UNPKG

storybook

Version:

Storybook: Develop, document, and test UI components in isolation

1,068 lines (1,064 loc) • 68.3 kB
import { dedent } from "./chunk-JP7NCOJX.js"; // src/shared/universal-store/instances.ts var instances = /* @__PURE__ */ new Map(); // src/shared/universal-store/index.ts var CHANNEL_EVENT_PREFIX = "UNIVERSAL_STORE:", ProgressState = { PENDING: "PENDING", RESOLVED: "RESOLVED", REJECTED: "REJECTED" }, _UniversalStore = class _UniversalStore { constructor(options, environmentOverrides) { /** Enable debug logs for this store */ this.debugging = !1; // TODO: narrow type of listeners based on event type this.listeners = /* @__PURE__ */ new Map([["*", /* @__PURE__ */ new Set()]]); /** Gets the current state */ this.getState = () => (this.debug("getState", { state: this.state }), this.state); /** * Subscribes to store events * * @returns A function to unsubscribe */ this.subscribe = (eventTypeOrListener, maybeListener) => { let subscribesToAllEvents = typeof eventTypeOrListener == "function", eventType = subscribesToAllEvents ? "*" : eventTypeOrListener, listener = subscribesToAllEvents ? eventTypeOrListener : maybeListener; if (this.debug("subscribe", { eventType, listener }), !listener) throw new TypeError( `Missing first subscribe argument, or second if first is the event type, when subscribing to a UniversalStore with id '${this.id}'` ); return this.listeners.has(eventType) || this.listeners.set(eventType, /* @__PURE__ */ new Set()), this.listeners.get(eventType).add(listener), () => { this.debug("unsubscribe", { eventType, listener }), this.listeners.has(eventType) && (this.listeners.get(eventType).delete(listener), this.listeners.get(eventType)?.size === 0 && this.listeners.delete(eventType)); }; }; /** Sends a custom event to the other stores */ this.send = (event) => { if (this.debug("send", { event }), this.status !== _UniversalStore.Status.READY) throw new TypeError( dedent`Cannot send event before store is ready. You can get the current status with store.status, or await store.readyPromise to wait for the store to be ready before sending events. ${JSON.stringify( { event, id: this.id, actor: this.actor, environment: this.environment }, null, 2 )}` ); this.emitToListeners(event, { actor: this.actor }), this.emitToChannel(event, { actor: this.actor }); }; if (this.debugging = options.debug ?? !1, !_UniversalStore.isInternalConstructing) throw new TypeError( "UniversalStore is not constructable - use UniversalStore.create() instead" ); if (_UniversalStore.isInternalConstructing = !1, this.id = options.id, this.actorId = Date.now().toString(36) + Math.random().toString(36).substring(2), this.actorType = options.leader ? _UniversalStore.ActorType.LEADER : _UniversalStore.ActorType.FOLLOWER, this.state = options.initialState, this.channelEventName = `${CHANNEL_EVENT_PREFIX}${this.id}`, this.debug("constructor", { options, environmentOverrides, channelEventName: this.channelEventName }), this.actor.type === _UniversalStore.ActorType.LEADER) this.syncing = { state: ProgressState.RESOLVED, promise: Promise.resolve() }; else { let syncingResolve, syncingReject, syncingPromise = new Promise((resolve, reject) => { syncingResolve = () => { this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.RESOLVED, resolve()); }, syncingReject = (reason) => { this.syncing.state === ProgressState.PENDING && (this.syncing.state = ProgressState.REJECTED, reject(reason)); }; }); this.syncing = { state: ProgressState.PENDING, promise: syncingPromise, resolve: syncingResolve, reject: syncingReject }; } this.getState = this.getState.bind(this), this.setState = this.setState.bind(this), this.subscribe = this.subscribe.bind(this), this.onStateChange = this.onStateChange.bind(this), this.send = this.send.bind(this), this.emitToChannel = this.emitToChannel.bind(this), this.prepareThis = this.prepareThis.bind(this), this.emitToListeners = this.emitToListeners.bind(this), this.handleChannelEvents = this.handleChannelEvents.bind(this), this.debug = this.debug.bind(this), this.channel = environmentOverrides?.channel ?? _UniversalStore.preparation.channel, this.environment = environmentOverrides?.environment ?? _UniversalStore.preparation.environment, this.channel && this.environment ? (_UniversalStore.preparation.resolve({ channel: this.channel, environment: this.environment }), this.prepareThis({ channel: this.channel, environment: this.environment })) : _UniversalStore.preparation.promise.then(this.prepareThis); } static setupPreparationPromise() { let resolveRef, rejectRef, promise = new Promise( (resolve, reject) => { resolveRef = (args) => { resolve(args); }, rejectRef = (...args) => { reject(args); }; } ); _UniversalStore.preparation = { resolve: resolveRef, reject: rejectRef, promise }; } /** The actor object representing the store instance with a unique ID and a type */ get actor() { return Object.freeze({ id: this.actorId, type: this.actorType, environment: this.environment ?? _UniversalStore.Environment.UNKNOWN }); } /** * The current state of the store, that signals both if the store is prepared by Storybook and * also - in the case of a follower - if the state has been synced with the leader's state. */ get status() { if (!this.channel || !this.environment) return _UniversalStore.Status.UNPREPARED; switch (this.syncing?.state) { case ProgressState.PENDING: case void 0: return _UniversalStore.Status.SYNCING; case ProgressState.REJECTED: return _UniversalStore.Status.ERROR; case ProgressState.RESOLVED: default: return _UniversalStore.Status.READY; } } /** * A promise that resolves when the store is fully ready. A leader will be ready when the store * has been prepared by Storybook, which is almost instantly. * * A follower will be ready when the state has been synced with the leader's state, within a few * hundred milliseconds. */ untilReady() { return Promise.all([_UniversalStore.preparation.promise, this.syncing?.promise]); } /** Creates a new instance of UniversalStore */ static create(options) { if (!options || typeof options?.id != "string") throw new TypeError("id is required and must be a string, when creating a UniversalStore"); options.debug && console.debug( dedent`[UniversalStore] create`, { options } ); let existing = instances.get(options.id); if (existing) return console.warn(dedent`UniversalStore with id "${options.id}" already exists in this environment, re-using existing. You should reuse the existing instance instead of trying to create a new one.`), existing; _UniversalStore.isInternalConstructing = !0; let store = new _UniversalStore(options); return instances.set(options.id, store), store; } /** * Used by Storybook to set the channel for all instances of UniversalStore in the given * environment. * * @internal */ static __prepare(channel, environment) { _UniversalStore.preparation.channel = channel, _UniversalStore.preparation.environment = environment, _UniversalStore.preparation.resolve({ channel, environment }); } /** * Updates the store's state * * Either a new state or a state updater function can be passed to the method. */ setState(updater) { let previousState = this.state, newState = typeof updater == "function" ? updater(previousState) : updater; if (this.debug("setState", { newState, previousState, updater }), this.status !== _UniversalStore.Status.READY) throw new TypeError( dedent`Cannot set state before store is ready. You can get the current status with store.status, or await store.readyPromise to wait for the store to be ready before sending events. ${JSON.stringify( { newState, id: this.id, actor: this.actor, environment: this.environment }, null, 2 )}` ); this.state = newState; let event = { type: _UniversalStore.InternalEventType.SET_STATE, payload: { state: newState, previousState } }; this.emitToChannel(event, { actor: this.actor }), this.emitToListeners(event, { actor: this.actor }); } /** * Subscribes to state changes * * @returns Unsubscribe function */ onStateChange(listener) { return this.debug("onStateChange", { listener }), this.subscribe( _UniversalStore.InternalEventType.SET_STATE, ({ payload }, eventInfo) => { listener(payload.state, payload.previousState, eventInfo); } ); } emitToChannel(event, eventInfo) { this.debug("emitToChannel", { event, eventInfo, channel: !!this.channel }), this.channel?.emit(this.channelEventName, { event, eventInfo }); } prepareThis({ channel, environment }) { this.channel = channel, this.environment = environment, this.debug("prepared", { channel: !!channel, environment }), this.channel.on(this.channelEventName, this.handleChannelEvents), this.actor.type === _UniversalStore.ActorType.LEADER ? this.emitToChannel( { type: _UniversalStore.InternalEventType.LEADER_CREATED }, { actor: this.actor } ) : (this.emitToChannel( { type: _UniversalStore.InternalEventType.FOLLOWER_CREATED }, { actor: this.actor } ), this.emitToChannel( { type: _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST }, { actor: this.actor } ), setTimeout(() => { this.syncing.reject( new TypeError( `No existing state found for follower with id: '${this.id}'. Make sure a leader with the same id exists before creating a follower.` ) ); }, 1e3)); } emitToListeners(event, eventInfo) { let eventTypeListeners = this.listeners.get(event.type), everythingListeners = this.listeners.get("*"); this.debug("emitToListeners", { event, eventInfo, eventTypeListeners, everythingListeners }), [...eventTypeListeners ?? [], ...everythingListeners ?? []].forEach( (listener) => listener(event, eventInfo) ); } handleChannelEvents(channelEvent) { let { event, eventInfo } = channelEvent; if ([eventInfo.actor.id, eventInfo.forwardingActor?.id].includes(this.actor.id)) { this.debug("handleChannelEvents: Ignoring event from self", { channelEvent }); return; } else if (this.syncing?.state === ProgressState.PENDING && event.type !== _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE) { this.debug("handleChannelEvents: Ignoring event while syncing", { channelEvent }); return; } if (this.debug("handleChannelEvents", { channelEvent }), this.actor.type === _UniversalStore.ActorType.LEADER) { let shouldForwardEvent = !0; switch (event.type) { case _UniversalStore.InternalEventType.EXISTING_STATE_REQUEST: shouldForwardEvent = !1; let responseEvent = { type: _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE, payload: this.state }; this.debug("handleChannelEvents: responding to existing state request", { responseEvent }), this.emitToChannel(responseEvent, { actor: this.actor }), this.emitToListeners(responseEvent, { actor: this.actor }); break; case _UniversalStore.InternalEventType.LEADER_CREATED: shouldForwardEvent = !1, this.syncing.state = ProgressState.REJECTED, this.debug("handleChannelEvents: erroring due to second leader being created", { event }), console.error( dedent`Detected multiple UniversalStore leaders created with the same id "${this.id}". Only one leader can exists at a time, your stores are now in an invalid state. Leaders detected: this: ${JSON.stringify(this.actor, null, 2)} other: ${JSON.stringify(eventInfo.actor, null, 2)}` ); break; } shouldForwardEvent && (this.debug("handleChannelEvents: forwarding event", { channelEvent }), this.emitToChannel(event, { actor: eventInfo.actor, forwardingActor: this.actor })); } if (this.actor.type === _UniversalStore.ActorType.FOLLOWER) switch (event.type) { case _UniversalStore.InternalEventType.EXISTING_STATE_RESPONSE: if (this.debug("handleChannelEvents: Setting state from leader's existing state response", { event }), this.syncing?.state !== ProgressState.PENDING) break; this.syncing.resolve?.(); let setStateEvent = { type: _UniversalStore.InternalEventType.SET_STATE, payload: { state: event.payload, previousState: this.state } }; this.state = event.payload, this.emitToListeners(setStateEvent, eventInfo); break; } switch (event.type) { case _UniversalStore.InternalEventType.SET_STATE: this.debug("handleChannelEvents: Setting state", { event }), this.state = event.payload.state; break; } this.emitToListeners(event, { actor: eventInfo.actor }); } debug(message, data) { this.debugging && console.debug( dedent`[UniversalStore::${this.id}::${this.environment ?? _UniversalStore.Environment.UNKNOWN}] ${message}`, JSON.stringify( { data, actor: this.actor, state: this.state, status: this.status }, null, 2 ) ); } /** * Used to reset the static fields of the UniversalStore class when cleaning up tests * * @internal */ static __reset() { _UniversalStore.preparation.reject(new Error("reset")), _UniversalStore.setupPreparationPromise(), _UniversalStore.isInternalConstructing = !1; } }; /** * Defines the possible actor types in the store system * * @readonly */ _UniversalStore.ActorType = { LEADER: "LEADER", FOLLOWER: "FOLLOWER" }, /** * Defines the possible environments the store can run in * * @readonly */ _UniversalStore.Environment = { SERVER: "SERVER", MANAGER: "MANAGER", PREVIEW: "PREVIEW", UNKNOWN: "UNKNOWN", MOCK: "MOCK" }, /** * Internal event types used for store synchronization * * @readonly */ _UniversalStore.InternalEventType = { EXISTING_STATE_REQUEST: "__EXISTING_STATE_REQUEST", EXISTING_STATE_RESPONSE: "__EXISTING_STATE_RESPONSE", SET_STATE: "__SET_STATE", LEADER_CREATED: "__LEADER_CREATED", FOLLOWER_CREATED: "__FOLLOWER_CREATED" }, _UniversalStore.Status = { UNPREPARED: "UNPREPARED", SYNCING: "SYNCING", READY: "READY", ERROR: "ERROR" }, // This is used to check if constructor was called from the static factory create() _UniversalStore.isInternalConstructing = !1, _UniversalStore.setupPreparationPromise(); var UniversalStore = _UniversalStore; // ../node_modules/telejson/dist/chunk-EAFQLD22.mjs var __create = Object.create, __defProp = Object.defineProperty, __getOwnPropDesc = Object.getOwnPropertyDescriptor, __getOwnPropNames = Object.getOwnPropertyNames, __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty, __commonJS = (cb, mod) => function() { return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports; }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }, __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )), eventProperties = [ "bubbles", "cancelBubble", "cancelable", "composed", "currentTarget", "defaultPrevented", "eventPhase", "isTrusted", "returnValue", "srcElement", "target", "timeStamp", "type" ], customEventSpecificProperties = ["detail"]; function extractEventHiddenProperties(event) { let rebuildEvent = eventProperties.filter((value) => event[value] !== void 0).reduce((acc, value) => (acc[value] = event[value], acc), {}); if (event instanceof CustomEvent) for (let value of customEventSpecificProperties.filter( (value2) => event[value2] !== void 0 )) rebuildEvent[value] = event[value]; return rebuildEvent; } // ../node_modules/telejson/dist/index.mjs var require_es_object_atoms = __commonJS({ "node_modules/.pnpm/es-object-atoms@1.1.1/node_modules/es-object-atoms/index.js"(exports, module) { "use strict"; module.exports = Object; } }), require_es_errors = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/index.js"(exports, module) { "use strict"; module.exports = Error; } }), require_eval = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/eval.js"(exports, module) { "use strict"; module.exports = EvalError; } }), require_range = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/range.js"(exports, module) { "use strict"; module.exports = RangeError; } }), require_ref = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/ref.js"(exports, module) { "use strict"; module.exports = ReferenceError; } }), require_syntax = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/syntax.js"(exports, module) { "use strict"; module.exports = SyntaxError; } }), require_type = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/type.js"(exports, module) { "use strict"; module.exports = TypeError; } }), require_uri = __commonJS({ "node_modules/.pnpm/es-errors@1.3.0/node_modules/es-errors/uri.js"(exports, module) { "use strict"; module.exports = URIError; } }), require_abs = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/abs.js"(exports, module) { "use strict"; module.exports = Math.abs; } }), require_floor = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/floor.js"(exports, module) { "use strict"; module.exports = Math.floor; } }), require_max = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/max.js"(exports, module) { "use strict"; module.exports = Math.max; } }), require_min = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/min.js"(exports, module) { "use strict"; module.exports = Math.min; } }), require_pow = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/pow.js"(exports, module) { "use strict"; module.exports = Math.pow; } }), require_round = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/round.js"(exports, module) { "use strict"; module.exports = Math.round; } }), require_isNaN = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/isNaN.js"(exports, module) { "use strict"; module.exports = Number.isNaN || function(a) { return a !== a; }; } }), require_sign = __commonJS({ "node_modules/.pnpm/math-intrinsics@1.1.0/node_modules/math-intrinsics/sign.js"(exports, module) { "use strict"; var $isNaN = require_isNaN(); module.exports = function(number) { return $isNaN(number) || number === 0 ? number : number < 0 ? -1 : 1; }; } }), require_gOPD = __commonJS({ "node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/gOPD.js"(exports, module) { "use strict"; module.exports = Object.getOwnPropertyDescriptor; } }), require_gopd = __commonJS({ "node_modules/.pnpm/gopd@1.2.0/node_modules/gopd/index.js"(exports, module) { "use strict"; var $gOPD = require_gOPD(); if ($gOPD) try { $gOPD([], "length"); } catch { $gOPD = null; } module.exports = $gOPD; } }), require_es_define_property = __commonJS({ "node_modules/.pnpm/es-define-property@1.0.1/node_modules/es-define-property/index.js"(exports, module) { "use strict"; var $defineProperty = Object.defineProperty || !1; if ($defineProperty) try { $defineProperty({}, "a", { value: 1 }); } catch { $defineProperty = !1; } module.exports = $defineProperty; } }), require_shams = __commonJS({ "node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/shams.js"(exports, module) { "use strict"; module.exports = function() { if (typeof Symbol != "function" || typeof Object.getOwnPropertySymbols != "function") return !1; if (typeof Symbol.iterator == "symbol") return !0; var obj = {}, sym = Symbol("test"), symObj = Object(sym); if (typeof sym == "string" || Object.prototype.toString.call(sym) !== "[object Symbol]" || Object.prototype.toString.call(symObj) !== "[object Symbol]") return !1; var symVal = 42; obj[sym] = symVal; for (var _ in obj) return !1; if (typeof Object.keys == "function" && Object.keys(obj).length !== 0 || typeof Object.getOwnPropertyNames == "function" && Object.getOwnPropertyNames(obj).length !== 0) return !1; var syms = Object.getOwnPropertySymbols(obj); if (syms.length !== 1 || syms[0] !== sym || !Object.prototype.propertyIsEnumerable.call(obj, sym)) return !1; if (typeof Object.getOwnPropertyDescriptor == "function") { var descriptor = ( /** @type {PropertyDescriptor} */ Object.getOwnPropertyDescriptor(obj, sym) ); if (descriptor.value !== symVal || descriptor.enumerable !== !0) return !1; } return !0; }; } }), require_has_symbols = __commonJS({ "node_modules/.pnpm/has-symbols@1.1.0/node_modules/has-symbols/index.js"(exports, module) { "use strict"; var origSymbol = typeof Symbol < "u" && Symbol, hasSymbolSham = require_shams(); module.exports = function() { return typeof origSymbol != "function" || typeof Symbol != "function" || typeof origSymbol("foo") != "symbol" || typeof Symbol("bar") != "symbol" ? !1 : hasSymbolSham(); }; } }), require_Reflect_getPrototypeOf = __commonJS({ "node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Reflect.getPrototypeOf.js"(exports, module) { "use strict"; module.exports = typeof Reflect < "u" && Reflect.getPrototypeOf || null; } }), require_Object_getPrototypeOf = __commonJS({ "node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/Object.getPrototypeOf.js"(exports, module) { "use strict"; var $Object = require_es_object_atoms(); module.exports = $Object.getPrototypeOf || null; } }), require_implementation = __commonJS({ "node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/implementation.js"(exports, module) { "use strict"; var ERROR_MESSAGE = "Function.prototype.bind called on incompatible ", toStr = Object.prototype.toString, max = Math.max, funcType = "[object Function]", concatty = function(a, b) { for (var arr = [], i = 0; i < a.length; i += 1) arr[i] = a[i]; for (var j = 0; j < b.length; j += 1) arr[j + a.length] = b[j]; return arr; }, slicy = function(arrLike, offset) { for (var arr = [], i = offset || 0, j = 0; i < arrLike.length; i += 1, j += 1) arr[j] = arrLike[i]; return arr; }, joiny = function(arr, joiner) { for (var str = "", i = 0; i < arr.length; i += 1) str += arr[i], i + 1 < arr.length && (str += joiner); return str; }; module.exports = function(that) { var target = this; if (typeof target != "function" || toStr.apply(target) !== funcType) throw new TypeError(ERROR_MESSAGE + target); for (var args = slicy(arguments, 1), bound, binder = function() { if (this instanceof bound) { var result = target.apply( this, concatty(args, arguments) ); return Object(result) === result ? result : this; } return target.apply( that, concatty(args, arguments) ); }, boundLength = max(0, target.length - args.length), boundArgs = [], i = 0; i < boundLength; i++) boundArgs[i] = "$" + i; if (bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder), target.prototype) { var Empty = function() { }; Empty.prototype = target.prototype, bound.prototype = new Empty(), Empty.prototype = null; } return bound; }; } }), require_function_bind = __commonJS({ "node_modules/.pnpm/function-bind@1.1.2/node_modules/function-bind/index.js"(exports, module) { "use strict"; var implementation = require_implementation(); module.exports = Function.prototype.bind || implementation; } }), require_functionCall = __commonJS({ "node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionCall.js"(exports, module) { "use strict"; module.exports = Function.prototype.call; } }), require_functionApply = __commonJS({ "node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/functionApply.js"(exports, module) { "use strict"; module.exports = Function.prototype.apply; } }), require_reflectApply = __commonJS({ "node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/reflectApply.js"(exports, module) { "use strict"; module.exports = typeof Reflect < "u" && Reflect && Reflect.apply; } }), require_actualApply = __commonJS({ "node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/actualApply.js"(exports, module) { "use strict"; var bind = require_function_bind(), $apply = require_functionApply(), $call = require_functionCall(), $reflectApply = require_reflectApply(); module.exports = $reflectApply || bind.call($call, $apply); } }), require_call_bind_apply_helpers = __commonJS({ "node_modules/.pnpm/call-bind-apply-helpers@1.0.2/node_modules/call-bind-apply-helpers/index.js"(exports, module) { "use strict"; var bind = require_function_bind(), $TypeError = require_type(), $call = require_functionCall(), $actualApply = require_actualApply(); module.exports = function(args) { if (args.length < 1 || typeof args[0] != "function") throw new $TypeError("a function is required"); return $actualApply(bind, $call, args); }; } }), require_get = __commonJS({ "node_modules/.pnpm/dunder-proto@1.0.1/node_modules/dunder-proto/get.js"(exports, module) { "use strict"; var callBind = require_call_bind_apply_helpers(), gOPD = require_gopd(), hasProtoAccessor; try { hasProtoAccessor = /** @type {{ __proto__?: typeof Array.prototype }} */ [].__proto__ === Array.prototype; } catch (e) { if (!e || typeof e != "object" || !("code" in e) || e.code !== "ERR_PROTO_ACCESS") throw e; } var desc = !!hasProtoAccessor && gOPD && gOPD( Object.prototype, /** @type {keyof typeof Object.prototype} */ "__proto__" ), $Object = Object, $getPrototypeOf = $Object.getPrototypeOf; module.exports = desc && typeof desc.get == "function" ? callBind([desc.get]) : typeof $getPrototypeOf == "function" ? ( /** @type {import('./get')} */ (function(value) { return $getPrototypeOf(value == null ? value : $Object(value)); }) ) : !1; } }), require_get_proto = __commonJS({ "node_modules/.pnpm/get-proto@1.0.1/node_modules/get-proto/index.js"(exports, module) { "use strict"; var reflectGetProto = require_Reflect_getPrototypeOf(), originalGetProto = require_Object_getPrototypeOf(), getDunderProto = require_get(); module.exports = reflectGetProto ? function(O) { return reflectGetProto(O); } : originalGetProto ? function(O) { if (!O || typeof O != "object" && typeof O != "function") throw new TypeError("getProto: not an object"); return originalGetProto(O); } : getDunderProto ? function(O) { return getDunderProto(O); } : null; } }), require_hasown = __commonJS({ "node_modules/.pnpm/hasown@2.0.2/node_modules/hasown/index.js"(exports, module) { "use strict"; var call = Function.prototype.call, $hasOwn = Object.prototype.hasOwnProperty, bind = require_function_bind(); module.exports = bind.call(call, $hasOwn); } }), require_get_intrinsic = __commonJS({ "node_modules/.pnpm/get-intrinsic@1.3.0/node_modules/get-intrinsic/index.js"(exports, module) { "use strict"; var undefined2, $Object = require_es_object_atoms(), $Error = require_es_errors(), $EvalError = require_eval(), $RangeError = require_range(), $ReferenceError = require_ref(), $SyntaxError = require_syntax(), $TypeError = require_type(), $URIError = require_uri(), abs = require_abs(), floor = require_floor(), max = require_max(), min = require_min(), pow = require_pow(), round = require_round(), sign = require_sign(), $Function = Function, getEvalledConstructor = function(expressionSyntax) { try { return $Function('"use strict"; return (' + expressionSyntax + ").constructor;")(); } catch { } }, $gOPD = require_gopd(), $defineProperty = require_es_define_property(), throwTypeError = function() { throw new $TypeError(); }, ThrowTypeError = $gOPD ? (function() { try { return arguments.callee, throwTypeError; } catch { try { return $gOPD(arguments, "callee").get; } catch { return throwTypeError; } } })() : throwTypeError, hasSymbols = require_has_symbols()(), getProto = require_get_proto(), $ObjectGPO = require_Object_getPrototypeOf(), $ReflectGPO = require_Reflect_getPrototypeOf(), $apply = require_functionApply(), $call = require_functionCall(), needsEval = {}, TypedArray = typeof Uint8Array > "u" || !getProto ? undefined2 : getProto(Uint8Array), INTRINSICS = { __proto__: null, "%AggregateError%": typeof AggregateError > "u" ? undefined2 : AggregateError, "%Array%": Array, "%ArrayBuffer%": typeof ArrayBuffer > "u" ? undefined2 : ArrayBuffer, "%ArrayIteratorPrototype%": hasSymbols && getProto ? getProto([][Symbol.iterator]()) : undefined2, "%AsyncFromSyncIteratorPrototype%": undefined2, "%AsyncFunction%": needsEval, "%AsyncGenerator%": needsEval, "%AsyncGeneratorFunction%": needsEval, "%AsyncIteratorPrototype%": needsEval, "%Atomics%": typeof Atomics > "u" ? undefined2 : Atomics, "%BigInt%": typeof BigInt > "u" ? undefined2 : BigInt, "%BigInt64Array%": typeof BigInt64Array > "u" ? undefined2 : BigInt64Array, "%BigUint64Array%": typeof BigUint64Array > "u" ? undefined2 : BigUint64Array, "%Boolean%": Boolean, "%DataView%": typeof DataView > "u" ? undefined2 : DataView, "%Date%": Date, "%decodeURI%": decodeURI, "%decodeURIComponent%": decodeURIComponent, "%encodeURI%": encodeURI, "%encodeURIComponent%": encodeURIComponent, "%Error%": $Error, "%eval%": eval, // eslint-disable-line no-eval "%EvalError%": $EvalError, "%Float16Array%": typeof Float16Array > "u" ? undefined2 : Float16Array, "%Float32Array%": typeof Float32Array > "u" ? undefined2 : Float32Array, "%Float64Array%": typeof Float64Array > "u" ? undefined2 : Float64Array, "%FinalizationRegistry%": typeof FinalizationRegistry > "u" ? undefined2 : FinalizationRegistry, "%Function%": $Function, "%GeneratorFunction%": needsEval, "%Int8Array%": typeof Int8Array > "u" ? undefined2 : Int8Array, "%Int16Array%": typeof Int16Array > "u" ? undefined2 : Int16Array, "%Int32Array%": typeof Int32Array > "u" ? undefined2 : Int32Array, "%isFinite%": isFinite, "%isNaN%": isNaN, "%IteratorPrototype%": hasSymbols && getProto ? getProto(getProto([][Symbol.iterator]())) : undefined2, "%JSON%": typeof JSON == "object" ? JSON : undefined2, "%Map%": typeof Map > "u" ? undefined2 : Map, "%MapIteratorPrototype%": typeof Map > "u" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Map())[Symbol.iterator]()), "%Math%": Math, "%Number%": Number, "%Object%": $Object, "%Object.getOwnPropertyDescriptor%": $gOPD, "%parseFloat%": parseFloat, "%parseInt%": parseInt, "%Promise%": typeof Promise > "u" ? undefined2 : Promise, "%Proxy%": typeof Proxy > "u" ? undefined2 : Proxy, "%RangeError%": $RangeError, "%ReferenceError%": $ReferenceError, "%Reflect%": typeof Reflect > "u" ? undefined2 : Reflect, "%RegExp%": RegExp, "%Set%": typeof Set > "u" ? undefined2 : Set, "%SetIteratorPrototype%": typeof Set > "u" || !hasSymbols || !getProto ? undefined2 : getProto((/* @__PURE__ */ new Set())[Symbol.iterator]()), "%SharedArrayBuffer%": typeof SharedArrayBuffer > "u" ? undefined2 : SharedArrayBuffer, "%String%": String, "%StringIteratorPrototype%": hasSymbols && getProto ? getProto(""[Symbol.iterator]()) : undefined2, "%Symbol%": hasSymbols ? Symbol : undefined2, "%SyntaxError%": $SyntaxError, "%ThrowTypeError%": ThrowTypeError, "%TypedArray%": TypedArray, "%TypeError%": $TypeError, "%Uint8Array%": typeof Uint8Array > "u" ? undefined2 : Uint8Array, "%Uint8ClampedArray%": typeof Uint8ClampedArray > "u" ? undefined2 : Uint8ClampedArray, "%Uint16Array%": typeof Uint16Array > "u" ? undefined2 : Uint16Array, "%Uint32Array%": typeof Uint32Array > "u" ? undefined2 : Uint32Array, "%URIError%": $URIError, "%WeakMap%": typeof WeakMap > "u" ? undefined2 : WeakMap, "%WeakRef%": typeof WeakRef > "u" ? undefined2 : WeakRef, "%WeakSet%": typeof WeakSet > "u" ? undefined2 : WeakSet, "%Function.prototype.call%": $call, "%Function.prototype.apply%": $apply, "%Object.defineProperty%": $defineProperty, "%Object.getPrototypeOf%": $ObjectGPO, "%Math.abs%": abs, "%Math.floor%": floor, "%Math.max%": max, "%Math.min%": min, "%Math.pow%": pow, "%Math.round%": round, "%Math.sign%": sign, "%Reflect.getPrototypeOf%": $ReflectGPO }; if (getProto) try { null.error; } catch (e) { errorProto = getProto(getProto(e)), INTRINSICS["%Error.prototype%"] = errorProto; } var errorProto, doEval = function doEval2(name) { var value; if (name === "%AsyncFunction%") value = getEvalledConstructor("async function () {}"); else if (name === "%GeneratorFunction%") value = getEvalledConstructor("function* () {}"); else if (name === "%AsyncGeneratorFunction%") value = getEvalledConstructor("async function* () {}"); else if (name === "%AsyncGenerator%") { var fn = doEval2("%AsyncGeneratorFunction%"); fn && (value = fn.prototype); } else if (name === "%AsyncIteratorPrototype%") { var gen = doEval2("%AsyncGenerator%"); gen && getProto && (value = getProto(gen.prototype)); } return INTRINSICS[name] = value, value; }, LEGACY_ALIASES = { __proto__: null, "%ArrayBufferPrototype%": ["ArrayBuffer", "prototype"], "%ArrayPrototype%": ["Array", "prototype"], "%ArrayProto_entries%": ["Array", "prototype", "entries"], "%ArrayProto_forEach%": ["Array", "prototype", "forEach"], "%ArrayProto_keys%": ["Array", "prototype", "keys"], "%ArrayProto_values%": ["Array", "prototype", "values"], "%AsyncFunctionPrototype%": ["AsyncFunction", "prototype"], "%AsyncGenerator%": ["AsyncGeneratorFunction", "prototype"], "%AsyncGeneratorPrototype%": ["AsyncGeneratorFunction", "prototype", "prototype"], "%BooleanPrototype%": ["Boolean", "prototype"], "%DataViewPrototype%": ["DataView", "prototype"], "%DatePrototype%": ["Date", "prototype"], "%ErrorPrototype%": ["Error", "prototype"], "%EvalErrorPrototype%": ["EvalError", "prototype"], "%Float32ArrayPrototype%": ["Float32Array", "prototype"], "%Float64ArrayPrototype%": ["Float64Array", "prototype"], "%FunctionPrototype%": ["Function", "prototype"], "%Generator%": ["GeneratorFunction", "prototype"], "%GeneratorPrototype%": ["GeneratorFunction", "prototype", "prototype"], "%Int8ArrayPrototype%": ["Int8Array", "prototype"], "%Int16ArrayPrototype%": ["Int16Array", "prototype"], "%Int32ArrayPrototype%": ["Int32Array", "prototype"], "%JSONParse%": ["JSON", "parse"], "%JSONStringify%": ["JSON", "stringify"], "%MapPrototype%": ["Map", "prototype"], "%NumberPrototype%": ["Number", "prototype"], "%ObjectPrototype%": ["Object", "prototype"], "%ObjProto_toString%": ["Object", "prototype", "toString"], "%ObjProto_valueOf%": ["Object", "prototype", "valueOf"], "%PromisePrototype%": ["Promise", "prototype"], "%PromiseProto_then%": ["Promise", "prototype", "then"], "%Promise_all%": ["Promise", "all"], "%Promise_reject%": ["Promise", "reject"], "%Promise_resolve%": ["Promise", "resolve"], "%RangeErrorPrototype%": ["RangeError", "prototype"], "%ReferenceErrorPrototype%": ["ReferenceError", "prototype"], "%RegExpPrototype%": ["RegExp", "prototype"], "%SetPrototype%": ["Set", "prototype"], "%SharedArrayBufferPrototype%": ["SharedArrayBuffer", "prototype"], "%StringPrototype%": ["String", "prototype"], "%SymbolPrototype%": ["Symbol", "prototype"], "%SyntaxErrorPrototype%": ["SyntaxError", "prototype"], "%TypedArrayPrototype%": ["TypedArray", "prototype"], "%TypeErrorPrototype%": ["TypeError", "prototype"], "%Uint8ArrayPrototype%": ["Uint8Array", "prototype"], "%Uint8ClampedArrayPrototype%": ["Uint8ClampedArray", "prototype"], "%Uint16ArrayPrototype%": ["Uint16Array", "prototype"], "%Uint32ArrayPrototype%": ["Uint32Array", "prototype"], "%URIErrorPrototype%": ["URIError", "prototype"], "%WeakMapPrototype%": ["WeakMap", "prototype"], "%WeakSetPrototype%": ["WeakSet", "prototype"] }, bind = require_function_bind(), hasOwn = require_hasown(), $concat = bind.call($call, Array.prototype.concat), $spliceApply = bind.call($apply, Array.prototype.splice), $replace = bind.call($call, String.prototype.replace), $strSlice = bind.call($call, String.prototype.slice), $exec = bind.call($call, RegExp.prototype.exec), rePropName2 = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g, reEscapeChar2 = /\\(\\)?/g, stringToPath2 = function(string) { var first = $strSlice(string, 0, 1), last = $strSlice(string, -1); if (first === "%" && last !== "%") throw new $SyntaxError("invalid intrinsic syntax, expected closing `%`"); if (last === "%" && first !== "%") throw new $SyntaxError("invalid intrinsic syntax, expected opening `%`"); var result = []; return $replace(string, rePropName2, function(match, number, quote, subString) { result[result.length] = quote ? $replace(subString, reEscapeChar2, "$1") : number || match; }), result; }, getBaseIntrinsic = function(name, allowMissing) { var intrinsicName = name, alias; if (hasOwn(LEGACY_ALIASES, intrinsicName) && (alias = LEGACY_ALIASES[intrinsicName], intrinsicName = "%" + alias[0] + "%"), hasOwn(INTRINSICS, intrinsicName)) { var value = INTRINSICS[intrinsicName]; if (value === needsEval && (value = doEval(intrinsicName)), typeof value > "u" && !allowMissing) throw new $TypeError("intrinsic " + name + " exists, but is not available. Please file an issue!"); return { alias, name: intrinsicName, value }; } throw new $SyntaxError("intrinsic " + name + " does not exist!"); }; module.exports = function(name, allowMissing) { if (typeof name != "string" || name.length === 0) throw new $TypeError("intrinsic name must be a non-empty string"); if (arguments.length > 1 && typeof allowMissing != "boolean") throw new $TypeError('"allowMissing" argument must be a boolean'); if ($exec(/^%?[^%]*%?$/, name) === null) throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name"); var parts = stringToPath2(name), intrinsicBaseName = parts.length > 0 ? parts[0] : "", intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing), intrinsicRealName = intrinsic.name, value = intrinsic.value, skipFurtherCaching = !1, alias = intrinsic.alias; alias && (intrinsicBaseName = alias[0], $spliceApply(parts, $concat([0, 1], alias))); for (var i = 1, isOwn = !0; i < parts.length; i += 1) { var part = parts[i], first = $strSlice(part, 0, 1), last = $strSlice(part, -1); if ((first === '"' || first === "'" || first === "`" || last === '"' || last === "'" || last === "`") && first !== last) throw new $SyntaxError("property names with quotes must have matching quotes"); if ((part === "constructor" || !isOwn) && (skipFurtherCaching = !0), intrinsicBaseName += "." + part, intrinsicRealName = "%" + intrinsicBaseName + "%", hasOwn(INTRINSICS, intrinsicRealName)) value = INTRINSICS[intrinsicRealName]; else if (value != null) { if (!(part in value)) { if (!allowMissing) throw new $TypeError("base intrinsic for " + name + " exists, but the property is not available."); return; } if ($gOPD && i + 1 >= parts.length) { var desc = $gOPD(value, part); isOwn = !!desc, isOwn && "get" in desc && !("originalValue" in desc.get) ? value = desc.get : value = value[part]; } else isOwn = hasOwn(value, part), value = value[part]; isOwn && !skipFurtherCaching && (INTRINSICS[intrinsicRealName] = value); } } return value; }; } }), require_call_bound = __commonJS({ "node_modules/.pnpm/call-bound@1.0.4/node_modules/call-bound/index.js"(exports, module) { "use strict"; var GetIntrinsic = require_get_intrinsic(), callBindBasic = require_call_bind_apply_helpers(), $indexOf = callBindBasic([GetIntrinsic("%String.prototype.indexOf%")]); module.exports = function(name, allowMissing) { var intrinsic = ( /** @type {(this: unknown, ...args: unknown[]) => unknown} */ GetIntrinsic(name, !!allowMissing) ); return typeof intrinsic == "function" && $indexOf(name, ".prototype.") > -1 ? callBindBasic( /** @type {const} */ [intrinsic] ) : intrinsic; }; } }), require_shams2 = __commonJS({ "node_modules/.pnpm/has-tostringtag@1.0.2/node_modules/has-tostringtag/shams.js"(exports, module) { "use strict"; var hasSymbols = require_shams(); module.exports = function() { return hasSymbols() && !!Symbol.toStringTag; }; } }), require_is_regex = __commonJS({ "node_modules/.pnpm/is-regex@1.2.1/node_modules/is-regex/index.js"(exports, module) { "use strict"; var callBound = require_call_bound(), hasToStringTag = require_shams2()(), hasOwn = require_hasown(), gOPD = require_gopd(), fn; hasToStringTag ? ($exec = callBound("RegExp.prototype.exec"), isRegexMarker = {}, throwRegexMarker = function() { throw isRegexMarker; }, badStringifier = { toString: throwRegexMarker, valueOf: throwRegexMarker }, typeof Symbol.toPrimitive == "symbol" && (badStringifier[Symbol.toPrimitive] = throwRegexMarker), fn = function(value) { if (!value || typeof value != "object") return !1; var descriptor = ( /** @type {NonNullable<typeof gOPD>} */ gOPD( /** @type {{ lastIndex?: unknown }} */ value, "lastIndex" ) ), hasLastIndexDataProperty = descriptor && hasOwn(descriptor, "value"); if (!hasLastIndexDataProperty) return !1; try { $exec( value, /** @type {string} */ /** @type {unknown} */ badStringifier ); } catch (e) { return e === isRegexMarker; } }) : ($toString = callBound("Object.prototype.toString"), regexClass = "[object RegExp]", fn = function(value) { return !value || typeof value != "object" && typeof value != "function" ? !1 : $toString(value) === regexClass; }); var $exec, isRegexMarker, throwRegexMarker, badStringifier, $toString, regexClass; module.exports = fn; } }), require_is_function = __commonJS({ "node_modules/.pnpm/is-function@1.0.2/node_modules/is-function/index.js"(exports, module) { module.exports = isFunction3; var toString2 = Object.prototype.toString; function isFunction3(fn) { if (!fn) return !1; var string = toString2.call(fn); return string === "[object Function]" || typeof fn == "function" && string !== "[object RegExp]" || typeof window < "u" && // IE8 and below (fn === window.setTimeout || fn === window.alert || fn === window.confirm || fn === window.prompt); } } }), require_safe_regex_test = __commonJS({ "node_modules/.pnpm/safe-regex-test@1.1.0/node_modules/safe-regex-test/index.js"(exports, module) { "use strict"; var callBound = require_call_bound(), isRegex = require_is_regex(), $exec = callBound("RegExp.prototype.exec"), $TypeError = require_type(); module.exports = function(regex) { if (!isRegex(regex)) throw new $TypeError("`regex` must be a RegExp"); return function(s) { return $exec(regex, s) !== null; }; }; } }), require_is_symbol = __commonJS({ "node_modules/.pnpm/is-symbol@1.1.1/node_modules/is-symbol/index.js"(exports, module) { "use strict"; var callBound = require_call_bound(), $toString = callBound("Object.prototype.toString"), hasSymbols = require_has_symbols()(), safeRegexTest = require_safe_regex_test(); hasSymbols ? ($symToStr = callBound("Symbol.prototype.toString"), isSymString = safeRegexTest(/^Symbol\(.*\)$/), isSymbolObject = function(value) { return typeof value.valueOf() != "symbol" ? !1 : isSymString($symToStr(value)); }, module.exports = function(value) { if (typeof value == "symbol") return !0; if (!value || typeof value != "object" || $toString(value) !== "[object Symbol]") return !1; try { return isSymbolObject(value); } catch { return !1; } }) : module.exports = function(value) { return !1; }; var $symToStr, isSymString, isSymbolObject; } }), import_is_regex = __toESM(require_is_regex()), import_is_function = __toESM(require_is_function()), import_is_symbol = __toESM(require_is_symbol()); function isObject(val) { return val != null && typeof val == "object" && Array.isArray(val) === !1; } var freeGlobal = typeof global == "object" && global && global.Object === Object && global, freeGlobal_default = freeGlobal, freeSelf = typeof self == "object" && self && self.Object === Object && self, root = freeGlobal_default || freeSelf || Function("return this")(), root_default = root, Symbol2 = root_default.Symbol, Symbol_default = Symbol2, objectProto = Object.prototype, hasOwnProperty = objectProto.hasOwnProperty, nativeObjectToString = objectProto.toString, symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0; function getRawTag(value) { var isOwn = hasOwnProperty.call(value, symToStringTag), tag = value[symToStringTag]; try { value[symToStringTag] = void 0; var unmasked = !0; } catch { } var result = nativeObjectToString.call(value); return unmasked && (isOwn ? value[symToStringTag] = tag : delete value[symToStringTag]), result; } var getRawTag_default = getRawTag, objectProto2 = Object.prototype, nativeObjectToString2 = objectProto2.toString; function objectToString(value) { return nativeObjectToString2.call(value); } var objectToString_default = objectToString, nullTag = "[object Null]", undefinedTag = "[object Undefined]", symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0; function baseGetTag(value) { return value == null ? value === void 0 ? undefinedTag : nullTag : symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value); } var baseGetTag_default = baseGetTag; function isObjectLike(value) { return value != null && typeof value == "object"; } var isObjectLike_default = isObjectLike, symbolTag