@codemem/core 0.42.0 → 0.43.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/better-sqlite-coordinator-store.d.ts.map +1 -1
  2. package/dist/coordinator-actions.d.ts +2 -0
  3. package/dist/coordinator-actions.d.ts.map +1 -1
  4. package/dist/{coordinator-api-SeLosPIq.js → coordinator-api-DGTIU3Ri.js} +394 -385
  5. package/dist/coordinator-api-DGTIU3Ri.js.map +1 -0
  6. package/dist/coordinator-api.d.ts.map +1 -1
  7. package/dist/coordinator-enrollment-reconciler.d.ts +1 -0
  8. package/dist/coordinator-enrollment-reconciler.d.ts.map +1 -1
  9. package/dist/coordinator-runtime.d.ts +2 -1
  10. package/dist/coordinator-runtime.d.ts.map +1 -1
  11. package/dist/coordinator-store-contract.d.ts +7 -0
  12. package/dist/coordinator-store-contract.d.ts.map +1 -1
  13. package/dist/coordinator-store-test-harness.d.ts.map +1 -1
  14. package/dist/coordinator-store.d.ts +1 -0
  15. package/dist/coordinator-store.d.ts.map +1 -1
  16. package/dist/d1-coordinator-store.d.ts.map +1 -1
  17. package/dist/db.d.ts +1 -1
  18. package/dist/db.d.ts.map +1 -1
  19. package/dist/device-identity-binding.d.ts.map +1 -1
  20. package/dist/identity-device-assignment.d.ts +40 -0
  21. package/dist/identity-device-assignment.d.ts.map +1 -0
  22. package/dist/index.d.ts +10 -4
  23. package/dist/index.d.ts.map +1 -1
  24. package/dist/index.js +9885 -7727
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal/cloudflare-coordinator.js +317 -312
  27. package/dist/internal/cloudflare-coordinator.js.map +1 -1
  28. package/dist/legacy-recipient-policy-projection.d.ts +31 -0
  29. package/dist/legacy-recipient-policy-projection.d.ts.map +1 -1
  30. package/dist/legacy-team-assignment-expectation.d.ts +8 -0
  31. package/dist/legacy-team-assignment-expectation.d.ts.map +1 -0
  32. package/dist/legacy-team-candidate.d.ts +61 -0
  33. package/dist/legacy-team-candidate.d.ts.map +1 -0
  34. package/dist/legacy-team-project-canonical-preflight.d.ts +36 -0
  35. package/dist/legacy-team-project-canonical-preflight.d.ts.map +1 -0
  36. package/dist/legacy-team-setup-activation.d.ts +44 -0
  37. package/dist/legacy-team-setup-activation.d.ts.map +1 -0
  38. package/dist/legacy-team-setup-attempt.d.ts +10 -0
  39. package/dist/legacy-team-setup-attempt.d.ts.map +1 -0
  40. package/dist/legacy-team-setup-draft.d.ts +118 -0
  41. package/dist/legacy-team-setup-draft.d.ts.map +1 -0
  42. package/dist/legacy-team-setup-errors.d.ts +34 -0
  43. package/dist/legacy-team-setup-errors.d.ts.map +1 -0
  44. package/dist/legacy-team-setup-limits.d.ts +11 -0
  45. package/dist/legacy-team-setup-limits.d.ts.map +1 -0
  46. package/dist/policy-team-device-eligibility.d.ts.map +1 -1
  47. package/dist/project-scope-settings.d.ts +3 -0
  48. package/dist/project-scope-settings.d.ts.map +1 -1
  49. package/dist/recipient-policy-actor-eligibility.d.ts +12 -0
  50. package/dist/recipient-policy-actor-eligibility.d.ts.map +1 -0
  51. package/dist/recipient-policy-contract.d.ts +52 -0
  52. package/dist/recipient-policy-contract.d.ts.map +1 -1
  53. package/dist/recipient-policy-edges.d.ts.map +1 -1
  54. package/dist/recipient-policy-identifiers.d.ts +41 -0
  55. package/dist/recipient-policy-identifiers.d.ts.map +1 -0
  56. package/dist/recipient-policy-migration.d.ts +13 -1
  57. package/dist/recipient-policy-migration.d.ts.map +1 -1
  58. package/dist/recipient-policy-onboarding.d.ts.map +1 -1
  59. package/dist/recipient-policy-reconciler.d.ts.map +1 -1
  60. package/dist/recipient-policy-reconciliation.d.ts +2 -0
  61. package/dist/recipient-policy-reconciliation.d.ts.map +1 -1
  62. package/dist/recipient-policy-review.d.ts +17 -0
  63. package/dist/recipient-policy-review.d.ts.map +1 -1
  64. package/dist/schema-bootstrap.d.ts +1 -0
  65. package/dist/schema-bootstrap.d.ts.map +1 -1
  66. package/dist/schema.d.ts +4912 -3150
  67. package/dist/schema.d.ts.map +1 -1
  68. package/dist/team-ownership-transitions.d.ts +22 -0
  69. package/dist/team-ownership-transitions.d.ts.map +1 -0
  70. package/dist/test-schema.generated.d.ts +1 -1
  71. package/dist/test-schema.generated.d.ts.map +1 -1
  72. package/package.json +1 -1
  73. package/dist/coordinator-api-SeLosPIq.js.map +0 -1
