@codemem/core 0.44.0-beta.1 → 0.44.1

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 (59) hide show
  1. package/dist/automatic-recall.d.ts +45 -0
  2. package/dist/automatic-recall.d.ts.map +1 -0
  3. package/dist/{coordinator-api-BAufmPEa.js → coordinator-api-C2ckGC2b.js} +710 -699
  4. package/dist/coordinator-api-C2ckGC2b.js.map +1 -0
  5. package/dist/coordinator-api.d.ts.map +1 -1
  6. package/dist/db.d.ts.map +1 -1
  7. package/dist/extraction-benchmark-scoring.d.ts +1 -0
  8. package/dist/extraction-benchmark-scoring.d.ts.map +1 -1
  9. package/dist/extraction-replay.d.ts +29 -0
  10. package/dist/extraction-replay.d.ts.map +1 -1
  11. package/dist/index.d.ts +11 -6
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +8964 -7979
  14. package/dist/index.js.map +1 -1
  15. package/dist/ingest-pipeline.d.ts.map +1 -1
  16. package/dist/ingest-prompts.d.ts +3 -1
  17. package/dist/ingest-prompts.d.ts.map +1 -1
  18. package/dist/ingest-xml-parser.d.ts.map +1 -1
  19. package/dist/internal/cloudflare-coordinator.js +316 -316
  20. package/dist/internal/cloudflare-coordinator.js.map +1 -1
  21. package/dist/legacy-team-setup-completion-manifest.d.ts.map +1 -1
  22. package/dist/legacy-team-setup-limits.d.ts +3 -1
  23. package/dist/legacy-team-setup-limits.d.ts.map +1 -1
  24. package/dist/maintenance/ai-structured.d.ts.map +1 -1
  25. package/dist/observer-client.d.ts +10 -0
  26. package/dist/observer-client.d.ts.map +1 -1
  27. package/dist/observer-concepts.d.ts +5 -0
  28. package/dist/observer-concepts.d.ts.map +1 -0
  29. package/dist/observer-config.d.ts.map +1 -1
  30. package/dist/observer-forced-tool.d.ts +34 -0
  31. package/dist/observer-forced-tool.d.ts.map +1 -0
  32. package/dist/observer-output-schema.d.ts +57 -0
  33. package/dist/observer-output-schema.d.ts.map +1 -0
  34. package/dist/observer-output.d.ts +59 -0
  35. package/dist/observer-output.d.ts.map +1 -0
  36. package/dist/pack.d.ts +7 -7
  37. package/dist/pack.d.ts.map +1 -1
  38. package/dist/project-invite-identity.d.ts +1 -0
  39. package/dist/project-invite-identity.d.ts.map +1 -1
  40. package/dist/raw-event-flush.d.ts.map +1 -1
  41. package/dist/ref-queries.d.ts +2 -0
  42. package/dist/ref-queries.d.ts.map +1 -1
  43. package/dist/schema-bootstrap.d.ts.map +1 -1
  44. package/dist/schema.d.ts +76 -0
  45. package/dist/schema.d.ts.map +1 -1
  46. package/dist/search.d.ts +4 -4
  47. package/dist/search.d.ts.map +1 -1
  48. package/dist/store.d.ts +10 -10
  49. package/dist/store.d.ts.map +1 -1
  50. package/dist/summary-memory.d.ts +6 -0
  51. package/dist/summary-memory.d.ts.map +1 -1
  52. package/dist/test-schema.generated.d.ts +1 -1
  53. package/dist/test-schema.generated.d.ts.map +1 -1
  54. package/dist/types.d.ts +16 -0
  55. package/dist/types.d.ts.map +1 -1
  56. package/dist/vectors.d.ts +1 -1
  57. package/dist/vectors.d.ts.map +1 -1
  58. package/package.json +3 -3
  59. package/dist/coordinator-api-BAufmPEa.js.map +0 -1
@@ -1,17 +1,176 @@
1
1
  import { resolve as e } from "node:path";
2
2
  import { createHash as t } from "node:crypto";
