playlight-sdk
Version:
The SDK for Playlight - a discovery platform, built into your own game.
1,406 lines • 279 kB
JavaScript
var __defProp = Object.defineProperty;
var __typeError = (msg) => {
throw TypeError(msg);
};
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
var _e3, _t2, _n2, _r, _s, _i, _o, _Batch_instances, a_fn, c_fn, l_fn, u_fn, _n3, _d2, _f, _p, _h, _g, __, _v, _m, _b2, _y, _w, _$, _x, _k, _S, _C, _Boundary_instances, I_fn, M_fn, E_fn, T_fn, O_fn, P_fn, _L, _D, _A, _j, _u, _W, _B, _N, _ResizeObserverSingleton_instances, q_fn, _a, _z, _R, _b, _F, _G, _c, _H, _Y, _V, _d, _U, _PlayLightAPI_instances, K_fn, _e2;
const e = {
exitIntent: {
enabled: true,
immediate: false
},
sidebar: {
hasFrameworkRoot: "auto",
forceVisible: false
}
};
function createConfig(t2 = {}) {
return deepMerge(e, t2);
}
function deepMerge(e2, t2) {
const n2 = {
...e2
};
return isObject(e2) && isObject(t2) && Object.keys(t2).forEach((s2) => {
isObject(t2[s2]) ? s2 in e2 ? n2[s2] = deepMerge(e2[s2], t2[s2]) : Object.assign(n2, {
[s2]: t2[s2]
}) : Object.assign(n2, {
[s2]: t2[s2]
});
}), n2;
}
function isObject(e2) {
return e2 && "object" == typeof e2 && !Array.isArray(e2);
}
const t = false;
var n = Array.isArray, s = Array.prototype.indexOf, i = Array.from, o = Object.defineProperty, a = Object.getOwnPropertyDescriptor, l = Object.getOwnPropertyDescriptors, c = Object.prototype, u = Array.prototype, d = Object.getPrototypeOf, f = Object.isExtensible;
function is_function(e2) {
return "function" == typeof e2;
}
const noop = () => {
};
function deferred() {
var e2, t2;
return {
promise: new Promise((n2, s2) => {
e2 = n2, t2 = s2;
}),
resolve: e2,
reject: t2
};
}
function to_array(e2, t2) {
if (Array.isArray(e2)) return e2;
if (!(Symbol.iterator in e2)) return Array.from(e2);
const n2 = [];
for (const s2 of e2) if (n2.push(s2), n2.length === t2) break;
return n2;
}
const p = 16, h = 32, g = 64, _ = 128, v = 1024, m = 2048, b = 4096, y = 8192, w = 16384, $ = 32768, x = 65536, k = 1 << 17, S = 1 << 19, C = 256, E = 512, O = 32768, I = 1 << 21, M = 1 << 23, T = Symbol("$state"), P = Symbol("legacy props"), L = Symbol(""), D = new class StaleReactionError extends Error {
constructor() {
super(...arguments);
__publicField(this, "name", "StaleReactionError");
__publicField(this, "message", "The reaction that called `getAbortSignal()` was re-run or destroyed");
}
}();
function equals(e2) {
return e2 === this.v;
}
function safe_not_equal(e2, t2) {
return e2 != e2 ? t2 == t2 : e2 !== t2 || null !== e2 && "object" == typeof e2 || "function" == typeof e2;
}
function safe_equals(e2) {
return !safe_not_equal(e2, this.v);
}
function lifecycle_outside_component(e2) {
throw new Error("https://svelte.dev/e/lifecycle_outside_component");
}
let A = false;
const j = Symbol();
let W = null;
function set_component_context(e2) {
W = e2;
}
function getContext(e2) {
return get_or_init_context_map().get(e2);
}
function push(e2, t2 = false, n2) {
W = {
p: W,
c: null,
e: null,
s: e2,
x: null,
l: A && !t2 ? {
s: null,
u: null,
$: []
} : null
};
}
function pop(e2) {
var t2 = (
/** @type {ComponentContext} */
W
), n2 = t2.e;
if (null !== n2) for (var s2 of (t2.e = null, n2)) create_user_effect(s2);
return W = t2.p, /** @type {T} */
{};
}
function is_runes() {
return !A || null !== W && null === W.l;
}
function get_or_init_context_map(e2) {
return null === W && lifecycle_outside_component(), W.c ?? (W.c = new Map(
/**
* @param {ComponentContext} component_context
* @returns {Map<unknown, unknown> | null}
*/
(function get_parent_context(e3) {
let t2 = e3.p;
for (; null !== t2; ) {
const e4 = t2.c;
if (null !== e4) return e4;
t2 = t2.p;
}
return null;
})(W) || void 0
));
}
let B = [];
function run_micro_tasks() {
var e2 = B;
B = [], (function run_all(e3) {
for (var t2 = 0; t2 < e3.length; t2++) e3[t2]();
})(e2);
}
function queue_micro_task(e2) {
if (0 === B.length && !Q) {
var t2 = B;
queueMicrotask(() => {
t2 === B && run_micro_tasks();
});
}
B.push(e2);
}
function flush_tasks() {
for (; B.length > 0; ) run_micro_tasks();
}
function proxy(e2) {
if ("object" != typeof e2 || null === e2 || T in e2) return e2;
const t2 = d(e2);
if (t2 !== c && t2 !== u) return e2;
var s2 = /* @__PURE__ */ new Map(), i2 = n(e2), o2 = /* @__PURE__ */ state(0), l2 = he, with_parent = (e3) => {
if (he === l2) return e3();
var t3 = ie, n2 = he;
set_active_reaction(null), set_update_version(l2);
var s3 = e3();
return set_active_reaction(t3), set_update_version(n2), s3;
};
return i2 && // We need to create the length source eagerly to ensure that
// mutations to the array are properly synced with our proxy
s2.set("length", /* @__PURE__ */ state(
/** @type {any[]} */
e2.length
)), new Proxy(
/** @type {any} */
e2,
{
defineProperty(e3, t3, n2) {
"value" in n2 && false !== n2.configurable && false !== n2.enumerable && false !== n2.writable || // we disallow non-basic descriptors, because unless they are applied to the
// target object — which we avoid, so that state can be forked — we will run
// afoul of the various invariants
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Proxy/Proxy/getOwnPropertyDescriptor#invariants
/**
* Property descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.
* @returns {never}
*/
(function state_descriptors_fixed() {
throw new Error("https://svelte.dev/e/state_descriptors_fixed");
})();
var i3 = s2.get(t3);
return void 0 === i3 ? i3 = with_parent(() => {
var e4 = /* @__PURE__ */ state(n2.value);
return s2.set(t3, e4), e4;
}) : set(i3, n2.value, true), true;
},
deleteProperty(e3, t3) {
var n2 = s2.get(t3);
if (void 0 === n2) {
if (t3 in e3) {
const e4 = with_parent(() => /* @__PURE__ */ state(j));
s2.set(t3, e4), increment(o2);
}
} else set(n2, j), increment(o2);
return true;
},
get(t3, n2, i3) {
var _a2;
if (n2 === T) return e2;
var o3 = s2.get(n2), l3 = n2 in t3;
if (
// create a source, but only if it's an own property and not a prototype property
void 0 !== o3 || l3 && !((_a2 = a(t3, n2)) == null ? void 0 : _a2.writable) || (o3 = with_parent(() => /* @__PURE__ */ state(proxy(l3 ? t3[n2] : j))), s2.set(n2, o3)), void 0 !== o3
) {
var c2 = get$1(o3);
return c2 === j ? void 0 : c2;
}
return Reflect.get(t3, n2, i3);
},
getOwnPropertyDescriptor(e3, t3) {
var n2 = Reflect.getOwnPropertyDescriptor(e3, t3);
if (n2 && "value" in n2) {
var i3 = s2.get(t3);
i3 && (n2.value = get$1(i3));
} else if (void 0 === n2) {
var o3 = s2.get(t3), a2 = o3 == null ? void 0 : o3.v;
if (void 0 !== o3 && a2 !== j) return {
enumerable: true,
configurable: true,
value: a2,
writable: true
};
}
return n2;
},
has(e3, t3) {
var _a2;
if (t3 === T) return true;
var n2 = s2.get(t3), i3 = void 0 !== n2 && n2.v !== j || Reflect.has(e3, t3);
if ((void 0 !== n2 || null !== ae && (!i3 || ((_a2 = a(e3, t3)) == null ? void 0 : _a2.writable))) && (void 0 === n2 && (n2 = with_parent(() => /* @__PURE__ */ state(i3 ? proxy(e3[t3]) : j)), s2.set(t3, n2)), get$1(n2) === j)) return false;
return i3;
},
set(e3, t3, n2, l3) {
var _a2;
var c2 = s2.get(t3), u2 = t3 in e3;
if (i2 && "length" === t3) for (var d2 = n2; d2 < /** @type {Source<number>} */
c2.v; d2 += 1) {
var f2 = s2.get(d2 + "");
void 0 !== f2 ? set(f2, j) : d2 in e3 && // If the item exists in the original, we need to create a uninitialized source,
// else a later read of the property would result in a source being created with
// the value of the original item at that index.
(f2 = with_parent(() => /* @__PURE__ */ state(j)), s2.set(d2 + "", f2));
}
void 0 === c2 ? u2 && !((_a2 = a(e3, t3)) == null ? void 0 : _a2.writable) || (set(c2 = with_parent(() => /* @__PURE__ */ state(void 0)), proxy(n2)), s2.set(t3, c2)) : (u2 = c2.v !== j, set(c2, with_parent(() => proxy(n2))));
var p2 = Reflect.getOwnPropertyDescriptor(e3, t3);
if ((p2 == null ? void 0 : p2.set) && p2.set.call(l3, n2), !u2) {
if (i2 && "string" == typeof t3) {
var h2 = (
/** @type {Source<number>} */
s2.get("length")
), g2 = Number(t3);
Number.isInteger(g2) && g2 >= h2.v && set(h2, g2 + 1);
}
increment(o2);
}
return true;
},
ownKeys(e3) {
get$1(o2);
var t3 = Reflect.ownKeys(e3).filter((e4) => {
var t4 = s2.get(e4);
return void 0 === t4 || t4.v !== j;
});
for (var [n2, i3] of s2) i3.v === j || n2 in e3 || t3.push(n2);
return t3;
},
setPrototypeOf() {
!(function state_prototype_fixed() {
throw new Error("https://svelte.dev/e/state_prototype_fixed");
})();
}
}
);
}
function get_proxied_value(e2) {
try {
if (null !== e2 && "object" == typeof e2 && T in e2) return e2[T];
} catch {
}
return e2;
}
function is(e2, t2) {
return Object.is(get_proxied_value(e2), get_proxied_value(t2));
}
var N, q, z, R;
function create_text(e2 = "") {
return document.createTextNode(e2);
}
// @__NO_SIDE_EFFECTS__
function get_first_child(e2) {
return z.call(e2);
}
// @__NO_SIDE_EFFECTS__
function get_next_sibling(e2) {
return R.call(e2);
}
function child(e2, t2) {
return /* @__PURE__ */ get_first_child(e2);
}
function first_child(e2, t2 = false) {
var n2 = (
/** @type {DocumentFragment} */
/* @__PURE__ */ get_first_child(
/** @type {Node} */
e2
)
);
return n2 instanceof Comment && "" === n2.data ? /* @__PURE__ */ get_next_sibling(n2) : n2;
}
function sibling(e2, t2 = 1, n2 = false) {
let s2 = e2;
for (; t2--; ) s2 = /** @type {TemplateNode} */
/* @__PURE__ */ get_next_sibling(s2);
return s2;
}
const F = /* @__PURE__ */ new WeakMap();
function handle_error(e2) {
var t2 = ae;
if (null === t2)
return ie.f |= M, e2;
if (0 === (t2.f & $)) {
if (0 === (t2.f & _)) throw !t2.parent && e2 instanceof Error && apply_adjustments(e2), e2;
t2.b.error(e2);
} else
invoke_error_boundary(e2, t2);
}
function invoke_error_boundary(e2, t2) {
for (; null !== t2; ) {
if (0 !== (t2.f & _)) try {
return void t2.b.error(e2);
} catch (t3) {
e2 = t3;
}
t2 = t2.parent;
}
throw e2 instanceof Error && apply_adjustments(e2), e2;
}
function apply_adjustments(e2) {
const t2 = F.get(e2);
t2 && (o(e2, "message", {
value: t2.message
}), o(e2, "stack", {
value: t2.stack
}));
}
const G = /* @__PURE__ */ new Set();
let H = null, Y = null, V = null, U = /* @__PURE__ */ new Set(), K = [], Z = null, J = false, Q = false;
const _Batch = class _Batch {
constructor() {
__privateAdd(this, _Batch_instances);
__publicField(this, "committed", false);
/**
* The current values of any sources that are updated in this batch
* They keys of this map are identical to `this.#previous`
* @type {Map<Source, any>}
*/
__publicField(this, "current", /* @__PURE__ */ new Map());
/**
* The values of any sources that are updated in this batch _before_ those updates took place.
* They keys of this map are identical to `this.#current`
* @type {Map<Source, any>}
*/
__privateAdd(this, _e3, /* @__PURE__ */ new Map());
/**
* When the batch is committed (and the DOM is updated), we need to remove old branches
* and append new ones by calling the functions added inside (if/each/key/etc) blocks
* @type {Set<() => void>}
*/
__privateAdd(this, _t2, /* @__PURE__ */ new Set());
/**
* The number of async effects that are currently in flight
*/
__privateAdd(this, _n2, 0);
/**
* The number of async effects that are currently in flight, _not_ inside a pending boundary
*/
__privateAdd(this, _r, 0);
/**
* A deferred that resolves when the batch is committed, used with `settled()`
* TODO replace with Promise.withResolvers once supported widely enough
* @type {{ promise: Promise<void>, resolve: (value?: any) => void, reject: (reason: unknown) => void } | null}
*/
__privateAdd(this, _s, null);
/**
* Deferred effects (which run after async work has completed) that are DIRTY
* @type {Effect[]}
*/
__privateAdd(this, _i, []);
/**
* Deferred effects that are MAYBE_DIRTY
* @type {Effect[]}
*/
__privateAdd(this, _o, []);
/**
* A set of branches that still exist, but will be destroyed when this batch
* is committed — we skip over these during `process`
* @type {Set<Effect>}
*/
__publicField(this, "skipped_effects", /* @__PURE__ */ new Set());
}
/**
*
* @param {Effect[]} root_effects
*/
process(e2) {
K = [], Y = null, this.apply();
var t2 = {
parent: null,
effect: null,
effects: [],
render_effects: [],
block_effects: []
};
for (const n2 of e2) __privateMethod(this, _Batch_instances, a_fn).call(this, n2, t2);
__privateMethod(this, _Batch_instances, l_fn).call(this), __privateGet(this, _r) > 0 ? (__privateMethod(this, _Batch_instances, c_fn).call(this, t2.effects), __privateMethod(this, _Batch_instances, c_fn).call(this, t2.render_effects), __privateMethod(this, _Batch_instances, c_fn).call(this, t2.block_effects)) : (
// TODO append/detach blocks here, not in #commit
// If sources are written to, then work needs to happen in a separate batch, else prior sources would be mixed with
// newly updated sources, which could lead to infinite loops when effects run over and over again.
(Y = this, H = null, flush_queued_effects(t2.render_effects), flush_queued_effects(t2.effects), Y = null)
), V = null;
}
/**
* Associate a change to a given source with the current
* batch, noting its previous and current values
* @param {Source} source
* @param {any} value
*/
capture(e2, t2) {
__privateGet(this, _e3).has(e2) || __privateGet(this, _e3).set(e2, t2), this.current.set(e2, e2.v), V == null ? void 0 : V.set(e2, e2.v);
}
activate() {
H = this;
}
deactivate() {
H = null, V = null;
}
flush() {
if (K.length > 0) {
if (this.activate(), flush_effects(), null !== H && H !== this)
return;
} else __privateMethod(this, _Batch_instances, l_fn).call(this);
this.deactivate();
for (const e2 of U) if (U.delete(e2), e2(), null !== H)
break;
}
/**
*
* @param {boolean} blocking
*/
increment(e2) {
__privateSet(this, _n2, __privateGet(this, _n2) + 1), e2 && __privateSet(this, _r, __privateGet(this, _r) + 1);
}
/**
*
* @param {boolean} blocking
*/
decrement(e2) {
__privateSet(this, _n2, __privateGet(this, _n2) - 1), e2 && __privateSet(this, _r, __privateGet(this, _r) - 1);
for (const e3 of __privateGet(this, _i)) set_signal_status(e3, m), schedule_effect(e3);
for (const e3 of __privateGet(this, _o)) set_signal_status(e3, b), schedule_effect(e3);
__privateSet(this, _i, []), __privateSet(this, _o, []), this.flush();
}
/** @param {() => void} fn */
add_callback(e2) {
__privateGet(this, _t2).add(e2);
}
settled() {
return (__privateGet(this, _s) ?? __privateSet(this, _s, deferred())).promise;
}
static ensure() {
if (null === H) {
const e2 = H = new _Batch();
G.add(H), Q || _Batch.enqueue(() => {
H === e2 && e2.flush();
});
}
return H;
}
/** @param {() => void} task */
static enqueue(e2) {
queue_micro_task(e2);
}
apply() {
}
};
_e3 = new WeakMap();
_t2 = new WeakMap();
_n2 = new WeakMap();
_r = new WeakMap();
_s = new WeakMap();
_i = new WeakMap();
_o = new WeakMap();
_Batch_instances = new WeakSet();
/**
* Traverse the effect tree, executing effects or stashing
* them for later execution as appropriate
* @param {Effect} root
* @param {EffectTarget} target
*/
a_fn = function(e2, t2) {
var _a2;
e2.f ^= v;
for (var n2 = e2.first; null !== n2; ) {
var s2 = n2.f, i2 = !!(96 & s2), o2 = i2 && 0 !== (s2 & v) || 0 !== (s2 & y) || this.skipped_effects.has(n2);
if (0 !== (n2.f & _) && ((_a2 = n2.b) == null ? void 0 : _a2.is_pending()) && (t2 = {
parent: t2,
effect: n2,
effects: [],
render_effects: [],
block_effects: []
}), !o2 && null !== n2.fn) {
i2 ? n2.f ^= v : 4 & s2 ? t2.effects.push(n2) : is_dirty(n2) && (0 !== (n2.f & p) && t2.block_effects.push(n2), update_effect(n2));
var a2 = n2.first;
if (null !== a2) {
n2 = a2;
continue;
}
}
var l2 = n2.parent;
for (n2 = n2.next; null === n2 && null !== l2; ) l2 === t2.effect && // TODO rather than traversing into pending boundaries and deferring the effects,
// could we just attach the effects _to_ the pending boundary and schedule them
// once the boundary is ready?
(__privateMethod(this, _Batch_instances, c_fn).call(this, t2.effects), __privateMethod(this, _Batch_instances, c_fn).call(this, t2.render_effects), __privateMethod(this, _Batch_instances, c_fn).call(this, t2.block_effects), t2 = /** @type {EffectTarget} */
t2.parent), n2 = l2.next, l2 = l2.parent;
}
};
/**
* @param {Effect[]} effects
*/
c_fn = function(e2) {
for (const t2 of e2) {
(0 !== (t2.f & m) ? __privateGet(this, _i) : __privateGet(this, _o)).push(t2), // mark as clean so they get scheduled if they depend on pending async state
set_signal_status(t2, v);
}
};
l_fn = function() {
if (0 === __privateGet(this, _r)) {
for (const e2 of __privateGet(this, _t2)) e2();
__privateGet(this, _t2).clear();
}
0 === __privateGet(this, _n2) && __privateMethod(this, _Batch_instances, u_fn).call(this);
};
u_fn = function() {
var _a2, _b3;
if (G.size > 1) {
__privateGet(this, _e3).clear();
var e2 = V, t2 = true, n2 = {
parent: null,
effect: null,
effects: [],
render_effects: [],
block_effects: []
};
for (const e3 of G) {
if (e3 === this) {
t2 = false;
continue;
}
const s2 = [];
for (const [n3, i3] of this.current) {
if (e3.current.has(n3)) {
if (!t2 || i3 === e3.current.get(n3))
continue;
e3.current.set(n3, i3);
}
s2.push(n3);
}
if (0 === s2.length) continue;
const i2 = [...e3.current.keys()].filter((e4) => !this.current.has(e4));
if (i2.length > 0) {
const t3 = /* @__PURE__ */ new Set(), o2 = /* @__PURE__ */ new Map();
for (const e4 of s2) mark_effects(e4, i2, t3, o2);
if (K.length > 0) {
H = e3, e3.apply();
for (const t4 of K) __privateMethod(_a2 = e3, _Batch_instances, a_fn).call(_a2, t4, n2);
K = [], e3.deactivate();
}
}
}
H = null, V = e2;
}
this.committed = true, G.delete(this), (_b3 = __privateGet(this, _s)) == null ? void 0 : _b3.resolve();
};
let Batch = _Batch;
function flush_effects() {
var e2 = re;
J = true;
try {
var n2 = 0;
for (set_is_updating_effect(true); K.length > 0; ) {
var s2 = Batch.ensure();
if (n2++ > 1e3) t, infinite_loop_guard();
s2.process(K), te.clear();
}
} finally {
J = false, set_is_updating_effect(e2), Z = null;
}
}
function infinite_loop_guard() {
try {
!/**
* Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
* @returns {never}
*/
(function effect_update_depth_exceeded() {
throw new Error("https://svelte.dev/e/effect_update_depth_exceeded");
})();
} catch (e2) {
invoke_error_boundary(e2, Z);
}
}
let ee = null;
function flush_queued_effects(e2) {
var t2 = e2.length;
if (0 !== t2) {
for (var n2 = 0; n2 < t2; ) {
var s2 = e2[n2++];
if (!(24576 & s2.f) && is_dirty(s2) && (ee = /* @__PURE__ */ new Set(), update_effect(s2), // Effects with no dependencies or teardown do not get added to the effect tree.
// Deferred effects (e.g. `$effect(...)`) _are_ added to the tree because we
// don't know if we need to keep them until they are executed. Doing the check
// here (rather than in `update_effect`) allows us to skip the work for
// immediate effects.
null === s2.deps && null === s2.first && null === s2.nodes_start && // if there's no teardown or abort controller we completely unlink
// the effect from the graph
(null === s2.teardown && null === s2.ac ? (
// remove this effect from the graph
unlink_effect(s2)
) : (
// keep the effect in the graph, but free up some memory
s2.fn = null
)), (ee == null ? void 0 : ee.size) > 0)) {
te.clear();
for (const e3 of ee) {
if (24576 & e3.f) continue;
const t3 = [e3];
let n3 = e3.parent;
for (; null !== n3; ) ee.has(n3) && (ee.delete(n3), t3.push(n3)), n3 = n3.parent;
for (let e4 = t3.length - 1; e4 >= 0; e4--) {
const n4 = t3[e4];
24576 & n4.f || update_effect(n4);
}
}
ee.clear();
}
}
ee = null;
}
}
function mark_effects(e2, t2, n2, s2) {
if (!n2.has(e2) && (n2.add(e2), null !== e2.reactions)) for (const i2 of e2.reactions) {
const e3 = i2.f;
2 & e3 ? mark_effects(
/** @type {Derived} */
i2,
t2,
n2,
s2
) : 4194320 & e3 && 0 === (e3 & m) && // we may have scheduled this one already
depends_on(i2, t2, s2) && (set_signal_status(i2, m), schedule_effect(
/** @type {Effect} */
i2
));
}
}
function depends_on(e2, t2, n2) {
const s2 = n2.get(e2);
if (void 0 !== s2) return s2;
if (null !== e2.deps) for (const s3 of e2.deps) {
if (t2.includes(s3)) return true;
if (2 & s3.f && depends_on(
/** @type {Derived} */
s3,
t2,
n2
)) return n2.set(
/** @type {Derived} */
s3,
true
), true;
}
return n2.set(e2, false), false;
}
function schedule_effect(e2) {
for (var t2 = Z = e2; null !== t2.parent; ) {
var n2 = (t2 = t2.parent).f;
if (J && t2 === ae && 0 !== (n2 & p)) return;
if (96 & n2) {
if (0 === (n2 & v)) return;
t2.f ^= v;
}
}
K.push(t2);
}
function createSubscriber(e2) {
let t2, n2 = 0, s2 = source(0);
return () => {
/**
* Internal representation of `$effect.tracking()`
* @returns {boolean}
*/
/* @__PURE__ */ (function effect_tracking() {
return null !== ie && !oe;
})() && (get$1(s2), render_effect(() => (0 === n2 && (t2 = untrack(() => e2(() => increment(s2)))), n2 += 1, () => {
queue_micro_task(() => {
n2 -= 1, 0 === n2 && (t2 == null ? void 0 : t2(), t2 = void 0, // Increment the version to ensure any dependent deriveds are marked dirty when the subscription is picked up again later.
// If we didn't do this then the comparison of write versions would determine that the derived has a later version than
// the subscriber, and it would not be re-run.
increment(s2));
});
})));
};
}
class Boundary {
/**
* @param {TemplateNode} node
* @param {BoundaryProps} props
* @param {((anchor: Node) => void)} children
*/
constructor(e2, t2, n2) {
__privateAdd(this, _Boundary_instances);
/** @type {Boundary | null} */
__publicField(this, "parent");
__privateAdd(this, _n3, false);
/** @type {TemplateNode} */
__privateAdd(this, _d2);
/** @type {TemplateNode | null} */
__privateAdd(this, _f, null);
/** @type {BoundaryProps} */
__privateAdd(this, _p);
/** @type {((anchor: Node) => void)} */
__privateAdd(this, _h);
/** @type {Effect} */
__privateAdd(this, _g);
/** @type {Effect | null} */
__privateAdd(this, __, null);
/** @type {Effect | null} */
__privateAdd(this, _v, null);
/** @type {Effect | null} */
__privateAdd(this, _m, null);
/** @type {DocumentFragment | null} */
__privateAdd(this, _b2, null);
/** @type {TemplateNode | null} */
__privateAdd(this, _y, null);
__privateAdd(this, _w, 0);
__privateAdd(this, _$, 0);
__privateAdd(this, _x, false);
/**
* A source containing the number of pending async deriveds/expressions.
* Only created if `$effect.pending()` is used inside the boundary,
* otherwise updating the source results in needless `Batch.ensure()`
* calls followed by no-op flushes
* @type {Source<number> | null}
*/
__privateAdd(this, _k, null);
__privateAdd(this, _S, () => {
__privateGet(this, _k) && internal_set(__privateGet(this, _k), __privateGet(this, _w));
});
__privateAdd(this, _C, createSubscriber(() => (__privateSet(this, _k, source(__privateGet(this, _w))), () => {
__privateSet(this, _k, null);
})));
__privateSet(this, _d2, e2), __privateSet(this, _p, t2), __privateSet(this, _h, n2), this.parent = /** @type {Effect} */
ae.b, __privateSet(this, _n3, !!__privateGet(this, _p).pending), __privateSet(this, _g, block(() => {
ae.b = this;
var e3 = __privateMethod(this, _Boundary_instances, E_fn).call(this);
try {
__privateSet(this, __, branch(() => n2(e3)));
} catch (e4) {
this.error(e4);
}
return __privateGet(this, _$) > 0 ? __privateMethod(this, _Boundary_instances, O_fn).call(this) : __privateSet(this, _n3, false), () => {
var _a2;
(_a2 = __privateGet(this, _y)) == null ? void 0 : _a2.remove();
};
}, 589952));
}
/**
* Returns `true` if the effect exists inside a boundary whose pending snippet is shown
* @returns {boolean}
*/
is_pending() {
return __privateGet(this, _n3) || !!this.parent && this.parent.is_pending();
}
has_pending_snippet() {
return !!__privateGet(this, _p).pending;
}
/**
* Update the source that powers `$effect.pending()` inside this boundary,
* and controls when the current `pending` snippet (if any) is removed.
* Do not call from inside the class
* @param {1 | -1} d
*/
update_pending_count(e2) {
__privateMethod(this, _Boundary_instances, P_fn).call(this, e2), __privateSet(this, _w, __privateGet(this, _w) + e2), U.add(__privateGet(this, _S));
}
get_effect_pending() {
return __privateGet(this, _C).call(this), get$1(
/** @type {Source<number>} */
__privateGet(this, _k)
);
}
/** @param {unknown} error */
error(e2) {
var t2 = __privateGet(this, _p).onerror;
let n2 = __privateGet(this, _p).failed;
if (__privateGet(this, _x) || !t2 && !n2) throw e2;
__privateGet(this, __) && (destroy_effect(__privateGet(this, __)), __privateSet(this, __, null)), __privateGet(this, _v) && (destroy_effect(__privateGet(this, _v)), __privateSet(this, _v, null)), __privateGet(this, _m) && (destroy_effect(__privateGet(this, _m)), __privateSet(this, _m, null));
var s2 = false, i2 = false;
const reset = () => {
s2 ? (
/**
* A `<svelte:boundary>` `reset` function only resets the boundary the first time it is called
*/
(function svelte_boundary_reset_noop() {
console.warn("https://svelte.dev/e/svelte_boundary_reset_noop");
})()
) : (s2 = true, i2 && /**
* A `<svelte:boundary>` `reset` function cannot be called while an error is still being handled
* @returns {never}
*/
(function svelte_boundary_reset_onerror() {
throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror");
})(), // If the failure happened while flushing effects, current_batch can be null
Batch.ensure(), __privateSet(this, _w, 0), null !== __privateGet(this, _m) && pause_effect(__privateGet(this, _m), () => {
__privateSet(this, _m, null);
}), // we intentionally do not try to find the nearest pending boundary. If this boundary has one, we'll render it on reset
// but it would be really weird to show the parent's boundary on a child reset.
__privateSet(this, _n3, this.has_pending_snippet()), __privateSet(this, __, __privateMethod(this, _Boundary_instances, T_fn).call(this, () => (__privateSet(this, _x, false), branch(() => __privateGet(this, _h).call(this, __privateGet(this, _d2)))))), __privateGet(this, _$) > 0 ? __privateMethod(this, _Boundary_instances, O_fn).call(this) : __privateSet(this, _n3, false));
};
var o2 = ie;
try {
set_active_reaction(null), i2 = true, t2 == null ? void 0 : t2(e2, reset), i2 = false;
} catch (e3) {
invoke_error_boundary(e3, __privateGet(this, _g) && __privateGet(this, _g).parent);
} finally {
set_active_reaction(o2);
}
n2 && queue_micro_task(() => {
__privateSet(this, _m, __privateMethod(this, _Boundary_instances, T_fn).call(this, () => {
Batch.ensure(), __privateSet(this, _x, true);
try {
return branch(() => {
n2(__privateGet(this, _d2), () => e2, () => reset);
});
} catch (e3) {
return invoke_error_boundary(
e3,
/** @type {Effect} */
__privateGet(this, _g).parent
), null;
} finally {
__privateSet(this, _x, false);
}
}));
});
}
}
_n3 = new WeakMap();
_d2 = new WeakMap();
_f = new WeakMap();
_p = new WeakMap();
_h = new WeakMap();
_g = new WeakMap();
__ = new WeakMap();
_v = new WeakMap();
_m = new WeakMap();
_b2 = new WeakMap();
_y = new WeakMap();
_w = new WeakMap();
_$ = new WeakMap();
_x = new WeakMap();
_k = new WeakMap();
_S = new WeakMap();
_C = new WeakMap();
_Boundary_instances = new WeakSet();
I_fn = function() {
try {
__privateSet(this, __, branch(() => __privateGet(this, _h).call(this, __privateGet(this, _d2))));
} catch (e2) {
this.error(e2);
}
__privateSet(this, _n3, false);
};
M_fn = function() {
const e2 = __privateGet(this, _p).pending;
e2 && (__privateSet(this, _v, branch(() => e2(__privateGet(this, _d2)))), Batch.enqueue(() => {
var e3 = __privateMethod(this, _Boundary_instances, E_fn).call(this);
__privateSet(this, __, __privateMethod(this, _Boundary_instances, T_fn).call(this, () => (Batch.ensure(), branch(() => __privateGet(this, _h).call(this, e3))))), __privateGet(this, _$) > 0 ? __privateMethod(this, _Boundary_instances, O_fn).call(this) : (pause_effect(
/** @type {Effect} */
__privateGet(this, _v),
() => {
__privateSet(this, _v, null);
}
), __privateSet(this, _n3, false));
}));
};
E_fn = function() {
var e2 = __privateGet(this, _d2);
return __privateGet(this, _n3) && (__privateSet(this, _y, create_text()), __privateGet(this, _d2).before(__privateGet(this, _y)), e2 = __privateGet(this, _y)), e2;
};
/**
* @param {() => Effect | null} fn
*/
T_fn = function(e2) {
var t2 = ae, n2 = ie, s2 = W;
set_active_effect(__privateGet(this, _g)), set_active_reaction(__privateGet(this, _g)), set_component_context(__privateGet(this, _g).ctx);
try {
return e2();
} catch (e3) {
return handle_error(e3), null;
} finally {
set_active_effect(t2), set_active_reaction(n2), set_component_context(s2);
}
};
O_fn = function() {
const e2 = (
/** @type {(anchor: Node) => void} */
__privateGet(this, _p).pending
);
null !== __privateGet(this, __) && (__privateSet(this, _b2, document.createDocumentFragment()), __privateGet(this, _b2).append(
/** @type {TemplateNode} */
__privateGet(this, _y)
), move_effect(__privateGet(this, __), __privateGet(this, _b2))), null === __privateGet(this, _v) && __privateSet(this, _v, branch(() => e2(__privateGet(this, _d2))));
};
/**
* Updates the pending count associated with the currently visible pending snippet,
* if any, such that we can replace the snippet with content once work is done
* @param {1 | -1} d
*/
P_fn = function(e2) {
var _a2;
this.has_pending_snippet() ? (__privateSet(this, _$, __privateGet(this, _$) + e2), 0 === __privateGet(this, _$) && (__privateSet(this, _n3, false), __privateGet(this, _v) && pause_effect(__privateGet(this, _v), () => {
__privateSet(this, _v, null);
}), __privateGet(this, _b2) && (__privateGet(this, _d2).before(__privateGet(this, _b2)), __privateSet(this, _b2, null)))) : this.parent && __privateMethod(_a2 = this.parent, _Boundary_instances, P_fn).call(_a2, e2);
};
function flatten(e2, t2, n2) {
const s2 = is_runes() ? derived : derived_safe_equal;
if (0 !== t2.length) {
var i2 = H, o2 = (
/** @type {Effect} */
ae
), a2 = (
/**
* Captures the current effect context so that we can restore it after
* some asynchronous work has happened (so that e.g. `await a + b`
* causes `b` to be registered as a dependency).
*/
/* @__PURE__ */ (function capture() {
var e3 = ae, t3 = ie, n3 = W, s3 = H;
return function restore2() {
set_active_effect(e3), set_active_reaction(t3), set_component_context(n3), s3 == null ? void 0 : s3.activate();
};
})()
);
Promise.all(t2.map((e3) => (
/**
* @template V
* @param {() => V | Promise<V>} fn
* @param {string} [location] If provided, print a warning if the value is not read immediately after update
* @returns {Promise<Source<V>>}
*/
(/* @__NO_SIDE_EFFECTS__ */ function async_derived(e4, t3) {
let n3 = (
/** @type {Effect | null} */
ae
);
null === n3 && (function async_derived_orphan() {
throw new Error("https://svelte.dev/e/async_derived_orphan");
})();
var s3 = (
/** @type {Boundary} */
n3.b
), i3 = (
/** @type {Promise<V>} */
/** @type {unknown} */
void 0
), o3 = source(
/** @type {V} */
j
), a3 = !ie, l2 = /* @__PURE__ */ new Map();
return (function async_effect(e5) {
return create_effect(4718592, e5, true);
})(() => {
var _a2;
var t4 = deferred();
i3 = t4.promise;
try {
Promise.resolve(e4()).then(t4.resolve, t4.reject).then(() => {
n4 === H && n4.committed && // if the batch was rejected as stale, we need to cleanup
// after any `$.save(...)` calls inside `fn()`
n4.deactivate(), unset_context();
});
} catch (e5) {
t4.reject(e5), unset_context();
}
var n4 = (
/** @type {Batch} */
H
);
if (a3) {
var c2 = !s3.is_pending();
s3.update_pending_count(1), n4.increment(c2), (_a2 = l2.get(n4)) == null ? void 0 : _a2.reject(D), l2.delete(n4), // delete to ensure correct order in Map iteration below
l2.set(n4, t4);
}
const handler = (e5, t5 = void 0) => {
if (n4.activate(), t5) t5 !== D && (o3.f |= M, // @ts-expect-error the error is the wrong type, but we don't care
internal_set(o3, t5));
else {
0 !== (o3.f & M) && (o3.f ^= M), internal_set(o3, e5);
for (const [e6, t6] of l2) {
if (l2.delete(e6), e6 === n4) break;
t6.reject(D);
}
}
a3 && (s3.update_pending_count(-1), n4.decrement(c2));
};
t4.promise.then(handler, (e5) => handler(null, e5 || "unknown"));
}), teardown(() => {
for (const e5 of l2.values()) e5.reject(D);
}), new Promise((e5) => {
function next(t4) {
function go() {
t4 === i3 ? e5(o3) : (
// if the effect re-runs before the initial promise
// resolves, delay resolution until we have a value
next(i3)
);
}
t4.then(go, go);
}
next(i3);
});
})(e3)
))).then((t3) => {
a2();
try {
n2([...e2.map(s2), ...t3]);
} catch (e3) {
0 === (o2.f & w) && invoke_error_boundary(e3, o2);
}
i2 == null ? void 0 : i2.deactivate(), unset_context();
}).catch((e3) => {
invoke_error_boundary(e3, o2);
});
} else n2(e2.map(s2));
}
function unset_context() {
set_active_effect(null), set_active_reaction(null), set_component_context(null);
}
// @__NO_SIDE_EFFECTS__
function derived(e2) {
var t2 = 2050, n2 = null !== ie && 2 & ie.f ? (
/** @type {Derived} */
ie
) : null;
null === ae || null !== n2 && 0 !== (n2.f & C) ? t2 |= C : (
// Since deriveds are evaluated lazily, any effects created inside them are
// created too late to ensure that the parent effect is added to the tree
ae.f |= S
);
return {
ctx: W,
deps: null,
effects: null,
equals,
f: t2,
fn: e2,
reactions: null,
rv: 0,
v: (
/** @type {V} */
j
),
wv: 0,
parent: n2 ?? ae,
ac: null
};
}
function user_derived(e2) {
const t2 = /* @__PURE__ */ derived(e2);
return push_reaction_value(t2), t2;
}
// @__NO_SIDE_EFFECTS__
function derived_safe_equal(e2) {
const t2 = /* @__PURE__ */ derived(e2);
return t2.equals = safe_equals, t2;
}
function destroy_derived_effects(e2) {
var t2 = e2.effects;
if (null !== t2) {
e2.effects = null;
for (var n2 = 0; n2 < t2.length; n2 += 1) destroy_effect(
/** @type {Effect} */
t2[n2]
);
}
}
function execute_derived(e2) {
var t2, n2 = ae;
set_active_effect((function get_derived_parent_effect(e3) {
for (var t3 = e3.parent; null !== t3; ) {
if (!(2 & t3.f))
return t3;
t3 = t3.parent;
}
return null;
})(e2));
try {
e2.f &= -32769, destroy_derived_effects(e2), t2 = update_reaction(e2);
} finally {
set_active_effect(n2);
}
return t2;
}
function update_derived(e2) {
var t2 = execute_derived(e2);
(e2.equals(t2) || // TODO can we avoid setting `derived.v` when `batch_values !== null`,
// without causing the value to be stale later?
(e2.v = t2, e2.wv = increment_write_version()), se) || (null !== V ? V.set(e2, e2.v) : set_signal_status(e2, !ge && 0 === (e2.f & C) || null === e2.deps ? v : b));
}
const te = /* @__PURE__ */ new Map();
function source(e2, t2) {
return {
f: 0,
// TODO ideally we could skip this altogether, but it causes type errors
v: e2,
reactions: null,
equals,
rv: 0,
wv: 0
};
}
// @__NO_SIDE_EFFECTS__
function state(e2, t2) {
const n2 = source(e2);
return push_reaction_value(n2), n2;
}
// @__NO_SIDE_EFFECTS__
function mutable_source(e2, t2 = false, n2 = true) {
var _a2;
const s2 = source(e2);
return t2 || (s2.equals = safe_equals), // bind the signal to the component context, in case we need to
// track updates to trigger beforeUpdate/afterUpdate callbacks
A && n2 && null !== W && null !== W.l && ((_a2 = W.l).s ?? (_a2.s = [])).push(s2), s2;
}
function set(e2, t2, n2 = false) {
return null !== ie && // since we are untracking the function inside `$inspect.with` we need to add this check
// to ensure we error if state is set inside an inspect effect
(!oe || 0 !== (ie.f & k)) && is_runes() && 4325394 & ie.f && !(le == null ? void 0 : le.includes(e2)) && (function state_unsafe_mutation() {
throw new Error("https://svelte.dev/e/state_unsafe_mutation");
})(), internal_set(e2, n2 ? proxy(t2) : t2);
}
function internal_set(e2, t2) {
if (!e2.equals(t2)) {
var n2 = e2.v;
se ? te.set(e2, t2) : te.set(e2, n2), e2.v = t2, Batch.ensure().capture(e2, n2), 2 & e2.f && // if we are assigning to a dirty derived we set it to clean/maybe dirty but we also eagerly execute it to track the dependencies
(0 !== (e2.f & m) && execute_derived(
/** @type {Derived} */
e2
), set_signal_status(e2, 0 === (e2.f & C) ? v : b)), e2.wv = increment_write_version(), mark_reactions(e2, m), // It's possible that the current reaction might not have up-to-date dependencies
// whilst it's actively running. So in the case of ensuring it registers the reaction
// properly for itself, we need to ensure the current effect actually gets
// scheduled. i.e: `$effect(() => x++)`
!is_runes() || null === ae || 0 === (ae.f & v) || 96 & ae.f || (null === de ? (
/** @param {null | Source[]} value */
(function set_untracked_writes(e3) {
de = e3;
})([e2])
) : de.push(e2));
}
return t2;
}
function increment(e2) {
set(e2, e2.v + 1);
}
function mark_reactions(e2, t2) {
var n2 = e2.reactions;
if (null !== n2) for (var s2 = is_runes(), i2 = n2.length, o2 = 0; o2 < i2; o2++) {
var a2 = n2[o2], l2 = a2.f;
if (s2 || a2 !== ae) {
var c2 = 0 === (l2 & m);
c2 && set_signal_status(a2, t2), 2 & l2 ? 0 === (l2 & O) && (a2.f |= O, mark_reactions(
/** @type {Derived} */
a2,
b
)) : c2 && (0 !== (l2 & p) && null !== ee && ee.add(
/** @type {Effect} */
a2
), schedule_effect(
/** @type {Effect} */
a2
));
}
}
}
function autofocus(e2, t2) {
if (t2) {
const t3 = document.body;
e2.autofocus = true, queue_micro_task(() => {
document.activeElement === t3 && e2.focus();
});
}
}
let ne = false;
function without_reactive_context(e2) {
var t2 = ie, n2 = ae;
set_active_reaction(null), set_active_effect(null);
try {
return e2();
} finally {
set_active_reaction(t2), set_active_effect(n2);
}
}
function listen_to_event_and_reset_event(e2, t2, n2, s2 = n2) {
e2.addEventListener(t2, () => without_reactive_context(n2));
const i2 = e2.__on_r;
e2.__on_r = i2 ? () => {
i2(), s2(true);
} : () => s2(true), (function add_form_reset_listener() {
ne || (ne = true, document.addEventListener(
"reset",
(e3) => {
Promise.resolve().then(() => {
var _a2;
if (!e3.defaultPrevented) for (
const t3 of
/**@type {HTMLFormElement} */
e3.target.elements
)
(_a2 = t3.__on_r) == null ? void 0 : _a2.call(t3);
});
},
// In the capture phase to guarantee we get noticed of it (no possiblity of stopPropagation)
{
capture: true
}
));
})();
}
let re = false;
function set_is_updating_effect(e2) {
re = e2;
}
let se = false;
function set_is_destroying_effect(e2) {
se = e2;
}
let ie = null, oe = false;
function set_active_reaction(e2) {
ie = e2;
}
let ae = null;
function set_active_effect(e2) {
ae = e2;
}
let le = null;
function push_reaction_value(e2) {
null !== ie && (null === le ? le = [e2] : le.push(e2));
}
let ce = null, ue = 0, de = null;
let fe = 1, pe = 0, he = pe;
function set_update_version(e2) {
he = e2;
}
let ge = false;
function increment_write_version() {
return ++fe;
}
function is_dirty(e2) {
var _a2;
var t2 = e2.f;
if (0 !== (t2 & m)) return true;
if (0 !== (t2 & b)) {
var n2 = e2.deps, s2 = 0 !== (t2 & C);
if (2 & t2 && (e2.f &= -32769), null !== n2) {
var i2, o2, a2 = 0 !== (t2 & E), l2 = s2 && null !== ae && !ge, c2 = n2.length;
if ((a2 || l2) && (null === ae || 0 === (ae.f & w))) {
var u2 = (
/** @type {Derived} */
e2
), d2 = u2.parent;
for (i2 = 0; i2 < c2; i2++) o2 = n2[i2], // We always re-add all reactions (even duplicates) if the derived was
// previously disconnected, however we don't if it was unowned as we
// de-duplicate dependencies in that case
!a2 && ((_a2 = o2 == null ? void 0 : o2.reactions) == null ? void 0 : _a2.includes(u2)) || (o2.reactions ?? (o2.reactions = [])).push(u2);
a2 && (u2.f ^= E), // If the unowned derived is now fully connected to the graph again (it's unowned and reconnected, has a parent
// and the parent is not unowned), then we can mark it as connected again, removing the need for the unowned
// flag
l2 && null !== d2 && 0 === (d2.f & C) && (u2.f ^= C);
}
for (i2 = 0; i2 < c2; i2++) if (is_dirty(o2 = n2[i2]) && update_derived(
/** @type {Derived} */
o2
), o2.wv > e2.wv) return true;
}
s2 && (null === ae || ge) || set_signal_status(e2, v);
}
return false;
}
function schedule_possible_effect_self_invalidation(e2, t2, n2 = true) {
var s2 = e2.reactions;
if (null !== s2 && !(le == null ? void 0 : le.includes(e2))) for (var i2 = 0; i2 < s2.length; i2++) {
var o2 = s2[i2];
2 & o2.f ? schedule_possible_effect_self_invalidation(
/** @type {Derived} */
o2,
t2,
false
) : t2 === o2 && (n2 ? set_signal_status(o2, m) : 0 !== (o2.f & v) && set_signal_status(o2, b), schedule_effect(
/** @type {Effect} */
o2
));
}
}
function update_reaction(e2) {
var _a2;
var t2 = ce, n2 = ue, s2 = de, i2 = ie, o2 = ge, a2 = le, l2 = W, c2 = oe, u2 = he, d2 = e2.f;
ce = /** @type {null | Value[]} */
null, ue = 0, de = null, ge = 0 !== (d2 & C) && (oe || !re || null === ie), ie = 96 & d2 ? null : e2, le = null, set_component_context(e2.ctx), oe = false, he = ++pe, null !== e2.ac && (without_reactive_context(() => {
e2.ac.abort(D);
}), e2.ac = null);
try {
e2.f |= I;
var f2 = (0, /** @type {Function} */
e2.fn)(), p2 = e2.deps;
if (null !== ce) {
var h2;
if (remove_reactions(e2, ue), null !== p2 && ue > 0) for (p2.length = ue + ce.length, h2 = 0; h2 < ce.length; h2++) p2[ue + h2] = ce[h2];
else e2.deps = p2 = ce;
if (!ge || // Deriveds that already have reactions can cleanup, so we still add them as reactions
2 & d2 && /** @type {import('#client').Derived} */
null !== e2.reactions) for (h2 = ue; h2 < p2.length; h2++) ((_a2 = p2[h2]).reactions ?? (_a2.reactions = [])).push(e2);
} else null !== p2 && ue < p2.length && (remove_reactions(e2, ue), p2.length = ue);
if (is_runes() && null !== de && !oe && null !== p2 && !(6146 & e2.f)) for (h2 = 0; h2 < /** @type {Source[]} */
de.length; h2++) schedule_possible_effect_self_invalidation(
de[h2],
/** @type {Effect} */
e2
);
return null !== i2 && i2 !== e2 && (pe++, null !== de && (null === s2 ? s2 = de : s2.push(.../** @type {Source[]} */
de))), 0 !== (e2.f & M) && (e2.f ^= M), f2;
} catch (e3) {
return handle_error(e3);
} finally {
e2.f ^= I, ce = t2, ue = n2, de = s2, ie = i2, ge = o2, le = a2, set_component_context(l2), oe = c2, he = u2;
}
}
function remove_reaction(e2, t2) {
let n2 = t2.reactions;
if (null !== n2) {
var i2 = s.call(n2, e2);
if (-1 !== i2) {
var o2 = n2.length - 1;
0 === o2 ? n2 = t2.reactions = null : (
// Swap with last element and then remove.
(n2[i2] = n2[o2], n2.pop())
);
}
}
null === n2 && 2 & t2.f && // Destroying a child effect while updating a parent effect can cause a dependency to appear
// to be unused, when in fact it is used by the currently-updating parent. Checking `new_deps`
// allows us to skip the expensive work of disconnecting and immediately reconnecting it
(null === ce || !ce.includes(t2)) && (set_signal_status(t2, b), // If we are working with a derived that is owned by an effect, then mark it as being
// disconnected.
768 & t2.f || (t2.f ^= E), // Disconnect any reactions owned by this reaction
destroy_derived_effects(
/** @type {Derived} **/
t2
), remove_reactions(
/** @type {Derived} **/
t2,
0
));
}
function remove_reactions(e2, t2) {
var n2 = e2.deps;
if (null !== n2) for (var s2 = t2; s2 < n2.length; s2++) remove_reaction(e2, n2[s2]);
}
function update_effect(e2) {
var t2 = e2.f;
if (0 === (t2 & w)) {
set_signal_status(e2, v);
var n2 = ae, s2 = re;
ae = e2, re = true;
try {
0 !== (t2 & p) ? (
/**
* @param {Effect} signal
* @returns {void}
*/
(function destroy_block_effect_children(e3) {
var t3 = e3.first;
for (; null !== t3; ) {
var n3 = t3.next;
0 === (t3.f & h) && destroy_effect(t3), t3 = n3;
}
})(e2)
) : destroy_effect_children(e2), execute_effect_teardown(e2);
var i2 = update_reaction(e2);
e2.teardown = "function" == typeof i2 ? i2 : null, e2.wv = fe;
} final