@orieljs/framework 0.1.0-alpha.14 → 0.1.0-alpha.16

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 (70) hide show
  1. package/dist/{chunk-X4N74JDO.js → chunk-3QHTNAMZ.js} +6 -4
  2. package/dist/{chunk-X4N74JDO.js.map → chunk-3QHTNAMZ.js.map} +1 -1
  3. package/dist/{chunk-BKA5F3TH.js → chunk-6AXJB4CD.js} +5 -1
  4. package/dist/chunk-6AXJB4CD.js.map +1 -0
  5. package/dist/{chunk-UBSIBGXR.js → chunk-MG4YEWMV.js} +1351 -497
  6. package/dist/chunk-MG4YEWMV.js.map +1 -0
  7. package/dist/{chunk-4NCMY3ZS.js → chunk-YNDMTTWL.js} +121 -8
  8. package/dist/chunk-YNDMTTWL.js.map +1 -0
  9. package/dist/contracts.d.ts +112 -1
  10. package/dist/contracts.js +5 -1
  11. package/dist/{index.d-lffxurFs.d.ts → index.d-DA-Iu2a2.d.ts} +39 -2
  12. package/dist/index.d.ts +2838 -2101
  13. package/dist/index.js +1805 -647
  14. package/dist/index.js.map +1 -1
  15. package/dist/{jsx-runtime-Bc5KJzwb.d.ts → jsx-runtime-CenT41Y0.d.ts} +1 -1
  16. package/dist/jsx-runtime.d.ts +2 -2
  17. package/dist/jsx-runtime.js +3 -3
  18. package/dist/{testing-CVpo7aRl.d.ts → testing-B8J_HhF4.d.ts} +6 -2
  19. package/dist/testing.d.ts +2 -2
  20. package/dist/testing.js +3 -3
  21. package/docs/authentication.md +45 -3
  22. package/docs/authorization.md +2 -4
  23. package/docs/cache.md +29 -5
  24. package/docs/configuration.md +84 -7
  25. package/docs/console.md +41 -2
  26. package/docs/container.md +4 -0
  27. package/docs/csrf.md +2 -2
  28. package/docs/database.md +27 -2
  29. package/docs/deployment.md +42 -18
  30. package/docs/eloquent-factories.md +7 -3
  31. package/docs/eloquent-mutators.md +2 -1
  32. package/docs/eloquent-observers.md +2 -0
  33. package/docs/eloquent-relationships.md +34 -1
  34. package/docs/eloquent-resources.md +253 -0
  35. package/docs/eloquent.md +47 -0
  36. package/docs/errors.md +12 -3
  37. package/docs/events.md +3 -1
  38. package/docs/export.md +3 -3
  39. package/docs/facades.md +1 -0
  40. package/docs/helpers.md +33 -2
  41. package/docs/inertia.md +11 -1
  42. package/docs/installation.md +6 -2
  43. package/docs/laravel.md +71 -0
  44. package/docs/lifecycle.md +9 -5
  45. package/docs/live.md +88 -8
  46. package/docs/mail.md +32 -5
  47. package/docs/middleware.md +20 -12
  48. package/docs/navigation.json +12 -0
  49. package/docs/notifications.md +22 -0
  50. package/docs/pagination.md +4 -0
  51. package/docs/passwords.md +4 -6
  52. package/docs/providers.md +4 -6
  53. package/docs/queues.md +70 -2
  54. package/docs/requests.md +42 -3
  55. package/docs/responses.md +9 -5
  56. package/docs/routing.md +118 -7
  57. package/docs/scheduling.md +27 -0
  58. package/docs/session.md +2 -2
  59. package/docs/starter-kits.md +26 -7
  60. package/docs/storage.md +10 -4
  61. package/docs/testing.md +10 -2
  62. package/docs/two-factor.md +38 -4
  63. package/docs/upgrade.md +182 -0
  64. package/docs/validation.md +70 -9
  65. package/docs/views.md +1 -0
  66. package/docs/vite.md +20 -1
  67. package/package.json +43 -35
  68. package/dist/chunk-4NCMY3ZS.js.map +0 -1
  69. package/dist/chunk-BKA5F3TH.js.map +0 -1
  70. package/dist/chunk-UBSIBGXR.js.map +0 -1
