188 lines
6.5 KiB
JavaScript
188 lines
6.5 KiB
JavaScript
import { _r as store_invalid_shape, gr as snippet_without_render_tag, nn as dynamic_void_element_content, tr as has_own_property, vr as svelte_element_invalid_this_value } from "./runtime-DInTlc-h.js";
|
||
import { _ as is_void, b as escape_html } from "./utils-BWzPBw9Y.js";
|
||
// node_modules/clsx/dist/clsx.mjs
|
||
function r(e) {
|
||
var t, f, n = "";
|
||
if ("string" == typeof e || "number" == typeof e) n += e;
|
||
else if ("object" == typeof e) if (Array.isArray(e)) {
|
||
var o = e.length;
|
||
for (t = 0; t < o; t++) e[t] && (f = r(e[t])) && (n && (n += " "), n += f);
|
||
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
||
return n;
|
||
}
|
||
function clsx$1() {
|
||
for (var e, t, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t = r(e)) && (n && (n += " "), n += t);
|
||
return n;
|
||
}
|
||
// node_modules/svelte/src/internal/shared/attributes.js
|
||
/**
|
||
* `<div translate={false}>` should be rendered as `<div translate="no">` and _not_
|
||
* `<div translate="false">`, which is equivalent to `<div translate="yes">`. There
|
||
* may be other odd cases that need to be added to this list in future
|
||
* @type {Record<string, Map<any, string>>}
|
||
*/
|
||
var replacements = { translate: /* @__PURE__ */ new Map([[true, "yes"], [false, "no"]]) };
|
||
/**
|
||
* @template V
|
||
* @param {string} name
|
||
* @param {V} value
|
||
* @param {boolean} [is_boolean]
|
||
* @returns {string}
|
||
*/
|
||
function attr(name, value, is_boolean = false) {
|
||
if (name === "hidden" && value !== "until-found") is_boolean = true;
|
||
if (value == null || is_boolean && !value && value !== "") return "";
|
||
const normalized = has_own_property.call(replacements, name) && replacements[name].get(value) || value;
|
||
return ` ${name}${is_boolean ? `=""` : `="${escape_html(normalized, true)}"`}`;
|
||
}
|
||
/**
|
||
* Small wrapper around clsx to preserve Svelte's (weird) handling of falsy values.
|
||
* TODO Svelte 6 revisit this, and likely turn all falsy values into the empty string (what clsx also does)
|
||
* @param {any} value
|
||
*/
|
||
function clsx(value) {
|
||
if (typeof value === "object") return clsx$1(value);
|
||
else return value ?? "";
|
||
}
|
||
var whitespace = [..." \n\r\f\xA0\v"];
|
||
/**
|
||
* @param {any} value
|
||
* @param {string | null} [hash]
|
||
* @param {Record<string, boolean>} [directives]
|
||
* @returns {string | null}
|
||
*/
|
||
function to_class(value, hash, directives) {
|
||
var classname = value == null ? "" : "" + value;
|
||
if (hash) classname = classname ? classname + " " + hash : hash;
|
||
if (directives) {
|
||
for (var key of Object.keys(directives)) if (directives[key]) classname = classname ? classname + " " + key : key;
|
||
else if (classname.length) {
|
||
var len = key.length;
|
||
var a = 0;
|
||
while ((a = classname.indexOf(key, a)) >= 0) {
|
||
var b = a + len;
|
||
if ((a === 0 || whitespace.includes(classname[a - 1])) && (b === classname.length || whitespace.includes(classname[b]))) classname = (a === 0 ? "" : classname.substring(0, a)) + classname.substring(b + 1);
|
||
else a = b;
|
||
}
|
||
}
|
||
}
|
||
return classname === "" ? null : classname;
|
||
}
|
||
/**
|
||
*
|
||
* @param {Record<string,any>} styles
|
||
* @param {boolean} important
|
||
*/
|
||
function append_styles(styles, important = false) {
|
||
var separator = important ? " !important;" : ";";
|
||
var css = "";
|
||
for (var key of Object.keys(styles)) {
|
||
var value = styles[key];
|
||
if (value != null && value !== "") css += " " + key + ": " + value + separator;
|
||
}
|
||
return css;
|
||
}
|
||
/**
|
||
* @param {string} name
|
||
* @returns {string}
|
||
*/
|
||
function to_css_name(name) {
|
||
if (name[0] !== "-" || name[1] !== "-") return name.toLowerCase();
|
||
return name;
|
||
}
|
||
/**
|
||
* @param {any} value
|
||
* @param {Record<string, any> | [Record<string, any>, Record<string, any>]} [styles]
|
||
* @returns {string | null}
|
||
*/
|
||
function to_style(value, styles) {
|
||
if (styles) {
|
||
var new_style = "";
|
||
/** @type {Record<string,any> | undefined} */
|
||
var normal_styles;
|
||
/** @type {Record<string,any> | undefined} */
|
||
var important_styles;
|
||
if (Array.isArray(styles)) {
|
||
normal_styles = styles[0];
|
||
important_styles = styles[1];
|
||
} else normal_styles = styles;
|
||
if (value) {
|
||
value = String(value).replaceAll(/\/\*.*?\*\//g, "").trim();
|
||
/** @type {boolean | '"' | "'"} */
|
||
var in_str = false;
|
||
var in_apo = 0;
|
||
var in_comment = false;
|
||
var reserved_names = [];
|
||
if (normal_styles) reserved_names.push(...Object.keys(normal_styles).map(to_css_name));
|
||
if (important_styles) reserved_names.push(...Object.keys(important_styles).map(to_css_name));
|
||
var start_index = 0;
|
||
var name_index = -1;
|
||
const len = value.length;
|
||
for (var i = 0; i < len; i++) {
|
||
var c = value[i];
|
||
if (in_comment) {
|
||
if (c === "/" && value[i - 1] === "*") in_comment = false;
|
||
} else if (in_str) {
|
||
if (in_str === c) in_str = false;
|
||
} else if (c === "/" && value[i + 1] === "*") in_comment = true;
|
||
else if (c === "\"" || c === "'") in_str = c;
|
||
else if (c === "(") in_apo++;
|
||
else if (c === ")") in_apo--;
|
||
if (!in_comment && in_str === false && in_apo === 0) {
|
||
if (c === ":" && name_index === -1) name_index = i;
|
||
else if (c === ";" || i === len - 1) {
|
||
if (name_index !== -1) {
|
||
var name = to_css_name(value.substring(start_index, name_index).trim());
|
||
if (!reserved_names.includes(name)) {
|
||
if (c !== ";") i++;
|
||
var property = value.substring(start_index, i).trim();
|
||
new_style += " " + property + ";";
|
||
}
|
||
}
|
||
start_index = i + 1;
|
||
name_index = -1;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
if (normal_styles) new_style += append_styles(normal_styles);
|
||
if (important_styles) new_style += append_styles(important_styles, true);
|
||
new_style = new_style.trim();
|
||
return new_style === "" ? null : new_style;
|
||
}
|
||
return value == null ? null : String(value);
|
||
}
|
||
// node_modules/svelte/src/internal/shared/validate.js
|
||
/**
|
||
* @param {() => string} tag_fn
|
||
* @returns {void}
|
||
*/
|
||
function validate_void_dynamic_element(tag_fn) {
|
||
const tag = tag_fn();
|
||
if (tag && is_void(tag)) dynamic_void_element_content(tag);
|
||
}
|
||
/** @param {() => unknown} tag_fn */
|
||
function validate_dynamic_element_tag(tag_fn) {
|
||
const tag = tag_fn();
|
||
if (tag && !(typeof tag === "string")) svelte_element_invalid_this_value();
|
||
}
|
||
/**
|
||
* @param {any} store
|
||
* @param {string} name
|
||
*/
|
||
function validate_store(store, name) {
|
||
if (store != null && typeof store.subscribe !== "function") store_invalid_shape(name);
|
||
}
|
||
/**
|
||
* @template {(...args: any[]) => unknown} T
|
||
* @param {T} fn
|
||
*/
|
||
function prevent_snippet_stringification(fn) {
|
||
fn.toString = () => {
|
||
snippet_without_render_tag();
|
||
return "";
|
||
};
|
||
return fn;
|
||
}
|
||
export { attr as a, to_style as c, validate_void_dynamic_element as i, validate_dynamic_element_tag as n, clsx as o, validate_store as r, to_class as s, prevent_snippet_stringification as t };
|