@wirecat/cli-memo 0.131.41 → 0.131.43

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 (127) hide show
  1. package/dist/bin/memo.js +2 -2
  2. package/dist/bundle/{all-profiles-ZTYUFM24.js → all-profiles-NL4TH4VM.js} +5 -5
  3. package/dist/bundle/{anthropic-BLXCM7J2.js → anthropic-JTVP4FKR.js} +3 -3
  4. package/dist/bundle/{app-server-MXYDSTTW.js → app-server-FF6PISNB.js} +35 -35
  5. package/dist/bundle/auto-KUNM4M5S.js +86 -0
  6. package/dist/bundle/{bun-GFMA4TKJ.js → bun-OTDLXIRE.js} +2 -2
  7. package/dist/bundle/{bun-sqlite-3V6EB3XP.js → bun-sqlite-HXOV4SGX.js} +2 -2
  8. package/dist/bundle/{chunk-RMJLG2D6.js → chunk-2A42QHPZ.js} +4 -4
  9. package/dist/bundle/{chunk-2G66FZPO.js → chunk-2LHLMF3R.js} +1 -1
  10. package/dist/bundle/{chunk-OY2CMEUW.js → chunk-3Z4BMSVX.js} +3 -3
  11. package/dist/bundle/{chunk-IJS2X4AZ.js → chunk-5HCWKNSM.js} +43 -43
  12. package/dist/bundle/{chunk-RZUSWGAC.js → chunk-5MP7XPIP.js} +2 -2
  13. package/dist/bundle/{chunk-Y4B4273X.js → chunk-6WDOIKM6.js} +7 -7
  14. package/dist/bundle/{chunk-ARNYYXLO.js → chunk-AH7TKAUY.js} +20 -20
  15. package/dist/bundle/{chunk-Y7XDV4GQ.js → chunk-BGNGOAG6.js} +6 -6
  16. package/dist/bundle/{chunk-DYSWDGOU.js → chunk-BIVHDUAX.js} +5 -5
  17. package/dist/bundle/{chunk-776YSJJY.js → chunk-C67763MQ.js} +1 -1
  18. package/dist/bundle/{chunk-LLL4RBDU.js → chunk-CIN7A3OM.js} +11 -11
  19. package/dist/bundle/{chunk-UA2H5FRV.js → chunk-DTODXX7Y.js} +1 -1
  20. package/dist/bundle/{chunk-3MVDNB6Y.js → chunk-DYX5ATS5.js} +3 -3
  21. package/dist/bundle/{chunk-ZETAM63O.js → chunk-ELAZVPZT.js} +1 -1
  22. package/dist/bundle/{chunk-BA3HPVBN.js → chunk-FJVQDWVV.js} +4 -4
  23. package/dist/bundle/{chunk-BFN5KXGH.js → chunk-G7QBCTF6.js} +333 -293
  24. package/dist/bundle/{chunk-ISVO2PHD.js → chunk-GCTZK5QV.js} +4 -4
  25. package/dist/bundle/{chunk-PPSIMMJM.js → chunk-GPT5MFYG.js} +17 -9
  26. package/dist/bundle/{chunk-JO3FC5B4.js → chunk-IJC57CPU.js} +7 -7
  27. package/dist/bundle/{chunk-WG3JJ7D5.js → chunk-IRHRNK2E.js} +1 -1
  28. package/dist/bundle/{chunk-SCIU5WHL.js → chunk-J3V25QFZ.js} +3 -3
  29. package/dist/bundle/{chunk-ULDE2Y7M.js → chunk-K44PG5V3.js} +49 -48
  30. package/dist/bundle/{chunk-2O2BSM4K.js → chunk-L5NN6UER.js} +1 -1
  31. package/dist/bundle/{chunk-WFME7ILV.js → chunk-LAMKU426.js} +5 -5
  32. package/dist/bundle/{chunk-NYNUDUFA.js → chunk-LDQYIKJH.js} +4 -4
  33. package/dist/bundle/{chunk-YNYOWOKD.js → chunk-LGQZNRNK.js} +149 -149
  34. package/dist/bundle/{chunk-NFN3JTGD.js → chunk-LSGFFIMA.js} +12 -12
  35. package/dist/bundle/{chunk-7GEK5BE5.js → chunk-LUHQEQA4.js} +2 -2
  36. package/dist/bundle/{chunk-XXDWCZRM.js → chunk-LUTZSIA6.js} +1 -1
  37. package/dist/bundle/{chunk-IJJ4OEXK.js → chunk-MISLCCYA.js} +1 -1
  38. package/dist/bundle/{chunk-J364I2EL.js → chunk-MLVYZIXB.js} +8 -8
  39. package/dist/bundle/{chunk-QUA7EHLA.js → chunk-MYOXBUSI.js} +10 -10
  40. package/dist/bundle/{chunk-OLVBY6N6.js → chunk-N5K6NZ2F.js} +2 -2
  41. package/dist/bundle/{chunk-A6HC2DWU.js → chunk-NYJHYLKS.js} +56 -56
  42. package/dist/bundle/{chunk-RNINC74Q.js → chunk-O5FX3Q4U.js} +1 -1
  43. package/dist/bundle/{chunk-QCE6BNKK.js → chunk-PFWAQGHE.js} +2 -2
  44. package/dist/bundle/{chunk-G6EOW6PY.js → chunk-PIQUCN4T.js} +2 -2
  45. package/dist/bundle/{chunk-F3OGJQWY.js → chunk-Q52KLN53.js} +5 -5
  46. package/dist/bundle/{chunk-B5LF2FVU.js → chunk-RCCKUVQP.js} +1 -1
  47. package/dist/bundle/{chunk-AYOFFZMO.js → chunk-RENUU3BQ.js} +22 -4
  48. package/dist/bundle/{chunk-V5TOZXBU.js → chunk-RJM4D644.js} +1283 -767
  49. package/dist/bundle/{chunk-7EOGXNLO.js → chunk-SKV7GYNB.js} +4 -4
  50. package/dist/bundle/{chunk-2E4N5DVE.js → chunk-TBHX7VF5.js} +27 -27
  51. package/dist/bundle/{chunk-7AS5QFWJ.js → chunk-TVWO7K4U.js} +5 -5
  52. package/dist/bundle/{chunk-S7TVQ7ES.js → chunk-TYIENI7Z.js} +305 -248
  53. package/dist/bundle/{chunk-VT4PCMY2.js → chunk-U3VDEHXY.js} +1 -1
  54. package/dist/bundle/{chunk-6V6VCYOS.js → chunk-U7MRZIBF.js} +3 -3
  55. package/dist/bundle/{chunk-NP7Y3JQ7.js → chunk-USAH53BQ.js} +9 -9
  56. package/dist/bundle/{chunk-BJWDBPLF.js → chunk-VJ34VFZ5.js} +2 -2
  57. package/dist/bundle/{chunk-NKKC6SLX.js → chunk-VQPUADFF.js} +1 -1
  58. package/dist/bundle/{chunk-VF24JTL4.js → chunk-WBNWH2D5.js} +1 -1
  59. package/dist/bundle/{chunk-ONJAEHOD.js → chunk-WCFGYCVN.js} +7 -7
  60. package/dist/bundle/{chunk-LGILT5CA.js → chunk-WVZIP7Z5.js} +2 -2
  61. package/dist/bundle/{chunk-5KL7T2EP.js → chunk-XCFGMQBF.js} +1 -1
  62. package/dist/bundle/{chunk-FVN42IND.js → chunk-XFSE3ZGY.js} +1 -1
  63. package/dist/bundle/{chunk-N2EY7NT3.js → chunk-YHQ2XNNJ.js} +1 -1
  64. package/dist/bundle/{chunk-RMMYPYNA.js → chunk-YXPAEW6N.js} +24 -21
  65. package/dist/bundle/{command-contract-KCV6NNGF.js → command-contract-7LYHZI4Y.js} +11 -11
  66. package/dist/bundle/{decode-SU7TIUXV.js → decode-7PFJ3AKS.js} +2 -2
  67. package/dist/bundle/{echarts-CJG2WVOX.js → echarts-YDLD5JI2.js} +2 -2
  68. package/dist/bundle/{embed-IBURCPTK.js → embed-YDR7WSPK.js} +3 -3
  69. package/dist/bundle/{embedder-SK773RJG.js → embedder-KQYPQKZA.js} +6 -6
  70. package/dist/bundle/{entry-6WOJUMZN.js → entry-FD4B2GID.js} +4 -4
  71. package/dist/bundle/failure-FOZGSUOL.js +66 -0
  72. package/dist/bundle/{first-run-CMSDLJGE.js → first-run-C6HSAXYV.js} +5 -5
  73. package/dist/bundle/{first-screen-6IZLOQ3Q.js → first-screen-ZM3LZRP4.js} +12 -12
  74. package/dist/bundle/{instructions-RHGGUIBR.js → instructions-O7YN5F6D.js} +1 -1
  75. package/dist/bundle/{mcp-HBKMY35O.js → mcp-X5XYKVTY.js} +35 -35
  76. package/dist/bundle/memo.js +6 -6
  77. package/dist/bundle/{node-NBXEN7JU.js → node-YP265UUP.js} +2 -2
  78. package/dist/bundle/{node-sqlite-WAGIYOYR.js → node-sqlite-K3PWKXTB.js} +3 -3
  79. package/dist/bundle/{oauth-INSEXJD2.js → oauth-CUIDTJ5Z.js} +4 -4
  80. package/dist/bundle/{open-LXFV2C67.js → open-SHUV2BPO.js} +2 -2
  81. package/dist/bundle/{openai-OCWAXC7E.js → openai-LSBA5CCQ.js} +7 -7
  82. package/dist/bundle/{process-MRPJP32M.js → process-POGO7VDZ.js} +1 -1
  83. package/dist/bundle/{program-XKO4X6BB.js → program-DZ4TM3PS.js} +342 -90
  84. package/dist/bundle/{prompt-ROLOHFNO.js → prompt-V7SEBV7G.js} +2 -2
  85. package/dist/bundle/{recognize-63ZLC4DN.js → recognize-DK3N2GVZ.js} +1 -1
  86. package/dist/bundle/{remote-J4ZBFG3Y.js → remote-XYFCKYIQ.js} +4 -4
  87. package/dist/bundle/{rerank-HUQCCGYO.js → rerank-COKJGAIB.js} +4 -4
  88. package/dist/bundle/{serve-MFJYL4AB.js → serve-KW3AGGTZ.js} +6 -6
  89. package/dist/bundle/{server-2JQ5K33G.js → server-72N5XGA6.js} +50 -50
  90. package/dist/bundle/server-QZPRR4H3.js +48 -0
  91. package/dist/bundle/server-VPEPJSQM.js +61 -0
  92. package/dist/bundle/{state-AV5MO77W.js → state-KHK3S4AC.js} +3 -3
  93. package/dist/bundle/{store-H4HCVN4H.js → store-GGUL63V7.js} +9 -9
  94. package/dist/bundle/store-maintenance-command-3KI6LYZB.js +48 -0
  95. package/dist/bundle/update-OLU3IRV6.js +69 -0
  96. package/dist/discovery/command.d.ts.map +1 -1
  97. package/dist/discovery/command.js +3 -0
  98. package/dist/discovery/command.js.map +1 -1
  99. package/dist/doctor/command.d.ts +1 -1
  100. package/dist/examples.d.ts.map +1 -1
  101. package/dist/examples.js +19 -0
  102. package/dist/examples.js.map +1 -1
  103. package/dist/finance/deals-command.d.ts +22 -0
  104. package/dist/finance/deals-command.d.ts.map +1 -0
  105. package/dist/finance/deals-command.js +235 -0
  106. package/dist/finance/deals-command.js.map +1 -0
  107. package/dist/knowledge/project-status-command.d.ts.map +1 -1
  108. package/dist/knowledge/project-status-command.js +16 -8
  109. package/dist/knowledge/project-status-command.js.map +1 -1
  110. package/dist/program.d.ts.map +1 -1
  111. package/dist/program.js +65 -0
  112. package/dist/program.js.map +1 -1
  113. package/dist/rows.d.ts.map +1 -1
  114. package/dist/rows.js +18 -0
  115. package/dist/rows.js.map +1 -1
  116. package/dist/version.d.ts +1 -1
  117. package/dist/version.js +1 -1
  118. package/package.json +2 -2
  119. package/skills/cli-memo/topics/money.md +6 -0
  120. package/skills/cli-memo/topics/projects.md +2 -1
  121. package/dist/bundle/auto-2RK6FE5A.js +0 -86
  122. package/dist/bundle/failure-4N6GOEGN.js +0 -66
  123. package/dist/bundle/server-RKPGL53W.js +0 -48
  124. package/dist/bundle/server-ZN2KC4EE.js +0 -61
  125. package/dist/bundle/store-maintenance-command-4GYOMUXE.js +0 -48
  126. package/dist/bundle/update-ATXEHV72.js +0 -69
  127. /package/dist/bundle/{chunk-VVDYRHYP.js → chunk-SWSCSMAU.js} +0 -0
@@ -100,11 +100,11 @@ import {
100
100
  validateQuery,
101
101
  walkQuery,
102
102
  zonedMoment
103
- } from "./chunk-A6HC2DWU.js";
103
+ } from "./chunk-NYJHYLKS.js";
104
104
  import {
105
105
  holdsCredential,
106
106
  secretNamed
107
- } from "./chunk-XXDWCZRM.js";
107
+ } from "./chunk-LUTZSIA6.js";
108
108
  import {
109
109
  DEFAULT_STEMMERS,
110
110
  DEFAULT_STEMMERS_VERSION,
@@ -117,26 +117,26 @@ import {
117
117
  fold,
118
118
  normalize,
119
119
  parseStemmers
120
- } from "./chunk-Y4B4273X.js";
120
+ } from "./chunk-6WDOIKM6.js";
121
121
  import {
122
122
  DEFAULT_TASK_CATEGORIES,
123
123
  sharedConfigPath,
124
124
  storedTaskCategories,
125
125
  taskCategoriesReader
126
- } from "./chunk-ISVO2PHD.js";
126
+ } from "./chunk-GCTZK5QV.js";
127
127
  import {
128
128
  refuseOwnerStoreInTests,
129
129
  storePath
130
- } from "./chunk-FVN42IND.js";
130
+ } from "./chunk-XFSE3ZGY.js";
131
131
  import {
132
132
  quietSqliteWarning,
133
133
  storeCapable
134
- } from "./chunk-F3OGJQWY.js";
134
+ } from "./chunk-Q52KLN53.js";
135
135
  import {
136
136
  PRAGMAS,
137
137
  TIME_LIMIT_FUNCTION,
138
138
  TimeLimitReached
139
- } from "./chunk-UA2H5FRV.js";
139
+ } from "./chunk-DTODXX7Y.js";
140
140
  import {
141
141
  array,
142
142
  boolean,
@@ -186,7 +186,7 @@ import {
186
186
  sql,
187
187
  sqliteTable,
188
188
  text
189
- } from "./chunk-VF24JTL4.js";
189
+ } from "./chunk-WBNWH2D5.js";
190
190
  import {
191
191
  __commonJS,
192
192
  __name,
@@ -9930,7 +9930,7 @@ var require_cjs = __commonJS({
9930
9930
  }
9931
9931
  });
9932
9932
 
