@tonconnect/ui
Version:
TonConnect UI is a UI kit for TonConnect SDK. Use it to connect your app to TON wallets via TonConnect protocol.
1,641 lines (1,640 loc) • 475 kB
JavaScript
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a2, b) => {
for (var prop in b || (b = {}))
if (__hasOwnProp.call(b, prop))
__defNormalProp(a2, prop, b[prop]);
if (__getOwnPropSymbols)
for (var prop of __getOwnPropSymbols(b)) {
if (__propIsEnum.call(b, prop))
__defNormalProp(a2, prop, b[prop]);
}
return a2;
};
var __spreadProps = (a2, b) => __defProps(a2, __getOwnPropDescs(b));
var __publicField = (obj, key, value) => {
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
return value;
};
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e2) {
reject(e2);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e2) {
reject(e2);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
var _a, _b, _c, _d, _e, _f, _g, _h;
import { TonConnectError, isWalletInfoCurrentlyInjected, toUserFriendlyAddress, CHAIN, TonConnect, isTelegramUrl, encodeTelegramUrlParameters, WalletMissingRequiredFeaturesError, isWalletInfoRemote, checkRequiredWalletFeatures, isWalletInfoCurrentlyEmbedded, createVersionInfo, BrowserEventDispatcher, createResponseVersionEvent, createRequestVersionEvent, createConnectionStartedEvent, createConnectionCompletedEvent, createConnectionErrorEvent, createConnectionRestoringStartedEvent, createConnectionRestoringCompletedEvent, createConnectionRestoringErrorEvent, createDisconnectionEvent, createTransactionSentForSignatureEvent, createTransactionSignedEvent, createTransactionSigningFailedEvent, createDataSentForSignatureEvent, createDataSignedEvent, createDataSigningFailedEvent, WalletNotSupportFeatureError } from "@tonconnect/sdk";
export * from "@tonconnect/sdk";
import UAParser from "ua-parser-js";
import deepmerge from "deepmerge";
import cn from "classnames";
const sharedConfig = {};
function setHydrateContext(context) {
sharedConfig.context = context;
}
const equalFn = (a2, b) => a2 === b;
const $PROXY = Symbol("solid-proxy");
const $TRACK = Symbol("solid-track");
const signalOptions = {
equals: equalFn
};
let runEffects = runQueue;
const STALE = 1;
const PENDING = 2;
const UNOWNED = {
owned: null,
cleanups: null,
context: null,
owner: null
};
const NO_INIT = {};
var Owner = null;
let Transition$1 = null;
let Listener = null;
let Updates = null;
let Effects = null;
let ExecCount = 0;
function createRoot(fn, detachedOwner) {
const listener = Listener, owner = Owner, unowned = fn.length === 0, root = unowned ? UNOWNED : {
owned: null,
cleanups: null,
context: null,
owner: detachedOwner === void 0 ? owner : detachedOwner
}, updateFn = unowned ? fn : () => fn(() => untrack(() => cleanNode(root)));
Owner = root;
Listener = null;
try {
return runUpdates(updateFn, true);
} finally {
Listener = listener;
Owner = owner;
}
}
function createSignal(value, options) {
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
const s2 = {
value,
observers: null,
observerSlots: null,
comparator: options.equals || void 0
};
const setter = (value2) => {
if (typeof value2 === "function") {
value2 = value2(s2.value);
}
return writeSignal(s2, value2);
};
return [readSignal.bind(s2), setter];
}
function createComputed(fn, value, options) {
const c2 = createComputation(fn, value, true, STALE);
updateComputation(c2);
}
function createRenderEffect(fn, value, options) {
const c2 = createComputation(fn, value, false, STALE);
updateComputation(c2);
}
function createEffect(fn, value, options) {
runEffects = runUserEffects;
const c2 = createComputation(fn, value, false, STALE);
c2.user = true;
Effects ? Effects.push(c2) : updateComputation(c2);
}
function createMemo(fn, value, options) {
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
const c2 = createComputation(fn, value, true, 0);
c2.observers = null;
c2.observerSlots = null;
c2.comparator = options.equals || void 0;
updateComputation(c2);
return readSignal.bind(c2);
}
function createResource(pSource, pFetcher, pOptions) {
let source;
let fetcher;
let options;
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
source = true;
fetcher = pSource;
options = pFetcher || {};
} else {
source = pSource;
fetcher = pFetcher;
options = pOptions || {};
}
let pr = null, initP = NO_INIT, id = null, scheduled = false, resolved = "initialValue" in options, dynamic = typeof source === "function" && createMemo(source);
const contexts = /* @__PURE__ */ new Set(), [value, setValue] = (options.storage || createSignal)(options.initialValue), [error, setError] = createSignal(void 0), [track, trigger] = createSignal(void 0, {
equals: false
}), [state, setState] = createSignal(resolved ? "ready" : "unresolved");
if (sharedConfig.context) {
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
let v;
if (options.ssrLoadFrom === "initial")
initP = options.initialValue;
else if (sharedConfig.load && (v = sharedConfig.load(id)))
initP = v[0];
}
function loadEnd(p2, v, error2, key) {
if (pr === p2) {
pr = null;
resolved = true;
if ((p2 === initP || v === initP) && options.onHydrated)
queueMicrotask(() => options.onHydrated(key, {
value: v
}));
initP = NO_INIT;
completeLoad(v, error2);
}
return v;
}
function completeLoad(v, err) {
runUpdates(() => {
if (err === void 0)
setValue(() => v);
setState(err !== void 0 ? "errored" : "ready");
setError(err);
for (const c2 of contexts.keys())
c2.decrement();
contexts.clear();
}, false);
}
function read() {
const c2 = SuspenseContext, v = value(), err = error();
if (err !== void 0 && !pr)
throw err;
if (Listener && !Listener.user && c2) {
createComputed(() => {
track();
if (pr) {
if (c2.resolved)
;
else if (!contexts.has(c2)) {
c2.increment();
contexts.add(c2);
}
}
});
}
return v;
}
function load(refetching = true) {
if (refetching !== false && scheduled)
return;
scheduled = false;
const lookup2 = dynamic ? dynamic() : source;
if (lookup2 == null || lookup2 === false) {
loadEnd(pr, untrack(value));
return;
}
const p2 = initP !== NO_INIT ? initP : untrack(() => fetcher(lookup2, {
value: value(),
refetching
}));
if (typeof p2 !== "object" || !(p2 && "then" in p2)) {
loadEnd(pr, p2, void 0, lookup2);
return p2;
}
pr = p2;
scheduled = true;
queueMicrotask(() => scheduled = false);
runUpdates(() => {
setState(resolved ? "refreshing" : "pending");
trigger();
}, false);
return p2.then((v) => loadEnd(p2, v, void 0, lookup2), (e2) => loadEnd(p2, void 0, castError(e2), lookup2));
}
Object.defineProperties(read, {
state: {
get: () => state()
},
error: {
get: () => error()
},
loading: {
get() {
const s2 = state();
return s2 === "pending" || s2 === "refreshing";
}
},
latest: {
get() {
if (!resolved)
return read();
const err = error();
if (err && !pr)
throw err;
return value();
}
}
});
if (dynamic)
createComputed(() => load(false));
else
load(false);
return [read, {
refetch: load,
mutate: setValue
}];
}
function batch(fn) {
return runUpdates(fn, false);
}
function untrack(fn) {
if (Listener === null)
return fn();
const listener = Listener;
Listener = null;
try {
return fn();
} finally {
Listener = listener;
}
}
function on(deps, fn, options) {
const isArray = Array.isArray(deps);
let prevInput;
let defer = options && options.defer;
return (prevValue) => {
let input;
if (isArray) {
input = Array(deps.length);
for (let i2 = 0; i2 < deps.length; i2++)
input[i2] = deps[i2]();
} else
input = deps();
if (defer) {
defer = false;
return void 0;
}
const result = untrack(() => fn(input, prevInput, prevValue));
prevInput = input;
return result;
};
}
function onMount(fn) {
createEffect(() => untrack(fn));
}
function onCleanup(fn) {
if (Owner === null)
;
else if (Owner.cleanups === null)
Owner.cleanups = [fn];
else
Owner.cleanups.push(fn);
return fn;
}
function getListener() {
return Listener;
}
function getOwner() {
return Owner;
}
function createContext(defaultValue, options) {
const id = Symbol("context");
return {
id,
Provider: createProvider(id),
defaultValue
};
}
function useContext(context) {
let ctx;
return (ctx = lookup(Owner, context.id)) !== void 0 ? ctx : context.defaultValue;
}
function children(fn) {
const children2 = createMemo(fn);
const memo = createMemo(() => resolveChildren(children2()));
memo.toArray = () => {
const c2 = memo();
return Array.isArray(c2) ? c2 : c2 != null ? [c2] : [];
};
return memo;
}
let SuspenseContext;
function readSignal() {
const runningTransition = Transition$1;
if (this.sources && (this.state || runningTransition)) {
if (this.state === STALE || runningTransition)
updateComputation(this);
else {
const updates = Updates;
Updates = null;
runUpdates(() => lookUpstream(this), false);
Updates = updates;
}
}
if (Listener) {
const sSlot = this.observers ? this.observers.length : 0;
if (!Listener.sources) {
Listener.sources = [this];
Listener.sourceSlots = [sSlot];
} else {
Listener.sources.push(this);
Listener.sourceSlots.push(sSlot);
}
if (!this.observers) {
this.observers = [Listener];
this.observerSlots = [Listener.sources.length - 1];
} else {
this.observers.push(Listener);
this.observerSlots.push(Listener.sources.length - 1);
}
}
return this.value;
}
function writeSignal(node, value, isComp) {
let current = node.value;
if (!node.comparator || !node.comparator(current, value)) {
node.value = value;
if (node.observers && node.observers.length) {
runUpdates(() => {
for (let i2 = 0; i2 < node.observers.length; i2 += 1) {
const o2 = node.observers[i2];
const TransitionRunning = Transition$1 && Transition$1.running;
if (TransitionRunning && Transition$1.disposed.has(o2))
;
if (TransitionRunning && !o2.tState || !TransitionRunning && !o2.state) {
if (o2.pure)
Updates.push(o2);
else
Effects.push(o2);
if (o2.observers)
markDownstream(o2);
}
if (TransitionRunning)
;
else
o2.state = STALE;
}
if (Updates.length > 1e6) {
Updates = [];
if (false)
;
throw new Error();
}
}, false);
}
}
return value;
}
function updateComputation(node) {
if (!node.fn)
return;
cleanNode(node);
const owner = Owner, listener = Listener, time = ExecCount;
Listener = Owner = node;
runComputation(node, node.value, time);
Listener = listener;
Owner = owner;
}
function runComputation(node, value, time) {
let nextValue;
try {
nextValue = node.fn(value);
} catch (err) {
if (node.pure) {
{
node.state = STALE;
node.owned && node.owned.forEach(cleanNode);
node.owned = null;
}
}
handleError(err);
}
if (!node.updatedAt || node.updatedAt <= time) {
if (node.updatedAt != null && "observers" in node) {
writeSignal(node, nextValue);
} else
node.value = nextValue;
node.updatedAt = time;
}
}
function createComputation(fn, init, pure, state = STALE, options) {
const c2 = {
fn,
state,
updatedAt: null,
owned: null,
sources: null,
sourceSlots: null,
cleanups: null,
value: init,
owner: Owner,
context: null,
pure
};
if (Owner === null)
;
else if (Owner !== UNOWNED) {
{
if (!Owner.owned)
Owner.owned = [c2];
else
Owner.owned.push(c2);
}
}
return c2;
}
function runTop(node) {
const runningTransition = Transition$1;
if (node.state === 0 || runningTransition)
return;
if (node.state === PENDING || runningTransition)
return lookUpstream(node);
if (node.suspense && untrack(node.suspense.inFallback))
return node.suspense.effects.push(node);
const ancestors = [node];
while ((node = node.owner) && (!node.updatedAt || node.updatedAt < ExecCount)) {
if (node.state || runningTransition)
ancestors.push(node);
}
for (let i2 = ancestors.length - 1; i2 >= 0; i2--) {
node = ancestors[i2];
if (node.state === STALE || runningTransition) {
updateComputation(node);
} else if (node.state === PENDING || runningTransition) {
const updates = Updates;
Updates = null;
runUpdates(() => lookUpstream(node, ancestors[0]), false);
Updates = updates;
}
}
}
function runUpdates(fn, init) {
if (Updates)
return fn();
let wait = false;
if (!init)
Updates = [];
if (Effects)
wait = true;
else
Effects = [];
ExecCount++;
try {
const res = fn();
completeUpdates(wait);
return res;
} catch (err) {
if (!wait)
Effects = null;
Updates = null;
handleError(err);
}
}
function completeUpdates(wait) {
if (Updates) {
runQueue(Updates);
Updates = null;
}
if (wait)
return;
const e2 = Effects;
Effects = null;
if (e2.length)
runUpdates(() => runEffects(e2), false);
}
function runQueue(queue) {
for (let i2 = 0; i2 < queue.length; i2++)
runTop(queue[i2]);
}
function runUserEffects(queue) {
let i2, userLength = 0;
for (i2 = 0; i2 < queue.length; i2++) {
const e2 = queue[i2];
if (!e2.user)
runTop(e2);
else
queue[userLength++] = e2;
}
if (sharedConfig.context)
setHydrateContext();
for (i2 = 0; i2 < userLength; i2++)
runTop(queue[i2]);
}
function lookUpstream(node, ignore) {
const runningTransition = Transition$1;
node.state = 0;
for (let i2 = 0; i2 < node.sources.length; i2 += 1) {
const source = node.sources[i2];
if (source.sources) {
if (source.state === STALE || runningTransition) {
if (source !== ignore)
runTop(source);
} else if (source.state === PENDING || runningTransition)
lookUpstream(source, ignore);
}
}
}
function markDownstream(node) {
const runningTransition = Transition$1;
for (let i2 = 0; i2 < node.observers.length; i2 += 1) {
const o2 = node.observers[i2];
if (!o2.state || runningTransition) {
o2.state = PENDING;
if (o2.pure)
Updates.push(o2);
else
Effects.push(o2);
o2.observers && markDownstream(o2);
}
}
}
function cleanNode(node) {
let i2;
if (node.sources) {
while (node.sources.length) {
const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
if (obs && obs.length) {
const n2 = obs.pop(), s2 = source.observerSlots.pop();
if (index < obs.length) {
n2.sourceSlots[s2] = index;
obs[index] = n2;
source.observerSlots[index] = s2;
}
}
}
}
if (node.owned) {
for (i2 = 0; i2 < node.owned.length; i2++)
cleanNode(node.owned[i2]);
node.owned = null;
}
if (node.cleanups) {
for (i2 = 0; i2 < node.cleanups.length; i2++)
node.cleanups[i2]();
node.cleanups = null;
}
node.state = 0;
node.context = null;
}
function castError(err) {
if (err instanceof Error || typeof err === "string")
return err;
return new Error("Unknown error");
}
function handleError(err) {
err = castError(err);
throw err;
}
function lookup(owner, key) {
return owner ? owner.context && owner.context[key] !== void 0 ? owner.context[key] : lookup(owner.owner, key) : void 0;
}
function resolveChildren(children2) {
if (typeof children2 === "function" && !children2.length)
return resolveChildren(children2());
if (Array.isArray(children2)) {
const results = [];
for (let i2 = 0; i2 < children2.length; i2++) {
const result = resolveChildren(children2[i2]);
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
}
return results;
}
return children2;
}
function createProvider(id, options) {
return function provider(props) {
let res;
createRenderEffect(() => res = untrack(() => {
Owner.context = {
[id]: props.value
};
return children(() => props.children);
}), void 0);
return res;
};
}
const FALLBACK = Symbol("fallback");
function dispose(d) {
for (let i2 = 0; i2 < d.length; i2++)
d[i2]();
}
function mapArray(list, mapFn, options = {}) {
let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
onCleanup(() => dispose(disposers));
return () => {
let newItems = list() || [], i2, j;
newItems[$TRACK];
return untrack(() => {
let newLen = newItems.length, newIndices, newIndicesNext, temp, tempdisposers, tempIndexes, start, end, newEnd, item;
if (newLen === 0) {
if (len !== 0) {
dispose(disposers);
disposers = [];
items = [];
mapped = [];
len = 0;
indexes && (indexes = []);
}
if (options.fallback) {
items = [FALLBACK];
mapped[0] = createRoot((disposer) => {
disposers[0] = disposer;
return options.fallback();
});
len = 1;
}
} else if (len === 0) {
mapped = new Array(newLen);
for (j = 0; j < newLen; j++) {
items[j] = newItems[j];
mapped[j] = createRoot(mapper);
}
len = newLen;
} else {
temp = new Array(newLen);
tempdisposers = new Array(newLen);
indexes && (tempIndexes = new Array(newLen));
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++)
;
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
temp[newEnd] = mapped[end];
tempdisposers[newEnd] = disposers[end];
indexes && (tempIndexes[newEnd] = indexes[end]);
}
newIndices = /* @__PURE__ */ new Map();
newIndicesNext = new Array(newEnd + 1);
for (j = newEnd; j >= start; j--) {
item = newItems[j];
i2 = newIndices.get(item);
newIndicesNext[j] = i2 === void 0 ? -1 : i2;
newIndices.set(item, j);
}
for (i2 = start; i2 <= end; i2++) {
item = items[i2];
j = newIndices.get(item);
if (j !== void 0 && j !== -1) {
temp[j] = mapped[i2];
tempdisposers[j] = disposers[i2];
indexes && (tempIndexes[j] = indexes[i2]);
j = newIndicesNext[j];
newIndices.set(item, j);
} else
disposers[i2]();
}
for (j = start; j < newLen; j++) {
if (j in temp) {
mapped[j] = temp[j];
disposers[j] = tempdisposers[j];
if (indexes) {
indexes[j] = tempIndexes[j];
indexes[j](j);
}
} else
mapped[j] = createRoot(mapper);
}
mapped = mapped.slice(0, len = newLen);
items = newItems.slice(0);
}
return mapped;
});
function mapper(disposer) {
disposers[j] = disposer;
if (indexes) {
const [s2, set] = createSignal(j);
indexes[j] = set;
return mapFn(newItems[j], s2);
}
return mapFn(newItems[j]);
}
};
}
function createComponent(Comp, props) {
return untrack(() => Comp(props || {}));
}
function trueFn() {
return true;
}
const propTraps = {
get(_, property, receiver) {
if (property === $PROXY)
return receiver;
return _.get(property);
},
has(_, property) {
if (property === $PROXY)
return true;
return _.has(property);
},
set: trueFn,
deleteProperty: trueFn,
getOwnPropertyDescriptor(_, property) {
return {
configurable: true,
enumerable: true,
get() {
return _.get(property);
},
set: trueFn,
deleteProperty: trueFn
};
},
ownKeys(_) {
return _.keys();
}
};
function resolveSource(s2) {
return !(s2 = typeof s2 === "function" ? s2() : s2) ? {} : s2;
}
function mergeProps(...sources) {
let proxy = false;
for (let i2 = 0; i2 < sources.length; i2++) {
const s2 = sources[i2];
proxy = proxy || !!s2 && $PROXY in s2;
sources[i2] = typeof s2 === "function" ? (proxy = true, createMemo(s2)) : s2;
}
if (proxy) {
return new Proxy({
get(property) {
for (let i2 = sources.length - 1; i2 >= 0; i2--) {
const v = resolveSource(sources[i2])[property];
if (v !== void 0)
return v;
}
},
has(property) {
for (let i2 = sources.length - 1; i2 >= 0; i2--) {
if (property in resolveSource(sources[i2]))
return true;
}
return false;
},
keys() {
const keys = [];
for (let i2 = 0; i2 < sources.length; i2++)
keys.push(...Object.keys(resolveSource(sources[i2])));
return [...new Set(keys)];
}
}, propTraps);
}
const target = {};
for (let i2 = sources.length - 1; i2 >= 0; i2--) {
if (sources[i2]) {
const descriptors = Object.getOwnPropertyDescriptors(sources[i2]);
for (const key in descriptors) {
if (key in target)
continue;
Object.defineProperty(target, key, {
enumerable: true,
get() {
for (let i3 = sources.length - 1; i3 >= 0; i3--) {
const v = (sources[i3] || {})[key];
if (v !== void 0)
return v;
}
}
});
}
}
}
return target;
}
function splitProps(props, ...keys) {
const blocked = new Set(keys.flat());
if ($PROXY in props) {
const res = keys.map((k) => {
return new Proxy({
get(property) {
return k.includes(property) ? props[property] : void 0;
},
has(property) {
return k.includes(property) && property in props;
},
keys() {
return k.filter((property) => property in props);
}
}, propTraps);
});
res.push(new Proxy({
get(property) {
return blocked.has(property) ? void 0 : props[property];
},
has(property) {
return blocked.has(property) ? false : property in props;
},
keys() {
return Object.keys(props).filter((k) => !blocked.has(k));
}
}, propTraps));
return res;
}
const descriptors = Object.getOwnPropertyDescriptors(props);
keys.push(Object.keys(descriptors).filter((k) => !blocked.has(k)));
return keys.map((k) => {
const clone = {};
for (let i2 = 0; i2 < k.length; i2++) {
const key = k[i2];
if (!(key in props))
continue;
Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
get() {
return props[key];
},
set() {
return true;
},
enumerable: true
});
}
return clone;
});
}
function For(props) {
const fallback = "fallback" in props && {
fallback: () => props.fallback
};
return createMemo(mapArray(() => props.each, props.children, fallback || void 0));
}
function Show(props) {
let strictEqual = false;
const keyed = props.keyed;
const condition = createMemo(() => props.when, void 0, {
equals: (a2, b) => strictEqual ? a2 === b : !a2 === !b
});
return createMemo(() => {
const c2 = condition();
if (c2) {
const child = props.children;
const fn = typeof child === "function" && child.length > 0;
strictEqual = keyed || fn;
return fn ? untrack(() => child(c2)) : child;
}
return props.fallback;
}, void 0, void 0);
}
function Switch(props) {
let strictEqual = false;
let keyed = false;
const equals = (a2, b) => a2[0] === b[0] && (strictEqual ? a2[1] === b[1] : !a2[1] === !b[1]) && a2[2] === b[2];
const conditions = children(() => props.children), evalConditions = createMemo(() => {
let conds = conditions();
if (!Array.isArray(conds))
conds = [conds];
for (let i2 = 0; i2 < conds.length; i2++) {
const c2 = conds[i2].when;
if (c2) {
keyed = !!conds[i2].keyed;
return [i2, c2, conds[i2]];
}
}
return [-1];
}, void 0, {
equals
});
return createMemo(() => {
const [index, when, cond] = evalConditions();
if (index < 0)
return props.fallback;
const c2 = cond.children;
const fn = typeof c2 === "function" && c2.length > 0;
strictEqual = keyed || fn;
return fn ? untrack(() => c2(when)) : c2;
}, void 0, void 0);
}
function Match(props) {
return props;
}
const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
const Properties = /* @__PURE__ */ new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
const ChildProperties = /* @__PURE__ */ new Set(["innerHTML", "textContent", "innerText", "children"]);
const Aliases = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
className: "class",
htmlFor: "for"
});
const PropAliases = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
class: "className",
formnovalidate: "formNoValidate",
ismap: "isMap",
nomodule: "noModule",
playsinline: "playsInline",
readonly: "readOnly"
});
const DelegatedEvents = /* @__PURE__ */ new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
const SVGElements = /* @__PURE__ */ new Set([
"altGlyph",
"altGlyphDef",
"altGlyphItem",
"animate",
"animateColor",
"animateMotion",
"animateTransform",
"circle",
"clipPath",
"color-profile",
"cursor",
"defs",
"desc",
"ellipse",
"feBlend",
"feColorMatrix",
"feComponentTransfer",
"feComposite",
"feConvolveMatrix",
"feDiffuseLighting",
"feDisplacementMap",
"feDistantLight",
"feFlood",
"feFuncA",
"feFuncB",
"feFuncG",
"feFuncR",
"feGaussianBlur",
"feImage",
"feMerge",
"feMergeNode",
"feMorphology",
"feOffset",
"fePointLight",
"feSpecularLighting",
"feSpotLight",
"feTile",
"feTurbulence",
"filter",
"font",
"font-face",
"font-face-format",
"font-face-name",
"font-face-src",
"font-face-uri",
"foreignObject",
"g",
"glyph",
"glyphRef",
"hkern",
"image",
"line",
"linearGradient",
"marker",
"mask",
"metadata",
"missing-glyph",
"mpath",
"path",
"pattern",
"polygon",
"polyline",
"radialGradient",
"rect",
"set",
"stop",
"svg",
"switch",
"symbol",
"text",
"textPath",
"tref",
"tspan",
"use",
"view",
"vkern"
]);
const SVGNamespace = {
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace"
};
function reconcileArrays(parentNode, a2, b) {
let bLength = b.length, aEnd = a2.length, bEnd = bLength, aStart = 0, bStart = 0, after = a2[aEnd - 1].nextSibling, map = null;
while (aStart < aEnd || bStart < bEnd) {
if (a2[aStart] === b[bStart]) {
aStart++;
bStart++;
continue;
}
while (a2[aEnd - 1] === b[bEnd - 1]) {
aEnd--;
bEnd--;
}
if (aEnd === aStart) {
const node = bEnd < bLength ? bStart ? b[bStart - 1].nextSibling : b[bEnd - bStart] : after;
while (bStart < bEnd)
parentNode.insertBefore(b[bStart++], node);
} else if (bEnd === bStart) {
while (aStart < aEnd) {
if (!map || !map.has(a2[aStart]))
a2[aStart].remove();
aStart++;
}
} else if (a2[aStart] === b[bEnd - 1] && b[bStart] === a2[aEnd - 1]) {
const node = a2[--aEnd].nextSibling;
parentNode.insertBefore(b[bStart++], a2[aStart++].nextSibling);
parentNode.insertBefore(b[--bEnd], node);
a2[aEnd] = b[bEnd];
} else {
if (!map) {
map = /* @__PURE__ */ new Map();
let i2 = bStart;
while (i2 < bEnd)
map.set(b[i2], i2++);
}
const index = map.get(a2[aStart]);
if (index != null) {
if (bStart < index && index < bEnd) {
let i2 = aStart, sequence = 1, t2;
while (++i2 < aEnd && i2 < bEnd) {
if ((t2 = map.get(a2[i2])) == null || t2 !== index + sequence)
break;
sequence++;
}
if (sequence > index - bStart) {
const node = a2[aStart];
while (bStart < index)
parentNode.insertBefore(b[bStart++], node);
} else
parentNode.replaceChild(b[bStart++], a2[aStart++]);
} else
aStart++;
} else
a2[aStart++].remove();
}
}
}
const $$EVENTS = "_$DX_DELEGATE";
function render(code, element, init, options = {}) {
let disposer;
createRoot((dispose2) => {
disposer = dispose2;
element === document ? code() : insert(element, code(), element.firstChild ? null : void 0, init);
}, options.owner);
return () => {
disposer();
element.textContent = "";
};
}
function template$1(html, check, isSVG) {
if (typeof window === 'undefined') {
return null;
}
const t2 = document.createElement("template");
t2.innerHTML = html;
let node = t2.content.firstChild;
if (isSVG)
node = node.firstChild;
return node;
}
function delegateEvents(eventNames, document2 = window.document) {
const e2 = document2[$$EVENTS] || (document2[$$EVENTS] = /* @__PURE__ */ new Set());
for (let i2 = 0, l2 = eventNames.length; i2 < l2; i2++) {
const name = eventNames[i2];
if (!e2.has(name)) {
e2.add(name);
document2.addEventListener(name, eventHandler);
}
}
}
function setAttribute(node, name, value) {
if (value == null)
node.removeAttribute(name);
else
node.setAttribute(name, value);
}
function setAttributeNS(node, namespace, name, value) {
if (value == null)
node.removeAttributeNS(namespace, name);
else
node.setAttributeNS(namespace, name, value);
}
function className(node, value) {
if (value == null)
node.removeAttribute("class");
else
node.className = value;
}
function addEventListener(node, name, handler, delegate) {
if (delegate) {
if (Array.isArray(handler)) {
node[`$$${name}`] = handler[0];
node[`$$${name}Data`] = handler[1];
} else
node[`$$${name}`] = handler;
} else if (Array.isArray(handler)) {
const handlerFn = handler[0];
node.addEventListener(name, handler[0] = (e2) => handlerFn.call(node, handler[1], e2));
} else
node.addEventListener(name, handler);
}
function classList(node, value, prev = {}) {
const classKeys = Object.keys(value || {}), prevKeys = Object.keys(prev);
let i2, len;
for (i2 = 0, len = prevKeys.length; i2 < len; i2++) {
const key = prevKeys[i2];
if (!key || key === "undefined" || value[key])
continue;
toggleClassKey(node, key, false);
delete prev[key];
}
for (i2 = 0, len = classKeys.length; i2 < len; i2++) {
const key = classKeys[i2], classValue = !!value[key];
if (!key || key === "undefined" || prev[key] === classValue || !classValue)
continue;
toggleClassKey(node, key, true);
prev[key] = classValue;
}
return prev;
}
function style(node, value, prev) {
if (!value)
return prev ? setAttribute(node, "style") : value;
const nodeStyle = node.style;
if (typeof value === "string")
return nodeStyle.cssText = value;
typeof prev === "string" && (nodeStyle.cssText = prev = void 0);
prev || (prev = {});
value || (value = {});
let v, s2;
for (s2 in prev) {
value[s2] == null && nodeStyle.removeProperty(s2);
delete prev[s2];
}
for (s2 in value) {
v = value[s2];
if (v !== prev[s2]) {
nodeStyle.setProperty(s2, v);
prev[s2] = v;
}
}
return prev;
}
function spread(node, props = {}, isSVG, skipChildren) {
const prevProps = {};
if (!skipChildren) {
createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
}
createRenderEffect(() => props.ref && props.ref(node));
createRenderEffect(() => assign(node, props, isSVG, true, prevProps, true));
return prevProps;
}
function use(fn, element, arg) {
return untrack(() => fn(element, arg));
}
function insert(parent, accessor, marker, initial) {
if (marker !== void 0 && !initial)
initial = [];
if (typeof accessor !== "function")
return insertExpression(parent, accessor, initial, marker);
createRenderEffect((current) => insertExpression(parent, accessor(), current, marker), initial);
}
function assign(node, props, isSVG, skipChildren, prevProps = {}, skipRef = false) {
props || (props = {});
for (const prop in prevProps) {
if (!(prop in props)) {
if (prop === "children")
continue;
prevProps[prop] = assignProp(node, prop, null, prevProps[prop], isSVG, skipRef);
}
}
for (const prop in props) {
if (prop === "children") {
if (!skipChildren)
insertExpression(node, props.children);
continue;
}
const value = props[prop];
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef);
}
}
function getNextElement(template2) {
let node, key;
if (!sharedConfig.context || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
return template2.cloneNode(true);
}
if (sharedConfig.completed)
sharedConfig.completed.add(node);
sharedConfig.registry.delete(key);
return node;
}
function toPropertyName(name) {
return name.toLowerCase().replace(/-([a-z])/g, (_, w) => w.toUpperCase());
}
function toggleClassKey(node, key, value) {
const classNames = key.trim().split(/\s+/);
for (let i2 = 0, nameLen = classNames.length; i2 < nameLen; i2++)
node.classList.toggle(classNames[i2], value);
}
function assignProp(node, prop, value, prev, isSVG, skipRef) {
let isCE, isProp, isChildProp;
if (prop === "style")
return style(node, value, prev);
if (prop === "classList")
return classList(node, value, prev);
if (value === prev)
return prev;
if (prop === "ref") {
if (!skipRef)
value(node);
} else if (prop.slice(0, 3) === "on:") {
const e2 = prop.slice(3);
prev && node.removeEventListener(e2, prev);
value && node.addEventListener(e2, value);
} else if (prop.slice(0, 10) === "oncapture:") {
const e2 = prop.slice(10);
prev && node.removeEventListener(e2, prev, true);
value && node.addEventListener(e2, value, true);
} else if (prop.slice(0, 2) === "on") {
const name = prop.slice(2).toLowerCase();
const delegate = DelegatedEvents.has(name);
if (!delegate && prev) {
const h2 = Array.isArray(prev) ? prev[0] : prev;
node.removeEventListener(name, h2);
}
if (delegate || value) {
addEventListener(node, name, value, delegate);
delegate && delegateEvents([name]);
}
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
if (prop === "class" || prop === "className")
className(node, value);
else if (isCE && !isProp && !isChildProp)
node[toPropertyName(prop)] = value;
else
node[PropAliases[prop] || prop] = value;
} else {
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
if (ns)
setAttributeNS(node, ns, prop, value);
else
setAttribute(node, Aliases[prop] || prop, value);
}
return value;
}
function eventHandler(e2) {
const key = `$$${e2.type}`;
let node = e2.composedPath && e2.composedPath()[0] || e2.target;
if (e2.target !== node) {
Object.defineProperty(e2, "target", {
configurable: true,
value: node
});
}
Object.defineProperty(e2, "currentTarget", {
configurable: true,
get() {
return node || document;
}
});
if (sharedConfig.registry && !sharedConfig.done) {
sharedConfig.done = true;
document.querySelectorAll("[id^=pl-]").forEach((elem) => {
while (elem && elem.nodeType !== 8 && elem.nodeValue !== "pl-" + e2) {
let x = elem.nextSibling;
elem.remove();
elem = x;
}
elem && elem.remove();
});
}
while (node) {
const handler = node[key];
if (handler && !node.disabled) {
const data = node[`${key}Data`];
data !== void 0 ? handler.call(node, data, e2) : handler.call(node, e2);
if (e2.cancelBubble)
return;
}
node = node._$host || node.parentNode || node.host;
}
}
function insertExpression(parent, value, current, marker, unwrapArray) {
if (sharedConfig.context && !current)
current = [...parent.childNodes];
while (typeof current === "function")
current = current();
if (value === current)
return current;
const t2 = typeof value, multi = marker !== void 0;
parent = multi && current[0] && current[0].parentNode || parent;
if (t2 === "string" || t2 === "number") {
if (sharedConfig.context)
return current;
if (t2 === "number")
value = value.toString();
if (multi) {
let node = current[0];
if (node && node.nodeType === 3) {
node.data = value;
} else
node = document.createTextNode(value);
current = cleanChildren(parent, current, marker, node);
} else {
if (current !== "" && typeof current === "string") {
current = parent.firstChild.data = value;
} else
current = parent.textContent = value;
}
} else if (value == null || t2 === "boolean") {
if (sharedConfig.context)
return current;
current = cleanChildren(parent, current, marker);
} else if (t2 === "function") {
createRenderEffect(() => {
let v = value();
while (typeof v === "function")
v = v();
current = insertExpression(parent, v, current, marker);
});
return () => current;
} else if (Array.isArray(value)) {
const array = [];
const currentArray = current && Array.isArray(current);
if (normalizeIncomingArray(array, value, current, unwrapArray)) {
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
return () => current;
}
if (sharedConfig.context) {
if (!array.length)
return current;
for (let i2 = 0; i2 < array.length; i2++) {
if (array[i2].parentNode)
return current = array;
}
}
if (array.length === 0) {
current = cleanChildren(parent, current, marker);
if (multi)
return current;
} else if (currentArray) {
if (current.length === 0) {
appendNodes(parent, array, marker);
} else
reconcileArrays(parent, current, array);
} else {
current && cleanChildren(parent);
appendNodes(parent, array);
}
current = array;
} else if (value instanceof Node) {
if (sharedConfig.context && value.parentNode)
return current = multi ? [value] : value;
if (Array.isArray(current)) {
if (multi)
return current = cleanChildren(parent, current, marker, value);
cleanChildren(parent, current, null, value);
} else if (current == null || current === "" || !parent.firstChild) {
parent.appendChild(value);
} else
parent.replaceChild(value, parent.firstChild);
current = value;
} else
;
return current;
}
function normalizeIncomingArray(normalized, array, current, unwrap2) {
let dynamic = false;
for (let i2 = 0, len = array.length; i2 < len; i2++) {
let item = array[i2], prev = current && current[i2];
if (item instanceof Node) {
normalized.push(item);
} else if (item == null || item === true || item === false)
;
else if (Array.isArray(item)) {
dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
} else if (typeof item === "function") {
if (unwrap2) {
while (typeof item === "function")
item = item();
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item], Array.isArray(prev) ? prev : [prev]) || dynamic;
} else {
normalized.push(item);
dynamic = true;
}
} else {
const value = String(item);
if (prev && prev.nodeType === 3 && prev.data === value) {
normalized.push(prev);
} else
normalized.push(document.createTextNode(value));
}
}
return dynamic;
}
function appendNodes(parent, array, marker = null) {
for (let i2 = 0, len = array.length; i2 < len; i2++)
parent.insertBefore(array[i2], marker);
}
function cleanChildren(parent, current, marker, replacement) {
if (marker === void 0)
return parent.textContent = "";
const node = replacement || document.createTextNode("");
if (current.length) {
let inserted = false;
for (let i2 = current.length - 1; i2 >= 0; i2--) {
const el = current[i2];
if (node !== el) {
const isParent = el.parentNode === parent;
if (!inserted && !i2)
isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);
else
isParent && el.remove();
} else
inserted = true;
}
} else
parent.insertBefore(node, marker);
return [node];
}
function getHydrationKey() {
const hydrate = sharedConfig.context;
return `${hydrate.id}${hydrate.count++}`;
}
const SVG_NAMESPACE = "http://www.w3.org/2000/svg";
function createElement(tagName, isSVG = false) {
return isSVG ? document.createElementNS(SVG_NAMESPACE, tagName) : document.createElement(tagName);
}
function Portal(props) {
const {
useShadow
} = props, marker = document.createTextNode(""), mount = props.mount || document.body;
function renderPortal() {
if (sharedConfig.context) {
const [s2, set] = createSignal(false);
queueMicrotask(() => set(true));
return () => s2() && props.children;
} else
return () => props.children;
}
if (mount instanceof HTMLHeadElement) {
const [clean, setClean] = createSignal(false);
const cleanup = () => setClean(true);
createRoot((dispose2) => insert(mount, () => !clean() ? renderPortal()() : dispose2(), null));
onCleanup(() => {
if (sharedConfig.context)
queueMicrotask(cleanup);
else
cleanup();
});
} else {
const container = createElement(props.isSVG ? "g" : "div", props.isSVG), renderRoot = useShadow && container.attachShadow ? container.attachShadow({
mode: "open"
}) : container;
Object.defineProperty(container, "_$host", {
get() {
return marker.parentNode;
},
configurable: true
});
insert(renderRoot, renderPortal());
mount.appendChild(container);
props.ref && props.ref(container);
onCleanup(() => mount.removeChild(container));
}
return marker;
}
function Dynamic(props) {
const [p2, others] = splitProps(props, ["component"]);
const cached = createMemo(() => p2.component);
return createMemo(() => {
const component = cached();
switch (typeof component) {
case "function":
return untrack(() => component(others));
case "string":
const isSvg = SVGElements.has(component);
const el = sharedConfig.context ? getNextElement() : createElement(component, isSvg);
spread(el, others, isSvg);
return el;
}
});
}
var THEME = /* @__PURE__ */ ((THEME2) => {
THEME2["DARK"] = "DARK";
THEME2["LIGHT"] = "LIGHT";
return THEME2;
})(THEME || {});
let e = { data: "" }, t = (t2) => "object" == typeof window ? ((t2 ? t2.querySelector("#_goober") : window._goober) || Object.assign((t2 || document.head).appendChild(document.createElement("style")), { innerHTML: " ", id: "_goober" })).firstChild : t2 || e, l = /(?:([\u0080-\uFFFF\w-%@]+) *:? *([^{;]+?);|([^;}{]*?) *{)|(}\s*)/g, a = /\/\*[^]*?\*\/| +/g, n = /\n+/g, o = (e2, t2) => {
let r = "", l2 = "", a2 = "";
for (let n2 in e2) {
let c2 = e2[n2];
"@" == n2[0] ? "i" == n2[1] ? r = n2 + " " + c2 + ";" : l2 += "f" == n2[1] ? o(c2, n2) : n2 + "{" + o(c2, "k" == n2[1] ? "" : t2) + "}" : "object" == typeof c2 ? l2 += o(c2, t2 ? t2.replace(/([^,])+/g, (e3) => n2.replace(/(^:.*)|([^,])+/g, (t3) => /&/.test(t3) ? t3.replace(/&/g, e3) : e3 ? e3 + " " + t3 : t3)) : n2) : null != c2 && (n2 = /^--/.test(n2) ? n2 : n2.replace(/[A-Z]/g, "-$&").toLowerCase(), a2 += o.p ? o.p(n2, c2) : n2 + ":" + c2 + ";");
}
return r + (t2 && a2 ? t2 + "{" + a2 + "}" : a2) + l2;
}, c = {}, s = (e2) => {
if ("object" == typeof e2) {
let t2 = "";
for (let r in e2)
t2 += r + s(e2[r]);
return t2;
}
return e2;
}, i = (e2, t2, r, i2, p2) => {
let u2 = s(e2), d = c[u2] || (c[u2] = ((e3) => {
let t3 = 0, r2 = 11;
for (; t3 < e3.length; )
r2 = 101 * r2 + e3.charCodeAt(t3++) >>> 0;
return "go" + r2;
})(u2));
if (!c[d]) {
let t3 = u2 !== e2 ? e2 : ((e3) => {
let t4, r2, o2 = [{}];
for (; t4 = l.exec(e3.replace(a, "")); )
t4[4] ? o2.shift() : t4[3] ? (r2 = t4[3].replace(n, " ").trim(), o2.unshift(o2[0][r2] = o2[0][r2] || {})) : o2[0][t4[1]] = t4[2].replace(n, " ").trim();
return o2[0];
})(e2);
c[d] = o(p2 ? { ["@keyframes " + d]: t3 } : t3, r ? "" : "." + d);
}
let f = r && c.g ? c.g : null;
return r && (c.g = c[d]), ((e3, t3, r2, l2) => {
l2 ? t3.data = t3.data.replace(l2, e3) : -1 === t3.data.indexOf(e3) && (t3.data = r2 ? e3 + t3.data : t3.data + e3);
})(c[d], t2, i2, f), d;
}, p = (e2, t2, r) => e2.reduce((e3, l2, a2) => {
let n2 = t2[a2];
if (n2 && n2.call) {
let e4 = n2(r), t3 = e4 && e4.props && e4.props.className || /^go/.test(e4) && e4;
n2 = t3 ? "." + t3 : e4 && "object" == typeof e4 ? e4.props ? "" : o(e4, "") : false === e4 ? "" : e4;
}
return e3 + l2 + (null == n2 ? "" : n2);
}, "");
function u(e2) {
let r = this || {}, l2 = e2.call ? e2(r.p) : e2;
return i(l2.unshift ? l2.raw ? p(l2, [].slice.call(arguments, 1), r.p) : l2.reduce((e3, t2) => Object.assign(e3, t2 && t2.call ? t2(r.p) : t2), {}) : l2, t(r.target), r.g, r.o, r.k);
}
u.bind({ g: 1 });
let h = u.bind({ k: 1 });
const ThemeContext = createContext();
function ThemeProvider(props) {
return createComponent(ThemeContext.Provider, {
value: props.theme,
get children() {
return props.children;
}
});
}
function useTheme() {
return useContext(ThemeContext);
}
function makeStyled(tag) {
let _ctx = this || {};
return (...args) => {
const Styled = (props) => {
const theme = useContext(ThemeContext);
const withTheme = mergeProps(props, { theme });
const clone = mergeProps(withTheme, {
get class() {
const pClass = withTheme.class, append = "class" in withTheme && /^go[0-9]+/.test(pClass);
let className2 = u.apply(
{ target: _ctx.target, o: append, p: withTheme, g: _ctx.g },
args
);
return [pClass, className2].filter(Boolean).join(" ");
}
});
const [local, newProps] = splitProps(clone, ["as", "theme"]);
const htmlProps = newProps;
const createTag = local.as || tag;
let el;
if (typeof createTag === "function") {
el = createTag(htmlProps);
} else {
{
if (_ctx.g == 1) {
el = document.createElement(createTag);
spread(el, htmlProps);
} else {
el = Dynamic(mergeProps({ component: createTag }, htmlProps));
}
}
}
return el;
};
Styled.class = (props) => {
return untrack(() => {
return u.apply({ target: _ctx.target, p: props, g: _ctx.g }, args);
});
};
return Styled;
};
}
const styled = new Proxy(makeStyled, {
get(target, tag) {
return target(tag);
}
});
function createGlobalStyles() {
const fn = makeStyled.call({ g: 1 }, "div").apply(null, arguments);
return function GlobalStyles2(props) {
fn(props);
return null;
};
}
const globalStylesTag = "tc-root";
const disableScrollClass = "tc-disable-scroll";
const usingMouseClass = "tc-using-mouse";
const GlobalStyles = (