// ==UserScript==
// @name Boluo Attribute Extension
// @namespace https://boluo.chat
// @version 0.1.3
// @author AutumnSaury
// @description 菠萝角色属性扩展
// @icon https://www.google.com/s2/favicons?sz=64&domain=boluo.chat
// @license Apache-2.0
// @homepageURL https://github.com/AutumnSaury/boluo-attribute-extension
// @match https://old.boluo.chat/chat/*
// @grant GM.getValue
// @grant GM.setValue
// @grant GM_addStyle
// @grant GM_addValueChangeListener
// ==/UserScript==
(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const e=document.createElement("style");e.textContent=t,document.head.append(e)})(` *,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::-moz-placeholder,textarea::-moz-placeholder{opacity:1;color:#9ca3af}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]:where(:not([hidden=until-found])){display:none}.tab-center{width:100%}.tab-center :is(th,td){text-align:center}.slim-webkit-scroll{overflow-y:auto}.slim-webkit-scroll::-webkit-scrollbar{width:5px}.slim-webkit-scroll::-webkit-scrollbar-track{display:none}.slim-webkit-scroll::-webkit-scrollbar-button{display:none}.slim-webkit-scroll::-webkit-scrollbar-thumb{background-color:#fff;border-radius:5px;width:5px!important}.pointer-events-none{pointer-events:none}.invisible{visibility:hidden}.fixed{position:fixed}.absolute{position:absolute}.relative{position:relative}.bottom-\\[calc\\(100\\%\\+0\\.25rem\\)\\]{bottom:calc(100% + .25rem)}.left-0{left:0}.left-1\\/2{left:50%}.top-0{top:0}.z-\\[--bae-modal-z-index\\]{z-index:var(--bae-modal-z-index)}.col-start-1{grid-column-start:1}.col-end-4{grid-column-end:4}.m-2{margin:.5rem}.mb-4{margin-bottom:1rem}.mr-1{margin-right:.25rem}.mr-2{margin-right:.5rem}.box-border{box-sizing:border-box}.block{display:block}.inline-block{display:inline-block}.flex{display:flex}.inline-flex{display:inline-flex}.table{display:table}.grid{display:grid}.size-\\[--bae-icon-size\\]{width:var(--bae-icon-size);height:var(--bae-icon-size)}.size-full{width:100%;height:100%}.size-max{width:-moz-max-content;width:max-content;height:-moz-max-content;height:max-content}.h-10{height:2.5rem}.max-h-\\[80vh\\]{max-height:80vh}.w-10{width:2.5rem}.w-full{width:100%}.flex-1{flex:1 1 0%}.-translate-x-1\\/2{--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.cursor-pointer{cursor:pointer}.grid-flow-col{grid-auto-flow:column}.grid-rows-1{grid-template-rows:repeat(1,minmax(0,1fr))}.flex-row{flex-direction:row}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-end{justify-content:flex-end}.justify-center{justify-content:center}.justify-around{justify-content:space-around}.gap-2{gap:.5rem}.overflow-visible{overflow:visible}.rounded{border-radius:.25rem}.rounded-\\[3px\\]{border-radius:3px}.rounded-full{border-radius:9999px}.rounded-md{border-radius:.375rem}.border{border-width:1px}.border-\\[\\#4a5568\\]{--tw-border-opacity: 1;border-color:rgb(74 85 104 / var(--tw-border-opacity))}.bg-\\[\\#232b3a\\]{--tw-bg-opacity: 1;background-color:rgb(35 43 58 / var(--tw-bg-opacity))}.bg-\\[\\#2d3748\\]{--tw-bg-opacity: 1;background-color:rgb(45 55 72 / var(--tw-bg-opacity))}.bg-\\[\\#4a5568\\]{--tw-bg-opacity: 1;background-color:rgb(74 85 104 / var(--tw-bg-opacity))}.bg-\\[\\#dd6b20\\]{--tw-bg-opacity: 1;background-color:rgb(221 107 32 / var(--tw-bg-opacity))}.bg-black{--tw-bg-opacity: 1;background-color:rgb(0 0 0 / var(--tw-bg-opacity))}.bg-black\\/50{background-color:#00000080}.bg-slate-500{--tw-bg-opacity: 1;background-color:rgb(100 116 139 / var(--tw-bg-opacity))}.bg-slate-950{--tw-bg-opacity: 1;background-color:rgb(2 6 23 / var(--tw-bg-opacity))}.bg-transparent{background-color:transparent}.bg-white{--tw-bg-opacity: 1;background-color:rgb(255 255 255 / var(--tw-bg-opacity))}.bg-opacity-0{--tw-bg-opacity: 0}.bg-opacity-30{--tw-bg-opacity: .3}.p-1{padding:.25rem}.p-2{padding:.5rem}.p-4{padding:1rem}.px-0{padding-left:0;padding-right:0}.px-3{padding-left:.75rem;padding-right:.75rem}.px-4{padding-left:1rem;padding-right:1rem}.py-0{padding-top:0;padding-bottom:0}.py-2{padding-top:.5rem;padding-bottom:.5rem}.py-3{padding-top:.75rem;padding-bottom:.75rem}.text-base{font-size:1rem;line-height:1.5rem}.text-lg{font-size:1.125rem;line-height:1.75rem}.text-xl{font-size:1.25rem;line-height:1.75rem}.text-xs{font-size:.75rem;line-height:1rem}.font-bold{font-weight:700}.text-\\[\\#a0aec0\\]{--tw-text-opacity: 1;color:rgb(160 174 192 / var(--tw-text-opacity))}.text-\\[\\#f7fafc\\]{--tw-text-opacity: 1;color:rgb(247 250 252 / var(--tw-text-opacity))}.text-\\[--bae-icon-size\\]{color:var(--bae-icon-size)}.text-white{--tw-text-opacity: 1;color:rgb(255 255 255 / var(--tw-text-opacity))}.shadow-\\[0_0_0_8px_\\#64646466\\]{--tw-shadow: 0 0 0 8px #64646466;--tw-shadow-colored: 0 0 0 8px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000),var(--tw-ring-shadow, 0 0 #0000),var(--tw-shadow)}.filter{filter:var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow)}.transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1);transition-duration:.15s}.duration-100{transition-duration:.1s}.ease-in{transition-timing-function:cubic-bezier(.4,0,1,1)}.after\\:absolute:after{content:var(--tw-content);position:absolute}.after\\:left-1\\/2:after{content:var(--tw-content);left:50%}.after\\:top-full:after{content:var(--tw-content);top:100%}.after\\:block:after{content:var(--tw-content);display:block}.after\\:size-0:after{content:var(--tw-content);width:0px;height:0px}.after\\:-translate-x-1\\/2:after{content:var(--tw-content);--tw-translate-x: -50%;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skew(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.after\\:border-8:after{content:var(--tw-content);border-width:8px}.after\\:border-solid:after{content:var(--tw-content);border-style:solid}.after\\:border-x-transparent:after{content:var(--tw-content);border-left-color:transparent;border-right-color:transparent}.after\\:border-b-transparent:after{content:var(--tw-content);border-bottom-color:transparent}.after\\:border-t-black:after{content:var(--tw-content);--tw-border-opacity: 1;border-top-color:rgb(0 0 0 / var(--tw-border-opacity))}.after\\:content-\\[\\'\\'\\]:after{--tw-content: "";content:var(--tw-content)}.last\\:mr-0:last-child{margin-right:0}.hover\\:border-\\[\\#cbd5e0\\]:hover{--tw-border-opacity: 1;border-color:rgb(203 213 224 / var(--tw-border-opacity))}.hover\\:bg-opacity-20:hover{--tw-bg-opacity: .2}.hover\\:bg-opacity-35:hover{--tw-bg-opacity: .35}.focus\\:border-\\[\\#a0aec0\\]:focus{--tw-border-opacity: 1;border-color:rgb(160 174 192 / var(--tw-border-opacity))}.focus\\:outline-none:focus{outline:2px solid transparent;outline-offset:2px}.group\\/popover:hover .group-hover\\/popover\\:visible{visibility:visible}@media (min-width: 768px){.md\\:min-w-96{min-width:24rem}} `);
(function () {
'use strict';
const sharedConfig = {
context: void 0,
registry: void 0,
effects: void 0,
done: false,
getContextId() {
return getContextId(this.context.count);
},
getNextContextId() {
return getContextId(this.context.count++);
}
};
function getContextId(count) {
const num = String(count), len = num.length - 1;
return sharedConfig.context.id + (len ? String.fromCharCode(96 + len) : "") + num;
}
const equalFn = (a, b) => a === b;
const $PROXY = Symbol("solid-proxy");
const SUPPORTS_PROXY = typeof Proxy === "function";
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 = null;
let ExternalSourceConfig = 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, current = detachedOwner === void 0 ? owner : detachedOwner, root = unowned ? UNOWNED : {
owned: null,
cleanups: null,
context: current ? current.context : null,
owner: current
}, 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 s = {
value,
observers: null,
observerSlots: null,
comparator: options.equals || void 0
};
const setter = (value2) => {
if (typeof value2 === "function") {
value2 = value2(s.value);
}
return writeSignal(s, value2);
};
return [readSignal.bind(s), setter];
}
function createComputed(fn, value, options) {
const c = createComputation(fn, value, true, STALE);
updateComputation(c);
}
function createRenderEffect(fn, value, options) {
const c = createComputation(fn, value, false, STALE);
updateComputation(c);
}
function createEffect(fn, value, options) {
runEffects = runUserEffects;
const c = createComputation(fn, value, false, STALE);
if (!options || !options.render) c.user = true;
Effects ? Effects.push(c) : updateComputation(c);
}
function createMemo(fn, value, options) {
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
const c = createComputation(fn, value, true, 0);
c.observers = null;
c.observerSlots = null;
c.comparator = options.equals || void 0;
updateComputation(c);
return readSignal.bind(c);
}
function isPromise(v) {
return v && typeof v === "object" && "then" in v;
}
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 = {};
} else {
source = pSource;
fetcher = pFetcher;
options = {};
}
let pr = null, initP = NO_INIT, 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");
function loadEnd(p, v, error2, key) {
if (pr === p) {
pr = null;
key !== void 0 && (resolved = true);
if ((p === 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" : resolved ? "ready" : "unresolved");
setError(err);
for (const c of contexts.keys()) c.decrement();
contexts.clear();
}, false);
}
function read() {
const c = SuspenseContext, v = value(), err = error();
if (err !== void 0 && !pr) throw err;
if (Listener && !Listener.user && c) {
createComputed(() => {
track();
if (pr) {
if (c.resolved) ;
else if (!contexts.has(c)) {
c.increment();
contexts.add(c);
}
}
});
}
return v;
}
function load(refetching = true) {
if (refetching !== false && scheduled) return;
scheduled = false;
const lookup = dynamic ? dynamic() : source;
if (lookup == null || lookup === false) {
loadEnd(pr, untrack(value));
return;
}
const p = initP !== NO_INIT ? initP : untrack(
() => fetcher(lookup, {
value: value(),
refetching
})
);
if (!isPromise(p)) {
loadEnd(pr, p, void 0, lookup);
return p;
}
pr = p;
if ("value" in p) {
if (p.status === "success") loadEnd(pr, p.value, void 0, lookup);
else loadEnd(pr, void 0, castError(p.value), lookup);
return p;
}
scheduled = true;
queueMicrotask(() => scheduled = false);
runUpdates(() => {
setState(resolved ? "refreshing" : "pending");
trigger();
}, false);
return p.then(
(v) => loadEnd(p, v, void 0, lookup),
(e) => loadEnd(p, void 0, castError(e), lookup)
);
}
Object.defineProperties(read, {
state: {
get: () => state()
},
error: {
get: () => error()
},
loading: {
get() {
const s = state();
return s === "pending" || s === "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 {
if (ExternalSourceConfig) ;
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 i = 0; i < deps.length; i++) input[i] = deps[i]();
} else input = deps();
if (defer) {
defer = false;
return prevValue;
}
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 runWithOwner(o, fn) {
const prev = Owner;
const prevListener = Listener;
Owner = o;
Listener = null;
try {
return runUpdates(fn, true);
} catch (err) {
handleError(err);
} finally {
Owner = prev;
Listener = prevListener;
}
}
function createContext(defaultValue, options) {
const id = Symbol("context");
return {
id,
Provider: createProvider(id),
defaultValue
};
}
function useContext(context) {
let value;
return Owner && Owner.context && (value = Owner.context[context.id]) !== void 0 ? value : context.defaultValue;
}
function children(fn) {
const children2 = createMemo(fn);
const memo = createMemo(() => resolveChildren(children2()));
memo.toArray = () => {
const c = memo();
return Array.isArray(c) ? c : c != null ? [c] : [];
};
return memo;
}
let SuspenseContext;
function readSignal() {
if (this.sources && this.state) {
if (this.state === STALE) 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 i = 0; i < node.observers.length; i += 1) {
const o = node.observers[i];
const TransitionRunning = Transition && Transition.running;
if (TransitionRunning && Transition.disposed.has(o)) ;
if (TransitionRunning ? !o.tState : !o.state) {
if (o.pure) Updates.push(o);
else Effects.push(o);
if (o.observers) markDownstream(o);
}
if (!TransitionRunning) o.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 time = ExecCount;
runComputation(
node,
node.value,
time
);
}
function runComputation(node, value, time) {
let nextValue;
const owner = Owner, listener = Listener;
Listener = Owner = node;
try {
nextValue = node.fn(value);
} catch (err) {
if (node.pure) {
{
node.state = STALE;
node.owned && node.owned.forEach(cleanNode);
node.owned = null;
}
}
node.updatedAt = time + 1;
return handleError(err);
} finally {
Listener = listener;
Owner = owner;
}
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 c = {
fn,
state,
updatedAt: null,
owned: null,
sources: null,
sourceSlots: null,
cleanups: null,
value: init,
owner: Owner,
context: Owner ? Owner.context : null,
pure
};
if (Owner === null) ;
else if (Owner !== UNOWNED) {
{
if (!Owner.owned) Owner.owned = [c];
else Owner.owned.push(c);
}
}
return c;
}
function runTop(node) {
if (node.state === 0) return;
if (node.state === PENDING) 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) ancestors.push(node);
}
for (let i = ancestors.length - 1; i >= 0; i--) {
node = ancestors[i];
if (node.state === STALE) {
updateComputation(node);
} else if (node.state === PENDING) {
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 e = Effects;
Effects = null;
if (e.length) runUpdates(() => runEffects(e), false);
}
function runQueue(queue) {
for (let i = 0; i < queue.length; i++) runTop(queue[i]);
}
function runUserEffects(queue) {
let i, userLength = 0;
for (i = 0; i < queue.length; i++) {
const e = queue[i];
if (!e.user) runTop(e);
else queue[userLength++] = e;
}
for (i = 0; i < userLength; i++) runTop(queue[i]);
}
function lookUpstream(node, ignore) {
node.state = 0;
for (let i = 0; i < node.sources.length; i += 1) {
const source = node.sources[i];
if (source.sources) {
const state = source.state;
if (state === STALE) {
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
runTop(source);
} else if (state === PENDING) lookUpstream(source, ignore);
}
}
}
function markDownstream(node) {
for (let i = 0; i < node.observers.length; i += 1) {
const o = node.observers[i];
if (!o.state) {
o.state = PENDING;
if (o.pure) Updates.push(o);
else Effects.push(o);
o.observers && markDownstream(o);
}
}
}
function cleanNode(node) {
let i;
if (node.sources) {
while (node.sources.length) {
const source = node.sources.pop(), index = node.sourceSlots.pop(), obs = source.observers;
if (obs && obs.length) {
const n = obs.pop(), s = source.observerSlots.pop();
if (index < obs.length) {
n.sourceSlots[s] = index;
obs[index] = n;
source.observerSlots[index] = s;
}
}
}
}
if (node.tOwned) {
for (i = node.tOwned.length - 1; i >= 0; i--) cleanNode(node.tOwned[i]);
delete node.tOwned;
}
if (node.owned) {
for (i = node.owned.length - 1; i >= 0; i--) cleanNode(node.owned[i]);
node.owned = null;
}
if (node.cleanups) {
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
node.cleanups = null;
}
node.state = 0;
}
function castError(err) {
if (err instanceof Error) return err;
return new Error(typeof err === "string" ? err : "Unknown error", {
cause: err
});
}
function handleError(err, owner = Owner) {
const error = castError(err);
throw error;
}
function resolveChildren(children2) {
if (typeof children2 === "function" && !children2.length) return resolveChildren(children2());
if (Array.isArray(children2)) {
const results = [];
for (let i = 0; i < children2.length; i++) {
const result = resolveChildren(children2[i]);
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 = {
...Owner.context,
[id]: props.value
};
return children(() => props.children);
}),
void 0
);
return res;
};
}
const FALLBACK = Symbol("fallback");
function dispose(d) {
for (let i = 0; i < d.length; i++) d[i]();
}
function mapArray(list, mapFn, options = {}) {
let items = [], mapped = [], disposers = [], len = 0, indexes = mapFn.length > 1 ? [] : null;
onCleanup(() => dispose(disposers));
return () => {
let newItems = list() || [], newLen = newItems.length, i, j;
newItems[$TRACK];
return untrack(() => {
let 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];
i = newIndices.get(item);
newIndicesNext[j] = i === void 0 ? -1 : i;
newIndices.set(item, j);
}
for (i = start; i <= end; i++) {
item = items[i];
j = newIndices.get(item);
if (j !== void 0 && j !== -1) {
temp[j] = mapped[i];
tempdisposers[j] = disposers[i];
indexes && (tempIndexes[j] = indexes[i]);
j = newIndicesNext[j];
newIndices.set(item, j);
} else disposers[i]();
}
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 [s, set] = createSignal(j);
indexes[j] = set;
return mapFn(newItems[j], s);
}
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(s) {
return !(s = typeof s === "function" ? s() : s) ? {} : s;
}
function resolveSources() {
for (let i = 0, length = this.length; i < length; ++i) {
const v = this[i]();
if (v !== void 0) return v;
}
}
function mergeProps(...sources) {
let proxy = false;
for (let i = 0; i < sources.length; i++) {
const s = sources[i];
proxy = proxy || !!s && $PROXY in s;
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
}
if (SUPPORTS_PROXY && proxy) {
return new Proxy(
{
get(property) {
for (let i = sources.length - 1; i >= 0; i--) {
const v = resolveSource(sources[i])[property];
if (v !== void 0) return v;
}
},
has(property) {
for (let i = sources.length - 1; i >= 0; i--) {
if (property in resolveSource(sources[i])) return true;
}
return false;
},
keys() {
const keys = [];
for (let i = 0; i < sources.length; i++)
keys.push(...Object.keys(resolveSource(sources[i])));
return [...new Set(keys)];
}
},
propTraps
);
}
const sourcesMap = {};
const defined = /* @__PURE__ */ Object.create(null);
for (let i = sources.length - 1; i >= 0; i--) {
const source = sources[i];
if (!source) continue;
const sourceKeys = Object.getOwnPropertyNames(source);
for (let i2 = sourceKeys.length - 1; i2 >= 0; i2--) {
const key = sourceKeys[i2];
if (key === "__proto__" || key === "constructor") continue;
const desc = Object.getOwnPropertyDescriptor(source, key);
if (!defined[key]) {
defined[key] = desc.get ? {
enumerable: true,
configurable: true,
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
} : desc.value !== void 0 ? desc : void 0;
} else {
const sources2 = sourcesMap[key];
if (sources2) {
if (desc.get) sources2.push(desc.get.bind(source));
else if (desc.value !== void 0) sources2.push(() => desc.value);
}
}
}
}
const target = {};
const definedKeys = Object.keys(defined);
for (let i = definedKeys.length - 1; i >= 0; i--) {
const key = definedKeys[i], desc = defined[key];
if (desc && desc.get) Object.defineProperty(target, key, desc);
else target[key] = desc ? desc.value : void 0;
}
return target;
}
const narrowedError = (name) => `Stale read from <${name}>.`;
function For(props) {
const fallback = "fallback" in props && {
fallback: () => props.fallback
};
return createMemo(mapArray(() => props.each, props.children, fallback || void 0));
}
function Show(props) {
const keyed = props.keyed;
const condition = createMemo(() => props.when, void 0, {
equals: (a, b) => keyed ? a === b : !a === !b
});
return createMemo(
() => {
const c = condition();
if (c) {
const child = props.children;
const fn = typeof child === "function" && child.length > 0;
return fn ? untrack(
() => child(
keyed ? c : () => {
if (!untrack(condition)) throw narrowedError("Show");
return props.when;
}
)
) : child;
}
return props.fallback;
},
void 0,
void 0
);
}
const ChildProperties = /* @__PURE__ */ new Set([
"innerHTML",
"textContent",
"innerText",
"children"
]);
const Aliases = /* @__PURE__ */ Object.assign(/* @__PURE__ */ Object.create(null), {
className: "class",
htmlFor: "for"
});
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 SVGNamespace = {
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace"
};
function reconcileArrays(parentNode, a, b) {
let bLength = b.length, aEnd = a.length, bEnd = bLength, aStart = 0, bStart = 0, after = a[aEnd - 1].nextSibling, map = null;
while (aStart < aEnd || bStart < bEnd) {
if (a[aStart] === b[bStart]) {
aStart++;
bStart++;
continue;
}
while (a[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(a[aStart])) a[aStart].remove();
aStart++;
}
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
const node = a[--aEnd].nextSibling;
parentNode.insertBefore(b[bStart++], a[aStart++].nextSibling);
parentNode.insertBefore(b[--bEnd], node);
a[aEnd] = b[bEnd];
} else {
if (!map) {
map = /* @__PURE__ */ new Map();
let i = bStart;
while (i < bEnd) map.set(b[i], i++);
}
const index = map.get(a[aStart]);
if (index != null) {
if (bStart < index && index < bEnd) {
let i = aStart, sequence = 1, t;
while (++i < aEnd && i < bEnd) {
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
sequence++;
}
if (sequence > index - bStart) {
const node = a[aStart];
while (bStart < index) parentNode.insertBefore(b[bStart++], node);
} else parentNode.replaceChild(b[bStart++], a[aStart++]);
} else aStart++;
} else a[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(html, isImportNode, isSVG) {
let node;
const create = () => {
const t = document.createElement("template");
t.innerHTML = html;
return t.content.firstChild;
};
const fn = () => (node || (node = create())).cloneNode(true);
fn.cloneNode = fn;
return fn;
}
function delegateEvents(eventNames, document2 = window.document) {
const e = document2[$$EVENTS] || (document2[$$EVENTS] = /* @__PURE__ */ new Set());
for (let i = 0, l = eventNames.length; i < l; i++) {
const name = eventNames[i];
if (!e.has(name)) {
e.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 setBoolAttribute(node, name, value) {
value ? node.setAttribute(name, "") : node.removeAttribute(name);
}
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] = (e) => handlerFn.call(node, handler[1], e));
} else node.addEventListener(name, handler, typeof handler !== "function" && handler);
}
function classList(node, value, prev = {}) {
const classKeys = Object.keys(value || {}), prevKeys = Object.keys(prev);
let i, len;
for (i = 0, len = prevKeys.length; i < len; i++) {
const key = prevKeys[i];
if (!key || key === "undefined" || value[key]) continue;
toggleClassKey(node, key, false);
delete prev[key];
}
for (i = 0, len = classKeys.length; i < len; i++) {
const key = classKeys[i], 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, s;
for (s in prev) {
value[s] == null && nodeStyle.removeProperty(s);
delete prev[s];
}
for (s in value) {
v = value[s];
if (v !== prev[s]) {
nodeStyle.setProperty(s, v);
prev[s] = v;
}
}
return prev;
}
function spread(node, props = {}, isSVG, skipChildren) {
const prevProps = {};
createRenderEffect(() => typeof props.ref === "function" && use(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, props);
}
}
for (const prop in props) {
if (prop === "children") {
continue;
}
const value = props[prop];
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG, skipRef, props);
}
}
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 i = 0, nameLen = classNames.length; i < nameLen; i++)
node.classList.toggle(classNames[i], value);
}
function assignProp(node, prop, value, prev, isSVG, skipRef, props) {
let isCE, isProp, isChildProp, forceProp;
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 e = prop.slice(3);
prev && node.removeEventListener(e, prev, typeof prev !== "function" && prev);
value && node.addEventListener(e, value, typeof value !== "function" && value);
} else if (prop.slice(0, 10) === "oncapture:") {
const e = prop.slice(10);
prev && node.removeEventListener(e, prev, true);
value && node.addEventListener(e, value, true);
} else if (prop.slice(0, 2) === "on") {
const name = prop.slice(2).toLowerCase();
const delegate = DelegatedEvents.has(name);
if (!delegate && prev) {
const h = Array.isArray(prev) ? prev[0] : prev;
node.removeEventListener(name, h);
}
if (delegate || value) {
addEventListener(node, name, value, delegate);
delegate && delegateEvents([name]);
}
} else if (prop.slice(0, 5) === "attr:") {
setAttribute(node, prop.slice(5), value);
} else if (prop.slice(0, 5) === "bool:") {
setBoolAttribute(node, prop.slice(5), value);
} else if ((forceProp = prop.slice(0, 5) === "prop:") || (isChildProp = ChildProperties.has(prop)) || !isSVG || (isCE = node.nodeName.includes("-") || "is" in props)) {
if (forceProp) {
prop = prop.slice(5);
isProp = true;
}
if (prop === "class" || prop === "className") className(node, value);
else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;
else node[prop] = value;
} else {
const ns = 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(e) {
let node = e.target;
const key = `$$${e.type}`;
const oriTarget = e.target;
const oriCurrentTarget = e.currentTarget;
const retarget = (value) => Object.defineProperty(e, "target", {
configurable: true,
value
});
const handleNode = () => {
const handler = node[key];
if (handler && !node.disabled) {
const data = node[`${key}Data`];
data !== void 0 ? handler.call(node, data, e) : handler.call(node, e);
if (e.cancelBubble) return;
}
node.host && typeof node.host !== "string" && !node.host._$host && node.contains(e.target) && retarget(node.host);
return true;
};
const walkUpTree = () => {
while (handleNode() && (node = node._$host || node.parentNode || node.host)) ;
};
Object.defineProperty(e, "currentTarget", {
configurable: true,
get() {
return node || document;
}
});
if (e.composedPath) {
const path = e.composedPath();
retarget(path[0]);
for (let i = 0; i < path.length - 2; i++) {
node = path[i];
if (!handleNode()) break;
if (node._$host) {
node = node._$host;
walkUpTree();
break;
}
if (node.parentNode === oriCurrentTarget) {
break;
}
}
} else walkUpTree();
retarget(oriTarget);
}
function insertExpression(parent, value, current, marker, unwrapArray) {
while (typeof current === "function") current = current();
if (value === current) return current;
const t = typeof value, multi = marker !== void 0;
parent = multi && current[0] && current[0].parentNode || parent;
if (t === "string" || t === "number") {
if (t === "number") {
value = value.toString();
if (value === current) return current;
}
if (multi) {
let node = current[0];
if (node && node.nodeType === 3) {
node.data !== value && (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 || t === "boolean") {
current = cleanChildren(parent, current, marker);
} else if (t === "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 (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.nodeType) {
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 i = 0, len = array.length; i < len; i++) {
let item = array[i], prev = current && current[normalized.length], t;
if (item == null || item === true || item === false) ;
else if ((t = typeof item) === "object" && item.nodeType) {
normalized.push(item);
} else if (Array.isArray(item)) {
dynamic = normalizeIncomingArray(normalized, item, prev) || dynamic;
} else if (t === "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 i = 0, len = array.length; i < len; i++) parent.insertBefore(array[i], 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 i = current.length - 1; i >= 0; i--) {
const el = current[i];
if (node !== el) {
const isParent = el.parentNode === parent;
if (!inserted && !i)
isParent ? parent.replaceChild(node, el) : parent.insertBefore(node, marker);
else isParent && el.remove();
} else inserted = true;
}
} else parent.insertBefore(node, marker);
return [node];
}
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, owner = getOwner();
let content;
let hydrating = !!sharedConfig.context;
createEffect(
() => {
content || (content = runWithOwner(owner, () => createMemo(() => props.children)));
const el = mount();
if (el instanceof HTMLHeadElement) {
const [clean, setClean] = createSignal(false);
const cleanup = () => setClean(true);
createRoot((dispose2) => insert(el, () => !clean() ? content() : dispose2(), null));
onCleanup(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, content);
el.appendChild(container);
props.ref && props.ref(container);
onCleanup(() => el.removeChild(container));
}
},
void 0,
{
render: !hydrating
}
);
return marker;
}
var _tmpl$$h = /* @__PURE__ */ template(`<i class="block text-[--bae-icon-size] size-[--bae-icon-size]">`);
const Icon = (props) => {
return (() => {
var _el$ = _tmpl$$h();
insert(_el$, () => props.children);
createRenderEffect((_$p) => (_$p = `${props.size ?? 18}px`) != null ? _el$.style.setProperty("--bae-icon-size", _$p) : _el$.style.removeProperty("--bae-icon-size"));
return _el$;
})();
};
var _tmpl$$g = /* @__PURE__ */ template(`<div class="group/popover relative inline-block"><div class="size-max invisible group-hover/popover:visible p-2 rounded-[3px] pointer-events-none text-base absolute left-1/2 bottom-[calc(100%+0.25rem)] -translate-x-1/2 bg-black after:content-[''] after:absolute after:block after:-translate-x-1/2 after:size-0 after:top-full after:left-1/2 after:border-8 after:border-solid after:border-x-transparent after:border-b-transparent after:border-t-black">`);
const Popover = (props) => {
return (() => {
var _el$ = _tmpl$$g(), _el$2 = _el$.firstChild;
insert(_el$, () => props.children, _el$2);
insert(_el$2, () => props.content);
return _el$;
})();
};
var _tmpl$$f = /* @__PURE__ */ template(`<button type=button><span class=font-bold>`);
const Switch = (props) => {
return (() => {
var _el$ = _tmpl$$f(), _el$2 = _el$.firstChild;
_el$.$$click = () => {
var _a;
(_a = props.onClick) == null ? void 0 : _a.call(props);
};
insert(_el$2, () => props.children);
createRenderEffect(() => className(_el$, `w-10 h-10 box-border rounded bg-white text-white cursor-pointer flex justify-center items-center ${props.value ?? false ? "bg-opacity-30 hover:bg-opacity-35" : "bg-opacity-0 hover:bg-opacity-20"}`));
return _el$;
})();
};
delegateEvents(["click"]);
const $RAW = Symbol("store-raw"), $NODE = Symbol("store-node"), $HAS = Symbol("store-has"), $SELF = Symbol("store-self");
function wrap$1(value) {
let p = value[$PROXY];
if (!p) {
Object.defineProperty(value, $PROXY, {
value: p = new Proxy(value, proxyTraps$1)
});
if (!Array.isArray(value)) {
const keys = Object.keys(value), desc = Object.getOwnPropertyDescriptors(value);
for (let i = 0, l = keys.length; i < l; i++) {
const prop = keys[i];
if (desc[prop].get) {
Object.defineProperty(value, prop, {
enumerable: desc[prop].enumerable,
get: desc[prop].get.bind(p)
});
}
}
}
}
return p;
}
function isWrappable(obj) {
let proto;
return obj != null && typeof obj === "object" && (obj[$PROXY] || !(proto = Object.getPrototypeOf(obj)) || proto === Object.prototype || Array.isArray(obj));
}
function unwrap(item, set = /* @__PURE__ */ new Set()) {
let result, unwrapped, v, prop;
if (result = item != null && item[$RAW]) return result;
if (!isWrappable(item) || set.has(item)) return item;
if (Array.isArray(item)) {
if (Object.isFrozen(item)) item = item.slice(0);
else set.add(item);
for (let i = 0, l = item.length; i < l; i++) {
v = item[i];
if ((unwrapped = unwrap(v, set)) !== v) item[i] = unwrapped;
}
} else {
if (Object.isFrozen(item)) item = Object.assign({}, item);
else set.add(item);
const keys = Object.keys(item), desc = Object.getOwnPropertyDescriptors(item);
for (let i = 0, l = keys.length; i < l; i++) {
prop = keys[i];
if (desc[prop].get) continue;
v = item[prop];
if ((unwrapped = unwrap(v, set)) !== v) item[prop] = unwrapped;
}
}
return item;
}
function getNodes(target, symbol) {
let nodes = target[symbol];
if (!nodes)
Object.defineProperty(target, symbol, {
value: nodes = /* @__PURE__ */ Object.create(null)
});
return nodes;
}
function getNode(nodes, property, value) {
if (nodes[property]) return nodes[property];
const [s, set] = createSignal(value, {
equals: false,
internal: true
});
s.$ = set;
return nodes[property] = s;
}
function proxyDescriptor$1(target, property) {
const desc = Reflect.getOwnPropertyDescriptor(target, property);
if (!desc || desc.get || !desc.configurable || property === $PROXY || property === $NODE)
return desc;
delete desc.value;
delete desc.writable;
desc.get = () => target[$PROXY][property];
return desc;
}
function trackSelf(target) {
getListener() && getNode(getNodes(target, $NODE), $SELF)();
}
function ownKeys(target) {
trackSelf(target);
return Reflect.ownKeys(target);
}
const proxyTraps$1 = {
get(target, property, receiver) {
if (property === $RAW) return target;
if (property === $PROXY) return receiver;
if (property === $TRACK) {
trackSelf(target);
return receiver;
}
const nodes = getNodes(target, $NODE);
const tracked = nodes[property];
let value = tracked ? tracked() : target[property];
if (property === $NODE || property === $HAS || property === "__proto__") return value;
if (!tracked) {
const desc = Object.getOwnPropertyDescriptor(target, property);
if (getListener() && (typeof value !== "function" || target.hasOwnProperty(property)) && !(desc && desc.get))
value = getNode(nodes, property, value)();
}
return isWrappable(value) ? wrap$1(value) : value;
},
has(target, property) {
if (property === $RAW || property === $PROXY || property === $TRACK || property === $NODE || property === $HAS || property === "__proto__")
return true;
getListener() && getNode(getNodes(target, $HAS), property)();
return property in target;
},
set() {
return true;
},
deleteProperty() {
return true;
},
ownKeys,
getOwnPropertyDescriptor: proxyDescriptor$1
};
function setProperty(state, property, value, deleting = false) {
if (!deleting && state[property] === value) return;
const prev = state[property], len = state.length;
if (value === void 0) {
delete state[property];
if (state[$HAS] && state[$HAS][property] && prev !== void 0) state[$HAS][property].$();
} else {
state[property] = value;
if (state[$HAS] && state[$HAS][property] && prev === void 0) state[$HAS][property].$();
}
let nodes = getNodes(state, $NODE), node;
if (node = getNode(nodes, property, prev)) node.$(() => value);
if (Array.isArray(state) && state.length !== len) {
for (let i = state.length; i < len; i++) (node = nodes[i]) && node.$();
(node = getNode(nodes, "length", len)) && node.$(state.length);
}
(node = nodes[$SELF]) && node.$();
}
function mergeStoreNode(state, value) {
const keys = Object.keys(value);
for (let i = 0; i < keys.length; i += 1) {
const key = keys[i];
setProperty(state, key, value[key]);
}
}
function updateArray(current, next) {
if (typeof next === "function") next = next(current);
next = unwrap(next);
if (Array.isArray(next)) {
if (current === next) return;
let i = 0, len = next.length;
for (; i < len; i++) {
const value = next[i];
if (current[i] !== value) setProperty(current, i, value);
}
setProperty(current, "length", len);
} else mergeStoreNode(current, next);
}
function updatePath(current, path, traversed = []) {
let part, prev = current;
if (path.length > 1) {
part = path.shift();
const partType = typeof part, isArray = Array.isArray(current);
if (Array.isArray(part)) {
for (let i = 0; i < part.length; i++) {
updatePath(current, [part[i]].concat(path), traversed);
}
return;
} else if (isArray && partType === "function") {
for (let i = 0; i < current.length; i++) {
if (part(current[i], i)) updatePath(current, [i].concat(path), traversed);
}
return;
} else if (isArray && partType === "object") {
const { from = 0, to = current.length - 1, by = 1 } = part;
for (let i = from; i <= to; i += by) {
updatePath(current, [i].concat(path), traversed);
}
return;
} else if (path.length > 1) {
updatePath(current[part], path, [part].concat(traversed));
return;
}
prev = current[part];
traversed = [part].concat(traversed);
}
let value = path[0];
if (typeof value === "function") {
value = value(prev, traversed);
if (value === prev) return;
}
if (part === void 0 && value == void 0) return;
value = unwrap(value);
if (part === void 0 || isWrappable(prev) && isWrappable(value) && !Array.isArray(value)) {
mergeStoreNode(prev, value);
} else setProperty(current, part, value);
}
function createStore(...[store, options]) {
const unwrappedStore = unwrap(store || {});
const isArray = Array.isArray(unwrappedStore);
const wrappedStore = wrap$1(unwrappedStore);
function setStore(...args) {
batch(() => {
isArray && args.length === 1 ? updateArray(unwrappedStore, args[0]) : updatePath(unwrappedStore, args);
});
}
return [wrappedStore, setStore];
}
var _tmpl$$e = /* @__PURE__ */ template(`<span class="mr-1 last:mr-0">`), _tmpl$2$3 = /* @__PURE__ */ template(`<span>`), _tmpl$3$1 = /* @__PURE__ */ template(`<button>`);
const sizeMap = {
small: 5,
medium: 7,
large: 9
};
const colorMap = {
primary: "bg-[#dd6b20]",
plain: "bg-[#4a5568]",
transparent: "bg-transparent"
};
const Button = (props) => {
return (() => {
var _el$ = _tmpl$3$1();
_el$.$$click = () => {
var _a;
(_a = props.onClick) == null ? void 0 : _a.call(props);
};
insert(_el$, createComponent(Show, {
get when() {
return props.icon != null;
},
get children() {
var _el$2 = _tmpl$$e();
insert(_el$2, createComponent(Icon, {
get children() {
return props.icon;
}
}));
return _el$2;
}
}), null);
insert(_el$, createComponent(Show, {
get when() {
return props.children != null;
},
get children() {
var _el$3 = _tmpl$2$3();
insert(_el$3, () => props.children);
return _el$3;
}
}), null);
createRenderEffect((_p$) => {
var _v$ = props.type, _v$2 = `inline-flex items-center text-white py-2 px-3 ${props.round === true ? `rounded-full size-${sizeMap[props.size ?? "medium"]} px-0 py-0` : "rounded-[3px]"} ${colorMap[props.variant ?? "transparent"]} h-${sizeMap[props.size ?? "medium"]}`;
_v$ !== _p$.e && setAttribute(_el$, "type", _p$.e = _v$);
_v$2 !== _p$.t && className(_el$, _p$.t = _v$2);
return _p$;
}, {
e: void 0,
t: void 0
});
return _el$;
})();
};
delegateEvents(["click"]);
var _tmpl$$d = /* @__PURE__ */ template(`<input class="bg-[#2d3748] text-[#f7fafc] p-2 text-lg transition-all ease-in duration-100 rounded w-full border border-[#4a5568] hover:border-[#cbd5e0] focus:outline-none focus:border-[#a0aec0]"type=text>`);
const Input = (props) => {
return (() => {
var _el$ = _tmpl$$d();
_el$.$$input = (e) => {
var _a;
(_a = props.onInput) == null ? void 0 : _a.call(props, e.target.value);
};
_el$.addEventListener("change", (e) => {
var _a;
(_a = props.onChange) == null ? void 0 : _a.call(props, e.target.value);
});
createRenderEffect(() => setAttribute(_el$, "placeholder", props.placeholder));
createRenderEffect(() => _el$.value = props.value ?? "");
return _el$;
})();
};
delegateEvents(["input"]);
var _tmpl$$c = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg viewBox="0 0 448 512"><path fill=currentColor d="M325.4 289.2 224 390.6 122.6 289.2C54 295.3 0 352.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-70.2-54-127.1-122.6-133.2M32 192c27.3 0 51.8-11.5 69.2-29.7 15.1 53.9 64 93.7 122.8 93.7 70.7 0 128-57.3 128-128S294.7 0 224 0c-50.4 0-93.6 29.4-114.5 71.8C92.1 47.8 64 32 32 32c0 33.4 17.1 62.8 43.1 80-26 17.2-43.1 46.6-43.1 80m144-96h96c17.7 0 32 14.3 32 32H144c0-17.7 14.3-32 32-32">`);
const Ninja = (props = {}) => (() => {
var _el$ = _tmpl$$c();
spread(_el$, props, true);
return _el$;
})();
var _tmpl$$b = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none stroke=currentColor stroke-width=1.5 class="w-6 h-6"viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round d="M19.5 12q0-1.848-.138-3.662a4.006 4.006 0 0 0-3.7-3.7 49 49 0 0 0-7.324 0 4.006 4.006 0 0 0-3.7 3.7q-.025.33-.046.662M19.5 12l3-3m-3 3-3-3m-12 3q0 1.848.138 3.662a4.006 4.006 0 0 0 3.7 3.7 49 49 0 0 0 7.324 0 4.006 4.006 0 0 0 3.7-3.7q.025-.33.046-.662M4.5 12l3 3m-3-3-3 3">`);
const Replace = (props = {}) => (() => {
var _el$ = _tmpl$$b();
spread(_el$, props, true);
return _el$;
})();
var _tmpl$$a = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=currentColor class="w-6 h-6"viewBox="0 0 24 24"><path d="M5.25 6.375a4.125 4.125 0 1 1 8.25 0 4.125 4.125 0 0 1-8.25 0m-3 12.75a7.125 7.125 0 0 1 14.25 0v.003l-.001.119a.75.75 0 0 1-.363.63 13.07 13.07 0 0 1-6.761 1.873c-2.472 0-4.786-.684-6.76-1.873a.75.75 0 0 1-.364-.63zM18.75 7.5a.75.75 0 0 0-1.5 0v2.25H15a.75.75 0 0 0 0 1.5h2.25v2.25a.75.75 0 0 0 1.5 0v-2.25H21a.75.75 0 0 0 0-1.5h-2.25z">`);
const AddUser = (props = {}) => (() => {
var _el$ = _tmpl$$a();
spread(_el$, props, true);
return _el$;
})();
var _tmpl$$9 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none stroke=currentColor stroke-width=1.5 class="w-6 h-6"viewBox="0 0 24 24"><path stroke-linecap=round stroke-linejoin=round d="M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3">`);
const ArrowRight = (props = {}) => (() => {
var _el$ = _tmpl$$9();
spread(_el$, props, true);
return _el$;
})();
var _tmpl$$8 = /* @__PURE__ */ template(`<svg xmlns=http://www.w3.org/2000/svg fill=none stroke=currentColor stroke-linecap=round stroke-linejoin=round stroke-width=2 class="feather feather-x-circle"viewBox="0 0 24 24"><circle cx=12 cy=12 r=10></circle><path d="m15 9-6 6M9 9l6 6">`);
const CloseCross = (props = {}) => (() => {
var _el$ = _tmpl$$8();
spread(_el$, props, true);
return _el$;
})();
var _GM = /* @__PURE__ */ (() => typeof GM != "undefined" ? GM : void 0)();
var _GM_addValueChangeListener = /* @__PURE__ */ (() => typeof GM_addValueChangeListener != "undefined" ? GM_addValueChangeListener : void 0)();
const [characterList, { mutate: mutateCharacterList }] = createResource(async () => await _GM.getValue("boluoCharacterList", []));
const setCharacterList = (value) => {
const newVal = mutateCharacterList(value);
void _GM.setValue("boluoCharacterList", newVal);
return newVal;
};
_GM_addValueChangeListener(
"boluoCharacterList",
(_, __, newVal) => {
void mutateCharacterList(newVal);
}
);
function useCharacterStore() {
const activeCharacter = createMemo(() => {
var _a;
return (_a = characterList()) == null ? void 0 : _a.find((c) => c.active);
});
const setActiveCharacter = (name) => {
characterList() != null && setCharacterList((prev) => {
return prev.map((c) => {
c.active = c.name === name;
return c;
});
});
};
const deleteCharacter = (name) => {
setCharacterList((prev) => {
return (prev == null ? void 0 : prev.filter((c) => c.name !== name)) ?? [];
});
};
const addCharacter = (newCharacter) => {
deleteCharacter(newCharacter.name);
setCharacterList((prev) => {
return [...prev ?? [], newCharacter];
});
};
return {
characterList,
setCharacterList,
activeCharacter,
setActiveCharacter,
deleteCharacter,
addCharacter
};
}
const [, setModalZIndex] = createSignal(3777);
function useModalZIndex() {
return setModalZIndex((prev) => prev + 1);
}
var _tmpl$$7 = /* @__PURE__ */ template(`<div class="fixed top-0 left-0 bg-black/50 size-full flex items-center justify-center z-[--bae-modal-z-index]"><div class="flex flex-col max-h-[80vh] slim-webkit-scroll md:min-w-96 rounded-md bg-[#232b3a] text-white shadow-[0_0_0_8px_#64646466] overflow-visible"><div class="flex w-full py-3 px-4 round"><div class="text-[#a0aec0] text-xl flex-1"></div></div><div class=p-4>`);
const Modal = (props) => {
const zIndex = useModalZIndex();
return createComponent(Portal, {
get children() {
return createComponent(Show, {
get when() {
return props.shown;
},
get children() {
var _el$ = _tmpl$$7(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild, _el$5 = _el$3.nextSibling;
_el$.$$click = () => {
props.onClose();
};
zIndex != null ? _el$.style.setProperty("--bae-modal-z-index", zIndex) : _el$.style.removeProperty("--bae-modal-z-index");
_el$2.$$click = (e) => {
e.stopPropagation();
};
insert(_el$4, () => props.title);
insert(_el$3, createComponent(Button, {
round: true,
get icon() {
return createComponent(CloseCross, {});
},
get onClick() {
return props.onClose;
}
}), null);
insert(_el$5, () => props.children);
return _el$;
}
});
}
});
};
delegateEvents(["click"]);
function simulateNativeInput(el, value) {
const nativeInputValueSetter = el instanceof HTMLInputElement ? Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, "value").set : Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype, "value").set;
nativeInputValueSetter.call(el, value);
el.dispatchEvent(
new CustomEvent("input", { bubbles: true, detail: { simulated: true } })
);
}
const [inputContent, setInputContent] = createSignal("");
function useDialogWindow(appRoot) {
const memo = createMemo(() => {
const root = appRoot();
if (!(root == null ? void 0 : root.isConnected)) {
return;
}
const bottomBar = root.parentElement.parentElement;
const dialog = bottomBar.previousElementSibling;
const topBar = dialog.previousElementSibling;
const inputArea = bottomBar.querySelector(".css-o3nsyu");
const sendButton = bottomBar.querySelector(
'.css-ks2ywa:has(svg[sprite="/2495daf7694b94d633e1e9925cf85201.svg#paper-plane-usage"])'
);
const openIDModal = async () => {
return await new Promise((resolve) => {
const userButton = topBar.querySelector(".css-1cdmsla");
userButton.click();
requestAnimationFrame(() => {
const editIDMenuItem = document.querySelector(".css-y6z4l5");
editIDMenuItem.click();
requestAnimationFrame(() => {
const closeButton = document.querySelector(".css-1ecu4hv");
const idInput = document.querySelector("#characterName");
const submitButton = document.querySelector(
".css-1pv2q34[type=submit]"
);
resolve({ closeButton, idInput, submitButton });
});
});
});
};
const setID = async (id) => {
const { idInput, submitButton } = await openIDModal();
simulateNativeInput(idInput, id);
submitButton.click();
};
const handleInput = (e) => {
if (!(e instanceof InputEvent)) {
return;
}
setInputContent(e.target.value);
};
inputArea.addEventListener("input", handleInput);
createEffect(
on(
inputContent,
(v) => {
simulateNativeInput(inputArea, v);
},
{ defer: true }
)
);
onCleanup(() => {
inputArea.removeEventListener("input", handleInput);
});
return {
bottomBar,
dialog,
topBar,
inputArea,
sendButton,
inputContent,
setInputContent,
openIDModal,
setID
};
});
return memo;
}
function formatImportString(importString) {
const namePattern = /(?<=\.st )(?:([\p{Script=Han}|\w]+?)(?:[- ]|?))?(.+)/gu;
const nameMatch = namePattern.exec(importString);
if (nameMatch == null) {
return {};
}
const name = nameMatch[1];
const attrString = nameMatch[2];
const attrPattern = /([\p{Script=Han}|\w]+?)(\d+)/gu;
const result = {};
for (let match = attrPattern.exec(attrString); match !== null; match = attrPattern.exec(attrString)) {
result[match[1]] = parseInt(match[2]);
}
return {
name,
attributes: result,
active: false
};
}
const GlobalContext = createContext({
dialog: () => void 0
});
const GlobalProvider = (props) => {
return createComponent(GlobalContext.Provider, props);
};
const useGlobalContext = () => useContext(GlobalContext);
var _tmpl$$6 = /* @__PURE__ */ template(`<table class=tab-center><thead><tr><th>属性名</th><th>属性值</th></tr></thead><tbody>`), _tmpl$2$2 = /* @__PURE__ */ template(`<tr><td></td><td>`);
const AttributeTable = (props) => {
return (() => {
var _el$ = _tmpl$$6(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
insert(_el$3, createComponent(For, {
get each() {
return Object.entries(props.attributes);
},
children: (item) => (() => {
var _el$4 = _tmpl$2$2(), _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling;
insert(_el$5, () => item[0]);
insert(_el$6, () => item[1]);
return _el$4;
})()
}));
return _el$;
})();
};
var _tmpl$$5 = /* @__PURE__ */ template(`<label class="block py-2">导入字符串`), _tmpl$2$1 = /* @__PURE__ */ template(`<div class=mb-4>`), _tmpl$3 = /* @__PURE__ */ template(`<form><div class=mb-4><label class="block py-2">角色名称</label></div><div class=mb-4></div><div class="flex justify-end">`), _tmpl$4 = /* @__PURE__ */ template(`<div><p>支持如下格式:</p><p><span>.st <</span><i>角色名</i><span>> <</span><i>技能名</i><span>><</span><i>数值</i><span>></span></p><p>例如:</p><p>.st 雄狮雷文 力量100智力0STR100INT0`);
const AddCharacterModal = (props) => {
const {
addCharacter,
setActiveCharacter
} = useCharacterStore();
const [newCharacter, setNewCharacter] = createStore({
// eslint-disable-next-line solid/reactivity
name: props.initName ?? "",
importString: "",
// eslint-disable-next-line solid/reactivity
attributes: props.initAttributes ?? {}
});
const {
dialog
} = useGlobalContext();
createEffect(on(() => newCharacter.importString, (val) => {
const resolved = formatImportString(val);
if (resolved.name != null) {
setNewCharacter((prev) => ({
...prev,
name: resolved.name
}));
}
if (resolved.attributes != null) {
setNewCharacter((prev) => ({
...prev,
attributes: resolved.attributes
}));
}
}));
return createComponent(Modal, {
get shown() {
return props.shown;
},
title: "添加身份",
get onClose() {
return props.onClose;
},
get children() {
var _el$ = _tmpl$3(), _el$2 = _el$.firstChild;
_el$2.firstChild;
var _el$4 = _el$2.nextSibling, _el$7 = _el$4.nextSibling;
_el$.addEventListener("submit", (e) => {
e.preventDefault();
void (async () => {
var _a;
addCharacter({
name: newCharacter.name,
attributes: newCharacter.attributes,
active: false
});
setActiveCharacter(newCharacter.name);
void ((_a = dialog()) == null ? void 0 : _a.setID(newCharacter.name));
props.onClose();
})();
});
insert(_el$2, createComponent(Input, {
placeholder: "要导入的角色名称",
get value() {
return newCharacter.name;
},
onInput: (v) => {
setNewCharacter((prev) => ({
...prev,
name: v
}));
}
}), null);
insert(_el$4, createComponent(Popover, {
get content() {
return _tmpl$4();
},
get children() {
return _tmpl$$5();
}
}), null);
insert(_el$4, createComponent(Input, {
placeholder: "请将骰娘导入字符串粘贴到这里",
get value() {
return newCharacter.importString;
},
onInput: (v) => {
setNewCharacter((prev) => ({
...prev,
importString: v
}));
}
}), null);
insert(_el$, createComponent(Show, {
get when() {
return Object.keys(newCharacter.attributes).length !== 0;
},
get children() {
var _el$6 = _tmpl$2$1();
insert(_el$6, createComponent(AttributeTable, {
get attributes() {
return newCharacter.attributes;
}
}));
return _el$6;
}
}), _el$7);
insert(_el$7, createComponent(Button, {
type: "submit",
variant: "primary",
children: "添加并启用"
}));
return _el$;
}
});
};
var _tmpl$$4 = /* @__PURE__ */ template(`<table class=tab-center><thead><tr><th>角色名</th><th>当前使用</th><th>操作</th></tr></thead><tbody>`), _tmpl$2 = /* @__PURE__ */ template(`<tr><td></td><td></td><td class="flex justify-around">`);
const CharacterTable = () => {
const {
characterList: characterList2,
setCharacterList: setCharacterList2,
setActiveCharacter
} = useCharacterStore();
const [editShown, setEditShown] = createSignal(false);
const {
dialog
} = useGlobalContext();
return (() => {
var _el$ = _tmpl$$4(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
insert(_el$3, createComponent(For, {
get each() {
return characterList2();
},
children: (item) => (() => {
var _el$4 = _tmpl$2(), _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$6.nextSibling;
insert(_el$4, createComponent(AddCharacterModal, {
get initAttributes() {
return item.attributes;
},
get initName() {
return item.name;
},
get shown() {
return editShown();
},
onClose: () => {
setEditShown(false);
}
}), _el$5);
insert(_el$5, () => item.name);
insert(_el$6, () => item.active ? "是" : "否");
insert(_el$7, createComponent(Button, {
variant: "primary",
onClick: () => {
var _a;
setActiveCharacter(item.name);
void ((_a = dialog()) == null ? void 0 : _a.setID(item.name));
},
children: "启用"
}), null);
insert(_el$7, createComponent(Button, {
variant: "primary",
onClick: () => {
setEditShown(true);
},
children: "重新导入"
}), null);
insert(_el$7, createComponent(Button, {
variant: "plain",
onClick: () => {
setCharacterList2((prev) => {
const newList = (prev == null ? void 0 : prev.filter((i) => i.name !== item.name)) ?? [];
return newList;
});
},
children: "删除"
}), null);
return _el$4;
})()
}));
return _el$;
})();
};
const CharacterListModal = (props) => {
return createComponent(Modal, {
get shown() {
return props.shown;
},
title: "身份列表",
get onClose() {
return props.onClose;
},
get children() {
return createComponent(CharacterTable, {});
}
});
};
var _tmpl$$3 = /* @__PURE__ */ template(`<span class="inline-flex h-10 items-center bg-slate-950 bg-opacity-30 rounded cursor-pointer"role=button><span class="p-1 m-2 rounded text-xs bg-slate-500"></span><span class="p-1 m-2 rounded text-xs bg-slate-500">`);
const Suggestion = (props) => {
return createComponent(Popover, {
content: "点击替换",
get children() {
var _el$ = _tmpl$$3(), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling;
_el$.$$click = () => {
props.onClick();
};
insert(_el$2, () => props.original);
insert(_el$, createComponent(Icon, {
get children() {
return createComponent(ArrowRight, {});
}
}), _el$3);
insert(_el$3, () => props.replacement);
return _el$;
}
});
};
delegateEvents(["click"]);
const getReplacementSuggestions = (text, attributes) => {
if (text === "" || Object.keys(attributes).length === 0) {
return [];
}
const pattern = new RegExp(Object.keys(attributes).join("|"), "g");
const matches = text.matchAll(pattern);
const suggestions = [];
for (const item of matches) {
const original = item[0];
const replacement = attributes[original].toString();
suggestions.push({
start: item.index,
end: item.index + original.length,
original,
replacement
});
}
return suggestions;
};
const replaceAttribute = (text, suggestion) => {
return text.slice(0, suggestion.start) + suggestion.replacement + text.slice(suggestion.end);
};
var _tmpl$$2 = /* @__PURE__ */ template(`<div class="flex-1 grid grid-rows-1 grid-flow-col gap-2">`);
const SuggestionList = (props) => {
const {
activeCharacter
} = useCharacterStore();
const {
dialog
} = useGlobalContext();
const suggestions = createMemo(() => {
var _a, _b;
return getReplacementSuggestions(((_a = dialog()) == null ? void 0 : _a.inputContent()) ?? "", ((_b = activeCharacter()) == null ? void 0 : _b.attributes) ?? {});
});
createEffect(on(() => ({
suggestions: suggestions(),
auto: props.autoReplacement,
dialog: dialog()
}), ({
suggestions: suggestions2,
auto,
dialog: dialog2
}) => {
if (auto) {
const suggestion = suggestions2[0];
if (suggestion != null) {
dialog2 == null ? void 0 : dialog2.setInputContent((prev) => replaceAttribute(prev, suggestion));
}
}
}));
return (() => {
var _el$ = _tmpl$$2();
insert(_el$, createComponent(For, {
get each() {
return suggestions();
},
children: (item) => createComponent(Suggestion, mergeProps(item, {
onClick: () => {
var _a;
(_a = dialog()) == null ? void 0 : _a.setInputContent((prev) => replaceAttribute(prev, item));
}
}))
}));
return _el$;
})();
};
var _tmpl$$1 = /* @__PURE__ */ template(`<div class="flex flex-row"><div class="flex flex-row"><div class=mr-1></div><div class=mr-2></div><div class=mr-1>`);
const App = () => {
const [root, setRoot] = createSignal(void 0, {
equals: false
});
const [autoReplacement, setAutoReplacement] = createSignal(false);
const [characterListShown, setCharacterListShown] = createSignal(false);
const [addCharacterShown, setAddCharacterShown] = createSignal(false);
const dialog = useDialogWindow(root);
onMount(() => {
setRoot((prev) => prev);
});
return createComponent(GlobalProvider, {
value: {
dialog
},
get children() {
var _el$ = _tmpl$$1(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.nextSibling, _el$5 = _el$4.nextSibling;
use(setRoot, _el$);
insert(_el$, createComponent(CharacterListModal, {
get shown() {
return characterListShown();
},
onClose: () => {
setCharacterListShown(false);
}
}), _el$2);
insert(_el$, createComponent(AddCharacterModal, {
get shown() {
return addCharacterShown();
},
onClose: () => {
setAddCharacterShown(false);
}
}), _el$2);
insert(_el$3, createComponent(Popover, {
content: "添加身份",
get children() {
return createComponent(Switch, {
onClick: () => {
setAddCharacterShown(true);
},
get children() {
return createComponent(Icon, {
get children() {
return createComponent(AddUser, {});
}
});
}
});
}
}));
insert(_el$4, createComponent(Popover, {
content: "自动属性值替换",
get children() {
return createComponent(Switch, {
get value() {
return autoReplacement();
},
onClick: () => {
setAutoReplacement((v) => !v);
},
get children() {
return createComponent(Icon, {
get children() {
return createComponent(Replace, {});
}
});
}
});
}
}));
insert(_el$5, createComponent(Popover, {
content: "身份管理",
get children() {
return createComponent(Switch, {
onClick: () => {
setCharacterListShown(true);
},
get children() {
return createComponent(Icon, {
get children() {
return createComponent(Ninja, {});
}
});
}
});
}
}));
insert(_el$2, createComponent(SuggestionList, {
get autoReplacement() {
return autoReplacement();
}
}), null);
return _el$;
}
});
};
var _tmpl$ = /* @__PURE__ */ template(`<div class="col-start-1 col-end-4">`);
function renderApp(mountPoint) {
mountPoint.style.rowGap = "5px";
mountPoint.style.columnGap = "5px";
const root = _tmpl$();
mountPoint.appendChild(root);
render(() => createComponent(App, {}), root);
}
const mutationObserver = new MutationObserver((mutations) => {
const newMountPoints = document.querySelectorAll(".css-1pgii3c:not([boluo-attribute-extension-loaded])");
newMountPoints.forEach((mountPoint) => {
mountPoint.setAttribute("boluo-attribute-extension-loaded", "");
renderApp(mountPoint);
});
});
mutationObserver.observe(document.body, {
childList: true,
subtree: true
});
})();