1124 lines
30 KiB
JavaScript
1124 lines
30 KiB
JavaScript
import "clsx";
|
|
const BROWSER = false;
|
|
var is_array = Array.isArray;
|
|
var array_from = Array.from;
|
|
var define_property = Object.defineProperty;
|
|
var get_descriptor = Object.getOwnPropertyDescriptor;
|
|
const noop = () => {
|
|
};
|
|
function run_all(arr) {
|
|
for (var i = 0; i < arr.length; i++) {
|
|
arr[i]();
|
|
}
|
|
}
|
|
function fallback(value, fallback2, lazy = false) {
|
|
return value === void 0 ? lazy ? (
|
|
/** @type {() => V} */
|
|
fallback2()
|
|
) : (
|
|
/** @type {V} */
|
|
fallback2
|
|
) : value;
|
|
}
|
|
const DERIVED = 1 << 1;
|
|
const EFFECT = 1 << 2;
|
|
const RENDER_EFFECT = 1 << 3;
|
|
const BLOCK_EFFECT = 1 << 4;
|
|
const BRANCH_EFFECT = 1 << 5;
|
|
const ROOT_EFFECT = 1 << 6;
|
|
const BOUNDARY_EFFECT = 1 << 7;
|
|
const UNOWNED = 1 << 8;
|
|
const DISCONNECTED = 1 << 9;
|
|
const CLEAN = 1 << 10;
|
|
const DIRTY = 1 << 11;
|
|
const MAYBE_DIRTY = 1 << 12;
|
|
const INERT = 1 << 13;
|
|
const DESTROYED = 1 << 14;
|
|
const EFFECT_RAN = 1 << 15;
|
|
const EFFECT_TRANSPARENT = 1 << 16;
|
|
const HEAD_EFFECT = 1 << 19;
|
|
const EFFECT_HAS_DERIVED = 1 << 20;
|
|
const LEGACY_PROPS = Symbol("legacy props");
|
|
function effect_update_depth_exceeded() {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/effect_update_depth_exceeded`);
|
|
}
|
|
}
|
|
function hydration_failed() {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/hydration_failed`);
|
|
}
|
|
}
|
|
function state_unsafe_local_read() {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/state_unsafe_local_read`);
|
|
}
|
|
}
|
|
function state_unsafe_mutation() {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/state_unsafe_mutation`);
|
|
}
|
|
}
|
|
let tracing_mode_flag = false;
|
|
const HYDRATION_START = "[";
|
|
const HYDRATION_END = "]";
|
|
const HYDRATION_ERROR = {};
|
|
var $window;
|
|
var first_child_getter;
|
|
var next_sibling_getter;
|
|
function init_operations() {
|
|
if ($window !== void 0) {
|
|
return;
|
|
}
|
|
$window = window;
|
|
var element_prototype = Element.prototype;
|
|
var node_prototype = Node.prototype;
|
|
first_child_getter = get_descriptor(node_prototype, "firstChild").get;
|
|
next_sibling_getter = get_descriptor(node_prototype, "nextSibling").get;
|
|
element_prototype.__click = void 0;
|
|
element_prototype.__className = "";
|
|
element_prototype.__attributes = null;
|
|
element_prototype.__styles = null;
|
|
element_prototype.__e = void 0;
|
|
Text.prototype.__t = void 0;
|
|
}
|
|
function create_text(value = "") {
|
|
return document.createTextNode(value);
|
|
}
|
|
// @__NO_SIDE_EFFECTS__
|
|
function get_first_child(node) {
|
|
return first_child_getter.call(node);
|
|
}
|
|
// @__NO_SIDE_EFFECTS__
|
|
function get_next_sibling(node) {
|
|
return next_sibling_getter.call(node);
|
|
}
|
|
function clear_text_content(node) {
|
|
node.textContent = "";
|
|
}
|
|
function destroy_derived_children(derived) {
|
|
var children = derived.children;
|
|
if (children !== null) {
|
|
derived.children = null;
|
|
for (var i = 0; i < children.length; i += 1) {
|
|
var child = children[i];
|
|
if ((child.f & DERIVED) !== 0) {
|
|
destroy_derived(
|
|
/** @type {Derived} */
|
|
child
|
|
);
|
|
} else {
|
|
destroy_effect(
|
|
/** @type {Effect} */
|
|
child
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function get_derived_parent_effect(derived) {
|
|
var parent = derived.parent;
|
|
while (parent !== null) {
|
|
if ((parent.f & DERIVED) === 0) {
|
|
return (
|
|
/** @type {Effect} */
|
|
parent
|
|
);
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
return null;
|
|
}
|
|
function execute_derived(derived) {
|
|
var value;
|
|
var prev_active_effect = active_effect;
|
|
set_active_effect(get_derived_parent_effect(derived));
|
|
{
|
|
try {
|
|
destroy_derived_children(derived);
|
|
value = update_reaction(derived);
|
|
} finally {
|
|
set_active_effect(prev_active_effect);
|
|
}
|
|
}
|
|
return value;
|
|
}
|
|
function update_derived(derived) {
|
|
var value = execute_derived(derived);
|
|
var status = (skip_reaction || (derived.f & UNOWNED) !== 0) && derived.deps !== null ? MAYBE_DIRTY : CLEAN;
|
|
set_signal_status(derived, status);
|
|
if (!derived.equals(value)) {
|
|
derived.v = value;
|
|
derived.version = increment_version();
|
|
}
|
|
}
|
|
function destroy_derived(derived) {
|
|
destroy_derived_children(derived);
|
|
remove_reactions(derived, 0);
|
|
set_signal_status(derived, DESTROYED);
|
|
derived.v = derived.children = derived.deps = derived.ctx = derived.reactions = null;
|
|
}
|
|
function push_effect(effect2, parent_effect) {
|
|
var parent_last = parent_effect.last;
|
|
if (parent_last === null) {
|
|
parent_effect.last = parent_effect.first = effect2;
|
|
} else {
|
|
parent_last.next = effect2;
|
|
effect2.prev = parent_last;
|
|
parent_effect.last = effect2;
|
|
}
|
|
}
|
|
function create_effect(type, fn, sync, push2 = true) {
|
|
var is_root = (type & ROOT_EFFECT) !== 0;
|
|
var parent_effect = active_effect;
|
|
var effect2 = {
|
|
ctx: component_context,
|
|
deps: null,
|
|
deriveds: null,
|
|
nodes_start: null,
|
|
nodes_end: null,
|
|
f: type | DIRTY,
|
|
first: null,
|
|
fn,
|
|
last: null,
|
|
next: null,
|
|
parent: is_root ? null : parent_effect,
|
|
prev: null,
|
|
teardown: null,
|
|
transitions: null,
|
|
version: 0
|
|
};
|
|
if (sync) {
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
try {
|
|
set_is_flushing_effect(true);
|
|
update_effect(effect2);
|
|
effect2.f |= EFFECT_RAN;
|
|
} catch (e) {
|
|
destroy_effect(effect2);
|
|
throw e;
|
|
} finally {
|
|
set_is_flushing_effect(previously_flushing_effect);
|
|
}
|
|
} else if (fn !== null) {
|
|
schedule_effect(effect2);
|
|
}
|
|
var inert = sync && effect2.deps === null && effect2.first === null && effect2.nodes_start === null && effect2.teardown === null && (effect2.f & EFFECT_HAS_DERIVED) === 0;
|
|
if (!inert && !is_root && push2) {
|
|
if (parent_effect !== null) {
|
|
push_effect(effect2, parent_effect);
|
|
}
|
|
if (active_reaction !== null && (active_reaction.f & DERIVED) !== 0) {
|
|
var derived = (
|
|
/** @type {Derived} */
|
|
active_reaction
|
|
);
|
|
(derived.children ??= []).push(effect2);
|
|
}
|
|
}
|
|
return effect2;
|
|
}
|
|
function component_root(fn) {
|
|
const effect2 = create_effect(ROOT_EFFECT, fn, true);
|
|
return (options = {}) => {
|
|
return new Promise((fulfil) => {
|
|
if (options.outro) {
|
|
pause_effect(effect2, () => {
|
|
destroy_effect(effect2);
|
|
fulfil(void 0);
|
|
});
|
|
} else {
|
|
destroy_effect(effect2);
|
|
fulfil(void 0);
|
|
}
|
|
});
|
|
};
|
|
}
|
|
function effect(fn) {
|
|
return create_effect(EFFECT, fn, false);
|
|
}
|
|
function branch(fn, push2 = true) {
|
|
return create_effect(RENDER_EFFECT | BRANCH_EFFECT, fn, true, push2);
|
|
}
|
|
function execute_effect_teardown(effect2) {
|
|
var teardown = effect2.teardown;
|
|
if (teardown !== null) {
|
|
const previous_reaction = active_reaction;
|
|
set_active_reaction(null);
|
|
try {
|
|
teardown.call(null);
|
|
} finally {
|
|
set_active_reaction(previous_reaction);
|
|
}
|
|
}
|
|
}
|
|
function destroy_effect_deriveds(signal) {
|
|
var deriveds = signal.deriveds;
|
|
if (deriveds !== null) {
|
|
signal.deriveds = null;
|
|
for (var i = 0; i < deriveds.length; i += 1) {
|
|
destroy_derived(deriveds[i]);
|
|
}
|
|
}
|
|
}
|
|
function destroy_effect_children(signal, remove_dom = false) {
|
|
var effect2 = signal.first;
|
|
signal.first = signal.last = null;
|
|
while (effect2 !== null) {
|
|
var next = effect2.next;
|
|
destroy_effect(effect2, remove_dom);
|
|
effect2 = next;
|
|
}
|
|
}
|
|
function destroy_block_effect_children(signal) {
|
|
var effect2 = signal.first;
|
|
while (effect2 !== null) {
|
|
var next = effect2.next;
|
|
if ((effect2.f & BRANCH_EFFECT) === 0) {
|
|
destroy_effect(effect2);
|
|
}
|
|
effect2 = next;
|
|
}
|
|
}
|
|
function destroy_effect(effect2, remove_dom = true) {
|
|
var removed = false;
|
|
if ((remove_dom || (effect2.f & HEAD_EFFECT) !== 0) && effect2.nodes_start !== null) {
|
|
var node = effect2.nodes_start;
|
|
var end = effect2.nodes_end;
|
|
while (node !== null) {
|
|
var next = node === end ? null : (
|
|
/** @type {TemplateNode} */
|
|
/* @__PURE__ */ get_next_sibling(node)
|
|
);
|
|
node.remove();
|
|
node = next;
|
|
}
|
|
removed = true;
|
|
}
|
|
destroy_effect_children(effect2, remove_dom && !removed);
|
|
destroy_effect_deriveds(effect2);
|
|
remove_reactions(effect2, 0);
|
|
set_signal_status(effect2, DESTROYED);
|
|
var transitions = effect2.transitions;
|
|
if (transitions !== null) {
|
|
for (const transition of transitions) {
|
|
transition.stop();
|
|
}
|
|
}
|
|
execute_effect_teardown(effect2);
|
|
var parent = effect2.parent;
|
|
if (parent !== null && parent.first !== null) {
|
|
unlink_effect(effect2);
|
|
}
|
|
effect2.next = effect2.prev = effect2.teardown = effect2.ctx = effect2.deps = effect2.fn = effect2.nodes_start = effect2.nodes_end = null;
|
|
}
|
|
function unlink_effect(effect2) {
|
|
var parent = effect2.parent;
|
|
var prev = effect2.prev;
|
|
var next = effect2.next;
|
|
if (prev !== null) prev.next = next;
|
|
if (next !== null) next.prev = prev;
|
|
if (parent !== null) {
|
|
if (parent.first === effect2) parent.first = next;
|
|
if (parent.last === effect2) parent.last = prev;
|
|
}
|
|
}
|
|
function pause_effect(effect2, callback) {
|
|
var transitions = [];
|
|
pause_children(effect2, transitions, true);
|
|
run_out_transitions(transitions, () => {
|
|
destroy_effect(effect2);
|
|
callback();
|
|
});
|
|
}
|
|
function run_out_transitions(transitions, fn) {
|
|
var remaining = transitions.length;
|
|
if (remaining > 0) {
|
|
var check = () => --remaining || fn();
|
|
for (var transition of transitions) {
|
|
transition.out(check);
|
|
}
|
|
} else {
|
|
fn();
|
|
}
|
|
}
|
|
function pause_children(effect2, transitions, local) {
|
|
if ((effect2.f & INERT) !== 0) return;
|
|
effect2.f ^= INERT;
|
|
if (effect2.transitions !== null) {
|
|
for (const transition of effect2.transitions) {
|
|
if (transition.is_global || local) {
|
|
transitions.push(transition);
|
|
}
|
|
}
|
|
}
|
|
var child = effect2.first;
|
|
while (child !== null) {
|
|
var sibling = child.next;
|
|
var transparent = (child.f & EFFECT_TRANSPARENT) !== 0 || (child.f & BRANCH_EFFECT) !== 0;
|
|
pause_children(child, transitions, transparent ? local : false);
|
|
child = sibling;
|
|
}
|
|
}
|
|
function flush_tasks() {
|
|
}
|
|
function invalid_default_snippet() {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/invalid_default_snippet`);
|
|
}
|
|
}
|
|
function lifecycle_outside_component(name) {
|
|
{
|
|
throw new Error(`https://svelte.dev/e/lifecycle_outside_component`);
|
|
}
|
|
}
|
|
const FLUSH_MICROTASK = 0;
|
|
const FLUSH_SYNC = 1;
|
|
let is_throwing_error = false;
|
|
let scheduler_mode = FLUSH_MICROTASK;
|
|
let is_micro_task_queued = false;
|
|
let last_scheduled_effect = null;
|
|
let is_flushing_effect = false;
|
|
function set_is_flushing_effect(value) {
|
|
is_flushing_effect = value;
|
|
}
|
|
let queued_root_effects = [];
|
|
let flush_count = 0;
|
|
let dev_effect_stack = [];
|
|
let active_reaction = null;
|
|
function set_active_reaction(reaction) {
|
|
active_reaction = reaction;
|
|
}
|
|
let active_effect = null;
|
|
function set_active_effect(effect2) {
|
|
active_effect = effect2;
|
|
}
|
|
let derived_sources = null;
|
|
let new_deps = null;
|
|
let skipped_deps = 0;
|
|
let untracked_writes = null;
|
|
function set_untracked_writes(value) {
|
|
untracked_writes = value;
|
|
}
|
|
let current_version = 1;
|
|
let skip_reaction = false;
|
|
let component_context = null;
|
|
function increment_version() {
|
|
return ++current_version;
|
|
}
|
|
function is_runes() {
|
|
return true;
|
|
}
|
|
function check_dirtiness(reaction) {
|
|
var flags = reaction.f;
|
|
if ((flags & DIRTY) !== 0) {
|
|
return true;
|
|
}
|
|
if ((flags & MAYBE_DIRTY) !== 0) {
|
|
var dependencies = reaction.deps;
|
|
var is_unowned = (flags & UNOWNED) !== 0;
|
|
if (dependencies !== null) {
|
|
var i;
|
|
var dependency;
|
|
var is_disconnected = (flags & DISCONNECTED) !== 0;
|
|
var is_unowned_connected = is_unowned && active_effect !== null && !skip_reaction;
|
|
var length = dependencies.length;
|
|
if (is_disconnected || is_unowned_connected) {
|
|
for (i = 0; i < length; i++) {
|
|
dependency = dependencies[i];
|
|
if (is_disconnected || !dependency?.reactions?.includes(reaction)) {
|
|
(dependency.reactions ??= []).push(reaction);
|
|
}
|
|
}
|
|
if (is_disconnected) {
|
|
reaction.f ^= DISCONNECTED;
|
|
}
|
|
}
|
|
for (i = 0; i < length; i++) {
|
|
dependency = dependencies[i];
|
|
if (check_dirtiness(
|
|
/** @type {Derived} */
|
|
dependency
|
|
)) {
|
|
update_derived(
|
|
/** @type {Derived} */
|
|
dependency
|
|
);
|
|
}
|
|
if (dependency.version > reaction.version) {
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
if (!is_unowned || active_effect !== null && !skip_reaction) {
|
|
set_signal_status(reaction, CLEAN);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function propagate_error(error, effect2) {
|
|
var current = effect2;
|
|
while (current !== null) {
|
|
if ((current.f & BOUNDARY_EFFECT) !== 0) {
|
|
try {
|
|
current.fn(error);
|
|
return;
|
|
} catch {
|
|
current.f ^= BOUNDARY_EFFECT;
|
|
}
|
|
}
|
|
current = current.parent;
|
|
}
|
|
is_throwing_error = false;
|
|
throw error;
|
|
}
|
|
function should_rethrow_error(effect2) {
|
|
return (effect2.f & DESTROYED) === 0 && (effect2.parent === null || (effect2.parent.f & BOUNDARY_EFFECT) === 0);
|
|
}
|
|
function handle_error(error, effect2, previous_effect, component_context2) {
|
|
if (is_throwing_error) {
|
|
if (previous_effect === null) {
|
|
is_throwing_error = false;
|
|
}
|
|
if (should_rethrow_error(effect2)) {
|
|
throw error;
|
|
}
|
|
return;
|
|
}
|
|
if (previous_effect !== null) {
|
|
is_throwing_error = true;
|
|
}
|
|
{
|
|
propagate_error(error, effect2);
|
|
return;
|
|
}
|
|
}
|
|
function update_reaction(reaction) {
|
|
var previous_deps = new_deps;
|
|
var previous_skipped_deps = skipped_deps;
|
|
var previous_untracked_writes = untracked_writes;
|
|
var previous_reaction = active_reaction;
|
|
var previous_skip_reaction = skip_reaction;
|
|
var prev_derived_sources = derived_sources;
|
|
var previous_component_context = component_context;
|
|
var flags = reaction.f;
|
|
new_deps = /** @type {null | Value[]} */
|
|
null;
|
|
skipped_deps = 0;
|
|
untracked_writes = null;
|
|
active_reaction = (flags & (BRANCH_EFFECT | ROOT_EFFECT)) === 0 ? reaction : null;
|
|
skip_reaction = !is_flushing_effect && (flags & UNOWNED) !== 0;
|
|
derived_sources = null;
|
|
component_context = reaction.ctx;
|
|
try {
|
|
var result = (
|
|
/** @type {Function} */
|
|
(0, reaction.fn)()
|
|
);
|
|
var deps = reaction.deps;
|
|
if (new_deps !== null) {
|
|
var i;
|
|
remove_reactions(reaction, skipped_deps);
|
|
if (deps !== null && skipped_deps > 0) {
|
|
deps.length = skipped_deps + new_deps.length;
|
|
for (i = 0; i < new_deps.length; i++) {
|
|
deps[skipped_deps + i] = new_deps[i];
|
|
}
|
|
} else {
|
|
reaction.deps = deps = new_deps;
|
|
}
|
|
if (!skip_reaction) {
|
|
for (i = skipped_deps; i < deps.length; i++) {
|
|
(deps[i].reactions ??= []).push(reaction);
|
|
}
|
|
}
|
|
} else if (deps !== null && skipped_deps < deps.length) {
|
|
remove_reactions(reaction, skipped_deps);
|
|
deps.length = skipped_deps;
|
|
}
|
|
return result;
|
|
} finally {
|
|
new_deps = previous_deps;
|
|
skipped_deps = previous_skipped_deps;
|
|
untracked_writes = previous_untracked_writes;
|
|
active_reaction = previous_reaction;
|
|
skip_reaction = previous_skip_reaction;
|
|
derived_sources = prev_derived_sources;
|
|
component_context = previous_component_context;
|
|
}
|
|
}
|
|
function remove_reaction(signal, dependency) {
|
|
let reactions = dependency.reactions;
|
|
if (reactions !== null) {
|
|
var index = reactions.indexOf(signal);
|
|
if (index !== -1) {
|
|
var new_length = reactions.length - 1;
|
|
if (new_length === 0) {
|
|
reactions = dependency.reactions = null;
|
|
} else {
|
|
reactions[index] = reactions[new_length];
|
|
reactions.pop();
|
|
}
|
|
}
|
|
}
|
|
if (reactions === null && (dependency.f & DERIVED) !== 0 && // 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
|
|
(new_deps === null || !new_deps.includes(dependency))) {
|
|
set_signal_status(dependency, MAYBE_DIRTY);
|
|
if ((dependency.f & (UNOWNED | DISCONNECTED)) === 0) {
|
|
dependency.f ^= DISCONNECTED;
|
|
}
|
|
remove_reactions(
|
|
/** @type {Derived} **/
|
|
dependency,
|
|
0
|
|
);
|
|
}
|
|
}
|
|
function remove_reactions(signal, start_index) {
|
|
var dependencies = signal.deps;
|
|
if (dependencies === null) return;
|
|
for (var i = start_index; i < dependencies.length; i++) {
|
|
remove_reaction(signal, dependencies[i]);
|
|
}
|
|
}
|
|
function update_effect(effect2) {
|
|
var flags = effect2.f;
|
|
if ((flags & DESTROYED) !== 0) {
|
|
return;
|
|
}
|
|
set_signal_status(effect2, CLEAN);
|
|
var previous_effect = active_effect;
|
|
var previous_component_context = component_context;
|
|
active_effect = effect2;
|
|
try {
|
|
if ((flags & BLOCK_EFFECT) !== 0) {
|
|
destroy_block_effect_children(effect2);
|
|
} else {
|
|
destroy_effect_children(effect2);
|
|
}
|
|
destroy_effect_deriveds(effect2);
|
|
execute_effect_teardown(effect2);
|
|
var teardown = update_reaction(effect2);
|
|
effect2.teardown = typeof teardown === "function" ? teardown : null;
|
|
effect2.version = current_version;
|
|
var deps = effect2.deps;
|
|
var dep;
|
|
if (BROWSER && tracing_mode_flag && (effect2.f & DIRTY) !== 0 && deps !== null) ;
|
|
if (BROWSER) ;
|
|
} catch (error) {
|
|
handle_error(error, effect2, previous_effect, previous_component_context || effect2.ctx);
|
|
} finally {
|
|
active_effect = previous_effect;
|
|
}
|
|
}
|
|
function infinite_loop_guard() {
|
|
if (flush_count > 1e3) {
|
|
flush_count = 0;
|
|
try {
|
|
effect_update_depth_exceeded();
|
|
} catch (error) {
|
|
if (last_scheduled_effect !== null) {
|
|
{
|
|
handle_error(error, last_scheduled_effect, null);
|
|
}
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
flush_count++;
|
|
}
|
|
function flush_queued_root_effects(root_effects) {
|
|
var length = root_effects.length;
|
|
if (length === 0) {
|
|
return;
|
|
}
|
|
infinite_loop_guard();
|
|
var previously_flushing_effect = is_flushing_effect;
|
|
is_flushing_effect = true;
|
|
try {
|
|
for (var i = 0; i < length; i++) {
|
|
var effect2 = root_effects[i];
|
|
if ((effect2.f & CLEAN) === 0) {
|
|
effect2.f ^= CLEAN;
|
|
}
|
|
var collected_effects = [];
|
|
process_effects(effect2, collected_effects);
|
|
flush_queued_effects(collected_effects);
|
|
}
|
|
} finally {
|
|
is_flushing_effect = previously_flushing_effect;
|
|
}
|
|
}
|
|
function flush_queued_effects(effects) {
|
|
var length = effects.length;
|
|
if (length === 0) return;
|
|
for (var i = 0; i < length; i++) {
|
|
var effect2 = effects[i];
|
|
if ((effect2.f & (DESTROYED | INERT)) === 0) {
|
|
try {
|
|
if (check_dirtiness(effect2)) {
|
|
update_effect(effect2);
|
|
if (effect2.deps === null && effect2.first === null && effect2.nodes_start === null) {
|
|
if (effect2.teardown === null) {
|
|
unlink_effect(effect2);
|
|
} else {
|
|
effect2.fn = null;
|
|
}
|
|
}
|
|
}
|
|
} catch (error) {
|
|
handle_error(error, effect2, null, effect2.ctx);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function process_deferred() {
|
|
is_micro_task_queued = false;
|
|
if (flush_count > 1001) {
|
|
return;
|
|
}
|
|
const previous_queued_root_effects = queued_root_effects;
|
|
queued_root_effects = [];
|
|
flush_queued_root_effects(previous_queued_root_effects);
|
|
if (!is_micro_task_queued) {
|
|
flush_count = 0;
|
|
last_scheduled_effect = null;
|
|
}
|
|
}
|
|
function schedule_effect(signal) {
|
|
if (scheduler_mode === FLUSH_MICROTASK) {
|
|
if (!is_micro_task_queued) {
|
|
is_micro_task_queued = true;
|
|
queueMicrotask(process_deferred);
|
|
}
|
|
}
|
|
last_scheduled_effect = signal;
|
|
var effect2 = signal;
|
|
while (effect2.parent !== null) {
|
|
effect2 = effect2.parent;
|
|
var flags = effect2.f;
|
|
if ((flags & (ROOT_EFFECT | BRANCH_EFFECT)) !== 0) {
|
|
if ((flags & CLEAN) === 0) return;
|
|
effect2.f ^= CLEAN;
|
|
}
|
|
}
|
|
queued_root_effects.push(effect2);
|
|
}
|
|
function process_effects(effect2, collected_effects) {
|
|
var current_effect = effect2.first;
|
|
var effects = [];
|
|
main_loop: while (current_effect !== null) {
|
|
var flags = current_effect.f;
|
|
var is_branch = (flags & BRANCH_EFFECT) !== 0;
|
|
var is_skippable_branch = is_branch && (flags & CLEAN) !== 0;
|
|
var sibling = current_effect.next;
|
|
if (!is_skippable_branch && (flags & INERT) === 0) {
|
|
if ((flags & RENDER_EFFECT) !== 0) {
|
|
if (is_branch) {
|
|
current_effect.f ^= CLEAN;
|
|
} else {
|
|
try {
|
|
if (check_dirtiness(current_effect)) {
|
|
update_effect(current_effect);
|
|
}
|
|
} catch (error) {
|
|
handle_error(error, current_effect, null, current_effect.ctx);
|
|
}
|
|
}
|
|
var child = current_effect.first;
|
|
if (child !== null) {
|
|
current_effect = child;
|
|
continue;
|
|
}
|
|
} else if ((flags & EFFECT) !== 0) {
|
|
effects.push(current_effect);
|
|
}
|
|
}
|
|
if (sibling === null) {
|
|
let parent = current_effect.parent;
|
|
while (parent !== null) {
|
|
if (effect2 === parent) {
|
|
break main_loop;
|
|
}
|
|
var parent_sibling = parent.next;
|
|
if (parent_sibling !== null) {
|
|
current_effect = parent_sibling;
|
|
continue main_loop;
|
|
}
|
|
parent = parent.parent;
|
|
}
|
|
}
|
|
current_effect = sibling;
|
|
}
|
|
for (var i = 0; i < effects.length; i++) {
|
|
child = effects[i];
|
|
collected_effects.push(child);
|
|
process_effects(child, collected_effects);
|
|
}
|
|
}
|
|
function flush_sync(fn) {
|
|
var previous_scheduler_mode = scheduler_mode;
|
|
var previous_queued_root_effects = queued_root_effects;
|
|
try {
|
|
infinite_loop_guard();
|
|
const root_effects = [];
|
|
scheduler_mode = FLUSH_SYNC;
|
|
queued_root_effects = root_effects;
|
|
is_micro_task_queued = false;
|
|
flush_queued_root_effects(previous_queued_root_effects);
|
|
var result = fn?.();
|
|
flush_tasks();
|
|
if (queued_root_effects.length > 0 || root_effects.length > 0) {
|
|
flush_sync();
|
|
}
|
|
flush_count = 0;
|
|
last_scheduled_effect = null;
|
|
if (BROWSER) ;
|
|
return result;
|
|
} finally {
|
|
scheduler_mode = previous_scheduler_mode;
|
|
queued_root_effects = previous_queued_root_effects;
|
|
}
|
|
}
|
|
function get(signal) {
|
|
var flags = signal.f;
|
|
var is_derived = (flags & DERIVED) !== 0;
|
|
if (is_derived && (flags & DESTROYED) !== 0) {
|
|
var value = execute_derived(
|
|
/** @type {Derived} */
|
|
signal
|
|
);
|
|
destroy_derived(
|
|
/** @type {Derived} */
|
|
signal
|
|
);
|
|
return value;
|
|
}
|
|
if (active_reaction !== null) {
|
|
if (derived_sources !== null && derived_sources.includes(signal)) {
|
|
state_unsafe_local_read();
|
|
}
|
|
var deps = active_reaction.deps;
|
|
if (new_deps === null && deps !== null && deps[skipped_deps] === signal) {
|
|
skipped_deps++;
|
|
} else if (new_deps === null) {
|
|
new_deps = [signal];
|
|
} else {
|
|
new_deps.push(signal);
|
|
}
|
|
if (untracked_writes !== null && active_effect !== null && (active_effect.f & CLEAN) !== 0 && (active_effect.f & BRANCH_EFFECT) === 0 && untracked_writes.includes(signal)) {
|
|
set_signal_status(active_effect, DIRTY);
|
|
schedule_effect(active_effect);
|
|
}
|
|
} else if (is_derived && /** @type {Derived} */
|
|
signal.deps === null) {
|
|
var derived = (
|
|
/** @type {Derived} */
|
|
signal
|
|
);
|
|
var parent = derived.parent;
|
|
var target = derived;
|
|
while (parent !== null) {
|
|
if ((parent.f & DERIVED) !== 0) {
|
|
var parent_derived = (
|
|
/** @type {Derived} */
|
|
parent
|
|
);
|
|
target = parent_derived;
|
|
parent = parent_derived.parent;
|
|
} else {
|
|
var parent_effect = (
|
|
/** @type {Effect} */
|
|
parent
|
|
);
|
|
if (!parent_effect.deriveds?.includes(target)) {
|
|
(parent_effect.deriveds ??= []).push(target);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (is_derived) {
|
|
derived = /** @type {Derived} */
|
|
signal;
|
|
if (check_dirtiness(derived)) {
|
|
update_derived(derived);
|
|
}
|
|
}
|
|
return signal.v;
|
|
}
|
|
function untrack(fn) {
|
|
const previous_reaction = active_reaction;
|
|
try {
|
|
active_reaction = null;
|
|
return fn();
|
|
} finally {
|
|
active_reaction = previous_reaction;
|
|
}
|
|
}
|
|
const STATUS_MASK = -7169;
|
|
function set_signal_status(signal, status) {
|
|
signal.f = signal.f & STATUS_MASK | status;
|
|
}
|
|
function push$1(props, runes = false, fn) {
|
|
component_context = {
|
|
p: component_context,
|
|
c: null,
|
|
e: null,
|
|
m: false,
|
|
s: props,
|
|
x: null,
|
|
l: null
|
|
};
|
|
}
|
|
function pop$1(component) {
|
|
const context_stack_item = component_context;
|
|
if (context_stack_item !== null) {
|
|
const component_effects = context_stack_item.e;
|
|
if (component_effects !== null) {
|
|
var previous_effect = active_effect;
|
|
var previous_reaction = active_reaction;
|
|
context_stack_item.e = null;
|
|
try {
|
|
for (var i = 0; i < component_effects.length; i++) {
|
|
var component_effect = component_effects[i];
|
|
set_active_effect(component_effect.effect);
|
|
set_active_reaction(component_effect.reaction);
|
|
effect(component_effect.fn);
|
|
}
|
|
} finally {
|
|
set_active_effect(previous_effect);
|
|
set_active_reaction(previous_reaction);
|
|
}
|
|
}
|
|
component_context = context_stack_item.p;
|
|
context_stack_item.m = true;
|
|
}
|
|
return (
|
|
/** @type {T} */
|
|
{}
|
|
);
|
|
}
|
|
function subscribe_to_store(store, run, invalidate) {
|
|
if (store == null) {
|
|
run(void 0);
|
|
if (invalidate) invalidate(void 0);
|
|
return noop;
|
|
}
|
|
const unsub = untrack(
|
|
() => store.subscribe(
|
|
run,
|
|
// @ts-expect-error
|
|
invalidate
|
|
)
|
|
);
|
|
return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
|
|
}
|
|
var current_component = null;
|
|
function getContext(key) {
|
|
const context_map = get_or_init_context_map();
|
|
const result = (
|
|
/** @type {T} */
|
|
context_map.get(key)
|
|
);
|
|
return result;
|
|
}
|
|
function setContext(key, context) {
|
|
get_or_init_context_map().set(key, context);
|
|
return context;
|
|
}
|
|
function get_or_init_context_map(name) {
|
|
if (current_component === null) {
|
|
lifecycle_outside_component();
|
|
}
|
|
return current_component.c ??= new Map(get_parent_context(current_component) || void 0);
|
|
}
|
|
function push(fn) {
|
|
current_component = { p: current_component, c: null, d: null };
|
|
}
|
|
function pop() {
|
|
var component = (
|
|
/** @type {Component} */
|
|
current_component
|
|
);
|
|
var ondestroy = component.d;
|
|
if (ondestroy) {
|
|
on_destroy.push(...ondestroy);
|
|
}
|
|
current_component = component.p;
|
|
}
|
|
function get_parent_context(component_context2) {
|
|
let parent = component_context2.p;
|
|
while (parent !== null) {
|
|
const context_map = parent.c;
|
|
if (context_map !== null) {
|
|
return context_map;
|
|
}
|
|
parent = parent.p;
|
|
}
|
|
return null;
|
|
}
|
|
const BLOCK_OPEN = `<!--${HYDRATION_START}-->`;
|
|
const BLOCK_CLOSE = `<!--${HYDRATION_END}-->`;
|
|
let on_destroy = [];
|
|
function render(component, options = {}) {
|
|
const payload = { out: "", css: /* @__PURE__ */ new Set(), head: { title: "", out: "" } };
|
|
const prev_on_destroy = on_destroy;
|
|
on_destroy = [];
|
|
payload.out += BLOCK_OPEN;
|
|
if (options.context) {
|
|
push();
|
|
current_component.c = options.context;
|
|
}
|
|
component(payload, options.props ?? {}, {}, {});
|
|
if (options.context) {
|
|
pop();
|
|
}
|
|
payload.out += BLOCK_CLOSE;
|
|
for (const cleanup of on_destroy) cleanup();
|
|
on_destroy = prev_on_destroy;
|
|
let head2 = payload.head.out + payload.head.title;
|
|
for (const { hash, code } of payload.css) {
|
|
head2 += `<style id="${hash}">${code}</style>`;
|
|
}
|
|
return {
|
|
head: head2,
|
|
html: payload.out,
|
|
body: payload.out
|
|
};
|
|
}
|
|
function head(payload, fn) {
|
|
const head_payload = payload.head;
|
|
head_payload.out += BLOCK_OPEN;
|
|
fn(head_payload);
|
|
head_payload.out += BLOCK_CLOSE;
|
|
}
|
|
function stringify(value) {
|
|
return typeof value === "string" ? value : value == null ? "" : value + "";
|
|
}
|
|
function store_get(store_values, store_name, store) {
|
|
if (store_name in store_values && store_values[store_name][0] === store) {
|
|
return store_values[store_name][2];
|
|
}
|
|
store_values[store_name]?.[1]();
|
|
store_values[store_name] = [store, null, void 0];
|
|
const unsub = subscribe_to_store(
|
|
store,
|
|
/** @param {any} v */
|
|
(v) => store_values[store_name][2] = v
|
|
);
|
|
store_values[store_name][1] = unsub;
|
|
return store_values[store_name][2];
|
|
}
|
|
function unsubscribe_stores(store_values) {
|
|
for (const store_name in store_values) {
|
|
store_values[store_name][1]();
|
|
}
|
|
}
|
|
function slot(payload, $$props, name, slot_props, fallback_fn) {
|
|
var slot_fn = $$props.$$slots?.[name];
|
|
if (slot_fn === true) {
|
|
slot_fn = $$props["children"];
|
|
}
|
|
if (slot_fn !== void 0) {
|
|
slot_fn(payload, slot_props);
|
|
} else {
|
|
fallback_fn?.();
|
|
}
|
|
}
|
|
function rest_props(props, rest) {
|
|
const rest_props2 = {};
|
|
let key;
|
|
for (key in props) {
|
|
if (!rest.includes(key)) {
|
|
rest_props2[key] = props[key];
|
|
}
|
|
}
|
|
return rest_props2;
|
|
}
|
|
function sanitize_props(props) {
|
|
const { children, $$slots, ...sanitized } = props;
|
|
return sanitized;
|
|
}
|
|
function bind_props(props_parent, props_now) {
|
|
for (const key in props_now) {
|
|
const initial_value = props_parent[key];
|
|
const value = props_now[key];
|
|
if (initial_value === void 0 && value !== void 0 && Object.getOwnPropertyDescriptor(props_parent, key)?.set) {
|
|
props_parent[key] = value;
|
|
}
|
|
}
|
|
}
|
|
function ensure_array_like(array_like_or_iterator) {
|
|
if (array_like_or_iterator) {
|
|
return array_like_or_iterator.length !== void 0 ? array_like_or_iterator : Array.from(array_like_or_iterator);
|
|
}
|
|
return [];
|
|
}
|
|
export {
|
|
current_component as $,
|
|
component_root as A,
|
|
BROWSER as B,
|
|
CLEAN as C,
|
|
DERIVED as D,
|
|
create_text as E,
|
|
branch as F,
|
|
push$1 as G,
|
|
HYDRATION_ERROR as H,
|
|
pop$1 as I,
|
|
component_context as J,
|
|
get as K,
|
|
LEGACY_PROPS as L,
|
|
MAYBE_DIRTY as M,
|
|
flush_sync as N,
|
|
render as O,
|
|
push as P,
|
|
setContext as Q,
|
|
pop as R,
|
|
noop as S,
|
|
getContext as T,
|
|
UNOWNED as U,
|
|
head as V,
|
|
fallback as W,
|
|
slot as X,
|
|
invalid_default_snippet as Y,
|
|
bind_props as Z,
|
|
stringify as _,
|
|
active_reaction as a,
|
|
store_get as a0,
|
|
unsubscribe_stores as a1,
|
|
rest_props as a2,
|
|
sanitize_props as a3,
|
|
ensure_array_like as a4,
|
|
subscribe_to_store as a5,
|
|
run_all as a6,
|
|
BLOCK_EFFECT as b,
|
|
increment_version as c,
|
|
derived_sources as d,
|
|
DIRTY as e,
|
|
set_signal_status as f,
|
|
schedule_effect as g,
|
|
active_effect as h,
|
|
is_runes as i,
|
|
BRANCH_EFFECT as j,
|
|
set_untracked_writes as k,
|
|
get_next_sibling as l,
|
|
define_property as m,
|
|
new_deps as n,
|
|
set_active_reaction as o,
|
|
set_active_effect as p,
|
|
is_array as q,
|
|
init_operations as r,
|
|
state_unsafe_mutation as s,
|
|
get_first_child as t,
|
|
untracked_writes as u,
|
|
HYDRATION_START as v,
|
|
HYDRATION_END as w,
|
|
hydration_failed as x,
|
|
clear_text_content as y,
|
|
array_from as z
|
|
};
|