@@ -81,51 +81,54 @@ function p(e) {
81
81
  function m(e) {
82
82
  return String(e.kind === "team_member" ? e.assigned_identity_id ?? "" : e.target_identity_id ?? "").trim();
83
83
  }
84
- //#endregion
85
- //#region src/project-invite-identity.ts
86
- var h = 120, g = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, _ = /^(?:actor|device|identity|local):\S+$/iu, v = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, y = /^pending[_-]\S+$/iu, b = /^[a-f0-9]{12,64}$/iu;
87
- function x(e, t) {
84
+ var h = "reciprocal_approval_request_changed", g = class extends Error {
85
+ code = h;
86
+ constructor() {
87
+ super(h), this.name = "CoordinatorReciprocalApprovalRequestChangedError";
88
+ }
89
+ }, _ = 120, v = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/iu, y = /^(?:actor|device|identity|local):\S+$/iu, b = /^(?:actor|device|identity)[_-][a-z0-9][a-z0-9._:-]{4,}$/iu, x = /^pending[_-]\S+$/iu, S = /^[a-f0-9]{12,64}$/iu;
90
+ function C(e, t) {
88
91
  if ([...e].some((e) => /[\p{Cc}\p{Cf}]/u.test(e))) throw Error(`${t}_invalid`);
89
92
  let n = e.replace(/\s+/gu, " ").trim();
90
93
  if (!n) throw Error(`${t}_required`);
91
- if ([...n].length > h) throw Error(`${t}_too_long`);
94
+ if ([...n].length > _) throw Error(`${t}_too_long`);
92
95
  return n;
93
96
  }
94
- function S(e) {
97
+ function w(e) {
95
98
  if (typeof e != "string") return !1;
96
99
  let t;
97
100
  try {
98
- t = x(e, "display_name");
101
+ t = C(e, "display_name");
99
102
  } catch {
100
103
  return !1;
101
104
  }
102
105
  return ![
103
- g,
104
- _,
105
106
  v,
106
107
  y,
107
- b
108
+ b,
109
+ x,
110
+ S
108
111
  ].some((e) => e.test(t));
109
112
  }
110
- function C(e, t) {
111
- let n = x(e, t);
112
- if (!S(n)) throw Error(`${t}_invalid`);
113
+ function T(e, t) {
114
+ let n = C(e, t);
115
+ if (!w(n)) throw Error(`${t}_invalid`);
113
116
  return n;
114
117
  }
115
- function w(e) {
118
+ function E(e) {
116
119
  let t = String(e ?? "").replace(/\.local$/iu, "");
117
- return t.trim() ? x(t.replace(/[-_]+/gu, " "), "device_display_name") : null;
120
+ return t.trim() ? C(t.replace(/[-_]+/gu, " "), "device_display_name") : null;
118
121
  }
119
- function T(e) {
122
+ function D(e) {
120
123
  for (let t of [
121
124
  e.explicitName,
122
125
  e.osName,
123
126
  e.coordinatorName
124
127
  ]) {
125
128
  let e = String(t ?? "").replace(/\.local$/iu, "").trim();
126
- if (!(!e || !S(e))) try {
127
- let e = w(t);
128
- if (e && S(e)) return e;
129
+ if (!(!e || !w(e))) try {
130
+ let e = E(t);
131
+ if (e && w(e)) return e;
129
132
  } catch {}
130
133
  }
131
134
  let t = String(e.fallbackSeed ?? "").replace(/[^a-z0-9]/giu, "").slice(0, 6);
@@ -138,21 +141,21 @@ function ee(e) {
138
141
  let t = e;
139
142
  if (!Number.isSafeInteger(t.existing_memory_count) || Number(t.existing_memory_count) < 0) throw Error("project_summaries_invalid");
140
143
  return {
141
- display_name: x(String(t.display_name ?? ""), "project_name"),
144
+ display_name: C(String(t.display_name ?? ""), "project_name"),
142
145
  existing_memory_count: Number(t.existing_memory_count)
143
146
  };
144
147
  });
145
148
  }
146
149
  //#endregion
147
150
  //#region src/recipient-reviewed-intent.ts
148
- var E = 1, D = class extends Error {
151
+ var O = 1, k = class extends Error {
149
152
  code;
150
153
  constructor(e) {
151
154
  super(e), this.name = "RecipientReviewedIntentError", this.code = e;
152
155
  }
153
- }, O = /[\p{Cc}\p{Cf}]/u, k = 100, A = 64 * 1024;
156
+ }, A = /[\p{Cc}\p{Cf}]/u, te = 100, ne = 64 * 1024;
154
157
  function j() {
155
- throw new D("recipient_reviewed_intent_invalid");
158
+ throw new k("recipient_reviewed_intent_invalid");
156
159
  }
157
160
  function M(e) {
158
161
  return (!e || typeof e != "object" || Array.isArray(e)) && j(), e;
@@ -161,31 +164,31 @@ function N(e, t) {
161
164
  Object.keys(e).some((e) => !t.includes(e)) && j();
162
165
  }
163
166
  function P(e, t) {
164
- return (typeof e != "string" || !e || e !== e.trim() || e.length > t || O.test(e)) && j(), e;
167
+ return (typeof e != "string" || !e || e !== e.trim() || e.length > t || A.test(e)) && j(), e;
165
168
  }
166
- function te(e) {
167
- (typeof e != "string" || O.test(e)) && j();
169
+ function re(e) {
170
+ (typeof e != "string" || A.test(e)) && j();
168
171
  let t = e.trim().replace(/\s+/gu, " ");
169
172
  return (!t || t.length > 256) && j(), t;
170
173
  }
171
- function ne(e) {
174
+ function ie(e) {
172
175
  typeof e != "string" && j();
173
176
  try {
174
- return x(e, "identity_display_name");
177
+ return C(e, "identity_display_name");
175
178
  } catch {
176
179
  return j();
177
180
  }
178
181
  }
179
- function re(e) {
182
+ function ae(e) {
180
183
  return (typeof e != "number" || !Number.isSafeInteger(e) || e < 0) && j(), e;
181
184
  }
182
- function ie(e, t) {
185
+ function oe(e, t) {
183
186
  return e < t ? -1 : +(e > t);
184
187
  }
185
- function ae(e) {
188
+ function se(e) {
186
189
  return e.kind === "direct" ? "direct" : `team\u0000${e.teamId}`;
187
190
  }
188
- function oe(e) {
191
+ function ce(e) {
189
192
  let t = M(e);
190
193
  return t.kind === "direct" ? (N(t, ["kind"]), { kind: "direct" }) : (t.kind !== "team" && j(), N(t, [
191
194
  "kind",
@@ -194,10 +197,10 @@ function oe(e) {
194
197
  ]), {
195
198
  kind: "team",
196
199
  teamId: P(t.teamId, 256),
197
- displayName: te(t.displayName)
200
+ displayName: re(t.displayName)
198
201
  });
199
202
  }
200
- function se(e) {
203
+ function le(e) {
201
204
  let t = M(e);
202
205
  N(t, [
203
206
  "canonicalProjectIdentity",
@@ -206,16 +209,16 @@ function se(e) {
206
209
  "futureMemoriesShared",
207
210
  "sources"
208
211
  ]), (t.futureMemoriesShared !== !0 || !Array.isArray(t.sources) || !t.sources.length) && j();
209
- let n = t.sources.map(oe).toSorted((e, t) => ie(ae(e), ae(t)));
210
- return new Set(n.map(ae)).size !== n.length && j(), {
212
+ let n = t.sources.map(ce).toSorted((e, t) => oe(se(e), se(t)));
213
+ return new Set(n.map(se)).size !== n.length && j(), {
211
214
  canonicalProjectIdentity: P(t.canonicalProjectIdentity, 512),
212
- displayName: te(t.displayName),
213
- existingMemoryCount: re(t.existingMemoryCount),
215
+ displayName: re(t.displayName),
216
+ existingMemoryCount: ae(t.existingMemoryCount),
214
217
  futureMemoriesShared: !0,
215
218
  sources: n
216
219
  };
217
220
  }
218
- function ce(e) {
221
+ function ue(e) {
219
222
  let t = M(e);
220
223
  return N(t, [
221
224
  "canonicalProjectIdentity",
@@ -223,25 +226,25 @@ function ce(e) {
223
226
  "existingMemoryCount"
224
227
  ]), {
225
228
  canonicalProjectIdentity: P(t.canonicalProjectIdentity, 512),
226
- displayName: te(t.displayName),
227
- existingMemoryCount: re(t.existingMemoryCount)
229
+ displayName: re(t.displayName),
230
+ existingMemoryCount: ae(t.existingMemoryCount)
228
231
  };
229
232
  }
230
- function le(e) {
231
- (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > k) && j();
232
- let t = e.projects.map(se).toSorted((e, t) => ie(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(ce).toSorted((e, t) => ie(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
233
+ function de(e) {
234
+ (!Array.isArray(e.projects) || !Array.isArray(e.excludedProjects) || e.projects.length > te) && j();
235
+ let t = e.projects.map(le).toSorted((e, t) => oe(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), n = e.excludedProjects.map(ue).toSorted((e, t) => oe(e.canonicalProjectIdentity, t.canonicalProjectIdentity)), r = t.map((e) => e.canonicalProjectIdentity), i = n.map((e) => e.canonicalProjectIdentity);
233
236
  return (new Set(r).size !== r.length || new Set(i).size !== i.length || i.some((e) => r.includes(e))) && j(), {
234
237
  projects: t,
235
238
  excludedProjects: n
236
239
  };
237
240
  }
238
- function ue(e, t) {
239
- 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 D("recipient_invite_intent_mismatch");
241
+ function fe(e, t) {
242
+ 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 k("recipient_invite_intent_mismatch");
240
243
  }
241
- function F(e, t) {
244
+ function pe(e, t) {
242
245
  let n = M(e);
243
246
  n.version !== 1 && j();
244
- let r = le(n), i;
247
+ let r = de(n), i;
245
248
  if (n.journey === "team") {
246
249
  N(n, [
247
250
  "version",
@@ -260,7 +263,7 @@ function F(e, t) {
260
263
  journey: "team",
261
264
  team: {
262
265
  teamId: P(e.teamId, 256),
263
- displayName: te(e.displayName),
266
+ displayName: re(e.displayName),
264
267
  futureProjectsInherit: !0
265
268
  },
266
269
  ...r
@@ -279,29 +282,29 @@ function F(e, t) {
279
282
  journey: "add_device",
280
283
  targetIdentity: {
281
284
  identityId: P(e.identityId, 256),
282
- displayName: ne(e.displayName)
285
+ displayName: ie(e.displayName)
283
286
  },
284
287
  ...r
285
288
  };
286
289
  } else j();
287
- return t && ue(i, t), new TextEncoder().encode(I(i)).byteLength > A && j(), i;
290
+ return t && fe(i, t), new TextEncoder().encode(F(i)).byteLength > ne && j(), i;
288
291
  }
289
- function I(e) {
290
- return Array.isArray(e) ? `[${e.map(I).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => ie(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${I(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
292
+ function F(e) {
293
+ return Array.isArray(e) ? `[${e.map(F).join(",")}]` : e && typeof e == "object" ? `{${Object.entries(e).toSorted(([e], [t]) => oe(e, t)).map(([e, t]) => `${JSON.stringify(e)}:${F(t)}`).join(",")}}` : JSON.stringify(e) ?? "null";
291
294
  }
292
- function de(e, t) {
293
- return I(F(e, t));
295
+ function me(e, t) {
296
+ return F(pe(e, t));
294
297
  }
295
- async function fe(e, t) {
296
- let n = de(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
298
+ async function he(e, t) {
299
+ let n = me(e, t), r = new TextEncoder().encode(`recipient-reviewed-intent-v1\n${n}`), i = await globalThis.crypto.subtle.digest("SHA-256", r);
297
300
  return Array.from(new Uint8Array(i), (e) => e.toString(16).padStart(2, "0")).join("");
298
301
  }
299
- async function L(e, t) {
300
- let n = F(e, t.target);
301
- if (await fe(n) !== t.digest) throw new D("recipient_invite_intent_mismatch");
302
+ async function ge(e, t) {
303
+ let n = pe(e, t.target);
304
+ if (await he(n) !== t.digest) throw new k("recipient_invite_intent_mismatch");
302
305
  return n;
303
306
  }
304
- async function pe(e, t) {
307
+ async function _e(e, t) {
305
308
  if (!e) throw Error("recipient_invite_review_unavailable");
306
309
  let n;
307
310
  try {
@@ -310,21 +313,21 @@ async function pe(e, t) {
310
313
  throw Error("recipient_invite_review_unavailable");
311
314
  }
312
315
  try {
313
- let r = F(n, t.target);
314
- if (I(r) !== e) throw Error("recipient_invite_review_unavailable");
315
- return await L(r, t);
316
+ let r = pe(n, t.target);
317
+ if (F(r) !== e) throw Error("recipient_invite_review_unavailable");
318
+ return await ge(r, t);
316
319
  } catch (e) {
317
- throw e instanceof D && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
320
+ throw e instanceof k && e.code === "recipient_invite_intent_mismatch" || e instanceof Error && e.message === "recipient_invite_review_unavailable" ? e : Error("recipient_invite_review_unavailable");
318
321
  }
319
322
  }
320
323
  //#endregion
321
324
  //#region src/sync-fingerprint.ts
322
- function me(e) {
325
+ function ve(e) {
323
326
  return t("sha256").update(e, "utf-8").digest("hex");
324
327
  }
325
328
  //#endregion
326
329
  //#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/compose.js
327
- var he = (e, t, n) => (r, i) => {
330
+ var ye = (e, t, n) => (r, i) => {
328
331
  let a = -1;
329
332
  return o(0);
330
333
  async function o(s) {
@@ -340,40 +343,40 @@ var he = (e, t, n) => (r, i) => {
340
343
  else r.finalized === !1 && n && (c = await n(r));
341
344
  return c && (r.finalized === !1 || l) && (r.res = c), r;
342
345
  }
343
- }, ge = /* @__PURE__ */ Symbol(), _e = async (e, t = /* @__PURE__ */ Object.create(null)) => {
344
- let { all: n = !1, dot: r = !1 } = t, i = (e instanceof Re ? e.raw.headers : e.headers).get("Content-Type");
345
- return i?.startsWith("multipart/form-data") || i?.startsWith("application/x-www-form-urlencoded") ? ve(e, {
346
+ }, be = /* @__PURE__ */ Symbol(), xe = async (e, t = /* @__PURE__ */ Object.create(null)) => {
347
+ let { all: n = !1, dot: r = !1 } = t, i = (e instanceof He ? e.raw.headers : e.headers).get("Content-Type");
348
+ return i?.startsWith("multipart/form-data") || i?.startsWith("application/x-www-form-urlencoded") ? Se(e, {
346
349
  all: n,
347
350
  dot: r
348
351
  }) : {};
349
352
  };
350
- async function ve(e, t) {
353
+ async function Se(e, t) {
351
354
  let n = await e.formData();
352
- return n ? ye(n, t) : {};
355
+ return n ? Ce(n, t) : {};
353
356
  }
354
- function ye(e, t) {
357
+ function Ce(e, t) {
355
358
  let n = /* @__PURE__ */ Object.create(null);
356
359
  return e.forEach((e, r) => {
357
- t.all || r.endsWith("[]") ? be(n, r, e) : n[r] = e;
360
+ t.all || r.endsWith("[]") ? we(n, r, e) : n[r] = e;
358
361
  }), t.dot && Object.entries(n).forEach(([e, t]) => {
359
- e.includes(".") && (xe(n, e, t), delete n[e]);
362
+ e.includes(".") && (Te(n, e, t), delete n[e]);
360
363
  }), n;
361
364
  }
362
- var be = (e, t, n) => {
365
+ var we = (e, t, n) => {
363
366
  e[t] === void 0 ? t.endsWith("[]") ? e[t] = [n] : e[t] = n : Array.isArray(e[t]) ? e[t].push(n) : e[t] = [e[t], n];
364
- }, xe = (e, t, n) => {
367
+ }, Te = (e, t, n) => {
365
368
  if (/(?:^|\.)__proto__\./.test(t)) return;
366
369
  let r = e, i = t.split(".");
367
370
  i.forEach((e, t) => {
368
371
  t === i.length - 1 ? r[e] = n : ((!r[e] || typeof r[e] != "object" || Array.isArray(r[e]) || r[e] instanceof File) && (r[e] = /* @__PURE__ */ Object.create(null)), r = r[e]);
369
372
  });
370
- }, Se = (e) => {
373
+ }, Ee = (e) => {
371
374
  let t = e.split("/");
372
375
  return t[0] === "" && t.shift(), t;
373
- }, Ce = (e) => {
374
- let { groups: t, path: n } = we(e);
375
- return Te(Se(n), t);
376
- }, we = (e) => {
376
+ }, De = (e) => {
377
+ let { groups: t, path: n } = Oe(e);
378
+ return ke(Ee(n), t);
379
+ }, Oe = (e) => {
377
380
  let t = [];
378
381
  return e = e.replace(/\{[^}]+\}/g, (e, n) => {
379
382
  let r = `@${n}`;
@@ -382,7 +385,7 @@ var be = (e, t, n) => {
382
385
  groups: t,
383
386
  path: e
384
387
  };
385
- }, Te = (e, t) => {
388
+ }, ke = (e, t) => {
386
389
  for (let n = t.length - 1; n >= 0; n--) {
387
390
  let [r] = t[n];
388
391
  for (let i = e.length - 1; i >= 0; i--) if (e[i].includes(r)) {
@@ -391,12 +394,12 @@ var be = (e, t, n) => {
391
394
  }
392
395
  }
393
396
  return e;
394
- }, R = {}, Ee = (e, t) => {
397
+ }, I = {}, Ae = (e, t) => {
395
398
  if (e === "*") return "*";
396
399
  let n = e.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
397
400
  if (n) {
398
401
  let r = `${e}#${t}`;
399
- return R[r] || (n[2] ? R[r] = t && t[0] !== ":" && t[0] !== "*" ? [
402
+ return I[r] || (n[2] ? I[r] = t && t[0] !== ":" && t[0] !== "*" ? [
400
403
  r,
401
404
  n[1],
402
405
  RegExp(`^${n[2]}(?=/${t})`)
@@ -404,14 +407,14 @@ var be = (e, t, n) => {
404
407
  e,
405
408
  n[1],
406
409
  RegExp(`^${n[2]}$`)
407
- ] : R[r] = [
410
+ ] : I[r] = [
408
411
  e,
409
412
  n[1],
410
413
  !0
411
- ]), R[r];
414
+ ]), I[r];
412
415
  }
413
416
  return null;
414
- }, De = (e, t) => {
417
+ }, je = (e, t) => {
415
418
  try {
416
419
  return t(e);
417
420
  } catch {
@@ -423,20 +426,20 @@ var be = (e, t, n) => {
423
426
  }
424
427
  });
425
428
  }
426
- }, Oe = (e) => De(e, decodeURI), ke = (e) => {
429
+ }, Me = (e) => je(e, decodeURI), Ne = (e) => {
427
430
  let t = e.url, n = t.indexOf("/", t.indexOf(":") + 4), r = n;
428
431
  for (; r < t.length; r++) {
429
432
  let e = t.charCodeAt(r);
430
433
  if (e === 37) {
431
434
  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);
432
- return Oe(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
435
+ return Me(o.includes("%25") ? o.replace(/%25/g, "%2525") : o);
433
436
  } else if (e === 63 || e === 35) break;
434
437
  }
435
438
  return t.slice(n, r);
436
- }, Ae = (e) => {
437
- let t = ke(e);
439
+ }, Pe = (e) => {
440
+ let t = Ne(e);
438
441
  return t.length > 1 && t.at(-1) === "/" ? t.slice(0, -1) : t;
439
- }, z = (e, t, ...n) => (n.length && (t = z(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), je = (e) => {
442
+ }, L = (e, t, ...n) => (n.length && (t = L(t, ...n)), `${e?.[0] === "/" ? "" : "/"}${e}${t === "/" ? "" : `${e?.at(-1) === "/" ? "" : "/"}${t?.[0] === "/" ? t.slice(1) : t}`}`), Fe = (e) => {
440
443
  if (e.charCodeAt(e.length - 1) !== 63 || !e.includes(":")) return null;
441
444
  let t = e.split("/"), n = [], r = "";
442
445
  return t.forEach((e) => {
@@ -447,7 +450,7 @@ var be = (e, t, n) => {
447
450
  r += "/" + t, n.push(r);
448
451
  } else r += "/" + e;
449
452
  }), n.filter((e, t, n) => n.indexOf(e) === t);
450
- }, Me = (e) => /[%+]/.test(e) ? (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), e.indexOf("%") === -1 ? e : De(e, Ie)) : e, Ne = (e, t, n) => {
453
+ }, Ie = (e) => /[%+]/.test(e) ? (e.indexOf("+") !== -1 && (e = e.replace(/\+/g, " ")), e.indexOf("%") === -1 ? e : je(e, Be)) : e, Le = (e, t, n) => {
451
454
  let r;
452
455
  if (!n && t && !/[%+]/.test(t)) {
453
456
  let n = e.indexOf("?", 8);
@@ -456,7 +459,7 @@ var be = (e, t, n) => {
456
459
  let r = e.charCodeAt(n + t.length + 1);
457
460
  if (r === 61) {
458
461
  let r = n + t.length + 2, i = e.indexOf("&", r);
459
- return Me(e.slice(r, i === -1 ? void 0 : i));
462
+ return Ie(e.slice(r, i === -1 ? void 0 : i));
460
463
  } else if (r == 38 || isNaN(r)) return "";
461
464
  n = e.indexOf(`&${t}`, n + 1);
462
465
  }
@@ -469,12 +472,12 @@ var be = (e, t, n) => {
469
472
  let t = e.indexOf("&", a + 1), o = e.indexOf("=", a);
470
473
  o > t && t !== -1 && (o = -1);
471
474
  let s = e.slice(a + 1, o === -1 ? t === -1 ? void 0 : t : o);
472
- if (r && (s = Me(s)), a = t, s === "") continue;
475
+ if (r && (s = Ie(s)), a = t, s === "") continue;
473
476
  let c;
474
- o === -1 ? c = "" : (c = e.slice(o + 1, t === -1 ? void 0 : t), r && (c = Me(c))), n ? (i[s] && Array.isArray(i[s]) || (i[s] = []), i[s].push(c)) : i[s] ??= c;
477
+ o === -1 ? c = "" : (c = e.slice(o + 1, t === -1 ? void 0 : t), r && (c = Ie(c))), n ? (i[s] && Array.isArray(i[s]) || (i[s] = []), i[s].push(c)) : i[s] ??= c;
475
478
  }
476
479
  return t ? i[t] : i;
477
- }, Pe = Ne, Fe = (e, t) => Ne(e, t, !0), Ie = decodeURIComponent, Le = (e) => De(e, Ie), Re = class {
480
+ }, Re = Le, ze = (e, t) => Le(e, t, !0), Be = decodeURIComponent, Ve = (e) => je(e, Be), He = class {
478
481
  raw;
479
482
  #e;
480
483
  #t;
@@ -489,13 +492,13 @@ var be = (e, t, n) => {
489
492
  }
490
493
  #n(e) {
491
494
  let t = this.#t[0][this.routeIndex][1][e], n = this.#i(t);
492
- return n && /\%/.test(n) ? Le(n) : n;
495
+ return n && /\%/.test(n) ? Ve(n) : n;
493
496
  }
494
497
  #r() {
495
498
  let e = {}, t = Object.keys(this.#t[0][this.routeIndex][1]);
496
499
  for (let n of t) {
497
500
  let t = this.#i(this.#t[0][this.routeIndex][1][n]);
498
- t !== void 0 && (e[n] = /\%/.test(t) ? Le(t) : t);
501
+ t !== void 0 && (e[n] = /\%/.test(t) ? Ve(t) : t);
499
502
  }
500
503
  return e;
501
504
  }
@@ -503,10 +506,10 @@ var be = (e, t, n) => {
503
506
  return this.#t[1] ? this.#t[1][e] : e;
504
507
  }
505
508
  query(e) {
506
- return Pe(this.url, e);
509
+ return Re(this.url, e);
507
510
  }
508
511
  queries(e) {
509
- return Fe(this.url, e);
512
+ return ze(this.url, e);
510
513
  }
511
514
  header(e) {
512
515
  if (e) return this.raw.headers.get(e) ?? void 0;
@@ -516,7 +519,7 @@ var be = (e, t, n) => {
516
519
  }), t;
517
520
  }
518
521
  async parseBody(e) {
519
- return _e(this, e);
522
+ return xe(this, e);
520
523
  }
521
524
  #a = (e) => {
522
525
  let { bodyCache: t, raw: n } = this, r = t[e];
@@ -554,7 +557,7 @@ var be = (e, t, n) => {
554
557
  get method() {
555
558
  return this.raw.method;
556
559
  }
557
- get [ge]() {
560
+ get [be]() {
558
561
  return this.#t;
559
562
  }
560
563
  get matchedRoutes() {
@@ -563,14 +566,14 @@ var be = (e, t, n) => {
563
566
  get routePath() {
564
567
  return this.#t[0].map(([[, e]]) => e)[this.routeIndex].path;
565
568
  }
566
- }, ze = {
569
+ }, Ue = {
567
570
  Stringify: 1,
568
571
  BeforeStream: 2,
569
572
  Stream: 3
570
- }, Be = (e, t) => {
573
+ }, We = (e, t) => {
571
574
  let n = new String(e);
572
575
  return n.isEscaped = !0, n.callbacks = t, n;
573
- }, Ve = async (e, t, n, r, i) => {
576
+ }, Ge = async (e, t, n, r, i) => {
574
577
  typeof e == "object" && !(e instanceof String) && (e instanceof Promise || (e = e.toString()), e instanceof Promise && (e = await e));
575
578
  let a = e.callbacks;
576
579
  if (!a?.length) return Promise.resolve(e);
@@ -579,12 +582,12 @@ var be = (e, t, n) => {
579
582
  phase: t,
580
583
  buffer: i,
581
584
  context: r
582
- }))).then((e) => Promise.all(e.filter(Boolean).map((e) => Ve(e, t, !1, r, i))).then(() => i[0]));
583
- return n ? Be(await o, a) : o;
584
- }, He = "text/plain; charset=UTF-8", Ue = (e, t) => ({
585
+ }))).then((e) => Promise.all(e.filter(Boolean).map((e) => Ge(e, t, !1, r, i))).then(() => i[0]));
586
+ return n ? We(await o, a) : o;
587
+ }, Ke = "text/plain; charset=UTF-8", qe = (e, t) => ({
585
588
  "Content-Type": e,
586
589
  ...t
587
- }), B = (e, t) => new Response(e, t), We = class {
590
+ }), R = (e, t) => new Response(e, t), Je = class {
588
591
  #e;
589
592
  #t;
590
593
  env = {};
@@ -604,7 +607,7 @@ var be = (e, t, n) => {
604
607
  this.#e = e, t && (this.#i = t.executionCtx, this.env = t.env, this.#c = t.notFoundHandler, this.#d = t.path, this.#u = t.matchResult);
605
608
  }
606
609
  get req() {
607
- return this.#t ??= new Re(this.#e, this.#d, this.#u), this.#t;
610
+ return this.#t ??= new He(this.#e, this.#d, this.#u), this.#t;
608
611
  }
609
612
  get event() {
610
613
  if (this.#i && "respondWith" in this.#i) return this.#i;
@@ -615,11 +618,11 @@ var be = (e, t, n) => {
615
618
  throw Error("This context has no ExecutionContext");
616
619
  }
617
620
  get res() {
618
- return this.#a ||= B(null, { headers: this.#l ??= new Headers() });
621
+ return this.#a ||= R(null, { headers: this.#l ??= new Headers() });
619
622
  }
620
623
  set res(e) {
621
624
  if (this.#a && e) {
622
- e = B(e.body, e);
625
+ e = R(e.body, e);
623
626
  for (let [t, n] of this.#a.headers.entries()) if (t !== "content-type") if (t === "set-cookie") {
624
627
  let t = this.#a.headers.getSetCookie();
625
628
  e.headers.delete("set-cookie");
@@ -635,7 +638,7 @@ var be = (e, t, n) => {
635
638
  this.#s = e;
636
639
  };
637
640
  header = (e, t, n) => {
638
- this.finalized && (this.#a = B(this.#a.body, this.#a));
641
+ this.finalized && (this.#a = R(this.#a.body, this.#a));
639
642
  let r = this.#a ? this.#a.headers : this.#l ??= new Headers();
640
643
  t === void 0 ? r.delete(e) : n?.append ? r.append(e, t) : r.set(e, t);
641
644
  };
@@ -660,38 +663,38 @@ var be = (e, t, n) => {
660
663
  r.delete(e);
661
664
  for (let n of t) r.append(e, n);
662
665
  }
663
- return B(e, {
666
+ return R(e, {
664
667
  status: typeof t == "number" ? t : t?.status ?? this.#r,
665
668
  headers: r
666
669
  });
667
670
  }
668
671
  newResponse = (...e) => this.#f(...e);
669
672
  body = (e, t, n) => this.#f(e, t, n);
670
- text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, Ue(He, n));
671
- json = (e, t, n) => this.#f(JSON.stringify(e), t, Ue("application/json", n));
673
+ text = (e, t, n) => !this.#l && !this.#r && !t && !n && !this.finalized ? new Response(e) : this.#f(e, t, qe(Ke, n));
674
+ json = (e, t, n) => this.#f(JSON.stringify(e), t, qe("application/json", n));
672
675
  html = (e, t, n) => {
673
- let r = (e) => this.#f(e, t, Ue("text/html; charset=UTF-8", n));
674
- return typeof e == "object" ? Ve(e, ze.Stringify, !1, {}).then(r) : r(e);
676
+ let r = (e) => this.#f(e, t, qe("text/html; charset=UTF-8", n));
677
+ return typeof e == "object" ? Ge(e, Ue.Stringify, !1, {}).then(r) : r(e);
675
678
  };
676
679
  redirect = (e, t) => {
677
680
  let n = String(e);
678
681
  return this.header("Location", /[^\x00-\xFF]/.test(n) ? encodeURI(n) : n), this.newResponse(null, t ?? 302);
679
682
  };
680
- notFound = () => (this.#c ??= () => B(), this.#c(this));
681
- }, Ge = [
683
+ notFound = () => (this.#c ??= () => R(), this.#c(this));
684
+ }, Ye = [
682
685
  "get",
683
686
  "post",
684
687
  "put",
685
688
  "delete",
686
689
  "options",
687
690
  "patch"
688
- ], Ke = "Can not add a route since the matcher is already built.", qe = class extends Error {}, Je = "__COMPOSED_HANDLER", Ye = (e) => e.text("404 Not Found", 404), Xe = (e, t) => {
691
+ ], Xe = "Can not add a route since the matcher is already built.", Ze = class extends Error {}, Qe = "__COMPOSED_HANDLER", $e = (e) => e.text("404 Not Found", 404), et = (e, t) => {
689
692
  if ("getResponse" in e) {
690
693
  let n = e.getResponse();
691
694
  return t.newResponse(n.body, n);
692
695
  }
693
696
  return console.error(e), t.text("Internal Server Error", 500);
694
- }, Ze = class e {
697
+ }, tt = class e {
695
698
  get;
696
699
  post;
697
700
  put;
@@ -707,7 +710,7 @@ var be = (e, t, n) => {
707
710
  #e = "/";
708
711
  routes = [];
709
712
  constructor(e = {}) {
710
- [...Ge, "all"].forEach((e) => {
713
+ [...Ye, "all"].forEach((e) => {
711
714
  this[e] = (t, ...n) => (typeof t == "string" ? this.#e = t : this.#r(e, this.#e, t), n.forEach((t) => {
712
715
  this.#r(e, this.#e, t);
713
716
  }), this);
@@ -723,7 +726,7 @@ var be = (e, t, n) => {
723
726
  this.#r("ALL", this.#e, e);
724
727
  }), this);
725
728
  let { strict: t, ...n } = e;
726
- Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? ke : Ae;
729
+ Object.assign(this, n), this.getPath = t ?? !0 ? e.getPath ?? Ne : Pe;
727
730
  }
728
731
  #t() {
729
732
  let t = new e({
@@ -732,18 +735,18 @@ var be = (e, t, n) => {
732
735
  });
733
736
  return t.errorHandler = this.errorHandler, t.#n = this.#n, t.routes = this.routes, t;
734
737
  }
735
- #n = Ye;
736
- errorHandler = Xe;
738
+ #n = $e;
739
+ errorHandler = et;
737
740
  route(e, t) {
738
741
  let n = this.basePath(e);
739
742
  return t.routes.map((e) => {
740
743
  let r;
741
- t.errorHandler === Xe ? r = e.handler : (r = async (n, r) => (await he([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Je] = e.handler), n.#r(e.method, e.path, r, e.basePath);
744
+ t.errorHandler === et ? r = e.handler : (r = async (n, r) => (await ye([], t.errorHandler)(n, () => e.handler(n, r))).res, r[Qe] = e.handler), n.#r(e.method, e.path, r, e.basePath);
742
745
  }), this;
743
746
  }
744
747
  basePath(e) {
745
748
  let t = this.#t();
746
- return t._basePath = z(this._basePath, e), t;
749
+ return t._basePath = L(this._basePath, e), t;
747
750
  }
748
751
  onError = (e) => (this.errorHandler = e, this);
749
752
  notFound = (e) => (this.#n = e, this);
@@ -761,21 +764,21 @@ var be = (e, t, n) => {
761
764
  return [e.env, t];
762
765
  };
763
766
  return r ||= (() => {
764
- let t = z(this._basePath, e), n = t === "/" ? 0 : t.length;
767
+ let t = L(this._basePath, e), n = t === "/" ? 0 : t.length;
765
768
  return (e) => {
766
769
  let t = new URL(e.url);
767
770
  return t.pathname = this.getPath(e).slice(n) || "/", new Request(t, e);
768
771
  };
769
- })(), this.#r("ALL", z(e, "*"), async (e, n) => {
772
+ })(), this.#r("ALL", L(e, "*"), async (e, n) => {
770
773
  let i = await t(r(e.req.raw), ...a(e));
771
774
  if (i) return i;
772
775
  await n();
773
776
  }), this;
774
777
  }
775
778
  #r(e, t, n, r) {
776
- e = e.toUpperCase(), t = z(this._basePath, t);
779
+ e = e.toUpperCase(), t = L(this._basePath, t);
777
780
  let i = {
778
- basePath: r === void 0 ? this._basePath : z(this._basePath, r),
781
+ basePath: r === void 0 ? this._basePath : L(this._basePath, r),
779
782
  path: t,
780
783
  method: e,
781
784
  handler: n
@@ -788,7 +791,7 @@ var be = (e, t, n) => {
788
791
  }
789
792
  #a(e, t, n, r) {
790
793
  if (r === "HEAD") return (async () => new Response(null, await this.#a(e, t, n, "GET")))();
791
- let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new We(e, {
794
+ let i = this.getPath(e, { env: n }), a = this.router.match(r, i), o = new Je(e, {
792
795
  path: i,
793
796
  matchResult: a,
794
797
  env: n,
@@ -806,7 +809,7 @@ var be = (e, t, n) => {
806
809
  }
807
810
  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);
808
811
  }
809
- let s = he(a[0], this.errorHandler, this.#n);
812
+ let s = ye(a[0], this.errorHandler, this.#n);
810
813
  return (async () => {
811
814
  try {
812
815
  let e = await s(o);
@@ -818,19 +821,19 @@ var be = (e, t, n) => {
818
821
  })();
819
822
  }
820
823
  fetch = (e, ...t) => this.#a(e, t[1], t[0], e.method);
821
- 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${z("/", e)}`, t), n, r));
824
+ 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${L("/", e)}`, t), n, r));
822
825
  fire = () => {
823
826
  addEventListener("fetch", (e) => {
824
827
  e.respondWith(this.#a(e.request, e, void 0, e.request.method));
825
828
  });
826
829
  };
827
- }, Qe = [];
828
- function $e(e, t) {
830
+ }, nt = [];
831
+ function rt(e, t) {
829
832
  let n = this.buildAllMatchers(), r = ((e, t) => {
830
833
  let r = n[e] || n.ALL, i = r[2][t];
831
834
  if (i) return i;
832
835
  let a = t.match(r[0]);
833
- if (!a) return [[], Qe];
836
+ if (!a) return [[], nt];
834
837
  let o = a.indexOf("", 1);
835
838
  return [r[1][o], a];
836
839
  });
@@ -838,17 +841,17 @@ function $e(e, t) {
838
841
  }
839
842
  //#endregion
840
843
  //#region ../../node_modules/.pnpm/hono@4.12.26/node_modules/hono/dist/router/reg-exp-router/node.js
841
- var V = "[^/]+", H = ".*", U = "(?:|/.*)", W = /* @__PURE__ */ Symbol(), et = /* @__PURE__ */ new Set(".\\+*[^]$()");
842
- function tt(e, t) {
843
- return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 || e === H || e === U ? 1 : t === H || t === U ? -1 : e === V ? 1 : t === V ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
844
+ var z = "[^/]+", B = ".*", V = "(?:|/.*)", H = /* @__PURE__ */ Symbol(), it = /* @__PURE__ */ new Set(".\\+*[^]$()");
845
+ function at(e, t) {
846
+ return e.length === 1 ? t.length === 1 ? e < t ? -1 : 1 : -1 : t.length === 1 || e === B || e === V ? 1 : t === B || t === V ? -1 : e === z ? 1 : t === z ? -1 : e.length === t.length ? e < t ? -1 : 1 : t.length - e.length;
844
847
  }
845
- var nt = class e {
848
+ var ot = class e {
846
849
  #e;
847
850
  #t;
848
851
  #n = /* @__PURE__ */ Object.create(null);
849
852
  insert(t, n, r, i, a) {
850
853
  if (t.length === 0) {
851
- if (this.#e !== void 0) throw W;
854
+ if (this.#e !== void 0) throw H;
852
855
  if (a) return;
853
856
  this.#e = n;
854
857
  return;
@@ -856,42 +859,42 @@ var nt = class e {
856
859
  let [o, ...s] = t, c = o === "*" ? s.length === 0 ? [
857
860
  "",
858
861
  "",
859
- H
862
+ B
860
863
  ] : [
861
864
  "",
862
865
  "",
863
- V
866
+ z
864
867
  ] : o === "/*" ? [
865
868
  "",
866
869
  "",
867
- U
870
+ V
868
871
  ] : o.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/), l;
869
872
  if (c) {
870
- let t = c[1], n = c[2] || V;
871
- if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)))) throw W;
873
+ let t = c[1], n = c[2] || z;
874
+ if (t && c[2] && (n === ".*" || (n = n.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:"), /\((?!\?:)/.test(n)))) throw H;
872
875
  if (l = this.#n[n], !l) {
873
- if (Object.keys(this.#n).some((e) => e !== H && e !== U)) throw W;
876
+ if (Object.keys(this.#n).some((e) => e !== B && e !== V)) throw H;
874
877
  if (a) return;
875
878
  l = this.#n[n] = new e(), t !== "" && (l.#t = i.varIndex++);
876
879
  }
877
880
  !a && t !== "" && r.push([t, l.#t]);
878
881
  } else if (l = this.#n[o], !l) {
879
- if (Object.keys(this.#n).some((e) => e.length > 1 && e !== H && e !== U)) throw W;
882
+ if (Object.keys(this.#n).some((e) => e.length > 1 && e !== B && e !== V)) throw H;
880
883
  if (a) return;
881
884
  l = this.#n[o] = new e();
882
885
  }
883
886
  l.insert(s, n, r, i, a);
884
887
  }
885
888
  buildRegExpStr() {
886
- let e = Object.keys(this.#n).sort(tt).map((e) => {
889
+ let e = Object.keys(this.#n).sort(at).map((e) => {
887
890
  let t = this.#n[e];
888
- return (typeof t.#t == "number" ? `(${e})@${t.#t}` : et.has(e) ? `\\${e}` : e) + t.buildRegExpStr();
891
+ return (typeof t.#t == "number" ? `(${e})@${t.#t}` : it.has(e) ? `\\${e}` : e) + t.buildRegExpStr();
889
892
  });
890
893
  return typeof this.#e == "number" && e.unshift(`#${this.#e}`), e.length === 0 ? "" : e.length === 1 ? e[0] : "(?:" + e.join("|") + ")";
891
894
  }
892
- }, rt = class {
895
+ }, st = class {
893
896
  #e = { varIndex: 0 };
894
- #t = new nt();
897
+ #t = new ot();
895
898
  insert(e, t, n) {
896
899
  let r = [], i = [];
897
900
  for (let t = 0;;) {
@@ -925,29 +928,29 @@ var nt = class e {
925
928
  r
926
929
  ];
927
930
  }
928
- }, it = [
931
+ }, ct = [
929
932
  /^$/,
930
933
  [],
931
934
  /* @__PURE__ */ Object.create(null)
932
- ], at = /* @__PURE__ */ Object.create(null);
933
- function ot(e) {
934
- return at[e] ??= RegExp(e === "*" ? "" : `^${e.replace(/\/\*$|([.\\+*[^\]$()])/g, (e, t) => t ? `\\${t}` : "(?:|/.*)")}$`);
935
+ ], lt = /* @__PURE__ */ Object.create(null);
936
+ function ut(e) {
937
+ return lt[e] ??= RegExp(e === "*" ? "" : `^${e.replace(/\/\*$|([.\\+*[^\]$()])/g, (e, t) => t ? `\\${t}` : "(?:|/.*)")}$`);
935
938
  }
936
- function st() {
937
- at = /* @__PURE__ */ Object.create(null);
939
+ function dt() {
940
+ lt = /* @__PURE__ */ Object.create(null);
938
941
  }
939
- function ct(e) {
940
- let t = new rt(), n = [];
941
- if (e.length === 0) return it;
942
+ function ft(e) {
943
+ let t = new st(), n = [];
944
+ if (e.length === 0) return ct;
942
945
  let r = e.map((e) => [!/\*|\/:/.test(e[0]), ...e]).sort(([e, t], [n, r]) => e ? 1 : n ? -1 : t.length - r.length), i = /* @__PURE__ */ Object.create(null);
943
946
  for (let e = 0, a = -1, o = r.length; e < o; e++) {
944
947
  let [o, s, c] = r[e];
945
- o ? i[s] = [c.map(([e]) => [e, /* @__PURE__ */ Object.create(null)]), Qe] : a++;
948
+ o ? i[s] = [c.map(([e]) => [e, /* @__PURE__ */ Object.create(null)]), nt] : a++;
946
949
  let l;
947
950
  try {
948
951
  l = t.insert(s, a, o);
949
952
  } catch (e) {
950
- throw e === W ? new qe(s) : e;
953
+ throw e === H ? new Ze(s) : e;
951
954
  }
952
955
  o || (n[a] = c.map(([e, t]) => {
953
956
  let n = /* @__PURE__ */ Object.create(null);
@@ -973,12 +976,12 @@ function ct(e) {
973
976
  i
974
977
  ];
975
978
  }
976
- function G(e, t) {
979
+ function U(e, t) {
977
980
  if (e) {
978
- for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (ot(n).test(t)) return [...e[n]];
981
+ for (let n of Object.keys(e).sort((e, t) => t.length - e.length)) if (ut(n).test(t)) return [...e[n]];
979
982
  }
980
983
  }
981
- var lt = class {
984
+ var pt = class {
982
985
  name = "RegExpRouter";
983
986
  #e;
984
987
  #t;
@@ -987,7 +990,7 @@ var lt = class {
987
990
  }
988
991
  add(e, t, n) {
989
992
  let r = this.#e, i = this.#t;
990
- if (!r || !i) throw Error(Ke);
993
+ if (!r || !i) throw Error(Xe);
991
994
  r[e] || [r, i].forEach((t) => {
992
995
  t[e] = /* @__PURE__ */ Object.create(null), Object.keys(t.ALL).forEach((n) => {
993
996
  t[e][n] = [...t.ALL[n]];
@@ -995,10 +998,10 @@ var lt = class {
995
998
  }), t === "/*" && (t = "*");
996
999
  let a = (t.match(/\/:/g) || []).length;
997
1000
  if (/\*$/.test(t)) {
998
- let o = ot(t);
1001
+ let o = ut(t);
999
1002
  e === "ALL" ? Object.keys(r).forEach((e) => {
1000
- r[e][t] ||= G(r[e], t) || G(r.ALL, t) || [];
1001
- }) : r[e][t] ||= G(r[e], t) || G(r.ALL, t) || [], Object.keys(r).forEach((t) => {
1003
+ r[e][t] ||= U(r[e], t) || U(r.ALL, t) || [];
1004
+ }) : r[e][t] ||= U(r[e], t) || U(r.ALL, t) || [], Object.keys(r).forEach((t) => {
1002
1005
  (e === "ALL" || e === t) && Object.keys(r[t]).forEach((e) => {
1003
1006
  o.test(e) && r[t][e].push([n, a]);
1004
1007
  });
@@ -1007,29 +1010,29 @@ var lt = class {
1007
1010
  });
1008
1011
  return;
1009
1012
  }
1010
- let o = je(t) || [t];
1013
+ let o = Fe(t) || [t];
1011
1014
  for (let t = 0, s = o.length; t < s; t++) {
1012
1015
  let c = o[t];
1013
1016
  Object.keys(i).forEach((o) => {
1014
- (e === "ALL" || e === o) && (i[o][c] ||= [...G(r[o], c) || G(r.ALL, c) || []], i[o][c].push([n, a - s + t + 1]));
1017
+ (e === "ALL" || e === o) && (i[o][c] ||= [...U(r[o], c) || U(r.ALL, c) || []], i[o][c].push([n, a - s + t + 1]));
1015
1018
  });
1016
1019
  }
1017
1020
  }
1018
- match = $e;
1021
+ match = rt;
1019
1022
  buildAllMatchers() {
1020
1023
  let e = /* @__PURE__ */ Object.create(null);
1021
1024
  return Object.keys(this.#t).concat(Object.keys(this.#e)).forEach((t) => {
1022
1025
  e[t] ||= this.#n(t);
1023
- }), this.#e = this.#t = void 0, st(), e;
1026
+ }), this.#e = this.#t = void 0, dt(), e;
1024
1027
  }
1025
1028
  #n(e) {
1026
1029
  let t = [], n = e === "ALL";
1027
1030
  return [this.#e, this.#t].forEach((r) => {
1028
1031
  let i = r[e] ? Object.keys(r[e]).map((t) => [t, r[e][t]]) : [];
1029
1032
  i.length === 0 ? e !== "ALL" && t.push(...Object.keys(r.ALL).map((e) => [e, r.ALL[e]])) : (n ||= !0, t.push(...i));
1030
- }), n ? ct(t) : null;
1033
+ }), n ? ft(t) : null;
1031
1034
  }
1032
- }, ut = class {
1035
+ }, mt = class {
1033
1036
  name = "SmartRouter";
1034
1037
  #e = [];
1035
1038
  #t = [];
@@ -1037,7 +1040,7 @@ var lt = class {
1037
1040
  this.#e = e.routers;
1038
1041
  }
1039
1042
  add(e, t, n) {
1040
- if (!this.#t) throw Error(Ke);
1043
+ if (!this.#t) throw Error(Xe);
1041
1044
  this.#t.push([
1042
1045
  e,
1043
1046
  t,
@@ -1053,7 +1056,7 @@ var lt = class {
1053
1056
  for (let e = 0, t = r.length; e < t; e++) i.add(...r[e]);
1054
1057
  o = i.match(e, t);
1055
1058
  } catch (e) {
1056
- if (e instanceof qe) continue;
1059
+ if (e instanceof Ze) continue;
1057
1060
  throw e;
1058
1061
  }
1059
1062
  this.match = i.match.bind(i), this.#e = [i], this.#t = void 0;
@@ -1066,15 +1069,15 @@ var lt = class {
1066
1069
  if (this.#t || this.#e.length !== 1) throw Error("No active router has been determined yet.");
1067
1070
  return this.#e[0];
1068
1071
  }
1069
- }, K = /* @__PURE__ */ Object.create(null), dt = (e) => {
1072
+ }, W = /* @__PURE__ */ Object.create(null), ht = (e) => {
1070
1073
  for (let t in e) return !0;
1071
1074
  return !1;
1072
- }, ft = class e {
1075
+ }, gt = class e {
1073
1076
  #e;
1074
1077
  #t;
1075
1078
  #n;
1076
1079
  #r = 0;
1077
- #i = K;
1080
+ #i = W;
1078
1081
  constructor(e, t, n) {
1079
1082
  if (this.#t = n || /* @__PURE__ */ Object.create(null), this.#e = [], e && t) {
1080
1083
  let n = /* @__PURE__ */ Object.create(null);
@@ -1088,9 +1091,9 @@ var lt = class {
1088
1091
  }
1089
1092
  insert(t, n, r) {
1090
1093
  this.#r = ++this.#r;
1091
- let i = this, a = Ce(n), o = [];
1094
+ let i = this, a = De(n), o = [];
1092
1095
  for (let t = 0, n = a.length; t < n; t++) {
1093
- let n = a[t], r = a[t + 1], s = Ee(n, r), c = Array.isArray(s) ? s[0] : n;
1096
+ let n = a[t], r = a[t + 1], s = Ae(n, r), c = Array.isArray(s) ? s[0] : n;
1094
1097
  if (c in i.#t) {
1095
1098
  i = i.#t[c], s && o.push(s[1]);
1096
1099
  continue;
@@ -1106,7 +1109,7 @@ var lt = class {
1106
1109
  #a(e, t, n, r, i) {
1107
1110
  for (let a = 0, o = t.#e.length; a < o; a++) {
1108
1111
  let o = t.#e[a], s = o[n] || o.ALL, c = {};
1109
- if (s !== void 0 && (s.params = /* @__PURE__ */ Object.create(null), e.push(s), r !== K || i && i !== K)) for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
1112
+ if (s !== void 0 && (s.params = /* @__PURE__ */ Object.create(null), e.push(s), r !== W || i && i !== W)) for (let e = 0, t = s.possibleKeys.length; e < t; e++) {
1110
1113
  let t = s.possibleKeys[e], n = c[s.score];
1111
1114
  s.params[t] = i?.[t] && !n ? i[t] : r[t] ?? i?.[t], c[s.score] = !0;
1112
1115
  }
@@ -1114,15 +1117,15 @@ var lt = class {
1114
1117
  }
1115
1118
  search(e, t) {
1116
1119
  let n = [];
1117
- this.#i = K;
1118
- let r = [this], i = Se(t), a = [], o = i.length, s = null;
1120
+ this.#i = W;
1121
+ let r = [this], i = Ee(t), a = [], o = i.length, s = null;
1119
1122
  for (let c = 0; c < o; c++) {
1120
1123
  let l = i[c], u = c === o - 1, d = [];
1121
1124
  for (let f = 0, p = r.length; f < p; f++) {
1122
1125
  let p = r[f], m = p.#t[l];
1123
1126
  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));
1124
1127
  for (let r = 0, f = p.#n.length; r < f; r++) {
1125
- let f = p.#n[r], m = p.#i === K ? {} : { ...p.#i };
1128
+ let f = p.#n[r], m = p.#i === W ? {} : { ...p.#i };
1126
1129
  if (f === "*") {
1127
1130
  let t = p.#t["*"];
1128
1131
  t && (this.#a(n, t, e, p.#i), t.#i = m, d.push(t));
@@ -1139,7 +1142,7 @@ var lt = class {
1139
1142
  }
1140
1143
  let r = t.substring(s[c]), l = _.exec(r);
1141
1144
  if (l) {
1142
- if (m[g] = l[0], this.#a(n, v, e, p.#i, m), dt(v.#t)) {
1145
+ if (m[g] = l[0], this.#a(n, v, e, p.#i, m), ht(v.#t)) {
1143
1146
  v.#i = m;
1144
1147
  let e = l[0].match(/\//)?.length ?? 0;
1145
1148
  (a[e] ||= []).push(v);
@@ -1155,14 +1158,14 @@ var lt = class {
1155
1158
  }
1156
1159
  return n.length > 1 && n.sort((e, t) => e.score - t.score), [n.map(({ handler: e, params: t }) => [e, t])];
1157
1160
  }
1158
- }, pt = class {
1161
+ }, _t = class {
1159
1162
  name = "TrieRouter";
1160
1163
  #e;
1161
1164
  constructor() {
1162
- this.#e = new ft();
1165
+ this.#e = new gt();
1163
1166
  }
1164
1167
  add(e, t, n) {
1165
- let r = je(t);
1168
+ let r = Fe(t);
1166
1169
  if (r) {
1167
1170
  for (let t = 0, i = r.length; t < i; t++) this.#e.insert(e, r[t], n);
1168
1171
  return;
@@ -1172,43 +1175,43 @@ var lt = class {
1172
1175
  match(e, t) {
1173
1176
  return this.#e.search(e, t);
1174
1177
  }
1175
- }, mt = class extends Ze {
1178
+ }, vt = class extends tt {
1176
1179
  constructor(e = {}) {
1177
- super(e), this.router = e.router ?? new ut({ routers: [new lt(), new pt()] });
1180
+ super(e), this.router = e.router ?? new mt({ routers: [new pt(), new _t()] });
1178
1181
  }
1179
1182
  };
1180
1183
  //#endregion
1181
1184
  //#region src/coordinator-invites.ts
1182
- function ht(e) {
1185
+ function yt(e) {
1183
1186
  let t = "";
1184
1187
  for (let n of e) t += String.fromCharCode(n);
1185
1188
  return btoa(t);
1186
1189
  }
1187
- function gt(e) {
1190
+ function bt(e) {
1188
1191
  let t = atob(e), n = new Uint8Array(t.length);
1189
1192
  for (let e = 0; e < t.length; e += 1) n[e] = t.charCodeAt(e);
1190
1193
  return n;
1191
1194
  }
1192
- function _t(e) {
1195
+ function xt(e) {
1193
1196
  return e.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
1194
1197
  }
1195
- function vt(e) {
1198
+ function St(e) {
1196
1199
  let t = e.replace(/-/g, "+").replace(/_/g, "/");
1197
1200
  return t + "=".repeat((4 - t.length % 4) % 4);
1198
1201
  }
1199
- function yt(e) {
1202
+ function G(e) {
1200
1203
  let t = JSON.stringify(e);
1201
- return _t(ht(new TextEncoder().encode(t)));
1204
+ return xt(yt(new TextEncoder().encode(t)));
1202
1205
  }
1203
- function bt(e) {
1204
- let t = new TextDecoder().decode(gt(vt(e))), n = JSON.parse(t);
1206
+ function Ct(e) {
1207
+ let t = new TextDecoder().decode(bt(St(e))), n = JSON.parse(t);
1205
1208
  if (typeof n != "object" || !n) throw Error("invalid invite payload");
1206
1209
  return n;
1207
1210
  }
1208
- function xt(e) {
1211
+ function K(e) {
1209
1212
  return `codemem://join?invite=${encodeURIComponent(e)}`;
1210
1213
  }
1211
- function St(e) {
1214
+ function wt(e) {
1212
1215
  let t = e.trim();
1213
1216
  if (t.startsWith("codemem://")) {
1214
1217
  let e = new URL(t).searchParams.get("invite") ?? "";
@@ -1219,33 +1222,33 @@ function St(e) {
1219
1222
  }
1220
1223
  //#endregion
1221
1224
  //#region src/project-invite-acceptance.ts
1222
- var Ct = "pending_setup", wt = "project_sync_enablement_failed", Tt = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", Et = class extends Error {
1223
- code = wt;
1224
- detail = Tt;
1225
+ var Tt = "pending_setup", Et = "project_sync_enablement_failed", Dt = "Invitation was accepted, but sync could not be enabled. Make the codemem config writable, then retry.", Ot = class extends Error {
1226
+ code = Et;
1227
+ detail = Dt;
1225
1228
  constructor(e) {
1226
- super(Tt, e), this.name = "ProjectSyncEnablementError";
1229
+ super(Dt, e), this.name = "ProjectSyncEnablementError";
1227
1230
  }
1228
1231
  };
1229
- function Dt(e) {
1232
+ function kt(e) {
1230
1233
  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.";
1231
1234
  }
1232
1235
  //#endregion
1233
1236
  //#region src/scope-resolution.ts
1234
- var Ot = "local-default", kt = "legacy-shared-review";
1237
+ var At = "local-default", jt = "legacy-shared-review";
1235
1238
  function q(e) {
1236
1239
  return e?.trim() || null;
1237
1240
  }
1238
1241
  function J(e) {
1239
1242
  return e.trim().replaceAll("\\", "/").replace(/\/+$/, "") || e.trim();
1240
1243
  }
1241
- function At(t) {
1244
+ function Mt(t) {
1242
1245
  return J(e(t));
1243
1246
  }
1244
- function jt(e) {
1247
+ function Nt(e) {
1245
1248
  let t = q(e);
1246
1249
  return t ? J(t) : null;
1247
1250
  }
1248
- function Mt(e) {
1251
+ function Pt(e) {
1249
1252
  let n = [
1250
1253
  e.cwd,
1251
1254
  e.project,
@@ -1253,7 +1256,7 @@ function Mt(e) {
1253
1256
  ].map((e) => q(e)).find((e) => e != null);
1254
1257
  return `unmapped:${t("sha256").update(n ?? "unknown", "utf8").digest("hex")}`;
1255
1258
  }
1256
- function Nt(e) {
1259
+ function Ft(e) {
1257
1260
  let t = q(e.gitRemote), n = q(e.gitBranch), r = q(e.cwd), i = q(e.workspaceId), a = q(e.project);
1258
1261
  if (t) {
1259
1262
  let r = J(t);
@@ -1268,7 +1271,7 @@ function Nt(e) {
1268
1271
  };
1269
1272
  }
1270
1273
  return r ? {
1271
- value: At(r),
1274
+ value: Mt(r),
1272
1275
  source: "cwd",
1273
1276
  displayProject: a
1274
1277
  } : i ? {
@@ -1276,41 +1279,41 @@ function Nt(e) {
1276
1279
  source: "workspace_id",
1277
1280
  displayProject: a
1278
1281
  } : {
1279
- value: Mt(e),
1282
+ value: Pt(e),
1280
1283
  source: "unmapped",
1281
1284
  displayProject: a
1282
1285
  };
1283
1286
  }
1284
- function Pt(e) {
1287
+ function It(e) {
1285
1288
  return !/[\\/:]/.test(e);
1286
1289
  }
1287
- function Ft(e) {
1290
+ function Lt(e) {
1288
1291
  return e.replace(/[|\\{}()[\]^$+?.*]/g, "\\$&");
1289
1292
  }
1290
- function It(e) {
1293
+ function Rt(e) {
1291
1294
  return e.replace(/[*?]/g, "").length;
1292
1295
  }
1293
- function Lt(e, t) {
1296
+ function zt(e, t) {
1294
1297
  let n = J(t);
1295
- return !n || Pt(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Ft(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
1298
+ return !n || It(n) ? !1 : /[*?]/.test(n) ? RegExp(`^${Lt(n).replaceAll("\\*", ".*").replaceAll("\\?", ".")}$`).test(e) : e === n;
1296
1299
  }
1297
- function Rt(e) {
1300
+ function Bt(e) {
1298
1301
  return e.mapping.priority ?? 0;
1299
1302
  }
1300
- function zt(e) {
1303
+ function Vt(e) {
1301
1304
  let t = q(e.mapping.updated_at);
1302
1305
  if (!t) return 0;
1303
1306
  let n = Date.parse(t);
1304
1307
  return Number.isFinite(n) ? n : 0;
1305
1308
  }
1306
- function Bt(e, t) {
1307
- return Rt(t) - Rt(e) || t.specificity - e.specificity || zt(t) - zt(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
1309
+ function Ht(e, t) {
1310
+ return Bt(t) - Bt(e) || t.specificity - e.specificity || Vt(t) - Vt(e) || (t.mapping.id ?? 0) - (e.mapping.id ?? 0) || e.mapping.scope_id.localeCompare(t.mapping.scope_id);
1308
1311
  }
1309
- function Vt(e) {
1310
- return e.toSorted(Bt)[0] ?? null;
1312
+ function Ut(e) {
1313
+ return e.toSorted(Ht)[0] ?? null;
1311
1314
  }
1312
- function Ht(e) {
1313
- let t = Nt(e), n = q(e.explicitScopeId);
1315
+ function Wt(e) {
1316
+ let t = Ft(e), n = q(e.explicitScopeId);
1314
1317
  if (n) return {
1315
1318
  scopeId: n,
1316
1319
  reason: "explicit_override",
@@ -1325,7 +1328,7 @@ function Ht(e) {
1325
1328
  mapping: null,
1326
1329
  matchedPattern: null
1327
1330
  };
1328
- let r = e.mappings ?? [], i = Vt(r.filter((e) => jt(e.workspace_identity) === t.value).map((e) => ({
1331
+ let r = e.mappings ?? [], i = Ut(r.filter((e) => Nt(e.workspace_identity) === t.value).map((e) => ({
1329
1332
  mapping: e,
1330
1333
  matchedPattern: null,
1331
1334
  specificity: t.value.length
@@ -1337,13 +1340,13 @@ function Ht(e) {
1337
1340
  mapping: i.mapping,
1338
1341
  matchedPattern: null
1339
1342
  };
1340
- let a = Vt(r.flatMap((e) => {
1343
+ let a = Ut(r.flatMap((e) => {
1341
1344
  if (q(e.workspace_identity)) return [];
1342
1345
  let n = q(e.project_pattern);
1343
- return !n || !Lt(t.value, n) ? [] : [{
1346
+ return !n || !zt(t.value, n) ? [] : [{
1344
1347
  mapping: e,
1345
1348
  matchedPattern: J(n),
1346
- specificity: It(n)
1349
+ specificity: Rt(n)
1347
1350
  }];
1348
1351
  }));
1349
1352
  return a ? {
@@ -1360,11 +1363,11 @@ function Ht(e) {
1360
1363
  matchedPattern: null
1361
1364
  };
1362
1365
  }
1363
- function Ut(e, t) {
1366
+ function Gt(e, t) {
1364
1367
  let n = new Set([
1365
1368
  "",
1366
- Ot,
1367
- kt
1369
+ At,
1370
+ jt
1368
1371
  ]), r = e.prepare("SELECT scope_id\n FROM replication_scopes\n WHERE status = 'active' AND authority_type = 'local'").all();
1369
1372
  for (let e of r) e.scope_id != null && n.add(e.scope_id);
1370
1373
  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);
@@ -1373,29 +1376,29 @@ function Ut(e, t) {
1373
1376
  }
1374
1377
  //#endregion
1375
1378
  //#region src/project-share-intent.ts
1376
- var Wt = "existing_and_future";
1377
- function Gt(e) {
1379
+ var Kt = "existing_and_future";
1380
+ function qt(e) {
1378
1381
  return t("sha256").update(JSON.stringify(e)).digest("hex");
1379
1382
  }
1380
- function Kt(e) {
1381
- return Gt({
1383
+ function Jt(e) {
1384
+ return qt({
1382
1385
  v: 1,
1383
- historyPolicy: Wt,
1386
+ historyPolicy: Kt,
1384
1387
  projects: e.map((e) => ({
1385
1388
  canonicalIdentity: e.canonicalIdentity,
1386
1389
  existingMemoryCount: e.existingMemoryCount
1387
1390
  })).toSorted((e, t) => e.canonicalIdentity.localeCompare(t.canonicalIdentity))
1388
1391
  });
1389
1392
  }
1390
- function qt(e) {
1391
- return Kt(e.map((e) => ({
1393
+ function Yt(e) {
1394
+ return Jt(e.map((e) => ({
1392
1395
  canonicalIdentity: e.canonical_identity,
1393
1396
  displayName: e.display_name,
1394
1397
  identitySource: "coordinator_acceptance",
1395
1398
  existingMemoryCount: e.existing_memory_count
1396
1399
  })));
1397
1400
  }
1398
- function Jt(e) {
1401
+ function Xt(e) {
1399
1402
  if (!Array.isArray(e) || e.length === 0 || e.length > 100) throw Error("operation_intent_invalid");
1400
1403
  let t = e.map((e) => {
1401
1404
  if (!e || typeof e != "object" || Array.isArray(e)) throw Error("operation_intent_invalid");
@@ -1403,11 +1406,11 @@ function Jt(e) {
1403
1406
  if (typeof t.canonical_identity != "string" || typeof t.display_name != "string") throw Error("operation_intent_invalid");
1404
1407
  let n = t.canonical_identity, r = n.trim(), i = t.display_name, a;
1405
1408
  try {
1406
- a = x(i, "project_name");
1409
+ a = C(i, "project_name");
1407
1410
  } catch {
1408
1411
  throw Error("operation_intent_invalid");
1409
1412
  }
1410
- let o = t.existing_memory_count, s = Nt({ gitRemote: r }).value;
1413
+ let o = t.existing_memory_count, s = Ft({ gitRemote: r }).value;
1411
1414
  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");
1412
1415
  return {
1413
1416
  canonical_identity: r,
@@ -1420,20 +1423,20 @@ function Jt(e) {
1420
1423
  }
1421
1424
  //#endregion
1422
1425
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/clock.js
1423
- function Yt(e) {
1426
+ function Zt(e) {
1424
1427
  let t = performance.now() * .001, n = Math.floor(t), r = Math.floor(t % 1 * 1e9);
1425
1428
  return e != null && (n -= e[0], r -= e[1], r < 0 && (n--, r += 1e9)), [n, r];
1426
1429
  }
1427
1430
  function Y() {
1428
- let [e, t] = Yt();
1431
+ let [e, t] = Zt();
1429
1432
  return e * 1e3 + Math.floor(t / 1e6);
1430
1433
  }
1431
- function Xt(e) {
1434
+ function Qt(e) {
1432
1435
  return new Promise((t) => setTimeout(t, e));
1433
1436
  }
1434
1437
  //#endregion
1435
1438
  //#region ../../node_modules/.pnpm/limiter@3.0.0/node_modules/limiter/dist/esm/TokenBucket.js
1436
- var Zt = class {
1439
+ var $t = class {
1437
1440
  bucketSize;
1438
1441
  tokensPerInterval;
1439
1442
  interval;
@@ -1466,7 +1469,7 @@ var Zt = class {
1466
1469
  if (this.bucketSize === 0) return Infinity;
1467
1470
  if (e > this.bucketSize) throw Error(`Requested tokens ${e} exceeds bucket size ${this.bucketSize}`);
1468
1471
  this.drip();
1469
- let t = async () => (await Xt(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
1472
+ let t = async () => (await Qt(Math.ceil((e - this.content) * (this.interval / this.tokensPerInterval))), this.removeTokens(e));
1470
1473
  if (e > this.content) return t();
1471
1474
  if (this.parentBucket != null) {
1472
1475
  let n = await this.parentBucket.removeTokens(e);
@@ -1486,13 +1489,13 @@ var Zt = class {
1486
1489
  let n = t * (this.tokensPerInterval / this.interval), r = this.content;
1487
1490
  return this.content = Math.min(this.content + n, this.bucketSize), Math.floor(this.content) > Math.floor(r);
1488
1491
  }
1489
- }, Qt = class {
1492
+ }, en = class {
1490
1493
  tokenBucket;
1491
1494
  curIntervalStart;
1492
1495
  tokensThisInterval;
1493
1496
  fireImmediately;
1494
1497
  constructor({ tokensPerInterval: e, interval: t, fireImmediately: n }) {
1495
- this.tokenBucket = new Zt({
1498
+ this.tokenBucket = new $t({
1496
1499
  bucketSize: e,
1497
1500
  tokensPerInterval: e,
1498
1501
  interval: t
@@ -1504,7 +1507,7 @@ var Zt = class {
1504
1507
  if ((t < this.curIntervalStart || t - this.curIntervalStart >= this.tokenBucket.interval) && (this.curIntervalStart = t, this.tokensThisInterval = 0), e > this.tokenBucket.tokensPerInterval - this.tokensThisInterval) {
1505
1508
  if (this.fireImmediately) return -1;
1506
1509
  {
1507
- await Xt(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
1510
+ await Qt(Math.ceil(this.curIntervalStart + this.tokenBucket.interval - t));
1508
1511
  let n = await this.tokenBucket.removeTokens(e);
1509
1512
  return this.tokensThisInterval += e, n;
1510
1513
  }
@@ -1525,7 +1528,7 @@ var Zt = class {
1525
1528
  };
1526
1529
  //#endregion
1527
1530
  //#region src/request-rate-limit.ts
1528
- function $t(e = {}) {
1531
+ function tn(e = {}) {
1529
1532
  let t = Math.max(1e3, Math.trunc(e.windowMs ?? 6e4)), n = e.now ?? (() => Date.now()), r = /* @__PURE__ */ new Map(), i = 0;
1530
1533
  function a(e) {
1531
1534
  return Math.max(1, Math.ceil(t / Math.max(1, e) / 1e3));
@@ -1542,7 +1545,7 @@ function $t(e = {}) {
1542
1545
  o(l);
1543
1546
  let u = `${c}:${e}`, d = r.get(u);
1544
1547
  return d || (d = {
1545
- limiter: new Qt({
1548
+ limiter: new en({
1546
1549
  tokensPerInterval: c,
1547
1550
  interval: t,
1548
1551
  fireImmediately: !0
@@ -1559,8 +1562,8 @@ function $t(e = {}) {
1559
1562
  }
1560
1563
  //#endregion
1561
1564
  //#region src/scope-membership-semantics.ts
1562
- var en = "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.";
1563
- function tn(e) {
1565
+ var nn = "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.";
1566
+ function rn(e) {
1564
1567
  let t = Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null, n = Number.isFinite(e.requiredEpoch) ? Number(e.requiredEpoch) : null;
1565
1568
  return t == null || n == null ? {
1566
1569
  membership_epoch: t,
@@ -1574,19 +1577,19 @@ function tn(e) {
1574
1577
  reason: t < n ? "stale_epoch" : "current"
1575
1578
  };
1576
1579
  }
1577
- function nn(e) {
1580
+ function an(e) {
1578
1581
  return {
1579
1582
  scope_id: e.scopeId,
1580
1583
  device_id: e.deviceId,
1581
1584
  membership_epoch: Number.isFinite(e.membershipEpoch) ? Number(e.membershipEpoch) : null,
1582
1585
  prevents_future_sync: !0,
1583
1586
  deletes_already_copied_data: !1,
1584
- message: en
1587
+ message: nn
1585
1588
  };
1586
1589
  }
1587
1590
  //#endregion
1588
1591
  //#region src/sync-auth-constants.ts
1589
- var rn = 300, an = 64 * 1024, X = "X-Codemem-Coordinator-Admin", on = "X-Codemem-Coordinator-Admin-Actor", sn = 120, cn = 30;
1592
+ var on = 300, sn = 64 * 1024, X = "X-Codemem-Coordinator-Admin", cn = "X-Codemem-Coordinator-Admin-Actor", ln = 120, un = 30;
1590
1593
  function Z(e, t) {
1591
1594
  let n = t.adminSecret();
1592
1595
  if (!n) return {
@@ -1605,14 +1608,14 @@ function Z(e, t) {
1605
1608
  error: "missing_admin_header"
1606
1609
  };
1607
1610
  }
1608
- function ln(e) {
1611
+ function dn(e) {
1609
1612
  let t = new URL(e);
1610
1613
  return t.search ? `${t.pathname}${t.search}` : t.pathname;
1611
1614
  }
1612
- async function un(e, t, n, r) {
1615
+ async function fn(e, t, n, r) {
1613
1616
  return await e.recordNonce(t, n, r);
1614
1617
  }
1615
- async function dn(e, t) {
1618
+ async function pn(e, t) {
1616
1619
  await e.cleanupNonces(t);
1617
1620
  }
1618
1621
  async function Q(e, t, n, r) {
@@ -1648,7 +1651,7 @@ async function Q(e, t, n, r) {
1648
1651
  try {
1649
1652
  u = await n({
1650
1653
  method: r.method,
1651
- pathWithQuery: ln(r.url),
1654
+ pathWithQuery: dn(r.url),
1652
1655
  bodyBytes: r.body,
1653
1656
  timestamp: o,
1654
1657
  nonce: s,
@@ -1669,7 +1672,7 @@ async function Q(e, t, n, r) {
1669
1672
  enrollment: null
1670
1673
  };
1671
1674
  let d = t.now();
1672
- return await un(e, i, s, d) ? (await dn(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 300 * 2 * 1e3)).toISOString()), {
1675
+ return await fn(e, i, s, d) ? (await pn(e, (/* @__PURE__ */ new Date(new Date(d).getTime() - 300 * 2 * 1e3)).toISOString()), {
1673
1676
  ok: !0,
1674
1677
  error: "ok",
1675
1678
  enrollment: c
@@ -1682,9 +1685,9 @@ async function Q(e, t, n, r) {
1682
1685
  function $(e) {
1683
1686
  return e === "device_disabled" ? 403 : e === "group_archived" ? 409 : 401;
1684
1687
  }
1685
- function fn(e) {
1688
+ function mn(e) {
1686
1689
  if (!e?.storeFactory || !e.runtime || !e.requestVerifier) throw Error("createCoordinatorApp requires storeFactory, runtime, and requestVerifier.");
1687
- let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, a = e.requestRateLimit ?? {}, o = a.limiter ?? $t(), s = Math.max(1, Math.trunc(a.readLimit ?? sn)), c = Math.max(1, Math.trunc(a.mutationLimit ?? cn)), l = Math.max(1, Math.trunc(a.unauthenticatedReadLimit ?? Math.min(20, s))), u = Math.max(1, Math.trunc(a.unauthenticatedMutationLimit ?? Math.min(10, c))), d = new mt(), f = new TextDecoder();
1690
+ let t = e.runtime, n = e.storeFactory, r = e.requestVerifier, a = e.requestRateLimit ?? {}, o = a.limiter ?? tn(), s = Math.max(1, Math.trunc(a.readLimit ?? ln)), c = Math.max(1, Math.trunc(a.mutationLimit ?? un)), l = Math.max(1, Math.trunc(a.unauthenticatedReadLimit ?? Math.min(20, s))), u = Math.max(1, Math.trunc(a.unauthenticatedMutationLimit ?? Math.min(10, c))), d = new vt(), f = new TextDecoder();
1688
1691
  function p(e, t, n) {
1689
1692
  let r = e.req.method === "GET" || e.req.method === "HEAD" || e.req.method === "OPTIONS", i = o.check(`${e.req.method}:${n ? "auth" : "anon"}:${t}`, n ? r ? s : c : r ? l : u);
1690
1693
  return i.allowed ? null : (e.header("Retry-After", String(i.retryAfterS)), e.json({
@@ -1694,7 +1697,7 @@ function fn(e) {
1694
1697
  }
1695
1698
  async function m(e) {
1696
1699
  let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
1697
- if (Number.isFinite(t) && t > an) return null;
1700
+ if (Number.isFinite(t) && t > sn) return null;
1698
1701
  let n = e.req.raw.body;
1699
1702
  if (!n) return new Uint8Array();
1700
1703
  let r = n.getReader(), i = [], a = 0;
@@ -1703,7 +1706,7 @@ function fn(e) {
1703
1706
  let { done: e, value: t } = await r.read();
1704
1707
  if (e) break;
1705
1708
  if (t) {
1706
- if (a += t.byteLength, a > an) return await r.cancel(), null;
1709
+ if (a += t.byteLength, a > sn) return await r.cancel(), null;
1707
1710
  i.push(t);
1708
1711
  }
1709
1712
  }
@@ -1722,14 +1725,14 @@ function fn(e) {
1722
1725
  return null;
1723
1726
  }
1724
1727
  }
1725
- function g(e, t) {
1728
+ function _(e, t) {
1726
1729
  let n = e[t];
1727
1730
  return n == null ? null : String(n).trim() || null;
1728
1731
  }
1729
- function _(e) {
1732
+ function v(e) {
1730
1733
  return e?.trim() || null;
1731
1734
  }
1732
- function v(e, t) {
1735
+ function y(e, t) {
1733
1736
  let n = e[t];
1734
1737
  if (n == null || n === "") return null;
1735
1738
  if (typeof n != "number" && typeof n != "string") return NaN;
@@ -1742,32 +1745,32 @@ function fn(e) {
1742
1745
  let r = n;
1743
1746
  return Number.isFinite(r) ? Math.trunc(r) : NaN;
1744
1747
  }
1745
- function y(e) {
1748
+ function b(e) {
1746
1749
  return [
1747
1750
  "1",
1748
1751
  "true",
1749
1752
  "yes"
1750
1753
  ].includes(String(e ?? "").trim().toLowerCase());
1751
1754
  }
1752
- function b(e) {
1755
+ function x(e) {
1753
1756
  try {
1754
- return Jt(JSON.parse(e ?? ""));
1757
+ return Xt(JSON.parse(e ?? ""));
1755
1758
  } catch {
1756
1759
  throw Error("operation_intent_invalid");
1757
1760
  }
1758
1761
  }
1759
- function x(e) {
1762
+ function S(e) {
1760
1763
  let t = String(e.operation_id ?? "").trim(), n = String(e.reviewed_project_set_digest ?? "").trim();
1761
1764
  if (!/^share_[a-f0-9]{40}$/u.test(t) || !/^[a-f0-9]{64}$/u.test(n)) throw Error("operation_intent_invalid");
1762
- let r = b(e.project_intent_json);
1763
- if (qt(r) !== n) throw Error("operation_intent_invalid");
1765
+ let r = x(e.project_intent_json);
1766
+ if (Yt(r) !== n) throw Error("operation_intent_invalid");
1764
1767
  return {
1765
1768
  operation_id: t,
1766
1769
  reviewed_project_set_digest: n,
1767
1770
  projects: r
1768
1771
  };
1769
1772
  }
1770
- function S(e) {
1773
+ function C(e) {
1771
1774
  try {
1772
1775
  return ee(JSON.parse(e ?? ""));
1773
1776
  } catch {
@@ -1779,7 +1782,7 @@ function fn(e) {
1779
1782
  let r = await e.getGroup(t);
1780
1783
  return r ? r.archived_at ? n.json({ error: "group_archived" }, 409) : null : n.json({ error: "group_not_found" }, 404);
1781
1784
  }
1782
- async function T(e, t, n, r) {
1785
+ async function E(e, t, n, r) {
1783
1786
  let i = await w(e, t, r);
1784
1787
  if (i) return {
1785
1788
  scope: null,
@@ -1801,7 +1804,7 @@ function fn(e) {
1801
1804
  response: r.json({ error: "scope_not_found" }, 404)
1802
1805
  };
1803
1806
  }
1804
- async function E(e, n, i) {
1807
+ async function D(e, n, i) {
1805
1808
  let a = await Q(e, t, r, {
1806
1809
  method: i.req.method,
1807
1810
  url: i.req.url,
@@ -1823,7 +1826,7 @@ function fn(e) {
1823
1826
  function O(e, t) {
1824
1827
  return e.status === "active" && e.membership_epoch >= t.membership_epoch;
1825
1828
  }
1826
- async function k(e, t, n) {
1829
+ async function A(e, t, n) {
1827
1830
  return (await e.listScopeMemberships(t.scope_id, !1)).some((e) => e.device_id === n && O(e, t));
1828
1831
  }
1829
1832
  return d.post("/v1/presence", async (e) => {
@@ -1899,14 +1902,14 @@ function fn(e) {
1899
1902
  if (!t) return e.json({ error: "group_id_required" }, 400);
1900
1903
  let r = n();
1901
1904
  try {
1902
- let { auth: n, response: i } = await E(r, t, e);
1905
+ let { auth: n, response: i } = await D(r, t, e);
1903
1906
  if (i) return i;
1904
1907
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
1905
1908
  let a = await r.listScopes({
1906
1909
  groupId: t,
1907
1910
  includeInactive: !1
1908
1911
  }), o = [];
1909
- for (let e of a) e.status === "active" && await k(r, e, String(n.enrollment.device_id)) && o.push(e);
1912
+ for (let e of a) e.status === "active" && await A(r, e, String(n.enrollment.device_id)) && o.push(e);
1910
1913
  return e.json({ items: o });
1911
1914
  } finally {
1912
1915
  await r.close();
@@ -1917,7 +1920,7 @@ function fn(e) {
1917
1920
  if (!r) return e.json({ error: "scope_id_required" }, 400);
1918
1921
  let i = n();
1919
1922
  try {
1920
- let { auth: n, response: a } = await E(i, t, e);
1923
+ let { auth: n, response: a } = await D(i, t, e);
1921
1924
  if (a) return a;
1922
1925
  if (!n.enrollment) return e.json({ error: "unknown_device" }, 401);
1923
1926
  let o = (await i.listScopes({
@@ -1964,11 +1967,11 @@ function fn(e) {
1964
1967
  if (i == null) return e.json({ error: "body_too_large" }, 413);
1965
1968
  let a = h(i);
1966
1969
  if (!a) return e.json({ error: "invalid_json" }, 400);
1967
- let o = String(a.group_id ?? "").trim(), s = String(a.requested_device_id ?? "").trim();
1970
+ let o = String(a.group_id ?? "").trim(), s = String(a.requested_device_id ?? "").trim(), c = Object.hasOwn(a, "expected_incoming_request_id") ? String(a.expected_incoming_request_id ?? "").trim() : void 0;
1968
1971
  if (!o || !s) return e.json({ error: "group_id_and_requested_device_id_required" }, 400);
1969
- let c = n();
1972
+ let l = n();
1970
1973
  try {
1971
- let n = await Q(c, t, r, {
1974
+ let n = await Q(l, t, r, {
1972
1975
  method: e.req.method,
1973
1976
  url: e.req.url,
1974
1977
  groupId: o,
@@ -1982,18 +1985,24 @@ function fn(e) {
1982
1985
  let a = p(e, String(n.enrollment.device_id), !0);
1983
1986
  if (a) return a;
1984
1987
  if (s === String(n.enrollment.device_id)) return e.json({ error: "requested_device_must_differ" }, 400);
1985
- if (!await c.getEnrollment(o, s)) return e.json({ error: "requested_device_not_found" }, 404);
1986
- let l = await c.createReciprocalApproval({
1987
- groupId: o,
1988
- requestingDeviceId: String(n.enrollment.device_id),
1989
- requestedDeviceId: s
1990
- });
1991
- return e.json({
1992
- ok: !0,
1993
- request: l
1994
- });
1988
+ if (!await l.getEnrollment(o, s)) return e.json({ error: "requested_device_not_found" }, 404);
1989
+ try {
1990
+ let t = await l.createReciprocalApproval({
1991
+ groupId: o,
1992
+ requestingDeviceId: String(n.enrollment.device_id),
1993
+ requestedDeviceId: s,
1994
+ ...c === void 0 ? {} : { expectedIncomingRequestId: c }
1995
+ });
1996
+ return e.json({
1997
+ ok: !0,
1998
+ request: t
1999
+ });
2000
+ } catch (t) {
2001
+ if (t instanceof g) return e.json({ error: t.code }, 409);
2002
+ throw t;
2003
+ }
1995
2004
  } finally {
1996
- await c.close();
2005
+ await l.close();
1997
2006
  }
1998
2007
  }), d.post("/v1/invites/add-device", async (e) => {
1999
2008
  let i = await m(e);
@@ -2031,7 +2040,7 @@ function fn(e) {
2031
2040
  if (!d || d !== d.trim() || d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "identity_binding_required" }, 403);
2032
2041
  let f;
2033
2042
  try {
2034
- f = await L(a.reviewed_intent, {
2043
+ f = await ge(a.reviewed_intent, {
2035
2044
  target: {
2036
2045
  kind: "add_device",
2037
2046
  targetIdentityId: d
@@ -2039,7 +2048,7 @@ function fn(e) {
2039
2048
  digest: l
2040
2049
  });
2041
2050
  } catch (t) {
2042
- return t instanceof D && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2051
+ return t instanceof k && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2043
2052
  }
2044
2053
  let m = await u.createInvite({
2045
2054
  groupId: s,
@@ -2063,13 +2072,13 @@ function fn(e) {
2063
2072
  target_identity_id: m.target_identity_id ?? void 0,
2064
2073
  inviter_device_id: m.inviter_device_id ?? void 0,
2065
2074
  reviewed_preview_digest: m.reviewed_preview_digest ?? void 0
2066
- }, g = yt(h), { token: _, ...v } = m;
2075
+ }, g = G(h), { token: _, ...v } = m;
2067
2076
  return e.json({
2068
2077
  ok: !0,
2069
2078
  invite: v,
2070
2079
  payload: h,
2071
2080
  encoded: g,
2072
- link: xt(g)
2081
+ link: K(g)
2073
2082
  });
2074
2083
  } finally {
2075
2084
  await u.close();
@@ -2085,7 +2094,7 @@ function fn(e) {
2085
2094
  if (!o) return e.json({ error: "invalid_json" }, 400);
2086
2095
  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;
2087
2096
  if (!s || !c || !l || !u) return e.json({ error: "group_id_device_id_fingerprint_public_key_required" }, 400);
2088
- if (me(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2097
+ if (ve(u) !== l) return e.json({ error: "fingerprint_mismatch" }, 400);
2089
2098
  let f = n();
2090
2099
  try {
2091
2100
  await f.createGroup(s), await f.enrollDevice(s, {
@@ -2202,7 +2211,7 @@ function fn(e) {
2202
2211
  try {
2203
2212
  let t = await w(o, a, e);
2204
2213
  if (t) return t;
2205
- let n = y(e.req.query("include_inactive"));
2214
+ let n = b(e.req.query("include_inactive"));
2206
2215
  return e.json({ items: await o.listScopes({
2207
2216
  groupId: a,
2208
2217
  includeInactive: n
@@ -2219,7 +2228,7 @@ function fn(e) {
2219
2228
  if (a == null) return e.json({ error: "body_too_large" }, 413);
2220
2229
  let o = h(a);
2221
2230
  if (!o) return e.json({ error: "invalid_json" }, 400);
2222
- let s = String(e.req.param("group_id") ?? "").trim(), c = g(o, "scope_id"), l = g(o, "label"), u = v(o, "membership_epoch");
2231
+ let s = String(e.req.param("group_id") ?? "").trim(), c = _(o, "scope_id"), l = _(o, "label"), u = y(o, "membership_epoch");
2223
2232
  if (!c || !l) return e.json({ error: "scope_id_and_label_required" }, 400);
2224
2233
  if (Number.isNaN(u)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
2225
2234
  let d = n();
@@ -2229,14 +2238,14 @@ function fn(e) {
2229
2238
  let n = await d.createScope({
2230
2239
  scopeId: c,
2231
2240
  label: l,
2232
- kind: g(o, "kind"),
2233
- authorityType: g(o, "authority_type"),
2234
- coordinatorId: g(o, "coordinator_id"),
2241
+ kind: _(o, "kind"),
2242
+ authorityType: _(o, "authority_type"),
2243
+ coordinatorId: _(o, "coordinator_id"),
2235
2244
  groupId: s,
2236
- manifestIssuerDeviceId: g(o, "manifest_issuer_device_id"),
2245
+ manifestIssuerDeviceId: _(o, "manifest_issuer_device_id"),
2237
2246
  membershipEpoch: u,
2238
- manifestHash: g(o, "manifest_hash"),
2239
- status: g(o, "status")
2247
+ manifestHash: _(o, "manifest_hash"),
2248
+ status: _(o, "status")
2240
2249
  });
2241
2250
  return e.json({
2242
2251
  ok: !0,
@@ -2256,24 +2265,24 @@ function fn(e) {
2256
2265
  if (a == null) return e.json({ error: "body_too_large" }, 413);
2257
2266
  let o = h(a);
2258
2267
  if (!o) return e.json({ error: "invalid_json" }, 400);
2259
- let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = v(o, "membership_epoch");
2268
+ let s = String(e.req.param("group_id") ?? "").trim(), c = String(e.req.param("scope_id") ?? "").trim(), l = y(o, "membership_epoch");
2260
2269
  if (!c) return e.json({ error: "scope_id_required" }, 400);
2261
2270
  if (Number.isNaN(l)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
2262
2271
  let u = n();
2263
2272
  try {
2264
- let t = await T(u, s, c, e);
2273
+ let t = await E(u, s, c, e);
2265
2274
  if (t.response) return t.response;
2266
2275
  let n = await u.updateScope({
2267
2276
  scopeId: c,
2268
- label: o.label === void 0 ? void 0 : g(o, "label"),
2269
- kind: o.kind === void 0 ? void 0 : g(o, "kind"),
2270
- authorityType: o.authority_type === void 0 ? void 0 : g(o, "authority_type"),
2271
- coordinatorId: o.coordinator_id === void 0 ? void 0 : g(o, "coordinator_id"),
2277
+ label: o.label === void 0 ? void 0 : _(o, "label"),
2278
+ kind: o.kind === void 0 ? void 0 : _(o, "kind"),
2279
+ authorityType: o.authority_type === void 0 ? void 0 : _(o, "authority_type"),
2280
+ coordinatorId: o.coordinator_id === void 0 ? void 0 : _(o, "coordinator_id"),
2272
2281
  groupId: s,
2273
- manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 : g(o, "manifest_issuer_device_id"),
2282
+ manifestIssuerDeviceId: o.manifest_issuer_device_id === void 0 ? void 0 : _(o, "manifest_issuer_device_id"),
2274
2283
  membershipEpoch: l,
2275
- manifestHash: o.manifest_hash === void 0 ? void 0 : g(o, "manifest_hash"),
2276
- status: o.status === void 0 ? void 0 : g(o, "status")
2284
+ manifestHash: o.manifest_hash === void 0 ? void 0 : _(o, "manifest_hash"),
2285
+ status: o.status === void 0 ? void 0 : _(o, "status")
2277
2286
  });
2278
2287
  return n ? e.json({
2279
2288
  ok: !0,
@@ -2291,8 +2300,8 @@ function fn(e) {
2291
2300
  if (i) return i;
2292
2301
  let a = String(e.req.param("group_id") ?? "").trim(), o = String(e.req.param("scope_id") ?? "").trim(), s = n();
2293
2302
  try {
2294
- let t = await T(s, a, o, e);
2295
- return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o, y(e.req.query("include_revoked"))) });
2303
+ let t = await E(s, a, o, e);
2304
+ return t.response ? t.response : e.json({ items: await s.listScopeMemberships(o, b(e.req.query("include_revoked"))) });
2296
2305
  } finally {
2297
2306
  await s.close();
2298
2307
  }
@@ -2305,27 +2314,27 @@ function fn(e) {
2305
2314
  if (o == null) return e.json({ error: "body_too_large" }, 413);
2306
2315
  let s = h(o);
2307
2316
  if (!s) return e.json({ error: "invalid_json" }, 400);
2308
- let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = g(s, "effect_id"), d = g(s, "device_id"), f = v(s, "membership_epoch");
2317
+ let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = _(s, "effect_id"), d = _(s, "device_id"), f = y(s, "membership_epoch");
2309
2318
  if (!u) return e.json({ error: "effect_id_required" }, 400);
2310
2319
  if (!d) return e.json({ error: "device_id_required" }, 400);
2311
2320
  if (Number.isNaN(f)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
2312
- let y = n();
2321
+ let g = n();
2313
2322
  try {
2314
- let t = await T(y, c, l, e);
2323
+ let t = await E(g, c, l, e);
2315
2324
  if (t.response) return t.response;
2316
- let n = await y.grantScopeMembership({
2325
+ let n = await g.grantScopeMembership({
2317
2326
  effectId: u,
2318
2327
  scopeId: l,
2319
2328
  deviceId: d,
2320
- role: g(s, "role"),
2329
+ role: _(s, "role"),
2321
2330
  membershipEpoch: f,
2322
- coordinatorId: g(s, "coordinator_id"),
2331
+ coordinatorId: _(s, "coordinator_id"),
2323
2332
  groupId: c,
2324
- manifestIssuerDeviceId: g(s, "manifest_issuer_device_id"),
2325
- manifestHash: g(s, "manifest_hash"),
2326
- signedManifestJson: g(s, "signed_manifest_json"),
2333
+ manifestIssuerDeviceId: _(s, "manifest_issuer_device_id"),
2334
+ manifestHash: _(s, "manifest_hash"),
2335
+ signedManifestJson: _(s, "signed_manifest_json"),
2327
2336
  actorType: "admin",
2328
- actorId: _(e.req.header(on))
2337
+ actorId: v(e.req.header(cn))
2329
2338
  });
2330
2339
  return e.json({
2331
2340
  ok: !0,
@@ -2338,7 +2347,7 @@ function fn(e) {
2338
2347
  let r = t instanceof i && t.code === "scope_inactive";
2339
2348
  return e.json({ error: r ? "scope_not_active" : n }, n === "scope_membership_effect_conflict" || r ? 409 : 400);
2340
2349
  } finally {
2341
- await y.close();
2350
+ await g.close();
2342
2351
  }
2343
2352
  }), d.post("/v1/admin/groups/:group_id/scopes/:scope_id/members/:device_id/revoke", async (e) => {
2344
2353
  let r = Z(e.req.header(X), t);
@@ -2349,28 +2358,28 @@ function fn(e) {
2349
2358
  if (o == null) return e.json({ error: "body_too_large" }, 413);
2350
2359
  let s = o.byteLength > 0 ? h(o) : {};
2351
2360
  if (!s) return e.json({ error: "invalid_json" }, 400);
2352
- let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = String(e.req.param("device_id") ?? "").trim(), d = g(s, "effect_id"), f = v(s, "membership_epoch");
2361
+ let c = String(e.req.param("group_id") ?? "").trim(), l = String(e.req.param("scope_id") ?? "").trim(), u = String(e.req.param("device_id") ?? "").trim(), d = _(s, "effect_id"), f = y(s, "membership_epoch");
2353
2362
  if (!d) return e.json({ error: "effect_id_required" }, 400);
2354
2363
  if (!u) return e.json({ error: "device_id_required" }, 400);
2355
2364
  if (Number.isNaN(f)) return e.json({ error: "membership_epoch_must_be_number" }, 400);
2356
- let y = n();
2365
+ let g = n();
2357
2366
  try {
2358
- let t = await T(y, c, l, e);
2367
+ let t = await E(g, c, l, e);
2359
2368
  if (t.response) return t.response;
2360
- if (!await y.revokeScopeMembership({
2369
+ if (!await g.revokeScopeMembership({
2361
2370
  effectId: d,
2362
2371
  scopeId: l,
2363
2372
  deviceId: u,
2364
2373
  groupId: c,
2365
2374
  membershipEpoch: f,
2366
- manifestHash: g(s, "manifest_hash"),
2367
- signedManifestJson: g(s, "signed_manifest_json"),
2375
+ manifestHash: _(s, "manifest_hash"),
2376
+ signedManifestJson: _(s, "signed_manifest_json"),
2368
2377
  actorType: "admin",
2369
- actorId: _(e.req.header(on))
2378
+ actorId: v(e.req.header(cn))
2370
2379
  })) return e.json({ error: "membership_not_found" }, 404);
2371
2380
  let n;
2372
2381
  try {
2373
- n = (await y.listScopeMemberships(l, !0)).find((e) => e.device_id === u);
2382
+ n = (await g.listScopeMemberships(l, !0)).find((e) => e.device_id === u);
2374
2383
  } catch {
2375
2384
  n = void 0;
2376
2385
  }
@@ -2378,7 +2387,7 @@ function fn(e) {
2378
2387
  ok: !0,
2379
2388
  scope_id: l,
2380
2389
  device_id: u,
2381
- revocation: nn({
2390
+ revocation: an({
2382
2391
  scopeId: l,
2383
2392
  deviceId: u,
2384
2393
  membershipEpoch: n?.membership_epoch ?? f
@@ -2388,7 +2397,7 @@ function fn(e) {
2388
2397
  let n = t instanceof Error ? t.message : String(t);
2389
2398
  return t instanceof i && t.code === "scope_group_mismatch" ? e.json({ error: "scope_not_found" }, 404) : e.json({ error: n }, n === "scope_membership_effect_conflict" ? 409 : 400);
2390
2399
  } finally {
2391
- await y.close();
2400
+ await g.close();
2392
2401
  }
2393
2402
  }), d.get("/v1/admin/devices", async (e) => {
2394
2403
  let r = Z(e.req.header(X), t);
@@ -2421,7 +2430,7 @@ function fn(e) {
2421
2430
  if (!l) return e.json({ error: "display_name_required" }, 400);
2422
2431
  let u;
2423
2432
  try {
2424
- u = C(l, "display_name");
2433
+ u = T(l, "display_name");
2425
2434
  } catch (t) {
2426
2435
  return e.json({ error: t instanceof Error ? t.message : "display_name_invalid" }, 400);
2427
2436
  }
@@ -2496,37 +2505,37 @@ function fn(e) {
2496
2505
  if (a == null) return e.json({ error: "body_too_large" }, 413);
2497
2506
  let o = h(a);
2498
2507
  if (!o) return e.json({ error: "invalid_json" }, 400);
2499
- 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, f = 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, b = String(o.invite_kind ?? o.kind ?? "").trim(), x = String(o.policy_team_id ?? "").trim() || null, S = String(o.target_identity_id ?? "").trim() || null, w = String(o.reviewed_preview_digest ?? "").trim() || null, T, E = null, O = null;
2508
+ 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, f = 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, b = String(o.invite_kind ?? o.kind ?? "").trim(), x = String(o.policy_team_id ?? "").trim() || null, S = String(o.target_identity_id ?? "").trim() || null, C = String(o.reviewed_preview_digest ?? "").trim() || null, w, E = null, D = null;
2500
2509
  if (!s || !["auto_admit", "approval_required"].includes(c) || !l) return e.json({ error: "group_id_policy_and_expires_at_required" }, 400);
2501
2510
  if (Object.hasOwn(o, "assigned_identity_id")) return e.json({ error: "assigned_identity_id_forbidden" }, 400);
2502
2511
  if (Number.isNaN(new Date(l).getTime())) return e.json({ error: "invalid_expires_at" }, 400);
2503
2512
  if (!!d != !!f) return e.json({ error: "operation_intent_reference_incomplete" }, 400);
2504
- let k = b || (d ? "project_share" : "legacy_enrollment");
2513
+ let O = b || (d ? "project_share" : "legacy_enrollment");
2505
2514
  if (![
2506
2515
  "legacy_enrollment",
2507
2516
  "project_share",
2508
2517
  "team_member",
2509
2518
  "add_device"
2510
- ].includes(k)) return e.json({ error: "invite_kind_invalid" }, 400);
2511
- if (k === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
2512
- if (w && !/^[a-f0-9]{64}$/u.test(w)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
2513
- if (k === "team_member" && (!x || !w || S) || k === "add_device" && (!S || !w || x) || !["team_member", "add_device"].includes(k) && (x || S || w)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2519
+ ].includes(O)) return e.json({ error: "invite_kind_invalid" }, 400);
2520
+ if (O === "project_share" ? !d : d) return e.json({ error: "invite_kind_intent_mismatch" }, 400);
2521
+ if (C && !/^[a-f0-9]{64}$/u.test(C)) return e.json({ error: "reviewed_preview_digest_invalid" }, 400);
2522
+ if (O === "team_member" && (!x || !C || S) || O === "add_device" && (!S || !C || x) || !["team_member", "add_device"].includes(O) && (x || S || C)) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2514
2523
  if ([x, S].filter((e) => !!e).some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "recipient_invite_identifier_invalid" }, 400);
2515
- if (k === "team_member" || k === "add_device") {
2524
+ if (O === "team_member" || O === "add_device") {
2516
2525
  if (o.reviewed_intent == null) return e.json({ error: "recipient_invite_review_unavailable" }, 400);
2517
2526
  try {
2518
- T = await L(o.reviewed_intent, {
2519
- target: k === "team_member" ? {
2527
+ w = await ge(o.reviewed_intent, {
2528
+ target: O === "team_member" ? {
2520
2529
  kind: "team_member",
2521
2530
  policyTeamId: String(x)
2522
2531
  } : {
2523
2532
  kind: "add_device",
2524
2533
  targetIdentityId: String(S)
2525
2534
  },
2526
- digest: String(w)
2535
+ digest: String(C)
2527
2536
  });
2528
2537
  } catch (t) {
2529
- return t instanceof D && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2538
+ return t instanceof k && t.code === "recipient_invite_intent_mismatch" ? e.json({ error: t.code }, 409) : e.json({ error: "recipient_invite_review_unavailable" }, 400);
2530
2539
  }
2531
2540
  } else if (o.reviewed_intent != null) return e.json({ error: "recipient_invite_metadata_invalid" }, 400);
2532
2541
  if (d && !/^share_[a-f0-9]{40}$/u.test(d) || f && !/^[a-f0-9]{64}$/u.test(f)) return e.json({ error: "operation_intent_reference_invalid" }, 400);
@@ -2538,17 +2547,17 @@ function fn(e) {
2538
2547
  y
2539
2548
  ].some((e) => e.length > 256 || /[\p{Cc}\p{Cf}]/u.test(e))) return e.json({ error: "project_invite_identity_context_invalid" }, 400);
2540
2549
  try {
2541
- if (C(_, "inviter_display_name"), E = ee(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== E.length || (O = o.project_intent.map((e, t) => {
2550
+ if (T(_, "inviter_display_name"), E = ee(o.project_summaries), !Array.isArray(o.project_intent) || o.project_intent.length !== E.length || (D = o.project_intent.map((e, t) => {
2542
2551
  let n;
2543
2552
  try {
2544
- n = Jt([e])[0];
2553
+ n = Xt([e])[0];
2545
2554
  } catch {
2546
2555
  throw Error("project_intent_invalid");
2547
2556
  }
2548
2557
  let r = E?.[t];
2549
2558
  if (!n || !r || n.display_name !== r.display_name || n.existing_memory_count !== r.existing_memory_count) throw Error("project_intent_invalid");
2550
2559
  return n;
2551
- }), new Set(O.map((e) => e.canonical_identity)).size !== O.length)) throw Error("project_intent_invalid");
2560
+ }), new Set(D.map((e) => e.canonical_identity)).size !== D.length)) throw Error("project_intent_invalid");
2552
2561
  } catch (t) {
2553
2562
  return e.json({ error: t instanceof Error ? t.message : "project_invite_invalid" }, 400);
2554
2563
  }
@@ -2570,12 +2579,12 @@ function fn(e) {
2570
2579
  inviterDeviceId: v,
2571
2580
  pendingPersonId: y,
2572
2581
  projectSummaries: E,
2573
- projectIntent: O,
2574
- inviteKind: k,
2582
+ projectIntent: D,
2583
+ inviteKind: O,
2575
2584
  policyTeamId: x,
2576
2585
  targetIdentityId: S,
2577
- reviewedPreviewDigest: w,
2578
- reviewedIntent: T
2586
+ reviewedPreviewDigest: C,
2587
+ reviewedIntent: w
2579
2588
  }), r = {
2580
2589
  v: 1,
2581
2590
  kind: n.invite_kind === "team_member" || n.invite_kind === "add_device" ? n.invite_kind : "coordinator_team_invite",
@@ -2600,13 +2609,13 @@ function fn(e) {
2600
2609
  inviter_device_id: n.inviter_device_id ?? void 0,
2601
2610
  reviewed_preview_digest: n.reviewed_preview_digest ?? void 0
2602
2611
  } : {}
2603
- }, i = yt(r), { token: a, ...p } = n;
2612
+ }, i = G(r), { token: a, ...p } = n;
2604
2613
  return e.json({
2605
2614
  ok: !0,
2606
2615
  invite: p,
2607
2616
  payload: r,
2608
2617
  encoded: i,
2609
- link: xt(i)
2618
+ link: K(i)
2610
2619
  });
2611
2620
  } catch (t) {
2612
2621
  if (t instanceof Error && t.message === "invite_operation_intent_conflict") return e.json({ error: "invite_operation_intent_conflict" }, 409);
@@ -2658,7 +2667,7 @@ function fn(e) {
2658
2667
  if (!n.project_intent_json || !n.project_summaries_json) return e.json({ error: "invite_invalid" }, 404);
2659
2668
  let i;
2660
2669
  try {
2661
- i = S(n.project_summaries_json);
2670
+ i = C(n.project_summaries_json);
2662
2671
  } catch {
2663
2672
  return e.json({ error: "invite_invalid" }, 409);
2664
2673
  }
@@ -2698,7 +2707,7 @@ function fn(e) {
2698
2707
  if (!n) return e.json({ error: "operation_not_found" }, 404);
2699
2708
  let r;
2700
2709
  try {
2701
- r = b(n.project_intent_json);
2710
+ r = x(n.project_intent_json);
2702
2711
  } catch {
2703
2712
  return e.json({ error: "operation_intent_invalid" }, 409);
2704
2713
  }
@@ -2708,7 +2717,7 @@ function fn(e) {
2708
2717
  display_name: String(e.display_name ?? ""),
2709
2718
  existing_memory_count: Number(e.existing_memory_count ?? 0)
2710
2719
  }));
2711
- s = xt(yt({
2720
+ s = K(G({
2712
2721
  v: 1,
2713
2722
  kind: "coordinator_team_invite",
2714
2723
  coordinator_url: new URL(e.req.url).origin,
@@ -2825,11 +2834,11 @@ function fn(e) {
2825
2834
  } finally {
2826
2835
  await c.close();
2827
2836
  }
2828
- }), d.post("/v1/admin/join-requests/approve", async (e) => pn(e, !0, {
2837
+ }), d.post("/v1/admin/join-requests/approve", async (e) => hn(e, !0, {
2829
2838
  createStore: n,
2830
2839
  runtime: t,
2831
2840
  rateLimitedResponse: p
2832
- })), d.post("/v1/admin/join-requests/deny", async (e) => pn(e, !1, {
2841
+ })), d.post("/v1/admin/join-requests/deny", async (e) => hn(e, !1, {
2833
2842
  createStore: n,
2834
2843
  runtime: t,
2835
2844
  rateLimitedResponse: p
@@ -2853,7 +2862,7 @@ function fn(e) {
2853
2862
  if (!i) return e.json({ error: "invalid_json" }, 400);
2854
2863
  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(), p = String(i.device_display_name ?? "").trim();
2855
2864
  if (!a || !o || !s || !c) return e.json({ error: "token_device_id_fingerprint_public_key_required" }, 400);
2856
- if (me(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
2865
+ if (ve(c) !== s) return e.json({ error: "fingerprint_mismatch" }, 400);
2857
2866
  let g = n();
2858
2867
  try {
2859
2868
  let n = await g.getInviteByTokenForInspection(a);
@@ -2881,11 +2890,11 @@ function fn(e) {
2881
2890
  try {
2882
2891
  if (i.recipient_display_name != null) {
2883
2892
  if (typeof i.recipient_display_name != "string") throw Error("recipient_display_name_invalid");
2884
- d = C(i.recipient_display_name, "recipient_display_name");
2893
+ d = T(i.recipient_display_name, "recipient_display_name");
2885
2894
  }
2886
2895
  if (i.device_display_name != null) {
2887
2896
  if (typeof i.device_display_name != "string") throw Error("device_display_name_invalid");
2888
- f = C(i.device_display_name, "device_display_name");
2897
+ f = T(i.device_display_name, "device_display_name");
2889
2898
  }
2890
2899
  } catch (t) {
2891
2900
  return e.json({ error: t instanceof Error ? t.message : "recipient_invite_identity_invalid" }, 400);
@@ -2940,13 +2949,13 @@ function fn(e) {
2940
2949
  if (d.length > 256 || /[\p{Cc}\p{Cf}]/u.test(d)) return e.json({ error: "recipient_actor_id_invalid" }, 400);
2941
2950
  let l, m;
2942
2951
  try {
2943
- l = C(f, "recipient_display_name"), m = C(p, "device_display_name");
2952
+ l = T(f, "recipient_display_name"), m = T(p, "device_display_name");
2944
2953
  } catch (t) {
2945
2954
  return e.json({ error: t instanceof Error ? t.message : "project_invite_identity_invalid" }, 400);
2946
2955
  }
2947
2956
  let h;
2948
2957
  try {
2949
- h = x(n);
2958
+ h = S(n);
2950
2959
  } catch {
2951
2960
  return e.json({ error: "operation_intent_invalid" }, 409);
2952
2961
  }
@@ -2964,7 +2973,7 @@ function fn(e) {
2964
2973
  });
2965
2974
  return e.json({
2966
2975
  ok: !0,
2967
- status: Ct,
2976
+ status: Tt,
2968
2977
  group_id: n.invite.group_id,
2969
2978
  operation_id: n.invite.operation_id,
2970
2979
  trust_state: n.invite.trust_state,
@@ -3033,14 +3042,14 @@ function fn(e) {
3033
3042
  }
3034
3043
  }), d;
3035
3044
  }
3036
- async function pn(e, t, n) {
3045
+ async function hn(e, t, n) {
3037
3046
  let r = Z(e.req.header(X), n.runtime);
3038
3047
  if (!r.ok) return n.rateLimitedResponse(e, e.req.path, !1) ?? e.json({ error: r.error }, 401);
3039
3048
  let i = n.rateLimitedResponse(e, "admin", !0);
3040
3049
  if (i) return i;
3041
3050
  let a = await (async () => {
3042
3051
  let t = Number.parseInt(e.req.header("content-length") ?? "", 10);
3043
- if (Number.isFinite(t) && t > an) return null;
3052
+ if (Number.isFinite(t) && t > sn) return null;
3044
3053
  let n = e.req.raw.body;
3045
3054
  if (!n) return new Uint8Array();
3046
3055
  let r = n.getReader(), i = [], a = 0;
@@ -3049,7 +3058,7 @@ async function pn(e, t, n) {
3049
3058
  let { done: e, value: t } = await r.read();
3050
3059
  if (e) break;
3051
3060
  if (t) {
3052
- if (a += t.byteLength, a > an) return await r.cancel(), null;
3061
+ if (a += t.byteLength, a > sn) return await r.cancel(), null;
3053
3062
  i.push(t);
3054
3063
  }
3055
3064
  }
@@ -3097,6 +3106,6 @@ async function pn(e, t, n) {
3097
3106
  }
3098
3107
  }
3099
3108
  //#endregion
3100
- export { fe as A, m as B, xt as C, de as D, D as E, C as F, o as G, l as H, x as I, c as K, ee as L, T as M, S as N, F as O, w as P, p as R, St as S, E as T, s as U, i as V, u as W, Tt as _, tn as a, bt as b, Jt as c, Ot as d, Nt as f, wt as g, Ct as h, nn as i, L as j, pe as k, Kt as l, Ut as m, rn as n, Wt as o, Ht as p, en as r, qt as s, fn as t, kt as u, Et as v, me as w, yt as x, Dt as y, d as z };
3109
+ export { he as A, p as B, K as C, me as D, k as E, T as F, s as G, m as H, C as I, c as J, u as K, ee as L, D as M, w as N, pe as O, E as P, g as R, wt as S, O as T, i as U, d as V, l as W, Dt as _, rn as a, Ct as b, Xt as c, At as d, Ft as f, Et as g, Tt as h, an as i, ge as j, _e as k, Jt as l, Gt as m, on as n, Kt as o, Wt as p, o as q, nn as r, Yt as s, mn as t, jt as u, Ot as v, ve as w, G as x, kt as y, h as z };
3101
3110
 
3102
- //# sourceMappingURL=coordinator-api-SeLosPIq.js.map
3111
+ //# sourceMappingURL=coordinator-api-DGTIU3Ri.js.map