/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ "use strict"; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var __publicField = (obj, key, value) => { __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); return value; }; // src/main.ts var main_exports = {}; __export(main_exports, { default: () => main_default }); module.exports = __toCommonJS(main_exports); // src/plugin.ts var import_obsidian6 = require("obsidian"); // node_modules/solid-js/dist/solid.js var sharedConfig = {}; function setHydrateContext(context) { sharedConfig.context = context; } function nextHydrateContext() { return { ...sharedConfig.context, id: `${sharedConfig.context.id}${sharedConfig.context.count++}-`, count: 0 }; } var equalFn = (a, b) => a === b; var $PROXY = Symbol("solid-proxy"); var $TRACK = Symbol("solid-track"); var $DEVCOMP = Symbol("solid-dev-component"); var signalOptions = { equals: equalFn }; var ERROR = null; var runEffects = runQueue; var STALE = 1; var PENDING = 2; var UNOWNED = { owned: null, cleanups: null, context: null, owner: null }; var Owner = null; var Transition = null; var Scheduler = null; var ExternalSourceFactory = null; var Listener = null; var Updates = null; var Effects = null; var ExecCount = 0; var [transPending, setTransPending] = /* @__PURE__ */ createSignal(false); function createRoot(fn, detachedOwner) { const listener = Listener, owner = Owner, unowned = fn.length === 0, root = unowned && true ? UNOWNED : { owned: null, cleanups: null, context: null, owner: detachedOwner || owner }, 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") { if (Transition && Transition.running && Transition.sources.has(s)) value2 = value2(s.tValue); else value2 = value2(s.value); } return writeSignal(s, value2); }; return [readSignal.bind(s), setter]; } function createRenderEffect(fn, value, options) { const c = createComputation(fn, value, false, STALE); if (Scheduler && Transition && Transition.running) Updates.push(c); else updateComputation(c); } function createEffect(fn, value, options) { runEffects = runUserEffects; const c = createComputation(fn, value, false, STALE), s = SuspenseContext && lookup(Owner, SuspenseContext.id); if (s) c.suspense = s; 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; if (Scheduler && Transition && Transition.running) { c.tState = STALE; Updates.push(c); } else updateComputation(c); return readSignal.bind(c); } function untrack(fn) { let result, listener = Listener; Listener = null; result = fn(); Listener = listener; 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 onError(fn) { ERROR || (ERROR = Symbol("error")); if (Owner === null) ; else if (Owner.context === null) Owner.context = { [ERROR]: [fn] }; else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn]; else Owner.context[ERROR].push(fn); } function startTransition(fn) { if (Transition && Transition.running) { fn(); return Transition.done; } const l = Listener; const o = Owner; return Promise.resolve().then(() => { Listener = l; Owner = o; let t; if (Scheduler || SuspenseContext) { t = Transition || (Transition = { sources: /* @__PURE__ */ new Set(), effects: [], promises: /* @__PURE__ */ new Set(), disposed: /* @__PURE__ */ new Set(), queue: /* @__PURE__ */ new Set(), running: true }); t.done || (t.done = new Promise((res) => t.resolve = res)); t.running = true; } runUpdates(fn, false); Listener = Owner = null; return t ? t.done : void 0; }); } function createContext(defaultValue) { 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 memo2 = createMemo(() => resolveChildren(children2())); memo2.toArray = () => { const c = memo2(); return Array.isArray(c) ? c : c != null ? [c] : []; }; return memo2; } var SuspenseContext; function readSignal() { const runningTransition = Transition && Transition.running; if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) { if (!runningTransition && this.state === STALE || runningTransition && this.tState === 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); } } if (runningTransition && Transition.sources.has(this)) return this.tValue; return this.value; } function writeSignal(node, value, isComp) { let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value; if (!node.comparator || !node.comparator(current, value)) { if (Transition) { const TransitionRunning = Transition.running; if (TransitionRunning || !isComp && Transition.sources.has(node)) { Transition.sources.add(node); node.tValue = value; } if (!TransitionRunning) node.value = value; } else 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)) continue; if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) { if (o.pure) Updates.push(o); else Effects.push(o); if (o.observers) markDownstream(o); } if (TransitionRunning) o.tState = STALE; else 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 owner = Owner, listener = Listener, time = ExecCount; Listener = Owner = node; runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time); if (Transition && !Transition.running && Transition.sources.has(node)) { queueMicrotask(() => { runUpdates(() => { Transition && (Transition.running = true); runComputation(node, node.tValue, time); }, false); }); } Listener = listener; Owner = owner; } function runComputation(node, value, time) { let nextValue; try { nextValue = node.fn(value); } catch (err) { if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE; handleError(err); } if (!node.updatedAt || node.updatedAt <= time) { if (node.updatedAt != null && "observers" in node) { writeSignal(node, nextValue, true); } else if (Transition && Transition.running && node.pure) { Transition.sources.add(node); node.tValue = 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: null, pure }; if (Transition && Transition.running) { c.state = 0; c.tState = state; } if (Owner === null) ; else if (Owner !== UNOWNED) { if (Transition && Transition.running && Owner.pure) { if (!Owner.tOwned) Owner.tOwned = [c]; else Owner.tOwned.push(c); } else { if (!Owner.owned) Owner.owned = [c]; else Owner.owned.push(c); } } if (ExternalSourceFactory) { const [track, trigger] = createSignal(void 0, { equals: false }); const ordinary = ExternalSourceFactory(c.fn, trigger); onCleanup(() => ordinary.dispose()); const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose()); const inTransition = ExternalSourceFactory(c.fn, triggerInTransition); c.fn = (x) => { track(); return Transition && Transition.running ? inTransition.track(x) : ordinary.track(x); }; } return c; } function runTop(node) { const runningTransition = Transition && Transition.running; if (!runningTransition && node.state === 0 || runningTransition && node.tState === 0) return; if (!runningTransition && node.state === PENDING || runningTransition && node.tState === 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 (runningTransition && Transition.disposed.has(node)) return; if (!runningTransition && node.state || runningTransition && node.tState) ancestors.push(node); } for (let i = ancestors.length - 1; i >= 0; i--) { node = ancestors[i]; if (runningTransition) { let top = node, prev = ancestors[i + 1]; while ((top = top.owner) && top !== prev) { if (Transition.disposed.has(top)) return; } } if (!runningTransition && node.state === STALE || runningTransition && node.tState === STALE) { updateComputation(node); } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === 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 (!Updates) Effects = null; handleError(err); } } function completeUpdates(wait) { if (Updates) { if (Scheduler && Transition && Transition.running) scheduleQueue(Updates); else runQueue(Updates); Updates = null; } if (wait) return; let res; if (Transition && Transition.running) { if (Transition.promises.size || Transition.queue.size) { Transition.running = false; Transition.effects.push.apply(Transition.effects, Effects); Effects = null; setTransPending(true); return; } const sources = Transition.sources; const disposed = Transition.disposed; res = Transition.resolve; for (const e2 of Effects) { "tState" in e2 && (e2.state = e2.tState); delete e2.tState; } Transition = null; runUpdates(() => { for (const d of disposed) cleanNode(d); for (const v of sources) { v.value = v.tValue; if (v.owned) { for (let i = 0, len = v.owned.length; i < len; i++) cleanNode(v.owned[i]); } if (v.tOwned) v.owned = v.tOwned; delete v.tValue; delete v.tOwned; v.tState = 0; } setTransPending(false); }, false); } const e = Effects; Effects = null; if (e.length) runUpdates(() => runEffects(e), false); if (res) res(); } function runQueue(queue) { for (let i = 0; i < queue.length; i++) runTop(queue[i]); } function scheduleQueue(queue) { for (let i = 0; i < queue.length; i++) { const item = queue[i]; const tasks = Transition.queue; if (!tasks.has(item)) { tasks.add(item); Scheduler(() => { tasks.delete(item); runUpdates(() => { Transition.running = true; runTop(item); if (!tasks.size) { Effects.push.apply(Effects, Transition.effects); Transition.effects = []; } }, false); Transition && (Transition.running = false); }); } } } 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; } if (sharedConfig.context) setHydrateContext(); for (i = 0; i < userLength; i++) runTop(queue[i]); } function lookUpstream(node, ignore) { const runningTransition = Transition && Transition.running; if (runningTransition) node.tState = 0; else node.state = 0; for (let i = 0; i < node.sources.length; i += 1) { const source = node.sources[i]; if (source.sources) { if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) { if (source !== ignore) runTop(source); } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookUpstream(source, ignore); } } } function markDownstream(node) { const runningTransition = Transition && Transition.running; for (let i = 0; i < node.observers.length; i += 1) { const o = node.observers[i]; if (!runningTransition && !o.state || runningTransition && !o.tState) { if (runningTransition) o.tState = PENDING; else 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 (Transition && Transition.running && node.pure) { if (node.tOwned) { for (i = 0; i < node.tOwned.length; i++) cleanNode(node.tOwned[i]); delete node.tOwned; } reset(node, true); } else if (node.owned) { for (i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]); node.owned = null; } if (node.cleanups) { for (i = 0; i < node.cleanups.length; i++) node.cleanups[i](); node.cleanups = null; } if (Transition && Transition.running) node.tState = 0; else node.state = 0; node.context = null; } function reset(node, top) { if (!top) { node.tState = 0; Transition.disposed.add(node); } if (node.owned) { for (let i = 0; i < node.owned.length; i++) reset(node.owned[i]); } } function castError(err) { if (err instanceof Error || typeof err === "string") return err; return new Error("Unknown error"); } function handleError(err) { err = castError(err); const fns = ERROR && lookup(Owner, ERROR); if (!fns) throw err; for (const f of fns) f(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 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) { return function provider(props) { let res; createRenderEffect(() => res = untrack(() => { Owner.context = { [id]: props.value }; return children(() => props.children); })); return res; }; } var 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() || [], i, 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]; 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]); } }; } var hydrationEnabled = false; function createComponent(Comp, props) { if (hydrationEnabled) { if (sharedConfig.context) { const c = sharedConfig.context; setHydrateContext(nextHydrateContext()); const r = untrack(() => Comp(props || {})); setHydrateContext(c); return r; } } return untrack(() => Comp(props || {})); } function For(props) { const fallback = "fallback" in props && { fallback: () => props.fallback }; return createMemo(mapArray(() => props.each, props.children, fallback ? fallback : void 0)); } function Show(props) { let strictEqual = false; const keyed = props.keyed; const condition = createMemo(() => props.when, void 0, { equals: (a, b) => strictEqual ? a === b : !a === !b }); return createMemo(() => { const c = condition(); if (c) { const child = props.children; const fn = typeof child === "function" && child.length > 0; strictEqual = keyed || fn; return fn ? untrack(() => child(c)) : child; } return props.fallback; }); } function Switch(props) { let strictEqual = false; let keyed = false; const conditions = children(() => props.children), evalConditions = createMemo(() => { let conds = conditions(); if (!Array.isArray(conds)) conds = [conds]; for (let i = 0; i < conds.length; i++) { const c = conds[i].when; if (c) { keyed = !!conds[i].keyed; return [i, c, conds[i]]; } } return [-1]; }, void 0, { equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2] }); return createMemo(() => { const [index, when, cond] = evalConditions(); if (index < 0) return props.fallback; const c = cond.children; const fn = typeof c === "function" && c.length > 0; strictEqual = keyed || fn; return fn ? untrack(() => c(when)) : c; }); } function Match(props) { return props; } var Errors; function ErrorBoundary(props) { let err; let v; if (sharedConfig.context && sharedConfig.load && (v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))) err = v[0]; const [errored, setErrored] = createSignal(err); Errors || (Errors = /* @__PURE__ */ new Set()); Errors.add(setErrored); onCleanup(() => Errors.delete(setErrored)); return createMemo(() => { let e; if (e = errored()) { const f = props.fallback; const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f; onError(setErrored); return res; } onError(setErrored); return props.children; }); } var SuspenseListContext = createContext(); // node_modules/solid-js/web/dist/web.js var 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"]; var Properties = /* @__PURE__ */ new Set(["className", "value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]); function memo(fn, equals) { return createMemo(fn, void 0, !equals ? { equals } : void 0); } 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(); } } } var $$EVENTS = "_$DX_DELEGATE"; function render(code, element, init) { let disposer; createRoot((dispose2) => { disposer = dispose2; element === document ? code() : insert(element, code(), element.firstChild ? null : void 0, init); }); return () => { disposer(); element.textContent = ""; }; } function template(html, check, isSVG) { const t = document.createElement("template"); t.innerHTML = html; let node = t.content.firstChild; if (isSVG) node = node.firstChild; return node; } 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 className(node, value) { if (value == null) node.removeAttribute("class"); else node.className = value; } 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 eventHandler(e) { const key = `$$${e.type}`; let node = e.composedPath && e.composedPath()[0] || e.target; if (e.target !== node) { Object.defineProperty(e, "target", { configurable: true, value: node }); } Object.defineProperty(e, "currentTarget", { configurable: true, get() { return node || document; } }); if (sharedConfig.registry && !sharedConfig.done) { sharedConfig.done = true; document.querySelectorAll("[id^=pl-]").forEach((elem) => elem.remove()); } while (node !== null) { 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 = node.host && node.host !== node && node.host instanceof Node ? node.host : node.parentNode; } } 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 t = typeof value, multi = marker !== void 0; parent = multi && current[0] && current[0].parentNode || parent; if (t === "string" || t === "number") { if (sharedConfig.context) return current; if (t === "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 || t === "boolean") { if (sharedConfig.context) return current; 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 (sharedConfig.context) { if (!array.length) return current; for (let i = 0; i < array.length; i++) { if (array[i].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, unwrap) { let dynamic = false; for (let i = 0, len = array.length; i < len; i++) { let item = array[i], prev = current && current[i]; 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 (unwrap) { 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) { 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]; } // src/sidebarView.tsx var import_obsidian5 = require("obsidian"); // src/settings.ts var import_obsidian = require("obsidian"); function isOpen(depth, mode) { if (mode == "expanded") { return true; } if (mode == "leaf-collapsed" && depth == 0) { return true; } if (mode == "root-collapsed" && depth != 0) { return true; } return false; } var DEFAULT_SETTINGS = { expansionMode: "expanded", ignoreNulls: false, nullValue: "", skipKey: "metatable", filterKeys: ["metatable", "frontmatter"], filterMode: "ignore", autolinks: false, naked: false, theme: "light" }; var MetatableSettingTab = class extends import_obsidian.PluginSettingTab { constructor(app, plugin) { super(app, plugin); __publicField(this, "plugin"); this.plugin = plugin; } async display() { const { containerEl, plugin } = this; containerEl.empty(); containerEl.createEl("h2", { text: "Metatable Settings" }); new import_obsidian.Setting(containerEl).setName("Expansion level").setDesc("Level of expansion of the metatable tree").addDropdown((drop) => drop.addOption("expanded", "Fully expanded").addOption("leaf-collapsed", "Collapse leafs").addOption("all-collapsed", "Collapse all").addOption("root-collapsed", "Collapse root").setValue(plugin.settings.expansionMode).onChange(async (value) => { plugin.settings.expansionMode = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Skip key").setDesc("When this key is found and `true`, the metatable will not be displayed").addText((text) => text.setValue(plugin.settings.skipKey).onChange(async (value) => { plugin.settings.skipKey = value; await plugin.saveSettings(); })); containerEl.createEl("h3", { text: "Nulls" }); new import_obsidian.Setting(containerEl).setName("Ignore null values").setDesc("Ignore any member with a null value.").addToggle((setting) => setting.setValue(plugin.settings.ignoreNulls).onChange(async (value) => { plugin.settings.ignoreNulls = value; await plugin.saveSettings(); this.display(); })); if (!plugin.settings.ignoreNulls) { new import_obsidian.Setting(containerEl).setName("Null value").setDesc("Text to show when a key has no value. Defaults to nothing").addText((text) => text.setValue(plugin.settings.nullValue).onChange(async (value) => { plugin.settings.nullValue = value; await plugin.saveSettings(); })); } containerEl.createEl("h3", { text: "Filter" }); new import_obsidian.Setting(containerEl).setName("Filter mode").setDesc("Either ignore or keep the filter keys").addDropdown((drop) => drop.addOption("ignore", "Ignore").addOption("keep", "Keep").setValue(plugin.settings.filterMode).onChange(async (value) => { plugin.settings.filterMode = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Filter keys").setDesc("Any empty field will be ignored."); let keyset = plugin.settings.filterKeys; let filterKeys2 = containerEl.createEl("ol"); for (const [idx, originalValue] of [...keyset].entries()) { if (originalValue === "") { continue; } addFilterInput(originalValue, filterKeys2, keyset, plugin, idx); } new import_obsidian.Setting(containerEl).addButton((x) => x.setButtonText("Add key").onClick(async () => { addFilterInput("", filterKeys2, keyset, plugin, keyset.length); })); containerEl.createEl("h3", { text: "Experimental" }); new import_obsidian.Setting(containerEl).setName("Autolink").setDesc("Enables autolinks for wikilinks `[[target]]`, frontmatter links `%target%` and local links `./deep/target`").addToggle((setting) => setting.setValue(plugin.settings.autolinks).onChange(async (value) => { plugin.settings.autolinks = value; await plugin.saveSettings(); })); new import_obsidian.Setting(containerEl).setName("Naked").setDesc("Removes the Shadow DOM and the default CSS so you can bring your own via CSS snippets.").addToggle((setting) => setting.setValue(plugin.settings.naked).onChange(async (value) => { plugin.settings.naked = value; await plugin.saveSettings(); })); } }; function addFilterInput(originalValue, el, keyset, plugin, idx) { const item = el.createEl("li"); const input = item.createEl("input"); item.setAttribute("id", `filter-${idx}`); input.setAttribute("type", "text"); input.setAttribute("value", originalValue); input.setAttribute("data-prev", originalValue); input.addEventListener("input", async (e) => { let target = e.target; keyset[idx] = target.value; input.setAttribute("data-prev", target.value); plugin.settings.filterKeys = keyset; await plugin.saveSettings(); }); } // src/value.ts function isLeaf(value) { return value === null || ["string", "number", "boolean"].some((kind) => typeof value == kind); } function isSet(value) { return value !== null && typeof value == "object" && !Array.isArray(value); } function isEmptyValue(value) { if (typeof value == "string" || Array.isArray(value)) { return value.length == 0; } if (typeof value == "object" && value != null) { return Object.keys(value).length == 0; } return value == null; } // src/core.ts function observeTheme(el) { const observer = new MutationObserver((mutationList) => { mutationList.forEach((mutation) => { const target = mutation.target; if (target.hasClass("theme-light")) { el.classList.add("light"); el.classList.remove("dark"); } else { el.classList.add("dark"); el.classList.remove("light"); } }); }); const body = document.querySelector("body"); observer.observe(body, { attributes: true, attributeFilter: ["class"] }); return observer; } function queryTheme() { const body = document.querySelector("body"); return body.hasClass("theme-light") ? "light" : "dark"; } function cleanData(data, settings) { if (data === void 0 || data === null) { return; } if (typeof data == "string") { return; } if (data[settings.skipKey] === true) { return; } let entries = Object.entries(data); entries = filterKeys(entries, settings.filterKeys, settings.filterMode); if (settings.ignoreNulls) { entries = filterNulls(entries); } entries = normalise(entries); return entries.length == 0 ? void 0 : Object.fromEntries(entries); } function normalise(entries) { return entries.map(([key, value]) => { if (key.toLocaleLowerCase() == "tags") { return [key, normaliseTags(value)]; } return [key, value]; }); } function normaliseTags(data) { if (data == null) { return []; } if (!Array.isArray(data) && typeof data != "string") { throw new Error("Tags must be an array or a string"); } const result = typeof data == "string" ? data.split(",").map((x) => x.trim()) : data; return result.filter((x) => x && x.length != 0); } function filterKeys(entries, keys, mode) { const predicate = mode == "ignore" ? (x) => !x : (x) => x; return entries.filter(([key, _value]) => predicate(keys.some((x) => x === key))); } function filterNulls(entries) { return entries.filter(([_key, value]) => !isEmptyValue(value)); } // src/mixture.tsx function useMixture() { return useContext(MixtureContext); } var MixtureContext = createContext(); function MixtureProvider(props) { const app = props.app; const settings = props.settings; const workspace = app.workspace; const searchFn = app.internalPlugins.getPluginById("global-search").instance.openGlobalSearch.bind(app.workspace); const openLinkFn = app.workspace.openLinkText.bind(app.workspace); onCleanup(() => { props.themeObserver.disconnect(); }); const mixture = { app, workspace, settings, search(term) { searchFn(term); }, isOpen(depth) { return isOpen(depth, settings.expansionMode); }, isNaked: settings.naked, openTag(tag) { searchFn(`tag:${tag}`); }, openNote(note) { openLinkFn(note, ""); }, cleanData: (data) => cleanData(data, settings) }; return createComponent(MixtureContext.Provider, { value: mixture, get children() { return props.children; } }); } // src/components/Sidebar.tsx var import_obsidian4 = require("obsidian"); // src/components/List.tsx var _tmpl$ = /* @__PURE__ */ template(``, 2); var _tmpl$2 = /* @__PURE__ */ template(`
  • `, 2); function List(props) { const name = `list-${props.key}`; return createComponent(Show, { get when() { return props.value.length > 0; }, get children() { const _el$ = _tmpl$.cloneNode(true); className(_el$, `list ${name}`); setAttribute(_el$, "part", `list ${name}`); insert(_el$, createComponent(For, { get each() { return props.value; }, children: (item, index) => (() => { const _el$2 = _tmpl$2.cloneNode(true); insert(_el$2, () => createComponent(Value, { get key() { return props.key; }, get depth() { return props.depth; }, value: item })); createRenderEffect((_p$) => { const _v$ = `${props.key}-${index()}`, _v$2 = `list-item list-item-${props.key}`; _v$ !== _p$._v$ && setAttribute(_el$2, "id", _p$._v$ = _v$); _v$2 !== _p$._v$2 && setAttribute(_el$2, "part", _p$._v$2 = _v$2); return _p$; }, { _v$: void 0, _v$2: void 0 }); return _el$2; })() })); return _el$; } }); } // src/components/Member.tsx var _tmpl$3 = /* @__PURE__ */ template(``, 2); var _tmpl$22 = /* @__PURE__ */ template(``, 2); var _tmpl$32 = /* @__PURE__ */ template(``, 2); var _tmpl$4 = /* @__PURE__ */ template(`

    Error:

    `, 2); var _tmpl$5 = /* @__PURE__ */ template(``, 4); var _tmpl$6 = /* @__PURE__ */ template(`
    `, 2); function Member(props) { const { cleanData: cleanData2, isOpen: isOpen2, settings } = useMixture(); const data = () => { var _a; return isSet(props.value) ? (_a = cleanData2(props.value)) != null ? _a : {} : props.value; }; const depth = () => props.depth + 1; return createComponent(ErrorBoundary, { fallback: (error) => (() => { const _el$5 = _tmpl$4.cloneNode(true), _el$6 = _el$5.firstChild; insert(_el$5, error, null); return _el$5; })(), get children() { return createComponent(Show, { get when() { return !(isEmptyValue(data()) && settings.ignoreNulls); }, get children() { const _el$ = _tmpl$32.cloneNode(true); insert(_el$, createComponent(Switch, { get children() { return [createComponent(Match, { get when() { return !isLeaf(props.value); }, get children() { return [createComponent(Key, { get target() { return props.id; }, get expanded() { return isOpen2(depth()); }, get children() { return props.key; } }), (() => { const _el$2 = _tmpl$3.cloneNode(true); insert(_el$2, createComponent(Value, { get key() { return props.key; }, get depth() { return depth(); }, get value() { return data(); } }), null); insert(_el$2, createComponent(Marker, {}), null); createRenderEffect(() => setAttribute(_el$2, "id", props.id)); return _el$2; })()]; } }), createComponent(Match, { get when() { return isLeaf(props.value); }, get children() { return [(() => { const _el$3 = _tmpl$22.cloneNode(true); insert(_el$3, () => props.key); createRenderEffect(() => setAttribute(_el$3, "title", props.key)); return _el$3; })(), (() => { const _el$4 = _tmpl$3.cloneNode(true); insert(_el$4, createComponent(Value, { get key() { return props.key; }, get depth() { return props.depth; }, get value() { return data(); } })); createRenderEffect(() => setAttribute(_el$4, "id", props.id)); return _el$4; })()]; } })]; } })); return _el$; } }); } }); } function Key(props) { const [isExpanded, setIsExpanded] = createSignal(props.expanded); const togglePart = () => isExpanded() ? "expanded" : "collapsed"; const handler = (event) => { event.stopPropagation(); event.preventDefault(); setIsExpanded(!isExpanded()); }; const clickHandler = (event) => handler(event); const keyHandler = (event) => { if (event.code == "Space" || event.code == "Enter") { handler(event); } }; return (() => { const _el$7 = _tmpl$5.cloneNode(true), _el$8 = _el$7.firstChild; _el$7.$$keydown = keyHandler; _el$7.$$click = clickHandler; insert(_el$8, () => props.children); createRenderEffect((_p$) => { const _v$ = `key toggle ${togglePart()}`, _v$2 = isExpanded(), _v$3 = props.target, _v$4 = props.children; _v$ !== _p$._v$ && setAttribute(_el$7, "part", _p$._v$ = _v$); _v$2 !== _p$._v$2 && setAttribute(_el$7, "aria-expanded", _p$._v$2 = _v$2); _v$3 !== _p$._v$3 && setAttribute(_el$7, "aria-controls", _p$._v$3 = _v$3); _v$4 !== _p$._v$4 && setAttribute(_el$7, "title", _p$._v$4 = _v$4); return _p$; }, { _v$: void 0, _v$2: void 0, _v$3: void 0, _v$4: void 0 }); return _el$7; })(); } function Marker() { return _tmpl$6.cloneNode(true); } delegateEvents(["click", "keydown"]); // src/components/Set.tsx var _tmpl$7 = /* @__PURE__ */ template(`
    `, 2); function Set2(props) { const name = `set-${props.key}`; return (() => { const _el$ = _tmpl$7.cloneNode(true); className(_el$, `set ${name}`); setAttribute(_el$, "part", `set ${name}`); insert(_el$, createComponent(For, { get each() { return Object.entries(props.value); }, children: ([key, value], index) => createComponent(Member, { get id() { return `${key}-${index()}`; }, get depth() { return props.depth; }, key, value }) })); return _el$; })(); } // src/components/Tag.tsx var _tmpl$8 = /* @__PURE__ */ template(``, 2); function Tag(props) { const { openTag } = useMixture(); const safeValue = encodeURI(props.value); const url = `#${safeValue}`; const clickHandler = (event) => { const trigger = event.target; event.preventDefault(); openTag(trigger.getAttribute("href")); }; return (() => { const _el$ = _tmpl$8.cloneNode(true); _el$.$$click = clickHandler; setAttribute(_el$, "href", url); setAttribute(_el$, "data-href", url); setAttribute(_el$, "part", `tag ${safeValue}`); insert(_el$, () => props.value); return _el$; })(); } delegateEvents(["click"]); // src/components/InternalLink.tsx var import_obsidian2 = require("obsidian"); var _tmpl$9 = /* @__PURE__ */ template(``, 2); function InternalLink(props) { const value = props.value; return createComponent(Switch, { get children() { return [createComponent(Match, { get when() { return isWikiLink(value); }, get children() { return createComponent(WikiLink, { value }); } }), createComponent(Match, { get when() { return isFrontmatterLink(value); }, get children() { return createComponent(FrontmatterLink, { value }); } }), createComponent(Match, { get when() { return isLocalLink(value); }, get children() { return createComponent(LocalLink, { value }); } }), createComponent(Match, { get when() { return isObsidianUrl(value); }, get children() { return createComponent(ObsidianLink, { value }); } })]; } }); } function isInternalLink(value) { return isWikiLink(value) || isFrontmatterLink(value) || isLocalLink(value) || isObsidianUrl(value); } function WikiLink(props) { let value = props.value.slice(2, -2); let url; let label; if (value.includes("|")) { const [urlValue, labelValue] = value.split("|"); url = urlValue.trim(); label = labelValue.trim(); } else { label = value; url = value; } return createComponent(Link, { label, url }); } function isWikiLink(value) { return value.startsWith("[[") && value.endsWith("]]"); } function FrontmatterLink(props) { let value = props.value.slice(1, -1); let url; let label; if (value.includes("|")) { const [urlValue, labelValue] = value.split("|"); url = urlValue.trim(); label = labelValue.trim(); } else { label = value; url = value; } return createComponent(Link, { label, url }); } function isFrontmatterLink(value) { return value.startsWith("%") && value.endsWith("%"); } function LocalLink(props) { return createComponent(Link, { get label() { return props.value; }, get url() { return props.value; } }); } function isLocalLink(value) { return value.startsWith("./") || value.startsWith("../"); } function ObsidianLink(props) { return createComponent(Link, { get label() { return props.value; }, get url() { return props.value; } }); } function isObsidianUrl(url) { return url instanceof URL && url.protocol == "obsidian:"; } function Link(props) { const { openNote } = useMixture(); const label = props.label; const url = props.url; const localUrl = encodeURI((0, import_obsidian2.getLinkpath)(url)); const clickHandler = (event) => { event.preventDefault(); openNote(event.target.dataset.href); }; return (() => { const _el$ = _tmpl$9.cloneNode(true); _el$.$$click = clickHandler; setAttribute(_el$, "href", localUrl); setAttribute(_el$, "data-href", localUrl); insert(_el$, label); return _el$; })(); } delegateEvents(["click"]); // src/components/ExternalLink.tsx var _tmpl$10 = /* @__PURE__ */ template(``, 2); function ExternalLink(props) { return createComponent(Link2, { get label() { return props.value; }, get url() { return props.value; } }); } function isExternalLink(value) { const url = tryUrl(value); return isUrl(url); } function isUrl(url) { const allowedProtocols = ["http:", "https:", "evernote:", "zotero:"]; return url instanceof URL && allowedProtocols.some((protocol) => url.protocol == protocol); } function tryUrl(value) { try { return new URL(value); } catch (_) { return value; } } function Link2(props) { const label = props.label; const url = props.url; return (() => { const _el$ = _tmpl$10.cloneNode(true); setAttribute(_el$, "href", url); insert(_el$, label); return _el$; })(); } // src/components/Leaf.tsx var _tmpl$11 = /* @__PURE__ */ template(``, 2); var _tmpl$23 = /* @__PURE__ */ template(``, 2); var _tmpl$33 = /* @__PURE__ */ template(``, 2); var _tmpl$42 = /* @__PURE__ */ template(``, 2); var _tmpl$52 = /* @__PURE__ */ template(``, 2); var _tmpl$62 = /* @__PURE__ */ template(``, 2); var ISODATE_RE = new RegExp(/^\d{4}-\d{2}-\d{2}$/); var MD_LINK_RE = new RegExp(/^\[(?