3
- function n(e) {
3
+ //#region src/project-identity.ts
4
+ var n = /^(?:command failed(?:\s|:)|error:\s|fatal:\s|git:\s)/iu, r = /^(?:giterror|git error|git command failed):[^\r\n]*(?:not a git repository|unknown revision or path|no such remote)\b/iu;
5
+ function i(e) {
6
+ if (typeof e != "string") return !1;
7
+ let t = e.trim();
8
+ return t ? t.includes("\n") || t.includes("\r") ? !0 : n.test(t) || r.test(t) : !1;
9
+ }
10
+ function a(e) {
11
+ let t = e?.trim();
12
+ return !t || i(t) ? null : t;
13
+ }
14
+ //#endregion
15
+ //#region src/scope-resolution.ts
16
+ var o = "local-default", s = "legacy-shared-review";
17
+ function c(e) {
18
+ return e?.trim() || null;
19
+ }
20
+ function l(e) {
21
+ return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
22
+ }
23
+ function u(t) {
24
+ return l(e(t));
25
+ }
26
+ function d(e) {
27
+ let t = c(e);
28
+ return t ? l(t) : null;
29
+ }
30
+ function f(e) {
31
+ let n = [
32
+ e.cwd,
33
+ e.project,
34
+ e.workspaceId
35
+ ].map((e) => a(e)).find((e) => e !== null), r = [
36
+ e.gitRemote,
37
+ e.gitBranch,
38
+ e.cwd,
39
+ e.project,
40
+ e.workspaceId
41
+ ].map((e) => typeof e == "string" ? e.trim() : null), o = n ?? "unknown";
42
+ return !n && r.some(i) && (o = JSON.stringify(r)), `unmapped:${t("sha256").update(o, "utf8").digest("hex")}`;
43
+ }
44
+ function p(e) {
45
+ let t = a(e.gitRemote), n = a(e.gitBranch), r = a(e.cwd), i = a(e.workspaceId), o = a(e.project);
46
+ if (t) {
47
+ let r = l(t);
48
+ return e.branchScoped && n ? {
49
+ value: `${r}:${n}`,
50
+ source: "git_remote_branch",
51
+ displayProject: o
52
+ } : {
53
+ value: r,
54
+ source: "git_remote",
55
+ displayProject: o
56
+ };
57
+ }
58
+ return r ? {
59
+ value: u(r),
60
+ source: "cwd",
61
+ displayProject: o
62
+ } : i ? {
63
+ value: l(i),
64
+ source: "workspace_id",
65
+ displayProject: o
66
+ } : {
67
+ value: f(e),
68
+ source: "unmapped",
69
+ displayProject: o
70
+ };
71
+ }
72
+ function m(e) {
73
+ return !/[\\/:]/.test(e);
74
+ }
75
+ function h(e) {
76
+ return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
77
+ }
78
+ function g(e) {
79
+ return e.replace(/[*?]/g, "").length;
80
+ }
81
+ function _(e, t) {
82
+ let n = l(t);
83
+ return !n || m(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${h(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
84
+ }
85
+ function v(e) {
86
+ return e.mapping.priority ?? 0;
87
+ }
88
+ function y(e) {
89
+ let t = c(e.mapping.updated_at);
90
+ if (!t) return 0;
91
+ let n = Date.parse(t);
92
+ return Number.isFinite(n) ? n : 0;
93
+ }
94
+ function ee(e, t) {
95
+ return v(t) - v(e) || t.specificity - e.specificity || y(t) - y(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
96
+ }
97
+ function b(e) {
98
+ return e.toSorted(ee)[0] ?? null;
99
+ }
100
+ function x(e) {
101
+ let t = p(e), n = c(e.explicitScopeId);
102
+ if (n) return {
103
+ scopeId: n,
104
+ reason: "explicit_override",
105
+ workspaceIdentity: t,
106
+ mapping: null,
107
+ matchedPattern: null
108
+ };
109
+ if (t.source === "unmapped") return {
110
+ scopeId: e.localDefaultScopeId ?? "local-default",
111
+ reason: "local_default",
112
+ workspaceIdentity: t,
113
+ mapping: null,
114
+ matchedPattern: null
115
+ };
116
+ let r = e.mappings ?? [], i = b(r.filter((e) => d(e.workspace_identity) === t.value).map((e) => ({
117
+ mapping: e,
118
+ matchedPattern: null,
119
+ specificity: t.value.length
120
+ })));
121
+ if (i) return {
122
+ scopeId: i.mapping.scope_id,
123
+ reason: "exact_mapping",
124
+ workspaceIdentity: t,
125
+ mapping: i.mapping,
126
+ matchedPattern: null
127
+ };
128
+ let a = b(r.flatMap((e) => {
129
+ if (c(e.workspace_identity)) return [];
130
+ let n = c(e.project_pattern);
131
+ return !n || !_(t.value, n) ? [] : [{
132
+ mapping: e,
133
+ matchedPattern: l(n),
134
+ specificity: g(n)
135
+ }];
136
+ }));
137
+ return a ? {
138
+ scopeId: a.mapping.scope_id,
139
+ reason: "pattern_mapping",
140
+ workspaceIdentity: t,
141
+ mapping: a.mapping,
142
+ matchedPattern: a.matchedPattern
143
+ } : {
144
+ scopeId: e.localDefaultScopeId ?? "local-default",
145
+ reason: "local_default",
146
+ workspaceIdentity: t,
147
+ mapping: null,
148
+ matchedPattern: null
149
+ };
150
+ }
151
+ function S(e, t) {
152
+ let n = /* @__PURE__ */ new Set([
153
+ "",
154
+ o,
155
+ s
156
+ ]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
157
+ for (let e of r) e.scope_id != null && n.add(e.scope_id);
158
+ let i = e.prepare("SELECT sm.scope_id AS scope_id\n FROM scope_memberships sm\n JOIN replication_scopes rs ON rs.scope_id = sm.scope_id\n WHERE sm.device_id = ?\n AND sm.status = 'active'\n AND rs.status = 'active'\n AND sm.membership_epoch >= rs.membership_epoch").all(t);
159
+ for (let e of i) e.scope_id != null && n.add(e.scope_id);
160
+ return [...n];
161
+ }
162
+ function C(e) {
4
163
  if (e.devices.length > 500 || e.projects.length > 500 || e.devices.length * e.projects.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
5
164
  }
6
- function r(e) {
165
+ function w(e) {
7
166
  if (e.projectIdentities.size * e.deviceCount > 1e4) throw Error("legacy_team_setup_roster_too_large");
8
167
  }
9
- function i(e, t, n) {
168
+ function T(e, t, n) {
10
169
  if (n.length === 0) return;
11
- let r = Number(e.prepare("SELECT COUNT(*) FROM identity_devices").pluck().get() ?? 0);
12
- if ((t.length + r) * n.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
170
+ let r = [...new Set(t.map((e) => e.deviceId))], i = r.length > 0 ? `WHERE device_id NOT IN (${r.map(() => "?").join(", ")})` : "", a = Number(e.prepare(`SELECT COUNT(*) FROM identity_devices ${i}`).pluck().get(...r) ?? 0);
171
+ if ((r.length + a) * n.length > 1e4) throw Error("legacy_team_setup_roster_too_large");
13
172
  }
14
- function a(e, t, n, r) {
173
+ function E(e, t, n, r) {
15
174
  if (!r) return;
16
175
  let i = [...new Set(t.map((e) => e.deviceId))], a = i.map(() => "?").join(", "), o = a ? `AND device_id NOT IN (${a})` : "", s = Number(e.prepare(`SELECT COUNT(*) FROM legacy_team_setup_draft_devices
17
176
  WHERE attempt_id = ? ${o}`).pluck().get(r, ...i) ?? 0), c = t.length + s;
@@ -19,146 +178,146 @@ function a(e, t, n, r) {
19
178
  }
20
179
  //#endregion
21
180
  //#region src/recipient-policy-identifiers.ts
22
- function o(e, t) {
181
+ function D(e, t) {
23
182
  return e < t ? -1 : +(e > t);
24
183
  }
25
- var s = /[\p{Cc}\p{Cf}]/u;
26
- function c(e, t) {
27
- return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !s.test(e);
184
+ var te = /[\p{Cc}\p{Cf}]/u;
185
+ function ne(e, t) {
186
+ return typeof e == "string" && e.length > 0 && e === e.trim() && e.length <= t && !te.test(e);
28
187
  }
29
- function l(e) {
30
- return c(e, 256);
188
+ function re(e) {
189
+ return ne(e, 256);
31
190
  }
32
- function u(e) {
33
- return c(e, 2048);
191
+ function ie(e) {
192
+ return ne(e, 2048);
34
193
  }
35
- var d = "Recipient policy value must be strict JSON data";
36
- function f() {
37
- throw TypeError(d);
194
+ var ae = "Recipient policy value must be strict JSON data";
195
+ function O() {
196
+ throw TypeError(ae);
38
197
  }
39
- function p(e) {
198
+ function oe(e) {
40
199
  let t = JSON.stringify(e);
41
- return t === void 0 ? f() : t;
200
+ return t === void 0 ? O() : t;
42
201
  }
43
- function m(e, t) {
202
+ function se(e, t) {
44
203
  if (e === null) return "null";
45
204
  if (typeof e == "boolean") return e ? "true" : "false";
46
- if (typeof e == "string") return p(e);
47
- if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ? f() : String(e);
48
- if (typeof e != "object" || t.has(e)) return f();
205
+ if (typeof e == "string") return oe(e);
206
+ if (typeof e == "number") return !Number.isFinite(e) || Object.is(e, -0) ? O() : String(e);
207
+ if (typeof e != "object" || t.has(e)) return O();
49
208
  t.add(e);
50
209
  try {
51
210
  if (Array.isArray(e)) {
52
- if (Object.getPrototypeOf(e) !== Array.prototype) return f();
211
+ if (Object.getPrototypeOf(e) !== Array.prototype) return O();
53
212
  let n = Reflect.ownKeys(e);
54
- if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return f();
213
+ if (n.length !== e.length + 1 || n.some((e) => typeof e != "string")) return O();
55
214
  let r = [];
56
215
  for (let n = 0; n < e.length; n += 1) {
57
216
  let i = Object.getOwnPropertyDescriptor(e, String(n));
58
- if (!i?.enumerable || !("value" in i)) return f();
59
- r.push(m(i.value, t));
217
+ if (!i?.enumerable || !("value" in i)) return O();
218
+ r.push(se(i.value, t));
60
219
  }
61
220
  return `[${r.join(",")}]`;
62
221
  }
63
222
  let n = Object.getPrototypeOf(e);
64
- return n !== Object.prototype && n !== null ? f() : `{${Reflect.ownKeys(e).map((t) => {
65
- if (typeof t != "string") return f();
223
+ return n !== Object.prototype && n !== null ? O() : `{${Reflect.ownKeys(e).map((t) => {
224
+ if (typeof t != "string") return O();
66
225
  let n = Object.getOwnPropertyDescriptor(e, t);
67
- return !n?.enumerable || !("value" in n) ? f() : [t, n.value];
68
- }).toSorted(([e], [t]) => o(e, t)).map(([e, n]) => `${p(e)}:${m(n, t)}`).join(",")}}`;
226
+ return !n?.enumerable || !("value" in n) ? O() : [t, n.value];
227
+ }).toSorted(([e], [t]) => D(e, t)).map(([e, n]) => `${oe(e)}:${se(n, t)}`).join(",")}}`;
69
228
  } finally {
70
229
  t.delete(e);
71
230
  }
72
231
  }
73
- function h(e) {
74
- return m(e, /* @__PURE__ */ new WeakSet());
232
+ function ce(e) {
233
+ return se(e, /* @__PURE__ */ new WeakSet());
75
234
  }
76
- function g(e, n) {
235
+ function le(e, n) {
77
236
  if (e.includes("\0") || !e.isWellFormed()) throw TypeError("Recipient policy digest prefix must be well-formed without NUL");
78
- return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(h(n), "utf8").digest("hex")}`;
237
+ return `${e}:${t("sha256").update(e, "utf8").update("\0", "utf8").update(ce(n), "utf8").digest("hex")}`;
79
238
  }
80
- function _(e, n) {
81
- return `${e}:${t("sha256").update(h(n), "utf8").digest("hex")}`;
239
+ function ue(e, n) {
240
+ return `${e}:${t("sha256").update(ce(n), "utf8").digest("hex")}`;
82
241
  }
83
- var v = ["team_invite", "coordinator_invite"];
84
- function y(e, n) {
242
+ var de = ["team_invite", "coordinator_invite"];
243
+ function fe(e, n) {
85
244
  return `legacy-team-candidate:${t("sha256").update(JSON.stringify([e, n])).digest("hex").slice(0, 32)}`;
86
245
  }
87
- function ee(e, t) {
88
- return g("legacy-team-project-ref-v1", [e, t]);
246
+ function pe(e, t) {
247
+ return le("legacy-team-project-ref-v1", [e, t]);
89
248
  }
90
- function b(e, t) {
91
- return g("legacy-team-canonical-project-ref-v1", [e, t]);
249
+ function me(e, t) {
250
+ return le("legacy-team-canonical-project-ref-v1", [e, t]);
92
251
  }
93
- function x(e, t) {
94
- return g("legacy-team-device-ref-v1", [e, t]);
252
+ function he(e, t) {
253
+ return le("legacy-team-device-ref-v1", [e, t]);
95
254
  }
96
- function S(e) {
97
- return _("policy-team-v1", e);
255
+ function ge(e) {
256
+ return ue("policy-team-v1", e);
98
257
  }
99
- function te(e) {
100
- return g("legacy-team-roster-v1", e.map((e) => ({
258
+ function _e(e) {
259
+ return le("legacy-team-roster-v1", e.map((e) => ({
101
260
  deviceId: e.deviceId,
102
261
  fingerprint: e.fingerprint,
103
262
  enabled: e.enabled,
104
263
  identityId: e.identityId
105
- })).toSorted((e, t) => o(e.deviceId, t.deviceId)));
264
+ })).toSorted((e, t) => D(e.deviceId, t.deviceId)));
106
265
  }
107
266
  //#endregion
108
267
  //#region src/coordinator-legacy-team-completion.ts
109
- var C = 1, w = 50, T = 500, E = 15e5, ne = 25 * E, re = 256, ie = 37661024, ae = "completion_conflict", oe = class extends Error {
110
- code = ae;
268
+ var ve = 1, ye = 50, be = 500, xe = 15e5, Se = 25 * xe, Ce = 256, we = 37661024, Te = "completion_conflict", Ee = class extends Error {
269
+ code = Te;
111
270
  constructor() {
112
- super(ae), this.name = "CoordinatorLegacyTeamCompletionConflictError";
271
+ super(Te), this.name = "CoordinatorLegacyTeamCompletionConflictError";
113
272
  }
114
273
  };
115
- function D() {
274
+ function k() {
116
275
  throw Error("completion_manifest_invalid");
117
276
  }
118
- function O(e) {
119
- return (!e || typeof e != "object" || Array.isArray(e)) && D(), e;
277
+ function A(e) {
278
+ return (!e || typeof e != "object" || Array.isArray(e)) && k(), e;
120
279
  }
121
- function k(e, t) {
280
+ function j(e, t) {
122
281
  let n = new Set(t);
123
- Object.keys(e).some((e) => !n.has(e)) && D();
282
+ Object.keys(e).some((e) => !n.has(e)) && k();
124
283
  }
125
- function se(e) {
284
+ function De(e) {
126
285
  return /^(?:[\\/]{2}|\.{1,2}[\\/]|\/|~[\\/]|[a-z]:[\\/]|file:)/iu.test(e);
127
286
  }
128
- function A(e) {
129
- return (typeof e != "string" || !e || e !== e.trim() || e.length > re || /[\p{Cc}\p{Cf}]/u.test(e) || se(e)) && D(), e;
287
+ function M(e) {
288
+ return (typeof e != "string" || !e || e !== e.trim() || e.length > Ce || /[\p{Cc}\p{Cf}]/u.test(e) || De(e)) && k(), e;
130
289
  }
131
- function j(e) {
132
- let t = A(e);
133
- return /^[a-f0-9]{64}$/u.test(t) || D(), t;
290
+ function N(e) {
291
+ let t = M(e);
292
+ return /^[a-f0-9]{64}$/u.test(t) || k(), t;
134
293
  }
135
- function ce(e) {
136
- typeof e != "string" && D();
294
+ function Oe(e) {
295
+ typeof e != "string" && k();
137
296
  let t = e.normalize("NFC").trim();
138
- return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || se(t)) && D(), t;
297
+ return (!t || [...t].length > 120 || /[\p{Cc}\p{Cf}]/u.test(t) || De(t)) && k(), t;
139
298
  }
140
- function le(e) {
141
- (typeof e != "string" || !e) && D();
299
+ function ke(e) {
300
+ (typeof e != "string" || !e) && k();
142
301
  let t = new Date(e);
143
- return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && D(), e;
302
+ return (Number.isNaN(t.getTime()) || t.toISOString() !== e) && k(), e;
144
303
  }
145
- function ue(e, t) {
146
- return (!Array.isArray(e) || e.length > t) && D(), e;
304
+ function Ae(e, t) {
305
+ return (!Array.isArray(e) || e.length > t) && k(), e;
147
306
  }
148
- function M(e, t) {
149
- let n = e.toSorted((e, n) => o(t(e), t(n)));
150
- return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && D(), n;
307
+ function je(e, t) {
308
+ let n = e.toSorted((e, n) => D(t(e), t(n)));
309
+ return n.some((e, r) => r > 0 && t(n[r - 1]) === t(e)) && k(), n;
151
310
  }
152
- function de(e) {
153
- return M(ue(e, 50).map(A), (e) => e);
311
+ function Me(e) {
312
+ return je(Ae(e, 50).map(M), (e) => e);
154
313
  }
155
- function fe(e) {
156
- let t = A(e);
157
- return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || D(), t;
314
+ function Ne(e) {
315
+ let t = M(e);
316
+ return /^legacy-team-candidate:[a-f0-9]{32}$/u.test(t) || k(), t;
158
317
  }
159
- function pe(e) {
160
- let t = O(e);
161
- k(t, [
318
+ function Pe(e) {
319
+ let t = A(e);
320
+ j(t, [
162
321
  "version",
163
322
  "coordinator_id",
164
323
  "candidate_ref",
@@ -174,165 +333,165 @@ function pe(e) {
174
333
  "project_mappings",
175
334
  "project_recipients",
176
335
  "completed_at"
177
- ]), t.version !== 1 && D();
178
- let n = O(t.team);
179
- k(n, [
336
+ ]), t.version !== 1 && k();
337
+ let n = A(t.team);
338
+ j(n, [
180
339
  "display_name",
181
340
  "policy_revision",
182
341
  "device_eligibility_mode"
183
- ]), n.device_eligibility_mode !== "reviewed_allowlist" && D();
184
- let r = A(t.team_id), i = M(ue(t.memberships, 500).map((e) => {
185
- let t = O(e);
186
- return k(t, ["identity_id", "role"]), t.role !== "member" && D(), {
187
- identity_id: A(t.identity_id),
342
+ ]), n.device_eligibility_mode !== "reviewed_allowlist" && k();
343
+ let r = M(t.team_id), i = je(Ae(t.memberships, 500).map((e) => {
344
+ let t = A(e);
345
+ return j(t, ["identity_id", "role"]), t.role !== "member" && k(), {
346
+ identity_id: M(t.identity_id),
188
347
  role: "member"
189
348
  };
190
- }), (e) => e.identity_id), a = M(ue(t.device_decisions, 500).map((e) => {
191
- let t = O(e);
192
- k(t, [
349
+ }), (e) => e.identity_id), a = je(Ae(t.device_decisions, 500).map((e) => {
350
+ let t = A(e);
351
+ j(t, [
193
352
  "device_id",
194
353
  "key_fingerprint",
195
354
  "enabled",
196
355
  "identity_id",
197
356
  "decision"
198
- ]), t.decision !== "included" && t.decision !== "excluded" && D(), typeof t.enabled != "boolean" && D();
199
- let n = t.identity_id == null ? null : A(t.identity_id);
200
- t.decision === "included" != !!n && D(), t.decision === "included" && !t.enabled && D();
357
+ ]), t.decision !== "included" && t.decision !== "excluded" && k(), typeof t.enabled != "boolean" && k();
358
+ let n = t.identity_id == null ? null : M(t.identity_id);
359
+ t.decision === "included" != !!n && k(), t.decision === "included" && !t.enabled && k();
201
360
  let r = t.decision;
202
361
  return {
203
- device_id: A(t.device_id),
204
- key_fingerprint: j(t.key_fingerprint),
362
+ device_id: M(t.device_id),
363
+ key_fingerprint: N(t.key_fingerprint),
205
364
  enabled: t.enabled,
206
365
  identity_id: n,
207
366
  decision: r
208
367
  };
209
368
  }), (e) => e.device_id);
210
- a.length === 0 && D();
211
- let s = new Set(i.map((e) => e.identity_id)), c = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
212
- (s.size !== c.size || [...c].some((e) => !s.has(e))) && D();
213
- let l = M(ue(t.project_mappings, 500).map((e) => {
214
- let t = O(e);
215
- k(t, [
369
+ a.length === 0 && k();
370
+ let o = new Set(i.map((e) => e.identity_id)), s = new Set(a.flatMap((e) => e.identity_id ? [e.identity_id] : []));
371
+ (o.size !== s.size || [...s].some((e) => !o.has(e))) && k();
372
+ let c = je(Ae(t.project_mappings, 500).map((e) => {
373
+ let t = A(e);
374
+ j(t, [
216
375
  "project_ref",
217
376
  "resolved_project_ref",
218
377
  "scope_id"
219
378
  ]);
220
- let n = A(t.project_ref), r = A(t.resolved_project_ref);
221
- return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) || D(), /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(r) || D(), {
379
+ let n = M(t.project_ref), r = M(t.resolved_project_ref);
380
+ return /^legacy-team-project-ref-v1:[0-9a-f]{64}$/u.test(n) || k(), /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(r) || k(), {
222
381
  project_ref: n,
223
382
  resolved_project_ref: r,
224
- scope_id: A(t.scope_id)
383
+ scope_id: M(t.scope_id)
225
384
  };
226
- }), (e) => e.project_ref), u = /* @__PURE__ */ new Map();
227
- for (let e of l) {
228
- let t = u.get(e.resolved_project_ref);
229
- t && t !== e.scope_id && D(), u.set(e.resolved_project_ref, e.scope_id);
230
- }
231
- let d = M(ue(t.project_recipients, 500).map((e) => {
232
- let t = O(e);
233
- k(t, ["resolved_project_ref", "team_id"]);
234
- let n = A(t.team_id);
235
- n !== r && D();
236
- let i = A(t.resolved_project_ref);
237
- return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) || D(), {
385
+ }), (e) => e.project_ref), l = /* @__PURE__ */ new Map();
386
+ for (let e of c) {
387
+ let t = l.get(e.resolved_project_ref);
388
+ t && t !== e.scope_id && k(), l.set(e.resolved_project_ref, e.scope_id);
389
+ }
390
+ let u = je(Ae(t.project_recipients, 500).map((e) => {
391
+ let t = A(e);
392
+ j(t, ["resolved_project_ref", "team_id"]);
393
+ let n = M(t.team_id);
394
+ n !== r && k();
395
+ let i = M(t.resolved_project_ref);
396
+ return /^legacy-team-resolved-project-ref-v1:[0-9a-f]{64}$/u.test(i) || k(), {
238
397
  resolved_project_ref: i,
239
398
  team_id: n
240
399
  };
241
- }), (e) => e.resolved_project_ref), f = [...new Set(l.map((e) => e.resolved_project_ref))].toSorted(o), p = d.map((e) => e.resolved_project_ref);
242
- JSON.stringify(p) !== JSON.stringify(f) && D();
243
- let m = {
400
+ }), (e) => e.resolved_project_ref), d = [...new Set(c.map((e) => e.resolved_project_ref))].toSorted(D), f = u.map((e) => e.resolved_project_ref);
401
+ JSON.stringify(f) !== JSON.stringify(d) && k();
402
+ let p = {
244
403
  version: 1,
245
- coordinator_id: A(t.coordinator_id),
246
- candidate_ref: fe(t.candidate_ref),
247
- candidate_digest: j(t.candidate_digest),
404
+ coordinator_id: M(t.coordinator_id),
405
+ candidate_ref: Ne(t.candidate_ref),
406
+ candidate_digest: N(t.candidate_digest),
248
407
  team_id: r,
249
- team_digest: j(t.team_digest),
250
- source_digest: j(t.source_digest),
251
- finish_digest: j(t.finish_digest),
252
- access_delta_digest: j(t.access_delta_digest),
408
+ team_digest: N(t.team_digest),
409
+ source_digest: N(t.source_digest),
410
+ finish_digest: N(t.finish_digest),
411
+ access_delta_digest: N(t.access_delta_digest),
253
412
  team: {
254
- display_name: ce(n.display_name),
255
- policy_revision: j(n.policy_revision),
413
+ display_name: Oe(n.display_name),
414
+ policy_revision: N(n.policy_revision),
256
415
  device_eligibility_mode: "reviewed_allowlist"
257
416
  },
258
417
  memberships: i,
259
418
  device_decisions: a,
260
- project_mappings: l,
261
- project_recipients: d,
262
- completed_at: le(t.completed_at)
419
+ project_mappings: c,
420
+ project_recipients: u,
421
+ completed_at: ke(t.completed_at)
263
422
  };
264
- return new TextEncoder().encode(JSON.stringify(m)).byteLength > 15e5 && D(), m;
423
+ return new TextEncoder().encode(JSON.stringify(p)).byteLength > 15e5 && k(), p;
265
424
  }
266
- function me(e) {
267
- return JSON.stringify(pe(e));
425
+ function Fe(e) {
426
+ return JSON.stringify(Pe(e));
268
427
  }
269
- function he(e) {
270
- e.team_id !== S(e.candidate_ref) && D();
428
+ function Ie(e) {
429
+ e.team_id !== ge(e.candidate_ref) && k();
271
430
  }
272
- function ge(e, t) {
273
- y(e.coordinator_id, t) !== e.candidate_ref && D();
431
+ function Le(e, t) {
432
+ fe(e.coordinator_id, t) !== e.candidate_ref && k();
274
433
  }
275
- function _e(e, t, n) {
276
- ge(e, t);
434
+ function Re(e, t, n) {
435
+ Le(e, t);
277
436
  let r = new Set(e.project_mappings.map((e) => e.scope_id));
278
- n.length !== r.size && D();
437
+ n.length !== r.size && k();
279
438
  let i = e.coordinator_id;
280
- for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) && D();
439
+ for (let e of n) (!e.scope_id || !r.has(e.scope_id) || e.authority_type !== "coordinator" || !e.coordinator_id || e.group_id !== t || e.status !== "active" || e.coordinator_id !== i) && k();
281
440
  return i;
282
441
  }
283
442
  //#endregion
284
443
  //#region src/coordinator-membership-effects.ts
285
- var ve = "scope_membership_effect_conflict", ye = {
444
+ var ze = "scope_membership_effect_conflict", Be = {
286
445
  device_not_enrolled: "device must be enrolled and enabled in the scope group.",
287
446
  scope_group_mismatch: "membership groupId must match the scope groupId.",
288
447
  scope_inactive: "scope is not active.",
289
448
  scope_not_found: "scopeId must reference an existing scope."
290
- }, N = class extends Error {
449
+ }, P = class extends Error {
291
450
  code;
292
451
  constructor(e) {
293
- super(ye[e]), this.name = "CoordinatorMembershipError", this.code = e;
452
+ super(Be[e]), this.name = "CoordinatorMembershipError", this.code = e;
294
453
  }
295
454
  };
296
- function P(e) {
455
+ function F(e) {
297
456
  return e?.trim() || null;
298
457
  }
299
- function be(e) {
300
- let t = P(e);
458
+ function Ve(e) {
459
+ let t = F(e);
301
460
  if (!t) throw Error("effectId is required.");
302
461
  if (t.length > 512 || /[\p{Cc}\p{Cf}]/u.test(t)) throw Error("effectId is invalid.");
303
462
  return t;
304
463
  }
305
- function xe(e) {
464
+ function He(e) {
306
465
  return JSON.stringify({
307
- scopeId: P(e.scopeId),
308
- deviceId: P(e.deviceId),
309
- role: P(e.role),
466
+ scopeId: F(e.scopeId),
467
+ deviceId: F(e.deviceId),
468
+ role: F(e.role),
310
469
  membershipEpoch: e.membershipEpoch ?? null,
311
- coordinatorId: P(e.coordinatorId),
312
- groupId: P(e.groupId),
313
- manifestIssuerDeviceId: P(e.manifestIssuerDeviceId),
314
- manifestHash: P(e.manifestHash),
315
- signedManifestJson: P(e.signedManifestJson),
316
- actorType: P(e.actorType),
317
- actorId: P(e.actorId)
470
+ coordinatorId: F(e.coordinatorId),
471
+ groupId: F(e.groupId),
472
+ manifestIssuerDeviceId: F(e.manifestIssuerDeviceId),
473
+ manifestHash: F(e.manifestHash),
474
+ signedManifestJson: F(e.signedManifestJson),
475
+ actorType: F(e.actorType),
476
+ actorId: F(e.actorId)
318
477
  });
319
478
  }
320
- function Se(e) {
479
+ function Ue(e) {
321
480
  return JSON.stringify({
322
- scopeId: P(e.scopeId),
323
- deviceId: P(e.deviceId),
324
- groupId: P(e.groupId),
481
+ scopeId: F(e.scopeId),
482
+ deviceId: F(e.deviceId),
483
+ groupId: F(e.groupId),
325
484
  membershipEpoch: e.membershipEpoch ?? null,
326
- manifestHash: P(e.manifestHash),
327
- signedManifestJson: P(e.signedManifestJson),
328
- actorType: P(e.actorType),
329
- actorId: P(e.actorId)
485
+ manifestHash: F(e.manifestHash),
486
+ signedManifestJson: F(e.signedManifestJson),
487
+ actorType: F(e.actorType),
488
+ actorId: F(e.actorId)
330
489
  });
331
490
  }
332
- function Ce(e, t, n) {
333
- if (e.action !== t || e.request_json !== n) throw Error(ve);
491
+ function We(e, t, n) {
492
+ if (e.action !== t || e.request_json !== n) throw Error(ze);
334
493
  }
335
- function we(e) {
494
+ function Ge(e) {
336
495
  if (e.action !== "grant" || e.outcome_applied !== 1 || e.role == null || e.status == null || e.membership_epoch == null || e.updated_at == null) throw Error("scope_membership_effect_receipt_invalid");
337
496
  return {
338
497
  scope_id: e.scope_id,
@@ -350,242 +509,254 @@ function we(e) {
350
509
  }
351
510
  //#endregion
352
511
  //#region src/coordinator-store-contract.ts
353
- function Te(e) {
512
+ function Ke(e) {
354
513
  let t = e.trim(), n = new Date(t);
355
514
  if (!t || Number.isNaN(n.getTime())) throw Error("expiresAt must be a valid date.");
356
515
  return n.toISOString();
357
516
  }
358
- var Ee = /^identity:[A-Za-z0-9_-]{18,24}$/u;
359
- function De(e) {
360
- return typeof e == "string" && e === e.trim() && Ee.test(e);
517
+ var qe = /^identity:[A-Za-z0-9_-]{18,24}$/u;
518
+ function Je(e) {
519
+ return typeof e == "string" && e === e.trim() && qe.test(e);
361
520
  }
362
- function Oe(e) {
521
+ function Ye(e) {
363
522
  return String(e.kind === "team_member" ? e.assigned_identity_id ?? "" : e.target_identity_id ?? "").trim();
364
523
  }
365
- var ke = "reciprocal_approval_request_changed", Ae = class extends Error {
366
- code = ke;
524
+ var Xe = "reciprocal_approval_request_changed", Ze = class extends Error {
525
+ code = Xe;
367
526
  constructor() {
368
- super(ke), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
527
+ super(Xe), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
369
528
  }
370
- }, je = 120, Me = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, Ne = /^(?:actor|device|identity|local):\S+$/iu, Pe = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, Fe = /^pending[_-]\S+$/iu, Ie = /^[a-f0-9]{12,64}$/iu;
371
- function F(e, t) {
529
+ }, Qe = 120, $e = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, et = /^(?:actor|device|identity|local):\S+$/iu, tt = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, nt = /^pending[_-]\S+$/iu, rt = /^[a-f0-9]{12,64}$/iu, it = /^(?=.{1,253}$)(?:(?:[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.){2,}[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?|[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?\.local)$/iu;
530
+ function I(e, t) {
372
531
  if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
373
532
  let n = e.replace(/\s+/gu, " ").trim();
374
533
  if (!n) throw Error(`${t}_required`);
375
- if ([...n].length > je) throw Error(`${t}_too_long`);
534
+ if ([...n].length > Qe) throw Error(`${t}_too_long`);
376
535
  return n;
377
536
  }
378
- function Le(e) {
537
+ function L(e) {
379
538
  if (typeof e != "string") return !1;
380
539
  let t;
381
540
  try {
382
- t = F(e, "display_name");
541
+ t = I(e, "display_name");
383
542
  } catch {
384
543
  return !1;
385
544
  }
386
545
  return ![
387
- Me,
388
- Ne,
389
- Pe,
390
- Fe,
391
- Ie
546
+ $e,
547
+ et,
548
+ tt,
549
+ nt,
550
+ rt
392
551
  ].some((e) => e.test(t));
393
552
  }
394
- function I(e, t) {
395
- let n = F(e, t);
396
- if (!Le(n)) throw Error(`${t}_invalid`);
553
+ function R(e, t) {
554
+ let n = I(e, t);
555
+ if (!L(n)) throw Error(`${t}_invalid`);
397
556
  return n;
398
557
  }
399
- function Re(e) {
400
- let t = String(e ?? "").replace(/\.local$/iu, "");
401
- return t.trim() ? F(t.replace(/[-_]+/gu, " "), "device_display_name") : null;
558
+ function at(e, t) {
559
+ let n = I(e, t);
560
+ if (!it.test(n) && !L(n)) throw Error(`${t}_invalid`);
561
+ return n;
562
+ }
563
+ function ot(e) {
564
+ let t = String(e ?? "").trim(), n = t.replace(/\.local$/iu, "");
565
+ return n ? at(it.test(t) ? n : n.replace(/[-_]+/gu, " "), "device_display_name") : null;
402
566
  }
403
- function ze(e) {
567
+ function st(e) {
404
568
  for (let t of [
405
569
  e.explicitName,
406
570
  e.osName,
407
571
  e.coordinatorName
408
572
  ]) {
409
- let e = String(t ?? "").replace(/\.local$/iu, "").trim();
410
- if (!(!e || !Le(e))) try {
411
- let e = Re(t);
412
- if (e && Le(e)) return e;
573
+ let e = String(t ?? "").trim(), n = e.replace(/\.local$/iu, "");
574
+ if (it.test(e)) {
575
+ try {
576
+ let t = ot(e);
577
+ if (t) return t;
578
+ } catch {}
579
+ continue;
580
+ }
581
+ if (!(!n || !L(n))) try {
582
+ let e = ot(t);
583
+ if (e && L(e)) return e;
413
584
  } catch {}
414
585
  }
415
586
  let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
416
587
  return t ? `Codemem device ${t}` : "Codemem device";
417
588
  }
418
- function Be(e) {
589
+ function ct(e) {
419
590
  if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("project_summaries_invalid");
420
591
  return e.map((e) => {
421
592
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("project_summaries_invalid");
422
593
  let t = e;
423
594
  if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
424
595
  return {
425
- display_name: F(String(t.display_name ?? ""), "project_name"),
596
+ display_name: I(String(t.display_name ?? ""), "project_name"),
426
597
  existing_memory_count: Number(t.existing_memory_count)
427
598
  };
428
599
  });
429
600
  }
430
601
  //#endregion
431
602
  //#region src/recipient-reviewed-intent.ts
432
- var Ve = 1, L = class extends Error {
603
+ var lt = 1, z = class extends Error {
433
604
  code;
434
605
  constructor(e) {
435
606
  super(e), this.name = "RecipientReviewedIntentError", this.code = e;
436
607
  }
437
- }, He = /[\p{Cc}\p{Cf}]/u, Ue = 100, We = 65536;
438
- function R() {
439
- throw new L("recipient_reviewed_intent_invalid");
608
+ }, ut = /[\p{Cc}\p{Cf}]/u, dt = 100, ft = 65536;
609
+ function B() {
610
+ throw new z("recipient_reviewed_intent_invalid");
440
611
  }
441
- function z(e) {
442
- return (!e || typeof e != "object" || Array.isArray(e)) && R(), e;
612
+ function V(e) {
613
+ return (!e || typeof e != "object" || Array.isArray(e)) && B(), e;
443
614
  }
444
- function B(e, t) {
445
- Object.keys(e).some((e) => !t.includes(e)) && R();
615
+ function H(e, t) {
616
+ Object.keys(e).some((e) => !t.includes(e)) && B();
446
617
  }
447
- function V(e, t) {
448
- return (typeof e != "string" || !e || e !== e.trim() || e.length > t || He.test(e)) && R(), e;
618
+ function U(e, t) {
619
+ return (typeof e != "string" || !e || e !== e.trim() || e.length > t || ut.test(e)) && B(), e;
449
620
  }
450
- function Ge(e) {
451
- (typeof e != "string" || He.test(e)) && R();
621
+ function pt(e) {
622
+ (typeof e != "string" || ut.test(e)) && B();
452
623
  let t = e.trim().replace(/\s+/gu, " ");
453
- return (!t || t.length > 256) && R(), t;
624
+ return (!t || t.length > 256) && B(), t;
454
625
  }
455
- function Ke(e) {
456
- typeof e != "string" && R();
626
+ function mt(e) {
627
+ typeof e != "string" && B();
457
628
  try {
458
- return F(e, "identity_display_name");
629
+ return I(e, "identity_display_name");
459
630
  } catch {
460
- return R();
631
+ return B();
461
632
  }
462
633
  }
463
- function qe(e) {
464
- return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && R(), e;
634
+ function ht(e) {
635
+ return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && B(), e;
465
636
  }
466
- function Je(e, t) {
637
+ function gt(e, t) {
467
638
  return e < t ? -1 : +(e > t);
468
639
  }
469
- function Ye(e) {
640
+ function _t(e) {
470
641
  return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
471
642
  }
472
- function Xe(e) {
473
- let t = z(e);
474
- return t.kind === "direct" ? (B(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && R(), B(t, [
643
+ function vt(e) {
644
+ let t = V(e);
645
+ return t.kind === "direct" ? (H(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && B(), H(t, [
475
646
  "kind",
476
647
  "teamId",
477
648
  "displayName"
478
649
  ]), {
479
650
  kind: "team",
480
- teamId: V(t.teamId, 256),
481
- displayName: Ge(t.displayName)
651
+ teamId: U(t.teamId, 256),
652
+ displayName: pt(t.displayName)
482
653
  });
483
654
  }
484
- function Ze(e) {
485
- let t = z(e);
486
- B(t, [
655
+ function yt(e) {
656
+ let t = V(e);
657
+ H(t, [
487
658
  "canonicalProjectIdentity",
488
659
  "displayName",
489
660
  "existingMemoryCount",
490
661
  "futureMemoriesShared",
491
662
  "sources"
492
- ]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && R();
493
- let n = t.sources.map(Xe).toSorted((e, t) => Je(Ye(e), Ye(t)));
494
- return new Set(n.map(Ye)).size !== n.length && R(), {
495
- canonicalProjectIdentity: V(t.canonicalProjectIdentity, 512),
496
- displayName: Ge(t.displayName),
497
- existingMemoryCount: qe(t.existingMemoryCount),
663
+ ]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && B();
664
+ let n = t.sources.map(vt).toSorted((e, t) => gt(_t(e), _t(t)));
665
+ return new Set(n.map(_t)).size !== n.length && B(), {
666
+ canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
667
+ displayName: pt(t.displayName),
668
+ existingMemoryCount: ht(t.existingMemoryCount),
498
669
  futureMemoriesShared: !0,
499
670
  sources: n
500
671
  };
501
672
  }
502
- function Qe(e) {
503
- let t = z(e);
504
- return B(t, [
673
+ function bt(e) {
674
+ let t = V(e);
675
+ return H(t, [
505
676
  "canonicalProjectIdentity",
506
677
  "displayName",
507
678
  "existingMemoryCount"
508
679
  ]), {
509
- canonicalProjectIdentity: V(t.canonicalProjectIdentity, 512),
510
- displayName: Ge(t.displayName),
511
- existingMemoryCount: qe(t.existingMemoryCount)
680
+ canonicalProjectIdentity: U(t.canonicalProjectIdentity, 512),
681
+ displayName: pt(t.displayName),
682
+ existingMemoryCount: ht(t.existingMemoryCount)
512
683
  };
513
684
  }
514
- function $e(e) {
515
- (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > Ue) && R();
516
- let t = e.projects.map(Ze).toSorted((e, t) => Je(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(Qe).toSorted((e, t) => Je(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
517
- return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && R(), {
685
+ function xt(e) {
686
+ (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > dt) && B();
687
+ let t = e.projects.map(yt).toSorted((e, t) => gt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(bt).toSorted((e, t) => gt(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
688
+ return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && B(), {
518
689
  projects: t,
519
690
  excludedProjects: n
520
691
  };
521
692
  }
522
- function et(e, t) {
523
- if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new L("recipient_invite_intent_mismatch");
693
+ function St(e, t) {
694
+ if (!(e.journey === "team" && t.kind === "team_member" && e.team.teamId === t.policyTeamId || e.journey === "add_device" && t.kind === "add_device" && e.targetIdentity.identityId === t.targetIdentityId)) throw new z("recipient_invite_intent_mismatch");
524
695
  }
525
- function tt(e, t) {
526
- let n = z(e);
527
- n.version !== 1 && R();
528
- let r = $e(n), i;
696
+ function Ct(e, t) {
697
+ let n = V(e);
698
+ n.version !== 1 && B();
699
+ let r = xt(n), i;
529
700
  if (n.journey === "team") {
530
- B(n, [
701
+ H(n, [
531
702
  "version",
532
703
  "journey",
533
704
  "team",
534
705
  "projects",
535
706
  "excludedProjects"
536
707
  ]);
537
- let e = z(n.team);
538
- B(e, [
708
+ let e = V(n.team);
709
+ H(e, [
539
710
  "teamId",
540
711
  "displayName",
541
712
  "futureProjectsInherit"
542
- ]), e.futureProjectsInherit !== !0 && R(), i = {
713
+ ]), e.futureProjectsInherit !== !0 && B(), i = {
543
714
  version: 1,
544
715
  journey: "team",
545
716
  team: {
546
- teamId: V(e.teamId, 256),
547
- displayName: Ge(e.displayName),
717
+ teamId: U(e.teamId, 256),
718
+ displayName: pt(e.displayName),
548
719
  futureProjectsInherit: !0
549
720
  },
550
721
  ...r
551
722
  };
552
723
  } else if (n.journey === "add_device") {
553
- B(n, [
724
+ H(n, [
554
725
  "version",
555
726
  "journey",
556
727
  "targetIdentity",
557
728
  "projects",
558
729
  "excludedProjects"
559
730
  ]);
560
- let e = z(n.targetIdentity);
561
- B(e, ["identityId", "displayName"]), i = {
731
+ let e = V(n.targetIdentity);
732
+ H(e, ["identityId", "displayName"]), i = {
562
733
  version: 1,
563
734
  journey: "add_device",
564
735
  targetIdentity: {
565
- identityId: V(e.identityId, 256),
566
- displayName: Ke(e.displayName)
736
+ identityId: U(e.identityId, 256),
737
+ displayName: mt(e.displayName)
567
738
  },
568
739
  ...r
569
740
  };
570
- } else R();
571
- return t && et(i, t), new TextEncoder().encode(H(i)).byteLength > We && R(), i;
741
+ } else B();
742
+ return t && St(i, t), new TextEncoder().encode(W(i)).byteLength > ft && B(), i;
572
743
  }
573
- function H(e) {
574
- return Array.isArray(e) ? `[${e.map(H).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => Je(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${H(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
744
+ function W(e) {
745
+ return Array.isArray(e) ? `[${e.map(W).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => gt(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${W(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
575
746
  }
576
- function nt(e, t) {
577
- return H(tt(e, t));
747
+ function wt(e, t) {
748
+ return W(Ct(e, t));
578
749
  }
579
- async function rt(e, t) {
580
- let n = nt(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
750
+ async function Tt(e, t) {
751
+ let n = wt(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
581
752
  return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
582
753
  }
583
- async function it(e, t) {
584
- let n = tt(e, t.target);
585
- if (await rt(n) !== t.digest) throw new L("recipient_invite_intent_mismatch");
754
+ async function Et(e, t) {
755
+ let n = Ct(e, t.target);
756
+ if (await Tt(n) !== t.digest) throw new z("recipient_invite_intent_mismatch");
586
757
  return n;
587
758
  }
588
- async function at(e, t) {
759
+ async function Dt(e, t) {
589
760
  if (!e) throw Error("recipient_invite_review_unavailable");
590
761
  let n;
591
762
  try {
@@ -594,21 +765,21 @@ async function at(e, t) {
594
765
  throw Error("recipient_invite_review_unavailable");
595
766
  }
596
767
  try {
597
- let r = tt(n, t.target);
598
- if (H(r) !== e) throw Error("recipient_invite_review_unavailable");
599
- return await it(r, t);
768
+ let r = Ct(n, t.target);
769
+ if (W(r) !== e) throw Error("recipient_invite_review_unavailable");
770
+ return await Et(r, t);
600
771
  } catch (e) {
601
- throw e instanceof L && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
772
+ throw e instanceof z && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
602
773
  }
603
774
  }
604
775
  //#endregion
605
776
  //#region src/sync-fingerprint.ts
606
- function ot(e) {
777
+ function Ot(e) {
607
778
  return t("sha256").update(e, "utf-8").digest("hex");
608
779
  }
609
780
  //#endregion
610
781
  //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/compose.js
611
- var st = (e, t, n) => (r, i) => {
782
+ var kt = (e, t, n) => (r, i) => {
612
783
  let a = -1;
613
784
  return o(0);
614
785
  async function o(s) {
@@ -624,45 +795,45 @@ var st = (e, t, n) => (r, i) => {
624
795
  else r.finalized === !1 && n && (c = await n(r));
625
796
  return c && (r.finalized === !1 || l) && (r.res = c), r;
626
797
  }
627
- }, ct = /* @__PURE__ */ Symbol(), lt = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), ut = 32, dt = 1e4, ft = (e) => "headers" in e, pt = async (e, t = /* @__PURE__ */ Object.create(null)) => {
628
- let { all: n = !1, dot: r = !1 } = t, i = (ft(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
629
- return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? mt(e, {
798
+ }, At = /* @__PURE__ */ Symbol(), jt = (e, t) => new Response(e, { headers: { "Content-Type": t.replace(/^[^;]+/, (e) => e.toLowerCase()) } }).formData(), Mt = 32, Nt = 1e4, Pt = (e) => "headers" in e, Ft = async (e, t = /* @__PURE__ */ Object.create(null)) => {
799
+ let { all: n = !1, dot: r = !1 } = t, i = (Pt(e) ? e.headers : e.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
800
+ return i === "multipart/form-data" || i === "application/x-www-form-urlencoded" ? It(e, {
630
801
  all: n,
631
802
  dot: r
632
803
  }) : {};
633
804
  };
634
- async function mt(e, t) {
635
- if (!ft(e) && e.bodyCache.formData) return ht(await e.bodyCache.formData, t);
636
- let n = ft(e) ? e.headers : e.raw.headers, r = lt(await e.arrayBuffer(), n.get("Content-Type") || "");
637
- ft(e) || (e.bodyCache.formData = r);
805
+ async function It(e, t) {
806
+ if (!Pt(e) && e.bodyCache.formData) return Lt(await e.bodyCache.formData, t);
807
+ let n = Pt(e) ? e.headers : e.raw.headers, r = jt(await e.arrayBuffer(), n.get("Content-Type") || "");
808
+ Pt(e) || (e.bodyCache.formData = r);
638
809
  let i = await r;
639
- return i ? ht(i, t) : {};
810
+ return i ? Lt(i, t) : {};
640
811
  }
641
- function ht(e, t) {
812
+ function Lt(e, t) {
642
813
  let n = /* @__PURE__ */ Object.create(null), r = { count: 0 };
643
814
  return e.forEach((e, r) => {
644
- t.all || r.endsWith("[]") ? gt(n, r, e) : n[r] = e;
815
+ t.all || r.endsWith("[]") ? Rt(n, r, e) : n[r] = e;
645
816
  }), t.dot && Object.entries(n).forEach(([e, t]) => {
646
- e.includes(".") && (_t(n, e, t, r), delete n[e]);
817
+ e.includes(".") && (zt(n, e, t, r), delete n[e]);
647
818
  }), n;
648
819
  }
649
- var gt = (e, t, n) => {
820
+ var Rt = (e, t, n) => {
650
821
  e[t] === void 0 ? e[t] = t.endsWith("[]") ? [n] : n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
651
- }, _t = (e, t, n, r) => {
822
+ }, zt = (e, t, n, r) => {
652
823
  if (/(?:^|\.)__proto__\./.test(t)) return;
653
- let i = e, a = t.split(".", ut + 2);
654
- a.length > ut + 1 && vt(), a.forEach((e, t) => {
655
- t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= dt && vt(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
824
+ let i = e, a = t.split(".", Mt + 2);
825
+ a.length > Mt + 1 && Bt(), a.forEach((e, t) => {
826
+ t === a.length - 1 ? i[e] = n : ((!i[e] || typeof i[e] != "object" || Array.isArray(i[e]) || i[e] instanceof File) && (r.count++ >= Nt && Bt(), i[e] = /* @__PURE__ */ Object.create(null)), i = i[e]);
656
827
  });
657
- }, vt = () => {
828
+ }, Bt = () => {
658
829
  throw Error("Nesting limit exceeded");
659
- }, yt = (e) => {
830
+ }, Vt = (e) => {
660
831
  let t = e.split("/");
661
832
  return t[0] === "" && t.shift(), t;
662
- }, bt = (e) => {
663
- let { groups: t, path: n } = xt(e);
664
- return St(yt(n), t);
665
- }, xt = (e) => {
833
+ }, Ht = (e) => {
834
+ let { groups: t, path: n } = Ut(e);
835
+ return Wt(Vt(n), t);
836
+ }, Ut = (e) => {
666
837
  let t = [];
667
838
  return e = e.replace(/\{[^}]+\}/g, (e, n) => {
668
839
  let r = `@${n}`;
@@ -671,7 +842,7 @@ var gt = (e, t, n) => {
671
842
  groups: t,
672
843
  path: e
673
844
  };
674
- }, St = (e, t) => {
845
+ }, Wt = (e, t) => {
675
846
  for (let n = t.length - 1; n >= 0; n--) {
676
847
  let [r] = t[n];
677
848
  for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
@@ -680,12 +851,12 @@ var gt = (e, t, n) => {
680
851
  }
681
852
  }
682
853
  return e;
683
- }, Ct = {}, wt = (e, t) => {
854
+ }, Gt = {}, Kt = (e, t) => {
684
855
  if (e === "*") return "*";
685
856
  let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
686
857
  if (n) {
687
858
  let r = `${e}#${t}`;
688
- return Ct[r] || (Ct[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
859
+ return Gt[r] || (Gt[r] = n[2] ? t && t[0] !== ":" && t[0] !== "*" ? [
689
860
  r,
690
861
  n[1],
691
862
  RegExp(`^${n[2]}(?=/${t})`)
@@ -697,10 +868,10 @@ var gt = (e, t, n) => {
697
868
  e,
698
869
  n[1],
699
870
  !0
700
- ]), Ct[r];
871
+ ]), Gt[r];
701
872
  }
702
873
  return null;
703
- }, Tt = (e, t) => {
874
+ }, qt = (e, t) => {
704
875
  try {
705
876
  return t(e);
706
877
  } catch {
@@ -712,21 +883,21 @@ var gt = (e, t, n) => {
712
883
  }
713
884
  });
714
885
  }
715
- }, Et = (e) => Tt(e, decodeURI), Dt = (e) => {
886
+ }, Jt = (e) => qt(e, decodeURI), Yt = (e) => {
716
887
  let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
717
888
  for (; r < t.length; r++) {
718
889
  let e = t.charCodeAt(r);
719
890
  if (e === 37) {
720
891
  let e = t.indexOf("?", r), i = t.indexOf("#", r), a = e === -1 ? i === -1 ? void 0 : i : i === -1 ? e : Math.min(e, i), o = t.slice(n, a);
721
- return Et(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
892
+ return Jt(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
722
893
  }
723
894
  if (e === 63 || e === 35) break;
724
895
  }
725
896
  return t.slice(n, r);
726
- }, Ot = (e) => {
727
- let t = Dt(e);
897
+ }, Xt = (e) => {
898
+ let t = Yt(e);
728
899
  return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
729
- }, U = (e, t, ...n) => (n.length && (t = U(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), kt = (e) => {
900
+ }, G = (e, t, ...n) => (n.length && (t = G(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), Zt = (e) => {
730
901
  if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
731
902
  let t = e.split("/"), n = [], r = "";
732
903
  return t.forEach((e) => {
@@ -739,7 +910,7 @@ var gt = (e, t, n) => {
739
910
  } else r += "/" + e;
740
911
  }
741
912
  }), n.filter((e, t, n) => n.indexOf(e) === t);
742
- }, At = (e) => e.indexOf("%") === -1 ? e : Tt(e, Ft), jt = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), At(e)), Mt = (e, t, n) => {
913
+ }, Qt = (e) => e.indexOf("%") === -1 ? e : qt(e, rn), $t = (e) => (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), Qt(e)), en = (e, t, n) => {
743
914
  let r = e.indexOf("#", 8);
744
915
  r !== -1 && (e = e.slice(0, r));
745
916
  let i;
@@ -750,7 +921,7 @@ var gt = (e, t, n) => {
750
921
  let r = e.charCodeAt(n + t.length + 1);
751
922
  if (r === 61) {
752
923
  let r = n + t.length + 2, i = e.indexOf("&", r);
753
- return jt(e.slice(r, i === -1 ? void 0 : i));
924
+ return $t(e.slice(r, i === -1 ? void 0 : i));
754
925
  }
755
926
  if (r == 38 || isNaN(r)) return "";
756
927
  n = e.indexOf(`&${t}`, n + 1);
@@ -764,12 +935,12 @@ var gt = (e, t, n) => {
764
935
  let t = e.indexOf("&", o + 1), r = e.indexOf("=", o);
765
936
  r > t && t !== -1 && (r = -1);
766
937
  let s = e.slice(o + 1, r === -1 ? t === -1 ? void 0 : t : r);
767
- if (i && (s = jt(s)), o = t, s === "") continue;
938
+ if (i && (s = $t(s)), o = t, s === "") continue;
768
939
  let c;
769
- r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = jt(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
940
+ r === -1 ? c = "" : (c = e.slice(r + 1, t === -1 ? void 0 : t), i && (c = $t(c))), n ? (a[s] && Array.isArray(a[s]) || (a[s] = []), a[s].push(c)) : a[s] ??= c;
770
941
  }
771
942
  return t ? a[t] : a;
772
- }, Nt = Mt, Pt = (e, t) => Mt(e, t, !0), Ft = decodeURIComponent, It = class {
943
+ }, tn = en, nn = (e, t) => en(e, t, !0), rn = decodeURIComponent, an = class {
773
944
  raw;
774
945
  #e;
775
946
  #t;
@@ -784,13 +955,13 @@ var gt = (e, t, n) => {
784
955
  }
785
956
  #n(e) {
786
957
  let t = this.#t[0][this.routeIndex]?.[1][e], n = this.#i(t);
787
- return n && At(n);
958
+ return n && Qt(n);
788
959
  }
789
960
  #r() {
790
961
  let e = {}, t = Object.keys(this.#t[0][this.routeIndex]?.[1] ?? {});
791
962
  for (let n of t) {
792
963
  let t = this.#i(this.#t[0][this.routeIndex][1][n]);
793
- t !== void 0 && (e[n] = At(t));
964
+ t !== void 0 && (e[n] = Qt(t));
794
965
  }
795
966
  return e;
796
967
  }
@@ -798,10 +969,10 @@ var gt = (e, t, n) => {
798
969
  return this.#t[1] ? this.#t[1][e] : e;
799
970
  }
800
971
  query(e) {
801
- return Nt(this.url, e);
972
+ return tn(this.url, e);
802
973
  }
803
974
  queries(e) {
804
- return Pt(this.url, e);
975
+ return nn(this.url, e);
805
976
  }
806
977
  header(e) {
807
978
  if (e) return this.raw.headers.get(e) ?? void 0;
@@ -811,7 +982,7 @@ var gt = (e, t, n) => {
811
982
  }), t;
812
983
  }
813
984
  async parseBody(e) {
814
- return pt(this, e);
985
+ return Ft(this, e);
815
986
  }
816
987
  #a = (e) => {
817
988
  let { bodyCache: t, raw: n } = this, r = t[e];
@@ -849,7 +1020,7 @@ var gt = (e, t, n) => {
849
1020
  get method() {
850
1021
  return this.raw.method;
851
1022
  }
852
- get [ct]() {
1023
+ get [At]() {
853
1024
  return this.#t;
854
1025
  }
855
1026
  get matchedRoutes() {
@@ -858,14 +1029,14 @@ var gt = (e, t, n) => {
858
1029
  get routePath() {
859
1030
  return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
860
1031
  }
861
- }, Lt = {
1032
+ }, on = {
862
1033
  Stringify: 1,
863
1034
  BeforeStream: 2,
864
1035
  Stream: 3
865
- }, Rt = (e, t) => {
1036
+ }, sn = (e, t) => {
866
1037
  let n = new String(e);
867
1038
  return n.isEscaped = !0, n.callbacks = t, n;
868
- }, zt = async (e, t, n, r, i) => {
1039
+ }, cn = async (e, t, n, r, i) => {
869
1040
  typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
870
1041
  let a = e.callbacks;
871
1042
  if (!a?.length) return Promise.resolve(e);
@@ -874,12 +1045,12 @@ var gt = (e, t, n) => {
874
1045
  phase: t,
875
1046
  buffer: i,
876
1047
  context: r
877
- }))).then((e) => Promise.all(e.filter(Boolean).map((e) => zt(e, t, !1, r, i))).then(() => i[0]));
878
- return n ? Rt(await o, a) : o;
879
- }, Bt = "text/plain; charset=UTF-8", Vt = (e, t) => ({
1048
+ }))).then((e) => Promise.all(e.filter(Boolean).map((e) => cn(e, t, !1, r, i))).then(() => i[0]));
1049
+ return n ? sn(await o, a) : o;
1050
+ }, ln = "text/plain; charset=UTF-8", un = (e, t) => ({
880
1051
  "Content-Type": e,
881
1052
  ...t
882
- }), W = (e, t) => new Response(e, t), Ht = class {
1053
+ }), K = (e, t) => new Response(e, t), dn = class {
883
1054
  #e;
884
1055
  #t;
885
1056
  env = {};
@@ -899,7 +1070,7 @@ var gt = (e, t, n) => {
899
1070
  this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
900
1071
  }
901
1072
  get req() {
902
- return this.#t ??= new It(this.#e, this.#d, this.#u), this.#t;
1073
+ return this.#t ??= new an(this.#e, this.#d, this.#u), this.#t;
903
1074
  }
904
1075
  get event() {
905
1076
  if (this.#i && "respondWith" in this.#i) return this.#i;
@@ -910,11 +1081,11 @@ var gt = (e, t, n) => {
910
1081
  throw Error("This context has no ExecutionContext");
911
1082
  }
912
1083
  get res() {
913
- return this.#a ||= W(null, { headers: this.#l ??= new Headers() });
1084
+ return this.#a ||= K(null, { headers: this.#l ??= new Headers() });
914
1085
  }
915
1086
  set res(e) {
916
1087
  if (this.#a && e) {
917
- e = W(e.body, e);
1088
+ e = K(e.body, e);
918
1089
  for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") {
919
1090
  if (t === "set-cookie") {
920
1091
  let t = this.#a.headers.getSetCookie();
@@ -932,7 +1103,7 @@ var gt = (e, t, n) => {
932
1103
  this.#s = e;
933
1104
  };
934
1105
  header = (e, t, n) => {
935
- this.finalized && (this.#a = W(this.#a.body, this.#a));
1106
+ this.finalized && (this.#a = K(this.#a.body, this.#a));
936
1107
  let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
937
1108
  t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
938
1109
  };
@@ -969,25 +1140,25 @@ var gt = (e, t, n) => {
969
1140
  }
970
1141
  }
971
1142
  }
972
- return W(e, {
1143
+ return K(e, {
973
1144
  status: typeof t == "number" ? t : t?.status ?? this.#r,
974
1145
  headers: r ?? n
975
1146
  });
976
1147
  }
977
1148
  newResponse = (...e) => this.#f(...e);
978
1149
  body = (e, t, n) => this.#f(e, t, n);
979
- text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Vt(Bt, n));
980
- json = (e, t, n) => this.#f(JSON.stringify(e), t, Vt("application/json", n));
1150
+ text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, un(ln, n));
1151
+ json = (e, t, n) => this.#f(JSON.stringify(e), t, un("application/json", n));
981
1152
  html = (e, t, n) => {
982
- let r = (e) => this.#f(e, t, Vt("text/html; charset=UTF-8", n));
983
- return typeof e == "object" ? zt(e, Lt.Stringify, !1, {}).then(r) : r(e);
1153
+ let r = (e) => this.#f(e, t, un("text/html; charset=UTF-8", n));
1154
+ return typeof e == "object" ? cn(e, on.Stringify, !1, {}).then(r) : r(e);
984
1155
  };
985
1156
  redirect = (e, t) => {
986
1157
  let n = String(e);
987
1158
  return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
988
1159
  };
989
- notFound = () => (this.#c ??= () => W(), this.#c(this));
990
- }, Ut = [
1160
+ notFound = () => (this.#c ??= () => K(), this.#c(this));
1161
+ }, fn = [
991
1162
  "get",
992
1163
  "post",
993
1164
  "put",
@@ -995,13 +1166,13 @@ var gt = (e, t, n) => {
995
1166
  "options",
996
1167
  "patch",
997
1168
  "query"
998
- ], Wt = "Can not add a route since the matcher is already built.", Gt = class extends Error {}, Kt = "__COMPOSED_HANDLER", qt = (e) => e.text("404 Not Found", 404), Jt = (e, t) => {
1169
+ ], pn = "Can not add a route since the matcher is already built.", mn = class extends Error {}, hn = "__COMPOSED_HANDLER", gn = (e) => e.text("404 Not Found", 404), _n = (e, t) => {
999
1170
  if ("getResponse" in e) {
1000
1171
  let n = e.getResponse();
1001
1172
  return t.newResponse(n.body, n);
1002
1173
  }
1003
1174
  return console.error(e), t.text("Internal Server Error", 500);
1004
- }, Yt = class e {
1175
+ }, vn = class e {
1005
1176
  get;
1006
1177
  post;
1007
1178
  put;
@@ -1018,7 +1189,7 @@ var gt = (e, t, n) => {
1018
1189
  #e = "/";
1019
1190
  routes = [];
1020
1191
  constructor(e = {}) {
1021
- [...Ut, "all"].forEach((e) => {
1192
+ [...fn, "all"].forEach((e) => {
1022
1193
  this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
1023
1194
  this.#r(e, this.#e, t);
1024
1195
  }), this);
@@ -1034,7 +1205,7 @@ var gt = (e, t, n) => {
1034
1205
  this.#r("ALL", this.#e, e);
1035
1206
  }), this);
1036
1207
  let { strict: t, ...n } = e;
1037
- Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? Dt : Ot;
1208
+ Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? Yt : Xt;
1038
1209
  }
1039
1210
  #t() {
1040
1211
  let t = new e({
@@ -1043,18 +1214,18 @@ var gt = (e, t, n) => {
1043
1214
  });
1044
1215
  return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
1045
1216
  }
1046
- #n = qt;
1047
- errorHandler = Jt;
1217
+ #n = gn;
1218
+ errorHandler = _n;
1048
1219
  route(e, t) {
1049
1220
  let n = this.basePath(e);
1050
1221
  return t.routes.map((e) => {
1051
1222
  let r;
1052
- t.errorHandler === Jt ? r = e.handler : (r = async (n, r) => (await st([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Kt] = e.handler), n.#r(e.method, e.path, r, e.basePath);
1223
+ t.errorHandler === _n ? r = e.handler : (r = async (n, r) => (await kt([], t.errorHandler)(n, () => e.handler(n, r))).res, r[hn] = e.handler), n.#r(e.method, e.path, r, e.basePath);
1053
1224
  }), this;
1054
1225
  }
1055
1226
  basePath(e) {
1056
1227
  let t = this.#t();
1057
- return t._basePath = U(this._basePath, e), t;
1228
+ return t._basePath = G(this._basePath, e), t;
1058
1229
  }
1059
1230
  onError = (e) => (this.errorHandler = e, this);
1060
1231
  notFound = (e) => (this.#n = e, this);
@@ -1072,21 +1243,21 @@ var gt = (e, t, n) => {
1072
1243
  return [e.env, t];
1073
1244
  };
1074
1245
  return r ||= (() => {
1075
- let t = U(this._basePath, e), n = t === "/" ? 0 : t.length;
1246
+ let t = G(this._basePath, e), n = t === "/" ? 0 : t.length;
1076
1247
  return (e) => {
1077
1248
  let t = new URL(e.url);
1078
1249
  return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
1079
1250
  };
1080
- })(), this.#r("ALL", U(e, "*"), async (e, n) => {
1251
+ })(), this.#r("ALL", G(e, "*"), async (e, n) => {
1081
1252
  let i = await t(r(e.req.raw), ...a(e));
1082
1253
  if (i) return i;
1083
1254
  await n();
1084
1255
  }), this;
1085
1256
  }
1086
1257
  #r(e, t, n, r) {
1087
- e = e.toUpperCase(), t = U(this._basePath, t);
1258
+ e = e.toUpperCase(), t = G(this._basePath, t);
1088
1259
  let i = {
1089
- basePath: r === void 0 ? this._basePath : U(this._basePath, r),
1260
+ basePath: r === void 0 ? this._basePath : G(this._basePath, r),
1090
1261
  path: t,
1091
1262
  method: e,
1092
1263
  handler: n
@@ -1099,7 +1270,7 @@ var gt = (e, t, n) => {
1099
1270
  }
1100
1271
  #a(e, t, n, r) {
1101
1272
  if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
1102
- let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new Ht(e, {
1273
+ let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new dn(e, {
1103
1274
  path: i,
1104
1275
  matchResult: a,
1105
1276
  env: n,
@@ -1117,7 +1288,7 @@ var gt = (e, t, n) => {
1117
1288
  }
1118
1289
  return e instanceof Promise ? e.then((e) => e || (o.finalized ? o.res : this.#n(o))).catch((e) => this.#i(e, o)) : e ?? this.#n(o);
1119
1290
  }
1120
- let s = st(a[0], this.errorHandler, this.#n);
1291
+ let s = kt(a[0], this.errorHandler, this.#n);
1121
1292
  return (async () => {
1122
1293
  try {
1123
1294
  let e = await s(o);
@@ -1129,19 +1300,19 @@ var gt = (e, t, n) => {
1129
1300
  })();
1130
1301
  }
1131
1302
  fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
1132
- request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${U("/", e)}`, t), n, r));
1303
+ request = (e, t, n, r) => e instanceof Request ? this.fetch(t ? new Request(e, t) : e, n, r) : (e = e.toString(), this.fetch(new Request(/^https?:\/\//.test(e) ? e : `http://localhost${G("/", e)}`, t), n, r));
1133
1304
  fire = () => {
1134
1305
  addEventListener("fetch", (e) => {
1135
1306
  e.respondWith(this.#a(e.request, e, void 0, e.request.method));
1136
1307
  });
1137
1308
  };
1138
- }, G = () => /* @__PURE__ */ Object.create(null), Xt = [];
1139
- function Zt(e, t) {
1309
+ }, q = () => /* @__PURE__ */ Object.create(null), yn = [];
1310
+ function bn(e, t) {
1140
1311
  let n = this.buildAllMatchers(), r = ((e, t) => {
1141
1312
  let r = n[e] || n.ALL, i = r[2][t];
1142
1313
  if (i) return i;
1143
1314
  let a = t.match(r[0]);
1144
- if (!a) return [[], Xt];
1315
+ if (!a) return [[], yn];
1145
1316
  let o = a.indexOf("", 1);
1146
1317
  return [r[1][o], a];
1147
1318
  });
@@ -1149,14 +1320,14 @@ function Zt(e, t) {
1149
1320
  }
1150
1321
  //#endregion
1151
1322
  //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/router/reg-exp-router/node.js
1152
- var Qt = "[^/]+", $t = "(?:|/.*)", K = /* @__PURE__ */ Symbol(), en = /* @__PURE__ */ new Set(".\\+*[^]$()");
1153
- function tn(e, t) {
1323
+ var xn = "[^/]+", Sn = "(?:|/.*)", J = /* @__PURE__ */ Symbol(), Cn = /* @__PURE__ */ new Set(".\\+*[^]$()");
1324
+ function wn(e, t) {
1154
1325
  return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 ? 1 : e === ".*" || e === "(?:|/.*)" ? t === "(?:|/.*)" ? -1 : 1 : t === ".*" || t === "(?:|/.*)" ? -1 : e === "[^/]+" ? 1 : t === "[^/]+" ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
1155
1326
  }
1156
- var nn = class e {
1327
+ var Tn = class e {
1157
1328
  #e;
1158
1329
  #t;
1159
- #n = G();
1330
+ #n = q();
1160
1331
  insert(t, n, r, i, a) {
1161
1332
  let o = this;
1162
1333
  for (let n = 0, a = t.length; n < a; n++) {
@@ -1167,43 +1338,43 @@ var nn = class e {
1167
1338
  ] : [
1168
1339
  "",
1169
1340
  "",
1170
- Qt
1341
+ xn
1171
1342
  ] : null : s === "/*" ? [
1172
1343
  "",
1173
1344
  "",
1174
- $t
1345
+ Sn
1175
1346
  ] : s.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
1176
1347
  if (c) {
1177
1348
  let t = c[1], n = c[2] || "[^/]+";
1178
- if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && en.has(n))) throw K;
1349
+ if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)) || n.length === 1 && Cn.has(n))) throw J;
1179
1350
  if (l = o.#n[n], !l) {
1180
1351
  if (n !== ".*" && n !== "(?:|/.*)") {
1181
- for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw K;
1352
+ for (let e in o.#n) if ((n.length > 1 || e.length > 1) && e !== ".*" && e !== "(?:|/.*)") throw J;
1182
1353
  }
1183
1354
  l = o.#n[n] = new e();
1184
1355
  }
1185
1356
  t !== "" && (l.#t ??= i.varIndex++, r.push([t, l.#t]));
1186
1357
  } else if (l = o.#n[s], !l) {
1187
- for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw K;
1358
+ for (let e in o.#n) if (e.length > 1 && e !== ".*" && e !== "(?:|/.*)") throw J;
1188
1359
  l = o.#n[s] = new e();
1189
1360
  }
1190
1361
  o = l;
1191
1362
  }
1192
- if (o.#e !== void 0) throw K;
1363
+ if (o.#e !== void 0) throw J;
1193
1364
  o.#e = a ? -1 : n;
1194
1365
  }
1195
1366
  buildRegExpStr() {
1196
- let e = Object.keys(this.#n).sort(tn).map((e) => {
1367
+ let e = Object.keys(this.#n).sort(wn).map((e) => {
1197
1368
  let t = this.#n[e], n = t.buildRegExpStr();
1198
- return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : en.has(e) ? `\\${e}` : e) + n;
1369
+ return n === "" ? "" : (typeof t.#t == "number" ? `(${e})@${t.#t}` : Cn.has(e) ? `\\${e}` : e) + n;
1199
1370
  }).filter(Boolean);
1200
1371
  return typeof this.#e == "number" && this.#e !== -1 && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
1201
1372
  }
1202
- }, rn = class {
1373
+ }, En = class {
1203
1374
  #e = { varIndex: 0 };
1204
- #t = new nn();
1375
+ #t = new Tn();
1205
1376
  #n = 0;
1206
- paths = G();
1377
+ paths = q();
1207
1378
  insert(e, t) {
1208
1379
  if (t) {
1209
1380
  this.#t.insert(e.split(""), 0, [], this.#e, !0);
@@ -1241,64 +1412,64 @@ var nn = class e {
1241
1412
  r
1242
1413
  ];
1243
1414
  }
1244
- }, an = G();
1245
- function on(e) {
1246
- return an[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? $t : e === "*" ? ".*" : `/:${Qt}`)}$`);
1415
+ }, Dn = q();
1416
+ function On(e) {
1417
+ return Dn[e] ??= RegExp(`^${e.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (e, t) => t ? `\\${t}` : e === "/*" ? Sn : e === "*" ? ".*" : `/:${xn}`)}$`);
1247
1418
  }
1248
- function sn(e, t) {
1249
- for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (on(n).test(t)) return [...e[n]];
1419
+ function kn(e, t) {
1420
+ for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (On(n).test(t)) return [...e[n]];
1250
1421
  }
1251
- var cn = class {
1422
+ var An = class {
1252
1423
  name = "RegExpRouter";
1253
1424
  #e;
1254
1425
  #t;
1255
1426
  #n;
1256
1427
  constructor() {
1257
- this.#e = { ALL: G() }, this.#t = { ALL: G() }, this.#n = { ALL: new rn() };
1428
+ this.#e = { ALL: q() }, this.#t = { ALL: q() }, this.#n = { ALL: new En() };
1258
1429
  }
1259
1430
  #r(e, t) {
1260
1431
  try {
1261
1432
  this.#n[e].insert(t, !/\*|\/:/.test(t));
1262
1433
  } catch (e) {
1263
- throw e === K ? new Gt(t) : e;
1434
+ throw e === J ? new mn(t) : e;
1264
1435
  }
1265
1436
  }
1266
1437
  add(e, t, n) {
1267
1438
  let r = this.#e, i = this.#t;
1268
- if (!r) throw Error(Wt);
1439
+ if (!r) throw Error(pn);
1269
1440
  if (!r[e]) {
1270
- this.#n[e] = new rn();
1441
+ this.#n[e] = new En();
1271
1442
  for (let t of [r, i]) {
1272
- t[e] = G();
1443
+ t[e] = q();
1273
1444
  for (let n in t.ALL) t[e][n] = [...t.ALL[n]], this.#r(e, n);
1274
1445
  }
1275
1446
  }
1276
1447
  t === "/*" && (t = "*");
1277
1448
  let a = e === "ALL" ? Object.keys(r) : [e];
1278
1449
  if (/\*$/.test(t)) {
1279
- let e = on(t);
1280
- for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = sn(r[e], t) || sn(r.ALL, t) || []);
1450
+ let e = On(t);
1451
+ for (let e of a) r[e][t] || (this.#r(e, t), r[e][t] = kn(r[e], t) || kn(r.ALL, t) || []);
1281
1452
  for (let o of [r, i]) for (let r of a) for (let i in o[r]) e.test(i) && o[r][i].push([n, t]);
1282
1453
  return;
1283
1454
  }
1284
- let o = kt(t) || [t];
1285
- for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = sn(r[t], e) || sn(r.ALL, e) || []), i[t][e].push([n, e]);
1455
+ let o = Zt(t) || [t];
1456
+ for (let e of o) for (let t of a) i[t][e] || (this.#r(t, e), i[t][e] = kn(r[t], e) || kn(r.ALL, e) || []), i[t][e].push([n, e]);
1286
1457
  }
1287
- match = Zt;
1458
+ match = bn;
1288
1459
  buildAllMatchers() {
1289
- let e = G();
1460
+ let e = q();
1290
1461
  for (let t of Object.keys(this.#t)) e[t] = this.#i(t);
1291
- return this.#e = this.#t = this.#n = void 0, an = G(), e;
1462
+ return this.#e = this.#t = this.#n = void 0, Dn = q(), e;
1292
1463
  }
1293
1464
  #i(e) {
1294
- let t = this.#e[e], n = this.#t[e], r = this.#n[e], i = G(), a = [], [o, s, c] = r.buildRegExp();
1465
+ let t = this.#e[e], n = this.#t[e], r = this.#n[e], i = q(), a = [], [o, s, c] = r.buildRegExp();
1295
1466
  for (let e of [t, n]) for (let t in e) {
1296
1467
  let n = e[t], o = r.paths[t];
1297
1468
  if (!o) {
1298
- i[t] = [n.map(([e]) => [e, G()]), Xt];
1469
+ i[t] = [n.map(([e]) => [e, q()]), yn];
1299
1470
  continue;
1300
1471
  }
1301
- a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e), G())]);
1472
+ a[o[0]] = n.map(([e, t]) => [e, r.paths[t][1].reduceRight((e, [t], n) => (e[t] = c[o[1][n][1]], e), q())]);
1302
1473
  }
1303
1474
  return [
1304
1475
  o,
@@ -1306,7 +1477,7 @@ var cn = class {
1306
1477
  i
1307
1478
  ];
1308
1479
  }
1309
- }, ln = class {
1480
+ }, jn = class {
1310
1481
  name = "SmartRouter";
1311
1482
  #e = [];
1312
1483
  #t = [];
@@ -1314,7 +1485,7 @@ var cn = class {
1314
1485
  this.#e = e.routers;
1315
1486
  }
1316
1487
  add(e, t, n) {
1317
- if (!this.#t) throw Error(Wt);
1488
+ if (!this.#t) throw Error(pn);
1318
1489
  this.#t.push([
1319
1490
  e,
1320
1491
  t,
@@ -1330,7 +1501,7 @@ var cn = class {
1330
1501
  for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
1331
1502
  o = i.match(e, t);
1332
1503
  } catch (e) {
1333
- if (e instanceof Gt) continue;
1504
+ if (e instanceof mn) continue;
1334
1505
  throw e;
1335
1506
  }
1336
1507
  this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
@@ -1343,29 +1514,29 @@ var cn = class {
1343
1514
  if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
1344
1515
  return this.#e[0];
1345
1516
  }
1346
- }, un = G(), dn = 0, fn = class e {
1517
+ }, Mn = q(), Nn = 0, Pn = class e {
1347
1518
  #e = [];
1348
- #t = G();
1519
+ #t = q();
1349
1520
  #n = [];
1350
1521
  #r;
1351
- #i = un;
1522
+ #i = Mn;
1352
1523
  insert(t, n, r) {
1353
- let i = this, a = bt(n), o = /* @__PURE__ */ new Set(), s = 0;
1524
+ let i = this, a = Ht(n), o = /* @__PURE__ */ new Set(), s = 0;
1354
1525
  for (let t of a) {
1355
- let n = a[++s], r = wt(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
1526
+ let n = a[++s], r = Kt(t, n) || (n === void 0 && t && t.indexOf("*") === t.length - 1 ? t : null), c = Array.isArray(r), l = c ? r[0] : r || t, u = i.#t[l] ||= new e();
1356
1527
  r && !u.#r && (u.#r = r, i.#n.push(u)), i = u, c && o.add(r[1]);
1357
1528
  }
1358
1529
  i.#e.push({ [t]: {
1359
1530
  handler: r,
1360
1531
  possibleKeys: [...o],
1361
- score: ++dn
1532
+ score: ++Nn
1362
1533
  } });
1363
1534
  }
1364
1535
  #a(e, t, n, r, i) {
1365
1536
  for (let a = 0, o = t.#e.length; a < o; a++) {
1366
1537
  let o = t.#e[a], s = o[n] || o.ALL;
1367
1538
  if (s) {
1368
- s.params = G(), e.push(s);
1539
+ s.params = q(), e.push(s);
1369
1540
  for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
1370
1541
  let t = s.possibleKeys[e];
1371
1542
  s.params[t] = i?.[t] && !e ? i[t] : r[t] ?? i?.[t];
@@ -1375,15 +1546,15 @@ var cn = class {
1375
1546
  }
1376
1547
  search(e, t) {
1377
1548
  let n = [];
1378
- this.#i = un;
1379
- let r = [this], i = yt(t), a = [], o = i.length, s = null;
1549
+ this.#i = Mn;
1550
+ let r = [this], i = Vt(t), a = [], o = i.length, s = null;
1380
1551
  for (let c = 0; c < o; c++) {
1381
1552
  let l = i[c], u = c === o - 1, d = [];
1382
1553
  for (let f = 0, p = r.length; f < p; f++) {
1383
1554
  let p = r[f], m = p.#t[l];
1384
1555
  m && (m.#i = p.#i, u ? (m.#t["*"] && this.#a(n, m.#t["*"], e, p.#i), this.#a(n, m, e, p.#i)) : d.push(m));
1385
1556
  for (let r of p.#n) {
1386
- let f = r.#r, m = p.#i === un ? {} : { ...p.#i };
1557
+ let f = r.#r, m = p.#i === Mn ? {} : { ...p.#i };
1387
1558
  if (typeof f == "string") {
1388
1559
  (f === "*" || l.startsWith(f.slice(0, -1))) && (this.#a(n, r, e, p.#i), f === "*" && (r.#i = m, d.push(r)));
1389
1560
  continue;
@@ -1417,52 +1588,52 @@ var cn = class {
1417
1588
  }
1418
1589
  return n[1] && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
1419
1590
  }
1420
- }, pn = class {
1591
+ }, Fn = class {
1421
1592
  name = "TrieRouter";
1422
- #e = new fn();
1593
+ #e = new Pn();
1423
1594
  add(e, t, n) {
1424
- for (let r of kt(t) || [t]) this.#e.insert(e, r, n);
1595
+ for (let r of Zt(t) || [t]) this.#e.insert(e, r, n);
1425
1596
  }
1426
1597
  match(e, t) {
1427
1598
  return this.#e.search(e, t);
1428
1599
  }
1429
- }, mn = class extends Yt {
1600
+ }, In = class extends vn {
1430
1601
  constructor(e = {}) {
1431
- super(e), this.router = e.router ?? new ln({ routers: [new cn(), new pn()] });
1602
+ super(e), this.router = e.router ?? new jn({ routers: [new An(), new Fn()] });
1432
1603
  }
1433
1604
  };
1434
1605
  //#endregion
1435
1606
  //#region src/coordinator-invites.ts
1436
- function hn(e) {
1607
+ function Ln(e) {
1437
1608
  let t = "";
1438
1609
  for (let n of e) t += String.fromCharCode(n);
1439
1610
  return btoa(t);
1440
1611
  }
1441
- function gn(e) {
1612
+ function Rn(e) {
1442
1613
  let t = atob(e), n = new Uint8Array(t.length);
1443
1614
  for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
1444
1615
  return n;
1445
1616
  }
1446
- function _n(e) {
1617
+ function zn(e) {
1447
1618
  return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1448
1619
  }
1449
- function vn(e) {
1620
+ function Bn(e) {
1450
1621
  let t = e.replace(/-/g, "+").replace(/_/g, "/");
1451
1622
  return t + "=".repeat((4 - t.length % 4) % 4);
1452
1623
  }
1453
- function yn(e) {
1624
+ function Vn(e) {
1454
1625
  let t = JSON.stringify(e);
1455
- return _n(hn(new TextEncoder().encode(t)));
1626
+ return zn(Ln(new TextEncoder().encode(t)));
1456
1627
  }
1457
- function bn(e) {
1458
- let t = new TextDecoder().decode(gn(vn(e))), n = JSON.parse(t);
1628
+ function Hn(e) {
1629
+ let t = new TextDecoder().decode(Rn(Bn(e))), n = JSON.parse(t);
1459
1630
  if (typeof n != "object" || !n) throw Error("invalid invite payload");
1460
1631
  return n;
1461
1632
  }
1462
- function xn(e) {
1633
+ function Un(e) {
1463
1634
  return `codemem://join?invite=${encodeURIComponent(e)}`;
1464
1635
  }
1465
- function Sn(e) {
1636
+ function Wn(e) {
1466
1637
  let t = e.trim();
1467
1638
  if (t.startsWith("codemem://")) {
1468
1639
  let e = new URL(t).searchParams.get("invite") ?? "";
@@ -1473,201 +1644,41 @@ function Sn(e) {
1473
1644
  }
1474
1645
  //#endregion
1475
1646
  //#region src/project-invite-acceptance.ts
1476
- var Cn = "pending_setup", wn = "project_sync_enablement_failed", Tn = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", En = class extends Error {
1477
- code = wn;
1478
- detail = Tn;
1647
+ var Gn = "pending_setup", Kn = "project_sync_enablement_failed", qn = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", Jn = class extends Error {
1648
+ code = Kn;
1649
+ detail = qn;
1479
1650
  constructor(e) {
1480
- super(Tn, e), this.name = "ProjectSyncEnablementError";
1651
+ super(qn, e), this.name = "ProjectSyncEnablementError";
1481
1652
  }
1482
1653
  };
1483
- function Dn(e) {
1654
+ function Yn(e) {
1484
1655
  return typeof e == "object" && !!e && "code" in e && e.code === "project_sync_enablement_failed" && "detail" in e && e.detail === "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.";
1485
1656
  }
1486
1657
  //#endregion
1487
- //#region src/project-identity.ts
1488
- var On = /^(?:command failed(?:\s|:)|error:\s|fatal:\s|git:\s)/iu, kn = /^(?:giterror|git error|git command failed):[^\r\n]*(?:not a git repository|unknown revision or path|no such remote)\b/iu;
1489
- function An(e) {
1490
- if (typeof e != "string") return !1;
1491
- let t = e.trim();
1492
- return t ? t.includes("\n") || t.includes("\r") ? !0 : On.test(t) || kn.test(t) : !1;
1493
- }
1494
- function q(e) {
1495
- let t = e?.trim();
1496
- return !t || An(t) ? null : t;
1497
- }
1498
- //#endregion
1499
- //#region src/scope-resolution.ts
1500
- var jn = "local-default", Mn = "legacy-shared-review";
1501
- function J(e) {
1502
- return e?.trim() || null;
1503
- }
1504
- function Y(e) {
1505
- return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
1506
- }
1507
- function Nn(t) {
1508
- return Y(e(t));
1509
- }
1510
- function Pn(e) {
1511
- let t = J(e);
1512
- return t ? Y(t) : null;
1513
- }
1514
- function Fn(e) {
1515
- let n = [
1516
- e.cwd,
1517
- e.project,
1518
- e.workspaceId
1519
- ].map((e) => q(e)).find((e) => e !== null), r = [
1520
- e.gitRemote,
1521
- e.gitBranch,
1522
- e.cwd,
1523
- e.project,
1524
- e.workspaceId
1525
- ].map((e) => typeof e == "string" ? e.trim() : null), i = n ?? "unknown";
1526
- return !n && r.some(An) && (i = JSON.stringify(r)), `unmapped:${t("sha256").update(i, "utf8").digest("hex")}`;
1527
- }
1528
- function In(e) {
1529
- let t = q(e.gitRemote), n = q(e.gitBranch), r = q(e.cwd), i = q(e.workspaceId), a = q(e.project);
1530
- if (t) {
1531
- let r = Y(t);
1532
- return e.branchScoped && n ? {
1533
- value: `${r}:${n}`,
1534
- source: "git_remote_branch",
1535
- displayProject: a
1536
- } : {
1537
- value: r,
1538
- source: "git_remote",
1539
- displayProject: a
1540
- };
1541
- }
1542
- return r ? {
1543
- value: Nn(r),
1544
- source: "cwd",
1545
- displayProject: a
1546
- } : i ? {
1547
- value: Y(i),
1548
- source: "workspace_id",
1549
- displayProject: a
1550
- } : {
1551
- value: Fn(e),
1552
- source: "unmapped",
1553
- displayProject: a
1554
- };
1555
- }
1556
- function Ln(e) {
1557
- return !/[\\/:]/.test(e);
1558
- }
1559
- function Rn(e) {
1560
- return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
1561
- }
1562
- function zn(e) {
1563
- return e.replace(/[*?]/g, "").length;
1564
- }
1565
- function Bn(e, t) {
1566
- let n = Y(t);
1567
- return !n || Ln(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Rn(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
1568
- }
1569
- function Vn(e) {
1570
- return e.mapping.priority ?? 0;
1571
- }
1572
- function Hn(e) {
1573
- let t = J(e.mapping.updated_at);
1574
- if (!t) return 0;
1575
- let n = Date.parse(t);
1576
- return Number.isFinite(n) ? n : 0;
1577
- }
1578
- function Un(e, t) {
1579
- return Vn(t) - Vn(e) || t.specificity - e.specificity || Hn(t) - Hn(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
1580
- }
1581
- function Wn(e) {
1582
- return e.toSorted(Un)[0] ?? null;
1583
- }
1584
- function Gn(e) {
1585
- let t = In(e), n = J(e.explicitScopeId);
1586
- if (n) return {
1587
- scopeId: n,
1588
- reason: "explicit_override",
1589
- workspaceIdentity: t,
1590
- mapping: null,
1591
- matchedPattern: null
1592
- };
1593
- if (t.source === "unmapped") return {
1594
- scopeId: e.localDefaultScopeId ?? "local-default",
1595
- reason: "local_default",
1596
- workspaceIdentity: t,
1597
- mapping: null,
1598
- matchedPattern: null
1599
- };
1600
- let r = e.mappings ?? [], i = Wn(r.filter((e) => Pn(e.workspace_identity) === t.value).map((e) => ({
1601
- mapping: e,
1602
- matchedPattern: null,
1603
- specificity: t.value.length
1604
- })));
1605
- if (i) return {
1606
- scopeId: i.mapping.scope_id,
1607
- reason: "exact_mapping",
1608
- workspaceIdentity: t,
1609
- mapping: i.mapping,
1610
- matchedPattern: null
1611
- };
1612
- let a = Wn(r.flatMap((e) => {
1613
- if (J(e.workspace_identity)) return [];
1614
- let n = J(e.project_pattern);
1615
- return !n || !Bn(t.value, n) ? [] : [{
1616
- mapping: e,
1617
- matchedPattern: Y(n),
1618
- specificity: zn(n)
1619
- }];
1620
- }));
1621
- return a ? {
1622
- scopeId: a.mapping.scope_id,
1623
- reason: "pattern_mapping",
1624
- workspaceIdentity: t,
1625
- mapping: a.mapping,
1626
- matchedPattern: a.matchedPattern
1627
- } : {
1628
- scopeId: e.localDefaultScopeId ?? "local-default",
1629
- reason: "local_default",
1630
- workspaceIdentity: t,
1631
- mapping: null,
1632
- matchedPattern: null
1633
- };
1634
- }
1635
- function Kn(e, t) {
1636
- let n = /* @__PURE__ */ new Set([
1637
- "",
1638
- jn,
1639
- Mn
1640
- ]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
1641
- for (let e of r) e.scope_id != null && n.add(e.scope_id);
1642
- let i = e.prepare("SELECT sm.scope_id AS scope_id\n FROM scope_memberships sm\n JOIN replication_scopes rs ON rs.scope_id = sm.scope_id\n WHERE sm.device_id = ?\n AND sm.status = 'active'\n AND rs.status = 'active'\n AND sm.membership_epoch >= rs.membership_epoch").all(t);
1643
- for (let e of i) e.scope_id != null && n.add(e.scope_id);
1644
- return [...n];
1645
- }
1646
- //#endregion
1647
1658
  //#region src/project-share-intent.ts
1648
- var qn = "existing_and_future";
1649
- function Jn(e) {
1659
+ var Xn = "existing_and_future";
1660
+ function Zn(e) {
1650
1661
  return t("sha256").update(JSON.stringify(e)).digest("hex");
1651
1662
  }
1652
- function Yn(e) {
1653
- return Jn({
1663
+ function Qn(e) {
1664
+ return Zn({
1654
1665
  v: 1,
1655
- historyPolicy: qn,
1666
+ historyPolicy: Xn,
1656
1667
  projects: e.map((e) => ({
1657
1668
  canonicalIdentity: e.canonicalIdentity,
1658
1669
  existingMemoryCount: e.existingMemoryCount
1659
1670
  })).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
1660
1671
  });
1661
1672
  }
1662
- function Xn(e) {
1663
- return Yn(e.map((e) => ({
1673
+ function $n(e) {
1674
+ return Qn(e.map((e) => ({
1664
1675
  canonicalIdentity: e.canonical_identity,
1665
1676
  displayName: e.display_name,
1666
1677
  identitySource: "coordinator_acceptance",
1667
1678
  existingMemoryCount: e.existing_memory_count
1668
1679
  })));
1669
1680
  }
1670
- function Zn(e) {
1681
+ function er(e) {
1671
1682
  if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
1672
1683
  let t = e.map((e) => {
1673
1684
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
@@ -1675,11 +1686,11 @@ function Zn(e) {
1675
1686
  if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
1676
1687
  let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
1677
1688
  try {
1678
- a = F(i, "project_name");
1689
+ a = I(i, "project_name");
1679
1690
  } catch {
1680
1691
  throw Error("operation_intent_invalid");
1681
1692
  }
1682
- let o = t.existing_memory_count, s = In({ gitRemote: r }).value;
1693
+ let o = t.existing_memory_count, s = p({ gitRemote: r }).value;
1683
1694
  if (!r || r !== n || r.length > 2048 || r.startsWith("unmapped:") || s !== r || a !== i || !Number.isSafeInteger(o) || Number(o) < 0 || /[\p{Cc}\p{Cf}]/u.test(r) || /[\p{Cc}\p{Cf}]/u.test(a)) throw Error("operation_intent_invalid");
1684
1695
  return {
1685
1696
  canonical_identity: r,
@@ -1692,20 +1703,20 @@ function Zn(e) {
1692
1703
  }
1693
1704
  //#endregion
1694
1705
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
1695
- function Qn(e) {
1706
+ function tr(e) {
1696
1707
  let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
1697
1708
  return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
1698
1709
  }
1699
- function $n() {
1700
- let [e, t] = Qn();
1710
+ function Y() {
1711
+ let [e, t] = tr();
1701
1712
  return e * 1e3 + Math.floor(t / 1e6);
1702
1713
  }
1703
- function er(e) {
1714
+ function nr(e) {
1704
1715
  return new Promise((t) => setTimeout(t, e));
1705
1716
  }
1706
1717
  //#endregion
1707
1718
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
1708
- var tr = class {
1719
+ var rr = class {
1709
1720
  bucketSize;
1710
1721
  tokensPerInterval;
1711
1722
  interval;
@@ -1732,13 +1743,13 @@ var tr = class {
1732
1743
  default: throw Error("Invalid interval " + n);
1733
1744
  }
1734
1745
  else this.interval = n;
1735
- this.parentBucket = r, this.content = 0, this.lastDrip = $n();
1746
+ this.parentBucket = r, this.content = 0, this.lastDrip = Y();
1736
1747
  }
1737
1748
  async removeTokens(e) {
1738
1749
  if (this.bucketSize === 0) return Infinity;
1739
1750
  if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
1740
1751
  this.drip();
1741
- let t = async () => (await er(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
1752
+ let t = async () => (await nr(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
1742
1753
  if (e > this.content) return t();
1743
1754
  if (this.parentBucket != null) {
1744
1755
  let n = await this.parentBucket.removeTokens(e);
@@ -1754,30 +1765,30 @@ var tr = class {
1754
1765
  let e = this.content;
1755
1766
  return this.content = this.bucketSize, this.content > e;
1756
1767
  }
1757
- let e = $n(), t = Math.max(e - this.lastDrip, 0);
1768
+ let e = Y(), t = Math.max(e - this.lastDrip, 0);
1758
1769
  this.lastDrip = e;
1759
1770
  let n = t * (this.tokensPerInterval / this.interval), r = this.content;
1760
1771
  return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
1761
1772
  }
1762
- }, nr = class {
1773
+ }, ir = class {
1763
1774
  tokenBucket;
1764
1775
  curIntervalStart;
1765
1776
  tokensThisInterval;
1766
1777
  fireImmediately;
1767
1778
  constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
1768
- this.tokenBucket = new tr({
1779
+ this.tokenBucket = new rr({
1769
1780
  bucketSize: e,
1770
1781
  tokensPerInterval: e,
1771
1782
  interval: t
1772
- }), this.tokenBucket.content = e, this.curIntervalStart = $n(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
1783
+ }), this.tokenBucket.content = e, this.curIntervalStart = Y(), this.tokensThisInterval = 0, this.fireImmediately = n ?? !1;
1773
1784
  }
1774
1785
  async removeTokens(e) {
1775
1786
  if (e > this.tokenBucket.bucketSize) throw Error(`Requested tokens ${e} exceeds maximum tokens per interval ${this.tokenBucket.bucketSize}`);
1776
- let t = $n();
1787
+ let t = Y();
1777
1788
  if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
1778
1789
  if (this.fireImmediately) return -1;
1779
1790
  {
1780
- await er(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
1791
+ await nr(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
1781
1792
  let n = await this.tokenBucket.removeTokens(e);
1782
1793
  return this.tokensThisInterval += e, n;
1783
1794
  }
@@ -1787,7 +1798,7 @@ var tr = class {
1787
1798
  }
1788
1799
  tryRemoveTokens(e) {
1789
1800
  if (e > this.tokenBucket.bucketSize) return !1;
1790
- let t = $n();
1801
+ let t = Y();
1791
1802
  if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) return !1;
1792
1803
  let n = this.tokenBucket.tryRemoveTokens(e);
1793
1804
  return n && (this.tokensThisInterval += e), n;
@@ -1798,7 +1809,7 @@ var tr = class {
1798
1809
  };
1799
1810
  //#endregion
1800
1811
  //#region src/request-rate-limit.ts
1801
- function rr(e = {}) {
1812
+ function ar(e = {}) {
1802
1813
  let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
1803
1814
  function a(e) {
1804
1815
  return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
@@ -1815,7 +1826,7 @@ function rr(e = {}) {
1815
1826
  o(l);
1816
1827
  let u = `${c}:${e}`, d = r.get(u);
1817
1828
  return d || (d = {
1818
- limiter: new nr({
1829
+ limiter: new ir({
1819
1830
  tokensPerInterval: c,
1820
1831
  interval: t,
1821
1832
  fireImmediately: !0
@@ -1832,8 +1843,8 @@ function rr(e = {}) {
1832
1843
  }
1833
1844
  //#endregion
1834
1845
  //#region src/scope-membership-semantics.ts
1835
- var ir = "Revocation blocks future sync for this Space. It does not remove data already copied to the revoked device; offline devices, backups, copied databases, malicious peers, or old versions may retain data.";
1836
- function ar(e) {
1846
+ var or = "Revocation blocks future sync for this Space. It does not remove data already copied to the revoked device; offline devices, backups, copied databases, malicious peers, or old versions may retain data.";
1847
+ function sr(e) {
1837
1848
  let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
1838
1849
  return t == null || n == null ? {
1839
1850
  membership_epoch: t,
@@ -1847,19 +1858,19 @@ function ar(e) {
1847
1858
  reason: t < n ? "stale_epoch" : "current"
1848
1859
  };
1849
1860
  }
1850
- function or(e) {
1861
+ function cr(e) {
1851
1862
  return {
1852
1863
  scope_id: e.scopeId,
1853
1864
  device_id: e.deviceId,
1854
1865
  membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
1855
1866
  prevents_future_sync: !0,
1856
1867
  deletes_already_copied_data: !1,
1857
- message: ir
1868
+ message: or
1858
1869
  };
1859
1870
  }
1860
1871
  //#endregion
1861
1872
  //#region src/sync-auth-constants.ts
1862
- var sr = 300, cr = 65536, lr = E + 1024, X = "X-Codemem-Coordinator-Admin", ur = "X-Codemem-Coordinator-Admin-Actor", dr = 120, fr = 30;
1873
+ var lr = 300, ur = 65536, dr = xe + 1024, X = "X-Codemem-Coordinator-Admin", fr = "X-Codemem-Coordinator-Admin-Actor", pr = 120, mr = 30;
1863
1874
  function Z(e, t) {
1864
1875
  let n = t.adminSecret();
1865
1876
  if (!n) return {
@@ -1878,14 +1889,14 @@ function Z(e, t) {
1878
1889
  error: "missing_admin_header"
1879
1890
  };
1880
1891
  }
1881
- function pr(e) {
1892
+ function hr(e) {
1882
1893
  let t = new URL(e);
1883
1894
  return t.search ? `${t.pathname}${t.search}` : t.pathname;
1884
1895
  }
1885
- async function mr(e, t, n, r) {
1896
+ async function gr(e, t, n, r) {
1886
1897
  return await e.recordNonce(t, n, r);
1887
1898
  }
1888
- async function hr(e, t) {
1899
+ async function _r(e, t) {
1889
1900
  await e.cleanupNonces(t);
1890
1901
  }
1891
1902
  async function Q(e, t, n, r) {
@@ -1921,7 +1932,7 @@ async function Q(e, t, n, r) {
1921
1932
  try {
1922
1933
  u = await n({
1923
1934
  method: r.method,
1924
- pathWithQuery: pr(r.url),
1935
+ pathWithQuery: hr(r.url),
1925
1936
  bodyBytes: r.body,
1926
1937
  timestamp: o,
1927
1938
  nonce: s,
@@ -1942,7 +1953,7 @@ async function Q(e, t, n, r) {
1942
1953
  enrollment: null
1943
1954
  };
1944
1955
  let d = t.now();
1945
- return await mr(e, i, s, d) ? (await hr(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
1956
+ return await gr(e, i, s, d) ? (await _r(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 6e5)).toISOString()), {
1946
1957
  ok: !0,
1947
1958
  error: "ok",
1948
1959
  enrollment: c
@@ -1955,9 +1966,9 @@ async function Q(e, t, n, r) {
1955
1966
  function $(e) {
1956
1967
  return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
1957
1968
  }
1958
- function gr(e) {
1969
+ function vr(e) {
1959
1970
  if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
1960
- let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? rr(), o = Math.max(1, Math.trunc(i.readLimit ?? dr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? fr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new mn(), d = new TextDecoder();
1971
+ let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, i = e.requestRateLimit ?? {}, a = i.limiter ?? ar(), o = Math.max(1, Math.trunc(i.readLimit ?? pr)), s = Math.max(1, Math.trunc(i.mutationLimit ?? mr)), c = Math.max(1, Math.trunc(i.unauthenticatedReadLimit ?? Math.min(20, o))), l = Math.max(1, Math.trunc(i.unauthenticatedMutationLimit ?? Math.min(10, s))), u = new In(), d = new TextDecoder();
1961
1972
  function f(e, t, n) {
1962
1973
  let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = a.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? o : s : r ? c : l);
1963
1974
  return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
@@ -1965,7 +1976,7 @@ function gr(e) {
1965
1976
  retry_after_s: i.retryAfterS
1966
1977
  }, 429));
1967
1978
  }
1968
- async function p(e, t = cr) {
1979
+ async function p(e, t = ur) {
1969
1980
  let n = Number.parseInt(e.req.header("content-length") ?? "", 10);
1970
1981
  if (Number.isFinite(n) && n > t) return null;
1971
1982
  let r = e.req.raw.body;
@@ -2024,7 +2035,7 @@ function gr(e) {
2024
2035
  }
2025
2036
  function y(e) {
2026
2037
  try {
2027
- return Zn(JSON.parse(e ?? ""));
2038
+ return er(JSON.parse(e ?? ""));
2028
2039
  } catch {
2029
2040
  throw Error("operation_intent_invalid");
2030
2041
  }
@@ -2033,7 +2044,7 @@ function gr(e) {
2033
2044
  let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
2034
2045
  if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
2035
2046
  let r = y(e.project_intent_json);
2036
- if (Xn(r) !== n) throw Error("operation_intent_invalid");
2047
+ if ($n(r) !== n) throw Error("operation_intent_invalid");
2037
2048
  return {
2038
2049
  operation_id: t,
2039
2050
  reviewed_project_set_digest: n,
@@ -2042,7 +2053,7 @@ function gr(e) {
2042
2053
  }
2043
2054
  function b(e) {
2044
2055
  try {
2045
- return Be(JSON.parse(e ?? ""));
2056
+ return ct(JSON.parse(e ?? ""));
2046
2057
  } catch {
2047
2058
  throw Error("operation_intent_invalid");
2048
2059
  }
@@ -2074,7 +2085,7 @@ function gr(e) {
2074
2085
  response: r.json({ error: "scope_not_found" }, 404)
2075
2086
  };
2076
2087
  }
2077
- async function te(e, n, i) {
2088
+ async function C(e, n, i) {
2078
2089
  let a = await Q(e, t, r, {
2079
2090
  method: i.req.method,
2080
2091
  url: i.req.url,
@@ -2093,7 +2104,7 @@ function gr(e) {
2093
2104
  response: f(i, String(a.enrollment.device_id), !0)
2094
2105
  };
2095
2106
  }
2096
- function C(e, t) {
2107
+ function w(e, t) {
2097
2108
  return e.status === "active" && e.membership_epoch >= t.membership_epoch;
2098
2109
  }
2099
2110
  return u.post("/v1/presence", async (e) => {
@@ -2169,7 +2180,7 @@ function gr(e) {
2169
2180
  if (!t) return e.json({ error: "group_id_required" }, 400);
2170
2181
  let r = n();
2171
2182
  try {
2172
- let { auth: n, response: i } = await te(r, t, e);
2183
+ let { auth: n, response: i } = await C(r, t, e);
2173
2184
  if (i) return i;
2174
2185
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
2175
2186
  let a = await r.listScopes({
@@ -2178,7 +2189,7 @@ function gr(e) {
2178
2189
  }), o = await r.listDeviceScopeMemberships(String(n.enrollment.device_id), !1), s = new Map(o.map((e) => [e.scope_id, e])), c = a.filter((e) => {
2179
2190
  if (e.status !== "active") return !1;
2180
2191
  let t = s.get(e.scope_id);
2181
- return !!(t && C(t, e));
2192
+ return !!(t && w(t, e));
2182
2193
  });
2183
2194
  return e.json({ items: c });
2184
2195
  } finally {
@@ -2190,7 +2201,7 @@ function gr(e) {
2190
2201
  if (!r) return e.json({ error: "scope_id_required" }, 400);
2191
2202
  let i = n();
2192
2203
  try {
2193
- let { auth: n, response: a } = await te(i, t, e);
2204
+ let { auth: n, response: a } = await C(i, t, e);
2194
2205
  if (a) return a;
2195
2206
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
2196
2207
  let o = (await i.listScopes({
@@ -2199,7 +2210,7 @@ function gr(e) {
2199
2210
  })).find((e) => e.scope_id === r) ?? null;
2200
2211
  if (o?.status !== "active") return e.json({ error: "scope_not_found" }, 404);
2201
2212
  let s = await i.listScopeMemberships(r, !1);
2202
- return s.some((e) => e.device_id === String(n.enrollment?.device_id) && C(e, o)) ? e.json({ items: s.filter((e) => C(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
2213
+ return s.some((e) => e.device_id === String(n.enrollment?.device_id) && w(e, o)) ? e.json({ items: s.filter((e) => w(e, o)) }) : e.json({ error: "scope_not_authorized" }, 403);
2203
2214
  } finally {
2204
2215
  await i.close();
2205
2216
  }
@@ -2268,7 +2279,7 @@ function gr(e) {
2268
2279
  request: t
2269
2280
  });
2270
2281
  } catch (t) {
2271
- if (t instanceof Ae) return e.json({ error: t.code }, 409);
2282
+ if (t instanceof Ze) return e.json({ error: t.code }, 409);
2272
2283
  throw t;
2273
2284
  }
2274
2285
  } finally {
@@ -2310,7 +2321,7 @@ function gr(e) {
2310
2321
  if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
2311
2322
  let p;
2312
2323
  try {
2313
- p = await it(a.reviewed_intent, {
2324
+ p = await Et(a.reviewed_intent, {
2314
2325
  target: {
2315
2326
  kind: "add_device",
2316
2327
  targetIdentityId: d
@@ -2318,7 +2329,7 @@ function gr(e) {
2318
2329
  digest: l
2319
2330
  });
2320
2331
  } catch (t) {
2321
- return t instanceof L && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2332
+ return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2322
2333
  }
2323
2334
  let m = await u.createInvite({
2324
2335
  groupId: s,
@@ -2342,13 +2353,13 @@ function gr(e) {
2342
2353
  target_identity_id: m.target_identity_id ?? void 0,
2343
2354
  inviter_device_id: m.inviter_device_id ?? void 0,
2344
2355
  reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
2345
- }, g = yn(h), { token: _, ...v } = m;
2356
+ }, g = Vn(h), { token: _, ...v } = m;
2346
2357
  return e.json({
2347
2358
  ok: !0,
2348
2359
  invite: v,
2349
2360
  payload: h,
2350
2361
  encoded: g,
2351
- link: xn(g)
2362
+ link: Un(g)
2352
2363
  });
2353
2364
  } finally {
2354
2365
  await u.close();
@@ -2364,7 +2375,7 @@ function gr(e) {
2364
2375
  if (!o) return e.json({ error: "invalid_json" }, 400);
2365
2376
  let s = String(o.group_id ?? "").trim(), c = String(o.device_id ?? "").trim(), l = String(o.fingerprint ?? "").trim(), u = String(o.public_key ?? "").trim(), d = String(o.display_name ?? "").trim() || null;
2366
2377
  if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
2367
- if (ot(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2378
+ if (Ot(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2368
2379
  let h = n();
2369
2380
  try {
2370
2381
  await h.createGroup(s), await h.enrollDevice(s, {
@@ -2604,7 +2615,7 @@ function gr(e) {
2604
2615
  manifestHash: h(o, "manifest_hash"),
2605
2616
  signedManifestJson: h(o, "signed_manifest_json"),
2606
2617
  actorType: "admin",
2607
- actorId: g(e.req.header(ur))
2618
+ actorId: g(e.req.header(fr))
2608
2619
  });
2609
2620
  return e.json({
2610
2621
  ok: !0,
@@ -2612,9 +2623,9 @@ function gr(e) {
2612
2623
  }, 201);
2613
2624
  } catch (t) {
2614
2625
  let n = t instanceof Error ? t.message : String(t);
2615
- if (t instanceof N && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
2616
- if (t instanceof N && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
2617
- let r = t instanceof N && t.code === "scope_inactive";
2626
+ if (t instanceof P && (t.code === "scope_not_found" || t.code === "scope_group_mismatch")) return e.json({ error: "scope_not_found" }, 404);
2627
+ if (t instanceof P && t.code === "device_not_enrolled") return e.json({ error: "device_not_enrolled_for_scope_group" }, 404);
2628
+ let r = t instanceof P && t.code === "scope_inactive";
2618
2629
  return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
2619
2630
  } finally {
2620
2631
  await v.close();
@@ -2645,7 +2656,7 @@ function gr(e) {
2645
2656
  manifestHash: h(o, "manifest_hash"),
2646
2657
  signedManifestJson: h(o, "signed_manifest_json"),
2647
2658
  actorType: "admin",
2648
- actorId: g(e.req.header(ur))
2659
+ actorId: g(e.req.header(fr))
2649
2660
  })) return e.json({ error: "membership_not_found" }, 404);
2650
2661
  let n;
2651
2662
  try {
@@ -2657,7 +2668,7 @@ function gr(e) {
2657
2668
  ok: !0,
2658
2669
  scope_id: c,
2659
2670
  device_id: l,
2660
- revocation: or({
2671
+ revocation: cr({
2661
2672
  scopeId: c,
2662
2673
  deviceId: l,
2663
2674
  membershipEpoch: n?.membership_epoch ?? d
@@ -2665,7 +2676,7 @@ function gr(e) {
2665
2676
  });
2666
2677
  } catch (t) {
2667
2678
  let n = t instanceof Error ? t.message : String(t);
2668
- return t instanceof N && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
2679
+ return t instanceof P && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
2669
2680
  } finally {
2670
2681
  await v.close();
2671
2682
  }
@@ -2700,7 +2711,7 @@ function gr(e) {
2700
2711
  if (!l) return e.json({ error: "display_name_required" }, 400);
2701
2712
  let u;
2702
2713
  try {
2703
- u = I(l, "display_name");
2714
+ u = R(l, "display_name");
2704
2715
  } catch (t) {
2705
2716
  return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
2706
2717
  }
@@ -2771,16 +2782,16 @@ function gr(e) {
2771
2782
  if (!r.ok) return f(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
2772
2783
  let i = f(e, "admin", !0);
2773
2784
  if (i) return i;
2774
- let a = await p(e, lr);
2785
+ let a = await p(e, dr);
2775
2786
  if (a == null) return e.json({ error: "body_too_large" }, 413);
2776
2787
  let o = m(a);
2777
2788
  if (!o) return e.json({ error: "invalid_json" }, 400);
2778
2789
  if (Object.keys(o).some((e) => e !== "group_id" && e !== "manifest")) return e.json({ error: "completion_manifest_invalid" }, 400);
2779
2790
  let s, c;
2780
2791
  try {
2781
- let e = de([o.group_id])[0];
2792
+ let e = Me([o.group_id])[0];
2782
2793
  if (!e) throw Error("completion_manifest_invalid");
2783
- s = e, c = pe(o.manifest), he(c);
2794
+ s = e, c = Pe(o.manifest), Ie(c);
2784
2795
  } catch {
2785
2796
  return e.json({ error: "completion_manifest_invalid" }, 400);
2786
2797
  }
@@ -2792,7 +2803,7 @@ function gr(e) {
2792
2803
  ...t
2793
2804
  }, t.status === "created" ? 201 : 200);
2794
2805
  } catch (t) {
2795
- if (t instanceof oe) return e.json({ error: t.code }, 409);
2806
+ if (t instanceof Ee) return e.json({ error: t.code }, 409);
2796
2807
  let n = t instanceof Error ? t.message : "completion_manifest_invalid";
2797
2808
  if (n === "group_not_found") return e.json({ error: n }, 404);
2798
2809
  if (n === "group_archived" || n === "completion_manifest_unavailable") return e.json({ error: n }, 409);
@@ -2808,8 +2819,8 @@ function gr(e) {
2808
2819
  if (i) return i;
2809
2820
  let a = String(e.req.query("group_id") ?? "").trim(), o;
2810
2821
  try {
2811
- if (de([a]).length !== 1) throw Error("completion_manifest_invalid");
2812
- o = fe(e.req.query("candidate_ref"));
2822
+ if (Me([a]).length !== 1) throw Error("completion_manifest_invalid");
2823
+ o = Ne(e.req.query("candidate_ref"));
2813
2824
  } catch {
2814
2825
  return e.json({ error: "group_id_and_candidate_ref_required" }, 400);
2815
2826
  }
@@ -2831,7 +2842,7 @@ function gr(e) {
2831
2842
  if (!o || Object.keys(o).some((e) => e !== "group_ids")) return e.json({ error: "completion_query_invalid" }, 400);
2832
2843
  let s;
2833
2844
  try {
2834
- if (s = de(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
2845
+ if (s = Me(o.group_ids), s.length === 0) throw Error("completion_query_invalid");
2835
2846
  } catch {
2836
2847
  return e.json({ error: "completion_query_invalid" }, 400);
2837
2848
  }
@@ -2853,27 +2864,27 @@ function gr(e) {
2853
2864
  if (a == null) return e.json({ error: "body_too_large" }, 413);
2854
2865
  let o = m(a);
2855
2866
  if (!o) return e.json({ error: "invalid_json" }, 400);
2856
- let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, te, C = null, w = null;
2867
+ let s = String(o.group_id ?? "").trim(), c = String(o.policy ?? "auto_admit").trim(), l = String(o.expires_at ?? "").trim(), u = String(o.created_by ?? "").trim() || null, d = String(o.operation_id ?? "").trim() || null, h = String(o.reviewed_project_set_digest ?? "").trim() || null, g = String(o.inviter_actor_id ?? "").trim() || null, _ = String(o.inviter_display_name ?? "").trim() || null, v = String(o.inviter_device_id ?? "").trim() || null, y = String(o.pending_person_id ?? "").trim() || null, ee = String(o.invite_kind ?? o.kind ?? "").trim(), b = String(o.policy_team_id ?? "").trim() || null, x = String(o.target_identity_id ?? "").trim() || null, S = String(o.reviewed_preview_digest ?? "").trim() || null, C, w = null, T = null;
2857
2868
  if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
2858
2869
  if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
2859
2870
  if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
2860
2871
  if (!!d != !!h) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
2861
- let T = ee || (d ? "project_share" : "legacy_enrollment");
2872
+ let E = ee || (d ? "project_share" : "legacy_enrollment");
2862
2873
  if (![
2863
2874
  "legacy_enrollment",
2864
2875
  "project_share",
2865
2876
  "team_member",
2866
2877
  "add_device"
2867
- ].includes(T)) return e.json({ error: "invite_kind_invalid" }, 400);
2868
- if (T === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
2878
+ ].includes(E)) return e.json({ error: "invite_kind_invalid" }, 400);
2879
+ if (E === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
2869
2880
  if (S && !/^[a-f0-9]{64}$/u.test(S)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
2870
- if (T === "team_member" && (!b || !S || x) || T === "add_device" && (!x || !S || b) || !["team_member", "add_device"].includes(T) && (b || x || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2881
+ if (E === "team_member" && (!b || !S || x) || E === "add_device" && (!x || !S || b) || !["team_member", "add_device"].includes(E) && (b || x || S)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2871
2882
  if ([b, x].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
2872
- if (T === "team_member" || T === "add_device") {
2883
+ if (E === "team_member" || E === "add_device") {
2873
2884
  if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
2874
2885
  try {
2875
- te = await it(o.reviewed_intent, {
2876
- target: T === "team_member" ? {
2886
+ C = await Et(o.reviewed_intent, {
2887
+ target: E === "team_member" ? {
2877
2888
  kind: "team_member",
2878
2889
  policyTeamId: String(b)
2879
2890
  } : {
@@ -2883,7 +2894,7 @@ function gr(e) {
2883
2894
  digest: String(S)
2884
2895
  });
2885
2896
  } catch (t) {
2886
- return t instanceof L && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2897
+ return t instanceof z && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2887
2898
  }
2888
2899
  } else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2889
2900
  if (d && !/^share_[a-f0-9]{40}$/u.test(d) || h && !/^[a-f0-9]{64}$/u.test(h)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
@@ -2895,27 +2906,27 @@ function gr(e) {
2895
2906
  y
2896
2907
  ].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
2897
2908
  try {
2898
- if (I(_, "inviter_display_name"), C = Be(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== C.length || (w = o.project_intent.map((e, t) => {
2909
+ if (R(_, "inviter_display_name"), w = ct(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== w.length || (T = o.project_intent.map((e, t) => {
2899
2910
  let n;
2900
2911
  try {
2901
- n = Zn([e])[0];
2912
+ n = er([e])[0];
2902
2913
  } catch {
2903
2914
  throw Error("project_intent_invalid");
2904
2915
  }
2905
- let r = C?.[t];
2916
+ let r = w?.[t];
2906
2917
  if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
2907
2918
  return n;
2908
- }), new Set(w.map((e) => e.canonical_identity)).size !== w.length)) throw Error("project_intent_invalid");
2919
+ }), new Set(T.map((e) => e.canonical_identity)).size !== T.length)) throw Error("project_intent_invalid");
2909
2920
  } catch (t) {
2910
2921
  return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
2911
2922
  }
2912
2923
  }
2913
- let E = n();
2924
+ let D = n();
2914
2925
  try {
2915
- let t = await E.getGroup(s);
2926
+ let t = await D.getGroup(s);
2916
2927
  if (!t) return e.json({ error: "group_not_found" }, 404);
2917
2928
  if (t.archived_at) return e.json({ error: "group_archived" }, 409);
2918
- let n = await E.createInvite({
2929
+ let n = await D.createInvite({
2919
2930
  groupId: s,
2920
2931
  policy: c,
2921
2932
  expiresAt: l,
@@ -2926,13 +2937,13 @@ function gr(e) {
2926
2937
  inviterDisplayName: _,
2927
2938
  inviterDeviceId: v,
2928
2939
  pendingPersonId: y,
2929
- projectSummaries: C,
2930
- projectIntent: w,
2931
- inviteKind: T,
2940
+ projectSummaries: w,
2941
+ projectIntent: T,
2942
+ inviteKind: E,
2932
2943
  policyTeamId: b,
2933
2944
  targetIdentityId: x,
2934
2945
  reviewedPreviewDigest: S,
2935
- reviewedIntent: te
2946
+ reviewedIntent: C
2936
2947
  }), r = {
2937
2948
  v: 1,
2938
2949
  kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
@@ -2945,7 +2956,7 @@ function gr(e) {
2945
2956
  ...n.operation_id ? {
2946
2957
  operation_id: n.operation_id,
2947
2958
  inviter_name: n.inviter_display_name ?? null,
2948
- project_summaries: C ?? []
2959
+ project_summaries: w ?? []
2949
2960
  } : {},
2950
2961
  ...n.invite_kind === "team_member" ? {
2951
2962
  policy_team_id: n.policy_team_id ?? void 0,
@@ -2957,20 +2968,20 @@ function gr(e) {
2957
2968
  inviter_device_id: n.inviter_device_id ?? void 0,
2958
2969
  reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
2959
2970
  } : {}
2960
- }, i = yn(r), { token: a, ...f } = n;
2971
+ }, i = Vn(r), { token: a, ...f } = n;
2961
2972
  return e.json({
2962
2973
  ok: !0,
2963
2974
  invite: f,
2964
2975
  payload: r,
2965
2976
  encoded: i,
2966
- link: xn(i)
2977
+ link: Un(i)
2967
2978
  });
2968
2979
  } catch (t) {
2969
2980
  if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
2970
2981
  if (t instanceof Error && t.message === "invite_already_bound") return e.json({ error: "invite_already_bound" }, 409);
2971
2982
  throw t;
2972
2983
  } finally {
2973
- await E.close();
2984
+ await D.close();
2974
2985
  }
2975
2986
  }), u.post("/v1/invites/inspect", async (e) => {
2976
2987
  let r = await p(e);
@@ -3065,7 +3076,7 @@ function gr(e) {
3065
3076
  display_name: String(e.display_name ?? ""),
3066
3077
  existing_memory_count: Number(e.existing_memory_count ?? 0)
3067
3078
  }));
3068
- s = xn(yn({
3079
+ s = Un(Vn({
3069
3080
  v: 1,
3070
3081
  kind: "coordinator_team_invite",
3071
3082
  coordinator_url: new URL(e.req.url).origin,
@@ -3182,11 +3193,11 @@ function gr(e) {
3182
3193
  } finally {
3183
3194
  await c.close();
3184
3195
  }
3185
- }), u.post("/v1/admin/join-requests/approve", async (e) => _r(e, !0, {
3196
+ }), u.post("/v1/admin/join-requests/approve", async (e) => yr(e, !0, {
3186
3197
  createStore: n,
3187
3198
  runtime: t,
3188
3199
  rateLimitedResponse: f
3189
- })), u.post("/v1/admin/join-requests/deny", async (e) => _r(e, !1, {
3200
+ })), u.post("/v1/admin/join-requests/deny", async (e) => yr(e, !1, {
3190
3201
  createStore: n,
3191
3202
  runtime: t,
3192
3203
  rateLimitedResponse: f
@@ -3210,7 +3221,7 @@ function gr(e) {
3210
3221
  if (!i) return e.json({ error: "invalid_json" }, 400);
3211
3222
  let a = String(i.token ?? "").trim(), o = String(i.device_id ?? "").trim(), s = String(i.fingerprint ?? "").trim(), c = String(i.public_key ?? "").trim(), l = String(i.display_name ?? "").trim() || null, u = String(i.operation_id ?? "").trim(), d = String(i.recipient_actor_id ?? "").trim(), f = String(i.recipient_display_name ?? "").trim(), h = String(i.device_display_name ?? "").trim();
3212
3223
  if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
3213
- if (ot(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
3224
+ if (Ot(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
3214
3225
  let g = n();
3215
3226
  try {
3216
3227
  let n = await g.getInviteByTokenForInspection(a);
@@ -3238,11 +3249,11 @@ function gr(e) {
3238
3249
  try {
3239
3250
  if (i.recipient_display_name != null) {
3240
3251
  if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
3241
- d = I(i.recipient_display_name, "recipient_display_name");
3252
+ d = R(i.recipient_display_name, "recipient_display_name");
3242
3253
  }
3243
3254
  if (i.device_display_name != null) {
3244
3255
  if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
3245
- f = I(i.device_display_name, "device_display_name");
3256
+ f = at(i.device_display_name, "device_display_name");
3246
3257
  }
3247
3258
  } catch (t) {
3248
3259
  return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
@@ -3297,7 +3308,7 @@ function gr(e) {
3297
3308
  if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
3298
3309
  let l, p;
3299
3310
  try {
3300
- l = I(f, "recipient_display_name"), p = I(h, "device_display_name");
3311
+ l = R(f, "recipient_display_name"), p = at(h, "device_display_name");
3301
3312
  } catch (t) {
3302
3313
  return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
3303
3314
  }
@@ -3321,7 +3332,7 @@ function gr(e) {
3321
3332
  });
3322
3333
  return e.json({
3323
3334
  ok: !0,
3324
- status: Cn,
3335
+ status: Gn,
3325
3336
  group_id: n.invite.group_id,
3326
3337
  operation_id: n.invite.operation_id,
3327
3338
  trust_state: n.invite.trust_state,
@@ -3390,14 +3401,14 @@ function gr(e) {
3390
3401
  }
3391
3402
  }), u;
3392
3403
  }
3393
- async function _r(e, t, n) {
3404
+ async function yr(e, t, n) {
3394
3405
  let r = Z(e.req.header(X), n.runtime);
3395
3406
  if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
3396
3407
  let i = n.rateLimitedResponse(e, "admin", !0);
3397
3408
  if (i) return i;
3398
3409
  let a = await (async () => {
3399
3410
  let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
3400
- if (Number.isFinite(t) && t > cr) return null;
3411
+ if (Number.isFinite(t) && t > ur) return null;
3401
3412
  let n = e.req.raw.body;
3402
3413
  if (!n) return /* @__PURE__ */ new Uint8Array();
3403
3414
  let r = n.getReader(), i = [], a = 0;
@@ -3406,7 +3417,7 @@ async function _r(e, t, n) {
3406
3417
  let { done: e, value: t } = await r.read();
3407
3418
  if (e) break;
3408
3419
  if (t) {
3409
- if (a += t.byteLength, a > cr) return await r.cancel(), null;
3420
+ if (a += t.byteLength, a > ur) return await r.cancel(), null;
3410
3421
  i.push(t);
3411
3422
  }
3412
3423
  }
@@ -3454,6 +3465,6 @@ async function _r(e, t, n) {
3454
3465
  }
3455
3466
  }
3456
3467
  //#endregion
3457
- export { E as $, at as A, ke as B, Sn as C, g as Ct, L as D, n as Dt, Ve as E, i as Et, Re as F, Ce as G, Te as H, I, be as J, xe as K, F as L, it as M, ze as N, nt as O, Le as P, ie as Q, Be as R, yn as S, te as St, ot as T, a as Tt, Oe as U, De as V, N as W, ae as X, Se as Y, ne as Z, wn as _, _ as _t, ar as a, fe as at, Dn as b, x as bt, Zn as c, ge as ct, jn as d, v as dt, w as et, In as f, h as ft, Cn as g, u as gt, q as h, l as ht, or as i, me as it, rt as j, tt as k, Yn as l, _e as lt, Kn as m, S as mt, sr as n, C as nt, qn as o, de as ot, Gn as p, o as pt, we as q, ir as r, oe as rt, Xn as s, pe as st, gr as t, T as tt, Mn as u, he as ut, Tn as v, y as vt, xn as w, r as wt, bn as x, ee as xt, En as y, b as yt, Ae as z };
3468
+ export { Ne as $, R as A, He as B, Ct as C, o as Ct, st as D, a as Dt, Et as E, S as Et, Je as F, Se as G, Ve as H, Ke as I, ye as J, we as K, Ye as L, ct as M, Ze as N, L as O, Xe as P, Fe as Q, P as R, wt as S, s as St, Tt as T, x as Tt, Ue as U, Ge as V, Te as W, ve as X, be as Y, Ee as Z, Wn as _, le as _t, sr as a, de as at, lt as b, T as bt, er as c, ge as ct, Kn as d, ue as dt, Me as et, qn as f, fe as ft, Vn as g, _e as gt, Hn as h, pe as ht, cr as i, Ie as it, I as j, ot as k, Qn as l, re as lt, Yn as m, he as mt, lr as n, Le as nt, Xn as o, ce as ot, Jn as p, me as pt, xe as q, or as r, Re as rt, $n as s, D as st, vr as t, Pe as tt, Gn as u, ie as ut, Un as v, w as vt, Dt as w, p as wt, z as x, C as xt, Ot as y, E as yt, We as z };
3458
3469
 
3459
- //# sourceMappingURL=coordinator-api-BAufmPEa.js.map
3470
+ //# sourceMappingURL=coordinator-api-C2ckGC2b.js.map