9933
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/account-store.js
9933
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/account-store.js
9934
9934
  var bindArea = /* @__PURE__ */ __name(({ keyed, whole }, account) => {
9935
9935
  const methods = whole;
9936
9936
  return Object.fromEntries(Object.keys(keyed).map((name) => [
@@ -10058,7 +10058,7 @@ var bindAccount = /* @__PURE__ */ __name((store, account, areas, owners) => {
10058
10058
  };
10059
10059
  }, "bindAccount");
10060
10060
 
10061
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/locator.js
10061
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/locator.js
10062
10062
  var SCHEME = "msg:";
10063
10063
  var formatLocator = /* @__PURE__ */ __name(({ provider, account, chat: chat2, message: message2 }) => SCHEME + [provider, account, chat2, message2].map(encodeURIComponent).join("/"), "formatLocator");
10064
10064
  var isLocator = /* @__PURE__ */ __name((reference2) => reference2.trim().startsWith(SCHEME), "isLocator");
@@ -10072,7 +10072,7 @@ var parseLocator = /* @__PURE__ */ __name((reference2) => {
10072
10072
  return { provider, account, chat: chat2, message: message2 };
10073
10073
  }, "parseLocator");
10074
10074
 
10075
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/references.js
10075
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/references.js
10076
10076
  var SIMPLE_REFERENCES = [
10077
10077
  "note",
10078
10078
  "document",
@@ -10087,6 +10087,9 @@ var SIMPLE_REFERENCES = [
10087
10087
  "invoice",
10088
10088
  "payment",
10089
10089
  "order",
10090
+ "deal",
10091
+ "lead",
10092
+ "pipeline",
10090
10093
  "entity"
10091
10094
  ];
10092
10095
  var malformed = /* @__PURE__ */ __name((text6, shape) => new CliError("validation_error", `"${singleLine(text6)}" is not a reference \u2014 expected ${shape}`, {
@@ -10220,8 +10223,8 @@ var looksLikeReference = /* @__PURE__ */ __name((text6) => {
10220
10223
  return match !== null && byPrefix.has(match[1]);
10221
10224
  }, "looksLikeReference");
10222
10225
 
10223
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/providers.js
10224
- var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events"];
10226
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/providers.js
10227
+ var KINDS = ["messages", "mail", "notes", "documents", "meetings", "events", "crm"];
10225
10228
  var MESSENGER_OPENS = { chat: "messages list", message: "messages show", contact: "contacts show" };
10226
10229
  var PROVIDERS = [
10227
10230
  { name: "telegram", kind: "messages", aliases: ["tg"], command: "tg", opens: MESSENGER_OPENS },
@@ -10336,7 +10339,7 @@ var providerNamed = /* @__PURE__ */ __name((word2) => {
10336
10339
  var kindIn = /* @__PURE__ */ __name((provider) => isFolderProvider(provider) ? "notes" : registry.find(({ name }) => name === provider)?.kind, "kindIn");
10337
10340
  var kindOf = /* @__PURE__ */ __name((provider) => kindIn(provider) ?? "messages", "kindOf");
10338
10341
 
10339
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/query.js
10342
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/query.js
10340
10343
  var isBotProvider = /* @__PURE__ */ __name((provider) => provider.endsWith("-bot"), "isBotProvider");
10341
10344
  var inSource = /* @__PURE__ */ __name((source2, provider) => source2 === "all" || source2 === "bots" && isBotProvider(provider) || source2 === "personal" && !isBotProvider(provider) || source2 === provider || providerNamed(source2)?.name === provider || isKind(source2) && kindOf(provider) === source2, "inSource");
10342
10345
  var fail = /* @__PURE__ */ __name((message2) => {
@@ -10359,7 +10362,7 @@ var sourceOf = /* @__PURE__ */ __name((name, value, providers2) => {
10359
10362
  return fail(`${name} takes ${[...sources, "messages", "mail"].join(", ")} \u2014 not "${value}"`);
10360
10363
  }, "sourceOf");
10361
10364
 
10362
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/account-list.js
10365
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/account-list.js
10363
10366
  var ACCOUNT_GROUPS = "accountGroups";
10364
10367
  var ACCOUNT_GROUPS_SETTING = "account_groups";
10365
10368
  var GROUP_NAME = /^[a-z0-9][a-z0-9_-]*$/i;
@@ -10521,7 +10524,8 @@ var READS = {
10521
10524
  notes: "notes \u2014 search notes reads them",
10522
10525
  documents: "documents \u2014 search notes reads them",
10523
10526
  meetings: "meetings \u2014 search all reads them",
10524
- events: "calendar events \u2014 no search reads them yet"
10527
+ events: "calendar events \u2014 no search reads them yet",
10528
+ crm: "CRM deals and leads \u2014 search all reads them"
10525
10529
  };
10526
10530
  var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf2 = (kind4) => READS[kind4]) => {
10527
10531
  const chosen = /* @__PURE__ */ new Map();
@@ -10546,7 +10550,7 @@ var fitting = /* @__PURE__ */ __name((entries, kinds2, what, reasonOf2 = (kind4)
10546
10550
  return { accounts: [...chosen.values()], skipped };
10547
10551
  }, "fitting");
10548
10552
 
10549
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
10553
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/drizzle/core.js
10550
10554
  var IndexBuilderOn = class {
10551
10555
  static {
10552
10556
  __name(this, "IndexBuilderOn");
@@ -10741,7 +10745,7 @@ function alias(table, alias2) {
10741
10745
  }
10742
10746
  __name(alias, "alias");
10743
10747
 
10744
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
10748
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/entity-types.js
10745
10749
  var ENTITY_TABLES = {
10746
10750
  account: "accounts",
10747
10751
  attachment: "attachments",
@@ -10749,6 +10753,7 @@ var ENTITY_TABLES = {
10749
10753
  calendar_entry: "calendar_entries",
10750
10754
  chat: "chats",
10751
10755
  conversation: "conversations",
10756
+ deal: "deals",
10752
10757
  document: "documents",
10753
10758
  document_picture: "documents",
10754
10759
  email: "emails",
@@ -10760,6 +10765,7 @@ var ENTITY_TABLES = {
10760
10765
  identity: "identities",
10761
10766
  image: "attachments",
10762
10767
  invoice: "invoices",
10768
+ lead: "leads",
10763
10769
  meeting: "meetings",
10764
10770
  meeting_transcript: "meeting_transcripts",
10765
10771
  meeting_transcript_row: "meeting_transcript_rows",
@@ -10770,6 +10776,7 @@ var ENTITY_TABLES = {
10770
10776
  organization: "organizations",
10771
10777
  payment: "payments",
10772
10778
  person: "persons",
10779
+ pipeline: "pipelines",
10773
10780
  place: "places",
10774
10781
  project: "projects",
10775
10782
  tag: "canonical_tags",
@@ -10784,7 +10791,7 @@ var orphanPointers = /* @__PURE__ */ __name((database) => pointerPairs(database)
10784
10791
  return { table, pointer, type, count, known: known2 };
10785
10792
  }).filter(({ count }) => count > 0)), "orphanPointers");
10786
10793
 
10787
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
10794
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/canonical-tags.js
10788
10795
  var canonicalTags = sqliteTable("canonical_tags", {
10789
10796
  id: integer("id").primaryKey(),
10790
10797
  name: text("name").notNull().unique(),
@@ -10793,7 +10800,7 @@ var canonicalTags = sqliteTable("canonical_tags", {
10793
10800
  updatedAt: integer("updated_at").notNull()
10794
10801
  });
10795
10802
 
10796
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
10803
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-transfers.js
10797
10804
  var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
10798
10805
  sourceKey: text("source_key").notNull(),
10799
10806
  collection: text("collection").notNull(),
@@ -10803,13 +10810,13 @@ var documentAnnotationTransfers = sqliteTable("document_annotation_transfers", {
10803
10810
  createdAt: integer("created_at").notNull()
10804
10811
  }, (table) => [primaryKey({ columns: [table.sourceKey, table.collection] })]);
10805
10812
 
10806
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
10813
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/document-index-pending.js
10807
10814
  var documentIndexPending = sqliteTable("document_index_pending", {
10808
10815
  id: integer("id").notNull(),
10809
10816
  indexableType: text("indexable_type").notNull()
10810
10817
  }, (table) => [primaryKey({ columns: [table.indexableType, table.id] })]);
10811
10818
 
10812
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
10819
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema/tag-consolidations.js
10813
10820
  var tagRedirects = sqliteTable("tag_redirects", {
10814
10821
  sourceId: integer("source_id").primaryKey().references(() => canonicalTags.id),
10815
10822
  survivorId: integer("survivor_id").notNull().references(() => canonicalTags.id),
@@ -10835,7 +10842,7 @@ var tagConsolidations = sqliteTable("tag_consolidations", {
10835
10842
  index("tag_consolidations_by_actor_type_actor_id").on(table.actorType, table.actorId)
10836
10843
  ]);
10837
10844
 
10838
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
10845
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/schema.js
10839
10846
  var accounts = sqliteTable("accounts", {
10840
10847
  id: integer("id").primaryKey(),
10841
10848
  provider: text("provider").notNull(),
@@ -12161,6 +12168,108 @@ var orders = sqliteTable("orders", {
12161
12168
  index("orders_by_author_type_author_id").on(table.authorType, table.authorId),
12162
12169
  index("orders_by_confirmed_by_type_confirmed_by_id").on(table.confirmedByType, table.confirmedById)
12163
12170
  ]);
12171
+ var pipelines = sqliteTable("pipelines", {
12172
+ id: integer("id").primaryKey(),
12173
+ accountId: integer("account_id").references(() => accounts.id),
12174
+ externalId: text("external_id"),
12175
+ kind: text("kind").notNull().default("deal"),
12176
+ name: text("name").notNull(),
12177
+ nameFolded: text("name_folded").notNull(),
12178
+ createdAt: integer("created_at").notNull(),
12179
+ updatedAt: integer("updated_at").notNull()
12180
+ }, (table) => [
12181
+ uniqueIndex("pipelines_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
12182
+ uniqueIndex("pipelines_by_name_folded_kind").on(table.nameFolded, table.kind).where(sql`account_id IS NULL`)
12183
+ ]);
12184
+ var pipelineStages = sqliteTable("pipeline_stages", {
12185
+ id: integer("id").primaryKey(),
12186
+ pipelineId: integer("pipeline_id").notNull().references(() => pipelines.id),
12187
+ name: text("name").notNull(),
12188
+ nameFolded: text("name_folded").notNull(),
12189
+ position: integer("position").notNull(),
12190
+ outcome: text("outcome").notNull().default("open"),
12191
+ externalId: text("external_id"),
12192
+ createdAt: integer("created_at").notNull(),
12193
+ updatedAt: integer("updated_at").notNull()
12194
+ }, (table) => [
12195
+ unique().on(table.pipelineId, table.nameFolded),
12196
+ uniqueIndex("pipeline_stages_by_pipeline_id_external_id").on(table.pipelineId, table.externalId).where(sql`external_id IS NOT NULL`),
12197
+ index("pipeline_stages_by_pipeline_id_position").on(table.pipelineId, table.position)
12198
+ ]);
12199
+ var deals = sqliteTable("deals", {
12200
+ id: integer("id").primaryKey(),
12201
+ title: text("title").notNull(),
12202
+ organizationId: integer("organization_id").references(() => organizations.id),
12203
+ projectId: integer("project_id").references(() => projects.id),
12204
+ stageId: integer("stage_id").notNull().references(() => pipelineStages.id),
12205
+ status: text("status").notNull(),
12206
+ currency: text("currency"),
12207
+ amount: integer("amount"),
12208
+ closeDate: text("close_date"),
12209
+ closedDate: text("closed_date"),
12210
+ rank: real("rank"),
12211
+ accountId: integer("account_id").references(() => accounts.id),
12212
+ externalId: text("external_id"),
12213
+ authorType: text("author_type").notNull(),
12214
+ authorId: integer("author_id").notNull(),
12215
+ model: text("model"),
12216
+ source: text("source").notNull(),
12217
+ metadata: text("metadata"),
12218
+ createdAt: integer("created_at").notNull(),
12219
+ updatedAt: integer("updated_at").notNull(),
12220
+ deletedAt: integer("deleted_at")
12221
+ }, (table) => [
12222
+ uniqueIndex("deals_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
12223
+ index("deals_by_organization_id").on(table.organizationId),
12224
+ index("deals_by_project_id").on(table.projectId),
12225
+ index("deals_by_stage_id").on(table.stageId),
12226
+ index("deals_by_author_type_author_id").on(table.authorType, table.authorId)
12227
+ ]);
12228
+ var leads = sqliteTable("leads", {
12229
+ id: integer("id").primaryKey(),
12230
+ title: text("title").notNull(),
12231
+ organizationId: integer("organization_id").references(() => organizations.id),
12232
+ projectId: integer("project_id").references(() => projects.id),
12233
+ stageId: integer("stage_id").notNull().references(() => pipelineStages.id),
12234
+ status: text("status").notNull(),
12235
+ currency: text("currency"),
12236
+ amount: integer("amount"),
12237
+ closeDate: text("close_date"),
12238
+ closedDate: text("closed_date"),
12239
+ rank: real("rank"),
12240
+ dealId: integer("deal_id").references(() => deals.id),
12241
+ accountId: integer("account_id").references(() => accounts.id),
12242
+ externalId: text("external_id"),
12243
+ authorType: text("author_type").notNull(),
12244
+ authorId: integer("author_id").notNull(),
12245
+ model: text("model"),
12246
+ source: text("source").notNull(),
12247
+ metadata: text("metadata"),
12248
+ createdAt: integer("created_at").notNull(),
12249
+ updatedAt: integer("updated_at").notNull(),
12250
+ deletedAt: integer("deleted_at")
12251
+ }, (table) => [
12252
+ uniqueIndex("leads_by_account_id_external_id").on(table.accountId, table.externalId).where(sql`account_id IS NOT NULL AND external_id IS NOT NULL`),
12253
+ index("leads_by_organization_id").on(table.organizationId),
12254
+ index("leads_by_project_id").on(table.projectId),
12255
+ index("leads_by_stage_id").on(table.stageId),
12256
+ index("leads_by_deal_id").on(table.dealId),
12257
+ index("leads_by_author_type_author_id").on(table.authorType, table.authorId)
12258
+ ]);
12259
+ var pipelineStageChanges = sqliteTable("pipeline_stage_changes", {
12260
+ id: integer("id").primaryKey(),
12261
+ itemType: text("item_type").notNull(),
12262
+ itemId: integer("item_id").notNull(),
12263
+ pipelineId: integer("pipeline_id").notNull().references(() => pipelines.id),
12264
+ fromStageId: integer("from_stage_id").references(() => pipelineStages.id),
12265
+ toStageId: integer("to_stage_id").notNull().references(() => pipelineStages.id),
12266
+ changedAt: integer("changed_at").notNull()
12267
+ }, (table) => [
12268
+ index("pipeline_stage_changes_by_item_type_item_id").on(table.itemType, table.itemId),
12269
+ index("pipeline_stage_changes_by_pipeline_id").on(table.pipelineId),
12270
+ index("pipeline_stage_changes_by_from_stage_id").on(table.fromStageId),
12271
+ index("pipeline_stage_changes_by_to_stage_id").on(table.toStageId)
12272
+ ]);
12164
12273
  var records = sqliteTable("records", {
12165
12274
  id: integer("id").primaryKey(),
12166
12275
  accountId: integer("account_id").notNull().references(() => accounts.id),
@@ -12502,7 +12611,7 @@ var storeSettings = sqliteTable("store_settings", {
12502
12611
  at: integer("at").notNull()
12503
12612
  });
12504
12613
 
12505
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
12614
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/involvement-queue.js
12506
12615
  var ARMS = [
12507
12616
  [
12508
12617
  "message",
@@ -12629,7 +12738,7 @@ var drainInvolvementQueue = /* @__PURE__ */ __name((database, cap = QUEUE_CAP) =
12629
12738
  return recomputed;
12630
12739
  }, "drainInvolvementQueue");
12631
12740
 
12632
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/mentions.js
12741
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/mentions.js
12633
12742
  import { domainToUnicode } from "node:url";
12634
12743
 
12635
12744
  // node_modules/.pnpm/psl@1.15.0/node_modules/psl/dist/psl.mjs
@@ -22651,7 +22760,7 @@ var oa = /* @__PURE__ */ __name((e) => {
22651
22760
  }, "oa");
22652
22761
  var na = { parse: O, get: aa, isValid: oa };
22653
22762
 
22654
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
22763
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/google-documents.js
22655
22764
  var LINK = /https?:\/\/(?:(?:docs|drive|sheets|slides)\.google\.com|forms\.gle)(?:[/?#][^\s<>"'`]*)?/gi;
22656
22765
  var ID = /^[\w-]{10,}$/;
22657
22766
  var trimUrl = /* @__PURE__ */ __name((url) => {
@@ -22692,7 +22801,7 @@ var googleDocumentLinks = /* @__PURE__ */ __name((text6) => [...text6.matchAll(L
22692
22801
  return { url, documentId: googleDocumentId(url) };
22693
22802
  }), "googleDocumentLinks");
22694
22803
 
22695
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
22804
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/phone-plans.generated.js
22696
22805
  var PHONE_PLANS = [
22697
22806
  {
22698
22807
  country: "us",
@@ -23072,7 +23181,7 @@ var PHONE_PLANS = [
23072
23181
  }
23073
23182
  ];
23074
23183
 
23075
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/phones.js
23184
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/phones.js
23076
23185
  var PHONE_COUNTRIES = PHONE_PLANS.map((plan) => plan.country);
23077
23186
  var DEFAULT_PHONE_COUNTRIES = ["ru"];
23078
23187
  var parsePhoneCountries = /* @__PURE__ */ __name((value) => {
@@ -23113,7 +23222,7 @@ var nationalPhone = /* @__PURE__ */ __name((digits, countries, { anyType }) => {
23113
23222
  return void 0;
23114
23223
  }, "nationalPhone");
23115
23224
 
23116
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/places.js
23225
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/places.js
23117
23226
  var BEFORE = [
23118
23227
  [/^(?:ул\.?|улиц[аеыу]|улицей)$/iu, "\u0443\u043B\u0438\u0446\u0430"],
23119
23228
  [/^(?:пр-т|просп\.?|проспект[аеу]?)$/iu, "\u043F\u0440\u043E\u0441\u043F\u0435\u043A\u0442"],
@@ -23373,7 +23482,7 @@ var findPlaces = /* @__PURE__ */ __name((text6) => {
23373
23482
  return found2.sort((a, b) => a.start - b.start);
23374
23483
  }, "findPlaces");
23375
23484
 
23376
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/mentions.js
23485
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/mentions.js
23377
23486
  var MENTION_KINDS = ["phone", "email", "url", "document", "person-name", "place"];
23378
23487
  var MENTION_VERSIONS = {
23379
23488
  phone: 1,
@@ -23563,7 +23672,7 @@ var typedPhone = /* @__PURE__ */ __name((typed, { phoneCountries = DEFAULT_PHONE
23563
23672
  };
23564
23673
  }, "typedPhone");
23565
23674
 
23566
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/first-names.js
23675
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/first-names.js
23567
23676
  var RUSSIAN = "\u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440 \u0410\u043B\u0435\u043A\u0441\u0435\u0439 \u0410\u043D\u0430\u0442\u043E\u043B\u0438\u0439 \u0410\u043D\u0434\u0440\u0435\u0439 \u0410\u043D\u0442\u043E\u043D \u0410\u0440\u043A\u0430\u0434\u0438\u0439 \u0410\u0440\u0441\u0435\u043D\u0438\u0439 \u0410\u0440\u0442\u0451\u043C \u0410\u0440\u0442\u0435\u043C \u0410\u0440\u0442\u0443\u0440 \u0411\u043E\u0440\u0438\u0441 \u0412\u0430\u0434\u0438\u043C \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D \u0412\u0430\u043B\u0435\u0440\u0438\u0439 \u0412\u0430\u0441\u0438\u043B\u0438\u0439 \u0412\u0438\u043A\u0442\u043E\u0440 \u0412\u0438\u0442\u0430\u043B\u0438\u0439 \u0412\u043B\u0430\u0434\u0438\u043C\u0438\u0440 \u0412\u043B\u0430\u0434\u0438\u0441\u043B\u0430\u0432 \u0412\u0441\u0435\u0432\u043E\u043B\u043E\u0434 \u0412\u044F\u0447\u0435\u0441\u043B\u0430\u0432 \u0413\u0435\u043D\u043D\u0430\u0434\u0438\u0439 \u0413\u0435\u043E\u0440\u0433\u0438\u0439 \u0413\u043B\u0435\u0431 \u0413\u0440\u0438\u0433\u043E\u0440\u0438\u0439 \u0414\u0430\u043D\u0438\u0438\u043B \u0414\u0430\u043D\u0438\u043B\u0430 \u0414\u0435\u043D\u0438\u0441 \u0414\u043C\u0438\u0442\u0440\u0438\u0439 \u0415\u0432\u0433\u0435\u043D\u0438\u0439 \u0415\u0433\u043E\u0440 \u0418\u0432\u0430\u043D \u0418\u0433\u043E\u0440\u044C \u0418\u043B\u044C\u044F \u041A\u0438\u0440\u0438\u043B\u043B \u041A\u043E\u043D\u0441\u0442\u0430\u043D\u0442\u0438\u043D \u041B\u0435\u043E\u043D\u0438\u0434 \u041C\u0430\u043A\u0441\u0438\u043C \u041C\u0430\u0440\u0430\u0442 \u041C\u0430\u0442\u0432\u0435\u0439 \u041C\u0438\u0445\u0430\u0438\u043B \u041D\u0438\u043A\u0438\u0442\u0430 \u041D\u0438\u043A\u043E\u043B\u0430\u0439 \u041E\u043B\u0435\u0433 \u041F\u0430\u0432\u0435\u043B \u041F\u0451\u0442\u0440 \u041F\u0435\u0442\u0440 \u0420\u043E\u0434\u0438\u043E\u043D \u0420\u043E\u0441\u0442\u0438\u0441\u043B\u0430\u0432 \u0420\u0443\u0441\u043B\u0430\u043D \u0420\u0443\u0441\u0442\u0430\u043C \u0421\u0435\u043C\u0451\u043D \u0421\u0435\u043C\u0435\u043D \u0421\u0435\u0440\u0433\u0435\u0439 \u0421\u0442\u0430\u043D\u0438\u0441\u043B\u0430\u0432 \u0421\u0442\u0435\u043F\u0430\u043D \u0422\u0438\u043C\u043E\u0444\u0435\u0439 \u0422\u0438\u043C\u0443\u0440 \u0424\u0451\u0434\u043E\u0440 \u0424\u0435\u0434\u043E\u0440 \u0424\u0438\u043B\u0438\u043F\u043F \u042D\u0434\u0443\u0430\u0440\u0434 \u042E\u0440\u0438\u0439 \u042F\u0440\u043E\u0441\u043B\u0430\u0432 \u042F\u043A\u043E\u0432 \u042D\u043B\u044C\u0434\u0430\u0440 \u0414\u0430\u0432\u0438\u0434 \u0417\u0430\u0445\u0430\u0440 \u0421\u0430\u0432\u0435\u043B\u0438\u0439 \u041C\u0438\u0440\u043E\u043D \u041F\u043B\u0430\u0442\u043E\u043D \u0414\u0435\u043C\u0438\u0434 \u0410\u0440\u0441\u0435\u043D \u041D\u0443\u0440\u043B\u0430\u043D \u0410\u043D\u0437\u043E\u0440 \u0410\u043B\u0435\u043A\u0441\u0430\u043D\u0434\u0440\u0430 \u0410\u043B\u0438\u043D\u0430 \u0410\u043B\u0438\u0441\u0430 \u0410\u043B\u043B\u0430 \u0410\u043D\u0430\u0441\u0442\u0430\u0441\u0438\u044F \u0410\u043D\u0433\u0435\u043B\u0438\u043D\u0430 \u0410\u043D\u043D\u0430 \u0410\u043D\u0442\u043E\u043D\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u043D\u0442\u0438\u043D\u0430 \u0412\u0430\u043B\u0435\u0440\u0438\u044F \u0412\u0430\u0440\u0432\u0430\u0440\u0430 \u0412\u0435\u0440\u043E\u043D\u0438\u043A\u0430 \u0412\u0438\u043A\u0442\u043E\u0440\u0438\u044F \u0413\u0430\u043B\u0438\u043D\u0430 \u0414\u0430\u0440\u044C\u044F \u0414\u0438\u0430\u043D\u0430 \u0415\u0432\u0433\u0435\u043D\u0438\u044F \u0415\u043A\u0430\u0442\u0435\u0440\u0438\u043D\u0430 \u0415\u043B\u0435\u043D\u0430 \u0415\u043B\u0438\u0437\u0430\u0432\u0435\u0442\u0430 \u0416\u0430\u043D\u043D\u0430 \u0417\u0438\u043D\u0430\u0438\u0434\u0430 \u041A\u0430\u0440\u0438\u043D\u0430 \u041A\u0438\u0440\u0430 \u041A\u043B\u0430\u0432\u0434\u0438\u044F \u041A\u0440\u0438\u0441\u0442\u0438\u043D\u0430 \u041A\u0441\u0435\u043D\u0438\u044F \u041B\u0430\u0440\u0438\u0441\u0430 \u041B\u0438\u0434\u0438\u044F \u041B\u044E\u0434\u043C\u0438\u043B\u0430 \u041C\u0430\u0440\u0433\u0430\u0440\u0438\u0442\u0430 \u041C\u0430\u0440\u0438\u043D\u0430 \u041C\u0430\u0440\u0438\u044F \u041C\u0438\u043B\u0430\u043D\u0430 \u041D\u0430\u0442\u0430\u043B\u044C\u044F \u041D\u0430\u0442\u0430\u043B\u0438\u044F \u041D\u0438\u043D\u0430 \u041E\u043A\u0441\u0430\u043D\u0430 \u041E\u043B\u0435\u0441\u044F \u041E\u043B\u044C\u0433\u0430 \u041F\u043E\u043B\u0438\u043D\u0430 \u0420\u0430\u0438\u0441\u0430 \u0421\u0432\u0435\u0442\u043B\u0430\u043D\u0430 \u0421\u043E\u0444\u0438\u044F \u0421\u043E\u0444\u044C\u044F \u0422\u0430\u0438\u0441\u0438\u044F \u0422\u0430\u043C\u0430\u0440\u0430 \u0422\u0430\u0442\u044C\u044F\u043D\u0430 \u0423\u043B\u044C\u044F\u043D\u0430 \u042E\u043B\u0438\u044F \u042D\u043B\u044C\u0432\u0438\u0440\u0430 \u0420\u0435\u0433\u0438\u043D\u0430 \u0421\u043D\u0435\u0436\u0430\u043D\u0430 \u0410\u043B\u0451\u043D\u0430 \u0410\u043B\u0435\u043D\u0430 \u0412\u0430\u0441\u0438\u043B\u0438\u0441\u0430 \u0410\u0440\u0438\u043D\u0430 \u0415\u0441\u0435\u043D\u0438\u044F \u042D\u0432\u0435\u043B\u0438\u043D\u0430 \u0421\u0430\u0448\u0430 \u0416\u0435\u043D\u044F \u0412\u0430\u043B\u044F \u0414\u0438\u043C\u0430 \u041C\u0438\u0448\u0430 \u041A\u043E\u043B\u044F \u041F\u0435\u0442\u044F \u0412\u0430\u0441\u044F \u0421\u0435\u0440\u0451\u0436\u0430 \u0421\u0435\u0440\u0435\u0436\u0430 \u041F\u0430\u0448\u0430 \u041B\u0451\u0448\u0430 \u041B\u0435\u0448\u0430 \u0412\u0438\u0442\u044F \u041A\u043E\u0441\u0442\u044F \u0412\u043E\u0432\u0430 \u0412\u043E\u043B\u043E\u0434\u044F \u0412\u0430\u043D\u044F \u0413\u043E\u0448\u0430 \u0413\u0440\u0438\u0448\u0430 \u0422\u043E\u043B\u044F \u0411\u043E\u0440\u044F \u0421\u0442\u0430\u0441 \u0422\u0451\u043C\u0430 \u0422\u0430\u043D\u044F \u041A\u0430\u0442\u044F \u041B\u0435\u043D\u0430 \u041D\u0430\u0442\u0430\u0448\u0430 \u0421\u0432\u0435\u0442\u0430 \u042E\u043B\u044F \u041D\u0430\u0441\u0442\u044F \u0414\u0430\u0448\u0430 \u041C\u0430\u0448\u0430 \u041B\u044E\u0434\u0430 \u0413\u0430\u043B\u044F \u0412\u0438\u043A\u0430 \u041A\u0441\u044E\u0448\u0430 \u041B\u0438\u0437\u0430 \u0421\u043E\u043D\u044F \u041D\u0430\u0434\u044F \u041B\u0435\u0440\u0430 \u0410\u043B\u0451\u0448\u0430 \u0410\u043B\u0435\u0448\u0430 \u041C\u0438\u0442\u044F \u0421\u0435\u043D\u044F \u0424\u0435\u0434\u044F \u0416\u0435\u043D\u0435\u0447\u043A\u0430 \u041E\u043B\u0435\u043D\u044C\u043A\u0430 \u0422\u0430\u043D\u0435\u0447\u043A\u0430";
23568
23677
  var EUROPEAN = "James John Robert Michael William David Richard Joseph Thomas Charles Christopher Daniel Matthew Anthony Donald Steven Paul Andrew Joshua Kenneth Kevin Brian George Timothy Ronald Edward Jason Jeffrey Ryan Jacob Gary Nicholas Eric Jonathan Stephen Larry Justin Scott Brandon Benjamin Samuel Gregory Alexander Patrick Raymond Dennis Jerry Tyler Aaron Nathan Henry Peter Zachary Douglas Harold Kyle Noah Ethan Oliver Harry Lucas Liam Mary Patricia Jennifer Linda Elizabeth Barbara Susan Jessica Sarah Karen Lisa Nancy Betty Margaret Sandra Ashley Kimberly Emily Donna Michelle Carol Amanda Dorothy Melissa Deborah Stephanie Rebecca Sharon Laura Cynthia Kathleen Angela Shirley Anna Brenda Pamela Emma Nicole Helen Samantha Katherine Christine Rachel Carolyn Janet Catherine Maria Heather Diane Ruth Julie Olivia Joyce Kelly Lauren Christina Joan Evelyn Judith Megan Andrea Cheryl Hannah Jacqueline Martha Teresa Sara Madison Frances Kathryn Janice Abigail Alice Julia Judy Sophia Denise Doris Marilyn Danielle Beverly Isabella Theresa Diana Natalie Charlotte Marie Kayla Alexis Javier Carlos Antonio Manuel Francisco Juan Pedro Alejandro Miguel Rafael Pablo Sergio Fernando Jorge Luis Alberto \xC1lvaro Diego Adri\xE1n Rub\xE9n Iv\xE1n \xD3scar Andr\xE9s Ra\xFAl Enrique Vicente Joaqu\xEDn Ignacio Gonzalo Marcos V\xEDctor Jaime Alfonso Guillermo Tom\xE1s Emilio Gabriel Nicol\xE1s Mart\xEDn Jordi Josep Xavier Luc\xEDa Carmen Isabel Cristina Marta Elena Raquel Silvia Beatriz Paula Nuria N\xFAria Sonia Alicia Irene Montserrat Inmaculada Noelia Lorena Sof\xEDa Valeria Claudia Natalia Sandra Ver\xF3nica Esther Yolanda Vanesa Laia Klaus J\xFCrgen Wolfgang Stefan Andreas Matthias Markus Tobias Florian Lukas Jonas Maximilian Sebastian Dirk Sabine Ursula Petra Monika Katrin Anja Pierre Michel Philippe Alain Fran\xE7ois Christophe Laurent Olivier Julien Mathieu S\xE9bastien Guillaume Antoine Camille Nathalie Isabelle Sylvie Sophie C\xE9line Aur\xE9lie Chlo\xE9 Manon Giuseppe Giovanni Marco Luca Francesco Alessandro Matteo Lorenzo Stefano Paolo Roberto Davide Simone Federico Giulia Francesca Chiara Valentina Alessia Martina Elisa Jo\xE3o Pedro Tiago Beatriz In\xEAs Mariana Piotr Krzysztof Tomasz Marcin Agnieszka Katarzyna Ma\u0142gorzata Magdalena";
23569
23678
  var WORDS = "\u0412\u0435\u0440\u0430 \u041D\u0430\u0434\u0435\u0436\u0434\u0430 \u041B\u044E\u0431\u043E\u0432\u044C \u0421\u043B\u0430\u0432\u0430 \u0420\u043E\u043C\u0430\u043D \u0420\u043E\u0437\u0430 \u041C\u0430\u0439\u044F \u041B\u0438\u043B\u0438\u044F \u0417\u043B\u0430\u0442\u0430 \u041C\u0438\u043B\u0430 \u041D\u0438\u043A\u0430 \u041B\u0435\u0432 \u0413\u043B\u043E\u0440\u0438\u044F Will Mark Rose Grace Hope Faith Bill Frank Jack June April Summer Amber Ruby Lily Daisy Victoria Virginia Georgia Florence Sydney Chelsea Jordan Austin Dallas Mercedes Dolores Rosa Pilar Marina Esperanza Gloria Amparo Consuelo Roc\xEDo Salvador Santiago Jes\xFAs \xC1ngeles Hugo Ram\xF3n Christian Felix F\xE9lix Mario Martin Victor Pierre Paz Merc\xE8 Estrella Aurora Concepci\xF3n Remedios Soledad Milagros Angel \xC1ngel Dawn Joy Holly Ivy Iris Violet Pearl";
@@ -23571,7 +23680,7 @@ var NOT_NAMES = ["\u0436\u0435\u043D\u0430", "\u0436\u0435\u043D\u044B", "\u0436
23571
23680
  var FIRST_NAMES = [...new Set(`${RUSSIAN} ${EUROPEAN}`.split(" "))];
23572
23681
  var NAME_WORDS = WORDS.split(" ");
23573
23682
 
23574
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/person-names.js
23683
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/person-names.js
23575
23684
  var LATIN_TO_CYRILLIC = {
23576
23685
  shch: "\u0449",
23577
23686
  sch: "\u0449",
@@ -23779,7 +23888,7 @@ var findUnknownNames = /* @__PURE__ */ __name((text6, stem, taken) => {
23779
23888
  return found2;
23780
23889
  }, "findUnknownNames");
23781
23890
 
23782
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/attachments.js
23891
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/attachments.js
23783
23892
  var NOT_FILES = /* @__PURE__ */ new Set([
23784
23893
  "webpage",
23785
23894
  "share",
@@ -23819,7 +23928,7 @@ var matchDownloads = /* @__PURE__ */ __name((stored3, files2) => {
23819
23928
  });
23820
23929
  }, "matchDownloads");
23821
23930
 
23822
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
23931
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/lucene/types.js
23823
23932
  var QUERY_VERSION = 1;
23824
23933
  var QUERY_LIMITS2 = {
23825
23934
  ...QUERY_LIMITS,
@@ -23855,7 +23964,7 @@ function exhausted(budget) {
23855
23964
  }
23856
23965
  __name(exhausted, "exhausted");
23857
23966
 
23858
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
23967
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/lucene/automaton.js
23859
23968
  var any = { kind: "char", ranges: [[0, 1114111]], negate: false };
23860
23969
  var literal2 = /* @__PURE__ */ __name((c) => ({
23861
23970
  kind: "char",
@@ -24255,7 +24364,7 @@ var foldRegex = /* @__PURE__ */ __name((pattern, span) => {
24255
24364
  return out;
24256
24365
  }, "foldRegex");
24257
24366
 
24258
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
24367
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/lucene/presets.js
24259
24368
  var PRESET_VERSION = 1;
24260
24369
  var PRESETS = {
24261
24370
  password: {
@@ -24309,7 +24418,7 @@ var PRESETS = {
24309
24418
  }
24310
24419
  };
24311
24420
 
24312
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
24421
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/lucene/registry.js
24313
24422
  var FIELD_VERSION = 2;
24314
24423
  var UNITS = {
24315
24424
  "": 1,
@@ -24770,12 +24879,12 @@ var validateAst = /* @__PURE__ */ __name((input) => {
24770
24879
  return validateFields(parsed3.output);
24771
24880
  }, "validateAst");
24772
24881
 
24773
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
24882
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/lucene/resolved.js
24774
24883
  var hasText = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? node.field === "text" || node.field === "exact" : node.clauses.some(({ node: node2 }) => hasText(node2)), "hasText");
24775
24884
  var isStemmed = /* @__PURE__ */ __name((node) => node.field === "text" && (node.operator === "term" || node.operator === "phrase") && node.value !== "", "isStemmed");
24776
24885
  var hasStems = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? isStemmed(node) : node.clauses.some(({ node: node2 }) => hasStems(node2)), "hasStems");
24777
24886
 
24778
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
24887
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-links.js
24779
24888
  var LIVE = "mn.kind = 'url' AND mn.status <> 'dismissed'";
24780
24889
  var MAIL_ROWS = `SELECT mn.source_id FROM mentions mn WHERE mn.source_type = 'email' AND ${LIVE}`;
24781
24890
  var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
@@ -24799,7 +24908,7 @@ var linkMatch = /* @__PURE__ */ __name((field4, typed, mail, mentioned2) => {
24799
24908
  };
24800
24909
  }, "linkMatch");
24801
24910
 
24802
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
24911
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/phone-countries.js
24803
24912
  var SETTING = "phoneCountries";
24804
24913
  var savedPhoneCountries = /* @__PURE__ */ __name((database) => {
24805
24914
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING);
@@ -24830,7 +24939,7 @@ var valueMatch = /* @__PURE__ */ __name((database, typed) => {
24830
24939
  return { sql: "mn.value = ?", params: [phone?.value ?? normalizedValue(typed, { phoneCountries })] };
24831
24940
  }, "valueMatch");
24832
24941
 
24833
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
24942
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/vocabulary.js
24834
24943
  var normalizeVocabularyName = /* @__PURE__ */ __name((input) => {
24835
24944
  if (typeof input !== "string" || input.length > 200 || /[\p{Cc}\p{Cf}]/u.test(input))
24836
24945
  throw new CliError("validation_error", "a vocabulary name takes 1\u2013200 characters without control characters");
@@ -24858,7 +24967,7 @@ var vocabularySimilarity = /* @__PURE__ */ __name((left, right) => {
24858
24967
  return 2 * intersection2 / (aa2.size + bb.size);
24859
24968
  }, "vocabularySimilarity");
24860
24969
 
24861
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
24970
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-creation.js
24862
24971
  import { createHash } from "node:crypto";
24863
24972
  var folded2 = /* @__PURE__ */ __name((name) => {
24864
24973
  try {
@@ -24924,7 +25033,7 @@ var guardTagCreation = /* @__PURE__ */ __name((context, name, kind4, by, options
24924
25033
  });
24925
25034
  }, "guardTagCreation");
24926
25035
 
24927
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
25036
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/tag-redirects.js
24928
25037
  var invalid2 = /* @__PURE__ */ __name((message2) => {
24929
25038
  throw new CliError("validation_error", message2);
24930
25039
  }, "invalid");
@@ -25001,7 +25110,7 @@ var createTagRedirectIndex = /* @__PURE__ */ __name((snapshot2) => {
25001
25110
  };
25002
25111
  }, "createTagRedirectIndex");
25003
25112
 
25004
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
25113
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-resolution.js
25005
25114
  var tagCanonicalId = /* @__PURE__ */ __name((database, id2) => {
25006
25115
  const row2 = database.prepare("SELECT canonical_id FROM resolved_tags WHERE id=?").get(id2);
25007
25116
  if (!row2)
@@ -25029,7 +25138,7 @@ var tagRedirectSnapshot = /* @__PURE__ */ __name((database) => {
25029
25138
  return snapshot2;
25030
25139
  }, "tagRedirectSnapshot");
25031
25140
 
25032
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
25141
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-keys.js
25033
25142
  import { createHash as createHash2 } from "node:crypto";
25034
25143
  var TASK_KEY_PREFIXES = {
25035
25144
  question: "Q",
@@ -25057,7 +25166,7 @@ var taskAccountOf = /* @__PURE__ */ __name((database, rowId) => {
25057
25166
  return row2 && String(row2.key) === inboxKey(String(row2.name)) ? String(row2.name) : void 0;
25058
25167
  }, "taskAccountOf");
25059
25168
 
25060
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
25169
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/things.js
25061
25170
  var storedThing = /* @__PURE__ */ __name((type, id2) => ({ type: String(type), id: Number(id2) }), "storedThing");
25062
25171
  var REFERABLE = {
25063
25172
  note: { tombstone: true },
@@ -25073,6 +25182,9 @@ var REFERABLE = {
25073
25182
  invoice: { tombstone: true },
25074
25183
  payment: { tombstone: true },
25075
25184
  order: { tombstone: true },
25185
+ deal: { tombstone: true },
25186
+ lead: { tombstone: true },
25187
+ pipeline: { tombstone: false },
25076
25188
  message: { tombstone: true },
25077
25189
  email: { tombstone: true },
25078
25190
  email_thread: { tombstone: true },
@@ -25222,11 +25334,11 @@ var taskIdOf = /* @__PURE__ */ __name((database, rowId) => {
25222
25334
  return row2 ? String(row2.id ?? row2.key) : void 0;
25223
25335
  }, "taskIdOf");
25224
25336
 
25225
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
25226
- var toMs = /* @__PURE__ */ __name((iso13) => {
25227
- if (iso13 === null || iso13 === void 0)
25337
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/values.js
25338
+ var toMs = /* @__PURE__ */ __name((iso14) => {
25339
+ if (iso14 === null || iso14 === void 0)
25228
25340
  return null;
25229
- const ms = Date.parse(iso13);
25341
+ const ms = Date.parse(iso14);
25230
25342
  return Number.isNaN(ms) ? null : ms;
25231
25343
  }, "toMs");
25232
25344
  var toIso = /* @__PURE__ */ __name((ms) => typeof ms === "number" ? new Date(ms).toISOString() : null, "toIso");
@@ -25236,7 +25348,7 @@ var present = /* @__PURE__ */ __name((entries) => Object.fromEntries(Object.entr
25236
25348
  var DELIVERY = { delivered: 1, read: 2 };
25237
25349
  var deliveryOf = /* @__PURE__ */ __name((stored3) => stored3 === DELIVERY.read ? "read" : stored3 === DELIVERY.delivered ? "delivered" : void 0, "deliveryOf");
25238
25350
 
25239
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
25351
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tags.js
25240
25352
  var TAG_KINDS = ["tag", "topic"];
25241
25353
  var TAGGABLE = { chat: "chat", contact: "identity", message: "message", task: "task" };
25242
25354
  var TAG_TYPE = {
@@ -25439,7 +25551,7 @@ var tagsOf = /* @__PURE__ */ __name(({ database }, key2, filter) => {
25439
25551
  return result;
25440
25552
  }, "tagsOf");
25441
25553
 
25442
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
25554
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-fields.js
25443
25555
  var speech = /* @__PURE__ */ __name((alias2) => `(coalesce(${alias2}.extractor,'') LIKE 'speech:%' OR ${alias2}.kind IN ('voice','video_note') OR coalesce(${alias2}.mime,'')='audio/ogg')`, "speech");
25444
25556
  var SPEECH = speech("att");
25445
25557
  var mentionText = /* @__PURE__ */ __name((alias2) => `CASE WHEN coalesce(json_extract(${alias2}.contact, '$.phone'), '') <> '' THEN 'phone: ' || json_extract(${alias2}.contact, '$.phone') ELSE ${alias2}.text END`, "mentionText");
@@ -25803,7 +25915,7 @@ var FIELD_COMPILERS = {
25803
25915
  subject
25804
25916
  };
25805
25917
 
25806
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
25918
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/place-key.js
25807
25919
  var placeOf = /* @__PURE__ */ __name((database) => {
25808
25920
  const exact = database.prepare("SELECT id FROM places WHERE folded = ?");
25809
25921
  const onStreet = database.prepare("SELECT id FROM places WHERE substr(folded, 1, ?) = ? LIMIT 2");
@@ -25819,7 +25931,7 @@ var placeOf = /* @__PURE__ */ __name((database) => {
25819
25931
  };
25820
25932
  }, "placeOf");
25821
25933
 
25822
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
25934
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-drain.js
25823
25935
  var DRAIN_ON_WRITE = 500;
25824
25936
  var METHOD = "rules";
25825
25937
  var telegramLink = /* @__PURE__ */ __name((database) => {
@@ -25982,7 +26094,7 @@ var drainMentions = /* @__PURE__ */ __name((database, now2, limit = DRAIN_ON_WRI
25982
26094
  return queued.length;
25983
26095
  }, "drainMentions");
25984
26096
 
25985
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
26097
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/index-state.js
25986
26098
  var indexRow = /* @__PURE__ */ __name((database, name) => {
25987
26099
  const exists2 = database.prepare("SELECT 1 FROM sqlite_master WHERE name = 'search_index_state'").get();
25988
26100
  if (!exists2)
@@ -25990,7 +26102,7 @@ var indexRow = /* @__PURE__ */ __name((database, name) => {
25990
26102
  return database.prepare("SELECT * FROM search_index_state WHERE name = ?").get(name);
25991
26103
  }, "indexRow");
25992
26104
 
25993
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
26105
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/stems.js
25994
26106
  var INDEX = "message_stems";
25995
26107
  var SETTING2 = "searchStemmers";
25996
26108
  var DRAIN_ON_WRITE2 = 500;
@@ -26112,7 +26224,7 @@ var stemmerCache = /* @__PURE__ */ __name(() => {
26112
26224
  };
26113
26225
  }, "stemmerCache");
26114
26226
 
26115
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
26227
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/transaction.js
26116
26228
  var SQLITE_BUSY = 5;
26117
26229
  var pause = new Int32Array(new SharedArrayBuffer(4));
26118
26230
  var isBusy = /* @__PURE__ */ __name((error) => {
@@ -26207,7 +26319,7 @@ var read = /* @__PURE__ */ __name((database, body2) => {
26207
26319
  }
26208
26320
  }, "read");
26209
26321
 
26210
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
26322
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/vector-index.js
26211
26323
  var source = /* @__PURE__ */ __name((model, dims) => `SELECT k.id, k.chunkable_type,
26212
26324
  coalesce(CASE k.chunkable_type
26213
26325
  WHEN 'image' THEN (SELECT ch.account_id FROM attachments a JOIN messages m ON m.id = a.attachable_id
@@ -26349,7 +26461,7 @@ var dropUnusedVectors = /* @__PURE__ */ __name((database, hashes) => {
26349
26461
  }, "dropUnusedVectors");
26350
26462
  var dropAllUnusedVectors = /* @__PURE__ */ __name((database) => database.prepare("DELETE FROM embeddings WHERE NOT EXISTS (SELECT 1 FROM chunks k WHERE k.content_hash = embeddings.content_hash) RETURNING 1").all().length, "dropAllUnusedVectors");
26351
26463
 
26352
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
26464
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/accounts.js
26353
26465
  var accountPk = /* @__PURE__ */ __name(({ orm, now: now2 }, { provider, account, scope: scope3 }, name = null) => Number(orm.insert(accounts).values({ provider, externalId: account, name, scope: scope3 ?? "personal", createdAt: now2(), updatedAt: now2() }).onConflictDoUpdate({
26354
26466
  target: [accounts.provider, accounts.externalId],
26355
26467
  set: {
@@ -26458,7 +26570,7 @@ var dropOrphanPeople = /* @__PURE__ */ __name((database, unseenBefore) => {
26458
26570
  AND id NOT IN (SELECT id FROM (${referencesTo(database, "persons", /* @__PURE__ */ new Set(["identity_links"]))}) WHERE id IS NOT NULL)`).run(JSON.stringify(persons2));
26459
26571
  }, "dropOrphanPeople");
26460
26572
 
26461
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
26573
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/folded.js
26462
26574
  var FOLDED = [
26463
26575
  { table: "tasks", column: "title" },
26464
26576
  { table: "tasks", column: "close_reason" },
@@ -26495,7 +26607,7 @@ var fillFolded = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
26495
26607
  return filled2;
26496
26608
  }, "fillFolded");
26497
26609
 
26498
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/history-skips.js
26610
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/history-skips.js
26499
26611
  var HISTORY_KEY = "$history";
26500
26612
  var objectOf = /* @__PURE__ */ __name((text6) => {
26501
26613
  if (typeof text6 !== "string")
@@ -26571,7 +26683,7 @@ var withoutHistory = /* @__PURE__ */ __name((metadata3) => {
26571
26683
  return rest;
26572
26684
  }, "withoutHistory");
26573
26685
 
26574
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
26686
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/conversations/chunks.js
26575
26687
  import { createHash as createHash3 } from "node:crypto";
26576
26688
  var CHUNK_CHARS = 1200;
26577
26689
  var CHUNK_OVERLAP = 150;
@@ -26676,7 +26788,7 @@ var cutChunks = /* @__PURE__ */ __name((members2, limit = CHUNK_CHARS, check3, c
26676
26788
  return chunks2;
26677
26789
  }, "cutChunks");
26678
26790
 
26679
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/task-signature.js
26791
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/task-signature.js
26680
26792
  var DAY = 864e5;
26681
26793
  var CURRENCY = [
26682
26794
  [/^(₽|руб.*|р\.?|rub)$/u, "RUB"],
@@ -26802,7 +26914,7 @@ var dueDayOf = /* @__PURE__ */ __name((text6, createdMs) => {
26802
26914
  return best?.day ?? null;
26803
26915
  }, "dueDayOf");
26804
26916
 
26805
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
26917
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/task-similarity.js
26806
26918
  var DAY2 = 864e5;
26807
26919
  var STOP_WORDS = new Set([
26808
26920
  // Russian and English as the test set ran them, already folded (пожалуйста → пожалуиста).
@@ -26957,7 +27069,7 @@ var rankCandidates = /* @__PURE__ */ __name((views, candidates) => candidates.ma
26957
27069
  ...compareViews(subjectViews ?? views, candidate, replyChain === void 0 ? {} : { replyChain })
26958
27070
  })).sort((a, b) => b.score - a.score), "rankCandidates");
26959
27071
 
26960
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
27072
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/vectors.js
26961
27073
  var currentChunks = /* @__PURE__ */ __name((chatKey) => sql`SELECT k.content_hash, k.chunkable_id AS conversation_id, r.first_message_id,
26962
27074
  r.last_message_id, r.text_start, r.text_end FROM chunks k JOIN chunk_messages r ON r.chunk_id = k.id
26963
27075
  JOIN conversations c ON k.chunkable_type = 'conversation' AND c.id = k.chunkable_id
@@ -27228,7 +27340,7 @@ var readiness = /* @__PURE__ */ __name(({ orm }, chatKey, model) => {
27228
27340
  };
27229
27341
  }, "readiness");
27230
27342
 
27231
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
27343
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-pictures.js
27232
27344
  var DOCUMENT_PICTURE = "document_picture";
27233
27345
  var SCAN_PAGE2 = 5e3;
27234
27346
  var idOf = /* @__PURE__ */ __name((ref3) => {
@@ -27291,7 +27403,7 @@ var documentPicturesOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
27291
27403
  }, "nearestPictures")
27292
27404
  }), "documentPicturesOver");
27293
27405
 
27294
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
27406
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/query-filter.js
27295
27407
  var glob = /* @__PURE__ */ __name((value) => [...fold(value).matchAll(/\\(.)|([*?])|(.)/gsu)].map(([, escaped2, wildcard, plain2]) => {
27296
27408
  const literal4 = escaped2 ?? plain2 ?? "";
27297
27409
  return wildcard ?? (/[*?[]/u.test(literal4) ? `[${literal4}]` : literal4);
@@ -27356,7 +27468,7 @@ var compile = /* @__PURE__ */ __name((node, columns, options) => {
27356
27468
  var queryFilter = /* @__PURE__ */ __name((ast, columns, options = {}) => compile(ast.root, columns, options), "queryFilter");
27357
27469
  var bound2 = /* @__PURE__ */ __name(({ sql: text6, params }) => sql.join(text6.split("?").map((part, at) => at < params.length ? sql`${sql.raw(part)}${params[at]}` : sql.raw(part)), sql``), "bound");
27358
27470
 
27359
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
27471
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/events.js
27360
27472
  var toJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.stringify(value), "toJson");
27361
27473
  var fromJson = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : JSON.parse(String(value)), "fromJson");
27362
27474
  var int = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "int");
@@ -27446,7 +27558,7 @@ var linkMeeting = /* @__PURE__ */ __name((database, id2, eventId, now2, mode = "
27446
27558
  });
27447
27559
  }, "linkMeeting");
27448
27560
 
27449
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
27561
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/note-index.js
27450
27562
  var EVENT_TEXT = "trim(coalesce(e.description, '') || ' ' || coalesce(e.location, '') || ' ' || coalesce((SELECT group_concat(p.name, ' ') FROM calendar_entries ce JOIN calendar_entry_participants p ON p.entry_id = ce.id WHERE ce.event_id = e.id AND ce.deleted_at IS NULL AND p.resource = 0 AND p.name IS NOT NULL), ''))";
27451
27563
  var UNSEARCHED_EVENT_TYPES = [
27452
27564
  "working-location",
@@ -27676,7 +27788,7 @@ var resetNoteIndex = /* @__PURE__ */ __name((database) => {
27676
27788
  return true;
27677
27789
  }, "resetNoteIndex");
27678
27790
 
27679
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
27791
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-resolution.js
27680
27792
  var keyOf3 = /* @__PURE__ */ __name((name) => fold(name).trim().replace(/^@/, ""), "keyOf");
27681
27793
  var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
27682
27794
  for (const key2 of new Set(names.filter((name) => !!name?.trim()).map(keyOf3))) {
@@ -27695,7 +27807,7 @@ var resolvePersonLinks = /* @__PURE__ */ __name((database, names) => {
27695
27807
  }
27696
27808
  }, "resolvePersonLinks");
27697
27809
 
27698
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
27810
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/identities.js
27699
27811
  var flag2 = /* @__PURE__ */ __name((value) => value === void 0 || value === null ? null : Number(value), "flag");
27700
27812
  var prepare = /* @__PURE__ */ __name((orm) => ({
27701
27813
  find: orm.select({
@@ -27920,7 +28032,7 @@ var meetingIdentityPk = /* @__PURE__ */ __name((context, accountId, identity) =>
27920
28032
  }, "meetingIdentityPk");
27921
28033
  var phoneOf = /* @__PURE__ */ __name(({ orm }, provider, nativeId) => orm.select({ phone: identities.phone }).from(identities).where(and(eq(identities.provider, provider), eq(identities.externalId, nativeId))).get()?.phone ?? null, "phoneOf");
27922
28034
 
27923
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
28035
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/chats.js
27924
28036
  var chatOf = /* @__PURE__ */ __name(({ orm }, accountKey, chatKey) => orm.select({ id: chats.externalId }).from(chats).where(and(eq(chats.id, chatKey), eq(chats.accountId, accountKey))).get()?.id, "chatOf");
27925
28037
  var findChatPk = /* @__PURE__ */ __name(({ orm }, accountKey, chatId) => orm.select({ pk: chats.id }).from(chats).where(and(eq(chats.accountId, accountKey), eq(chats.externalId, chatId))).get()?.pk, "findChatPk");
27926
28038
  var chatPkFor = /* @__PURE__ */ __name((context, accountKey, chatId) => findChatPk(context, accountKey, chatId) ?? Number(context.orm.insert(chats).values({
@@ -28200,7 +28312,7 @@ var replaceAutoTags = /* @__PURE__ */ __name((context, key2, chatId, algorithm,
28200
28312
  }
28201
28313
  }, "replaceAutoTags");
28202
28314
 
28203
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/counters.js
28315
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/counters.js
28204
28316
  var COUNTER_FIELDS = ["views", "reactions", "comments"];
28205
28317
  var validCounter = /* @__PURE__ */ __name((value) => typeof value === "number" && Number.isFinite(value) && value >= 0, "validCounter");
28206
28318
  var counterObservationTime = /* @__PURE__ */ __name((observation, now2) => {
@@ -28219,7 +28331,7 @@ var counterFreshness = /* @__PURE__ */ __name((states) => {
28219
28331
  return states.some((one2) => one2.freshness === "stale") ? "stale" : "fresh";
28220
28332
  }, "counterFreshness");
28221
28333
 
28222
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/context/evidence.js
28334
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/context/evidence.js
28223
28335
  import { createHash as createHash4 } from "node:crypto";
28224
28336
  var CONTEXT_MAX_READ_BYTES = 262144;
28225
28337
  var CONTEXT_SOURCE_KINDS = ["message", "mail", "document", "meeting"];
@@ -28317,7 +28429,7 @@ var contextEvidenceRequest = /* @__PURE__ */ __name((input) => {
28317
28429
  return { source: source2, query, chat: chat2, senders, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal: input.signal };
28318
28430
  }, "contextEvidenceRequest");
28319
28431
 
28320
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/email-activity.js
28432
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-activity.js
28321
28433
  var MAIL_AGENDA_COLUMNS = { chat_kind: { type: "enum", sql: "'dialog'" } };
28322
28434
  var ACTIVITY = `
28323
28435
  SELECT t.external_id AS thread, t.subject, t.last_email_at, t.emails_count,
@@ -28434,7 +28546,7 @@ var mailActivity = /* @__PURE__ */ __name((database) => ({
28434
28546
  threadActivity: /* @__PURE__ */ __name(async (accountId, since, where) => threadActivity(database, accountId, since, where), "threadActivity")
28435
28547
  }), "mailActivity");
28436
28548
 
28437
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
28549
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/conversations/mail-text.js
28438
28550
  var GREETING = new RegExp("^(hi|hello|hey|dear|greetings|good (morning|afternoon|evening)|\u043F\u0440\u0438\u0432\u0435\u0442|\u0437\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439(\u0442\u0435)?|\u0434\u043E\u0431\u0440(\u044B\u0439|\u043E\u0435|\u043E\u0433\u043E) (\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440|\u0443\u0442\u0440\u043E|\u0443\u0442\u0440\u0430|\u0434\u043D\u044F)|hola|buen(os|as) (d\xEDas|dias|tardes|noches)|estimad[oa]s?|querid[oa]s?)(?![\\p{L}\\p{N}])([\\s,]+\\p{L}[\\p{L}.'\u2019-]*){0,3}\\s*[,!.:]?$", "iu");
28439
28551
  var SIGN_OFF = /^(best|best regards|best wishes|kind regards|warm regards|regards|thanks|thanks again|thanks a lot|thank you|many thanks|cheers|sincerely|yours|yours truly|yours sincerely|br|с уважением|спасибо|заранее спасибо|всего доброго|всего хорошего|un saludo|saludos|saludos cordiales|atentamente|gracias|muchas gracias)[\s,.!]*$/iu;
28440
28552
  var ATTRIBUTION = /(wrote|написал[аи]?|escribió|a écrit|schrieb)\s*:\s*$/iu;
@@ -28575,7 +28687,7 @@ var mailOwnText = /* @__PURE__ */ __name((body2) => {
28575
28687
  return text6 || body2.trim();
28576
28688
  }, "mailOwnText");
28577
28689
 
28578
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
28690
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-index.js
28579
28691
  var titleOf = /* @__PURE__ */ __name((subject2) => subject2?.replace(/^\s*((re|fwd?|aw|wg)\s*:\s*)+/i, "").trim() || null, "titleOf");
28580
28692
  var MAIL_PIECES = `(SELECT k.id, k.content_hash, k.chunkable_type AS type, k.chunkable_id AS owner, k.position,
28581
28693
  k.start_offset, k.end_offset, k.account_id, k.occurred_at, a.attachable_id AS email_id,
@@ -28685,7 +28797,7 @@ var drainEmailIndex = /* @__PURE__ */ __name((database, stemmerFor2) => {
28685
28797
  return emails3 + threads;
28686
28798
  }, "drainEmailIndex");
28687
28799
 
28688
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
28800
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-locations.js
28689
28801
  var locate = /* @__PURE__ */ __name((database, accountId, emailId, where) => database.prepare(`INSERT OR REPLACE INTO email_locations (mailbox_id, uidvalidity, uid, email_id)
28690
28802
  SELECT id, ?, ?, ? FROM mailboxes WHERE account_id = ? AND external_id = ?`).run(where.uidvalidity, where.uid, emailId, accountId, where.folder), "locate");
28691
28803
  var folderEmails = /* @__PURE__ */ __name((database, accountId, folder, uidvalidity) => database.prepare(`SELECT l.uid, e.external_id, coalesce(e.received_at, e.sent_at) AS at, e.read, e.flagged,
@@ -28783,7 +28895,7 @@ var forgetLocations = /* @__PURE__ */ __name((database, accountId, folder, uidva
28783
28895
  var backfillSentAt = /* @__PURE__ */ __name((database, accountId, limit) => Number(database.prepare(`UPDATE emails SET sent_at = received_at WHERE id IN (
28784
28896
  SELECT id FROM emails WHERE account_id = ? AND sent_at IS NULL AND received_at IS NOT NULL LIMIT ?)`).run(accountId, limit).changes), "backfillSentAt");
28785
28897
 
28786
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
28898
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/email-state.js
28787
28899
  var recountEmailThread = /* @__PURE__ */ __name((database, threadId, now2) => database.prepare(`UPDATE email_threads SET
28788
28900
  emails_count = (SELECT count(*) FROM emails WHERE email_thread_id = ? AND deleted_at IS NULL),
28789
28901
  last_email_at = (SELECT max(coalesce(sent_at, received_at)) FROM emails
@@ -28833,7 +28945,7 @@ var markEmailsRestored = /* @__PURE__ */ __name((database, accountId, externalId
28833
28945
  return threads.length;
28834
28946
  }, "markEmailsRestored");
28835
28947
 
28836
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
28948
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-rules.js
28837
28949
  var sorted = /* @__PURE__ */ __name((value) => Array.isArray(value) ? value.map(sorted) : value !== null && typeof value === "object" ? Object.fromEntries(Object.keys(value).sort().map((key2) => [key2, sorted(value[key2])])) : value, "sorted");
28838
28950
  var conditionsKey = /* @__PURE__ */ __name((conditions) => JSON.stringify(sorted(conditions)), "conditionsKey");
28839
28951
  var ruleOf = /* @__PURE__ */ __name((row2) => ({
@@ -28900,7 +29012,7 @@ var mailRulesOver = /* @__PURE__ */ __name((database) => ({
28900
29012
  }
28901
29013
  }), "mailRulesOver");
28902
29014
 
28903
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
29015
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/link-reviews.js
28904
29016
  var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates, reason, now2) => {
28905
29017
  database.prepare(`INSERT INTO link_reviews (linkable_type, linkable_id, entity_type, candidates, reason, status, created_at, updated_at)
28906
29018
  VALUES (?, ?, ?, ?, ?, 'open', ?, ?)
@@ -28908,7 +29020,7 @@ var reviewLink = /* @__PURE__ */ __name((database, linkable, entity, candidates,
28908
29020
  reason = excluded.reason, updated_at = excluded.updated_at WHERE link_reviews.status = 'open'`).run(linkable.type, linkable.id, entity, JSON.stringify([...candidates].sort((a, b) => a - b)), reason, now2, now2);
28909
29021
  }, "reviewLink");
28910
29022
 
28911
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
29023
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-operation.js
28912
29024
  function checkMeetingCancelled(signal) {
28913
29025
  if (!signal?.aborted)
28914
29026
  return;
@@ -28919,7 +29031,7 @@ function checkMeetingCancelled(signal) {
28919
29031
  }
28920
29032
  __name(checkMeetingCancelled, "checkMeetingCancelled");
28921
29033
 
28922
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
29034
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-values.js
28923
29035
  var meetingOf = /* @__PURE__ */ __name((row2) => ({
28924
29036
  id: Number(row2.id),
28925
29037
  accountId: Number(row2.account_id),
@@ -28969,7 +29081,7 @@ var transcriptRowOf = /* @__PURE__ */ __name((row2) => ({
28969
29081
  createdAt: Number(row2.created_at)
28970
29082
  }), "transcriptRowOf");
28971
29083
 
28972
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
29084
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-reads.js
28973
29085
  var MEETING_TEXT = ["external_id", "title", "description", "location", "join_url", "timezone", "metadata"];
28974
29086
  var TRANSCRIPT_TEXT = ["source", "format", "language", "content_hash", "metadata"];
28975
29087
  var ROW_TEXT = ["speaker_name", "text", "normalized_text", "metadata"];
@@ -29136,7 +29248,7 @@ var meetingReadsOver = /* @__PURE__ */ __name(({ database }) => ({
29136
29248
  }
29137
29249
  }), "meetingReadsOver");
29138
29250
 
29139
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
29251
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-selection.js
29140
29252
  var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
29141
29253
  const clauses = ["m.account_id=?", "m.deleted_at IS NULL"];
29142
29254
  const params = [input.accountId];
@@ -29179,7 +29291,7 @@ var meetingSelectionSql = /* @__PURE__ */ __name((input) => {
29179
29291
  return { clauses, params };
29180
29292
  }, "meetingSelectionSql");
29181
29293
 
29182
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
29294
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-chat-lines.js
29183
29295
  var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
29184
29296
  async meetingChatLines(input) {
29185
29297
  checkMeetingCancelled(input.signal);
@@ -29207,7 +29319,7 @@ var meetingChatLinesOver = /* @__PURE__ */ __name(({ database }) => ({
29207
29319
  }
29208
29320
  }), "meetingChatLinesOver");
29209
29321
 
29210
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
29322
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/reads.js
29211
29323
  var MESSAGE_FIELDS = {
29212
29324
  pk: messages.id,
29213
29325
  nativeId: messages.externalId,
@@ -29378,7 +29490,7 @@ var chatActivity = /* @__PURE__ */ __name(({ database }, accountKey, since, wher
29378
29490
  storedAt: toIso(Number(database.prepare("SELECT max(created_at) AS at FROM messages WHERE account_id = ?").get(accountKey)?.at) || null)
29379
29491
  }), "chatActivity");
29380
29492
 
29381
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
29493
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/search.js
29382
29494
  var HIT_FIELDS = {
29383
29495
  ...MESSAGE_FIELDS,
29384
29496
  chatTitle: sql`${chats.title}`.as("chat_title"),
@@ -29477,7 +29589,7 @@ var directReplies = /* @__PURE__ */ __name((context, parents, limit) => {
29477
29589
  };
29478
29590
  }, "directReplies");
29479
29591
 
29480
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
29592
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-links.js
29481
29593
  var identityRow = /* @__PURE__ */ __name(({ orm }, { provider, id: id2 }) => orm.select({ pk: identities.id, personPk: identityLinks.personId }).from(identities).innerJoin(identityLinks, eq(identityLinks.identityId, identities.id)).where(and(eq(identities.provider, provider), eq(identities.externalId, id2))).get(), "identityRow");
29482
29594
  var required = /* @__PURE__ */ __name((context, ref3) => {
29483
29595
  const found2 = identityRow(context, ref3);
@@ -29608,7 +29720,7 @@ var mentioning = /* @__PURE__ */ __name((context, accountKey, { id: id2, usernam
29608
29720
  }, "mentioning");
29609
29721
  var escaped = /* @__PURE__ */ __name((text6) => text6.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "escaped");
29610
29722
 
29611
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
29723
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-context-links.js
29612
29724
  var missing2 = /* @__PURE__ */ __name(() => {
29613
29725
  throw new CliError("not_found", "Meeting, participant or selected target not found");
29614
29726
  }, "missing");
@@ -29730,7 +29842,7 @@ function meetingContextLinksOver(context) {
29730
29842
  }
29731
29843
  __name(meetingContextLinksOver, "meetingContextLinksOver");
29732
29844
 
29733
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
29845
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-index-values.js
29734
29846
  var INDEX_CODES = { meeting_transcript_row: 1, meeting_chat_message: 2, meeting_summary: 3 };
29735
29847
  var meetingRowid = /* @__PURE__ */ __name((type, id2) => id2 * 4 + INDEX_CODES[type], "meetingRowid");
29736
29848
  var summaryOf = /* @__PURE__ */ __name((row2) => ({
@@ -29759,7 +29871,7 @@ var indexedText = /* @__PURE__ */ __name((database, type, id2) => {
29759
29871
  return row2 ? summaryText(summaryOf(row2)) : null;
29760
29872
  }, "indexedText");
29761
29873
 
29762
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
29874
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stem-state.js
29763
29875
  var summaryBytes = ["title", "overview", "sections", "next_steps", "content"].map((key2) => `coalesce(length(CAST(s.${key2} AS BLOB)),0)`).join("+");
29764
29876
  var meetingCurrentIndexRows = `
29765
29877
  SELECT 'meeting_transcript_row' AS indexable_type,r.id,r.id*4+1 AS rid,1 AS live,coalesce(length(CAST(r.text AS BLOB)),0) AS bytes FROM meeting_transcript_rows r JOIN meeting_transcripts t ON t.id=r.meeting_transcript_id JOIN meetings m ON m.id=t.meeting_id WHERE m.account_id=? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL
@@ -29790,7 +29902,7 @@ var invalidateMeetingStems = /* @__PURE__ */ __name((database, type, id2) => {
29790
29902
  }, "invalidateMeetingStems");
29791
29903
  var meetingStemmableText = /* @__PURE__ */ __name((text6) => text6.replace(/[\p{L}\p{N}\p{M}\p{Co}]+/gu, (token) => token.length <= 1024 ? token : ""), "meetingStemmableText");
29792
29904
 
29793
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
29905
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-index.js
29794
29906
  function meetingHitIndexOver({ database, now: now2 }) {
29795
29907
  return {
29796
29908
  async indexSearch(original) {
@@ -29858,10 +29970,10 @@ function meetingHitIndexOver({ database, now: now2 }) {
29858
29970
  }
29859
29971
  __name(meetingHitIndexOver, "meetingHitIndexOver");
29860
29972
 
29861
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
29973
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
29862
29974
  import { createHash as createHash5 } from "node:crypto";
29863
29975
 
29864
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/trigrams.js
29976
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/trigrams.js
29865
29977
  var trigrams = /* @__PURE__ */ __name((term) => {
29866
29978
  const padded = ` ${term} `;
29867
29979
  const pieces = /* @__PURE__ */ new Set();
@@ -29870,7 +29982,7 @@ var trigrams = /* @__PURE__ */ __name((term) => {
29870
29982
  return [...pieces];
29871
29983
  }, "trigrams");
29872
29984
 
29873
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/correct.js
29985
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/correct.js
29874
29986
  var SHORTEST_CORRECTION = 3;
29875
29987
  var maxEdits = /* @__PURE__ */ __name((word2) => word2.length <= 4 ? 1 : 2, "maxEdits");
29876
29988
  var editDistance = /* @__PURE__ */ __name((a, b, max) => {
@@ -29917,7 +30029,7 @@ var correctWords = /* @__PURE__ */ __name(async (vocabulary, words3) => {
29917
30029
  return corrections;
29918
30030
  }, "correctWords");
29919
30031
 
29920
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/garbled.js
30032
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/garbled.js
29921
30033
  var SHORTEST_GARBLED = 4;
29922
30034
  var MOST_WIDENED = 64;
29923
30035
  var plain = /* @__PURE__ */ __name((word2) => word2.replaceAll("\u044D", "\u0435"), "plain");
@@ -30009,7 +30121,7 @@ var widenWords = /* @__PURE__ */ __name((probes, vocabulary, stem, known2) => {
30009
30121
  return found2.map((words3) => words3.sort((a, b) => a.distance - b.distance || b.docs - a.docs || a.term.localeCompare(b.term)).slice(0, MOST_WIDENED).map((word2) => word2.term));
30010
30122
  }, "widenWords");
30011
30123
 
30012
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
30124
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/russian-dictionary.js
30013
30125
  import { readFileSync } from "node:fs";
30014
30126
  var loaded;
30015
30127
  var dictionary = /* @__PURE__ */ __name(() => {
@@ -30068,7 +30180,7 @@ var knownRussianWord = /* @__PURE__ */ __name((word2) => {
30068
30180
  return false;
30069
30181
  }, "knownRussianWord");
30070
30182
 
30071
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
30183
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-query.js
30072
30184
  var WORD3 = /[\p{L}\p{N}\p{M}]+/gu;
30073
30185
  var MOST_WORDS = 128;
30074
30186
  var quote = /* @__PURE__ */ __name((word2) => `"${word2.replaceAll('"', '""')}"`, "quote");
@@ -30295,7 +30407,7 @@ var matchMeetingText = /* @__PURE__ */ __name((tree, text6, stemmer) => {
30295
30407
  return check3(tree);
30296
30408
  }, "matchMeetingText");
30297
30409
 
30298
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
30410
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-hit-search.js
30299
30411
  var fail3 = /* @__PURE__ */ __name((message2) => {
30300
30412
  throw new CliError("validation_error", message2);
30301
30413
  }, "fail");
@@ -30477,7 +30589,7 @@ function meetingHitSearchOver({ database }) {
30477
30589
  }
30478
30590
  __name(meetingHitSearchOver, "meetingHitSearchOver");
30479
30591
 
30480
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-languages.js
30592
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-languages.js
30481
30593
  var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
30482
30594
  async fillTranscriptLanguages({ accountId, apply, now: now2 }) {
30483
30595
  positiveReadInteger(accountId, "accountId");
@@ -30509,7 +30621,7 @@ var meetingLanguagesOver = /* @__PURE__ */ __name(({ database }) => ({
30509
30621
  }
30510
30622
  }), "meetingLanguagesOver");
30511
30623
 
30512
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
30624
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-participant-search.js
30513
30625
  import { createHash as createHash6 } from "node:crypto";
30514
30626
  var cursorOf2 = /* @__PURE__ */ __name((value, key2) => {
30515
30627
  if (value === void 0)
@@ -30599,7 +30711,7 @@ var meetingParticipantSearchOver = /* @__PURE__ */ __name((context) => ({
30599
30711
  }
30600
30712
  }), "meetingParticipantSearchOver");
30601
30713
 
30602
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
30714
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-context-queries.js
30603
30715
  var preparationQueries = {
30604
30716
  participants: {
30605
30717
  fields: "p.id, p.identity_id, p.display_name, l.person_id",
@@ -30649,7 +30761,7 @@ var preparationQueries = {
30649
30761
  }
30650
30762
  };
30651
30763
 
30652
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
30764
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-context.js
30653
30765
  var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
30654
30766
  async preparationContext(original) {
30655
30767
  const input = validateMeetingPreparationContext(original);
@@ -30690,7 +30802,7 @@ var meetingPreparationContextOver = /* @__PURE__ */ __name(({ database }) => ({
30690
30802
  }
30691
30803
  }), "meetingPreparationContextOver");
30692
30804
 
30693
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
30805
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/preparation-subjects.js
30694
30806
  var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
30695
30807
  SELECT m.id FROM meetings m JOIN meeting_series s ON s.id=m.meeting_series_id
30696
30808
  WHERE m.id IN (${Array.from({ length: anchors }, () => "?").join(",")}) AND m.account_id=? AND s.account_id=?
@@ -30704,7 +30816,7 @@ var preparationSubjects = /* @__PURE__ */ __name((anchors) => `WITH anchors AS (
30704
30816
  JOIN main.projects p ON p.id=l.to_id WHERE p.account_id IS NULL AND p.deleted_at IS NULL
30705
30817
  )`, "preparationSubjects");
30706
30818
 
30707
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
30819
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-knowledge.js
30708
30820
  var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => ({
30709
30821
  async preparationKnowledge(original) {
30710
30822
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -30749,7 +30861,7 @@ var meetingPreparationKnowledgeOver = /* @__PURE__ */ __name(({ database }) => (
30749
30861
  }
30750
30862
  }), "meetingPreparationKnowledgeOver");
30751
30863
 
30752
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
30864
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-preparation-notes.js
30753
30865
  var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
30754
30866
  async preparationNotes(original) {
30755
30867
  const { accountId, seriesId, anchorIds, after: after2, before: before2, limit, maxReadBytes, signal } = validateMeetingRelatedHistory(original);
@@ -30802,7 +30914,7 @@ var meetingPreparationNotesOver = /* @__PURE__ */ __name(({ database }) => ({
30802
30914
  }
30803
30915
  }), "meetingPreparationNotesOver");
30804
30916
 
30805
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
30917
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-related-history.js
30806
30918
  var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
30807
30919
  async relatedHistory(original) {
30808
30920
  const input = validateMeetingRelatedHistory(original);
@@ -30873,7 +30985,7 @@ var meetingRelatedHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
30873
30985
  }
30874
30986
  }), "meetingRelatedHistoryOver");
30875
30987
 
30876
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
30988
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-review.js
30877
30989
  var number2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : Number(value), "number");
30878
30990
  var text2 = /* @__PURE__ */ __name((value) => value === null || value === void 0 ? null : String(value), "text");
30879
30991
  var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
@@ -30954,7 +31066,7 @@ var meetingReviewOver = /* @__PURE__ */ __name(({ database }) => ({
30954
31066
  }
30955
31067
  }), "meetingReviewOver");
30956
31068
 
30957
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
31069
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-series-history.js
30958
31070
  var bytes2 = "length(CAST(external_id AS BLOB)) + coalesce(length(CAST(title AS BLOB)), 0)";
30959
31071
  var ensureBytes2 = /* @__PURE__ */ __name((size2, budget) => {
30960
31072
  if (!Number.isSafeInteger(size2) || size2 < 0 || size2 > budget)
@@ -31008,7 +31120,7 @@ var meetingSeriesHistoryOver = /* @__PURE__ */ __name(({ database }) => ({
31008
31120
  }
31009
31121
  }), "meetingSeriesHistoryOver");
31010
31122
 
31011
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
31123
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-stats.js
31012
31124
  var MOST_ROWS = 5e5;
31013
31125
  var meetingCountsSql = /* @__PURE__ */ __name((where) => `SELECT m.started_at, coalesce(m.duration_ms, m.ended_at - m.started_at) AS duration_ms,
31014
31126
  EXISTS (SELECT 1 FROM meeting_transcripts t WHERE t.meeting_id = m.id AND t.deleted_at IS NULL
@@ -31077,7 +31189,7 @@ var meetingStatsOver = /* @__PURE__ */ __name(({ database }) => ({
31077
31189
  }
31078
31190
  }), "meetingStatsOver");
31079
31191
 
31080
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
31192
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meetings.js
31081
31193
  var CURSOR_KEY = "meetings";
31082
31194
  var seriesOf2 = /* @__PURE__ */ __name((row2) => ({
31083
31195
  id: Number(row2.id),
@@ -31646,7 +31758,7 @@ var meetingStoreOver = /* @__PURE__ */ __name((context) => {
31646
31758
  };
31647
31759
  }, "meetingStoreOver");
31648
31760
 
31649
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
31761
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/sync.js
31650
31762
  var syncStateOf = /* @__PURE__ */ __name(({ orm }, accountKey, name) => {
31651
31763
  const row2 = orm.select({ value: syncCursors.value, at: syncCursors.updatedAt }).from(syncCursors).where(and(eq(syncCursors.accountId, accountKey), eq(syncCursors.key, name))).get();
31652
31764
  return row2 ? { value: row2.value, at: toIso(row2.at) } : void 0;
@@ -31672,7 +31784,7 @@ var release = /* @__PURE__ */ __name(({ orm }, chatKey, anchor, holder) => {
31672
31784
  orm.delete(fetchLeases).where(and(eq(fetchLeases.chatId, chatKey), eq(fetchLeases.anchor, anchor), eq(fetchLeases.holder, holder))).run();
31673
31785
  }, "release");
31674
31786
 
31675
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/thread-columns.js
31787
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/thread-columns.js
31676
31788
  var THREAD_COLUMNS = {
31677
31789
  subject: {
31678
31790
  where: /* @__PURE__ */ __name(({ value }) => ({
@@ -31689,7 +31801,7 @@ var threadRows = /* @__PURE__ */ __name((database, filter) => {
31689
31801
  AND (${filter.where?.sql ?? "1"}) ORDER BY coalesce(last_email_at, 0) DESC, id DESC LIMIT ? OFFSET ?`).all(filter.accountId ?? null, filter.accountId ?? null, filter.includeDeleted ? 1 : 0, ...filter.where?.params ?? [], limit, offset);
31690
31802
  }, "threadRows");
31691
31803
 
31692
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
31804
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/emails.js
31693
31805
  var threadConversation = /* @__PURE__ */ __name((place, builtAt) => ({
31694
31806
  id: `email:${place.emailId}`,
31695
31807
  chatId: place.threadExternalId,
@@ -32245,7 +32357,7 @@ var mailStoreOver = /* @__PURE__ */ __name(({ database, orm, now: now2 }, stemme
32245
32357
  }
32246
32358
  }), "mailStoreOver");
32247
32359
 
32248
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/search/dictionary.js
32360
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/search/dictionary.js
32249
32361
  import { readFileSync as readFileSync2 } from "node:fs";
32250
32362
  var DICTIONARIES = Object.fromEntries(LANGUAGES.map(({ name, dictionary: dictionary3 }) => [name, dictionary3]));
32251
32363
  var folded4 = /* @__PURE__ */ __name((word2) => /^[а-яё'-]*$/.test(word2) ? word2.replaceAll("\u0451", "\u0435").replaceAll("\u0439", "\u0438") : fold(word2), "folded");
@@ -32335,7 +32447,7 @@ var knownWord = /* @__PURE__ */ __name((languages) => {
32335
32447
  }, "knownWord");
32336
32448
  var dictionaryLanguages = /* @__PURE__ */ __name((stemmers) => [stemmers.cyrillic, ...stemmers.latin.split(",")].filter((name) => Object.hasOwn(DICTIONARIES, name)), "dictionaryLanguages");
32337
32449
 
32338
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
32450
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/transcript-query.js
32339
32451
  var predicates = /* @__PURE__ */ __name((node) => node.kind === "predicate" ? [node] : node.clauses.flatMap(({ node: node2 }) => predicates(node2)), "predicates");
32340
32452
  var readsTranscripts = /* @__PURE__ */ __name((node) => (node.operator === "term" || node.operator === "phrase") && /[\p{L}\p{N}]/u.test(normalize(node.value)) && (node.field === "transcript" || node.implicit === true && (node.field === "text" || node.field === "exact")), "readsTranscripts");
32341
32453
  var LATIN_NUMBERS = new Set(`zero one two three four five six seven eight nine ten eleven twelve twenty thirty forty fifty sixty seventy
@@ -32421,7 +32533,7 @@ var spokenTranscripts = /* @__PURE__ */ __name((database, item, speaking, keys)
32421
32533
  return found2;
32422
32534
  }, "spokenTranscripts");
32423
32535
 
32424
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
32536
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/hit-places.js
32425
32537
  var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, found2, pks) => {
32426
32538
  const placeLeaves = leaves.filter(({ node }) => (node.operator === "term" || node.operator === "phrase") && (node.implicit || node.field === "content" || node.field === "transcript"));
32427
32539
  if (!placeLeaves.length || !pks.length || found2.length !== pks.length)
@@ -32468,7 +32580,7 @@ var placeHits = /* @__PURE__ */ __name((database, corpus, leaves, transcripts, f
32468
32580
  });
32469
32581
  }, "placeHits");
32470
32582
 
32471
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-groups.js
32583
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene-groups.js
32472
32584
  var GROUPS = {
32473
32585
  chat: {
32474
32586
  key: "m.chat_id",
@@ -32490,7 +32602,7 @@ var GROUPS = {
32490
32602
  }
32491
32603
  };
32492
32604
 
32493
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
32605
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/lucene.js
32494
32606
  var MESSAGES2 = {
32495
32607
  rows: "messages",
32496
32608
  threads: "chats",
@@ -32973,7 +33085,7 @@ var runCompiled = /* @__PURE__ */ __name(async (context, execution, by) => {
32973
33085
  };
32974
33086
  }, "runCompiled");
32975
33087
 
32976
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
33088
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/counters.js
32977
33089
  function invalidMetadata() {
32978
33090
  throw new CliError("validation_error", "stored counter metadata is malformed \u2014 check the store before refreshing");
32979
33091
  }
@@ -33075,7 +33187,7 @@ var counterTargets = /* @__PURE__ */ __name((context, execution, options) => wit
33075
33187
  };
33076
33188
  }), "counterTargets");
33077
33189
 
33078
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
33190
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/attachment-texts.js
33079
33191
  var NOT_FILE_LIST = [...NOT_FILES].map((kind4) => `'${kind4}'`).join(",");
33080
33192
  var fileAttachments = /* @__PURE__ */ __name(({ database }, accountKey, { chatKey, messageId, beforePk, limit }) => database.prepare(`SELECT att.id AS pk, c.external_id AS chat_id, m.external_id AS message_id, att.position, att.kind, att.name, att.mime,
33081
33193
  att.size, att.local_path, att.extraction AS origin, att.size AS read_bytes, att.extraction_error AS error, att.content_sha256, att.extractor
@@ -33194,7 +33306,7 @@ var attachmentViews = /* @__PURE__ */ __name(({ database }, accountKey, { chatKe
33194
33306
  }));
33195
33307
  }, "attachmentViews");
33196
33308
 
33197
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
33309
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/transcripts.js
33198
33310
  var transcript = /* @__PURE__ */ __name(({ orm }, chatKey, messageId) => orm.select({ text: messageTranscripts.text, source: messageTranscripts.source }).from(messageTranscripts).where(and(eq(messageTranscripts.chatId, chatKey), eq(messageTranscripts.messageExternalId, messageId))).get(), "transcript");
33199
33311
  var keepTranscript = /* @__PURE__ */ __name((context, chatKey, messageId, text6, source2) => {
33200
33312
  const { orm, database, now: now2 } = context;
@@ -33232,7 +33344,7 @@ var intoVoiceAttachment = /* @__PURE__ */ __name((context, messagePk) => {
33232
33344
  keepText(context, Number(row2.id), { text: String(row2.text), origin: "extracted", extractor: `speech:${row2.source}` });
33233
33345
  }, "intoVoiceAttachment");
33234
33346
 
33235
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
33347
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/messages.js
33236
33348
  var FIELDS = [
33237
33349
  "threadExternalId",
33238
33350
  "senderIdentityId",
@@ -33549,7 +33661,7 @@ var writeDerivedReactions = /* @__PURE__ */ __name((context, chatKey, messageId)
33549
33661
  reactionStatementsOf(context.database).total.run(JSON.stringify(derived), chatKey, messageId);
33550
33662
  }, "writeDerivedReactions");
33551
33663
 
33552
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/keys.js
33664
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/keys.js
33553
33665
  var keysOver = /* @__PURE__ */ __name((context) => {
33554
33666
  const findAccountPk2 = /* @__PURE__ */ __name((key2) => findAccountPk(context, key2), "findAccountPk");
33555
33667
  const findChatPk2 = /* @__PURE__ */ __name((accountKey, chatId) => findChatPk(context, accountKey, chatId), "findChatPk");
@@ -33570,7 +33682,7 @@ var keysOver = /* @__PURE__ */ __name((context) => {
33570
33682
  };
33571
33683
  }, "keysOver");
33572
33684
 
33573
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
33685
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/account-groups.js
33574
33686
  var accountGroupsOf = /* @__PURE__ */ __name((database) => {
33575
33687
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(ACCOUNT_GROUPS);
33576
33688
  if (!row2)
@@ -33605,7 +33717,7 @@ var saveProfile = /* @__PURE__ */ __name((database, app, profile, key2, now2) =>
33605
33717
  database.prepare("INSERT OR REPLACE INTO store_settings (key, value, at) VALUES (?, ?, ?)").run(PROFILES, JSON.stringify(profiles), now2);
33606
33718
  }, "saveProfile");
33607
33719
 
33608
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
33720
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/actors.js
33609
33721
  var BOT_KINDS = ["agent", "rule", "script", "integration"];
33610
33722
  var ownerPerson = /* @__PURE__ */ __name((database) => {
33611
33723
  const found2 = database.prepare("SELECT id FROM persons WHERE owner = 1 ORDER BY id LIMIT 1").get();
@@ -33662,7 +33774,7 @@ var proposedBySql = /* @__PURE__ */ __name((type, id2, by) => {
33662
33774
  return { sql: bot("pb.name = ?"), params: [by.bot] };
33663
33775
  }, "proposedBySql");
33664
33776
 
33665
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
33777
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/own-identities.js
33666
33778
  var linkOwnIdentities = /* @__PURE__ */ __name((context) => {
33667
33779
  const owner = ownerPerson(context.database).id;
33668
33780
  const strays = context.database.prepare("SELECT DISTINCT l.person_id AS person FROM identity_links l JOIN identities i ON i.id = l.identity_id JOIN accounts a ON a.provider = i.provider AND a.external_id = i.external_id WHERE l.person_id <> ?").all(owner);
@@ -33683,7 +33795,7 @@ var linkToOwner = /* @__PURE__ */ __name((context, ref3) => {
33683
33795
  return personOf(context, ref3);
33684
33796
  }, "linkToOwner");
33685
33797
 
33686
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
33798
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/providers.js
33687
33799
  var PROVIDERS_SETTING = "providers";
33688
33800
  var storedProvidersOf = /* @__PURE__ */ __name((database) => {
33689
33801
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(PROVIDERS_SETTING);
@@ -33718,7 +33830,7 @@ var registerProvider = /* @__PURE__ */ __name((database, value, now2) => {
33718
33830
  });
33719
33831
  }, "registerProvider");
33720
33832
 
33721
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
33833
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-candidates.js
33722
33834
  var DAY3 = 864e5;
33723
33835
  var RECENTLY_CLOSED_MS = 14 * DAY3;
33724
33836
  var TEXT_LIMIT = 20;
@@ -33917,7 +34029,7 @@ var taskSimilarityOver = /* @__PURE__ */ __name((context) => {
33917
34029
  };
33918
34030
  }, "taskSimilarityOver");
33919
34031
 
33920
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
34032
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-category-settings.js
33921
34033
  var SETTING3 = "taskCategories";
33922
34034
  var savedTaskCategories = /* @__PURE__ */ __name((database) => {
33923
34035
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(SETTING3);
@@ -33936,7 +34048,7 @@ var saveTaskCategories = /* @__PURE__ */ __name((database, categories, now2) =>
33936
34048
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(SETTING3, JSON.stringify(categories), now2);
33937
34049
  }, "saveTaskCategories");
33938
34050
 
33939
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
34051
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close.js
33940
34052
  var DEFAULT_AGENT_CLOSE = { allowed: true, min: 0.8 };
33941
34053
  var ALLOWED = "taskAgentClose";
33942
34054
  var MIN = "taskAgentCloseMin";
@@ -33992,10 +34104,10 @@ var SUGGESTION_COLUMNS = [
33992
34104
  ];
33993
34105
  var CLEAR_SUGGESTION = SUGGESTION_COLUMNS.map((column2) => `${column2} = NULL`).join(", ");
33994
34106
 
33995
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/mail-findings.js
34107
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/mail-findings.js
33996
34108
  var MAIL_FINDINGS_KIND = "mail_findings";
33997
34109
 
33998
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/decisions.js
34110
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/decisions.js
33999
34111
  var TASK_CLOSE_KIND = "task_close";
34000
34112
  var DEFAULT_DECISION_POLICY = { agentDecisions: false, ruleProposalsOwnerOnly: true };
34001
34113
  var isOwnerOnlyKind = /* @__PURE__ */ __name((kind4) => kind4 === MAIL_FINDINGS_KIND || kind4 === MEETING_FINDINGS_KIND || kind4 === TASK_CLOSE_KIND, "isOwnerOnlyKind");
@@ -34043,7 +34155,17 @@ var assertMayDecide = /* @__PURE__ */ __name((row2, by, policy = DEFAULT_DECISIO
34043
34155
  }, "assertMayDecide");
34044
34156
  var deciderAuthor = /* @__PURE__ */ __name((by) => by === "owner" ? "owner" : { bot: by.bot, ...by.model === void 0 ? {} : { model: by.model } }, "deciderAuthor");
34045
34157
 
34046
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
34158
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/deals.js
34159
+ var DEAL_KINDS = ["deal", "lead"];
34160
+ var DEAL_STATUSES = ["open", "won", "lost"];
34161
+ var STAGE_OUTCOMES = DEAL_STATUSES;
34162
+ var DEAL_ROLES = ["owner", "contact", "decision-maker"];
34163
+ var dealLine = /* @__PURE__ */ __name((deal) => {
34164
+ const money = deal.amount === null || deal.currency === null ? "" : `, ${moneyLabel(deal.amount, deal.currency)}`;
34165
+ return `${deal.title} \xB7 ${deal.stage}${money}${deal.status === "open" ? "" : ` (${deal.status})`}`;
34166
+ }, "dealLine");
34167
+
34168
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/ref-summaries.js
34047
34169
  var PROFILE_PLACEHOLDER = "<profile>";
34048
34170
  var oneLine = /* @__PURE__ */ __name((text6) => singleLine(text6.replace(/\s+/g, " ").trim()), "oneLine");
34049
34171
  var openKind = /* @__PURE__ */ __name((kind4) => kind4 === "email" ? "message" : kind4 === "email_thread" ? "chat" : kind4 === "unknown" ? void 0 : kind4, "openKind");
@@ -34086,6 +34208,9 @@ var WORDS2 = {
34086
34208
  invoice: "Invoice",
34087
34209
  payment: "Payment",
34088
34210
  order: "Order",
34211
+ deal: "Deal",
34212
+ lead: "Lead",
34213
+ pipeline: "Pipeline",
34089
34214
  email: "Email",
34090
34215
  email_thread: "Email thread",
34091
34216
  unknown: "Unknown"
@@ -34096,7 +34221,7 @@ var refLabel = /* @__PURE__ */ __name((summary) => {
34096
34221
  return `${WORDS2[summary.kind]} ${named3}${notes2 === "" ? "" : ` (${notes2})`}`;
34097
34222
  }, "refLabel");
34098
34223
 
34099
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/ref-summaries.js
34224
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/ref-summaries.js
34100
34225
  var EXCERPT_CHARS = 280;
34101
34226
  var TITLE_CHARS = 120;
34102
34227
  var MEMORY_TITLE_CHARS = 80;
@@ -34119,6 +34244,12 @@ var byId = /* @__PURE__ */ __name((kind4, table, columns) => ({
34119
34244
  kind: kind4,
34120
34245
  sql: /* @__PURE__ */ __name((body2) => `${select(columns(body2))} FROM w JOIN ${table} x ON x.id = w.k1`, "sql")
34121
34246
  }), "byId");
34247
+ var crmColumns = /* @__PURE__ */ __name(() => ({
34248
+ title: "json_object('id', x.id, 'title', x.title, 'stage', (SELECT name FROM pipeline_stages WHERE id = x.stage_id), 'amount', x.amount, 'currency', x.currency, 'status', x.status)",
34249
+ holder: "(SELECT name FROM projects WHERE id = x.project_id)",
34250
+ at: "x.created_at",
34251
+ deleted: "x.deleted_at"
34252
+ }), "crmColumns");
34122
34253
  var READERS = {
34123
34254
  message: {
34124
34255
  kind: "message",
@@ -34270,7 +34401,10 @@ var READERS = {
34270
34401
  holder: "(SELECT name FROM projects WHERE id = x.project_id)",
34271
34402
  at: "x.created_at",
34272
34403
  deleted: "x.deleted_at"
34273
- }))
34404
+ })),
34405
+ deal: byId("deal", "deals", crmColumns),
34406
+ lead: byId("lead", "leads", crmColumns),
34407
+ pipeline: byId("pipeline", "pipelines", () => ({ title: "x.name", at: "x.created_at" }))
34274
34408
  };
34275
34409
  var FALLBACK = { email: "message", email_thread: "chat" };
34276
34410
  var route = /* @__PURE__ */ __name((reference2) => {
@@ -34361,6 +34495,9 @@ var titleOf2 = /* @__PURE__ */ __name((kind4, reference2, found2) => {
34361
34495
  return fieldsOf2(found2.title, paymentLine);
34362
34496
  case "order":
34363
34497
  return fieldsOf2(found2.title, orderLine);
34498
+ case "deal":
34499
+ case "lead":
34500
+ return fieldsOf2(found2.title, dealLine);
34364
34501
  case "folder":
34365
34502
  return reference2.type === "folder" && reference2.path !== null && found2.title !== null ? `${found2.title}/${reference2.path}` : found2.title;
34366
34503
  default:
@@ -34457,7 +34594,7 @@ var refReadsOf = /* @__PURE__ */ __name((database, texts2, { excerpt = false } =
34457
34594
  var summaryOf2 = /* @__PURE__ */ __name(({ sender, excerpt, ...summary }, withExcerpt) => withExcerpt ? { ...summary, excerpt } : summary, "summaryOf");
34458
34595
  var refSummariesOf = /* @__PURE__ */ __name((database, texts2, options = {}) => new Map([...refReadsOf(database, texts2, options)].map(([text6, read2]) => [text6, summaryOf2(read2, options.excerpt === true)])), "refSummariesOf");
34459
34596
 
34460
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
34597
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-sources.js
34461
34598
  var sourceOf3 = /* @__PURE__ */ __name((read2, ref3) => ({
34462
34599
  ref: ref3,
34463
34600
  kind: read2.kind,
@@ -34493,7 +34630,7 @@ var evidenceSourcesOf = /* @__PURE__ */ __name((database, from2) => {
34493
34630
  });
34494
34631
  }, "evidenceSourcesOf");
34495
34632
 
34496
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/attachments/limits.js
34633
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/attachments/limits.js
34497
34634
  var MAX_FILE_BYTES = 50 * 1024 * 1024;
34498
34635
  var MAX_TEXT_CHARS = 2e6;
34499
34636
  var ATTACHMENT_LIMIT_ENV = [
@@ -34519,7 +34656,7 @@ var pdfPreviewLimits = /* @__PURE__ */ __name((env = process.env) => {
34519
34656
  return { pixels, bytes: positive(env, "MESSAGING_PDF_PREVIEW_MAX_MIB", 8 * 1024 * 1024, 1024 * 1024) };
34520
34657
  }, "pdfPreviewLimits");
34521
34658
 
34522
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/ulid.js
34659
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/ulid.js
34523
34660
  import { randomBytes } from "node:crypto";
34524
34661
  var CROCKFORD = "0123456789ABCDEFGHJKMNPQRSTVWXYZ";
34525
34662
  var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
@@ -34532,7 +34669,7 @@ var ulid = /* @__PURE__ */ __name((now2 = Date.now()) => {
34532
34669
  return time3 + random;
34533
34670
  }, "ulid");
34534
34671
 
34535
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
34672
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-metadata.js
34536
34673
  var FOLDED_FIELDS = ["title", "site", "language", "author"];
34537
34674
  var encodeDocumentMetadata = /* @__PURE__ */ __name((meta, sections) => {
34538
34675
  if (!meta && !sections?.length)
@@ -34553,7 +34690,7 @@ var languageOf = /* @__PURE__ */ __name((meta) => {
34553
34690
  return typeof language === "string" && language !== "" ? language : null;
34554
34691
  }, "languageOf");
34555
34692
 
34556
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
34693
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/files.js
34557
34694
  var isObject = /* @__PURE__ */ __name((value) => value !== null && typeof value === "object" && !Array.isArray(value), "isObject");
34558
34695
  var objectOf2 = /* @__PURE__ */ __name((value) => {
34559
34696
  if (isObject(value))
@@ -34796,7 +34933,7 @@ var filesStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
34796
34933
  };
34797
34934
  }, "filesStoreOver");
34798
34935
 
34799
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
34936
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/imported-documents.js
34800
34937
  var IMPORTED_DOCUMENT_QUERY = defineQuery({
34801
34938
  entity: "document",
34802
34939
  backend: "sql",
@@ -34842,7 +34979,7 @@ var importedDocumentWhere = /* @__PURE__ */ __name((database, query) => {
34842
34979
  return queryFilter(validateQuery(query, IMPORTED_DOCUMENT_QUERY), columns);
34843
34980
  }, "importedDocumentWhere");
34844
34981
 
34845
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
34982
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/notes.js
34846
34983
  var NOTE_FORMATS = ["obsidian", "markdown"];
34847
34984
  var iso2 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
34848
34985
  var optionalIso = /* @__PURE__ */ __name((value) => value == null ? null : iso2(value), "optionalIso");
@@ -35368,7 +35505,7 @@ var notesStoreOver = /* @__PURE__ */ __name((context) => {
35368
35505
  };
35369
35506
  }, "notesStoreOver");
35370
35507
 
35371
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
35508
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/memories.js
35372
35509
  var NAMED = "SELECT m.*, b.name AS author_name, b.kind AS author_kind FROM memories m LEFT JOIN bots b ON m.author_type = 'bot' AND b.id = m.author_id";
35373
35510
  var iso3 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
35374
35511
  var oneOf2 = /* @__PURE__ */ __name((value, allowed, what) => {
@@ -35590,7 +35727,7 @@ var memoriesStoreOver = /* @__PURE__ */ __name((context) => {
35590
35727
  };
35591
35728
  }, "memoriesStoreOver");
35592
35729
 
35593
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
35730
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-first-pass.js
35594
35731
  var DEFAULT_FIRST_PASS_PER_CHAT = 0;
35595
35732
  var KEY = "taskFirstPassPerChat";
35596
35733
  var firstPassPerChatOf = /* @__PURE__ */ __name((value, setting = "task_first_pass_per_chat") => {
@@ -35610,7 +35747,7 @@ var saveFirstPassPerChat = /* @__PURE__ */ __name((database, value, now2) => {
35610
35747
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(KEY, String(value), now2);
35611
35748
  }, "saveFirstPassPerChat");
35612
35749
 
35613
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/external-links.js
35750
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/external-links.js
35614
35751
  var EXTERNAL_SERVICE = /^[a-z][a-z0-9-]{0,31}$/;
35615
35752
  var EXTERNAL_ID_CHARS = 200;
35616
35753
  var SOURCE_URL_CHARS = 2e3;
@@ -35637,7 +35774,7 @@ var sourceUrlOf = /* @__PURE__ */ __name((value, reason = "task.source-url") =>
35637
35774
  return text6;
35638
35775
  }, "sourceUrlOf");
35639
35776
 
35640
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
35777
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-board.js
35641
35778
  var TASK_SORTS = ["priority", "due", "created", "updated", "key", "state"];
35642
35779
  var field = /* @__PURE__ */ __name((name, type, example, more = {}) => ({
35643
35780
  name,
@@ -35860,7 +35997,7 @@ var withoutField = /* @__PURE__ */ __name((query, name) => {
35860
35997
  return root === void 0 ? void 0 : { ...query, root };
35861
35998
  }, "withoutField");
35862
35999
 
35863
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-comments.js
36000
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-comments.js
35864
36001
  var authorNamed = /* @__PURE__ */ __name((database, row2) => {
35865
36002
  if (row2.author_type == null)
35866
36003
  return null;
@@ -35888,7 +36025,7 @@ var addComment = /* @__PURE__ */ __name((context, task, body2, by) => {
35888
36025
  return commentsOf(database, task).find((one2) => one2.ref === `note:${made}`);
35889
36026
  }, "addComment");
35890
36027
 
35891
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
36028
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-relations.js
35892
36029
  var TASK_RELATION_KINDS = [
35893
36030
  "blocked-by",
35894
36031
  "follow-up-of",
@@ -36018,7 +36155,7 @@ var taskRelationsStoreOver = /* @__PURE__ */ __name((context, record4) => {
36018
36155
  };
36019
36156
  }, "taskRelationsStoreOver");
36020
36157
 
36021
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
36158
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/work-tasks.js
36022
36159
  var TASK_ROLES = ["assignee", "reviewer", "watcher"];
36023
36160
  var iso4 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
36024
36161
  var recordTaskEvent = /* @__PURE__ */ __name((database, task, actor, kind4, changes, at) => {
@@ -36547,7 +36684,7 @@ var workTasksOver = /* @__PURE__ */ __name((context) => {
36547
36684
  };
36548
36685
  }, "workTasksOver");
36549
36686
 
36550
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
36687
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-close-store.js
36551
36688
  var taskCloseOver = /* @__PURE__ */ __name((context) => {
36552
36689
  const { database, now: now2 } = context;
36553
36690
  const liveRow = /* @__PURE__ */ __name((id2) => {
@@ -36596,7 +36733,7 @@ var taskCloseOver = /* @__PURE__ */ __name((context) => {
36596
36733
  };
36597
36734
  }, "taskCloseOver");
36598
36735
 
36599
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
36736
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-pairs.js
36600
36737
  var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
36601
36738
  const { database, now: now2 } = context;
36602
36739
  const required3 = /* @__PURE__ */ __name((id2) => {
@@ -36814,7 +36951,7 @@ var taskPairsOver = /* @__PURE__ */ __name((context, similarity) => {
36814
36951
  };
36815
36952
  }, "taskPairsOver");
36816
36953
 
36817
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-stats.js
36954
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-stats.js
36818
36955
  var ACCOUNT_SCOPE = "t.package_id IS NOT NULL AND t.deleted_at IS NULL AND t.project_id = ?";
36819
36956
  var TASK_STATS_SQL = {
36820
36957
  rows: /* @__PURE__ */ __name((board, filter) => `SELECT t.source_group, t.source_kind, t.project_id, t.status, t.created_at, t.closed_at FROM tasks t WHERE ${board ? BOARD_SCOPE : ACCOUNT_SCOPE}${filter} ORDER BY t.created_at, t.id`, "rows"),
@@ -36853,7 +36990,7 @@ var taskStatsOver = /* @__PURE__ */ __name(({ database }, inbox) => ({
36853
36990
  }, "statNames")
36854
36991
  }), "taskStatsOver");
36855
36992
 
36856
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
36993
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tasks.js
36857
36994
  var COLUMNS3 = "t.id AS row_id, t.package_id, t.source_locator, t.source_kind, t.source_group, t.type, t.status, t.close_reason, t.source, t.created_at, t.due_at, t.closed_at, t.closed_by_type, t.closed_by_id, t.key, t.category, t.claimed_by, t.claimed_until, p.name AS account";
36858
36995
  var inboxProject = /* @__PURE__ */ __name(({ database, now: now2 }, account, create) => {
36859
36996
  const key2 = inboxKey(account);
@@ -37060,7 +37197,7 @@ var oneOf3 = /* @__PURE__ */ __name((values, value, column2) => {
37060
37197
  throw new CliError("configuration_error", `the store holds a task with an unknown ${column2} "${String(value)}"`);
37061
37198
  }, "oneOf");
37062
37199
 
37063
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/accounts.js
37200
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/accounts.js
37064
37201
  var accountAccountsOver = /* @__PURE__ */ __name((context) => {
37065
37202
  const { database } = context;
37066
37203
  const { accountPk: accountPk2, findAccountPk: findAccountPk2 } = keysOver(context);
@@ -37105,7 +37242,7 @@ var accountsStoreOver = /* @__PURE__ */ __name((context, keyed) => {
37105
37242
  };
37106
37243
  }, "accountsStoreOver");
37107
37244
 
37108
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
37245
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/attachments.js
37109
37246
  var refColumn = /* @__PURE__ */ __name((ref3) => ref3 && Object.keys(ref3).length > 0 ? { providerRef: JSON.stringify(ref3) } : {}, "refColumn");
37110
37247
  var updatePlaced = /* @__PURE__ */ __name(({ orm }, chatKey, messageId, files2, change) => {
37111
37248
  const message2 = orm.select({ pk: messages.id }).from(messages).where(and(eq(messages.chatId, chatKey), eq(messages.externalId, messageId))).get();
@@ -37129,7 +37266,7 @@ var keepDownloads = /* @__PURE__ */ __name((context, chatKey, messageId, files2)
37129
37266
  })), "keepDownloads");
37130
37267
  var keepProviderRefs = /* @__PURE__ */ __name((context, chatKey, messageId, files2) => updatePlaced(context, chatKey, messageId, files2.filter((file) => Object.keys(file.providerRef).length > 0), (file) => refColumn(file.providerRef)), "keepProviderRefs");
37131
37268
 
37132
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/attachments.js
37269
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/attachments.js
37133
37270
  var accountAttachmentsOver = /* @__PURE__ */ __name((context) => {
37134
37271
  const { database } = context;
37135
37272
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -37186,7 +37323,7 @@ var attachmentsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
37186
37323
  }, "keepAttachmentText")
37187
37324
  }), "attachmentsStoreOver");
37188
37325
 
37189
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
37326
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-rekey.js
37190
37327
  var chatRow = /* @__PURE__ */ __name((context, accountKey, chatId) => context.database.prepare("SELECT * FROM chats WHERE account_id = ? AND external_id = ?").get(accountKey, chatId), "chatRow");
37191
37328
  var pointerMover = /* @__PURE__ */ __name((context, type) => {
37192
37329
  const statements = pointerPairs(context.database).filter(({ table }) => table !== "involvements").map(({ table, pointer }) => {
@@ -37366,7 +37503,7 @@ var rekeyChats = /* @__PURE__ */ __name((context, key2, accountKey, pairs, lockM
37366
37503
  return done;
37367
37504
  }, "rekeyChats");
37368
37505
 
37369
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
37506
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/completeness.js
37370
37507
  var historyStartKey = /* @__PURE__ */ __name((chatId) => `history_start:${chatId}`, "historyStartKey");
37371
37508
  var fetchedKey = /* @__PURE__ */ __name((chatId) => `fetched:${chatId}`, "fetchedKey");
37372
37509
  var CHAT_LIST_KEY = "chat_list_complete";
@@ -37424,7 +37561,7 @@ var chatCoverage = /* @__PURE__ */ __name(({ database }, accountKey) => {
37424
37561
  return { ...coverage, oldestMessageAt: toIso(oldest) };
37425
37562
  }, "chatCoverage");
37426
37563
 
37427
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/chats.js
37564
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/chats.js
37428
37565
  var chatsStoreOver = /* @__PURE__ */ __name((context) => {
37429
37566
  const { database } = context;
37430
37567
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, writeState: writeState2 } = keysOver(context);
@@ -37559,7 +37696,7 @@ var chatsStoreOver = /* @__PURE__ */ __name((context) => {
37559
37696
  };
37560
37697
  }, "chatsStoreOver");
37561
37698
 
37562
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
37699
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/batches.js
37563
37700
  import { createHash as createHash7 } from "node:crypto";
37564
37701
  var BATCH_CONTEXT = 50;
37565
37702
  var replied = /* @__PURE__ */ __name((m) => sql`EXISTS (SELECT 1 FROM messages p WHERE p.chat_id = ${m}.chat_id
@@ -37697,7 +37834,7 @@ var saveAnswers = /* @__PURE__ */ __name((context, id2, answer) => {
37697
37834
  var clearAnswers = /* @__PURE__ */ __name(({ orm }, chatKey, model) => Number(orm.all(sql`DELETE FROM message_links WHERE chat_id = ${chatKey} AND source = 'agent'
37698
37835
  ${model === void 0 ? sql`` : sql`AND method = ${model}`} RETURNING 1 AS n`).length), "clearAnswers");
37699
37836
 
37700
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
37837
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/conversations.js
37701
37838
  import { setTimeout } from "node:timers/promises";
37702
37839
  var position = /* @__PURE__ */ __name((sentAt, pk) => `${sentAt}:${pk}`, "position");
37703
37840
  var linkInputs = /* @__PURE__ */ __name(({ orm }, chatKey, { after: after2, limit }) => {
@@ -38009,7 +38146,7 @@ var agentAnswers = /* @__PURE__ */ __name(({ orm }, chatKey) => new Map(orm.all(
38009
38146
  AND NOT EXISTS (SELECT 1 FROM messages d
38010
38147
  WHERE d.id IN (l.message_id, l.parent_id) AND d.deleted_at > l.created_at)`).map(({ id: id2, parent: parent2 }) => [id2, parent2])), "agentAnswers");
38011
38148
 
38012
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/conversations.js
38149
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/conversations.js
38013
38150
  var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
38014
38151
  const { database } = context;
38015
38152
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -38116,7 +38253,7 @@ var conversationsStoreOver = /* @__PURE__ */ __name((context) => {
38116
38253
  };
38117
38254
  }, "conversationsStoreOver");
38118
38255
 
38119
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/counters.js
38256
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/counters.js
38120
38257
  var LIVE_MESSAGE = "SELECT m.id AS pk FROM messages m JOIN chats c ON c.id=m.chat_id JOIN accounts ac ON ac.id=m.account_id WHERE ac.provider=? AND ac.external_id=? AND c.external_id=? AND m.external_id=? AND m.deleted_at IS NULL";
38121
38258
  var accountCountersOver = /* @__PURE__ */ __name((context) => {
38122
38259
  const { database } = context;
@@ -38141,7 +38278,7 @@ var countersStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
38141
38278
  counterTargets: /* @__PURE__ */ __name(async (execution, options) => counterTargets(context, execution, options), "counterTargets")
38142
38279
  }), "countersStoreOver");
38143
38280
 
38144
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
38281
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mentions.js
38145
38282
  var MENTION_STATUSES = ["found", "linked", "dismissed"];
38146
38283
  var MENTION_QUERY = defineQuery({
38147
38284
  entity: "mention",
@@ -38357,7 +38494,7 @@ var listPlaces = /* @__PURE__ */ __name((database, { limit, offset }) => {
38357
38494
  return { items: hasMore ? rows.slice(0, limit) : rows, hasMore };
38358
38495
  }, "listPlaces");
38359
38496
 
38360
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/mentions.js
38497
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/mentions.js
38361
38498
  var accountMentionsOver = /* @__PURE__ */ __name((context) => {
38362
38499
  const { database } = context;
38363
38500
  const { findAccountPk: findAccountPk2 } = keysOver(context);
@@ -38392,7 +38529,7 @@ var mentionsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
38392
38529
  places: /* @__PURE__ */ __name(async (window) => listPlaces(context.database, window), "places")
38393
38530
  }), "mentionsStoreOver");
38394
38531
 
38395
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
38532
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/document-links.js
38396
38533
  var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messageId) => {
38397
38534
  const read2 = database.prepare("SELECT m.id, m.external_id, m.text, m.sent_at, m.sender_name, coalesce(m.sender_chat_external_id, i.external_id) AS sender_id FROM messages m LEFT JOIN identities i ON i.id = m.sender_identity_id WHERE m.chat_id = ? AND m.deleted_at IS NULL AND (m.text LIKE '%google.com%' OR m.text LIKE '%forms.gle%') " + (messageId === void 0 ? "" : "AND m.external_id = ? ") + "ORDER BY m.sent_at DESC, m.id DESC");
38398
38535
  const rows = messageId === void 0 ? read2.all(chatKey) : read2.all(chatKey, messageId);
@@ -38407,7 +38544,7 @@ var documentLinkMessages = /* @__PURE__ */ __name(({ database }, chatKey, messag
38407
38544
  }));
38408
38545
  }, "documentLinkMessages");
38409
38546
 
38410
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
38547
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/follow-ups.js
38411
38548
  var stemmerFor = stemmerCache();
38412
38549
  var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit }) => {
38413
38550
  if (wanted.length > 50 || !Number.isInteger(limit) || limit < 1 || limit > 100)
@@ -38451,7 +38588,7 @@ var laterSharingRare = /* @__PURE__ */ __name((context, wanted, { rareAt, limit
38451
38588
  });
38452
38589
  }, "laterSharingRare");
38453
38590
 
38454
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/messages.js
38591
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/messages.js
38455
38592
  var accountMessagesOver = /* @__PURE__ */ __name((context) => {
38456
38593
  const { database } = context;
38457
38594
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf, chatPkFor: chatPkFor2, answeredChatPk: answeredChatPk2, upsertMessage: upsertMessage2 } = keysOver(context);
@@ -38586,7 +38723,7 @@ var messagesStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
38586
38723
  laterSharingRare: /* @__PURE__ */ __name(async (wanted, options) => laterSharingRare(context, wanted, options), "laterSharingRare")
38587
38724
  }), "messagesStoreOver");
38588
38725
 
38589
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
38726
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-preparation.js
38590
38727
  var GLOBAL_PROJECT = "SELECT id FROM main.projects WHERE account_id IS NULL AND deleted_at IS NULL";
38591
38728
  var iso5 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
38592
38729
  var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: accounts2, limit }) => {
@@ -38643,7 +38780,7 @@ var personPreparation = /* @__PURE__ */ __name(({ database }, uid, { accounts: a
38643
38780
  });
38644
38781
  }, "personPreparation");
38645
38782
 
38646
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
38783
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/person-scope.js
38647
38784
  var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds) => {
38648
38785
  const id2 = Number(uid);
38649
38786
  if (!/^[1-9]\d*$/.test(uid) || !Number.isSafeInteger(id2) || !accountIds.length || accountIds.length > 1e3 || accountIds.some((account) => !Number.isSafeInteger(account) || account <= 0))
@@ -38651,7 +38788,7 @@ var personSeenInAccounts = /* @__PURE__ */ __name(({ database }, uid, accountIds
38651
38788
  return Boolean(database.prepare("SELECT 1 FROM persons p JOIN identity_links l ON l.person_id=p.id JOIN account_identities a ON a.identity_id=l.identity_id WHERE p.id=? AND a.account_id IN (SELECT value FROM json_each(?)) LIMIT 1").get(id2, JSON.stringify(accountIds)));
38652
38789
  }, "personSeenInAccounts");
38653
38790
 
38654
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
38791
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/private-people.js
38655
38792
  var required2 = /* @__PURE__ */ __name(({ database }, key2, personId) => {
38656
38793
  const row2 = database.prepare("SELECT a.id AS account_id, i.id AS identity_id FROM accounts a JOIN account_identities ai ON ai.account_id=a.id JOIN identities i ON i.id=ai.identity_id WHERE a.provider=? AND a.external_id=? AND i.provider=? AND i.external_id=?").get(key2.provider, key2.account, key2.provider, personId);
38657
38794
  if (!row2)
@@ -38717,7 +38854,7 @@ var removeNote = /* @__PURE__ */ __name((context, key2, personId, id2) => {
38717
38854
  return { id: id2, personId, removed: true };
38718
38855
  }, "removeNote");
38719
38856
 
38720
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/people.js
38857
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/people.js
38721
38858
  var accountPeopleOver = /* @__PURE__ */ __name((context) => {
38722
38859
  const { database } = context;
38723
38860
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, identityPk: identityPk2 } = keysOver(context);
@@ -38802,13 +38939,13 @@ var peopleStoreOver = /* @__PURE__ */ __name((context, keyed) => {
38802
38939
  };
38803
38940
  }, "peopleStoreOver");
38804
38941
 
38805
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
38942
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
38806
38943
  import { createHash as createHash9 } from "node:crypto";
38807
38944
 
38808
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38945
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
38809
38946
  import { createHash as createHash8 } from "node:crypto";
38810
38947
 
38811
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
38948
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/rankings-options.js
38812
38949
  var MESSAGE_MEASURES = ["views", "reactions", "forwards", "comments", "replies", "thread-size"];
38813
38950
  var AUTHOR_MEASURES = [
38814
38951
  "messages",
@@ -38948,7 +39085,7 @@ var withoutUrls = /* @__PURE__ */ __name((text6) => text6.replace(/\S+/gu, (toke
38948
39085
  var rankingWords = /* @__PURE__ */ __name((text6) => withoutUrls(text6).match(/[\p{L}\p{N}]+/gu)?.length ?? 0, "rankingWords");
38949
39086
  var rankingQuestion = /* @__PURE__ */ __name((text6) => withoutUrls(text6).includes("?"), "rankingQuestion");
38950
39087
 
38951
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
39088
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/rankings-graph.js
38952
39089
  var RANKING_GRAPH_LIMITS = { nodes: 5e4, depth: 256, work: 1e7, bytes: 8388608 };
38953
39090
  var exhausted2 = /* @__PURE__ */ __name((budget) => {
38954
39091
  throw new CliError("validation_error", `ranking exceeded ${budget} \u2014 narrow its chat or date scope`, {
@@ -39170,7 +39307,7 @@ var rankReplyGraph = /* @__PURE__ */ __name((nodes, check3 = () => {
39170
39307
  };
39171
39308
  }, "rankReplyGraph");
39172
39309
 
39173
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
39310
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/admin-statistics.js
39174
39311
  var adminEntityKey = /* @__PURE__ */ __name((row2) => JSON.stringify([row2.account.provider, row2.account.account, row2.id]), "adminEntityKey");
39175
39312
  var personKey = /* @__PURE__ */ __name((node) => JSON.stringify([node.account.provider, node.account.account, node.sender]), "personKey");
39176
39313
  var locator = /* @__PURE__ */ __name((node) => formatLocator({ ...node.account, chat: node.chatId, message: node.id }), "locator");
@@ -39344,7 +39481,7 @@ var calculateAdminStatistics = /* @__PURE__ */ __name((nodes, stays, options, in
39344
39481
  return { items, evidence, summary, graph: graph.quality };
39345
39482
  }, "calculateAdminStatistics");
39346
39483
 
39347
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
39484
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/rankings-range.js
39348
39485
  var rankingContextRange = /* @__PURE__ */ __name((root) => {
39349
39486
  const dates = [];
39350
39487
  const visit = /* @__PURE__ */ __name((node, required3) => {
@@ -39366,7 +39503,7 @@ var rankingContextRange = /* @__PURE__ */ __name((root) => {
39366
39503
  return dates[0].node.resolution.date;
39367
39504
  }, "rankingContextRange");
39368
39505
 
39369
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
39506
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/rankings.js
39370
39507
  var reactionCounts = /* @__PURE__ */ __name((stored3) => {
39371
39508
  let counts;
39372
39509
  try {
@@ -39661,7 +39798,7 @@ var rankQuery = /* @__PURE__ */ __name((context, execution, request, inspect) =>
39661
39798
  });
39662
39799
  }, "rankQuery");
39663
39800
 
39664
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
39801
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/admin-statistics.js
39665
39802
  function fail4(message2, reason = "query.too-large") {
39666
39803
  throw new CliError("validation_error", message2, { reason, complete: false });
39667
39804
  }
@@ -39838,7 +39975,7 @@ var adminStatisticsQuery = /* @__PURE__ */ __name((context, execution, request)
39838
39975
  return result;
39839
39976
  }), "adminStatisticsQuery");
39840
39977
 
39841
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
39978
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/conversation-eligibility.js
39842
39979
  var conversationEligibility = /* @__PURE__ */ __name(async (context, execution) => {
39843
39980
  if (!execution.accounts.length)
39844
39981
  return { conversations: [], chats: [] };
@@ -39856,7 +39993,7 @@ var conversationEligibility = /* @__PURE__ */ __name(async (context, execution)
39856
39993
  return { conversations: conversations2, chats: chats2 };
39857
39994
  }, "conversationEligibility");
39858
39995
 
39859
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
39996
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/ranking-evidence.js
39860
39997
  import { createHash as createHash10 } from "node:crypto";
39861
39998
  var EVIDENCE_BYTES = 64 * 1024;
39862
39999
  var FINGERPRINT_BYTES = 8 * 1024 * 1024;
@@ -40006,7 +40143,7 @@ var rankingEvidence = /* @__PURE__ */ __name((context, execution, request) => {
40006
40143
  return result;
40007
40144
  }, "rankingEvidence");
40008
40145
 
40009
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/reply-times.js
40146
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/reply-times.js
40010
40147
  var FAR = Number.MAX_SAFE_INTEGER;
40011
40148
  var chatsIn = /* @__PURE__ */ __name((scope3, kinds2) => {
40012
40149
  const params = [...scope3.accounts.flatMap(({ provider, account }) => [provider, account]), ...kinds2];
@@ -40100,7 +40237,7 @@ var waitingChats = /* @__PURE__ */ __name((context, scope3, waits, cap) => {
40100
40237
  });
40101
40238
  }, "waitingChats");
40102
40239
 
40103
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/queries.js
40240
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/queries.js
40104
40241
  var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
40105
40242
  const mailIndexed = /* @__PURE__ */ __name((execution) => {
40106
40243
  if (execution.corpus === "mail")
@@ -40121,7 +40258,7 @@ var queriesStoreOver = /* @__PURE__ */ __name((context, stemmerFor2) => {
40121
40258
  };
40122
40259
  }, "queriesStoreOver");
40123
40260
 
40124
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
40261
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/chat-events.js
40125
40262
  var saveChatEvents = /* @__PURE__ */ __name((context, accountKey, provider, chatKey, events3) => {
40126
40263
  const { database, now: now2 } = context;
40127
40264
  const insert = database.prepare(`INSERT INTO chat_events (chat_id, source_id, action, actor_identity_id, title, happened_at, created_at, updated_at)
@@ -40160,10 +40297,10 @@ var chatEventsOf = /* @__PURE__ */ __name(({ database }, chatKey, { since = 0, l
40160
40297
  }));
40161
40298
  }, "chatEventsOf");
40162
40299
 
40163
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
40300
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
40164
40301
  import { createHash as createHash11 } from "node:crypto";
40165
40302
 
40166
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/calendar.js
40303
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/calendar.js
40167
40304
  var calendarKey = /* @__PURE__ */ __name((zone, by) => {
40168
40305
  const format = new Intl.DateTimeFormat("en-CA", {
40169
40306
  timeZone: zone,
@@ -40183,7 +40320,7 @@ var weekKey = /* @__PURE__ */ __name((day) => {
40183
40320
  return date3.toISOString().slice(0, 10);
40184
40321
  }, "weekKey");
40185
40322
 
40186
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/retention.js
40323
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/retention.js
40187
40324
  var RETENTION_TOLERANCE = 864e5;
40188
40325
  var validateRetentionOptions = /* @__PURE__ */ __name((options) => {
40189
40326
  const { since, until, cutoff, checkpoints, within, limit, by } = options;
@@ -40237,7 +40374,7 @@ var retentionCohorts = /* @__PURE__ */ __name((stays, options) => {
40237
40374
  return [...groups.values()].sort((a, b) => a.cohort.localeCompare(b.cohort));
40238
40375
  }, "retentionCohorts");
40239
40376
 
40240
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
40377
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/retention.js
40241
40378
  var iso6 = /* @__PURE__ */ __name((at) => new Date(at).toISOString(), "iso");
40242
40379
  var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId, options, evidence) => {
40243
40380
  validateRetentionOptions(options);
@@ -40368,7 +40505,7 @@ var retentionQuery = /* @__PURE__ */ __name((context, accountPk2, chatPk, chatId
40368
40505
  };
40369
40506
  }, "retentionQuery");
40370
40507
 
40371
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
40508
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/roster.js
40372
40509
  var iso7 = /* @__PURE__ */ __name((ms) => ms === null ? null : new Date(ms).toISOString(), "iso");
40373
40510
  var marksOf = /* @__PURE__ */ __name(({ isBot, flagged, deleted, hasPhoto }) => ({
40374
40511
  ...isBot === void 0 ? {} : { bot: isBot },
@@ -40499,7 +40636,7 @@ var trackedChats = /* @__PURE__ */ __name((context, accountKey, where) => contex
40499
40636
  lastCount: memberCountsOf(context, pk).at(-1) ?? null
40500
40637
  })), "trackedChats");
40501
40638
 
40502
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/roster.js
40639
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/roster.js
40503
40640
  var rosterStoreOver = /* @__PURE__ */ __name((context) => {
40504
40641
  const { database } = context;
40505
40642
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, writeMembers: writeMembers2 } = keysOver(context);
@@ -40555,7 +40692,7 @@ var rosterStoreOver = /* @__PURE__ */ __name((context) => {
40555
40692
  };
40556
40693
  }, "rosterStoreOver");
40557
40694
 
40558
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
40695
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/backfill.js
40559
40696
  var pendingNormalization = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL").get()?.n), "pendingNormalization");
40560
40697
  var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatch, until = /* @__PURE__ */ __name(() => false, "until") } = {}) => {
40561
40698
  const next = database.prepare(`SELECT id AS pk, text FROM messages WHERE normalized_text IS NULL AND deleted_at IS NULL AND id > ? ORDER BY id LIMIT ?`);
@@ -40579,7 +40716,7 @@ var backfillNormalized = /* @__PURE__ */ __name((database, { batch = 5e3, onBatc
40579
40716
  }
40580
40717
  }, "backfillNormalized");
40581
40718
 
40582
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
40719
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/search-index.js
40583
40720
  var INDEX2 = "message_words";
40584
40721
  var searchIndexState2 = /* @__PURE__ */ __name((database) => {
40585
40722
  const row2 = indexRow(database, INDEX2);
@@ -40706,7 +40843,7 @@ var resetSearchIndex = /* @__PURE__ */ __name((database) => {
40706
40843
  });
40707
40844
  }, "resetSearchIndex");
40708
40845
 
40709
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
40846
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/stems-fill.js
40710
40847
  var fillStems = /* @__PURE__ */ __name((database, { batch = 5e3, until = /* @__PURE__ */ __name(() => false, "until"), onBatch, now: now2 = Date.now } = {}) => {
40711
40848
  const filled2 = { stemmed: 0, drained: 0 };
40712
40849
  const before2 = stemsState(database);
@@ -40801,7 +40938,7 @@ var followDefaultStemmers = /* @__PURE__ */ __name((database, now2 = Date.now) =
40801
40938
  return resetStems(database, { now: now2 });
40802
40939
  }, "followDefaultStemmers");
40803
40940
 
40804
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
40941
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/words.js
40805
40942
  var VOCABULARY = "SELECT term, doc FROM message_words_vocab WHERE col = 'normalized_text'";
40806
40943
  var knownTerms = /* @__PURE__ */ __name(({ database }, terms2) => {
40807
40944
  const lookup = database.prepare(`${VOCABULARY} AND term >= ? AND term <= ? LIMIT 1`);
@@ -40823,7 +40960,7 @@ var termCandidates = /* @__PURE__ */ __name(({ database }, pieces, { shortest, l
40823
40960
  });
40824
40961
  }, "termCandidates");
40825
40962
 
40826
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/search-index.js
40963
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/search-index.js
40827
40964
  var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
40828
40965
  const { database } = context;
40829
40966
  const stemmerFor2 = stemmerCache();
@@ -40845,7 +40982,7 @@ var searchIndexStoreOver = /* @__PURE__ */ __name((context) => {
40845
40982
  };
40846
40983
  }, "searchIndexStoreOver");
40847
40984
 
40848
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
40985
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/searches.js
40849
40986
  var HISTORY_KEPT = 1e3;
40850
40987
  var commandFilter = /* @__PURE__ */ __name((commands) => commands ? { sql: ` AND command IN (${commands.map(() => "?").join(", ")})`, values: [...commands] } : { sql: "", values: [] }, "commandFilter");
40851
40988
  var COLUMNS5 = "id, name, command, params, language, version, fields_version, created_at, updated_at, last_run_at, runs";
@@ -40914,7 +41051,7 @@ var clearHistory = /* @__PURE__ */ __name(({ database }, commands) => {
40914
41051
  return database.prepare(`DELETE FROM searches WHERE name IS NULL${only.sql}`).run(...only.values).changes;
40915
41052
  }, "clearHistory");
40916
41053
 
40917
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/searches.js
41054
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/searches.js
40918
41055
  var searchesStoreOver = /* @__PURE__ */ __name((context) => {
40919
41056
  const { database } = context;
40920
41057
  return {
@@ -40938,7 +41075,7 @@ var searchesStoreOver = /* @__PURE__ */ __name((context) => {
40938
41075
  };
40939
41076
  }, "searchesStoreOver");
40940
41077
 
40941
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
41078
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/agent-actions.js
40942
41079
  var ACTION_TIERS = ["read", "draft", "write-private", "write-public", "destructive", "admin"];
40943
41080
  var ACTION_OUTCOMES = ["ok", "refused", "failed"];
40944
41081
  var CODE = /^[a-z][a-z0-9_]{0,63}$/;
@@ -40981,7 +41118,7 @@ var agentActionsStoreOver = /* @__PURE__ */ __name((context, afterRecord = () =>
40981
41118
  };
40982
41119
  }, "agentActionsStoreOver");
40983
41120
 
40984
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
41121
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/bot-updates.js
40985
41122
  var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
40986
41123
  }) => {
40987
41124
  const { database, now: now2 } = context;
@@ -41040,7 +41177,7 @@ var botUpdateStoreOver = /* @__PURE__ */ __name((context, afterSave = () => {
41040
41177
  };
41041
41178
  }, "botUpdateStoreOver");
41042
41179
 
41043
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
41180
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-events.js
41044
41181
  var DAY4 = 864e5;
41045
41182
  var accountsOf = /* @__PURE__ */ __name((filter) => {
41046
41183
  if (filter.accountIds !== void 0 && filter.accountId !== void 0)
@@ -41149,7 +41286,7 @@ var listEvents = /* @__PURE__ */ __name((database, filter) => {
41149
41286
  return database.prepare(`SELECT e.* FROM events e WHERE ${clauses.join(" AND ")} ORDER BY ${filter.newest ? "e.starts_at DESC, e.id DESC" : "e.starts_at, e.id"} LIMIT ? OFFSET ?`).all(...params, limit, offset).map(eventOf);
41150
41287
  }, "listEvents");
41151
41288
 
41152
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-forget.js
41289
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar-forget.js
41153
41290
  var distinctIds = /* @__PURE__ */ __name((rows) => [...new Set(rows.map((row2) => Number(row2.id)))], "distinctIds");
41154
41291
  var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, accountId, cursorKey: cursorKey2, now: now2 }, refresh) => {
41155
41292
  const unseenBefore = unreferenced(database, "identities");
@@ -41204,7 +41341,7 @@ var forgetCalendarRows = /* @__PURE__ */ __name((database, { calendarId, account
41204
41341
  return { entries: entryIds.length, events: goneEvents.length };
41205
41342
  }, "forgetCalendarRows");
41206
41343
 
41207
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
41344
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/calendar.js
41208
41345
  var calendarOf = /* @__PURE__ */ __name((row2) => ({
41209
41346
  id: Number(row2.id),
41210
41347
  accountId: Number(row2.account_id),
@@ -41791,7 +41928,7 @@ var eventStoreOver = /* @__PURE__ */ __name((context) => {
41791
41928
  };
41792
41929
  }, "eventStoreOver");
41793
41930
 
41794
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
41931
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/catalog.js
41795
41932
  var CATALOG_QUERY = defineQuery({
41796
41933
  entity: "document",
41797
41934
  backend: "sql",
@@ -42033,7 +42170,7 @@ var catalogStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => {
42033
42170
  };
42034
42171
  }, "catalogStoreOver");
42035
42172
 
42036
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
42173
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-document-source.js
42037
42174
  var drive = "CASE WHEN json_valid(n.front_matter) THEN json_extract(n.front_matter,'$.source')='google-drive' ELSE 0 END";
42038
42175
  var field3 = /* @__PURE__ */ __name((name) => `CASE WHEN (${drive}) THEN
42039
42176
  CASE WHEN json_type(n.front_matter,'$.${name}')='text' THEN json_extract(n.front_matter,'$.${name}') END END`, "field");
@@ -42046,7 +42183,7 @@ var contextDocumentTimeKind = `CASE WHEN (${remoteTime}) IS NOT NULL
42046
42183
  THEN 'source-modified' ELSE 'stored-update' END`;
42047
42184
  var contextDocumentUrl = `coalesce(${preferred("url")},n.url,${field3("sourceUrl")})`;
42048
42185
 
42049
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
42186
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-meeting-source.js
42050
42187
  var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
42051
42188
  const { source: source2, words: words3, after: after2, before: before2, limit, maxReadBytes, cursor, signal } = request;
42052
42189
  signal?.throwIfAborted();
@@ -42145,7 +42282,7 @@ var readMeetingContextEvidence = /* @__PURE__ */ __name((database, request) => {
42145
42282
  });
42146
42283
  }, "readMeetingContextEvidence");
42147
42284
 
42148
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
42285
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/context-evidence.js
42149
42286
  var corpora = {
42150
42287
  message: {
42151
42288
  table: "messages",
@@ -42384,7 +42521,789 @@ var contextRecordsOver = /* @__PURE__ */ __name(({ database }) => ({
42384
42521
  }
42385
42522
  }), "contextRecordsOver");
42386
42523
 
42387
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
42524
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/finance.js
42525
+ var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
42526
+ throw new CliError(code, message2, { reason });
42527
+ }, "refuse");
42528
+ var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
42529
+ if (typeof value !== "string" || !allowed.includes(value))
42530
+ return refuse(`${what} is one of ${allowed.join(", ")}`, "finance.field");
42531
+ return value;
42532
+ }, "oneOf");
42533
+ var text3 = /* @__PURE__ */ __name((value, what, limit) => {
42534
+ if (value === void 0 || value === null)
42535
+ return null;
42536
+ if (typeof value !== "string" || !value.trim() || value.length > limit || value.includes("\0"))
42537
+ return refuse(`${what} takes 1\u2013${limit} characters`, "finance.field");
42538
+ return value.trim();
42539
+ }, "text");
42540
+ var isoDate = /* @__PURE__ */ __name((value, what) => {
42541
+ if (value === void 0 || value === null)
42542
+ return null;
42543
+ const date3 = typeof value === "string" ? value.trim() : "";
42544
+ if (!/^\d{4}-\d{2}-\d{2}$/.test(date3) || (/* @__PURE__ */ new Date(`${date3}T00:00:00Z`)).toISOString().slice(0, 10) !== date3)
42545
+ return refuse(`${what} is a date such as 2026-11-15`, "finance.field");
42546
+ return date3;
42547
+ }, "isoDate");
42548
+ var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
42549
+ var evidenceList = /* @__PURE__ */ __name((value) => {
42550
+ if (value === void 0)
42551
+ return [];
42552
+ if (!Array.isArray(value) || value.length > 8 || value.some((one2) => typeof one2 !== "string" || !one2.trim()))
42553
+ return refuse("evidence is a list of at most 8 references", "finance.field");
42554
+ return [...new Set(value.map((one2) => one2.trim()))];
42555
+ }, "evidenceList");
42556
+ var MAX_LINES = 500;
42557
+ var reasonOf = /* @__PURE__ */ __name((metadata3) => {
42558
+ if (metadata3 == null)
42559
+ return null;
42560
+ try {
42561
+ const { reason } = JSON.parse(String(metadata3));
42562
+ return typeof reason === "string" ? reason : null;
42563
+ } catch {
42564
+ return null;
42565
+ }
42566
+ }, "reasonOf");
42567
+ var PAID = "(SELECT coalesce(sum(a.amount), 0) FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = i.id AND p.review = 'confirmed' AND p.deleted_at IS NULL)";
42568
+ var INVOICES = `SELECT i.*, ${PAID} AS paid, b.name AS author_name, b.kind AS author_kind FROM invoices i LEFT JOIN bots b ON i.author_type = 'bot' AND b.id = i.author_id`;
42569
+ var PAYMENTS = "SELECT p.*, (SELECT coalesce(sum(amount), 0) FROM payment_allocations WHERE payment_id = p.id) AS allocated, b.name AS author_name, b.kind AS author_kind FROM payments p LEFT JOIN bots b ON p.author_type = 'bot' AND b.id = p.author_id";
42570
+ var reviewedRowsOver = /* @__PURE__ */ __name((context) => {
42571
+ const { database } = context;
42572
+ const partyOf = /* @__PURE__ */ __name((type, id2) => {
42573
+ if (type == null)
42574
+ return null;
42575
+ const { subject: subject2, subjectName: subjectName2, subjectIsOwner } = subjectOf(database, { subject_type: type, subject_id: id2 });
42576
+ return subject2 === null ? null : { ref: subject2, name: subjectName2, owner: subjectIsOwner };
42577
+ }, "partyOf");
42578
+ const partyThing = /* @__PURE__ */ __name((reference2, what) => {
42579
+ if (reference2 === void 0)
42580
+ return void 0;
42581
+ const thing = requiredThing(database, reference2, what);
42582
+ if (thing.type !== "person" && thing.type !== "organization")
42583
+ return refuse(`${what} is a person: or organization: reference, not ${reference2}`, "finance.party");
42584
+ return thing;
42585
+ }, "partyThing");
42586
+ const reviewedOf = /* @__PURE__ */ __name((row2, type) => ({
42587
+ review: row2.review,
42588
+ author: authorOf(row2),
42589
+ model: row2.model == null ? null : String(row2.model),
42590
+ confirmedBy: row2.confirmed_by_type == null ? null : { type: row2.confirmed_by_type, id: String(row2.confirmed_by_id) },
42591
+ source: String(row2.source),
42592
+ reason: reasonOf(row2.metadata),
42593
+ evidence: evidenceOf(context, { type, id: Number(row2.id) }),
42594
+ ...projectOf(database, row2),
42595
+ createdAt: iso8(row2.created_at),
42596
+ updatedAt: iso8(row2.updated_at)
42597
+ }), "reviewedOf");
42598
+ const written2 = /* @__PURE__ */ __name((input) => {
42599
+ const owner = input.by === "owner";
42600
+ const { actor, model } = authorActor(context, input.by);
42601
+ const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
42602
+ const reason = owner ? null : text3(input.reason, "a reason", 2e3);
42603
+ return {
42604
+ owner,
42605
+ actor,
42606
+ model,
42607
+ source: source2,
42608
+ review: owner ? "confirmed" : "proposed",
42609
+ confirmedType: owner ? actor.type : null,
42610
+ confirmedId: owner ? actor.id : null,
42611
+ metadata: reason === null ? null : JSON.stringify({ reason }),
42612
+ project: input.project === void 0 ? null : projectId(database, input.project),
42613
+ evidence: evidenceList(input.evidence)
42614
+ };
42615
+ }, "written");
42616
+ const keepEvidence = /* @__PURE__ */ __name((type, id2, by) => {
42617
+ if (by.evidence.length)
42618
+ linkEvidence(context, { type, id: id2 }, by.evidence, by.owner ? "owner" : "agent");
42619
+ }, "keepEvidence");
42620
+ const ownerOnly = /* @__PURE__ */ __name((by, what) => {
42621
+ if (by !== "owner")
42622
+ refuse(`only the owner ${what}`, "finance.owner-only", "permission_error");
42623
+ }, "ownerOnly");
42624
+ const keepDecision = /* @__PURE__ */ __name((table, id2, by, reason) => {
42625
+ const why = [by === "owner" ? void 0 : by.reason.trim(), reason?.trim() || void 0].filter(Boolean).join(": ");
42626
+ if (by === "owner" && !why)
42627
+ return;
42628
+ const decision = by === "owner" ? { by: "owner", reason: why } : { by: "agent", bot: by.bot, reason: why };
42629
+ database.prepare(`UPDATE ${table} SET metadata = json_set(coalesce(metadata, '{}'), '$.decision', json(?)) WHERE id = ?`).run(JSON.stringify(decision), id2);
42630
+ }, "keepDecision");
42631
+ return { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision };
42632
+ }, "reviewedRowsOver");
42633
+ var financeOperationsOver = /* @__PURE__ */ __name((context) => {
42634
+ const { database, now: now2 } = context;
42635
+ const { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision } = reviewedRowsOver(context);
42636
+ const invoiceOf2 = /* @__PURE__ */ __name((row2) => {
42637
+ const currency = String(row2.currency);
42638
+ const scale = scaleOf(currency);
42639
+ const [total, paid] = [Number(row2.total), Number(row2.paid)];
42640
+ const counterparty = partyOf(row2.counterparty_type, row2.counterparty_id);
42641
+ const fields4 = {
42642
+ id: Number(row2.id),
42643
+ number: row2.number == null ? null : String(row2.number),
42644
+ direction: row2.direction,
42645
+ total,
42646
+ currency,
42647
+ counterpartyName: counterparty?.name ?? null,
42648
+ dueDate: row2.due_date == null ? null : String(row2.due_date),
42649
+ status: row2.status,
42650
+ review: row2.review
42651
+ };
42652
+ return {
42653
+ id: String(row2.id),
42654
+ ref: `invoice:${row2.id}`,
42655
+ title: invoiceTitle(fields4),
42656
+ direction: fields4.direction,
42657
+ number: fields4.number,
42658
+ issuer: partyOf(row2.issuer_type, row2.issuer_id),
42659
+ counterparty,
42660
+ currency,
42661
+ total: formatDecimal(total, scale),
42662
+ paid: formatDecimal(paid, scale),
42663
+ open: formatDecimal(Math.max(total - paid, 0), scale),
42664
+ issueDate: row2.issue_date == null ? null : String(row2.issue_date),
42665
+ dueDate: fields4.dueDate,
42666
+ status: fields4.status,
42667
+ ...reviewedOf(row2, "invoice")
42668
+ };
42669
+ }, "invoiceOf");
42670
+ const paymentOf3 = /* @__PURE__ */ __name((row2) => {
42671
+ const currency = String(row2.currency);
42672
+ const scale = scaleOf(currency);
42673
+ const [amount, allocated] = [Number(row2.amount), Number(row2.allocated)];
42674
+ const direction = row2.direction;
42675
+ const payer = partyOf(row2.payer_type, row2.payer_id);
42676
+ const payee = partyOf(row2.payee_type, row2.payee_id);
42677
+ const date3 = String(row2.payment_date);
42678
+ return {
42679
+ id: String(row2.id),
42680
+ ref: `payment:${row2.id}`,
42681
+ title: paymentEntryTitle({
42682
+ direction,
42683
+ amount,
42684
+ currency,
42685
+ partyName: (direction === "in" ? payer : payee)?.name ?? null,
42686
+ date: date3,
42687
+ review: row2.review
42688
+ }),
42689
+ direction,
42690
+ payer,
42691
+ payee,
42692
+ amount: formatDecimal(amount, scale),
42693
+ currency,
42694
+ date: date3,
42695
+ reference: row2.reference == null ? null : String(row2.reference),
42696
+ allocated: formatDecimal(allocated, scale),
42697
+ unallocated: formatDecimal(amount - allocated, scale),
42698
+ ...reviewedOf(row2, "payment")
42699
+ };
42700
+ }, "paymentOf");
42701
+ const allocationsWhere = /* @__PURE__ */ __name((column2, id2) => database.prepare(`SELECT a.*, p.currency FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.${column2} = ? ORDER BY a.id`).all(id2).map((row2) => ({
42702
+ payment: `payment:${row2.payment_id}`,
42703
+ invoice: `invoice:${row2.invoice_id}`,
42704
+ amount: formatDecimal(Number(row2.amount), scaleOf(String(row2.currency))),
42705
+ currency: String(row2.currency),
42706
+ createdAt: iso8(row2.created_at)
42707
+ })), "allocationsWhere");
42708
+ const rowOf2 = /* @__PURE__ */ __name((reference2, type) => {
42709
+ const thing = requiredThing(database, reference2.includes(":") ? reference2 : `${type}:${reference2}`, `the ${type}`);
42710
+ if (thing.type !== type)
42711
+ return refuse(`${reference2} is not an ${type}`, "finance.ref");
42712
+ return database.prepare(`${type === "invoice" ? INVOICES : PAYMENTS} WHERE ${type[0]}.id = ?`).get(thing.id);
42713
+ }, "rowOf");
42714
+ const invoiceDetail = /* @__PURE__ */ __name((reference2) => {
42715
+ const row2 = rowOf2(reference2, "invoice");
42716
+ const scale = scaleOf(String(row2.currency));
42717
+ const lines = database.prepare("SELECT * FROM invoice_lines WHERE invoice_id = ? ORDER BY position").all(Number(row2.id)).map((line) => ({
42718
+ position: Number(line.position),
42719
+ description: String(line.description),
42720
+ quantity: String(line.quantity),
42721
+ unitPrice: line.unit_price == null ? null : formatDecimal(Number(line.unit_price), scale),
42722
+ amount: formatDecimal(Number(line.amount), scale)
42723
+ }));
42724
+ return { ...invoiceOf2(row2), lines, allocations: allocationsWhere("invoice_id", Number(row2.id)) };
42725
+ }, "invoiceDetail");
42726
+ const paymentDetail = /* @__PURE__ */ __name((reference2) => {
42727
+ const row2 = rowOf2(reference2, "payment");
42728
+ return { ...paymentOf3(row2), allocations: allocationsWhere("payment_id", Number(row2.id)) };
42729
+ }, "paymentDetail");
42730
+ const settle = /* @__PURE__ */ __name((invoiceId) => {
42731
+ const row2 = database.prepare(`SELECT i.status, i.total, ${PAID} AS paid FROM invoices i WHERE i.id = ?`).get(invoiceId);
42732
+ if (!row2)
42733
+ return;
42734
+ const status = settledStatus(row2.status, Number(row2.total), Number(row2.paid));
42735
+ database.prepare("UPDATE invoices SET status = ?, updated_at = ? WHERE id = ? AND status <> ?").run(status, now2(), invoiceId, status);
42736
+ }, "settle");
42737
+ const allocateRow = /* @__PURE__ */ __name((payment, reference2, units, actor) => {
42738
+ const invoice = rowOf2(reference2, "invoice");
42739
+ const [paymentRef, invoiceRef] = [`payment:${payment.id}`, `invoice:${invoice.id}`];
42740
+ if (invoice.deleted_at != null || invoice.review === "rejected")
42741
+ refuse(`${invoiceRef} is ${invoice.review === "rejected" ? "rejected" : "deleted"}`, "finance.allocate");
42742
+ if (invoice.status === "draft" || invoice.status === "void")
42743
+ refuse(`${invoiceRef} is ${invoice.status}; only an issued invoice is paid`, "finance.allocate");
42744
+ const currency = String(payment.currency);
42745
+ if (invoice.currency !== currency)
42746
+ refuse(`${paymentRef} is in ${currency} and ${invoiceRef} in ${String(invoice.currency)}; the store converts nothing`, "finance.currency");
42747
+ const fromPayment = Number(database.prepare("SELECT coalesce(sum(amount), 0) AS n FROM payment_allocations WHERE payment_id = ?").get(Number(payment.id))?.n);
42748
+ if (fromPayment + units > Number(payment.amount))
42749
+ refuse(`${paymentRef} is ${moneyLabel(Number(payment.amount), currency)} and ${moneyLabel(fromPayment, currency)} of it is already allocated; ${moneyLabel(units, currency)} more is too much`, "finance.over-payment");
42750
+ const toInvoice = Number(database.prepare("SELECT coalesce(sum(a.amount), 0) AS n FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND ((p.review = 'confirmed' AND p.deleted_at IS NULL) OR a.payment_id = ?)").get(Number(invoice.id), Number(payment.id))?.n);
42751
+ if (toInvoice + units > Number(invoice.total))
42752
+ refuse(`${invoiceRef} totals ${moneyLabel(Number(invoice.total), currency)} and ${moneyLabel(toInvoice, currency)} is already allocated to it; ${moneyLabel(units, currency)} more is too much`, "finance.over-invoice");
42753
+ const at = now2();
42754
+ database.prepare("INSERT INTO payment_allocations (payment_id, invoice_id, amount, author_type, author_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (payment_id, invoice_id) DO UPDATE SET amount = amount + excluded.amount, updated_at = excluded.updated_at").run(Number(payment.id), Number(invoice.id), units, actor.type, actor.id, at, at);
42755
+ return Number(invoice.id);
42756
+ }, "allocateRow");
42757
+ const coveredElsewhere = /* @__PURE__ */ __name((paymentId) => {
42758
+ const over = database.prepare("SELECT a.invoice_id, a.amount, i.total, i.currency, (SELECT coalesce(sum(o.amount), 0) FROM payment_allocations o JOIN payments p ON p.id = o.payment_id WHERE o.invoice_id = a.invoice_id AND o.payment_id <> a.payment_id AND p.review = 'confirmed' AND p.deleted_at IS NULL) AS others FROM payment_allocations a JOIN invoices i ON i.id = a.invoice_id WHERE a.payment_id = ? AND a.amount + others > i.total LIMIT 1").get(paymentId);
42759
+ if (!over)
42760
+ return;
42761
+ const currency = String(over.currency);
42762
+ refuse(`invoice:${over.invoice_id} is already covered by other payments: ${moneyLabel(Number(over.others), currency)} of ${moneyLabel(Number(over.total), currency)}; payment:${paymentId} would add ${moneyLabel(Number(over.amount), currency)}, so it stays proposed`, "finance.over-invoice");
42763
+ }, "coveredElsewhere");
42764
+ const decide2 = /* @__PURE__ */ __name((reference2, by, reason, confirm) => {
42765
+ const thing = requiredThing(database, reference2, "the proposal");
42766
+ if (thing.type !== "invoice" && thing.type !== "payment")
42767
+ return refuse(`${reference2} is not an invoice: or payment:`, "finance.ref");
42768
+ const type = thing.type;
42769
+ const table = type === "invoice" ? "invoices" : "payments";
42770
+ const row2 = rowOf2(reference2, type);
42771
+ const ref3 = `${type}:${row2.id}`;
42772
+ assertMayDecide({ id: ref3, proposedBy: proposerOf(database, row2.author_type, row2.author_id), ownerOnly: true }, by, context.decisions);
42773
+ if (row2.review !== "proposed")
42774
+ refuse(`${ref3} is already ${String(row2.review)}`, "proposal.wrong-state");
42775
+ const id2 = Number(row2.id);
42776
+ write(database, () => {
42777
+ const at = now2();
42778
+ if (confirm && type === "payment")
42779
+ coveredElsewhere(id2);
42780
+ if (confirm) {
42781
+ const { actor } = authorActor(context, deciderAuthor(by));
42782
+ database.prepare(`UPDATE ${table} SET review = 'confirmed', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?`).run(actor.type, actor.id, at, id2);
42783
+ } else
42784
+ database.prepare(`UPDATE ${table} SET review = 'rejected', updated_at = ? WHERE id = ?`).run(at, id2);
42785
+ keepDecision(table, id2, by, reason);
42786
+ const touched = type === "invoice" ? [id2] : database.prepare("SELECT invoice_id FROM payment_allocations WHERE payment_id = ?").all(id2).map((one2) => Number(one2.invoice_id));
42787
+ if (!confirm)
42788
+ database.prepare(`DELETE FROM payment_allocations WHERE ${type === "invoice" ? "invoice_id" : "payment_id"} = ?`).run(id2);
42789
+ for (const invoice of touched)
42790
+ settle(invoice);
42791
+ });
42792
+ return type === "invoice" ? invoiceDetail(ref3) : paymentDetail(ref3);
42793
+ }, "decide");
42794
+ const mayAllocate = /* @__PURE__ */ __name((row2, by) => {
42795
+ if (by === "owner")
42796
+ return;
42797
+ const own = row2.author_type === "bot" && row2.author_name != null && botKey(String(row2.author_name)) === botKey(by.bot);
42798
+ if (row2.review !== "proposed" || !own)
42799
+ refuse(`only the owner allocates payment:${row2.id}; a bot allocates only from a payment it proposed that is still proposed`, "finance.owner-only", "permission_error");
42800
+ }, "mayAllocate");
42801
+ const limitOf2 = /* @__PURE__ */ __name((limit) => Math.min(Math.max(limit ?? 100, 1), 500), "limitOf");
42802
+ return {
42803
+ addInvoice: /* @__PURE__ */ __name((input) => {
42804
+ const direction = oneOf4(input.direction, INVOICE_DIRECTIONS, "an invoice's direction");
42805
+ const currency = currencyOf(input.currency);
42806
+ if (!Array.isArray(input.lines) || input.lines.length === 0 || input.lines.length > MAX_LINES)
42807
+ refuse(`an invoice has 1\u2013${MAX_LINES} lines`, "finance.lines");
42808
+ const lines = input.lines.map((line, at) => {
42809
+ const what = `line ${at + 1}`;
42810
+ const quantity = quantityOf(line.quantity ?? "1");
42811
+ const unitPrice = line.unitPrice === void 0 ? null : minorUnits(line.unitPrice, currency, `${what}'s unit price`);
42812
+ const computed = unitPrice === null ? null : lineUnits(quantity.thousandths, unitPrice);
42813
+ const amount = line.amount === void 0 ? computed : minorUnits(line.amount, currency, `${what}'s amount`);
42814
+ if (amount === null)
42815
+ return refuse(`${what} takes a unit price, an amount or both`, "finance.lines");
42816
+ if (computed !== null && computed !== amount)
42817
+ refuse(`${what}: ${quantity.text} \xD7 ${moneyLabel(unitPrice, currency)} is ${moneyLabel(computed, currency)}, not ${moneyLabel(amount, currency)}`, "finance.line-amount");
42818
+ return {
42819
+ description: text3(line.description, `${what}'s description`, 500) ?? refuse(`${what} needs a description`, "finance.lines"),
42820
+ quantity: quantity.text,
42821
+ unitPrice: unitPrice ?? (quantity.thousandths === 1000n ? amount : null),
42822
+ amount
42823
+ };
42824
+ });
42825
+ const total = lines.reduce((sum, line) => sum + line.amount, 0);
42826
+ if (!Number.isSafeInteger(total))
42827
+ refuse("an invoice's total is too large", "finance.total");
42828
+ if (total <= 0)
42829
+ refuse("an invoice totals more than 0", "finance.total");
42830
+ if (input.total !== void 0) {
42831
+ const printed = minorUnits(input.total, currency, "an invoice's total");
42832
+ if (printed !== total)
42833
+ refuse(`the invoice's total ${moneyLabel(printed, currency)} is not the sum of its lines, ${moneyLabel(total, currency)}`, "finance.total");
42834
+ }
42835
+ const number3 = text3(input.number, "an invoice's number", 80);
42836
+ const issueDate = isoDate(input.issueDate, "an invoice's issue date");
42837
+ const dueDate = isoDate(input.dueDate, "an invoice's due date");
42838
+ const id2 = write(database, () => {
42839
+ const issuer = partyThing(input.issuer, "the issuer");
42840
+ const counterparty = partyThing(input.counterparty, "the counterparty") ?? refuse("an invoice names its counterparty, a person: or organization:", "finance.party");
42841
+ const by = written2(input);
42842
+ const at = now2();
42843
+ const made = Number(database.prepare("INSERT INTO invoices (direction, number, issuer_type, issuer_id, counterparty_type, counterparty_id, project_id, currency, total, issue_date, due_date, status, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(direction, number3, issuer?.type ?? null, issuer?.id ?? null, counterparty.type, counterparty.id, by.project, currency, total, issueDate, dueDate, input.draft ? "draft" : "issued", by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at)?.id);
42844
+ const insert = database.prepare("INSERT INTO invoice_lines (invoice_id, position, description, quantity, unit_price, amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
42845
+ for (const [index2, line] of lines.entries())
42846
+ insert.run(made, index2 + 1, line.description, line.quantity, line.unitPrice, line.amount, at, at);
42847
+ keepEvidence("invoice", made, by);
42848
+ return made;
42849
+ });
42850
+ return invoiceDetail(`invoice:${id2}`);
42851
+ }, "addInvoice"),
42852
+ invoice: /* @__PURE__ */ __name((reference2) => invoiceDetail(reference2), "invoice"),
42853
+ invoices: /* @__PURE__ */ __name((filter = {}) => {
42854
+ const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
42855
+ const counterparty = partyThing(filter.counterparty, "the counterparty");
42856
+ const by = proposedBySql("i.author_type", "i.author_id", filter.proposedBy);
42857
+ const status = filter.status === void 0 ? null : oneOf4(filter.status, INVOICE_STATUSES, "a status");
42858
+ const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
42859
+ return database.prepare(`${INVOICES} WHERE i.deleted_at IS NULL AND (? IS NULL OR i.direction = ?) AND (? IS NULL OR i.status = ?) AND (? IS NULL OR i.review = ?) AND (? IS NULL OR i.project_id = ?) AND (? IS NULL OR (i.counterparty_type = ? AND i.counterparty_id = ?)) AND (? IS NULL OR i.number = ?) ${filter.open ? "AND i.status IN ('issued', 'partly_paid') " : ""}AND ${by.sql} ORDER BY i.created_at DESC, i.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, status, status, review, review, project2, project2, counterparty?.type ?? null, counterparty?.type ?? null, counterparty?.id ?? null, filter.number ?? null, filter.number ?? null, ...by.params, limitOf2(filter.limit)).map(invoiceOf2);
42860
+ }, "invoices"),
42861
+ issueInvoice: /* @__PURE__ */ __name((reference2, by) => {
42862
+ ownerOnly(by, "issues an invoice");
42863
+ const row2 = rowOf2(reference2, "invoice");
42864
+ if (row2.status !== "draft")
42865
+ refuse(`invoice:${row2.id} is ${String(row2.status)}, not a draft`, "finance.status");
42866
+ write(database, () => {
42867
+ database.prepare("UPDATE invoices SET status = 'issued', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
42868
+ settle(Number(row2.id));
42869
+ });
42870
+ return invoiceDetail(`invoice:${row2.id}`);
42871
+ }, "issueInvoice"),
42872
+ voidInvoice: /* @__PURE__ */ __name((reference2, by) => {
42873
+ ownerOnly(by, "voids an invoice");
42874
+ const row2 = rowOf2(reference2, "invoice");
42875
+ if (row2.status === "void")
42876
+ refuse(`invoice:${row2.id} is already void`, "finance.status");
42877
+ const allocated = database.prepare("SELECT 1 FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND p.review = 'confirmed' AND p.deleted_at IS NULL LIMIT 1").get(Number(row2.id));
42878
+ if (allocated)
42879
+ refuse(`payments are allocated to invoice:${row2.id}; a paid invoice is not voided`, "finance.status");
42880
+ write(database, () => {
42881
+ database.prepare("DELETE FROM payment_allocations WHERE invoice_id = ? AND payment_id IN (SELECT id FROM payments WHERE review = 'proposed')").run(Number(row2.id));
42882
+ database.prepare("UPDATE invoices SET status = 'void', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
42883
+ });
42884
+ return invoiceDetail(`invoice:${row2.id}`);
42885
+ }, "voidInvoice"),
42886
+ addPayment: /* @__PURE__ */ __name((input) => {
42887
+ const direction = oneOf4(input.direction, MONEY_DIRECTIONS, "a payment's direction");
42888
+ const currency = currencyOf(input.currency);
42889
+ const amount = minorUnits(input.amount, currency, "a payment's amount");
42890
+ if (amount <= 0)
42891
+ refuse("a payment's amount is more than 0", "money.amount");
42892
+ const date3 = isoDate(input.date, "a payment's date") ?? refuse("a payment has a date", "finance.field");
42893
+ const reference2 = text3(input.reference, "a payment's reference", 500);
42894
+ const allocations = (input.allocations ?? []).map(({ invoice, amount: share }) => ({
42895
+ invoice,
42896
+ units: minorUnits(share, currency, `the amount allocated to ${invoice}`)
42897
+ }));
42898
+ const id2 = write(database, () => {
42899
+ const payer = partyThing(input.payer, "the payer");
42900
+ const payee = partyThing(input.payee, "the payee");
42901
+ const by = written2(input);
42902
+ const at = now2();
42903
+ const made = database.prepare("INSERT INTO payments (direction, payer_type, payer_id, payee_type, payee_id, amount, currency, payment_date, reference, project_id, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(direction, payer?.type ?? null, payer?.id ?? null, payee?.type ?? null, payee?.id ?? null, amount, currency, date3, reference2, by.project, by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at);
42904
+ keepEvidence("payment", Number(made.id), by);
42905
+ const touched = allocations.map(({ invoice, units }) => allocateRow(made, invoice, units, by.actor));
42906
+ for (const invoice of touched)
42907
+ settle(invoice);
42908
+ return Number(made.id);
42909
+ });
42910
+ return paymentDetail(`payment:${id2}`);
42911
+ }, "addPayment"),
42912
+ payment: /* @__PURE__ */ __name((reference2) => paymentDetail(reference2), "payment"),
42913
+ payments: /* @__PURE__ */ __name((filter = {}) => {
42914
+ const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
42915
+ const party2 = partyThing(filter.party, "the party");
42916
+ const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
42917
+ const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
42918
+ return database.prepare(`${PAYMENTS} WHERE p.deleted_at IS NULL AND (? IS NULL OR p.direction = ?) AND (? IS NULL OR p.review = ?) AND (? IS NULL OR p.project_id = ?) AND (? IS NULL OR (p.payer_type = ? AND p.payer_id = ?) OR (p.payee_type = ? AND p.payee_id = ?)) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, review, review, project2, project2, party2?.type ?? null, party2?.type ?? null, party2?.id ?? null, party2?.type ?? null, party2?.id ?? null, ...by.params, limitOf2(filter.limit)).map(paymentOf3);
42919
+ }, "payments"),
42920
+ allocate: /* @__PURE__ */ __name(({ payment, invoice, amount, by }) => {
42921
+ const row2 = rowOf2(payment, "payment");
42922
+ const ref3 = `payment:${row2.id}`;
42923
+ mayAllocate(row2, by);
42924
+ if (row2.review === "rejected" || row2.deleted_at != null)
42925
+ refuse(`${ref3} is ${String(row2.review)}`, "finance.allocate");
42926
+ const currency = String(row2.currency);
42927
+ const units = minorUnits(amount, currency, "an allocation");
42928
+ if (units <= 0)
42929
+ refuse("an allocation is more than 0", "money.amount");
42930
+ const invoiceId = write(database, () => {
42931
+ const { actor } = authorActor(context, by);
42932
+ const made = allocateRow(row2, invoice, units, actor);
42933
+ settle(made);
42934
+ return made;
42935
+ });
42936
+ const found2 = allocationsWhere("payment_id", Number(row2.id)).find((one2) => one2.invoice === `invoice:${invoiceId}`);
42937
+ return found2;
42938
+ }, "allocate"),
42939
+ unallocate: /* @__PURE__ */ __name(({ payment, invoice, by }) => {
42940
+ const row2 = rowOf2(payment, "payment");
42941
+ const ref3 = `payment:${row2.id}`;
42942
+ mayAllocate(row2, by);
42943
+ if (row2.review === "rejected" || row2.deleted_at != null)
42944
+ refuse(`${ref3} is ${row2.deleted_at != null ? "deleted" : "rejected"}; only a proposed or confirmed payment's allocations are taken back`, "finance.unallocate");
42945
+ const target = rowOf2(invoice, "invoice");
42946
+ write(database, () => {
42947
+ const gone = database.prepare("DELETE FROM payment_allocations WHERE payment_id = ? AND invoice_id = ?").run(Number(row2.id), Number(target.id));
42948
+ if (gone.changes === 0)
42949
+ throw new CliError("not_found", `${ref3} is not allocated to invoice:${target.id}`, {
42950
+ reason: "finance.not-allocated"
42951
+ });
42952
+ settle(Number(target.id));
42953
+ });
42954
+ return paymentDetail(ref3);
42955
+ }, "unallocate"),
42956
+ confirm: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, true), "confirm"),
42957
+ reject: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, false), "reject"),
42958
+ openTotals: /* @__PURE__ */ __name((filter = {}) => {
42959
+ const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
42960
+ const rows = database.prepare(`SELECT i.direction, i.currency, sum(i.total - ${PAID}) AS open, count(*) AS n FROM invoices i WHERE i.review = 'confirmed' AND i.deleted_at IS NULL AND i.status IN ('issued', 'partly_paid') AND (? IS NULL OR i.project_id = ?) GROUP BY i.direction, i.currency ORDER BY i.currency`).all(project2, project2);
42961
+ const totals = /* @__PURE__ */ __name((direction) => rows.filter((row2) => row2.direction === direction).map((row2) => ({ ...moneyOf(Number(row2.open), String(row2.currency)), invoices: Number(row2.n) })), "totals");
42962
+ return { receivable: totals("receivable"), payable: totals("payable") };
42963
+ }, "openTotals")
42964
+ };
42965
+ }, "financeOperationsOver");
42966
+ var financeStoreOver = /* @__PURE__ */ __name((context) => {
42967
+ const operations = financeOperationsOver(context);
42968
+ return {
42969
+ addInvoice: /* @__PURE__ */ __name(async (input) => operations.addInvoice(input), "addInvoice"),
42970
+ invoice: /* @__PURE__ */ __name(async (reference2) => operations.invoice(reference2), "invoice"),
42971
+ invoices: /* @__PURE__ */ __name(async (filter) => operations.invoices(filter), "invoices"),
42972
+ issueInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.issueInvoice(reference2, by), "issueInvoice"),
42973
+ voidInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.voidInvoice(reference2, by), "voidInvoice"),
42974
+ addPayment: /* @__PURE__ */ __name(async (input) => operations.addPayment(input), "addPayment"),
42975
+ payment: /* @__PURE__ */ __name(async (reference2) => operations.payment(reference2), "payment"),
42976
+ payments: /* @__PURE__ */ __name(async (filter) => operations.payments(filter), "payments"),
42977
+ allocate: /* @__PURE__ */ __name(async (input) => operations.allocate(input), "allocate"),
42978
+ unallocate: /* @__PURE__ */ __name(async (input) => operations.unallocate(input), "unallocate"),
42979
+ confirm: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.confirm(reference2, by, reason), "confirm"),
42980
+ reject: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.reject(reference2, by, reason), "reject"),
42981
+ openTotals: /* @__PURE__ */ __name(async (filter) => operations.openTotals(filter), "openTotals")
42982
+ };
42983
+ }, "financeStoreOver");
42984
+
42985
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/deals.js
42986
+ var TABLES = { deal: "deals", lead: "leads" };
42987
+ var itemsSql = /* @__PURE__ */ __name((kind4) => `SELECT d.*, s.name AS stage_name, s.pipeline_id, p.name AS pipeline_name, b.name AS author_name, b.kind AS author_kind, a.provider AS account_provider, a.external_id AS account_external_id FROM ${TABLES[kind4]} d JOIN pipeline_stages s ON s.id = d.stage_id JOIN pipelines p ON p.id = s.pipeline_id LEFT JOIN bots b ON d.author_type = 'bot' AND b.id = d.author_id LEFT JOIN accounts a ON a.id = d.account_id`, "itemsSql");
42988
+ var MAX_STAGES = 30;
42989
+ var MAX_PEOPLE = 20;
42990
+ var iso9 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
42991
+ var jsonField = /* @__PURE__ */ __name((metadata3, key2) => {
42992
+ if (metadata3 == null)
42993
+ return null;
42994
+ try {
42995
+ const value = JSON.parse(String(metadata3))[key2];
42996
+ return typeof value === "string" ? value : null;
42997
+ } catch {
42998
+ return null;
42999
+ }
43000
+ }, "jsonField");
43001
+ var accountOf3 = /* @__PURE__ */ __name((provider, external) => provider == null ? null : { provider: String(provider), account: String(external) }, "accountOf");
43002
+ var dealOperationsOver = /* @__PURE__ */ __name((context) => {
43003
+ const { database, now: now2 } = context;
43004
+ const { partyOf, partyThing } = reviewedRowsOver(context);
43005
+ const today = /* @__PURE__ */ __name(() => new Date(now2()).toISOString().slice(0, 10), "today");
43006
+ const peopleOf = /* @__PURE__ */ __name((kind4, id2) => database.prepare(`SELECT to_id, role FROM links WHERE from_type = ? AND from_id = ? AND kind = ${linkKind("related-to")} AND to_type = 'person' AND to_id IS NOT NULL ORDER BY id`).all(kind4, id2).map((row2) => ({ ...partyOf("person", row2.to_id), role: row2.role })), "peopleOf");
43007
+ const itemOf = /* @__PURE__ */ __name((kind4) => (row2) => {
43008
+ const currency = row2.currency == null ? null : String(row2.currency);
43009
+ const amount = row2.amount == null || currency === null ? null : Number(row2.amount);
43010
+ const fields4 = {
43011
+ id: Number(row2.id),
43012
+ title: String(row2.title),
43013
+ stage: String(row2.stage_name),
43014
+ amount,
43015
+ currency,
43016
+ status: row2.status
43017
+ };
43018
+ return {
43019
+ id: String(row2.id),
43020
+ ref: `${kind4}:${row2.id}`,
43021
+ kind: kind4,
43022
+ title: fields4.title,
43023
+ summary: dealLine(fields4),
43024
+ pipeline: `pipeline:${row2.pipeline_id}`,
43025
+ pipelineName: String(row2.pipeline_name),
43026
+ stage: fields4.stage,
43027
+ status: fields4.status,
43028
+ organization: partyOf(row2.organization_id == null ? null : "organization", row2.organization_id),
43029
+ currency,
43030
+ amount: amount === null || currency === null ? null : formatDecimal(amount, scaleOf(currency)),
43031
+ closeDate: row2.close_date == null ? null : String(row2.close_date),
43032
+ closedDate: row2.closed_date == null ? null : String(row2.closed_date),
43033
+ closedReason: jsonField(row2.metadata, "closed_reason"),
43034
+ rank: row2.rank == null ? null : Number(row2.rank),
43035
+ deal: row2.deal_id == null ? null : `deal:${row2.deal_id}`,
43036
+ account: accountOf3(row2.account_provider, row2.account_external_id),
43037
+ externalId: row2.external_id == null ? null : String(row2.external_id),
43038
+ people: peopleOf(kind4, fields4.id),
43039
+ author: authorOf(row2),
43040
+ model: row2.model == null ? null : String(row2.model),
43041
+ source: String(row2.source),
43042
+ reason: jsonField(row2.metadata, "reason"),
43043
+ evidence: evidenceOf(context, { type: kind4, id: fields4.id }),
43044
+ ...projectOf(database, row2),
43045
+ createdAt: iso9(row2.created_at),
43046
+ updatedAt: iso9(row2.updated_at)
43047
+ };
43048
+ }, "itemOf");
43049
+ const rowOf2 = /* @__PURE__ */ __name((reference2) => {
43050
+ const thing = requiredThing(database, reference2.includes(":") ? reference2 : `deal:${reference2}`, "the deal");
43051
+ if (thing.type !== "deal" && thing.type !== "lead")
43052
+ return refuse(`${reference2} is not a deal or a lead`, "deal.ref");
43053
+ return { kind: thing.type, row: database.prepare(`${itemsSql(thing.type)} WHERE d.id = ?`).get(thing.id) };
43054
+ }, "rowOf");
43055
+ const read2 = /* @__PURE__ */ __name((reference2) => {
43056
+ const { kind: kind4, row: row2 } = rowOf2(reference2);
43057
+ return itemOf(kind4)(row2);
43058
+ }, "read");
43059
+ const kindOf4 = /* @__PURE__ */ __name((kind4) => kind4 === void 0 ? "deal" : oneOf4(kind4, DEAL_KINDS, "a kind"), "kindOf");
43060
+ const pipelineRows = /* @__PURE__ */ __name((kind4) => database.prepare("SELECT p.*, a.provider AS account_provider, a.external_id AS account_external_id FROM pipelines p LEFT JOIN accounts a ON a.id = p.account_id WHERE (? IS NULL OR p.kind = ?) ORDER BY p.name_folded, p.id").all(kind4 ?? null, kind4 ?? null), "pipelineRows");
43061
+ const label = /* @__PURE__ */ __name((row2) => `pipeline:${row2.id} (${row2.name}${row2.account_provider == null ? "" : `, ${row2.account_provider}:${row2.account_external_id}`})`, "label");
43062
+ const pipelineRow = /* @__PURE__ */ __name((reference2, kind4) => {
43063
+ const named3 = reference2.trim();
43064
+ if (/^pipeline:\d+$/.test(named3)) {
43065
+ const row2 = pipelineRows(kind4).find((one2) => `pipeline:${one2.id}` === named3);
43066
+ if (!row2)
43067
+ throw new CliError("not_found", `no ${kind4 ?? ""} pipeline ${named3}`, { reason: "pipeline.not-found" });
43068
+ return row2;
43069
+ }
43070
+ const rows = pipelineRows(kind4).filter((one2) => one2.name_folded === fold(named3));
43071
+ if (rows.length === 0)
43072
+ throw new CliError("not_found", `no ${kind4 === void 0 ? "" : `${kind4} `}pipeline named ${named3}`, {
43073
+ reason: "pipeline.not-found"
43074
+ });
43075
+ if (rows.length > 1)
43076
+ return refuse(`more than one pipeline is named ${named3}: ${rows.map(label).join(", ")}; name one by its reference`, "pipeline.ambiguous");
43077
+ return rows[0];
43078
+ }, "pipelineRow");
43079
+ const stagesOf = /* @__PURE__ */ __name((pipelineIds) => database.prepare(`SELECT s.*, (SELECT count(*) FROM deals d WHERE d.stage_id = s.id AND d.status = 'open' AND d.deleted_at IS NULL) + (SELECT count(*) FROM leads l WHERE l.stage_id = s.id AND l.status = 'open' AND l.deleted_at IS NULL) AS open FROM pipeline_stages s WHERE s.pipeline_id IN (${pipelineIds.map(() => "?").join(", ") || "NULL"}) ORDER BY s.pipeline_id, s.position, s.id`).all(...pipelineIds), "stagesOf");
43080
+ const pipelinesOf = /* @__PURE__ */ __name((rows) => {
43081
+ const stages = stagesOf(rows.map((row2) => Number(row2.id)));
43082
+ return rows.map((row2) => ({
43083
+ id: String(row2.id),
43084
+ ref: `pipeline:${row2.id}`,
43085
+ name: String(row2.name),
43086
+ kind: row2.kind,
43087
+ account: accountOf3(row2.account_provider, row2.account_external_id),
43088
+ externalId: row2.external_id == null ? null : String(row2.external_id),
43089
+ stages: stages.filter((stage) => stage.pipeline_id === row2.id).map((stage) => ({
43090
+ name: String(stage.name),
43091
+ position: Number(stage.position),
43092
+ outcome: stage.outcome,
43093
+ externalId: stage.external_id == null ? null : String(stage.external_id),
43094
+ open: Number(stage.open)
43095
+ })),
43096
+ createdAt: iso9(row2.created_at)
43097
+ }));
43098
+ }, "pipelinesOf");
43099
+ const stageRow = /* @__PURE__ */ __name((stage, kind4, pipeline) => {
43100
+ const rows = database.prepare("SELECT s.*, p.name AS pipeline_name FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.name_folded = ? AND p.kind = ? AND (? IS NULL OR p.id = ?) ORDER BY p.id").all(fold(stage.trim()), kind4, pipeline ?? null, pipeline ?? null);
43101
+ if (rows.length === 0)
43102
+ return refuse(`no stage named ${stage} in ${pipeline === void 0 ? `a ${kind4} pipeline` : "that pipeline"}`, "deal.stage");
43103
+ if (rows.length > 1)
43104
+ return refuse(`more than one pipeline has a stage named ${stage}: ${rows.map((row2) => `pipeline:${row2.pipeline_id} (${row2.pipeline_name})`).join(", ")}; name the pipeline`, "deal.stage");
43105
+ return rows[0];
43106
+ }, "stageRow");
43107
+ const firstStage = /* @__PURE__ */ __name((kind4, pipeline) => {
43108
+ const pipelines2 = pipeline === void 0 ? pipelineRows(kind4) : [{ id: pipeline }];
43109
+ if (pipelines2.length !== 1)
43110
+ return refuse(`name the stage: ${pipelines2.length === 0 ? `no ${kind4} pipeline is stored` : `more than one ${kind4} pipeline is stored`}`, "deal.stage");
43111
+ const row2 = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id LIMIT 1").get(Number(pipelines2[0]?.id));
43112
+ return row2 ?? refuse("the pipeline has no stages", "deal.stage");
43113
+ }, "firstStage");
43114
+ const funnelOf = /* @__PURE__ */ __name((pipeline, since) => {
43115
+ const kind4 = pipeline.kind;
43116
+ const cutoff = since === null ? null : Date.parse(`${since}T00:00:00Z`);
43117
+ const items = database.prepare(`SELECT d.id, d.status, d.stage_id FROM ${TABLES[kind4]} d JOIN pipeline_stages s ON s.id = d.stage_id WHERE s.pipeline_id = ? AND d.deleted_at IS NULL AND (? IS NULL OR d.created_at >= ?)`).all(Number(pipeline.id), cutoff, cutoff);
43118
+ const stages = database.prepare("SELECT id, position, outcome FROM pipeline_stages WHERE pipeline_id = ? ORDER BY position, id").all(Number(pipeline.id));
43119
+ const order = new Map(stages.map((stage, at) => [Number(stage.id), at]));
43120
+ const lostStage = new Set(stages.filter((stage) => stage.outcome === "lost").map((stage) => Number(stage.id)));
43121
+ const entered = /* @__PURE__ */ new Map();
43122
+ for (const change of database.prepare("SELECT item_id, to_stage_id FROM pipeline_stage_changes WHERE item_type = ? AND pipeline_id = ?").all(kind4, Number(pipeline.id))) {
43123
+ const list2 = entered.get(Number(change.item_id)) ?? [];
43124
+ list2.push(Number(change.to_stage_id));
43125
+ entered.set(Number(change.item_id), list2);
43126
+ }
43127
+ const furthest = items.map((item) => {
43128
+ if (item.status === "won")
43129
+ return Number.POSITIVE_INFINITY;
43130
+ const reached = [...entered.get(Number(item.id)) ?? [], Number(item.stage_id)].filter((stage) => !lostStage.has(stage)).map((stage) => order.get(stage) ?? -1);
43131
+ return Math.max(-1, ...reached);
43132
+ });
43133
+ const lost = items.filter((item) => item.status === "lost").length;
43134
+ const reachedAt = /* @__PURE__ */ __name((at) => lostStage.has(Number(stages[at]?.id)) ? lost : furthest.filter((far) => far >= at).length, "reachedAt");
43135
+ const funnel = pipeline.stages.map((stage, at) => {
43136
+ const reached = reachedAt(at);
43137
+ const next = stages.findIndex((one2, after2) => after2 > at && !lostStage.has(Number(one2.id)));
43138
+ const conversion = lostStage.has(Number(stages[at]?.id)) || next === -1 || reached === 0 ? null : Math.round(reachedAt(next) / reached * 1e3) / 1e3;
43139
+ return { ...stage, reached, conversion };
43140
+ });
43141
+ const won = items.filter((item) => item.status === "won").length;
43142
+ return {
43143
+ ...pipeline,
43144
+ stages: funnel,
43145
+ totals: {
43146
+ items: items.length,
43147
+ open: items.length - won - lost,
43148
+ won,
43149
+ lost,
43150
+ winRate: won + lost === 0 ? null : Math.round(won / (won + lost) * 1e3) / 1e3
43151
+ },
43152
+ since
43153
+ };
43154
+ }, "funnelOf");
43155
+ const setStage = /* @__PURE__ */ __name((kind4, id2, stage, status, date3) => {
43156
+ database.prepare(`UPDATE ${TABLES[kind4]} SET stage_id = ?, status = ?, closed_date = ?, updated_at = ? WHERE id = ?`).run(Number(stage.id), status, status === "open" ? null : date3, now2(), id2);
43157
+ }, "setStage");
43158
+ const notDeleted = /* @__PURE__ */ __name((row2, kind4, what) => {
43159
+ if (row2.deleted_at != null)
43160
+ refuse(`${kind4}:${row2.id} is deleted; it no longer ${what}`, "deal.closed");
43161
+ }, "notDeleted");
43162
+ return {
43163
+ addPipeline: /* @__PURE__ */ __name(({ name, kind: kind4, stages, by }) => {
43164
+ const pipelineKind = kindOf4(kind4);
43165
+ const named3 = text3(name, "a pipeline's name", 80) ?? refuse("a pipeline needs a name", "pipeline.field");
43166
+ if (!Array.isArray(stages) || stages.length === 0 || stages.length > MAX_STAGES)
43167
+ refuse(`a pipeline has 1\u2013${MAX_STAGES} stages`, "pipeline.field");
43168
+ const kept = stages.map((stage) => {
43169
+ const one2 = typeof stage === "string" ? { name: stage } : stage;
43170
+ return {
43171
+ name: text3(one2.name, "a stage's name", 80),
43172
+ outcome: one2.outcome === void 0 ? "open" : oneOf4(one2.outcome, STAGE_OUTCOMES, "a stage's outcome")
43173
+ };
43174
+ });
43175
+ if (new Set(kept.map((stage) => fold(stage.name))).size !== kept.length)
43176
+ refuse("each stage is named once", "pipeline.field");
43177
+ authorActor(context, by);
43178
+ const id2 = write(database, () => {
43179
+ if (database.prepare("SELECT 1 FROM pipelines WHERE name_folded = ? AND kind = ? AND account_id IS NULL").get(fold(named3), pipelineKind))
43180
+ refuse(`a ${pipelineKind} pipeline named ${named3} is already stored`, "pipeline.duplicate");
43181
+ const at = now2();
43182
+ const made = Number(database.prepare("INSERT INTO pipelines (kind, name, name_folded, created_at, updated_at) VALUES (?, ?, ?, ?, ?) RETURNING id").get(pipelineKind, named3, fold(named3), at, at)?.id);
43183
+ const insert = database.prepare("INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?)");
43184
+ kept.forEach((stage, index2) => {
43185
+ insert.run(made, stage.name, fold(stage.name), index2 + 1, stage.outcome, at, at);
43186
+ });
43187
+ return made;
43188
+ });
43189
+ return pipelinesOf(pipelineRows(pipelineKind).filter((row2) => Number(row2.id) === id2))[0];
43190
+ }, "addPipeline"),
43191
+ pipelines: /* @__PURE__ */ __name((filter = {}) => pipelinesOf(pipelineRows(filter.kind === void 0 ? void 0 : kindOf4(filter.kind))), "pipelines"),
43192
+ pipeline: /* @__PURE__ */ __name((reference2, options = {}) => {
43193
+ const kind4 = options.kind === void 0 ? void 0 : kindOf4(options.kind);
43194
+ const since = isoDate(options.since, "the first day counted");
43195
+ return funnelOf(pipelinesOf([pipelineRow(reference2, kind4)])[0], since);
43196
+ }, "pipeline"),
43197
+ add: /* @__PURE__ */ __name((input) => {
43198
+ const kind4 = kindOf4(input.kind);
43199
+ const title = text3(input.title, `a ${kind4}'s title`, 200) ?? refuse(`a ${kind4} needs a title`, "deal.field");
43200
+ if (input.amount === void 0 !== (input.currency === void 0))
43201
+ refuse("an amount and its currency come together", "deal.field");
43202
+ const currency = input.currency === void 0 ? null : currencyOf(input.currency);
43203
+ const amount = currency === null ? null : minorUnits(input.amount, currency, "an amount");
43204
+ if (amount !== null && amount < 0)
43205
+ refuse("an amount is 0 or more", "money.amount");
43206
+ const closeDate = isoDate(input.closeDate, "an expected close day");
43207
+ const people2 = input.people ?? [];
43208
+ if (people2.length > MAX_PEOPLE)
43209
+ refuse(`at most ${MAX_PEOPLE} people`, "deal.field");
43210
+ const owner = input.by === "owner";
43211
+ const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
43212
+ const reason = text3(input.reason, "a reason", 2e3);
43213
+ const evidence = input.evidence ?? [];
43214
+ if (!Array.isArray(evidence) || evidence.length > 8)
43215
+ refuse("evidence is at most 8 references", "deal.field");
43216
+ const id2 = write(database, () => {
43217
+ const pipeline = input.pipeline === void 0 ? void 0 : Number(pipelineRow(input.pipeline, kind4).id);
43218
+ const stageText = text3(input.stage, "a stage's name", 80);
43219
+ const stage = stageText === null ? kind4 === "lead" ? firstStage(kind4, pipeline) : refuse("a deal starts in a stage", "deal.field") : stageRow(stageText, kind4, pipeline);
43220
+ const status = stage.outcome ?? "open";
43221
+ const organization2 = partyThing(input.organization, "the organization");
43222
+ if (organization2 !== void 0 && organization2.type !== "organization")
43223
+ refuse(`the organization is an organization: reference, not ${input.organization}`, "deal.field");
43224
+ const persons2 = people2.map(({ person: person2, role }) => {
43225
+ const thing = requiredThing(database, person2, "the person");
43226
+ if (thing.type !== "person")
43227
+ return refuse(`${person2} is not a person`, "deal.field");
43228
+ return { id: thing.id, role: oneOf4(role, DEAL_ROLES, "a person's role") };
43229
+ });
43230
+ const { actor, model } = authorActor(context, input.by);
43231
+ const at = now2();
43232
+ const made = Number(database.prepare(`INSERT INTO ${TABLES[kind4]} (title, organization_id, project_id, stage_id, status, currency, amount, close_date, closed_date, author_type, author_id, model, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id`).get(title, organization2?.id ?? null, input.project === void 0 ? null : projectId(database, input.project), Number(stage.id), status, currency, amount, closeDate, status === "open" ? null : today(), actor.type, actor.id, model, source2, reason === null ? null : JSON.stringify({ reason }), at, at)?.id);
43233
+ const link3 = database.prepare(`INSERT INTO links (from_type, from_id, to_type, to_id, kind, role, source, confirmed, created_at, author, updated_at) VALUES (?, ?, 'person', ?, ${linkKind("related-to")}, ?, ?, 1, ?, ?, ?)`);
43234
+ for (const person2 of persons2)
43235
+ link3.run(kind4, made, person2.id, person2.role, owner ? "owner" : "suggested", at, owner ? "owner" : "agent", at);
43236
+ if (evidence.length)
43237
+ linkEvidence(context, { type: kind4, id: made }, evidence, owner ? "owner" : "agent");
43238
+ return made;
43239
+ });
43240
+ return read2(`${kind4}:${id2}`);
43241
+ }, "add"),
43242
+ get: /* @__PURE__ */ __name((reference2) => read2(reference2), "get"),
43243
+ list: /* @__PURE__ */ __name((filter = {}) => {
43244
+ const kind4 = kindOf4(filter.kind);
43245
+ const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
43246
+ const organization2 = partyThing(filter.organization, "the organization");
43247
+ const by = proposedBySql("d.author_type", "d.author_id", filter.proposedBy);
43248
+ const status = filter.status === void 0 ? null : oneOf4(filter.status, DEAL_STATUSES, "a status");
43249
+ const stage = filter.stage === void 0 ? null : fold(filter.stage.trim());
43250
+ const pipeline = filter.pipeline === void 0 ? null : Number(pipelineRow(filter.pipeline, kind4).id);
43251
+ const limit = Math.min(Math.max(filter.limit ?? 100, 1), 500);
43252
+ return database.prepare(`${itemsSql(kind4)} WHERE d.deleted_at IS NULL AND (? IS NULL OR d.status = ?) AND (? IS NULL OR d.project_id = ?) AND (? IS NULL OR s.name_folded = ?) AND (? IS NULL OR p.id = ?) AND (? IS NULL OR d.organization_id = ?) AND ${by.sql} ORDER BY d.created_at DESC, d.id DESC LIMIT ?`).all(status, status, project2, project2, stage, stage, pipeline, pipeline, organization2?.id ?? null, organization2?.id ?? null, ...by.params, limit).map(itemOf(kind4));
43253
+ }, "list"),
43254
+ find: /* @__PURE__ */ __name(({ words: words3, anyWord, accounts: accounts2, limit }) => {
43255
+ const wanted = [...new Set(words3.map((word2) => fold(word2).trim()).filter(Boolean))];
43256
+ if (!wanted.length)
43257
+ return [];
43258
+ const most2 = Math.min(Math.max(limit ?? 100, 1), 500);
43259
+ const within = accounts2?.map(({ provider, account }) => `${provider}\0${account}`);
43260
+ const found2 = DEAL_KINDS.flatMap((kind4) => database.prepare(`SELECT d.id, d.title, d.updated_at, a.provider, a.external_id AS account FROM ${TABLES[kind4]} d LEFT JOIN accounts a ON a.id = d.account_id WHERE d.deleted_at IS NULL`).all().filter((row2) => within === void 0 || within.includes(`${row2.provider}\0${row2.account}`)).map((row2) => {
43261
+ const title = fold(String(row2.title));
43262
+ return { kind: kind4, row: row2, score: wanted.filter((word2) => title.includes(word2)).length };
43263
+ }).filter(({ score }) => anyWord ? score > 0 : score === wanted.length));
43264
+ return found2.sort((a, b) => b.score - a.score || Number(b.row.updated_at) - Number(a.row.updated_at) || Number(b.row.id) - Number(a.row.id)).slice(0, most2).map(({ kind: kind4, row: row2 }) => read2(`${kind4}:${row2.id}`));
43265
+ }, "find"),
43266
+ move: /* @__PURE__ */ __name((reference2, { stage, by }) => {
43267
+ authorActor(context, by);
43268
+ const { kind: kind4, row: row2 } = rowOf2(reference2);
43269
+ notDeleted(row2, kind4, "moves");
43270
+ const next = stageRow(text3(stage, "a stage's name", 80) ?? "", kind4, Number(row2.pipeline_id));
43271
+ write(database, () => setStage(kind4, Number(row2.id), next, next.outcome, today()));
43272
+ return read2(`${kind4}:${row2.id}`);
43273
+ }, "move"),
43274
+ close: /* @__PURE__ */ __name((reference2, { status, date: date3, reason, by }) => {
43275
+ authorActor(context, by);
43276
+ const outcome = oneOf4(status, ["won", "lost"], "a closed status");
43277
+ const day = isoDate(date3, "the day it closed") ?? today();
43278
+ const why = text3(reason, "why it closed", 2e3);
43279
+ const { kind: kind4, row: row2 } = rowOf2(reference2);
43280
+ notDeleted(row2, kind4, "closes");
43281
+ const stage = database.prepare("SELECT * FROM pipeline_stages WHERE pipeline_id = ? AND outcome = ? ORDER BY position, id LIMIT 1").get(Number(row2.pipeline_id), outcome) ?? { id: row2.stage_id };
43282
+ write(database, () => {
43283
+ setStage(kind4, Number(row2.id), stage, outcome, day);
43284
+ if (why !== null)
43285
+ database.prepare(`UPDATE ${TABLES[kind4]} SET metadata = json_set(coalesce(metadata, '{}'), '$.closed_reason', ?) WHERE id = ?`).run(why, Number(row2.id));
43286
+ });
43287
+ return read2(`${kind4}:${row2.id}`);
43288
+ }, "close")
43289
+ };
43290
+ }, "dealOperationsOver");
43291
+ var dealsStoreOver = /* @__PURE__ */ __name((context) => {
43292
+ const operations = dealOperationsOver(context);
43293
+ return {
43294
+ addPipeline: /* @__PURE__ */ __name(async (input) => operations.addPipeline(input), "addPipeline"),
43295
+ pipelines: /* @__PURE__ */ __name(async (filter) => operations.pipelines(filter), "pipelines"),
43296
+ pipeline: /* @__PURE__ */ __name(async (reference2, options) => operations.pipeline(reference2, options), "pipeline"),
43297
+ add: /* @__PURE__ */ __name(async (input) => operations.add(input), "add"),
43298
+ get: /* @__PURE__ */ __name(async (reference2) => operations.get(reference2), "get"),
43299
+ list: /* @__PURE__ */ __name(async (filter) => operations.list(filter), "list"),
43300
+ find: /* @__PURE__ */ __name(async (search2) => operations.find(search2), "find"),
43301
+ move: /* @__PURE__ */ __name(async (reference2, input) => operations.move(reference2, input), "move"),
43302
+ close: /* @__PURE__ */ __name(async (reference2, input) => operations.close(reference2, input), "close")
43303
+ };
43304
+ }, "dealsStoreOver");
43305
+
43306
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/note-search.js
42388
43307
  var NOTE_FIELDS = [
42389
43308
  "text",
42390
43309
  "exact",
@@ -42814,7 +43733,7 @@ var noteSearchOver = /* @__PURE__ */ __name((context) => {
42814
43733
  };
42815
43734
  }, "noteSearchOver");
42816
43735
 
42817
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
43736
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/event-search.js
42818
43737
  var EVENT_FIELDS = ["text", "exact", "body", "title", "date", "in"];
42819
43738
  var inEventAccounts = /* @__PURE__ */ __name((event) => searchableCopy(event, "c.account_id IN (SELECT CAST(value AS INTEGER) FROM json_each(?))"), "inEventAccounts");
42820
43739
  var EVENT_CORPUS = {
@@ -42946,468 +43865,7 @@ var eventSearchOver = /* @__PURE__ */ __name((context) => {
42946
43865
  };
42947
43866
  }, "eventSearchOver");
42948
43867
 
42949
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/finance.js
42950
- var refuse = /* @__PURE__ */ __name((message2, reason, code = "validation_error") => {
42951
- throw new CliError(code, message2, { reason });
42952
- }, "refuse");
42953
- var oneOf4 = /* @__PURE__ */ __name((value, allowed, what) => {
42954
- if (typeof value !== "string" || !allowed.includes(value))
42955
- return refuse(`${what} is one of ${allowed.join(", ")}`, "finance.field");
42956
- return value;
42957
- }, "oneOf");
42958
- var text3 = /* @__PURE__ */ __name((value, what, limit) => {
42959
- if (value === void 0 || value === null)
42960
- return null;
42961
- if (typeof value !== "string" || !value.trim() || value.length > limit || value.includes("\0"))
42962
- return refuse(`${what} takes 1\u2013${limit} characters`, "finance.field");
42963
- return value.trim();
42964
- }, "text");
42965
- var isoDate = /* @__PURE__ */ __name((value, what) => {
42966
- if (value === void 0 || value === null)
42967
- return null;
42968
- const date3 = typeof value === "string" ? value.trim() : "";
42969
- if (!/^\d{4}-\d{2}-\d{2}$/.test(date3) || (/* @__PURE__ */ new Date(`${date3}T00:00:00Z`)).toISOString().slice(0, 10) !== date3)
42970
- return refuse(`${what} is a date such as 2026-11-15`, "finance.field");
42971
- return date3;
42972
- }, "isoDate");
42973
- var iso8 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
42974
- var evidenceList = /* @__PURE__ */ __name((value) => {
42975
- if (value === void 0)
42976
- return [];
42977
- if (!Array.isArray(value) || value.length > 8 || value.some((one2) => typeof one2 !== "string" || !one2.trim()))
42978
- return refuse("evidence is a list of at most 8 references", "finance.field");
42979
- return [...new Set(value.map((one2) => one2.trim()))];
42980
- }, "evidenceList");
42981
- var MAX_LINES = 500;
42982
- var reasonOf = /* @__PURE__ */ __name((metadata3) => {
42983
- if (metadata3 == null)
42984
- return null;
42985
- try {
42986
- const { reason } = JSON.parse(String(metadata3));
42987
- return typeof reason === "string" ? reason : null;
42988
- } catch {
42989
- return null;
42990
- }
42991
- }, "reasonOf");
42992
- var PAID = "(SELECT coalesce(sum(a.amount), 0) FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = i.id AND p.review = 'confirmed' AND p.deleted_at IS NULL)";
42993
- var INVOICES = `SELECT i.*, ${PAID} AS paid, b.name AS author_name, b.kind AS author_kind FROM invoices i LEFT JOIN bots b ON i.author_type = 'bot' AND b.id = i.author_id`;
42994
- var PAYMENTS = "SELECT p.*, (SELECT coalesce(sum(amount), 0) FROM payment_allocations WHERE payment_id = p.id) AS allocated, b.name AS author_name, b.kind AS author_kind FROM payments p LEFT JOIN bots b ON p.author_type = 'bot' AND b.id = p.author_id";
42995
- var reviewedRowsOver = /* @__PURE__ */ __name((context) => {
42996
- const { database } = context;
42997
- const partyOf = /* @__PURE__ */ __name((type, id2) => {
42998
- if (type == null)
42999
- return null;
43000
- const { subject: subject2, subjectName: subjectName2, subjectIsOwner } = subjectOf(database, { subject_type: type, subject_id: id2 });
43001
- return subject2 === null ? null : { ref: subject2, name: subjectName2, owner: subjectIsOwner };
43002
- }, "partyOf");
43003
- const partyThing = /* @__PURE__ */ __name((reference2, what) => {
43004
- if (reference2 === void 0)
43005
- return void 0;
43006
- const thing = requiredThing(database, reference2, what);
43007
- if (thing.type !== "person" && thing.type !== "organization")
43008
- return refuse(`${what} is a person: or organization: reference, not ${reference2}`, "finance.party");
43009
- return thing;
43010
- }, "partyThing");
43011
- const reviewedOf = /* @__PURE__ */ __name((row2, type) => ({
43012
- review: row2.review,
43013
- author: authorOf(row2),
43014
- model: row2.model == null ? null : String(row2.model),
43015
- confirmedBy: row2.confirmed_by_type == null ? null : { type: row2.confirmed_by_type, id: String(row2.confirmed_by_id) },
43016
- source: String(row2.source),
43017
- reason: reasonOf(row2.metadata),
43018
- evidence: evidenceOf(context, { type, id: Number(row2.id) }),
43019
- ...projectOf(database, row2),
43020
- createdAt: iso8(row2.created_at),
43021
- updatedAt: iso8(row2.updated_at)
43022
- }), "reviewedOf");
43023
- const written2 = /* @__PURE__ */ __name((input) => {
43024
- const owner = input.by === "owner";
43025
- const { actor, model } = authorActor(context, input.by);
43026
- const source2 = owner ? "owner" : text3(input.source, "a source", 80) ?? "agent";
43027
- const reason = owner ? null : text3(input.reason, "a reason", 2e3);
43028
- return {
43029
- owner,
43030
- actor,
43031
- model,
43032
- source: source2,
43033
- review: owner ? "confirmed" : "proposed",
43034
- confirmedType: owner ? actor.type : null,
43035
- confirmedId: owner ? actor.id : null,
43036
- metadata: reason === null ? null : JSON.stringify({ reason }),
43037
- project: input.project === void 0 ? null : projectId(database, input.project),
43038
- evidence: evidenceList(input.evidence)
43039
- };
43040
- }, "written");
43041
- const keepEvidence = /* @__PURE__ */ __name((type, id2, by) => {
43042
- if (by.evidence.length)
43043
- linkEvidence(context, { type, id: id2 }, by.evidence, by.owner ? "owner" : "agent");
43044
- }, "keepEvidence");
43045
- const ownerOnly = /* @__PURE__ */ __name((by, what) => {
43046
- if (by !== "owner")
43047
- refuse(`only the owner ${what}`, "finance.owner-only", "permission_error");
43048
- }, "ownerOnly");
43049
- const keepDecision = /* @__PURE__ */ __name((table, id2, by, reason) => {
43050
- const why = [by === "owner" ? void 0 : by.reason.trim(), reason?.trim() || void 0].filter(Boolean).join(": ");
43051
- if (by === "owner" && !why)
43052
- return;
43053
- const decision = by === "owner" ? { by: "owner", reason: why } : { by: "agent", bot: by.bot, reason: why };
43054
- database.prepare(`UPDATE ${table} SET metadata = json_set(coalesce(metadata, '{}'), '$.decision', json(?)) WHERE id = ?`).run(JSON.stringify(decision), id2);
43055
- }, "keepDecision");
43056
- return { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision };
43057
- }, "reviewedRowsOver");
43058
- var financeOperationsOver = /* @__PURE__ */ __name((context) => {
43059
- const { database, now: now2 } = context;
43060
- const { partyOf, partyThing, reviewedOf, written: written2, keepEvidence, ownerOnly, keepDecision } = reviewedRowsOver(context);
43061
- const invoiceOf2 = /* @__PURE__ */ __name((row2) => {
43062
- const currency = String(row2.currency);
43063
- const scale = scaleOf(currency);
43064
- const [total, paid] = [Number(row2.total), Number(row2.paid)];
43065
- const counterparty = partyOf(row2.counterparty_type, row2.counterparty_id);
43066
- const fields4 = {
43067
- id: Number(row2.id),
43068
- number: row2.number == null ? null : String(row2.number),
43069
- direction: row2.direction,
43070
- total,
43071
- currency,
43072
- counterpartyName: counterparty?.name ?? null,
43073
- dueDate: row2.due_date == null ? null : String(row2.due_date),
43074
- status: row2.status,
43075
- review: row2.review
43076
- };
43077
- return {
43078
- id: String(row2.id),
43079
- ref: `invoice:${row2.id}`,
43080
- title: invoiceTitle(fields4),
43081
- direction: fields4.direction,
43082
- number: fields4.number,
43083
- issuer: partyOf(row2.issuer_type, row2.issuer_id),
43084
- counterparty,
43085
- currency,
43086
- total: formatDecimal(total, scale),
43087
- paid: formatDecimal(paid, scale),
43088
- open: formatDecimal(Math.max(total - paid, 0), scale),
43089
- issueDate: row2.issue_date == null ? null : String(row2.issue_date),
43090
- dueDate: fields4.dueDate,
43091
- status: fields4.status,
43092
- ...reviewedOf(row2, "invoice")
43093
- };
43094
- }, "invoiceOf");
43095
- const paymentOf3 = /* @__PURE__ */ __name((row2) => {
43096
- const currency = String(row2.currency);
43097
- const scale = scaleOf(currency);
43098
- const [amount, allocated] = [Number(row2.amount), Number(row2.allocated)];
43099
- const direction = row2.direction;
43100
- const payer = partyOf(row2.payer_type, row2.payer_id);
43101
- const payee = partyOf(row2.payee_type, row2.payee_id);
43102
- const date3 = String(row2.payment_date);
43103
- return {
43104
- id: String(row2.id),
43105
- ref: `payment:${row2.id}`,
43106
- title: paymentEntryTitle({
43107
- direction,
43108
- amount,
43109
- currency,
43110
- partyName: (direction === "in" ? payer : payee)?.name ?? null,
43111
- date: date3,
43112
- review: row2.review
43113
- }),
43114
- direction,
43115
- payer,
43116
- payee,
43117
- amount: formatDecimal(amount, scale),
43118
- currency,
43119
- date: date3,
43120
- reference: row2.reference == null ? null : String(row2.reference),
43121
- allocated: formatDecimal(allocated, scale),
43122
- unallocated: formatDecimal(amount - allocated, scale),
43123
- ...reviewedOf(row2, "payment")
43124
- };
43125
- }, "paymentOf");
43126
- const allocationsWhere = /* @__PURE__ */ __name((column2, id2) => database.prepare(`SELECT a.*, p.currency FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.${column2} = ? ORDER BY a.id`).all(id2).map((row2) => ({
43127
- payment: `payment:${row2.payment_id}`,
43128
- invoice: `invoice:${row2.invoice_id}`,
43129
- amount: formatDecimal(Number(row2.amount), scaleOf(String(row2.currency))),
43130
- currency: String(row2.currency),
43131
- createdAt: iso8(row2.created_at)
43132
- })), "allocationsWhere");
43133
- const rowOf2 = /* @__PURE__ */ __name((reference2, type) => {
43134
- const thing = requiredThing(database, reference2.includes(":") ? reference2 : `${type}:${reference2}`, `the ${type}`);
43135
- if (thing.type !== type)
43136
- return refuse(`${reference2} is not an ${type}`, "finance.ref");
43137
- return database.prepare(`${type === "invoice" ? INVOICES : PAYMENTS} WHERE ${type[0]}.id = ?`).get(thing.id);
43138
- }, "rowOf");
43139
- const invoiceDetail = /* @__PURE__ */ __name((reference2) => {
43140
- const row2 = rowOf2(reference2, "invoice");
43141
- const scale = scaleOf(String(row2.currency));
43142
- const lines = database.prepare("SELECT * FROM invoice_lines WHERE invoice_id = ? ORDER BY position").all(Number(row2.id)).map((line) => ({
43143
- position: Number(line.position),
43144
- description: String(line.description),
43145
- quantity: String(line.quantity),
43146
- unitPrice: line.unit_price == null ? null : formatDecimal(Number(line.unit_price), scale),
43147
- amount: formatDecimal(Number(line.amount), scale)
43148
- }));
43149
- return { ...invoiceOf2(row2), lines, allocations: allocationsWhere("invoice_id", Number(row2.id)) };
43150
- }, "invoiceDetail");
43151
- const paymentDetail = /* @__PURE__ */ __name((reference2) => {
43152
- const row2 = rowOf2(reference2, "payment");
43153
- return { ...paymentOf3(row2), allocations: allocationsWhere("payment_id", Number(row2.id)) };
43154
- }, "paymentDetail");
43155
- const settle = /* @__PURE__ */ __name((invoiceId) => {
43156
- const row2 = database.prepare(`SELECT i.status, i.total, ${PAID} AS paid FROM invoices i WHERE i.id = ?`).get(invoiceId);
43157
- if (!row2)
43158
- return;
43159
- const status = settledStatus(row2.status, Number(row2.total), Number(row2.paid));
43160
- database.prepare("UPDATE invoices SET status = ?, updated_at = ? WHERE id = ? AND status <> ?").run(status, now2(), invoiceId, status);
43161
- }, "settle");
43162
- const allocateRow = /* @__PURE__ */ __name((payment, reference2, units, actor) => {
43163
- const invoice = rowOf2(reference2, "invoice");
43164
- const [paymentRef, invoiceRef] = [`payment:${payment.id}`, `invoice:${invoice.id}`];
43165
- if (invoice.deleted_at != null || invoice.review === "rejected")
43166
- refuse(`${invoiceRef} is ${invoice.review === "rejected" ? "rejected" : "deleted"}`, "finance.allocate");
43167
- if (invoice.status === "draft" || invoice.status === "void")
43168
- refuse(`${invoiceRef} is ${invoice.status}; only an issued invoice is paid`, "finance.allocate");
43169
- const currency = String(payment.currency);
43170
- if (invoice.currency !== currency)
43171
- refuse(`${paymentRef} is in ${currency} and ${invoiceRef} in ${String(invoice.currency)}; the store converts nothing`, "finance.currency");
43172
- const fromPayment = Number(database.prepare("SELECT coalesce(sum(amount), 0) AS n FROM payment_allocations WHERE payment_id = ?").get(Number(payment.id))?.n);
43173
- if (fromPayment + units > Number(payment.amount))
43174
- refuse(`${paymentRef} is ${moneyLabel(Number(payment.amount), currency)} and ${moneyLabel(fromPayment, currency)} of it is already allocated; ${moneyLabel(units, currency)} more is too much`, "finance.over-payment");
43175
- const toInvoice = Number(database.prepare("SELECT coalesce(sum(a.amount), 0) AS n FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND ((p.review = 'confirmed' AND p.deleted_at IS NULL) OR a.payment_id = ?)").get(Number(invoice.id), Number(payment.id))?.n);
43176
- if (toInvoice + units > Number(invoice.total))
43177
- refuse(`${invoiceRef} totals ${moneyLabel(Number(invoice.total), currency)} and ${moneyLabel(toInvoice, currency)} is already allocated to it; ${moneyLabel(units, currency)} more is too much`, "finance.over-invoice");
43178
- const at = now2();
43179
- database.prepare("INSERT INTO payment_allocations (payment_id, invoice_id, amount, author_type, author_id, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT (payment_id, invoice_id) DO UPDATE SET amount = amount + excluded.amount, updated_at = excluded.updated_at").run(Number(payment.id), Number(invoice.id), units, actor.type, actor.id, at, at);
43180
- return Number(invoice.id);
43181
- }, "allocateRow");
43182
- const coveredElsewhere = /* @__PURE__ */ __name((paymentId) => {
43183
- const over = database.prepare("SELECT a.invoice_id, a.amount, i.total, i.currency, (SELECT coalesce(sum(o.amount), 0) FROM payment_allocations o JOIN payments p ON p.id = o.payment_id WHERE o.invoice_id = a.invoice_id AND o.payment_id <> a.payment_id AND p.review = 'confirmed' AND p.deleted_at IS NULL) AS others FROM payment_allocations a JOIN invoices i ON i.id = a.invoice_id WHERE a.payment_id = ? AND a.amount + others > i.total LIMIT 1").get(paymentId);
43184
- if (!over)
43185
- return;
43186
- const currency = String(over.currency);
43187
- refuse(`invoice:${over.invoice_id} is already covered by other payments: ${moneyLabel(Number(over.others), currency)} of ${moneyLabel(Number(over.total), currency)}; payment:${paymentId} would add ${moneyLabel(Number(over.amount), currency)}, so it stays proposed`, "finance.over-invoice");
43188
- }, "coveredElsewhere");
43189
- const decide2 = /* @__PURE__ */ __name((reference2, by, reason, confirm) => {
43190
- const thing = requiredThing(database, reference2, "the proposal");
43191
- if (thing.type !== "invoice" && thing.type !== "payment")
43192
- return refuse(`${reference2} is not an invoice: or payment:`, "finance.ref");
43193
- const type = thing.type;
43194
- const table = type === "invoice" ? "invoices" : "payments";
43195
- const row2 = rowOf2(reference2, type);
43196
- const ref3 = `${type}:${row2.id}`;
43197
- assertMayDecide({ id: ref3, proposedBy: proposerOf(database, row2.author_type, row2.author_id), ownerOnly: true }, by, context.decisions);
43198
- if (row2.review !== "proposed")
43199
- refuse(`${ref3} is already ${String(row2.review)}`, "proposal.wrong-state");
43200
- const id2 = Number(row2.id);
43201
- write(database, () => {
43202
- const at = now2();
43203
- if (confirm && type === "payment")
43204
- coveredElsewhere(id2);
43205
- if (confirm) {
43206
- const { actor } = authorActor(context, deciderAuthor(by));
43207
- database.prepare(`UPDATE ${table} SET review = 'confirmed', confirmed_by_type = ?, confirmed_by_id = ?, updated_at = ? WHERE id = ?`).run(actor.type, actor.id, at, id2);
43208
- } else
43209
- database.prepare(`UPDATE ${table} SET review = 'rejected', updated_at = ? WHERE id = ?`).run(at, id2);
43210
- keepDecision(table, id2, by, reason);
43211
- const touched = type === "invoice" ? [id2] : database.prepare("SELECT invoice_id FROM payment_allocations WHERE payment_id = ?").all(id2).map((one2) => Number(one2.invoice_id));
43212
- if (!confirm)
43213
- database.prepare(`DELETE FROM payment_allocations WHERE ${type === "invoice" ? "invoice_id" : "payment_id"} = ?`).run(id2);
43214
- for (const invoice of touched)
43215
- settle(invoice);
43216
- });
43217
- return type === "invoice" ? invoiceDetail(ref3) : paymentDetail(ref3);
43218
- }, "decide");
43219
- const mayAllocate = /* @__PURE__ */ __name((row2, by) => {
43220
- if (by === "owner")
43221
- return;
43222
- const own = row2.author_type === "bot" && row2.author_name != null && botKey(String(row2.author_name)) === botKey(by.bot);
43223
- if (row2.review !== "proposed" || !own)
43224
- refuse(`only the owner allocates payment:${row2.id}; a bot allocates only from a payment it proposed that is still proposed`, "finance.owner-only", "permission_error");
43225
- }, "mayAllocate");
43226
- const limitOf2 = /* @__PURE__ */ __name((limit) => Math.min(Math.max(limit ?? 100, 1), 500), "limitOf");
43227
- return {
43228
- addInvoice: /* @__PURE__ */ __name((input) => {
43229
- const direction = oneOf4(input.direction, INVOICE_DIRECTIONS, "an invoice's direction");
43230
- const currency = currencyOf(input.currency);
43231
- if (!Array.isArray(input.lines) || input.lines.length === 0 || input.lines.length > MAX_LINES)
43232
- refuse(`an invoice has 1\u2013${MAX_LINES} lines`, "finance.lines");
43233
- const lines = input.lines.map((line, at) => {
43234
- const what = `line ${at + 1}`;
43235
- const quantity = quantityOf(line.quantity ?? "1");
43236
- const unitPrice = line.unitPrice === void 0 ? null : minorUnits(line.unitPrice, currency, `${what}'s unit price`);
43237
- const computed = unitPrice === null ? null : lineUnits(quantity.thousandths, unitPrice);
43238
- const amount = line.amount === void 0 ? computed : minorUnits(line.amount, currency, `${what}'s amount`);
43239
- if (amount === null)
43240
- return refuse(`${what} takes a unit price, an amount or both`, "finance.lines");
43241
- if (computed !== null && computed !== amount)
43242
- refuse(`${what}: ${quantity.text} \xD7 ${moneyLabel(unitPrice, currency)} is ${moneyLabel(computed, currency)}, not ${moneyLabel(amount, currency)}`, "finance.line-amount");
43243
- return {
43244
- description: text3(line.description, `${what}'s description`, 500) ?? refuse(`${what} needs a description`, "finance.lines"),
43245
- quantity: quantity.text,
43246
- unitPrice: unitPrice ?? (quantity.thousandths === 1000n ? amount : null),
43247
- amount
43248
- };
43249
- });
43250
- const total = lines.reduce((sum, line) => sum + line.amount, 0);
43251
- if (!Number.isSafeInteger(total))
43252
- refuse("an invoice's total is too large", "finance.total");
43253
- if (total <= 0)
43254
- refuse("an invoice totals more than 0", "finance.total");
43255
- if (input.total !== void 0) {
43256
- const printed = minorUnits(input.total, currency, "an invoice's total");
43257
- if (printed !== total)
43258
- refuse(`the invoice's total ${moneyLabel(printed, currency)} is not the sum of its lines, ${moneyLabel(total, currency)}`, "finance.total");
43259
- }
43260
- const number3 = text3(input.number, "an invoice's number", 80);
43261
- const issueDate = isoDate(input.issueDate, "an invoice's issue date");
43262
- const dueDate = isoDate(input.dueDate, "an invoice's due date");
43263
- const id2 = write(database, () => {
43264
- const issuer = partyThing(input.issuer, "the issuer");
43265
- const counterparty = partyThing(input.counterparty, "the counterparty") ?? refuse("an invoice names its counterparty, a person: or organization:", "finance.party");
43266
- const by = written2(input);
43267
- const at = now2();
43268
- const made = Number(database.prepare("INSERT INTO invoices (direction, number, issuer_type, issuer_id, counterparty_type, counterparty_id, project_id, currency, total, issue_date, due_date, status, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING id").get(direction, number3, issuer?.type ?? null, issuer?.id ?? null, counterparty.type, counterparty.id, by.project, currency, total, issueDate, dueDate, input.draft ? "draft" : "issued", by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at)?.id);
43269
- const insert = database.prepare("INSERT INTO invoice_lines (invoice_id, position, description, quantity, unit_price, amount, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
43270
- for (const [index2, line] of lines.entries())
43271
- insert.run(made, index2 + 1, line.description, line.quantity, line.unitPrice, line.amount, at, at);
43272
- keepEvidence("invoice", made, by);
43273
- return made;
43274
- });
43275
- return invoiceDetail(`invoice:${id2}`);
43276
- }, "addInvoice"),
43277
- invoice: /* @__PURE__ */ __name((reference2) => invoiceDetail(reference2), "invoice"),
43278
- invoices: /* @__PURE__ */ __name((filter = {}) => {
43279
- const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
43280
- const counterparty = partyThing(filter.counterparty, "the counterparty");
43281
- const by = proposedBySql("i.author_type", "i.author_id", filter.proposedBy);
43282
- const status = filter.status === void 0 ? null : oneOf4(filter.status, INVOICE_STATUSES, "a status");
43283
- const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
43284
- return database.prepare(`${INVOICES} WHERE i.deleted_at IS NULL AND (? IS NULL OR i.direction = ?) AND (? IS NULL OR i.status = ?) AND (? IS NULL OR i.review = ?) AND (? IS NULL OR i.project_id = ?) AND (? IS NULL OR (i.counterparty_type = ? AND i.counterparty_id = ?)) AND (? IS NULL OR i.number = ?) ${filter.open ? "AND i.status IN ('issued', 'partly_paid') " : ""}AND ${by.sql} ORDER BY i.created_at DESC, i.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, status, status, review, review, project2, project2, counterparty?.type ?? null, counterparty?.type ?? null, counterparty?.id ?? null, filter.number ?? null, filter.number ?? null, ...by.params, limitOf2(filter.limit)).map(invoiceOf2);
43285
- }, "invoices"),
43286
- issueInvoice: /* @__PURE__ */ __name((reference2, by) => {
43287
- ownerOnly(by, "issues an invoice");
43288
- const row2 = rowOf2(reference2, "invoice");
43289
- if (row2.status !== "draft")
43290
- refuse(`invoice:${row2.id} is ${String(row2.status)}, not a draft`, "finance.status");
43291
- write(database, () => {
43292
- database.prepare("UPDATE invoices SET status = 'issued', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
43293
- settle(Number(row2.id));
43294
- });
43295
- return invoiceDetail(`invoice:${row2.id}`);
43296
- }, "issueInvoice"),
43297
- voidInvoice: /* @__PURE__ */ __name((reference2, by) => {
43298
- ownerOnly(by, "voids an invoice");
43299
- const row2 = rowOf2(reference2, "invoice");
43300
- if (row2.status === "void")
43301
- refuse(`invoice:${row2.id} is already void`, "finance.status");
43302
- const allocated = database.prepare("SELECT 1 FROM payment_allocations a JOIN payments p ON p.id = a.payment_id WHERE a.invoice_id = ? AND p.review = 'confirmed' AND p.deleted_at IS NULL LIMIT 1").get(Number(row2.id));
43303
- if (allocated)
43304
- refuse(`payments are allocated to invoice:${row2.id}; a paid invoice is not voided`, "finance.status");
43305
- write(database, () => {
43306
- database.prepare("DELETE FROM payment_allocations WHERE invoice_id = ? AND payment_id IN (SELECT id FROM payments WHERE review = 'proposed')").run(Number(row2.id));
43307
- database.prepare("UPDATE invoices SET status = 'void', updated_at = ? WHERE id = ?").run(now2(), Number(row2.id));
43308
- });
43309
- return invoiceDetail(`invoice:${row2.id}`);
43310
- }, "voidInvoice"),
43311
- addPayment: /* @__PURE__ */ __name((input) => {
43312
- const direction = oneOf4(input.direction, MONEY_DIRECTIONS, "a payment's direction");
43313
- const currency = currencyOf(input.currency);
43314
- const amount = minorUnits(input.amount, currency, "a payment's amount");
43315
- if (amount <= 0)
43316
- refuse("a payment's amount is more than 0", "money.amount");
43317
- const date3 = isoDate(input.date, "a payment's date") ?? refuse("a payment has a date", "finance.field");
43318
- const reference2 = text3(input.reference, "a payment's reference", 500);
43319
- const allocations = (input.allocations ?? []).map(({ invoice, amount: share }) => ({
43320
- invoice,
43321
- units: minorUnits(share, currency, `the amount allocated to ${invoice}`)
43322
- }));
43323
- const id2 = write(database, () => {
43324
- const payer = partyThing(input.payer, "the payer");
43325
- const payee = partyThing(input.payee, "the payee");
43326
- const by = written2(input);
43327
- const at = now2();
43328
- const made = database.prepare("INSERT INTO payments (direction, payer_type, payer_id, payee_type, payee_id, amount, currency, payment_date, reference, project_id, review, author_type, author_id, model, confirmed_by_type, confirmed_by_id, source, metadata, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) RETURNING *").get(direction, payer?.type ?? null, payer?.id ?? null, payee?.type ?? null, payee?.id ?? null, amount, currency, date3, reference2, by.project, by.review, by.actor.type, by.actor.id, by.model, by.confirmedType, by.confirmedId, by.source, by.metadata, at, at);
43329
- keepEvidence("payment", Number(made.id), by);
43330
- const touched = allocations.map(({ invoice, units }) => allocateRow(made, invoice, units, by.actor));
43331
- for (const invoice of touched)
43332
- settle(invoice);
43333
- return Number(made.id);
43334
- });
43335
- return paymentDetail(`payment:${id2}`);
43336
- }, "addPayment"),
43337
- payment: /* @__PURE__ */ __name((reference2) => paymentDetail(reference2), "payment"),
43338
- payments: /* @__PURE__ */ __name((filter = {}) => {
43339
- const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
43340
- const party2 = partyThing(filter.party, "the party");
43341
- const by = proposedBySql("p.author_type", "p.author_id", filter.proposedBy);
43342
- const review = filter.review === void 0 ? null : oneOf4(filter.review, FINANCE_REVIEWS, "a review");
43343
- return database.prepare(`${PAYMENTS} WHERE p.deleted_at IS NULL AND (? IS NULL OR p.direction = ?) AND (? IS NULL OR p.review = ?) AND (? IS NULL OR p.project_id = ?) AND (? IS NULL OR (p.payer_type = ? AND p.payer_id = ?) OR (p.payee_type = ? AND p.payee_id = ?)) AND ${by.sql} ORDER BY p.created_at DESC, p.id DESC LIMIT ?`).all(filter.direction ?? null, filter.direction ?? null, review, review, project2, project2, party2?.type ?? null, party2?.type ?? null, party2?.id ?? null, party2?.type ?? null, party2?.id ?? null, ...by.params, limitOf2(filter.limit)).map(paymentOf3);
43344
- }, "payments"),
43345
- allocate: /* @__PURE__ */ __name(({ payment, invoice, amount, by }) => {
43346
- const row2 = rowOf2(payment, "payment");
43347
- const ref3 = `payment:${row2.id}`;
43348
- mayAllocate(row2, by);
43349
- if (row2.review === "rejected" || row2.deleted_at != null)
43350
- refuse(`${ref3} is ${String(row2.review)}`, "finance.allocate");
43351
- const currency = String(row2.currency);
43352
- const units = minorUnits(amount, currency, "an allocation");
43353
- if (units <= 0)
43354
- refuse("an allocation is more than 0", "money.amount");
43355
- const invoiceId = write(database, () => {
43356
- const { actor } = authorActor(context, by);
43357
- const made = allocateRow(row2, invoice, units, actor);
43358
- settle(made);
43359
- return made;
43360
- });
43361
- const found2 = allocationsWhere("payment_id", Number(row2.id)).find((one2) => one2.invoice === `invoice:${invoiceId}`);
43362
- return found2;
43363
- }, "allocate"),
43364
- unallocate: /* @__PURE__ */ __name(({ payment, invoice, by }) => {
43365
- const row2 = rowOf2(payment, "payment");
43366
- const ref3 = `payment:${row2.id}`;
43367
- mayAllocate(row2, by);
43368
- if (row2.review === "rejected" || row2.deleted_at != null)
43369
- refuse(`${ref3} is ${row2.deleted_at != null ? "deleted" : "rejected"}; only a proposed or confirmed payment's allocations are taken back`, "finance.unallocate");
43370
- const target = rowOf2(invoice, "invoice");
43371
- write(database, () => {
43372
- const gone = database.prepare("DELETE FROM payment_allocations WHERE payment_id = ? AND invoice_id = ?").run(Number(row2.id), Number(target.id));
43373
- if (gone.changes === 0)
43374
- throw new CliError("not_found", `${ref3} is not allocated to invoice:${target.id}`, {
43375
- reason: "finance.not-allocated"
43376
- });
43377
- settle(Number(target.id));
43378
- });
43379
- return paymentDetail(ref3);
43380
- }, "unallocate"),
43381
- confirm: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, true), "confirm"),
43382
- reject: /* @__PURE__ */ __name((reference2, by, reason) => decide2(reference2, by, reason, false), "reject"),
43383
- openTotals: /* @__PURE__ */ __name((filter = {}) => {
43384
- const project2 = filter.project === void 0 ? null : projectId(database, filter.project);
43385
- const rows = database.prepare(`SELECT i.direction, i.currency, sum(i.total - ${PAID}) AS open, count(*) AS n FROM invoices i WHERE i.review = 'confirmed' AND i.deleted_at IS NULL AND i.status IN ('issued', 'partly_paid') AND (? IS NULL OR i.project_id = ?) GROUP BY i.direction, i.currency ORDER BY i.currency`).all(project2, project2);
43386
- const totals = /* @__PURE__ */ __name((direction) => rows.filter((row2) => row2.direction === direction).map((row2) => ({ ...moneyOf(Number(row2.open), String(row2.currency)), invoices: Number(row2.n) })), "totals");
43387
- return { receivable: totals("receivable"), payable: totals("payable") };
43388
- }, "openTotals")
43389
- };
43390
- }, "financeOperationsOver");
43391
- var financeStoreOver = /* @__PURE__ */ __name((context) => {
43392
- const operations = financeOperationsOver(context);
43393
- return {
43394
- addInvoice: /* @__PURE__ */ __name(async (input) => operations.addInvoice(input), "addInvoice"),
43395
- invoice: /* @__PURE__ */ __name(async (reference2) => operations.invoice(reference2), "invoice"),
43396
- invoices: /* @__PURE__ */ __name(async (filter) => operations.invoices(filter), "invoices"),
43397
- issueInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.issueInvoice(reference2, by), "issueInvoice"),
43398
- voidInvoice: /* @__PURE__ */ __name(async (reference2, by) => operations.voidInvoice(reference2, by), "voidInvoice"),
43399
- addPayment: /* @__PURE__ */ __name(async (input) => operations.addPayment(input), "addPayment"),
43400
- payment: /* @__PURE__ */ __name(async (reference2) => operations.payment(reference2), "payment"),
43401
- payments: /* @__PURE__ */ __name(async (filter) => operations.payments(filter), "payments"),
43402
- allocate: /* @__PURE__ */ __name(async (input) => operations.allocate(input), "allocate"),
43403
- unallocate: /* @__PURE__ */ __name(async (input) => operations.unallocate(input), "unallocate"),
43404
- confirm: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.confirm(reference2, by, reason), "confirm"),
43405
- reject: /* @__PURE__ */ __name(async (reference2, by, reason) => operations.reject(reference2, by, reason), "reject"),
43406
- openTotals: /* @__PURE__ */ __name(async (filter) => operations.openTotals(filter), "openTotals")
43407
- };
43408
- }, "financeStoreOver");
43409
-
43410
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
43868
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-entries.js
43411
43869
  var refuse2 = /* @__PURE__ */ __name((message2, reason) => {
43412
43870
  throw new CliError("validation_error", message2, { reason });
43413
43871
  }, "refuse");
@@ -43485,7 +43943,7 @@ var paymentEntriesOver = /* @__PURE__ */ __name((context) => {
43485
43943
  };
43486
43944
  }, "paymentEntriesOver");
43487
43945
 
43488
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
43946
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/evidence-findings.js
43489
43947
  var EVIDENCE_FINDINGS_KIND = "evidence_findings";
43490
43948
  var reference = /* @__PURE__ */ __name((raw) => {
43491
43949
  if (/^(document|note):[1-9]\d*$/.test(raw))
@@ -43511,7 +43969,7 @@ var validateEvidenceFindings = /* @__PURE__ */ __name((input) => {
43511
43969
  return valid;
43512
43970
  }, "validateEvidenceFindings");
43513
43971
 
43514
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/moment.js
43972
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/moment.js
43515
43973
  var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false } = {}) => {
43516
43974
  try {
43517
43975
  return zonedMoment(wanted, timezoneOf(zone), { start: 0, end: wanted.length }, { end });
@@ -43523,9 +43981,9 @@ var calendarMoment = /* @__PURE__ */ __name((wanted, flag6, { zone, end = false
43523
43981
  }
43524
43982
  }, "calendarMoment");
43525
43983
 
43526
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
43984
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/facts.js
43527
43985
  var NAMED3 = "SELECT f.*, b.name AS author_name, b.kind AS author_kind FROM facts f LEFT JOIN bots b ON f.author_type = 'bot' AND b.id = f.author_id";
43528
- var iso9 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
43986
+ var iso10 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
43529
43987
  var oneOf5 = /* @__PURE__ */ __name((value, allowed, what) => {
43530
43988
  if (typeof value !== "string" || !allowed.includes(value))
43531
43989
  throw new CliError("validation_error", `${what} is one of ${allowed.join(", ")}`);
@@ -43541,7 +43999,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
43541
43999
  status: row2.status,
43542
44000
  ...projectOf(database, row2),
43543
44001
  ...subjectOf(database, row2),
43544
- occurredAt: row2.occurred_at == null ? null : iso9(row2.occurred_at),
44002
+ occurredAt: row2.occurred_at == null ? null : iso10(row2.occurred_at),
43545
44003
  supersedes: row2.supersedes_id == null ? null : `fact:${row2.supersedes_id}`,
43546
44004
  author: authorOf(row2),
43547
44005
  model: row2.model == null ? null : String(row2.model),
@@ -43549,8 +44007,8 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
43549
44007
  scope: row2.scope == null ? null : row2.scope,
43550
44008
  source: String(row2.source),
43551
44009
  evidence: evidenceOf(context, { type: "fact", id: Number(row2.id) }),
43552
- createdAt: iso9(row2.created_at),
43553
- updatedAt: iso9(row2.updated_at)
44010
+ createdAt: iso10(row2.created_at),
44011
+ updatedAt: iso10(row2.updated_at)
43554
44012
  }), "factOf");
43555
44013
  const rowOf2 = /* @__PURE__ */ __name((reference2) => {
43556
44014
  const thing = requiredThing(database, reference2.includes(":") ? reference2 : `fact:${reference2}`, "the fact");
@@ -43666,7 +44124,7 @@ var factOperationsOver = /* @__PURE__ */ __name((context) => {
43666
44124
  const step = {
43667
44125
  step: "revoked",
43668
44126
  by: "owner",
43669
- at: iso9(at),
44127
+ at: iso10(at),
43670
44128
  confirmedBy: { type: current.confirmed_by_type, id: String(current.confirmed_by_id) },
43671
44129
  ...decision === void 0 ? {} : { decision },
43672
44130
  ...reason?.trim() ? { reason: reason.trim() } : {}
@@ -43732,7 +44190,7 @@ var factsStoreOver = /* @__PURE__ */ __name((context) => {
43732
44190
  };
43733
44191
  }, "factsStoreOver");
43734
44192
 
43735
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
44193
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/findings-core.js
43736
44194
  var invalid4 = /* @__PURE__ */ __name((message2) => {
43737
44195
  throw new CliError("validation_error", message2);
43738
44196
  }, "invalid");
@@ -43836,10 +44294,10 @@ var findingsCoreOver = /* @__PURE__ */ __name((context, kind4) => {
43836
44294
  return { snapshot: snapshot2, snapshotParts, previous, outcomes, create };
43837
44295
  }, "findingsCoreOver");
43838
44296
 
43839
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
44297
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/proposed-actions.js
43840
44298
  var PROPOSAL_STATUSES = ["proposed", "approved", "rejected", "executed", "failed"];
43841
44299
  var PROPOSAL_VERDICTS = ["useful", "not_useful"];
43842
- var iso10 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
44300
+ var iso11 = /* @__PURE__ */ __name((value) => value == null ? null : new Date(Number(value)).toISOString(), "iso");
43843
44301
  var json2 = /* @__PURE__ */ __name((value) => value == null ? null : JSON.parse(String(value)), "json");
43844
44302
  var STATUS = `CASE WHEN p.status = 'approved' AND p.kind IN ('${MEETING_FINDINGS_KIND}', '${EVIDENCE_FINDINGS_KIND}', '${MAIL_FINDINGS_KIND}') AND json_array_length(p.result, '$.accepted') = 0 THEN 'rejected' ELSE p.status END`;
43845
44303
  var NAMED4 = `SELECT p.*, ${STATUS} AS shown_status, b.name AS proposer_name, b.kind AS proposer_kind FROM proposed_actions p LEFT JOIN bots b ON p.proposed_by_type = 'bot' AND b.id = p.proposed_by_id`;
@@ -43870,12 +44328,12 @@ var proposalOperationsOver = /* @__PURE__ */ __name((context) => {
43870
44328
  kind: row2.proposed_by_type !== "bot" ? null : row2.proposer_kind === "rule" || row2.proposer_name === "rule" ? "rule" : "agent"
43871
44329
  },
43872
44330
  decidedBy: row2.decided_by_type == null ? null : { type: row2.decided_by_type, id: String(row2.decided_by_id) },
43873
- decidedAt: iso10(row2.decided_at),
43874
- executedAt: iso10(row2.executed_at),
44331
+ decidedAt: iso11(row2.decided_at),
44332
+ executedAt: iso11(row2.executed_at),
43875
44333
  result: json2(row2.result),
43876
44334
  error: row2.error == null ? null : String(row2.error),
43877
44335
  verdict: row2.verdict ?? null,
43878
- createdAt: iso10(row2.created_at)
44336
+ createdAt: iso11(row2.created_at)
43879
44337
  };
43880
44338
  }, "actionOf");
43881
44339
  const rowOf2 = /* @__PURE__ */ __name((id2) => {
@@ -44001,7 +44459,7 @@ var proposedActionsStoreOver = /* @__PURE__ */ __name((context) => {
44001
44459
  };
44002
44460
  }, "proposedActionsStoreOver");
44003
44461
 
44004
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
44462
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/evidence-findings.js
44005
44463
  var stale = /* @__PURE__ */ __name(() => {
44006
44464
  throw new CliError("validation_error", "evidence findings changed since they were read; stage a new batch", {
44007
44465
  reason: "evidence-findings.stale"
@@ -44182,7 +44640,7 @@ var evidenceFindingsStoreOver = /* @__PURE__ */ __name((context) => {
44182
44640
  };
44183
44641
  }, "evidenceFindingsStoreOver");
44184
44642
 
44185
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
44643
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/involvements.js
44186
44644
  var pendingInvolvements = /* @__PURE__ */ __name((database) => Number(database.prepare("SELECT count(*) AS n FROM involvement_pending").get()?.n ?? 0), "pendingInvolvements");
44187
44645
  var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => ({
44188
44646
  rebuild: /* @__PURE__ */ __name((personId) => write(database, () => {
@@ -44235,7 +44693,7 @@ var involvementStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) => (
44235
44693
  }, "forPerson")
44236
44694
  }), "involvementStoreOver");
44237
44695
 
44238
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
44696
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-projects.js
44239
44697
  import { createHash as createHash12 } from "node:crypto";
44240
44698
  var fields3 = "id,from_id,to_id,source,confirmed,updated_at,length(evidence) AS evidenceLength,substr(evidence,1,2000) AS evidence";
44241
44699
  var id = /* @__PURE__ */ __name((value) => {
@@ -44321,7 +44779,7 @@ var meetingProjectsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 })
44321
44779
  };
44322
44780
  }, "meetingProjectsStoreOver");
44323
44781
 
44324
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
44782
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/knowledge-query.js
44325
44783
  var ORGANIZATIONS_QUERY = {
44326
44784
  entity: "organization",
44327
44785
  backend: "sql",
@@ -44362,7 +44820,7 @@ var REMINDERS_QUERY = {
44362
44820
  })
44363
44821
  };
44364
44822
 
44365
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/organizations.js
44823
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/organizations.js
44366
44824
  var organizationOf = /* @__PURE__ */ __name((row2) => ({
44367
44825
  id: String(row2.id),
44368
44826
  ref: `organization:${row2.id}`,
@@ -44395,7 +44853,7 @@ var organizationsStoreOver = /* @__PURE__ */ __name(({ database, now: now2 }) =>
44395
44853
  }), "updateOrganization")
44396
44854
  }), "organizationsStoreOver");
44397
44855
 
44398
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/relation-proposals.js
44856
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/relation-proposals.js
44399
44857
  var relationOf = /* @__PURE__ */ __name((link3) => ({
44400
44858
  id: link3.id,
44401
44859
  from: link3.from,
@@ -44621,16 +45079,16 @@ var decidedOrigin = /* @__PURE__ */ __name((by) => by === "owner" ? { origin: "o
44621
45079
  provenance: `agent:${by.bot} for the owner: ${by.reason.trim()}`
44622
45080
  }, "decidedOrigin");
44623
45081
 
44624
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
45082
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
44625
45083
  import { createHash as createHash15 } from "node:crypto";
44626
45084
 
44627
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
45085
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
44628
45086
  import { createHash as createHash14 } from "node:crypto";
44629
45087
 
44630
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
45088
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
44631
45089
  import { createHash as createHash13 } from "node:crypto";
44632
45090
 
44633
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
45091
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-input.js
44634
45092
  var consolidationId = /* @__PURE__ */ __name((value, field4) => {
44635
45093
  if (typeof value !== "string" || !/^[1-9]\d*$/.test(value) || !Number.isSafeInteger(Number(value)))
44636
45094
  throw new CliError("validation_error", `${field4} must be a positive canonical tag id`);
@@ -44681,7 +45139,7 @@ var consolidationApplyInput = /* @__PURE__ */ __name((options) => {
44681
45139
  return input;
44682
45140
  }, "consolidationApplyInput");
44683
45141
 
44684
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
45142
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation-apply.js
44685
45143
  var receiptOf = /* @__PURE__ */ __name((row2) => ({
44686
45144
  id: String(row2.id),
44687
45145
  sourceId: String(row2.source_id),
@@ -44756,7 +45214,7 @@ var applyTagConsolidation = /* @__PURE__ */ __name((context, preview, options) =
44756
45214
  }, { beforeCommit: check3 });
44757
45215
  }, "applyTagConsolidation");
44758
45216
 
44759
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
45217
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/tag-consolidation.js
44760
45218
  var selections = [
44761
45219
  ["taggings", "tag_id IN (SELECT value FROM json_each(?))"],
44762
45220
  ["aliases", "aliasable_type='tag' AND aliasable_id IN (SELECT value FROM json_each(?))"],
@@ -44900,7 +45358,7 @@ var previewRows = /* @__PURE__ */ __name((context, options, source2, survivor, m
44900
45358
  };
44901
45359
  }, "previewRows");
44902
45360
 
44903
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
45361
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/vocabulary.js
44904
45362
  var kinds = ["project", "tag", "topic"];
44905
45363
  var cancelled2 = /* @__PURE__ */ __name((signal) => {
44906
45364
  if (signal?.aborted)
@@ -45164,13 +45622,13 @@ var vocabularyStoreOver = /* @__PURE__ */ __name((context) => {
45164
45622
  };
45165
45623
  }, "vocabularyStoreOver");
45166
45624
 
45167
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
45625
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/knowledge.js
45168
45626
  var TYPED_KEY_PREFIXES = new Set(Object.values(TASK_KEY_PREFIXES));
45169
45627
  var ORGANIZATION_KINDS = ["company", "team", "family", "community"];
45170
45628
  var PROJECT_TYPES = ["work", "client", "personal", "oss", "other"];
45171
45629
  var SCOPES = ["personal", "work"];
45172
45630
  var UNVERIFIED = { type: "unknown" };
45173
- var iso11 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
45631
+ var iso12 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
45174
45632
  var bounded2 = /* @__PURE__ */ __name((limit = 100, offset = 0) => {
45175
45633
  if (!Number.isInteger(limit) || limit < 1 || limit > 500 || !Number.isInteger(offset) || offset < 0 || offset > 1e5)
45176
45634
  throw new CliError("validation_error", "limit takes 1\u2013500 and offset takes 0\u2013100000");
@@ -45272,7 +45730,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45272
45730
  return { type: "chat", id: parsed3.chat };
45273
45731
  if (parsed3.type === "folder")
45274
45732
  return { type: "folder", id: parsed3.id, path: parsed3.path };
45275
- if (parsed3.type === "entity" || parsed3.type === "memory" || parsed3.type === "fact" || parsed3.type === "bot" || parsed3.type === "event" || parsed3.type === "meeting" || parsed3.type === "invoice" || parsed3.type === "payment" || parsed3.type === "order")
45733
+ if (parsed3.type === "entity" || parsed3.type === "memory" || parsed3.type === "fact" || parsed3.type === "bot" || parsed3.type === "event" || parsed3.type === "meeting" || parsed3.type === "invoice" || parsed3.type === "payment" || parsed3.type === "order" || parsed3.type === "deal" || parsed3.type === "lead" || parsed3.type === "pipeline")
45276
45734
  return void 0;
45277
45735
  return { type: parsed3.type, id: parsed3.id };
45278
45736
  }, "targetOfThing");
@@ -45303,8 +45761,8 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45303
45761
  text: String(row2.body),
45304
45762
  revision: Number(row2.revision),
45305
45763
  authoredBy: "owner",
45306
- createdAt: iso11(row2.created_at),
45307
- updatedAt: iso11(row2.updated_at)
45764
+ createdAt: iso12(row2.created_at),
45765
+ updatedAt: iso12(row2.updated_at)
45308
45766
  };
45309
45767
  }, "annotationOf");
45310
45768
  const noteRow = /* @__PURE__ */ __name((id2) => /^\d+$/.test(id2) ? database.prepare("SELECT * FROM notes WHERE id = ? AND deleted_at IS NULL").get(Number(id2)) : void 0, "noteRow");
@@ -45325,7 +45783,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45325
45783
  type: row2.type,
45326
45784
  organizationId: row2.organization_id == null ? null : String(row2.organization_id),
45327
45785
  scope: row2.scope,
45328
- createdAt: iso11(row2.created_at)
45786
+ createdAt: iso12(row2.created_at)
45329
45787
  }), "projectOf");
45330
45788
  const proposals = relationProposalsOver(context);
45331
45789
  const RELATIONS = `SELECT * FROM links WHERE kind IN (${RELATION_KINDS.map(linkKind).join(",")}) AND to_id IS NOT NULL`;
@@ -45361,7 +45819,7 @@ var knowledgeStoreOver = /* @__PURE__ */ __name((context) => {
45361
45819
  const reminderOf = /* @__PURE__ */ __name((row2) => ({
45362
45820
  id: String(row2.id),
45363
45821
  task: taskIdOf(database, Number(row2.task_id)) ?? String(row2.task_id),
45364
- dueAt: iso11(row2.due_at),
45822
+ dueAt: iso12(row2.due_at),
45365
45823
  timezone: String(row2.timezone),
45366
45824
  state: row2.state,
45367
45825
  revision: Number(row2.revision),
@@ -45705,7 +46163,7 @@ var projectKey = /* @__PURE__ */ __name((name) => {
45705
46163
  return key2.padEnd(3, "X");
45706
46164
  }, "projectKey");
45707
46165
 
45708
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
46166
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/log-pruning.js
45709
46167
  var DAY5 = 864e5;
45710
46168
  var SETTING4 = "logs_pruned_at";
45711
46169
  var LOG_RETENTION = { agentActionsMs: 90 * DAY5, botUpdatePayloadsMs: 30 * DAY5 };
@@ -45732,7 +46190,7 @@ var logPruner = /* @__PURE__ */ __name((database, now2) => {
45732
46190
  };
45733
46191
  }, "logPruner");
45734
46192
 
45735
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/mail/findings.js
46193
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/mail/findings.js
45736
46194
  var MAIL_FINDINGS_PER_RUN = 30;
45737
46195
  var MAIL_FINDINGS_PER_SENDER = 5;
45738
46196
  var invalid6 = /* @__PURE__ */ __name((message2) => {
@@ -46108,7 +46566,7 @@ var checkMailFindings = /* @__PURE__ */ __name((input) => {
46108
46566
  }, "checkMailFindings");
46109
46567
  var mailFindingFingerprint = /* @__PURE__ */ __name(({ id: _id, ...finding }) => findingHash(finding), "mailFindingFingerprint");
46110
46568
 
46111
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/mail/score.js
46569
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/mail/score.js
46112
46570
  var import_disposable_email_domains_js = __toESM(require_dist(), 1);
46113
46571
  var import_tldts = __toESM(require_cjs(), 1);
46114
46572
  var WEIGHTS = {
@@ -46241,7 +46699,7 @@ var scoreGroup = /* @__PURE__ */ __name((items, context) => {
46241
46699
  return { score: kept.reduce((sum, signal) => sum + WEIGHTS[signal], 0), signals: kept };
46242
46700
  }, "scoreGroup");
46243
46701
 
46244
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/orders.js
46702
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/orders.js
46245
46703
  var ORDERS = "SELECT o.*, b.name AS author_name, b.kind AS author_kind FROM orders o LEFT JOIN bots b ON o.author_type = 'bot' AND b.id = o.author_id";
46246
46704
  var orderOperationsOver = /* @__PURE__ */ __name((context) => {
46247
46705
  const { database, now: now2 } = context;
@@ -46393,7 +46851,7 @@ var ordersStoreOver = /* @__PURE__ */ __name((context) => {
46393
46851
  };
46394
46852
  }, "ordersStoreOver");
46395
46853
 
46396
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-findings.js
46854
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mail-findings.js
46397
46855
  var stale2 = /* @__PURE__ */ __name(() => {
46398
46856
  throw new CliError("validation_error", "mail findings cite mail that changed since it was read; stage a new batch", {
46399
46857
  reason: "mail-findings.stale"
@@ -46434,7 +46892,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
46434
46892
  return invalid7("stored findings exceed the read budget");
46435
46893
  return proposals.get(id2);
46436
46894
  }, "load");
46437
- const accountOf3 = /* @__PURE__ */ __name((proposal) => mailbox2(proposal.account), "accountOf");
46895
+ const accountOf4 = /* @__PURE__ */ __name((proposal) => mailbox2(proposal.account), "accountOf");
46438
46896
  const view = /* @__PURE__ */ __name((proposal) => {
46439
46897
  const input = proposal.payload;
46440
46898
  if (!input || !proposal.account || !["proposed", "approved", "rejected"].includes(proposal.status))
@@ -46449,7 +46907,7 @@ var mailFindingsStoreOver = /* @__PURE__ */ __name((context) => {
46449
46907
  decidedBy: proposal.decidedBy,
46450
46908
  decidedAt: proposal.decidedAt,
46451
46909
  previous: proposal.result ? proposal.result.items : input.findings.flatMap((finding) => {
46452
- const held = core.previous(accountOf3(proposal), mailFindingFingerprint(finding));
46910
+ const held = core.previous(accountOf4(proposal), mailFindingFingerprint(finding));
46453
46911
  return held ? [{ ...held, id: finding.id, reused: true }] : [];
46454
46912
  }),
46455
46913
  receipt: proposal.result
@@ -46818,7 +47276,7 @@ ${evidence.join("\n")}`, agent);
46818
47276
  return batch;
46819
47277
  }
46820
47278
  const input = proposal.payload;
46821
- const account = accountOf3(proposal);
47279
+ const account = accountOf4(proposal);
46822
47280
  const chosen = batch.input.findings.filter((finding) => accepted.includes(finding.id));
46823
47281
  if (chosen.length)
46824
47282
  cite(chosen, account, true);
@@ -46850,7 +47308,7 @@ ${evidence.join("\n")}`, agent);
46850
47308
  };
46851
47309
  }, "mailFindingsStoreOver");
46852
47310
 
46853
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
47311
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-findings.js
46854
47312
  var stale3 = /* @__PURE__ */ __name(() => {
46855
47313
  throw new CliError("validation_error", "meeting findings changed since they were read; stage a new batch", {
46856
47314
  reason: "meeting-findings.stale"
@@ -47018,7 +47476,7 @@ var meetingFindingsStoreOver = /* @__PURE__ */ __name((context) => {
47018
47476
  };
47019
47477
  }, "meetingFindingsStoreOver");
47020
47478
 
47021
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
47479
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/meeting-vectors.js
47022
47480
  var RANK_BATCH = 512;
47023
47481
  var LIVE3 = "FROM chunks k JOIN meeting_transcripts t ON k.chunkable_type = 'meeting_transcript' AND t.id = k.chunkable_id JOIN meetings m ON m.id = t.meeting_id WHERE m.account_id = ? AND m.deleted_at IS NULL AND t.deleted_at IS NULL AND t.superseded_at IS NULL";
47024
47482
  var limitOf = /* @__PURE__ */ __name((value, name, max = 1e3) => {
@@ -47289,7 +47747,7 @@ var meetingVectorsOver = /* @__PURE__ */ __name((context) => ({
47289
47747
  }
47290
47748
  }), "meetingVectorsOver");
47291
47749
 
47292
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
47750
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/mention-sources.js
47293
47751
  var OTHER_SOURCES = ["document", "note", "email"];
47294
47752
  var TEXTS = {
47295
47753
  document: "JOIN documents s ON mn.source_type = 'document' AND s.id = mn.source_id AND s.deleted_at IS NULL WHERE 1 ",
@@ -47390,11 +47848,11 @@ var sourceMentionStoreOver = /* @__PURE__ */ __name((context) => {
47390
47848
  };
47391
47849
  }, "sourceMentionStoreOver");
47392
47850
 
47393
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
47851
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
47394
47852
  import { mkdirSync, statSync, writeFileSync } from "node:fs";
47395
47853
  import { dirname } from "node:path";
47396
47854
 
47397
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
47855
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/clients.js
47398
47856
  import { readFileSync as readFileSync3 } from "node:fs";
47399
47857
  var CLIENTS_SETTING = "clients";
47400
47858
  var coreVersion = (() => {
@@ -47452,7 +47910,7 @@ var refusalAdvice = /* @__PURE__ */ __name((clients, command, schema) => {
47452
47910
  return mover ? `${own} (${mover.command} ${mover.version} moved the store to schema ${schema})` : own;
47453
47911
  }, "refusalAdvice");
47454
47912
 
47455
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
47913
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/migrations.generated.js
47456
47914
  var GENERATED = [
47457
47915
  {
47458
47916
  "name": "20261010184427_initial",
@@ -48452,10 +48910,59 @@ WHERE json_type(params, '$.selection') = 'object';`
48452
48910
  "ALTER TABLE `tasks` ADD `source_url` text;",
48453
48911
  "CREATE INDEX `tasks_by_provider_external_id` ON `tasks` (`provider`,`external_id`) WHERE external_id IS NOT NULL;"
48454
48912
  ]
48913
+ },
48914
+ {
48915
+ "name": "20261106010504_version-52-deals",
48916
+ "statements": [
48917
+ "CREATE TABLE `deals` (\n `id` integer PRIMARY KEY,\n `title` text NOT NULL,\n `organization_id` integer,\n `project_id` integer,\n `stage_id` integer NOT NULL,\n `status` text NOT NULL,\n `currency` text,\n `amount` integer,\n `close_date` text,\n `closed_date` text,\n `rank` real,\n `account_id` integer,\n `external_id` text,\n `author_type` text NOT NULL,\n `author_id` integer NOT NULL,\n `model` text,\n `source` text NOT NULL,\n `metadata` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n `deleted_at` integer,\n CONSTRAINT `fk_deals_organization_id_organizations_id_fk` FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`),\n CONSTRAINT `fk_deals_project_id_projects_id_fk` FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`),\n CONSTRAINT `fk_deals_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_deals_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
48918
+ "CREATE TABLE `leads` (\n `id` integer PRIMARY KEY,\n `title` text NOT NULL,\n `organization_id` integer,\n `project_id` integer,\n `stage_id` integer NOT NULL,\n `status` text NOT NULL,\n `currency` text,\n `amount` integer,\n `close_date` text,\n `closed_date` text,\n `rank` real,\n `deal_id` integer,\n `account_id` integer,\n `external_id` text,\n `author_type` text NOT NULL,\n `author_id` integer NOT NULL,\n `model` text,\n `source` text NOT NULL,\n `metadata` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n `deleted_at` integer,\n CONSTRAINT `fk_leads_organization_id_organizations_id_fk` FOREIGN KEY (`organization_id`) REFERENCES `organizations`(`id`),\n CONSTRAINT `fk_leads_project_id_projects_id_fk` FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`),\n CONSTRAINT `fk_leads_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_leads_deal_id_deals_id_fk` FOREIGN KEY (`deal_id`) REFERENCES `deals`(`id`),\n CONSTRAINT `fk_leads_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
48919
+ "CREATE TABLE `pipeline_stage_changes` (\n `id` integer PRIMARY KEY,\n `item_type` text NOT NULL,\n `item_id` integer NOT NULL,\n `pipeline_id` integer NOT NULL,\n `from_stage_id` integer,\n `to_stage_id` integer NOT NULL,\n `changed_at` integer NOT NULL,\n CONSTRAINT `fk_pipeline_stage_changes_pipeline_id_pipelines_id_fk` FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`),\n CONSTRAINT `fk_pipeline_stage_changes_from_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`from_stage_id`) REFERENCES `pipeline_stages`(`id`),\n CONSTRAINT `fk_pipeline_stage_changes_to_stage_id_pipeline_stages_id_fk` FOREIGN KEY (`to_stage_id`) REFERENCES `pipeline_stages`(`id`)\n);",
48920
+ "CREATE TABLE `pipeline_stages` (\n `id` integer PRIMARY KEY,\n `pipeline_id` integer NOT NULL,\n `name` text NOT NULL,\n `name_folded` text NOT NULL,\n `position` integer NOT NULL,\n `outcome` text DEFAULT 'open' NOT NULL,\n `external_id` text,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n CONSTRAINT `fk_pipeline_stages_pipeline_id_pipelines_id_fk` FOREIGN KEY (`pipeline_id`) REFERENCES `pipelines`(`id`),\n CONSTRAINT `pipeline_stages_pipeline_id_name_folded_unique` UNIQUE(`pipeline_id`,`name_folded`)\n);",
48921
+ "CREATE TABLE `pipelines` (\n `id` integer PRIMARY KEY,\n `account_id` integer,\n `external_id` text,\n `kind` text DEFAULT 'deal' NOT NULL,\n `name` text NOT NULL,\n `name_folded` text NOT NULL,\n `created_at` integer NOT NULL,\n `updated_at` integer NOT NULL,\n CONSTRAINT `fk_pipelines_account_id_accounts_id_fk` FOREIGN KEY (`account_id`) REFERENCES `accounts`(`id`)\n);",
48922
+ "CREATE UNIQUE INDEX `deals_by_account_id_external_id` ON `deals` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
48923
+ "CREATE INDEX `deals_by_organization_id` ON `deals` (`organization_id`);",
48924
+ "CREATE INDEX `deals_by_project_id` ON `deals` (`project_id`);",
48925
+ "CREATE INDEX `deals_by_stage_id` ON `deals` (`stage_id`);",
48926
+ "CREATE INDEX `deals_by_author_type_author_id` ON `deals` (`author_type`,`author_id`);",
48927
+ "CREATE UNIQUE INDEX `leads_by_account_id_external_id` ON `leads` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
48928
+ "CREATE INDEX `leads_by_organization_id` ON `leads` (`organization_id`);",
48929
+ "CREATE INDEX `leads_by_project_id` ON `leads` (`project_id`);",
48930
+ "CREATE INDEX `leads_by_stage_id` ON `leads` (`stage_id`);",
48931
+ "CREATE INDEX `leads_by_deal_id` ON `leads` (`deal_id`);",
48932
+ "CREATE INDEX `leads_by_author_type_author_id` ON `leads` (`author_type`,`author_id`);",
48933
+ "CREATE INDEX `pipeline_stage_changes_by_item_type_item_id` ON `pipeline_stage_changes` (`item_type`,`item_id`);",
48934
+ "CREATE INDEX `pipeline_stage_changes_by_pipeline_id` ON `pipeline_stage_changes` (`pipeline_id`);",
48935
+ "CREATE INDEX `pipeline_stage_changes_by_from_stage_id` ON `pipeline_stage_changes` (`from_stage_id`);",
48936
+ "CREATE INDEX `pipeline_stage_changes_by_to_stage_id` ON `pipeline_stage_changes` (`to_stage_id`);",
48937
+ "CREATE UNIQUE INDEX `pipeline_stages_by_pipeline_id_external_id` ON `pipeline_stages` (`pipeline_id`,`external_id`) WHERE external_id IS NOT NULL;",
48938
+ "CREATE INDEX `pipeline_stages_by_pipeline_id_position` ON `pipeline_stages` (`pipeline_id`,`position`);",
48939
+ "CREATE UNIQUE INDEX `pipelines_by_account_id_external_id` ON `pipelines` (`account_id`,`external_id`) WHERE account_id IS NOT NULL AND external_id IS NOT NULL;",
48940
+ "CREATE UNIQUE INDEX `pipelines_by_name_folded_kind` ON `pipelines` (`name_folded`,`kind`) WHERE account_id IS NULL;"
48941
+ ]
48942
+ },
48943
+ {
48944
+ "name": "20261106010507_version-52-deals-rules",
48945
+ "statements": [
48946
+ "-- The store's code checks these first and says why; the triggers keep a stray write from another build, a sync or a\n-- hand edit from storing a row the store's code would refuse.\nCREATE TRIGGER pipelines_valid_bi BEFORE INSERT ON pipelines WHEN new.kind NOT IN ('deal', 'lead') BEGIN\n SELECT RAISE(ABORT, 'pipelines: kind is deal or lead');\nEND;",
48947
+ "CREATE TRIGGER pipelines_valid_bu BEFORE UPDATE ON pipelines WHEN new.kind NOT IN ('deal', 'lead') BEGIN\n SELECT RAISE(ABORT, 'pipelines: kind is deal or lead');\nEND;",
48948
+ "CREATE TRIGGER pipelines_kind_bu BEFORE UPDATE OF kind ON pipelines\n WHEN new.kind <> old.kind AND EXISTS (SELECT 1 FROM pipeline_stages s WHERE s.pipeline_id = new.id\n AND (EXISTS (SELECT 1 FROM deals d WHERE d.stage_id = s.id) OR EXISTS (SELECT 1 FROM leads l WHERE l.stage_id = s.id))) BEGIN\n SELECT RAISE(ABORT, 'pipelines: the kind of a pipeline that holds deals or leads stays');\nEND;",
48949
+ "CREATE TRIGGER pipeline_stages_valid_bi BEFORE INSERT ON pipeline_stages\n WHEN new.outcome NOT IN ('open', 'won', 'lost') BEGIN\n SELECT RAISE(ABORT, 'pipeline_stages: outcome is open, won or lost');\nEND;",
48950
+ "CREATE TRIGGER pipeline_stages_valid_bu BEFORE UPDATE ON pipeline_stages\n WHEN new.outcome NOT IN ('open', 'won', 'lost') BEGIN\n SELECT RAISE(ABORT, 'pipeline_stages: outcome is open, won or lost');\nEND;",
48951
+ "CREATE TRIGGER deals_valid_bi BEFORE INSERT ON deals\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'deal' BEGIN\n SELECT RAISE(ABORT, 'deals: a known status, an amount with its currency, and a stage of a deal pipeline');\nEND;",
48952
+ "CREATE TRIGGER deals_valid_bu BEFORE UPDATE ON deals\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'deal' BEGIN\n SELECT RAISE(ABORT, 'deals: a known status, an amount with its currency, and a stage of a deal pipeline');\nEND;",
48953
+ "-- Every stage a row enters, with the time its writer gave, is what conversion between stages is counted from.\nCREATE TRIGGER deals_stage_ai AFTER INSERT ON deals BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'deal', new.id, s.pipeline_id, NULL, new.stage_id, new.created_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
48954
+ "CREATE TRIGGER deals_stage_au AFTER UPDATE OF stage_id ON deals WHEN new.stage_id IS NOT old.stage_id BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'deal', new.id, s.pipeline_id, old.stage_id, new.stage_id, new.updated_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
48955
+ "CREATE TRIGGER leads_valid_bi BEFORE INSERT ON leads\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'lead' BEGIN\n SELECT RAISE(ABORT, 'leads: a known status, an amount with its currency, and a stage of a lead pipeline');\nEND;",
48956
+ "CREATE TRIGGER leads_valid_bu BEFORE UPDATE ON leads\n WHEN new.status NOT IN ('open', 'won', 'lost')\n OR (new.amount IS NULL) <> (new.currency IS NULL) OR new.amount < 0\n OR (SELECT p.kind FROM pipeline_stages s JOIN pipelines p ON p.id = s.pipeline_id WHERE s.id = new.stage_id) IS NOT 'lead' BEGIN\n SELECT RAISE(ABORT, 'leads: a known status, an amount with its currency, and a stage of a lead pipeline');\nEND;",
48957
+ "CREATE TRIGGER leads_stage_ai AFTER INSERT ON leads BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'lead', new.id, s.pipeline_id, NULL, new.stage_id, new.created_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
48958
+ "CREATE TRIGGER leads_stage_au AFTER UPDATE OF stage_id ON leads WHEN new.stage_id IS NOT old.stage_id BEGIN\n INSERT INTO pipeline_stage_changes (item_type, item_id, pipeline_id, from_stage_id, to_stage_id, changed_at)\n SELECT 'lead', new.id, s.pipeline_id, old.stage_id, new.stage_id, new.updated_at FROM pipeline_stages s WHERE s.id = new.stage_id;\nEND;",
48959
+ "-- The default lead pipeline, so a lead can be recorded before the owner or an agent makes one.\nINSERT INTO pipelines (kind, name, name_folded, created_at, updated_at)\n VALUES ('lead', 'Leads', 'leads', CAST(strftime('%s', 'now') AS INTEGER) * 1000, CAST(strftime('%s', 'now') AS INTEGER) * 1000);",
48960
+ "INSERT INTO pipeline_stages (pipeline_id, name, name_folded, position, outcome, created_at, updated_at)\n SELECT p.id, v.name, v.name, v.position, v.outcome, p.created_at, p.created_at FROM pipelines p,\n (SELECT 'new' AS name, 1 AS position, 'open' AS outcome UNION ALL SELECT 'contacted', 2, 'open'\n UNION ALL SELECT 'qualified', 3, 'open' UNION ALL SELECT 'won', 4, 'won' UNION ALL SELECT 'lost', 5, 'lost') v\n WHERE p.kind = 'lead' AND p.name_folded = 'leads' AND p.account_id IS NULL;"
48961
+ ]
48455
48962
  }
48456
48963
  ];
48457
48964
 
48458
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
48965
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/manifest.js
48459
48966
  var MANIFEST = [
48460
48967
  { name: "20261010184427_initial", version: 1, minCompatible: 1 },
48461
48968
  { name: "20261011035353_version-2-facts", version: 2, minCompatible: 1 },
@@ -48523,7 +49030,9 @@ var MANIFEST = [
48523
49030
  { name: "20261104232153_version-49-relation-amounts", version: 49, minCompatible: 34 },
48524
49031
  { name: "20261105125314_version-50-orders", version: 50, minCompatible: 34 },
48525
49032
  { name: "20261105125315_version-50-orders-rules", version: 50, minCompatible: 34 },
48526
- { name: "20261105144549_version-51-task-links", version: 51, minCompatible: 34 }
49033
+ { name: "20261105144549_version-51-task-links", version: 51, minCompatible: 34 },
49034
+ { name: "20261106010504_version-52-deals", version: 52, minCompatible: 34 },
49035
+ { name: "20261106010507_version-52-deals-rules", version: 52, minCompatible: 34 }
48527
49036
  ];
48528
49037
  var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated = GENERATED) => {
48529
49038
  const migrations = [];
@@ -48547,7 +49056,7 @@ var generatedMigrations = /* @__PURE__ */ __name((manifest = MANIFEST, generated
48547
49056
  return migrations;
48548
49057
  }, "generatedMigrations");
48549
49058
 
48550
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/migrations.js
49059
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/migrations.js
48551
49060
  var MIGRATIONS = generatedMigrations();
48552
49061
  var HISTORY = `CREATE TABLE IF NOT EXISTS schema_migrations (
48553
49062
  version INTEGER PRIMARY KEY,
@@ -48600,7 +49109,7 @@ var migrate = /* @__PURE__ */ __name((database, { migrations = MIGRATIONS, now:
48600
49109
  }
48601
49110
  }, "migrate");
48602
49111
 
48603
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
49112
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/join-keys.js
48604
49113
  var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
48605
49114
  const pending = database.prepare("SELECT id, join_url FROM meetings WHERE join_url IS NOT NULL AND join_key IS NULL AND id > ? ORDER BY id LIMIT ?");
48606
49115
  if (pending.get(0, 1) === void 0)
@@ -48622,7 +49131,7 @@ var fillJoinKeys = /* @__PURE__ */ __name((database, { batch = 2e3 } = {}) => {
48622
49131
  }
48623
49132
  }, "fillJoinKeys");
48624
49133
 
48625
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
49134
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/open.js
48626
49135
  var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {}) => {
48627
49136
  refuseOwnerStoreInTests(path);
48628
49137
  const opened = "Bun" in globalThis ? await openUnderBun(path, readOnly) : await openUnderNode(path, readOnly);
@@ -48636,8 +49145,8 @@ var openSqlite = /* @__PURE__ */ __name(async (path, { readOnly = false } = {})
48636
49145
  }, "openSqlite");
48637
49146
  var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
48638
49147
  quietSqliteWarning();
48639
- const { drizzle } = await import("./node-NBXEN7JU.js");
48640
- const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-WAGIYOYR.js");
49148
+ const { drizzle } = await import("./node-YP265UUP.js");
49149
+ const { cacheOverNodeSqlite, nodeClient } = await import("./node-sqlite-K3PWKXTB.js");
48641
49150
  const client = await nodeClient(path, { readOnly });
48642
49151
  try {
48643
49152
  return { database: cacheOverNodeSqlite(client), orm: drizzle({ client }) };
@@ -48647,8 +49156,8 @@ var openUnderNode = /* @__PURE__ */ __name(async (path, readOnly) => {
48647
49156
  }
48648
49157
  }, "openUnderNode");
48649
49158
  var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
48650
- const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-3V6EB3XP.js");
48651
- const { drizzle } = await import("./bun-GFMA4TKJ.js");
49159
+ const { bunClient, cacheOverBunSqlite } = await import("./bun-sqlite-HXOV4SGX.js");
49160
+ const { drizzle } = await import("./bun-OTDLXIRE.js");
48652
49161
  const client = await bunClient(path, readOnly ? { readonly: true, create: false } : void 0);
48653
49162
  try {
48654
49163
  return { database: cacheOverBunSqlite(client), orm: drizzle({ client }) };
@@ -48658,7 +49167,7 @@ var openUnderBun = /* @__PURE__ */ __name(async (path, readOnly) => {
48658
49167
  }
48659
49168
  }, "openUnderBun");
48660
49169
 
48661
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-facts.js
49170
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/payment-facts.js
48662
49171
  var PAYMENT_FACTS_TO_MOVE = "payment_facts_to_move";
48663
49172
  var paymentOf = /* @__PURE__ */ __name((metadata3) => {
48664
49173
  try {
@@ -48726,7 +49235,7 @@ var movePaymentFacts = /* @__PURE__ */ __name((context) => {
48726
49235
  });
48727
49236
  }, "movePaymentFacts");
48728
49237
 
48729
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
49238
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/read-compatibility.js
48730
49239
  var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
48731
49240
  const ours = MIGRATIONS.at(-1)?.version ?? 0;
48732
49241
  if (!database.prepare("SELECT 1 FROM sqlite_master WHERE type='table' AND name='schema_migrations'").get())
@@ -48741,7 +49250,7 @@ var assertReadCompatible = /* @__PURE__ */ __name((database, command) => {
48741
49250
  throw new CliError("configuration_error", `The store requires schema ${minCompatible}, but this tool supports ${ours}; ${refusalAdvice(storeClients(database), command, version)}`);
48742
49251
  }, "assertReadCompatible");
48743
49252
 
48744
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/suggested-links.js
49253
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/suggested-links.js
48745
49254
  var SUGGESTED_LINKS_TO_MOVE = "suggested_links_to_move";
48746
49255
  var proposerOf2 = /* @__PURE__ */ __name((provenance2) => {
48747
49256
  if (provenance2?.startsWith("rule:"))
@@ -48787,7 +49296,7 @@ var moveSuggestedLinks = /* @__PURE__ */ __name((database, now2) => {
48787
49296
  });
48788
49297
  }, "moveSuggestedLinks");
48789
49298
 
48790
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/test-accounts.js
49299
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/test-accounts.js
48791
49300
  var TEST_ACCOUNTS_TO_PURGE = "test_accounts_to_purge";
48792
49301
  var TEST_PROVIDER = "chat";
48793
49302
  var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
@@ -48808,7 +49317,7 @@ var purgeTestAccounts = /* @__PURE__ */ __name((context, warn) => {
48808
49317
  }
48809
49318
  }, "purgeTestAccounts");
48810
49319
 
48811
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
49320
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/open-store.js
48812
49321
  var BACKFILL_ON_OPEN = 5e3;
48813
49322
  var NOT_WRITABLE = /* @__PURE__ */ new Set(["EACCES", "EPERM", "EROFS"]);
48814
49323
  var createWritable = /* @__PURE__ */ __name((file) => {
@@ -48873,10 +49382,10 @@ var openStoreContext = /* @__PURE__ */ __name(async ({ path, env, now: now2 = Da
48873
49382
  }
48874
49383
  }, "openStoreContext");
48875
49384
 
48876
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
49385
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
48877
49386
  import { createHash as createHash16 } from "node:crypto";
48878
49387
 
48879
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
49388
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/schema.js
48880
49389
  var text4 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
48881
49390
  var ref = text4(2048);
48882
49391
  var timestamp2 = pipe(number(), safeInteger(), minValue(0));
@@ -48942,7 +49451,7 @@ var projectAnnotationsSchema = strictObject({
48942
49451
  }))
48943
49452
  });
48944
49453
 
48945
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
49454
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/manifest.js
48946
49455
  var PROJECT_ANNOTATIONS_MAX_BYTES = 4 * 1024 * 1024;
48947
49456
  var invalid9 = /* @__PURE__ */ __name((field4) => {
48948
49457
  throw new CliError("validation_error", `invalid project annotations.${field4}`);
@@ -49046,7 +49555,7 @@ var validateProjectAnnotationsGraph = /* @__PURE__ */ __name((manifest, addition
49046
49555
  invalid9("external.unused");
49047
49556
  }, "validateProjectAnnotationsGraph");
49048
49557
 
49049
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
49558
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/plan.js
49050
49559
  var hash = pipe(string(), regex(/^[a-f0-9]{64}$/));
49051
49560
  var ref2 = pipe(string(), minLength(1), maxLength(2048));
49052
49561
  var targetSchema = strictObject({
@@ -49152,7 +49661,7 @@ var planBoundProjectAnnotations = /* @__PURE__ */ __name((manifest, manifest_fin
49152
49661
  };
49153
49662
  }, "planBoundProjectAnnotations");
49154
49663
 
49155
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
49664
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-model.js
49156
49665
  import { createHash as createHash17 } from "node:crypto";
49157
49666
  var text5 = /* @__PURE__ */ __name((max) => pipe(string(), minLength(1), maxLength(max)), "text");
49158
49667
  var timestamp3 = pipe(number(), safeInteger(), minValue(0));
@@ -49246,7 +49755,7 @@ var projectAnnotationSnapshotFingerprint = /* @__PURE__ */ __name((json3) => {
49246
49755
  })).digest("hex");
49247
49756
  }, "projectAnnotationSnapshotFingerprint");
49248
49757
 
49249
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
49758
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/request.js
49250
49759
  var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false) => {
49251
49760
  if (!request || typeof request !== "object" || Array.isArray(request))
49252
49761
  throw new CliError("validation_error", "project annotation request is required");
@@ -49263,7 +49772,7 @@ var projectAnnotationRequest = /* @__PURE__ */ __name((request, restore = false)
49263
49772
  return { snapshot: snapshot2, projectId: Number(request.project.slice(8)) };
49264
49773
  }, "projectAnnotationRequest");
49265
49774
 
49266
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
49775
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/budget.js
49267
49776
  var SnapshotBudget = class {
49268
49777
  static {
49269
49778
  __name(this, "SnapshotBudget");
@@ -49289,13 +49798,13 @@ var SnapshotBudget = class {
49289
49798
  }
49290
49799
  };
49291
49800
 
49292
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
49801
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
49293
49802
  import { createHash as createHash19 } from "node:crypto";
49294
49803
 
49295
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
49804
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/project-transfer/snapshot-plan.js
49296
49805
  var planProjectAnnotationSnapshot = /* @__PURE__ */ __name((json3, target, bindings) => planBoundProjectAnnotations(decodeProjectAnnotationSnapshot(json3), projectAnnotationSnapshotFingerprint(json3), target, bindings), "planProjectAnnotationSnapshot");
49297
49806
 
49298
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
49807
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/sources.js
49299
49808
  import { createHash as createHash18 } from "node:crypto";
49300
49809
  var invalid11 = /* @__PURE__ */ __name(() => {
49301
49810
  throw new CliError("configuration_error", "project snapshot has an unavailable or unsupported dependency");
@@ -49438,7 +49947,7 @@ var ProjectSnapshotSources = class {
49438
49947
  }
49439
49948
  };
49440
49949
 
49441
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
49950
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/snapshot.js
49442
49951
  var unsupported = /* @__PURE__ */ __name(() => {
49443
49952
  throw new CliError("configuration_error", "project snapshot has unsupported metadata, deletion or account scope");
49444
49953
  }, "unsupported");
@@ -49609,7 +50118,7 @@ var projectAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, bu
49609
50118
  return { snapshot: snapshot2, read_bytes: budget.bytes, records: budget.records };
49610
50119
  }), "projectAnnotationSnapshot");
49611
50120
 
49612
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
50121
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/preview.js
49613
50122
  var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, manifest, bindings, budget) => read(database, () => {
49614
50123
  const current = projectAnnotationSnapshot(database, projectId2, budget).snapshot;
49615
50124
  const sources = new ProjectSnapshotSources(database, budget);
@@ -49671,7 +50180,7 @@ var previewAnnotationSnapshot = /* @__PURE__ */ __name((database, projectId2, ma
49671
50180
  };
49672
50181
  }), "previewAnnotationSnapshot");
49673
50182
 
49674
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
50183
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/records.js
49675
50184
  var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, snapshot2, bindings) => {
49676
50185
  const mappings = { ...bindings };
49677
50186
  const resolve = /* @__PURE__ */ __name((ref3) => {
@@ -49713,7 +50222,7 @@ var restoreAnnotationRecords = /* @__PURE__ */ __name((database, projectId2, sna
49713
50222
  return mappings;
49714
50223
  }, "restoreAnnotationRecords");
49715
50224
 
49716
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
50225
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/project-transfer/store.js
49717
50226
  var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
49718
50227
  async preview(request) {
49719
50228
  const { snapshot: snapshot2, projectId: projectId2 } = projectAnnotationRequest(request);
@@ -49743,7 +50252,7 @@ var projectAnnotationStoreOver = /* @__PURE__ */ __name(({ database }) => ({
49743
50252
  }
49744
50253
  }), "projectAnnotationStoreOver");
49745
50254
 
49746
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/domain/records.js
50255
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/domain/records.js
49747
50256
  import { createHash as createHash20 } from "node:crypto";
49748
50257
  var RECORDS_SCHEMA_VERSION = 1;
49749
50258
  var RECORD_OPERATIONS = ["upsert", "delete"];
@@ -49975,7 +50484,7 @@ var envelopeOfJsonl = /* @__PURE__ */ __name((text6) => {
49975
50484
  return isObject2(header) ? { ...header, records: records2 } : header;
49976
50485
  }, "envelopeOfJsonl");
49977
50486
 
49978
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/records.js
50487
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/records.js
49979
50488
  var PROJECTED = {
49980
50489
  invoice: { roles: ["issuer", "counterparty", "project"], many: [] },
49981
50490
  payment: { roles: ["payer", "payee", "project", "settles"], many: ["settles"] }
@@ -49993,7 +50502,7 @@ var codeOf = /* @__PURE__ */ __name((error) => {
49993
50502
  return error.code === "not_found" ? "record.reference-not-found" : "record.entity";
49994
50503
  }, "codeOf");
49995
50504
  var unsettled = /* @__PURE__ */ __name((fields4, relations) => recordFingerprint(fields4, relations.filter((relation) => relation.role !== "settles")), "unsettled");
49996
- var iso12 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
50505
+ var iso13 = /* @__PURE__ */ __name((value) => new Date(Number(value)).toISOString(), "iso");
49997
50506
  var stringField = /* @__PURE__ */ __name((fields4, name) => {
49998
50507
  const value = fields4[name];
49999
50508
  if (value === void 0 || value === null)
@@ -50326,9 +50835,9 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
50326
50835
  entity: entityRef(row2.entity_type, row2.entity_id),
50327
50836
  flagged: row2.entity_id != null && (row2.deleted_at != null || row2.projected_fingerprint !== row2.fingerprint),
50328
50837
  batchId: String(row2.batch_id),
50329
- createdAt: iso12(row2.created_at),
50330
- updatedAt: iso12(row2.updated_at),
50331
- deletedAt: row2.deleted_at == null ? null : iso12(row2.deleted_at)
50838
+ createdAt: iso13(row2.created_at),
50839
+ updatedAt: iso13(row2.updated_at),
50840
+ deletedAt: row2.deleted_at == null ? null : iso13(row2.deleted_at)
50332
50841
  }), "sourceRecordOf");
50333
50842
  const SELECT2 = "SELECT r.*, a.provider, a.external_id AS account FROM records r JOIN accounts a ON a.id = r.account_id ";
50334
50843
  const rowOf2 = /* @__PURE__ */ __name((key2) => sql2(`${SELECT2}WHERE a.provider = ? AND a.external_id = ? AND r.type = ? AND r.external_id = ?`).get(key2.provider, key2.account, key2.type, key2.externalId), "rowOf");
@@ -50388,7 +50897,7 @@ var recordStoreOver = /* @__PURE__ */ __name((context) => {
50388
50897
  };
50389
50898
  }, "recordStoreOver");
50390
50899
 
50391
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
50900
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/ranges.js
50392
50901
  var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to) => {
50393
50902
  const touching = and(eq(syncRanges.chatId, chatKey), lte(syncRanges.fromKey, to + 1), gte(syncRanges.toKey, from2 - 1));
50394
50903
  let merged = { from: from2, to };
@@ -50401,7 +50910,7 @@ var markRange = /* @__PURE__ */ __name(({ orm, now: now2 }, chatKey, from2, to)
50401
50910
  }, "markRange");
50402
50911
  var ranges = /* @__PURE__ */ __name(({ orm }, chatKey) => orm.select({ from: syncRanges.fromKey, to: syncRanges.toKey }).from(syncRanges).where(eq(syncRanges.chatId, chatKey)).orderBy(syncRanges.fromKey).all(), "ranges");
50403
50912
 
50404
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-analysis-marks.js
50913
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-analysis-marks.js
50405
50914
  var prefixOf2 = /* @__PURE__ */ __name(({ provider, account }) => `task_analysis:${provider}:${account}:`, "prefixOf");
50406
50915
  var markOf = /* @__PURE__ */ __name((prefix, row2) => ({
50407
50916
  chatId: String(row2.key).slice(prefix.length),
@@ -50422,7 +50931,7 @@ var setTaskAnalysisMark = /* @__PURE__ */ __name((database, account, { chatId, c
50422
50931
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(prefixOf2(account) + chatId, JSON.stringify({ ...saved, checkedAt: checkedAt ?? new Date(now2).toISOString() }), now2);
50423
50932
  }, "setTaskAnalysisMark");
50424
50933
 
50425
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
50934
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/task-rule-stops.js
50426
50935
  var keyOf4 = /* @__PURE__ */ __name(({ provider, account }) => `task_rules_until:${provider}:${account}`, "keyOf");
50427
50936
  var taskRulesStop = /* @__PURE__ */ __name((database, account) => {
50428
50937
  const row2 = database.prepare("SELECT value FROM store_settings WHERE key = ?").get(keyOf4(account));
@@ -50432,7 +50941,7 @@ var setTaskRulesStop = /* @__PURE__ */ __name((database, account, until, now2) =
50432
50941
  database.prepare("INSERT INTO store_settings (key, value, at) VALUES (?, ?, ?) ON CONFLICT (key) DO UPDATE SET value = excluded.value, at = excluded.at").run(keyOf4(account), JSON.stringify(until), now2);
50433
50942
  }, "setTaskRulesStop");
50434
50943
 
50435
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sync.js
50944
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sync.js
50436
50945
  var syncStoreOver = /* @__PURE__ */ __name((context) => {
50437
50946
  const { database } = context;
50438
50947
  const { accountPk: accountPk2, findAccountPk: findAccountPk2, chatKeyOf, chatPkFor: chatPkFor2, identityPk: identityPk2, writeMembers: writeMembers2, writeState: writeState2 } = keysOver(context);
@@ -50491,7 +51000,7 @@ var syncStoreOver = /* @__PURE__ */ __name((context) => {
50491
51000
  };
50492
51001
  }, "syncStoreOver");
50493
51002
 
50494
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/tags.js
51003
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/tags.js
50495
51004
  var tagsStoreOver = /* @__PURE__ */ __name((context) => {
50496
51005
  const { database } = context;
50497
51006
  return {
@@ -50513,7 +51022,7 @@ var tagsStoreOver = /* @__PURE__ */ __name((context) => {
50513
51022
  };
50514
51023
  }, "tagsStoreOver");
50515
51024
 
50516
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
51025
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/image-chunks.js
50517
51026
  var IS_IMAGE = sql`(a.kind = 'photo' OR a.mime LIKE 'image/%')`;
50518
51027
  var neighbours = /* @__PURE__ */ __name(({ orm }, chatKey, messagePk, sentAt, { messages: messages2, withinMs }, side) => orm.all(sql`SELECT sender_name AS sender, text, sent_at AS sentAt FROM messages
50519
51028
  WHERE chat_id = ${chatKey} AND deleted_at IS NULL AND trim(text) <> '' AND id <> ${messagePk}
@@ -50640,7 +51149,7 @@ var savePictureChunks = /* @__PURE__ */ __name(({ orm, now: now2, database }, ac
50640
51149
  dropUnusedVectors(database, released.map(({ hash: hash2 }) => hash2));
50641
51150
  }, "savePictureChunks");
50642
51151
 
50643
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
51152
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/message-chunks.js
50644
51153
  var messagesToEmbed = /* @__PURE__ */ __name(({ orm }, accountPk2, { chatKey, model, after: after2, limit }) => orm.all(sql`SELECT m.id AS messagePk, m.text, m.sent_at AS sentAt, k.content_hash AS hash,
50645
51154
  EXISTS (SELECT 1 FROM embeddings v WHERE v.model = ${model} AND v.content_hash = k.content_hash) AS embedded
50646
51155
  FROM messages m
@@ -50729,7 +51238,7 @@ var nearestMessages = /* @__PURE__ */ __name((context, accountPk2, { limit, quer
50729
51238
  return plain2(best(found2));
50730
51239
  }, "nearestMessages");
50731
51240
 
50732
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/vectors.js
51241
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/vectors.js
50733
51242
  var accountVectorsOver = /* @__PURE__ */ __name((context, mail) => {
50734
51243
  const { database } = context;
50735
51244
  const { findAccountPk: findAccountPk2, findChatPk: findChatPk2, chatKeyOf } = keysOver(context);
@@ -50987,7 +51496,7 @@ var vectorsStoreOver = /* @__PURE__ */ __name((context, keyed) => ({
50987
51496
  embeddedHashes: /* @__PURE__ */ __name(async (model, hashes) => embeddedHashes(context, model, hashes), "embeddedHashes")
50988
51497
  }), "vectorsStoreOver");
50989
51498
 
50990
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
51499
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/store-tables.js
50991
51500
  import { existsSync, readFileSync as readFileSync4 } from "node:fs";
50992
51501
  import { dirname as dirname2, join as join2 } from "node:path";
50993
51502
  var BOOKKEEPING = ["schema_migrations", "store_settings"];
@@ -51075,10 +51584,10 @@ var lastBackup = /* @__PURE__ */ __name((path) => {
51075
51584
  }
51076
51585
  }, "lastBackup");
51077
51586
 
51078
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/providers.js
51587
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/providers.js
51079
51588
  var registerProvider2 = /* @__PURE__ */ __name((store, entry2) => store.accounts.registerProvider(entry2), "registerProvider");
51080
51589
 
51081
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
51590
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/sqlite/store-contents.js
51082
51591
  var COUNTED_TABLES = [
51083
51592
  "accounts",
51084
51593
  "chats",
@@ -51163,7 +51672,7 @@ var storeContents = /* @__PURE__ */ __name((database) => {
51163
51672
  };
51164
51673
  }, "storeContents");
51165
51674
 
51166
- // node_modules/.pnpm/@wirecat+cli-core@0.584.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_ded3b38d9f479071bd35502124c4f129/node_modules/@wirecat/cli-core/dist/store/store.js
51675
+ // node_modules/.pnpm/@wirecat+cli-core@0.589.0_@wirecat+cli-base@0.78.0_commander@15.0.0_esbuild@0.28.2_type_0ee3f6df6a9715cc0d8fd3b6006034a9/node_modules/@wirecat/cli-core/dist/store/store.js
51167
51676
  var openStore = /* @__PURE__ */ __name(async (options = {}) => {
51168
51677
  const context = await openStoreContext(options);
51169
51678
  try {
@@ -51229,6 +51738,7 @@ var storeOver = /* @__PURE__ */ __name((context) => {
51229
51738
  const facts2 = once3(() => factsStoreOver(context));
51230
51739
  const finance = once3(() => financeStoreOver(context));
51231
51740
  const orders2 = once3(() => ordersStoreOver(context));
51741
+ const deals2 = once3(() => dealsStoreOver(context));
51232
51742
  const records2 = once3(() => recordStoreOver(context));
51233
51743
  const memories2 = once3(() => memoriesStoreOver(context));
51234
51744
  const proposedActions2 = once3(() => proposedActionsStoreOver(context));
@@ -51339,6 +51849,9 @@ var storeOver = /* @__PURE__ */ __name((context) => {
51339
51849
  get orders() {
51340
51850
  return orders2();
51341
51851
  },
51852
+ get deals() {
51853
+ return deals2();
51854
+ },
51342
51855
  get records() {
51343
51856
  return records2();
51344
51857
  },
@@ -51467,6 +51980,9 @@ export {
51467
51980
  mayDecide,
51468
51981
  assertMayDecide,
51469
51982
  deciderAuthor,
51983
+ DEAL_KINDS,
51984
+ DEAL_STATUSES,
51985
+ DEAL_ROLES,
51470
51986
  openOf,
51471
51987
  refLabel,
51472
51988
  MAX_FILE_BYTES,