@equinor/fusion-framework-vite-plugin-spa 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4663,7 +4663,7 @@ function defaultErrorFactory() {
4663
4663
  return new EmptyError();
4664
4664
  }
4665
4665
 
4666
- function finalize(callback) {
4666
+ function finalize$1(callback) {
4667
4667
  return operate(function (source, subscriber) {
4668
4668
  try {
4669
4669
  source.subscribe(subscriber);
@@ -9838,7 +9838,7 @@ const coerce = {
9838
9838
  };
9839
9839
  const NEVER = INVALID;
9840
9840
 
9841
- var z$1 = /*#__PURE__*/Object.freeze({
9841
+ var z = /*#__PURE__*/Object.freeze({
9842
9842
  __proto__: null,
9843
9843
  BRAND: BRAND,
9844
9844
  DIRTY: DIRTY,
@@ -10585,7 +10585,7 @@ const createSseSelector = (options) => {
10585
10585
  eventFilter: options?.eventFilter,
10586
10586
  })).pipe(
10587
10587
  // Stop reading if the abort signal is triggered
10588
- takeUntil(options?.abortSignal ? fromEvent(options.abortSignal, 'abort') : EMPTY), finalize(async () => {
10588
+ takeUntil(options?.abortSignal ? fromEvent(options.abortSignal, 'abort') : EMPTY), finalize$1(async () => {
10589
10589
  // cancel just in case of a pre-mature exit
10590
10590
  await reader.cancel().catch(() => {
10591
10591
  /** ignore cancellation errors */
@@ -10998,21 +10998,21 @@ const configureHttpClient = (name, args) => ({
10998
10998
  var MsalModuleVersion;
10999
10999
  (function (MsalModuleVersion) {
11000
11000
  MsalModuleVersion["V2"] = "v2";
11001
- MsalModuleVersion["Latest"] = "4.0.8";
11001
+ MsalModuleVersion["Latest"] = "4.1.0";
11002
11002
  })(MsalModuleVersion || (MsalModuleVersion = {}));
11003
11003
 
11004
- const VersionSchema = z$1.string().transform((x) => String(semver.coerce(x)));
11005
- const AuthClientConfigSchema = z$1.object({
11006
- clientId: z$1.string(),
11007
- tenantId: z$1.string(),
11008
- redirectUri: z$1.string().optional(),
11004
+ const VersionSchema = z.string().transform((x) => String(semver.coerce(x)));
11005
+ const AuthClientConfigSchema = z.object({
11006
+ clientId: z.string(),
11007
+ tenantId: z.string(),
11008
+ redirectUri: z.string().optional(),
11009
11009
  });
11010
11010
  // NOTE: this might need refinement to validate the provider
11011
- const AuthClientSchema = z$1.custom();
11012
- const AuthConfigSchema = z$1.object({
11011
+ const AuthClientSchema = z.custom();
11012
+ const AuthConfigSchema = z.object({
11013
11013
  client: AuthClientConfigSchema.optional(),
11014
11014
  provider: AuthClientSchema.optional(),
11015
- requiresAuth: z$1.boolean().optional(),
11015
+ requiresAuth: z.boolean().optional(),
11016
11016
  version: VersionSchema,
11017
11017
  });
11018
11018
  class AuthConfigurator extends BaseConfigBuilder {
@@ -29234,27 +29234,228 @@ let ConsoleLogger$1 = class ConsoleLogger extends Logger$1 {
29234
29234
  };
29235
29235
  };
29236
29236
 
29237
+ var VersionMessageType;
29238
+ (function (VersionMessageType) {
29239
+ VersionMessageType["MajorIncompatibility"] = "major-incompatibility";
29240
+ VersionMessageType["MinorMismatch"] = "minor-mismatch";
29241
+ VersionMessageType["PatchDifference"] = "patch-difference";
29242
+ VersionMessageType["InvalidVersion"] = "invalid-version";
29243
+ VersionMessageType["InvalidLatestVersion"] = "invalid-latest-version";
29244
+ VersionMessageType["IncompatibleVersion"] = "incompatible-version";
29245
+ })(VersionMessageType || (VersionMessageType = {}));
29246
+
29247
+ /**
29248
+ * Creates a human-readable version message based on the version message type.
29249
+ *
29250
+ * This function generates descriptive error messages for different version compatibility
29251
+ * scenarios, helping developers understand version-related issues.
29252
+ *
29253
+ * @param type - The type of version message to create
29254
+ * @param requestedVersion - The version that was requested by the user
29255
+ * @param latestVersion - The latest available version in the system
29256
+ * @returns A formatted, human-readable version message string
29257
+ *
29258
+ * @example
29259
+ * ```typescript
29260
+ * const message = createVersionMessage(
29261
+ * VersionMessageType.MajorIncompatibility,
29262
+ * '3.0.0',
29263
+ * '2.1.0'
29264
+ * );
29265
+ * // Returns: "Requested major version 3.0.0 is greater than the latest major version 2.1.0"
29266
+ * ```
29267
+ *
29268
+ * @example
29269
+ * ```typescript
29270
+ * const message = createVersionMessage(
29271
+ * VersionMessageType.MinorMismatch,
29272
+ * '2.1.0',
29273
+ * '2.2.0'
29274
+ * );
29275
+ * // Returns: "Minor version mismatch, requested 2.1.0, latest 2.2.0"
29276
+ * ```
29277
+ */
29278
+ const createVersionMessage = (type, requestedVersion, latestVersion) => {
29279
+ // Convert versions to strings for consistent formatting
29280
+ const requestedVersionString = String(requestedVersion);
29281
+ const latestVersionString = String(latestVersion);
29282
+ switch (type) {
29283
+ case VersionMessageType.MajorIncompatibility:
29284
+ return `Requested major version ${requestedVersionString} is greater than the latest major version ${latestVersionString}`;
29285
+ case VersionMessageType.InvalidVersion:
29286
+ return `Invalid version ${requestedVersionString}`;
29287
+ case VersionMessageType.InvalidLatestVersion:
29288
+ return `Failed to parse latest version "${latestVersionString}" - this indicates the version.ts file was not generated correctly. Check for import errors in the build process.`;
29289
+ case VersionMessageType.MinorMismatch:
29290
+ return `Minor version mismatch, requested ${requestedVersionString}, latest ${latestVersionString}`;
29291
+ case VersionMessageType.PatchDifference:
29292
+ return `Patch version difference, requested ${requestedVersionString}, latest ${latestVersionString}`;
29293
+ case VersionMessageType.IncompatibleVersion:
29294
+ return `Incompatible version, requested ${requestedVersionString}, latest ${latestVersionString}`;
29295
+ default:
29296
+ return createVersionMessage(VersionMessageType.IncompatibleVersion, requestedVersion, latestVersion);
29297
+ }
29298
+ };
29299
+
29300
+ /**
29301
+ * Creates a VersionError instance with a formatted message.
29302
+ *
29303
+ * This is a helper function that creates a VersionError with a human-readable
29304
+ * message based on the error type and version information.
29305
+ *
29306
+ * @param type - The type of version error
29307
+ * @param requestedVersion - The version that was requested
29308
+ * @param latestVersion - The latest available version
29309
+ * @param options - Additional error options including the error type
29310
+ * @returns A new VersionError instance with formatted message
29311
+ */
29312
+ const createVersionError = (type, requestedVersion, latestVersion, options) => {
29313
+ return new VersionError(createVersionMessage(type, requestedVersion, latestVersion), requestedVersion, latestVersion, { ...options, type });
29314
+ };
29315
+ /**
29316
+ * Error class for version-related issues in the MSAL module.
29317
+ *
29318
+ * This error is thrown when there are version compatibility problems,
29319
+ * such as requesting an incompatible major version or providing an invalid version string.
29320
+ *
29321
+ * @example
29322
+ * ```typescript
29323
+ * try {
29324
+ * resolveVersion('3.0.0'); // Assuming latest is 2.x
29325
+ * } catch (error) {
29326
+ * if (error instanceof VersionError) {
29327
+ * console.error('Version error:', error.message);
29328
+ * console.error('Requested:', error.requestedVersion);
29329
+ * console.error('Latest:', error.latestVersion);
29330
+ * console.error('Type:', error.type);
29331
+ * }
29332
+ * }
29333
+ * ```
29334
+ *
29335
+ * @example
29336
+ * ```typescript
29337
+ * // Create a version error manually
29338
+ * const error = VersionError.create(
29339
+ * VersionError.Type.MajorIncompatibility,
29340
+ * '3.0.0',
29341
+ * '2.1.0'
29342
+ * );
29343
+ * ```
29344
+ */
29345
+ class VersionError extends Error {
29346
+ /** The version that was requested by the user */
29347
+ requestedVersion;
29348
+ /** The latest available version in the system */
29349
+ latestVersion;
29350
+ /** The specific type of version error that occurred */
29351
+ type;
29352
+ /** The error name for instanceof checks */
29353
+ static Name = 'VersionError';
29354
+ /** Reference to the VersionMessageType enum for convenience */
29355
+ static Type = VersionMessageType;
29356
+ /** Factory method for creating VersionError instances with formatted messages */
29357
+ static create = createVersionError;
29358
+ /**
29359
+ * Creates a new VersionError instance.
29360
+ *
29361
+ * @param message - The error message describing the version issue
29362
+ * @param requestedVersion - The version that was requested (will be stored as string)
29363
+ * @param latestVersion - The latest available version (will be stored as string)
29364
+ * @param options - Additional error options including the error type
29365
+ */
29366
+ constructor(message, requestedVersion, latestVersion, options) {
29367
+ super(message, options);
29368
+ this.name = VersionError.Name;
29369
+ // Store versions as strings
29370
+ this.requestedVersion = String(requestedVersion);
29371
+ this.latestVersion = String(latestVersion);
29372
+ this.type = options?.type;
29373
+ }
29374
+ }
29375
+
29376
+ /**
29377
+ * Resolves and validates a version string against the latest available MSAL version.
29378
+ *
29379
+ * This function performs comprehensive version checking including:
29380
+ * - Parsing and validating the requested version
29381
+ * - Checking major version compatibility (throws on incompatibility)
29382
+ * - Warning on minor version mismatches (logs warning but continues)
29383
+ * - Ignoring patch version differences for maximum compatibility
29384
+ *
29385
+ * @param version - The version string or SemVer object to resolve. If not provided, defaults to latest.
29386
+ * @returns A ResolvedVersion object containing parsed versions and compatibility information
29387
+ *
29388
+ * @throws {VersionError} When the requested version is invalid or incompatible
29389
+ *
29390
+ * @example
29391
+ * ```typescript
29392
+ * // Resolve a specific version
29393
+ * const result = resolveVersion('2.1.0');
29394
+ * console.log(result.satisfiesLatest); // true if major version matches
29395
+ *
29396
+ * // Resolve with SemVer object
29397
+ * const result2 = resolveVersion(new SemVer('2.0.0'));
29398
+ *
29399
+ * // Default to latest version
29400
+ * const result3 = resolveVersion();
29401
+ * ```
29402
+ *
29403
+ * @example
29404
+ * ```typescript
29405
+ * // Error handling
29406
+ * try {
29407
+ * const result = resolveVersion('3.0.0'); // Assuming latest is 2.x
29408
+ * } catch (error) {
29409
+ * if (error instanceof VersionError) {
29410
+ * console.error('Version error:', error.message);
29411
+ * }
29412
+ * }
29413
+ * ```
29414
+ */
29237
29415
  function resolveVersion(version) {
29238
- const wantedVersion = semver.coerce(version || MsalModuleVersion.Latest);
29416
+ // Initialize warnings array to collect any version mismatches
29417
+ const warnings = [];
29418
+ // Parse the requested version, defaulting to latest if not provided
29419
+ const versionString = version || MsalModuleVersion.Latest;
29420
+ // Parse versions using coerce for backward compatibility
29421
+ const wantedVersion = semver.coerce(versionString);
29239
29422
  const latestVersion = semver.coerce(MsalModuleVersion.Latest);
29240
- // check if version is valid semver version
29423
+ // Validate that the requested version is a valid semver
29241
29424
  if (!wantedVersion) {
29242
- throw new Error(`Invalid version ${version} provided`);
29425
+ throw VersionError.create(VersionError.Type.InvalidVersion, versionString, MsalModuleVersion.Latest);
29243
29426
  }
29427
+ // This should never happen! Indicates version.ts was not generated correctly
29428
+ // This is a critical build-time issue that needs immediate attention
29244
29429
  if (!latestVersion) {
29245
- throw new Error('Invalid latest version');
29430
+ throw VersionError.create(VersionError.Type.InvalidLatestVersion, versionString, MsalModuleVersion.Latest);
29431
+ }
29432
+ // Major version incompatibility check - this is a hard error
29433
+ // Users cannot request a major version that doesn't exist yet
29434
+ if (wantedVersion.major > latestVersion.major) {
29435
+ throw VersionError.create(VersionError.Type.MajorIncompatibility, String(wantedVersion), String(latestVersion));
29246
29436
  }
29247
- // check if version is greater than latest
29248
- if (semver.gt(wantedVersion, latestVersion)) {
29249
- throw new Error(`Requested version ${version} is greater than the latest version ${MsalModuleVersion.Latest}`);
29437
+ // Minor version mismatch - add warning but don't throw
29438
+ // This helps developers stay aware of version differences without breaking functionality
29439
+ if (wantedVersion.major === latestVersion.major && wantedVersion.minor !== latestVersion.minor) {
29440
+ const minorMismatchWarning = VersionError.create(VersionError.Type.MinorMismatch, String(wantedVersion), String(latestVersion));
29441
+ warnings.push(minorMismatchWarning.message);
29250
29442
  }
29443
+ // Find the corresponding enum version for the requested major version
29444
+ // This is used for module configuration and feature detection
29251
29445
  const enumVersion = Object.values(MsalModuleVersion).find((x) => semver.coerce(x)?.major === wantedVersion.major);
29446
+ // If no matching enum version is found, this indicates a major version
29447
+ // that doesn't have a corresponding enum value defined
29448
+ if (!enumVersion) {
29449
+ throw VersionError.create(VersionError.Type.MajorIncompatibility, String(wantedVersion), String(latestVersion));
29450
+ }
29451
+ // Return comprehensive version resolution result
29252
29452
  return {
29253
29453
  wantedVersion,
29254
29454
  latestVersion,
29255
- enumVersion,
29256
29455
  isLatest: wantedVersion.compare(latestVersion) === 0,
29257
29456
  satisfiesLatest: wantedVersion.major === latestVersion.major,
29457
+ enumVersion,
29458
+ warnings: warnings.length > 0 ? warnings : undefined,
29258
29459
  };
29259
29460
  }
29260
29461
 
@@ -29544,10 +29745,7 @@ function v35(version, hash, value, namespace, buf, offset) {
29544
29745
  const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
29545
29746
  var native = { randomUUID };
29546
29747
 
29547
- function v4(options, buf, offset) {
29548
- if (native.randomUUID && true && !options) {
29549
- return native.randomUUID();
29550
- }
29748
+ function _v4(options, buf, offset) {
29551
29749
  options = options || {};
29552
29750
  const rnds = options.random ?? options.rng?.() ?? rng();
29553
29751
  if (rnds.length < 16) {
@@ -29557,8 +29755,14 @@ function v4(options, buf, offset) {
29557
29755
  rnds[8] = (rnds[8] & 0x3f) | 0x80;
29558
29756
  return unsafeStringify(rnds);
29559
29757
  }
29758
+ function v4(options, buf, offset) {
29759
+ if (native.randomUUID && true && !options) {
29760
+ return native.randomUUID();
29761
+ }
29762
+ return _v4(options);
29763
+ }
29560
29764
 
29561
- function f$1(s, x, y, z) {
29765
+ function f(s, x, y, z) {
29562
29766
  switch (s) {
29563
29767
  case 0:
29564
29768
  return (x & y) ^ (~x & z);
@@ -29612,7 +29816,7 @@ function sha1(bytes) {
29612
29816
  let e = H[4];
29613
29817
  for (let t = 0; t < 80; ++t) {
29614
29818
  const s = Math.floor(t / 20);
29615
- const T = (ROTL(a, 5) + f$1(s, b, c, d) + e + K[s] + W[t]) >>> 0;
29819
+ const T = (ROTL(a, 5) + f(s, b, c, d) + e + K[s] + W[t]) >>> 0;
29616
29820
  e = d;
29617
29821
  d = c;
29618
29822
  c = ROTL(b, 30) >>> 0;
@@ -29672,7 +29876,711 @@ class QueryClientError extends Error {
29672
29876
  }
29673
29877
  }
29674
29878
 
29675
- function n(n){for(var r=arguments.length,t=Array(r>1?r-1:0),e=1;e<r;e++)t[e-1]=arguments[e];if("production"!==process.env.NODE_ENV){var i=Y[n],o=i?"function"==typeof i?i.apply(null,t):i:"unknown error nr: "+n;throw Error("[Immer] "+o)}throw Error("[Immer] minified error nr: "+n+(t.length?" "+t.map((function(n){return "'"+n+"'"})).join(","):"")+". Find the full error at: https://bit.ly/3cXEKWf")}function r(n){return !!n&&!!n[Q]}function t(n){var r;return !!n&&(function(n){if(!n||"object"!=typeof n)return false;var r=Object.getPrototypeOf(n);if(null===r)return true;var t=Object.hasOwnProperty.call(r,"constructor")&&r.constructor;return t===Object||"function"==typeof t&&Function.toString.call(t)===Z}(n)||Array.isArray(n)||!!n[L]||!!(null===(r=n.constructor)||void 0===r?void 0:r[L])||s(n)||v(n))}function i(n,r,t){ void 0===t&&(t=false),0===o(n)?(t?Object.keys:nn)(n).forEach((function(e){t&&"symbol"==typeof e||r(e,n[e],n);})):n.forEach((function(t,e){return r(e,t,n)}));}function o(n){var r=n[Q];return r?r.i>3?r.i-4:r.i:Array.isArray(n)?1:s(n)?2:v(n)?3:0}function u(n,r){return 2===o(n)?n.has(r):Object.prototype.hasOwnProperty.call(n,r)}function a(n,r){return 2===o(n)?n.get(r):n[r]}function f(n,r,t){var e=o(n);2===e?n.set(r,t):3===e?n.add(t):n[r]=t;}function c(n,r){return n===r?0!==n||1/n==1/r:n!=n&&r!=r}function s(n){return X&&n instanceof Map}function v(n){return q&&n instanceof Set}function p(n){return n.o||n.t}function l(n){if(Array.isArray(n))return Array.prototype.slice.call(n);var r=rn(n);delete r[Q];for(var t=nn(r),e=0;e<t.length;e++){var i=t[e],o=r[i];false===o.writable&&(o.writable=true,o.configurable=true),(o.get||o.set)&&(r[i]={configurable:true,writable:true,enumerable:o.enumerable,value:n[i]});}return Object.create(Object.getPrototypeOf(n),r)}function d(n,e){return void 0===e&&(e=false),y(n)||r(n)||!t(n)||(o(n)>1&&(n.set=n.add=n.clear=n.delete=h),Object.freeze(n),e&&i(n,(function(n,r){return d(r,true)}),true)),n}function h(){n(2);}function y(n){return null==n||"object"!=typeof n||Object.isFrozen(n)}function b(r){var t=tn[r];return t||n(18,r),t}function _(){return "production"===process.env.NODE_ENV||U||n(0),U}function j(n,r){r&&(b("Patches"),n.u=[],n.s=[],n.v=r);}function g(n){O(n),n.p.forEach(S),n.p=null;}function O(n){n===U&&(U=n.l);}function w(n){return U={p:[],l:U,h:n,m:true,_:0}}function S(n){var r=n[Q];0===r.i||1===r.i?r.j():r.g=true;}function P(r,e){e._=e.p.length;var i=e.p[0],o=void 0!==r&&r!==i;return e.h.O||b("ES5").S(e,r,o),o?(i[Q].P&&(g(e),n(4)),t(r)&&(r=M(e,r),e.l||x(e,r)),e.u&&b("Patches").M(i[Q].t,r,e.u,e.s)):r=M(e,i,[]),g(e),e.u&&e.v(e.u,e.s),r!==H?r:void 0}function M(n,r,t){if(y(r))return r;var e=r[Q];if(!e)return i(r,(function(i,o){return A(n,e,r,i,o,t)}),true),r;if(e.A!==n)return r;if(!e.P)return x(n,e.t,true),e.t;if(!e.I){e.I=true,e.A._--;var o=4===e.i||5===e.i?e.o=l(e.k):e.o,u=o,a=false;3===e.i&&(u=new Set(o),o.clear(),a=true),i(u,(function(r,i){return A(n,e,o,r,i,t,a)})),x(n,o,false),t&&n.u&&b("Patches").N(e,t,n.u,n.s);}return e.o}function A(e,i,o,a,c,s,v){if("production"!==process.env.NODE_ENV&&c===o&&n(5),r(c)){var p=M(e,c,s&&i&&3!==i.i&&!u(i.R,a)?s.concat(a):void 0);if(f(o,a,p),!r(p))return;e.m=false;}else v&&o.add(c);if(t(c)&&!y(c)){if(!e.h.D&&e._<1)return;M(e,c),i&&i.A.l||x(e,c);}}function x(n,r,t){ void 0===t&&(t=false),!n.l&&n.h.D&&n.m&&d(r,t);}function z(n,r){var t=n[Q];return (t?p(t):n)[r]}function I(n,r){if(r in n)for(var t=Object.getPrototypeOf(n);t;){var e=Object.getOwnPropertyDescriptor(t,r);if(e)return e;t=Object.getPrototypeOf(t);}}function k(n){n.P||(n.P=true,n.l&&k(n.l));}function E(n){n.o||(n.o=l(n.t));}function N(n,r,t){var e=s(r)?b("MapSet").F(r,t):v(r)?b("MapSet").T(r,t):n.O?function(n,r){var t=Array.isArray(n),e={i:t?1:0,A:r?r.A:_(),P:false,I:false,R:{},l:r,t:n,k:null,o:null,j:null,C:false},i=e,o=en;t&&(i=[e],o=on);var u=Proxy.revocable(i,o),a=u.revoke,f=u.proxy;return e.k=f,e.j=a,f}(r,t):b("ES5").J(r,t);return (t?t.A:_()).p.push(e),e}function R(e){return r(e)||n(22,e),function n(r){if(!t(r))return r;var e,u=r[Q],c=o(r);if(u){if(!u.P&&(u.i<4||!b("ES5").K(u)))return u.t;u.I=true,e=D(r,c),u.I=false;}else e=D(r,c);return i(e,(function(r,t){u&&a(u.t,r)===t||f(e,r,n(t));})),3===c?new Set(e):e}(e)}function D(n,r){switch(r){case 2:return new Map(n);case 3:return Array.from(n)}return l(n)}function K(n){return n}var G,U,W="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),X="undefined"!=typeof Map,q="undefined"!=typeof Set,B="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,H=W?Symbol.for("immer-nothing"):((G={})["immer-nothing"]=true,G),L=W?Symbol.for("immer-draftable"):"__$immer_draftable",Q=W?Symbol.for("immer-state"):"__$immer_state",Y={0:"Illegal state",1:"Immer drafts cannot have computed properties",2:"This object has been frozen and should not be mutated",3:function(n){return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+n},4:"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",5:"Immer forbids circular references",6:"The first or second argument to `produce` must be a function",7:"The third argument to `produce` must be a function or undefined",8:"First argument to `createDraft` must be a plain object, an array, or an immerable object",9:"First argument to `finishDraft` must be a draft returned by `createDraft`",10:"The given draft is already finalized",11:"Object.defineProperty() cannot be used on an Immer draft",12:"Object.setPrototypeOf() cannot be used on an Immer draft",13:"Immer only supports deleting array indices",14:"Immer only supports setting array indices and the 'length' property",15:function(n){return "Cannot apply patch, path doesn't resolve: "+n},16:'Sets cannot have "replace" patches.',17:function(n){return "Unsupported patch operation: "+n},18:function(n){return "The plugin for '"+n+"' has not been loaded into Immer. To enable the plugin, import and call `enable"+n+"()` when initializing your application."},20:"Cannot use proxies if Proxy, Proxy.revocable or Reflect are not available",21:function(n){return "produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '"+n+"'"},22:function(n){return "'current' expects a draft, got: "+n},23:function(n){return "'original' expects a draft, got: "+n},24:"Patching reserved attributes like __proto__, prototype and constructor is not allowed"},Z=""+Object.prototype.constructor,nn="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Object.getOwnPropertyNames,rn=Object.getOwnPropertyDescriptors||function(n){var r={};return nn(n).forEach((function(t){r[t]=Object.getOwnPropertyDescriptor(n,t);})),r},tn={},en={get:function(n,r){if(r===Q)return n;var e=p(n);if(!u(e,r))return function(n,r,t){var e,i=I(r,t);return i?"value"in i?i.value:null===(e=i.get)||void 0===e?void 0:e.call(n.k):void 0}(n,e,r);var i=e[r];return n.I||!t(i)?i:i===z(n.t,r)?(E(n),n.o[r]=N(n.A.h,i,n)):i},has:function(n,r){return r in p(n)},ownKeys:function(n){return Reflect.ownKeys(p(n))},set:function(n,r,t){var e=I(p(n),r);if(null==e?void 0:e.set)return e.set.call(n.k,t),true;if(!n.P){var i=z(p(n),r),o=null==i?void 0:i[Q];if(o&&o.t===t)return n.o[r]=t,n.R[r]=false,true;if(c(t,i)&&(void 0!==t||u(n.t,r)))return true;E(n),k(n);}return n.o[r]===t&&(void 0!==t||r in n.o)||Number.isNaN(t)&&Number.isNaN(n.o[r])||(n.o[r]=t,n.R[r]=true),true},deleteProperty:function(n,r){return void 0!==z(n.t,r)||r in n.t?(n.R[r]=false,E(n),k(n)):delete n.R[r],n.o&&delete n.o[r],true},getOwnPropertyDescriptor:function(n,r){var t=p(n),e=Reflect.getOwnPropertyDescriptor(t,r);return e?{writable:true,configurable:1!==n.i||"length"!==r,enumerable:e.enumerable,value:t[r]}:e},defineProperty:function(){n(11);},getPrototypeOf:function(n){return Object.getPrototypeOf(n.t)},setPrototypeOf:function(){n(12);}},on={};i(en,(function(n,r){on[n]=function(){return arguments[0]=arguments[0][0],r.apply(this,arguments)};})),on.deleteProperty=function(r,t){return "production"!==process.env.NODE_ENV&&isNaN(parseInt(t))&&n(13),on.set.call(this,r,t,void 0)},on.set=function(r,t,e){return "production"!==process.env.NODE_ENV&&"length"!==t&&isNaN(parseInt(t))&&n(14),en.set.call(this,r[0],t,e,r[0])};var un=function(){function e(r){var e=this;this.O=B,this.D=true,this.produce=function(r,i,o){if("function"==typeof r&&"function"!=typeof i){var u=i;i=r;var a=e;return function(n){var r=this;void 0===n&&(n=u);for(var t=arguments.length,e=Array(t>1?t-1:0),o=1;o<t;o++)e[o-1]=arguments[o];return a.produce(n,(function(n){var t;return (t=i).call.apply(t,[r,n].concat(e))}))}}var f;if("function"!=typeof i&&n(6),void 0!==o&&"function"!=typeof o&&n(7),t(r)){var c=w(e),s=N(e,r,void 0),v=true;try{f=i(s),v=!1;}finally{v?g(c):O(c);}return "undefined"!=typeof Promise&&f instanceof Promise?f.then((function(n){return j(c,o),P(n,c)}),(function(n){throw g(c),n})):(j(c,o),P(f,c))}if(!r||"object"!=typeof r){if(void 0===(f=i(r))&&(f=r),f===H&&(f=void 0),e.D&&d(f,true),o){var p=[],l=[];b("Patches").M(r,f,p,l),o(p,l);}return f}n(21,r);},this.produceWithPatches=function(n,r){if("function"==typeof n)return function(r){for(var t=arguments.length,i=Array(t>1?t-1:0),o=1;o<t;o++)i[o-1]=arguments[o];return e.produceWithPatches(r,(function(r){return n.apply(void 0,[r].concat(i))}))};var t,i,o=e.produce(n,r,(function(n,r){t=n,i=r;}));return "undefined"!=typeof Promise&&o instanceof Promise?o.then((function(n){return [n,t,i]})):[o,t,i]},"boolean"==typeof(null==r?void 0:r.useProxies)&&this.setUseProxies(r.useProxies),"boolean"==typeof(null==r?void 0:r.autoFreeze)&&this.setAutoFreeze(r.autoFreeze);}var i=e.prototype;return i.createDraft=function(e){t(e)||n(8),r(e)&&(e=R(e));var i=w(this),o=N(this,e,void 0);return o[Q].C=true,O(i),o},i.finishDraft=function(r,t){var e=r&&r[Q];"production"!==process.env.NODE_ENV&&(e&&e.C||n(9),e.I&&n(10));var i=e.A;return j(i,t),P(void 0,i)},i.setAutoFreeze=function(n){this.D=n;},i.setUseProxies=function(r){r&&!B&&n(20),this.O=r;},i.applyPatches=function(n,t){var e;for(e=t.length-1;e>=0;e--){var i=t[e];if(0===i.path.length&&"replace"===i.op){n=i.value;break}}e>-1&&(t=t.slice(e+1));var o=b("Patches").$;return r(n)?o(n,t):this.produce(n,(function(n){return o(n,t)}))},e}(),an=new un,fn=an.produce;an.produceWithPatches.bind(an);an.setAutoFreeze.bind(an);an.setUseProxies.bind(an);an.applyPatches.bind(an);an.createDraft.bind(an);an.finishDraft.bind(an);
29879
+ // src/utils/env.ts
29880
+ var NOTHING = Symbol.for("immer-nothing");
29881
+ var DRAFTABLE = Symbol.for("immer-draftable");
29882
+ var DRAFT_STATE = Symbol.for("immer-state");
29883
+
29884
+ // src/utils/errors.ts
29885
+ var errors = process.env.NODE_ENV !== "production" ? [
29886
+ // All error codes, starting by 0:
29887
+ function(plugin) {
29888
+ return `The plugin for '${plugin}' has not been loaded into Immer. To enable the plugin, import and call \`enable${plugin}()\` when initializing your application.`;
29889
+ },
29890
+ function(thing) {
29891
+ return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${thing}'`;
29892
+ },
29893
+ "This object has been frozen and should not be mutated",
29894
+ function(data) {
29895
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + data;
29896
+ },
29897
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
29898
+ "Immer forbids circular references",
29899
+ "The first or second argument to `produce` must be a function",
29900
+ "The third argument to `produce` must be a function or undefined",
29901
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
29902
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
29903
+ function(thing) {
29904
+ return `'current' expects a draft, got: ${thing}`;
29905
+ },
29906
+ "Object.defineProperty() cannot be used on an Immer draft",
29907
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
29908
+ "Immer only supports deleting array indices",
29909
+ "Immer only supports setting array indices and the 'length' property",
29910
+ function(thing) {
29911
+ return `'original' expects a draft, got: ${thing}`;
29912
+ }
29913
+ // Note: if more errors are added, the errorOffset in Patches.ts should be increased
29914
+ // See Patches.ts for additional errors
29915
+ ] : [];
29916
+ function die(error, ...args) {
29917
+ if (process.env.NODE_ENV !== "production") {
29918
+ const e = errors[error];
29919
+ const msg = typeof e === "function" ? e.apply(null, args) : e;
29920
+ throw new Error(`[Immer] ${msg}`);
29921
+ }
29922
+ throw new Error(
29923
+ `[Immer] minified error nr: ${error}. Full error at: https://bit.ly/3cXEKWf`
29924
+ );
29925
+ }
29926
+
29927
+ // src/utils/common.ts
29928
+ var getPrototypeOf = Object.getPrototypeOf;
29929
+ function isDraft(value) {
29930
+ return !!value && !!value[DRAFT_STATE];
29931
+ }
29932
+ function isDraftable(value) {
29933
+ if (!value)
29934
+ return false;
29935
+ return isPlainObject(value) || Array.isArray(value) || !!value[DRAFTABLE] || !!value.constructor?.[DRAFTABLE] || isMap(value) || isSet(value);
29936
+ }
29937
+ var objectCtorString = Object.prototype.constructor.toString();
29938
+ function isPlainObject(value) {
29939
+ if (!value || typeof value !== "object")
29940
+ return false;
29941
+ const proto = getPrototypeOf(value);
29942
+ if (proto === null) {
29943
+ return true;
29944
+ }
29945
+ const Ctor = Object.hasOwnProperty.call(proto, "constructor") && proto.constructor;
29946
+ if (Ctor === Object)
29947
+ return true;
29948
+ return typeof Ctor == "function" && Function.toString.call(Ctor) === objectCtorString;
29949
+ }
29950
+ function each(obj, iter) {
29951
+ if (getArchtype(obj) === 0 /* Object */) {
29952
+ Reflect.ownKeys(obj).forEach((key) => {
29953
+ iter(key, obj[key], obj);
29954
+ });
29955
+ } else {
29956
+ obj.forEach((entry, index) => iter(index, entry, obj));
29957
+ }
29958
+ }
29959
+ function getArchtype(thing) {
29960
+ const state = thing[DRAFT_STATE];
29961
+ return state ? state.type_ : Array.isArray(thing) ? 1 /* Array */ : isMap(thing) ? 2 /* Map */ : isSet(thing) ? 3 /* Set */ : 0 /* Object */;
29962
+ }
29963
+ function has(thing, prop) {
29964
+ return getArchtype(thing) === 2 /* Map */ ? thing.has(prop) : Object.prototype.hasOwnProperty.call(thing, prop);
29965
+ }
29966
+ function set(thing, propOrOldValue, value) {
29967
+ const t = getArchtype(thing);
29968
+ if (t === 2 /* Map */)
29969
+ thing.set(propOrOldValue, value);
29970
+ else if (t === 3 /* Set */) {
29971
+ thing.add(value);
29972
+ } else
29973
+ thing[propOrOldValue] = value;
29974
+ }
29975
+ function is(x, y) {
29976
+ if (x === y) {
29977
+ return x !== 0 || 1 / x === 1 / y;
29978
+ } else {
29979
+ return x !== x && y !== y;
29980
+ }
29981
+ }
29982
+ function isMap(target) {
29983
+ return target instanceof Map;
29984
+ }
29985
+ function isSet(target) {
29986
+ return target instanceof Set;
29987
+ }
29988
+ function latest(state) {
29989
+ return state.copy_ || state.base_;
29990
+ }
29991
+ function shallowCopy(base, strict) {
29992
+ if (isMap(base)) {
29993
+ return new Map(base);
29994
+ }
29995
+ if (isSet(base)) {
29996
+ return new Set(base);
29997
+ }
29998
+ if (Array.isArray(base))
29999
+ return Array.prototype.slice.call(base);
30000
+ const isPlain = isPlainObject(base);
30001
+ if (strict === true || strict === "class_only" && !isPlain) {
30002
+ const descriptors = Object.getOwnPropertyDescriptors(base);
30003
+ delete descriptors[DRAFT_STATE];
30004
+ let keys = Reflect.ownKeys(descriptors);
30005
+ for (let i = 0; i < keys.length; i++) {
30006
+ const key = keys[i];
30007
+ const desc = descriptors[key];
30008
+ if (desc.writable === false) {
30009
+ desc.writable = true;
30010
+ desc.configurable = true;
30011
+ }
30012
+ if (desc.get || desc.set)
30013
+ descriptors[key] = {
30014
+ configurable: true,
30015
+ writable: true,
30016
+ // could live with !!desc.set as well here...
30017
+ enumerable: desc.enumerable,
30018
+ value: base[key]
30019
+ };
30020
+ }
30021
+ return Object.create(getPrototypeOf(base), descriptors);
30022
+ } else {
30023
+ const proto = getPrototypeOf(base);
30024
+ if (proto !== null && isPlain) {
30025
+ return { ...base };
30026
+ }
30027
+ const obj = Object.create(proto);
30028
+ return Object.assign(obj, base);
30029
+ }
30030
+ }
30031
+ function freeze(obj, deep = false) {
30032
+ if (isFrozen(obj) || isDraft(obj) || !isDraftable(obj))
30033
+ return obj;
30034
+ if (getArchtype(obj) > 1) {
30035
+ Object.defineProperties(obj, {
30036
+ set: { value: dontMutateFrozenCollections },
30037
+ add: { value: dontMutateFrozenCollections },
30038
+ clear: { value: dontMutateFrozenCollections },
30039
+ delete: { value: dontMutateFrozenCollections }
30040
+ });
30041
+ }
30042
+ Object.freeze(obj);
30043
+ if (deep)
30044
+ Object.values(obj).forEach((value) => freeze(value, true));
30045
+ return obj;
30046
+ }
30047
+ function dontMutateFrozenCollections() {
30048
+ die(2);
30049
+ }
30050
+ function isFrozen(obj) {
30051
+ return Object.isFrozen(obj);
30052
+ }
30053
+
30054
+ // src/utils/plugins.ts
30055
+ var plugins = {};
30056
+ function getPlugin(pluginKey) {
30057
+ const plugin = plugins[pluginKey];
30058
+ if (!plugin) {
30059
+ die(0, pluginKey);
30060
+ }
30061
+ return plugin;
30062
+ }
30063
+
30064
+ // src/core/scope.ts
30065
+ var currentScope;
30066
+ function getCurrentScope() {
30067
+ return currentScope;
30068
+ }
30069
+ function createScope(parent_, immer_) {
30070
+ return {
30071
+ drafts_: [],
30072
+ parent_,
30073
+ immer_,
30074
+ // Whenever the modified draft contains a draft from another scope, we
30075
+ // need to prevent auto-freezing so the unowned draft can be finalized.
30076
+ canAutoFreeze_: true,
30077
+ unfinalizedDrafts_: 0
30078
+ };
30079
+ }
30080
+ function usePatchesInScope(scope, patchListener) {
30081
+ if (patchListener) {
30082
+ getPlugin("Patches");
30083
+ scope.patches_ = [];
30084
+ scope.inversePatches_ = [];
30085
+ scope.patchListener_ = patchListener;
30086
+ }
30087
+ }
30088
+ function revokeScope(scope) {
30089
+ leaveScope(scope);
30090
+ scope.drafts_.forEach(revokeDraft);
30091
+ scope.drafts_ = null;
30092
+ }
30093
+ function leaveScope(scope) {
30094
+ if (scope === currentScope) {
30095
+ currentScope = scope.parent_;
30096
+ }
30097
+ }
30098
+ function enterScope(immer2) {
30099
+ return currentScope = createScope(currentScope, immer2);
30100
+ }
30101
+ function revokeDraft(draft) {
30102
+ const state = draft[DRAFT_STATE];
30103
+ if (state.type_ === 0 /* Object */ || state.type_ === 1 /* Array */)
30104
+ state.revoke_();
30105
+ else
30106
+ state.revoked_ = true;
30107
+ }
30108
+
30109
+ // src/core/finalize.ts
30110
+ function processResult(result, scope) {
30111
+ scope.unfinalizedDrafts_ = scope.drafts_.length;
30112
+ const baseDraft = scope.drafts_[0];
30113
+ const isReplaced = result !== void 0 && result !== baseDraft;
30114
+ if (isReplaced) {
30115
+ if (baseDraft[DRAFT_STATE].modified_) {
30116
+ revokeScope(scope);
30117
+ die(4);
30118
+ }
30119
+ if (isDraftable(result)) {
30120
+ result = finalize(scope, result);
30121
+ if (!scope.parent_)
30122
+ maybeFreeze(scope, result);
30123
+ }
30124
+ if (scope.patches_) {
30125
+ getPlugin("Patches").generateReplacementPatches_(
30126
+ baseDraft[DRAFT_STATE].base_,
30127
+ result,
30128
+ scope.patches_,
30129
+ scope.inversePatches_
30130
+ );
30131
+ }
30132
+ } else {
30133
+ result = finalize(scope, baseDraft, []);
30134
+ }
30135
+ revokeScope(scope);
30136
+ if (scope.patches_) {
30137
+ scope.patchListener_(scope.patches_, scope.inversePatches_);
30138
+ }
30139
+ return result !== NOTHING ? result : void 0;
30140
+ }
30141
+ function finalize(rootScope, value, path) {
30142
+ if (isFrozen(value))
30143
+ return value;
30144
+ const state = value[DRAFT_STATE];
30145
+ if (!state) {
30146
+ each(
30147
+ value,
30148
+ (key, childValue) => finalizeProperty(rootScope, state, value, key, childValue, path)
30149
+ );
30150
+ return value;
30151
+ }
30152
+ if (state.scope_ !== rootScope)
30153
+ return value;
30154
+ if (!state.modified_) {
30155
+ maybeFreeze(rootScope, state.base_, true);
30156
+ return state.base_;
30157
+ }
30158
+ if (!state.finalized_) {
30159
+ state.finalized_ = true;
30160
+ state.scope_.unfinalizedDrafts_--;
30161
+ const result = state.copy_;
30162
+ let resultEach = result;
30163
+ let isSet2 = false;
30164
+ if (state.type_ === 3 /* Set */) {
30165
+ resultEach = new Set(result);
30166
+ result.clear();
30167
+ isSet2 = true;
30168
+ }
30169
+ each(
30170
+ resultEach,
30171
+ (key, childValue) => finalizeProperty(rootScope, state, result, key, childValue, path, isSet2)
30172
+ );
30173
+ maybeFreeze(rootScope, result, false);
30174
+ if (path && rootScope.patches_) {
30175
+ getPlugin("Patches").generatePatches_(
30176
+ state,
30177
+ path,
30178
+ rootScope.patches_,
30179
+ rootScope.inversePatches_
30180
+ );
30181
+ }
30182
+ }
30183
+ return state.copy_;
30184
+ }
30185
+ function finalizeProperty(rootScope, parentState, targetObject, prop, childValue, rootPath, targetIsSet) {
30186
+ if (process.env.NODE_ENV !== "production" && childValue === targetObject)
30187
+ die(5);
30188
+ if (isDraft(childValue)) {
30189
+ const path = rootPath && parentState && parentState.type_ !== 3 /* Set */ && // Set objects are atomic since they have no keys.
30190
+ !has(parentState.assigned_, prop) ? rootPath.concat(prop) : void 0;
30191
+ const res = finalize(rootScope, childValue, path);
30192
+ set(targetObject, prop, res);
30193
+ if (isDraft(res)) {
30194
+ rootScope.canAutoFreeze_ = false;
30195
+ } else
30196
+ return;
30197
+ } else if (targetIsSet) {
30198
+ targetObject.add(childValue);
30199
+ }
30200
+ if (isDraftable(childValue) && !isFrozen(childValue)) {
30201
+ if (!rootScope.immer_.autoFreeze_ && rootScope.unfinalizedDrafts_ < 1) {
30202
+ return;
30203
+ }
30204
+ finalize(rootScope, childValue);
30205
+ if ((!parentState || !parentState.scope_.parent_) && typeof prop !== "symbol" && (isMap(targetObject) ? targetObject.has(prop) : Object.prototype.propertyIsEnumerable.call(targetObject, prop)))
30206
+ maybeFreeze(rootScope, childValue);
30207
+ }
30208
+ }
30209
+ function maybeFreeze(scope, value, deep = false) {
30210
+ if (!scope.parent_ && scope.immer_.autoFreeze_ && scope.canAutoFreeze_) {
30211
+ freeze(value, deep);
30212
+ }
30213
+ }
30214
+
30215
+ // src/core/proxy.ts
30216
+ function createProxyProxy(base, parent) {
30217
+ const isArray = Array.isArray(base);
30218
+ const state = {
30219
+ type_: isArray ? 1 /* Array */ : 0 /* Object */,
30220
+ // Track which produce call this is associated with.
30221
+ scope_: parent ? parent.scope_ : getCurrentScope(),
30222
+ // True for both shallow and deep changes.
30223
+ modified_: false,
30224
+ // Used during finalization.
30225
+ finalized_: false,
30226
+ // Track which properties have been assigned (true) or deleted (false).
30227
+ assigned_: {},
30228
+ // The parent draft state.
30229
+ parent_: parent,
30230
+ // The base state.
30231
+ base_: base,
30232
+ // The base proxy.
30233
+ draft_: null,
30234
+ // set below
30235
+ // The base copy with any updated values.
30236
+ copy_: null,
30237
+ // Called by the `produce` function.
30238
+ revoke_: null,
30239
+ isManual_: false
30240
+ };
30241
+ let target = state;
30242
+ let traps = objectTraps;
30243
+ if (isArray) {
30244
+ target = [state];
30245
+ traps = arrayTraps;
30246
+ }
30247
+ const { revoke, proxy } = Proxy.revocable(target, traps);
30248
+ state.draft_ = proxy;
30249
+ state.revoke_ = revoke;
30250
+ return proxy;
30251
+ }
30252
+ var objectTraps = {
30253
+ get(state, prop) {
30254
+ if (prop === DRAFT_STATE)
30255
+ return state;
30256
+ const source = latest(state);
30257
+ if (!has(source, prop)) {
30258
+ return readPropFromProto(state, source, prop);
30259
+ }
30260
+ const value = source[prop];
30261
+ if (state.finalized_ || !isDraftable(value)) {
30262
+ return value;
30263
+ }
30264
+ if (value === peek(state.base_, prop)) {
30265
+ prepareCopy(state);
30266
+ return state.copy_[prop] = createProxy(value, state);
30267
+ }
30268
+ return value;
30269
+ },
30270
+ has(state, prop) {
30271
+ return prop in latest(state);
30272
+ },
30273
+ ownKeys(state) {
30274
+ return Reflect.ownKeys(latest(state));
30275
+ },
30276
+ set(state, prop, value) {
30277
+ const desc = getDescriptorFromProto(latest(state), prop);
30278
+ if (desc?.set) {
30279
+ desc.set.call(state.draft_, value);
30280
+ return true;
30281
+ }
30282
+ if (!state.modified_) {
30283
+ const current2 = peek(latest(state), prop);
30284
+ const currentState = current2?.[DRAFT_STATE];
30285
+ if (currentState && currentState.base_ === value) {
30286
+ state.copy_[prop] = value;
30287
+ state.assigned_[prop] = false;
30288
+ return true;
30289
+ }
30290
+ if (is(value, current2) && (value !== void 0 || has(state.base_, prop)))
30291
+ return true;
30292
+ prepareCopy(state);
30293
+ markChanged(state);
30294
+ }
30295
+ if (state.copy_[prop] === value && // special case: handle new props with value 'undefined'
30296
+ (value !== void 0 || prop in state.copy_) || // special case: NaN
30297
+ Number.isNaN(value) && Number.isNaN(state.copy_[prop]))
30298
+ return true;
30299
+ state.copy_[prop] = value;
30300
+ state.assigned_[prop] = true;
30301
+ return true;
30302
+ },
30303
+ deleteProperty(state, prop) {
30304
+ if (peek(state.base_, prop) !== void 0 || prop in state.base_) {
30305
+ state.assigned_[prop] = false;
30306
+ prepareCopy(state);
30307
+ markChanged(state);
30308
+ } else {
30309
+ delete state.assigned_[prop];
30310
+ }
30311
+ if (state.copy_) {
30312
+ delete state.copy_[prop];
30313
+ }
30314
+ return true;
30315
+ },
30316
+ // Note: We never coerce `desc.value` into an Immer draft, because we can't make
30317
+ // the same guarantee in ES5 mode.
30318
+ getOwnPropertyDescriptor(state, prop) {
30319
+ const owner = latest(state);
30320
+ const desc = Reflect.getOwnPropertyDescriptor(owner, prop);
30321
+ if (!desc)
30322
+ return desc;
30323
+ return {
30324
+ writable: true,
30325
+ configurable: state.type_ !== 1 /* Array */ || prop !== "length",
30326
+ enumerable: desc.enumerable,
30327
+ value: owner[prop]
30328
+ };
30329
+ },
30330
+ defineProperty() {
30331
+ die(11);
30332
+ },
30333
+ getPrototypeOf(state) {
30334
+ return getPrototypeOf(state.base_);
30335
+ },
30336
+ setPrototypeOf() {
30337
+ die(12);
30338
+ }
30339
+ };
30340
+ var arrayTraps = {};
30341
+ each(objectTraps, (key, fn) => {
30342
+ arrayTraps[key] = function() {
30343
+ arguments[0] = arguments[0][0];
30344
+ return fn.apply(this, arguments);
30345
+ };
30346
+ });
30347
+ arrayTraps.deleteProperty = function(state, prop) {
30348
+ if (process.env.NODE_ENV !== "production" && isNaN(parseInt(prop)))
30349
+ die(13);
30350
+ return arrayTraps.set.call(this, state, prop, void 0);
30351
+ };
30352
+ arrayTraps.set = function(state, prop, value) {
30353
+ if (process.env.NODE_ENV !== "production" && prop !== "length" && isNaN(parseInt(prop)))
30354
+ die(14);
30355
+ return objectTraps.set.call(this, state[0], prop, value, state[0]);
30356
+ };
30357
+ function peek(draft, prop) {
30358
+ const state = draft[DRAFT_STATE];
30359
+ const source = state ? latest(state) : draft;
30360
+ return source[prop];
30361
+ }
30362
+ function readPropFromProto(state, source, prop) {
30363
+ const desc = getDescriptorFromProto(source, prop);
30364
+ return desc ? `value` in desc ? desc.value : (
30365
+ // This is a very special case, if the prop is a getter defined by the
30366
+ // prototype, we should invoke it with the draft as context!
30367
+ desc.get?.call(state.draft_)
30368
+ ) : void 0;
30369
+ }
30370
+ function getDescriptorFromProto(source, prop) {
30371
+ if (!(prop in source))
30372
+ return void 0;
30373
+ let proto = getPrototypeOf(source);
30374
+ while (proto) {
30375
+ const desc = Object.getOwnPropertyDescriptor(proto, prop);
30376
+ if (desc)
30377
+ return desc;
30378
+ proto = getPrototypeOf(proto);
30379
+ }
30380
+ return void 0;
30381
+ }
30382
+ function markChanged(state) {
30383
+ if (!state.modified_) {
30384
+ state.modified_ = true;
30385
+ if (state.parent_) {
30386
+ markChanged(state.parent_);
30387
+ }
30388
+ }
30389
+ }
30390
+ function prepareCopy(state) {
30391
+ if (!state.copy_) {
30392
+ state.copy_ = shallowCopy(
30393
+ state.base_,
30394
+ state.scope_.immer_.useStrictShallowCopy_
30395
+ );
30396
+ }
30397
+ }
30398
+
30399
+ // src/core/immerClass.ts
30400
+ var Immer2 = class {
30401
+ constructor(config) {
30402
+ this.autoFreeze_ = true;
30403
+ this.useStrictShallowCopy_ = false;
30404
+ /**
30405
+ * The `produce` function takes a value and a "recipe function" (whose
30406
+ * return value often depends on the base state). The recipe function is
30407
+ * free to mutate its first argument however it wants. All mutations are
30408
+ * only ever applied to a __copy__ of the base state.
30409
+ *
30410
+ * Pass only a function to create a "curried producer" which relieves you
30411
+ * from passing the recipe function every time.
30412
+ *
30413
+ * Only plain objects and arrays are made mutable. All other objects are
30414
+ * considered uncopyable.
30415
+ *
30416
+ * Note: This function is __bound__ to its `Immer` instance.
30417
+ *
30418
+ * @param {any} base - the initial state
30419
+ * @param {Function} recipe - function that receives a proxy of the base state as first argument and which can be freely modified
30420
+ * @param {Function} patchListener - optional function that will be called with all the patches produced here
30421
+ * @returns {any} a new state, or the initial state if nothing was modified
30422
+ */
30423
+ this.produce = (base, recipe, patchListener) => {
30424
+ if (typeof base === "function" && typeof recipe !== "function") {
30425
+ const defaultBase = recipe;
30426
+ recipe = base;
30427
+ const self = this;
30428
+ return function curriedProduce(base2 = defaultBase, ...args) {
30429
+ return self.produce(base2, (draft) => recipe.call(this, draft, ...args));
30430
+ };
30431
+ }
30432
+ if (typeof recipe !== "function")
30433
+ die(6);
30434
+ if (patchListener !== void 0 && typeof patchListener !== "function")
30435
+ die(7);
30436
+ let result;
30437
+ if (isDraftable(base)) {
30438
+ const scope = enterScope(this);
30439
+ const proxy = createProxy(base, void 0);
30440
+ let hasError = true;
30441
+ try {
30442
+ result = recipe(proxy);
30443
+ hasError = false;
30444
+ } finally {
30445
+ if (hasError)
30446
+ revokeScope(scope);
30447
+ else
30448
+ leaveScope(scope);
30449
+ }
30450
+ usePatchesInScope(scope, patchListener);
30451
+ return processResult(result, scope);
30452
+ } else if (!base || typeof base !== "object") {
30453
+ result = recipe(base);
30454
+ if (result === void 0)
30455
+ result = base;
30456
+ if (result === NOTHING)
30457
+ result = void 0;
30458
+ if (this.autoFreeze_)
30459
+ freeze(result, true);
30460
+ if (patchListener) {
30461
+ const p = [];
30462
+ const ip = [];
30463
+ getPlugin("Patches").generateReplacementPatches_(base, result, p, ip);
30464
+ patchListener(p, ip);
30465
+ }
30466
+ return result;
30467
+ } else
30468
+ die(1, base);
30469
+ };
30470
+ this.produceWithPatches = (base, recipe) => {
30471
+ if (typeof base === "function") {
30472
+ return (state, ...args) => this.produceWithPatches(state, (draft) => base(draft, ...args));
30473
+ }
30474
+ let patches, inversePatches;
30475
+ const result = this.produce(base, recipe, (p, ip) => {
30476
+ patches = p;
30477
+ inversePatches = ip;
30478
+ });
30479
+ return [result, patches, inversePatches];
30480
+ };
30481
+ if (typeof config?.autoFreeze === "boolean")
30482
+ this.setAutoFreeze(config.autoFreeze);
30483
+ if (typeof config?.useStrictShallowCopy === "boolean")
30484
+ this.setUseStrictShallowCopy(config.useStrictShallowCopy);
30485
+ }
30486
+ createDraft(base) {
30487
+ if (!isDraftable(base))
30488
+ die(8);
30489
+ if (isDraft(base))
30490
+ base = current(base);
30491
+ const scope = enterScope(this);
30492
+ const proxy = createProxy(base, void 0);
30493
+ proxy[DRAFT_STATE].isManual_ = true;
30494
+ leaveScope(scope);
30495
+ return proxy;
30496
+ }
30497
+ finishDraft(draft, patchListener) {
30498
+ const state = draft && draft[DRAFT_STATE];
30499
+ if (!state || !state.isManual_)
30500
+ die(9);
30501
+ const { scope_: scope } = state;
30502
+ usePatchesInScope(scope, patchListener);
30503
+ return processResult(void 0, scope);
30504
+ }
30505
+ /**
30506
+ * Pass true to automatically freeze all copies created by Immer.
30507
+ *
30508
+ * By default, auto-freezing is enabled.
30509
+ */
30510
+ setAutoFreeze(value) {
30511
+ this.autoFreeze_ = value;
30512
+ }
30513
+ /**
30514
+ * Pass true to enable strict shallow copy.
30515
+ *
30516
+ * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
30517
+ */
30518
+ setUseStrictShallowCopy(value) {
30519
+ this.useStrictShallowCopy_ = value;
30520
+ }
30521
+ applyPatches(base, patches) {
30522
+ let i;
30523
+ for (i = patches.length - 1; i >= 0; i--) {
30524
+ const patch = patches[i];
30525
+ if (patch.path.length === 0 && patch.op === "replace") {
30526
+ base = patch.value;
30527
+ break;
30528
+ }
30529
+ }
30530
+ if (i > -1) {
30531
+ patches = patches.slice(i + 1);
30532
+ }
30533
+ const applyPatchesImpl = getPlugin("Patches").applyPatches_;
30534
+ if (isDraft(base)) {
30535
+ return applyPatchesImpl(base, patches);
30536
+ }
30537
+ return this.produce(
30538
+ base,
30539
+ (draft) => applyPatchesImpl(draft, patches)
30540
+ );
30541
+ }
30542
+ };
30543
+ function createProxy(value, parent) {
30544
+ const draft = isMap(value) ? getPlugin("MapSet").proxyMap_(value, parent) : isSet(value) ? getPlugin("MapSet").proxySet_(value, parent) : createProxyProxy(value, parent);
30545
+ const scope = parent ? parent.scope_ : getCurrentScope();
30546
+ scope.drafts_.push(draft);
30547
+ return draft;
30548
+ }
30549
+
30550
+ // src/core/current.ts
30551
+ function current(value) {
30552
+ if (!isDraft(value))
30553
+ die(10, value);
30554
+ return currentImpl(value);
30555
+ }
30556
+ function currentImpl(value) {
30557
+ if (!isDraftable(value) || isFrozen(value))
30558
+ return value;
30559
+ const state = value[DRAFT_STATE];
30560
+ let copy;
30561
+ if (state) {
30562
+ if (!state.modified_)
30563
+ return state.base_;
30564
+ state.finalized_ = true;
30565
+ copy = shallowCopy(value, state.scope_.immer_.useStrictShallowCopy_);
30566
+ } else {
30567
+ copy = shallowCopy(value, true);
30568
+ }
30569
+ each(copy, (key, childValue) => {
30570
+ set(copy, key, currentImpl(childValue));
30571
+ });
30572
+ if (state) {
30573
+ state.finalized_ = false;
30574
+ }
30575
+ return copy;
30576
+ }
30577
+
30578
+ // src/immer.ts
30579
+ var immer = new Immer2();
30580
+ var produce = immer.produce;
30581
+ function castDraft(value) {
30582
+ return value;
30583
+ }
29676
30584
 
29677
30585
  const filterAction = (...types) => filter((x) => types.includes(x.type));
29678
30586
 
@@ -29874,7 +30782,7 @@ function createAsyncAction(type, request, success, failure) {
29874
30782
 
29875
30783
  function freezeDraftable(val) {
29876
30784
  // biome-ignore lint/suspicious/noEmptyBlockStatements: This is a valid use case for an empty block statement
29877
- return t(val) ? fn(val, () => { }) : val;
30785
+ return isDraftable(val) ? produce(val, () => { }) : val;
29878
30786
  }
29879
30787
  function isStateFunction(x) {
29880
30788
  return typeof x === 'function';
@@ -29900,7 +30808,7 @@ function createReducer$2(initialState, mapOrBuilderCallback) {
29900
30808
  }
29901
30809
  return caseReducers.reduce((previousState, caseReducer) => {
29902
30810
  if (caseReducer) {
29903
- if (r(previousState)) {
30811
+ if (isDraft(previousState)) {
29904
30812
  // If it's already a draft, we must already be inside a `createNextState` call,
29905
30813
  // likely because this is being wrapped in `createReducer`, `createSlice`, or nested
29906
30814
  // inside an existing draft. It's safe to just pass the draft to the mutator.
@@ -29911,7 +30819,7 @@ function createReducer$2(initialState, mapOrBuilderCallback) {
29911
30819
  }
29912
30820
  return result;
29913
30821
  }
29914
- else if (!t(previousState)) {
30822
+ else if (!isDraftable(previousState)) {
29915
30823
  // If state is not draftable (ex: a primitive, such as 0), we want to directly
29916
30824
  // return the caseReducer func and not wrap it with produce.
29917
30825
  const result = caseReducer(previousState, action);
@@ -29929,7 +30837,7 @@ function createReducer$2(initialState, mapOrBuilderCallback) {
29929
30837
  // createNextState() produces an Immutable<Draft<S>> rather
29930
30838
  // than an Immutable<S>, and TypeScript cannot find out how to reconcile
29931
30839
  // these two types.
29932
- return fn(previousState, (draft) => {
30840
+ return produce(previousState, (draft) => {
29933
30841
  return caseReducer(draft, action);
29934
30842
  });
29935
30843
  }
@@ -30195,7 +31103,7 @@ const createReducer$1 = (initial = {}) => createReducer$2(initial, (builder) =>
30195
31103
  // It updates the state by setting a new `QueryClientRequest` object for the key specified by `action.meta.transaction`.
30196
31104
  // The new `QueryClientRequest` object is created by merging `action.payload` and `action.meta`, and initializing
30197
31105
  // `execution` as an empty array, `errors` as an empty array, and `status` as 'idle'.
30198
- state[action.meta.transaction] = K({
31106
+ state[action.meta.transaction] = castDraft({
30199
31107
  ...action.payload,
30200
31108
  ...action.meta,
30201
31109
  execution: [],
@@ -30818,7 +31726,7 @@ const resolveDefaultLogLevel = () => {
30818
31726
  const defaultLogLevel = resolveDefaultLogLevel();
30819
31727
 
30820
31728
  // Generated by genversion.
30821
- const version = '1.1.5';
31729
+ const version = '1.1.7';
30822
31730
 
30823
31731
  /**
30824
31732
  * Defines an abstract base class for a logger implementation that provides common logging functionality.
@@ -31411,7 +32319,7 @@ function createReducer (actions, initial = {}) {
31411
32319
  return createReducer$2(initial, (builder) => builder
31412
32320
  .addCase(actions.set, (state, action) => {
31413
32321
  const { key, record } = action.payload;
31414
- state[key] = K(record);
32322
+ state[key] = castDraft(record);
31415
32323
  })
31416
32324
  // Handles the 'set' action to update or add a cache record.
31417
32325
  .addCase(actions.insert, (state, action) => {
@@ -31422,7 +32330,7 @@ function createReducer (actions, initial = {}) {
31422
32330
  record.updated = Date.now();
31423
32331
  record.updates ??= 0;
31424
32332
  record.updates++;
31425
- record.value = K(entry.value);
32333
+ record.value = castDraft(entry.value);
31426
32334
  record.transaction = entry.transaction;
31427
32335
  // reset the mutated timestamp
31428
32336
  record.mutated = undefined;
@@ -31430,7 +32338,7 @@ function createReducer (actions, initial = {}) {
31430
32338
  else {
31431
32339
  // If the record does not exist, create a new one with the current timestamp.
31432
32340
  const created = Date.now();
31433
- state[key] = K({
32341
+ state[key] = castDraft({
31434
32342
  ...entry,
31435
32343
  created,
31436
32344
  updated: created, // Set `updated` to the creation time.
@@ -31458,7 +32366,7 @@ function createReducer (actions, initial = {}) {
31458
32366
  const record = state[key];
31459
32367
  if (record) {
31460
32368
  // Update the record with the new value and metadata.
31461
- record.value = K(value);
32369
+ record.value = castDraft(value);
31462
32370
  record.updated = updated;
31463
32371
  record.mutated = Date.now();
31464
32372
  record.updates ??= 0;
@@ -31702,7 +32610,7 @@ class QueryTask extends Subject {
31702
32610
  complete: result.completed,
31703
32611
  value: result.value,
31704
32612
  };
31705
- }), finalize(() => {
32613
+ }), finalize$1(() => {
31706
32614
  logger?.debug(`QueryTask complete`, {
31707
32615
  uuid: this.uuid,
31708
32616
  key: this.key,
@@ -32303,15 +33211,15 @@ class Query {
32303
33211
  /**
32304
33212
  * Represents a service from the service discovery API.
32305
33213
  */
32306
- const ApiService = z$1
33214
+ const ApiService = z
32307
33215
  .object({
32308
- key: z$1.string().describe('The key used to identify the service'),
32309
- uri: z$1.string().describe('The URI of the service'),
32310
- id: z$1.string().optional().describe('The ID of the service'),
32311
- environment: z$1.string().optional().describe('The environment of the service'),
32312
- name: z$1.string().optional().describe('The name of the service'),
32313
- scopes: z$1.array(z$1.string()).optional().default([]).describe('Endpoint authentication scopes'),
32314
- tags: z$1.array(z$1.string()).optional().describe('Tags for the service'),
33216
+ key: z.string().describe('The key used to identify the service'),
33217
+ uri: z.string().describe('The URI of the service'),
33218
+ id: z.string().optional().describe('The ID of the service'),
33219
+ environment: z.string().optional().describe('The environment of the service'),
33220
+ name: z.string().optional().describe('The name of the service'),
33221
+ scopes: z.array(z.string()).optional().default([]).describe('Endpoint authentication scopes'),
33222
+ tags: z.array(z.string()).optional().describe('Tags for the service'),
32315
33223
  })
32316
33224
  .describe('A service from the service discovery API')
32317
33225
  .transform((value) => ({
@@ -32331,7 +33239,7 @@ const ApiService = z$1
32331
33239
  * @constant
32332
33240
  * @description A list of services from the service discovery API.
32333
33241
  */
32334
- const ApiServices = z$1
33242
+ const ApiServices = z
32335
33243
  .array(ApiService)
32336
33244
  .describe('A list of services from the service discovery API');
32337
33245