@@ -6,15 +6,20 @@ import {
6
6
  ContainerNotAvailableError,
7
7
  ServiceProvider,
8
8
  Str,
9
+ ValidatedInput,
9
10
  currentContainer,
10
11
  facade,
11
12
  fileType_exports,
12
- inject
13
- } from "./chunk-4NCMY3ZS.js";
13
+ inject,
14
+ isPublicAsset,
15
+ serializeDate,
16
+ warnProcessWide
17
+ } from "./chunk-YNDMTTWL.js";
14
18
  import {
15
19
  Application,
16
20
  AuthFactory,
17
21
  BusDispatcher,
22
+ CacheManager,
18
23
  ClassNames,
19
24
  ClassRegistry,
20
25
  ConfigRepository,
@@ -33,6 +38,7 @@ import {
33
38
  LiveManager,
34
39
  LogManager,
35
40
  MailManager,
41
+ MaintenanceMode,
36
42
  MiddlewareCallbacks,
37
43
  NotificationDispatcher,
38
44
  PaginationState,
@@ -44,10 +50,11 @@ import {
44
50
  RoutingPaths,
45
51
  Session,
46
52
  UrlGenerator,
53
+ VALIDATED_INPUT,
47
54
  ValidationFactory,
48
55
  ViewFactory,
49
56
  token
50
- } from "./chunk-BKA5F3TH.js";
57
+ } from "./chunk-6AXJB4CD.js";
51
58
 
52
59
  // ../Config/dist/index.js
53
60
  import { existsSync, readFileSync } from "fs";
@@ -56,16 +63,16 @@ import { parse } from "dotenv";
56
63
  import { existsSync as existsSync2, readdirSync } from "fs";
57
64
  import { join as join2 } from "path";
58
65
  import { pathToFileURL } from "url";
59
- var kind = (value) => value === null ? "null" : Array.isArray(value) ? "array" : typeof value;
60
- var isPlainObject = (value) => {
61
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
62
- const proto = Object.getPrototypeOf(value);
66
+ var kind = (value2) => value2 === null ? "null" : Array.isArray(value2) ? "array" : typeof value2;
67
+ var isPlainObject = (value2) => {
68
+ if (typeof value2 !== "object" || value2 === null || Array.isArray(value2)) return false;
69
+ const proto = Object.getPrototypeOf(value2);
63
70
  return proto === Object.prototype || proto === null;
64
71
  };
65
72
  function typed(repository, key2, defaultValue, expected, check) {
66
- const value = repository.get(key2, defaultValue);
67
- if (!check(value)) throw new TypeError(`Configuration value for key [${key2}] must be ${expected}, ${kind(value)} given.`);
68
- return value;
73
+ const value2 = repository.get(key2, defaultValue);
74
+ if (!check(value2)) throw new TypeError(`Configuration value for key [${key2}] must be ${expected}, ${kind(value2)} given.`);
75
+ return value2;
69
76
  }
70
77
  var Config = facade(ConfigRepository, {
71
78
  /** Several keys at once: a list of keys, or an object of keys and their defaults. */
@@ -74,24 +81,24 @@ var Config = facade(ConfigRepository, {
74
81
  return Object.fromEntries(entries.map(([key2, fallback]) => [key2, this.get(key2, fallback)]));
75
82
  },
76
83
  /** Puts a value first in the array at `key` (creating it when missing). */
77
- prepend(key2, value) {
84
+ prepend(key2, value2) {
78
85
  const current = this.get(key2, []);
79
- this.set(key2, [value, ...Array.isArray(current) ? current : [current]]);
86
+ this.set(key2, [value2, ...Array.isArray(current) ? current : [current]]);
80
87
  },
81
88
  string(key2, defaultValue) {
82
- return typed(this, key2, defaultValue, "a string", (value) => typeof value === "string");
89
+ return typed(this, key2, defaultValue, "a string", (value2) => typeof value2 === "string");
83
90
  },
84
91
  integer(key2, defaultValue) {
85
- return typed(this, key2, defaultValue, "an integer", (value) => Number.isInteger(value));
92
+ return typed(this, key2, defaultValue, "an integer", (value2) => Number.isInteger(value2));
86
93
  },
87
94
  float(key2, defaultValue) {
88
- return typed(this, key2, defaultValue, "a float", (value) => typeof value === "number");
95
+ return typed(this, key2, defaultValue, "a float", (value2) => typeof value2 === "number");
89
96
  },
90
97
  boolean(key2, defaultValue) {
91
- return typed(this, key2, defaultValue, "a boolean", (value) => typeof value === "boolean");
98
+ return typed(this, key2, defaultValue, "a boolean", (value2) => typeof value2 === "boolean");
92
99
  },
93
100
  array(key2, defaultValue) {
94
- return typed(this, key2, defaultValue, "an array", (value) => Array.isArray(value) || isPlainObject(value));
101
+ return typed(this, key2, defaultValue, "an array", (value2) => Array.isArray(value2) || isPlainObject(value2));
95
102
  }
96
103
  });
97
104
  var Repository = class {
@@ -105,13 +112,14 @@ var Repository = class {
105
112
  get(key2, defaultValue) {
106
113
  return Arr.get(this.items, key2, defaultValue);
107
114
  }
108
- set(keyOrValues, value) {
109
- const entries = typeof keyOrValues === "string" ? [[keyOrValues, value]] : Object.entries(keyOrValues);
115
+ set(keyOrValues, value2) {
116
+ warnProcessWide("config()", "set it in a service provider's boot()");
117
+ const entries = typeof keyOrValues === "string" ? [[keyOrValues, value2]] : Object.entries(keyOrValues);
110
118
  for (const [k, v] of entries) Arr.set(this.items, k, v);
111
119
  }
112
- push(key2, value) {
120
+ push(key2, value2) {
113
121
  const current = this.get(key2, []);
114
- this.set(key2, [...Array.isArray(current) ? current : [current], value]);
122
+ this.set(key2, [...Array.isArray(current) ? current : [current], value2]);
115
123
  }
116
124
  all() {
117
125
  return this.items;
@@ -140,7 +148,18 @@ function singleQuoted(source) {
140
148
  for (const match of source.matchAll(/^[ \t]*(?:export[ \t]+)?([\w.-]+)[ \t]*=[ \t]*'/gm)) keys.add(match[1]);
141
149
  return keys;
142
150
  }
143
- function loadEnvironment(basePath) {
151
+ function envOption(argv) {
152
+ for (let i = 0; i < argv.length; i++) {
153
+ const token2 = argv[i];
154
+ if (token2 === "--") return void 0;
155
+ if (token2.startsWith("--env=")) return token2.slice("--env=".length) || void 0;
156
+ if (token2 === "--env" && argv[i + 1] !== void 0 && !argv[i + 1].startsWith("-")) return argv[i + 1];
157
+ }
158
+ return void 0;
159
+ }
160
+ function loadEnvironment(basePath, argv = process.argv.slice(2)) {
161
+ const option = envOption(argv);
162
+ if (option !== void 0) process.env.APP_ENV = option;
144
163
  const appEnv = process.env.APP_ENV;
145
164
  const specific = appEnv ? join(basePath, `.env.${appEnv}`) : void 0;
146
165
  const file = specific && existsSync(specific) ? specific : join(basePath, ".env");
@@ -148,20 +167,20 @@ function loadEnvironment(basePath) {
148
167
  const source = readFileSync(file, "utf8");
149
168
  const literal = singleQuoted(source);
150
169
  for (const [key2, raw] of Object.entries(parse(source))) {
151
- const value = literal.has(key2) ? raw : raw.replace(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g, (match, name) => process.env[name] ?? match);
152
- if (process.env[key2] === void 0) process.env[key2] = value;
170
+ const value2 = literal.has(key2) ? raw : raw.replace(/\$\{([A-Za-z_][A-Za-z0-9_.]*)\}/g, (match, name) => process.env[name] ?? match);
171
+ if (process.env[key2] === void 0) process.env[key2] = value2;
153
172
  }
154
173
  return file;
155
174
  }
156
175
  var CONFIG_FILE = /^(?!.*\.d\.ts$)([A-Za-z0-9_-]+)\.(ts|js|mjs)$/;
157
- function clonePlain(value) {
158
- if (Array.isArray(value)) return value.map((item) => clonePlain(item));
159
- if (typeof value === "object" && value !== null) {
160
- const proto = Object.getPrototypeOf(value);
161
- if (proto !== Object.prototype && proto !== null) return value;
162
- return Object.fromEntries(Object.entries(value).map(([key2, item]) => [key2, clonePlain(item)]));
176
+ function clonePlain(value2) {
177
+ if (Array.isArray(value2)) return value2.map((item) => clonePlain(item));
178
+ if (typeof value2 === "object" && value2 !== null) {
179
+ const proto = Object.getPrototypeOf(value2);
180
+ if (proto !== Object.prototype && proto !== null) return value2;
181
+ return Object.fromEntries(Object.entries(value2).map(([key2, item]) => [key2, clonePlain(item)]));
163
182
  }
164
- return value;
183
+ return value2;
165
184
  }
166
185
  async function loadConfiguration(configPath) {
167
186
  if (!existsSync2(configPath)) return {};
@@ -184,12 +203,14 @@ import { existsSync as existsSync3, readFileSync as readFileSync2, statSync } fr
184
203
  var FIRST = "abcdefghijklmnopqrstuvwxyz";
185
204
  var REST = `${FIRST}0123456789`;
186
205
  var CLASS_ATTRIBUTE = /^(class|o:[^\s=]*-class[^\s=]*)$/i;
206
+ var ALPINE_EXPRESSION = /^(:|x-bind:)class$/i;
207
+ var ALPINE_CLASS_LIST = /^x-transition:(enter|leave)(-start|-end)?$/i;
187
208
  var RAW_TEXT = /* @__PURE__ */ new Set(["script", "style", "textarea", "title", "xmp", "noembed", "noframes"]);
188
209
  function rewriteHtml(html, map) {
189
210
  if (Object.keys(map).length === 0) return html;
190
- return replaceHtmlClasses(html, (token2) => map[decodeEntities(token2)] ?? token2);
211
+ return replaceHtmlClasses(html, (token2) => map[decodeEntities(token2)] ?? token2, { alpine: true });
191
212
  }
192
- function replaceHtmlClasses(html, replace) {
213
+ function replaceHtmlClasses(html, replace, options = {}) {
193
214
  let out = "";
194
215
  let last = 0;
195
216
  let i = 0;
@@ -222,13 +243,21 @@ function replaceHtmlClasses(html, replace) {
222
243
  const quote2 = html[j] === '"' || html[j] === "'" ? html[j] : "";
223
244
  const valueStart = quote2 === "" ? j : j + 1;
224
245
  const valueEnd = quote2 === "" ? unquotedEnd(html, valueStart) : indexOrEnd(html, quote2, valueStart);
225
- if (CLASS_ATTRIBUTE.test(name)) {
226
- const value = html.slice(valueStart, valueEnd);
227
- const renamed = value.replace(/\S+/g, replace);
228
- if (renamed !== value) {
246
+ if (CLASS_ATTRIBUTE.test(name) || options.alpine && ALPINE_CLASS_LIST.test(name)) {
247
+ const value2 = html.slice(valueStart, valueEnd);
248
+ const renamed = value2.replace(/\S+/g, replace);
249
+ if (renamed !== value2) {
229
250
  out += html.slice(last, valueStart) + renamed;
230
251
  last = valueEnd;
231
252
  }
253
+ } else if (options.alpine && ALPINE_EXPRESSION.test(name)) {
254
+ const raw = html.slice(valueStart, valueEnd);
255
+ const decoded = decodeEntities(raw);
256
+ const renamed = rewriteClassExpression(decoded, replace);
257
+ if (renamed !== decoded) {
258
+ out += html.slice(last, valueStart) + (raw === decoded ? renamed : encodeAttribute(renamed));
259
+ last = valueEnd;
260
+ }
232
261
  }
233
262
  j = quote2 === "" ? valueEnd : valueEnd + 1;
234
263
  }
@@ -242,6 +271,97 @@ function replaceHtmlClasses(html, replace) {
242
271
  }
243
272
  return out + html.slice(last);
244
273
  }
274
+ var ATTRIBUTE_ESCAPES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" };
275
+ var encodeAttribute = (value2) => value2.replace(/[&<>"']/g, (character) => ATTRIBUTE_ESCAPES[character]);
276
+ function rewriteClassExpression(expression, replace) {
277
+ let out = "";
278
+ let previous = "";
279
+ let i = 0;
280
+ while (i < expression.length) {
281
+ const character = expression[i];
282
+ if (character === "`") {
283
+ const end = templateEnd(expression, i);
284
+ out += `\`${rewriteTemplate(expression.slice(i + 1, end), replace)}${expression[end] ?? ""}`;
285
+ previous = character;
286
+ i = end + 1;
287
+ continue;
288
+ }
289
+ if (character === "'" || character === '"') {
290
+ let end = i + 1;
291
+ while (end < expression.length && expression[end] !== character) end += expression[end] === "\\" ? 2 : 1;
292
+ const body = expression.slice(i + 1, end);
293
+ const compared = /[=!]=$/.test(out.trimEnd()) || /^\s*[=!]=/.test(expression.slice(end + 1));
294
+ const untouched = compared || body.includes("\\");
295
+ out += character + (untouched ? body : body.replace(/\S+/g, replace)) + (expression[end] ?? "");
296
+ previous = character;
297
+ i = end + 1;
298
+ continue;
299
+ }
300
+ if (/[A-Za-z_$]/.test(character)) {
301
+ let end = i + 1;
302
+ while (end < expression.length && /[\w$-]/.test(expression[end]) && !(expression[end] === "-" && !/[\w$]/.test(expression[end + 1] ?? ""))) end++;
303
+ const word = expression.slice(i, end);
304
+ const isKey = (previous === "{" || previous === ",") && /^\s*:/.test(expression.slice(end));
305
+ const renamed = isKey ? replace(word) : word;
306
+ out += renamed === word || /^[A-Za-z_$][\w$]*$/.test(renamed) ? renamed : `'${renamed}'`;
307
+ previous = "word";
308
+ i = end;
309
+ continue;
310
+ }
311
+ if (!/\s/.test(character)) previous = character;
312
+ out += character;
313
+ i++;
314
+ }
315
+ return out;
316
+ }
317
+ function templateEnd(code, start) {
318
+ let i = start + 1;
319
+ while (i < code.length && code[i] !== "`") {
320
+ if (code[i] === "\\") i += 2;
321
+ else if (code.startsWith("${", i)) i = substitutionEnd(code, i + 2) + 1;
322
+ else i++;
323
+ }
324
+ return i;
325
+ }
326
+ function substitutionEnd(code, start) {
327
+ let depth = 0;
328
+ let i = start;
329
+ while (i < code.length) {
330
+ const character = code[i];
331
+ if (character === "'" || character === '"') {
332
+ i++;
333
+ while (i < code.length && code[i] !== character) i += code[i] === "\\" ? 2 : 1;
334
+ } else if (character === "`") {
335
+ i = templateEnd(code, i);
336
+ } else if (character === "{") {
337
+ depth++;
338
+ } else if (character === "}") {
339
+ if (depth === 0) return i;
340
+ depth--;
341
+ }
342
+ i++;
343
+ }
344
+ return i;
345
+ }
346
+ function rewriteTemplate(body, replace) {
347
+ if (body.includes("\\")) return body;
348
+ let out = "";
349
+ let i = 0;
350
+ while (i < body.length) {
351
+ const open = body.indexOf("${", i);
352
+ const text = body.slice(i, open === -1 ? body.length : open);
353
+ out += text.replace(/\S+/g, (word, offset) => {
354
+ const gluedBefore = offset === 0 && i > 0;
355
+ const gluedAfter = offset + word.length === text.length && open !== -1;
356
+ return gluedBefore || gluedAfter ? word : replace(word);
357
+ });
358
+ if (open === -1) break;
359
+ const close = substitutionEnd(body, open + 2);
360
+ out += `\${${rewriteClassExpression(body.slice(open + 2, close), replace)}}`;
361
+ i = close + 1;
362
+ }
363
+ return out;
364
+ }
245
365
  function attributeNameEnd(html, i) {
246
366
  let j = i + 1;
247
367
  while (j < html.length && !/[\s/>=]/.test(html[j])) j++;
@@ -257,9 +377,9 @@ function indexOrEnd(html, search, from) {
257
377
  return index === -1 ? html.length : index;
258
378
  }
259
379
  var NAMED = { amp: "&", lt: "<", gt: ">", quot: '"', apos: "'", nbsp: "\xA0" };
260
- function decodeEntities(value) {
261
- if (!value.includes("&")) return value;
262
- return value.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (entity, body) => {
380
+ function decodeEntities(value2) {
381
+ if (!value2.includes("&")) return value2;
382
+ return value2.replace(/&(#x[0-9a-f]+|#\d+|[a-z]+);/gi, (entity, body) => {
263
383
  if (body[0] === "#") return String.fromCodePoint(body[1] === "x" || body[1] === "X" ? Number.parseInt(body.slice(2), 16) : Number(body.slice(1)));
264
384
  return NAMED[body.toLowerCase()] ?? entity;
265
385
  });
@@ -435,7 +555,7 @@ var ViteHtml = class {
435
555
  var TRACKED = { "data-navigate-track": true };
436
556
  var CSS_PATH = /\.(css|less|sass|scss|styl|stylus|pcss|postcss)(\?[^.]*)?$/;
437
557
  var manifests = /* @__PURE__ */ new Map();
438
- var escapeAttribute = (value) => value.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
558
+ var escapeAttribute = (value2) => value2.replace(/&/g, "&amp;").replace(/"/g, "&quot;");
439
559
  var Vite = class {
440
560
  constructor(app) {
441
561
  this.app = app;
@@ -671,7 +791,7 @@ var Vite = class {
671
791
  }
672
792
  /** false/null/undefined are dropped, true is a bare attribute, anything else name="value". */
673
793
  #parseAttributes(attributes) {
674
- return Object.entries(attributes).filter(([, value]) => value !== false && value !== null && value !== void 0).map(([name, value]) => value === true ? name : `${name}="${escapeAttribute(String(value))}"`);
794
+ return Object.entries(attributes).filter(([, value2]) => value2 !== false && value2 !== null && value2 !== void 0).map(([name, value2]) => value2 === true ? name : `${name}="${escapeAttribute(String(value2))}"`);
675
795
  }
676
796
  };
677
797
  function currentVite() {
@@ -700,7 +820,7 @@ var Application2 = class _Application extends Container2 {
700
820
  this.singleton(ClassNames, () => new ClassNameMap(this));
701
821
  }
702
822
  base;
703
- version = "0.1.0-alpha.14";
823
+ version = "0.1.0-alpha.16";
704
824
  providers = [];
705
825
  bootingCallbacks = [];
706
826
  bootedCallbacks = [];
@@ -755,8 +875,8 @@ var Application2 = class _Application extends Container2 {
755
875
  runningInConsole() {
756
876
  return this.inConsole;
757
877
  }
758
- setRunningInConsole(value = true) {
759
- this.inConsole = value;
878
+ setRunningInConsole(value2 = true) {
879
+ this.inConsole = value2;
760
880
  }
761
881
  async register(provider) {
762
882
  const cls = typeof provider === "function" ? provider : provider.constructor;
@@ -804,6 +924,14 @@ var Application2 = class _Application extends Container2 {
804
924
  * A callback for the end of the process (the CLI after its command, the server on SIGTERM): close DB pools, Redis
805
925
  * clients and log files. Not in Laravel, whose PHP processes end with each request.
806
926
  */
927
+ /** The maintenance mode driver `app.maintenance.driver` names, bound by the Http service provider. */
928
+ maintenanceMode() {
929
+ return this.make(MaintenanceMode);
930
+ }
931
+ /** Whether `oriel down` put the app in maintenance mode (Laravel's isDownForMaintenance()). */
932
+ async isDownForMaintenance() {
933
+ return this.bound(MaintenanceMode) ? this.make(MaintenanceMode).active() : false;
934
+ }
807
935
  onShutdown(callback) {
808
936
  this.shutdownCallbacks.push(callback);
809
937
  }
@@ -852,35 +980,21 @@ var Application2 = class _Application extends Container2 {
852
980
  }
853
981
  }
854
982
  };
855
- var ClosureKernel = class {
856
- routes = /* @__PURE__ */ new Map();
857
- on(method, path, handler) {
858
- this.routes.set(`${method.toUpperCase()} ${path}`, handler);
859
- return this;
860
- }
861
- async handle(request2) {
862
- const handler = this.routes.get(`${request2.method} ${new URL(request2.url).pathname}`);
863
- if (!handler) return new Response("Not Found", { status: 404, headers: { "content-type": "text/plain; charset=utf-8" } });
864
- return toResponse(await handler(request2));
865
- }
866
- };
867
- function toResponse(output) {
868
- if (output instanceof Response) return output;
869
- if (output === void 0 || output === null) return new Response(null, { status: 204 });
870
- if (typeof output === "string") return new Response(output, { headers: { "content-type": "text/html; charset=utf-8" } });
871
- return Response.json(output);
872
- }
873
983
 
874
984
  // ../Http/dist/index.js
875
985
  import { createReadStream } from "fs";
876
986
  import { stat } from "fs/promises";
877
987
  import { basename } from "path";
878
988
  import { Readable } from "stream";
879
- import { readFile } from "fs/promises";
989
+ import { createHmac, timingSafeEqual } from "crypto";
990
+ import { existsSync as existsSync4 } from "fs";
991
+ import { mkdir, readFile, rm, writeFile } from "fs/promises";
992
+ import { dirname } from "path";
993
+ import { readFile as readFile2 } from "fs/promises";
880
994
  import { fileURLToPath } from "url";
881
- import { existsSync as existsSync4, lstatSync, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
882
- import { cp, mkdir, mkdtemp, rename, rm, writeFile } from "fs/promises";
883
- import { basename as basename2, dirname, join as join5, resolve as resolve2 } from "path";
995
+ import { existsSync as existsSync23, lstatSync, readdirSync as readdirSync2, statSync as statSync3 } from "fs";
996
+ import { cp, mkdir as mkdir2, mkdtemp, rename, rm as rm2, writeFile as writeFile2 } from "fs/promises";
997
+ import { basename as basename2, dirname as dirname2, join as join5, relative as relative2, resolve as resolve2 } from "path";
884
998
  import { createReadStream as createReadStream2 } from "fs";
885
999
  import { stat as stat2 } from "fs/promises";
886
1000
  import { Readable as Readable2 } from "stream";
@@ -889,13 +1003,13 @@ import { posix } from "path";
889
1003
  import { createServer } from "http";
890
1004
  import { Readable as Readable3 } from "stream";
891
1005
  import { pipeline } from "stream/promises";
892
- import { existsSync as existsSync42 } from "fs";
893
- import { mkdir as mkdir2, readFile as readFile2, writeFile as writeFile2 } from "fs/promises";
894
- import { dirname as dirname2, resolve as resolve3 } from "path";
895
- import { existsSync as existsSync23, readFileSync as readFileSync3 } from "fs";
1006
+ import { existsSync as existsSync5 } from "fs";
1007
+ import { mkdir as mkdir3, readFile as readFile3, writeFile as writeFile3 } from "fs/promises";
1008
+ import { dirname as dirname3, resolve as resolve3 } from "path";
1009
+ import { existsSync as existsSync32, readFileSync as readFileSync3 } from "fs";
896
1010
  import { join as join23 } from "path";
897
1011
  import * as util from "util";
898
- import { existsSync as existsSync32, statSync as statSync22, watch as watchPath } from "fs";
1012
+ import { existsSync as existsSync42, statSync as statSync22, watch as watchPath } from "fs";
899
1013
  import { join as join32 } from "path";
900
1014
  import { createServer as createServer2 } from "net";
901
1015
  import { spawn as spawnProcess } from "child_process";
@@ -952,14 +1066,14 @@ async function readBody(raw, limit) {
952
1066
  const chunks = [];
953
1067
  let size = 0;
954
1068
  for (; ; ) {
955
- const { done, value } = await reader.read();
1069
+ const { done, value: value2 } = await reader.read();
956
1070
  if (done) break;
957
- size += value.byteLength;
1071
+ size += value2.byteLength;
958
1072
  if (limit !== null && size > limit) {
959
1073
  await reader.cancel();
960
1074
  throw new HttpException(413, "Content Too Large");
961
1075
  }
962
- chunks.push(value);
1076
+ chunks.push(value2);
963
1077
  }
964
1078
  const out = new Uint8Array(size);
965
1079
  let offset = 0;
@@ -1003,10 +1117,10 @@ var HttpRedirectResponse = class {
1003
1117
  targetUrl;
1004
1118
  status;
1005
1119
  #headers;
1006
- with(key2, value) {
1120
+ with(key2, value2) {
1007
1121
  const session = optionalSession();
1008
1122
  if (session === void 0) return this;
1009
- if (typeof key2 === "string") session.flash(key2, value);
1123
+ if (typeof key2 === "string") session.flash(key2, value2);
1010
1124
  else for (const [name, item] of Object.entries(key2)) session.flash(name, item);
1011
1125
  return this;
1012
1126
  }
@@ -1033,14 +1147,14 @@ var HttpRedirectResponse = class {
1033
1147
  * Always a Set-Cookie header on this response (Laravel's RedirectResponse::withCookie). A bound CookieJar only
1034
1148
  * supplies the defaults (path, domain, secure, same-site); queueing would lose the cookie outside the web group.
1035
1149
  */
1036
- withCookie(name, value, minutes = 0) {
1150
+ withCookie(name, value2, minutes = 0) {
1037
1151
  const jar = optionalCookieJar();
1038
- const cookie = jar !== void 0 ? jar.make(name, value, minutes) : { name, value, minutes, path: "/", secure: false, httpOnly: true, sameSite: "lax" };
1152
+ const cookie = jar !== void 0 ? jar.make(name, value2, minutes) : { name, value: value2, minutes, path: "/", secure: false, httpOnly: true, sameSite: "lax" };
1039
1153
  this.#headers.append("Set-Cookie", serializeCookie(cookie));
1040
1154
  return this;
1041
1155
  }
1042
- header(name, value) {
1043
- this.#headers.set(name, value);
1156
+ header(name, value2) {
1157
+ this.#headers.set(name, value2);
1044
1158
  return this;
1045
1159
  }
1046
1160
  toResponse() {
@@ -1226,11 +1340,12 @@ var FormUploadedFile = class _FormUploadedFile {
1226
1340
  return inject(FilesystemManager).disk(disk).putFileAs(directory, this, name);
1227
1341
  }
1228
1342
  };
1343
+ var MAX_INPUT_NESTING = 64;
1229
1344
  var FORBIDDEN = /* @__PURE__ */ new Set(["__proto__", "prototype", "constructor"]);
1230
1345
  var INTEGER_KEY = /^(?:0|[1-9]\d*)$/;
1231
- var isPlainObject2 = (value) => {
1232
- if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
1233
- const prototype = Object.getPrototypeOf(value);
1346
+ var isPlainObject2 = (value2) => {
1347
+ if (typeof value2 !== "object" || value2 === null || Array.isArray(value2)) return false;
1348
+ const prototype = Object.getPrototypeOf(value2);
1234
1349
  return prototype === Object.prototype || prototype === null;
1235
1350
  };
1236
1351
  function parseBracketKey(name) {
@@ -1238,25 +1353,26 @@ function parseBracketKey(name) {
1238
1353
  if (open <= 0 || !name.endsWith("]")) return [name];
1239
1354
  const segments = [name.slice(0, open)];
1240
1355
  const rest = name.slice(open);
1241
- const matches2 = rest.match(/\[[^[\]]*\]/g);
1242
- if (matches2 === null || matches2.join("") !== rest) return [name];
1243
- for (const match of matches2) segments.push(match.slice(1, -1));
1356
+ const matches22 = rest.match(/\[[^[\]]*\]/g);
1357
+ if (matches22 === null || matches22.join("") !== rest) return [name];
1358
+ for (const match of matches22) segments.push(match.slice(1, -1));
1244
1359
  return segments;
1245
1360
  }
1246
- function normalizeLists(value) {
1247
- if (Array.isArray(value)) return value.map(normalizeLists);
1248
- if (!isPlainObject2(value)) return value;
1249
- const keys = Object.keys(value);
1361
+ function normalizeLists(value2) {
1362
+ if (Array.isArray(value2)) return value2.map(normalizeLists);
1363
+ if (!isPlainObject2(value2)) return value2;
1364
+ const keys = Object.keys(value2);
1250
1365
  const out = {};
1251
- for (const key2 of keys) out[key2] = normalizeLists(value[key2]);
1366
+ for (const key2 of keys) out[key2] = normalizeLists(value2[key2]);
1252
1367
  if (keys.length > 0 && keys.every((key2, index) => key2 === String(index))) return keys.map((key2) => out[key2]);
1253
1368
  return out;
1254
1369
  }
1255
1370
  function fromEntries(entries) {
1256
1371
  const root = {};
1257
1372
  const nextIndex = /* @__PURE__ */ new WeakMap();
1258
- for (const [name, value] of entries) {
1373
+ for (const [name, value2] of entries) {
1259
1374
  const segments = parseBracketKey(name);
1375
+ if (segments.length - 1 > MAX_INPUT_NESTING) throw new HttpException(400, "The request input is nested too deeply.");
1260
1376
  if (segments.some((segment) => FORBIDDEN.has(segment))) continue;
1261
1377
  let node = root;
1262
1378
  for (let i = 0; i < segments.length; i++) {
@@ -1269,7 +1385,7 @@ function fromEntries(entries) {
1269
1385
  nextIndex.set(node, Number(segment) + 1);
1270
1386
  }
1271
1387
  if (i === segments.length - 1) {
1272
- node[segment] = value;
1388
+ node[segment] = value2;
1273
1389
  break;
1274
1390
  }
1275
1391
  if (!isPlainObject2(node[segment])) node[segment] = {};
@@ -1278,38 +1394,38 @@ function fromEntries(entries) {
1278
1394
  }
1279
1395
  return normalizeLists(root);
1280
1396
  }
1281
- function sanitize(value) {
1282
- if (Array.isArray(value)) return value.map(sanitize);
1283
- if (!isPlainObject2(value)) return value;
1397
+ function sanitize(value2) {
1398
+ if (Array.isArray(value2)) return value2.map(sanitize);
1399
+ if (!isPlainObject2(value2)) return value2;
1284
1400
  const out = {};
1285
- for (const [key2, item] of Object.entries(value)) if (!FORBIDDEN.has(key2)) out[key2] = sanitize(item);
1401
+ for (const [key2, item] of Object.entries(value2)) if (!FORBIDDEN.has(key2)) out[key2] = sanitize(item);
1286
1402
  return out;
1287
1403
  }
1288
1404
  function mergeRecursive(base, override) {
1289
1405
  const out = { ...base };
1290
- for (const [key2, value] of Object.entries(override)) {
1406
+ for (const [key2, value2] of Object.entries(override)) {
1291
1407
  if (FORBIDDEN.has(key2)) continue;
1292
1408
  const current = out[key2];
1293
- out[key2] = (isPlainObject2(current) || Array.isArray(current)) && (isPlainObject2(value) || Array.isArray(value)) ? normalizeLists(mergeRecursive({ ...current }, { ...value })) : value;
1409
+ out[key2] = (isPlainObject2(current) || Array.isArray(current)) && (isPlainObject2(value2) || Array.isArray(value2)) ? normalizeLists(mergeRecursive({ ...current }, { ...value2 })) : value2;
1294
1410
  }
1295
1411
  return out;
1296
1412
  }
1297
- function isBlank(value) {
1298
- if (value === null || value === void 0) return true;
1299
- if (typeof value === "string") return value.trim() === "";
1300
- if (Array.isArray(value)) return value.length === 0;
1301
- if (isPlainObject2(value)) return Object.keys(value).length === 0;
1413
+ function isBlank(value2) {
1414
+ if (value2 === null || value2 === void 0) return true;
1415
+ if (typeof value2 === "string") return value2.trim() === "";
1416
+ if (Array.isArray(value2)) return value2.length === 0;
1417
+ if (isPlainObject2(value2)) return Object.keys(value2).length === 0;
1302
1418
  return false;
1303
1419
  }
1304
1420
  function transformLeaves(tree, transform, prefix = "") {
1305
1421
  const out = {};
1306
- for (const [key2, value] of Object.entries(tree)) out[key2] = transformValue(`${prefix}${key2}`, value, transform);
1422
+ for (const [key2, value2] of Object.entries(tree)) out[key2] = transformValue(`${prefix}${key2}`, value2, transform);
1307
1423
  return out;
1308
1424
  }
1309
- function transformValue(path, value, transform) {
1310
- if (Array.isArray(value)) return value.map((item, index) => transformValue(`${path}.${index}`, item, transform));
1311
- if (isPlainObject2(value)) return transformLeaves(value, transform, `${path}.`);
1312
- return transform(path, value);
1425
+ function transformValue(path, value2, transform) {
1426
+ if (Array.isArray(value2)) return value2.map((item, index) => transformValue(`${path}.${index}`, item, transform));
1427
+ if (isPlainObject2(value2)) return transformLeaves(value2, transform, `${path}.`);
1428
+ return transform(path, value2);
1313
1429
  }
1314
1430
  var TRUE_VALUES = /* @__PURE__ */ new Set(["1", "true", "on", "yes"]);
1315
1431
  var normalizeIp = (ip) => ip.trim().replace(/^::ffff:(\d+\.\d+\.\d+\.\d+)$/i, "$1");
@@ -1325,11 +1441,11 @@ function ipMatches(ip, patterns) {
1325
1441
  if (!pattern.includes("/")) return normalizeIp(pattern) === address;
1326
1442
  const [range, bits] = pattern.split("/");
1327
1443
  const base = ipv4ToNumber(range);
1328
- const value = ipv4ToNumber(address);
1444
+ const value2 = ipv4ToNumber(address);
1329
1445
  const size = Number(bits);
1330
- if (base === void 0 || value === void 0 || !(size >= 0 && size <= 32)) return false;
1446
+ if (base === void 0 || value2 === void 0 || !(size >= 0 && size <= 32)) return false;
1331
1447
  const mask = size === 0 ? 0 : ~0 << 32 - size >>> 0;
1332
- return (base & mask) >>> 0 === (value & mask) >>> 0;
1448
+ return (base & mask) >>> 0 === (value2 & mask) >>> 0;
1333
1449
  });
1334
1450
  }
1335
1451
  var IncomingRequest = class {
@@ -1339,7 +1455,12 @@ var IncomingRequest = class {
1339
1455
  this.#trustedProxies = options.trustedProxies ?? [];
1340
1456
  this.#maxBodySize = options.maxBodySize === void 0 ? 8 * 1024 * 1024 : options.maxBodySize;
1341
1457
  this.#maxJsonDepth = options.maxJsonDepth === void 0 ? 512 : options.maxJsonDepth;
1342
- this.#query = fromEntries(this.#url.searchParams.entries());
1458
+ try {
1459
+ this.#query = fromEntries(this.#url.searchParams.entries());
1460
+ } catch (error) {
1461
+ this.#query = {};
1462
+ this.#inputError = error;
1463
+ }
1343
1464
  this.#method = raw.method.toUpperCase();
1344
1465
  }
1345
1466
  raw;
@@ -1354,12 +1475,16 @@ var IncomingRequest = class {
1354
1475
  #method;
1355
1476
  #cookies;
1356
1477
  #loading;
1478
+ #inputError;
1357
1479
  #userResolver;
1480
+ /** What the last validate() returned (a FormRequest's writes it too), for safe(). */
1481
+ [VALIDATED_INPUT];
1358
1482
  /** Reads and parses the body (JSON, urlencoded or multipart) once, then applies method spoofing. */
1359
1483
  load() {
1360
1484
  return this.#loading ??= this.#load();
1361
1485
  }
1362
1486
  async #load() {
1487
+ if (this.#inputError !== void 0) throw this.#inputError;
1363
1488
  const method = this.raw.method.toUpperCase();
1364
1489
  if (method !== "GET" && method !== "HEAD" && this.raw.body !== null) {
1365
1490
  const type = (this.raw.headers.get("content-type") ?? "").toLowerCase();
@@ -1381,7 +1506,8 @@ var IncomingRequest = class {
1381
1506
  } else {
1382
1507
  await this.#parseForm(await new Response(bytes, { headers: { "content-type": this.raw.headers.get("content-type") ?? "" } }).formData());
1383
1508
  }
1384
- } catch {
1509
+ } catch (error) {
1510
+ if (error instanceof HttpException) throw error;
1385
1511
  }
1386
1512
  }
1387
1513
  }
@@ -1407,15 +1533,15 @@ var IncomingRequest = class {
1407
1533
  async #parseForm(form) {
1408
1534
  const fields = [];
1409
1535
  const files = [];
1410
- for (const [name, value] of form.entries()) {
1411
- if (typeof value === "string") fields.push([name, value]);
1412
- else if (!((value.name ?? "") === "" && value.size === 0)) files.push([name, await FormUploadedFile.fromFile(value)]);
1536
+ for (const [name, value2] of form.entries()) {
1537
+ if (typeof value2 === "string") fields.push([name, value2]);
1538
+ else if (!((value2.name ?? "") === "" && value2.size === 0)) files.push([name, await FormUploadedFile.fromFile(value2)]);
1413
1539
  }
1414
1540
  this.#body = fromEntries(fields);
1415
1541
  this.#files = fromEntries(files);
1416
1542
  }
1417
- #string(value) {
1418
- return typeof value === "string" && value !== "" ? value : void 0;
1543
+ #string(value2) {
1544
+ return typeof value2 === "string" && value2 !== "" ? value2 : void 0;
1419
1545
  }
1420
1546
  method() {
1421
1547
  return this.#method;
@@ -1551,8 +1677,8 @@ var IncomingRequest = class {
1551
1677
  }
1552
1678
  /** Laravel's string(): the input as a Stringable (the default when it is missing or null): request().string('q').trim(). */
1553
1679
  string(key2, defaultValue = "") {
1554
- const value = this.input(key2);
1555
- return Str.of(value === void 0 || value === null ? defaultValue : value);
1680
+ const value2 = this.input(key2);
1681
+ return Str.of(value2 === void 0 || value2 === null ? defaultValue : value2);
1556
1682
  }
1557
1683
  /** Laravel's str(): string() under its short name. */
1558
1684
  str(key2, defaultValue = "") {
@@ -1560,19 +1686,19 @@ var IncomingRequest = class {
1560
1686
  }
1561
1687
  /** PHP's FILTER_VALIDATE_BOOLEAN: '1', 'true', 'on', 'yes' (any case) and true are true. */
1562
1688
  boolean(key2, defaultValue = false) {
1563
- const value = this.input(key2);
1564
- if (value === void 0) return defaultValue;
1565
- if (typeof value === "boolean") return value;
1566
- if (typeof value === "number") return value === 1;
1567
- return typeof value === "string" && TRUE_VALUES.has(value.trim().toLowerCase());
1689
+ const value2 = this.input(key2);
1690
+ if (value2 === void 0) return defaultValue;
1691
+ if (typeof value2 === "boolean") return value2;
1692
+ if (typeof value2 === "number") return value2 === 1;
1693
+ return typeof value2 === "string" && TRUE_VALUES.has(value2.trim().toLowerCase());
1568
1694
  }
1569
1695
  /** PHP's intval: leading digits, else 0. */
1570
1696
  integer(key2, defaultValue = 0) {
1571
- const value = this.input(key2);
1572
- if (value === void 0) return defaultValue;
1573
- if (typeof value === "number") return Number.isFinite(value) ? Math.trunc(value) : 0;
1574
- if (typeof value === "boolean") return value ? 1 : 0;
1575
- const parsed = Number.parseInt(String(value).trim(), 10);
1697
+ const value2 = this.input(key2);
1698
+ if (value2 === void 0) return defaultValue;
1699
+ if (typeof value2 === "number") return Number.isFinite(value2) ? Math.trunc(value2) : 0;
1700
+ if (typeof value2 === "boolean") return value2 ? 1 : 0;
1701
+ const parsed = Number.parseInt(String(value2).trim(), 10);
1576
1702
  return Number.isNaN(parsed) ? 0 : parsed;
1577
1703
  }
1578
1704
  /** Adds or replaces top-level body values. */
@@ -1587,12 +1713,12 @@ var IncomingRequest = class {
1587
1713
  return this;
1588
1714
  }
1589
1715
  file(key2) {
1590
- const value = Arr.get(this.#files, key2);
1591
- return value instanceof FormUploadedFile ? value : void 0;
1716
+ const value2 = Arr.get(this.#files, key2);
1717
+ return value2 instanceof FormUploadedFile ? value2 : void 0;
1592
1718
  }
1593
1719
  hasFile(key2) {
1594
- const value = Arr.get(this.#files, key2);
1595
- return value instanceof FormUploadedFile || Array.isArray(value) && value.some((item) => item instanceof FormUploadedFile);
1720
+ const value2 = Arr.get(this.#files, key2);
1721
+ return value2 instanceof FormUploadedFile || Array.isArray(value2) && value2.some((item) => item instanceof FormUploadedFile);
1596
1722
  }
1597
1723
  allFiles() {
1598
1724
  return { ...this.#files };
@@ -1608,12 +1734,12 @@ var IncomingRequest = class {
1608
1734
  if (index === -1) continue;
1609
1735
  const name = part.slice(0, index).trim();
1610
1736
  if (name === "" || Object.hasOwn(cookies, name)) continue;
1611
- let value = part.slice(index + 1).trim();
1612
- if (value.startsWith('"') && value.endsWith('"')) value = value.slice(1, -1);
1737
+ let value2 = part.slice(index + 1).trim();
1738
+ if (value2.startsWith('"') && value2.endsWith('"')) value2 = value2.slice(1, -1);
1613
1739
  try {
1614
- cookies[name] = decodeURIComponent(value);
1740
+ cookies[name] = decodeURIComponent(value2);
1615
1741
  } catch {
1616
- cookies[name] = value;
1742
+ cookies[name] = value2;
1617
1743
  }
1618
1744
  }
1619
1745
  this.#cookies = cookies;
@@ -1650,7 +1776,16 @@ var IncomingRequest = class {
1650
1776
  * rules: `validate({ title: 'required|string' })` is `{ title: string }`.
1651
1777
  */
1652
1778
  validate(rules, messages, attributes) {
1653
- return inject(ValidationFactory).make(this.all(), rules, messages, attributes).validated();
1779
+ return inject(ValidationFactory).make(this.all(), rules, messages, attributes).validated().then((data) => {
1780
+ this[VALIDATED_INPUT] = data;
1781
+ return data;
1782
+ });
1783
+ }
1784
+ /** What the last validate() (this one, or a FormRequest's) returned, as a ValidatedInput; throws before any. */
1785
+ safe() {
1786
+ const data = this[VALIDATED_INPUT];
1787
+ if (data === void 0) throw new HttpServerError("safe() reads what validate() returned: validate the request first.");
1788
+ return new ValidatedInput(data);
1654
1789
  }
1655
1790
  #currentRoute() {
1656
1791
  const container2 = currentContainer();
@@ -1659,8 +1794,8 @@ var IncomingRequest = class {
1659
1794
  };
1660
1795
  function structuredCloneInput(tree) {
1661
1796
  const out = {};
1662
- for (const [key2, value] of Object.entries(tree)) {
1663
- out[key2] = isPlainObject2(value) ? structuredCloneInput(value) : Array.isArray(value) ? [...value] : value;
1797
+ for (const [key2, value2] of Object.entries(tree)) {
1798
+ out[key2] = isPlainObject2(value2) ? structuredCloneInput(value2) : Array.isArray(value2) ? [...value2] : value2;
1664
1799
  }
1665
1800
  return out;
1666
1801
  }
@@ -1744,32 +1879,282 @@ var HttpResponseFactory = class {
1744
1879
  return new Response(body, { status: 200, headers: merged });
1745
1880
  }
1746
1881
  };
1747
- var ConvertEmptyStringsToNull = class {
1882
+ var TRIM = /^[\s\uFEFF\u200B\u200E]+|[\s\uFEFF\u200B\u200E]+$/g;
1883
+ var TrimStrings = class _TrimStrings {
1884
+ static #skip = [];
1885
+ /** Dotted input keys left untouched. Override in a subclass to change. */
1886
+ except = ["current_password", "password", "password_confirmation"];
1887
+ /** Leaves a request untouched when the callback returns true, in every app until flushState() (Laravel's skipWhen()). */
1888
+ static skipWhen(callback) {
1889
+ _TrimStrings.#skip.push(callback);
1890
+ }
1891
+ /** Forgets the skipWhen() callbacks. */
1892
+ static flushState() {
1893
+ _TrimStrings.#skip = [];
1894
+ }
1748
1895
  async handle(request2, next) {
1749
- if (request2 instanceof IncomingRequest) request2.transformInput((_key, value) => value === "" ? null : value);
1896
+ if (request2 instanceof IncomingRequest) {
1897
+ const configured = configuredExceptions("http.trim_strings_except");
1898
+ const skips = [..._TrimStrings.#skip, ...configured.filter((entry) => typeof entry === "function")];
1899
+ if (!skips.some((skip) => skip(request2))) {
1900
+ const except = [...this.except, ...configured.filter((entry) => typeof entry === "string")];
1901
+ request2.transformInput((key2, value2) => typeof value2 === "string" && !except.includes(key2) ? value2.replace(TRIM, "") : value2);
1902
+ }
1903
+ }
1750
1904
  return next(request2);
1751
1905
  }
1752
1906
  };
1753
- var TRIM = /^[\s\uFEFF\u200B\u200E]+|[\s\uFEFF\u200B\u200E]+$/g;
1754
- var TrimStrings = class {
1755
- /** Dotted input keys left untouched. Override in a subclass to change. */
1756
- except = ["current_password", "password", "password_confirmation"];
1907
+ function configuredExceptions(key2) {
1908
+ const container2 = currentContainer();
1909
+ if (container2 === void 0 || !container2.bound(ConfigRepository)) return [];
1910
+ return container2.make(ConfigRepository).get(key2, []) ?? [];
1911
+ }
1912
+ var ConvertEmptyStringsToNull = class _ConvertEmptyStringsToNull {
1913
+ static #skip = [];
1914
+ /** Leaves a request untouched when the callback returns true, in every app until flushState() (Laravel's skipWhen()). */
1915
+ static skipWhen(callback) {
1916
+ _ConvertEmptyStringsToNull.#skip.push(callback);
1917
+ }
1918
+ /** Forgets the skipWhen() callbacks. */
1919
+ static flushState() {
1920
+ _ConvertEmptyStringsToNull.#skip = [];
1921
+ }
1757
1922
  async handle(request2, next) {
1758
1923
  if (request2 instanceof IncomingRequest) {
1759
- request2.transformInput(
1760
- (key2, value) => typeof value === "string" && !this.except.includes(key2) ? value.replace(TRIM, "") : value
1761
- );
1924
+ const configured = configuredExceptions("http.convert_empty_strings_except").filter((entry) => typeof entry === "function");
1925
+ if (![..._ConvertEmptyStringsToNull.#skip, ...configured].some((skip) => skip(request2))) {
1926
+ request2.transformInput((_key, value2) => value2 === "" ? null : value2);
1927
+ }
1762
1928
  }
1763
1929
  return next(request2);
1764
1930
  }
1765
1931
  };
1932
+ var CORS_DEFAULTS = {
1933
+ paths: ["api/*"],
1934
+ allowed_methods: ["*"],
1935
+ allowed_origins: ["*"],
1936
+ allowed_origins_patterns: [],
1937
+ allowed_headers: ["*"],
1938
+ exposed_headers: [],
1939
+ max_age: 0,
1940
+ supports_credentials: false
1941
+ };
1942
+ var CORS_CONFIG_STUB = `export default {
1943
+ paths: ['api/*'],
1944
+ allowed_methods: ['*'],
1945
+ allowed_origins: ['*'],
1946
+ allowed_origins_patterns: [],
1947
+ allowed_headers: ['*'],
1948
+ exposed_headers: [],
1949
+ max_age: 0,
1950
+ supports_credentials: false,
1951
+ }
1952
+ `;
1953
+ var HandleCors = class {
1954
+ async handle(request2, next) {
1955
+ const options = corsOptions();
1956
+ if (!options.paths.some((path) => matches(request2, path))) return next(request2);
1957
+ const cors = new Cors(options);
1958
+ if (request2.method() === "OPTIONS" && request2.header("access-control-request-method") !== void 0) {
1959
+ const headers2 = new Headers();
1960
+ cors.preflightHeaders(request2, headers2);
1961
+ vary(headers2, "Access-Control-Request-Method");
1962
+ return new Response(null, { status: 204, headers: headers2 });
1963
+ }
1964
+ const response2 = await next(request2);
1965
+ const headers = new Headers();
1966
+ if (request2.method() === "OPTIONS") vary(headers, "Access-Control-Request-Method");
1967
+ cors.actualHeaders(request2, headers);
1968
+ return withHeaders(response2, headers);
1969
+ }
1970
+ };
1971
+ function corsOptions() {
1972
+ const container2 = currentContainer();
1973
+ const configured = container2?.bound(ConfigRepository) ? container2.make(ConfigRepository).get("cors") : void 0;
1974
+ return { ...CORS_DEFAULTS, ...configured };
1975
+ }
1976
+ function matches(request2, path) {
1977
+ const pattern = path === "/" ? path : path.replace(/^\/+|\/+$/g, "");
1978
+ return request2.is(pattern) || request2.fullUrl() === path;
1979
+ }
1980
+ var wildcard = (origin) => new RegExp(`^${origin.replace(/[.*+?^${}()|[\]\\]/g, "\\$&").replace(/\\\*/g, ".*")}$`, "u");
1981
+ var Cors = class {
1982
+ constructor(options) {
1983
+ this.options = options;
1984
+ this.#allowAllOrigins = options.allowed_origins.includes("*");
1985
+ this.#origins = options.allowed_origins.filter((origin) => !origin.includes("*"));
1986
+ this.#patterns = [
1987
+ ...options.allowed_origins.filter((origin) => origin !== "*" && origin.includes("*")).map(wildcard),
1988
+ ...options.allowed_origins_patterns.map((pattern) => pattern instanceof RegExp ? pattern : new RegExp(pattern, "u"))
1989
+ ];
1990
+ }
1991
+ options;
1992
+ #allowAllOrigins;
1993
+ #origins;
1994
+ #patterns;
1995
+ preflightHeaders(request2, headers) {
1996
+ this.#origin(request2, headers);
1997
+ if (!headers.has("access-control-allow-origin")) return;
1998
+ this.#credentials(headers);
1999
+ this.#methods(request2, headers);
2000
+ this.#allowedHeaders(request2, headers);
2001
+ if (this.options.max_age !== null && this.options.max_age !== void 0) {
2002
+ headers.set("Access-Control-Max-Age", String(this.options.max_age));
2003
+ }
2004
+ }
2005
+ actualHeaders(request2, headers) {
2006
+ this.#origin(request2, headers);
2007
+ if (!headers.has("access-control-allow-origin")) return;
2008
+ this.#credentials(headers);
2009
+ if (this.options.exposed_headers.length > 0) headers.set("Access-Control-Expose-Headers", this.options.exposed_headers.join(", "));
2010
+ }
2011
+ #origin(request2, headers) {
2012
+ const origin = request2.header("origin");
2013
+ if (this.#allowAllOrigins && !this.options.supports_credentials) {
2014
+ headers.set("Access-Control-Allow-Origin", "*");
2015
+ } else if (!this.#allowAllOrigins && this.#patterns.length === 0 && this.#origins.length === 1) {
2016
+ headers.set("Access-Control-Allow-Origin", this.#origins[0]);
2017
+ } else {
2018
+ if (origin !== void 0 && this.#allowed(origin)) headers.set("Access-Control-Allow-Origin", origin);
2019
+ vary(headers, "Origin");
2020
+ }
2021
+ }
2022
+ #allowed(origin) {
2023
+ return this.#allowAllOrigins || this.#origins.includes(origin) || this.#patterns.some((pattern) => pattern.test(origin));
2024
+ }
2025
+ #credentials(headers) {
2026
+ if (this.options.supports_credentials) headers.set("Access-Control-Allow-Credentials", "true");
2027
+ }
2028
+ #methods(request2, headers) {
2029
+ let methods = this.options.allowed_methods.map((method) => method.toUpperCase()).join(", ");
2030
+ if (this.options.allowed_methods.includes("*")) {
2031
+ methods = (request2.header("access-control-request-method") ?? "").toUpperCase();
2032
+ vary(headers, "Access-Control-Request-Method");
2033
+ }
2034
+ if (methods !== "") headers.set("Access-Control-Allow-Methods", methods);
2035
+ }
2036
+ #allowedHeaders(request2, headers) {
2037
+ let allowed = this.options.allowed_headers.join(", ");
2038
+ if (this.options.allowed_headers.includes("*")) {
2039
+ allowed = request2.header("access-control-request-headers") ?? "";
2040
+ vary(headers, "Access-Control-Request-Headers");
2041
+ }
2042
+ if (allowed !== "") headers.set("Access-Control-Allow-Headers", allowed);
2043
+ }
2044
+ };
2045
+ function vary(headers, name) {
2046
+ const current = headers.get("vary");
2047
+ if (current === null || current === "") headers.set("Vary", name);
2048
+ else if (!current.split(",").some((entry) => entry.trim().toLowerCase() === name.toLowerCase())) headers.set("Vary", `${current}, ${name}`);
2049
+ }
2050
+ function withHeaders(response2, cors) {
2051
+ const apply = (target2) => {
2052
+ for (const [name, value2] of cors) {
2053
+ if (name === "vary") for (const entry of value2.split(",")) vary(target2, entry.trim());
2054
+ else target2.set(name, value2);
2055
+ }
2056
+ };
2057
+ try {
2058
+ apply(response2.headers);
2059
+ return response2;
2060
+ } catch {
2061
+ const copy = new Headers(response2.headers);
2062
+ apply(copy);
2063
+ return new Response(response2.body, { status: response2.status, statusText: response2.statusText, headers: copy });
2064
+ }
2065
+ }
2066
+ var BYPASS_COOKIE = "oriel_maintenance";
2067
+ var BYPASS_SECONDS = 12 * 60 * 60;
2068
+ var mac = (expiresAt, secret) => createHmac("sha256", secret).update(String(expiresAt)).digest("hex");
2069
+ function bypassCookieValue(secret, now = Date.now()) {
2070
+ const expiresAt = Math.floor(now / 1e3) + BYPASS_SECONDS;
2071
+ return { value: Buffer.from(JSON.stringify({ expires_at: expiresAt, mac: mac(expiresAt, secret) })).toString("base64"), expiresAt };
2072
+ }
2073
+ function isValidBypassCookie(value2, secret, now = Date.now()) {
2074
+ if (value2 === void 0 || value2 === "") return false;
2075
+ let payload;
2076
+ try {
2077
+ payload = JSON.parse(Buffer.from(value2, "base64").toString("utf8"));
2078
+ } catch {
2079
+ return false;
2080
+ }
2081
+ if (typeof payload !== "object" || payload === null) return false;
2082
+ const { expires_at: expiresAt, mac: given } = payload;
2083
+ if (typeof expiresAt !== "number" || typeof given !== "string") return false;
2084
+ const expected = Buffer.from(mac(expiresAt, secret));
2085
+ const actual = Buffer.from(given);
2086
+ return expected.length === actual.length && timingSafeEqual(expected, actual) && expiresAt >= Math.floor(now / 1e3);
2087
+ }
2088
+ var trimSlashes = (path) => path === "/" ? path : path.replace(/^\/+|\/+$/g, "");
2089
+ var PreventRequestsDuringMaintenance = class {
2090
+ /** Paths that answer while the app is down, as `request.is()` patterns. Override in a subclass to add some. */
2091
+ except = [];
2092
+ async handle(request2, next) {
2093
+ const container2 = currentContainer();
2094
+ if (container2 === void 0 || !container2.bound(MaintenanceMode)) return next(request2);
2095
+ const mode = container2.make(MaintenanceMode);
2096
+ if (!await mode.active()) return next(request2);
2097
+ if (this.inExceptArray(request2, container2)) return next(request2);
2098
+ const data = await mode.data() ?? { status: 503 };
2099
+ if (data.secret !== void 0 && request2.path() === data.secret) return this.bypassResponse(request2, data.secret, container2);
2100
+ if (data.secret !== void 0 && isValidBypassCookie(request2.cookie(BYPASS_COOKIE), data.secret)) return next(request2);
2101
+ if (data.redirect !== void 0) {
2102
+ const path = trimSlashes(data.redirect);
2103
+ if (request2.path() !== path) return redirectTo(request2, path);
2104
+ }
2105
+ const headers = this.headers(data);
2106
+ if (data.template !== void 0) {
2107
+ return new Response(data.template, { status: data.status ?? 503, headers: { ...headers, "content-type": "text/html; charset=utf-8" } });
2108
+ }
2109
+ throw new HttpException(data.status ?? 503, "Service Unavailable", headers);
2110
+ }
2111
+ /** The health route, the subclass's `except`, and `withMiddleware((m) => m.preventRequestsDuringMaintenance({ except }))`'s. */
2112
+ inExceptArray(request2, container2) {
2113
+ const configured = container2.bound(ConfigRepository) ? container2.make(ConfigRepository).get("http.maintenance_except", []) : [];
2114
+ const health = container2.bound(RoutingPaths) ? container2.make(RoutingPaths).health : void 0;
2115
+ const paths = [...this.except, ...configured ?? [], ...health === void 0 ? [] : [health]];
2116
+ return paths.some((path) => {
2117
+ const pattern = trimSlashes(path);
2118
+ return request2.fullUrl() === path || request2.is(pattern);
2119
+ });
2120
+ }
2121
+ headers(data) {
2122
+ const headers = {};
2123
+ if (data.retry !== void 0) headers["Retry-After"] = String(data.retry);
2124
+ if (data.refresh !== void 0) headers.Refresh = String(data.refresh);
2125
+ return headers;
2126
+ }
2127
+ /** A 302 to `/` with the bypass cookie, on the session's path and domain. */
2128
+ bypassResponse(request2, secret, container2) {
2129
+ const config = container2.bound(ConfigRepository) ? container2.make(ConfigRepository) : void 0;
2130
+ const path = config?.get("session.path", "/") ?? "/";
2131
+ const domain = config?.get("session.domain", null) ?? null;
2132
+ const { value: value2, expiresAt } = bypassCookieValue(secret);
2133
+ const cookie = [
2134
+ `${BYPASS_COOKIE}=${encodeURIComponent(value2)}`,
2135
+ `Expires=${new Date(expiresAt * 1e3).toUTCString()}`,
2136
+ `Max-Age=${BYPASS_SECONDS}`,
2137
+ `Path=${path}`,
2138
+ ...domain ? [`Domain=${domain}`] : [],
2139
+ "HttpOnly",
2140
+ "SameSite=Lax"
2141
+ ].join("; ");
2142
+ const response2 = redirectTo(request2, "/");
2143
+ response2.headers.append("Set-Cookie", cookie);
2144
+ return response2;
2145
+ }
2146
+ };
2147
+ function redirectTo(request2, path) {
2148
+ const origin = new URL(request2.url()).origin;
2149
+ return new Response(null, { status: 302, headers: { Location: path === "/" ? `${origin}/` : `${origin}/${path}` } });
2150
+ }
1766
2151
  var plainServerError = () => new Response("Server Error", { status: 500, headers: { "content-type": "text/plain; charset=utf-8" } });
1767
2152
  var Kernel = class {
1768
2153
  constructor(app) {
1769
2154
  this.app = app;
1770
2155
  }
1771
2156
  app;
1772
- #middleware = [TrimStrings, ConvertEmptyStringsToNull];
2157
+ #middleware = [HandleCors, PreventRequestsDuringMaintenance, TrimStrings, ConvertEmptyStringsToNull];
1773
2158
  #requests = /* @__PURE__ */ new WeakMap();
1774
2159
  getGlobalMiddleware() {
1775
2160
  return [...this.#middleware];
@@ -1786,6 +2171,10 @@ var Kernel = class {
1786
2171
  for (const cls of [...middleware].reverse()) if (!this.#middleware.includes(cls)) this.#middleware.unshift(cls);
1787
2172
  return this;
1788
2173
  }
2174
+ removeMiddleware(...middleware) {
2175
+ this.#middleware = this.#middleware.filter((cls) => !middleware.includes(cls));
2176
+ return this;
2177
+ }
1789
2178
  hasMiddleware(middleware) {
1790
2179
  return this.#middleware.includes(middleware);
1791
2180
  }
@@ -1908,31 +2297,166 @@ var Kernel = class {
1908
2297
  /** config('http.max_body_size'): bytes, or null for no limit. Anything else is a configuration error. */
1909
2298
  #maxBodySize() {
1910
2299
  if (!this.app.bound(ConfigRepository)) return 8 * 1024 * 1024;
1911
- const value = this.app.make(ConfigRepository).get("http.max_body_size", 8 * 1024 * 1024);
1912
- if (value === null) return null;
1913
- if (typeof value === "number" && Number.isFinite(value) && value >= 0) return value;
2300
+ const value2 = this.app.make(ConfigRepository).get("http.max_body_size", 8 * 1024 * 1024);
2301
+ if (value2 === null) return null;
2302
+ if (typeof value2 === "number" && Number.isFinite(value2) && value2 >= 0) return value2;
1914
2303
  throw new HttpServerError(
1915
- `Invalid http.max_body_size ${JSON.stringify(value) ?? String(value)}: use a number of bytes (0 or more), or null for no limit.`
2304
+ `Invalid http.max_body_size ${JSON.stringify(value2) ?? String(value2)}: use a number of bytes (0 or more), or null for no limit.`
1916
2305
  );
1917
2306
  }
1918
2307
  /** config('http.max_json_depth'): how deep a JSON body may nest, or null for no limit. */
1919
2308
  #maxJsonDepth() {
1920
2309
  if (!this.app.bound(ConfigRepository)) return 512;
1921
- const value = this.app.make(ConfigRepository).get("http.max_json_depth", 512);
1922
- if (value === null) return null;
1923
- if (typeof value === "number" && Number.isInteger(value) && value >= 1) return value;
2310
+ const value2 = this.app.make(ConfigRepository).get("http.max_json_depth", 512);
2311
+ if (value2 === null) return null;
2312
+ if (typeof value2 === "number" && Number.isInteger(value2) && value2 >= 1) return value2;
1924
2313
  throw new HttpServerError(
1925
- `Invalid http.max_json_depth ${JSON.stringify(value) ?? String(value)}: use a whole number (1 or more), or null for no limit.`
2314
+ `Invalid http.max_json_depth ${JSON.stringify(value2) ?? String(value2)}: use a whole number (1 or more), or null for no limit.`
1926
2315
  );
1927
2316
  }
1928
2317
  /** config('http.trusted_proxies'): an array, or a comma-separated string such as '*' or '10.0.0.0/8,::1'. */
1929
2318
  #trustedProxies() {
1930
2319
  if (!this.app.bound(ConfigRepository)) return [];
1931
- const value = this.app.make(ConfigRepository).get("http.trusted_proxies", []);
1932
- if (typeof value === "string") return value.split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
1933
- return Array.isArray(value) ? value.map(String) : [];
2320
+ const value2 = this.app.make(ConfigRepository).get("http.trusted_proxies", []);
2321
+ if (typeof value2 === "string") return value2.split(",").map((entry) => entry.trim()).filter((entry) => entry !== "");
2322
+ return Array.isArray(value2) ? value2.map(String) : [];
2323
+ }
2324
+ };
2325
+ var MAINTENANCE_CACHE_KEY = "oriel:foundation:down";
2326
+ var CacheMaintenanceMode = class {
2327
+ constructor(store2) {
2328
+ this.store = store2;
2329
+ }
2330
+ store;
2331
+ async activate(data) {
2332
+ await this.store().forever(MAINTENANCE_CACHE_KEY, data);
2333
+ }
2334
+ async deactivate() {
2335
+ await this.store().forget(MAINTENANCE_CACHE_KEY);
2336
+ }
2337
+ async active() {
2338
+ return this.store().has(MAINTENANCE_CACHE_KEY);
2339
+ }
2340
+ async data() {
2341
+ return this.store().get(MAINTENANCE_CACHE_KEY);
2342
+ }
2343
+ };
2344
+ var FileMaintenanceMode = class {
2345
+ constructor(path) {
2346
+ this.path = path;
2347
+ }
2348
+ path;
2349
+ async activate(data) {
2350
+ await mkdir(dirname(this.path), { recursive: true });
2351
+ await writeFile(this.path, JSON.stringify(data, null, 4));
2352
+ }
2353
+ async deactivate() {
2354
+ await rm(this.path, { force: true });
2355
+ }
2356
+ async active() {
2357
+ return existsSync4(this.path);
2358
+ }
2359
+ async data() {
2360
+ if (!existsSync4(this.path)) return void 0;
2361
+ try {
2362
+ return JSON.parse(await readFile(this.path, "utf8"));
2363
+ } catch {
2364
+ return { status: 503 };
2365
+ }
1934
2366
  }
1935
2367
  };
2368
+ var DOWN = "down {--redirect= : The path that users should be redirected to} {--render= : The view that should be prerendered for display during maintenance mode} {--retry= : The number of seconds after which the request may be retried} {--refresh= : The number of seconds after which the browser may refresh} {--secret= : The secret phrase that may be used to bypass maintenance mode} {--with-secret : Generate a random secret phrase that may be used to bypass maintenance mode} {--status=503 : The status code that should be used when returning the maintenance mode response}";
2369
+ function value(command, name) {
2370
+ const given = command.option(name);
2371
+ return given === void 0 || given === null || given === false || given === "" ? void 0 : String(given);
2372
+ }
2373
+ function registerMaintenanceCommands(kernel, app) {
2374
+ kernel.command(DOWN, async function() {
2375
+ const numbers = {};
2376
+ for (const name of ["status", "retry", "refresh"]) {
2377
+ const given = value(this, name);
2378
+ if (given === void 0) continue;
2379
+ if (!/^\d+$/.test(given)) {
2380
+ this.error(`The --${name} option must be a number.`);
2381
+ return 1;
2382
+ }
2383
+ numbers[name] = Number(given);
2384
+ }
2385
+ const mode = app.maintenanceMode();
2386
+ const secret = this.option("with-secret") === true ? Str.random(16) : value(this, "secret");
2387
+ if (await mode.active() && secret === void 0) {
2388
+ this.info("Application is already down.");
2389
+ return 0;
2390
+ }
2391
+ const data = { status: numbers.status ?? 503 };
2392
+ const redirect2 = value(this, "redirect");
2393
+ if (redirect2 !== void 0) data.redirect = redirect2 === "/" ? "/" : `/${redirect2.replace(/^\/+|\/+$/g, "")}`;
2394
+ if (numbers.retry !== void 0 && numbers.retry > 0) data.retry = numbers.retry;
2395
+ if (numbers.refresh !== void 0 && numbers.refresh > 0) data.refresh = numbers.refresh;
2396
+ if (secret !== void 0) data.secret = secret;
2397
+ const render = value(this, "render");
2398
+ if (render !== void 0) {
2399
+ if (!app.bound(ViewFactory)) {
2400
+ this.error("--render needs the View service provider.");
2401
+ return 1;
2402
+ }
2403
+ data.template = await app.make(ViewFactory).make(render, { retryAfter: data.retry }).render();
2404
+ }
2405
+ await mode.activate(data);
2406
+ this.info("Application is now in maintenance mode.");
2407
+ if (secret !== void 0) {
2408
+ const url2 = (app.bound(ConfigRepository) ? app.make(ConfigRepository).get("app.url", "http://localhost") : "http://localhost") ?? "http://localhost";
2409
+ this.info(`You may bypass maintenance mode via [${url2.replace(/\/+$/, "")}/${secret}].`);
2410
+ }
2411
+ return 0;
2412
+ }).purpose("Put the application into maintenance / demo mode");
2413
+ kernel.command("up", async function() {
2414
+ const mode = app.maintenanceMode();
2415
+ if (!await mode.active()) {
2416
+ this.info("Application is already up.");
2417
+ return 0;
2418
+ }
2419
+ await mode.deactivate();
2420
+ this.info("Application is now live.");
2421
+ return 0;
2422
+ }).purpose("Bring the application out of maintenance mode");
2423
+ }
2424
+ var escape = (value2) => value2.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
2425
+ var TrustHosts = class {
2426
+ async handle(request2, next) {
2427
+ const container2 = currentContainer();
2428
+ const app = container2?.bound(Application) ? container2.make(Application) : void 0;
2429
+ if (app !== void 0 && !app.environment("local") && !app.runningUnitTests()) {
2430
+ const host = new URL(request2.url()).hostname.toLowerCase();
2431
+ if (!this.hosts().some((trusted) => typeof trusted === "string" ? trusted.toLowerCase() === host : trusted.test(host))) {
2432
+ throw new HttpException(404, "Bad hostname provided.");
2433
+ }
2434
+ }
2435
+ return next(request2);
2436
+ }
2437
+ /** The trusted hosts and patterns (Laravel's hosts()). */
2438
+ hosts() {
2439
+ const container2 = currentContainer();
2440
+ const config = container2?.bound(ConfigRepository) ? container2.make(ConfigRepository) : void 0;
2441
+ const options = config?.get("http.trusted_hosts") ?? {};
2442
+ const listed = typeof options.at === "function" ? options.at() : options.at ?? [];
2443
+ const hosts = [...listed];
2444
+ if (options.at === void 0 || options.subdomains !== false) {
2445
+ const appHost = this.#applicationHost(config?.get("app.url"));
2446
+ if (appHost !== void 0) hosts.push(new RegExp(`^(.+\\.)?${escape(appHost)}$`, "i"));
2447
+ }
2448
+ return hosts;
2449
+ }
2450
+ #applicationHost(url2) {
2451
+ if (url2 === void 0 || url2 === "") return void 0;
2452
+ try {
2453
+ return new URL(url2).hostname.toLowerCase();
2454
+ } catch {
2455
+ return void 0;
2456
+ }
2457
+ }
2458
+ };
2459
+ var FRAMEWORK_GLOBALS = [HandleCors, PreventRequestsDuringMaintenance, TrimStrings, ConvertEmptyStringsToNull];
1936
2460
  var MiddlewareConfiguration = class {
1937
2461
  constructor(kernel, router, config) {
1938
2462
  this.kernel = kernel;
@@ -1950,6 +2474,38 @@ var MiddlewareConfiguration = class {
1950
2474
  this.kernel.prependMiddleware(...middleware);
1951
2475
  return this;
1952
2476
  }
2477
+ /** Takes middleware out of the global list (Laravel 11's remove()); one that isn't there is ignored. */
2478
+ remove(...middleware) {
2479
+ this.kernel.removeMiddleware(...middleware);
2480
+ return this;
2481
+ }
2482
+ /**
2483
+ * Fields TrimStrings leaves as sent (dotted keys, added to the password fields), and callbacks that leave a whole
2484
+ * request untouched. Stored in config('http.trim_strings_except'), so each app has its own.
2485
+ */
2486
+ trimStrings(options) {
2487
+ return this.#addTo("http.trim_strings_except", options.except ?? []);
2488
+ }
2489
+ /** Callbacks that leave a whole request's empty strings as sent. Stored in config('http.convert_empty_strings_except'). */
2490
+ convertEmptyStringsToNull(options) {
2491
+ return this.#addTo("http.convert_empty_strings_except", options.except ?? []);
2492
+ }
2493
+ /**
2494
+ * Laravel 11's trustHosts(): puts TrustHosts in the global list, after what was prepended and before the framework's
2495
+ * own middleware, and stores the options in config('http.trusted_hosts').
2496
+ */
2497
+ trustHosts(options = {}) {
2498
+ const list = this.kernel.getGlobalMiddleware().filter((cls) => cls !== TrustHosts);
2499
+ const at = list.findIndex((cls) => FRAMEWORK_GLOBALS.includes(cls));
2500
+ list.splice(at === -1 ? 0 : at, 0, TrustHosts);
2501
+ this.kernel.setGlobalMiddleware(list);
2502
+ this.config?.set("http.trusted_hosts", options);
2503
+ return this;
2504
+ }
2505
+ /** Paths that still answer while the app is down (Laravel 11's preventRequestsDuringMaintenance(except:)). */
2506
+ preventRequestsDuringMaintenance(options) {
2507
+ return this.#addTo("http.maintenance_except", options.except ?? []);
2508
+ }
1953
2509
  web(options) {
1954
2510
  return this.#modifyGroup("web", options);
1955
2511
  }
@@ -1980,6 +2536,11 @@ var MiddlewareConfiguration = class {
1980
2536
  this.config?.set("http.redirect_users_to", url2);
1981
2537
  return this;
1982
2538
  }
2539
+ #addTo(key2, entries) {
2540
+ const current = this.config?.get(key2, []) ?? [];
2541
+ this.config?.set(key2, [...current, ...entries]);
2542
+ return this;
2543
+ }
1983
2544
  /** Laravel's order: prepends, then the group minus removals, then appends. */
1984
2545
  #modifyGroup(name, { append = [], prepend = [], remove = [] }) {
1985
2546
  const current = this.router.getMiddlewareGroups()[name] ?? [];
@@ -2042,8 +2603,8 @@ var STATUS_TEXTS = {
2042
2603
  function statusText(status) {
2043
2604
  return STATUS_TEXTS[status] ?? (status >= 500 ? "Server Error" : "Error");
2044
2605
  }
2045
- function escapeHtml(value) {
2046
- return value.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
2606
+ function escapeHtml(value2) {
2607
+ return value2.replace(/[&<>"']/g, (char) => `&#${char.charCodeAt(0)};`);
2047
2608
  }
2048
2609
  function minimalPage(status, message) {
2049
2610
  const title = escapeHtml(message);
@@ -2071,7 +2632,7 @@ function stackFrames(error) {
2071
2632
  return frames;
2072
2633
  }
2073
2634
  async function excerpt(frame, radius = 5) {
2074
- const source = await readFile(frame.file, "utf8").catch(() => void 0);
2635
+ const source = await readFile2(frame.file, "utf8").catch(() => void 0);
2075
2636
  if (source === void 0) return void 0;
2076
2637
  const lines = source.split("\n");
2077
2638
  const start = Math.max(1, frame.line - radius);
@@ -2211,7 +2772,7 @@ var ErrorHandler = class {
2211
2772
  else if (this.shouldReturnJson(http, error)) response2 = this.#renderJson(error);
2212
2773
  else response2 = await this.#renderHtml(http, error);
2213
2774
  const headers = error?.headers;
2214
- return headers === void 0 ? response2 : withHeaders(response2, headers);
2775
+ return headers === void 0 ? response2 : withHeaders2(response2, headers);
2215
2776
  }
2216
2777
  /** An error with its own render(request) or toResponse(request) (Laravel's renderable exceptions / Responsable). */
2217
2778
  async #renderCustom(request2, error) {
@@ -2331,9 +2892,9 @@ var ErrorHandler = class {
2331
2892
  return currentContainer() ?? this.app;
2332
2893
  }
2333
2894
  };
2334
- function withHeaders(response2, extra) {
2895
+ function withHeaders2(response2, extra) {
2335
2896
  const headers = new Headers(response2.headers);
2336
- for (const [name, value] of Object.entries(extra)) headers.set(name, value);
2897
+ for (const [name, value2] of Object.entries(extra)) headers.set(name, value2);
2337
2898
  return new Response(response2.body, { status: response2.status, statusText: response2.statusText, headers });
2338
2899
  }
2339
2900
  var ExceptionsConfiguration = class {
@@ -2364,7 +2925,6 @@ function applyExceptionCallbacks(app, handler) {
2364
2925
  const configurator = new ExceptionsConfiguration(handler);
2365
2926
  for (const callback of app.make(ExceptionCallbacks)) callback(configurator);
2366
2927
  }
2367
- var HIDDEN_SEGMENT = /^\.|\.(ts|tsx|mts|cts)$|[. ]$/i;
2368
2928
  async function servePublicFile(publicPath, request2) {
2369
2929
  if (request2.method !== "GET" && request2.method !== "HEAD") return void 0;
2370
2930
  let pathname;
@@ -2377,7 +2937,7 @@ async function servePublicFile(publicPath, request2) {
2377
2937
  const root = resolve(publicPath);
2378
2938
  const file = resolve(root, `.${pathname}`);
2379
2939
  if (!file.startsWith(root + sep)) return void 0;
2380
- if (relative(root, file).split(/[\\/]/).some((segment) => HIDDEN_SEGMENT.test(segment))) return void 0;
2940
+ if (!isPublicAsset(relative(root, file))) return void 0;
2381
2941
  const info = await stat2(file).catch(() => void 0);
2382
2942
  if (info === void 0 || !info.isFile()) return void 0;
2383
2943
  const type = mimeFromExtension(file);
@@ -2475,16 +3035,16 @@ var NOT_FOUND_PATH = "/__oriel-export-not-found__";
2475
3035
  async function exportSite(app, options) {
2476
3036
  const output = resolve2(options.output);
2477
3037
  const publicPath = options.publicPath === false ? void 0 : resolve2(options.publicPath);
2478
- if (publicPath !== void 0 && existsSync4(join5(publicPath, "hot"))) {
3038
+ if (publicPath !== void 0 && existsSync23(join5(publicPath, "hot"))) {
2479
3039
  throw new Error("The Vite dev server is running (public/hot exists): stop `npm run dev`, build the assets with `npm run build`, then export.");
2480
3040
  }
2481
3041
  assertReplaceable(output);
2482
- const staging = await mkdtemp(join5(dirname(output), `.${basename2(output)}-`));
3042
+ const staging = await mkdtemp(join5(dirname2(output), `.${basename2(output)}-`));
2483
3043
  try {
2484
- if (publicPath !== void 0 && existsSync4(publicPath)) {
2485
- await cp(publicPath, staging, { recursive: true, filter: (source) => basename2(source) !== "hot" && !lstatSync(source).isSymbolicLink() });
3044
+ if (publicPath !== void 0 && existsSync23(publicPath)) {
3045
+ await cp(publicPath, staging, { recursive: true, filter: (source) => basename2(source) !== "hot" && !lstatSync(source).isSymbolicLink() && isPublicAsset(relative2(publicPath, source)) });
2486
3046
  }
2487
- const excluded = (path) => options.exclude.some((pattern) => wildcard(pattern).test(path));
3047
+ const excluded = (path) => options.exclude.some((pattern) => wildcard2(pattern).test(path));
2488
3048
  const isPublicFile = (path) => publicPath !== void 0 && path !== "/" && isFile(join5(publicPath, path));
2489
3049
  const queue = [.../* @__PURE__ */ new Set(["/", ...options.paths.map(rooted)])].filter((path) => path === "/" || !excluded(path));
2490
3050
  const seen = new Set(queue);
@@ -2517,18 +3077,18 @@ async function exportSite(app, options) {
2517
3077
  const notFound = await fetchPage(app, new URL(NOT_FOUND_PATH, options.baseUrl).href);
2518
3078
  const notFoundPage = notFound.status === 404 && isHtml(notFound.headers);
2519
3079
  if (notFoundPage) await writeInto(staging, "404.html", notFound.body);
2520
- await writeFile(join5(staging, MARKER), "");
2521
- await rm(output, { recursive: true, force: true });
3080
+ await writeFile2(join5(staging, MARKER), "");
3081
+ await rm2(output, { recursive: true, force: true });
2522
3082
  await rename(staging, output);
2523
3083
  return { pages, redirects, notFoundPage };
2524
3084
  } catch (error) {
2525
- await rm(staging, { recursive: true, force: true });
3085
+ await rm2(staging, { recursive: true, force: true });
2526
3086
  throw error;
2527
3087
  }
2528
3088
  }
2529
3089
  function assertReplaceable(output) {
2530
- if (!existsSync4(output)) return;
2531
- if (statSync3(output).isDirectory() && (existsSync4(join5(output, MARKER)) || readdirSync2(output).length === 0)) return;
3090
+ if (!existsSync23(output)) return;
3091
+ if (statSync3(output).isDirectory() && (existsSync23(join5(output, MARKER)) || readdirSync2(output).length === 0)) return;
2532
3092
  throw new Error(`[${output}] exists and wasn't made by oriel export: remove it, or export somewhere else with --output.`);
2533
3093
  }
2534
3094
  async function fetchPage(app, url2) {
@@ -2540,13 +3100,13 @@ async function fetchPage(app, url2) {
2540
3100
  }
2541
3101
  async function writeInto(folder, file, body) {
2542
3102
  const path = join5(folder, file);
2543
- await mkdir(dirname(path), { recursive: true });
2544
- await writeFile(path, body);
3103
+ await mkdir2(dirname2(path), { recursive: true });
3104
+ await writeFile2(path, body);
2545
3105
  }
2546
3106
  var isHtml = (headers) => (headers.get("content-type") ?? "").includes("text/html");
2547
3107
  var rooted = (path) => path.startsWith("/") ? path : `/${path}`;
2548
- var isFile = (path) => existsSync4(path) && statSync3(path).isFile();
2549
- var wildcard = (pattern) => new RegExp(`^${rooted(pattern).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
3108
+ var isFile = (path) => existsSync23(path) && statSync3(path).isFile();
3109
+ var wildcard2 = (pattern) => new RegExp(`^${rooted(pattern).replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*")}$`);
2550
3110
  function bunRuntime() {
2551
3111
  return globalThis.Bun;
2552
3112
  }
@@ -2558,6 +3118,8 @@ async function serveBun(app, options) {
2558
3118
  const server = bun.serve({
2559
3119
  port: options.port,
2560
3120
  hostname: options.hostname,
3121
+ // Bun closes a connection idle for 10 seconds by default, a slow page included; 255 is the most it allows.
3122
+ idleTimeout: options.requestTimeout === 0 ? 0 : Math.min(options.requestTimeout, 255),
2561
3123
  async fetch(request2, current) {
2562
3124
  setClientAddress(request2, current.requestIP(request2)?.address);
2563
3125
  const response2 = await handleSafely(app, request2, options.publicPath);
@@ -2660,8 +3222,8 @@ function toWebRequest(req, res, fallbackHost) {
2660
3222
  async function writeResponse(res, response2) {
2661
3223
  res.statusCode = response2.status;
2662
3224
  if (response2.statusText !== "") res.statusMessage = response2.statusText;
2663
- response2.headers.forEach((value, name) => {
2664
- if (name !== "set-cookie") res.setHeader(name, value);
3225
+ response2.headers.forEach((value2, name) => {
3226
+ if (name !== "set-cookie") res.setHeader(name, value2);
2665
3227
  });
2666
3228
  const cookies = response2.headers.getSetCookie();
2667
3229
  if (cookies.length > 0) res.setHeader("set-cookie", cookies);
@@ -2688,15 +3250,23 @@ function nodeRequestHandler(app, options) {
2688
3250
  } catch {
2689
3251
  res.destroy();
2690
3252
  }
2691
- await terminateRequest(app, request2, response2);
3253
+ const waitUntil = options.waitUntil?.();
3254
+ if (waitUntil !== void 0) waitUntil(terminateRequest(app, request2, response2));
3255
+ else await terminateRequest(app, request2, response2);
2692
3256
  };
2693
3257
  }
3258
+ function nodeTimeouts(options) {
3259
+ const keepAliveTimeout = options.keepAliveTimeout * 1e3;
3260
+ const requestTimeout = options.requestTimeout * 1e3;
3261
+ const headersTimeout = requestTimeout > 0 ? Math.min(keepAliveTimeout + 1e3, requestTimeout) : keepAliveTimeout + 1e3;
3262
+ return { keepAliveTimeout, headersTimeout, requestTimeout };
3263
+ }
2694
3264
  async function serveNode(app, options) {
2695
3265
  const handle = nodeRequestHandler(app, {
2696
3266
  ...options.publicPath !== void 0 && { publicPath: options.publicPath },
2697
3267
  fallbackHost: `${displayHost(options.hostname)}:${options.port}`
2698
3268
  });
2699
- const server = createServer((req, res) => void handle(req, res));
3269
+ const server = createServer(nodeTimeouts(options), (req, res) => void handle(req, res));
2700
3270
  await new Promise((resolve4, reject) => {
2701
3271
  server.once("error", reject);
2702
3272
  server.listen(options.port, options.hostname, () => {
@@ -2729,12 +3299,18 @@ async function serveNode(app, options) {
2729
3299
  function detectRuntime() {
2730
3300
  return bunRuntime() !== void 0 ? "bun" : "node";
2731
3301
  }
3302
+ var set = (value2) => value2 === void 0 || value2 === "" ? void 0 : value2;
3303
+ function defaultHostname() {
3304
+ return set(process.env.HOST) ?? set(process.env.SERVER_HOST) ?? "127.0.0.1";
3305
+ }
2732
3306
  async function serve(app, options = {}) {
2733
3307
  const resolved = {
2734
3308
  port: options.port ?? Number(process.env.PORT ?? process.env.SERVER_PORT ?? 8e3),
2735
- hostname: options.hostname ?? "127.0.0.1",
3309
+ hostname: options.hostname ?? defaultHostname(),
2736
3310
  signals: options.signals ?? true,
2737
3311
  shutdownTimeout: options.shutdownTimeout ?? 1e4,
3312
+ keepAliveTimeout: options.keepAliveTimeout ?? 65,
3313
+ requestTimeout: options.requestTimeout ?? 300,
2738
3314
  ...options.publicPath !== false && { publicPath: options.publicPath ?? app.publicPath() }
2739
3315
  };
2740
3316
  await app.boot();
@@ -2755,7 +3331,7 @@ var BUN_ENV_FILES = [
2755
3331
  ".env.production.local",
2756
3332
  ".env.test.local"
2757
3333
  ];
2758
- var expand = (value, env2) => value.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_match, braced, bare) => env2[braced ?? bare] ?? "");
3334
+ var expand = (value2, env2) => value2.replace(/\$\{([A-Za-z_][A-Za-z0-9_]*)\}|\$([A-Za-z_][A-Za-z0-9_]*)/g, (_match, braced, bare) => env2[braced ?? bare] ?? "");
2759
3335
  function serverEnvironment(options = {}) {
2760
3336
  const launched = options.launched ?? launchEnvironment;
2761
3337
  const env2 = { ...launched };
@@ -2765,7 +3341,7 @@ function serverEnvironment(options = {}) {
2765
3341
  const cwd = options.cwd ?? process.cwd();
2766
3342
  for (const name of BUN_ENV_FILES) {
2767
3343
  const file = join23(cwd, name);
2768
- if (!existsSync23(file)) continue;
3344
+ if (!existsSync32(file)) continue;
2769
3345
  let values;
2770
3346
  try {
2771
3347
  values = parseEnv2(readFileSync3(file, "utf8"));
@@ -2773,8 +3349,8 @@ function serverEnvironment(options = {}) {
2773
3349
  continue;
2774
3350
  }
2775
3351
  for (const [key2, raw] of Object.entries(values)) {
2776
- const value = launched[key2];
2777
- if (raw !== void 0 && value !== void 0 && (value === raw || value === expand(raw, launched))) delete env2[key2];
3352
+ const value2 = launched[key2];
3353
+ if (raw !== void 0 && value2 !== void 0 && (value2 === raw || value2 === expand(raw, launched))) delete env2[key2];
2778
3354
  }
2779
3355
  }
2780
3356
  return env2;
@@ -2840,7 +3416,7 @@ function watchFiles(basePath, onChange, options = {}) {
2840
3416
  };
2841
3417
  start(".", false, (file) => file === null ? void 0 : toSlashes(file));
2842
3418
  for (const folder of WATCHED_FOLDERS) {
2843
- if (existsSync32(join32(basePath, folder))) start(folder, true, (file) => `${folder}/${file === null ? "" : toSlashes(file)}`);
3419
+ if (existsSync42(join32(basePath, folder))) start(folder, true, (file) => `${folder}/${file === null ? "" : toSlashes(file)}`);
2844
3420
  }
2845
3421
  return {
2846
3422
  close() {
@@ -2973,12 +3549,12 @@ var WatchedServer = class {
2973
3549
  function io(command) {
2974
3550
  return {
2975
3551
  option: (name) => {
2976
- const value = command.option(name);
2977
- return value === void 0 || value === null || value === false || value === "" ? void 0 : String(value);
3552
+ const value2 = command.option(name);
3553
+ return value2 === void 0 || value2 === null || value2 === false || value2 === "" ? void 0 : String(value2);
2978
3554
  },
2979
3555
  flag: (name) => {
2980
- const value = command.option(name);
2981
- return value === true || value === "true" || value === "1";
3556
+ const value2 = command.option(name);
3557
+ return value2 === true || value2 === "true" || value2 === "1";
2982
3558
  },
2983
3559
  info: (message) => command.info(message),
2984
3560
  line: (message) => command.line(message),
@@ -3044,7 +3620,7 @@ ${create[0]}`);
3044
3620
  return void 0;
3045
3621
  }
3046
3622
  async function serveWatching(app, out, port, run) {
3047
- const hostname = out.option("host") ?? "127.0.0.1";
3623
+ const hostname = out.option("host") ?? defaultHostname();
3048
3624
  const requested = port !== void 0 ? Number(port) : Number(process.env.PORT ?? process.env.SERVER_PORT ?? 8e3);
3049
3625
  let claimed;
3050
3626
  try {
@@ -3104,7 +3680,7 @@ function registerHttpCommands(kernel, app, options = {}) {
3104
3680
  const terminalWidth = options.terminalWidth ?? (() => process.stdout.columns ?? 120);
3105
3681
  const runWatching = options.watch ?? ((watchOptions) => new WatchedServer(watchOptions).run());
3106
3682
  kernel.command(
3107
- "serve {--host=127.0.0.1 : The host address to serve the application on} {--port= : The port to serve the application on} {--watch : Automatically restart the server when the application is modified}",
3683
+ "serve {--host= : The host address to serve the application on} {--port= : The port to serve the application on} {--watch : Automatically restart the server when the application is modified}",
3108
3684
  async function() {
3109
3685
  const out = io(this);
3110
3686
  const port = out.option("port");
@@ -3113,8 +3689,9 @@ function registerHttpCommands(kernel, app, options = {}) {
3113
3689
  return 1;
3114
3690
  }
3115
3691
  if (out.flag("watch")) return serveWatching(app, out, port, runWatching);
3692
+ const host = out.option("host");
3116
3693
  const server = await serveApp(app, {
3117
- hostname: out.option("host") ?? "127.0.0.1",
3694
+ ...host !== void 0 && host !== "" && { hostname: host },
3118
3695
  ...port !== void 0 && { port: Number(port) },
3119
3696
  onListen: (running) => {
3120
3697
  out.info(`Server running on [${running.url}].`);
@@ -3163,22 +3740,28 @@ function registerHttpCommands(kernel, app, options = {}) {
3163
3740
  kernel.command("install:api {--force : Overwrite any existing API routes file}", async function() {
3164
3741
  const out = io(this);
3165
3742
  const routesFile = app.basePath("routes/api.ts");
3166
- if (existsSync42(routesFile) && !out.flag("force")) {
3743
+ if (existsSync5(routesFile) && !out.flag("force")) {
3167
3744
  out.error("API routes file already exists.");
3168
3745
  } else {
3169
- await mkdir2(dirname2(routesFile), { recursive: true });
3170
- await writeFile2(routesFile, API_ROUTES_STUB);
3746
+ await mkdir3(dirname3(routesFile), { recursive: true });
3747
+ await writeFile3(routesFile, API_ROUTES_STUB);
3171
3748
  out.info("Published API routes file.");
3172
3749
  }
3750
+ const corsFile = app.configPath("cors.ts");
3751
+ if (!existsSync5(corsFile)) {
3752
+ await mkdir3(dirname3(corsFile), { recursive: true });
3753
+ await writeFile3(corsFile, CORS_CONFIG_STUB);
3754
+ out.info("Published CORS config file.");
3755
+ }
3173
3756
  const bootstrapFile = app.bootstrapPath("app.ts");
3174
- const source = existsSync42(bootstrapFile) ? await readFile2(bootstrapFile, "utf8") : void 0;
3757
+ const source = existsSync5(bootstrapFile) ? await readFile3(bootstrapFile, "utf8") : void 0;
3175
3758
  const updated = source === void 0 ? void 0 : addApiRouting(source);
3176
3759
  if (updated === void 0) {
3177
3760
  out.warn(
3178
3761
  "Unable to automatically add API route definition to bootstrap file. Add api: 'routes/api.ts' to withRouting() in bootstrap/app.ts."
3179
3762
  );
3180
3763
  } else if (updated !== source) {
3181
- await writeFile2(bootstrapFile, updated);
3764
+ await writeFile3(bootstrapFile, updated);
3182
3765
  }
3183
3766
  out.info("API scaffolding installed.");
3184
3767
  return 0;
@@ -3197,12 +3780,14 @@ var HttpServiceProvider = class extends ServiceProvider {
3197
3780
  },
3198
3781
  "http"
3199
3782
  );
3783
+ this.mergeConfigFrom({ ...CORS_DEFAULTS }, "cors");
3200
3784
  this.app.singleton(HttpKernel, () => new Kernel(this.app));
3201
3785
  this.app.singleton(ExceptionHandler, () => {
3202
3786
  const handler = new ErrorHandler(this.app);
3203
3787
  applyExceptionCallbacks(this.app, handler);
3204
3788
  return handler;
3205
3789
  });
3790
+ this.app.singleton(MaintenanceMode, () => this.maintenanceMode());
3206
3791
  this.app.singleton(ResponseFactory, () => new HttpResponseFactory());
3207
3792
  this.app.singleton(Redirector, () => new HttpRedirector());
3208
3793
  }
@@ -3211,23 +3796,309 @@ var HttpServiceProvider = class extends ServiceProvider {
3211
3796
  const kernel = this.app.make(HttpKernel);
3212
3797
  if (kernel instanceof Kernel && this.app.bound(Router)) applyMiddlewareCallbacks(this.app, kernel);
3213
3798
  });
3214
- if (this.app.bound(ConsoleKernel)) registerHttpCommands(this.app.make(ConsoleKernel), this.app);
3799
+ if (this.app.bound(ConsoleKernel)) {
3800
+ registerHttpCommands(this.app.make(ConsoleKernel), this.app);
3801
+ registerMaintenanceCommands(this.app.make(ConsoleKernel), this.app);
3802
+ }
3803
+ }
3804
+ /** config('app.maintenance'): `file` (storage/framework/down, the default) or `cache` (a store every server shares). */
3805
+ maintenanceMode() {
3806
+ const config = this.app.bound(ConfigRepository) ? this.app.make(ConfigRepository) : void 0;
3807
+ const settings = config?.get("app.maintenance", {}) ?? {};
3808
+ const driver = settings.driver ?? "file";
3809
+ if (driver === "file") return new FileMaintenanceMode(this.app.storagePath("framework/down"));
3810
+ if (driver === "cache") {
3811
+ return new CacheMaintenanceMode(() => {
3812
+ const cache = this.app.make(CacheManager);
3813
+ return settings.store === void 0 || settings.store === "" ? cache.store() : cache.store(settings.store);
3814
+ });
3815
+ }
3816
+ throw new HttpServerError(`Unsupported maintenance mode driver [${driver}]: use "file" or "cache".`);
3817
+ }
3818
+ };
3819
+ var MissingValue = class {
3820
+ #missing = true;
3821
+ /** Laravel's isMissing(). */
3822
+ isMissing() {
3823
+ return this.#missing;
3215
3824
  }
3216
3825
  };
3826
+ var isMissing = (value2) => value2 instanceof MissingValue;
3827
+ var isPlainObject22 = (value2) => {
3828
+ if (typeof value2 !== "object" || value2 === null || Array.isArray(value2)) return false;
3829
+ const prototype = Object.getPrototypeOf(value2);
3830
+ return prototype === Object.prototype || prototype === null;
3831
+ };
3832
+ var isEmpty = (value2) => Object.keys(value2).length === 0;
3833
+ function mergeJson(target2, ...sources) {
3834
+ const merged = { ...target2 };
3835
+ for (const source of sources) {
3836
+ for (const [key2, value2] of Object.entries(source)) {
3837
+ const current = merged[key2];
3838
+ if (isPlainObject22(current) && isPlainObject22(value2)) merged[key2] = mergeJson(current, value2);
3839
+ else if (Array.isArray(current) && Array.isArray(value2)) merged[key2] = [...current, ...value2];
3840
+ else merged[key2] = value2;
3841
+ }
3842
+ }
3843
+ return merged;
3844
+ }
3845
+ var ResourceResponse = class {
3846
+ constructor(resource) {
3847
+ this.resource = resource;
3848
+ }
3849
+ resource;
3850
+ status;
3851
+ headers = new Headers();
3852
+ setStatusCode(status) {
3853
+ this.status = status;
3854
+ return this;
3855
+ }
3856
+ header(name, value2) {
3857
+ this.headers.set(name, value2);
3858
+ return this;
3859
+ }
3860
+ withHeaders(headers) {
3861
+ for (const [name, value2] of Object.entries(headers)) this.headers.set(name, value2);
3862
+ return this;
3863
+ }
3864
+ /** The body's top-level keys beside the data: with()'s and additional()'s (a paginated collection adds links and meta). */
3865
+ extra(request2) {
3866
+ return [this.resource.with(request2), this.resource.getAdditional()];
3867
+ }
3868
+ /** The JSON body: the resolved data, wrapped, beside the extra keys. */
3869
+ body(request2) {
3870
+ return this.wrap(this.resource.resolve(request2), this.extra(request2));
3871
+ }
3872
+ wrap(data, extra) {
3873
+ const wrapper = this.resource.wrapperKey();
3874
+ const unwrapped = (key2) => !isPlainObject22(data) || !Object.hasOwn(data, key2);
3875
+ const hasExtra = extra.some((keys) => !isEmpty(keys));
3876
+ let wrapped;
3877
+ if (wrapper !== null && unwrapped(wrapper)) wrapped = { [wrapper]: data };
3878
+ else if (hasExtra && (wrapper === null || unwrapped(wrapper))) wrapped = { [wrapper ?? "data"]: data };
3879
+ else if (isPlainObject22(data)) wrapped = data;
3880
+ if (wrapped === void 0) return data;
3881
+ return mergeJson(wrapped, ...extra);
3882
+ }
3883
+ defaultStatus() {
3884
+ const model = this.resource.resource;
3885
+ return typeof model === "object" && model !== null && model.wasRecentlyCreated === true ? 201 : 200;
3886
+ }
3887
+ async toResponse(request2) {
3888
+ const headers = new Headers(this.headers);
3889
+ headers.set("content-type", "application/json");
3890
+ const response2 = new Response(JSON.stringify(this.body(request2)), { status: this.status ?? this.defaultStatus(), headers });
3891
+ this.resource.withResponse(request2, response2);
3892
+ return response2;
3893
+ }
3894
+ };
3895
+ var LINK_KEYS = { first: "first_page_url", last: "last_page_url", prev: "prev_page_url", next: "next_page_url" };
3896
+ var PaginatedResourceResponse = class extends ResourceResponse {
3897
+ extra(request2) {
3898
+ return [this.paginationInformation(), ...super.extra(request2)];
3899
+ }
3900
+ paginationInformation() {
3901
+ const paginated = this.resource.resource.toArray();
3902
+ const links = {};
3903
+ for (const [name, key2] of Object.entries(LINK_KEYS)) links[name] = paginated[key2] ?? null;
3904
+ const meta = {};
3905
+ const moved = /* @__PURE__ */ new Set(["data", ...Object.values(LINK_KEYS)]);
3906
+ for (const [key2, value2] of Object.entries(paginated)) if (!moved.has(key2)) meta[key2] = value2;
3907
+ return { links, meta };
3908
+ }
3909
+ };
3910
+ var anonymousCollection = {
3911
+ Class: void 0
3912
+ };
3913
+ var isPlainObject3 = (value2) => {
3914
+ if (typeof value2 !== "object" || value2 === null) return false;
3915
+ const prototype = Object.getPrototypeOf(value2);
3916
+ return prototype === Object.prototype || prototype === null;
3917
+ };
3918
+ function resourceRequest() {
3919
+ const container2 = currentContainer();
3920
+ if (container2?.bound(HttpRequest)) {
3921
+ try {
3922
+ return container2.make(HttpRequest);
3923
+ } catch {
3924
+ }
3925
+ }
3926
+ const url2 = container2?.bound(ConfigRepository) ? container2.make(ConfigRepository).get("app.url", "") : "";
3927
+ return new IncomingRequest(new Request(url2 || "http://localhost"));
3928
+ }
3929
+ var leftOut = (value2) => isMissing(value2) || value2 instanceof JsonResource && isMissing(value2.resource);
3930
+ function resolveValue(value2, request2) {
3931
+ if (value2 instanceof JsonResource) return value2.resource === null || value2.resource === void 0 ? null : value2.resolve(request2);
3932
+ if (value2 instanceof Date) return serializeDate(value2);
3933
+ if (Array.isArray(value2)) return value2.filter((item) => !leftOut(item)).map((item) => resolveValue(item, request2));
3934
+ if (isPlainObject3(value2)) {
3935
+ const resolved = {};
3936
+ for (const [key2, item] of Object.entries(value2)) if (!leftOut(item)) resolved[key2] = resolveValue(item, request2);
3937
+ return resolved;
3938
+ }
3939
+ return value2;
3940
+ }
3941
+ var JsonResource = class {
3942
+ constructor(resource) {
3943
+ this.resource = resource;
3944
+ }
3945
+ resource;
3946
+ /**
3947
+ * The key the JSON is wrapped in (Laravel's `$wrap`): `data`, or none after `withoutWrapping()`. Set on the class it's
3948
+ * called on, so `JsonResource.withoutWrapping()` changes it for every resource.
3949
+ */
3950
+ static wrapper = "data";
3951
+ /** additional()'s keys, beside the data. */
3952
+ #additional = {};
3953
+ /**
3954
+ * A resource of this class: `PostResource.make(post)`, or `make(this.whenLoaded('post'))`. A null resource resolves
3955
+ * to null when nested, as a belongsTo that found nothing.
3956
+ */
3957
+ static make(resource) {
3958
+ return new this(resource);
3959
+ }
3960
+ /**
3961
+ * A collection of resources of this class: `PostResource.collection(posts)`, of a list, a collection or a paginator
3962
+ * (which adds Laravel's links and meta), or `collection(this.whenLoaded('posts'))`.
3963
+ */
3964
+ static collection(resource) {
3965
+ return new anonymousCollection.Class(resource, this);
3966
+ }
3967
+ /** Laravel's static wrap(): the key the JSON goes in, for this class and those that don't set their own. */
3968
+ static wrap(key2) {
3969
+ this.wrapper = key2;
3970
+ }
3971
+ /** Laravel's withoutWrapping(): the JSON goes bare. `JsonResource.withoutWrapping()` does it for every resource. */
3972
+ static withoutWrapping() {
3973
+ this.wrapper = null;
3974
+ }
3975
+ /** @internal The wrapper key of this resource's class. */
3976
+ wrapperKey() {
3977
+ return this.constructor.wrapper;
3978
+ }
3979
+ /** Top-level keys beside the data (Laravel's $additional): `PostResource.make(post).additional({ meta: { … } })`. */
3980
+ additional(data) {
3981
+ this.#additional = data;
3982
+ return this;
3983
+ }
3984
+ /** @internal additional()'s keys. */
3985
+ getAdditional() {
3986
+ return this.#additional;
3987
+ }
3988
+ /** Laravel's with(): top-level keys beside the data, for every response of this resource. None by default. */
3989
+ with(_request) {
3990
+ return {};
3991
+ }
3992
+ /** Laravel's withResponse(): change the response before it is sent (set a header). */
3993
+ withResponse(_request, _response) {
3994
+ }
3995
+ /** The response, to change its status or headers: `PostResource.make(post).response().setStatusCode(202)`. */
3996
+ response(_request) {
3997
+ return new ResourceResponse(this);
3998
+ }
3999
+ /** What toResponse() sends, as an object: what an Inertia page gets for a resource prop (inertia-laravel's getData()). */
4000
+ toResponseBody(request2 = resourceRequest()) {
4001
+ return this.response(request2).body(request2);
4002
+ }
4003
+ /** The JSON response: the data in its wrapper key, with()'s and additional()'s keys beside it. */
4004
+ toResponse(request2) {
4005
+ return this.response(request2).toResponse(request2);
4006
+ }
4007
+ /** The keys of the resource's JSON. By default the resource's own toArray(), the object itself, or {} for null. */
4008
+ toArray(_request) {
4009
+ const resource = this.resource;
4010
+ if (resource === null || resource === void 0) return {};
4011
+ if (typeof resource.toArray === "function") return resource.toArray();
4012
+ return resource;
4013
+ }
4014
+ /** toArray(), with its MissingValue keys removed and its nested resources resolved. */
4015
+ resolve(request2 = resourceRequest()) {
4016
+ return resolveValue(this.toArray(request2), request2);
4017
+ }
4018
+ /** The resolved JSON, unwrapped (Laravel's jsonSerialize()): what JSON.stringify() of a resource gives. */
4019
+ toJSON() {
4020
+ return this.resolve();
4021
+ }
4022
+ when(condition, value2, ...fallback) {
4023
+ if (condition) return typeof value2 === "function" ? value2() : value2;
4024
+ if (fallback.length > 0) return typeof fallback[0] === "function" ? fallback[0]() : fallback[0];
4025
+ return new MissingValue();
4026
+ }
4027
+ whenLoaded(relation, ...rest) {
4028
+ const model = this.resource;
4029
+ const loaded = typeof model?.relationLoaded === "function" && model.relationLoaded(relation);
4030
+ if (!loaded) return rest.length >= 2 ? typeof rest[1] === "function" ? rest[1]() : rest[1] : new MissingValue();
4031
+ const value2 = model.getRelation(relation);
4032
+ if (rest.length === 0) return value2;
4033
+ if (value2 === null || value2 === void 0) return null;
4034
+ return rest[0](value2);
4035
+ }
4036
+ whenCounted(relation, ...rest) {
4037
+ const attributes = this.resource?.getAttributes?.() ?? {};
4038
+ const key2 = `${Str.snake(relation)}_count`;
4039
+ if (!Object.hasOwn(attributes, key2)) return rest.length >= 2 ? typeof rest[1] === "function" ? rest[1]() : rest[1] : new MissingValue();
4040
+ const count = attributes[key2] === null ? null : Number(attributes[key2]);
4041
+ if (rest.length === 0) return count;
4042
+ if (count === null) return null;
4043
+ return rest[0](count);
4044
+ }
4045
+ /** The values when the condition holds, else none, for an object spread: `...this.mergeWhen(admin, { secret })`. */
4046
+ mergeWhen(condition, value2) {
4047
+ if (!condition) return {};
4048
+ return typeof value2 === "function" ? value2() : value2;
4049
+ }
4050
+ };
4051
+ var isPaginated = (value2) => typeof value2 === "object" && value2 !== null && typeof value2.items === "function" && typeof value2.getCollection === "function" && typeof value2.toArray === "function";
4052
+ var ResourceCollection = class extends JsonResource {
4053
+ /** The resource each item is made into. An instance field, read when the items are first read. */
4054
+ collects;
4055
+ #collection;
4056
+ /** The items, each made into `collects` (once, when first read: a subclass's field isn't set in the constructor). */
4057
+ get collection() {
4058
+ if (this.#collection === void 0) {
4059
+ const resource = this.resource;
4060
+ const items = isMissing(resource) || resource === null || resource === void 0 ? [] : isPaginated(resource) ? resource.items() : [...resource];
4061
+ const collects = this.collects;
4062
+ this.#collection = new Collection(collects === void 0 ? items : items.map((item) => item instanceof collects ? item : new collects(item)));
4063
+ }
4064
+ return this.#collection;
4065
+ }
4066
+ count() {
4067
+ return this.collection.count();
4068
+ }
4069
+ [Symbol.iterator]() {
4070
+ return this.collection[Symbol.iterator]();
4071
+ }
4072
+ /** Each item resolved: a resource's JSON, or the item itself. */
4073
+ toArray(request2) {
4074
+ return this.collection.all().map((item) => resolveValue(item, request2));
4075
+ }
4076
+ /** Over a paginator, a response with Laravel's links and meta. */
4077
+ response(_request) {
4078
+ return isPaginated(this.resource) ? new PaginatedResourceResponse(this) : new ResourceResponse(this);
4079
+ }
4080
+ };
4081
+ var AnonymousResourceCollection = class extends ResourceCollection {
4082
+ constructor(resource, collects) {
4083
+ super(resource);
4084
+ this.collects = collects;
4085
+ }
4086
+ };
4087
+ anonymousCollection.Class = AnonymousResourceCollection;
3217
4088
 
3218
4089
  // ../Live/dist/index.js
3219
4090
  import { AssertionError } from "assert";
3220
4091
  import { isDeepStrictEqual } from "util";
3221
- import { createHmac, timingSafeEqual } from "crypto";
4092
+ import { createHmac as createHmac2, timingSafeEqual as timingSafeEqual2 } from "crypto";
3222
4093
  import { AsyncLocalStorage as AsyncLocalStorage2 } from "async_hooks";
3223
4094
  import { randomBytes as randomBytes2 } from "crypto";
3224
- import { existsSync as existsSync5, readdirSync as readdirSync3 } from "fs";
3225
- import { join as join6, relative as relative2, sep as sep2 } from "path";
4095
+ import { existsSync as existsSync6, readdirSync as readdirSync3 } from "fs";
4096
+ import { join as join6, relative as relative3, sep as sep2 } from "path";
3226
4097
  import { pathToFileURL as pathToFileURL2 } from "url";
3227
4098
  import { AsyncLocalStorage } from "async_hooks";
3228
4099
  import { existsSync as existsSync24 } from "fs";
3229
- import { mkdir as mkdir3, writeFile as writeFile3 } from "fs/promises";
3230
- import { dirname as dirname3, join as join24, relative as relative22, sep as sep22 } from "path";
4100
+ import { mkdir as mkdir4, writeFile as writeFile4 } from "fs/promises";
4101
+ import { dirname as dirname4, join as join24, relative as relative22, sep as sep22 } from "path";
3231
4102
  var LiveError = class extends Error {
3232
4103
  name = "LiveError";
3233
4104
  kind = "Server";
@@ -3407,9 +4278,9 @@ function temporaryDirectory() {
3407
4278
  return uploadSetting("directory").replace(/^\/+|\/+$/g, "");
3408
4279
  }
3409
4280
  var FILENAME = /^[A-Za-z0-9]{40}(?:\.[a-z0-9]+)?$/;
3410
- function isTemporaryFileData(value) {
3411
- if (typeof value !== "object" || value === null) return false;
3412
- const data = value;
4281
+ function isTemporaryFileData(value2) {
4282
+ if (typeof value2 !== "object" || value2 === null) return false;
4283
+ const data = value2;
3413
4284
  return typeof data.filename === "string" && FILENAME.test(data.filename) && typeof data.name === "string" && typeof data.size === "number" && Number.isSafeInteger(data.size) && data.size >= 0 && typeof data.type === "string" && typeof data.extension === "string" && /^[a-z0-9]*$/.test(data.extension);
3414
4285
  }
3415
4286
  var HOUR = 36e5;
@@ -3465,9 +4336,9 @@ var TemporaryUploadedFile = class {
3465
4336
  return new ReadableStream({
3466
4337
  pull: async (controller) => {
3467
4338
  reader ??= (await temporaryDisk().readStream(this.path)).getReader();
3468
- const { done, value } = await reader.read();
4339
+ const { done, value: value2 } = await reader.read();
3469
4340
  if (done) controller.close();
3470
- else controller.enqueue(value);
4341
+ else controller.enqueue(value2);
3471
4342
  },
3472
4343
  cancel: async (reason) => {
3473
4344
  await reader?.cancel(reason);
@@ -3520,36 +4391,36 @@ var TemporaryUploadedFile = class {
3520
4391
  return container().make(UrlGenerator).temporarySignedRoute("live.preview-file", expires, { filename: this.filename }, false);
3521
4392
  }
3522
4393
  };
3523
- function isModel(value) {
3524
- if (typeof value !== "object" || value === null) return false;
3525
- const candidate = value;
4394
+ function isModel(value2) {
4395
+ if (typeof value2 !== "object" || value2 === null) return false;
4396
+ const candidate = value2;
3526
4397
  return typeof candidate.getKey === "function" && typeof candidate.getKeyName === "function" && typeof candidate.getTable === "function" && typeof candidate.exists === "boolean";
3527
4398
  }
3528
- var isPlainObject3 = (value) => {
3529
- const proto = Object.getPrototypeOf(value);
4399
+ var isPlainObject4 = (value2) => {
4400
+ const proto = Object.getPrototypeOf(value2);
3530
4401
  return proto === Object.prototype || proto === null;
3531
4402
  };
3532
- var isTuple = (value) => Array.isArray(value) && value.length === 2 && typeof value[1] === "object" && value[1] !== null && !Array.isArray(value[1]) && typeof value[1].s === "string";
4403
+ var isTuple = (value2) => Array.isArray(value2) && value2.length === 2 && typeof value2[1] === "object" && value2[1] !== null && !Array.isArray(value2[1]) && typeof value2[1].s === "string";
3533
4404
  function classNameOf(registry, cls) {
3534
4405
  return registry.nameOf(cls) ?? registry.register(cls);
3535
4406
  }
3536
- function dehydrate(value, registry, path, seen = /* @__PURE__ */ new Set()) {
3537
- switch (typeof value) {
4407
+ function dehydrate(value2, registry, path, seen = /* @__PURE__ */ new Set()) {
4408
+ switch (typeof value2) {
3538
4409
  case "undefined":
3539
4410
  return [null, { s: "u" }];
3540
4411
  case "string":
3541
4412
  case "boolean":
3542
- return value;
4413
+ return value2;
3543
4414
  case "number":
3544
- if (!Number.isFinite(value)) throw new LiveError(`Property [${path}] is ${value}: Live state must be JSON (finite numbers only).`);
3545
- return value;
4415
+ if (!Number.isFinite(value2)) throw new LiveError(`Property [${path}] is ${value2}: Live state must be JSON (finite numbers only).`);
4416
+ return value2;
3546
4417
  case "bigint":
3547
4418
  case "symbol":
3548
4419
  case "function":
3549
- throw new LiveError(`Property [${path}] holds a ${typeof value}: Live state may only hold primitives, arrays, plain objects, Dates, models and collections.`);
4420
+ throw new LiveError(`Property [${path}] holds a ${typeof value2}: Live state may only hold primitives, arrays, plain objects, Dates, models and collections.`);
3550
4421
  }
3551
- if (value === null) return null;
3552
- const object = value;
4422
+ if (value2 === null) return null;
4423
+ const object = value2;
3553
4424
  if (seen.has(object)) throw new LiveError(`Property [${path}] contains a circular reference.`);
3554
4425
  seen.add(object);
3555
4426
  try {
@@ -3574,7 +4445,7 @@ function dehydrate(value, registry, path, seen = /* @__PURE__ */ new Set()) {
3574
4445
  const meta = object.constructor === Collection ? { s: "clctn" } : { s: "clctn", class: classNameOf(registry, object.constructor) };
3575
4446
  return [items.map((item, i) => dehydrate(item, registry, `${path}.${i}`, seen)), meta];
3576
4447
  }
3577
- if (isPlainObject3(object)) {
4448
+ if (isPlainObject4(object)) {
3578
4449
  const out = {};
3579
4450
  for (const [key2, item] of Object.entries(object)) out[key2] = dehydrate(item, registry, `${path}.${key2}`, seen);
3580
4451
  return [out, { s: "obj" }];
@@ -3596,9 +4467,9 @@ function collectionClass(registry, name) {
3596
4467
  if (typeof cls !== "function" || !(cls.prototype instanceof Collection)) throw new LiveError(`Unable to hydrate the [${name}] collection: it is not registered.`);
3597
4468
  return cls;
3598
4469
  }
3599
- async function hydrate(value, registry) {
3600
- if (!isTuple(value)) return value;
3601
- const [inner, meta] = value;
4470
+ async function hydrate(value2, registry) {
4471
+ if (!isTuple(value2)) return value2;
4472
+ const [inner, meta] = value2;
3602
4473
  switch (meta.s) {
3603
4474
  case "u":
3604
4475
  return void 0;
@@ -3680,8 +4551,8 @@ function stateOf(component) {
3680
4551
  if (state === void 0) states.set(component, state = { id: "", name: "", errors: {}, dispatches: [], skipRender: false });
3681
4552
  return state;
3682
4553
  }
3683
- function isComponentClass(value) {
3684
- return typeof value === "function" && value[COMPONENT] === true;
4554
+ function isComponentClass(value2) {
4555
+ return typeof value2 === "function" && value2[COMPONENT] === true;
3685
4556
  }
3686
4557
  var ErrorBag = class {
3687
4558
  constructor(messages) {
@@ -3862,8 +4733,8 @@ function trackFlash(session, { saved = true } = {}) {
3862
4733
  };
3863
4734
  }
3864
4735
  var ESCAPES = { "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" };
3865
- function escapeAttribute2(value) {
3866
- return value.replace(/[&<>"']/g, (char) => ESCAPES[char]);
4736
+ function escapeAttribute2(value2) {
4737
+ return value2.replace(/[&<>"']/g, (char) => ESCAPES[char]);
3867
4738
  }
3868
4739
  function stripTags(html) {
3869
4740
  return html.replace(/<[^>]*>/g, "");
@@ -3910,31 +4781,31 @@ function insertAttributesIntoRoot(html, attributes) {
3910
4781
  const source = html.trim();
3911
4782
  const match = /^((?:<!--[\s\S]*?-->\s*)*<[A-Za-z][\w:-]*)/.exec(source);
3912
4783
  if (match === null) throw new LiveError("Live could not find the root element of the component.");
3913
- const rendered = Object.entries(attributes).map(([name, value]) => ` ${name}="${escapeAttribute2(value)}"`).join("");
4784
+ const rendered = Object.entries(attributes).map(([name, value2]) => ` ${name}="${escapeAttribute2(value2)}"`).join("");
3914
4785
  return match[1] + rendered + source.slice(match[1].length);
3915
4786
  }
3916
- function canonicalJson(value) {
3917
- if (Array.isArray(value)) return `[${value.map((item) => canonicalJson(item === void 0 ? null : item)).join(",")}]`;
3918
- if (typeof value === "object" && value !== null) {
3919
- const entries = Object.keys(value).sort().filter((key2) => value[key2] !== void 0).map((key2) => `${JSON.stringify(key2)}:${canonicalJson(value[key2])}`);
4787
+ function canonicalJson(value2) {
4788
+ if (Array.isArray(value2)) return `[${value2.map((item) => canonicalJson(item === void 0 ? null : item)).join(",")}]`;
4789
+ if (typeof value2 === "object" && value2 !== null) {
4790
+ const entries = Object.keys(value2).sort().filter((key2) => value2[key2] !== void 0).map((key2) => `${JSON.stringify(key2)}:${canonicalJson(value2[key2])}`);
3920
4791
  return `{${entries.join(",")}}`;
3921
4792
  }
3922
- return JSON.stringify(value);
4793
+ return JSON.stringify(value2);
3923
4794
  }
3924
4795
  function checksum(key2, payload) {
3925
- return createHmac("sha256", key2).update(canonicalJson({ data: payload.data, memo: payload.memo })).digest("hex");
4796
+ return createHmac2("sha256", key2).update(canonicalJson({ data: payload.data, memo: payload.memo })).digest("hex");
3926
4797
  }
3927
4798
  function verifyChecksum(key2, payload, given) {
3928
4799
  if (typeof given !== "string") return false;
3929
4800
  const expected = Buffer.from(checksum(key2, payload), "utf8");
3930
4801
  const actual = Buffer.from(given, "utf8");
3931
- return expected.length === actual.length && timingSafeEqual(expected, actual);
4802
+ return expected.length === actual.length && timingSafeEqual2(expected, actual);
3932
4803
  }
3933
4804
  function signatureOf(key2, purpose, payload) {
3934
- return createHmac("sha256", key2).update(`${purpose}|${payload}`).digest("base64url");
4805
+ return createHmac2("sha256", key2).update(`${purpose}|${payload}`).digest("base64url");
3935
4806
  }
3936
- function signValue(key2, purpose, value) {
3937
- const payload = Buffer.from(JSON.stringify(value), "utf8").toString("base64url");
4807
+ function signValue(key2, purpose, value2) {
4808
+ const payload = Buffer.from(JSON.stringify(value2), "utf8").toString("base64url");
3938
4809
  return `${payload}.${signatureOf(key2, purpose, payload)}`;
3939
4810
  }
3940
4811
  function verifiedValue(key2, purpose, token2) {
@@ -3944,7 +4815,7 @@ function verifiedValue(key2, purpose, token2) {
3944
4815
  const payload = token2.slice(0, dot);
3945
4816
  const expected = Buffer.from(signatureOf(key2, purpose, payload), "utf8");
3946
4817
  const given = Buffer.from(token2.slice(dot + 1), "utf8");
3947
- if (expected.length !== given.length || !timingSafeEqual(expected, given)) return void 0;
4818
+ if (expected.length !== given.length || !timingSafeEqual2(expected, given)) return void 0;
3948
4819
  try {
3949
4820
  return JSON.parse(Buffer.from(payload, "base64url").toString("utf8"));
3950
4821
  } catch {
@@ -4080,7 +4951,7 @@ function WithFileUploads(Base) {
4080
4951
  function usesFileUploads(component) {
4081
4952
  return component[UPLOADS] === true;
4082
4953
  }
4083
- var isRecord = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4954
+ var isRecord = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
4084
4955
  var read = (component, path) => path.split(".").reduce((node, segment) => isRecord(node) || Array.isArray(node) ? node[segment] : void 0, component);
4085
4956
  function uploadErrors(name, errors, multiple) {
4086
4957
  if (typeof errors === "string") {
@@ -4099,23 +4970,23 @@ async function runUploadCall(component, method, params, update) {
4099
4970
  if (!usesFileUploads(component)) {
4100
4971
  throw new LiveError(`Cannot handle file upload without [WithFileUploads] on the [${stateOf(component).name}] component class.`);
4101
4972
  }
4102
- const [name, value, multiple] = [String(params[0] ?? ""), params[1], params[2] === true];
4973
+ const [name, value2, multiple] = [String(params[0] ?? ""), params[1], params[2] === true];
4103
4974
  switch (method) {
4104
4975
  case "_startUpload":
4105
4976
  component.skipRender();
4106
4977
  return inject(UrlGenerator).temporarySignedRoute("live.upload-file", uploadSetting("max_upload_time") * 60, void 0, false);
4107
4978
  case "_finishUpload": {
4108
4979
  await cleanupOldUploads();
4109
- const files = (Array.isArray(value) ? value : []).map((reference) => temporaryFileFromReference(reference, stateOf(component).name));
4980
+ const files = (Array.isArray(value2) ? value2 : []).map((reference) => temporaryFileFromReference(reference, stateOf(component).name));
4110
4981
  const current = read(component, name);
4111
4982
  const next = multiple ? files : Array.isArray(current) ? [...current, ...files] : files[0] ?? null;
4112
4983
  await update(name, next);
4113
4984
  return files.map((file) => file.filename);
4114
4985
  }
4115
4986
  case "_uploadErrored":
4116
- throw new UploadValidationError(uploadErrors(name, value, multiple));
4987
+ throw new UploadValidationError(uploadErrors(name, value2, multiple));
4117
4988
  case "_removeUpload": {
4118
- const filename = String(value ?? "");
4989
+ const filename = String(value2 ?? "");
4119
4990
  const current = read(component, name);
4120
4991
  if (Array.isArray(current)) {
4121
4992
  const removed = current.filter((file) => file instanceof TemporaryUploadedFile && file.filename === filename);
@@ -4225,10 +5096,10 @@ var Testable = class _Testable {
4225
5096
  * file input does it: the upload rules, the temporary disk, then a TemporaryUploadedFile (or an array) in the
4226
5097
  * property, or the upload's errors on it (Livewire's).
4227
5098
  */
4228
- async set(path, value) {
4229
- const files = [value].flat();
4230
- if (typeof path === "string" && files.length > 0 && files.every((file) => file instanceof Blob)) return this.upload(path, files, Array.isArray(value));
4231
- return this.#update(typeof path === "string" ? { [path]: value } : path, []);
5099
+ async set(path, value2) {
5100
+ const files = [value2].flat();
5101
+ if (typeof path === "string" && files.length > 0 && files.every((file) => file instanceof Blob)) return this.upload(path, files, Array.isArray(value2));
5102
+ return this.#update(typeof path === "string" ? { [path]: value2 } : path, []);
4232
5103
  }
4233
5104
  /** Uploads `files` into the property `name` (an array when `multiple`), as the browser's upload calls do. */
4234
5105
  async upload(name, files, multiple = false) {
@@ -4265,38 +5136,38 @@ var Testable = class _Testable {
4265
5136
  this.#instance = result.instance;
4266
5137
  return this;
4267
5138
  }
4268
- assertSet(path, value) {
5139
+ assertSet(path, value2) {
4269
5140
  const actual = this.get(path);
4270
- if (!isDeepStrictEqual(actual, value)) fail(`Failed asserting that property [${path}] is set to the expected value.`, actual, value);
5141
+ if (!isDeepStrictEqual(actual, value2)) fail(`Failed asserting that property [${path}] is set to the expected value.`, actual, value2);
4271
5142
  return this;
4272
5143
  }
4273
- assertNotSet(path, value) {
4274
- if (isDeepStrictEqual(this.get(path), value)) fail(`Failed asserting that property [${path}] is not set to the given value.`, this.get(path), value);
5144
+ assertNotSet(path, value2) {
5145
+ if (isDeepStrictEqual(this.get(path), value2)) fail(`Failed asserting that property [${path}] is not set to the given value.`, this.get(path), value2);
4275
5146
  return this;
4276
5147
  }
4277
5148
  /** Each value, HTML-escaped, appears in the rendered HTML. */
4278
5149
  assertSee(...values) {
4279
- for (const value of values) if (!this.html().includes(escapeAttribute2(value))) fail(`Failed asserting that [${value}] is in the rendered HTML.`, this.html(), value);
5150
+ for (const value2 of values) if (!this.html().includes(escapeAttribute2(value2))) fail(`Failed asserting that [${value2}] is in the rendered HTML.`, this.html(), value2);
4280
5151
  return this;
4281
5152
  }
4282
5153
  assertDontSee(...values) {
4283
- for (const value of values) if (this.html().includes(escapeAttribute2(value))) fail(`Failed asserting that [${value}] is not in the rendered HTML.`, this.html(), value);
5154
+ for (const value2 of values) if (this.html().includes(escapeAttribute2(value2))) fail(`Failed asserting that [${value2}] is not in the rendered HTML.`, this.html(), value2);
4284
5155
  return this;
4285
5156
  }
4286
5157
  /** Each value appears in the rendered HTML as written (not escaped). */
4287
5158
  assertSeeHtml(...values) {
4288
- for (const value of values) if (!this.html().includes(value)) fail(`Failed asserting that [${value}] is in the rendered HTML.`, this.html(), value);
5159
+ for (const value2 of values) if (!this.html().includes(value2)) fail(`Failed asserting that [${value2}] is in the rendered HTML.`, this.html(), value2);
4289
5160
  return this;
4290
5161
  }
4291
5162
  /** Each value, HTML-escaped, appears in the rendered text: the HTML with its tags stripped (Livewire's assertSeeText). */
4292
5163
  assertSeeText(...values) {
4293
5164
  const text = stripTags(this.html());
4294
- for (const value of values) if (!text.includes(escapeAttribute2(value))) fail(`Failed asserting that [${value}] is in the rendered text.`, text, value);
5165
+ for (const value2 of values) if (!text.includes(escapeAttribute2(value2))) fail(`Failed asserting that [${value2}] is in the rendered text.`, text, value2);
4295
5166
  return this;
4296
5167
  }
4297
5168
  assertDontSeeText(...values) {
4298
5169
  const text = stripTags(this.html());
4299
- for (const value of values) if (text.includes(escapeAttribute2(value))) fail(`Failed asserting that [${value}] is not in the rendered text.`, text, value);
5170
+ for (const value2 of values) if (text.includes(escapeAttribute2(value2))) fail(`Failed asserting that [${value2}] is not in the rendered text.`, text, value2);
4300
5171
  return this;
4301
5172
  }
4302
5173
  assertDispatched(name, params) {
@@ -4338,9 +5209,9 @@ var Testable = class _Testable {
4338
5209
  return this;
4339
5210
  }
4340
5211
  /** The last call returned `value`. */
4341
- assertReturned(value) {
5212
+ assertReturned(value2) {
4342
5213
  const returned = this.#effects.returns?.at(-1);
4343
- if (!isDeepStrictEqual(returned, value)) fail("Failed asserting that the method returned the expected value.", returned, value);
5214
+ if (!isDeepStrictEqual(returned, value2)) fail("Failed asserting that the method returned the expected value.", returned, value2);
4344
5215
  return this;
4345
5216
  }
4346
5217
  };
@@ -4379,7 +5250,7 @@ async function placeholderHtml(container2, instance, params) {
4379
5250
  return (typeof output === "string" ? output : await views.renderToString(output)).trim();
4380
5251
  }
4381
5252
  function lazyPayload(key2, registry, load) {
4382
- const params = Object.fromEntries(Object.entries(load.params).map(([name, value]) => [name, dehydrate(value, registry, `${load.name}.${name}`)]));
5253
+ const params = Object.fromEntries(Object.entries(load.params).map(([name, value2]) => [name, dehydrate(value2, registry, `${load.name}.${name}`)]));
4383
5254
  return signValue(key2, PURPOSE, { ...load, params });
4384
5255
  }
4385
5256
  async function lazyLoadOf(key2, registry, payload, component) {
@@ -4402,7 +5273,7 @@ function defaultName(cls) {
4402
5273
  return typeof name === "string" && name !== "" ? Str.kebab(name) : void 0;
4403
5274
  }
4404
5275
  function componentFiles(directory) {
4405
- if (!existsSync5(directory)) return [];
5276
+ if (!existsSync6(directory)) return [];
4406
5277
  return readdirSync3(directory, { recursive: true, encoding: "utf8" }).filter((file) => /\.(tsx|ts|jsx|js|mts|mjs)$/.test(file) && !/\.(test|spec|d)\.[^.]+$/.test(file)).map((file) => file.split(sep2).join("/")).sort();
4407
5278
  }
4408
5279
  async function discover(directory) {
@@ -4412,11 +5283,11 @@ async function discover(directory) {
4412
5283
  /* @vite-ignore */
4413
5284
  pathToFileURL2(join6(directory, file)).href
4414
5285
  );
4415
- found.push([componentName(relative2(directory, join6(directory, file))), module.default]);
5286
+ found.push([componentName(relative3(directory, join6(directory, file))), module.default]);
4416
5287
  }
4417
5288
  return found;
4418
5289
  }
4419
- var PERSISTENT_MIDDLEWARE = ["auth", "verified", "guest", "can"];
5290
+ var PERSISTENT_MIDDLEWARE = ["auth", "verified", "guest", "can", "password.confirm"];
4420
5291
  var ROUTER_METHODS = ["getRoutesByMatchOrder", "getPatterns", "getPatternVersion", "getMiddleware", "getMiddlewareGroups", "substituteBindings"];
4421
5292
  function canMatch(router) {
4422
5293
  const methods = router;
@@ -4533,8 +5404,8 @@ async function throughMiddleware(container2, request2, pass, destination) {
4533
5404
  }
4534
5405
  }
4535
5406
  var PAGINATED = /* @__PURE__ */ Symbol.for("oriel:live.pagination");
4536
- function toPage(value) {
4537
- const page = typeof value === "number" ? value : typeof value === "string" && value.trim() !== "" ? Number(value) : Number.NaN;
5407
+ function toPage(value2) {
5408
+ const page = typeof value2 === "number" ? value2 : typeof value2 === "string" && value2.trim() !== "" ? Number(value2) : Number.NaN;
4538
5409
  return Number.isFinite(page) && page >= 1 ? Math.min(Math.floor(page), Number.MAX_SAFE_INTEGER) : 1;
4539
5410
  }
4540
5411
  async function hook(instance, name, ...args) {
@@ -4566,12 +5437,12 @@ function WithPagination(Base) {
4566
5437
  Object.defineProperty(WithPaginationMixin.prototype, PAGINATED, { value: true });
4567
5438
  return WithPaginationMixin;
4568
5439
  }
4569
- function isPaginated(component) {
5440
+ function isPaginated2(component) {
4570
5441
  return component[PAGINATED] === true;
4571
5442
  }
4572
5443
  var rendering = new AsyncLocalStorage();
4573
5444
  function renderPaginated(component, url2, run) {
4574
- return rendering.run(isPaginated(component) ? { component, url: url2 } : void 0, run);
5445
+ return rendering.run(isPaginated2(component) ? { component, url: url2 } : void 0, run);
4575
5446
  }
4576
5447
  function outsidePagination(run) {
4577
5448
  return rendering.run(void 0, run);
@@ -4599,9 +5470,9 @@ function optional(container2, token2) {
4599
5470
  return void 0;
4600
5471
  }
4601
5472
  }
4602
- var isRecord2 = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
4603
- function setOwn(object, key2, value) {
4604
- Object.defineProperty(object, key2, { value, enumerable: true, writable: true, configurable: true });
5473
+ var isRecord2 = (value2) => typeof value2 === "object" && value2 !== null && !Array.isArray(value2);
5474
+ function setOwn(object, key2, value2) {
5475
+ Object.defineProperty(object, key2, { value: value2, enumerable: true, writable: true, configurable: true });
4605
5476
  }
4606
5477
  async function hook2(instance, name, ...args) {
4607
5478
  const method = instance[name];
@@ -4674,8 +5545,8 @@ var LiveComponentManager = class {
4674
5545
  const lazy = lazyMode(cls, embedParams);
4675
5546
  await hook2(instance, "boot");
4676
5547
  if (lazy !== void 0) return this.mountPlaceholder(instance, params, lazy);
4677
- for (const [property, value] of Object.entries(params)) {
4678
- if (Object.hasOwn(instance, property)) instance[property] = value;
5548
+ for (const [property, value2] of Object.entries(params)) {
5549
+ if (Object.hasOwn(instance, property)) instance[property] = value2;
4679
5550
  }
4680
5551
  this.prepareComputed(instance);
4681
5552
  const request2 = optional(this.container(), HttpRequest);
@@ -4735,8 +5606,8 @@ var LiveComponentManager = class {
4735
5606
  state.errors = { ...snapshot.memo.errors };
4736
5607
  await hook2(instance, "boot");
4737
5608
  const registry = this.registry();
4738
- for (const [property, value] of Object.entries(snapshot.data)) {
4739
- Object.defineProperty(instance, property, { value: await hydrate(value, registry), enumerable: true, writable: true, configurable: true });
5609
+ for (const [property, value2] of Object.entries(snapshot.data)) {
5610
+ Object.defineProperty(instance, property, { value: await hydrate(value2, registry), enumerable: true, writable: true, configurable: true });
4740
5611
  }
4741
5612
  this.prepareComputed(instance);
4742
5613
  const returns = [];
@@ -4744,14 +5615,14 @@ var LiveComponentManager = class {
4744
5615
  if (load === void 0) await hook2(instance, "hydrate");
4745
5616
  try {
4746
5617
  if (load !== void 0) {
4747
- for (const [property, value] of Object.entries(load.params)) {
4748
- if (Object.hasOwn(instance, property)) instance[property] = value;
5618
+ for (const [property, value2] of Object.entries(load.params)) {
5619
+ if (Object.hasOwn(instance, property)) instance[property] = value2;
4749
5620
  }
4750
5621
  loading.set(instance, load.tag);
4751
5622
  await hook2(instance, "mount", load.params);
4752
5623
  returns.push(void 0);
4753
5624
  }
4754
- for (const [path, value] of Object.entries(updates)) await this.applyUpdate(instance, path, value);
5625
+ for (const [path, value2] of Object.entries(updates)) await this.applyUpdate(instance, path, value2);
4755
5626
  for (const call of load === void 0 ? calls : []) returns.push(await this.call(instance, call.method, call.params));
4756
5627
  } catch (error) {
4757
5628
  const errors = error.errors;
@@ -4878,15 +5749,15 @@ var LiveComponentManager = class {
4878
5749
  }
4879
5750
  }
4880
5751
  }
4881
- async applyUpdate(instance, path, value) {
5752
+ async applyUpdate(instance, path, value2) {
4882
5753
  if (!isUpdatable(instance, path)) throw new PropertyNotUpdatableError(path, stateOf(instance).name);
4883
5754
  const [root, ...rest] = path.split(".");
4884
5755
  const key2 = rest.length > 0 ? rest.join(".") : void 0;
4885
5756
  const studly = Str.studly(root);
4886
- await hook2(instance, "updating", path, value);
4887
- await hook2(instance, `updating${studly}`, value, key2);
5757
+ await hook2(instance, "updating", path, value2);
5758
+ await hook2(instance, `updating${studly}`, value2, key2);
4888
5759
  const target2 = instance;
4889
- if (rest.length === 0) target2[root] = value;
5760
+ if (rest.length === 0) target2[root] = value2;
4890
5761
  else {
4891
5762
  const assertSlot = (node2, segment) => {
4892
5763
  if (Array.isArray(node2) && !isArraySlot(node2, segment)) throw new PropertyNotUpdatableError(path, stateOf(instance).name);
@@ -4900,10 +5771,10 @@ var LiveComponentManager = class {
4900
5771
  }
4901
5772
  const last = rest.at(-1);
4902
5773
  assertSlot(node, last);
4903
- Object.defineProperty(node, last, { value, enumerable: true, writable: true, configurable: true });
5774
+ Object.defineProperty(node, last, { value: value2, enumerable: true, writable: true, configurable: true });
4904
5775
  }
4905
- await hook2(instance, "updated", path, value);
4906
- await hook2(instance, `updated${studly}`, value, key2);
5776
+ await hook2(instance, "updated", path, value2);
5777
+ await hook2(instance, `updated${studly}`, value2, key2);
4907
5778
  }
4908
5779
  /** Runs one call from the browser: a magic action, an event, an upload call, or a public method. Returns its return value. */
4909
5780
  async call(instance, method, params) {
@@ -4928,7 +5799,7 @@ var LiveComponentManager = class {
4928
5799
  return void 0;
4929
5800
  }
4930
5801
  }
4931
- if (UPLOAD_CALLS.has(method)) return runUploadCall(instance, method, params, (path, value) => this.applyUpdate(instance, path, value));
5802
+ if (UPLOAD_CALLS.has(method)) return runUploadCall(instance, method, params, (path, value2) => this.applyUpdate(instance, path, value2));
4932
5803
  if (!isCallable(instance, method)) throw new MethodNotCallableError(method, name);
4933
5804
  return instance[method](...params);
4934
5805
  }
@@ -4955,12 +5826,12 @@ var LiveComponentManager = class {
4955
5826
  }
4956
5827
  /** The absolute URL of the page a memo path belongs to, on the current request's origin ('/' + path without one). */
4957
5828
  pageUrl(path) {
4958
- const relative3 = `/${path.replace(/^\/+/, "")}`;
5829
+ const relative32 = `/${path.replace(/^\/+/, "")}`;
4959
5830
  const url2 = optional(this.container(), HttpRequest)?.url();
4960
5831
  try {
4961
- return url2 === void 0 ? relative3 : new URL(relative3, url2).href;
5832
+ return url2 === void 0 ? relative32 : new URL(relative32, url2).href;
4962
5833
  } catch {
4963
- return relative3;
5834
+ return relative32;
4964
5835
  }
4965
5836
  }
4966
5837
  /** Dispatches, redirects: the effects every response carries. */
@@ -4984,7 +5855,7 @@ var LiveComponentManager = class {
4984
5855
  await hook2(instance, "dehydrate");
4985
5856
  const registry = this.registry();
4986
5857
  const data = {};
4987
- for (const [property, value] of Object.entries(instance)) data[property] = dehydrate(value, registry, `${memo.name}.${property}`);
5858
+ for (const [property, value2] of Object.entries(instance)) data[property] = dehydrate(value2, registry, `${memo.name}.${property}`);
4988
5859
  const signed = { data, memo: { ...memo, errors: { ...stateOf(instance).errors } } };
4989
5860
  return { ...signed, checksum: checksum(this.key(), signed) };
4990
5861
  }
@@ -5011,7 +5882,7 @@ test('{{ name }} renders', async () => {
5011
5882
  `;
5012
5883
  var CLASS_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
5013
5884
  function importPath(from, to) {
5014
- const path = relative22(dirname3(from), to).split(sep22).join("/").replace(/\.tsx?$/, "");
5885
+ const path = relative22(dirname4(from), to).split(sep22).join("/").replace(/\.tsx?$/, "");
5015
5886
  return path.startsWith(".") ? path : `./${path}`;
5016
5887
  }
5017
5888
  function registerLiveCommands(kernel, app) {
@@ -5030,8 +5901,8 @@ function registerLiveCommands(kernel, app) {
5030
5901
  this.error(`Component [${relative22(app.basePath(), file)}] already exists.`);
5031
5902
  return 1;
5032
5903
  }
5033
- await mkdir3(dirname3(file), { recursive: true });
5034
- await writeFile3(file, COMPONENT_STUB.replace("{{ class }}", () => className));
5904
+ await mkdir4(dirname4(file), { recursive: true });
5905
+ await writeFile4(file, COMPONENT_STUB.replace("{{ class }}", () => className));
5035
5906
  this.info(`Component [${relative22(app.basePath(), file)}] created successfully.`);
5036
5907
  if (this.option("test") === true) {
5037
5908
  const testFile = app.basePath(join24("tests", "Feature", "Live", ...segments.slice(0, -1), `${className}.test.ts`));
@@ -5041,8 +5912,8 @@ function registerLiveCommands(kernel, app) {
5041
5912
  }
5042
5913
  const name = segments.map((segment) => Str.kebab(segment)).join(".");
5043
5914
  const test = TEST_STUB.replaceAll("{{ class }}", () => className).replace("{{ component }}", () => importPath(testFile, file)).replace("{{ testCase }}", () => importPath(testFile, app.basePath(join24("tests", "TestCase.ts")))).replace("{{ name }}", () => name);
5044
- await mkdir3(dirname3(testFile), { recursive: true });
5045
- await writeFile3(testFile, test);
5915
+ await mkdir4(dirname4(testFile), { recursive: true });
5916
+ await writeFile4(testFile, test);
5046
5917
  this.info(`Test [${relative22(app.basePath(), testFile)}] created successfully.`);
5047
5918
  }
5048
5919
  return 0;
@@ -5124,12 +5995,12 @@ function Pagination({ paginator, class: className, buttonClass = "btn btn-second
5124
5995
  // ../Testing/dist/index.js
5125
5996
  import { AssertionError as AssertionError2 } from "assert";
5126
5997
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "util";
5127
- import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
5998
+ import { existsSync as existsSync7, readFileSync as readFileSync4 } from "fs";
5128
5999
  import { join as join7 } from "path";
5129
6000
  import { parse as parse2 } from "dotenv";
5130
6001
  import { existsSync as existsSync25 } from "fs";
5131
6002
  import { join as join25 } from "path";
5132
- import { createHmac as createHmac2 } from "crypto";
6003
+ import { createHmac as createHmac3 } from "crypto";
5133
6004
  import { randomUUID } from "crypto";
5134
6005
  import { randomUUID as randomUUID2 } from "crypto";
5135
6006
  import { randomUUID as randomUUID3 } from "crypto";
@@ -5192,12 +6063,12 @@ function freezeSecond(callback) {
5192
6063
  travelTo(at);
5193
6064
  return at;
5194
6065
  }
5195
- function travel(value) {
5196
- return new Wormhole(value);
6066
+ function travel(value2) {
6067
+ return new Wormhole(value2);
5197
6068
  }
5198
6069
  var Wormhole = class {
5199
- constructor(value) {
5200
- this.value = value;
6070
+ constructor(value2) {
6071
+ this.value = value2;
5201
6072
  }
5202
6073
  value;
5203
6074
  millisecond(callback) {
@@ -5268,17 +6139,17 @@ function fail2(message, details = {}) {
5268
6139
  function assert(condition, message, details) {
5269
6140
  if (!condition) fail2(typeof message === "function" ? message() : message, details);
5270
6141
  }
5271
- function format(value) {
5272
- if (typeof value === "string") return JSON.stringify(value);
5273
- if (typeof value === "function") return value.name === "" ? "[Function]" : `[Function ${value.name}]`;
6142
+ function format(value2) {
6143
+ if (typeof value2 === "string") return JSON.stringify(value2);
6144
+ if (typeof value2 === "function") return value2.name === "" ? "[Function]" : `[Function ${value2.name}]`;
5274
6145
  try {
5275
- return JSON.stringify(value, (_key, item) => typeof item === "bigint" ? `${item}n` : item) ?? String(value);
6146
+ return JSON.stringify(value2, (_key, item) => typeof item === "bigint" ? `${item}n` : item) ?? String(value2);
5276
6147
  } catch {
5277
- return String(value);
6148
+ return String(value2);
5278
6149
  }
5279
6150
  }
5280
- function escapeHtml2(value) {
5281
- return value.replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" })[char]);
6151
+ function escapeHtml2(value2) {
6152
+ return value2.replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#039;" })[char]);
5282
6153
  }
5283
6154
  function stripTags2(html) {
5284
6155
  return html.replace(/<[^>]*>/g, "");
@@ -5286,23 +6157,23 @@ function stripTags2(html) {
5286
6157
  function equals(a, b) {
5287
6158
  return isDeepStrictEqual2(canonical(a), canonical(b));
5288
6159
  }
5289
- function canonical(value) {
5290
- if (Array.isArray(value)) return value.map(canonical);
5291
- if (typeof value === "object" && value !== null && Object.getPrototypeOf(value) === Object.prototype) {
5292
- return Object.fromEntries(Object.keys(value).sort().map((key2) => [key2, canonical(value[key2])]));
6160
+ function canonical(value2) {
6161
+ if (Array.isArray(value2)) return value2.map(canonical);
6162
+ if (typeof value2 === "object" && value2 !== null && Object.getPrototypeOf(value2) === Object.prototype) {
6163
+ return Object.fromEntries(Object.keys(value2).sort().map((key2) => [key2, canonical(value2[key2])]));
5293
6164
  }
5294
- return value;
6165
+ return value2;
5295
6166
  }
5296
6167
  function isSubset(subset, actual) {
5297
6168
  if (typeof subset !== "object" || subset === null) return equals(subset, actual);
5298
6169
  if (typeof actual !== "object" || actual === null) return false;
5299
6170
  if (Array.isArray(subset) !== Array.isArray(actual)) return false;
5300
- return Object.entries(subset).every(([key2, value]) => Object.hasOwn(actual, key2) && isSubset(value, actual[key2]));
6171
+ return Object.entries(subset).every(([key2, value2]) => Object.hasOwn(actual, key2) && isSubset(value2, actual[key2]));
5301
6172
  }
5302
- function* objectsIn(value) {
5303
- if (typeof value !== "object" || value === null) return;
5304
- if (!Array.isArray(value)) yield value;
5305
- for (const child of Object.values(value)) yield* objectsIn(child);
6173
+ function* objectsIn(value2) {
6174
+ if (typeof value2 !== "object" || value2 === null) return;
6175
+ if (!Array.isArray(value2)) yield value2;
6176
+ for (const child of Object.values(value2)) yield* objectsIn(child);
5306
6177
  }
5307
6178
  function containsPair(tree, key2, expected) {
5308
6179
  for (const object of objectsIn(tree)) if (Object.hasOwn(object, key2) && isSubset(expected, object[key2])) return true;
@@ -5418,9 +6289,9 @@ function target(db, table, connection) {
5418
6289
  return { table: table.getTable(), connection: db.connection(connection ?? table.getConnectionName?.()) };
5419
6290
  }
5420
6291
  function constrain(query, data) {
5421
- for (const [column, value] of Object.entries(data)) {
5422
- if (value === null) query.whereNull(column);
5423
- else query.where(column, value);
6292
+ for (const [column, value2] of Object.entries(data)) {
6293
+ if (value2 === null) query.whereNull(column);
6294
+ else query.where(column, value2);
5424
6295
  }
5425
6296
  return query;
5426
6297
  }
@@ -5499,7 +6370,7 @@ function parseAddress(address) {
5499
6370
  }
5500
6371
  function dotEnv(cwd) {
5501
6372
  const file = join7(cwd, ".env");
5502
- return existsSync6(file) ? parse2(readFileSync4(file, "utf8")) : {};
6373
+ return existsSync7(file) ? parse2(readFileSync4(file, "utf8")) : {};
5503
6374
  }
5504
6375
  function serverDatabase(connection) {
5505
6376
  if (typeof connection.url === "string" && connection.url !== "") return parseAddress(connection.url);
@@ -5543,16 +6414,16 @@ function testingConfig(env2 = process.env, log = (line) => console.log(line), cw
5543
6414
  };
5544
6415
  }
5545
6416
  function applyEnvironment(values, env2 = process.env) {
5546
- for (const [key2, value] of Object.entries(values)) env2[key2] ??= value;
6417
+ for (const [key2, value2] of Object.entries(values)) env2[key2] ??= value2;
5547
6418
  }
5548
- function clonePlain2(value) {
5549
- if (Array.isArray(value)) return value.map((item) => clonePlain2(item));
5550
- if (typeof value === "object" && value !== null) {
5551
- const proto = Object.getPrototypeOf(value);
5552
- if (proto !== Object.prototype && proto !== null) return value;
5553
- return Object.fromEntries(Object.entries(value).map(([key2, item]) => [key2, clonePlain2(item)]));
6419
+ function clonePlain2(value2) {
6420
+ if (Array.isArray(value2)) return value2.map((item) => clonePlain2(item));
6421
+ if (typeof value2 === "object" && value2 !== null) {
6422
+ const proto = Object.getPrototypeOf(value2);
6423
+ if (proto !== Object.prototype && proto !== null) return value2;
6424
+ return Object.fromEntries(Object.entries(value2).map(([key2, item]) => [key2, clonePlain2(item)]));
5554
6425
  }
5555
- return value;
6426
+ return value2;
5556
6427
  }
5557
6428
  var RefreshDatabaseState = { migrated: false };
5558
6429
  async function runCommand(app, command, parameters = {}) {
@@ -5578,7 +6449,10 @@ function connectionsOf(test) {
5578
6449
  }
5579
6450
  async function beginTransactions(test, connections) {
5580
6451
  const levels = connections.map((connection) => connection.transactionLevel());
5581
- for (const connection of connections) await connection.beginTransaction();
6452
+ for (const connection of connections) {
6453
+ await connection.beginTransaction();
6454
+ connection.ignoreAfterCommitAtCurrentLevel?.();
6455
+ }
5582
6456
  test.beforeApplicationDestroyed(async () => {
5583
6457
  for (const [index, connection] of [...connections.entries()].reverse()) await rollBackTo(connection, levels[index] ?? 0);
5584
6458
  });
@@ -5625,20 +6499,20 @@ var DatabaseTransactions = {
5625
6499
  await beginTransactions(test, connectionsOf(test));
5626
6500
  }
5627
6501
  };
5628
- function typeOf(value) {
5629
- if (value === null) return ["null"];
5630
- if (Array.isArray(value)) return ["array"];
5631
- switch (typeof value) {
6502
+ function typeOf(value2) {
6503
+ if (value2 === null) return ["null"];
6504
+ if (Array.isArray(value2)) return ["array"];
6505
+ switch (typeof value2) {
5632
6506
  case "string":
5633
6507
  return ["string"];
5634
6508
  case "boolean":
5635
6509
  return ["boolean"];
5636
6510
  case "number":
5637
- return Number.isInteger(value) ? ["integer", "number"] : ["double", "float", "number"];
6511
+ return Number.isInteger(value2) ? ["integer", "number"] : ["double", "float", "number"];
5638
6512
  case "object":
5639
6513
  return ["array", "object"];
5640
6514
  default:
5641
- return [typeof value];
6515
+ return [typeof value2];
5642
6516
  }
5643
6517
  }
5644
6518
  var AssertableJson = class _AssertableJson {
@@ -5787,7 +6661,7 @@ var AssertableJson = class _AssertableJson {
5787
6661
  return this;
5788
6662
  }
5789
6663
  whereAll(bindings) {
5790
- for (const [key2, value] of Object.entries(bindings)) this.where(key2, value);
6664
+ for (const [key2, value2] of Object.entries(bindings)) this.where(key2, value2);
5791
6665
  return this;
5792
6666
  }
5793
6667
  /** whereType('id', 'integer'), whereType('name', 'string|null'), whereType('tags', ['array', 'null']). */
@@ -5817,7 +6691,7 @@ var AssertableJson = class _AssertableJson {
5817
6691
  const values = typeof actual === "object" && actual !== null ? Object.values(actual) : [actual];
5818
6692
  const wanted = Array.isArray(expected) ? expected : [expected];
5819
6693
  const missing = wanted.filter(
5820
- (item) => typeof item === "function" ? !values.some((value) => item(value)) : !values.some((value) => equals(toPlain(item), value))
6694
+ (item) => typeof item === "function" ? !values.some((value2) => item(value2)) : !values.some((value2) => equals(toPlain(item), value2))
5821
6695
  );
5822
6696
  assert(missing.length === 0, `Property [${this.dotPath(key2)}] does not contain [${missing.map(format).join(", ")}].`, { actual });
5823
6697
  return this;
@@ -5867,14 +6741,14 @@ var AssertableJson = class _AssertableJson {
5867
6741
  return this.prop();
5868
6742
  }
5869
6743
  };
5870
- function sizeOf(value) {
5871
- if (Array.isArray(value)) return value.length;
5872
- if (typeof value === "object" && value !== null) return Object.keys(value).length;
5873
- if (typeof value === "string") return value.length;
6744
+ function sizeOf(value2) {
6745
+ if (Array.isArray(value2)) return value2.length;
6746
+ if (typeof value2 === "object" && value2 !== null) return Object.keys(value2).length;
6747
+ if (typeof value2 === "string") return value2.length;
5874
6748
  return 0;
5875
6749
  }
5876
- function toPlain(value) {
5877
- return value === void 0 ? void 0 : JSON.parse(JSON.stringify(value));
6750
+ function toPlain(value2) {
6751
+ return value2 === void 0 ? void 0 : JSON.parse(JSON.stringify(value2));
5878
6752
  }
5879
6753
  function inertiaPageOf(response2) {
5880
6754
  let page;
@@ -5910,25 +6784,25 @@ var AssertableInertia = class _AssertableInertia extends AssertableJson {
5910
6784
  return this.#page;
5911
6785
  }
5912
6786
  /** The component name; the page file must exist unless `shouldExist` is false (inertia.testing.ensure_pages_exist). */
5913
- component(value, shouldExist) {
6787
+ component(value2, shouldExist) {
5914
6788
  const actual = this.page.component;
5915
- assert(actual === value, "Unexpected Inertia page component.", { actual, expected: value });
6789
+ assert(actual === value2, "Unexpected Inertia page component.", { actual, expected: value2 });
5916
6790
  const app = this.#app();
5917
6791
  const config = app?.bound(ConfigRepository) ? app.make(ConfigRepository) : void 0;
5918
6792
  if (shouldExist === true || shouldExist === void 0 && config?.get("inertia.testing.ensure_pages_exist", true) !== false) {
5919
6793
  const paths = config?.get("inertia.pages.paths", []) ?? [];
5920
6794
  const extensions = config?.get("inertia.pages.extensions", []) ?? [];
5921
- const exists = paths.some((path) => extensions.some((extension) => existsSync25(join25(path, `${value}.${extension}`))));
5922
- if (!exists) fail2(`Inertia page component file [${value}] does not exist.`);
6795
+ const exists = paths.some((path) => extensions.some((extension) => existsSync25(join25(path, `${value2}.${extension}`))));
6796
+ if (!exists) fail2(`Inertia page component file [${value2}] does not exist.`);
5923
6797
  }
5924
6798
  return this;
5925
6799
  }
5926
- url(value) {
5927
- assert(this.page.url === value, "Unexpected Inertia page url.", { actual: this.page.url, expected: value });
6800
+ url(value2) {
6801
+ assert(this.page.url === value2, "Unexpected Inertia page url.", { actual: this.page.url, expected: value2 });
5928
6802
  return this;
5929
6803
  }
5930
- version(value) {
5931
- assert(this.page.version === value, "Unexpected Inertia asset version.", { actual: this.page.version, expected: value });
6804
+ version(value2) {
6805
+ assert(this.page.version === value2, "Unexpected Inertia asset version.", { actual: this.page.version, expected: value2 });
5932
6806
  return this;
5933
6807
  }
5934
6808
  /** The flash data has `key` (dot paths allowed), equal to `expected` when given. */
@@ -6015,14 +6889,14 @@ var AssertableInertia = class _AssertableInertia extends AssertableJson {
6015
6889
  }
6016
6890
  };
6017
6891
  function cookiePrefix(name, key2) {
6018
- return `${createHmac2("sha1", key2).update(`${name}v2`).digest("hex")}|`;
6892
+ return `${createHmac3("sha1", key2).update(`${name}v2`).digest("hex")}|`;
6019
6893
  }
6020
- function encryptCookie(encrypter, name, value) {
6021
- return encrypter.encrypt(cookiePrefix(name, encrypter.getKey()) + value, false);
6894
+ function encryptCookie(encrypter, name, value2) {
6895
+ return encrypter.encrypt(cookiePrefix(name, encrypter.getKey()) + value2, false);
6022
6896
  }
6023
- function decryptCookie(encrypter, name, value) {
6897
+ function decryptCookie(encrypter, name, value2) {
6024
6898
  try {
6025
- const plain = encrypter.decrypt(value, false);
6899
+ const plain = encrypter.decrypt(value2, false);
6026
6900
  const prefix = cookiePrefix(name, encrypter.getKey());
6027
6901
  return plain.startsWith(prefix) ? plain.slice(prefix.length) : void 0;
6028
6902
  } catch {
@@ -6048,14 +6922,14 @@ function parseSetCookie(header) {
6048
6922
  for (const attribute of attributes) {
6049
6923
  const at = attribute.indexOf("=");
6050
6924
  const key2 = (at === -1 ? attribute : attribute.slice(0, at)).trim().toLowerCase();
6051
- const value = at === -1 ? "" : attribute.slice(at + 1).trim();
6052
- if (key2 === "path") cookie.path = value;
6053
- else if (key2 === "domain") cookie.domain = value;
6054
- else if (key2 === "max-age") cookie.maxAge = Number(value);
6055
- else if (key2 === "expires") cookie.expires = new Date(value);
6925
+ const value2 = at === -1 ? "" : attribute.slice(at + 1).trim();
6926
+ if (key2 === "path") cookie.path = value2;
6927
+ else if (key2 === "domain") cookie.domain = value2;
6928
+ else if (key2 === "max-age") cookie.maxAge = Number(value2);
6929
+ else if (key2 === "expires") cookie.expires = new Date(value2);
6056
6930
  else if (key2 === "httponly") cookie.httpOnly = true;
6057
6931
  else if (key2 === "secure") cookie.secure = true;
6058
- else if (key2 === "samesite") cookie.sameSite = value;
6932
+ else if (key2 === "samesite") cookie.sameSite = value2;
6059
6933
  }
6060
6934
  return cookie;
6061
6935
  }
@@ -6067,7 +6941,7 @@ function responseCookies(response2) {
6067
6941
  return response2.headers.getSetCookie().map(parseSetCookie);
6068
6942
  }
6069
6943
  function cookieHeader(cookies) {
6070
- return [...cookies].map(([name, value]) => `${encodeURIComponent(name)}=${encodeURIComponent(value)}`).join("; ");
6944
+ return [...cookies].map(([name, value2]) => `${encodeURIComponent(name)}=${encodeURIComponent(value2)}`).join("; ");
6071
6945
  }
6072
6946
  var REDIRECTS = /* @__PURE__ */ new Set([201, 301, 302, 303, 307, 308]);
6073
6947
  var TestResponse = class _TestResponse {
@@ -6221,10 +7095,10 @@ ${this.excerpt()}`);
6221
7095
  return this;
6222
7096
  }
6223
7097
  // Headers -----------------------------------------------------------------------------------------------
6224
- assertHeader(name, value) {
7098
+ assertHeader(name, value2) {
6225
7099
  const actual = this.headers.get(name);
6226
7100
  assert(actual !== null, `Header [${name}] not present on response.`);
6227
- if (value !== void 0) assert(actual === value, `Header [${name}] was found, but value [${actual}] does not match [${value}].`, { actual, expected: value });
7101
+ if (value2 !== void 0) assert(actual === value2, `Header [${name}] was found, but value [${actual}] does not match [${value2}].`, { actual, expected: value2 });
6228
7102
  return this;
6229
7103
  }
6230
7104
  assertHeaderMissing(name) {
@@ -6241,49 +7115,49 @@ ${this.excerpt()}`);
6241
7115
  return this;
6242
7116
  }
6243
7117
  // Content -----------------------------------------------------------------------------------------------
6244
- assertContent(value) {
6245
- assert(this.content === value, "Response content does not match.", { actual: this.content, expected: value });
7118
+ assertContent(value2) {
7119
+ assert(this.content === value2, "Response content does not match.", { actual: this.content, expected: value2 });
6246
7120
  return this;
6247
7121
  }
6248
7122
  /** The content contains the value(s); values are HTML-escaped first unless `escape` is false (Laravel). */
6249
- assertSee(value, escape = true) {
6250
- for (const needle of this.needles(value, escape)) {
7123
+ assertSee(value2, escape2 = true) {
7124
+ for (const needle of this.needles(value2, escape2)) {
6251
7125
  assert(this.content.includes(needle), `Failed asserting that the response contains [${needle}].
6252
7126
 
6253
7127
  ${this.excerpt()}`);
6254
7128
  }
6255
7129
  return this;
6256
7130
  }
6257
- assertDontSee(value, escape = true) {
6258
- for (const needle of this.needles(value, escape)) {
7131
+ assertDontSee(value2, escape2 = true) {
7132
+ for (const needle of this.needles(value2, escape2)) {
6259
7133
  assert(!this.content.includes(needle), `Failed asserting that the response does not contain [${needle}].
6260
7134
 
6261
7135
  ${this.excerpt()}`);
6262
7136
  }
6263
7137
  return this;
6264
7138
  }
6265
- assertSeeInOrder(values, escape = true) {
6266
- return this.inOrder(this.content, this.needles(values, escape));
7139
+ assertSeeInOrder(values, escape2 = true) {
7140
+ return this.inOrder(this.content, this.needles(values, escape2));
6267
7141
  }
6268
7142
  /** Like assertSee, against the content with its tags stripped. */
6269
- assertSeeText(value, escape = true) {
7143
+ assertSeeText(value2, escape2 = true) {
6270
7144
  const text = stripTags2(this.content);
6271
- for (const needle of this.needles(value, escape)) {
7145
+ for (const needle of this.needles(value2, escape2)) {
6272
7146
  assert(text.includes(needle), `Failed asserting that the response text contains [${needle}].
6273
7147
 
6274
7148
  ${this.excerpt(text)}`);
6275
7149
  }
6276
7150
  return this;
6277
7151
  }
6278
- assertDontSeeText(value, escape = true) {
7152
+ assertDontSeeText(value2, escape2 = true) {
6279
7153
  const text = stripTags2(this.content);
6280
- for (const needle of this.needles(value, escape)) {
7154
+ for (const needle of this.needles(value2, escape2)) {
6281
7155
  assert(!text.includes(needle), `Failed asserting that the response text does not contain [${needle}].`);
6282
7156
  }
6283
7157
  return this;
6284
7158
  }
6285
- assertSeeTextInOrder(values, escape = true) {
6286
- return this.inOrder(stripTags2(this.content), this.needles(values, escape));
7159
+ assertSeeTextInOrder(values, escape2 = true) {
7160
+ return this.inOrder(stripTags2(this.content), this.needles(values, escape2));
6287
7161
  }
6288
7162
  // JSON --------------------------------------------------------------------------------------------------
6289
7163
  /**
@@ -6348,15 +7222,15 @@ ${this.excerpt(text)}`);
6348
7222
  /** Each key/value pair appears somewhere in the JSON (Laravel's assertJsonFragment). */
6349
7223
  assertJsonFragment(data) {
6350
7224
  const actual = this.json();
6351
- for (const [key2, value] of Object.entries(data)) {
6352
- assert(containsPair(actual, key2, value), `Unable to find JSON fragment ${format({ [key2]: value })} in the response.`, { actual, expected: data });
7225
+ for (const [key2, value2] of Object.entries(data)) {
7226
+ assert(containsPair(actual, key2, value2), `Unable to find JSON fragment ${format({ [key2]: value2 })} in the response.`, { actual, expected: data });
6353
7227
  }
6354
7228
  return this;
6355
7229
  }
6356
7230
  /** Passes when at least one pair of `data` is absent (Laravel's assertJsonMissing). */
6357
7231
  assertJsonMissing(data) {
6358
7232
  const actual = this.json();
6359
- const allPresent = Object.entries(data).every(([key2, value]) => containsPair(actual, key2, value));
7233
+ const allPresent = Object.entries(data).every(([key2, value2]) => containsPair(actual, key2, value2));
6360
7234
  assert(!allPresent, `Found unexpected JSON fragment ${format(data)} in the response.`, { actual });
6361
7235
  return this;
6362
7236
  }
@@ -6368,8 +7242,8 @@ ${this.excerpt(text)}`);
6368
7242
  }
6369
7243
  /** The JSON (or the value at `key`) has `count` elements. */
6370
7244
  assertJsonCount(count, key2) {
6371
- const value = this.json(key2);
6372
- const actual = Array.isArray(value) ? value.length : typeof value === "object" && value !== null ? Object.keys(value).length : -1;
7245
+ const value2 = this.json(key2);
7246
+ const actual = Array.isArray(value2) ? value2.length : typeof value2 === "object" && value2 !== null ? Object.keys(value2).length : -1;
6373
7247
  assert(actual === count, `Failed to assert that the response ${key2 === void 0 ? "" : `[${key2}] `}count matched the expected ${count} (got ${actual}).`, { actual, expected: count });
6374
7248
  return this;
6375
7249
  }
@@ -6419,38 +7293,38 @@ ${this.excerpt()}`);
6419
7293
  return session;
6420
7294
  }
6421
7295
  /** A key (with an optional value or predicate), several keys, or a { key: value } record. */
6422
- assertSessionHas(key2, value) {
7296
+ assertSessionHas(key2, value2) {
6423
7297
  if (Array.isArray(key2)) {
6424
7298
  for (const k of key2) this.assertSessionHas(k);
6425
7299
  return this;
6426
7300
  }
6427
7301
  if (typeof key2 === "object") return this.assertSessionHasAll(key2);
6428
7302
  const session = this.session();
6429
- if (value === void 0) {
7303
+ if (value2 === void 0) {
6430
7304
  assert(session.has(key2), `Session is missing expected key [${key2}].`);
6431
- } else if (typeof value === "function") {
6432
- assert(value(session.get(key2)) === true, `Session value for [${key2}] does not pass the given check.`);
7305
+ } else if (typeof value2 === "function") {
7306
+ assert(value2(session.get(key2)) === true, `Session value for [${key2}] does not pass the given check.`);
6433
7307
  } else {
6434
- assert(equals(session.get(key2), value), `Session value for [${key2}] does not match.`, { actual: session.get(key2), expected: value });
7308
+ assert(equals(session.get(key2), value2), `Session value for [${key2}] does not match.`, { actual: session.get(key2), expected: value2 });
6435
7309
  }
6436
7310
  return this;
6437
7311
  }
6438
7312
  assertSessionHasAll(bindings) {
6439
- for (const [key2, value] of Object.entries(bindings)) this.assertSessionHas(key2, value);
7313
+ for (const [key2, value2] of Object.entries(bindings)) this.assertSessionHas(key2, value2);
6440
7314
  return this;
6441
7315
  }
6442
- assertSessionMissing(key2, value) {
7316
+ assertSessionMissing(key2, value2) {
6443
7317
  const session = this.session();
6444
7318
  for (const k of [key2].flat()) {
6445
- if (value === void 0) assert(!session.has(k), `Session has unexpected key [${k}].`);
6446
- else assert(!equals(session.get(k), value), `Session has unexpected value for [${k}].`);
7319
+ if (value2 === void 0) assert(!session.has(k), `Session has unexpected key [${k}].`);
7320
+ else assert(!equals(session.get(k), value2), `Session has unexpected value for [${k}].`);
6447
7321
  }
6448
7322
  return this;
6449
7323
  }
6450
7324
  /** Old input flashed with the redirect (withInput()). */
6451
- assertSessionHasInput(key2, value) {
7325
+ assertSessionHasInput(key2, value2) {
6452
7326
  const session = this.session();
6453
- const entries = typeof key2 === "string" ? [[key2, value]] : Array.isArray(key2) ? key2.map((k) => [k, void 0]) : Object.entries(key2);
7327
+ const entries = typeof key2 === "string" ? [[key2, value2]] : Array.isArray(key2) ? key2.map((k) => [k, void 0]) : Object.entries(key2);
6454
7328
  for (const [k, expected] of entries) {
6455
7329
  const actual = session.getOldInput(k);
6456
7330
  assert(actual !== void 0, `Session is missing expected key [${k}] in the old input.`);
@@ -6509,16 +7383,16 @@ ${JSON.stringify(errors, null, 2)}`, { actual: errors, expected: {} });
6509
7383
  return responseCookies(this.baseResponse).findLast((cookie) => cookie.name === name);
6510
7384
  }
6511
7385
  /** The cookie is set; with `value`, its (decrypted, unless `encrypted` is false) value matches. */
6512
- assertCookie(name, value, encrypted = true) {
7386
+ assertCookie(name, value2, encrypted = true) {
6513
7387
  const cookie = this.getCookie(name);
6514
7388
  assert(cookie !== void 0, `Cookie [${name}] not present on response.`);
6515
- if (value === void 0) return this;
7389
+ if (value2 === void 0) return this;
6516
7390
  const actual = encrypted ? this.decrypted(cookie) : cookie.value;
6517
- assert(actual === value, `Cookie [${name}] was found, but value [${actual}] does not match [${value}].`, { actual, expected: value });
7391
+ assert(actual === value2, `Cookie [${name}] was found, but value [${actual}] does not match [${value2}].`, { actual, expected: value2 });
6518
7392
  return this;
6519
7393
  }
6520
- assertPlainCookie(name, value) {
6521
- return this.assertCookie(name, value, false);
7394
+ assertPlainCookie(name, value2) {
7395
+ return this.assertCookie(name, value2, false);
6522
7396
  }
6523
7397
  assertCookieExpired(name) {
6524
7398
  const cookie = this.getCookie(name);
@@ -6551,18 +7425,18 @@ ${JSON.stringify(errors, null, 2)}`, { actual: errors, expected: {} });
6551
7425
  return this;
6552
7426
  }
6553
7427
  /** The view received `key` (dot paths allowed), optionally with this value or passing this predicate. */
6554
- assertViewHas(key2, value) {
7428
+ assertViewHas(key2, value2) {
6555
7429
  if (typeof key2 !== "string") return this.assertViewHasAll(key2);
6556
7430
  const data = this.viewDataOf(this.ensureView());
6557
7431
  assert(Arr.has(data, key2), `Failed asserting that the view has key [${key2}].`, { actual: Object.keys(data) });
6558
7432
  const actual = Arr.get(data, key2);
6559
- if (typeof value === "function") assert(value(actual) === true, `View data [${key2}] does not pass the given check.`);
6560
- else if (value !== void 0) assert(equals(actual, value), `View data [${key2}] does not match the expected value.`, { actual, expected: value });
7433
+ if (typeof value2 === "function") assert(value2(actual) === true, `View data [${key2}] does not pass the given check.`);
7434
+ else if (value2 !== void 0) assert(equals(actual, value2), `View data [${key2}] does not match the expected value.`, { actual, expected: value2 });
6561
7435
  return this;
6562
7436
  }
6563
7437
  assertViewHasAll(bindings) {
6564
7438
  if (Array.isArray(bindings)) for (const key2 of bindings) this.assertViewHas(key2);
6565
- else for (const [key2, value] of Object.entries(bindings)) this.assertViewHas(key2, value);
7439
+ else for (const [key2, value2] of Object.entries(bindings)) this.assertViewHas(key2, value2);
6566
7440
  return this;
6567
7441
  }
6568
7442
  assertViewMissing(key2) {
@@ -6632,8 +7506,8 @@ ${this.excerpt()}`;
6632
7506
  if (app === void 0 || !app.bound(Encrypter)) return cookie.value;
6633
7507
  return decryptCookie(app.make(Encrypter), cookie.name, cookie.value);
6634
7508
  }
6635
- needles(value, escape) {
6636
- return [value].flat().map((needle) => escape ? escapeHtml2(needle) : needle);
7509
+ needles(value2, escape2) {
7510
+ return [value2].flat().map((needle) => escape2 ? escapeHtml2(needle) : needle);
6637
7511
  }
6638
7512
  inOrder(haystack, needles) {
6639
7513
  let position = 0;
@@ -6662,8 +7536,8 @@ function forward(target2, overrides, before) {
6662
7536
  get(object, property) {
6663
7537
  before?.();
6664
7538
  if (Object.hasOwn(overrides, property)) return overrides[property];
6665
- const value = Reflect.get(object, property, object);
6666
- return typeof value === "function" ? value.bind(object) : value;
7539
+ const value2 = Reflect.get(object, property, object);
7540
+ return typeof value2 === "function" ? value2.bind(object) : value2;
6667
7541
  }
6668
7542
  });
6669
7543
  }
@@ -6880,14 +7754,14 @@ var HttpClient = class {
6880
7754
  let body;
6881
7755
  const data = options.data ?? {};
6882
7756
  if (verb === "GET" || verb === "HEAD") {
6883
- for (const [key2, value] of flatten(data)) if (typeof value === "string") url2.searchParams.append(key2, value);
7757
+ for (const [key2, value2] of flatten(data)) if (typeof value2 === "string") url2.searchParams.append(key2, value2);
6884
7758
  } else if (options.json) {
6885
7759
  body = JSON.stringify(data);
6886
7760
  } else if (Object.keys(data).length > 0) {
6887
7761
  const fields = flatten(data);
6888
- if (fields.some(([, value]) => typeof value !== "string")) {
7762
+ if (fields.some(([, value2]) => typeof value2 !== "string")) {
6889
7763
  const form = new FormData();
6890
- for (const [key2, value] of fields) form.append(key2, value);
7764
+ for (const [key2, value2] of fields) form.append(key2, value2);
6891
7765
  body = form;
6892
7766
  } else {
6893
7767
  body = new URLSearchParams(fields);
@@ -6908,15 +7782,15 @@ var HttpClient = class {
6908
7782
  /** The cookies as EncryptCookies would leave them, since no middleware runs for a Live test. */
6909
7783
  plainCookies() {
6910
7784
  const plain = {};
6911
- for (const [name, { value, encrypt }] of this.cookies) {
6912
- plain[name] = encrypt ? value : this.decrypted(name, value) ?? value;
7785
+ for (const [name, { value: value2, encrypt }] of this.cookies) {
7786
+ plain[name] = encrypt ? value2 : this.decrypted(name, value2) ?? value2;
6913
7787
  }
6914
7788
  return plain;
6915
7789
  }
6916
7790
  /** A cookie kept from a response is as it was sent: encrypted, unless the app excepts it. */
6917
- decrypted(name, value) {
7791
+ decrypted(name, value2) {
6918
7792
  try {
6919
- return this.app.bound(Encrypter) ? decryptCookie(this.app.make(Encrypter), name, value) : void 0;
7793
+ return this.app.bound(Encrypter) ? decryptCookie(this.app.make(Encrypter), name, value2) : void 0;
6920
7794
  } catch {
6921
7795
  return void 0;
6922
7796
  }
@@ -6925,8 +7799,8 @@ var HttpClient = class {
6925
7799
  const needsKey = [...this.cookies.values()].some(({ encrypt }) => encrypt);
6926
7800
  const encrypter = needsKey && this.app.bound(Encrypter) ? this.app.make(Encrypter) : void 0;
6927
7801
  const values = /* @__PURE__ */ new Map();
6928
- for (const [name, { value, encrypt }] of this.cookies) {
6929
- values.set(name, encrypt && encrypter !== void 0 ? encryptCookie(encrypter, name, value) : value);
7802
+ for (const [name, { value: value2, encrypt }] of this.cookies) {
7803
+ values.set(name, encrypt && encrypter !== void 0 ? encryptCookie(encrypter, name, value2) : value2);
6930
7804
  }
6931
7805
  return cookieHeader(values);
6932
7806
  }
@@ -6947,15 +7821,15 @@ function setClientAddress2(request2, address) {
6947
7821
  }
6948
7822
  function flatten(data, prefix = "") {
6949
7823
  const out = [];
6950
- for (const [key2, value] of Object.entries(data)) {
7824
+ for (const [key2, value2] of Object.entries(data)) {
6951
7825
  const name = prefix === "" ? key2 : `${prefix}[${key2}]`;
6952
- if (value === void 0) continue;
6953
- if (value === null) out.push([name, ""]);
6954
- else if (value instanceof Blob) out.push([name, value]);
6955
- else if (value instanceof Date) out.push([name, value.toISOString()]);
6956
- else if (typeof value === "object") out.push(...flatten(value, name));
6957
- else if (typeof value === "boolean") out.push([name, value ? "1" : "0"]);
6958
- else out.push([name, String(value)]);
7826
+ if (value2 === void 0) continue;
7827
+ if (value2 === null) out.push([name, ""]);
7828
+ else if (value2 instanceof Blob) out.push([name, value2]);
7829
+ else if (value2 instanceof Date) out.push([name, value2.toISOString()]);
7830
+ else if (typeof value2 === "object") out.push(...flatten(value2, name));
7831
+ else if (typeof value2 === "boolean") out.push([name, value2 ? "1" : "0"]);
7832
+ else out.push([name, String(value2)]);
6959
7833
  }
6960
7834
  return out;
6961
7835
  }
@@ -7106,8 +7980,8 @@ var MakesHttpRequests = class extends InteractsWithApplication {
7106
7980
  Object.assign(this.http.headers, headers);
7107
7981
  return this;
7108
7982
  }
7109
- withHeader(name, value) {
7110
- this.http.headers[name] = value;
7983
+ withHeader(name, value2) {
7984
+ this.http.headers[name] = value2;
7111
7985
  return this;
7112
7986
  }
7113
7987
  withToken(token2, type = "Bearer") {
@@ -7123,18 +7997,18 @@ var MakesHttpRequests = class extends InteractsWithApplication {
7123
7997
  }
7124
7998
  /** Cookies are encrypted the way EncryptCookies expects when the app has an Encrypter. */
7125
7999
  withCookies(cookies) {
7126
- for (const [name, value] of Object.entries(cookies)) this.http.cookies.set(name, { value, encrypt: true });
8000
+ for (const [name, value2] of Object.entries(cookies)) this.http.cookies.set(name, { value: value2, encrypt: true });
7127
8001
  return this;
7128
8002
  }
7129
- withCookie(name, value) {
7130
- return this.withCookies({ [name]: value });
8003
+ withCookie(name, value2) {
8004
+ return this.withCookies({ [name]: value2 });
7131
8005
  }
7132
8006
  withUnencryptedCookies(cookies) {
7133
- for (const [name, value] of Object.entries(cookies)) this.http.cookies.set(name, { value, encrypt: false });
8007
+ for (const [name, value2] of Object.entries(cookies)) this.http.cookies.set(name, { value: value2, encrypt: false });
7134
8008
  return this;
7135
8009
  }
7136
- withUnencryptedCookie(name, value) {
7137
- return this.withUnencryptedCookies({ [name]: value });
8010
+ withUnencryptedCookie(name, value2) {
8011
+ return this.withUnencryptedCookies({ [name]: value2 });
7138
8012
  }
7139
8013
  /** Follow redirects (always with GET, like Laravel) and return the final response. */
7140
8014
  followingRedirects() {
@@ -7299,8 +8173,8 @@ var InteractsWithTime = class extends InteractsWithConsole {
7299
8173
  travelTo(date, callback) {
7300
8174
  return callback ? travelTo(date, callback) : travelTo(date);
7301
8175
  }
7302
- travel(value) {
7303
- return travel(value);
8176
+ travel(value2) {
8177
+ return travel(value2);
7304
8178
  }
7305
8179
  travelBack() {
7306
8180
  return travelBack();
@@ -7334,15 +8208,15 @@ function nameOf(target2) {
7334
8208
  if (typeof target2 === "function") return target2.name;
7335
8209
  return target2.constructor.name;
7336
8210
  }
7337
- function matches(item, target2) {
8211
+ function matches2(item, target2) {
7338
8212
  if (typeof target2 === "string") return typeof item === "string" ? item === target2 : typeof item === "object" && item !== null && item.constructor.name === target2;
7339
8213
  return typeof item === "object" && item !== null && item.constructor === target2;
7340
8214
  }
7341
8215
  function matchesAny(item, targets) {
7342
- return targets.some((target2) => matches(item, target2));
8216
+ return targets.some((target2) => matches2(item, target2));
7343
8217
  }
7344
8218
  function sameJob(actual, expected) {
7345
- if (typeof expected === "function" || typeof expected === "string") return matches(actual, expected);
8219
+ if (typeof expected === "function" || typeof expected === "string") return matches2(actual, expected);
7346
8220
  return actual.constructor === expected.constructor && equals({ ...actual }, { ...expected });
7347
8221
  }
7348
8222
  var SHOULD_QUEUE = /* @__PURE__ */ Symbol.for("oriel:bus.shouldQueue");
@@ -7354,7 +8228,7 @@ function isQueueable(job) {
7354
8228
  if (QUEUE_OPTIONS.some((option) => members[option] !== void 0)) return true;
7355
8229
  return typeof members.uniqueId === "function" || typeof members.retryUntil === "function";
7356
8230
  }
7357
- var isClass = (value) => typeof value === "function" && typeof value.prototype?.handle === "function";
8231
+ var isClass = (value2) => typeof value2 === "function" && typeof value2.prototype?.handle === "function";
7358
8232
  var asPair = (listener) => {
7359
8233
  if (Array.isArray(listener) && listener.length === 2 && typeof listener[1] === "string") return [listener[0], listener[1]];
7360
8234
  return isClass(listener) ? [listener, "handle"] : void 0;
@@ -7788,6 +8662,16 @@ var QueueFake = class _QueueFake {
7788
8662
  }
7789
8663
  extend(_driver, _factory) {
7790
8664
  }
8665
+ /** The real manager's, so a job pushed past the fake still reaches the callback. */
8666
+ before(callback) {
8667
+ this.manager?.before(callback);
8668
+ }
8669
+ after(callback) {
8670
+ this.manager?.after(callback);
8671
+ }
8672
+ failing(callback) {
8673
+ this.manager?.failing(callback);
8674
+ }
7791
8675
  // Assertions ---------------------------------------------------------------------------------------------
7792
8676
  /** Pushed at least once; a number asserts the count; a filter gets (job, queue, connection). */
7793
8677
  assertPushed(job, callback) {
@@ -8568,8 +9452,8 @@ var BitWriter = class {
8568
9452
  bytes = [];
8569
9453
  buffer = 0;
8570
9454
  count = 0;
8571
- write(value, bits) {
8572
- this.buffer |= value << this.count;
9455
+ write(value2, bits) {
9456
+ this.buffer |= value2 << this.count;
8573
9457
  this.count += bits;
8574
9458
  while (this.count >= 8) {
8575
9459
  this.bytes.push(this.buffer & 255);
@@ -8797,29 +9681,12 @@ export {
8797
9681
  vite,
8798
9682
  viteReactRefresh,
8799
9683
  Application2 as Application,
8800
- ClosureKernel,
8801
9684
  HttpException,
8802
9685
  HttpResponseException,
8803
9686
  HttpServerError,
8804
- exceedsJsonDepth,
8805
- requestScope,
8806
- currentRequest,
8807
- optionalSession,
8808
- optionalCookieJar,
8809
9687
  HttpRedirectResponse,
8810
9688
  HttpRedirector,
8811
- setClientAddress,
8812
- clientAddress,
8813
- extensionFromMime,
8814
9689
  FormUploadedFile,
8815
- parseBracketKey,
8816
- normalizeLists,
8817
- fromEntries,
8818
- sanitize,
8819
- mergeRecursive,
8820
- isBlank,
8821
- transformLeaves,
8822
- ipMatches,
8823
9690
  IncomingRequest,
8824
9691
  request,
8825
9692
  response,
@@ -8832,39 +9699,26 @@ export {
8832
9699
  abortUnless,
8833
9700
  contentDisposition,
8834
9701
  HttpResponseFactory,
8835
- ConvertEmptyStringsToNull,
8836
9702
  TrimStrings,
9703
+ ConvertEmptyStringsToNull,
9704
+ HandleCors,
9705
+ PreventRequestsDuringMaintenance,
8837
9706
  Kernel,
9707
+ TrustHosts,
8838
9708
  MiddlewareConfiguration,
8839
- applyMiddlewareCallbacks,
8840
- statusText,
8841
- escapeHtml,
8842
- minimalPage,
8843
- stackFrames,
8844
- debugPage,
8845
- statusFor,
8846
- summarizeValidation,
8847
9709
  ErrorHandler,
8848
9710
  ExceptionsConfiguration,
8849
- applyExceptionCallbacks,
8850
- servePublicFile,
8851
9711
  ExportError,
8852
9712
  exportSite,
8853
- bunRuntime,
8854
- serveBun,
8855
- toWebRequest,
8856
- writeResponse,
8857
9713
  nodeRequestHandler,
8858
- serveNode,
8859
- detectRuntime,
8860
9714
  serve,
8861
9715
  routeListRows,
8862
- filterRouteList,
8863
- formatRouteList,
8864
- API_ROUTES_STUB,
8865
- addApiRouting,
8866
- registerHttpCommands,
8867
9716
  HttpServiceProvider,
9717
+ MissingValue,
9718
+ ResourceResponse,
9719
+ JsonResource,
9720
+ ResourceCollection,
9721
+ AnonymousResourceCollection,
8868
9722
  LiveError,
8869
9723
  CorruptComponentPayloadError,
8870
9724
  MethodNotCallableError,
@@ -8941,7 +9795,7 @@ export {
8941
9795
  TestCase,
8942
9796
  install2,
8943
9797
  nameOf,
8944
- matches,
9798
+ matches2 as matches,
8945
9799
  EventFake,
8946
9800
  BusFake,
8947
9801
  QueueFake,
@@ -8955,4 +9809,4 @@ export {
8955
9809
  StorageFake,
8956
9810
  FakeFile
8957
9811
  };
8958
- //# sourceMappingURL=chunk-UBSIBGXR.js.map
9812
+ //# sourceMappingURL=chunk-MG4YEWMV.js.map