diff --git a/PaperBell/.obsidian/plugins/longform/data.json b/PaperBell/.obsidian/plugins/longform/data.json index 3435340a..283920f9 100644 --- a/PaperBell/.obsidian/plugins/longform/data.json +++ b/PaperBell/.obsidian/plugins/longform/data.json @@ -18,6 +18,7 @@ "waitForSync": false, "fallbackWaitEnabled": true, "fallbackWaitTime": 5, + "writeProperty": false, "workflows": { "CompileWithTitledFormatters": { "name": "CompileWithTitledFormatters", diff --git a/PaperBell/.obsidian/plugins/longform/main.js b/PaperBell/.obsidian/plugins/longform/main.js index 5604b626..13f4fcc2 100644 --- a/PaperBell/.obsidian/plugins/longform/main.js +++ b/PaperBell/.obsidian/plugins/longform/main.js @@ -2660,6 +2660,13 @@ function prevent_default(fn) { return fn.call(this, event); }; } +function stop_propagation(fn) { + return function (event) { + event.stopPropagation(); + // @ts-ignore + return fn.call(this, event); + }; +} function attr(node, attribute, value) { if (value == null) node.removeAttribute(attribute); @@ -2898,6 +2905,11 @@ function transition_out(block, local, detach, callback) { callback(); } } + +function destroy_block(block, lookup) { + block.d(1); + lookup.delete(block.key); +} function outro_and_destroy_block(block, lookup) { transition_out(block, 1, 1, () => { lookup.delete(block.key); @@ -20543,11 +20555,15 @@ function fileNameFromPath(path) { * Prefers Templater, then the core Templates plugin, then a plain note without using the template. * @param path Path to note to create. * @param template Path to template to use. + * + * @returns `null` if it fails to create the note. `TFile` for the new note, if successful. */ function createNoteWithPotentialTemplate(app, path, template) { return __awaiter(this, void 0, void 0, function* () { const file = yield createNote(app, path); - if (template && file) { + if (!file) + return null; + if (template) { let contents = ""; let pluginUsed = ""; try { @@ -20567,6 +20583,7 @@ function createNoteWithPotentialTemplate(app, path, template) { yield app.vault.adapter.write(path, contents); } } + return file; }); } /** @@ -20774,11 +20791,18 @@ function draftTitle(draft) { var _a; return (_a = draft.draftTitle) !== null && _a !== void 0 ? _a : draft.vaultPath; } -function createScene(app, path, draft, open) { +function createScene(app, path, index, draft, open) { var _a; return __awaiter(this, void 0, void 0, function* () { const template = (_a = draft.sceneTemplate) !== null && _a !== void 0 ? _a : get_store_value(pluginSettings).sceneTemplate; - createNoteWithPotentialTemplate(app, path, template); + const note = yield createNoteWithPotentialTemplate(app, path, template); + if (note === null) + return; + if (get_store_value(pluginSettings).writeProperty) { + yield app.fileManager.processFrontMatter(note, (fm) => { + fm["longform-order"] = index; + }); + } if (open) { app.workspace.openLinkText(path, "/", false); } @@ -20810,7 +20834,7 @@ function insertScene(app, draftsStore, draft, sceneName, vault, location, open) return d; }); }); - yield createScene(app, newScenePath, draft, open); + yield createScene(app, newScenePath, draft.scenes.findIndex((s) => s.title === sceneName), draft, open); }); } function setDraftOnFrontmatterObject(obj, draft) { @@ -20909,6 +20933,19 @@ function numberScenes(scenes) { function formatSceneNumber(numbering) { return numbering.join("."); } +/** + * Scenes that participate in compile numbering (excludes `longform-ignore` in + * frontmatter). Matches `compile()` multi-scene input selection. + */ +function scenesForCompileNumbering(app, draft) { + const folderPath = sceneFolderPath(draft, app.vault); + return draft.scenes.filter((s) => { + var _a; + const path = scenePathForFolder(s.title, folderPath); + const meta = app.metadataCache.getCache(path); + return !((_a = meta === null || meta === void 0 ? void 0 : meta.frontmatter) === null || _a === void 0 ? void 0 : _a["longform-ignore"]); + }); +} function insertDraftIntoFrontmatter(app, path, draft) { return __awaiter(this, void 0, void 0, function* () { const exists = yield app.vault.adapter.exists(path); @@ -21137,8 +21174,11 @@ function compile(app, draft, workflow, kinds, statusCallback) { else { const folderPath = sceneFolderPath(draft, app.vault); currentInput = []; + // Skipped / ignored scenes are excluded before numbering (see + // `scenesForCompileNumbering`) so compiled output stays contiguous. + const includedScenes = scenesForCompileNumbering(app, draft); // Build initial inputs - for (const scene of numberScenes(draft.scenes)) { + for (const scene of numberScenes(includedScenes)) { const path = scenePathForFolder(scene.title, folderPath); const contents = yield app.vault.adapter.read(path); const metadata = app.metadataCache.getCache(path); @@ -21588,7 +21628,7 @@ const WriteToNoteStep = makeBuiltinStep({ { id: "target", name: "Output path", - description: "Path for the created manuscript note, relative to your project. $1 will be replaced with your project’s title.", + description: "Path for the created manuscript note. Paths starting with '/' are relative to your vault root; otherwise relative to your project. $1 will be replaced with your project's title.", type: CompileStepOptionType.Text, default: "manuscript.md", }, @@ -21652,8 +21692,8 @@ function resolvePath(projectPath, filePath) { } if (!filePath.startsWith(".")) { if (filePath.startsWith("/")) { - // handle file path like: /filename.md - return obsidian.normalizePath(`${projectPath}${filePath}`); + // Absolute path from vault root - strip leading slash + return obsidian.normalizePath(filePath.substring(1)); } return obsidian.normalizePath(`${projectPath}/${filePath}`); } @@ -21745,24 +21785,357 @@ const AddFrontmatterStep = makeBuiltinStep({ } }); +/** + * Build a Pandoc-style YAML frontmatter from a Zenodo deposition metadata + * object. Returns the body of the frontmatter (no surrounding `---` lines) + * and always ends with a newline. + */ +function buildPandocYaml(metadata) { + var _a, _b, _c, _d, _e, _f, _g; + if (!metadata || typeof metadata !== "object") { + throw new Error("[Add Zenodo Frontmatter] Metadata must be a JSON object."); + } + if (!metadata.title || typeof metadata.title !== "string") { + throw new Error("[Add Zenodo Frontmatter] Metadata is missing required field 'title'."); + } + if (!Array.isArray(metadata.creators) || + metadata.creators.length === 0 || + metadata.creators.some((c) => !c || typeof c.name !== "string" || !c.name)) { + throw new Error("[Add Zenodo Frontmatter] Metadata is missing required field 'creators' (non-empty array of {name, ...})."); + } + const ext = (_a = metadata._longform) !== null && _a !== void 0 ? _a : {}; + const date = metadata.publication_date && metadata.publication_date.length > 0 + ? metadata.publication_date + : new Date().toISOString().slice(0, 10); + const correspondingSet = new Set((_b = ext.corresponding) !== null && _b !== void 0 ? _b : []); + const authorAffiliations = (_c = ext.author_affiliations) !== null && _c !== void 0 ? _c : {}; + const affiliationIndex = []; + const indexFor = (name) => { + const i = affiliationIndex.indexOf(name); + if (i >= 0) + return i + 1; + affiliationIndex.push(name); + return affiliationIndex.length; + }; + const authorsOut = metadata.creators.map((creator) => { + const explicit = authorAffiliations[creator.name]; + const affilNames = explicit && explicit.length > 0 + ? explicit + : creator.affiliation + ? [creator.affiliation] + : []; + return { + name: creator.name, + affiliationIndices: affilNames.map(indexFor), + corresponding: correspondingSet.has(creator.name), + }; + }); + const lines = []; + lines.push(`title: ${yamlString(metadata.title)}`); + lines.push(`date: ${yamlString(date)}`); + lines.push("authors:"); + for (const a of authorsOut) { + lines.push(` - name: ${yamlString(a.name)}`); + if (a.affiliationIndices.length > 0) { + lines.push(` affiliation: [${a.affiliationIndices.join(", ")}]`); + } + if (a.corresponding) { + lines.push(` corresponding: ${yamlString("yes")}`); + } + } + if (affiliationIndex.length > 0) { + lines.push("affiliations:"); + affiliationIndex.forEach((name, i) => { + lines.push(` - index: ${i + 1}`); + lines.push(` name: ${yamlString(name)}`); + }); + } + lines.push(`abstract: ${yamlString((_d = metadata.description) !== null && _d !== void 0 ? _d : "")}`); + if (Array.isArray(metadata.keywords) && metadata.keywords.length > 0) { + lines.push("keywords:"); + for (const k of metadata.keywords) { + lines.push(` - ${yamlString(String(k))}`); + } + } + lines.push(`target: ${yamlString((_e = metadata.journal_title) !== null && _e !== void 0 ? _e : "")}`); + lines.push(`acronym: ${yamlString((_f = ext.acronym) !== null && _f !== void 0 ? _f : "")}`); + lines.push(`csl: ${yamlString((_g = ext.csl) !== null && _g !== void 0 ? _g : "")}`); + if (ext.template) { + lines.push(`template: ${yamlString(ext.template)}`); + } + if (ext.lineno) { + lines.push(`lineno: ${yamlString("true")}`); + } + if (ext.figures_at_end) { + lines.push(`figures-at-end: ${yamlString("true")}`); + } + let body = lines.join("\n") + "\n"; + if (ext.extra_yaml && ext.extra_yaml.length > 0) { + const extra = ext.extra_yaml.endsWith("\n") + ? ext.extra_yaml + : ext.extra_yaml + "\n"; + body += extra; + } + return body; +} +/** Quote a value as a YAML double-quoted string, escaping `\` and `"`. */ +function yamlString(s) { + return `"${String(s).replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`; +} + +const AddZenodoFrontmatterStep = makeBuiltinStep({ + id: "add-zenodo-frontmatter", + description: { + name: "Add Zenodo Frontmatter", + description: "Reads a Zenodo-style metadata JSON from your project folder and prepends a Pandoc-compatible YAML frontmatter to the manuscript.", + availableKinds: [CompileStepKind.Manuscript], + options: [ + { + id: "metadata-file", + name: "Metadata file", + description: "Filename of the Zenodo deposition metadata JSON in your project folder (or its 'source/' subfolder). Trailing '.json' is optional.", + type: CompileStepOptionType.Text, + default: "metadata.json", + }, + { + id: "error-on-missing-file", + name: "Error on missing file", + description: "If checked, throw an error when the metadata file is not found. Otherwise pass the manuscript through unchanged.", + type: CompileStepOptionType.Boolean, + default: true, + }, + ], + }, + compile(input, context) { + var _a, _b; + return __awaiter(this, void 0, void 0, function* () { + if (context.kind !== CompileStepKind.Manuscript) { + throw new Error("Cannot add frontmatter to non-manuscript."); + } + const metaFileName = String((_a = context.optionValues["metadata-file"]) !== null && _a !== void 0 ? _a : "metadata.json").trim(); + const errorOnMissingFile = Boolean((_b = context.optionValues["error-on-missing-file"]) !== null && _b !== void 0 ? _b : true); + const baseName = metaFileName.endsWith(".json") + ? metaFileName + : `${metaFileName}.json`; + const candidatePaths = [ + `${context.projectPath}/${baseName}`, + `${context.projectPath}/source/${baseName}`, + ]; + let file = null; + let foundPath = ""; + for (const path of candidatePaths) { + const f = context.app.vault.getAbstractFileByPath(path); + if (f instanceof obsidian.TFile) { + file = f; + foundPath = path; + break; + } + } + if (!file) { + if (errorOnMissingFile) { + throw new Error(`[Add Zenodo Frontmatter] Metadata file not found at ${candidatePaths.join(" or ")}`); + } + return input; + } + const raw = yield context.app.vault.cachedRead(file); + let metadata; + try { + metadata = JSON.parse(raw); + } + catch (e) { + throw new Error(`[Add Zenodo Frontmatter] Invalid JSON in ${foundPath}: ${e.message}`); + } + const yaml = buildPandocYaml(metadata); + return { + contents: `---\n${yaml}---\n\n${input.contents}`, + }; + }); + }, +}); + +/** + * Resolve a dot/bracket path expression against a value. + * Supports `a.b.c` and `a.b[0].c` mixed notation. Returns `undefined` + * for any segment that does not resolve. + */ +function getByPath(root, pathExpr) { + const tokens = []; + let buf = ""; + for (let i = 0; i < pathExpr.length; i++) { + const ch = pathExpr[i]; + if (ch === ".") { + if (buf) { + tokens.push(buf); + buf = ""; + } + } + else if (ch === "[") { + if (buf) { + tokens.push(buf); + buf = ""; + } + let j = i + 1; + let idx = ""; + while (j < pathExpr.length && pathExpr[j] !== "]") { + idx += pathExpr[j++]; + } + i = j; + tokens.push(idx.trim()); + } + else { + buf += ch; + } + } + if (buf) + tokens.push(buf); + let cur = root; + for (const t of tokens) { + if (cur === null || cur === undefined) + return undefined; + if (/^\d+$/.test(t)) { + const idx = parseInt(t, 10); + if (!Array.isArray(cur) || idx < 0 || idx >= cur.length) + return undefined; + cur = cur[idx]; + } + else if (typeof cur === "object") { + const obj = cur; + cur = Object.prototype.hasOwnProperty.call(obj, t) ? obj[t] : undefined; + } + else { + return undefined; + } + } + return cur; +} +/** Build a global regex matching ` path ` placeholders. */ +function buildPlaceholderRegex(startDelim, endDelim) { + const esc = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + return new RegExp(`${esc(startDelim)}\\s*([a-zA-Z0-9_.$\\[\\]-]+)\\s*${esc(endDelim)}`, "g"); +} + +const ReplaceJsonPlaceholdersStep = makeBuiltinStep({ + id: "replace-json-placeholders", + description: { + name: "Replace JSON Placeholders", + description: "Replaces {{path.to.value}} placeholders in your manuscript with values from a JSON file in your project folder.", + availableKinds: [CompileStepKind.Manuscript], + options: [ + { + id: "json-file", + name: "JSON file", + description: "Filename of the JSON data file in your project folder (or its 'source/' subfolder). Trailing '.json' is optional.", + type: CompileStepOptionType.Text, + default: "results.json", + }, + { + id: "start-delim", + name: "Start delimiter", + description: "Left delimiter of placeholders.", + type: CompileStepOptionType.Text, + default: "{{", + }, + { + id: "end-delim", + name: "End delimiter", + description: "Right delimiter of placeholders.", + type: CompileStepOptionType.Text, + default: "}}", + }, + { + id: "error-on-missing", + name: "Error on missing", + description: "If checked, throw an error when a placeholder path is not found in the JSON file. Otherwise leave the placeholder unchanged.", + type: CompileStepOptionType.Boolean, + default: false, + }, + ], + }, + compile(input, context) { + var _a, _b, _c; + return __awaiter(this, void 0, void 0, function* () { + if (context.kind !== CompileStepKind.Manuscript) { + throw new Error("Cannot replace placeholders on non-manuscript."); + } + const jsonFileName = String((_a = context.optionValues["json-file"]) !== null && _a !== void 0 ? _a : "results.json").trim(); + const startDelim = String((_b = context.optionValues["start-delim"]) !== null && _b !== void 0 ? _b : "{{"); + const endDelim = String((_c = context.optionValues["end-delim"]) !== null && _c !== void 0 ? _c : "}}"); + const errorOnMissing = Boolean(context.optionValues["error-on-missing"]); + const baseName = jsonFileName.endsWith(".json") + ? jsonFileName + : `${jsonFileName}.json`; + const candidatePaths = [ + `${context.projectPath}/${baseName}`, + `${context.projectPath}/source/${baseName}`, + ]; + let file = null; + let foundPath = ""; + for (const path of candidatePaths) { + const f = context.app.vault.getAbstractFileByPath(path); + if (f instanceof obsidian.TFile) { + file = f; + foundPath = path; + break; + } + } + if (!file) { + throw new Error(`[Replace JSON Placeholders] JSON file not found at ${candidatePaths.join(" or ")}`); + } + const raw = yield context.app.vault.cachedRead(file); + let data; + try { + data = JSON.parse(raw); + } + catch (e) { + throw new Error(`[Replace JSON Placeholders] Invalid JSON in ${foundPath}: ${e.message}`); + } + const pattern = buildPlaceholderRegex(startDelim, endDelim); + const replaced = input.contents.replace(pattern, (match, rawPath) => { + const pathExpr = String(rawPath).trim(); + const value = getByPath(data, pathExpr); + if (value === undefined) { + if (errorOnMissing) { + throw new Error(`[Replace JSON Placeholders] Missing value for placeholder path: ${pathExpr}`); + } + return match; + } + if (value === null) + return ""; + if (typeof value === "object") { + try { + return JSON.stringify(value); + } + catch (_a) { + return String(value); + } + } + return String(value); + }); + return { contents: replaced }; + }); + }, +}); + const BUILTIN_STEPS = [ AddFrontmatterStep, + AddZenodoFrontmatterStep, ConcatenateTextStep, PrependTitleStep, RemoveCommentsStep, RemoveLinksStep, RemoveStrikethroughsStep, + ReplaceJsonPlaceholdersStep, StripFrontmatterStep, WriteToNoteStep, ]; /* src/view/compile/add-step-modal/AddStepModal.svelte generated by Svelte v3.49.0 */ -function add_css$e(target) { +function add_css$f(target) { append_styles(target, "svelte-muo6j5", ".longform-steps-grid.svelte-muo6j5.svelte-muo6j5{display:grid;grid-template-columns:1fr 1fr;gap:var(--size-4-4);grid-auto-rows:auto}.longform-compile-step.svelte-muo6j5.svelte-muo6j5{cursor:pointer;grid-column:auto;grid-row:auto;background-color:var(--background-secondary);border:var(--size-2-1) solid var(--background-modifier-border);border-radius:var(--size-4-4);padding:var(--size-4-2)}.longform-compile-step.svelte-muo6j5.svelte-muo6j5:hover{border:var(--size-2-1) solid var(--text-accent);background-color:var(--background-modifier-form-field)}.longform-compile-step.svelte-muo6j5 h3.svelte-muo6j5{padding:var(--size-4-2) 0;margin:0}.longform-compile-step.svelte-muo6j5 .longform-step-kind-pill.svelte-muo6j5{background-color:var(--text-accent);color:var(--text-on-accent);border-radius:var(--radius-l);font-size:var(--font-smallest);font-weight:bold;padding:var(--size-4-1);margin-right:var(--size-4-1);height:var(--size-4-5)}"); } -function get_each_context$6(ctx, list, i) { +function get_each_context$7(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[8] = list[i]; return child_ctx; @@ -21914,7 +22287,7 @@ function create_each_block_2(ctx) { } // (41:2) {#if $userScriptSteps} -function create_if_block$c(ctx) { +function create_if_block$d(ctx) { let h2; let t1; let div; @@ -21922,7 +22295,7 @@ function create_if_block$c(ctx) { let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$6(get_each_context$6(ctx, each_value, i)); + each_blocks[i] = create_each_block$7(get_each_context$7(ctx, each_value, i)); } return { @@ -21953,12 +22326,12 @@ function create_if_block$c(ctx) { let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context$6(ctx, each_value, i); + const child_ctx = get_each_context$7(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block$6(child_ctx); + each_blocks[i] = create_each_block$7(child_ctx); each_blocks[i].c(); each_blocks[i].m(div, null); } @@ -22012,7 +22385,7 @@ function create_each_block_1$1(ctx) { } // (44:6) {#each $userScriptSteps as step} -function create_each_block$6(ctx) { +function create_each_block$7(ctx) { let div1; let h3; let t0_value = /*step*/ ctx[8].description.name + ""; @@ -22116,7 +22489,7 @@ function create_each_block$6(ctx) { }; } -function create_fragment$f(ctx) { +function create_fragment$g(ctx) { let div1; let p; let t1; @@ -22131,7 +22504,7 @@ function create_fragment$f(ctx) { each_blocks[i] = create_each_block_2(get_each_context_2(ctx, each_value_2, i)); } - let if_block = /*$userScriptSteps*/ ctx[0] && create_if_block$c(ctx); + let if_block = /*$userScriptSteps*/ ctx[0] && create_if_block$d(ctx); return { c() { @@ -22196,7 +22569,7 @@ function create_fragment$f(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$c(ctx); + if_block = create_if_block$d(ctx); if_block.c(); if_block.m(div1, null); } @@ -22215,7 +22588,7 @@ function create_fragment$f(ctx) { }; } -function instance$f($$self, $$props, $$invalidate) { +function instance$g($$self, $$props, $$invalidate) { let $workflows; let $selectedDraft; let $currentWorkflow; @@ -22249,7 +22622,7 @@ function instance$f($$self, $$props, $$invalidate) { class AddStepModal extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$f, create_fragment$f, safe_not_equal, {}, add_css$e); + init(this, options, instance$g, create_fragment$g, safe_not_equal, {}, add_css$f); } } @@ -22337,11 +22710,11 @@ const ICON_SVG = 'div.svelte-yprjpc{margin:0 var(--size-4-2) 0 var(--size-4-6)\n }.longform-compile-step-option.svelte-yprjpc.svelte-yprjpc{margin:0 var(--size-4-4) var(--size-4-4) 0}.longform-compile-step-option.svelte-yprjpc label.svelte-yprjpc{display:block;font-weight:600;font-size:var(--font-smallest)}.longform-compile-step-checkbox-container.svelte-yprjpc.svelte-yprjpc{display:flex;flex-direction:row;align-items:center;justify-content:flex-start}.longform-compile-step-option.svelte-yprjpc input[type=\"text\"].svelte-yprjpc{margin:0 0 var(--size-4-1) 0;width:100%}.longform-compile-step-option.svelte-yprjpc textarea.svelte-yprjpc{color:var(--text-accent);margin:0 0 var(--size-4-1) 0;width:100%;resize:vertical}.longform-compile-step-option.svelte-yprjpc input[type=\"checkbox\"].svelte-yprjpc{margin:0 var(--size-4-2) var(--size-2-1) 0}.longform-compile-step-option.svelte-yprjpc input.svelte-yprjpc:focus{color:var(--text-accent-hover)}.longform-compile-step-option-description.svelte-yprjpc.svelte-yprjpc{font-size:var(--font-smallest);line-height:1em;color:var(--text-faint)}.longform-compile-step-error-container.svelte-yprjpc.svelte-yprjpc{margin-top:var(--size-4-2)}.longform-compile-step-error.svelte-yprjpc.svelte-yprjpc{color:var(--text-error);font-size:var(--font-smallest);line-height:1em}"); } -function get_each_context$5(ctx, list, i) { +function get_each_context$6(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[9] = list[i]; child_ctx[10] = list; @@ -22350,7 +22723,7 @@ function get_each_context$5(ctx, list, i) { } // (31:2) {:else} -function create_else_block$4(ctx) { +function create_else_block$5(ctx) { let div1; let div0; let h4; @@ -22371,8 +22744,8 @@ function create_else_block$4(ctx) { let mounted; let dispose; let if_block0 = /*calculatedKind*/ ctx[2] !== null && create_if_block_5$3(ctx); - let if_block1 = /*step*/ ctx[0].description.options.length > 0 && create_if_block_2$6(ctx); - let if_block2 = /*error*/ ctx[3] && create_if_block_1$8(ctx); + let if_block1 = /*step*/ ctx[0].description.options.length > 0 && create_if_block_2$7(ctx); + let if_block2 = /*error*/ ctx[3] && create_if_block_1$9(ctx); return { c() { @@ -22450,7 +22823,7 @@ function create_else_block$4(ctx) { if (if_block1) { if_block1.p(ctx, dirty); } else { - if_block1 = create_if_block_2$6(ctx); + if_block1 = create_if_block_2$7(ctx); if_block1.c(); if_block1.m(t8.parentNode, t8); } @@ -22463,7 +22836,7 @@ function create_else_block$4(ctx) { if (if_block2) { if_block2.p(ctx, dirty); } else { - if_block2 = create_if_block_1$8(ctx); + if_block2 = create_if_block_1$9(ctx); if_block2.c(); if_block2.m(if_block2_anchor.parentNode, if_block2_anchor); } @@ -22489,7 +22862,7 @@ function create_else_block$4(ctx) { } // (15:2) {#if step.description.canonicalID === PLACEHOLDER_MISSING_STEP.description.canonicalID} -function create_if_block$b(ctx) { +function create_if_block$c(ctx) { let div1; let div0; let t1; @@ -22575,14 +22948,14 @@ function create_if_block_5$3(ctx) { } // (51:4) {#if step.description.options.length > 0} -function create_if_block_2$6(ctx) { +function create_if_block_2$7(ctx) { let div1; let div0; let each_value = /*step*/ ctx[0].description.options; let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$5(get_each_context$5(ctx, each_value, i)); + each_blocks[i] = create_each_block$6(get_each_context$6(ctx, each_value, i)); } return { @@ -22611,12 +22984,12 @@ function create_if_block_2$6(ctx) { let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context$5(ctx, each_value, i); + const child_ctx = get_each_context$6(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block$5(child_ctx); + each_blocks[i] = create_each_block$6(child_ctx); each_blocks[i].c(); each_blocks[i].m(div0, null); } @@ -22844,7 +23217,7 @@ function create_if_block_3$3(ctx) { } // (54:10) {#each step.description.options as option} -function create_each_block$5(ctx) { +function create_each_block$6(ctx) { let div; let t0; let p; @@ -22903,7 +23276,7 @@ function create_each_block$5(ctx) { } // (89:4) {#if error} -function create_if_block_1$8(ctx) { +function create_if_block_1$9(ctx) { let div; let p; let t; @@ -22930,12 +23303,12 @@ function create_if_block_1$8(ctx) { }; } -function create_fragment$e(ctx) { +function create_fragment$f(ctx) { let div; function select_block_type(ctx, dirty) { - if (/*step*/ ctx[0].description.canonicalID === PLACEHOLDER_MISSING_STEP.description.canonicalID) return create_if_block$b; - return create_else_block$4; + if (/*step*/ ctx[0].description.canonicalID === PLACEHOLDER_MISSING_STEP.description.canonicalID) return create_if_block$c; + return create_else_block$5; } let current_block_type = select_block_type(ctx); @@ -22973,7 +23346,7 @@ function create_fragment$e(ctx) { }; } -function instance$e($$self, $$props, $$invalidate) { +function instance$f($$self, $$props, $$invalidate) { let { step } = $$props; let { ordinal } = $$props; let { calculatedKind } = $$props; @@ -23025,8 +23398,8 @@ class CompileStepView extends SvelteComponent { init( this, options, - instance$e, - create_fragment$e, + instance$f, + create_fragment$f, safe_not_equal, { step: 0, @@ -23034,7 +23407,7 @@ class CompileStepView extends SvelteComponent { calculatedKind: 2, error: 3 }, - add_css$d + add_css$e ); } } @@ -25823,7 +26196,7 @@ _extends(Remove, { /* src/view/sortable/SortableList.svelte generated by Svelte v3.49.0 */ -function get_each_context$4(ctx, list, i) { +function get_each_context$5(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[9] = list[i]; return child_ctx; @@ -25833,7 +26206,7 @@ const get_default_slot_changes = dirty => ({ item: dirty & /*items*/ 1 }); const get_default_slot_context = ctx => ({ item: /*item*/ ctx[9] }); // (87:2) {#each items as item (item.id)} -function create_each_block$4(key_1, ctx) { +function create_each_block$5(key_1, ctx) { let li; let t; let li_data_id_value; @@ -25905,7 +26278,7 @@ function create_each_block$4(key_1, ctx) { }; } -function create_fragment$d(ctx) { +function create_fragment$e(ctx) { let ul; let each_blocks = []; let each_1_lookup = new Map(); @@ -25915,9 +26288,9 @@ function create_fragment$d(ctx) { const get_key = ctx => /*item*/ ctx[9].id; for (let i = 0; i < each_value.length; i += 1) { - let child_ctx = get_each_context$4(ctx, each_value, i); + let child_ctx = get_each_context$5(ctx, each_value, i); let key = get_key(child_ctx); - each_1_lookup.set(key, each_blocks[i] = create_each_block$4(key, child_ctx)); + each_1_lookup.set(key, each_blocks[i] = create_each_block$5(key, child_ctx)); } return { @@ -25944,7 +26317,7 @@ function create_fragment$d(ctx) { if (dirty & /*items, $$scope*/ 33) { each_value = /*items*/ ctx[0]; group_outros(); - each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, ul, outro_and_destroy_block, create_each_block$4, null, get_each_context$4); + each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, ul, outro_and_destroy_block, create_each_block$5, null, get_each_context$5); check_outros(); } @@ -26026,7 +26399,7 @@ function IndentPlugin() { // @ts-ignore Sortable.mount(new IndentPlugin()); -function instance$d($$self, $$props, $$invalidate) { +function instance$e($$self, $$props, $$invalidate) { let { $$slots: slots = {}, $$scope } = $$props; let { items = [] } = $$props; let { sortableOptions = {} } = $$props; @@ -26117,7 +26490,7 @@ class SortableList extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$d, create_fragment$d, safe_not_equal, { + init(this, options, instance$e, create_fragment$e, safe_not_equal, { items: 0, sortableOptions: 3, trackIndents: 4 @@ -27973,11 +28346,11 @@ var omit_1 = omit; /* src/view/components/AutoTextArea.svelte generated by Svelte v3.49.0 */ -function add_css$c(target) { +function add_css$d(target) { append_styles(target, "svelte-1wdi5lq", ".container.svelte-1wdi5lq{position:relative}pre.svelte-1wdi5lq,textarea.svelte-1wdi5lq{font-family:inherit;padding:var(--size-4-2);box-sizing:border-box;border:none;line-height:1.2;overflow:hidden}textarea.svelte-1wdi5lq{position:absolute;width:100%;height:100%;top:0;resize:none}"); } -function create_fragment$c(ctx) { +function create_fragment$d(ctx) { let div; let pre; let t0_value = /*value*/ ctx[0] + "\n" + ""; @@ -28051,7 +28424,7 @@ function create_fragment$c(ctx) { }; } -function instance$c($$self, $$props, $$invalidate) { +function instance$d($$self, $$props, $$invalidate) { let minHeight; let maxHeight; let { value = "" } = $$props; @@ -28088,24 +28461,24 @@ function instance$c($$self, $$props, $$invalidate) { class AutoTextArea extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$c, create_fragment$c, safe_not_equal, { value: 0, minRows: 4, maxRows: 5 }, add_css$c); + init(this, options, instance$d, create_fragment$d, safe_not_equal, { value: 0, minRows: 4, maxRows: 5 }, add_css$d); } } /* src/view/compile/CompileView.svelte generated by Svelte v3.49.0 */ -function add_css$b(target) { +function add_css$c(target) { append_styles(target, "svelte-1hf1yah", ".longform-workflow-picker-container.svelte-1hf1yah.svelte-1hf1yah{padding:var(--size-4-2);background:var(--background-primary);display:flex;flex-direction:column}#longform-workflows.svelte-1hf1yah.svelte-1hf1yah{color:var(--color-accent-2)}.longform-workflow-picker.svelte-1hf1yah.svelte-1hf1yah{display:flex;flex-direction:row;justify-content:space-between;align-items:center;flex-wrap:wrap;margin-bottom:var(--size-4-2)}.longform-workflow-picker.svelte-1hf1yah .longform-hint.svelte-1hf1yah{font-size:1em}select.svelte-1hf1yah.svelte-1hf1yah{background-color:transparent;border:none;padding:var(--size-4-1) 0;margin:0;font-family:inherit;font-size:inherit;cursor:inherit;line-height:inherit;outline:none;box-shadow:none}.select.svelte-1hf1yah.svelte-1hf1yah{cursor:pointer}.select.svelte-1hf1yah>select.svelte-1hf1yah{color:var(--text-accent)}.select.svelte-1hf1yah>select.svelte-1hf1yah:hover{text-decoration:underline;color:var(--text-accent-hover)}.longform-compile-container.svelte-1hf1yah .longform-sortable-step-list{list-style-type:none;padding:0;margin:0}.options-button.svelte-1hf1yah.svelte-1hf1yah{background-color:var(--background-secondary-alt);color:var(--text-accent)}.options-button.svelte-1hf1yah.svelte-1hf1yah:hover{background-color:var(--background-primary);color:var(--text-accent-hover)}.add-step-container.svelte-1hf1yah.svelte-1hf1yah{display:flex;flex-direction:row;align-items:center;justify-content:center}.add-step-container.svelte-1hf1yah button.svelte-1hf1yah{font-weight:bold;color:var(--text-accent)}.add-step-container.svelte-1hf1yah button.svelte-1hf1yah:hover{text-decoration:underline;color:var(--text-accent-hover)}.longform-compile-instructions.svelte-1hf1yah.svelte-1hf1yah{font-size:var(--font-smallest);padding:var(--size-4-4) var(--size-4-4) var(--size-4-1) var(--size-4-8);color:var(--text-muted)}.longform-compile-instructions.svelte-1hf1yah li.svelte-1hf1yah{margin-bottom:var(--size-4-1)\n }.longform-compile-instructions.svelte-1hf1yah strong.svelte-1hf1yah{color:var(--color-accent-2)}.compile-button.svelte-1hf1yah.svelte-1hf1yah{font-weight:bold;background-color:var(--interactive-accent);color:var(--text-on-accent)}.compile-button.svelte-1hf1yah.svelte-1hf1yah:hover{background-color:var(--interactive-accent-hover);color:var(--text-on-accent)}.compile-button.svelte-1hf1yah.svelte-1hf1yah:disabled{background-color:var(--text-muted);color:var(--text-faint)}.longform-compile-run-container.svelte-1hf1yah.svelte-1hf1yah{display:flex;flex-direction:row;align-items:center;justify-content:space-between;margin-top:var(--size-4-8)}.longform-compile-run-container.svelte-1hf1yah .compile-status.svelte-1hf1yah{color:var(--text-muted)}.compile-status-error{color:var(--text-error) !important}.compile-status-success{color:var(--interactive-success) !important}.step-ghost{background-color:var(--interactive-accent-hover);color:var(--text-on-accent)}"); } -function get_each_context$3(ctx, list, i) { +function get_each_context$4(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[44] = list[i]; return child_ctx; } // (177:0) {#if $selectedDraft} -function create_if_block$a(ctx) { +function create_if_block$b(ctx) { let div3; let div1; let div0; @@ -28119,14 +28492,14 @@ function create_if_block$a(ctx) { function select_block_type(ctx, dirty) { if (/*workflowInputState*/ ctx[6] !== "hidden") return create_if_block_5$2; - return create_else_block$3; + return create_else_block$4; } let current_block_type = select_block_type(ctx); let if_block0 = current_block_type(ctx); let if_block1 = /*$workflows*/ ctx[4][/*currentWorkflowName*/ ctx[1]] && create_if_block_4$2(ctx); - let if_block2 = /*$workflows*/ ctx[4][/*currentWorkflowName*/ ctx[1]] && create_if_block_2$5(ctx); - let if_block3 = /*$currentWorkflow*/ ctx[2] && /*$currentWorkflow*/ ctx[2].steps.length > 0 && create_if_block_1$7(ctx); + let if_block2 = /*$workflows*/ ctx[4][/*currentWorkflowName*/ ctx[1]] && create_if_block_2$6(ctx); + let if_block3 = /*$currentWorkflow*/ ctx[2] && /*$currentWorkflow*/ ctx[2].steps.length > 0 && create_if_block_1$8(ctx); return { c() { @@ -28216,7 +28589,7 @@ function create_if_block$a(ctx) { transition_in(if_block2, 1); } } else { - if_block2 = create_if_block_2$5(ctx); + if_block2 = create_if_block_2$6(ctx); if_block2.c(); transition_in(if_block2, 1); if_block2.m(div3, t2); @@ -28235,7 +28608,7 @@ function create_if_block$a(ctx) { if (if_block3) { if_block3.p(ctx, dirty); } else { - if_block3 = create_if_block_1$7(ctx); + if_block3 = create_if_block_1$8(ctx); if_block3.c(); if_block3.m(div2, null); } @@ -28266,7 +28639,7 @@ function create_if_block$a(ctx) { } // (200:8) {:else} -function create_else_block$3(ctx) { +function create_else_block$4(ctx) { let t0; let button; let mounted; @@ -28386,7 +28759,7 @@ function create_else_block_1$1(ctx) { let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$3(get_each_context$3(ctx, each_value, i)); + each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i)); } return { @@ -28423,12 +28796,12 @@ function create_else_block_1$1(ctx) { let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context$3(ctx, each_value, i); + const child_ctx = get_each_context$4(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block$3(child_ctx); + each_blocks[i] = create_each_block$4(child_ctx); each_blocks[i].c(); each_blocks[i].m(select, null); } @@ -28475,7 +28848,7 @@ function create_if_block_6$1(ctx) { } // (210:16) {#each allWorkflowNames as workflowOption} -function create_each_block$3(ctx) { +function create_each_block$4(ctx) { let option; let t_value = /*workflowOption*/ ctx[44] + ""; let t; @@ -28564,7 +28937,7 @@ function create_if_block_4$2(ctx) { } // (241:4) {#if $workflows[currentWorkflowName]} -function create_if_block_2$5(ctx) { +function create_if_block_2$6(ctx) { let sortablelist; let updating_items; let t; @@ -28742,7 +29115,7 @@ function create_if_block_3$2(ctx) { } // (292:6) {#if $currentWorkflow && $currentWorkflow.steps.length > 0} -function create_if_block_1$7(ctx) { +function create_if_block_1$8(ctx) { let button; let t0; let button_disabled_value; @@ -28807,10 +29180,10 @@ function create_if_block_1$7(ctx) { }; } -function create_fragment$b(ctx) { +function create_fragment$c(ctx) { let if_block_anchor; let current; - let if_block = /*$selectedDraft*/ ctx[3] && create_if_block$a(ctx); + let if_block = /*$selectedDraft*/ ctx[3] && create_if_block$b(ctx); return { c() { @@ -28831,7 +29204,7 @@ function create_fragment$b(ctx) { transition_in(if_block, 1); } } else { - if_block = create_if_block$a(ctx); + if_block = create_if_block$b(ctx); if_block.c(); transition_in(if_block, 1); if_block.m(if_block_anchor.parentNode, if_block_anchor); @@ -28866,7 +29239,7 @@ function focusOnInit(el) { el.focus(); } -function instance$b($$self, $$props, $$invalidate) { +function instance$c($$self, $$props, $$invalidate) { let $currentWorkflow; let $selectedDraft; let $workflows; @@ -29186,7 +29559,7 @@ function instance$b($$self, $$props, $$invalidate) { class CompileView extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$b, create_fragment$b, safe_not_equal, {}, add_css$b, [-1, -1]); + init(this, options, instance$c, create_fragment$c, safe_not_equal, {}, add_css$c, [-1, -1]); } } @@ -29246,12 +29619,12 @@ const goalProgress = derived([selectedDraft, sessions, pluginSettings, activeFil /* src/view/explorer/NewSceneField.svelte generated by Svelte v3.49.0 */ -function add_css$a(target) { +function add_css$b(target) { append_styles(target, "svelte-e1ncqi", ".new-scene-container.svelte-e1ncqi{margin:0;padding:var(--size-4-2) 0}#new-scene.svelte-e1ncqi{width:100%;background:var(--background-modifier-form-field);border:var(--input-border-width) solid var(--background-modifier-border);border-radius:var(--input-radius);font-size:var(--font-ui-small);padding:var(--size-4-1) var(--size-4-2)}#new-scene.invalid.svelte-e1ncqi{color:var(--text-error)}"); } // (50:2) {#if error} -function create_if_block$9(ctx) { +function create_if_block$a(ctx) { let p; let t; @@ -29273,13 +29646,13 @@ function create_if_block$9(ctx) { }; } -function create_fragment$a(ctx) { +function create_fragment$b(ctx) { let div; let input; let t; let mounted; let dispose; - let if_block = /*error*/ ctx[2] && create_if_block$9(ctx); + let if_block = /*error*/ ctx[2] && create_if_block$a(ctx); return { c() { @@ -29324,7 +29697,7 @@ function create_fragment$a(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$9(ctx); + if_block = create_if_block$a(ctx); if_block.c(); if_block.m(div, null); } @@ -29345,7 +29718,7 @@ function create_fragment$a(ctx) { }; } -function instance$a($$self, $$props, $$invalidate) { +function instance$b($$self, $$props, $$invalidate) { let $selectedDraft; component_subscribe($$self, selectedDraft, $$value => $$invalidate(7, $selectedDraft = $$value)); let newSceneName = ""; @@ -29416,17 +29789,17 @@ function instance$a($$self, $$props, $$invalidate) { class NewSceneField extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$a, create_fragment$a, safe_not_equal, {}, add_css$a); + init(this, options, instance$b, create_fragment$b, safe_not_equal, {}, add_css$b); } } /* src/view/explorer/ProjectPicker.svelte generated by Svelte v3.49.0 */ -function add_css$9(target) { +function add_css$a(target) { append_styles(target, "svelte-1hf8c86", "#project-picker-container.svelte-1hf8c86.svelte-1hf8c86{margin-bottom:var(--size-4-2)}select.svelte-1hf8c86.svelte-1hf8c86{background-color:transparent;border:var(--input-border-width) solid var(--background-modifier-border);border-radius:var(--input-radius);padding:var(--size-4-2) var(--size-4-3);width:100%;height:100%;font-family:inherit;font-size:var(--font-ui-large);cursor:inherit;line-height:inherit;outline:none;box-shadow:none}.select.svelte-1hf8c86>select.svelte-1hf8c86:hover{color:var(--text-normal);background-color:var(--background-modifier-hover);box-shadow:0 0 0 2px var(--background-modifier-border-focus);border-color:var(--background-modifier-border-focus);transition:box-shadow 0.15s ease-in-out,\n border 0.15s ease-in-out}.current-draft-path.svelte-1hf8c86.svelte-1hf8c86{color:var(--text-faint);font-size:var(--font-smallest);padding:0 0 var(--size-4-1) var(--size-4-3)}.current-draft-path.svelte-1hf8c86.svelte-1hf8c86:hover{color:var(--text-accent);cursor:pointer}#select-drafts.svelte-1hf8c86.svelte-1hf8c86{margin-top:var(--size-4-1)}"); } -function get_each_context$2(ctx, list, i) { +function get_each_context$3(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[12] = list[i]; return child_ctx; @@ -29439,7 +29812,7 @@ function get_each_context_1(ctx, list, i) { } // (80:2) {:else} -function create_else_block$2(ctx) { +function create_else_block$3(ctx) { let p; return { @@ -29461,7 +29834,7 @@ function create_else_block$2(ctx) { } // (49:2) {#if projectOptions.length > 0} -function create_if_block$8(ctx) { +function create_if_block$9(ctx) { let div1; let div0; let select; @@ -29478,8 +29851,8 @@ function create_if_block$8(ctx) { each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i)); } - let if_block0 = /*$selectedProjectHasMultipleDrafts*/ ctx[4] && create_if_block_2$4(ctx); - let if_block1 = /*$selectedDraft*/ ctx[2] && create_if_block_1$6(ctx); + let if_block0 = /*$selectedProjectHasMultipleDrafts*/ ctx[4] && create_if_block_2$5(ctx); + let if_block1 = /*$selectedDraft*/ ctx[2] && create_if_block_1$7(ctx); return { c() { @@ -29562,7 +29935,7 @@ function create_if_block$8(ctx) { if (if_block0) { if_block0.p(ctx, dirty); } else { - if_block0 = create_if_block_2$4(ctx); + if_block0 = create_if_block_2$5(ctx); if_block0.c(); if_block0.m(div1, null); } @@ -29575,7 +29948,7 @@ function create_if_block$8(ctx) { if (if_block1) { if_block1.p(ctx, dirty); } else { - if_block1 = create_if_block_1$6(ctx); + if_block1 = create_if_block_1$7(ctx); if_block1.c(); if_block1.m(if_block1_anchor.parentNode, if_block1_anchor); } @@ -29631,7 +30004,7 @@ function create_each_block_1(ctx) { } // (65:6) {#if $selectedProjectHasMultipleDrafts} -function create_if_block_2$4(ctx) { +function create_if_block_2$5(ctx) { let div; let select; let mounted; @@ -29640,7 +30013,7 @@ function create_if_block_2$4(ctx) { let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i)); + each_blocks[i] = create_each_block$3(get_each_context$3(ctx, each_value, i)); } return { @@ -29679,12 +30052,12 @@ function create_if_block_2$4(ctx) { let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context$2(ctx, each_value, i); + const child_ctx = get_each_context$3(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block$2(child_ctx); + each_blocks[i] = create_each_block$3(child_ctx); each_blocks[i].c(); each_blocks[i].m(select, null); } @@ -29711,7 +30084,7 @@ function create_if_block_2$4(ctx) { } // (68:12) {#each draftOptions as draftOption} -function create_each_block$2(ctx) { +function create_each_block$3(ctx) { let option; let t_value = /*draftOption*/ ctx[12].title + ""; let t; @@ -29743,7 +30116,7 @@ function create_each_block$2(ctx) { } // (75:4) {#if $selectedDraft} -function create_if_block_1$6(ctx) { +function create_if_block_1$7(ctx) { let div; let t_value = /*$selectedDraft*/ ctx[2].vaultPath + ""; let t; @@ -29776,12 +30149,12 @@ function create_if_block_1$6(ctx) { }; } -function create_fragment$9(ctx) { +function create_fragment$a(ctx) { let div; function select_block_type(ctx, dirty) { - if (/*projectOptions*/ ctx[0].length > 0) return create_if_block$8; - return create_else_block$2; + if (/*projectOptions*/ ctx[0].length > 0) return create_if_block$9; + return create_else_block$3; } let current_block_type = select_block_type(ctx); @@ -29820,7 +30193,7 @@ function create_fragment$9(ctx) { }; } -function instance$9($$self, $$props, $$invalidate) { +function instance$a($$self, $$props, $$invalidate) { let $selectedDraft; let $selectedDraftVaultPath; let $projects; @@ -29911,17 +30284,17 @@ function instance$9($$self, $$props, $$invalidate) { class ProjectPicker extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$9, create_fragment$9, safe_not_equal, {}, add_css$9); + init(this, options, instance$a, create_fragment$a, safe_not_equal, {}, add_css$a); } } /* src/view/components/Disclosure.svelte generated by Svelte v3.49.0 */ -function add_css$8(target) { +function add_css$9(target) { append_styles(target, "svelte-ff880f", ".right-triangle.svelte-ff880f.svelte-ff880f{transition:transform 0.3s;display:flex;align-items:center;justify-content:center;width:var(--size-4-3);color:var(--icon-color);margin-left:calc(var(--size-4-1) * -1);margin-top:calc(var(--size-4-1) * -.25)}.collapsed.svelte-ff880f .right-triangle.svelte-ff880f{transform:rotate(-90deg)}"); } -function create_fragment$8(ctx) { +function create_fragment$9(ctx) { let span; let svg; let path; @@ -29977,7 +30350,7 @@ function create_fragment$8(ctx) { }; } -function instance$8($$self, $$props, $$invalidate) { +function instance$9($$self, $$props, $$invalidate) { let { collapsed = false } = $$props; let { class: className = "" } = $$props; @@ -29996,7 +30369,7 @@ function instance$8($$self, $$props, $$invalidate) { class Disclosure extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$8, create_fragment$8, safe_not_equal, { collapsed: 0, class: 1 }, add_css$8); + init(this, options, instance$9, create_fragment$9, safe_not_equal, { collapsed: 0, class: 1 }, add_css$9); } } @@ -30082,28 +30455,28 @@ const ignoreAll = () => { /* src/view/explorer/SceneList.svelte generated by Svelte v3.49.0 */ -function add_css$7(target) { +function add_css$8(target) { append_styles(target, "svelte-u6nqd", ".group{margin-left:var(--size-4-2)}#scene-list.svelte-u6nqd.svelte-u6nqd{margin:var(--size-4-1) 0}#scene-list.svelte-u6nqd .sortable-scene-list{list-style-type:none;padding:0;margin:0}.scene-container.svelte-u6nqd.svelte-u6nqd{display:flex;flex-direction:row;align-items:center;border:var(--border-width) solid transparent;border-radius:var(--radius-s);cursor:pointer;color:var(--nav-item-color);font-size:var(--nav-item-size);font-weight:var(--nav-item-weight);line-height:var(--line-height-tight);padding:var(--size-4-1) var(--size-4-2);white-space:normal}.scene-container.collapsible.svelte-u6nqd.svelte-u6nqd{display:flex;flex-direction:row;align-items:center;border:var(--border-width) solid transparent;border-radius:var(--radius-s);cursor:pointer;color:var(--nav-item-color);font-size:var(--nav-item-size);font-weight:var(--nav-item-weight);line-height:var(--line-height-tight);padding:var(--size-4-1) var(--size-4-2);white-space:normal}.scene-container.hidden.svelte-u6nqd.svelte-u6nqd{display:none}.scene-container.svelte-u6nqd .svelte-u6nqd:nth-child(2){margin-left:var(--size-4-2)}.selected.svelte-u6nqd.svelte-u6nqd,.svelte-u6nqd:not(.dragging) .scene-container.svelte-u6nqd:hover{background-color:var(--background-secondary-alt);color:var(--text-normal)}.scene-container.svelte-u6nqd.svelte-u6nqd:active{background-color:inherit;color:var(--text-muted)}.longform-scene-number.svelte-u6nqd.svelte-u6nqd{color:var(--text-muted);margin-right:var(--size-4-1);font-weight:bold}.longform-scene-number.svelte-u6nqd.svelte-u6nqd::after{content:\".\"}#longform-unknown-files-wizard.svelte-u6nqd.svelte-u6nqd{border-top:var(--border-width) solid var(--text-muted);padding:var(--size-4-2) 0}.longform-unknown-inner.svelte-u6nqd.svelte-u6nqd{border-left:var(--size-2-1) solid var(--text-accent);padding:0 0 0 var(--size-4-1)}.longform-unknown-explanation.svelte-u6nqd.svelte-u6nqd{color:var(--text-muted);font-size:1em}#longform-unknown-files-wizard.svelte-u6nqd ul.svelte-u6nqd{list-style-type:none;padding:0 0 0 var(--size-4-2)}.longform-unknown-file.svelte-u6nqd.svelte-u6nqd{display:flex;flex-direction:row;justify-content:space-between}.longform-unknown-add.svelte-u6nqd.svelte-u6nqd{color:var(--text-accent);font-weight:bold}.longform-unknown-ignore.svelte-u6nqd.svelte-u6nqd{color:var(--text-muted);font-weight:bold}.scene-drag-ghost{background-color:var(--interactive-accent-hover);color:var(--text-on-accent);margin-left:var(--ghost-indent)}"); } -function get_each_context$1(ctx, list, i) { +function get_each_context$2(ctx, list, i) { const child_ctx = ctx.slice(); - child_ctx[40] = list[i]; + child_ctx[45] = list[i]; return child_ctx; } -// (294:8) {#if item.collapsible} -function create_if_block_2$3(ctx) { +// (342:8) {#if item.collapsible} +function create_if_block_2$4(ctx) { let disclosure; let current; function click_handler() { - return /*click_handler*/ ctx[20](/*item*/ ctx[43]); + return /*click_handler*/ ctx[23](/*item*/ ctx[48]); } disclosure = new Disclosure({ props: { - collapsed: /*collapsedItems*/ ctx[0].contains(/*item*/ ctx[43].id) + collapsed: /*collapsedItems*/ ctx[0].contains(/*item*/ ctx[48].id) } }); @@ -30120,7 +30493,7 @@ function create_if_block_2$3(ctx) { p(new_ctx, dirty) { ctx = new_ctx; const disclosure_changes = {}; - if (dirty[0] & /*collapsedItems*/ 1 | dirty[1] & /*item*/ 4096) disclosure_changes.collapsed = /*collapsedItems*/ ctx[0].contains(/*item*/ ctx[43].id); + if (dirty[0] & /*collapsedItems*/ 1 | dirty[1] & /*item*/ 131072) disclosure_changes.collapsed = /*collapsedItems*/ ctx[0].contains(/*item*/ ctx[48].id); disclosure.$set(disclosure_changes); }, i(local) { @@ -30138,10 +30511,10 @@ function create_if_block_2$3(ctx) { }; } -// (309:10) {#if $pluginSettings.numberScenes} -function create_if_block_1$5(ctx) { +// (357:10) {#if $pluginSettings.numberScenes} +function create_if_block_1$6(ctx) { let span; - let t_value = /*numberLabel*/ ctx[18](/*item*/ ctx[43]) + ""; + let t_value = /*numberLabel*/ ctx[20](/*item*/ ctx[48]) + ""; let t; return { @@ -30155,7 +30528,7 @@ function create_if_block_1$5(ctx) { append(span, t); }, p(ctx, dirty) { - if (dirty[1] & /*item*/ 4096 && t_value !== (t_value = /*numberLabel*/ ctx[18](/*item*/ ctx[43]) + "")) set_data(t, t_value); + if (dirty[1] & /*item*/ 131072 && t_value !== (t_value = /*numberLabel*/ ctx[20](/*item*/ ctx[48]) + "")) set_data(t, t_value); }, d(detaching) { if (detaching) detach(span); @@ -30163,33 +30536,42 @@ function create_if_block_1$5(ctx) { }; } -// (275:4) +// (322:4) function create_default_slot(ctx) { let div2; let t0; let div1; let t1; let div0; - let t2_value = /*item*/ ctx[43].name + ""; + let t2_value = /*item*/ ctx[48].name + ""; let t2; let div0_id_value; let div0_data_item_path_value; let div0_data_item_name_value; let div0_contenteditable_value; let div1_data_scene_path_value; + let t3; + let span; + let span_aria_label_value; + let iconAction_action; let div2_class_value; let div2_data_scene_path_value; let div2_data_scene_indent_value; let div2_data_scene_name_value; let div2_data_scene_status_value; + let div2_data_scene_ignored_value; let current; let mounted; let dispose; - let if_block0 = /*item*/ ctx[43].collapsible && create_if_block_2$3(ctx); - let if_block1 = /*$pluginSettings*/ ctx[7].numberScenes && create_if_block_1$5(ctx); + let if_block0 = /*item*/ ctx[48].collapsible && create_if_block_2$4(ctx); + let if_block1 = /*$pluginSettings*/ ctx[7].numberScenes && create_if_block_1$6(ctx); function click_handler_1(...args) { - return /*click_handler_1*/ ctx[21](/*item*/ ctx[43], ...args); + return /*click_handler_1*/ ctx[24](/*item*/ ctx[48], ...args); + } + + function click_handler_2() { + return /*click_handler_2*/ ctx[25](/*item*/ ctx[48]); } return { @@ -30202,22 +30584,32 @@ function create_default_slot(ctx) { t1 = space(); div0 = element("div"); t2 = text(t2_value); - attr(div0, "id", div0_id_value = `longform-scene-${/*item*/ ctx[43].name}`); - attr(div0, "data-item-path", div0_data_item_path_value = /*item*/ ctx[43].path); - attr(div0, "data-item-name", div0_data_item_name_value = /*item*/ ctx[43].name); + t3 = space(); + span = element("span"); + attr(div0, "id", div0_id_value = `longform-scene-${/*item*/ ctx[48].name}`); + attr(div0, "data-item-path", div0_data_item_path_value = /*item*/ ctx[48].path); + attr(div0, "data-item-name", div0_data_item_name_value = /*item*/ ctx[48].name); set_style(div0, "display", "inline"); - attr(div0, "contenteditable", div0_contenteditable_value = /*item*/ ctx[43].path === /*editingPath*/ ctx[5]); + attr(div0, "contenteditable", div0_contenteditable_value = /*item*/ ctx[48].path === /*editingPath*/ ctx[5]); attr(div0, "class", "svelte-u6nqd"); set_style(div1, "width", "100%"); - attr(div1, "data-scene-path", div1_data_scene_path_value = /*item*/ ctx[43].path); + attr(div1, "data-scene-path", div1_data_scene_path_value = /*item*/ ctx[48].path); attr(div1, "class", "svelte-u6nqd"); - attr(div2, "class", div2_class_value = "scene-container" + (/*item*/ ctx[43].hidden ? ' hidden' : '') + (/*item*/ ctx[43].collapsible ? ' collapsible' : '') + " svelte-u6nqd"); - set_style(div2, "padding-left", "calc((" + /*item*/ ctx[43].indent + " * var(--longform-explorer-indent-size)) + 6px " + (/*item*/ ctx[43].collapsible ? '' : '+ var(--size-4-4)') + ")"); - attr(div2, "data-scene-path", div2_data_scene_path_value = /*item*/ ctx[43].path); - attr(div2, "data-scene-indent", div2_data_scene_indent_value = /*item*/ ctx[43].indent); - attr(div2, "data-scene-name", div2_data_scene_name_value = /*item*/ ctx[43].name); - attr(div2, "data-scene-status", div2_data_scene_status_value = /*item*/ ctx[43].status); - toggle_class(div2, "selected", /*$activeFile*/ ctx[6] && /*$activeFile*/ ctx[6].path === /*item*/ ctx[43].path); + attr(span, "class", "longform-scene-ignore-toggle svelte-u6nqd"); + + attr(span, "aria-label", span_aria_label_value = /*item*/ ctx[48].ignored + ? "Include in compile" + : "Skip in compile"); + + toggle_class(span, "is-ignored", /*item*/ ctx[48].ignored); + attr(div2, "class", div2_class_value = "scene-container" + (/*item*/ ctx[48].hidden ? ' hidden' : '') + (/*item*/ ctx[48].collapsible ? ' collapsible' : '') + " svelte-u6nqd"); + set_style(div2, "padding-left", "calc((" + /*item*/ ctx[48].indent + " * var(--longform-explorer-indent-size)) + 6px " + (/*item*/ ctx[48].collapsible ? '' : '+ var(--size-4-4)') + ")"); + attr(div2, "data-scene-path", div2_data_scene_path_value = /*item*/ ctx[48].path); + attr(div2, "data-scene-indent", div2_data_scene_indent_value = /*item*/ ctx[48].indent); + attr(div2, "data-scene-name", div2_data_scene_name_value = /*item*/ ctx[48].name); + attr(div2, "data-scene-status", div2_data_scene_status_value = /*item*/ ctx[48].status); + attr(div2, "data-scene-ignored", div2_data_scene_ignored_value = /*item*/ ctx[48].ignored); + toggle_class(div2, "selected", /*$activeFile*/ ctx[6] && /*$activeFile*/ ctx[6].path === /*item*/ ctx[48].path); }, m(target, anchor) { insert(target, div2, anchor); @@ -30228,26 +30620,30 @@ function create_default_slot(ctx) { append(div1, t1); append(div1, div0); append(div0, t2); + append(div2, t3); + append(div2, span); current = true; if (!mounted) { dispose = [ listen(div0, "keydown", function () { - if (is_function(/*item*/ ctx[43].path === /*editingPath*/ ctx[5] - ? /*onKeydown*/ ctx[14] - : null)) (/*item*/ ctx[43].path === /*editingPath*/ ctx[5] - ? /*onKeydown*/ ctx[14] + if (is_function(/*item*/ ctx[48].path === /*editingPath*/ ctx[5] + ? /*onKeydown*/ ctx[16] + : null)) (/*item*/ ctx[48].path === /*editingPath*/ ctx[5] + ? /*onKeydown*/ ctx[16] : null).apply(this, arguments); }), listen(div0, "blur", function () { - if (is_function(/*item*/ ctx[43].path === /*editingPath*/ ctx[5] - ? /*onBlur*/ ctx[15] - : null)) (/*item*/ ctx[43].path === /*editingPath*/ ctx[5] - ? /*onBlur*/ ctx[15] + if (is_function(/*item*/ ctx[48].path === /*editingPath*/ ctx[5] + ? /*onBlur*/ ctx[17] + : null)) (/*item*/ ctx[48].path === /*editingPath*/ ctx[5] + ? /*onBlur*/ ctx[17] : null).apply(this, arguments); }), listen(div1, "click", click_handler_1), - listen(div2, "contextmenu", prevent_default(/*onContext*/ ctx[13])) + listen(span, "click", stop_propagation(click_handler_2)), + action_destroyer(iconAction_action = /*iconAction*/ ctx[13].call(null, span, /*item*/ ctx[48].ignored ? "eye-off" : "eye")), + listen(div2, "contextmenu", prevent_default(/*onContext*/ ctx[15])) ]; mounted = true; @@ -30256,15 +30652,15 @@ function create_default_slot(ctx) { p(new_ctx, dirty) { ctx = new_ctx; - if (/*item*/ ctx[43].collapsible) { + if (/*item*/ ctx[48].collapsible) { if (if_block0) { if_block0.p(ctx, dirty); - if (dirty[1] & /*item*/ 4096) { + if (dirty[1] & /*item*/ 131072) { transition_in(if_block0, 1); } } else { - if_block0 = create_if_block_2$3(ctx); + if_block0 = create_if_block_2$4(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div2, t0); @@ -30283,7 +30679,7 @@ function create_default_slot(ctx) { if (if_block1) { if_block1.p(ctx, dirty); } else { - if_block1 = create_if_block_1$5(ctx); + if_block1 = create_if_block_1$6(ctx); if_block1.c(); if_block1.m(div1, t1); } @@ -30292,54 +30688,70 @@ function create_default_slot(ctx) { if_block1 = null; } - if ((!current || dirty[1] & /*item*/ 4096) && t2_value !== (t2_value = /*item*/ ctx[43].name + "")) set_data(t2, t2_value); + if ((!current || dirty[1] & /*item*/ 131072) && t2_value !== (t2_value = /*item*/ ctx[48].name + "")) set_data(t2, t2_value); - if (!current || dirty[1] & /*item*/ 4096 && div0_id_value !== (div0_id_value = `longform-scene-${/*item*/ ctx[43].name}`)) { + if (!current || dirty[1] & /*item*/ 131072 && div0_id_value !== (div0_id_value = `longform-scene-${/*item*/ ctx[48].name}`)) { attr(div0, "id", div0_id_value); } - if (!current || dirty[1] & /*item*/ 4096 && div0_data_item_path_value !== (div0_data_item_path_value = /*item*/ ctx[43].path)) { + if (!current || dirty[1] & /*item*/ 131072 && div0_data_item_path_value !== (div0_data_item_path_value = /*item*/ ctx[48].path)) { attr(div0, "data-item-path", div0_data_item_path_value); } - if (!current || dirty[1] & /*item*/ 4096 && div0_data_item_name_value !== (div0_data_item_name_value = /*item*/ ctx[43].name)) { + if (!current || dirty[1] & /*item*/ 131072 && div0_data_item_name_value !== (div0_data_item_name_value = /*item*/ ctx[48].name)) { attr(div0, "data-item-name", div0_data_item_name_value); } - if (!current || dirty[0] & /*editingPath*/ 32 | dirty[1] & /*item*/ 4096 && div0_contenteditable_value !== (div0_contenteditable_value = /*item*/ ctx[43].path === /*editingPath*/ ctx[5])) { + if (!current || dirty[0] & /*editingPath*/ 32 | dirty[1] & /*item*/ 131072 && div0_contenteditable_value !== (div0_contenteditable_value = /*item*/ ctx[48].path === /*editingPath*/ ctx[5])) { attr(div0, "contenteditable", div0_contenteditable_value); } - if (!current || dirty[1] & /*item*/ 4096 && div1_data_scene_path_value !== (div1_data_scene_path_value = /*item*/ ctx[43].path)) { + if (!current || dirty[1] & /*item*/ 131072 && div1_data_scene_path_value !== (div1_data_scene_path_value = /*item*/ ctx[48].path)) { attr(div1, "data-scene-path", div1_data_scene_path_value); } - if (!current || dirty[1] & /*item*/ 4096 && div2_class_value !== (div2_class_value = "scene-container" + (/*item*/ ctx[43].hidden ? ' hidden' : '') + (/*item*/ ctx[43].collapsible ? ' collapsible' : '') + " svelte-u6nqd")) { + if (!current || dirty[1] & /*item*/ 131072 && span_aria_label_value !== (span_aria_label_value = /*item*/ ctx[48].ignored + ? "Include in compile" + : "Skip in compile")) { + attr(span, "aria-label", span_aria_label_value); + } + + if (iconAction_action && is_function(iconAction_action.update) && dirty[1] & /*item*/ 131072) iconAction_action.update.call(null, /*item*/ ctx[48].ignored ? "eye-off" : "eye"); + + if (dirty[1] & /*item*/ 131072) { + toggle_class(span, "is-ignored", /*item*/ ctx[48].ignored); + } + + if (!current || dirty[1] & /*item*/ 131072 && div2_class_value !== (div2_class_value = "scene-container" + (/*item*/ ctx[48].hidden ? ' hidden' : '') + (/*item*/ ctx[48].collapsible ? ' collapsible' : '') + " svelte-u6nqd")) { attr(div2, "class", div2_class_value); } - if (!current || dirty[1] & /*item*/ 4096) { - set_style(div2, "padding-left", "calc((" + /*item*/ ctx[43].indent + " * var(--longform-explorer-indent-size)) + 6px " + (/*item*/ ctx[43].collapsible ? '' : '+ var(--size-4-4)') + ")"); + if (!current || dirty[1] & /*item*/ 131072) { + set_style(div2, "padding-left", "calc((" + /*item*/ ctx[48].indent + " * var(--longform-explorer-indent-size)) + 6px " + (/*item*/ ctx[48].collapsible ? '' : '+ var(--size-4-4)') + ")"); } - if (!current || dirty[1] & /*item*/ 4096 && div2_data_scene_path_value !== (div2_data_scene_path_value = /*item*/ ctx[43].path)) { + if (!current || dirty[1] & /*item*/ 131072 && div2_data_scene_path_value !== (div2_data_scene_path_value = /*item*/ ctx[48].path)) { attr(div2, "data-scene-path", div2_data_scene_path_value); } - if (!current || dirty[1] & /*item*/ 4096 && div2_data_scene_indent_value !== (div2_data_scene_indent_value = /*item*/ ctx[43].indent)) { + if (!current || dirty[1] & /*item*/ 131072 && div2_data_scene_indent_value !== (div2_data_scene_indent_value = /*item*/ ctx[48].indent)) { attr(div2, "data-scene-indent", div2_data_scene_indent_value); } - if (!current || dirty[1] & /*item*/ 4096 && div2_data_scene_name_value !== (div2_data_scene_name_value = /*item*/ ctx[43].name)) { + if (!current || dirty[1] & /*item*/ 131072 && div2_data_scene_name_value !== (div2_data_scene_name_value = /*item*/ ctx[48].name)) { attr(div2, "data-scene-name", div2_data_scene_name_value); } - if (!current || dirty[1] & /*item*/ 4096 && div2_data_scene_status_value !== (div2_data_scene_status_value = /*item*/ ctx[43].status)) { + if (!current || dirty[1] & /*item*/ 131072 && div2_data_scene_status_value !== (div2_data_scene_status_value = /*item*/ ctx[48].status)) { attr(div2, "data-scene-status", div2_data_scene_status_value); } - if (dirty[0] & /*$activeFile*/ 64 | dirty[1] & /*item, item*/ 4096) { - toggle_class(div2, "selected", /*$activeFile*/ ctx[6] && /*$activeFile*/ ctx[6].path === /*item*/ ctx[43].path); + if (!current || dirty[1] & /*item*/ 131072 && div2_data_scene_ignored_value !== (div2_data_scene_ignored_value = /*item*/ ctx[48].ignored)) { + attr(div2, "data-scene-ignored", div2_data_scene_ignored_value); + } + + if (dirty[0] & /*$activeFile*/ 64 | dirty[1] & /*item, item*/ 131072) { + toggle_class(div2, "selected", /*$activeFile*/ ctx[6] && /*$activeFile*/ ctx[6].path === /*item*/ ctx[48].path); } }, i(local) { @@ -30361,8 +30773,8 @@ function create_default_slot(ctx) { }; } -// (327:2) {#if $selectedDraft && $selectedDraft.format === "scenes" && $selectedDraft.unknownFiles.length > 0} -function create_if_block$7(ctx) { +// (384:2) {#if $selectedDraft && $selectedDraft.format === "scenes" && $selectedDraft.unknownFiles.length > 0} +function create_if_block$8(ctx) { let div2; let div1; let p; @@ -30390,7 +30802,7 @@ function create_if_block$7(ctx) { let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); + each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i)); } return { @@ -30448,8 +30860,8 @@ function create_if_block$7(ctx) { if (!mounted) { dispose = [ - listen(button0, "click", /*click_handler_2*/ ctx[23]), - listen(button1, "click", /*click_handler_3*/ ctx[24]) + listen(button0, "click", /*click_handler_3*/ ctx[27]), + listen(button1, "click", /*click_handler_4*/ ctx[28]) ]; mounted = true; @@ -30462,17 +30874,17 @@ function create_if_block$7(ctx) { ? "" : "s") + "")) set_data(t3, t3_value); - if (dirty[0] & /*doWithUnknown, $selectedDraft*/ 65538) { + if (dirty[0] & /*doWithUnknown, $selectedDraft*/ 262146) { each_value = /*$selectedDraft*/ ctx[1].unknownFiles; let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context$1(ctx, each_value, i); + const child_ctx = get_each_context$2(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block$1(child_ctx); + each_blocks[i] = create_each_block$2(child_ctx); each_blocks[i].c(); each_blocks[i].m(ul, null); } @@ -30494,12 +30906,12 @@ function create_if_block$7(ctx) { }; } -// (346:10) {#each $selectedDraft.unknownFiles as fileName} -function create_each_block$1(ctx) { +// (403:10) {#each $selectedDraft.unknownFiles as fileName} +function create_each_block$2(ctx) { let li; let div1; let span; - let t0_value = /*fileName*/ ctx[40] + ""; + let t0_value = /*fileName*/ ctx[45] + ""; let t0; let t1; let div0; @@ -30510,12 +30922,12 @@ function create_each_block$1(ctx) { let mounted; let dispose; - function click_handler_4() { - return /*click_handler_4*/ ctx[25](/*fileName*/ ctx[40]); + function click_handler_5() { + return /*click_handler_5*/ ctx[29](/*fileName*/ ctx[45]); } - function click_handler_5() { - return /*click_handler_5*/ ctx[26](/*fileName*/ ctx[40]); + function click_handler_6() { + return /*click_handler_6*/ ctx[30](/*fileName*/ ctx[45]); } return { @@ -30550,8 +30962,8 @@ function create_each_block$1(ctx) { if (!mounted) { dispose = [ - listen(button0, "click", click_handler_4), - listen(button1, "click", click_handler_5) + listen(button0, "click", click_handler_5), + listen(button1, "click", click_handler_6) ]; mounted = true; @@ -30559,7 +30971,7 @@ function create_each_block$1(ctx) { }, p(new_ctx, dirty) { ctx = new_ctx; - if (dirty[0] & /*$selectedDraft*/ 2 && t0_value !== (t0_value = /*fileName*/ ctx[40] + "")) set_data(t0, t0_value); + if (dirty[0] & /*$selectedDraft*/ 2 && t0_value !== (t0_value = /*fileName*/ ctx[45] + "")) set_data(t0, t0_value); }, d(detaching) { if (detaching) detach(li); @@ -30569,7 +30981,7 @@ function create_each_block$1(ctx) { }; } -function create_fragment$7(ctx) { +function create_fragment$8(ctx) { let div1; let div0; let sortablelist; @@ -30578,7 +30990,7 @@ function create_fragment$7(ctx) { let current; function sortablelist_items_binding(value) { - /*sortablelist_items_binding*/ ctx[22](value); + /*sortablelist_items_binding*/ ctx[26](value); } let sortablelist_props = { @@ -30588,8 +31000,8 @@ function create_fragment$7(ctx) { $$slots: { default: [ create_default_slot, - ({ item }) => ({ 43: item }), - ({ item }) => [0, item ? 4096 : 0] + ({ item }) => ({ 48: item }), + ({ item }) => [0, item ? 131072 : 0] ] }, $$scope: { ctx } @@ -30603,7 +31015,7 @@ function create_fragment$7(ctx) { binding_callbacks.push(() => bind(sortablelist, 'items', sortablelist_items_binding)); sortablelist.$on("orderChanged", /*itemOrderChanged*/ ctx[9]); sortablelist.$on("indentChanged", /*itemIndentChanged*/ ctx[10]); - let if_block = /*$selectedDraft*/ ctx[1] && /*$selectedDraft*/ ctx[1].format === "scenes" && /*$selectedDraft*/ ctx[1].unknownFiles.length > 0 && create_if_block$7(ctx); + let if_block = /*$selectedDraft*/ ctx[1] && /*$selectedDraft*/ ctx[1].format === "scenes" && /*$selectedDraft*/ ctx[1].unknownFiles.length > 0 && create_if_block$8(ctx); return { c() { @@ -30629,7 +31041,7 @@ function create_fragment$7(ctx) { p(ctx, dirty) { const sortablelist_changes = {}; - if (dirty[0] & /*$activeFile, editingPath, $pluginSettings, collapsedItems*/ 225 | dirty[1] & /*$$scope, item*/ 12288) { + if (dirty[0] & /*$activeFile, editingPath, $pluginSettings, collapsedItems*/ 225 | dirty[1] & /*$$scope, item*/ 393216) { sortablelist_changes.$$scope = { dirty, ctx }; } @@ -30653,7 +31065,7 @@ function create_fragment$7(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$7(ctx); + if_block = create_if_block$8(ctx); if_block.c(); if_block.m(div1, null); } @@ -30679,12 +31091,12 @@ function create_fragment$7(ctx) { }; } -function instance$7($$self, $$props, $$invalidate) { +function instance$8($$self, $$props, $$invalidate) { let $drafts; let $selectedDraft; let $activeFile; let $pluginSettings; - component_subscribe($$self, drafts, $$value => $$invalidate(19, $drafts = $$value)); + component_subscribe($$self, drafts, $$value => $$invalidate(22, $drafts = $$value)); component_subscribe($$self, selectedDraft, $$value => $$invalidate(1, $selectedDraft = $$value)); component_subscribe($$self, activeFile, $$value => $$invalidate(6, $activeFile = $$value)); component_subscribe($$self, pluginSettings, $$value => $$invalidate(7, $pluginSettings = $$value)); @@ -30697,6 +31109,16 @@ function instance$7($$self, $$props, $$invalidate) { let items; let collapsedItems = []; + // Bumped whenever the metadata cache changes, so that `ignored` + // (read from each scene file's frontmatter) re-derives automatically. + let metadataVersion = 0; + + const metadataCacheRef = app.metadataCache.on("changed", () => { + $$invalidate(21, metadataVersion++, metadataVersion); + }); + + onDestroy(() => app.metadataCache.offref(metadataCacheRef)); + // INDENTATION & COLLAPSING let ghostIndent = 0; @@ -30704,11 +31126,23 @@ function instance$7($$self, $$props, $$invalidate) { let draggingID = null; function itemsFromScenes(indentedScenes, _collapsedItems) { - const scenes = numberScenes(indentedScenes); + const draft = $selectedDraft; + const numberingByTitle = new Map(); + + for (const s of numberScenes(scenesForCompileNumbering(app, draft))) { + numberingByTitle.set(s.title, s.numbering); + } + const itemsToReturn = []; let ignoringUntilIndent = Infinity; - scenes.forEach(({ title, indent, numbering }, index) => { + indentedScenes.forEach(({ title, indent }, index) => { + var _a; + + const numbering = (_a = numberingByTitle.get(title)) !== null && _a !== void 0 + ? _a + : []; + const hidden = indent > ignoringUntilIndent; if (!hidden) { @@ -30721,16 +31155,24 @@ function instance$7($$self, $$props, $$invalidate) { ignoringUntilIndent = Math.min(ignoringUntilIndent, indent); } - const nextScene = index < scenes.length - 1 ? scenes[index + 1] : false; + const nextScene = index < indentedScenes.length - 1 + ? indentedScenes[index + 1] + : null; + const path = makeScenePath($selectedDraft, title); const file = app.vault.getAbstractFileByPath(path); let status = undefined; + let ignored = false; if (file && file instanceof obsidian.TFile) { const metadata = app.metadataCache.getFileCache(file); - if (metadata && metadata.frontmatter && metadata.frontmatter["status"]) { - status = `${metadata.frontmatter["status"]}`; + if (metadata && metadata.frontmatter) { + if (metadata.frontmatter["status"]) { + status = `${metadata.frontmatter["status"]}`; + } + + ignored = !!metadata.frontmatter["longform-ignore"]; } } @@ -30739,8 +31181,9 @@ function instance$7($$self, $$props, $$invalidate) { name: title, indent, path, - collapsible: nextScene && nextScene.indent > indent, + collapsible: !!nextScene && nextScene.indent > indent, hidden, + ignored, numbering, status }; @@ -30807,6 +31250,32 @@ function instance$7($$self, $$props, $$invalidate) { } } + function toggleIgnore(item) { + return __awaiter(this, void 0, void 0, function* () { + const file = app.vault.getAbstractFileByPath(item.path); + if (!(file instanceof obsidian.TFile)) return; + + yield app.fileManager.processFrontMatter(file, fm => { + if (fm["longform-ignore"]) { + delete fm["longform-ignore"]; + } else { + fm["longform-ignore"] = true; + } + }); + }); + } + + function iconAction(node, name) { + obsidian.setIcon(node, name); + + return { + update(next) { + node.empty(); + obsidian.setIcon(node, next); + } + }; + } + // Grab the click context function and call it when a valid scene is clicked. const onSceneClick = getContext("onSceneClick"); @@ -30921,6 +31390,10 @@ function instance$7($$self, $$props, $$invalidate) { } function numberLabel(item) { + if (item.ignored) { + return ""; + } + return formatSceneNumber(item.numbering); } @@ -30986,25 +31459,28 @@ function instance$7($$self, $$props, $$invalidate) { ? onItemClick(item, e) : {}; + const click_handler_2 = item => toggleIgnore(item); + function sortablelist_items_binding(value) { items = value; - (($$invalidate(2, items), $$invalidate(1, $selectedDraft)), $$invalidate(0, collapsedItems)); + ((($$invalidate(2, items), $$invalidate(21, metadataVersion)), $$invalidate(1, $selectedDraft)), $$invalidate(0, collapsedItems)); } - const click_handler_2 = () => doWithAll("add"); - const click_handler_3 = () => doWithAll("ignore"); - const click_handler_4 = fileName => doWithUnknown(fileName, "add"); - const click_handler_5 = fileName => doWithUnknown(fileName, "ignore"); + const click_handler_3 = () => doWithAll("add"); + const click_handler_4 = () => doWithAll("ignore"); + const click_handler_5 = fileName => doWithUnknown(fileName, "add"); + const click_handler_6 = fileName => doWithUnknown(fileName, "ignore"); $$self.$$.update = () => { - if ($$self.$$.dirty[0] & /*$selectedDraft, $drafts*/ 524290) { + if ($$self.$$.dirty[0] & /*$selectedDraft, $drafts*/ 4194306) { if ($selectedDraft) { currentDraftIndex = $drafts.findIndex(d => d.vaultPath === $selectedDraft.vaultPath); } } - if ($$self.$$.dirty[0] & /*$selectedDraft, collapsedItems*/ 3) { + if ($$self.$$.dirty[0] & /*metadataVersion, $selectedDraft, collapsedItems*/ 2097155) { { + $$invalidate(2, items = $selectedDraft && $selectedDraft.format === "scenes" ? itemsFromScenes($selectedDraft.scenes, collapsedItems) : []); @@ -31025,6 +31501,8 @@ function instance$7($$self, $$props, $$invalidate) { itemOrderChanged, itemIndentChanged, collapseItem, + toggleIgnore, + iconAction, onItemClick, onContext, onKeydown, @@ -31032,32 +31510,34 @@ function instance$7($$self, $$props, $$invalidate) { doWithUnknown, doWithAll, numberLabel, + metadataVersion, $drafts, click_handler, click_handler_1, - sortablelist_items_binding, click_handler_2, + sortablelist_items_binding, click_handler_3, click_handler_4, - click_handler_5 + click_handler_5, + click_handler_6 ]; } class SceneList extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$7, create_fragment$7, safe_not_equal, {}, add_css$7, [-1, -1]); + init(this, options, instance$8, create_fragment$8, safe_not_equal, {}, add_css$8, [-1, -1]); } } /* src/view/components/Icon.svelte generated by Svelte v3.49.0 */ -function add_css$6(target) { +function add_css$7(target) { append_styles(target, "svelte-eq2zbb", "span.svelte-eq2zbb{display:flex;align-items:center;justify-content:center}"); } // (9:0) {#if iconName.length > 0} -function create_if_block$6(ctx) { +function create_if_block$7(ctx) { let span; let icon_action; let mounted; @@ -31087,9 +31567,9 @@ function create_if_block$6(ctx) { }; } -function create_fragment$6(ctx) { +function create_fragment$7(ctx) { let if_block_anchor; - let if_block = /*iconName*/ ctx[0].length > 0 && create_if_block$6(ctx); + let if_block = /*iconName*/ ctx[0].length > 0 && create_if_block$7(ctx); return { c() { @@ -31105,7 +31585,7 @@ function create_fragment$6(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$6(ctx); + if_block = create_if_block$7(ctx); if_block.c(); if_block.m(if_block_anchor.parentNode, if_block_anchor); } @@ -31123,7 +31603,7 @@ function create_fragment$6(ctx) { }; } -function instance$6($$self, $$props, $$invalidate) { +function instance$7($$self, $$props, $$invalidate) { let { iconName = "" } = $$props; const icon = (node, icon) => { @@ -31140,7 +31620,7 @@ function instance$6($$self, $$props, $$invalidate) { class Icon extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$6, create_fragment$6, safe_not_equal, { iconName: 0 }, add_css$6); + init(this, options, instance$7, create_fragment$7, safe_not_equal, { iconName: 0 }, add_css$7); } } @@ -33313,24 +33793,24 @@ class FolderSuggest extends TextInputSuggest { /* src/view/explorer/DraftList.svelte generated by Svelte v3.49.0 */ -function add_css$5(target) { +function add_css$6(target) { append_styles(target, "svelte-1ytjg2y", "#draft-list.svelte-1ytjg2y.svelte-1ytjg2y{margin:var(--size-4-1) 0}#draft-list.svelte-1ytjg2y ol.svelte-1ytjg2y{list-style-type:none;padding:0;margin:0}.draft-container.svelte-1ytjg2y.svelte-1ytjg2y{display:flex;border:var(--border-width) solid transparent;border-radius:var(--radius-s);cursor:pointer;color:var(--text-muted);font-size:var(--font-small);line-height:var(--h3-line-height);white-space:nowrap;padding:var(--size-2-1) 0}.selected.svelte-1ytjg2y.svelte-1ytjg2y,.draft-container.svelte-1ytjg2y.svelte-1ytjg2y:hover{background-color:var(--background-secondary-alt);color:var(--text-normal)}.draft-container.svelte-1ytjg2y.svelte-1ytjg2y:active{background-color:inherit;color:var(--text-muted)}"); } -function get_each_context(ctx, list, i) { +function get_each_context$1(ctx, list, i) { const child_ctx = ctx.slice(); child_ctx[11] = list[i]; return child_ctx; } // (52:2) {#if $selectedProject} -function create_if_block$5(ctx) { +function create_if_block$6(ctx) { let ol; let each_value = /*$selectedProject*/ ctx[1]; let each_blocks = []; for (let i = 0; i < each_value.length; i += 1) { - each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i)); + each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i)); } return { @@ -33356,12 +33836,12 @@ function create_if_block$5(ctx) { let i; for (i = 0; i < each_value.length; i += 1) { - const child_ctx = get_each_context(ctx, each_value, i); + const child_ctx = get_each_context$1(ctx, each_value, i); if (each_blocks[i]) { each_blocks[i].p(child_ctx, dirty); } else { - each_blocks[i] = create_each_block(child_ctx); + each_blocks[i] = create_each_block$1(child_ctx); each_blocks[i].c(); each_blocks[i].m(ol, null); } @@ -33382,7 +33862,7 @@ function create_if_block$5(ctx) { } // (54:6) {#each $selectedProject as draft} -function create_each_block(ctx) { +function create_each_block$1(ctx) { let li; let div; let t0_value = draftTitle(/*draft*/ ctx[11]) + ""; @@ -33461,9 +33941,9 @@ function create_each_block(ctx) { }; } -function create_fragment$5(ctx) { +function create_fragment$6(ctx) { let div; - let if_block = /*$selectedProject*/ ctx[1] && create_if_block$5(ctx); + let if_block = /*$selectedProject*/ ctx[1] && create_if_block$6(ctx); return { c() { @@ -33481,7 +33961,7 @@ function create_fragment$5(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$5(ctx); + if_block = create_if_block$6(ctx); if_block.c(); if_block.m(div, null); } @@ -33499,7 +33979,7 @@ function create_fragment$5(ctx) { }; } -function instance$5($$self, $$props, $$invalidate) { +function instance$6($$self, $$props, $$invalidate) { let $drafts; let $selectedDraftVaultPath; let $selectedProject; @@ -33580,18 +34060,18 @@ function instance$5($$self, $$props, $$invalidate) { class DraftList extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$5, create_fragment$5, safe_not_equal, {}, add_css$5); + init(this, options, instance$6, create_fragment$6, safe_not_equal, {}, add_css$6); } } /* src/view/explorer/ProjectDetails.svelte generated by Svelte v3.49.0 */ -function add_css$4(target) { - append_styles(target, "svelte-db2avi", ".longform-project-section.svelte-db2avi.svelte-db2avi{margin-top:var(--size-4-4);padding-bottom:var(--size-4-2);padding-left:var(--size-4-8)}.longform-project-section.svelte-db2avi+.longform-project-section.svelte-db2avi{border-top:var(--border-width) solid var(--background-modifier-border);padding-top:var(--size-4-4)}.longform-project-details-section-header.svelte-db2avi.svelte-db2avi{display:flex;flex-direction:row;justify-content:start;align-items:center;cursor:pointer;margin-left:calc(var(--size-4-6) * -1)}h4.svelte-db2avi.svelte-db2avi{font-size:var(--font-ui-medium);color:var(--text-normal);user-select:none;font-weight:inherit;margin:0 0 0 var(--size-4-4)}input.svelte-db2avi.svelte-db2avi{width:100%}label.svelte-db2avi.svelte-db2avi{display:block;font-size:var(--font-ui-smaller);color:var(--text-muted);margin-top:var(--size-4-4);line-height:var(--line-height-tight)}p.longform-project-warning.svelte-db2avi.svelte-db2avi{color:var(--text-faint);font-size:var(--font-smallest);margin:var(--size-2-1) 0 0 var(--size-2-1);line-height:normal}.word-counts.svelte-db2avi p.svelte-db2avi{margin:var(--size-4-2) 0;font-size:var(--font-smallest);color:var(--text-muted)}.word-counts.svelte-db2avi p strong.svelte-db2avi{color:var(--text-normal)}.progress.svelte-db2avi.svelte-db2avi{height:var(--size-4-6);width:100%;background-color:var(--background-secondary-alt);border-radius:var(--radius-s);position:relative;overflow:hidden;margin-top:var(--size-4-4)}.progress.svelte-db2avi.svelte-db2avi:before{content:attr(data-label);font-size:var(--font-smallest);color:var(--progress-text-color);font-weight:bold;position:absolute;text-align:center;top:0;left:0;right:0;display:flex;justify-content:center;align-items:center;align-self:center;height:100%}.progress.svelte-db2avi .value.svelte-db2avi{height:100%;background-color:var(--text-accent)}.drafts-title-container.svelte-db2avi.svelte-db2avi{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:var(--size-4-2)}.drafts-title-container.svelte-db2avi h4.svelte-db2avi{margin-right:var(--size-4-2)}.drafts-title-container.svelte-db2avi button.svelte-db2avi{margin:0;padding:var(--size-4-2);color:var(--interactive-accent);background-color:inherit}"); +function add_css$5(target) { + append_styles(target, "svelte-1ioudaq", ".longform-project-section.svelte-1ioudaq.svelte-1ioudaq{margin-top:var(--size-4-4);padding-bottom:var(--size-4-2);padding-left:var(--size-4-8)}.longform-project-section.svelte-1ioudaq+.longform-project-section.svelte-1ioudaq{border-top:var(--border-width) solid var(--background-modifier-border);padding-top:var(--size-4-4)}.longform-project-details-section-header.svelte-1ioudaq.svelte-1ioudaq{display:flex;flex-direction:row;justify-content:start;align-items:center;cursor:pointer;margin-left:calc(var(--size-4-6) * -1)}h4.svelte-1ioudaq.svelte-1ioudaq{font-size:var(--font-ui-medium);color:var(--text-normal);user-select:none;font-weight:inherit;margin:0 0 0 var(--size-4-4)}input.svelte-1ioudaq.svelte-1ioudaq{width:100%}label.svelte-1ioudaq.svelte-1ioudaq{display:block;font-size:var(--font-ui-smaller);color:var(--text-muted);margin-top:var(--size-4-4);line-height:var(--line-height-tight)}p.longform-project-warning.svelte-1ioudaq.svelte-1ioudaq{color:var(--text-faint);font-size:var(--font-smallest);margin:var(--size-2-1) 0 0 var(--size-2-1);line-height:normal}.word-counts.svelte-1ioudaq p.svelte-1ioudaq{margin:var(--size-4-2) 0;font-size:var(--font-smallest);color:var(--text-muted)}.word-counts.svelte-1ioudaq p strong.svelte-1ioudaq{color:var(--text-normal)}.progress.svelte-1ioudaq.svelte-1ioudaq{height:var(--size-4-6);width:100%;background-color:var(--background-secondary-alt);border-radius:var(--radius-s);position:relative;overflow:hidden;margin-top:var(--size-4-4)}.progress.svelte-1ioudaq.svelte-1ioudaq:before{content:attr(data-label);font-size:var(--font-smallest);color:var(--progress-text-color);font-weight:bold;position:absolute;text-align:center;top:0;left:0;right:0;display:flex;justify-content:center;align-items:center;align-self:center;height:100%}.progress.svelte-1ioudaq .value.svelte-1ioudaq{height:100%;background-color:var(--text-accent)}.drafts-title-container.svelte-1ioudaq.svelte-1ioudaq{display:flex;flex-direction:row;justify-content:space-between;align-items:center;margin-bottom:var(--size-4-2)}.drafts-title-container.svelte-1ioudaq h4.svelte-1ioudaq{margin-right:var(--size-4-2)}.drafts-title-container.svelte-1ioudaq button.svelte-1ioudaq{margin:0;padding:var(--size-4-2);color:var(--interactive-accent);background-color:inherit}.longform-manuscript-metadata-help.svelte-1ioudaq.svelte-1ioudaq{color:var(--text-muted);font-size:var(--font-ui-smaller);line-height:var(--line-height-tight);margin:var(--size-4-2) 0 var(--size-4-3) 0}.longform-manuscript-metadata-help.svelte-1ioudaq a.svelte-1ioudaq{color:var(--text-accent)}.longform-edit-metadata-button.svelte-1ioudaq.svelte-1ioudaq{width:100%}"); } -// (145:2) {#if $selectedDraft} -function create_if_block_5$1(ctx) { +// (150:2) {#if $selectedDraft} +function create_if_block_7(ctx) { let div1; let div0; let disclosure; @@ -33606,7 +34086,7 @@ function create_if_block_5$1(ctx) { props: { collapsed: !/*showMetdata*/ ctx[1] } }); - let if_block = /*showMetdata*/ ctx[1] && create_if_block_6(ctx); + let if_block = /*showMetdata*/ ctx[1] && create_if_block_8(ctx); return { c() { @@ -33618,9 +34098,9 @@ function create_if_block_5$1(ctx) { h4.textContent = "Project Metadata"; t2 = space(); if (if_block) if_block.c(); - attr(h4, "class", "svelte-db2avi"); - attr(div0, "class", "longform-project-details-section-header svelte-db2avi"); - attr(div1, "class", "longform-project-section svelte-db2avi"); + attr(h4, "class", "svelte-1ioudaq"); + attr(div0, "class", "longform-project-details-section-header svelte-1ioudaq"); + attr(div1, "class", "longform-project-section svelte-1ioudaq"); }, m(target, anchor) { insert(target, div1, anchor); @@ -33633,20 +34113,20 @@ function create_if_block_5$1(ctx) { current = true; if (!mounted) { - dispose = listen(div0, "click", /*click_handler*/ ctx[22]); + dispose = listen(div0, "click", /*click_handler*/ ctx[24]); mounted = true; } }, p(ctx, dirty) { const disclosure_changes = {}; - if (dirty & /*showMetdata*/ 2) disclosure_changes.collapsed = !/*showMetdata*/ ctx[1]; + if (dirty[0] & /*showMetdata*/ 2) disclosure_changes.collapsed = !/*showMetdata*/ ctx[1]; disclosure.$set(disclosure_changes); if (/*showMetdata*/ ctx[1]) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block_6(ctx); + if_block = create_if_block_8(ctx); if_block.c(); if_block.m(div1, null); } @@ -33674,8 +34154,8 @@ function create_if_block_5$1(ctx) { }; } -// (156:6) {#if showMetdata} -function create_if_block_6(ctx) { +// (161:6) {#if showMetdata} +function create_if_block_8(ctx) { let div; let label; let t1; @@ -33684,7 +34164,7 @@ function create_if_block_6(ctx) { let t2; let mounted; let dispose; - let if_block = /*$selectedDraft*/ ctx[0].format === "scenes" && create_if_block_7(ctx); + let if_block = /*$selectedDraft*/ ctx[0].format === "scenes" && create_if_block_9(ctx); return { c() { @@ -33696,11 +34176,11 @@ function create_if_block_6(ctx) { t2 = space(); if (if_block) if_block.c(); attr(label, "for", "longform-project-title"); - attr(label, "class", "svelte-db2avi"); + attr(label, "class", "svelte-1ioudaq"); attr(input, "id", "longform-project-title"); attr(input, "type", "text"); input.value = input_value_value = /*$selectedDraft*/ ctx[0].title; - attr(input, "class", "svelte-db2avi"); + attr(input, "class", "svelte-1ioudaq"); }, m(target, anchor) { insert(target, div, anchor); @@ -33711,12 +34191,12 @@ function create_if_block_6(ctx) { if (if_block) if_block.m(div, null); if (!mounted) { - dispose = listen(input, "change", /*titleChanged*/ ctx[12]); + dispose = listen(input, "change", /*titleChanged*/ ctx[13]); mounted = true; } }, p(ctx, dirty) { - if (dirty & /*$selectedDraft*/ 1 && input_value_value !== (input_value_value = /*$selectedDraft*/ ctx[0].title) && input.value !== input_value_value) { + if (dirty[0] & /*$selectedDraft*/ 1 && input_value_value !== (input_value_value = /*$selectedDraft*/ ctx[0].title) && input.value !== input_value_value) { input.value = input_value_value; } @@ -33724,7 +34204,7 @@ function create_if_block_6(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block_7(ctx); + if_block = create_if_block_9(ctx); if_block.c(); if_block.m(div, null); } @@ -33742,8 +34222,8 @@ function create_if_block_6(ctx) { }; } -// (165:10) {#if $selectedDraft.format === "scenes"} -function create_if_block_7(ctx) { +// (170:10) {#if $selectedDraft.format === "scenes"} +function create_if_block_9(ctx) { let label0; let t1; let input0; @@ -33778,50 +34258,50 @@ function create_if_block_7(ctx) { p1 = element("p"); p1.textContent = "This file will be used as a template when creating new scenes\n via the New Scene… field. If you use a templating plugin\n (Templater or the core plugin) it will be used to process this\n template."; attr(label0, "for", "longform-project-scene-folder"); - attr(label0, "class", "svelte-db2avi"); + attr(label0, "class", "svelte-1ioudaq"); attr(input0, "id", "longform-project-scene-folder"); attr(input0, "type", "text"); input0.value = input0_value_value = /*$selectedDraft*/ ctx[0].sceneFolder; - attr(input0, "class", "svelte-db2avi"); - attr(p0, "class", "longform-project-warning svelte-db2avi"); + attr(input0, "class", "svelte-1ioudaq"); + attr(p0, "class", "longform-project-warning svelte-1ioudaq"); attr(label1, "for", "longform-project-scene-template"); - attr(label1, "class", "svelte-db2avi"); + attr(label1, "class", "svelte-1ioudaq"); attr(input1, "id", "longform-project-scene-template"); attr(input1, "type", "text"); input1.value = input1_value_value = /*$selectedDraft*/ ctx[0].sceneTemplate; - attr(input1, "class", "svelte-db2avi"); - attr(p1, "class", "longform-project-warning svelte-db2avi"); + attr(input1, "class", "svelte-1ioudaq"); + attr(p1, "class", "longform-project-warning svelte-1ioudaq"); }, m(target, anchor) { insert(target, label0, anchor); insert(target, t1, anchor); insert(target, input0, anchor); - /*input0_binding*/ ctx[23](input0); + /*input0_binding*/ ctx[25](input0); insert(target, t2, anchor); insert(target, p0, anchor); insert(target, t4, anchor); insert(target, label1, anchor); insert(target, t6, anchor); insert(target, input1, anchor); - /*input1_binding*/ ctx[24](input1); + /*input1_binding*/ ctx[26](input1); insert(target, t7, anchor); insert(target, p1, anchor); if (!mounted) { dispose = [ - listen(input0, "blur", /*sceneFolderChanged*/ ctx[13]), - listen(input1, "blur", /*sceneTemplateChanged*/ ctx[14]) + listen(input0, "blur", /*sceneFolderChanged*/ ctx[14]), + listen(input1, "blur", /*sceneTemplateChanged*/ ctx[15]) ]; mounted = true; } }, p(ctx, dirty) { - if (dirty & /*$selectedDraft*/ 1 && input0_value_value !== (input0_value_value = /*$selectedDraft*/ ctx[0].sceneFolder) && input0.value !== input0_value_value) { + if (dirty[0] & /*$selectedDraft*/ 1 && input0_value_value !== (input0_value_value = /*$selectedDraft*/ ctx[0].sceneFolder) && input0.value !== input0_value_value) { input0.value = input0_value_value; } - if (dirty & /*$selectedDraft*/ 1 && input1_value_value !== (input1_value_value = /*$selectedDraft*/ ctx[0].sceneTemplate) && input1.value !== input1_value_value) { + if (dirty[0] & /*$selectedDraft*/ 1 && input1_value_value !== (input1_value_value = /*$selectedDraft*/ ctx[0].sceneTemplate) && input1.value !== input1_value_value) { input1.value = input1_value_value; } }, @@ -33829,14 +34309,14 @@ function create_if_block_7(ctx) { if (detaching) detach(label0); if (detaching) detach(t1); if (detaching) detach(input0); - /*input0_binding*/ ctx[23](null); + /*input0_binding*/ ctx[25](null); if (detaching) detach(t2); if (detaching) detach(p0); if (detaching) detach(t4); if (detaching) detach(label1); if (detaching) detach(t6); if (detaching) detach(input1); - /*input1_binding*/ ctx[24](null); + /*input1_binding*/ ctx[26](null); if (detaching) detach(t7); if (detaching) detach(p1); mounted = false; @@ -33845,8 +34325,140 @@ function create_if_block_7(ctx) { }; } -// (214:4) {#if showWordCount} -function create_if_block_1$4(ctx) { +// (204:2) {#if $selectedDraft} +function create_if_block_5$1(ctx) { + let div1; + let div0; + let disclosure; + let t0; + let h4; + let t2; + let current; + let mounted; + let dispose; + + disclosure = new Disclosure({ + props: { + collapsed: !/*showManuscriptMetadata*/ ctx[12] + } + }); + + let if_block = /*showManuscriptMetadata*/ ctx[12] && create_if_block_6(ctx); + + return { + c() { + div1 = element("div"); + div0 = element("div"); + create_component(disclosure.$$.fragment); + t0 = space(); + h4 = element("h4"); + h4.textContent = "Manuscript Metadata"; + t2 = space(); + if (if_block) if_block.c(); + attr(h4, "class", "svelte-1ioudaq"); + attr(div0, "class", "longform-project-details-section-header svelte-1ioudaq"); + attr(div1, "class", "longform-project-section svelte-1ioudaq"); + }, + m(target, anchor) { + insert(target, div1, anchor); + append(div1, div0); + mount_component(disclosure, div0, null); + append(div0, t0); + append(div0, h4); + append(div1, t2); + if (if_block) if_block.m(div1, null); + current = true; + + if (!mounted) { + dispose = listen(div0, "click", /*click_handler_1*/ ctx[27]); + mounted = true; + } + }, + p(ctx, dirty) { + const disclosure_changes = {}; + if (dirty[0] & /*showManuscriptMetadata*/ 4096) disclosure_changes.collapsed = !/*showManuscriptMetadata*/ ctx[12]; + disclosure.$set(disclosure_changes); + + if (/*showManuscriptMetadata*/ ctx[12]) { + if (if_block) { + if_block.p(ctx, dirty); + } else { + if_block = create_if_block_6(ctx); + if_block.c(); + if_block.m(div1, null); + } + } else if (if_block) { + if_block.d(1); + if_block = null; + } + }, + i(local) { + if (current) return; + transition_in(disclosure.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(disclosure.$$.fragment, local); + current = false; + }, + d(detaching) { + if (detaching) detach(div1); + destroy_component(disclosure); + if (if_block) if_block.d(); + mounted = false; + dispose(); + } + }; +} + +// (215:6) {#if showManuscriptMetadata} +function create_if_block_6(ctx) { + let div; + let p; + let t7; + let button; + let mounted; + let dispose; + + return { + c() { + div = element("div"); + p = element("p"); + + p.innerHTML = `Authors, abstract, journal, and Pandoc options for the + Add Zenodo Frontmatter compile step. Stored as + metadata.json in your project folder, in + Zenodo deposition format.`; + + t7 = space(); + button = element("button"); + button.textContent = "Edit metadata…"; + attr(p, "class", "longform-manuscript-metadata-help svelte-1ioudaq"); + attr(button, "type", "button"); + attr(button, "class", "longform-edit-metadata-button svelte-1ioudaq"); + }, + m(target, anchor) { + insert(target, div, anchor); + append(div, p); + append(div, t7); + append(div, button); + + if (!mounted) { + dispose = listen(button, "click", /*onEditMetadata*/ ctx[17]); + mounted = true; + } + }, + p: noop, + d(detaching) { + if (detaching) detach(div); + mounted = false; + dispose(); + } + }; +} + +// (253:4) {#if showWordCount} +function create_if_block_1$5(ctx) { let div; let t0; let t1; @@ -33858,7 +34470,7 @@ function create_if_block_1$4(ctx) { let t5; let if_block0 = /*showProgress*/ ctx[9] && create_if_block_4$1(ctx); let if_block1 = /*sceneCount*/ ctx[8] && create_if_block_3$1(ctx); - let if_block2 = /*draftCount*/ ctx[7] && create_if_block_2$2(ctx); + let if_block2 = /*draftCount*/ ctx[7] && create_if_block_2$3(ctx); return { c() { @@ -33874,9 +34486,9 @@ function create_if_block_1$4(ctx) { strong.textContent = "Project:"; t4 = space(); t5 = text(t5_value); - attr(strong, "class", "svelte-db2avi"); + attr(strong, "class", "svelte-1ioudaq"); attr(p, "title", "Word count across all drafts of this project."); - attr(p, "class", "svelte-db2avi"); + attr(p, "class", "svelte-1ioudaq"); }, m(target, anchor) { insert(target, div, anchor); @@ -33922,7 +34534,7 @@ function create_if_block_1$4(ctx) { if (if_block2) { if_block2.p(ctx, dirty); } else { - if_block2 = create_if_block_2$2(ctx); + if_block2 = create_if_block_2$3(ctx); if_block2.c(); if_block2.m(div, t2); } @@ -33931,7 +34543,7 @@ function create_if_block_1$4(ctx) { if_block2 = null; } - if (dirty & /*projectCount*/ 64 && t5_value !== (t5_value = pluralize(/*projectCount*/ ctx[6], "word") + "")) set_data(t5, t5_value); + if (dirty[0] & /*projectCount*/ 64 && t5_value !== (t5_value = pluralize(/*projectCount*/ ctx[6], "word") + "")) set_data(t5, t5_value); }, d(detaching) { if (detaching) detach(div); @@ -33942,7 +34554,7 @@ function create_if_block_1$4(ctx) { }; } -// (216:8) {#if showProgress} +// (255:8) {#if showProgress} function create_if_block_4$1(ctx) { let div1; let div0; @@ -33952,9 +34564,9 @@ function create_if_block_4$1(ctx) { c() { div1 = element("div"); div0 = element("div"); - attr(div0, "class", "value svelte-db2avi"); + attr(div0, "class", "value svelte-1ioudaq"); attr(div0, "style", div0_style_value = `width:${/*goalPercentage*/ ctx[10]}%;`); - attr(div1, "class", "progress svelte-db2avi"); + attr(div1, "class", "progress svelte-1ioudaq"); attr(div1, "data-label", /*goalDescription*/ ctx[11]); attr(div1, "title", /*goalDescription*/ ctx[11]); }, @@ -33963,15 +34575,15 @@ function create_if_block_4$1(ctx) { append(div1, div0); }, p(ctx, dirty) { - if (dirty & /*goalPercentage*/ 1024 && div0_style_value !== (div0_style_value = `width:${/*goalPercentage*/ ctx[10]}%;`)) { + if (dirty[0] & /*goalPercentage*/ 1024 && div0_style_value !== (div0_style_value = `width:${/*goalPercentage*/ ctx[10]}%;`)) { attr(div0, "style", div0_style_value); } - if (dirty & /*goalDescription*/ 2048) { + if (dirty[0] & /*goalDescription*/ 2048) { attr(div1, "data-label", /*goalDescription*/ ctx[11]); } - if (dirty & /*goalDescription*/ 2048) { + if (dirty[0] & /*goalDescription*/ 2048) { attr(div1, "title", /*goalDescription*/ ctx[11]); } }, @@ -33981,7 +34593,7 @@ function create_if_block_4$1(ctx) { }; } -// (225:8) {#if sceneCount} +// (264:8) {#if sceneCount} function create_if_block_3$1(ctx) { let p; let strong; @@ -33996,9 +34608,9 @@ function create_if_block_3$1(ctx) { strong.textContent = "Scene:"; t1 = space(); t2 = text(t2_value); - attr(strong, "class", "svelte-db2avi"); + attr(strong, "class", "svelte-1ioudaq"); attr(p, "title", "Word count in this scene of this project."); - attr(p, "class", "svelte-db2avi"); + attr(p, "class", "svelte-1ioudaq"); }, m(target, anchor) { insert(target, p, anchor); @@ -34007,7 +34619,7 @@ function create_if_block_3$1(ctx) { append(p, t2); }, p(ctx, dirty) { - if (dirty & /*sceneCount*/ 256 && t2_value !== (t2_value = pluralize(/*sceneCount*/ ctx[8], "word") + "")) set_data(t2, t2_value); + if (dirty[0] & /*sceneCount*/ 256 && t2_value !== (t2_value = pluralize(/*sceneCount*/ ctx[8], "word") + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) detach(p); @@ -34015,8 +34627,8 @@ function create_if_block_3$1(ctx) { }; } -// (231:8) {#if draftCount} -function create_if_block_2$2(ctx) { +// (270:8) {#if draftCount} +function create_if_block_2$3(ctx) { let p; let strong; let t1; @@ -34030,9 +34642,9 @@ function create_if_block_2$2(ctx) { strong.textContent = "Draft:"; t1 = space(); t2 = text(t2_value); - attr(strong, "class", "svelte-db2avi"); + attr(strong, "class", "svelte-1ioudaq"); attr(p, "title", "Word count in just this draft of this project."); - attr(p, "class", "svelte-db2avi"); + attr(p, "class", "svelte-1ioudaq"); }, m(target, anchor) { insert(target, p, anchor); @@ -34041,7 +34653,7 @@ function create_if_block_2$2(ctx) { append(p, t2); }, p(ctx, dirty) { - if (dirty & /*draftCount*/ 128 && t2_value !== (t2_value = pluralize(/*draftCount*/ ctx[7], "word") + "")) set_data(t2, t2_value); + if (dirty[0] & /*draftCount*/ 128 && t2_value !== (t2_value = pluralize(/*draftCount*/ ctx[7], "word") + "")) set_data(t2, t2_value); }, d(detaching) { if (detaching) detach(p); @@ -34049,8 +34661,8 @@ function create_if_block_2$2(ctx) { }; } -// (259:4) {#if showDrafts} -function create_if_block$4(ctx) { +// (298:4) {#if showDrafts} +function create_if_block$5(ctx) { let draftlist; let current; draftlist = new DraftList({}); @@ -34078,131 +34690,137 @@ function create_if_block$4(ctx) { }; } -function create_fragment$4(ctx) { +function create_fragment$5(ctx) { let div5; let t0; + let t1; let div1; let div0; let disclosure0; - let t1; + let t2; let h40; - let t3; - let div1_style_value; let t4; + let div1_style_value; + let t5; let div4; let div3; let div2; let disclosure1; - let t5; + let t6; let h41; - let t7; + let t8; let button; let icon; - let t8; + let t9; let current; let mounted; let dispose; - let if_block0 = /*$selectedDraft*/ ctx[0] && create_if_block_5$1(ctx); + let if_block0 = /*$selectedDraft*/ ctx[0] && create_if_block_7(ctx); + let if_block1 = /*$selectedDraft*/ ctx[0] && create_if_block_5$1(ctx); disclosure0 = new Disclosure({ props: { collapsed: !/*showWordCount*/ ctx[2] } }); - let if_block1 = /*showWordCount*/ ctx[2] && create_if_block_1$4(ctx); + let if_block2 = /*showWordCount*/ ctx[2] && create_if_block_1$5(ctx); disclosure1 = new Disclosure({ props: { collapsed: !/*showDrafts*/ ctx[3] } }); icon = new Icon({ props: { iconName: "plus-with-circle" } }); - let if_block2 = /*showDrafts*/ ctx[3] && create_if_block$4(); + let if_block3 = /*showDrafts*/ ctx[3] && create_if_block$5(); return { c() { div5 = element("div"); if (if_block0) if_block0.c(); t0 = space(); + if (if_block1) if_block1.c(); + t1 = space(); div1 = element("div"); div0 = element("div"); create_component(disclosure0.$$.fragment); - t1 = space(); + t2 = space(); h40 = element("h4"); h40.textContent = "Word Count"; - t3 = space(); - if (if_block1) if_block1.c(); t4 = space(); + if (if_block2) if_block2.c(); + t5 = space(); div4 = element("div"); div3 = element("div"); div2 = element("div"); create_component(disclosure1.$$.fragment); - t5 = space(); + t6 = space(); h41 = element("h4"); h41.textContent = "Drafts"; - t7 = space(); + t8 = space(); button = element("button"); create_component(icon.$$.fragment); - t8 = space(); - if (if_block2) if_block2.c(); - attr(h40, "class", "svelte-db2avi"); - attr(div0, "class", "longform-project-details-section-header svelte-db2avi"); - attr(div1, "class", "longform-project-section word-counts svelte-db2avi"); + t9 = space(); + if (if_block3) if_block3.c(); + attr(h40, "class", "svelte-1ioudaq"); + attr(div0, "class", "longform-project-details-section-header svelte-1ioudaq"); + attr(div1, "class", "longform-project-section word-counts svelte-1ioudaq"); attr(div1, "style", div1_style_value = `--progress-text-color:${/*goalPercentage*/ ctx[10] >= 43 ? "var(--text-on-accent)" : "var(--text-accent)"}`); - attr(h41, "class", "svelte-db2avi"); - attr(div2, "class", "longform-project-details-section-header svelte-db2avi"); + attr(h41, "class", "svelte-1ioudaq"); + attr(div2, "class", "longform-project-details-section-header svelte-1ioudaq"); attr(button, "type", "button"); - attr(button, "class", "svelte-db2avi"); - attr(div3, "class", "drafts-title-container svelte-db2avi"); - attr(div4, "class", "longform-project-section svelte-db2avi"); + attr(button, "class", "svelte-1ioudaq"); + attr(div3, "class", "drafts-title-container svelte-1ioudaq"); + attr(div4, "class", "longform-project-section svelte-1ioudaq"); }, m(target, anchor) { insert(target, div5, anchor); if (if_block0) if_block0.m(div5, null); append(div5, t0); + if (if_block1) if_block1.m(div5, null); + append(div5, t1); append(div5, div1); append(div1, div0); mount_component(disclosure0, div0, null); - append(div0, t1); + append(div0, t2); append(div0, h40); - append(div1, t3); - if (if_block1) if_block1.m(div1, null); - append(div5, t4); + append(div1, t4); + if (if_block2) if_block2.m(div1, null); + append(div5, t5); append(div5, div4); append(div4, div3); append(div3, div2); mount_component(disclosure1, div2, null); - append(div2, t5); + append(div2, t6); append(div2, h41); - append(div3, t7); + append(div3, t8); append(div3, button); mount_component(icon, button, null); - append(div4, t8); - if (if_block2) if_block2.m(div4, null); + append(div4, t9); + if (if_block3) if_block3.m(div4, null); current = true; if (!mounted) { dispose = [ - listen(div0, "click", /*click_handler_1*/ ctx[25]), - listen(div2, "click", /*click_handler_2*/ ctx[26]), - listen(button, "click", /*onNewDraft*/ ctx[15]) + listen(div0, "click", /*click_handler_2*/ ctx[28]), + listen(div2, "click", /*click_handler_3*/ ctx[29]), + listen(button, "click", /*onNewDraft*/ ctx[16]) ]; mounted = true; } }, - p(ctx, [dirty]) { + p(ctx, dirty) { if (/*$selectedDraft*/ ctx[0]) { if (if_block0) { if_block0.p(ctx, dirty); - if (dirty & /*$selectedDraft*/ 1) { + if (dirty[0] & /*$selectedDraft*/ 1) { transition_in(if_block0, 1); } } else { - if_block0 = create_if_block_5$1(ctx); + if_block0 = create_if_block_7(ctx); if_block0.c(); transition_in(if_block0, 1); if_block0.m(div5, t0); @@ -34217,49 +34835,72 @@ function create_fragment$4(ctx) { check_outros(); } - const disclosure0_changes = {}; - if (dirty & /*showWordCount*/ 4) disclosure0_changes.collapsed = !/*showWordCount*/ ctx[2]; - disclosure0.$set(disclosure0_changes); - - if (/*showWordCount*/ ctx[2]) { + if (/*$selectedDraft*/ ctx[0]) { if (if_block1) { if_block1.p(ctx, dirty); + + if (dirty[0] & /*$selectedDraft*/ 1) { + transition_in(if_block1, 1); + } } else { - if_block1 = create_if_block_1$4(ctx); + if_block1 = create_if_block_5$1(ctx); if_block1.c(); - if_block1.m(div1, null); + transition_in(if_block1, 1); + if_block1.m(div5, t1); } } else if (if_block1) { - if_block1.d(1); - if_block1 = null; + group_outros(); + + transition_out(if_block1, 1, 1, () => { + if_block1 = null; + }); + + check_outros(); } - if (!current || dirty & /*goalPercentage*/ 1024 && div1_style_value !== (div1_style_value = `--progress-text-color:${/*goalPercentage*/ ctx[10] >= 43 + const disclosure0_changes = {}; + if (dirty[0] & /*showWordCount*/ 4) disclosure0_changes.collapsed = !/*showWordCount*/ ctx[2]; + disclosure0.$set(disclosure0_changes); + + if (/*showWordCount*/ ctx[2]) { + if (if_block2) { + if_block2.p(ctx, dirty); + } else { + if_block2 = create_if_block_1$5(ctx); + if_block2.c(); + if_block2.m(div1, null); + } + } else if (if_block2) { + if_block2.d(1); + if_block2 = null; + } + + if (!current || dirty[0] & /*goalPercentage*/ 1024 && div1_style_value !== (div1_style_value = `--progress-text-color:${/*goalPercentage*/ ctx[10] >= 43 ? "var(--text-on-accent)" : "var(--text-accent)"}`)) { attr(div1, "style", div1_style_value); } const disclosure1_changes = {}; - if (dirty & /*showDrafts*/ 8) disclosure1_changes.collapsed = !/*showDrafts*/ ctx[3]; + if (dirty[0] & /*showDrafts*/ 8) disclosure1_changes.collapsed = !/*showDrafts*/ ctx[3]; disclosure1.$set(disclosure1_changes); if (/*showDrafts*/ ctx[3]) { - if (if_block2) { - if (dirty & /*showDrafts*/ 8) { - transition_in(if_block2, 1); + if (if_block3) { + if (dirty[0] & /*showDrafts*/ 8) { + transition_in(if_block3, 1); } } else { - if_block2 = create_if_block$4(); - if_block2.c(); - transition_in(if_block2, 1); - if_block2.m(div4, null); + if_block3 = create_if_block$5(); + if_block3.c(); + transition_in(if_block3, 1); + if_block3.m(div4, null); } - } else if (if_block2) { + } else if (if_block3) { group_outros(); - transition_out(if_block2, 1, 1, () => { - if_block2 = null; + transition_out(if_block3, 1, 1, () => { + if_block3 = null; }); check_outros(); @@ -34268,28 +34909,31 @@ function create_fragment$4(ctx) { i(local) { if (current) return; transition_in(if_block0); + transition_in(if_block1); transition_in(disclosure0.$$.fragment, local); transition_in(disclosure1.$$.fragment, local); transition_in(icon.$$.fragment, local); - transition_in(if_block2); + transition_in(if_block3); current = true; }, o(local) { transition_out(if_block0); + transition_out(if_block1); transition_out(disclosure0.$$.fragment, local); transition_out(disclosure1.$$.fragment, local); transition_out(icon.$$.fragment, local); - transition_out(if_block2); + transition_out(if_block3); current = false; }, d(detaching) { if (detaching) detach(div5); if (if_block0) if_block0.d(); - destroy_component(disclosure0); if (if_block1) if_block1.d(); + destroy_component(disclosure0); + if (if_block2) if_block2.d(); destroy_component(disclosure1); destroy_component(icon); - if (if_block2) if_block2.d(); + if (if_block3) if_block3.d(); mounted = false; run_all(dispose); } @@ -34310,7 +34954,7 @@ function pluralize(count, noun, pluralNoun = null) { } } -function instance$4($$self, $$props, $$invalidate) { +function instance$5($$self, $$props, $$invalidate) { let $pluginSettings; let $goalProgress; let $selectedDraft; @@ -34319,14 +34963,14 @@ function instance$4($$self, $$props, $$invalidate) { let $projects; let $selectedDraftWordCountStatus; let $selectedDraftVaultPath; - component_subscribe($$self, pluginSettings, $$value => $$invalidate(16, $pluginSettings = $$value)); - component_subscribe($$self, goalProgress, $$value => $$invalidate(17, $goalProgress = $$value)); + component_subscribe($$self, pluginSettings, $$value => $$invalidate(18, $pluginSettings = $$value)); + component_subscribe($$self, goalProgress, $$value => $$invalidate(19, $goalProgress = $$value)); component_subscribe($$self, selectedDraft, $$value => $$invalidate(0, $selectedDraft = $$value)); - component_subscribe($$self, drafts, $$value => $$invalidate(18, $drafts = $$value)); - component_subscribe($$self, activeFile, $$value => $$invalidate(19, $activeFile = $$value)); - component_subscribe($$self, projects, $$value => $$invalidate(20, $projects = $$value)); - component_subscribe($$self, selectedDraftWordCountStatus, $$value => $$invalidate(21, $selectedDraftWordCountStatus = $$value)); - component_subscribe($$self, selectedDraftVaultPath, $$value => $$invalidate(27, $selectedDraftVaultPath = $$value)); + component_subscribe($$self, drafts, $$value => $$invalidate(20, $drafts = $$value)); + component_subscribe($$self, activeFile, $$value => $$invalidate(21, $activeFile = $$value)); + component_subscribe($$self, projects, $$value => $$invalidate(22, $projects = $$value)); + component_subscribe($$self, selectedDraftWordCountStatus, $$value => $$invalidate(23, $selectedDraftWordCountStatus = $$value)); + component_subscribe($$self, selectedDraftVaultPath, $$value => $$invalidate(30, $selectedDraftVaultPath = $$value)); const app = useApp(); let showMetdata = true; let showWordCount = true; @@ -34443,6 +35087,14 @@ function instance$4($$self, $$props, $$invalidate) { showNewDraftModal(); } + const showMetadataModal = getContext("showMetadataModal"); + + function onEditMetadata() { + showMetadataModal(); + } + + let showManuscriptMetadata = true; + const click_handler = () => { $$invalidate(1, showMetdata = !showMetdata); }; @@ -34462,15 +35114,19 @@ function instance$4($$self, $$props, $$invalidate) { } const click_handler_1 = () => { - $$invalidate(2, showWordCount = !showWordCount); + $$invalidate(12, showManuscriptMetadata = !showManuscriptMetadata); }; const click_handler_2 = () => { + $$invalidate(2, showWordCount = !showWordCount); + }; + + const click_handler_3 = () => { $$invalidate(3, showDrafts = !showDrafts); }; $$self.$$.update = () => { - if ($$self.$$.dirty & /*$selectedDraftWordCountStatus, $projects, $selectedDraft*/ 3145729) { + if ($$self.$$.dirty[0] & /*$selectedDraftWordCountStatus, $projects, $selectedDraft*/ 12582913) { { if ($selectedDraftWordCountStatus) { const { scene, draft, project } = $selectedDraftWordCountStatus; @@ -34485,7 +35141,7 @@ function instance$4($$self, $$props, $$invalidate) { } } - if ($$self.$$.dirty & /*$activeFile, $selectedDraft, $drafts*/ 786433) { + if ($$self.$$.dirty[0] & /*$activeFile, $selectedDraft, $drafts*/ 3145729) { { if ($activeFile && $selectedDraft) { const draft = draftForPath($activeFile.path, $drafts); @@ -34494,7 +35150,7 @@ function instance$4($$self, $$props, $$invalidate) { } } - if ($$self.$$.dirty & /*$goalProgress, $pluginSettings*/ 196608) { + if ($$self.$$.dirty[0] & /*$goalProgress, $pluginSettings*/ 786432) { { $$invalidate(10, goalPercentage = Math.ceil(Math.min($goalProgress, 1) * 100)); $$invalidate(11, goalDescription = `${Math.round($goalProgress * $pluginSettings.sessionGoal)}/${$pluginSettings.sessionGoal}`); @@ -34515,10 +35171,12 @@ function instance$4($$self, $$props, $$invalidate) { showProgress, goalPercentage, goalDescription, + showManuscriptMetadata, titleChanged, sceneFolderChanged, sceneTemplateChanged, onNewDraft, + onEditMetadata, $pluginSettings, $goalProgress, $drafts, @@ -34529,14 +35187,15 @@ function instance$4($$self, $$props, $$invalidate) { input0_binding, input1_binding, click_handler_1, - click_handler_2 + click_handler_2, + click_handler_3 ]; } class ProjectDetails extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$4, create_fragment$4, safe_not_equal, {}, add_css$4); + init(this, options, instance$5, create_fragment$5, safe_not_equal, {}, add_css$5, [-1, -1]); } } @@ -34559,6 +35218,7 @@ const DEFAULT_SETTINGS = { sessionFile: DEFAULT_SESSION_FILE, numberScenes: false, sceneTemplate: null, + writeProperty: false, projects: {}, waitForSync: false, fallbackWaitEnabled: true, @@ -34584,6 +35244,7 @@ const TRACKED_SETTINGS_PATHS = [ "waitForSync", "fallbackWaitEnabled", "fallbackWaitTime", + "writeProperty", ]; const PASSTHROUGH_SAVE_SETTINGS_PATHS = [ "sessionStorage", @@ -34601,6 +35262,7 @@ const PASSTHROUGH_SAVE_SETTINGS_PATHS = [ "waitForSync", "fallbackWaitEnabled", "fallbackWaitTime", + "writeProperty", ]; const INDEX_MIGRATION_NOTICE = "\n\nThis is a Longform 1.0 Index File, and the project it corresponded to has since been migrated. It has been marked as to-be-ignored in the new project and can be safely deleted."; @@ -34721,12 +35383,12 @@ function migrate(settings, app) { /* src/view/explorer/Tab.svelte generated by Svelte v3.49.0 */ -function add_css$3(target) { +function add_css$4(target) { append_styles(target, "svelte-1ohhb9z", ".tab-button.svelte-1ohhb9z{background:none;border:none;border-bottom:none;border-radius:var(--tab-radius-active);padding:0 1em 0 0.4em;box-shadow:none;margin:0;color:var(--tab-text-color-focused);font-size:var(--tab-font-size);font-weight:var(--tab-font-weight);white-space:nowrap;border-right:1px solid var(--tab-outline-color)}.tab-button.svelte-1ohhb9z:hover{color:var(--tab-text-color-focused);background-color:var(--background-modifier-hover)}.tab-button.selected.svelte-1ohhb9z{background-color:var(--tab-background-active);color:var(--tab-text-color-focused-active)}"); } // (10:2) {#if tab == "Scenes"} -function create_if_block_2$1(ctx) { +function create_if_block_2$2(ctx) { let svg; let path0; let path1; @@ -34769,7 +35431,7 @@ function create_if_block_2$1(ctx) { } // (31:2) {#if tab == "Project"} -function create_if_block_1$3(ctx) { +function create_if_block_1$4(ctx) { let svg; let path0; let path1; @@ -34808,7 +35470,7 @@ function create_if_block_1$3(ctx) { } // (48:2) {#if tab == "Compile"} -function create_if_block$3(ctx) { +function create_if_block$4(ctx) { let svg; let rect; let path; @@ -34846,7 +35508,7 @@ function create_if_block$3(ctx) { }; } -function create_fragment$3(ctx) { +function create_fragment$4(ctx) { let button; let t0; let t1; @@ -34854,9 +35516,9 @@ function create_fragment$3(ctx) { let t3; let mounted; let dispose; - let if_block0 = /*tab*/ ctx[0] == "Scenes" && create_if_block_2$1(); - let if_block1 = /*tab*/ ctx[0] == "Project" && create_if_block_1$3(); - let if_block2 = /*tab*/ ctx[0] == "Compile" && create_if_block$3(); + let if_block0 = /*tab*/ ctx[0] == "Scenes" && create_if_block_2$2(); + let if_block1 = /*tab*/ ctx[0] == "Project" && create_if_block_1$4(); + let if_block2 = /*tab*/ ctx[0] == "Compile" && create_if_block$4(); return { c() { @@ -34889,7 +35551,7 @@ function create_fragment$3(ctx) { p(ctx, [dirty]) { if (/*tab*/ ctx[0] == "Scenes") { if (if_block0) ; else { - if_block0 = create_if_block_2$1(); + if_block0 = create_if_block_2$2(); if_block0.c(); if_block0.m(button, t0); } @@ -34900,7 +35562,7 @@ function create_fragment$3(ctx) { if (/*tab*/ ctx[0] == "Project") { if (if_block1) ; else { - if_block1 = create_if_block_1$3(); + if_block1 = create_if_block_1$4(); if_block1.c(); if_block1.m(button, t1); } @@ -34911,7 +35573,7 @@ function create_fragment$3(ctx) { if (/*tab*/ ctx[0] == "Compile") { if (if_block2) ; else { - if_block2 = create_if_block$3(); + if_block2 = create_if_block$4(); if_block2.c(); if_block2.m(button, t2); } @@ -34939,7 +35601,7 @@ function create_fragment$3(ctx) { }; } -function instance$3($$self, $$props, $$invalidate) { +function instance$4($$self, $$props, $$invalidate) { let $selectedTab; component_subscribe($$self, selectedTab, $$value => $$invalidate(1, $selectedTab = $$value)); let { tab } = $$props; @@ -34955,18 +35617,18 @@ function instance$3($$self, $$props, $$invalidate) { class Tab extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$3, create_fragment$3, safe_not_equal, { tab: 0 }, add_css$3); + init(this, options, instance$4, create_fragment$4, safe_not_equal, { tab: 0 }, add_css$4); } } /* src/view/explorer/ExplorerView.svelte generated by Svelte v3.49.0 */ -function add_css$2(target) { +function add_css$3(target) { append_styles(target, "svelte-1v1mbat", ".longform-explorer.svelte-1v1mbat{font-size:var(--longform-explorer-font-size)}.longform-migrate-button.svelte-1v1mbat{background-color:var(--interactive-accent);color:var(--text-on-accent)}.longform-migrate-button.svelte-1v1mbat:hover{background-color:var(--interactive-accent-hover)}.tab-list.svelte-1v1mbat{margin:0;font-size:0}.tab-panel-container.svelte-1v1mbat{background:var(--background-primary);padding:var(--size-4-1) var(--size-4-2)}.tab-panel-container.disconnected.svelte-1v1mbat{background:none;padding:0}.longform-sync-wait.svelte-1v1mbat{display:flex;flex-direction:column;align-items:center;justify-content:center;height:100%;padding:2rem;gap:1rem}.longform-spinner.svelte-1v1mbat{border:3px solid var(--background-modifier-border);border-top:3px solid var(--text-accent);border-radius:50%;width:24px;height:24px;animation:svelte-1v1mbat-spin 1s linear infinite}.longform-sync-message.svelte-1v1mbat{color:var(--text-muted);font-size:0.8em;text-align:center}@keyframes svelte-1v1mbat-spin{0%{transform:rotate(0deg)}100%{transform:rotate(360deg)}}"); } // (49:0) {:else} -function create_else_block$1(ctx) { +function create_else_block$2(ctx) { let div; let projectpicker; let t; @@ -34974,7 +35636,7 @@ function create_else_block$1(ctx) { let if_block; let current; projectpicker = new ProjectPicker({}); - const if_block_creators = [create_if_block_2, create_else_block_2]; + const if_block_creators = [create_if_block_2$1, create_else_block_2]; const if_blocks = []; function select_block_type_1(ctx, dirty) { @@ -35047,7 +35709,7 @@ function create_else_block$1(ctx) { } // (42:26) -function create_if_block_1$2(ctx) { +function create_if_block_1$3(ctx) { let div2; return { @@ -35072,7 +35734,7 @@ function create_if_block_1$2(ctx) { } // (25:0) {#if $needsMigration} -function create_if_block$2(ctx) { +function create_if_block$3(ctx) { let div; let p0; let t1; @@ -35216,7 +35878,7 @@ function create_else_block_2(ctx) { } // (52:4) {#if $selectedDraft && $selectedDraft.format === "scenes"} -function create_if_block_2(ctx) { +function create_if_block_2$1(ctx) { let div2; let div1; let div0; @@ -35500,12 +36162,12 @@ function create_if_block_3(ctx) { }; } -function create_fragment$2(ctx) { +function create_fragment$3(ctx) { let current_block_type_index; let if_block; let if_block_anchor; let current; - const if_block_creators = [create_if_block$2, create_if_block_1$2, create_else_block$1]; + const if_block_creators = [create_if_block$3, create_if_block_1$3, create_else_block$2]; const if_blocks = []; function select_block_type(ctx, dirty) { @@ -35570,7 +36232,7 @@ function create_fragment$2(ctx) { }; } -function instance$2($$self, $$props, $$invalidate) { +function instance$3($$self, $$props, $$invalidate) { let $selectedTab; let $selectedDraft; let $needsMigration; @@ -35601,18 +36263,18 @@ function instance$2($$self, $$props, $$invalidate) { class ExplorerView extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$2, create_fragment$2, safe_not_equal, {}, add_css$2); + init(this, options, instance$3, create_fragment$3, safe_not_equal, {}, add_css$3); } } /* src/view/project-lifecycle/new-draft-modal/NewDraftModal.svelte generated by Svelte v3.49.0 */ -function add_css$1(target) { +function add_css$2(target) { append_styles(target, "svelte-1kaigjd", ".draft-title-container.svelte-1kaigjd.svelte-1kaigjd{margin-bottom:var(--size-4-4)}label.svelte-1kaigjd.svelte-1kaigjd{font-weight:bold;color:var(--text-muted);display:block;font-size:var(--font-smallest)}input[type=\"text\"].svelte-1kaigjd.svelte-1kaigjd{width:100%;font-size:var(--h2-size);height:var(--size-4-12);padding:var(--size-4-2)}.source-path.svelte-1kaigjd.svelte-1kaigjd{color:var(--text-muted)}.target-path.svelte-1kaigjd.svelte-1kaigjd{color:var(--text-accent)}.draft-creation-container.svelte-1kaigjd.svelte-1kaigjd{display:flex;flex-direction:row;justify-content:end}.draft-creation-container.svelte-1kaigjd button.svelte-1kaigjd{font-weight:bold;background-color:var(--interactive-accent);color:var(--text-on-accent);margin:0}"); } // (73:4) {#if valid && $selectedDraft} -function create_if_block$1(ctx) { +function create_if_block$2(ctx) { let p; let t0; let t1; @@ -35627,7 +36289,7 @@ function create_if_block$1(ctx) { let button; let mounted; let dispose; - let if_block = /*copyScenes*/ ctx[3] && create_if_block_1$1(); + let if_block = /*copyScenes*/ ctx[3] && create_if_block_1$2(); return { c() { @@ -35672,7 +36334,7 @@ function create_if_block$1(ctx) { p(ctx, dirty) { if (/*copyScenes*/ ctx[3]) { if (if_block) ; else { - if_block = create_if_block_1$1(); + if_block = create_if_block_1$2(); if_block.c(); if_block.m(p, t1); } @@ -35696,7 +36358,7 @@ function create_if_block$1(ctx) { } // (75:36) {#if copyScenes} -function create_if_block_1$1(ctx) { +function create_if_block_1$2(ctx) { let b; return { @@ -35713,7 +36375,7 @@ function create_if_block_1$1(ctx) { }; } -function create_fragment$1(ctx) { +function create_fragment$2(ctx) { let div3; let p; let t1; @@ -35728,7 +36390,7 @@ function create_fragment$1(ctx) { let div2; let mounted; let dispose; - let if_block = /*valid*/ ctx[1] && /*$selectedDraft*/ ctx[2] && create_if_block$1(ctx); + let if_block = /*valid*/ ctx[1] && /*$selectedDraft*/ ctx[2] && create_if_block$2(ctx); return { c() { @@ -35793,7 +36455,7 @@ function create_fragment$1(ctx) { if (if_block) { if_block.p(ctx, dirty); } else { - if_block = create_if_block$1(ctx); + if_block = create_if_block$2(ctx); if_block.c(); if_block.m(div2, null); } @@ -35816,7 +36478,7 @@ function create_fragment$1(ctx) { const regex$1 = /[:\\\/]/; -function instance$1($$self, $$props, $$invalidate) { +function instance$2($$self, $$props, $$invalidate) { let $selectedDraft; component_subscribe($$self, selectedDraft, $$value => $$invalidate(2, $selectedDraft = $$value)); let title; @@ -35902,7 +36564,7 @@ function instance$1($$self, $$props, $$invalidate) { class NewDraftModal extends SvelteComponent { constructor(options) { super(); - init(this, options, instance$1, create_fragment$1, safe_not_equal, {}, add_css$1); + init(this, options, instance$2, create_fragment$2, safe_not_equal, {}, add_css$2); } } @@ -35959,6 +36621,1323 @@ class NewDraftModalContainer extends obsidian.Modal { } } +/* src/view/metadata-modal/MetadataModal.svelte generated by Svelte v3.49.0 */ + +function add_css$1(target) { + append_styles(target, "svelte-1k3e56", ".metadata-modal-root.svelte-1k3e56.svelte-1k3e56{display:block;width:100%;max-width:640px;margin:0 auto}.muted.svelte-1k3e56.svelte-1k3e56{color:var(--text-muted)}.small.svelte-1k3e56.svelte-1k3e56{font-size:var(--font-ui-smaller);line-height:var(--line-height-tight)}.req.svelte-1k3e56.svelte-1k3e56{color:var(--text-error);margin-left:2px}section.svelte-1k3e56.svelte-1k3e56{border-top:var(--border-width) solid var(--background-modifier-border);padding:var(--size-4-4) 0 var(--size-4-2) 0}section.svelte-1k3e56.svelte-1k3e56:first-of-type{border-top:none;padding-top:0}section.svelte-1k3e56 h3.svelte-1k3e56{margin:0 0 var(--size-4-2) 0;font-size:var(--font-ui-medium);font-weight:600;color:var(--text-normal)}.section-head.svelte-1k3e56.svelte-1k3e56{display:flex;justify-content:space-between;align-items:center;margin-bottom:var(--size-4-1)}.section-head.svelte-1k3e56 h3.svelte-1k3e56{margin:0}.field.svelte-1k3e56.svelte-1k3e56{display:flex;flex-direction:column;margin-top:var(--size-4-3)}.field.svelte-1k3e56>span.svelte-1k3e56{font-size:var(--font-ui-smaller);color:var(--text-muted);margin-bottom:var(--size-4-1)}.field.svelte-1k3e56 input.svelte-1k3e56,.field.svelte-1k3e56 textarea.svelte-1k3e56{width:100%}.field.svelte-1k3e56 textarea.svelte-1k3e56{font-family:var(--font-text);resize:vertical;min-height:6em}.row.two-col.svelte-1k3e56.svelte-1k3e56{display:grid;grid-template-columns:1fr 1fr;gap:var(--size-4-3)}.row.two-col.svelte-1k3e56 .field.svelte-1k3e56{margin-top:var(--size-4-3)}.toggles.svelte-1k3e56.svelte-1k3e56{align-items:center;margin-top:var(--size-4-3)}.toggle.svelte-1k3e56.svelte-1k3e56{display:flex;align-items:center;gap:var(--size-4-2);color:var(--text-normal);font-size:var(--font-ui-small)}.toggle.svelte-1k3e56 input.svelte-1k3e56{margin:0}.creators.svelte-1k3e56.svelte-1k3e56{display:flex;flex-direction:column;gap:var(--size-4-2);margin-top:var(--size-4-2)}.creator-row.svelte-1k3e56.svelte-1k3e56{display:flex;align-items:stretch;gap:var(--size-4-2);padding:var(--size-4-2);border:var(--border-width) solid var(--background-modifier-border);border-radius:var(--radius-s);background:var(--background-secondary)}.creator-fields.svelte-1k3e56.svelte-1k3e56{display:grid;grid-template-columns:1.2fr 1.6fr 1fr;gap:var(--size-4-2);flex:1}.creator-fields.svelte-1k3e56 input.svelte-1k3e56{width:100%}.creator-actions.svelte-1k3e56.svelte-1k3e56{display:flex;flex-direction:column;gap:2px;align-items:stretch;justify-content:center}.creator-actions.svelte-1k3e56 button.svelte-1k3e56{padding:var(--size-2-1) var(--size-4-2);line-height:1;font-size:var(--font-ui-smaller);min-width:1.8em}button.ghost.svelte-1k3e56.svelte-1k3e56{background:transparent;color:var(--text-muted);box-shadow:none;border:var(--border-width) solid var(--background-modifier-border)}button.ghost.svelte-1k3e56.svelte-1k3e56:hover:not(:disabled){color:var(--text-normal);background:var(--background-modifier-hover)}button.ghost.svelte-1k3e56.svelte-1k3e56:disabled{opacity:0.4;cursor:not-allowed}button.ghost.danger.svelte-1k3e56.svelte-1k3e56:hover:not(:disabled){color:var(--text-error);border-color:var(--text-error)}button.primary.svelte-1k3e56.svelte-1k3e56{background-color:var(--interactive-accent);color:var(--text-on-accent)}button.primary.svelte-1k3e56.svelte-1k3e56:disabled{opacity:0.5;cursor:not-allowed}footer.svelte-1k3e56.svelte-1k3e56{margin-top:var(--size-4-4);padding-top:var(--size-4-3);border-top:var(--border-width) solid var(--background-modifier-border);display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:var(--size-4-2)}footer.svelte-1k3e56 .file-path.svelte-1k3e56{margin:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:60%}footer.svelte-1k3e56 .actions.svelte-1k3e56{display:flex;gap:var(--size-4-2)}.empty-state.svelte-1k3e56.svelte-1k3e56{display:flex;flex-direction:column;align-items:center;text-align:center;padding:var(--size-4-8) var(--size-4-4);gap:var(--size-4-3);min-height:320px;box-sizing:border-box}.empty-state.svelte-1k3e56>.svelte-1k3e56{flex-shrink:0}.empty-icon.svelte-1k3e56.svelte-1k3e56{display:flex;align-items:center;justify-content:center;width:56px;height:56px;border-radius:50%;background:var(--background-modifier-hover);color:var(--text-muted)}.empty-icon.svelte-1k3e56 svg{width:26px;height:26px}.empty-title.svelte-1k3e56.svelte-1k3e56{margin:0;font-size:var(--font-ui-medium);font-weight:600;color:var(--text-normal)}.empty-message.svelte-1k3e56.svelte-1k3e56{margin:0;max-width:440px;color:var(--text-muted);line-height:var(--line-height-normal)}.empty-path.svelte-1k3e56.svelte-1k3e56{margin:0;word-break:break-all}.empty-actions.svelte-1k3e56.svelte-1k3e56{display:flex;gap:var(--size-4-2);margin-top:var(--size-4-2)}code.svelte-1k3e56.svelte-1k3e56{font-size:0.9em}"); +} + +function get_each_context(ctx, list, i) { + const child_ctx = ctx.slice(); + child_ctx[37] = list[i]; + child_ctx[38] = list; + child_ctx[39] = i; + return child_ctx; +} + +// (229:2) {:else} +function create_else_block$1(ctx) { + let form_1; + let section0; + let h30; + let t1; + let label0; + let span1; + let t4; + let input0; + let t5; + let div0; + let label1; + let span2; + let t7; + let input1; + let t8; + let label2; + let span3; + let t10; + let input2; + let t11; + let label3; + let span4; + let t13; + let input3; + let t14; + let label4; + let span5; + let t16; + let textarea; + let t17; + let label5; + let span6; + let t19; + let input4; + let t20; + let section1; + let div1; + let h31; + let t21; + let t22; + let button0; + let icon; + let t23; + let p0; + let t29; + let div2; + let each_blocks = []; + let each_1_lookup = new Map(); + let t30; + let section2; + let h32; + let t32; + let p1; + let t36; + let div3; + let label6; + let span7; + let t38; + let input5; + let t39; + let label7; + let span8; + let t41; + let input6; + let t42; + let label8; + let span9; + let t44; + let input7; + let t45; + let div4; + let label9; + let input8; + let t46; + let span10; + let t48; + let label10; + let input9; + let t49; + let span11; + let t51; + let footer; + let p2; + let t52; + let code3; + let t53; + let t54; + let div5; + let button1; + let t56; + let button2; + let t57; + let button2_disabled_value; + let current; + let mounted; + let dispose; + let if_block = !/*creatorsOk*/ ctx[3] && create_if_block_2(); + icon = new Icon({ props: { iconName: "plus-with-circle" } }); + let each_value = /*form*/ ctx[2].creators; + const get_key = ctx => /*i*/ ctx[39]; + + for (let i = 0; i < each_value.length; i += 1) { + let child_ctx = get_each_context(ctx, each_value, i); + let key = get_key(child_ctx); + each_1_lookup.set(key, each_blocks[i] = create_each_block(key, child_ctx)); + } + + return { + c() { + form_1 = element("form"); + section0 = element("section"); + h30 = element("h3"); + h30.textContent = "Basics"; + t1 = space(); + label0 = element("label"); + span1 = element("span"); + span1.innerHTML = `Title*`; + t4 = space(); + input0 = element("input"); + t5 = space(); + div0 = element("div"); + label1 = element("label"); + span2 = element("span"); + span2.textContent = "Publication date"; + t7 = space(); + input1 = element("input"); + t8 = space(); + label2 = element("label"); + span3 = element("span"); + span3.textContent = "Version"; + t10 = space(); + input2 = element("input"); + t11 = space(); + label3 = element("label"); + span4 = element("span"); + span4.textContent = "Journal"; + t13 = space(); + input3 = element("input"); + t14 = space(); + label4 = element("label"); + span5 = element("span"); + span5.textContent = "Abstract / description"; + t16 = space(); + textarea = element("textarea"); + t17 = space(); + label5 = element("label"); + span6 = element("span"); + span6.textContent = "Keywords"; + t19 = space(); + input4 = element("input"); + t20 = space(); + section1 = element("section"); + div1 = element("div"); + h31 = element("h3"); + t21 = text("Creators\n "); + if (if_block) if_block.c(); + t22 = space(); + button0 = element("button"); + create_component(icon.$$.fragment); + t23 = space(); + p0 = element("p"); + + p0.innerHTML = `Zenodo treats affiliation as a single string. For + multi-affiliation authors, edit + _longform.author_affiliations directly in the JSON file.`; + + t29 = space(); + div2 = element("div"); + + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].c(); + } + + t30 = space(); + section2 = element("section"); + h32 = element("h3"); + h32.textContent = "Longform extras"; + t32 = space(); + p1 = element("p"); + + p1.innerHTML = `Plugin-specific keys under _longform. Zenodo ignores + these on upload.`; + + t36 = space(); + div3 = element("div"); + label6 = element("label"); + span7 = element("span"); + span7.textContent = "Acronym"; + t38 = space(); + input5 = element("input"); + t39 = space(); + label7 = element("label"); + span8 = element("span"); + span8.textContent = "CSL style"; + t41 = space(); + input6 = element("input"); + t42 = space(); + label8 = element("label"); + span9 = element("span"); + span9.textContent = "Pandoc template"; + t44 = space(); + input7 = element("input"); + t45 = space(); + div4 = element("div"); + label9 = element("label"); + input8 = element("input"); + t46 = space(); + span10 = element("span"); + span10.textContent = "Line numbers"; + t48 = space(); + label10 = element("label"); + input9 = element("input"); + t49 = space(); + span11 = element("span"); + span11.textContent = "Figures at end"; + t51 = space(); + footer = element("footer"); + p2 = element("p"); + t52 = text("Saving to "); + code3 = element("code"); + t53 = text(/*filePath*/ ctx[4]); + t54 = space(); + div5 = element("div"); + button1 = element("button"); + button1.textContent = "Cancel"; + t56 = space(); + button2 = element("button"); + t57 = text("Save"); + attr(h30, "class", "svelte-1k3e56"); + attr(span1, "class", "svelte-1k3e56"); + attr(input0, "type", "text"); + attr(input0, "placeholder", "Manuscript title"); + attr(input0, "class", "svelte-1k3e56"); + attr(label0, "class", "field svelte-1k3e56"); + attr(span2, "class", "svelte-1k3e56"); + attr(input1, "type", "date"); + attr(input1, "class", "svelte-1k3e56"); + attr(label1, "class", "field svelte-1k3e56"); + attr(span3, "class", "svelte-1k3e56"); + attr(input2, "type", "text"); + attr(input2, "placeholder", "v1.0"); + attr(input2, "class", "svelte-1k3e56"); + attr(label2, "class", "field svelte-1k3e56"); + attr(div0, "class", "row two-col svelte-1k3e56"); + attr(span4, "class", "svelte-1k3e56"); + attr(input3, "type", "text"); + attr(input3, "placeholder", "Nature"); + attr(input3, "class", "svelte-1k3e56"); + attr(label3, "class", "field svelte-1k3e56"); + attr(span5, "class", "svelte-1k3e56"); + attr(textarea, "rows", "5"); + attr(textarea, "placeholder", "Manuscript abstract."); + attr(textarea, "class", "svelte-1k3e56"); + attr(label4, "class", "field svelte-1k3e56"); + attr(span6, "class", "svelte-1k3e56"); + attr(input4, "type", "text"); + attr(input4, "placeholder", "comma, separated, list"); + attr(input4, "class", "svelte-1k3e56"); + attr(label5, "class", "field svelte-1k3e56"); + attr(section0, "class", "svelte-1k3e56"); + attr(h31, "class", "svelte-1k3e56"); + attr(button0, "type", "button"); + attr(button0, "class", "ghost svelte-1k3e56"); + attr(button0, "title", "Add creator"); + attr(div1, "class", "section-head svelte-1k3e56"); + attr(p0, "class", "muted small svelte-1k3e56"); + attr(div2, "class", "creators svelte-1k3e56"); + attr(section1, "class", "svelte-1k3e56"); + attr(h32, "class", "svelte-1k3e56"); + attr(p1, "class", "muted small svelte-1k3e56"); + attr(span7, "class", "svelte-1k3e56"); + attr(input5, "type", "text"); + attr(input5, "placeholder", "MYPAPER"); + attr(input5, "class", "svelte-1k3e56"); + attr(label6, "class", "field svelte-1k3e56"); + attr(span8, "class", "svelte-1k3e56"); + attr(input6, "type", "text"); + attr(input6, "placeholder", "nature"); + attr(input6, "class", "svelte-1k3e56"); + attr(label7, "class", "field svelte-1k3e56"); + attr(div3, "class", "row two-col svelte-1k3e56"); + attr(span9, "class", "svelte-1k3e56"); + attr(input7, "type", "text"); + attr(input7, "placeholder", "default"); + attr(input7, "class", "svelte-1k3e56"); + attr(label8, "class", "field svelte-1k3e56"); + attr(input8, "type", "checkbox"); + attr(input8, "class", "svelte-1k3e56"); + attr(label9, "class", "toggle svelte-1k3e56"); + attr(input9, "type", "checkbox"); + attr(input9, "class", "svelte-1k3e56"); + attr(label10, "class", "toggle svelte-1k3e56"); + attr(div4, "class", "row two-col toggles svelte-1k3e56"); + attr(section2, "class", "svelte-1k3e56"); + attr(code3, "class", "svelte-1k3e56"); + attr(p2, "class", "muted small file-path svelte-1k3e56"); + attr(button1, "type", "button"); + attr(button1, "class", "ghost svelte-1k3e56"); + attr(button2, "type", "submit"); + attr(button2, "class", "primary svelte-1k3e56"); + button2.disabled = button2_disabled_value = !/*canSave*/ ctx[6]; + attr(div5, "class", "actions svelte-1k3e56"); + attr(footer, "class", "svelte-1k3e56"); + }, + m(target, anchor) { + insert(target, form_1, anchor); + append(form_1, section0); + append(section0, h30); + append(section0, t1); + append(section0, label0); + append(label0, span1); + append(label0, t4); + append(label0, input0); + set_input_value(input0, /*form*/ ctx[2].title); + append(section0, t5); + append(section0, div0); + append(div0, label1); + append(label1, span2); + append(label1, t7); + append(label1, input1); + set_input_value(input1, /*form*/ ctx[2].publication_date); + append(div0, t8); + append(div0, label2); + append(label2, span3); + append(label2, t10); + append(label2, input2); + set_input_value(input2, /*form*/ ctx[2].version); + append(section0, t11); + append(section0, label3); + append(label3, span4); + append(label3, t13); + append(label3, input3); + set_input_value(input3, /*form*/ ctx[2].journal_title); + append(section0, t14); + append(section0, label4); + append(label4, span5); + append(label4, t16); + append(label4, textarea); + set_input_value(textarea, /*form*/ ctx[2].description); + append(section0, t17); + append(section0, label5); + append(label5, span6); + append(label5, t19); + append(label5, input4); + set_input_value(input4, /*form*/ ctx[2].keywords); + append(form_1, t20); + append(form_1, section1); + append(section1, div1); + append(div1, h31); + append(h31, t21); + if (if_block) if_block.m(h31, null); + append(div1, t22); + append(div1, button0); + mount_component(icon, button0, null); + append(section1, t23); + append(section1, p0); + append(section1, t29); + append(section1, div2); + + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].m(div2, null); + } + + append(form_1, t30); + append(form_1, section2); + append(section2, h32); + append(section2, t32); + append(section2, p1); + append(section2, t36); + append(section2, div3); + append(div3, label6); + append(label6, span7); + append(label6, t38); + append(label6, input5); + set_input_value(input5, /*form*/ ctx[2].acronym); + append(div3, t39); + append(div3, label7); + append(label7, span8); + append(label7, t41); + append(label7, input6); + set_input_value(input6, /*form*/ ctx[2].csl); + append(section2, t42); + append(section2, label8); + append(label8, span9); + append(label8, t44); + append(label8, input7); + set_input_value(input7, /*form*/ ctx[2].template); + append(section2, t45); + append(section2, div4); + append(div4, label9); + append(label9, input8); + input8.checked = /*form*/ ctx[2].lineno; + append(label9, t46); + append(label9, span10); + append(div4, t48); + append(div4, label10); + append(label10, input9); + input9.checked = /*form*/ ctx[2].figuresAtEnd; + append(label10, t49); + append(label10, span11); + append(form_1, t51); + append(form_1, footer); + append(footer, p2); + append(p2, t52); + append(p2, code3); + append(code3, t53); + append(footer, t54); + append(footer, div5); + append(div5, button1); + append(div5, t56); + append(div5, button2); + append(button2, t57); + current = true; + + if (!mounted) { + dispose = [ + listen(input0, "input", /*input0_input_handler*/ ctx[15]), + listen(input1, "input", /*input1_input_handler*/ ctx[16]), + listen(input2, "input", /*input2_input_handler*/ ctx[17]), + listen(input3, "input", /*input3_input_handler*/ ctx[18]), + listen(textarea, "input", /*textarea_input_handler*/ ctx[19]), + listen(input4, "input", /*input4_input_handler*/ ctx[20]), + listen(button0, "click", /*addCreator*/ ctx[8]), + listen(input5, "input", /*input5_input_handler*/ ctx[27]), + listen(input6, "input", /*input6_input_handler*/ ctx[28]), + listen(input7, "input", /*input7_input_handler*/ ctx[29]), + listen(input8, "change", /*input8_change_handler*/ ctx[30]), + listen(input9, "change", /*input9_change_handler*/ ctx[31]), + listen(button1, "click", /*close*/ ctx[7]), + listen(form_1, "submit", prevent_default(/*onSave*/ ctx[11])) + ]; + + mounted = true; + } + }, + p(ctx, dirty) { + if (dirty[0] & /*form*/ 4 && input0.value !== /*form*/ ctx[2].title) { + set_input_value(input0, /*form*/ ctx[2].title); + } + + if (dirty[0] & /*form*/ 4) { + set_input_value(input1, /*form*/ ctx[2].publication_date); + } + + if (dirty[0] & /*form*/ 4 && input2.value !== /*form*/ ctx[2].version) { + set_input_value(input2, /*form*/ ctx[2].version); + } + + if (dirty[0] & /*form*/ 4 && input3.value !== /*form*/ ctx[2].journal_title) { + set_input_value(input3, /*form*/ ctx[2].journal_title); + } + + if (dirty[0] & /*form*/ 4) { + set_input_value(textarea, /*form*/ ctx[2].description); + } + + if (dirty[0] & /*form*/ 4 && input4.value !== /*form*/ ctx[2].keywords) { + set_input_value(input4, /*form*/ ctx[2].keywords); + } + + if (!/*creatorsOk*/ ctx[3]) { + if (if_block) ; else { + if_block = create_if_block_2(); + if_block.c(); + if_block.m(h31, null); + } + } else if (if_block) { + if_block.d(1); + if_block = null; + } + + if (dirty[0] & /*removeCreator, form, moveCreator*/ 1540) { + each_value = /*form*/ ctx[2].creators; + each_blocks = update_keyed_each(each_blocks, dirty, get_key, 1, ctx, each_value, each_1_lookup, div2, destroy_block, create_each_block, null, get_each_context); + } + + if (dirty[0] & /*form*/ 4 && input5.value !== /*form*/ ctx[2].acronym) { + set_input_value(input5, /*form*/ ctx[2].acronym); + } + + if (dirty[0] & /*form*/ 4 && input6.value !== /*form*/ ctx[2].csl) { + set_input_value(input6, /*form*/ ctx[2].csl); + } + + if (dirty[0] & /*form*/ 4 && input7.value !== /*form*/ ctx[2].template) { + set_input_value(input7, /*form*/ ctx[2].template); + } + + if (dirty[0] & /*form*/ 4) { + input8.checked = /*form*/ ctx[2].lineno; + } + + if (dirty[0] & /*form*/ 4) { + input9.checked = /*form*/ ctx[2].figuresAtEnd; + } + + if (!current || dirty[0] & /*filePath*/ 16) set_data(t53, /*filePath*/ ctx[4]); + + if (!current || dirty[0] & /*canSave*/ 64 && button2_disabled_value !== (button2_disabled_value = !/*canSave*/ ctx[6])) { + button2.disabled = button2_disabled_value; + } + }, + i(local) { + if (current) return; + transition_in(icon.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(icon.$$.fragment, local); + current = false; + }, + d(detaching) { + if (detaching) detach(form_1); + if (if_block) if_block.d(); + destroy_component(icon); + + for (let i = 0; i < each_blocks.length; i += 1) { + each_blocks[i].d(); + } + + mounted = false; + run_all(dispose); + } + }; +} + +// (208:24) +function create_if_block_1$1(ctx) { + let div2; + let div0; + let icon; + let t0; + let h2; + let t2; + let p0; + let t8; + let p1; + let t9; + let code1; + let t10; + let t11; + let t12; + let div1; + let button0; + let t14; + let button1; + let current; + let mounted; + let dispose; + icon = new Icon({ props: { iconName: "documents" } }); + + return { + c() { + div2 = element("div"); + div0 = element("div"); + create_component(icon.$$.fragment); + t0 = space(); + h2 = element("h2"); + h2.textContent = "No metadata yet"; + t2 = space(); + p0 = element("p"); + + p0.innerHTML = `This project doesn't have a metadata.json file. Create + one to describe authors, abstract, journal, and more for the + Add Zenodo Frontmatter compile step.`; + + t8 = space(); + p1 = element("p"); + t9 = text("Will be saved to "); + code1 = element("code"); + t10 = text(/*projectPath*/ ctx[0]); + t11 = text("/metadata.json"); + t12 = space(); + div1 = element("div"); + button0 = element("button"); + button0.textContent = "Cancel"; + t14 = space(); + button1 = element("button"); + button1.textContent = "Create metadata.json"; + attr(div0, "class", "empty-icon svelte-1k3e56"); + attr(h2, "class", "empty-title svelte-1k3e56"); + attr(p0, "class", "empty-message svelte-1k3e56"); + attr(code1, "class", "svelte-1k3e56"); + attr(p1, "class", "empty-path muted small svelte-1k3e56"); + attr(button0, "type", "button"); + attr(button0, "class", "ghost svelte-1k3e56"); + attr(button1, "type", "button"); + attr(button1, "class", "primary svelte-1k3e56"); + attr(div1, "class", "empty-actions svelte-1k3e56"); + attr(div2, "class", "empty-state svelte-1k3e56"); + }, + m(target, anchor) { + insert(target, div2, anchor); + append(div2, div0); + mount_component(icon, div0, null); + append(div2, t0); + append(div2, h2); + append(div2, t2); + append(div2, p0); + append(div2, t8); + append(div2, p1); + append(p1, t9); + append(p1, code1); + append(code1, t10); + append(code1, t11); + append(div2, t12); + append(div2, div1); + append(div1, button0); + append(div1, t14); + append(div1, button1); + current = true; + + if (!mounted) { + dispose = [ + listen(button0, "click", /*close*/ ctx[7]), + listen(button1, "click", /*onCreateFile*/ ctx[12]) + ]; + + mounted = true; + } + }, + p(ctx, dirty) { + if (!current || dirty[0] & /*projectPath*/ 1) set_data(t10, /*projectPath*/ ctx[0]); + }, + i(local) { + if (current) return; + transition_in(icon.$$.fragment, local); + current = true; + }, + o(local) { + transition_out(icon.$$.fragment, local); + current = false; + }, + d(detaching) { + if (detaching) detach(div2); + destroy_component(icon); + mounted = false; + run_all(dispose); + } + }; +} + +// (206:2) {#if loading} +function create_if_block$1(ctx) { + let p; + + return { + c() { + p = element("p"); + p.textContent = "Loading metadata…"; + attr(p, "class", "muted svelte-1k3e56"); + }, + m(target, anchor) { + insert(target, p, anchor); + }, + p: noop, + i: noop, + o: noop, + d(detaching) { + if (detaching) detach(p); + } + }; +} + +// (277:12) {#if !creatorsOk} +function create_if_block_2(ctx) { + let span; + + return { + c() { + span = element("span"); + span.textContent = "*"; + attr(span, "class", "req svelte-1k3e56"); + }, + m(target, anchor) { + insert(target, span, anchor); + }, + d(detaching) { + if (detaching) detach(span); + } + }; +} + +// (289:10) {#each form.creators as creator, i (i)} +function create_each_block(key_1, ctx) { + let div2; + let div0; + let input0; + let t0; + let input1; + let t1; + let input2; + let t2; + let div1; + let button0; + let t3; + let button0_disabled_value; + let t4; + let button1; + let t5; + let button1_disabled_value; + let t6; + let button2; + let t8; + let mounted; + let dispose; + + function input0_input_handler_1() { + /*input0_input_handler_1*/ ctx[21].call(input0, /*each_value*/ ctx[38], /*i*/ ctx[39]); + } + + function input1_input_handler_1() { + /*input1_input_handler_1*/ ctx[22].call(input1, /*each_value*/ ctx[38], /*i*/ ctx[39]); + } + + function input2_input_handler_1() { + /*input2_input_handler_1*/ ctx[23].call(input2, /*each_value*/ ctx[38], /*i*/ ctx[39]); + } + + function click_handler() { + return /*click_handler*/ ctx[24](/*i*/ ctx[39]); + } + + function click_handler_1() { + return /*click_handler_1*/ ctx[25](/*i*/ ctx[39]); + } + + function click_handler_2() { + return /*click_handler_2*/ ctx[26](/*i*/ ctx[39]); + } + + return { + key: key_1, + first: null, + c() { + div2 = element("div"); + div0 = element("div"); + input0 = element("input"); + t0 = space(); + input1 = element("input"); + t1 = space(); + input2 = element("input"); + t2 = space(); + div1 = element("div"); + button0 = element("button"); + t3 = text("▲"); + t4 = space(); + button1 = element("button"); + t5 = text("▼"); + t6 = space(); + button2 = element("button"); + button2.textContent = "✕"; + t8 = space(); + attr(input0, "type", "text"); + attr(input0, "placeholder", "Family, Given"); + attr(input0, "class", "creator-name svelte-1k3e56"); + attr(input1, "type", "text"); + attr(input1, "placeholder", "Affiliation"); + attr(input1, "class", "creator-affil svelte-1k3e56"); + attr(input2, "type", "text"); + attr(input2, "placeholder", "0000-0000-0000-0000"); + attr(input2, "class", "creator-orcid svelte-1k3e56"); + attr(div0, "class", "creator-fields svelte-1k3e56"); + attr(button0, "type", "button"); + attr(button0, "class", "ghost svelte-1k3e56"); + button0.disabled = button0_disabled_value = /*i*/ ctx[39] === 0; + attr(button0, "title", "Move up"); + attr(button1, "type", "button"); + attr(button1, "class", "ghost svelte-1k3e56"); + button1.disabled = button1_disabled_value = /*i*/ ctx[39] === /*form*/ ctx[2].creators.length - 1; + attr(button1, "title", "Move down"); + attr(button2, "type", "button"); + attr(button2, "class", "ghost danger svelte-1k3e56"); + attr(button2, "title", "Remove creator"); + attr(div1, "class", "creator-actions svelte-1k3e56"); + attr(div2, "class", "creator-row svelte-1k3e56"); + this.first = div2; + }, + m(target, anchor) { + insert(target, div2, anchor); + append(div2, div0); + append(div0, input0); + set_input_value(input0, /*creator*/ ctx[37].name); + append(div0, t0); + append(div0, input1); + set_input_value(input1, /*creator*/ ctx[37].affiliation); + append(div0, t1); + append(div0, input2); + set_input_value(input2, /*creator*/ ctx[37].orcid); + append(div2, t2); + append(div2, div1); + append(div1, button0); + append(button0, t3); + append(div1, t4); + append(div1, button1); + append(button1, t5); + append(div1, t6); + append(div1, button2); + append(div2, t8); + + if (!mounted) { + dispose = [ + listen(input0, "input", input0_input_handler_1), + listen(input1, "input", input1_input_handler_1), + listen(input2, "input", input2_input_handler_1), + listen(button0, "click", click_handler), + listen(button1, "click", click_handler_1), + listen(button2, "click", click_handler_2) + ]; + + mounted = true; + } + }, + p(new_ctx, dirty) { + ctx = new_ctx; + + if (dirty[0] & /*form*/ 4 && input0.value !== /*creator*/ ctx[37].name) { + set_input_value(input0, /*creator*/ ctx[37].name); + } + + if (dirty[0] & /*form*/ 4 && input1.value !== /*creator*/ ctx[37].affiliation) { + set_input_value(input1, /*creator*/ ctx[37].affiliation); + } + + if (dirty[0] & /*form*/ 4 && input2.value !== /*creator*/ ctx[37].orcid) { + set_input_value(input2, /*creator*/ ctx[37].orcid); + } + + if (dirty[0] & /*form*/ 4 && button0_disabled_value !== (button0_disabled_value = /*i*/ ctx[39] === 0)) { + button0.disabled = button0_disabled_value; + } + + if (dirty[0] & /*form*/ 4 && button1_disabled_value !== (button1_disabled_value = /*i*/ ctx[39] === /*form*/ ctx[2].creators.length - 1)) { + button1.disabled = button1_disabled_value; + } + }, + d(detaching) { + if (detaching) detach(div2); + mounted = false; + run_all(dispose); + } + }; +} + +function create_fragment$1(ctx) { + let div; + let current_block_type_index; + let if_block; + let current; + const if_block_creators = [create_if_block$1, create_if_block_1$1, create_else_block$1]; + const if_blocks = []; + + function select_block_type(ctx, dirty) { + if (/*loading*/ ctx[1]) return 0; + if (!/*fileExists*/ ctx[5]) return 1; + return 2; + } + + current_block_type_index = select_block_type(ctx); + if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); + + return { + c() { + div = element("div"); + if_block.c(); + attr(div, "class", "metadata-modal-root svelte-1k3e56"); + }, + m(target, anchor) { + insert(target, div, anchor); + if_blocks[current_block_type_index].m(div, null); + current = true; + }, + p(ctx, dirty) { + let previous_block_index = current_block_type_index; + current_block_type_index = select_block_type(ctx); + + if (current_block_type_index === previous_block_index) { + if_blocks[current_block_type_index].p(ctx, dirty); + } else { + group_outros(); + + transition_out(if_blocks[previous_block_index], 1, 1, () => { + if_blocks[previous_block_index] = null; + }); + + check_outros(); + if_block = if_blocks[current_block_type_index]; + + if (!if_block) { + if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx); + if_block.c(); + } else { + if_block.p(ctx, dirty); + } + + transition_in(if_block, 1); + if_block.m(div, null); + } + }, + i(local) { + if (current) return; + transition_in(if_block); + current = true; + }, + o(local) { + transition_out(if_block); + current = false; + }, + d(detaching) { + if (detaching) detach(div); + if_blocks[current_block_type_index].d(); + } + }; +} + +function setOrDelete(obj, key, value) { + if (value && value.length > 0) obj[key] = value; else delete obj[key]; +} + +function instance$1($$self, $$props, $$invalidate) { + let titleOk; + let creatorsOk; + let canSave; + let { projectPath } = $$props; + let { projectTitle } = $$props; + const app = useApp(); + const close = getContext("close"); + + // Round-trip preservation: keep the parsed JSON so unknown fields survive save. + let originalJson = {}; + + let filePath = `${projectPath}/metadata.json`; + let fileExists = false; + let loading = true; + let form = blankForm(); + + function blankForm() { + return { + title: projectTitle !== null && projectTitle !== void 0 + ? projectTitle + : "", + publication_date: new Date().toISOString().slice(0, 10), + description: "", + keywords: "", + journal_title: "", + version: "", + creators: [{ name: "", affiliation: "", orcid: "" }], + acronym: "", + csl: "", + template: "", + lineno: false, + figuresAtEnd: false + }; + } + + onMount(() => __awaiter(void 0, void 0, void 0, function* () { + const candidates = [`${projectPath}/metadata.json`, `${projectPath}/source/metadata.json`]; + let loadedFrom = ""; + let loadedRaw = ""; + + for (const path of candidates) { + const f = app.vault.getAbstractFileByPath(path); + + if (f instanceof obsidian.TFile) { + loadedFrom = path; + loadedRaw = yield app.vault.cachedRead(f); + break; + } + } + + if (loadedFrom) { + $$invalidate(4, filePath = loadedFrom); + $$invalidate(5, fileExists = true); + + try { + const parsed = JSON.parse(loadedRaw); + originalJson = parsed; + $$invalidate(2, form = parsedToForm(parsed)); + } catch(e) { + new obsidian.Notice(`metadata.json is invalid JSON; opening blank form. (${e.message})`); + originalJson = {}; + } + } + + $$invalidate(1, loading = false); + })); + + function parsedToForm(j) { + var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k; + const ext = (_a = j._longform) !== null && _a !== void 0 ? _a : {}; + + const creators = Array.isArray(j.creators) + ? j.creators.map(c => { + var _a, _b, _c; + + return { + name: String((_a = c === null || c === void 0 ? void 0 : c.name) !== null && _a !== void 0 + ? _a + : ""), + affiliation: String((_b = c === null || c === void 0 ? void 0 : c.affiliation) !== null && _b !== void 0 + ? _b + : ""), + orcid: String((_c = c === null || c === void 0 ? void 0 : c.orcid) !== null && _c !== void 0 + ? _c + : "") + }; + }) + : [{ name: "", affiliation: "", orcid: "" }]; + + const keywords = Array.isArray(j.keywords) + ? j.keywords.map(k => String(k)).join(", ") + : ""; + + return { + title: String((_c = (_b = j.title) !== null && _b !== void 0 + ? _b + : projectTitle) !== null && _c !== void 0 + ? _c + : ""), + publication_date: String((_d = j.publication_date) !== null && _d !== void 0 + ? _d + : new Date().toISOString().slice(0, 10)), + description: String((_e = j.description) !== null && _e !== void 0 ? _e : ""), + keywords, + journal_title: String((_f = j.journal_title) !== null && _f !== void 0 + ? _f + : ""), + version: String((_g = j.version) !== null && _g !== void 0 ? _g : ""), + creators: creators.length > 0 + ? creators + : [{ name: "", affiliation: "", orcid: "" }], + acronym: String((_h = ext.acronym) !== null && _h !== void 0 ? _h : ""), + csl: String((_j = ext.csl) !== null && _j !== void 0 ? _j : ""), + template: String((_k = ext.template) !== null && _k !== void 0 ? _k : ""), + lineno: Boolean(ext.lineno), + figuresAtEnd: Boolean(ext.figures_at_end) + }; + } + + function buildOutputJson() { + var _a; + const out = Object.assign({}, originalJson); + out.title = form.title; + out.publication_date = form.publication_date; + if (!out.upload_type) out.upload_type = "publication"; + if (!out.publication_type) out.publication_type = "article"; + out.description = form.description; + + out.creators = form.creators.filter(c => c.name.trim() !== "").map(c => { + const o = { name: c.name.trim() }; + if (c.affiliation.trim()) o.affiliation = c.affiliation.trim(); + if (c.orcid.trim()) o.orcid = c.orcid.trim(); + return o; + }); + + const kws = form.keywords.split(",").map(k => k.trim()).filter(k => k.length > 0); + if (kws.length > 0) out.keywords = kws; else delete out.keywords; + if (form.journal_title.trim()) out.journal_title = form.journal_title.trim(); else delete out.journal_title; + if (form.version.trim()) out.version = form.version.trim(); else delete out.version; + + const prevExt = (_a = originalJson._longform) !== null && _a !== void 0 + ? _a + : {}; + + const ext = Object.assign({}, prevExt); + setOrDelete(ext, "acronym", form.acronym.trim()); + setOrDelete(ext, "csl", form.csl.trim()); + setOrDelete(ext, "template", form.template.trim()); + ext.lineno = form.lineno; + ext.figures_at_end = form.figuresAtEnd; + if (!form.lineno) delete ext.lineno; + if (!form.figuresAtEnd) delete ext.figures_at_end; + if (Object.keys(ext).length > 0) out._longform = ext; else delete out._longform; + return out; + } + + function addCreator() { + $$invalidate(2, form.creators = [...form.creators, { name: "", affiliation: "", orcid: "" }], form); + } + + function removeCreator(i) { + $$invalidate(2, form.creators = form.creators.filter((_, idx) => idx !== i), form); + + if (form.creators.length === 0) { + $$invalidate(2, form.creators = [{ name: "", affiliation: "", orcid: "" }], form); + } + } + + function moveCreator(i, dir) { + const j = i + dir; + if (j < 0 || j >= form.creators.length) return; + const next = form.creators.slice(); + [next[i], next[j]] = [next[j], next[i]]; + $$invalidate(2, form.creators = next, form); + } + + function onSave() { + return __awaiter(this, void 0, void 0, function* () { + if (!canSave) return; + const data = buildOutputJson(); + const text = JSON.stringify(data, null, 2) + "\n"; + + try { + const existing = app.vault.getAbstractFileByPath(filePath); + + if (existing instanceof obsidian.TFile) { + yield app.vault.modify(existing, text); + } else { + const parent = filePath.split("/").slice(0, -1).join("/"); + + if (parent && !(yield app.vault.adapter.exists(parent))) { + yield app.vault.createFolder(parent); + } + + yield app.vault.create(filePath, text); + } + + new obsidian.Notice("Metadata saved."); + close(); + } catch(e) { + new obsidian.Notice(`Failed to save metadata: ${e.message}`); + } + }); + } + + function onCreateFile() { + return __awaiter(this, void 0, void 0, function* () { + $$invalidate(5, fileExists = true); + }); + } + + function input0_input_handler() { + form.title = this.value; + $$invalidate(2, form); + } + + function input1_input_handler() { + form.publication_date = this.value; + $$invalidate(2, form); + } + + function input2_input_handler() { + form.version = this.value; + $$invalidate(2, form); + } + + function input3_input_handler() { + form.journal_title = this.value; + $$invalidate(2, form); + } + + function textarea_input_handler() { + form.description = this.value; + $$invalidate(2, form); + } + + function input4_input_handler() { + form.keywords = this.value; + $$invalidate(2, form); + } + + function input0_input_handler_1(each_value, i) { + each_value[i].name = this.value; + $$invalidate(2, form); + } + + function input1_input_handler_1(each_value, i) { + each_value[i].affiliation = this.value; + $$invalidate(2, form); + } + + function input2_input_handler_1(each_value, i) { + each_value[i].orcid = this.value; + $$invalidate(2, form); + } + + const click_handler = i => moveCreator(i, -1); + const click_handler_1 = i => moveCreator(i, 1); + const click_handler_2 = i => removeCreator(i); + + function input5_input_handler() { + form.acronym = this.value; + $$invalidate(2, form); + } + + function input6_input_handler() { + form.csl = this.value; + $$invalidate(2, form); + } + + function input7_input_handler() { + form.template = this.value; + $$invalidate(2, form); + } + + function input8_change_handler() { + form.lineno = this.checked; + $$invalidate(2, form); + } + + function input9_change_handler() { + form.figuresAtEnd = this.checked; + $$invalidate(2, form); + } + + $$self.$$set = $$props => { + if ('projectPath' in $$props) $$invalidate(0, projectPath = $$props.projectPath); + if ('projectTitle' in $$props) $$invalidate(13, projectTitle = $$props.projectTitle); + }; + + $$self.$$.update = () => { + if ($$self.$$.dirty[0] & /*form*/ 4) { + $$invalidate(14, titleOk = form.title.trim().length > 0); + } + + if ($$self.$$.dirty[0] & /*form*/ 4) { + $$invalidate(3, creatorsOk = form.creators.some(c => c.name.trim().length > 0)); + } + + if ($$self.$$.dirty[0] & /*loading, titleOk, creatorsOk*/ 16394) { + $$invalidate(6, canSave = !loading && titleOk && creatorsOk); + } + }; + + return [ + projectPath, + loading, + form, + creatorsOk, + filePath, + fileExists, + canSave, + close, + addCreator, + removeCreator, + moveCreator, + onSave, + onCreateFile, + projectTitle, + titleOk, + input0_input_handler, + input1_input_handler, + input2_input_handler, + input3_input_handler, + textarea_input_handler, + input4_input_handler, + input0_input_handler_1, + input1_input_handler_1, + input2_input_handler_1, + click_handler, + click_handler_1, + click_handler_2, + input5_input_handler, + input6_input_handler, + input7_input_handler, + input8_change_handler, + input9_change_handler + ]; +} + +class MetadataModal$1 extends SvelteComponent { + constructor(options) { + super(); + init(this, options, instance$1, create_fragment$1, safe_not_equal, { projectPath: 0, projectTitle: 13 }, add_css$1, [-1, -1]); + } +} + +class MetadataModal extends obsidian.Modal { + constructor(app, projectPath, projectTitle) { + super(app); + this.component = null; + this.projectPath = projectPath; + this.projectTitle = projectTitle; + } + onOpen() { + const { contentEl, titleEl, modalEl } = this; + titleEl.empty(); + contentEl.empty(); + modalEl.addClass("longform-metadata-modal"); + contentEl.addClass("longform-metadata-modal-content"); + const target = contentEl.createDiv("longform-metadata-modal-root"); + const context = appContext(this); + context.set("close", () => this.close()); + this.component = new MetadataModal$1({ + target, + context, + props: { + projectPath: this.projectPath, + projectTitle: this.projectTitle, + }, + }); + } + onClose() { + if (this.component) { + this.component.$destroy(); + this.component = null; + } + this.contentEl.empty(); + } +} + class UndoManager { constructor() { this.listeners = []; @@ -36060,6 +38039,7 @@ class ExplorerPane extends obsidian.ItemView { }; // Context function for showing a right-click menu context.set("onContextClick", (path, x, y, onRename) => { + var _a; const file = this.app.vault.getAbstractFileByPath(path); if (!file) { return; @@ -36100,6 +38080,22 @@ class ExplorerPane extends obsidian.ItemView { item.setIcon("minus-circle"); item.onClick(() => ignoreScene(file.name.endsWith(".md") ? file.name.slice(0, -3) : file.name)); }); + if (file instanceof obsidian.TFile) { + const cache = this.app.metadataCache.getFileCache(file); + const ignored = !!((_a = cache === null || cache === void 0 ? void 0 : cache.frontmatter) === null || _a === void 0 ? void 0 : _a["longform-ignore"]); + menu.addItem((item) => { + item.setTitle(ignored ? "Include in compile" : "Skip in compile"); + item.setIcon(ignored ? "eye" : "eye-off"); + item.onClick(() => this.app.fileManager.processFrontMatter(file, (fm) => { + if (fm["longform-ignore"]) { + delete fm["longform-ignore"]; + } + else { + fm["longform-ignore"] = true; + } + })); + }); + } // Triggering this event lets other apps insert menu items // including Obsidian, giving us lots of stuff for free. this.app.workspace.trigger("file-menu", menu, file, "longform"); @@ -36148,6 +38144,16 @@ class ExplorerPane extends obsidian.ItemView { context.set("showNewDraftModal", () => { new NewDraftModalContainer(this.app).open(); }); + context.set("showMetadataModal", () => { + const draft = get_store_value(selectedDraft); + if (!draft) + return; + const projectPath = draft.vaultPath + .split("/") + .slice(0, -1) + .join("/"); + new MetadataModal(this.app, projectPath, draft.title).open(); + }); this.explorerView = new ExplorerView({ target: this.contentEl, context, @@ -36164,416 +38170,6 @@ class ExplorerPane extends obsidian.ItemView { } } -class LongformSettingsTab extends obsidian.PluginSettingTab { - constructor(app, plugin) { - super(app, plugin); - this.plugin = plugin; - } - display() { - const settings = get_store_value(pluginSettings); - const { containerEl } = this; - containerEl.empty(); - new obsidian.Setting(containerEl).setName("Composition").setHeading(); - new obsidian.Setting(containerEl).setName("New scene template").addSearch((cb) => { - new FileSuggest(this.app, cb.inputEl); - cb.setPlaceholder("templates/Scene.md") - .setValue(settings.sceneTemplate) - .onChange((v) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sceneTemplate: v }))); - }); - }); - containerEl.createEl("p", { cls: "setting-item-description" }, (el) => { - el.innerHTML = - "This file will be used as a template when creating new scenes via the New Scene… field. If you use a templating plugin (Templater or the core plugin) it will be used to process this template. This setting applies to all projects and can be overridden per-project in the Project > Project Metadata settings in the Longform pane."; - }); - new obsidian.Setting(containerEl) - .setName("Show scene numbers in Scenes tab") - .setDesc("If on, shows numbers for scenes with subscenes separated by periods, e.g. 1.1.2. Create subscenes by dragging a scene to an indent under an existing scene, or us an indent command.") - .addToggle((cb) => { - cb.setValue(settings.numberScenes); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { numberScenes: value }))); - }); - }); - new obsidian.Setting(containerEl).setName("Compile").setHeading(); - new obsidian.Setting(containerEl) - .setName("User script step folder") - .setDesc(".js files in this folder will be available as User Script Steps in the Compile panel.") - .addSearch((cb) => { - new FolderSuggest(this.app, cb.inputEl); - cb.setPlaceholder("my/script/steps/") - .setValue(settings.userScriptFolder) - .onChange((v) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { userScriptFolder: v }))); - }); - }); - this.stepsSummary = containerEl.createSpan(); - this.stepsList = containerEl.createEl("ul", { - cls: "longform-settings-user-steps", - }); - this.unsubscribeUserScripts = userScriptSteps.subscribe((steps) => { - if (steps && steps.length > 0) { - this.stepsSummary.innerText = `Loaded ${steps.length} step${steps.length !== 1 ? "s" : ""}:`; - } - else { - this.stepsSummary.innerText = "No steps loaded."; - } - if (this.stepsList) { - this.stepsList.empty(); - if (steps) { - steps.forEach((s) => { - const stepEl = this.stepsList.createEl("li"); - stepEl.createSpan({ - text: s.description.name, - cls: "longform-settings-user-step-name", - }); - stepEl.createSpan({ - text: `(${s.description.canonicalID})`, - cls: "longform-settings-user-step-id", - }); - }); - } - } - }); - containerEl.createEl("p", { cls: "setting-item-description" }, (el) => { - el.innerHTML = - "User Script Steps are automatically loaded from this folder. Changes to .js files in this folder are synced with Longform after a slight delay. If your script does not appear here or in the Compile tab, you may have an error in your script—check the dev console for it."; - }); - new obsidian.Setting(containerEl).setName("Word Counts & Sessions").setHeading(); - new obsidian.Setting(containerEl) - .setName("Show word counts in status bar") - .setDesc("Click the status item to show the focused note’s project.") - .addToggle((cb) => { - cb.setValue(settings.showWordCountInStatusBar); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { showWordCountInStatusBar: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Start new writing sessions each day") - .setDesc("You can always manually start a new session by running the Longform: Start New Writing Session command. Turning this off will cause writing sessions to carry over across multiple days until you manually start a new one.") - .addToggle((cb) => { - cb.setValue(settings.startNewSessionEachDay); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { startNewSessionEachDay: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Session word count goal") - .setDesc("A number of words to target for a given writing session.") - .addText((cb) => { - cb.setValue(settings.sessionGoal.toString()); - cb.onChange((value) => { - const numberValue = +value; - if (numberValue && numberValue > 0) { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionGoal: numberValue }))); - } - }); - }); - new obsidian.Setting(containerEl) - .setName("Goal applies to") - .setDesc("You can set your word count goal to target all Longform writing, or you can make each project or scene have its own discrete goal.") - .addDropdown((cb) => { - cb.addOption("all", "words written across all projects"); - cb.addOption("project", "each project individually"); - cb.addOption("note", "each scene or single-scene project"); - cb.setValue(settings.applyGoalTo); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { applyGoalTo: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Notify on goal reached") - .addToggle((cb) => { - cb.setValue(settings.notifyOnGoal); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { notifyOnGoal: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Count deletions against goal") - .setDesc("If on, deleting words will count as negative words written. You cannot go below zero for a session.") - .addToggle((cb) => { - cb.setValue(settings.countDeletionsForGoal); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { countDeletionsForGoal: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Sessions to keep") - .setDesc("Number of sessions to store locally.") - .addText((cb) => { - cb.setValue(settings.keepSessionCount.toString()); - cb.onChange((value) => { - const numberValue = +value; - if (numberValue && numberValue > 0) { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { keepSessionCount: numberValue }))); - } - }); - }); - new obsidian.Setting(containerEl) - .setName("Store session data") - .setDesc("Where your writing session data is stored. By default, data is stored alongside other Longform settings in the plugin’s data.json file. You may instead store it in a separate .json file in the plugin folder, or in a file in your vault. You may want to do this for selective sync or git reasons.") - .addDropdown((cb) => { - cb.addOption("data", "with Longform settings"); - cb.addOption("plugin-folder", "as a .json file in the longform/ plugin folder"); - cb.addOption("file", "as a file in your vault"); - cb.setValue(settings.sessionStorage); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionStorage: value }))); - }); - }); - const updateSessionFile = obsidian.debounce((value) => { - // Normalize file to end in .json - let fileName = value; - if (!fileName || fileName.length === 0) { - fileName = DEFAULT_SESSION_FILE; - } - fileName = obsidian.normalizePath(fileName); - if (!fileName.endsWith(".json")) { - fileName = `${fileName}.json`; - } - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionFile: fileName }))); - }, 1000); - const sessionFileStorageSettings = new obsidian.Setting(containerEl) - .setName("Session storage file") - .setDesc("Location in your vault to store session JSON. Created if does not exist, overwritten if it does.") - .addText((cb) => { - var _a; - cb.setPlaceholder(DEFAULT_SESSION_FILE); - cb.setValue((_a = settings.sessionFile) !== null && _a !== void 0 ? _a : DEFAULT_SESSION_FILE); - cb.onChange(updateSessionFile); - }); - sessionFileStorageSettings.settingEl.style.display = "none"; - this.unsubscribeSettings = pluginSettings.subscribe((settings) => { - sessionFileStorageSettings.settingEl.style.display = - settings.sessionStorage === "file" ? "flex" : "none"; - }); - new obsidian.Setting(containerEl).setName("Troubleshooting").setHeading(); - new obsidian.Setting(containerEl) - .setName("Wait for Obsidian Sync") - .setDesc("Prevent Longform from running until Obsidian Sync completes its first sync. If you are using Sync, you may want to enable this if you experience issues with scenes disappearing or falsely being shown as new.") - .addToggle((cb) => { - cb.setValue(settings.waitForSync); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { waitForSync: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Enable fallback wait") - .setDesc("If sync status cannot be detected, wait for the time specified below before looking for scenes.") - .addToggle((cb) => { - cb.setValue(settings.fallbackWaitEnabled); - cb.onChange((value) => { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { fallbackWaitEnabled: value }))); - }); - }); - new obsidian.Setting(containerEl) - .setName("Fallback wait time") - .setDesc("Time to wait in seconds if sync status cannot be detected.") - .addText((cb) => { - cb.setValue(settings.fallbackWaitTime.toString()); - cb.onChange((value) => { - const numberValue = parseInt(value); - if (!isNaN(numberValue) && numberValue > 0) { - pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { fallbackWaitTime: numberValue }))); - } - }); - }); - new obsidian.Setting(containerEl).setName("Credits").setHeading(); - containerEl.createEl("p", {}, (el) => { - el.innerHTML = - 'Longform written and maintained by Kevin Barrett.'; - }); - containerEl.createEl("p", {}, (el) => { - el.innerHTML = - 'Read the source code and report issues at https://github.com/kevboh/longform.'; - }); - containerEl.createEl("p", {}, (el) => { - el.innerHTML = - 'Icon made by Zlatko Najdenovski from www.flaticon.com.'; - }); - } - hide() { - this.unsubscribeUserScripts(); - this.unsubscribeSettings(); - } -} - -/** - * Prepare a workflow for storage as json. - * @param workflow The workflow to serialize. - * @requires serialized An array of `SerializedStep`s that can be safely saved as json. - */ -function serializeWorkflow(workflow) { - const serialized = workflow.steps.map((step) => ({ - id: step.description.canonicalID, - optionValues: step.optionValues, - })); - return { - name: workflow.name, - description: workflow.description, - steps: serialized, - }; -} -function lookupStep(id, userSteps = []) { - const builtIn = BUILTIN_STEPS.find((s) => s.id === id); - if (builtIn) { - return builtIn; - } - const userStep = userSteps.find((s) => s.id === id); - if (userStep) { - return userStep; - } - return PLACEHOLDER_MISSING_STEP; -} -/** - * Deserializes an array of JSON-compatible steps into one that can be run as a workflow. - * @param w The JSON-compatible steps to deserialize. - * @returns deserialized Array of `CompileStep`s to use as a workflow. - */ -function deserializeWorkflow(w) { - var _a; - const userSteps = (_a = get_store_value(userScriptSteps)) !== null && _a !== void 0 ? _a : []; - const deserialized = Object.assign(Object.assign({}, w), { steps: w.steps.map((s) => { - const step = lookupStep(s.id, userSteps); - return Object.assign(Object.assign({}, step), { optionValues: s.optionValues }); - }) }); - return deserialized; -} - -const DEBOUNCE_SCRIPT_LOAD_DELAY_MS = 10000; -/** - * Watches the user's script folder and loads the scripts it finds there. - */ -class UserScriptObserver { - constructor(vault, userScriptFolder) { - this.initializedSteps = false; - this.vault = vault; - this.userScriptFolder = userScriptFolder; - this.onScriptModify = debounce_1(() => { - console.log(`[Longform] File in user script folder modified, reloading scripts…`); - this.loadUserSteps(); - }, DEBOUNCE_SCRIPT_LOAD_DELAY_MS); - } - destroy() { - this.unsubscribeScriptFolder(); - } - beginObserving() { - if (this.unsubscribeScriptFolder) { - this.unsubscribeScriptFolder(); - } - this.unsubscribeScriptFolder = pluginSettings.subscribe((s) => __awaiter(this, void 0, void 0, function* () { - if (this.initializedSteps && - s.userScriptFolder === this.userScriptFolder) { - return; - } - if (s.userScriptFolder == null) { - return; - } - const valid = yield this.vault.adapter.exists(s.userScriptFolder); - if (!valid) { - return; - } - this.userScriptFolder = s.userScriptFolder; - if (this.userScriptFolder) { - yield this.loadUserSteps(); - } - else { - userScriptSteps.set(null); - console.log("[Longform] Cleared user script steps."); - } - })); - } - loadUserSteps() { - return __awaiter(this, void 0, void 0, function* () { - if (!this.userScriptFolder) { - return; - } - const valid = yield this.vault.adapter.exists(this.userScriptFolder); - if (!valid) { - return; - } - // Get all .js files in folder - const { files } = yield this.vault.adapter.list(this.userScriptFolder); - const scripts = files.filter((f) => f.endsWith("js")); - const userSteps = []; - for (const file of scripts) { - try { - const step = yield this.loadScript(file); - userSteps.push(step); - } - catch (e) { - console.error(`[Longform] skipping user script ${file} due to error:`, e); - } - } - console.log(`[Longform] Loaded ${userSteps.length} user script steps.`); - userScriptSteps.set(userSteps); - this.initializedSteps = true; - // if workflows have loaded, merge in user steps to get updated values - const _workflows = get_store_value(workflows); - const workflowNames = Object.keys(_workflows); - const mergedWorkflows = {}; - workflowNames.forEach((name) => { - const workflow = _workflows[name]; - const workflowSteps = workflow.steps.map((step) => { - const userStep = userSteps.find((u) => step.description.canonicalID === u.description.canonicalID); - if (userStep) { - let mergedStep = Object.assign(Object.assign({}, userStep), { id: step.id, optionValues: userStep.optionValues }); - // Copy existing step's option values into the merged step - for (const key of Object.keys(step.optionValues)) { - if (mergedStep.optionValues[key]) { - mergedStep = Object.assign(Object.assign({}, mergedStep), { optionValues: Object.assign(Object.assign({}, mergedStep.optionValues), { [key]: step.optionValues[key] }) }); - } - } - return mergedStep; - } - else { - return step; - } - }); - mergedWorkflows[name] = Object.assign(Object.assign({}, workflow), { steps: workflowSteps }); - }); - workflows.set(mergedWorkflows); - return userSteps; - }); - } - loadScript(path) { - return __awaiter(this, void 0, void 0, function* () { - const js = yield this.vault.adapter.read(path); - // eslint-disable-next-line prefer-const - let _require = (s) => { - return window.require && window.require(s); - }; - // eslint-disable-next-line prefer-const - let exports = {}; - // eslint-disable-next-line prefer-const - let module = { - exports, - }; - const evaluateScript = window.eval("(function anonymous(require, module, exports){" + js + "\n})"); - evaluateScript(_require, module, exports); - const loadedStep = exports["default"] || module.exports; - if (!loadedStep) { - console.error(`[Longform] Failed to load user script ${path}. No exports detected.`); - throw new Error(`Failed to load user script ${path}. No exports detected.`); - } - const step = makeBuiltinStep(Object.assign(Object.assign({}, loadedStep), { id: path, description: Object.assign(Object.assign({}, loadedStep.description), { availableKinds: loadedStep.description.availableKinds.map((v) => CompileStepKind[v]), options: loadedStep.description.options - ? loadedStep.description.options.map((o) => (Object.assign(Object.assign({}, o), { type: CompileStepOptionType[o.type] }))) - : [] }) }), true); - return Object.assign(Object.assign({}, step), { id: path, description: Object.assign(Object.assign({}, step.description), { canonicalID: path, isScript: true }) }); - }); - } - fileEventCallback(file) { - if (this.userScriptFolder && - file.path.endsWith("js") && - ((file.parent && file.parent.path == this.userScriptFolder) || - (file.parent === null && file.path.startsWith(this.userScriptFolder)))) { - this.onScriptModify(); - } - } -} - function resolveIfLongformFile(metadataCache, file) { const metadata = metadataCache.getFileCache(file); if (metadata && metadata.frontmatter && metadata.frontmatter["longform"]) { @@ -37036,9 +38632,83 @@ class StoreVaultSync { yield this.app.fileManager.processFrontMatter(file, (fm) => { setDraftOnFrontmatterObject(fm, draft); }); + // for multi-scene projects, optionally set a property on each scene that holds its order within the project + if (get_store_value(pluginSettings).writeProperty) { + if (draft.format === "scenes") { + const writes = []; + const multiDraft = draft; + const sceneNumbers = numberScenes(scenesForCompileNumbering(this.app, multiDraft)); + const includedTitles = new Set(sceneNumbers.map((s) => s.title)); + sceneNumbers.forEach((numberedScene, index) => { + const sceneFilePath = scenePath(numberedScene.title, multiDraft, this.app.vault); + const sceneFile = this.app.vault.getAbstractFileByPath(sceneFilePath); + // false if a folder, or not found + if (!(sceneFile instanceof obsidian.TFile)) { + return; + } + writes.push(writeSceneNumbers(this.app, sceneFile, index, numberedScene.numbering)); + }); + for (const scene of multiDraft.scenes) { + if (includedTitles.has(scene.title)) { + continue; + } + const sceneFilePath = scenePath(scene.title, multiDraft, this.app.vault); + const sceneFile = this.app.vault.getAbstractFileByPath(sceneFilePath); + if (!(sceneFile instanceof obsidian.TFile)) { + continue; + } + writes.push(clearSceneNumbers(this.app, sceneFile)); + } + yield Promise.all(writes); + } + } }); } } +function syncSceneIndices(app) { + const writes = []; + get_store_value(drafts).forEach((draft) => { + if (draft.format !== "scenes") + return; + const multiDraft = draft; + const sceneNumbers = numberScenes(scenesForCompileNumbering(app, multiDraft)); + const includedTitles = new Set(sceneNumbers.map((s) => s.title)); + sceneNumbers.forEach((numberedScene, index) => { + const sceneFilePath = scenePath(numberedScene.title, multiDraft, app.vault); + const sceneFile = app.vault.getAbstractFileByPath(sceneFilePath); + if (!(sceneFile instanceof obsidian.TFile)) { + return; + } + writes.push(writeSceneNumbers(app, sceneFile, index, numberedScene.numbering)); + }); + for (const scene of multiDraft.scenes) { + if (includedTitles.has(scene.title)) { + continue; + } + const sceneFilePath = scenePath(scene.title, multiDraft, app.vault); + const sceneFile = app.vault.getAbstractFileByPath(sceneFilePath); + if (!(sceneFile instanceof obsidian.TFile)) { + continue; + } + writes.push(clearSceneNumbers(app, sceneFile)); + } + }); + if (writes.length === 0) + return; + return Promise.all(writes); +} +function clearSceneNumbers(app, file) { + return app.fileManager.processFrontMatter(file, (fm) => { + delete fm["longform-order"]; + delete fm["longform-number"]; + }); +} +function writeSceneNumbers(app, file, index, numbering) { + return app.fileManager.processFrontMatter(file, (fm) => { + fm["longform-order"] = index; + fm["longform-number"] = formatSceneNumber(numbering); + }); +} const ESCAPED_CHARACTERS = new Set("/&$^+.()=!|[]{},".split("")); function ignoredPatternToRegex(pattern) { let regex = ""; @@ -37060,6 +38730,428 @@ function ignoredPatternToRegex(pattern) { return new RegExp(`^${regex}$`); } +class LongformSettingsTab extends obsidian.PluginSettingTab { + constructor(app, plugin) { + super(app, plugin); + this.plugin = plugin; + } + display() { + const settings = get_store_value(pluginSettings); + const { containerEl } = this; + containerEl.empty(); + new obsidian.Setting(containerEl).setName("Composition").setHeading(); + new obsidian.Setting(containerEl).setName("New scene template").addSearch((cb) => { + new FileSuggest(this.app, cb.inputEl); + cb.setPlaceholder("templates/Scene.md") + .setValue(settings.sceneTemplate) + .onChange((v) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sceneTemplate: v }))); + }); + }); + containerEl.createEl("p", { cls: "setting-item-description" }, (el) => { + el.innerHTML = + "This file will be used as a template when creating new scenes via the New Scene… field. If you use a templating plugin (Templater or the core plugin) it will be used to process this template. This setting applies to all projects and can be overridden per-project in the Project > Project Metadata settings in the Longform pane."; + }); + new obsidian.Setting(containerEl) + .setName("Show scene numbers in Scenes tab") + .setDesc("If on, shows numbers for scenes with subscenes separated by periods, e.g. 1.1.2. Create subscenes by dragging a scene to an indent under an existing scene, or us an indent command.") + .addToggle((cb) => { + cb.setValue(settings.numberScenes); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { numberScenes: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Write scene index to frontmatter") + .setDesc("If enabled, will add a scene index, and scene number, to the frontmatter of scene files.") + .addToggle((toggle) => { + toggle.setValue(settings.writeProperty); + toggle.onChange((value) => { + pluginSettings.update((settings) => (Object.assign(Object.assign({}, settings), { writeProperty: value }))); + if (value) { + syncSceneIndices(this.app); + } + }); + }); + new obsidian.Setting(containerEl).setName("Compile").setHeading(); + new obsidian.Setting(containerEl) + .setName("User script step folder") + .setDesc(".js files in this folder will be available as User Script Steps in the Compile panel.") + .addSearch((cb) => { + new FolderSuggest(this.app, cb.inputEl); + cb.setPlaceholder("my/script/steps/") + .setValue(settings.userScriptFolder) + .onChange((v) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { userScriptFolder: v }))); + }); + }); + this.stepsSummary = containerEl.createSpan(); + this.stepsList = containerEl.createEl("ul", { + cls: "longform-settings-user-steps", + }); + this.unsubscribeUserScripts = userScriptSteps.subscribe((steps) => { + if (steps && steps.length > 0) { + this.stepsSummary.innerText = `Loaded ${steps.length} step${steps.length !== 1 ? "s" : ""}:`; + } + else { + this.stepsSummary.innerText = "No steps loaded."; + } + if (this.stepsList) { + this.stepsList.empty(); + if (steps) { + steps.forEach((s) => { + const stepEl = this.stepsList.createEl("li"); + stepEl.createSpan({ + text: s.description.name, + cls: "longform-settings-user-step-name", + }); + stepEl.createSpan({ + text: `(${s.description.canonicalID})`, + cls: "longform-settings-user-step-id", + }); + }); + } + } + }); + containerEl.createEl("p", { cls: "setting-item-description" }, (el) => { + el.innerHTML = + "User Script Steps are automatically loaded from this folder. Changes to .js files in this folder are synced with Longform after a slight delay. If your script does not appear here or in the Compile tab, you may have an error in your script—check the dev console for it."; + }); + new obsidian.Setting(containerEl).setName("Word Counts & Sessions").setHeading(); + new obsidian.Setting(containerEl) + .setName("Show word counts in status bar") + .setDesc("Click the status item to show the focused note’s project.") + .addToggle((cb) => { + cb.setValue(settings.showWordCountInStatusBar); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { showWordCountInStatusBar: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Start new writing sessions each day") + .setDesc("You can always manually start a new session by running the Longform: Start New Writing Session command. Turning this off will cause writing sessions to carry over across multiple days until you manually start a new one.") + .addToggle((cb) => { + cb.setValue(settings.startNewSessionEachDay); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { startNewSessionEachDay: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Session word count goal") + .setDesc("A number of words to target for a given writing session.") + .addText((cb) => { + cb.setValue(settings.sessionGoal.toString()); + cb.onChange((value) => { + const numberValue = +value; + if (numberValue && numberValue > 0) { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionGoal: numberValue }))); + } + }); + }); + new obsidian.Setting(containerEl) + .setName("Goal applies to") + .setDesc("You can set your word count goal to target all Longform writing, or you can make each project or scene have its own discrete goal.") + .addDropdown((cb) => { + cb.addOption("all", "words written across all projects"); + cb.addOption("project", "each project individually"); + cb.addOption("note", "each scene or single-scene project"); + cb.setValue(settings.applyGoalTo); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { applyGoalTo: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Notify on goal reached") + .addToggle((cb) => { + cb.setValue(settings.notifyOnGoal); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { notifyOnGoal: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Count deletions against goal") + .setDesc("If on, deleting words will count as negative words written. You cannot go below zero for a session.") + .addToggle((cb) => { + cb.setValue(settings.countDeletionsForGoal); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { countDeletionsForGoal: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Sessions to keep") + .setDesc("Number of sessions to store locally.") + .addText((cb) => { + cb.setValue(settings.keepSessionCount.toString()); + cb.onChange((value) => { + const numberValue = +value; + if (numberValue && numberValue > 0) { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { keepSessionCount: numberValue }))); + } + }); + }); + new obsidian.Setting(containerEl) + .setName("Store session data") + .setDesc("Where your writing session data is stored. By default, data is stored alongside other Longform settings in the plugin’s data.json file. You may instead store it in a separate .json file in the plugin folder, or in a file in your vault. You may want to do this for selective sync or git reasons.") + .addDropdown((cb) => { + cb.addOption("data", "with Longform settings"); + cb.addOption("plugin-folder", "as a .json file in the longform/ plugin folder"); + cb.addOption("file", "as a file in your vault"); + cb.setValue(settings.sessionStorage); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionStorage: value }))); + }); + }); + const updateSessionFile = obsidian.debounce((value) => { + // Normalize file to end in .json + let fileName = value; + if (!fileName || fileName.length === 0) { + fileName = DEFAULT_SESSION_FILE; + } + fileName = obsidian.normalizePath(fileName); + if (!fileName.endsWith(".json")) { + fileName = `${fileName}.json`; + } + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { sessionFile: fileName }))); + }, 1000); + const sessionFileStorageSettings = new obsidian.Setting(containerEl) + .setName("Session storage file") + .setDesc("Location in your vault to store session JSON. Created if does not exist, overwritten if it does.") + .addText((cb) => { + var _a; + cb.setPlaceholder(DEFAULT_SESSION_FILE); + cb.setValue((_a = settings.sessionFile) !== null && _a !== void 0 ? _a : DEFAULT_SESSION_FILE); + cb.onChange(updateSessionFile); + }); + sessionFileStorageSettings.settingEl.style.display = "none"; + this.unsubscribeSettings = pluginSettings.subscribe((settings) => { + sessionFileStorageSettings.settingEl.style.display = + settings.sessionStorage === "file" ? "flex" : "none"; + }); + new obsidian.Setting(containerEl).setName("Troubleshooting").setHeading(); + new obsidian.Setting(containerEl) + .setName("Wait for Obsidian Sync") + .setDesc("Prevent Longform from running until Obsidian Sync completes its first sync. If you are using Sync, you may want to enable this if you experience issues with scenes disappearing or falsely being shown as new.") + .addToggle((cb) => { + cb.setValue(settings.waitForSync); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { waitForSync: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Enable fallback wait") + .setDesc("If sync status cannot be detected, wait for the time specified below before looking for scenes.") + .addToggle((cb) => { + cb.setValue(settings.fallbackWaitEnabled); + cb.onChange((value) => { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { fallbackWaitEnabled: value }))); + }); + }); + new obsidian.Setting(containerEl) + .setName("Fallback wait time") + .setDesc("Time to wait in seconds if sync status cannot be detected.") + .addText((cb) => { + cb.setValue(settings.fallbackWaitTime.toString()); + cb.onChange((value) => { + const numberValue = parseInt(value); + if (!isNaN(numberValue) && numberValue > 0) { + pluginSettings.update((s) => (Object.assign(Object.assign({}, s), { fallbackWaitTime: numberValue }))); + } + }); + }); + new obsidian.Setting(containerEl).setName("Credits").setHeading(); + containerEl.createEl("p", {}, (el) => { + el.innerHTML = + 'Longform written and maintained by Kevin Barrett.'; + }); + containerEl.createEl("p", {}, (el) => { + el.innerHTML = + 'Read the source code and report issues at https://github.com/kevboh/longform.'; + }); + containerEl.createEl("p", {}, (el) => { + el.innerHTML = + 'Icon made by Zlatko Najdenovski from www.flaticon.com.'; + }); + } + hide() { + this.unsubscribeUserScripts(); + this.unsubscribeSettings(); + } +} + +/** + * Prepare a workflow for storage as json. + * @param workflow The workflow to serialize. + * @requires serialized An array of `SerializedStep`s that can be safely saved as json. + */ +function serializeWorkflow(workflow) { + const serialized = workflow.steps.map((step) => ({ + id: step.description.canonicalID, + optionValues: step.optionValues, + })); + return { + name: workflow.name, + description: workflow.description, + steps: serialized, + }; +} +function lookupStep(id, userSteps = []) { + const builtIn = BUILTIN_STEPS.find((s) => s.id === id); + if (builtIn) { + return builtIn; + } + const userStep = userSteps.find((s) => s.id === id); + if (userStep) { + return userStep; + } + return PLACEHOLDER_MISSING_STEP; +} +/** + * Deserializes an array of JSON-compatible steps into one that can be run as a workflow. + * @param w The JSON-compatible steps to deserialize. + * @returns deserialized Array of `CompileStep`s to use as a workflow. + */ +function deserializeWorkflow(w) { + var _a; + const userSteps = (_a = get_store_value(userScriptSteps)) !== null && _a !== void 0 ? _a : []; + const deserialized = Object.assign(Object.assign({}, w), { steps: w.steps.map((s) => { + const step = lookupStep(s.id, userSteps); + return Object.assign(Object.assign({}, step), { optionValues: s.optionValues }); + }) }); + return deserialized; +} + +const DEBOUNCE_SCRIPT_LOAD_DELAY_MS = 10000; +/** + * Watches the user's script folder and loads the scripts it finds there. + */ +class UserScriptObserver { + constructor(vault, userScriptFolder) { + this.initializedSteps = false; + this.vault = vault; + this.userScriptFolder = userScriptFolder; + this.onScriptModify = debounce_1(() => { + console.log(`[Longform] File in user script folder modified, reloading scripts…`); + this.loadUserSteps(); + }, DEBOUNCE_SCRIPT_LOAD_DELAY_MS); + } + destroy() { + this.unsubscribeScriptFolder(); + } + beginObserving() { + if (this.unsubscribeScriptFolder) { + this.unsubscribeScriptFolder(); + } + this.unsubscribeScriptFolder = pluginSettings.subscribe((s) => __awaiter(this, void 0, void 0, function* () { + if (this.initializedSteps && + s.userScriptFolder === this.userScriptFolder) { + return; + } + if (s.userScriptFolder == null) { + return; + } + const valid = yield this.vault.adapter.exists(s.userScriptFolder); + if (!valid) { + return; + } + this.userScriptFolder = s.userScriptFolder; + if (this.userScriptFolder) { + yield this.loadUserSteps(); + } + else { + userScriptSteps.set(null); + console.log("[Longform] Cleared user script steps."); + } + })); + } + loadUserSteps() { + return __awaiter(this, void 0, void 0, function* () { + if (!this.userScriptFolder) { + return; + } + const valid = yield this.vault.adapter.exists(this.userScriptFolder); + if (!valid) { + return; + } + // Get all .js files in folder + const { files } = yield this.vault.adapter.list(this.userScriptFolder); + const scripts = files.filter((f) => f.endsWith("js")); + const userSteps = []; + for (const file of scripts) { + try { + const step = yield this.loadScript(file); + userSteps.push(step); + } + catch (e) { + console.error(`[Longform] skipping user script ${file} due to error:`, e); + } + } + console.log(`[Longform] Loaded ${userSteps.length} user script steps.`); + userScriptSteps.set(userSteps); + this.initializedSteps = true; + // if workflows have loaded, merge in user steps to get updated values + const _workflows = get_store_value(workflows); + const workflowNames = Object.keys(_workflows); + const mergedWorkflows = {}; + workflowNames.forEach((name) => { + const workflow = _workflows[name]; + const workflowSteps = workflow.steps.map((step) => { + const userStep = userSteps.find((u) => step.description.canonicalID === u.description.canonicalID); + if (userStep) { + let mergedStep = Object.assign(Object.assign({}, userStep), { id: step.id, optionValues: userStep.optionValues }); + // Copy existing step's option values into the merged step + for (const key of Object.keys(step.optionValues)) { + if (mergedStep.optionValues[key]) { + mergedStep = Object.assign(Object.assign({}, mergedStep), { optionValues: Object.assign(Object.assign({}, mergedStep.optionValues), { [key]: step.optionValues[key] }) }); + } + } + return mergedStep; + } + else { + return step; + } + }); + mergedWorkflows[name] = Object.assign(Object.assign({}, workflow), { steps: workflowSteps }); + }); + workflows.set(mergedWorkflows); + return userSteps; + }); + } + loadScript(path) { + return __awaiter(this, void 0, void 0, function* () { + const js = yield this.vault.adapter.read(path); + // eslint-disable-next-line prefer-const + let _require = (s) => { + return window.require && window.require(s); + }; + // eslint-disable-next-line prefer-const + let exports = {}; + // eslint-disable-next-line prefer-const + let module = { + exports, + }; + const evaluateScript = window.eval("(function anonymous(require, module, exports){" + js + "\n})"); + evaluateScript(_require, module, exports); + const loadedStep = exports["default"] || module.exports; + if (!loadedStep) { + console.error(`[Longform] Failed to load user script ${path}. No exports detected.`); + throw new Error(`Failed to load user script ${path}. No exports detected.`); + } + const step = makeBuiltinStep(Object.assign(Object.assign({}, loadedStep), { id: path, description: Object.assign(Object.assign({}, loadedStep.description), { availableKinds: loadedStep.description.availableKinds.map((v) => CompileStepKind[v]), options: loadedStep.description.options + ? loadedStep.description.options.map((o) => (Object.assign(Object.assign({}, o), { type: CompileStepOptionType[o.type] }))) + : [] }) }), true); + return Object.assign(Object.assign({}, step), { id: path, description: Object.assign(Object.assign({}, step.description), { canonicalID: path, isScript: true }) }); + }); + } + fileEventCallback(file) { + if (this.userScriptFolder && + file.path.endsWith("js") && + ((file.parent && file.parent.path == this.userScriptFolder) || + (file.parent === null && file.path.startsWith(this.userScriptFolder)))) { + this.onScriptModify(); + } + } +} + class JumpModal extends obsidian.FuzzySuggestModal { constructor(app, items, instructions = [], onSelect) { super(app); @@ -38340,12 +40432,26 @@ class LongformAPI { * Annotates an array of indented scenes with a `numbering` property, an array of `number`s. * This property corresponds to each scene’s “number,” where a scene with no indent is numbered `[1]` or `[2]` or `[3]`, etc. * while an indented scene might be numbered `[1, 1, 2]` to indicate scene 1.1.2, the second scene at a third indent under the first scene and first subscene. + * + * Does not apply `longform-ignore`; use `scenesWithCompileNumberings` to match compile output. + * * @param scenes Array of `IndentedScene`s to annotate. * @returns Array of `NumberedScene`s, which are `IndentedScene`s with an added `numbering` property of type `number[]`. */ scenesWithNumberings(scenes) { return numberScenes(scenes); } + /** + * Numbering for scenes that participate in compile (skips `longform-ignore` in scene frontmatter). + * Matches multi-scene `compile()` numbering and Longform’s scene list when numbering is enabled. + * + * @param app Obsidian app (metadata cache). + * @param draft A multi-scene draft. + * @returns Numbered scenes in compile order. + */ + scenesWithCompileNumberings(app, draft) { + return numberScenes(scenesForCompileNumbering(app, draft)); + } /** * Given an array of numbers, returns the string corresponding to those numbers formatted as scene/subscene “numbering.” * For example, `[1, 1, 2]` becomes `"1.1.2"`. @@ -38666,5 +40772,3 @@ class LongformPlugin extends obsidian.Plugin { } module.exports = LongformPlugin; - -/* nosourcemap */ \ No newline at end of file diff --git a/PaperBell/.obsidian/plugins/longform/manifest.json b/PaperBell/.obsidian/plugins/longform/manifest.json index 230610cb..da57b42b 100644 --- a/PaperBell/.obsidian/plugins/longform/manifest.json +++ b/PaperBell/.obsidian/plugins/longform/manifest.json @@ -1,7 +1,7 @@ { "id": "longform", "name": "Longform", - "version": "2.1.0", + "version": "2.2.0-beta.3", "minAppVersion": "1.0", "description": "Write novels, screenplays, and other long projects in Obsidian.", "author": "Kevin Barrett", diff --git a/PaperBell/.obsidian/plugins/longform/styles.css b/PaperBell/.obsidian/plugins/longform/styles.css index 25d27b78..935b1dcb 100644 --- a/PaperBell/.obsidian/plugins/longform/styles.css +++ b/PaperBell/.obsidian/plugins/longform/styles.css @@ -17,3 +17,15 @@ margin-left: var(--size-4-2); color: var(--text-muted); } + +.longform-metadata-modal { + min-height: 360px; + height: auto; + max-height: 85vh; +} + +.longform-metadata-modal-content { + min-height: 320px; + height: auto; + overflow-y: auto; +} diff --git a/PaperBell/.obsidian/plugins/paperbell/data.json b/PaperBell/.obsidian/plugins/paperbell/data.json index 3cadc41a..ada065a9 100644 --- a/PaperBell/.obsidian/plugins/paperbell/data.json +++ b/PaperBell/.obsidian/plugins/paperbell/data.json @@ -9,6 +9,7 @@ "landing": { "firstLoad": false, "completedSteps": { + "account": false, "renameRepo": false, "configurePlugins": { "obsidian-pandoc-reference-list": false, @@ -70,6 +71,13 @@ "maxAge": 30, "refreshInterval": 300000, "cacheTimeout": 60000, + "literatureFolderPath": "Inputs/Zotero", + "literatureDisplaySettings": { + "titleWrap": true, + "authorWrap": true, + "keywordsWrap": true, + "tagsWrap": true + }, "folderPath": "Inputs/Zotero" }, "researchFocusMap": { @@ -84,6 +92,8 @@ "trackingTags": [ "project" ], + "gridSize": 50, + "borderRadius": 4, "folderPath": "Cards/Concepts", "recursive": true }, @@ -278,6 +288,14 @@ "autoUpdate": false, "minAppVersion": "4.0.2", "customReplacements": {}, + "updateScope": { + "regularFiles": true, + "obsidianCore": true, + "plugins": true, + "themes": true, + "snippets": true, + "pluginData": false + }, "obsidianConflictHandling": { "settings": "prompt", "themes": "prompt", @@ -292,23 +310,6 @@ "institution": "PaperBell Pro", "avatar": "https://avatars.githubusercontent.com/u/196615410?s=400&u=7f34975ce8ebc7e3247d85ab1a0c560012ec4892&v=4" }, - "displaySettings": { - "titleWrap": true, - "authorWrap": true, - "keywordsWrap": true, - "tagsWrap": true - }, - "heatmapSettings": { - "gridSize": 50, - "borderRadius": 4 - }, - "researchFocusSettings": { - "trackingTags": [ - "project" - ], - "gridSize": 50, - "borderRadius": 4 - }, "componentSettings": { "academicOverview": { "showCitations": true, @@ -394,14 +395,29 @@ "autoStartBreaks": false, "autoStartWork": false }, - "literatureSettings": { - "folderPath": "Inputs/Zotero", - "displaySettings": { - "titleWrap": true, - "authorWrap": true, - "keywordsWrap": true, - "tagsWrap": true - } + "baseContainerPaths": { + "projects": null, + "papers": null, + "experiments": null, + "tasks": null, + "resources": null, + "books": null, + "literature": null + }, + "aiSkills": { + "agentType": "claude-code", + "skillsDirectory": ".claude/skills", + "builtinSkillStates": {}, + "marketplaceSkills": [] + }, + "agentAutoExec": { + "enabled": false, + "rules": [], + "binaryPaths": {}, + "globalMaxConcurrent": 2, + "showNoticeOnTrigger": true, + "maxOutputLinesPerRun": 5000, + "maxHistoryRuns": 50 }, "ZotLitColors": { "enabled": true, diff --git a/PaperBell/.obsidian/plugins/zotlit/main.js b/PaperBell/.obsidian/plugins/zotlit/main.js index 71d1a4c3..bdc7e567 100644 --- a/PaperBell/.obsidian/plugins/zotlit/main.js +++ b/PaperBell/.obsidian/plugins/zotlit/main.js @@ -3,43 +3,43 @@ THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source visit the plugins github repository */ -"use strict";var zB=Object.create;var hs=Object.defineProperty;var nS=Object.getOwnPropertyDescriptor;var UB=Object.getOwnPropertyNames;var WB=Object.getPrototypeOf,HB=Object.prototype.hasOwnProperty;var KB=(t,e,r)=>e in t?hs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var Yu=(t,e)=>()=>(t&&(e=t(t=0)),e);var g=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),oS=(t,e)=>{for(var r in e)hs(t,r,{get:e[r],enumerable:!0})},iS=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of UB(e))!HB.call(t,o)&&o!==r&&hs(t,o,{get:()=>e[o],enumerable:!(n=nS(e,o))||n.enumerable});return t};var Z=(t,e,r)=>(r=t!=null?zB(WB(t)):{},iS(e||!t||!t.__esModule?hs(r,"default",{value:t,enumerable:!0}):r,t)),$g=t=>iS(hs({},"__esModule",{value:!0}),t),de=(t,e,r,n)=>{for(var o=n>1?void 0:n?nS(e,r):e,i=t.length-1,s;i>=0;i--)(s=t[i])&&(o=(n?s(e,r,o):s(o))||o);return n&&o&&hs(e,r,o),o};var sS=(t,e,r)=>(KB(t,typeof e!="symbol"?e+"":e,r),r);var RS=g((Rue,kS)=>{var vs=1e3,ws=vs*60,xs=ws*60,ni=xs*24,rz=ni*7,nz=ni*365.25;kS.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return oz(t);if(r==="number"&&isFinite(t))return e.long?sz(t):iz(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function oz(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*nz;case"weeks":case"week":case"w":return r*rz;case"days":case"day":case"d":return r*ni;case"hours":case"hour":case"hrs":case"hr":case"h":return r*xs;case"minutes":case"minute":case"mins":case"min":case"m":return r*ws;case"seconds":case"second":case"secs":case"sec":case"s":return r*vs;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function iz(t){var e=Math.abs(t);return e>=ni?Math.round(t/ni)+"d":e>=xs?Math.round(t/xs)+"h":e>=ws?Math.round(t/ws)+"m":e>=vs?Math.round(t/vs)+"s":t+"ms"}function sz(t){var e=Math.abs(t);return e>=ni?af(t,e,ni,"day"):e>=xs?af(t,e,xs,"hour"):e>=ws?af(t,e,ws,"minute"):e>=vs?af(t,e,vs,"second"):t+" ms"}function af(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var DS=g((Nue,NS)=>{function az(t){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=s,r.humanize=RS(),r.destroy=u,Object.keys(t).forEach(c=>{r[c]=t[c]}),r.names=[],r.skips=[],r.formatters={};function e(c){let f=0;for(let p=0;p{if(J==="%%")return"%";$++;let K=r.formatters[G];if(typeof K=="function"){let F=y[$];J=K.call(v,F),y.splice($,1),$--}return J}),r.formatArgs.call(v,y),(v.log||r.log).apply(v,y)}return b.namespace=c,b.useColors=r.useColors(),b.color=r.selectColor(c),b.extend=n,b.destroy=r.destroy,Object.defineProperty(b,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(d!==r.namespaces&&(d=r.namespaces,h=r.enabled(c)),h),set:y=>{p=y}}),typeof r.init=="function"&&r.init(b),b}function n(c,f){let p=r(this.namespace+(typeof f>"u"?":":f)+c);return p.log=this.log,p}function o(c){r.save(c),r.namespaces=c,r.names=[],r.skips=[];let f,p=(typeof c=="string"?c:"").split(/[\s,]+/),d=p.length;for(f=0;f"-"+f)].join(",");return r.enable(""),c}function s(c){if(c[c.length-1]==="*")return!0;let f,p;for(f=0,p=r.skips.length;f{Wt.formatArgs=cz;Wt.save=uz;Wt.load=fz;Wt.useColors=lz;Wt.storage=pz();Wt.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Wt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function lz(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function cz(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+lf.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}Wt.log=console.debug||console.log||(()=>{});function uz(t){try{t?Wt.storage.setItem("debug",t):Wt.storage.removeItem("debug")}catch{}}function fz(){let t;try{t=Wt.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function pz(){try{return localStorage}catch{}}lf.exports=DS()(Wt);var{formatters:dz}=lf.exports;dz.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var PS=g((Due,FS)=>{"use strict";FS.exports=mz;function Es(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function mz(t){if(t=t||{},t.circles)return hz(t);return t.proto?n:r;function e(o,i){for(var s=Object.keys(o),a=new Array(s.length),l=0;l{var gz=require("util"),oi=Ze()("log4js:configuration"),cf=[],uf=[],MS=t=>!t,$S=t=>t&&typeof t=="object"&&!Array.isArray(t),yz=t=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(t),bz=t=>t&&typeof t=="number"&&Number.isInteger(t),vz=t=>{uf.push(t),oi(`Added listener, now ${uf.length} listeners`)},wz=t=>{cf.push(t),oi(`Added pre-processing listener, now ${cf.length} listeners`)},LS=(t,e,r)=>{(Array.isArray(e)?e:[e]).forEach(o=>{if(o)throw new Error(`Problem with log4js configuration: (${gz.inspect(t,{depth:5})}) - ${r}`)})},xz=t=>{oi("New configuration to be validated: ",t),LS(t,MS($S(t)),"must be an object."),oi(`Calling pre-processing listeners (${cf.length})`),cf.forEach(e=>e(t)),oi("Configuration pre-processing finished."),oi(`Calling configuration listeners (${uf.length})`),uf.forEach(e=>e(t)),oi("Configuration finished.")};jS.exports={configure:xz,addListener:vz,addPreProcessingListener:wz,throwExceptionIf:LS,anObject:$S,anInteger:bz,validIdentifier:yz,not:MS}});var ff=g((Pue,sr)=>{"use strict";function qS(t,e){for(var r=t.toString();r.length-1?o:i,a=si(e.getHours()),l=si(e.getMinutes()),u=si(e.getSeconds()),c=qS(e.getMilliseconds(),3),f=Ez(e.getTimezoneOffset()),p=t.replace(/dd/g,r).replace(/MM/g,n).replace(/y{1,4}/g,s).replace(/hh/g,a).replace(/mm/g,l).replace(/ss/g,u).replace(/SSS/g,c).replace(/O/g,f);return p}function lo(t,e,r,n){t["set"+(n?"":"UTC")+e](r)}function Sz(t,e,r){var n=t.indexOf("O")<0,o=!1,i=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(f,p){lo(f,"FullYear",p,n)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(f,p){lo(f,"Month",p-1,n),f.getMonth()!==p-1&&(o=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(f,p){o&&lo(f,"Month",f.getMonth()-1,n),lo(f,"Date",p,n)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(f,p){lo(f,"Hours",p,n)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(f,p){lo(f,"Minutes",p,n)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(f,p){lo(f,"Seconds",p,n)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(f,p){lo(f,"Milliseconds",p,n)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(f,p){p==="Z"?p=0:p=p.replace(":","");var d=Math.abs(p),h=(p>0?-1:1)*(d%100+Math.floor(d/100)*60);f.setUTCMinutes(f.getUTCMinutes()+h)}}],s=i.reduce(function(f,p){return p.pattern.test(f.regexp)?(p.index=f.regexp.match(p.pattern).index,f.regexp=f.regexp.replace(p.pattern,"("+p.regexp+")")):p.index=-1,f},{regexp:t,index:[]}),a=i.filter(function(f){return f.index>-1});a.sort(function(f,p){return f.index-p.index});var l=new RegExp(s.regexp),u=l.exec(e);if(u){var c=r||sr.exports.now();return a.forEach(function(f,p){f.fn(c,u[p+1])}),c}throw new Error("String '"+e+"' could not be parsed as '"+t+"'")}function Iz(t,e,r){if(!t)throw new Error("pattern must be supplied");return Sz(t,e,r)}function _z(){return new Date}sr.exports=BS;sr.exports.asString=BS;sr.exports.parse=Iz;sr.exports.now=_z;sr.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS";sr.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO";sr.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS";sr.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"});var Yg=g((Mue,QS)=>{var co=ff(),zS=require("os"),tl=require("util"),el=require("path"),US=require("url"),WS=Ze()("log4js:layouts"),HS={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function KS(t){return t?`\x1B[${HS[t][0]}m`:""}function VS(t){return t?`\x1B[${HS[t][1]}m`:""}function Oz(t,e){return KS(e)+t+VS(e)}function GS(t,e){return Oz(tl.format("[%s] [%s] %s - ",co.asString(t.startTime),t.level.toString(),t.categoryName),e)}function ZS(t){return GS(t)+tl.format(...t.data)}function pf(t){return GS(t,t.level.colour)+tl.format(...t.data)}function JS(t){return tl.format(...t.data)}function YS(t){return t.data[0]}function XS(t,e){let r="%r %p %c - %m%n",n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;t=t||r;function o(O,_){let I=O.categoryName;if(_){let B=parseInt(_,10),D=I.split(".");BD&&(I=oe.slice(-D).join(el.sep))}return I}function T(O){return O.lineNumber?`${O.lineNumber}`:""}function $(O){return O.columnNumber?`${O.columnNumber}`:""}function V(O){return O.callStack||""}let J={c:o,d:i,h:s,m:a,n:l,p:u,r:c,"[":f,"]":p,y:b,z:h,"%":d,x:y,X:v,f:x,l:T,o:$,s:V};function G(O,_,I){return J[O](_,I)}function K(O,_){let I;return O?(I=parseInt(O.slice(1),10),I>0?_.slice(0,I):_.slice(I)):_}function F(O,_){let I;if(O)if(O.charAt(0)==="-")for(I=parseInt(O.slice(1),10);_.length{var Be=ii(),e1=["white","grey","black","blue","cyan","green","magenta","red","yellow"],ze=class{constructor(e,r,n){this.level=e,this.levelStr=r,this.colour=n}toString(){return this.levelStr}static getLevel(e,r){return e?e instanceof ze?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),ze[e.toString().toUpperCase()]||r):r}static addLevels(e){e&&(Object.keys(e).forEach(n=>{let o=n.toUpperCase();ze[o]=new ze(e[n].value,o,e[n].colour);let i=ze.levels.findIndex(s=>s.levelStr===o);i>-1?ze.levels[i]=ze[o]:ze.levels.push(ze[o])}),ze.levels.sort((n,o)=>n.level-o.level))}isLessThanOrEqualTo(e){return typeof e=="string"&&(e=ze.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return typeof e=="string"&&(e=ze.getLevel(e)),this.level>=e.level}isEqualTo(e){return typeof e=="string"&&(e=ze.getLevel(e)),this.level===e.level}};ze.levels=[];ze.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}});Be.addListener(t=>{let e=t.levels;e&&(Be.throwExceptionIf(t,Be.not(Be.anObject(e)),"levels must be an object"),Object.keys(e).forEach(n=>{Be.throwExceptionIf(t,Be.not(Be.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),Be.throwExceptionIf(t,Be.not(Be.anObject(e[n])),`level "${n}" must be an object`),Be.throwExceptionIf(t,Be.not(e[n].value),`level "${n}" must have a 'value' property`),Be.throwExceptionIf(t,Be.not(Be.anInteger(e[n].value)),`level "${n}".value must have an integer value`),Be.throwExceptionIf(t,Be.not(e[n].colour),`level "${n}" must have a 'colour' property`),Be.throwExceptionIf(t,Be.not(e1.indexOf(e[n].colour)>-1),`level "${n}".colour must be one of ${e1.join(", ")}`)}))});Be.addListener(t=>{ze.addLevels(t.levels)});t1.exports=ze});var f1=g(nl=>{"use strict";var{parse:o1,stringify:i1}=JSON,{keys:Tz}=Object,rl=String,s1="string",r1={},df="object",a1=(t,e)=>e,Cz=t=>t instanceof rl?rl(t):t,Az=(t,e)=>typeof e===s1?new rl(e):e,l1=(t,e,r,n)=>{let o=[];for(let i=Tz(r),{length:s}=i,a=0;a{let n=rl(e.push(r)-1);return t.set(r,n),n},c1=(t,e)=>{let r=o1(t,Az).map(Cz),n=r[0],o=e||a1,i=typeof n===df&&n?l1(r,new Set,n,o):n;return o.call({"":i},"",i)};nl.parse=c1;var u1=(t,e,r)=>{let n=e&&typeof e===df?(c,f)=>c===""||-1o1(u1(t));nl.toJSON=kz;var Rz=t=>c1(i1(t));nl.fromJSON=Rz});var Xg=g((jue,m1)=>{var p1=f1(),d1=ai(),Ss=class{constructor(e,r,n,o,i){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=r,this.context=Object.assign({},o),this.pid=process.pid,i&&(this.functionName=i.functionName,this.fileName=i.fileName,this.lineNumber=i.lineNumber,this.columnNumber=i.columnNumber,this.callStack=i.callStack)}serialise(){return p1.stringify(this,(e,r)=>(r&&r.message&&r.stack?r=Object.assign({message:r.message,stack:r.stack},r):typeof r=="number"&&(Number.isNaN(r)||!Number.isFinite(r))?r=r.toString():typeof r>"u"&&(r=typeof r),r))}static deserialise(e){let r;try{let n=p1.parse(e,(o,i)=>{if(i&&i.message&&i.stack){let s=new Error(i);Object.keys(i).forEach(a=>{s[a]=i[a]}),i=s}return i});n.location={functionName:n.functionName,fileName:n.fileName,lineNumber:n.lineNumber,columnNumber:n.columnNumber,callStack:n.callStack},r=new Ss(n.categoryName,d1.getLevel(n.level.levelStr),n.data,n.context,n.location),r.startTime=new Date(n.startTime),r.pid=n.pid,r.cluster=n.cluster}catch(n){r=new Ss("log4js",d1.ERROR,["Unable to parse log:",e,"because: ",n])}return r}};m1.exports=Ss});var hf=g((que,y1)=>{var ar=Ze()("log4js:clustering"),Nz=Xg(),Dz=ii(),Is=!1,lr=null;try{lr=require("cluster")}catch{ar("cluster module not present"),Is=!0}var ey=[],il=!1,ol="NODE_APP_INSTANCE",h1=()=>il&&process.env[ol]==="0",Qg=()=>Is||lr&&lr.isMaster||h1(),g1=t=>{ey.forEach(e=>e(t))},mf=(t,e)=>{if(ar("cluster message received from worker ",t,": ",e),t.topic&&t.data&&(e=t,t=void 0),e&&e.topic&&e.topic==="log4js:message"){ar("received message: ",e.data);let r=Nz.deserialise(e.data);g1(r)}};Is||Dz.addListener(t=>{ey.length=0,{pm2:il,disableClustering:Is,pm2InstanceVar:ol="NODE_APP_INSTANCE"}=t,ar(`clustering disabled ? ${Is}`),ar(`cluster.isMaster ? ${lr&&lr.isMaster}`),ar(`pm2 enabled ? ${il}`),ar(`pm2InstanceVar = ${ol}`),ar(`process.env[${ol}] = ${process.env[ol]}`),il&&process.removeListener("message",mf),lr&&lr.removeListener&&lr.removeListener("message",mf),Is||t.disableClustering?ar("Not listening for cluster messages, because clustering disabled."):h1()?(ar("listening for PM2 broadcast messages"),process.on("message",mf)):lr&&lr.isMaster?(ar("listening for cluster messages"),lr.on("message",mf)):ar("not listening for messages, because we are not a master process")});y1.exports={onlyOnMaster:(t,e)=>Qg()?t():e,isMaster:Qg,send:t=>{Qg()?g1(t):(il||(t.cluster={workerId:lr.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:t.serialise()}))},onMessage:t=>{ey.push(t)}}});var w1=g((Bue,v1)=>{function Fz(t){if(typeof t=="number"&&Number.isInteger(t))return t;let e={K:1024,M:1024*1024,G:1024*1024*1024},r=Object.keys(e),n=t.slice(-1).toLocaleUpperCase(),o=t.slice(0,-1).trim();if(r.indexOf(n)<0||!Number.isInteger(Number(o)))throw Error(`maxLogSize: "${t}" is invalid`);return o*e[n]}function Pz(t,e){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{r[n]&&(r[n]=t[n](e[n]))}),r}function ty(t){return Pz({maxLogSize:Fz},t)}var b1={dateFile:ty,file:ty,fileSync:ty};v1.exports.modifyConfig=t=>b1[t.type]?b1[t.type](t):t});var E1=g((zue,x1)=>{var Mz=console.log.bind(console);function $z(t,e){return r=>{Mz(t(r,e))}}function Lz(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),$z(r,t.timezoneOffset)}x1.exports.configure=Lz});var I1=g(S1=>{function jz(t,e){return r=>{process.stdout.write(`${t(r,e)} -`)}}function qz(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),jz(r,t.timezoneOffset)}S1.configure=qz});var O1=g((Wue,_1)=>{function Bz(t,e){return r=>{process.stderr.write(`${t(r,e)} -`)}}function zz(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),Bz(r,t.timezoneOffset)}_1.exports.configure=zz});var C1=g((Hue,T1)=>{function Uz(t,e,r,n){let o=n.getLevel(t),i=n.getLevel(e,n.FATAL);return s=>{let a=s.level;o.isLessThanOrEqualTo(a)&&i.isGreaterThanOrEqualTo(a)&&r(s)}}function Wz(t,e,r,n){let o=r(t.appender);return Uz(t.level,t.maxLevel,o,n)}T1.exports.configure=Wz});var R1=g((Kue,k1)=>{var A1=Ze()("log4js:categoryFilter");function Hz(t,e){return typeof t=="string"&&(t=[t]),r=>{A1(`Checking ${r.categoryName} against ${t}`),t.indexOf(r.categoryName)===-1&&(A1("Not excluded, sending to appender"),e(r))}}function Kz(t,e,r){let n=r(t.appender);return Hz(t.exclude,n)}k1.exports.configure=Kz});var F1=g((Vue,D1)=>{var N1=Ze()("log4js:noLogFilter");function Vz(t){return t.filter(r=>r!=null&&r!=="")}function Gz(t,e){return r=>{N1(`Checking data: ${r.data} against filters: ${t}`),typeof t=="string"&&(t=[t]),t=Vz(t);let n=new RegExp(t.join("|"),"i");(t.length===0||r.data.findIndex(o=>n.test(o))<0)&&(N1("Not excluded, sending to appender"),e(r))}}function Zz(t,e,r){let n=r(t.appender);return Gz(t.exclude,n)}D1.exports.configure=Zz});var At=g(ry=>{"use strict";ry.fromCallback=function(t){return Object.defineProperty(function(){if(typeof arguments[arguments.length-1]=="function")t.apply(this,arguments);else return new Promise((e,r)=>{arguments[arguments.length]=(n,o)=>{if(n)return r(n);e(o)},arguments.length++,t.apply(this,arguments)})},"name",{value:t.name})};ry.fromPromise=function(t){return Object.defineProperty(function(){let e=arguments[arguments.length-1];if(typeof e!="function")return t.apply(this,arguments);t.apply(this,arguments).then(r=>e(null,r),e)},"name",{value:t.name})}});var M1=g((Zue,P1)=>{var uo=require("constants"),Jz=process.cwd,gf=null,Yz=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return gf||(gf=Jz.call(process)),gf};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ny=process.chdir,process.chdir=function(t){gf=null,ny.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ny));var ny;P1.exports=Xz;function Xz(t){uo.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=i(t.chown),t.fchown=i(t.fchown),t.lchown=i(t.lchown),t.chmod=n(t.chmod),t.fchmod=n(t.fchmod),t.lchmod=n(t.lchmod),t.chownSync=s(t.chownSync),t.fchownSync=s(t.fchownSync),t.lchownSync=s(t.lchownSync),t.chmodSync=o(t.chmodSync),t.fchmodSync=o(t.fchmodSync),t.lchmodSync=o(t.lchmodSync),t.stat=a(t.stat),t.fstat=a(t.fstat),t.lstat=a(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(c,f,p){p&&process.nextTick(p)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(c,f,p,d){d&&process.nextTick(d)},t.lchownSync=function(){}),Yz==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:function(c){function f(p,d,h){var b=Date.now(),y=0;c(p,d,function v(x){if(x&&(x.code==="EACCES"||x.code==="EPERM"||x.code==="EBUSY")&&Date.now()-b<6e4){setTimeout(function(){t.stat(d,function(T,$){T&&T.code==="ENOENT"?c(p,d,v):h(x)})},y),y<100&&(y+=10);return}h&&h(x)})}return Object.setPrototypeOf&&Object.setPrototypeOf(f,c),f}(t.rename)),t.read=typeof t.read!="function"?t.read:function(c){function f(p,d,h,b,y,v){var x;if(v&&typeof v=="function"){var T=0;x=function($,V,J){if($&&$.code==="EAGAIN"&&T<10)return T++,c.call(t,p,d,h,b,y,x);v.apply(this,arguments)}}return c.call(t,p,d,h,b,y,x)}return Object.setPrototypeOf&&Object.setPrototypeOf(f,c),f}(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:function(c){return function(f,p,d,h,b){for(var y=0;;)try{return c.call(t,f,p,d,h,b)}catch(v){if(v.code==="EAGAIN"&&y<10){y++;continue}throw v}}}(t.readSync);function e(c){c.lchmod=function(f,p,d){c.open(f,uo.O_WRONLY|uo.O_SYMLINK,p,function(h,b){if(h){d&&d(h);return}c.fchmod(b,p,function(y){c.close(b,function(v){d&&d(y||v)})})})},c.lchmodSync=function(f,p){var d=c.openSync(f,uo.O_WRONLY|uo.O_SYMLINK,p),h=!0,b;try{b=c.fchmodSync(d,p),h=!1}finally{if(h)try{c.closeSync(d)}catch{}else c.closeSync(d)}return b}}function r(c){uo.hasOwnProperty("O_SYMLINK")&&c.futimes?(c.lutimes=function(f,p,d,h){c.open(f,uo.O_SYMLINK,function(b,y){if(b){h&&h(b);return}c.futimes(y,p,d,function(v){c.close(y,function(x){h&&h(v||x)})})})},c.lutimesSync=function(f,p,d){var h=c.openSync(f,uo.O_SYMLINK),b,y=!0;try{b=c.futimesSync(h,p,d),y=!1}finally{if(y)try{c.closeSync(h)}catch{}else c.closeSync(h)}return b}):c.futimes&&(c.lutimes=function(f,p,d,h){h&&process.nextTick(h)},c.lutimesSync=function(){})}function n(c){return c&&function(f,p,d){return c.call(t,f,p,function(h){u(h)&&(h=null),d&&d.apply(this,arguments)})}}function o(c){return c&&function(f,p){try{return c.call(t,f,p)}catch(d){if(!u(d))throw d}}}function i(c){return c&&function(f,p,d,h){return c.call(t,f,p,d,function(b){u(b)&&(b=null),h&&h.apply(this,arguments)})}}function s(c){return c&&function(f,p,d){try{return c.call(t,f,p,d)}catch(h){if(!u(h))throw h}}}function a(c){return c&&function(f,p,d){typeof p=="function"&&(d=p,p=null);function h(b,y){y&&(y.uid<0&&(y.uid+=4294967296),y.gid<0&&(y.gid+=4294967296)),d&&d.apply(this,arguments)}return p?c.call(t,f,p,h):c.call(t,f,h)}}function l(c){return c&&function(f,p){var d=p?c.call(t,f,p):c.call(t,f);return d&&(d.uid<0&&(d.uid+=4294967296),d.gid<0&&(d.gid+=4294967296)),d}}function u(c){if(!c||c.code==="ENOSYS")return!0;var f=!process.getuid||process.getuid()!==0;return!!(f&&(c.code==="EINVAL"||c.code==="EPERM"))}}});var j1=g((Jue,L1)=>{var $1=require("stream").Stream;L1.exports=Qz;function Qz(t){return{ReadStream:e,WriteStream:r};function e(n,o){if(!(this instanceof e))return new e(n,o);$1.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,o=o||{};for(var s=Object.keys(o),a=0,l=s.length;athis.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}t.open(this.path,this.flags,this.mode,function(c,f){if(c){i.emit("error",c),i.readable=!1;return}i.fd=f,i.emit("open",f),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);$1.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};for(var i=Object.keys(o),s=0,a=i.length;s= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var B1=g((Yue,q1)=>{"use strict";q1.exports=t6;var e6=Object.getPrototypeOf||function(t){return t.__proto__};function t6(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:e6(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var Ue=g((Xue,sy)=>{var ke=require("fs"),r6=M1(),n6=j1(),o6=B1(),yf=require("util"),st,vf;typeof Symbol=="function"&&typeof Symbol.for=="function"?(st=Symbol.for("graceful-fs.queue"),vf=Symbol.for("graceful-fs.previous")):(st="___graceful-fs.queue",vf="___graceful-fs.previous");function i6(){}function W1(t,e){Object.defineProperty(t,st,{get:function(){return e}})}var li=i6;yf.debuglog?li=yf.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(li=function(){var t=yf.format.apply(yf,arguments);t="GFS4: "+t.split(/\n/).join(` -GFS4: `),console.error(t)});ke[st]||(z1=global[st]||[],W1(ke,z1),ke.close=function(t){function e(r,n){return t.call(ke,r,function(o){o||U1(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,vf,{value:t}),e}(ke.close),ke.closeSync=function(t){function e(r){t.apply(ke,arguments),U1()}return Object.defineProperty(e,vf,{value:t}),e}(ke.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){li(ke[st]),require("assert").equal(ke[st].length,0)}));var z1;global[st]||W1(global,ke[st]);sy.exports=oy(o6(ke));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ke.__patched&&(sy.exports=oy(ke),ke.__patched=!0);function oy(t){r6(t),t.gracefulify=oy,t.createReadStream=V,t.createWriteStream=J;var e=t.readFile;t.readFile=r;function r(F,Q,O){return typeof Q=="function"&&(O=Q,Q=null),_(F,Q,O);function _(I,B,D,oe){return e(I,B,function(se){se&&(se.code==="EMFILE"||se.code==="ENFILE")?_s([_,[I,B,D],se,oe||Date.now(),Date.now()]):typeof D=="function"&&D.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=o;function o(F,Q,O,_){return typeof O=="function"&&(_=O,O=null),I(F,Q,O,_);function I(B,D,oe,se,be){return n(B,D,oe,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?_s([I,[B,D,oe,se],ce,be||Date.now(),Date.now()]):typeof se=="function"&&se.apply(this,arguments)})}}var i=t.appendFile;i&&(t.appendFile=s);function s(F,Q,O,_){return typeof O=="function"&&(_=O,O=null),I(F,Q,O,_);function I(B,D,oe,se,be){return i(B,D,oe,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?_s([I,[B,D,oe,se],ce,be||Date.now(),Date.now()]):typeof se=="function"&&se.apply(this,arguments)})}}var a=t.copyFile;a&&(t.copyFile=l);function l(F,Q,O,_){return typeof O=="function"&&(_=O,O=0),I(F,Q,O,_);function I(B,D,oe,se,be){return a(B,D,oe,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?_s([I,[B,D,oe,se],ce,be||Date.now(),Date.now()]):typeof se=="function"&&se.apply(this,arguments)})}}var u=t.readdir;t.readdir=f;var c=/^v[0-5]\./;function f(F,Q,O){typeof Q=="function"&&(O=Q,Q=null);var _=c.test(process.version)?function(D,oe,se,be){return u(D,I(D,oe,se,be))}:function(D,oe,se,be){return u(D,oe,I(D,oe,se,be))};return _(F,Q,O);function I(B,D,oe,se){return function(be,ce){be&&(be.code==="EMFILE"||be.code==="ENFILE")?_s([_,[B,D,oe],be,se||Date.now(),Date.now()]):(ce&&ce.sort&&ce.sort(),typeof oe=="function"&&oe.call(this,be,ce))}}}if(process.version.substr(0,4)==="v0.8"){var p=n6(t);v=p.ReadStream,T=p.WriteStream}var d=t.ReadStream;d&&(v.prototype=Object.create(d.prototype),v.prototype.open=x);var h=t.WriteStream;h&&(T.prototype=Object.create(h.prototype),T.prototype.open=$),Object.defineProperty(t,"ReadStream",{get:function(){return v},set:function(F){v=F},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return T},set:function(F){T=F},enumerable:!0,configurable:!0});var b=v;Object.defineProperty(t,"FileReadStream",{get:function(){return b},set:function(F){b=F},enumerable:!0,configurable:!0});var y=T;Object.defineProperty(t,"FileWriteStream",{get:function(){return y},set:function(F){y=F},enumerable:!0,configurable:!0});function v(F,Q){return this instanceof v?(d.apply(this,arguments),this):v.apply(Object.create(v.prototype),arguments)}function x(){var F=this;K(F.path,F.flags,F.mode,function(Q,O){Q?(F.autoClose&&F.destroy(),F.emit("error",Q)):(F.fd=O,F.emit("open",O),F.read())})}function T(F,Q){return this instanceof T?(h.apply(this,arguments),this):T.apply(Object.create(T.prototype),arguments)}function $(){var F=this;K(F.path,F.flags,F.mode,function(Q,O){Q?(F.destroy(),F.emit("error",Q)):(F.fd=O,F.emit("open",O))})}function V(F,Q){return new t.ReadStream(F,Q)}function J(F,Q){return new t.WriteStream(F,Q)}var G=t.open;t.open=K;function K(F,Q,O,_){return typeof O=="function"&&(_=O,O=null),I(F,Q,O,_);function I(B,D,oe,se,be){return G(B,D,oe,function(ce,E){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?_s([I,[B,D,oe,se],ce,be||Date.now(),Date.now()]):typeof se=="function"&&se.apply(this,arguments)})}}return t}function _s(t){li("ENQUEUE",t[0].name,t[1]),ke[st].push(t),iy()}var bf;function U1(){for(var t=Date.now(),e=0;e2&&(ke[st][e][3]=t,ke[st][e][4]=t);iy()}function iy(){if(clearTimeout(bf),bf=void 0,ke[st].length!==0){var t=ke[st].shift(),e=t[0],r=t[1],n=t[2],o=t[3],i=t[4];if(o===void 0)li("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-o>=6e4){li("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-i,l=Math.max(i-o,1),u=Math.min(l*1.2,100);a>=u?(li("RETRY",e.name,r),e.apply(null,r.concat([o]))):ke[st].push(t)}bf===void 0&&(bf=setTimeout(iy,0))}}});var ay=g(ci=>{"use strict";var H1=At().fromCallback,cr=Ue(),s6=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(t=>typeof cr[t]=="function");Object.keys(cr).forEach(t=>{t!=="promises"&&(ci[t]=cr[t])});s6.forEach(t=>{ci[t]=H1(cr[t])});ci.exists=function(t,e){return typeof e=="function"?cr.exists(t,e):new Promise(r=>cr.exists(t,r))};ci.read=function(t,e,r,n,o,i){return typeof i=="function"?cr.read(t,e,r,n,o,i):new Promise((s,a)=>{cr.read(t,e,r,n,o,(l,u,c)=>{if(l)return a(l);s({bytesRead:u,buffer:c})})})};ci.write=function(t,e,...r){return typeof r[r.length-1]=="function"?cr.write(t,e,...r):new Promise((n,o)=>{cr.write(t,e,...r,(i,s,a)=>{if(i)return o(i);n({bytesWritten:s,buffer:a})})})};typeof cr.realpath.native=="function"&&(ci.realpath.native=H1(cr.realpath.native))});var cy=g((efe,V1)=>{"use strict";var ly=require("path");function K1(t){return t=ly.normalize(ly.resolve(t)).split(ly.sep),t.length>0?t[0]:null}var a6=/[<>:"|?*]/;function l6(t){let e=K1(t);return t=t.replace(e,""),a6.test(t)}V1.exports={getRootPath:K1,invalidWin32Path:l6}});var Z1=g((tfe,G1)=>{"use strict";var c6=Ue(),uy=require("path"),u6=cy().invalidWin32Path,f6=parseInt("0777",8);function fy(t,e,r,n){if(typeof e=="function"?(r=e,e={}):(!e||typeof e!="object")&&(e={mode:e}),process.platform==="win32"&&u6(t)){let s=new Error(t+" contains invalid WIN32 path characters.");return s.code="EINVAL",r(s)}let o=e.mode,i=e.fs||c6;o===void 0&&(o=f6&~process.umask()),n||(n=null),r=r||function(){},t=uy.resolve(t),i.mkdir(t,o,s=>{if(!s)return n=n||t,r(null,n);switch(s.code){case"ENOENT":if(uy.dirname(t)===t)return r(s);fy(uy.dirname(t),e,(a,l)=>{a?r(a,l):fy(t,e,r,l)});break;default:i.stat(t,(a,l)=>{a||!l.isDirectory()?r(s,n):r(null,n)});break}})}G1.exports=fy});var Y1=g((rfe,J1)=>{"use strict";var p6=Ue(),py=require("path"),d6=cy().invalidWin32Path,m6=parseInt("0777",8);function dy(t,e,r){(!e||typeof e!="object")&&(e={mode:e});let n=e.mode,o=e.fs||p6;if(process.platform==="win32"&&d6(t)){let i=new Error(t+" contains invalid WIN32 path characters.");throw i.code="EINVAL",i}n===void 0&&(n=m6&~process.umask()),r||(r=null),t=py.resolve(t);try{o.mkdirSync(t,n),r=r||t}catch(i){if(i.code==="ENOENT"){if(py.dirname(t)===t)throw i;r=dy(py.dirname(t),e,r),dy(t,e,r)}else{let s;try{s=o.statSync(t)}catch{throw i}if(!s.isDirectory())throw i}}return r}J1.exports=dy});var Ht=g((nfe,X1)=>{"use strict";var h6=At().fromCallback,my=h6(Z1()),hy=Y1();X1.exports={mkdirs:my,mkdirsSync:hy,mkdirp:my,mkdirpSync:hy,ensureDir:my,ensureDirSync:hy}});var gy=g((ofe,eI)=>{"use strict";var pt=Ue(),Q1=require("os"),wf=require("path");function g6(){let t=wf.join("millis-test-sync"+Date.now().toString()+Math.random().toString().slice(2));t=wf.join(Q1.tmpdir(),t);let e=new Date(1435410243862);pt.writeFileSync(t,"https://github.com/jprichardson/node-fs-extra/pull/141");let r=pt.openSync(t,"r+");return pt.futimesSync(r,e,e),pt.closeSync(r),pt.statSync(t).mtime>1435410243e3}function y6(t){let e=wf.join("millis-test"+Date.now().toString()+Math.random().toString().slice(2));e=wf.join(Q1.tmpdir(),e);let r=new Date(1435410243862);pt.writeFile(e,"https://github.com/jprichardson/node-fs-extra/pull/141",n=>{if(n)return t(n);pt.open(e,"r+",(o,i)=>{if(o)return t(o);pt.futimes(i,r,r,s=>{if(s)return t(s);pt.close(i,a=>{if(a)return t(a);pt.stat(e,(l,u)=>{if(l)return t(l);t(null,u.mtime>1435410243e3)})})})})})}function b6(t){if(typeof t=="number")return Math.floor(t/1e3)*1e3;if(t instanceof Date)return new Date(Math.floor(t.getTime()/1e3)*1e3);throw new Error("fs-extra: timeRemoveMillis() unknown parameter type")}function v6(t,e,r,n){pt.open(t,"r+",(o,i)=>{if(o)return n(o);pt.futimes(i,e,r,s=>{pt.close(i,a=>{n&&n(s||a)})})})}function w6(t,e,r){let n=pt.openSync(t,"r+");return pt.futimesSync(n,e,r),pt.closeSync(n)}eI.exports={hasMillisRes:y6,hasMillisResSync:g6,timeRemoveMillis:b6,utimesMillis:v6,utimesMillisSync:w6}});var ll=g((ife,sI)=>{"use strict";var ur=Ue(),kt=require("path"),tI=10,rI=5,x6=0,by=process.versions.node.split("."),nI=Number.parseInt(by[0],10),oI=Number.parseInt(by[1],10),E6=Number.parseInt(by[2],10);function sl(){if(nI>tI)return!0;if(nI===tI){if(oI>rI)return!0;if(oI===rI&&E6>=x6)return!0}return!1}function S6(t,e,r){sl()?ur.stat(t,{bigint:!0},(n,o)=>{if(n)return r(n);ur.stat(e,{bigint:!0},(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))}):ur.stat(t,(n,o)=>{if(n)return r(n);ur.stat(e,(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))})}function I6(t,e){let r,n;sl()?r=ur.statSync(t,{bigint:!0}):r=ur.statSync(t);try{sl()?n=ur.statSync(e,{bigint:!0}):n=ur.statSync(e)}catch(o){if(o.code==="ENOENT")return{srcStat:r,destStat:null};throw o}return{srcStat:r,destStat:n}}function _6(t,e,r,n){S6(t,e,(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;return a&&a.ino&&a.dev&&a.ino===s.ino&&a.dev===s.dev?n(new Error("Source and destination must not be the same.")):s.isDirectory()&&vy(t,e)?n(new Error(al(t,e,r))):n(null,{srcStat:s,destStat:a})})}function O6(t,e,r){let{srcStat:n,destStat:o}=I6(t,e);if(o&&o.ino&&o.dev&&o.ino===n.ino&&o.dev===n.dev)throw new Error("Source and destination must not be the same.");if(n.isDirectory()&&vy(t,e))throw new Error(al(t,e,r));return{srcStat:n,destStat:o}}function yy(t,e,r,n,o){let i=kt.resolve(kt.dirname(t)),s=kt.resolve(kt.dirname(r));if(s===i||s===kt.parse(s).root)return o();sl()?ur.stat(s,{bigint:!0},(a,l)=>a?a.code==="ENOENT"?o():o(a):l.ino&&l.dev&&l.ino===e.ino&&l.dev===e.dev?o(new Error(al(t,r,n))):yy(t,e,s,n,o)):ur.stat(s,(a,l)=>a?a.code==="ENOENT"?o():o(a):l.ino&&l.dev&&l.ino===e.ino&&l.dev===e.dev?o(new Error(al(t,r,n))):yy(t,e,s,n,o))}function iI(t,e,r,n){let o=kt.resolve(kt.dirname(t)),i=kt.resolve(kt.dirname(r));if(i===o||i===kt.parse(i).root)return;let s;try{sl()?s=ur.statSync(i,{bigint:!0}):s=ur.statSync(i)}catch(a){if(a.code==="ENOENT")return;throw a}if(s.ino&&s.dev&&s.ino===e.ino&&s.dev===e.dev)throw new Error(al(t,r,n));return iI(t,e,i,n)}function vy(t,e){let r=kt.resolve(t).split(kt.sep).filter(o=>o),n=kt.resolve(e).split(kt.sep).filter(o=>o);return r.reduce((o,i,s)=>o&&n[s]===i,!0)}function al(t,e,r){return`Cannot ${r} '${t}' to a subdirectory of itself, '${e}'.`}sI.exports={checkPaths:_6,checkPathsSync:O6,checkParentPaths:yy,checkParentPathsSync:iI,isSrcSubdir:vy}});var lI=g((sfe,aI)=>{"use strict";aI.exports=function(t){if(typeof Buffer.allocUnsafe=="function")try{return Buffer.allocUnsafe(t)}catch{return new Buffer(t)}return new Buffer(t)}});var dI=g((afe,pI)=>{"use strict";var Ce=Ue(),cl=require("path"),T6=Ht().mkdirsSync,C6=gy().utimesMillisSync,ul=ll();function A6(t,e,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; +"use strict";var uz=Object.create;var xs=Object.defineProperty;var hS=Object.getOwnPropertyDescriptor;var fz=Object.getOwnPropertyNames;var pz=Object.getPrototypeOf,dz=Object.prototype.hasOwnProperty;var mz=(t,e,r)=>e in t?xs(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var rc=(t,e)=>()=>(t&&(e=t(t=0)),e);var b=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),gS=(t,e)=>{for(var r in e)xs(t,r,{get:e[r],enumerable:!0})},yS=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of fz(e))!dz.call(t,o)&&o!==r&&xs(t,o,{get:()=>e[o],enumerable:!(n=hS(e,o))||n.enumerable});return t};var Y=(t,e,r)=>(r=t!=null?uz(pz(t)):{},yS(e||!t||!t.__esModule?xs(r,"default",{value:t,enumerable:!0}):r,t)),Zg=t=>yS(xs({},"__esModule",{value:!0}),t),he=(t,e,r,n)=>{for(var o=n>1?void 0:n?hS(e,r):e,i=t.length-1,s;i>=0;i--)(s=t[i])&&(o=(n?s(e,r,o):s(o))||o);return n&&o&&xs(e,r,o),o};var bS=(t,e,r)=>(mz(t,typeof e!="symbol"?e+"":e,r),r);var p,a=rc(()=>{p={"121":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"123":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"125":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"128":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"130":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"132":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"133":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"135":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"136":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"139":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"140":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"143":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]},"145":{darwin:["arm64","x64"],linux:["arm64","x64"],win32:["arm64","ia32","x64"]}}});var WS=b((hle,US)=>{a();var _s=1e3,Ts=_s*60,Os=Ts*60,ai=Os*24,_z=ai*7,Tz=ai*365.25;US.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Oz(t);if(r==="number"&&isFinite(t))return e.long?kz(t):Cz(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Oz(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Tz;case"weeks":case"week":case"w":return r*_z;case"days":case"day":case"d":return r*ai;case"hours":case"hour":case"hrs":case"hr":case"h":return r*Os;case"minutes":case"minute":case"mins":case"min":case"m":return r*Ts;case"seconds":case"second":case"secs":case"sec":case"s":return r*_s;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Cz(t){var e=Math.abs(t);return e>=ai?Math.round(t/ai)+"d":e>=Os?Math.round(t/Os)+"h":e>=Ts?Math.round(t/Ts)+"m":e>=_s?Math.round(t/_s)+"s":t+"ms"}function kz(t){var e=Math.abs(t);return e>=ai?mf(t,e,ai,"day"):e>=Os?mf(t,e,Os,"hour"):e>=Ts?mf(t,e,Ts,"minute"):e>=_s?mf(t,e,_s,"second"):t+" ms"}function mf(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var KS=b((yle,HS)=>{a();function Az(t){r.debug=r,r.default=r,r.coerce=l,r.disable=i,r.enable=o,r.enabled=s,r.humanize=WS(),r.destroy=f,Object.keys(t).forEach(u=>{r[u]=t[u]}),r.names=[],r.skips=[],r.formatters={};function e(u){let d=0;for(let m=0;m{if(X==="%%")return"%";j++;let G=r.formatters[J];if(typeof G=="function"){let M=v[j];X=G.call(x,M),v.splice(j,1),j--}return X}),r.formatArgs.call(x,v),(x.log||r.log).apply(x,v)}return w.namespace=u,w.useColors=r.useColors(),w.color=r.selectColor(u),w.extend=n,w.destroy=r.destroy,Object.defineProperty(w,"enabled",{enumerable:!0,configurable:!1,get:()=>m!==null?m:(h!==r.namespaces&&(h=r.namespaces,y=r.enabled(u)),y),set:v=>{m=v}}),typeof r.init=="function"&&r.init(w),w}function n(u,d){let m=r(this.namespace+(typeof d>"u"?":":d)+u);return m.log=this.log,m}function o(u){r.save(u),r.namespaces=u,r.names=[],r.skips=[];let d,m=(typeof u=="string"?u:"").split(/[\s,]+/),h=m.length;for(d=0;d"-"+d)].join(",");return r.enable(""),u}function s(u){if(u[u.length-1]==="*")return!0;let d,m;for(d=0,m=r.skips.length;d{a();Gt.formatArgs=Nz;Gt.save=Dz;Gt.load=Pz;Gt.useColors=Rz;Gt.storage=Fz();Gt.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Gt.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Rz(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function Nz(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+hf.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}Gt.log=console.debug||console.log||(()=>{});function Dz(t){try{t?Gt.storage.setItem("debug",t):Gt.storage.removeItem("debug")}catch{}}function Pz(){let t;try{t=Gt.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function Fz(){try{return localStorage}catch{}}hf.exports=KS()(Gt);var{formatters:Mz}=hf.exports;Mz.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var GS=b((wle,VS)=>{"use strict";a();VS.exports=$z;function Cs(t){return t instanceof Buffer?Buffer.from(t):new t.constructor(t.buffer.slice(),t.byteOffset,t.length)}function $z(t){if(t=t||{},t.circles)return Lz(t);return t.proto?n:r;function e(o,i){for(var s=Object.keys(o),c=new Array(s.length),l=0;l{a();var jz=require("util"),ci=Xe()("log4js:configuration"),gf=[],yf=[],ZS=t=>!t,JS=t=>t&&typeof t=="object"&&!Array.isArray(t),qz=t=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(t),Bz=t=>t&&typeof t=="number"&&Number.isInteger(t),zz=t=>{yf.push(t),ci(`Added listener, now ${yf.length} listeners`)},Uz=t=>{gf.push(t),ci(`Added pre-processing listener, now ${gf.length} listeners`)},YS=(t,e,r)=>{(Array.isArray(e)?e:[e]).forEach(o=>{if(o)throw new Error(`Problem with log4js configuration: (${jz.inspect(t,{depth:5})}) - ${r}`)})},Wz=t=>{ci("New configuration to be validated: ",t),YS(t,ZS(JS(t)),"must be an object."),ci(`Calling pre-processing listeners (${gf.length})`),gf.forEach(e=>e(t)),ci("Configuration pre-processing finished."),ci(`Calling configuration listeners (${yf.length})`),yf.forEach(e=>e(t)),ci("Configuration finished.")};XS.exports={configure:Wz,addListener:zz,addPreProcessingListener:Uz,throwExceptionIf:YS,anObject:JS,anInteger:Bz,validIdentifier:qz,not:ZS}});var bf=b((Ile,ur)=>{"use strict";a();function QS(t,e){for(var r=t.toString();r.length-1?o:i,c=ui(e.getHours()),l=ui(e.getMinutes()),f=ui(e.getSeconds()),u=QS(e.getMilliseconds(),3),d=Hz(e.getTimezoneOffset()),m=t.replace(/dd/g,r).replace(/MM/g,n).replace(/y{1,4}/g,s).replace(/hh/g,c).replace(/mm/g,l).replace(/ss/g,f).replace(/SSS/g,u).replace(/O/g,d);return m}function fo(t,e,r,n){t["set"+(n?"":"UTC")+e](r)}function Kz(t,e,r){var n=t.indexOf("O")<0,o=!1,i=[{pattern:/y{1,4}/,regexp:"\\d{1,4}",fn:function(d,m){fo(d,"FullYear",m,n)}},{pattern:/MM/,regexp:"\\d{1,2}",fn:function(d,m){fo(d,"Month",m-1,n),d.getMonth()!==m-1&&(o=!0)}},{pattern:/dd/,regexp:"\\d{1,2}",fn:function(d,m){o&&fo(d,"Month",d.getMonth()-1,n),fo(d,"Date",m,n)}},{pattern:/hh/,regexp:"\\d{1,2}",fn:function(d,m){fo(d,"Hours",m,n)}},{pattern:/mm/,regexp:"\\d\\d",fn:function(d,m){fo(d,"Minutes",m,n)}},{pattern:/ss/,regexp:"\\d\\d",fn:function(d,m){fo(d,"Seconds",m,n)}},{pattern:/SSS/,regexp:"\\d\\d\\d",fn:function(d,m){fo(d,"Milliseconds",m,n)}},{pattern:/O/,regexp:"[+-]\\d{1,2}:?\\d{2}?|Z",fn:function(d,m){m==="Z"?m=0:m=m.replace(":","");var h=Math.abs(m),y=(m>0?-1:1)*(h%100+Math.floor(h/100)*60);d.setUTCMinutes(d.getUTCMinutes()+y)}}],s=i.reduce(function(d,m){return m.pattern.test(d.regexp)?(m.index=d.regexp.match(m.pattern).index,d.regexp=d.regexp.replace(m.pattern,"("+m.regexp+")")):m.index=-1,d},{regexp:t,index:[]}),c=i.filter(function(d){return d.index>-1});c.sort(function(d,m){return d.index-m.index});var l=new RegExp(s.regexp),f=l.exec(e);if(f){var u=r||ur.exports.now();return c.forEach(function(d,m){d.fn(u,f[m+1])}),u}throw new Error("String '"+e+"' could not be parsed as '"+t+"'")}function Vz(t,e,r){if(!t)throw new Error("pattern must be supplied");return Kz(t,e,r)}function Gz(){return new Date}ur.exports=eI;ur.exports.asString=eI;ur.exports.parse=Vz;ur.exports.now=Gz;ur.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS";ur.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO";ur.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS";ur.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"});var ly=b((Tle,pI)=>{a();var po=bf(),tI=require("os"),lc=require("util"),cc=require("path"),rI=require("url"),nI=Xe()("log4js:layouts"),oI={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function iI(t){return t?`\x1B[${oI[t][0]}m`:""}function sI(t){return t?`\x1B[${oI[t][1]}m`:""}function Zz(t,e){return iI(e)+t+sI(e)}function aI(t,e){return Zz(lc.format("[%s] [%s] %s - ",po.asString(t.startTime),t.level.toString(),t.categoryName),e)}function cI(t){return aI(t)+lc.format(...t.data)}function vf(t){return aI(t,t.level.colour)+lc.format(...t.data)}function lI(t){return lc.format(...t.data)}function uI(t){return t.data[0]}function fI(t,e){let r="%r %p %c - %m%n",n=/%(-?[0-9]+)?(\.?-?[0-9]+)?([[\]cdhmnprzxXyflos%])(\{([^}]+)\})?|([^%]+)/;t=t||r;function o(C,O){let T=C.categoryName;if(O){let U=parseInt(O,10),F=T.split(".");UF&&(T=se.slice(-F).join(cc.sep))}return T}function k(C){return C.lineNumber?`${C.lineNumber}`:""}function j(C){return C.columnNumber?`${C.columnNumber}`:""}function Z(C){return C.callStack||""}let X={c:o,d:i,h:s,m:c,n:l,p:f,r:u,"[":d,"]":m,y:w,z:y,"%":h,x:v,X:x,f:S,l:k,o:j,s:Z};function J(C,O,T){return X[C](O,T)}function G(C,O){let T;return C?(T=parseInt(C.slice(1),10),T>0?O.slice(0,T):O.slice(T)):O}function M(C,O){let T;if(C)if(C.charAt(0)==="-")for(T=parseInt(C.slice(1),10);O.length{a();var We=li(),dI=["white","grey","black","blue","cyan","green","magenta","red","yellow"],He=class{constructor(e,r,n){this.level=e,this.levelStr=r,this.colour=n}toString(){return this.levelStr}static getLevel(e,r){return e?e instanceof He?e:(e instanceof Object&&e.levelStr&&(e=e.levelStr),He[e.toString().toUpperCase()]||r):r}static addLevels(e){e&&(Object.keys(e).forEach(n=>{let o=n.toUpperCase();He[o]=new He(e[n].value,o,e[n].colour);let i=He.levels.findIndex(s=>s.levelStr===o);i>-1?He.levels[i]=He[o]:He.levels.push(He[o])}),He.levels.sort((n,o)=>n.level-o.level))}isLessThanOrEqualTo(e){return typeof e=="string"&&(e=He.getLevel(e)),this.level<=e.level}isGreaterThanOrEqualTo(e){return typeof e=="string"&&(e=He.getLevel(e)),this.level>=e.level}isEqualTo(e){return typeof e=="string"&&(e=He.getLevel(e)),this.level===e.level}};He.levels=[];He.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}});We.addListener(t=>{let e=t.levels;e&&(We.throwExceptionIf(t,We.not(We.anObject(e)),"levels must be an object"),Object.keys(e).forEach(n=>{We.throwExceptionIf(t,We.not(We.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),We.throwExceptionIf(t,We.not(We.anObject(e[n])),`level "${n}" must be an object`),We.throwExceptionIf(t,We.not(e[n].value),`level "${n}" must have a 'value' property`),We.throwExceptionIf(t,We.not(We.anInteger(e[n].value)),`level "${n}".value must have an integer value`),We.throwExceptionIf(t,We.not(e[n].colour),`level "${n}" must have a 'colour' property`),We.throwExceptionIf(t,We.not(dI.indexOf(e[n].colour)>-1),`level "${n}".colour must be one of ${dI.join(", ")}`)}))});We.addListener(t=>{He.addLevels(t.levels)});mI.exports=He});var II=b(fc=>{"use strict";a();var{parse:yI,stringify:bI}=JSON,{keys:Jz}=Object,uc=String,vI="string",hI={},wf="object",wI=(t,e)=>e,Yz=t=>t instanceof uc?uc(t):t,Xz=(t,e)=>typeof e===vI?new uc(e):e,xI=(t,e,r,n)=>{let o=[];for(let i=Jz(r),{length:s}=i,c=0;c{let n=uc(e.push(r)-1);return t.set(r,n),n},EI=(t,e)=>{let r=yI(t,Xz).map(Yz),n=r[0],o=e||wI,i=typeof n===wf&&n?xI(r,new Set,n,o):n;return o.call({"":i},"",i)};fc.parse=EI;var SI=(t,e,r)=>{let n=e&&typeof e===wf?(u,d)=>u===""||-1yI(SI(t));fc.toJSON=Qz;var e6=t=>EI(bI(t));fc.fromJSON=e6});var uy=b((Nle,OI)=>{a();var _I=II(),TI=fi(),ks=class{constructor(e,r,n,o,i){this.startTime=new Date,this.categoryName=e,this.data=n,this.level=r,this.context=Object.assign({},o),this.pid=process.pid,i&&(this.functionName=i.functionName,this.fileName=i.fileName,this.lineNumber=i.lineNumber,this.columnNumber=i.columnNumber,this.callStack=i.callStack)}serialise(){return _I.stringify(this,(e,r)=>(r&&r.message&&r.stack?r=Object.assign({message:r.message,stack:r.stack},r):typeof r=="number"&&(Number.isNaN(r)||!Number.isFinite(r))?r=r.toString():typeof r>"u"&&(r=typeof r),r))}static deserialise(e){let r;try{let n=_I.parse(e,(o,i)=>{if(i&&i.message&&i.stack){let s=new Error(i);Object.keys(i).forEach(c=>{s[c]=i[c]}),i=s}return i});n.location={functionName:n.functionName,fileName:n.fileName,lineNumber:n.lineNumber,columnNumber:n.columnNumber,callStack:n.callStack},r=new ks(n.categoryName,TI.getLevel(n.level.levelStr),n.data,n.context,n.location),r.startTime=new Date(n.startTime),r.pid=n.pid,r.cluster=n.cluster}catch(n){r=new ks("log4js",TI.ERROR,["Unable to parse log:",e,"because: ",n])}return r}};OI.exports=ks});var Ef=b((Ple,AI)=>{a();var fr=Xe()("log4js:clustering"),t6=uy(),r6=li(),As=!1,pr=null;try{pr=require("cluster")}catch{fr("cluster module not present"),As=!0}var py=[],dc=!1,pc="NODE_APP_INSTANCE",CI=()=>dc&&process.env[pc]==="0",fy=()=>As||pr&&pr.isMaster||CI(),kI=t=>{py.forEach(e=>e(t))},xf=(t,e)=>{if(fr("cluster message received from worker ",t,": ",e),t.topic&&t.data&&(e=t,t=void 0),e&&e.topic&&e.topic==="log4js:message"){fr("received message: ",e.data);let r=t6.deserialise(e.data);kI(r)}};As||r6.addListener(t=>{py.length=0,{pm2:dc,disableClustering:As,pm2InstanceVar:pc="NODE_APP_INSTANCE"}=t,fr(`clustering disabled ? ${As}`),fr(`cluster.isMaster ? ${pr&&pr.isMaster}`),fr(`pm2 enabled ? ${dc}`),fr(`pm2InstanceVar = ${pc}`),fr(`process.env[${pc}] = ${process.env[pc]}`),dc&&process.removeListener("message",xf),pr&&pr.removeListener&&pr.removeListener("message",xf),As||t.disableClustering?fr("Not listening for cluster messages, because clustering disabled."):CI()?(fr("listening for PM2 broadcast messages"),process.on("message",xf)):pr&&pr.isMaster?(fr("listening for cluster messages"),pr.on("message",xf)):fr("not listening for messages, because we are not a master process")});AI.exports={onlyOnMaster:(t,e)=>fy()?t():e,isMaster:fy,send:t=>{fy()?kI(t):(dc||(t.cluster={workerId:pr.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:t.serialise()}))},onMessage:t=>{py.push(t)}}});var DI=b((Mle,NI)=>{a();function n6(t){if(typeof t=="number"&&Number.isInteger(t))return t;let e={K:1024,M:1024*1024,G:1024*1024*1024},r=Object.keys(e),n=t.slice(-1).toLocaleUpperCase(),o=t.slice(0,-1).trim();if(r.indexOf(n)<0||!Number.isInteger(Number(o)))throw Error(`maxLogSize: "${t}" is invalid`);return o*e[n]}function o6(t,e){let r=Object.assign({},e);return Object.keys(t).forEach(n=>{r[n]&&(r[n]=t[n](e[n]))}),r}function dy(t){return o6({maxLogSize:n6},t)}var RI={dateFile:dy,file:dy,fileSync:dy};NI.exports.modifyConfig=t=>RI[t.type]?RI[t.type](t):t});var FI=b((Lle,PI)=>{a();var i6=console.log.bind(console);function s6(t,e){return r=>{i6(t(r,e))}}function a6(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),s6(r,t.timezoneOffset)}PI.exports.configure=a6});var $I=b(MI=>{a();function c6(t,e){return r=>{process.stdout.write(`${t(r,e)} +`)}}function l6(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),c6(r,t.timezoneOffset)}MI.configure=l6});var jI=b((zle,LI)=>{a();function u6(t,e){return r=>{process.stderr.write(`${t(r,e)} +`)}}function f6(t,e){let r=e.colouredLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),u6(r,t.timezoneOffset)}LI.exports.configure=f6});var BI=b((Wle,qI)=>{a();function p6(t,e,r,n){let o=n.getLevel(t),i=n.getLevel(e,n.FATAL);return s=>{let c=s.level;o.isLessThanOrEqualTo(c)&&i.isGreaterThanOrEqualTo(c)&&r(s)}}function d6(t,e,r,n){let o=r(t.appender);return p6(t.level,t.maxLevel,o,n)}qI.exports.configure=d6});var WI=b((Kle,UI)=>{a();var zI=Xe()("log4js:categoryFilter");function m6(t,e){return typeof t=="string"&&(t=[t]),r=>{zI(`Checking ${r.categoryName} against ${t}`),t.indexOf(r.categoryName)===-1&&(zI("Not excluded, sending to appender"),e(r))}}function h6(t,e,r){let n=r(t.appender);return m6(t.exclude,n)}UI.exports.configure=h6});var VI=b((Gle,KI)=>{a();var HI=Xe()("log4js:noLogFilter");function g6(t){return t.filter(r=>r!=null&&r!=="")}function y6(t,e){return r=>{HI(`Checking data: ${r.data} against filters: ${t}`),typeof t=="string"&&(t=[t]),t=g6(t);let n=new RegExp(t.join("|"),"i");(t.length===0||r.data.findIndex(o=>n.test(o))<0)&&(HI("Not excluded, sending to appender"),e(r))}}function b6(t,e,r){let n=r(t.appender);return y6(t.exclude,n)}KI.exports.configure=b6});var Nt=b(my=>{"use strict";a();my.fromCallback=function(t){return Object.defineProperty(function(){if(typeof arguments[arguments.length-1]=="function")t.apply(this,arguments);else return new Promise((e,r)=>{arguments[arguments.length]=(n,o)=>{if(n)return r(n);e(o)},arguments.length++,t.apply(this,arguments)})},"name",{value:t.name})};my.fromPromise=function(t){return Object.defineProperty(function(){let e=arguments[arguments.length-1];if(typeof e!="function")return t.apply(this,arguments);t.apply(this,arguments).then(r=>e(null,r),e)},"name",{value:t.name})}});var ZI=b((Xle,GI)=>{a();var mo=require("constants"),v6=process.cwd,Sf=null,w6=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Sf||(Sf=v6.call(process)),Sf};try{process.cwd()}catch{}typeof process.chdir=="function"&&(hy=process.chdir,process.chdir=function(t){Sf=null,hy.call(process,t)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,hy));var hy;GI.exports=x6;function x6(t){mo.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\.6\.[0-2]|^v0\.5\./)&&e(t),t.lutimes||r(t),t.chown=i(t.chown),t.fchown=i(t.fchown),t.lchown=i(t.lchown),t.chmod=n(t.chmod),t.fchmod=n(t.fchmod),t.lchmod=n(t.lchmod),t.chownSync=s(t.chownSync),t.fchownSync=s(t.fchownSync),t.lchownSync=s(t.lchownSync),t.chmodSync=o(t.chmodSync),t.fchmodSync=o(t.fchmodSync),t.lchmodSync=o(t.lchmodSync),t.stat=c(t.stat),t.fstat=c(t.fstat),t.lstat=c(t.lstat),t.statSync=l(t.statSync),t.fstatSync=l(t.fstatSync),t.lstatSync=l(t.lstatSync),t.chmod&&!t.lchmod&&(t.lchmod=function(u,d,m){m&&process.nextTick(m)},t.lchmodSync=function(){}),t.chown&&!t.lchown&&(t.lchown=function(u,d,m,h){h&&process.nextTick(h)},t.lchownSync=function(){}),w6==="win32"&&(t.rename=typeof t.rename!="function"?t.rename:function(u){function d(m,h,y){var w=Date.now(),v=0;u(m,h,function x(S){if(S&&(S.code==="EACCES"||S.code==="EPERM"||S.code==="EBUSY")&&Date.now()-w<6e4){setTimeout(function(){t.stat(h,function(k,j){k&&k.code==="ENOENT"?u(m,h,x):y(S)})},v),v<100&&(v+=10);return}y&&y(S)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d}(t.rename)),t.read=typeof t.read!="function"?t.read:function(u){function d(m,h,y,w,v,x){var S;if(x&&typeof x=="function"){var k=0;S=function(j,Z,X){if(j&&j.code==="EAGAIN"&&k<10)return k++,u.call(t,m,h,y,w,v,S);x.apply(this,arguments)}}return u.call(t,m,h,y,w,v,S)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,u),d}(t.read),t.readSync=typeof t.readSync!="function"?t.readSync:function(u){return function(d,m,h,y,w){for(var v=0;;)try{return u.call(t,d,m,h,y,w)}catch(x){if(x.code==="EAGAIN"&&v<10){v++;continue}throw x}}}(t.readSync);function e(u){u.lchmod=function(d,m,h){u.open(d,mo.O_WRONLY|mo.O_SYMLINK,m,function(y,w){if(y){h&&h(y);return}u.fchmod(w,m,function(v){u.close(w,function(x){h&&h(v||x)})})})},u.lchmodSync=function(d,m){var h=u.openSync(d,mo.O_WRONLY|mo.O_SYMLINK,m),y=!0,w;try{w=u.fchmodSync(h,m),y=!1}finally{if(y)try{u.closeSync(h)}catch{}else u.closeSync(h)}return w}}function r(u){mo.hasOwnProperty("O_SYMLINK")&&u.futimes?(u.lutimes=function(d,m,h,y){u.open(d,mo.O_SYMLINK,function(w,v){if(w){y&&y(w);return}u.futimes(v,m,h,function(x){u.close(v,function(S){y&&y(x||S)})})})},u.lutimesSync=function(d,m,h){var y=u.openSync(d,mo.O_SYMLINK),w,v=!0;try{w=u.futimesSync(y,m,h),v=!1}finally{if(v)try{u.closeSync(y)}catch{}else u.closeSync(y)}return w}):u.futimes&&(u.lutimes=function(d,m,h,y){y&&process.nextTick(y)},u.lutimesSync=function(){})}function n(u){return u&&function(d,m,h){return u.call(t,d,m,function(y){f(y)&&(y=null),h&&h.apply(this,arguments)})}}function o(u){return u&&function(d,m){try{return u.call(t,d,m)}catch(h){if(!f(h))throw h}}}function i(u){return u&&function(d,m,h,y){return u.call(t,d,m,h,function(w){f(w)&&(w=null),y&&y.apply(this,arguments)})}}function s(u){return u&&function(d,m,h){try{return u.call(t,d,m,h)}catch(y){if(!f(y))throw y}}}function c(u){return u&&function(d,m,h){typeof m=="function"&&(h=m,m=null);function y(w,v){v&&(v.uid<0&&(v.uid+=4294967296),v.gid<0&&(v.gid+=4294967296)),h&&h.apply(this,arguments)}return m?u.call(t,d,m,y):u.call(t,d,y)}}function l(u){return u&&function(d,m){var h=m?u.call(t,d,m):u.call(t,d);return h&&(h.uid<0&&(h.uid+=4294967296),h.gid<0&&(h.gid+=4294967296)),h}}function f(u){if(!u||u.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(u.code==="EINVAL"||u.code==="EPERM"))}}});var XI=b((eue,YI)=>{a();var JI=require("stream").Stream;YI.exports=E6;function E6(t){return{ReadStream:e,WriteStream:r};function e(n,o){if(!(this instanceof e))return new e(n,o);JI.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,o=o||{};for(var s=Object.keys(o),c=0,l=s.length;cthis.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}t.open(this.path,this.flags,this.mode,function(u,d){if(u){i.emit("error",u),i.readable=!1;return}i.fd=d,i.emit("open",d),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);JI.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};for(var i=Object.keys(o),s=0,c=i.length;s= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=t.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var e1=b((rue,QI)=>{"use strict";a();QI.exports=I6;var S6=Object.getPrototypeOf||function(t){return t.__proto__};function I6(t){if(t===null||typeof t!="object")return t;if(t instanceof Object)var e={__proto__:S6(t)};else var e=Object.create(null);return Object.getOwnPropertyNames(t).forEach(function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}),e}});var Ke=b((oue,by)=>{a();var De=require("fs"),_6=ZI(),T6=XI(),O6=e1(),If=require("util"),lt,Tf;typeof Symbol=="function"&&typeof Symbol.for=="function"?(lt=Symbol.for("graceful-fs.queue"),Tf=Symbol.for("graceful-fs.previous")):(lt="___graceful-fs.queue",Tf="___graceful-fs.previous");function C6(){}function n1(t,e){Object.defineProperty(t,lt,{get:function(){return e}})}var pi=C6;If.debuglog?pi=If.debuglog("gfs4"):/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&(pi=function(){var t=If.format.apply(If,arguments);t="GFS4: "+t.split(/\n/).join(` +GFS4: `),console.error(t)});De[lt]||(t1=global[lt]||[],n1(De,t1),De.close=function(t){function e(r,n){return t.call(De,r,function(o){o||r1(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(e,Tf,{value:t}),e}(De.close),De.closeSync=function(t){function e(r){t.apply(De,arguments),r1()}return Object.defineProperty(e,Tf,{value:t}),e}(De.closeSync),/\bgfs4\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){pi(De[lt]),require("assert").equal(De[lt].length,0)}));var t1;global[lt]||n1(global,De[lt]);by.exports=gy(O6(De));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!De.__patched&&(by.exports=gy(De),De.__patched=!0);function gy(t){_6(t),t.gracefulify=gy,t.createReadStream=Z,t.createWriteStream=X;var e=t.readFile;t.readFile=r;function r(M,te,C){return typeof te=="function"&&(C=te,te=null),O(M,te,C);function O(T,U,F,se){return e(T,U,function(ce){ce&&(ce.code==="EMFILE"||ce.code==="ENFILE")?Rs([O,[T,U,F],ce,se||Date.now(),Date.now()]):typeof F=="function"&&F.apply(this,arguments)})}}var n=t.writeFile;t.writeFile=o;function o(M,te,C,O){return typeof C=="function"&&(O=C,C=null),T(M,te,C,O);function T(U,F,se,ce,xe){return n(U,F,se,function(fe){fe&&(fe.code==="EMFILE"||fe.code==="ENFILE")?Rs([T,[U,F,se,ce],fe,xe||Date.now(),Date.now()]):typeof ce=="function"&&ce.apply(this,arguments)})}}var i=t.appendFile;i&&(t.appendFile=s);function s(M,te,C,O){return typeof C=="function"&&(O=C,C=null),T(M,te,C,O);function T(U,F,se,ce,xe){return i(U,F,se,function(fe){fe&&(fe.code==="EMFILE"||fe.code==="ENFILE")?Rs([T,[U,F,se,ce],fe,xe||Date.now(),Date.now()]):typeof ce=="function"&&ce.apply(this,arguments)})}}var c=t.copyFile;c&&(t.copyFile=l);function l(M,te,C,O){return typeof C=="function"&&(O=C,C=0),T(M,te,C,O);function T(U,F,se,ce,xe){return c(U,F,se,function(fe){fe&&(fe.code==="EMFILE"||fe.code==="ENFILE")?Rs([T,[U,F,se,ce],fe,xe||Date.now(),Date.now()]):typeof ce=="function"&&ce.apply(this,arguments)})}}var f=t.readdir;t.readdir=d;var u=/^v[0-5]\./;function d(M,te,C){typeof te=="function"&&(C=te,te=null);var O=u.test(process.version)?function(F,se,ce,xe){return f(F,T(F,se,ce,xe))}:function(F,se,ce,xe){return f(F,se,T(F,se,ce,xe))};return O(M,te,C);function T(U,F,se,ce){return function(xe,fe){xe&&(xe.code==="EMFILE"||xe.code==="ENFILE")?Rs([O,[U,F,se],xe,ce||Date.now(),Date.now()]):(fe&&fe.sort&&fe.sort(),typeof se=="function"&&se.call(this,xe,fe))}}}if(process.version.substr(0,4)==="v0.8"){var m=T6(t);x=m.ReadStream,k=m.WriteStream}var h=t.ReadStream;h&&(x.prototype=Object.create(h.prototype),x.prototype.open=S);var y=t.WriteStream;y&&(k.prototype=Object.create(y.prototype),k.prototype.open=j),Object.defineProperty(t,"ReadStream",{get:function(){return x},set:function(M){x=M},enumerable:!0,configurable:!0}),Object.defineProperty(t,"WriteStream",{get:function(){return k},set:function(M){k=M},enumerable:!0,configurable:!0});var w=x;Object.defineProperty(t,"FileReadStream",{get:function(){return w},set:function(M){w=M},enumerable:!0,configurable:!0});var v=k;Object.defineProperty(t,"FileWriteStream",{get:function(){return v},set:function(M){v=M},enumerable:!0,configurable:!0});function x(M,te){return this instanceof x?(h.apply(this,arguments),this):x.apply(Object.create(x.prototype),arguments)}function S(){var M=this;G(M.path,M.flags,M.mode,function(te,C){te?(M.autoClose&&M.destroy(),M.emit("error",te)):(M.fd=C,M.emit("open",C),M.read())})}function k(M,te){return this instanceof k?(y.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function j(){var M=this;G(M.path,M.flags,M.mode,function(te,C){te?(M.destroy(),M.emit("error",te)):(M.fd=C,M.emit("open",C))})}function Z(M,te){return new t.ReadStream(M,te)}function X(M,te){return new t.WriteStream(M,te)}var J=t.open;t.open=G;function G(M,te,C,O){return typeof C=="function"&&(O=C,C=null),T(M,te,C,O);function T(U,F,se,ce,xe){return J(U,F,se,function(fe,I){fe&&(fe.code==="EMFILE"||fe.code==="ENFILE")?Rs([T,[U,F,se,ce],fe,xe||Date.now(),Date.now()]):typeof ce=="function"&&ce.apply(this,arguments)})}}return t}function Rs(t){pi("ENQUEUE",t[0].name,t[1]),De[lt].push(t),yy()}var _f;function r1(){for(var t=Date.now(),e=0;e2&&(De[lt][e][3]=t,De[lt][e][4]=t);yy()}function yy(){if(clearTimeout(_f),_f=void 0,De[lt].length!==0){var t=De[lt].shift(),e=t[0],r=t[1],n=t[2],o=t[3],i=t[4];if(o===void 0)pi("RETRY",e.name,r),e.apply(null,r);else if(Date.now()-o>=6e4){pi("TIMEOUT",e.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var c=Date.now()-i,l=Math.max(i-o,1),f=Math.min(l*1.2,100);c>=f?(pi("RETRY",e.name,r),e.apply(null,r.concat([o]))):De[lt].push(t)}_f===void 0&&(_f=setTimeout(yy,0))}}});var vy=b(di=>{"use strict";a();var o1=Nt().fromCallback,dr=Ke(),k6=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(t=>typeof dr[t]=="function");Object.keys(dr).forEach(t=>{t!=="promises"&&(di[t]=dr[t])});k6.forEach(t=>{di[t]=o1(dr[t])});di.exists=function(t,e){return typeof e=="function"?dr.exists(t,e):new Promise(r=>dr.exists(t,r))};di.read=function(t,e,r,n,o,i){return typeof i=="function"?dr.read(t,e,r,n,o,i):new Promise((s,c)=>{dr.read(t,e,r,n,o,(l,f,u)=>{if(l)return c(l);s({bytesRead:f,buffer:u})})})};di.write=function(t,e,...r){return typeof r[r.length-1]=="function"?dr.write(t,e,...r):new Promise((n,o)=>{dr.write(t,e,...r,(i,s,c)=>{if(i)return o(i);n({bytesWritten:s,buffer:c})})})};typeof dr.realpath.native=="function"&&(di.realpath.native=o1(dr.realpath.native))});var xy=b((cue,s1)=>{"use strict";a();var wy=require("path");function i1(t){return t=wy.normalize(wy.resolve(t)).split(wy.sep),t.length>0?t[0]:null}var A6=/[<>:"|?*]/;function R6(t){let e=i1(t);return t=t.replace(e,""),A6.test(t)}s1.exports={getRootPath:i1,invalidWin32Path:R6}});var c1=b((uue,a1)=>{"use strict";a();var N6=Ke(),Ey=require("path"),D6=xy().invalidWin32Path,P6=parseInt("0777",8);function Sy(t,e,r,n){if(typeof e=="function"?(r=e,e={}):(!e||typeof e!="object")&&(e={mode:e}),process.platform==="win32"&&D6(t)){let s=new Error(t+" contains invalid WIN32 path characters.");return s.code="EINVAL",r(s)}let o=e.mode,i=e.fs||N6;o===void 0&&(o=P6&~process.umask()),n||(n=null),r=r||function(){},t=Ey.resolve(t),i.mkdir(t,o,s=>{if(!s)return n=n||t,r(null,n);switch(s.code){case"ENOENT":if(Ey.dirname(t)===t)return r(s);Sy(Ey.dirname(t),e,(c,l)=>{c?r(c,l):Sy(t,e,r,l)});break;default:i.stat(t,(c,l)=>{c||!l.isDirectory()?r(s,n):r(null,n)});break}})}a1.exports=Sy});var u1=b((pue,l1)=>{"use strict";a();var F6=Ke(),Iy=require("path"),M6=xy().invalidWin32Path,$6=parseInt("0777",8);function _y(t,e,r){(!e||typeof e!="object")&&(e={mode:e});let n=e.mode,o=e.fs||F6;if(process.platform==="win32"&&M6(t)){let i=new Error(t+" contains invalid WIN32 path characters.");throw i.code="EINVAL",i}n===void 0&&(n=$6&~process.umask()),r||(r=null),t=Iy.resolve(t);try{o.mkdirSync(t,n),r=r||t}catch(i){if(i.code==="ENOENT"){if(Iy.dirname(t)===t)throw i;r=_y(Iy.dirname(t),e,r),_y(t,e,r)}else{let s;try{s=o.statSync(t)}catch{throw i}if(!s.isDirectory())throw i}}return r}l1.exports=_y});var Zt=b((mue,f1)=>{"use strict";a();var L6=Nt().fromCallback,Ty=L6(c1()),Oy=u1();f1.exports={mkdirs:Ty,mkdirsSync:Oy,mkdirp:Ty,mkdirpSync:Oy,ensureDir:Ty,ensureDirSync:Oy}});var Cy=b((gue,d1)=>{"use strict";a();var mt=Ke(),p1=require("os"),Of=require("path");function j6(){let t=Of.join("millis-test-sync"+Date.now().toString()+Math.random().toString().slice(2));t=Of.join(p1.tmpdir(),t);let e=new Date(1435410243862);mt.writeFileSync(t,"https://github.com/jprichardson/node-fs-extra/pull/141");let r=mt.openSync(t,"r+");return mt.futimesSync(r,e,e),mt.closeSync(r),mt.statSync(t).mtime>1435410243e3}function q6(t){let e=Of.join("millis-test"+Date.now().toString()+Math.random().toString().slice(2));e=Of.join(p1.tmpdir(),e);let r=new Date(1435410243862);mt.writeFile(e,"https://github.com/jprichardson/node-fs-extra/pull/141",n=>{if(n)return t(n);mt.open(e,"r+",(o,i)=>{if(o)return t(o);mt.futimes(i,r,r,s=>{if(s)return t(s);mt.close(i,c=>{if(c)return t(c);mt.stat(e,(l,f)=>{if(l)return t(l);t(null,f.mtime>1435410243e3)})})})})})}function B6(t){if(typeof t=="number")return Math.floor(t/1e3)*1e3;if(t instanceof Date)return new Date(Math.floor(t.getTime()/1e3)*1e3);throw new Error("fs-extra: timeRemoveMillis() unknown parameter type")}function z6(t,e,r,n){mt.open(t,"r+",(o,i)=>{if(o)return n(o);mt.futimes(i,e,r,s=>{mt.close(i,c=>{n&&n(s||c)})})})}function U6(t,e,r){let n=mt.openSync(t,"r+");return mt.futimesSync(n,e,r),mt.closeSync(n)}d1.exports={hasMillisRes:q6,hasMillisResSync:j6,timeRemoveMillis:B6,utimesMillis:z6,utimesMillisSync:U6}});var gc=b((bue,v1)=>{"use strict";a();var mr=Ke(),Dt=require("path"),m1=10,h1=5,W6=0,Ay=process.versions.node.split("."),g1=Number.parseInt(Ay[0],10),y1=Number.parseInt(Ay[1],10),H6=Number.parseInt(Ay[2],10);function mc(){if(g1>m1)return!0;if(g1===m1){if(y1>h1)return!0;if(y1===h1&&H6>=W6)return!0}return!1}function K6(t,e,r){mc()?mr.stat(t,{bigint:!0},(n,o)=>{if(n)return r(n);mr.stat(e,{bigint:!0},(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))}):mr.stat(t,(n,o)=>{if(n)return r(n);mr.stat(e,(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))})}function V6(t,e){let r,n;mc()?r=mr.statSync(t,{bigint:!0}):r=mr.statSync(t);try{mc()?n=mr.statSync(e,{bigint:!0}):n=mr.statSync(e)}catch(o){if(o.code==="ENOENT")return{srcStat:r,destStat:null};throw o}return{srcStat:r,destStat:n}}function G6(t,e,r,n){K6(t,e,(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:c}=i;return c&&c.ino&&c.dev&&c.ino===s.ino&&c.dev===s.dev?n(new Error("Source and destination must not be the same.")):s.isDirectory()&&Ry(t,e)?n(new Error(hc(t,e,r))):n(null,{srcStat:s,destStat:c})})}function Z6(t,e,r){let{srcStat:n,destStat:o}=V6(t,e);if(o&&o.ino&&o.dev&&o.ino===n.ino&&o.dev===n.dev)throw new Error("Source and destination must not be the same.");if(n.isDirectory()&&Ry(t,e))throw new Error(hc(t,e,r));return{srcStat:n,destStat:o}}function ky(t,e,r,n,o){let i=Dt.resolve(Dt.dirname(t)),s=Dt.resolve(Dt.dirname(r));if(s===i||s===Dt.parse(s).root)return o();mc()?mr.stat(s,{bigint:!0},(c,l)=>c?c.code==="ENOENT"?o():o(c):l.ino&&l.dev&&l.ino===e.ino&&l.dev===e.dev?o(new Error(hc(t,r,n))):ky(t,e,s,n,o)):mr.stat(s,(c,l)=>c?c.code==="ENOENT"?o():o(c):l.ino&&l.dev&&l.ino===e.ino&&l.dev===e.dev?o(new Error(hc(t,r,n))):ky(t,e,s,n,o))}function b1(t,e,r,n){let o=Dt.resolve(Dt.dirname(t)),i=Dt.resolve(Dt.dirname(r));if(i===o||i===Dt.parse(i).root)return;let s;try{mc()?s=mr.statSync(i,{bigint:!0}):s=mr.statSync(i)}catch(c){if(c.code==="ENOENT")return;throw c}if(s.ino&&s.dev&&s.ino===e.ino&&s.dev===e.dev)throw new Error(hc(t,r,n));return b1(t,e,i,n)}function Ry(t,e){let r=Dt.resolve(t).split(Dt.sep).filter(o=>o),n=Dt.resolve(e).split(Dt.sep).filter(o=>o);return r.reduce((o,i,s)=>o&&n[s]===i,!0)}function hc(t,e,r){return`Cannot ${r} '${t}' to a subdirectory of itself, '${e}'.`}v1.exports={checkPaths:G6,checkPathsSync:Z6,checkParentPaths:ky,checkParentPathsSync:b1,isSrcSubdir:Ry}});var x1=b((wue,w1)=>{"use strict";a();w1.exports=function(t){if(typeof Buffer.allocUnsafe=="function")try{return Buffer.allocUnsafe(t)}catch{return new Buffer(t)}return new Buffer(t)}});var T1=b((Eue,_1)=>{"use strict";a();var Re=Ke(),yc=require("path"),J6=Zt().mkdirsSync,Y6=Cy().utimesMillisSync,bc=gc();function X6(t,e,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; - see https://github.com/jprichardson/node-fs-extra/issues/269`);let{srcStat:n,destStat:o}=ul.checkPathsSync(t,e,"copy");return ul.checkParentPathsSync(t,n,e,"copy"),k6(o,t,e,r)}function k6(t,e,r,n){if(n.filter&&!n.filter(e,r))return;let o=cl.dirname(r);return Ce.existsSync(o)||T6(o),cI(t,e,r,n)}function cI(t,e,r,n){if(!(n.filter&&!n.filter(e,r)))return R6(t,e,r,n)}function R6(t,e,r,n){let i=(n.dereference?Ce.statSync:Ce.lstatSync)(e);if(i.isDirectory())return P6(i,t,e,r,n);if(i.isFile()||i.isCharacterDevice()||i.isBlockDevice())return N6(i,t,e,r,n);if(i.isSymbolicLink())return L6(t,e,r,n)}function N6(t,e,r,n,o){return e?D6(t,r,n,o):uI(t,r,n,o)}function D6(t,e,r,n){if(n.overwrite)return Ce.unlinkSync(r),uI(t,e,r,n);if(n.errorOnExist)throw new Error(`'${r}' already exists`)}function uI(t,e,r,n){return typeof Ce.copyFileSync=="function"?(Ce.copyFileSync(e,r),Ce.chmodSync(r,t.mode),n.preserveTimestamps?C6(r,t.atime,t.mtime):void 0):F6(t,e,r,n)}function F6(t,e,r,n){let i=lI()(65536),s=Ce.openSync(e,"r"),a=Ce.openSync(r,"w",t.mode),l=0;for(;l$6(n,t,e,r))}function $6(t,e,r,n){let o=cl.join(e,t),i=cl.join(r,t),{destStat:s}=ul.checkPathsSync(o,i,"copy");return cI(s,o,i,n)}function L6(t,e,r,n){let o=Ce.readlinkSync(e);if(n.dereference&&(o=cl.resolve(process.cwd(),o)),t){let i;try{i=Ce.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return Ce.symlinkSync(o,r);throw s}if(n.dereference&&(i=cl.resolve(process.cwd(),i)),ul.isSrcSubdir(o,i))throw new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`);if(Ce.statSync(r).isDirectory()&&ul.isSrcSubdir(i,o))throw new Error(`Cannot overwrite '${i}' with '${o}'.`);return j6(o,r)}else return Ce.symlinkSync(o,r)}function j6(t,e){return Ce.unlinkSync(e),Ce.symlinkSync(t,e)}pI.exports=A6});var wy=g((lfe,mI)=>{"use strict";mI.exports={copySync:dI()}});var Zr=g((cfe,gI)=>{"use strict";var q6=At().fromPromise,hI=ay();function B6(t){return hI.access(t).then(()=>!0).catch(()=>!1)}gI.exports={pathExists:q6(B6),pathExistsSync:hI.existsSync}});var _I=g((ufe,II)=>{"use strict";var at=Ue(),fl=require("path"),z6=Ht().mkdirs,U6=Zr().pathExists,W6=gy().utimesMillis,pl=ll();function H6(t,e,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; + see https://github.com/jprichardson/node-fs-extra/issues/269`);let{srcStat:n,destStat:o}=bc.checkPathsSync(t,e,"copy");return bc.checkParentPathsSync(t,n,e,"copy"),Q6(o,t,e,r)}function Q6(t,e,r,n){if(n.filter&&!n.filter(e,r))return;let o=yc.dirname(r);return Re.existsSync(o)||J6(o),E1(t,e,r,n)}function E1(t,e,r,n){if(!(n.filter&&!n.filter(e,r)))return e9(t,e,r,n)}function e9(t,e,r,n){let i=(n.dereference?Re.statSync:Re.lstatSync)(e);if(i.isDirectory())return o9(i,t,e,r,n);if(i.isFile()||i.isCharacterDevice()||i.isBlockDevice())return t9(i,t,e,r,n);if(i.isSymbolicLink())return a9(t,e,r,n)}function t9(t,e,r,n,o){return e?r9(t,r,n,o):S1(t,r,n,o)}function r9(t,e,r,n){if(n.overwrite)return Re.unlinkSync(r),S1(t,e,r,n);if(n.errorOnExist)throw new Error(`'${r}' already exists`)}function S1(t,e,r,n){return typeof Re.copyFileSync=="function"?(Re.copyFileSync(e,r),Re.chmodSync(r,t.mode),n.preserveTimestamps?Y6(r,t.atime,t.mtime):void 0):n9(t,e,r,n)}function n9(t,e,r,n){let i=x1()(65536),s=Re.openSync(e,"r"),c=Re.openSync(r,"w",t.mode),l=0;for(;ls9(n,t,e,r))}function s9(t,e,r,n){let o=yc.join(e,t),i=yc.join(r,t),{destStat:s}=bc.checkPathsSync(o,i,"copy");return E1(s,o,i,n)}function a9(t,e,r,n){let o=Re.readlinkSync(e);if(n.dereference&&(o=yc.resolve(process.cwd(),o)),t){let i;try{i=Re.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return Re.symlinkSync(o,r);throw s}if(n.dereference&&(i=yc.resolve(process.cwd(),i)),bc.isSrcSubdir(o,i))throw new Error(`Cannot copy '${o}' to a subdirectory of itself, '${i}'.`);if(Re.statSync(r).isDirectory()&&bc.isSrcSubdir(i,o))throw new Error(`Cannot overwrite '${i}' with '${o}'.`);return c9(o,r)}else return Re.symlinkSync(o,r)}function c9(t,e){return Re.unlinkSync(e),Re.symlinkSync(t,e)}_1.exports=X6});var Ny=b((Iue,O1)=>{"use strict";a();O1.exports={copySync:T1()}});var Xr=b((Tue,k1)=>{"use strict";a();var l9=Nt().fromPromise,C1=vy();function u9(t){return C1.access(t).then(()=>!0).catch(()=>!1)}k1.exports={pathExists:l9(u9),pathExistsSync:C1.existsSync}});var L1=b((Cue,$1)=>{"use strict";a();var ut=Ke(),vc=require("path"),f9=Zt().mkdirs,p9=Xr().pathExists,d9=Cy().utimesMillis,wc=gc();function m9(t,e,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended; - see https://github.com/jprichardson/node-fs-extra/issues/269`),pl.checkPaths(t,e,"copy",(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;pl.checkParentPaths(t,s,e,"copy",l=>l?n(l):r.filter?vI(yI,a,t,e,r,n):yI(a,t,e,r,n))})}function yI(t,e,r,n,o){let i=fl.dirname(r);U6(i,(s,a)=>{if(s)return o(s);if(a)return xy(t,e,r,n,o);z6(i,l=>l?o(l):xy(t,e,r,n,o))})}function vI(t,e,r,n,o,i){Promise.resolve(o.filter(r,n)).then(s=>s?t(e,r,n,o,i):i(),s=>i(s))}function xy(t,e,r,n,o){return n.filter?vI(bI,t,e,r,n,o):bI(t,e,r,n,o)}function bI(t,e,r,n,o){(n.dereference?at.stat:at.lstat)(e,(s,a)=>{if(s)return o(s);if(a.isDirectory())return Z6(a,t,e,r,n,o);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return K6(a,t,e,r,n,o);if(a.isSymbolicLink())return X6(t,e,r,n,o)})}function K6(t,e,r,n,o,i){return e?V6(t,r,n,o,i):wI(t,r,n,o,i)}function V6(t,e,r,n,o){if(n.overwrite)at.unlink(r,i=>i?o(i):wI(t,e,r,n,o));else return n.errorOnExist?o(new Error(`'${r}' already exists`)):o()}function wI(t,e,r,n,o){return typeof at.copyFile=="function"?at.copyFile(e,r,i=>i?o(i):xI(t,r,n,o)):G6(t,e,r,n,o)}function G6(t,e,r,n,o){let i=at.createReadStream(e);i.on("error",s=>o(s)).once("open",()=>{let s=at.createWriteStream(r,{mode:t.mode});s.on("error",a=>o(a)).on("open",()=>i.pipe(s)).once("close",()=>xI(t,r,n,o))})}function xI(t,e,r,n){at.chmod(e,t.mode,o=>o?n(o):r.preserveTimestamps?W6(e,t.atime,t.mtime,n):n())}function Z6(t,e,r,n,o,i){return e?e&&!e.isDirectory()?i(new Error(`Cannot overwrite non-directory '${n}' with directory '${r}'.`)):EI(r,n,o,i):J6(t,r,n,o,i)}function J6(t,e,r,n,o){at.mkdir(r,i=>{if(i)return o(i);EI(e,r,n,s=>s?o(s):at.chmod(r,t.mode,o))})}function EI(t,e,r,n){at.readdir(t,(o,i)=>o?n(o):SI(i,t,e,r,n))}function SI(t,e,r,n,o){let i=t.pop();return i?Y6(t,i,e,r,n,o):o()}function Y6(t,e,r,n,o,i){let s=fl.join(r,e),a=fl.join(n,e);pl.checkPaths(s,a,"copy",(l,u)=>{if(l)return i(l);let{destStat:c}=u;xy(c,s,a,o,f=>f?i(f):SI(t,r,n,o,i))})}function X6(t,e,r,n,o){at.readlink(e,(i,s)=>{if(i)return o(i);if(n.dereference&&(s=fl.resolve(process.cwd(),s)),t)at.readlink(r,(a,l)=>a?a.code==="EINVAL"||a.code==="UNKNOWN"?at.symlink(s,r,o):o(a):(n.dereference&&(l=fl.resolve(process.cwd(),l)),pl.isSrcSubdir(s,l)?o(new Error(`Cannot copy '${s}' to a subdirectory of itself, '${l}'.`)):t.isDirectory()&&pl.isSrcSubdir(l,s)?o(new Error(`Cannot overwrite '${l}' with '${s}'.`)):Q6(s,r,o)));else return at.symlink(s,r,o)})}function Q6(t,e,r){at.unlink(e,n=>n?r(n):at.symlink(t,e,r))}II.exports=H6});var Ey=g((ffe,OI)=>{"use strict";var e4=At().fromCallback;OI.exports={copy:e4(_I())}});var PI=g((pfe,FI)=>{"use strict";var TI=Ue(),RI=require("path"),he=require("assert"),dl=process.platform==="win32";function NI(t){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(r=>{t[r]=t[r]||TI[r],r=r+"Sync",t[r]=t[r]||TI[r]}),t.maxBusyTries=t.maxBusyTries||3}function Sy(t,e,r){let n=0;typeof e=="function"&&(r=e,e={}),he(t,"rimraf: missing path"),he.strictEqual(typeof t,"string","rimraf: path should be a string"),he.strictEqual(typeof r,"function","rimraf: callback function required"),he(e,"rimraf: invalid options argument provided"),he.strictEqual(typeof e,"object","rimraf: options should be object"),NI(e),CI(t,e,function o(i){if(i){if((i.code==="EBUSY"||i.code==="ENOTEMPTY"||i.code==="EPERM")&&nCI(t,e,o),s)}i.code==="ENOENT"&&(i=null)}r(i)})}function CI(t,e,r){he(t),he(e),he(typeof r=="function"),e.lstat(t,(n,o)=>{if(n&&n.code==="ENOENT")return r(null);if(n&&n.code==="EPERM"&&dl)return AI(t,e,n,r);if(o&&o.isDirectory())return xf(t,e,n,r);e.unlink(t,i=>{if(i){if(i.code==="ENOENT")return r(null);if(i.code==="EPERM")return dl?AI(t,e,i,r):xf(t,e,i,r);if(i.code==="EISDIR")return xf(t,e,i,r)}return r(i)})})}function AI(t,e,r,n){he(t),he(e),he(typeof n=="function"),r&&he(r instanceof Error),e.chmod(t,438,o=>{o?n(o.code==="ENOENT"?null:r):e.stat(t,(i,s)=>{i?n(i.code==="ENOENT"?null:r):s.isDirectory()?xf(t,e,r,n):e.unlink(t,n)})})}function kI(t,e,r){let n;he(t),he(e),r&&he(r instanceof Error);try{e.chmodSync(t,438)}catch(o){if(o.code==="ENOENT")return;throw r}try{n=e.statSync(t)}catch(o){if(o.code==="ENOENT")return;throw r}n.isDirectory()?Ef(t,e,r):e.unlinkSync(t)}function xf(t,e,r,n){he(t),he(e),r&&he(r instanceof Error),he(typeof n=="function"),e.rmdir(t,o=>{o&&(o.code==="ENOTEMPTY"||o.code==="EEXIST"||o.code==="EPERM")?t4(t,e,n):o&&o.code==="ENOTDIR"?n(r):n(o)})}function t4(t,e,r){he(t),he(e),he(typeof r=="function"),e.readdir(t,(n,o)=>{if(n)return r(n);let i=o.length,s;if(i===0)return e.rmdir(t,r);o.forEach(a=>{Sy(RI.join(t,a),e,l=>{if(!s){if(l)return r(s=l);--i===0&&e.rmdir(t,r)}})})})}function DI(t,e){let r;e=e||{},NI(e),he(t,"rimraf: missing path"),he.strictEqual(typeof t,"string","rimraf: path should be a string"),he(e,"rimraf: missing options"),he.strictEqual(typeof e,"object","rimraf: options should be object");try{r=e.lstatSync(t)}catch(n){if(n.code==="ENOENT")return;n.code==="EPERM"&&dl&&kI(t,e,n)}try{r&&r.isDirectory()?Ef(t,e,null):e.unlinkSync(t)}catch(n){if(n.code==="ENOENT")return;if(n.code==="EPERM")return dl?kI(t,e,n):Ef(t,e,n);if(n.code!=="EISDIR")throw n;Ef(t,e,n)}}function Ef(t,e,r){he(t),he(e),r&&he(r instanceof Error);try{e.rmdirSync(t)}catch(n){if(n.code==="ENOTDIR")throw r;if(n.code==="ENOTEMPTY"||n.code==="EEXIST"||n.code==="EPERM")r4(t,e);else if(n.code!=="ENOENT")throw n}}function r4(t,e){if(he(t),he(e),e.readdirSync(t).forEach(r=>DI(RI.join(t,r),e)),dl){let r=Date.now();do try{return e.rmdirSync(t,e)}catch{}while(Date.now()-r<500)}else return e.rmdirSync(t,e)}FI.exports=Sy;Sy.sync=DI});var ml=g((dfe,$I)=>{"use strict";var n4=At().fromCallback,MI=PI();$I.exports={remove:n4(MI),removeSync:MI.sync}});var HI=g((mfe,WI)=>{"use strict";var o4=At().fromCallback,qI=Ue(),BI=require("path"),zI=Ht(),UI=ml(),LI=o4(function(e,r){r=r||function(){},qI.readdir(e,(n,o)=>{if(n)return zI.mkdirs(e,r);o=o.map(s=>BI.join(e,s)),i();function i(){let s=o.pop();if(!s)return r();UI.remove(s,a=>{if(a)return r(a);i()})}})});function jI(t){let e;try{e=qI.readdirSync(t)}catch{return zI.mkdirsSync(t)}e.forEach(r=>{r=BI.join(t,r),UI.removeSync(r)})}WI.exports={emptyDirSync:jI,emptydirSync:jI,emptyDir:LI,emptydir:LI}});var ZI=g((hfe,GI)=>{"use strict";var i4=At().fromCallback,KI=require("path"),hl=Ue(),VI=Ht(),s4=Zr().pathExists;function a4(t,e){function r(){hl.writeFile(t,"",n=>{if(n)return e(n);e()})}hl.stat(t,(n,o)=>{if(!n&&o.isFile())return e();let i=KI.dirname(t);s4(i,(s,a)=>{if(s)return e(s);if(a)return r();VI.mkdirs(i,l=>{if(l)return e(l);r()})})})}function l4(t){let e;try{e=hl.statSync(t)}catch{}if(e&&e.isFile())return;let r=KI.dirname(t);hl.existsSync(r)||VI.mkdirsSync(r),hl.writeFileSync(t,"")}GI.exports={createFile:i4(a4),createFileSync:l4}});var e_=g((gfe,QI)=>{"use strict";var c4=At().fromCallback,YI=require("path"),ui=Ue(),XI=Ht(),JI=Zr().pathExists;function u4(t,e,r){function n(o,i){ui.link(o,i,s=>{if(s)return r(s);r(null)})}JI(e,(o,i)=>{if(o)return r(o);if(i)return r(null);ui.lstat(t,s=>{if(s)return s.message=s.message.replace("lstat","ensureLink"),r(s);let a=YI.dirname(e);JI(a,(l,u)=>{if(l)return r(l);if(u)return n(t,e);XI.mkdirs(a,c=>{if(c)return r(c);n(t,e)})})})})}function f4(t,e){if(ui.existsSync(e))return;try{ui.lstatSync(t)}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}let n=YI.dirname(e);return ui.existsSync(n)||XI.mkdirsSync(n),ui.linkSync(t,e)}QI.exports={createLink:c4(u4),createLinkSync:f4}});var r_=g((yfe,t_)=>{"use strict";var fo=require("path"),gl=Ue(),p4=Zr().pathExists;function d4(t,e,r){if(fo.isAbsolute(t))return gl.lstat(t,n=>n?(n.message=n.message.replace("lstat","ensureSymlink"),r(n)):r(null,{toCwd:t,toDst:t}));{let n=fo.dirname(e),o=fo.join(n,t);return p4(o,(i,s)=>i?r(i):s?r(null,{toCwd:o,toDst:t}):gl.lstat(t,a=>a?(a.message=a.message.replace("lstat","ensureSymlink"),r(a)):r(null,{toCwd:t,toDst:fo.relative(n,t)})))}}function m4(t,e){let r;if(fo.isAbsolute(t)){if(r=gl.existsSync(t),!r)throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}else{let n=fo.dirname(e),o=fo.join(n,t);if(r=gl.existsSync(o),r)return{toCwd:o,toDst:t};if(r=gl.existsSync(t),!r)throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:fo.relative(n,t)}}}t_.exports={symlinkPaths:d4,symlinkPathsSync:m4}});var i_=g((bfe,o_)=>{"use strict";var n_=Ue();function h4(t,e,r){if(r=typeof e=="function"?e:r,e=typeof e=="function"?!1:e,e)return r(null,e);n_.lstat(t,(n,o)=>{if(n)return r(null,"file");e=o&&o.isDirectory()?"dir":"file",r(null,e)})}function g4(t,e){let r;if(e)return e;try{r=n_.lstatSync(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}o_.exports={symlinkType:h4,symlinkTypeSync:g4}});var p_=g((vfe,f_)=>{"use strict";var y4=At().fromCallback,a_=require("path"),Os=Ue(),l_=Ht(),b4=l_.mkdirs,v4=l_.mkdirsSync,c_=r_(),w4=c_.symlinkPaths,x4=c_.symlinkPathsSync,u_=i_(),E4=u_.symlinkType,S4=u_.symlinkTypeSync,s_=Zr().pathExists;function I4(t,e,r,n){n=typeof r=="function"?r:n,r=typeof r=="function"?!1:r,s_(e,(o,i)=>{if(o)return n(o);if(i)return n(null);w4(t,e,(s,a)=>{if(s)return n(s);t=a.toDst,E4(a.toCwd,r,(l,u)=>{if(l)return n(l);let c=a_.dirname(e);s_(c,(f,p)=>{if(f)return n(f);if(p)return Os.symlink(t,e,u,n);b4(c,d=>{if(d)return n(d);Os.symlink(t,e,u,n)})})})})})}function _4(t,e,r){if(Os.existsSync(e))return;let o=x4(t,e);t=o.toDst,r=S4(o.toCwd,r);let i=a_.dirname(e);return Os.existsSync(i)||v4(i),Os.symlinkSync(t,e,r)}f_.exports={createSymlink:y4(I4),createSymlinkSync:_4}});var m_=g((wfe,d_)=>{"use strict";var Sf=ZI(),If=e_(),_f=p_();d_.exports={createFile:Sf.createFile,createFileSync:Sf.createFileSync,ensureFile:Sf.createFile,ensureFileSync:Sf.createFileSync,createLink:If.createLink,createLinkSync:If.createLinkSync,ensureLink:If.createLink,ensureLinkSync:If.createLinkSync,createSymlink:_f.createSymlink,createSymlinkSync:_f.createSymlinkSync,ensureSymlink:_f.createSymlink,ensureSymlinkSync:_f.createSymlinkSync}});var b_=g((xfe,y_)=>{var Ts;try{Ts=Ue()}catch{Ts=require("fs")}function O4(t,e,r){r==null&&(r=e,e={}),typeof e=="string"&&(e={encoding:e}),e=e||{};var n=e.fs||Ts,o=!0;"throws"in e&&(o=e.throws),n.readFile(t,e,function(i,s){if(i)return r(i);s=g_(s);var a;try{a=JSON.parse(s,e?e.reviver:null)}catch(l){return o?(l.message=t+": "+l.message,r(l)):r(null,null)}r(null,a)})}function T4(t,e){e=e||{},typeof e=="string"&&(e={encoding:e});var r=e.fs||Ts,n=!0;"throws"in e&&(n=e.throws);try{var o=r.readFileSync(t,e);return o=g_(o),JSON.parse(o,e.reviver)}catch(i){if(n)throw i.message=t+": "+i.message,i;return null}}function h_(t,e){var r,n=` -`;typeof e=="object"&&e!==null&&(e.spaces&&(r=e.spaces),e.EOL&&(n=e.EOL));var o=JSON.stringify(t,e?e.replacer:null,r);return o.replace(/\n/g,n)+n}function C4(t,e,r,n){n==null&&(n=r,r={}),r=r||{};var o=r.fs||Ts,i="";try{i=h_(e,r)}catch(s){n&&n(s,null);return}o.writeFile(t,i,r,n)}function A4(t,e,r){r=r||{};var n=r.fs||Ts,o=h_(e,r);return n.writeFileSync(t,o,r)}function g_(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t=t.replace(/^\uFEFF/,""),t}var k4={readFile:O4,readFileSync:T4,writeFile:C4,writeFileSync:A4};y_.exports=k4});var Tf=g((Efe,w_)=>{"use strict";var v_=At().fromCallback,Of=b_();w_.exports={readJson:v_(Of.readFile),readJsonSync:Of.readFileSync,writeJson:v_(Of.writeFile),writeJsonSync:Of.writeFileSync}});var S_=g((Sfe,E_)=>{"use strict";var R4=require("path"),N4=Ht(),D4=Zr().pathExists,x_=Tf();function F4(t,e,r,n){typeof r=="function"&&(n=r,r={});let o=R4.dirname(t);D4(o,(i,s)=>{if(i)return n(i);if(s)return x_.writeJson(t,e,r,n);N4.mkdirs(o,a=>{if(a)return n(a);x_.writeJson(t,e,r,n)})})}E_.exports=F4});var __=g((Ife,I_)=>{"use strict";var P4=Ue(),M4=require("path"),$4=Ht(),L4=Tf();function j4(t,e,r){let n=M4.dirname(t);P4.existsSync(n)||$4.mkdirsSync(n),L4.writeJsonSync(t,e,r)}I_.exports=j4});var T_=g((_fe,O_)=>{"use strict";var q4=At().fromCallback,vt=Tf();vt.outputJson=q4(S_());vt.outputJsonSync=__();vt.outputJSON=vt.outputJson;vt.outputJSONSync=vt.outputJsonSync;vt.writeJSON=vt.writeJson;vt.writeJSONSync=vt.writeJsonSync;vt.readJSON=vt.readJson;vt.readJSONSync=vt.readJsonSync;O_.exports=vt});var D_=g((Ofe,N_)=>{"use strict";var k_=Ue(),B4=require("path"),z4=wy().copySync,R_=ml().removeSync,U4=Ht().mkdirpSync,C_=ll();function W4(t,e,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:o}=C_.checkPathsSync(t,e,"move");return C_.checkParentPathsSync(t,o,e,"move"),U4(B4.dirname(e)),H4(t,e,n)}function H4(t,e,r){if(r)return R_(e),A_(t,e,r);if(k_.existsSync(e))throw new Error("dest already exists.");return A_(t,e,r)}function A_(t,e,r){try{k_.renameSync(t,e)}catch(n){if(n.code!=="EXDEV")throw n;return K4(t,e,r)}}function K4(t,e,r){return z4(t,e,{overwrite:r,errorOnExist:!0}),R_(t)}N_.exports=W4});var P_=g((Tfe,F_)=>{"use strict";F_.exports={moveSync:D_()}});var q_=g((Cfe,j_)=>{"use strict";var V4=Ue(),G4=require("path"),Z4=Ey().copy,L_=ml().remove,J4=Ht().mkdirp,Y4=Zr().pathExists,M_=ll();function X4(t,e,r,n){typeof r=="function"&&(n=r,r={});let o=r.overwrite||r.clobber||!1;M_.checkPaths(t,e,"move",(i,s)=>{if(i)return n(i);let{srcStat:a}=s;M_.checkParentPaths(t,a,e,"move",l=>{if(l)return n(l);J4(G4.dirname(e),u=>u?n(u):Q4(t,e,o,n))})})}function Q4(t,e,r,n){if(r)return L_(e,o=>o?n(o):$_(t,e,r,n));Y4(e,(o,i)=>o?n(o):i?n(new Error("dest already exists.")):$_(t,e,r,n))}function $_(t,e,r,n){V4.rename(t,e,o=>o?o.code!=="EXDEV"?n(o):e9(t,e,r,n):n())}function e9(t,e,r,n){Z4(t,e,{overwrite:r,errorOnExist:!0},i=>i?n(i):L_(t,n))}j_.exports=X4});var z_=g((Afe,B_)=>{"use strict";var t9=At().fromCallback;B_.exports={move:t9(q_())}});var K_=g((kfe,H_)=>{"use strict";var r9=At().fromCallback,yl=Ue(),U_=require("path"),W_=Ht(),n9=Zr().pathExists;function o9(t,e,r,n){typeof r=="function"&&(n=r,r="utf8");let o=U_.dirname(t);n9(o,(i,s)=>{if(i)return n(i);if(s)return yl.writeFile(t,e,r,n);W_.mkdirs(o,a=>{if(a)return n(a);yl.writeFile(t,e,r,n)})})}function i9(t,...e){let r=U_.dirname(t);if(yl.existsSync(r))return yl.writeFileSync(t,...e);W_.mkdirsSync(r),yl.writeFileSync(t,...e)}H_.exports={outputFile:r9(o9),outputFileSync:i9}});var _y=g((Rfe,Iy)=>{"use strict";Iy.exports=Object.assign({},ay(),wy(),Ey(),HI(),m_(),T_(),Ht(),P_(),z_(),K_(),Zr(),ml());var V_=require("fs");Object.getOwnPropertyDescriptor(V_,"promises")&&Object.defineProperty(Iy.exports,"promises",{get(){return V_.promises}})});var Z_=g((Nfe,G_)=>{G_.exports=()=>new Date});var Y_=g((Dfe,J_)=>{var s9=Ze()("streamroller:fileNameFormatter"),a9=require("path"),l9=".gz",c9=".";J_.exports=({file:t,keepFileExt:e,needsIndex:r,alwaysIncludeDate:n,compress:o,fileNameSep:i})=>{let s=i||c9,a=a9.join(t.dir,t.name),l=d=>d+t.ext,u=(d,h,b)=>(r||!b)&&h?d+s+h:d,c=(d,h,b)=>(h>0||n)&&b?d+s+b:d,f=(d,h)=>h&&o?d+l9:d,p=e?[c,u,l,f]:[l,c,u,f];return({date:d,index:h})=>(s9(`_formatFileName: date=${d}, index=${h}`),p.reduce((b,y)=>y(b,h,d),a))}});var tO=g((Ffe,eO)=>{var fi=Ze()("streamroller:fileNameParser"),X_=".gz",Q_=ff(),u9=".";eO.exports=({file:t,keepFileExt:e,pattern:r,fileNameSep:n})=>{let o=n||u9,i=(p,d)=>p.endsWith(X_)?(fi("it is gzipped"),d.isCompressed=!0,p.slice(0,-1*X_.length)):p,s="__NOT_MATCHING__",f=[i,e?p=>p.startsWith(t.name)&&p.endsWith(t.ext)?(fi("it starts and ends with the right things"),p.slice(t.name.length+1,-1*t.ext.length)):s:p=>p.startsWith(t.base)?(fi("it starts with the right things"),p.slice(t.base.length+1)):s,r?(p,d)=>{let h=p.split(o),b=h[h.length-1];fi("items: ",h,", indexStr: ",b);let y=p;b!==void 0&&b.match(/^\d+$/)?(y=p.slice(0,-1*(b.length+1)),fi(`dateStr is ${y}`),r&&!y&&(y=b,b="0")):b="0";try{let v=Q_.parse(r,y,new Date(0,0));return Q_.asString(r,v)!==y?p:(d.index=parseInt(b,10),d.date=y,d.timestamp=v.getTime(),"")}catch(v){return fi(`Problem parsing ${y} as ${r}, error was: `,v),p}}:(p,d)=>p.match(/^\d+$/)?(fi("it has an index"),d.index=parseInt(p,10),""):p];return p=>{let d={filename:p,index:0,isCompressed:!1};return f.reduce((b,y)=>y(b,d),p)?null:d}}});var nO=g((Pfe,rO)=>{var Rt=Ze()("streamroller:moveAndMaybeCompressFile"),In=_y(),f9=require("zlib"),p9=function(t){let e={mode:parseInt("0600",8),compress:!1},r=Object.assign({},e,t);return Rt(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(r)}`),r},d9=async(t,e,r)=>{if(r=p9(r),t===e){Rt("moveAndMaybeCompressFile: source and target are the same, not doing anything");return}if(await In.pathExists(t))if(Rt(`moveAndMaybeCompressFile: moving file from ${t} to ${e} ${r.compress?"with":"without"} compress`),r.compress)await new Promise((n,o)=>{let i=!1,s=In.createWriteStream(e,{mode:r.mode,flags:"wx"}).on("open",()=>{i=!0;let a=In.createReadStream(t).on("open",()=>{a.pipe(f9.createGzip()).pipe(s)}).on("error",l=>{Rt(`moveAndMaybeCompressFile: error reading ${t}`,l),s.destroy(l)})}).on("finish",()=>{Rt(`moveAndMaybeCompressFile: finished compressing ${e}, deleting ${t}`),In.unlink(t).then(n).catch(a=>{Rt(`moveAndMaybeCompressFile: error deleting ${t}, truncating instead`,a),In.truncate(t).then(n).catch(l=>{Rt(`moveAndMaybeCompressFile: error truncating ${t}`,l),o(l)})})}).on("error",a=>{i?(Rt(`moveAndMaybeCompressFile: error writing ${e}, deleting`,a),In.unlink(e).then(()=>{o(a)}).catch(l=>{Rt(`moveAndMaybeCompressFile: error deleting ${e}`,l),o(l)})):(Rt(`moveAndMaybeCompressFile: error creating ${e}`,a),o(a))})}).catch(()=>{});else{Rt(`moveAndMaybeCompressFile: renaming ${t} to ${e}`);try{await In.move(t,e,{overwrite:!0})}catch(n){if(Rt(`moveAndMaybeCompressFile: error renaming ${t} to ${e}`,n),n.code!=="ENOENT"){Rt("moveAndMaybeCompressFile: trying copy+truncate instead");try{await In.copy(t,e,{overwrite:!0}),await In.truncate(t)}catch(o){Rt("moveAndMaybeCompressFile: error copy+truncate",o)}}}}};rO.exports=d9});var kf=g((Mfe,oO)=>{var Kt=Ze()("streamroller:RollingFileWriteStream"),di=_y(),pi=require("path"),m9=require("os"),Cf=Z_(),Af=ff(),{Writable:h9}=require("stream"),g9=Y_(),y9=tO(),b9=nO(),v9=t=>(Kt(`deleteFiles: files to delete: ${t}`),Promise.all(t.map(e=>di.unlink(e).catch(r=>{Kt(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${r}`)})))),Oy=class extends h9{constructor(e,r){if(Kt(`constructor: creating RollingFileWriteStream. path=${e}`),typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(pi.sep))throw new Error(`Filename is a directory: ${e}`);e.indexOf(`~${pi.sep}`)===0&&(e=e.replace("~",m9.homedir())),super(r),this.options=this._parseOption(r),this.fileObject=pi.parse(e),this.fileObject.dir===""&&(this.fileObject=pi.parse(pi.join(process.cwd(),e))),this.fileFormatter=g9({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`);if(n.numBackups||n.numBackups===0){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return Kt(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,r,n){this._shouldRoll().then(()=>{Kt(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,r,o=>{this.state.currentSize+=e.length,n(o)})})}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(Kt(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==Af(this.options.pattern,Cf())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return Kt("_roll: closing the current stream"),new Promise((e,r)=>{this.currentFileStream.end("",this.options.encoding,()=>{this._moveOldFiles().then(e).catch(r)})})}async _moveOldFiles(){let e=await this._getExistingFiles(),r=this.state.currentDate?e.filter(n=>n.date===this.state.currentDate):e;for(let n=r.length;n>=0;n--){Kt(`_moveOldFiles: i = ${n}`);let o=this.fileFormatter({date:this.state.currentDate,index:n}),i=this.fileFormatter({date:this.state.currentDate,index:n+1}),s={compress:this.options.compress&&n===0,mode:this.options.mode};await b9(o,i,s)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?Af(this.options.pattern,Cf()):null,Kt(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise((n,o)=>{this.currentFileStream.write("","utf8",()=>{this._clean().then(n).catch(o)})})}async _getExistingFiles(){let e=await di.readdir(this.fileObject.dir).catch(()=>[]);Kt(`_getExistingFiles: files=${e}`);let r=e.map(o=>this.fileNameParser(o)).filter(o=>o),n=o=>(o.timestamp?o.timestamp:Cf().getTime())-o.index;return r.sort((o,i)=>n(o)-n(i)),r}_renewWriteStream(){let e=this.fileFormatter({date:this.state.currentDate,index:0}),r=i=>{try{return di.mkdirSync(i,{recursive:!0})}catch(s){if(s.code==="ENOENT")return r(pi.dirname(i)),r(i);if(s.code!=="EEXIST"&&s.code!=="EROFS")throw s;try{if(di.statSync(i).isDirectory())return i;throw s}catch{throw s}}};r(this.fileObject.dir);let n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode},o=function(i,s,a){return i[a]=i[s],delete i[s],i};di.appendFileSync(e,"",o({...n},"flags","flag")),this.currentFileStream=di.createWriteStream(e,n),this.currentFileStream.on("error",i=>{this.emit("error",i)})}async _clean(){let e=await this._getExistingFiles();if(Kt(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),Kt("_clean: existing files are: ",e),this._tooManyFiles(e.length)){let r=e.slice(0,e.length-this.options.numToKeep).map(n=>pi.format({dir:this.fileObject.dir,base:n.filename}));await v9(r)}}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};oO.exports=Oy});var sO=g(($fe,iO)=>{var w9=kf(),Ty=class extends w9{constructor(e,r,n,o){o||(o={}),r&&(o.maxSize=r),!o.numBackups&&o.numBackups!==0&&(!n&&n!==0&&(n=1),o.numBackups=n),super(e,o),this.backups=o.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};iO.exports=Ty});var lO=g((Lfe,aO)=>{var x9=kf(),Cy=class extends x9{constructor(e,r,n){r&&typeof r=="object"&&(n=r,r=null),n||(n={}),r||(r="yyyy-MM-dd"),n.pattern=r,!n.numBackups&&n.numBackups!==0?(!n.daysToKeep&&n.daysToKeep!==0?n.daysToKeep=1:process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"),n.numBackups=n.daysToKeep):n.daysToKeep=n.numBackups,super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}};aO.exports=Cy});var Ay=g((jfe,cO)=>{cO.exports={RollingFileWriteStream:kf(),RollingFileStream:sO(),DateRollingFileStream:lO()}});var mO=g((qfe,dO)=>{var uO=Ze()("log4js:file"),ky=require("path"),E9=Ay(),pO=require("os"),S9=pO.EOL,Rf=!1,Nf=new Set;function fO(){Nf.forEach(t=>{t.sighupHandler()})}function I9(t,e,r,n,o,i){if(typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(ky.sep))throw new Error(`Filename is a directory: ${t}`);t=t.replace(new RegExp(`^~(?=${ky.sep}.+)`),pO.homedir()),t=ky.normalize(t),n=!n&&n!==0?5:n,uO("Creating file appender (",t,", ",r,", ",n,", ",o,", ",i,")");function s(u,c,f,p){let d=new E9.RollingFileStream(u,c,f,p);return d.on("error",h=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",u,h)}),d.on("drain",()=>{process.emit("log4js:pause",!1)}),d}let a=s(t,r,n,o),l=function(u){if(a.writable){if(o.removeColor===!0){let c=/\x1b[[0-9;]*m/g;u.data=u.data.map(f=>typeof f=="string"?f.replace(c,""):f)}a.write(e(u,i)+S9,"utf8")||process.emit("log4js:pause",!0)}};return l.reopen=function(){a.end(()=>{a=s(t,r,n,o)})},l.sighupHandler=function(){uO("SIGHUP handler called."),l.reopen()},l.shutdown=function(u){Nf.delete(l),Nf.size===0&&Rf&&(process.removeListener("SIGHUP",fO),Rf=!1),a.end("","utf-8",u)},Nf.add(l),Rf||(process.on("SIGHUP",fO),Rf=!0),l}function _9(t,e){let r=e.basicLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),t.mode=t.mode||384,I9(t.filename,r,t.maxLogSize,t.backups,t,t.timezoneOffset)}dO.exports.configure=_9});var gO=g((Bfe,hO)=>{var O9=Ay(),T9=require("os"),C9=T9.EOL;function A9(t,e,r){let n=new O9.DateRollingFileStream(t,e,r);return n.on("error",o=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",t,o)}),n.on("drain",()=>{process.emit("log4js:pause",!1)}),n}function k9(t,e,r,n,o){n.maxSize=n.maxLogSize;let i=A9(t,e,n),s=function(a){i.writable&&(i.write(r(a,o)+C9,"utf8")||process.emit("log4js:pause",!0))};return s.shutdown=function(a){i.end("","utf-8",a)},s}function R9(t,e){let r=e.basicLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),t.alwaysIncludePattern||(t.alwaysIncludePattern=!1),t.mode=t.mode||384,k9(t.filename,t.pattern,r,t,t.timezoneOffset)}hO.exports.configure=R9});var wO=g((zfe,vO)=>{var _n=Ze()("log4js:fileSync"),Yr=require("path"),Jr=require("fs"),yO=require("os"),N9=yO.EOL;function bO(t,e){let r=n=>{try{return Jr.mkdirSync(n,{recursive:!0})}catch(o){if(o.code==="ENOENT")return r(Yr.dirname(n)),r(n);if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;try{if(Jr.statSync(n).isDirectory())return n;throw o}catch{throw o}}};r(Yr.dirname(t)),Jr.appendFileSync(t,"",{mode:e.mode,flag:e.flags})}var Ry=class{constructor(e,r,n,o){if(_n("In RollingFileStream"),r<0)throw new Error(`maxLogSize (${r}) should be > 0`);this.filename=e,this.size=r,this.backups=n,this.options=o,this.currentSize=0;function i(s){let a=0;try{a=Jr.statSync(s).size}catch{bO(s,o)}return a}this.currentSize=i(this.filename)}shouldRoll(){return _n("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){let r=this,n=new RegExp(`^${Yr.basename(e)}`);function o(u){return n.test(u)}function i(u){return parseInt(u.slice(`${Yr.basename(e)}.`.length),10)||0}function s(u,c){return i(u)-i(c)}function a(u){let c=i(u);if(_n(`Index of ${u} is ${c}`),r.backups===0)Jr.truncateSync(e,0);else if(c ${e}.${c+1}`),Jr.renameSync(Yr.join(Yr.dirname(e),u),`${e}.${c+1}`)}}function l(){_n("Renaming the old files"),Jr.readdirSync(Yr.dirname(e)).filter(o).sort(s).reverse().forEach(a)}_n("Rolling, rolling, rolling"),l()}write(e,r){let n=this;function o(){_n("writing the chunk to the file"),n.currentSize+=e.length,Jr.appendFileSync(n.filename,e)}_n("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),o()}};function D9(t,e,r,n,o,i){if(typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(Yr.sep))throw new Error(`Filename is a directory: ${t}`);t=t.replace(new RegExp(`^~(?=${Yr.sep}.+)`),yO.homedir()),t=Yr.normalize(t),n=!n&&n!==0?5:n,_n("Creating fileSync appender (",t,", ",r,", ",n,", ",o,", ",i,")");function s(l,u,c){let f;return u?f=new Ry(l,u,c,o):f=(p=>(bO(p,o),{write(d){Jr.appendFileSync(p,d)}}))(l),f}let a=s(t,r,n);return l=>{a.write(e(l,i)+N9)}}function F9(t,e){let r=e.basicLayout;t.layout&&(r=e.layout(t.layout.type,t.layout));let n={flags:t.flags||"a",encoding:t.encoding||"utf8",mode:t.mode||384};return D9(t.filename,r,t.maxLogSize,t.backups,n,t.timezoneOffset)}vO.exports.configure=F9});var EO=g((Ufe,xO)=>{var Xr=Ze()("log4js:tcp"),P9=require("net");function M9(t,e){let r=!1,n=[],o,i=3,s="__LOG4JS__";function a(f){Xr("Writing log event to socket"),r=o.write(`${e(f)}${s}`,"utf8")}function l(){let f;for(Xr("emptying buffer");f=n.shift();)a(f)}function u(){Xr(`appender creating socket to ${t.host||"localhost"}:${t.port||5e3}`),s=`${t.endMsg||"__LOG4JS__"}`,o=P9.createConnection(t.port||5e3,t.host||"localhost"),o.on("connect",()=>{Xr("socket connected"),l(),r=!0}),o.on("drain",()=>{Xr("drain event received, emptying buffer"),r=!0,l()}),o.on("timeout",o.end.bind(o)),o.on("error",f=>{Xr("connection error",f),r=!1,l()}),o.on("close",u)}u();function c(f){r?a(f):(Xr("buffering log event because it cannot write at the moment"),n.push(f))}return c.shutdown=function(f){Xr("shutdown called"),n.length&&i?(Xr("buffer has items, waiting 100ms to empty"),i-=1,setTimeout(()=>{c.shutdown(f)},100)):(o.removeAllListeners("close"),o.end(f))},c}function $9(t,e){Xr(`configure with config = ${t}`);let r=function(n){return n.serialise()};return t.layout&&(r=e.layout(t.layout.type,t.layout)),M9(t,r)}xO.exports.configure=$9});var Fy=g((Wfe,Dy)=>{var Ny=require("path"),po=Ze()("log4js:appenders"),fr=ii(),SO=hf(),L9=ai(),j9=Yg(),q9=w1(),Ar=new Map;Ar.set("console",E1());Ar.set("stdout",I1());Ar.set("stderr",O1());Ar.set("logLevelFilter",C1());Ar.set("categoryFilter",R1());Ar.set("noLogFilter",F1());Ar.set("file",mO());Ar.set("dateFile",gO());Ar.set("fileSync",wO());Ar.set("tcp",EO());var bl=new Map,Df=(t,e)=>{let r;try{let n=`${t}.cjs`;r=require.resolve(n),po("Loading module from ",n)}catch{r=t,po("Loading module from ",t)}try{return require(r)}catch(n){fr.throwExceptionIf(e,n.code!=="MODULE_NOT_FOUND",`appender "${t}" could not be loaded (error was: ${n})`);return}},B9=(t,e)=>Ar.get(t)||Df(`./${t}`,e)||Df(t,e)||require.main&&require.main.filename&&Df(Ny.join(Ny.dirname(require.main.filename),t),e)||Df(Ny.join(process.cwd(),t),e),Ff=new Set,IO=(t,e)=>{if(bl.has(t))return bl.get(t);if(!e.appenders[t])return!1;if(Ff.has(t))throw new Error(`Dependency loop detected for appender ${t}.`);Ff.add(t),po(`Creating appender ${t}`);let r=z9(t,e);return Ff.delete(t),bl.set(t,r),r},z9=(t,e)=>{let r=e.appenders[t],n=r.type.configure?r.type:B9(r.type,e);return fr.throwExceptionIf(e,fr.not(n),`appender "${t}" is not valid (type "${r.type}" could not be found)`),n.appender&&(process.emitWarning(`Appender ${r.type} exports an appender function.`,"DeprecationWarning","log4js-node-DEP0001"),po("[log4js-node-DEP0001]",`DEPRECATION: Appender ${r.type} exports an appender function.`)),n.shutdown&&(process.emitWarning(`Appender ${r.type} exports a shutdown function.`,"DeprecationWarning","log4js-node-DEP0002"),po("[log4js-node-DEP0002]",`DEPRECATION: Appender ${r.type} exports a shutdown function.`)),po(`${t}: clustering.isMaster ? ${SO.isMaster()}`),po(`${t}: appenderModule is ${require("util").inspect(n)}`),SO.onlyOnMaster(()=>(po(`calling appenderModule.configure for ${t} / ${r.type}`),n.configure(q9.modifyConfig(r),j9,o=>IO(o,e),L9)),()=>{})},_O=t=>{if(bl.clear(),Ff.clear(),!t)return;let e=[];Object.values(t.categories).forEach(r=>{e.push(...r.appenders)}),Object.keys(t.appenders).forEach(r=>{(e.includes(r)||t.appenders[r].type==="tcp-server"||t.appenders[r].type==="multiprocess")&&IO(r,t)})},OO=()=>{_O()};OO();fr.addListener(t=>{fr.throwExceptionIf(t,fr.not(fr.anObject(t.appenders)),'must have a property "appenders" of type object.');let e=Object.keys(t.appenders);fr.throwExceptionIf(t,fr.not(e.length),"must define at least one appender."),e.forEach(r=>{fr.throwExceptionIf(t,fr.not(t.appenders[r].type),`appender "${r}" is not valid (must be an object with property "type")`)})});fr.addListener(_O);Dy.exports=bl;Dy.exports.init=OO});var $y=g((Hfe,Pf)=>{var vl=Ze()("log4js:categories"),Fe=ii(),Py=ai(),TO=Fy(),mo=new Map;function CO(t,e,r){if(e.inherit===!1)return;let n=r.lastIndexOf(".");if(n<0)return;let o=r.slice(0,n),i=t.categories[o];i||(i={inherit:!0,appenders:[]}),CO(t,i,o),!t.categories[o]&&i.appenders&&i.appenders.length&&i.level&&(t.categories[o]=i),e.appenders=e.appenders||[],e.level=e.level||i.level,i.appenders.forEach(s=>{e.appenders.includes(s)||e.appenders.push(s)}),e.parent=i}function U9(t){if(!t.categories)return;Object.keys(t.categories).forEach(r=>{let n=t.categories[r];CO(t,n,r)})}Fe.addPreProcessingListener(t=>U9(t));Fe.addListener(t=>{Fe.throwExceptionIf(t,Fe.not(Fe.anObject(t.categories)),'must have a property "categories" of type object.');let e=Object.keys(t.categories);Fe.throwExceptionIf(t,Fe.not(e.length),"must define at least one category."),e.forEach(r=>{let n=t.categories[r];Fe.throwExceptionIf(t,[Fe.not(n.appenders),Fe.not(n.level)],`category "${r}" is not valid (must be an object with properties "appenders" and "level")`),Fe.throwExceptionIf(t,Fe.not(Array.isArray(n.appenders)),`category "${r}" is not valid (appenders must be an array of appender names)`),Fe.throwExceptionIf(t,Fe.not(n.appenders.length),`category "${r}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(n,"enableCallStack")&&Fe.throwExceptionIf(t,typeof n.enableCallStack!="boolean",`category "${r}" is not valid (enableCallStack must be boolean type)`),n.appenders.forEach(o=>{Fe.throwExceptionIf(t,Fe.not(TO.get(o)),`category "${r}" is not valid (appender "${o}" is not defined)`)}),Fe.throwExceptionIf(t,Fe.not(Py.getLevel(n.level)),`category "${r}" is not valid (level "${n.level}" not recognised; valid levels are ${Py.levels.join(", ")})`)}),Fe.throwExceptionIf(t,Fe.not(t.categories.default),'must define a "default" category.')});var My=t=>{if(mo.clear(),!t)return;Object.keys(t.categories).forEach(r=>{let n=t.categories[r],o=[];n.appenders.forEach(i=>{o.push(TO.get(i)),vl(`Creating category ${r}`),mo.set(r,{appenders:o,level:Py.getLevel(n.level),enableCallStack:n.enableCallStack||!1})})})},AO=()=>{My()};AO();Fe.addListener(My);var Cs=t=>{if(vl(`configForCategory: searching for config for ${t}`),mo.has(t))return vl(`configForCategory: ${t} exists in config, returning it`),mo.get(t);let e;return t.indexOf(".")>0?(vl(`configForCategory: ${t} has hierarchy, cloning from parents`),e={...Cs(t.slice(0,t.lastIndexOf(".")))}):(mo.has("default")||My({categories:{default:{appenders:["out"],level:"OFF"}}}),vl("configForCategory: cloning default category"),e={...mo.get("default")}),mo.set(t,e),e},W9=t=>Cs(t).appenders,H9=t=>Cs(t).level,K9=(t,e)=>{Cs(t).level=e},V9=t=>Cs(t).enableCallStack===!0,G9=(t,e)=>{Cs(t).enableCallStack=e};Pf.exports=mo;Pf.exports=Object.assign(Pf.exports,{appendersForCategory:W9,getLevelForCategory:H9,setLevelForCategory:K9,getEnableCallStackForCategory:V9,setEnableCallStackForCategory:G9,init:AO})});var FO=g((Kfe,DO)=>{var kO=Ze()("log4js:logger"),Z9=Xg(),Qr=ai(),J9=hf(),Mf=$y(),RO=ii(),Y9=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function X9(t,e=4){try{let r=t.stack.split(` -`).slice(e),n=Y9.exec(r[0]);if(n&&n.length===6)return{functionName:n[1],fileName:n[2],lineNumber:parseInt(n[3],10),columnNumber:parseInt(n[4],10),callStack:r.join(` -`)};console.error("log4js.logger - defaultParseCallStack error")}catch(r){console.error("log4js.logger - defaultParseCallStack error",r)}return null}var wl=class{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=X9,kO(`Logger created (${this.category}, ${this.level})`)}get level(){return Qr.getLevel(Mf.getLevelForCategory(this.category),Qr.OFF)}set level(e){Mf.setLevelForCategory(this.category,Qr.getLevel(e,this.level))}get useCallStack(){return Mf.getEnableCallStackForCategory(this.category)}set useCallStack(e){Mf.setEnableCallStackForCategory(this.category,e===!0)}log(e,...r){let n=Qr.getLevel(e);n?this.isLevelEnabled(n)&&this._log(n,r):RO.validIdentifier(e)&&r.length>0?(this.log(Qr.WARN,"log4js:logger.log: valid log-level not found as first parameter given:",e),this.log(Qr.INFO,`[${e}]`,...r)):this.log(Qr.INFO,e,...r)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,r){kO(`sending log data (${e}) to appenders`);let n=new Z9(this.category,e,r,this.context,this.useCallStack&&this.parseCallStack(new Error));J9.send(n)}addContext(e,r){this.context[e]=r}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}};function NO(t){let e=Qr.getLevel(t),n=e.toString().toLowerCase().replace(/_([a-z])/g,i=>i[1].toUpperCase()),o=n[0].toUpperCase()+n.slice(1);wl.prototype[`is${o}Enabled`]=function(){return this.isLevelEnabled(e)},wl.prototype[n]=function(...i){this.log(e,...i)}}Qr.levels.forEach(NO);RO.addListener(()=>{Qr.levels.forEach(NO)});DO.exports=wl});var $O=g((Vfe,MO)=>{var As=ai(),Q9=':remote-addr - - ":method :url HTTP/:http-version" :status :content-length ":referrer" ":user-agent"';function eU(t){return t.originalUrl||t.url}function tU(t,e,r){let n=i=>{let s=i.concat();for(let a=0;an.source?n.source:n);e=new RegExp(r.join("|"))}return e}function nU(t,e,r){let n=e;if(r){let o=r.find(i=>{let s=!1;return i.from&&i.to?s=t>=i.from&&t<=i.to:s=i.codes.indexOf(t)!==-1,s});o&&(n=As.getLevel(o.level,n))}return n}MO.exports=function(e,r){typeof r=="string"||typeof r=="function"?r={format:r}:r=r||{};let n=e,o=As.getLevel(r.level,As.INFO),i=r.format||Q9;return(s,a,l)=>{if(s._logging!==void 0)return l();if(typeof r.nolog!="function"){let u=rU(r.nolog);if(u&&u.test(s.originalUrl))return l()}if(n.isLevelEnabled(o)||r.level==="auto"){let u=new Date,{writeHead:c}=a;s._logging=!0,a.writeHead=(d,h)=>{a.writeHead=c,a.writeHead(d,h),a.__statusCode=d,a.__headers=h||{}};let f=!1,p=()=>{if(f)return;if(f=!0,typeof r.nolog=="function"&&r.nolog(s,a)===!0){s._logging=!1;return}a.responseTime=new Date-u,a.statusCode&&r.level==="auto"&&(o=As.INFO,a.statusCode>=300&&(o=As.WARN),a.statusCode>=400&&(o=As.ERROR)),o=nU(a.statusCode,o,r.statusRules);let d=tU(s,a,r.tokens||[]);if(r.context&&n.addContext("res",a),typeof i=="function"){let h=i(s,a,b=>PO(b,d));h&&n.log(o,h)}else n.log(o,PO(i,d));r.context&&n.removeContext("res")};a.on("end",p),a.on("finish",p),a.on("error",p),a.on("close",p)}return l()}}});var zO=g((Gfe,BO)=>{var LO=Ze()("log4js:recording"),$f=[];function oU(){return function(t){LO(`received logEvent, number of events now ${$f.length+1}`),LO("log event was ",t),$f.push(t)}}function jO(){return $f.slice()}function qO(){$f.length=0}BO.exports={configure:oU,replay:jO,playback:jO,reset:qO,erase:qO}});var ZO=g((Zfe,GO)=>{var ho=Ze()("log4js:main"),iU=require("fs"),sU=PS()({proto:!0}),aU=ii(),lU=Yg(),cU=ai(),UO=Fy(),WO=$y(),uU=FO(),fU=hf(),pU=$O(),dU=zO(),xl=!1;function mU(t){if(!xl)return;ho("Received log event ",t),WO.appendersForCategory(t.categoryName).forEach(r=>{r(t)})}function hU(t){ho(`Loading configuration from ${t}`);try{return JSON.parse(iU.readFileSync(t,"utf8"))}catch(e){throw new Error(`Problem reading config from file "${t}". Error was ${e.message}`,e)}}function HO(t){xl&&KO();let e=t;return typeof e=="string"&&(e=hU(t)),ho(`Configuration is ${e}`),aU.configure(sU(e)),fU.onMessage(mU),xl=!0,VO}function gU(){return dU}function KO(t){ho("Shutdown called. Disabling all log writing."),xl=!1;let e=Array.from(UO.values());UO.init(),WO.init();let r=e.reduceRight((s,a)=>a.shutdown?s+1:s,0);if(r===0)return ho("No appenders with shutdown functions found."),t!==void 0&&t();let n=0,o;ho(`Found ${r} appenders with shutdown functions.`);function i(s){o=o||s,n+=1,ho(`Appender shutdowns complete: ${n} / ${r}`),n>=r&&(ho("All shutdown functions completed."),t&&t(o))}return e.filter(s=>s.shutdown).forEach(s=>s.shutdown(i)),null}function yU(t){return xl||HO(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new uU(t||"default")}var VO={getLogger:yU,configure:HO,shutdown:KO,connectLogger:pU,levels:cU,addLayout:lU.addLayout,recording:gU};GO.exports=VO});var ks=g(Lf=>{"use strict";Object.defineProperty(Lf,"__esModule",{value:!0});function JO(t,e){if(e)return t;throw new Error("Unhandled discriminated union member: "+JSON.stringify(t))}Lf.assertNever=JO;Lf.default=JO});var QO=g((Yfe,XO)=>{"use strict";var bU=["h","min","s","ms","\u03BCs","ns"],vU=["hour","minute","second","millisecond","microsecond","nanosecond"],YO=[3600,60,1,1e6,1e3,1];XO.exports=function(t,e){var r,n,o,i,s,a,l,u,c,f;if(r=!1,n=!1,e&&(r=e.verbose||!1,n=e.precise||!1),!Array.isArray(t)||t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")return"";for(t[1]<0&&(f=t[0]+t[1]/1e9,t[0]=parseInt(f),t[1]=parseFloat((f%1).toPrecision(9))*1e9),c="",o=0;o<6&&(i=o<3?0:1,s=t[i],o!==3&&o!==0&&(s=s%YO[o-1]),o===2&&(s+=t[1]/1e9),a=s/YO[o],!(a>=1&&(r&&(a=Math.floor(a)),n?u=a.toString():(l=a>=10?0:2,u=a.toFixed(l)),u.indexOf(".")>-1&&u[u.length-1]==="0"&&(u=u.replace(/\.?0+$/,"")),c&&(c+=" "),c+=u,r?(c+=" "+vU[o],u!=="1"&&(c+="s")):c+=" "+bU[o],!r)));o++);return c}});var tT=g((Xfe,eT)=>{"use strict";eT.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var sT=g((Qfe,iT)=>{"use strict";var oT="%[a-f0-9]{2}",rT=new RegExp("("+oT+")|([^%]+?)","gi"),nT=new RegExp("("+oT+")+","gi");function Ly(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Ly(r),Ly(n))}function wU(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(rT)||[],r=1;r{"use strict";aT.exports=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];let r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]}});var uT=g((tpe,cT)=>{"use strict";cT.exports=function(t,e){for(var r={},n=Object.keys(t),o=Array.isArray(e),i=0;i{"use strict";var EU=tT(),SU=sT(),pT=lT(),IU=uT(),_U=t=>t==null,jy=Symbol("encodeFragmentIdentifier");function OU(t){switch(t.arrayFormat){case"index":return e=>(r,n)=>{let o=r.length;return n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[Me(e,t),"[",o,"]"].join("")]:[...r,[Me(e,t),"[",Me(o,t),"]=",Me(n,t)].join("")]};case"bracket":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[Me(e,t),"[]"].join("")]:[...r,[Me(e,t),"[]=",Me(n,t)].join("")];case"colon-list-separator":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[Me(e,t),":list="].join("")]:[...r,[Me(e,t),":list=",Me(n,t)].join("")];case"comma":case"separator":case"bracket-separator":{let e=t.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(n,o)=>o===void 0||t.skipNull&&o===null||t.skipEmptyString&&o===""?n:(o=o===null?"":o,n.length===0?[[Me(r,t),e,Me(o,t)].join("")]:[[n,Me(o,t)].join(t.arrayFormatSeparator)])}default:return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,Me(e,t)]:[...r,[Me(e,t),"=",Me(n,t)].join("")]}}function TU(t){let e;switch(t.arrayFormat){case"index":return(r,n,o)=>{if(e=/\[(\d*)\]$/.exec(r),r=r.replace(/\[\d*\]$/,""),!e){o[r]=n;return}o[r]===void 0&&(o[r]={}),o[r][e[1]]=n};case"bracket":return(r,n,o)=>{if(e=/(\[\])$/.exec(r),r=r.replace(/\[\]$/,""),!e){o[r]=n;return}if(o[r]===void 0){o[r]=[n];return}o[r]=[].concat(o[r],n)};case"colon-list-separator":return(r,n,o)=>{if(e=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!e){o[r]=n;return}if(o[r]===void 0){o[r]=[n];return}o[r]=[].concat(o[r],n)};case"comma":case"separator":return(r,n,o)=>{let i=typeof n=="string"&&n.includes(t.arrayFormatSeparator),s=typeof n=="string"&&!i&&On(n,t).includes(t.arrayFormatSeparator);n=s?On(n,t):n;let a=i||s?n.split(t.arrayFormatSeparator).map(l=>On(l,t)):n===null?n:On(n,t);o[r]=a};case"bracket-separator":return(r,n,o)=>{let i=/(\[\])$/.test(r);if(r=r.replace(/\[\]$/,""),!i){o[r]=n&&On(n,t);return}let s=n===null?[]:n.split(t.arrayFormatSeparator).map(a=>On(a,t));if(o[r]===void 0){o[r]=s;return}o[r]=[].concat(o[r],s)};default:return(r,n,o)=>{if(o[r]===void 0){o[r]=n;return}o[r]=[].concat(o[r],n)}}}function dT(t){if(typeof t!="string"||t.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function Me(t,e){return e.encode?e.strict?EU(t):encodeURIComponent(t):t}function On(t,e){return e.decode?SU(t):t}function mT(t){return Array.isArray(t)?t.sort():typeof t=="object"?mT(Object.keys(t)).sort((e,r)=>Number(e)-Number(r)).map(e=>t[e]):t}function hT(t){let e=t.indexOf("#");return e!==-1&&(t=t.slice(0,e)),t}function CU(t){let e="",r=t.indexOf("#");return r!==-1&&(e=t.slice(r)),e}function gT(t){t=hT(t);let e=t.indexOf("?");return e===-1?"":t.slice(e+1)}function fT(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&typeof t=="string"&&t.trim()!==""?t=Number(t):e.parseBooleans&&t!==null&&(t.toLowerCase()==="true"||t.toLowerCase()==="false")&&(t=t.toLowerCase()==="true"),t}function yT(t,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),dT(e.arrayFormatSeparator);let r=TU(e),n=Object.create(null);if(typeof t!="string"||(t=t.trim().replace(/^[?#&]/,""),!t))return n;for(let o of t.split("&")){if(o==="")continue;let[i,s]=pT(e.decode?o.replace(/\+/g," "):o,"=");s=s===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?s:On(s,e),r(On(i,e),s,n)}for(let o of Object.keys(n)){let i=n[o];if(typeof i=="object"&&i!==null)for(let s of Object.keys(i))i[s]=fT(i[s],e);else n[o]=fT(i,e)}return e.sort===!1?n:(e.sort===!0?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((o,i)=>{let s=n[i];return s&&typeof s=="object"&&!Array.isArray(s)?o[i]=mT(s):o[i]=s,o},Object.create(null))}Nt.extract=gT;Nt.parse=yT;Nt.stringify=(t,e)=>{if(!t)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),dT(e.arrayFormatSeparator);let r=s=>e.skipNull&&_U(t[s])||e.skipEmptyString&&t[s]==="",n=OU(e),o={};for(let s of Object.keys(t))r(s)||(o[s]=t[s]);let i=Object.keys(o);return e.sort!==!1&&i.sort(e.sort),i.map(s=>{let a=t[s];return a===void 0?"":a===null?Me(s,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?Me(s,e)+"[]":a.reduce(n(s),[]).join("&"):Me(s,e)+"="+Me(a,e)}).filter(s=>s.length>0).join("&")};Nt.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);let[r,n]=pT(t,"#");return Object.assign({url:r.split("?")[0]||"",query:yT(gT(t),e)},e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:On(n,e)}:{})};Nt.stringifyUrl=(t,e)=>{e=Object.assign({encode:!0,strict:!0,[jy]:!0},e);let r=hT(t.url).split("?")[0]||"",n=Nt.extract(t.url),o=Nt.parse(n,{sort:!1}),i=Object.assign(o,t.query),s=Nt.stringify(i,e);s&&(s=`?${s}`);let a=CU(t.url);return t.fragmentIdentifier&&(a=`#${e[jy]?Me(t.fragmentIdentifier,e):t.fragmentIdentifier}`),`${r}${s}${a}`};Nt.pick=(t,e,r)=>{r=Object.assign({parseFragmentIdentifier:!0,[jy]:!1},r);let{url:n,query:o,fragmentIdentifier:i}=Nt.parseUrl(t,r);return Nt.stringifyUrl({url:n,query:IU(o,e),fragmentIdentifier:i},r)};Nt.exclude=(t,e,r)=>{let n=Array.isArray(e)?o=>!e.includes(o):(o,i)=>!e(o,i);return Nt.pick(t,n,r)}});function Nn(t,e){for(var r in e)t[r]=e[r];return t}function zA(t){var e=t.parentNode;e&&e.removeChild(t)}function H(t,e,r){var n,o,i,s={};for(i in e)i=="key"?n=e[i]:i=="ref"?o=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?Kl.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return Wl(t,s,n,o,null)}function Wl(t,e,r,n,o){var i={type:t,props:e,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:o??++jA};return o==null&&q.vnode!=null&&q.vnode(i),i}function Tp(){return{current:null}}function M(t){return t.children}function Gt(t,e){this.props=t,this.context=e}function Hl(t,e){if(e==null)return t.__?Hl(t.__,t.__.__k.indexOf(t)+1):null;for(var r;e0?Wl(d.type,d.props,d.key,d.ref?d.ref:null,d.__v):d)!=null){if(d.__=r,d.__b=r.__b+1,(p=v[c])===null||p&&d.key==p.key&&d.type===p.type)v[c]=void 0;else for(f=0;f2&&(s.children=arguments.length>3?Kl.call(arguments,2):r),Wl(t.type,s,n||t.key,o||t.ref,null)}function We(t,e){var r={__c:e="__cC"+qA++,__:t,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,i;return this.getChildContext||(o=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(s){this.props.value!==s.value&&o.some(jb)},this.sub=function(s){o.push(s);var a=s.componentWillUnmount;s.componentWillUnmount=function(){o.splice(o.indexOf(s),1),a&&a.call(s)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}var Kl,q,jA,o7,Ul,PA,qA,Ip,BA,i7,Hs=Yu(()=>{Ip={},BA=[],i7=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;Kl=BA.slice,q={__e:function(t,e,r,n){for(var o,i,s;e=e.__;)if((o=e.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(t)),s=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,n||{}),s=o.__d),s)return o.__E=o}catch(a){t=a}throw t}},jA=0,o7=function(t){return t!=null&&t.constructor===void 0},Gt.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Nn({},this.state),typeof t=="function"&&(t=t(Nn({},r),this.props)),t&&Nn(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),jb(this))},Gt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),jb(this))},Gt.prototype.render=M,Ul=[],_p.__r=0,qA=0});function Si(t,e){q.__h&&q.__h(Oe,t,Ks||e),Ks=0;var r=Oe.__H||(Oe.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({__V:Cp}),r.__[t]}function L(t){return Ks=1,an(ik,t)}function an(t,e,r){var n=Si(So++,2);if(n.t=t,!n.__c&&(n.__=[r?r(e):ik(void 0,e),function(i){var s=n.__N?n.__N[0]:n.__[0],a=n.t(s,i);s!==a&&(n.__N=[a,n.__[1]],n.__c.setState({}))}],n.__c=Oe,!Oe.u)){Oe.u=!0;var o=Oe.shouldComponentUpdate;Oe.shouldComponentUpdate=function(i,s,a){if(!n.__c.__H)return!0;var l=n.__c.__H.__.filter(function(c){return c.__c});if(l.every(function(c){return!c.__N}))return!o||o.call(this,i,s,a);var u=!1;return l.forEach(function(c){if(c.__N){var f=c.__[0];c.__=c.__N,c.__N=void 0,f!==c.__[0]&&(u=!0)}}),!(!u&&n.__c.props===i)&&(!o||o.call(this,i,s,a))}}return n.__N||n.__}function U(t,e){var r=Si(So++,3);!q.__s&&Kb(r.__H,e)&&(r.__=t,r.i=e,Oe.__H.__h.push(r))}function Pt(t,e){var r=Si(So++,4);!q.__s&&Kb(r.__H,e)&&(r.__=t,r.i=e,Oe.__h.push(r))}function P(t){return Ks=5,ie(function(){return{current:t}},[])}function Wb(t,e,r){Ks=6,Pt(function(){return typeof t=="function"?(t(e()),function(){return t(null)}):t?(t.current=e(),function(){return t.current=null}):void 0},r==null?r:r.concat(t))}function ie(t,e){var r=Si(So++,7);return Kb(r.__H,e)?(r.__V=t(),r.i=e,r.__h=t,r.__V):r.__}function X(t,e){return Ks=8,ie(function(){return t},e)}function te(t){var e=Oe.context[t.__c],r=Si(So++,9);return r.c=t,e?(r.__==null&&(r.__=!0,e.sub(Oe)),e.props.value):t.__}function Ii(t,e){q.useDebugValue&&q.useDebugValue(e?e(t):t)}function c7(t){var e=Si(So++,10),r=L();return e.__=t,Oe.componentDidCatch||(Oe.componentDidCatch=function(n,o){e.__&&e.__(n,o),r[1](n)}),[r[0],function(){r[1](void 0)}]}function Hb(){var t=Si(So++,11);if(!t.__){for(var e=Oe.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var r=e.__m||(e.__m=[0,0]);t.__="P"+r[0]+"-"+r[1]++}return t.__}function u7(){for(var t;t=ok.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Ap),t.__H.__h.forEach(Ub),t.__H.__h=[]}catch(e){t.__H.__h=[],q.__e(e,t.__v)}}function f7(t){var e,r=function(){clearTimeout(n),nk&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(r,100);nk&&(e=requestAnimationFrame(r))}function Ap(t){var e=Oe,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),Oe=e}function Ub(t){var e=Oe;t.__c=t.__(),Oe=e}function Kb(t,e){return!t||t.length!==e.length||e.some(function(r,n){return r!==t[n]})}function ik(t,e){return typeof e=="function"?e(t):e}var So,Oe,zb,YA,Ks,ok,Cp,XA,QA,ek,tk,rk,nk,Vb=Yu(()=>{Hs();Ks=0,ok=[],Cp=[],XA=q.__b,QA=q.__r,ek=q.diffed,tk=q.__c,rk=q.unmount;q.__b=function(t){Oe=null,XA&&XA(t)},q.__r=function(t){QA&&QA(t),So=0;var e=(Oe=t.__c).__H;e&&(zb===Oe?(e.__h=[],Oe.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.__V=Cp,r.__N=r.i=void 0})):(e.__h.forEach(Ap),e.__h.forEach(Ub),e.__h=[])),zb=Oe},q.diffed=function(t){ek&&ek(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(ok.push(e)!==1&&YA===q.requestAnimationFrame||((YA=q.requestAnimationFrame)||f7)(u7)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.__V!==Cp&&(r.__=r.__V),r.i=void 0,r.__V=Cp})),zb=Oe=null},q.__c=function(t,e){e.some(function(r){try{r.__h.forEach(Ap),r.__h=r.__h.filter(function(n){return!n.__||Ub(n)})}catch(n){e.some(function(o){o.__h&&(o.__h=[])}),e=[],q.__e(n,r.__v)}}),tk&&tk(t,e)},q.unmount=function(t){rk&&rk(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Ap(n)}catch(o){e=o}}),r.__H=void 0,e&&q.__e(e,r.__v))};nk=typeof requestAnimationFrame=="function"});function mk(t,e){for(var r in e)t[r]=e[r];return t}function Zb(t,e){for(var r in t)if(r!=="__source"&&!(r in e))return!0;for(var n in e)if(n!=="__source"&&t[n]!==e[n])return!0;return!1}function Gb(t,e){return t===e&&(t!==0||1/t==1/e)||t!=t&&e!=e}function kp(t){this.props=t}function ht(t,e){function r(o){var i=this.props.ref,s=i==o.ref;return!s&&i&&(i.call?i(null):i.current=null),e?!e(this.props,o)||!s:Zb(this.props,o)}function n(o){return this.shouldComponentUpdate=r,H(t,o)}return n.displayName="Memo("+(t.displayName||t.name)+")",n.prototype.isReactComponent=!0,n.__f=!0,n}function Y(t){function e(r){var n=mk({},r);return delete n.ref,t(n,r.ref||null)}return e.$$typeof=p7,e.render=e,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}function hk(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),t.__c.__H=null),(t=mk({},t)).__c!=null&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(n){return hk(n,e,r)})),t}function gk(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(n){return gk(n,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}function Vl(){this.__u=0,this.t=null,this.__b=null}function yk(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function bk(t){var e,r,n;function o(i){if(e||(e=t()).then(function(s){r=s.default||s},function(s){n=s}),n)throw n;if(!r)throw e;return H(r,i)}return o.displayName="Lazy",o.__f=!0,o}function Vs(){this.u=null,this.o=null}function m7(t){return this.getChildContext=function(){return t.context},t.children}function h7(t){var e=this,r=t.i;e.componentWillUnmount=function(){Ws(null,e.l),e.l=null,e.i=null},e.i&&e.i!==r&&e.componentWillUnmount(),t.__v?(e.l||(e.i=r,e.l={nodeType:1,parentNode:r,childNodes:[],appendChild:function(n){this.childNodes.push(n),e.i.appendChild(n)},insertBefore:function(n,o){this.childNodes.push(n),e.i.appendChild(n)},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e.i.removeChild(n)}}),Ws(H(m7,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}function vk(t,e){var r=H(h7,{__v:t,i:e});return r.containerInfo=e,r}function xk(t,e,r){return e.__k==null&&(e.textContent=""),Ws(t,e),typeof r=="function"&&r(),t?t.__c:null}function Ek(t,e,r){return Bb(t,e),typeof r=="function"&&r(),t?t.__c:null}function v7(){}function w7(){return this.cancelBubble}function x7(){return this.defaultPrevented}function _k(t){return H.bind(null,t)}function Zt(t){return!!t&&t.$$typeof===wk}function gr(t){return Zt(t)?JA.apply(null,arguments):t}function Ok(t){return!!t.__k&&(Ws(null,t),!0)}function Tk(t){return t&&(t.base||t.nodeType===1&&t)||null}function Jb(t){t()}function kk(t){return t}function Rk(){return[!1,Jb]}function Dk(t,e){var r=e(),n=L({h:{__:r,v:e}}),o=n[0].h,i=n[1];return Pt(function(){o.__=r,o.v=e,Gb(o.__,e())||i({h:o})},[t,r,e]),U(function(){return Gb(o.__,o.v())||i({h:o}),t(function(){Gb(o.__,o.v())||i({h:o})})},[t]),r}var sk,p7,ak,Qe,d7,lk,ck,wk,g7,y7,b7,uk,Sk,fk,pk,dk,Ik,E7,Ck,ln,Ak,Nk,N,Yb=Yu(()=>{Hs();Hs();Vb();Vb();(kp.prototype=new Gt).isPureReactComponent=!0,kp.prototype.shouldComponentUpdate=function(t,e){return Zb(this.props,t)||Zb(this.state,e)};sk=q.__b;q.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),sk&&sk(t)};p7=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;ak=function(t,e){return t==null?null:sn(sn(t).map(e))},Qe={map:ak,forEach:ak,count:function(t){return t?sn(t).length:0},only:function(t){var e=sn(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:sn},d7=q.__e;q.__e=function(t,e,r,n){if(t.then){for(var o,i=e;i=i.__;)if((o=i.__c)&&o.__c)return e.__e==null&&(e.__e=r.__e,e.__k=r.__k),o.__c(t,e)}d7(t,e,r,n)};lk=q.unmount;q.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&t.__h===!0&&(t.type=null),lk&&lk(t)},(Vl.prototype=new Gt).__c=function(t,e){var r=e.__c,n=this;n.t==null&&(n.t=[]),n.t.push(r);var o=yk(n.__v),i=!1,s=function(){i||(i=!0,r.__R=null,o?o(a):a())};r.__R=s;var a=function(){if(!--n.__u){if(n.state.__a){var u=n.state.__a;n.__v.__k[0]=gk(u,u.__c.__P,u.__c.__O)}var c;for(n.setState({__a:n.__b=null});c=n.t.pop();)c.forceUpdate()}},l=e.__h===!0;n.__u++||l||n.setState({__a:n.__b=n.__v.__k[0]}),t.then(s,s)},Vl.prototype.componentWillUnmount=function(){this.t=[]},Vl.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=hk(this.__b,r,n.__O=n.__P)}this.__b=null}var o=e.__a&&H(M,null,t.fallback);return o&&(o.__h=null),[H(M,null,e.__a?null:t.children),o]};ck=function(t,e,r){if(++r[1]===r[0]&&t.o.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.o.size))for(r=t.u;r;){for(;r.length>3;)r.pop()();if(r[1]Qe,Component:()=>Gt,Fragment:()=>M,PureComponent:()=>kp,StrictMode:()=>Ak,Suspense:()=>Vl,SuspenseList:()=>Vs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>Ik,cloneElement:()=>gr,createContext:()=>We,createElement:()=>H,createFactory:()=>_k,createPortal:()=>vk,createRef:()=>Tp,default:()=>N,findDOMNode:()=>Tk,flushSync:()=>ln,forwardRef:()=>Y,hydrate:()=>Ek,isValidElement:()=>Zt,lazy:()=>bk,memo:()=>ht,render:()=>xk,startTransition:()=>Jb,unmountComponentAtNode:()=>Ok,unstable_batchedUpdates:()=>Ck,useCallback:()=>X,useContext:()=>te,useDebugValue:()=>Ii,useDeferredValue:()=>kk,useEffect:()=>U,useErrorBoundary:()=>c7,useId:()=>Hb,useImperativeHandle:()=>Wb,useInsertionEffect:()=>Nk,useLayoutEffect:()=>Pt,useMemo:()=>ie,useReducer:()=>an,useRef:()=>P,useState:()=>L,useSyncExternalStore:()=>Dk,useTransition:()=>Rk,version:()=>E7});var S=Yu(()=>{Yb();Yb()});var Er=g((SD,ID)=>{"use strict";var um=function(t){return t&&t.Math===Math&&t};ID.exports=um(typeof globalThis=="object"&&globalThis)||um(typeof window=="object"&&window)||um(typeof self=="object"&&self)||um(typeof global=="object"&&global)||function(){return this}()||SD||Function("return this")()});var It=g((IOe,_D)=>{"use strict";_D.exports=function(t){try{return!!t()}catch{return!0}}});var zc=g((_Oe,OD)=>{"use strict";var QK=It();OD.exports=!QK(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var RD=g((OOe,kD)=>{"use strict";var eV=zc(),AD=Function.prototype,TD=AD.apply,CD=AD.call;kD.exports=typeof Reflect=="object"&&Reflect.apply||(eV?CD.bind(TD):function(){return CD.apply(TD,arguments)})});var _t=g((TOe,FD)=>{"use strict";var ND=zc(),DD=Function.prototype,L0=DD.call,tV=ND&&DD.bind.bind(L0,L0);FD.exports=ND?tV:function(t){return function(){return L0.apply(t,arguments)}}});var Hi=g((COe,MD)=>{"use strict";var PD=_t(),rV=PD({}.toString),nV=PD("".slice);MD.exports=function(t){return nV(rV(t),8,-1)}});var j0=g((AOe,$D)=>{"use strict";var oV=Hi(),iV=_t();$D.exports=function(t){if(oV(t)==="Function")return iV(t)}});var B0=g((kOe,LD)=>{"use strict";var q0=typeof document=="object"&&document.all,sV=typeof q0>"u"&&q0!==void 0;LD.exports={all:q0,IS_HTMLDDA:sV}});var ot=g((ROe,qD)=>{"use strict";var jD=B0(),aV=jD.all;qD.exports=jD.IS_HTMLDDA?function(t){return typeof t=="function"||t===aV}:function(t){return typeof t=="function"}});var Sr=g((NOe,BD)=>{"use strict";var lV=It();BD.exports=!lV(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Gn=g((DOe,zD)=>{"use strict";var cV=zc(),fm=Function.prototype.call;zD.exports=cV?fm.bind(fm):function(){return fm.apply(fm,arguments)}});var KD=g(HD=>{"use strict";var UD={}.propertyIsEnumerable,WD=Object.getOwnPropertyDescriptor,uV=WD&&!UD.call({1:2},1);HD.f=uV?function(e){var r=WD(this,e);return!!r&&r.enumerable}:UD});var Uc=g((POe,VD)=>{"use strict";VD.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var U0=g((MOe,GD)=>{"use strict";var fV=_t(),pV=It(),dV=Hi(),z0=Object,mV=fV("".split);GD.exports=pV(function(){return!z0("z").propertyIsEnumerable(0)})?function(t){return dV(t)==="String"?mV(t,""):z0(t)}:z0});var ba=g(($Oe,ZD)=>{"use strict";ZD.exports=function(t){return t==null}});var Wc=g((LOe,JD)=>{"use strict";var hV=ba(),gV=TypeError;JD.exports=function(t){if(hV(t))throw gV("Can't call method on "+t);return t}});var va=g((jOe,YD)=>{"use strict";var yV=U0(),bV=Wc();YD.exports=function(t){return yV(bV(t))}});var qr=g((qOe,eF)=>{"use strict";var XD=ot(),QD=B0(),vV=QD.all;eF.exports=QD.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:XD(t)||t===vV}:function(t){return typeof t=="object"?t!==null:XD(t)}});var Hc=g((BOe,tF)=>{"use strict";tF.exports={}});var Ki=g((zOe,nF)=>{"use strict";var W0=Hc(),H0=Er(),wV=ot(),rF=function(t){return wV(t)?t:void 0};nF.exports=function(t,e){return arguments.length<2?rF(W0[t])||rF(H0[t]):W0[t]&&W0[t][e]||H0[t]&&H0[t][e]}});var pm=g((UOe,oF)=>{"use strict";var xV=_t();oF.exports=xV({}.isPrototypeOf)});var sF=g((WOe,iF)=>{"use strict";iF.exports=typeof navigator<"u"&&String(navigator.userAgent)||""});var dF=g((HOe,pF)=>{"use strict";var fF=Er(),K0=sF(),aF=fF.process,lF=fF.Deno,cF=aF&&aF.versions||lF&&lF.version,uF=cF&&cF.v8,Br,dm;uF&&(Br=uF.split("."),dm=Br[0]>0&&Br[0]<4?1:+(Br[0]+Br[1]));!dm&&K0&&(Br=K0.match(/Edge\/(\d+)/),(!Br||Br[1]>=74)&&(Br=K0.match(/Chrome\/(\d+)/),Br&&(dm=+Br[1])));pF.exports=dm});var V0=g((KOe,hF)=>{"use strict";var mF=dF(),EV=It(),SV=Er(),IV=SV.String;hF.exports=!!Object.getOwnPropertySymbols&&!EV(function(){var t=Symbol("symbol detection");return!IV(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&mF&&mF<41})});var G0=g((VOe,gF)=>{"use strict";var _V=V0();gF.exports=_V&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var Z0=g((GOe,yF)=>{"use strict";var OV=Ki(),TV=ot(),CV=pm(),AV=G0(),kV=Object;yF.exports=AV?function(t){return typeof t=="symbol"}:function(t){var e=OV("Symbol");return TV(e)&&CV(e.prototype,kV(t))}});var mm=g((ZOe,bF)=>{"use strict";var RV=String;bF.exports=function(t){try{return RV(t)}catch{return"Object"}}});var Vi=g((JOe,vF)=>{"use strict";var NV=ot(),DV=mm(),FV=TypeError;vF.exports=function(t){if(NV(t))return t;throw FV(DV(t)+" is not a function")}});var hm=g((YOe,wF)=>{"use strict";var PV=Vi(),MV=ba();wF.exports=function(t,e){var r=t[e];return MV(r)?void 0:PV(r)}});var EF=g((XOe,xF)=>{"use strict";var J0=Gn(),Y0=ot(),X0=qr(),$V=TypeError;xF.exports=function(t,e){var r,n;if(e==="string"&&Y0(r=t.toString)&&!X0(n=J0(r,t))||Y0(r=t.valueOf)&&!X0(n=J0(r,t))||e!=="string"&&Y0(r=t.toString)&&!X0(n=J0(r,t)))return n;throw $V("Can't convert object to primitive value")}});var Kc=g((QOe,SF)=>{"use strict";SF.exports=!0});var OF=g((eTe,_F)=>{"use strict";var IF=Er(),LV=Object.defineProperty;_F.exports=function(t,e){try{LV(IF,t,{value:e,configurable:!0,writable:!0})}catch{IF[t]=e}return e}});var gm=g((tTe,CF)=>{"use strict";var jV=Er(),qV=OF(),TF="__core-js_shared__",BV=jV[TF]||qV(TF,{});CF.exports=BV});var Q0=g((rTe,kF)=>{"use strict";var zV=Kc(),AF=gm();(kF.exports=function(t,e){return AF[t]||(AF[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.32.1",mode:zV?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE",source:"https://github.com/zloirock/core-js"})});var ym=g((nTe,RF)=>{"use strict";var UV=Wc(),WV=Object;RF.exports=function(t){return WV(UV(t))}});var vn=g((oTe,NF)=>{"use strict";var HV=_t(),KV=ym(),VV=HV({}.hasOwnProperty);NF.exports=Object.hasOwn||function(e,r){return VV(KV(e),r)}});var bm=g((iTe,DF)=>{"use strict";var GV=_t(),ZV=0,JV=Math.random(),YV=GV(1 .toString);DF.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+YV(++ZV+JV,36)}});var zr=g((sTe,PF)=>{"use strict";var XV=Er(),QV=Q0(),FF=vn(),eG=bm(),tG=V0(),rG=G0(),wa=XV.Symbol,ew=QV("wks"),nG=rG?wa.for||wa:wa&&wa.withoutSetter||eG;PF.exports=function(t){return FF(ew,t)||(ew[t]=tG&&FF(wa,t)?wa[t]:nG("Symbol."+t)),ew[t]}});var jF=g((aTe,LF)=>{"use strict";var oG=Gn(),MF=qr(),$F=Z0(),iG=hm(),sG=EF(),aG=zr(),lG=TypeError,cG=aG("toPrimitive");LF.exports=function(t,e){if(!MF(t)||$F(t))return t;var r=iG(t,cG),n;if(r){if(e===void 0&&(e="default"),n=oG(r,t,e),!MF(n)||$F(n))return n;throw lG("Can't convert object to primitive value")}return e===void 0&&(e="number"),sG(t,e)}});var Vc=g((lTe,qF)=>{"use strict";var uG=jF(),fG=Z0();qF.exports=function(t){var e=uG(t,"string");return fG(e)?e:e+""}});var rw=g((cTe,zF)=>{"use strict";var pG=Er(),BF=qr(),tw=pG.document,dG=BF(tw)&&BF(tw.createElement);zF.exports=function(t){return dG?tw.createElement(t):{}}});var nw=g((uTe,UF)=>{"use strict";var mG=Sr(),hG=It(),gG=rw();UF.exports=!mG&&!hG(function(){return Object.defineProperty(gG("div"),"a",{get:function(){return 7}}).a!==7})});var KF=g(HF=>{"use strict";var yG=Sr(),bG=Gn(),vG=KD(),wG=Uc(),xG=va(),EG=Vc(),SG=vn(),IG=nw(),WF=Object.getOwnPropertyDescriptor;HF.f=yG?WF:function(e,r){if(e=xG(e),r=EG(r),IG)try{return WF(e,r)}catch{}if(SG(e,r))return wG(!bG(vG.f,e,r),e[r])}});var GF=g((pTe,VF)=>{"use strict";var _G=It(),OG=ot(),TG=/#|\.prototype\./,Gc=function(t,e){var r=AG[CG(t)];return r===RG?!0:r===kG?!1:OG(e)?_G(e):!!e},CG=Gc.normalize=function(t){return String(t).replace(TG,".").toLowerCase()},AG=Gc.data={},kG=Gc.NATIVE="N",RG=Gc.POLYFILL="P";VF.exports=Gc});var Zc=g((dTe,JF)=>{"use strict";var ZF=j0(),NG=Vi(),DG=zc(),FG=ZF(ZF.bind);JF.exports=function(t,e){return NG(t),e===void 0?t:DG?FG(t,e):function(){return t.apply(e,arguments)}}});var ow=g((mTe,YF)=>{"use strict";var PG=Sr(),MG=It();YF.exports=PG&&MG(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var qo=g((hTe,XF)=>{"use strict";var $G=qr(),LG=String,jG=TypeError;XF.exports=function(t){if($G(t))return t;throw jG(LG(t)+" is not an object")}});var Bo=g(eP=>{"use strict";var qG=Sr(),BG=nw(),zG=ow(),vm=qo(),QF=Vc(),UG=TypeError,iw=Object.defineProperty,WG=Object.getOwnPropertyDescriptor,sw="enumerable",aw="configurable",lw="writable";eP.f=qG?zG?function(e,r,n){if(vm(e),r=QF(r),vm(n),typeof e=="function"&&r==="prototype"&&"value"in n&&lw in n&&!n[lw]){var o=WG(e,r);o&&o[lw]&&(e[r]=n.value,n={configurable:aw in n?n[aw]:o[aw],enumerable:sw in n?n[sw]:o[sw],writable:!1})}return iw(e,r,n)}:iw:function(e,r,n){if(vm(e),r=QF(r),vm(n),BG)try{return iw(e,r,n)}catch{}if("get"in n||"set"in n)throw UG("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var Gi=g((yTe,tP)=>{"use strict";var HG=Sr(),KG=Bo(),VG=Uc();tP.exports=HG?function(t,e,r){return KG.f(t,e,VG(1,r))}:function(t,e,r){return t[e]=r,t}});var Zi=g((bTe,nP)=>{"use strict";var wm=Er(),GG=RD(),ZG=j0(),JG=ot(),YG=KF().f,XG=GF(),xa=Hc(),QG=Zc(),Ea=Gi(),rP=vn(),eZ=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return GG(t,this,arguments)};return e.prototype=t.prototype,e};nP.exports=function(t,e){var r=t.target,n=t.global,o=t.stat,i=t.proto,s=n?wm:o?wm[r]:(wm[r]||{}).prototype,a=n?xa:xa[r]||Ea(xa,r,{})[r],l=a.prototype,u,c,f,p,d,h,b,y,v;for(p in e)u=XG(n?p:r+(o?".":"#")+p,t.forced),c=!u&&s&&rP(s,p),h=a[p],c&&(t.dontCallGetSet?(v=YG(s,p),b=v&&v.value):b=s[p]),d=c&&b?b:e[p],!(c&&typeof h==typeof d)&&(t.bind&&c?y=QG(d,wm):t.wrap&&c?y=eZ(d):i&&JG(d)?y=ZG(d):y=d,(t.sham||d&&d.sham||h&&h.sham)&&Ea(y,"sham",!0),Ea(a,p,y),i&&(f=r+"Prototype",rP(xa,f)||Ea(xa,f,{}),Ea(xa[f],p,d),t.real&&l&&(u||!l[p])&&Ea(l,p,d)))}});var Jc=g((vTe,oP)=>{"use strict";oP.exports={}});var sP=g((wTe,iP)=>{"use strict";var tZ=Math.ceil,rZ=Math.floor;iP.exports=Math.trunc||function(e){var r=+e;return(r>0?rZ:tZ)(r)}});var cw=g((xTe,aP)=>{"use strict";var nZ=sP();aP.exports=function(t){var e=+t;return e!==e||e===0?0:nZ(e)}});var uw=g((ETe,lP)=>{"use strict";var oZ=cw(),iZ=Math.max,sZ=Math.min;lP.exports=function(t,e){var r=oZ(t);return r<0?iZ(r+e,0):sZ(r,e)}});var uP=g((STe,cP)=>{"use strict";var aZ=cw(),lZ=Math.min;cP.exports=function(t){return t>0?lZ(aZ(t),9007199254740991):0}});var Yc=g((ITe,fP)=>{"use strict";var cZ=uP();fP.exports=function(t){return cZ(t.length)}});var mP=g((_Te,dP)=>{"use strict";var uZ=va(),fZ=uw(),pZ=Yc(),pP=function(t){return function(e,r,n){var o=uZ(e),i=pZ(o),s=fZ(n,i),a;if(t&&r!==r){for(;i>s;)if(a=o[s++],a!==a)return!0}else for(;i>s;s++)if((t||s in o)&&o[s]===r)return t||s||0;return!t&&-1}};dP.exports={includes:pP(!0),indexOf:pP(!1)}});var pw=g((OTe,gP)=>{"use strict";var dZ=_t(),fw=vn(),mZ=va(),hZ=mP().indexOf,gZ=Jc(),hP=dZ([].push);gP.exports=function(t,e){var r=mZ(t),n=0,o=[],i;for(i in r)!fw(gZ,i)&&fw(r,i)&&hP(o,i);for(;e.length>n;)fw(r,i=e[n++])&&(~hZ(o,i)||hP(o,i));return o}});var xm=g((TTe,yP)=>{"use strict";yP.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var dw=g(bP=>{"use strict";var yZ=pw(),bZ=xm(),vZ=bZ.concat("length","prototype");bP.f=Object.getOwnPropertyNames||function(e){return yZ(e,vZ)}});var wP=g((ATe,vP)=>{"use strict";var wZ=Vc(),xZ=Bo(),EZ=Uc();vP.exports=function(t,e,r){var n=wZ(e);n in t?xZ.f(t,n,EZ(0,r)):t[n]=r}});var SP=g((kTe,EP)=>{"use strict";var xP=uw(),SZ=Yc(),IZ=wP(),_Z=Array,OZ=Math.max;EP.exports=function(t,e,r){for(var n=SZ(t),o=xP(e,n),i=xP(r===void 0?n:r,n),s=_Z(OZ(i-o,0)),a=0;o{"use strict";var TZ=Hi(),CZ=va(),IP=dw().f,AZ=SP(),_P=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],kZ=function(t){try{return IP(t)}catch{return AZ(_P)}};OP.exports.f=function(e){return _P&&TZ(e)==="Window"?kZ(e):IP(CZ(e))}});var AP=g((NTe,CP)=>{"use strict";var RZ=It();CP.exports=RZ(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})});var NP=g((DTe,RP)=>{"use strict";var NZ=It(),DZ=qr(),FZ=Hi(),kP=AP(),Em=Object.isExtensible,PZ=NZ(function(){Em(1)});RP.exports=PZ||kP?function(e){return!DZ(e)||kP&&FZ(e)==="ArrayBuffer"?!1:Em?Em(e):!0}:Em});var FP=g((FTe,DP)=>{"use strict";var MZ=It();DP.exports=!MZ(function(){return Object.isExtensible(Object.preventExtensions({}))})});var yw=g((PTe,$P)=>{"use strict";var $Z=Zi(),LZ=_t(),jZ=Jc(),qZ=qr(),mw=vn(),BZ=Bo().f,PP=dw(),zZ=TP(),hw=NP(),UZ=bm(),WZ=FP(),MP=!1,Zn=UZ("meta"),HZ=0,gw=function(t){BZ(t,Zn,{value:{objectID:"O"+HZ++,weakData:{}}})},KZ=function(t,e){if(!qZ(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!mw(t,Zn)){if(!hw(t))return"F";if(!e)return"E";gw(t)}return t[Zn].objectID},VZ=function(t,e){if(!mw(t,Zn)){if(!hw(t))return!0;if(!e)return!1;gw(t)}return t[Zn].weakData},GZ=function(t){return WZ&&MP&&hw(t)&&!mw(t,Zn)&&gw(t),t},ZZ=function(){JZ.enable=function(){},MP=!0;var t=PP.f,e=LZ([].splice),r={};r[Zn]=1,t(r).length&&(PP.f=function(n){for(var o=t(n),i=0,s=o.length;i{"use strict";LP.exports={}});var qP=g(($Te,jP)=>{"use strict";var YZ=zr(),XZ=Xc(),QZ=YZ("iterator"),eJ=Array.prototype;jP.exports=function(t){return t!==void 0&&(XZ.Array===t||eJ[QZ]===t)}});var Sm=g((LTe,zP)=>{"use strict";var tJ=zr(),rJ=tJ("toStringTag"),BP={};BP[rJ]="z";zP.exports=String(BP)==="[object z]"});var _m=g((jTe,UP)=>{"use strict";var nJ=Sm(),oJ=ot(),Im=Hi(),iJ=zr(),sJ=iJ("toStringTag"),aJ=Object,lJ=Im(function(){return arguments}())==="Arguments",cJ=function(t,e){try{return t[e]}catch{}};UP.exports=nJ?Im:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=cJ(e=aJ(t),sJ))=="string"?r:lJ?Im(e):(n=Im(e))==="Object"&&oJ(e.callee)?"Arguments":n}});var bw=g((qTe,HP)=>{"use strict";var uJ=_m(),WP=hm(),fJ=ba(),pJ=Xc(),dJ=zr(),mJ=dJ("iterator");HP.exports=function(t){if(!fJ(t))return WP(t,mJ)||WP(t,"@@iterator")||pJ[uJ(t)]}});var VP=g((BTe,KP)=>{"use strict";var hJ=Gn(),gJ=Vi(),yJ=qo(),bJ=mm(),vJ=bw(),wJ=TypeError;KP.exports=function(t,e){var r=arguments.length<2?vJ(t):e;if(gJ(r))return yJ(hJ(r,t));throw wJ(bJ(t)+" is not iterable")}});var JP=g((zTe,ZP)=>{"use strict";var xJ=Gn(),GP=qo(),EJ=hm();ZP.exports=function(t,e,r){var n,o;GP(t);try{if(n=EJ(t,"return"),!n){if(e==="throw")throw r;return r}n=xJ(n,t)}catch(i){o=!0,n=i}if(e==="throw")throw r;if(o)throw n;return GP(n),r}});var Qc=g((UTe,eM)=>{"use strict";var SJ=Zc(),IJ=Gn(),_J=qo(),OJ=mm(),TJ=qP(),CJ=Yc(),YP=pm(),AJ=VP(),kJ=bw(),XP=JP(),RJ=TypeError,Om=function(t,e){this.stopped=t,this.result=e},QP=Om.prototype;eM.exports=function(t,e,r){var n=r&&r.that,o=!!(r&&r.AS_ENTRIES),i=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),a=!!(r&&r.INTERRUPTED),l=SJ(e,n),u,c,f,p,d,h,b,y=function(x){return u&&XP(u,"normal",x),new Om(!0,x)},v=function(x){return o?(_J(x),a?l(x[0],x[1],y):l(x[0],x[1])):a?l(x,y):l(x)};if(i)u=t.iterator;else if(s)u=t;else{if(c=kJ(t),!c)throw RJ(OJ(t)+" is not iterable");if(TJ(c)){for(f=0,p=CJ(t);p>f;f++)if(d=v(t[f]),d&&YP(QP,d))return d;return new Om(!1)}u=AJ(t,c)}for(h=i?t.next:u.next;!(b=IJ(h,u)).done;){try{d=v(b.value)}catch(x){XP(u,"throw",x)}if(typeof d=="object"&&d&&YP(QP,d))return d}return new Om(!1)}});var vw=g((WTe,tM)=>{"use strict";var NJ=pm(),DJ=TypeError;tM.exports=function(t,e){if(NJ(e,t))return t;throw DJ("Incorrect invocation")}});var nM=g((HTe,rM)=>{"use strict";var FJ=Sm(),PJ=_m();rM.exports=FJ?{}.toString:function(){return"[object "+PJ(this)+"]"}});var Tm=g((KTe,iM)=>{"use strict";var MJ=Sm(),$J=Bo().f,LJ=Gi(),jJ=vn(),qJ=nM(),BJ=zr(),oM=BJ("toStringTag");iM.exports=function(t,e,r,n){if(t){var o=r?t:t.prototype;jJ(o,oM)||$J(o,oM,{configurable:!0,value:e}),n&&!MJ&&LJ(o,"toString",qJ)}}});var aM=g((VTe,sM)=>{"use strict";var zJ=Hi();sM.exports=Array.isArray||function(e){return zJ(e)==="Array"}});var cM=g((GTe,lM)=>{"use strict";var UJ=_t(),WJ=ot(),ww=gm(),HJ=UJ(Function.toString);WJ(ww.inspectSource)||(ww.inspectSource=function(t){return HJ(t)});lM.exports=ww.inspectSource});var hM=g((ZTe,mM)=>{"use strict";var KJ=_t(),VJ=It(),uM=ot(),GJ=_m(),ZJ=Ki(),JJ=cM(),fM=function(){},YJ=[],pM=ZJ("Reflect","construct"),xw=/^\s*(?:class|function)\b/,XJ=KJ(xw.exec),QJ=!xw.exec(fM),eu=function(e){if(!uM(e))return!1;try{return pM(fM,YJ,e),!0}catch{return!1}},dM=function(e){if(!uM(e))return!1;switch(GJ(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return QJ||!!XJ(xw,JJ(e))}catch{return!0}};dM.sham=!0;mM.exports=!pM||VJ(function(){var t;return eu(eu.call)||!eu(Object)||!eu(function(){t=!0})||t})?dM:eu});var vM=g((JTe,bM)=>{"use strict";var gM=aM(),eY=hM(),tY=qr(),rY=zr(),nY=rY("species"),yM=Array;bM.exports=function(t){var e;return gM(t)&&(e=t.constructor,eY(e)&&(e===yM||gM(e.prototype))?e=void 0:tY(e)&&(e=e[nY],e===null&&(e=void 0))),e===void 0?yM:e}});var xM=g((YTe,wM)=>{"use strict";var oY=vM();wM.exports=function(t,e){return new(oY(t))(e===0?0:e)}});var IM=g((XTe,SM)=>{"use strict";var iY=Zc(),sY=_t(),aY=U0(),lY=ym(),cY=Yc(),uY=xM(),EM=sY([].push),zo=function(t){var e=t===1,r=t===2,n=t===3,o=t===4,i=t===6,s=t===7,a=t===5||i;return function(l,u,c,f){for(var p=lY(l),d=aY(p),h=iY(u,c),b=cY(d),y=0,v=f||uY,x=e?v(l,b):r||s?v(l,0):void 0,T,$;b>y;y++)if((a||y in d)&&(T=d[y],$=h(T,y,p),t))if(e)x[y]=$;else if($)switch(t){case 3:return!0;case 5:return T;case 6:return y;case 2:EM(x,T)}else switch(t){case 4:return!1;case 7:EM(x,T)}return i?-1:n||o?o:x}};SM.exports={forEach:zo(0),map:zo(1),filter:zo(2),some:zo(3),every:zo(4),find:zo(5),findIndex:zo(6),filterReject:zo(7)}});var TM=g((QTe,OM)=>{"use strict";var fY=Er(),pY=ot(),_M=fY.WeakMap;OM.exports=pY(_M)&&/native code/.test(String(_M))});var Cm=g((eCe,AM)=>{"use strict";var dY=Q0(),mY=bm(),CM=dY("keys");AM.exports=function(t){return CM[t]||(CM[t]=mY(t))}});var _w=g((tCe,NM)=>{"use strict";var hY=TM(),RM=Er(),gY=qr(),yY=Gi(),Ew=vn(),Sw=gm(),bY=Cm(),vY=Jc(),kM="Object already initialized",Iw=RM.TypeError,wY=RM.WeakMap,Am,tu,km,xY=function(t){return km(t)?tu(t):Am(t,{})},EY=function(t){return function(e){var r;if(!gY(e)||(r=tu(e)).type!==t)throw Iw("Incompatible receiver, "+t+" required");return r}};hY||Sw.state?(Ur=Sw.state||(Sw.state=new wY),Ur.get=Ur.get,Ur.has=Ur.has,Ur.set=Ur.set,Am=function(t,e){if(Ur.has(t))throw Iw(kM);return e.facade=t,Ur.set(t,e),e},tu=function(t){return Ur.get(t)||{}},km=function(t){return Ur.has(t)}):(Ji=bY("state"),vY[Ji]=!0,Am=function(t,e){if(Ew(t,Ji))throw Iw(kM);return e.facade=t,yY(t,Ji,e),e},tu=function(t){return Ew(t,Ji)?t[Ji]:{}},km=function(t){return Ew(t,Ji)});var Ur,Ji;NM.exports={set:Am,get:tu,has:km,enforce:xY,getterFor:EY}});var PM=g((rCe,FM)=>{"use strict";var SY=Zi(),IY=Er(),_Y=yw(),OY=It(),TY=Gi(),CY=Qc(),AY=vw(),kY=ot(),RY=qr(),NY=ba(),DY=Tm(),FY=Bo().f,PY=IM().forEach,MY=Sr(),DM=_w(),$Y=DM.set,LY=DM.getterFor;FM.exports=function(t,e,r){var n=t.indexOf("Map")!==-1,o=t.indexOf("Weak")!==-1,i=n?"set":"add",s=IY[t],a=s&&s.prototype,l={},u;if(!MY||!kY(s)||!(o||a.forEach&&!OY(function(){new s().entries().next()})))u=r.getConstructor(e,t,n,i),_Y.enable();else{u=e(function(p,d){$Y(AY(p,c),{type:t,collection:new s}),NY(d)||CY(d,p[i],{that:p,AS_ENTRIES:n})});var c=u.prototype,f=LY(t);PY(["add","clear","delete","forEach","get","has","set","keys","values","entries"],function(p){var d=p==="add"||p==="set";p in a&&!(o&&p==="clear")&&TY(c,p,function(h,b){var y=f(this).collection;if(!d&&o&&!RY(h))return p==="get"?void 0:!1;var v=y[p](h===0?0:h,b);return d?this:v})}),o||FY(c,"size",{configurable:!0,get:function(){return f(this).collection.size}})}return DY(u,t,!1,!0),l[t]=u,SY({global:!0,forced:!0},l),o||r.setStrong(u,t,n),u}});var $M=g((nCe,MM)=>{"use strict";var jY=pw(),qY=xm();MM.exports=Object.keys||function(e){return jY(e,qY)}});var jM=g(LM=>{"use strict";var BY=Sr(),zY=ow(),UY=Bo(),WY=qo(),HY=va(),KY=$M();LM.f=BY&&!zY?Object.defineProperties:function(e,r){WY(e);for(var n=HY(r),o=KY(r),i=o.length,s=0,a;i>s;)UY.f(e,a=o[s++],n[a]);return e}});var BM=g((iCe,qM)=>{"use strict";var VY=Ki();qM.exports=VY("document","documentElement")});var ru=g((sCe,GM)=>{"use strict";var GY=qo(),ZY=jM(),zM=xm(),JY=Jc(),YY=BM(),XY=rw(),QY=Cm(),UM=">",WM="<",Tw="prototype",Cw="script",KM=QY("IE_PROTO"),Ow=function(){},VM=function(t){return WM+Cw+UM+t+WM+"/"+Cw+UM},HM=function(t){t.write(VM("")),t.close();var e=t.parentWindow.Object;return t=null,e},eX=function(){var t=XY("iframe"),e="java"+Cw+":",r;return t.style.display="none",YY.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(VM("document.F=Object")),r.close(),r.F},Rm,Nm=function(){try{Rm=new ActiveXObject("htmlfile")}catch{}Nm=typeof document<"u"?document.domain&&Rm?HM(Rm):eX():HM(Rm);for(var t=zM.length;t--;)delete Nm[Tw][zM[t]];return Nm()};JY[KM]=!0;GM.exports=Object.create||function(e,r){var n;return e!==null?(Ow[Tw]=GY(e),n=new Ow,Ow[Tw]=null,n[KM]=e):n=Nm(),r===void 0?n:ZY.f(n,r)}});var Aw=g((aCe,ZM)=>{"use strict";var tX=Bo();ZM.exports=function(t,e,r){return tX.f(t,e,r)}});var Dm=g((lCe,JM)=>{"use strict";var rX=Gi();JM.exports=function(t,e,r,n){return n&&n.enumerable?t[e]=r:rX(t,e,r),t}});var XM=g((cCe,YM)=>{"use strict";var nX=Dm();YM.exports=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:nX(t,n,e[n],r);return t}});var t2=g((uCe,e2)=>{"use strict";var kw=Sr(),oX=vn(),QM=Function.prototype,iX=kw&&Object.getOwnPropertyDescriptor,Rw=oX(QM,"name"),sX=Rw&&function(){}.name==="something",aX=Rw&&(!kw||kw&&iX(QM,"name").configurable);e2.exports={EXISTS:Rw,PROPER:sX,CONFIGURABLE:aX}});var n2=g((fCe,r2)=>{"use strict";var lX=It();r2.exports=!lX(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var Dw=g((pCe,i2)=>{"use strict";var cX=vn(),uX=ot(),fX=ym(),pX=Cm(),dX=n2(),o2=pX("IE_PROTO"),Nw=Object,mX=Nw.prototype;i2.exports=dX?Nw.getPrototypeOf:function(t){var e=fX(t);if(cX(e,o2))return e[o2];var r=e.constructor;return uX(r)&&e instanceof r?r.prototype:e instanceof Nw?mX:null}});var $w=g((dCe,l2)=>{"use strict";var hX=It(),gX=ot(),yX=qr(),bX=ru(),s2=Dw(),vX=Dm(),wX=zr(),xX=Kc(),Mw=wX("iterator"),a2=!1,Jn,Fw,Pw;[].keys&&(Pw=[].keys(),"next"in Pw?(Fw=s2(s2(Pw)),Fw!==Object.prototype&&(Jn=Fw)):a2=!0);var EX=!yX(Jn)||hX(function(){var t={};return Jn[Mw].call(t)!==t});EX?Jn={}:xX&&(Jn=bX(Jn));gX(Jn[Mw])||vX(Jn,Mw,function(){return this});l2.exports={IteratorPrototype:Jn,BUGGY_SAFARI_ITERATORS:a2}});var u2=g((mCe,c2)=>{"use strict";var SX=$w().IteratorPrototype,IX=ru(),_X=Uc(),OX=Tm(),TX=Xc(),CX=function(){return this};c2.exports=function(t,e,r,n){var o=e+" Iterator";return t.prototype=IX(SX,{next:_X(+!n,r)}),OX(t,o,!1,!0),TX[o]=CX,t}});var p2=g((hCe,f2)=>{"use strict";var AX=_t(),kX=Vi();f2.exports=function(t,e,r){try{return AX(kX(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}}});var m2=g((gCe,d2)=>{"use strict";var RX=ot(),NX=String,DX=TypeError;d2.exports=function(t){if(typeof t=="object"||RX(t))return t;throw DX("Can't set "+NX(t)+" as a prototype")}});var g2=g((yCe,h2)=>{"use strict";var FX=p2(),PX=qo(),MX=m2();h2.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=FX(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(o,i){return PX(o),MX(i),t?r(o,i):o.__proto__=i,o}}():void 0)});var T2=g((bCe,O2)=>{"use strict";var $X=Zi(),LX=Gn(),Fm=Kc(),I2=t2(),jX=ot(),qX=u2(),y2=Dw(),b2=g2(),BX=Tm(),zX=Gi(),Lw=Dm(),UX=zr(),v2=Xc(),_2=$w(),WX=I2.PROPER,HX=I2.CONFIGURABLE,w2=_2.IteratorPrototype,Pm=_2.BUGGY_SAFARI_ITERATORS,nu=UX("iterator"),x2="keys",ou="values",E2="entries",S2=function(){return this};O2.exports=function(t,e,r,n,o,i,s){qX(r,e,n);var a=function(v){if(v===o&&p)return p;if(!Pm&&v in c)return c[v];switch(v){case x2:return function(){return new r(this,v)};case ou:return function(){return new r(this,v)};case E2:return function(){return new r(this,v)}}return function(){return new r(this)}},l=e+" Iterator",u=!1,c=t.prototype,f=c[nu]||c["@@iterator"]||o&&c[o],p=!Pm&&f||a(o),d=e==="Array"&&c.entries||f,h,b,y;if(d&&(h=y2(d.call(new t)),h!==Object.prototype&&h.next&&(!Fm&&y2(h)!==w2&&(b2?b2(h,w2):jX(h[nu])||Lw(h,nu,S2)),BX(h,l,!0,!0),Fm&&(v2[l]=S2))),WX&&o===ou&&f&&f.name!==ou&&(!Fm&&HX?zX(c,"name",ou):(u=!0,p=function(){return LX(f,this)})),o)if(b={values:a(ou),keys:i?p:a(x2),entries:a(E2)},s)for(y in b)(Pm||u||!(y in c))&&Lw(c,y,b[y]);else $X({target:e,proto:!0,forced:Pm||u},b);return(!Fm||s)&&c[nu]!==p&&Lw(c,nu,p,{name:o}),v2[e]=p,b}});var A2=g((vCe,C2)=>{"use strict";C2.exports=function(t,e){return{value:t,done:e}}});var N2=g((wCe,R2)=>{"use strict";var KX=Ki(),VX=Aw(),GX=zr(),ZX=Sr(),k2=GX("species");R2.exports=function(t){var e=KX(t);ZX&&e&&!e[k2]&&VX(e,k2,{configurable:!0,get:function(){return this}})}});var L2=g((xCe,$2)=>{"use strict";var JX=ru(),YX=Aw(),D2=XM(),XX=Zc(),QX=vw(),eQ=ba(),tQ=Qc(),rQ=T2(),Mm=A2(),nQ=N2(),iu=Sr(),F2=yw().fastKey,M2=_w(),P2=M2.set,jw=M2.getterFor;$2.exports={getConstructor:function(t,e,r,n){var o=t(function(u,c){QX(u,i),P2(u,{type:e,index:JX(null),first:void 0,last:void 0,size:0}),iu||(u.size=0),eQ(c)||tQ(c,u[n],{that:u,AS_ENTRIES:r})}),i=o.prototype,s=jw(e),a=function(u,c,f){var p=s(u),d=l(u,c),h,b;return d?d.value=f:(p.last=d={index:b=F2(c,!0),key:c,value:f,previous:h=p.last,next:void 0,removed:!1},p.first||(p.first=d),h&&(h.next=d),iu?p.size++:u.size++,b!=="F"&&(p.index[b]=d)),u},l=function(u,c){var f=s(u),p=F2(c),d;if(p!=="F")return f.index[p];for(d=f.first;d;d=d.next)if(d.key===c)return d};return D2(i,{clear:function(){for(var c=this,f=s(c),p=f.index,d=f.first;d;)d.removed=!0,d.previous&&(d.previous=d.previous.next=void 0),delete p[d.index],d=d.next;f.first=f.last=void 0,iu?f.size=0:c.size=0},delete:function(u){var c=this,f=s(c),p=l(c,u);if(p){var d=p.next,h=p.previous;delete f.index[p.index],p.removed=!0,h&&(h.next=d),d&&(d.previous=h),f.first===p&&(f.first=d),f.last===p&&(f.last=h),iu?f.size--:c.size--}return!!p},forEach:function(c){for(var f=s(this),p=XX(c,arguments.length>1?arguments[1]:void 0),d;d=d?d.next:f.first;)for(p(d.value,d.key,this);d&&d.removed;)d=d.previous},has:function(c){return!!l(this,c)}}),D2(i,r?{get:function(c){var f=l(this,c);return f&&f.value},set:function(c,f){return a(this,c===0?0:c,f)}}:{add:function(c){return a(this,c=c===0?0:c,c)}}),iu&&YX(i,"size",{configurable:!0,get:function(){return s(this).size}}),o},setStrong:function(t,e,r){var n=e+" Iterator",o=jw(e),i=jw(n);rQ(t,e,function(s,a){P2(this,{type:n,target:s,state:o(s),kind:a,last:void 0})},function(){for(var s=i(this),a=s.kind,l=s.last;l&&l.removed;)l=l.previous;return!s.target||!(s.last=l=l?l.next:s.state.first)?(s.target=void 0,Mm(void 0,!0)):Mm(a==="keys"?l.key:a==="values"?l.value:[l.key,l.value],!1)},r?"entries":"values",!r,!0),nQ(e)}}});var j2=g(()=>{"use strict";var oQ=PM(),iQ=L2();oQ("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},iQ)});var q2=g(()=>{"use strict";j2()});var z2=g((OCe,B2)=>{"use strict";B2.exports=function(t,e){return e===1?function(r,n){return r[t](n)}:function(r,n,o){return r[t](n,o)}}});var H2=g((TCe,W2)=>{"use strict";var sQ=Ki(),$m=z2(),U2=sQ("Map");W2.exports={Map:U2,set:$m("set",2),get:$m("get",1),has:$m("has",1),remove:$m("delete",1),proto:U2.prototype}});var K2=g(()=>{"use strict";var aQ=Zi(),lQ=_t(),cQ=Vi(),uQ=Wc(),fQ=Qc(),Lm=H2(),pQ=Kc(),dQ=Lm.Map,mQ=Lm.has,hQ=Lm.get,gQ=Lm.set,yQ=lQ([].push);aQ({target:"Map",stat:!0,forced:pQ},{groupBy:function(e,r){uQ(e),cQ(r);var n=new dQ,o=0;return fQ(e,function(i){var s=r(i,o++);mQ(n,s)?yQ(hQ(n,s),i):gQ(n,s,[i])}),n}})});var Z2=g((kCe,G2)=>{"use strict";q2();K2();var bQ=Gn(),vQ=ot(),wQ=Hc(),V2=wQ.Map,xQ=V2.groupBy;G2.exports=function(e,r,n){return bQ(xQ,vQ(this)?this:V2,e,r,n)}});var Y2=g((RCe,J2)=>{"use strict";var EQ=Z2();J2.exports=EQ});var X2=g(()=>{"use strict";var SQ=Zi(),IQ=Sr(),_Q=ru();SQ({target:"Object",stat:!0,sham:!IQ},{create:_Q})});var Q2=g(()=>{"use strict";var OQ=Zi(),TQ=Ki(),CQ=_t(),AQ=Vi(),kQ=Wc(),RQ=Vc(),NQ=Qc(),DQ=TQ("Object","create"),FQ=CQ([].push);OQ({target:"Object",stat:!0},{groupBy:function(e,r){kQ(e),AQ(r);var n=DQ(null),o=0;return NQ(e,function(i){var s=RQ(r(i,o++));s in n?FQ(n[s],i):n[s]=[i]}),n}})});var t$=g((MCe,e$)=>{"use strict";X2();Q2();var PQ=Hc();e$.exports=PQ.Object.groupBy});var n$=g(($Ce,r$)=>{"use strict";var MQ=t$();r$.exports=MQ});var S$=g(E$=>{"use strict";var _a=(S(),$g(Nr));function QQ(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var eee=typeof Object.is=="function"?Object.is:QQ,tee=_a.useState,ree=_a.useEffect,nee=_a.useLayoutEffect,oee=_a.useDebugValue;function iee(t,e){var r=e(),n=tee({inst:{value:r,getSnapshot:e}}),o=n[0].inst,i=n[1];return nee(function(){o.value=r,o.getSnapshot=e,ox(o)&&i({inst:o})},[t,r,e]),ree(function(){return ox(o)&&i({inst:o}),t(function(){ox(o)&&i({inst:o})})},[t]),oee(r),r}function ox(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!eee(t,r)}catch{return!0}}function see(t,e){return e()}var aee=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?see:iee;E$.useSyncExternalStore=_a.useSyncExternalStore!==void 0?_a.useSyncExternalStore:aee});var _$=g((iRe,I$)=>{"use strict";I$.exports=S$()});var T$=g(O$=>{"use strict";var Ym=(S(),$g(Nr)),lee=_$();function cee(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var uee=typeof Object.is=="function"?Object.is:cee,fee=lee.useSyncExternalStore,pee=Ym.useRef,dee=Ym.useEffect,mee=Ym.useMemo,hee=Ym.useDebugValue;O$.useSyncExternalStoreWithSelector=function(t,e,r,n,o){var i=pee(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=mee(function(){function l(d){if(!u){if(u=!0,c=d,d=n(d),o!==void 0&&s.hasValue){var h=s.value;if(o(h,d))return f=h}return f=d}if(h=f,uee(c,d))return h;var b=n(d);return o!==void 0&&o(h,b)?h:(c=d,f=b)}var u=!1,c,f,p=r===void 0?null:r;return[function(){return l(e())},p===null?void 0:function(){return l(p())}]},[e,r,n,o]);var a=fee(t,i[0],i[1]);return dee(function(){s.hasValue=!0,s.value=a},[a]),hee(a),a}});var A$=g((aRe,C$)=>{"use strict";C$.exports=T$()});var Go=g((Y$e,eo)=>{function Px(){return eo.exports=Px=Object.assign?Object.assign.bind():function(t){for(var e=1;e{function Ux(t){return to.exports=Ux=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},to.exports.__esModule=!0,to.exports.default=to.exports,Ux(t)}to.exports=Ux,to.exports.__esModule=!0,to.exports.default=to.exports});var Cj=g((kLe,Iu)=>{var Tj=gh().default;function tne(t,e){if(Tj(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(Tj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}Iu.exports=tne,Iu.exports.__esModule=!0,Iu.exports.default=Iu.exports});var Aj=g((RLe,_u)=>{var rne=gh().default,nne=Cj();function one(t){var e=nne(t,"string");return rne(e)==="symbol"?e:String(e)}_u.exports=one,_u.exports.__esModule=!0,_u.exports.default=_u.exports});var kj=g((NLe,Ou)=>{var ine=Aj();function sne(t,e,r){return e=ine(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Ou.exports=sne,Ou.exports.__esModule=!0,Ou.exports.default=Ou.exports});var Rj=g((DLe,Tu)=>{function ane(t){if(Array.isArray(t))return t}Tu.exports=ane,Tu.exports.__esModule=!0,Tu.exports.default=Tu.exports});var Nj=g((FLe,Cu)=>{function lne(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,o,i,s,a=[],l=!0,u=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(a.push(n.value),a.length!==e);l=!0);}catch(c){u=!0,o=c}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(u)throw o}}return a}}Cu.exports=lne,Cu.exports.__esModule=!0,Cu.exports.default=Cu.exports});var Dj=g((PLe,Au)=>{function cne(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r{var Fj=Dj();function une(t,e){if(t){if(typeof t=="string")return Fj(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Fj(t,e)}}ku.exports=une,ku.exports.__esModule=!0,ku.exports.default=ku.exports});var Mj=g(($Le,Ru)=>{function fne(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. -In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}Ru.exports=fne,Ru.exports.__esModule=!0,Ru.exports.default=Ru.exports});var $j=g((LLe,Nu)=>{var pne=Rj(),dne=Nj(),mne=Pj(),hne=Mj();function gne(t,e){return pne(t)||dne(t,e)||mne(t,e)||hne()}Nu.exports=gne,Nu.exports.__esModule=!0,Nu.exports.default=Nu.exports});var jj=g((yh,Lj)=>{"use strict";yh.__esModule=!0;yh.default={scheme:"threezerotwofour",author:"jan t. sott (http://github.com/idleberg)",base00:"#090300",base01:"#3a3432",base02:"#4a4543",base03:"#5c5855",base04:"#807d7c",base05:"#a5a2a2",base06:"#d6d5d4",base07:"#f7f7f7",base08:"#db2d20",base09:"#e8bbd0",base0A:"#fded02",base0B:"#01a252",base0C:"#b5e4f4",base0D:"#01a0e4",base0E:"#a16a94",base0F:"#cdab53"};Lj.exports=yh.default});var Bj=g((bh,qj)=>{"use strict";bh.__esModule=!0;bh.default={scheme:"apathy",author:"jannik siebert (https://github.com/janniks)",base00:"#031A16",base01:"#0B342D",base02:"#184E45",base03:"#2B685E",base04:"#5F9C92",base05:"#81B5AC",base06:"#A7CEC8",base07:"#D2E7E4",base08:"#3E9688",base09:"#3E7996",base0A:"#3E4C96",base0B:"#883E96",base0C:"#963E4C",base0D:"#96883E",base0E:"#4C963E",base0F:"#3E965B"};qj.exports=bh.default});var Uj=g((vh,zj)=>{"use strict";vh.__esModule=!0;vh.default={scheme:"ashes",author:"jannik siebert (https://github.com/janniks)",base00:"#1C2023",base01:"#393F45",base02:"#565E65",base03:"#747C84",base04:"#ADB3BA",base05:"#C7CCD1",base06:"#DFE2E5",base07:"#F3F4F5",base08:"#C7AE95",base09:"#C7C795",base0A:"#AEC795",base0B:"#95C7AE",base0C:"#95AEC7",base0D:"#AE95C7",base0E:"#C795AE",base0F:"#C79595"};zj.exports=vh.default});var Hj=g((wh,Wj)=>{"use strict";wh.__esModule=!0;wh.default={scheme:"atelier dune",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune)",base00:"#20201d",base01:"#292824",base02:"#6e6b5e",base03:"#7d7a68",base04:"#999580",base05:"#a6a28c",base06:"#e8e4cf",base07:"#fefbec",base08:"#d73737",base09:"#b65611",base0A:"#cfb017",base0B:"#60ac39",base0C:"#1fad83",base0D:"#6684e1",base0E:"#b854d4",base0F:"#d43552"};Wj.exports=wh.default});var Vj=g((xh,Kj)=>{"use strict";xh.__esModule=!0;xh.default={scheme:"atelier forest",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest)",base00:"#1b1918",base01:"#2c2421",base02:"#68615e",base03:"#766e6b",base04:"#9c9491",base05:"#a8a19f",base06:"#e6e2e0",base07:"#f1efee",base08:"#f22c40",base09:"#df5320",base0A:"#d5911a",base0B:"#5ab738",base0C:"#00ad9c",base0D:"#407ee7",base0E:"#6666ea",base0F:"#c33ff3"};Kj.exports=xh.default});var Zj=g((Eh,Gj)=>{"use strict";Eh.__esModule=!0;Eh.default={scheme:"atelier heath",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath)",base00:"#1b181b",base01:"#292329",base02:"#695d69",base03:"#776977",base04:"#9e8f9e",base05:"#ab9bab",base06:"#d8cad8",base07:"#f7f3f7",base08:"#ca402b",base09:"#a65926",base0A:"#bb8a35",base0B:"#379a37",base0C:"#159393",base0D:"#516aec",base0E:"#7b59c0",base0F:"#cc33cc"};Gj.exports=Eh.default});var Yj=g((Sh,Jj)=>{"use strict";Sh.__esModule=!0;Sh.default={scheme:"atelier lakeside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside/)",base00:"#161b1d",base01:"#1f292e",base02:"#516d7b",base03:"#5a7b8c",base04:"#7195a8",base05:"#7ea2b4",base06:"#c1e4f6",base07:"#ebf8ff",base08:"#d22d72",base09:"#935c25",base0A:"#8a8a0f",base0B:"#568c3b",base0C:"#2d8f6f",base0D:"#257fad",base0E:"#5d5db1",base0F:"#b72dd2"};Jj.exports=Sh.default});var Qj=g((Ih,Xj)=>{"use strict";Ih.__esModule=!0;Ih.default={scheme:"atelier seaside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside/)",base00:"#131513",base01:"#242924",base02:"#5e6e5e",base03:"#687d68",base04:"#809980",base05:"#8ca68c",base06:"#cfe8cf",base07:"#f0fff0",base08:"#e6193c",base09:"#87711d",base0A:"#c3c322",base0B:"#29a329",base0C:"#1999b3",base0D:"#3d62f5",base0E:"#ad2bee",base0F:"#e619c3"};Xj.exports=Ih.default});var t3=g((_h,e3)=>{"use strict";_h.__esModule=!0;_h.default={scheme:"bespin",author:"jan t. sott",base00:"#28211c",base01:"#36312e",base02:"#5e5d5c",base03:"#666666",base04:"#797977",base05:"#8a8986",base06:"#9d9b97",base07:"#baae9e",base08:"#cf6a4c",base09:"#cf7d34",base0A:"#f9ee98",base0B:"#54be0d",base0C:"#afc4db",base0D:"#5ea6ea",base0E:"#9b859d",base0F:"#937121"};e3.exports=_h.default});var n3=g((Oh,r3)=>{"use strict";Oh.__esModule=!0;Oh.default={scheme:"brewer",author:"timoth\xE9e poisot (http://github.com/tpoisot)",base00:"#0c0d0e",base01:"#2e2f30",base02:"#515253",base03:"#737475",base04:"#959697",base05:"#b7b8b9",base06:"#dadbdc",base07:"#fcfdfe",base08:"#e31a1c",base09:"#e6550d",base0A:"#dca060",base0B:"#31a354",base0C:"#80b1d3",base0D:"#3182bd",base0E:"#756bb1",base0F:"#b15928"};r3.exports=Oh.default});var i3=g((Th,o3)=>{"use strict";Th.__esModule=!0;Th.default={scheme:"bright",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#303030",base02:"#505050",base03:"#b0b0b0",base04:"#d0d0d0",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ffffff",base08:"#fb0120",base09:"#fc6d24",base0A:"#fda331",base0B:"#a1c659",base0C:"#76c7b7",base0D:"#6fb3d2",base0E:"#d381c3",base0F:"#be643c"};o3.exports=Th.default});var a3=g((Ch,s3)=>{"use strict";Ch.__esModule=!0;Ch.default={scheme:"chalk",author:"chris kempson (http://chriskempson.com)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#f5f5f5",base08:"#fb9fb1",base09:"#eda987",base0A:"#ddb26f",base0B:"#acc267",base0C:"#12cfc0",base0D:"#6fc2ef",base0E:"#e1a3ee",base0F:"#deaf8f"};s3.exports=Ch.default});var c3=g((Ah,l3)=>{"use strict";Ah.__esModule=!0;Ah.default={scheme:"codeschool",author:"brettof86",base00:"#232c31",base01:"#1c3657",base02:"#2a343a",base03:"#3f4944",base04:"#84898c",base05:"#9ea7a6",base06:"#a7cfa3",base07:"#b5d8f6",base08:"#2a5491",base09:"#43820d",base0A:"#a03b1e",base0B:"#237986",base0C:"#b02f30",base0D:"#484d79",base0E:"#c59820",base0F:"#c98344"};l3.exports=Ah.default});var f3=g((kh,u3)=>{"use strict";kh.__esModule=!0;kh.default={scheme:"colors",author:"mrmrs (http://clrs.cc)",base00:"#111111",base01:"#333333",base02:"#555555",base03:"#777777",base04:"#999999",base05:"#bbbbbb",base06:"#dddddd",base07:"#ffffff",base08:"#ff4136",base09:"#ff851b",base0A:"#ffdc00",base0B:"#2ecc40",base0C:"#7fdbff",base0D:"#0074d9",base0E:"#b10dc9",base0F:"#85144b"};u3.exports=kh.default});var d3=g((Rh,p3)=>{"use strict";Rh.__esModule=!0;Rh.default={scheme:"default",author:"chris kempson (http://chriskempson.com)",base00:"#181818",base01:"#282828",base02:"#383838",base03:"#585858",base04:"#b8b8b8",base05:"#d8d8d8",base06:"#e8e8e8",base07:"#f8f8f8",base08:"#ab4642",base09:"#dc9656",base0A:"#f7ca88",base0B:"#a1b56c",base0C:"#86c1b9",base0D:"#7cafc2",base0E:"#ba8baf",base0F:"#a16946"};p3.exports=Rh.default});var h3=g((Nh,m3)=>{"use strict";Nh.__esModule=!0;Nh.default={scheme:"eighties",author:"chris kempson (http://chriskempson.com)",base00:"#2d2d2d",base01:"#393939",base02:"#515151",base03:"#747369",base04:"#a09f93",base05:"#d3d0c8",base06:"#e8e6df",base07:"#f2f0ec",base08:"#f2777a",base09:"#f99157",base0A:"#ffcc66",base0B:"#99cc99",base0C:"#66cccc",base0D:"#6699cc",base0E:"#cc99cc",base0F:"#d27b53"};m3.exports=Nh.default});var y3=g((Dh,g3)=>{"use strict";Dh.__esModule=!0;Dh.default={scheme:"embers",author:"jannik siebert (https://github.com/janniks)",base00:"#16130F",base01:"#2C2620",base02:"#433B32",base03:"#5A5047",base04:"#8A8075",base05:"#A39A90",base06:"#BEB6AE",base07:"#DBD6D1",base08:"#826D57",base09:"#828257",base0A:"#6D8257",base0B:"#57826D",base0C:"#576D82",base0D:"#6D5782",base0E:"#82576D",base0F:"#825757"};g3.exports=Dh.default});var v3=g((Fh,b3)=>{"use strict";Fh.__esModule=!0;Fh.default={scheme:"flat",author:"chris kempson (http://chriskempson.com)",base00:"#2C3E50",base01:"#34495E",base02:"#7F8C8D",base03:"#95A5A6",base04:"#BDC3C7",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ECF0F1",base08:"#E74C3C",base09:"#E67E22",base0A:"#F1C40F",base0B:"#2ECC71",base0C:"#1ABC9C",base0D:"#3498DB",base0E:"#9B59B6",base0F:"#be643c"};b3.exports=Fh.default});var x3=g((Ph,w3)=>{"use strict";Ph.__esModule=!0;Ph.default={scheme:"google",author:"seth wright (http://sethawright.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#CC342B",base09:"#F96A38",base0A:"#FBA922",base0B:"#198844",base0C:"#3971ED",base0D:"#3971ED",base0E:"#A36AC7",base0F:"#3971ED"};w3.exports=Ph.default});var S3=g((Mh,E3)=>{"use strict";Mh.__esModule=!0;Mh.default={scheme:"grayscale",author:"alexandre gavioli (https://github.com/alexx2/)",base00:"#101010",base01:"#252525",base02:"#464646",base03:"#525252",base04:"#ababab",base05:"#b9b9b9",base06:"#e3e3e3",base07:"#f7f7f7",base08:"#7c7c7c",base09:"#999999",base0A:"#a0a0a0",base0B:"#8e8e8e",base0C:"#868686",base0D:"#686868",base0E:"#747474",base0F:"#5e5e5e"};E3.exports=Mh.default});var _3=g(($h,I3)=>{"use strict";$h.__esModule=!0;$h.default={scheme:"green screen",author:"chris kempson (http://chriskempson.com)",base00:"#001100",base01:"#003300",base02:"#005500",base03:"#007700",base04:"#009900",base05:"#00bb00",base06:"#00dd00",base07:"#00ff00",base08:"#007700",base09:"#009900",base0A:"#007700",base0B:"#00bb00",base0C:"#005500",base0D:"#009900",base0E:"#00bb00",base0F:"#005500"};I3.exports=$h.default});var T3=g((Lh,O3)=>{"use strict";Lh.__esModule=!0;Lh.default={scheme:"harmonic16",author:"jannik siebert (https://github.com/janniks)",base00:"#0b1c2c",base01:"#223b54",base02:"#405c79",base03:"#627e99",base04:"#aabcce",base05:"#cbd6e2",base06:"#e5ebf1",base07:"#f7f9fb",base08:"#bf8b56",base09:"#bfbf56",base0A:"#8bbf56",base0B:"#56bf8b",base0C:"#568bbf",base0D:"#8b56bf",base0E:"#bf568b",base0F:"#bf5656"};O3.exports=Lh.default});var A3=g((jh,C3)=>{"use strict";jh.__esModule=!0;jh.default={scheme:"hopscotch",author:"jan t. sott",base00:"#322931",base01:"#433b42",base02:"#5c545b",base03:"#797379",base04:"#989498",base05:"#b9b5b8",base06:"#d5d3d5",base07:"#ffffff",base08:"#dd464c",base09:"#fd8b19",base0A:"#fdcc59",base0B:"#8fc13e",base0C:"#149b93",base0D:"#1290bf",base0E:"#c85e7c",base0F:"#b33508"};C3.exports=jh.default});var R3=g((qh,k3)=>{"use strict";qh.__esModule=!0;qh.default={scheme:"isotope",author:"jan t. sott",base00:"#000000",base01:"#404040",base02:"#606060",base03:"#808080",base04:"#c0c0c0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#ff0000",base09:"#ff9900",base0A:"#ff0099",base0B:"#33ff00",base0C:"#00ffff",base0D:"#0066ff",base0E:"#cc00ff",base0F:"#3300ff"};k3.exports=qh.default});var D3=g((Bh,N3)=>{"use strict";Bh.__esModule=!0;Bh.default={scheme:"marrakesh",author:"alexandre gavioli (http://github.com/alexx2/)",base00:"#201602",base01:"#302e00",base02:"#5f5b17",base03:"#6c6823",base04:"#86813b",base05:"#948e48",base06:"#ccc37a",base07:"#faf0a5",base08:"#c35359",base09:"#b36144",base0A:"#a88339",base0B:"#18974e",base0C:"#75a738",base0D:"#477ca1",base0E:"#8868b3",base0F:"#b3588e"};N3.exports=Bh.default});var P3=g((zh,F3)=>{"use strict";zh.__esModule=!0;zh.default={scheme:"mocha",author:"chris kempson (http://chriskempson.com)",base00:"#3B3228",base01:"#534636",base02:"#645240",base03:"#7e705a",base04:"#b8afad",base05:"#d0c8c6",base06:"#e9e1dd",base07:"#f5eeeb",base08:"#cb6077",base09:"#d28b71",base0A:"#f4bc87",base0B:"#beb55b",base0C:"#7bbda4",base0D:"#8ab3b5",base0E:"#a89bb9",base0F:"#bb9584"};F3.exports=zh.default});var $3=g((Uh,M3)=>{"use strict";Uh.__esModule=!0;Uh.default={scheme:"monokai",author:"wimer hazenberg (http://www.monokai.nl)",base00:"#272822",base01:"#383830",base02:"#49483e",base03:"#75715e",base04:"#a59f85",base05:"#f8f8f2",base06:"#f5f4f1",base07:"#f9f8f5",base08:"#f92672",base09:"#fd971f",base0A:"#f4bf75",base0B:"#a6e22e",base0C:"#a1efe4",base0D:"#66d9ef",base0E:"#ae81ff",base0F:"#cc6633"};M3.exports=Uh.default});var j3=g((Wh,L3)=>{"use strict";Wh.__esModule=!0;Wh.default={scheme:"ocean",author:"chris kempson (http://chriskempson.com)",base00:"#2b303b",base01:"#343d46",base02:"#4f5b66",base03:"#65737e",base04:"#a7adba",base05:"#c0c5ce",base06:"#dfe1e8",base07:"#eff1f5",base08:"#bf616a",base09:"#d08770",base0A:"#ebcb8b",base0B:"#a3be8c",base0C:"#96b5b4",base0D:"#8fa1b3",base0E:"#b48ead",base0F:"#ab7967"};L3.exports=Wh.default});var B3=g((Hh,q3)=>{"use strict";Hh.__esModule=!0;Hh.default={scheme:"paraiso",author:"jan t. sott",base00:"#2f1e2e",base01:"#41323f",base02:"#4f424c",base03:"#776e71",base04:"#8d8687",base05:"#a39e9b",base06:"#b9b6b0",base07:"#e7e9db",base08:"#ef6155",base09:"#f99b15",base0A:"#fec418",base0B:"#48b685",base0C:"#5bc4bf",base0D:"#06b6ef",base0E:"#815ba4",base0F:"#e96ba8"};q3.exports=Hh.default});var U3=g((Kh,z3)=>{"use strict";Kh.__esModule=!0;Kh.default={scheme:"pop",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#eb008a",base09:"#f29333",base0A:"#f8ca12",base0B:"#37b349",base0C:"#00aabb",base0D:"#0e5a94",base0E:"#b31e8d",base0F:"#7a2d00"};z3.exports=Kh.default});var H3=g((Vh,W3)=>{"use strict";Vh.__esModule=!0;Vh.default={scheme:"railscasts",author:"ryan bates (http://railscasts.com)",base00:"#2b2b2b",base01:"#272935",base02:"#3a4055",base03:"#5a647e",base04:"#d4cfc9",base05:"#e6e1dc",base06:"#f4f1ed",base07:"#f9f7f3",base08:"#da4939",base09:"#cc7833",base0A:"#ffc66d",base0B:"#a5c261",base0C:"#519f50",base0D:"#6d9cbe",base0E:"#b6b3eb",base0F:"#bc9458"};W3.exports=Vh.default});var V3=g((Gh,K3)=>{"use strict";Gh.__esModule=!0;Gh.default={scheme:"shapeshifter",author:"tyler benziger (http://tybenz.com)",base00:"#000000",base01:"#040404",base02:"#102015",base03:"#343434",base04:"#555555",base05:"#ababab",base06:"#e0e0e0",base07:"#f9f9f9",base08:"#e92f2f",base09:"#e09448",base0A:"#dddd13",base0B:"#0ed839",base0C:"#23edda",base0D:"#3b48e3",base0E:"#f996e2",base0F:"#69542d"};K3.exports=Gh.default});var Z3=g((Zh,G3)=>{"use strict";Zh.__esModule=!0;Zh.default={scheme:"solarized",author:"ethan schoonover (http://ethanschoonover.com/solarized)",base00:"#002b36",base01:"#073642",base02:"#586e75",base03:"#657b83",base04:"#839496",base05:"#93a1a1",base06:"#eee8d5",base07:"#fdf6e3",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"};G3.exports=Zh.default});var Y3=g((Jh,J3)=>{"use strict";Jh.__esModule=!0;Jh.default={scheme:"summerfruit",author:"christopher corley (http://cscorley.github.io/)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#B0B0B0",base05:"#D0D0D0",base06:"#E0E0E0",base07:"#FFFFFF",base08:"#FF0086",base09:"#FD8900",base0A:"#ABA800",base0B:"#00C918",base0C:"#1faaaa",base0D:"#3777E6",base0E:"#AD00A1",base0F:"#cc6633"};J3.exports=Jh.default});var Q3=g((Yh,X3)=>{"use strict";Yh.__esModule=!0;Yh.default={scheme:"tomorrow",author:"chris kempson (http://chriskempson.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#cc6666",base09:"#de935f",base0A:"#f0c674",base0B:"#b5bd68",base0C:"#8abeb7",base0D:"#81a2be",base0E:"#b294bb",base0F:"#a3685a"};X3.exports=Yh.default});var t5=g((Xh,e5)=>{"use strict";Xh.__esModule=!0;Xh.default={scheme:"london tube",author:"jan t. sott",base00:"#231f20",base01:"#1c3f95",base02:"#5a5758",base03:"#737171",base04:"#959ca1",base05:"#d9d8d8",base06:"#e7e7e8",base07:"#ffffff",base08:"#ee2e24",base09:"#f386a1",base0A:"#ffd204",base0B:"#00853e",base0C:"#85cebc",base0D:"#009ddc",base0E:"#98005d",base0F:"#b06110"};e5.exports=Xh.default});var n5=g((Qh,r5)=>{"use strict";Qh.__esModule=!0;Qh.default={scheme:"twilight",author:"david hart (http://hart-dev.com)",base00:"#1e1e1e",base01:"#323537",base02:"#464b50",base03:"#5f5a60",base04:"#838184",base05:"#a7a7a7",base06:"#c3c3c3",base07:"#ffffff",base08:"#cf6a4c",base09:"#cda869",base0A:"#f9ee98",base0B:"#8f9d6a",base0C:"#afc4db",base0D:"#7587a6",base0E:"#9b859d",base0F:"#9b703f"};r5.exports=Qh.default});var o5=g(ae=>{"use strict";ae.__esModule=!0;function le(t){return t&&t.__esModule?t.default:t}var yne=jj();ae.threezerotwofour=le(yne);var bne=Bj();ae.apathy=le(bne);var vne=Uj();ae.ashes=le(vne);var wne=Hj();ae.atelierDune=le(wne);var xne=Vj();ae.atelierForest=le(xne);var Ene=Zj();ae.atelierHeath=le(Ene);var Sne=Yj();ae.atelierLakeside=le(Sne);var Ine=Qj();ae.atelierSeaside=le(Ine);var _ne=t3();ae.bespin=le(_ne);var One=n3();ae.brewer=le(One);var Tne=i3();ae.bright=le(Tne);var Cne=a3();ae.chalk=le(Cne);var Ane=c3();ae.codeschool=le(Ane);var kne=f3();ae.colors=le(kne);var Rne=d3();ae.default=le(Rne);var Nne=h3();ae.eighties=le(Nne);var Dne=y3();ae.embers=le(Dne);var Fne=v3();ae.flat=le(Fne);var Pne=x3();ae.google=le(Pne);var Mne=S3();ae.grayscale=le(Mne);var $ne=_3();ae.greenscreen=le($ne);var Lne=T3();ae.harmonic=le(Lne);var jne=A3();ae.hopscotch=le(jne);var qne=R3();ae.isotope=le(qne);var Bne=D3();ae.marrakesh=le(Bne);var zne=P3();ae.mocha=le(zne);var Une=$3();ae.monokai=le(Une);var Wne=j3();ae.ocean=le(Wne);var Hne=B3();ae.paraiso=le(Hne);var Kne=U3();ae.pop=le(Kne);var Vne=H3();ae.railscasts=le(Vne);var Gne=V3();ae.shapeshifter=le(Gne);var Zne=Z3();ae.solarized=le(Zne);var Jne=Y3();ae.summerfruit=le(Jne);var Yne=Q3();ae.tomorrow=le(Yne);var Xne=t5();ae.tube=le(Xne);var Qne=n5();ae.twilight=le(Qne)});var s5=g((qLe,i5)=>{"use strict";i5.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var l5=g((BLe,a5)=>{a5.exports=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")}});var f5=g((zLe,u5)=>{"use strict";var eoe=l5(),toe=Array.prototype.concat,roe=Array.prototype.slice,c5=u5.exports=function(e){for(var r=[],n=0,o=e.length;n{var Du=s5(),Fu=f5(),p5=Object.hasOwnProperty,d5=Object.create(null);for(eg in Du)p5.call(Du,eg)&&(d5[Du[eg]]=eg);var eg,tr=m5.exports={to:{},get:{}};tr.get=function(t){var e=t.substring(0,3).toLowerCase(),r,n;switch(e){case"hsl":r=tr.get.hsl(t),n="hsl";break;case"hwb":r=tr.get.hwb(t),n="hwb";break;default:r=tr.get.rgb(t),n="rgb";break}return r?{model:n,value:r}:null};tr.get.rgb=function(t){if(!t)return null;var e=/^#([a-f0-9]{3,4})$/i,r=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,n=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,o=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,i=/^(\w+)$/,s=[0,0,0,1],a,l,u;if(a=t.match(r)){for(u=a[2],a=a[1],l=0;l<3;l++){var c=l*2;s[l]=parseInt(a.slice(c,c+2),16)}u&&(s[3]=parseInt(u,16)/255)}else if(a=t.match(e)){for(a=a[1],u=a[3],l=0;l<3;l++)s[l]=parseInt(a[l]+a[l],16);u&&(s[3]=parseInt(u+u,16)/255)}else if(a=t.match(n)){for(l=0;l<3;l++)s[l]=parseInt(a[l+1],0);a[4]&&(a[5]?s[3]=parseFloat(a[4])*.01:s[3]=parseFloat(a[4]))}else if(a=t.match(o)){for(l=0;l<3;l++)s[l]=Math.round(parseFloat(a[l+1])*2.55);a[4]&&(a[5]?s[3]=parseFloat(a[4])*.01:s[3]=parseFloat(a[4]))}else return(a=t.match(i))?a[1]==="transparent"?[0,0,0,0]:p5.call(Du,a[1])?(s=Du[a[1]],s[3]=1,s):null:null;for(l=0;l<3;l++)s[l]=Jo(s[l],0,255);return s[3]=Jo(s[3],0,1),s};tr.get.hsl=function(t){if(!t)return null;var e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=t.match(e);if(r){var n=parseFloat(r[4]),o=(parseFloat(r[1])%360+360)%360,i=Jo(parseFloat(r[2]),0,100),s=Jo(parseFloat(r[3]),0,100),a=Jo(isNaN(n)?1:n,0,1);return[o,i,s,a]}return null};tr.get.hwb=function(t){if(!t)return null;var e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=t.match(e);if(r){var n=parseFloat(r[4]),o=(parseFloat(r[1])%360+360)%360,i=Jo(parseFloat(r[2]),0,100),s=Jo(parseFloat(r[3]),0,100),a=Jo(isNaN(n)?1:n,0,1);return[o,i,s,a]}return null};tr.to.hex=function(){var t=Fu(arguments);return"#"+tg(t[0])+tg(t[1])+tg(t[2])+(t[3]<1?tg(Math.round(t[3]*255)):"")};tr.to.rgb=function(){var t=Fu(arguments);return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};tr.to.rgb.percent=function(){var t=Fu(arguments),e=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+r+"%, "+n+"%)":"rgba("+e+"%, "+r+"%, "+n+"%, "+t[3]+")"};tr.to.hsl=function(){var t=Fu(arguments);return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};tr.to.hwb=function(){var t=Fu(arguments),e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};tr.to.keyword=function(t){return d5[t.slice(0,3)]};function Jo(t,e,r){return Math.min(Math.max(e,t),r)}function tg(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}});var y5=g((WLe,g5)=>{"use strict";g5.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var Wx=g((HLe,x5)=>{var as=y5(),w5={};for(rg in as)as.hasOwnProperty(rg)&&(w5[as[rg]]=rg);var rg,j=x5.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(Tt in j)if(j.hasOwnProperty(Tt)){if(!("channels"in j[Tt]))throw new Error("missing channels property: "+Tt);if(!("labels"in j[Tt]))throw new Error("missing channel labels property: "+Tt);if(j[Tt].labels.length!==j[Tt].channels)throw new Error("channel and label counts mismatch: "+Tt);b5=j[Tt].channels,v5=j[Tt].labels,delete j[Tt].channels,delete j[Tt].labels,Object.defineProperty(j[Tt],"channels",{value:b5}),Object.defineProperty(j[Tt],"labels",{value:v5})}var b5,v5,Tt;j.rgb.hsl=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=Math.min(e,r,n),i=Math.max(e,r,n),s=i-o,a,l,u;return i===o?a=0:e===i?a=(r-n)/s:r===i?a=2+(n-e)/s:n===i&&(a=4+(e-r)/s),a=Math.min(a*60,360),a<0&&(a+=360),u=(o+i)/2,i===o?l=0:u<=.5?l=s/(i+o):l=s/(2-i-o),[a,l*100,u*100]};j.rgb.hsv=function(t){var e,r,n,o,i,s=t[0]/255,a=t[1]/255,l=t[2]/255,u=Math.max(s,a,l),c=u-Math.min(s,a,l),f=function(p){return(u-p)/6/c+1/2};return c===0?o=i=0:(i=c/u,e=f(s),r=f(a),n=f(l),s===u?o=n-r:a===u?o=1/3+e-n:l===u&&(o=2/3+r-e),o<0?o+=1:o>1&&(o-=1)),[o*360,i*100,u*100]};j.rgb.hwb=function(t){var e=t[0],r=t[1],n=t[2],o=j.rgb.hsl(t)[0],i=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[o,i*100,n*100]};j.rgb.cmyk=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o,i,s,a;return a=Math.min(1-e,1-r,1-n),o=(1-e-a)/(1-a)||0,i=(1-r-a)/(1-a)||0,s=(1-n-a)/(1-a)||0,[o*100,i*100,s*100,a*100]};function noe(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}j.rgb.keyword=function(t){var e=w5[t];if(e)return e;var r=1/0,n;for(var o in as)if(as.hasOwnProperty(o)){var i=as[o],s=noe(t,i);s.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var o=e*.4124+r*.3576+n*.1805,i=e*.2126+r*.7152+n*.0722,s=e*.0193+r*.1192+n*.9505;return[o*100,i*100,s*100]};j.rgb.lab=function(t){var e=j.rgb.xyz(t),r=e[0],n=e[1],o=e[2],i,s,a;return r/=95.047,n/=100,o/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=116*n-16,s=500*(r-n),a=200*(n-o),[i,s,a]};j.hsl.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,o,i,s,a,l;if(r===0)return l=n*255,[l,l,l];n<.5?i=n*(1+r):i=n+r-n*r,o=2*n-i,a=[0,0,0];for(var u=0;u<3;u++)s=e+1/3*-(u-1),s<0&&s++,s>1&&s--,6*s<1?l=o+(i-o)*6*s:2*s<1?l=i:3*s<2?l=o+(i-o)*(2/3-s)*6:l=o,a[u]=l*255;return a};j.hsl.hsv=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,o=r,i=Math.max(n,.01),s,a;return n*=2,r*=n<=1?n:2-n,o*=i<=1?i:2-i,a=(n+r)/2,s=n===0?2*o/(i+o):2*r/(n+r),[e,s*100,a*100]};j.hsv.rgb=function(t){var e=t[0]/60,r=t[1]/100,n=t[2]/100,o=Math.floor(e)%6,i=e-Math.floor(e),s=255*n*(1-r),a=255*n*(1-r*i),l=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,l,s];case 1:return[a,n,s];case 2:return[s,n,l];case 3:return[s,a,n];case 4:return[l,s,n];case 5:return[n,s,a]}};j.hsv.hsl=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,o=Math.max(n,.01),i,s,a;return a=(2-r)*n,i=(2-r)*o,s=r*o,s/=i<=1?i:2-i,s=s||0,a/=2,[e,s*100,a*100]};j.hwb.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,o=r+n,i,s,a,l;o>1&&(r/=o,n/=o),i=Math.floor(6*e),s=1-n,a=6*e-i,i&1&&(a=1-a),l=r+a*(s-r);var u,c,f;switch(i){default:case 6:case 0:u=s,c=l,f=r;break;case 1:u=l,c=s,f=r;break;case 2:u=r,c=s,f=l;break;case 3:u=r,c=l,f=s;break;case 4:u=l,c=r,f=s;break;case 5:u=s,c=r,f=l;break}return[u*255,c*255,f*255]};j.cmyk.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,o=t[3]/100,i,s,a;return i=1-Math.min(1,e*(1-o)+o),s=1-Math.min(1,r*(1-o)+o),a=1-Math.min(1,n*(1-o)+o),[i*255,s*255,a*255]};j.xyz.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,o,i,s;return o=e*3.2406+r*-1.5372+n*-.4986,i=e*-.9689+r*1.8758+n*.0415,s=e*.0557+r*-.204+n*1.057,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[o*255,i*255,s*255]};j.xyz.lab=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return e/=95.047,r/=100,n/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=116*r-16,i=500*(e-r),s=200*(r-n),[o,i,s]};j.lab.xyz=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;i=(e+16)/116,o=r/500+i,s=i-n/200;var a=Math.pow(i,3),l=Math.pow(o,3),u=Math.pow(s,3);return i=a>.008856?a:(i-16/116)/7.787,o=l>.008856?l:(o-16/116)/7.787,s=u>.008856?u:(s-16/116)/7.787,o*=95.047,i*=100,s*=108.883,[o,i,s]};j.lab.lch=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return o=Math.atan2(n,r),i=o*360/2/Math.PI,i<0&&(i+=360),s=Math.sqrt(r*r+n*n),[e,s,i]};j.lch.lab=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return s=n/360*2*Math.PI,o=r*Math.cos(s),i=r*Math.sin(s),[e,o,i]};j.rgb.ansi16=function(t){var e=t[0],r=t[1],n=t[2],o=1 in arguments?arguments[1]:j.rgb.hsv(t)[2];if(o=Math.round(o/50),o===0)return 30;var i=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return o===2&&(i+=60),i};j.hsv.ansi16=function(t){return j.rgb.ansi16(j.hsv.rgb(t),t[2])};j.rgb.ansi256=function(t){var e=t[0],r=t[1],n=t[2];if(e===r&&r===n)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var o=16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5);return o};j.ansi16.rgb=function(t){var e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var r=(~~(t>50)+1)*.5,n=(e&1)*r*255,o=(e>>1&1)*r*255,i=(e>>2&1)*r*255;return[n,o,i]};j.ansi256.rgb=function(t){if(t>=232){var e=(t-232)*10+8;return[e,e,e]}t-=16;var r,n=Math.floor(t/36)/5*255,o=Math.floor((r=t%36)/6)/5*255,i=r%6/5*255;return[n,o,i]};j.rgb.hex=function(t){var e=((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255),r=e.toString(16).toUpperCase();return"000000".substring(r.length)+r};j.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var r=e[0];e[0].length===3&&(r=r.split("").map(function(a){return a+a}).join(""));var n=parseInt(r,16),o=n>>16&255,i=n>>8&255,s=n&255;return[o,i,s]};j.rgb.hcg=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=Math.max(Math.max(e,r),n),i=Math.min(Math.min(e,r),n),s=o-i,a,l;return s<1?a=i/(1-s):a=0,s<=0?l=0:o===e?l=(r-n)/s%6:o===r?l=2+(n-e)/s:l=4+(e-r)/s+4,l/=6,l%=1,[l*360,s*100,a*100]};j.hsl.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1,o=0;return r<.5?n=2*e*r:n=2*e*(1-r),n<1&&(o=(r-.5*n)/(1-n)),[t[0],n*100,o*100]};j.hsv.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=e*r,o=0;return n<1&&(o=(r-n)/(1-n)),[t[0],n*100,o*100]};j.hcg.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];var o=[0,0,0],i=e%1*6,s=i%1,a=1-s,l=0;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=a,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=a,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=a}return l=(1-r)*n,[(r*o[0]+l)*255,(r*o[1]+l)*255,(r*o[2]+l)*255]};j.hcg.hsv=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e),o=0;return n>0&&(o=e/n),[t[0],o*100,n*100]};j.hcg.hsl=function(t){var e=t[1]/100,r=t[2]/100,n=r*(1-e)+.5*e,o=0;return n>0&&n<.5?o=e/(2*n):n>=.5&&n<1&&(o=e/(2*(1-n))),[t[0],o*100,n*100]};j.hcg.hwb=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};j.hwb.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1-r,o=n-e,i=0;return o<1&&(i=(n-o)/(1-o)),[t[0],o*100,i*100]};j.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};j.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};j.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};j.gray.hsl=j.gray.hsv=function(t){return[0,0,t[0]]};j.gray.hwb=function(t){return[0,100,t[0]]};j.gray.cmyk=function(t){return[0,0,0,t[0]]};j.gray.lab=function(t){return[t[0],0,0]};j.gray.hex=function(t){var e=Math.round(t[0]/100*255)&255,r=(e<<16)+(e<<8)+e,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n};j.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]}});var S5=g((KLe,E5)=>{var ng=Wx();function ooe(){for(var t={},e=Object.keys(ng),r=e.length,n=0;n{var Hx=Wx(),loe=S5(),Da={},coe=Object.keys(Hx);function uoe(t){var e=function(r){return r==null?r:(arguments.length>1&&(r=Array.prototype.slice.call(arguments)),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function foe(t){var e=function(r){if(r==null)return r;arguments.length>1&&(r=Array.prototype.slice.call(arguments));var n=t(r);if(typeof n=="object")for(var o=n.length,i=0;i{"use strict";var Pu=h5(),rr=_5(),Gx=[].slice,O5=["keyword","gray","hex"],Kx={};Object.keys(rr).forEach(function(t){Kx[Gx.call(rr[t].labels).sort().join("")]=t});var og={};function ut(t,e){if(!(this instanceof ut))return new ut(t,e);if(e&&e in O5&&(e=null),e&&!(e in rr))throw new Error("Unknown model: "+e);var r,n;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof ut)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if(typeof t=="string"){var o=Pu.get(t);if(o===null)throw new Error("Unable to parse color from string: "+t);this.model=o.model,n=rr[this.model].channels,this.color=o.value.slice(0,n),this.valpha=typeof o.value[n]=="number"?o.value[n]:1}else if(t.length){this.model=e||"rgb",n=rr[this.model].channels;var i=Gx.call(t,0,n);this.color=Vx(i,n),this.valpha=typeof t[n]=="number"?t[n]:1}else if(typeof t=="number")t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;var s=Object.keys(t);"alpha"in t&&(s.splice(s.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);var a=s.sort().join("");if(!(a in Kx))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=Kx[a];var l=rr[this.model].labels,u=[];for(r=0;rr?(e+.05)/(r+.05):(r+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return ut.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),r=e.color[0];return r=(r+t)%360,r=r<0?360+r:r,e.color[0]=r,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var r=t.rgb(),n=this.rgb(),o=e===void 0?.5:e,i=2*o-1,s=r.alpha()-n.alpha(),a=((i*s===-1?i:(i+s)/(1+i*s))+1)/2,l=1-a;return ut.rgb(a*r.red()+l*n.red(),a*r.green()+l*n.green(),a*r.blue()+l*n.blue(),r.alpha()*o+n.alpha()*(1-o))}};Object.keys(rr).forEach(function(t){if(O5.indexOf(t)===-1){var e=rr[t].channels;ut.prototype[t]=function(){if(this.model===t)return new ut(this);if(arguments.length)return new ut(arguments,t);var r=typeof arguments[e]=="number"?e:this.valpha;return new ut(moe(rr[this.model][t].raw(this.color)).concat(r),t)},ut[t]=function(r){return typeof r=="number"&&(r=Vx(Gx.call(arguments),e)),new ut(r,t)}}});function poe(t,e){return Number(t.toFixed(e))}function doe(t){return function(e){return poe(e,t)}}function Pe(t,e,r){return t=Array.isArray(t)?t:[t],t.forEach(function(n){(og[n]||(og[n]=[]))[e]=r}),t=t[0],function(n){var o;return arguments.length?(r&&(n=r(n)),o=this[t](),o.color[e]=n,o):(o=this[t]().color[e],r&&(o=r(o)),o)}}function Ge(t){return function(e){return Math.max(0,Math.min(t,e))}}function moe(t){return Array.isArray(t)?t:[t]}function Vx(t,e){for(var r=0;r{var hoe="Expected a function",A5="__lodash_placeholder__",cs=1,sg=2,goe=4,ls=8,Mu=16,Fa=32,$u=64,M5=128,yoe=256,$5=512,k5=1/0,boe=9007199254740991,voe=17976931348623157e292,R5=0/0,woe=[["ary",M5],["bind",cs],["bindKey",sg],["curry",ls],["curryRight",Mu],["flip",$5],["partial",Fa],["partialRight",$u],["rearg",yoe]],xoe="[object Function]",Eoe="[object GeneratorFunction]",Soe="[object Symbol]",Ioe=/[\\^$.*+?()[\]{}|]/g,_oe=/^\s+|\s+$/g,Ooe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Toe=/\{\n\/\* \[wrapped with (.+)\] \*/,Coe=/,? & /,Aoe=/^[-+]0x[0-9a-f]+$/i,koe=/^0b[01]+$/i,Roe=/^\[object .+?Constructor\]$/,Noe=/^0o[0-7]+$/i,Doe=/^(?:0|[1-9]\d*)$/,Foe=parseInt,Poe=typeof global=="object"&&global&&global.Object===Object&&global,Moe=typeof self=="object"&&self&&self.Object===Object&&self,ju=Poe||Moe||Function("return this")();function L5(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function $oe(t,e){for(var r=-1,n=t?t.length:0;++r-1}function joe(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i2?t:void 0}();function Joe(t){return Pa(t)?Goe(t):{}}function Yoe(t){if(!Pa(t)||lie(t))return!1;var e=pie(t)||Woe(t)?Voe:Roe;return e.test(uie(t))}function Xoe(t,e,r,n){for(var o=-1,i=t.length,s=r.length,a=-1,l=e.length,u=ig(i-s,0),c=Array(l+u),f=!n;++a1&&x.reverse(),c&&l1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Ooe,`{ + see https://github.com/jprichardson/node-fs-extra/issues/269`),wc.checkPaths(t,e,"copy",(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:c}=i;wc.checkParentPaths(t,s,e,"copy",l=>l?n(l):r.filter?N1(A1,c,t,e,r,n):A1(c,t,e,r,n))})}function A1(t,e,r,n,o){let i=vc.dirname(r);p9(i,(s,c)=>{if(s)return o(s);if(c)return Dy(t,e,r,n,o);f9(i,l=>l?o(l):Dy(t,e,r,n,o))})}function N1(t,e,r,n,o,i){Promise.resolve(o.filter(r,n)).then(s=>s?t(e,r,n,o,i):i(),s=>i(s))}function Dy(t,e,r,n,o){return n.filter?N1(R1,t,e,r,n,o):R1(t,e,r,n,o)}function R1(t,e,r,n,o){(n.dereference?ut.stat:ut.lstat)(e,(s,c)=>{if(s)return o(s);if(c.isDirectory())return b9(c,t,e,r,n,o);if(c.isFile()||c.isCharacterDevice()||c.isBlockDevice())return h9(c,t,e,r,n,o);if(c.isSymbolicLink())return x9(t,e,r,n,o)})}function h9(t,e,r,n,o,i){return e?g9(t,r,n,o,i):D1(t,r,n,o,i)}function g9(t,e,r,n,o){if(n.overwrite)ut.unlink(r,i=>i?o(i):D1(t,e,r,n,o));else return n.errorOnExist?o(new Error(`'${r}' already exists`)):o()}function D1(t,e,r,n,o){return typeof ut.copyFile=="function"?ut.copyFile(e,r,i=>i?o(i):P1(t,r,n,o)):y9(t,e,r,n,o)}function y9(t,e,r,n,o){let i=ut.createReadStream(e);i.on("error",s=>o(s)).once("open",()=>{let s=ut.createWriteStream(r,{mode:t.mode});s.on("error",c=>o(c)).on("open",()=>i.pipe(s)).once("close",()=>P1(t,r,n,o))})}function P1(t,e,r,n){ut.chmod(e,t.mode,o=>o?n(o):r.preserveTimestamps?d9(e,t.atime,t.mtime,n):n())}function b9(t,e,r,n,o,i){return e?e&&!e.isDirectory()?i(new Error(`Cannot overwrite non-directory '${n}' with directory '${r}'.`)):F1(r,n,o,i):v9(t,r,n,o,i)}function v9(t,e,r,n,o){ut.mkdir(r,i=>{if(i)return o(i);F1(e,r,n,s=>s?o(s):ut.chmod(r,t.mode,o))})}function F1(t,e,r,n){ut.readdir(t,(o,i)=>o?n(o):M1(i,t,e,r,n))}function M1(t,e,r,n,o){let i=t.pop();return i?w9(t,i,e,r,n,o):o()}function w9(t,e,r,n,o,i){let s=vc.join(r,e),c=vc.join(n,e);wc.checkPaths(s,c,"copy",(l,f)=>{if(l)return i(l);let{destStat:u}=f;Dy(u,s,c,o,d=>d?i(d):M1(t,r,n,o,i))})}function x9(t,e,r,n,o){ut.readlink(e,(i,s)=>{if(i)return o(i);if(n.dereference&&(s=vc.resolve(process.cwd(),s)),t)ut.readlink(r,(c,l)=>c?c.code==="EINVAL"||c.code==="UNKNOWN"?ut.symlink(s,r,o):o(c):(n.dereference&&(l=vc.resolve(process.cwd(),l)),wc.isSrcSubdir(s,l)?o(new Error(`Cannot copy '${s}' to a subdirectory of itself, '${l}'.`)):t.isDirectory()&&wc.isSrcSubdir(l,s)?o(new Error(`Cannot overwrite '${l}' with '${s}'.`)):E9(s,r,o)));else return ut.symlink(s,r,o)})}function E9(t,e,r){ut.unlink(e,n=>n?r(n):ut.symlink(t,e,r))}$1.exports=m9});var Py=b((Aue,j1)=>{"use strict";a();var S9=Nt().fromCallback;j1.exports={copy:S9(L1())}});var G1=b((Nue,V1)=>{"use strict";a();var q1=Ke(),W1=require("path"),ye=require("assert"),xc=process.platform==="win32";function H1(t){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(r=>{t[r]=t[r]||q1[r],r=r+"Sync",t[r]=t[r]||q1[r]}),t.maxBusyTries=t.maxBusyTries||3}function Fy(t,e,r){let n=0;typeof e=="function"&&(r=e,e={}),ye(t,"rimraf: missing path"),ye.strictEqual(typeof t,"string","rimraf: path should be a string"),ye.strictEqual(typeof r,"function","rimraf: callback function required"),ye(e,"rimraf: invalid options argument provided"),ye.strictEqual(typeof e,"object","rimraf: options should be object"),H1(e),B1(t,e,function o(i){if(i){if((i.code==="EBUSY"||i.code==="ENOTEMPTY"||i.code==="EPERM")&&nB1(t,e,o),s)}i.code==="ENOENT"&&(i=null)}r(i)})}function B1(t,e,r){ye(t),ye(e),ye(typeof r=="function"),e.lstat(t,(n,o)=>{if(n&&n.code==="ENOENT")return r(null);if(n&&n.code==="EPERM"&&xc)return z1(t,e,n,r);if(o&&o.isDirectory())return Cf(t,e,n,r);e.unlink(t,i=>{if(i){if(i.code==="ENOENT")return r(null);if(i.code==="EPERM")return xc?z1(t,e,i,r):Cf(t,e,i,r);if(i.code==="EISDIR")return Cf(t,e,i,r)}return r(i)})})}function z1(t,e,r,n){ye(t),ye(e),ye(typeof n=="function"),r&&ye(r instanceof Error),e.chmod(t,438,o=>{o?n(o.code==="ENOENT"?null:r):e.stat(t,(i,s)=>{i?n(i.code==="ENOENT"?null:r):s.isDirectory()?Cf(t,e,r,n):e.unlink(t,n)})})}function U1(t,e,r){let n;ye(t),ye(e),r&&ye(r instanceof Error);try{e.chmodSync(t,438)}catch(o){if(o.code==="ENOENT")return;throw r}try{n=e.statSync(t)}catch(o){if(o.code==="ENOENT")return;throw r}n.isDirectory()?kf(t,e,r):e.unlinkSync(t)}function Cf(t,e,r,n){ye(t),ye(e),r&&ye(r instanceof Error),ye(typeof n=="function"),e.rmdir(t,o=>{o&&(o.code==="ENOTEMPTY"||o.code==="EEXIST"||o.code==="EPERM")?I9(t,e,n):o&&o.code==="ENOTDIR"?n(r):n(o)})}function I9(t,e,r){ye(t),ye(e),ye(typeof r=="function"),e.readdir(t,(n,o)=>{if(n)return r(n);let i=o.length,s;if(i===0)return e.rmdir(t,r);o.forEach(c=>{Fy(W1.join(t,c),e,l=>{if(!s){if(l)return r(s=l);--i===0&&e.rmdir(t,r)}})})})}function K1(t,e){let r;e=e||{},H1(e),ye(t,"rimraf: missing path"),ye.strictEqual(typeof t,"string","rimraf: path should be a string"),ye(e,"rimraf: missing options"),ye.strictEqual(typeof e,"object","rimraf: options should be object");try{r=e.lstatSync(t)}catch(n){if(n.code==="ENOENT")return;n.code==="EPERM"&&xc&&U1(t,e,n)}try{r&&r.isDirectory()?kf(t,e,null):e.unlinkSync(t)}catch(n){if(n.code==="ENOENT")return;if(n.code==="EPERM")return xc?U1(t,e,n):kf(t,e,n);if(n.code!=="EISDIR")throw n;kf(t,e,n)}}function kf(t,e,r){ye(t),ye(e),r&&ye(r instanceof Error);try{e.rmdirSync(t)}catch(n){if(n.code==="ENOTDIR")throw r;if(n.code==="ENOTEMPTY"||n.code==="EEXIST"||n.code==="EPERM")_9(t,e);else if(n.code!=="ENOENT")throw n}}function _9(t,e){if(ye(t),ye(e),e.readdirSync(t).forEach(r=>K1(W1.join(t,r),e)),xc){let r=Date.now();do try{return e.rmdirSync(t,e)}catch{}while(Date.now()-r<500)}else return e.rmdirSync(t,e)}V1.exports=Fy;Fy.sync=K1});var Ec=b((Pue,J1)=>{"use strict";a();var T9=Nt().fromCallback,Z1=G1();J1.exports={remove:T9(Z1),removeSync:Z1.sync}});var o_=b((Mue,n_)=>{"use strict";a();var O9=Nt().fromCallback,Q1=Ke(),e_=require("path"),t_=Zt(),r_=Ec(),Y1=O9(function(e,r){r=r||function(){},Q1.readdir(e,(n,o)=>{if(n)return t_.mkdirs(e,r);o=o.map(s=>e_.join(e,s)),i();function i(){let s=o.pop();if(!s)return r();r_.remove(s,c=>{if(c)return r(c);i()})}})});function X1(t){let e;try{e=Q1.readdirSync(t)}catch{return t_.mkdirsSync(t)}e.forEach(r=>{r=e_.join(t,r),r_.removeSync(r)})}n_.exports={emptyDirSync:X1,emptydirSync:X1,emptyDir:Y1,emptydir:Y1}});var c_=b((Lue,a_)=>{"use strict";a();var C9=Nt().fromCallback,i_=require("path"),Sc=Ke(),s_=Zt(),k9=Xr().pathExists;function A9(t,e){function r(){Sc.writeFile(t,"",n=>{if(n)return e(n);e()})}Sc.stat(t,(n,o)=>{if(!n&&o.isFile())return e();let i=i_.dirname(t);k9(i,(s,c)=>{if(s)return e(s);if(c)return r();s_.mkdirs(i,l=>{if(l)return e(l);r()})})})}function R9(t){let e;try{e=Sc.statSync(t)}catch{}if(e&&e.isFile())return;let r=i_.dirname(t);Sc.existsSync(r)||s_.mkdirsSync(r),Sc.writeFileSync(t,"")}a_.exports={createFile:C9(A9),createFileSync:R9}});var d_=b((que,p_)=>{"use strict";a();var N9=Nt().fromCallback,u_=require("path"),mi=Ke(),f_=Zt(),l_=Xr().pathExists;function D9(t,e,r){function n(o,i){mi.link(o,i,s=>{if(s)return r(s);r(null)})}l_(e,(o,i)=>{if(o)return r(o);if(i)return r(null);mi.lstat(t,s=>{if(s)return s.message=s.message.replace("lstat","ensureLink"),r(s);let c=u_.dirname(e);l_(c,(l,f)=>{if(l)return r(l);if(f)return n(t,e);f_.mkdirs(c,u=>{if(u)return r(u);n(t,e)})})})})}function P9(t,e){if(mi.existsSync(e))return;try{mi.lstatSync(t)}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}let n=u_.dirname(e);return mi.existsSync(n)||f_.mkdirsSync(n),mi.linkSync(t,e)}p_.exports={createLink:N9(D9),createLinkSync:P9}});var h_=b((zue,m_)=>{"use strict";a();var ho=require("path"),Ic=Ke(),F9=Xr().pathExists;function M9(t,e,r){if(ho.isAbsolute(t))return Ic.lstat(t,n=>n?(n.message=n.message.replace("lstat","ensureSymlink"),r(n)):r(null,{toCwd:t,toDst:t}));{let n=ho.dirname(e),o=ho.join(n,t);return F9(o,(i,s)=>i?r(i):s?r(null,{toCwd:o,toDst:t}):Ic.lstat(t,c=>c?(c.message=c.message.replace("lstat","ensureSymlink"),r(c)):r(null,{toCwd:t,toDst:ho.relative(n,t)})))}}function $9(t,e){let r;if(ho.isAbsolute(t)){if(r=Ic.existsSync(t),!r)throw new Error("absolute srcpath does not exist");return{toCwd:t,toDst:t}}else{let n=ho.dirname(e),o=ho.join(n,t);if(r=Ic.existsSync(o),r)return{toCwd:o,toDst:t};if(r=Ic.existsSync(t),!r)throw new Error("relative srcpath does not exist");return{toCwd:t,toDst:ho.relative(n,t)}}}m_.exports={symlinkPaths:M9,symlinkPathsSync:$9}});var b_=b((Wue,y_)=>{"use strict";a();var g_=Ke();function L9(t,e,r){if(r=typeof e=="function"?e:r,e=typeof e=="function"?!1:e,e)return r(null,e);g_.lstat(t,(n,o)=>{if(n)return r(null,"file");e=o&&o.isDirectory()?"dir":"file",r(null,e)})}function j9(t,e){let r;if(e)return e;try{r=g_.lstatSync(t)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}y_.exports={symlinkType:L9,symlinkTypeSync:j9}});var __=b((Kue,I_)=>{"use strict";a();var q9=Nt().fromCallback,w_=require("path"),Ns=Ke(),x_=Zt(),B9=x_.mkdirs,z9=x_.mkdirsSync,E_=h_(),U9=E_.symlinkPaths,W9=E_.symlinkPathsSync,S_=b_(),H9=S_.symlinkType,K9=S_.symlinkTypeSync,v_=Xr().pathExists;function V9(t,e,r,n){n=typeof r=="function"?r:n,r=typeof r=="function"?!1:r,v_(e,(o,i)=>{if(o)return n(o);if(i)return n(null);U9(t,e,(s,c)=>{if(s)return n(s);t=c.toDst,H9(c.toCwd,r,(l,f)=>{if(l)return n(l);let u=w_.dirname(e);v_(u,(d,m)=>{if(d)return n(d);if(m)return Ns.symlink(t,e,f,n);B9(u,h=>{if(h)return n(h);Ns.symlink(t,e,f,n)})})})})})}function G9(t,e,r){if(Ns.existsSync(e))return;let o=W9(t,e);t=o.toDst,r=K9(o.toCwd,r);let i=w_.dirname(e);return Ns.existsSync(i)||z9(i),Ns.symlinkSync(t,e,r)}I_.exports={createSymlink:q9(V9),createSymlinkSync:G9}});var O_=b((Gue,T_)=>{"use strict";a();var Af=c_(),Rf=d_(),Nf=__();T_.exports={createFile:Af.createFile,createFileSync:Af.createFileSync,ensureFile:Af.createFile,ensureFileSync:Af.createFileSync,createLink:Rf.createLink,createLinkSync:Rf.createLinkSync,ensureLink:Rf.createLink,ensureLinkSync:Rf.createLinkSync,createSymlink:Nf.createSymlink,createSymlinkSync:Nf.createSymlinkSync,ensureSymlink:Nf.createSymlink,ensureSymlinkSync:Nf.createSymlinkSync}});var R_=b((Jue,A_)=>{a();var Ds;try{Ds=Ke()}catch{Ds=require("fs")}function Z9(t,e,r){r==null&&(r=e,e={}),typeof e=="string"&&(e={encoding:e}),e=e||{};var n=e.fs||Ds,o=!0;"throws"in e&&(o=e.throws),n.readFile(t,e,function(i,s){if(i)return r(i);s=k_(s);var c;try{c=JSON.parse(s,e?e.reviver:null)}catch(l){return o?(l.message=t+": "+l.message,r(l)):r(null,null)}r(null,c)})}function J9(t,e){e=e||{},typeof e=="string"&&(e={encoding:e});var r=e.fs||Ds,n=!0;"throws"in e&&(n=e.throws);try{var o=r.readFileSync(t,e);return o=k_(o),JSON.parse(o,e.reviver)}catch(i){if(n)throw i.message=t+": "+i.message,i;return null}}function C_(t,e){var r,n=` +`;typeof e=="object"&&e!==null&&(e.spaces&&(r=e.spaces),e.EOL&&(n=e.EOL));var o=JSON.stringify(t,e?e.replacer:null,r);return o.replace(/\n/g,n)+n}function Y9(t,e,r,n){n==null&&(n=r,r={}),r=r||{};var o=r.fs||Ds,i="";try{i=C_(e,r)}catch(s){n&&n(s,null);return}o.writeFile(t,i,r,n)}function X9(t,e,r){r=r||{};var n=r.fs||Ds,o=C_(e,r);return n.writeFileSync(t,o,r)}function k_(t){return Buffer.isBuffer(t)&&(t=t.toString("utf8")),t=t.replace(/^\uFEFF/,""),t}var Q9={readFile:Z9,readFileSync:J9,writeFile:Y9,writeFileSync:X9};A_.exports=Q9});var Pf=b((Xue,D_)=>{"use strict";a();var N_=Nt().fromCallback,Df=R_();D_.exports={readJson:N_(Df.readFile),readJsonSync:Df.readFileSync,writeJson:N_(Df.writeFile),writeJsonSync:Df.writeFileSync}});var M_=b((efe,F_)=>{"use strict";a();var e4=require("path"),t4=Zt(),r4=Xr().pathExists,P_=Pf();function n4(t,e,r,n){typeof r=="function"&&(n=r,r={});let o=e4.dirname(t);r4(o,(i,s)=>{if(i)return n(i);if(s)return P_.writeJson(t,e,r,n);t4.mkdirs(o,c=>{if(c)return n(c);P_.writeJson(t,e,r,n)})})}F_.exports=n4});var L_=b((rfe,$_)=>{"use strict";a();var o4=Ke(),i4=require("path"),s4=Zt(),a4=Pf();function c4(t,e,r){let n=i4.dirname(t);o4.existsSync(n)||s4.mkdirsSync(n),a4.writeJsonSync(t,e,r)}$_.exports=c4});var q_=b((ofe,j_)=>{"use strict";a();var l4=Nt().fromCallback,Et=Pf();Et.outputJson=l4(M_());Et.outputJsonSync=L_();Et.outputJSON=Et.outputJson;Et.outputJSONSync=Et.outputJsonSync;Et.writeJSON=Et.writeJson;Et.writeJSONSync=Et.writeJsonSync;Et.readJSON=Et.readJson;Et.readJSONSync=Et.readJsonSync;j_.exports=Et});var K_=b((sfe,H_)=>{"use strict";a();var U_=Ke(),u4=require("path"),f4=Ny().copySync,W_=Ec().removeSync,p4=Zt().mkdirpSync,B_=gc();function d4(t,e,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:o}=B_.checkPathsSync(t,e,"move");return B_.checkParentPathsSync(t,o,e,"move"),p4(u4.dirname(e)),m4(t,e,n)}function m4(t,e,r){if(r)return W_(e),z_(t,e,r);if(U_.existsSync(e))throw new Error("dest already exists.");return z_(t,e,r)}function z_(t,e,r){try{U_.renameSync(t,e)}catch(n){if(n.code!=="EXDEV")throw n;return h4(t,e,r)}}function h4(t,e,r){return f4(t,e,{overwrite:r,errorOnExist:!0}),W_(t)}H_.exports=d4});var G_=b((cfe,V_)=>{"use strict";a();V_.exports={moveSync:K_()}});var Q_=b((ufe,X_)=>{"use strict";a();var g4=Ke(),y4=require("path"),b4=Py().copy,Y_=Ec().remove,v4=Zt().mkdirp,w4=Xr().pathExists,Z_=gc();function x4(t,e,r,n){typeof r=="function"&&(n=r,r={});let o=r.overwrite||r.clobber||!1;Z_.checkPaths(t,e,"move",(i,s)=>{if(i)return n(i);let{srcStat:c}=s;Z_.checkParentPaths(t,c,e,"move",l=>{if(l)return n(l);v4(y4.dirname(e),f=>f?n(f):E4(t,e,o,n))})})}function E4(t,e,r,n){if(r)return Y_(e,o=>o?n(o):J_(t,e,r,n));w4(e,(o,i)=>o?n(o):i?n(new Error("dest already exists.")):J_(t,e,r,n))}function J_(t,e,r,n){g4.rename(t,e,o=>o?o.code!=="EXDEV"?n(o):S4(t,e,r,n):n())}function S4(t,e,r,n){b4(t,e,{overwrite:r,errorOnExist:!0},i=>i?n(i):Y_(t,n))}X_.exports=x4});var tT=b((pfe,eT)=>{"use strict";a();var I4=Nt().fromCallback;eT.exports={move:I4(Q_())}});var iT=b((mfe,oT)=>{"use strict";a();var _4=Nt().fromCallback,_c=Ke(),rT=require("path"),nT=Zt(),T4=Xr().pathExists;function O4(t,e,r,n){typeof r=="function"&&(n=r,r="utf8");let o=rT.dirname(t);T4(o,(i,s)=>{if(i)return n(i);if(s)return _c.writeFile(t,e,r,n);nT.mkdirs(o,c=>{if(c)return n(c);_c.writeFile(t,e,r,n)})})}function C4(t,...e){let r=rT.dirname(t);if(_c.existsSync(r))return _c.writeFileSync(t,...e);nT.mkdirsSync(r),_c.writeFileSync(t,...e)}oT.exports={outputFile:_4(O4),outputFileSync:C4}});var $y=b((gfe,My)=>{"use strict";a();My.exports=Object.assign({},vy(),Ny(),Py(),o_(),O_(),q_(),Zt(),G_(),tT(),iT(),Xr(),Ec());var sT=require("fs");Object.getOwnPropertyDescriptor(sT,"promises")&&Object.defineProperty(My.exports,"promises",{get(){return sT.promises}})});var cT=b((bfe,aT)=>{a();aT.exports=()=>new Date});var uT=b((wfe,lT)=>{a();var k4=Xe()("streamroller:fileNameFormatter"),A4=require("path"),R4=".gz",N4=".";lT.exports=({file:t,keepFileExt:e,needsIndex:r,alwaysIncludeDate:n,compress:o,fileNameSep:i})=>{let s=i||N4,c=A4.join(t.dir,t.name),l=h=>h+t.ext,f=(h,y,w)=>(r||!w)&&y?h+s+y:h,u=(h,y,w)=>(y>0||n)&&w?h+s+w:h,d=(h,y)=>y&&o?h+R4:h,m=e?[u,f,l,d]:[l,u,f,d];return({date:h,index:y})=>(k4(`_formatFileName: date=${h}, index=${y}`),m.reduce((w,v)=>v(w,y,h),c))}});var mT=b((Efe,dT)=>{a();var hi=Xe()("streamroller:fileNameParser"),fT=".gz",pT=bf(),D4=".";dT.exports=({file:t,keepFileExt:e,pattern:r,fileNameSep:n})=>{let o=n||D4,i=(m,h)=>m.endsWith(fT)?(hi("it is gzipped"),h.isCompressed=!0,m.slice(0,-1*fT.length)):m,s="__NOT_MATCHING__",d=[i,e?m=>m.startsWith(t.name)&&m.endsWith(t.ext)?(hi("it starts and ends with the right things"),m.slice(t.name.length+1,-1*t.ext.length)):s:m=>m.startsWith(t.base)?(hi("it starts with the right things"),m.slice(t.base.length+1)):s,r?(m,h)=>{let y=m.split(o),w=y[y.length-1];hi("items: ",y,", indexStr: ",w);let v=m;w!==void 0&&w.match(/^\d+$/)?(v=m.slice(0,-1*(w.length+1)),hi(`dateStr is ${v}`),r&&!v&&(v=w,w="0")):w="0";try{let x=pT.parse(r,v,new Date(0,0));return pT.asString(r,x)!==v?m:(h.index=parseInt(w,10),h.date=v,h.timestamp=x.getTime(),"")}catch(x){return hi(`Problem parsing ${v} as ${r}, error was: `,x),m}}:(m,h)=>m.match(/^\d+$/)?(hi("it has an index"),h.index=parseInt(m,10),""):m];return m=>{let h={filename:m,index:0,isCompressed:!1};return d.reduce((w,v)=>v(w,h),m)?null:h}}});var gT=b((Ife,hT)=>{a();var Pt=Xe()("streamroller:moveAndMaybeCompressFile"),On=$y(),P4=require("zlib"),F4=function(t){let e={mode:parseInt("0600",8),compress:!1},r=Object.assign({},e,t);return Pt(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(r)}`),r},M4=async(t,e,r)=>{if(r=F4(r),t===e){Pt("moveAndMaybeCompressFile: source and target are the same, not doing anything");return}if(await On.pathExists(t))if(Pt(`moveAndMaybeCompressFile: moving file from ${t} to ${e} ${r.compress?"with":"without"} compress`),r.compress)await new Promise((n,o)=>{let i=!1,s=On.createWriteStream(e,{mode:r.mode,flags:"wx"}).on("open",()=>{i=!0;let c=On.createReadStream(t).on("open",()=>{c.pipe(P4.createGzip()).pipe(s)}).on("error",l=>{Pt(`moveAndMaybeCompressFile: error reading ${t}`,l),s.destroy(l)})}).on("finish",()=>{Pt(`moveAndMaybeCompressFile: finished compressing ${e}, deleting ${t}`),On.unlink(t).then(n).catch(c=>{Pt(`moveAndMaybeCompressFile: error deleting ${t}, truncating instead`,c),On.truncate(t).then(n).catch(l=>{Pt(`moveAndMaybeCompressFile: error truncating ${t}`,l),o(l)})})}).on("error",c=>{i?(Pt(`moveAndMaybeCompressFile: error writing ${e}, deleting`,c),On.unlink(e).then(()=>{o(c)}).catch(l=>{Pt(`moveAndMaybeCompressFile: error deleting ${e}`,l),o(l)})):(Pt(`moveAndMaybeCompressFile: error creating ${e}`,c),o(c))})}).catch(()=>{});else{Pt(`moveAndMaybeCompressFile: renaming ${t} to ${e}`);try{await On.move(t,e,{overwrite:!0})}catch(n){if(Pt(`moveAndMaybeCompressFile: error renaming ${t} to ${e}`,n),n.code!=="ENOENT"){Pt("moveAndMaybeCompressFile: trying copy+truncate instead");try{await On.copy(t,e,{overwrite:!0}),await On.truncate(t)}catch(o){Pt("moveAndMaybeCompressFile: error copy+truncate",o)}}}}};hT.exports=M4});var $f=b((Tfe,yT)=>{a();var Jt=Xe()("streamroller:RollingFileWriteStream"),yi=$y(),gi=require("path"),$4=require("os"),Ff=cT(),Mf=bf(),{Writable:L4}=require("stream"),j4=uT(),q4=mT(),B4=gT(),z4=t=>(Jt(`deleteFiles: files to delete: ${t}`),Promise.all(t.map(e=>yi.unlink(e).catch(r=>{Jt(`deleteFiles: error when unlinking ${e}, ignoring. Error was ${r}`)})))),Ly=class extends L4{constructor(e,r){if(Jt(`constructor: creating RollingFileWriteStream. path=${e}`),typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(gi.sep))throw new Error(`Filename is a directory: ${e}`);e.indexOf(`~${gi.sep}`)===0&&(e=e.replace("~",$4.homedir())),super(r),this.options=this._parseOption(r),this.fileObject=gi.parse(e),this.fileObject.dir===""&&(this.fileObject=gi.parse(gi.join(process.cwd(),e))),this.fileFormatter=j4({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`);if(n.numBackups||n.numBackups===0){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return Jt(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(e){this.currentFileStream.end("",this.options.encoding,e)}_write(e,r,n){this._shouldRoll().then(()=>{Jt(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${e}`),this.currentFileStream.write(e,r,o=>{this.state.currentSize+=e.length,n(o)})})}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(Jt(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==Mf(this.options.pattern,Ff())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return Jt("_roll: closing the current stream"),new Promise((e,r)=>{this.currentFileStream.end("",this.options.encoding,()=>{this._moveOldFiles().then(e).catch(r)})})}async _moveOldFiles(){let e=await this._getExistingFiles(),r=this.state.currentDate?e.filter(n=>n.date===this.state.currentDate):e;for(let n=r.length;n>=0;n--){Jt(`_moveOldFiles: i = ${n}`);let o=this.fileFormatter({date:this.state.currentDate,index:n}),i=this.fileFormatter({date:this.state.currentDate,index:n+1}),s={compress:this.options.compress&&n===0,mode:this.options.mode};await B4(o,i,s)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?Mf(this.options.pattern,Ff()):null,Jt(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise((n,o)=>{this.currentFileStream.write("","utf8",()=>{this._clean().then(n).catch(o)})})}async _getExistingFiles(){let e=await yi.readdir(this.fileObject.dir).catch(()=>[]);Jt(`_getExistingFiles: files=${e}`);let r=e.map(o=>this.fileNameParser(o)).filter(o=>o),n=o=>(o.timestamp?o.timestamp:Ff().getTime())-o.index;return r.sort((o,i)=>n(o)-n(i)),r}_renewWriteStream(){let e=this.fileFormatter({date:this.state.currentDate,index:0}),r=i=>{try{return yi.mkdirSync(i,{recursive:!0})}catch(s){if(s.code==="ENOENT")return r(gi.dirname(i)),r(i);if(s.code!=="EEXIST"&&s.code!=="EROFS")throw s;try{if(yi.statSync(i).isDirectory())return i;throw s}catch{throw s}}};r(this.fileObject.dir);let n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode},o=function(i,s,c){return i[c]=i[s],delete i[s],i};yi.appendFileSync(e,"",o({...n},"flags","flag")),this.currentFileStream=yi.createWriteStream(e,n),this.currentFileStream.on("error",i=>{this.emit("error",i)})}async _clean(){let e=await this._getExistingFiles();if(Jt(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${e.length}`),Jt("_clean: existing files are: ",e),this._tooManyFiles(e.length)){let r=e.slice(0,e.length-this.options.numToKeep).map(n=>gi.format({dir:this.fileObject.dir,base:n.filename}));await z4(r)}}_tooManyFiles(e){return this.options.numToKeep>0&&e>this.options.numToKeep}};yT.exports=Ly});var vT=b((Cfe,bT)=>{a();var U4=$f(),jy=class extends U4{constructor(e,r,n,o){o||(o={}),r&&(o.maxSize=r),!o.numBackups&&o.numBackups!==0&&(!n&&n!==0&&(n=1),o.numBackups=n),super(e,o),this.backups=o.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};bT.exports=jy});var xT=b((Afe,wT)=>{a();var W4=$f(),qy=class extends W4{constructor(e,r,n){r&&typeof r=="object"&&(n=r,r=null),n||(n={}),r||(r="yyyy-MM-dd"),n.pattern=r,!n.numBackups&&n.numBackups!==0?(!n.daysToKeep&&n.daysToKeep!==0?n.daysToKeep=1:process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"),n.numBackups=n.daysToKeep):n.daysToKeep=n.numBackups,super(e,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}};wT.exports=qy});var By=b((Nfe,ET)=>{a();ET.exports={RollingFileWriteStream:$f(),RollingFileStream:vT(),DateRollingFileStream:xT()}});var OT=b((Pfe,TT)=>{a();var ST=Xe()("log4js:file"),zy=require("path"),H4=By(),_T=require("os"),K4=_T.EOL,Lf=!1,jf=new Set;function IT(){jf.forEach(t=>{t.sighupHandler()})}function V4(t,e,r,n,o,i){if(typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(zy.sep))throw new Error(`Filename is a directory: ${t}`);t=t.replace(new RegExp(`^~(?=${zy.sep}.+)`),_T.homedir()),t=zy.normalize(t),n=!n&&n!==0?5:n,ST("Creating file appender (",t,", ",r,", ",n,", ",o,", ",i,")");function s(f,u,d,m){let h=new H4.RollingFileStream(f,u,d,m);return h.on("error",y=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",f,y)}),h.on("drain",()=>{process.emit("log4js:pause",!1)}),h}let c=s(t,r,n,o),l=function(f){if(c.writable){if(o.removeColor===!0){let u=/\x1b[[0-9;]*m/g;f.data=f.data.map(d=>typeof d=="string"?d.replace(u,""):d)}c.write(e(f,i)+K4,"utf8")||process.emit("log4js:pause",!0)}};return l.reopen=function(){c.end(()=>{c=s(t,r,n,o)})},l.sighupHandler=function(){ST("SIGHUP handler called."),l.reopen()},l.shutdown=function(f){jf.delete(l),jf.size===0&&Lf&&(process.removeListener("SIGHUP",IT),Lf=!1),c.end("","utf-8",f)},jf.add(l),Lf||(process.on("SIGHUP",IT),Lf=!0),l}function G4(t,e){let r=e.basicLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),t.mode=t.mode||384,V4(t.filename,r,t.maxLogSize,t.backups,t,t.timezoneOffset)}TT.exports.configure=G4});var kT=b((Mfe,CT)=>{a();var Z4=By(),J4=require("os"),Y4=J4.EOL;function X4(t,e,r){let n=new Z4.DateRollingFileStream(t,e,r);return n.on("error",o=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",t,o)}),n.on("drain",()=>{process.emit("log4js:pause",!1)}),n}function Q4(t,e,r,n,o){n.maxSize=n.maxLogSize;let i=X4(t,e,n),s=function(c){i.writable&&(i.write(r(c,o)+Y4,"utf8")||process.emit("log4js:pause",!0))};return s.shutdown=function(c){i.end("","utf-8",c)},s}function eU(t,e){let r=e.basicLayout;return t.layout&&(r=e.layout(t.layout.type,t.layout)),t.alwaysIncludePattern||(t.alwaysIncludePattern=!1),t.mode=t.mode||384,Q4(t.filename,t.pattern,r,t,t.timezoneOffset)}CT.exports.configure=eU});var DT=b((Lfe,NT)=>{a();var Cn=Xe()("log4js:fileSync"),en=require("path"),Qr=require("fs"),AT=require("os"),tU=AT.EOL;function RT(t,e){let r=n=>{try{return Qr.mkdirSync(n,{recursive:!0})}catch(o){if(o.code==="ENOENT")return r(en.dirname(n)),r(n);if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;try{if(Qr.statSync(n).isDirectory())return n;throw o}catch{throw o}}};r(en.dirname(t)),Qr.appendFileSync(t,"",{mode:e.mode,flag:e.flags})}var Uy=class{constructor(e,r,n,o){if(Cn("In RollingFileStream"),r<0)throw new Error(`maxLogSize (${r}) should be > 0`);this.filename=e,this.size=r,this.backups=n,this.options=o,this.currentSize=0;function i(s){let c=0;try{c=Qr.statSync(s).size}catch{RT(s,o)}return c}this.currentSize=i(this.filename)}shouldRoll(){return Cn("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(e){let r=this,n=new RegExp(`^${en.basename(e)}`);function o(f){return n.test(f)}function i(f){return parseInt(f.slice(`${en.basename(e)}.`.length),10)||0}function s(f,u){return i(f)-i(u)}function c(f){let u=i(f);if(Cn(`Index of ${f} is ${u}`),r.backups===0)Qr.truncateSync(e,0);else if(u ${e}.${u+1}`),Qr.renameSync(en.join(en.dirname(e),f),`${e}.${u+1}`)}}function l(){Cn("Renaming the old files"),Qr.readdirSync(en.dirname(e)).filter(o).sort(s).reverse().forEach(c)}Cn("Rolling, rolling, rolling"),l()}write(e,r){let n=this;function o(){Cn("writing the chunk to the file"),n.currentSize+=e.length,Qr.appendFileSync(n.filename,e)}Cn("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),o()}};function rU(t,e,r,n,o,i){if(typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(en.sep))throw new Error(`Filename is a directory: ${t}`);t=t.replace(new RegExp(`^~(?=${en.sep}.+)`),AT.homedir()),t=en.normalize(t),n=!n&&n!==0?5:n,Cn("Creating fileSync appender (",t,", ",r,", ",n,", ",o,", ",i,")");function s(l,f,u){let d;return f?d=new Uy(l,f,u,o):d=(m=>(RT(m,o),{write(h){Qr.appendFileSync(m,h)}}))(l),d}let c=s(t,r,n);return l=>{c.write(e(l,i)+tU)}}function nU(t,e){let r=e.basicLayout;t.layout&&(r=e.layout(t.layout.type,t.layout));let n={flags:t.flags||"a",encoding:t.encoding||"utf8",mode:t.mode||384};return rU(t.filename,r,t.maxLogSize,t.backups,n,t.timezoneOffset)}NT.exports.configure=nU});var FT=b((qfe,PT)=>{a();var tn=Xe()("log4js:tcp"),oU=require("net");function iU(t,e){let r=!1,n=[],o,i=3,s="__LOG4JS__";function c(d){tn("Writing log event to socket"),r=o.write(`${e(d)}${s}`,"utf8")}function l(){let d;for(tn("emptying buffer");d=n.shift();)c(d)}function f(){tn(`appender creating socket to ${t.host||"localhost"}:${t.port||5e3}`),s=`${t.endMsg||"__LOG4JS__"}`,o=oU.createConnection(t.port||5e3,t.host||"localhost"),o.on("connect",()=>{tn("socket connected"),l(),r=!0}),o.on("drain",()=>{tn("drain event received, emptying buffer"),r=!0,l()}),o.on("timeout",o.end.bind(o)),o.on("error",d=>{tn("connection error",d),r=!1,l()}),o.on("close",f)}f();function u(d){r?c(d):(tn("buffering log event because it cannot write at the moment"),n.push(d))}return u.shutdown=function(d){tn("shutdown called"),n.length&&i?(tn("buffer has items, waiting 100ms to empty"),i-=1,setTimeout(()=>{u.shutdown(d)},100)):(o.removeAllListeners("close"),o.end(d))},u}function sU(t,e){tn(`configure with config = ${t}`);let r=function(n){return n.serialise()};return t.layout&&(r=e.layout(t.layout.type,t.layout)),iU(t,r)}PT.exports.configure=sU});var Ky=b((zfe,Hy)=>{a();var Wy=require("path"),go=Xe()("log4js:appenders"),hr=li(),MT=Ef(),aU=fi(),cU=ly(),lU=DI(),Dr=new Map;Dr.set("console",FI());Dr.set("stdout",$I());Dr.set("stderr",jI());Dr.set("logLevelFilter",BI());Dr.set("categoryFilter",WI());Dr.set("noLogFilter",VI());Dr.set("file",OT());Dr.set("dateFile",kT());Dr.set("fileSync",DT());Dr.set("tcp",FT());var Tc=new Map,qf=(t,e)=>{let r;try{let n=`${t}.cjs`;r=require.resolve(n),go("Loading module from ",n)}catch{r=t,go("Loading module from ",t)}try{return require(r)}catch(n){hr.throwExceptionIf(e,n.code!=="MODULE_NOT_FOUND",`appender "${t}" could not be loaded (error was: ${n})`);return}},uU=(t,e)=>Dr.get(t)||qf(`./${t}`,e)||qf(t,e)||require.main&&require.main.filename&&qf(Wy.join(Wy.dirname(require.main.filename),t),e)||qf(Wy.join(process.cwd(),t),e),Bf=new Set,$T=(t,e)=>{if(Tc.has(t))return Tc.get(t);if(!e.appenders[t])return!1;if(Bf.has(t))throw new Error(`Dependency loop detected for appender ${t}.`);Bf.add(t),go(`Creating appender ${t}`);let r=fU(t,e);return Bf.delete(t),Tc.set(t,r),r},fU=(t,e)=>{let r=e.appenders[t],n=r.type.configure?r.type:uU(r.type,e);return hr.throwExceptionIf(e,hr.not(n),`appender "${t}" is not valid (type "${r.type}" could not be found)`),n.appender&&(process.emitWarning(`Appender ${r.type} exports an appender function.`,"DeprecationWarning","log4js-node-DEP0001"),go("[log4js-node-DEP0001]",`DEPRECATION: Appender ${r.type} exports an appender function.`)),n.shutdown&&(process.emitWarning(`Appender ${r.type} exports a shutdown function.`,"DeprecationWarning","log4js-node-DEP0002"),go("[log4js-node-DEP0002]",`DEPRECATION: Appender ${r.type} exports a shutdown function.`)),go(`${t}: clustering.isMaster ? ${MT.isMaster()}`),go(`${t}: appenderModule is ${require("util").inspect(n)}`),MT.onlyOnMaster(()=>(go(`calling appenderModule.configure for ${t} / ${r.type}`),n.configure(lU.modifyConfig(r),cU,o=>$T(o,e),aU)),()=>{})},LT=t=>{if(Tc.clear(),Bf.clear(),!t)return;let e=[];Object.values(t.categories).forEach(r=>{e.push(...r.appenders)}),Object.keys(t.appenders).forEach(r=>{(e.includes(r)||t.appenders[r].type==="tcp-server"||t.appenders[r].type==="multiprocess")&&$T(r,t)})},jT=()=>{LT()};jT();hr.addListener(t=>{hr.throwExceptionIf(t,hr.not(hr.anObject(t.appenders)),'must have a property "appenders" of type object.');let e=Object.keys(t.appenders);hr.throwExceptionIf(t,hr.not(e.length),"must define at least one appender."),e.forEach(r=>{hr.throwExceptionIf(t,hr.not(t.appenders[r].type),`appender "${r}" is not valid (must be an object with property "type")`)})});hr.addListener(LT);Hy.exports=Tc;Hy.exports.init=jT});var Zy=b((Wfe,zf)=>{a();var Oc=Xe()("log4js:categories"),$e=li(),Vy=fi(),qT=Ky(),yo=new Map;function BT(t,e,r){if(e.inherit===!1)return;let n=r.lastIndexOf(".");if(n<0)return;let o=r.slice(0,n),i=t.categories[o];i||(i={inherit:!0,appenders:[]}),BT(t,i,o),!t.categories[o]&&i.appenders&&i.appenders.length&&i.level&&(t.categories[o]=i),e.appenders=e.appenders||[],e.level=e.level||i.level,i.appenders.forEach(s=>{e.appenders.includes(s)||e.appenders.push(s)}),e.parent=i}function pU(t){if(!t.categories)return;Object.keys(t.categories).forEach(r=>{let n=t.categories[r];BT(t,n,r)})}$e.addPreProcessingListener(t=>pU(t));$e.addListener(t=>{$e.throwExceptionIf(t,$e.not($e.anObject(t.categories)),'must have a property "categories" of type object.');let e=Object.keys(t.categories);$e.throwExceptionIf(t,$e.not(e.length),"must define at least one category."),e.forEach(r=>{let n=t.categories[r];$e.throwExceptionIf(t,[$e.not(n.appenders),$e.not(n.level)],`category "${r}" is not valid (must be an object with properties "appenders" and "level")`),$e.throwExceptionIf(t,$e.not(Array.isArray(n.appenders)),`category "${r}" is not valid (appenders must be an array of appender names)`),$e.throwExceptionIf(t,$e.not(n.appenders.length),`category "${r}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(n,"enableCallStack")&&$e.throwExceptionIf(t,typeof n.enableCallStack!="boolean",`category "${r}" is not valid (enableCallStack must be boolean type)`),n.appenders.forEach(o=>{$e.throwExceptionIf(t,$e.not(qT.get(o)),`category "${r}" is not valid (appender "${o}" is not defined)`)}),$e.throwExceptionIf(t,$e.not(Vy.getLevel(n.level)),`category "${r}" is not valid (level "${n.level}" not recognised; valid levels are ${Vy.levels.join(", ")})`)}),$e.throwExceptionIf(t,$e.not(t.categories.default),'must define a "default" category.')});var Gy=t=>{if(yo.clear(),!t)return;Object.keys(t.categories).forEach(r=>{let n=t.categories[r],o=[];n.appenders.forEach(i=>{o.push(qT.get(i)),Oc(`Creating category ${r}`),yo.set(r,{appenders:o,level:Vy.getLevel(n.level),enableCallStack:n.enableCallStack||!1})})})},zT=()=>{Gy()};zT();$e.addListener(Gy);var Ps=t=>{if(Oc(`configForCategory: searching for config for ${t}`),yo.has(t))return Oc(`configForCategory: ${t} exists in config, returning it`),yo.get(t);let e;return t.indexOf(".")>0?(Oc(`configForCategory: ${t} has hierarchy, cloning from parents`),e={...Ps(t.slice(0,t.lastIndexOf(".")))}):(yo.has("default")||Gy({categories:{default:{appenders:["out"],level:"OFF"}}}),Oc("configForCategory: cloning default category"),e={...yo.get("default")}),yo.set(t,e),e},dU=t=>Ps(t).appenders,mU=t=>Ps(t).level,hU=(t,e)=>{Ps(t).level=e},gU=t=>Ps(t).enableCallStack===!0,yU=(t,e)=>{Ps(t).enableCallStack=e};zf.exports=yo;zf.exports=Object.assign(zf.exports,{appendersForCategory:dU,getLevelForCategory:mU,setLevelForCategory:hU,getEnableCallStackForCategory:gU,setEnableCallStackForCategory:yU,init:zT})});var VT=b((Kfe,KT)=>{a();var UT=Xe()("log4js:logger"),bU=uy(),rn=fi(),vU=Ef(),Uf=Zy(),WT=li(),wU=/at (?:(.+)\s+\()?(?:(.+?):(\d+)(?::(\d+))?|([^)]+))\)?/;function xU(t,e=4){try{let r=t.stack.split(` +`).slice(e),n=wU.exec(r[0]);if(n&&n.length===6)return{functionName:n[1],fileName:n[2],lineNumber:parseInt(n[3],10),columnNumber:parseInt(n[4],10),callStack:r.join(` +`)};console.error("log4js.logger - defaultParseCallStack error")}catch(r){console.error("log4js.logger - defaultParseCallStack error",r)}return null}var Cc=class{constructor(e){if(!e)throw new Error("No category provided.");this.category=e,this.context={},this.parseCallStack=xU,UT(`Logger created (${this.category}, ${this.level})`)}get level(){return rn.getLevel(Uf.getLevelForCategory(this.category),rn.OFF)}set level(e){Uf.setLevelForCategory(this.category,rn.getLevel(e,this.level))}get useCallStack(){return Uf.getEnableCallStackForCategory(this.category)}set useCallStack(e){Uf.setEnableCallStackForCategory(this.category,e===!0)}log(e,...r){let n=rn.getLevel(e);n?this.isLevelEnabled(n)&&this._log(n,r):WT.validIdentifier(e)&&r.length>0?(this.log(rn.WARN,"log4js:logger.log: valid log-level not found as first parameter given:",e),this.log(rn.INFO,`[${e}]`,...r)):this.log(rn.INFO,e,...r)}isLevelEnabled(e){return this.level.isLessThanOrEqualTo(e)}_log(e,r){UT(`sending log data (${e}) to appenders`);let n=new bU(this.category,e,r,this.context,this.useCallStack&&this.parseCallStack(new Error));vU.send(n)}addContext(e,r){this.context[e]=r}removeContext(e){delete this.context[e]}clearContext(){this.context={}}setParseCallStackFunction(e){this.parseCallStack=e}};function HT(t){let e=rn.getLevel(t),n=e.toString().toLowerCase().replace(/_([a-z])/g,i=>i[1].toUpperCase()),o=n[0].toUpperCase()+n.slice(1);Cc.prototype[`is${o}Enabled`]=function(){return this.isLevelEnabled(e)},Cc.prototype[n]=function(...i){this.log(e,...i)}}rn.levels.forEach(HT);WT.addListener(()=>{rn.levels.forEach(HT)});KT.exports=Cc});var JT=b((Gfe,ZT)=>{a();var Fs=fi(),EU=':remote-addr - - ":method :url HTTP/:http-version" :status :content-length ":referrer" ":user-agent"';function SU(t){return t.originalUrl||t.url}function IU(t,e,r){let n=i=>{let s=i.concat();for(let c=0;cn.source?n.source:n);e=new RegExp(r.join("|"))}return e}function TU(t,e,r){let n=e;if(r){let o=r.find(i=>{let s=!1;return i.from&&i.to?s=t>=i.from&&t<=i.to:s=i.codes.indexOf(t)!==-1,s});o&&(n=Fs.getLevel(o.level,n))}return n}ZT.exports=function(e,r){typeof r=="string"||typeof r=="function"?r={format:r}:r=r||{};let n=e,o=Fs.getLevel(r.level,Fs.INFO),i=r.format||EU;return(s,c,l)=>{if(s._logging!==void 0)return l();if(typeof r.nolog!="function"){let f=_U(r.nolog);if(f&&f.test(s.originalUrl))return l()}if(n.isLevelEnabled(o)||r.level==="auto"){let f=new Date,{writeHead:u}=c;s._logging=!0,c.writeHead=(h,y)=>{c.writeHead=u,c.writeHead(h,y),c.__statusCode=h,c.__headers=y||{}};let d=!1,m=()=>{if(d)return;if(d=!0,typeof r.nolog=="function"&&r.nolog(s,c)===!0){s._logging=!1;return}c.responseTime=new Date-f,c.statusCode&&r.level==="auto"&&(o=Fs.INFO,c.statusCode>=300&&(o=Fs.WARN),c.statusCode>=400&&(o=Fs.ERROR)),o=TU(c.statusCode,o,r.statusRules);let h=IU(s,c,r.tokens||[]);if(r.context&&n.addContext("res",c),typeof i=="function"){let y=i(s,c,w=>GT(w,h));y&&n.log(o,y)}else n.log(o,GT(i,h));r.context&&n.removeContext("res")};c.on("end",m),c.on("finish",m),c.on("error",m),c.on("close",m)}return l()}}});var tO=b((Jfe,eO)=>{a();var YT=Xe()("log4js:recording"),Wf=[];function OU(){return function(t){YT(`received logEvent, number of events now ${Wf.length+1}`),YT("log event was ",t),Wf.push(t)}}function XT(){return Wf.slice()}function QT(){Wf.length=0}eO.exports={configure:OU,replay:XT,playback:XT,reset:QT,erase:QT}});var cO=b((Xfe,aO)=>{a();var bo=Xe()("log4js:main"),CU=require("fs"),kU=GS()({proto:!0}),AU=li(),RU=ly(),NU=fi(),rO=Ky(),nO=Zy(),DU=VT(),PU=Ef(),FU=JT(),MU=tO(),kc=!1;function $U(t){if(!kc)return;bo("Received log event ",t),nO.appendersForCategory(t.categoryName).forEach(r=>{r(t)})}function LU(t){bo(`Loading configuration from ${t}`);try{return JSON.parse(CU.readFileSync(t,"utf8"))}catch(e){throw new Error(`Problem reading config from file "${t}". Error was ${e.message}`,e)}}function oO(t){kc&&iO();let e=t;return typeof e=="string"&&(e=LU(t)),bo(`Configuration is ${e}`),AU.configure(kU(e)),PU.onMessage($U),kc=!0,sO}function jU(){return MU}function iO(t){bo("Shutdown called. Disabling all log writing."),kc=!1;let e=Array.from(rO.values());rO.init(),nO.init();let r=e.reduceRight((s,c)=>c.shutdown?s+1:s,0);if(r===0)return bo("No appenders with shutdown functions found."),t!==void 0&&t();let n=0,o;bo(`Found ${r} appenders with shutdown functions.`);function i(s){o=o||s,n+=1,bo(`Appender shutdowns complete: ${n} / ${r}`),n>=r&&(bo("All shutdown functions completed."),t&&t(o))}return e.filter(s=>s.shutdown).forEach(s=>s.shutdown(i)),null}function qU(t){return kc||oO(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new DU(t||"default")}var sO={getLogger:qU,configure:oO,shutdown:iO,connectLogger:FU,levels:NU,addLayout:RU.addLayout,recording:jU};aO.exports=sO});var Ms=b(Hf=>{"use strict";a();Object.defineProperty(Hf,"__esModule",{value:!0});function lO(t,e){if(e)return t;throw new Error("Unhandled discriminated union member: "+JSON.stringify(t))}Hf.assertNever=lO;Hf.default=lO});var pO=b((rpe,fO)=>{"use strict";a();var BU=["h","min","s","ms","\u03BCs","ns"],zU=["hour","minute","second","millisecond","microsecond","nanosecond"],uO=[3600,60,1,1e6,1e3,1];fO.exports=function(t,e){var r,n,o,i,s,c,l,f,u,d;if(r=!1,n=!1,e&&(r=e.verbose||!1,n=e.precise||!1),!Array.isArray(t)||t.length!==2||typeof t[0]!="number"||typeof t[1]!="number")return"";for(t[1]<0&&(d=t[0]+t[1]/1e9,t[0]=parseInt(d),t[1]=parseFloat((d%1).toPrecision(9))*1e9),u="",o=0;o<6&&(i=o<3?0:1,s=t[i],o!==3&&o!==0&&(s=s%uO[o-1]),o===2&&(s+=t[1]/1e9),c=s/uO[o],!(c>=1&&(r&&(c=Math.floor(c)),n?f=c.toString():(l=c>=10?0:2,f=c.toFixed(l)),f.indexOf(".")>-1&&f[f.length-1]==="0"&&(f=f.replace(/\.?0+$/,"")),u&&(u+=" "),u+=f,r?(u+=" "+zU[o],f!=="1"&&(u+="s")):u+=" "+BU[o],!r)));o++);return u}});var mO=b((ope,dO)=>{"use strict";a();dO.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var vO=b((spe,bO)=>{"use strict";a();var yO="%[a-f0-9]{2}",hO=new RegExp("("+yO+")|([^%]+?)","gi"),gO=new RegExp("("+yO+")+","gi");function Jy(t,e){try{return[decodeURIComponent(t.join(""))]}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Jy(r),Jy(n))}function UU(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(hO)||[],r=1;r{"use strict";a();wO.exports=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];let r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]}});var SO=b((upe,EO)=>{"use strict";a();EO.exports=function(t,e){for(var r={},n=Object.keys(t),o=Array.isArray(e),i=0;i{"use strict";a();var HU=mO(),KU=vO(),_O=xO(),VU=SO(),GU=t=>t==null,Yy=Symbol("encodeFragmentIdentifier");function ZU(t){switch(t.arrayFormat){case"index":return e=>(r,n)=>{let o=r.length;return n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[je(e,t),"[",o,"]"].join("")]:[...r,[je(e,t),"[",je(o,t),"]=",je(n,t)].join("")]};case"bracket":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[je(e,t),"[]"].join("")]:[...r,[je(e,t),"[]=",je(n,t)].join("")];case"colon-list-separator":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[je(e,t),":list="].join("")]:[...r,[je(e,t),":list=",je(n,t)].join("")];case"comma":case"separator":case"bracket-separator":{let e=t.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(n,o)=>o===void 0||t.skipNull&&o===null||t.skipEmptyString&&o===""?n:(o=o===null?"":o,n.length===0?[[je(r,t),e,je(o,t)].join("")]:[[n,je(o,t)].join(t.arrayFormatSeparator)])}default:return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,je(e,t)]:[...r,[je(e,t),"=",je(n,t)].join("")]}}function JU(t){let e;switch(t.arrayFormat){case"index":return(r,n,o)=>{if(e=/\[(\d*)\]$/.exec(r),r=r.replace(/\[\d*\]$/,""),!e){o[r]=n;return}o[r]===void 0&&(o[r]={}),o[r][e[1]]=n};case"bracket":return(r,n,o)=>{if(e=/(\[\])$/.exec(r),r=r.replace(/\[\]$/,""),!e){o[r]=n;return}if(o[r]===void 0){o[r]=[n];return}o[r]=[].concat(o[r],n)};case"colon-list-separator":return(r,n,o)=>{if(e=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!e){o[r]=n;return}if(o[r]===void 0){o[r]=[n];return}o[r]=[].concat(o[r],n)};case"comma":case"separator":return(r,n,o)=>{let i=typeof n=="string"&&n.includes(t.arrayFormatSeparator),s=typeof n=="string"&&!i&&kn(n,t).includes(t.arrayFormatSeparator);n=s?kn(n,t):n;let c=i||s?n.split(t.arrayFormatSeparator).map(l=>kn(l,t)):n===null?n:kn(n,t);o[r]=c};case"bracket-separator":return(r,n,o)=>{let i=/(\[\])$/.test(r);if(r=r.replace(/\[\]$/,""),!i){o[r]=n&&kn(n,t);return}let s=n===null?[]:n.split(t.arrayFormatSeparator).map(c=>kn(c,t));if(o[r]===void 0){o[r]=s;return}o[r]=[].concat(o[r],s)};default:return(r,n,o)=>{if(o[r]===void 0){o[r]=n;return}o[r]=[].concat(o[r],n)}}}function TO(t){if(typeof t!="string"||t.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function je(t,e){return e.encode?e.strict?HU(t):encodeURIComponent(t):t}function kn(t,e){return e.decode?KU(t):t}function OO(t){return Array.isArray(t)?t.sort():typeof t=="object"?OO(Object.keys(t)).sort((e,r)=>Number(e)-Number(r)).map(e=>t[e]):t}function CO(t){let e=t.indexOf("#");return e!==-1&&(t=t.slice(0,e)),t}function YU(t){let e="",r=t.indexOf("#");return r!==-1&&(e=t.slice(r)),e}function kO(t){t=CO(t);let e=t.indexOf("?");return e===-1?"":t.slice(e+1)}function IO(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&typeof t=="string"&&t.trim()!==""?t=Number(t):e.parseBooleans&&t!==null&&(t.toLowerCase()==="true"||t.toLowerCase()==="false")&&(t=t.toLowerCase()==="true"),t}function AO(t,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),TO(e.arrayFormatSeparator);let r=JU(e),n=Object.create(null);if(typeof t!="string"||(t=t.trim().replace(/^[?#&]/,""),!t))return n;for(let o of t.split("&")){if(o==="")continue;let[i,s]=_O(e.decode?o.replace(/\+/g," "):o,"=");s=s===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?s:kn(s,e),r(kn(i,e),s,n)}for(let o of Object.keys(n)){let i=n[o];if(typeof i=="object"&&i!==null)for(let s of Object.keys(i))i[s]=IO(i[s],e);else n[o]=IO(i,e)}return e.sort===!1?n:(e.sort===!0?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((o,i)=>{let s=n[i];return s&&typeof s=="object"&&!Array.isArray(s)?o[i]=OO(s):o[i]=s,o},Object.create(null))}Ft.extract=kO;Ft.parse=AO;Ft.stringify=(t,e)=>{if(!t)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),TO(e.arrayFormatSeparator);let r=s=>e.skipNull&&GU(t[s])||e.skipEmptyString&&t[s]==="",n=ZU(e),o={};for(let s of Object.keys(t))r(s)||(o[s]=t[s]);let i=Object.keys(o);return e.sort!==!1&&i.sort(e.sort),i.map(s=>{let c=t[s];return c===void 0?"":c===null?je(s,e):Array.isArray(c)?c.length===0&&e.arrayFormat==="bracket-separator"?je(s,e)+"[]":c.reduce(n(s),[]).join("&"):je(s,e)+"="+je(c,e)}).filter(s=>s.length>0).join("&")};Ft.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);let[r,n]=_O(t,"#");return Object.assign({url:r.split("?")[0]||"",query:AO(kO(t),e)},e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:kn(n,e)}:{})};Ft.stringifyUrl=(t,e)=>{e=Object.assign({encode:!0,strict:!0,[Yy]:!0},e);let r=CO(t.url).split("?")[0]||"",n=Ft.extract(t.url),o=Ft.parse(n,{sort:!1}),i=Object.assign(o,t.query),s=Ft.stringify(i,e);s&&(s=`?${s}`);let c=YU(t.url);return t.fragmentIdentifier&&(c=`#${e[Yy]?je(t.fragmentIdentifier,e):t.fragmentIdentifier}`),`${r}${s}${c}`};Ft.pick=(t,e,r)=>{r=Object.assign({parseFragmentIdentifier:!0,[Yy]:!1},r);let{url:n,query:o,fragmentIdentifier:i}=Ft.parseUrl(t,r);return Ft.stringifyUrl({url:n,query:VU(o,e),fragmentIdentifier:i},r)};Ft.exclude=(t,e,r)=>{let n=Array.isArray(e)?o=>!e.includes(o):(o,i)=>!e(o,i);return Ft.pick(t,n,r)}});function Fn(t,e){for(var r in e)t[r]=e[r];return t}function tA(t){var e=t.parentNode;e&&e.removeChild(t)}function V(t,e,r){var n,o,i,s={};for(i in e)i=="key"?n=e[i]:i=="ref"?o=e[i]:s[i]=e[i];if(arguments.length>2&&(s.children=arguments.length>3?el.call(arguments,2):r),typeof t=="function"&&t.defaultProps!=null)for(i in t.defaultProps)s[i]===void 0&&(s[i]=t.defaultProps[i]);return Xc(t,s,n,o,null)}function Xc(t,e,r,n,o){var i={type:t,props:e,key:r,ref:n,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:o??++Xk};return o==null&&z.vnode!=null&&z.vnode(i),i}function Mp(){return{current:null}}function L(t){return t.children}function Xt(t,e){this.props=t,this.context=e}function Qc(t,e){if(e==null)return t.__?Qc(t.__,t.__.__k.indexOf(t)+1):null;for(var r;e0?Xc(h.type,h.props,h.key,h.ref?h.ref:null,h.__v):h)!=null){if(h.__=r,h.__b=r.__b+1,(m=x[u])===null||m&&h.key==m.key&&h.type===m.type)x[u]=void 0;else for(d=0;d2&&(s.children=arguments.length>3?el.call(arguments,2):r),Xc(t.type,s,n||t.key,o||t.ref,null)}function Ve(t,e){var r={__c:e="__cC"+Qk++,__:t,Consumer:function(n,o){return n.children(o)},Provider:function(n){var o,i;return this.getChildContext||(o=[],(i={})[e]=this,this.getChildContext=function(){return i},this.shouldComponentUpdate=function(s){this.props.value!==s.value&&o.some(Zb)},this.sub=function(s){o.push(s);var c=s.componentWillUnmount;s.componentWillUnmount=function(){o.splice(o.indexOf(s),1),c&&c.call(s)}}),n.children}};return r.Provider.__=r.Consumer.contextType=r}var el,z,Xk,_7,Yc,Gk,Qk,Dp,eA,T7,Ys=rc(()=>{a();Dp={},eA=[],T7=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;el=eA.slice,z={__e:function(t,e,r,n){for(var o,i,s;e=e.__;)if((o=e.__c)&&!o.__)try{if((i=o.constructor)&&i.getDerivedStateFromError!=null&&(o.setState(i.getDerivedStateFromError(t)),s=o.__d),o.componentDidCatch!=null&&(o.componentDidCatch(t,n||{}),s=o.__d),s)return o.__E=o}catch(c){t=c}throw t}},Xk=0,_7=function(t){return t!=null&&t.constructor===void 0},Xt.prototype.setState=function(t,e){var r;r=this.__s!=null&&this.__s!==this.state?this.__s:this.__s=Fn({},this.state),typeof t=="function"&&(t=t(Fn({},r),this.props)),t&&Fn(r,t),t!=null&&this.__v&&(e&&this._sb.push(e),Zb(this))},Xt.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),Zb(this))},Xt.prototype.render=L,Yc=[],Pp.__r=0,Qk=0});function Oi(t,e){z.__h&&z.__h(ke,t,Xs||e),Xs=0;var r=ke.__H||(ke.__H={__:[],__h:[]});return t>=r.__.length&&r.__.push({__V:$p}),r.__[t]}function q(t){return Xs=1,un(bA,t)}function un(t,e,r){var n=Oi(To++,2);if(n.t=t,!n.__c&&(n.__=[r?r(e):bA(void 0,e),function(i){var s=n.__N?n.__N[0]:n.__[0],c=n.t(s,i);s!==c&&(n.__N=[c,n.__[1]],n.__c.setState({}))}],n.__c=ke,!ke.u)){ke.u=!0;var o=ke.shouldComponentUpdate;ke.shouldComponentUpdate=function(i,s,c){if(!n.__c.__H)return!0;var l=n.__c.__H.__.filter(function(u){return u.__c});if(l.every(function(u){return!u.__N}))return!o||o.call(this,i,s,c);var f=!1;return l.forEach(function(u){if(u.__N){var d=u.__[0];u.__=u.__N,u.__N=void 0,d!==u.__[0]&&(f=!0)}}),!(!f&&n.__c.props===i)&&(!o||o.call(this,i,s,c))}}return n.__N||n.__}function K(t,e){var r=Oi(To++,3);!z.__s&&rv(r.__H,e)&&(r.__=t,r.i=e,ke.__H.__h.push(r))}function Lt(t,e){var r=Oi(To++,4);!z.__s&&rv(r.__H,e)&&(r.__=t,r.i=e,ke.__h.push(r))}function $(t){return Xs=5,ae(function(){return{current:t}},[])}function ev(t,e,r){Xs=6,Lt(function(){return typeof t=="function"?(t(e()),function(){return t(null)}):t?(t.current=e(),function(){return t.current=null}):void 0},r==null?r:r.concat(t))}function ae(t,e){var r=Oi(To++,7);return rv(r.__H,e)?(r.__V=t(),r.i=e,r.__h=t,r.__V):r.__}function ee(t,e){return Xs=8,ae(function(){return t},e)}function ne(t){var e=ke.context[t.__c],r=Oi(To++,9);return r.c=t,e?(r.__==null&&(r.__=!0,e.sub(ke)),e.props.value):t.__}function Ci(t,e){z.useDebugValue&&z.useDebugValue(e?e(t):t)}function A7(t){var e=Oi(To++,10),r=q();return e.__=t,ke.componentDidCatch||(ke.componentDidCatch=function(n,o){e.__&&e.__(n,o),r[1](n)}),[r[0],function(){r[1](void 0)}]}function tv(){var t=Oi(To++,11);if(!t.__){for(var e=ke.__v;e!==null&&!e.__m&&e.__!==null;)e=e.__;var r=e.__m||(e.__m=[0,0]);t.__="P"+r[0]+"-"+r[1]++}return t.__}function R7(){for(var t;t=yA.shift();)if(t.__P&&t.__H)try{t.__H.__h.forEach(Lp),t.__H.__h.forEach(Qb),t.__H.__h=[]}catch(e){t.__H.__h=[],z.__e(e,t.__v)}}function N7(t){var e,r=function(){clearTimeout(n),gA&&cancelAnimationFrame(e),setTimeout(t)},n=setTimeout(r,100);gA&&(e=requestAnimationFrame(r))}function Lp(t){var e=ke,r=t.__c;typeof r=="function"&&(t.__c=void 0,r()),ke=e}function Qb(t){var e=ke;t.__c=t.__(),ke=e}function rv(t,e){return!t||t.length!==e.length||e.some(function(r,n){return r!==t[n]})}function bA(t,e){return typeof e=="function"?e(t):e}var To,ke,Xb,uA,Xs,yA,$p,fA,pA,dA,mA,hA,gA,nv=rc(()=>{a();Ys();Xs=0,yA=[],$p=[],fA=z.__b,pA=z.__r,dA=z.diffed,mA=z.__c,hA=z.unmount;z.__b=function(t){ke=null,fA&&fA(t)},z.__r=function(t){pA&&pA(t),To=0;var e=(ke=t.__c).__H;e&&(Xb===ke?(e.__h=[],ke.__h=[],e.__.forEach(function(r){r.__N&&(r.__=r.__N),r.__V=$p,r.__N=r.i=void 0})):(e.__h.forEach(Lp),e.__h.forEach(Qb),e.__h=[])),Xb=ke},z.diffed=function(t){dA&&dA(t);var e=t.__c;e&&e.__H&&(e.__H.__h.length&&(yA.push(e)!==1&&uA===z.requestAnimationFrame||((uA=z.requestAnimationFrame)||N7)(R7)),e.__H.__.forEach(function(r){r.i&&(r.__H=r.i),r.__V!==$p&&(r.__=r.__V),r.i=void 0,r.__V=$p})),Xb=ke=null},z.__c=function(t,e){e.some(function(r){try{r.__h.forEach(Lp),r.__h=r.__h.filter(function(n){return!n.__||Qb(n)})}catch(n){e.some(function(o){o.__h&&(o.__h=[])}),e=[],z.__e(n,r.__v)}}),mA&&mA(t,e)},z.unmount=function(t){hA&&hA(t);var e,r=t.__c;r&&r.__H&&(r.__H.__.forEach(function(n){try{Lp(n)}catch(o){e=o}}),r.__H=void 0,e&&z.__e(e,r.__v))};gA=typeof requestAnimationFrame=="function"});function OA(t,e){for(var r in e)t[r]=e[r];return t}function iv(t,e){for(var r in t)if(r!=="__source"&&!(r in e))return!0;for(var n in e)if(n!=="__source"&&t[n]!==e[n])return!0;return!1}function ov(t,e){return t===e&&(t!==0||1/t==1/e)||t!=t&&e!=e}function jp(t){this.props=t}function yt(t,e){function r(o){var i=this.props.ref,s=i==o.ref;return!s&&i&&(i.call?i(null):i.current=null),e?!e(this.props,o)||!s:iv(this.props,o)}function n(o){return this.shouldComponentUpdate=r,V(t,o)}return n.displayName="Memo("+(t.displayName||t.name)+")",n.prototype.isReactComponent=!0,n.__f=!0,n}function Q(t){function e(r){var n=OA({},r);return delete n.ref,t(n,r.ref||null)}return e.$$typeof=D7,e.render=e,e.prototype.isReactComponent=e.__f=!0,e.displayName="ForwardRef("+(t.displayName||t.name)+")",e}function CA(t,e,r){return t&&(t.__c&&t.__c.__H&&(t.__c.__H.__.forEach(function(n){typeof n.__c=="function"&&n.__c()}),t.__c.__H=null),(t=OA({},t)).__c!=null&&(t.__c.__P===r&&(t.__c.__P=e),t.__c=null),t.__k=t.__k&&t.__k.map(function(n){return CA(n,e,r)})),t}function kA(t,e,r){return t&&(t.__v=null,t.__k=t.__k&&t.__k.map(function(n){return kA(n,e,r)}),t.__c&&t.__c.__P===e&&(t.__e&&r.insertBefore(t.__e,t.__d),t.__c.__e=!0,t.__c.__P=r)),t}function tl(){this.__u=0,this.t=null,this.__b=null}function AA(t){var e=t.__.__c;return e&&e.__a&&e.__a(t)}function RA(t){var e,r,n;function o(i){if(e||(e=t()).then(function(s){r=s.default||s},function(s){n=s}),n)throw n;if(!r)throw e;return V(r,i)}return o.displayName="Lazy",o.__f=!0,o}function Qs(){this.u=null,this.o=null}function F7(t){return this.getChildContext=function(){return t.context},t.children}function M7(t){var e=this,r=t.i;e.componentWillUnmount=function(){Js(null,e.l),e.l=null,e.i=null},e.i&&e.i!==r&&e.componentWillUnmount(),t.__v?(e.l||(e.i=r,e.l={nodeType:1,parentNode:r,childNodes:[],appendChild:function(n){this.childNodes.push(n),e.i.appendChild(n)},insertBefore:function(n,o){this.childNodes.push(n),e.i.appendChild(n)},removeChild:function(n){this.childNodes.splice(this.childNodes.indexOf(n)>>>1,1),e.i.removeChild(n)}}),Js(V(F7,{context:e.context},t.__v),e.l)):e.l&&e.componentWillUnmount()}function NA(t,e){var r=V(M7,{__v:t,i:e});return r.containerInfo=e,r}function PA(t,e,r){return e.__k==null&&(e.textContent=""),Js(t,e),typeof r=="function"&&r(),t?t.__c:null}function FA(t,e,r){return Yb(t,e),typeof r=="function"&&r(),t?t.__c:null}function q7(){}function B7(){return this.cancelBubble}function z7(){return this.defaultPrevented}function LA(t){return V.bind(null,t)}function Qt(t){return!!t&&t.$$typeof===DA}function wr(t){return Qt(t)?lA.apply(null,arguments):t}function jA(t){return!!t.__k&&(Js(null,t),!0)}function qA(t){return t&&(t.base||t.nodeType===1&&t)||null}function sv(t){t()}function UA(t){return t}function WA(){return[!1,sv]}function KA(t,e){var r=e(),n=q({h:{__:r,v:e}}),o=n[0].h,i=n[1];return Lt(function(){o.__=r,o.v=e,ov(o.__,e())||i({h:o})},[t,r,e]),K(function(){return ov(o.__,o.v())||i({h:o}),t(function(){ov(o.__,o.v())||i({h:o})})},[t]),r}var vA,D7,wA,rt,P7,xA,EA,DA,$7,L7,j7,SA,MA,IA,_A,TA,$A,U7,BA,fn,zA,HA,P,av=rc(()=>{a();Ys();Ys();nv();nv();(jp.prototype=new Xt).isPureReactComponent=!0,jp.prototype.shouldComponentUpdate=function(t,e){return iv(this.props,t)||iv(this.state,e)};vA=z.__b;z.__b=function(t){t.type&&t.type.__f&&t.ref&&(t.props.ref=t.ref,t.ref=null),vA&&vA(t)};D7=typeof Symbol<"u"&&Symbol.for&&Symbol.for("react.forward_ref")||3911;wA=function(t,e){return t==null?null:ln(ln(t).map(e))},rt={map:wA,forEach:wA,count:function(t){return t?ln(t).length:0},only:function(t){var e=ln(t);if(e.length!==1)throw"Children.only";return e[0]},toArray:ln},P7=z.__e;z.__e=function(t,e,r,n){if(t.then){for(var o,i=e;i=i.__;)if((o=i.__c)&&o.__c)return e.__e==null&&(e.__e=r.__e,e.__k=r.__k),o.__c(t,e)}P7(t,e,r,n)};xA=z.unmount;z.unmount=function(t){var e=t.__c;e&&e.__R&&e.__R(),e&&t.__h===!0&&(t.type=null),xA&&xA(t)},(tl.prototype=new Xt).__c=function(t,e){var r=e.__c,n=this;n.t==null&&(n.t=[]),n.t.push(r);var o=AA(n.__v),i=!1,s=function(){i||(i=!0,r.__R=null,o?o(c):c())};r.__R=s;var c=function(){if(!--n.__u){if(n.state.__a){var f=n.state.__a;n.__v.__k[0]=kA(f,f.__c.__P,f.__c.__O)}var u;for(n.setState({__a:n.__b=null});u=n.t.pop();)u.forceUpdate()}},l=e.__h===!0;n.__u++||l||n.setState({__a:n.__b=n.__v.__k[0]}),t.then(s,s)},tl.prototype.componentWillUnmount=function(){this.t=[]},tl.prototype.render=function(t,e){if(this.__b){if(this.__v.__k){var r=document.createElement("div"),n=this.__v.__k[0].__c;this.__v.__k[0]=CA(this.__b,r,n.__O=n.__P)}this.__b=null}var o=e.__a&&V(L,null,t.fallback);return o&&(o.__h=null),[V(L,null,e.__a?null:t.children),o]};EA=function(t,e,r){if(++r[1]===r[0]&&t.o.delete(e),t.props.revealOrder&&(t.props.revealOrder[0]!=="t"||!t.o.size))for(r=t.u;r;){for(;r.length>3;)r.pop()();if(r[1]rt,Component:()=>Xt,Fragment:()=>L,PureComponent:()=>jp,StrictMode:()=>zA,Suspense:()=>tl,SuspenseList:()=>Qs,__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:()=>$A,cloneElement:()=>wr,createContext:()=>Ve,createElement:()=>V,createFactory:()=>LA,createPortal:()=>NA,createRef:()=>Mp,default:()=>P,findDOMNode:()=>qA,flushSync:()=>fn,forwardRef:()=>Q,hydrate:()=>FA,isValidElement:()=>Qt,lazy:()=>RA,memo:()=>yt,render:()=>PA,startTransition:()=>sv,unmountComponentAtNode:()=>jA,unstable_batchedUpdates:()=>BA,useCallback:()=>ee,useContext:()=>ne,useDebugValue:()=>Ci,useDeferredValue:()=>UA,useEffect:()=>K,useErrorBoundary:()=>A7,useId:()=>tv,useImperativeHandle:()=>ev,useInsertionEffect:()=>HA,useLayoutEffect:()=>Lt,useMemo:()=>ae,useReducer:()=>un,useRef:()=>$,useState:()=>q,useSyncExternalStore:()=>KA,useTransition:()=>WA,version:()=>U7});var _=rc(()=>{a();av();av()});var Tr=b((MD,$D)=>{"use strict";a();var vm=function(t){return t&&t.Math===Math&&t};$D.exports=vm(typeof globalThis=="object"&&globalThis)||vm(typeof window=="object"&&window)||vm(typeof self=="object"&&self)||vm(typeof global=="object"&&global)||function(){return this}()||MD||Function("return this")()});var Ot=b((kAe,LD)=>{"use strict";a();LD.exports=function(t){try{return!!t()}catch{return!0}}});var Jl=b((RAe,jD)=>{"use strict";a();var wV=Ot();jD.exports=!wV(function(){var t=function(){}.bind();return typeof t!="function"||t.hasOwnProperty("prototype")})});var WD=b((DAe,UD)=>{"use strict";a();var xV=Jl(),zD=Function.prototype,qD=zD.apply,BD=zD.call;UD.exports=typeof Reflect=="object"&&Reflect.apply||(xV?BD.bind(qD):function(){return BD.apply(qD,arguments)})});var Ct=b((FAe,VD)=>{"use strict";a();var HD=Jl(),KD=Function.prototype,G0=KD.call,EV=HD&&KD.bind.bind(G0,G0);VD.exports=HD?EV:function(t){return function(){return G0.apply(t,arguments)}}});var Zi=b(($Ae,ZD)=>{"use strict";a();var GD=Ct(),SV=GD({}.toString),IV=GD("".slice);ZD.exports=function(t){return IV(SV(t),8,-1)}});var Z0=b((jAe,JD)=>{"use strict";a();var _V=Zi(),TV=Ct();JD.exports=function(t){if(_V(t)==="Function")return TV(t)}});var Y0=b((BAe,YD)=>{"use strict";a();var J0=typeof document=="object"&&document.all,OV=typeof J0>"u"&&J0!==void 0;YD.exports={all:J0,IS_HTMLDDA:OV}});var at=b((UAe,QD)=>{"use strict";a();var XD=Y0(),CV=XD.all;QD.exports=XD.IS_HTMLDDA?function(t){return typeof t=="function"||t===CV}:function(t){return typeof t=="function"}});var Or=b((HAe,eP)=>{"use strict";a();var kV=Ot();eP.exports=!kV(function(){return Object.defineProperty({},1,{get:function(){return 7}})[1]!==7})});var Yn=b((VAe,tP)=>{"use strict";a();var AV=Jl(),wm=Function.prototype.call;tP.exports=AV?wm.bind(wm):function(){return wm.apply(wm,arguments)}});var iP=b(oP=>{"use strict";a();var rP={}.propertyIsEnumerable,nP=Object.getOwnPropertyDescriptor,RV=nP&&!rP.call({1:2},1);oP.f=RV?function(e){var r=nP(this,e);return!!r&&r.enumerable}:rP});var Yl=b((YAe,sP)=>{"use strict";a();sP.exports=function(t,e){return{enumerable:!(t&1),configurable:!(t&2),writable:!(t&4),value:e}}});var Q0=b((QAe,aP)=>{"use strict";a();var NV=Ct(),DV=Ot(),PV=Zi(),X0=Object,FV=NV("".split);aP.exports=DV(function(){return!X0("z").propertyIsEnumerable(0)})?function(t){return PV(t)==="String"?FV(t,""):X0(t)}:X0});var Ia=b((tRe,cP)=>{"use strict";a();cP.exports=function(t){return t==null}});var Xl=b((nRe,lP)=>{"use strict";a();var MV=Ia(),$V=TypeError;lP.exports=function(t){if(MV(t))throw $V("Can't call method on "+t);return t}});var _a=b((iRe,uP)=>{"use strict";a();var LV=Q0(),jV=Xl();uP.exports=function(t){return LV(jV(t))}});var Ur=b((aRe,dP)=>{"use strict";a();var fP=at(),pP=Y0(),qV=pP.all;dP.exports=pP.IS_HTMLDDA?function(t){return typeof t=="object"?t!==null:fP(t)||t===qV}:function(t){return typeof t=="object"?t!==null:fP(t)}});var Ql=b((lRe,mP)=>{"use strict";a();mP.exports={}});var Ji=b((fRe,gP)=>{"use strict";a();var ew=Ql(),tw=Tr(),BV=at(),hP=function(t){return BV(t)?t:void 0};gP.exports=function(t,e){return arguments.length<2?hP(ew[t])||hP(tw[t]):ew[t]&&ew[t][e]||tw[t]&&tw[t][e]}});var xm=b((dRe,yP)=>{"use strict";a();var zV=Ct();yP.exports=zV({}.isPrototypeOf)});var vP=b((hRe,bP)=>{"use strict";a();bP.exports=typeof navigator<"u"&&String(navigator.userAgent)||""});var TP=b((yRe,_P)=>{"use strict";a();var IP=Tr(),rw=vP(),wP=IP.process,xP=IP.Deno,EP=wP&&wP.versions||xP&&xP.version,SP=EP&&EP.v8,Wr,Em;SP&&(Wr=SP.split("."),Em=Wr[0]>0&&Wr[0]<4?1:+(Wr[0]+Wr[1]));!Em&&rw&&(Wr=rw.match(/Edge\/(\d+)/),(!Wr||Wr[1]>=74)&&(Wr=rw.match(/Chrome\/(\d+)/),Wr&&(Em=+Wr[1])));_P.exports=Em});var nw=b((vRe,CP)=>{"use strict";a();var OP=TP(),UV=Ot(),WV=Tr(),HV=WV.String;CP.exports=!!Object.getOwnPropertySymbols&&!UV(function(){var t=Symbol("symbol detection");return!HV(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&OP&&OP<41})});var ow=b((xRe,kP)=>{"use strict";a();var KV=nw();kP.exports=KV&&!Symbol.sham&&typeof Symbol.iterator=="symbol"});var iw=b((SRe,AP)=>{"use strict";a();var VV=Ji(),GV=at(),ZV=xm(),JV=ow(),YV=Object;AP.exports=JV?function(t){return typeof t=="symbol"}:function(t){var e=VV("Symbol");return GV(e)&&ZV(e.prototype,YV(t))}});var Sm=b((_Re,RP)=>{"use strict";a();var XV=String;RP.exports=function(t){try{return XV(t)}catch{return"Object"}}});var Yi=b((ORe,NP)=>{"use strict";a();var QV=at(),eG=Sm(),tG=TypeError;NP.exports=function(t){if(QV(t))return t;throw tG(eG(t)+" is not a function")}});var Im=b((kRe,DP)=>{"use strict";a();var rG=Yi(),nG=Ia();DP.exports=function(t,e){var r=t[e];return nG(r)?void 0:rG(r)}});var FP=b((RRe,PP)=>{"use strict";a();var sw=Yn(),aw=at(),cw=Ur(),oG=TypeError;PP.exports=function(t,e){var r,n;if(e==="string"&&aw(r=t.toString)&&!cw(n=sw(r,t))||aw(r=t.valueOf)&&!cw(n=sw(r,t))||e!=="string"&&aw(r=t.toString)&&!cw(n=sw(r,t)))return n;throw oG("Can't convert object to primitive value")}});var eu=b((DRe,MP)=>{"use strict";a();MP.exports=!0});var jP=b((FRe,LP)=>{"use strict";a();var $P=Tr(),iG=Object.defineProperty;LP.exports=function(t,e){try{iG($P,t,{value:e,configurable:!0,writable:!0})}catch{$P[t]=e}return e}});var _m=b(($Re,BP)=>{"use strict";a();var sG=Tr(),aG=jP(),qP="__core-js_shared__",cG=sG[qP]||aG(qP,{});BP.exports=cG});var lw=b((jRe,UP)=>{"use strict";a();var lG=eu(),zP=_m();(UP.exports=function(t,e){return zP[t]||(zP[t]=e!==void 0?e:{})})("versions",[]).push({version:"3.32.1",mode:lG?"pure":"global",copyright:"\xA9 2014-2023 Denis Pushkarev (zloirock.ru)",license:"https://github.com/zloirock/core-js/blob/v3.32.1/LICENSE",source:"https://github.com/zloirock/core-js"})});var Tm=b((BRe,WP)=>{"use strict";a();var uG=Xl(),fG=Object;WP.exports=function(t){return fG(uG(t))}});var En=b((URe,HP)=>{"use strict";a();var pG=Ct(),dG=Tm(),mG=pG({}.hasOwnProperty);HP.exports=Object.hasOwn||function(e,r){return mG(dG(e),r)}});var Om=b((HRe,KP)=>{"use strict";a();var hG=Ct(),gG=0,yG=Math.random(),bG=hG(1 .toString);KP.exports=function(t){return"Symbol("+(t===void 0?"":t)+")_"+bG(++gG+yG,36)}});var Hr=b((VRe,GP)=>{"use strict";a();var vG=Tr(),wG=lw(),VP=En(),xG=Om(),EG=nw(),SG=ow(),Ta=vG.Symbol,uw=wG("wks"),IG=SG?Ta.for||Ta:Ta&&Ta.withoutSetter||xG;GP.exports=function(t){return VP(uw,t)||(uw[t]=EG&&VP(Ta,t)?Ta[t]:IG("Symbol."+t)),uw[t]}});var XP=b((ZRe,YP)=>{"use strict";a();var _G=Yn(),ZP=Ur(),JP=iw(),TG=Im(),OG=FP(),CG=Hr(),kG=TypeError,AG=CG("toPrimitive");YP.exports=function(t,e){if(!ZP(t)||JP(t))return t;var r=TG(t,AG),n;if(r){if(e===void 0&&(e="default"),n=_G(r,t,e),!ZP(n)||JP(n))return n;throw kG("Can't convert object to primitive value")}return e===void 0&&(e="number"),OG(t,e)}});var tu=b((YRe,QP)=>{"use strict";a();var RG=XP(),NG=iw();QP.exports=function(t){var e=RG(t,"string");return NG(e)?e:e+""}});var pw=b((QRe,tF)=>{"use strict";a();var DG=Tr(),eF=Ur(),fw=DG.document,PG=eF(fw)&&eF(fw.createElement);tF.exports=function(t){return PG?fw.createElement(t):{}}});var dw=b((tNe,rF)=>{"use strict";a();var FG=Or(),MG=Ot(),$G=pw();rF.exports=!FG&&!MG(function(){return Object.defineProperty($G("div"),"a",{get:function(){return 7}}).a!==7})});var iF=b(oF=>{"use strict";a();var LG=Or(),jG=Yn(),qG=iP(),BG=Yl(),zG=_a(),UG=tu(),WG=En(),HG=dw(),nF=Object.getOwnPropertyDescriptor;oF.f=LG?nF:function(e,r){if(e=zG(e),r=UG(r),HG)try{return nF(e,r)}catch{}if(WG(e,r))return BG(!jG(qG.f,e,r),e[r])}});var aF=b((iNe,sF)=>{"use strict";a();var KG=Ot(),VG=at(),GG=/#|\.prototype\./,ru=function(t,e){var r=JG[ZG(t)];return r===XG?!0:r===YG?!1:VG(e)?KG(e):!!e},ZG=ru.normalize=function(t){return String(t).replace(GG,".").toLowerCase()},JG=ru.data={},YG=ru.NATIVE="N",XG=ru.POLYFILL="P";sF.exports=ru});var nu=b((aNe,lF)=>{"use strict";a();var cF=Z0(),QG=Yi(),eZ=Jl(),tZ=cF(cF.bind);lF.exports=function(t,e){return QG(t),e===void 0?t:eZ?tZ(t,e):function(){return t.apply(e,arguments)}}});var mw=b((lNe,uF)=>{"use strict";a();var rZ=Or(),nZ=Ot();uF.exports=rZ&&nZ(function(){return Object.defineProperty(function(){},"prototype",{value:42,writable:!1}).prototype!==42})});var Wo=b((fNe,fF)=>{"use strict";a();var oZ=Ur(),iZ=String,sZ=TypeError;fF.exports=function(t){if(oZ(t))return t;throw sZ(iZ(t)+" is not an object")}});var Ho=b(dF=>{"use strict";a();var aZ=Or(),cZ=dw(),lZ=mw(),Cm=Wo(),pF=tu(),uZ=TypeError,hw=Object.defineProperty,fZ=Object.getOwnPropertyDescriptor,gw="enumerable",yw="configurable",bw="writable";dF.f=aZ?lZ?function(e,r,n){if(Cm(e),r=pF(r),Cm(n),typeof e=="function"&&r==="prototype"&&"value"in n&&bw in n&&!n[bw]){var o=fZ(e,r);o&&o[bw]&&(e[r]=n.value,n={configurable:yw in n?n[yw]:o[yw],enumerable:gw in n?n[gw]:o[gw],writable:!1})}return hw(e,r,n)}:hw:function(e,r,n){if(Cm(e),r=pF(r),Cm(n),cZ)try{return hw(e,r,n)}catch{}if("get"in n||"set"in n)throw uZ("Accessors not supported");return"value"in n&&(e[r]=n.value),e}});var Xi=b((hNe,mF)=>{"use strict";a();var pZ=Or(),dZ=Ho(),mZ=Yl();mF.exports=pZ?function(t,e,r){return dZ.f(t,e,mZ(1,r))}:function(t,e,r){return t[e]=r,t}});var Qi=b((yNe,gF)=>{"use strict";a();var km=Tr(),hZ=WD(),gZ=Z0(),yZ=at(),bZ=iF().f,vZ=aF(),Oa=Ql(),wZ=nu(),Ca=Xi(),hF=En(),xZ=function(t){var e=function(r,n,o){if(this instanceof e){switch(arguments.length){case 0:return new t;case 1:return new t(r);case 2:return new t(r,n)}return new t(r,n,o)}return hZ(t,this,arguments)};return e.prototype=t.prototype,e};gF.exports=function(t,e){var r=t.target,n=t.global,o=t.stat,i=t.proto,s=n?km:o?km[r]:(km[r]||{}).prototype,c=n?Oa:Oa[r]||Ca(Oa,r,{})[r],l=c.prototype,f,u,d,m,h,y,w,v,x;for(m in e)f=vZ(n?m:r+(o?".":"#")+m,t.forced),u=!f&&s&&hF(s,m),y=c[m],u&&(t.dontCallGetSet?(x=bZ(s,m),w=x&&x.value):w=s[m]),h=u&&w?w:e[m],!(u&&typeof y==typeof h)&&(t.bind&&u?v=wZ(h,km):t.wrap&&u?v=xZ(h):i&&yZ(h)?v=gZ(h):v=h,(t.sham||h&&h.sham||y&&y.sham)&&Ca(v,"sham",!0),Ca(c,m,v),i&&(d=r+"Prototype",hF(Oa,d)||Ca(Oa,d,{}),Ca(Oa[d],m,h),t.real&&l&&(f||!l[m])&&Ca(l,m,h)))}});var ou=b((vNe,yF)=>{"use strict";a();yF.exports={}});var vF=b((xNe,bF)=>{"use strict";a();var EZ=Math.ceil,SZ=Math.floor;bF.exports=Math.trunc||function(e){var r=+e;return(r>0?SZ:EZ)(r)}});var vw=b((SNe,wF)=>{"use strict";a();var IZ=vF();wF.exports=function(t){var e=+t;return e!==e||e===0?0:IZ(e)}});var ww=b((_Ne,xF)=>{"use strict";a();var _Z=vw(),TZ=Math.max,OZ=Math.min;xF.exports=function(t,e){var r=_Z(t);return r<0?TZ(r+e,0):OZ(r,e)}});var SF=b((ONe,EF)=>{"use strict";a();var CZ=vw(),kZ=Math.min;EF.exports=function(t){return t>0?kZ(CZ(t),9007199254740991):0}});var iu=b((kNe,IF)=>{"use strict";a();var AZ=SF();IF.exports=function(t){return AZ(t.length)}});var OF=b((RNe,TF)=>{"use strict";a();var RZ=_a(),NZ=ww(),DZ=iu(),_F=function(t){return function(e,r,n){var o=RZ(e),i=DZ(o),s=NZ(n,i),c;if(t&&r!==r){for(;i>s;)if(c=o[s++],c!==c)return!0}else for(;i>s;s++)if((t||s in o)&&o[s]===r)return t||s||0;return!t&&-1}};TF.exports={includes:_F(!0),indexOf:_F(!1)}});var Ew=b((DNe,kF)=>{"use strict";a();var PZ=Ct(),xw=En(),FZ=_a(),MZ=OF().indexOf,$Z=ou(),CF=PZ([].push);kF.exports=function(t,e){var r=FZ(t),n=0,o=[],i;for(i in r)!xw($Z,i)&&xw(r,i)&&CF(o,i);for(;e.length>n;)xw(r,i=e[n++])&&(~MZ(o,i)||CF(o,i));return o}});var Am=b((FNe,AF)=>{"use strict";a();AF.exports=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]});var Sw=b(RF=>{"use strict";a();var LZ=Ew(),jZ=Am(),qZ=jZ.concat("length","prototype");RF.f=Object.getOwnPropertyNames||function(e){return LZ(e,qZ)}});var DF=b((jNe,NF)=>{"use strict";a();var BZ=tu(),zZ=Ho(),UZ=Yl();NF.exports=function(t,e,r){var n=BZ(e);n in t?zZ.f(t,n,UZ(0,r)):t[n]=r}});var MF=b((BNe,FF)=>{"use strict";a();var PF=ww(),WZ=iu(),HZ=DF(),KZ=Array,VZ=Math.max;FF.exports=function(t,e,r){for(var n=WZ(t),o=PF(e,n),i=PF(r===void 0?n:r,n),s=KZ(VZ(i-o,0)),c=0;o{"use strict";a();var GZ=Zi(),ZZ=_a(),$F=Sw().f,JZ=MF(),LF=typeof window=="object"&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],YZ=function(t){try{return $F(t)}catch{return JZ(LF)}};jF.exports.f=function(e){return LF&&GZ(e)==="Window"?YZ(e):$F(ZZ(e))}});var zF=b((HNe,BF)=>{"use strict";a();var XZ=Ot();BF.exports=XZ(function(){if(typeof ArrayBuffer=="function"){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})});var HF=b((VNe,WF)=>{"use strict";a();var QZ=Ot(),eJ=Ur(),tJ=Zi(),UF=zF(),Rm=Object.isExtensible,rJ=QZ(function(){Rm(1)});WF.exports=rJ||UF?function(e){return!eJ(e)||UF&&tJ(e)==="ArrayBuffer"?!1:Rm?Rm(e):!0}:Rm});var VF=b((ZNe,KF)=>{"use strict";a();var nJ=Ot();KF.exports=!nJ(function(){return Object.isExtensible(Object.preventExtensions({}))})});var Ow=b((YNe,JF)=>{"use strict";a();var oJ=Qi(),iJ=Ct(),sJ=ou(),aJ=Ur(),Iw=En(),cJ=Ho().f,GF=Sw(),lJ=qF(),_w=HF(),uJ=Om(),fJ=VF(),ZF=!1,Xn=uJ("meta"),pJ=0,Tw=function(t){cJ(t,Xn,{value:{objectID:"O"+pJ++,weakData:{}}})},dJ=function(t,e){if(!aJ(t))return typeof t=="symbol"?t:(typeof t=="string"?"S":"P")+t;if(!Iw(t,Xn)){if(!_w(t))return"F";if(!e)return"E";Tw(t)}return t[Xn].objectID},mJ=function(t,e){if(!Iw(t,Xn)){if(!_w(t))return!0;if(!e)return!1;Tw(t)}return t[Xn].weakData},hJ=function(t){return fJ&&ZF&&_w(t)&&!Iw(t,Xn)&&Tw(t),t},gJ=function(){yJ.enable=function(){},ZF=!0;var t=GF.f,e=iJ([].splice),r={};r[Xn]=1,t(r).length&&(GF.f=function(n){for(var o=t(n),i=0,s=o.length;i{"use strict";a();YF.exports={}});var QF=b((tDe,XF)=>{"use strict";a();var bJ=Hr(),vJ=su(),wJ=bJ("iterator"),xJ=Array.prototype;XF.exports=function(t){return t!==void 0&&(vJ.Array===t||xJ[wJ]===t)}});var Nm=b((nDe,tM)=>{"use strict";a();var EJ=Hr(),SJ=EJ("toStringTag"),eM={};eM[SJ]="z";tM.exports=String(eM)==="[object z]"});var Pm=b((iDe,rM)=>{"use strict";a();var IJ=Nm(),_J=at(),Dm=Zi(),TJ=Hr(),OJ=TJ("toStringTag"),CJ=Object,kJ=Dm(function(){return arguments}())==="Arguments",AJ=function(t,e){try{return t[e]}catch{}};rM.exports=IJ?Dm:function(t){var e,r,n;return t===void 0?"Undefined":t===null?"Null":typeof(r=AJ(e=CJ(t),OJ))=="string"?r:kJ?Dm(e):(n=Dm(e))==="Object"&&_J(e.callee)?"Arguments":n}});var Cw=b((aDe,oM)=>{"use strict";a();var RJ=Pm(),nM=Im(),NJ=Ia(),DJ=su(),PJ=Hr(),FJ=PJ("iterator");oM.exports=function(t){if(!NJ(t))return nM(t,FJ)||nM(t,"@@iterator")||DJ[RJ(t)]}});var sM=b((lDe,iM)=>{"use strict";a();var MJ=Yn(),$J=Yi(),LJ=Wo(),jJ=Sm(),qJ=Cw(),BJ=TypeError;iM.exports=function(t,e){var r=arguments.length<2?qJ(t):e;if($J(r))return LJ(MJ(r,t));throw BJ(jJ(t)+" is not iterable")}});var lM=b((fDe,cM)=>{"use strict";a();var zJ=Yn(),aM=Wo(),UJ=Im();cM.exports=function(t,e,r){var n,o;aM(t);try{if(n=UJ(t,"return"),!n){if(e==="throw")throw r;return r}n=zJ(n,t)}catch(i){o=!0,n=i}if(e==="throw")throw r;if(o)throw n;return aM(n),r}});var au=b((dDe,dM)=>{"use strict";a();var WJ=nu(),HJ=Yn(),KJ=Wo(),VJ=Sm(),GJ=QF(),ZJ=iu(),uM=xm(),JJ=sM(),YJ=Cw(),fM=lM(),XJ=TypeError,Fm=function(t,e){this.stopped=t,this.result=e},pM=Fm.prototype;dM.exports=function(t,e,r){var n=r&&r.that,o=!!(r&&r.AS_ENTRIES),i=!!(r&&r.IS_RECORD),s=!!(r&&r.IS_ITERATOR),c=!!(r&&r.INTERRUPTED),l=WJ(e,n),f,u,d,m,h,y,w,v=function(S){return f&&fM(f,"normal",S),new Fm(!0,S)},x=function(S){return o?(KJ(S),c?l(S[0],S[1],v):l(S[0],S[1])):c?l(S,v):l(S)};if(i)f=t.iterator;else if(s)f=t;else{if(u=YJ(t),!u)throw XJ(VJ(t)+" is not iterable");if(GJ(u)){for(d=0,m=ZJ(t);m>d;d++)if(h=x(t[d]),h&&uM(pM,h))return h;return new Fm(!1)}f=JJ(t,u)}for(y=i?t.next:f.next;!(w=HJ(y,f)).done;){try{h=x(w.value)}catch(S){fM(f,"throw",S)}if(typeof h=="object"&&h&&uM(pM,h))return h}return new Fm(!1)}});var kw=b((hDe,mM)=>{"use strict";a();var QJ=xm(),eY=TypeError;mM.exports=function(t,e){if(QJ(e,t))return t;throw eY("Incorrect invocation")}});var gM=b((yDe,hM)=>{"use strict";a();var tY=Nm(),rY=Pm();hM.exports=tY?{}.toString:function(){return"[object "+rY(this)+"]"}});var Mm=b((vDe,bM)=>{"use strict";a();var nY=Nm(),oY=Ho().f,iY=Xi(),sY=En(),aY=gM(),cY=Hr(),yM=cY("toStringTag");bM.exports=function(t,e,r,n){if(t){var o=r?t:t.prototype;sY(o,yM)||oY(o,yM,{configurable:!0,value:e}),n&&!nY&&iY(o,"toString",aY)}}});var wM=b((xDe,vM)=>{"use strict";a();var lY=Zi();vM.exports=Array.isArray||function(e){return lY(e)==="Array"}});var EM=b((SDe,xM)=>{"use strict";a();var uY=Ct(),fY=at(),Aw=_m(),pY=uY(Function.toString);fY(Aw.inspectSource)||(Aw.inspectSource=function(t){return pY(t)});xM.exports=Aw.inspectSource});var CM=b((_De,OM)=>{"use strict";a();var dY=Ct(),mY=Ot(),SM=at(),hY=Pm(),gY=Ji(),yY=EM(),IM=function(){},bY=[],_M=gY("Reflect","construct"),Rw=/^\s*(?:class|function)\b/,vY=dY(Rw.exec),wY=!Rw.exec(IM),cu=function(e){if(!SM(e))return!1;try{return _M(IM,bY,e),!0}catch{return!1}},TM=function(e){if(!SM(e))return!1;switch(hY(e)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}try{return wY||!!vY(Rw,yY(e))}catch{return!0}};TM.sham=!0;OM.exports=!_M||mY(function(){var t;return cu(cu.call)||!cu(Object)||!cu(function(){t=!0})||t})?TM:cu});var NM=b((ODe,RM)=>{"use strict";a();var kM=wM(),xY=CM(),EY=Ur(),SY=Hr(),IY=SY("species"),AM=Array;RM.exports=function(t){var e;return kM(t)&&(e=t.constructor,xY(e)&&(e===AM||kM(e.prototype))?e=void 0:EY(e)&&(e=e[IY],e===null&&(e=void 0))),e===void 0?AM:e}});var PM=b((kDe,DM)=>{"use strict";a();var _Y=NM();DM.exports=function(t,e){return new(_Y(t))(e===0?0:e)}});var $M=b((RDe,MM)=>{"use strict";a();var TY=nu(),OY=Ct(),CY=Q0(),kY=Tm(),AY=iu(),RY=PM(),FM=OY([].push),Ko=function(t){var e=t===1,r=t===2,n=t===3,o=t===4,i=t===6,s=t===7,c=t===5||i;return function(l,f,u,d){for(var m=kY(l),h=CY(m),y=TY(f,u),w=AY(h),v=0,x=d||RY,S=e?x(l,w):r||s?x(l,0):void 0,k,j;w>v;v++)if((c||v in h)&&(k=h[v],j=y(k,v,m),t))if(e)S[v]=j;else if(j)switch(t){case 3:return!0;case 5:return k;case 6:return v;case 2:FM(S,k)}else switch(t){case 4:return!1;case 7:FM(S,k)}return i?-1:n||o?o:S}};MM.exports={forEach:Ko(0),map:Ko(1),filter:Ko(2),some:Ko(3),every:Ko(4),find:Ko(5),findIndex:Ko(6),filterReject:Ko(7)}});var qM=b((DDe,jM)=>{"use strict";a();var NY=Tr(),DY=at(),LM=NY.WeakMap;jM.exports=DY(LM)&&/native code/.test(String(LM))});var $m=b((FDe,zM)=>{"use strict";a();var PY=lw(),FY=Om(),BM=PY("keys");zM.exports=function(t){return BM[t]||(BM[t]=FY(t))}});var Fw=b(($De,HM)=>{"use strict";a();var MY=qM(),WM=Tr(),$Y=Ur(),LY=Xi(),Nw=En(),Dw=_m(),jY=$m(),qY=ou(),UM="Object already initialized",Pw=WM.TypeError,BY=WM.WeakMap,Lm,lu,jm,zY=function(t){return jm(t)?lu(t):Lm(t,{})},UY=function(t){return function(e){var r;if(!$Y(e)||(r=lu(e)).type!==t)throw Pw("Incompatible receiver, "+t+" required");return r}};MY||Dw.state?(Kr=Dw.state||(Dw.state=new BY),Kr.get=Kr.get,Kr.has=Kr.has,Kr.set=Kr.set,Lm=function(t,e){if(Kr.has(t))throw Pw(UM);return e.facade=t,Kr.set(t,e),e},lu=function(t){return Kr.get(t)||{}},jm=function(t){return Kr.has(t)}):(es=jY("state"),qY[es]=!0,Lm=function(t,e){if(Nw(t,es))throw Pw(UM);return e.facade=t,LY(t,es,e),e},lu=function(t){return Nw(t,es)?t[es]:{}},jm=function(t){return Nw(t,es)});var Kr,es;HM.exports={set:Lm,get:lu,has:jm,enforce:zY,getterFor:UY}});var GM=b((jDe,VM)=>{"use strict";a();var WY=Qi(),HY=Tr(),KY=Ow(),VY=Ot(),GY=Xi(),ZY=au(),JY=kw(),YY=at(),XY=Ur(),QY=Ia(),eX=Mm(),tX=Ho().f,rX=$M().forEach,nX=Or(),KM=Fw(),oX=KM.set,iX=KM.getterFor;VM.exports=function(t,e,r){var n=t.indexOf("Map")!==-1,o=t.indexOf("Weak")!==-1,i=n?"set":"add",s=HY[t],c=s&&s.prototype,l={},f;if(!nX||!YY(s)||!(o||c.forEach&&!VY(function(){new s().entries().next()})))f=r.getConstructor(e,t,n,i),KY.enable();else{f=e(function(m,h){oX(JY(m,u),{type:t,collection:new s}),QY(h)||ZY(h,m[i],{that:m,AS_ENTRIES:n})});var u=f.prototype,d=iX(t);rX(["add","clear","delete","forEach","get","has","set","keys","values","entries"],function(m){var h=m==="add"||m==="set";m in c&&!(o&&m==="clear")&&GY(u,m,function(y,w){var v=d(this).collection;if(!h&&o&&!XY(y))return m==="get"?void 0:!1;var x=v[m](y===0?0:y,w);return h?this:x})}),o||tX(u,"size",{configurable:!0,get:function(){return d(this).collection.size}})}return eX(f,t,!1,!0),l[t]=f,WY({global:!0,forced:!0},l),o||r.setStrong(f,t,n),f}});var JM=b((BDe,ZM)=>{"use strict";a();var sX=Ew(),aX=Am();ZM.exports=Object.keys||function(e){return sX(e,aX)}});var XM=b(YM=>{"use strict";a();var cX=Or(),lX=mw(),uX=Ho(),fX=Wo(),pX=_a(),dX=JM();YM.f=cX&&!lX?Object.defineProperties:function(e,r){fX(e);for(var n=pX(r),o=dX(r),i=o.length,s=0,c;i>s;)uX.f(e,c=o[s++],n[c]);return e}});var e$=b((HDe,QM)=>{"use strict";a();var mX=Ji();QM.exports=mX("document","documentElement")});var uu=b((VDe,a$)=>{"use strict";a();var hX=Wo(),gX=XM(),t$=Am(),yX=ou(),bX=e$(),vX=pw(),wX=$m(),r$=">",n$="<",$w="prototype",Lw="script",i$=wX("IE_PROTO"),Mw=function(){},s$=function(t){return n$+Lw+r$+t+n$+"/"+Lw+r$},o$=function(t){t.write(s$("")),t.close();var e=t.parentWindow.Object;return t=null,e},xX=function(){var t=vX("iframe"),e="java"+Lw+":",r;return t.style.display="none",bX.appendChild(t),t.src=String(e),r=t.contentWindow.document,r.open(),r.write(s$("document.F=Object")),r.close(),r.F},qm,Bm=function(){try{qm=new ActiveXObject("htmlfile")}catch{}Bm=typeof document<"u"?document.domain&&qm?o$(qm):xX():o$(qm);for(var t=t$.length;t--;)delete Bm[$w][t$[t]];return Bm()};yX[i$]=!0;a$.exports=Object.create||function(e,r){var n;return e!==null?(Mw[$w]=hX(e),n=new Mw,Mw[$w]=null,n[i$]=e):n=Bm(),r===void 0?n:gX.f(n,r)}});var jw=b((ZDe,c$)=>{"use strict";a();var EX=Ho();c$.exports=function(t,e,r){return EX.f(t,e,r)}});var zm=b((YDe,l$)=>{"use strict";a();var SX=Xi();l$.exports=function(t,e,r,n){return n&&n.enumerable?t[e]=r:SX(t,e,r),t}});var f$=b((QDe,u$)=>{"use strict";a();var IX=zm();u$.exports=function(t,e,r){for(var n in e)r&&r.unsafe&&t[n]?t[n]=e[n]:IX(t,n,e[n],r);return t}});var m$=b((tPe,d$)=>{"use strict";a();var qw=Or(),_X=En(),p$=Function.prototype,TX=qw&&Object.getOwnPropertyDescriptor,Bw=_X(p$,"name"),OX=Bw&&function(){}.name==="something",CX=Bw&&(!qw||qw&&TX(p$,"name").configurable);d$.exports={EXISTS:Bw,PROPER:OX,CONFIGURABLE:CX}});var g$=b((nPe,h$)=>{"use strict";a();var kX=Ot();h$.exports=!kX(function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})});var Uw=b((iPe,b$)=>{"use strict";a();var AX=En(),RX=at(),NX=Tm(),DX=$m(),PX=g$(),y$=DX("IE_PROTO"),zw=Object,FX=zw.prototype;b$.exports=PX?zw.getPrototypeOf:function(t){var e=NX(t);if(AX(e,y$))return e[y$];var r=e.constructor;return RX(r)&&e instanceof r?r.prototype:e instanceof zw?FX:null}});var Vw=b((aPe,x$)=>{"use strict";a();var MX=Ot(),$X=at(),LX=Ur(),jX=uu(),v$=Uw(),qX=zm(),BX=Hr(),zX=eu(),Kw=BX("iterator"),w$=!1,Qn,Ww,Hw;[].keys&&(Hw=[].keys(),"next"in Hw?(Ww=v$(v$(Hw)),Ww!==Object.prototype&&(Qn=Ww)):w$=!0);var UX=!LX(Qn)||MX(function(){var t={};return Qn[Kw].call(t)!==t});UX?Qn={}:zX&&(Qn=jX(Qn));$X(Qn[Kw])||qX(Qn,Kw,function(){return this});x$.exports={IteratorPrototype:Qn,BUGGY_SAFARI_ITERATORS:w$}});var S$=b((lPe,E$)=>{"use strict";a();var WX=Vw().IteratorPrototype,HX=uu(),KX=Yl(),VX=Mm(),GX=su(),ZX=function(){return this};E$.exports=function(t,e,r,n){var o=e+" Iterator";return t.prototype=HX(WX,{next:KX(+!n,r)}),VX(t,o,!1,!0),GX[o]=ZX,t}});var _$=b((fPe,I$)=>{"use strict";a();var JX=Ct(),YX=Yi();I$.exports=function(t,e,r){try{return JX(YX(Object.getOwnPropertyDescriptor(t,e)[r]))}catch{}}});var O$=b((dPe,T$)=>{"use strict";a();var XX=at(),QX=String,eQ=TypeError;T$.exports=function(t){if(typeof t=="object"||XX(t))return t;throw eQ("Can't set "+QX(t)+" as a prototype")}});var k$=b((hPe,C$)=>{"use strict";a();var tQ=_$(),rQ=Wo(),nQ=O$();C$.exports=Object.setPrototypeOf||("__proto__"in{}?function(){var t=!1,e={},r;try{r=tQ(Object.prototype,"__proto__","set"),r(e,[]),t=e instanceof Array}catch{}return function(o,i){return rQ(o),nQ(i),t?r(o,i):o.__proto__=i,o}}():void 0)});var q$=b((yPe,j$)=>{"use strict";a();var oQ=Qi(),iQ=Yn(),Um=eu(),$$=m$(),sQ=at(),aQ=S$(),A$=Uw(),R$=k$(),cQ=Mm(),lQ=Xi(),Gw=zm(),uQ=Hr(),N$=su(),L$=Vw(),fQ=$$.PROPER,pQ=$$.CONFIGURABLE,D$=L$.IteratorPrototype,Wm=L$.BUGGY_SAFARI_ITERATORS,fu=uQ("iterator"),P$="keys",pu="values",F$="entries",M$=function(){return this};j$.exports=function(t,e,r,n,o,i,s){aQ(r,e,n);var c=function(x){if(x===o&&m)return m;if(!Wm&&x in u)return u[x];switch(x){case P$:return function(){return new r(this,x)};case pu:return function(){return new r(this,x)};case F$:return function(){return new r(this,x)}}return function(){return new r(this)}},l=e+" Iterator",f=!1,u=t.prototype,d=u[fu]||u["@@iterator"]||o&&u[o],m=!Wm&&d||c(o),h=e==="Array"&&u.entries||d,y,w,v;if(h&&(y=A$(h.call(new t)),y!==Object.prototype&&y.next&&(!Um&&A$(y)!==D$&&(R$?R$(y,D$):sQ(y[fu])||Gw(y,fu,M$)),cQ(y,l,!0,!0),Um&&(N$[l]=M$))),fQ&&o===pu&&d&&d.name!==pu&&(!Um&&pQ?lQ(u,"name",pu):(f=!0,m=function(){return iQ(d,this)})),o)if(w={values:c(pu),keys:i?m:c(P$),entries:c(F$)},s)for(v in w)(Wm||f||!(v in u))&&Gw(u,v,w[v]);else oQ({target:e,proto:!0,forced:Wm||f},w);return(!Um||s)&&u[fu]!==m&&Gw(u,fu,m,{name:o}),N$[e]=m,w}});var z$=b((vPe,B$)=>{"use strict";a();B$.exports=function(t,e){return{value:t,done:e}}});var H$=b((xPe,W$)=>{"use strict";a();var dQ=Ji(),mQ=jw(),hQ=Hr(),gQ=Or(),U$=hQ("species");W$.exports=function(t){var e=dQ(t);gQ&&e&&!e[U$]&&mQ(e,U$,{configurable:!0,get:function(){return this}})}});var Y$=b((SPe,J$)=>{"use strict";a();var yQ=uu(),bQ=jw(),K$=f$(),vQ=nu(),wQ=kw(),xQ=Ia(),EQ=au(),SQ=q$(),Hm=z$(),IQ=H$(),du=Or(),V$=Ow().fastKey,Z$=Fw(),G$=Z$.set,Zw=Z$.getterFor;J$.exports={getConstructor:function(t,e,r,n){var o=t(function(f,u){wQ(f,i),G$(f,{type:e,index:yQ(null),first:void 0,last:void 0,size:0}),du||(f.size=0),xQ(u)||EQ(u,f[n],{that:f,AS_ENTRIES:r})}),i=o.prototype,s=Zw(e),c=function(f,u,d){var m=s(f),h=l(f,u),y,w;return h?h.value=d:(m.last=h={index:w=V$(u,!0),key:u,value:d,previous:y=m.last,next:void 0,removed:!1},m.first||(m.first=h),y&&(y.next=h),du?m.size++:f.size++,w!=="F"&&(m.index[w]=h)),f},l=function(f,u){var d=s(f),m=V$(u),h;if(m!=="F")return d.index[m];for(h=d.first;h;h=h.next)if(h.key===u)return h};return K$(i,{clear:function(){for(var u=this,d=s(u),m=d.index,h=d.first;h;)h.removed=!0,h.previous&&(h.previous=h.previous.next=void 0),delete m[h.index],h=h.next;d.first=d.last=void 0,du?d.size=0:u.size=0},delete:function(f){var u=this,d=s(u),m=l(u,f);if(m){var h=m.next,y=m.previous;delete d.index[m.index],m.removed=!0,y&&(y.next=h),h&&(h.previous=y),d.first===m&&(d.first=h),d.last===m&&(d.last=y),du?d.size--:u.size--}return!!m},forEach:function(u){for(var d=s(this),m=vQ(u,arguments.length>1?arguments[1]:void 0),h;h=h?h.next:d.first;)for(m(h.value,h.key,this);h&&h.removed;)h=h.previous},has:function(u){return!!l(this,u)}}),K$(i,r?{get:function(u){var d=l(this,u);return d&&d.value},set:function(u,d){return c(this,u===0?0:u,d)}}:{add:function(u){return c(this,u=u===0?0:u,u)}}),du&&bQ(i,"size",{configurable:!0,get:function(){return s(this).size}}),o},setStrong:function(t,e,r){var n=e+" Iterator",o=Zw(e),i=Zw(n);SQ(t,e,function(s,c){G$(this,{type:n,target:s,state:o(s),kind:c,last:void 0})},function(){for(var s=i(this),c=s.kind,l=s.last;l&&l.removed;)l=l.previous;return!s.target||!(s.last=l=l?l.next:s.state.first)?(s.target=void 0,Hm(void 0,!0)):Hm(c==="keys"?l.key:c==="values"?l.value:[l.key,l.value],!1)},r?"entries":"values",!r,!0),IQ(e)}}});var X$=b(()=>{"use strict";a();var _Q=GM(),TQ=Y$();_Q("Map",function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},TQ)});var Q$=b(()=>{"use strict";a();X$()});var t2=b((RPe,e2)=>{"use strict";a();e2.exports=function(t,e){return e===1?function(r,n){return r[t](n)}:function(r,n,o){return r[t](n,o)}}});var o2=b((DPe,n2)=>{"use strict";a();var OQ=Ji(),Km=t2(),r2=OQ("Map");n2.exports={Map:r2,set:Km("set",2),get:Km("get",1),has:Km("has",1),remove:Km("delete",1),proto:r2.prototype}});var i2=b(()=>{"use strict";a();var CQ=Qi(),kQ=Ct(),AQ=Yi(),RQ=Xl(),NQ=au(),Vm=o2(),DQ=eu(),PQ=Vm.Map,FQ=Vm.has,MQ=Vm.get,$Q=Vm.set,LQ=kQ([].push);CQ({target:"Map",stat:!0,forced:DQ},{groupBy:function(e,r){RQ(e),AQ(r);var n=new PQ,o=0;return NQ(e,function(i){var s=r(i,o++);FQ(n,s)?LQ(MQ(n,s),i):$Q(n,s,[i])}),n}})});var c2=b((LPe,a2)=>{"use strict";a();Q$();i2();var jQ=Yn(),qQ=at(),BQ=Ql(),s2=BQ.Map,zQ=s2.groupBy;a2.exports=function(e,r,n){return jQ(zQ,qQ(this)?this:s2,e,r,n)}});var u2=b((qPe,l2)=>{"use strict";a();var UQ=c2();l2.exports=UQ});var f2=b(()=>{"use strict";a();var WQ=Qi(),HQ=Or(),KQ=uu();WQ({target:"Object",stat:!0,sham:!HQ},{create:KQ})});var p2=b(()=>{"use strict";a();var VQ=Qi(),GQ=Ji(),ZQ=Ct(),JQ=Yi(),YQ=Xl(),XQ=tu(),QQ=au(),eee=GQ("Object","create"),tee=ZQ([].push);VQ({target:"Object",stat:!0},{groupBy:function(e,r){YQ(e),JQ(r);var n=eee(null),o=0;return QQ(e,function(i){var s=XQ(r(i,o++));s in n?tee(n[s],i):n[s]=[i]}),n}})});var m2=b((GPe,d2)=>{"use strict";a();f2();p2();var ree=Ql();d2.exports=ree.Object.groupBy});var g2=b((JPe,h2)=>{"use strict";a();var nee=m2();h2.exports=nee});var M2=b(F2=>{"use strict";a();var Ra=(_(),Zg(Mr));function wee(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var xee=typeof Object.is=="function"?Object.is:wee,Eee=Ra.useState,See=Ra.useEffect,Iee=Ra.useLayoutEffect,_ee=Ra.useDebugValue;function Tee(t,e){var r=e(),n=Eee({inst:{value:r,getSnapshot:e}}),o=n[0].inst,i=n[1];return Iee(function(){o.value=r,o.getSnapshot=e,mx(o)&&i({inst:o})},[t,r,e]),See(function(){return mx(o)&&i({inst:o}),t(function(){mx(o)&&i({inst:o})})},[t]),_ee(r),r}function mx(t){var e=t.getSnapshot;t=t.value;try{var r=e();return!xee(t,r)}catch{return!0}}function Oee(t,e){return e()}var Cee=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Oee:Tee;F2.useSyncExternalStore=Ra.useSyncExternalStore!==void 0?Ra.useSyncExternalStore:Cee});var L2=b((n2e,$2)=>{"use strict";a();$2.exports=M2()});var q2=b(j2=>{"use strict";a();var sh=(_(),Zg(Mr)),kee=L2();function Aee(t,e){return t===e&&(t!==0||1/t===1/e)||t!==t&&e!==e}var Ree=typeof Object.is=="function"?Object.is:Aee,Nee=kee.useSyncExternalStore,Dee=sh.useRef,Pee=sh.useEffect,Fee=sh.useMemo,Mee=sh.useDebugValue;j2.useSyncExternalStoreWithSelector=function(t,e,r,n,o){var i=Dee(null);if(i.current===null){var s={hasValue:!1,value:null};i.current=s}else s=i.current;i=Fee(function(){function l(h){if(!f){if(f=!0,u=h,h=n(h),o!==void 0&&s.hasValue){var y=s.value;if(o(y,h))return d=y}return d=h}if(y=d,Ree(u,h))return y;var w=n(h);return o!==void 0&&o(y,w)?y:(u=h,d=w)}var f=!1,u,d,m=r===void 0?null:r;return[function(){return l(e())},m===null?void 0:function(){return l(m())}]},[e,r,n,o]);var c=Nee(t,i[0],i[1]);return Pee(function(){s.hasValue=!0,s.value=c},[c]),Mee(c),c}});var z2=b((a2e,B2)=>{"use strict";a();B2.exports=q2()});var Xo=b((a4e,no)=>{a();function Hx(){return no.exports=Hx=Object.assign?Object.assign.bind():function(t){for(var e=1;e{a();function Qx(t){return oo.exports=Qx=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},oo.exports.__esModule=!0,oo.exports.default=oo.exports,Qx(t)}oo.exports=Qx,oo.exports.__esModule=!0,oo.exports.default=oo.exports});var Bj=b((X4e,Nu)=>{a();var qj=_h().default;function Ene(t,e){if(qj(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var n=r.call(t,e||"default");if(qj(n)!=="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}Nu.exports=Ene,Nu.exports.__esModule=!0,Nu.exports.default=Nu.exports});var zj=b((eUe,Du)=>{a();var Sne=_h().default,Ine=Bj();function _ne(t){var e=Ine(t,"string");return Sne(e)==="symbol"?e:String(e)}Du.exports=_ne,Du.exports.__esModule=!0,Du.exports.default=Du.exports});var Uj=b((rUe,Pu)=>{a();var Tne=zj();function One(t,e,r){return e=Tne(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}Pu.exports=One,Pu.exports.__esModule=!0,Pu.exports.default=Pu.exports});var Wj=b((oUe,Fu)=>{a();function Cne(t){if(Array.isArray(t))return t}Fu.exports=Cne,Fu.exports.__esModule=!0,Fu.exports.default=Fu.exports});var Hj=b((sUe,Mu)=>{a();function kne(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var n,o,i,s,c=[],l=!0,f=!1;try{if(i=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;l=!1}else for(;!(l=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);l=!0);}catch(u){f=!0,o=u}finally{try{if(!l&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(f)throw o}}return c}}Mu.exports=kne,Mu.exports.__esModule=!0,Mu.exports.default=Mu.exports});var Kj=b((cUe,$u)=>{a();function Ane(t,e){(e==null||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r{a();var Vj=Kj();function Rne(t,e){if(t){if(typeof t=="string")return Vj(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);if(r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set")return Array.from(t);if(r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return Vj(t,e)}}Lu.exports=Rne,Lu.exports.__esModule=!0,Lu.exports.default=Lu.exports});var Zj=b((pUe,ju)=>{a();function Nne(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. +In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}ju.exports=Nne,ju.exports.__esModule=!0,ju.exports.default=ju.exports});var Jj=b((mUe,qu)=>{a();var Dne=Wj(),Pne=Hj(),Fne=Gj(),Mne=Zj();function $ne(t,e){return Dne(t)||Pne(t,e)||Fne(t,e)||Mne()}qu.exports=$ne,qu.exports.__esModule=!0,qu.exports.default=qu.exports});var Xj=b((Th,Yj)=>{"use strict";a();Th.__esModule=!0;Th.default={scheme:"threezerotwofour",author:"jan t. sott (http://github.com/idleberg)",base00:"#090300",base01:"#3a3432",base02:"#4a4543",base03:"#5c5855",base04:"#807d7c",base05:"#a5a2a2",base06:"#d6d5d4",base07:"#f7f7f7",base08:"#db2d20",base09:"#e8bbd0",base0A:"#fded02",base0B:"#01a252",base0C:"#b5e4f4",base0D:"#01a0e4",base0E:"#a16a94",base0F:"#cdab53"};Yj.exports=Th.default});var e5=b((Oh,Qj)=>{"use strict";a();Oh.__esModule=!0;Oh.default={scheme:"apathy",author:"jannik siebert (https://github.com/janniks)",base00:"#031A16",base01:"#0B342D",base02:"#184E45",base03:"#2B685E",base04:"#5F9C92",base05:"#81B5AC",base06:"#A7CEC8",base07:"#D2E7E4",base08:"#3E9688",base09:"#3E7996",base0A:"#3E4C96",base0B:"#883E96",base0C:"#963E4C",base0D:"#96883E",base0E:"#4C963E",base0F:"#3E965B"};Qj.exports=Oh.default});var r5=b((Ch,t5)=>{"use strict";a();Ch.__esModule=!0;Ch.default={scheme:"ashes",author:"jannik siebert (https://github.com/janniks)",base00:"#1C2023",base01:"#393F45",base02:"#565E65",base03:"#747C84",base04:"#ADB3BA",base05:"#C7CCD1",base06:"#DFE2E5",base07:"#F3F4F5",base08:"#C7AE95",base09:"#C7C795",base0A:"#AEC795",base0B:"#95C7AE",base0C:"#95AEC7",base0D:"#AE95C7",base0E:"#C795AE",base0F:"#C79595"};t5.exports=Ch.default});var o5=b((kh,n5)=>{"use strict";a();kh.__esModule=!0;kh.default={scheme:"atelier dune",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/dune)",base00:"#20201d",base01:"#292824",base02:"#6e6b5e",base03:"#7d7a68",base04:"#999580",base05:"#a6a28c",base06:"#e8e4cf",base07:"#fefbec",base08:"#d73737",base09:"#b65611",base0A:"#cfb017",base0B:"#60ac39",base0C:"#1fad83",base0D:"#6684e1",base0E:"#b854d4",base0F:"#d43552"};n5.exports=kh.default});var s5=b((Ah,i5)=>{"use strict";a();Ah.__esModule=!0;Ah.default={scheme:"atelier forest",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/forest)",base00:"#1b1918",base01:"#2c2421",base02:"#68615e",base03:"#766e6b",base04:"#9c9491",base05:"#a8a19f",base06:"#e6e2e0",base07:"#f1efee",base08:"#f22c40",base09:"#df5320",base0A:"#d5911a",base0B:"#5ab738",base0C:"#00ad9c",base0D:"#407ee7",base0E:"#6666ea",base0F:"#c33ff3"};i5.exports=Ah.default});var c5=b((Rh,a5)=>{"use strict";a();Rh.__esModule=!0;Rh.default={scheme:"atelier heath",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/heath)",base00:"#1b181b",base01:"#292329",base02:"#695d69",base03:"#776977",base04:"#9e8f9e",base05:"#ab9bab",base06:"#d8cad8",base07:"#f7f3f7",base08:"#ca402b",base09:"#a65926",base0A:"#bb8a35",base0B:"#379a37",base0C:"#159393",base0D:"#516aec",base0E:"#7b59c0",base0F:"#cc33cc"};a5.exports=Rh.default});var u5=b((Nh,l5)=>{"use strict";a();Nh.__esModule=!0;Nh.default={scheme:"atelier lakeside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/lakeside/)",base00:"#161b1d",base01:"#1f292e",base02:"#516d7b",base03:"#5a7b8c",base04:"#7195a8",base05:"#7ea2b4",base06:"#c1e4f6",base07:"#ebf8ff",base08:"#d22d72",base09:"#935c25",base0A:"#8a8a0f",base0B:"#568c3b",base0C:"#2d8f6f",base0D:"#257fad",base0E:"#5d5db1",base0F:"#b72dd2"};l5.exports=Nh.default});var p5=b((Dh,f5)=>{"use strict";a();Dh.__esModule=!0;Dh.default={scheme:"atelier seaside",author:"bram de haan (http://atelierbram.github.io/syntax-highlighting/atelier-schemes/seaside/)",base00:"#131513",base01:"#242924",base02:"#5e6e5e",base03:"#687d68",base04:"#809980",base05:"#8ca68c",base06:"#cfe8cf",base07:"#f0fff0",base08:"#e6193c",base09:"#87711d",base0A:"#c3c322",base0B:"#29a329",base0C:"#1999b3",base0D:"#3d62f5",base0E:"#ad2bee",base0F:"#e619c3"};f5.exports=Dh.default});var m5=b((Ph,d5)=>{"use strict";a();Ph.__esModule=!0;Ph.default={scheme:"bespin",author:"jan t. sott",base00:"#28211c",base01:"#36312e",base02:"#5e5d5c",base03:"#666666",base04:"#797977",base05:"#8a8986",base06:"#9d9b97",base07:"#baae9e",base08:"#cf6a4c",base09:"#cf7d34",base0A:"#f9ee98",base0B:"#54be0d",base0C:"#afc4db",base0D:"#5ea6ea",base0E:"#9b859d",base0F:"#937121"};d5.exports=Ph.default});var g5=b((Fh,h5)=>{"use strict";a();Fh.__esModule=!0;Fh.default={scheme:"brewer",author:"timoth\xE9e poisot (http://github.com/tpoisot)",base00:"#0c0d0e",base01:"#2e2f30",base02:"#515253",base03:"#737475",base04:"#959697",base05:"#b7b8b9",base06:"#dadbdc",base07:"#fcfdfe",base08:"#e31a1c",base09:"#e6550d",base0A:"#dca060",base0B:"#31a354",base0C:"#80b1d3",base0D:"#3182bd",base0E:"#756bb1",base0F:"#b15928"};h5.exports=Fh.default});var b5=b((Mh,y5)=>{"use strict";a();Mh.__esModule=!0;Mh.default={scheme:"bright",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#303030",base02:"#505050",base03:"#b0b0b0",base04:"#d0d0d0",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ffffff",base08:"#fb0120",base09:"#fc6d24",base0A:"#fda331",base0B:"#a1c659",base0C:"#76c7b7",base0D:"#6fb3d2",base0E:"#d381c3",base0F:"#be643c"};y5.exports=Mh.default});var w5=b(($h,v5)=>{"use strict";a();$h.__esModule=!0;$h.default={scheme:"chalk",author:"chris kempson (http://chriskempson.com)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#f5f5f5",base08:"#fb9fb1",base09:"#eda987",base0A:"#ddb26f",base0B:"#acc267",base0C:"#12cfc0",base0D:"#6fc2ef",base0E:"#e1a3ee",base0F:"#deaf8f"};v5.exports=$h.default});var E5=b((Lh,x5)=>{"use strict";a();Lh.__esModule=!0;Lh.default={scheme:"codeschool",author:"brettof86",base00:"#232c31",base01:"#1c3657",base02:"#2a343a",base03:"#3f4944",base04:"#84898c",base05:"#9ea7a6",base06:"#a7cfa3",base07:"#b5d8f6",base08:"#2a5491",base09:"#43820d",base0A:"#a03b1e",base0B:"#237986",base0C:"#b02f30",base0D:"#484d79",base0E:"#c59820",base0F:"#c98344"};x5.exports=Lh.default});var I5=b((jh,S5)=>{"use strict";a();jh.__esModule=!0;jh.default={scheme:"colors",author:"mrmrs (http://clrs.cc)",base00:"#111111",base01:"#333333",base02:"#555555",base03:"#777777",base04:"#999999",base05:"#bbbbbb",base06:"#dddddd",base07:"#ffffff",base08:"#ff4136",base09:"#ff851b",base0A:"#ffdc00",base0B:"#2ecc40",base0C:"#7fdbff",base0D:"#0074d9",base0E:"#b10dc9",base0F:"#85144b"};S5.exports=jh.default});var T5=b((qh,_5)=>{"use strict";a();qh.__esModule=!0;qh.default={scheme:"default",author:"chris kempson (http://chriskempson.com)",base00:"#181818",base01:"#282828",base02:"#383838",base03:"#585858",base04:"#b8b8b8",base05:"#d8d8d8",base06:"#e8e8e8",base07:"#f8f8f8",base08:"#ab4642",base09:"#dc9656",base0A:"#f7ca88",base0B:"#a1b56c",base0C:"#86c1b9",base0D:"#7cafc2",base0E:"#ba8baf",base0F:"#a16946"};_5.exports=qh.default});var C5=b((Bh,O5)=>{"use strict";a();Bh.__esModule=!0;Bh.default={scheme:"eighties",author:"chris kempson (http://chriskempson.com)",base00:"#2d2d2d",base01:"#393939",base02:"#515151",base03:"#747369",base04:"#a09f93",base05:"#d3d0c8",base06:"#e8e6df",base07:"#f2f0ec",base08:"#f2777a",base09:"#f99157",base0A:"#ffcc66",base0B:"#99cc99",base0C:"#66cccc",base0D:"#6699cc",base0E:"#cc99cc",base0F:"#d27b53"};O5.exports=Bh.default});var A5=b((zh,k5)=>{"use strict";a();zh.__esModule=!0;zh.default={scheme:"embers",author:"jannik siebert (https://github.com/janniks)",base00:"#16130F",base01:"#2C2620",base02:"#433B32",base03:"#5A5047",base04:"#8A8075",base05:"#A39A90",base06:"#BEB6AE",base07:"#DBD6D1",base08:"#826D57",base09:"#828257",base0A:"#6D8257",base0B:"#57826D",base0C:"#576D82",base0D:"#6D5782",base0E:"#82576D",base0F:"#825757"};k5.exports=zh.default});var N5=b((Uh,R5)=>{"use strict";a();Uh.__esModule=!0;Uh.default={scheme:"flat",author:"chris kempson (http://chriskempson.com)",base00:"#2C3E50",base01:"#34495E",base02:"#7F8C8D",base03:"#95A5A6",base04:"#BDC3C7",base05:"#e0e0e0",base06:"#f5f5f5",base07:"#ECF0F1",base08:"#E74C3C",base09:"#E67E22",base0A:"#F1C40F",base0B:"#2ECC71",base0C:"#1ABC9C",base0D:"#3498DB",base0E:"#9B59B6",base0F:"#be643c"};R5.exports=Uh.default});var P5=b((Wh,D5)=>{"use strict";a();Wh.__esModule=!0;Wh.default={scheme:"google",author:"seth wright (http://sethawright.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#CC342B",base09:"#F96A38",base0A:"#FBA922",base0B:"#198844",base0C:"#3971ED",base0D:"#3971ED",base0E:"#A36AC7",base0F:"#3971ED"};D5.exports=Wh.default});var M5=b((Hh,F5)=>{"use strict";a();Hh.__esModule=!0;Hh.default={scheme:"grayscale",author:"alexandre gavioli (https://github.com/alexx2/)",base00:"#101010",base01:"#252525",base02:"#464646",base03:"#525252",base04:"#ababab",base05:"#b9b9b9",base06:"#e3e3e3",base07:"#f7f7f7",base08:"#7c7c7c",base09:"#999999",base0A:"#a0a0a0",base0B:"#8e8e8e",base0C:"#868686",base0D:"#686868",base0E:"#747474",base0F:"#5e5e5e"};F5.exports=Hh.default});var L5=b((Kh,$5)=>{"use strict";a();Kh.__esModule=!0;Kh.default={scheme:"green screen",author:"chris kempson (http://chriskempson.com)",base00:"#001100",base01:"#003300",base02:"#005500",base03:"#007700",base04:"#009900",base05:"#00bb00",base06:"#00dd00",base07:"#00ff00",base08:"#007700",base09:"#009900",base0A:"#007700",base0B:"#00bb00",base0C:"#005500",base0D:"#009900",base0E:"#00bb00",base0F:"#005500"};$5.exports=Kh.default});var q5=b((Vh,j5)=>{"use strict";a();Vh.__esModule=!0;Vh.default={scheme:"harmonic16",author:"jannik siebert (https://github.com/janniks)",base00:"#0b1c2c",base01:"#223b54",base02:"#405c79",base03:"#627e99",base04:"#aabcce",base05:"#cbd6e2",base06:"#e5ebf1",base07:"#f7f9fb",base08:"#bf8b56",base09:"#bfbf56",base0A:"#8bbf56",base0B:"#56bf8b",base0C:"#568bbf",base0D:"#8b56bf",base0E:"#bf568b",base0F:"#bf5656"};j5.exports=Vh.default});var z5=b((Gh,B5)=>{"use strict";a();Gh.__esModule=!0;Gh.default={scheme:"hopscotch",author:"jan t. sott",base00:"#322931",base01:"#433b42",base02:"#5c545b",base03:"#797379",base04:"#989498",base05:"#b9b5b8",base06:"#d5d3d5",base07:"#ffffff",base08:"#dd464c",base09:"#fd8b19",base0A:"#fdcc59",base0B:"#8fc13e",base0C:"#149b93",base0D:"#1290bf",base0E:"#c85e7c",base0F:"#b33508"};B5.exports=Gh.default});var W5=b((Zh,U5)=>{"use strict";a();Zh.__esModule=!0;Zh.default={scheme:"isotope",author:"jan t. sott",base00:"#000000",base01:"#404040",base02:"#606060",base03:"#808080",base04:"#c0c0c0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#ff0000",base09:"#ff9900",base0A:"#ff0099",base0B:"#33ff00",base0C:"#00ffff",base0D:"#0066ff",base0E:"#cc00ff",base0F:"#3300ff"};U5.exports=Zh.default});var K5=b((Jh,H5)=>{"use strict";a();Jh.__esModule=!0;Jh.default={scheme:"marrakesh",author:"alexandre gavioli (http://github.com/alexx2/)",base00:"#201602",base01:"#302e00",base02:"#5f5b17",base03:"#6c6823",base04:"#86813b",base05:"#948e48",base06:"#ccc37a",base07:"#faf0a5",base08:"#c35359",base09:"#b36144",base0A:"#a88339",base0B:"#18974e",base0C:"#75a738",base0D:"#477ca1",base0E:"#8868b3",base0F:"#b3588e"};H5.exports=Jh.default});var G5=b((Yh,V5)=>{"use strict";a();Yh.__esModule=!0;Yh.default={scheme:"mocha",author:"chris kempson (http://chriskempson.com)",base00:"#3B3228",base01:"#534636",base02:"#645240",base03:"#7e705a",base04:"#b8afad",base05:"#d0c8c6",base06:"#e9e1dd",base07:"#f5eeeb",base08:"#cb6077",base09:"#d28b71",base0A:"#f4bc87",base0B:"#beb55b",base0C:"#7bbda4",base0D:"#8ab3b5",base0E:"#a89bb9",base0F:"#bb9584"};V5.exports=Yh.default});var J5=b((Xh,Z5)=>{"use strict";a();Xh.__esModule=!0;Xh.default={scheme:"monokai",author:"wimer hazenberg (http://www.monokai.nl)",base00:"#272822",base01:"#383830",base02:"#49483e",base03:"#75715e",base04:"#a59f85",base05:"#f8f8f2",base06:"#f5f4f1",base07:"#f9f8f5",base08:"#f92672",base09:"#fd971f",base0A:"#f4bf75",base0B:"#a6e22e",base0C:"#a1efe4",base0D:"#66d9ef",base0E:"#ae81ff",base0F:"#cc6633"};Z5.exports=Xh.default});var X5=b((Qh,Y5)=>{"use strict";a();Qh.__esModule=!0;Qh.default={scheme:"ocean",author:"chris kempson (http://chriskempson.com)",base00:"#2b303b",base01:"#343d46",base02:"#4f5b66",base03:"#65737e",base04:"#a7adba",base05:"#c0c5ce",base06:"#dfe1e8",base07:"#eff1f5",base08:"#bf616a",base09:"#d08770",base0A:"#ebcb8b",base0B:"#a3be8c",base0C:"#96b5b4",base0D:"#8fa1b3",base0E:"#b48ead",base0F:"#ab7967"};Y5.exports=Qh.default});var e3=b((eg,Q5)=>{"use strict";a();eg.__esModule=!0;eg.default={scheme:"paraiso",author:"jan t. sott",base00:"#2f1e2e",base01:"#41323f",base02:"#4f424c",base03:"#776e71",base04:"#8d8687",base05:"#a39e9b",base06:"#b9b6b0",base07:"#e7e9db",base08:"#ef6155",base09:"#f99b15",base0A:"#fec418",base0B:"#48b685",base0C:"#5bc4bf",base0D:"#06b6ef",base0E:"#815ba4",base0F:"#e96ba8"};Q5.exports=eg.default});var r3=b((tg,t3)=>{"use strict";a();tg.__esModule=!0;tg.default={scheme:"pop",author:"chris kempson (http://chriskempson.com)",base00:"#000000",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#b0b0b0",base05:"#d0d0d0",base06:"#e0e0e0",base07:"#ffffff",base08:"#eb008a",base09:"#f29333",base0A:"#f8ca12",base0B:"#37b349",base0C:"#00aabb",base0D:"#0e5a94",base0E:"#b31e8d",base0F:"#7a2d00"};t3.exports=tg.default});var o3=b((rg,n3)=>{"use strict";a();rg.__esModule=!0;rg.default={scheme:"railscasts",author:"ryan bates (http://railscasts.com)",base00:"#2b2b2b",base01:"#272935",base02:"#3a4055",base03:"#5a647e",base04:"#d4cfc9",base05:"#e6e1dc",base06:"#f4f1ed",base07:"#f9f7f3",base08:"#da4939",base09:"#cc7833",base0A:"#ffc66d",base0B:"#a5c261",base0C:"#519f50",base0D:"#6d9cbe",base0E:"#b6b3eb",base0F:"#bc9458"};n3.exports=rg.default});var s3=b((ng,i3)=>{"use strict";a();ng.__esModule=!0;ng.default={scheme:"shapeshifter",author:"tyler benziger (http://tybenz.com)",base00:"#000000",base01:"#040404",base02:"#102015",base03:"#343434",base04:"#555555",base05:"#ababab",base06:"#e0e0e0",base07:"#f9f9f9",base08:"#e92f2f",base09:"#e09448",base0A:"#dddd13",base0B:"#0ed839",base0C:"#23edda",base0D:"#3b48e3",base0E:"#f996e2",base0F:"#69542d"};i3.exports=ng.default});var c3=b((og,a3)=>{"use strict";a();og.__esModule=!0;og.default={scheme:"solarized",author:"ethan schoonover (http://ethanschoonover.com/solarized)",base00:"#002b36",base01:"#073642",base02:"#586e75",base03:"#657b83",base04:"#839496",base05:"#93a1a1",base06:"#eee8d5",base07:"#fdf6e3",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"};a3.exports=og.default});var u3=b((ig,l3)=>{"use strict";a();ig.__esModule=!0;ig.default={scheme:"summerfruit",author:"christopher corley (http://cscorley.github.io/)",base00:"#151515",base01:"#202020",base02:"#303030",base03:"#505050",base04:"#B0B0B0",base05:"#D0D0D0",base06:"#E0E0E0",base07:"#FFFFFF",base08:"#FF0086",base09:"#FD8900",base0A:"#ABA800",base0B:"#00C918",base0C:"#1faaaa",base0D:"#3777E6",base0E:"#AD00A1",base0F:"#cc6633"};l3.exports=ig.default});var p3=b((sg,f3)=>{"use strict";a();sg.__esModule=!0;sg.default={scheme:"tomorrow",author:"chris kempson (http://chriskempson.com)",base00:"#1d1f21",base01:"#282a2e",base02:"#373b41",base03:"#969896",base04:"#b4b7b4",base05:"#c5c8c6",base06:"#e0e0e0",base07:"#ffffff",base08:"#cc6666",base09:"#de935f",base0A:"#f0c674",base0B:"#b5bd68",base0C:"#8abeb7",base0D:"#81a2be",base0E:"#b294bb",base0F:"#a3685a"};f3.exports=sg.default});var m3=b((ag,d3)=>{"use strict";a();ag.__esModule=!0;ag.default={scheme:"london tube",author:"jan t. sott",base00:"#231f20",base01:"#1c3f95",base02:"#5a5758",base03:"#737171",base04:"#959ca1",base05:"#d9d8d8",base06:"#e7e7e8",base07:"#ffffff",base08:"#ee2e24",base09:"#f386a1",base0A:"#ffd204",base0B:"#00853e",base0C:"#85cebc",base0D:"#009ddc",base0E:"#98005d",base0F:"#b06110"};d3.exports=ag.default});var g3=b((cg,h3)=>{"use strict";a();cg.__esModule=!0;cg.default={scheme:"twilight",author:"david hart (http://hart-dev.com)",base00:"#1e1e1e",base01:"#323537",base02:"#464b50",base03:"#5f5a60",base04:"#838184",base05:"#a7a7a7",base06:"#c3c3c3",base07:"#ffffff",base08:"#cf6a4c",base09:"#cda869",base0A:"#f9ee98",base0B:"#8f9d6a",base0C:"#afc4db",base0D:"#7587a6",base0E:"#9b859d",base0F:"#9b703f"};h3.exports=cg.default});var y3=b(le=>{"use strict";a();le.__esModule=!0;function ue(t){return t&&t.__esModule?t.default:t}var Lne=Xj();le.threezerotwofour=ue(Lne);var jne=e5();le.apathy=ue(jne);var qne=r5();le.ashes=ue(qne);var Bne=o5();le.atelierDune=ue(Bne);var zne=s5();le.atelierForest=ue(zne);var Une=c5();le.atelierHeath=ue(Une);var Wne=u5();le.atelierLakeside=ue(Wne);var Hne=p5();le.atelierSeaside=ue(Hne);var Kne=m5();le.bespin=ue(Kne);var Vne=g5();le.brewer=ue(Vne);var Gne=b5();le.bright=ue(Gne);var Zne=w5();le.chalk=ue(Zne);var Jne=E5();le.codeschool=ue(Jne);var Yne=I5();le.colors=ue(Yne);var Xne=T5();le.default=ue(Xne);var Qne=C5();le.eighties=ue(Qne);var eoe=A5();le.embers=ue(eoe);var toe=N5();le.flat=ue(toe);var roe=P5();le.google=ue(roe);var noe=M5();le.grayscale=ue(noe);var ooe=L5();le.greenscreen=ue(ooe);var ioe=q5();le.harmonic=ue(ioe);var soe=z5();le.hopscotch=ue(soe);var aoe=W5();le.isotope=ue(aoe);var coe=K5();le.marrakesh=ue(coe);var loe=G5();le.mocha=ue(loe);var uoe=J5();le.monokai=ue(uoe);var foe=X5();le.ocean=ue(foe);var poe=e3();le.paraiso=ue(poe);var doe=r3();le.pop=ue(doe);var moe=o3();le.railscasts=ue(moe);var hoe=s3();le.shapeshifter=ue(hoe);var goe=c3();le.solarized=ue(goe);var yoe=u3();le.summerfruit=ue(yoe);var boe=p3();le.tomorrow=ue(boe);var voe=m3();le.tube=ue(voe);var woe=g3();le.twilight=ue(woe)});var v3=b((t8e,b3)=>{"use strict";a();b3.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var x3=b((n8e,w3)=>{a();w3.exports=function(e){return!e||typeof e=="string"?!1:e instanceof Array||Array.isArray(e)||e.length>=0&&(e.splice instanceof Function||Object.getOwnPropertyDescriptor(e,e.length-1)&&e.constructor.name!=="String")}});var I3=b((i8e,S3)=>{"use strict";a();var xoe=x3(),Eoe=Array.prototype.concat,Soe=Array.prototype.slice,E3=S3.exports=function(e){for(var r=[],n=0,o=e.length;n{a();var Bu=v3(),zu=I3(),_3=Object.hasOwnProperty,T3=Object.create(null);for(lg in Bu)_3.call(Bu,lg)&&(T3[Bu[lg]]=lg);var lg,ir=O3.exports={to:{},get:{}};ir.get=function(t){var e=t.substring(0,3).toLowerCase(),r,n;switch(e){case"hsl":r=ir.get.hsl(t),n="hsl";break;case"hwb":r=ir.get.hwb(t),n="hwb";break;default:r=ir.get.rgb(t),n="rgb";break}return r?{model:n,value:r}:null};ir.get.rgb=function(t){if(!t)return null;var e=/^#([a-f0-9]{3,4})$/i,r=/^#([a-f0-9]{6})([a-f0-9]{2})?$/i,n=/^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,o=/^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/,i=/^(\w+)$/,s=[0,0,0,1],c,l,f;if(c=t.match(r)){for(f=c[2],c=c[1],l=0;l<3;l++){var u=l*2;s[l]=parseInt(c.slice(u,u+2),16)}f&&(s[3]=parseInt(f,16)/255)}else if(c=t.match(e)){for(c=c[1],f=c[3],l=0;l<3;l++)s[l]=parseInt(c[l]+c[l],16);f&&(s[3]=parseInt(f+f,16)/255)}else if(c=t.match(n)){for(l=0;l<3;l++)s[l]=parseInt(c[l+1],0);c[4]&&(c[5]?s[3]=parseFloat(c[4])*.01:s[3]=parseFloat(c[4]))}else if(c=t.match(o)){for(l=0;l<3;l++)s[l]=Math.round(parseFloat(c[l+1])*2.55);c[4]&&(c[5]?s[3]=parseFloat(c[4])*.01:s[3]=parseFloat(c[4]))}else return(c=t.match(i))?c[1]==="transparent"?[0,0,0,0]:_3.call(Bu,c[1])?(s=Bu[c[1]],s[3]=1,s):null:null;for(l=0;l<3;l++)s[l]=ei(s[l],0,255);return s[3]=ei(s[3],0,1),s};ir.get.hsl=function(t){if(!t)return null;var e=/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=t.match(e);if(r){var n=parseFloat(r[4]),o=(parseFloat(r[1])%360+360)%360,i=ei(parseFloat(r[2]),0,100),s=ei(parseFloat(r[3]),0,100),c=ei(isNaN(n)?1:n,0,1);return[o,i,s,c]}return null};ir.get.hwb=function(t){if(!t)return null;var e=/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/,r=t.match(e);if(r){var n=parseFloat(r[4]),o=(parseFloat(r[1])%360+360)%360,i=ei(parseFloat(r[2]),0,100),s=ei(parseFloat(r[3]),0,100),c=ei(isNaN(n)?1:n,0,1);return[o,i,s,c]}return null};ir.to.hex=function(){var t=zu(arguments);return"#"+ug(t[0])+ug(t[1])+ug(t[2])+(t[3]<1?ug(Math.round(t[3]*255)):"")};ir.to.rgb=function(){var t=zu(arguments);return t.length<4||t[3]===1?"rgb("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+")":"rgba("+Math.round(t[0])+", "+Math.round(t[1])+", "+Math.round(t[2])+", "+t[3]+")"};ir.to.rgb.percent=function(){var t=zu(arguments),e=Math.round(t[0]/255*100),r=Math.round(t[1]/255*100),n=Math.round(t[2]/255*100);return t.length<4||t[3]===1?"rgb("+e+"%, "+r+"%, "+n+"%)":"rgba("+e+"%, "+r+"%, "+n+"%, "+t[3]+")"};ir.to.hsl=function(){var t=zu(arguments);return t.length<4||t[3]===1?"hsl("+t[0]+", "+t[1]+"%, "+t[2]+"%)":"hsla("+t[0]+", "+t[1]+"%, "+t[2]+"%, "+t[3]+")"};ir.to.hwb=function(){var t=zu(arguments),e="";return t.length>=4&&t[3]!==1&&(e=", "+t[3]),"hwb("+t[0]+", "+t[1]+"%, "+t[2]+"%"+e+")"};ir.to.keyword=function(t){return T3[t.slice(0,3)]};function ei(t,e,r){return Math.min(Math.max(e,t),r)}function ug(t){var e=Math.round(t).toString(16).toUpperCase();return e.length<2?"0"+e:e}});var A3=b((l8e,k3)=>{"use strict";a();k3.exports={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]}});var eE=b((f8e,P3)=>{a();var fs=A3(),D3={};for(fg in fs)fs.hasOwnProperty(fg)&&(D3[fs[fg]]=fg);var fg,B=P3.exports={rgb:{channels:3,labels:"rgb"},hsl:{channels:3,labels:"hsl"},hsv:{channels:3,labels:"hsv"},hwb:{channels:3,labels:"hwb"},cmyk:{channels:4,labels:"cmyk"},xyz:{channels:3,labels:"xyz"},lab:{channels:3,labels:"lab"},lch:{channels:3,labels:"lch"},hex:{channels:1,labels:["hex"]},keyword:{channels:1,labels:["keyword"]},ansi16:{channels:1,labels:["ansi16"]},ansi256:{channels:1,labels:["ansi256"]},hcg:{channels:3,labels:["h","c","g"]},apple:{channels:3,labels:["r16","g16","b16"]},gray:{channels:1,labels:["gray"]}};for(At in B)if(B.hasOwnProperty(At)){if(!("channels"in B[At]))throw new Error("missing channels property: "+At);if(!("labels"in B[At]))throw new Error("missing channel labels property: "+At);if(B[At].labels.length!==B[At].channels)throw new Error("channel and label counts mismatch: "+At);R3=B[At].channels,N3=B[At].labels,delete B[At].channels,delete B[At].labels,Object.defineProperty(B[At],"channels",{value:R3}),Object.defineProperty(B[At],"labels",{value:N3})}var R3,N3,At;B.rgb.hsl=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=Math.min(e,r,n),i=Math.max(e,r,n),s=i-o,c,l,f;return i===o?c=0:e===i?c=(r-n)/s:r===i?c=2+(n-e)/s:n===i&&(c=4+(e-r)/s),c=Math.min(c*60,360),c<0&&(c+=360),f=(o+i)/2,i===o?l=0:f<=.5?l=s/(i+o):l=s/(2-i-o),[c,l*100,f*100]};B.rgb.hsv=function(t){var e,r,n,o,i,s=t[0]/255,c=t[1]/255,l=t[2]/255,f=Math.max(s,c,l),u=f-Math.min(s,c,l),d=function(m){return(f-m)/6/u+1/2};return u===0?o=i=0:(i=u/f,e=d(s),r=d(c),n=d(l),s===f?o=n-r:c===f?o=1/3+e-n:l===f&&(o=2/3+r-e),o<0?o+=1:o>1&&(o-=1)),[o*360,i*100,f*100]};B.rgb.hwb=function(t){var e=t[0],r=t[1],n=t[2],o=B.rgb.hsl(t)[0],i=1/255*Math.min(e,Math.min(r,n));return n=1-1/255*Math.max(e,Math.max(r,n)),[o,i*100,n*100]};B.rgb.cmyk=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o,i,s,c;return c=Math.min(1-e,1-r,1-n),o=(1-e-c)/(1-c)||0,i=(1-r-c)/(1-c)||0,s=(1-n-c)/(1-c)||0,[o*100,i*100,s*100,c*100]};function Ioe(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)+Math.pow(t[2]-e[2],2)}B.rgb.keyword=function(t){var e=D3[t];if(e)return e;var r=1/0,n;for(var o in fs)if(fs.hasOwnProperty(o)){var i=fs[o],s=Ioe(t,i);s.04045?Math.pow((e+.055)/1.055,2.4):e/12.92,r=r>.04045?Math.pow((r+.055)/1.055,2.4):r/12.92,n=n>.04045?Math.pow((n+.055)/1.055,2.4):n/12.92;var o=e*.4124+r*.3576+n*.1805,i=e*.2126+r*.7152+n*.0722,s=e*.0193+r*.1192+n*.9505;return[o*100,i*100,s*100]};B.rgb.lab=function(t){var e=B.rgb.xyz(t),r=e[0],n=e[1],o=e[2],i,s,c;return r/=95.047,n/=100,o/=108.883,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=o>.008856?Math.pow(o,1/3):7.787*o+16/116,i=116*n-16,s=500*(r-n),c=200*(n-o),[i,s,c]};B.hsl.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,o,i,s,c,l;if(r===0)return l=n*255,[l,l,l];n<.5?i=n*(1+r):i=n+r-n*r,o=2*n-i,c=[0,0,0];for(var f=0;f<3;f++)s=e+1/3*-(f-1),s<0&&s++,s>1&&s--,6*s<1?l=o+(i-o)*6*s:2*s<1?l=i:3*s<2?l=o+(i-o)*(2/3-s)*6:l=o,c[f]=l*255;return c};B.hsl.hsv=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,o=r,i=Math.max(n,.01),s,c;return n*=2,r*=n<=1?n:2-n,o*=i<=1?i:2-i,c=(n+r)/2,s=n===0?2*o/(i+o):2*r/(n+r),[e,s*100,c*100]};B.hsv.rgb=function(t){var e=t[0]/60,r=t[1]/100,n=t[2]/100,o=Math.floor(e)%6,i=e-Math.floor(e),s=255*n*(1-r),c=255*n*(1-r*i),l=255*n*(1-r*(1-i));switch(n*=255,o){case 0:return[n,l,s];case 1:return[c,n,s];case 2:return[s,n,l];case 3:return[s,c,n];case 4:return[l,s,n];case 5:return[n,s,c]}};B.hsv.hsl=function(t){var e=t[0],r=t[1]/100,n=t[2]/100,o=Math.max(n,.01),i,s,c;return c=(2-r)*n,i=(2-r)*o,s=r*o,s/=i<=1?i:2-i,s=s||0,c/=2,[e,s*100,c*100]};B.hwb.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100,o=r+n,i,s,c,l;o>1&&(r/=o,n/=o),i=Math.floor(6*e),s=1-n,c=6*e-i,i&1&&(c=1-c),l=r+c*(s-r);var f,u,d;switch(i){default:case 6:case 0:f=s,u=l,d=r;break;case 1:f=l,u=s,d=r;break;case 2:f=r,u=s,d=l;break;case 3:f=r,u=l,d=s;break;case 4:f=l,u=r,d=s;break;case 5:f=s,u=r,d=l;break}return[f*255,u*255,d*255]};B.cmyk.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,o=t[3]/100,i,s,c;return i=1-Math.min(1,e*(1-o)+o),s=1-Math.min(1,r*(1-o)+o),c=1-Math.min(1,n*(1-o)+o),[i*255,s*255,c*255]};B.xyz.rgb=function(t){var e=t[0]/100,r=t[1]/100,n=t[2]/100,o,i,s;return o=e*3.2406+r*-1.5372+n*-.4986,i=e*-.9689+r*1.8758+n*.0415,s=e*.0557+r*-.204+n*1.057,o=o>.0031308?1.055*Math.pow(o,1/2.4)-.055:o*12.92,i=i>.0031308?1.055*Math.pow(i,1/2.4)-.055:i*12.92,s=s>.0031308?1.055*Math.pow(s,1/2.4)-.055:s*12.92,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[o*255,i*255,s*255]};B.xyz.lab=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return e/=95.047,r/=100,n/=108.883,e=e>.008856?Math.pow(e,1/3):7.787*e+16/116,r=r>.008856?Math.pow(r,1/3):7.787*r+16/116,n=n>.008856?Math.pow(n,1/3):7.787*n+16/116,o=116*r-16,i=500*(e-r),s=200*(r-n),[o,i,s]};B.lab.xyz=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;i=(e+16)/116,o=r/500+i,s=i-n/200;var c=Math.pow(i,3),l=Math.pow(o,3),f=Math.pow(s,3);return i=c>.008856?c:(i-16/116)/7.787,o=l>.008856?l:(o-16/116)/7.787,s=f>.008856?f:(s-16/116)/7.787,o*=95.047,i*=100,s*=108.883,[o,i,s]};B.lab.lch=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return o=Math.atan2(n,r),i=o*360/2/Math.PI,i<0&&(i+=360),s=Math.sqrt(r*r+n*n),[e,s,i]};B.lch.lab=function(t){var e=t[0],r=t[1],n=t[2],o,i,s;return s=n/360*2*Math.PI,o=r*Math.cos(s),i=r*Math.sin(s),[e,o,i]};B.rgb.ansi16=function(t){var e=t[0],r=t[1],n=t[2],o=1 in arguments?arguments[1]:B.rgb.hsv(t)[2];if(o=Math.round(o/50),o===0)return 30;var i=30+(Math.round(n/255)<<2|Math.round(r/255)<<1|Math.round(e/255));return o===2&&(i+=60),i};B.hsv.ansi16=function(t){return B.rgb.ansi16(B.hsv.rgb(t),t[2])};B.rgb.ansi256=function(t){var e=t[0],r=t[1],n=t[2];if(e===r&&r===n)return e<8?16:e>248?231:Math.round((e-8)/247*24)+232;var o=16+36*Math.round(e/255*5)+6*Math.round(r/255*5)+Math.round(n/255*5);return o};B.ansi16.rgb=function(t){var e=t%10;if(e===0||e===7)return t>50&&(e+=3.5),e=e/10.5*255,[e,e,e];var r=(~~(t>50)+1)*.5,n=(e&1)*r*255,o=(e>>1&1)*r*255,i=(e>>2&1)*r*255;return[n,o,i]};B.ansi256.rgb=function(t){if(t>=232){var e=(t-232)*10+8;return[e,e,e]}t-=16;var r,n=Math.floor(t/36)/5*255,o=Math.floor((r=t%36)/6)/5*255,i=r%6/5*255;return[n,o,i]};B.rgb.hex=function(t){var e=((Math.round(t[0])&255)<<16)+((Math.round(t[1])&255)<<8)+(Math.round(t[2])&255),r=e.toString(16).toUpperCase();return"000000".substring(r.length)+r};B.hex.rgb=function(t){var e=t.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);if(!e)return[0,0,0];var r=e[0];e[0].length===3&&(r=r.split("").map(function(c){return c+c}).join(""));var n=parseInt(r,16),o=n>>16&255,i=n>>8&255,s=n&255;return[o,i,s]};B.rgb.hcg=function(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=Math.max(Math.max(e,r),n),i=Math.min(Math.min(e,r),n),s=o-i,c,l;return s<1?c=i/(1-s):c=0,s<=0?l=0:o===e?l=(r-n)/s%6:o===r?l=2+(n-e)/s:l=4+(e-r)/s+4,l/=6,l%=1,[l*360,s*100,c*100]};B.hsl.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1,o=0;return r<.5?n=2*e*r:n=2*e*(1-r),n<1&&(o=(r-.5*n)/(1-n)),[t[0],n*100,o*100]};B.hsv.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=e*r,o=0;return n<1&&(o=(r-n)/(1-n)),[t[0],n*100,o*100]};B.hcg.rgb=function(t){var e=t[0]/360,r=t[1]/100,n=t[2]/100;if(r===0)return[n*255,n*255,n*255];var o=[0,0,0],i=e%1*6,s=i%1,c=1-s,l=0;switch(Math.floor(i)){case 0:o[0]=1,o[1]=s,o[2]=0;break;case 1:o[0]=c,o[1]=1,o[2]=0;break;case 2:o[0]=0,o[1]=1,o[2]=s;break;case 3:o[0]=0,o[1]=c,o[2]=1;break;case 4:o[0]=s,o[1]=0,o[2]=1;break;default:o[0]=1,o[1]=0,o[2]=c}return l=(1-r)*n,[(r*o[0]+l)*255,(r*o[1]+l)*255,(r*o[2]+l)*255]};B.hcg.hsv=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e),o=0;return n>0&&(o=e/n),[t[0],o*100,n*100]};B.hcg.hsl=function(t){var e=t[1]/100,r=t[2]/100,n=r*(1-e)+.5*e,o=0;return n>0&&n<.5?o=e/(2*n):n>=.5&&n<1&&(o=e/(2*(1-n))),[t[0],o*100,n*100]};B.hcg.hwb=function(t){var e=t[1]/100,r=t[2]/100,n=e+r*(1-e);return[t[0],(n-e)*100,(1-n)*100]};B.hwb.hcg=function(t){var e=t[1]/100,r=t[2]/100,n=1-r,o=n-e,i=0;return o<1&&(i=(n-o)/(1-o)),[t[0],o*100,i*100]};B.apple.rgb=function(t){return[t[0]/65535*255,t[1]/65535*255,t[2]/65535*255]};B.rgb.apple=function(t){return[t[0]/255*65535,t[1]/255*65535,t[2]/255*65535]};B.gray.rgb=function(t){return[t[0]/100*255,t[0]/100*255,t[0]/100*255]};B.gray.hsl=B.gray.hsv=function(t){return[0,0,t[0]]};B.gray.hwb=function(t){return[0,100,t[0]]};B.gray.cmyk=function(t){return[0,0,0,t[0]]};B.gray.lab=function(t){return[t[0],0,0]};B.gray.hex=function(t){var e=Math.round(t[0]/100*255)&255,r=(e<<16)+(e<<8)+e,n=r.toString(16).toUpperCase();return"000000".substring(n.length)+n};B.rgb.gray=function(t){var e=(t[0]+t[1]+t[2])/3;return[e/255*100]}});var M3=b((d8e,F3)=>{a();var pg=eE();function _oe(){for(var t={},e=Object.keys(pg),r=e.length,n=0;n{a();var tE=eE(),koe=M3(),ja={},Aoe=Object.keys(tE);function Roe(t){var e=function(r){return r==null?r:(arguments.length>1&&(r=Array.prototype.slice.call(arguments)),t(r))};return"conversion"in t&&(e.conversion=t.conversion),e}function Noe(t){var e=function(r){if(r==null)return r;arguments.length>1&&(r=Array.prototype.slice.call(arguments));var n=t(r);if(typeof n=="object")for(var o=n.length,i=0;i{"use strict";a();var Uu=C3(),sr=L3(),oE=[].slice,j3=["keyword","gray","hex"],rE={};Object.keys(sr).forEach(function(t){rE[oE.call(sr[t].labels).sort().join("")]=t});var dg={};function dt(t,e){if(!(this instanceof dt))return new dt(t,e);if(e&&e in j3&&(e=null),e&&!(e in sr))throw new Error("Unknown model: "+e);var r,n;if(t==null)this.model="rgb",this.color=[0,0,0],this.valpha=1;else if(t instanceof dt)this.model=t.model,this.color=t.color.slice(),this.valpha=t.valpha;else if(typeof t=="string"){var o=Uu.get(t);if(o===null)throw new Error("Unable to parse color from string: "+t);this.model=o.model,n=sr[this.model].channels,this.color=o.value.slice(0,n),this.valpha=typeof o.value[n]=="number"?o.value[n]:1}else if(t.length){this.model=e||"rgb",n=sr[this.model].channels;var i=oE.call(t,0,n);this.color=nE(i,n),this.valpha=typeof t[n]=="number"?t[n]:1}else if(typeof t=="number")t&=16777215,this.model="rgb",this.color=[t>>16&255,t>>8&255,t&255],this.valpha=1;else{this.valpha=1;var s=Object.keys(t);"alpha"in t&&(s.splice(s.indexOf("alpha"),1),this.valpha=typeof t.alpha=="number"?t.alpha:0);var c=s.sort().join("");if(!(c in rE))throw new Error("Unable to parse color from object: "+JSON.stringify(t));this.model=rE[c];var l=sr[this.model].labels,f=[];for(r=0;rr?(e+.05)/(r+.05):(r+.05)/(e+.05)},level:function(t){var e=this.contrast(t);return e>=7.1?"AAA":e>=4.5?"AA":""},isDark:function(){var t=this.rgb().color,e=(t[0]*299+t[1]*587+t[2]*114)/1e3;return e<128},isLight:function(){return!this.isDark()},negate:function(){for(var t=this.rgb(),e=0;e<3;e++)t.color[e]=255-t.color[e];return t},lighten:function(t){var e=this.hsl();return e.color[2]+=e.color[2]*t,e},darken:function(t){var e=this.hsl();return e.color[2]-=e.color[2]*t,e},saturate:function(t){var e=this.hsl();return e.color[1]+=e.color[1]*t,e},desaturate:function(t){var e=this.hsl();return e.color[1]-=e.color[1]*t,e},whiten:function(t){var e=this.hwb();return e.color[1]+=e.color[1]*t,e},blacken:function(t){var e=this.hwb();return e.color[2]+=e.color[2]*t,e},grayscale:function(){var t=this.rgb().color,e=t[0]*.3+t[1]*.59+t[2]*.11;return dt.rgb(e,e,e)},fade:function(t){return this.alpha(this.valpha-this.valpha*t)},opaquer:function(t){return this.alpha(this.valpha+this.valpha*t)},rotate:function(t){var e=this.hsl(),r=e.color[0];return r=(r+t)%360,r=r<0?360+r:r,e.color[0]=r,e},mix:function(t,e){if(!t||!t.rgb)throw new Error('Argument to "mix" was not a Color instance, but rather an instance of '+typeof t);var r=t.rgb(),n=this.rgb(),o=e===void 0?.5:e,i=2*o-1,s=r.alpha()-n.alpha(),c=((i*s===-1?i:(i+s)/(1+i*s))+1)/2,l=1-c;return dt.rgb(c*r.red()+l*n.red(),c*r.green()+l*n.green(),c*r.blue()+l*n.blue(),r.alpha()*o+n.alpha()*(1-o))}};Object.keys(sr).forEach(function(t){if(j3.indexOf(t)===-1){var e=sr[t].channels;dt.prototype[t]=function(){if(this.model===t)return new dt(this);if(arguments.length)return new dt(arguments,t);var r=typeof arguments[e]=="number"?e:this.valpha;return new dt(Foe(sr[this.model][t].raw(this.color)).concat(r),t)},dt[t]=function(r){return typeof r=="number"&&(r=nE(oE.call(arguments),e)),new dt(r,t)}}});function Doe(t,e){return Number(t.toFixed(e))}function Poe(t){return function(e){return Doe(e,t)}}function Le(t,e,r){return t=Array.isArray(t)?t:[t],t.forEach(function(n){(dg[n]||(dg[n]=[]))[e]=r}),t=t[0],function(n){var o;return arguments.length?(r&&(n=r(n)),o=this[t](),o.color[e]=n,o):(o=this[t]().color[e],r&&(o=r(o)),o)}}function Ye(t){return function(e){return Math.max(0,Math.min(t,e))}}function Foe(t){return Array.isArray(t)?t:[t]}function nE(t,e){for(var r=0;r{a();var Moe="Expected a function",z3="__lodash_placeholder__",ds=1,hg=2,$oe=4,ps=8,Wu=16,qa=32,Hu=64,Z3=128,Loe=256,J3=512,U3=1/0,joe=9007199254740991,qoe=17976931348623157e292,W3=0/0,Boe=[["ary",Z3],["bind",ds],["bindKey",hg],["curry",ps],["curryRight",Wu],["flip",J3],["partial",qa],["partialRight",Hu],["rearg",Loe]],zoe="[object Function]",Uoe="[object GeneratorFunction]",Woe="[object Symbol]",Hoe=/[\\^$.*+?()[\]{}|]/g,Koe=/^\s+|\s+$/g,Voe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,Goe=/\{\n\/\* \[wrapped with (.+)\] \*/,Zoe=/,? & /,Joe=/^[-+]0x[0-9a-f]+$/i,Yoe=/^0b[01]+$/i,Xoe=/^\[object .+?Constructor\]$/,Qoe=/^0o[0-7]+$/i,eie=/^(?:0|[1-9]\d*)$/,tie=parseInt,rie=typeof global=="object"&&global&&global.Object===Object&&global,nie=typeof self=="object"&&self&&self.Object===Object&&self,Vu=rie||nie||Function("return this")();function Y3(t,e,r){switch(r.length){case 0:return t.call(e);case 1:return t.call(e,r[0]);case 2:return t.call(e,r[0],r[1]);case 3:return t.call(e,r[0],r[1],r[2])}return t.apply(e,r)}function oie(t,e){for(var r=-1,n=t?t.length:0;++r-1}function sie(t,e,r,n){for(var o=t.length,i=r+(n?1:-1);n?i--:++i2?t:void 0}();function yie(t){return Ba(t)?hie(t):{}}function bie(t){if(!Ba(t)||kie(t))return!1;var e=Die(t)||fie(t)?mie:Xoe;return e.test(Rie(t))}function vie(t,e,r,n){for(var o=-1,i=t.length,s=r.length,c=-1,l=e.length,f=mg(i-s,0),u=Array(l+f),d=!n;++c1&&S.reverse(),u&&l1?"& ":"")+e[n],e=e.join(r>2?", ":" "),t.replace(Voe,`{ /* [wrapped with `+e+`] */ -`)}function aie(t,e){return e=e??boe,!!e&&(typeof t=="number"||Doe.test(t))&&t>-1&&t%1==0&&txe});module.exports=$g(xae);function aS(t){var e=new WeakMap;return r=>e.has(r)?e.get(r):VB(e,r,t(r,e))}function VB(t,e,r){return t.set(e,r),r}function lS(t){return t&&typeof t=="object"?JSON.parse(JSON.stringify(t)):t}var En=typeof queueMicrotask=="function"?queueMicrotask:(t=>e=>t.then(e))(Promise.resolve());function cS(t){let e=Promise.resolve(t);return(r,n)=>r||n?(typeof n>"u"&&(n=console.error),e=e.then(r,n)):e}function uS(){let t,e,r=new Promise((n,o)=>{t=n,e=o});return{resolve:t,reject:e,promise:r}}var Dae=require("obsidian"),ft;(function(t){Object.assign(t,require("obsidian"))})(ft||(ft={}));var Lg="use.me",jg="use.factory",gs,Za,qg=function(){return Object.defineProperties(t(),{this:{get(){if(gs)return gs;throw new TypeError("No current context")}},me:{value:Lg},factory:{value:jg}});function t(o){let i=new Map;i.prev=o;let s=Object.assign(o?l=>{let u=i.get(l);if(!u){for(let d=i.prev;d;d=d.prev)if(u=d.get(l)){u=Object.assign(Object.assign({},u),{s:u.s||1});break}u=u||{s:2,v:r},i.set(l,u)}let c,f,p;for(;;)switch(u.s){case 0:return gs===s&&Za&&Za.push(l),u.v;case 1:if(c=u.d,!c||a(()=>c.k.every(d=>s(d)===c.c(d)))){u.s=0;break}u.v=c.f;case 2:u.s=4;try{e(i,l,0,a(f=u.v,l,p=[])),p.length&&(u.d={c:s,f,k:p});break}catch(d){u.s=3,u.v=d,u.d=null}case 3:throw u.v;case 4:throw new Error(`Factory ${String(u.v)} didn't resolve ${String(l)}`)}}:l=>qg.this(l),{def(l,u){return e(i,l,2,u),s},set(l,u){return e(i,l,1,u),s},fork(l){let u=t(i);return l!=null?u(l):u}});return o?s.use=s:s;function a(l,u,c){let f=gs,p=Za;try{return gs=s,Za=c,l(u)}finally{gs=f,Za=p}}}function e(o,i,s,a){if(o.has(i)){let l=o.get(i);if(!l.s)throw new Error(`Already read: ${String(i)}`);l.s=s,l.v=a,l.d=null}else o.set(i,{s,v:a})}function r(o){if(typeof o[Lg]=="function")return o[Lg](o);if(n(o))return typeof o.prototype[jg]=="function"?o.prototype[jg]():new o;throw new ReferenceError(`No config for ${String(o)}`)}function n(o){return typeof o=="function"&&o.prototype!==void 0&&(Object.getPrototypeOf(o.prototype)!==Object.prototype||Object.getOwnPropertyNames(o.prototype).length>1||o.toString().startsWith("class"))}}();var GB,ys=(t=>(t.service=function(e){return t(Xu).addChild(e),t.this},t.plugin=function(e){if(!Sn)GB=e.app,Sn=t.fork(),Sn.set(ft.Plugin,e),Sn.set(e.constructor,e),e.addChild(Sn.use(Xu));else if(e!==Sn.use(ft.Plugin))throw new TypeError("use.plugin() called on multiple plugins");return Sn},t.def(ft.Plugin,()=>{throw new Error("Plugin not created yet")}),t.def(ft.App,()=>t(ft.Plugin).app),t))(qg),Sn;function Bg(t){if(t?.use)return t.use;if(Sn)return Sn;if(t instanceof ft.Plugin)return t.use=ys.plugin(t);throw new Error("No context available: did you forget to `use.plugin()`?")}var fe=class extends ft.Component{constructor(){super(...arguments),this.use=ys.service(this)}},Xu=class extends ft.Component{constructor(){super(...arguments),this.children=new Set([this])}onload(){this.loaded=!0}onunload(){this.loaded=!1,this.children.clear()}addChild(e){return this.children.has(e)||(this.children.add(e),this.loaded?En(()=>super.addChild(e)):super.addChild(e)),e}};function ZB(t,e){En(()=>t.removeChild(e))}function fS(t,e){let r=new ft.Component;r.onload=()=>{ZB(t,r),t=null,e()},t.addChild(r)}function ef(){throw new Error("Cycle detected")}function tf(){if(io>1){io--;return}let t,e=!1;for(;Ja!==void 0;){let r=Ja;for(Ja=void 0,zg++;r!==void 0;){let n=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&hS(r))try{r.c()}catch(o){e||(t=o,e=!0)}r=n}}if(zg=0,io--,e)throw t}function pS(t){if(io>0)return t();io++;try{return t()}finally{tf()}}var De,Ja;var io=0,zg=0,Qu=0;function dS(t){if(De===void 0)return;let e=t.n;if(e===void 0||e.t!==De)return e={i:0,S:t,p:De.s,n:void 0,t:De,e:void 0,x:void 0,r:e},De.s!==void 0&&(De.s.n=e),De.s=e,t.n=e,32&De.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=De.s,e.n=void 0,De.s.n=e,De.s=e),e}function Ct(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}Ct.prototype.h=function(){return!0};Ct.prototype.S=function(t){this.t!==t&&t.e===void 0&&(t.x=this.t,this.t!==void 0&&(this.t.e=t),this.t=t)};Ct.prototype.U=function(t){if(this.t!==void 0){let e=t.e,r=t.x;e!==void 0&&(e.x=r,t.e=void 0),r!==void 0&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}};Ct.prototype.subscribe=function(t){let e=this;return Wg(function(){let r=e.value,n=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=n}})};Ct.prototype.valueOf=function(){return this.value};Ct.prototype.toString=function(){return this.value+""};Ct.prototype.toJSON=function(){return this.value};Ct.prototype.peek=function(){return this.v};Object.defineProperty(Ct.prototype,"value",{get(){let t=dS(this);return t!==void 0&&(t.i=this.i),this.v},set(t){if(De instanceof so&&function(){throw new Error("Computed cannot have side-effects")}(),t!==this.v){zg>100&&ef(),this.v=t,this.i++,Qu++,io++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{tf()}}}});function mS(t){return new Ct(t)}function hS(t){for(let e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function gS(t){for(let e=t.s;e!==void 0;e=e.n){let r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function yS(t){let e,r=t.s;for(;r!==void 0;){let n=r.p;r.i===-1?(r.S.U(r),n!==void 0&&(n.n=r.n),r.n!==void 0&&(r.n.p=n)):e=r,r.S.n=r.r,r.r!==void 0&&(r.r=void 0),r=n}t.s=e}function so(t){Ct.call(this,void 0),this.x=t,this.s=void 0,this.g=Qu-1,this.f=4}(so.prototype=new Ct).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Qu))return!0;if(this.g=Qu,this.f|=1,this.i>0&&!hS(this))return this.f&=-2,!0;let t=De;try{gS(this),De=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return De=t,yS(this),this.f&=-2,!0};so.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Ct.prototype.S.call(this,t)};so.prototype.U=function(t){if(this.t!==void 0&&(Ct.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}};so.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;t!==void 0;t=t.x)t.t.N()}};so.prototype.peek=function(){if(this.h()||ef(),16&this.f)throw this.v;return this.v};Object.defineProperty(so.prototype,"value",{get(){1&this.f&&ef();let t=dS(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function rf(t){return new so(t)}function bS(t){let e=t.u;if(t.u=void 0,typeof e=="function"){io++;let r=De;De=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,Ug(t),n}finally{De=r,tf()}}}function Ug(t){for(let e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,bS(t)}function JB(t){if(De!==this)throw new Error("Out-of-order effect");yS(this),De=t,this.f&=-2,8&this.f&&Ug(this),tf()}function Ya(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}Ya.prototype.c=function(){let t=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};Ya.prototype.S=function(){1&this.f&&ef(),this.f|=1,this.f&=-9,bS(this),gS(this),io++;let t=De;return De=this,JB.bind(this,t)};Ya.prototype.N=function(){2&this.f||(this.f|=2,this.o=Ja,Ja=this)};Ya.prototype.d=function(){this.f|=8,1&this.f||Ug(this)};function Wg(t){let e=new Ya(t);try{e.c()}catch(r){throw e.d(),r}return e.d.bind(e)}function Hg(t){let e=rf(t);return()=>e.value}function vS(t){let e=mS(t);function r(){return e.value,t}return r.set=function(n){t!==n&&(Qa.size||En(YB),Qa.set(e,t=n))},r}var Qa=new Map;function YB(){Qa.size&&pS(()=>{for(let[t,e]of Qa.entries())Qa.delete(t),t.value=e})}var XB=aS(function(t){return{}});function me(t,e,r){let n=r.get;return{...r,get(){var o,i;return((o=(i=XB(this))[e])!==null&&o!==void 0?o:i[e]=Hg(n.bind(this)))()}}}var Xa;function He(t){let e=Wg(function(){let r=Xa,n=Xa=[];try{let o=t.call(this);if(o&&n.push(o),n.length)return n.length===1?n.pop():function(){for(;n.length;)try{n.shift()()}catch(i){Promise.reject(i)}}}finally{Xa=r}});return Xa&&Xa.push(e),e}function or(t,e){let r=Object.keys(e).map(n=>QB(t,n,e[n]));return r.length===1?r[0]:function(){r.forEach(n=>n())}}function QB(t,e,r){let n=t[e],o=t.hasOwnProperty(e),i=r(n);return n&&Object.setPrototypeOf(i,n),Object.setPrototypeOf(s,i),t[e]=s,a;function s(...l){return i===n&&t[e]===s&&a(),i.apply(this,l)}function a(){t[e]===s&&(o?t[e]=n:delete t[e]),i!==n&&(i=n,Object.setPrototypeOf(s,n||Function))}}var nf=t=>{if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},ez=new Set(["__proto__","prototype","constructor"]),Kg=(t,e)=>{if(!nf(e))return t;t||(t={});for(let[r,n]of Object.entries(e)){if(ez.has(r))continue;let o=t[r];if(nf(o)&&nf(n))t[r]=Kg(o,n);else{if(n===void 0)continue;nf(n)?t[r]=Kg({},n):Array.isArray(n)?t[r]=[...n]:t[r]=n}}return t};function of(t={},e={}){return Kg({...e},{...t})}var sf=class extends fe{get current(){return this.cloned()}addDefaults(e){this.data=of(this.data,e)}constructor(){super(),this.plugin=this.use(ft.Plugin),this.queue=cS(),this.data={},this.version=vS(0),this.cloned=Hg(()=>this.version()?lS(this.data):null),this.queue(async()=>{var e;await new Promise(r=>fS(this.plugin,r)),this.data=of((e=await this.plugin.loadData())!==null&&e!==void 0?e:{},this.data),this.version.set(this.version()+1)},console.error)}once(e,r){let n=this.each(o=>{n(),e.call(r,o)});return n}each(e,r){return He(()=>{this.current&&En(e.bind(r,this.current))})}onChange(e,r){return this.each(e,r)}update(e){return this.queue(async()=>{var r;let n=this.data,o=JSON.stringify(n);try{var i=JSON.parse(o);i=(r=e(i))!==null&&r!==void 0?r:i;let s=JSON.stringify(i);o!==s&&(this.data=i,this.version.set(this.version()+1),await this.plugin.saveData(JSON.parse(s)).catch(console.error))}catch(s){console.error(s)}return this.data})}};function wS(t,e,r,n){let{resolve:o,promise:i}=uS(),s=new class extends ft.FuzzySuggestModal{getItemText(a){var l;return(l=e?.(a))!==null&&l!==void 0?l:""+a}getItems(){return t}onChooseItem(a,l){o({item:a,event:l})}onClose(){super.onClose(),En(()=>o({item:null,event:null}))}}(app);return r&&s.setPlaceholder(r),n?.(s),s.open(),i}var qB=require("obsidian");var xS=t=>`obsidian-zotero:${t}`;var ir=({key:t,groupID:e,parentItem:r},n=!1)=>{let o=[t];return!n&&r&&o.push(`a${r}`),typeof e=="number"&&o.push(`g${e}`),o.join("")},ES=(t,e,r=!0)=>(n,...o)=>{let i="";for(let s=0;s0&&(i+=t(o[s-1])),i+=(r?n.raw:n)[s];return e(i)},Zg=(t=!0,e)=>ES(r=>r,r=>new RegExp(t?"^"+r+"$":r,e),!0),Vg=String.raw`[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}`,Gg=String.raw`\d+`,SS=t=>{let e={annotKey:Vg,parentKey:Vg,groupID:Gg,page:Gg};if(t)for(let r in e)e[r]=`(${e[r]})`;return ES(r=>e[r],r=>r)`${"annotKey"}a${"parentKey"}(?:g${"groupID"})?(?:p${"page"})?`},IS=Zg()`${Vg}(?:g${Gg})?`,_S=Zg()`${SS(!0)}`,OS=Zg()`(?:${SS(!1)}n?)+`,bs=(t,e)=>{if(t===null)return null;let r;return typeof t=="number"?r=t:r=parseInt(t,10),Number.isInteger(r)?e?r+1:r:null};var TS=(t,e,{getLogger:r,configure:n})=>{let o=xS(t);return n({appenders:{out:{type:"console"}},categories:{default:{appenders:["out"],level:e},[o]:{appenders:["out"],level:e}}}),r(o)},CS={ALL:"ALL",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",FATAL:"FATAL",MARK:"MARK",OFF:"OFF"};var ao=()=>(...t)=>t;var AS=t=>`better-sqlite3-${t}.node`;var Sp=Z(ZO(),1);var $b=Z(ks(),1),Eo=require("obsidian"),NA=Z(QO(),1);var KT=require("http");var AU=Z(ks(),1),kU=Z(qy(),1),By=Z(qy(),1);var vT=ao()("open","export","update");var bT=(t,e)=>{let r=new RegExp(`^${e}\\[(\\d+)\\]$`);return Object.entries(t).filter(([n])=>r.test(n)).sort(([n],[o])=>Number(n.match(r)[1])-Number(o.match(r)[1])).map(([,n])=>JSON.parse(n))},jf=t=>{if(t.type==="item")return{version:t.version,type:t.type,items:bT(t,"items")};if(t.type==="annotation")return{version:t.version,type:t.type,annots:bT(t,"annots"),parent:JSON.parse(t.parent)};throw new TypeError("Unrecognized query type: "+t.type)};var zy=/^/;var qf=require("obsidian");var El=require("path");var ET=require("path/posix");var Wy=require("obsidian");var wT={"123":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"125":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"128":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"130":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"132":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"133":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"135":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]},"136":{darwin:["arm64","x64"],linux:["x64","arm64"],win32:["ia32","x64","arm64"]}};var xT=Wy.Platform.isDesktopApp?require("@electron/remote").app.getPath("userData"):null,{arch:ppe,platform:dpe,versions:{modules:NU,electron:mpe}}=process,Uy=wT,ST=({modules:t})=>{if(t in Uy)return 0;let r=Object.keys(Uy).map(o=>parseInt(o,10)).sort((o,i)=>o-i);return parseInt(t,10)>r[r.length-1]?1:-1},IT=({platform:t,arch:e})=>!!Uy[NU][t]?.includes(e),_T=()=>Wy.Platform.isDesktopApp?{arch:process.arch,platform:process.platform,modules:process.versions.modules,electron:process.versions.electron}:null,Hy=t=>t.versions?.["better-sqlite3"],Rs=t=>{if(!xT)return null;let e=Hy(t);return e?(0,ET.join)(xT,AS(e)):null};var OT={citationEditorSuggester:!0,showCitekeyInSuggester:!1};var TT={literatureNoteFolder:"LiteratureNotes"};var CT={enableServer:!1,serverPort:9091,serverHostname:"127.0.0.1"};var Ky=require("path/posix");var AT=`[!note] Page <%= it.pageLabel %> - -<%= it.imgEmbed %><%= it.text %> -<% if (it.comment) { %> ---- -<%= it.comment %> -<% } %>`;var kT=`<% for (const annotation of it) { %> -<%~ include("annotation", annotation) %> -<% } %>`;var RT='[<%= it.map(lit => `@${lit.citekey}`).join("; ") %>]';var NT='<%= it.map(lit => `@${lit.citekey}`).join("; ") %>';var DT=`<%= it.content %>`;var FT=`title: "<%= it.title %>" -citekey: "<%= it.citekey %>"`;var PT=`# <%= it.title %> - -[Zotero](<%= it.backlink %>) <%= it.fileLink %> -<%~ include("annots", it.annotations) %>`;var dt={Ejectable:{note:PT,field:FT,annots:kT,annotation:AT,cite:RT,cite2:NT,colored:DT},Embeded:{filename:"<%= it.citekey ?? it.DOI ?? it.title ?? it.key %>.md"}},en={Ejectable:Object.keys(dt.Ejectable),Embeded:Object.keys(dt.Embeded),All:Object.keys(dt.Ejectable).concat(Object.keys(dt.Embeded))};function Vy(t){return Object.hasOwn(dt.Embeded,t)?`zt-${t}.eta.md`:Object.hasOwn(dt.Ejectable,t)?t==="annotation"?"zt-annot.eta.md":`zt-${t}.eta.md`:null}function mi(t,e){return(0,Ky.join)(e,Vy(t))}function wt(t,e){let r=en.Embeded.find(o=>(0,Ky.join)(e,`zt-${o}.eta.md`)===t);if(r)return{type:"embeded",name:r};let n=en.Ejectable.find(o=>mi(o,e)===t);return n?{type:"ejectable",name:n}:null}var MT={template:{folder:"ZtTemplates",templates:dt.Embeded},updateAnnotBlock:!1,updateOverwrite:!1,autoPairEta:!1,autoTrim:[!1,!1]};var $T={autoRefresh:!0};var LT=require("os"),jT=require("path"),qT=()=>({zoteroDataDir:(0,jT.join)((0,LT.homedir)(),"Zotero"),citationLibrary:1});var BT=require("obsidian"),zT={imgExcerptImport:BT.Platform.isWin?"copy":"symlink",imgExcerptPath:"ZtImgExcerpt"};var UT=()=>({...WT,...OT,...TT,...CT,...MT,...$T,...qT(),...zT});function lt(t,e,r=!1){let n=0;return(...o)=>{if(e(),n++>(r?1:0))return t(...o)}}var ge=class extends sf{#e=this.use(xe);#t;get nativeBinding(){if(this.#t)return this.#t;let e=Rs(this.#e.manifest);if(e)return this.#t=e,this.#t;throw new Error("Failed to get native binding path")}get templateDir(){return this.current?.template?.folder}get libId(){return this.current?.citationLibrary}get simpleTemplates(){return this.current?.template?.templates}get zoteroDbPath(){return(0,El.join)(this.current?.zoteroDataDir,"zotero.sqlite")}get bbtSearchDbPath(){return(0,El.join)(this.current?.zoteroDataDir,"better-bibtex-search.sqlite")}get bbtMainDbPath(){return(0,El.join)(this.current?.zoteroDataDir,"better-bibtex.sqlite")}get zoteroCacheDirPath(){return(0,El.join)(this.current?.zoteroDataDir,"cache")}get dbConnParams(){return[{zotero:this.zoteroDbPath,bbtSearch:this.bbtSearchDbPath,bbtMain:this.bbtMainDbPath},{nativeBinding:this.nativeBinding}]}};de([me],ge.prototype,"templateDir",1),de([me],ge.prototype,"libId",1),de([me],ge.prototype,"simpleTemplates",1),de([me],ge.prototype,"zoteroDbPath",1),de([me],ge.prototype,"bbtSearchDbPath",1),de([me],ge.prototype,"bbtMainDbPath",1),de([me],ge.prototype,"zoteroCacheDirPath",1),de([me],ge.prototype,"dbConnParams",1);function HT(t){let e=Bg(t)(ge);return e.addDefaults(UT()),e}var qU=new Set(["notify"]),BU=new Set([...vT.map(t=>`zotero/${t}`)]),Tn=class extends fe{#e=new qf.Events;settings=this.use(ge);plugin=this.use(xe);server=null;get port(){return this.settings.current?.serverPort}get hostname(){return this.settings.current?.serverHostname}get enableServer(){return this.settings.current?.enableServer}onload(){this.register(He(lt(()=>{this.enableServer?this.initServer():this.closeServer()},()=>this.enableServer))),this.register(He(lt(()=>{this.reloadPort(),new qf.Notice("Server port is saved and applied.")},()=>(this.port,this.hostname),!0))),this.registerObsidianProtocolHandler()}onunload(){this.closeServer(),this.server=null}registerObsidianProtocolHandler(){let e=r=>{let{action:n,...o}=r;this.trigger(n,o)};for(let r of BU)this.plugin.registerObsidianProtocolHandler(r,e)}#t(){this.server??=(0,KT.createServer)((e,r)=>{this.requestListener(e,r)})}#n(){this.server?.listening||this.server?.listen(this.port,this.hostname,()=>this.listeningListener())}initServer(){this.#t(),this.#n()}closeServer(){this.server?.close()}reloadPort(){this.enableServer&&(this.closeServer(),this.#t(),this.#n())}requestListener(e,r){if(!e.url){W.error("Request without url"),r.statusCode=400,r.end();return}W.trace("server recieved req",e.url,e.rawHeaders);let{pathname:n,searchParams:o}=new URL(e.url,`http://${e.headers.host}`),i=n.substring(1),s=`bg:${n.substring(1)}`;if(qU.has(i)){let a=Object.fromEntries(o.entries());e.headers["content-type"]==="application/json"?new Promise((l,u)=>{let c="";e.on("data",f=>c+=f),e.on("error",f=>u(f)),e.on("end",()=>{try{l(JSON.parse(c))}catch(f){u(f)}})}).then(l=>{this.trigger(s,a,l),r.end()}):(this.trigger(s,a),r.end())}else r.statusCode=404,r.end()}listeningListener(){this.server&&W.info(`Server is listening at ${zU(this.server)}`)}on(e,r,n){return this.#e.on(e,r,n)}off(e,r){return this.#e.off(e,r)}offref(e){return this.#e.offref(e)}trigger(e,...r){return W.trace(`server trigger ${e}`,...r),this.#e.trigger(e,...r)}tryTrigger(e,r){return this.#e.tryTrigger(e,r)}};de([me],Tn.prototype,"port",1),de([me],Tn.prototype,"hostname",1),de([me],Tn.prototype,"enableServer",1);function zU(t){let e=t.address();return e?typeof e=="string"?e:`${e.address}:${e.port}`:"?"}var VT=Z(ks(),1),GT=require("obsidian");function ZT(t,e={}){return _l({...e,register:r=>t.metadataCache.on("initialized",r),unregister:r=>t.metadataCache.offref(r),escape:()=>t.metadataCache.initialized,timeout:e.timeout??null})}function Gy(t,e={}){return _l({...e,register:r=>t.vault.on("zotero:db-refresh",r),unregister:r=>t.vault.offref(r)})}function Ns(t,e={}){return _l({...e,unregister:r=>t.app.vault.offref(r),escape:()=>t.dbWorker.status===2,register:r=>{let n=t.dbWorker.status;if(n===0)return t.app.vault.on("zotero:db-ready",r);if(n===1)return t.app.vault.on("zotero:db-refresh",r);if(n===2)throw new Error("should not be called when db is ready");(0,VT.assertNever)(n)}})}var JT=t=>new Promise(e=>{t.workspace.onLayoutReady(e)}),_l=({register:t,unregister:e,escape:r,timeout:n=1e4,waitAfterEvent:o,debounce:i=1e3})=>{let s=null;return[new Promise((l,u)=>{if(r?.()){l();return}s=function(){e(p),u(new Il)};function c(){e(p),l()}async function f(){o!==void 0&&await sleep(o),c()}let p=t(i?(0,GT.debounce)(f,i,!0):f);n!==null&&sleep(n).then(()=>{e(p),r?.()?c():u(new Sl(n))})}),s]},Sl=class extends Error{constructor(r){super(`Timeout after ${r}ms`);this.timeout=r}},Il=class extends Error{constructor(){super("Manually cancelled")}};var WU=t=>{let e=new Blob([t],{type:"text/javascript"});return URL.createObjectURL(e)},YT=(t,e)=>{let r=WU(t),n=new Worker(r,e);return URL.revokeObjectURL(r),n};var Zy=class extends Error{},Ie=t=>{throw new Zy(t)},Jy=class extends Error{},ve=t=>{throw new Jy(t)};var go=(t,e)=>$e(t)===e,$e=t=>{let e=typeof t;return e==="object"?t===null?"null":"object":e==="function"?"object":e},Yy={bigint:"a bigint",boolean:"boolean",null:"null",number:"a number",object:"an object",string:"a string",symbol:"a symbol",undefined:"undefined"};var pr=(t,e)=>t in e,XT=t=>Object.entries(t),_e=t=>Object.keys(t),hi=t=>{let e=[];for(;t!==Object.prototype&&t!==null&&t!==void 0;){for(let r of Object.getOwnPropertyNames(t))e.includes(r)||e.push(r);for(let r of Object.getOwnPropertySymbols(t))e.includes(r)||e.push(r);t=Object.getPrototypeOf(t)}return e},Ds=(t,e)=>{let r=t?.[e];return r!=null};var QT=t=>Object.keys(t).length,Ol=t=>go(t,"object")?Object.keys(t).length!==0:!1,dde=Symbol("id");var tn=t=>Array.isArray(t)?t:[t];var Je=class extends Array{static fromString(e,r="/"){return e===r?new Je:new Je(...e.split(r))}toString(e="/"){return this.length?this.join(e):e}},eC=(t,e)=>{let r=t;for(let n of e){if(typeof r!="object"||r===null)return;r=r[n]}return r};var Xy=/^(?!^-0$)-?(?:0|[1-9]\d*)(?:\.\d*[1-9])?$/,HU=t=>Xy.test(t),KU=/^-?\d*\.?\d*$/,VU=t=>t.length!==0&&KU.test(t),Bf=/^(?:0|(?:-?[1-9]\d*))$/,Tl=t=>Bf.test(t),Cl=/^(?:0|(?:[1-9]\d*))$/,tC=/^-?\d+$/,GU=t=>tC.test(t),rC={number:"a number",bigint:"a bigint",integer:"an integer"},nC=(t,e)=>`'${t}' was parsed as ${rC[e]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,ZU=(t,e)=>e==="number"?HU(t):Tl(t),JU=(t,e)=>e==="number"?Number(t):Number.parseInt(t),YU=(t,e)=>e==="number"?VU(t):GU(t),Al=(t,e)=>oC(t,"number",e),zf=(t,e)=>oC(t,"integer",e),oC=(t,e,r)=>{let n=JU(t,e);if(!Number.isNaN(n)){if(ZU(t,e))return n;if(YU(t,e))return ve(nC(t,e))}return r?ve(r===!0?`Failed to parse ${rC[e]} from '${t}'`:r):void 0},Qy=t=>{if(t[t.length-1]!=="n")return;let e=t.slice(0,-1),r;try{r=BigInt(e)}catch{return}if(Bf.test(e))return r;if(tC.test(e))return ve(nC(t,"bigint"))};var Re=(t,e)=>{switch($e(t)){case"object":return JSON.stringify(eb(t,Uf,[]),null,e);case"symbol":return Uf.onSymbol(t);default:return tb(t)}},Uf={onCycle:()=>"(cycle)",onSymbol:t=>`(symbol${t.description&&` ${t.description}`})`,onFunction:t=>`(function${t.name&&` ${t.name}`})`},eb=(t,e,r)=>{switch($e(t)){case"object":if(typeof t=="function")return Uf.onFunction(t);if(r.includes(t))return"(cycle)";let n=[...r,t];if(Array.isArray(t))return t.map(i=>eb(i,e,n));let o={};for(let i in t)o[i]=eb(t[i],e,n);return o;case"symbol":return Uf.onSymbol(t);case"bigint":return`${t}n`;case"undefined":return"undefined";default:return t}},tb=t=>typeof t=="string"?`'${t}'`:typeof t=="bigint"?`${t}n`:`${t}`;function XU(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function QU(t,e){return e.get?e.get.call(t):e.value}function e8(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function sC(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function iC(t,e){var r=sC(t,e,"get");return QU(t,r)}function t8(t,e,r){XU(t,e),e.set(t,r)}function r8(t,e,r){var n=sC(t,e,"set");return e8(t,n,r),r}function Wf(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var dr=t=>(e,r,n)=>e===void 0?r===void 0?Ie(Vf):r:r===void 0?e:t(e,r,n),Vf="Unexpected operation two undefined operands",rb={domain:({l:t,r:e})=>`${t.join(", ")} and ${e.join(", ")}`,range:({l:t,r:e})=>`${Kf(t)} and ${Kf(e)}`,class:({l:t,r:e})=>`classes ${typeof t=="string"?t:t.name} and ${typeof e=="string"?e:e.name}`,tupleLength:({l:t,r:e})=>`tuples of length ${t} and ${e}`,value:({l:t,r:e})=>`literal values ${Re(t)} and ${Re(e)}`,leftAssignability:({l:t,r:e})=>`literal value ${Re(t.value)} and ${Re(e)}`,rightAssignability:({l:t,r:e})=>`literal value ${Re(e.value)} and ${Re(t)}`,union:({l:t,r:e})=>`branches ${Re(t)} and branches ${Re(e)}`},Kf=t=>"limit"in t?`the range of exactly ${t.limit}`:t.min?t.max?`the range bounded by ${t.min.comparator}${t.min.limit} and ${t.max.comparator}${t.max.limit}`:`${t.min.comparator}${t.min.limit}`:t.max?`${t.max.comparator}${t.max.limit}`:"the unbounded range",Hf=new WeakMap,yo=class{get disjoints(){return iC(this,Hf)}addDisjoint(e,r,n){return iC(this,Hf)[`${this.path}`]={kind:e,l:r,r:n},Gf}constructor(e,r){Wf(this,"type",void 0),Wf(this,"lastOperator",void 0),Wf(this,"path",void 0),Wf(this,"domain",void 0),t8(this,Hf,{writable:!0,value:void 0}),this.type=e,this.lastOperator=r,this.path=new Je,r8(this,Hf,{})}},Gf=Symbol("empty"),aC=()=>Gf,kr=t=>t===Gf,lC=Symbol("equal"),Ye=()=>lC,mr=t=>t===lC,Fs=(t,e)=>(r,n,o)=>{let i={},s=_e({...r,...n}),a=!0,l=!0;for(let u of s){let c=typeof t=="function"?t(u,r[u],n[u],o):t[u](r[u],n[u],o);if(mr(c))r[u]!==void 0&&(i[u]=r[u]);else if(kr(c))if(e.onEmpty==="omit")a=!1,l=!1;else return Gf;else c!==void 0&&(i[u]=c),a&&(a=c===r[u]),l&&(l=c===n[u])}return a?l?Ye():r:l?n:i};var cC=t=>{let e=_e(t);if(e.length===1){let n=e[0];return`${n==="/"?"":`At ${n}: `}Intersection of ${rb[t[n].kind](t[n])} results in an unsatisfiable type`}let r=` +`)}function Cie(t,e){return e=e??joe,!!e&&(typeof t=="number"||eie.test(t))&&t>-1&&t%1==0&&tIe});module.exports=Zg(Hae);a();a();function vS(t){var e=new WeakMap;return r=>e.has(r)?e.get(r):gz(e,r,t(r,e))}function gz(t,e,r){return t.set(e,r),r}a();function wS(t){return t&&typeof t=="object"?JSON.parse(JSON.stringify(t)):t}a();var _n=typeof queueMicrotask=="function"?queueMicrotask:(t=>e=>t.then(e))(Promise.resolve());function xS(t){let e=Promise.resolve(t);return(r,n)=>r||n?(typeof n>"u"&&(n=console.error),e=e.then(r,n)):e}a();function ES(){let t,e,r=new Promise((n,o)=>{t=n,e=o});return{resolve:t,reject:e,promise:r}}a();var xt;(t=>Object.assign(t,require("obsidian")))(xt||={});a();a();var Jg="use.me",Yg="use.factory",Es,nc,Xg=function(){return Object.defineProperties(t(),{this:{get(){if(Es)return Es;throw new TypeError("No current context")}},me:{value:Jg},factory:{value:Yg}});function t(o){let i=new Map;i.prev=o;let s=Object.assign(o?l=>{let f=i.get(l);if(!f){for(let h=i.prev;h;h=h.prev)if(f=h.get(l)){f=Object.assign(Object.assign({},f),{s:f.s||1});break}f=f||{s:2,v:r},i.set(l,f)}let u,d,m;for(;;)switch(f.s){case 0:return Es===s&&nc&&nc.push(l),f.v;case 1:if(u=f.d,!u||c(()=>u.k.every(h=>s(h)===u.c(h)))){f.s=0;break}f.v=u.f;case 2:f.s=4;try{e(i,l,0,c(d=f.v,l,m=[])),m.length&&(f.d={c:s,f:d,k:m});break}catch(h){f.s=3,f.v=h,f.d=null}case 3:throw f.v;case 4:throw new Error(`Factory ${String(f.v)} didn't resolve ${String(l)}`)}}:l=>Xg.this(l),{def(l,f){return e(i,l,2,f),s},set(l,f){return e(i,l,1,f),s},fork(l){let f=t(i);return l!=null?f(l):f}});return o?s.use=s:s;function c(l,f,u){let d=Es,m=nc;try{return Es=s,nc=u,l(f)}finally{Es=d,nc=m}}}function e(o,i,s,c){if(o.has(i)){let l=o.get(i);if(!l.s)throw new Error(`Already read: ${String(i)}`);l.s=s,l.v=c,l.d=null}else o.set(i,{s,v:c})}function r(o){if(typeof o[Jg]=="function")return o[Jg](o);if(n(o))return typeof o.prototype[Yg]=="function"?o.prototype[Yg]():new o;throw new ReferenceError(`No config for ${String(o)}`)}function n(o){return typeof o=="function"&&o.prototype!==void 0&&(Object.getPrototypeOf(o.prototype)!==Object.prototype||Object.getOwnPropertyNames(o.prototype).length>1||o.toString().startsWith("class"))}}();var yz,Ss=(t=>(t.service=function(e){return t(af).addChild(e),t.this},t.plugin=function(e){if(!Tn)yz=e.app,Tn=t.fork(),Tn.set(xt.Plugin,e),Tn.set(e.constructor,e),e.addChild(Tn.use(af));else if(e!==Tn.use(xt.Plugin))throw new TypeError("use.plugin() called on multiple plugins");return Tn},t.def(xt.Plugin,()=>{throw new Error("Plugin not created yet")}),t.def(xt.App,()=>t(xt.Plugin).app),t))(Xg),Tn;function Qg(t){if(t?.use)return t.use;if(Tn)return Tn;if(t instanceof xt.Plugin)return t.use=Ss.plugin(t);throw new Error("No context available: did you forget to `use.plugin()`?")}var de=class extends xt.Component{use=Ss.service(this)},af=class extends xt.Component{loaded;children=new Set([this]);onload(){this.loaded=!0}onunload(){this.loaded=!1,this.children.clear()}addChild(e){return this.children.has(e)||(this.children.add(e),this.loaded?_n(()=>super.addChild(e)):super.addChild(e)),e}};function bz(t,e){_n(()=>t.removeChild(e))}function SS(t,e){let r=new xt.Component;r.onload=()=>{bz(t,r),t=null,e()},t.addChild(r)}a();a();function lf(){throw new Error("Cycle detected")}function uf(){if(co>1){co--;return}let t,e=!1;for(;oc!==void 0;){let r=oc;for(oc=void 0,ey++;r!==void 0;){let n=r.o;if(r.o=void 0,r.f&=-3,!(8&r.f)&&OS(r))try{r.c()}catch(o){e||(t=o,e=!0)}r=n}}if(ey=0,co--,e)throw t}function IS(t){if(co>0)return t();co++;try{return t()}finally{uf()}}var Me,oc;var co=0,ey=0,cf=0;function _S(t){if(Me===void 0)return;let e=t.n;if(e===void 0||e.t!==Me)return e={i:0,S:t,p:Me.s,n:void 0,t:Me,e:void 0,x:void 0,r:e},Me.s!==void 0&&(Me.s.n=e),Me.s=e,t.n=e,32&Me.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=Me.s,e.n=void 0,Me.s.n=e,Me.s=e),e}function Rt(t){this.v=t,this.i=0,this.n=void 0,this.t=void 0}Rt.prototype.h=function(){return!0};Rt.prototype.S=function(t){this.t!==t&&t.e===void 0&&(t.x=this.t,this.t!==void 0&&(this.t.e=t),this.t=t)};Rt.prototype.U=function(t){if(this.t!==void 0){let e=t.e,r=t.x;e!==void 0&&(e.x=r,t.e=void 0),r!==void 0&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r)}};Rt.prototype.subscribe=function(t){let e=this;return ry(function(){let r=e.value,n=32&this.f;this.f&=-33;try{t(r)}finally{this.f|=n}})};Rt.prototype.valueOf=function(){return this.value};Rt.prototype.toString=function(){return this.value+""};Rt.prototype.toJSON=function(){return this.value};Rt.prototype.peek=function(){return this.v};Object.defineProperty(Rt.prototype,"value",{get(){let t=_S(this);return t!==void 0&&(t.i=this.i),this.v},set(t){if(Me instanceof lo&&function(){throw new Error("Computed cannot have side-effects")}(),t!==this.v){ey>100&&lf(),this.v=t,this.i++,cf++,co++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{uf()}}}});function TS(t){return new Rt(t)}function OS(t){for(let e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function CS(t){for(let e=t.s;e!==void 0;e=e.n){let r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function kS(t){let e,r=t.s;for(;r!==void 0;){let n=r.p;r.i===-1?(r.S.U(r),n!==void 0&&(n.n=r.n),r.n!==void 0&&(r.n.p=n)):e=r,r.S.n=r.r,r.r!==void 0&&(r.r=void 0),r=n}t.s=e}function lo(t){Rt.call(this,void 0),this.x=t,this.s=void 0,this.g=cf-1,this.f=4}(lo.prototype=new Rt).h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===cf))return!0;if(this.g=cf,this.f|=1,this.i>0&&!OS(this))return this.f&=-2,!0;let t=Me;try{CS(this),Me=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return Me=t,kS(this),this.f&=-2,!0};lo.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Rt.prototype.S.call(this,t)};lo.prototype.U=function(t){if(this.t!==void 0&&(Rt.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}};lo.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;t!==void 0;t=t.x)t.t.N()}};lo.prototype.peek=function(){if(this.h()||lf(),16&this.f)throw this.v;return this.v};Object.defineProperty(lo.prototype,"value",{get(){1&this.f&&lf();let t=_S(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function AS(t){return new lo(t)}function RS(t){let e=t.u;if(t.u=void 0,typeof e=="function"){co++;let r=Me;Me=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,ty(t),n}finally{Me=r,uf()}}}function ty(t){for(let e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,RS(t)}function vz(t){if(Me!==this)throw new Error("Out-of-order effect");kS(this),Me=t,this.f&=-2,8&this.f&&ty(this),uf()}function ic(t){this.x=t,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}ic.prototype.c=function(){let t=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.u=e)}finally{t()}};ic.prototype.S=function(){1&this.f&&lf(),this.f|=1,this.f&=-9,RS(this),CS(this),co++;let t=Me;return Me=this,vz.bind(this,t)};ic.prototype.N=function(){2&this.f||(this.f|=2,this.o=oc,oc=this)};ic.prototype.d=function(){this.f|=8,1&this.f||ty(this)};function ry(t){let e=new ic(t);try{e.c()}catch(r){throw e.d(),r}return e.d.bind(e)}function ny(t){let e=AS(t);return()=>e.value}function NS(t){let e=TS(t);function r(){return e.value,t}return r.set=function(n){t!==n&&(ac.size||_n(wz),ac.set(e,t=n))},r}var ac=new Map;function wz(){ac.size&&IS(()=>{for(let[t,e]of ac.entries())ac.delete(t),t.value=e})}var xz=vS(function(t){return{}});function ge(t,e,r){let n=r.get;return{...r,get(){return(xz(this)[e]??=ny(n.bind(this)))()}}}var sc;function Ge(t){let e=ry(function(){let r=sc,n=sc=[];try{let o=t.call(this);if(o&&n.push(o),n.length)return n.length===1?n.pop():function(){for(;n.length;)try{n.shift()()}catch(i){Promise.reject(i)}}}finally{sc=r}});return sc&&sc.push(e),e}a();function cr(t,e){let r=Object.keys(e).map(n=>Ez(t,n,e[n]));return r.length===1?r[0]:function(){r.forEach(n=>n())}}function Ez(t,e,r){let n=t[e],o=t.hasOwnProperty(e),i=r(n);return n&&Object.setPrototypeOf(i,n),Object.setPrototypeOf(s,i),t[e]=s,c;function s(...l){return i===n&&t[e]===s&&c(),i.apply(this,l)}function c(){t[e]===s&&(o?t[e]=n:delete t[e]),i!==n&&(i=n,Object.setPrototypeOf(s,n||Function))}}a();var ff=t=>{if(typeof t!="object"||t===null)return!1;let e=Object.getPrototypeOf(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Sz=new Set(["__proto__","prototype","constructor"]),oy=(t,e)=>{if(!ff(e))return t;t||(t={});for(let[r,n]of Object.entries(e)){if(Sz.has(r))continue;let o=t[r];if(ff(o)&&ff(n))t[r]=oy(o,n);else{if(n===void 0)continue;ff(n)?t[r]=oy({},n):Array.isArray(n)?t[r]=[...n]:t[r]=n}}return t};function pf(t={},e={}){return oy({...e},{...t})}a();var df=class extends de{plugin=this.use(xt.Plugin);queue=xS();data={};version=NS(0);cloned=ny(()=>this.version()?wS(this.data):null);get current(){return this.cloned()}addDefaults(e){this.data=pf(this.data,e)}constructor(){super(),this.queue(async()=>{await new Promise(e=>SS(this.plugin,e)),this.data=pf(await this.plugin.loadData()??{},this.current),this.version.set(this.version()+1)},console.error)}once(e,r){let n=this.each(o=>{n(),e.call(r,o)});return n}each(e,r){return Ge(()=>{this.current&&_n(e.bind(r,this.current))})}onChange(e,r){return this.each(e,r)}update(e){return this.queue(async()=>{let r=this.data,n=JSON.stringify(r);try{var o=JSON.parse(n);o=e(o)??o;let i=JSON.stringify(o);n!==i&&(this.data=o,this.version.set(this.version()+1),await this.plugin.saveData(JSON.parse(i)).catch(console.error))}catch(i){console.error(i)}return this.data})}};a();function DS(t,e,r,n){let{resolve:o,promise:i}=ES(),s=new class extends xt.FuzzySuggestModal{getItemText(c){return e?.(c)??""+c}getItems(){return t}onChooseItem(c,l){o({item:c,event:l})}onClose(){super.onClose(),_n(()=>o({item:null,event:null}))}}(app);return r&&s.setPlaceholder(r),n?.(s),s.open(),i}var cz=require("obsidian");a();a();a();var PS=t=>`obsidian-zotero:${t}`;a();var lr=({key:t,groupID:e,parentItem:r},n=!1)=>{let o=[t];return!n&&r&&o.push(`a${r}`),typeof e=="number"&&o.push(`g${e}`),o.join("")},FS=(t,e,r=!0)=>(n,...o)=>{let i="";for(let s=0;s0&&(i+=t(o[s-1])),i+=(r?n.raw:n)[s];return e(i)},ay=(t=!0,e)=>FS(r=>r,r=>new RegExp(t?"^"+r+"$":r,e),!0),iy=String.raw`[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}`,sy=String.raw`\d+`,MS=t=>{let e={annotKey:iy,parentKey:iy,groupID:sy,page:sy};if(t)for(let r in e)e[r]=`(${e[r]})`;return FS(r=>e[r],r=>r)`${"annotKey"}a${"parentKey"}(?:g${"groupID"})?(?:p${"page"})?`},$S=ay()`${iy}(?:g${sy})?`,LS=ay()`${MS(!0)}`,jS=ay()`(?:${MS(!1)}n?)+`,Is=(t,e)=>{if(t===null)return null;let r;return typeof t=="number"?r=t:r=parseInt(t,10),Number.isInteger(r)?e?r+1:r:null};a();a();var qS=(t,e,{getLogger:r,configure:n})=>{let o=PS(t);return n({appenders:{out:{type:"console"}},categories:{default:{appenders:["out"],level:e},[o]:{appenders:["out"],level:e}}}),r(o)},BS={ALL:"ALL",TRACE:"TRACE",DEBUG:"DEBUG",INFO:"INFO",WARN:"WARN",ERROR:"ERROR",FATAL:"FATAL",MARK:"MARK",OFF:"OFF"};a();var uo=()=>(...t)=>t;a();a();var zS=t=>`better-sqlite3-${t}.node`;var Np=Y(cO(),1);a();var Vb=Y(Ms(),1),_o=require("obsidian"),Hk=Y(pO(),1);a();var iC=require("http");a();a();var XU=Y(Ms(),1),QU=Y(Xy(),1),Qy=Y(Xy(),1);var NO=uo()("open","export","update");var RO=(t,e)=>{let r=new RegExp(`^${e}\\[(\\d+)\\]$`);return Object.entries(t).filter(([n])=>r.test(n)).sort(([n],[o])=>Number(n.match(r)[1])-Number(o.match(r)[1])).map(([,n])=>JSON.parse(n))},Kf=t=>{if(t.type==="item")return{version:t.version,type:t.type,items:RO(t,"items")};if(t.type==="annotation")return{version:t.version,type:t.type,annots:RO(t,"annots"),parent:JSON.parse(t.parent)};throw new TypeError("Unrecognized query type: "+t.type)};a();var eb=/^/;var Zf=require("obsidian");a();var Ac=require("path");a();var PO=require("path/posix");var tb=require("obsidian"),Gf="v12.8.0",Vf=p,FO=()=>Object.keys(Vf).length===0,DO=tb.Platform.isDesktopApp?require("@electron/remote").app.getPath("userData"):null,{arch:Ipe,platform:_pe,versions:{modules:Tpe,electron:Ope}}=process,MO=({modules:t})=>{if(FO()||t in Vf)return 0;let e=Object.keys(Vf).map(n=>parseInt(n,10)).sort((n,o)=>n-o);return parseInt(t,10)>e[e.length-1]?1:-1},$O=({modules:t,platform:e,arch:r})=>FO()?!0:Vf[t]?.[e]?.includes(r)??!1,LO=()=>tb.Platform.isDesktopApp?{arch:process.arch,platform:process.platform,modules:process.versions.modules,electron:process.versions.electron}:null,$s=()=>DO?(0,PO.join)(DO,zS(Gf)):null;a();a();var jO={citationEditorSuggester:!0,showCitekeyInSuggester:!1};a();var qO={literatureNoteFolder:"LiteratureNotes"};a();var BO={enableServer:!1,serverPort:9091,serverHostname:"127.0.0.1"};a();a();var rb=require("path/posix");var zO=`[!note] Page <%= it.pageLabel %>\r +\r +<%= it.imgEmbed %><%= it.text %>\r +<% if (it.comment) { %>\r +---\r +<%= it.comment %>\r +<% } %>`;var UO=`<% for (const annotation of it) { %>\r +<%~ include("annotation", annotation) %>\r +<% } %>`;var WO='[<%= it.map(lit => `@${lit.citekey}`).join("; ") %>]';var HO='<%= it.map(lit => `@${lit.citekey}`).join("; ") %>';var KO=`<%= it.content %>`;var VO=`title: "<%= it.title %>"\r +citekey: "<%= it.citekey %>"`;var GO=`# <%= it.title %>\r +\r +[Zotero](<%= it.backlink %>) <%= it.fileLink %>\r +<%~ include("annots", it.annotations) %>`;var ht={Ejectable:{note:GO,field:VO,annots:UO,annotation:zO,cite:WO,cite2:HO,colored:KO},Embeded:{filename:"<%= it.citekey ?? it.DOI ?? it.title ?? it.key %>.md"}},nn={Ejectable:Object.keys(ht.Ejectable),Embeded:Object.keys(ht.Embeded),All:Object.keys(ht.Ejectable).concat(Object.keys(ht.Embeded))};function nb(t){return Object.hasOwn(ht.Embeded,t)?`zt-${t}.eta.md`:Object.hasOwn(ht.Ejectable,t)?t==="annotation"?"zt-annot.eta.md":`zt-${t}.eta.md`:null}function bi(t,e){return(0,rb.join)(e,nb(t))}function St(t,e){let r=nn.Embeded.find(o=>(0,rb.join)(e,`zt-${o}.eta.md`)===t);if(r)return{type:"embeded",name:r};let n=nn.Ejectable.find(o=>bi(o,e)===t);return n?{type:"ejectable",name:n}:null}var ZO={template:{folder:"ZtTemplates",templates:ht.Embeded},updateAnnotBlock:!1,updateOverwrite:!1,autoPairEta:!1,autoTrim:[!1,!1]};a();var JO={autoRefresh:!0};a();var YO=require("os"),XO=require("path"),QO=()=>({zoteroDataDir:(0,XO.join)((0,YO.homedir)(),"Zotero"),citationLibrary:1});a();var eC=require("obsidian"),tC={imgExcerptImport:eC.Platform.isWin?"copy":"symlink",imgExcerptPath:"ZtImgExcerpt"};var rC=()=>({...nC,...jO,...qO,...BO,...ZO,...JO,...QO(),...tC});function ft(t,e,r=!1){let n=0;return(...o)=>{if(e(),n++>(r?1:0))return t(...o)}}var be=class extends df{#e=this.use(Ie);#t;get nativeBinding(){if(this.#t)return this.#t;let e=$s();if(e)return this.#t=e,this.#t;throw new Error("Failed to get native binding path")}get templateDir(){return this.current?.template?.folder}get libId(){return this.current?.citationLibrary}get simpleTemplates(){return this.current?.template?.templates}get zoteroDbPath(){return(0,Ac.join)(this.current?.zoteroDataDir,"zotero.sqlite")}get bbtSearchDbPath(){return(0,Ac.join)(this.current?.zoteroDataDir,"better-bibtex-search.sqlite")}get bbtMainDbPath(){return(0,Ac.join)(this.current?.zoteroDataDir,"better-bibtex.sqlite")}get zoteroCacheDirPath(){return(0,Ac.join)(this.current?.zoteroDataDir,"cache")}get dbConnParams(){return[{zotero:this.zoteroDbPath,bbtSearch:this.bbtSearchDbPath,bbtMain:this.bbtMainDbPath},{nativeBinding:this.nativeBinding}]}};he([ge],be.prototype,"templateDir",1),he([ge],be.prototype,"libId",1),he([ge],be.prototype,"simpleTemplates",1),he([ge],be.prototype,"zoteroDbPath",1),he([ge],be.prototype,"bbtSearchDbPath",1),he([ge],be.prototype,"bbtMainDbPath",1),he([ge],be.prototype,"zoteroCacheDirPath",1),he([ge],be.prototype,"dbConnParams",1);function oC(t){let e=Qg(t)(be);return e.addDefaults(rC()),e}var a8=new Set(["notify"]),c8=new Set([...NO.map(t=>`zotero/${t}`)]),An=class extends de{#e=new Zf.Events;settings=this.use(be);plugin=this.use(Ie);server=null;get port(){return this.settings.current?.serverPort}get hostname(){return this.settings.current?.serverHostname}get enableServer(){return this.settings.current?.enableServer}onload(){this.register(Ge(ft(()=>{this.enableServer?this.initServer():this.closeServer()},()=>this.enableServer))),this.register(Ge(ft(()=>{this.reloadPort(),new Zf.Notice("Server port is saved and applied.")},()=>(this.port,this.hostname),!0))),this.registerObsidianProtocolHandler()}onunload(){this.closeServer(),this.server=null}registerObsidianProtocolHandler(){let e=r=>{let{action:n,...o}=r;this.trigger(n,o)};for(let r of c8)this.plugin.registerObsidianProtocolHandler(r,e)}#t(){this.server??=(0,iC.createServer)((e,r)=>{this.requestListener(e,r)})}#n(){this.server?.listening||this.server?.listen(this.port,this.hostname,()=>this.listeningListener())}initServer(){this.#t(),this.#n()}closeServer(){this.server?.close()}reloadPort(){this.enableServer&&(this.closeServer(),this.#t(),this.#n())}requestListener(e,r){if(!e.url){H.error("Request without url"),r.statusCode=400,r.end();return}H.trace("server recieved req",e.url,e.rawHeaders);let{pathname:n,searchParams:o}=new URL(e.url,`http://${e.headers.host}`),i=n.substring(1),s=`bg:${n.substring(1)}`;if(a8.has(i)){let c=Object.fromEntries(o.entries());e.headers["content-type"]==="application/json"?new Promise((l,f)=>{let u="";e.on("data",d=>u+=d),e.on("error",d=>f(d)),e.on("end",()=>{try{l(JSON.parse(u))}catch(d){f(d)}})}).then(l=>{this.trigger(s,c,l),r.end()}):(this.trigger(s,c),r.end())}else r.statusCode=404,r.end()}listeningListener(){this.server&&H.info(`Server is listening at ${l8(this.server)}`)}on(e,r,n){return this.#e.on(e,r,n)}off(e,r){return this.#e.off(e,r)}offref(e){return this.#e.offref(e)}trigger(e,...r){return H.trace(`server trigger ${e}`,...r),this.#e.trigger(e,...r)}tryTrigger(e,r){return this.#e.tryTrigger(e,r)}};he([ge],An.prototype,"port",1),he([ge],An.prototype,"hostname",1),he([ge],An.prototype,"enableServer",1);function l8(t){let e=t.address();return e?typeof e=="string"?e:`${e.address}:${e.port}`:"?"}a();var sC=Y(Ms(),1),aC=require("obsidian");function cC(t,e={}){return Dc({...e,register:r=>t.metadataCache.on("initialized",r),unregister:r=>t.metadataCache.offref(r),escape:()=>t.metadataCache.initialized,timeout:e.timeout??null})}function ob(t,e={}){return Dc({...e,register:r=>t.vault.on("zotero:db-refresh",r),unregister:r=>t.vault.offref(r)})}function Ls(t,e={}){return Dc({...e,unregister:r=>t.app.vault.offref(r),escape:()=>t.dbWorker.status===2,register:r=>{let n=t.dbWorker.status;if(n===0)return t.app.vault.on("zotero:db-ready",r);if(n===1)return t.app.vault.on("zotero:db-refresh",r);if(n===2)throw new Error("should not be called when db is ready");(0,sC.assertNever)(n)}})}var lC=t=>new Promise(e=>{t.workspace.onLayoutReady(e)}),Dc=({register:t,unregister:e,escape:r,timeout:n=1e4,waitAfterEvent:o,debounce:i=1e3})=>{let s=null;return[new Promise((l,f)=>{if(r?.()){l();return}s=function(){e(m),f(new Nc)};function u(){e(m),l()}async function d(){o!==void 0&&await sleep(o),u()}let m=t(i?(0,aC.debounce)(d,i,!0):d);n!==null&&sleep(n).then(()=>{e(m),r?.()?u():f(new Rc(n))})}),s]},Rc=class extends Error{constructor(r){super(`Timeout after ${r}ms`);this.timeout=r}},Nc=class extends Error{constructor(){super("Manually cancelled")}};a();a();var f8=t=>{let e=new Blob([t],{type:"text/javascript"});return URL.createObjectURL(e)},uC=(t,e)=>{let r=f8(t),n=new Worker(r,e);return URL.revokeObjectURL(r),n};a();a();a();a();a();a();a();a();a();a();var ib=class extends Error{},Oe=t=>{throw new ib(t)},sb=class extends Error{},Ee=t=>{throw new sb(t)};a();a();var vo=(t,e)=>qe(t)===e,qe=t=>{let e=typeof t;return e==="object"?t===null?"null":"object":e==="function"?"object":e},ab={bigint:"a bigint",boolean:"boolean",null:"null",number:"a number",object:"an object",string:"a string",symbol:"a symbol",undefined:"undefined"};var gr=(t,e)=>t in e,fC=t=>Object.entries(t),Ce=t=>Object.keys(t),vi=t=>{let e=[];for(;t!==Object.prototype&&t!==null&&t!==void 0;){for(let r of Object.getOwnPropertyNames(t))e.includes(r)||e.push(r);for(let r of Object.getOwnPropertySymbols(t))e.includes(r)||e.push(r);t=Object.getPrototypeOf(t)}return e},js=(t,e)=>{let r=t?.[e];return r!=null};var pC=t=>Object.keys(t).length,Pc=t=>vo(t,"object")?Object.keys(t).length!==0:!1,zde=Symbol("id");var on=t=>Array.isArray(t)?t:[t];a();var Qe=class extends Array{static fromString(e,r="/"){return e===r?new Qe:new Qe(...e.split(r))}toString(e="/"){return this.length?this.join(e):e}},dC=(t,e)=>{let r=t;for(let n of e){if(typeof r!="object"||r===null)return;r=r[n]}return r};a();a();var cb=/^(?!^-0$)-?(?:0|[1-9]\d*)(?:\.\d*[1-9])?$/,p8=t=>cb.test(t),d8=/^-?\d*\.?\d*$/,m8=t=>t.length!==0&&d8.test(t),Jf=/^(?:0|(?:-?[1-9]\d*))$/,Fc=t=>Jf.test(t),Mc=/^(?:0|(?:[1-9]\d*))$/,mC=/^-?\d+$/,h8=t=>mC.test(t),hC={number:"a number",bigint:"a bigint",integer:"an integer"},gC=(t,e)=>`'${t}' was parsed as ${hC[e]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,g8=(t,e)=>e==="number"?p8(t):Fc(t),y8=(t,e)=>e==="number"?Number(t):Number.parseInt(t),b8=(t,e)=>e==="number"?m8(t):h8(t),$c=(t,e)=>yC(t,"number",e),Yf=(t,e)=>yC(t,"integer",e),yC=(t,e,r)=>{let n=y8(t,e);if(!Number.isNaN(n)){if(g8(t,e))return n;if(b8(t,e))return Ee(gC(t,e))}return r?Ee(r===!0?`Failed to parse ${hC[e]} from '${t}'`:r):void 0},lb=t=>{if(t[t.length-1]!=="n")return;let e=t.slice(0,-1),r;try{r=BigInt(e)}catch{return}if(Jf.test(e))return r;if(mC.test(e))return Ee(gC(t,"bigint"))};var Pe=(t,e)=>{switch(qe(t)){case"object":return JSON.stringify(ub(t,Xf,[]),null,e);case"symbol":return Xf.onSymbol(t);default:return fb(t)}},Xf={onCycle:()=>"(cycle)",onSymbol:t=>`(symbol${t.description&&` ${t.description}`})`,onFunction:t=>`(function${t.name&&` ${t.name}`})`},ub=(t,e,r)=>{switch(qe(t)){case"object":if(typeof t=="function")return Xf.onFunction(t);if(r.includes(t))return"(cycle)";let n=[...r,t];if(Array.isArray(t))return t.map(i=>ub(i,e,n));let o={};for(let i in t)o[i]=ub(t[i],e,n);return o;case"symbol":return Xf.onSymbol(t);case"bigint":return`${t}n`;case"undefined":return"undefined";default:return t}},fb=t=>typeof t=="string"?`'${t}'`:typeof t=="bigint"?`${t}n`:`${t}`;function v8(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function w8(t,e){return e.get?e.get.call(t):e.value}function x8(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function vC(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function bC(t,e){var r=vC(t,e,"get");return w8(t,r)}function E8(t,e,r){v8(t,e),e.set(t,r)}function S8(t,e,r){var n=vC(t,e,"set");return x8(t,n,r),r}function Qf(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var yr=t=>(e,r,n)=>e===void 0?r===void 0?Oe(rp):r:r===void 0?e:t(e,r,n),rp="Unexpected operation two undefined operands",pb={domain:({l:t,r:e})=>`${t.join(", ")} and ${e.join(", ")}`,range:({l:t,r:e})=>`${tp(t)} and ${tp(e)}`,class:({l:t,r:e})=>`classes ${typeof t=="string"?t:t.name} and ${typeof e=="string"?e:e.name}`,tupleLength:({l:t,r:e})=>`tuples of length ${t} and ${e}`,value:({l:t,r:e})=>`literal values ${Pe(t)} and ${Pe(e)}`,leftAssignability:({l:t,r:e})=>`literal value ${Pe(t.value)} and ${Pe(e)}`,rightAssignability:({l:t,r:e})=>`literal value ${Pe(e.value)} and ${Pe(t)}`,union:({l:t,r:e})=>`branches ${Pe(t)} and branches ${Pe(e)}`},tp=t=>"limit"in t?`the range of exactly ${t.limit}`:t.min?t.max?`the range bounded by ${t.min.comparator}${t.min.limit} and ${t.max.comparator}${t.max.limit}`:`${t.min.comparator}${t.min.limit}`:t.max?`${t.max.comparator}${t.max.limit}`:"the unbounded range",ep=new WeakMap,wo=class{get disjoints(){return bC(this,ep)}addDisjoint(e,r,n){return bC(this,ep)[`${this.path}`]={kind:e,l:r,r:n},np}constructor(e,r){Qf(this,"type",void 0),Qf(this,"lastOperator",void 0),Qf(this,"path",void 0),Qf(this,"domain",void 0),E8(this,ep,{writable:!0,value:void 0}),this.type=e,this.lastOperator=r,this.path=new Qe,S8(this,ep,{})}},np=Symbol("empty"),wC=()=>np,Pr=t=>t===np,xC=Symbol("equal"),et=()=>xC,br=t=>t===xC,qs=(t,e)=>(r,n,o)=>{let i={},s=Ce({...r,...n}),c=!0,l=!0;for(let f of s){let u=typeof t=="function"?t(f,r[f],n[f],o):t[f](r[f],n[f],o);if(br(u))r[f]!==void 0&&(i[f]=r[f]);else if(Pr(u))if(e.onEmpty==="omit")c=!1,l=!1;else return np;else u!==void 0&&(i[f]=u),c&&(c=u===r[f]),l&&(l=u===n[f])}return c?l?et():r:l?n:i};var EC=t=>{let e=Ce(t);if(e.length===1){let n=e[0];return`${n==="/"?"":`At ${n}: `}Intersection of ${pb[t[n].kind](t[n])} results in an unsatisfiable type`}let r=` "Intersection results in unsatisfiable types at the following paths: -`;for(let n in t)r+=` ${n}: ${rb[t[n].kind](t[n])} -`;return r},Zf=(t,e,r)=>`${t.length?`At ${t}: `:""}${e} ${r?`${r} `:""}results in an unsatisfiable type`;var kl={Array,Date,Error,Function,Map,RegExp,Set,Object,String,Number,Boolean,WeakMap,WeakSet,Promise},Ps=(t,e)=>{if($e(t)!=="object")return;let r=e??kl,n=Object.getPrototypeOf(t);for(;n?.constructor&&(!r[n.constructor.name]||!(t instanceof r[n.constructor.name]));)n=Object.getPrototypeOf(n);return n?.constructor?.name};var bo=t=>Array.isArray(t),nb={Object:"an object",Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},Jf=t=>{let e=Object(t).name;return e&&pr(e,kl)&&kl[e]===t?e:void 0};var uC=dr((t,e,r)=>t===e?Ye():t instanceof e?t:e instanceof t?e:r.addDisjoint("class",t,e)),fC=(t,e)=>typeof t=="string"?Ps(e.data)===t||!e.problems.add("class",t):e.data instanceof t||!e.problems.add("class",t);var Yf=(t,e)=>{if(Array.isArray(t)){if(Array.isArray(e)){let r=n8(t,e);return r.length===t.length?r.length===e.length?Ye():t:r.length===e.length?e:r}return t.includes(e)?t:[...t,e]}return Array.isArray(e)?e.includes(t)?e:[...e,t]:t===e?Ye():[t,e]},n8=(t,e)=>{let r=[...t];for(let n of e)t.includes(n)||r.push(n);return r};var pC=dr((t,e)=>t===e?Ye():Math.abs(t*e/o8(t,e))),o8=(t,e)=>{let r,n=t,o=e;for(;o!==0;)r=o,o=n%o,n=r;return n},dC=(t,e)=>e.data%t===0||!e.problems.add("divisor",t);var Rl=t=>t[0]==="?",Xf=t=>t[0]==="!",nn={index:"[index]"},vo=t=>Rl(t)||Xf(t)?t[1]:t,i8=t=>{if(typeof t.length=="object"&&Xf(t.length)&&typeof t.length[1]!="string"&&ep(t.length[1],"number"))return t.length[1].number.value},mC=dr((t,e,r)=>{let n=s8(t,e,r);if(typeof n=="symbol")return n;let o=i8(n);if(o===void 0||!(nn.index in n))return n;let{[nn.index]:i,...s}=n,a=vo(i);for(let l=0;l{if(e===void 0)return r===void 0?Ye():r;if(r===void 0)return e;n.path.push(t);let o=Qf(vo(e),vo(r),n);n.path.pop();let i=Rl(e)&&Rl(r);return kr(o)&&i?{}:o},{onEmpty:"bubble"}),hC=(t,e,r)=>{let n=r.type.config?.keys??r.type.scope.config.keys;return n==="loose"?a8(t,e,r):l8(n,t,e,r)},a8=(t,e,r)=>{for(let n in e){let o=e[n];r.path.push(n),n===nn.index?t.push(["indexProp",rn(vo(o),r)]):Rl(o)?t.push(["optionalProp",[n,rn(o[1],r)]]):Xf(o)?t.push(["prerequisiteProp",[n,rn(o[1],r)]]):t.push(["requiredProp",[n,rn(o,r)]]),r.path.pop()}},l8=(t,e,r,n)=>{let o={required:{},optional:{}};for(let i in r){let s=r[i];n.path.push(i),i===nn.index?o.index=rn(vo(s),n):Rl(s)?o.optional[i]=rn(s[1],n):Xf(s)?e.push(["prerequisiteProp",[i,rn(s[1],n)]]):o.required[i]=rn(s,n),n.path.pop()}e.push([`${t}Props`,o])};function c8(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var ob=t=>typeof t=="string"||Array.isArray(t)?t.length:typeof t=="number"?t:0,u8=t=>typeof t=="string"?"characters":Array.isArray(t)?"items long":"",tp=class{toString(){return Re(this.value)}get domain(){return $e(this.value)}get size(){return ob(this.value)}get units(){return u8(this.value)}get className(){return Object(this.value).constructor.name}constructor(e){c8(this,"value",void 0),this.value=e}};var rp={">":!0,">=":!0},ib={"<":!0,"<=":!0},Nl=t=>"comparator"in t,yC=dr((t,e,r)=>{if(Nl(t))return Nl(e)?t.limit===e.limit?Ye():r.addDisjoint("range",t,e):gC(e,t.limit)?t:r.addDisjoint("range",t,e);if(Nl(e))return gC(t,e.limit)?e:r.addDisjoint("range",t,e);let n=Ms("min",t.min,e.min),o=Ms("max",t.max,e.max);return n==="l"?o==="r"?Ms("min",t.min,e.max)==="l"?r.addDisjoint("range",t,e):{min:t.min,max:e.max}:t:n==="r"?o==="l"?Ms("max",t.max,e.min)==="l"?r.addDisjoint("range",t,e):{min:e.min,max:t.max}:e:o==="l"?t:o==="r"?e:Ye()}),gC=(t,e)=>Nl(t)?e===t.limit:f8(t.min,e)&&p8(t.max,e),f8=(t,e)=>!t||e>t.limit||e===t.limit&&!Dl(t.comparator),p8=(t,e)=>!t||e{let n=r.lastDomain==="string"?"characters":r.lastDomain==="object"?"items long":void 0;if(Nl(e))return t.push(["bound",n?{...e,units:n}:e]);e.min&&t.push(["bound",n?{...e.min,units:n}:e.min]),e.max&&t.push(["bound",n?{...e.max,units:n}:e.max])},vC=(t,e)=>d8[t.comparator](ob(e.data),t.limit)||!e.problems.add("bound",t),d8={"<":(t,e)=>t":(t,e)=>t>e,"<=":(t,e)=>t<=e,">=":(t,e)=>t>=e,"==":(t,e)=>t===e},Ms=(t,e,r)=>e?r?e.limit===r.limit?Dl(e.comparator)?Dl(r.comparator)?"=":"l":Dl(r.comparator)?"r":"=":t==="min"?e.limit>r.limit?"l":"r":e.limitt.length===1;var sb={},ab=t=>(sb[t]||(sb[t]=new RegExp(t)),sb[t]),wC=(t,e)=>ab(t).test(e.data)||!e.problems.add("regex",`/${t}/`),xC=dr(Yf);var SC=(t,e,r)=>"value"in t?"value"in e?t.value===e.value?Ye():r.addDisjoint("value",t.value,e.value):EC(t.value,e,r)?t:r.addDisjoint("leftAssignability",t,e):"value"in e?EC(e.value,t,r)?e:r.addDisjoint("rightAssignability",t,e):h8(t,e,r),m8=dr(Yf),h8=Fs({divisor:pC,regex:xC,props:mC,class:uC,range:yC,narrow:m8},{onEmpty:"bubble"}),lb=(t,e)=>{let r=[],n;for(n in t)g8[n](r,t[n],e);return r.sort((o,i)=>Fl[o[0]]-Fl[i[0]])},g8={regex:(t,e)=>{for(let r of tn(e))t.push(["regex",r])},divisor:(t,e)=>{t.push(["divisor",e])},range:bC,class:(t,e)=>{t.push(["class",e])},props:hC,narrow:(t,e)=>{for(let r of tn(e))t.push(["narrow",r])},value:(t,e)=>{t.push(["value",e])}},Fl={config:-1,domain:0,value:0,domains:0,branches:0,switch:0,alias:0,class:0,regex:1,divisor:1,bound:1,prerequisiteProp:2,distilledProps:3,strictProps:3,requiredProp:3,optionalProp:3,indexProp:3,narrow:4,morph:5},EC=(t,e,r)=>!r.type.scope.type(["node",{[r.domain]:e}])(t).problems;var cb=t=>t?.lBranches!==void 0,_C=(t,e,r)=>{let n={lBranches:t,rBranches:e,lExtendsR:[],rExtendsL:[],equalities:[],distinctIntersections:[]},o=e.map(i=>({condition:i,distinct:[]}));return t.forEach((i,s)=>{let a=!1,l=o.map((u,c)=>{if(a||!u.distinct)return null;let f=u.condition,p=Ml(i,f,r);return kr(p)?null:p===i?(n.lExtendsR.push(s),a=!0,null):p===f?(n.rExtendsL.push(c),u.distinct=null,null):mr(p)?(n.equalities.push([s,c]),a=!0,u.distinct=null,null):go(p,"object")?p:Ie(`Unexpected predicate intersection result of type '${$e(p)}'`)});if(!a)for(let u=0;ui.distinct??[]),n},ub=t=>"rules"in t,Pl=(t,e)=>{if(ub(t)){let r=lb(t.rules,e);if(t.morph)if(typeof t.morph=="function")r.push(["morph",t.morph]);else for(let n of t.morph)r.push(["morph",n]);return r}return lb(t,e)},IC=t=>t.rules??t,Ml=(t,e,r)=>{let n=IC(t),o=IC(e),i=SC(n,o,r);return"morph"in t?"morph"in e?t.morph===e.morph?mr(i)||kr(i)?i:{rules:i,morph:t.morph}:r.lastOperator==="&"?ve(Zf(r.path,"Intersection","of morphs")):{}:kr(i)?i:{rules:mr(i)?t.rules:i,morph:t.morph}:"morph"in e?kr(i)?i:{rules:mr(i)?e.rules:i,morph:e.morph}:i};var OC=t=>`${t==="/"?"A":`At ${t}, a`} union including one or more morphs must be discriminatable`;var CC=(t,e)=>{let r=b8(t,e),n=t.map((o,i)=>i);return AC(t,n,r,e)},AC=(t,e,r,n)=>{if(e.length===1)return Pl(t[e[0]],n);let o=w8(e,r);if(!o)return[["branches",e.map(s=>pb(t[s],n.type.scope)?ve(OC(`${n.path}`)):Pl(t[s],n))]];let i={};for(let s in o.indexCases){let a=o.indexCases[s];i[s]=AC(t,a,r,n),s!=="default"&&$l(i[s],o.path,o,n)}return[["switch",{path:o.path,kind:o.kind,cases:i}]]},$l=(t,e,r,n)=>{for(let o=0;oIe(`Unexpectedly failed to discriminate ${t.kind} at path '${t.path}'`),y8={domain:!0,class:!0,value:!0},b8=(t,e)=>{let r={disjointsByPair:{},casesByDisjoint:{}};for(let n=0;n{let e=Je.fromString(t);return[e,e.pop()]},w8=(t,e)=>{let r;for(let n=0;n{let v=t.indexOf(y);if(v!==-1)return delete f[v],!0});b.length!==0&&(c[h]=b,p++)}let d=_e(f);if(d.length&&(c.default=d.map(h=>parseInt(h))),!r||p>r.score){let[h,b]=v8(l);if(r={path:h,kind:b,indexCases:c,score:p},p===t.length)return r}}}}return r},TC=(t,e)=>{switch(t){case"value":return kC(e);case"domain":return e;case"class":return Jf(e);default:return}},kC=t=>{let e=$e(t);return e==="object"||e==="symbol"?void 0:tb(t)},x8={value:t=>kC(t)??"default",class:t=>Ps(t)??"default",domain:$e},RC=(t,e)=>x8[t](e),pb=(t,e)=>"morph"in t?!0:"props"in t?Object.values(t.props).some(r=>E8(vo(r),e)):!1,E8=(t,e)=>typeof t=="string"?e.resolve(t).includesMorph:Object.values(e.resolveTypeNode(t)).some(r=>r===!0?!1:bo(r)?r.some(n=>pb(n,e)):pb(r,e));var $s=t=>t===!0?{}:t,NC=(t,e,r)=>{if(t===!0&&e===!0)return Ye();if(!bo(t)&&!bo(e)){let s=Ml($s(t),$s(e),r);return s===t?t:s===e?e:s}let n=tn($s(t)),o=tn($s(e)),i=_C(n,o,r);return i.equalities.length===n.length&&i.equalities.length===o.length?Ye():i.lExtendsR.length+i.equalities.length===n.length?t:i.rExtendsL.length+i.equalities.length===o.length?e:i},DC=(t,e,r,n)=>{n.domain=t;let o=NC(e,r,n);if(!cb(o))return o;let i=[...o.distinctIntersections,...o.equalities.map(s=>o.lBranches[s[0]]),...o.lExtendsR.map(s=>o.lBranches[s]),...o.rExtendsL.map(s=>o.rBranches[s])];return i.length===0&&n.addDisjoint("union",o.lBranches,o.rBranches),i.length===1?i[0]:i},FC=(t,e,r,n)=>{let o=new yo(n,"|"),i=NC(e,r,o);if(!cb(i))return mr(i)||i===e?r:i===r?e:t==="boolean"?!0:[$s(e),$s(r)];let s=[...i.lBranches.filter((a,l)=>!i.lExtendsR.includes(l)&&!i.equalities.some(u=>u[0]===l)),...i.rBranches.filter((a,l)=>!i.rExtendsL.includes(l)&&!i.equalities.some(u=>u[1]===l))];return s.length===1?s[0]:s},db=(t,e)=>t===!0?[]:bo(t)?CC(t,e):Pl(t,e),PC=t=>typeof t=="object"&&"value"in t;var Ll=t=>"config"in t,Qf=(t,e,r)=>{r.domain=void 0;let n=r.type.scope.resolveTypeNode(t),o=r.type.scope.resolveTypeNode(e),i=S8(n,o,r);return typeof i=="object"&&!Ol(i)?Ol(r.disjoints)?aC():r.addDisjoint("domain",_e(n),_e(o)):i===n?t:i===o?e:i},S8=Fs((t,e,r,n)=>{if(e===void 0)return r===void 0?Ie(Vf):void 0;if(r!==void 0)return DC(t,e,r,n)},{onEmpty:"omit"}),wo=(t,e,r)=>{let n=new yo(r,"&"),o=Qf(t,e,n);return kr(o)?ve(cC(n.disjoints)):mr(o)?t:o},np=(t,e,r)=>{let n=r.scope.resolveTypeNode(t),o=r.scope.resolveTypeNode(e),i={},s=_e({...n,...o});for(let a of s)i[a]=Ds(n,a)?Ds(o,a)?FC(a,n[a],o[a],r):n[a]:Ds(o,a)?o[a]:Ie(Vf);return i},I8=t=>t[0]&&(t[0][0]==="value"||t[0][0]==="class"),mb=t=>{let e={type:t,path:new Je,lastDomain:"undefined"};return rn(t.node,e)},rn=(t,e)=>{if(typeof t=="string")return e.type.scope.resolve(t).flat;let r=Ll(t),n=_8(r?t.node:t,e);return r?[["config",{config:XT(t.config),node:n}]]:n},_8=(t,e)=>{let r=_e(t);if(r.length===1){let o=r[0],i=t[o];if(i===!0)return o;e.lastDomain=o;let s=db(i,e);return I8(s)?s:[["domain",o],...s]}let n={};for(let o of r)e.lastDomain=o,n[o]=db(t[o],e);return[["domains",n]]},ep=(t,e)=>O8(t,e)&&PC(t[e]),O8=(t,e)=>{let r=_e(t);return r.length===1&&r[0]===e},Ls=t=>({object:{class:Array,props:{[nn.index]:t}}});function hb(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ne=class{shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}shiftUntil(e){let r="";for(;this.lookahead;){if(e(this,r))if(r[r.length-1]===Ne.escapeToken)r=r.slice(0,-1);else break;r+=this.shift()}return r}shiftUntilNextTerminator(){return this.shiftUntil(Ne.lookaheadIsNotWhitespace),this.shiftUntil(Ne.lookaheadIsTerminator)}get unscanned(){return this.chars.slice(this.i,this.chars.length).join("")}lookaheadIs(e){return this.lookahead===e}lookaheadIsIn(e){return this.lookahead in e}constructor(e){hb(this,"chars",void 0),hb(this,"i",void 0),hb(this,"finalized",!1),this.chars=[...e],this.i=0}};(function(t){var e=t.lookaheadIsTerminator=p=>p.lookahead in o,r=t.lookaheadIsNotWhitespace=p=>p.lookahead!==f,n=t.comparatorStartChars={"<":!0,">":!0,"=":!0},o=t.terminatingChars={...n,"|":!0,"&":!0,")":!0,"[":!0,"%":!0," ":!0},i=t.comparators={"<":!0,">":!0,"<=":!0,">=":!0,"==":!0},s=t.oneCharComparators={"<":!0,">":!0},a=t.comparatorDescriptions={"<":"less than",">":"more than","<=":"at most",">=":"at least","==":"exactly"},l=t.invertedComparators={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},u=t.branchTokens={"|":!0,"&":!0},c=t.escapeToken="\\",f=t.whiteSpaceToken=" "})(Ne||(Ne={}));function T8(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function C8(t,e){return e.get?e.get.call(t):e.value}function A8(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function MC(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function op(t,e){var r=MC(t,e,"get");return C8(t,r)}function k8(t,e,r){T8(t,e),e.set(t,r)}function R8(t,e,r){var n=MC(t,e,"set");return A8(t,n,r),r}function Cn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var yb=class extends TypeError{constructor(e){super(`${e}`),Cn(this,"cause",void 0),this.cause=e}},bi=class{toString(){return this.message}get message(){return this.writers.addContext(this.reason,this.path)}get reason(){return this.writers.writeReason(this.mustBe,new tp(this.data))}get mustBe(){return typeof this.writers.mustBe=="string"?this.writers.mustBe:this.writers.mustBe(this.source)}constructor(e,r,n,o,i){Cn(this,"code",void 0),Cn(this,"path",void 0),Cn(this,"data",void 0),Cn(this,"source",void 0),Cn(this,"writers",void 0),Cn(this,"parts",void 0),this.code=e,this.path=r,this.data=n,this.source=o,this.writers=i,this.code==="multi"&&(this.parts=this.source)}},js=new WeakMap,bb=class extends Array{mustBe(e,r){return this.add("custom",e,r)}add(e,r,n){let o=Je.from(n?.path??op(this,js).path),i=n&&"data"in n?n.data:op(this,js).data,s=new bi(e,o,i,r,op(this,js).getProblemConfig(e));return this.addProblem(s),s}addProblem(e){let r=`${e.path}`,n=this.byPath[r];if(n)if(n.parts)n.parts.push(e);else{let o=new bi("multi",n.path,n.data,[n,e],op(this,js).getProblemConfig("multi")),i=this.indexOf(n);this[i===-1?this.length:i]=o,this.byPath[r]=o}else this.byPath[r]=e,this.push(e);this.count++}get summary(){return`${this}`}toString(){return this.join(` -`)}throw(){throw new yb(this)}constructor(e){super(),Cn(this,"byPath",{}),Cn(this,"count",0),k8(this,js,{writable:!0,value:void 0}),R8(this,js,e)}},ip=bb,N8=t=>t[0].toUpperCase()+t.slice(1),vb=t=>t.map(e=>Yy[e]),$C=t=>t.map(e=>nb[e]),gb=t=>{if(t.length===0)return"never";if(t.length===1)return t[0];let e="";for(let r=0;r`must be ${t}${e&&` (was ${e})`}`,LC=(t,e)=>e.length===0?N8(t):e.length===1&&Tl(e[0])?`Item at index ${e[0]} ${t}`:`${e} ${t}`,yi={divisor:{mustBe:t=>t===1?"an integer":`a multiple of ${t}`},class:{mustBe:t=>{let e=Jf(t);return e?nb[e]:`an instance of ${t.name}`},writeReason:(t,e)=>gi(t,e.className)},domain:{mustBe:t=>Yy[t],writeReason:(t,e)=>gi(t,e.domain)},missing:{mustBe:()=>"defined",writeReason:t=>gi(t,"")},extraneous:{mustBe:()=>"removed",writeReason:t=>gi(t,"")},bound:{mustBe:t=>`${Ne.comparatorDescriptions[t.comparator]} ${t.limit}${t.units?` ${t.units}`:""}`,writeReason:(t,e)=>gi(t,`${e.size}`)},regex:{mustBe:t=>`a string matching ${t}`},value:{mustBe:Re},branches:{mustBe:t=>gb(t.map(e=>`${e.path} must be ${e.parts?gb(e.parts.map(r=>r.mustBe)):e.mustBe}`)),writeReason:(t,e)=>`${t} (was ${e})`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},multi:{mustBe:t=>"\u2022 "+t.map(e=>e.mustBe).join(` +`;for(let n in t)r+=` ${n}: ${pb[t[n].kind](t[n])} +`;return r},op=(t,e,r)=>`${t.length?`At ${t}: `:""}${e} ${r?`${r} `:""}results in an unsatisfiable type`;a();a();var Lc={Array,Date,Error,Function,Map,RegExp,Set,Object,String,Number,Boolean,WeakMap,WeakSet,Promise},Bs=(t,e)=>{if(qe(t)!=="object")return;let r=e??Lc,n=Object.getPrototypeOf(t);for(;n?.constructor&&(!r[n.constructor.name]||!(t instanceof r[n.constructor.name]));)n=Object.getPrototypeOf(n);return n?.constructor?.name};var xo=t=>Array.isArray(t),db={Object:"an object",Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},ip=t=>{let e=Object(t).name;return e&&gr(e,Lc)&&Lc[e]===t?e:void 0};a();a();a();var SC=yr((t,e,r)=>t===e?et():t instanceof e?t:e instanceof t?e:r.addDisjoint("class",t,e)),IC=(t,e)=>typeof t=="string"?Bs(e.data)===t||!e.problems.add("class",t):e.data instanceof t||!e.problems.add("class",t);a();var sp=(t,e)=>{if(Array.isArray(t)){if(Array.isArray(e)){let r=I8(t,e);return r.length===t.length?r.length===e.length?et():t:r.length===e.length?e:r}return t.includes(e)?t:[...t,e]}return Array.isArray(e)?e.includes(t)?e:[...e,t]:t===e?et():[t,e]},I8=(t,e)=>{let r=[...t];for(let n of e)t.includes(n)||r.push(n);return r};a();var _C=yr((t,e)=>t===e?et():Math.abs(t*e/_8(t,e))),_8=(t,e)=>{let r,n=t,o=e;for(;o!==0;)r=o,o=n%o,n=r;return n},TC=(t,e)=>e.data%t===0||!e.problems.add("divisor",t);a();var jc=t=>t[0]==="?",ap=t=>t[0]==="!",an={index:"[index]"},Eo=t=>jc(t)||ap(t)?t[1]:t,T8=t=>{if(typeof t.length=="object"&&ap(t.length)&&typeof t.length[1]!="string"&&lp(t.length[1],"number"))return t.length[1].number.value},OC=yr((t,e,r)=>{let n=O8(t,e,r);if(typeof n=="symbol")return n;let o=T8(n);if(o===void 0||!(an.index in n))return n;let{[an.index]:i,...s}=n,c=Eo(i);for(let l=0;l{if(e===void 0)return r===void 0?et():r;if(r===void 0)return e;n.path.push(t);let o=cp(Eo(e),Eo(r),n);n.path.pop();let i=jc(e)&&jc(r);return Pr(o)&&i?{}:o},{onEmpty:"bubble"}),CC=(t,e,r)=>{let n=r.type.config?.keys??r.type.scope.config.keys;return n==="loose"?C8(t,e,r):k8(n,t,e,r)},C8=(t,e,r)=>{for(let n in e){let o=e[n];r.path.push(n),n===an.index?t.push(["indexProp",sn(Eo(o),r)]):jc(o)?t.push(["optionalProp",[n,sn(o[1],r)]]):ap(o)?t.push(["prerequisiteProp",[n,sn(o[1],r)]]):t.push(["requiredProp",[n,sn(o,r)]]),r.path.pop()}},k8=(t,e,r,n)=>{let o={required:{},optional:{}};for(let i in r){let s=r[i];n.path.push(i),i===an.index?o.index=sn(Eo(s),n):jc(s)?o.optional[i]=sn(s[1],n):ap(s)?e.push(["prerequisiteProp",[i,sn(s[1],n)]]):o.required[i]=sn(s,n),n.path.pop()}e.push([`${t}Props`,o])};a();a();function A8(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var mb=t=>typeof t=="string"||Array.isArray(t)?t.length:typeof t=="number"?t:0,R8=t=>typeof t=="string"?"characters":Array.isArray(t)?"items long":"",up=class{toString(){return Pe(this.value)}get domain(){return qe(this.value)}get size(){return mb(this.value)}get units(){return R8(this.value)}get className(){return Object(this.value).constructor.name}constructor(e){A8(this,"value",void 0),this.value=e}};var fp={">":!0,">=":!0},hb={"<":!0,"<=":!0},qc=t=>"comparator"in t,AC=yr((t,e,r)=>{if(qc(t))return qc(e)?t.limit===e.limit?et():r.addDisjoint("range",t,e):kC(e,t.limit)?t:r.addDisjoint("range",t,e);if(qc(e))return kC(t,e.limit)?e:r.addDisjoint("range",t,e);let n=zs("min",t.min,e.min),o=zs("max",t.max,e.max);return n==="l"?o==="r"?zs("min",t.min,e.max)==="l"?r.addDisjoint("range",t,e):{min:t.min,max:e.max}:t:n==="r"?o==="l"?zs("max",t.max,e.min)==="l"?r.addDisjoint("range",t,e):{min:e.min,max:t.max}:e:o==="l"?t:o==="r"?e:et()}),kC=(t,e)=>qc(t)?e===t.limit:N8(t.min,e)&&D8(t.max,e),N8=(t,e)=>!t||e>t.limit||e===t.limit&&!Bc(t.comparator),D8=(t,e)=>!t||e{let n=r.lastDomain==="string"?"characters":r.lastDomain==="object"?"items long":void 0;if(qc(e))return t.push(["bound",n?{...e,units:n}:e]);e.min&&t.push(["bound",n?{...e.min,units:n}:e.min]),e.max&&t.push(["bound",n?{...e.max,units:n}:e.max])},NC=(t,e)=>P8[t.comparator](mb(e.data),t.limit)||!e.problems.add("bound",t),P8={"<":(t,e)=>t":(t,e)=>t>e,"<=":(t,e)=>t<=e,">=":(t,e)=>t>=e,"==":(t,e)=>t===e},zs=(t,e,r)=>e?r?e.limit===r.limit?Bc(e.comparator)?Bc(r.comparator)?"=":"l":Bc(r.comparator)?"r":"=":t==="min"?e.limit>r.limit?"l":"r":e.limitt.length===1;a();var gb={},yb=t=>(gb[t]||(gb[t]=new RegExp(t)),gb[t]),DC=(t,e)=>yb(t).test(e.data)||!e.problems.add("regex",`/${t}/`),PC=yr(sp);var MC=(t,e,r)=>"value"in t?"value"in e?t.value===e.value?et():r.addDisjoint("value",t.value,e.value):FC(t.value,e,r)?t:r.addDisjoint("leftAssignability",t,e):"value"in e?FC(e.value,t,r)?e:r.addDisjoint("rightAssignability",t,e):M8(t,e,r),F8=yr(sp),M8=qs({divisor:_C,regex:PC,props:OC,class:SC,range:AC,narrow:F8},{onEmpty:"bubble"}),bb=(t,e)=>{let r=[],n;for(n in t)$8[n](r,t[n],e);return r.sort((o,i)=>zc[o[0]]-zc[i[0]])},$8={regex:(t,e)=>{for(let r of on(e))t.push(["regex",r])},divisor:(t,e)=>{t.push(["divisor",e])},range:RC,class:(t,e)=>{t.push(["class",e])},props:CC,narrow:(t,e)=>{for(let r of on(e))t.push(["narrow",r])},value:(t,e)=>{t.push(["value",e])}},zc={config:-1,domain:0,value:0,domains:0,branches:0,switch:0,alias:0,class:0,regex:1,divisor:1,bound:1,prerequisiteProp:2,distilledProps:3,strictProps:3,requiredProp:3,optionalProp:3,indexProp:3,narrow:4,morph:5},FC=(t,e,r)=>!r.type.scope.type(["node",{[r.domain]:e}])(t).problems;var vb=t=>t?.lBranches!==void 0,LC=(t,e,r)=>{let n={lBranches:t,rBranches:e,lExtendsR:[],rExtendsL:[],equalities:[],distinctIntersections:[]},o=e.map(i=>({condition:i,distinct:[]}));return t.forEach((i,s)=>{let c=!1,l=o.map((f,u)=>{if(c||!f.distinct)return null;let d=f.condition,m=Wc(i,d,r);return Pr(m)?null:m===i?(n.lExtendsR.push(s),c=!0,null):m===d?(n.rExtendsL.push(u),f.distinct=null,null):br(m)?(n.equalities.push([s,u]),c=!0,f.distinct=null,null):vo(m,"object")?m:Oe(`Unexpected predicate intersection result of type '${qe(m)}'`)});if(!c)for(let f=0;fi.distinct??[]),n},wb=t=>"rules"in t,Uc=(t,e)=>{if(wb(t)){let r=bb(t.rules,e);if(t.morph)if(typeof t.morph=="function")r.push(["morph",t.morph]);else for(let n of t.morph)r.push(["morph",n]);return r}return bb(t,e)},$C=t=>t.rules??t,Wc=(t,e,r)=>{let n=$C(t),o=$C(e),i=MC(n,o,r);return"morph"in t?"morph"in e?t.morph===e.morph?br(i)||Pr(i)?i:{rules:i,morph:t.morph}:r.lastOperator==="&"?Ee(op(r.path,"Intersection","of morphs")):{}:Pr(i)?i:{rules:br(i)?t.rules:i,morph:t.morph}:"morph"in e?Pr(i)?i:{rules:br(i)?e.rules:i,morph:e.morph}:i};a();a();var jC=t=>`${t==="/"?"A":`At ${t}, a`} union including one or more morphs must be discriminatable`;var BC=(t,e)=>{let r=j8(t,e),n=t.map((o,i)=>i);return zC(t,n,r,e)},zC=(t,e,r,n)=>{if(e.length===1)return Uc(t[e[0]],n);let o=B8(e,r);if(!o)return[["branches",e.map(s=>Eb(t[s],n.type.scope)?Ee(jC(`${n.path}`)):Uc(t[s],n))]];let i={};for(let s in o.indexCases){let c=o.indexCases[s];i[s]=zC(t,c,r,n),s!=="default"&&Hc(i[s],o.path,o,n)}return[["switch",{path:o.path,kind:o.kind,cases:i}]]},Hc=(t,e,r,n)=>{for(let o=0;oOe(`Unexpectedly failed to discriminate ${t.kind} at path '${t.path}'`),L8={domain:!0,class:!0,value:!0},j8=(t,e)=>{let r={disjointsByPair:{},casesByDisjoint:{}};for(let n=0;n{let e=Qe.fromString(t);return[e,e.pop()]},B8=(t,e)=>{let r;for(let n=0;n{let x=t.indexOf(v);if(x!==-1)return delete d[x],!0});w.length!==0&&(u[y]=w,m++)}let h=Ce(d);if(h.length&&(u.default=h.map(y=>parseInt(y))),!r||m>r.score){let[y,w]=q8(l);if(r={path:y,kind:w,indexCases:u,score:m},m===t.length)return r}}}}return r},qC=(t,e)=>{switch(t){case"value":return UC(e);case"domain":return e;case"class":return ip(e);default:return}},UC=t=>{let e=qe(t);return e==="object"||e==="symbol"?void 0:fb(t)},z8={value:t=>UC(t)??"default",class:t=>Bs(t)??"default",domain:qe},WC=(t,e)=>z8[t](e),Eb=(t,e)=>"morph"in t?!0:"props"in t?Object.values(t.props).some(r=>U8(Eo(r),e)):!1,U8=(t,e)=>typeof t=="string"?e.resolve(t).includesMorph:Object.values(e.resolveTypeNode(t)).some(r=>r===!0?!1:xo(r)?r.some(n=>Eb(n,e)):Eb(r,e));var Us=t=>t===!0?{}:t,HC=(t,e,r)=>{if(t===!0&&e===!0)return et();if(!xo(t)&&!xo(e)){let s=Wc(Us(t),Us(e),r);return s===t?t:s===e?e:s}let n=on(Us(t)),o=on(Us(e)),i=LC(n,o,r);return i.equalities.length===n.length&&i.equalities.length===o.length?et():i.lExtendsR.length+i.equalities.length===n.length?t:i.rExtendsL.length+i.equalities.length===o.length?e:i},KC=(t,e,r,n)=>{n.domain=t;let o=HC(e,r,n);if(!vb(o))return o;let i=[...o.distinctIntersections,...o.equalities.map(s=>o.lBranches[s[0]]),...o.lExtendsR.map(s=>o.lBranches[s]),...o.rExtendsL.map(s=>o.rBranches[s])];return i.length===0&&n.addDisjoint("union",o.lBranches,o.rBranches),i.length===1?i[0]:i},VC=(t,e,r,n)=>{let o=new wo(n,"|"),i=HC(e,r,o);if(!vb(i))return br(i)||i===e?r:i===r?e:t==="boolean"?!0:[Us(e),Us(r)];let s=[...i.lBranches.filter((c,l)=>!i.lExtendsR.includes(l)&&!i.equalities.some(f=>f[0]===l)),...i.rBranches.filter((c,l)=>!i.rExtendsL.includes(l)&&!i.equalities.some(f=>f[1]===l))];return s.length===1?s[0]:s},Sb=(t,e)=>t===!0?[]:xo(t)?BC(t,e):Uc(t,e),GC=t=>typeof t=="object"&&"value"in t;var Kc=t=>"config"in t,cp=(t,e,r)=>{r.domain=void 0;let n=r.type.scope.resolveTypeNode(t),o=r.type.scope.resolveTypeNode(e),i=W8(n,o,r);return typeof i=="object"&&!Pc(i)?Pc(r.disjoints)?wC():r.addDisjoint("domain",Ce(n),Ce(o)):i===n?t:i===o?e:i},W8=qs((t,e,r,n)=>{if(e===void 0)return r===void 0?Oe(rp):void 0;if(r!==void 0)return KC(t,e,r,n)},{onEmpty:"omit"}),So=(t,e,r)=>{let n=new wo(r,"&"),o=cp(t,e,n);return Pr(o)?Ee(EC(n.disjoints)):br(o)?t:o},pp=(t,e,r)=>{let n=r.scope.resolveTypeNode(t),o=r.scope.resolveTypeNode(e),i={},s=Ce({...n,...o});for(let c of s)i[c]=js(n,c)?js(o,c)?VC(c,n[c],o[c],r):n[c]:js(o,c)?o[c]:Oe(rp);return i},H8=t=>t[0]&&(t[0][0]==="value"||t[0][0]==="class"),Ib=t=>{let e={type:t,path:new Qe,lastDomain:"undefined"};return sn(t.node,e)},sn=(t,e)=>{if(typeof t=="string")return e.type.scope.resolve(t).flat;let r=Kc(t),n=K8(r?t.node:t,e);return r?[["config",{config:fC(t.config),node:n}]]:n},K8=(t,e)=>{let r=Ce(t);if(r.length===1){let o=r[0],i=t[o];if(i===!0)return o;e.lastDomain=o;let s=Sb(i,e);return H8(s)?s:[["domain",o],...s]}let n={};for(let o of r)e.lastDomain=o,n[o]=Sb(t[o],e);return[["domains",n]]},lp=(t,e)=>V8(t,e)&&GC(t[e]),V8=(t,e)=>{let r=Ce(t);return r.length===1&&r[0]===e},Ws=t=>({object:{class:Array,props:{[an.index]:t}}});a();a();a();a();a();function _b(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Fe=class{shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}shiftUntil(e){let r="";for(;this.lookahead;){if(e(this,r))if(r[r.length-1]===Fe.escapeToken)r=r.slice(0,-1);else break;r+=this.shift()}return r}shiftUntilNextTerminator(){return this.shiftUntil(Fe.lookaheadIsNotWhitespace),this.shiftUntil(Fe.lookaheadIsTerminator)}get unscanned(){return this.chars.slice(this.i,this.chars.length).join("")}lookaheadIs(e){return this.lookahead===e}lookaheadIsIn(e){return this.lookahead in e}constructor(e){_b(this,"chars",void 0),_b(this,"i",void 0),_b(this,"finalized",!1),this.chars=[...e],this.i=0}};(function(t){var e=t.lookaheadIsTerminator=m=>m.lookahead in o,r=t.lookaheadIsNotWhitespace=m=>m.lookahead!==d,n=t.comparatorStartChars={"<":!0,">":!0,"=":!0},o=t.terminatingChars={...n,"|":!0,"&":!0,")":!0,"[":!0,"%":!0," ":!0},i=t.comparators={"<":!0,">":!0,"<=":!0,">=":!0,"==":!0},s=t.oneCharComparators={"<":!0,">":!0},c=t.comparatorDescriptions={"<":"less than",">":"more than","<=":"at most",">=":"at least","==":"exactly"},l=t.invertedComparators={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},f=t.branchTokens={"|":!0,"&":!0},u=t.escapeToken="\\",d=t.whiteSpaceToken=" "})(Fe||(Fe={}));function G8(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Z8(t,e){return e.get?e.get.call(t):e.value}function J8(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function ZC(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function dp(t,e){var r=ZC(t,e,"get");return Z8(t,r)}function Y8(t,e,r){G8(t,e),e.set(t,r)}function X8(t,e,r){var n=ZC(t,e,"set");return J8(t,n,r),r}function Rn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ob=class extends TypeError{constructor(e){super(`${e}`),Rn(this,"cause",void 0),this.cause=e}},Ei=class{toString(){return this.message}get message(){return this.writers.addContext(this.reason,this.path)}get reason(){return this.writers.writeReason(this.mustBe,new up(this.data))}get mustBe(){return typeof this.writers.mustBe=="string"?this.writers.mustBe:this.writers.mustBe(this.source)}constructor(e,r,n,o,i){Rn(this,"code",void 0),Rn(this,"path",void 0),Rn(this,"data",void 0),Rn(this,"source",void 0),Rn(this,"writers",void 0),Rn(this,"parts",void 0),this.code=e,this.path=r,this.data=n,this.source=o,this.writers=i,this.code==="multi"&&(this.parts=this.source)}},Hs=new WeakMap,Cb=class extends Array{mustBe(e,r){return this.add("custom",e,r)}add(e,r,n){let o=Qe.from(n?.path??dp(this,Hs).path),i=n&&"data"in n?n.data:dp(this,Hs).data,s=new Ei(e,o,i,r,dp(this,Hs).getProblemConfig(e));return this.addProblem(s),s}addProblem(e){let r=`${e.path}`,n=this.byPath[r];if(n)if(n.parts)n.parts.push(e);else{let o=new Ei("multi",n.path,n.data,[n,e],dp(this,Hs).getProblemConfig("multi")),i=this.indexOf(n);this[i===-1?this.length:i]=o,this.byPath[r]=o}else this.byPath[r]=e,this.push(e);this.count++}get summary(){return`${this}`}toString(){return this.join(` +`)}throw(){throw new Ob(this)}constructor(e){super(),Rn(this,"byPath",{}),Rn(this,"count",0),Y8(this,Hs,{writable:!0,value:void 0}),X8(this,Hs,e)}},mp=Cb,Q8=t=>t[0].toUpperCase()+t.slice(1),kb=t=>t.map(e=>ab[e]),JC=t=>t.map(e=>db[e]),Tb=t=>{if(t.length===0)return"never";if(t.length===1)return t[0];let e="";for(let r=0;r`must be ${t}${e&&` (was ${e})`}`,YC=(t,e)=>e.length===0?Q8(t):e.length===1&&Fc(e[0])?`Item at index ${e[0]} ${t}`:`${e} ${t}`,xi={divisor:{mustBe:t=>t===1?"an integer":`a multiple of ${t}`},class:{mustBe:t=>{let e=ip(t);return e?db[e]:`an instance of ${t.name}`},writeReason:(t,e)=>wi(t,e.className)},domain:{mustBe:t=>ab[t],writeReason:(t,e)=>wi(t,e.domain)},missing:{mustBe:()=>"defined",writeReason:t=>wi(t,"")},extraneous:{mustBe:()=>"removed",writeReason:t=>wi(t,"")},bound:{mustBe:t=>`${Fe.comparatorDescriptions[t.comparator]} ${t.limit}${t.units?` ${t.units}`:""}`,writeReason:(t,e)=>wi(t,`${e.size}`)},regex:{mustBe:t=>`a string matching ${t}`},value:{mustBe:Pe},branches:{mustBe:t=>Tb(t.map(e=>`${e.path} must be ${e.parts?Tb(e.parts.map(r=>r.mustBe)):e.mustBe}`)),writeReason:(t,e)=>`${t} (was ${e})`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},multi:{mustBe:t=>"\u2022 "+t.map(e=>e.mustBe).join(` \u2022 `),writeReason:(t,e)=>`${e} must be... -${t}`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},custom:{mustBe:t=>t},cases:{mustBe:t=>gb(t)}},jC=_e(yi),D8=()=>{let t={},e;for(e of jC)t[e]={mustBe:yi[e].mustBe,writeReason:yi[e].writeReason??gi,addContext:yi[e].addContext??LC};return t},F8=D8(),qC=t=>{if(!t)return F8;let e={};for(let r of jC)e[r]={mustBe:t[r]?.mustBe??yi[r].mustBe,writeReason:t[r]?.writeReason??yi[r].writeReason??t.writeReason??gi,addContext:t[r]?.addContext??yi[r].addContext??t.addContext??LC};return e};function P8(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function M8(t,e){return e.get?e.get.call(t):e.value}function $8(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function UC(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function wb(t,e){var r=UC(t,e,"get");return M8(t,r)}function L8(t,e,r){P8(t,e),e.set(t,r)}function j8(t,e,r){var n=UC(t,e,"set");return $8(t,n,r),r}function on(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var q8=()=>({mustBe:[],writeReason:[],addContext:[],keys:[]}),B8=["mustBe","writeReason","addContext"],WC=(t,e)=>{let r=new xb(e,t);sp(t.flat,r);let n=new HC(r);if(r.problems.count)n.problems=r.problems;else{for(let[o,i]of r.entriesToPrune)delete o[i];n.data=r.data}return n},HC=class{constructor(){on(this,"data",void 0),on(this,"problems",void 0)}},jl=new WeakMap,xb=class{getProblemConfig(e){let r={};for(let n of B8)r[n]=this.traversalConfig[n][0]??this.rootScope.config.codes[e][n];return r}traverseConfig(e,r){for(let o of e)this.traversalConfig[o[0]].unshift(o[1]);let n=sp(r,this);for(let o of e)this.traversalConfig[o[0]].shift();return n}traverseKey(e,r){let n=this.data;this.data=this.data[e],this.path.push(e);let o=sp(r,this);return this.path.pop(),n[e]!==this.data&&(n[e]=this.data),this.data=n,o}traverseResolution(e){let r=this.type.scope.resolve(e),n=r.qualifiedName,o=this.data,i=go(o,"object");if(i){let l=wb(this,jl)[n];if(l){if(l.includes(o))return!0;l.push(o)}else wb(this,jl)[n]=[o]}let s=this.type;this.type=r;let a=sp(r.flat,this);return this.type=s,i&&wb(this,jl)[n].pop(),a}traverseBranches(e){let r=this.failFast;this.failFast=!0;let n=this.problems,o=new ip(this);this.problems=o;let i=this.path,s=this.entriesToPrune,a=!1;for(let l of e)if(this.path=new Je,this.entriesToPrune=[],ap(l,this)){a=!0,s.push(...this.entriesToPrune);break}return this.path=i,this.entriesToPrune=s,this.problems=n,this.failFast=r,a||!this.problems.add("branches",o)}constructor(e,r){on(this,"data",void 0),on(this,"type",void 0),on(this,"path",void 0),on(this,"problems",void 0),on(this,"entriesToPrune",void 0),on(this,"failFast",void 0),on(this,"traversalConfig",void 0),on(this,"rootScope",void 0),L8(this,jl,{writable:!0,value:void 0}),this.data=e,this.type=r,this.path=new Je,this.problems=new ip(this),this.entriesToPrune=[],this.failFast=!1,this.traversalConfig=q8(),j8(this,jl,{}),this.rootScope=r.scope}},sp=(t,e)=>typeof t=="string"?$e(e.data)===t||!e.problems.add("domain",t):ap(t,e),ap=(t,e)=>{let r=!0;for(let n=0;nt[0]in e.data?e.traverseKey(t[0],t[1]):(e.problems.add("missing",void 0,{path:e.path.concat(t[0]),data:void 0}),!1),zC=t=>(e,r)=>{let n=!0,o={...e.required};for(let s in r.data)if(e.required[s]?(n=r.traverseKey(s,e.required[s])&&n,delete o[s]):e.optional[s]?n=r.traverseKey(s,e.optional[s])&&n:e.index&&Bf.test(s)?n=r.traverseKey(s,e.index)&&n:t==="distilledProps"?r.failFast?r.entriesToPrune.push([r.data,s]):delete r.data[s]:(n=!1,r.problems.add("extraneous",r.data[s],{path:r.path.concat(s)})),!n&&r.failFast)return!1;let i=Object.keys(o);if(i.length){for(let s of i)r.problems.add("missing",void 0,{path:r.path.concat(s)});return!1}return n},z8={regex:wC,divisor:dC,domains:(t,e)=>{let r=t[$e(e.data)];return r?ap(r,e):!e.problems.add("cases",vb(_e(t)))},domain:(t,e)=>$e(e.data)===t||!e.problems.add("domain",t),bound:vC,optionalProp:(t,e)=>t[0]in e.data?e.traverseKey(t[0],t[1]):!0,requiredProp:BC,prerequisiteProp:BC,indexProp:(t,e)=>{if(!Array.isArray(e.data))return e.problems.add("class",Array),!1;let r=!0;for(let n=0;ne.traverseBranches(t),switch:(t,e)=>{let r=eC(e.data,t.path),n=RC(t.kind,r);if(Ds(t.cases,n))return ap(t.cases[n],e);let o=_e(t.cases),i=e.path.concat(t.path),s=t.kind==="value"?o:t.kind==="domain"?vb(o):t.kind==="class"?$C(o):Ie(`Unexpectedly encountered rule kind '${t.kind}' during traversal`);return e.problems.add("cases",s,{path:i,data:r}),!1},alias:(t,e)=>e.traverseResolution(t),class:fC,narrow:(t,e)=>{let r=e.problems.count,n=t(e.data,e.problems);return!n&&e.problems.count===r&&e.problems.mustBe(t.name?`valid according to ${t.name}`:"valid"),n},config:({config:t,node:e},r)=>r.traverseConfig(t,e),value:(t,e)=>e.data===t||!e.problems.add("value",t),morph:(t,e)=>{let r=t(e.data,e.problems);if(e.problems.length)return!1;if(r instanceof bi)return e.problems.addProblem(r),!1;if(r instanceof HC){if(r.problems){for(let n of r.problems)e.problems.addProblem(n);return!1}return e.data=r.data,!0}return e.data=r,!0},distilledProps:zC("distilledProps"),strictProps:zC("strictProps")};var xo=new Proxy(()=>xo,{get:()=>xo});var Eb=(t,e,r,n)=>{let o={node:t,flat:[["alias",t]],allows:a=>!i(a).problems,assert:a=>{let l=i(a);return l.problems?l.problems.throw():l.data},infer:xo,inferIn:xo,qualifiedName:U8(t)?n.getAnonymousQualifiedName(t):`${n.name}.${t}`,definition:e,scope:n,includesMorph:!1,config:r},i={[t]:a=>WC(i,a)}[t];return Object.assign(i,o)},Sb=t=>t?.infer===xo,U8=t=>t[0]==="\u03BB";var KC=t=>{let e=t.scanner.shiftUntilNextTerminator();t.setRoot(W8(t,e))},W8=(t,e)=>t.ctx.type.scope.addParsedReferenceIfResolvable(e,t.ctx)?e:H8(e)??t.error(e===""?Ib(t):K8(e)),H8=t=>{let e=Al(t);if(e!==void 0)return{number:{value:e}};let r=Qy(t);if(r!==void 0)return{bigint:{value:r}}},K8=t=>`'${t}' is unresolvable`,Ib=t=>{let e=t.previousOperator();return e?_b(e,t.scanner.unscanned):V8(t.scanner.unscanned)},_b=(t,e)=>`Token '${t}' requires a right operand${e?` before '${e}'`:""}`,V8=t=>`Expected an expression${t?` before '${t}'`:""}`;var Ob=(t,e)=>({node:e.type.scope.resolveTypeNode(Xe(t[0],e)),config:t[2]});var hr=t=>Object.isFrozen(t)?t:Array.isArray(t)?Object.freeze(t.map(hr)):G8(t),G8=t=>{for(let e in t)hr(t[e]);return t};var Z8=hr({regex:Cl.source}),J8=hr({range:{min:{comparator:">=",limit:0}},divisor:1}),VC=(t,e)=>{let r=e.type.scope.resolveNode(Xe(t[1],e)),n=_e(r).map(c=>X8(c,r[c])),o=GC(n);if(!o.length)return Zf(e.path,"keyof");let i={};for(let c of o){let f=typeof c;if(f==="string"||f==="number"||f==="symbol"){var s,a;(s=i)[a=f]??(s[a]=[]),i[f].push({value:c})}else if(c===Cl){var l,u;(l=i).string??(l.string=[]),i.string.push(Z8),(u=i).number??(u.number=[]),i.number.push(J8)}else return Ie(`Unexpected keyof key '${Re(c)}'`)}return Object.fromEntries(Object.entries(i).map(([c,f])=>[c,f.length===1?f[0]:f]))},Y8={bigint:hi(0n),boolean:hi(!1),null:[],number:hi(0),object:[],string:hi(""),symbol:hi(Symbol()),undefined:[]},X8=(t,e)=>t!=="object"||e===!0?Y8[t]:GC(tn(e).map(r=>Q8(r))),GC=t=>{if(!t.length)return[];let e=t[0];for(let r=1;rt[r].includes(n));return e},Q8=t=>{let e=[];if("props"in t)for(let r of Object.keys(t.props))r===nn.index?e.push(Cl):e.includes(r)||(e.push(r),Cl.test(r)&&e.push(zf(r,`Unexpectedly failed to parse an integer from key '${r}'`)));if("class"in t){let r=typeof t.class=="string"?kl[t.class]:t.class;for(let n of hi(r.prototype))e.includes(n)||e.push(n)}return e};var JC=(t,e)=>{if(typeof t[2]!="function")return ve(eW(t[2]));let r=Xe(t[0],e),n=e.type.scope.resolveTypeNode(r),o=t[2];e.type.includesMorph=!0;let i,s={};for(i in n){let a=n[i];a===!0?s[i]={rules:{},morph:o}:typeof a=="object"?s[i]=bo(a)?a.map(l=>ZC(l,o)):ZC(a,o):Ie(`Unexpected predicate value for domain '${i}': ${Re(a)}`)}return s},ZC=(t,e)=>ub(t)?{...t,morph:t.morph?Array.isArray(t.morph)?[...t.morph,e]:[t.morph,e]:e}:{rules:t,morph:e},eW=t=>`Morph expression requires a function following '|>' (was ${typeof t})`;var YC=t=>`Expected a Function or Record operand (${Re(t)} was invalid)`,XC=(t,e,r,n)=>{let o=_e(e);if(!go(t,"object"))return ve(YC(t));let i={};if(typeof t=="function"){let s={[n]:t};for(let a of o)i[a]=s}else for(let s of o){if(t[s]===void 0)continue;let a={[n]:t[s]};if(typeof a[n]!="function")return ve(YC(a));i[s]=a}return i};var QC=(t,e)=>{let r=Xe(t[0],e),n=e.type.scope.resolveNode(r),o=Ll(n),i=o?n.node:n,s=wo(r,XC(t[2],i,e,"narrow"),e.type);return o?{config:n.config,node:s}:s};var tA=(t,e)=>{if(rW(t))return rA[t[1]](t,e);if(nW(t))return nA[t[0]](t,e);let r={length:["!",{number:{value:t.length}}]};for(let n=0;n{if(t[2]===void 0)return ve(_b(t[1],""));let r=Xe(t[0],e),n=Xe(t[2],e);return t[1]==="&"?wo(r,n,e.type):np(r,n,e.type)},tW=(t,e)=>Ls(Xe(t[0],e));var rW=t=>rA[t[1]]!==void 0,rA={"|":eA,"&":eA,"[]":tW,"=>":QC,"|>":JC,":":Ob},nA={keyof:VC,instanceof:t=>typeof t[1]!="function"?ve(`Expected a constructor following 'instanceof' operator (was ${typeof t[1]}).`):{object:{class:t[1]}},"===":t=>({[$e(t[1])]:{value:t[1]}}),node:t=>t[1]},nW=t=>nA[t[0]]!==void 0;var oA=(t,e)=>{let r={};for(let n in t){let o=n,i=!1;n[n.length-1]==="?"&&(n[n.length-2]===Ne.escapeToken?o=`${n.slice(0,-2)}?`:(o=n.slice(0,-1),i=!0)),e.path.push(o);let s=Xe(t[n],e);e.path.pop(),r[o]=i?["?",s]:s}return{object:{props:r}}};var iA=t=>`Unmatched )${t===""?"":` before ${t}`}`,sA="Missing )",aA=(t,e)=>`Left bounds are only valid when paired with right bounds (try ...${e}${t})`,lp=t=>`Left-bounded expressions must specify their limits using < or <= (was ${t})`,lA=(t,e,r,n)=>`An expression may have at most one left bound (parsed ${t}${Ne.invertedComparators[e]}, ${r}${Ne.invertedComparators[n]})`;function ql(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var cp=class{error(e){return ve(e)}hasRoot(){return this.root!==void 0}resolveRoot(){return this.assertHasRoot(),this.ctx.type.scope.resolveTypeNode(this.root)}rootToString(){return this.assertHasRoot(),Re(this.root)}ejectRootIfLimit(){this.assertHasRoot();let e=typeof this.root=="string"?this.ctx.type.scope.resolveNode(this.root):this.root;if(ep(e,"number")){let r=e.number.value;return this.root=void 0,r}}ejectRangeIfOpen(){if(this.branches.range){let e=this.branches.range;return delete this.branches.range,e}}assertHasRoot(){if(this.root===void 0)return Ie("Unexpected interaction with unset root")}assertUnsetRoot(){if(this.root!==void 0)return Ie("Unexpected attempt to overwrite root")}setRoot(e){this.assertUnsetRoot(),this.root=e}rootToArray(){this.root=Ls(this.ejectRoot())}intersect(e){this.root=wo(this.ejectRoot(),e,this.ctx.type)}ejectRoot(){this.assertHasRoot();let e=this.root;return this.root=void 0,e}ejectFinalizedRoot(){this.assertHasRoot();let e=this.root;return this.root=oW,e}finalize(){if(this.groups.length)return this.error(sA);this.finalizeBranches(),this.scanner.finalized=!0}reduceLeftBound(e,r){let n=Ne.invertedComparators[r];if(!pr(n,rp))return this.error(lp(r));if(this.branches.range)return this.error(lA(`${this.branches.range.limit}`,this.branches.range.comparator,`${e}`,n));this.branches.range={limit:e,comparator:n}}finalizeBranches(){this.assertRangeUnset(),this.branches.union?(this.pushRootToBranch("|"),this.setRoot(this.branches.union)):this.branches.intersection&&this.setRoot(wo(this.branches.intersection,this.ejectRoot(),this.ctx.type))}finalizeGroup(){this.finalizeBranches();let e=this.groups.pop();if(!e)return this.error(iA(this.scanner.unscanned));this.branches=e}pushRootToBranch(e){this.assertRangeUnset(),this.branches.intersection=this.branches.intersection?wo(this.branches.intersection,this.ejectRoot(),this.ctx.type):this.ejectRoot(),e==="|"&&(this.branches.union=this.branches.union?np(this.branches.union,this.branches.intersection,this.ctx.type):this.branches.intersection,delete this.branches.intersection)}assertRangeUnset(){if(this.branches.range)return this.error(aA(`${this.branches.range.limit}`,this.branches.range.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={}}previousOperator(){return this.branches.range?.comparator??this.branches.intersection?"&":this.branches.union?"|":void 0}shiftedByOne(){return this.scanner.shift(),this}constructor(e,r){ql(this,"ctx",void 0),ql(this,"scanner",void 0),ql(this,"root",void 0),ql(this,"branches",void 0),ql(this,"groups",void 0),this.ctx=r,this.branches={},this.groups=[],this.scanner=new Ne(e)}},oW=new Proxy({},{get:()=>Ie("Unexpected attempt to access ejected attributes")});var cA=(t,e)=>{let r=t.scanner.shiftUntil(iW[e]);if(t.scanner.lookahead==="")return t.error(aW(r,e));t.scanner.shift()==="/"?(ab(r),t.setRoot({string:{regex:r}})):t.setRoot({string:{value:r}})},uA={"'":1,'"':1,"/":1},iW={"'":t=>t.lookahead==="'",'"':t=>t.lookahead==='"',"/":t=>t.lookahead==="/"},sW={'"':"double-quote","'":"single-quote","/":"forward slash"},aW=(t,e)=>`${e}${t} requires a closing ${sW[e]}`;var up=t=>t.scanner.lookahead===""?t.error(Ib(t)):t.scanner.lookahead==="("?t.shiftedByOne().reduceGroupOpen():t.scanner.lookaheadIsIn(uA)?cA(t,t.scanner.shift()):t.scanner.lookahead===" "?up(t.shiftedByOne()):KC(t);var fA=t=>`Bounded expression ${t} must be a number, string or array`;var pA=(t,e)=>{let r=lW(t,e),n=t.ejectRootIfLimit();return n===void 0?uW(t,r):t.reduceLeftBound(n,r)},lW=(t,e)=>t.scanner.lookaheadIs("=")?`${e}${t.scanner.shift()}`:pr(e,Ne.oneCharComparators)?e:t.error(cW),cW="= is not a valid comparator. Use == to check for equality",uW=(t,e)=>{let r=t.scanner.shiftUntilNextTerminator(),n=Al(r,dW(e,r+t.scanner.unscanned)),o=t.ejectRangeIfOpen(),i={comparator:e,limit:n},s=o?Tb(i,ib)?Ms("min",o,i)==="l"?t.error(mW({min:o,max:i})):{min:o,max:i}:t.error(lp(e)):pW(i,"==")?i:Tb(i,rp)?{min:i}:Tb(i,ib)?{max:i}:Ie(`Unexpected comparator '${i.comparator}'`);t.intersect(fW(s,t))},fW=(t,e)=>{let r=e.resolveRoot(),n=_e(r),o={},i={range:t};return n.every(a=>{switch(a){case"string":return o.string=i,!0;case"number":return o.number=i,!0;case"object":return o.object=i,r.object===!0?!1:tn(r.object).every(l=>"class"in l&&l.class===Array);default:return!1}})||e.error(fA(e.rootToString())),o},pW=(t,e)=>t.comparator===e,Tb=(t,e)=>t.comparator in e,dW=(t,e)=>`Comparator ${t} must be followed by a number literal (was '${e}')`,mW=t=>`${Kf(t)} is empty`;var dA=t=>`Divisibility operand ${t} must be a number`;var hA=t=>{let e=t.scanner.shiftUntilNextTerminator(),r=zf(e,mA(e));r===0&&t.error(mA(0));let n=_e(t.resolveRoot());n.length===1&&n[0]==="number"?t.intersect({number:{divisor:r}}):t.error(dA(t.rootToString()))},mA=t=>`% operator must be followed by a non-zero integer literal (was ${t})`;var Cb=t=>{let e=t.scanner.shift();return e===""?t.finalize():e==="["?t.scanner.shift()==="]"?t.rootToArray():t.error(gW):pr(e,Ne.branchTokens)?t.pushRootToBranch(e):e===")"?t.finalizeGroup():pr(e,Ne.comparatorStartChars)?pA(t,e):e==="%"?hA(t):e===" "?Cb(t):Ie(hW(e))},hW=t=>`Unexpected character '${t}'`,gW="Missing expected ']'";var gA=(t,e)=>e.type.scope.parseCache.get(t)??e.type.scope.parseCache.set(t,yW(t,e)??bW(t,e)),yW=(t,e)=>{if(e.type.scope.addParsedReferenceIfResolvable(t,e))return t;if(t.endsWith("[]")){let r=t.slice(0,-2);if(e.type.scope.addParsedReferenceIfResolvable(t,e))return Ls(r)}},bW=(t,e)=>{let r=new cp(t,e);return up(r),vW(r)},vW=t=>{for(;!t.scanner.finalized;)wW(t);return t.ejectFinalizedRoot()},wW=t=>t.hasRoot()?Cb(t):up(t);var Xe=(t,e)=>{let r=$e(t);if(r==="string")return gA(t,e);if(r!=="object")return ve(Ab(r));let n=Ps(t);switch(n){case"Object":return oA(t,e);case"Array":return tA(t,e);case"RegExp":return{string:{regex:t.source}};case"Function":if(Sb(t))return e.type.scope.addAnonymousTypeReference(t,e);if(xW(t)){let o=t();if(Sb(o))return e.type.scope.addAnonymousTypeReference(o,e)}return ve(Ab("Function"));default:return ve(Ab(n??Re(t)))}},Yge=Symbol("as"),xW=t=>typeof t=="function"&&t.length===0,Ab=t=>`Type definitions must be strings or objects (was ${t})`;function EW(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var qs=class{get root(){return this.cache}has(e){return e in this.cache}get(e){return this.cache[e]}set(e,r){return this.cache[e]=r,r}constructor(){EW(this,"cache",{})}},fp=class extends qs{set(e,r){return this.cache[e]=hr(r),r}};function xA(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function SW(t,e){return e.get?e.get.call(t):e.value}function IW(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function EA(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function kn(t,e){var r=EA(t,e,"get");return SW(t,r)}function yA(t,e,r){xA(t,e),e.set(t,r)}function bA(t,e,r){var n=EA(t,e,"set");return IW(t,n,r),r}function An(t,e,r){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return r}function pp(t,e){xA(t,e),e.add(t)}function Dt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _W=t=>({codes:qC(t.codes),keys:t.keys??"loose"}),OW=0,vA={},kb={};var vi=new WeakMap,Bs=new WeakMap,wA=new WeakSet,dp=new WeakSet,Nb=new WeakSet,mp=new WeakSet,Db=class{getAnonymousQualifiedName(e){let r=0,n=e;for(;this.isResolvable(n);)n=`${e}${r++}`;return`${this.name}.${n}`}addAnonymousTypeReference(e,r){var n;return(n=r.type).includesMorph||(n.includesMorph=e.includesMorph),e.node}get infer(){return xo}compile(){if(!kb[this.name]){for(let e in this.aliases)this.resolve(e);kb[this.name]=kn(this,Bs).root}return kn(this,Bs).root}addParsedReferenceIfResolvable(e,r){var n;let o=An(this,mp,Fb).call(this,e,"undefined",[e]);return o?((n=r.type).includesMorph||(n.includesMorph=o.includesMorph),!0):!1}resolve(e){return An(this,mp,Fb).call(this,e,"throw",[e])}resolveNode(e){return typeof e=="string"?this.resolveNode(this.resolve(e).node):e}resolveTypeNode(e){let r=this.resolveNode(e);return Ll(r)?r.node:r}isResolvable(e){return kn(this,vi).has(e)||this.aliases[e]}constructor(e,r={}){pp(this,wA),pp(this,dp),pp(this,Nb),pp(this,mp),Dt(this,"aliases",void 0),Dt(this,"name",void 0),Dt(this,"config",void 0),Dt(this,"parseCache",void 0),yA(this,vi,{writable:!0,value:void 0}),yA(this,Bs,{writable:!0,value:void 0}),Dt(this,"expressions",void 0),Dt(this,"intersection",void 0),Dt(this,"union",void 0),Dt(this,"arrayOf",void 0),Dt(this,"keyOf",void 0),Dt(this,"valueOf",void 0),Dt(this,"instanceOf",void 0),Dt(this,"narrow",void 0),Dt(this,"morph",void 0),Dt(this,"type",void 0),this.aliases=e,this.parseCache=new fp,bA(this,vi,new qs),bA(this,Bs,new qs),this.expressions={intersection:(n,o,i)=>this.type([n,"&",o],i),union:(n,o,i)=>this.type([n,"|",o],i),arrayOf:(n,o)=>this.type([n,"[]"],o),keyOf:(n,o)=>this.type(["keyof",n],o),node:(n,o)=>this.type(["node",n],o),instanceOf:(n,o)=>this.type(["instanceof",n],o),valueOf:(n,o)=>this.type(["===",n],o),narrow:(n,o,i)=>this.type([n,"=>",o],i),morph:(n,o,i)=>this.type([n,"|>",o],i)},this.intersection=this.expressions.intersection,this.union=this.expressions.union,this.arrayOf=this.expressions.arrayOf,this.keyOf=this.expressions.keyOf,this.valueOf=this.expressions.valueOf,this.instanceOf=this.expressions.instanceOf,this.narrow=this.expressions.narrow,this.morph=this.expressions.morph,this.type=Object.assign((n,o={})=>{let i=Eb("\u03BBtype",n,o,this),s=An(this,Nb,SA).call(this,i),a=Xe(n,s);return i.node=hr(Ol(o)?{config:o,node:this.resolveTypeNode(a)}:a),i.flat=hr(mb(i)),i},{from:this.expressions.node}),this.name=An(this,wA,TW).call(this,r),r.standard!==!1&&An(this,dp,Rb).call(this,[kb.standard],"imports"),r.imports&&An(this,dp,Rb).call(this,r.imports,"imports"),r.includes&&An(this,dp,Rb).call(this,r.includes,"includes"),this.config=_W(r)}};function TW(t){let e=t.name?vA[t.name]?ve(`A scope named '${t.name}' already exists`):t.name:`scope${++OW}`;return vA[e]=this,e}function Rb(t,e){for(let r of t)for(let n in r)(kn(this,vi).has(n)||n in this.aliases)&&ve(AW(n)),kn(this,vi).set(n,r[n]),e==="includes"&&kn(this,Bs).set(n,r[n])}function SA(t){return{type:t,path:new Je}}function Fb(t,e,r){let n=kn(this,vi).get(t);if(n)return n;let o=this.aliases[t];if(!o)return e==="throw"?Ie(`Unexpectedly failed to resolve alias '${t}'`):void 0;let i=Eb(t,o,{},this),s=An(this,Nb,SA).call(this,i);kn(this,vi).set(t,i),kn(this,Bs).set(t,i);let a=Xe(o,s);if(typeof a=="string"){if(r.includes(a))return ve(CW(t,r));r.push(a),a=An(this,mp,Fb).call(this,a,"throw",r).node}return i.node=hr(a),i.flat=hr(mb(i)),i}var Ft=(t,e={})=>new Db(t,e),Pb=Ft({},{name:"root",standard:!1}),Rr=Pb.type,CW=(t,e)=>`Alias '${t}' has a shallow resolution cycle: ${[...e,t].join("=>")}`,AW=t=>`Alias '${t}' is already defined`;var hp=Ft({Function:["node",{object:{class:Function}}],Date:["node",{object:{class:Date}}],Error:["node",{object:{class:Error}}],Map:["node",{object:{class:Map}}],RegExp:["node",{object:{class:RegExp}}],Set:["node",{object:{class:Set}}],WeakMap:["node",{object:{class:WeakMap}}],WeakSet:["node",{object:{class:WeakSet}}],Promise:["node",{object:{class:Promise}}]},{name:"jsObjects",standard:!1}),IA=hp.compile();var _A={bigint:!0,boolean:!0,null:!0,number:!0,object:!0,string:!0,symbol:!0,undefined:!0},gp=Ft({any:["node",_A],bigint:["node",{bigint:!0}],boolean:["node",{boolean:!0}],false:["node",{boolean:{value:!1}}],never:["node",{}],null:["node",{null:!0}],number:["node",{number:!0}],object:["node",{object:!0}],string:["node",{string:!0}],symbol:["node",{symbol:!0}],true:["node",{boolean:{value:!0}}],unknown:["node",_A],void:["node",{undefined:!0}],undefined:["node",{undefined:!0}]},{name:"ts",standard:!1}),wi=gp.compile();var kW=t=>{let e=t.replace(/[- ]+/g,""),r=0,n,o,i;for(let s=e.length-1;s>=0;s--)n=e.substring(s,s+1),o=parseInt(n,10),i?(o*=2,o>=10?r+=o%10+1:r+=o):r+=o,i=!i;return!!(r%10===0&&e)},RW=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,OA=Rr([RW,"=>",(t,e)=>kW(t)||!e.mustBe("a valid credit card number")],{mustBe:"a valid credit card number"});var NW=/^[./-]$/,DW=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,FW=t=>!isNaN(t),yp=t=>`a ${t}-formatted date`,PW=(t,e)=>{if(!e?.format){let a=new Date(t);return FW(a)?a:"a valid date"}if(e.format==="iso8601")return DW.test(t)?new Date(t):yp("iso8601");let r=t.split(NW),n=t[r[0].length],o=n?e.format.split(n):[e.format];if(r.length!==o.length)return yp(e.format);let i={};for(let a=0;a",(t,e)=>{let r=PW(t);return typeof r=="string"?e.mustBe(r):r}]);var MW=Rr([Xy,"|>",t=>parseFloat(t)],{mustBe:"a well-formed numeric string"}),$W=Rr([wi.string,"|>",(t,e)=>{if(!Tl(t))return e.mustBe("a well-formed integer string");let r=parseInt(t);return Number.isSafeInteger(r)?r:e.mustBe("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")}]),LW=Rr(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/,{mustBe:"a valid email"}),jW=Rr(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,{mustBe:"a valid UUID"}),qW=Rr(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,{mustBe:"a valid semantic version (see https://semver.org/)"}),BW=Rr([wi.string,"|>",t=>JSON.parse(t)],{mustBe:"a JSON-parsable string"}),bp=Ft({alpha:[/^[A-Za-z]*$/,":",{mustBe:"only letters"}],alphanumeric:[/^[A-Za-z\d]*$/,":",{mustBe:"only letters and digits"}],lowercase:[/^[a-z]*$/,":",{mustBe:"only lowercase letters"}],uppercase:[/^[A-Z]*$/,":",{mustBe:"only uppercase letters"}],creditCard:OA,email:LW,uuid:jW,parsedNumber:MW,parsedInteger:$W,parsedDate:TA,semver:qW,json:BW,integer:["node",{number:{divisor:1}}]},{name:"validation",standard:!1}),CA=bp.compile();var vp=Ft({},{name:"standard",includes:[wi,IA,CA],standard:!1}),zW=vp.compile(),Rn={root:Pb,tsKeywords:gp,jsObjects:hp,validation:bp,ark:vp};var Bl=vp.type;var UW=Rn.ark.intersection,WW=Rn.ark.union,HW=Rn.ark.arrayOf,KW=Rn.ark.keyOf,VW=Rn.ark.instanceOf,GW=Rn.ark.valueOf,ZW=Rn.ark.narrow,JW=Rn.ark.morph;var{DataRequest:Wye,DataResponse:AA}=Ft({DataRequest:{id:"number",method:"string",params:"any[]"},DataResponse:{id:"number","eventName?":"string",payload:"any",error:"any"}}).compile(),wp="__METHODS__",xp="__EVAL__";var kA=()=>({events:{},emit(t,...e){let r=this.events[t]||[];for(let n=0,o=r.length;n{this.events[t]=this.events[t]?.filter(r=>e!==r)}}});function xi(){let t=kA();return t.once=(e,r)=>{let n=(...i)=>{o(),r(...i)},o=t.on(e,n);return o},t}function YW(t){return Object.assign(new Error,t)}var Ei=class{pending=new Map;terminateState=!1;terminationHandler=null;lastId=0;worker;constructor(){this.worker=this.setupWorker(),this.worker.onMessage(e=>this.onMessage(e.data)),this.worker.onError(e=>this.onError(e.error))}internal=xi();evt=xi();task=xi();onMessage(e){if(this.terminateState==="finished")return;if(e==="ready"){this.internal.emit("ready");return}let{data:r,problems:n}=AA(e);if(n)throw new Error(n.toString());if(r.eventName){this.evt.emit(r.eventName,r.payload);return}this.task.emit(r.id,r.payload,r.error),this.terminateState==="requested"&&this.terminate()}onError(e){for(let r of this.pending.values())r.abort(e);this.pending.clear(),this.worker.terminate()}methods(){return this.invoke(wp)}eval(e,r,n){let o=[e,...r];return this.invoke(xp,o,{transfer:n})}send({id:e,method:r,params:n,transfer:o,timeout:i},s=new AbortController){let a=s.signal;return this.pending.set(e,s),new Promise((l,u)=>{this.worker.send({id:e,method:r,params:n},{transfer:o});let c=-1,f=()=>{u(a?.reason),p(),window.clearTimeout(c)};i!==void 0&&(c=window.setTimeout(()=>{s.abort(new DOMException(`Timeout after ${i}ms`,"TimeoutError"))},i)),a?.addEventListener("abort",f);let p=this.task.once(e,(d,h)=>{a?.removeEventListener("abort",f),h?u(YW(h)):l(d)})}).catch(l=>{if(l instanceof DOMException&&["AbortError","TimeoutError"].includes(l.name))return this.terminate(!0).then(()=>{throw l});throw l}).finally(()=>{this.pending.delete(e)})}async invoke(e,r=[],{controller:n,transfer:o}={}){if(this.terminateState!==!1)throw new Error("Worker is terminated");let i=++this.lastId;return await this.worker.readyPromise,await this.send({id:i,method:e,params:r,transfer:o},n)}busy(){return this.pending.size>0}terminate(e=!1,r){if(e){for(let n of this.pending.values())n.abort(new Error("Worker terminated"));this.pending.clear()}if(this.busy()){this.terminateState="requested";let n=new Promise(o=>{this.internal.once("terminate",o)});return r!==void 0?Promise.race([n,XW(r)]).then():n}return this.worker.terminate(),Promise.resolve()}};function XW(t){return new Promise(e=>setTimeout(()=>e(new DOMException(`Timeout after ${t}ms`,"TimeoutError")),t))}var zs=class extends Ei{setupWorker(){let e=this,r=Object.assign(this.initWebWorker(),{readyPromise:new Promise(n=>e.internal.once("ready",()=>n(!0))),killed:!1,send(n,o){r.postMessage(n,o)},onMessage(n){return r.addEventListener("message",n),()=>r.removeEventListener("message",n)},onError(n){return r.addEventListener("error",n),()=>r.removeEventListener("error",n)}});return or(r,{terminate:n=>function(){r.killed||(n.call(this),r.killed=!0,e.internal.emit("terminate")),e.terminateState="finished"}}),r}};var Us=class{workers=[];tasks=[];pending=new Map;emitter=xi();#e=xi();maxQueueSize=1/0;maxWorkers=Math.max((this.getMaxConcurrency()||4)-1,1);minWorkers=0;getMaxConcurrency(){return navigator.hardwareConcurrency}constructor(e={}){if(e.maxQueueSize!==void 0&&(this.maxQueueSize=e7.assert(e.maxQueueSize)),e.maxWorkers!==void 0&&(this.maxWorkers=QW.assert(e.maxWorkers)),e.minWorkers!==void 0){let o=t7.assert(e.minWorkers);o==="max"?this.minWorkers=this.maxWorkers:(this.minWorkers=o,this.maxWorkers=Math.max(this.minWorkers,this.maxWorkers)),this.ensureMinWorkers()}let r={},n=o=>r[o]??=(...i)=>this.invoke(o,i);this.proxy=new Proxy(r,{get:(o,i)=>!Reflect.has(o,i)&&typeof i=="string"?n(i):Reflect.get(o,i)}),this.methods().then(o=>o.forEach(n))}eval(e,r,n={}){return this.invoke(xp,[typeof e=="string"?e:e.toString(),r],n)}invoke(e,r=[],n={}){if(this.tasks.length>=this.maxQueueSize)throw new Error("Max queue size of "+this.maxQueueSize+" reached");let o={method:e,params:r,transfer:n.transfer};return this.tasks.push(o),this.pending.set(o,n.controller??new AbortController),this.next(),new Promise((i,s)=>{let a=[this.#e.on("complete",(l,u)=>{o===l&&(a.forEach(c=>c()),i(u))}),this.#e.on("error",(l,u)=>{o===l&&(a.forEach(c=>c()),s(u))})]})}methods(){return this.invoke(wp)}proxy;next(){if(this.tasks.length===0)return;let e=this.getWorker();if(!e)return;let r=this.tasks.shift();if(!this.pending.has(r))return this.next();let n=this.pending.get(r);e.invoke(r.method,r.params,{transfer:r.transfer,timeout:r.timeout,controller:n}).then(o=>{this.#e.emit("complete",r,o)}).catch(o=>{this.#e.emit("error",r,o),e.terminateState==="finished"&&this.removeWorker(e)}).finally(()=>{this.pending.delete(r),this.next()})}getWorker(){for(let e of this.workers)if(!e.busy())return e;if(this.workers.length{try{await n.terminate(e,r),this.removeWorkerFromList(n)}finally{this.emitter.emit("worker-terminate")}})).then()}get stats(){let e=this.workers.length,r=this.workers.filter(function(n){return n.busy()}).length;return{totalWorkers:e,busyWorkers:r,idleWorkers:e-r,pendingTasks:this.tasks.length,activeTasks:r}}ensureMinWorkers(){if(this.minWorkers)for(let e=this.workers.length;e=1"),e7=Bl("integer>=1"),t7=Bl('integer>=0|"max"');var RA='"use strict";var Zg=Object.create;var vu=Object.defineProperty;var Qg=Object.getOwnPropertyDescriptor;var Xg=Object.getOwnPropertyNames;var ey=Object.getPrototypeOf,ty=Object.prototype.hasOwnProperty;var D=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ry=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xg(t))!ty.call(e,o)&&o!==r&&vu(e,o,{get:()=>t[o],enumerable:!(n=Qg(t,o))||n.enumerable});return e};var $r=(e,t,r)=>(r=e!=null?Zg(ey(e)):{},ry(t||!e||!e.__esModule?vu(r,"default",{value:e,enumerable:!0}):r,e));var Js=D((pl,Hs)=>{(function(e){if(typeof pl=="object"&&typeof Hs<"u")Hs.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function n(o,i,s){function a(l,d){if(!i[l]){if(!o[l]){var f=typeof require=="function"&&require;if(!d&&f)return f(l,!0);if(u)return u(l,!0);var g=new Error("Cannot find module \'"+l+"\'");throw g.code="MODULE_NOT_FOUND",g}var w=i[l]={exports:{}};o[l][0].call(w.exports,function(x){var S=o[l][1][x];return a(S||x)},w,w.exports,n,o,i,s)}return i[l].exports}for(var u=typeof require=="function"&&require,m=0;m"u"&&n(3);var f=Promise;function g(c,h){h&&c.then(function(p){h(null,p)},function(p){h(p)})}function w(c,h,p){typeof h=="function"&&c.then(h),typeof p=="function"&&c.catch(p)}function x(c){return typeof c!="string"&&(console.warn(c+" used as a key, but it is not a string."),c=String(c)),c}function S(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var N="local-forage-detect-blob-support",M=void 0,k={},ee=Object.prototype.toString,xe="readonly",A="readwrite";function B(c){for(var h=c.length,p=new ArrayBuffer(h),b=new Uint8Array(p),v=0;v=43)}}).catch(function(){return!1})}function F(c){return typeof M=="boolean"?f.resolve(M):L(c).then(function(h){return M=h,M})}function j(c){var h=k[c.name],p={};p.promise=new f(function(b,v){p.resolve=b,p.reject=v}),h.deferredOperations.push(p),h.dbReady?h.dbReady=h.dbReady.then(function(){return p.promise}):h.dbReady=p.promise}function O(c){var h=k[c.name],p=h.deferredOperations.pop();if(p)return p.resolve(),p.promise}function $(c,h){var p=k[c.name],b=p.deferredOperations.pop();if(b)return b.reject(h),b.promise}function R(c,h){return new f(function(p,b){if(k[c.name]=k[c.name]||Xa(),c.db)if(h)j(c),c.db.close();else return p(c.db);var v=[c.name];h&&v.push(c.version);var y=m.open.apply(m,v);h&&(y.onupgradeneeded=function(E){var I=y.result;try{I.createObjectStore(c.storeName),E.oldVersion<=1&&I.createObjectStore(N)}catch(_){if(_.name==="ConstraintError")console.warn(\'The database "\'+c.name+\'" has been upgraded from version \'+E.oldVersion+" to version "+E.newVersion+\', but the storage "\'+c.storeName+\'" already exists.\');else throw _}}),y.onerror=function(E){E.preventDefault(),b(y.error)},y.onsuccess=function(){var E=y.result;E.onversionchange=function(I){I.target.close()},p(E),O(c)}})}function U(c){return R(c,!1)}function q(c){return R(c,!0)}function W(c,h){if(!c.db)return!0;var p=!c.db.objectStoreNames.contains(c.storeName),b=c.versionc.db.version;if(b&&(c.version!==h&&console.warn(\'The database "\'+c.name+`" can\'t be downgraded from version `+c.db.version+" to version "+c.version+"."),c.version=c.db.version),v||p){if(p){var y=c.db.version+1;y>c.version&&(c.version=y)}return!0}return!1}function K(c){return new f(function(h,p){var b=new FileReader;b.onerror=p,b.onloadend=function(v){var y=btoa(v.target.result||"");h({__local_forage_encoded_blob:!0,data:y,type:c.type})},b.readAsBinaryString(c)})}function X(c){var h=B(atob(c.data));return d([h],{type:c.type})}function J(c){return c&&c.__local_forage_encoded_blob}function Zn(c){var h=this,p=h._initReady().then(function(){var b=k[h._dbInfo.name];if(b&&b.dbReady)return b.dbReady});return w(p,c,c),p}function Xh(c){j(c);for(var h=k[c.name],p=h.forages,b=0;b0&&(!c.db||y.name==="InvalidStateError"||y.name==="NotFoundError"))return f.resolve().then(function(){if(!c.db||y.name==="NotFoundError"&&!c.db.objectStoreNames.contains(c.storeName)&&c.version<=c.db.version)return c.db&&(c.version=c.db.version+1),q(c)}).then(function(){return Xh(c).then(function(){ft(c,h,p,b-1)})}).catch(p);p(y)}}function Xa(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function eg(c){var h=this,p={db:null};if(c)for(var b in c)p[b]=c[b];var v=k[p.name];v||(v=Xa(),k[p.name]=v),v.forages.push(h),h._initReady||(h._initReady=h.ready,h.ready=Zn);var y=[];function E(){return f.resolve()}for(var I=0;I>4,C[v++]=(E&15)<<4|I>>2,C[v++]=(I&3)<<6|_&63;return T}function Ki(c){var h=new Uint8Array(c),p="",b;for(b=0;b>2],p+=vt[(h[b]&3)<<4|h[b+1]>>4],p+=vt[(h[b+1]&15)<<2|h[b+2]>>6],p+=vt[h[b+2]&63];return h.length%3===2?p=p.substring(0,p.length-1)+"=":h.length%3===1&&(p=p.substring(0,p.length-2)+"=="),p}function mg(c,h){var p="";if(c&&(p=fu.call(c)),c&&(p==="[object ArrayBuffer]"||c.buffer&&fu.call(c.buffer)==="[object ArrayBuffer]")){var b,v=Qn;c instanceof ArrayBuffer?(b=c,v+=zi):(b=c.buffer,p==="[object Int8Array]"?v+=tu:p==="[object Uint8Array]"?v+=ru:p==="[object Uint8ClampedArray]"?v+=nu:p==="[object Int16Array]"?v+=ou:p==="[object Uint16Array]"?v+=su:p==="[object Int32Array]"?v+=iu:p==="[object Uint32Array]"?v+=au:p==="[object Float32Array]"?v+=uu:p==="[object Float64Array]"?v+=cu:h(new Error("Failed to get type for BinaryArray"))),h(v+Ki(b))}else if(p==="[object Blob]"){var y=new FileReader;y.onload=function(){var E=pg+c.type+"~"+Ki(this.result);h(Qn+Wi+E)},y.readAsArrayBuffer(c)}else try{h(JSON.stringify(c))}catch(E){console.error("Couldn\'t convert value into a JSON string: ",c),h(null,E)}}function dg(c){if(c.substring(0,Ui)!==Qn)return JSON.parse(c);var h=c.substring(lu),p=c.substring(Ui,lu),b;if(p===Wi&&eu.test(h)){var v=h.match(eu);b=v[1],h=h.substring(v[0].length)}var y=pu(h);switch(p){case zi:return y;case Wi:return d([y],{type:b});case tu:return new Int8Array(y);case ru:return new Uint8Array(y);case nu:return new Uint8ClampedArray(y);case ou:return new Int16Array(y);case su:return new Uint16Array(y);case iu:return new Int32Array(y);case au:return new Uint32Array(y);case uu:return new Float32Array(y);case cu:return new Float64Array(y);default:throw new Error("Unkown type: "+p)}}var Gi={serialize:mg,deserialize:dg,stringToBuffer:pu,bufferToString:Ki};function mu(c,h,p,b){c.executeSql("CREATE TABLE IF NOT EXISTS "+h.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],p,b)}function hg(c){var h=this,p={db:null};if(c)for(var b in c)p[b]=typeof c[b]!="string"?c[b].toString():c[b];var v=new f(function(y,E){try{p.db=openDatabase(p.name,String(p.version),p.description,p.size)}catch(I){return E(I)}p.db.transaction(function(I){mu(I,p,function(){h._dbInfo=p,y()},function(_,T){E(T)})},E)});return p.serializer=Gi,v}function wt(c,h,p,b,v,y){c.executeSql(p,b,v,function(E,I){I.code===I.SYNTAX_ERR?E.executeSql("SELECT name FROM sqlite_master WHERE type=\'table\' AND name = ?",[h.storeName],function(_,T){T.rows.length?y(_,I):mu(_,h,function(){_.executeSql(p,b,v,y)},y)},y):y(E,I)},y)}function gg(c,h){var p=this;c=x(c);var b=new f(function(v,y){p.ready().then(function(){var E=p._dbInfo;E.db.transaction(function(I){wt(I,E,"SELECT * FROM "+E.storeName+" WHERE key = ? LIMIT 1",[c],function(_,T){var C=T.rows.length?T.rows.item(0).value:null;C&&(C=E.serializer.deserialize(C)),v(C)},function(_,T){y(T)})})}).catch(y)});return g(b,h),b}function yg(c,h){var p=this,b=new f(function(v,y){p.ready().then(function(){var E=p._dbInfo;E.db.transaction(function(I){wt(I,E,"SELECT * FROM "+E.storeName,[],function(_,T){for(var C=T.rows,P=C.length,z=0;z0){E(du.apply(v,[c,_,p,b-1]));return}I(z)}})})}).catch(I)});return g(y,p),y}function bg(c,h,p){return du.apply(this,[c,h,p,1])}function vg(c,h){var p=this;c=x(c);var b=new f(function(v,y){p.ready().then(function(){var E=p._dbInfo;E.db.transaction(function(I){wt(I,E,"DELETE FROM "+E.storeName+" WHERE key = ?",[c],function(){v()},function(_,T){y(T)})})}).catch(y)});return g(b,h),b}function wg(c){var h=this,p=new f(function(b,v){h.ready().then(function(){var y=h._dbInfo;y.db.transaction(function(E){wt(E,y,"DELETE FROM "+y.storeName,[],function(){b()},function(I,_){v(_)})})}).catch(v)});return g(p,c),p}function xg(c){var h=this,p=new f(function(b,v){h.ready().then(function(){var y=h._dbInfo;y.db.transaction(function(E){wt(E,y,"SELECT COUNT(key) as c FROM "+y.storeName,[],function(I,_){var T=_.rows.item(0).c;b(T)},function(I,_){v(_)})})}).catch(v)});return g(p,c),p}function Eg(c,h){var p=this,b=new f(function(v,y){p.ready().then(function(){var E=p._dbInfo;E.db.transaction(function(I){wt(I,E,"SELECT key FROM "+E.storeName+" WHERE id = ? LIMIT 1",[c+1],function(_,T){var C=T.rows.length?T.rows.item(0).key:null;v(C)},function(_,T){y(T)})})}).catch(y)});return g(b,h),b}function Ig(c){var h=this,p=new f(function(b,v){h.ready().then(function(){var y=h._dbInfo;y.db.transaction(function(E){wt(E,y,"SELECT key FROM "+y.storeName,[],function(I,_){for(var T=[],C=0;C<_.rows.length;C++)T.push(_.rows.item(C).key);b(T)},function(I,_){v(_)})})}).catch(v)});return g(p,c),p}function Sg(c){return new f(function(h,p){c.transaction(function(b){b.executeSql("SELECT name FROM sqlite_master WHERE type=\'table\' AND name <> \'__WebKitDatabaseInfoTable__\'",[],function(v,y){for(var E=[],I=0;I0}function Cg(c){var h=this,p={};if(c)for(var b in c)p[b]=c[b];return p.keyPrefix=hu(c,h._defaultConfig),Ng()?(h._dbInfo=p,p.serializer=Gi,f.resolve()):f.reject()}function Ag(c){var h=this,p=h.ready().then(function(){for(var b=h._dbInfo.keyPrefix,v=localStorage.length-1;v>=0;v--){var y=localStorage.key(v);y.indexOf(b)===0&&localStorage.removeItem(y)}});return g(p,c),p}function Rg(c,h){var p=this;c=x(c);var b=p.ready().then(function(){var v=p._dbInfo,y=localStorage.getItem(v.keyPrefix+c);return y&&(y=v.serializer.deserialize(y)),y});return g(b,h),b}function Fg(c,h){var p=this,b=p.ready().then(function(){for(var v=p._dbInfo,y=v.keyPrefix,E=y.length,I=localStorage.length,_=1,T=0;T=0;E--){var I=localStorage.key(E);I.indexOf(y)===0&&localStorage.removeItem(I)}}):v=f.reject("Invalid arguments"),g(v,h),v}var Lg={_driver:"localStorageWrapper",_initStorage:Cg,_support:_g(),iterate:Fg,getItem:Rg,setItem:qg,removeItem:Mg,clear:Ag,length:kg,key:$g,keys:Pg,dropInstance:jg},Bg=function(h,p){return h===p||typeof h=="number"&&typeof p=="number"&&isNaN(h)&&isNaN(p)},Ug=function(h,p){for(var b=h.length,v=0;v"u"?"undefined":s(p))==="object"){if(this._ready)return new Error("Can\'t call config() after localforage has been used.");for(var b in p){if(b==="storeName"&&(p[b]=p[b].replace(/\\W/g,"_")),b==="version"&&typeof p[b]!="number")return new Error("Database version must be a number.");this._config[b]=p[b]}return"driver"in p&&p.driver?this.setDriver(this._config.driver):!0}else return typeof p=="string"?this._config[p]:this._config},c.prototype.defineDriver=function(p,b,v){var y=new f(function(E,I){try{var _=p._driver,T=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!p._driver){I(T);return}for(var C=Hi.concat("_initStorage"),P=0,z=C.length;P{var gr=1e3,yr=gr*60,br=yr*60,zt=br*24,Lv=zt*7,Bv=zt*365.25;ml.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Uv(e);if(r==="number"&&isFinite(e))return t.long?Wv(e):zv(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Uv(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Bv;case"weeks":case"week":case"w":return r*Lv;case"days":case"day":case"d":return r*zt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*br;case"minutes":case"minute":case"mins":case"min":case"m":return r*yr;case"seconds":case"second":case"secs":case"sec":case"s":return r*gr;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function zv(e){var t=Math.abs(e);return t>=zt?Math.round(e/zt)+"d":t>=br?Math.round(e/br)+"h":t>=yr?Math.round(e/yr)+"m":t>=gr?Math.round(e/gr)+"s":e+"ms"}function Wv(e){var t=Math.abs(e);return t>=zt?Wo(e,t,zt,"day"):t>=br?Wo(e,t,br,"hour"):t>=yr?Wo(e,t,yr,"minute"):t>=gr?Wo(e,t,gr,"second"):e+" ms"}function Wo(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var gl=D((tA,hl)=>{function Kv(e){r.debug=r,r.default=r,r.coerce=u,r.disable=i,r.enable=o,r.enabled=s,r.humanize=dl(),r.destroy=m,Object.keys(e).forEach(l=>{r[l]=e[l]}),r.names=[],r.skips=[],r.formatters={};function t(l){let d=0;for(let f=0;f{if(A==="%%")return"%";ee++;let L=r.formatters[B];if(typeof L=="function"){let F=S[ee];A=L.call(N,F),S.splice(ee,1),ee--}return A}),r.formatArgs.call(N,S),(N.log||r.log).apply(N,S)}return x.namespace=l,x.useColors=r.useColors(),x.color=r.selectColor(l),x.extend=n,x.destroy=r.destroy,Object.defineProperty(x,"enabled",{enumerable:!0,configurable:!1,get:()=>f!==null?f:(g!==r.namespaces&&(g=r.namespaces,w=r.enabled(l)),w),set:S=>{f=S}}),typeof r.init=="function"&&r.init(x),x}function n(l,d){let f=r(this.namespace+(typeof d>"u"?":":d)+l);return f.log=this.log,f}function o(l){r.save(l),r.namespaces=l,r.names=[],r.skips=[];let d,f=(typeof l=="string"?l:"").split(/[\\s,]+/),g=f.length;for(d=0;d"-"+d)].join(",");return r.enable(""),l}function s(l){if(l[l.length-1]==="*")return!0;let d,f;for(d=0,f=r.skips.length;d{Fe.formatArgs=Hv;Fe.save=Jv;Fe.load=Vv;Fe.useColors=Gv;Fe.storage=Yv();Fe.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Fe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Gv(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function Hv(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Ko.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}Fe.log=console.debug||console.log||(()=>{});function Jv(e){try{e?Fe.storage.setItem("debug",e):Fe.storage.removeItem("debug")}catch{}}function Vv(){let e;try{e=Fe.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function Yv(){try{return localStorage}catch{}}Ko.exports=gl()(Fe);var{formatters:Zv}=Ko.exports;Zv.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var bl=D((rA,yl)=>{"use strict";yl.exports=Qv;function vr(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function Qv(e){if(e=e||{},e.circles)return Xv(e);return e.proto?n:r;function t(o,i){for(var s=Object.keys(o),a=new Array(s.length),u=0;u{var ew=require("util"),Wt=we()("log4js:configuration"),Go=[],Ho=[],vl=e=>!e,wl=e=>e&&typeof e=="object"&&!Array.isArray(e),tw=e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),rw=e=>e&&typeof e=="number"&&Number.isInteger(e),nw=e=>{Ho.push(e),Wt(`Added listener, now ${Ho.length} listeners`)},ow=e=>{Go.push(e),Wt(`Added pre-processing listener, now ${Go.length} listeners`)},xl=(e,t,r)=>{(Array.isArray(t)?t:[t]).forEach(o=>{if(o)throw new Error(`Problem with log4js configuration: (${ew.inspect(e,{depth:5})}) - ${r}`)})},iw=e=>{Wt("New configuration to be validated: ",e),xl(e,vl(wl(e)),"must be an object."),Wt(`Calling pre-processing listeners (${Go.length})`),Go.forEach(t=>t(e)),Wt("Configuration pre-processing finished."),Wt(`Calling configuration listeners (${Ho.length})`),Ho.forEach(t=>t(e)),Wt("Configuration finished.")};El.exports={configure:iw,addListener:nw,addPreProcessingListener:ow,throwExceptionIf:xl,anObject:wl,anInteger:rw,validIdentifier:tw,not:vl}});var Jo=D((oA,ze)=>{"use strict";function Il(e,t){for(var r=e.toString();r.length-1?o:i,a=Gt(t.getHours()),u=Gt(t.getMinutes()),m=Gt(t.getSeconds()),l=Il(t.getMilliseconds(),3),d=sw(t.getTimezoneOffset()),f=e.replace(/dd/g,r).replace(/MM/g,n).replace(/y{1,4}/g,s).replace(/hh/g,a).replace(/mm/g,u).replace(/ss/g,m).replace(/SSS/g,l).replace(/O/g,d);return f}function _t(e,t,r,n){e["set"+(n?"":"UTC")+t](r)}function aw(e,t,r){var n=e.indexOf("O")<0,o=!1,i=[{pattern:/y{1,4}/,regexp:"\\\\d{1,4}",fn:function(d,f){_t(d,"FullYear",f,n)}},{pattern:/MM/,regexp:"\\\\d{1,2}",fn:function(d,f){_t(d,"Month",f-1,n),d.getMonth()!==f-1&&(o=!0)}},{pattern:/dd/,regexp:"\\\\d{1,2}",fn:function(d,f){o&&_t(d,"Month",d.getMonth()-1,n),_t(d,"Date",f,n)}},{pattern:/hh/,regexp:"\\\\d{1,2}",fn:function(d,f){_t(d,"Hours",f,n)}},{pattern:/mm/,regexp:"\\\\d\\\\d",fn:function(d,f){_t(d,"Minutes",f,n)}},{pattern:/ss/,regexp:"\\\\d\\\\d",fn:function(d,f){_t(d,"Seconds",f,n)}},{pattern:/SSS/,regexp:"\\\\d\\\\d\\\\d",fn:function(d,f){_t(d,"Milliseconds",f,n)}},{pattern:/O/,regexp:"[+-]\\\\d{1,2}:?\\\\d{2}?|Z",fn:function(d,f){f==="Z"?f=0:f=f.replace(":","");var g=Math.abs(f),w=(f>0?-1:1)*(g%100+Math.floor(g/100)*60);d.setUTCMinutes(d.getUTCMinutes()+w)}}],s=i.reduce(function(d,f){return f.pattern.test(d.regexp)?(f.index=d.regexp.match(f.pattern).index,d.regexp=d.regexp.replace(f.pattern,"("+f.regexp+")")):f.index=-1,d},{regexp:e,index:[]}),a=i.filter(function(d){return d.index>-1});a.sort(function(d,f){return d.index-f.index});var u=new RegExp(s.regexp),m=u.exec(t);if(m){var l=r||ze.exports.now();return a.forEach(function(d,f){d.fn(l,m[f+1])}),l}throw new Error("String \'"+t+"\' could not be parsed as \'"+e+"\'")}function uw(e,t,r){if(!e)throw new Error("pattern must be supplied");return aw(e,t,r)}function cw(){return new Date}ze.exports=Sl;ze.exports.asString=Sl;ze.exports.parse=uw;ze.exports.now=cw;ze.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS";ze.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO";ze.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS";ze.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"});var Ys=D((iA,kl)=>{var Tt=Jo(),Ol=require("os"),bn=require("util"),yn=require("path"),Dl=require("url"),_l=we()("log4js:layouts"),Tl={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function Nl(e){return e?`\\x1B[${Tl[e][0]}m`:""}function Cl(e){return e?`\\x1B[${Tl[e][1]}m`:""}function lw(e,t){return Nl(t)+e+Cl(t)}function Al(e,t){return lw(bn.format("[%s] [%s] %s - ",Tt.asString(e.startTime),e.level.toString(),e.categoryName),t)}function Rl(e){return Al(e)+bn.format(...e.data)}function Vo(e){return Al(e,e.level.colour)+bn.format(...e.data)}function Fl(e){return bn.format(...e.data)}function $l(e){return e.data[0]}function Pl(e,t){let r="%r %p %c - %m%n",n=/%(-?[0-9]+)?(\\.?-?[0-9]+)?([[\\]cdhmnprzxXyflos%])(\\{([^}]+)\\})?|([^%]+)/;e=e||r;function o(O,$){let R=O.categoryName;if($){let U=parseInt($,10),q=R.split(".");Uq&&(R=W.slice(-q).join(yn.sep))}return R}function k(O){return O.lineNumber?`${O.lineNumber}`:""}function ee(O){return O.columnNumber?`${O.columnNumber}`:""}function xe(O){return O.callStack||""}let A={c:o,d:i,h:s,m:a,n:u,p:m,r:l,"[":d,"]":f,y:x,z:w,"%":g,x:S,X:N,f:M,l:k,o:ee,s:xe};function B(O,$,R){return A[O]($,R)}function L(O,$){let R;return O?(R=parseInt(O.slice(1),10),R>0?$.slice(0,R):$.slice(R)):$}function F(O,$){let R;if(O)if(O.charAt(0)==="-")for(R=parseInt(O.slice(1),10);$.length{var me=Kt(),Ml=["white","grey","black","blue","cyan","green","magenta","red","yellow"],de=class{constructor(t,r,n){this.level=t,this.levelStr=r,this.colour=n}toString(){return this.levelStr}static getLevel(t,r){return t?t instanceof de?t:(t instanceof Object&&t.levelStr&&(t=t.levelStr),de[t.toString().toUpperCase()]||r):r}static addLevels(t){t&&(Object.keys(t).forEach(n=>{let o=n.toUpperCase();de[o]=new de(t[n].value,o,t[n].colour);let i=de.levels.findIndex(s=>s.levelStr===o);i>-1?de.levels[i]=de[o]:de.levels.push(de[o])}),de.levels.sort((n,o)=>n.level-o.level))}isLessThanOrEqualTo(t){return typeof t=="string"&&(t=de.getLevel(t)),this.level<=t.level}isGreaterThanOrEqualTo(t){return typeof t=="string"&&(t=de.getLevel(t)),this.level>=t.level}isEqualTo(t){return typeof t=="string"&&(t=de.getLevel(t)),this.level===t.level}};de.levels=[];de.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}});me.addListener(e=>{let t=e.levels;t&&(me.throwExceptionIf(e,me.not(me.anObject(t)),"levels must be an object"),Object.keys(t).forEach(n=>{me.throwExceptionIf(e,me.not(me.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),me.throwExceptionIf(e,me.not(me.anObject(t[n])),`level "${n}" must be an object`),me.throwExceptionIf(e,me.not(t[n].value),`level "${n}" must have a \'value\' property`),me.throwExceptionIf(e,me.not(me.anInteger(t[n].value)),`level "${n}".value must have an integer value`),me.throwExceptionIf(e,me.not(t[n].colour),`level "${n}" must have a \'colour\' property`),me.throwExceptionIf(e,me.not(Ml.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Ml.join(", ")}`)}))});me.addListener(e=>{de.addLevels(e.levels)});ql.exports=de});var Jl=D(wn=>{"use strict";var{parse:Bl,stringify:Ul}=JSON,{keys:fw}=Object,vn=String,zl="string",jl={},Yo="object",Wl=(e,t)=>t,pw=e=>e instanceof vn?vn(e):e,mw=(e,t)=>typeof t===zl?new vn(t):t,Kl=(e,t,r,n)=>{let o=[];for(let i=fw(r),{length:s}=i,a=0;a{let n=vn(t.push(r)-1);return e.set(r,n),n},Gl=(e,t)=>{let r=Bl(e,mw).map(pw),n=r[0],o=t||Wl,i=typeof n===Yo&&n?Kl(r,new Set,n,o):n;return o.call({"":i},"",i)};wn.parse=Gl;var Hl=(e,t,r)=>{let n=t&&typeof t===Yo?(l,d)=>l===""||-1Bl(Hl(e));wn.toJSON=dw;var hw=e=>Gl(Ul(e));wn.fromJSON=hw});var Zs=D((uA,Zl)=>{var Vl=Jl(),Yl=Ht(),wr=class{constructor(t,r,n,o,i){this.startTime=new Date,this.categoryName=t,this.data=n,this.level=r,this.context=Object.assign({},o),this.pid=process.pid,i&&(this.functionName=i.functionName,this.fileName=i.fileName,this.lineNumber=i.lineNumber,this.columnNumber=i.columnNumber,this.callStack=i.callStack)}serialise(){return Vl.stringify(this,(t,r)=>(r&&r.message&&r.stack?r=Object.assign({message:r.message,stack:r.stack},r):typeof r=="number"&&(Number.isNaN(r)||!Number.isFinite(r))?r=r.toString():typeof r>"u"&&(r=typeof r),r))}static deserialise(t){let r;try{let n=Vl.parse(t,(o,i)=>{if(i&&i.message&&i.stack){let s=new Error(i);Object.keys(i).forEach(a=>{s[a]=i[a]}),i=s}return i});n.location={functionName:n.functionName,fileName:n.fileName,lineNumber:n.lineNumber,columnNumber:n.columnNumber,callStack:n.callStack},r=new wr(n.categoryName,Yl.getLevel(n.level.levelStr),n.data,n.context,n.location),r.startTime=new Date(n.startTime),r.pid=n.pid,r.cluster=n.cluster}catch(n){r=new wr("log4js",Yl.ERROR,["Unable to parse log:",t,"because: ",n])}return r}};Zl.exports=wr});var Qo=D((cA,ef)=>{var We=we()("log4js:clustering"),gw=Zs(),yw=Kt(),xr=!1,Ke=null;try{Ke=require("cluster")}catch{We("cluster module not present"),xr=!0}var Xs=[],En=!1,xn="NODE_APP_INSTANCE",Ql=()=>En&&process.env[xn]==="0",Qs=()=>xr||Ke&&Ke.isMaster||Ql(),Xl=e=>{Xs.forEach(t=>t(e))},Zo=(e,t)=>{if(We("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&t.topic==="log4js:message"){We("received message: ",t.data);let r=gw.deserialise(t.data);Xl(r)}};xr||yw.addListener(e=>{Xs.length=0,{pm2:En,disableClustering:xr,pm2InstanceVar:xn="NODE_APP_INSTANCE"}=e,We(`clustering disabled ? ${xr}`),We(`cluster.isMaster ? ${Ke&&Ke.isMaster}`),We(`pm2 enabled ? ${En}`),We(`pm2InstanceVar = ${xn}`),We(`process.env[${xn}] = ${process.env[xn]}`),En&&process.removeListener("message",Zo),Ke&&Ke.removeListener&&Ke.removeListener("message",Zo),xr||e.disableClustering?We("Not listening for cluster messages, because clustering disabled."):Ql()?(We("listening for PM2 broadcast messages"),process.on("message",Zo)):Ke&&Ke.isMaster?(We("listening for cluster messages"),Ke.on("message",Zo)):We("not listening for messages, because we are not a master process")});ef.exports={onlyOnMaster:(e,t)=>Qs()?e():t,isMaster:Qs,send:e=>{Qs()?Xl(e):(En||(e.cluster={workerId:Ke.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{Xs.push(e)}}});var nf=D((lA,rf)=>{function bw(e){if(typeof e=="number"&&Number.isInteger(e))return e;let t={K:1024,M:1024*1024,G:1024*1024*1024},r=Object.keys(t),n=e.slice(-1).toLocaleUpperCase(),o=e.slice(0,-1).trim();if(r.indexOf(n)<0||!Number.isInteger(Number(o)))throw Error(`maxLogSize: "${e}" is invalid`);return o*t[n]}function vw(e,t){let r=Object.assign({},t);return Object.keys(e).forEach(n=>{r[n]&&(r[n]=e[n](t[n]))}),r}function ea(e){return vw({maxLogSize:bw},e)}var tf={dateFile:ea,file:ea,fileSync:ea};rf.exports.modifyConfig=e=>tf[e.type]?tf[e.type](e):e});var sf=D((fA,of)=>{var ww=console.log.bind(console);function xw(e,t){return r=>{ww(e(r,t))}}function Ew(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),xw(r,e.timezoneOffset)}of.exports.configure=Ew});var uf=D(af=>{function Iw(e,t){return r=>{process.stdout.write(`${e(r,t)}\n`)}}function Sw(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),Iw(r,e.timezoneOffset)}af.configure=Sw});var lf=D((mA,cf)=>{function Ow(e,t){return r=>{process.stderr.write(`${e(r,t)}\n`)}}function Dw(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),Ow(r,e.timezoneOffset)}cf.exports.configure=Dw});var pf=D((dA,ff)=>{function _w(e,t,r,n){let o=n.getLevel(e),i=n.getLevel(t,n.FATAL);return s=>{let a=s.level;o.isLessThanOrEqualTo(a)&&i.isGreaterThanOrEqualTo(a)&&r(s)}}function Tw(e,t,r,n){let o=r(e.appender);return _w(e.level,e.maxLevel,o,n)}ff.exports.configure=Tw});var hf=D((hA,df)=>{var mf=we()("log4js:categoryFilter");function Nw(e,t){return typeof e=="string"&&(e=[e]),r=>{mf(`Checking ${r.categoryName} against ${e}`),e.indexOf(r.categoryName)===-1&&(mf("Not excluded, sending to appender"),t(r))}}function Cw(e,t,r){let n=r(e.appender);return Nw(e.exclude,n)}df.exports.configure=Cw});var bf=D((gA,yf)=>{var gf=we()("log4js:noLogFilter");function Aw(e){return e.filter(r=>r!=null&&r!=="")}function Rw(e,t){return r=>{gf(`Checking data: ${r.data} against filters: ${e}`),typeof e=="string"&&(e=[e]),e=Aw(e);let n=new RegExp(e.join("|"),"i");(e.length===0||r.data.findIndex(o=>n.test(o))<0)&&(gf("Not excluded, sending to appender"),t(r))}}function Fw(e,t,r){let n=r(e.appender);return Rw(e.exclude,n)}yf.exports.configure=Fw});var Ce=D(ta=>{"use strict";ta.fromCallback=function(e){return Object.defineProperty(function(){if(typeof arguments[arguments.length-1]=="function")e.apply(this,arguments);else return new Promise((t,r)=>{arguments[arguments.length]=(n,o)=>{if(n)return r(n);t(o)},arguments.length++,e.apply(this,arguments)})},"name",{value:e.name})};ta.fromPromise=function(e){return Object.defineProperty(function(){let t=arguments[arguments.length-1];if(typeof t!="function")return e.apply(this,arguments);e.apply(this,arguments).then(r=>t(null,r),t)},"name",{value:e.name})}});var wf=D((bA,vf)=>{var Nt=require("constants"),$w=process.cwd,Xo=null,Pw=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return Xo||(Xo=$w.call(process)),Xo};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ra=process.chdir,process.chdir=function(e){Xo=null,ra.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ra));var ra;vf.exports=kw;function kw(e){Nt.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\\.6\\.[0-2]|^v0\\.5\\./)&&t(e),e.lutimes||r(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=u(e.statSync),e.fstatSync=u(e.fstatSync),e.lstatSync=u(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(l,d,f){f&&process.nextTick(f)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(l,d,f,g){g&&process.nextTick(g)},e.lchownSync=function(){}),Pw==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(l){function d(f,g,w){var x=Date.now(),S=0;l(f,g,function N(M){if(M&&(M.code==="EACCES"||M.code==="EPERM"||M.code==="EBUSY")&&Date.now()-x<6e4){setTimeout(function(){e.stat(g,function(k,ee){k&&k.code==="ENOENT"?l(f,g,N):w(M)})},S),S<100&&(S+=10);return}w&&w(M)})}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d}(e.rename)),e.read=typeof e.read!="function"?e.read:function(l){function d(f,g,w,x,S,N){var M;if(N&&typeof N=="function"){var k=0;M=function(ee,xe,A){if(ee&&ee.code==="EAGAIN"&&k<10)return k++,l.call(e,f,g,w,x,S,M);N.apply(this,arguments)}}return l.call(e,f,g,w,x,S,M)}return Object.setPrototypeOf&&Object.setPrototypeOf(d,l),d}(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:function(l){return function(d,f,g,w,x){for(var S=0;;)try{return l.call(e,d,f,g,w,x)}catch(N){if(N.code==="EAGAIN"&&S<10){S++;continue}throw N}}}(e.readSync);function t(l){l.lchmod=function(d,f,g){l.open(d,Nt.O_WRONLY|Nt.O_SYMLINK,f,function(w,x){if(w){g&&g(w);return}l.fchmod(x,f,function(S){l.close(x,function(N){g&&g(S||N)})})})},l.lchmodSync=function(d,f){var g=l.openSync(d,Nt.O_WRONLY|Nt.O_SYMLINK,f),w=!0,x;try{x=l.fchmodSync(g,f),w=!1}finally{if(w)try{l.closeSync(g)}catch{}else l.closeSync(g)}return x}}function r(l){Nt.hasOwnProperty("O_SYMLINK")&&l.futimes?(l.lutimes=function(d,f,g,w){l.open(d,Nt.O_SYMLINK,function(x,S){if(x){w&&w(x);return}l.futimes(S,f,g,function(N){l.close(S,function(M){w&&w(N||M)})})})},l.lutimesSync=function(d,f,g){var w=l.openSync(d,Nt.O_SYMLINK),x,S=!0;try{x=l.futimesSync(w,f,g),S=!1}finally{if(S)try{l.closeSync(w)}catch{}else l.closeSync(w)}return x}):l.futimes&&(l.lutimes=function(d,f,g,w){w&&process.nextTick(w)},l.lutimesSync=function(){})}function n(l){return l&&function(d,f,g){return l.call(e,d,f,function(w){m(w)&&(w=null),g&&g.apply(this,arguments)})}}function o(l){return l&&function(d,f){try{return l.call(e,d,f)}catch(g){if(!m(g))throw g}}}function i(l){return l&&function(d,f,g,w){return l.call(e,d,f,g,function(x){m(x)&&(x=null),w&&w.apply(this,arguments)})}}function s(l){return l&&function(d,f,g){try{return l.call(e,d,f,g)}catch(w){if(!m(w))throw w}}}function a(l){return l&&function(d,f,g){typeof f=="function"&&(g=f,f=null);function w(x,S){S&&(S.uid<0&&(S.uid+=4294967296),S.gid<0&&(S.gid+=4294967296)),g&&g.apply(this,arguments)}return f?l.call(e,d,f,w):l.call(e,d,w)}}function u(l){return l&&function(d,f){var g=f?l.call(e,d,f):l.call(e,d);return g&&(g.uid<0&&(g.uid+=4294967296),g.gid<0&&(g.gid+=4294967296)),g}}function m(l){if(!l||l.code==="ENOSYS")return!0;var d=!process.getuid||process.getuid()!==0;return!!(d&&(l.code==="EINVAL"||l.code==="EPERM"))}}});var If=D((vA,Ef)=>{var xf=require("stream").Stream;Ef.exports=Mw;function Mw(e){return{ReadStream:t,WriteStream:r};function t(n,o){if(!(this instanceof t))return new t(n,o);xf.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,o=o||{};for(var s=Object.keys(o),a=0,u=s.length;athis.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(l,d){if(l){i.emit("error",l),i.readable=!1;return}i.fd=d,i.emit("open",d),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);xf.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};for(var i=Object.keys(o),s=0,a=i.length;s= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Of=D((wA,Sf)=>{"use strict";Sf.exports=jw;var qw=Object.getPrototypeOf||function(e){return e.__proto__};function jw(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:qw(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var he=D((xA,ia)=>{var ae=require("fs"),Lw=wf(),Bw=If(),Uw=Of(),ei=require("util"),Ee,ri;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Ee=Symbol.for("graceful-fs.queue"),ri=Symbol.for("graceful-fs.previous")):(Ee="___graceful-fs.queue",ri="___graceful-fs.previous");function zw(){}function Tf(e,t){Object.defineProperty(e,Ee,{get:function(){return t}})}var Jt=zw;ei.debuglog?Jt=ei.debuglog("gfs4"):/\\bgfs4\\b/i.test(process.env.NODE_DEBUG||"")&&(Jt=function(){var e=ei.format.apply(ei,arguments);e="GFS4: "+e.split(/\\n/).join(`\nGFS4: `),console.error(e)});ae[Ee]||(Df=global[Ee]||[],Tf(ae,Df),ae.close=function(e){function t(r,n){return e.call(ae,r,function(o){o||_f(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,ri,{value:e}),t}(ae.close),ae.closeSync=function(e){function t(r){e.apply(ae,arguments),_f()}return Object.defineProperty(t,ri,{value:e}),t}(ae.closeSync),/\\bgfs4\\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Jt(ae[Ee]),require("assert").equal(ae[Ee].length,0)}));var Df;global[Ee]||Tf(global,ae[Ee]);ia.exports=na(Uw(ae));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ae.__patched&&(ia.exports=na(ae),ae.__patched=!0);function na(e){Lw(e),e.gracefulify=na,e.createReadStream=xe,e.createWriteStream=A;var t=e.readFile;e.readFile=r;function r(F,j,O){return typeof j=="function"&&(O=j,j=null),$(F,j,O);function $(R,U,q,W){return t(R,U,function(K){K&&(K.code==="EMFILE"||K.code==="ENFILE")?Er([$,[R,U,q],K,W||Date.now(),Date.now()]):typeof q=="function"&&q.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=o;function o(F,j,O,$){return typeof O=="function"&&($=O,O=null),R(F,j,O,$);function R(U,q,W,K,X){return n(U,q,W,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?Er([R,[U,q,W,K],J,X||Date.now(),Date.now()]):typeof K=="function"&&K.apply(this,arguments)})}}var i=e.appendFile;i&&(e.appendFile=s);function s(F,j,O,$){return typeof O=="function"&&($=O,O=null),R(F,j,O,$);function R(U,q,W,K,X){return i(U,q,W,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?Er([R,[U,q,W,K],J,X||Date.now(),Date.now()]):typeof K=="function"&&K.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=u);function u(F,j,O,$){return typeof O=="function"&&($=O,O=0),R(F,j,O,$);function R(U,q,W,K,X){return a(U,q,W,function(J){J&&(J.code==="EMFILE"||J.code==="ENFILE")?Er([R,[U,q,W,K],J,X||Date.now(),Date.now()]):typeof K=="function"&&K.apply(this,arguments)})}}var m=e.readdir;e.readdir=d;var l=/^v[0-5]\\./;function d(F,j,O){typeof j=="function"&&(O=j,j=null);var $=l.test(process.version)?function(q,W,K,X){return m(q,R(q,W,K,X))}:function(q,W,K,X){return m(q,W,R(q,W,K,X))};return $(F,j,O);function R(U,q,W,K){return function(X,J){X&&(X.code==="EMFILE"||X.code==="ENFILE")?Er([$,[U,q,W],X,K||Date.now(),Date.now()]):(J&&J.sort&&J.sort(),typeof W=="function"&&W.call(this,X,J))}}}if(process.version.substr(0,4)==="v0.8"){var f=Bw(e);N=f.ReadStream,k=f.WriteStream}var g=e.ReadStream;g&&(N.prototype=Object.create(g.prototype),N.prototype.open=M);var w=e.WriteStream;w&&(k.prototype=Object.create(w.prototype),k.prototype.open=ee),Object.defineProperty(e,"ReadStream",{get:function(){return N},set:function(F){N=F},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return k},set:function(F){k=F},enumerable:!0,configurable:!0});var x=N;Object.defineProperty(e,"FileReadStream",{get:function(){return x},set:function(F){x=F},enumerable:!0,configurable:!0});var S=k;Object.defineProperty(e,"FileWriteStream",{get:function(){return S},set:function(F){S=F},enumerable:!0,configurable:!0});function N(F,j){return this instanceof N?(g.apply(this,arguments),this):N.apply(Object.create(N.prototype),arguments)}function M(){var F=this;L(F.path,F.flags,F.mode,function(j,O){j?(F.autoClose&&F.destroy(),F.emit("error",j)):(F.fd=O,F.emit("open",O),F.read())})}function k(F,j){return this instanceof k?(w.apply(this,arguments),this):k.apply(Object.create(k.prototype),arguments)}function ee(){var F=this;L(F.path,F.flags,F.mode,function(j,O){j?(F.destroy(),F.emit("error",j)):(F.fd=O,F.emit("open",O))})}function xe(F,j){return new e.ReadStream(F,j)}function A(F,j){return new e.WriteStream(F,j)}var B=e.open;e.open=L;function L(F,j,O,$){return typeof O=="function"&&($=O,O=null),R(F,j,O,$);function R(U,q,W,K,X){return B(U,q,W,function(J,Zn){J&&(J.code==="EMFILE"||J.code==="ENFILE")?Er([R,[U,q,W,K],J,X||Date.now(),Date.now()]):typeof K=="function"&&K.apply(this,arguments)})}}return e}function Er(e){Jt("ENQUEUE",e[0].name,e[1]),ae[Ee].push(e),oa()}var ti;function _f(){for(var e=Date.now(),t=0;t2&&(ae[Ee][t][3]=e,ae[Ee][t][4]=e);oa()}function oa(){if(clearTimeout(ti),ti=void 0,ae[Ee].length!==0){var e=ae[Ee].shift(),t=e[0],r=e[1],n=e[2],o=e[3],i=e[4];if(o===void 0)Jt("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-o>=6e4){Jt("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-i,u=Math.max(i-o,1),m=Math.min(u*1.2,100);a>=m?(Jt("RETRY",t.name,r),t.apply(null,r.concat([o]))):ae[Ee].push(e)}ti===void 0&&(ti=setTimeout(oa,0))}}});var sa=D(Vt=>{"use strict";var Nf=Ce().fromCallback,Ge=he(),Ww=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof Ge[e]=="function");Object.keys(Ge).forEach(e=>{e!=="promises"&&(Vt[e]=Ge[e])});Ww.forEach(e=>{Vt[e]=Nf(Ge[e])});Vt.exists=function(e,t){return typeof t=="function"?Ge.exists(e,t):new Promise(r=>Ge.exists(e,r))};Vt.read=function(e,t,r,n,o,i){return typeof i=="function"?Ge.read(e,t,r,n,o,i):new Promise((s,a)=>{Ge.read(e,t,r,n,o,(u,m,l)=>{if(u)return a(u);s({bytesRead:m,buffer:l})})})};Vt.write=function(e,t,...r){return typeof r[r.length-1]=="function"?Ge.write(e,t,...r):new Promise((n,o)=>{Ge.write(e,t,...r,(i,s,a)=>{if(i)return o(i);n({bytesWritten:s,buffer:a})})})};typeof Ge.realpath.native=="function"&&(Vt.realpath.native=Nf(Ge.realpath.native))});var ua=D((IA,Af)=>{"use strict";var aa=require("path");function Cf(e){return e=aa.normalize(aa.resolve(e)).split(aa.sep),e.length>0?e[0]:null}var Kw=/[<>:"|?*]/;function Gw(e){let t=Cf(e);return e=e.replace(t,""),Kw.test(e)}Af.exports={getRootPath:Cf,invalidWin32Path:Gw}});var Ff=D((SA,Rf)=>{"use strict";var Hw=he(),ca=require("path"),Jw=ua().invalidWin32Path,Vw=parseInt("0777",8);function la(e,t,r,n){if(typeof t=="function"?(r=t,t={}):(!t||typeof t!="object")&&(t={mode:t}),process.platform==="win32"&&Jw(e)){let s=new Error(e+" contains invalid WIN32 path characters.");return s.code="EINVAL",r(s)}let o=t.mode,i=t.fs||Hw;o===void 0&&(o=Vw&~process.umask()),n||(n=null),r=r||function(){},e=ca.resolve(e),i.mkdir(e,o,s=>{if(!s)return n=n||e,r(null,n);switch(s.code){case"ENOENT":if(ca.dirname(e)===e)return r(s);la(ca.dirname(e),t,(a,u)=>{a?r(a,u):la(e,t,r,u)});break;default:i.stat(e,(a,u)=>{a||!u.isDirectory()?r(s,n):r(null,n)});break}})}Rf.exports=la});var Pf=D((OA,$f)=>{"use strict";var Yw=he(),fa=require("path"),Zw=ua().invalidWin32Path,Qw=parseInt("0777",8);function pa(e,t,r){(!t||typeof t!="object")&&(t={mode:t});let n=t.mode,o=t.fs||Yw;if(process.platform==="win32"&&Zw(e)){let i=new Error(e+" contains invalid WIN32 path characters.");throw i.code="EINVAL",i}n===void 0&&(n=Qw&~process.umask()),r||(r=null),e=fa.resolve(e);try{o.mkdirSync(e,n),r=r||e}catch(i){if(i.code==="ENOENT"){if(fa.dirname(e)===e)throw i;r=pa(fa.dirname(e),t,r),pa(e,t,r)}else{let s;try{s=o.statSync(e)}catch{throw i}if(!s.isDirectory())throw i}}return r}$f.exports=pa});var $e=D((DA,kf)=>{"use strict";var Xw=Ce().fromCallback,ma=Xw(Ff()),da=Pf();kf.exports={mkdirs:ma,mkdirsSync:da,mkdirp:ma,mkdirpSync:da,ensureDir:ma,ensureDirSync:da}});var ha=D((_A,qf)=>{"use strict";var Se=he(),Mf=require("os"),ni=require("path");function ex(){let e=ni.join("millis-test-sync"+Date.now().toString()+Math.random().toString().slice(2));e=ni.join(Mf.tmpdir(),e);let t=new Date(1435410243862);Se.writeFileSync(e,"https://github.com/jprichardson/node-fs-extra/pull/141");let r=Se.openSync(e,"r+");return Se.futimesSync(r,t,t),Se.closeSync(r),Se.statSync(e).mtime>1435410243e3}function tx(e){let t=ni.join("millis-test"+Date.now().toString()+Math.random().toString().slice(2));t=ni.join(Mf.tmpdir(),t);let r=new Date(1435410243862);Se.writeFile(t,"https://github.com/jprichardson/node-fs-extra/pull/141",n=>{if(n)return e(n);Se.open(t,"r+",(o,i)=>{if(o)return e(o);Se.futimes(i,r,r,s=>{if(s)return e(s);Se.close(i,a=>{if(a)return e(a);Se.stat(t,(u,m)=>{if(u)return e(u);e(null,m.mtime>1435410243e3)})})})})})}function rx(e){if(typeof e=="number")return Math.floor(e/1e3)*1e3;if(e instanceof Date)return new Date(Math.floor(e.getTime()/1e3)*1e3);throw new Error("fs-extra: timeRemoveMillis() unknown parameter type")}function nx(e,t,r,n){Se.open(e,"r+",(o,i)=>{if(o)return n(o);Se.futimes(i,t,r,s=>{Se.close(i,a=>{n&&n(s||a)})})})}function ox(e,t,r){let n=Se.openSync(e,"r+");return Se.futimesSync(n,t,r),Se.closeSync(n)}qf.exports={hasMillisRes:tx,hasMillisResSync:ex,timeRemoveMillis:rx,utimesMillis:nx,utimesMillisSync:ox}});var On=D((TA,Wf)=>{"use strict";var He=he(),Ae=require("path"),jf=10,Lf=5,ix=0,ya=process.versions.node.split("."),Bf=Number.parseInt(ya[0],10),Uf=Number.parseInt(ya[1],10),sx=Number.parseInt(ya[2],10);function In(){if(Bf>jf)return!0;if(Bf===jf){if(Uf>Lf)return!0;if(Uf===Lf&&sx>=ix)return!0}return!1}function ax(e,t,r){In()?He.stat(e,{bigint:!0},(n,o)=>{if(n)return r(n);He.stat(t,{bigint:!0},(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))}):He.stat(e,(n,o)=>{if(n)return r(n);He.stat(t,(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))})}function ux(e,t){let r,n;In()?r=He.statSync(e,{bigint:!0}):r=He.statSync(e);try{In()?n=He.statSync(t,{bigint:!0}):n=He.statSync(t)}catch(o){if(o.code==="ENOENT")return{srcStat:r,destStat:null};throw o}return{srcStat:r,destStat:n}}function cx(e,t,r,n){ax(e,t,(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;return a&&a.ino&&a.dev&&a.ino===s.ino&&a.dev===s.dev?n(new Error("Source and destination must not be the same.")):s.isDirectory()&&ba(e,t)?n(new Error(Sn(e,t,r))):n(null,{srcStat:s,destStat:a})})}function lx(e,t,r){let{srcStat:n,destStat:o}=ux(e,t);if(o&&o.ino&&o.dev&&o.ino===n.ino&&o.dev===n.dev)throw new Error("Source and destination must not be the same.");if(n.isDirectory()&&ba(e,t))throw new Error(Sn(e,t,r));return{srcStat:n,destStat:o}}function ga(e,t,r,n,o){let i=Ae.resolve(Ae.dirname(e)),s=Ae.resolve(Ae.dirname(r));if(s===i||s===Ae.parse(s).root)return o();In()?He.stat(s,{bigint:!0},(a,u)=>a?a.code==="ENOENT"?o():o(a):u.ino&&u.dev&&u.ino===t.ino&&u.dev===t.dev?o(new Error(Sn(e,r,n))):ga(e,t,s,n,o)):He.stat(s,(a,u)=>a?a.code==="ENOENT"?o():o(a):u.ino&&u.dev&&u.ino===t.ino&&u.dev===t.dev?o(new Error(Sn(e,r,n))):ga(e,t,s,n,o))}function zf(e,t,r,n){let o=Ae.resolve(Ae.dirname(e)),i=Ae.resolve(Ae.dirname(r));if(i===o||i===Ae.parse(i).root)return;let s;try{In()?s=He.statSync(i,{bigint:!0}):s=He.statSync(i)}catch(a){if(a.code==="ENOENT")return;throw a}if(s.ino&&s.dev&&s.ino===t.ino&&s.dev===t.dev)throw new Error(Sn(e,r,n));return zf(e,t,i,n)}function ba(e,t){let r=Ae.resolve(e).split(Ae.sep).filter(o=>o),n=Ae.resolve(t).split(Ae.sep).filter(o=>o);return r.reduce((o,i,s)=>o&&n[s]===i,!0)}function Sn(e,t,r){return`Cannot ${r} \'${e}\' to a subdirectory of itself, \'${t}\'.`}Wf.exports={checkPaths:cx,checkPathsSync:lx,checkParentPaths:ga,checkParentPathsSync:zf,isSrcSubdir:ba}});var Gf=D((NA,Kf)=>{"use strict";Kf.exports=function(e){if(typeof Buffer.allocUnsafe=="function")try{return Buffer.allocUnsafe(e)}catch{return new Buffer(e)}return new Buffer(e)}});var Zf=D((CA,Yf)=>{"use strict";var ne=he(),Dn=require("path"),fx=$e().mkdirsSync,px=ha().utimesMillisSync,_n=On();function mx(e,t,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`);let{srcStat:n,destStat:o}=_n.checkPathsSync(e,t,"copy");return _n.checkParentPathsSync(e,n,t,"copy"),dx(o,e,t,r)}function dx(e,t,r,n){if(n.filter&&!n.filter(t,r))return;let o=Dn.dirname(r);return ne.existsSync(o)||fx(o),Hf(e,t,r,n)}function Hf(e,t,r,n){if(!(n.filter&&!n.filter(t,r)))return hx(e,t,r,n)}function hx(e,t,r,n){let i=(n.dereference?ne.statSync:ne.lstatSync)(t);if(i.isDirectory())return vx(i,e,t,r,n);if(i.isFile()||i.isCharacterDevice()||i.isBlockDevice())return gx(i,e,t,r,n);if(i.isSymbolicLink())return Ex(e,t,r,n)}function gx(e,t,r,n,o){return t?yx(e,r,n,o):Jf(e,r,n,o)}function yx(e,t,r,n){if(n.overwrite)return ne.unlinkSync(r),Jf(e,t,r,n);if(n.errorOnExist)throw new Error(`\'${r}\' already exists`)}function Jf(e,t,r,n){return typeof ne.copyFileSync=="function"?(ne.copyFileSync(t,r),ne.chmodSync(r,e.mode),n.preserveTimestamps?px(r,e.atime,e.mtime):void 0):bx(e,t,r,n)}function bx(e,t,r,n){let i=Gf()(65536),s=ne.openSync(t,"r"),a=ne.openSync(r,"w",e.mode),u=0;for(;uxx(n,e,t,r))}function xx(e,t,r,n){let o=Dn.join(t,e),i=Dn.join(r,e),{destStat:s}=_n.checkPathsSync(o,i,"copy");return Hf(s,o,i,n)}function Ex(e,t,r,n){let o=ne.readlinkSync(t);if(n.dereference&&(o=Dn.resolve(process.cwd(),o)),e){let i;try{i=ne.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return ne.symlinkSync(o,r);throw s}if(n.dereference&&(i=Dn.resolve(process.cwd(),i)),_n.isSrcSubdir(o,i))throw new Error(`Cannot copy \'${o}\' to a subdirectory of itself, \'${i}\'.`);if(ne.statSync(r).isDirectory()&&_n.isSrcSubdir(i,o))throw new Error(`Cannot overwrite \'${i}\' with \'${o}\'.`);return Ix(o,r)}else return ne.symlinkSync(o,r)}function Ix(e,t){return ne.unlinkSync(t),ne.symlinkSync(e,t)}Yf.exports=mx});var va=D((AA,Qf)=>{"use strict";Qf.exports={copySync:Zf()}});var it=D((RA,ep)=>{"use strict";var Sx=Ce().fromPromise,Xf=sa();function Ox(e){return Xf.access(e).then(()=>!0).catch(()=>!1)}ep.exports={pathExists:Sx(Ox),pathExistsSync:Xf.existsSync}});var cp=D((FA,up)=>{"use strict";var Ie=he(),Tn=require("path"),Dx=$e().mkdirs,_x=it().pathExists,Tx=ha().utimesMillis,Nn=On();function Nx(e,t,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`),Nn.checkPaths(e,t,"copy",(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;Nn.checkParentPaths(e,s,t,"copy",u=>u?n(u):r.filter?np(tp,a,e,t,r,n):tp(a,e,t,r,n))})}function tp(e,t,r,n,o){let i=Tn.dirname(r);_x(i,(s,a)=>{if(s)return o(s);if(a)return wa(e,t,r,n,o);Dx(i,u=>u?o(u):wa(e,t,r,n,o))})}function np(e,t,r,n,o,i){Promise.resolve(o.filter(r,n)).then(s=>s?e(t,r,n,o,i):i(),s=>i(s))}function wa(e,t,r,n,o){return n.filter?np(rp,e,t,r,n,o):rp(e,t,r,n,o)}function rp(e,t,r,n,o){(n.dereference?Ie.stat:Ie.lstat)(t,(s,a)=>{if(s)return o(s);if(a.isDirectory())return Fx(a,e,t,r,n,o);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return Cx(a,e,t,r,n,o);if(a.isSymbolicLink())return kx(e,t,r,n,o)})}function Cx(e,t,r,n,o,i){return t?Ax(e,r,n,o,i):op(e,r,n,o,i)}function Ax(e,t,r,n,o){if(n.overwrite)Ie.unlink(r,i=>i?o(i):op(e,t,r,n,o));else return n.errorOnExist?o(new Error(`\'${r}\' already exists`)):o()}function op(e,t,r,n,o){return typeof Ie.copyFile=="function"?Ie.copyFile(t,r,i=>i?o(i):ip(e,r,n,o)):Rx(e,t,r,n,o)}function Rx(e,t,r,n,o){let i=Ie.createReadStream(t);i.on("error",s=>o(s)).once("open",()=>{let s=Ie.createWriteStream(r,{mode:e.mode});s.on("error",a=>o(a)).on("open",()=>i.pipe(s)).once("close",()=>ip(e,r,n,o))})}function ip(e,t,r,n){Ie.chmod(t,e.mode,o=>o?n(o):r.preserveTimestamps?Tx(t,e.atime,e.mtime,n):n())}function Fx(e,t,r,n,o,i){return t?t&&!t.isDirectory()?i(new Error(`Cannot overwrite non-directory \'${n}\' with directory \'${r}\'.`)):sp(r,n,o,i):$x(e,r,n,o,i)}function $x(e,t,r,n,o){Ie.mkdir(r,i=>{if(i)return o(i);sp(t,r,n,s=>s?o(s):Ie.chmod(r,e.mode,o))})}function sp(e,t,r,n){Ie.readdir(e,(o,i)=>o?n(o):ap(i,e,t,r,n))}function ap(e,t,r,n,o){let i=e.pop();return i?Px(e,i,t,r,n,o):o()}function Px(e,t,r,n,o,i){let s=Tn.join(r,t),a=Tn.join(n,t);Nn.checkPaths(s,a,"copy",(u,m)=>{if(u)return i(u);let{destStat:l}=m;wa(l,s,a,o,d=>d?i(d):ap(e,r,n,o,i))})}function kx(e,t,r,n,o){Ie.readlink(t,(i,s)=>{if(i)return o(i);if(n.dereference&&(s=Tn.resolve(process.cwd(),s)),e)Ie.readlink(r,(a,u)=>a?a.code==="EINVAL"||a.code==="UNKNOWN"?Ie.symlink(s,r,o):o(a):(n.dereference&&(u=Tn.resolve(process.cwd(),u)),Nn.isSrcSubdir(s,u)?o(new Error(`Cannot copy \'${s}\' to a subdirectory of itself, \'${u}\'.`)):e.isDirectory()&&Nn.isSrcSubdir(u,s)?o(new Error(`Cannot overwrite \'${u}\' with \'${s}\'.`)):Mx(s,r,o)));else return Ie.symlink(s,r,o)})}function Mx(e,t,r){Ie.unlink(t,n=>n?r(n):Ie.symlink(e,t,r))}up.exports=Nx});var xa=D(($A,lp)=>{"use strict";var qx=Ce().fromCallback;lp.exports={copy:qx(cp())}});var vp=D((PA,bp)=>{"use strict";var fp=he(),hp=require("path"),G=require("assert"),Cn=process.platform==="win32";function gp(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(r=>{e[r]=e[r]||fp[r],r=r+"Sync",e[r]=e[r]||fp[r]}),e.maxBusyTries=e.maxBusyTries||3}function Ea(e,t,r){let n=0;typeof t=="function"&&(r=t,t={}),G(e,"rimraf: missing path"),G.strictEqual(typeof e,"string","rimraf: path should be a string"),G.strictEqual(typeof r,"function","rimraf: callback function required"),G(t,"rimraf: invalid options argument provided"),G.strictEqual(typeof t,"object","rimraf: options should be object"),gp(t),pp(e,t,function o(i){if(i){if((i.code==="EBUSY"||i.code==="ENOTEMPTY"||i.code==="EPERM")&&npp(e,t,o),s)}i.code==="ENOENT"&&(i=null)}r(i)})}function pp(e,t,r){G(e),G(t),G(typeof r=="function"),t.lstat(e,(n,o)=>{if(n&&n.code==="ENOENT")return r(null);if(n&&n.code==="EPERM"&&Cn)return mp(e,t,n,r);if(o&&o.isDirectory())return oi(e,t,n,r);t.unlink(e,i=>{if(i){if(i.code==="ENOENT")return r(null);if(i.code==="EPERM")return Cn?mp(e,t,i,r):oi(e,t,i,r);if(i.code==="EISDIR")return oi(e,t,i,r)}return r(i)})})}function mp(e,t,r,n){G(e),G(t),G(typeof n=="function"),r&&G(r instanceof Error),t.chmod(e,438,o=>{o?n(o.code==="ENOENT"?null:r):t.stat(e,(i,s)=>{i?n(i.code==="ENOENT"?null:r):s.isDirectory()?oi(e,t,r,n):t.unlink(e,n)})})}function dp(e,t,r){let n;G(e),G(t),r&&G(r instanceof Error);try{t.chmodSync(e,438)}catch(o){if(o.code==="ENOENT")return;throw r}try{n=t.statSync(e)}catch(o){if(o.code==="ENOENT")return;throw r}n.isDirectory()?ii(e,t,r):t.unlinkSync(e)}function oi(e,t,r,n){G(e),G(t),r&&G(r instanceof Error),G(typeof n=="function"),t.rmdir(e,o=>{o&&(o.code==="ENOTEMPTY"||o.code==="EEXIST"||o.code==="EPERM")?jx(e,t,n):o&&o.code==="ENOTDIR"?n(r):n(o)})}function jx(e,t,r){G(e),G(t),G(typeof r=="function"),t.readdir(e,(n,o)=>{if(n)return r(n);let i=o.length,s;if(i===0)return t.rmdir(e,r);o.forEach(a=>{Ea(hp.join(e,a),t,u=>{if(!s){if(u)return r(s=u);--i===0&&t.rmdir(e,r)}})})})}function yp(e,t){let r;t=t||{},gp(t),G(e,"rimraf: missing path"),G.strictEqual(typeof e,"string","rimraf: path should be a string"),G(t,"rimraf: missing options"),G.strictEqual(typeof t,"object","rimraf: options should be object");try{r=t.lstatSync(e)}catch(n){if(n.code==="ENOENT")return;n.code==="EPERM"&&Cn&&dp(e,t,n)}try{r&&r.isDirectory()?ii(e,t,null):t.unlinkSync(e)}catch(n){if(n.code==="ENOENT")return;if(n.code==="EPERM")return Cn?dp(e,t,n):ii(e,t,n);if(n.code!=="EISDIR")throw n;ii(e,t,n)}}function ii(e,t,r){G(e),G(t),r&&G(r instanceof Error);try{t.rmdirSync(e)}catch(n){if(n.code==="ENOTDIR")throw r;if(n.code==="ENOTEMPTY"||n.code==="EEXIST"||n.code==="EPERM")Lx(e,t);else if(n.code!=="ENOENT")throw n}}function Lx(e,t){if(G(e),G(t),t.readdirSync(e).forEach(r=>yp(hp.join(e,r),t)),Cn){let r=Date.now();do try{return t.rmdirSync(e,t)}catch{}while(Date.now()-r<500)}else return t.rmdirSync(e,t)}bp.exports=Ea;Ea.sync=yp});var An=D((kA,xp)=>{"use strict";var Bx=Ce().fromCallback,wp=vp();xp.exports={remove:Bx(wp),removeSync:wp.sync}});var Np=D((MA,Tp)=>{"use strict";var Ux=Ce().fromCallback,Sp=he(),Op=require("path"),Dp=$e(),_p=An(),Ep=Ux(function(t,r){r=r||function(){},Sp.readdir(t,(n,o)=>{if(n)return Dp.mkdirs(t,r);o=o.map(s=>Op.join(t,s)),i();function i(){let s=o.pop();if(!s)return r();_p.remove(s,a=>{if(a)return r(a);i()})}})});function Ip(e){let t;try{t=Sp.readdirSync(e)}catch{return Dp.mkdirsSync(e)}t.forEach(r=>{r=Op.join(e,r),_p.removeSync(r)})}Tp.exports={emptyDirSync:Ip,emptydirSync:Ip,emptyDir:Ep,emptydir:Ep}});var Fp=D((qA,Rp)=>{"use strict";var zx=Ce().fromCallback,Cp=require("path"),Rn=he(),Ap=$e(),Wx=it().pathExists;function Kx(e,t){function r(){Rn.writeFile(e,"",n=>{if(n)return t(n);t()})}Rn.stat(e,(n,o)=>{if(!n&&o.isFile())return t();let i=Cp.dirname(e);Wx(i,(s,a)=>{if(s)return t(s);if(a)return r();Ap.mkdirs(i,u=>{if(u)return t(u);r()})})})}function Gx(e){let t;try{t=Rn.statSync(e)}catch{}if(t&&t.isFile())return;let r=Cp.dirname(e);Rn.existsSync(r)||Ap.mkdirsSync(r),Rn.writeFileSync(e,"")}Rp.exports={createFile:zx(Kx),createFileSync:Gx}});var qp=D((jA,Mp)=>{"use strict";var Hx=Ce().fromCallback,Pp=require("path"),Yt=he(),kp=$e(),$p=it().pathExists;function Jx(e,t,r){function n(o,i){Yt.link(o,i,s=>{if(s)return r(s);r(null)})}$p(t,(o,i)=>{if(o)return r(o);if(i)return r(null);Yt.lstat(e,s=>{if(s)return s.message=s.message.replace("lstat","ensureLink"),r(s);let a=Pp.dirname(t);$p(a,(u,m)=>{if(u)return r(u);if(m)return n(e,t);kp.mkdirs(a,l=>{if(l)return r(l);n(e,t)})})})})}function Vx(e,t){if(Yt.existsSync(t))return;try{Yt.lstatSync(e)}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}let n=Pp.dirname(t);return Yt.existsSync(n)||kp.mkdirsSync(n),Yt.linkSync(e,t)}Mp.exports={createLink:Hx(Jx),createLinkSync:Vx}});var Lp=D((LA,jp)=>{"use strict";var Ct=require("path"),Fn=he(),Yx=it().pathExists;function Zx(e,t,r){if(Ct.isAbsolute(e))return Fn.lstat(e,n=>n?(n.message=n.message.replace("lstat","ensureSymlink"),r(n)):r(null,{toCwd:e,toDst:e}));{let n=Ct.dirname(t),o=Ct.join(n,e);return Yx(o,(i,s)=>i?r(i):s?r(null,{toCwd:o,toDst:e}):Fn.lstat(e,a=>a?(a.message=a.message.replace("lstat","ensureSymlink"),r(a)):r(null,{toCwd:e,toDst:Ct.relative(n,e)})))}}function Qx(e,t){let r;if(Ct.isAbsolute(e)){if(r=Fn.existsSync(e),!r)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}else{let n=Ct.dirname(t),o=Ct.join(n,e);if(r=Fn.existsSync(o),r)return{toCwd:o,toDst:e};if(r=Fn.existsSync(e),!r)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:Ct.relative(n,e)}}}jp.exports={symlinkPaths:Zx,symlinkPathsSync:Qx}});var zp=D((BA,Up)=>{"use strict";var Bp=he();function Xx(e,t,r){if(r=typeof t=="function"?t:r,t=typeof t=="function"?!1:t,t)return r(null,t);Bp.lstat(e,(n,o)=>{if(n)return r(null,"file");t=o&&o.isDirectory()?"dir":"file",r(null,t)})}function e0(e,t){let r;if(t)return t;try{r=Bp.lstatSync(e)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}Up.exports={symlinkType:Xx,symlinkTypeSync:e0}});var Yp=D((UA,Vp)=>{"use strict";var t0=Ce().fromCallback,Kp=require("path"),Ir=he(),Gp=$e(),r0=Gp.mkdirs,n0=Gp.mkdirsSync,Hp=Lp(),o0=Hp.symlinkPaths,i0=Hp.symlinkPathsSync,Jp=zp(),s0=Jp.symlinkType,a0=Jp.symlinkTypeSync,Wp=it().pathExists;function u0(e,t,r,n){n=typeof r=="function"?r:n,r=typeof r=="function"?!1:r,Wp(t,(o,i)=>{if(o)return n(o);if(i)return n(null);o0(e,t,(s,a)=>{if(s)return n(s);e=a.toDst,s0(a.toCwd,r,(u,m)=>{if(u)return n(u);let l=Kp.dirname(t);Wp(l,(d,f)=>{if(d)return n(d);if(f)return Ir.symlink(e,t,m,n);r0(l,g=>{if(g)return n(g);Ir.symlink(e,t,m,n)})})})})})}function c0(e,t,r){if(Ir.existsSync(t))return;let o=i0(e,t);e=o.toDst,r=a0(o.toCwd,r);let i=Kp.dirname(t);return Ir.existsSync(i)||n0(i),Ir.symlinkSync(e,t,r)}Vp.exports={createSymlink:t0(u0),createSymlinkSync:c0}});var Qp=D((zA,Zp)=>{"use strict";var si=Fp(),ai=qp(),ui=Yp();Zp.exports={createFile:si.createFile,createFileSync:si.createFileSync,ensureFile:si.createFile,ensureFileSync:si.createFileSync,createLink:ai.createLink,createLinkSync:ai.createLinkSync,ensureLink:ai.createLink,ensureLinkSync:ai.createLinkSync,createSymlink:ui.createSymlink,createSymlinkSync:ui.createSymlinkSync,ensureSymlink:ui.createSymlink,ensureSymlinkSync:ui.createSymlinkSync}});var rm=D((WA,tm)=>{var Sr;try{Sr=he()}catch{Sr=require("fs")}function l0(e,t,r){r==null&&(r=t,t={}),typeof t=="string"&&(t={encoding:t}),t=t||{};var n=t.fs||Sr,o=!0;"throws"in t&&(o=t.throws),n.readFile(e,t,function(i,s){if(i)return r(i);s=em(s);var a;try{a=JSON.parse(s,t?t.reviver:null)}catch(u){return o?(u.message=e+": "+u.message,r(u)):r(null,null)}r(null,a)})}function f0(e,t){t=t||{},typeof t=="string"&&(t={encoding:t});var r=t.fs||Sr,n=!0;"throws"in t&&(n=t.throws);try{var o=r.readFileSync(e,t);return o=em(o),JSON.parse(o,t.reviver)}catch(i){if(n)throw i.message=e+": "+i.message,i;return null}}function Xp(e,t){var r,n=`\n`;typeof t=="object"&&t!==null&&(t.spaces&&(r=t.spaces),t.EOL&&(n=t.EOL));var o=JSON.stringify(e,t?t.replacer:null,r);return o.replace(/\\n/g,n)+n}function p0(e,t,r,n){n==null&&(n=r,r={}),r=r||{};var o=r.fs||Sr,i="";try{i=Xp(t,r)}catch(s){n&&n(s,null);return}o.writeFile(e,i,r,n)}function m0(e,t,r){r=r||{};var n=r.fs||Sr,o=Xp(t,r);return n.writeFileSync(e,o,r)}function em(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\\uFEFF/,""),e}var d0={readFile:l0,readFileSync:f0,writeFile:p0,writeFileSync:m0};tm.exports=d0});var li=D((KA,om)=>{"use strict";var nm=Ce().fromCallback,ci=rm();om.exports={readJson:nm(ci.readFile),readJsonSync:ci.readFileSync,writeJson:nm(ci.writeFile),writeJsonSync:ci.writeFileSync}});var am=D((GA,sm)=>{"use strict";var h0=require("path"),g0=$e(),y0=it().pathExists,im=li();function b0(e,t,r,n){typeof r=="function"&&(n=r,r={});let o=h0.dirname(e);y0(o,(i,s)=>{if(i)return n(i);if(s)return im.writeJson(e,t,r,n);g0.mkdirs(o,a=>{if(a)return n(a);im.writeJson(e,t,r,n)})})}sm.exports=b0});var cm=D((HA,um)=>{"use strict";var v0=he(),w0=require("path"),x0=$e(),E0=li();function I0(e,t,r){let n=w0.dirname(e);v0.existsSync(n)||x0.mkdirsSync(n),E0.writeJsonSync(e,t,r)}um.exports=I0});var fm=D((JA,lm)=>{"use strict";var S0=Ce().fromCallback,De=li();De.outputJson=S0(am());De.outputJsonSync=cm();De.outputJSON=De.outputJson;De.outputJSONSync=De.outputJsonSync;De.writeJSON=De.writeJson;De.writeJSONSync=De.writeJsonSync;De.readJSON=De.readJson;De.readJSONSync=De.readJsonSync;lm.exports=De});var ym=D((VA,gm)=>{"use strict";var dm=he(),O0=require("path"),D0=va().copySync,hm=An().removeSync,_0=$e().mkdirpSync,pm=On();function T0(e,t,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:o}=pm.checkPathsSync(e,t,"move");return pm.checkParentPathsSync(e,o,t,"move"),_0(O0.dirname(t)),N0(e,t,n)}function N0(e,t,r){if(r)return hm(t),mm(e,t,r);if(dm.existsSync(t))throw new Error("dest already exists.");return mm(e,t,r)}function mm(e,t,r){try{dm.renameSync(e,t)}catch(n){if(n.code!=="EXDEV")throw n;return C0(e,t,r)}}function C0(e,t,r){return D0(e,t,{overwrite:r,errorOnExist:!0}),hm(e)}gm.exports=T0});var vm=D((YA,bm)=>{"use strict";bm.exports={moveSync:ym()}});var Sm=D((ZA,Im)=>{"use strict";var A0=he(),R0=require("path"),F0=xa().copy,Em=An().remove,$0=$e().mkdirp,P0=it().pathExists,wm=On();function k0(e,t,r,n){typeof r=="function"&&(n=r,r={});let o=r.overwrite||r.clobber||!1;wm.checkPaths(e,t,"move",(i,s)=>{if(i)return n(i);let{srcStat:a}=s;wm.checkParentPaths(e,a,t,"move",u=>{if(u)return n(u);$0(R0.dirname(t),m=>m?n(m):M0(e,t,o,n))})})}function M0(e,t,r,n){if(r)return Em(t,o=>o?n(o):xm(e,t,r,n));P0(t,(o,i)=>o?n(o):i?n(new Error("dest already exists.")):xm(e,t,r,n))}function xm(e,t,r,n){A0.rename(e,t,o=>o?o.code!=="EXDEV"?n(o):q0(e,t,r,n):n())}function q0(e,t,r,n){F0(e,t,{overwrite:r,errorOnExist:!0},i=>i?n(i):Em(e,n))}Im.exports=k0});var Dm=D((QA,Om)=>{"use strict";var j0=Ce().fromCallback;Om.exports={move:j0(Sm())}});var Cm=D((XA,Nm)=>{"use strict";var L0=Ce().fromCallback,$n=he(),_m=require("path"),Tm=$e(),B0=it().pathExists;function U0(e,t,r,n){typeof r=="function"&&(n=r,r="utf8");let o=_m.dirname(e);B0(o,(i,s)=>{if(i)return n(i);if(s)return $n.writeFile(e,t,r,n);Tm.mkdirs(o,a=>{if(a)return n(a);$n.writeFile(e,t,r,n)})})}function z0(e,...t){let r=_m.dirname(e);if($n.existsSync(r))return $n.writeFileSync(e,...t);Tm.mkdirsSync(r),$n.writeFileSync(e,...t)}Nm.exports={outputFile:L0(U0),outputFileSync:z0}});var Sa=D((eR,Ia)=>{"use strict";Ia.exports=Object.assign({},sa(),va(),xa(),Np(),Qp(),fm(),$e(),vm(),Dm(),Cm(),it(),An());var Am=require("fs");Object.getOwnPropertyDescriptor(Am,"promises")&&Object.defineProperty(Ia.exports,"promises",{get(){return Am.promises}})});var Fm=D((tR,Rm)=>{Rm.exports=()=>new Date});var Pm=D((rR,$m)=>{var W0=we()("streamroller:fileNameFormatter"),K0=require("path"),G0=".gz",H0=".";$m.exports=({file:e,keepFileExt:t,needsIndex:r,alwaysIncludeDate:n,compress:o,fileNameSep:i})=>{let s=i||H0,a=K0.join(e.dir,e.name),u=g=>g+e.ext,m=(g,w,x)=>(r||!x)&&w?g+s+w:g,l=(g,w,x)=>(w>0||n)&&x?g+s+x:g,d=(g,w)=>w&&o?g+G0:g,f=t?[l,m,u,d]:[u,l,m,d];return({date:g,index:w})=>(W0(`_formatFileName: date=${g}, index=${w}`),f.reduce((x,S)=>S(x,w,g),a))}});var jm=D((nR,qm)=>{var Zt=we()("streamroller:fileNameParser"),km=".gz",Mm=Jo(),J0=".";qm.exports=({file:e,keepFileExt:t,pattern:r,fileNameSep:n})=>{let o=n||J0,i=(f,g)=>f.endsWith(km)?(Zt("it is gzipped"),g.isCompressed=!0,f.slice(0,-1*km.length)):f,s="__NOT_MATCHING__",d=[i,t?f=>f.startsWith(e.name)&&f.endsWith(e.ext)?(Zt("it starts and ends with the right things"),f.slice(e.name.length+1,-1*e.ext.length)):s:f=>f.startsWith(e.base)?(Zt("it starts with the right things"),f.slice(e.base.length+1)):s,r?(f,g)=>{let w=f.split(o),x=w[w.length-1];Zt("items: ",w,", indexStr: ",x);let S=f;x!==void 0&&x.match(/^\\d+$/)?(S=f.slice(0,-1*(x.length+1)),Zt(`dateStr is ${S}`),r&&!S&&(S=x,x="0")):x="0";try{let N=Mm.parse(r,S,new Date(0,0));return Mm.asString(r,N)!==S?f:(g.index=parseInt(x,10),g.date=S,g.timestamp=N.getTime(),"")}catch(N){return Zt(`Problem parsing ${S} as ${r}, error was: `,N),f}}:(f,g)=>f.match(/^\\d+$/)?(Zt("it has an index"),g.index=parseInt(f,10),""):f];return f=>{let g={filename:f,index:0,isCompressed:!1};return d.reduce((x,S)=>S(x,g),f)?null:g}}});var Bm=D((oR,Lm)=>{var Re=we()("streamroller:moveAndMaybeCompressFile"),gt=Sa(),V0=require("zlib"),Y0=function(e){let t={mode:parseInt("0600",8),compress:!1},r=Object.assign({},t,e);return Re(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(r)}`),r},Z0=async(e,t,r)=>{if(r=Y0(r),e===t){Re("moveAndMaybeCompressFile: source and target are the same, not doing anything");return}if(await gt.pathExists(e))if(Re(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${r.compress?"with":"without"} compress`),r.compress)await new Promise((n,o)=>{let i=!1,s=gt.createWriteStream(t,{mode:r.mode,flags:"wx"}).on("open",()=>{i=!0;let a=gt.createReadStream(e).on("open",()=>{a.pipe(V0.createGzip()).pipe(s)}).on("error",u=>{Re(`moveAndMaybeCompressFile: error reading ${e}`,u),s.destroy(u)})}).on("finish",()=>{Re(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),gt.unlink(e).then(n).catch(a=>{Re(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,a),gt.truncate(e).then(n).catch(u=>{Re(`moveAndMaybeCompressFile: error truncating ${e}`,u),o(u)})})}).on("error",a=>{i?(Re(`moveAndMaybeCompressFile: error writing ${t}, deleting`,a),gt.unlink(t).then(()=>{o(a)}).catch(u=>{Re(`moveAndMaybeCompressFile: error deleting ${t}`,u),o(u)})):(Re(`moveAndMaybeCompressFile: error creating ${t}`,a),o(a))})}).catch(()=>{});else{Re(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await gt.move(e,t,{overwrite:!0})}catch(n){if(Re(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),n.code!=="ENOENT"){Re("moveAndMaybeCompressFile: trying copy+truncate instead");try{await gt.copy(e,t,{overwrite:!0}),await gt.truncate(e)}catch(o){Re("moveAndMaybeCompressFile: error copy+truncate",o)}}}}};Lm.exports=Z0});var mi=D((iR,Um)=>{var Pe=we()("streamroller:RollingFileWriteStream"),Xt=Sa(),Qt=require("path"),Q0=require("os"),fi=Fm(),pi=Jo(),{Writable:X0}=require("stream"),eE=Pm(),tE=jm(),rE=Bm(),nE=e=>(Pe(`deleteFiles: files to delete: ${e}`),Promise.all(e.map(t=>Xt.unlink(t).catch(r=>{Pe(`deleteFiles: error when unlinking ${t}, ignoring. Error was ${r}`)})))),Oa=class extends X0{constructor(t,r){if(Pe(`constructor: creating RollingFileWriteStream. path=${t}`),typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(Qt.sep))throw new Error(`Filename is a directory: ${t}`);t.indexOf(`~${Qt.sep}`)===0&&(t=t.replace("~",Q0.homedir())),super(r),this.options=this._parseOption(r),this.fileObject=Qt.parse(t),this.fileObject.dir===""&&(this.fileObject=Qt.parse(Qt.join(process.cwd(),t))),this.fileFormatter=eE({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`);if(n.numBackups||n.numBackups===0){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return Pe(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(t){this.currentFileStream.end("",this.options.encoding,t)}_write(t,r,n){this._shouldRoll().then(()=>{Pe(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${t}`),this.currentFileStream.write(t,r,o=>{this.state.currentSize+=t.length,n(o)})})}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(Pe(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==pi(this.options.pattern,fi())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return Pe("_roll: closing the current stream"),new Promise((t,r)=>{this.currentFileStream.end("",this.options.encoding,()=>{this._moveOldFiles().then(t).catch(r)})})}async _moveOldFiles(){let t=await this._getExistingFiles(),r=this.state.currentDate?t.filter(n=>n.date===this.state.currentDate):t;for(let n=r.length;n>=0;n--){Pe(`_moveOldFiles: i = ${n}`);let o=this.fileFormatter({date:this.state.currentDate,index:n}),i=this.fileFormatter({date:this.state.currentDate,index:n+1}),s={compress:this.options.compress&&n===0,mode:this.options.mode};await rE(o,i,s)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?pi(this.options.pattern,fi()):null,Pe(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise((n,o)=>{this.currentFileStream.write("","utf8",()=>{this._clean().then(n).catch(o)})})}async _getExistingFiles(){let t=await Xt.readdir(this.fileObject.dir).catch(()=>[]);Pe(`_getExistingFiles: files=${t}`);let r=t.map(o=>this.fileNameParser(o)).filter(o=>o),n=o=>(o.timestamp?o.timestamp:fi().getTime())-o.index;return r.sort((o,i)=>n(o)-n(i)),r}_renewWriteStream(){let t=this.fileFormatter({date:this.state.currentDate,index:0}),r=i=>{try{return Xt.mkdirSync(i,{recursive:!0})}catch(s){if(s.code==="ENOENT")return r(Qt.dirname(i)),r(i);if(s.code!=="EEXIST"&&s.code!=="EROFS")throw s;try{if(Xt.statSync(i).isDirectory())return i;throw s}catch{throw s}}};r(this.fileObject.dir);let n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode},o=function(i,s,a){return i[a]=i[s],delete i[s],i};Xt.appendFileSync(t,"",o({...n},"flags","flag")),this.currentFileStream=Xt.createWriteStream(t,n),this.currentFileStream.on("error",i=>{this.emit("error",i)})}async _clean(){let t=await this._getExistingFiles();if(Pe(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${t.length}`),Pe("_clean: existing files are: ",t),this._tooManyFiles(t.length)){let r=t.slice(0,t.length-this.options.numToKeep).map(n=>Qt.format({dir:this.fileObject.dir,base:n.filename}));await nE(r)}}_tooManyFiles(t){return this.options.numToKeep>0&&t>this.options.numToKeep}};Um.exports=Oa});var Wm=D((sR,zm)=>{var oE=mi(),Da=class extends oE{constructor(t,r,n,o){o||(o={}),r&&(o.maxSize=r),!o.numBackups&&o.numBackups!==0&&(!n&&n!==0&&(n=1),o.numBackups=n),super(t,o),this.backups=o.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};zm.exports=Da});var Gm=D((aR,Km)=>{var iE=mi(),_a=class extends iE{constructor(t,r,n){r&&typeof r=="object"&&(n=r,r=null),n||(n={}),r||(r="yyyy-MM-dd"),n.pattern=r,!n.numBackups&&n.numBackups!==0?(!n.daysToKeep&&n.daysToKeep!==0?n.daysToKeep=1:process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"),n.numBackups=n.daysToKeep):n.daysToKeep=n.numBackups,super(t,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}};Km.exports=_a});var Ta=D((uR,Hm)=>{Hm.exports={RollingFileWriteStream:mi(),RollingFileStream:Wm(),DateRollingFileStream:Gm()}});var Qm=D((cR,Zm)=>{var Jm=we()("log4js:file"),Na=require("path"),sE=Ta(),Ym=require("os"),aE=Ym.EOL,di=!1,hi=new Set;function Vm(){hi.forEach(e=>{e.sighupHandler()})}function uE(e,t,r,n,o,i){if(typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Na.sep))throw new Error(`Filename is a directory: ${e}`);e=e.replace(new RegExp(`^~(?=${Na.sep}.+)`),Ym.homedir()),e=Na.normalize(e),n=!n&&n!==0?5:n,Jm("Creating file appender (",e,", ",r,", ",n,", ",o,", ",i,")");function s(m,l,d,f){let g=new sE.RollingFileStream(m,l,d,f);return g.on("error",w=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",m,w)}),g.on("drain",()=>{process.emit("log4js:pause",!1)}),g}let a=s(e,r,n,o),u=function(m){if(a.writable){if(o.removeColor===!0){let l=/\\x1b[[0-9;]*m/g;m.data=m.data.map(d=>typeof d=="string"?d.replace(l,""):d)}a.write(t(m,i)+aE,"utf8")||process.emit("log4js:pause",!0)}};return u.reopen=function(){a.end(()=>{a=s(e,r,n,o)})},u.sighupHandler=function(){Jm("SIGHUP handler called."),u.reopen()},u.shutdown=function(m){hi.delete(u),hi.size===0&&di&&(process.removeListener("SIGHUP",Vm),di=!1),a.end("","utf-8",m)},hi.add(u),di||(process.on("SIGHUP",Vm),di=!0),u}function cE(e,t){let r=t.basicLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,uE(e.filename,r,e.maxLogSize,e.backups,e,e.timezoneOffset)}Zm.exports.configure=cE});var ed=D((lR,Xm)=>{var lE=Ta(),fE=require("os"),pE=fE.EOL;function mE(e,t,r){let n=new lE.DateRollingFileStream(e,t,r);return n.on("error",o=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,o)}),n.on("drain",()=>{process.emit("log4js:pause",!1)}),n}function dE(e,t,r,n,o){n.maxSize=n.maxLogSize;let i=mE(e,t,n),s=function(a){i.writable&&(i.write(r(a,o)+pE,"utf8")||process.emit("log4js:pause",!0))};return s.shutdown=function(a){i.end("","utf-8",a)},s}function hE(e,t){let r=t.basicLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,dE(e.filename,e.pattern,r,e,e.timezoneOffset)}Xm.exports.configure=hE});var od=D((fR,nd)=>{var yt=we()("log4js:fileSync"),at=require("path"),st=require("fs"),td=require("os"),gE=td.EOL;function rd(e,t){let r=n=>{try{return st.mkdirSync(n,{recursive:!0})}catch(o){if(o.code==="ENOENT")return r(at.dirname(n)),r(n);if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;try{if(st.statSync(n).isDirectory())return n;throw o}catch{throw o}}};r(at.dirname(e)),st.appendFileSync(e,"",{mode:t.mode,flag:t.flags})}var Ca=class{constructor(t,r,n,o){if(yt("In RollingFileStream"),r<0)throw new Error(`maxLogSize (${r}) should be > 0`);this.filename=t,this.size=r,this.backups=n,this.options=o,this.currentSize=0;function i(s){let a=0;try{a=st.statSync(s).size}catch{rd(s,o)}return a}this.currentSize=i(this.filename)}shouldRoll(){return yt("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(t){let r=this,n=new RegExp(`^${at.basename(t)}`);function o(m){return n.test(m)}function i(m){return parseInt(m.slice(`${at.basename(t)}.`.length),10)||0}function s(m,l){return i(m)-i(l)}function a(m){let l=i(m);if(yt(`Index of ${m} is ${l}`),r.backups===0)st.truncateSync(t,0);else if(l ${t}.${l+1}`),st.renameSync(at.join(at.dirname(t),m),`${t}.${l+1}`)}}function u(){yt("Renaming the old files"),st.readdirSync(at.dirname(t)).filter(o).sort(s).reverse().forEach(a)}yt("Rolling, rolling, rolling"),u()}write(t,r){let n=this;function o(){yt("writing the chunk to the file"),n.currentSize+=t.length,st.appendFileSync(n.filename,t)}yt("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),o()}};function yE(e,t,r,n,o,i){if(typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(at.sep))throw new Error(`Filename is a directory: ${e}`);e=e.replace(new RegExp(`^~(?=${at.sep}.+)`),td.homedir()),e=at.normalize(e),n=!n&&n!==0?5:n,yt("Creating fileSync appender (",e,", ",r,", ",n,", ",o,", ",i,")");function s(u,m,l){let d;return m?d=new Ca(u,m,l,o):d=(f=>(rd(f,o),{write(g){st.appendFileSync(f,g)}}))(u),d}let a=s(e,r,n);return u=>{a.write(t(u,i)+gE)}}function bE(e,t){let r=t.basicLayout;e.layout&&(r=t.layout(e.layout.type,e.layout));let n={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return yE(e.filename,r,e.maxLogSize,e.backups,n,e.timezoneOffset)}nd.exports.configure=bE});var sd=D((pR,id)=>{var ut=we()("log4js:tcp"),vE=require("net");function wE(e,t){let r=!1,n=[],o,i=3,s="__LOG4JS__";function a(d){ut("Writing log event to socket"),r=o.write(`${t(d)}${s}`,"utf8")}function u(){let d;for(ut("emptying buffer");d=n.shift();)a(d)}function m(){ut(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),s=`${e.endMsg||"__LOG4JS__"}`,o=vE.createConnection(e.port||5e3,e.host||"localhost"),o.on("connect",()=>{ut("socket connected"),u(),r=!0}),o.on("drain",()=>{ut("drain event received, emptying buffer"),r=!0,u()}),o.on("timeout",o.end.bind(o)),o.on("error",d=>{ut("connection error",d),r=!1,u()}),o.on("close",m)}m();function l(d){r?a(d):(ut("buffering log event because it cannot write at the moment"),n.push(d))}return l.shutdown=function(d){ut("shutdown called"),n.length&&i?(ut("buffer has items, waiting 100ms to empty"),i-=1,setTimeout(()=>{l.shutdown(d)},100)):(o.removeAllListeners("close"),o.end(d))},l}function xE(e,t){ut(`configure with config = ${e}`);let r=function(n){return n.serialise()};return e.layout&&(r=t.layout(e.layout.type,e.layout)),wE(e,r)}id.exports.configure=xE});var Fa=D((mR,Ra)=>{var Aa=require("path"),At=we()("log4js:appenders"),Je=Kt(),ad=Qo(),EE=Ht(),IE=Ys(),SE=nf(),Qe=new Map;Qe.set("console",sf());Qe.set("stdout",uf());Qe.set("stderr",lf());Qe.set("logLevelFilter",pf());Qe.set("categoryFilter",hf());Qe.set("noLogFilter",bf());Qe.set("file",Qm());Qe.set("dateFile",ed());Qe.set("fileSync",od());Qe.set("tcp",sd());var Pn=new Map,gi=(e,t)=>{let r;try{let n=`${e}.cjs`;r=require.resolve(n),At("Loading module from ",n)}catch{r=e,At("Loading module from ",e)}try{return require(r)}catch(n){Je.throwExceptionIf(t,n.code!=="MODULE_NOT_FOUND",`appender "${e}" could not be loaded (error was: ${n})`);return}},OE=(e,t)=>Qe.get(e)||gi(`./${e}`,t)||gi(e,t)||require.main&&require.main.filename&&gi(Aa.join(Aa.dirname(require.main.filename),e),t)||gi(Aa.join(process.cwd(),e),t),yi=new Set,ud=(e,t)=>{if(Pn.has(e))return Pn.get(e);if(!t.appenders[e])return!1;if(yi.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);yi.add(e),At(`Creating appender ${e}`);let r=DE(e,t);return yi.delete(e),Pn.set(e,r),r},DE=(e,t)=>{let r=t.appenders[e],n=r.type.configure?r.type:OE(r.type,t);return Je.throwExceptionIf(t,Je.not(n),`appender "${e}" is not valid (type "${r.type}" could not be found)`),n.appender&&(process.emitWarning(`Appender ${r.type} exports an appender function.`,"DeprecationWarning","log4js-node-DEP0001"),At("[log4js-node-DEP0001]",`DEPRECATION: Appender ${r.type} exports an appender function.`)),n.shutdown&&(process.emitWarning(`Appender ${r.type} exports a shutdown function.`,"DeprecationWarning","log4js-node-DEP0002"),At("[log4js-node-DEP0002]",`DEPRECATION: Appender ${r.type} exports a shutdown function.`)),At(`${e}: clustering.isMaster ? ${ad.isMaster()}`),At(`${e}: appenderModule is ${require("util").inspect(n)}`),ad.onlyOnMaster(()=>(At(`calling appenderModule.configure for ${e} / ${r.type}`),n.configure(SE.modifyConfig(r),IE,o=>ud(o,t),EE)),()=>{})},cd=e=>{if(Pn.clear(),yi.clear(),!e)return;let t=[];Object.values(e.categories).forEach(r=>{t.push(...r.appenders)}),Object.keys(e.appenders).forEach(r=>{(t.includes(r)||e.appenders[r].type==="tcp-server"||e.appenders[r].type==="multiprocess")&&ud(r,e)})},ld=()=>{cd()};ld();Je.addListener(e=>{Je.throwExceptionIf(e,Je.not(Je.anObject(e.appenders)),\'must have a property "appenders" of type object.\');let t=Object.keys(e.appenders);Je.throwExceptionIf(e,Je.not(t.length),"must define at least one appender."),t.forEach(r=>{Je.throwExceptionIf(e,Je.not(e.appenders[r].type),`appender "${r}" is not valid (must be an object with property "type")`)})});Je.addListener(cd);Ra.exports=Pn;Ra.exports.init=ld});var ka=D((dR,bi)=>{var kn=we()("log4js:categories"),ue=Kt(),$a=Ht(),fd=Fa(),Rt=new Map;function pd(e,t,r){if(t.inherit===!1)return;let n=r.lastIndexOf(".");if(n<0)return;let o=r.slice(0,n),i=e.categories[o];i||(i={inherit:!0,appenders:[]}),pd(e,i,o),!e.categories[o]&&i.appenders&&i.appenders.length&&i.level&&(e.categories[o]=i),t.appenders=t.appenders||[],t.level=t.level||i.level,i.appenders.forEach(s=>{t.appenders.includes(s)||t.appenders.push(s)}),t.parent=i}function _E(e){if(!e.categories)return;Object.keys(e.categories).forEach(r=>{let n=e.categories[r];pd(e,n,r)})}ue.addPreProcessingListener(e=>_E(e));ue.addListener(e=>{ue.throwExceptionIf(e,ue.not(ue.anObject(e.categories)),\'must have a property "categories" of type object.\');let t=Object.keys(e.categories);ue.throwExceptionIf(e,ue.not(t.length),"must define at least one category."),t.forEach(r=>{let n=e.categories[r];ue.throwExceptionIf(e,[ue.not(n.appenders),ue.not(n.level)],`category "${r}" is not valid (must be an object with properties "appenders" and "level")`),ue.throwExceptionIf(e,ue.not(Array.isArray(n.appenders)),`category "${r}" is not valid (appenders must be an array of appender names)`),ue.throwExceptionIf(e,ue.not(n.appenders.length),`category "${r}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(n,"enableCallStack")&&ue.throwExceptionIf(e,typeof n.enableCallStack!="boolean",`category "${r}" is not valid (enableCallStack must be boolean type)`),n.appenders.forEach(o=>{ue.throwExceptionIf(e,ue.not(fd.get(o)),`category "${r}" is not valid (appender "${o}" is not defined)`)}),ue.throwExceptionIf(e,ue.not($a.getLevel(n.level)),`category "${r}" is not valid (level "${n.level}" not recognised; valid levels are ${$a.levels.join(", ")})`)}),ue.throwExceptionIf(e,ue.not(e.categories.default),\'must define a "default" category.\')});var Pa=e=>{if(Rt.clear(),!e)return;Object.keys(e.categories).forEach(r=>{let n=e.categories[r],o=[];n.appenders.forEach(i=>{o.push(fd.get(i)),kn(`Creating category ${r}`),Rt.set(r,{appenders:o,level:$a.getLevel(n.level),enableCallStack:n.enableCallStack||!1})})})},md=()=>{Pa()};md();ue.addListener(Pa);var Or=e=>{if(kn(`configForCategory: searching for config for ${e}`),Rt.has(e))return kn(`configForCategory: ${e} exists in config, returning it`),Rt.get(e);let t;return e.indexOf(".")>0?(kn(`configForCategory: ${e} has hierarchy, cloning from parents`),t={...Or(e.slice(0,e.lastIndexOf(".")))}):(Rt.has("default")||Pa({categories:{default:{appenders:["out"],level:"OFF"}}}),kn("configForCategory: cloning default category"),t={...Rt.get("default")}),Rt.set(e,t),t},TE=e=>Or(e).appenders,NE=e=>Or(e).level,CE=(e,t)=>{Or(e).level=t},AE=e=>Or(e).enableCallStack===!0,RE=(e,t)=>{Or(e).enableCallStack=t};bi.exports=Rt;bi.exports=Object.assign(bi.exports,{appendersForCategory:TE,getLevelForCategory:NE,setLevelForCategory:CE,getEnableCallStackForCategory:AE,setEnableCallStackForCategory:RE,init:md})});var bd=D((hR,yd)=>{var dd=we()("log4js:logger"),FE=Zs(),ct=Ht(),$E=Qo(),vi=ka(),hd=Kt(),PE=/at (?:(.+)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/;function kE(e,t=4){try{let r=e.stack.split(`\n`).slice(t),n=PE.exec(r[0]);if(n&&n.length===6)return{functionName:n[1],fileName:n[2],lineNumber:parseInt(n[3],10),columnNumber:parseInt(n[4],10),callStack:r.join(`\n`)};console.error("log4js.logger - defaultParseCallStack error")}catch(r){console.error("log4js.logger - defaultParseCallStack error",r)}return null}var Mn=class{constructor(t){if(!t)throw new Error("No category provided.");this.category=t,this.context={},this.parseCallStack=kE,dd(`Logger created (${this.category}, ${this.level})`)}get level(){return ct.getLevel(vi.getLevelForCategory(this.category),ct.OFF)}set level(t){vi.setLevelForCategory(this.category,ct.getLevel(t,this.level))}get useCallStack(){return vi.getEnableCallStackForCategory(this.category)}set useCallStack(t){vi.setEnableCallStackForCategory(this.category,t===!0)}log(t,...r){let n=ct.getLevel(t);n?this.isLevelEnabled(n)&&this._log(n,r):hd.validIdentifier(t)&&r.length>0?(this.log(ct.WARN,"log4js:logger.log: valid log-level not found as first parameter given:",t),this.log(ct.INFO,`[${t}]`,...r)):this.log(ct.INFO,t,...r)}isLevelEnabled(t){return this.level.isLessThanOrEqualTo(t)}_log(t,r){dd(`sending log data (${t}) to appenders`);let n=new FE(this.category,t,r,this.context,this.useCallStack&&this.parseCallStack(new Error));$E.send(n)}addContext(t,r){this.context[t]=r}removeContext(t){delete this.context[t]}clearContext(){this.context={}}setParseCallStackFunction(t){this.parseCallStack=t}};function gd(e){let t=ct.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,i=>i[1].toUpperCase()),o=n[0].toUpperCase()+n.slice(1);Mn.prototype[`is${o}Enabled`]=function(){return this.isLevelEnabled(t)},Mn.prototype[n]=function(...i){this.log(t,...i)}}ct.levels.forEach(gd);hd.addListener(()=>{ct.levels.forEach(gd)});yd.exports=Mn});var xd=D((gR,wd)=>{var Dr=Ht(),ME=\':remote-addr - - ":method :url HTTP/:http-version" :status :content-length ":referrer" ":user-agent"\';function qE(e){return e.originalUrl||e.url}function jE(e,t,r){let n=i=>{let s=i.concat();for(let a=0;an.source?n.source:n);t=new RegExp(r.join("|"))}return t}function BE(e,t,r){let n=t;if(r){let o=r.find(i=>{let s=!1;return i.from&&i.to?s=e>=i.from&&e<=i.to:s=i.codes.indexOf(e)!==-1,s});o&&(n=Dr.getLevel(o.level,n))}return n}wd.exports=function(t,r){typeof r=="string"||typeof r=="function"?r={format:r}:r=r||{};let n=t,o=Dr.getLevel(r.level,Dr.INFO),i=r.format||ME;return(s,a,u)=>{if(s._logging!==void 0)return u();if(typeof r.nolog!="function"){let m=LE(r.nolog);if(m&&m.test(s.originalUrl))return u()}if(n.isLevelEnabled(o)||r.level==="auto"){let m=new Date,{writeHead:l}=a;s._logging=!0,a.writeHead=(g,w)=>{a.writeHead=l,a.writeHead(g,w),a.__statusCode=g,a.__headers=w||{}};let d=!1,f=()=>{if(d)return;if(d=!0,typeof r.nolog=="function"&&r.nolog(s,a)===!0){s._logging=!1;return}a.responseTime=new Date-m,a.statusCode&&r.level==="auto"&&(o=Dr.INFO,a.statusCode>=300&&(o=Dr.WARN),a.statusCode>=400&&(o=Dr.ERROR)),o=BE(a.statusCode,o,r.statusRules);let g=jE(s,a,r.tokens||[]);if(r.context&&n.addContext("res",a),typeof i=="function"){let w=i(s,a,x=>vd(x,g));w&&n.log(o,w)}else n.log(o,vd(i,g));r.context&&n.removeContext("res")};a.on("end",f),a.on("finish",f),a.on("error",f),a.on("close",f)}return u()}}});var Dd=D((yR,Od)=>{var Ed=we()("log4js:recording"),wi=[];function UE(){return function(e){Ed(`received logEvent, number of events now ${wi.length+1}`),Ed("log event was ",e),wi.push(e)}}function Id(){return wi.slice()}function Sd(){wi.length=0}Od.exports={configure:UE,replay:Id,playback:Id,reset:Sd,erase:Sd}});var Fd=D((bR,Rd)=>{var Ft=we()("log4js:main"),zE=require("fs"),WE=bl()({proto:!0}),KE=Kt(),GE=Ys(),HE=Ht(),_d=Fa(),Td=ka(),JE=bd(),VE=Qo(),YE=xd(),ZE=Dd(),qn=!1;function QE(e){if(!qn)return;Ft("Received log event ",e),Td.appendersForCategory(e.categoryName).forEach(r=>{r(e)})}function XE(e){Ft(`Loading configuration from ${e}`);try{return JSON.parse(zE.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}function Nd(e){qn&&Cd();let t=e;return typeof t=="string"&&(t=XE(e)),Ft(`Configuration is ${t}`),KE.configure(WE(t)),VE.onMessage(QE),qn=!0,Ad}function eI(){return ZE}function Cd(e){Ft("Shutdown called. Disabling all log writing."),qn=!1;let t=Array.from(_d.values());_d.init(),Td.init();let r=t.reduceRight((s,a)=>a.shutdown?s+1:s,0);if(r===0)return Ft("No appenders with shutdown functions found."),e!==void 0&&e();let n=0,o;Ft(`Found ${r} appenders with shutdown functions.`);function i(s){o=o||s,n+=1,Ft(`Appender shutdowns complete: ${n} / ${r}`),n>=r&&(Ft("All shutdown functions completed."),e&&e(o))}return t.filter(s=>s.shutdown).forEach(s=>s.shutdown(i)),null}function tI(e){return qn||Nd(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new JE(e||"default")}var Ad={getLogger:tI,configure:Nd,shutdown:Cd,connectLogger:YE,levels:HE,addLayout:GE.addLayout,recording:eI};Rd.exports=Ad});var lt=D(Ei=>{"use strict";Ei.getBooleanOption=(e,t)=>{let r=!1;if(t in e&&typeof(r=e[t])!="boolean")throw new TypeError(`Expected the "${t}" option to be a boolean`);return r};Ei.cppdb=Symbol();Ei.inspect=Symbol.for("nodejs.util.inspect.custom")});var ja=D((ER,kd)=>{"use strict";var qa={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function er(e,t){if(new.target!==er)return new er(e,t);if(typeof t!="string")throw new TypeError("Expected second argument to be a string");Error.call(this,e),qa.value=""+e,Object.defineProperty(this,"message",qa),Error.captureStackTrace(this,er),this.code=t}Object.setPrototypeOf(er,Error);Object.setPrototypeOf(er.prototype,Error.prototype);Object.defineProperty(er.prototype,"name",qa);kd.exports=er});var qd=D((IR,Md)=>{var Ii=require("path").sep||"/";Md.exports=nI;function nI(e){if(typeof e!="string"||e.length<=7||e.substring(0,7)!="file://")throw new TypeError("must pass in a file:// URI to convert to a file path");var t=decodeURI(e.substring(7)),r=t.indexOf("/"),n=t.substring(0,r),o=t.substring(r+1);return n=="localhost"&&(n=""),n&&(n=Ii+Ii+n),o=o.replace(/^(.+)\\|/,"$1:"),Ii=="\\\\"&&(o=o.replace(/\\//g,"\\\\")),/^.+\\:/.test(o)||(o=Ii+o),n+o}});var Ud=D((_r,Bd)=>{var La=require("fs"),Oi=require("path"),oI=qd(),Si=Oi.join,iI=Oi.dirname,jd=La.accessSync&&function(e){try{La.accessSync(e)}catch{return!1}return!0}||La.existsSync||Oi.existsSync,Ld={arrow:process.env.NODE_BINDINGS_ARROW||" \\u2192 ",compiled:process.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:process.platform,arch:process.arch,nodePreGyp:"node-v"+process.versions.modules+"-"+process.platform+"-"+process.arch,version:process.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"],["module_root","addon-build","release","install-root","bindings"],["module_root","addon-build","debug","install-root","bindings"],["module_root","addon-build","default","install-root","bindings"],["module_root","lib","binding","nodePreGyp","bindings"]]};function sI(e){typeof e=="string"?e={bindings:e}:e||(e={}),Object.keys(Ld).map(function(u){u in e||(e[u]=Ld[u])}),e.module_root||(e.module_root=_r.getRoot(_r.getFileName())),Oi.extname(e.bindings)!=".node"&&(e.bindings+=".node");for(var t=typeof __webpack_require__=="function"?__non_webpack_require__:require,r=[],n=0,o=e.try.length,i,s,a;n{"use strict";var{cppdb:Xe}=lt();$t.prepare=function(t){return this[Xe].prepare(t,this,!1)};$t.exec=function(t){return this[Xe].exec(t),this};$t.close=function(){return this[Xe].close(),this};$t.loadExtension=function(...t){return this[Xe].loadExtension(...t),this};$t.defaultSafeIntegers=function(...t){return this[Xe].defaultSafeIntegers(...t),this};$t.unsafeMode=function(...t){return this[Xe].unsafeMode(...t),this};$t.getters={name:{get:function(){return this[Xe].name},enumerable:!0},open:{get:function(){return this[Xe].open},enumerable:!0},inTransaction:{get:function(){return this[Xe].inTransaction},enumerable:!0},readonly:{get:function(){return this[Xe].readonly},enumerable:!0},memory:{get:function(){return this[Xe].memory},enumerable:!0}}});var Gd=D((OR,Kd)=>{"use strict";var{cppdb:aI}=lt(),Wd=new WeakMap;Kd.exports=function(t){if(typeof t!="function")throw new TypeError("Expected first argument to be a function");let r=this[aI],n=uI(r,this),{apply:o}=Function.prototype,i={default:{value:Di(o,t,r,n.default)},deferred:{value:Di(o,t,r,n.deferred)},immediate:{value:Di(o,t,r,n.immediate)},exclusive:{value:Di(o,t,r,n.exclusive)},database:{value:this,enumerable:!0}};return Object.defineProperties(i.default.value,i),Object.defineProperties(i.deferred.value,i),Object.defineProperties(i.immediate.value,i),Object.defineProperties(i.exclusive.value,i),i.default.value};var uI=(e,t)=>{let r=Wd.get(e);if(!r){let n={commit:e.prepare("COMMIT",t,!1),rollback:e.prepare("ROLLBACK",t,!1),savepoint:e.prepare("SAVEPOINT ` _bs3. `",t,!1),release:e.prepare("RELEASE ` _bs3. `",t,!1),rollbackTo:e.prepare("ROLLBACK TO ` _bs3. `",t,!1)};Wd.set(e,r={default:Object.assign({begin:e.prepare("BEGIN",t,!1)},n),deferred:Object.assign({begin:e.prepare("BEGIN DEFERRED",t,!1)},n),immediate:Object.assign({begin:e.prepare("BEGIN IMMEDIATE",t,!1)},n),exclusive:Object.assign({begin:e.prepare("BEGIN EXCLUSIVE",t,!1)},n)})}return r},Di=(e,t,r,{begin:n,commit:o,rollback:i,savepoint:s,release:a,rollbackTo:u})=>function(){let l,d,f;r.inTransaction?(l=s,d=a,f=u):(l=n,d=o,f=i),l.run();try{let g=e.call(t,this,arguments);return d.run(),g}catch(g){throw r.inTransaction&&(f.run(),f!==i&&d.run()),g}}});var Jd=D((DR,Hd)=>{"use strict";var{getBooleanOption:cI,cppdb:lI}=lt();Hd.exports=function(t,r){if(r==null&&(r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");let n=cI(r,"simple"),o=this[lI].prepare(`PRAGMA ${t}`,this,!0);return n?o.pluck().get():o.all()}});var Zd=D((_R,Yd)=>{"use strict";var fI=require("fs"),pI=require("path"),{promisify:mI}=require("util"),{cppdb:dI}=lt(),Vd=mI(fI.access);Yd.exports=async function(t,r){if(r==null&&(r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");t=t.trim();let n="attached"in r?r.attached:"main",o="progress"in r?r.progress:null;if(!t)throw new TypeError("Backup filename cannot be an empty string");if(t===":memory:")throw new TypeError(\'Invalid backup filename ":memory:"\');if(typeof n!="string")throw new TypeError(\'Expected the "attached" option to be a string\');if(!n)throw new TypeError(\'The "attached" option cannot be an empty string\');if(o!=null&&typeof o!="function")throw new TypeError(\'Expected the "progress" option to be a function\');await Vd(pI.dirname(t)).catch(()=>{throw new TypeError("Cannot save backup because the directory does not exist")});let i=await Vd(t).then(()=>!1,()=>!0);return hI(this[dI].backup(this,n,t,i),o||null)};var hI=(e,t)=>{let r=0,n=!0;return new Promise((o,i)=>{setImmediate(function s(){try{let a=e.transfer(r);if(!a.remainingPages){e.close(),o(a);return}if(n&&(n=!1,r=100),t){let u=t(a);if(u!==void 0)if(typeof u=="number"&&u===u)r=Math.max(0,Math.min(2147483647,Math.round(u)));else throw new TypeError("Expected progress callback to return a number or undefined")}setImmediate(s)}catch(a){e.close(),i(a)}})})}});var Xd=D((TR,Qd)=>{"use strict";var{cppdb:gI}=lt();Qd.exports=function(t){if(t==null&&(t={}),typeof t!="object")throw new TypeError("Expected first argument to be an options object");let r="attached"in t?t.attached:"main";if(typeof r!="string")throw new TypeError(\'Expected the "attached" option to be a string\');if(!r)throw new TypeError(\'The "attached" option cannot be an empty string\');return this[gI].serialize(r)}});var th=D((NR,eh)=>{"use strict";var{getBooleanOption:_i,cppdb:yI}=lt();eh.exports=function(t,r,n){if(r==null&&(r={}),typeof r=="function"&&(n=r,r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof n!="function")throw new TypeError("Expected last argument to be a function");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");if(!t)throw new TypeError("User-defined function name cannot be an empty string");let o="safeIntegers"in r?+_i(r,"safeIntegers"):2,i=_i(r,"deterministic"),s=_i(r,"directOnly"),a=_i(r,"varargs"),u=-1;if(!a){if(u=n.length,!Number.isInteger(u)||u<0)throw new TypeError("Expected function.length to be a positive integer");if(u>100)throw new RangeError("User-defined functions cannot have more than 100 arguments")}return this[yI].function(n,t,u,o,i,s),this}});var oh=D((CR,nh)=>{"use strict";var{getBooleanOption:Ti,cppdb:bI}=lt();nh.exports=function(t,r){if(typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object"||r===null)throw new TypeError("Expected second argument to be an options object");if(!t)throw new TypeError("User-defined function name cannot be an empty string");let n="start"in r?r.start:null,o=Ba(r,"step",!0),i=Ba(r,"inverse",!1),s=Ba(r,"result",!1),a="safeIntegers"in r?+Ti(r,"safeIntegers"):2,u=Ti(r,"deterministic"),m=Ti(r,"directOnly"),l=Ti(r,"varargs"),d=-1;if(!l&&(d=Math.max(rh(o),i?rh(i):0),d>0&&(d-=1),d>100))throw new RangeError("User-defined functions cannot have more than 100 arguments");return this[bI].aggregate(n,o,i,s,t,d,a,u,m),this};var Ba=(e,t,r)=>{let n=t in e?e[t]:null;if(typeof n=="function")return n;if(n!=null)throw new TypeError(`Expected the "${t}" option to be a function`);if(r)throw new TypeError(`Missing required option "${t}"`);return null},rh=({length:e})=>{if(Number.isInteger(e)&&e>=0)return e;throw new TypeError("Expected function.length to be a positive integer")}});var uh=D((AR,ah)=>{"use strict";var{cppdb:vI}=lt();ah.exports=function(t,r){if(typeof t!="string")throw new TypeError("Expected first argument to be a string");if(!t)throw new TypeError("Virtual table module name cannot be an empty string");let n=!1;if(typeof r=="object"&&r!==null)n=!0,r=_I(sh(r,"used",t));else{if(typeof r!="function")throw new TypeError("Expected second argument to be a function or a table definition object");r=wI(r)}return this[vI].table(r,t,n),this};function wI(e){return function(r,n,o,...i){let s={module:r,database:n,table:o},a=OI.call(e,s,i);if(typeof a!="object"||a===null)throw new TypeError(`Virtual table module "${r}" did not return a table definition object`);return sh(a,"returned",r)}}function sh(e,t,r){if(!jn.call(e,"rows"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition without a "rows" property`);if(!jn.call(e,"columns"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition without a "columns" property`);let n=e.rows;if(typeof n!="function"||Object.getPrototypeOf(n)!==DI)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "rows" property (should be a generator function)`);let o=e.columns;if(!Array.isArray(o)||!(o=[...o]).every(m=>typeof m=="string"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "columns" property (should be an array of strings)`);if(o.length!==new Set(o).size)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with duplicate column names`);if(!o.length)throw new RangeError(`Virtual table module "${r}" ${t} a table definition with zero columns`);let i;if(jn.call(e,"parameters")){if(i=e.parameters,!Array.isArray(i)||!(i=[...i]).every(m=>typeof m=="string"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "parameters" property (should be an array of strings)`)}else i=SI(n);if(i.length!==new Set(i).size)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with duplicate parameter names`);if(i.length>32)throw new RangeError(`Virtual table module "${r}" ${t} a table definition with more than the maximum number of 32 parameters`);for(let m of i)if(o.includes(m))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with column "${m}" which was ambiguously defined as both a column and parameter`);let s=2;if(jn.call(e,"safeIntegers")){let m=e.safeIntegers;if(typeof m!="boolean")throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "safeIntegers" property (should be a boolean)`);s=+m}let a=!1;if(jn.call(e,"directOnly")&&(a=e.directOnly,typeof a!="boolean"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "directOnly" property (should be a boolean)`);return[`CREATE TABLE x(${[...i.map(ih).map(m=>`${m} HIDDEN`),...o.map(ih)].join(", ")});`,xI(n,new Map(o.map((m,l)=>[m,i.length+l])),r),i,s,a]}function xI(e,t,r){return function*(...o){let i=o.map(s=>Buffer.isBuffer(s)?Buffer.from(s):s);for(let s=0;s`"${e.replace(/"/g,\'""\')}"`,_I=e=>()=>e});var lh=D((RR,ch)=>{"use strict";var TI=function(){};ch.exports=function(t,r){return Object.assign(new TI,this)}});var dh=D((FR,mh)=>{"use strict";var NI=require("fs"),fh=require("path"),Ln=lt(),CI=ja(),ph;function Oe(e,t){if(new.target==null)return new Oe(e,t);let r;if(Buffer.isBuffer(e)&&(r=e,e=":memory:"),e==null&&(e=""),t==null&&(t={}),typeof e!="string")throw new TypeError("Expected first argument to be a string");if(typeof t!="object")throw new TypeError("Expected second argument to be an options object");if("readOnly"in t)throw new TypeError(\'Misspelled option "readOnly" should be "readonly"\');if("memory"in t)throw new TypeError(\'Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)\');let n=e.trim(),o=n===""||n===":memory:",i=Ln.getBooleanOption(t,"readonly"),s=Ln.getBooleanOption(t,"uriPath"),a=Ln.getBooleanOption(t,"fileMustExist"),u="timeout"in t?t.timeout:5e3,m="verbose"in t?t.verbose:null,l="nativeBinding"in t?t.nativeBinding:null;if(i&&o&&!r)throw new TypeError("In-memory/temporary databases cannot be readonly");if(!Number.isInteger(u)||u<0)throw new TypeError(\'Expected the "timeout" option to be a positive integer\');if(u>2147483647)throw new RangeError(\'Option "timeout" cannot be greater than 2147483647\');if(m!=null&&typeof m!="function")throw new TypeError(\'Expected the "verbose" option to be a function\');if(l!=null&&typeof l!="string"&&typeof l!="object")throw new TypeError(\'Expected the "nativeBinding" option to be a string or addon object\');let d;if(l==null?d=ph||(ph=Ud()("better_sqlite3.node")):typeof l=="string"?d=(typeof __non_webpack_require__=="function"?__non_webpack_require__:require)(fh.resolve(l).replace(/(\\.node)?$/,".node")):d=l,d.isInitialized||(d.setErrorConstructor(CI),d.isInitialized=!0),!o&&!s&&!NI.existsSync(fh.dirname(n)))throw new TypeError("Cannot open database because the directory does not exist");Object.defineProperties(this,{[Ln.cppdb]:{value:new d.Database(n,e,o,i,a,u,m||null,r||null,s||null)},...tr.getters})}var tr=zd();Oe.prototype.prepare=tr.prepare;Oe.prototype.transaction=Gd();Oe.prototype.pragma=Jd();Oe.prototype.backup=Zd();Oe.prototype.serialize=Xd();Oe.prototype.function=th();Oe.prototype.aggregate=oh();Oe.prototype.table=uh();Oe.prototype.loadExtension=tr.loadExtension;Oe.prototype.exec=tr.exec;Oe.prototype.close=tr.close;Oe.prototype.defaultSafeIntegers=tr.defaultSafeIntegers;Oe.prototype.unsafeMode=tr.unsafeMode;Oe.prototype[Ln.inspect]=lh();mh.exports=Oe});var hh=D(($R,Ua)=>{"use strict";Ua.exports=dh();Ua.exports.SqliteError=ja()});var wh=D(Ni=>{"use strict";Object.defineProperty(Ni,"__esModule",{value:!0});function vh(e,t){if(t)return e;throw new Error("Unhandled discriminated union member: "+JSON.stringify(e))}Ni.assertNever=vh;Ni.default=vh});var Zi=class extends Error{},te=e=>{throw new Zi(e)},Qi=class extends Error{},Q=e=>{throw new Qi(e)};var xt=(e,t)=>le(e)===t,le=e=>{let t=typeof e;return t==="object"?e===null?"null":"object":t==="function"?"object":t},Xi={bigint:"a bigint",boolean:"boolean",null:"null",number:"a number",object:"an object",string:"a string",symbol:"a symbol",undefined:"undefined"};var Me=(e,t)=>e in t,wu=e=>Object.entries(e),re=e=>Object.keys(e),Pt=e=>{let t=[];for(;e!==Object.prototype&&e!==null&&e!==void 0;){for(let r of Object.getOwnPropertyNames(e))t.includes(r)||t.push(r);for(let r of Object.getOwnPropertySymbols(e))t.includes(r)||t.push(r);e=Object.getPrototypeOf(e)}return t},ir=(e,t)=>{let r=e?.[t];return r!=null};var xu=e=>Object.keys(e).length,Pr=e=>xt(e,"object")?Object.keys(e).length!==0:!1,tS=Symbol("id");var et=e=>Array.isArray(e)?e:[e];var ge=class extends Array{static fromString(t,r="/"){return t===r?new ge:new ge(...t.split(r))}toString(t="/"){return this.length?this.join(t):t}},Eu=(e,t)=>{let r=e;for(let n of t){if(typeof r!="object"||r===null)return;r=r[n]}return r};var es=/^(?!^-0$)-?(?:0|[1-9]\\d*)(?:\\.\\d*[1-9])?$/,ny=e=>es.test(e),oy=/^-?\\d*\\.?\\d*$/,iy=e=>e.length!==0&&oy.test(e),eo=/^(?:0|(?:-?[1-9]\\d*))$/,kr=e=>eo.test(e),Mr=/^(?:0|(?:[1-9]\\d*))$/,Iu=/^-?\\d+$/,sy=e=>Iu.test(e),Su={number:"a number",bigint:"a bigint",integer:"an integer"},Ou=(e,t)=>`\'${e}\' was parsed as ${Su[t]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,ay=(e,t)=>t==="number"?ny(e):kr(e),uy=(e,t)=>t==="number"?Number(e):Number.parseInt(e),cy=(e,t)=>t==="number"?iy(e):sy(e),qr=(e,t)=>Du(e,"number",t),to=(e,t)=>Du(e,"integer",t),Du=(e,t,r)=>{let n=uy(e,t);if(!Number.isNaN(n)){if(ay(e,t))return n;if(cy(e,t))return Q(Ou(e,t))}return r?Q(r===!0?`Failed to parse ${Su[t]} from \'${e}\'`:r):void 0},ts=e=>{if(e[e.length-1]!=="n")return;let t=e.slice(0,-1),r;try{r=BigInt(t)}catch{return}if(eo.test(t))return r;if(Iu.test(t))return Q(Ou(e,"bigint"))};var ie=(e,t)=>{switch(le(e)){case"object":return JSON.stringify(rs(e,ro,[]),null,t);case"symbol":return ro.onSymbol(e);default:return ns(e)}},ro={onCycle:()=>"(cycle)",onSymbol:e=>`(symbol${e.description&&` ${e.description}`})`,onFunction:e=>`(function${e.name&&` ${e.name}`})`},rs=(e,t,r)=>{switch(le(e)){case"object":if(typeof e=="function")return ro.onFunction(e);if(r.includes(e))return"(cycle)";let n=[...r,e];if(Array.isArray(e))return e.map(i=>rs(i,t,n));let o={};for(let i in e)o[i]=rs(e[i],t,n);return o;case"symbol":return ro.onSymbol(e);case"bigint":return`${e}n`;case"undefined":return"undefined";default:return e}},ns=e=>typeof e=="string"?`\'${e}\'`:typeof e=="bigint"?`${e}n`:`${e}`;function ly(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function fy(e,t){return t.get?t.get.call(e):t.value}function py(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function Tu(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function _u(e,t){var r=Tu(e,t,"get");return fy(e,r)}function my(e,t,r){ly(e,t),t.set(e,r)}function dy(e,t,r){var n=Tu(e,t,"set");return py(e,n,r),r}function no(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var qe=e=>(t,r,n)=>t===void 0?r===void 0?te(so):r:r===void 0?t:e(t,r,n),so="Unexpected operation two undefined operands",os={domain:({l:e,r:t})=>`${e.join(", ")} and ${t.join(", ")}`,range:({l:e,r:t})=>`${io(e)} and ${io(t)}`,class:({l:e,r:t})=>`classes ${typeof e=="string"?e:e.name} and ${typeof t=="string"?t:t.name}`,tupleLength:({l:e,r:t})=>`tuples of length ${e} and ${t}`,value:({l:e,r:t})=>`literal values ${ie(e)} and ${ie(t)}`,leftAssignability:({l:e,r:t})=>`literal value ${ie(e.value)} and ${ie(t)}`,rightAssignability:({l:e,r:t})=>`literal value ${ie(t.value)} and ${ie(e)}`,union:({l:e,r:t})=>`branches ${ie(e)} and branches ${ie(t)}`},io=e=>"limit"in e?`the range of exactly ${e.limit}`:e.min?e.max?`the range bounded by ${e.min.comparator}${e.min.limit} and ${e.max.comparator}${e.max.limit}`:`${e.min.comparator}${e.min.limit}`:e.max?`${e.max.comparator}${e.max.limit}`:"the unbounded range",oo=new WeakMap,Et=class{get disjoints(){return _u(this,oo)}addDisjoint(t,r,n){return _u(this,oo)[`${this.path}`]={kind:t,l:r,r:n},ao}constructor(t,r){no(this,"type",void 0),no(this,"lastOperator",void 0),no(this,"path",void 0),no(this,"domain",void 0),my(this,oo,{writable:!0,value:void 0}),this.type=t,this.lastOperator=r,this.path=new ge,dy(this,oo,{})}},ao=Symbol("empty"),Nu=()=>ao,Ye=e=>e===ao,Cu=Symbol("equal"),ye=()=>Cu,je=e=>e===Cu,sr=(e,t)=>(r,n,o)=>{let i={},s=re({...r,...n}),a=!0,u=!0;for(let m of s){let l=typeof e=="function"?e(m,r[m],n[m],o):e[m](r[m],n[m],o);if(je(l))r[m]!==void 0&&(i[m]=r[m]);else if(Ye(l))if(t.onEmpty==="omit")a=!1,u=!1;else return ao;else l!==void 0&&(i[m]=l),a&&(a=l===r[m]),u&&(u=l===n[m])}return a?u?ye():r:u?n:i};var Au=e=>{let t=re(e);if(t.length===1){let n=t[0];return`${n==="/"?"":`At ${n}: `}Intersection of ${os[e[n].kind](e[n])} results in an unsatisfiable type`}let r=`\n "Intersection results in unsatisfiable types at the following paths:\n`;for(let n in e)r+=` ${n}: ${os[e[n].kind](e[n])}\n`;return r},uo=(e,t,r)=>`${e.length?`At ${e}: `:""}${t} ${r?`${r} `:""}results in an unsatisfiable type`;var jr={Array,Date,Error,Function,Map,RegExp,Set,Object,String,Number,Boolean,WeakMap,WeakSet,Promise},ar=(e,t)=>{if(le(e)!=="object")return;let r=t??jr,n=Object.getPrototypeOf(e);for(;n?.constructor&&(!r[n.constructor.name]||!(e instanceof r[n.constructor.name]));)n=Object.getPrototypeOf(n);return n?.constructor?.name};var It=e=>Array.isArray(e),is={Object:"an object",Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},co=e=>{let t=Object(e).name;return t&&Me(t,jr)&&jr[t]===e?t:void 0};var Ru=qe((e,t,r)=>e===t?ye():e instanceof t?e:t instanceof e?t:r.addDisjoint("class",e,t)),Fu=(e,t)=>typeof e=="string"?ar(t.data)===e||!t.problems.add("class",e):t.data instanceof e||!t.problems.add("class",e);var lo=(e,t)=>{if(Array.isArray(e)){if(Array.isArray(t)){let r=hy(e,t);return r.length===e.length?r.length===t.length?ye():e:r.length===t.length?t:r}return e.includes(t)?e:[...e,t]}return Array.isArray(t)?t.includes(e)?t:[...t,e]:e===t?ye():[e,t]},hy=(e,t)=>{let r=[...e];for(let n of t)e.includes(n)||r.push(n);return r};var $u=qe((e,t)=>e===t?ye():Math.abs(e*t/gy(e,t))),gy=(e,t)=>{let r,n=e,o=t;for(;o!==0;)r=o,o=n%o,n=r;return n},Pu=(e,t)=>t.data%e===0||!t.problems.add("divisor",e);var Lr=e=>e[0]==="?",fo=e=>e[0]==="!",rt={index:"[index]"},St=e=>Lr(e)||fo(e)?e[1]:e,yy=e=>{if(typeof e.length=="object"&&fo(e.length)&&typeof e.length[1]!="string"&&mo(e.length[1],"number"))return e.length[1].number.value},ku=qe((e,t,r)=>{let n=by(e,t,r);if(typeof n=="symbol")return n;let o=yy(n);if(o===void 0||!(rt.index in n))return n;let{[rt.index]:i,...s}=n,a=St(i);for(let u=0;u{if(t===void 0)return r===void 0?ye():r;if(r===void 0)return t;n.path.push(e);let o=po(St(t),St(r),n);n.path.pop();let i=Lr(t)&&Lr(r);return Ye(o)&&i?{}:o},{onEmpty:"bubble"}),Mu=(e,t,r)=>{let n=r.type.config?.keys??r.type.scope.config.keys;return n==="loose"?vy(e,t,r):wy(n,e,t,r)},vy=(e,t,r)=>{for(let n in t){let o=t[n];r.path.push(n),n===rt.index?e.push(["indexProp",tt(St(o),r)]):Lr(o)?e.push(["optionalProp",[n,tt(o[1],r)]]):fo(o)?e.push(["prerequisiteProp",[n,tt(o[1],r)]]):e.push(["requiredProp",[n,tt(o,r)]]),r.path.pop()}},wy=(e,t,r,n)=>{let o={required:{},optional:{}};for(let i in r){let s=r[i];n.path.push(i),i===rt.index?o.index=tt(St(s),n):Lr(s)?o.optional[i]=tt(s[1],n):fo(s)?t.push(["prerequisiteProp",[i,tt(s[1],n)]]):o.required[i]=tt(s,n),n.path.pop()}t.push([`${e}Props`,o])};function xy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ss=e=>typeof e=="string"||Array.isArray(e)?e.length:typeof e=="number"?e:0,Ey=e=>typeof e=="string"?"characters":Array.isArray(e)?"items long":"",ho=class{toString(){return ie(this.value)}get domain(){return le(this.value)}get size(){return ss(this.value)}get units(){return Ey(this.value)}get className(){return Object(this.value).constructor.name}constructor(t){xy(this,"value",void 0),this.value=t}};var go={">":!0,">=":!0},as={"<":!0,"<=":!0},Br=e=>"comparator"in e,ju=qe((e,t,r)=>{if(Br(e))return Br(t)?e.limit===t.limit?ye():r.addDisjoint("range",e,t):qu(t,e.limit)?e:r.addDisjoint("range",e,t);if(Br(t))return qu(e,t.limit)?t:r.addDisjoint("range",e,t);let n=ur("min",e.min,t.min),o=ur("max",e.max,t.max);return n==="l"?o==="r"?ur("min",e.min,t.max)==="l"?r.addDisjoint("range",e,t):{min:e.min,max:t.max}:e:n==="r"?o==="l"?ur("max",e.max,t.min)==="l"?r.addDisjoint("range",e,t):{min:t.min,max:e.max}:t:o==="l"?e:o==="r"?t:ye()}),qu=(e,t)=>Br(e)?t===e.limit:Iy(e.min,t)&&Sy(e.max,t),Iy=(e,t)=>!e||t>e.limit||t===e.limit&&!Ur(e.comparator),Sy=(e,t)=>!e||t{let n=r.lastDomain==="string"?"characters":r.lastDomain==="object"?"items long":void 0;if(Br(t))return e.push(["bound",n?{...t,units:n}:t]);t.min&&e.push(["bound",n?{...t.min,units:n}:t.min]),t.max&&e.push(["bound",n?{...t.max,units:n}:t.max])},Bu=(e,t)=>Oy[e.comparator](ss(t.data),e.limit)||!t.problems.add("bound",e),Oy={"<":(e,t)=>e":(e,t)=>e>t,"<=":(e,t)=>e<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e===t},ur=(e,t,r)=>t?r?t.limit===r.limit?Ur(t.comparator)?Ur(r.comparator)?"=":"l":Ur(r.comparator)?"r":"=":e==="min"?t.limit>r.limit?"l":"r":t.limite.length===1;var us={},cs=e=>(us[e]||(us[e]=new RegExp(e)),us[e]),Uu=(e,t)=>cs(e).test(t.data)||!t.problems.add("regex",`/${e}/`),zu=qe(lo);var Ku=(e,t,r)=>"value"in e?"value"in t?e.value===t.value?ye():r.addDisjoint("value",e.value,t.value):Wu(e.value,t,r)?e:r.addDisjoint("leftAssignability",e,t):"value"in t?Wu(t.value,e,r)?t:r.addDisjoint("rightAssignability",e,t):_y(e,t,r),Dy=qe(lo),_y=sr({divisor:$u,regex:zu,props:ku,class:Ru,range:ju,narrow:Dy},{onEmpty:"bubble"}),ls=(e,t)=>{let r=[],n;for(n in e)Ty[n](r,e[n],t);return r.sort((o,i)=>zr[o[0]]-zr[i[0]])},Ty={regex:(e,t)=>{for(let r of et(t))e.push(["regex",r])},divisor:(e,t)=>{e.push(["divisor",t])},range:Lu,class:(e,t)=>{e.push(["class",t])},props:Mu,narrow:(e,t)=>{for(let r of et(t))e.push(["narrow",r])},value:(e,t)=>{e.push(["value",t])}},zr={config:-1,domain:0,value:0,domains:0,branches:0,switch:0,alias:0,class:0,regex:1,divisor:1,bound:1,prerequisiteProp:2,distilledProps:3,strictProps:3,requiredProp:3,optionalProp:3,indexProp:3,narrow:4,morph:5},Wu=(e,t,r)=>!r.type.scope.type(["node",{[r.domain]:t}])(e).problems;var fs=e=>e?.lBranches!==void 0,Hu=(e,t,r)=>{let n={lBranches:e,rBranches:t,lExtendsR:[],rExtendsL:[],equalities:[],distinctIntersections:[]},o=t.map(i=>({condition:i,distinct:[]}));return e.forEach((i,s)=>{let a=!1,u=o.map((m,l)=>{if(a||!m.distinct)return null;let d=m.condition,f=Kr(i,d,r);return Ye(f)?null:f===i?(n.lExtendsR.push(s),a=!0,null):f===d?(n.rExtendsL.push(l),m.distinct=null,null):je(f)?(n.equalities.push([s,l]),a=!0,m.distinct=null,null):xt(f,"object")?f:te(`Unexpected predicate intersection result of type \'${le(f)}\'`)});if(!a)for(let m=0;mi.distinct??[]),n},ps=e=>"rules"in e,Wr=(e,t)=>{if(ps(e)){let r=ls(e.rules,t);if(e.morph)if(typeof e.morph=="function")r.push(["morph",e.morph]);else for(let n of e.morph)r.push(["morph",n]);return r}return ls(e,t)},Gu=e=>e.rules??e,Kr=(e,t,r)=>{let n=Gu(e),o=Gu(t),i=Ku(n,o,r);return"morph"in e?"morph"in t?e.morph===t.morph?je(i)||Ye(i)?i:{rules:i,morph:e.morph}:r.lastOperator==="&"?Q(uo(r.path,"Intersection","of morphs")):{}:Ye(i)?i:{rules:je(i)?e.rules:i,morph:e.morph}:"morph"in t?Ye(i)?i:{rules:je(i)?t.rules:i,morph:t.morph}:i};var Ju=e=>`${e==="/"?"A":`At ${e}, a`} union including one or more morphs must be discriminatable`;var Yu=(e,t)=>{let r=Cy(e,t),n=e.map((o,i)=>i);return Zu(e,n,r,t)},Zu=(e,t,r,n)=>{if(t.length===1)return Wr(e[t[0]],n);let o=Ry(t,r);if(!o)return[["branches",t.map(s=>ds(e[s],n.type.scope)?Q(Ju(`${n.path}`)):Wr(e[s],n))]];let i={};for(let s in o.indexCases){let a=o.indexCases[s];i[s]=Zu(e,a,r,n),s!=="default"&&Gr(i[s],o.path,o,n)}return[["switch",{path:o.path,kind:o.kind,cases:i}]]},Gr=(e,t,r,n)=>{for(let o=0;ote(`Unexpectedly failed to discriminate ${e.kind} at path \'${e.path}\'`),Ny={domain:!0,class:!0,value:!0},Cy=(e,t)=>{let r={disjointsByPair:{},casesByDisjoint:{}};for(let n=0;n{let t=ge.fromString(e);return[t,t.pop()]},Ry=(e,t)=>{let r;for(let n=0;n{let N=e.indexOf(S);if(N!==-1)return delete d[N],!0});x.length!==0&&(l[w]=x,f++)}let g=re(d);if(g.length&&(l.default=g.map(w=>parseInt(w))),!r||f>r.score){let[w,x]=Ay(u);if(r={path:w,kind:x,indexCases:l,score:f},f===e.length)return r}}}}return r},Vu=(e,t)=>{switch(e){case"value":return Qu(t);case"domain":return t;case"class":return co(t);default:return}},Qu=e=>{let t=le(e);return t==="object"||t==="symbol"?void 0:ns(e)},Fy={value:e=>Qu(e)??"default",class:e=>ar(e)??"default",domain:le},Xu=(e,t)=>Fy[e](t),ds=(e,t)=>"morph"in e?!0:"props"in e?Object.values(e.props).some(r=>$y(St(r),t)):!1,$y=(e,t)=>typeof e=="string"?t.resolve(e).includesMorph:Object.values(t.resolveTypeNode(e)).some(r=>r===!0?!1:It(r)?r.some(n=>ds(n,t)):ds(r,t));var cr=e=>e===!0?{}:e,ec=(e,t,r)=>{if(e===!0&&t===!0)return ye();if(!It(e)&&!It(t)){let s=Kr(cr(e),cr(t),r);return s===e?e:s===t?t:s}let n=et(cr(e)),o=et(cr(t)),i=Hu(n,o,r);return i.equalities.length===n.length&&i.equalities.length===o.length?ye():i.lExtendsR.length+i.equalities.length===n.length?e:i.rExtendsL.length+i.equalities.length===o.length?t:i},tc=(e,t,r,n)=>{n.domain=e;let o=ec(t,r,n);if(!fs(o))return o;let i=[...o.distinctIntersections,...o.equalities.map(s=>o.lBranches[s[0]]),...o.lExtendsR.map(s=>o.lBranches[s]),...o.rExtendsL.map(s=>o.rBranches[s])];return i.length===0&&n.addDisjoint("union",o.lBranches,o.rBranches),i.length===1?i[0]:i},rc=(e,t,r,n)=>{let o=new Et(n,"|"),i=ec(t,r,o);if(!fs(i))return je(i)||i===t?r:i===r?t:e==="boolean"?!0:[cr(t),cr(r)];let s=[...i.lBranches.filter((a,u)=>!i.lExtendsR.includes(u)&&!i.equalities.some(m=>m[0]===u)),...i.rBranches.filter((a,u)=>!i.rExtendsL.includes(u)&&!i.equalities.some(m=>m[1]===u))];return s.length===1?s[0]:s},hs=(e,t)=>e===!0?[]:It(e)?Yu(e,t):Wr(e,t),nc=e=>typeof e=="object"&&"value"in e;var Hr=e=>"config"in e,po=(e,t,r)=>{r.domain=void 0;let n=r.type.scope.resolveTypeNode(e),o=r.type.scope.resolveTypeNode(t),i=Py(n,o,r);return typeof i=="object"&&!Pr(i)?Pr(r.disjoints)?Nu():r.addDisjoint("domain",re(n),re(o)):i===n?e:i===o?t:i},Py=sr((e,t,r,n)=>{if(t===void 0)return r===void 0?te(so):void 0;if(r!==void 0)return tc(e,t,r,n)},{onEmpty:"omit"}),Ot=(e,t,r)=>{let n=new Et(r,"&"),o=po(e,t,n);return Ye(o)?Q(Au(n.disjoints)):je(o)?e:o},yo=(e,t,r)=>{let n=r.scope.resolveTypeNode(e),o=r.scope.resolveTypeNode(t),i={},s=re({...n,...o});for(let a of s)i[a]=ir(n,a)?ir(o,a)?rc(a,n[a],o[a],r):n[a]:ir(o,a)?o[a]:te(so);return i},ky=e=>e[0]&&(e[0][0]==="value"||e[0][0]==="class"),gs=e=>{let t={type:e,path:new ge,lastDomain:"undefined"};return tt(e.node,t)},tt=(e,t)=>{if(typeof e=="string")return t.type.scope.resolve(e).flat;let r=Hr(e),n=My(r?e.node:e,t);return r?[["config",{config:wu(e.config),node:n}]]:n},My=(e,t)=>{let r=re(e);if(r.length===1){let o=r[0],i=e[o];if(i===!0)return o;t.lastDomain=o;let s=hs(i,t);return ky(s)?s:[["domain",o],...s]}let n={};for(let o of r)t.lastDomain=o,n[o]=hs(e[o],t);return[["domains",n]]},mo=(e,t)=>qy(e,t)&&nc(e[t]),qy=(e,t)=>{let r=re(e);return r.length===1&&r[0]===t},lr=e=>({object:{class:Array,props:{[rt.index]:e}}});function ys(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var se=class{shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}shiftUntil(t){let r="";for(;this.lookahead;){if(t(this,r))if(r[r.length-1]===se.escapeToken)r=r.slice(0,-1);else break;r+=this.shift()}return r}shiftUntilNextTerminator(){return this.shiftUntil(se.lookaheadIsNotWhitespace),this.shiftUntil(se.lookaheadIsTerminator)}get unscanned(){return this.chars.slice(this.i,this.chars.length).join("")}lookaheadIs(t){return this.lookahead===t}lookaheadIsIn(t){return this.lookahead in t}constructor(t){ys(this,"chars",void 0),ys(this,"i",void 0),ys(this,"finalized",!1),this.chars=[...t],this.i=0}};(function(e){var t=e.lookaheadIsTerminator=f=>f.lookahead in o,r=e.lookaheadIsNotWhitespace=f=>f.lookahead!==d,n=e.comparatorStartChars={"<":!0,">":!0,"=":!0},o=e.terminatingChars={...n,"|":!0,"&":!0,")":!0,"[":!0,"%":!0," ":!0},i=e.comparators={"<":!0,">":!0,"<=":!0,">=":!0,"==":!0},s=e.oneCharComparators={"<":!0,">":!0},a=e.comparatorDescriptions={"<":"less than",">":"more than","<=":"at most",">=":"at least","==":"exactly"},u=e.invertedComparators={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},m=e.branchTokens={"|":!0,"&":!0},l=e.escapeToken="\\\\",d=e.whiteSpaceToken=" "})(se||(se={}));function jy(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Ly(e,t){return t.get?t.get.call(e):t.value}function By(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function oc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function bo(e,t){var r=oc(e,t,"get");return Ly(e,r)}function Uy(e,t,r){jy(e,t),t.set(e,r)}function zy(e,t,r){var n=oc(e,t,"set");return By(e,n,r),r}function pt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var vs=class extends TypeError{constructor(t){super(`${t}`),pt(this,"cause",void 0),this.cause=t}},qt=class{toString(){return this.message}get message(){return this.writers.addContext(this.reason,this.path)}get reason(){return this.writers.writeReason(this.mustBe,new ho(this.data))}get mustBe(){return typeof this.writers.mustBe=="string"?this.writers.mustBe:this.writers.mustBe(this.source)}constructor(t,r,n,o,i){pt(this,"code",void 0),pt(this,"path",void 0),pt(this,"data",void 0),pt(this,"source",void 0),pt(this,"writers",void 0),pt(this,"parts",void 0),this.code=t,this.path=r,this.data=n,this.source=o,this.writers=i,this.code==="multi"&&(this.parts=this.source)}},fr=new WeakMap,ws=class extends Array{mustBe(t,r){return this.add("custom",t,r)}add(t,r,n){let o=ge.from(n?.path??bo(this,fr).path),i=n&&"data"in n?n.data:bo(this,fr).data,s=new qt(t,o,i,r,bo(this,fr).getProblemConfig(t));return this.addProblem(s),s}addProblem(t){let r=`${t.path}`,n=this.byPath[r];if(n)if(n.parts)n.parts.push(t);else{let o=new qt("multi",n.path,n.data,[n,t],bo(this,fr).getProblemConfig("multi")),i=this.indexOf(n);this[i===-1?this.length:i]=o,this.byPath[r]=o}else this.byPath[r]=t,this.push(t);this.count++}get summary(){return`${this}`}toString(){return this.join(`\n`)}throw(){throw new vs(this)}constructor(t){super(),pt(this,"byPath",{}),pt(this,"count",0),Uy(this,fr,{writable:!0,value:void 0}),zy(this,fr,t)}},vo=ws,Wy=e=>e[0].toUpperCase()+e.slice(1),xs=e=>e.map(t=>Xi[t]),ic=e=>e.map(t=>is[t]),bs=e=>{if(e.length===0)return"never";if(e.length===1)return e[0];let t="";for(let r=0;r`must be ${e}${t&&` (was ${t})`}`,sc=(e,t)=>t.length===0?Wy(e):t.length===1&&kr(t[0])?`Item at index ${t[0]} ${e}`:`${t} ${e}`,Mt={divisor:{mustBe:e=>e===1?"an integer":`a multiple of ${e}`},class:{mustBe:e=>{let t=co(e);return t?is[t]:`an instance of ${e.name}`},writeReason:(e,t)=>kt(e,t.className)},domain:{mustBe:e=>Xi[e],writeReason:(e,t)=>kt(e,t.domain)},missing:{mustBe:()=>"defined",writeReason:e=>kt(e,"")},extraneous:{mustBe:()=>"removed",writeReason:e=>kt(e,"")},bound:{mustBe:e=>`${se.comparatorDescriptions[e.comparator]} ${e.limit}${e.units?` ${e.units}`:""}`,writeReason:(e,t)=>kt(e,`${t.size}`)},regex:{mustBe:e=>`a string matching ${e}`},value:{mustBe:ie},branches:{mustBe:e=>bs(e.map(t=>`${t.path} must be ${t.parts?bs(t.parts.map(r=>r.mustBe)):t.mustBe}`)),writeReason:(e,t)=>`${e} (was ${t})`,addContext:(e,t)=>t.length?`At ${t}, ${e}`:e},multi:{mustBe:e=>"\\u2022 "+e.map(t=>t.mustBe).join(`\n\\u2022 `),writeReason:(e,t)=>`${t} must be...\n${e}`,addContext:(e,t)=>t.length?`At ${t}, ${e}`:e},custom:{mustBe:e=>e},cases:{mustBe:e=>bs(e)}},ac=re(Mt),Ky=()=>{let e={},t;for(t of ac)e[t]={mustBe:Mt[t].mustBe,writeReason:Mt[t].writeReason??kt,addContext:Mt[t].addContext??sc};return e},Gy=Ky(),uc=e=>{if(!e)return Gy;let t={};for(let r of ac)t[r]={mustBe:e[r]?.mustBe??Mt[r].mustBe,writeReason:e[r]?.writeReason??Mt[r].writeReason??e.writeReason??kt,addContext:e[r]?.addContext??Mt[r].addContext??e.addContext??sc};return t};function Hy(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Jy(e,t){return t.get?t.get.call(e):t.value}function Vy(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function fc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function Es(e,t){var r=fc(e,t,"get");return Jy(e,r)}function Yy(e,t,r){Hy(e,t),t.set(e,r)}function Zy(e,t,r){var n=fc(e,t,"set");return Vy(e,n,r),r}function nt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Qy=()=>({mustBe:[],writeReason:[],addContext:[],keys:[]}),Xy=["mustBe","writeReason","addContext"],pc=(e,t)=>{let r=new Is(t,e);wo(e.flat,r);let n=new mc(r);if(r.problems.count)n.problems=r.problems;else{for(let[o,i]of r.entriesToPrune)delete o[i];n.data=r.data}return n},mc=class{constructor(){nt(this,"data",void 0),nt(this,"problems",void 0)}},Jr=new WeakMap,Is=class{getProblemConfig(t){let r={};for(let n of Xy)r[n]=this.traversalConfig[n][0]??this.rootScope.config.codes[t][n];return r}traverseConfig(t,r){for(let o of t)this.traversalConfig[o[0]].unshift(o[1]);let n=wo(r,this);for(let o of t)this.traversalConfig[o[0]].shift();return n}traverseKey(t,r){let n=this.data;this.data=this.data[t],this.path.push(t);let o=wo(r,this);return this.path.pop(),n[t]!==this.data&&(n[t]=this.data),this.data=n,o}traverseResolution(t){let r=this.type.scope.resolve(t),n=r.qualifiedName,o=this.data,i=xt(o,"object");if(i){let u=Es(this,Jr)[n];if(u){if(u.includes(o))return!0;u.push(o)}else Es(this,Jr)[n]=[o]}let s=this.type;this.type=r;let a=wo(r.flat,this);return this.type=s,i&&Es(this,Jr)[n].pop(),a}traverseBranches(t){let r=this.failFast;this.failFast=!0;let n=this.problems,o=new vo(this);this.problems=o;let i=this.path,s=this.entriesToPrune,a=!1;for(let u of t)if(this.path=new ge,this.entriesToPrune=[],xo(u,this)){a=!0,s.push(...this.entriesToPrune);break}return this.path=i,this.entriesToPrune=s,this.problems=n,this.failFast=r,a||!this.problems.add("branches",o)}constructor(t,r){nt(this,"data",void 0),nt(this,"type",void 0),nt(this,"path",void 0),nt(this,"problems",void 0),nt(this,"entriesToPrune",void 0),nt(this,"failFast",void 0),nt(this,"traversalConfig",void 0),nt(this,"rootScope",void 0),Yy(this,Jr,{writable:!0,value:void 0}),this.data=t,this.type=r,this.path=new ge,this.problems=new vo(this),this.entriesToPrune=[],this.failFast=!1,this.traversalConfig=Qy(),Zy(this,Jr,{}),this.rootScope=r.scope}},wo=(e,t)=>typeof e=="string"?le(t.data)===e||!t.problems.add("domain",e):xo(e,t),xo=(e,t)=>{let r=!0;for(let n=0;ne[0]in t.data?t.traverseKey(e[0],e[1]):(t.problems.add("missing",void 0,{path:t.path.concat(e[0]),data:void 0}),!1),lc=e=>(t,r)=>{let n=!0,o={...t.required};for(let s in r.data)if(t.required[s]?(n=r.traverseKey(s,t.required[s])&&n,delete o[s]):t.optional[s]?n=r.traverseKey(s,t.optional[s])&&n:t.index&&eo.test(s)?n=r.traverseKey(s,t.index)&&n:e==="distilledProps"?r.failFast?r.entriesToPrune.push([r.data,s]):delete r.data[s]:(n=!1,r.problems.add("extraneous",r.data[s],{path:r.path.concat(s)})),!n&&r.failFast)return!1;let i=Object.keys(o);if(i.length){for(let s of i)r.problems.add("missing",void 0,{path:r.path.concat(s)});return!1}return n},eb={regex:Uu,divisor:Pu,domains:(e,t)=>{let r=e[le(t.data)];return r?xo(r,t):!t.problems.add("cases",xs(re(e)))},domain:(e,t)=>le(t.data)===e||!t.problems.add("domain",e),bound:Bu,optionalProp:(e,t)=>e[0]in t.data?t.traverseKey(e[0],e[1]):!0,requiredProp:cc,prerequisiteProp:cc,indexProp:(e,t)=>{if(!Array.isArray(t.data))return t.problems.add("class",Array),!1;let r=!0;for(let n=0;nt.traverseBranches(e),switch:(e,t)=>{let r=Eu(t.data,e.path),n=Xu(e.kind,r);if(ir(e.cases,n))return xo(e.cases[n],t);let o=re(e.cases),i=t.path.concat(e.path),s=e.kind==="value"?o:e.kind==="domain"?xs(o):e.kind==="class"?ic(o):te(`Unexpectedly encountered rule kind \'${e.kind}\' during traversal`);return t.problems.add("cases",s,{path:i,data:r}),!1},alias:(e,t)=>t.traverseResolution(e),class:Fu,narrow:(e,t)=>{let r=t.problems.count,n=e(t.data,t.problems);return!n&&t.problems.count===r&&t.problems.mustBe(e.name?`valid according to ${e.name}`:"valid"),n},config:({config:e,node:t},r)=>r.traverseConfig(e,t),value:(e,t)=>t.data===e||!t.problems.add("value",e),morph:(e,t)=>{let r=e(t.data,t.problems);if(t.problems.length)return!1;if(r instanceof qt)return t.problems.addProblem(r),!1;if(r instanceof mc){if(r.problems){for(let n of r.problems)t.problems.addProblem(n);return!1}return t.data=r.data,!0}return t.data=r,!0},distilledProps:lc("distilledProps"),strictProps:lc("strictProps")};var Dt=new Proxy(()=>Dt,{get:()=>Dt});var Ss=(e,t,r,n)=>{let o={node:e,flat:[["alias",e]],allows:a=>!i(a).problems,assert:a=>{let u=i(a);return u.problems?u.problems.throw():u.data},infer:Dt,inferIn:Dt,qualifiedName:tb(e)?n.getAnonymousQualifiedName(e):`${n.name}.${e}`,definition:t,scope:n,includesMorph:!1,config:r},i={[e]:a=>pc(i,a)}[e];return Object.assign(i,o)},Os=e=>e?.infer===Dt,tb=e=>e[0]==="\\u03BB";var dc=e=>{let t=e.scanner.shiftUntilNextTerminator();e.setRoot(rb(e,t))},rb=(e,t)=>e.ctx.type.scope.addParsedReferenceIfResolvable(t,e.ctx)?t:nb(t)??e.error(t===""?Ds(e):ob(t)),nb=e=>{let t=qr(e);if(t!==void 0)return{number:{value:t}};let r=ts(e);if(r!==void 0)return{bigint:{value:r}}},ob=e=>`\'${e}\' is unresolvable`,Ds=e=>{let t=e.previousOperator();return t?_s(t,e.scanner.unscanned):ib(e.scanner.unscanned)},_s=(e,t)=>`Token \'${e}\' requires a right operand${t?` before \'${t}\'`:""}`,ib=e=>`Expected an expression${e?` before \'${e}\'`:""}`;var Ts=(e,t)=>({node:t.type.scope.resolveTypeNode(be(e[0],t)),config:e[2]});var Le=e=>Object.isFrozen(e)?e:Array.isArray(e)?Object.freeze(e.map(Le)):sb(e),sb=e=>{for(let t in e)Le(e[t]);return e};var ab=Le({regex:Mr.source}),ub=Le({range:{min:{comparator:">=",limit:0}},divisor:1}),hc=(e,t)=>{let r=t.type.scope.resolveNode(be(e[1],t)),n=re(r).map(l=>lb(l,r[l])),o=gc(n);if(!o.length)return uo(t.path,"keyof");let i={};for(let l of o){let d=typeof l;if(d==="string"||d==="number"||d==="symbol"){var s,a;(s=i)[a=d]??(s[a]=[]),i[d].push({value:l})}else if(l===Mr){var u,m;(u=i).string??(u.string=[]),i.string.push(ab),(m=i).number??(m.number=[]),i.number.push(ub)}else return te(`Unexpected keyof key \'${ie(l)}\'`)}return Object.fromEntries(Object.entries(i).map(([l,d])=>[l,d.length===1?d[0]:d]))},cb={bigint:Pt(0n),boolean:Pt(!1),null:[],number:Pt(0),object:[],string:Pt(""),symbol:Pt(Symbol()),undefined:[]},lb=(e,t)=>e!=="object"||t===!0?cb[e]:gc(et(t).map(r=>fb(r))),gc=e=>{if(!e.length)return[];let t=e[0];for(let r=1;re[r].includes(n));return t},fb=e=>{let t=[];if("props"in e)for(let r of Object.keys(e.props))r===rt.index?t.push(Mr):t.includes(r)||(t.push(r),Mr.test(r)&&t.push(to(r,`Unexpectedly failed to parse an integer from key \'${r}\'`)));if("class"in e){let r=typeof e.class=="string"?jr[e.class]:e.class;for(let n of Pt(r.prototype))t.includes(n)||t.push(n)}return t};var bc=(e,t)=>{if(typeof e[2]!="function")return Q(pb(e[2]));let r=be(e[0],t),n=t.type.scope.resolveTypeNode(r),o=e[2];t.type.includesMorph=!0;let i,s={};for(i in n){let a=n[i];a===!0?s[i]={rules:{},morph:o}:typeof a=="object"?s[i]=It(a)?a.map(u=>yc(u,o)):yc(a,o):te(`Unexpected predicate value for domain \'${i}\': ${ie(a)}`)}return s},yc=(e,t)=>ps(e)?{...e,morph:e.morph?Array.isArray(e.morph)?[...e.morph,t]:[e.morph,t]:t}:{rules:e,morph:t},pb=e=>`Morph expression requires a function following \'|>\' (was ${typeof e})`;var vc=e=>`Expected a Function or Record operand (${ie(e)} was invalid)`,wc=(e,t,r,n)=>{let o=re(t);if(!xt(e,"object"))return Q(vc(e));let i={};if(typeof e=="function"){let s={[n]:e};for(let a of o)i[a]=s}else for(let s of o){if(e[s]===void 0)continue;let a={[n]:e[s]};if(typeof a[n]!="function")return Q(vc(a));i[s]=a}return i};var xc=(e,t)=>{let r=be(e[0],t),n=t.type.scope.resolveNode(r),o=Hr(n),i=o?n.node:n,s=Ot(r,wc(e[2],i,t,"narrow"),t.type);return o?{config:n.config,node:s}:s};var Ic=(e,t)=>{if(db(e))return Sc[e[1]](e,t);if(hb(e))return Oc[e[0]](e,t);let r={length:["!",{number:{value:e.length}}]};for(let n=0;n{if(e[2]===void 0)return Q(_s(e[1],""));let r=be(e[0],t),n=be(e[2],t);return e[1]==="&"?Ot(r,n,t.type):yo(r,n,t.type)},mb=(e,t)=>lr(be(e[0],t));var db=e=>Sc[e[1]]!==void 0,Sc={"|":Ec,"&":Ec,"[]":mb,"=>":xc,"|>":bc,":":Ts},Oc={keyof:hc,instanceof:e=>typeof e[1]!="function"?Q(`Expected a constructor following \'instanceof\' operator (was ${typeof e[1]}).`):{object:{class:e[1]}},"===":e=>({[le(e[1])]:{value:e[1]}}),node:e=>e[1]},hb=e=>Oc[e[0]]!==void 0;var Dc=(e,t)=>{let r={};for(let n in e){let o=n,i=!1;n[n.length-1]==="?"&&(n[n.length-2]===se.escapeToken?o=`${n.slice(0,-2)}?`:(o=n.slice(0,-1),i=!0)),t.path.push(o);let s=be(e[n],t);t.path.pop(),r[o]=i?["?",s]:s}return{object:{props:r}}};var _c=e=>`Unmatched )${e===""?"":` before ${e}`}`,Tc="Missing )",Nc=(e,t)=>`Left bounds are only valid when paired with right bounds (try ...${t}${e})`,Eo=e=>`Left-bounded expressions must specify their limits using < or <= (was ${e})`,Cc=(e,t,r,n)=>`An expression may have at most one left bound (parsed ${e}${se.invertedComparators[t]}, ${r}${se.invertedComparators[n]})`;function Vr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Io=class{error(t){return Q(t)}hasRoot(){return this.root!==void 0}resolveRoot(){return this.assertHasRoot(),this.ctx.type.scope.resolveTypeNode(this.root)}rootToString(){return this.assertHasRoot(),ie(this.root)}ejectRootIfLimit(){this.assertHasRoot();let t=typeof this.root=="string"?this.ctx.type.scope.resolveNode(this.root):this.root;if(mo(t,"number")){let r=t.number.value;return this.root=void 0,r}}ejectRangeIfOpen(){if(this.branches.range){let t=this.branches.range;return delete this.branches.range,t}}assertHasRoot(){if(this.root===void 0)return te("Unexpected interaction with unset root")}assertUnsetRoot(){if(this.root!==void 0)return te("Unexpected attempt to overwrite root")}setRoot(t){this.assertUnsetRoot(),this.root=t}rootToArray(){this.root=lr(this.ejectRoot())}intersect(t){this.root=Ot(this.ejectRoot(),t,this.ctx.type)}ejectRoot(){this.assertHasRoot();let t=this.root;return this.root=void 0,t}ejectFinalizedRoot(){this.assertHasRoot();let t=this.root;return this.root=gb,t}finalize(){if(this.groups.length)return this.error(Tc);this.finalizeBranches(),this.scanner.finalized=!0}reduceLeftBound(t,r){let n=se.invertedComparators[r];if(!Me(n,go))return this.error(Eo(r));if(this.branches.range)return this.error(Cc(`${this.branches.range.limit}`,this.branches.range.comparator,`${t}`,n));this.branches.range={limit:t,comparator:n}}finalizeBranches(){this.assertRangeUnset(),this.branches.union?(this.pushRootToBranch("|"),this.setRoot(this.branches.union)):this.branches.intersection&&this.setRoot(Ot(this.branches.intersection,this.ejectRoot(),this.ctx.type))}finalizeGroup(){this.finalizeBranches();let t=this.groups.pop();if(!t)return this.error(_c(this.scanner.unscanned));this.branches=t}pushRootToBranch(t){this.assertRangeUnset(),this.branches.intersection=this.branches.intersection?Ot(this.branches.intersection,this.ejectRoot(),this.ctx.type):this.ejectRoot(),t==="|"&&(this.branches.union=this.branches.union?yo(this.branches.union,this.branches.intersection,this.ctx.type):this.branches.intersection,delete this.branches.intersection)}assertRangeUnset(){if(this.branches.range)return this.error(Nc(`${this.branches.range.limit}`,this.branches.range.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={}}previousOperator(){return this.branches.range?.comparator??this.branches.intersection?"&":this.branches.union?"|":void 0}shiftedByOne(){return this.scanner.shift(),this}constructor(t,r){Vr(this,"ctx",void 0),Vr(this,"scanner",void 0),Vr(this,"root",void 0),Vr(this,"branches",void 0),Vr(this,"groups",void 0),this.ctx=r,this.branches={},this.groups=[],this.scanner=new se(t)}},gb=new Proxy({},{get:()=>te("Unexpected attempt to access ejected attributes")});var Ac=(e,t)=>{let r=e.scanner.shiftUntil(yb[t]);if(e.scanner.lookahead==="")return e.error(vb(r,t));e.scanner.shift()==="/"?(cs(r),e.setRoot({string:{regex:r}})):e.setRoot({string:{value:r}})},Rc={"\'":1,\'"\':1,"/":1},yb={"\'":e=>e.lookahead==="\'",\'"\':e=>e.lookahead===\'"\',"/":e=>e.lookahead==="/"},bb={\'"\':"double-quote","\'":"single-quote","/":"forward slash"},vb=(e,t)=>`${t}${e} requires a closing ${bb[t]}`;var So=e=>e.scanner.lookahead===""?e.error(Ds(e)):e.scanner.lookahead==="("?e.shiftedByOne().reduceGroupOpen():e.scanner.lookaheadIsIn(Rc)?Ac(e,e.scanner.shift()):e.scanner.lookahead===" "?So(e.shiftedByOne()):dc(e);var Fc=e=>`Bounded expression ${e} must be a number, string or array`;var $c=(e,t)=>{let r=wb(e,t),n=e.ejectRootIfLimit();return n===void 0?Eb(e,r):e.reduceLeftBound(n,r)},wb=(e,t)=>e.scanner.lookaheadIs("=")?`${t}${e.scanner.shift()}`:Me(t,se.oneCharComparators)?t:e.error(xb),xb="= is not a valid comparator. Use == to check for equality",Eb=(e,t)=>{let r=e.scanner.shiftUntilNextTerminator(),n=qr(r,Ob(t,r+e.scanner.unscanned)),o=e.ejectRangeIfOpen(),i={comparator:t,limit:n},s=o?Ns(i,as)?ur("min",o,i)==="l"?e.error(Db({min:o,max:i})):{min:o,max:i}:e.error(Eo(t)):Sb(i,"==")?i:Ns(i,go)?{min:i}:Ns(i,as)?{max:i}:te(`Unexpected comparator \'${i.comparator}\'`);e.intersect(Ib(s,e))},Ib=(e,t)=>{let r=t.resolveRoot(),n=re(r),o={},i={range:e};return n.every(a=>{switch(a){case"string":return o.string=i,!0;case"number":return o.number=i,!0;case"object":return o.object=i,r.object===!0?!1:et(r.object).every(u=>"class"in u&&u.class===Array);default:return!1}})||t.error(Fc(t.rootToString())),o},Sb=(e,t)=>e.comparator===t,Ns=(e,t)=>e.comparator in t,Ob=(e,t)=>`Comparator ${e} must be followed by a number literal (was \'${t}\')`,Db=e=>`${io(e)} is empty`;var Pc=e=>`Divisibility operand ${e} must be a number`;var Mc=e=>{let t=e.scanner.shiftUntilNextTerminator(),r=to(t,kc(t));r===0&&e.error(kc(0));let n=re(e.resolveRoot());n.length===1&&n[0]==="number"?e.intersect({number:{divisor:r}}):e.error(Pc(e.rootToString()))},kc=e=>`% operator must be followed by a non-zero integer literal (was ${e})`;var Cs=e=>{let t=e.scanner.shift();return t===""?e.finalize():t==="["?e.scanner.shift()==="]"?e.rootToArray():e.error(Tb):Me(t,se.branchTokens)?e.pushRootToBranch(t):t===")"?e.finalizeGroup():Me(t,se.comparatorStartChars)?$c(e,t):t==="%"?Mc(e):t===" "?Cs(e):te(_b(t))},_b=e=>`Unexpected character \'${e}\'`,Tb="Missing expected \']\'";var qc=(e,t)=>t.type.scope.parseCache.get(e)??t.type.scope.parseCache.set(e,Nb(e,t)??Cb(e,t)),Nb=(e,t)=>{if(t.type.scope.addParsedReferenceIfResolvable(e,t))return e;if(e.endsWith("[]")){let r=e.slice(0,-2);if(t.type.scope.addParsedReferenceIfResolvable(e,t))return lr(r)}},Cb=(e,t)=>{let r=new Io(e,t);return So(r),Ab(r)},Ab=e=>{for(;!e.scanner.finalized;)Rb(e);return e.ejectFinalizedRoot()},Rb=e=>e.hasRoot()?Cs(e):So(e);var be=(e,t)=>{let r=le(e);if(r==="string")return qc(e,t);if(r!=="object")return Q(As(r));let n=ar(e);switch(n){case"Object":return Dc(e,t);case"Array":return Ic(e,t);case"RegExp":return{string:{regex:e.source}};case"Function":if(Os(e))return t.type.scope.addAnonymousTypeReference(e,t);if(Fb(e)){let o=e();if(Os(o))return t.type.scope.addAnonymousTypeReference(o,t)}return Q(As("Function"));default:return Q(As(n??ie(e)))}},j_=Symbol("as"),Fb=e=>typeof e=="function"&&e.length===0,As=e=>`Type definitions must be strings or objects (was ${e})`;function $b(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var pr=class{get root(){return this.cache}has(t){return t in this.cache}get(t){return this.cache[t]}set(t,r){return this.cache[t]=r,r}constructor(){$b(this,"cache",{})}},Oo=class extends pr{set(t,r){return this.cache[t]=Le(r),r}};function zc(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Pb(e,t){return t.get?t.get.call(e):t.value}function kb(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function Wc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function dt(e,t){var r=Wc(e,t,"get");return Pb(e,r)}function jc(e,t,r){zc(e,t),t.set(e,r)}function Lc(e,t,r){var n=Wc(e,t,"set");return kb(e,n,r),r}function mt(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}function Do(e,t){zc(e,t),t.add(e)}function Ne(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Mb=e=>({codes:uc(e.codes),keys:e.keys??"loose"}),qb=0,Bc={},Rs={};var jt=new WeakMap,mr=new WeakMap,Uc=new WeakSet,_o=new WeakSet,$s=new WeakSet,To=new WeakSet,Ps=class{getAnonymousQualifiedName(t){let r=0,n=t;for(;this.isResolvable(n);)n=`${t}${r++}`;return`${this.name}.${n}`}addAnonymousTypeReference(t,r){var n;return(n=r.type).includesMorph||(n.includesMorph=t.includesMorph),t.node}get infer(){return Dt}compile(){if(!Rs[this.name]){for(let t in this.aliases)this.resolve(t);Rs[this.name]=dt(this,mr).root}return dt(this,mr).root}addParsedReferenceIfResolvable(t,r){var n;let o=mt(this,To,ks).call(this,t,"undefined",[t]);return o?((n=r.type).includesMorph||(n.includesMorph=o.includesMorph),!0):!1}resolve(t){return mt(this,To,ks).call(this,t,"throw",[t])}resolveNode(t){return typeof t=="string"?this.resolveNode(this.resolve(t).node):t}resolveTypeNode(t){let r=this.resolveNode(t);return Hr(r)?r.node:r}isResolvable(t){return dt(this,jt).has(t)||this.aliases[t]}constructor(t,r={}){Do(this,Uc),Do(this,_o),Do(this,$s),Do(this,To),Ne(this,"aliases",void 0),Ne(this,"name",void 0),Ne(this,"config",void 0),Ne(this,"parseCache",void 0),jc(this,jt,{writable:!0,value:void 0}),jc(this,mr,{writable:!0,value:void 0}),Ne(this,"expressions",void 0),Ne(this,"intersection",void 0),Ne(this,"union",void 0),Ne(this,"arrayOf",void 0),Ne(this,"keyOf",void 0),Ne(this,"valueOf",void 0),Ne(this,"instanceOf",void 0),Ne(this,"narrow",void 0),Ne(this,"morph",void 0),Ne(this,"type",void 0),this.aliases=t,this.parseCache=new Oo,Lc(this,jt,new pr),Lc(this,mr,new pr),this.expressions={intersection:(n,o,i)=>this.type([n,"&",o],i),union:(n,o,i)=>this.type([n,"|",o],i),arrayOf:(n,o)=>this.type([n,"[]"],o),keyOf:(n,o)=>this.type(["keyof",n],o),node:(n,o)=>this.type(["node",n],o),instanceOf:(n,o)=>this.type(["instanceof",n],o),valueOf:(n,o)=>this.type(["===",n],o),narrow:(n,o,i)=>this.type([n,"=>",o],i),morph:(n,o,i)=>this.type([n,"|>",o],i)},this.intersection=this.expressions.intersection,this.union=this.expressions.union,this.arrayOf=this.expressions.arrayOf,this.keyOf=this.expressions.keyOf,this.valueOf=this.expressions.valueOf,this.instanceOf=this.expressions.instanceOf,this.narrow=this.expressions.narrow,this.morph=this.expressions.morph,this.type=Object.assign((n,o={})=>{let i=Ss("\\u03BBtype",n,o,this),s=mt(this,$s,Kc).call(this,i),a=be(n,s);return i.node=Le(Pr(o)?{config:o,node:this.resolveTypeNode(a)}:a),i.flat=Le(gs(i)),i},{from:this.expressions.node}),this.name=mt(this,Uc,jb).call(this,r),r.standard!==!1&&mt(this,_o,Fs).call(this,[Rs.standard],"imports"),r.imports&&mt(this,_o,Fs).call(this,r.imports,"imports"),r.includes&&mt(this,_o,Fs).call(this,r.includes,"includes"),this.config=Mb(r)}};function jb(e){let t=e.name?Bc[e.name]?Q(`A scope named \'${e.name}\' already exists`):e.name:`scope${++qb}`;return Bc[t]=this,t}function Fs(e,t){for(let r of e)for(let n in r)(dt(this,jt).has(n)||n in this.aliases)&&Q(Bb(n)),dt(this,jt).set(n,r[n]),t==="includes"&&dt(this,mr).set(n,r[n])}function Kc(e){return{type:e,path:new ge}}function ks(e,t,r){let n=dt(this,jt).get(e);if(n)return n;let o=this.aliases[e];if(!o)return t==="throw"?te(`Unexpectedly failed to resolve alias \'${e}\'`):void 0;let i=Ss(e,o,{},this),s=mt(this,$s,Kc).call(this,i);dt(this,jt).set(e,i),dt(this,mr).set(e,i);let a=be(o,s);if(typeof a=="string"){if(r.includes(a))return Q(Lb(e,r));r.push(a),a=mt(this,To,ks).call(this,a,"throw",r).node}return i.node=Le(a),i.flat=Le(gs(i)),i}var Be=(e,t={})=>new Ps(e,t),Ms=Be({},{name:"root",standard:!1}),Ze=Ms.type,Lb=(e,t)=>`Alias \'${e}\' has a shallow resolution cycle: ${[...t,e].join("=>")}`,Bb=e=>`Alias \'${e}\' is already defined`;var No=Be({Function:["node",{object:{class:Function}}],Date:["node",{object:{class:Date}}],Error:["node",{object:{class:Error}}],Map:["node",{object:{class:Map}}],RegExp:["node",{object:{class:RegExp}}],Set:["node",{object:{class:Set}}],WeakMap:["node",{object:{class:WeakMap}}],WeakSet:["node",{object:{class:WeakSet}}],Promise:["node",{object:{class:Promise}}]},{name:"jsObjects",standard:!1}),Gc=No.compile();var Hc={bigint:!0,boolean:!0,null:!0,number:!0,object:!0,string:!0,symbol:!0,undefined:!0},Co=Be({any:["node",Hc],bigint:["node",{bigint:!0}],boolean:["node",{boolean:!0}],false:["node",{boolean:{value:!1}}],never:["node",{}],null:["node",{null:!0}],number:["node",{number:!0}],object:["node",{object:!0}],string:["node",{string:!0}],symbol:["node",{symbol:!0}],true:["node",{boolean:{value:!0}}],unknown:["node",Hc],void:["node",{undefined:!0}],undefined:["node",{undefined:!0}]},{name:"ts",standard:!1}),Lt=Co.compile();var Ub=e=>{let t=e.replace(/[- ]+/g,""),r=0,n,o,i;for(let s=t.length-1;s>=0;s--)n=t.substring(s,s+1),o=parseInt(n,10),i?(o*=2,o>=10?r+=o%10+1:r+=o):r+=o,i=!i;return!!(r%10===0&&t)},zb=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,Jc=Ze([zb,"=>",(e,t)=>Ub(e)||!t.mustBe("a valid credit card number")],{mustBe:"a valid credit card number"});var Wb=/^[./-]$/,Kb=/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([.,]\\d+(?!:))?)?(\\17[0-5]\\d([.,]\\d+)?)?([zZ]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$/,Gb=e=>!isNaN(e),Ao=e=>`a ${e}-formatted date`,Hb=(e,t)=>{if(!t?.format){let a=new Date(e);return Gb(a)?a:"a valid date"}if(t.format==="iso8601")return Kb.test(e)?new Date(e):Ao("iso8601");let r=e.split(Wb),n=e[r[0].length],o=n?t.format.split(n):[t.format];if(r.length!==o.length)return Ao(t.format);let i={};for(let a=0;a",(e,t)=>{let r=Hb(e);return typeof r=="string"?t.mustBe(r):r}]);var Jb=Ze([es,"|>",e=>parseFloat(e)],{mustBe:"a well-formed numeric string"}),Vb=Ze([Lt.string,"|>",(e,t)=>{if(!kr(e))return t.mustBe("a well-formed integer string");let r=parseInt(e);return Number.isSafeInteger(r)?r:t.mustBe("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")}]),Yb=Ze(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/,{mustBe:"a valid email"}),Zb=Ze(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,{mustBe:"a valid UUID"}),Qb=Ze(/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/,{mustBe:"a valid semantic version (see https://semver.org/)"}),Xb=Ze([Lt.string,"|>",e=>JSON.parse(e)],{mustBe:"a JSON-parsable string"}),Ro=Be({alpha:[/^[A-Za-z]*$/,":",{mustBe:"only letters"}],alphanumeric:[/^[A-Za-z\\d]*$/,":",{mustBe:"only letters and digits"}],lowercase:[/^[a-z]*$/,":",{mustBe:"only lowercase letters"}],uppercase:[/^[A-Z]*$/,":",{mustBe:"only uppercase letters"}],creditCard:Jc,email:Yb,uuid:Zb,parsedNumber:Jb,parsedInteger:Vb,parsedDate:Vc,semver:Qb,json:Xb,integer:["node",{number:{divisor:1}}]},{name:"validation",standard:!1}),Yc=Ro.compile();var Fo=Be({},{name:"standard",includes:[Lt,Gc,Yc],standard:!1}),ev=Fo.compile(),ht={root:Ms,tsKeywords:Co,jsObjects:No,validation:Ro,ark:Fo};var tv=Fo.type;var rv=ht.ark.intersection,nv=ht.ark.union,ov=ht.ark.arrayOf,iv=ht.ark.keyOf,sv=ht.ark.instanceOf,av=ht.ark.valueOf,uv=ht.ark.narrow,cv=ht.ark.morph;var{DataRequest:Zc,DataResponse:R1}=Be({DataRequest:{id:"number",method:"string",params:"any[]"},DataResponse:{id:"number","eventName?":"string",payload:"any",error:"any"}}).compile(),Qc="__METHODS__",Xc="__EVAL__";var lv=typeof parent<"u"&&typeof window<"u"&&window!==parent?parent.postMessage:postMessage,Yr=class{methods;constructor(t){if(!(typeof self<"u"&&typeof postMessage=="function"&&typeof addEventListener=="function"))throw new Error("Script must be executed as a worker");this.methods={...t,[Qc]:()=>Object.keys(t),[Xc]:(r,...n)=>new Function(`return (${r})`)()(...n)},addEventListener("message",r=>this.onMessage(r.data)),this.send("ready")}send(t,r){lv(t,r)}async onMessage(t){let{data:r,problems:n}=Zc(t);if(n)return this.send({id:-1,payload:null,error:n.toString()});try{let o=this.methods[r.method];if(!o)throw new Error(\'Unknown method "\'+r.method+\'"\');let i=await o.apply(o,r.params);this.send({id:r.id,payload:i,error:null})}catch(o){console.error(o),this.send({id:r.id,payload:null,error:fv(o)})}}emit(t,r){this.send({eventName:t,payload:r,id:-1,error:null})}};function fv(e){return Object.getOwnPropertyNames(e).reduce((t,r)=>Object.defineProperty(t,r,{value:e[r],enumerable:!0}),{})}var el=e=>`obsidian-zotero:${e}`;var Ls=({key:e,groupID:t,parentItem:r},n=!1)=>{let o=[e];return!n&&r&&o.push(`a${r}`),typeof t=="number"&&o.push(`g${t}`),o.join("")},tl=(e,t,r=!0)=>(n,...o)=>{let i="";for(let s=0;s0&&(i+=e(o[s-1])),i+=(r?n.raw:n)[s];return t(i)},Bs=(e=!0,t)=>tl(r=>r,r=>new RegExp(e?"^"+r+"$":r,t),!0),qs=String.raw`[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}`,js=String.raw`\\d+`,rl=e=>{let t={annotKey:qs,parentKey:qs,groupID:js,page:js};if(e)for(let r in t)t[r]=`(${t[r]})`;return tl(r=>t[r],r=>r)`${"annotKey"}a${"parentKey"}(?:g${"groupID"})?(?:p${"page"})?`},k1=Bs()`${qs}(?:g${js})?`,M1=Bs()`${rl(!0)}`,q1=Bs()`(?:${rl(!1)}n?)+`;var mv=/^[0-9]{4}\\-(0[0-9]|10|11|12)\\-(0[0-9]|[1-2][0-9]|30|31) /;var dv=/^\\-?[0-9]{4}\\-(0[1-9]|10|11|12)\\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/,hv=/^\\-?[0-9]{4}\\-(0[1-9]|10|11|12)\\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9])$/,gv=e=>yv(e)||bv(e)?!1:mv.test(e),nl=e=>e?gv(e)?e.substring(0,10):"0000-00-00":"";var yv=e=>dv.test(e),bv=e=>hv.test(e);var ol=(e,t,{getLogger:r,configure:n})=>{let o=el(e);return n({appenders:{out:{type:"console"}},categories:{default:{appenders:["out"],level:t},[o]:{appenders:["out"],level:t}}}),r(o)};var il=()=>(...e)=>e;function sl(e,t){let r=Object.keys(t).map(n=>vv(e,n,t[n]));return r.length===1?r[0]:function(){r.forEach(n=>n())}}function vv(e,t,r){let n=e[t],o=e.hasOwnProperty(t),i=r(n);return n&&Object.setPrototypeOf(i,n),Object.setPrototypeOf(s,i),e[t]=s,a;function s(...u){return i===n&&e[t]===s&&a(),i.apply(this,u)}function a(){e[t]===s&&(o?e[t]=n:delete e[t]),i!==n&&(i=n,Object.setPrototypeOf(s,n||Function))}}var al=e=>{let t=r=>async(...n)=>{try{return await r(...n)}catch(o){throw console.error(o),o}};return sl(e,Object.fromEntries(Object.keys(e).map(r=>[r,t]))),e};var ul;(function(e){e[e.highlight=1]="highlight",e[e.note=2]="note",e[e.image=3]="image",e[e.ink=4]="ink",e[e.underline=5]="underline",e[e.text=6]="text"})(ul||(ul={}));var cl;(function(e){e[e.manual=0]="manual",e[e.auto=1]="auto"})(cl||(cl={}));var ll;(function(e){e[e.importedFile=0]="importedFile",e[e.importedUrl=1]="importedUrl",e[e.linkedFile=2]="linkedFile",e[e.linkedUrl=3]="linkedUrl",e[e.embeddedImage=4]="embeddedImage"})(ll||(ll={}));var Us;(function(e){e[e.fullName=0]="fullName",e[e.nameOnly=1]="nameOnly"})(Us||(Us={}));var zs=["attachment","note","annotation"];var $o=zs.map(e=>`\'${e}\'`).join(",");var ve=(e="itemID")=>`--sql\n ${e} IS NOT NULL\n ${e==="itemID"?`AND ${e} NOT IN (SELECT itemID FROM deletedItems)`:""}\n`,Ue=(e,t="$itemId")=>typeof e=="boolean"?"":`AND ${e} = ${t}`;var Z=class{statement;constructor(t){this.statement=t.prepare(this.sql())}get database(){return this.statement.database}get(t){return this.statement.get(t)}all(t){return this.statement.all(t)}},dr=class extends Z{query(t){return this.all(t)}},Po=class extends Z{query(){return this.all([])}},hr=class extends Z{query(t){return this.all(t).map(r=>this.parse(r,t))}};var Ws=(e,t)=>{for(let r=0;re?.split("|").map(t=>parseInt(t,10))??[];var ko=`--sql\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n annots.type,\n annots.authorName,\n annots.text,\n annots.comment,\n annots.color,\n annots.pageLabel,\n annots.sortIndex,\n annots.position,\n annots.isExternal\n`,Mo=`--sql\n itemAnnotations annots\n JOIN items USING (itemID)\n`,qo=(e,t,r)=>Object.assign(e,{sortIndex:Ks(e.sortIndex),position:JSON.parse(e.position),libraryID:t,groupID:r,itemType:"annotation"});var wv=`--sql\nSELECT\n ${ko},\n annots.parentItemID,\n parentItems.key as parentItem\nFROM\n ${Mo}\n JOIN items as parentItems ON annots.parentItemID = parentItems.itemID\nWHERE\n items.key = $annotKey\n AND items.libraryID = $libId\n AND ${ve("items.itemID")}\n`,Zr=class extends Z{trxCache={};sql(){return wv}parse(t,r){return qo(t,r.libId,r.groupID)}query(t){let{annotKeys:r,libId:n}=t,o=s=>s.reduce((a,u)=>{let m=this.get({annotKey:u,libId:n});return m&&(a[u]=this.parse(m,t)),a},{});return(this.trxCache[n]??=this.database.transaction(o))(r)}};var xv=`--sql\nSELECT\n ${ko}\nFROM\n ${Mo}\nWHERE\n parentItemID = $attachmentId\n AND items.libraryID = $libId\n AND ${ve()}\n`,Qr=class extends hr{sql(){return xv}getKeyStatement=this.database.prepare("SELECT key FROM items WHERE itemID = $attachmentId AND libraryID = $libId");parse(t,r,n){return Object.assign(qo(t,r.libId,r.groupID),{parentItem:n,parentItemID:r.attachmentId})}query(t){let r=this.getKeyStatement.get(t)?.key;if(r===void 0)throw new Error("Parent item not found");return this.all(t).map(n=>this.parse(n,t,r)).sort((n,o)=>Ws(n.sortIndex,o.sortIndex))}};var jo=`--sql\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n notes.note,\n notes.title\n`,Lo=`--sql\n itemNotes notes\n JOIN items USING (itemID)\n`,Bo=(e,t,r)=>Object.assign(e,{libraryID:t,groupID:r,itemType:"note"});var Ev=`--sql\nSELECT\n ${jo},\n notes.parentItemID,\n parentItems.key as parentItem\nFROM\n ${Lo}\n JOIN items as parentItems ON notes.parentItemID = parentItems.itemID\nWHERE\n items.key = $noteKey\n AND items.libraryID = $libId\n AND ${ve("items.itemID")}\n`,Xr=class extends Z{trxCache={};sql(){return Ev}parse(t,r){return Bo(t,r.libId,r.groupID)}query(t){let{noteKeys:r,libId:n}=t,o=s=>s.reduce((a,u)=>{let m=this.get({noteKey:u,libId:n});return m&&(a[u]=this.parse(m,t)),a},{});return(this.trxCache[n]??=this.database.transaction(o))(r)}};var Iv=`--sql\nSELECT\n ${jo}\nFROM\n ${Lo}\nWHERE\n parentItemID = $itemID\n AND items.libraryID = $libId\n AND ${ve()}\n`,en=class extends hr{sql(){return Iv}getKeyStatement=this.database.prepare("SELECT key FROM items WHERE itemID = $itemID AND libraryID = $libId");parse(t,r,n){return Object.assign(Bo(t,r.libId,r.groupID),{parentItem:n,parentItemID:r.itemID})}query(t){let r=this.getKeyStatement.get(t)?.key;if(r===void 0)throw new Error("Parent item not found");return this.all(t).map(n=>this.parse(n,t,r))}};var Sv=`--sql\nSELECT\n atchs.itemID,\n atchs.path,\n atchs.contentType,\n atchs.linkMode,\n charsets.charset,\n items.key,\n COUNT(atchs.itemID) as annotCount\nFROM\n itemAttachments atchs\n JOIN items USING (itemID)\n LEFT JOIN charsets USING (charsetID)\n LEFT JOIN itemAnnotations annots ON atchs.itemID = annots.parentItemID\nWHERE\n atchs.parentItemID = $itemId\n AND libraryID = $libId\n AND ${ve("atchs.itemID")}\nGROUP BY atchs.itemID\n`,tn=class extends dr{sql(){return Sv}};var ot="betterbibtex",Bt="bbts";var Ov=`--sql\nSELECT\n citationkey as citekey\nFROM\n ${ot}.citationkey\nWHERE\n itemID = $itemID\n AND (libraryID IS NULL OR libraryID = $libId)\n`,Dv=`--sql\nSELECT\n citekey\nFROM\n ${Bt}.citekeys\nWHERE\n itemID = $itemID\n AND (libraryID IS NULL OR libraryID = $libId)\n`,rn=class extends Z{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemID:n,libId:o});return i&&(r[n]=i.citekey),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Ov}query(t){return this.trx(t.items)}},nn=class extends Z{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemID:n,libId:o});return i&&(r[n]=i.citekey),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Dv}query(t){return this.trx(t.items)}};var _v=`--sql\nSELECT\n itemID\nFROM\n ${ot}.citationkey\nWHERE\n citationkey = $citekey\n`,Tv=`--sql\nSELECT\n itemID\nFROM\n ${Bt}.citekeys\nWHERE\n citekey = $citekey\n`,on=class extends Z{trxFunc=t=>t.reduce((r,n)=>{let o=this.get({citekey:n});return r[n]=o?.itemID??-1,r},{});trx=this.database.transaction(this.trxFunc);sql(){return _v}query(t){return this.trx(t.citekeys)}},sn=class extends Z{trxFunc=t=>t.reduce((r,n)=>{let o=this.get({citekey:n});return r[n]=o?.itemID??-1,r},{});trx=this.database.transaction(this.trxFunc);sql(){return Tv}query(t){return this.trx(t.citekeys)}};var Uo=e=>`--sql\nSELECT\n itemID,\n creators.firstName,\n creators.lastName,\n creators.fieldMode,\n creatorTypes.creatorType,\n orderIndex\nFROM\n items\n LEFT JOIN itemCreators USING (itemID)\n JOIN creators USING (creatorID)\n JOIN creatorTypes USING (creatorTypeID)\nWHERE\n libraryID = $libId\n ${Ue(e||"itemID")}\n AND ${ve()}\nORDER BY\n itemID,\n orderIndex\n`;var KT=Uo(!0);function fl(e){for(var t={},r=e.length,n=0;nt.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return Nv}query(t){return Ut(this.trx(t))}};var zo=e=>`--sql\nSELECT\n items.itemID,\n fieldsCombined.fieldName,\n itemDataValues.value\nFROM\n items\n JOIN itemData USING (itemID)\n JOIN itemDataValues USING (valueID)\n JOIN fieldsCombined USING (fieldID)\n JOIN itemTypesCombined USING (itemTypeID)\nWHERE\n libraryID = $libId\n ${Ue(e||"items.itemID")}\n AND itemTypesCombined.typeName NOT IN (${$o})\n AND ${ve()}\n`;var FN=zo(!0);var Cv=zo(!1),un=class extends Z{trxFunc=t=>t.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return Cv}query(t){return Ut(this.trx(t))}};var cn=e=>`--sql\nSELECT\n items.libraryID,\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n itemTypesCombined.typeName as itemType,\n json_group_array(collectionID) filter (where collectionID is not null) as collectionIDs\nFROM \n items\n JOIN itemTypesCombined USING (itemTypeID)\n LEFT JOIN collectionItems USING (itemID)\nWHERE \n libraryID = $libId\n ${e==="full"?Ue(!1):e==="id"?Ue("items.itemID"):Ue("items.key","$key")}\n AND ${ve()}\n AND itemType NOT IN (${$o})\nGROUP BY itemID\n`;var Av=cn("full"),ln=class extends Z{sql(){return Av}query(t){return this.all(t).map(({collectionIDs:n,...o})=>({...o,collectionIDs:JSON.parse(n)}))}};var Rv=cn("id"),Fv=cn("key"),fn=class extends Z{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemId:n,libId:o});return i&&(r[n]={...i,collectionIDs:JSON.parse(i.collectionIDs)}),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Rv}query(t){return this.trx(t)}},pn=class extends Z{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({key:n,libId:o});return i&&(r[n]={...i,collectionIDs:JSON.parse(i.collectionIDs)}),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Fv}query(t){return this.trx(t)}};var mn=e=>`--sql\nWITH\n RECURSIVE CollectionPath AS (\n -- Base case: collections without a parent\n SELECT\n collectionID,\n parentCollectionID,\n collectionName AS path\n FROM\n collections\n WHERE\n libraryID = $libId\n ${e==="full"?Ue(!1):e==="id"?Ue("collectionID","$collectionID"):Ue("key","$key")}\n AND ${ve("collectionID")}\n UNION ALL\n -- Recursive case: join with parent collections\n SELECT\n prev.collectionID,\n c.parentCollectionID,\n c.collectionName\n FROM\n collections c\n JOIN CollectionPath prev ON c.collectionID = prev.parentCollectionID\n )\nSELECT\n p.collectionID,\n json_group_array(p.path) path,\n c.key,\n c.collectionName,\n c.libraryID\nFROM\n CollectionPath p\n JOIN collections c USING (collectionID)\nGROUP BY\n collectionID\nORDER BY\n collectionID;\n`;function Gs({collectionID:e,collectionName:t,path:r,...n}){return{...n,id:e,name:t,path:JSON.parse(r)}}var ZN=mn("full");var $v=mn("id"),tC=mn("key"),dn=class extends Z{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({collectionID:n,libId:o});return i&&r.set(n,Gs(i)),r},new Map);trx=this.database.transaction(this.trxFunc);sql(){return $v}query(t){return this.trx(t)}};var Pv=`--sql\nSELECT\n libraries.libraryID,\n groups.groupID,\n CASE\n libraries.type\n WHEN \'user\' THEN \'My Library\'\n WHEN \'group\' THEN groups.name\n ELSE NULL\n END AS name\nFROM\n libraries\n LEFT JOIN groups USING (libraryID)\nWHERE\n libraries.libraryID IS NOT NULL\nORDER BY\n libraryID\n`,hn=class extends Po{sql(){return Pv}};var kv=`--sql\nSELECT\n tagID,\n type,\n name\nFROM\n itemTags\n JOIN items USING (itemID)\n JOIN tags USING (tagID)\nWHERE\n itemID = $itemId\n AND tagID IS NOT NULL\n AND libraryID = $libId\n`,gn=class extends Z{trxFunc=t=>t.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return kv}query(t){return Ut(this.trx(t))}};var Mv=new Set(il()("creators","itemID","itemType","key","libraryID","collections"));var Qh=$r(Js(),1);var $d=$r(Js(),1),xi=$r(Fd(),1),rI="INFO",Pd=ol("db-worker",rI,xi.default),Ma="log4js_loglevel";$d.default.getItem(Ma).then(e=>{typeof e=="string"&&e in xi.levels&&(Pd.level=e,console.debug(`Read from localforage: loglevel ${e}`))});var oe=Pd;var yh=require("fs"),bh=$r(hh(),1);var bt=class extends Error{constructor(){super("Database not set")}},gh=e=>{try{return(0,yh.statSync)(e).mtimeMs}catch(t){if(t.code==="ENOENT")return-1;throw t}},Bn=class{database=null;get instance(){return this.database?.instance}get databaseList(){return this.instance?.pragma("database_list")??[]}tableExists(t,r=""){if(!this.database)throw new bt;let n=r||"main",{exist:o}=(this.database.existStatements[n]??=this.database.instance.prepare(`SELECT count(*) AS exist FROM ${r?`${r}.`:""}sqlite_master WHERE type = \'table\' AND name = $tableName`)).get({tableName:t});return!!o}attachDatabase(t,r){if(!this.instance)throw new bt;this.instance.prepare(`ATTACH DATABASE $path AS ${r}`).run({path:t})}detachDatabase(t){if(!this.instance)throw new bt;this.instance.prepare(`DETACH DATABASE ${t}`).run()}isUpToDate(){if(!this.database)return null;let t=gh(this.database.file);return t===-1?null:this.database.mtime===t}opened=!1;open(t,r){try{this.database?.instance&&(oe.debug("Database opened before, closing: ",this.database.instance.name),this.close());let n=gh(t);return n===-1?(this.opened=!1,!1):(this.database={mtime:n,instance:AI(t,r),file:t,existStatements:{},prepared:new Map},oe.debug("Database opened: ",t),this.opened=!0,!0)}catch(n){throw oe.error("Failed to open database",t),n}}close(){this.opened=!1,this.instance?.close(),this.database=null}prepare(t){if(!this.database)throw new bt;let r=this.database.prepared.get(t);if(r)return r;let n=new t(this.database.instance);return this.database.prepared.set(t,n),n}};function AI(e,t){return new bh.default(`file:${e}?mode=ro&immutable=1`,{nativeBinding:t.nativeBinding,uriPath:!0,verbose:void 0})}function RI(e){return e.tableExists("citationkey",ot)}var Un=class{#e=null;get instance(){return this.status==="READY"?this.#e:null}get zotero(){if(!this.#e)throw new Error("database not ready");return this.#e.zotero}status="NOT_INITIALIZED";get loadStatus(){if(this.#e?.zotero.opened!==!0)return{main:!1,bbtMain:!1,bbtSearch:null};let t=this.#e.zotero.databaseList;return t.some(o=>o.name===ot)?this.#e.bbtAfterMigration?{main:!0,bbtMain:!0,bbtSearch:null}:{main:!0,bbtMain:!0,bbtSearch:t.some(o=>o.name===Bt)}:{main:!0,bbtMain:!1,bbtSearch:null}}get bbtLoadStatus(){let t=this.loadStatus;return t.bbtMain?t.bbtSearch!==!1:!1}getItemIDsFromCitekey(t){if(!this.#e)throw new bt;let r=this.#e.bbtAfterMigration?on:sn;return this.#e.zotero.prepare(r).query({citekeys:t})}getCitekeys(t){if(!this.#e)throw new bt;let r=this.#e.bbtAfterMigration?rn:nn;return this.#e.zotero.prepare(r).query({items:t})}load(t,r){let n={zotero:this.#e?.zotero??new Bn};try{let o=n.zotero.open(t.zotero,r);if(!o)throw new Error(`Failed to open main database, no database found at ${t.zotero}`);let i=FI(t,n.zotero),s=n.zotero.prepare(hn).query().reduce((a,u)=>(a[u.libraryID]=u,a),{});return this.#e={...n,bbtAfterMigration:i.bbtSearch===null,libraries:s},this.status="READY",{main:o,...i}}catch(o){throw this.status="ERROR",o}}groupOf(t){if(!this.#e)throw new Error("Library info not loaded");return this.#e.libraries[t].groupID}get libraries(){if(!this.#e)throw new Error("Library info not loaded");return Object.values(this.#e.libraries)}};function FI(e,t){try{t.attachDatabase(`file:${e.bbtMain}?mode=ro&immutable=1`,ot)}catch(n){let{code:o}=n;return o==="SQLITE_CANTOPEN"?oe.debug(`Unable to open bbt main database, no database found at ${e.bbtMain}`):oe.debug(`Unable to open bbt main database, ${o} @ ${e.bbtMain}`),{bbtMain:!1,bbtSearch:null}}if(RI(t))return{bbtMain:!0,bbtSearch:null};try{t.attachDatabase(`file:${e.bbtSearch}?mode=ro&immutable=1`,ot)}catch(n){let{code:o}=n;return o==="SQLITE_CANTOPEN"?oe.debug(`Unable to open bbt search database, no database found at ${e.bbtSearch}`):oe.debug(`Unable to open bbt search database, ${o} @ ${e.bbtSearch}`),{bbtMain:!0,bbtSearch:!1}}return{bbtMain:!0,bbtSearch:!0}}var xh=$r(wh(),1);var $I=e=>typeof e[0][0]=="string";function Eh(e){return[...new Set(e)]}var zn=class{#e=Ci;async get(t,r){if(t.length===0)return[];if(!r)return await Promise.all(t.map(([i,s])=>this.#t(i,s)));let n=$I(t)?this.#e.readItemByKey(t):this.#e.readItemById(t);return await this.#e.updateIndex(n),Object.values(n)}async#t(t,r){let n=await this.#e.getItemsCache(r);return typeof t=="number"?n.byId.get(t)??null:typeof t=="string"?n.byKey.get(t)??null:((0,xh.assertNever)(t),null)}};function Wn(){this.cache=null,this.matcher=null,this.stemmer=null,this.filter=null}Wn.prototype.add;Wn.prototype.append;Wn.prototype.search;Wn.prototype.update;Wn.prototype.remove;function Tr(e,t){return typeof e<"u"?e:t}function za(e){let t=new Array(e);for(let r=0;r1&&(e=Wa(e,this.stemmer)),n&&e.length>1&&(e=PI(e)),r||r==="")){let o=e.split(r);return this.filter?kI(o,this.filter):o}return e}var Th=/[\\p{Z}\\p{S}\\p{P}\\p{C}]+/u;function Nh(e){let t=H();for(let r=0,n=e.length;r=0;m--){let l=e[m],d=l.length,f=H(),g=!s;for(let w=0;w=0;m--){l=n[m],d=l.length;for(let f=0,g;f0;n--)this.queue[n]=this.queue[n-1];this.queue[0]=e}this.cache[e]=t};Fi.prototype.get=function(e){let t=this.cache[e];if(this.limit&&t){let r=this.queue.indexOf(e);if(r){let n=this.queue[r-1];this.queue[r-1]=this.queue[r],this.queue[r]=n}}return t};Fi.prototype.del=function(e){for(let t=0,r,n;t=this.minlength&&(a||!s[l])){let f=ki(u,o,m),g="";switch(this.tokenize){case"full":if(d>2){for(let w=0;ww;x--)if(x-w>=this.minlength){let S=ki(u,o,m,d,w);g=l.substring(w,x),this.push_index(s,g,S,e,r)}break}case"reverse":if(d>1){for(let w=d-1;w>0;w--)if(g=l[w]+g,g.length>=this.minlength){let x=ki(u,o,m,d,w);this.push_index(s,g,x,e,r)}g=""}case"forward":if(d>1){for(let w=0;w=this.minlength&&this.push_index(s,g,f,e,r);break}default:if(this.boost&&(f=Math.min(f/this.boost(t,l,m)|0,u-1)),this.push_index(s,l,f,e,r),a&&o>1&&m=this.minlength&&!w[l]){w[l]=1;let k=ki(x+(o/2>x?0:1),o,m,N-1,M-1),ee=this.bidirectional&&l>S;this.push_index(i,ee?S:l,k,e,r,ee?l:S)}}}}}this.fastupdate||(this.register[e]=1)}}return this};function ki(e,t,r,n,o){return r&&e>1?t+(n||0)<=e?r+(o||0):(e-1)/(t+(n||0))*(r+(o||0))+1|0:0}_e.prototype.push_index=function(e,t,r,n,o,i){let s=i?this.ctx:this.map;if((!e[t]||i&&!e[t][i])&&(this.optimize&&(s=s[r]),i?(e=e[t]||(e[t]=H()),e[i]=1,s=s[i]||(s[i]=H())):e[t]=1,s=s[t]||(s[t]=[]),this.optimize||(s=s[r]||(s[r]=[])),(!o||!s.includes(n))&&(s[s.length]=n,this.fastupdate))){let a=this.register[n]||(this.register[n]=[]);a[a.length]=s}};_e.prototype.search=function(e,t,r){r||(!t&&Ve(e)?(r=e,e=r.query):Ve(t)&&(r=t));let n=[],o,i,s,a=0;if(r&&(e=r.query||e,t=r.limit,a=r.offset||0,i=r.context,s=!0&&r.suggest),e&&(e=this.encode(""+e),o=e.length,o>1)){let d=H(),f=[];for(let g=0,w=0,x;g=this.minlength&&!d[x]){if(!this.optimize&&!s&&!this.map[x])return n;f[w++]=x,d[x]=1}e=f,o=e.length}if(!o)return n;t||(t=100);let u=this.depth&&o>1&&i!==!1,m=0,l;u?(l=e[0],m=1):o>1&&e.sort(Oh);for(let d,f;m=r)))));d++);if(m){if(o)return Uh(a,r,0);e[e.length]=a;return}}return!t&&a};function Uh(e,t,r){return e.length===1?e=e[0]:e=Sh(e),r||e.length>t?e.slice(r,r+t):e}function Bh(e,t,r,n){if(r){let o=n&&t>r;e=e[o?t:r],e=e&&e[o?r:t]}else e=e[t];return e}_e.prototype.contain=function(e){return!!this.register[e]};_e.prototype.update=function(e,t){return this.remove(e).add(e,t)};_e.prototype.remove=function(e,t){let r=this.register[e];if(r){if(this.fastupdate)for(let n=0,o;n1&&(e.splice(s,1),i++):i++}else{o=Math.min(e.length,r);for(let s=0,a;s"u"&&self.exports,o=this;this.worker=BI(r,n,e.worker),this.resolver=H(),this.worker&&(n?this.worker.on("message",function(i){o.resolver[i.id](i.msg),delete o.resolver[i.id]}):this.worker.onmessage=function(i){i=i.data,o.resolver[i.id](i.msg),delete o.resolver[i.id]},this.worker.postMessage({task:"init",factory:r,options:e}))}var Kh=Hn;Jn("add");Jn("append");Jn("search");Jn("update");Jn("remove");function Jn(e){Hn.prototype[e]=Hn.prototype[e+"Async"]=function(){let t=this,r=[].slice.call(arguments),n=r[r.length-1],o;Kn(n)&&(o=n,r.splice(r.length-1,1));let i=new Promise(function(s){setTimeout(function(){t.resolver[++Wh]=s,t.worker.postMessage({task:e,id:Wh,args:r})})});return o?(i.then(o),this):i}}function BI(factory,is_node_js,worker_path){let worker;try{worker=is_node_js?eval(\'new (require("worker_threads")["Worker"])("../dist/node/node.js")\'):factory?new Worker(URL.createObjectURL(new Blob(["onmessage="+zh.toString()],{type:"text/javascript"}))):new Worker(fe(worker_path)?worker_path:"worker/worker.js",{type:"module"})}catch(e){}return worker}function Te(e){if(!(this instanceof Te))return new Te(e);let t=e.document||e.doc||e,r;this.tree=[],this.field=[],this.marker=[],this.register=H(),this.key=(r=t.key||t.id)&&Li(r,this.marker)||"id",this.fastupdate=Tr(e.fastupdate,!0),!0&&(this.storetree=(r=t.store)&&r!==!0&&[],this.store=r&&H()),!0&&(this.tag=(r=t.tag)&&Li(r,this.marker),this.tagindex=r&&H()),!0&&(this.cache=(r=e.cache)&&new $i(r),e.cache=!1),!0&&(this.worker=e.worker),!0&&(this.async=!1),this.index=UI.call(this,e,t)}var Hh=Te;function UI(e,t){let r=H(),n=t.index||t.field||t;fe(n)&&(n=[n]);for(let o=0,i,s;o=0&&(e=e.substring(0,e.length-2),e&&(t[n]=!0)),e&&(r[n++]=e);return n1?r:r[0]}function Va(e,t){if(fe(t))e=e[t];else for(let r=0;e&&r1?r.splice(n,1):delete this.tagindex[t])}!0&&this.store&&delete this.store[e],delete this.register[e]}return this};Te.prototype.search=function(e,t,r,n){r||(!t&&Ve(e)?(r=e,e=""):Ve(t)&&(r=t,t=0));let o=[],i=[],s,a,u,m,l,d,f=0;if(r)if(rr(r))u=r,r=null;else{if(e=r.query||e,s=r.pluck,u=s||r.index||r.field,m=!0&&r.tag,a=!0&&this.store&&r.enrich,l=r.bool==="and",t=r.limit||t||100,d=r.offset||0,m&&(fe(m)&&(m=[m]),!e)){for(let w=0,x;w1||m&&m.length>1);let g=!n&&(this.worker||this.async)&&[];for(let w=0,x,S,N;w0)return(i>t||r)&&(o=o.slice(r,r+t)),n&&(o=Jh.call(this,o)),{tag:e,result:o}}function Jh(e){let t=new Array(e.length);for(let r=0,n;r{e=n,t=o});return{resolve:e,reject:t,promise:r}}var Vn=class{#e=Ar;readCitekeys(t){if(oe.debug("Reading Better BibTex database"),!this.#e.bbtLoadStatus)return oe.info("Better BibTex database not enabled, skipping..."),[];let r=this.#e.getCitekeys(t);return oe.info("Finished reading Better BibTex"),r}toItemObjects(t,r){let n=this.readCitekeys(r),o=this.#e.zotero.prepare(un).query(r),i=this.#e.zotero.prepare(an).query(r),s=Eh(r.flatMap(([u])=>t[u]?.collectionIDs?.map(m=>`${m}-${t[u].libraryID}`)??[])).filter(u=>u!==null),a=this.#e.zotero.prepare(dn).query(s.map(u=>u.split("-").map(m=>+m)));return r.reduce((u,[m,l])=>{if(!m)return u;let d=n[m];d||oe.warn(`Citekey: No item found for itemID ${m}`,d);let f=o[m].reduce((N,M)=>{let{value:k}=M;return M.fieldName==="date"&&(k=nl(k).split("-")[0]),(N[M.fieldName]??=[]).push(k),N},{}),{collectionIDs:g,...w}=t[m],x=g.map(N=>a.get(N)).filter(N=>N!==void 0),S={...w,libraryID:l,groupID:this.#e.groupOf(l),itemID:m,creators:i[m],collections:x,citekey:n[m],...f,dateAccessed:HI(f)?JI(f.accessDate[0]):null};return u[m]=S,u},{})}};function HI(e){let t=e;return Array.isArray(t.accessDate)&&t.accessDate.length===1&&typeof t.accessDate[0]=="string"}function JI(e){let t=e.replace(" ","T")+"Z";try{return new Date(t)}catch{return null}}var Yn=class{#e=Ar;#t=new Vn;#r=new Hh({worker:!0,charset:Ch,language:Vh,document:{id:"itemID",index:["title","creators[]:firstName","creators[]:lastName","date"]},tokenize:"full",suggest:!0});#o=new Map;#n=new Map;getStatus(t){if(!this.#n.has(t)){let n=Yh();return this.#n.set(t,n),n.promise}let r=this.#n.get(t);return r instanceof Promise||typeof r=="string"?r:r.promise}load(t){let r=this.#n.get(t);if(r instanceof Promise)return r;let n=this.#a(t),o=this.#u(t,n).then(()=>{this.#n.set(t,"READY")}).catch(i=>{throw this.#n.set(t,"ERROR"),i});return typeof r=="string"||!r||o.then(r.resolve,r.reject),this.#n.set(t,o),o}async searchItems(t,r){return await this.#i(t),await this.#r.searchAsync(r)}async getCachedItems(t,r){await this.#i(r);let n=this.#o.get(r);if(!n)throw new Error("Cache not initialized");let o=[...n.byId.values()].sort((i,s)=>s.dateAccessed&&i.dateAccessed?s.dateAccessed.getTime()-i.dateAccessed.getTime():0);return t<=0?o:o.slice(0,t)}async getItemsCache(t){await this.#i(t);let r=this.#o.get(t);if(!r)throw new Error("Cache not initialized");return r}async#i(t){let r=this.getStatus(t);if(r==="ERROR")throw new Error("Indexing failed");r instanceof Promise&&await r}#a(t){oe.debug("Reading main Zotero database for index");let{zotero:r}=this.#e,n=this.#s(r.prepare(ln).query({libId:t}));return oe.info("Finished reading main Zotero database for index"),n}readItemByKey(t){let{zotero:r}=this.#e,n=r.prepare(pn).query(t);return this.#s(t.map(([i])=>n[i]))}readItemById(t){let{zotero:r}=this.#e,n=r.prepare(fn).query(t);return this.#s(t.map(([i])=>n[i]))}#s(t){let r=t.reduce((o,i)=>(o[i.itemID]=i,o),{}),n=t.map(o=>[o.itemID,o.libraryID]);return this.#t.toItemObjects(r,n)}async#u(t,r){oe.trace("Start flexsearch indexing");let n=Object.values(r),o=this.#o.get(t);if(this.#o.set(t,{byId:new Map(n.map(i=>[i.itemID,i])),byKey:new Map(n.map(i=>[Ls(i,!0),i]))}),!o)await Promise.all([...n.map(i=>this.#r.addAsync(i.itemID,i))]);else{let i=new Set(n.map(a=>a.itemID)),s=[...o.byId.keys()].filter(a=>!i.has(a));o.byId.clear(),o.byKey.clear(),await Promise.all([...n.map(a=>this.#r.addAsync(a.itemID,a)),...s.map(a=>this.#r.removeAsync(a))])}oe.info("Library citation index done: "+t)}async updateIndex(t){await Promise.all(Object.values(t).map(async r=>{let n=this.#o.get(r.libraryID);if(!n)throw new Error("Cannot update index for library not initialized");n.byId.set(r.itemID,r),n.byKey.set(Ls(r,!0),r),await this.#r.updateAsync(r.itemID,r)}))}};var Ar=new Un,Ci=new Yn,Zh=new zn;function nr(e,t){return(...r)=>{oe.debug(`Reading Zotero database for ${typeof t=="string"?t:t(null,...r)}`);let n=e.apply(null,r);return Promise.resolve(n).then(o=>oe.debug(`Finished reading Zotero database for ${typeof t=="string"?t:t(o,...r)}`)),n}}var Qa=class{#e=Ar;#t=Ci;#r=Zh;api={getLibs:()=>this.#e.libraries,initIndex:async t=>{await this.#t.load(t)},openDb:(...t)=>this.#e.load(...t),search:async(t,r)=>await this.#t.searchItems(t,r),getItems:async(t,r)=>await this.#r.get(t,r),getTags:nr(t=>this.#e.zotero.prepare(gn).query(t),"tags"),getItemIDsFromCitekey:t=>this.#e.getItemIDsFromCitekey(t),getItemsFromCache:(t,r)=>this.#t.getCachedItems(t,r),getAttachments:nr((t,r)=>this.#e.zotero.prepare(tn).query({itemId:t,libId:r}),(t,r)=>`attachments of item ${r}`+(t?`, count: ${t.length}`:"")),getAnnotations:nr((t,r)=>this.#e.zotero.prepare(Qr).query({attachmentId:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`annotations of attachment ${r}`+(t?`, count: ${t.length}`:"")),getAnnotFromKey:nr((t,r)=>this.#e.zotero.prepare(Zr).query({annotKeys:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`annotations with keys: ${r.join(",")}`+(t?`, count: ${t.length}`:"")),getNotes:nr((t,r)=>this.#e.zotero.prepare(en).query({itemID:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`notes of literature ${r}`+(t?`, count: ${t.length}`:"")),getNoteFromKey:nr((t,r)=>this.#e.zotero.prepare(Xr).query({noteKeys:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`notes with keys: ${r.join(",")}`+(t?`, count: ${t.length}`:"")),isUpToDate:()=>this.#e.zotero.isUpToDate(),getLoadStatus:()=>{let t=this.#e.loadStatus;return{main:t.main,bbt:this.#e.bbtLoadStatus,bbtVersion:t.bbtSearch===null?"v1":"v0"}},raw:(t,r,n)=>{let{zotero:{instance:o}}=this.#e;if(!o)throw new Error("failed to query raw: no main database opened");return o.prepare(r)[t](...n)},setLoglevel:t=>{oe.level=t,Qh.default.setItem(Ma,t)}};toAPI(){return al(this.api)}},VI=new Qa;new Yr(VI.toAPI());\n/*! Bundled license information:\n\nlocalforage/dist/localforage.js:\n (*!\n localForage -- Offline Storage, Improved\n Version 1.10.0\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n *)\n\nflatted/cjs/index.js:\n (*! (c) 2020 Andrea Giammarchi *)\n*/\n';var Mb=class extends zs{initWebWorker(){return YT(RA,{name:"zotlit database worker"})}},Ep=class extends Us{workerCtor(){return new Mb}};var Vt=class extends fe{settings=this.use(ge);app=this.use(Eo.App);plugin=this.use(xe);server=this.use(Tn);get zoteroDataDir(){return this.settings.current?.zoteroDataDir}onload(){W.debug("loading DatabaseWorker"),this.settings.once(async()=>{let e=(0,Eo.debounce)(()=>this.refresh({task:"dbConn"}),500,!0);this.registerEvent(this.app.vault.on("zotero:db-updated",()=>e()));let r=process.hrtime();await this.initialize(),W.debug(`ZoteroDB Initialization complete. Took ${(0,NA.default)(process.hrtime(r))}`);let n=this.genAutoRefresh(this.plugin);this.registerEvent(this.server.on("bg:notify",async(o,i)=>{i.event==="regular-item/update"&&n(i)})),this.plugin.addCommand({id:"refresh-zotero-data",name:"Refresh Zotero data",callback:async()=>{await this.refresh({task:"full"})}}),this.plugin.addCommand({id:"refresh-zotero-search-index",name:"Refresh Zotero search index",callback:async()=>{await this.refresh({task:"searchIndex"})}})}),this.register(He(lt(async()=>{this.status===0?await this.initialize():await this.refresh({task:"full"})},()=>this.zoteroDataDir))),this.register(He(lt(async()=>{await this.refresh({task:"searchIndex",force:!0}),new Eo.Notice("Zotero search index updated.")},()=>this.settings.libId,!0)))}genAutoRefresh(e){let r=!1,n=null,o=()=>{n&&(W.debug("unregistering db refresh watcher"),n(),n=null)},i=(0,Eo.debounce)(async()=>{if(o(),W.debug("Auto Refreshing Zotero Search Index"),!r){r=!1;try{W.debug("Db not refreshed, waiting before auto refresh");let[s]=Gy(e.app,{timeout:1e4});await s}catch(s){if(s instanceof Sl){W.warn("no db refreshed event received in 10s, skip refresh search index");return}else{console.error("error while waiting for db refresh during execute",s);return}}}await this.refresh({task:"searchIndex",force:!0}),W.debug("Auto Refreshing Zotero Search Index Success")},5e3,!0);return s=>{if(W.debug(`Request to auto refresh search index: (refreshed ${r})`,s),i(),o(),r)return;W.debug("watching db refresh while waiting for search index auto refresh");let[a,l]=Gy(e.app,{timeout:null});n=l,a.then(()=>{W.debug("db refresh while requesting auto refresh search index"),r=!0,n=null}).catch(u=>{u instanceof Il||console.error("error while waiting for db refresh during request",u)})}}async onunload(){await this.#e.terminate(),this.#t=0,this.#s=null}#e=new Ep({minWorkers:1,maxWorkers:1});get api(){return this.#e.proxy}#t=0;get status(){return this.#t}#n=null;async#o(e){let r=this.settings.libId;return!e&&this.#n===r?(W.debug(`Skipping search index init, lib ${r} already indexed`),!1):(await this.api.initIndex(r),this.#n=r,W.debug(`Search index init complete for lib ${r}`),!0)}async#i(){let[e,r]=this.settings.dbConnParams,{main:n,bbtMain:o,bbtSearch:i}=await this.api.openDb(e,r);if((!o||i===!1)&&W.debug("Failed to open Better BibTeX database, skipping..."),!n)throw new Error("Failed to init ZoteroDB")}async initialize(){if(this.#t!==0)throw new Error("Calling init on already initialized db, use refresh instead");await this.#i(),this.app.vault.trigger("zotero:db-ready"),await this.#o(!0),this.app.metadataCache.trigger("zotero:search-ready"),W.info("ZoteroDB Initialization complete."),this.#t=2}#r=null;#s=null;refresh(e){if(this.#t===0)return Promise.reject(new Error("Calling refresh on uninitialized database"));if(this.#t===2){this.#t=1;let r=(async()=>{e.task==="dbConn"?await this.#a():e.task==="searchIndex"?await this.#l(e.force):e.task==="full"?await this.#c():(0,$b.assertNever)(e),this.#t=2;let n=this.#s;n&&(this.#s=null,await this.refresh(n))})();return this.#r=r}else{if(this.#t===1)return this.#r?(this.#s=this.#u(e),this.#r):Promise.reject(new Error("Other task in pending state"));(0,$b.assertNever)(this.#t)}}async#a(){await this.#i(),this.app.vault.trigger("zotero:db-refresh")}async#l(e=!1){await this.#o(e)&&this.app.metadataCache.trigger("zotero:search-refresh")}async#c(){await this.#a(),await this.#l(!0),new Eo.Notice("ZoteroDB Refresh complete.")}#u(e){if(!this.#s)return e;let r=this.#s;return r.task==="full"?r:r.task===e.task?r.task==="searchIndex"?{...r,force:r.force||e.force}:r:{task:"full"}}};de([me],Vt.prototype,"zoteroDataDir",1);var DA="INFO",FA="log4js_loglevel",n7=()=>{let t=localStorage.getItem(FA);return typeof t=="string"&&t in Sp.levels?(console.debug(`Read from localstorage: loglevel ${t}`),t):DA},Lb=TS("main",n7(),Sp.default),W=Lb,mt=(t,e,...r)=>{if(!e){Lb.error(t,...r);return}Lb.error(t,e instanceof Error?e.message:String(e),...r),console.error(e)},WT={logLevel:DA},zl=class extends fe{settings=this.use(ge);get level(){return this.settings.current?.logLevel}async applyLogLevel(){localStorage.setItem(FA,this.level),await this.use(Vt).api.setLoglevel(this.level)}onload(){this.register(He(lt(()=>this.applyLogLevel(),()=>this.level)))}};de([me],zl.prototype,"level",1);var yN=require("fs"),Hn=require("obsidian");S();var Ee={},Gs=Symbol(),$k=t=>!!t[Gs],Fk=t=>!t[Gs].c,Gl=t=>{var e;let{b:r,c:n}=t[Gs];n&&(n(),(e=S7.get(r))==null||e())},Np=(t,e)=>{let r=t[Gs].o,n=e[Gs].o;return r===n||t===n||$k(r)&&Np(r,e)},Pk=(t,e)=>{let r={b:t,o:e,c:null},n=new Promise(o=>{r.c=()=>{r.c=null,o()},e.finally(r.c)});return n[Gs]=r,n},S7=new WeakMap;var Rp=t=>"init"in t,Qb="r",ev="w",Zl="c",tv="s",Mk="h",I7="n",_7="l",O7="a",T7="m",C7=t=>{let e=new WeakMap,r=new WeakMap,n=new Map,o,i;if((Ee.env&&Ee.env.MODE)!=="production"&&(o=new Set,i=new Set),t)for(let[E,w]of t){let C={v:w,r:0,y:!0,d:new Map};(Ee.env&&Ee.env.MODE)!=="production"&&(Object.freeze(C),Rp(E)||console.warn("Found initial value for derived atom which can cause unexpected behavior",E)),e.set(E,C)}let s=new WeakMap,a=(E,w,C)=>{let A=s.get(w);A||(A=new Map,s.set(w,A)),C.then(()=>{A.get(E)===C&&(A.delete(E),A.size||s.delete(w))}),A.set(E,C)},l=E=>{let w=new Set,C=s.get(E);return C&&(s.delete(E),C.forEach((A,k)=>{Gl(A),w.add(k)})),w},u=new WeakMap,c=E=>{let w=u.get(E);return w||(w=new Map,u.set(E,w)),w},f=(E,w)=>{if(E){let C=c(E),A=C.get(w);return A||(A=f(E.p,w),A&&"p"in A&&Fk(A.p)&&(A=void 0),A&&C.set(w,A)),A}return e.get(w)},p=(E,w,C)=>{if((Ee.env&&Ee.env.MODE)!=="production"&&Object.freeze(C),E)c(E).set(w,C);else{let A=e.get(w);e.set(w,C),n.has(w)||n.set(w,A)}},d=(E,w=new Map,C)=>{if(!C)return w;let A=new Map,k=!1;return C.forEach(R=>{var z;let ne=((z=f(E,R))==null?void 0:z.r)||0;A.set(R,ne),w.get(R)!==ne&&(k=!0)}),w.size===A.size&&!k?w:A},h=(E,w,C,A,k)=>{let R=f(E,w);if(R){if(k&&(!("p"in R)||!Np(R.p,k)))return R;"p"in R&&Gl(R.p)}let z={v:C,r:R?.r||0,y:!0,d:d(E,R?.d,A)},ne=!R?.y;return!R||!("v"in R)||!Object.is(R.v,C)?(ne=!0,++z.r,z.d.has(w)&&(z.d=new Map(z.d).set(w,z.r))):z.d!==R.d&&(z.d.size!==R.d.size||!Array.from(z.d.keys()).every(Gr=>R.d.has(Gr)))&&(ne=!0,Promise.resolve().then(()=>{D(E)})),R&&!ne?R:(p(E,w,z),z)},b=(E,w,C,A,k)=>{let R=f(E,w);if(R){if(k&&(!("p"in R)||!Np(R.p,k)))return R;"p"in R&&Gl(R.p)}let z={e:C,r:(R?.r||0)+1,y:!0,d:d(E,R?.d,A)};return p(E,w,z),z},y=(E,w,C,A)=>{let k=f(E,w);if(k&&"p"in k){if(Np(k.p,C))return k.y?k:{...k,y:!0};Gl(k.p)}a(E,w,C);let R={p:C,r:(k?.r||0)+1,y:!0,d:d(E,k?.d,A)};return p(E,w,R),R},v=(E,w,C,A)=>{if(C instanceof Promise){let k=Pk(C,C.then(R=>{h(E,w,R,A,k)}).catch(R=>{if(R instanceof Promise)return $k(R)?R.then(()=>{T(E,w,!0)}):R;b(E,w,R,A,k)}));return y(E,w,k,A)}return h(E,w,C,A)},x=(E,w)=>{let C=f(E,w);if(C){let A={...C,y:!1};p(E,w,A)}else(Ee.env&&Ee.env.MODE)!=="production"&&console.warn("[Bug] could not invalidate non existing atom",w)},T=(E,w,C)=>{if(!C){let k=f(E,w);if(k){if(k.y&&"p"in k&&!Fk(k.p))return k;if(k.d.forEach((R,z)=>{if(z!==w)if(!r.has(z))T(E,z);else{let ne=f(E,z);ne&&!ne.y&&T(E,z)}}),Array.from(k.d).every(([R,z])=>{let ne=f(E,R);return ne&&!("p"in ne)&&ne.r===z}))return k.y?k:{...k,y:!0}}}let A=new Set;try{let k=w.read(R=>{A.add(R);let z=R===w?f(E,R):T(E,R);if(z){if("e"in z)throw z.e;if("p"in z)throw z.p;return z.v}if(Rp(R))return R.init;throw new Error("no atom init")});return v(E,w,k,A)}catch(k){if(k instanceof Promise){let R=Pk(k,k);return y(E,w,R,A)}return b(E,w,k,A)}},$=(E,w)=>T(w,E),V=(E,w)=>{let C=r.get(w);return C||(C=_(E,w)),C},J=(E,w)=>!w.l.size&&(!w.t.size||w.t.size===1&&w.t.has(E)),G=(E,w)=>{let C=r.get(w);C&&J(w,C)&&I(E,w)},K=(E,w)=>{let C=r.get(w);C?.t.forEach(A=>{A!==w&&(x(E,A),K(E,A))})},F=(E,w,C)=>{let A=!0,k=(ne,Gr)=>{let Cr=T(E,ne);if("e"in Cr)throw Cr.e;if("p"in Cr){if(Gr?.unstable_promise)return Cr.p.then(()=>{let Ju=f(E,ne);return Ju&&"p"in Ju&&Ju.p===Cr.p?new Promise(Mg=>setTimeout(Mg)).then(()=>k(ne,Gr)):k(ne,Gr)});throw(Ee.env&&Ee.env.MODE)!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",ne),Cr.p}if("v"in Cr)return Cr.v;throw(Ee.env&&Ee.env.MODE)!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",ne),new Error("no value found")},R=(ne,Gr)=>{let Cr;if(ne===w){if(!Rp(ne))throw new Error("atom not writable");l(ne).forEach(rS=>{rS!==E&&v(rS,ne,Gr)});let Mg=f(E,ne),BB=v(E,ne,Gr);Mg!==BB&&K(E,ne)}else Cr=F(E,ne,Gr);return A||D(E),Cr},z=w.write(k,R,C);return A=!1,z},Q=(E,w,C)=>{let A=F(C,E,w);return D(C),A},O=E=>!!E.write,_=(E,w,C)=>{let A={t:new Set(C&&[C]),l:new Set};if(r.set(w,A),(Ee.env&&Ee.env.MODE)!=="production"&&i.add(w),T(void 0,w).d.forEach((R,z)=>{let ne=r.get(z);ne?ne.t.add(w):z!==w&&_(E,z,w)}),O(w)&&w.onMount){let R=ne=>Q(w,ne,E),z=w.onMount(R);E=void 0,z&&(A.u=z)}return A},I=(E,w)=>{var C;let A=(C=r.get(w))==null?void 0:C.u;A&&A(),r.delete(w),(Ee.env&&Ee.env.MODE)!=="production"&&i.delete(w);let k=f(E,w);k?("p"in k&&Gl(k.p),k.d.forEach((R,z)=>{if(z!==w){let ne=r.get(z);ne&&(ne.t.delete(w),J(z,ne)&&I(E,z))}})):(Ee.env&&Ee.env.MODE)!=="production"&&console.warn("[Bug] could not find atom state to unmount",w)},B=(E,w,C,A)=>{let k=new Set(C.d.keys());A?.forEach((R,z)=>{if(k.has(z)){k.delete(z);return}let ne=r.get(z);ne&&(ne.t.delete(w),J(z,ne)&&I(E,z))}),k.forEach(R=>{let z=r.get(R);z?z.t.add(w):r.has(w)&&_(E,R,w)})},D=E=>{if(E){c(E).forEach((C,A)=>{let k=e.get(A);if(C!==k){let R=r.get(A);R?.l.forEach(z=>z(E))}});return}for(;n.size;){let w=Array.from(n);n.clear(),w.forEach(([C,A])=>{let k=f(void 0,C);if(k&&k.d!==A?.d&&B(void 0,C,k,A?.d),A&&!A.y&&k?.y)return;let R=r.get(C);R?.l.forEach(z=>z())})}(Ee.env&&Ee.env.MODE)!=="production"&&o.forEach(w=>w())},oe=E=>{c(E).forEach((C,A)=>{let k=e.get(A);(!k||C.r>k.r||C.y!==k.y||C.r===k.r&&C.d!==k.d)&&(e.set(A,C),C.d!==k?.d&&B(E,A,C,k?.d))})},se=(E,w)=>{w&&oe(w),D(void 0)},be=(E,w,C)=>{let k=V(C,E).l;return k.add(w),()=>{k.delete(w),G(C,E)}},ce=(E,w)=>{for(let[C,A]of E)Rp(C)&&(v(w,C,A),K(w,C));D(w)};return(Ee.env&&Ee.env.MODE)!=="production"?{[Qb]:$,[ev]:Q,[Zl]:se,[tv]:be,[Mk]:ce,[I7]:E=>(o.add(E),()=>{o.delete(E)}),[_7]:()=>i.values(),[O7]:E=>e.get(E),[T7]:E=>r.get(E)}:{[Qb]:$,[ev]:Q,[Zl]:se,[tv]:be,[Mk]:ce}};var Lk=(t,e)=>({s:e?e(t).SECRET_INTERNAL_store:C7(t)}),Xb=new Map,rv=t=>(Xb.has(t)||Xb.set(t,We(Lk())),Xb.get(t)),jk=({children:t,initialValues:e,scope:r,unstable_createStore:n,unstable_enableVersionedWrite:o})=>{let[i,s]=L({});U(()=>{let u=a.current;u.w&&(u.s[Zl](null,i),delete i.p,u.v=i)},[i]);let a=P();if(!a.current){let u=Lk(e,n);if(o){let c=0;u.w=f=>{s(p=>{let d=c?p:{p};return f(d),d})},u.v=i,u.r=f=>{++c,f(),--c}}a.current=u}let l=rv(r);return H(l.Provider,{value:a.current},t)},A7=0;function Jt(t,e){let r=`atom${++A7}`,n={toString:()=>r};return typeof t=="function"?n.read=t:(n.init=t,n.read=o=>o(n),n.write=(o,i,s)=>i(n,typeof s=="function"?s(o(n)):s)),e&&(n.write=e),n}function xt(t,e){let r=rv(e),n=te(r),{s:o,v:i}=n,s=p=>{let d=o[Qb](t,p);if((Ee.env&&Ee.env.MODE)!=="production"&&!d.y)throw new Error("should not be invalidated");if("e"in d)throw d.e;if("p"in d)throw d.p;if("v"in d)return d.v;throw new Error("no atom value")},[[a,l,u],c]=an((p,d)=>{let h=s(d);return Object.is(p[1],h)&&p[2]===t?p:[d,h,t]},i,p=>{let d=s(p);return[p,d,t]}),f=l;return u!==t&&(c(a),f=s(a)),U(()=>{let{v:p}=n;p&&o[Zl](t,p);let d=o[tv](t,c,p);return c(p),d},[o,t,n]),U(()=>{o[Zl](t,a)}),Ii(f),f}function nv(t,e){let r=rv(e),{s:n,w:o}=te(r);return X(s=>{if((Ee.env&&Ee.env.MODE)!=="production"&&!("write"in t))throw new Error("not writable atom");let a=l=>n[ev](t,s,l);return o?o(a):a()},[n,o,t])}var hN=require("obsidian");S();var qk=()=>{let t=[];return{get:()=>t,set:(n,o)=>{t.push([n,o])}}};var Dr=Jt(null),ov=Jt(t=>{let{arch:e,platform:r,modules:n}=t(Dr).platform;return`better-sqlite3-${t(Dr).binaryVersion}-electron-v${n}-${r}-${e}.tar.gz`}),Jl=Jt(t=>`https://github.com/aidenlx/better-sqlite3/releases/download/${t(Dr).binaryVersion}/${t(ov)}`),Gbe=Jt(t=>t(Jl).replace("github.com","download.fastgit.org")),Dp=Jt(t=>Rs(t(Dr).manifest)),Bk=Jt(t=>t(Dr).mode);var dN=Z(ks(),1);S();var zk=function(t){return function(e,r){var n=P(!1);t(function(){return function(){n.current=!1}},[]),t(function(){if(!n.current)n.current=!0;else return e()},r)}};function Io(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(a){s={error:a}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}S();var Yl=function(t){return typeof t=="function"};var Uk=function(t){return typeof t>"u"};var k7=!1,Wk=k7;function R7(t){Wk&&(Yl(t)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof t)));var e=P(t);e.current=ie(function(){return t},[t]);var r=P();return r.current||(r.current=function(){for(var n=[],o=0;o{let e=P(null);return[X(n=>{e.current&&e.current.empty(),n&&(0,Zk.setIcon)(n,t),e.current=n},[t])]};Hs();Hs();var F7=0;function m(t,e,r,n,o){var i,s,a={};for(s in e)s=="ref"?i=e[s]:a[s]=e[s];var l={type:t,props:a,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--F7,__source:o,__self:n};if(typeof t=="function"&&(i=t.defaultProps))for(s in i)a[s]===void 0&&(a[s]=i[s]);return q.vnode&&q.vnode(l),l}var Xl=({name:t,desc:e,button:r,onClick:n,icon:o,className:i,...s})=>m("div",{className:Zs("setting-item",i),...s,children:[o&&m("div",{className:"setting-icon",children:o}),m("div",{className:"setting-item-info",children:[m("div",{className:"setting-item-name",children:t}),m("div",{className:"setting-item-description",children:e})]}),m("div",{className:"setting-item-control",children:r&&m("button",{className:"mod-cta",onClick:n,children:r})})]});S();var P7=()=>m("svg",{className:"icon-blank svg-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",height:"32",width:"32"}),M7=()=>m("svg",{className:"icon-spin svg-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",height:"32",width:"32",children:[m("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),m("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z",children:m("animateTransform",{attributeName:"transform",type:"rotate",from:"0 16 16",to:"360 16 16",dur:"0.8s",repeatCount:"indefinite"})})]}),Jk=({color:t="var(--icon-color, black)",delay:e=0,height:r=16,width:n=16,style:o,...i})=>{let[s,a]=L(e>0);return U(()=>{let l=-1;return s&&(l=window.setTimeout(()=>{a(!1)},e)),()=>{window.clearTimeout(l)}},[]),m("div",{style:{...o,fill:t,height:Number(r)||r,width:Number(n)||n},...i,children:s?m(P7,{}):m(M7,{})})};var nN=require("fs"),Fd=require("fs/promises"),oN=require("stream"),E0=require("stream/promises"),bK=require("@electron/remote");var Fp=class extends Error{},av=class extends Fp{},lv=class extends Fp{},$7=(t,e=",")=>t.join(e),L7={accept:"*",multiple:!1,strict:!1},Yk=t=>{let{accept:e,multiple:r,strict:n}={...L7,...t},o=B7({multiple:r,accept:Array.isArray(e)?$7(e):e});return new Promise(i=>{o.onchange=()=>{i(j7(o.files,r,n)),o.remove()},o.click()})},j7=(t,e,r)=>new Promise((n,o)=>{if(!t)return o(new av);let i=q7(t,e,r);if(!i)return o(new lv);n(i)}),q7=(t,e,r)=>!e&&r?t.length===1?t[0]:null:t.length?t:null,B7=({accept:t,multiple:e})=>{let r=document.createElement("input");return r.type="file",r.multiple=e,r.accept=t,r};var S0=require("obsidian");var nR=Z(require("events"),1),St=Z(require("fs"),1);var Bp=require("node:events"),hv=Z(require("node:stream"),1),rR=require("node:string_decoder"),Xk=typeof process=="object"&&process?process:{stdout:null,stderr:null},z7=t=>!!t&&typeof t=="object"&&(t instanceof $t||t instanceof hv.default||U7(t)||W7(t)),U7=t=>!!t&&typeof t=="object"&&t instanceof Bp.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==hv.default.Writable.prototype.pipe,W7=t=>!!t&&typeof t=="object"&&t instanceof Bp.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",Dn=Symbol("EOF"),Fn=Symbol("maybeEmitEnd"),_o=Symbol("emittedEnd"),Pp=Symbol("emittingEnd"),Ql=Symbol("emittedError"),Mp=Symbol("closed"),Qk=Symbol("read"),$p=Symbol("flush"),eR=Symbol("flushChunk"),Fr=Symbol("encoding"),Js=Symbol("decoder"),et=Symbol("flowing"),ec=Symbol("paused"),Ys=Symbol("resume"),tt=Symbol("buffer"),Et=Symbol("pipes"),rt=Symbol("bufferLength"),cv=Symbol("bufferPush"),Lp=Symbol("bufferShift"),gt=Symbol("objectMode"),Le=Symbol("destroyed"),uv=Symbol("error"),fv=Symbol("emitData"),tR=Symbol("emitEnd"),pv=Symbol("emitEnd2"),cn=Symbol("async"),dv=Symbol("abort"),jp=Symbol("aborted"),tc=Symbol("signal"),_i=Symbol("dataListeners"),Xt=Symbol("discarded"),rc=t=>Promise.resolve().then(t),H7=t=>t(),K7=t=>t==="end"||t==="finish"||t==="prefinish",V7=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,G7=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),qp=class{src;dest;opts;ondrain;constructor(e,r,n){this.src=e,this.dest=r,this.opts=n,this.ondrain=()=>e[Ys](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},mv=class extends qp{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,r,n){super(e,r,n),this.proxyErrors=o=>r.emit("error",o),e.on("error",this.proxyErrors)}},Z7=t=>!!t.objectMode,J7=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",$t=class extends Bp.EventEmitter{[et]=!1;[ec]=!1;[Et]=[];[tt]=[];[gt];[Fr];[cn];[Js];[Dn]=!1;[_o]=!1;[Pp]=!1;[Mp]=!1;[Ql]=null;[rt]=0;[Le]=!1;[tc];[jp]=!1;[_i]=0;[Xt]=!1;writable=!0;readable=!0;constructor(...e){let r=e[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");Z7(r)?(this[gt]=!0,this[Fr]=null):J7(r)?(this[Fr]=r.encoding,this[gt]=!1):(this[gt]=!1,this[Fr]=null),this[cn]=!!r.async,this[Js]=this[Fr]?new rR.StringDecoder(this[Fr]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[tt]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[Et]});let{signal:n}=r;n&&(this[tc]=n,n.aborted?this[dv]():n.addEventListener("abort",()=>this[dv]()))}get bufferLength(){return this[rt]}get encoding(){return this[Fr]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[gt]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[cn]}set async(e){this[cn]=this[cn]||!!e}[dv](){this[jp]=!0,this.emit("abort",this[tc]?.reason),this.destroy(this[tc]?.reason)}get aborted(){return this[jp]}set aborted(e){}write(e,r,n){if(this[jp])return!1;if(this[Dn])throw new Error("write after end");if(this[Le])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let o=this[cn]?rc:H7;if(!this[gt]&&!Buffer.isBuffer(e)){if(G7(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(V7(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[gt]?(this[et]&&this[rt]!==0&&this[$p](!0),this[et]?this.emit("data",e):this[cv](e),this[rt]!==0&&this.emit("readable"),n&&o(n),this[et]):e.length?(typeof e=="string"&&!(r===this[Fr]&&!this[Js]?.lastNeed)&&(e=Buffer.from(e,r)),Buffer.isBuffer(e)&&this[Fr]&&(e=this[Js].write(e)),this[et]&&this[rt]!==0&&this[$p](!0),this[et]?this.emit("data",e):this[cv](e),this[rt]!==0&&this.emit("readable"),n&&o(n),this[et]):(this[rt]!==0&&this.emit("readable"),n&&o(n),this[et])}read(e){if(this[Le])return null;if(this[Xt]=!1,this[rt]===0||e===0||e&&e>this[rt])return this[Fn](),null;this[gt]&&(e=null),this[tt].length>1&&!this[gt]&&(this[tt]=[this[Fr]?this[tt].join(""):Buffer.concat(this[tt],this[rt])]);let r=this[Qk](e||null,this[tt][0]);return this[Fn](),r}[Qk](e,r){if(this[gt])this[Lp]();else{let n=r;e===n.length||e===null?this[Lp]():typeof n=="string"?(this[tt][0]=n.slice(e),r=n.slice(0,e),this[rt]-=e):(this[tt][0]=n.subarray(e),r=n.subarray(0,e),this[rt]-=e)}return this.emit("data",r),!this[tt].length&&!this[Dn]&&this.emit("drain"),r}end(e,r,n){return typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r="utf8"),e!==void 0&&this.write(e,r),n&&this.once("end",n),this[Dn]=!0,this.writable=!1,(this[et]||!this[ec])&&this[Fn](),this}[Ys](){this[Le]||(!this[_i]&&!this[Et].length&&(this[Xt]=!0),this[ec]=!1,this[et]=!0,this.emit("resume"),this[tt].length?this[$p]():this[Dn]?this[Fn]():this.emit("drain"))}resume(){return this[Ys]()}pause(){this[et]=!1,this[ec]=!0,this[Xt]=!1}get destroyed(){return this[Le]}get flowing(){return this[et]}get paused(){return this[ec]}[cv](e){this[gt]?this[rt]+=1:this[rt]+=e.length,this[tt].push(e)}[Lp](){return this[gt]?this[rt]-=1:this[rt]-=this[tt][0].length,this[tt].shift()}[$p](e=!1){do;while(this[eR](this[Lp]())&&this[tt].length);!e&&!this[tt].length&&!this[Dn]&&this.emit("drain")}[eR](e){return this.emit("data",e),this[et]}pipe(e,r){if(this[Le])return e;this[Xt]=!1;let n=this[_o];return r=r||{},e===Xk.stdout||e===Xk.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&e.end():(this[Et].push(r.proxyErrors?new mv(this,e,r):new qp(this,e,r)),this[cn]?rc(()=>this[Ys]()):this[Ys]()),e}unpipe(e){let r=this[Et].find(n=>n.dest===e);r&&(this[Et].length===1?(this[et]&&this[_i]===0&&(this[et]=!1),this[Et]=[]):this[Et].splice(this[Et].indexOf(r),1),r.unpipe())}addListener(e,r){return this.on(e,r)}on(e,r){let n=super.on(e,r);if(e==="data")this[Xt]=!1,this[_i]++,!this[Et].length&&!this[et]&&this[Ys]();else if(e==="readable"&&this[rt]!==0)super.emit("readable");else if(K7(e)&&this[_o])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[Ql]){let o=r;this[cn]?rc(()=>o.call(this,this[Ql])):o.call(this,this[Ql])}return n}removeListener(e,r){return this.off(e,r)}off(e,r){let n=super.off(e,r);return e==="data"&&(this[_i]=this.listeners("data").length,this[_i]===0&&!this[Xt]&&!this[Et].length&&(this[et]=!1)),n}removeAllListeners(e){let r=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[_i]=0,!this[Xt]&&!this[Et].length&&(this[et]=!1)),r}get emittedEnd(){return this[_o]}[Fn](){!this[Pp]&&!this[_o]&&!this[Le]&&this[tt].length===0&&this[Dn]&&(this[Pp]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Mp]&&this.emit("close"),this[Pp]=!1)}emit(e,...r){let n=r[0];if(e!=="error"&&e!=="close"&&e!==Le&&this[Le])return!1;if(e==="data")return!this[gt]&&!n?!1:this[cn]?(rc(()=>this[fv](n)),!0):this[fv](n);if(e==="end")return this[tR]();if(e==="close"){if(this[Mp]=!0,!this[_o]&&!this[Le])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[Ql]=n,super.emit(uv,n);let i=!this[tc]||this.listeners("error").length?super.emit("error",n):!1;return this[Fn](),i}else if(e==="resume"){let i=super.emit("resume");return this[Fn](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let o=super.emit(e,...r);return this[Fn](),o}[fv](e){for(let n of this[Et])n.dest.write(e)===!1&&this.pause();let r=this[Xt]?!1:super.emit("data",e);return this[Fn](),r}[tR](){return this[_o]?!1:(this[_o]=!0,this.readable=!1,this[cn]?(rc(()=>this[pv]()),!0):this[pv]())}[pv](){if(this[Js]){let r=this[Js].end();if(r){for(let n of this[Et])n.dest.write(r);this[Xt]||super.emit("data",r)}}for(let r of this[Et])r.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[gt]||(e.dataLength=0);let r=this.promise();return this.on("data",n=>{e.push(n),this[gt]||(e.dataLength+=n.length)}),await r,e}async concat(){if(this[gt])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[Fr]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,r)=>{this.on(Le,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[Xt]=!1;let e=!1,r=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return r();let o=this.read();if(o!==null)return Promise.resolve({done:!1,value:o});if(this[Dn])return r();let i,s,a=f=>{this.off("data",l),this.off("end",u),this.off(Le,c),r(),s(f)},l=f=>{this.off("error",a),this.off("end",u),this.off(Le,c),this.pause(),i({value:f,done:!!this[Dn]})},u=()=>{this.off("error",a),this.off("data",l),this.off(Le,c),r(),i({done:!0,value:void 0})},c=()=>a(new Error("stream destroyed"));return new Promise((f,p)=>{s=p,i=f,this.once(Le,c),this.once("error",a),this.once("end",u),this.once("data",l)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[Xt]=!1;let e=!1,r=()=>(this.pause(),this.off(uv,r),this.off(Le,r),this.off("end",r),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return r();let o=this.read();return o===null?r():{done:!1,value:o}};return this.once("end",r),this.once(uv,r),this.once(Le,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(e){if(this[Le])return e?this.emit("error",e):this.emit(Le),this;this[Le]=!0,this[Xt]=!0,this[tt].length=0,this[rt]=0;let r=this;return typeof r.close=="function"&&!this[Mp]&&r.close(),e?this.emit("error",e):this.emit(Le),this}static get isStream(){return z7}};var Y7=St.default.writev,To=Symbol("_autoClose"),Mr=Symbol("_close"),nc=Symbol("_ended"),ye=Symbol("_fd"),gv=Symbol("_finished"),Mn=Symbol("_flags"),yv=Symbol("_flush"),xv=Symbol("_handleChunk"),Ev=Symbol("_makeBuf"),ic=Symbol("_mode"),zp=Symbol("_needDrain"),ea=Symbol("_onerror"),ta=Symbol("_onopen"),bv=Symbol("_onread"),Xs=Symbol("_onwrite"),Co=Symbol("_open"),Pr=Symbol("_path"),Oo=Symbol("_pos"),un=Symbol("_queue"),Qs=Symbol("_read"),vv=Symbol("_readSize"),Pn=Symbol("_reading"),oc=Symbol("_remain"),wv=Symbol("_size"),Up=Symbol("_write"),Oi=Symbol("_writing"),Wp=Symbol("_defaultFlag"),Ti=Symbol("_errored"),Ci=class extends $t{[Ti]=!1;[ye];[Pr];[vv];[Pn]=!1;[wv];[oc];[To];constructor(e,r){if(r=r||{},super(r),this.readable=!0,this.writable=!1,typeof e!="string")throw new TypeError("path must be a string");this[Ti]=!1,this[ye]=typeof r.fd=="number"?r.fd:void 0,this[Pr]=e,this[vv]=r.readSize||16*1024*1024,this[Pn]=!1,this[wv]=typeof r.size=="number"?r.size:1/0,this[oc]=this[wv],this[To]=typeof r.autoClose=="boolean"?r.autoClose:!0,typeof this[ye]=="number"?this[Qs]():this[Co]()}get fd(){return this[ye]}get path(){return this[Pr]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[Co](){St.default.open(this[Pr],"r",(e,r)=>this[ta](e,r))}[ta](e,r){e?this[ea](e):(this[ye]=r,this.emit("open",r),this[Qs]())}[Ev](){return Buffer.allocUnsafe(Math.min(this[vv],this[oc]))}[Qs](){if(!this[Pn]){this[Pn]=!0;let e=this[Ev]();if(e.length===0)return process.nextTick(()=>this[bv](null,0,e));St.default.read(this[ye],e,0,e.length,null,(r,n,o)=>this[bv](r,n,o))}}[bv](e,r,n){this[Pn]=!1,e?this[ea](e):this[xv](r,n)&&this[Qs]()}[Mr](){if(this[To]&&typeof this[ye]=="number"){let e=this[ye];this[ye]=void 0,St.default.close(e,r=>r?this.emit("error",r):this.emit("close"))}}[ea](e){this[Pn]=!0,this[Mr](),this.emit("error",e)}[xv](e,r){let n=!1;return this[oc]-=e,e>0&&(n=super.write(ethis[ta](e,r))}[ta](e,r){this[Wp]&&this[Mn]==="r+"&&e&&e.code==="ENOENT"?(this[Mn]="w",this[Co]()):e?this[ea](e):(this[ye]=r,this.emit("open",r),this[Oi]||this[yv]())}end(e,r){return e&&this.write(e,r),this[nc]=!0,!this[Oi]&&!this[un].length&&typeof this[ye]=="number"&&this[Xs](null,0),this}write(e,r){return typeof e=="string"&&(e=Buffer.from(e,r)),this[nc]?(this.emit("error",new Error("write() after end()")),!1):this[ye]===void 0||this[Oi]||this[un].length?(this[un].push(e),this[zp]=!0,!1):(this[Oi]=!0,this[Up](e),!0)}[Up](e){St.default.write(this[ye],e,0,e.length,this[Oo],(r,n)=>this[Xs](r,n))}[Xs](e,r){e?this[ea](e):(this[Oo]!==void 0&&typeof r=="number"&&(this[Oo]+=r),this[un].length?this[yv]():(this[Oi]=!1,this[nc]&&!this[gv]?(this[gv]=!0,this[Mr](),this.emit("finish")):this[zp]&&(this[zp]=!1,this.emit("drain"))))}[yv](){if(this[un].length===0)this[nc]&&this[Xs](null,0);else if(this[un].length===1)this[Up](this[un].pop());else{let e=this[un];this[un]=[],Y7(this[ye],e,this[Oo],(r,n)=>this[Xs](r,n))}}[Mr](){if(this[To]&&typeof this[ye]=="number"){let e=this[ye];this[ye]=void 0,St.default.close(e,r=>r?this.emit("error",r):this.emit("close"))}}},ra=class extends $n{[Co](){let e;if(this[Wp]&&this[Mn]==="r+")try{e=St.default.openSync(this[Pr],this[Mn],this[ic])}catch(r){if(r?.code==="ENOENT")return this[Mn]="w",this[Co]();throw r}else e=St.default.openSync(this[Pr],this[Mn],this[ic]);this[ta](null,e)}[Mr](){if(this[To]&&typeof this[ye]=="number"){let e=this[ye];this[ye]=void 0,St.default.closeSync(e),this.emit("close")}}[Up](e){let r=!0;try{this[Xs](null,St.default.writeSync(this[ye],e,0,e.length,this[Oo])),r=!1}finally{if(r)try{this[Mr]()}catch{}}}};var Yv=Z(require("node:path"),1);var $i=Z(require("node:fs"),1),ld=require("path");var X7=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),oR=t=>!!t.sync&&!!t.file,iR=t=>!t.sync&&!!t.file,sR=t=>!!t.sync&&!t.file,aR=t=>!t.sync&&!t.file;var lR=t=>!!t.file;var Q7=t=>{let e=X7.get(t);return e||t},sc=(t={})=>{if(!t)return{};let e={};for(let[r,n]of Object.entries(t)){let o=Q7(r);e[o]=n}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e};var fn=(t,e,r,n,o)=>Object.assign((i=[],s,a)=>{Array.isArray(i)&&(s=i,i={}),typeof s=="function"&&(a=s,s=void 0),s?s=Array.from(s):s=[];let l=sc(i);if(o?.(l,s),oR(l)){if(typeof a=="function")throw new TypeError("callback not supported for sync tar functions");return t(l,s)}else if(iR(l)){let u=e(l,s),c=a||void 0;return c?u.then(()=>c(),c):u}else if(sR(l)){if(typeof a=="function")throw new TypeError("callback not supported for sync tar functions");return r(l,s)}else if(aR(l)){if(typeof a=="function")throw new TypeError("callback only supported with file option");return n(l,s)}else throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:n,validate:o});var IR=require("events");var Kp=Z(require("assert"),1),jn=require("buffer");var fR=Z(require("zlib"),1);var cR=Z(require("zlib"),1),eH=cR.default.constants||{ZLIB_VERNUM:4736},Ln=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},eH));var uR=jn.Buffer.concat,Ai=Symbol("_superWrite"),na=class extends Error{code;errno;constructor(e){super("zlib: "+e.message),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,this.constructor)}get name(){return"ZlibError"}},Iv=Symbol("flushFlag"),Vp=class extends $t{#e=!1;#t=!1;#n;#o;#i;#r;#s;get sawError(){return this.#e}get handle(){return this.#r}get flushFlag(){return this.#n}constructor(e,r){if(!e||typeof e!="object")throw new TypeError("invalid options for ZlibBase constructor");super(e),this.#n=e.flush??0,this.#o=e.finishFlush??0,this.#i=e.fullFlushFlag??0;try{this.#r=new fR.default[r](e)}catch(n){throw new na(n)}this.#s=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#r?.on("error",n=>this.#s(new na(n))),this.once("end",()=>this.close)}close(){this.#r&&(this.#r.close(),this.#r=void 0,this.emit("close"))}reset(){if(!this.#e)return(0,Kp.default)(this.#r,"zlib binding closed"),this.#r.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#i),this.write(Object.assign(jn.Buffer.alloc(0),{[Iv]:e})))}end(e,r,n){return typeof e=="function"&&(n=e,r=void 0,e=void 0),typeof r=="function"&&(n=r,r=void 0),e&&(r?this.write(e,r):this.write(e)),this.flush(this.#o),this.#t=!0,super.end(n)}get ended(){return this.#t}[Ai](e){return super.write(e)}write(e,r,n){if(typeof r=="function"&&(n=r,r="utf8"),typeof e=="string"&&(e=jn.Buffer.from(e,r)),this.#e)return;(0,Kp.default)(this.#r,"zlib binding closed");let o=this.#r._handle,i=o.close;o.close=()=>{};let s=this.#r.close;this.#r.close=()=>{},jn.Buffer.concat=u=>u;let a;try{let u=typeof e[Iv]=="number"?e[Iv]:this.#n;a=this.#r._processChunk(e,u),jn.Buffer.concat=uR}catch(u){jn.Buffer.concat=uR,this.#s(new na(u))}finally{this.#r&&(this.#r._handle=o,o.close=i,this.#r.close=s,this.#r.removeAllListeners("error"))}this.#r&&this.#r.on("error",u=>this.#s(new na(u)));let l;if(a)if(Array.isArray(a)&&a.length>0){let u=a[0];l=this[Ai](jn.Buffer.from(u));for(let c=1;c{typeof o=="function"&&(i=o,o=this.flushFlag),this.flush(o),i?.()};try{this.handle.params(e,r)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#t=r)}}}};var Zp=class extends Gp{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[Ai](e){return this.#e?(this.#e=!1,e[9]=255,super[Ai](e)):super[Ai](e)}};var Jp=class extends Gp{constructor(e){super(e,"Unzip")}},Yp=class extends Vp{constructor(e,r){e=e||{},e.flush=e.flush||Ln.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||Ln.BROTLI_OPERATION_FINISH,e.fullFlushFlag=Ln.BROTLI_OPERATION_FLUSH,super(e,r)}},Xp=class extends Yp{constructor(e){super(e,"BrotliCompress")}},Qp=class extends Yp{constructor(e){super(e,"BrotliDecompress")}};var yr=class{tail;head;length=0;static create(e=[]){return new yr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,n=e.prev;return r&&(r.prev=n),n&&(n.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,n=e.length;r1)n=r;else if(this.head)o=this.head.next,n=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=0;o;i++)n=e(n,o.value,i),o=o.next;return n}reduceReverse(e,r){let n,o=this.tail;if(arguments.length>1)n=r;else if(this.tail)o=this.tail.prev,n=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let i=this.length-1;o;i--)n=e(n,o.value,i),o=o.prev;return n}toArray(){let e=new Array(this.length);for(let r=0,n=this.head;n;r++)e[r]=n.value,n=n.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,n=this.tail;n;r++)e[r]=n.value,n=n.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let n=new yr;if(rthis.length&&(r=this.length);let o=this.head,i=0;for(i=0;o&&ithis.length&&(r=this.length);let o=this.length,i=this.tail;for(;i&&o>r;o--)i=i.prev;for(;i&&o>e;o--,i=i.prev)n.push(i.value);return n}splice(e,r=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let s=0;o&&s{if(Number.isSafeInteger(t))t<0?sH(t,e):iH(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},iH=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},sH=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var n=e.length;n>1;n--){var o=t&255;t=Math.floor(t/256),r?e[n-1]=mR(o):o===0?e[n-1]=0:(r=!0,e[n-1]=hR(o))}},dR=t=>{let e=t[0],r=e===128?lH(t.subarray(1,t.length)):e===255?aH(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},aH=t=>{for(var e=t.length,r=0,n=!1,o=e-1;o>-1;o--){var i=Number(t[o]),s;n?s=mR(i):i===0?s=i:(n=!0,s=hR(i)),s!==0&&(r-=s*Math.pow(256,e-o-1))}return r},lH=t=>{for(var e=t.length,r=0,n=e-1;n>-1;n--){var o=Number(t[n]);o!==0&&(r+=o*Math.pow(256,e-n-1))}return r},mR=t=>(255^t)&255,hR=t=>(255^t)+1&255;var ed=t=>td.has(t);var td=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),gR=new Map(Array.from(td).map(t=>[t[1],t[0]]));var Qt=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,r=0,n,o){Buffer.isBuffer(e)?this.decode(e,r||0,n,o):e&&this.#t(e)}decode(e,r,n,o){if(r||(r=0),!e||!(e.length>=r+512))throw new Error("need 512 bytes for header");this.path=ki(e,r,100),this.mode=Ao(e,r+100,8),this.uid=Ao(e,r+108,8),this.gid=Ao(e,r+116,8),this.size=Ao(e,r+124,12),this.mtime=_v(e,r+136,12),this.cksum=Ao(e,r+148,12),o&&this.#t(o,!0),n&&this.#t(n);let i=ki(e,r+156,1);if(ed(i)&&(this.#e=i||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=ki(e,r+157,100),e.subarray(r+257,r+265).toString()==="ustar\x0000")if(this.uname=ki(e,r+265,32),this.gname=ki(e,r+297,32),this.devmaj=Ao(e,r+329,8)??0,this.devmin=Ao(e,r+337,8)??0,e[r+475]!==0){let a=ki(e,r+345,155);this.path=a+"/"+this.path}else{let a=ki(e,r+345,130);a&&(this.path=a+"/"+this.path),this.atime=_v(e,r+476,12),this.ctime=_v(e,r+488,12)}let s=8*32;for(let a=r;a!(o==null||n==="path"&&r||n==="linkpath"&&r||n==="global"))))}encode(e,r=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=r+512))throw new Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,o=uH(this.path||"",n),i=o[0],s=o[1];this.needPax=!!o[2],this.needPax=Ri(e,r,100,i)||this.needPax,this.needPax=ko(e,r+100,8,this.mode)||this.needPax,this.needPax=ko(e,r+108,8,this.uid)||this.needPax,this.needPax=ko(e,r+116,8,this.gid)||this.needPax,this.needPax=ko(e,r+124,12,this.size)||this.needPax,this.needPax=Ov(e,r+136,12,this.mtime)||this.needPax,e[r+156]=this.#e.charCodeAt(0),this.needPax=Ri(e,r+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",r+257,8),this.needPax=Ri(e,r+265,32,this.uname)||this.needPax,this.needPax=Ri(e,r+297,32,this.gname)||this.needPax,this.needPax=ko(e,r+329,8,this.devmaj)||this.needPax,this.needPax=ko(e,r+337,8,this.devmin)||this.needPax,this.needPax=Ri(e,r+345,n,s)||this.needPax,e[r+475]!==0?this.needPax=Ri(e,r+345,155,s)||this.needPax:(this.needPax=Ri(e,r+345,130,s)||this.needPax,this.needPax=Ov(e,r+476,12,this.atime)||this.needPax,this.needPax=Ov(e,r+488,12,this.ctime)||this.needPax);let a=8*32;for(let l=r;l{let n=t,o="",i,s=Ni.posix.parse(t).root||".";if(Buffer.byteLength(n)<100)i=[n,o,!1];else{o=Ni.posix.dirname(n),n=Ni.posix.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(o)<=e?i=[n,o,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(o)<=e?i=[n.slice(0,100-1),o,!0]:(n=Ni.posix.join(Ni.posix.basename(o),n),o=Ni.posix.dirname(o));while(o!==s&&i===void 0);i||(i=[t.slice(0,100-1),"",!0])}return i},ki=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),_v=(t,e,r)=>fH(Ao(t,e,r)),fH=t=>t===void 0?void 0:new Date(t*1e3),Ao=(t,e,r)=>Number(t[e])&128?dR(t.subarray(e,e+r)):dH(t,e,r),pH=t=>isNaN(t)?void 0:t,dH=(t,e,r)=>pH(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),mH={12:8589934591,8:2097151},ko=(t,e,r,n)=>n===void 0?!1:n>mH[r]||n<0?(pR(n,t.subarray(e,e+r)),!0):(hH(t,e,r,n),!1),hH=(t,e,r,n)=>t.write(gH(n,r),e,r,"ascii"),gH=(t,e)=>yH(Math.floor(t).toString(8),e),yH=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Ov=(t,e,r,n)=>n===void 0?!1:ko(t,e,r,n.getTime()/1e3),bH=new Array(156).join("\0"),Ri=(t,e,r,n)=>n===void 0?!1:(t.write(n+bH,e,r,"utf8"),n.length!==Buffer.byteLength(n)||n.length>r);var bR=require("node:path");var pn=class{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),n=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(n);for(let i=0;i<512;i++)o[i]=0;new Qt({path:("PaxHeader/"+(0,bR.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let i=r+512;i=Math.pow(10,s)&&(s+=1),s+i+o}static parse(e,r,n=!1){return new pn(vH(wH(e),r),n)}},vH=(t,e)=>e?Object.assign({},e,t):t,wH=t=>t.replace(/\n$/,"").split(` -`).reduce(xH,Object.create(null)),xH=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let n=e.split("="),o=n.shift();if(!o)return t;let i=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),s=n.join("=");return t[i]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(i)?new Date(Number(s)*1e3):/^[0-9]+$/.test(s)?+s:s,t};var EH=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,ee=EH!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var oa=class extends $t{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,r,n){switch(super({}),this.pause(),this.extended=r,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.path=ee(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?ee(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,r&&this.#e(r),n&&this.#e(n,!0)}write(e){let r=e.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,o=this.blockRemain;return this.remain=Math.max(0,n-r),this.blockRemain=Math.max(0,o-r),this.ignore?!0:n>=r?super.write(e):super.write(e.subarray(0,n))}#e(e,r=!1){e.path&&(e.path=ee(e.path)),e.linkpath&&(e.linkpath=ee(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,o])=>!(o==null||n==="path"&&r))))}};var Di=(t,e,r,n={})=>{t.file&&(n.file=t.file),t.cwd&&(n.cwd=t.cwd),n.code=r instanceof Error&&r.code||e,n.tarCode=e,!t.strict&&n.recoverable!==!1?(r instanceof Error&&(n=Object.assign(r,n),r=r.message),t.emit("warn",e,r,n)):r instanceof Error?t.emit("error",Object.assign(r,n)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),n))};var SH=1024*1024,Tv=Buffer.from([31,139]),br=Symbol("state"),Fi=Symbol("writeEntry"),qn=Symbol("readEntry"),Cv=Symbol("nextEntry"),vR=Symbol("processEntry"),dn=Symbol("extendedHeader"),lc=Symbol("globalExtendedHeader"),Ro=Symbol("meta"),wR=Symbol("emitMeta"),Se=Symbol("buffer"),Bn=Symbol("queue"),No=Symbol("ended"),Av=Symbol("emittedEnd"),Pi=Symbol("emit"),Ke=Symbol("unzip"),rd=Symbol("consumeChunk"),nd=Symbol("consumeChunkSub"),kv=Symbol("consumeBody"),xR=Symbol("consumeMeta"),ER=Symbol("consumeHeader"),cc=Symbol("consuming"),Rv=Symbol("bufferConcat"),od=Symbol("maybeEnd"),ia=Symbol("writing"),Do=Symbol("aborted"),id=Symbol("onDone"),Mi=Symbol("sawValidEntry"),sd=Symbol("sawNullBlock"),ad=Symbol("sawEOF"),SR=Symbol("closeStream"),IH=()=>!0,zn=class extends IR.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;writable=!0;readable=!1;[Bn]=new yr;[Se];[qn];[Fi];[br]="begin";[Ro]="";[dn];[lc];[No]=!1;[Ke];[Do]=!1;[Mi];[sd]=!1;[ad]=!1;[ia]=!1;[cc]=!1;[Av]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(id,()=>{(this[br]==="begin"||this[Mi]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(id,e.ondone):this.on(id,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||SH,this.filter=typeof e.filter=="function"?e.filter:IH;let r=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!e.gzip&&e.brotli!==void 0?e.brotli:r?void 0:!1,this.on("end",()=>this[SR]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,r,n={}){Di(this,e,r,n)}[ER](e,r){this[Mi]===void 0&&(this[Mi]=!1);let n;try{n=new Qt(e,r,this[dn],this[lc])}catch(o){return this.warn("TAR_ENTRY_INVALID",o)}if(n.nullBlock)this[sd]?(this[ad]=!0,this[br]==="begin"&&(this[br]="header"),this[Pi]("eof")):(this[sd]=!0,this[Pi]("nullBlock"));else if(this[sd]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let o=n.type;if(/^(Symbolic)?Link$/.test(o)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(o)&&!/^(Global)?ExtendedHeader$/.test(o)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let i=this[Fi]=new oa(n,this[dn],this[lc]);if(!this[Mi])if(i.remain){let s=()=>{i.invalid||(this[Mi]=!0)};i.on("end",s)}else this[Mi]=!0;i.meta?i.size>this.maxMetaEntrySize?(i.ignore=!0,this[Pi]("ignoredEntry",i),this[br]="ignore",i.resume()):i.size>0&&(this[Ro]="",i.on("data",s=>this[Ro]+=s),this[br]="meta"):(this[dn]=void 0,i.ignore=i.ignore||!this.filter(i.path,i),i.ignore?(this[Pi]("ignoredEntry",i),this[br]=i.remain?"ignore":"header",i.resume()):(i.remain?this[br]="body":(this[br]="header",i.end()),this[qn]?this[Bn].push(i):(this[Bn].push(i),this[Cv]())))}}}[SR](){queueMicrotask(()=>this.emit("close"))}[vR](e){let r=!0;if(!e)this[qn]=void 0,r=!1;else if(Array.isArray(e)){let[n,...o]=e;this.emit(n,...o)}else this[qn]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[Cv]()),r=!1);return r}[Cv](){do;while(this[vR](this[Bn].shift()));if(!this[Bn].length){let e=this[qn];!e||e.flowing||e.size===e.remain?this[ia]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[kv](e,r){let n=this[Fi];if(!n)throw new Error("attempt to consume body without entry??");let o=n.blockRemain??0,i=o>=e.length&&r===0?e:e.subarray(r,r+o);return n.write(i),n.blockRemain||(this[br]="header",this[Fi]=void 0,n.end()),i.length}[xR](e,r){let n=this[Fi],o=this[kv](e,r);return!this[Fi]&&n&&this[wR](n),o}[Pi](e,r,n){!this[Bn].length&&!this[qn]?this.emit(e,r,n):this[Bn].push([e,r,n])}[wR](e){switch(this[Pi]("meta",this[Ro]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[dn]=pn.parse(this[Ro],this[dn],!1);break;case"GlobalExtendedHeader":this[lc]=pn.parse(this[Ro],this[lc],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let r=this[dn]??Object.create(null);this[dn]=r,r.path=this[Ro].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let r=this[dn]||Object.create(null);this[dn]=r,r.linkpath=this[Ro].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+e.type)}}abort(e){this[Do]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,r,n){if(typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8")),this[Do])return n?.(),!1;if((this[Ke]===void 0||this.brotli===void 0&&this[Ke]===!1)&&e){if(this[Se]&&(e=Buffer.concat([this[Se],e]),this[Se]=void 0),e.lengththis[rd](u)),this[Ke].on("error",u=>this.abort(u)),this[Ke].on("end",()=>{this[No]=!0,this[rd]()}),this[ia]=!0;let l=!!this[Ke][a?"end":"write"](e);return this[ia]=!1,n?.(),l}}this[ia]=!0,this[Ke]?this[Ke].write(e):this[rd](e),this[ia]=!1;let i=this[Bn].length?!1:this[qn]?this[qn].flowing:!0;return!i&&!this[Bn].length&&this[qn]?.once("drain",()=>this.emit("drain")),n?.(),i}[Rv](e){e&&!this[Do]&&(this[Se]=this[Se]?Buffer.concat([this[Se],e]):e)}[od](){if(this[No]&&!this[Av]&&!this[Do]&&!this[cc]){this[Av]=!0;let e=this[Fi];if(e&&e.blockRemain){let r=this[Se]?this[Se].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${r} available)`,{entry:e}),this[Se]&&e.write(this[Se]),e.end()}this[Pi](id)}}[rd](e){if(this[cc]&&e)this[Rv](e);else if(!e&&!this[Se])this[od]();else if(e){if(this[cc]=!0,this[Se]){this[Rv](e);let r=this[Se];this[Se]=void 0,this[nd](r)}else this[nd](e);for(;this[Se]&&this[Se]?.length>=512&&!this[Do]&&!this[ad];){let r=this[Se];this[Se]=void 0,this[nd](r)}this[cc]=!1}(!this[Se]||this[No])&&this[od]()}[nd](e){let r=0,n=e.length;for(;r+512<=n&&!this[Do]&&!this[ad];)switch(this[br]){case"begin":case"header":this[ER](e,r),r+=512;break;case"ignore":case"body":r+=this[kv](e,r);break;case"meta":r+=this[xR](e,r);break;default:throw new Error("invalid state: "+this[br])}r{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)};var _H=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},Nv=(t,e)=>{let r=new Map(e.map(i=>[mn(i),!0])),n=t.filter,o=(i,s="")=>{let a=s||(0,ld.parse)(i).root||".",l;if(i===a)l=!1;else{let u=r.get(i);u!==void 0?l=u:l=o((0,ld.dirname)(i),a)}return r.set(i,l),l};t.filter=n?(i,s)=>n(i,s)&&o(mn(i)):i=>o(mn(i))},OH=t=>{let e=new zn(t),r=t.file,n;try{let o=$i.default.statSync(r),i=t.maxReadSize||16*1024*1024;if(o.size{let r=new zn(t),n=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((s,a)=>{r.on("error",a),r.on("end",s),$i.default.stat(o,(l,u)=>{if(l)a(l);else{let c=new Ci(o,{readSize:n,size:u.size});c.on("error",a),c.pipe(r)}})})},Un=fn(OH,TH,t=>new zn(t),t=>new zn(t),(t,e)=>{e?.length&&Nv(t,e),t.noResume||_H(t)});var hc=Z(require("fs"),1);var $r=Z(require("fs"),1);var $v=Z(require("path"),1);var Dv=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);var OR=require("node:path"),{isAbsolute:CH,parse:_R}=OR.win32,uc=t=>{let e="",r=_R(t);for(;CH(t)||r.root;){let n=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(n.length),e+=n,r=_R(t)}return[e,t]};var cd=["|","<",">","?",":"],Fv=cd.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),AH=new Map(cd.map((t,e)=>[t,Fv[e]])),kH=new Map(Fv.map((t,e)=>[t,cd[e]])),Pv=t=>cd.reduce((e,r)=>e.split(r).join(AH.get(r)),t),TR=t=>Fv.reduce((e,r)=>e.split(r).join(kH.get(r)),t);var DR=(t,e)=>e?(t=ee(t).replace(/^\.(\/|$)/,""),mn(e)+"/"+t):ee(t),RH=16*1024*1024,AR=Symbol("process"),kR=Symbol("file"),RR=Symbol("directory"),Lv=Symbol("symlink"),NR=Symbol("hardlink"),fc=Symbol("header"),ud=Symbol("read"),jv=Symbol("lstat"),fd=Symbol("onlstat"),qv=Symbol("onread"),Bv=Symbol("onreadlink"),zv=Symbol("openfile"),Uv=Symbol("onopenfile"),Fo=Symbol("close"),pd=Symbol("mode"),Wv=Symbol("awaitDrain"),Mv=Symbol("ondrain"),hn=Symbol("prefix"),pc=class extends $t{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;#e=!1;constructor(e,r={}){let n=sc(r);super(),this.path=ee(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||RH,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=ee(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?ee(n.prefix):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let o=!1;if(!this.preservePaths){let[s,a]=uc(this.path);s&&typeof a=="string"&&(this.path=a,o=s)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=TR(this.path.replace(/\\/g,"/")),e=e.replace(/\\/g,"/")),this.absolute=ee(n.absolute||$v.default.resolve(this.cwd,e)),this.path===""&&(this.path="./"),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path});let i=this.statCache.get(this.absolute);i?this[fd](i):this[jv]()}warn(e,r,n={}){return Di(this,e,r,n)}emit(e,...r){return e==="error"&&(this.#e=!0),super.emit(e,...r)}[jv](){$r.default.lstat(this.absolute,(e,r)=>{if(e)return this.emit("error",e);this[fd](r)})}[fd](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=NH(e),this.emit("stat",e),this[AR]()}[AR](){switch(this.type){case"File":return this[kR]();case"Directory":return this[RR]();case"SymbolicLink":return this[Lv]();default:return this.end()}}[pd](e){return Dv(e,this.type==="Directory",this.portable)}[hn](e){return DR(e,this.prefix)}[fc](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.header=new Qt({path:this[hn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[hn](this.linkpath):this.linkpath,mode:this[pd](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new pn({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[hn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[hn](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw new Error("failed to encode header");super.write(e)}[RR](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[fc](),this.end()}[Lv](){$r.default.readlink(this.absolute,(e,r)=>{if(e)return this.emit("error",e);this[Bv](r)})}[Bv](e){this.linkpath=ee(e),this[fc](),this.end()}[NR](e){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=ee($v.default.relative(this.cwd,e)),this.stat.size=0,this[fc](),this.end()}[kR](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,r=this.linkCache.get(e);if(r?.indexOf(this.cwd)===0)return this[NR](r);this.linkCache.set(e,this.absolute)}if(this[fc](),this.stat.size===0)return this.end();this[zv]()}[zv](){$r.default.open(this.absolute,"r",(e,r)=>{if(e)return this.emit("error",e);this[Uv](r)})}[Uv](e){if(this.fd=e,this.#e)return this[Fo]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let r=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(r),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[ud]()}[ud](){let{fd:e,buf:r,offset:n,length:o,pos:i}=this;if(e===void 0||r===void 0)throw new Error("cannot read file without first opening");$r.default.read(e,r,n,o,i,(s,a)=>{if(s)return this[Fo](()=>this.emit("error",s));this[qv](a)})}[Fo](e=()=>{}){this.fd!==void 0&&$r.default.close(this.fd,e)}[qv](e){if(e<=0&&this.remain>0){let o=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Fo](()=>this.emit("error",o))}if(e>this.remain){let o=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Fo](()=>this.emit("error",o))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(e===this.remain)for(let o=e;othis[Mv]())}[Wv](e){this.once("drain",e)}write(e,r,n){if(typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8")),this.blockRemaine?this.emit("error",e):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[ud]()}},dd=class extends pc{sync=!0;[jv](){this[fd]($r.default.lstatSync(this.absolute))}[Lv](){this[Bv]($r.default.readlinkSync(this.absolute))}[zv](){this[Uv]($r.default.openSync(this.absolute,"r"))}[ud](){let e=!0;try{let{fd:r,buf:n,offset:o,length:i,pos:s}=this;if(r===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let a=$r.default.readSync(r,n,o,i,s);this[qv](a),e=!1}finally{if(e)try{this[Fo](()=>{})}catch{}}}[Wv](e){e()}[Fo](e=()=>{}){this.fd!==void 0&&$r.default.closeSync(this.fd),e()}},md=class extends $t{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;warn(e,r,n={}){return Di(this,e,r,n)}constructor(e,r={}){let n=sc(r);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.readEntry=e;let{type:o}=e;if(o==="Unsupported")throw new Error("writing entry that should be ignored");this.type=o,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=ee(e.path),this.mode=e.mode!==void 0?this[pd](e.mode):void 0,this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath!==void 0?ee(e.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let i=!1;if(!this.preservePaths){let[a,l]=uc(this.path);a&&typeof l=="string"&&(this.path=l,i=a)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.header=new Qt({path:this[hn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[hn](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path}),this.header.encode()&&!this.noPax&&super.write(new pn({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[hn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[hn](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let s=this.header?.block;if(!s)throw new Error("failed to encode header");super.write(s),e.pipe(this)}[hn](e){return DR(e,this.prefix)}[pd](e){return Dv(e,this.type==="Directory",this.portable)}write(e,r,n){typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8"));let o=e.length;if(o>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=o,super.write(e,n)}end(e,r,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(n=e,r=void 0,e=void 0),typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,r??"utf8")),n&&this.once("finish",n),e?super.end(e,n):super.end(n),this}},NH=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var Jv=Z(require("path"),1);var wd=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,r){this.path=e||"./",this.absolute=r}},FR=Buffer.alloc(1024),hd=Symbol("onStat"),dc=Symbol("ended"),Lr=Symbol("queue"),sa=Symbol("current"),Li=Symbol("process"),mc=Symbol("processing"),PR=Symbol("processJob"),jr=Symbol("jobs"),Hv=Symbol("jobDone"),gd=Symbol("addFSEntry"),MR=Symbol("addTarEntry"),Gv=Symbol("stat"),Zv=Symbol("readdir"),yd=Symbol("onreaddir"),bd=Symbol("pipe"),$R=Symbol("entry"),Kv=Symbol("entryOpt"),vd=Symbol("writeEntryClass"),LR=Symbol("write"),Vv=Symbol("ondrain"),Po=class extends $t{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[vd];onWriteEntry;[Lr];[jr]=0;[mc]=!1;[dc]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=ee(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[vd]=pc,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli){if(e.gzip&&e.brotli)throw new TypeError("gzip and brotli are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new Zp(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new Xp(e.brotli)),!this.zip)throw new Error("impossible");let r=this.zip;r.on("data",n=>super.write(n)),r.on("end",()=>super.end()),r.on("drain",()=>this[Vv]()),this.on("resume",()=>r.resume())}else this.on("drain",this[Vv]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[Lr]=new yr,this[jr]=0,this.jobs=Number(e.jobs)||4,this[mc]=!1,this[dc]=!1}[LR](e){return super.write(e)}add(e){return this.write(e),this}end(e){return e&&this.add(e),this[dc]=!0,this[Li](),this}write(e){if(this[dc])throw new Error("write after end");return e instanceof oa?this[MR](e):this[gd](e),this.flowing}[MR](e){let r=ee(Jv.default.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new wd(e.path,r);n.entry=new md(e,this[Kv](n)),n.entry.on("end",()=>this[Hv](n)),this[jr]+=1,this[Lr].push(n)}this[Li]()}[gd](e){let r=ee(Jv.default.resolve(this.cwd,e));this[Lr].push(new wd(e,r)),this[Li]()}[Gv](e){e.pending=!0,this[jr]+=1;let r=this.follow?"stat":"lstat";hc.default[r](e.absolute,(n,o)=>{e.pending=!1,this[jr]-=1,n?this.emit("error",n):this[hd](e,o)})}[hd](e,r){this.statCache.set(e.absolute,r),e.stat=r,this.filter(e.path,r)||(e.ignore=!0),this[Li]()}[Zv](e){e.pending=!0,this[jr]+=1,hc.default.readdir(e.absolute,(r,n)=>{if(e.pending=!1,this[jr]-=1,r)return this.emit("error",r);this[yd](e,n)})}[yd](e,r){this.readdirCache.set(e.absolute,r),e.readdir=r,this[Li]()}[Li](){if(!this[mc]){this[mc]=!0;for(let e=this[Lr].head;e&&this[jr]this.warn(r,n,o),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix}}[$R](e){this[jr]+=1;try{let r=new this[vd](e.path,this[Kv](e));return this.onWriteEntry?.(r),r.on("end",()=>this[Hv](e)).on("error",n=>this.emit("error",n))}catch(r){this.emit("error",r)}}[Vv](){this[sa]&&this[sa].entry&&this[sa].entry.resume()}[bd](e){e.piped=!0,e.readdir&&e.readdir.forEach(o=>{let i=e.path,s=i==="./"?"":i.replace(/\/*$/,"/");this[gd](s+o)});let r=e.entry,n=this.zip;if(!r)throw new Error("cannot pipe without source");n?r.on("data",o=>{n.write(o)||r.pause()}):r.on("data",o=>{super.write(o)||r.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,r,n={}){Di(this,e,r,n)}},ji=class extends Po{sync=!0;constructor(e){super(e),this[vd]=dd}pause(){}resume(){}[Gv](e){let r=this.follow?"statSync":"lstatSync";this[hd](e,hc.default[r](e.absolute))}[Zv](e){this[yd](e,hc.default.readdirSync(e.absolute))}[bd](e){let r=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(o=>{let i=e.path,s=i==="./"?"":i.replace(/\/*$/,"/");this[gd](s+o)}),!r)throw new Error("Cannot pipe without source");n?r.on("data",o=>{n.write(o)}):r.on("data",o=>{super[LR](o)})}};var DH=(t,e)=>{let r=new ji(t),n=new ra(t.file,{mode:t.mode||438});r.pipe(n),jR(r,e)},FH=(t,e)=>{let r=new Po(t),n=new $n(t.file,{mode:t.mode||438});r.pipe(n);let o=new Promise((i,s)=>{n.on("error",s),n.on("close",i),r.on("error",s)});return qR(r,e),o},jR=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Un({file:Yv.default.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(r)}),t.end()},qR=async(t,e)=>{for(let r=0;r{t.add(o)}}):t.add(n)}t.end()},PH=(t,e)=>{let r=new ji(t);return jR(r,e),r},MH=(t,e)=>{let r=new Po(t);return qR(r,e),r},$H=fn(DH,FH,PH,MH,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")});var w0=Z(require("node:fs"),1);var rN=Z(require("node:assert"),1),v0=require("node:crypto"),ue=Z(require("node:fs"),1),yn=Z(require("node:path"),1);var Xv=Z(require("fs"),1),LH=process.env.__FAKE_PLATFORM__||process.platform,jH=LH==="win32",{O_CREAT:qH,O_TRUNC:BH,O_WRONLY:zH}=Xv.default.constants,BR=Number(process.env.__FAKE_FS_O_FILENAME__)||Xv.default.constants.UV_FS_O_FILEMAP||0,UH=jH&&!!BR,WH=512*1024,HH=BR|BH|qH|zH,Qv=UH?t=>t"w";var gc=Z(require("node:fs"),1),aa=Z(require("node:path"),1),e0=(t,e,r)=>{try{return gc.default.lchownSync(t,e,r)}catch(n){if(n?.code!=="ENOENT")throw n}},xd=(t,e,r,n)=>{gc.default.lchown(t,e,r,o=>{n(o&&o?.code!=="ENOENT"?o:null)})},KH=(t,e,r,n,o)=>{if(e.isDirectory())t0(aa.default.resolve(t,e.name),r,n,i=>{if(i)return o(i);let s=aa.default.resolve(t,e.name);xd(s,r,n,o)});else{let i=aa.default.resolve(t,e.name);xd(i,r,n,o)}},t0=(t,e,r,n)=>{gc.default.readdir(t,{withFileTypes:!0},(o,i)=>{if(o){if(o.code==="ENOENT")return n();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return n(o)}if(o||!i.length)return xd(t,e,r,n);let s=i.length,a=null,l=u=>{if(!a){if(u)return n(a=u);if(--s===0)return xd(t,e,r,n)}};for(let u of i)KH(t,u,e,r,l)})},VH=(t,e,r,n)=>{e.isDirectory()&&r0(aa.default.resolve(t,e.name),r,n),e0(aa.default.resolve(t,e.name),r,n)},r0=(t,e,r)=>{let n;try{n=gc.default.readdirSync(t,{withFileTypes:!0})}catch(o){let i=o;if(i?.code==="ENOENT")return;if(i?.code==="ENOTDIR"||i?.code==="ENOTSUP")return e0(t,e,r);throw i}for(let o of n)VH(t,o,e,r);return e0(t,e,r)};var er=Z(require("fs"),1);var n0=require("path");var Mo=require("fs"),vr=t=>{if(!t)t={mode:511};else if(typeof t=="object")t={mode:511,...t};else if(typeof t=="number")t={mode:t};else if(typeof t=="string")t={mode:parseInt(t,8)};else throw new TypeError("invalid options argument");let e=t,r=t.fs||{};return t.mkdir=t.mkdir||r.mkdir||Mo.mkdir,t.mkdirAsync=t.mkdirAsync?t.mkdirAsync:async(n,o)=>new Promise((i,s)=>e.mkdir(n,o,(a,l)=>a?s(a):i(l))),t.stat=t.stat||r.stat||Mo.stat,t.statAsync=t.statAsync?t.statAsync:async n=>new Promise((o,i)=>e.stat(n,(s,a)=>s?i(s):o(a))),t.statSync=t.statSync||r.statSync||Mo.statSync,t.mkdirSync=t.mkdirSync||r.mkdirSync||Mo.mkdirSync,e};var gn=(t,e,r)=>{let n=(0,n0.dirname)(t),o={...vr(e),recursive:!1};if(n===t)try{return o.mkdirSync(t,o)}catch(i){let s=i;if(s&&s.code!=="EISDIR")throw i;return}try{return o.mkdirSync(t,o),r||t}catch(i){let s=i;if(s&&s.code==="ENOENT")return gn(t,o,gn(n,o,r));if(s&&s.code!=="EEXIST"&&s&&s.code!=="EROFS")throw i;try{if(!o.statSync(t).isDirectory())throw i}catch{throw i}}},Wn=Object.assign(async(t,e,r)=>{let n=vr(e);n.recursive=!1;let o=(0,n0.dirname)(t);return o===t?n.mkdirAsync(t,n).catch(i=>{let s=i;if(s&&s.code!=="EISDIR")throw i}):n.mkdirAsync(t,n).then(()=>r||t,async i=>{let s=i;if(s&&s.code==="ENOENT")return Wn(o,n).then(a=>Wn(t,n,a));if(s&&s.code!=="EEXIST"&&s.code!=="EROFS")throw i;return n.statAsync(t).then(a=>{if(a.isDirectory())return r;throw i},()=>{throw i})})},{sync:gn});var a0=require("path");var o0=require("path"),i0=async(t,e,r)=>{if(r!==e)return t.statAsync(e).then(n=>n.isDirectory()?r:void 0,n=>{let o=n;return o&&o.code==="ENOENT"?i0(t,(0,o0.dirname)(e),e):void 0})},s0=(t,e,r)=>{if(r!==e)try{return t.statSync(e).isDirectory()?r:void 0}catch(n){let o=n;return o&&o.code==="ENOENT"?s0(t,(0,o0.dirname)(e),e):void 0}};var la=(t,e)=>{let r=vr(e);if(r.recursive=!0,(0,a0.dirname)(t)===t)return r.mkdirSync(t,r);let o=s0(r,t);try{return r.mkdirSync(t,r),o}catch(i){let s=i;if(s&&s.code==="ENOENT")return gn(t,r);throw i}},yc=Object.assign(async(t,e)=>{let r={...vr(e),recursive:!0};return(0,a0.dirname)(t)===t?await r.mkdirAsync(t,r):i0(r,t).then(o=>r.mkdirAsync(t,r).then(i=>o||i).catch(i=>{let s=i;if(s&&s.code==="ENOENT")return Wn(t,r);throw i}))},{sync:la});var Ed=require("path"),GH=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,l0=t=>{if(/\0/.test(t))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:t,code:"ERR_INVALID_ARG_VALUE"});if(t=(0,Ed.resolve)(t),GH==="win32"){let e=/[*|"<>?:]/,{root:r}=(0,Ed.parse)(t);if(e.test(t.substring(r.length)))throw Object.assign(new Error("Illegal characters in path."),{path:t,code:"EINVAL"})}return t};var Sd=require("fs");var ZH=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,c0=ZH.replace(/^v/,"").split("."),zR=+c0[0]>10||+c0[0]==10&&+c0[1]>=12,bc=zR?t=>vr(t).mkdirSync===Sd.mkdirSync:()=>!1,Id=Object.assign(zR?t=>vr(t).mkdir===Sd.mkdir:()=>!1,{sync:bc});var _d=(t,e)=>{t=l0(t);let r=vr(e);return bc(r)?la(t,r):gn(t,r)};var UR=Object.assign(async(t,e)=>{t=l0(t);let r=vr(e);return Id(r)?yc(t,r):Wn(t,r)},{mkdirpSync:_d,mkdirpNative:yc,mkdirpNativeSync:la,mkdirpManual:Wn,mkdirpManualSync:gn,sync:_d,native:yc,nativeSync:la,manual:Wn,manualSync:gn,useNative:Id,useNativeSync:bc});var Ec=Z(require("node:path"),1);var vc=class extends Error{path;code;syscall="chdir";constructor(e,r){super(`${r}: Cannot cd into '${e}'`),this.path=e,this.code=r}get name(){return"CwdError"}};var wc=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,r){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=r}get name(){return"SymlinkError"}};var Od=(t,e)=>t.get(ee(e)),xc=(t,e,r)=>t.set(ee(e),r),JH=(t,e)=>{er.default.stat(t,(r,n)=>{(r||!n.isDirectory())&&(r=new vc(t,r?.code||"ENOTDIR")),e(r)})},WR=(t,e,r)=>{t=ee(t);let n=e.umask??18,o=e.mode|448,i=(o&n)!==0,s=e.uid,a=e.gid,l=typeof s=="number"&&typeof a=="number"&&(s!==e.processUid||a!==e.processGid),u=e.preserve,c=e.unlink,f=e.cache,p=ee(e.cwd),d=(y,v)=>{y?r(y):(xc(f,t,!0),v&&l?t0(v,s,a,x=>d(x)):i?er.default.chmod(t,o,r):r())};if(f&&Od(f,t)===!0)return d();if(t===p)return JH(t,d);if(u)return UR(t,{mode:o}).then(y=>d(null,y??void 0),d);let b=ee(Ec.default.relative(p,t)).split("/");Td(p,b,o,f,c,p,void 0,d)},Td=(t,e,r,n,o,i,s,a)=>{if(!e.length)return a(null,s);let l=e.shift(),u=ee(Ec.default.resolve(t+"/"+l));if(Od(n,u))return Td(u,e,r,n,o,i,s,a);er.default.mkdir(u,r,HR(u,e,r,n,o,i,s,a))},HR=(t,e,r,n,o,i,s,a)=>l=>{l?er.default.lstat(t,(u,c)=>{if(u)u.path=u.path&&ee(u.path),a(u);else if(c.isDirectory())Td(t,e,r,n,o,i,s,a);else if(o)er.default.unlink(t,f=>{if(f)return a(f);er.default.mkdir(t,r,HR(t,e,r,n,o,i,s,a))});else{if(c.isSymbolicLink())return a(new wc(t,t+"/"+e.join("/")));a(l)}}):(s=s||t,Td(t,e,r,n,o,i,s,a))},YH=t=>{let e=!1,r;try{e=er.default.statSync(t).isDirectory()}catch(n){r=n?.code}finally{if(!e)throw new vc(t,r??"ENOTDIR")}},KR=(t,e)=>{t=ee(t);let r=e.umask??18,n=e.mode|448,o=(n&r)!==0,i=e.uid,s=e.gid,a=typeof i=="number"&&typeof s=="number"&&(i!==e.processUid||s!==e.processGid),l=e.preserve,u=e.unlink,c=e.cache,f=ee(e.cwd),p=y=>{xc(c,t,!0),y&&a&&r0(y,i,s),o&&er.default.chmodSync(t,n)};if(c&&Od(c,t)===!0)return p();if(t===f)return YH(f),p();if(l)return p(_d(t,n)??void 0);let h=ee(Ec.default.relative(f,t)).split("/"),b;for(let y=h.shift(),v=f;y&&(v+="/"+y);y=h.shift())if(v=ee(Ec.default.resolve(v)),!Od(c,v))try{er.default.mkdirSync(v,n),b=b||v,xc(c,v,!0)}catch{let T=er.default.lstatSync(v);if(T.isDirectory()){xc(c,v,!0);continue}else if(u){er.default.unlinkSync(v),er.default.mkdirSync(v,n),b=b||v,xc(c,v,!0);continue}else if(T.isSymbolicLink())return new wc(v,v+"/"+h.join("/"))}return p(b)};var u0=Object.create(null),{hasOwnProperty:XH}=Object.prototype,Cd=t=>(XH.call(u0,t)||(u0[t]=t.normalize("NFD")),u0[t]);var f0=require("node:path");var QH=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,eK=QH==="win32",tK=t=>t.split("/").slice(0,-1).reduce((r,n)=>{let o=r[r.length-1];return o!==void 0&&(n=(0,f0.join)(o,n)),r.push(n||"/"),r},[]),Ad=class{#e=new Map;#t=new Map;#n=new Set;reserve(e,r){e=eK?["win32 parallelization disabled"]:e.map(o=>mn((0,f0.join)(Cd(o))).toLowerCase());let n=new Set(e.map(o=>tK(o)).reduce((o,i)=>o.concat(i)));this.#t.set(r,{dirs:n,paths:e});for(let o of e){let i=this.#e.get(o);i?i.push(r):this.#e.set(o,[r])}for(let o of n){let i=this.#e.get(o);if(!i)this.#e.set(o,[new Set([r])]);else{let s=i[i.length-1];s instanceof Set?s.add(r):i.push(new Set([r]))}}return this.#i(r)}#o(e){let r=this.#t.get(e);if(!r)throw new Error("function does not have any path reservations");return{paths:r.paths.map(n=>this.#e.get(n)),dirs:[...r.dirs].map(n=>this.#e.get(n))}}check(e){let{paths:r,dirs:n}=this.#o(e);return r.every(o=>o&&o[0]===e)&&n.every(o=>o&&o[0]instanceof Set&&o[0].has(e))}#i(e){return this.#n.has(e)||!this.check(e)?!1:(this.#n.add(e),e(()=>this.#r(e)),!0)}#r(e){if(!this.#n.has(e))return!1;let r=this.#t.get(e);if(!r)throw new Error("invalid reservation");let{paths:n,dirs:o}=r,i=new Set;for(let s of n){let a=this.#e.get(s);if(!a||a?.[0]!==e)continue;let l=a[1];if(!l){this.#e.delete(s);continue}if(a.shift(),typeof l=="function")i.add(l);else for(let u of l)i.add(u)}for(let s of o){let a=this.#e.get(s),l=a?.[0];if(!(!a||!(l instanceof Set)))if(l.size===1&&a.length===1){this.#e.delete(s);continue}else if(l.size===1){a.shift();let u=a[0];typeof u=="function"&&i.add(u)}else l.delete(e)}return this.#n.delete(e),i.forEach(s=>this.#i(s)),!0}};var VR=Symbol("onEntry"),m0=Symbol("checkFs"),GR=Symbol("checkFs2"),Nd=Symbol("pruneCache"),h0=Symbol("isReusable"),wr=Symbol("makeFs"),g0=Symbol("file"),y0=Symbol("directory"),Dd=Symbol("link"),ZR=Symbol("symlink"),JR=Symbol("hardlink"),YR=Symbol("unsupported"),XR=Symbol("checkPath"),$o=Symbol("mkdir"),yt=Symbol("onError"),kd=Symbol("pending"),QR=Symbol("pend"),ca=Symbol("unpend"),p0=Symbol("ended"),d0=Symbol("maybeClose"),b0=Symbol("skip"),Sc=Symbol("doChown"),Ic=Symbol("uid"),_c=Symbol("gid"),Oc=Symbol("checkedCwd"),rK=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Tc=rK==="win32",nK=1024,oK=(t,e)=>{if(!Tc)return ue.default.unlink(t,e);let r=t+".DELETE."+(0,v0.randomBytes)(16).toString("hex");ue.default.rename(t,r,n=>{if(n)return e(n);ue.default.unlink(r,e)})},iK=t=>{if(!Tc)return ue.default.unlinkSync(t);let e=t+".DELETE."+(0,v0.randomBytes)(16).toString("hex");ue.default.renameSync(t,e),ue.default.unlinkSync(e)},eN=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,tN=t=>mn(ee(Cd(t))).toLowerCase(),sK=(t,e)=>{e=tN(e);for(let r of t.keys()){let n=tN(r);(n===e||n.indexOf(e+"/")===0)&&t.delete(r)}},aK=t=>{for(let e of t.keys())t.delete(e)},ua=class extends zn{[p0]=!1;[Oc]=!1;[kd]=0;reservations=new Ad;transform;writable=!0;readable=!1;dirCache;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[p0]=!0,this[d0]()},super(e),this.transform=e.transform,this.dirCache=e.dirCache||new Map,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;e.preserveOwner===void 0&&typeof e.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:nK,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||Tc,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=ee(yn.default.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:process.umask():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",r=>this[VR](r))}warn(e,r,n={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(n.recoverable=!1),super.warn(e,r,n)}[d0](){this[p0]&&this[kd]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[XR](e){let r=ee(e.path),n=r.split("/");if(this.strip){if(n.length=this.strip)e.linkpath=o.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),e.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:r,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(n.includes("..")||Tc&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:e,path:r}),!1;let[o,i]=uc(r);o&&(e.path=String(i),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:e,path:r}))}if(yn.default.isAbsolute(e.path)?e.absolute=ee(yn.default.resolve(e.path)):e.absolute=ee(yn.default.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:ee(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:o}=yn.default.win32.parse(String(e.absolute));e.absolute=o+Pv(String(e.absolute).slice(o.length));let{root:i}=yn.default.win32.parse(e.path);e.path=i+Pv(e.path.slice(i.length))}return!0}[VR](e){if(!this[XR](e))return e.resume();switch(rN.default.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode=e.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[m0](e);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[YR](e)}}[yt](e,r){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:r}),this[ca](),r.resume())}[$o](e,r,n){WR(ee(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:r},n)}[Sc](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Ic](e){return eN(this.uid,e.uid,this.processUid)}[_c](e){return eN(this.gid,e.gid,this.processGid)}[g0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,o=new $n(String(e.absolute),{flags:Qv(e.size),mode:n,autoClose:!1});o.on("error",l=>{o.fd&&ue.default.close(o.fd,()=>{}),o.write=()=>!0,this[yt](l,e),r()});let i=1,s=l=>{if(l){o.fd&&ue.default.close(o.fd,()=>{}),this[yt](l,e),r();return}--i===0&&o.fd!==void 0&&ue.default.close(o.fd,u=>{u?this[yt](u,e):this[ca](),r()})};o.on("finish",()=>{let l=String(e.absolute),u=o.fd;if(typeof u=="number"&&e.mtime&&!this.noMtime){i++;let c=e.atime||new Date,f=e.mtime;ue.default.futimes(u,c,f,p=>p?ue.default.utimes(l,c,f,d=>s(d&&p)):s())}if(typeof u=="number"&&this[Sc](e)){i++;let c=this[Ic](e),f=this[_c](e);typeof c=="number"&&typeof f=="number"&&ue.default.fchown(u,c,f,p=>p?ue.default.chown(l,c,f,d=>s(d&&p)):s())}s()});let a=this.transform&&this.transform(e)||e;a!==e&&(a.on("error",l=>{this[yt](l,e),r()}),e.pipe(a)),a.pipe(o)}[y0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.dmode;this[$o](String(e.absolute),n,o=>{if(o){this[yt](o,e),r();return}let i=1,s=()=>{--i===0&&(r(),this[ca](),e.resume())};e.mtime&&!this.noMtime&&(i++,ue.default.utimes(String(e.absolute),e.atime||new Date,e.mtime,s)),this[Sc](e)&&(i++,ue.default.chown(String(e.absolute),Number(this[Ic](e)),Number(this[_c](e)),s)),s()})}[YR](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[ZR](e,r){this[Dd](e,String(e.linkpath),"symlink",r)}[JR](e,r){let n=ee(yn.default.resolve(this.cwd,String(e.linkpath)));this[Dd](e,n,"link",r)}[QR](){this[kd]++}[ca](){this[kd]--,this[d0]()}[b0](e){this[ca](),e.resume()}[h0](e,r){return e.type==="File"&&!this.unlink&&r.isFile()&&r.nlink<=1&&!Tc}[m0](e){this[QR]();let r=[e.path];e.linkpath&&r.push(e.linkpath),this.reservations.reserve(r,n=>this[GR](e,n))}[Nd](e){e.type==="SymbolicLink"?aK(this.dirCache):e.type!=="Directory"&&sK(this.dirCache,String(e.absolute))}[GR](e,r){this[Nd](e);let n=a=>{this[Nd](e),r(a)},o=()=>{this[$o](this.cwd,this.dmode,a=>{if(a){this[yt](a,e),n();return}this[Oc]=!0,i()})},i=()=>{if(e.absolute!==this.cwd){let a=ee(yn.default.dirname(String(e.absolute)));if(a!==this.cwd)return this[$o](a,this.dmode,l=>{if(l){this[yt](l,e),n();return}s()})}s()},s=()=>{ue.default.lstat(String(e.absolute),(a,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(e.mtime??l.mtime))){this[b0](e),n();return}if(a||this[h0](e,l))return this[wr](null,e,n);if(l.isDirectory()){if(e.type==="Directory"){let u=this.chmod&&e.mode&&(l.mode&4095)!==e.mode,c=f=>this[wr](f??null,e,n);return u?ue.default.chmod(String(e.absolute),Number(e.mode),c):c()}if(e.absolute!==this.cwd)return ue.default.rmdir(String(e.absolute),u=>this[wr](u??null,e,n))}if(e.absolute===this.cwd)return this[wr](null,e,n);oK(String(e.absolute),u=>this[wr](u??null,e,n))})};this[Oc]?i():o()}[wr](e,r,n){if(e){this[yt](e,r),n();return}switch(r.type){case"File":case"OldFile":case"ContiguousFile":return this[g0](r,n);case"Link":return this[JR](r,n);case"SymbolicLink":return this[ZR](r,n);case"Directory":case"GNUDumpDir":return this[y0](r,n)}}[Dd](e,r,n,o){ue.default[n](r,String(e.absolute),i=>{i?this[yt](i,e):(this[ca](),e.resume()),o()})}},Rd=t=>{try{return[null,t()]}catch(e){return[e,null]}},Cc=class extends ua{sync=!0;[wr](e,r){return super[wr](e,r,()=>{})}[m0](e){if(this[Nd](e),!this[Oc]){let i=this[$o](this.cwd,this.dmode);if(i)return this[yt](i,e);this[Oc]=!0}if(e.absolute!==this.cwd){let i=ee(yn.default.dirname(String(e.absolute)));if(i!==this.cwd){let s=this[$o](i,this.dmode);if(s)return this[yt](s,e)}}let[r,n]=Rd(()=>ue.default.lstatSync(String(e.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(e.mtime??n.mtime)))return this[b0](e);if(r||this[h0](e,n))return this[wr](null,e);if(n.isDirectory()){if(e.type==="Directory"){let s=this.chmod&&e.mode&&(n.mode&4095)!==e.mode,[a]=s?Rd(()=>{ue.default.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[wr](a,e)}let[i]=Rd(()=>ue.default.rmdirSync(String(e.absolute)));this[wr](i,e)}let[o]=e.absolute===this.cwd?[]:Rd(()=>iK(String(e.absolute)));this[wr](o,e)}[g0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,o=a=>{let l;try{ue.default.closeSync(i)}catch(u){l=u}(a||l)&&this[yt](a||l,e),r()},i;try{i=ue.default.openSync(String(e.absolute),Qv(e.size),n)}catch(a){return o(a)}let s=this.transform&&this.transform(e)||e;s!==e&&(s.on("error",a=>this[yt](a,e)),e.pipe(s)),s.on("data",a=>{try{ue.default.writeSync(i,a,0,a.length)}catch(l){o(l)}}),s.on("end",()=>{let a=null;if(e.mtime&&!this.noMtime){let l=e.atime||new Date,u=e.mtime;try{ue.default.futimesSync(i,l,u)}catch(c){try{ue.default.utimesSync(String(e.absolute),l,u)}catch{a=c}}}if(this[Sc](e)){let l=this[Ic](e),u=this[_c](e);try{ue.default.fchownSync(i,Number(l),Number(u))}catch(c){try{ue.default.chownSync(String(e.absolute),Number(l),Number(u))}catch{a=a||c}}}o(a)})}[y0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.dmode,o=this[$o](String(e.absolute),n);if(o){this[yt](o,e),r();return}if(e.mtime&&!this.noMtime)try{ue.default.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Sc](e))try{ue.default.chownSync(String(e.absolute),Number(this[Ic](e)),Number(this[_c](e)))}catch{}r(),e.resume()}[$o](e,r){try{return KR(ee(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:r})}catch(n){return n}}[Dd](e,r,n,o){let i=`${n}Sync`;try{ue.default[i](r,String(e.absolute)),o(),e.resume()}catch(s){return this[yt](s,e)}}};var lK=t=>{let e=new Cc(t),r=t.file,n=w0.default.statSync(r),o=t.maxReadSize||16*1024*1024;new Hp(r,{readSize:o,size:n.size}).pipe(e)},cK=(t,e)=>{let r=new ua(t),n=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((s,a)=>{r.on("error",a),r.on("close",s),w0.default.stat(o,(l,u)=>{if(l)a(l);else{let c=new Ci(o,{readSize:n,size:u.size});c.on("error",a),c.pipe(r)}})})},uK=fn(lK,cK,t=>new Cc(t),t=>new ua(t),(t,e)=>{e?.length&&Nv(t,e)});var Lt=Z(require("node:fs"),1),x0=Z(require("node:path"),1);var fK=(t,e)=>{let r=new ji(t),n=!0,o,i;try{try{o=Lt.default.openSync(t.file,"r+")}catch(l){if(l?.code==="ENOENT")o=Lt.default.openSync(t.file,"w+");else throw l}let s=Lt.default.fstatSync(o),a=Buffer.alloc(512);e:for(i=0;is.size)break;i+=u,t.mtimeCache&&l.mtime&&t.mtimeCache.set(String(l.path),l.mtime)}n=!1,pK(t,r,i,o,e)}finally{if(n)try{Lt.default.closeSync(o)}catch{}}},pK=(t,e,r,n,o)=>{let i=new ra(t.file,{fd:n,start:r});e.pipe(i),mK(e,o)},dK=(t,e)=>{e=Array.from(e);let r=new Po(t),n=(i,s,a)=>{let l=(d,h)=>{d?Lt.default.close(i,b=>a(d)):a(null,h)},u=0;if(s===0)return l(null,0);let c=0,f=Buffer.alloc(512),p=(d,h)=>{if(d||typeof h>"u")return l(d);if(c+=h,c<512&&h)return Lt.default.read(i,f,c,f.length-c,u+c,p);if(u===0&&f[0]===31&&f[1]===139)return l(new Error("cannot append to compressed archives"));if(c<512)return l(null,u);let b=new Qt(f);if(!b.cksumValid)return l(null,u);let y=512*Math.ceil((b.size??0)/512);if(u+y+512>s||(u+=y+512,u>=s))return l(null,u);t.mtimeCache&&b.mtime&&t.mtimeCache.set(String(b.path),b.mtime),c=0,Lt.default.read(i,f,0,512,u,p)};Lt.default.read(i,f,0,512,u,p)};return new Promise((i,s)=>{r.on("error",s);let a="r+",l=(u,c)=>{if(u&&u.code==="ENOENT"&&a==="r+")return a="w+",Lt.default.open(t.file,a,l);if(u||!c)return s(u);Lt.default.fstat(c,(f,p)=>{if(f)return Lt.default.close(c,()=>s(f));n(c,p.size,(d,h)=>{if(d)return s(d);let b=new $n(t.file,{fd:c,start:h});r.pipe(b),b.on("error",s),b.on("close",i),hK(r,e)})})};Lt.default.open(t.file,a,l)})},mK=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Un({file:x0.default.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(r)}),t.end()},hK=async(t,e)=>{for(let r=0;rt.add(o)}):t.add(n)}t.end()},qi=fn(fK,dK,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!lR(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});var gK=fn(qi.syncFile,qi.asyncFile,qi.syncNoFile,qi.asyncNoFile,(t,e=[])=>{qi.validate?.(t,e),yK(t)}),yK=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,n)=>e(r,n)&&!((t.mtimeCache?.get(r)??n.mtime??0)>(n.mtime??0)):(r,n)=>!((t.mtimeCache?.get(r)??n.mtime??0)>(n.mtime??0))};var Pd=async(t,e,r)=>{if(r){await(0,Fd.writeFile)(e,Buffer.from(t));return}let n=(0,nN.createWriteStream)(e);try{let o="build/Release/better_sqlite3.node",i=[];i.push((0,E0.pipeline)(oN.Readable.from(Buffer.from(t)),Un({gzip:!0,onReadEntry:s=>{s.path===o&&i.push((0,E0.pipeline)(s,n))}},[o]))),await Promise.all(i)}catch(o){throw n.destroy(),await(0,Fd.rm)(e,{force:!0}),o}},iN=async()=>{let t=await Yk({multiple:!1,accept:[".tar.gz",".node"],strict:!0});return t?{decompressed:!t.name.endsWith(".gz"),arrayBuffer:await t.arrayBuffer()}:null},sN=async t=>(await(0,S0.requestUrl)({url:t,method:"HEAD"})).status,aN=async t=>(await(0,S0.requestUrl)({url:t})).arrayBuffer;var lN=(i=>(i[i.Idle=0]="Idle",i[i.Downloading=1]="Downloading",i[i.Importing=2]="Importing",i[i.Success=3]="Success",i[i.Failed=4]="Failed",i))(lN||{}),fa=Jt(0),vK=Jt(t=>t(fa)===4),cN=Jt(null),wK=Jt(t=>{switch(t(fa)){case 0:return null;case 1:return"Downloading...";case 2:return"Importing...";case 3:return"Module successfully installed";case 4:return`Module install failed: ${t(cN)}`;default:break}}),xK=Jt(null,(t,e,[r,n])=>{e(fa,4);let o="Failed to install module when "+lN[r];mt(o,n),e(cN,o+": "+(n instanceof Error?n.message:`${n}`))}),EK=()=>{let t=nv(fa),e=nv(xK),r=xt(Jl),n=xt(Dp);return Yt(async()=>{if(!n){e([0,new Error("Cannot find binary version")]);return}t(1);let o;try{if(await sN(r)===404)throw new Error(`Requested module not available (${r}), please open an issue on GitHub`);o=await aN(r)}catch(i){e([1,i]);return}t(2);try{await Pd(o,n,!1)}catch(i){e([2,i]);return}t(3)})},uN=()=>{let t=xt(fa),e=xt(wK),r=xt(Dr),n=EK();return m("div",{className:"zt-auto-install",children:[m(Xl,{name:"Auto Install",desc:"Recommended",button:t===0?"Install":void 0,onClick:n}),t!==0&&m(Xl,{className:Zs("zt-auto-install-status",{"mod-warning":t===4,"mod-success":t===3}),icon:m(IK,{}),name:e,button:t===3?"Reload Plugin":void 0,onClick:()=>r.reloadPlugin()})]})},SK=()=>{let t=xt(vK),[e]=Mt(t?"slash":"check");return m("div",{className:"zt-install-done-icon",style:{display:"contents"},ref:e})},IK=()=>{switch(xt(fa)){case 0:return null;case 1:case 2:return m(Jk,{className:"zt-install-spin-icon",style:{display:"contents"}});case 3:case 4:return m(SK,{})}};var fN=require("obsidian");S();var _K=async t=>{try{let e=await iN();return e?(await Pd(e.arrayBuffer,t,e.decompressed),!0):(W.info("No file selected, skip import module"),!1)}catch(e){return new fN.Notice(`Failed to import module from ${t}: ${e}`),mt("import module "+t,e),!1}},OK=()=>{let[t,e]=L(!1),r=xt(Dp),n=async()=>{if(!r)return;await _K(r)&&e(!0)},o=xt(Jl),i=xt(ov),s=xt(Dr);return m("ol",{children:[m("li",{children:["Download ",m("code",{children:".node.gz"})," file from"," ",m("a",{href:o,children:"GitHub"}),"."]}),m("li",{children:["Select downloaded ",m("code",{children:i})," or uncompressed"," ",m("code",{children:"better-sqlite3.node"}),"to install:",m(TK,{onClick:n,done:t})]}),m("li",{children:["Reload ZotLit:",m(CK,{onClick:()=>s.reloadPlugin()})]})]})},pN=()=>{let[t,e]=L(!1);return m("div",{className:"zt-manual-install",children:[m(Xl,{name:"Manual Install",desc:"Use this option if you have trouble downloading the module with auto install.",button:`${t?"Hide":"Show"} Guide`,onClick:()=>e(r=>!r)}),m("div",{hidden:!t,children:m(OK,{})})]})},TK=({done:t,onClick:e})=>m("button",{className:Zs({"zt-import-done":t}),onClick:e,children:t?"Library file imported":"Select"}),CK=({disabled:t,onClick:e})=>m("button",{disabled:t,onClick:e,children:"Reload Plugin"});var AK=()=>{let t=xt(Bk);switch(t){case"install":return m(M,{children:["ZotLit requires latest version of ",m("code",{children:"better-sqlite3"})," to be installed. Use one of the method below to install or update it."]});case"reset":return m(M,{children:[m("code",{children:"better-sqlite3"})," seems to be broken and failed to load. you can try to use one of the method below to reinstall it."]});default:(0,dN.default)(t)}},mN=()=>m(M,{children:[m("style",{children:` +${t}`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},custom:{mustBe:t=>t},cases:{mustBe:t=>Tb(t)}},XC=Ce(xi),eW=()=>{let t={},e;for(e of XC)t[e]={mustBe:xi[e].mustBe,writeReason:xi[e].writeReason??wi,addContext:xi[e].addContext??YC};return t},tW=eW(),QC=t=>{if(!t)return tW;let e={};for(let r of XC)e[r]={mustBe:t[r]?.mustBe??xi[r].mustBe,writeReason:t[r]?.writeReason??xi[r].writeReason??t.writeReason??wi,addContext:t[r]?.addContext??xi[r].addContext??t.addContext??YC};return e};function rW(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function nW(t,e){return e.get?e.get.call(t):e.value}function oW(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function rk(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function Ab(t,e){var r=rk(t,e,"get");return nW(t,r)}function iW(t,e,r){rW(t,e),e.set(t,r)}function sW(t,e,r){var n=rk(t,e,"set");return oW(t,n,r),r}function cn(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var aW=()=>({mustBe:[],writeReason:[],addContext:[],keys:[]}),cW=["mustBe","writeReason","addContext"],nk=(t,e)=>{let r=new Rb(e,t);hp(t.flat,r);let n=new ok(r);if(r.problems.count)n.problems=r.problems;else{for(let[o,i]of r.entriesToPrune)delete o[i];n.data=r.data}return n},ok=class{constructor(){cn(this,"data",void 0),cn(this,"problems",void 0)}},Vc=new WeakMap,Rb=class{getProblemConfig(e){let r={};for(let n of cW)r[n]=this.traversalConfig[n][0]??this.rootScope.config.codes[e][n];return r}traverseConfig(e,r){for(let o of e)this.traversalConfig[o[0]].unshift(o[1]);let n=hp(r,this);for(let o of e)this.traversalConfig[o[0]].shift();return n}traverseKey(e,r){let n=this.data;this.data=this.data[e],this.path.push(e);let o=hp(r,this);return this.path.pop(),n[e]!==this.data&&(n[e]=this.data),this.data=n,o}traverseResolution(e){let r=this.type.scope.resolve(e),n=r.qualifiedName,o=this.data,i=vo(o,"object");if(i){let l=Ab(this,Vc)[n];if(l){if(l.includes(o))return!0;l.push(o)}else Ab(this,Vc)[n]=[o]}let s=this.type;this.type=r;let c=hp(r.flat,this);return this.type=s,i&&Ab(this,Vc)[n].pop(),c}traverseBranches(e){let r=this.failFast;this.failFast=!0;let n=this.problems,o=new mp(this);this.problems=o;let i=this.path,s=this.entriesToPrune,c=!1;for(let l of e)if(this.path=new Qe,this.entriesToPrune=[],gp(l,this)){c=!0,s.push(...this.entriesToPrune);break}return this.path=i,this.entriesToPrune=s,this.problems=n,this.failFast=r,c||!this.problems.add("branches",o)}constructor(e,r){cn(this,"data",void 0),cn(this,"type",void 0),cn(this,"path",void 0),cn(this,"problems",void 0),cn(this,"entriesToPrune",void 0),cn(this,"failFast",void 0),cn(this,"traversalConfig",void 0),cn(this,"rootScope",void 0),iW(this,Vc,{writable:!0,value:void 0}),this.data=e,this.type=r,this.path=new Qe,this.problems=new mp(this),this.entriesToPrune=[],this.failFast=!1,this.traversalConfig=aW(),sW(this,Vc,{}),this.rootScope=r.scope}},hp=(t,e)=>typeof t=="string"?qe(e.data)===t||!e.problems.add("domain",t):gp(t,e),gp=(t,e)=>{let r=!0;for(let n=0;nt[0]in e.data?e.traverseKey(t[0],t[1]):(e.problems.add("missing",void 0,{path:e.path.concat(t[0]),data:void 0}),!1),tk=t=>(e,r)=>{let n=!0,o={...e.required};for(let s in r.data)if(e.required[s]?(n=r.traverseKey(s,e.required[s])&&n,delete o[s]):e.optional[s]?n=r.traverseKey(s,e.optional[s])&&n:e.index&&Jf.test(s)?n=r.traverseKey(s,e.index)&&n:t==="distilledProps"?r.failFast?r.entriesToPrune.push([r.data,s]):delete r.data[s]:(n=!1,r.problems.add("extraneous",r.data[s],{path:r.path.concat(s)})),!n&&r.failFast)return!1;let i=Object.keys(o);if(i.length){for(let s of i)r.problems.add("missing",void 0,{path:r.path.concat(s)});return!1}return n},lW={regex:DC,divisor:TC,domains:(t,e)=>{let r=t[qe(e.data)];return r?gp(r,e):!e.problems.add("cases",kb(Ce(t)))},domain:(t,e)=>qe(e.data)===t||!e.problems.add("domain",t),bound:NC,optionalProp:(t,e)=>t[0]in e.data?e.traverseKey(t[0],t[1]):!0,requiredProp:ek,prerequisiteProp:ek,indexProp:(t,e)=>{if(!Array.isArray(e.data))return e.problems.add("class",Array),!1;let r=!0;for(let n=0;ne.traverseBranches(t),switch:(t,e)=>{let r=dC(e.data,t.path),n=WC(t.kind,r);if(js(t.cases,n))return gp(t.cases[n],e);let o=Ce(t.cases),i=e.path.concat(t.path),s=t.kind==="value"?o:t.kind==="domain"?kb(o):t.kind==="class"?JC(o):Oe(`Unexpectedly encountered rule kind '${t.kind}' during traversal`);return e.problems.add("cases",s,{path:i,data:r}),!1},alias:(t,e)=>e.traverseResolution(t),class:IC,narrow:(t,e)=>{let r=e.problems.count,n=t(e.data,e.problems);return!n&&e.problems.count===r&&e.problems.mustBe(t.name?`valid according to ${t.name}`:"valid"),n},config:({config:t,node:e},r)=>r.traverseConfig(t,e),value:(t,e)=>e.data===t||!e.problems.add("value",t),morph:(t,e)=>{let r=t(e.data,e.problems);if(e.problems.length)return!1;if(r instanceof Ei)return e.problems.addProblem(r),!1;if(r instanceof ok){if(r.problems){for(let n of r.problems)e.problems.addProblem(n);return!1}return e.data=r.data,!0}return e.data=r,!0},distilledProps:tk("distilledProps"),strictProps:tk("strictProps")};a();var Io=new Proxy(()=>Io,{get:()=>Io});var Nb=(t,e,r,n)=>{let o={node:t,flat:[["alias",t]],allows:c=>!i(c).problems,assert:c=>{let l=i(c);return l.problems?l.problems.throw():l.data},infer:Io,inferIn:Io,qualifiedName:uW(t)?n.getAnonymousQualifiedName(t):`${n.name}.${t}`,definition:e,scope:n,includesMorph:!1,config:r},i={[t]:c=>nk(i,c)}[t];return Object.assign(i,o)},Db=t=>t?.infer===Io,uW=t=>t[0]==="\u03BB";a();a();var ik=t=>{let e=t.scanner.shiftUntilNextTerminator();t.setRoot(fW(t,e))},fW=(t,e)=>t.ctx.type.scope.addParsedReferenceIfResolvable(e,t.ctx)?e:pW(e)??t.error(e===""?Pb(t):dW(e)),pW=t=>{let e=$c(t);if(e!==void 0)return{number:{value:e}};let r=lb(t);if(r!==void 0)return{bigint:{value:r}}},dW=t=>`'${t}' is unresolvable`,Pb=t=>{let e=t.previousOperator();return e?Fb(e,t.scanner.unscanned):mW(t.scanner.unscanned)},Fb=(t,e)=>`Token '${t}' requires a right operand${e?` before '${e}'`:""}`,mW=t=>`Expected an expression${t?` before '${t}'`:""}`;a();var Mb=(t,e)=>({node:e.type.scope.resolveTypeNode(tt(t[0],e)),config:t[2]});a();a();var vr=t=>Object.isFrozen(t)?t:Array.isArray(t)?Object.freeze(t.map(vr)):hW(t),hW=t=>{for(let e in t)vr(t[e]);return t};var gW=vr({regex:Mc.source}),yW=vr({range:{min:{comparator:">=",limit:0}},divisor:1}),sk=(t,e)=>{let r=e.type.scope.resolveNode(tt(t[1],e)),n=Ce(r).map(u=>vW(u,r[u])),o=ak(n);if(!o.length)return op(e.path,"keyof");let i={};for(let u of o){let d=typeof u;if(d==="string"||d==="number"||d==="symbol"){var s,c;(s=i)[c=d]??(s[c]=[]),i[d].push({value:u})}else if(u===Mc){var l,f;(l=i).string??(l.string=[]),i.string.push(gW),(f=i).number??(f.number=[]),i.number.push(yW)}else return Oe(`Unexpected keyof key '${Pe(u)}'`)}return Object.fromEntries(Object.entries(i).map(([u,d])=>[u,d.length===1?d[0]:d]))},bW={bigint:vi(0n),boolean:vi(!1),null:[],number:vi(0),object:[],string:vi(""),symbol:vi(Symbol()),undefined:[]},vW=(t,e)=>t!=="object"||e===!0?bW[t]:ak(on(e).map(r=>wW(r))),ak=t=>{if(!t.length)return[];let e=t[0];for(let r=1;rt[r].includes(n));return e},wW=t=>{let e=[];if("props"in t)for(let r of Object.keys(t.props))r===an.index?e.push(Mc):e.includes(r)||(e.push(r),Mc.test(r)&&e.push(Yf(r,`Unexpectedly failed to parse an integer from key '${r}'`)));if("class"in t){let r=typeof t.class=="string"?Lc[t.class]:t.class;for(let n of vi(r.prototype))e.includes(n)||e.push(n)}return e};a();var lk=(t,e)=>{if(typeof t[2]!="function")return Ee(xW(t[2]));let r=tt(t[0],e),n=e.type.scope.resolveTypeNode(r),o=t[2];e.type.includesMorph=!0;let i,s={};for(i in n){let c=n[i];c===!0?s[i]={rules:{},morph:o}:typeof c=="object"?s[i]=xo(c)?c.map(l=>ck(l,o)):ck(c,o):Oe(`Unexpected predicate value for domain '${i}': ${Pe(c)}`)}return s},ck=(t,e)=>wb(t)?{...t,morph:t.morph?Array.isArray(t.morph)?[...t.morph,e]:[t.morph,e]:e}:{rules:t,morph:e},xW=t=>`Morph expression requires a function following '|>' (was ${typeof t})`;a();a();var uk=t=>`Expected a Function or Record operand (${Pe(t)} was invalid)`,fk=(t,e,r,n)=>{let o=Ce(e);if(!vo(t,"object"))return Ee(uk(t));let i={};if(typeof t=="function"){let s={[n]:t};for(let c of o)i[c]=s}else for(let s of o){if(t[s]===void 0)continue;let c={[n]:t[s]};if(typeof c[n]!="function")return Ee(uk(c));i[s]=c}return i};var pk=(t,e)=>{let r=tt(t[0],e),n=e.type.scope.resolveNode(r),o=Kc(n),i=o?n.node:n,s=So(r,fk(t[2],i,e,"narrow"),e.type);return o?{config:n.config,node:s}:s};var mk=(t,e)=>{if(SW(t))return hk[t[1]](t,e);if(IW(t))return gk[t[0]](t,e);let r={length:["!",{number:{value:t.length}}]};for(let n=0;n{if(t[2]===void 0)return Ee(Fb(t[1],""));let r=tt(t[0],e),n=tt(t[2],e);return t[1]==="&"?So(r,n,e.type):pp(r,n,e.type)},EW=(t,e)=>Ws(tt(t[0],e));var SW=t=>hk[t[1]]!==void 0,hk={"|":dk,"&":dk,"[]":EW,"=>":pk,"|>":lk,":":Mb},gk={keyof:sk,instanceof:t=>typeof t[1]!="function"?Ee(`Expected a constructor following 'instanceof' operator (was ${typeof t[1]}).`):{object:{class:t[1]}},"===":t=>({[qe(t[1])]:{value:t[1]}}),node:t=>t[1]},IW=t=>gk[t[0]]!==void 0;a();var yk=(t,e)=>{let r={};for(let n in t){let o=n,i=!1;n[n.length-1]==="?"&&(n[n.length-2]===Fe.escapeToken?o=`${n.slice(0,-2)}?`:(o=n.slice(0,-1),i=!0)),e.path.push(o);let s=tt(t[n],e);e.path.pop(),r[o]=i?["?",s]:s}return{object:{props:r}}};a();a();a();var bk=t=>`Unmatched )${t===""?"":` before ${t}`}`,vk="Missing )",wk=(t,e)=>`Left bounds are only valid when paired with right bounds (try ...${e}${t})`,yp=t=>`Left-bounded expressions must specify their limits using < or <= (was ${t})`,xk=(t,e,r,n)=>`An expression may have at most one left bound (parsed ${t}${Fe.invertedComparators[e]}, ${r}${Fe.invertedComparators[n]})`;function Gc(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var bp=class{error(e){return Ee(e)}hasRoot(){return this.root!==void 0}resolveRoot(){return this.assertHasRoot(),this.ctx.type.scope.resolveTypeNode(this.root)}rootToString(){return this.assertHasRoot(),Pe(this.root)}ejectRootIfLimit(){this.assertHasRoot();let e=typeof this.root=="string"?this.ctx.type.scope.resolveNode(this.root):this.root;if(lp(e,"number")){let r=e.number.value;return this.root=void 0,r}}ejectRangeIfOpen(){if(this.branches.range){let e=this.branches.range;return delete this.branches.range,e}}assertHasRoot(){if(this.root===void 0)return Oe("Unexpected interaction with unset root")}assertUnsetRoot(){if(this.root!==void 0)return Oe("Unexpected attempt to overwrite root")}setRoot(e){this.assertUnsetRoot(),this.root=e}rootToArray(){this.root=Ws(this.ejectRoot())}intersect(e){this.root=So(this.ejectRoot(),e,this.ctx.type)}ejectRoot(){this.assertHasRoot();let e=this.root;return this.root=void 0,e}ejectFinalizedRoot(){this.assertHasRoot();let e=this.root;return this.root=_W,e}finalize(){if(this.groups.length)return this.error(vk);this.finalizeBranches(),this.scanner.finalized=!0}reduceLeftBound(e,r){let n=Fe.invertedComparators[r];if(!gr(n,fp))return this.error(yp(r));if(this.branches.range)return this.error(xk(`${this.branches.range.limit}`,this.branches.range.comparator,`${e}`,n));this.branches.range={limit:e,comparator:n}}finalizeBranches(){this.assertRangeUnset(),this.branches.union?(this.pushRootToBranch("|"),this.setRoot(this.branches.union)):this.branches.intersection&&this.setRoot(So(this.branches.intersection,this.ejectRoot(),this.ctx.type))}finalizeGroup(){this.finalizeBranches();let e=this.groups.pop();if(!e)return this.error(bk(this.scanner.unscanned));this.branches=e}pushRootToBranch(e){this.assertRangeUnset(),this.branches.intersection=this.branches.intersection?So(this.branches.intersection,this.ejectRoot(),this.ctx.type):this.ejectRoot(),e==="|"&&(this.branches.union=this.branches.union?pp(this.branches.union,this.branches.intersection,this.ctx.type):this.branches.intersection,delete this.branches.intersection)}assertRangeUnset(){if(this.branches.range)return this.error(wk(`${this.branches.range.limit}`,this.branches.range.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={}}previousOperator(){return this.branches.range?.comparator??this.branches.intersection?"&":this.branches.union?"|":void 0}shiftedByOne(){return this.scanner.shift(),this}constructor(e,r){Gc(this,"ctx",void 0),Gc(this,"scanner",void 0),Gc(this,"root",void 0),Gc(this,"branches",void 0),Gc(this,"groups",void 0),this.ctx=r,this.branches={},this.groups=[],this.scanner=new Fe(e)}},_W=new Proxy({},{get:()=>Oe("Unexpected attempt to access ejected attributes")});a();a();var Ek=(t,e)=>{let r=t.scanner.shiftUntil(TW[e]);if(t.scanner.lookahead==="")return t.error(CW(r,e));t.scanner.shift()==="/"?(yb(r),t.setRoot({string:{regex:r}})):t.setRoot({string:{value:r}})},Sk={"'":1,'"':1,"/":1},TW={"'":t=>t.lookahead==="'",'"':t=>t.lookahead==='"',"/":t=>t.lookahead==="/"},OW={'"':"double-quote","'":"single-quote","/":"forward slash"},CW=(t,e)=>`${e}${t} requires a closing ${OW[e]}`;var vp=t=>t.scanner.lookahead===""?t.error(Pb(t)):t.scanner.lookahead==="("?t.shiftedByOne().reduceGroupOpen():t.scanner.lookaheadIsIn(Sk)?Ek(t,t.scanner.shift()):t.scanner.lookahead===" "?vp(t.shiftedByOne()):ik(t);a();a();a();var Ik=t=>`Bounded expression ${t} must be a number, string or array`;var _k=(t,e)=>{let r=kW(t,e),n=t.ejectRootIfLimit();return n===void 0?RW(t,r):t.reduceLeftBound(n,r)},kW=(t,e)=>t.scanner.lookaheadIs("=")?`${e}${t.scanner.shift()}`:gr(e,Fe.oneCharComparators)?e:t.error(AW),AW="= is not a valid comparator. Use == to check for equality",RW=(t,e)=>{let r=t.scanner.shiftUntilNextTerminator(),n=$c(r,PW(e,r+t.scanner.unscanned)),o=t.ejectRangeIfOpen(),i={comparator:e,limit:n},s=o?$b(i,hb)?zs("min",o,i)==="l"?t.error(FW({min:o,max:i})):{min:o,max:i}:t.error(yp(e)):DW(i,"==")?i:$b(i,fp)?{min:i}:$b(i,hb)?{max:i}:Oe(`Unexpected comparator '${i.comparator}'`);t.intersect(NW(s,t))},NW=(t,e)=>{let r=e.resolveRoot(),n=Ce(r),o={},i={range:t};return n.every(c=>{switch(c){case"string":return o.string=i,!0;case"number":return o.number=i,!0;case"object":return o.object=i,r.object===!0?!1:on(r.object).every(l=>"class"in l&&l.class===Array);default:return!1}})||e.error(Ik(e.rootToString())),o},DW=(t,e)=>t.comparator===e,$b=(t,e)=>t.comparator in e,PW=(t,e)=>`Comparator ${t} must be followed by a number literal (was '${e}')`,FW=t=>`${tp(t)} is empty`;a();a();var Tk=t=>`Divisibility operand ${t} must be a number`;var Ck=t=>{let e=t.scanner.shiftUntilNextTerminator(),r=Yf(e,Ok(e));r===0&&t.error(Ok(0));let n=Ce(t.resolveRoot());n.length===1&&n[0]==="number"?t.intersect({number:{divisor:r}}):t.error(Tk(t.rootToString()))},Ok=t=>`% operator must be followed by a non-zero integer literal (was ${t})`;var Lb=t=>{let e=t.scanner.shift();return e===""?t.finalize():e==="["?t.scanner.shift()==="]"?t.rootToArray():t.error($W):gr(e,Fe.branchTokens)?t.pushRootToBranch(e):e===")"?t.finalizeGroup():gr(e,Fe.comparatorStartChars)?_k(t,e):e==="%"?Ck(t):e===" "?Lb(t):Oe(MW(e))},MW=t=>`Unexpected character '${t}'`,$W="Missing expected ']'";var kk=(t,e)=>e.type.scope.parseCache.get(t)??e.type.scope.parseCache.set(t,LW(t,e)??jW(t,e)),LW=(t,e)=>{if(e.type.scope.addParsedReferenceIfResolvable(t,e))return t;if(t.endsWith("[]")){let r=t.slice(0,-2);if(e.type.scope.addParsedReferenceIfResolvable(t,e))return Ws(r)}},jW=(t,e)=>{let r=new bp(t,e);return vp(r),qW(r)},qW=t=>{for(;!t.scanner.finalized;)BW(t);return t.ejectFinalizedRoot()},BW=t=>t.hasRoot()?Lb(t):vp(t);var tt=(t,e)=>{let r=qe(t);if(r==="string")return kk(t,e);if(r!=="object")return Ee(jb(r));let n=Bs(t);switch(n){case"Object":return yk(t,e);case"Array":return mk(t,e);case"RegExp":return{string:{regex:t.source}};case"Function":if(Db(t))return e.type.scope.addAnonymousTypeReference(t,e);if(zW(t)){let o=t();if(Db(o))return e.type.scope.addAnonymousTypeReference(o,e)}return Ee(jb("Function"));default:return Ee(jb(n??Pe(t)))}},gbe=Symbol("as"),zW=t=>typeof t=="function"&&t.length===0,jb=t=>`Type definitions must be strings or objects (was ${t})`;a();function UW(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var Ks=class{get root(){return this.cache}has(e){return e in this.cache}get(e){return this.cache[e]}set(e,r){return this.cache[e]=r,r}constructor(){UW(this,"cache",{})}},wp=class extends Ks{set(e,r){return this.cache[e]=vr(r),r}};function Pk(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function WW(t,e){return e.get?e.get.call(t):e.value}function HW(t,e,r){if(e.set)e.set.call(t,r);else{if(!e.writable)throw new TypeError("attempted to set read only private field");e.value=r}}function Fk(t,e,r){if(!e.has(t))throw new TypeError("attempted to "+r+" private field on non-instance");return e.get(t)}function Dn(t,e){var r=Fk(t,e,"get");return WW(t,r)}function Ak(t,e,r){Pk(t,e),e.set(t,r)}function Rk(t,e,r){var n=Fk(t,e,"set");return HW(t,n,r),r}function Nn(t,e,r){if(!e.has(t))throw new TypeError("attempted to get private field on non-instance");return r}function xp(t,e){Pk(t,e),e.add(t)}function Mt(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var KW=t=>({codes:QC(t.codes),keys:t.keys??"loose"}),VW=0,Nk={},qb={};var Si=new WeakMap,Vs=new WeakMap,Dk=new WeakSet,Ep=new WeakSet,zb=new WeakSet,Sp=new WeakSet,Ub=class{getAnonymousQualifiedName(e){let r=0,n=e;for(;this.isResolvable(n);)n=`${e}${r++}`;return`${this.name}.${n}`}addAnonymousTypeReference(e,r){var n;return(n=r.type).includesMorph||(n.includesMorph=e.includesMorph),e.node}get infer(){return Io}compile(){if(!qb[this.name]){for(let e in this.aliases)this.resolve(e);qb[this.name]=Dn(this,Vs).root}return Dn(this,Vs).root}addParsedReferenceIfResolvable(e,r){var n;let o=Nn(this,Sp,Wb).call(this,e,"undefined",[e]);return o?((n=r.type).includesMorph||(n.includesMorph=o.includesMorph),!0):!1}resolve(e){return Nn(this,Sp,Wb).call(this,e,"throw",[e])}resolveNode(e){return typeof e=="string"?this.resolveNode(this.resolve(e).node):e}resolveTypeNode(e){let r=this.resolveNode(e);return Kc(r)?r.node:r}isResolvable(e){return Dn(this,Si).has(e)||this.aliases[e]}constructor(e,r={}){xp(this,Dk),xp(this,Ep),xp(this,zb),xp(this,Sp),Mt(this,"aliases",void 0),Mt(this,"name",void 0),Mt(this,"config",void 0),Mt(this,"parseCache",void 0),Ak(this,Si,{writable:!0,value:void 0}),Ak(this,Vs,{writable:!0,value:void 0}),Mt(this,"expressions",void 0),Mt(this,"intersection",void 0),Mt(this,"union",void 0),Mt(this,"arrayOf",void 0),Mt(this,"keyOf",void 0),Mt(this,"valueOf",void 0),Mt(this,"instanceOf",void 0),Mt(this,"narrow",void 0),Mt(this,"morph",void 0),Mt(this,"type",void 0),this.aliases=e,this.parseCache=new wp,Rk(this,Si,new Ks),Rk(this,Vs,new Ks),this.expressions={intersection:(n,o,i)=>this.type([n,"&",o],i),union:(n,o,i)=>this.type([n,"|",o],i),arrayOf:(n,o)=>this.type([n,"[]"],o),keyOf:(n,o)=>this.type(["keyof",n],o),node:(n,o)=>this.type(["node",n],o),instanceOf:(n,o)=>this.type(["instanceof",n],o),valueOf:(n,o)=>this.type(["===",n],o),narrow:(n,o,i)=>this.type([n,"=>",o],i),morph:(n,o,i)=>this.type([n,"|>",o],i)},this.intersection=this.expressions.intersection,this.union=this.expressions.union,this.arrayOf=this.expressions.arrayOf,this.keyOf=this.expressions.keyOf,this.valueOf=this.expressions.valueOf,this.instanceOf=this.expressions.instanceOf,this.narrow=this.expressions.narrow,this.morph=this.expressions.morph,this.type=Object.assign((n,o={})=>{let i=Nb("\u03BBtype",n,o,this),s=Nn(this,zb,Mk).call(this,i),c=tt(n,s);return i.node=vr(Pc(o)?{config:o,node:this.resolveTypeNode(c)}:c),i.flat=vr(Ib(i)),i},{from:this.expressions.node}),this.name=Nn(this,Dk,GW).call(this,r),r.standard!==!1&&Nn(this,Ep,Bb).call(this,[qb.standard],"imports"),r.imports&&Nn(this,Ep,Bb).call(this,r.imports,"imports"),r.includes&&Nn(this,Ep,Bb).call(this,r.includes,"includes"),this.config=KW(r)}};function GW(t){let e=t.name?Nk[t.name]?Ee(`A scope named '${t.name}' already exists`):t.name:`scope${++VW}`;return Nk[e]=this,e}function Bb(t,e){for(let r of t)for(let n in r)(Dn(this,Si).has(n)||n in this.aliases)&&Ee(JW(n)),Dn(this,Si).set(n,r[n]),e==="includes"&&Dn(this,Vs).set(n,r[n])}function Mk(t){return{type:t,path:new Qe}}function Wb(t,e,r){let n=Dn(this,Si).get(t);if(n)return n;let o=this.aliases[t];if(!o)return e==="throw"?Oe(`Unexpectedly failed to resolve alias '${t}'`):void 0;let i=Nb(t,o,{},this),s=Nn(this,zb,Mk).call(this,i);Dn(this,Si).set(t,i),Dn(this,Vs).set(t,i);let c=tt(o,s);if(typeof c=="string"){if(r.includes(c))return Ee(ZW(t,r));r.push(c),c=Nn(this,Sp,Wb).call(this,c,"throw",r).node}return i.node=vr(c),i.flat=vr(Ib(i)),i}var $t=(t,e={})=>new Ub(t,e),Hb=$t({},{name:"root",standard:!1}),Fr=Hb.type,ZW=(t,e)=>`Alias '${t}' has a shallow resolution cycle: ${[...e,t].join("=>")}`,JW=t=>`Alias '${t}' is already defined`;a();a();var Ip=$t({Function:["node",{object:{class:Function}}],Date:["node",{object:{class:Date}}],Error:["node",{object:{class:Error}}],Map:["node",{object:{class:Map}}],RegExp:["node",{object:{class:RegExp}}],Set:["node",{object:{class:Set}}],WeakMap:["node",{object:{class:WeakMap}}],WeakSet:["node",{object:{class:WeakSet}}],Promise:["node",{object:{class:Promise}}]},{name:"jsObjects",standard:!1}),$k=Ip.compile();a();var Lk={bigint:!0,boolean:!0,null:!0,number:!0,object:!0,string:!0,symbol:!0,undefined:!0},_p=$t({any:["node",Lk],bigint:["node",{bigint:!0}],boolean:["node",{boolean:!0}],false:["node",{boolean:{value:!1}}],never:["node",{}],null:["node",{null:!0}],number:["node",{number:!0}],object:["node",{object:!0}],string:["node",{string:!0}],symbol:["node",{symbol:!0}],true:["node",{boolean:{value:!0}}],unknown:["node",Lk],void:["node",{undefined:!0}],undefined:["node",{undefined:!0}]},{name:"ts",standard:!1}),Ii=_p.compile();a();a();var YW=t=>{let e=t.replace(/[- ]+/g,""),r=0,n,o,i;for(let s=e.length-1;s>=0;s--)n=e.substring(s,s+1),o=parseInt(n,10),i?(o*=2,o>=10?r+=o%10+1:r+=o):r+=o,i=!i;return!!(r%10===0&&e)},XW=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\d{3})\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,jk=Fr([XW,"=>",(t,e)=>YW(t)||!e.mustBe("a valid credit card number")],{mustBe:"a valid credit card number"});a();var QW=/^[./-]$/,e7=/^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/,t7=t=>!isNaN(t),Tp=t=>`a ${t}-formatted date`,r7=(t,e)=>{if(!e?.format){let c=new Date(t);return t7(c)?c:"a valid date"}if(e.format==="iso8601")return e7.test(t)?new Date(t):Tp("iso8601");let r=t.split(QW),n=t[r[0].length],o=n?e.format.split(n):[e.format];if(r.length!==o.length)return Tp(e.format);let i={};for(let c=0;c",(t,e)=>{let r=r7(t);return typeof r=="string"?e.mustBe(r):r}]);var n7=Fr([cb,"|>",t=>parseFloat(t)],{mustBe:"a well-formed numeric string"}),o7=Fr([Ii.string,"|>",(t,e)=>{if(!Fc(t))return e.mustBe("a well-formed integer string");let r=parseInt(t);return Number.isSafeInteger(r)?r:e.mustBe("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")}]),i7=Fr(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$/,{mustBe:"a valid email"}),s7=Fr(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,{mustBe:"a valid UUID"}),a7=Fr(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/,{mustBe:"a valid semantic version (see https://semver.org/)"}),c7=Fr([Ii.string,"|>",t=>JSON.parse(t)],{mustBe:"a JSON-parsable string"}),Op=$t({alpha:[/^[A-Za-z]*$/,":",{mustBe:"only letters"}],alphanumeric:[/^[A-Za-z\d]*$/,":",{mustBe:"only letters and digits"}],lowercase:[/^[a-z]*$/,":",{mustBe:"only lowercase letters"}],uppercase:[/^[A-Z]*$/,":",{mustBe:"only uppercase letters"}],creditCard:jk,email:i7,uuid:s7,parsedNumber:n7,parsedInteger:o7,parsedDate:qk,semver:a7,json:c7,integer:["node",{number:{divisor:1}}]},{name:"validation",standard:!1}),Bk=Op.compile();var Cp=$t({},{name:"standard",includes:[Ii,$k,Bk],standard:!1}),l7=Cp.compile(),Pn={root:Hb,tsKeywords:_p,jsObjects:Ip,validation:Op,ark:Cp};var Zc=Cp.type;a();var u7=Pn.ark.intersection,f7=Pn.ark.union,p7=Pn.ark.arrayOf,d7=Pn.ark.keyOf,m7=Pn.ark.instanceOf,h7=Pn.ark.valueOf,g7=Pn.ark.narrow,y7=Pn.ark.morph;var{DataRequest:wve,DataResponse:zk}=$t({DataRequest:{id:"number",method:"string",params:"any[]"},DataResponse:{id:"number","eventName?":"string",payload:"any",error:"any"}}).compile(),kp="__METHODS__",Ap="__EVAL__";a();a();var Uk=()=>({events:{},emit(t,...e){let r=this.events[t]||[];for(let n=0,o=r.length;n{this.events[t]=this.events[t]?.filter(r=>e!==r)}}});function _i(){let t=Uk();return t.once=(e,r)=>{let n=(...i)=>{o(),r(...i)},o=t.on(e,n);return o},t}function b7(t){return Object.assign(new Error,t)}var Ti=class{pending=new Map;terminateState=!1;terminationHandler=null;lastId=0;worker;constructor(){this.worker=this.setupWorker(),this.worker.onMessage(e=>this.onMessage(e.data)),this.worker.onError(e=>this.onError(e.error))}internal=_i();evt=_i();task=_i();onMessage(e){if(this.terminateState==="finished")return;if(e==="ready"){this.internal.emit("ready");return}let{data:r,problems:n}=zk(e);if(n)throw new Error(n.toString());if(r.eventName){this.evt.emit(r.eventName,r.payload);return}this.task.emit(r.id,r.payload,r.error),this.terminateState==="requested"&&this.terminate()}onError(e){for(let r of this.pending.values())r.abort(e);this.pending.clear(),this.worker.terminate()}methods(){return this.invoke(kp)}eval(e,r,n){let o=[e,...r];return this.invoke(Ap,o,{transfer:n})}send({id:e,method:r,params:n,transfer:o,timeout:i},s=new AbortController){let c=s.signal;return this.pending.set(e,s),new Promise((l,f)=>{this.worker.send({id:e,method:r,params:n},{transfer:o});let u=-1,d=()=>{f(c?.reason),m(),window.clearTimeout(u)};i!==void 0&&(u=window.setTimeout(()=>{s.abort(new DOMException(`Timeout after ${i}ms`,"TimeoutError"))},i)),c?.addEventListener("abort",d);let m=this.task.once(e,(h,y)=>{c?.removeEventListener("abort",d),y?f(b7(y)):l(h)})}).catch(l=>{if(l instanceof DOMException&&["AbortError","TimeoutError"].includes(l.name))return this.terminate(!0).then(()=>{throw l});throw l}).finally(()=>{this.pending.delete(e)})}async invoke(e,r=[],{controller:n,transfer:o}={}){if(this.terminateState!==!1)throw new Error("Worker is terminated");let i=++this.lastId;return await this.worker.readyPromise,await this.send({id:i,method:e,params:r,transfer:o},n)}busy(){return this.pending.size>0}terminate(e=!1,r){if(e){for(let n of this.pending.values())n.abort(new Error("Worker terminated"));this.pending.clear()}if(this.busy()){this.terminateState="requested";let n=new Promise(o=>{this.internal.once("terminate",o)});return r!==void 0?Promise.race([n,v7(r)]).then():n}return this.worker.terminate(),Promise.resolve()}};function v7(t){return new Promise(e=>setTimeout(()=>e(new DOMException(`Timeout after ${t}ms`,"TimeoutError")),t))}a();var Gs=class extends Ti{setupWorker(){let e=this,r=Object.assign(this.initWebWorker(),{readyPromise:new Promise(n=>e.internal.once("ready",()=>n(!0))),killed:!1,send(n,o){r.postMessage(n,o)},onMessage(n){return r.addEventListener("message",n),()=>r.removeEventListener("message",n)},onError(n){return r.addEventListener("error",n),()=>r.removeEventListener("error",n)}});return cr(r,{terminate:n=>function(){r.killed||(n.call(this),r.killed=!0,e.internal.emit("terminate")),e.terminateState="finished"}}),r}};a();var Zs=class{workers=[];tasks=[];pending=new Map;emitter=_i();#e=_i();maxQueueSize=1/0;maxWorkers=Math.max((this.getMaxConcurrency()||4)-1,1);minWorkers=0;getMaxConcurrency(){return navigator.hardwareConcurrency}constructor(e={}){if(e.maxQueueSize!==void 0&&(this.maxQueueSize=x7.assert(e.maxQueueSize)),e.maxWorkers!==void 0&&(this.maxWorkers=w7.assert(e.maxWorkers)),e.minWorkers!==void 0){let o=E7.assert(e.minWorkers);o==="max"?this.minWorkers=this.maxWorkers:(this.minWorkers=o,this.maxWorkers=Math.max(this.minWorkers,this.maxWorkers)),this.ensureMinWorkers()}let r={},n=o=>r[o]??=(...i)=>this.invoke(o,i);this.proxy=new Proxy(r,{get:(o,i)=>!Reflect.has(o,i)&&typeof i=="string"?n(i):Reflect.get(o,i)}),this.methods().then(o=>o.forEach(n))}eval(e,r,n={}){return this.invoke(Ap,[typeof e=="string"?e:e.toString(),r],n)}invoke(e,r=[],n={}){if(this.tasks.length>=this.maxQueueSize)throw new Error("Max queue size of "+this.maxQueueSize+" reached");let o={method:e,params:r,transfer:n.transfer};return this.tasks.push(o),this.pending.set(o,n.controller??new AbortController),this.next(),new Promise((i,s)=>{let c=[this.#e.on("complete",(l,f)=>{o===l&&(c.forEach(u=>u()),i(f))}),this.#e.on("error",(l,f)=>{o===l&&(c.forEach(u=>u()),s(f))})]})}methods(){return this.invoke(kp)}proxy;next(){if(this.tasks.length===0)return;let e=this.getWorker();if(!e)return;let r=this.tasks.shift();if(!this.pending.has(r))return this.next();let n=this.pending.get(r);e.invoke(r.method,r.params,{transfer:r.transfer,timeout:r.timeout,controller:n}).then(o=>{this.#e.emit("complete",r,o)}).catch(o=>{this.#e.emit("error",r,o),e.terminateState==="finished"&&this.removeWorker(e)}).finally(()=>{this.pending.delete(r),this.next()})}getWorker(){for(let e of this.workers)if(!e.busy())return e;if(this.workers.length{try{await n.terminate(e,r),this.removeWorkerFromList(n)}finally{this.emitter.emit("worker-terminate")}})).then()}get stats(){let e=this.workers.length,r=this.workers.filter(function(n){return n.busy()}).length;return{totalWorkers:e,busyWorkers:r,idleWorkers:e-r,pendingTasks:this.tasks.length,activeTasks:r}}ensureMinWorkers(){if(this.minWorkers)for(let e=this.workers.length;e=1"),x7=Zc("integer>=1"),E7=Zc('integer>=0|"max"');var Wk='"use strict";var ey=Object.create;var Iu=Object.defineProperty;var ty=Object.getOwnPropertyDescriptor;var ry=Object.getOwnPropertyNames;var ny=Object.getPrototypeOf,oy=Object.prototype.hasOwnProperty;var iy=(e,t)=>()=>(e&&(t=e(e=0)),t);var T=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var sy=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of ry(t))!oy.call(e,o)&&o!==r&&Iu(e,o,{get:()=>t[o],enumerable:!(n=ty(t,o))||n.enumerable});return e};var kr=(e,t,r)=>(r=e!=null?ey(ny(e)):{},sy(t||!e||!e.__esModule?Iu(r,"default",{value:e,enumerable:!0}):r,e));var u=iy(()=>{});var Zs=T((gl,Ys)=>{u();(function(e){if(typeof gl=="object"&&typeof Ys<"u")Ys.exports=e();else if(typeof define=="function"&&define.amd)define([],e);else{var t;typeof window<"u"?t=window:typeof global<"u"?t=global:typeof self<"u"?t=self:t=this,t.localforage=e()}})(function(){var e,t,r;return function n(o,i,s){function a(f,h){if(!i[f]){if(!o[f]){var p=typeof require=="function"&&require;if(!h&&p)return p(f,!0);if(c)return c(f,!0);var b=new Error("Cannot find module \'"+f+"\'");throw b.code="MODULE_NOT_FOUND",b}var E=i[f]={exports:{}};o[f][0].call(E.exports,function(I){var D=o[f][1][I];return a(D||I)},E,E.exports,n,o,i,s)}return i[f].exports}for(var c=typeof require=="function"&&require,m=0;m"u"&&n(3);var p=Promise;function b(l,y){y&&l.then(function(d){y(null,d)},function(d){y(d)})}function E(l,y,d){typeof y=="function"&&l.then(y),typeof d=="function"&&l.catch(d)}function I(l){return typeof l!="string"&&(console.warn(l+" used as a key, but it is not a string."),l=String(l)),l}function D(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var A="local-forage-detect-blob-support",j=void 0,q={},ne=Object.prototype.toString,Ie="readonly",F="readwrite";function z(l){for(var y=l.length,d=new ArrayBuffer(y),w=new Uint8Array(d),x=0;x=43)}}).catch(function(){return!1})}function P(l){return typeof j=="boolean"?p.resolve(j):U(l).then(function(y){return j=y,j})}function B(l){var y=q[l.name],d={};d.promise=new p(function(w,x){d.resolve=w,d.reject=x}),y.deferredOperations.push(d),y.dbReady?y.dbReady=y.dbReady.then(function(){return d.promise}):y.dbReady=d.promise}function _(l){var y=q[l.name],d=y.deferredOperations.pop();if(d)return d.resolve(),d.promise}function k(l,y){var d=q[l.name],w=d.deferredOperations.pop();if(w)return w.reject(y),w.promise}function $(l,y){return new p(function(d,w){if(q[l.name]=q[l.name]||nu(),l.db)if(y)B(l),l.db.close();else return d(l.db);var x=[l.name];y&&x.push(l.version);var v=m.open.apply(m,x);y&&(v.onupgradeneeded=function(S){var O=v.result;try{O.createObjectStore(l.storeName),S.oldVersion<=1&&O.createObjectStore(A)}catch(N){if(N.name==="ConstraintError")console.warn(\'The database "\'+l.name+\'" has been upgraded from version \'+S.oldVersion+" to version "+S.newVersion+\', but the storage "\'+l.storeName+\'" already exists.\');else throw N}}),v.onerror=function(S){S.preventDefault(),w(v.error)},v.onsuccess=function(){var S=v.result;S.onversionchange=function(O){O.target.close()},d(S),_(l)}})}function W(l){return $(l,!1)}function L(l){return $(l,!0)}function G(l,y){if(!l.db)return!0;var d=!l.db.objectStoreNames.contains(l.storeName),w=l.versionl.db.version;if(w&&(l.version!==y&&console.warn(\'The database "\'+l.name+`" can\'t be downgraded from version `+l.db.version+" to version "+l.version+"."),l.version=l.db.version),x||d){if(d){var v=l.db.version+1;v>l.version&&(l.version=v)}return!0}return!1}function H(l){return new p(function(y,d){var w=new FileReader;w.onerror=d,w.onloadend=function(x){var v=btoa(x.target.result||"");y({__local_forage_encoded_blob:!0,data:v,type:l.type})},w.readAsBinaryString(l)})}function re(l){var y=z(atob(l.data));return h([y],{type:l.type})}function Y(l){return l&&l.__local_forage_encoded_blob}function Qn(l){var y=this,d=y._initReady().then(function(){var w=q[y._dbInfo.name];if(w&&w.dbReady)return w.dbReady});return E(d,l,l),d}function rg(l){B(l);for(var y=q[l.name],d=y.forages,w=0;w0&&(!l.db||v.name==="InvalidStateError"||v.name==="NotFoundError"))return p.resolve().then(function(){if(!l.db||v.name==="NotFoundError"&&!l.db.objectStoreNames.contains(l.storeName)&&l.version<=l.db.version)return l.db&&(l.version=l.db.version+1),L(l)}).then(function(){return rg(l).then(function(){mt(l,y,d,w-1)})}).catch(d);d(v)}}function nu(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function ng(l){var y=this,d={db:null};if(l)for(var w in l)d[w]=l[w];var x=q[d.name];x||(x=nu(),q[d.name]=x),x.forages.push(y),y._initReady||(y._initReady=y.ready,y.ready=Qn);var v=[];function S(){return p.resolve()}for(var O=0;O>4,R[x++]=(S&15)<<4|O>>2,R[x++]=(O&3)<<6|N&63;return C}function Ji(l){var y=new Uint8Array(l),d="",w;for(w=0;w>2],d+=xt[(y[w]&3)<<4|y[w+1]>>4],d+=xt[(y[w+1]&15)<<2|y[w+2]>>6],d+=xt[y[w+2]&63];return y.length%3===2?d=d.substring(0,d.length-1)+"=":y.length%3===1&&(d=d.substring(0,d.length-2)+"=="),d}function gg(l,y){var d="";if(l&&(d=hu.call(l)),l&&(d==="[object ArrayBuffer]"||l.buffer&&hu.call(l.buffer)==="[object ArrayBuffer]")){var w,x=Xn;l instanceof ArrayBuffer?(w=l,x+=Gi):(w=l.buffer,d==="[object Int8Array]"?x+=iu:d==="[object Uint8Array]"?x+=su:d==="[object Uint8ClampedArray]"?x+=au:d==="[object Int16Array]"?x+=uu:d==="[object Uint16Array]"?x+=lu:d==="[object Int32Array]"?x+=cu:d==="[object Uint32Array]"?x+=fu:d==="[object Float32Array]"?x+=pu:d==="[object Float64Array]"?x+=mu:y(new Error("Failed to get type for BinaryArray"))),y(x+Ji(w))}else if(d==="[object Blob]"){var v=new FileReader;v.onload=function(){var S=hg+l.type+"~"+Ji(this.result);y(Xn+Hi+S)},v.readAsArrayBuffer(l)}else try{y(JSON.stringify(l))}catch(S){console.error("Couldn\'t convert value into a JSON string: ",l),y(null,S)}}function yg(l){if(l.substring(0,Ki)!==Xn)return JSON.parse(l);var y=l.substring(du),d=l.substring(Ki,du),w;if(d===Hi&&ou.test(y)){var x=y.match(ou);w=x[1],y=y.substring(x[0].length)}var v=gu(y);switch(d){case Gi:return v;case Hi:return h([v],{type:w});case iu:return new Int8Array(v);case su:return new Uint8Array(v);case au:return new Uint8ClampedArray(v);case uu:return new Int16Array(v);case lu:return new Uint16Array(v);case cu:return new Int32Array(v);case fu:return new Uint32Array(v);case pu:return new Float32Array(v);case mu:return new Float64Array(v);default:throw new Error("Unkown type: "+d)}}var Vi={serialize:gg,deserialize:yg,stringToBuffer:gu,bufferToString:Ji};function yu(l,y,d,w){l.executeSql("CREATE TABLE IF NOT EXISTS "+y.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],d,w)}function bg(l){var y=this,d={db:null};if(l)for(var w in l)d[w]=typeof l[w]!="string"?l[w].toString():l[w];var x=new p(function(v,S){try{d.db=openDatabase(d.name,String(d.version),d.description,d.size)}catch(O){return S(O)}d.db.transaction(function(O){yu(O,d,function(){y._dbInfo=d,v()},function(N,C){S(C)})},S)});return d.serializer=Vi,x}function Et(l,y,d,w,x,v){l.executeSql(d,w,x,function(S,O){O.code===O.SYNTAX_ERR?S.executeSql("SELECT name FROM sqlite_master WHERE type=\'table\' AND name = ?",[y.storeName],function(N,C){C.rows.length?v(N,O):yu(N,y,function(){N.executeSql(d,w,x,v)},v)},v):v(S,O)},v)}function vg(l,y){var d=this;l=I(l);var w=new p(function(x,v){d.ready().then(function(){var S=d._dbInfo;S.db.transaction(function(O){Et(O,S,"SELECT * FROM "+S.storeName+" WHERE key = ? LIMIT 1",[l],function(N,C){var R=C.rows.length?C.rows.item(0).value:null;R&&(R=S.serializer.deserialize(R)),x(R)},function(N,C){v(C)})})}).catch(v)});return b(w,y),w}function wg(l,y){var d=this,w=new p(function(x,v){d.ready().then(function(){var S=d._dbInfo;S.db.transaction(function(O){Et(O,S,"SELECT * FROM "+S.storeName,[],function(N,C){for(var R=C.rows,M=R.length,K=0;K0){S(bu.apply(x,[l,N,d,w-1]));return}O(K)}})})}).catch(O)});return b(v,d),v}function xg(l,y,d){return bu.apply(this,[l,y,d,1])}function Eg(l,y){var d=this;l=I(l);var w=new p(function(x,v){d.ready().then(function(){var S=d._dbInfo;S.db.transaction(function(O){Et(O,S,"DELETE FROM "+S.storeName+" WHERE key = ?",[l],function(){x()},function(N,C){v(C)})})}).catch(v)});return b(w,y),w}function Ig(l){var y=this,d=new p(function(w,x){y.ready().then(function(){var v=y._dbInfo;v.db.transaction(function(S){Et(S,v,"DELETE FROM "+v.storeName,[],function(){w()},function(O,N){x(N)})})}).catch(x)});return b(d,l),d}function Sg(l){var y=this,d=new p(function(w,x){y.ready().then(function(){var v=y._dbInfo;v.db.transaction(function(S){Et(S,v,"SELECT COUNT(key) as c FROM "+v.storeName,[],function(O,N){var C=N.rows.item(0).c;w(C)},function(O,N){x(N)})})}).catch(x)});return b(d,l),d}function Og(l,y){var d=this,w=new p(function(x,v){d.ready().then(function(){var S=d._dbInfo;S.db.transaction(function(O){Et(O,S,"SELECT key FROM "+S.storeName+" WHERE id = ? LIMIT 1",[l+1],function(N,C){var R=C.rows.length?C.rows.item(0).key:null;x(R)},function(N,C){v(C)})})}).catch(v)});return b(w,y),w}function Dg(l){var y=this,d=new p(function(w,x){y.ready().then(function(){var v=y._dbInfo;v.db.transaction(function(S){Et(S,v,"SELECT key FROM "+v.storeName,[],function(O,N){for(var C=[],R=0;R \'__WebKitDatabaseInfoTable__\'",[],function(x,v){for(var S=[],O=0;O0}function Fg(l){var y=this,d={};if(l)for(var w in l)d[w]=l[w];return d.keyPrefix=vu(l,y._defaultConfig),Rg()?(y._dbInfo=d,d.serializer=Vi,p.resolve()):p.reject()}function $g(l){var y=this,d=y.ready().then(function(){for(var w=y._dbInfo.keyPrefix,x=localStorage.length-1;x>=0;x--){var v=localStorage.key(x);v.indexOf(w)===0&&localStorage.removeItem(v)}});return b(d,l),d}function Pg(l,y){var d=this;l=I(l);var w=d.ready().then(function(){var x=d._dbInfo,v=localStorage.getItem(x.keyPrefix+l);return v&&(v=x.serializer.deserialize(v)),v});return b(w,y),w}function kg(l,y){var d=this,w=d.ready().then(function(){for(var x=d._dbInfo,v=x.keyPrefix,S=v.length,O=localStorage.length,N=1,C=0;C=0;S--){var O=localStorage.key(S);O.indexOf(v)===0&&localStorage.removeItem(O)}}):x=p.reject("Invalid arguments"),b(x,y),x}var zg={_driver:"localStorageWrapper",_initStorage:Fg,_support:Cg(),iterate:kg,getItem:Pg,setItem:Bg,removeItem:Lg,clear:$g,length:jg,key:Mg,keys:qg,dropInstance:Ug},Wg=function(y,d){return y===d||typeof y=="number"&&typeof d=="number"&&isNaN(y)&&isNaN(d)},Kg=function(y,d){for(var w=y.length,x=0;x"u"?"undefined":s(d))==="object"){if(this._ready)return new Error("Can\'t call config() after localforage has been used.");for(var w in d){if(w==="storeName"&&(d[w]=d[w].replace(/\\W/g,"_")),w==="version"&&typeof d[w]!="number")return new Error("Database version must be a number.");this._config[w]=d[w]}return"driver"in d&&d.driver?this.setDriver(this._config.driver):!0}else return typeof d=="string"?this._config[d]:this._config},l.prototype.defineDriver=function(d,w,x){var v=new p(function(S,O){try{var N=d._driver,C=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!d._driver){O(C);return}for(var R=Yi.concat("_initStorage"),M=0,K=R.length;M{u();var br=1e3,vr=br*60,wr=vr*60,Kt=wr*24,Wv=Kt*7,Kv=Kt*365.25;yl.exports=function(e,t){t=t||{};var r=typeof e;if(r==="string"&&e.length>0)return Gv(e);if(r==="number"&&isFinite(e))return t.long?Jv(e):Hv(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))};function Gv(e){if(e=String(e),!(e.length>100)){var t=/^(-?(?:\\d+)?\\.?\\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(t){var r=parseFloat(t[1]),n=(t[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Kv;case"weeks":case"week":case"w":return r*Wv;case"days":case"day":case"d":return r*Kt;case"hours":case"hour":case"hrs":case"hr":case"h":return r*wr;case"minutes":case"minute":case"mins":case"min":case"m":return r*vr;case"seconds":case"second":case"secs":case"sec":case"s":return r*br;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Hv(e){var t=Math.abs(e);return t>=Kt?Math.round(e/Kt)+"d":t>=wr?Math.round(e/wr)+"h":t>=vr?Math.round(e/vr)+"m":t>=br?Math.round(e/br)+"s":e+"ms"}function Jv(e){var t=Math.abs(e);return t>=Kt?Ko(e,t,Kt,"day"):t>=wr?Ko(e,t,wr,"hour"):t>=vr?Ko(e,t,vr,"minute"):t>=br?Ko(e,t,br,"second"):e+" ms"}function Ko(e,t,r,n){var o=t>=r*1.5;return Math.round(e/r)+" "+n+(o?"s":"")}});var wl=T((lF,vl)=>{u();function Vv(e){r.debug=r,r.default=r,r.coerce=c,r.disable=i,r.enable=o,r.enabled=s,r.humanize=bl(),r.destroy=m,Object.keys(e).forEach(f=>{r[f]=e[f]}),r.names=[],r.skips=[],r.formatters={};function t(f){let h=0;for(let p=0;p{if(F==="%%")return"%";ne++;let U=r.formatters[z];if(typeof U=="function"){let P=D[ne];F=U.call(A,P),D.splice(ne,1),ne--}return F}),r.formatArgs.call(A,D),(A.log||r.log).apply(A,D)}return I.namespace=f,I.useColors=r.useColors(),I.color=r.selectColor(f),I.extend=n,I.destroy=r.destroy,Object.defineProperty(I,"enabled",{enumerable:!0,configurable:!1,get:()=>p!==null?p:(b!==r.namespaces&&(b=r.namespaces,E=r.enabled(f)),E),set:D=>{p=D}}),typeof r.init=="function"&&r.init(I),I}function n(f,h){let p=r(this.namespace+(typeof h>"u"?":":h)+f);return p.log=this.log,p}function o(f){r.save(f),r.namespaces=f,r.names=[],r.skips=[];let h,p=(typeof f=="string"?f:"").split(/[\\s,]+/),b=p.length;for(h=0;h"-"+h)].join(",");return r.enable(""),f}function s(f){if(f[f.length-1]==="*")return!0;let h,p;for(h=0,p=r.skips.length;h{u();Pe.formatArgs=Zv;Pe.save=Qv;Pe.load=Xv;Pe.useColors=Yv;Pe.storage=ew();Pe.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();Pe.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Yv(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\\/(\\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\\/(\\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\\/(\\d+)/)}function Zv(e){if(e[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+e[0]+(this.useColors?"%c ":" ")+"+"+Go.exports.humanize(this.diff),!this.useColors)return;let t="color: "+this.color;e.splice(1,0,t,"color: inherit");let r=0,n=0;e[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),e.splice(n,0,t)}Pe.log=console.debug||console.log||(()=>{});function Qv(e){try{e?Pe.storage.setItem("debug",e):Pe.storage.removeItem("debug")}catch{}}function Xv(){let e;try{e=Pe.storage.getItem("debug")}catch{}return!e&&typeof process<"u"&&"env"in process&&(e=process.env.DEBUG),e}function ew(){try{return localStorage}catch{}}Go.exports=wl()(Pe);var{formatters:tw}=Go.exports;tw.j=function(e){try{return JSON.stringify(e)}catch(t){return"[UnexpectedJSONParseError]: "+t.message}}});var El=T((mF,xl)=>{"use strict";u();xl.exports=rw;function xr(e){return e instanceof Buffer?Buffer.from(e):new e.constructor(e.buffer.slice(),e.byteOffset,e.length)}function rw(e){if(e=e||{},e.circles)return nw(e);return e.proto?n:r;function t(o,i){for(var s=Object.keys(o),a=new Array(s.length),c=0;c{u();var ow=require("util"),Gt=Ee()("log4js:configuration"),Ho=[],Jo=[],Il=e=>!e,Sl=e=>e&&typeof e=="object"&&!Array.isArray(e),iw=e=>/^[A-Za-z][A-Za-z0-9_]*$/g.test(e),sw=e=>e&&typeof e=="number"&&Number.isInteger(e),aw=e=>{Jo.push(e),Gt(`Added listener, now ${Jo.length} listeners`)},uw=e=>{Ho.push(e),Gt(`Added pre-processing listener, now ${Ho.length} listeners`)},Ol=(e,t,r)=>{(Array.isArray(t)?t:[t]).forEach(o=>{if(o)throw new Error(`Problem with log4js configuration: (${ow.inspect(e,{depth:5})}) - ${r}`)})},cw=e=>{Gt("New configuration to be validated: ",e),Ol(e,Il(Sl(e)),"must be an object."),Gt(`Calling pre-processing listeners (${Ho.length})`),Ho.forEach(t=>t(e)),Gt("Configuration pre-processing finished."),Gt(`Calling configuration listeners (${Jo.length})`),Jo.forEach(t=>t(e)),Gt("Configuration finished.")};Dl.exports={configure:cw,addListener:aw,addPreProcessingListener:uw,throwExceptionIf:Ol,anObject:Sl,anInteger:sw,validIdentifier:iw,not:Il}});var Vo=T((yF,Ke)=>{"use strict";u();function _l(e,t){for(var r=e.toString();r.length-1?o:i,a=Jt(t.getHours()),c=Jt(t.getMinutes()),m=Jt(t.getSeconds()),f=_l(t.getMilliseconds(),3),h=lw(t.getTimezoneOffset()),p=e.replace(/dd/g,r).replace(/MM/g,n).replace(/y{1,4}/g,s).replace(/hh/g,a).replace(/mm/g,c).replace(/ss/g,m).replace(/SSS/g,f).replace(/O/g,h);return p}function Nt(e,t,r,n){e["set"+(n?"":"UTC")+t](r)}function fw(e,t,r){var n=e.indexOf("O")<0,o=!1,i=[{pattern:/y{1,4}/,regexp:"\\\\d{1,4}",fn:function(h,p){Nt(h,"FullYear",p,n)}},{pattern:/MM/,regexp:"\\\\d{1,2}",fn:function(h,p){Nt(h,"Month",p-1,n),h.getMonth()!==p-1&&(o=!0)}},{pattern:/dd/,regexp:"\\\\d{1,2}",fn:function(h,p){o&&Nt(h,"Month",h.getMonth()-1,n),Nt(h,"Date",p,n)}},{pattern:/hh/,regexp:"\\\\d{1,2}",fn:function(h,p){Nt(h,"Hours",p,n)}},{pattern:/mm/,regexp:"\\\\d\\\\d",fn:function(h,p){Nt(h,"Minutes",p,n)}},{pattern:/ss/,regexp:"\\\\d\\\\d",fn:function(h,p){Nt(h,"Seconds",p,n)}},{pattern:/SSS/,regexp:"\\\\d\\\\d\\\\d",fn:function(h,p){Nt(h,"Milliseconds",p,n)}},{pattern:/O/,regexp:"[+-]\\\\d{1,2}:?\\\\d{2}?|Z",fn:function(h,p){p==="Z"?p=0:p=p.replace(":","");var b=Math.abs(p),E=(p>0?-1:1)*(b%100+Math.floor(b/100)*60);h.setUTCMinutes(h.getUTCMinutes()+E)}}],s=i.reduce(function(h,p){return p.pattern.test(h.regexp)?(p.index=h.regexp.match(p.pattern).index,h.regexp=h.regexp.replace(p.pattern,"("+p.regexp+")")):p.index=-1,h},{regexp:e,index:[]}),a=i.filter(function(h){return h.index>-1});a.sort(function(h,p){return h.index-p.index});var c=new RegExp(s.regexp),m=c.exec(t);if(m){var f=r||Ke.exports.now();return a.forEach(function(h,p){h.fn(f,m[p+1])}),f}throw new Error("String \'"+t+"\' could not be parsed as \'"+e+"\'")}function pw(e,t,r){if(!e)throw new Error("pattern must be supplied");return fw(e,t,r)}function mw(){return new Date}Ke.exports=Tl;Ke.exports.asString=Tl;Ke.exports.parse=pw;Ke.exports.now=mw;Ke.exports.ISO8601_FORMAT="yyyy-MM-ddThh:mm:ss.SSS";Ke.exports.ISO8601_WITH_TZ_OFFSET_FORMAT="yyyy-MM-ddThh:mm:ss.SSSO";Ke.exports.DATETIME_FORMAT="dd MM yyyy hh:mm:ss.SSS";Ke.exports.ABSOLUTETIME_FORMAT="hh:mm:ss.SSS"});var Xs=T((vF,Ll)=>{u();var Ct=Vo(),Nl=require("os"),wn=require("util"),vn=require("path"),Cl=require("url"),Al=Ee()("log4js:layouts"),Rl={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[90,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[91,39],yellow:[33,39]};function Fl(e){return e?`\\x1B[${Rl[e][0]}m`:""}function $l(e){return e?`\\x1B[${Rl[e][1]}m`:""}function dw(e,t){return Fl(t)+e+$l(t)}function Pl(e,t){return dw(wn.format("[%s] [%s] %s - ",Ct.asString(e.startTime),e.level.toString(),e.categoryName),t)}function kl(e){return Pl(e)+wn.format(...e.data)}function Yo(e){return Pl(e,e.level.colour)+wn.format(...e.data)}function Ml(e){return wn.format(...e.data)}function ql(e){return e.data[0]}function jl(e,t){let r="%r %p %c - %m%n",n=/%(-?[0-9]+)?(\\.?-?[0-9]+)?([[\\]cdhmnprzxXyflos%])(\\{([^}]+)\\})?|([^%]+)/;e=e||r;function o(_,k){let $=_.categoryName;if(k){let W=parseInt(k,10),L=$.split(".");WL&&($=G.slice(-L).join(vn.sep))}return $}function q(_){return _.lineNumber?`${_.lineNumber}`:""}function ne(_){return _.columnNumber?`${_.columnNumber}`:""}function Ie(_){return _.callStack||""}let F={c:o,d:i,h:s,m:a,n:c,p:m,r:f,"[":h,"]":p,y:I,z:E,"%":b,x:D,X:A,f:j,l:q,o:ne,s:Ie};function z(_,k,$){return F[_](k,$)}function U(_,k){let $;return _?($=parseInt(_.slice(1),10),$>0?k.slice(0,$):k.slice($)):k}function P(_,k){let $;if(_)if(_.charAt(0)==="-")for($=parseInt(_.slice(1),10);k.length<$;)k+=" ";else for($=parseInt(_,10);k.length<$;)k=` ${k}`;return k}function B(_,k,$){let W=_;return W=U(k,W),W=P($,W),W}return function(_){let k="",$,W=e;for(;($=n.exec(W))!==null;){let L=$[1],G=$[2],H=$[3],re=$[5],Y=$[6];if(Y)k+=Y.toString();else{let Qn=z(H,_,re);k+=B(Qn,G,L)}W=W.slice($.index+$[0].length)}return k}}var Qs={messagePassThrough(){return Ml},basic(){return kl},colored(){return Yo},coloured(){return Yo},pattern(e){return jl(e&&e.pattern,e&&e.tokens)},dummy(){return ql}};Ll.exports={basicLayout:kl,messagePassThroughLayout:Ml,patternLayout:jl,colouredLayout:Yo,coloredLayout:Yo,dummyLayout:ql,addLayout(e,t){Qs[e]=t},layout(e,t){return Qs[e]&&Qs[e](t)}}});var Vt=T((xF,Ul)=>{u();var he=Ht(),Bl=["white","grey","black","blue","cyan","green","magenta","red","yellow"],ge=class{constructor(t,r,n){this.level=t,this.levelStr=r,this.colour=n}toString(){return this.levelStr}static getLevel(t,r){return t?t instanceof ge?t:(t instanceof Object&&t.levelStr&&(t=t.levelStr),ge[t.toString().toUpperCase()]||r):r}static addLevels(t){t&&(Object.keys(t).forEach(n=>{let o=n.toUpperCase();ge[o]=new ge(t[n].value,o,t[n].colour);let i=ge.levels.findIndex(s=>s.levelStr===o);i>-1?ge.levels[i]=ge[o]:ge.levels.push(ge[o])}),ge.levels.sort((n,o)=>n.level-o.level))}isLessThanOrEqualTo(t){return typeof t=="string"&&(t=ge.getLevel(t)),this.level<=t.level}isGreaterThanOrEqualTo(t){return typeof t=="string"&&(t=ge.getLevel(t)),this.level>=t.level}isEqualTo(t){return typeof t=="string"&&(t=ge.getLevel(t)),this.level===t.level}};ge.levels=[];ge.addLevels({ALL:{value:Number.MIN_VALUE,colour:"grey"},TRACE:{value:5e3,colour:"blue"},DEBUG:{value:1e4,colour:"cyan"},INFO:{value:2e4,colour:"green"},WARN:{value:3e4,colour:"yellow"},ERROR:{value:4e4,colour:"red"},FATAL:{value:5e4,colour:"magenta"},MARK:{value:9007199254740992,colour:"grey"},OFF:{value:Number.MAX_VALUE,colour:"grey"}});he.addListener(e=>{let t=e.levels;t&&(he.throwExceptionIf(e,he.not(he.anObject(t)),"levels must be an object"),Object.keys(t).forEach(n=>{he.throwExceptionIf(e,he.not(he.validIdentifier(n)),`level name "${n}" is not a valid identifier (must start with a letter, only contain A-Z,a-z,0-9,_)`),he.throwExceptionIf(e,he.not(he.anObject(t[n])),`level "${n}" must be an object`),he.throwExceptionIf(e,he.not(t[n].value),`level "${n}" must have a \'value\' property`),he.throwExceptionIf(e,he.not(he.anInteger(t[n].value)),`level "${n}".value must have an integer value`),he.throwExceptionIf(e,he.not(t[n].colour),`level "${n}" must have a \'colour\' property`),he.throwExceptionIf(e,he.not(Bl.indexOf(t[n].colour)>-1),`level "${n}".colour must be one of ${Bl.join(", ")}`)}))});he.addListener(e=>{ge.addLevels(e.levels)});Ul.exports=ge});var Ql=T(En=>{"use strict";u();var{parse:Kl,stringify:Gl}=JSON,{keys:hw}=Object,xn=String,Hl="string",zl={},Zo="object",Jl=(e,t)=>t,gw=e=>e instanceof xn?xn(e):e,yw=(e,t)=>typeof t===Hl?new xn(t):t,Vl=(e,t,r,n)=>{let o=[];for(let i=hw(r),{length:s}=i,a=0;a{let n=xn(t.push(r)-1);return e.set(r,n),n},Yl=(e,t)=>{let r=Kl(e,yw).map(gw),n=r[0],o=t||Jl,i=typeof n===Zo&&n?Vl(r,new Set,n,o):n;return o.call({"":i},"",i)};En.parse=Yl;var Zl=(e,t,r)=>{let n=t&&typeof t===Zo?(f,h)=>f===""||-1Kl(Zl(e));En.toJSON=bw;var vw=e=>Yl(Gl(e));En.fromJSON=vw});var ea=T((OF,tf)=>{u();var Xl=Ql(),ef=Vt(),Er=class{constructor(t,r,n,o,i){this.startTime=new Date,this.categoryName=t,this.data=n,this.level=r,this.context=Object.assign({},o),this.pid=process.pid,i&&(this.functionName=i.functionName,this.fileName=i.fileName,this.lineNumber=i.lineNumber,this.columnNumber=i.columnNumber,this.callStack=i.callStack)}serialise(){return Xl.stringify(this,(t,r)=>(r&&r.message&&r.stack?r=Object.assign({message:r.message,stack:r.stack},r):typeof r=="number"&&(Number.isNaN(r)||!Number.isFinite(r))?r=r.toString():typeof r>"u"&&(r=typeof r),r))}static deserialise(t){let r;try{let n=Xl.parse(t,(o,i)=>{if(i&&i.message&&i.stack){let s=new Error(i);Object.keys(i).forEach(a=>{s[a]=i[a]}),i=s}return i});n.location={functionName:n.functionName,fileName:n.fileName,lineNumber:n.lineNumber,columnNumber:n.columnNumber,callStack:n.callStack},r=new Er(n.categoryName,ef.getLevel(n.level.levelStr),n.data,n.context,n.location),r.startTime=new Date(n.startTime),r.pid=n.pid,r.cluster=n.cluster}catch(n){r=new Er("log4js",ef.ERROR,["Unable to parse log:",t,"because: ",n])}return r}};tf.exports=Er});var Xo=T((_F,of)=>{u();var Ge=Ee()("log4js:clustering"),ww=ea(),xw=Ht(),Ir=!1,He=null;try{He=require("cluster")}catch{Ge("cluster module not present"),Ir=!0}var ra=[],Sn=!1,In="NODE_APP_INSTANCE",rf=()=>Sn&&process.env[In]==="0",ta=()=>Ir||He&&He.isMaster||rf(),nf=e=>{ra.forEach(t=>t(e))},Qo=(e,t)=>{if(Ge("cluster message received from worker ",e,": ",t),e.topic&&e.data&&(t=e,e=void 0),t&&t.topic&&t.topic==="log4js:message"){Ge("received message: ",t.data);let r=ww.deserialise(t.data);nf(r)}};Ir||xw.addListener(e=>{ra.length=0,{pm2:Sn,disableClustering:Ir,pm2InstanceVar:In="NODE_APP_INSTANCE"}=e,Ge(`clustering disabled ? ${Ir}`),Ge(`cluster.isMaster ? ${He&&He.isMaster}`),Ge(`pm2 enabled ? ${Sn}`),Ge(`pm2InstanceVar = ${In}`),Ge(`process.env[${In}] = ${process.env[In]}`),Sn&&process.removeListener("message",Qo),He&&He.removeListener&&He.removeListener("message",Qo),Ir||e.disableClustering?Ge("Not listening for cluster messages, because clustering disabled."):rf()?(Ge("listening for PM2 broadcast messages"),process.on("message",Qo)):He&&He.isMaster?(Ge("listening for cluster messages"),He.on("message",Qo)):Ge("not listening for messages, because we are not a master process")});of.exports={onlyOnMaster:(e,t)=>ta()?e():t,isMaster:ta,send:e=>{ta()?nf(e):(Sn||(e.cluster={workerId:He.worker.id,worker:process.pid}),process.send({topic:"log4js:message",data:e.serialise()}))},onMessage:e=>{ra.push(e)}}});var uf=T((NF,af)=>{u();function Ew(e){if(typeof e=="number"&&Number.isInteger(e))return e;let t={K:1024,M:1024*1024,G:1024*1024*1024},r=Object.keys(t),n=e.slice(-1).toLocaleUpperCase(),o=e.slice(0,-1).trim();if(r.indexOf(n)<0||!Number.isInteger(Number(o)))throw Error(`maxLogSize: "${e}" is invalid`);return o*t[n]}function Iw(e,t){let r=Object.assign({},t);return Object.keys(e).forEach(n=>{r[n]&&(r[n]=e[n](t[n]))}),r}function na(e){return Iw({maxLogSize:Ew},e)}var sf={dateFile:na,file:na,fileSync:na};af.exports.modifyConfig=e=>sf[e.type]?sf[e.type](e):e});var lf=T((AF,cf)=>{u();var Sw=console.log.bind(console);function Ow(e,t){return r=>{Sw(e(r,t))}}function Dw(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),Ow(r,e.timezoneOffset)}cf.exports.configure=Dw});var pf=T(ff=>{u();function _w(e,t){return r=>{process.stdout.write(`${e(r,t)}\n`)}}function Tw(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),_w(r,e.timezoneOffset)}ff.configure=Tw});var df=T((PF,mf)=>{u();function Nw(e,t){return r=>{process.stderr.write(`${e(r,t)}\n`)}}function Cw(e,t){let r=t.colouredLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),Nw(r,e.timezoneOffset)}mf.exports.configure=Cw});var gf=T((MF,hf)=>{u();function Aw(e,t,r,n){let o=n.getLevel(e),i=n.getLevel(t,n.FATAL);return s=>{let a=s.level;o.isLessThanOrEqualTo(a)&&i.isGreaterThanOrEqualTo(a)&&r(s)}}function Rw(e,t,r,n){let o=r(e.appender);return Aw(e.level,e.maxLevel,o,n)}hf.exports.configure=Rw});var vf=T((jF,bf)=>{u();var yf=Ee()("log4js:categoryFilter");function Fw(e,t){return typeof e=="string"&&(e=[e]),r=>{yf(`Checking ${r.categoryName} against ${e}`),e.indexOf(r.categoryName)===-1&&(yf("Not excluded, sending to appender"),t(r))}}function $w(e,t,r){let n=r(e.appender);return Fw(e.exclude,n)}bf.exports.configure=$w});var Ef=T((BF,xf)=>{u();var wf=Ee()("log4js:noLogFilter");function Pw(e){return e.filter(r=>r!=null&&r!=="")}function kw(e,t){return r=>{wf(`Checking data: ${r.data} against filters: ${e}`),typeof e=="string"&&(e=[e]),e=Pw(e);let n=new RegExp(e.join("|"),"i");(e.length===0||r.data.findIndex(o=>n.test(o))<0)&&(wf("Not excluded, sending to appender"),t(r))}}function Mw(e,t,r){let n=r(e.appender);return kw(e.exclude,n)}xf.exports.configure=Mw});var Re=T(oa=>{"use strict";u();oa.fromCallback=function(e){return Object.defineProperty(function(){if(typeof arguments[arguments.length-1]=="function")e.apply(this,arguments);else return new Promise((t,r)=>{arguments[arguments.length]=(n,o)=>{if(n)return r(n);t(o)},arguments.length++,e.apply(this,arguments)})},"name",{value:e.name})};oa.fromPromise=function(e){return Object.defineProperty(function(){let t=arguments[arguments.length-1];if(typeof t!="function")return e.apply(this,arguments);e.apply(this,arguments).then(r=>t(null,r),t)},"name",{value:e.name})}});var Sf=T((KF,If)=>{u();var At=require("constants"),qw=process.cwd,ei=null,jw=process.env.GRACEFUL_FS_PLATFORM||process.platform;process.cwd=function(){return ei||(ei=qw.call(process)),ei};try{process.cwd()}catch{}typeof process.chdir=="function"&&(ia=process.chdir,process.chdir=function(e){ei=null,ia.call(process,e)},Object.setPrototypeOf&&Object.setPrototypeOf(process.chdir,ia));var ia;If.exports=Lw;function Lw(e){At.hasOwnProperty("O_SYMLINK")&&process.version.match(/^v0\\.6\\.[0-2]|^v0\\.5\\./)&&t(e),e.lutimes||r(e),e.chown=i(e.chown),e.fchown=i(e.fchown),e.lchown=i(e.lchown),e.chmod=n(e.chmod),e.fchmod=n(e.fchmod),e.lchmod=n(e.lchmod),e.chownSync=s(e.chownSync),e.fchownSync=s(e.fchownSync),e.lchownSync=s(e.lchownSync),e.chmodSync=o(e.chmodSync),e.fchmodSync=o(e.fchmodSync),e.lchmodSync=o(e.lchmodSync),e.stat=a(e.stat),e.fstat=a(e.fstat),e.lstat=a(e.lstat),e.statSync=c(e.statSync),e.fstatSync=c(e.fstatSync),e.lstatSync=c(e.lstatSync),e.chmod&&!e.lchmod&&(e.lchmod=function(f,h,p){p&&process.nextTick(p)},e.lchmodSync=function(){}),e.chown&&!e.lchown&&(e.lchown=function(f,h,p,b){b&&process.nextTick(b)},e.lchownSync=function(){}),jw==="win32"&&(e.rename=typeof e.rename!="function"?e.rename:function(f){function h(p,b,E){var I=Date.now(),D=0;f(p,b,function A(j){if(j&&(j.code==="EACCES"||j.code==="EPERM"||j.code==="EBUSY")&&Date.now()-I<6e4){setTimeout(function(){e.stat(b,function(q,ne){q&&q.code==="ENOENT"?f(p,b,A):E(j)})},D),D<100&&(D+=10);return}E&&E(j)})}return Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h}(e.rename)),e.read=typeof e.read!="function"?e.read:function(f){function h(p,b,E,I,D,A){var j;if(A&&typeof A=="function"){var q=0;j=function(ne,Ie,F){if(ne&&ne.code==="EAGAIN"&&q<10)return q++,f.call(e,p,b,E,I,D,j);A.apply(this,arguments)}}return f.call(e,p,b,E,I,D,j)}return Object.setPrototypeOf&&Object.setPrototypeOf(h,f),h}(e.read),e.readSync=typeof e.readSync!="function"?e.readSync:function(f){return function(h,p,b,E,I){for(var D=0;;)try{return f.call(e,h,p,b,E,I)}catch(A){if(A.code==="EAGAIN"&&D<10){D++;continue}throw A}}}(e.readSync);function t(f){f.lchmod=function(h,p,b){f.open(h,At.O_WRONLY|At.O_SYMLINK,p,function(E,I){if(E){b&&b(E);return}f.fchmod(I,p,function(D){f.close(I,function(A){b&&b(D||A)})})})},f.lchmodSync=function(h,p){var b=f.openSync(h,At.O_WRONLY|At.O_SYMLINK,p),E=!0,I;try{I=f.fchmodSync(b,p),E=!1}finally{if(E)try{f.closeSync(b)}catch{}else f.closeSync(b)}return I}}function r(f){At.hasOwnProperty("O_SYMLINK")&&f.futimes?(f.lutimes=function(h,p,b,E){f.open(h,At.O_SYMLINK,function(I,D){if(I){E&&E(I);return}f.futimes(D,p,b,function(A){f.close(D,function(j){E&&E(A||j)})})})},f.lutimesSync=function(h,p,b){var E=f.openSync(h,At.O_SYMLINK),I,D=!0;try{I=f.futimesSync(E,p,b),D=!1}finally{if(D)try{f.closeSync(E)}catch{}else f.closeSync(E)}return I}):f.futimes&&(f.lutimes=function(h,p,b,E){E&&process.nextTick(E)},f.lutimesSync=function(){})}function n(f){return f&&function(h,p,b){return f.call(e,h,p,function(E){m(E)&&(E=null),b&&b.apply(this,arguments)})}}function o(f){return f&&function(h,p){try{return f.call(e,h,p)}catch(b){if(!m(b))throw b}}}function i(f){return f&&function(h,p,b,E){return f.call(e,h,p,b,function(I){m(I)&&(I=null),E&&E.apply(this,arguments)})}}function s(f){return f&&function(h,p,b){try{return f.call(e,h,p,b)}catch(E){if(!m(E))throw E}}}function a(f){return f&&function(h,p,b){typeof p=="function"&&(b=p,p=null);function E(I,D){D&&(D.uid<0&&(D.uid+=4294967296),D.gid<0&&(D.gid+=4294967296)),b&&b.apply(this,arguments)}return p?f.call(e,h,p,E):f.call(e,h,E)}}function c(f){return f&&function(h,p){var b=p?f.call(e,h,p):f.call(e,h);return b&&(b.uid<0&&(b.uid+=4294967296),b.gid<0&&(b.gid+=4294967296)),b}}function m(f){if(!f||f.code==="ENOSYS")return!0;var h=!process.getuid||process.getuid()!==0;return!!(h&&(f.code==="EINVAL"||f.code==="EPERM"))}}});var _f=T((HF,Df)=>{u();var Of=require("stream").Stream;Df.exports=Bw;function Bw(e){return{ReadStream:t,WriteStream:r};function t(n,o){if(!(this instanceof t))return new t(n,o);Of.call(this);var i=this;this.path=n,this.fd=null,this.readable=!0,this.paused=!1,this.flags="r",this.mode=438,this.bufferSize=64*1024,o=o||{};for(var s=Object.keys(o),a=0,c=s.length;athis.end)throw new Error("start must be <= end");this.pos=this.start}if(this.fd!==null){process.nextTick(function(){i._read()});return}e.open(this.path,this.flags,this.mode,function(f,h){if(f){i.emit("error",f),i.readable=!1;return}i.fd=h,i.emit("open",h),i._read()})}function r(n,o){if(!(this instanceof r))return new r(n,o);Of.call(this),this.path=n,this.fd=null,this.writable=!0,this.flags="w",this.encoding="binary",this.mode=438,this.bytesWritten=0,o=o||{};for(var i=Object.keys(o),s=0,a=i.length;s= zero");this.pos=this.start}this.busy=!1,this._queue=[],this.fd===null&&(this._open=e.open,this._queue.push([this._open,this.path,this.flags,this.mode,void 0]),this.flush())}}});var Nf=T((VF,Tf)=>{"use strict";u();Tf.exports=zw;var Uw=Object.getPrototypeOf||function(e){return e.__proto__};function zw(e){if(e===null||typeof e!="object")return e;if(e instanceof Object)var t={__proto__:Uw(e)};else var t=Object.create(null);return Object.getOwnPropertyNames(e).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))}),t}});var ye=T((ZF,ua)=>{u();var ce=require("fs"),Ww=Sf(),Kw=_f(),Gw=Nf(),ti=require("util"),Se,ni;typeof Symbol=="function"&&typeof Symbol.for=="function"?(Se=Symbol.for("graceful-fs.queue"),ni=Symbol.for("graceful-fs.previous")):(Se="___graceful-fs.queue",ni="___graceful-fs.previous");function Hw(){}function Rf(e,t){Object.defineProperty(e,Se,{get:function(){return t}})}var Yt=Hw;ti.debuglog?Yt=ti.debuglog("gfs4"):/\\bgfs4\\b/i.test(process.env.NODE_DEBUG||"")&&(Yt=function(){var e=ti.format.apply(ti,arguments);e="GFS4: "+e.split(/\\n/).join(`\nGFS4: `),console.error(e)});ce[Se]||(Cf=global[Se]||[],Rf(ce,Cf),ce.close=function(e){function t(r,n){return e.call(ce,r,function(o){o||Af(),typeof n=="function"&&n.apply(this,arguments)})}return Object.defineProperty(t,ni,{value:e}),t}(ce.close),ce.closeSync=function(e){function t(r){e.apply(ce,arguments),Af()}return Object.defineProperty(t,ni,{value:e}),t}(ce.closeSync),/\\bgfs4\\b/i.test(process.env.NODE_DEBUG||"")&&process.on("exit",function(){Yt(ce[Se]),require("assert").equal(ce[Se].length,0)}));var Cf;global[Se]||Rf(global,ce[Se]);ua.exports=sa(Gw(ce));process.env.TEST_GRACEFUL_FS_GLOBAL_PATCH&&!ce.__patched&&(ua.exports=sa(ce),ce.__patched=!0);function sa(e){Ww(e),e.gracefulify=sa,e.createReadStream=Ie,e.createWriteStream=F;var t=e.readFile;e.readFile=r;function r(P,B,_){return typeof B=="function"&&(_=B,B=null),k(P,B,_);function k($,W,L,G){return t($,W,function(H){H&&(H.code==="EMFILE"||H.code==="ENFILE")?Sr([k,[$,W,L],H,G||Date.now(),Date.now()]):typeof L=="function"&&L.apply(this,arguments)})}}var n=e.writeFile;e.writeFile=o;function o(P,B,_,k){return typeof _=="function"&&(k=_,_=null),$(P,B,_,k);function $(W,L,G,H,re){return n(W,L,G,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?Sr([$,[W,L,G,H],Y,re||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var i=e.appendFile;i&&(e.appendFile=s);function s(P,B,_,k){return typeof _=="function"&&(k=_,_=null),$(P,B,_,k);function $(W,L,G,H,re){return i(W,L,G,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?Sr([$,[W,L,G,H],Y,re||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var a=e.copyFile;a&&(e.copyFile=c);function c(P,B,_,k){return typeof _=="function"&&(k=_,_=0),$(P,B,_,k);function $(W,L,G,H,re){return a(W,L,G,function(Y){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?Sr([$,[W,L,G,H],Y,re||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}var m=e.readdir;e.readdir=h;var f=/^v[0-5]\\./;function h(P,B,_){typeof B=="function"&&(_=B,B=null);var k=f.test(process.version)?function(L,G,H,re){return m(L,$(L,G,H,re))}:function(L,G,H,re){return m(L,G,$(L,G,H,re))};return k(P,B,_);function $(W,L,G,H){return function(re,Y){re&&(re.code==="EMFILE"||re.code==="ENFILE")?Sr([k,[W,L,G],re,H||Date.now(),Date.now()]):(Y&&Y.sort&&Y.sort(),typeof G=="function"&&G.call(this,re,Y))}}}if(process.version.substr(0,4)==="v0.8"){var p=Kw(e);A=p.ReadStream,q=p.WriteStream}var b=e.ReadStream;b&&(A.prototype=Object.create(b.prototype),A.prototype.open=j);var E=e.WriteStream;E&&(q.prototype=Object.create(E.prototype),q.prototype.open=ne),Object.defineProperty(e,"ReadStream",{get:function(){return A},set:function(P){A=P},enumerable:!0,configurable:!0}),Object.defineProperty(e,"WriteStream",{get:function(){return q},set:function(P){q=P},enumerable:!0,configurable:!0});var I=A;Object.defineProperty(e,"FileReadStream",{get:function(){return I},set:function(P){I=P},enumerable:!0,configurable:!0});var D=q;Object.defineProperty(e,"FileWriteStream",{get:function(){return D},set:function(P){D=P},enumerable:!0,configurable:!0});function A(P,B){return this instanceof A?(b.apply(this,arguments),this):A.apply(Object.create(A.prototype),arguments)}function j(){var P=this;U(P.path,P.flags,P.mode,function(B,_){B?(P.autoClose&&P.destroy(),P.emit("error",B)):(P.fd=_,P.emit("open",_),P.read())})}function q(P,B){return this instanceof q?(E.apply(this,arguments),this):q.apply(Object.create(q.prototype),arguments)}function ne(){var P=this;U(P.path,P.flags,P.mode,function(B,_){B?(P.destroy(),P.emit("error",B)):(P.fd=_,P.emit("open",_))})}function Ie(P,B){return new e.ReadStream(P,B)}function F(P,B){return new e.WriteStream(P,B)}var z=e.open;e.open=U;function U(P,B,_,k){return typeof _=="function"&&(k=_,_=null),$(P,B,_,k);function $(W,L,G,H,re){return z(W,L,G,function(Y,Qn){Y&&(Y.code==="EMFILE"||Y.code==="ENFILE")?Sr([$,[W,L,G,H],Y,re||Date.now(),Date.now()]):typeof H=="function"&&H.apply(this,arguments)})}}return e}function Sr(e){Yt("ENQUEUE",e[0].name,e[1]),ce[Se].push(e),aa()}var ri;function Af(){for(var e=Date.now(),t=0;t2&&(ce[Se][t][3]=e,ce[Se][t][4]=e);aa()}function aa(){if(clearTimeout(ri),ri=void 0,ce[Se].length!==0){var e=ce[Se].shift(),t=e[0],r=e[1],n=e[2],o=e[3],i=e[4];if(o===void 0)Yt("RETRY",t.name,r),t.apply(null,r);else if(Date.now()-o>=6e4){Yt("TIMEOUT",t.name,r);var s=r.pop();typeof s=="function"&&s.call(null,n)}else{var a=Date.now()-i,c=Math.max(i-o,1),m=Math.min(c*1.2,100);a>=m?(Yt("RETRY",t.name,r),t.apply(null,r.concat([o]))):ce[Se].push(e)}ri===void 0&&(ri=setTimeout(aa,0))}}});var ca=T(Zt=>{"use strict";u();var Ff=Re().fromCallback,Je=ye(),Jw=["access","appendFile","chmod","chown","close","copyFile","fchmod","fchown","fdatasync","fstat","fsync","ftruncate","futimes","lchown","lchmod","link","lstat","mkdir","mkdtemp","open","readFile","readdir","readlink","realpath","rename","rmdir","stat","symlink","truncate","unlink","utimes","writeFile"].filter(e=>typeof Je[e]=="function");Object.keys(Je).forEach(e=>{e!=="promises"&&(Zt[e]=Je[e])});Jw.forEach(e=>{Zt[e]=Ff(Je[e])});Zt.exists=function(e,t){return typeof t=="function"?Je.exists(e,t):new Promise(r=>Je.exists(e,r))};Zt.read=function(e,t,r,n,o,i){return typeof i=="function"?Je.read(e,t,r,n,o,i):new Promise((s,a)=>{Je.read(e,t,r,n,o,(c,m,f)=>{if(c)return a(c);s({bytesRead:m,buffer:f})})})};Zt.write=function(e,t,...r){return typeof r[r.length-1]=="function"?Je.write(e,t,...r):new Promise((n,o)=>{Je.write(e,t,...r,(i,s,a)=>{if(i)return o(i);n({bytesWritten:s,buffer:a})})})};typeof Je.realpath.native=="function"&&(Zt.realpath.native=Ff(Je.realpath.native))});var fa=T((t$,Pf)=>{"use strict";u();var la=require("path");function $f(e){return e=la.normalize(la.resolve(e)).split(la.sep),e.length>0?e[0]:null}var Vw=/[<>:"|?*]/;function Yw(e){let t=$f(e);return e=e.replace(t,""),Vw.test(e)}Pf.exports={getRootPath:$f,invalidWin32Path:Yw}});var Mf=T((n$,kf)=>{"use strict";u();var Zw=ye(),pa=require("path"),Qw=fa().invalidWin32Path,Xw=parseInt("0777",8);function ma(e,t,r,n){if(typeof t=="function"?(r=t,t={}):(!t||typeof t!="object")&&(t={mode:t}),process.platform==="win32"&&Qw(e)){let s=new Error(e+" contains invalid WIN32 path characters.");return s.code="EINVAL",r(s)}let o=t.mode,i=t.fs||Zw;o===void 0&&(o=Xw&~process.umask()),n||(n=null),r=r||function(){},e=pa.resolve(e),i.mkdir(e,o,s=>{if(!s)return n=n||e,r(null,n);switch(s.code){case"ENOENT":if(pa.dirname(e)===e)return r(s);ma(pa.dirname(e),t,(a,c)=>{a?r(a,c):ma(e,t,r,c)});break;default:i.stat(e,(a,c)=>{a||!c.isDirectory()?r(s,n):r(null,n)});break}})}kf.exports=ma});var jf=T((i$,qf)=>{"use strict";u();var ex=ye(),da=require("path"),tx=fa().invalidWin32Path,rx=parseInt("0777",8);function ha(e,t,r){(!t||typeof t!="object")&&(t={mode:t});let n=t.mode,o=t.fs||ex;if(process.platform==="win32"&&tx(e)){let i=new Error(e+" contains invalid WIN32 path characters.");throw i.code="EINVAL",i}n===void 0&&(n=rx&~process.umask()),r||(r=null),e=da.resolve(e);try{o.mkdirSync(e,n),r=r||e}catch(i){if(i.code==="ENOENT"){if(da.dirname(e)===e)throw i;r=ha(da.dirname(e),t,r),ha(e,t,r)}else{let s;try{s=o.statSync(e)}catch{throw i}if(!s.isDirectory())throw i}}return r}qf.exports=ha});var ke=T((a$,Lf)=>{"use strict";u();var nx=Re().fromCallback,ga=nx(Mf()),ya=jf();Lf.exports={mkdirs:ga,mkdirsSync:ya,mkdirp:ga,mkdirpSync:ya,ensureDir:ga,ensureDirSync:ya}});var ba=T((c$,Uf)=>{"use strict";u();var De=ye(),Bf=require("os"),oi=require("path");function ox(){let e=oi.join("millis-test-sync"+Date.now().toString()+Math.random().toString().slice(2));e=oi.join(Bf.tmpdir(),e);let t=new Date(1435410243862);De.writeFileSync(e,"https://github.com/jprichardson/node-fs-extra/pull/141");let r=De.openSync(e,"r+");return De.futimesSync(r,t,t),De.closeSync(r),De.statSync(e).mtime>1435410243e3}function ix(e){let t=oi.join("millis-test"+Date.now().toString()+Math.random().toString().slice(2));t=oi.join(Bf.tmpdir(),t);let r=new Date(1435410243862);De.writeFile(t,"https://github.com/jprichardson/node-fs-extra/pull/141",n=>{if(n)return e(n);De.open(t,"r+",(o,i)=>{if(o)return e(o);De.futimes(i,r,r,s=>{if(s)return e(s);De.close(i,a=>{if(a)return e(a);De.stat(t,(c,m)=>{if(c)return e(c);e(null,m.mtime>1435410243e3)})})})})})}function sx(e){if(typeof e=="number")return Math.floor(e/1e3)*1e3;if(e instanceof Date)return new Date(Math.floor(e.getTime()/1e3)*1e3);throw new Error("fs-extra: timeRemoveMillis() unknown parameter type")}function ax(e,t,r,n){De.open(e,"r+",(o,i)=>{if(o)return n(o);De.futimes(i,t,r,s=>{De.close(i,a=>{n&&n(s||a)})})})}function ux(e,t,r){let n=De.openSync(e,"r+");return De.futimesSync(n,t,r),De.closeSync(n)}Uf.exports={hasMillisRes:ix,hasMillisResSync:ox,timeRemoveMillis:sx,utimesMillis:ax,utimesMillisSync:ux}});var _n=T((f$,Jf)=>{"use strict";u();var Ve=ye(),Fe=require("path"),zf=10,Wf=5,cx=0,wa=process.versions.node.split("."),Kf=Number.parseInt(wa[0],10),Gf=Number.parseInt(wa[1],10),lx=Number.parseInt(wa[2],10);function On(){if(Kf>zf)return!0;if(Kf===zf){if(Gf>Wf)return!0;if(Gf===Wf&&lx>=cx)return!0}return!1}function fx(e,t,r){On()?Ve.stat(e,{bigint:!0},(n,o)=>{if(n)return r(n);Ve.stat(t,{bigint:!0},(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))}):Ve.stat(e,(n,o)=>{if(n)return r(n);Ve.stat(t,(i,s)=>i?i.code==="ENOENT"?r(null,{srcStat:o,destStat:null}):r(i):r(null,{srcStat:o,destStat:s}))})}function px(e,t){let r,n;On()?r=Ve.statSync(e,{bigint:!0}):r=Ve.statSync(e);try{On()?n=Ve.statSync(t,{bigint:!0}):n=Ve.statSync(t)}catch(o){if(o.code==="ENOENT")return{srcStat:r,destStat:null};throw o}return{srcStat:r,destStat:n}}function mx(e,t,r,n){fx(e,t,(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;return a&&a.ino&&a.dev&&a.ino===s.ino&&a.dev===s.dev?n(new Error("Source and destination must not be the same.")):s.isDirectory()&&xa(e,t)?n(new Error(Dn(e,t,r))):n(null,{srcStat:s,destStat:a})})}function dx(e,t,r){let{srcStat:n,destStat:o}=px(e,t);if(o&&o.ino&&o.dev&&o.ino===n.ino&&o.dev===n.dev)throw new Error("Source and destination must not be the same.");if(n.isDirectory()&&xa(e,t))throw new Error(Dn(e,t,r));return{srcStat:n,destStat:o}}function va(e,t,r,n,o){let i=Fe.resolve(Fe.dirname(e)),s=Fe.resolve(Fe.dirname(r));if(s===i||s===Fe.parse(s).root)return o();On()?Ve.stat(s,{bigint:!0},(a,c)=>a?a.code==="ENOENT"?o():o(a):c.ino&&c.dev&&c.ino===t.ino&&c.dev===t.dev?o(new Error(Dn(e,r,n))):va(e,t,s,n,o)):Ve.stat(s,(a,c)=>a?a.code==="ENOENT"?o():o(a):c.ino&&c.dev&&c.ino===t.ino&&c.dev===t.dev?o(new Error(Dn(e,r,n))):va(e,t,s,n,o))}function Hf(e,t,r,n){let o=Fe.resolve(Fe.dirname(e)),i=Fe.resolve(Fe.dirname(r));if(i===o||i===Fe.parse(i).root)return;let s;try{On()?s=Ve.statSync(i,{bigint:!0}):s=Ve.statSync(i)}catch(a){if(a.code==="ENOENT")return;throw a}if(s.ino&&s.dev&&s.ino===t.ino&&s.dev===t.dev)throw new Error(Dn(e,r,n));return Hf(e,t,i,n)}function xa(e,t){let r=Fe.resolve(e).split(Fe.sep).filter(o=>o),n=Fe.resolve(t).split(Fe.sep).filter(o=>o);return r.reduce((o,i,s)=>o&&n[s]===i,!0)}function Dn(e,t,r){return`Cannot ${r} \'${e}\' to a subdirectory of itself, \'${t}\'.`}Jf.exports={checkPaths:mx,checkPathsSync:dx,checkParentPaths:va,checkParentPathsSync:Hf,isSrcSubdir:xa}});var Yf=T((m$,Vf)=>{"use strict";u();Vf.exports=function(e){if(typeof Buffer.allocUnsafe=="function")try{return Buffer.allocUnsafe(e)}catch{return new Buffer(e)}return new Buffer(e)}});var tp=T((h$,ep)=>{"use strict";u();var se=ye(),Tn=require("path"),hx=ke().mkdirsSync,gx=ba().utimesMillisSync,Nn=_n();function yx(e,t,r){typeof r=="function"&&(r={filter:r}),r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`);let{srcStat:n,destStat:o}=Nn.checkPathsSync(e,t,"copy");return Nn.checkParentPathsSync(e,n,t,"copy"),bx(o,e,t,r)}function bx(e,t,r,n){if(n.filter&&!n.filter(t,r))return;let o=Tn.dirname(r);return se.existsSync(o)||hx(o),Zf(e,t,r,n)}function Zf(e,t,r,n){if(!(n.filter&&!n.filter(t,r)))return vx(e,t,r,n)}function vx(e,t,r,n){let i=(n.dereference?se.statSync:se.lstatSync)(t);if(i.isDirectory())return Ix(i,e,t,r,n);if(i.isFile()||i.isCharacterDevice()||i.isBlockDevice())return wx(i,e,t,r,n);if(i.isSymbolicLink())return Dx(e,t,r,n)}function wx(e,t,r,n,o){return t?xx(e,r,n,o):Qf(e,r,n,o)}function xx(e,t,r,n){if(n.overwrite)return se.unlinkSync(r),Qf(e,t,r,n);if(n.errorOnExist)throw new Error(`\'${r}\' already exists`)}function Qf(e,t,r,n){return typeof se.copyFileSync=="function"?(se.copyFileSync(t,r),se.chmodSync(r,e.mode),n.preserveTimestamps?gx(r,e.atime,e.mtime):void 0):Ex(e,t,r,n)}function Ex(e,t,r,n){let i=Yf()(65536),s=se.openSync(t,"r"),a=se.openSync(r,"w",e.mode),c=0;for(;cOx(n,e,t,r))}function Ox(e,t,r,n){let o=Tn.join(t,e),i=Tn.join(r,e),{destStat:s}=Nn.checkPathsSync(o,i,"copy");return Zf(s,o,i,n)}function Dx(e,t,r,n){let o=se.readlinkSync(t);if(n.dereference&&(o=Tn.resolve(process.cwd(),o)),e){let i;try{i=se.readlinkSync(r)}catch(s){if(s.code==="EINVAL"||s.code==="UNKNOWN")return se.symlinkSync(o,r);throw s}if(n.dereference&&(i=Tn.resolve(process.cwd(),i)),Nn.isSrcSubdir(o,i))throw new Error(`Cannot copy \'${o}\' to a subdirectory of itself, \'${i}\'.`);if(se.statSync(r).isDirectory()&&Nn.isSrcSubdir(i,o))throw new Error(`Cannot overwrite \'${i}\' with \'${o}\'.`);return _x(o,r)}else return se.symlinkSync(o,r)}function _x(e,t){return se.unlinkSync(t),se.symlinkSync(e,t)}ep.exports=yx});var Ea=T((y$,rp)=>{"use strict";u();rp.exports={copySync:tp()}});var at=T((v$,op)=>{"use strict";u();var Tx=Re().fromPromise,np=ca();function Nx(e){return np.access(e).then(()=>!0).catch(()=>!1)}op.exports={pathExists:Tx(Nx),pathExistsSync:np.existsSync}});var mp=T((x$,pp)=>{"use strict";u();var Oe=ye(),Cn=require("path"),Cx=ke().mkdirs,Ax=at().pathExists,Rx=ba().utimesMillis,An=_n();function Fx(e,t,r,n){typeof r=="function"&&!n?(n=r,r={}):typeof r=="function"&&(r={filter:r}),n=n||function(){},r=r||{},r.clobber="clobber"in r?!!r.clobber:!0,r.overwrite="overwrite"in r?!!r.overwrite:r.clobber,r.preserveTimestamps&&process.arch==="ia32"&&console.warn(`fs-extra: Using the preserveTimestamps option in 32-bit node is not recommended;\n\n see https://github.com/jprichardson/node-fs-extra/issues/269`),An.checkPaths(e,t,"copy",(o,i)=>{if(o)return n(o);let{srcStat:s,destStat:a}=i;An.checkParentPaths(e,s,t,"copy",c=>c?n(c):r.filter?ap(ip,a,e,t,r,n):ip(a,e,t,r,n))})}function ip(e,t,r,n,o){let i=Cn.dirname(r);Ax(i,(s,a)=>{if(s)return o(s);if(a)return Ia(e,t,r,n,o);Cx(i,c=>c?o(c):Ia(e,t,r,n,o))})}function ap(e,t,r,n,o,i){Promise.resolve(o.filter(r,n)).then(s=>s?e(t,r,n,o,i):i(),s=>i(s))}function Ia(e,t,r,n,o){return n.filter?ap(sp,e,t,r,n,o):sp(e,t,r,n,o)}function sp(e,t,r,n,o){(n.dereference?Oe.stat:Oe.lstat)(t,(s,a)=>{if(s)return o(s);if(a.isDirectory())return Mx(a,e,t,r,n,o);if(a.isFile()||a.isCharacterDevice()||a.isBlockDevice())return $x(a,e,t,r,n,o);if(a.isSymbolicLink())return Lx(e,t,r,n,o)})}function $x(e,t,r,n,o,i){return t?Px(e,r,n,o,i):up(e,r,n,o,i)}function Px(e,t,r,n,o){if(n.overwrite)Oe.unlink(r,i=>i?o(i):up(e,t,r,n,o));else return n.errorOnExist?o(new Error(`\'${r}\' already exists`)):o()}function up(e,t,r,n,o){return typeof Oe.copyFile=="function"?Oe.copyFile(t,r,i=>i?o(i):cp(e,r,n,o)):kx(e,t,r,n,o)}function kx(e,t,r,n,o){let i=Oe.createReadStream(t);i.on("error",s=>o(s)).once("open",()=>{let s=Oe.createWriteStream(r,{mode:e.mode});s.on("error",a=>o(a)).on("open",()=>i.pipe(s)).once("close",()=>cp(e,r,n,o))})}function cp(e,t,r,n){Oe.chmod(t,e.mode,o=>o?n(o):r.preserveTimestamps?Rx(t,e.atime,e.mtime,n):n())}function Mx(e,t,r,n,o,i){return t?t&&!t.isDirectory()?i(new Error(`Cannot overwrite non-directory \'${n}\' with directory \'${r}\'.`)):lp(r,n,o,i):qx(e,r,n,o,i)}function qx(e,t,r,n,o){Oe.mkdir(r,i=>{if(i)return o(i);lp(t,r,n,s=>s?o(s):Oe.chmod(r,e.mode,o))})}function lp(e,t,r,n){Oe.readdir(e,(o,i)=>o?n(o):fp(i,e,t,r,n))}function fp(e,t,r,n,o){let i=e.pop();return i?jx(e,i,t,r,n,o):o()}function jx(e,t,r,n,o,i){let s=Cn.join(r,t),a=Cn.join(n,t);An.checkPaths(s,a,"copy",(c,m)=>{if(c)return i(c);let{destStat:f}=m;Ia(f,s,a,o,h=>h?i(h):fp(e,r,n,o,i))})}function Lx(e,t,r,n,o){Oe.readlink(t,(i,s)=>{if(i)return o(i);if(n.dereference&&(s=Cn.resolve(process.cwd(),s)),e)Oe.readlink(r,(a,c)=>a?a.code==="EINVAL"||a.code==="UNKNOWN"?Oe.symlink(s,r,o):o(a):(n.dereference&&(c=Cn.resolve(process.cwd(),c)),An.isSrcSubdir(s,c)?o(new Error(`Cannot copy \'${s}\' to a subdirectory of itself, \'${c}\'.`)):e.isDirectory()&&An.isSrcSubdir(c,s)?o(new Error(`Cannot overwrite \'${c}\' with \'${s}\'.`)):Bx(s,r,o)));else return Oe.symlink(s,r,o)})}function Bx(e,t,r){Oe.unlink(t,n=>n?r(n):Oe.symlink(e,t,r))}pp.exports=Fx});var Sa=T((I$,dp)=>{"use strict";u();var Ux=Re().fromCallback;dp.exports={copy:Ux(mp())}});var Ip=T((O$,Ep)=>{"use strict";u();var hp=ye(),vp=require("path"),J=require("assert"),Rn=process.platform==="win32";function wp(e){["unlink","chmod","stat","lstat","rmdir","readdir"].forEach(r=>{e[r]=e[r]||hp[r],r=r+"Sync",e[r]=e[r]||hp[r]}),e.maxBusyTries=e.maxBusyTries||3}function Oa(e,t,r){let n=0;typeof t=="function"&&(r=t,t={}),J(e,"rimraf: missing path"),J.strictEqual(typeof e,"string","rimraf: path should be a string"),J.strictEqual(typeof r,"function","rimraf: callback function required"),J(t,"rimraf: invalid options argument provided"),J.strictEqual(typeof t,"object","rimraf: options should be object"),wp(t),gp(e,t,function o(i){if(i){if((i.code==="EBUSY"||i.code==="ENOTEMPTY"||i.code==="EPERM")&&ngp(e,t,o),s)}i.code==="ENOENT"&&(i=null)}r(i)})}function gp(e,t,r){J(e),J(t),J(typeof r=="function"),t.lstat(e,(n,o)=>{if(n&&n.code==="ENOENT")return r(null);if(n&&n.code==="EPERM"&&Rn)return yp(e,t,n,r);if(o&&o.isDirectory())return ii(e,t,n,r);t.unlink(e,i=>{if(i){if(i.code==="ENOENT")return r(null);if(i.code==="EPERM")return Rn?yp(e,t,i,r):ii(e,t,i,r);if(i.code==="EISDIR")return ii(e,t,i,r)}return r(i)})})}function yp(e,t,r,n){J(e),J(t),J(typeof n=="function"),r&&J(r instanceof Error),t.chmod(e,438,o=>{o?n(o.code==="ENOENT"?null:r):t.stat(e,(i,s)=>{i?n(i.code==="ENOENT"?null:r):s.isDirectory()?ii(e,t,r,n):t.unlink(e,n)})})}function bp(e,t,r){let n;J(e),J(t),r&&J(r instanceof Error);try{t.chmodSync(e,438)}catch(o){if(o.code==="ENOENT")return;throw r}try{n=t.statSync(e)}catch(o){if(o.code==="ENOENT")return;throw r}n.isDirectory()?si(e,t,r):t.unlinkSync(e)}function ii(e,t,r,n){J(e),J(t),r&&J(r instanceof Error),J(typeof n=="function"),t.rmdir(e,o=>{o&&(o.code==="ENOTEMPTY"||o.code==="EEXIST"||o.code==="EPERM")?zx(e,t,n):o&&o.code==="ENOTDIR"?n(r):n(o)})}function zx(e,t,r){J(e),J(t),J(typeof r=="function"),t.readdir(e,(n,o)=>{if(n)return r(n);let i=o.length,s;if(i===0)return t.rmdir(e,r);o.forEach(a=>{Oa(vp.join(e,a),t,c=>{if(!s){if(c)return r(s=c);--i===0&&t.rmdir(e,r)}})})})}function xp(e,t){let r;t=t||{},wp(t),J(e,"rimraf: missing path"),J.strictEqual(typeof e,"string","rimraf: path should be a string"),J(t,"rimraf: missing options"),J.strictEqual(typeof t,"object","rimraf: options should be object");try{r=t.lstatSync(e)}catch(n){if(n.code==="ENOENT")return;n.code==="EPERM"&&Rn&&bp(e,t,n)}try{r&&r.isDirectory()?si(e,t,null):t.unlinkSync(e)}catch(n){if(n.code==="ENOENT")return;if(n.code==="EPERM")return Rn?bp(e,t,n):si(e,t,n);if(n.code!=="EISDIR")throw n;si(e,t,n)}}function si(e,t,r){J(e),J(t),r&&J(r instanceof Error);try{t.rmdirSync(e)}catch(n){if(n.code==="ENOTDIR")throw r;if(n.code==="ENOTEMPTY"||n.code==="EEXIST"||n.code==="EPERM")Wx(e,t);else if(n.code!=="ENOENT")throw n}}function Wx(e,t){if(J(e),J(t),t.readdirSync(e).forEach(r=>xp(vp.join(e,r),t)),Rn){let r=Date.now();do try{return t.rmdirSync(e,t)}catch{}while(Date.now()-r<500)}else return t.rmdirSync(e,t)}Ep.exports=Oa;Oa.sync=xp});var Fn=T((_$,Op)=>{"use strict";u();var Kx=Re().fromCallback,Sp=Ip();Op.exports={remove:Kx(Sp),removeSync:Sp.sync}});var Fp=T((N$,Rp)=>{"use strict";u();var Gx=Re().fromCallback,Tp=ye(),Np=require("path"),Cp=ke(),Ap=Fn(),Dp=Gx(function(t,r){r=r||function(){},Tp.readdir(t,(n,o)=>{if(n)return Cp.mkdirs(t,r);o=o.map(s=>Np.join(t,s)),i();function i(){let s=o.pop();if(!s)return r();Ap.remove(s,a=>{if(a)return r(a);i()})}})});function _p(e){let t;try{t=Tp.readdirSync(e)}catch{return Cp.mkdirsSync(e)}t.forEach(r=>{r=Np.join(e,r),Ap.removeSync(r)})}Rp.exports={emptyDirSync:_p,emptydirSync:_p,emptyDir:Dp,emptydir:Dp}});var Mp=T((A$,kp)=>{"use strict";u();var Hx=Re().fromCallback,$p=require("path"),$n=ye(),Pp=ke(),Jx=at().pathExists;function Vx(e,t){function r(){$n.writeFile(e,"",n=>{if(n)return t(n);t()})}$n.stat(e,(n,o)=>{if(!n&&o.isFile())return t();let i=$p.dirname(e);Jx(i,(s,a)=>{if(s)return t(s);if(a)return r();Pp.mkdirs(i,c=>{if(c)return t(c);r()})})})}function Yx(e){let t;try{t=$n.statSync(e)}catch{}if(t&&t.isFile())return;let r=$p.dirname(e);$n.existsSync(r)||Pp.mkdirsSync(r),$n.writeFileSync(e,"")}kp.exports={createFile:Hx(Vx),createFileSync:Yx}});var Up=T((F$,Bp)=>{"use strict";u();var Zx=Re().fromCallback,jp=require("path"),Qt=ye(),Lp=ke(),qp=at().pathExists;function Qx(e,t,r){function n(o,i){Qt.link(o,i,s=>{if(s)return r(s);r(null)})}qp(t,(o,i)=>{if(o)return r(o);if(i)return r(null);Qt.lstat(e,s=>{if(s)return s.message=s.message.replace("lstat","ensureLink"),r(s);let a=jp.dirname(t);qp(a,(c,m)=>{if(c)return r(c);if(m)return n(e,t);Lp.mkdirs(a,f=>{if(f)return r(f);n(e,t)})})})})}function Xx(e,t){if(Qt.existsSync(t))return;try{Qt.lstatSync(e)}catch(i){throw i.message=i.message.replace("lstat","ensureLink"),i}let n=jp.dirname(t);return Qt.existsSync(n)||Lp.mkdirsSync(n),Qt.linkSync(e,t)}Bp.exports={createLink:Zx(Qx),createLinkSync:Xx}});var Wp=T((P$,zp)=>{"use strict";u();var Rt=require("path"),Pn=ye(),e0=at().pathExists;function t0(e,t,r){if(Rt.isAbsolute(e))return Pn.lstat(e,n=>n?(n.message=n.message.replace("lstat","ensureSymlink"),r(n)):r(null,{toCwd:e,toDst:e}));{let n=Rt.dirname(t),o=Rt.join(n,e);return e0(o,(i,s)=>i?r(i):s?r(null,{toCwd:o,toDst:e}):Pn.lstat(e,a=>a?(a.message=a.message.replace("lstat","ensureSymlink"),r(a)):r(null,{toCwd:e,toDst:Rt.relative(n,e)})))}}function r0(e,t){let r;if(Rt.isAbsolute(e)){if(r=Pn.existsSync(e),!r)throw new Error("absolute srcpath does not exist");return{toCwd:e,toDst:e}}else{let n=Rt.dirname(t),o=Rt.join(n,e);if(r=Pn.existsSync(o),r)return{toCwd:o,toDst:e};if(r=Pn.existsSync(e),!r)throw new Error("relative srcpath does not exist");return{toCwd:e,toDst:Rt.relative(n,e)}}}zp.exports={symlinkPaths:t0,symlinkPathsSync:r0}});var Hp=T((M$,Gp)=>{"use strict";u();var Kp=ye();function n0(e,t,r){if(r=typeof t=="function"?t:r,t=typeof t=="function"?!1:t,t)return r(null,t);Kp.lstat(e,(n,o)=>{if(n)return r(null,"file");t=o&&o.isDirectory()?"dir":"file",r(null,t)})}function o0(e,t){let r;if(t)return t;try{r=Kp.lstatSync(e)}catch{return"file"}return r&&r.isDirectory()?"dir":"file"}Gp.exports={symlinkType:n0,symlinkTypeSync:o0}});var em=T((j$,Xp)=>{"use strict";u();var i0=Re().fromCallback,Vp=require("path"),Or=ye(),Yp=ke(),s0=Yp.mkdirs,a0=Yp.mkdirsSync,Zp=Wp(),u0=Zp.symlinkPaths,c0=Zp.symlinkPathsSync,Qp=Hp(),l0=Qp.symlinkType,f0=Qp.symlinkTypeSync,Jp=at().pathExists;function p0(e,t,r,n){n=typeof r=="function"?r:n,r=typeof r=="function"?!1:r,Jp(t,(o,i)=>{if(o)return n(o);if(i)return n(null);u0(e,t,(s,a)=>{if(s)return n(s);e=a.toDst,l0(a.toCwd,r,(c,m)=>{if(c)return n(c);let f=Vp.dirname(t);Jp(f,(h,p)=>{if(h)return n(h);if(p)return Or.symlink(e,t,m,n);s0(f,b=>{if(b)return n(b);Or.symlink(e,t,m,n)})})})})})}function m0(e,t,r){if(Or.existsSync(t))return;let o=c0(e,t);e=o.toDst,r=f0(o.toCwd,r);let i=Vp.dirname(t);return Or.existsSync(i)||a0(i),Or.symlinkSync(e,t,r)}Xp.exports={createSymlink:i0(p0),createSymlinkSync:m0}});var rm=T((B$,tm)=>{"use strict";u();var ai=Mp(),ui=Up(),ci=em();tm.exports={createFile:ai.createFile,createFileSync:ai.createFileSync,ensureFile:ai.createFile,ensureFileSync:ai.createFileSync,createLink:ui.createLink,createLinkSync:ui.createLinkSync,ensureLink:ui.createLink,ensureLinkSync:ui.createLinkSync,createSymlink:ci.createSymlink,createSymlinkSync:ci.createSymlinkSync,ensureSymlink:ci.createSymlink,ensureSymlinkSync:ci.createSymlinkSync}});var sm=T((z$,im)=>{u();var Dr;try{Dr=ye()}catch{Dr=require("fs")}function d0(e,t,r){r==null&&(r=t,t={}),typeof t=="string"&&(t={encoding:t}),t=t||{};var n=t.fs||Dr,o=!0;"throws"in t&&(o=t.throws),n.readFile(e,t,function(i,s){if(i)return r(i);s=om(s);var a;try{a=JSON.parse(s,t?t.reviver:null)}catch(c){return o?(c.message=e+": "+c.message,r(c)):r(null,null)}r(null,a)})}function h0(e,t){t=t||{},typeof t=="string"&&(t={encoding:t});var r=t.fs||Dr,n=!0;"throws"in t&&(n=t.throws);try{var o=r.readFileSync(e,t);return o=om(o),JSON.parse(o,t.reviver)}catch(i){if(n)throw i.message=e+": "+i.message,i;return null}}function nm(e,t){var r,n=`\n`;typeof t=="object"&&t!==null&&(t.spaces&&(r=t.spaces),t.EOL&&(n=t.EOL));var o=JSON.stringify(e,t?t.replacer:null,r);return o.replace(/\\n/g,n)+n}function g0(e,t,r,n){n==null&&(n=r,r={}),r=r||{};var o=r.fs||Dr,i="";try{i=nm(t,r)}catch(s){n&&n(s,null);return}o.writeFile(e,i,r,n)}function y0(e,t,r){r=r||{};var n=r.fs||Dr,o=nm(t,r);return n.writeFileSync(e,o,r)}function om(e){return Buffer.isBuffer(e)&&(e=e.toString("utf8")),e=e.replace(/^\\uFEFF/,""),e}var b0={readFile:d0,readFileSync:h0,writeFile:g0,writeFileSync:y0};im.exports=b0});var fi=T((K$,um)=>{"use strict";u();var am=Re().fromCallback,li=sm();um.exports={readJson:am(li.readFile),readJsonSync:li.readFileSync,writeJson:am(li.writeFile),writeJsonSync:li.writeFileSync}});var fm=T((H$,lm)=>{"use strict";u();var v0=require("path"),w0=ke(),x0=at().pathExists,cm=fi();function E0(e,t,r,n){typeof r=="function"&&(n=r,r={});let o=v0.dirname(e);x0(o,(i,s)=>{if(i)return n(i);if(s)return cm.writeJson(e,t,r,n);w0.mkdirs(o,a=>{if(a)return n(a);cm.writeJson(e,t,r,n)})})}lm.exports=E0});var mm=T((V$,pm)=>{"use strict";u();var I0=ye(),S0=require("path"),O0=ke(),D0=fi();function _0(e,t,r){let n=S0.dirname(e);I0.existsSync(n)||O0.mkdirsSync(n),D0.writeJsonSync(e,t,r)}pm.exports=_0});var hm=T((Z$,dm)=>{"use strict";u();var T0=Re().fromCallback,Te=fi();Te.outputJson=T0(fm());Te.outputJsonSync=mm();Te.outputJSON=Te.outputJson;Te.outputJSONSync=Te.outputJsonSync;Te.writeJSON=Te.writeJson;Te.writeJSONSync=Te.writeJsonSync;Te.readJSON=Te.readJson;Te.readJSONSync=Te.readJsonSync;dm.exports=Te});var xm=T((X$,wm)=>{"use strict";u();var bm=ye(),N0=require("path"),C0=Ea().copySync,vm=Fn().removeSync,A0=ke().mkdirpSync,gm=_n();function R0(e,t,r){r=r||{};let n=r.overwrite||r.clobber||!1,{srcStat:o}=gm.checkPathsSync(e,t,"move");return gm.checkParentPathsSync(e,o,t,"move"),A0(N0.dirname(t)),F0(e,t,n)}function F0(e,t,r){if(r)return vm(t),ym(e,t,r);if(bm.existsSync(t))throw new Error("dest already exists.");return ym(e,t,r)}function ym(e,t,r){try{bm.renameSync(e,t)}catch(n){if(n.code!=="EXDEV")throw n;return $0(e,t,r)}}function $0(e,t,r){return C0(e,t,{overwrite:r,errorOnExist:!0}),vm(e)}wm.exports=R0});var Im=T((tP,Em)=>{"use strict";u();Em.exports={moveSync:xm()}});var Tm=T((nP,_m)=>{"use strict";u();var P0=ye(),k0=require("path"),M0=Sa().copy,Dm=Fn().remove,q0=ke().mkdirp,j0=at().pathExists,Sm=_n();function L0(e,t,r,n){typeof r=="function"&&(n=r,r={});let o=r.overwrite||r.clobber||!1;Sm.checkPaths(e,t,"move",(i,s)=>{if(i)return n(i);let{srcStat:a}=s;Sm.checkParentPaths(e,a,t,"move",c=>{if(c)return n(c);q0(k0.dirname(t),m=>m?n(m):B0(e,t,o,n))})})}function B0(e,t,r,n){if(r)return Dm(t,o=>o?n(o):Om(e,t,r,n));j0(t,(o,i)=>o?n(o):i?n(new Error("dest already exists.")):Om(e,t,r,n))}function Om(e,t,r,n){P0.rename(e,t,o=>o?o.code!=="EXDEV"?n(o):U0(e,t,r,n):n())}function U0(e,t,r,n){M0(e,t,{overwrite:r,errorOnExist:!0},i=>i?n(i):Dm(e,n))}_m.exports=L0});var Cm=T((iP,Nm)=>{"use strict";u();var z0=Re().fromCallback;Nm.exports={move:z0(Tm())}});var $m=T((aP,Fm)=>{"use strict";u();var W0=Re().fromCallback,kn=ye(),Am=require("path"),Rm=ke(),K0=at().pathExists;function G0(e,t,r,n){typeof r=="function"&&(n=r,r="utf8");let o=Am.dirname(e);K0(o,(i,s)=>{if(i)return n(i);if(s)return kn.writeFile(e,t,r,n);Rm.mkdirs(o,a=>{if(a)return n(a);kn.writeFile(e,t,r,n)})})}function H0(e,...t){let r=Am.dirname(e);if(kn.existsSync(r))return kn.writeFileSync(e,...t);Rm.mkdirsSync(r),kn.writeFileSync(e,...t)}Fm.exports={outputFile:W0(G0),outputFileSync:H0}});var _a=T((cP,Da)=>{"use strict";u();Da.exports=Object.assign({},ca(),Ea(),Sa(),Fp(),rm(),hm(),ke(),Im(),Cm(),$m(),at(),Fn());var Pm=require("fs");Object.getOwnPropertyDescriptor(Pm,"promises")&&Object.defineProperty(Da.exports,"promises",{get(){return Pm.promises}})});var Mm=T((fP,km)=>{u();km.exports=()=>new Date});var jm=T((mP,qm)=>{u();var J0=Ee()("streamroller:fileNameFormatter"),V0=require("path"),Y0=".gz",Z0=".";qm.exports=({file:e,keepFileExt:t,needsIndex:r,alwaysIncludeDate:n,compress:o,fileNameSep:i})=>{let s=i||Z0,a=V0.join(e.dir,e.name),c=b=>b+e.ext,m=(b,E,I)=>(r||!I)&&E?b+s+E:b,f=(b,E,I)=>(E>0||n)&&I?b+s+I:b,h=(b,E)=>E&&o?b+Y0:b,p=t?[f,m,c,h]:[c,f,m,h];return({date:b,index:E})=>(J0(`_formatFileName: date=${b}, index=${E}`),p.reduce((I,D)=>D(I,E,b),a))}});var zm=T((hP,Um)=>{u();var Xt=Ee()("streamroller:fileNameParser"),Lm=".gz",Bm=Vo(),Q0=".";Um.exports=({file:e,keepFileExt:t,pattern:r,fileNameSep:n})=>{let o=n||Q0,i=(p,b)=>p.endsWith(Lm)?(Xt("it is gzipped"),b.isCompressed=!0,p.slice(0,-1*Lm.length)):p,s="__NOT_MATCHING__",h=[i,t?p=>p.startsWith(e.name)&&p.endsWith(e.ext)?(Xt("it starts and ends with the right things"),p.slice(e.name.length+1,-1*e.ext.length)):s:p=>p.startsWith(e.base)?(Xt("it starts with the right things"),p.slice(e.base.length+1)):s,r?(p,b)=>{let E=p.split(o),I=E[E.length-1];Xt("items: ",E,", indexStr: ",I);let D=p;I!==void 0&&I.match(/^\\d+$/)?(D=p.slice(0,-1*(I.length+1)),Xt(`dateStr is ${D}`),r&&!D&&(D=I,I="0")):I="0";try{let A=Bm.parse(r,D,new Date(0,0));return Bm.asString(r,A)!==D?p:(b.index=parseInt(I,10),b.date=D,b.timestamp=A.getTime(),"")}catch(A){return Xt(`Problem parsing ${D} as ${r}, error was: `,A),p}}:(p,b)=>p.match(/^\\d+$/)?(Xt("it has an index"),b.index=parseInt(p,10),""):p];return p=>{let b={filename:p,index:0,isCompressed:!1};return h.reduce((I,D)=>D(I,b),p)?null:b}}});var Km=T((yP,Wm)=>{u();var $e=Ee()("streamroller:moveAndMaybeCompressFile"),bt=_a(),X0=require("zlib"),eE=function(e){let t={mode:parseInt("0600",8),compress:!1},r=Object.assign({},t,e);return $e(`_parseOption: moveAndMaybeCompressFile called with option=${JSON.stringify(r)}`),r},tE=async(e,t,r)=>{if(r=eE(r),e===t){$e("moveAndMaybeCompressFile: source and target are the same, not doing anything");return}if(await bt.pathExists(e))if($e(`moveAndMaybeCompressFile: moving file from ${e} to ${t} ${r.compress?"with":"without"} compress`),r.compress)await new Promise((n,o)=>{let i=!1,s=bt.createWriteStream(t,{mode:r.mode,flags:"wx"}).on("open",()=>{i=!0;let a=bt.createReadStream(e).on("open",()=>{a.pipe(X0.createGzip()).pipe(s)}).on("error",c=>{$e(`moveAndMaybeCompressFile: error reading ${e}`,c),s.destroy(c)})}).on("finish",()=>{$e(`moveAndMaybeCompressFile: finished compressing ${t}, deleting ${e}`),bt.unlink(e).then(n).catch(a=>{$e(`moveAndMaybeCompressFile: error deleting ${e}, truncating instead`,a),bt.truncate(e).then(n).catch(c=>{$e(`moveAndMaybeCompressFile: error truncating ${e}`,c),o(c)})})}).on("error",a=>{i?($e(`moveAndMaybeCompressFile: error writing ${t}, deleting`,a),bt.unlink(t).then(()=>{o(a)}).catch(c=>{$e(`moveAndMaybeCompressFile: error deleting ${t}`,c),o(c)})):($e(`moveAndMaybeCompressFile: error creating ${t}`,a),o(a))})}).catch(()=>{});else{$e(`moveAndMaybeCompressFile: renaming ${e} to ${t}`);try{await bt.move(e,t,{overwrite:!0})}catch(n){if($e(`moveAndMaybeCompressFile: error renaming ${e} to ${t}`,n),n.code!=="ENOENT"){$e("moveAndMaybeCompressFile: trying copy+truncate instead");try{await bt.copy(e,t,{overwrite:!0}),await bt.truncate(e)}catch(o){$e("moveAndMaybeCompressFile: error copy+truncate",o)}}}}};Wm.exports=tE});var di=T((vP,Gm)=>{u();var Me=Ee()("streamroller:RollingFileWriteStream"),tr=_a(),er=require("path"),rE=require("os"),pi=Mm(),mi=Vo(),{Writable:nE}=require("stream"),oE=jm(),iE=zm(),sE=Km(),aE=e=>(Me(`deleteFiles: files to delete: ${e}`),Promise.all(e.map(t=>tr.unlink(t).catch(r=>{Me(`deleteFiles: error when unlinking ${t}, ignoring. Error was ${r}`)})))),Ta=class extends nE{constructor(t,r){if(Me(`constructor: creating RollingFileWriteStream. path=${t}`),typeof t!="string"||t.length===0)throw new Error(`Invalid filename: ${t}`);if(t.endsWith(er.sep))throw new Error(`Filename is a directory: ${t}`);t.indexOf(`~${er.sep}`)===0&&(t=t.replace("~",rE.homedir())),super(r),this.options=this._parseOption(r),this.fileObject=er.parse(t),this.fileObject.dir===""&&(this.fileObject=er.parse(er.join(process.cwd(),t))),this.fileFormatter=oE({file:this.fileObject,alwaysIncludeDate:this.options.alwaysIncludePattern,needsIndex:this.options.maxSize 0`);if(n.numBackups||n.numBackups===0){if(n.numBackups<0)throw new Error(`options.numBackups (${n.numBackups}) should be >= 0`);if(n.numBackups>=Number.MAX_SAFE_INTEGER)throw new Error(`options.numBackups (${n.numBackups}) should be < Number.MAX_SAFE_INTEGER`);n.numToKeep=n.numBackups+1}else if(n.numToKeep<=0)throw new Error(`options.numToKeep (${n.numToKeep}) should be > 0`);return Me(`_parseOption: creating stream with option=${JSON.stringify(n)}`),n}_final(t){this.currentFileStream.end("",this.options.encoding,t)}_write(t,r,n){this._shouldRoll().then(()=>{Me(`_write: writing chunk. file=${this.currentFileStream.path} state=${JSON.stringify(this.state)} chunk=${t}`),this.currentFileStream.write(t,r,o=>{this.state.currentSize+=t.length,n(o)})})}async _shouldRoll(){(this._dateChanged()||this._tooBig())&&(Me(`_shouldRoll: rolling because dateChanged? ${this._dateChanged()} or tooBig? ${this._tooBig()}`),await this._roll())}_dateChanged(){return this.state.currentDate&&this.state.currentDate!==mi(this.options.pattern,pi())}_tooBig(){return this.state.currentSize>=this.options.maxSize}_roll(){return Me("_roll: closing the current stream"),new Promise((t,r)=>{this.currentFileStream.end("",this.options.encoding,()=>{this._moveOldFiles().then(t).catch(r)})})}async _moveOldFiles(){let t=await this._getExistingFiles(),r=this.state.currentDate?t.filter(n=>n.date===this.state.currentDate):t;for(let n=r.length;n>=0;n--){Me(`_moveOldFiles: i = ${n}`);let o=this.fileFormatter({date:this.state.currentDate,index:n}),i=this.fileFormatter({date:this.state.currentDate,index:n+1}),s={compress:this.options.compress&&n===0,mode:this.options.mode};await sE(o,i,s)}this.state.currentSize=0,this.state.currentDate=this.state.currentDate?mi(this.options.pattern,pi()):null,Me(`_moveOldFiles: finished rolling files. state=${JSON.stringify(this.state)}`),this._renewWriteStream(),await new Promise((n,o)=>{this.currentFileStream.write("","utf8",()=>{this._clean().then(n).catch(o)})})}async _getExistingFiles(){let t=await tr.readdir(this.fileObject.dir).catch(()=>[]);Me(`_getExistingFiles: files=${t}`);let r=t.map(o=>this.fileNameParser(o)).filter(o=>o),n=o=>(o.timestamp?o.timestamp:pi().getTime())-o.index;return r.sort((o,i)=>n(o)-n(i)),r}_renewWriteStream(){let t=this.fileFormatter({date:this.state.currentDate,index:0}),r=i=>{try{return tr.mkdirSync(i,{recursive:!0})}catch(s){if(s.code==="ENOENT")return r(er.dirname(i)),r(i);if(s.code!=="EEXIST"&&s.code!=="EROFS")throw s;try{if(tr.statSync(i).isDirectory())return i;throw s}catch{throw s}}};r(this.fileObject.dir);let n={flags:this.options.flags,encoding:this.options.encoding,mode:this.options.mode},o=function(i,s,a){return i[a]=i[s],delete i[s],i};tr.appendFileSync(t,"",o({...n},"flags","flag")),this.currentFileStream=tr.createWriteStream(t,n),this.currentFileStream.on("error",i=>{this.emit("error",i)})}async _clean(){let t=await this._getExistingFiles();if(Me(`_clean: numToKeep = ${this.options.numToKeep}, existingFiles = ${t.length}`),Me("_clean: existing files are: ",t),this._tooManyFiles(t.length)){let r=t.slice(0,t.length-this.options.numToKeep).map(n=>er.format({dir:this.fileObject.dir,base:n.filename}));await aE(r)}}_tooManyFiles(t){return this.options.numToKeep>0&&t>this.options.numToKeep}};Gm.exports=Ta});var Jm=T((xP,Hm)=>{u();var uE=di(),Na=class extends uE{constructor(t,r,n,o){o||(o={}),r&&(o.maxSize=r),!o.numBackups&&o.numBackups!==0&&(!n&&n!==0&&(n=1),o.numBackups=n),super(t,o),this.backups=o.numBackups,this.size=this.options.maxSize}get theStream(){return this.currentFileStream}};Hm.exports=Na});var Ym=T((IP,Vm)=>{u();var cE=di(),Ca=class extends cE{constructor(t,r,n){r&&typeof r=="object"&&(n=r,r=null),n||(n={}),r||(r="yyyy-MM-dd"),n.pattern=r,!n.numBackups&&n.numBackups!==0?(!n.daysToKeep&&n.daysToKeep!==0?n.daysToKeep=1:process.emitWarning("options.daysToKeep is deprecated due to the confusion it causes when used together with file size rolling. Please use options.numBackups instead.","DeprecationWarning","streamroller-DEP0001"),n.numBackups=n.daysToKeep):n.daysToKeep=n.numBackups,super(t,n),this.mode=this.options.mode}get theStream(){return this.currentFileStream}};Vm.exports=Ca});var Aa=T((OP,Zm)=>{u();Zm.exports={RollingFileWriteStream:di(),RollingFileStream:Jm(),DateRollingFileStream:Ym()}});var rd=T((_P,td)=>{u();var Qm=Ee()("log4js:file"),Ra=require("path"),lE=Aa(),ed=require("os"),fE=ed.EOL,hi=!1,gi=new Set;function Xm(){gi.forEach(e=>{e.sighupHandler()})}function pE(e,t,r,n,o,i){if(typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(Ra.sep))throw new Error(`Filename is a directory: ${e}`);e=e.replace(new RegExp(`^~(?=${Ra.sep}.+)`),ed.homedir()),e=Ra.normalize(e),n=!n&&n!==0?5:n,Qm("Creating file appender (",e,", ",r,", ",n,", ",o,", ",i,")");function s(m,f,h,p){let b=new lE.RollingFileStream(m,f,h,p);return b.on("error",E=>{console.error("log4js.fileAppender - Writing to file %s, error happened ",m,E)}),b.on("drain",()=>{process.emit("log4js:pause",!1)}),b}let a=s(e,r,n,o),c=function(m){if(a.writable){if(o.removeColor===!0){let f=/\\x1b[[0-9;]*m/g;m.data=m.data.map(h=>typeof h=="string"?h.replace(f,""):h)}a.write(t(m,i)+fE,"utf8")||process.emit("log4js:pause",!0)}};return c.reopen=function(){a.end(()=>{a=s(e,r,n,o)})},c.sighupHandler=function(){Qm("SIGHUP handler called."),c.reopen()},c.shutdown=function(m){gi.delete(c),gi.size===0&&hi&&(process.removeListener("SIGHUP",Xm),hi=!1),a.end("","utf-8",m)},gi.add(c),hi||(process.on("SIGHUP",Xm),hi=!0),c}function mE(e,t){let r=t.basicLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),e.mode=e.mode||384,pE(e.filename,r,e.maxLogSize,e.backups,e,e.timezoneOffset)}td.exports.configure=mE});var od=T((NP,nd)=>{u();var dE=Aa(),hE=require("os"),gE=hE.EOL;function yE(e,t,r){let n=new dE.DateRollingFileStream(e,t,r);return n.on("error",o=>{console.error("log4js.dateFileAppender - Writing to file %s, error happened ",e,o)}),n.on("drain",()=>{process.emit("log4js:pause",!1)}),n}function bE(e,t,r,n,o){n.maxSize=n.maxLogSize;let i=yE(e,t,n),s=function(a){i.writable&&(i.write(r(a,o)+gE,"utf8")||process.emit("log4js:pause",!0))};return s.shutdown=function(a){i.end("","utf-8",a)},s}function vE(e,t){let r=t.basicLayout;return e.layout&&(r=t.layout(e.layout.type,e.layout)),e.alwaysIncludePattern||(e.alwaysIncludePattern=!1),e.mode=e.mode||384,bE(e.filename,e.pattern,r,e,e.timezoneOffset)}nd.exports.configure=vE});var ud=T((AP,ad)=>{u();var vt=Ee()("log4js:fileSync"),ct=require("path"),ut=require("fs"),id=require("os"),wE=id.EOL;function sd(e,t){let r=n=>{try{return ut.mkdirSync(n,{recursive:!0})}catch(o){if(o.code==="ENOENT")return r(ct.dirname(n)),r(n);if(o.code!=="EEXIST"&&o.code!=="EROFS")throw o;try{if(ut.statSync(n).isDirectory())return n;throw o}catch{throw o}}};r(ct.dirname(e)),ut.appendFileSync(e,"",{mode:t.mode,flag:t.flags})}var Fa=class{constructor(t,r,n,o){if(vt("In RollingFileStream"),r<0)throw new Error(`maxLogSize (${r}) should be > 0`);this.filename=t,this.size=r,this.backups=n,this.options=o,this.currentSize=0;function i(s){let a=0;try{a=ut.statSync(s).size}catch{sd(s,o)}return a}this.currentSize=i(this.filename)}shouldRoll(){return vt("should roll with current size %d, and max size %d",this.currentSize,this.size),this.currentSize>=this.size}roll(t){let r=this,n=new RegExp(`^${ct.basename(t)}`);function o(m){return n.test(m)}function i(m){return parseInt(m.slice(`${ct.basename(t)}.`.length),10)||0}function s(m,f){return i(m)-i(f)}function a(m){let f=i(m);if(vt(`Index of ${m} is ${f}`),r.backups===0)ut.truncateSync(t,0);else if(f ${t}.${f+1}`),ut.renameSync(ct.join(ct.dirname(t),m),`${t}.${f+1}`)}}function c(){vt("Renaming the old files"),ut.readdirSync(ct.dirname(t)).filter(o).sort(s).reverse().forEach(a)}vt("Rolling, rolling, rolling"),c()}write(t,r){let n=this;function o(){vt("writing the chunk to the file"),n.currentSize+=t.length,ut.appendFileSync(n.filename,t)}vt("in write"),this.shouldRoll()&&(this.currentSize=0,this.roll(this.filename)),o()}};function xE(e,t,r,n,o,i){if(typeof e!="string"||e.length===0)throw new Error(`Invalid filename: ${e}`);if(e.endsWith(ct.sep))throw new Error(`Filename is a directory: ${e}`);e=e.replace(new RegExp(`^~(?=${ct.sep}.+)`),id.homedir()),e=ct.normalize(e),n=!n&&n!==0?5:n,vt("Creating fileSync appender (",e,", ",r,", ",n,", ",o,", ",i,")");function s(c,m,f){let h;return m?h=new Fa(c,m,f,o):h=(p=>(sd(p,o),{write(b){ut.appendFileSync(p,b)}}))(c),h}let a=s(e,r,n);return c=>{a.write(t(c,i)+wE)}}function EE(e,t){let r=t.basicLayout;e.layout&&(r=t.layout(e.layout.type,e.layout));let n={flags:e.flags||"a",encoding:e.encoding||"utf8",mode:e.mode||384};return xE(e.filename,r,e.maxLogSize,e.backups,n,e.timezoneOffset)}ad.exports.configure=EE});var ld=T((FP,cd)=>{u();var lt=Ee()("log4js:tcp"),IE=require("net");function SE(e,t){let r=!1,n=[],o,i=3,s="__LOG4JS__";function a(h){lt("Writing log event to socket"),r=o.write(`${t(h)}${s}`,"utf8")}function c(){let h;for(lt("emptying buffer");h=n.shift();)a(h)}function m(){lt(`appender creating socket to ${e.host||"localhost"}:${e.port||5e3}`),s=`${e.endMsg||"__LOG4JS__"}`,o=IE.createConnection(e.port||5e3,e.host||"localhost"),o.on("connect",()=>{lt("socket connected"),c(),r=!0}),o.on("drain",()=>{lt("drain event received, emptying buffer"),r=!0,c()}),o.on("timeout",o.end.bind(o)),o.on("error",h=>{lt("connection error",h),r=!1,c()}),o.on("close",m)}m();function f(h){r?a(h):(lt("buffering log event because it cannot write at the moment"),n.push(h))}return f.shutdown=function(h){lt("shutdown called"),n.length&&i?(lt("buffer has items, waiting 100ms to empty"),i-=1,setTimeout(()=>{f.shutdown(h)},100)):(o.removeAllListeners("close"),o.end(h))},f}function OE(e,t){lt(`configure with config = ${e}`);let r=function(n){return n.serialise()};return e.layout&&(r=t.layout(e.layout.type,e.layout)),SE(e,r)}cd.exports.configure=OE});var ka=T((PP,Pa)=>{u();var $a=require("path"),Ft=Ee()("log4js:appenders"),Ye=Ht(),fd=Xo(),DE=Vt(),_E=Xs(),TE=uf(),et=new Map;et.set("console",lf());et.set("stdout",pf());et.set("stderr",df());et.set("logLevelFilter",gf());et.set("categoryFilter",vf());et.set("noLogFilter",Ef());et.set("file",rd());et.set("dateFile",od());et.set("fileSync",ud());et.set("tcp",ld());var Mn=new Map,yi=(e,t)=>{let r;try{let n=`${e}.cjs`;r=require.resolve(n),Ft("Loading module from ",n)}catch{r=e,Ft("Loading module from ",e)}try{return require(r)}catch(n){Ye.throwExceptionIf(t,n.code!=="MODULE_NOT_FOUND",`appender "${e}" could not be loaded (error was: ${n})`);return}},NE=(e,t)=>et.get(e)||yi(`./${e}`,t)||yi(e,t)||require.main&&require.main.filename&&yi($a.join($a.dirname(require.main.filename),e),t)||yi($a.join(process.cwd(),e),t),bi=new Set,pd=(e,t)=>{if(Mn.has(e))return Mn.get(e);if(!t.appenders[e])return!1;if(bi.has(e))throw new Error(`Dependency loop detected for appender ${e}.`);bi.add(e),Ft(`Creating appender ${e}`);let r=CE(e,t);return bi.delete(e),Mn.set(e,r),r},CE=(e,t)=>{let r=t.appenders[e],n=r.type.configure?r.type:NE(r.type,t);return Ye.throwExceptionIf(t,Ye.not(n),`appender "${e}" is not valid (type "${r.type}" could not be found)`),n.appender&&(process.emitWarning(`Appender ${r.type} exports an appender function.`,"DeprecationWarning","log4js-node-DEP0001"),Ft("[log4js-node-DEP0001]",`DEPRECATION: Appender ${r.type} exports an appender function.`)),n.shutdown&&(process.emitWarning(`Appender ${r.type} exports a shutdown function.`,"DeprecationWarning","log4js-node-DEP0002"),Ft("[log4js-node-DEP0002]",`DEPRECATION: Appender ${r.type} exports a shutdown function.`)),Ft(`${e}: clustering.isMaster ? ${fd.isMaster()}`),Ft(`${e}: appenderModule is ${require("util").inspect(n)}`),fd.onlyOnMaster(()=>(Ft(`calling appenderModule.configure for ${e} / ${r.type}`),n.configure(TE.modifyConfig(r),_E,o=>pd(o,t),DE)),()=>{})},md=e=>{if(Mn.clear(),bi.clear(),!e)return;let t=[];Object.values(e.categories).forEach(r=>{t.push(...r.appenders)}),Object.keys(e.appenders).forEach(r=>{(t.includes(r)||e.appenders[r].type==="tcp-server"||e.appenders[r].type==="multiprocess")&&pd(r,e)})},dd=()=>{md()};dd();Ye.addListener(e=>{Ye.throwExceptionIf(e,Ye.not(Ye.anObject(e.appenders)),\'must have a property "appenders" of type object.\');let t=Object.keys(e.appenders);Ye.throwExceptionIf(e,Ye.not(t.length),"must define at least one appender."),t.forEach(r=>{Ye.throwExceptionIf(e,Ye.not(e.appenders[r].type),`appender "${r}" is not valid (must be an object with property "type")`)})});Ye.addListener(md);Pa.exports=Mn;Pa.exports.init=dd});var ja=T((MP,vi)=>{u();var qn=Ee()("log4js:categories"),le=Ht(),Ma=Vt(),hd=ka(),$t=new Map;function gd(e,t,r){if(t.inherit===!1)return;let n=r.lastIndexOf(".");if(n<0)return;let o=r.slice(0,n),i=e.categories[o];i||(i={inherit:!0,appenders:[]}),gd(e,i,o),!e.categories[o]&&i.appenders&&i.appenders.length&&i.level&&(e.categories[o]=i),t.appenders=t.appenders||[],t.level=t.level||i.level,i.appenders.forEach(s=>{t.appenders.includes(s)||t.appenders.push(s)}),t.parent=i}function AE(e){if(!e.categories)return;Object.keys(e.categories).forEach(r=>{let n=e.categories[r];gd(e,n,r)})}le.addPreProcessingListener(e=>AE(e));le.addListener(e=>{le.throwExceptionIf(e,le.not(le.anObject(e.categories)),\'must have a property "categories" of type object.\');let t=Object.keys(e.categories);le.throwExceptionIf(e,le.not(t.length),"must define at least one category."),t.forEach(r=>{let n=e.categories[r];le.throwExceptionIf(e,[le.not(n.appenders),le.not(n.level)],`category "${r}" is not valid (must be an object with properties "appenders" and "level")`),le.throwExceptionIf(e,le.not(Array.isArray(n.appenders)),`category "${r}" is not valid (appenders must be an array of appender names)`),le.throwExceptionIf(e,le.not(n.appenders.length),`category "${r}" is not valid (appenders must contain at least one appender name)`),Object.prototype.hasOwnProperty.call(n,"enableCallStack")&&le.throwExceptionIf(e,typeof n.enableCallStack!="boolean",`category "${r}" is not valid (enableCallStack must be boolean type)`),n.appenders.forEach(o=>{le.throwExceptionIf(e,le.not(hd.get(o)),`category "${r}" is not valid (appender "${o}" is not defined)`)}),le.throwExceptionIf(e,le.not(Ma.getLevel(n.level)),`category "${r}" is not valid (level "${n.level}" not recognised; valid levels are ${Ma.levels.join(", ")})`)}),le.throwExceptionIf(e,le.not(e.categories.default),\'must define a "default" category.\')});var qa=e=>{if($t.clear(),!e)return;Object.keys(e.categories).forEach(r=>{let n=e.categories[r],o=[];n.appenders.forEach(i=>{o.push(hd.get(i)),qn(`Creating category ${r}`),$t.set(r,{appenders:o,level:Ma.getLevel(n.level),enableCallStack:n.enableCallStack||!1})})})},yd=()=>{qa()};yd();le.addListener(qa);var _r=e=>{if(qn(`configForCategory: searching for config for ${e}`),$t.has(e))return qn(`configForCategory: ${e} exists in config, returning it`),$t.get(e);let t;return e.indexOf(".")>0?(qn(`configForCategory: ${e} has hierarchy, cloning from parents`),t={..._r(e.slice(0,e.lastIndexOf(".")))}):($t.has("default")||qa({categories:{default:{appenders:["out"],level:"OFF"}}}),qn("configForCategory: cloning default category"),t={...$t.get("default")}),$t.set(e,t),t},RE=e=>_r(e).appenders,FE=e=>_r(e).level,$E=(e,t)=>{_r(e).level=t},PE=e=>_r(e).enableCallStack===!0,kE=(e,t)=>{_r(e).enableCallStack=t};vi.exports=$t;vi.exports=Object.assign(vi.exports,{appendersForCategory:RE,getLevelForCategory:FE,setLevelForCategory:$E,getEnableCallStackForCategory:PE,setEnableCallStackForCategory:kE,init:yd})});var Ed=T((jP,xd)=>{u();var bd=Ee()("log4js:logger"),ME=ea(),ft=Vt(),qE=Xo(),wi=ja(),vd=Ht(),jE=/at (?:(.+)\\s+\\()?(?:(.+?):(\\d+)(?::(\\d+))?|([^)]+))\\)?/;function LE(e,t=4){try{let r=e.stack.split(`\n`).slice(t),n=jE.exec(r[0]);if(n&&n.length===6)return{functionName:n[1],fileName:n[2],lineNumber:parseInt(n[3],10),columnNumber:parseInt(n[4],10),callStack:r.join(`\n`)};console.error("log4js.logger - defaultParseCallStack error")}catch(r){console.error("log4js.logger - defaultParseCallStack error",r)}return null}var jn=class{constructor(t){if(!t)throw new Error("No category provided.");this.category=t,this.context={},this.parseCallStack=LE,bd(`Logger created (${this.category}, ${this.level})`)}get level(){return ft.getLevel(wi.getLevelForCategory(this.category),ft.OFF)}set level(t){wi.setLevelForCategory(this.category,ft.getLevel(t,this.level))}get useCallStack(){return wi.getEnableCallStackForCategory(this.category)}set useCallStack(t){wi.setEnableCallStackForCategory(this.category,t===!0)}log(t,...r){let n=ft.getLevel(t);n?this.isLevelEnabled(n)&&this._log(n,r):vd.validIdentifier(t)&&r.length>0?(this.log(ft.WARN,"log4js:logger.log: valid log-level not found as first parameter given:",t),this.log(ft.INFO,`[${t}]`,...r)):this.log(ft.INFO,t,...r)}isLevelEnabled(t){return this.level.isLessThanOrEqualTo(t)}_log(t,r){bd(`sending log data (${t}) to appenders`);let n=new ME(this.category,t,r,this.context,this.useCallStack&&this.parseCallStack(new Error));qE.send(n)}addContext(t,r){this.context[t]=r}removeContext(t){delete this.context[t]}clearContext(){this.context={}}setParseCallStackFunction(t){this.parseCallStack=t}};function wd(e){let t=ft.getLevel(e),n=t.toString().toLowerCase().replace(/_([a-z])/g,i=>i[1].toUpperCase()),o=n[0].toUpperCase()+n.slice(1);jn.prototype[`is${o}Enabled`]=function(){return this.isLevelEnabled(t)},jn.prototype[n]=function(...i){this.log(t,...i)}}ft.levels.forEach(wd);vd.addListener(()=>{ft.levels.forEach(wd)});xd.exports=jn});var Od=T((BP,Sd)=>{u();var Tr=Vt(),BE=\':remote-addr - - ":method :url HTTP/:http-version" :status :content-length ":referrer" ":user-agent"\';function UE(e){return e.originalUrl||e.url}function zE(e,t,r){let n=i=>{let s=i.concat();for(let a=0;an.source?n.source:n);t=new RegExp(r.join("|"))}return t}function KE(e,t,r){let n=t;if(r){let o=r.find(i=>{let s=!1;return i.from&&i.to?s=e>=i.from&&e<=i.to:s=i.codes.indexOf(e)!==-1,s});o&&(n=Tr.getLevel(o.level,n))}return n}Sd.exports=function(t,r){typeof r=="string"||typeof r=="function"?r={format:r}:r=r||{};let n=t,o=Tr.getLevel(r.level,Tr.INFO),i=r.format||BE;return(s,a,c)=>{if(s._logging!==void 0)return c();if(typeof r.nolog!="function"){let m=WE(r.nolog);if(m&&m.test(s.originalUrl))return c()}if(n.isLevelEnabled(o)||r.level==="auto"){let m=new Date,{writeHead:f}=a;s._logging=!0,a.writeHead=(b,E)=>{a.writeHead=f,a.writeHead(b,E),a.__statusCode=b,a.__headers=E||{}};let h=!1,p=()=>{if(h)return;if(h=!0,typeof r.nolog=="function"&&r.nolog(s,a)===!0){s._logging=!1;return}a.responseTime=new Date-m,a.statusCode&&r.level==="auto"&&(o=Tr.INFO,a.statusCode>=300&&(o=Tr.WARN),a.statusCode>=400&&(o=Tr.ERROR)),o=KE(a.statusCode,o,r.statusRules);let b=zE(s,a,r.tokens||[]);if(r.context&&n.addContext("res",a),typeof i=="function"){let E=i(s,a,I=>Id(I,b));E&&n.log(o,E)}else n.log(o,Id(i,b));r.context&&n.removeContext("res")};a.on("end",p),a.on("finish",p),a.on("error",p),a.on("close",p)}return c()}}});var Cd=T((zP,Nd)=>{u();var Dd=Ee()("log4js:recording"),xi=[];function GE(){return function(e){Dd(`received logEvent, number of events now ${xi.length+1}`),Dd("log event was ",e),xi.push(e)}}function _d(){return xi.slice()}function Td(){xi.length=0}Nd.exports={configure:GE,replay:_d,playback:_d,reset:Td,erase:Td}});var Md=T((KP,kd)=>{u();var Pt=Ee()("log4js:main"),HE=require("fs"),JE=El()({proto:!0}),VE=Ht(),YE=Xs(),ZE=Vt(),Ad=ka(),Rd=ja(),QE=Ed(),XE=Xo(),eI=Od(),tI=Cd(),Ln=!1;function rI(e){if(!Ln)return;Pt("Received log event ",e),Rd.appendersForCategory(e.categoryName).forEach(r=>{r(e)})}function nI(e){Pt(`Loading configuration from ${e}`);try{return JSON.parse(HE.readFileSync(e,"utf8"))}catch(t){throw new Error(`Problem reading config from file "${e}". Error was ${t.message}`,t)}}function Fd(e){Ln&&$d();let t=e;return typeof t=="string"&&(t=nI(e)),Pt(`Configuration is ${t}`),VE.configure(JE(t)),XE.onMessage(rI),Ln=!0,Pd}function oI(){return tI}function $d(e){Pt("Shutdown called. Disabling all log writing."),Ln=!1;let t=Array.from(Ad.values());Ad.init(),Rd.init();let r=t.reduceRight((s,a)=>a.shutdown?s+1:s,0);if(r===0)return Pt("No appenders with shutdown functions found."),e!==void 0&&e();let n=0,o;Pt(`Found ${r} appenders with shutdown functions.`);function i(s){o=o||s,n+=1,Pt(`Appender shutdowns complete: ${n} / ${r}`),n>=r&&(Pt("All shutdown functions completed."),e&&e(o))}return t.filter(s=>s.shutdown).forEach(s=>s.shutdown(i)),null}function iI(e){return Ln||Fd(process.env.LOG4JS_CONFIG||{appenders:{out:{type:"stdout"}},categories:{default:{appenders:["out"],level:"OFF"}}}),new QE(e||"default")}var Pd={getLogger:iI,configure:Fd,shutdown:$d,connectLogger:eI,levels:ZE,addLayout:YE.addLayout,recording:oI};kd.exports=Pd});var pt=T(Ii=>{"use strict";u();Ii.getBooleanOption=(e,t)=>{let r=!1;if(t in e&&typeof(r=e[t])!="boolean")throw new TypeError(`Expected the "${t}" option to be a boolean`);return r};Ii.cppdb=Symbol();Ii.inspect=Symbol.for("nodejs.util.inspect.custom")});var Ua=T((QP,Ld)=>{"use strict";u();var Ba={value:"SqliteError",writable:!0,enumerable:!1,configurable:!0};function rr(e,t){if(new.target!==rr)return new rr(e,t);if(typeof t!="string")throw new TypeError("Expected second argument to be a string");Error.call(this,e),Ba.value=""+e,Object.defineProperty(this,"message",Ba),Error.captureStackTrace(this,rr),this.code=t}Object.setPrototypeOf(rr,Error);Object.setPrototypeOf(rr.prototype,Error.prototype);Object.defineProperty(rr.prototype,"name",Ba);Ld.exports=rr});var Ud=T((ek,Bd)=>{u();var Si=require("path").sep||"/";Bd.exports=aI;function aI(e){if(typeof e!="string"||e.length<=7||e.substring(0,7)!="file://")throw new TypeError("must pass in a file:// URI to convert to a file path");var t=decodeURI(e.substring(7)),r=t.indexOf("/"),n=t.substring(0,r),o=t.substring(r+1);return n=="localhost"&&(n=""),n&&(n=Si+Si+n),o=o.replace(/^(.+)\\|/,"$1:"),Si=="\\\\"&&(o=o.replace(/\\//g,"\\\\")),/^.+\\:/.test(o)||(o=Si+o),n+o}});var Gd=T((Nr,Kd)=>{u();var za=require("fs"),Di=require("path"),uI=Ud(),Oi=Di.join,cI=Di.dirname,zd=za.accessSync&&function(e){try{za.accessSync(e)}catch{return!1}return!0}||za.existsSync||Di.existsSync,Wd={arrow:process.env.NODE_BINDINGS_ARROW||" \\u2192 ",compiled:process.env.NODE_BINDINGS_COMPILED_DIR||"compiled",platform:process.platform,arch:process.arch,nodePreGyp:"node-v"+process.versions.modules+"-"+process.platform+"-"+process.arch,version:process.versions.node,bindings:"bindings.node",try:[["module_root","build","bindings"],["module_root","build","Debug","bindings"],["module_root","build","Release","bindings"],["module_root","out","Debug","bindings"],["module_root","Debug","bindings"],["module_root","out","Release","bindings"],["module_root","Release","bindings"],["module_root","build","default","bindings"],["module_root","compiled","version","platform","arch","bindings"],["module_root","addon-build","release","install-root","bindings"],["module_root","addon-build","debug","install-root","bindings"],["module_root","addon-build","default","install-root","bindings"],["module_root","lib","binding","nodePreGyp","bindings"]]};function lI(e){typeof e=="string"?e={bindings:e}:e||(e={}),Object.keys(Wd).map(function(c){c in e||(e[c]=Wd[c])}),e.module_root||(e.module_root=Nr.getRoot(Nr.getFileName())),Di.extname(e.bindings)!=".node"&&(e.bindings+=".node");for(var t=typeof __webpack_require__=="function"?__non_webpack_require__:require,r=[],n=0,o=e.try.length,i,s,a;n{"use strict";u();var{cppdb:tt}=pt();kt.prepare=function(t){return this[tt].prepare(t,this,!1)};kt.exec=function(t){return this[tt].exec(t),this};kt.close=function(){return this[tt].close(),this};kt.loadExtension=function(...t){return this[tt].loadExtension(...t),this};kt.defaultSafeIntegers=function(...t){return this[tt].defaultSafeIntegers(...t),this};kt.unsafeMode=function(...t){return this[tt].unsafeMode(...t),this};kt.getters={name:{get:function(){return this[tt].name},enumerable:!0},open:{get:function(){return this[tt].open},enumerable:!0},inTransaction:{get:function(){return this[tt].inTransaction},enumerable:!0},readonly:{get:function(){return this[tt].readonly},enumerable:!0},memory:{get:function(){return this[tt].memory},enumerable:!0}}});var Yd=T((ik,Vd)=>{"use strict";u();var{cppdb:fI}=pt(),Jd=new WeakMap;Vd.exports=function(t){if(typeof t!="function")throw new TypeError("Expected first argument to be a function");let r=this[fI],n=pI(r,this),{apply:o}=Function.prototype,i={default:{value:_i(o,t,r,n.default)},deferred:{value:_i(o,t,r,n.deferred)},immediate:{value:_i(o,t,r,n.immediate)},exclusive:{value:_i(o,t,r,n.exclusive)},database:{value:this,enumerable:!0}};return Object.defineProperties(i.default.value,i),Object.defineProperties(i.deferred.value,i),Object.defineProperties(i.immediate.value,i),Object.defineProperties(i.exclusive.value,i),i.default.value};var pI=(e,t)=>{let r=Jd.get(e);if(!r){let n={commit:e.prepare("COMMIT",t,!1),rollback:e.prepare("ROLLBACK",t,!1),savepoint:e.prepare("SAVEPOINT ` _bs3. `",t,!1),release:e.prepare("RELEASE ` _bs3. `",t,!1),rollbackTo:e.prepare("ROLLBACK TO ` _bs3. `",t,!1)};Jd.set(e,r={default:Object.assign({begin:e.prepare("BEGIN",t,!1)},n),deferred:Object.assign({begin:e.prepare("BEGIN DEFERRED",t,!1)},n),immediate:Object.assign({begin:e.prepare("BEGIN IMMEDIATE",t,!1)},n),exclusive:Object.assign({begin:e.prepare("BEGIN EXCLUSIVE",t,!1)},n)})}return r},_i=(e,t,r,{begin:n,commit:o,rollback:i,savepoint:s,release:a,rollbackTo:c})=>function(){let f,h,p;r.inTransaction?(f=s,h=a,p=c):(f=n,h=o,p=i),f.run();try{let b=e.call(t,this,arguments);if(b&&typeof b.then=="function")throw new TypeError("Transaction function cannot return a promise");return h.run(),b}catch(b){throw r.inTransaction&&(p.run(),p!==i&&h.run()),b}}});var Qd=T((ak,Zd)=>{"use strict";u();var{getBooleanOption:mI,cppdb:dI}=pt();Zd.exports=function(t,r){if(r==null&&(r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");let n=mI(r,"simple"),o=this[dI].prepare(`PRAGMA ${t}`,this,!0);return n?o.pluck().get():o.all()}});var th=T((ck,eh)=>{"use strict";u();var hI=require("fs"),gI=require("path"),{promisify:yI}=require("util"),{cppdb:bI}=pt(),Xd=yI(hI.access);eh.exports=async function(t,r){if(r==null&&(r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");t=t.trim();let n="attached"in r?r.attached:"main",o="progress"in r?r.progress:null;if(!t)throw new TypeError("Backup filename cannot be an empty string");if(t===":memory:")throw new TypeError(\'Invalid backup filename ":memory:"\');if(typeof n!="string")throw new TypeError(\'Expected the "attached" option to be a string\');if(!n)throw new TypeError(\'The "attached" option cannot be an empty string\');if(o!=null&&typeof o!="function")throw new TypeError(\'Expected the "progress" option to be a function\');await Xd(gI.dirname(t)).catch(()=>{throw new TypeError("Cannot save backup because the directory does not exist")});let i=await Xd(t).then(()=>!1,()=>!0);return vI(this[bI].backup(this,n,t,i),o||null)};var vI=(e,t)=>{let r=0,n=!0;return new Promise((o,i)=>{setImmediate(function s(){try{let a=e.transfer(r);if(!a.remainingPages){e.close(),o(a);return}if(n&&(n=!1,r=100),t){let c=t(a);if(c!==void 0)if(typeof c=="number"&&c===c)r=Math.max(0,Math.min(2147483647,Math.round(c)));else throw new TypeError("Expected progress callback to return a number or undefined")}setImmediate(s)}catch(a){e.close(),i(a)}})})}});var nh=T((fk,rh)=>{"use strict";u();var{cppdb:wI}=pt();rh.exports=function(t){if(t==null&&(t={}),typeof t!="object")throw new TypeError("Expected first argument to be an options object");let r="attached"in t?t.attached:"main";if(typeof r!="string")throw new TypeError(\'Expected the "attached" option to be a string\');if(!r)throw new TypeError(\'The "attached" option cannot be an empty string\');return this[wI].serialize(r)}});var ih=T((mk,oh)=>{"use strict";u();var{getBooleanOption:Ti,cppdb:xI}=pt();oh.exports=function(t,r,n){if(r==null&&(r={}),typeof r=="function"&&(n=r,r={}),typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof n!="function")throw new TypeError("Expected last argument to be a function");if(typeof r!="object")throw new TypeError("Expected second argument to be an options object");if(!t)throw new TypeError("User-defined function name cannot be an empty string");let o="safeIntegers"in r?+Ti(r,"safeIntegers"):2,i=Ti(r,"deterministic"),s=Ti(r,"directOnly"),a=Ti(r,"varargs"),c=-1;if(!a){if(c=n.length,!Number.isInteger(c)||c<0)throw new TypeError("Expected function.length to be a positive integer");if(c>100)throw new RangeError("User-defined functions cannot have more than 100 arguments")}return this[xI].function(n,t,c,o,i,s),this}});var uh=T((hk,ah)=>{"use strict";u();var{getBooleanOption:Ni,cppdb:EI}=pt();ah.exports=function(t,r){if(typeof t!="string")throw new TypeError("Expected first argument to be a string");if(typeof r!="object"||r===null)throw new TypeError("Expected second argument to be an options object");if(!t)throw new TypeError("User-defined function name cannot be an empty string");let n="start"in r?r.start:null,o=Wa(r,"step",!0),i=Wa(r,"inverse",!1),s=Wa(r,"result",!1),a="safeIntegers"in r?+Ni(r,"safeIntegers"):2,c=Ni(r,"deterministic"),m=Ni(r,"directOnly"),f=Ni(r,"varargs"),h=-1;if(!f&&(h=Math.max(sh(o),i?sh(i):0),h>0&&(h-=1),h>100))throw new RangeError("User-defined functions cannot have more than 100 arguments");return this[EI].aggregate(n,o,i,s,t,h,a,c,m),this};var Wa=(e,t,r)=>{let n=t in e?e[t]:null;if(typeof n=="function")return n;if(n!=null)throw new TypeError(`Expected the "${t}" option to be a function`);if(r)throw new TypeError(`Missing required option "${t}"`);return null},sh=({length:e})=>{if(Number.isInteger(e)&&e>=0)return e;throw new TypeError("Expected function.length to be a positive integer")}});var ph=T((yk,fh)=>{"use strict";u();var{cppdb:II}=pt();fh.exports=function(t,r){if(typeof t!="string")throw new TypeError("Expected first argument to be a string");if(!t)throw new TypeError("Virtual table module name cannot be an empty string");let n=!1;if(typeof r=="object"&&r!==null)n=!0,r=AI(lh(r,"used",t));else{if(typeof r!="function")throw new TypeError("Expected second argument to be a function or a table definition object");r=SI(r)}return this[II].table(r,t,n),this};function SI(e){return function(r,n,o,...i){let s={module:r,database:n,table:o},a=NI.call(e,s,i);if(typeof a!="object"||a===null)throw new TypeError(`Virtual table module "${r}" did not return a table definition object`);return lh(a,"returned",r)}}function lh(e,t,r){if(!Bn.call(e,"rows"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition without a "rows" property`);if(!Bn.call(e,"columns"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition without a "columns" property`);let n=e.rows;if(typeof n!="function"||Object.getPrototypeOf(n)!==CI)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "rows" property (should be a generator function)`);let o=e.columns;if(!Array.isArray(o)||!(o=[...o]).every(m=>typeof m=="string"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "columns" property (should be an array of strings)`);if(o.length!==new Set(o).size)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with duplicate column names`);if(!o.length)throw new RangeError(`Virtual table module "${r}" ${t} a table definition with zero columns`);let i;if(Bn.call(e,"parameters")){if(i=e.parameters,!Array.isArray(i)||!(i=[...i]).every(m=>typeof m=="string"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "parameters" property (should be an array of strings)`)}else i=TI(n);if(i.length!==new Set(i).size)throw new TypeError(`Virtual table module "${r}" ${t} a table definition with duplicate parameter names`);if(i.length>32)throw new RangeError(`Virtual table module "${r}" ${t} a table definition with more than the maximum number of 32 parameters`);for(let m of i)if(o.includes(m))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with column "${m}" which was ambiguously defined as both a column and parameter`);let s=2;if(Bn.call(e,"safeIntegers")){let m=e.safeIntegers;if(typeof m!="boolean")throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "safeIntegers" property (should be a boolean)`);s=+m}let a=!1;if(Bn.call(e,"directOnly")&&(a=e.directOnly,typeof a!="boolean"))throw new TypeError(`Virtual table module "${r}" ${t} a table definition with an invalid "directOnly" property (should be a boolean)`);return[`CREATE TABLE x(${[...i.map(ch).map(m=>`${m} HIDDEN`),...o.map(ch)].join(", ")});`,OI(n,new Map(o.map((m,f)=>[m,i.length+f])),r),i,s,a]}function OI(e,t,r){return function*(...o){let i=o.map(s=>Buffer.isBuffer(s)?Buffer.from(s):s);for(let s=0;s`"${e.replace(/"/g,\'""\')}"`,AI=e=>()=>e});var dh=T((vk,mh)=>{"use strict";u();var RI=function(){};mh.exports=function(t,r){return Object.assign(new RI,this)}});var bh=T((xk,yh)=>{"use strict";u();var FI=require("fs"),hh=require("path"),Ci=pt(),$I=Ua(),gh;function _e(e,t){if(new.target==null)return new _e(e,t);let r;if(Buffer.isBuffer(e)&&(r=e,e=":memory:"),e==null&&(e=""),t==null&&(t={}),typeof e!="string")throw new TypeError("Expected first argument to be a string");if(typeof t!="object")throw new TypeError("Expected second argument to be an options object");if("readOnly"in t)throw new TypeError(\'Misspelled option "readOnly" should be "readonly"\');if("memory"in t)throw new TypeError(\'Option "memory" was removed in v7.0.0 (use ":memory:" filename instead)\');let n=e.trim(),o=n===""||n===":memory:",i=Ci.getBooleanOption(t,"readonly"),s=Ci.getBooleanOption(t,"fileMustExist"),a="timeout"in t?t.timeout:5e3,c="verbose"in t?t.verbose:null,m="nativeBinding"in t?t.nativeBinding:null;if(i&&o&&!r)throw new TypeError("In-memory/temporary databases cannot be readonly");if(!Number.isInteger(a)||a<0)throw new TypeError(\'Expected the "timeout" option to be a positive integer\');if(a>2147483647)throw new RangeError(\'Option "timeout" cannot be greater than 2147483647\');if(c!=null&&typeof c!="function")throw new TypeError(\'Expected the "verbose" option to be a function\');if(m!=null&&typeof m!="string"&&typeof m!="object")throw new TypeError(\'Expected the "nativeBinding" option to be a string or addon object\');let f;if(m==null?f=gh||(gh=Gd()("better_sqlite3.node")):typeof m=="string"?f=(typeof __non_webpack_require__=="function"?__non_webpack_require__:require)(hh.resolve(m).replace(/(\\.node)?$/,".node")):f=m,f.isInitialized||(f.setErrorConstructor($I),f.isInitialized=!0),!o&&!n.startsWith("file:")&&!FI.existsSync(hh.dirname(n)))throw new TypeError("Cannot open database because the directory does not exist");Object.defineProperties(this,{[Ci.cppdb]:{value:new f.Database(n,e,o,i,s,a,c||null,r||null)},...nr.getters})}var nr=Hd();_e.prototype.prepare=nr.prepare;_e.prototype.transaction=Yd();_e.prototype.pragma=Qd();_e.prototype.backup=th();_e.prototype.serialize=nh();_e.prototype.function=ih();_e.prototype.aggregate=uh();_e.prototype.table=ph();_e.prototype.loadExtension=nr.loadExtension;_e.prototype.exec=nr.exec;_e.prototype.close=nr.close;_e.prototype.defaultSafeIntegers=nr.defaultSafeIntegers;_e.prototype.unsafeMode=nr.unsafeMode;_e.prototype[Ci.inspect]=dh();yh.exports=_e});var vh=T((Ik,Ka)=>{"use strict";u();Ka.exports=bh();Ka.exports.SqliteError=Ua()});var Ih=T(Ri=>{"use strict";u();Object.defineProperty(Ri,"__esModule",{value:!0});function Eh(e,t){if(t)return e;throw new Error("Unhandled discriminated union member: "+JSON.stringify(e))}Ri.assertNever=Eh;Ri.default=Eh});u();u();u();u();u();u();u();u();u();var es=class extends Error{},oe=e=>{throw new es(e)},ts=class extends Error{},te=e=>{throw new ts(e)};u();u();var It=(e,t)=>pe(e)===t,pe=e=>{let t=typeof e;return t==="object"?e===null?"null":"object":t==="function"?"object":t},rs={bigint:"a bigint",boolean:"boolean",null:"null",number:"a number",object:"an object",string:"a string",symbol:"a symbol",undefined:"undefined"};var je=(e,t)=>e in t,Su=e=>Object.entries(e),ie=e=>Object.keys(e),Mt=e=>{let t=[];for(;e!==Object.prototype&&e!==null&&e!==void 0;){for(let r of Object.getOwnPropertyNames(e))t.includes(r)||t.push(r);for(let r of Object.getOwnPropertySymbols(e))t.includes(r)||t.push(r);e=Object.getPrototypeOf(e)}return t},ar=(e,t)=>{let r=e?.[t];return r!=null};var Ou=e=>Object.keys(e).length,Mr=e=>It(e,"object")?Object.keys(e).length!==0:!1,cS=Symbol("id");var rt=e=>Array.isArray(e)?e:[e];u();var be=class extends Array{static fromString(t,r="/"){return t===r?new be:new be(...t.split(r))}toString(t="/"){return this.length?this.join(t):t}},Du=(e,t)=>{let r=e;for(let n of t){if(typeof r!="object"||r===null)return;r=r[n]}return r};u();u();var ns=/^(?!^-0$)-?(?:0|[1-9]\\d*)(?:\\.\\d*[1-9])?$/,ay=e=>ns.test(e),uy=/^-?\\d*\\.?\\d*$/,cy=e=>e.length!==0&&uy.test(e),to=/^(?:0|(?:-?[1-9]\\d*))$/,qr=e=>to.test(e),jr=/^(?:0|(?:[1-9]\\d*))$/,_u=/^-?\\d+$/,ly=e=>_u.test(e),Tu={number:"a number",bigint:"a bigint",integer:"an integer"},Nu=(e,t)=>`\'${e}\' was parsed as ${Tu[t]} but could not be narrowed to a literal value. Avoid unnecessary leading or trailing zeros and other abnormal notation`,fy=(e,t)=>t==="number"?ay(e):qr(e),py=(e,t)=>t==="number"?Number(e):Number.parseInt(e),my=(e,t)=>t==="number"?cy(e):ly(e),Lr=(e,t)=>Cu(e,"number",t),ro=(e,t)=>Cu(e,"integer",t),Cu=(e,t,r)=>{let n=py(e,t);if(!Number.isNaN(n)){if(fy(e,t))return n;if(my(e,t))return te(Nu(e,t))}return r?te(r===!0?`Failed to parse ${Tu[t]} from \'${e}\'`:r):void 0},os=e=>{if(e[e.length-1]!=="n")return;let t=e.slice(0,-1),r;try{r=BigInt(t)}catch{return}if(to.test(t))return r;if(_u.test(t))return te(Nu(e,"bigint"))};var ae=(e,t)=>{switch(pe(e)){case"object":return JSON.stringify(is(e,no,[]),null,t);case"symbol":return no.onSymbol(e);default:return ss(e)}},no={onCycle:()=>"(cycle)",onSymbol:e=>`(symbol${e.description&&` ${e.description}`})`,onFunction:e=>`(function${e.name&&` ${e.name}`})`},is=(e,t,r)=>{switch(pe(e)){case"object":if(typeof e=="function")return no.onFunction(e);if(r.includes(e))return"(cycle)";let n=[...r,e];if(Array.isArray(e))return e.map(i=>is(i,t,n));let o={};for(let i in e)o[i]=is(e[i],t,n);return o;case"symbol":return no.onSymbol(e);case"bigint":return`${e}n`;case"undefined":return"undefined";default:return e}},ss=e=>typeof e=="string"?`\'${e}\'`:typeof e=="bigint"?`${e}n`:`${e}`;function dy(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function hy(e,t){return t.get?t.get.call(e):t.value}function gy(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function Ru(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function Au(e,t){var r=Ru(e,t,"get");return hy(e,r)}function yy(e,t,r){dy(e,t),t.set(e,r)}function by(e,t,r){var n=Ru(e,t,"set");return gy(e,n,r),r}function oo(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Le=e=>(t,r,n)=>t===void 0?r===void 0?oe(ao):r:r===void 0?t:e(t,r,n),ao="Unexpected operation two undefined operands",as={domain:({l:e,r:t})=>`${e.join(", ")} and ${t.join(", ")}`,range:({l:e,r:t})=>`${so(e)} and ${so(t)}`,class:({l:e,r:t})=>`classes ${typeof e=="string"?e:e.name} and ${typeof t=="string"?t:t.name}`,tupleLength:({l:e,r:t})=>`tuples of length ${e} and ${t}`,value:({l:e,r:t})=>`literal values ${ae(e)} and ${ae(t)}`,leftAssignability:({l:e,r:t})=>`literal value ${ae(e.value)} and ${ae(t)}`,rightAssignability:({l:e,r:t})=>`literal value ${ae(t.value)} and ${ae(e)}`,union:({l:e,r:t})=>`branches ${ae(e)} and branches ${ae(t)}`},so=e=>"limit"in e?`the range of exactly ${e.limit}`:e.min?e.max?`the range bounded by ${e.min.comparator}${e.min.limit} and ${e.max.comparator}${e.max.limit}`:`${e.min.comparator}${e.min.limit}`:e.max?`${e.max.comparator}${e.max.limit}`:"the unbounded range",io=new WeakMap,St=class{get disjoints(){return Au(this,io)}addDisjoint(t,r,n){return Au(this,io)[`${this.path}`]={kind:t,l:r,r:n},uo}constructor(t,r){oo(this,"type",void 0),oo(this,"lastOperator",void 0),oo(this,"path",void 0),oo(this,"domain",void 0),yy(this,io,{writable:!0,value:void 0}),this.type=t,this.lastOperator=r,this.path=new be,by(this,io,{})}},uo=Symbol("empty"),Fu=()=>uo,Qe=e=>e===uo,$u=Symbol("equal"),ve=()=>$u,Be=e=>e===$u,ur=(e,t)=>(r,n,o)=>{let i={},s=ie({...r,...n}),a=!0,c=!0;for(let m of s){let f=typeof e=="function"?e(m,r[m],n[m],o):e[m](r[m],n[m],o);if(Be(f))r[m]!==void 0&&(i[m]=r[m]);else if(Qe(f))if(t.onEmpty==="omit")a=!1,c=!1;else return uo;else f!==void 0&&(i[m]=f),a&&(a=f===r[m]),c&&(c=f===n[m])}return a?c?ve():r:c?n:i};var Pu=e=>{let t=ie(e);if(t.length===1){let n=t[0];return`${n==="/"?"":`At ${n}: `}Intersection of ${as[e[n].kind](e[n])} results in an unsatisfiable type`}let r=`\n "Intersection results in unsatisfiable types at the following paths:\n`;for(let n in e)r+=` ${n}: ${as[e[n].kind](e[n])}\n`;return r},co=(e,t,r)=>`${e.length?`At ${e}: `:""}${t} ${r?`${r} `:""}results in an unsatisfiable type`;u();u();var Br={Array,Date,Error,Function,Map,RegExp,Set,Object,String,Number,Boolean,WeakMap,WeakSet,Promise},cr=(e,t)=>{if(pe(e)!=="object")return;let r=t??Br,n=Object.getPrototypeOf(e);for(;n?.constructor&&(!r[n.constructor.name]||!(e instanceof r[n.constructor.name]));)n=Object.getPrototypeOf(n);return n?.constructor?.name};var Ot=e=>Array.isArray(e),us={Object:"an object",Array:"an array",Function:"a function",Date:"a Date",RegExp:"a RegExp",Error:"an Error",Map:"a Map",Set:"a Set",String:"a String object",Number:"a Number object",Boolean:"a Boolean object",Promise:"a Promise",WeakMap:"a WeakMap",WeakSet:"a WeakSet"},lo=e=>{let t=Object(e).name;return t&&je(t,Br)&&Br[t]===e?t:void 0};u();u();u();var ku=Le((e,t,r)=>e===t?ve():e instanceof t?e:t instanceof e?t:r.addDisjoint("class",e,t)),Mu=(e,t)=>typeof e=="string"?cr(t.data)===e||!t.problems.add("class",e):t.data instanceof e||!t.problems.add("class",e);u();var fo=(e,t)=>{if(Array.isArray(e)){if(Array.isArray(t)){let r=vy(e,t);return r.length===e.length?r.length===t.length?ve():e:r.length===t.length?t:r}return e.includes(t)?e:[...e,t]}return Array.isArray(t)?t.includes(e)?t:[...t,e]:e===t?ve():[e,t]},vy=(e,t)=>{let r=[...e];for(let n of t)e.includes(n)||r.push(n);return r};u();var qu=Le((e,t)=>e===t?ve():Math.abs(e*t/wy(e,t))),wy=(e,t)=>{let r,n=e,o=t;for(;o!==0;)r=o,o=n%o,n=r;return n},ju=(e,t)=>t.data%e===0||!t.problems.add("divisor",e);u();var Ur=e=>e[0]==="?",po=e=>e[0]==="!",ot={index:"[index]"},Dt=e=>Ur(e)||po(e)?e[1]:e,xy=e=>{if(typeof e.length=="object"&&po(e.length)&&typeof e.length[1]!="string"&&ho(e.length[1],"number"))return e.length[1].number.value},Lu=Le((e,t,r)=>{let n=Ey(e,t,r);if(typeof n=="symbol")return n;let o=xy(n);if(o===void 0||!(ot.index in n))return n;let{[ot.index]:i,...s}=n,a=Dt(i);for(let c=0;c{if(t===void 0)return r===void 0?ve():r;if(r===void 0)return t;n.path.push(e);let o=mo(Dt(t),Dt(r),n);n.path.pop();let i=Ur(t)&&Ur(r);return Qe(o)&&i?{}:o},{onEmpty:"bubble"}),Bu=(e,t,r)=>{let n=r.type.config?.keys??r.type.scope.config.keys;return n==="loose"?Iy(e,t,r):Sy(n,e,t,r)},Iy=(e,t,r)=>{for(let n in t){let o=t[n];r.path.push(n),n===ot.index?e.push(["indexProp",nt(Dt(o),r)]):Ur(o)?e.push(["optionalProp",[n,nt(o[1],r)]]):po(o)?e.push(["prerequisiteProp",[n,nt(o[1],r)]]):e.push(["requiredProp",[n,nt(o,r)]]),r.path.pop()}},Sy=(e,t,r,n)=>{let o={required:{},optional:{}};for(let i in r){let s=r[i];n.path.push(i),i===ot.index?o.index=nt(Dt(s),n):Ur(s)?o.optional[i]=nt(s[1],n):po(s)?t.push(["prerequisiteProp",[i,nt(s[1],n)]]):o.required[i]=nt(s,n),n.path.pop()}t.push([`${e}Props`,o])};u();u();function Oy(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var cs=e=>typeof e=="string"||Array.isArray(e)?e.length:typeof e=="number"?e:0,Dy=e=>typeof e=="string"?"characters":Array.isArray(e)?"items long":"",go=class{toString(){return ae(this.value)}get domain(){return pe(this.value)}get size(){return cs(this.value)}get units(){return Dy(this.value)}get className(){return Object(this.value).constructor.name}constructor(t){Oy(this,"value",void 0),this.value=t}};var yo={">":!0,">=":!0},ls={"<":!0,"<=":!0},zr=e=>"comparator"in e,zu=Le((e,t,r)=>{if(zr(e))return zr(t)?e.limit===t.limit?ve():r.addDisjoint("range",e,t):Uu(t,e.limit)?e:r.addDisjoint("range",e,t);if(zr(t))return Uu(e,t.limit)?t:r.addDisjoint("range",e,t);let n=lr("min",e.min,t.min),o=lr("max",e.max,t.max);return n==="l"?o==="r"?lr("min",e.min,t.max)==="l"?r.addDisjoint("range",e,t):{min:e.min,max:t.max}:e:n==="r"?o==="l"?lr("max",e.max,t.min)==="l"?r.addDisjoint("range",e,t):{min:t.min,max:e.max}:t:o==="l"?e:o==="r"?t:ve()}),Uu=(e,t)=>zr(e)?t===e.limit:_y(e.min,t)&&Ty(e.max,t),_y=(e,t)=>!e||t>e.limit||t===e.limit&&!Wr(e.comparator),Ty=(e,t)=>!e||t{let n=r.lastDomain==="string"?"characters":r.lastDomain==="object"?"items long":void 0;if(zr(t))return e.push(["bound",n?{...t,units:n}:t]);t.min&&e.push(["bound",n?{...t.min,units:n}:t.min]),t.max&&e.push(["bound",n?{...t.max,units:n}:t.max])},Ku=(e,t)=>Ny[e.comparator](cs(t.data),e.limit)||!t.problems.add("bound",e),Ny={"<":(e,t)=>e":(e,t)=>e>t,"<=":(e,t)=>e<=t,">=":(e,t)=>e>=t,"==":(e,t)=>e===t},lr=(e,t,r)=>t?r?t.limit===r.limit?Wr(t.comparator)?Wr(r.comparator)?"=":"l":Wr(r.comparator)?"r":"=":e==="min"?t.limit>r.limit?"l":"r":t.limite.length===1;u();var fs={},ps=e=>(fs[e]||(fs[e]=new RegExp(e)),fs[e]),Gu=(e,t)=>ps(e).test(t.data)||!t.problems.add("regex",`/${e}/`),Hu=Le(fo);var Vu=(e,t,r)=>"value"in e?"value"in t?e.value===t.value?ve():r.addDisjoint("value",e.value,t.value):Ju(e.value,t,r)?e:r.addDisjoint("leftAssignability",e,t):"value"in t?Ju(t.value,e,r)?t:r.addDisjoint("rightAssignability",e,t):Ay(e,t,r),Cy=Le(fo),Ay=ur({divisor:qu,regex:Hu,props:Lu,class:ku,range:zu,narrow:Cy},{onEmpty:"bubble"}),ms=(e,t)=>{let r=[],n;for(n in e)Ry[n](r,e[n],t);return r.sort((o,i)=>Kr[o[0]]-Kr[i[0]])},Ry={regex:(e,t)=>{for(let r of rt(t))e.push(["regex",r])},divisor:(e,t)=>{e.push(["divisor",t])},range:Wu,class:(e,t)=>{e.push(["class",t])},props:Bu,narrow:(e,t)=>{for(let r of rt(t))e.push(["narrow",r])},value:(e,t)=>{e.push(["value",t])}},Kr={config:-1,domain:0,value:0,domains:0,branches:0,switch:0,alias:0,class:0,regex:1,divisor:1,bound:1,prerequisiteProp:2,distilledProps:3,strictProps:3,requiredProp:3,optionalProp:3,indexProp:3,narrow:4,morph:5},Ju=(e,t,r)=>!r.type.scope.type(["node",{[r.domain]:t}])(e).problems;var ds=e=>e?.lBranches!==void 0,Zu=(e,t,r)=>{let n={lBranches:e,rBranches:t,lExtendsR:[],rExtendsL:[],equalities:[],distinctIntersections:[]},o=t.map(i=>({condition:i,distinct:[]}));return e.forEach((i,s)=>{let a=!1,c=o.map((m,f)=>{if(a||!m.distinct)return null;let h=m.condition,p=Hr(i,h,r);return Qe(p)?null:p===i?(n.lExtendsR.push(s),a=!0,null):p===h?(n.rExtendsL.push(f),m.distinct=null,null):Be(p)?(n.equalities.push([s,f]),a=!0,m.distinct=null,null):It(p,"object")?p:oe(`Unexpected predicate intersection result of type \'${pe(p)}\'`)});if(!a)for(let m=0;mi.distinct??[]),n},hs=e=>"rules"in e,Gr=(e,t)=>{if(hs(e)){let r=ms(e.rules,t);if(e.morph)if(typeof e.morph=="function")r.push(["morph",e.morph]);else for(let n of e.morph)r.push(["morph",n]);return r}return ms(e,t)},Yu=e=>e.rules??e,Hr=(e,t,r)=>{let n=Yu(e),o=Yu(t),i=Vu(n,o,r);return"morph"in e?"morph"in t?e.morph===t.morph?Be(i)||Qe(i)?i:{rules:i,morph:e.morph}:r.lastOperator==="&"?te(co(r.path,"Intersection","of morphs")):{}:Qe(i)?i:{rules:Be(i)?e.rules:i,morph:e.morph}:"morph"in t?Qe(i)?i:{rules:Be(i)?t.rules:i,morph:t.morph}:i};u();u();var Qu=e=>`${e==="/"?"A":`At ${e}, a`} union including one or more morphs must be discriminatable`;var ec=(e,t)=>{let r=$y(e,t),n=e.map((o,i)=>i);return tc(e,n,r,t)},tc=(e,t,r,n)=>{if(t.length===1)return Gr(e[t[0]],n);let o=ky(t,r);if(!o)return[["branches",t.map(s=>ys(e[s],n.type.scope)?te(Qu(`${n.path}`)):Gr(e[s],n))]];let i={};for(let s in o.indexCases){let a=o.indexCases[s];i[s]=tc(e,a,r,n),s!=="default"&&Jr(i[s],o.path,o,n)}return[["switch",{path:o.path,kind:o.kind,cases:i}]]},Jr=(e,t,r,n)=>{for(let o=0;ooe(`Unexpectedly failed to discriminate ${e.kind} at path \'${e.path}\'`),Fy={domain:!0,class:!0,value:!0},$y=(e,t)=>{let r={disjointsByPair:{},casesByDisjoint:{}};for(let n=0;n{let t=be.fromString(e);return[t,t.pop()]},ky=(e,t)=>{let r;for(let n=0;n{let A=e.indexOf(D);if(A!==-1)return delete h[A],!0});I.length!==0&&(f[E]=I,p++)}let b=ie(h);if(b.length&&(f.default=b.map(E=>parseInt(E))),!r||p>r.score){let[E,I]=Py(c);if(r={path:E,kind:I,indexCases:f,score:p},p===e.length)return r}}}}return r},Xu=(e,t)=>{switch(e){case"value":return rc(t);case"domain":return t;case"class":return lo(t);default:return}},rc=e=>{let t=pe(e);return t==="object"||t==="symbol"?void 0:ss(e)},My={value:e=>rc(e)??"default",class:e=>cr(e)??"default",domain:pe},nc=(e,t)=>My[e](t),ys=(e,t)=>"morph"in e?!0:"props"in e?Object.values(e.props).some(r=>qy(Dt(r),t)):!1,qy=(e,t)=>typeof e=="string"?t.resolve(e).includesMorph:Object.values(t.resolveTypeNode(e)).some(r=>r===!0?!1:Ot(r)?r.some(n=>ys(n,t)):ys(r,t));var fr=e=>e===!0?{}:e,oc=(e,t,r)=>{if(e===!0&&t===!0)return ve();if(!Ot(e)&&!Ot(t)){let s=Hr(fr(e),fr(t),r);return s===e?e:s===t?t:s}let n=rt(fr(e)),o=rt(fr(t)),i=Zu(n,o,r);return i.equalities.length===n.length&&i.equalities.length===o.length?ve():i.lExtendsR.length+i.equalities.length===n.length?e:i.rExtendsL.length+i.equalities.length===o.length?t:i},ic=(e,t,r,n)=>{n.domain=e;let o=oc(t,r,n);if(!ds(o))return o;let i=[...o.distinctIntersections,...o.equalities.map(s=>o.lBranches[s[0]]),...o.lExtendsR.map(s=>o.lBranches[s]),...o.rExtendsL.map(s=>o.rBranches[s])];return i.length===0&&n.addDisjoint("union",o.lBranches,o.rBranches),i.length===1?i[0]:i},sc=(e,t,r,n)=>{let o=new St(n,"|"),i=oc(t,r,o);if(!ds(i))return Be(i)||i===t?r:i===r?t:e==="boolean"?!0:[fr(t),fr(r)];let s=[...i.lBranches.filter((a,c)=>!i.lExtendsR.includes(c)&&!i.equalities.some(m=>m[0]===c)),...i.rBranches.filter((a,c)=>!i.rExtendsL.includes(c)&&!i.equalities.some(m=>m[1]===c))];return s.length===1?s[0]:s},bs=(e,t)=>e===!0?[]:Ot(e)?ec(e,t):Gr(e,t),ac=e=>typeof e=="object"&&"value"in e;var Vr=e=>"config"in e,mo=(e,t,r)=>{r.domain=void 0;let n=r.type.scope.resolveTypeNode(e),o=r.type.scope.resolveTypeNode(t),i=jy(n,o,r);return typeof i=="object"&&!Mr(i)?Mr(r.disjoints)?Fu():r.addDisjoint("domain",ie(n),ie(o)):i===n?e:i===o?t:i},jy=ur((e,t,r,n)=>{if(t===void 0)return r===void 0?oe(ao):void 0;if(r!==void 0)return ic(e,t,r,n)},{onEmpty:"omit"}),_t=(e,t,r)=>{let n=new St(r,"&"),o=mo(e,t,n);return Qe(o)?te(Pu(n.disjoints)):Be(o)?e:o},bo=(e,t,r)=>{let n=r.scope.resolveTypeNode(e),o=r.scope.resolveTypeNode(t),i={},s=ie({...n,...o});for(let a of s)i[a]=ar(n,a)?ar(o,a)?sc(a,n[a],o[a],r):n[a]:ar(o,a)?o[a]:oe(ao);return i},Ly=e=>e[0]&&(e[0][0]==="value"||e[0][0]==="class"),vs=e=>{let t={type:e,path:new be,lastDomain:"undefined"};return nt(e.node,t)},nt=(e,t)=>{if(typeof e=="string")return t.type.scope.resolve(e).flat;let r=Vr(e),n=By(r?e.node:e,t);return r?[["config",{config:Su(e.config),node:n}]]:n},By=(e,t)=>{let r=ie(e);if(r.length===1){let o=r[0],i=e[o];if(i===!0)return o;t.lastDomain=o;let s=bs(i,t);return Ly(s)?s:[["domain",o],...s]}let n={};for(let o of r)t.lastDomain=o,n[o]=bs(e[o],t);return[["domains",n]]},ho=(e,t)=>Uy(e,t)&&ac(e[t]),Uy=(e,t)=>{let r=ie(e);return r.length===1&&r[0]===t},pr=e=>({object:{class:Array,props:{[ot.index]:e}}});u();u();u();u();u();function ws(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var ue=class{shift(){return this.chars[this.i++]??""}get lookahead(){return this.chars[this.i]??""}shiftUntil(t){let r="";for(;this.lookahead;){if(t(this,r))if(r[r.length-1]===ue.escapeToken)r=r.slice(0,-1);else break;r+=this.shift()}return r}shiftUntilNextTerminator(){return this.shiftUntil(ue.lookaheadIsNotWhitespace),this.shiftUntil(ue.lookaheadIsTerminator)}get unscanned(){return this.chars.slice(this.i,this.chars.length).join("")}lookaheadIs(t){return this.lookahead===t}lookaheadIsIn(t){return this.lookahead in t}constructor(t){ws(this,"chars",void 0),ws(this,"i",void 0),ws(this,"finalized",!1),this.chars=[...t],this.i=0}};(function(e){var t=e.lookaheadIsTerminator=p=>p.lookahead in o,r=e.lookaheadIsNotWhitespace=p=>p.lookahead!==h,n=e.comparatorStartChars={"<":!0,">":!0,"=":!0},o=e.terminatingChars={...n,"|":!0,"&":!0,")":!0,"[":!0,"%":!0," ":!0},i=e.comparators={"<":!0,">":!0,"<=":!0,">=":!0,"==":!0},s=e.oneCharComparators={"<":!0,">":!0},a=e.comparatorDescriptions={"<":"less than",">":"more than","<=":"at most",">=":"at least","==":"exactly"},c=e.invertedComparators={"<":">",">":"<","<=":">=",">=":"<=","==":"=="},m=e.branchTokens={"|":!0,"&":!0},f=e.escapeToken="\\\\",h=e.whiteSpaceToken=" "})(ue||(ue={}));function zy(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Wy(e,t){return t.get?t.get.call(e):t.value}function Ky(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function uc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function vo(e,t){var r=uc(e,t,"get");return Wy(e,r)}function Gy(e,t,r){zy(e,t),t.set(e,r)}function Hy(e,t,r){var n=uc(e,t,"set");return Ky(e,n,r),r}function dt(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Es=class extends TypeError{constructor(t){super(`${t}`),dt(this,"cause",void 0),this.cause=t}},Lt=class{toString(){return this.message}get message(){return this.writers.addContext(this.reason,this.path)}get reason(){return this.writers.writeReason(this.mustBe,new go(this.data))}get mustBe(){return typeof this.writers.mustBe=="string"?this.writers.mustBe:this.writers.mustBe(this.source)}constructor(t,r,n,o,i){dt(this,"code",void 0),dt(this,"path",void 0),dt(this,"data",void 0),dt(this,"source",void 0),dt(this,"writers",void 0),dt(this,"parts",void 0),this.code=t,this.path=r,this.data=n,this.source=o,this.writers=i,this.code==="multi"&&(this.parts=this.source)}},mr=new WeakMap,Is=class extends Array{mustBe(t,r){return this.add("custom",t,r)}add(t,r,n){let o=be.from(n?.path??vo(this,mr).path),i=n&&"data"in n?n.data:vo(this,mr).data,s=new Lt(t,o,i,r,vo(this,mr).getProblemConfig(t));return this.addProblem(s),s}addProblem(t){let r=`${t.path}`,n=this.byPath[r];if(n)if(n.parts)n.parts.push(t);else{let o=new Lt("multi",n.path,n.data,[n,t],vo(this,mr).getProblemConfig("multi")),i=this.indexOf(n);this[i===-1?this.length:i]=o,this.byPath[r]=o}else this.byPath[r]=t,this.push(t);this.count++}get summary(){return`${this}`}toString(){return this.join(`\n`)}throw(){throw new Es(this)}constructor(t){super(),dt(this,"byPath",{}),dt(this,"count",0),Gy(this,mr,{writable:!0,value:void 0}),Hy(this,mr,t)}},wo=Is,Jy=e=>e[0].toUpperCase()+e.slice(1),Ss=e=>e.map(t=>rs[t]),cc=e=>e.map(t=>us[t]),xs=e=>{if(e.length===0)return"never";if(e.length===1)return e[0];let t="";for(let r=0;r`must be ${e}${t&&` (was ${t})`}`,lc=(e,t)=>t.length===0?Jy(e):t.length===1&&qr(t[0])?`Item at index ${t[0]} ${e}`:`${t} ${e}`,jt={divisor:{mustBe:e=>e===1?"an integer":`a multiple of ${e}`},class:{mustBe:e=>{let t=lo(e);return t?us[t]:`an instance of ${e.name}`},writeReason:(e,t)=>qt(e,t.className)},domain:{mustBe:e=>rs[e],writeReason:(e,t)=>qt(e,t.domain)},missing:{mustBe:()=>"defined",writeReason:e=>qt(e,"")},extraneous:{mustBe:()=>"removed",writeReason:e=>qt(e,"")},bound:{mustBe:e=>`${ue.comparatorDescriptions[e.comparator]} ${e.limit}${e.units?` ${e.units}`:""}`,writeReason:(e,t)=>qt(e,`${t.size}`)},regex:{mustBe:e=>`a string matching ${e}`},value:{mustBe:ae},branches:{mustBe:e=>xs(e.map(t=>`${t.path} must be ${t.parts?xs(t.parts.map(r=>r.mustBe)):t.mustBe}`)),writeReason:(e,t)=>`${e} (was ${t})`,addContext:(e,t)=>t.length?`At ${t}, ${e}`:e},multi:{mustBe:e=>"\\u2022 "+e.map(t=>t.mustBe).join(`\n\\u2022 `),writeReason:(e,t)=>`${t} must be...\n${e}`,addContext:(e,t)=>t.length?`At ${t}, ${e}`:e},custom:{mustBe:e=>e},cases:{mustBe:e=>xs(e)}},fc=ie(jt),Vy=()=>{let e={},t;for(t of fc)e[t]={mustBe:jt[t].mustBe,writeReason:jt[t].writeReason??qt,addContext:jt[t].addContext??lc};return e},Yy=Vy(),pc=e=>{if(!e)return Yy;let t={};for(let r of fc)t[r]={mustBe:e[r]?.mustBe??jt[r].mustBe,writeReason:e[r]?.writeReason??jt[r].writeReason??e.writeReason??qt,addContext:e[r]?.addContext??jt[r].addContext??e.addContext??lc};return t};function Zy(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Qy(e,t){return t.get?t.get.call(e):t.value}function Xy(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function hc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function Os(e,t){var r=hc(e,t,"get");return Qy(e,r)}function eb(e,t,r){Zy(e,t),t.set(e,r)}function tb(e,t,r){var n=hc(e,t,"set");return Xy(e,n,r),r}function it(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var rb=()=>({mustBe:[],writeReason:[],addContext:[],keys:[]}),nb=["mustBe","writeReason","addContext"],gc=(e,t)=>{let r=new Ds(t,e);xo(e.flat,r);let n=new yc(r);if(r.problems.count)n.problems=r.problems;else{for(let[o,i]of r.entriesToPrune)delete o[i];n.data=r.data}return n},yc=class{constructor(){it(this,"data",void 0),it(this,"problems",void 0)}},Yr=new WeakMap,Ds=class{getProblemConfig(t){let r={};for(let n of nb)r[n]=this.traversalConfig[n][0]??this.rootScope.config.codes[t][n];return r}traverseConfig(t,r){for(let o of t)this.traversalConfig[o[0]].unshift(o[1]);let n=xo(r,this);for(let o of t)this.traversalConfig[o[0]].shift();return n}traverseKey(t,r){let n=this.data;this.data=this.data[t],this.path.push(t);let o=xo(r,this);return this.path.pop(),n[t]!==this.data&&(n[t]=this.data),this.data=n,o}traverseResolution(t){let r=this.type.scope.resolve(t),n=r.qualifiedName,o=this.data,i=It(o,"object");if(i){let c=Os(this,Yr)[n];if(c){if(c.includes(o))return!0;c.push(o)}else Os(this,Yr)[n]=[o]}let s=this.type;this.type=r;let a=xo(r.flat,this);return this.type=s,i&&Os(this,Yr)[n].pop(),a}traverseBranches(t){let r=this.failFast;this.failFast=!0;let n=this.problems,o=new wo(this);this.problems=o;let i=this.path,s=this.entriesToPrune,a=!1;for(let c of t)if(this.path=new be,this.entriesToPrune=[],Eo(c,this)){a=!0,s.push(...this.entriesToPrune);break}return this.path=i,this.entriesToPrune=s,this.problems=n,this.failFast=r,a||!this.problems.add("branches",o)}constructor(t,r){it(this,"data",void 0),it(this,"type",void 0),it(this,"path",void 0),it(this,"problems",void 0),it(this,"entriesToPrune",void 0),it(this,"failFast",void 0),it(this,"traversalConfig",void 0),it(this,"rootScope",void 0),eb(this,Yr,{writable:!0,value:void 0}),this.data=t,this.type=r,this.path=new be,this.problems=new wo(this),this.entriesToPrune=[],this.failFast=!1,this.traversalConfig=rb(),tb(this,Yr,{}),this.rootScope=r.scope}},xo=(e,t)=>typeof e=="string"?pe(t.data)===e||!t.problems.add("domain",e):Eo(e,t),Eo=(e,t)=>{let r=!0;for(let n=0;ne[0]in t.data?t.traverseKey(e[0],e[1]):(t.problems.add("missing",void 0,{path:t.path.concat(e[0]),data:void 0}),!1),dc=e=>(t,r)=>{let n=!0,o={...t.required};for(let s in r.data)if(t.required[s]?(n=r.traverseKey(s,t.required[s])&&n,delete o[s]):t.optional[s]?n=r.traverseKey(s,t.optional[s])&&n:t.index&&to.test(s)?n=r.traverseKey(s,t.index)&&n:e==="distilledProps"?r.failFast?r.entriesToPrune.push([r.data,s]):delete r.data[s]:(n=!1,r.problems.add("extraneous",r.data[s],{path:r.path.concat(s)})),!n&&r.failFast)return!1;let i=Object.keys(o);if(i.length){for(let s of i)r.problems.add("missing",void 0,{path:r.path.concat(s)});return!1}return n},ob={regex:Gu,divisor:ju,domains:(e,t)=>{let r=e[pe(t.data)];return r?Eo(r,t):!t.problems.add("cases",Ss(ie(e)))},domain:(e,t)=>pe(t.data)===e||!t.problems.add("domain",e),bound:Ku,optionalProp:(e,t)=>e[0]in t.data?t.traverseKey(e[0],e[1]):!0,requiredProp:mc,prerequisiteProp:mc,indexProp:(e,t)=>{if(!Array.isArray(t.data))return t.problems.add("class",Array),!1;let r=!0;for(let n=0;nt.traverseBranches(e),switch:(e,t)=>{let r=Du(t.data,e.path),n=nc(e.kind,r);if(ar(e.cases,n))return Eo(e.cases[n],t);let o=ie(e.cases),i=t.path.concat(e.path),s=e.kind==="value"?o:e.kind==="domain"?Ss(o):e.kind==="class"?cc(o):oe(`Unexpectedly encountered rule kind \'${e.kind}\' during traversal`);return t.problems.add("cases",s,{path:i,data:r}),!1},alias:(e,t)=>t.traverseResolution(e),class:Mu,narrow:(e,t)=>{let r=t.problems.count,n=e(t.data,t.problems);return!n&&t.problems.count===r&&t.problems.mustBe(e.name?`valid according to ${e.name}`:"valid"),n},config:({config:e,node:t},r)=>r.traverseConfig(e,t),value:(e,t)=>t.data===e||!t.problems.add("value",e),morph:(e,t)=>{let r=e(t.data,t.problems);if(t.problems.length)return!1;if(r instanceof Lt)return t.problems.addProblem(r),!1;if(r instanceof yc){if(r.problems){for(let n of r.problems)t.problems.addProblem(n);return!1}return t.data=r.data,!0}return t.data=r,!0},distilledProps:dc("distilledProps"),strictProps:dc("strictProps")};u();var Tt=new Proxy(()=>Tt,{get:()=>Tt});var _s=(e,t,r,n)=>{let o={node:e,flat:[["alias",e]],allows:a=>!i(a).problems,assert:a=>{let c=i(a);return c.problems?c.problems.throw():c.data},infer:Tt,inferIn:Tt,qualifiedName:ib(e)?n.getAnonymousQualifiedName(e):`${n.name}.${e}`,definition:t,scope:n,includesMorph:!1,config:r},i={[e]:a=>gc(i,a)}[e];return Object.assign(i,o)},Ts=e=>e?.infer===Tt,ib=e=>e[0]==="\\u03BB";u();u();var bc=e=>{let t=e.scanner.shiftUntilNextTerminator();e.setRoot(sb(e,t))},sb=(e,t)=>e.ctx.type.scope.addParsedReferenceIfResolvable(t,e.ctx)?t:ab(t)??e.error(t===""?Ns(e):ub(t)),ab=e=>{let t=Lr(e);if(t!==void 0)return{number:{value:t}};let r=os(e);if(r!==void 0)return{bigint:{value:r}}},ub=e=>`\'${e}\' is unresolvable`,Ns=e=>{let t=e.previousOperator();return t?Cs(t,e.scanner.unscanned):cb(e.scanner.unscanned)},Cs=(e,t)=>`Token \'${e}\' requires a right operand${t?` before \'${t}\'`:""}`,cb=e=>`Expected an expression${e?` before \'${e}\'`:""}`;u();var As=(e,t)=>({node:t.type.scope.resolveTypeNode(we(e[0],t)),config:e[2]});u();u();var Ue=e=>Object.isFrozen(e)?e:Array.isArray(e)?Object.freeze(e.map(Ue)):lb(e),lb=e=>{for(let t in e)Ue(e[t]);return e};var fb=Ue({regex:jr.source}),pb=Ue({range:{min:{comparator:">=",limit:0}},divisor:1}),vc=(e,t)=>{let r=t.type.scope.resolveNode(we(e[1],t)),n=ie(r).map(f=>db(f,r[f])),o=wc(n);if(!o.length)return co(t.path,"keyof");let i={};for(let f of o){let h=typeof f;if(h==="string"||h==="number"||h==="symbol"){var s,a;(s=i)[a=h]??(s[a]=[]),i[h].push({value:f})}else if(f===jr){var c,m;(c=i).string??(c.string=[]),i.string.push(fb),(m=i).number??(m.number=[]),i.number.push(pb)}else return oe(`Unexpected keyof key \'${ae(f)}\'`)}return Object.fromEntries(Object.entries(i).map(([f,h])=>[f,h.length===1?h[0]:h]))},mb={bigint:Mt(0n),boolean:Mt(!1),null:[],number:Mt(0),object:[],string:Mt(""),symbol:Mt(Symbol()),undefined:[]},db=(e,t)=>e!=="object"||t===!0?mb[e]:wc(rt(t).map(r=>hb(r))),wc=e=>{if(!e.length)return[];let t=e[0];for(let r=1;re[r].includes(n));return t},hb=e=>{let t=[];if("props"in e)for(let r of Object.keys(e.props))r===ot.index?t.push(jr):t.includes(r)||(t.push(r),jr.test(r)&&t.push(ro(r,`Unexpectedly failed to parse an integer from key \'${r}\'`)));if("class"in e){let r=typeof e.class=="string"?Br[e.class]:e.class;for(let n of Mt(r.prototype))t.includes(n)||t.push(n)}return t};u();var Ec=(e,t)=>{if(typeof e[2]!="function")return te(gb(e[2]));let r=we(e[0],t),n=t.type.scope.resolveTypeNode(r),o=e[2];t.type.includesMorph=!0;let i,s={};for(i in n){let a=n[i];a===!0?s[i]={rules:{},morph:o}:typeof a=="object"?s[i]=Ot(a)?a.map(c=>xc(c,o)):xc(a,o):oe(`Unexpected predicate value for domain \'${i}\': ${ae(a)}`)}return s},xc=(e,t)=>hs(e)?{...e,morph:e.morph?Array.isArray(e.morph)?[...e.morph,t]:[e.morph,t]:t}:{rules:e,morph:t},gb=e=>`Morph expression requires a function following \'|>\' (was ${typeof e})`;u();u();var Ic=e=>`Expected a Function or Record operand (${ae(e)} was invalid)`,Sc=(e,t,r,n)=>{let o=ie(t);if(!It(e,"object"))return te(Ic(e));let i={};if(typeof e=="function"){let s={[n]:e};for(let a of o)i[a]=s}else for(let s of o){if(e[s]===void 0)continue;let a={[n]:e[s]};if(typeof a[n]!="function")return te(Ic(a));i[s]=a}return i};var Oc=(e,t)=>{let r=we(e[0],t),n=t.type.scope.resolveNode(r),o=Vr(n),i=o?n.node:n,s=_t(r,Sc(e[2],i,t,"narrow"),t.type);return o?{config:n.config,node:s}:s};var _c=(e,t)=>{if(bb(e))return Tc[e[1]](e,t);if(vb(e))return Nc[e[0]](e,t);let r={length:["!",{number:{value:e.length}}]};for(let n=0;n{if(e[2]===void 0)return te(Cs(e[1],""));let r=we(e[0],t),n=we(e[2],t);return e[1]==="&"?_t(r,n,t.type):bo(r,n,t.type)},yb=(e,t)=>pr(we(e[0],t));var bb=e=>Tc[e[1]]!==void 0,Tc={"|":Dc,"&":Dc,"[]":yb,"=>":Oc,"|>":Ec,":":As},Nc={keyof:vc,instanceof:e=>typeof e[1]!="function"?te(`Expected a constructor following \'instanceof\' operator (was ${typeof e[1]}).`):{object:{class:e[1]}},"===":e=>({[pe(e[1])]:{value:e[1]}}),node:e=>e[1]},vb=e=>Nc[e[0]]!==void 0;u();var Cc=(e,t)=>{let r={};for(let n in e){let o=n,i=!1;n[n.length-1]==="?"&&(n[n.length-2]===ue.escapeToken?o=`${n.slice(0,-2)}?`:(o=n.slice(0,-1),i=!0)),t.path.push(o);let s=we(e[n],t);t.path.pop(),r[o]=i?["?",s]:s}return{object:{props:r}}};u();u();u();var Ac=e=>`Unmatched )${e===""?"":` before ${e}`}`,Rc="Missing )",Fc=(e,t)=>`Left bounds are only valid when paired with right bounds (try ...${t}${e})`,Io=e=>`Left-bounded expressions must specify their limits using < or <= (was ${e})`,$c=(e,t,r,n)=>`An expression may have at most one left bound (parsed ${e}${ue.invertedComparators[t]}, ${r}${ue.invertedComparators[n]})`;function Zr(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var So=class{error(t){return te(t)}hasRoot(){return this.root!==void 0}resolveRoot(){return this.assertHasRoot(),this.ctx.type.scope.resolveTypeNode(this.root)}rootToString(){return this.assertHasRoot(),ae(this.root)}ejectRootIfLimit(){this.assertHasRoot();let t=typeof this.root=="string"?this.ctx.type.scope.resolveNode(this.root):this.root;if(ho(t,"number")){let r=t.number.value;return this.root=void 0,r}}ejectRangeIfOpen(){if(this.branches.range){let t=this.branches.range;return delete this.branches.range,t}}assertHasRoot(){if(this.root===void 0)return oe("Unexpected interaction with unset root")}assertUnsetRoot(){if(this.root!==void 0)return oe("Unexpected attempt to overwrite root")}setRoot(t){this.assertUnsetRoot(),this.root=t}rootToArray(){this.root=pr(this.ejectRoot())}intersect(t){this.root=_t(this.ejectRoot(),t,this.ctx.type)}ejectRoot(){this.assertHasRoot();let t=this.root;return this.root=void 0,t}ejectFinalizedRoot(){this.assertHasRoot();let t=this.root;return this.root=wb,t}finalize(){if(this.groups.length)return this.error(Rc);this.finalizeBranches(),this.scanner.finalized=!0}reduceLeftBound(t,r){let n=ue.invertedComparators[r];if(!je(n,yo))return this.error(Io(r));if(this.branches.range)return this.error($c(`${this.branches.range.limit}`,this.branches.range.comparator,`${t}`,n));this.branches.range={limit:t,comparator:n}}finalizeBranches(){this.assertRangeUnset(),this.branches.union?(this.pushRootToBranch("|"),this.setRoot(this.branches.union)):this.branches.intersection&&this.setRoot(_t(this.branches.intersection,this.ejectRoot(),this.ctx.type))}finalizeGroup(){this.finalizeBranches();let t=this.groups.pop();if(!t)return this.error(Ac(this.scanner.unscanned));this.branches=t}pushRootToBranch(t){this.assertRangeUnset(),this.branches.intersection=this.branches.intersection?_t(this.branches.intersection,this.ejectRoot(),this.ctx.type):this.ejectRoot(),t==="|"&&(this.branches.union=this.branches.union?bo(this.branches.union,this.branches.intersection,this.ctx.type):this.branches.intersection,delete this.branches.intersection)}assertRangeUnset(){if(this.branches.range)return this.error(Fc(`${this.branches.range.limit}`,this.branches.range.comparator))}reduceGroupOpen(){this.groups.push(this.branches),this.branches={}}previousOperator(){return this.branches.range?.comparator??this.branches.intersection?"&":this.branches.union?"|":void 0}shiftedByOne(){return this.scanner.shift(),this}constructor(t,r){Zr(this,"ctx",void 0),Zr(this,"scanner",void 0),Zr(this,"root",void 0),Zr(this,"branches",void 0),Zr(this,"groups",void 0),this.ctx=r,this.branches={},this.groups=[],this.scanner=new ue(t)}},wb=new Proxy({},{get:()=>oe("Unexpected attempt to access ejected attributes")});u();u();var Pc=(e,t)=>{let r=e.scanner.shiftUntil(xb[t]);if(e.scanner.lookahead==="")return e.error(Ib(r,t));e.scanner.shift()==="/"?(ps(r),e.setRoot({string:{regex:r}})):e.setRoot({string:{value:r}})},kc={"\'":1,\'"\':1,"/":1},xb={"\'":e=>e.lookahead==="\'",\'"\':e=>e.lookahead===\'"\',"/":e=>e.lookahead==="/"},Eb={\'"\':"double-quote","\'":"single-quote","/":"forward slash"},Ib=(e,t)=>`${t}${e} requires a closing ${Eb[t]}`;var Oo=e=>e.scanner.lookahead===""?e.error(Ns(e)):e.scanner.lookahead==="("?e.shiftedByOne().reduceGroupOpen():e.scanner.lookaheadIsIn(kc)?Pc(e,e.scanner.shift()):e.scanner.lookahead===" "?Oo(e.shiftedByOne()):bc(e);u();u();u();var Mc=e=>`Bounded expression ${e} must be a number, string or array`;var qc=(e,t)=>{let r=Sb(e,t),n=e.ejectRootIfLimit();return n===void 0?Db(e,r):e.reduceLeftBound(n,r)},Sb=(e,t)=>e.scanner.lookaheadIs("=")?`${t}${e.scanner.shift()}`:je(t,ue.oneCharComparators)?t:e.error(Ob),Ob="= is not a valid comparator. Use == to check for equality",Db=(e,t)=>{let r=e.scanner.shiftUntilNextTerminator(),n=Lr(r,Nb(t,r+e.scanner.unscanned)),o=e.ejectRangeIfOpen(),i={comparator:t,limit:n},s=o?Rs(i,ls)?lr("min",o,i)==="l"?e.error(Cb({min:o,max:i})):{min:o,max:i}:e.error(Io(t)):Tb(i,"==")?i:Rs(i,yo)?{min:i}:Rs(i,ls)?{max:i}:oe(`Unexpected comparator \'${i.comparator}\'`);e.intersect(_b(s,e))},_b=(e,t)=>{let r=t.resolveRoot(),n=ie(r),o={},i={range:e};return n.every(a=>{switch(a){case"string":return o.string=i,!0;case"number":return o.number=i,!0;case"object":return o.object=i,r.object===!0?!1:rt(r.object).every(c=>"class"in c&&c.class===Array);default:return!1}})||t.error(Mc(t.rootToString())),o},Tb=(e,t)=>e.comparator===t,Rs=(e,t)=>e.comparator in t,Nb=(e,t)=>`Comparator ${e} must be followed by a number literal (was \'${t}\')`,Cb=e=>`${so(e)} is empty`;u();u();var jc=e=>`Divisibility operand ${e} must be a number`;var Bc=e=>{let t=e.scanner.shiftUntilNextTerminator(),r=ro(t,Lc(t));r===0&&e.error(Lc(0));let n=ie(e.resolveRoot());n.length===1&&n[0]==="number"?e.intersect({number:{divisor:r}}):e.error(jc(e.rootToString()))},Lc=e=>`% operator must be followed by a non-zero integer literal (was ${e})`;var Fs=e=>{let t=e.scanner.shift();return t===""?e.finalize():t==="["?e.scanner.shift()==="]"?e.rootToArray():e.error(Rb):je(t,ue.branchTokens)?e.pushRootToBranch(t):t===")"?e.finalizeGroup():je(t,ue.comparatorStartChars)?qc(e,t):t==="%"?Bc(e):t===" "?Fs(e):oe(Ab(t))},Ab=e=>`Unexpected character \'${e}\'`,Rb="Missing expected \']\'";var Uc=(e,t)=>t.type.scope.parseCache.get(e)??t.type.scope.parseCache.set(e,Fb(e,t)??$b(e,t)),Fb=(e,t)=>{if(t.type.scope.addParsedReferenceIfResolvable(e,t))return e;if(e.endsWith("[]")){let r=e.slice(0,-2);if(t.type.scope.addParsedReferenceIfResolvable(e,t))return pr(r)}},$b=(e,t)=>{let r=new So(e,t);return Oo(r),Pb(r)},Pb=e=>{for(;!e.scanner.finalized;)kb(e);return e.ejectFinalizedRoot()},kb=e=>e.hasRoot()?Fs(e):Oo(e);var we=(e,t)=>{let r=pe(e);if(r==="string")return Uc(e,t);if(r!=="object")return te($s(r));let n=cr(e);switch(n){case"Object":return Cc(e,t);case"Array":return _c(e,t);case"RegExp":return{string:{regex:e.source}};case"Function":if(Ts(e))return t.type.scope.addAnonymousTypeReference(e,t);if(Mb(e)){let o=e();if(Ts(o))return t.type.scope.addAnonymousTypeReference(o,t)}return te($s("Function"));default:return te($s(n??ae(e)))}},M1=Symbol("as"),Mb=e=>typeof e=="function"&&e.length===0,$s=e=>`Type definitions must be strings or objects (was ${e})`;u();function qb(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var dr=class{get root(){return this.cache}has(t){return t in this.cache}get(t){return this.cache[t]}set(t,r){return this.cache[t]=r,r}constructor(){qb(this,"cache",{})}},Do=class extends dr{set(t,r){return this.cache[t]=Ue(r),r}};function Hc(e,t){if(t.has(e))throw new TypeError("Cannot initialize the same private elements twice on an object")}function jb(e,t){return t.get?t.get.call(e):t.value}function Lb(e,t,r){if(t.set)t.set.call(e,r);else{if(!t.writable)throw new TypeError("attempted to set read only private field");t.value=r}}function Jc(e,t,r){if(!t.has(e))throw new TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function gt(e,t){var r=Jc(e,t,"get");return jb(e,r)}function zc(e,t,r){Hc(e,t),t.set(e,r)}function Wc(e,t,r){var n=Jc(e,t,"set");return Lb(e,n,r),r}function ht(e,t,r){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return r}function _o(e,t){Hc(e,t),t.add(e)}function Ae(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}var Bb=e=>({codes:pc(e.codes),keys:e.keys??"loose"}),Ub=0,Kc={},Ps={};var Bt=new WeakMap,hr=new WeakMap,Gc=new WeakSet,To=new WeakSet,Ms=new WeakSet,No=new WeakSet,qs=class{getAnonymousQualifiedName(t){let r=0,n=t;for(;this.isResolvable(n);)n=`${t}${r++}`;return`${this.name}.${n}`}addAnonymousTypeReference(t,r){var n;return(n=r.type).includesMorph||(n.includesMorph=t.includesMorph),t.node}get infer(){return Tt}compile(){if(!Ps[this.name]){for(let t in this.aliases)this.resolve(t);Ps[this.name]=gt(this,hr).root}return gt(this,hr).root}addParsedReferenceIfResolvable(t,r){var n;let o=ht(this,No,js).call(this,t,"undefined",[t]);return o?((n=r.type).includesMorph||(n.includesMorph=o.includesMorph),!0):!1}resolve(t){return ht(this,No,js).call(this,t,"throw",[t])}resolveNode(t){return typeof t=="string"?this.resolveNode(this.resolve(t).node):t}resolveTypeNode(t){let r=this.resolveNode(t);return Vr(r)?r.node:r}isResolvable(t){return gt(this,Bt).has(t)||this.aliases[t]}constructor(t,r={}){_o(this,Gc),_o(this,To),_o(this,Ms),_o(this,No),Ae(this,"aliases",void 0),Ae(this,"name",void 0),Ae(this,"config",void 0),Ae(this,"parseCache",void 0),zc(this,Bt,{writable:!0,value:void 0}),zc(this,hr,{writable:!0,value:void 0}),Ae(this,"expressions",void 0),Ae(this,"intersection",void 0),Ae(this,"union",void 0),Ae(this,"arrayOf",void 0),Ae(this,"keyOf",void 0),Ae(this,"valueOf",void 0),Ae(this,"instanceOf",void 0),Ae(this,"narrow",void 0),Ae(this,"morph",void 0),Ae(this,"type",void 0),this.aliases=t,this.parseCache=new Do,Wc(this,Bt,new dr),Wc(this,hr,new dr),this.expressions={intersection:(n,o,i)=>this.type([n,"&",o],i),union:(n,o,i)=>this.type([n,"|",o],i),arrayOf:(n,o)=>this.type([n,"[]"],o),keyOf:(n,o)=>this.type(["keyof",n],o),node:(n,o)=>this.type(["node",n],o),instanceOf:(n,o)=>this.type(["instanceof",n],o),valueOf:(n,o)=>this.type(["===",n],o),narrow:(n,o,i)=>this.type([n,"=>",o],i),morph:(n,o,i)=>this.type([n,"|>",o],i)},this.intersection=this.expressions.intersection,this.union=this.expressions.union,this.arrayOf=this.expressions.arrayOf,this.keyOf=this.expressions.keyOf,this.valueOf=this.expressions.valueOf,this.instanceOf=this.expressions.instanceOf,this.narrow=this.expressions.narrow,this.morph=this.expressions.morph,this.type=Object.assign((n,o={})=>{let i=_s("\\u03BBtype",n,o,this),s=ht(this,Ms,Vc).call(this,i),a=we(n,s);return i.node=Ue(Mr(o)?{config:o,node:this.resolveTypeNode(a)}:a),i.flat=Ue(vs(i)),i},{from:this.expressions.node}),this.name=ht(this,Gc,zb).call(this,r),r.standard!==!1&&ht(this,To,ks).call(this,[Ps.standard],"imports"),r.imports&&ht(this,To,ks).call(this,r.imports,"imports"),r.includes&&ht(this,To,ks).call(this,r.includes,"includes"),this.config=Bb(r)}};function zb(e){let t=e.name?Kc[e.name]?te(`A scope named \'${e.name}\' already exists`):e.name:`scope${++Ub}`;return Kc[t]=this,t}function ks(e,t){for(let r of e)for(let n in r)(gt(this,Bt).has(n)||n in this.aliases)&&te(Kb(n)),gt(this,Bt).set(n,r[n]),t==="includes"&>(this,hr).set(n,r[n])}function Vc(e){return{type:e,path:new be}}function js(e,t,r){let n=gt(this,Bt).get(e);if(n)return n;let o=this.aliases[e];if(!o)return t==="throw"?oe(`Unexpectedly failed to resolve alias \'${e}\'`):void 0;let i=_s(e,o,{},this),s=ht(this,Ms,Vc).call(this,i);gt(this,Bt).set(e,i),gt(this,hr).set(e,i);let a=we(o,s);if(typeof a=="string"){if(r.includes(a))return te(Wb(e,r));r.push(a),a=ht(this,No,js).call(this,a,"throw",r).node}return i.node=Ue(a),i.flat=Ue(vs(i)),i}var ze=(e,t={})=>new qs(e,t),Ls=ze({},{name:"root",standard:!1}),Xe=Ls.type,Wb=(e,t)=>`Alias \'${e}\' has a shallow resolution cycle: ${[...t,e].join("=>")}`,Kb=e=>`Alias \'${e}\' is already defined`;u();u();var Co=ze({Function:["node",{object:{class:Function}}],Date:["node",{object:{class:Date}}],Error:["node",{object:{class:Error}}],Map:["node",{object:{class:Map}}],RegExp:["node",{object:{class:RegExp}}],Set:["node",{object:{class:Set}}],WeakMap:["node",{object:{class:WeakMap}}],WeakSet:["node",{object:{class:WeakSet}}],Promise:["node",{object:{class:Promise}}]},{name:"jsObjects",standard:!1}),Yc=Co.compile();u();var Zc={bigint:!0,boolean:!0,null:!0,number:!0,object:!0,string:!0,symbol:!0,undefined:!0},Ao=ze({any:["node",Zc],bigint:["node",{bigint:!0}],boolean:["node",{boolean:!0}],false:["node",{boolean:{value:!1}}],never:["node",{}],null:["node",{null:!0}],number:["node",{number:!0}],object:["node",{object:!0}],string:["node",{string:!0}],symbol:["node",{symbol:!0}],true:["node",{boolean:{value:!0}}],unknown:["node",Zc],void:["node",{undefined:!0}],undefined:["node",{undefined:!0}]},{name:"ts",standard:!1}),Ut=Ao.compile();u();u();var Gb=e=>{let t=e.replace(/[- ]+/g,""),r=0,n,o,i;for(let s=t.length-1;s>=0;s--)n=t.substring(s,s+1),o=parseInt(n,10),i?(o*=2,o>=10?r+=o%10+1:r+=o):r+=o,i=!i;return!!(r%10===0&&t)},Hb=/^(?:4[0-9]{12}(?:[0-9]{3,6})?|5[1-5][0-9]{14}|(222[1-9]|22[3-9][0-9]|2[3-6][0-9]{2}|27[01][0-9]|2720)[0-9]{12}|6(?:011|5[0-9][0-9])[0-9]{12,15}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11}|6[27][0-9]{14}|^(81[0-9]{14,17}))$/,Qc=Xe([Hb,"=>",(e,t)=>Gb(e)||!t.mustBe("a valid credit card number")],{mustBe:"a valid credit card number"});u();var Jb=/^[./-]$/,Vb=/^([+-]?\\d{4}(?!\\d{2}\\b))((-?)((0[1-9]|1[0-2])(\\3([12]\\d|0[1-9]|3[01]))?|W([0-4]\\d|5[0-3])(-?[1-7])?|(00[1-9]|0[1-9]\\d|[12]\\d{2}|3([0-5]\\d|6[1-6])))([T]((([01]\\d|2[0-3])((:?)[0-5]\\d)?|24:?00)([.,]\\d+(?!:))?)?(\\17[0-5]\\d([.,]\\d+)?)?([zZ]|([+-])([01]\\d|2[0-3]):?([0-5]\\d)?)?)?)?$/,Yb=e=>!isNaN(e),Ro=e=>`a ${e}-formatted date`,Zb=(e,t)=>{if(!t?.format){let a=new Date(e);return Yb(a)?a:"a valid date"}if(t.format==="iso8601")return Vb.test(e)?new Date(e):Ro("iso8601");let r=e.split(Jb),n=e[r[0].length],o=n?t.format.split(n):[t.format];if(r.length!==o.length)return Ro(t.format);let i={};for(let a=0;a",(e,t)=>{let r=Zb(e);return typeof r=="string"?t.mustBe(r):r}]);var Qb=Xe([ns,"|>",e=>parseFloat(e)],{mustBe:"a well-formed numeric string"}),Xb=Xe([Ut.string,"|>",(e,t)=>{if(!qr(e))return t.mustBe("a well-formed integer string");let r=parseInt(e);return Number.isSafeInteger(r)?r:t.mustBe("an integer in the range Number.MIN_SAFE_INTEGER to Number.MAX_SAFE_INTEGER")}]),ev=Xe(/^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}$/,{mustBe:"a valid email"}),tv=Xe(/^[0-9A-Fa-f]{8}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{4}-[0-9A-Fa-f]{12}$/,{mustBe:"a valid UUID"}),rv=Xe(/^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$/,{mustBe:"a valid semantic version (see https://semver.org/)"}),nv=Xe([Ut.string,"|>",e=>JSON.parse(e)],{mustBe:"a JSON-parsable string"}),Fo=ze({alpha:[/^[A-Za-z]*$/,":",{mustBe:"only letters"}],alphanumeric:[/^[A-Za-z\\d]*$/,":",{mustBe:"only letters and digits"}],lowercase:[/^[a-z]*$/,":",{mustBe:"only lowercase letters"}],uppercase:[/^[A-Z]*$/,":",{mustBe:"only uppercase letters"}],creditCard:Qc,email:ev,uuid:tv,parsedNumber:Qb,parsedInteger:Xb,parsedDate:Xc,semver:rv,json:nv,integer:["node",{number:{divisor:1}}]},{name:"validation",standard:!1}),el=Fo.compile();var $o=ze({},{name:"standard",includes:[Ut,Yc,el],standard:!1}),ov=$o.compile(),yt={root:Ls,tsKeywords:Ao,jsObjects:Co,validation:Fo,ark:$o};var iv=$o.type;u();var sv=yt.ark.intersection,av=yt.ark.union,uv=yt.ark.arrayOf,cv=yt.ark.keyOf,lv=yt.ark.instanceOf,fv=yt.ark.valueOf,pv=yt.ark.narrow,mv=yt.ark.morph;var{DataRequest:tl,DataResponse:BT}=ze({DataRequest:{id:"number",method:"string",params:"any[]"},DataResponse:{id:"number","eventName?":"string",payload:"any",error:"any"}}).compile(),rl="__METHODS__",nl="__EVAL__";var dv=typeof parent<"u"&&typeof window<"u"&&window!==parent?parent.postMessage:postMessage,Qr=class{methods;constructor(t){if(!(typeof self<"u"&&typeof postMessage=="function"&&typeof addEventListener=="function"))throw new Error("Script must be executed as a worker");this.methods={...t,[rl]:()=>Object.keys(t),[nl]:(r,...n)=>new Function(`return (${r})`)()(...n)},addEventListener("message",r=>this.onMessage(r.data)),this.send("ready")}send(t,r){dv(t,r)}async onMessage(t){let{data:r,problems:n}=tl(t);if(n)return this.send({id:-1,payload:null,error:n.toString()});try{let o=this.methods[r.method];if(!o)throw new Error(\'Unknown method "\'+r.method+\'"\');let i=await o.apply(o,r.params);this.send({id:r.id,payload:i,error:null})}catch(o){console.error(o),this.send({id:r.id,payload:null,error:hv(o)})}}emit(t,r){this.send({eventName:t,payload:r,id:-1,error:null})}};function hv(e){return Object.getOwnPropertyNames(e).reduce((t,r)=>Object.defineProperty(t,r,{value:e[r],enumerable:!0}),{})}u();u();var ol=e=>`obsidian-zotero:${e}`;u();var zs=({key:e,groupID:t,parentItem:r},n=!1)=>{let o=[e];return!n&&r&&o.push(`a${r}`),typeof t=="number"&&o.push(`g${t}`),o.join("")},il=(e,t,r=!0)=>(n,...o)=>{let i="";for(let s=0;s0&&(i+=e(o[s-1])),i+=(r?n.raw:n)[s];return t(i)},Ws=(e=!0,t)=>il(r=>r,r=>new RegExp(e?"^"+r+"$":r,t),!0),Bs=String.raw`[23456789ABCDEFGHIJKLMNPQRSTUVWXYZ]{8}`,Us=String.raw`\\d+`,sl=e=>{let t={annotKey:Bs,parentKey:Bs,groupID:Us,page:Us};if(e)for(let r in t)t[r]=`(${t[r]})`;return il(r=>t[r],r=>r)`${"annotKey"}a${"parentKey"}(?:g${"groupID"})?(?:p${"page"})?`},JT=Ws()`${Bs}(?:g${Us})?`,VT=Ws()`${sl(!0)}`,YT=Ws()`(?:${sl(!1)}n?)+`;u();var yv=/^[0-9]{4}\\-(0[0-9]|10|11|12)\\-(0[0-9]|[1-2][0-9]|30|31) /;var bv=/^\\-?[0-9]{4}\\-(0[1-9]|10|11|12)\\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9]):([0-5][0-9])$/,vv=/^\\-?[0-9]{4}\\-(0[1-9]|10|11|12)\\-(0[1-9]|[1-2][0-9]|30|31) ([0-1][0-9]|[2][0-3]):([0-5][0-9])$/,wv=e=>xv(e)||Ev(e)?!1:yv.test(e),al=e=>e?wv(e)?e.substring(0,10):"0000-00-00":"";var xv=e=>bv.test(e),Ev=e=>vv.test(e);u();var ul=(e,t,{getLogger:r,configure:n})=>{let o=ol(e);return n({appenders:{out:{type:"console"}},categories:{default:{appenders:["out"],level:t},[o]:{appenders:["out"],level:t}}}),r(o)};u();var cl=()=>(...e)=>e;u();u();function ll(e,t){let r=Object.keys(t).map(n=>Iv(e,n,t[n]));return r.length===1?r[0]:function(){r.forEach(n=>n())}}function Iv(e,t,r){let n=e[t],o=e.hasOwnProperty(t),i=r(n);return n&&Object.setPrototypeOf(i,n),Object.setPrototypeOf(s,i),e[t]=s,a;function s(...c){return i===n&&e[t]===s&&a(),i.apply(this,c)}function a(){e[t]===s&&(o?e[t]=n:delete e[t]),i!==n&&(i=n,Object.setPrototypeOf(s,n||Function))}}var fl=e=>{let t=r=>async(...n)=>{try{return await r(...n)}catch(o){throw console.error(o),o}};return ll(e,Object.fromEntries(Object.keys(e).map(r=>[r,t]))),e};u();u();u();u();u();u();u();u();var pl;(function(e){e[e.highlight=1]="highlight",e[e.note=2]="note",e[e.image=3]="image",e[e.ink=4]="ink",e[e.underline=5]="underline",e[e.text=6]="text"})(pl||(pl={}));var ml;(function(e){e[e.manual=0]="manual",e[e.auto=1]="auto"})(ml||(ml={}));var dl;(function(e){e[e.importedFile=0]="importedFile",e[e.importedUrl=1]="importedUrl",e[e.linkedFile=2]="linkedFile",e[e.linkedUrl=3]="linkedUrl",e[e.embeddedImage=4]="embeddedImage"})(dl||(dl={}));var Ks;(function(e){e[e.fullName=0]="fullName",e[e.nameOnly=1]="nameOnly"})(Ks||(Ks={}));u();var Gs=["attachment","note","annotation"];u();u();var Po=Gs.map(e=>`\'${e}\'`).join(",");var xe=(e="itemID")=>`--sql\n ${e} IS NOT NULL\n ${e==="itemID"?`AND ${e} NOT IN (SELECT itemID FROM deletedItems)`:""}\n`,We=(e,t="$itemId")=>typeof e=="boolean"?"":`AND ${e} = ${t}`;u();var ee=class{statement;constructor(t){this.statement=t.prepare(this.sql())}get database(){return this.statement.database}get(t){return this.statement.get(t)}all(t){return this.statement.all(t)}},gr=class extends ee{query(t){return this.all(t)}},ko=class extends ee{query(){return this.all([])}},yr=class extends ee{query(t){return this.all(t).map(r=>this.parse(r,t))}};u();u();var Hs=(e,t)=>{for(let r=0;re?.split("|").map(t=>parseInt(t,10))??[];var Mo=`--sql\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n annots.type,\n annots.authorName,\n annots.text,\n annots.comment,\n annots.color,\n annots.pageLabel,\n annots.sortIndex,\n annots.position,\n annots.isExternal\n`,qo=`--sql\n itemAnnotations annots\n JOIN items USING (itemID)\n`,jo=(e,t,r)=>Object.assign(e,{sortIndex:Js(e.sortIndex),position:JSON.parse(e.position),libraryID:t,groupID:r,itemType:"annotation"});var Sv=`--sql\nSELECT\n ${Mo},\n annots.parentItemID,\n parentItems.key as parentItem\nFROM\n ${qo}\n JOIN items as parentItems ON annots.parentItemID = parentItems.itemID\nWHERE\n items.key = $annotKey\n AND items.libraryID = $libId\n AND ${xe("items.itemID")}\n`,Xr=class extends ee{trxCache={};sql(){return Sv}parse(t,r){return jo(t,r.libId,r.groupID)}query(t){let{annotKeys:r,libId:n}=t,o=s=>s.reduce((a,c)=>{let m=this.get({annotKey:c,libId:n});return m&&(a[c]=this.parse(m,t)),a},{});return(this.trxCache[n]??=this.database.transaction(o))(r)}};u();var Ov=`--sql\nSELECT\n ${Mo}\nFROM\n ${qo}\nWHERE\n parentItemID = $attachmentId\n AND items.libraryID = $libId\n AND ${xe()}\n`,en=class extends yr{sql(){return Ov}getKeyStatement=this.database.prepare("SELECT key FROM items WHERE itemID = $attachmentId AND libraryID = $libId");parse(t,r,n){return Object.assign(jo(t,r.libId,r.groupID),{parentItem:n,parentItemID:r.attachmentId})}query(t){let r=this.getKeyStatement.get(t)?.key;if(r===void 0)throw new Error("Parent item not found");return this.all(t).map(n=>this.parse(n,t,r)).sort((n,o)=>Hs(n.sortIndex,o.sortIndex))}};u();u();var Lo=`--sql\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n notes.note,\n notes.title\n`,Bo=`--sql\n itemNotes notes\n JOIN items USING (itemID)\n`,Uo=(e,t,r)=>Object.assign(e,{libraryID:t,groupID:r,itemType:"note"});var Dv=`--sql\nSELECT\n ${Lo},\n notes.parentItemID,\n parentItems.key as parentItem\nFROM\n ${Bo}\n JOIN items as parentItems ON notes.parentItemID = parentItems.itemID\nWHERE\n items.key = $noteKey\n AND items.libraryID = $libId\n AND ${xe("items.itemID")}\n`,tn=class extends ee{trxCache={};sql(){return Dv}parse(t,r){return Uo(t,r.libId,r.groupID)}query(t){let{noteKeys:r,libId:n}=t,o=s=>s.reduce((a,c)=>{let m=this.get({noteKey:c,libId:n});return m&&(a[c]=this.parse(m,t)),a},{});return(this.trxCache[n]??=this.database.transaction(o))(r)}};u();var _v=`--sql\nSELECT\n ${Lo}\nFROM\n ${Bo}\nWHERE\n parentItemID = $itemID\n AND items.libraryID = $libId\n AND ${xe()}\n`,rn=class extends yr{sql(){return _v}getKeyStatement=this.database.prepare("SELECT key FROM items WHERE itemID = $itemID AND libraryID = $libId");parse(t,r,n){return Object.assign(Uo(t,r.libId,r.groupID),{parentItem:n,parentItemID:r.itemID})}query(t){let r=this.getKeyStatement.get(t)?.key;if(r===void 0)throw new Error("Parent item not found");return this.all(t).map(n=>this.parse(n,t,r))}};u();var Tv=`--sql\nSELECT\n atchs.itemID,\n atchs.path,\n atchs.contentType,\n atchs.linkMode,\n charsets.charset,\n items.key,\n COUNT(atchs.itemID) as annotCount\nFROM\n itemAttachments atchs\n JOIN items USING (itemID)\n LEFT JOIN charsets USING (charsetID)\n LEFT JOIN itemAnnotations annots ON atchs.itemID = annots.parentItemID\nWHERE\n atchs.parentItemID = $itemId\n AND libraryID = $libId\n AND ${xe("atchs.itemID")}\nGROUP BY atchs.itemID\n`,nn=class extends gr{sql(){return Tv}};u();u();var st="betterbibtex",zt="bbts";var Nv=`--sql\nSELECT\n citationkey as citekey\nFROM\n ${st}.citationkey\nWHERE\n itemID = $itemID\n AND (libraryID IS NULL OR libraryID = $libId)\n`,Cv=`--sql\nSELECT\n citekey\nFROM\n ${zt}.citekeys\nWHERE\n itemID = $itemID\n AND (libraryID IS NULL OR libraryID = $libId)\n`,on=class extends ee{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemID:n,libId:o});return i&&(r[n]=i.citekey),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Nv}query(t){return this.trx(t.items)}},sn=class extends ee{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemID:n,libId:o});return i&&(r[n]=i.citekey),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Cv}query(t){return this.trx(t.items)}};u();var Av=`--sql\nSELECT\n itemID\nFROM\n ${st}.citationkey\nWHERE\n citationkey = $citekey\n`,Rv=`--sql\nSELECT\n itemID\nFROM\n ${zt}.citekeys\nWHERE\n citekey = $citekey\n`,an=class extends ee{trxFunc=t=>t.reduce((r,n)=>{let o=this.get({citekey:n});return r[n]=o?.itemID??-1,r},{});trx=this.database.transaction(this.trxFunc);sql(){return Av}query(t){return this.trx(t.citekeys)}},un=class extends ee{trxFunc=t=>t.reduce((r,n)=>{let o=this.get({citekey:n});return r[n]=o?.itemID??-1,r},{});trx=this.database.transaction(this.trxFunc);sql(){return Rv}query(t){return this.trx(t.citekeys)}};u();u();var zo=e=>`--sql\nSELECT\n itemID,\n creators.firstName,\n creators.lastName,\n creators.fieldMode,\n creatorTypes.creatorType,\n orderIndex\nFROM\n items\n LEFT JOIN itemCreators USING (itemID)\n JOIN creators USING (creatorID)\n JOIN creatorTypes USING (creatorTypeID)\nWHERE\n libraryID = $libId\n ${We(e||"itemID")}\n AND ${xe()}\nORDER BY\n itemID,\n orderIndex\n`;var RC=zo(!0);u();u();u();u();function hl(e){for(var t={},r=e.length,n=0;nt.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return Fv}query(t){return Wt(this.trx(t))}};u();u();var Wo=e=>`--sql\nSELECT\n items.itemID,\n fieldsCombined.fieldName,\n itemDataValues.value\nFROM\n items\n JOIN itemData USING (itemID)\n JOIN itemDataValues USING (valueID)\n JOIN fieldsCombined USING (fieldID)\n JOIN itemTypesCombined USING (itemTypeID)\nWHERE\n libraryID = $libId\n ${We(e||"items.itemID")}\n AND itemTypesCombined.typeName NOT IN (${Po})\n AND ${xe()}\n`;var DA=Wo(!0);u();var $v=Wo(!1),ln=class extends ee{trxFunc=t=>t.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return $v}query(t){return Wt(this.trx(t))}};u();u();var fn=e=>`--sql\nSELECT\n items.libraryID,\n items.itemID,\n items.key,\n items.clientDateModified,\n items.dateAdded,\n items.dateModified,\n itemTypesCombined.typeName as itemType,\n json_group_array(collectionID) filter (where collectionID is not null) as collectionIDs\nFROM \n items\n JOIN itemTypesCombined USING (itemTypeID)\n LEFT JOIN collectionItems USING (itemID)\nWHERE \n libraryID = $libId\n ${e==="full"?We(!1):e==="id"?We("items.itemID"):We("items.key","$key")}\n AND ${xe()}\n AND itemType NOT IN (${Po})\nGROUP BY itemID\n`;var Pv=fn("full"),pn=class extends ee{sql(){return Pv}query(t){return this.all(t).map(({collectionIDs:n,...o})=>({...o,collectionIDs:JSON.parse(n)}))}};u();var kv=fn("id"),Mv=fn("key"),mn=class extends ee{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({itemId:n,libId:o});return i&&(r[n]={...i,collectionIDs:JSON.parse(i.collectionIDs)}),r},{});trx=this.database.transaction(this.trxFunc);sql(){return kv}query(t){return this.trx(t)}},dn=class extends ee{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({key:n,libId:o});return i&&(r[n]={...i,collectionIDs:JSON.parse(i.collectionIDs)}),r},{});trx=this.database.transaction(this.trxFunc);sql(){return Mv}query(t){return this.trx(t)}};u();u();var hn=e=>`--sql\nWITH\n RECURSIVE CollectionPath AS (\n -- Base case: collections without a parent\n SELECT\n collectionID,\n parentCollectionID,\n collectionName AS path\n FROM\n collections\n WHERE\n libraryID = $libId\n ${e==="full"?We(!1):e==="id"?We("collectionID","$collectionID"):We("key","$key")}\n AND ${xe("collectionID")}\n UNION ALL\n -- Recursive case: join with parent collections\n SELECT\n prev.collectionID,\n c.parentCollectionID,\n c.collectionName\n FROM\n collections c\n JOIN CollectionPath prev ON c.collectionID = prev.parentCollectionID\n )\nSELECT\n p.collectionID,\n json_group_array(p.path) path,\n c.key,\n c.collectionName,\n c.libraryID\nFROM\n CollectionPath p\n JOIN collections c USING (collectionID)\nGROUP BY\n collectionID\nORDER BY\n collectionID;\n`;function Vs({collectionID:e,collectionName:t,path:r,...n}){return{...n,id:e,name:t,path:JSON.parse(r)}}var YA=hn("full");u();var qv=hn("id"),tR=hn("key"),gn=class extends ee{trxFunc=t=>t.reduce((r,[n,o])=>{let i=this.get({collectionID:n,libId:o});return i&&r.set(n,Vs(i)),r},new Map);trx=this.database.transaction(this.trxFunc);sql(){return qv}query(t){return this.trx(t)}};u();var jv=`--sql\nSELECT\n libraries.libraryID,\n groups.groupID,\n CASE\n libraries.type\n WHEN \'user\' THEN \'My Library\'\n WHEN \'group\' THEN groups.name\n ELSE NULL\n END AS name\nFROM\n libraries\n LEFT JOIN groups USING (libraryID)\nWHERE\n libraries.libraryID IS NOT NULL\nORDER BY\n libraryID\n`,yn=class extends ko{sql(){return jv}};u();var Lv=`--sql\nSELECT\n tagID,\n type,\n name\nFROM\n itemTags\n JOIN items USING (itemID)\n JOIN tags USING (tagID)\nWHERE\n itemID = $itemId\n AND tagID IS NOT NULL\n AND libraryID = $libId\n`,bn=class extends ee{trxFunc=t=>t.map(([r,n])=>[r,this.all({itemId:r,libId:n})]);trx=this.database.transaction(this.trxFunc);sql(){return Lv}query(t){return Wt(this.trx(t))}};u();u();u();var Bv=new Set(cl()("creators","itemID","itemType","key","libraryID","collections"));var tg=kr(Zs(),1);u();u();u();var qd=kr(Zs(),1),Ei=kr(Md(),1),sI="INFO",jd=ul("db-worker",sI,Ei.default),La="log4js_loglevel";qd.default.getItem(La).then(e=>{typeof e=="string"&&e in Ei.levels&&(jd.level=e,console.debug(`Read from localforage: loglevel ${e}`))});var Q=jd;u();var xh=require("fs"),Ga=kr(vh(),1);var wt=class extends Error{constructor(){super("Database not set")}};globalThis.sqlite3=Ga.default;var wh=e=>{try{return(0,xh.statSync)(e).mtimeMs}catch(t){if(t.code==="ENOENT")return-1;throw t}},Un=class{database=null;get instance(){return this.database?.instance}get databaseList(){return this.instance?.pragma("database_list")??[]}tableExists(t,r=""){if(!this.database)throw new wt;let n=r||"main",{exist:o}=(this.database.existStatements[n]??=this.database.instance.prepare(`SELECT count(*) AS exist FROM ${r?`${r}.`:""}sqlite_master WHERE type = \'table\' AND name = $tableName`)).get({tableName:t});return!!o}attachDatabase(t,r){if(!this.instance)throw new wt;this.instance.prepare(`ATTACH DATABASE $path AS ${r}`).run({path:t})}detachDatabase(t){if(!this.instance)throw new wt;this.instance.prepare(`DETACH DATABASE ${t}`).run()}isUpToDate(){if(!this.database)return null;let t=wh(this.database.file);return t===-1?null:this.database.mtime===t}opened=!1;open(t,r){let n=Ai(t);try{this.database?.instance&&(Q.debug("Database opened before, closing: ",this.database.instance.name),this.close());let o=wh(t);return o===-1?(Q.debug(`Database file not found, skipping open: ${n}`),this.opened=!1,!1):(Q.debug(`Opening database: ${n}`),this.database={mtime:o,instance:PI(n,r),file:t,existStatements:{},prepared:new Map},Q.debug(`Database opened: ${n}`),this.opened=!0,!0)}catch(o){throw Q.error(`Failed to open database: ${n}`,o),o}}close(){this.opened=!1,this.instance?.close(),this.database=null}prepare(t){if(!this.database)throw new wt;let r=this.database.prepared.get(t);if(r)return r;let n=new t(this.database.instance);return this.database.prepared.set(t,n),n}},Ai=e=>`file:${e}?mode=ro&immutable=1`;function PI(e,t){return new Ga.default(e,{nativeBinding:t.nativeBinding,verbose:void 0})}function kI(e){return e.tableExists("citationkey",st)}var zn=class{#e=null;get instance(){return this.status==="READY"?this.#e:null}get zotero(){if(!this.#e)throw new Error("database not ready");return this.#e.zotero}status="NOT_INITIALIZED";get loadStatus(){if(this.#e?.zotero.opened!==!0)return{main:!1,bbtMain:!1,bbtSearch:null};let t=this.#e.zotero.databaseList;return t.some(o=>o.name===st)?this.#e.bbtAfterMigration?{main:!0,bbtMain:!0,bbtSearch:null}:{main:!0,bbtMain:!0,bbtSearch:t.some(o=>o.name===zt)}:{main:!0,bbtMain:!1,bbtSearch:null}}get bbtLoadStatus(){let t=this.loadStatus;return t.bbtMain?t.bbtSearch!==!1:!1}getItemIDsFromCitekey(t){if(!this.#e)throw new wt;let r=this.#e.bbtAfterMigration?an:un;return this.#e.zotero.prepare(r).query({citekeys:t})}getCitekeys(t){if(!this.#e)throw new wt;let r=this.#e.bbtAfterMigration?on:sn;return this.#e.zotero.prepare(r).query({items:t})}load(t,r){let n={zotero:this.#e?.zotero??new Un};try{let o=n.zotero.open(t.zotero,r);if(!o)throw new Error(`Failed to open main database, no database found at ${t.zotero}`);let i=MI(t,n.zotero),s=n.zotero.prepare(yn).query().reduce((a,c)=>(a[c.libraryID]=c,a),{});return this.#e={...n,bbtAfterMigration:i.bbtSearch===null,libraries:s},this.status="READY",{main:o,...i}}catch(o){throw this.status="ERROR",o}}groupOf(t){if(!this.#e)throw new Error("Library info not loaded");return this.#e.libraries[t].groupID}get libraries(){if(!this.#e)throw new Error("Library info not loaded");return Object.values(this.#e.libraries)}};function MI(e,t){let r=Ai(e.bbtMain);try{Q.debug(`Attaching bbt main database: ${r}`),t.attachDatabase(r,st),Q.debug(`Attached bbt main database: ${r}`)}catch(i){let{code:s}=i;return s==="SQLITE_CANTOPEN"?Q.debug(`Unable to open bbt main database, no database found at ${r}`):Q.debug(`Unable to open bbt main database, ${s} @ ${r}`),{bbtMain:!1,bbtSearch:null}}if(kI(t))return{bbtMain:!0,bbtSearch:null};let o=Ai(e.bbtSearch);try{Q.debug(`Attaching bbt search database: ${o}`),t.attachDatabase(o,st),Q.debug(`Attached bbt search database: ${o}`)}catch(i){let{code:s}=i;return s==="SQLITE_CANTOPEN"?Q.debug(`Unable to open bbt search database, no database found at ${o}`):Q.debug(`Unable to open bbt search database, ${s} @ ${o}`),{bbtMain:!0,bbtSearch:!1}}return{bbtMain:!0,bbtSearch:!0}}u();var Sh=kr(Ih(),1);var qI=e=>typeof e[0][0]=="string";function Oh(e){return[...new Set(e)]}var Wn=class{#e=Fi;async get(t,r){if(t.length===0)return[];if(!r)return await Promise.all(t.map(([i,s])=>this.#t(i,s)));let n=qI(t)?this.#e.readItemByKey(t):this.#e.readItemById(t);return await this.#e.updateIndex(n),Object.values(n)}async#t(t,r){let n=await this.#e.getItemsCache(r);return typeof t=="number"?n.byId.get(t)??null:typeof t=="string"?n.byKey.get(t)??null:((0,Sh.assertNever)(t),null)}};u();u();u();u();u();function Kn(){this.cache=null,this.matcher=null,this.stemmer=null,this.filter=null}Kn.prototype.add;Kn.prototype.append;Kn.prototype.search;Kn.prototype.update;Kn.prototype.remove;u();u();u();function Cr(e,t){return typeof e<"u"?e:t}function Ha(e){let t=new Array(e);for(let r=0;r1&&(e=Ja(e,this.stemmer)),n&&e.length>1&&(e=jI(e)),r||r==="")){let o=e.split(r);return this.filter?LI(o,this.filter):o}return e}var Ah=/[\\p{Z}\\p{S}\\p{P}\\p{C}]+/u;function Rh(e){let t=V();for(let r=0,n=e.length;r=0;m--){let f=e[m],h=f.length,p=V(),b=!s;for(let E=0;E=0;m--){f=n[m],h=f.length;for(let p=0,b;p0;n--)this.queue[n]=this.queue[n-1];this.queue[0]=e}this.cache[e]=t};ki.prototype.get=function(e){let t=this.cache[e];if(this.limit&&t){let r=this.queue.indexOf(e);if(r){let n=this.queue[r-1];this.queue[r-1]=this.queue[r],this.queue[r]=n}}return t};ki.prototype.del=function(e){for(let t=0,r,n;t=this.minlength&&(a||!s[f])){let p=ji(c,o,m),b="";switch(this.tokenize){case"full":if(h>2){for(let E=0;EE;I--)if(I-E>=this.minlength){let D=ji(c,o,m,h,E);b=f.substring(E,I),this.push_index(s,b,D,e,r)}break}case"reverse":if(h>1){for(let E=h-1;E>0;E--)if(b=f[E]+b,b.length>=this.minlength){let I=ji(c,o,m,h,E);this.push_index(s,b,I,e,r)}b=""}case"forward":if(h>1){for(let E=0;E=this.minlength&&this.push_index(s,b,p,e,r);break}default:if(this.boost&&(p=Math.min(p/this.boost(t,f,m)|0,c-1)),this.push_index(s,f,p,e,r),a&&o>1&&m=this.minlength&&!E[f]){E[f]=1;let q=ji(I+(o/2>I?0:1),o,m,A-1,j-1),ne=this.bidirectional&&f>D;this.push_index(i,ne?D:f,q,e,r,ne?f:D)}}}}}this.fastupdate||(this.register[e]=1)}}return this};function ji(e,t,r,n,o){return r&&e>1?t+(n||0)<=e?r+(o||0):(e-1)/(t+(n||0))*(r+(o||0))+1|0:0}Ne.prototype.push_index=function(e,t,r,n,o,i){let s=i?this.ctx:this.map;if((!e[t]||i&&!e[t][i])&&(this.optimize&&(s=s[r]),i?(e=e[t]||(e[t]=V()),e[i]=1,s=s[i]||(s[i]=V())):e[t]=1,s=s[t]||(s[t]=[]),this.optimize||(s=s[r]||(s[r]=[])),(!o||!s.includes(n))&&(s[s.length]=n,this.fastupdate))){let a=this.register[n]||(this.register[n]=[]);a[a.length]=s}};Ne.prototype.search=function(e,t,r){r||(!t&&Ze(e)?(r=e,e=r.query):Ze(t)&&(r=t));let n=[],o,i,s,a=0;if(r&&(e=r.query||e,t=r.limit,a=r.offset||0,i=r.context,s=!0&&r.suggest),e&&(e=this.encode(""+e),o=e.length,o>1)){let h=V(),p=[];for(let b=0,E=0,I;b=this.minlength&&!h[I]){if(!this.optimize&&!s&&!this.map[I])return n;p[E++]=I,h[I]=1}e=p,o=e.length}if(!o)return n;t||(t=100);let c=this.depth&&o>1&&i!==!1,m=0,f;c?(f=e[0],m=1):o>1&&e.sort(Th);for(let h,p;m=r)))));h++);if(m){if(o)return Kh(a,r,0);e[e.length]=a;return}}return!t&&a};function Kh(e,t,r){return e.length===1?e=e[0]:e=_h(e),r||e.length>t?e.slice(r,r+t):e}function Wh(e,t,r,n){if(r){let o=n&&t>r;e=e[o?t:r],e=e&&e[o?r:t]}else e=e[t];return e}Ne.prototype.contain=function(e){return!!this.register[e]};Ne.prototype.update=function(e,t){return this.remove(e).add(e,t)};Ne.prototype.remove=function(e,t){let r=this.register[e];if(r){if(this.fastupdate)for(let n=0,o;n1&&(e.splice(s,1),i++):i++}else{o=Math.min(e.length,r);for(let s=0,a;s"u"&&self.exports,o=this;this.worker=KI(r,n,e.worker),this.resolver=V(),this.worker&&(n?this.worker.on("message",function(i){o.resolver[i.id](i.msg),delete o.resolver[i.id]}):this.worker.onmessage=function(i){i=i.data,o.resolver[i.id](i.msg),delete o.resolver[i.id]},this.worker.postMessage({task:"init",factory:r,options:e}))}var Jh=Jn;Vn("add");Vn("append");Vn("search");Vn("update");Vn("remove");function Vn(e){Jn.prototype[e]=Jn.prototype[e+"Async"]=function(){let t=this,r=[].slice.call(arguments),n=r[r.length-1],o;Gn(n)&&(o=n,r.splice(r.length-1,1));let i=new Promise(function(s){setTimeout(function(){t.resolver[++Hh]=s,t.worker.postMessage({task:e,id:Hh,args:r})})});return o?(i.then(o),this):i}}function KI(factory,is_node_js,worker_path){let worker;try{worker=is_node_js?eval(\'new (require("worker_threads")["Worker"])("../dist/node/node.js")\'):factory?new Worker(URL.createObjectURL(new Blob(["onmessage="+Gh.toString()],{type:"text/javascript"}))):new Worker(me(worker_path)?worker_path:"worker/worker.js",{type:"module"})}catch(e){}return worker}function Ce(e){if(!(this instanceof Ce))return new Ce(e);let t=e.document||e.doc||e,r;this.tree=[],this.field=[],this.marker=[],this.register=V(),this.key=(r=t.key||t.id)&&zi(r,this.marker)||"id",this.fastupdate=Cr(e.fastupdate,!0),!0&&(this.storetree=(r=t.store)&&r!==!0&&[],this.store=r&&V()),!0&&(this.tag=(r=t.tag)&&zi(r,this.marker),this.tagindex=r&&V()),!0&&(this.cache=(r=e.cache)&&new Mi(r),e.cache=!1),!0&&(this.worker=e.worker),!0&&(this.async=!1),this.index=GI.call(this,e,t)}var Yh=Ce;function GI(e,t){let r=V(),n=t.index||t.field||t;me(n)&&(n=[n]);for(let o=0,i,s;o=0&&(e=e.substring(0,e.length-2),e&&(t[n]=!0)),e&&(r[n++]=e);return n1?r:r[0]}function Xa(e,t){if(me(t))e=e[t];else for(let r=0;e&&r1?r.splice(n,1):delete this.tagindex[t])}!0&&this.store&&delete this.store[e],delete this.register[e]}return this};Ce.prototype.search=function(e,t,r,n){r||(!t&&Ze(e)?(r=e,e=""):Ze(t)&&(r=t,t=0));let o=[],i=[],s,a,c,m,f,h,p=0;if(r)if(or(r))c=r,r=null;else{if(e=r.query||e,s=r.pluck,c=s||r.index||r.field,m=!0&&r.tag,a=!0&&this.store&&r.enrich,f=r.bool==="and",t=r.limit||t||100,h=r.offset||0,m&&(me(m)&&(m=[m]),!e)){for(let E=0,I;E1||m&&m.length>1);let b=!n&&(this.worker||this.async)&&[];for(let E=0,I,D,A;E0)return(i>t||r)&&(o=o.slice(r,r+t)),n&&(o=Zh.call(this,o)),{tag:e,result:o}}function Zh(e){let t=new Array(e.length);for(let r=0,n;r{e=n,t=o});return{resolve:e,reject:t,promise:r}}u();var Yn=class{#e=Fr;readCitekeys(t){if(Q.debug("Reading Better BibTex database"),!this.#e.bbtLoadStatus)return Q.info("Better BibTex database not enabled, skipping..."),[];let r=this.#e.getCitekeys(t);return Q.info("Finished reading Better BibTex"),r}toItemObjects(t,r){let n=this.readCitekeys(r),o=this.#e.zotero.prepare(ln).query(r),i=this.#e.zotero.prepare(cn).query(r),s=Oh(r.flatMap(([c])=>t[c]?.collectionIDs?.map(m=>`${m}-${t[c].libraryID}`)??[])).filter(c=>c!==null),a=this.#e.zotero.prepare(gn).query(s.map(c=>c.split("-").map(m=>+m)));return r.reduce((c,[m,f])=>{if(!m)return c;let h=n[m];h||Q.warn(`Citekey: No item found for itemID ${m}`,h);let p=o[m].reduce((A,j)=>{let{value:q}=j;return j.fieldName==="date"&&(q=al(q).split("-")[0]),(A[j.fieldName]??=[]).push(q),A},{}),{collectionIDs:b,...E}=t[m],I=b.map(A=>a.get(A)).filter(A=>A!==void 0),D={...E,libraryID:f,groupID:this.#e.groupOf(f),itemID:m,creators:i[m],collections:I,citekey:n[m],...p,dateAccessed:ZI(p)?QI(p.accessDate[0]):null};return c[m]=D,c},{})}};function ZI(e){let t=e;return Array.isArray(t.accessDate)&&t.accessDate.length===1&&typeof t.accessDate[0]=="string"}function QI(e){let t=e.replace(" ","T")+"Z";try{return new Date(t)}catch{return null}}var Zn=class{#e=Fr;#t=new Yn;#r=new Yh({worker:!0,charset:Fh,language:Qh,document:{id:"itemID",index:["title","creators[]:firstName","creators[]:lastName","date"]},tokenize:"full",suggest:!0});#o=new Map;#n=new Map;getStatus(t){if(!this.#n.has(t)){let n=Xh();return this.#n.set(t,n),n.promise}let r=this.#n.get(t);return r instanceof Promise||typeof r=="string"?r:r.promise}load(t){let r=this.#n.get(t);if(r instanceof Promise)return r;let n=this.#a(t),o=this.#u(t,n).then(()=>{this.#n.set(t,"READY")}).catch(i=>{throw this.#n.set(t,"ERROR"),i});return typeof r=="string"||!r||o.then(r.resolve,r.reject),this.#n.set(t,o),o}async searchItems(t,r){return await this.#i(t),await this.#r.searchAsync(r)}async getCachedItems(t,r){await this.#i(r);let n=this.#o.get(r);if(!n)throw new Error("Cache not initialized");let o=[...n.byId.values()].sort((i,s)=>s.dateAccessed&&i.dateAccessed?s.dateAccessed.getTime()-i.dateAccessed.getTime():0);return t<=0?o:o.slice(0,t)}async getItemsCache(t){await this.#i(t);let r=this.#o.get(t);if(!r)throw new Error("Cache not initialized");return r}async#i(t){let r=this.getStatus(t);if(r==="ERROR")throw new Error("Indexing failed");r instanceof Promise&&await r}#a(t){Q.debug("Reading main Zotero database for index");let{zotero:r}=this.#e,n=this.#s(r.prepare(pn).query({libId:t}));return Q.info("Finished reading main Zotero database for index"),n}readItemByKey(t){let{zotero:r}=this.#e,n=r.prepare(dn).query(t);return this.#s(t.map(([i])=>n[i]))}readItemById(t){let{zotero:r}=this.#e,n=r.prepare(mn).query(t);return this.#s(t.map(([i])=>n[i]))}#s(t){let r=t.reduce((o,i)=>(o[i.itemID]=i,o),{}),n=t.map(o=>[o.itemID,o.libraryID]);return this.#t.toItemObjects(r,n)}async#u(t,r){Q.trace("Start flexsearch indexing");let n=Object.values(r),o=this.#o.get(t);if(this.#o.set(t,{byId:new Map(n.map(i=>[i.itemID,i])),byKey:new Map(n.map(i=>[zs(i,!0),i]))}),!o)await Promise.all([...n.map(i=>this.#r.addAsync(i.itemID,i))]);else{let i=new Set(n.map(a=>a.itemID)),s=[...o.byId.keys()].filter(a=>!i.has(a));o.byId.clear(),o.byKey.clear(),await Promise.all([...n.map(a=>this.#r.addAsync(a.itemID,a)),...s.map(a=>this.#r.removeAsync(a))])}Q.info("Library citation index done: "+t)}async updateIndex(t){await Promise.all(Object.values(t).map(async r=>{let n=this.#o.get(r.libraryID);if(!n)throw new Error("Cannot update index for library not initialized");n.byId.set(r.itemID,r),n.byKey.set(zs(r,!0),r),await this.#r.updateAsync(r.itemID,r)}))}};var Fr=new zn,Fi=new Zn,eg=new Wn;u();function ir(e,t){return(...r)=>{Q.debug(`Reading Zotero database for ${typeof t=="string"?t:t(null,...r)}`);let n=e.apply(null,r);return Promise.resolve(n).then(o=>Q.debug(`Finished reading Zotero database for ${typeof t=="string"?t:t(o,...r)}`)),n}}var ru=class{#e=Fr;#t=Fi;#r=eg;api={getLibs:()=>this.#e.libraries,initIndex:async t=>{await this.#t.load(t)},openDb:(...t)=>this.#e.load(...t),search:async(t,r)=>await this.#t.searchItems(t,r),getItems:async(t,r)=>await this.#r.get(t,r),getTags:ir(t=>this.#e.zotero.prepare(bn).query(t),"tags"),getItemIDsFromCitekey:t=>this.#e.getItemIDsFromCitekey(t),getItemsFromCache:(t,r)=>this.#t.getCachedItems(t,r),getAttachments:ir((t,r)=>this.#e.zotero.prepare(nn).query({itemId:t,libId:r}),(t,r)=>`attachments of item ${r}`+(t?`, count: ${t.length}`:"")),getAnnotations:ir((t,r)=>this.#e.zotero.prepare(en).query({attachmentId:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`annotations of attachment ${r}`+(t?`, count: ${t.length}`:"")),getAnnotFromKey:ir((t,r)=>this.#e.zotero.prepare(Xr).query({annotKeys:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`annotations with keys: ${r.join(",")}`+(t?`, count: ${t.length}`:"")),getNotes:ir((t,r)=>this.#e.zotero.prepare(rn).query({itemID:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`notes of literature ${r}`+(t?`, count: ${t.length}`:"")),getNoteFromKey:ir((t,r)=>this.#e.zotero.prepare(tn).query({noteKeys:t,libId:r,groupID:this.#e.groupOf(r)}),(t,r)=>`notes with keys: ${r.join(",")}`+(t?`, count: ${t.length}`:"")),isUpToDate:()=>this.#e.zotero.isUpToDate(),getLoadStatus:()=>{let t=this.#e.loadStatus;return{main:t.main,bbt:this.#e.bbtLoadStatus,bbtVersion:t.bbtSearch===null?"v1":"v0"}},raw:(t,r,n)=>{let{zotero:{instance:o}}=this.#e;if(!o)throw new Error("failed to query raw: no main database opened");return o.prepare(r)[t](...n)},setLoglevel:t=>{Q.level=t,tg.default.setItem(La,t)}};toAPI(){return fl(this.api)}},XI=new ru;new Qr(XI.toAPI());\n/*! Bundled license information:\n\nlocalforage/dist/localforage.js:\n (*!\n localForage -- Offline Storage, Improved\n Version 1.10.0\n https://localforage.github.io/localForage\n (c) 2013-2017 Mozilla, Apache License 2.0\n *)\n\nflatted/cjs/index.js:\n (*! (c) 2020 Andrea Giammarchi *)\n*/\n';var Kb=class extends Gs{initWebWorker(){return uC(Wk,{name:"zotlit database worker"})}},Rp=class extends Zs{workerCtor(){return new Kb}};var Yt=class extends de{settings=this.use(be);app=this.use(_o.App);plugin=this.use(Ie);server=this.use(An);get zoteroDataDir(){return this.settings.current?.zoteroDataDir}onload(){H.debug("loading DatabaseWorker"),this.settings.once(async()=>{let e=(0,_o.debounce)(()=>this.refresh({task:"dbConn"}),500,!0);this.registerEvent(this.app.vault.on("zotero:db-updated",()=>e()));let r=process.hrtime();await this.initialize(),H.debug(`ZoteroDB Initialization complete. Took ${(0,Hk.default)(process.hrtime(r))}`);let n=this.genAutoRefresh(this.plugin);this.registerEvent(this.server.on("bg:notify",async(o,i)=>{i.event==="regular-item/update"&&n(i)})),this.plugin.addCommand({id:"refresh-zotero-data",name:"Refresh Zotero data",callback:async()=>{await this.refresh({task:"full"})}}),this.plugin.addCommand({id:"refresh-zotero-search-index",name:"Refresh Zotero search index",callback:async()=>{await this.refresh({task:"searchIndex"})}})}),this.register(Ge(ft(async()=>{this.status===0?await this.initialize():await this.refresh({task:"full"})},()=>this.zoteroDataDir))),this.register(Ge(ft(async()=>{await this.refresh({task:"searchIndex",force:!0}),new _o.Notice("Zotero search index updated.")},()=>this.settings.libId,!0)))}genAutoRefresh(e){let r=!1,n=null,o=()=>{n&&(H.debug("unregistering db refresh watcher"),n(),n=null)},i=(0,_o.debounce)(async()=>{if(o(),H.debug("Auto Refreshing Zotero Search Index"),!r){r=!1;try{H.debug("Db not refreshed, waiting before auto refresh");let[s]=ob(e.app,{timeout:1e4});await s}catch(s){if(s instanceof Rc){H.warn("no db refreshed event received in 10s, skip refresh search index");return}else{console.error("error while waiting for db refresh during execute",s);return}}}await this.refresh({task:"searchIndex",force:!0}),H.debug("Auto Refreshing Zotero Search Index Success")},5e3,!0);return s=>{if(H.debug(`Request to auto refresh search index: (refreshed ${r})`,s),i(),o(),r)return;H.debug("watching db refresh while waiting for search index auto refresh");let[c,l]=ob(e.app,{timeout:null});n=l,c.then(()=>{H.debug("db refresh while requesting auto refresh search index"),r=!0,n=null}).catch(f=>{f instanceof Nc||console.error("error while waiting for db refresh during request",f)})}}async onunload(){await this.#e.terminate(),this.#t=0,this.#s=null}#e=new Rp({minWorkers:1,maxWorkers:1});get api(){return this.#e.proxy}#t=0;get status(){return this.#t}#n=null;async#o(e){let r=this.settings.libId;return!e&&this.#n===r?(H.debug(`Skipping search index init, lib ${r} already indexed`),!1):(await this.api.initIndex(r),this.#n=r,H.debug(`Search index init complete for lib ${r}`),!0)}async#i(){let[e,r]=this.settings.dbConnParams;H.debug("Opening Zotero databases",{zotero:e.zotero,bbtMain:e.bbtMain,bbtSearch:e.bbtSearch});let{main:n,bbtMain:o,bbtSearch:i}=await this.api.openDb(e,r);if(H.debug("Zotero database open result",{main:n,bbtMain:o,bbtSearch:i}),(!o||i===!1)&&H.debug("Failed to open Better BibTeX database, skipping..."),!n)throw new Error("Failed to init ZoteroDB")}async initialize(){if(this.#t!==0)throw new Error("Calling init on already initialized db, use refresh instead");await this.#i(),this.app.vault.trigger("zotero:db-ready"),await this.#o(!0),this.app.metadataCache.trigger("zotero:search-ready"),H.info("ZoteroDB Initialization complete."),this.#t=2}#r=null;#s=null;refresh(e){if(this.#t===0)return Promise.reject(new Error("Calling refresh on uninitialized database"));if(this.#t===2){this.#t=1;let r=(async()=>{e.task==="dbConn"?await this.#a():e.task==="searchIndex"?await this.#c(e.force):e.task==="full"?await this.#l():(0,Vb.assertNever)(e),this.#t=2;let n=this.#s;n&&(this.#s=null,await this.refresh(n))})();return this.#r=r}else{if(this.#t===1)return this.#r?(this.#s=this.#u(e),this.#r):Promise.reject(new Error("Other task in pending state"));(0,Vb.assertNever)(this.#t)}}async#a(){await this.#i(),this.app.vault.trigger("zotero:db-refresh")}async#c(e=!1){await this.#o(e)&&this.app.metadataCache.trigger("zotero:search-refresh")}async#l(){await this.#a(),await this.#c(!0),new _o.Notice("ZoteroDB Refresh complete.")}#u(e){if(!this.#s)return e;let r=this.#s;return r.task==="full"?r:r.task===e.task?r.task==="searchIndex"?{...r,force:r.force||e.force}:r:{task:"full"}}};he([ge],Yt.prototype,"zoteroDataDir",1);var Kk="INFO",Vk="log4js_loglevel",I7=()=>{let t=localStorage.getItem(Vk);return typeof t=="string"&&t in Np.levels?(console.debug(`Read from localstorage: loglevel ${t}`),t):Kk},Gb=qS("main",I7(),Np.default),H=Gb,gt=(t,e,...r)=>{if(!e){Gb.error(t,...r);return}Gb.error(t,e instanceof Error?e.message:String(e),...r),console.error(e)},nC={logLevel:Kk},Jc=class extends de{settings=this.use(be);get level(){return this.settings.current?.logLevel}async applyLogLevel(){localStorage.setItem(Vk,this.level),await this.use(Yt).api.setLoglevel(this.level)}onload(){this.register(Ge(ft(()=>this.applyLogLevel(),()=>this.level)))}};he([ge],Jc.prototype,"level",1);a();var AN=require("fs"),Gn=require("obsidian");a();a();_();var _e={},ea=Symbol(),JA=t=>!!t[ea],VA=t=>!t[ea].c,rl=t=>{var e;let{b:r,c:n}=t[ea];n&&(n(),(e=W7.get(r))==null||e())},Bp=(t,e)=>{let r=t[ea].o,n=e[ea].o;return r===n||t===n||JA(r)&&Bp(r,e)},GA=(t,e)=>{let r={b:t,o:e,c:null},n=new Promise(o=>{r.c=()=>{r.c=null,o()},e.finally(r.c)});return n[ea]=r,n},W7=new WeakMap;var qp=t=>"init"in t,lv="r",uv="w",nl="c",fv="s",ZA="h",H7="n",K7="l",V7="a",G7="m",Z7=t=>{let e=new WeakMap,r=new WeakMap,n=new Map,o,i;if((_e.env&&_e.env.MODE)!=="production"&&(o=new Set,i=new Set),t)for(let[I,E]of t){let A={v:E,r:0,y:!0,d:new Map};(_e.env&&_e.env.MODE)!=="production"&&(Object.freeze(A),qp(I)||console.warn("Found initial value for derived atom which can cause unexpected behavior",I)),e.set(I,A)}let s=new WeakMap,c=(I,E,A)=>{let R=s.get(E);R||(R=new Map,s.set(E,R)),A.then(()=>{R.get(I)===A&&(R.delete(I),R.size||s.delete(E))}),R.set(I,A)},l=I=>{let E=new Set,A=s.get(I);return A&&(s.delete(I),A.forEach((R,N)=>{rl(R),E.add(N)})),E},f=new WeakMap,u=I=>{let E=f.get(I);return E||(E=new Map,f.set(I,E)),E},d=(I,E)=>{if(I){let A=u(I),R=A.get(E);return R||(R=d(I.p,E),R&&"p"in R&&VA(R.p)&&(R=void 0),R&&A.set(E,R)),R}return e.get(E)},m=(I,E,A)=>{if((_e.env&&_e.env.MODE)!=="production"&&Object.freeze(A),I)u(I).set(E,A);else{let R=e.get(E);e.set(E,A),n.has(E)||n.set(E,R)}},h=(I,E=new Map,A)=>{if(!A)return E;let R=new Map,N=!1;return A.forEach(D=>{var W;let ie=((W=d(I,D))==null?void 0:W.r)||0;R.set(D,ie),E.get(D)!==ie&&(N=!0)}),E.size===R.size&&!N?E:R},y=(I,E,A,R,N)=>{let D=d(I,E);if(D){if(N&&(!("p"in D)||!Bp(D.p,N)))return D;"p"in D&&rl(D.p)}let W={v:A,r:D?.r||0,y:!0,d:h(I,D?.d,R)},ie=!D?.y;return!D||!("v"in D)||!Object.is(D.v,A)?(ie=!0,++W.r,W.d.has(E)&&(W.d=new Map(W.d).set(E,W.r))):W.d!==D.d&&(W.d.size!==D.d.size||!Array.from(W.d.keys()).every(Yr=>D.d.has(Yr)))&&(ie=!0,Promise.resolve().then(()=>{F(I)})),D&&!ie?D:(m(I,E,W),W)},w=(I,E,A,R,N)=>{let D=d(I,E);if(D){if(N&&(!("p"in D)||!Bp(D.p,N)))return D;"p"in D&&rl(D.p)}let W={e:A,r:(D?.r||0)+1,y:!0,d:h(I,D?.d,R)};return m(I,E,W),W},v=(I,E,A,R)=>{let N=d(I,E);if(N&&"p"in N){if(Bp(N.p,A))return N.y?N:{...N,y:!0};rl(N.p)}c(I,E,A);let D={p:A,r:(N?.r||0)+1,y:!0,d:h(I,N?.d,R)};return m(I,E,D),D},x=(I,E,A,R)=>{if(A instanceof Promise){let N=GA(A,A.then(D=>{y(I,E,D,R,N)}).catch(D=>{if(D instanceof Promise)return JA(D)?D.then(()=>{k(I,E,!0)}):D;w(I,E,D,R,N)}));return v(I,E,N,R)}return y(I,E,A,R)},S=(I,E)=>{let A=d(I,E);if(A){let R={...A,y:!1};m(I,E,R)}else(_e.env&&_e.env.MODE)!=="production"&&console.warn("[Bug] could not invalidate non existing atom",E)},k=(I,E,A)=>{if(!A){let N=d(I,E);if(N){if(N.y&&"p"in N&&!VA(N.p))return N;if(N.d.forEach((D,W)=>{if(W!==E)if(!r.has(W))k(I,W);else{let ie=d(I,W);ie&&!ie.y&&k(I,W)}}),Array.from(N.d).every(([D,W])=>{let ie=d(I,D);return ie&&!("p"in ie)&&ie.r===W}))return N.y?N:{...N,y:!0}}}let R=new Set;try{let N=E.read(D=>{R.add(D);let W=D===E?d(I,D):k(I,D);if(W){if("e"in W)throw W.e;if("p"in W)throw W.p;return W.v}if(qp(D))return D.init;throw new Error("no atom init")});return x(I,E,N,R)}catch(N){if(N instanceof Promise){let D=GA(N,N);return v(I,E,D,R)}return w(I,E,N,R)}},j=(I,E)=>k(E,I),Z=(I,E)=>{let A=r.get(E);return A||(A=O(I,E)),A},X=(I,E)=>!E.l.size&&(!E.t.size||E.t.size===1&&E.t.has(I)),J=(I,E)=>{let A=r.get(E);A&&X(E,A)&&T(I,E)},G=(I,E)=>{let A=r.get(E);A?.t.forEach(R=>{R!==E&&(S(I,R),G(I,R))})},M=(I,E,A)=>{let R=!0,N=(ie,Yr)=>{let Nr=k(I,ie);if("e"in Nr)throw Nr.e;if("p"in Nr){if(Yr?.unstable_promise)return Nr.p.then(()=>{let sf=d(I,ie);return sf&&"p"in sf&&sf.p===Nr.p?new Promise(Gg=>setTimeout(Gg)).then(()=>N(ie,Yr)):N(ie,Yr)});throw(_e.env&&_e.env.MODE)!=="production"&&console.info("Reading pending atom state in write operation. We throw a promise for now.",ie),Nr.p}if("v"in Nr)return Nr.v;throw(_e.env&&_e.env.MODE)!=="production"&&console.warn("[Bug] no value found while reading atom in write operation. This is probably a bug.",ie),new Error("no value found")},D=(ie,Yr)=>{let Nr;if(ie===E){if(!qp(ie))throw new Error("atom not writable");l(ie).forEach(mS=>{mS!==I&&x(mS,ie,Yr)});let Gg=d(I,ie),lz=x(I,ie,Yr);Gg!==lz&&G(I,ie)}else Nr=M(I,ie,Yr);return R||F(I),Nr},W=E.write(N,D,A);return R=!1,W},te=(I,E,A)=>{let R=M(A,I,E);return F(A),R},C=I=>!!I.write,O=(I,E,A)=>{let R={t:new Set(A&&[A]),l:new Set};if(r.set(E,R),(_e.env&&_e.env.MODE)!=="production"&&i.add(E),k(void 0,E).d.forEach((D,W)=>{let ie=r.get(W);ie?ie.t.add(E):W!==E&&O(I,W,E)}),C(E)&&E.onMount){let D=ie=>te(E,ie,I),W=E.onMount(D);I=void 0,W&&(R.u=W)}return R},T=(I,E)=>{var A;let R=(A=r.get(E))==null?void 0:A.u;R&&R(),r.delete(E),(_e.env&&_e.env.MODE)!=="production"&&i.delete(E);let N=d(I,E);N?("p"in N&&rl(N.p),N.d.forEach((D,W)=>{if(W!==E){let ie=r.get(W);ie&&(ie.t.delete(E),X(W,ie)&&T(I,W))}})):(_e.env&&_e.env.MODE)!=="production"&&console.warn("[Bug] could not find atom state to unmount",E)},U=(I,E,A,R)=>{let N=new Set(A.d.keys());R?.forEach((D,W)=>{if(N.has(W)){N.delete(W);return}let ie=r.get(W);ie&&(ie.t.delete(E),X(W,ie)&&T(I,W))}),N.forEach(D=>{let W=r.get(D);W?W.t.add(E):r.has(E)&&O(I,D,E)})},F=I=>{if(I){u(I).forEach((A,R)=>{let N=e.get(R);if(A!==N){let D=r.get(R);D?.l.forEach(W=>W(I))}});return}for(;n.size;){let E=Array.from(n);n.clear(),E.forEach(([A,R])=>{let N=d(void 0,A);if(N&&N.d!==R?.d&&U(void 0,A,N,R?.d),R&&!R.y&&N?.y)return;let D=r.get(A);D?.l.forEach(W=>W())})}(_e.env&&_e.env.MODE)!=="production"&&o.forEach(E=>E())},se=I=>{u(I).forEach((A,R)=>{let N=e.get(R);(!N||A.r>N.r||A.y!==N.y||A.r===N.r&&A.d!==N.d)&&(e.set(R,A),A.d!==N?.d&&U(I,R,A,N?.d))})},ce=(I,E)=>{E&&se(E),F(void 0)},xe=(I,E,A)=>{let N=Z(A,I).l;return N.add(E),()=>{N.delete(E),J(A,I)}},fe=(I,E)=>{for(let[A,R]of I)qp(A)&&(x(E,A,R),G(E,A));F(E)};return(_e.env&&_e.env.MODE)!=="production"?{[lv]:j,[uv]:te,[nl]:ce,[fv]:xe,[ZA]:fe,[H7]:I=>(o.add(I),()=>{o.delete(I)}),[K7]:()=>i.values(),[V7]:I=>e.get(I),[G7]:I=>r.get(I)}:{[lv]:j,[uv]:te,[nl]:ce,[fv]:xe,[ZA]:fe}};var YA=(t,e)=>({s:e?e(t).SECRET_INTERNAL_store:Z7(t)}),cv=new Map,pv=t=>(cv.has(t)||cv.set(t,Ve(YA())),cv.get(t)),XA=({children:t,initialValues:e,scope:r,unstable_createStore:n,unstable_enableVersionedWrite:o})=>{let[i,s]=q({});K(()=>{let f=c.current;f.w&&(f.s[nl](null,i),delete i.p,f.v=i)},[i]);let c=$();if(!c.current){let f=YA(e,n);if(o){let u=0;f.w=d=>{s(m=>{let h=u?m:{p:m};return d(h),h})},f.v=i,f.r=d=>{++u,d(),--u}}c.current=f}let l=pv(r);return V(l.Provider,{value:c.current},t)},J7=0;function er(t,e){let r=`atom${++J7}`,n={toString:()=>r};return typeof t=="function"?n.read=t:(n.init=t,n.read=o=>o(n),n.write=(o,i,s)=>i(n,typeof s=="function"?s(o(n)):s)),e&&(n.write=e),n}function It(t,e){let r=pv(e),n=ne(r),{s:o,v:i}=n,s=m=>{let h=o[lv](t,m);if((_e.env&&_e.env.MODE)!=="production"&&!h.y)throw new Error("should not be invalidated");if("e"in h)throw h.e;if("p"in h)throw h.p;if("v"in h)return h.v;throw new Error("no atom value")},[[c,l,f],u]=un((m,h)=>{let y=s(h);return Object.is(m[1],y)&&m[2]===t?m:[h,y,t]},i,m=>{let h=s(m);return[m,h,t]}),d=l;return f!==t&&(u(c),d=s(c)),K(()=>{let{v:m}=n;m&&o[nl](t,m);let h=o[fv](t,u,m);return u(m),h},[o,t,n]),K(()=>{o[nl](t,c)}),Ci(d),d}function dv(t,e){let r=pv(e),{s:n,w:o}=ne(r);return ee(s=>{if((_e.env&&_e.env.MODE)!=="production"&&!("write"in t))throw new Error("not writable atom");let c=l=>n[uv](t,s,l);return o?o(c):c()},[n,o,t])}var CN=require("obsidian");_();a();var QA=()=>{let t=[];return{get:()=>t,set:(n,o)=>{t.push([n,o])}}};a();var Oo=er(null),mv=er(t=>{let{arch:e,platform:r,modules:n}=t(Oo).platform;return`better-sqlite3-${Gf}-electron-v${n}-${r}-${e}.tar.gz`}),ol=er(t=>`https://github.com/WiseLibs/better-sqlite3/releases/download/${Gf}/${t(mv)}`),B0e=er(t=>t(ol).replace("github.com","download.fastgit.org")),zp=er(()=>$s()),eR=er(t=>t(Oo).mode);a();var TN=Y(Ms(),1);a();a();a();_();var tR=function(t){return function(e,r){var n=$(!1);t(function(){return function(){n.current=!1}},[]),t(function(){if(!n.current)n.current=!0;else return e()},r)}};a();function Co(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),o,i=[],s;try{for(;(e===void 0||e-- >0)&&!(o=n.next()).done;)i.push(o.value)}catch(c){s={error:c}}finally{try{o&&!o.done&&(r=n.return)&&r.call(n)}finally{if(s)throw s.error}}return i}a();_();a();var il=function(t){return typeof t=="function"};var rR=function(t){return typeof t>"u"};a();var Y7=!1,nR=Y7;function X7(t){nR&&(il(t)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof t)));var e=$(t);e.current=ae(function(){return t},[t]);var r=$();return r.current||(r.current=function(){for(var n=[],o=0;o{let e=$(null);return[ee(n=>{e.current&&e.current.empty(),n&&(0,cR.setIcon)(n,t),e.current=n},[t])]};a();a();a();Ys();Ys();var tH=0;function g(t,e,r,n,o){var i,s,c={};for(s in e)s=="ref"?i=e[s]:c[s]=e[s];var l={type:t,props:c,key:r,ref:i,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,__h:null,constructor:void 0,__v:--tH,__source:o,__self:n};if(typeof t=="function"&&(i=t.defaultProps))for(s in i)c[s]===void 0&&(c[s]=i[s]);return z.vnode&&z.vnode(l),l}var sl=({name:t,desc:e,button:r,onClick:n,icon:o,className:i,...s})=>g("div",{className:ta("setting-item",i),...s,children:[o&&g("div",{className:"setting-icon",children:o}),g("div",{className:"setting-item-info",children:[g("div",{className:"setting-item-name",children:t}),g("div",{className:"setting-item-description",children:e})]}),g("div",{className:"setting-item-control",children:r&&g("button",{className:"mod-cta",onClick:n,children:r})})]});a();_();var rH=()=>g("svg",{className:"icon-blank svg-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",height:"32",width:"32"}),nH=()=>g("svg",{className:"icon-spin svg-icon",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",height:"32",width:"32",children:[g("path",{opacity:".25",d:"M16 0 A16 16 0 0 0 16 32 A16 16 0 0 0 16 0 M16 4 A12 12 0 0 1 16 28 A12 12 0 0 1 16 4"}),g("path",{d:"M16 0 A16 16 0 0 1 32 16 L28 16 A12 12 0 0 0 16 4z",children:g("animateTransform",{attributeName:"transform",type:"rotate",from:"0 16 16",to:"360 16 16",dur:"0.8s",repeatCount:"indefinite"})})]}),lR=({color:t="var(--icon-color, black)",delay:e=0,height:r=16,width:n=16,style:o,...i})=>{let[s,c]=q(e>0);return K(()=>{let l=-1;return s&&(l=window.setTimeout(()=>{c(!1)},e)),()=>{window.clearTimeout(l)}},[]),g("div",{style:{...o,fill:t,height:Number(r)||r,width:Number(n)||n},...i,children:s?g(rH,{}):g(nH,{})})};a();var gN=require("fs"),Ud=require("fs/promises"),yN=require("stream"),N0=require("stream/promises"),jK=require("@electron/remote");a();var Up=class extends Error{},yv=class extends Up{},bv=class extends Up{},oH=(t,e=",")=>t.join(e),iH={accept:"*",multiple:!1,strict:!1},uR=t=>{let{accept:e,multiple:r,strict:n}={...iH,...t},o=cH({multiple:r,accept:Array.isArray(e)?oH(e):e});return new Promise(i=>{o.onchange=()=>{i(sH(o.files,r,n)),o.remove()},o.click()})},sH=(t,e,r)=>new Promise((n,o)=>{if(!t)return o(new yv);let i=aH(t,e,r);if(!i)return o(new bv);n(i)}),aH=(t,e,r)=>!e&&r?t.length===1?t[0]:null:t.length?t:null,cH=({accept:t,multiple:e})=>{let r=document.createElement("input");return r.type="file",r.multiple=e,r.accept=t,r};var D0=require("obsidian");a();a();a();var gR=Y(require("events"),1),Tt=Y(require("fs"),1);a();var Jp=require("node:events"),_v=Y(require("node:stream"),1),hR=require("node:string_decoder"),fR=typeof process=="object"&&process?process:{stdout:null,stderr:null},lH=t=>!!t&&typeof t=="object"&&(t instanceof qt||t instanceof _v.default||uH(t)||fH(t)),uH=t=>!!t&&typeof t=="object"&&t instanceof Jp.EventEmitter&&typeof t.pipe=="function"&&t.pipe!==_v.default.Writable.prototype.pipe,fH=t=>!!t&&typeof t=="object"&&t instanceof Jp.EventEmitter&&typeof t.write=="function"&&typeof t.end=="function",Mn=Symbol("EOF"),$n=Symbol("maybeEmitEnd"),ko=Symbol("emittedEnd"),Wp=Symbol("emittingEnd"),al=Symbol("emittedError"),Hp=Symbol("closed"),pR=Symbol("read"),Kp=Symbol("flush"),dR=Symbol("flushChunk"),$r=Symbol("encoding"),ra=Symbol("decoder"),nt=Symbol("flowing"),cl=Symbol("paused"),na=Symbol("resume"),ot=Symbol("buffer"),_t=Symbol("pipes"),it=Symbol("bufferLength"),vv=Symbol("bufferPush"),Vp=Symbol("bufferShift"),bt=Symbol("objectMode"),Be=Symbol("destroyed"),wv=Symbol("error"),xv=Symbol("emitData"),mR=Symbol("emitEnd"),Ev=Symbol("emitEnd2"),pn=Symbol("async"),Sv=Symbol("abort"),Gp=Symbol("aborted"),ll=Symbol("signal"),ki=Symbol("dataListeners"),rr=Symbol("discarded"),ul=t=>Promise.resolve().then(t),pH=t=>t(),dH=t=>t==="end"||t==="finish"||t==="prefinish",mH=t=>t instanceof ArrayBuffer||!!t&&typeof t=="object"&&t.constructor&&t.constructor.name==="ArrayBuffer"&&t.byteLength>=0,hH=t=>!Buffer.isBuffer(t)&&ArrayBuffer.isView(t),Zp=class{src;dest;opts;ondrain;constructor(e,r,n){this.src=e,this.dest=r,this.opts=n,this.ondrain=()=>e[na](),this.dest.on("drain",this.ondrain)}unpipe(){this.dest.removeListener("drain",this.ondrain)}proxyErrors(e){}end(){this.unpipe(),this.opts.end&&this.dest.end()}},Iv=class extends Zp{unpipe(){this.src.removeListener("error",this.proxyErrors),super.unpipe()}constructor(e,r,n){super(e,r,n),this.proxyErrors=o=>r.emit("error",o),e.on("error",this.proxyErrors)}},gH=t=>!!t.objectMode,yH=t=>!t.objectMode&&!!t.encoding&&t.encoding!=="buffer",qt=class extends Jp.EventEmitter{[nt]=!1;[cl]=!1;[_t]=[];[ot]=[];[bt];[$r];[pn];[ra];[Mn]=!1;[ko]=!1;[Wp]=!1;[Hp]=!1;[al]=null;[it]=0;[Be]=!1;[ll];[Gp]=!1;[ki]=0;[rr]=!1;writable=!0;readable=!0;constructor(...e){let r=e[0]||{};if(super(),r.objectMode&&typeof r.encoding=="string")throw new TypeError("Encoding and objectMode may not be used together");gH(r)?(this[bt]=!0,this[$r]=null):yH(r)?(this[$r]=r.encoding,this[bt]=!1):(this[bt]=!1,this[$r]=null),this[pn]=!!r.async,this[ra]=this[$r]?new hR.StringDecoder(this[$r]):null,r&&r.debugExposeBuffer===!0&&Object.defineProperty(this,"buffer",{get:()=>this[ot]}),r&&r.debugExposePipes===!0&&Object.defineProperty(this,"pipes",{get:()=>this[_t]});let{signal:n}=r;n&&(this[ll]=n,n.aborted?this[Sv]():n.addEventListener("abort",()=>this[Sv]()))}get bufferLength(){return this[it]}get encoding(){return this[$r]}set encoding(e){throw new Error("Encoding must be set at instantiation time")}setEncoding(e){throw new Error("Encoding must be set at instantiation time")}get objectMode(){return this[bt]}set objectMode(e){throw new Error("objectMode must be set at instantiation time")}get async(){return this[pn]}set async(e){this[pn]=this[pn]||!!e}[Sv](){this[Gp]=!0,this.emit("abort",this[ll]?.reason),this.destroy(this[ll]?.reason)}get aborted(){return this[Gp]}set aborted(e){}write(e,r,n){if(this[Gp])return!1;if(this[Mn])throw new Error("write after end");if(this[Be])return this.emit("error",Object.assign(new Error("Cannot call write after a stream was destroyed"),{code:"ERR_STREAM_DESTROYED"})),!0;typeof r=="function"&&(n=r,r="utf8"),r||(r="utf8");let o=this[pn]?ul:pH;if(!this[bt]&&!Buffer.isBuffer(e)){if(hH(e))e=Buffer.from(e.buffer,e.byteOffset,e.byteLength);else if(mH(e))e=Buffer.from(e);else if(typeof e!="string")throw new Error("Non-contiguous data written to non-objectMode stream")}return this[bt]?(this[nt]&&this[it]!==0&&this[Kp](!0),this[nt]?this.emit("data",e):this[vv](e),this[it]!==0&&this.emit("readable"),n&&o(n),this[nt]):e.length?(typeof e=="string"&&!(r===this[$r]&&!this[ra]?.lastNeed)&&(e=Buffer.from(e,r)),Buffer.isBuffer(e)&&this[$r]&&(e=this[ra].write(e)),this[nt]&&this[it]!==0&&this[Kp](!0),this[nt]?this.emit("data",e):this[vv](e),this[it]!==0&&this.emit("readable"),n&&o(n),this[nt]):(this[it]!==0&&this.emit("readable"),n&&o(n),this[nt])}read(e){if(this[Be])return null;if(this[rr]=!1,this[it]===0||e===0||e&&e>this[it])return this[$n](),null;this[bt]&&(e=null),this[ot].length>1&&!this[bt]&&(this[ot]=[this[$r]?this[ot].join(""):Buffer.concat(this[ot],this[it])]);let r=this[pR](e||null,this[ot][0]);return this[$n](),r}[pR](e,r){if(this[bt])this[Vp]();else{let n=r;e===n.length||e===null?this[Vp]():typeof n=="string"?(this[ot][0]=n.slice(e),r=n.slice(0,e),this[it]-=e):(this[ot][0]=n.subarray(e),r=n.subarray(0,e),this[it]-=e)}return this.emit("data",r),!this[ot].length&&!this[Mn]&&this.emit("drain"),r}end(e,r,n){return typeof e=="function"&&(n=e,e=void 0),typeof r=="function"&&(n=r,r="utf8"),e!==void 0&&this.write(e,r),n&&this.once("end",n),this[Mn]=!0,this.writable=!1,(this[nt]||!this[cl])&&this[$n](),this}[na](){this[Be]||(!this[ki]&&!this[_t].length&&(this[rr]=!0),this[cl]=!1,this[nt]=!0,this.emit("resume"),this[ot].length?this[Kp]():this[Mn]?this[$n]():this.emit("drain"))}resume(){return this[na]()}pause(){this[nt]=!1,this[cl]=!0,this[rr]=!1}get destroyed(){return this[Be]}get flowing(){return this[nt]}get paused(){return this[cl]}[vv](e){this[bt]?this[it]+=1:this[it]+=e.length,this[ot].push(e)}[Vp](){return this[bt]?this[it]-=1:this[it]-=this[ot][0].length,this[ot].shift()}[Kp](e=!1){do;while(this[dR](this[Vp]())&&this[ot].length);!e&&!this[ot].length&&!this[Mn]&&this.emit("drain")}[dR](e){return this.emit("data",e),this[nt]}pipe(e,r){if(this[Be])return e;this[rr]=!1;let n=this[ko];return r=r||{},e===fR.stdout||e===fR.stderr?r.end=!1:r.end=r.end!==!1,r.proxyErrors=!!r.proxyErrors,n?r.end&&e.end():(this[_t].push(r.proxyErrors?new Iv(this,e,r):new Zp(this,e,r)),this[pn]?ul(()=>this[na]()):this[na]()),e}unpipe(e){let r=this[_t].find(n=>n.dest===e);r&&(this[_t].length===1?(this[nt]&&this[ki]===0&&(this[nt]=!1),this[_t]=[]):this[_t].splice(this[_t].indexOf(r),1),r.unpipe())}addListener(e,r){return this.on(e,r)}on(e,r){let n=super.on(e,r);if(e==="data")this[rr]=!1,this[ki]++,!this[_t].length&&!this[nt]&&this[na]();else if(e==="readable"&&this[it]!==0)super.emit("readable");else if(dH(e)&&this[ko])super.emit(e),this.removeAllListeners(e);else if(e==="error"&&this[al]){let o=r;this[pn]?ul(()=>o.call(this,this[al])):o.call(this,this[al])}return n}removeListener(e,r){return this.off(e,r)}off(e,r){let n=super.off(e,r);return e==="data"&&(this[ki]=this.listeners("data").length,this[ki]===0&&!this[rr]&&!this[_t].length&&(this[nt]=!1)),n}removeAllListeners(e){let r=super.removeAllListeners(e);return(e==="data"||e===void 0)&&(this[ki]=0,!this[rr]&&!this[_t].length&&(this[nt]=!1)),r}get emittedEnd(){return this[ko]}[$n](){!this[Wp]&&!this[ko]&&!this[Be]&&this[ot].length===0&&this[Mn]&&(this[Wp]=!0,this.emit("end"),this.emit("prefinish"),this.emit("finish"),this[Hp]&&this.emit("close"),this[Wp]=!1)}emit(e,...r){let n=r[0];if(e!=="error"&&e!=="close"&&e!==Be&&this[Be])return!1;if(e==="data")return!this[bt]&&!n?!1:this[pn]?(ul(()=>this[xv](n)),!0):this[xv](n);if(e==="end")return this[mR]();if(e==="close"){if(this[Hp]=!0,!this[ko]&&!this[Be])return!1;let i=super.emit("close");return this.removeAllListeners("close"),i}else if(e==="error"){this[al]=n,super.emit(wv,n);let i=!this[ll]||this.listeners("error").length?super.emit("error",n):!1;return this[$n](),i}else if(e==="resume"){let i=super.emit("resume");return this[$n](),i}else if(e==="finish"||e==="prefinish"){let i=super.emit(e);return this.removeAllListeners(e),i}let o=super.emit(e,...r);return this[$n](),o}[xv](e){for(let n of this[_t])n.dest.write(e)===!1&&this.pause();let r=this[rr]?!1:super.emit("data",e);return this[$n](),r}[mR](){return this[ko]?!1:(this[ko]=!0,this.readable=!1,this[pn]?(ul(()=>this[Ev]()),!0):this[Ev]())}[Ev](){if(this[ra]){let r=this[ra].end();if(r){for(let n of this[_t])n.dest.write(r);this[rr]||super.emit("data",r)}}for(let r of this[_t])r.end();let e=super.emit("end");return this.removeAllListeners("end"),e}async collect(){let e=Object.assign([],{dataLength:0});this[bt]||(e.dataLength=0);let r=this.promise();return this.on("data",n=>{e.push(n),this[bt]||(e.dataLength+=n.length)}),await r,e}async concat(){if(this[bt])throw new Error("cannot concat in objectMode");let e=await this.collect();return this[$r]?e.join(""):Buffer.concat(e,e.dataLength)}async promise(){return new Promise((e,r)=>{this.on(Be,()=>r(new Error("stream destroyed"))),this.on("error",n=>r(n)),this.on("end",()=>e())})}[Symbol.asyncIterator](){this[rr]=!1;let e=!1,r=async()=>(this.pause(),e=!0,{value:void 0,done:!0});return{next:()=>{if(e)return r();let o=this.read();if(o!==null)return Promise.resolve({done:!1,value:o});if(this[Mn])return r();let i,s,c=d=>{this.off("data",l),this.off("end",f),this.off(Be,u),r(),s(d)},l=d=>{this.off("error",c),this.off("end",f),this.off(Be,u),this.pause(),i({value:d,done:!!this[Mn]})},f=()=>{this.off("error",c),this.off("data",l),this.off(Be,u),r(),i({done:!0,value:void 0})},u=()=>c(new Error("stream destroyed"));return new Promise((d,m)=>{s=m,i=d,this.once(Be,u),this.once("error",c),this.once("end",f),this.once("data",l)})},throw:r,return:r,[Symbol.asyncIterator](){return this}}}[Symbol.iterator](){this[rr]=!1;let e=!1,r=()=>(this.pause(),this.off(wv,r),this.off(Be,r),this.off("end",r),e=!0,{done:!0,value:void 0}),n=()=>{if(e)return r();let o=this.read();return o===null?r():{done:!1,value:o}};return this.once("end",r),this.once(wv,r),this.once(Be,r),{next:n,throw:r,return:r,[Symbol.iterator](){return this}}}destroy(e){if(this[Be])return e?this.emit("error",e):this.emit(Be),this;this[Be]=!0,this[rr]=!0,this[ot].length=0,this[it]=0;let r=this;return typeof r.close=="function"&&!this[Hp]&&r.close(),e?this.emit("error",e):this.emit(Be),this}static get isStream(){return lH}};var bH=Tt.default.writev,Ro=Symbol("_autoClose"),jr=Symbol("_close"),fl=Symbol("_ended"),ve=Symbol("_fd"),Tv=Symbol("_finished"),jn=Symbol("_flags"),Ov=Symbol("_flush"),Rv=Symbol("_handleChunk"),Nv=Symbol("_makeBuf"),dl=Symbol("_mode"),Yp=Symbol("_needDrain"),sa=Symbol("_onerror"),aa=Symbol("_onopen"),Cv=Symbol("_onread"),oa=Symbol("_onwrite"),No=Symbol("_open"),Lr=Symbol("_path"),Ao=Symbol("_pos"),dn=Symbol("_queue"),ia=Symbol("_read"),kv=Symbol("_readSize"),Ln=Symbol("_reading"),pl=Symbol("_remain"),Av=Symbol("_size"),Xp=Symbol("_write"),Ai=Symbol("_writing"),Qp=Symbol("_defaultFlag"),Ri=Symbol("_errored"),Ni=class extends qt{[Ri]=!1;[ve];[Lr];[kv];[Ln]=!1;[Av];[pl];[Ro];constructor(e,r){if(r=r||{},super(r),this.readable=!0,this.writable=!1,typeof e!="string")throw new TypeError("path must be a string");this[Ri]=!1,this[ve]=typeof r.fd=="number"?r.fd:void 0,this[Lr]=e,this[kv]=r.readSize||16*1024*1024,this[Ln]=!1,this[Av]=typeof r.size=="number"?r.size:1/0,this[pl]=this[Av],this[Ro]=typeof r.autoClose=="boolean"?r.autoClose:!0,typeof this[ve]=="number"?this[ia]():this[No]()}get fd(){return this[ve]}get path(){return this[Lr]}write(){throw new TypeError("this is a readable stream")}end(){throw new TypeError("this is a readable stream")}[No](){Tt.default.open(this[Lr],"r",(e,r)=>this[aa](e,r))}[aa](e,r){e?this[sa](e):(this[ve]=r,this.emit("open",r),this[ia]())}[Nv](){return Buffer.allocUnsafe(Math.min(this[kv],this[pl]))}[ia](){if(!this[Ln]){this[Ln]=!0;let e=this[Nv]();if(e.length===0)return process.nextTick(()=>this[Cv](null,0,e));Tt.default.read(this[ve],e,0,e.length,null,(r,n,o)=>this[Cv](r,n,o))}}[Cv](e,r,n){this[Ln]=!1,e?this[sa](e):this[Rv](r,n)&&this[ia]()}[jr](){if(this[Ro]&&typeof this[ve]=="number"){let e=this[ve];this[ve]=void 0,Tt.default.close(e,r=>r?this.emit("error",r):this.emit("close"))}}[sa](e){this[Ln]=!0,this[jr](),this.emit("error",e)}[Rv](e,r){let n=!1;return this[pl]-=e,e>0&&(n=super.write(ethis[aa](e,r))}[aa](e,r){this[Qp]&&this[jn]==="r+"&&e&&e.code==="ENOENT"?(this[jn]="w",this[No]()):e?this[sa](e):(this[ve]=r,this.emit("open",r),this[Ai]||this[Ov]())}end(e,r){return e&&this.write(e,r),this[fl]=!0,!this[Ai]&&!this[dn].length&&typeof this[ve]=="number"&&this[oa](null,0),this}write(e,r){return typeof e=="string"&&(e=Buffer.from(e,r)),this[fl]?(this.emit("error",new Error("write() after end()")),!1):this[ve]===void 0||this[Ai]||this[dn].length?(this[dn].push(e),this[Yp]=!0,!1):(this[Ai]=!0,this[Xp](e),!0)}[Xp](e){Tt.default.write(this[ve],e,0,e.length,this[Ao],(r,n)=>this[oa](r,n))}[oa](e,r){e?this[sa](e):(this[Ao]!==void 0&&typeof r=="number"&&(this[Ao]+=r),this[dn].length?this[Ov]():(this[Ai]=!1,this[fl]&&!this[Tv]?(this[Tv]=!0,this[jr](),this.emit("finish")):this[Yp]&&(this[Yp]=!1,this.emit("drain"))))}[Ov](){if(this[dn].length===0)this[fl]&&this[oa](null,0);else if(this[dn].length===1)this[Xp](this[dn].pop());else{let e=this[dn];this[dn]=[],bH(this[ve],e,this[Ao],(r,n)=>this[oa](r,n))}}[jr](){if(this[Ro]&&typeof this[ve]=="number"){let e=this[ve];this[ve]=void 0,Tt.default.close(e,r=>r?this.emit("error",r):this.emit("close"))}}},ca=class extends qn{[No](){let e;if(this[Qp]&&this[jn]==="r+")try{e=Tt.default.openSync(this[Lr],this[jn],this[dl])}catch(r){if(r?.code==="ENOENT")return this[jn]="w",this[No]();throw r}else e=Tt.default.openSync(this[Lr],this[jn],this[dl]);this[aa](null,e)}[jr](){if(this[Ro]&&typeof this[ve]=="number"){let e=this[ve];this[ve]=void 0,Tt.default.closeSync(e),this.emit("close")}}[Xp](e){let r=!0;try{this[oa](null,Tt.default.writeSync(this[ve],e,0,e.length,this[Ao])),r=!1}finally{if(r)try{this[jr]()}catch{}}}};var a0=Y(require("node:path"),1);a();var Bi=Y(require("node:fs"),1),yd=require("path");a();a();var vH=new Map([["C","cwd"],["f","file"],["z","gzip"],["P","preservePaths"],["U","unlink"],["strip-components","strip"],["stripComponents","strip"],["keep-newer","newer"],["keepNewer","newer"],["keep-newer-files","newer"],["keepNewerFiles","newer"],["k","keep"],["keep-existing","keep"],["keepExisting","keep"],["m","noMtime"],["no-mtime","noMtime"],["p","preserveOwner"],["L","follow"],["h","follow"],["onentry","onReadEntry"]]),yR=t=>!!t.sync&&!!t.file,bR=t=>!t.sync&&!!t.file,vR=t=>!!t.sync&&!t.file,wR=t=>!t.sync&&!t.file;var xR=t=>!!t.file;var wH=t=>{let e=vH.get(t);return e||t},ml=(t={})=>{if(!t)return{};let e={};for(let[r,n]of Object.entries(t)){let o=wH(r);e[o]=n}return e.chmod===void 0&&e.noChmod===!1&&(e.chmod=!0),delete e.noChmod,e};var mn=(t,e,r,n,o)=>Object.assign((i=[],s,c)=>{Array.isArray(i)&&(s=i,i={}),typeof s=="function"&&(c=s,s=void 0),s?s=Array.from(s):s=[];let l=ml(i);if(o?.(l,s),yR(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return t(l,s)}else if(bR(l)){let f=e(l,s),u=c||void 0;return u?f.then(()=>u(),u):f}else if(vR(l)){if(typeof c=="function")throw new TypeError("callback not supported for sync tar functions");return r(l,s)}else if(wR(l)){if(typeof c=="function")throw new TypeError("callback only supported with file option");return n(l,s)}else throw new Error("impossible options??")},{syncFile:t,asyncFile:e,syncNoFile:r,asyncNoFile:n,validate:o});a();var $R=require("events");a();var td=Y(require("assert"),1),zn=require("buffer");var IR=Y(require("zlib"),1);a();var ER=Y(require("zlib"),1),xH=ER.default.constants||{ZLIB_VERNUM:4736},Bn=Object.freeze(Object.assign(Object.create(null),{Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_VERSION_ERROR:-6,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,DEFLATE:1,INFLATE:2,GZIP:3,GUNZIP:4,DEFLATERAW:5,INFLATERAW:6,UNZIP:7,BROTLI_DECODE:8,BROTLI_ENCODE:9,Z_MIN_WINDOWBITS:8,Z_MAX_WINDOWBITS:15,Z_DEFAULT_WINDOWBITS:15,Z_MIN_CHUNK:64,Z_MAX_CHUNK:1/0,Z_DEFAULT_CHUNK:16384,Z_MIN_MEMLEVEL:1,Z_MAX_MEMLEVEL:9,Z_DEFAULT_MEMLEVEL:8,Z_MIN_LEVEL:-1,Z_MAX_LEVEL:9,Z_DEFAULT_LEVEL:-1,BROTLI_OPERATION_PROCESS:0,BROTLI_OPERATION_FLUSH:1,BROTLI_OPERATION_FINISH:2,BROTLI_OPERATION_EMIT_METADATA:3,BROTLI_MODE_GENERIC:0,BROTLI_MODE_TEXT:1,BROTLI_MODE_FONT:2,BROTLI_DEFAULT_MODE:0,BROTLI_MIN_QUALITY:0,BROTLI_MAX_QUALITY:11,BROTLI_DEFAULT_QUALITY:11,BROTLI_MIN_WINDOW_BITS:10,BROTLI_MAX_WINDOW_BITS:24,BROTLI_LARGE_MAX_WINDOW_BITS:30,BROTLI_DEFAULT_WINDOW:22,BROTLI_MIN_INPUT_BLOCK_BITS:16,BROTLI_MAX_INPUT_BLOCK_BITS:24,BROTLI_PARAM_MODE:0,BROTLI_PARAM_QUALITY:1,BROTLI_PARAM_LGWIN:2,BROTLI_PARAM_LGBLOCK:3,BROTLI_PARAM_DISABLE_LITERAL_CONTEXT_MODELING:4,BROTLI_PARAM_SIZE_HINT:5,BROTLI_PARAM_LARGE_WINDOW:6,BROTLI_PARAM_NPOSTFIX:7,BROTLI_PARAM_NDIRECT:8,BROTLI_DECODER_RESULT_ERROR:0,BROTLI_DECODER_RESULT_SUCCESS:1,BROTLI_DECODER_RESULT_NEEDS_MORE_INPUT:2,BROTLI_DECODER_RESULT_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_PARAM_DISABLE_RING_BUFFER_REALLOCATION:0,BROTLI_DECODER_PARAM_LARGE_WINDOW:1,BROTLI_DECODER_NO_ERROR:0,BROTLI_DECODER_SUCCESS:1,BROTLI_DECODER_NEEDS_MORE_INPUT:2,BROTLI_DECODER_NEEDS_MORE_OUTPUT:3,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_NIBBLE:-1,BROTLI_DECODER_ERROR_FORMAT_RESERVED:-2,BROTLI_DECODER_ERROR_FORMAT_EXUBERANT_META_NIBBLE:-3,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_ALPHABET:-4,BROTLI_DECODER_ERROR_FORMAT_SIMPLE_HUFFMAN_SAME:-5,BROTLI_DECODER_ERROR_FORMAT_CL_SPACE:-6,BROTLI_DECODER_ERROR_FORMAT_HUFFMAN_SPACE:-7,BROTLI_DECODER_ERROR_FORMAT_CONTEXT_MAP_REPEAT:-8,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_1:-9,BROTLI_DECODER_ERROR_FORMAT_BLOCK_LENGTH_2:-10,BROTLI_DECODER_ERROR_FORMAT_TRANSFORM:-11,BROTLI_DECODER_ERROR_FORMAT_DICTIONARY:-12,BROTLI_DECODER_ERROR_FORMAT_WINDOW_BITS:-13,BROTLI_DECODER_ERROR_FORMAT_PADDING_1:-14,BROTLI_DECODER_ERROR_FORMAT_PADDING_2:-15,BROTLI_DECODER_ERROR_FORMAT_DISTANCE:-16,BROTLI_DECODER_ERROR_DICTIONARY_NOT_SET:-19,BROTLI_DECODER_ERROR_INVALID_ARGUMENTS:-20,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MODES:-21,BROTLI_DECODER_ERROR_ALLOC_TREE_GROUPS:-22,BROTLI_DECODER_ERROR_ALLOC_CONTEXT_MAP:-25,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_1:-26,BROTLI_DECODER_ERROR_ALLOC_RING_BUFFER_2:-27,BROTLI_DECODER_ERROR_ALLOC_BLOCK_TYPE_TREES:-30,BROTLI_DECODER_ERROR_UNREACHABLE:-31},xH));var SR=zn.Buffer.concat,Di=Symbol("_superWrite"),la=class extends Error{code;errno;constructor(e){super("zlib: "+e.message),this.code=e.code,this.errno=e.errno,this.code||(this.code="ZLIB_ERROR"),this.message="zlib: "+e.message,Error.captureStackTrace(this,this.constructor)}get name(){return"ZlibError"}},Pv=Symbol("flushFlag"),rd=class extends qt{#e=!1;#t=!1;#n;#o;#i;#r;#s;get sawError(){return this.#e}get handle(){return this.#r}get flushFlag(){return this.#n}constructor(e,r){if(!e||typeof e!="object")throw new TypeError("invalid options for ZlibBase constructor");super(e),this.#n=e.flush??0,this.#o=e.finishFlush??0,this.#i=e.fullFlushFlag??0;try{this.#r=new IR.default[r](e)}catch(n){throw new la(n)}this.#s=n=>{this.#e||(this.#e=!0,this.close(),this.emit("error",n))},this.#r?.on("error",n=>this.#s(new la(n))),this.once("end",()=>this.close)}close(){this.#r&&(this.#r.close(),this.#r=void 0,this.emit("close"))}reset(){if(!this.#e)return(0,td.default)(this.#r,"zlib binding closed"),this.#r.reset?.()}flush(e){this.ended||(typeof e!="number"&&(e=this.#i),this.write(Object.assign(zn.Buffer.alloc(0),{[Pv]:e})))}end(e,r,n){return typeof e=="function"&&(n=e,r=void 0,e=void 0),typeof r=="function"&&(n=r,r=void 0),e&&(r?this.write(e,r):this.write(e)),this.flush(this.#o),this.#t=!0,super.end(n)}get ended(){return this.#t}[Di](e){return super.write(e)}write(e,r,n){if(typeof r=="function"&&(n=r,r="utf8"),typeof e=="string"&&(e=zn.Buffer.from(e,r)),this.#e)return;(0,td.default)(this.#r,"zlib binding closed");let o=this.#r._handle,i=o.close;o.close=()=>{};let s=this.#r.close;this.#r.close=()=>{},zn.Buffer.concat=f=>f;let c;try{let f=typeof e[Pv]=="number"?e[Pv]:this.#n;c=this.#r._processChunk(e,f),zn.Buffer.concat=SR}catch(f){zn.Buffer.concat=SR,this.#s(new la(f))}finally{this.#r&&(this.#r._handle=o,o.close=i,this.#r.close=s,this.#r.removeAllListeners("error"))}this.#r&&this.#r.on("error",f=>this.#s(new la(f)));let l;if(c)if(Array.isArray(c)&&c.length>0){let f=c[0];l=this[Di](zn.Buffer.from(f));for(let u=1;u{typeof o=="function"&&(i=o,o=this.flushFlag),this.flush(o),i?.()};try{this.handle.params(e,r)}finally{this.handle.flush=n}this.handle&&(this.#e=e,this.#t=r)}}}};var od=class extends nd{#e;constructor(e){super(e,"Gzip"),this.#e=e&&!!e.portable}[Di](e){return this.#e?(this.#e=!1,e[9]=255,super[Di](e)):super[Di](e)}};var id=class extends nd{constructor(e){super(e,"Unzip")}},sd=class extends rd{constructor(e,r){e=e||{},e.flush=e.flush||Bn.BROTLI_OPERATION_PROCESS,e.finishFlush=e.finishFlush||Bn.BROTLI_OPERATION_FINISH,e.fullFlushFlag=Bn.BROTLI_OPERATION_FLUSH,super(e,r)}},ad=class extends sd{constructor(e){super(e,"BrotliCompress")}},cd=class extends sd{constructor(e){super(e,"BrotliDecompress")}};a();var xr=class{tail;head;length=0;static create(e=[]){return new xr(e)}constructor(e=[]){for(let r of e)this.push(r)}*[Symbol.iterator](){for(let e=this.head;e;e=e.next)yield e.value}removeNode(e){if(e.list!==this)throw new Error("removing node which does not belong to this list");let r=e.next,n=e.prev;return r&&(r.prev=n),n&&(n.next=r),e===this.head&&(this.head=r),e===this.tail&&(this.tail=n),this.length--,e.next=void 0,e.prev=void 0,e.list=void 0,r}unshiftNode(e){if(e===this.head)return;e.list&&e.list.removeNode(e);let r=this.head;e.list=this,e.next=r,r&&(r.prev=e),this.head=e,this.tail||(this.tail=e),this.length++}pushNode(e){if(e===this.tail)return;e.list&&e.list.removeNode(e);let r=this.tail;e.list=this,e.prev=r,r&&(r.next=e),this.tail=e,this.head||(this.head=e),this.length++}push(...e){for(let r=0,n=e.length;r1)n=r;else if(this.head)o=this.head.next,n=this.head.value;else throw new TypeError("Reduce of empty list with no initial value");for(var i=0;o;i++)n=e(n,o.value,i),o=o.next;return n}reduceReverse(e,r){let n,o=this.tail;if(arguments.length>1)n=r;else if(this.tail)o=this.tail.prev,n=this.tail.value;else throw new TypeError("Reduce of empty list with no initial value");for(let i=this.length-1;o;i--)n=e(n,o.value,i),o=o.prev;return n}toArray(){let e=new Array(this.length);for(let r=0,n=this.head;n;r++)e[r]=n.value,n=n.next;return e}toArrayReverse(){let e=new Array(this.length);for(let r=0,n=this.tail;n;r++)e[r]=n.value,n=n.prev;return e}slice(e=0,r=this.length){r<0&&(r+=this.length),e<0&&(e+=this.length);let n=new xr;if(rthis.length&&(r=this.length);let o=this.head,i=0;for(i=0;o&&ithis.length&&(r=this.length);let o=this.length,i=this.tail;for(;i&&o>r;o--)i=i.prev;for(;i&&o>e;o--,i=i.prev)n.push(i.value);return n}splice(e,r=0,...n){e>this.length&&(e=this.length-1),e<0&&(e=this.length+e);let o=this.head;for(let s=0;o&&s{if(Number.isSafeInteger(t))t<0?OH(t,e):TH(t,e);else throw Error("cannot encode number outside of javascript safe integer range");return e},TH=(t,e)=>{e[0]=128;for(var r=e.length;r>1;r--)e[r-1]=t&255,t=Math.floor(t/256)},OH=(t,e)=>{e[0]=255;var r=!1;t=t*-1;for(var n=e.length;n>1;n--){var o=t&255;t=Math.floor(t/256),r?e[n-1]=OR(o):o===0?e[n-1]=0:(r=!0,e[n-1]=CR(o))}},TR=t=>{let e=t[0],r=e===128?kH(t.subarray(1,t.length)):e===255?CH(t):null;if(r===null)throw Error("invalid base256 encoding");if(!Number.isSafeInteger(r))throw Error("parsed number outside of javascript safe integer range");return r},CH=t=>{for(var e=t.length,r=0,n=!1,o=e-1;o>-1;o--){var i=Number(t[o]),s;n?s=OR(i):i===0?s=i:(n=!0,s=CR(i)),s!==0&&(r-=s*Math.pow(256,e-o-1))}return r},kH=t=>{for(var e=t.length,r=0,n=e-1;n>-1;n--){var o=Number(t[n]);o!==0&&(r+=o*Math.pow(256,e-n-1))}return r},OR=t=>(255^t)&255,CR=t=>(255^t)+1&255;a();var ld=t=>ud.has(t);var ud=new Map([["0","File"],["","OldFile"],["1","Link"],["2","SymbolicLink"],["3","CharacterDevice"],["4","BlockDevice"],["5","Directory"],["6","FIFO"],["7","ContiguousFile"],["g","GlobalExtendedHeader"],["x","ExtendedHeader"],["A","SolarisACL"],["D","GNUDumpDir"],["I","Inode"],["K","NextFileHasLongLinkpath"],["L","NextFileHasLongPath"],["M","ContinuationFile"],["N","OldGnuLongPath"],["S","SparseFile"],["V","TapeVolumeHeader"],["X","OldExtendedHeader"]]),kR=new Map(Array.from(ud).map(t=>[t[1],t[0]]));var nr=class{cksumValid=!1;needPax=!1;nullBlock=!1;block;path;mode;uid;gid;size;cksum;#e="Unsupported";linkpath;uname;gname;devmaj=0;devmin=0;atime;ctime;mtime;charset;comment;constructor(e,r=0,n,o){Buffer.isBuffer(e)?this.decode(e,r||0,n,o):e&&this.#t(e)}decode(e,r,n,o){if(r||(r=0),!e||!(e.length>=r+512))throw new Error("need 512 bytes for header");this.path=Pi(e,r,100),this.mode=Do(e,r+100,8),this.uid=Do(e,r+108,8),this.gid=Do(e,r+116,8),this.size=Do(e,r+124,12),this.mtime=Fv(e,r+136,12),this.cksum=Do(e,r+148,12),o&&this.#t(o,!0),n&&this.#t(n);let i=Pi(e,r+156,1);if(ld(i)&&(this.#e=i||"0"),this.#e==="0"&&this.path.slice(-1)==="/"&&(this.#e="5"),this.#e==="5"&&(this.size=0),this.linkpath=Pi(e,r+157,100),e.subarray(r+257,r+265).toString()==="ustar\x0000")if(this.uname=Pi(e,r+265,32),this.gname=Pi(e,r+297,32),this.devmaj=Do(e,r+329,8)??0,this.devmin=Do(e,r+337,8)??0,e[r+475]!==0){let c=Pi(e,r+345,155);this.path=c+"/"+this.path}else{let c=Pi(e,r+345,130);c&&(this.path=c+"/"+this.path),this.atime=Fv(e,r+476,12),this.ctime=Fv(e,r+488,12)}let s=8*32;for(let c=r;c!(o==null||n==="path"&&r||n==="linkpath"&&r||n==="global"))))}encode(e,r=0){if(e||(e=this.block=Buffer.alloc(512)),this.#e==="Unsupported"&&(this.#e="0"),!(e.length>=r+512))throw new Error("need 512 bytes for header");let n=this.ctime||this.atime?130:155,o=RH(this.path||"",n),i=o[0],s=o[1];this.needPax=!!o[2],this.needPax=Fi(e,r,100,i)||this.needPax,this.needPax=Po(e,r+100,8,this.mode)||this.needPax,this.needPax=Po(e,r+108,8,this.uid)||this.needPax,this.needPax=Po(e,r+116,8,this.gid)||this.needPax,this.needPax=Po(e,r+124,12,this.size)||this.needPax,this.needPax=Mv(e,r+136,12,this.mtime)||this.needPax,e[r+156]=this.#e.charCodeAt(0),this.needPax=Fi(e,r+157,100,this.linkpath)||this.needPax,e.write("ustar\x0000",r+257,8),this.needPax=Fi(e,r+265,32,this.uname)||this.needPax,this.needPax=Fi(e,r+297,32,this.gname)||this.needPax,this.needPax=Po(e,r+329,8,this.devmaj)||this.needPax,this.needPax=Po(e,r+337,8,this.devmin)||this.needPax,this.needPax=Fi(e,r+345,n,s)||this.needPax,e[r+475]!==0?this.needPax=Fi(e,r+345,155,s)||this.needPax:(this.needPax=Fi(e,r+345,130,s)||this.needPax,this.needPax=Mv(e,r+476,12,this.atime)||this.needPax,this.needPax=Mv(e,r+488,12,this.ctime)||this.needPax);let c=8*32;for(let l=r;l{let n=t,o="",i,s=Mi.posix.parse(t).root||".";if(Buffer.byteLength(n)<100)i=[n,o,!1];else{o=Mi.posix.dirname(n),n=Mi.posix.basename(n);do Buffer.byteLength(n)<=100&&Buffer.byteLength(o)<=e?i=[n,o,!1]:Buffer.byteLength(n)>100&&Buffer.byteLength(o)<=e?i=[n.slice(0,100-1),o,!0]:(n=Mi.posix.join(Mi.posix.basename(o),n),o=Mi.posix.dirname(o));while(o!==s&&i===void 0);i||(i=[t.slice(0,100-1),"",!0])}return i},Pi=(t,e,r)=>t.subarray(e,e+r).toString("utf8").replace(/\0.*/,""),Fv=(t,e,r)=>NH(Do(t,e,r)),NH=t=>t===void 0?void 0:new Date(t*1e3),Do=(t,e,r)=>Number(t[e])&128?TR(t.subarray(e,e+r)):PH(t,e,r),DH=t=>isNaN(t)?void 0:t,PH=(t,e,r)=>DH(parseInt(t.subarray(e,e+r).toString("utf8").replace(/\0.*$/,"").trim(),8)),FH={12:8589934591,8:2097151},Po=(t,e,r,n)=>n===void 0?!1:n>FH[r]||n<0?(_R(n,t.subarray(e,e+r)),!0):(MH(t,e,r,n),!1),MH=(t,e,r,n)=>t.write($H(n,r),e,r,"ascii"),$H=(t,e)=>LH(Math.floor(t).toString(8),e),LH=(t,e)=>(t.length===e-1?t:new Array(e-t.length-1).join("0")+t+" ")+"\0",Mv=(t,e,r,n)=>n===void 0?!1:Po(t,e,r,n.getTime()/1e3),jH=new Array(156).join("\0"),Fi=(t,e,r,n)=>n===void 0?!1:(t.write(n+jH,e,r,"utf8"),n.length!==Buffer.byteLength(n)||n.length>r);a();var RR=require("node:path");var hn=class{atime;mtime;ctime;charset;comment;gid;uid;gname;uname;linkpath;dev;ino;nlink;path;size;mode;global;constructor(e,r=!1){this.atime=e.atime,this.charset=e.charset,this.comment=e.comment,this.ctime=e.ctime,this.dev=e.dev,this.gid=e.gid,this.global=r,this.gname=e.gname,this.ino=e.ino,this.linkpath=e.linkpath,this.mtime=e.mtime,this.nlink=e.nlink,this.path=e.path,this.size=e.size,this.uid=e.uid,this.uname=e.uname}encode(){let e=this.encodeBody();if(e==="")return Buffer.allocUnsafe(0);let r=Buffer.byteLength(e),n=512*Math.ceil(1+r/512),o=Buffer.allocUnsafe(n);for(let i=0;i<512;i++)o[i]=0;new nr({path:("PaxHeader/"+(0,RR.basename)(this.path??"")).slice(0,99),mode:this.mode||420,uid:this.uid,gid:this.gid,size:r,mtime:this.mtime,type:this.global?"GlobalExtendedHeader":"ExtendedHeader",linkpath:"",uname:this.uname||"",gname:this.gname||"",devmaj:0,devmin:0,atime:this.atime,ctime:this.ctime}).encode(o),o.write(e,512,r,"utf8");for(let i=r+512;i=Math.pow(10,s)&&(s+=1),s+i+o}static parse(e,r,n=!1){return new hn(qH(BH(e),r),n)}},qH=(t,e)=>e?Object.assign({},e,t):t,BH=t=>t.replace(/\n$/,"").split(` +`).reduce(zH,Object.create(null)),zH=(t,e)=>{let r=parseInt(e,10);if(r!==Buffer.byteLength(e)+1)return t;e=e.slice((r+" ").length);let n=e.split("="),o=n.shift();if(!o)return t;let i=o.replace(/^SCHILY\.(dev|ino|nlink)/,"$1"),s=n.join("=");return t[i]=/^([A-Z]+\.)?([mac]|birth|creation)time$/.test(i)?new Date(Number(s)*1e3):/^[0-9]+$/.test(s)?+s:s,t};a();a();var UH=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,re=UH!=="win32"?t=>t:t=>t&&t.replace(/\\/g,"/");var ua=class extends qt{extended;globalExtended;header;startBlockSize;blockRemain;remain;type;meta=!1;ignore=!1;path;mode;uid;gid;uname;gname;size=0;mtime;atime;ctime;linkpath;dev;ino;nlink;invalid=!1;absolute;unsupported=!1;constructor(e,r,n){switch(super({}),this.pause(),this.extended=r,this.globalExtended=n,this.header=e,this.remain=e.size??0,this.startBlockSize=512*Math.ceil(this.remain/512),this.blockRemain=this.startBlockSize,this.type=e.type,this.type){case"File":case"OldFile":case"Link":case"SymbolicLink":case"CharacterDevice":case"BlockDevice":case"Directory":case"FIFO":case"ContiguousFile":case"GNUDumpDir":break;case"NextFileHasLongLinkpath":case"NextFileHasLongPath":case"OldGnuLongPath":case"GlobalExtendedHeader":case"ExtendedHeader":case"OldExtendedHeader":this.meta=!0;break;default:this.ignore=!0}if(!e.path)throw new Error("no path provided for tar.ReadEntry");this.path=re(e.path),this.mode=e.mode,this.mode&&(this.mode=this.mode&4095),this.uid=e.uid,this.gid=e.gid,this.uname=e.uname,this.gname=e.gname,this.size=this.remain,this.mtime=e.mtime,this.atime=e.atime,this.ctime=e.ctime,this.linkpath=e.linkpath?re(e.linkpath):void 0,this.uname=e.uname,this.gname=e.gname,r&&this.#e(r),n&&this.#e(n,!0)}write(e){let r=e.length;if(r>this.blockRemain)throw new Error("writing more to entry than is appropriate");let n=this.remain,o=this.blockRemain;return this.remain=Math.max(0,n-r),this.blockRemain=Math.max(0,o-r),this.ignore?!0:n>=r?super.write(e):super.write(e.subarray(0,n))}#e(e,r=!1){e.path&&(e.path=re(e.path)),e.linkpath&&(e.linkpath=re(e.linkpath)),Object.assign(this,Object.fromEntries(Object.entries(e).filter(([n,o])=>!(o==null||n==="path"&&r))))}};a();var $i=(t,e,r,n={})=>{t.file&&(n.file=t.file),t.cwd&&(n.cwd=t.cwd),n.code=r instanceof Error&&r.code||e,n.tarCode=e,!t.strict&&n.recoverable!==!1?(r instanceof Error&&(n=Object.assign(r,n),r=r.message),t.emit("warn",e,r,n)):r instanceof Error?t.emit("error",Object.assign(r,n)):t.emit("error",Object.assign(new Error(`${e}: ${r}`),n))};var WH=1024*1024,$v=Buffer.from([31,139]),Er=Symbol("state"),Li=Symbol("writeEntry"),Un=Symbol("readEntry"),Lv=Symbol("nextEntry"),NR=Symbol("processEntry"),gn=Symbol("extendedHeader"),gl=Symbol("globalExtendedHeader"),Fo=Symbol("meta"),DR=Symbol("emitMeta"),Te=Symbol("buffer"),Wn=Symbol("queue"),Mo=Symbol("ended"),jv=Symbol("emittedEnd"),ji=Symbol("emit"),Ze=Symbol("unzip"),fd=Symbol("consumeChunk"),pd=Symbol("consumeChunkSub"),qv=Symbol("consumeBody"),PR=Symbol("consumeMeta"),FR=Symbol("consumeHeader"),yl=Symbol("consuming"),Bv=Symbol("bufferConcat"),dd=Symbol("maybeEnd"),fa=Symbol("writing"),$o=Symbol("aborted"),md=Symbol("onDone"),qi=Symbol("sawValidEntry"),hd=Symbol("sawNullBlock"),gd=Symbol("sawEOF"),MR=Symbol("closeStream"),HH=()=>!0,Hn=class extends $R.EventEmitter{file;strict;maxMetaEntrySize;filter;brotli;writable=!0;readable=!1;[Wn]=new xr;[Te];[Un];[Li];[Er]="begin";[Fo]="";[gn];[gl];[Mo]=!1;[Ze];[$o]=!1;[qi];[hd]=!1;[gd]=!1;[fa]=!1;[yl]=!1;[jv]=!1;constructor(e={}){super(),this.file=e.file||"",this.on(md,()=>{(this[Er]==="begin"||this[qi]===!1)&&this.warn("TAR_BAD_ARCHIVE","Unrecognized archive format")}),e.ondone?this.on(md,e.ondone):this.on(md,()=>{this.emit("prefinish"),this.emit("finish"),this.emit("end")}),this.strict=!!e.strict,this.maxMetaEntrySize=e.maxMetaEntrySize||WH,this.filter=typeof e.filter=="function"?e.filter:HH;let r=e.file&&(e.file.endsWith(".tar.br")||e.file.endsWith(".tbr"));this.brotli=!e.gzip&&e.brotli!==void 0?e.brotli:r?void 0:!1,this.on("end",()=>this[MR]()),typeof e.onwarn=="function"&&this.on("warn",e.onwarn),typeof e.onReadEntry=="function"&&this.on("entry",e.onReadEntry)}warn(e,r,n={}){$i(this,e,r,n)}[FR](e,r){this[qi]===void 0&&(this[qi]=!1);let n;try{n=new nr(e,r,this[gn],this[gl])}catch(o){return this.warn("TAR_ENTRY_INVALID",o)}if(n.nullBlock)this[hd]?(this[gd]=!0,this[Er]==="begin"&&(this[Er]="header"),this[ji]("eof")):(this[hd]=!0,this[ji]("nullBlock"));else if(this[hd]=!1,!n.cksumValid)this.warn("TAR_ENTRY_INVALID","checksum failure",{header:n});else if(!n.path)this.warn("TAR_ENTRY_INVALID","path is required",{header:n});else{let o=n.type;if(/^(Symbolic)?Link$/.test(o)&&!n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath required",{header:n});else if(!/^(Symbolic)?Link$/.test(o)&&!/^(Global)?ExtendedHeader$/.test(o)&&n.linkpath)this.warn("TAR_ENTRY_INVALID","linkpath forbidden",{header:n});else{let i=this[Li]=new ua(n,this[gn],this[gl]);if(!this[qi])if(i.remain){let s=()=>{i.invalid||(this[qi]=!0)};i.on("end",s)}else this[qi]=!0;i.meta?i.size>this.maxMetaEntrySize?(i.ignore=!0,this[ji]("ignoredEntry",i),this[Er]="ignore",i.resume()):i.size>0&&(this[Fo]="",i.on("data",s=>this[Fo]+=s),this[Er]="meta"):(this[gn]=void 0,i.ignore=i.ignore||!this.filter(i.path,i),i.ignore?(this[ji]("ignoredEntry",i),this[Er]=i.remain?"ignore":"header",i.resume()):(i.remain?this[Er]="body":(this[Er]="header",i.end()),this[Un]?this[Wn].push(i):(this[Wn].push(i),this[Lv]())))}}}[MR](){queueMicrotask(()=>this.emit("close"))}[NR](e){let r=!0;if(!e)this[Un]=void 0,r=!1;else if(Array.isArray(e)){let[n,...o]=e;this.emit(n,...o)}else this[Un]=e,this.emit("entry",e),e.emittedEnd||(e.on("end",()=>this[Lv]()),r=!1);return r}[Lv](){do;while(this[NR](this[Wn].shift()));if(!this[Wn].length){let e=this[Un];!e||e.flowing||e.size===e.remain?this[fa]||this.emit("drain"):e.once("drain",()=>this.emit("drain"))}}[qv](e,r){let n=this[Li];if(!n)throw new Error("attempt to consume body without entry??");let o=n.blockRemain??0,i=o>=e.length&&r===0?e:e.subarray(r,r+o);return n.write(i),n.blockRemain||(this[Er]="header",this[Li]=void 0,n.end()),i.length}[PR](e,r){let n=this[Li],o=this[qv](e,r);return!this[Li]&&n&&this[DR](n),o}[ji](e,r,n){!this[Wn].length&&!this[Un]?this.emit(e,r,n):this[Wn].push([e,r,n])}[DR](e){switch(this[ji]("meta",this[Fo]),e.type){case"ExtendedHeader":case"OldExtendedHeader":this[gn]=hn.parse(this[Fo],this[gn],!1);break;case"GlobalExtendedHeader":this[gl]=hn.parse(this[Fo],this[gl],!0);break;case"NextFileHasLongPath":case"OldGnuLongPath":{let r=this[gn]??Object.create(null);this[gn]=r,r.path=this[Fo].replace(/\0.*/,"");break}case"NextFileHasLongLinkpath":{let r=this[gn]||Object.create(null);this[gn]=r,r.linkpath=this[Fo].replace(/\0.*/,"");break}default:throw new Error("unknown meta: "+e.type)}}abort(e){this[$o]=!0,this.emit("abort",e),this.warn("TAR_ABORT",e,{recoverable:!1})}write(e,r,n){if(typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8")),this[$o])return n?.(),!1;if((this[Ze]===void 0||this.brotli===void 0&&this[Ze]===!1)&&e){if(this[Te]&&(e=Buffer.concat([this[Te],e]),this[Te]=void 0),e.length<$v.length)return this[Te]=e,n?.(),!0;for(let c=0;this[Ze]===void 0&&c<$v.length;c++)e[c]!==$v[c]&&(this[Ze]=!1);let s=this.brotli===void 0;if(this[Ze]===!1&&s)if(e.length<512)if(this[Mo])this.brotli=!0;else return this[Te]=e,n?.(),!0;else try{new nr(e.subarray(0,512)),this.brotli=!1}catch{this.brotli=!0}if(this[Ze]===void 0||this[Ze]===!1&&this.brotli){let c=this[Mo];this[Mo]=!1,this[Ze]=this[Ze]===void 0?new id({}):new cd({}),this[Ze].on("data",f=>this[fd](f)),this[Ze].on("error",f=>this.abort(f)),this[Ze].on("end",()=>{this[Mo]=!0,this[fd]()}),this[fa]=!0;let l=!!this[Ze][c?"end":"write"](e);return this[fa]=!1,n?.(),l}}this[fa]=!0,this[Ze]?this[Ze].write(e):this[fd](e),this[fa]=!1;let i=this[Wn].length?!1:this[Un]?this[Un].flowing:!0;return!i&&!this[Wn].length&&this[Un]?.once("drain",()=>this.emit("drain")),n?.(),i}[Bv](e){e&&!this[$o]&&(this[Te]=this[Te]?Buffer.concat([this[Te],e]):e)}[dd](){if(this[Mo]&&!this[jv]&&!this[$o]&&!this[yl]){this[jv]=!0;let e=this[Li];if(e&&e.blockRemain){let r=this[Te]?this[Te].length:0;this.warn("TAR_BAD_ARCHIVE",`Truncated input (needed ${e.blockRemain} more bytes, only ${r} available)`,{entry:e}),this[Te]&&e.write(this[Te]),e.end()}this[ji](md)}}[fd](e){if(this[yl]&&e)this[Bv](e);else if(!e&&!this[Te])this[dd]();else if(e){if(this[yl]=!0,this[Te]){this[Bv](e);let r=this[Te];this[Te]=void 0,this[pd](r)}else this[pd](e);for(;this[Te]&&this[Te]?.length>=512&&!this[$o]&&!this[gd];){let r=this[Te];this[Te]=void 0,this[pd](r)}this[yl]=!1}(!this[Te]||this[Mo])&&this[dd]()}[pd](e){let r=0,n=e.length;for(;r+512<=n&&!this[$o]&&!this[gd];)switch(this[Er]){case"begin":case"header":this[FR](e,r),r+=512;break;case"ignore":case"body":r+=this[qv](e,r);break;case"meta":r+=this[PR](e,r);break;default:throw new Error("invalid state: "+this[Er])}r{let e=t.length-1,r=-1;for(;e>-1&&t.charAt(e)==="/";)r=e,e--;return r===-1?t:t.slice(0,r)};var KH=t=>{let e=t.onReadEntry;t.onReadEntry=e?r=>{e(r),r.resume()}:r=>r.resume()},zv=(t,e)=>{let r=new Map(e.map(i=>[yn(i),!0])),n=t.filter,o=(i,s="")=>{let c=s||(0,yd.parse)(i).root||".",l;if(i===c)l=!1;else{let f=r.get(i);f!==void 0?l=f:l=o((0,yd.dirname)(i),c)}return r.set(i,l),l};t.filter=n?(i,s)=>n(i,s)&&o(yn(i)):i=>o(yn(i))},VH=t=>{let e=new Hn(t),r=t.file,n;try{let o=Bi.default.statSync(r),i=t.maxReadSize||16*1024*1024;if(o.size{let r=new Hn(t),n=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((s,c)=>{r.on("error",c),r.on("end",s),Bi.default.stat(o,(l,f)=>{if(l)c(l);else{let u=new Ni(o,{readSize:n,size:f.size});u.on("error",c),u.pipe(r)}})})},Kn=mn(VH,GH,t=>new Hn(t),t=>new Hn(t),(t,e)=>{e?.length&&zv(t,e),t.noResume||KH(t)});a();var Sl=Y(require("fs"),1);a();var qr=Y(require("fs"),1);var Vv=Y(require("path"),1);a();var Uv=(t,e,r)=>(t&=4095,r&&(t=(t|384)&-19),e&&(t&256&&(t|=64),t&32&&(t|=8),t&4&&(t|=1)),t);a();var jR=require("node:path"),{isAbsolute:ZH,parse:LR}=jR.win32,bl=t=>{let e="",r=LR(t);for(;ZH(t)||r.root;){let n=t.charAt(0)==="/"&&t.slice(0,4)!=="//?/"?"/":r.root;t=t.slice(n.length),e+=n,r=LR(t)}return[e,t]};a();var bd=["|","<",">","?",":"],Wv=bd.map(t=>String.fromCharCode(61440+t.charCodeAt(0))),JH=new Map(bd.map((t,e)=>[t,Wv[e]])),YH=new Map(Wv.map((t,e)=>[t,bd[e]])),Hv=t=>bd.reduce((e,r)=>e.split(r).join(JH.get(r)),t),qR=t=>Wv.reduce((e,r)=>e.split(r).join(YH.get(r)),t);var KR=(t,e)=>e?(t=re(t).replace(/^\.(\/|$)/,""),yn(e)+"/"+t):re(t),XH=16*1024*1024,zR=Symbol("process"),UR=Symbol("file"),WR=Symbol("directory"),Gv=Symbol("symlink"),HR=Symbol("hardlink"),vl=Symbol("header"),vd=Symbol("read"),Zv=Symbol("lstat"),wd=Symbol("onlstat"),Jv=Symbol("onread"),Yv=Symbol("onreadlink"),Xv=Symbol("openfile"),Qv=Symbol("onopenfile"),Lo=Symbol("close"),xd=Symbol("mode"),e0=Symbol("awaitDrain"),Kv=Symbol("ondrain"),bn=Symbol("prefix"),wl=class extends qt{path;portable;myuid=process.getuid&&process.getuid()||0;myuser=process.env.USER||"";maxReadSize;linkCache;statCache;preservePaths;cwd;strict;mtime;noPax;noMtime;prefix;fd;blockLen=0;blockRemain=0;buf;pos=0;remain=0;length=0;offset=0;win32;absolute;header;type;linkpath;stat;#e=!1;constructor(e,r={}){let n=ml(r);super(),this.path=re(e),this.portable=!!n.portable,this.maxReadSize=n.maxReadSize||XH,this.linkCache=n.linkCache||new Map,this.statCache=n.statCache||new Map,this.preservePaths=!!n.preservePaths,this.cwd=re(n.cwd||process.cwd()),this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.mtime=n.mtime,this.prefix=n.prefix?re(n.prefix):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let o=!1;if(!this.preservePaths){let[s,c]=bl(this.path);s&&typeof c=="string"&&(this.path=c,o=s)}this.win32=!!n.win32||process.platform==="win32",this.win32&&(this.path=qR(this.path.replace(/\\/g,"/")),e=e.replace(/\\/g,"/")),this.absolute=re(n.absolute||Vv.default.resolve(this.cwd,e)),this.path===""&&(this.path="./"),o&&this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:this,path:o+this.path});let i=this.statCache.get(this.absolute);i?this[wd](i):this[Zv]()}warn(e,r,n={}){return $i(this,e,r,n)}emit(e,...r){return e==="error"&&(this.#e=!0),super.emit(e,...r)}[Zv](){qr.default.lstat(this.absolute,(e,r)=>{if(e)return this.emit("error",e);this[wd](r)})}[wd](e){this.statCache.set(this.absolute,e),this.stat=e,e.isFile()||(e.size=0),this.type=QH(e),this.emit("stat",e),this[zR]()}[zR](){switch(this.type){case"File":return this[UR]();case"Directory":return this[WR]();case"SymbolicLink":return this[Gv]();default:return this.end()}}[xd](e){return Uv(e,this.type==="Directory",this.portable)}[bn](e){return KR(e,this.prefix)}[vl](){if(!this.stat)throw new Error("cannot write header before stat");this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.header=new nr({path:this[bn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bn](this.linkpath):this.linkpath,mode:this[xd](this.stat.mode),uid:this.portable?void 0:this.stat.uid,gid:this.portable?void 0:this.stat.gid,size:this.stat.size,mtime:this.noMtime?void 0:this.mtime||this.stat.mtime,type:this.type==="Unsupported"?void 0:this.type,uname:this.portable?void 0:this.stat.uid===this.myuid?this.myuser:"",atime:this.portable?void 0:this.stat.atime,ctime:this.portable?void 0:this.stat.ctime}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.header.atime,ctime:this.portable?void 0:this.header.ctime,gid:this.portable?void 0:this.header.gid,mtime:this.noMtime?void 0:this.mtime||this.header.mtime,path:this[bn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bn](this.linkpath):this.linkpath,size:this.header.size,uid:this.portable?void 0:this.header.uid,uname:this.portable?void 0:this.header.uname,dev:this.portable?void 0:this.stat.dev,ino:this.portable?void 0:this.stat.ino,nlink:this.portable?void 0:this.stat.nlink}).encode());let e=this.header?.block;if(!e)throw new Error("failed to encode header");super.write(e)}[WR](){if(!this.stat)throw new Error("cannot create directory entry without stat");this.path.slice(-1)!=="/"&&(this.path+="/"),this.stat.size=0,this[vl](),this.end()}[Gv](){qr.default.readlink(this.absolute,(e,r)=>{if(e)return this.emit("error",e);this[Yv](r)})}[Yv](e){this.linkpath=re(e),this[vl](),this.end()}[HR](e){if(!this.stat)throw new Error("cannot create link entry without stat");this.type="Link",this.linkpath=re(Vv.default.relative(this.cwd,e)),this.stat.size=0,this[vl](),this.end()}[UR](){if(!this.stat)throw new Error("cannot create file entry without stat");if(this.stat.nlink>1){let e=`${this.stat.dev}:${this.stat.ino}`,r=this.linkCache.get(e);if(r?.indexOf(this.cwd)===0)return this[HR](r);this.linkCache.set(e,this.absolute)}if(this[vl](),this.stat.size===0)return this.end();this[Xv]()}[Xv](){qr.default.open(this.absolute,"r",(e,r)=>{if(e)return this.emit("error",e);this[Qv](r)})}[Qv](e){if(this.fd=e,this.#e)return this[Lo]();if(!this.stat)throw new Error("should stat before calling onopenfile");this.blockLen=512*Math.ceil(this.stat.size/512),this.blockRemain=this.blockLen;let r=Math.min(this.blockLen,this.maxReadSize);this.buf=Buffer.allocUnsafe(r),this.offset=0,this.pos=0,this.remain=this.stat.size,this.length=this.buf.length,this[vd]()}[vd](){let{fd:e,buf:r,offset:n,length:o,pos:i}=this;if(e===void 0||r===void 0)throw new Error("cannot read file without first opening");qr.default.read(e,r,n,o,i,(s,c)=>{if(s)return this[Lo](()=>this.emit("error",s));this[Jv](c)})}[Lo](e=()=>{}){this.fd!==void 0&&qr.default.close(this.fd,e)}[Jv](e){if(e<=0&&this.remain>0){let o=Object.assign(new Error("encountered unexpected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Lo](()=>this.emit("error",o))}if(e>this.remain){let o=Object.assign(new Error("did not encounter expected EOF"),{path:this.absolute,syscall:"read",code:"EOF"});return this[Lo](()=>this.emit("error",o))}if(!this.buf)throw new Error("should have created buffer prior to reading");if(e===this.remain)for(let o=e;othis[Kv]())}[e0](e){this.once("drain",e)}write(e,r,n){if(typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8")),this.blockRemaine?this.emit("error",e):this.end());if(!this.buf)throw new Error("buffer lost somehow in ONDRAIN");this.offset>=this.length&&(this.buf=Buffer.allocUnsafe(Math.min(this.blockRemain,this.buf.length)),this.offset=0),this.length=this.buf.length-this.offset,this[vd]()}},Ed=class extends wl{sync=!0;[Zv](){this[wd](qr.default.lstatSync(this.absolute))}[Gv](){this[Yv](qr.default.readlinkSync(this.absolute))}[Xv](){this[Qv](qr.default.openSync(this.absolute,"r"))}[vd](){let e=!0;try{let{fd:r,buf:n,offset:o,length:i,pos:s}=this;if(r===void 0||n===void 0)throw new Error("fd and buf must be set in READ method");let c=qr.default.readSync(r,n,o,i,s);this[Jv](c),e=!1}finally{if(e)try{this[Lo](()=>{})}catch{}}}[e0](e){e()}[Lo](e=()=>{}){this.fd!==void 0&&qr.default.closeSync(this.fd),e()}},Sd=class extends qt{blockLen=0;blockRemain=0;buf=0;pos=0;remain=0;length=0;preservePaths;portable;strict;noPax;noMtime;readEntry;type;prefix;path;mode;uid;gid;uname;gname;header;mtime;atime;ctime;linkpath;size;warn(e,r,n={}){return $i(this,e,r,n)}constructor(e,r={}){let n=ml(r);super(),this.preservePaths=!!n.preservePaths,this.portable=!!n.portable,this.strict=!!n.strict,this.noPax=!!n.noPax,this.noMtime=!!n.noMtime,this.readEntry=e;let{type:o}=e;if(o==="Unsupported")throw new Error("writing entry that should be ignored");this.type=o,this.type==="Directory"&&this.portable&&(this.noMtime=!0),this.prefix=n.prefix,this.path=re(e.path),this.mode=e.mode!==void 0?this[xd](e.mode):void 0,this.uid=this.portable?void 0:e.uid,this.gid=this.portable?void 0:e.gid,this.uname=this.portable?void 0:e.uname,this.gname=this.portable?void 0:e.gname,this.size=e.size,this.mtime=this.noMtime?void 0:n.mtime||e.mtime,this.atime=this.portable?void 0:e.atime,this.ctime=this.portable?void 0:e.ctime,this.linkpath=e.linkpath!==void 0?re(e.linkpath):void 0,typeof n.onwarn=="function"&&this.on("warn",n.onwarn);let i=!1;if(!this.preservePaths){let[c,l]=bl(this.path);c&&typeof l=="string"&&(this.path=l,i=c)}this.remain=e.size,this.blockRemain=e.startBlockSize,this.header=new nr({path:this[bn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bn](this.linkpath):this.linkpath,mode:this.mode,uid:this.portable?void 0:this.uid,gid:this.portable?void 0:this.gid,size:this.size,mtime:this.noMtime?void 0:this.mtime,type:this.type,uname:this.portable?void 0:this.uname,atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime}),i&&this.warn("TAR_ENTRY_INFO",`stripping ${i} from absolute path`,{entry:this,path:i+this.path}),this.header.encode()&&!this.noPax&&super.write(new hn({atime:this.portable?void 0:this.atime,ctime:this.portable?void 0:this.ctime,gid:this.portable?void 0:this.gid,mtime:this.noMtime?void 0:this.mtime,path:this[bn](this.path),linkpath:this.type==="Link"&&this.linkpath!==void 0?this[bn](this.linkpath):this.linkpath,size:this.size,uid:this.portable?void 0:this.uid,uname:this.portable?void 0:this.uname,dev:this.portable?void 0:this.readEntry.dev,ino:this.portable?void 0:this.readEntry.ino,nlink:this.portable?void 0:this.readEntry.nlink}).encode());let s=this.header?.block;if(!s)throw new Error("failed to encode header");super.write(s),e.pipe(this)}[bn](e){return KR(e,this.prefix)}[xd](e){return Uv(e,this.type==="Directory",this.portable)}write(e,r,n){typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,typeof r=="string"?r:"utf8"));let o=e.length;if(o>this.blockRemain)throw new Error("writing more to entry than is appropriate");return this.blockRemain-=o,super.write(e,n)}end(e,r,n){return this.blockRemain&&super.write(Buffer.alloc(this.blockRemain)),typeof e=="function"&&(n=e,r=void 0,e=void 0),typeof r=="function"&&(n=r,r=void 0),typeof e=="string"&&(e=Buffer.from(e,r??"utf8")),n&&this.once("finish",n),e?super.end(e,n):super.end(n),this}},QH=t=>t.isFile()?"File":t.isDirectory()?"Directory":t.isSymbolicLink()?"SymbolicLink":"Unsupported";var s0=Y(require("path"),1);var kd=class{path;absolute;entry;stat;readdir;pending=!1;ignore=!1;piped=!1;constructor(e,r){this.path=e||"./",this.absolute=r}},VR=Buffer.alloc(1024),Id=Symbol("onStat"),xl=Symbol("ended"),Br=Symbol("queue"),pa=Symbol("current"),zi=Symbol("process"),El=Symbol("processing"),GR=Symbol("processJob"),zr=Symbol("jobs"),t0=Symbol("jobDone"),_d=Symbol("addFSEntry"),ZR=Symbol("addTarEntry"),o0=Symbol("stat"),i0=Symbol("readdir"),Td=Symbol("onreaddir"),Od=Symbol("pipe"),JR=Symbol("entry"),r0=Symbol("entryOpt"),Cd=Symbol("writeEntryClass"),YR=Symbol("write"),n0=Symbol("ondrain"),jo=class extends qt{opt;cwd;maxReadSize;preservePaths;strict;noPax;prefix;linkCache;statCache;file;portable;zip;readdirCache;noDirRecurse;follow;noMtime;mtime;filter;jobs;[Cd];onWriteEntry;[Br];[zr]=0;[El]=!1;[xl]=!1;constructor(e={}){if(super(),this.opt=e,this.file=e.file||"",this.cwd=e.cwd||process.cwd(),this.maxReadSize=e.maxReadSize,this.preservePaths=!!e.preservePaths,this.strict=!!e.strict,this.noPax=!!e.noPax,this.prefix=re(e.prefix||""),this.linkCache=e.linkCache||new Map,this.statCache=e.statCache||new Map,this.readdirCache=e.readdirCache||new Map,this.onWriteEntry=e.onWriteEntry,this[Cd]=wl,typeof e.onwarn=="function"&&this.on("warn",e.onwarn),this.portable=!!e.portable,e.gzip||e.brotli){if(e.gzip&&e.brotli)throw new TypeError("gzip and brotli are mutually exclusive");if(e.gzip&&(typeof e.gzip!="object"&&(e.gzip={}),this.portable&&(e.gzip.portable=!0),this.zip=new od(e.gzip)),e.brotli&&(typeof e.brotli!="object"&&(e.brotli={}),this.zip=new ad(e.brotli)),!this.zip)throw new Error("impossible");let r=this.zip;r.on("data",n=>super.write(n)),r.on("end",()=>super.end()),r.on("drain",()=>this[n0]()),this.on("resume",()=>r.resume())}else this.on("drain",this[n0]);this.noDirRecurse=!!e.noDirRecurse,this.follow=!!e.follow,this.noMtime=!!e.noMtime,e.mtime&&(this.mtime=e.mtime),this.filter=typeof e.filter=="function"?e.filter:()=>!0,this[Br]=new xr,this[zr]=0,this.jobs=Number(e.jobs)||4,this[El]=!1,this[xl]=!1}[YR](e){return super.write(e)}add(e){return this.write(e),this}end(e){return e&&this.add(e),this[xl]=!0,this[zi](),this}write(e){if(this[xl])throw new Error("write after end");return e instanceof ua?this[ZR](e):this[_d](e),this.flowing}[ZR](e){let r=re(s0.default.resolve(this.cwd,e.path));if(!this.filter(e.path,e))e.resume();else{let n=new kd(e.path,r);n.entry=new Sd(e,this[r0](n)),n.entry.on("end",()=>this[t0](n)),this[zr]+=1,this[Br].push(n)}this[zi]()}[_d](e){let r=re(s0.default.resolve(this.cwd,e));this[Br].push(new kd(e,r)),this[zi]()}[o0](e){e.pending=!0,this[zr]+=1;let r=this.follow?"stat":"lstat";Sl.default[r](e.absolute,(n,o)=>{e.pending=!1,this[zr]-=1,n?this.emit("error",n):this[Id](e,o)})}[Id](e,r){this.statCache.set(e.absolute,r),e.stat=r,this.filter(e.path,r)||(e.ignore=!0),this[zi]()}[i0](e){e.pending=!0,this[zr]+=1,Sl.default.readdir(e.absolute,(r,n)=>{if(e.pending=!1,this[zr]-=1,r)return this.emit("error",r);this[Td](e,n)})}[Td](e,r){this.readdirCache.set(e.absolute,r),e.readdir=r,this[zi]()}[zi](){if(!this[El]){this[El]=!0;for(let e=this[Br].head;e&&this[zr]this.warn(r,n,o),noPax:this.noPax,cwd:this.cwd,absolute:e.absolute,preservePaths:this.preservePaths,maxReadSize:this.maxReadSize,strict:this.strict,portable:this.portable,linkCache:this.linkCache,statCache:this.statCache,noMtime:this.noMtime,mtime:this.mtime,prefix:this.prefix}}[JR](e){this[zr]+=1;try{let r=new this[Cd](e.path,this[r0](e));return this.onWriteEntry?.(r),r.on("end",()=>this[t0](e)).on("error",n=>this.emit("error",n))}catch(r){this.emit("error",r)}}[n0](){this[pa]&&this[pa].entry&&this[pa].entry.resume()}[Od](e){e.piped=!0,e.readdir&&e.readdir.forEach(o=>{let i=e.path,s=i==="./"?"":i.replace(/\/*$/,"/");this[_d](s+o)});let r=e.entry,n=this.zip;if(!r)throw new Error("cannot pipe without source");n?r.on("data",o=>{n.write(o)||r.pause()}):r.on("data",o=>{super.write(o)||r.pause()})}pause(){return this.zip&&this.zip.pause(),super.pause()}warn(e,r,n={}){$i(this,e,r,n)}},Ui=class extends jo{sync=!0;constructor(e){super(e),this[Cd]=Ed}pause(){}resume(){}[o0](e){let r=this.follow?"statSync":"lstatSync";this[Id](e,Sl.default[r](e.absolute))}[i0](e){this[Td](e,Sl.default.readdirSync(e.absolute))}[Od](e){let r=e.entry,n=this.zip;if(e.readdir&&e.readdir.forEach(o=>{let i=e.path,s=i==="./"?"":i.replace(/\/*$/,"/");this[_d](s+o)}),!r)throw new Error("Cannot pipe without source");n?r.on("data",o=>{n.write(o)}):r.on("data",o=>{super[YR](o)})}};var eK=(t,e)=>{let r=new Ui(t),n=new ca(t.file,{mode:t.mode||438});r.pipe(n),XR(r,e)},tK=(t,e)=>{let r=new jo(t),n=new qn(t.file,{mode:t.mode||438});r.pipe(n);let o=new Promise((i,s)=>{n.on("error",s),n.on("close",i),r.on("error",s)});return QR(r,e),o},XR=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Kn({file:a0.default.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(r)}),t.end()},QR=async(t,e)=>{for(let r=0;r{t.add(o)}}):t.add(n)}t.end()},rK=(t,e)=>{let r=new Ui(t);return XR(r,e),r},nK=(t,e)=>{let r=new jo(t);return QR(r,e),r},oK=mn(eK,tK,rK,nK,(t,e)=>{if(!e?.length)throw new TypeError("no paths specified to add to archive")});a();var A0=Y(require("node:fs"),1);a();var hN=Y(require("node:assert"),1),k0=require("node:crypto"),pe=Y(require("node:fs"),1),wn=Y(require("node:path"),1);a();var c0=Y(require("fs"),1),iK=process.env.__FAKE_PLATFORM__||process.platform,sK=iK==="win32",{O_CREAT:aK,O_TRUNC:cK,O_WRONLY:lK}=c0.default.constants,eN=Number(process.env.__FAKE_FS_O_FILENAME__)||c0.default.constants.UV_FS_O_FILEMAP||0,uK=sK&&!!eN,fK=512*1024,pK=eN|cK|aK|lK,l0=uK?t=>t"w";a();a();var Il=Y(require("node:fs"),1),da=Y(require("node:path"),1),u0=(t,e,r)=>{try{return Il.default.lchownSync(t,e,r)}catch(n){if(n?.code!=="ENOENT")throw n}},Ad=(t,e,r,n)=>{Il.default.lchown(t,e,r,o=>{n(o&&o?.code!=="ENOENT"?o:null)})},dK=(t,e,r,n,o)=>{if(e.isDirectory())f0(da.default.resolve(t,e.name),r,n,i=>{if(i)return o(i);let s=da.default.resolve(t,e.name);Ad(s,r,n,o)});else{let i=da.default.resolve(t,e.name);Ad(i,r,n,o)}},f0=(t,e,r,n)=>{Il.default.readdir(t,{withFileTypes:!0},(o,i)=>{if(o){if(o.code==="ENOENT")return n();if(o.code!=="ENOTDIR"&&o.code!=="ENOTSUP")return n(o)}if(o||!i.length)return Ad(t,e,r,n);let s=i.length,c=null,l=f=>{if(!c){if(f)return n(c=f);if(--s===0)return Ad(t,e,r,n)}};for(let f of i)dK(t,f,e,r,l)})},mK=(t,e,r,n)=>{e.isDirectory()&&p0(da.default.resolve(t,e.name),r,n),u0(da.default.resolve(t,e.name),r,n)},p0=(t,e,r)=>{let n;try{n=Il.default.readdirSync(t,{withFileTypes:!0})}catch(o){let i=o;if(i?.code==="ENOENT")return;if(i?.code==="ENOTDIR"||i?.code==="ENOTSUP")return u0(t,e,r);throw i}for(let o of n)mK(t,o,e,r);return u0(t,e,r)};var or=Y(require("fs"),1);a();a();var d0=require("path");a();var qo=require("fs"),Sr=t=>{if(!t)t={mode:511};else if(typeof t=="object")t={mode:511,...t};else if(typeof t=="number")t={mode:t};else if(typeof t=="string")t={mode:parseInt(t,8)};else throw new TypeError("invalid options argument");let e=t,r=t.fs||{};return t.mkdir=t.mkdir||r.mkdir||qo.mkdir,t.mkdirAsync=t.mkdirAsync?t.mkdirAsync:async(n,o)=>new Promise((i,s)=>e.mkdir(n,o,(c,l)=>c?s(c):i(l))),t.stat=t.stat||r.stat||qo.stat,t.statAsync=t.statAsync?t.statAsync:async n=>new Promise((o,i)=>e.stat(n,(s,c)=>s?i(s):o(c))),t.statSync=t.statSync||r.statSync||qo.statSync,t.mkdirSync=t.mkdirSync||r.mkdirSync||qo.mkdirSync,e};var vn=(t,e,r)=>{let n=(0,d0.dirname)(t),o={...Sr(e),recursive:!1};if(n===t)try{return o.mkdirSync(t,o)}catch(i){let s=i;if(s&&s.code!=="EISDIR")throw i;return}try{return o.mkdirSync(t,o),r||t}catch(i){let s=i;if(s&&s.code==="ENOENT")return vn(t,o,vn(n,o,r));if(s&&s.code!=="EEXIST"&&s&&s.code!=="EROFS")throw i;try{if(!o.statSync(t).isDirectory())throw i}catch{throw i}}},Vn=Object.assign(async(t,e,r)=>{let n=Sr(e);n.recursive=!1;let o=(0,d0.dirname)(t);return o===t?n.mkdirAsync(t,n).catch(i=>{let s=i;if(s&&s.code!=="EISDIR")throw i}):n.mkdirAsync(t,n).then(()=>r||t,async i=>{let s=i;if(s&&s.code==="ENOENT")return Vn(o,n).then(c=>Vn(t,n,c));if(s&&s.code!=="EEXIST"&&s.code!=="EROFS")throw i;return n.statAsync(t).then(c=>{if(c.isDirectory())return r;throw i},()=>{throw i})})},{sync:vn});a();var y0=require("path");a();var m0=require("path"),h0=async(t,e,r)=>{if(r!==e)return t.statAsync(e).then(n=>n.isDirectory()?r:void 0,n=>{let o=n;return o&&o.code==="ENOENT"?h0(t,(0,m0.dirname)(e),e):void 0})},g0=(t,e,r)=>{if(r!==e)try{return t.statSync(e).isDirectory()?r:void 0}catch(n){let o=n;return o&&o.code==="ENOENT"?g0(t,(0,m0.dirname)(e),e):void 0}};var ma=(t,e)=>{let r=Sr(e);if(r.recursive=!0,(0,y0.dirname)(t)===t)return r.mkdirSync(t,r);let o=g0(r,t);try{return r.mkdirSync(t,r),o}catch(i){let s=i;if(s&&s.code==="ENOENT")return vn(t,r);throw i}},_l=Object.assign(async(t,e)=>{let r={...Sr(e),recursive:!0};return(0,y0.dirname)(t)===t?await r.mkdirAsync(t,r):h0(r,t).then(o=>r.mkdirAsync(t,r).then(i=>o||i).catch(i=>{let s=i;if(s&&s.code==="ENOENT")return Vn(t,r);throw i}))},{sync:ma});a();var Rd=require("path"),hK=process.env.__TESTING_MKDIRP_PLATFORM__||process.platform,b0=t=>{if(/\0/.test(t))throw Object.assign(new TypeError("path must be a string without null bytes"),{path:t,code:"ERR_INVALID_ARG_VALUE"});if(t=(0,Rd.resolve)(t),hK==="win32"){let e=/[*|"<>?:]/,{root:r}=(0,Rd.parse)(t);if(e.test(t.substring(r.length)))throw Object.assign(new Error("Illegal characters in path."),{path:t,code:"EINVAL"})}return t};a();var Nd=require("fs");var gK=process.env.__TESTING_MKDIRP_NODE_VERSION__||process.version,v0=gK.replace(/^v/,"").split("."),tN=+v0[0]>10||+v0[0]==10&&+v0[1]>=12,Tl=tN?t=>Sr(t).mkdirSync===Nd.mkdirSync:()=>!1,Dd=Object.assign(tN?t=>Sr(t).mkdir===Nd.mkdir:()=>!1,{sync:Tl});var Pd=(t,e)=>{t=b0(t);let r=Sr(e);return Tl(r)?ma(t,r):vn(t,r)};var rN=Object.assign(async(t,e)=>{t=b0(t);let r=Sr(e);return Dd(r)?_l(t,r):Vn(t,r)},{mkdirpSync:Pd,mkdirpNative:_l,mkdirpNativeSync:ma,mkdirpManual:Vn,mkdirpManualSync:vn,sync:Pd,native:_l,nativeSync:ma,manual:Vn,manualSync:vn,useNative:Dd,useNativeSync:Tl});var Al=Y(require("node:path"),1);a();var Ol=class extends Error{path;code;syscall="chdir";constructor(e,r){super(`${r}: Cannot cd into '${e}'`),this.path=e,this.code=r}get name(){return"CwdError"}};a();var Cl=class extends Error{path;symlink;syscall="symlink";code="TAR_SYMLINK_ERROR";constructor(e,r){super("TAR_SYMLINK_ERROR: Cannot extract through symbolic link"),this.symlink=e,this.path=r}get name(){return"SymlinkError"}};var Fd=(t,e)=>t.get(re(e)),kl=(t,e,r)=>t.set(re(e),r),yK=(t,e)=>{or.default.stat(t,(r,n)=>{(r||!n.isDirectory())&&(r=new Ol(t,r?.code||"ENOTDIR")),e(r)})},nN=(t,e,r)=>{t=re(t);let n=e.umask??18,o=e.mode|448,i=(o&n)!==0,s=e.uid,c=e.gid,l=typeof s=="number"&&typeof c=="number"&&(s!==e.processUid||c!==e.processGid),f=e.preserve,u=e.unlink,d=e.cache,m=re(e.cwd),h=(v,x)=>{v?r(v):(kl(d,t,!0),x&&l?f0(x,s,c,S=>h(S)):i?or.default.chmod(t,o,r):r())};if(d&&Fd(d,t)===!0)return h();if(t===m)return yK(t,h);if(f)return rN(t,{mode:o}).then(v=>h(null,v??void 0),h);let w=re(Al.default.relative(m,t)).split("/");Md(m,w,o,d,u,m,void 0,h)},Md=(t,e,r,n,o,i,s,c)=>{if(!e.length)return c(null,s);let l=e.shift(),f=re(Al.default.resolve(t+"/"+l));if(Fd(n,f))return Md(f,e,r,n,o,i,s,c);or.default.mkdir(f,r,oN(f,e,r,n,o,i,s,c))},oN=(t,e,r,n,o,i,s,c)=>l=>{l?or.default.lstat(t,(f,u)=>{if(f)f.path=f.path&&re(f.path),c(f);else if(u.isDirectory())Md(t,e,r,n,o,i,s,c);else if(o)or.default.unlink(t,d=>{if(d)return c(d);or.default.mkdir(t,r,oN(t,e,r,n,o,i,s,c))});else{if(u.isSymbolicLink())return c(new Cl(t,t+"/"+e.join("/")));c(l)}}):(s=s||t,Md(t,e,r,n,o,i,s,c))},bK=t=>{let e=!1,r;try{e=or.default.statSync(t).isDirectory()}catch(n){r=n?.code}finally{if(!e)throw new Ol(t,r??"ENOTDIR")}},iN=(t,e)=>{t=re(t);let r=e.umask??18,n=e.mode|448,o=(n&r)!==0,i=e.uid,s=e.gid,c=typeof i=="number"&&typeof s=="number"&&(i!==e.processUid||s!==e.processGid),l=e.preserve,f=e.unlink,u=e.cache,d=re(e.cwd),m=v=>{kl(u,t,!0),v&&c&&p0(v,i,s),o&&or.default.chmodSync(t,n)};if(u&&Fd(u,t)===!0)return m();if(t===d)return bK(d),m();if(l)return m(Pd(t,n)??void 0);let y=re(Al.default.relative(d,t)).split("/"),w;for(let v=y.shift(),x=d;v&&(x+="/"+v);v=y.shift())if(x=re(Al.default.resolve(x)),!Fd(u,x))try{or.default.mkdirSync(x,n),w=w||x,kl(u,x,!0)}catch{let k=or.default.lstatSync(x);if(k.isDirectory()){kl(u,x,!0);continue}else if(f){or.default.unlinkSync(x),or.default.mkdirSync(x,n),w=w||x,kl(u,x,!0);continue}else if(k.isSymbolicLink())return new Cl(x,x+"/"+y.join("/"))}return m(w)};a();var w0=Object.create(null),{hasOwnProperty:vK}=Object.prototype,$d=t=>(vK.call(w0,t)||(w0[t]=t.normalize("NFD")),w0[t]);a();var x0=require("node:path");var wK=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,xK=wK==="win32",EK=t=>t.split("/").slice(0,-1).reduce((r,n)=>{let o=r[r.length-1];return o!==void 0&&(n=(0,x0.join)(o,n)),r.push(n||"/"),r},[]),Ld=class{#e=new Map;#t=new Map;#n=new Set;reserve(e,r){e=xK?["win32 parallelization disabled"]:e.map(o=>yn((0,x0.join)($d(o))).toLowerCase());let n=new Set(e.map(o=>EK(o)).reduce((o,i)=>o.concat(i)));this.#t.set(r,{dirs:n,paths:e});for(let o of e){let i=this.#e.get(o);i?i.push(r):this.#e.set(o,[r])}for(let o of n){let i=this.#e.get(o);if(!i)this.#e.set(o,[new Set([r])]);else{let s=i[i.length-1];s instanceof Set?s.add(r):i.push(new Set([r]))}}return this.#i(r)}#o(e){let r=this.#t.get(e);if(!r)throw new Error("function does not have any path reservations");return{paths:r.paths.map(n=>this.#e.get(n)),dirs:[...r.dirs].map(n=>this.#e.get(n))}}check(e){let{paths:r,dirs:n}=this.#o(e);return r.every(o=>o&&o[0]===e)&&n.every(o=>o&&o[0]instanceof Set&&o[0].has(e))}#i(e){return this.#n.has(e)||!this.check(e)?!1:(this.#n.add(e),e(()=>this.#r(e)),!0)}#r(e){if(!this.#n.has(e))return!1;let r=this.#t.get(e);if(!r)throw new Error("invalid reservation");let{paths:n,dirs:o}=r,i=new Set;for(let s of n){let c=this.#e.get(s);if(!c||c?.[0]!==e)continue;let l=c[1];if(!l){this.#e.delete(s);continue}if(c.shift(),typeof l=="function")i.add(l);else for(let f of l)i.add(f)}for(let s of o){let c=this.#e.get(s),l=c?.[0];if(!(!c||!(l instanceof Set)))if(l.size===1&&c.length===1){this.#e.delete(s);continue}else if(l.size===1){c.shift();let f=c[0];typeof f=="function"&&i.add(f)}else l.delete(e)}return this.#n.delete(e),i.forEach(s=>this.#i(s)),!0}};var sN=Symbol("onEntry"),I0=Symbol("checkFs"),aN=Symbol("checkFs2"),Bd=Symbol("pruneCache"),_0=Symbol("isReusable"),Ir=Symbol("makeFs"),T0=Symbol("file"),O0=Symbol("directory"),zd=Symbol("link"),cN=Symbol("symlink"),lN=Symbol("hardlink"),uN=Symbol("unsupported"),fN=Symbol("checkPath"),Bo=Symbol("mkdir"),vt=Symbol("onError"),jd=Symbol("pending"),pN=Symbol("pend"),ha=Symbol("unpend"),E0=Symbol("ended"),S0=Symbol("maybeClose"),C0=Symbol("skip"),Rl=Symbol("doChown"),Nl=Symbol("uid"),Dl=Symbol("gid"),Pl=Symbol("checkedCwd"),SK=process.env.TESTING_TAR_FAKE_PLATFORM||process.platform,Fl=SK==="win32",IK=1024,_K=(t,e)=>{if(!Fl)return pe.default.unlink(t,e);let r=t+".DELETE."+(0,k0.randomBytes)(16).toString("hex");pe.default.rename(t,r,n=>{if(n)return e(n);pe.default.unlink(r,e)})},TK=t=>{if(!Fl)return pe.default.unlinkSync(t);let e=t+".DELETE."+(0,k0.randomBytes)(16).toString("hex");pe.default.renameSync(t,e),pe.default.unlinkSync(e)},dN=(t,e,r)=>t!==void 0&&t===t>>>0?t:e!==void 0&&e===e>>>0?e:r,mN=t=>yn(re($d(t))).toLowerCase(),OK=(t,e)=>{e=mN(e);for(let r of t.keys()){let n=mN(r);(n===e||n.indexOf(e+"/")===0)&&t.delete(r)}},CK=t=>{for(let e of t.keys())t.delete(e)},ga=class extends Hn{[E0]=!1;[Pl]=!1;[jd]=0;reservations=new Ld;transform;writable=!0;readable=!1;dirCache;uid;gid;setOwner;preserveOwner;processGid;processUid;maxDepth;forceChown;win32;newer;keep;noMtime;preservePaths;unlink;cwd;strip;processUmask;umask;dmode;fmode;chmod;constructor(e={}){if(e.ondone=()=>{this[E0]=!0,this[S0]()},super(e),this.transform=e.transform,this.dirCache=e.dirCache||new Map,this.chmod=!!e.chmod,typeof e.uid=="number"||typeof e.gid=="number"){if(typeof e.uid!="number"||typeof e.gid!="number")throw new TypeError("cannot set owner without number uid and gid");if(e.preserveOwner)throw new TypeError("cannot preserve owner in archive and also set owner explicitly");this.uid=e.uid,this.gid=e.gid,this.setOwner=!0}else this.uid=void 0,this.gid=void 0,this.setOwner=!1;e.preserveOwner===void 0&&typeof e.uid!="number"?this.preserveOwner=!!(process.getuid&&process.getuid()===0):this.preserveOwner=!!e.preserveOwner,this.processUid=(this.preserveOwner||this.setOwner)&&process.getuid?process.getuid():void 0,this.processGid=(this.preserveOwner||this.setOwner)&&process.getgid?process.getgid():void 0,this.maxDepth=typeof e.maxDepth=="number"?e.maxDepth:IK,this.forceChown=e.forceChown===!0,this.win32=!!e.win32||Fl,this.newer=!!e.newer,this.keep=!!e.keep,this.noMtime=!!e.noMtime,this.preservePaths=!!e.preservePaths,this.unlink=!!e.unlink,this.cwd=re(wn.default.resolve(e.cwd||process.cwd())),this.strip=Number(e.strip)||0,this.processUmask=this.chmod?typeof e.processUmask=="number"?e.processUmask:process.umask():0,this.umask=typeof e.umask=="number"?e.umask:this.processUmask,this.dmode=e.dmode||511&~this.umask,this.fmode=e.fmode||438&~this.umask,this.on("entry",r=>this[sN](r))}warn(e,r,n={}){return(e==="TAR_BAD_ARCHIVE"||e==="TAR_ABORT")&&(n.recoverable=!1),super.warn(e,r,n)}[S0](){this[E0]&&this[jd]===0&&(this.emit("prefinish"),this.emit("finish"),this.emit("end"))}[fN](e){let r=re(e.path),n=r.split("/");if(this.strip){if(n.length=this.strip)e.linkpath=o.slice(this.strip).join("/");else return!1}n.splice(0,this.strip),e.path=n.join("/")}if(isFinite(this.maxDepth)&&n.length>this.maxDepth)return this.warn("TAR_ENTRY_ERROR","path excessively deep",{entry:e,path:r,depth:n.length,maxDepth:this.maxDepth}),!1;if(!this.preservePaths){if(n.includes("..")||Fl&&/^[a-z]:\.\.$/i.test(n[0]??""))return this.warn("TAR_ENTRY_ERROR","path contains '..'",{entry:e,path:r}),!1;let[o,i]=bl(r);o&&(e.path=String(i),this.warn("TAR_ENTRY_INFO",`stripping ${o} from absolute path`,{entry:e,path:r}))}if(wn.default.isAbsolute(e.path)?e.absolute=re(wn.default.resolve(e.path)):e.absolute=re(wn.default.resolve(this.cwd,e.path)),!this.preservePaths&&typeof e.absolute=="string"&&e.absolute.indexOf(this.cwd+"/")!==0&&e.absolute!==this.cwd)return this.warn("TAR_ENTRY_ERROR","path escaped extraction target",{entry:e,path:re(e.path),resolvedPath:e.absolute,cwd:this.cwd}),!1;if(e.absolute===this.cwd&&e.type!=="Directory"&&e.type!=="GNUDumpDir")return!1;if(this.win32){let{root:o}=wn.default.win32.parse(String(e.absolute));e.absolute=o+Hv(String(e.absolute).slice(o.length));let{root:i}=wn.default.win32.parse(e.path);e.path=i+Hv(e.path.slice(i.length))}return!0}[sN](e){if(!this[fN](e))return e.resume();switch(hN.default.equal(typeof e.absolute,"string"),e.type){case"Directory":case"GNUDumpDir":e.mode&&(e.mode=e.mode|448);case"File":case"OldFile":case"ContiguousFile":case"Link":case"SymbolicLink":return this[I0](e);case"CharacterDevice":case"BlockDevice":case"FIFO":default:return this[uN](e)}}[vt](e,r){e.name==="CwdError"?this.emit("error",e):(this.warn("TAR_ENTRY_ERROR",e,{entry:r}),this[ha](),r.resume())}[Bo](e,r,n){nN(re(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:r},n)}[Rl](e){return this.forceChown||this.preserveOwner&&(typeof e.uid=="number"&&e.uid!==this.processUid||typeof e.gid=="number"&&e.gid!==this.processGid)||typeof this.uid=="number"&&this.uid!==this.processUid||typeof this.gid=="number"&&this.gid!==this.processGid}[Nl](e){return dN(this.uid,e.uid,this.processUid)}[Dl](e){return dN(this.gid,e.gid,this.processGid)}[T0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,o=new qn(String(e.absolute),{flags:l0(e.size),mode:n,autoClose:!1});o.on("error",l=>{o.fd&&pe.default.close(o.fd,()=>{}),o.write=()=>!0,this[vt](l,e),r()});let i=1,s=l=>{if(l){o.fd&&pe.default.close(o.fd,()=>{}),this[vt](l,e),r();return}--i===0&&o.fd!==void 0&&pe.default.close(o.fd,f=>{f?this[vt](f,e):this[ha](),r()})};o.on("finish",()=>{let l=String(e.absolute),f=o.fd;if(typeof f=="number"&&e.mtime&&!this.noMtime){i++;let u=e.atime||new Date,d=e.mtime;pe.default.futimes(f,u,d,m=>m?pe.default.utimes(l,u,d,h=>s(h&&m)):s())}if(typeof f=="number"&&this[Rl](e)){i++;let u=this[Nl](e),d=this[Dl](e);typeof u=="number"&&typeof d=="number"&&pe.default.fchown(f,u,d,m=>m?pe.default.chown(l,u,d,h=>s(h&&m)):s())}s()});let c=this.transform&&this.transform(e)||e;c!==e&&(c.on("error",l=>{this[vt](l,e),r()}),e.pipe(c)),c.pipe(o)}[O0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.dmode;this[Bo](String(e.absolute),n,o=>{if(o){this[vt](o,e),r();return}let i=1,s=()=>{--i===0&&(r(),this[ha](),e.resume())};e.mtime&&!this.noMtime&&(i++,pe.default.utimes(String(e.absolute),e.atime||new Date,e.mtime,s)),this[Rl](e)&&(i++,pe.default.chown(String(e.absolute),Number(this[Nl](e)),Number(this[Dl](e)),s)),s()})}[uN](e){e.unsupported=!0,this.warn("TAR_ENTRY_UNSUPPORTED",`unsupported entry type: ${e.type}`,{entry:e}),e.resume()}[cN](e,r){this[zd](e,String(e.linkpath),"symlink",r)}[lN](e,r){let n=re(wn.default.resolve(this.cwd,String(e.linkpath)));this[zd](e,n,"link",r)}[pN](){this[jd]++}[ha](){this[jd]--,this[S0]()}[C0](e){this[ha](),e.resume()}[_0](e,r){return e.type==="File"&&!this.unlink&&r.isFile()&&r.nlink<=1&&!Fl}[I0](e){this[pN]();let r=[e.path];e.linkpath&&r.push(e.linkpath),this.reservations.reserve(r,n=>this[aN](e,n))}[Bd](e){e.type==="SymbolicLink"?CK(this.dirCache):e.type!=="Directory"&&OK(this.dirCache,String(e.absolute))}[aN](e,r){this[Bd](e);let n=c=>{this[Bd](e),r(c)},o=()=>{this[Bo](this.cwd,this.dmode,c=>{if(c){this[vt](c,e),n();return}this[Pl]=!0,i()})},i=()=>{if(e.absolute!==this.cwd){let c=re(wn.default.dirname(String(e.absolute)));if(c!==this.cwd)return this[Bo](c,this.dmode,l=>{if(l){this[vt](l,e),n();return}s()})}s()},s=()=>{pe.default.lstat(String(e.absolute),(c,l)=>{if(l&&(this.keep||this.newer&&l.mtime>(e.mtime??l.mtime))){this[C0](e),n();return}if(c||this[_0](e,l))return this[Ir](null,e,n);if(l.isDirectory()){if(e.type==="Directory"){let f=this.chmod&&e.mode&&(l.mode&4095)!==e.mode,u=d=>this[Ir](d??null,e,n);return f?pe.default.chmod(String(e.absolute),Number(e.mode),u):u()}if(e.absolute!==this.cwd)return pe.default.rmdir(String(e.absolute),f=>this[Ir](f??null,e,n))}if(e.absolute===this.cwd)return this[Ir](null,e,n);_K(String(e.absolute),f=>this[Ir](f??null,e,n))})};this[Pl]?i():o()}[Ir](e,r,n){if(e){this[vt](e,r),n();return}switch(r.type){case"File":case"OldFile":case"ContiguousFile":return this[T0](r,n);case"Link":return this[lN](r,n);case"SymbolicLink":return this[cN](r,n);case"Directory":case"GNUDumpDir":return this[O0](r,n)}}[zd](e,r,n,o){pe.default[n](r,String(e.absolute),i=>{i?this[vt](i,e):(this[ha](),e.resume()),o()})}},qd=t=>{try{return[null,t()]}catch(e){return[e,null]}},Ml=class extends ga{sync=!0;[Ir](e,r){return super[Ir](e,r,()=>{})}[I0](e){if(this[Bd](e),!this[Pl]){let i=this[Bo](this.cwd,this.dmode);if(i)return this[vt](i,e);this[Pl]=!0}if(e.absolute!==this.cwd){let i=re(wn.default.dirname(String(e.absolute)));if(i!==this.cwd){let s=this[Bo](i,this.dmode);if(s)return this[vt](s,e)}}let[r,n]=qd(()=>pe.default.lstatSync(String(e.absolute)));if(n&&(this.keep||this.newer&&n.mtime>(e.mtime??n.mtime)))return this[C0](e);if(r||this[_0](e,n))return this[Ir](null,e);if(n.isDirectory()){if(e.type==="Directory"){let s=this.chmod&&e.mode&&(n.mode&4095)!==e.mode,[c]=s?qd(()=>{pe.default.chmodSync(String(e.absolute),Number(e.mode))}):[];return this[Ir](c,e)}let[i]=qd(()=>pe.default.rmdirSync(String(e.absolute)));this[Ir](i,e)}let[o]=e.absolute===this.cwd?[]:qd(()=>TK(String(e.absolute)));this[Ir](o,e)}[T0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.fmode,o=c=>{let l;try{pe.default.closeSync(i)}catch(f){l=f}(c||l)&&this[vt](c||l,e),r()},i;try{i=pe.default.openSync(String(e.absolute),l0(e.size),n)}catch(c){return o(c)}let s=this.transform&&this.transform(e)||e;s!==e&&(s.on("error",c=>this[vt](c,e)),e.pipe(s)),s.on("data",c=>{try{pe.default.writeSync(i,c,0,c.length)}catch(l){o(l)}}),s.on("end",()=>{let c=null;if(e.mtime&&!this.noMtime){let l=e.atime||new Date,f=e.mtime;try{pe.default.futimesSync(i,l,f)}catch(u){try{pe.default.utimesSync(String(e.absolute),l,f)}catch{c=u}}}if(this[Rl](e)){let l=this[Nl](e),f=this[Dl](e);try{pe.default.fchownSync(i,Number(l),Number(f))}catch(u){try{pe.default.chownSync(String(e.absolute),Number(l),Number(f))}catch{c=c||u}}}o(c)})}[O0](e,r){let n=typeof e.mode=="number"?e.mode&4095:this.dmode,o=this[Bo](String(e.absolute),n);if(o){this[vt](o,e),r();return}if(e.mtime&&!this.noMtime)try{pe.default.utimesSync(String(e.absolute),e.atime||new Date,e.mtime)}catch{}if(this[Rl](e))try{pe.default.chownSync(String(e.absolute),Number(this[Nl](e)),Number(this[Dl](e)))}catch{}r(),e.resume()}[Bo](e,r){try{return iN(re(e),{uid:this.uid,gid:this.gid,processUid:this.processUid,processGid:this.processGid,umask:this.processUmask,preserve:this.preservePaths,unlink:this.unlink,cache:this.dirCache,cwd:this.cwd,mode:r})}catch(n){return n}}[zd](e,r,n,o){let i=`${n}Sync`;try{pe.default[i](r,String(e.absolute)),o(),e.resume()}catch(s){return this[vt](s,e)}}};var kK=t=>{let e=new Ml(t),r=t.file,n=A0.default.statSync(r),o=t.maxReadSize||16*1024*1024;new ed(r,{readSize:o,size:n.size}).pipe(e)},AK=(t,e)=>{let r=new ga(t),n=t.maxReadSize||16*1024*1024,o=t.file;return new Promise((s,c)=>{r.on("error",c),r.on("close",s),A0.default.stat(o,(l,f)=>{if(l)c(l);else{let u=new Ni(o,{readSize:n,size:f.size});u.on("error",c),u.pipe(r)}})})},RK=mn(kK,AK,t=>new Ml(t),t=>new ga(t),(t,e)=>{e?.length&&zv(t,e)});a();var Bt=Y(require("node:fs"),1),R0=Y(require("node:path"),1);var NK=(t,e)=>{let r=new Ui(t),n=!0,o,i;try{try{o=Bt.default.openSync(t.file,"r+")}catch(l){if(l?.code==="ENOENT")o=Bt.default.openSync(t.file,"w+");else throw l}let s=Bt.default.fstatSync(o),c=Buffer.alloc(512);e:for(i=0;is.size)break;i+=f,t.mtimeCache&&l.mtime&&t.mtimeCache.set(String(l.path),l.mtime)}n=!1,DK(t,r,i,o,e)}finally{if(n)try{Bt.default.closeSync(o)}catch{}}},DK=(t,e,r,n,o)=>{let i=new ca(t.file,{fd:n,start:r});e.pipe(i),FK(e,o)},PK=(t,e)=>{e=Array.from(e);let r=new jo(t),n=(i,s,c)=>{let l=(h,y)=>{h?Bt.default.close(i,w=>c(h)):c(null,y)},f=0;if(s===0)return l(null,0);let u=0,d=Buffer.alloc(512),m=(h,y)=>{if(h||typeof y>"u")return l(h);if(u+=y,u<512&&y)return Bt.default.read(i,d,u,d.length-u,f+u,m);if(f===0&&d[0]===31&&d[1]===139)return l(new Error("cannot append to compressed archives"));if(u<512)return l(null,f);let w=new nr(d);if(!w.cksumValid)return l(null,f);let v=512*Math.ceil((w.size??0)/512);if(f+v+512>s||(f+=v+512,f>=s))return l(null,f);t.mtimeCache&&w.mtime&&t.mtimeCache.set(String(w.path),w.mtime),u=0,Bt.default.read(i,d,0,512,f,m)};Bt.default.read(i,d,0,512,f,m)};return new Promise((i,s)=>{r.on("error",s);let c="r+",l=(f,u)=>{if(f&&f.code==="ENOENT"&&c==="r+")return c="w+",Bt.default.open(t.file,c,l);if(f||!u)return s(f);Bt.default.fstat(u,(d,m)=>{if(d)return Bt.default.close(u,()=>s(d));n(u,m.size,(h,y)=>{if(h)return s(h);let w=new qn(t.file,{fd:u,start:y});r.pipe(w),w.on("error",s),w.on("close",i),MK(r,e)})})};Bt.default.open(t.file,c,l)})},FK=(t,e)=>{e.forEach(r=>{r.charAt(0)==="@"?Kn({file:R0.default.resolve(t.cwd,r.slice(1)),sync:!0,noResume:!0,onReadEntry:n=>t.add(n)}):t.add(r)}),t.end()},MK=async(t,e)=>{for(let r=0;rt.add(o)}):t.add(n)}t.end()},Wi=mn(NK,PK,()=>{throw new TypeError("file is required")},()=>{throw new TypeError("file is required")},(t,e)=>{if(!xR(t))throw new TypeError("file is required");if(t.gzip||t.brotli||t.file.endsWith(".br")||t.file.endsWith(".tbr"))throw new TypeError("cannot append to compressed archives");if(!e?.length)throw new TypeError("no paths specified to add/replace")});a();var $K=mn(Wi.syncFile,Wi.asyncFile,Wi.syncNoFile,Wi.asyncNoFile,(t,e=[])=>{Wi.validate?.(t,e),LK(t)}),LK=t=>{let e=t.filter;t.mtimeCache||(t.mtimeCache=new Map),t.filter=e?(r,n)=>e(r,n)&&!((t.mtimeCache?.get(r)??n.mtime??0)>(n.mtime??0)):(r,n)=>!((t.mtimeCache?.get(r)??n.mtime??0)>(n.mtime??0))};var Wd=async(t,e,r)=>{if(r){await(0,Ud.writeFile)(e,Buffer.from(t));return}let n=(0,gN.createWriteStream)(e);try{let o="build/Release/better_sqlite3.node",i=[];i.push((0,N0.pipeline)(yN.Readable.from(Buffer.from(t)),Kn({gzip:!0,onReadEntry:s=>{s.path===o&&i.push((0,N0.pipeline)(s,n))}},[o]))),await Promise.all(i)}catch(o){throw n.destroy(),await(0,Ud.rm)(e,{force:!0}),o}},bN=async()=>{let t=await uR({multiple:!1,accept:[".tar.gz",".node"],strict:!0});return t?{decompressed:!t.name.endsWith(".gz"),arrayBuffer:await t.arrayBuffer()}:null},vN=async t=>(await(0,D0.requestUrl)({url:t,method:"HEAD"})).status,wN=async t=>(await(0,D0.requestUrl)({url:t})).arrayBuffer;var xN=(i=>(i[i.Idle=0]="Idle",i[i.Downloading=1]="Downloading",i[i.Importing=2]="Importing",i[i.Success=3]="Success",i[i.Failed=4]="Failed",i))(xN||{}),ya=er(0),qK=er(t=>t(ya)===4),EN=er(null),BK=er(t=>{switch(t(ya)){case 0:return null;case 1:return"Downloading...";case 2:return"Importing...";case 3:return"Module successfully installed";case 4:return`Module install failed: ${t(EN)}`;default:break}}),zK=er(null,(t,e,[r,n])=>{e(ya,4);let o="Failed to install module when "+xN[r];gt(o,n),e(EN,o+": "+(n instanceof Error?n.message:`${n}`))}),UK=()=>{let t=dv(ya),e=dv(zK),r=It(ol),n=It(zp);return tr(async()=>{if(!n){e([0,new Error("Cannot find binary version")]);return}t(1);let o;try{if(await vN(r)===404)throw new Error(`Requested module not available (${r}), please open an issue on GitHub`);o=await wN(r)}catch(i){e([1,i]);return}t(2);try{await Wd(o,n,!1)}catch(i){e([2,i]);return}t(3)})},SN=()=>{let t=It(ya),e=It(BK),r=It(Oo),n=UK();return g("div",{className:"zt-auto-install",children:[g(sl,{name:"Auto Install",desc:"Recommended",button:t===0?"Install":void 0,onClick:n}),t!==0&&g(sl,{className:ta("zt-auto-install-status",{"mod-warning":t===4,"mod-success":t===3}),icon:g(HK,{}),name:e,button:t===3?"Reload Plugin":void 0,onClick:()=>r.reloadPlugin()})]})},WK=()=>{let t=It(qK),[e]=jt(t?"slash":"check");return g("div",{className:"zt-install-done-icon",style:{display:"contents"},ref:e})},HK=()=>{switch(It(ya)){case 0:return null;case 1:case 2:return g(lR,{className:"zt-install-spin-icon",style:{display:"contents"}});case 3:case 4:return g(WK,{})}};a();var IN=require("obsidian");_();var KK=async t=>{try{let e=await bN();return e?(await Wd(e.arrayBuffer,t,e.decompressed),!0):(H.info("No file selected, skip import module"),!1)}catch(e){return new IN.Notice(`Failed to import module from ${t}: ${e}`),gt("import module "+t,e),!1}},VK=()=>{let[t,e]=q(!1),r=It(zp),n=async()=>{if(!r)return;await KK(r)&&e(!0)},o=It(ol),i=It(mv),s=It(Oo);return g("ol",{children:[g("li",{children:["Download ",g("code",{children:".node.gz"})," file from"," ",g("a",{href:o,children:"GitHub"}),"."]}),g("li",{children:["Select downloaded ",g("code",{children:i})," or uncompressed"," ",g("code",{children:"better-sqlite3.node"}),"to install:",g(GK,{onClick:n,done:t})]}),g("li",{children:["Reload ZotLit:",g(ZK,{onClick:()=>s.reloadPlugin()})]})]})},_N=()=>{let[t,e]=q(!1);return g("div",{className:"zt-manual-install",children:[g(sl,{name:"Manual Install",desc:"Use this option if you have trouble downloading the module with auto install.",button:`${t?"Hide":"Show"} Guide`,onClick:()=>e(r=>!r)}),g("div",{hidden:!t,children:g(VK,{})})]})},GK=({done:t,onClick:e})=>g("button",{className:ta({"zt-import-done":t}),onClick:e,children:t?"Library file imported":"Select"}),ZK=({disabled:t,onClick:e})=>g("button",{disabled:t,onClick:e,children:"Reload Plugin"});var JK=()=>{let t=It(eR);switch(t){case"install":return g(L,{children:["ZotLit requires latest version of ",g("code",{children:"better-sqlite3"})," to be installed. Use one of the method below to install or update it."]});case"reset":return g(L,{children:[g("code",{children:"better-sqlite3"})," seems to be broken and failed to load. you can try to use one of the method below to reinstall it."]});default:(0,TN.default)(t)}},ON=()=>g(L,{children:[g("style",{children:` .modal.mod-zt-install-guide .modal-content { display: flex; flex-direction: column; @@ -84,10 +84,10 @@ ${t}`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},custom:{mustBe:t=>t},cases:{ .zt-auto-install-status .setting-item-name { color: var(--text-muted); } - `}),m("div",{className:"zt-install-desc",children:m(AK,{})}),m("div",{className:"zt-install-methods",children:[m(uN,{}),m(pN,{})]})]});var Ac=class extends hN.Modal{constructor(r,n,o,i,s){super(s);this.manifest=r;this.platform=n;this.binaryVersion=o;this.mode=i;this.app=s;this.titleEl.setText("Setup ZotLit"),this.modalEl.addClass("mod-zt-install-guide")}onOpen(){let r=qk();r.set(Dr,this),N.render(m(jk,{initialValues:r.get(),children:m(mN,{})}),this.contentEl)}onClose(){N.unmountComponentAtNode(this.contentEl)}async reloadPlugin(){await this.app.plugins.disablePlugin(this.manifest.id),this.close(),await this.app.plugins.enablePlugin(this.manifest.id)}};var gN=(t,e,r,n)=>{let o=_T();if(!o)throw new Error("Not in desktop app");let i=ST(o);if(i<0)new Hn.Notice(`The electron (electron: ${o.electron}, module version: ${o.modules}) in current version of obsidian is not supported by zotlit, please reinstall using latest obsidian installer (.exe/.dmg/...) from obsidian.md`);else if(i>0)new Hn.Notice(`The electron (electron: ${o.electron}, module version: ${o.modules}) in current version of obsidian is newer than the one supported by installed zotlit, please update zotlit to the latest version`);else if(!IT(o))new Hn.Notice(`Your device (${o.arch}-${o.platform}) is not supported by zotlit`);else{let s=Hy(e);if(!s)throw new Error(`Cannot find binary version for ${e.name} v${e.version}`);try{(0,yN.statSync)(t).isFile()?r==="reset"&&new Ac(e,o,s,r,n).open():new Hn.Notice("Path to database library occupied, please check the location manually: "+t,2e3)}catch(a){let l=a;l.code==="ENOENT"?new Ac(e,o,s,r,n).open():(new Hn.Notice(`Unexpected error while checking path of better-sqlite3, please check the location manually: ${t}, error: ${l}`,2e3),mt("checking better-sqlite3 path:"+t,l))}}},kK=(t,e)=>{if(!Hn.Platform.isDesktopApp)throw new Error("Not in desktop app");let r=Rs(t);if(!r)throw new Error(`Cannot find binary version for ${t.name} v${t.version}`);try{return require(r),!0}catch(n){return n?.code==="MODULE_NOT_FOUND"?gN(r,t,"install",e):(new Hn.Notice(`Failed to load database library: ${n}`),mt("Failed to load database library",n),gN(r,t,"reset",e)),!1}},bN=kK;var Bq=require("path/posix");var no=require("obsidian");var Ae;(function(t){t[t.highlight=1]="highlight",t[t.note=2]="note",t[t.image=3]="image",t[t.ink=4]="ink",t[t.underline=5]="underline",t[t.text=6]="text"})(Ae||(Ae={}));var Bi;(function(t){t[t.manual=0]="manual",t[t.auto=1]="auto"})(Bi||(Bi={}));var Md;(function(t){t[t.importedFile=0]="importedFile",t[t.importedUrl=1]="importedUrl",t[t.linkedFile=2]="linkedFile",t[t.linkedUrl=3]="linkedUrl",t[t.embeddedImage=4]="embeddedImage"})(Md||(Md={}));var kc;(function(t){t[t.fullName=0]="fullName",t[t.nameOnly=1]="nameOnly"})(kc||(kc={}));var $d=["attachment","note","annotation"];var Ld=$d.map(t=>`'${t}'`).join(",");var nt=(t="itemID")=>`--sql + `}),g("div",{className:"zt-install-desc",children:g(JK,{})}),g("div",{className:"zt-install-methods",children:[g(SN,{}),g(_N,{})]})]});var $l=class extends CN.Modal{constructor(r,n,o,i){super(i);this.manifest=r;this.platform=n;this.mode=o;this.app=i;this.titleEl.setText("Setup ZotLit"),this.modalEl.addClass("mod-zt-install-guide")}onOpen(){let r=QA();r.set(Oo,this),P.render(g(XA,{initialValues:r.get(),children:g(ON,{})}),this.contentEl)}onClose(){P.unmountComponentAtNode(this.contentEl)}async reloadPlugin(){await this.app.plugins.disablePlugin(this.manifest.id),this.close(),await this.app.plugins.enablePlugin(this.manifest.id)}};var kN=(t,e,r,n)=>{let o=LO();if(!o)throw new Error("Not in desktop app");let i=MO(o);if(i<0)new Gn.Notice(`The electron (electron: ${o.electron}, module version: ${o.modules}) in current version of obsidian is not supported by zotlit, please reinstall using latest obsidian installer (.exe/.dmg/...) from obsidian.md`);else if(i>0)new Gn.Notice(`The electron (electron: ${o.electron}, module version: ${o.modules}) in current version of obsidian is newer than the one supported by installed zotlit, please update zotlit to the latest version`);else if(!$O(o))new Gn.Notice(`Your device (${o.arch}-${o.platform}) is not supported by zotlit`);else try{(0,AN.statSync)(t).isFile()?r==="reset"&&new $l(e,o,r,n).open():new Gn.Notice("Path to database library occupied, please check the location manually: "+t,2e3)}catch(s){let c=s;c.code==="ENOENT"?new $l(e,o,r,n).open():(new Gn.Notice(`Unexpected error while checking path of better-sqlite3, please check the location manually: ${t}, error: ${c}`,2e3),gt("checking better-sqlite3 path:"+t,c))}},YK=(t,e)=>{if(!Gn.Platform.isDesktopApp)throw new Error("Not in desktop app");let r=$s();if(!r)throw new Error(`Cannot find binary version for ${t.name} v${t.version}`);try{return require(r),!0}catch(n){return n?.code==="MODULE_NOT_FOUND"?kN(r,t,"install",e):(new Gn.Notice(`Failed to load database library: ${n}`),gt("Failed to load database library",n),kN(r,t,"reset",e)),!1}},RN=YK;a();var eB=require("path/posix");var so=require("obsidian");a();a();a();a();a();a();a();a();var Ne;(function(t){t[t.highlight=1]="highlight",t[t.note=2]="note",t[t.image=3]="image",t[t.ink=4]="ink",t[t.underline=5]="underline",t[t.text=6]="text"})(Ne||(Ne={}));var Hi;(function(t){t[t.manual=0]="manual",t[t.auto=1]="auto"})(Hi||(Hi={}));var Hd;(function(t){t[t.importedFile=0]="importedFile",t[t.importedUrl=1]="importedUrl",t[t.linkedFile=2]="linkedFile",t[t.linkedUrl=3]="linkedUrl",t[t.embeddedImage=4]="embeddedImage"})(Hd||(Hd={}));var Ll;(function(t){t[t.fullName=0]="fullName",t[t.nameOnly=1]="nameOnly"})(Ll||(Ll={}));a();var Kd=["attachment","note","annotation"];a();a();var Vd=Kd.map(t=>`'${t}'`).join(",");var st=(t="itemID")=>`--sql ${t} IS NOT NULL ${t==="itemID"?`AND ${t} NOT IN (SELECT itemID FROM deletedItems)`:""} -`,xr=(t,e="$itemId")=>typeof t=="boolean"?"":`AND ${t} = ${e}`;var jd=(t,e)=>{for(let r=0;r!!t.path,Rc=t=>I0(t)&&!!t.contentType&&RK.has(t.contentType),vN=t=>`obzt-active-atch-${t.itemID}-${t.libraryID}`,_0=(t,e)=>{let r=t.getItem(vN(e));if(!r)return null;let n=parseInt(r,10);return n>0?n:null},pa=(t,e,r)=>t.setItem(vN(e),r.toString());var qd=`--sql +`,_r=(t,e="$itemId")=>typeof t=="boolean"?"":`AND ${t} = ${e}`;a();a();a();var Gd=(t,e)=>{for(let r=0;r!!t.path,jl=t=>P0(t)&&!!t.contentType&&XK.has(t.contentType),NN=t=>`obzt-active-atch-${t.itemID}-${t.libraryID}`,F0=(t,e)=>{let r=t.getItem(NN(e));if(!r)return null;let n=parseInt(r,10);return n>0?n:null},ba=(t,e,r)=>t.setItem(NN(e),r.toString());var Zd=`--sql items.itemID, items.key, items.clientDateModified, @@ -102,31 +102,31 @@ ${t}`,addContext:(t,e)=>e.length?`At ${e}, ${t}`:t},custom:{mustBe:t=>t},cases:{ annots.sortIndex, annots.position, annots.isExternal -`,Bd=`--sql +`,Jd=`--sql itemAnnotations annots JOIN items USING (itemID) -`;var lEe=`--sql +`;var I1e=`--sql SELECT - ${qd}, + ${Zd}, annots.parentItemID, parentItems.key as parentItem FROM - ${Bd} + ${Jd} JOIN items as parentItems ON annots.parentItemID = parentItems.itemID WHERE items.key = $annotKey AND items.libraryID = $libId - AND ${nt("items.itemID")} -`;var dEe=`--sql + AND ${st("items.itemID")} +`;a();var A1e=`--sql SELECT - ${qd} + ${Zd} FROM - ${Bd} + ${Jd} WHERE parentItemID = $attachmentId AND items.libraryID = $libId - AND ${nt()} -`;var zd=`--sql + AND ${st()} +`;a();a();var Yd=`--sql items.itemID, items.key, items.clientDateModified, @@ -134,31 +134,31 @@ WHERE items.dateModified, notes.note, notes.title -`,Ud=`--sql +`,Xd=`--sql itemNotes notes JOIN items USING (itemID) -`;var bEe=`--sql +`;var $1e=`--sql SELECT - ${zd}, + ${Yd}, notes.parentItemID, parentItems.key as parentItem FROM - ${Ud} + ${Xd} JOIN items as parentItems ON notes.parentItemID = parentItems.itemID WHERE items.key = $noteKey AND items.libraryID = $libId - AND ${nt("items.itemID")} -`;var EEe=`--sql + AND ${st("items.itemID")} +`;a();var z1e=`--sql SELECT - ${zd} + ${Yd} FROM - ${Ud} + ${Xd} WHERE parentItemID = $itemID AND items.libraryID = $libId - AND ${nt()} -`;var _Ee=`--sql + AND ${st()} +`;a();var K1e=`--sql SELECT atchs.itemID, atchs.path, @@ -175,39 +175,39 @@ FROM WHERE atchs.parentItemID = $itemId AND libraryID = $libId - AND ${nt("atchs.itemID")} + AND ${st("atchs.itemID")} GROUP BY atchs.itemID -`;var Nc="betterbibtex",Dc="bbts";var kEe=`--sql +`;a();a();var ql="betterbibtex",Bl="bbts";var Q1e=`--sql SELECT citationkey as citekey FROM - ${Nc}.citationkey + ${ql}.citationkey WHERE itemID = $itemID AND (libraryID IS NULL OR libraryID = $libId) -`,REe=`--sql +`,e_e=`--sql SELECT citekey FROM - ${Dc}.citekeys + ${Bl}.citekeys WHERE itemID = $itemID AND (libraryID IS NULL OR libraryID = $libId) -`;var PEe=`--sql +`;a();var i_e=`--sql SELECT itemID FROM - ${Nc}.citationkey + ${ql}.citationkey WHERE citationkey = $citekey -`,MEe=`--sql +`,s_e=`--sql SELECT itemID FROM - ${Dc}.citekeys + ${Bl}.citekeys WHERE citekey = $citekey -`;var Wd=t=>`--sql +`;a();a();var Qd=t=>`--sql SELECT itemID, creators.firstName, @@ -222,12 +222,12 @@ FROM JOIN creatorTypes USING (creatorTypeID) WHERE libraryID = $libId - ${xr(t||"itemID")} - AND ${nt()} + ${_r(t||"itemID")} + AND ${st()} ORDER BY itemID, orderIndex -`;var zEe=Wd(!0);function xN(t){return t===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:t!==null&&t.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:t.BS_PRIVATE_NESTED_SOME_NONE+1|0}:t}function EN(t,e){for(var r=t.length,n=e.length,o=new Array(r+n|0),i=0;ie||t`--sql +`;var m_e=Qd(!0);a();a();a();a();a();function PN(t){return t===void 0?{BS_PRIVATE_NESTED_SOME_NONE:0}:t!==null&&t.BS_PRIVATE_NESTED_SOME_NONE!==void 0?{BS_PRIVATE_NESTED_SOME_NONE:t.BS_PRIVATE_NESTED_SOME_NONE+1|0}:t}a();function FN(t,e){for(var r=t.length,n=e.length,o=new Array(r+n|0),i=0;ie||t`--sql SELECT items.itemID, fieldsCombined.fieldName, @@ -240,10 +240,10 @@ FROM JOIN itemTypesCombined USING (itemTypeID) WHERE libraryID = $libId - ${xr(t||"items.itemID")} - AND itemTypesCombined.typeName NOT IN (${Ld}) - AND ${nt()} -`;var LSe=Xd(!0);var zSe=Xd(!1);var $c=t=>`--sql + ${_r(t||"items.itemID")} + AND itemTypesCombined.typeName NOT IN (${Vd}) + AND ${st()} +`;var vTe=am(!0);a();var ITe=am(!1);a();a();var Hl=t=>`--sql SELECT items.libraryID, items.itemID, @@ -259,11 +259,11 @@ FROM LEFT JOIN collectionItems USING (itemID) WHERE libraryID = $libId - ${t==="full"?xr(!1):t==="id"?xr("items.itemID"):xr("items.key","$key")} - AND ${nt()} - AND itemType NOT IN (${Ld}) + ${t==="full"?_r(!1):t==="id"?_r("items.itemID"):_r("items.key","$key")} + AND ${st()} + AND itemType NOT IN (${Vd}) GROUP BY itemID -`;var GSe=$c("full");var XSe=$c("id"),QSe=$c("key");var Lc=t=>`--sql +`;var NTe=Hl("full");a();var $Te=Hl("id"),LTe=Hl("key");a();a();var Kl=t=>`--sql WITH RECURSIVE CollectionPath AS ( -- Base case: collections without a parent @@ -275,8 +275,8 @@ WITH collections WHERE libraryID = $libId - ${t==="full"?xr(!1):t==="id"?xr("collectionID","$collectionID"):xr("key","$key")} - AND ${nt("collectionID")} + ${t==="full"?_r(!1):t==="id"?_r("collectionID","$collectionID"):_r("key","$key")} + AND ${st("collectionID")} UNION ALL -- Recursive case: join with parent collections SELECT @@ -300,23 +300,23 @@ GROUP BY collectionID ORDER BY collectionID; -`;var i1e=Lc("full");var c1e=Lc("id"),u1e=Lc("key");var iD=require("path"),Lo=({groupID:t,key:e},r)=>{let n=[r,"cache"];return t?n.push("groups",t.toString()):n.push("library"),(0,iD.join)(...n,e+".png")};var jc=t=>Qd(t)?[t.firstName,t.lastName].join(" "):em(t)?t.lastName:null,Qd=t=>{let e=t;return e.fieldMode===kc.fullName&&e.firstName!==null&&e.lastName!==null},em=t=>{let e=t;return e.fieldMode===kc.nameOnly&&e.lastName!==null},A0=new Set(ao()("creators","itemID","itemType","key","libraryID","collections")),k0=t=>!$d.includes(t.itemType)&&typeof t.key=="string",qc=t=>t.itemType==="annotation"&&!!t.parentItem;var sD=t=>typeof t.groupID=="number"?`groups/${t.groupID}`:"library",jo=t=>{let e;if(k0(t))e=new URL(`zotero://select/${sD(t)}/items/${t.key}`);else if(qc(t)){e=new URL(`zotero://open-pdf/${sD(t)}/items/${t.parentItem}`);let r;try{r=bs(t.position.pageIndex,!0)}catch(n){console.warn(n),r=null}typeof r=="number"&&e.searchParams.append("page",r.toString()),t.key&&e.searchParams.append("annotation",t.key)}else return"";return e.toString()};var lD=require("obsidian");var rm=require("obsidian");async function aD(t){let e=await Wi(t);if(!e)return null;let{value:r,evt:n}=e;return{value:r.item,evt:n}}function Wi(t){let e,r=new Promise((o,i)=>{e=o}),n=or(t,{selectSuggestion:o=>function(s,a,...l){return e(s!==null?{value:s,evt:a}:null),o.call(this,s,a,...l)},onClose:o=>function(...s){return e(null),o.call(this,...s)}});return r.finally(n),t.open(),r}var tm=class extends rm.SuggestModal{initial=!0;async#e(){let e=this.inputEl.value,r=await this.getSuggestions(e);if(r.length!==0){let n=this.limit;n&&n>0&&(r=r.slice(0,n)),this.chooser.setSuggestions(r)}else e?this.onNoSuggestion():this.chooser.setSuggestions(null)}#t=(0,rm.debounce)(this.#e.bind(this),250,!0);updateSuggestions(){this.initial?(this.#e(),this.initial=!1):this.#t()}};var R0=class extends lD.FuzzySuggestModal{constructor(r,n){super(n);this.attachments=r}getItems(){return this.attachments}renderSuggestion(r,n){n.addClass("mod-complex");let o=n.createDiv("suggestion-content").createDiv("suggestion-title").createSpan(),i=n.createDiv("suggestion-aux");super.renderSuggestion(r,o),i.createEl("kbd","suggestion-hotkey").setText((r.item.annotCount??0).toString())}getItemText(r){return r.path?.replace(/^storage:/,"")??r.key}onChooseItem(){}};async function $K(t,e){return t.length===1?t[0]:t.length?(await aD(new R0(t,e)))?.value??null:null}function ga(t,e){pa(window.localStorage,e,t.itemID)}async function Kn(t,e){let r=t.filter(Rc);return await $K(r,e)}var tx=require("obsidian");var Ot=require("obsidian");var ya=require("obsidian"),cD=()=>`Press ${ya.Platform.isMacOS?"\u2318 Cmd":"Ctrl"} + ${ya.Platform.isMacOS?"\u2325 Option":"Shift"} + I, then go to the "Console" tab to see the log.`;var bt=t=>t instanceof ya.TFile&&t.extension==="md",uD=t=>typeof t=="string"?t:t.path;function N0(t){let e=zi(t,o=>o.comment?.match(zy)?.[1]??-1),r=e[-1]??[],n=new Map(r.map(o=>[o.itemID,[o]]));delete e[-1];for(let[o,i]of Object.entries(e)){let s=n.get(+o);i.forEach(a=>{a.comment&&=a.comment.replace(zy,"")??null}),s?s.push(...i.sort((a,l)=>jd(a.sortIndex,l.sortIndex))):i.forEach(a=>{n.set(a.itemID,[a])})}for(let[o,...i]of n.values())if(!(i.length<=0)){for(let s of i)s.comment&&(o.comment=(o.comment??"")+` +`;var KTe=Kl("full");a();var YTe=Kl("id"),XTe=Kl("key");a();a();a();var bD=require("path"),zo=({groupID:t,key:e},r)=>{let n=[r,"cache"];return t?n.push("groups",t.toString()):n.push("library"),(0,bD.join)(...n,e+".png")};a();a();var Vl=t=>cm(t)?[t.firstName,t.lastName].join(" "):lm(t)?t.lastName:null,cm=t=>{let e=t;return e.fieldMode===Ll.fullName&&e.firstName!==null&&e.lastName!==null},lm=t=>{let e=t;return e.fieldMode===Ll.nameOnly&&e.lastName!==null},j0=new Set(uo()("creators","itemID","itemType","key","libraryID","collections")),q0=t=>!Kd.includes(t.itemType)&&typeof t.key=="string",Gl=t=>t.itemType==="annotation"&&!!t.parentItem;var vD=t=>typeof t.groupID=="number"?`groups/${t.groupID}`:"library",Uo=t=>{let e;if(q0(t))e=new URL(`zotero://select/${vD(t)}/items/${t.key}`);else if(Gl(t)){e=new URL(`zotero://open-pdf/${vD(t)}/items/${t.parentItem}`);let r;try{r=Is(t.position.pageIndex,!0)}catch(n){console.warn(n),r=null}typeof r=="number"&&e.searchParams.append("page",r.toString()),t.key&&e.searchParams.append("annotation",t.key)}else return"";return e.toString()};var xD=require("obsidian");a();var fm=require("obsidian");async function wD(t){let e=await Gi(t);if(!e)return null;let{value:r,evt:n}=e;return{value:r.item,evt:n}}function Gi(t){let e,r=new Promise((o,i)=>{e=o}),n=cr(t,{selectSuggestion:o=>function(s,c,...l){return e(s!==null?{value:s,evt:c}:null),o.call(this,s,c,...l)},onClose:o=>function(...s){return e(null),o.call(this,...s)}});return r.finally(n),t.open(),r}var um=class extends fm.SuggestModal{initial=!0;async#e(){let e=this.inputEl.value,r=await this.getSuggestions(e);if(r.length!==0){let n=this.limit;n&&n>0&&(r=r.slice(0,n)),this.chooser.setSuggestions(r)}else e?this.onNoSuggestion():this.chooser.setSuggestions(null)}#t=(0,fm.debounce)(this.#e.bind(this),250,!0);updateSuggestions(){this.initial?(this.#e(),this.initial=!1):this.#t()}};var B0=class extends xD.FuzzySuggestModal{constructor(r,n){super(n);this.attachments=r}getItems(){return this.attachments}renderSuggestion(r,n){n.addClass("mod-complex");let o=n.createDiv("suggestion-content").createDiv("suggestion-title").createSpan(),i=n.createDiv("suggestion-aux");super.renderSuggestion(r,o),i.createEl("kbd","suggestion-hotkey").setText((r.item.annotCount??0).toString())}getItemText(r){return r.path?.replace(/^storage:/,"")??r.key}onChooseItem(){}};async function oV(t,e){return t.length===1?t[0]:t.length?(await wD(new B0(t,e)))?.value??null:null}function Ea(t,e){ba(window.localStorage,e,t.itemID)}async function Zn(t,e){let r=t.filter(jl);return await oV(r,e)}a();a();var fx=require("obsidian");a();a();var kt=require("obsidian");a();var Sa=require("obsidian"),ED=()=>`Press ${Sa.Platform.isMacOS?"\u2318 Cmd":"Ctrl"} + ${Sa.Platform.isMacOS?"\u2325 Option":"Shift"} + I, then go to the "Console" tab to see the log.`;var wt=t=>t instanceof Sa.TFile&&t.extension==="md",SD=t=>typeof t=="string"?t:t.path;a();a();function z0(t){let e=Ki(t,o=>o.comment?.match(eb)?.[1]??-1),r=e[-1]??[],n=new Map(r.map(o=>[o.itemID,[o]]));delete e[-1];for(let[o,i]of Object.entries(e)){let s=n.get(+o);i.forEach(c=>{c.comment&&=c.comment.replace(eb,"")??null}),s?s.push(...i.sort((c,l)=>Gd(c.sortIndex,l.sortIndex))):i.forEach(c=>{n.set(c.itemID,[c])})}for(let[o,...i]of n.values())if(!(i.length<=0)){for(let s of i)s.comment&&(o.comment=(o.comment??"")+` `+s.comment),s.text&&(o.text?o.text.endsWith("-")&&!o.text.endsWith("--")?o.text.substring(0,o.text.length-1)+s.text.trimStart():o.text.match(/[a-zA-Z\d]\s*$/)&&s.text.match(/^\s*[a-zA-Z\d]/)?o.text=o.text.trimEnd()+" "+s.text.trimStart():o.text=o.text.trimEnd()+s.text.trimStart():o.text=s.text);o.comment=o.comment?.replace(/\n+/,` -`).replace(/^\s+|\s+$/g,"")??null}return[...n.values()]}function D0(t){return t.map(e=>e[0])}function F0(t,e){let r=t.map(([n,...o])=>{if(o.length===0)return[n.itemID,e[n.itemID]];let i=new Map(e[n.itemID].map(s=>[s.tagID,s]));return o.forEach(s=>{e[s.itemID].forEach(a=>{i.set(a.tagID,a)})}),[n.itemID,Array.from(i.values())]});return Object.fromEntries(r)}function fD(t,e){let r=N0(t);return{annotations:D0(r),tags:F0(r,e)}}var am=class{constructor(e){this.cache=void 0,this.cache=e}define(e,r){this.cache[e]=r}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},ct=class extends Error{constructor(e){super(e),this.name="Eta Error"}};function Bc(t,e,r){let n=e.slice(0,r).split(/\n/),o=n.length,i=n[o-1].length+1;throw t+=" at line "+o+" col "+i+`: +`).replace(/^\s+|\s+$/g,"")??null}return[...n.values()]}function U0(t){return t.map(e=>e[0])}function W0(t,e){let r=t.map(([n,...o])=>{if(o.length===0)return[n.itemID,e[n.itemID]];let i=new Map(e[n.itemID].map(s=>[s.tagID,s]));return o.forEach(s=>{e[s.itemID].forEach(c=>{i.set(c.tagID,c)})}),[n.itemID,Array.from(i.values())]});return Object.fromEntries(r)}function ID(t,e){let r=z0(t);return{annotations:U0(r),tags:W0(r,e)}}a();a();var gm=class{constructor(e){this.cache=void 0,this.cache=e}define(e,r){this.cache[e]=r}get(e){return this.cache[e]}remove(e){delete this.cache[e]}reset(){this.cache={}}load(e){this.cache={...this.cache,...e}}},pt=class extends Error{constructor(e){super(e),this.name="Eta Error"}};function Zl(t,e,r){let n=e.slice(0,r).split(/\n/),o=n.length,i=n[o-1].length+1;throw t+=" at line "+o+" col "+i+`: `+e.split(/\n/)[o-1]+` - `+Array(i).join(" ")+"^",new ct(t)}function LK(t,e,r,n){let o=e.split(` -`),i=Math.max(r-3,0),s=Math.min(o.length,r+3),a=n,l=o.slice(i,s).map(function(f,p){let d=p+i+1;return(d==r?" >> ":" ")+d+"| "+f}).join(` -`),u=a?a+":"+r+` + `+Array(i).join(" ")+"^",new pt(t)}function iV(t,e,r,n){let o=e.split(` +`),i=Math.max(r-3,0),s=Math.min(o.length,r+3),c=n,l=o.slice(i,s).map(function(d,m){let h=m+i+1;return(h==r?" >> ":" ")+h+"| "+d}).join(` +`),f=c?c+":"+r+` `:"line "+r+` -`,c=new ct(u+l+` +`,u=new pt(f+l+` -`+t.message);throw c.name=t.name,c}var jK=async function(){}.constructor;function qK(t,e){let r=this.config,n=e&&e.async?jK:Function;try{let o=new n(r.varName,"options",this.compileToString.call(this,t,e));return o.mtime=e?.mtime,o}catch(o){throw o instanceof SyntaxError?new ct(`Bad template syntax +`+t.message);throw u.name=t.name,u}var sV=async function(){}.constructor;function aV(t,e){let r=this.config,n=e&&e.async?sV:Function;try{let o=new n(r.varName,"options",this.compileToString.call(this,t,e));return o.mtime=e?.mtime,o}catch(o){throw o instanceof SyntaxError?new pt(`Bad template syntax `+o.message+` `+Array(o.message.length+1).join("=")+` `+this.compileToString.call(this,t,e)+` -`):o}}function BK(t,e){let r=this.config,n=e&&e.async,o=this.compileBody,i=this.parse.call(this,t),s=`${r.functionHeader} +`):o}}function cV(t,e){let r=this.config,n=e&&e.async,o=this.compileBody,i=this.parse.call(this,t),s=`${r.functionHeader} let include = (template, data) => this.render(template, data, options); let includeAsync = (template, data) => this.renderAsync(template, data, options); @@ -333,36 +333,36 @@ if (__eta.layout) { } ${r.useWith?"}":""}${r.debug?"} catch (e) { this.RuntimeErr(e, __eta.templateStr, __eta.line, options.filepath) }":""} return __eta.res; -`;if(r.plugins)for(let a=0;a":">",'"':""","'":"'"};function HK(t){return WK[t]}function KK(t){let e=String(t);return/[&<>"']/.test(e)?e.replace(/[&<>"']/g,HK):e}var pD={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,debug:!1,escapeFunction:KK,filterFunction:t=>String(t),functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it"},nm=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,om=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,im=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function sm(t){return t.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function VK(t,e){return t.slice(0,e).split(` -`).length}function GK(t){let e=this.config,r=[],n=!1,o=0,i=e.parse;if(e.plugins)for(let f=0;f0&&s!==void 0&&i<=s))return o;let a=this.readFile(n),l=this.compile(a,e);return this.config.cache&&r.define(n,l),l}}function M0(t,e,r){let n,o={...r,async:!1};return typeof t=="string"?(t.startsWith("@")||(o.filepath=this.resolvePath(t,o)),n=vD.call(this,t,o)):n=t,n.call(this,e,o)}function $0(t,e,r){let n,o={...r,async:!0};typeof t=="string"?(t.startsWith("@")||(o.filepath=this.resolvePath(t,o)),n=vD.call(this,t,o)):n=t;let i=n.call(this,e,o);return Promise.resolve(i)}function wD(t,e){let r=this.compile(t,{async:!1});return M0.call(this,r,e)}function xD(t,e){let r=this.compile(t,{async:!0});return $0.call(this,r,e)}var cm=class extends lm{use=ys.this;settings=this.use(ge);app=this.use(ED.App);tplFileCache=new WeakMap;constructor(){super();let e=this;this.config={...this.config,cache:!0,autoEscape:!1,autoFilter:!0,filterFunction:r=>r==null?"":r instanceof Date?r.toISOString():r,plugins:[],get autoTrim(){return e.settings.current?.autoTrim},get views(){return e.settings.templateDir}}}resolvePath=bD;readFile=gD;readModTime=yD;render=M0;renderAsync=$0;renderString=wD;renderStringAsync=xD;getFile(e){let r=this.app.vault.getAbstractFileByPath(e);if(!r)return e;if(!bt(r))throw new ct(`'${e}' is not a markdown file`);return r}};var a$=Z(Y2(),1),l$=Z(n$(),1);var Hm=require("obsidian");var $Q="\\ufeff?",LQ=typeof process<"u"?process.platform:"",jQ="^("+$Q+"(= yaml =|---)$([\\s\\S]*?)^(?:\\2|\\.\\.\\.)\\s*$"+(LQ==="win32"?"\\r?":"")+"(?:\\n)?)",qQ=new RegExp(jQ,"m");function jm(t){t=t||"";let e=t.split(/(\r?\n)/);return e[0]&&/= yaml =|---/.test(e[0])?zQ(t):{yaml:null,body:t,bodyBegin:1}}function BQ(t,e){let r=1,n=e.indexOf(` +`;if(r.plugins)for(let c=0;c":">",'"':""","'":"'"};function pV(t){return fV[t]}function dV(t){let e=String(t);return/[&<>"']/.test(e)?e.replace(/[&<>"']/g,pV):e}var _D={autoEscape:!0,autoFilter:!1,autoTrim:[!1,"nl"],cache:!1,cacheFilepaths:!0,debug:!1,escapeFunction:dV,filterFunction:t=>String(t),functionHeader:"",parse:{exec:"",interpolate:"=",raw:"~"},plugins:[],rmWhitespace:!1,tags:["<%","%>"],useWith:!1,varName:"it"},pm=/`(?:\\[\s\S]|\${(?:[^{}]|{(?:[^{}]|{[^}]*})*})*}|(?!\${)[^\\`])*`/g,dm=/'(?:\\[\s\w"'\\`]|[^\n\r'\\])*?'/g,mm=/"(?:\\[\s\w"'\\`]|[^\n\r"\\])*?"/g;function hm(t){return t.replace(/[.*+\-?^${}()|[\]\\]/g,"\\$&")}function mV(t,e){return t.slice(0,e).split(` +`).length}function hV(t){let e=this.config,r=[],n=!1,o=0,i=e.parse;if(e.plugins)for(let d=0;d0&&s!==void 0&&i<=s))return o;let c=this.readFile(n),l=this.compile(c,e);return this.config.cache&&r.define(n,l),l}}function K0(t,e,r){let n,o={...r,async:!1};return typeof t=="string"?(t.startsWith("@")||(o.filepath=this.resolvePath(t,o)),n=ND.call(this,t,o)):n=t,n.call(this,e,o)}function V0(t,e,r){let n,o={...r,async:!0};typeof t=="string"?(t.startsWith("@")||(o.filepath=this.resolvePath(t,o)),n=ND.call(this,t,o)):n=t;let i=n.call(this,e,o);return Promise.resolve(i)}function DD(t,e){let r=this.compile(t,{async:!1});return K0.call(this,r,e)}function PD(t,e){let r=this.compile(t,{async:!0});return V0.call(this,r,e)}var bm=class extends ym{use=Ss.this;settings=this.use(be);app=this.use(FD.App);tplFileCache=new WeakMap;constructor(){super();let e=this;this.config={...this.config,cache:!0,autoEscape:!1,autoFilter:!0,filterFunction:r=>r==null?"":r instanceof Date?r.toISOString():r,plugins:[],get autoTrim(){return e.settings.current?.autoTrim},get views(){return e.settings.templateDir}}}resolvePath=RD;readFile=kD;readModTime=AD;render=K0;renderAsync=V0;renderString=DD;renderStringAsync=PD;getFile(e){let r=this.app.vault.getAbstractFileByPath(e);if(!r)return e;if(!wt(r))throw new pt(`'${e}' is not a markdown file`);return r}};a();var w2=Y(u2(),1),x2=Y(g2(),1);var eh=require("obsidian");a();var oee="\\ufeff?",iee=typeof process<"u"?process.platform:"",see="^("+oee+"(= yaml =|---)$([\\s\\S]*?)^(?:\\2|\\.\\.\\.)\\s*$"+(iee==="win32"?"\\r?":"")+"(?:\\n)?)",aee=new RegExp(see,"m");function Gm(t){t=t||"";let e=t.split(/(\r?\n)/);return e[0]&&/= yaml =|---/.test(e[0])?lee(t):{yaml:null,body:t,bodyBegin:1}}function cee(t,e){let r=1,n=e.indexOf(` `),o=t.index+t[0].length;for(;n!==-1;){if(n>=o)return r;r++,n=e.indexOf(` -`,n+1)}return r}function zQ(t){let e=qQ.exec(t);if(!e)return{yaml:null,body:t,bodyBegin:1};let r=e[e.length-1].replace(/^\s+|\s+$/g,""),n=t.replace(e[0],""),o=BQ(e,t);return{yaml:r,body:n,bodyBegin:o}}var Bm=require("path"),Uw=require("url");function qw(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Bw(t,e){if(typeof t!="string"||typeof e!="string")throw new TypeError("Expected a string");let r=new RegExp(`(?:${qw(e)}){2,}`,"g");return t.replace(r,e)}function qm(){return/[<>:"/\\|?*\u0000-\u001F]/g}function o$(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}function zw(t,e){if(typeof t!="string"||typeof e!="string")throw new TypeError("Expected a string");return t.startsWith(e)&&(t=t.slice(e.length)),t.endsWith(e)&&(t=t.slice(0,-e.length)),t}var UQ=100,i$=/[\u0000-\u001F\u0080-\u009F]/g,WQ=/^\.+(\\|\/)|^\.+$/,HQ=/\.+$/;function Yi(t,e={}){if(typeof t!="string")throw new TypeError("Expected a string");let r=e.replacement===void 0?"!":e.replacement;if(qm().test(r)&&i$.test(r))throw new Error("Replacement string cannot contain reserved filename characters");if(t=t.normalize("NFD"),t=t.replace(WQ,r),t=t.replace(qm(),r),t=t.replace(i$,r),t=t.replace(HQ,""),r.length>0){let o=t[0]===".";t=Bw(t,r),t=t.length>1?zw(t,r):t,!o&&t[0]==="."&&(t=r+t),t[t.length-1]==="."&&(t+=r)}t=o$().test(t)?t+r:t;let n=typeof e.maxLength=="number"?e.maxLength:UQ;if(t.length>n){let o=t.lastIndexOf(".");if(o===-1)t=t.slice(0,n);else{let i=t.slice(0,o),s=t.slice(o);t=i.slice(0,Math.max(1,n-s.length))+s}}return t}var Ww=t=>encodeURI(t)===t?t:`<${t}>`,zm=t=>t.name.endsWith(".eta.md"),Hw=(t,e)=>e.path?e.path.startsWith("storage:")?(0,Bm.join)(t,"storage",e.key,e.path.replace(/^storage:/,"")):e.path:"",Um=(t,e,r,n=null,o=null)=>{if(!n?.path)return"";let i=o?`#page=${o}`:void 0,s=e.vault.adapter.getBasePath(),a=Hw(t,n),l=(0,Bm.relative)(s,a);if(l.startsWith(".."))return`[attachment](${Ww((0,Uw.pathToFileURL)(a).href+(i??""))})`;{let u=e.metadataCache.getFirstLinkpathDest(l,"");return u?e.fileManager.generateMarkdownLink(u,r??"",i).replace(/^!/,""):(W.warn("fileLink: file not found",l,a),"")}},s$=t=>Yi(t,{replacement:"_"}),Wm=t=>qc(t)&&t.type===Ae.image,KQ=(t,e,r)=>e?`[${r??""}](${Ww(t)})`:`[[${t}${r?"|"+r:""}]]`,Kw=(t,e)=>{if(Wm(t)){let r=e.imgCacheImporter.import(t);if(r)return KQ(r,e.app.vault.getConfig("useMarkdownLinks"));{let n=e.imgCacheImporter.getCachePath(t);return`[Annotation ${t.key}](${Ww((0,Uw.pathToFileURL)(n).href)})`}}else return""};function c$(t){or(t,{compile:e=>function(n,o){let i=this,s=e.call(this,n,o);if(!o?.filepath)return s;let a=o.filepath,l=wt(a,i.settings.templateDir);if(!l)return s;let u=s;switch(l.name){case"filename":u=(c,f)=>s$(s.call(this,c,f));break;case"annotation":u=(c,f)=>{let p=s.call(this,c,f),d=!0,{yaml:h,body:b}=jm(p);if(h)try{(0,Hm.parseYaml)(h).callout===!1&&(d=!1)}catch(v){new Hm.Notice(`Error parsing frontmatter, ${v}`)}if(!d)return b;let y=b.trim().split(` -`);return y.push(`^${c.blockID}`),y.map(v=>`> ${v}`).join(` -`)};break;default:break}return Object.groupBy&&Map.groupBy?u:(c,f)=>{let p=VQ(),d=u.call(this,c,f);return p(),d}}})}function VQ(){let t=[];return Object.groupBy||(Object.groupBy=l$.default,t.push(()=>delete Object.groupBy)),Map.groupBy||(Map.groupBy=a$.default,t.push(()=>delete Map.groupBy)),()=>t.forEach(e=>e())}var Xi="zotero-key",Sa="zt-attachments";var u$=require("url");var f$=require("obsidian");var Uo=t=>t.plugin.settings.current?.zoteroDataDir,su=Symbol("proxied"),Km=t=>!!t[su];var Vm={"#FF6666":"red","#FF8C19":"orange","#F19837":"orange","#FFD400":"yellow","#999999":"gray","#AAAAAA":"gray","#5FB236":"green","#009980":"cyan","#2EA8E5":"blue","#576DD9":"navy","#A28AE5":"purple","#A6507B":"brown","#E56EEE":"magenta"};var Vw=new Set(ao()("attachment","tags")),Gw=(t,e,r)=>new Proxy({get page(){return bs(t.position.pageIndex,!0)??NaN},get backlink(){return jo(t)},get blockID(){let n=ir(t),o=bs(t.position.pageIndex,!0);return typeof o=="number"&&(n+=`p${o}`),n},get commentMd(){return t.comment?(0,f$.htmlToMarkdown)(t.comment):""},get imgPath(){return Wm(this)?Lo(this,Uo(r)):""},get imgUrl(){if(Wm(this)){let n=Lo(this,Uo(r));return(0,u$.pathToFileURL)(n).href}else return""},get imgLink(){return Kw(this,r.plugin)},get imgEmbed(){let n=Kw(this,r.plugin);return n?`!${n}`:""},get fileLink(){return Um(Uo(r),r.plugin.app,r.sourcePath,e.attachment,bs(t.position.pageIndex,!0))},get textBlock(){return t.text?`\`\`\`zotero-annot -> ${t.text} [zotero](${jo(t)}) -\`\`\``:""},get colorName(){let n=t.color?.toUpperCase();return Vm[n]||this.color},docItem:"not-loaded"},{get(n,o,i){if(o==="tags"){if(!e.tags[t.itemID])throw console.error(e,t.itemID),new Error("No tags loaded for item "+t.itemID);return e.tags[t.itemID]}if(o==="docItem"){if(n.docItem==="not-loaded")throw new Error("Doc Item not loaded for item "+t.itemID);return n.docItem}return Vw.has(o)?Reflect.get(e,o,i):Reflect.get(t,o,i)??Reflect.get(n,o,i)},ownKeys(n){return[...Reflect.ownKeys(t),...Vw,...Reflect.ownKeys(n)]},getOwnPropertyDescriptor(n,o){return Object.prototype.hasOwnProperty.call(t,o)?Reflect.getOwnPropertyDescriptor(t,o):Vw.has(o)?Reflect.getOwnPropertyDescriptor(e,o):Reflect.getOwnPropertyDescriptor(n,o)}});function Zw(t,e){return!t||Km(t)?t:new Proxy({get filePath(){return Hw(Uo(e),t)}},{get(r,n,o){return n===su?!0:Reflect.get(t,n,o)??Reflect.get(r,n,o)},ownKeys(r){return[...Reflect.ownKeys(t),...Reflect.ownKeys(r)]},getOwnPropertyDescriptor(r,n){return Object.prototype.hasOwnProperty.call(t,n)?Reflect.getOwnPropertyDescriptor(t,n):Reflect.getOwnPropertyDescriptor(r,n)}})}var Jw=class extends Array{toString(){return this.join(" > ")}},Yw=({path:t,...e})=>{let r={path:Jw.from(t),toString(){return e.name}};return new Proxy(r,{get(n,o,i){return Reflect.get(n,o,i)??Reflect.get(e,o,i)},ownKeys(n){return[...Reflect.ownKeys(e),...Reflect.ownKeys(n).filter(o=>!(o==="toJSON"||o==="toString"))]},getOwnPropertyDescriptor(n,o){return Object.prototype.hasOwnProperty.call(e,o)?Reflect.getOwnPropertyDescriptor(e,o):Reflect.getOwnPropertyDescriptor(n,o)}})};var Xw=t=>{let e={get fullname(){return jc(t)??""},toString(){return this.fullname},toJSON(){return this.fullname}};return new Proxy(e,{get(r,n,o){return Reflect.get(r,n,o)??Reflect.get(t,n,o)},ownKeys(r){return[...Reflect.ownKeys(t),...Reflect.ownKeys(r).filter(n=>!(n==="toJSON"||n==="toString"))]},getOwnPropertyDescriptor(r,n){return Object.prototype.hasOwnProperty.call(t,n)?Reflect.getOwnPropertyDescriptor(t,n):Reflect.getOwnPropertyDescriptor(r,n)}})};var Qw=new Set(ao()("attachment","allAttachments","tags","notes")),ex=({creators:t,collections:e,...r},n,o)=>{let i=t.map(s=>Xw(s));return new Proxy({get backlink(){return jo(r)},get fileLink(){return Um(Uo(o),o.plugin.app,o.sourcePath,n.attachment)},get authorsShort(){let s=this.authors;if(!s.length)return"";let a=s[0],l=a.lastName??a.fullname;return s.length===1?l:`${l} et al.`},annotations:"not-loaded",creators:i,collections:e.map(s=>Yw(s)),get authors(){return i.filter(s=>s.creatorType==="author")}},{get(s,a,l){if(a==="tags"){if(!n.tags[r.itemID])throw new Error("No tags loaded for item "+r.itemID);return n.tags[r.itemID]}return Qw.has(a)?n[a]:a==="annotations"?s.annotations:Reflect.get(r,a,l)??Reflect.get(s,a,l)},ownKeys(s){return[...Reflect.ownKeys(r),...Qw,...Reflect.ownKeys(s)]},getOwnPropertyDescriptor(s,a){return Object.prototype.hasOwnProperty.call(r,a)?Reflect.getOwnPropertyDescriptor(r,a):Qw.has(a)?Reflect.getOwnPropertyDescriptor(n,a):Reflect.getOwnPropertyDescriptor(s,a)}})};function p$(t){return!t||Km(t)?t:new Proxy({toString(){return t.name},toJSON(){return t.name}},{get(e,r,n){return r===su?!0:Reflect.get(e,r,n)??Reflect.get(t,r,n)},ownKeys(e){return[...Reflect.ownKeys(t),...Reflect.ownKeys(e).filter(r=>!(r==="toJSON"||r==="toString"))]},getOwnPropertyDescriptor(e,r){return Object.prototype.hasOwnProperty.call(t,r)?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)}})}function jt(t,e,r){let n={...t,attachement:Zw(t.attachment,e),allAttachments:t.allAttachments.map(a=>Zw(a,e)),tags:ma(t.tags,a=>a.map(l=>p$(l)))},o=ex(t.docItem,n,e),i=t.annotations.map(a=>{let l=Gw(a,n,e);return l.docItem=o,l}),s=r?i[t.annotations.findIndex(a=>a.itemID===r.itemID)]:void 0;return o.annotations=i,{annotation:s,annotations:i,docItem:o}}var Wo=class extends fe{eta=this.use(cm);plugin=this.use(xe);settings=this.use(ge);app=this.use(Ot.App);get vault(){return this.app.vault}get folder(){return this.settings.templateDir}get filenameTemplate(){return this.settings.simpleTemplates?.filename}get autoTrim(){return this.settings.current?.autoTrim}async loadTemplates(){let e=this.vault.getAbstractFileByPath(this.folder);if(!e)return;if(!(e instanceof Ot.TFolder)){W.warn("Template folder is occupied by a file");return}let r=[];Ot.Vault.recurseChildren(e,async n=>{!bt(n)||!n.path.endsWith(".eta.md")||r.push(n)}),await Promise.all(r.map(async n=>this.eta.tplFileCache.set(n,await this.vault.cachedRead(n))))}onload(){c$(this.eta),this.settings.once(async()=>{await this.loadTemplates()}),this.register(He(lt(()=>this.plugin.app.vault.trigger("zotero:template-updated","filename"),()=>this.filenameTemplate,!0))),this.register(He(lt(async()=>en.All.forEach(e=>this.plugin.app.vault.trigger("zotero:template-updated",e)),()=>this.autoTrim,!0))),this.registerEvent(this.vault.on("create",this.onFileChange,this)),this.registerEvent(this.vault.on("modify",this.onFileChange,this)),this.registerEvent(this.vault.on("delete",async e=>{if(!bt(e))return;let r=this.fromPath(e.path);r&&(this.eta.tplFileCache.delete(e),this.vault.trigger("zotero:template-updated",r))})),this.registerEvent(this.vault.on("rename",async(e,r)=>{await this.onFileChange(e);let n=this.fromPath(r);n&&this.vault.trigger("zotero:template-updated",n)}))}async onFileChange(e){if(!bt(e))return;let r=this.fromPath(e.path);this.eta.tplFileCache.set(e,await this.vault.cachedRead(e)),this.vault.trigger("zotero:template-updated",r)}fromPath(e){let r=wt(e,this.folder);return r?.type==="ejectable"?r.name:null}onFileUpdate(e){bt(e)&&this.fromPath(e.path)}onFileRename(e,r){bt(e)&&this.fromPath(e.path),this.fromPath(r)}mergeAnnotTags(e){if(e.annotations.length===0)return e;let r=fD(e.annotations,e.tags);return e.annotations=r.annotations,e.tags={...e.tags,...r.tags},e}render(e,r){try{let n=this.eta.render(e,r);return this.plugin.imgCacheImporter.flush(),n}catch(n){throw console.error("Error while rendering",e,n),n}}renderAnnot(e,r,n){n.merge!==!1&&(r=this.mergeAnnotTags(r));let o=jt(r,n,e);return this.render("annotation",o.annotation)}renderNote(e,r,n){r.merge!==!1&&(e=this.mergeAnnotTags(e));let o=jt(e,r),i=this.#e(o.docItem,n),s=this.render("note",o.docItem);return["",i,s].join(`--- -`)}renderAnnots(e,r){r.merge!==!1&&(e=this.mergeAnnotTags(e));let n=jt(e,r);return this.render("annots",n.annotations)}renderCitations(e,r,n=!1){let o=e.map(i=>jt(i,r));return this.render(n?"cite2":"cite",o.map(i=>i.docItem))}renderColored(e){return this.render("colored",e)}renderFilename(e,r){let n=jt(e,r);return this.render("filename",n.docItem)}toFrontmatterRecord(e){let r=this.render("field",e),n=!1,{yaml:o,body:i}=jm(r);if(o)try{(0,Ot.parseYaml)(o).raw===!0&&(n=!0)}catch(f){new Ot.Notice(`Error parsing frontmatter, ${f}`)}let s=ir(e,!0),a=e.attachment?[e.attachment.itemID.toString()]:void 0,{[Xi]:l,[Sa]:u,...c}=(0,Ot.parseYaml)(i);return{mode:n?"raw":"parsed",yaml:[`${Xi}: ${s}`,`${Sa}: ${u??a}`,i.trim(),""].join(` -`),data:{[Xi]:s,[Sa]:a,...Mc(c,f=>!(f===""||f===null||f===void 0))}}}renderFrontmatter(e,r,n){let o=jt(e,r);return this.#e(o.docItem,n)}#e(e,r){try{let n=this.toFrontmatterRecord(e);return n.mode==="raw"?n.yaml:(0,Ot.stringifyYaml)(r!==void 0?Ui(n.data,r):n.data)}catch(n){throw mt("Failed to renderYaml",n,e),new Ot.Notice("Failed to renderYaml"),n}}async setFrontmatterTo(e,r){try{let n=this.toFrontmatterRecord(r).data;await this.plugin.app.fileManager.processFrontMatter(e,o=>Object.assign(o,n))}catch(n){mt("Failed to set frontmatter to file "+e.path,n,r),new Ot.Notice("Failed to set frontmatter to file "+e.path)}}};de([me],Wo.prototype,"folder",1),de([me],Wo.prototype,"filenameTemplate",1),de([me],Wo.prototype,"autoTrim",1);var Gm=require("@codemirror/state"),d$=require("obsidian");var m$=t=>Gm.Prec.highest(Gm.EditorState.languageData.of(e=>{let r=[],n=t.getConfig("autoPairBrackets"),o=t.getConfig("autoPairMarkdown");n&&r.push("(","[","{","'",'"'),o&&r.push("*","_","`","```");let i=e.field(d$.editorInfoField);return i?.file&&zm(i?.file)&&r.push("<","%"),[{closeBrackets:{brackets:r}}]}));var g$=require("obsidian");var h$=[{prefix:"=",name:"interpolate tag",description:"An interpolation outputs data into the template"},{prefix:" ",name:"evaluation tag",description:"An evaluate tag inserts its contents into the template function."}],Zm=class extends g$.EditorSuggest{onTrigger(e,r,n){if(!n||!zm(n))return null;let o=r.getLine(e.line),s=o.substring(0,e.ch).match(/<%([ =]?)$/);if(!s)return null;let[a,l]=s,u=o.substring(e.ch).match(/^([\w ]*)%>/),c;if(!u)c={...e};else{let[,f]=u;if(l===" "&&f.length===1)return null;c={...e,ch:e.ch+f.length}}return{end:c,start:{ch:s.index+a.length-l.length,line:e.line},query:s[1]}}getSuggestions(e){return e.query?h$.filter(r=>r.prefix===e.query):h$}renderSuggestion({prefix:e,name:r,description:n},o){e===" "?o.createSpan({text:"No Prefix"}):o.createEl("code",{text:e}),o.createDiv({text:r}),o.createDiv({text:n})}selectSuggestion({prefix:e},r){if(!this.context)return;let{editor:n,end:o,start:i}=this.context,s=e===" "?" ":"= it. ";n.transaction({changes:[{from:i,to:o,text:s}],selection:{from:{...i,ch:i.ch+s.length-1}}})}};var Ia=class extends fe{#e=null;plugin=this.use(xe);settings=this.use(ge);#t(){this.plugin.registerEditorSuggest(new Zm(this.plugin.app))}get etaBracketPairing(){return this.settings.current?.autoPairEta}#n(e){let r=this.#e!==null;this.#e===null?(this.#e=[],this.plugin.registerEditorExtension(this.#e)):this.#e.length=0,e&&this.#e.push(m$(this.plugin.app.vault)),r&&this.plugin.app.workspace.updateOptions()}onload(){this.#t(),this.register(He(lt(()=>this.#n(this.etaBracketPairing),()=>this.etaBracketPairing)))}};de([me],Ia.prototype,"etaBracketPairing",1);var rx=t=>{let e=t?.frontmatter?.[Xi];return e&&typeof e=="string"&&IS.test(e)?e:null},Qi=(t,e)=>{if(!t)return null;let r=typeof t=="string"?e.getCache(t):t instanceof tx.TFile?e.getFileCache(t):null;return rx(r)},es=(t,e)=>{if(!t)return null;let n=(typeof t=="string"?e.getCache(t):t instanceof tx.TFile?e.getFileCache(t):null)?.frontmatter?.[Sa];if(n&&Array.isArray(n)&&n.length>0){let o=[];for(let i of n)if(typeof i=="string"){let s=Number(i);if(!(s>0&&Number.isInteger(s)))return null;o.push(s)}else if(typeof i=="number"){if(!(i>0&&Number.isInteger(i)))return null;o.push(i)}return o}return null},au=({id:t})=>!!t&&OS.test(t),lu=t=>t.split("n").map(e=>{let[,r,,n]=e.split("p")[0].match(_S);return ir({key:r,groupID:n?+n:void 0},!0)});function cu(t,e){let r=uD(t);return!!Qi(r,e.metadataCache)}var $q=require("url");S();var Ho=We({});S();var Ve=We({});S();var y$=function(t){return typeof t=="function"};var ZQ=!1,b$=ZQ;function JQ(t){b$&&(y$(t)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof t)));var e=P(t);e.current=ie(function(){return t},[t]);var r=P();return r.current||(r.current=function(){for(var n=[],o=0;o{let e,r=new Set,n=(l,u)=>{let c=typeof l=="function"?l(e):l;if(!Object.is(c,e)){let f=e;e=u??typeof c!="object"?c:Object.assign({},e,c),r.forEach(p=>p(e,f))}},o=()=>e,a={setState:n,getState:o,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(x$.env&&x$.env.MODE)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,a),a},uu=t=>t?w$(t):w$;S();var k$=Z(A$(),1);var{useSyncExternalStoreWithSelector:gee}=k$.default;function qt(t,e=t.getState,r){let n=gee(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return Ii(n),n}function Oa(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(let[n,o]of t)if(!Object.is(o,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0}let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;nt&&(e=0,n=r,r=new Map)}return{get:function(s){var a=r.get(s);if(a!==void 0)return a;if((a=n.get(s))!==void 0)return o(s,a),a},set:function(s,a){r.has(s)?r.set(s,a):o(s,a)}}}var ax="!";function L$(t){var e=t.separator||":";return function(n){for(var o=0,i=[],s=0,a=0;a{t.forEach(r=>{typeof r=="function"?r(e):r!=null&&(r.current=e)})}}var eh=(t,e)=>{let{setIcon:r}=te(Ho),n=P(null);return X(i=>{n.current&&kee.call(n.current),i&&(r(i,t),e&&i.firstElementChild instanceof SVGSVGElement&&i.firstElementChild.style.setProperty("--icon-size",typeof e=="number"||!Number.isNaN(Number(e))?`${e}px`:e)),n.current=i},[t,e,r])};function kee(){for(;this.lastChild;)this.removeChild(this.lastChild)}var Vo=ht(Y(function({icon:e,size:r,className:n,...o},i){let s=eh(e,r),a=Qm(s,i);return m("div",{ref:a,className:re("zt-icon",n),...o})}));S();var rs=Y(function({onClick:e,onKeyDown:r,className:n,...o},i){return m(Vo,{onClick:e,onKeyDown:r??e,className:re("clickable-icon",n),...o,ref:i,role:"button",tabIndex:0})});S();S();var Y$=ht(Y(function({icon:e,...r},n){let o=eh(e);return m("button",{ref:Qm(o,n),...r})}));var ns=Y(function({className:e,active:r=!1,...n},o){return m(Y$,{...n,ref:o,className:re("clickable-icon",{"is-active":r},e)})});function fu(t){return m(rs,{size:16,icon:"info","aria-label":"Show details",...t})}function pu(){let t=arguments[0];for(let e=1,r=arguments.length;eo(e).replace(/<\/?b>/g,"**").replace(/<\/?i>/g,"*"),[e,o]);return m("div",{className:re("annot-comment select-text overflow-x-auto break-words px-2 py-1",r),...n,children:i(s)})});S();var Q$=Y(function({className:e,...r},n){return m("div",{ref:n,className:re("annot-excerpt",e),...r})});S();function cx({text:t,pageLabel:e,className:r,collapsed:n=!1,...o}){let i=t??`Area Excerpt for Page ${e??"?"}`;return m("img",{className:re("w-full",n?"max-h-20 object-cover object-left-top":"object-scale-down",r),alt:i,...o})}var eL=ht(function({type:e,text:r,pageLabel:n,imgSrc:o,collapsed:i}){switch(e){case Ae.highlight:case Ae.underline:case Ae.text:return m("p",{className:"select-text",children:r});case Ae.image:if(!o)throw new Error("imgSrc is required for image annotation");return m(cx,{collapsed:i,src:o,pageLabel:n,text:r});default:return m(M,{children:["Unsupported Type: ",Ae[e]??e]})}});function ux({checkbox:t,drag:e,buttons:r,onMoreOptions:n,className:o,children:i,onContextMenu:s,...a}){return m("div",{className:re("annot-header flex cursor-context-menu items-center gap-1",o),onContextMenu:s??n,...a,children:[t,m("div",{className:"annot-header-drag-container flex flex-row items-center gap-1",children:e}),m("div",{className:"annot-header-buttons-container flex flex-row items-center gap-1 opacity-0 transition-opacity hover:opacity-100",children:r}),m("div",{className:"annot-header-space flex-1"}),i]})}var Ree=typeof global=="object"&&global&&global.Object===Object&&global,tL=Ree;var Nee=typeof self=="object"&&self&&self.Object===Object&&self,Dee=tL||Nee||Function("return this")(),rL=Dee;var Fee=rL.Symbol,Xn=Fee;var nL=Object.prototype,Pee=nL.hasOwnProperty,Mee=nL.toString,du=Xn?Xn.toStringTag:void 0;function $ee(t){var e=Pee.call(t,du),r=t[du];try{t[du]=void 0;var n=!0}catch{}var o=Mee.call(t);return n&&(e?t[du]=r:delete t[du]),o}var oL=$ee;var Lee=Object.prototype,jee=Lee.toString;function qee(t){return jee.call(t)}var iL=qee;var Bee="[object Null]",zee="[object Undefined]",sL=Xn?Xn.toStringTag:void 0;function Uee(t){return t==null?t===void 0?zee:Bee:sL&&sL in Object(t)?oL(t):iL(t)}var aL=Uee;function Wee(t){return t!=null&&typeof t=="object"}var lL=Wee;var Hee="[object Symbol]";function Kee(t){return typeof t=="symbol"||lL(t)&&aL(t)==Hee}var cL=Kee;function Vee(t,e){for(var r=-1,n=t==null?0:t.length,o=Array(n);++ro?0:o+e),r=r>o?o:r,r<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n=n?t:gL(t,e,r)}var yL=Xee;var Qee="\\ud800-\\udfff",ete="\\u0300-\\u036f",tte="\\ufe20-\\ufe2f",rte="\\u20d0-\\u20ff",nte=ete+tte+rte,ote="\\ufe0e\\ufe0f",ite="\\u200d",ste=RegExp("["+ite+Qee+nte+ote+"]");function ate(t){return ste.test(t)}var th=ate;function lte(t){return t.split("")}var bL=lte;var vL="\\ud800-\\udfff",cte="\\u0300-\\u036f",ute="\\ufe20-\\ufe2f",fte="\\u20d0-\\u20ff",pte=cte+ute+fte,dte="\\ufe0e\\ufe0f",mte="["+vL+"]",fx="["+pte+"]",px="\\ud83c[\\udffb-\\udfff]",hte="(?:"+fx+"|"+px+")",wL="[^"+vL+"]",xL="(?:\\ud83c[\\udde6-\\uddff]){2}",EL="[\\ud800-\\udbff][\\udc00-\\udfff]",gte="\\u200d",SL=hte+"?",IL="["+dte+"]?",yte="(?:"+gte+"(?:"+[wL,xL,EL].join("|")+")"+IL+SL+")*",bte=IL+SL+yte,vte="(?:"+[wL+fx+"?",fx,xL,EL,mte].join("|")+")",wte=RegExp(px+"(?="+px+")|"+vte+bte,"g");function xte(t){return t.match(wte)||[]}var _L=xte;function Ete(t){return th(t)?_L(t):bL(t)}var OL=Ete;function Ste(t){return function(e){e=ka(e);var r=th(e)?OL(e):void 0,n=r?r[0]:e.charAt(0),o=r?yL(r,1).join(""):e.slice(1);return n[t]()+o}}var TL=Ste;var Ite=TL("toUpperCase"),CL=Ite;function _te(t,e,r,n){var o=-1,i=t==null?0:t.length;for(n&&i&&(r=t[++o]);++o{switch(t){case Ae.highlight:return"align-left";case Ae.underline:return"underline";case Ae.image:return"frame";case Ae.text:return"text-select";case Ae.note:case Ae.ink:default:return"file-question"}};S();var nj=t=>{let{annotRenderer:e,store:r}=te(Ve),n=qt(r,e.storeSelector,Oa);return e.get(t,n)};S();var oj=t=>{let{getImgSrc:e}=te(Ve);return ie(()=>e(t),[t,e])};function mx({className:t,...e}){return m(rs,{icon:"more-vertical",className:re("annot-header-more-options",t),"aria-label":"More options",size:"0.9rem","aria-label-delay":"50",...e})}S();var ij=ht(function({pageLabel:e,backlink:r,className:n,...o}){let i=e?`Page ${e}`:"";return r?m("a",{className:re("annot-page","external-link","bg-[length:12px] bg-[center_right_3px] pr-[18px] text-xs",n),href:r,"aria-label":`Open annotation in Zotero at page ${e}`,"aria-label-delay":"500",...o,children:i}):m("span",{className:re("annot-page",n),children:i})});S();function hx({tags:t}){return t.length===0?null:m("div",{className:"annot-tags-container",children:t.map(e=>m(hre,{...e},e.tagID))})}var hre=ht(function({name:e}){return m("a",{className:re("tag","annot-tag"),children:e})});function gx({collapsed:t=!1,annotation:e,checkbox:r,tags:n,className:o,...i}){let s=P(null),{onMoreOptions:a,onDragStart:l,onShowDetails:u}=te(Ve),c=C0.selectKeys(e,["type","text","pageLabel"]),f=nj(e),p=Wr(h=>a(h,e)),d=Wr(()=>u("annot",e.itemID));return m("div",{className:re("annot-preview","bg-primary shadow-border col-span-1 flex flex-col divide-y overflow-auto rounded-sm transition-colors",o),"data-id":e.itemID,...i,children:[m(ux,{className:"bg-primary-alt py-1 pl-2 pr-1",checkbox:r,drag:m(tj,{type:e.type,color:e.color,icon:rj(e.type),draggable:f!==null,onDragStart:Wr(h=>f&&l(h,f,s.current)),size:16}),buttons:m(M,{children:[m(fu,{className:"p-0.5",size:14,onClick:d}),m(mx,{className:"p-0",onClick:p})]}),onMoreOptions:p,children:m(ij,{pageLabel:e.pageLabel,backlink:jo(e)})}),m(Q$,{ref:s,className:"px-2 py-1",children:m("blockquote",{className:re("border-l-blockquote pl-2 leading-tight",{"line-clamp-3":t}),style:{borderColor:e.color??"var(--interactive-accent)"},children:m(eL,{...c,collapsed:t,imgSrc:oj(e)})})}),e.comment&&m(X$,{content:e.comment}),n&&m(hx,{tags:n})]})}function yx({selectable:t=!1,collapsed:e,annotations:r,getTags:n}){let[o,{add:i,remove:s}]=nx();return m("div",{role:"list",className:"@md:grid-cols-2 @md:gap-3 @3xl:grid-cols-4 grid grid-cols-1 gap-2",children:r.map(a=>m(gx,{checkbox:t&&m(gre,{checked:o.has(a.itemID),onChange:l=>l?i(a.itemID):s(a.itemID)}),collapsed:e,role:"listitem",annotation:a,tags:n(a.itemID)},a.itemID))})}function gre({checked:t,onChange:e}){return m("div",{className:"flex h-5 items-center",children:m("input",{type:"checkbox",className:"m-0 h-4 w-4",checked:t,onChange:r=>e(r.target.checked)})})}S();var yre=()=>qt(te(Ve).store,t=>({attachments:t.allAttachments,onChange:t.setActiveAtch,value:t.attachmentID}),Oa);function bx(){let{attachments:t,onChange:e,value:r}=yre();return t?t.length===1?null:t.length<=0?m("span",{className:"atch-select-empty",children:"No attachments available"}):m("select",{className:"atch-select",onChange:n=>e(parseInt(n.target.value,10)),value:r??void 0,children:t.map(({itemID:n,path:o,annotCount:i})=>m("option",{value:n,children:["(",i,") ",o?.replace(/^storage:/,"")]},n))}):m(M,{children:"Loading"})}function vx({isCollapsed:t,...e}){return m(ns,{...e,icon:t?"chevrons-up-down":"chevrons-down-up","aria-label":t?"Expand":"Collapse"})}S();function rh(t){let{store:e,onSetFollow:r}=te(Ve),n=qt(e,s=>s.follow),o=n===null?"not following":n==="ob-note"?"active literature note":"active literature in Zotero reader";return m(M,{children:[m(ns,{...t,onClick:r,icon:n===null?"unlink":"link","aria-label":"Choose follow mode"+(n===null?" (Currently linked with literature)":""),"aria-label-delay":"50"}),n!==null&&m("span",{className:"ml-1","aria-label":`Following ${o}`,children:n==="ob-note"?"ob":"zt"})]})}function nh({children:t,buttons:e}){return m("div",{className:"nav-header",children:[m("div",{className:"nav-buttons-container",children:e}),t]})}function wx(t){return m(ns,{...t,icon:"refresh-ccw","aria-label":"Refresh annotation list","aria-label-delay":"50"})}var bre=()=>{let{registerDbUpdate:t,store:e}=te(Ve),r=qt(e,n=>n.refresh);U(()=>t(r),[t,r])};function mu(){bre();let{store:t}=te(Ve),e=qt(t,r=>r.doc);return e?m(vre,{docItem:e.docItem}):m(M,{children:[m(nh,{buttons:m(rh,{})}),m("div",{className:"pane-empty p-2",children:"Active file not literature note"})]})}function vre({docItem:t}){let{refreshConn:e,onShowDetails:r}=te(Ve),[n,{toggle:o}]=Jm(!1),i=wre();return m(M,{children:[m(nh,{buttons:m(M,{children:[m(fu,{className:"nav-action-button",onClick:Wr(()=>r("doc-item",t.itemID))}),m(vx,{className:"nav-action-button",isCollapsed:n,onClick:o}),m(wx,{className:"nav-action-button",onClick:e}),m(rh,{})]}),children:m(bx,{})}),m("div",{className:re("annots-container @container","overflow-auto px-3 pt-1 pb-8 text-xs"),children:i?m(yx,{collapsed:n,...i}):m(M,{children:"Loading"})})]})}var wre=()=>qt(te(Ve).store,t=>!t.doc||!t.annotations||!t.attachment?null:{annotations:t.annotations,getTags:e=>t.tags[e]??[]},Oa);S();function pe(){return pe=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[o]=t[o]);return r}function oh(t,e=166){let r;function n(...o){let i=()=>{t.apply(this,o)};clearTimeout(r),r=setTimeout(i,e)}return n.clear=()=>{clearTimeout(r)},n}function Ex(t){return t&&t.ownerDocument||document}function hu(t){return Ex(t).defaultView||window}function Sx(t,e){typeof t=="function"?t(e):t&&(t.current=e)}S();var xre=typeof window<"u"?Pt:U,Ix=xre;S();function ih(...t){return ie(()=>t.every(e=>e==null)?null:e=>{t.forEach(r=>{Sx(r,e)})},t)}S();S();var Ere=["onChange","maxRows","minRows","style","value"];function sh(t){return parseInt(t,10)||0}var Sre={shadow:{visibility:"hidden",position:"absolute",overflow:"hidden",height:0,top:0,left:0,transform:"translateZ(0)"}};function sj(t){return t==null||Object.keys(t).length===0||t.outerHeightStyle===0&&!t.overflow}var Ire=Y(function(e,r){let{onChange:n,maxRows:o,minRows:i=1,style:s,value:a}=e,l=xx(e,Ere),{current:u}=P(a!=null),c=P(null),f=ih(r,c),p=P(null),d=P(0),[h,b]=L({outerHeightStyle:0}),y=X(()=>{let V=c.current,G=hu(V).getComputedStyle(V);if(G.width==="0px")return{outerHeightStyle:0};let K=p.current;K.style.width=G.width,K.value=V.value||e.placeholder||"x",K.value.slice(-1)===` -`&&(K.value+=" ");let F=G.boxSizing,Q=sh(G.paddingBottom)+sh(G.paddingTop),O=sh(G.borderBottomWidth)+sh(G.borderTopWidth),_=K.scrollHeight;K.value="x";let I=K.scrollHeight,B=_;i&&(B=Math.max(Number(i)*I,B)),o&&(B=Math.min(Number(o)*I,B)),B=Math.max(B,I);let D=B+(F==="border-box"?Q+O:0),oe=Math.abs(B-_)<=1;return{outerHeightStyle:D,overflow:oe}},[o,i,e.placeholder]),v=(V,J)=>{let{outerHeightStyle:G,overflow:K}=J;return d.current<20&&(G>0&&Math.abs((V.outerHeightStyle||0)-G)>1||V.overflow!==K)?(d.current+=1,{overflow:K,outerHeightStyle:G}):V},x=X(()=>{let V=y();sj(V)||b(J=>v(J,V))},[y]),T=()=>{let V=y();sj(V)||ln(()=>{b(J=>v(J,V))})};return U(()=>{let V=oh(()=>{d.current=0,c.current&&T()}),J,G=c.current,K=hu(G);return K.addEventListener("resize",V),typeof ResizeObserver<"u"&&(J=new ResizeObserver(V),J.observe(G)),()=>{V.clear(),K.removeEventListener("resize",V),J&&J.disconnect()}}),Ix(()=>{x()}),U(()=>{d.current=0},[a]),m(M,{children:[m("textarea",pe({value:a,onChange:V=>{d.current=0,u||x(),n&&n(V)},ref:f,rows:i,style:pe({height:h.outerHeightStyle,overflow:h.overflow?"hidden":void 0},s)},l)),m("textarea",{"aria-hidden":!0,className:e.className,readOnly:!0,ref:p,tabIndex:-1,style:pe({},Sre.shadow,s,{padding:0})})]})}),gu=Ire;S();S();S();S();function _re(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function _x(...t){return e=>t.forEach(r=>_re(r,e))}function ah(...t){return X(_x(...t),t)}S();function aj(t,e=[]){let r=[];function n(i,s){let a=We(s),l=r.length;r=[...r,s];function u(f){let{scope:p,children:d,...h}=f,b=p?.[t][l]||a,y=ie(()=>h,Object.values(h));return H(b.Provider,{value:y},d)}function c(f,p){let d=p?.[t][l]||a,h=te(d);if(h)return h;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return u.displayName=i+"Provider",[u,c]}let o=()=>{let i=r.map(s=>We(s));return function(a){let l=a?.[t]||i;return ie(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[n,Ore(o,...e)]}function Ore(...t){let e=t[0];if(t.length===1)return e;let r=()=>{let n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){let s=n.reduce((a,{useScope:l,scopeName:u})=>{let f=l(i)[`__scope${u}`];return{...a,...f}},{});return ie(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return r.scopeName=e.scopeName,r}function Bt(t,e,{checkForDefaultPrevented:r=!0}={}){return function(o){if(t?.(o),r===!1||!o.defaultPrevented)return e?.(o)}}S();S();function Ox(t){let e=P(t);return U(()=>{e.current=t}),ie(()=>(...r)=>{var n;return(n=e.current)===null||n===void 0?void 0:n.call(e,...r)},[])}function lj({prop:t,defaultProp:e,onChange:r=()=>{}}){let[n,o]=Tre({defaultProp:e,onChange:r}),i=t!==void 0,s=i?t:n,a=Ox(r),l=X(u=>{if(i){let f=typeof u=="function"?u(t):u;f!==t&&a(f)}else o(u)},[i,t,o,a]);return[s,l]}function Tre({defaultProp:t,onChange:e}){let r=L(t),[n]=r,o=P(n),i=Ox(e);return U(()=>{o.current!==n&&(i(n),o.current=n)},[n,o,i]),r}S();function cj(t){let e=P({value:t,previous:t});return ie(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}S();S();var yu=globalThis?.document?Pt:()=>{};function uj(t){let[e,r]=L(void 0);return yu(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});let n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;let i=o[0],s,a;if("borderBoxSize"in i){let l=i.borderBoxSize,u=Array.isArray(l)?l[0]:l;s=u.inlineSize,a=u.blockSize}else s=t.offsetWidth,a=t.offsetHeight;r({width:s,height:a})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}S();S();function Cre(t,e){return an((r,n)=>{let o=e[r][n];return o??r},t)}var Tx=t=>{let{present:e,children:r}=t,n=Are(e),o=typeof r=="function"?r({present:n.isPresent}):Qe.only(r),i=ah(n.ref,o.ref);return typeof r=="function"||n.isPresent?gr(o,{ref:i}):null};Tx.displayName="Presence";function Are(t){let[e,r]=L(),n=P({}),o=P(t),i=P("none"),s=t?"mounted":"unmounted",[a,l]=Cre(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return U(()=>{let u=lh(n.current);i.current=a==="mounted"?u:"none"},[a]),yu(()=>{let u=n.current,c=o.current;if(c!==t){let p=i.current,d=lh(u);t?l("MOUNT"):d==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&p!==d?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),yu(()=>{if(e){let u=f=>{let d=lh(n.current).includes(f.animationName);f.target===e&&d&&ln(()=>l("ANIMATION_END"))},c=f=>{f.target===e&&(i.current=lh(n.current))};return e.addEventListener("animationstart",c),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{e.removeEventListener("animationstart",c),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:X(u=>{u&&(n.current=getComputedStyle(u)),r(u)},[])}}function lh(t){return t?.animationName||"none"}S();S();S();var Ax=Y((t,e)=>{let{children:r,...n}=t,o=Qe.toArray(r),i=o.find(Rre);if(i){let s=i.props.children,a=o.map(l=>l===i?Qe.count(s)>1?Qe.only(null):Zt(s)?s.props.children:null:l);return H(Cx,pe({},n,{ref:e}),Zt(s)?gr(s,void 0,a):null)}return H(Cx,pe({},n,{ref:e}),r)});Ax.displayName="Slot";var Cx=Y((t,e)=>{let{children:r,...n}=t;return Zt(r)?gr(r,{...Nre(n,r.props),ref:_x(e,r.ref)}):Qe.count(r)>1?Qe.only(null):null});Cx.displayName="SlotClone";var kre=({children:t})=>H(M,null,t);function Rre(t){return Zt(t)&&t.type===kre}function Nre(t,e){let r={...e};for(let n in e){let o=t[n],i=e[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{i(...a),o(...a)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...t,...r}}var Dre=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],kx=Dre.reduce((t,e)=>{let r=Y((n,o)=>{let{asChild:i,...s}=n,a=i?Ax:e;return U(()=>{window[Symbol.for("radix-ui")]=!0},[]),H(a,pe({},s,{ref:o}))});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});var fj="Checkbox",[Fre,V2e]=aj(fj),[Pre,Mre]=Fre(fj),$re=Y((t,e)=>{let{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:a,value:l="on",onCheckedChange:u,...c}=t,[f,p]=L(null),d=ah(e,T=>p(T)),h=P(!1),b=f?!!f.closest("form"):!0,[y=!1,v]=lj({prop:o,defaultProp:i,onChange:u}),x=P(y);return U(()=>{let T=f?.form;if(T){let $=()=>v(x.current);return T.addEventListener("reset",$),()=>T.removeEventListener("reset",$)}},[f,v]),H(Pre,{scope:r,state:y,disabled:a},H(kx.button,pe({type:"button",role:"checkbox","aria-checked":os(y)?"mixed":y,"aria-required":s,"data-state":pj(y),"data-disabled":a?"":void 0,disabled:a,value:l},c,{ref:d,onKeyDown:Bt(t.onKeyDown,T=>{T.key==="Enter"&&T.preventDefault()}),onClick:Bt(t.onClick,T=>{v($=>os($)?!0:!$),b&&(h.current=T.isPropagationStopped(),h.current||T.stopPropagation())})})),b&&H(qre,{control:f,bubbles:!h.current,name:n,value:l,checked:y,required:s,disabled:a,style:{transform:"translateX(-100%)"}}))}),Lre="CheckboxIndicator",jre=Y((t,e)=>{let{__scopeCheckbox:r,forceMount:n,...o}=t,i=Mre(Lre,r);return H(Tx,{present:n||os(i.state)||i.state===!0},H(kx.span,pe({"data-state":pj(i.state),"data-disabled":i.disabled?"":void 0},o,{ref:e,style:{pointerEvents:"none",...t.style}})))}),qre=t=>{let{control:e,checked:r,bubbles:n=!0,...o}=t,i=P(null),s=cj(r),a=uj(e);return U(()=>{let l=i.current,u=window.HTMLInputElement.prototype,f=Object.getOwnPropertyDescriptor(u,"checked").set;if(s!==r&&f){let p=new Event("click",{bubbles:n});l.indeterminate=os(r),f.call(l,os(r)?!1:r),l.dispatchEvent(p)}},[s,r,n]),H("input",pe({type:"checkbox","aria-hidden":!0,defaultChecked:os(r)?!1:r},o,{tabIndex:-1,ref:i,style:{...t.style,...a,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function os(t){return t==="indeterminate"}function pj(t){return os(t)?"indeterminate":t?"checked":"unchecked"}var Rx=$re,dj=jre;S();var Nx=Y(({className:t,checked:e,...r},n)=>m(Rx,{ref:n,className:re("data-[state=checked]:text-mod-error peer h-3 w-3 shrink-0 rounded-sm border disabled:cursor-not-allowed disabled:opacity-50 bg-primary obzt-btn-reset",t),checked:e,...r,children:m(dj,{className:re("flex items-center justify-center"),children:m(Vo,{icon:"chevrons-down",size:"0.75rem",className:"contents"})})}));Nx.displayName=Rx.displayName;var mj=Y(({id:t,checked:e,onCheckChange:r,title:n,disabled:o,className:i,...s},a)=>m("div",{className:re("flex items-center gap-x-1","rounded-sm focus-within:outline-none focus-within:ring-2 focus-within:ring-mod-border-focus focus-within:ring-offset-2",e&&"animate-pulse",i),ref:a,...s,children:[m(Nx,{className:re("h-3 w-3",o&&"hidden"),id:t,checked:e,disabled:o,onCheckedChange:r}),m("label",{htmlFor:t,className:"peer-[[data-state=checked]]:text-mod-error text-status-bar text-txt-status-bar leading-none peer-disabled:cursor-not-allowed",children:n})]}));mj.displayName="ImportingStatus";var mg=require("obsidian");S();var Na=require("obsidian");S();var hj={sanitize:DOMPurify.sanitize.bind(DOMPurify),setIcon:Na.setIcon,renderMarkdown(t){return m(zre,{content:t})}};function zre({content:t}){let e=P(null);return m("div",{className:"contents",ref:n=>{n?(n.empty(),e.current&&e.current.unload(),e.current=new Na.Component,Na.MarkdownRenderer.renderMarkdown(t,n,"",e.current)):e.current&&(e.current.unload(),e.current=null)}})}var is=require("obsidian"),ch=class extends is.FileView{constructor(e){super(e),this.navigation=!1,this.allowNoFile=!0,this.requestUpdate=(0,is.debounce)(()=>this.update(),10)}load(){super.load(),this.registerEvent(this.app.workspace.on("file-open",this.onFileOpen,this))}async setState(e,r){if(!Object.hasOwn(e,"file")&&!Object.hasOwn(e,"group")){let n=this.leaf.workspace.getActiveFile();n&&(e.file=n?.path)}await super.setState(e,r)}onLoadFile(e){return this.requestUpdate()}onUnloadFile(e){return this.requestUpdate()}onFileOpen(e){this.leaf.group||this.leaf.pinned||(e instanceof is.TFile?this.loadFile(e):this.loadFile(null),this.requestUpdate())}onGroupChange(){if(super.onGroupChange(),this.leaf.group)for(let e=0,r=this.leaf.workspace.getGroupLeaves(this.leaf.group);etypeof t=="string"&&t.trim().length>0?await e.database.search(t):await e.database.getItemsOf(50);function dh({item:t,fields:e},r){r.addClass("mod-complex");let n=r.createDiv("suggestion-content").createDiv("suggestion-title").createSpan(),o=r.createDiv("suggestion-aux");for(let a of e){let l=o.createEl("kbd","suggestion-hotkey");switch(l.setAttribute("aria-label",a),a){case"title":(0,uh.setIcon)(l,"type");break;case"creators":(0,uh.setIcon)(l,"user");break;case"date":(0,uh.setIcon)(l,"calendar");break;default:l.setText(a);break}}let[i]=t.title??[],s=n.createDiv({cls:"title"});typeof i=="string"&&i?s.setText(i):s.setText("Title missing"),this.plugin.settings.current?.showCitekeyInSuggester&&t.citekey&&n.createDiv({cls:"citekey",text:t.citekey}),Ure(t)&&n.append(Wre(t))}var Ure=t=>t.itemType==="journalArticle",Wre=t=>{let{creators:e,date:r,publicationTitle:n,volume:o,issue:i,pages:s}=t,a={creators:Hre(e),date:r,publication:n,volume:o,issue:i,pages:s},l=(u,c,f)=>a[c]&&u.createSpan({cls:f??c,text:a[c]??void 0});return createDiv({cls:"meta"},u=>{(a.creators||a.date)&&u.createSpan({cls:"author-year"},c=>{l(c,"creators"),l(c,"date")}),l(u,"publication"),(a.volume||a.issue)&&u.createSpan({cls:"vol-issue"},c=>{l(c,"volume"),l(c,"issue")}),l(u,"pages")})},Hre=t=>{if(!t||!t[0])return"";let e=t[0],r=Qd(e)||em(e)?e.lastName:"";return t.length>1&&(r=r.trim()+" et al."),r};var bu=class extends gj.EditorSuggest{constructor(r){super(r.app);this.plugin=r;this.suggestEl.addClass(fh)}getSuggestions(r){return ph(r.query,this.plugin)}renderSuggestion=dh.bind(this)};var Qn=class extends tm{constructor(r){super(r.app);this.plugin=r;this.modalEl.addClass(fh)}getSuggestions(r){return ph(r,this.plugin)}renderSuggestion=dh.bind(this);onChooseSuggestion(){}};var vj=require("obsidian");var yj=require("@codemirror/state");async function bj(t,e,r=e.settings.current?.updateOverwrite){let{app:n,noteIndex:o,templateRenderer:i}=e,s=o.getNotesFor(t);if(s.length===0)return null;let a=e.settings.libId,l=await e.databaseAPI.getAttachments(t.itemID,a),u=new Set(s.flatMap(y=>es(y,e.app.metadataCache))),c=l.filter(y=>u.has(y.itemID)),f;c.length===0&&(f=await Kn(l,e.app),f&&(ga(f,t),c.push(f)));let p=await e.databaseAPI.getNotes(t.itemID,a).then(y=>e.noteParser.normalizeNotes(y)),d=await vu(t,{all:l,selected:c,notes:p},e),h=Object.values(d)[0],b={notes:s.length,addedAnnots:0,updatedAnnots:0};for(let y of s){let v=n.metadataCache.getCache(y);if(!v)continue;let x=es(y,e.app.metadataCache);x||(f===void 0&&(f=await Kn(c,e.app)),f?x=[f.itemID]:x=[]);let T=n.vault.getAbstractFileByPath(y),$={plugin:e,sourcePath:y};if(r){let _=await i.renderNote(d[x[0]],$);await n.vault.modify(T,_);continue}let V=pu((v.sections?.filter(au)??[]).flatMap(_=>lu(_.id).map(I=>[I,_.position])),zi(([_])=>_),ha((_,I)=>({key:_,blocks:I.map(([B,D])=>D)}))),J=new Set(Object.values(v.blocks??{})?.filter(au).flatMap(_=>lu(_.id).map(I=>I))),G=new Map(x.map(_=>[d[_],[]])),K=[];if(await Promise.all(x.map(async _=>{let I=d[_];if(!(!I.annotations||I.annotations.length===0))return await Promise.all(I.annotations.map(async B=>{let D=ir(B,!0),oe=V[D];if(oe){if(!e.settings.current?.updateAnnotBlock)return;let se=await i.renderAnnot(B,I,$);K.push(...oe.blocks.map(be=>({from:be.start.offset,to:be.end.offset,insert:se})))}else J.has(D)||G.get(I).push(B)})??[])})),K.length>0){let _=yj.EditorState.create({doc:await n.vault.read(T)}).update({changes:K}).state.doc.toString();await n.vault.modify(T,_)}await i.setFrontmatterTo(T,jt(h,$).docItem);let F=[...G].reduce((_,[I,B])=>{if(B.length===0)return _;let D=i.renderAnnots({...I,annotations:B},$);return(_&&_+` -`)+D},"");F&&await n.vault.append(T,F);let Q=K.length,O=[...G.values()].reduce((_,I)=>_+I.length,0);b.updatedAnnots+=Q,b.addedAnnots+=O}return b}async function vu(t,{all:e,selected:r,notes:n},o){let i=o.settings.libId,s=await o.databaseAPI.getTags([[t.itemID,i]]);if(r.length===0)return{[-1]:{docItem:t,attachment:null,tags:s,allAttachments:e,annotations:[],notes:n}};let a={};for(let l of r){let u=l?await o.databaseAPI.getAnnotations(l.itemID,i):[];a[l.itemID]={docItem:t,attachment:l,tags:{...s,...await o.databaseAPI.getTags(u.map(c=>[c.itemID,i]))},allAttachments:e,annotations:u,notes:n}}return a}async function mh({alt:t,item:e},{start:r,end:n,editor:o,file:i},s){let{plugin:a}=s,l=a.settings.libId,u=await a.databaseAPI.getAttachments(e.itemID,l),c=new Set(es(i,a.app.metadataCache)),f=u.filter(y=>c.has(y.itemID)),p;f.length===0&&(p=await Kn(u,a.app),p&&(ga(p,e),f.push(p)));let d=await a.databaseAPI.getNotes(e.itemID,l).then(y=>a.noteParser.normalizeNotes(y)),h=await vu(e,{all:u,selected:f,notes:d},s.plugin),b=s.renderCitations(Object.values(h),{plugin:s.plugin},t);o.replaceRange(b,r,n),o.setCursor(o.offsetToPos(o.posToOffset(r)+b.length))}var wj=t=>vj.Keymap.isModifier(t,"Shift");var Kre=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to insert primary Markdown citation"},{command:"\u21B5 (end with /)",purpose:"Insert secondary Markdown citation"}],wu=class extends bu{constructor(r){super(r);this.plugin=r;this.setInstructions(Kre)}onTrigger(r,n){if(!this.plugin.settings.current?.citationEditorSuggester)return null;let o=n.getLine(r.line),s=o.substring(0,r.ch).match(/[[【]@([^\]】]*)$/);if(!s)return null;let a={...r};return(o[r.ch]==="]"||o[r.ch]==="\u3011")&&(a.ch+=1),{end:a,start:{ch:s.index,line:r.line,alt:!!s[0]?.endsWith("/")},query:s[1].replaceAll(/\/$/g,"")}}selectSuggestion(r){this.context&&mh({item:r.item,alt:this.context.start.alt??!1},this.context,this.plugin.templateRenderer)}};var Vre=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to insert Markdown citation"},{command:"shift \u21B5",purpose:"to insert secondary Markdown citation"},{command:"esc",purpose:"to dismiss"}],Dx=class extends Qn{constructor(r){super(r);this.plugin=r;this.setInstructions(Vre)}};async function Fx(t,e,r){let n=await hh(r);if(!n)return!1;let o=t.getCursor();return await mh({item:n.value.item,alt:wj(n.evt)},{start:o,end:o,editor:t,file:e},r.templateRenderer),!0}async function hh(t){return await Wi(new Dx(t))}var us=require("obsidian");S();S();S();S();var Zo=Z(Go());S();function Mx(t){let e=Object.prototype.toString.call(t).slice(8,-1);return e==="Object"&&typeof t[Symbol.iterator]=="function"?"Iterable":e==="Custom"&&t.constructor!==Object&&t instanceof Object?"Object":e}var Ij=Z(Go());S();var Eu=Z(Go());S();var xj=Z(Go());S();function xu(t){let{styling:e,arrowStyle:r="single",expanded:n,nodeType:o,onClick:i}=t;return N.createElement("div",(0,xj.default)({},e("arrowContainer",r),{onClick:i}),N.createElement("div",e(["arrow","arrowSign"],o,n,r),"\u25B6",r==="double"&&N.createElement("div",e(["arrowSign","arrowSignInner"]),"\u25B6")))}function Gre(t,e){return t==="Object"?Object.keys(e).length:t==="Array"?e.length:1/0}function Zre(t){return typeof t.set=="function"}function Jre(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1/0,i;if(t==="Object"){let s=Object.getOwnPropertyNames(e);r&&s.sort(r===!0?void 0:r),s=s.slice(n,o+1),i={entries:s.map(a=>({key:a,value:e[a]}))}}else if(t==="Array")i={entries:e.slice(n,o+1).map((s,a)=>({key:a+n,value:s}))};else{let s=0,a=[],l=!0,u=Zre(e);for(let c of e){if(s>o){l=!1;break}n<=s&&(u&&Array.isArray(c)?typeof c[0]=="string"||typeof c[0]=="number"?a.push({key:c[0],value:c[1]}):a.push({key:`[entry ${s}]`,value:{"[key]":c[0],"[value]":c[1]}}):a.push({key:s,value:c})),s++}i={hasMore:!l,entries:a}}return i}function $x(t,e,r){let n=[];for(;e-t>r*r;)r=r*r;for(let o=t;o<=e;o+=r)n.push({from:o,to:Math.min(e,o+r-1)});return n}function Lx(t,e,r,n){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:1/0,s=Jre.bind(null,t,e,r);if(!n)return s().entries;let a=i<1/0,l=Math.min(i-o,Gre(t,e));if(t!=="Iterable"){if(l<=n||n<7)return s(o,i).entries}else if(l<=n&&!a)return s(o,i).entries;let u;if(t==="Iterable"){let{hasMore:c,entries:f}=s(o,o+n-1);u=c?[...f,...$x(o+n,o+2*n-1,n)]:f}else u=a?$x(o,i,n):[...s(0,n-5).entries,...$x(n-4,l-5,n),...s(l-4,l-1).entries];return u}var Ej=Z(Go());S();function jx(t){let{styling:e,from:r,to:n,renderChildNodes:o,nodeType:i}=t,[s,a]=L(!1),l=X(()=>{a(!s)},[s]);return s?N.createElement("div",e("itemRange",s),o(t,r,n)):N.createElement("div",(0,Ej.default)({},e("itemRange",s),{onClick:l}),N.createElement(xu,{nodeType:i,styling:e,expanded:!1,onClick:l,arrowStyle:"double"}),`${r} ... ${n}`)}function Yre(t){return t.to!==void 0}function Sj(t,e,r){let{nodeType:n,data:o,collectionLimit:i,circularCache:s,keyPath:a,postprocessValue:l,sortObjectKeys:u}=t,c=[];return Lx(n,o,u,i,e,r).forEach(f=>{if(Yre(f))c.push(N.createElement(jx,(0,Eu.default)({},t,{key:`ItemRange--${f.from}-${f.to}`,from:f.from,to:f.to,renderChildNodes:Sj})));else{let{key:p,value:d}=f,h=s.indexOf(d)!==-1;c.push(N.createElement(Su,(0,Eu.default)({},t,{postprocessValue:l,collectionLimit:i,key:`Node--${p}`,keyPath:[p,...a],value:l(d),circularCache:[...s,d],isCircular:h,hideRoot:!1})))}}),c}function ss(t){let{circularCache:e=[],collectionLimit:r,createItemString:n,data:o,expandable:i,getItemString:s,hideRoot:a,isCircular:l,keyPath:u,labelRenderer:c,level:f=0,nodeType:p,nodeTypeIndicator:d,shouldExpandNodeInitially:h,styling:b}=t,[y,v]=L(l?!1:h(u,o,f)),x=X(()=>{i&&v(!y)},[i,y]),T=y||a&&f===0?Sj({...t,circularCache:e,level:f+1}):null,$=N.createElement("span",b("nestedNodeItemType",y),d),V=s(p,o,$,n(o,r),u),J=[u,p,y,i];return a?N.createElement("li",b("rootNode",...J),N.createElement("ul",b("rootNodeChildren",...J),T)):N.createElement("li",b("nestedNode",...J),i&&N.createElement(xu,{styling:b,nodeType:p,expanded:y,onClick:x}),N.createElement("label",(0,Eu.default)({},b(["label","nestedNodeLabel"],...J),{onClick:x}),c(...J)),N.createElement("span",(0,Eu.default)({},b("nestedNodeItemString",...J),{onClick:x}),V),N.createElement("ul",b("nestedNodeChildren",...J),T))}function Xre(t){let e=Object.getOwnPropertyNames(t).length;return`${e} ${e!==1?"keys":"key"}`}function qx(t){let{data:e,...r}=t;return N.createElement(ss,(0,Ij.default)({},r,{data:e,nodeType:"Object",nodeTypeIndicator:r.nodeType==="Error"?"Error()":"{}",createItemString:Xre,expandable:Object.getOwnPropertyNames(e).length>0}))}var _j=Z(Go());S();function Qre(t){return`${t.length} ${t.length!==1?"items":"item"}`}function Bx(t){let{data:e,...r}=t;return N.createElement(ss,(0,_j.default)({},r,{data:e,nodeType:"Array",nodeTypeIndicator:"[]",createItemString:Qre,expandable:e.length>0}))}var Oj=Z(Go());S();function ene(t,e){let r=0,n=!1;if(Number.isSafeInteger(t.size))r=t.size;else for(let o of t){if(e&&r+1>e){n=!0;break}r+=1}return`${n?">":""}${r} ${r!==1?"entries":"entry"}`}function zx(t){return N.createElement(ss,(0,Oj.default)({},t,{nodeType:"Iterable",nodeTypeIndicator:"()",createItemString:ene,expandable:!0}))}S();function Hr(t){let{nodeType:e,styling:r,labelRenderer:n,keyPath:o,valueRenderer:i,value:s,valueGetter:a=l=>l}=t;return N.createElement("li",r("value",e,o),N.createElement("label",r(["label","valueLabel"],e,o),n(o,e,!1,!1)),N.createElement("span",r("valueText",e,o),i(a(s),s,...o)))}function Su(t){let{getItemString:e,keyPath:r,labelRenderer:n,styling:o,value:i,valueRenderer:s,isCustomNode:a,...l}=t,u=a(i)?"Custom":Mx(i),c={getItemString:e,key:r[0],keyPath:r,labelRenderer:n,nodeType:u,styling:o,value:i,valueRenderer:s},f={...l,...c,data:i,isCustomNode:a};switch(u){case"Object":case"Error":case"WeakMap":case"WeakSet":return N.createElement(qx,f);case"Array":return N.createElement(Bx,f);case"Iterable":case"Map":case"Set":return N.createElement(zx,f);case"String":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:p=>`"${p}"`}));case"Number":return N.createElement(Hr,c);case"Boolean":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:p=>p?"true":"false"}));case"Date":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:p=>p.toISOString()}));case"Null":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:()=>"null"}));case"Undefined":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:()=>"undefined"}));case"Function":case"Symbol":return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:p=>p.toString()}));case"Custom":return N.createElement(Hr,c);default:return N.createElement(Hr,(0,Zo.default)({},c,{valueGetter:()=>`<${u}>`}))}}var ag=Z(gh()),X5=Z(kj()),tE=Z($j()),rE=Z(o5()),Xx=Z(C5()),Qx=Z(V5());function G5(t){var e=t[0],r=t[1],n=t[2],o,i,s;return o=e*1+r*0+n*1.13983,i=e*1+r*-.39465+n*-.5806,s=e*1+r*2.02311+n*0,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[o*255,i*255,s*255]}function Z5(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=e*.299+r*.587+n*.114,i=e*-.14713+r*-.28886+n*.436,s=e*.615+r*-.51499+n*-.10001;return[o,i,s]}function J5(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function zt(t){for(var e=1;e1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l2?n-2:0),i=2;i1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=e.defaultBase16,o=n===void 0?Q5:n,i=e.base16Themes,s=i===void 0?null:i,a=Iie(r,s);a&&(r=zt(zt({},a),r));for(var l=Y5.reduce(function(b,y){return b[y]=r[y]||o[y],b},{}),u=Object.keys(r).reduce(function(b,y){return Y5.indexOf(y)===-1&&(b[y]=r[y]),b},{}),c=t(l),f=Eie(u,c),p=arguments.length,d=new Array(p>3?p-3:0),h=3;h({BACKGROUND_COLOR:t.base00,TEXT_COLOR:t.base07,STRING_COLOR:t.base0B,DATE_COLOR:t.base0B,NUMBER_COLOR:t.base09,BOOLEAN_COLOR:t.base09,NULL_COLOR:t.base08,UNDEFINED_COLOR:t.base08,FUNCTION_COLOR:t.base08,SYMBOL_COLOR:t.base08,LABEL_COLOR:t.base0D,ARROW_COLOR:t.base0D,ITEM_STRING_COLOR:t.base0B,ITEM_STRING_EXPANDED_COLOR:t.base03}),Oie=t=>({String:t.STRING_COLOR,Date:t.DATE_COLOR,Number:t.NUMBER_COLOR,Boolean:t.BOOLEAN_COLOR,Null:t.NULL_COLOR,Undefined:t.UNDEFINED_COLOR,Function:t.FUNCTION_COLOR,Symbol:t.SYMBOL_COLOR}),Tie=t=>{let e=_ie(t);return{tree:{border:0,padding:0,marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"0.125em",marginRight:0,listStyle:"none",MozUserSelect:"none",WebkitUserSelect:"none",backgroundColor:e.BACKGROUND_COLOR},value:(r,n,o)=>{let{style:i}=r;return{style:{...i,paddingTop:"0.25em",paddingRight:0,marginLeft:"0.875em",WebkitUserSelect:"text",MozUserSelect:"text",wordWrap:"break-word",paddingLeft:o.length>1?"2.125em":"1.25em",textIndent:"-0.5em",wordBreak:"break-all"}}},label:{display:"inline-block",color:e.LABEL_COLOR},valueLabel:{margin:"0 0.5em 0 0"},valueText:(r,n)=>{let{style:o}=r;return{style:{...o,color:Oie(e)[n]}}},itemRange:(r,n)=>({style:{paddingTop:n?0:"0.25em",cursor:"pointer",color:e.LABEL_COLOR}}),arrow:(r,n,o)=>{let{style:i}=r;return{style:{...i,marginLeft:0,transition:"150ms",WebkitTransition:"150ms",MozTransition:"150ms",WebkitTransform:o?"rotateZ(90deg)":"rotateZ(0deg)",MozTransform:o?"rotateZ(90deg)":"rotateZ(0deg)",transform:o?"rotateZ(90deg)":"rotateZ(0deg)",transformOrigin:"45% 50%",WebkitTransformOrigin:"45% 50%",MozTransformOrigin:"45% 50%",position:"relative",lineHeight:"1.1em",fontSize:"0.75em"}}},arrowContainer:(r,n)=>{let{style:o}=r;return{style:{...o,display:"inline-block",paddingRight:"0.5em",paddingLeft:n==="double"?"1em":0,cursor:"pointer"}}},arrowSign:{color:e.ARROW_COLOR},arrowSignInner:{position:"absolute",top:0,left:"-0.4em"},nestedNode:(r,n,o,i,s)=>{let{style:a}=r;return{style:{...a,position:"relative",paddingTop:"0.25em",marginLeft:n.length>1?"0.875em":0,paddingLeft:s?0:"1.125em"}}},rootNode:{padding:0,margin:0},nestedNodeLabel:(r,n,o,i,s)=>{let{style:a}=r;return{style:{...a,margin:0,padding:0,WebkitUserSelect:s?"inherit":"text",MozUserSelect:s?"inherit":"text",cursor:s?"pointer":"default"}}},nestedNodeItemString:(r,n,o,i)=>{let{style:s}=r;return{style:{...s,paddingLeft:"0.5em",cursor:"default",color:i?e.ITEM_STRING_EXPANDED_COLOR:e.ITEM_STRING_COLOR}}},nestedNodeItemType:{marginLeft:"0.3em",marginRight:"0.3em"},nestedNodeChildren:(r,n,o)=>{let{style:i}=r;return{style:{...i,padding:0,margin:0,listStyle:"none",display:o?"block":"none"}}},rootNodeChildren:{padding:0,margin:0,listStyle:"none"}}},Cie=eq(Tie,{defaultBase16:nq}),oq=Cie;var iq=t=>t,Aie=(t,e,r)=>r===0,kie=(t,e,r,n)=>N.createElement("span",null,r," ",n),Rie=t=>{let[e]=t;return N.createElement("span",null,e,":")},Nie=()=>!1;function sq(t){let{data:e,theme:r,invertTheme:n,keyPath:o=["root"],labelRenderer:i=Rie,valueRenderer:s=iq,shouldExpandNodeInitially:a=Aie,hideRoot:l=!1,getItemString:u=kie,postprocessValue:c=iq,isCustomNode:f=Nie,collectionLimit:p=50,sortObjectKeys:d=!1}=t,h=ie(()=>oq(n?rq(r):r),[r,n]);return N.createElement("ul",h("tree"),N.createElement(Su,{keyPath:l?[]:o,value:c(e),isCustomNode:f,styling:h,labelRenderer:i,valueRenderer:s,shouldExpandNodeInitially:a,hideRoot:l,getItemString:u,postprocessValue:c,collectionLimit:p,sortObjectKeys:d}))}var aq=require("obsidian");var Die=()=>{let[t]=Mt("clipboard-copy");return m("span",{ref:t})},lq=(t,e,r,n,o)=>{if(o.length===1){let i=async s=>{s.preventDefault(),s.stopPropagation(),await navigator.clipboard.writeText("```json\n"+JSON.stringify(e,null,2)+"\n```"),new aq.Notice("Copied JSON code block to clipboard")};return m("span",{role:"button",tabIndex:0,onClick:i,onKeyDown:i,"aria-label":"Copy item details in JSON",children:[n," ",m(Die,{})]})}if(o[1]==="creators"&&o.length===3){let i=jc(e);if(i)return m("span",{children:i})}if(o[1]==="tags"&&o.length===3){let i=e;return m("span",{children:['"',i.name,'"" (',Bi[i.type],")"]})}if(o[0]==="sortIndex"&&o.length===2)return m("span",{children:["[",e.join(", "),"]"]});if(o.length===2&&Array.isArray(e)&&e.length===1){let i=JSON.stringify(e[0]);return m("span",{children:[r," ",i.length>100?i.slice(0,100)+"...":i]})}return m("span",{children:[r," ",n]})};var uq=require("obsidian");var fq=(t,e,r,n)=>{let o=t.length===1,i=t.slice(0,-1),s=cq(i);return m("span",{...o?void 0:{onContextMenu:u=>{let c=new uq.Menu().addItem(f=>f.setTitle("Copy template").onClick(()=>{navigator.clipboard.writeText(`<%= ${s} %>`)}));n&&e!=="Array"&&c.addItem(f=>f.setTitle("Copy template (using with)").onClick(()=>{let[p,...d]=i,h=typeof p=="string"&&pq.test(p)?p:`'${p}'`,b=cq(d);navigator.clipboard.writeText(`<% { const { ${h}: $it } = ${b}; %> +`,n+1)}return r}function lee(t){let e=aee.exec(t);if(!e)return{yaml:null,body:t,bodyBegin:1};let r=e[e.length-1].replace(/^\s+|\s+$/g,""),n=t.replace(e[0],""),o=cee(e,t);return{yaml:r,body:n,bodyBegin:o}}a();var Jm=require("path"),Qw=require("url");a();a();a();a();function Jw(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}function Yw(t,e){if(typeof t!="string"||typeof e!="string")throw new TypeError("Expected a string");let r=new RegExp(`(?:${Jw(e)}){2,}`,"g");return t.replace(r,e)}a();function Zm(){return/[<>:"/\\|?*\u0000-\u001F]/g}function y2(){return/^(con|prn|aux|nul|com\d|lpt\d)$/i}a();function Xw(t,e){if(typeof t!="string"||typeof e!="string")throw new TypeError("Expected a string");return t.startsWith(e)&&(t=t.slice(e.length)),t.endsWith(e)&&(t=t.slice(0,-e.length)),t}var uee=100,b2=/[\u0000-\u001F\u0080-\u009F]/g,fee=/^\.+(\\|\/)|^\.+$/,pee=/\.+$/;function ts(t,e={}){if(typeof t!="string")throw new TypeError("Expected a string");let r=e.replacement===void 0?"!":e.replacement;if(Zm().test(r)&&b2.test(r))throw new Error("Replacement string cannot contain reserved filename characters");if(t=t.normalize("NFD"),t=t.replace(fee,r),t=t.replace(Zm(),r),t=t.replace(b2,r),t=t.replace(pee,""),r.length>0){let o=t[0]===".";t=Yw(t,r),t=t.length>1?Xw(t,r):t,!o&&t[0]==="."&&(t=r+t),t[t.length-1]==="."&&(t+=r)}t=y2().test(t)?t+r:t;let n=typeof e.maxLength=="number"?e.maxLength:uee;if(t.length>n){let o=t.lastIndexOf(".");if(o===-1)t=t.slice(0,n);else{let i=t.slice(0,o),s=t.slice(o);t=i.slice(0,Math.max(1,n-s.length))+s}}return t}a();var ex=t=>encodeURI(t)===t?t:`<${t}>`,Ym=t=>t.name.endsWith(".eta.md"),tx=(t,e)=>e.path?e.path.startsWith("storage:")?(0,Jm.join)(t,"storage",e.key,e.path.replace(/^storage:/,"")):e.path:"",Xm=(t,e,r,n=null,o=null)=>{if(!n?.path)return"";let i=o?`#page=${o}`:void 0,s=e.vault.adapter.getBasePath(),c=tx(t,n),l=(0,Jm.relative)(s,c);if(l.startsWith(".."))return`[attachment](${ex((0,Qw.pathToFileURL)(c).href+(i??""))})`;{let f=e.metadataCache.getFirstLinkpathDest(l,"");return f?e.fileManager.generateMarkdownLink(f,r??"",i).replace(/^!/,""):(H.warn("fileLink: file not found",l,c),"")}},v2=t=>ts(t,{replacement:"_"}),Qm=t=>Gl(t)&&t.type===Ne.image,dee=(t,e,r)=>e?`[${r??""}](${ex(t)})`:`[[${t}${r?"|"+r:""}]]`,rx=(t,e)=>{if(Qm(t)){let r=e.imgCacheImporter.import(t);if(r)return dee(r,e.app.vault.getConfig("useMarkdownLinks"));{let n=e.imgCacheImporter.getCachePath(t);return`[Annotation ${t.key}](${ex((0,Qw.pathToFileURL)(n).href)})`}}else return""};function E2(t){cr(t,{compile:e=>function(n,o){let i=this,s=e.call(this,n,o);if(!o?.filepath)return s;let c=o.filepath,l=St(c,i.settings.templateDir);if(!l)return s;let f=s;switch(l.name){case"filename":f=(u,d)=>v2(s.call(this,u,d));break;case"annotation":f=(u,d)=>{let m=s.call(this,u,d),h=!0,{yaml:y,body:w}=Gm(m);if(y)try{(0,eh.parseYaml)(y).callout===!1&&(h=!1)}catch(x){new eh.Notice(`Error parsing frontmatter, ${x}`)}if(!h)return w;let v=w.trim().split(` +`);return v.push(`^${u.blockID}`),v.map(x=>`> ${x}`).join(` +`)};break;default:break}return Object.groupBy&&Map.groupBy?f:(u,d)=>{let m=mee(),h=f.call(this,u,d);return m(),h}}})}function mee(){let t=[];return Object.groupBy||(Object.groupBy=x2.default,t.push(()=>delete Object.groupBy)),Map.groupBy||(Map.groupBy=w2.default,t.push(()=>delete Map.groupBy)),()=>t.forEach(e=>e())}a();var rs="zotero-key",ka="zt-attachments";a();a();var S2=require("url");var I2=require("obsidian");a();var Vo=t=>t.plugin.settings.current?.zoteroDataDir,mu=Symbol("proxied"),th=t=>!!t[mu];var rh={"#FF6666":"red","#FF8C19":"orange","#F19837":"orange","#FFD400":"yellow","#999999":"gray","#AAAAAA":"gray","#5FB236":"green","#009980":"cyan","#2EA8E5":"blue","#576DD9":"navy","#A28AE5":"purple","#A6507B":"brown","#E56EEE":"magenta"};var nx=new Set(uo()("attachment","tags")),ox=(t,e,r)=>new Proxy({get page(){return Is(t.position.pageIndex,!0)??NaN},get backlink(){return Uo(t)},get blockID(){let n=lr(t),o=Is(t.position.pageIndex,!0);return typeof o=="number"&&(n+=`p${o}`),n},get commentMd(){return t.comment?(0,I2.htmlToMarkdown)(t.comment):""},get imgPath(){return Qm(this)?zo(this,Vo(r)):""},get imgUrl(){if(Qm(this)){let n=zo(this,Vo(r));return(0,S2.pathToFileURL)(n).href}else return""},get imgLink(){return rx(this,r.plugin)},get imgEmbed(){let n=rx(this,r.plugin);return n?`!${n}`:""},get fileLink(){return Xm(Vo(r),r.plugin.app,r.sourcePath,e.attachment,Is(t.position.pageIndex,!0))},get textBlock(){return t.text?`\`\`\`zotero-annot +> ${t.text} [zotero](${Uo(t)}) +\`\`\``:""},get colorName(){let n=t.color?.toUpperCase();return rh[n]||this.color},docItem:"not-loaded"},{get(n,o,i){if(o==="tags"){if(!e.tags[t.itemID])throw console.error(e,t.itemID),new Error("No tags loaded for item "+t.itemID);return e.tags[t.itemID]}if(o==="docItem"){if(n.docItem==="not-loaded")throw new Error("Doc Item not loaded for item "+t.itemID);return n.docItem}return nx.has(o)?Reflect.get(e,o,i):Reflect.get(t,o,i)??Reflect.get(n,o,i)},ownKeys(n){return[...Reflect.ownKeys(t),...nx,...Reflect.ownKeys(n)]},getOwnPropertyDescriptor(n,o){return Object.prototype.hasOwnProperty.call(t,o)?Reflect.getOwnPropertyDescriptor(t,o):nx.has(o)?Reflect.getOwnPropertyDescriptor(e,o):Reflect.getOwnPropertyDescriptor(n,o)}});a();function ix(t,e){return!t||th(t)?t:new Proxy({get filePath(){return tx(Vo(e),t)}},{get(r,n,o){return n===mu?!0:Reflect.get(t,n,o)??Reflect.get(r,n,o)},ownKeys(r){return[...Reflect.ownKeys(t),...Reflect.ownKeys(r)]},getOwnPropertyDescriptor(r,n){return Object.prototype.hasOwnProperty.call(t,n)?Reflect.getOwnPropertyDescriptor(t,n):Reflect.getOwnPropertyDescriptor(r,n)}})}a();a();var sx=class extends Array{toString(){return this.join(" > ")}},ax=({path:t,...e})=>{let r={path:sx.from(t),toString(){return e.name}};return new Proxy(r,{get(n,o,i){return Reflect.get(n,o,i)??Reflect.get(e,o,i)},ownKeys(n){return[...Reflect.ownKeys(e),...Reflect.ownKeys(n).filter(o=>!(o==="toJSON"||o==="toString"))]},getOwnPropertyDescriptor(n,o){return Object.prototype.hasOwnProperty.call(e,o)?Reflect.getOwnPropertyDescriptor(e,o):Reflect.getOwnPropertyDescriptor(n,o)}})};a();var cx=t=>{let e={get fullname(){return Vl(t)??""},toString(){return this.fullname},toJSON(){return this.fullname}};return new Proxy(e,{get(r,n,o){return Reflect.get(r,n,o)??Reflect.get(t,n,o)},ownKeys(r){return[...Reflect.ownKeys(t),...Reflect.ownKeys(r).filter(n=>!(n==="toJSON"||n==="toString"))]},getOwnPropertyDescriptor(r,n){return Object.prototype.hasOwnProperty.call(t,n)?Reflect.getOwnPropertyDescriptor(t,n):Reflect.getOwnPropertyDescriptor(r,n)}})};var lx=new Set(uo()("attachment","allAttachments","tags","notes")),ux=({creators:t,collections:e,...r},n,o)=>{let i=t.map(s=>cx(s));return new Proxy({get backlink(){return Uo(r)},get fileLink(){return Xm(Vo(o),o.plugin.app,o.sourcePath,n.attachment)},get authorsShort(){let s=this.authors;if(!s.length)return"";let c=s[0],l=c.lastName??c.fullname;return s.length===1?l:`${l} et al.`},annotations:"not-loaded",creators:i,collections:e.map(s=>ax(s)),get authors(){return i.filter(s=>s.creatorType==="author")}},{get(s,c,l){if(c==="tags"){if(!n.tags[r.itemID])throw new Error("No tags loaded for item "+r.itemID);return n.tags[r.itemID]}return lx.has(c)?n[c]:c==="annotations"?s.annotations:Reflect.get(r,c,l)??Reflect.get(s,c,l)},ownKeys(s){return[...Reflect.ownKeys(r),...lx,...Reflect.ownKeys(s)]},getOwnPropertyDescriptor(s,c){return Object.prototype.hasOwnProperty.call(r,c)?Reflect.getOwnPropertyDescriptor(r,c):lx.has(c)?Reflect.getOwnPropertyDescriptor(n,c):Reflect.getOwnPropertyDescriptor(s,c)}})};a();function _2(t){return!t||th(t)?t:new Proxy({toString(){return t.name},toJSON(){return t.name}},{get(e,r,n){return r===mu?!0:Reflect.get(e,r,n)??Reflect.get(t,r,n)},ownKeys(e){return[...Reflect.ownKeys(t),...Reflect.ownKeys(e).filter(r=>!(r==="toJSON"||r==="toString"))]},getOwnPropertyDescriptor(e,r){return Object.prototype.hasOwnProperty.call(t,r)?Reflect.getOwnPropertyDescriptor(t,r):Reflect.getOwnPropertyDescriptor(e,r)}})}function zt(t,e,r){let n={...t,attachement:ix(t.attachment,e),allAttachments:t.allAttachments.map(c=>ix(c,e)),tags:wa(t.tags,c=>c.map(l=>_2(l)))},o=ux(t.docItem,n,e),i=t.annotations.map(c=>{let l=ox(c,n,e);return l.docItem=o,l}),s=r?i[t.annotations.findIndex(c=>c.itemID===r.itemID)]:void 0;return o.annotations=i,{annotation:s,annotations:i,docItem:o}}var Go=class extends de{eta=this.use(bm);plugin=this.use(Ie);settings=this.use(be);app=this.use(kt.App);get vault(){return this.app.vault}get folder(){return this.settings.templateDir}get filenameTemplate(){return this.settings.simpleTemplates?.filename}get autoTrim(){return this.settings.current?.autoTrim}async loadTemplates(){let e=this.vault.getAbstractFileByPath(this.folder);if(!e)return;if(!(e instanceof kt.TFolder)){H.warn("Template folder is occupied by a file");return}let r=[];kt.Vault.recurseChildren(e,async n=>{!wt(n)||!n.path.endsWith(".eta.md")||r.push(n)}),await Promise.all(r.map(async n=>this.eta.tplFileCache.set(n,await this.vault.cachedRead(n))))}onload(){E2(this.eta),this.settings.once(async()=>{await this.loadTemplates()}),this.register(Ge(ft(()=>this.plugin.app.vault.trigger("zotero:template-updated","filename"),()=>this.filenameTemplate,!0))),this.register(Ge(ft(async()=>nn.All.forEach(e=>this.plugin.app.vault.trigger("zotero:template-updated",e)),()=>this.autoTrim,!0))),this.registerEvent(this.vault.on("create",this.onFileChange,this)),this.registerEvent(this.vault.on("modify",this.onFileChange,this)),this.registerEvent(this.vault.on("delete",async e=>{if(!wt(e))return;let r=this.fromPath(e.path);r&&(this.eta.tplFileCache.delete(e),this.vault.trigger("zotero:template-updated",r))})),this.registerEvent(this.vault.on("rename",async(e,r)=>{await this.onFileChange(e);let n=this.fromPath(r);n&&this.vault.trigger("zotero:template-updated",n)}))}async onFileChange(e){if(!wt(e))return;let r=this.fromPath(e.path);this.eta.tplFileCache.set(e,await this.vault.cachedRead(e)),this.vault.trigger("zotero:template-updated",r)}fromPath(e){let r=St(e,this.folder);return r?.type==="ejectable"?r.name:null}onFileUpdate(e){wt(e)&&this.fromPath(e.path)}onFileRename(e,r){wt(e)&&this.fromPath(e.path),this.fromPath(r)}mergeAnnotTags(e){if(e.annotations.length===0)return e;let r=ID(e.annotations,e.tags);return e.annotations=r.annotations,e.tags={...e.tags,...r.tags},e}render(e,r){try{let n=this.eta.render(e,r);return this.plugin.imgCacheImporter.flush(),n}catch(n){throw console.error("Error while rendering",e,n),n}}renderAnnot(e,r,n){n.merge!==!1&&(r=this.mergeAnnotTags(r));let o=zt(r,n,e);return this.render("annotation",o.annotation)}renderNote(e,r,n){r.merge!==!1&&(e=this.mergeAnnotTags(e));let o=zt(e,r),i=this.#e(o.docItem,n),s=this.render("note",o.docItem);return["",i,s].join(`--- +`)}renderAnnots(e,r){r.merge!==!1&&(e=this.mergeAnnotTags(e));let n=zt(e,r);return this.render("annots",n.annotations)}renderCitations(e,r,n=!1){let o=e.map(i=>zt(i,r));return this.render(n?"cite2":"cite",o.map(i=>i.docItem))}renderColored(e){return this.render("colored",e)}renderFilename(e,r){let n=zt(e,r);return this.render("filename",n.docItem)}toFrontmatterRecord(e){let r=this.render("field",e),n=!1,{yaml:o,body:i}=Gm(r);if(o)try{(0,kt.parseYaml)(o).raw===!0&&(n=!0)}catch(d){new kt.Notice(`Error parsing frontmatter, ${d}`)}let s=lr(e,!0),c=e.attachment?[e.attachment.itemID.toString()]:void 0,{[rs]:l,[ka]:f,...u}=(0,kt.parseYaml)(i);return{mode:n?"raw":"parsed",yaml:[`${rs}: ${s}`,`${ka}: ${f??c}`,i.trim(),""].join(` +`),data:{[rs]:s,[ka]:c,...Wl(u,d=>!(d===""||d===null||d===void 0))}}}renderFrontmatter(e,r,n){let o=zt(e,r);return this.#e(o.docItem,n)}#e(e,r){try{let n=this.toFrontmatterRecord(e);return n.mode==="raw"?n.yaml:(0,kt.stringifyYaml)(r!==void 0?Vi(n.data,r):n.data)}catch(n){throw gt("Failed to renderYaml",n,e),new kt.Notice("Failed to renderYaml"),n}}async setFrontmatterTo(e,r){try{let n=this.toFrontmatterRecord(r).data;await this.plugin.app.fileManager.processFrontMatter(e,o=>Object.assign(o,n))}catch(n){gt("Failed to set frontmatter to file "+e.path,n,r),new kt.Notice("Failed to set frontmatter to file "+e.path)}}};he([ge],Go.prototype,"folder",1),he([ge],Go.prototype,"filenameTemplate",1),he([ge],Go.prototype,"autoTrim",1);a();a();var nh=require("@codemirror/state"),T2=require("obsidian");var O2=t=>nh.Prec.highest(nh.EditorState.languageData.of(e=>{let r=[],n=t.getConfig("autoPairBrackets"),o=t.getConfig("autoPairMarkdown");n&&r.push("(","[","{","'",'"'),o&&r.push("*","_","`","```");let i=e.field(T2.editorInfoField);return i?.file&&Ym(i?.file)&&r.push("<","%"),[{closeBrackets:{brackets:r}}]}));a();var k2=require("obsidian");var C2=[{prefix:"=",name:"interpolate tag",description:"An interpolation outputs data into the template"},{prefix:" ",name:"evaluation tag",description:"An evaluate tag inserts its contents into the template function."}],oh=class extends k2.EditorSuggest{onTrigger(e,r,n){if(!n||!Ym(n))return null;let o=r.getLine(e.line),s=o.substring(0,e.ch).match(/<%([ =]?)$/);if(!s)return null;let[c,l]=s,f=o.substring(e.ch).match(/^([\w ]*)%>/),u;if(!f)u={...e};else{let[,d]=f;if(l===" "&&d.length===1)return null;u={...e,ch:e.ch+d.length}}return{end:u,start:{ch:s.index+c.length-l.length,line:e.line},query:s[1]}}getSuggestions(e){return e.query?C2.filter(r=>r.prefix===e.query):C2}renderSuggestion({prefix:e,name:r,description:n},o){e===" "?o.createSpan({text:"No Prefix"}):o.createEl("code",{text:e}),o.createDiv({text:r}),o.createDiv({text:n})}selectSuggestion({prefix:e},r){if(!this.context)return;let{editor:n,end:o,start:i}=this.context,s=e===" "?" ":"= it. ";n.transaction({changes:[{from:i,to:o,text:s}],selection:{from:{...i,ch:i.ch+s.length-1}}})}};var Aa=class extends de{#e=null;plugin=this.use(Ie);settings=this.use(be);#t(){this.plugin.registerEditorSuggest(new oh(this.plugin.app))}get etaBracketPairing(){return this.settings.current?.autoPairEta}#n(e){let r=this.#e!==null;this.#e===null?(this.#e=[],this.plugin.registerEditorExtension(this.#e)):this.#e.length=0,e&&this.#e.push(O2(this.plugin.app.vault)),r&&this.plugin.app.workspace.updateOptions()}onload(){this.#t(),this.register(Ge(ft(()=>this.#n(this.etaBracketPairing),()=>this.etaBracketPairing)))}};he([ge],Aa.prototype,"etaBracketPairing",1);a();var px=t=>{let e=t?.frontmatter?.[rs];return e&&typeof e=="string"&&$S.test(e)?e:null},ns=(t,e)=>{if(!t)return null;let r=typeof t=="string"?e.getCache(t):t instanceof fx.TFile?e.getFileCache(t):null;return px(r)},os=(t,e)=>{if(!t)return null;let n=(typeof t=="string"?e.getCache(t):t instanceof fx.TFile?e.getFileCache(t):null)?.frontmatter?.[ka];if(n&&Array.isArray(n)&&n.length>0){let o=[];for(let i of n)if(typeof i=="string"){let s=Number(i);if(!(s>0&&Number.isInteger(s)))return null;o.push(s)}else if(typeof i=="number"){if(!(i>0&&Number.isInteger(i)))return null;o.push(i)}return o}return null},hu=({id:t})=>!!t&&jS.test(t),gu=t=>t.split("n").map(e=>{let[,r,,n]=e.split("p")[0].match(LS);return lr({key:r,groupID:n?+n:void 0},!0)});function yu(t,e){let r=SD(t);return!!ns(r,e.metadataCache)}a();var Jq=require("url");a();a();_();var Zo=Ve({});a();a();_();var Je=Ve({});a();a();a();_();a();var A2=function(t){return typeof t=="function"};a();var gee=!1,R2=gee;function yee(t){R2&&(A2(t)||console.error("useMemoizedFn expected parameter is a function, got ".concat(typeof t)));var e=$(t);e.current=ae(function(){return t},[t]);var r=$();return r.current||(r.current=function(){for(var n=[],o=0;o{let e,r=new Set,n=(l,f)=>{let u=typeof l=="function"?l(e):l;if(!Object.is(u,e)){let d=e;e=f??typeof u!="object"?u:Object.assign({},e,u),r.forEach(m=>m(e,d))}},o=()=>e,c={setState:n,getState:o,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(P2.env&&P2.env.MODE)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}};return e=t(n,o,c),c},bu=t=>t?D2(t):D2;_();var U2=Y(z2(),1);var{useSyncExternalStoreWithSelector:$ee}=U2.default;function Ut(t,e=t.getState,r){let n=$ee(t.subscribe,t.getState,t.getServerState||t.getState,e,r);return Ci(n),n}a();function Na(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(let[n,o]of t)if(!Object.is(o,e.get(n)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(let n of t)if(!e.has(n))return!1;return!0}let r=Object.keys(t);if(r.length!==Object.keys(e).length)return!1;for(let n=0;nt&&(e=0,n=r,r=new Map)}return{get:function(s){var c=r.get(s);if(c!==void 0)return c;if((c=n.get(s))!==void 0)return o(s,c),c},set:function(s,c){r.has(s)?r.set(s,c):o(s,c)}}}a();var yx="!";function Y2(t){var e=t.separator||":";return function(n){for(var o=0,i=[],s=0,c=0;c{t.forEach(r=>{typeof r=="function"?r(e):r!=null&&(r.current=e)})}}var lh=(t,e)=>{let{setIcon:r}=ne(Zo),n=$(null);return ee(i=>{n.current&&Yee.call(n.current),i&&(r(i,t),e&&i.firstElementChild instanceof SVGSVGElement&&i.firstElementChild.style.setProperty("--icon-size",typeof e=="number"||!Number.isNaN(Number(e))?`${e}px`:e)),n.current=i},[t,e,r])};function Yee(){for(;this.lastChild;)this.removeChild(this.lastChild)}var Yo=yt(Q(function({icon:e,size:r,className:n,...o},i){let s=lh(e,r),c=ch(s,i);return g("div",{ref:c,className:oe("zt-icon",n),...o})}));a();_();var ss=Q(function({onClick:e,onKeyDown:r,className:n,...o},i){return g(Yo,{onClick:e,onKeyDown:r??e,className:oe("clickable-icon",n),...o,ref:i,role:"button",tabIndex:0})});a();_();a();_();var uL=yt(Q(function({icon:e,...r},n){let o=lh(e);return g("button",{ref:ch(o,n),...r})}));var as=Q(function({className:e,active:r=!1,...n},o){return g(uL,{...n,ref:o,className:oe("clickable-icon",{"is-active":r},e)})});function vu(t){return g(ss,{size:16,icon:"info","aria-label":"Show details",...t})}a();a();a();a();function wu(){let t=arguments[0];for(let e=1,r=arguments.length;eo(e).replace(/<\/?b>/g,"**").replace(/<\/?i>/g,"*"),[e,o]);return g("div",{className:oe("annot-comment select-text overflow-x-auto break-words px-2 py-1",r),...n,children:i(s)})});a();_();var pL=Q(function({className:e,...r},n){return g("div",{ref:n,className:oe("annot-excerpt",e),...r})});a();_();a();function vx({text:t,pageLabel:e,className:r,collapsed:n=!1,...o}){let i=t??`Area Excerpt for Page ${e??"?"}`;return g("img",{className:oe("w-full",n?"max-h-20 object-cover object-left-top":"object-scale-down",r),alt:i,...o})}var dL=yt(function({type:e,text:r,pageLabel:n,imgSrc:o,collapsed:i}){switch(e){case Ne.highlight:case Ne.underline:case Ne.text:return g("p",{className:"select-text",children:r});case Ne.image:if(!o)throw new Error("imgSrc is required for image annotation");return g(vx,{collapsed:i,src:o,pageLabel:n,text:r});default:return g(L,{children:["Unsupported Type: ",Ne[e]??e]})}});a();function wx({checkbox:t,drag:e,buttons:r,onMoreOptions:n,className:o,children:i,onContextMenu:s,...c}){return g("div",{className:oe("annot-header flex cursor-context-menu items-center gap-1",o),onContextMenu:s??n,...c,children:[t,g("div",{className:"annot-header-drag-container flex flex-row items-center gap-1",children:e}),g("div",{className:"annot-header-buttons-container flex flex-row items-center gap-1 opacity-0 transition-opacity hover:opacity-100",children:r}),g("div",{className:"annot-header-space flex-1"}),i]})}a();a();a();a();a();a();a();var Xee=typeof global=="object"&&global&&global.Object===Object&&global,mL=Xee;var Qee=typeof self=="object"&&self&&self.Object===Object&&self,ete=mL||Qee||Function("return this")(),hL=ete;var tte=hL.Symbol,to=tte;a();var gL=Object.prototype,rte=gL.hasOwnProperty,nte=gL.toString,xu=to?to.toStringTag:void 0;function ote(t){var e=rte.call(t,xu),r=t[xu];try{t[xu]=void 0;var n=!0}catch{}var o=nte.call(t);return n&&(e?t[xu]=r:delete t[xu]),o}var yL=ote;a();var ite=Object.prototype,ste=ite.toString;function ate(t){return ste.call(t)}var bL=ate;var cte="[object Null]",lte="[object Undefined]",vL=to?to.toStringTag:void 0;function ute(t){return t==null?t===void 0?lte:cte:vL&&vL in Object(t)?yL(t):bL(t)}var wL=ute;a();function fte(t){return t!=null&&typeof t=="object"}var xL=fte;var pte="[object Symbol]";function dte(t){return typeof t=="symbol"||xL(t)&&wL(t)==pte}var EL=dte;a();a();function mte(t,e){for(var r=-1,n=t==null?0:t.length,o=Array(n);++ro?0:o+e),r=r>o?o:r,r<0&&(r+=o),o=e>r?0:r-e>>>0,e>>>=0;for(var i=Array(o);++n=n?t:kL(t,e,r)}var AL=vte;a();var wte="\\ud800-\\udfff",xte="\\u0300-\\u036f",Ete="\\ufe20-\\ufe2f",Ste="\\u20d0-\\u20ff",Ite=xte+Ete+Ste,_te="\\ufe0e\\ufe0f",Tte="\\u200d",Ote=RegExp("["+Tte+wte+Ite+_te+"]");function Cte(t){return Ote.test(t)}var uh=Cte;a();a();function kte(t){return t.split("")}var RL=kte;a();var NL="\\ud800-\\udfff",Ate="\\u0300-\\u036f",Rte="\\ufe20-\\ufe2f",Nte="\\u20d0-\\u20ff",Dte=Ate+Rte+Nte,Pte="\\ufe0e\\ufe0f",Fte="["+NL+"]",xx="["+Dte+"]",Ex="\\ud83c[\\udffb-\\udfff]",Mte="(?:"+xx+"|"+Ex+")",DL="[^"+NL+"]",PL="(?:\\ud83c[\\udde6-\\uddff]){2}",FL="[\\ud800-\\udbff][\\udc00-\\udfff]",$te="\\u200d",ML=Mte+"?",$L="["+Pte+"]?",Lte="(?:"+$te+"(?:"+[DL,PL,FL].join("|")+")"+$L+ML+")*",jte=$L+ML+Lte,qte="(?:"+[DL+xx+"?",xx,PL,FL,Fte].join("|")+")",Bte=RegExp(Ex+"(?="+Ex+")|"+qte+jte,"g");function zte(t){return t.match(Bte)||[]}var LL=zte;function Ute(t){return uh(t)?LL(t):RL(t)}var jL=Ute;function Wte(t){return function(e){e=Ma(e);var r=uh(e)?jL(e):void 0,n=r?r[0]:e.charAt(0),o=r?AL(r,1).join(""):e.slice(1);return n[t]()+o}}var qL=Wte;var Hte=qL("toUpperCase"),BL=Hte;a();a();function Kte(t,e,r,n){var o=-1,i=t==null?0:t.length;for(n&&i&&(r=t[++o]);++o{switch(t){case Ne.highlight:return"align-left";case Ne.underline:return"underline";case Ne.image:return"frame";case Ne.text:return"text-select";case Ne.note:case Ne.ink:default:return"file-question"}};a();_();var gj=t=>{let{annotRenderer:e,store:r}=ne(Je),n=Ut(r,e.storeSelector,Na);return e.get(t,n)};a();_();var yj=t=>{let{getImgSrc:e}=ne(Je);return ae(()=>e(t),[t,e])};a();function Ix({className:t,...e}){return g(ss,{icon:"more-vertical",className:oe("annot-header-more-options",t),"aria-label":"More options",size:"0.9rem","aria-label-delay":"50",...e})}a();_();var bj=yt(function({pageLabel:e,backlink:r,className:n,...o}){let i=e?`Page ${e}`:"";return r?g("a",{className:oe("annot-page","external-link","bg-[length:12px] bg-[center_right_3px] pr-[18px] text-xs",n),href:r,"aria-label":`Open annotation in Zotero at page ${e}`,"aria-label-delay":"500",...o,children:i}):g("span",{className:oe("annot-page",n),children:i})});a();_();function _x({tags:t}){return t.length===0?null:g("div",{className:"annot-tags-container",children:t.map(e=>g(Mre,{...e},e.tagID))})}var Mre=yt(function({name:e}){return g("a",{className:oe("tag","annot-tag"),children:e})});function Tx({collapsed:t=!1,annotation:e,checkbox:r,tags:n,className:o,...i}){let s=$(null),{onMoreOptions:c,onDragStart:l,onShowDetails:f}=ne(Je),u=L0.selectKeys(e,["type","text","pageLabel"]),d=gj(e),m=Vr(y=>c(y,e)),h=Vr(()=>f("annot",e.itemID));return g("div",{className:oe("annot-preview","bg-primary shadow-border col-span-1 flex flex-col divide-y overflow-auto rounded-sm transition-colors",o),"data-id":e.itemID,...i,children:[g(wx,{className:"bg-primary-alt py-1 pl-2 pr-1",checkbox:r,drag:g(mj,{type:e.type,color:e.color,icon:hj(e.type),draggable:d!==null,onDragStart:Vr(y=>d&&l(y,d,s.current)),size:16}),buttons:g(L,{children:[g(vu,{className:"p-0.5",size:14,onClick:h}),g(Ix,{className:"p-0",onClick:m})]}),onMoreOptions:m,children:g(bj,{pageLabel:e.pageLabel,backlink:Uo(e)})}),g(pL,{ref:s,className:"px-2 py-1",children:g("blockquote",{className:oe("border-l-blockquote pl-2 leading-tight",{"line-clamp-3":t}),style:{borderColor:e.color??"var(--interactive-accent)"},children:g(dL,{...u,collapsed:t,imgSrc:yj(e)})})}),e.comment&&g(fL,{content:e.comment}),n&&g(_x,{tags:n})]})}function Ox({selectable:t=!1,collapsed:e,annotations:r,getTags:n}){let[o,{add:i,remove:s}]=dx();return g("div",{role:"list",className:"@md:grid-cols-2 @md:gap-3 @3xl:grid-cols-4 grid grid-cols-1 gap-2",children:r.map(c=>g(Tx,{checkbox:t&&g($re,{checked:o.has(c.itemID),onChange:l=>l?i(c.itemID):s(c.itemID)}),collapsed:e,role:"listitem",annotation:c,tags:n(c.itemID)},c.itemID))})}function $re({checked:t,onChange:e}){return g("div",{className:"flex h-5 items-center",children:g("input",{type:"checkbox",className:"m-0 h-4 w-4",checked:t,onChange:r=>e(r.target.checked)})})}a();_();var Lre=()=>Ut(ne(Je).store,t=>({attachments:t.allAttachments,onChange:t.setActiveAtch,value:t.attachmentID}),Na);function Cx(){let{attachments:t,onChange:e,value:r}=Lre();return t?t.length===1?null:t.length<=0?g("span",{className:"atch-select-empty",children:"No attachments available"}):g("select",{className:"atch-select",onChange:n=>e(parseInt(n.target.value,10)),value:r??void 0,children:t.map(({itemID:n,path:o,annotCount:i})=>g("option",{value:n,children:["(",i,") ",o?.replace(/^storage:/,"")]},n))}):g(L,{children:"Loading"})}a();function kx({isCollapsed:t,...e}){return g(as,{...e,icon:t?"chevrons-up-down":"chevrons-down-up","aria-label":t?"Expand":"Collapse"})}a();_();function fh(t){let{store:e,onSetFollow:r}=ne(Je),n=Ut(e,s=>s.follow),o=n===null?"not following":n==="ob-note"?"active literature note":"active literature in Zotero reader";return g(L,{children:[g(as,{...t,onClick:r,icon:n===null?"unlink":"link","aria-label":"Choose follow mode"+(n===null?" (Currently linked with literature)":""),"aria-label-delay":"50"}),n!==null&&g("span",{className:"ml-1","aria-label":`Following ${o}`,children:n==="ob-note"?"ob":"zt"})]})}a();function ph({children:t,buttons:e}){return g("div",{className:"nav-header",children:[g("div",{className:"nav-buttons-container",children:e}),t]})}a();function Ax(t){return g(as,{...t,icon:"refresh-ccw","aria-label":"Refresh annotation list","aria-label-delay":"50"})}var jre=()=>{let{registerDbUpdate:t,store:e}=ne(Je),r=Ut(e,n=>n.refresh);K(()=>t(r),[t,r])};function Eu(){jre();let{store:t}=ne(Je),e=Ut(t,r=>r.doc);return e?g(qre,{docItem:e.docItem}):g(L,{children:[g(ph,{buttons:g(fh,{})}),g("div",{className:"pane-empty p-2",children:"Active file not literature note"})]})}function qre({docItem:t}){let{refreshConn:e,onShowDetails:r}=ne(Je),[n,{toggle:o}]=ih(!1),i=Bre();return g(L,{children:[g(ph,{buttons:g(L,{children:[g(vu,{className:"nav-action-button",onClick:Vr(()=>r("doc-item",t.itemID))}),g(kx,{className:"nav-action-button",isCollapsed:n,onClick:o}),g(Ax,{className:"nav-action-button",onClick:e}),g(fh,{})]}),children:g(Cx,{})}),g("div",{className:oe("annots-container @container","overflow-auto px-3 pt-1 pb-8 text-xs"),children:i?g(Ox,{collapsed:n,...i}):g(L,{children:"Loading"})})]})}var Bre=()=>Ut(ne(Je).store,t=>!t.doc||!t.annotations||!t.attachment?null:{annotations:t.annotations,getTags:e=>t.tags[e]??[]},Na);a();_();a();a();a();a();function me(){return me=Object.assign?Object.assign.bind():function(t){for(var e=1;e=0)&&(r[o]=t[o]);return r}a();a();function dh(t,e=166){let r;function n(...o){let i=()=>{t.apply(this,o)};clearTimeout(r),r=setTimeout(i,e)}return n.clear=()=>{clearTimeout(r)},n}a();function Nx(t){return t&&t.ownerDocument||document}a();function Su(t){return Nx(t).defaultView||window}a();function Dx(t,e){typeof t=="function"?t(e):t&&(t.current=e)}a();_();var zre=typeof window<"u"?Lt:K,Px=zre;a();_();function mh(...t){return ae(()=>t.every(e=>e==null)?null:e=>{t.forEach(r=>{Dx(r,e)})},t)}a();a();_();_();var Ure=["onChange","maxRows","minRows","style","value"];function hh(t){return parseInt(t,10)||0}var Wre={shadow:{visibility:"hidden",position:"absolute",overflow:"hidden",height:0,top:0,left:0,transform:"translateZ(0)"}};function vj(t){return t==null||Object.keys(t).length===0||t.outerHeightStyle===0&&!t.overflow}var Hre=Q(function(e,r){let{onChange:n,maxRows:o,minRows:i=1,style:s,value:c}=e,l=Rx(e,Ure),{current:f}=$(c!=null),u=$(null),d=mh(r,u),m=$(null),h=$(0),[y,w]=q({outerHeightStyle:0}),v=ee(()=>{let Z=u.current,J=Su(Z).getComputedStyle(Z);if(J.width==="0px")return{outerHeightStyle:0};let G=m.current;G.style.width=J.width,G.value=Z.value||e.placeholder||"x",G.value.slice(-1)===` +`&&(G.value+=" ");let M=J.boxSizing,te=hh(J.paddingBottom)+hh(J.paddingTop),C=hh(J.borderBottomWidth)+hh(J.borderTopWidth),O=G.scrollHeight;G.value="x";let T=G.scrollHeight,U=O;i&&(U=Math.max(Number(i)*T,U)),o&&(U=Math.min(Number(o)*T,U)),U=Math.max(U,T);let F=U+(M==="border-box"?te+C:0),se=Math.abs(U-O)<=1;return{outerHeightStyle:F,overflow:se}},[o,i,e.placeholder]),x=(Z,X)=>{let{outerHeightStyle:J,overflow:G}=X;return h.current<20&&(J>0&&Math.abs((Z.outerHeightStyle||0)-J)>1||Z.overflow!==G)?(h.current+=1,{overflow:G,outerHeightStyle:J}):Z},S=ee(()=>{let Z=v();vj(Z)||w(X=>x(X,Z))},[v]),k=()=>{let Z=v();vj(Z)||fn(()=>{w(X=>x(X,Z))})};return K(()=>{let Z=dh(()=>{h.current=0,u.current&&k()}),X,J=u.current,G=Su(J);return G.addEventListener("resize",Z),typeof ResizeObserver<"u"&&(X=new ResizeObserver(Z),X.observe(J)),()=>{Z.clear(),G.removeEventListener("resize",Z),X&&X.disconnect()}}),Px(()=>{S()}),K(()=>{h.current=0},[c]),g(L,{children:[g("textarea",me({value:c,onChange:Z=>{h.current=0,f||S(),n&&n(Z)},ref:d,rows:i,style:me({height:y.outerHeightStyle,overflow:y.overflow?"hidden":void 0},s)},l)),g("textarea",{"aria-hidden":!0,className:e.className,readOnly:!0,ref:m,tabIndex:-1,style:me({},Wre.shadow,s,{padding:0})})]})}),Iu=Hre;_();a();_();a();a();_();a();_();function Kre(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function Fx(...t){return e=>t.forEach(r=>Kre(r,e))}function gh(...t){return ee(Fx(...t),t)}a();_();function wj(t,e=[]){let r=[];function n(i,s){let c=Ve(s),l=r.length;r=[...r,s];function f(d){let{scope:m,children:h,...y}=d,w=m?.[t][l]||c,v=ae(()=>y,Object.values(y));return V(w.Provider,{value:v},h)}function u(d,m){let h=m?.[t][l]||c,y=ne(h);if(y)return y;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return f.displayName=i+"Provider",[f,u]}let o=()=>{let i=r.map(s=>Ve(s));return function(c){let l=c?.[t]||i;return ae(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])}};return o.scopeName=t,[n,Vre(o,...e)]}function Vre(...t){let e=t[0];if(t.length===1)return e;let r=()=>{let n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){let s=n.reduce((c,{useScope:l,scopeName:f})=>{let d=l(i)[`__scope${f}`];return{...c,...d}},{});return ae(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return r.scopeName=e.scopeName,r}a();function Wt(t,e,{checkForDefaultPrevented:r=!0}={}){return function(o){if(t?.(o),r===!1||!o.defaultPrevented)return e?.(o)}}a();_();a();_();function Mx(t){let e=$(t);return K(()=>{e.current=t}),ae(()=>(...r)=>{var n;return(n=e.current)===null||n===void 0?void 0:n.call(e,...r)},[])}function xj({prop:t,defaultProp:e,onChange:r=()=>{}}){let[n,o]=Gre({defaultProp:e,onChange:r}),i=t!==void 0,s=i?t:n,c=Mx(r),l=ee(f=>{if(i){let d=typeof f=="function"?f(t):f;d!==t&&c(d)}else o(f)},[i,t,o,c]);return[s,l]}function Gre({defaultProp:t,onChange:e}){let r=q(t),[n]=r,o=$(n),i=Mx(e);return K(()=>{o.current!==n&&(i(n),o.current=n)},[n,o,i]),r}a();_();function Ej(t){let e=$({value:t,previous:t});return ae(()=>(e.current.value!==t&&(e.current.previous=e.current.value,e.current.value=t),e.current.previous),[t])}a();_();a();_();var _u=globalThis?.document?Lt:()=>{};function Sj(t){let[e,r]=q(void 0);return _u(()=>{if(t){r({width:t.offsetWidth,height:t.offsetHeight});let n=new ResizeObserver(o=>{if(!Array.isArray(o)||!o.length)return;let i=o[0],s,c;if("borderBoxSize"in i){let l=i.borderBoxSize,f=Array.isArray(l)?l[0]:l;s=f.inlineSize,c=f.blockSize}else s=t.offsetWidth,c=t.offsetHeight;r({width:s,height:c})});return n.observe(t,{box:"border-box"}),()=>n.unobserve(t)}else r(void 0)},[t]),e}a();_();_();function Zre(t,e){return un((r,n)=>{let o=e[r][n];return o??r},t)}var $x=t=>{let{present:e,children:r}=t,n=Jre(e),o=typeof r=="function"?r({present:n.isPresent}):rt.only(r),i=gh(n.ref,o.ref);return typeof r=="function"||n.isPresent?wr(o,{ref:i}):null};$x.displayName="Presence";function Jre(t){let[e,r]=q(),n=$({}),o=$(t),i=$("none"),s=t?"mounted":"unmounted",[c,l]=Zre(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return K(()=>{let f=yh(n.current);i.current=c==="mounted"?f:"none"},[c]),_u(()=>{let f=n.current,u=o.current;if(u!==t){let m=i.current,h=yh(f);t?l("MOUNT"):h==="none"||f?.display==="none"?l("UNMOUNT"):l(u&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),_u(()=>{if(e){let f=d=>{let h=yh(n.current).includes(d.animationName);d.target===e&&h&&fn(()=>l("ANIMATION_END"))},u=d=>{d.target===e&&(i.current=yh(n.current))};return e.addEventListener("animationstart",u),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{e.removeEventListener("animationstart",u),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:ee(f=>{f&&(n.current=getComputedStyle(f)),r(f)},[])}}function yh(t){return t?.animationName||"none"}a();_();_();a();_();var jx=Q((t,e)=>{let{children:r,...n}=t,o=rt.toArray(r),i=o.find(Xre);if(i){let s=i.props.children,c=o.map(l=>l===i?rt.count(s)>1?rt.only(null):Qt(s)?s.props.children:null:l);return V(Lx,me({},n,{ref:e}),Qt(s)?wr(s,void 0,c):null)}return V(Lx,me({},n,{ref:e}),r)});jx.displayName="Slot";var Lx=Q((t,e)=>{let{children:r,...n}=t;return Qt(r)?wr(r,{...Qre(n,r.props),ref:Fx(e,r.ref)}):rt.count(r)>1?rt.only(null):null});Lx.displayName="SlotClone";var Yre=({children:t})=>V(L,null,t);function Xre(t){return Qt(t)&&t.type===Yre}function Qre(t,e){let r={...e};for(let n in e){let o=t[n],i=e[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...c)=>{i(...c),o(...c)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...t,...r}}var ene=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],qx=ene.reduce((t,e)=>{let r=Q((n,o)=>{let{asChild:i,...s}=n,c=i?jx:e;return K(()=>{window[Symbol.for("radix-ui")]=!0},[]),V(c,me({},s,{ref:o}))});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});var Ij="Checkbox",[tne,z6e]=wj(Ij),[rne,nne]=tne(Ij),one=Q((t,e)=>{let{__scopeCheckbox:r,name:n,checked:o,defaultChecked:i,required:s,disabled:c,value:l="on",onCheckedChange:f,...u}=t,[d,m]=q(null),h=gh(e,k=>m(k)),y=$(!1),w=d?!!d.closest("form"):!0,[v=!1,x]=xj({prop:o,defaultProp:i,onChange:f}),S=$(v);return K(()=>{let k=d?.form;if(k){let j=()=>x(S.current);return k.addEventListener("reset",j),()=>k.removeEventListener("reset",j)}},[d,x]),V(rne,{scope:r,state:v,disabled:c},V(qx.button,me({type:"button",role:"checkbox","aria-checked":cs(v)?"mixed":v,"aria-required":s,"data-state":_j(v),"data-disabled":c?"":void 0,disabled:c,value:l},u,{ref:h,onKeyDown:Wt(t.onKeyDown,k=>{k.key==="Enter"&&k.preventDefault()}),onClick:Wt(t.onClick,k=>{x(j=>cs(j)?!0:!j),w&&(y.current=k.isPropagationStopped(),y.current||k.stopPropagation())})})),w&&V(ane,{control:d,bubbles:!y.current,name:n,value:l,checked:v,required:s,disabled:c,style:{transform:"translateX(-100%)"}}))}),ine="CheckboxIndicator",sne=Q((t,e)=>{let{__scopeCheckbox:r,forceMount:n,...o}=t,i=nne(ine,r);return V($x,{present:n||cs(i.state)||i.state===!0},V(qx.span,me({"data-state":_j(i.state),"data-disabled":i.disabled?"":void 0},o,{ref:e,style:{pointerEvents:"none",...t.style}})))}),ane=t=>{let{control:e,checked:r,bubbles:n=!0,...o}=t,i=$(null),s=Ej(r),c=Sj(e);return K(()=>{let l=i.current,f=window.HTMLInputElement.prototype,d=Object.getOwnPropertyDescriptor(f,"checked").set;if(s!==r&&d){let m=new Event("click",{bubbles:n});l.indeterminate=cs(r),d.call(l,cs(r)?!1:r),l.dispatchEvent(m)}},[s,r,n]),V("input",me({type:"checkbox","aria-hidden":!0,defaultChecked:cs(r)?!1:r},o,{tabIndex:-1,ref:i,style:{...t.style,...c,position:"absolute",pointerEvents:"none",opacity:0,margin:0}}))};function cs(t){return t==="indeterminate"}function _j(t){return cs(t)?"indeterminate":t?"checked":"unchecked"}var Bx=one,Tj=sne;_();var zx=Q(({className:t,checked:e,...r},n)=>g(Bx,{ref:n,className:oe("data-[state=checked]:text-mod-error peer h-3 w-3 shrink-0 rounded-sm border disabled:cursor-not-allowed disabled:opacity-50 bg-primary obzt-btn-reset",t),checked:e,...r,children:g(Tj,{className:oe("flex items-center justify-center"),children:g(Yo,{icon:"chevrons-down",size:"0.75rem",className:"contents"})})}));zx.displayName=Bx.displayName;var Oj=Q(({id:t,checked:e,onCheckChange:r,title:n,disabled:o,className:i,...s},c)=>g("div",{className:oe("flex items-center gap-x-1","rounded-sm focus-within:outline-none focus-within:ring-2 focus-within:ring-mod-border-focus focus-within:ring-offset-2",e&&"animate-pulse",i),ref:c,...s,children:[g(zx,{className:oe("h-3 w-3",o&&"hidden"),id:t,checked:e,disabled:o,onCheckedChange:r}),g("label",{htmlFor:t,className:"peer-[[data-state=checked]]:text-mod-error text-status-bar text-txt-status-bar leading-none peer-disabled:cursor-not-allowed",children:n})]}));Oj.displayName="ImportingStatus";var Sg=require("obsidian");_();a();var La=require("obsidian");_();var Cj={sanitize:DOMPurify.sanitize.bind(DOMPurify),setIcon:La.setIcon,renderMarkdown(t){return g(lne,{content:t})}};function lne({content:t}){let e=$(null);return g("div",{className:"contents",ref:n=>{n?(n.empty(),e.current&&e.current.unload(),e.current=new La.Component,La.MarkdownRenderer.renderMarkdown(t,n,"",e.current)):e.current&&(e.current.unload(),e.current=null)}})}a();var ls=require("obsidian"),bh=class extends ls.FileView{constructor(e){super(e),this.navigation=!1,this.allowNoFile=!0,this.requestUpdate=(0,ls.debounce)(()=>this.update(),10)}load(){super.load(),this.registerEvent(this.app.workspace.on("file-open",this.onFileOpen,this))}async setState(e,r){if(!Object.hasOwn(e,"file")&&!Object.hasOwn(e,"group")){let n=this.leaf.workspace.getActiveFile();n&&(e.file=n?.path)}await super.setState(e,r)}onLoadFile(e){return this.requestUpdate()}onUnloadFile(e){return this.requestUpdate()}onFileOpen(e){this.leaf.group||this.leaf.pinned||(e instanceof ls.TFile?this.loadFile(e):this.loadFile(null),this.requestUpdate())}onGroupChange(){if(super.onGroupChange(),this.leaf.group)for(let e=0,r=this.leaf.workspace.getGroupLeaves(this.leaf.group);etypeof t=="string"&&t.trim().length>0?await e.database.search(t):await e.database.getItemsOf(50);function Eh({item:t,fields:e},r){r.addClass("mod-complex");let n=r.createDiv("suggestion-content").createDiv("suggestion-title").createSpan(),o=r.createDiv("suggestion-aux");for(let c of e){let l=o.createEl("kbd","suggestion-hotkey");switch(l.setAttribute("aria-label",c),c){case"title":(0,vh.setIcon)(l,"type");break;case"creators":(0,vh.setIcon)(l,"user");break;case"date":(0,vh.setIcon)(l,"calendar");break;default:l.setText(c);break}}let[i]=t.title??[],s=n.createDiv({cls:"title"});typeof i=="string"&&i?s.setText(i):s.setText("Title missing"),this.plugin.settings.current?.showCitekeyInSuggester&&t.citekey&&n.createDiv({cls:"citekey",text:t.citekey}),une(t)&&n.append(fne(t))}var une=t=>t.itemType==="journalArticle",fne=t=>{let{creators:e,date:r,publicationTitle:n,volume:o,issue:i,pages:s}=t,c={creators:pne(e),date:r,publication:n,volume:o,issue:i,pages:s},l=(f,u,d)=>c[u]&&f.createSpan({cls:d??u,text:c[u]??void 0});return createDiv({cls:"meta"},f=>{(c.creators||c.date)&&f.createSpan({cls:"author-year"},u=>{l(u,"creators"),l(u,"date")}),l(f,"publication"),(c.volume||c.issue)&&f.createSpan({cls:"vol-issue"},u=>{l(u,"volume"),l(u,"issue")}),l(f,"pages")})},pne=t=>{if(!t||!t[0])return"";let e=t[0],r=cm(e)||lm(e)?e.lastName:"";return t.length>1&&(r=r.trim()+" et al."),r};var Tu=class extends kj.EditorSuggest{constructor(r){super(r.app);this.plugin=r;this.suggestEl.addClass(wh)}getSuggestions(r){return xh(r.query,this.plugin)}renderSuggestion=Eh.bind(this)};a();var ro=class extends um{constructor(r){super(r.app);this.plugin=r;this.modalEl.addClass(wh)}getSuggestions(r){return xh(r,this.plugin)}renderSuggestion=Eh.bind(this);onChooseSuggestion(){}};a();var Nj=require("obsidian");a();var Aj=require("@codemirror/state");async function Rj(t,e,r=e.settings.current?.updateOverwrite){let{app:n,noteIndex:o,templateRenderer:i}=e,s=o.getNotesFor(t);if(s.length===0)return null;let c=e.settings.libId,l=await e.databaseAPI.getAttachments(t.itemID,c),f=new Set(s.flatMap(v=>os(v,e.app.metadataCache))),u=l.filter(v=>f.has(v.itemID)),d;u.length===0&&(d=await Zn(l,e.app),d&&(Ea(d,t),u.push(d)));let m=await e.databaseAPI.getNotes(t.itemID,c).then(v=>e.noteParser.normalizeNotes(v)),h=await Ou(t,{all:l,selected:u,notes:m},e),y=Object.values(h)[0],w={notes:s.length,addedAnnots:0,updatedAnnots:0};for(let v of s){let x=n.metadataCache.getCache(v);if(!x)continue;let S=os(v,e.app.metadataCache);S||(d===void 0&&(d=await Zn(u,e.app)),d?S=[d.itemID]:S=[]);let k=n.vault.getAbstractFileByPath(v),j={plugin:e,sourcePath:v};if(r){let O=await i.renderNote(h[S[0]],j);await n.vault.modify(k,O);continue}let Z=wu((x.sections?.filter(hu)??[]).flatMap(O=>gu(O.id).map(T=>[T,O.position])),Ki(([O])=>O),xa((O,T)=>({key:O,blocks:T.map(([U,F])=>F)}))),X=new Set(Object.values(x.blocks??{})?.filter(hu).flatMap(O=>gu(O.id).map(T=>T))),J=new Map(S.map(O=>[h[O],[]])),G=[];if(await Promise.all(S.map(async O=>{let T=h[O];if(!(!T.annotations||T.annotations.length===0))return await Promise.all(T.annotations.map(async U=>{let F=lr(U,!0),se=Z[F];if(se){if(!e.settings.current?.updateAnnotBlock)return;let ce=await i.renderAnnot(U,T,j);G.push(...se.blocks.map(xe=>({from:xe.start.offset,to:xe.end.offset,insert:ce})))}else X.has(F)||J.get(T).push(U)})??[])})),G.length>0){let O=Aj.EditorState.create({doc:await n.vault.read(k)}).update({changes:G}).state.doc.toString();await n.vault.modify(k,O)}await i.setFrontmatterTo(k,zt(y,j).docItem);let M=[...J].reduce((O,[T,U])=>{if(U.length===0)return O;let F=i.renderAnnots({...T,annotations:U},j);return(O&&O+` +`)+F},"");M&&await n.vault.append(k,M);let te=G.length,C=[...J.values()].reduce((O,T)=>O+T.length,0);w.updatedAnnots+=te,w.addedAnnots+=C}return w}async function Ou(t,{all:e,selected:r,notes:n},o){let i=o.settings.libId,s=await o.databaseAPI.getTags([[t.itemID,i]]);if(r.length===0)return{[-1]:{docItem:t,attachment:null,tags:s,allAttachments:e,annotations:[],notes:n}};let c={};for(let l of r){let f=l?await o.databaseAPI.getAnnotations(l.itemID,i):[];c[l.itemID]={docItem:t,attachment:l,tags:{...s,...await o.databaseAPI.getTags(f.map(u=>[u.itemID,i]))},allAttachments:e,annotations:f,notes:n}}return c}async function Sh({alt:t,item:e},{start:r,end:n,editor:o,file:i},s){let{plugin:c}=s,l=c.settings.libId,f=await c.databaseAPI.getAttachments(e.itemID,l),u=new Set(os(i,c.app.metadataCache)),d=f.filter(v=>u.has(v.itemID)),m;d.length===0&&(m=await Zn(f,c.app),m&&(Ea(m,e),d.push(m)));let h=await c.databaseAPI.getNotes(e.itemID,l).then(v=>c.noteParser.normalizeNotes(v)),y=await Ou(e,{all:f,selected:d,notes:h},s.plugin),w=s.renderCitations(Object.values(y),{plugin:s.plugin},t);o.replaceRange(w,r,n),o.setCursor(o.offsetToPos(o.posToOffset(r)+w.length))}var Dj=t=>Nj.Keymap.isModifier(t,"Shift");var dne=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to insert primary Markdown citation"},{command:"\u21B5 (end with /)",purpose:"Insert secondary Markdown citation"}],Cu=class extends Tu{constructor(r){super(r);this.plugin=r;this.setInstructions(dne)}onTrigger(r,n){if(!this.plugin.settings.current?.citationEditorSuggester)return null;let o=n.getLine(r.line),s=o.substring(0,r.ch).match(/[[【]@([^\]】]*)$/);if(!s)return null;let c={...r};return(o[r.ch]==="]"||o[r.ch]==="\u3011")&&(c.ch+=1),{end:c,start:{ch:s.index,line:r.line,alt:!!s[0]?.endsWith("/")},query:s[1].replaceAll(/\/$/g,"")}}selectSuggestion(r){this.context&&Sh({item:r.item,alt:this.context.start.alt??!1},this.context,this.plugin.templateRenderer)}};a();var mne=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to insert Markdown citation"},{command:"shift \u21B5",purpose:"to insert secondary Markdown citation"},{command:"esc",purpose:"to dismiss"}],Ux=class extends ro{constructor(r){super(r);this.plugin=r;this.setInstructions(mne)}};async function Wx(t,e,r){let n=await Ih(r);if(!n)return!1;let o=t.getCursor();return await Sh({item:n.value.item,alt:Dj(n.evt)},{start:o,end:o,editor:t,file:e},r.templateRenderer),!0}async function Ih(t){return await Gi(new Ux(t))}a();var ms=require("obsidian");a();_();_();a();_();a();_();a();var Qo=Y(Xo());_();a();function Kx(t){let e=Object.prototype.toString.call(t).slice(8,-1);return e==="Object"&&typeof t[Symbol.iterator]=="function"?"Iterable":e==="Custom"&&t.constructor!==Object&&t instanceof Object?"Object":e}a();var $j=Y(Xo());_();a();var Au=Y(Xo());_();a();var Pj=Y(Xo());_();function ku(t){let{styling:e,arrowStyle:r="single",expanded:n,nodeType:o,onClick:i}=t;return P.createElement("div",(0,Pj.default)({},e("arrowContainer",r),{onClick:i}),P.createElement("div",e(["arrow","arrowSign"],o,n,r),"\u25B6",r==="double"&&P.createElement("div",e(["arrowSign","arrowSignInner"]),"\u25B6")))}a();function hne(t,e){return t==="Object"?Object.keys(e).length:t==="Array"?e.length:1/0}function gne(t){return typeof t.set=="function"}function yne(t,e,r){let n=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:1/0,i;if(t==="Object"){let s=Object.getOwnPropertyNames(e);r&&s.sort(r===!0?void 0:r),s=s.slice(n,o+1),i={entries:s.map(c=>({key:c,value:e[c]}))}}else if(t==="Array")i={entries:e.slice(n,o+1).map((s,c)=>({key:c+n,value:s}))};else{let s=0,c=[],l=!0,f=gne(e);for(let u of e){if(s>o){l=!1;break}n<=s&&(f&&Array.isArray(u)?typeof u[0]=="string"||typeof u[0]=="number"?c.push({key:u[0],value:u[1]}):c.push({key:`[entry ${s}]`,value:{"[key]":u[0],"[value]":u[1]}}):c.push({key:s,value:u})),s++}i={hasMore:!l,entries:c}}return i}function Vx(t,e,r){let n=[];for(;e-t>r*r;)r=r*r;for(let o=t;o<=e;o+=r)n.push({from:o,to:Math.min(e,o+r-1)});return n}function Gx(t,e,r,n){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:0,i=arguments.length>5&&arguments[5]!==void 0?arguments[5]:1/0,s=yne.bind(null,t,e,r);if(!n)return s().entries;let c=i<1/0,l=Math.min(i-o,hne(t,e));if(t!=="Iterable"){if(l<=n||n<7)return s(o,i).entries}else if(l<=n&&!c)return s(o,i).entries;let f;if(t==="Iterable"){let{hasMore:u,entries:d}=s(o,o+n-1);f=u?[...d,...Vx(o+n,o+2*n-1,n)]:d}else f=c?Vx(o,i,n):[...s(0,n-5).entries,...Vx(n-4,l-5,n),...s(l-4,l-1).entries];return f}a();var Fj=Y(Xo());_();function Zx(t){let{styling:e,from:r,to:n,renderChildNodes:o,nodeType:i}=t,[s,c]=q(!1),l=ee(()=>{c(!s)},[s]);return s?P.createElement("div",e("itemRange",s),o(t,r,n)):P.createElement("div",(0,Fj.default)({},e("itemRange",s),{onClick:l}),P.createElement(ku,{nodeType:i,styling:e,expanded:!1,onClick:l,arrowStyle:"double"}),`${r} ... ${n}`)}function bne(t){return t.to!==void 0}function Mj(t,e,r){let{nodeType:n,data:o,collectionLimit:i,circularCache:s,keyPath:c,postprocessValue:l,sortObjectKeys:f}=t,u=[];return Gx(n,o,f,i,e,r).forEach(d=>{if(bne(d))u.push(P.createElement(Zx,(0,Au.default)({},t,{key:`ItemRange--${d.from}-${d.to}`,from:d.from,to:d.to,renderChildNodes:Mj})));else{let{key:m,value:h}=d,y=s.indexOf(h)!==-1;u.push(P.createElement(Ru,(0,Au.default)({},t,{postprocessValue:l,collectionLimit:i,key:`Node--${m}`,keyPath:[m,...c],value:l(h),circularCache:[...s,h],isCircular:y,hideRoot:!1})))}}),u}function us(t){let{circularCache:e=[],collectionLimit:r,createItemString:n,data:o,expandable:i,getItemString:s,hideRoot:c,isCircular:l,keyPath:f,labelRenderer:u,level:d=0,nodeType:m,nodeTypeIndicator:h,shouldExpandNodeInitially:y,styling:w}=t,[v,x]=q(l?!1:y(f,o,d)),S=ee(()=>{i&&x(!v)},[i,v]),k=v||c&&d===0?Mj({...t,circularCache:e,level:d+1}):null,j=P.createElement("span",w("nestedNodeItemType",v),h),Z=s(m,o,j,n(o,r),f),X=[f,m,v,i];return c?P.createElement("li",w("rootNode",...X),P.createElement("ul",w("rootNodeChildren",...X),k)):P.createElement("li",w("nestedNode",...X),i&&P.createElement(ku,{styling:w,nodeType:m,expanded:v,onClick:S}),P.createElement("label",(0,Au.default)({},w(["label","nestedNodeLabel"],...X),{onClick:S}),u(...X)),P.createElement("span",(0,Au.default)({},w("nestedNodeItemString",...X),{onClick:S}),Z),P.createElement("ul",w("nestedNodeChildren",...X),k))}function vne(t){let e=Object.getOwnPropertyNames(t).length;return`${e} ${e!==1?"keys":"key"}`}function Jx(t){let{data:e,...r}=t;return P.createElement(us,(0,$j.default)({},r,{data:e,nodeType:"Object",nodeTypeIndicator:r.nodeType==="Error"?"Error()":"{}",createItemString:vne,expandable:Object.getOwnPropertyNames(e).length>0}))}a();var Lj=Y(Xo());_();function wne(t){return`${t.length} ${t.length!==1?"items":"item"}`}function Yx(t){let{data:e,...r}=t;return P.createElement(us,(0,Lj.default)({},r,{data:e,nodeType:"Array",nodeTypeIndicator:"[]",createItemString:wne,expandable:e.length>0}))}a();var jj=Y(Xo());_();function xne(t,e){let r=0,n=!1;if(Number.isSafeInteger(t.size))r=t.size;else for(let o of t){if(e&&r+1>e){n=!0;break}r+=1}return`${n?">":""}${r} ${r!==1?"entries":"entry"}`}function Xx(t){return P.createElement(us,(0,jj.default)({},t,{nodeType:"Iterable",nodeTypeIndicator:"()",createItemString:xne,expandable:!0}))}a();_();function Gr(t){let{nodeType:e,styling:r,labelRenderer:n,keyPath:o,valueRenderer:i,value:s,valueGetter:c=l=>l}=t;return P.createElement("li",r("value",e,o),P.createElement("label",r(["label","valueLabel"],e,o),n(o,e,!1,!1)),P.createElement("span",r("valueText",e,o),i(c(s),s,...o)))}function Ru(t){let{getItemString:e,keyPath:r,labelRenderer:n,styling:o,value:i,valueRenderer:s,isCustomNode:c,...l}=t,f=c(i)?"Custom":Kx(i),u={getItemString:e,key:r[0],keyPath:r,labelRenderer:n,nodeType:f,styling:o,value:i,valueRenderer:s},d={...l,...u,data:i,isCustomNode:c};switch(f){case"Object":case"Error":case"WeakMap":case"WeakSet":return P.createElement(Jx,d);case"Array":return P.createElement(Yx,d);case"Iterable":case"Map":case"Set":return P.createElement(Xx,d);case"String":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:m=>`"${m}"`}));case"Number":return P.createElement(Gr,u);case"Boolean":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:m=>m?"true":"false"}));case"Date":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:m=>m.toISOString()}));case"Null":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:()=>"null"}));case"Undefined":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:()=>"undefined"}));case"Function":case"Symbol":return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:m=>m.toString()}));case"Custom":return P.createElement(Gr,u);default:return P.createElement(Gr,(0,Qo.default)({},u,{valueGetter:()=>`<${f}>`}))}}a();a();var gg=Y(_h()),fq=Y(Uj()),fE=Y(Jj()),pE=Y(y3()),cE=Y(B3()),lE=Y(sq());a();function aq(t){var e=t[0],r=t[1],n=t[2],o,i,s;return o=e*1+r*0+n*1.13983,i=e*1+r*-.39465+n*-.5806,s=e*1+r*2.02311+n*0,o=Math.min(Math.max(0,o),1),i=Math.min(Math.max(0,i),1),s=Math.min(Math.max(0,s),1),[o*255,i*255,s*255]}function cq(t){var e=t[0]/255,r=t[1]/255,n=t[2]/255,o=e*.299+r*.587+n*.114,i=e*-.14713+r*-.28886+n*.436,s=e*.615+r*-.51499+n*-.10001;return[o,i,s]}function lq(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),r.push.apply(r,n)}return r}function Ht(t){for(var e=1;e1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l1?s-1:0),l=1;l2?n-2:0),i=2;i1&&arguments[1]!==void 0?arguments[1]:{},r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},n=e.defaultBase16,o=n===void 0?pq:n,i=e.base16Themes,s=i===void 0?null:i,c=Hie(r,s);c&&(r=Ht(Ht({},c),r));for(var l=uq.reduce(function(w,v){return w[v]=r[v]||o[v],w},{}),f=Object.keys(r).reduce(function(w,v){return uq.indexOf(v)===-1&&(w[v]=r[v]),w},{}),u=t(l),d=Uie(f,u),m=arguments.length,h=new Array(m>3?m-3:0),y=3;y({BACKGROUND_COLOR:t.base00,TEXT_COLOR:t.base07,STRING_COLOR:t.base0B,DATE_COLOR:t.base0B,NUMBER_COLOR:t.base09,BOOLEAN_COLOR:t.base09,NULL_COLOR:t.base08,UNDEFINED_COLOR:t.base08,FUNCTION_COLOR:t.base08,SYMBOL_COLOR:t.base08,LABEL_COLOR:t.base0D,ARROW_COLOR:t.base0D,ITEM_STRING_COLOR:t.base0B,ITEM_STRING_EXPANDED_COLOR:t.base03}),Vie=t=>({String:t.STRING_COLOR,Date:t.DATE_COLOR,Number:t.NUMBER_COLOR,Boolean:t.BOOLEAN_COLOR,Null:t.NULL_COLOR,Undefined:t.UNDEFINED_COLOR,Function:t.FUNCTION_COLOR,Symbol:t.SYMBOL_COLOR}),Gie=t=>{let e=Kie(t);return{tree:{border:0,padding:0,marginTop:"0.5em",marginBottom:"0.5em",marginLeft:"0.125em",marginRight:0,listStyle:"none",MozUserSelect:"none",WebkitUserSelect:"none",backgroundColor:e.BACKGROUND_COLOR},value:(r,n,o)=>{let{style:i}=r;return{style:{...i,paddingTop:"0.25em",paddingRight:0,marginLeft:"0.875em",WebkitUserSelect:"text",MozUserSelect:"text",wordWrap:"break-word",paddingLeft:o.length>1?"2.125em":"1.25em",textIndent:"-0.5em",wordBreak:"break-all"}}},label:{display:"inline-block",color:e.LABEL_COLOR},valueLabel:{margin:"0 0.5em 0 0"},valueText:(r,n)=>{let{style:o}=r;return{style:{...o,color:Vie(e)[n]}}},itemRange:(r,n)=>({style:{paddingTop:n?0:"0.25em",cursor:"pointer",color:e.LABEL_COLOR}}),arrow:(r,n,o)=>{let{style:i}=r;return{style:{...i,marginLeft:0,transition:"150ms",WebkitTransition:"150ms",MozTransition:"150ms",WebkitTransform:o?"rotateZ(90deg)":"rotateZ(0deg)",MozTransform:o?"rotateZ(90deg)":"rotateZ(0deg)",transform:o?"rotateZ(90deg)":"rotateZ(0deg)",transformOrigin:"45% 50%",WebkitTransformOrigin:"45% 50%",MozTransformOrigin:"45% 50%",position:"relative",lineHeight:"1.1em",fontSize:"0.75em"}}},arrowContainer:(r,n)=>{let{style:o}=r;return{style:{...o,display:"inline-block",paddingRight:"0.5em",paddingLeft:n==="double"?"1em":0,cursor:"pointer"}}},arrowSign:{color:e.ARROW_COLOR},arrowSignInner:{position:"absolute",top:0,left:"-0.4em"},nestedNode:(r,n,o,i,s)=>{let{style:c}=r;return{style:{...c,position:"relative",paddingTop:"0.25em",marginLeft:n.length>1?"0.875em":0,paddingLeft:s?0:"1.125em"}}},rootNode:{padding:0,margin:0},nestedNodeLabel:(r,n,o,i,s)=>{let{style:c}=r;return{style:{...c,margin:0,padding:0,WebkitUserSelect:s?"inherit":"text",MozUserSelect:s?"inherit":"text",cursor:s?"pointer":"default"}}},nestedNodeItemString:(r,n,o,i)=>{let{style:s}=r;return{style:{...s,paddingLeft:"0.5em",cursor:"default",color:i?e.ITEM_STRING_EXPANDED_COLOR:e.ITEM_STRING_COLOR}}},nestedNodeItemType:{marginLeft:"0.3em",marginRight:"0.3em"},nestedNodeChildren:(r,n,o)=>{let{style:i}=r;return{style:{...i,padding:0,margin:0,listStyle:"none",display:o?"block":"none"}}},rootNodeChildren:{padding:0,margin:0,listStyle:"none"}}},Zie=dq(Gie,{defaultBase16:gq}),yq=Zie;var bq=t=>t,Jie=(t,e,r)=>r===0,Yie=(t,e,r,n)=>P.createElement("span",null,r," ",n),Xie=t=>{let[e]=t;return P.createElement("span",null,e,":")},Qie=()=>!1;function vq(t){let{data:e,theme:r,invertTheme:n,keyPath:o=["root"],labelRenderer:i=Xie,valueRenderer:s=bq,shouldExpandNodeInitially:c=Jie,hideRoot:l=!1,getItemString:f=Yie,postprocessValue:u=bq,isCustomNode:d=Qie,collectionLimit:m=50,sortObjectKeys:h=!1}=t,y=ae(()=>yq(n?hq(r):r),[r,n]);return P.createElement("ul",y("tree"),P.createElement(Ru,{keyPath:l?[]:o,value:u(e),isCustomNode:d,styling:y,labelRenderer:i,valueRenderer:s,shouldExpandNodeInitially:c,hideRoot:l,getItemString:f,postprocessValue:u,collectionLimit:m,sortObjectKeys:h}))}a();var wq=require("obsidian");var ese=()=>{let[t]=jt("clipboard-copy");return g("span",{ref:t})},xq=(t,e,r,n,o)=>{if(o.length===1){let i=async s=>{s.preventDefault(),s.stopPropagation(),await navigator.clipboard.writeText("```json\n"+JSON.stringify(e,null,2)+"\n```"),new wq.Notice("Copied JSON code block to clipboard")};return g("span",{role:"button",tabIndex:0,onClick:i,onKeyDown:i,"aria-label":"Copy item details in JSON",children:[n," ",g(ese,{})]})}if(o[1]==="creators"&&o.length===3){let i=Vl(e);if(i)return g("span",{children:i})}if(o[1]==="tags"&&o.length===3){let i=e;return g("span",{children:['"',i.name,'"" (',Hi[i.type],")"]})}if(o[0]==="sortIndex"&&o.length===2)return g("span",{children:["[",e.join(", "),"]"]});if(o.length===2&&Array.isArray(e)&&e.length===1){let i=JSON.stringify(e[0]);return g("span",{children:[r," ",i.length>100?i.slice(0,100)+"...":i]})}return g("span",{children:[r," ",n]})};a();var Sq=require("obsidian");var Iq=(t,e,r,n)=>{let o=t.length===1,i=t.slice(0,-1),s=Eq(i);return g("span",{...o?void 0:{onContextMenu:f=>{let u=new Sq.Menu().addItem(d=>d.setTitle("Copy template").onClick(()=>{navigator.clipboard.writeText(`<%= ${s} %>`)}));n&&e!=="Array"&&u.addItem(d=>d.setTitle("Copy template (using with)").onClick(()=>{let[m,...h]=i,y=typeof m=="string"&&_q.test(m)?m:`'${m}'`,w=Eq(h);navigator.clipboard.writeText(`<% { const { ${y}: $it } = ${w}; %> <%= $it %> -<% } %>`)})),e==="Array"&&c.addItem(f=>f.setTitle("Copy template (using for-of loop)").onClick(()=>{navigator.clipboard.writeText(`<% for (const $it of ${s}) { %> +<% } %>`)})),e==="Array"&&u.addItem(d=>d.setTitle("Copy template (using for-of loop)").onClick(()=>{navigator.clipboard.writeText(`<% for (const $it of ${s}) { %> <%= $it %> -<% } %>`)})).addItem(f=>f.setTitle("Copy template (using forEach)").onClick(()=>{navigator.clipboard.writeText(`<% ${s}.forEach(($it, i) => { %> +<% } %>`)})).addItem(d=>d.setTitle("Copy template (using forEach)").onClick(()=>{navigator.clipboard.writeText(`<% ${s}.forEach(($it, i) => { %> <%= $it %> -<% }) %>`)})).addItem(f=>f.setTitle("Copy template (pick first element)").onClick(()=>{navigator.clipboard.writeText(`<%= ${s}.first() %>`)})).addItem(f=>f.setTitle("Copy template (pick last element)").onClick(()=>{navigator.clipboard.writeText(`<%= ${s}.last() %>`)})),A0.has(i[0])||c.addItem(f=>f.setTitle("Copy template (render when present)").onClick(()=>{navigator.clipboard.writeText(`<% if (${s}) { %> +<% }) %>`)})).addItem(d=>d.setTitle("Copy template (pick first element)").onClick(()=>{navigator.clipboard.writeText(`<%= ${s}.first() %>`)})).addItem(d=>d.setTitle("Copy template (pick last element)").onClick(()=>{navigator.clipboard.writeText(`<%= ${s}.last() %>`)})),j0.has(i[0])||u.addItem(d=>d.setTitle("Copy template (render when present)").onClick(()=>{navigator.clipboard.writeText(`<% if (${s}) { %> <%= ${s} %> -<% } %>`)})),u.preventDefault(),c.showAtMouseEvent(u.nativeEvent)},style:{cursor:"context-menu"}},children:[t[0],": "]})},cq=t=>"it"+t.map(Fie).reverse().join(""),pq=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,Fie=t=>typeof t=="number"?`[${t}]`:pq.test(t)?`.${t}`:`[${JSON.stringify(t)}]`;var Pie=new Set(["sortIndex"]),Mie=new Set(["creators","tags"]),$ie=new Set(["position"]),dq=(t,e,r)=>{let n=t[0];return Pie.has(n)||Mie.has(n)&&Array.isArray(e)&&e.length>6?!1:!!($ie.has(n)||r<1||r<2&&Array.isArray(e)&&e.length>1)};var Lie={grad:.9,turn:360,rad:360/(2*Math.PI)},ro=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},it=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=Math.pow(10,e)),Math.round(r*t)/r+0},_r=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=1),t>r?r:t>e?t:e},Eq=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},mq=function(t){return{r:_r(t.r,0,255),g:_r(t.g,0,255),b:_r(t.b,0,255),a:_r(t.a)}},nE=function(t){return{r:it(t.r),g:it(t.g),b:it(t.b),a:it(t.a,3)}},jie=/^#([0-9a-f]{3,8})$/i,lg=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Sq=function(t){var e=t.r,r=t.g,n=t.b,o=t.a,i=Math.max(e,r,n),s=i-Math.min(e,r,n),a=s?i===e?(r-n)/s:i===r?2+(n-e)/s:4+(e-r)/s:0;return{h:60*(a<0?a+6:a),s:i?s/i*100:0,v:i/255*100,a:o}},Iq=function(t){var e=t.h,r=t.s,n=t.v,o=t.a;e=e/360*6,r/=100,n/=100;var i=Math.floor(e),s=n*(1-r),a=n*(1-(e-i)*r),l=n*(1-(1-e+i)*r),u=i%6;return{r:255*[n,a,s,s,l,n][u],g:255*[l,n,n,a,s,s][u],b:255*[s,s,l,n,n,a][u],a:o}},hq=function(t){return{h:Eq(t.h),s:_r(t.s,0,100),l:_r(t.l,0,100),a:_r(t.a)}},gq=function(t){return{h:it(t.h),s:it(t.s),l:it(t.l),a:it(t.a,3)}},yq=function(t){return Iq((r=(e=t).s,{h:e.h,s:(r*=((n=e.l)<50?n:100-n)/100)>0?2*r/(n+r)*100:0,v:n+r,a:e.a}));var e,r,n},qu=function(t){return{h:(e=Sq(t)).h,s:(o=(200-(r=e.s))*(n=e.v)/100)>0&&o<200?r*n/100/(o<=100?o:200-o)*100:0,l:o/2,a:e.a};var e,r,n,o},qie=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Bie=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,zie=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Uie=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,bq={string:[[function(t){var e=jie.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?it(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?it(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=zie.exec(t)||Uie.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:mq({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=qie.exec(t)||Bie.exec(t);if(!e)return null;var r,n,o=hq({h:(r=e[1],n=e[2],n===void 0&&(n="deg"),Number(r)*(Lie[n]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return yq(o)},"hsl"]],object:[[function(t){var e=t.r,r=t.g,n=t.b,o=t.a,i=o===void 0?1:o;return ro(e)&&ro(r)&&ro(n)?mq({r:Number(e),g:Number(r),b:Number(n),a:Number(i)}):null},"rgb"],[function(t){var e=t.h,r=t.s,n=t.l,o=t.a,i=o===void 0?1:o;if(!ro(e)||!ro(r)||!ro(n))return null;var s=hq({h:Number(e),s:Number(r),l:Number(n),a:Number(i)});return yq(s)},"hsl"],[function(t){var e=t.h,r=t.s,n=t.v,o=t.a,i=o===void 0?1:o;if(!ro(e)||!ro(r)||!ro(n))return null;var s=function(a){return{h:Eq(a.h),s:_r(a.s,0,100),v:_r(a.v,0,100),a:_r(a.a)}}({h:Number(e),s:Number(r),v:Number(n),a:Number(i)});return Iq(s)},"hsv"]]},vq=function(t,e){for(var r=0;r=.5},t.prototype.toHex=function(){return e=nE(this.rgba),r=e.r,n=e.g,o=e.b,s=(i=e.a)<1?lg(it(255*i)):"","#"+lg(r)+lg(n)+lg(o)+s;var e,r,n,o,i,s},t.prototype.toRgb=function(){return nE(this.rgba)},t.prototype.toRgbString=function(){return e=nE(this.rgba),r=e.r,n=e.g,o=e.b,(i=e.a)<1?"rgba("+r+", "+n+", "+o+", "+i+")":"rgb("+r+", "+n+", "+o+")";var e,r,n,o,i},t.prototype.toHsl=function(){return gq(qu(this.rgba))},t.prototype.toHslString=function(){return e=gq(qu(this.rgba)),r=e.h,n=e.s,o=e.l,(i=e.a)<1?"hsla("+r+", "+n+"%, "+o+"%, "+i+")":"hsl("+r+", "+n+"%, "+o+"%)";var e,r,n,o,i},t.prototype.toHsv=function(){return e=Sq(this.rgba),{h:it(e.h),s:it(e.s),v:it(e.v),a:it(e.a,3)};var e},t.prototype.invert=function(){return nr({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),nr(oE(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),nr(oE(this.rgba,-e))},t.prototype.grayscale=function(){return nr(oE(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),nr(wq(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),nr(wq(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?nr({r:(r=this.rgba).r,g:r.g,b:r.b,a:e}):it(this.rgba.a,3);var r},t.prototype.hue=function(e){var r=qu(this.rgba);return typeof e=="number"?nr({h:e,s:r.s,l:r.l,a:r.a}):it(r.h)},t.prototype.isEqual=function(e){return this.toHex()===nr(e).toHex()},t}(),nr=function(t){return t instanceof xq?t:new xq(t)};var Hie=/^#(?:[\dA-F]{3}){1,2}$|^#(?:[\dA-F]{4}){1,2}$/i,Kie=t=>{let e=nr(t),{r,g:n,b:o}=e.rgba;return r*.299+n*.587+o*.114>186},_q=(t,e,...r)=>{if(typeof e=="string"&&Hie.test(e))return m("span",{style:{backgroundColor:e,padding:"0 0.5em",color:Kie(e)?"black":"white"},children:e});let n;return r[0]==="linkMode"&&typeof e=="number"&&(n=Md[e]),r[0]==="type"&&typeof e=="number"&&(r.length===2&&Ae[e]?n=Ae[e]:r.length===4&&typeof r[1]=="number"&&r[2]==="tags"&&Bi[e]&&(n=Bi[e])),n?m(M,{children:[t," ",m("span",{children:["(",n,")"]})]}):t};var Oq=()=>document.body.classList.contains("theme-dark"),Vie={scheme:"Solarized Light",author:"Ethan Schoonover (modified by aramisgithub)",base00:"transparent",base01:"#eee8d5",base02:"#93a1a1",base03:"#839496",base04:"#657b83",base05:"#586e75",base06:"#073642",base07:"#002b36",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"},Gie={scheme:"Solarized Dark",author:"Ethan Schoonover (modified by aramisgithub)",base00:"transparent",base01:"#073642",base02:"#586e75",base03:"#657b83",base04:"#839496",base05:"#93a1a1",base06:"#eee8d5",base07:"#fdf6e3",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"};function sE({item:t,registerCssChange:e}){let[r,n]=L(()=>Oq());return U(()=>e?.(()=>n(Oq())),[e]),t?m(sq,{data:t,theme:r?Gie:Vie,invertTheme:!1,keyPath:["Zotero Item Data"],shouldExpandNodeInitially:dq,valueRenderer:_q,labelRenderer:fq,getItemString:lq}):m("div",{children:"No Details Available"})}var Tq=require("obsidian");var cg=t=>({plugin:t,sourcePath:""});function Zie(){return uu((t,e)=>({preview:null,templateType:null,setTemplateType(r){t(n=>({...n,templateType:r||void 0}))},setPreview(r){t(({...n})=>({...n,preview:r??null}))},async setPreviewFromState(r,n){let o=e().preview;if(o?.docItem.itemID===r?.docItem&&o?.attachment?.itemID===r?.attachment&&o?.annot?.itemID===r?.annot)return!1;let i=n.database.settings.libId;if(!r.docItem)return console.error("TemplatePreview: no docItem provided"),!1;let[s]=await n.databaseAPI.getItems([[r.docItem,i]]);if(!s)return console.error("TemplatePreview: no docItem found for id "+r.docItem),!1;let a=await n.databaseAPI.getAttachments(r.docItem,i),l=a.find(d=>d.itemID===r.attachment)??null;r.attachment&&!l&&console.error("TemplatePreview: no attachment found for id "+r.attachment);let u=l?await n.databaseAPI.getAnnotations(l.itemID,i):[],c=u.find(d=>d.itemID===r.annot);r.annot&&!c&&console.error("TemplatePreview: no annotation found for id "+r.annot);let f=await n.databaseAPI.getTags([[r.docItem,i],...u.map(d=>[d.itemID,i])]),p;try{p=await n.databaseAPI.getNotes(s.itemID,i).then(d=>n.noteParser.normalizeNotes(d))}catch(d){console.error(d),p=[]}return t(()=>({preview:{docItem:s,allAttachments:a,annotations:u,attachment:l,tags:f,annot:u.find(d=>d.itemID===r.annot),notes:p}})),!0}}))}function Cq(t,e){let r=null,n=null,o=null;return function(...i){if(r&&window.clearTimeout(r),n){o=i;return}r=window.setTimeout(()=>{r=null,n=t(...i).then(()=>{o?n=t(...o):n=null}).catch(s=>{console.error(s),n=null})},e)}}var $a=class extends Tq.FileView{constructor(r,n){super(r);this.plugin=n;this.store=Zie()}store;canAcceptExtension(r){return r==="md"}getTemplateType(r){if(!r)return!1;let n=wt(r.path,this.plugin.settings.templateDir);return n?.type!=="ejectable"?!1:n.name}setTemplateType(r){this.store.getState().setTemplateType(r)}async onLoadFile(r){await super.onLoadFile(r),this.setTemplateType(this.getTemplateType(r))}getState(){let r=super.getState(),{preview:n}=this.store.getState(),o;if(!n)o={preview:null};else{let{docItem:i,attachment:s,annot:a}=n;o={preview:{docItem:i.itemID,attachment:s?.itemID,annot:a?.itemID}}}return{...r,...o}}async setState(r,n){if(await super.setState(r,n),r.preview===void 0)return;let o=this.store.getState();r.preview===null?o.setPreview(null):await o.setPreviewFromState(r.preview,this.plugin)}setPreview(r){this.store.getState().setPreview(r)}async onOpen(){await super.onOpen();let[r,n]=Ns(this.plugin);n&&this.register(n),await r}};var La="zotero-item-details",Aq=({templateType:t})=>t==="annotation"?t:"note",ug=class extends $a{getViewType(){return La}getDisplayText(){let e=this.store.getState();return e.templateType?"Zotero Item Details: "+Aq(e):"Zotero Item Details"}async onOpen(){await super.onOpen();let[e,r]=Ns(this.plugin);r&&this.register(r),await e,N.render(m(Jie,{store:this.store,plugin:this.plugin}),this.contentEl)}async onClose(){N.unmountComponentAtNode(this.contentEl),await super.onClose()}};function Jie({store:t,plugin:e}){let r=qt(t,Aq),n=qt(t,i=>i.preview),o=ie(()=>{let i=cg(e);if(!n)return null;switch(r){case"note":{let s=jt(n,i);return s.docItem.annotations=void 0,s.docItem}case"annotation":{let s=jt(n,i),a=n.annot?s.annotations.find(l=>l.itemID===n.annot?.itemID):s.annotations[0];return a?(a.docItem=void 0,a):null}default:throw new Error("Unsupported template type")}},[e,n,r]);return o?m(sE,{item:o,registerCssChange:i=>(e.app.workspace.on("css-change",i),()=>e.app.workspace.off("css-change",i))}):m("div",{})}var kq=Z(ks(),1),Or=require("obsidian");var ja="zotero-template-preview",fg=class extends $a{getViewType(){return ja}getDisplayText(){let e=this.store.getState().templateType;return e?"Zotero Template Preview: "+e:"Zotero Template Preview"}async switchToTemplate(e){if(!this.leaf.group)return!1;let r=Rq(this.leaf.group,this.plugin);if(!r)return!1;let n=lE(e,this.plugin.settings.templateDir,this.app);if(!n||!(n instanceof Or.TFile)){new Or.Notice("Template file not found: "+e);return}return await r.openFile(n),!0}onload(){let e={annots:this.addAction("list-ordered","Open Template for Annotations",async()=>await this.switchToTemplate("annots")||new Or.Notice("Cannot switch to template")),note:this.addAction("file-input","Open Note Template",async()=>await this.switchToTemplate("note")||new Or.Notice("Cannot switch to template")),annotation:this.addAction("highlighter","Open Template for Single Annotation",async()=>await this.switchToTemplate("annotation")||new Or.Notice("Cannot switch to template")),field:this.addAction("info","Open Template for Note Properties",async()=>await this.switchToTemplate("field")||new Or.Notice("Cannot switch to template"))};Object.values(e).forEach(r=>r.hide()),this.register(this.store.subscribe((r,n)=>{if(r.templateType!==n.templateType)for(let[o,i]of Object.entries(e))i.toggle(o!==r.templateType)})),this.registerEvent(this.app.vault.on("zotero:template-updated",r=>{let n=this.getTemplateType(this.file);n&&r===n&&(this.setTemplateType(n),this.requestRender())}))}content=null;async render(){let{preview:e,templateType:r}=this.store.getState();if(!r){this.contentEl.empty(),this.contentEl.setText("No template preview available");return}if(!e){this.contentEl.empty(),this.contentEl.setText("No preview data available");return}let n="",o=cg(this.plugin),i=this.plugin.templateRenderer;try{switch(r){case"annotation":{let l=e.annot??e.annotations[0];if(!l){this.contentEl.setText("No annotation data available");return}n=i.renderAnnot(l,e,o);break}case"annots":n=i.renderAnnots(e,o);break;case"note":n=i.renderNote(e,o);break;case"field":n=i.renderFrontmatter(e,o);break;case"cite":n=i.renderCitations([e],o);break;case"cite2":n=i.renderCitations([e],o,!0);break;case"colored":n=i.renderColored({content:"I'm Highlight",color:"#FF000080",colorName:"red",bgColor:"#FF000080",bgColorName:"red"});break;default:(0,kq.assertNever)(r)}if(n===this.content?.markdown)return;this.content?.unload(),this.contentEl.empty();let s=await(0,Or.loadPrism)(),a=s.highlight(n,s.languages.markdown,"markdown");this.content=new aE(n),this.contentEl.createEl("pre").createEl("code",{cls:"language-markdown"}).innerHTML=a}catch(s){this.content?.unload(),this.contentEl.empty();let a=s instanceof Error?s.message:String(s);this.contentEl.createEl("h1",{text:`Error while rendering ${r}`,cls:["mod-error","message"]}),this.contentEl.createEl("pre",{text:a})}}requestRender=Cq(()=>this.render(),200);async onOpen(){await super.onOpen(),this.register(this.store.subscribe((e,r)=>{e.templateType!==r.templateType?this.requestRender():e.preview!==r.preview&&this.requestRender()}))}},aE=class extends Or.Component{constructor(r){super();this.markdown=r}};async function fs(t,e,{app:r,settings:n}){let{workspace:o}=r,i=lE(t,n.templateDir,r);if(!i||!(i instanceof us.TFile)){new us.Notice("Template file not found: "+t);return}let s=o.getLeavesOfType("markdown").filter(c=>{let f=c.view;return f.file?wt(f.file.path,n.templateDir)?.type==="ejectable"&&c.getRoot().type==="floating":!1});if(s.length>0){let c=s[0];if(await c.openFile(i),!c.group)return;let f=o.getGroupLeaves(c.group);for(let p of f){let d=p.view.getViewType();if(d===ja||d===La){let h=p.view.getState();await p.view.setState({...h,preview:e},{})}}return}let a=o.openPopoutLeaf(),l=o.createLeafBySplit(a,"vertical"),u=o.createLeafBySplit(l,"vertical");await Promise.all([a.openFile(i,{active:!0}),l.setViewState({type:ja,state:{file:i.path,preview:e},group:a}),u.setViewState({type:La,state:{file:i.path,preview:e},group:a})])}function lE(t,e,r){let n=mi(t,e),o=r.vault.getAbstractFileByPath(n);return o instanceof us.TFile?o:null}function Rq(t,e){return e.app.workspace.getGroupLeaves(t).find(n=>n.view instanceof us.MarkdownView&&n.view.file&&wt(n.view.file.path,e.settings.templateDir)?.type==="ejectable")}var Nq=t=>(e,r,n)=>{let{imgCacheImporter:o}=t,i=String(e.timeStamp),s="drag-source";e.dataTransfer.setData("text/plain",r()),e.dataTransfer.setData(s,i),e.dataTransfer.dropEffect="copy";let a=e.target.win,{workspace:l}=t.app,u=p=>{p.dataTransfer?.getData(s)===i&&o.flush(),l.off("editor-drop",u),a.removeEventListener("dragend",c)},c=()=>{o.cancel(),l.off("editor-drop",u)},f=l.on("editor-drop",p=>{p.dataTransfer?.getData("drag-source")===i&&o.flush(),l.offref(f)});a.addEventListener("dragend",c,{once:!0}),n&&e.dataTransfer.setDragImage(n,0,0)},Dq=t=>({storeSelector:e=>Yd(e,["doc","attachment","allAttachments","tags","annotations"]),get:(e,{allAttachments:r,attachment:n,doc:o,tags:i,annotations:s})=>!r||!n||!o||!i[e.itemID]||!s?null:()=>{let a=t.app.workspace.getActiveFile(),l=a&&bt(a)?a.path:null;return t.templateRenderer.renderAnnot(e,{tags:i,attachment:n,allAttachments:r,annotations:s,docItem:o.docItem,notes:[]},{plugin:t,sourcePath:l,merge:!1})}});var qa=require("obsidian");var Fq=t=>(e,r)=>{let n=new qa.Menu;if(n.addItem(o=>o.setTitle("Jump to note").setIcon("links-going-out").onClick(Yie(r,t))),t.app.workspace.trigger("zotero:open-annot-menu",r,n),e.nativeEvent instanceof MouseEvent)n.showAtMouseEvent(e.nativeEvent);else{let o=e.currentTarget.getBoundingClientRect();n.showAtPosition({x:o.left,y:o.bottom})}},Yie=(t,e)=>async()=>{let r=e.app.workspace.getActiveFile(),n=r&&bt(r)?r.path:void 0,o=e.plugin.noteIndex.getBlocksFor({item:t,file:n}).shift();if(!o){new qa.Notice("No embed for this annotation in current note");return}let i=o.blocks.sort((p,d)=>{let h=p.start.offset-d.start.offset;return h!==0?h:p.end.offset-d.end.offset})[0];await sleep(10);let{leaf:s}=e,{workspace:a,vault:l}=e.app,u;if(s.group)u=a.getGroupLeaves(s.group);else{u=[];let p=a.getActiveFileView();p&&u.push(p.leaf)}let c=!1,f=i.end.line+1;for(let p of u)p&&p.view instanceof qa.MarkdownView&&p.view.file?.path===o.file&&(p.view.setEphemeralState({line:f}),c=!0);if(!c){let p=l.getAbstractFileByPath(o.file);if(!p||!bt(p))throw new Error("File from block info not found: "+o.file);a.getLeaf().openFile(p,{eState:{line:f}})}};var Pq=(t,e)=>e.length===0?null:t?e.find(r=>r.itemID===t)??e[0]:e[0],pg=()=>({doc:null,allAttachments:null,attachmentID:null,annotations:null,attachment:null,tags:{}}),Xie=()=>({follow:"zt-reader",doc:null,allAttachments:null,attachmentID:null,annotations:null,attachment:null,tags:{}}),Bu=t=>t.databaseAPI,Mq=t=>uu((e,r)=>{let n=async(s,a)=>{let l=(await Bu(t).getAttachments(s,a)).filter(Rc);e(u=>({...u,allAttachments:l,attachment:Pq(u.attachmentID,l)}))},o=async(s,a)=>{let l=await Bu(t).getTags([[s,a]]);return e(u=>({...u,tags:l})),l},i=async s=>{let{attachment:a}=r();if(!a)return;let l=await Bu(t).getAnnotations(a.itemID,s),u=N0(l);e(p=>({...p,annotations:D0(u),attachment:a}));let c=await Bu(t).getTags(l.map(p=>[p.itemID,s])),f=F0(u,c);e(p=>({...p,tags:{...p.tags,...f}}))};return{...Xie(),loadDocItem:async(s,a,l,u=!1)=>{if(s<0)return e(pg());if(r().doc?.docItem.itemID===s&&!u)return;let c=(await Bu(t).getItems([[s,l]]))[0];if(!c)return e(pg());let f={docItem:c,lib:l};if(a<0){let p=_0(window.localStorage,c);e({...pg(),doc:f,attachmentID:p})}else pa(window.localStorage,c,a),e({...pg(),doc:f,attachmentID:a});await n(c.itemID,l),await o(c.itemID,l),await i(l)},refresh:async()=>{let{doc:s,attachment:a}=r();if(!s)return;let{docItem:l,lib:u}=s;await n(l.itemID,u),await o(l.itemID,u),a&&await i(u)},setActiveAtch:s=>{let{doc:a,allAttachments:l}=r();if(a)if(pa(window.localStorage,a.docItem,s),!l)e(u=>({...u,attachment:null,attachmentID:s}));else{let u=Pq(s,l);e(c=>({...c,attachment:u,attachmentID:s}))}},setFollow:s=>e({follow:s})}});var hg="zotero-annotation-view",dg=class extends ch{constructor(r,n){super(r);this.plugin=n;this.store=Mq(n)}update(){if(this.follow!=="ob-note")return;let r=this.plugin.settings.libId;(async()=>{if(this.file?.extension!=="md")return!1;let n=Qi(this.file,this.app.metadataCache),o=es(this.file,this.app.metadataCache);if(!n)return!1;let[i]=await this.plugin.databaseAPI.getItems([[n,r]]);return i?(this.setStatePrev(s=>({...s,follow:"ob-note",itemId:i.itemID,attachmentId:o?.[0]??void 0})),!0):!1})().then(n=>{n||this.setStatePrev(o=>({...o,follow:"ob-note",itemId:-1}))})}getViewType(){return hg}#e=null;onload(){super.onload(),this.contentEl.addClass("obzt");let r=null,n=!1,o=i=>{if(n)r=i;else{n=!0;let{itemId:s,attachmentId:a}=i;this.setStatePrev(l=>({...l,itemId:s,attachmentId:a})).then(()=>{if(n=!1,r===null)return;let l=r;r=null,o(l)})}};this.registerEvent(this.plugin.server.on("bg:notify",(i,s)=>{s.event==="reader/active"&&(this.#e=s.itemId,!(this.follow!=="zt-reader"||s.itemId<0||s.attachmentId<0)&&o(s))}))}getDisplayText(){return this.follow!=="ob-note"||!this.file?.basename?"Zotero Annotations":`Zotero Annotations for ${this.file.basename}`}getIcon(){return"highlighter"}get lib(){return this.plugin.settings.libId}store;get follow(){return this.store.getState().follow}getState(){let r=super.getState(),n=this.store.getState(),o={itemId:n.doc?.docItem.itemID??-1,attachmentId:n.attachment?.itemID??-1,follow:n.follow};return{...r&&typeof r=="object"?r:{},...o}}async setState(r,n){await super.setState(r,n??{});let{itemId:o=-1,attachmentId:i=-1,follow:s="zt-reader"}=r;this.store.getState().setFollow(s),await this.store.getState().loadDocItem(o,i,this.lib)}async setStatePrev(r){await this.setState(r(this.getState()))}onSetFollowZt=async()=>{this.setStatePrev(r=>({...r,follow:"zt-reader"})),await this.setStatePrev(({attachmentId:r,...n})=>({...n,follow:"zt-reader",...this.#e===null?{attachmentId:r}:{itemId:this.#e}}))};onSetFollowOb=()=>{this.store.getState().setFollow("ob-note"),this.update()};onSetFollowNull=async()=>{let{plugin:r}=this,n=await hh(r);if(!n)return;let{itemID:o}=n.value.item,i=r.settings.libId,s=await r.databaseAPI.getAttachments(o,i),a=await Kn(s,this.app);await this.setStatePrev(({attachmentId:l,...u})=>({...u,follow:null,itemId:o,attachmentId:a?.itemID}))};getContext(){let r=this,{plugin:n,store:o,app:i}=r;return{store:o,registerDbUpdate(s){return i.vault.on("zotero:db-refresh",s),()=>i.vault.off("zotero:db-refresh",s)},refreshConn:async()=>{await n.dbWorker.refresh({task:"dbConn"})},getImgSrc:s=>{let a=Lo(s,n.settings.current?.zoteroDataDir);return Qie(a)},onShowDetails:async(s,a)=>{let l=o.getState(),u=l.attachmentID??void 0;if(s==="doc-item")await fs("note",{docItem:a,attachment:u},n);else{let c=l.doc?.docItem.itemID;if(!c)throw new Error("Missing doc item when showing annotation details");await fs("annotation",{docItem:c,attachment:u,annot:a},n)}},onDragStart:Nq(n),onMoreOptions:Fq(r),annotRenderer:Dq(n),onSetFollow(s){let a=new mg.Menu,l=o.getState().follow;if(l!=="zt-reader"&&a.addItem(u=>u.setIcon("book").setTitle("Follow active literature in Zotero reader").onClick(r.onSetFollowZt)),l!=="ob-note"&&a.addItem(u=>u.setIcon("file-edit").setTitle("Follow active literature note").onClick(r.onSetFollowOb)),a.addItem(u=>u.setIcon("file-lock-2").setTitle("Link with selected literature").onClick(async()=>{s.target.blur(),await r.onSetFollowNull()})),s.nativeEvent instanceof MouseEvent)a.showAtMouseEvent(s.nativeEvent);else{let c=s.target.getBoundingClientRect();a.showAtPosition({x:c.x,y:c.y})}}}}async onOpen(){await super.onOpen();let[r,n]=Ns(this.plugin);n&&this.register(n),this.contentEl.empty(),this.contentEl.createDiv({cls:"pane-empty p-2",text:"Loading..."}),r.then(()=>{this.contentEl.empty(),N.render(m(Ho.Provider,{value:hj,children:m(Ve.Provider,{value:this.getContext(),children:m(mu,{})})}),this.contentEl)}).catch(o=>{this.contentEl.empty(),console.error("Failed to load annot view: ",o),this.contentEl.createDiv({cls:"pane-empty p-2",text:"Failed to load, Check console for details"})}),this.registerEvent(this.plugin.server.on("bg:notify",(o,i)=>{if(i.event!=="reader/annot-select")return;let s=i.updates.filter(([,l])=>l).pop();if(!s)return;let[a]=s;this.highlightAnnot(a)}))}async onClose(){N.unmountComponentAtNode(this.contentEl),await super.onClose()}async highlightAnnot(r){let n=this.contentEl.querySelector(`.annot-preview[data-id="${r}"]`);n instanceof HTMLElement&&(n.addClass("select-flashing"),n.scrollIntoView({behavior:"smooth",block:"center"}),await sleep(1500),n.removeClass("select-flashing"))}};function Qie(t){return(mg.Platform.resourcePathPrefix??"app://local/")+(0,$q.pathToFileURL)(t).pathname.substring(1)+`?${Date.now()}`}var Lq=require("path/posix");var gg=require("obsidian");var ese=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to continue select note to import"},{command:"esc",purpose:"to dismiss"}],cE=class extends Qn{constructor(r){super(r);this.plugin=r;this.setInstructions(ese)}};async function jq(t){let e=await Wi(new cE(t));if(!e)return!1;let{value:{item:r}}=e,n=await t.databaseAPI.getNotes(r.itemID,t.settings.libId);if(n.length===0)return new gg.Notice("No note found for selected literature"),!1;let o=await wS(n,c=>c.title??c.note?.substring(0,20)??`No title (Key ${c.key})`);if(!o.item)return!1;let i=o.item;if(!i.note)return new gg.Notice("Selected note is empty"),!1;let s=await t.noteParser.turndown(i.note),a=t.settings.current?.literatureNoteFolder,l=(0,Lq.join)(a,"zt-import",Yi(i.title??[i.note.substring(0,10),i.key].join("_"),{replacement:"_"})),u=await t.app.fileManager.createNewMarkdownFile(t.app.vault.getRoot(),l,s);return await t.app.workspace.openLinkText(u.path,"",!0),new gg.Notice(`Note imported: ${i.title??i.key}`),!0}var wn=require("obsidian");var yg=class extends fe{plugin=this.use(xe);onload(){this.registerEvent(this.plugin.server.on("zotero/open",e=>this.onZtOpen(jf(e)))),this.registerEvent(this.plugin.server.on("zotero/export",e=>this.onZtExport(jf(e)))),this.registerEvent(this.plugin.server.on("zotero/update",e=>this.onZtExport(jf(e))))}async onZtOpen(e){if(e.type==="annotation"){new wn.Notice("Not implemented yet");return}if(e.items.length<1){new wn.Notice("No items to open");return}await this.plugin.noteFeatures.openNote(e.items[0])}async onZtUpdate(e){if(e.type==="annotation"){new wn.Notice("Single annotation update not yet supported");return}if(e.items.length<1){new wn.Notice("No items to open");return}if(e.items.length>1){new wn.Notice("Multiple literature note update not yet supported");return}await this.plugin.noteFeatures.updateNoteFromId(e.items[0])}async onZtExport(e){if(e.type==="annotation"){new wn.Notice("Not implemented yet");return}e.items.length<1?new wn.Notice("No items to open"):e.items.length>1&&new wn.Notice("Multiple items not yet supported");let{libraryID:r,id:n}=e.items[0],[o]=await this.plugin.databaseAPI.getItems([[n,r]]);if(!o){new wn.Notice("Item not found: "+n);return}let i=await this.plugin.noteFeatures.createNoteForDocItemFull(o);await this.plugin.app.workspace.openLinkText(i,"",!1,{active:!0})}};var qq=require("obsidian");var tse=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to open/create literature note"},{command:"esc",purpose:"to dismiss"}],uE=class extends Qn{constructor(r){super(r);this.plugin=r;this.setInstructions(tse)}};async function fE(t){let e=await Wi(new uE(t));if(!e)return!1;let{value:{item:r},evt:n}=e;if(await t.noteFeatures.openNote(r,!0))return!0;let o=await t.noteFeatures.createNoteForDocItemFull(r);return await t.app.workspace.openLinkText(o,"",qq.Keymap.isModEvent(n),{active:!0}),!0}var pE=class extends fe{plugin=this.use(xe);protocol=this.use(yg);onload(){let{plugin:e}=this,{app:r}=e;e.addCommand({id:"note-quick-switcher",name:"Open quick switcher for literature notes",callback:()=>fE(e)}),e.registerView(hg,o=>new dg(o,e)),e.registerView(ja,o=>new fg(o,e)),e.registerView(La,o=>new ug(o,e)),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{let s=wt(i.path,e.settings.templateDir);s?.type==="ejectable"&&o.addItem(a=>a.setIcon("edit").setTitle("Open template preview").onClick(()=>{fs(s.name,null,e)}))})),e.addCommand({id:"zotero-annot-view",name:"Open Zotero annotation view in side panel",callback:()=>{r.workspace.ensureSideLeaf(hg,"right",{active:!0,state:{file:r.workspace.getActiveFile()?.path}})}}),e.addCommand({id:"insert-markdown-citation",name:"Insert Markdown citation",editorCallback:(o,i)=>Fx(o,i.file,e)}),e.registerEditorSuggest(new wu(e));let n=async(o,i)=>{let s=e.settings.libId,a=Qi(o,r.metadataCache);if(!a)return new no.Notice("Cannot get zotero item key from file name"),!1;let[l]=await e.databaseAPI.getItems([[a,s]]);if(!l)return new no.Notice("Cannot find zotero item with key "+a),!1;await this.updateNote(l,i)};e.addCommand({id:"update-literature-note",name:"Update literature note",editorCheckCallback(o,i,s){let a=s.file&&cu(s.file,r);if(o)return!!a;a&&n(s.file)}}),e.addCommand({id:"overwrite-update-literature-note",name:"Force update literature note by overwriting",editorCheckCallback(o,i,s){let a=s.file&&cu(s.file,r);if(o)return!!a;a&&n(s.file,!0)}}),e.addCommand({id:"import-note",name:"Import note",callback:()=>jq(e)}),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{cu(i,r)&&(o.addItem(s=>s.setTitle("Update literature note").setIcon("sync").onClick(()=>n(i))),e.settings.current?.updateOverwrite||o.addItem(s=>s.setTitle("Force update by overwriting").setIcon("sync").onClick(()=>n(i,!0))))})),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{let s=wt(i.path,e.settings.templateDir);s?.type==="ejectable"&&o.addItem(a=>a.setTitle("Reset to default").setIcon("reset").onClick(async()=>{activeWindow.confirm("Reset template to default?")&&await e.app.vault.modify(i,dt.Ejectable[s.name])}))}))}async openNote(e,r=!1){let{workspace:n}=this.plugin.app,{noteIndex:o}=this.plugin,i=o.getNotesFor(e);if(!i.length)return!r&&new no.Notice(`No literature note found for zotero item with key ${e.key}`),!1;let s=i.sort().shift();return await n.openLinkText(s,"",!1,{active:!0}),!0}async createNoteForDocItem(e,r){let{noteIndex:n}=this.plugin,o=n.getNotesFor(e);if(o.length)throw new bg(o,e.key);let{vault:i,fileManager:s}=this.plugin.app,{literatureNoteFolder:a}=this.plugin.settings.current,l=this.plugin.templateRenderer,u=(0,Bq.join)(a,r.filename(l,{plugin:this.plugin})),c=i.getAbstractFileByPath(u);if(c&&Qi(c,this.plugin.app.metadataCache))throw new bg([u],e.key);return await s.createNewMarkdownFile(i.getRoot(),u,r.note(l,{plugin:this.plugin,sourcePath:u}))}async createNoteForDocItemFull(e){let r=this.plugin.settings.libId,n=await this.plugin.databaseAPI.getAttachments(e.itemID,r),o=await Kn(n,this.plugin.app);o&&ga(o,e);let i=await this.plugin.databaseAPI.getNotes(e.itemID,r).then(u=>this.plugin.noteParser.normalizeNotes(u)),s=await vu(e,{all:n,selected:o?[o]:[],notes:i},this.plugin),a=Object.values(s)[0];return(await this.createNoteForDocItem(e,{note:(u,c)=>u.renderNote(a,c),filename:(u,c)=>u.renderFilename(a,c)})).path}async updateNoteFromId(e){let{noteIndex:r,databaseAPI:n}=this.plugin;if(!r.getNotesFor(e).length){new no.Notice(`No literature note found for zotero item with key ${e.key}`);return}let[i]=await n.getItems([[e.key,e.libraryID]]);if(!i){new no.Notice(`Cannot find zotero item with key ${e.key}`);return}await this.updateNote(i)}async updateNote(e,r){let n=await bj(e,this.plugin,r);n?n.addedAnnots>0||n.updatedAnnots>0?new no.Notice(`Affected ${n.notes} notes, annotations: ${n.addedAnnots} added, ${n.updatedAnnots} updated`):new no.Notice(`Affected ${n.notes} notes, no annotation updated`):new no.Notice("No note found for this literature")}},zq=pE,bg=class extends Error{constructor(r,n){super(`Note linked to ${n} already exists: ${r.join(",")}`);this.targets=r;this.key=n;this.name="NoteExistsError"}};var wg=require("@codemirror/language");var dE=require("obsidian");var vg=class extends fe{plugin=this.use(xe);onload(){this.patchEditorClick()}async patchEditorClick(){let{workspace:e}=this.plugin.app,{noteIndex:r,database:n,settings:o,noteFeatures:i}=this.plugin;await JT(this.plugin.app);let s=()=>e.getLeavesOfType("markdown").length>0,[a,l]=_l({register:c=>e.on("layout-change",()=>{s()&&c()}),unregister:c=>e.offref(c),escape:s,timeout:null});l&&this.register(l),await a;let u=e.getLeavesOfType("markdown")[0].view;this.register(or(u.editor.constructor.prototype,{getClickableTokenAt:c=>function(f,...p){let d=c.call(this,f,...p);return d||rse.call(this,f,r)}})),this.register(or(u.editMode.constructor.prototype,{triggerClickableToken:c=>function(f,p){if(f.type==="internal-link"&&f.citekey==="zotero")(async()=>{let d=f.text,{[d]:h}=await n.api.getItemIDsFromCitekey([f.text]);if(h<0){new dE.Notice(`Citekey ${d} not found in Zotero`);return}let[b]=await n.api.getItems([[h,o.libId]]);if(!b){new dE.Notice(`Item not found for citekey ${d}`);return}let y=await i.createNoteForDocItemFull(b);await e.openLinkText(y,"",!0,{active:!0})})();else return c.call(this,f,p)}}))}};function rse(t,e){let r=this.cm,n=r.state.doc,o=[],i=n.line(t.line+1),s=(0,wg.syntaxTree)(r.state),a=i.from;s.iterate({from:i.from,to:i.to,enter:b=>{let y=b.type,v=b.from,x=b.to,T=y.prop(wg.tokenClassNodeProp);T&&(a=l){u=b;break}}if(u<0)return null;let c=o[u];if(!c.type.split(" ").includes("hmd-barelink"))return null;let p=n.sliceString(c.from,c.to);if(!p.startsWith("@"))return null;let d=p.slice(1),h={start:this.offsetToPos(c.from),end:this.offsetToPos(c.to)};if(e.citekeyCache.has(d)){let[b]=e.citekeyCache.get(d);return{type:"internal-link",text:b,...h}}else return{type:"internal-link",text:d,citekey:"zotero",...h}}var xg=require("obsidian");var Ba=class extends fe{plugin=this.use(xe);settings=this.use(ge);app=this.use(xg.App);get meta(){return this.app.metadataCache}get vault(){return this.app.vault}get literatureNoteFolder(){return this.settings.current?.literatureNoteFolder}get joinPath(){return nse(this.literatureNoteFolder)}noteCache=new Map;blockCache={byFile:new Map,byKey:new Map};citekeyCache=new Map;#e(e,r){let n=rx(r);if(n){if(!this.noteCache.has(n))return this.noteCache.set(n,new Set([e])),!0;let i=this.noteCache.get(n),s=i.size;return i.add(e).size!==s}let o=!1;for(let[i,s]of this.noteCache.entries()){let a=s.delete(e);o||=a,a&&s.size===0&&this.noteCache.delete(i)}return o}#t(e,r){let n=l=>{let u=this.blockCache.byFile.get(l);if(!u)return!1;this.blockCache.byFile.delete(l);for(let c of u){let f=this.blockCache.byKey.get(c.key);f.delete(c),f.size===0&&this.blockCache.byKey.delete(c.key)}return!0};if(!r)return n(e);let{blocks:o,sections:i}=r;if(!i||!o)return n(e);let s=i.filter(au);if(s.length===0)return n(e);n(e);let a=pu(s.flatMap(l=>lu(l.id).map(u=>[u,l.position])),zi(([l])=>l),ha((l,u)=>({file:e,key:l,blocks:u.map(([c,f])=>f)})),Gd);this.blockCache.byFile.set(e,a);for(let l of a){let u=this.blockCache.byKey.get(l.key);u?u.add(l):this.blockCache.byKey.set(l.key,new Set([l]))}return!0}#n(e,r){let n=r?.frontmatter?.citekey;if(n){if(!this.citekeyCache.has(n))return this.citekeyCache.set(n,new Set([e])),!0;let i=this.citekeyCache.get(n),s=i.size;return i.add(e).size!==s}let o=!1;for(let[i,s]of this.citekeyCache.entries()){let a=s.delete(e);o||=a,a&&s.size===0&&this.citekeyCache.delete(i)}return o}getNotesFor(e){let r=this.noteCache.get(ir(e,!0));return r?[...r]:[]}getBlocksFor({file:e,item:r}){if(!e&&!r)throw new Error("no file or item provided");let n=r?this.blockCache.byKey.get(ir(r,!0)):null,o=e?this.blockCache.byFile.get(e):null;return e&&r?!o||!n?[]:o.filter(i=>n.has(i)):e?o?[...o]:[]:r?n?[...n]:[]:[]}getBlocksIn(e){let r=this.blockCache.byFile.get(e);return r?[...r]:null}#o(e,r){r===void 0&&(r=this.meta.getCache(e)),[this.#e(e,r),this.#t(e,r),this.#n(e,r)].some(o=>o)&&this.meta.trigger("zotero:index-update",e)}#i(e){this.#o(e,null)}#r(){this.noteCache.clear(),this.blockCache.byFile.clear(),this.blockCache.byKey.clear(),this.meta.trigger("zotero:index-clear")}onload(){this.settings.once(()=>{[this.meta.on("changed",this.onMetaChanged,this),this.vault.on("rename",this.onFileRenamed,this),this.vault.on("delete",this.onFileRemoved,this)].forEach(this.registerEvent.bind(this));let[e,r]=ZT(this.plugin.app,{});r&&this.register(r),e.then(()=>{this.onMetaBuilt(),this.plugin.addCommand({id:"refresh-note-index",name:"Refresh literature notes index",callback:()=>{this.reload(),new xg.Notice("Literature notes re-indexed")}})})}),this.register(He(lt(()=>this.reload(),()=>this.literatureNoteFolder,!0)))}onMetaBuilt(){for(let e of this.vault.getMarkdownFiles())this.#o(e.path)}onMetaChanged(e,r,n){this.#o(e.path,n)}onFileRemoved(e){bt(e)&&this.#i(e.path)}onFileRenamed(e,r){this.#i(r),bt(e)&&this.#o(e.path)}reload(){this.#r(),this.onMetaBuilt(),W.info("Note Index: Reloaded")}};de([me],Ba.prototype,"literatureNoteFolder",1);var nse=t=>t==="/"?"":t+"/";var mE=require("crypto");var Uq="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var ose=128,ps,za,ise=t=>{!ps||ps.lengthps.length&&((0,mE.randomFillSync)(ps),za=0),za+=t};var Eg=(t=21)=>{ise(t-=0);let e="";for(let r=za-t;r({filter:(e,r)=>e.nodeName==="SPAN"&&!!e.style.color,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let{color:o,colorName:i}=gE(r.style.color),s=r.firstChild,a={bgColor:null,bgColorName:null};if(s===r.lastChild&&s?.nodeName==="SPAN"&&s.style.backgroundColor){let{color:l,colorName:u}=gE(s.style.backgroundColor);a={bgColor:l,bgColorName:u}}return t.renderColored({content:e,color:o,colorName:i,...a})}}),Vq=t=>({filter:(e,r)=>e.nodeName==="SPAN"&&!!e.style.backgroundColor,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let{color:o,colorName:i}=gE(r.style.backgroundColor),s=r.parentElement;return s?.nodeName==="SPAN"&&s.style.color&&!r.nextSibling?e:t.renderColored({content:e,color:null,colorName:null,bgColor:o,bgColorName:i})}});function gE(t){if(!t)return{colorName:null,color:null};let e=nr(t).toHex().toUpperCase();return{colorName:Vm[e.substring(0,7)]??e,color:e}}var zu={cite:{pattern:/%%ZTNOTE\.CITE:([\w-]{10})%%/g,create:t=>`%%ZTNOTE.CITE:${t}%%`},annot:{pattern:/%%ZTNOTE\.ANNOT:([\w-]{10})%%/g,create:t=>`%%ZTNOTE.ANNOT:${t}%%`}},yE=class{constructor(e){Object.assign(this,e)}toString(){return this.content}},Sg=class extends fe{plugin=this.use(xe);citations=new Map;annotations=new Map;tdService=new globalThis.TurndownService({headingStyle:"atx"}).addRule("color",Kq(this.plugin.templateRenderer)).addRule("bg-color",Vq(this.plugin.templateRenderer)).addRule("highlight-imported",{filter:(e,r)=>{if(e.tagName!=="P")return!1;let[n,o,i]=e.childNodes;return n instanceof HTMLElement&&n.classList.contains("highlight")?o instanceof HTMLElement?o.classList.contains("citation"):o instanceof Text&&o.textContent?.trim()===""?i instanceof HTMLElement&&i.classList.contains("citation"):!1:!1},replacement:(e,r,n)=>{let[o,i]=r.children;for(;r.firstChild!==i;)r.removeChild(r.firstChild);r.removeChild(i);let s=Gq(o.dataset.annotation),a=r,l=Eg(10);return this.annotations.set(l,{annotationKey:s.annotationKey,citationKey:Ua(s.citationItem.uris[0]),attachementKey:Ua(s.attachmentURI),commentHTML:a.textContent?.trim()?a.innerHTML:null,inline:!1}),zu.annot.create(l)}}).addRule("citation",{filter:(e,r)=>e.classList.contains("citation")&&!!e.dataset.citation,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let o=sse(r.dataset.citation),i=Eg(10);return this.citations.set(i,{text:e,itemKeys:o.citationItems.map(({uris:[s]})=>Ua(s))}),zu.cite.create(i)}}).addRule("highlight",{filter:(e,r)=>e.classList.contains("highlight")&&!!e.dataset.annotation,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let o=Gq(r.dataset.annotation),i=Eg(10);return this.annotations.set(i,{annotationKey:o.annotationKey,citationKey:Ua(o.citationItem.uris[0]),attachementKey:Ua(o.attachmentURI),commentHTML:null,inline:!0}),zu.annot.create(i)}});onload(){}async normalizeNotes(e){let r=[];for(let{note:n,...o}of e)r.push(new yE({...o,content:n?await this.turndown(n):"",note:n}));return r}async turndown(e){this.citations.clear(),this.annotations.clear();let r=this.tdService.turndown(e),n={citations:[...this.citations.values()].flatMap(c=>c.itemKeys),annotations:[...this.annotations.values()].map(c=>c.citationKey)},o=new Set([...this.annotations.values()].map(c=>c.attachementKey)),i=this.plugin.settings.libId,s=ase([...n.citations,...n.annotations]),a=await this.plugin.databaseAPI.getItems(s.map(c=>[c,i])).then(async c=>{let f=new Map;for(let p=0;pc?[c.item.itemID,...[...c.annotations.values()].map(f=>f.itemID)]:[]).map(c=>[c,i])),u=r.replaceAll(zu.cite.pattern,(c,f)=>{let p=this.citations.get(f),d=p.itemKeys.map(b=>{let y=a.get(b);if(!y)throw W.error("citation not found, key: ",b,p),new Error(`citation not found: key ${b}`);return{allAttachments:y.attachments,annotations:[],docItem:y.item,attachment:null,tags:l,notes:[]}});return this.plugin.templateRenderer.renderCitations(d,{plugin:this.plugin})}).replaceAll(zu.annot.pattern,(c,f)=>{let p=this.annotations.get(f),d=a.get(p.citationKey);if(!d)throw W.error("citation not found, key:",f,p),new Error(`citation key not found: ${f}`);let h=d.annotations.get(p.annotationKey);if(!h)throw W.error("annotation not found, key: ",p.annotationKey,p),new Error(`annotation key not found: ${p.annotationKey}`);let b=this.plugin.templateRenderer.renderAnnot({...h,ztnote:{comment:p.commentHTML,get commentMd(){return p.commentHTML?(0,Zq.htmlToMarkdown)(p.commentHTML):""},inline:p.inline}},{allAttachments:d.attachments,annotations:[...d.annotations.values()],attachment:d.attachments.find(y=>y.itemID===h.parentItemID),docItem:d.item,notes:[],tags:l},{plugin:this.plugin});return p.inline?b:` -`+b+` +<% } %>`)})),f.preventDefault(),u.showAtMouseEvent(f.nativeEvent)},style:{cursor:"context-menu"}},children:[t[0],": "]})},Eq=t=>"it"+t.map(tse).reverse().join(""),_q=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,tse=t=>typeof t=="number"?`[${t}]`:_q.test(t)?`.${t}`:`[${JSON.stringify(t)}]`;a();var rse=new Set(["sortIndex"]),nse=new Set(["creators","tags"]),ose=new Set(["position"]),Tq=(t,e,r)=>{let n=t[0];return rse.has(n)||nse.has(n)&&Array.isArray(e)&&e.length>6?!1:!!(ose.has(n)||r<1||r<2&&Array.isArray(e)&&e.length>1)};a();a();var ise={grad:.9,turn:360,rad:360/(2*Math.PI)},io=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},ct=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=Math.pow(10,e)),Math.round(r*t)/r+0},kr=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=1),t>r?r:t>e?t:e},Fq=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Oq=function(t){return{r:kr(t.r,0,255),g:kr(t.g,0,255),b:kr(t.b,0,255),a:kr(t.a)}},dE=function(t){return{r:ct(t.r),g:ct(t.g),b:ct(t.b),a:ct(t.a,3)}},sse=/^#([0-9a-f]{3,8})$/i,yg=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Mq=function(t){var e=t.r,r=t.g,n=t.b,o=t.a,i=Math.max(e,r,n),s=i-Math.min(e,r,n),c=s?i===e?(r-n)/s:i===r?2+(n-e)/s:4+(e-r)/s:0;return{h:60*(c<0?c+6:c),s:i?s/i*100:0,v:i/255*100,a:o}},$q=function(t){var e=t.h,r=t.s,n=t.v,o=t.a;e=e/360*6,r/=100,n/=100;var i=Math.floor(e),s=n*(1-r),c=n*(1-(e-i)*r),l=n*(1-(1-e+i)*r),f=i%6;return{r:255*[n,c,s,s,l,n][f],g:255*[l,n,n,c,s,s][f],b:255*[s,s,l,n,n,c][f],a:o}},Cq=function(t){return{h:Fq(t.h),s:kr(t.s,0,100),l:kr(t.l,0,100),a:kr(t.a)}},kq=function(t){return{h:ct(t.h),s:ct(t.s),l:ct(t.l),a:ct(t.a,3)}},Aq=function(t){return $q((r=(e=t).s,{h:e.h,s:(r*=((n=e.l)<50?n:100-n)/100)>0?2*r/(n+r)*100:0,v:n+r,a:e.a}));var e,r,n},Gu=function(t){return{h:(e=Mq(t)).h,s:(o=(200-(r=e.s))*(n=e.v)/100)>0&&o<200?r*n/100/(o<=100?o:200-o)*100:0,l:o/2,a:e.a};var e,r,n,o},ase=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,cse=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,lse=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,use=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Rq={string:[[function(t){var e=sse.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?ct(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?ct(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=lse.exec(t)||use.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Oq({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=ase.exec(t)||cse.exec(t);if(!e)return null;var r,n,o=Cq({h:(r=e[1],n=e[2],n===void 0&&(n="deg"),Number(r)*(ise[n]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return Aq(o)},"hsl"]],object:[[function(t){var e=t.r,r=t.g,n=t.b,o=t.a,i=o===void 0?1:o;return io(e)&&io(r)&&io(n)?Oq({r:Number(e),g:Number(r),b:Number(n),a:Number(i)}):null},"rgb"],[function(t){var e=t.h,r=t.s,n=t.l,o=t.a,i=o===void 0?1:o;if(!io(e)||!io(r)||!io(n))return null;var s=Cq({h:Number(e),s:Number(r),l:Number(n),a:Number(i)});return Aq(s)},"hsl"],[function(t){var e=t.h,r=t.s,n=t.v,o=t.a,i=o===void 0?1:o;if(!io(e)||!io(r)||!io(n))return null;var s=function(c){return{h:Fq(c.h),s:kr(c.s,0,100),v:kr(c.v,0,100),a:kr(c.a)}}({h:Number(e),s:Number(r),v:Number(n),a:Number(i)});return $q(s)},"hsv"]]},Nq=function(t,e){for(var r=0;r=.5},t.prototype.toHex=function(){return e=dE(this.rgba),r=e.r,n=e.g,o=e.b,s=(i=e.a)<1?yg(ct(255*i)):"","#"+yg(r)+yg(n)+yg(o)+s;var e,r,n,o,i,s},t.prototype.toRgb=function(){return dE(this.rgba)},t.prototype.toRgbString=function(){return e=dE(this.rgba),r=e.r,n=e.g,o=e.b,(i=e.a)<1?"rgba("+r+", "+n+", "+o+", "+i+")":"rgb("+r+", "+n+", "+o+")";var e,r,n,o,i},t.prototype.toHsl=function(){return kq(Gu(this.rgba))},t.prototype.toHslString=function(){return e=kq(Gu(this.rgba)),r=e.h,n=e.s,o=e.l,(i=e.a)<1?"hsla("+r+", "+n+"%, "+o+"%, "+i+")":"hsl("+r+", "+n+"%, "+o+"%)";var e,r,n,o,i},t.prototype.toHsv=function(){return e=Mq(this.rgba),{h:ct(e.h),s:ct(e.s),v:ct(e.v),a:ct(e.a,3)};var e},t.prototype.invert=function(){return ar({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),ar(mE(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),ar(mE(this.rgba,-e))},t.prototype.grayscale=function(){return ar(mE(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),ar(Dq(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),ar(Dq(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?ar({r:(r=this.rgba).r,g:r.g,b:r.b,a:e}):ct(this.rgba.a,3);var r},t.prototype.hue=function(e){var r=Gu(this.rgba);return typeof e=="number"?ar({h:e,s:r.s,l:r.l,a:r.a}):ct(r.h)},t.prototype.isEqual=function(e){return this.toHex()===ar(e).toHex()},t}(),ar=function(t){return t instanceof Pq?t:new Pq(t)};var pse=/^#(?:[\dA-F]{3}){1,2}$|^#(?:[\dA-F]{4}){1,2}$/i,dse=t=>{let e=ar(t),{r,g:n,b:o}=e.rgba;return r*.299+n*.587+o*.114>186},Lq=(t,e,...r)=>{if(typeof e=="string"&&pse.test(e))return g("span",{style:{backgroundColor:e,padding:"0 0.5em",color:dse(e)?"black":"white"},children:e});let n;return r[0]==="linkMode"&&typeof e=="number"&&(n=Hd[e]),r[0]==="type"&&typeof e=="number"&&(r.length===2&&Ne[e]?n=Ne[e]:r.length===4&&typeof r[1]=="number"&&r[2]==="tags"&&Hi[e]&&(n=Hi[e])),n?g(L,{children:[t," ",g("span",{children:["(",n,")"]})]}):t};var jq=()=>document.body.classList.contains("theme-dark"),mse={scheme:"Solarized Light",author:"Ethan Schoonover (modified by aramisgithub)",base00:"transparent",base01:"#eee8d5",base02:"#93a1a1",base03:"#839496",base04:"#657b83",base05:"#586e75",base06:"#073642",base07:"#002b36",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"},hse={scheme:"Solarized Dark",author:"Ethan Schoonover (modified by aramisgithub)",base00:"transparent",base01:"#073642",base02:"#586e75",base03:"#657b83",base04:"#839496",base05:"#93a1a1",base06:"#eee8d5",base07:"#fdf6e3",base08:"#dc322f",base09:"#cb4b16",base0A:"#b58900",base0B:"#859900",base0C:"#2aa198",base0D:"#268bd2",base0E:"#6c71c4",base0F:"#d33682"};function gE({item:t,registerCssChange:e}){let[r,n]=q(()=>jq());return K(()=>e?.(()=>n(jq())),[e]),t?g(vq,{data:t,theme:r?hse:mse,invertTheme:!1,keyPath:["Zotero Item Data"],shouldExpandNodeInitially:Tq,valueRenderer:Lq,labelRenderer:Iq,getItemString:xq}):g("div",{children:"No Details Available"})}a();var qq=require("obsidian");var bg=t=>({plugin:t,sourcePath:""});function gse(){return bu((t,e)=>({preview:null,templateType:null,setTemplateType(r){t(n=>({...n,templateType:r||void 0}))},setPreview(r){t(({...n})=>({...n,preview:r??null}))},async setPreviewFromState(r,n){let o=e().preview;if(o?.docItem.itemID===r?.docItem&&o?.attachment?.itemID===r?.attachment&&o?.annot?.itemID===r?.annot)return!1;let i=n.database.settings.libId;if(!r.docItem)return console.error("TemplatePreview: no docItem provided"),!1;let[s]=await n.databaseAPI.getItems([[r.docItem,i]]);if(!s)return console.error("TemplatePreview: no docItem found for id "+r.docItem),!1;let c=await n.databaseAPI.getAttachments(r.docItem,i),l=c.find(h=>h.itemID===r.attachment)??null;r.attachment&&!l&&console.error("TemplatePreview: no attachment found for id "+r.attachment);let f=l?await n.databaseAPI.getAnnotations(l.itemID,i):[],u=f.find(h=>h.itemID===r.annot);r.annot&&!u&&console.error("TemplatePreview: no annotation found for id "+r.annot);let d=await n.databaseAPI.getTags([[r.docItem,i],...f.map(h=>[h.itemID,i])]),m;try{m=await n.databaseAPI.getNotes(s.itemID,i).then(h=>n.noteParser.normalizeNotes(h))}catch(h){console.error(h),m=[]}return t(()=>({preview:{docItem:s,allAttachments:c,annotations:f,attachment:l,tags:d,annot:f.find(h=>h.itemID===r.annot),notes:m}})),!0}}))}function Bq(t,e){let r=null,n=null,o=null;return function(...i){if(r&&window.clearTimeout(r),n){o=i;return}r=window.setTimeout(()=>{r=null,n=t(...i).then(()=>{o?n=t(...o):n=null}).catch(s=>{console.error(s),n=null})},e)}}var Ua=class extends qq.FileView{constructor(r,n){super(r);this.plugin=n;this.store=gse()}store;canAcceptExtension(r){return r==="md"}getTemplateType(r){if(!r)return!1;let n=St(r.path,this.plugin.settings.templateDir);return n?.type!=="ejectable"?!1:n.name}setTemplateType(r){this.store.getState().setTemplateType(r)}async onLoadFile(r){await super.onLoadFile(r),this.setTemplateType(this.getTemplateType(r))}getState(){let r=super.getState(),{preview:n}=this.store.getState(),o;if(!n)o={preview:null};else{let{docItem:i,attachment:s,annot:c}=n;o={preview:{docItem:i.itemID,attachment:s?.itemID,annot:c?.itemID}}}return{...r,...o}}async setState(r,n){if(await super.setState(r,n),r.preview===void 0)return;let o=this.store.getState();r.preview===null?o.setPreview(null):await o.setPreviewFromState(r.preview,this.plugin)}setPreview(r){this.store.getState().setPreview(r)}async onOpen(){await super.onOpen();let[r,n]=Ls(this.plugin);n&&this.register(n),await r}};var Wa="zotero-item-details",zq=({templateType:t})=>t==="annotation"?t:"note",vg=class extends Ua{getViewType(){return Wa}getDisplayText(){let e=this.store.getState();return e.templateType?"Zotero Item Details: "+zq(e):"Zotero Item Details"}async onOpen(){await super.onOpen();let[e,r]=Ls(this.plugin);r&&this.register(r),await e,P.render(g(yse,{store:this.store,plugin:this.plugin}),this.contentEl)}async onClose(){P.unmountComponentAtNode(this.contentEl),await super.onClose()}};function yse({store:t,plugin:e}){let r=Ut(t,zq),n=Ut(t,i=>i.preview),o=ae(()=>{let i=bg(e);if(!n)return null;switch(r){case"note":{let s=zt(n,i);return s.docItem.annotations=void 0,s.docItem}case"annotation":{let s=zt(n,i),c=n.annot?s.annotations.find(l=>l.itemID===n.annot?.itemID):s.annotations[0];return c?(c.docItem=void 0,c):null}default:throw new Error("Unsupported template type")}},[e,n,r]);return o?g(gE,{item:o,registerCssChange:i=>(e.app.workspace.on("css-change",i),()=>e.app.workspace.off("css-change",i))}):g("div",{})}a();var Uq=Y(Ms(),1),Ar=require("obsidian");var Ha="zotero-template-preview",wg=class extends Ua{getViewType(){return Ha}getDisplayText(){let e=this.store.getState().templateType;return e?"Zotero Template Preview: "+e:"Zotero Template Preview"}async switchToTemplate(e){if(!this.leaf.group)return!1;let r=Wq(this.leaf.group,this.plugin);if(!r)return!1;let n=bE(e,this.plugin.settings.templateDir,this.app);if(!n||!(n instanceof Ar.TFile)){new Ar.Notice("Template file not found: "+e);return}return await r.openFile(n),!0}onload(){let e={annots:this.addAction("list-ordered","Open Template for Annotations",async()=>await this.switchToTemplate("annots")||new Ar.Notice("Cannot switch to template")),note:this.addAction("file-input","Open Note Template",async()=>await this.switchToTemplate("note")||new Ar.Notice("Cannot switch to template")),annotation:this.addAction("highlighter","Open Template for Single Annotation",async()=>await this.switchToTemplate("annotation")||new Ar.Notice("Cannot switch to template")),field:this.addAction("info","Open Template for Note Properties",async()=>await this.switchToTemplate("field")||new Ar.Notice("Cannot switch to template"))};Object.values(e).forEach(r=>r.hide()),this.register(this.store.subscribe((r,n)=>{if(r.templateType!==n.templateType)for(let[o,i]of Object.entries(e))i.toggle(o!==r.templateType)})),this.registerEvent(this.app.vault.on("zotero:template-updated",r=>{let n=this.getTemplateType(this.file);n&&r===n&&(this.setTemplateType(n),this.requestRender())}))}content=null;async render(){let{preview:e,templateType:r}=this.store.getState();if(!r){this.contentEl.empty(),this.contentEl.setText("No template preview available");return}if(!e){this.contentEl.empty(),this.contentEl.setText("No preview data available");return}let n="",o=bg(this.plugin),i=this.plugin.templateRenderer;try{switch(r){case"annotation":{let l=e.annot??e.annotations[0];if(!l){this.contentEl.setText("No annotation data available");return}n=i.renderAnnot(l,e,o);break}case"annots":n=i.renderAnnots(e,o);break;case"note":n=i.renderNote(e,o);break;case"field":n=i.renderFrontmatter(e,o);break;case"cite":n=i.renderCitations([e],o);break;case"cite2":n=i.renderCitations([e],o,!0);break;case"colored":n=i.renderColored({content:"I'm Highlight",color:"#FF000080",colorName:"red",bgColor:"#FF000080",bgColorName:"red"});break;default:(0,Uq.assertNever)(r)}if(n===this.content?.markdown)return;this.content?.unload(),this.contentEl.empty();let s=await(0,Ar.loadPrism)(),c=s.highlight(n,s.languages.markdown,"markdown");this.content=new yE(n),this.contentEl.createEl("pre").createEl("code",{cls:"language-markdown"}).innerHTML=c}catch(s){this.content?.unload(),this.contentEl.empty();let c=s instanceof Error?s.message:String(s);this.contentEl.createEl("h1",{text:`Error while rendering ${r}`,cls:["mod-error","message"]}),this.contentEl.createEl("pre",{text:c})}}requestRender=Bq(()=>this.render(),200);async onOpen(){await super.onOpen(),this.register(this.store.subscribe((e,r)=>{e.templateType!==r.templateType?this.requestRender():e.preview!==r.preview&&this.requestRender()}))}},yE=class extends Ar.Component{constructor(r){super();this.markdown=r}};async function hs(t,e,{app:r,settings:n}){let{workspace:o}=r,i=bE(t,n.templateDir,r);if(!i||!(i instanceof ms.TFile)){new ms.Notice("Template file not found: "+t);return}let s=o.getLeavesOfType("markdown").filter(u=>{let d=u.view;return d.file?St(d.file.path,n.templateDir)?.type==="ejectable"&&u.getRoot().type==="floating":!1});if(s.length>0){let u=s[0];if(await u.openFile(i),!u.group)return;let d=o.getGroupLeaves(u.group);for(let m of d){let h=m.view.getViewType();if(h===Ha||h===Wa){let y=m.view.getState();await m.view.setState({...y,preview:e},{})}}return}let c=o.openPopoutLeaf(),l=o.createLeafBySplit(c,"vertical"),f=o.createLeafBySplit(l,"vertical");await Promise.all([c.openFile(i,{active:!0}),l.setViewState({type:Ha,state:{file:i.path,preview:e},group:c}),f.setViewState({type:Wa,state:{file:i.path,preview:e},group:c})])}function bE(t,e,r){let n=bi(t,e),o=r.vault.getAbstractFileByPath(n);return o instanceof ms.TFile?o:null}function Wq(t,e){return e.app.workspace.getGroupLeaves(t).find(n=>n.view instanceof ms.MarkdownView&&n.view.file&&St(n.view.file.path,e.settings.templateDir)?.type==="ejectable")}a();var Hq=t=>(e,r,n)=>{let{imgCacheImporter:o}=t,i=String(e.timeStamp),s="drag-source";e.dataTransfer.setData("text/plain",r()),e.dataTransfer.setData(s,i),e.dataTransfer.dropEffect="copy";let c=e.target.win,{workspace:l}=t.app,f=m=>{m.dataTransfer?.getData(s)===i&&o.flush(),l.off("editor-drop",f),c.removeEventListener("dragend",u)},u=()=>{o.cancel(),l.off("editor-drop",f)},d=l.on("editor-drop",m=>{m.dataTransfer?.getData("drag-source")===i&&o.flush(),l.offref(d)});c.addEventListener("dragend",u,{once:!0}),n&&e.dataTransfer.setDragImage(n,0,0)},Kq=t=>({storeSelector:e=>sm(e,["doc","attachment","allAttachments","tags","annotations"]),get:(e,{allAttachments:r,attachment:n,doc:o,tags:i,annotations:s})=>!r||!n||!o||!i[e.itemID]||!s?null:()=>{let c=t.app.workspace.getActiveFile(),l=c&&wt(c)?c.path:null;return t.templateRenderer.renderAnnot(e,{tags:i,attachment:n,allAttachments:r,annotations:s,docItem:o.docItem,notes:[]},{plugin:t,sourcePath:l,merge:!1})}});a();var Ka=require("obsidian");var Vq=t=>(e,r)=>{let n=new Ka.Menu;if(n.addItem(o=>o.setTitle("Jump to note").setIcon("links-going-out").onClick(bse(r,t))),t.app.workspace.trigger("zotero:open-annot-menu",r,n),e.nativeEvent instanceof MouseEvent)n.showAtMouseEvent(e.nativeEvent);else{let o=e.currentTarget.getBoundingClientRect();n.showAtPosition({x:o.left,y:o.bottom})}},bse=(t,e)=>async()=>{let r=e.app.workspace.getActiveFile(),n=r&&wt(r)?r.path:void 0,o=e.plugin.noteIndex.getBlocksFor({item:t,file:n}).shift();if(!o){new Ka.Notice("No embed for this annotation in current note");return}let i=o.blocks.sort((m,h)=>{let y=m.start.offset-h.start.offset;return y!==0?y:m.end.offset-h.end.offset})[0];await sleep(10);let{leaf:s}=e,{workspace:c,vault:l}=e.app,f;if(s.group)f=c.getGroupLeaves(s.group);else{f=[];let m=c.getActiveFileView();m&&f.push(m.leaf)}let u=!1,d=i.end.line+1;for(let m of f)m&&m.view instanceof Ka.MarkdownView&&m.view.file?.path===o.file&&(m.view.setEphemeralState({line:d}),u=!0);if(!u){let m=l.getAbstractFileByPath(o.file);if(!m||!wt(m))throw new Error("File from block info not found: "+o.file);c.getLeaf().openFile(m,{eState:{line:d}})}};a();var Gq=(t,e)=>e.length===0?null:t?e.find(r=>r.itemID===t)??e[0]:e[0],xg=()=>({doc:null,allAttachments:null,attachmentID:null,annotations:null,attachment:null,tags:{}}),vse=()=>({follow:"zt-reader",doc:null,allAttachments:null,attachmentID:null,annotations:null,attachment:null,tags:{}}),Zu=t=>t.databaseAPI,Zq=t=>bu((e,r)=>{let n=async(s,c)=>{let l=(await Zu(t).getAttachments(s,c)).filter(jl);e(f=>({...f,allAttachments:l,attachment:Gq(f.attachmentID,l)}))},o=async(s,c)=>{let l=await Zu(t).getTags([[s,c]]);return e(f=>({...f,tags:l})),l},i=async s=>{let{attachment:c}=r();if(!c)return;let l=await Zu(t).getAnnotations(c.itemID,s),f=z0(l);e(m=>({...m,annotations:U0(f),attachment:c}));let u=await Zu(t).getTags(l.map(m=>[m.itemID,s])),d=W0(f,u);e(m=>({...m,tags:{...m.tags,...d}}))};return{...vse(),loadDocItem:async(s,c,l,f=!1)=>{if(s<0)return e(xg());if(r().doc?.docItem.itemID===s&&!f)return;let u=(await Zu(t).getItems([[s,l]]))[0];if(!u)return e(xg());let d={docItem:u,lib:l};if(c<0){let m=F0(window.localStorage,u);e({...xg(),doc:d,attachmentID:m})}else ba(window.localStorage,u,c),e({...xg(),doc:d,attachmentID:c});await n(u.itemID,l),await o(u.itemID,l),await i(l)},refresh:async()=>{let{doc:s,attachment:c}=r();if(!s)return;let{docItem:l,lib:f}=s;await n(l.itemID,f),await o(l.itemID,f),c&&await i(f)},setActiveAtch:s=>{let{doc:c,allAttachments:l}=r();if(c)if(ba(window.localStorage,c.docItem,s),!l)e(f=>({...f,attachment:null,attachmentID:s}));else{let f=Gq(s,l);e(u=>({...u,attachment:f,attachmentID:s}))}},setFollow:s=>e({follow:s})}});var Ig="zotero-annotation-view",Eg=class extends bh{constructor(r,n){super(r);this.plugin=n;this.store=Zq(n)}update(){if(this.follow!=="ob-note")return;let r=this.plugin.settings.libId;(async()=>{if(this.file?.extension!=="md")return!1;let n=ns(this.file,this.app.metadataCache),o=os(this.file,this.app.metadataCache);if(!n)return!1;let[i]=await this.plugin.databaseAPI.getItems([[n,r]]);return i?(this.setStatePrev(s=>({...s,follow:"ob-note",itemId:i.itemID,attachmentId:o?.[0]??void 0})),!0):!1})().then(n=>{n||this.setStatePrev(o=>({...o,follow:"ob-note",itemId:-1}))})}getViewType(){return Ig}#e=null;onload(){super.onload(),this.contentEl.addClass("obzt");let r=null,n=!1,o=i=>{if(n)r=i;else{n=!0;let{itemId:s,attachmentId:c}=i;this.setStatePrev(l=>({...l,itemId:s,attachmentId:c})).then(()=>{if(n=!1,r===null)return;let l=r;r=null,o(l)})}};this.registerEvent(this.plugin.server.on("bg:notify",(i,s)=>{s.event==="reader/active"&&(this.#e=s.itemId,!(this.follow!=="zt-reader"||s.itemId<0||s.attachmentId<0)&&o(s))}))}getDisplayText(){return this.follow!=="ob-note"||!this.file?.basename?"Zotero Annotations":`Zotero Annotations for ${this.file.basename}`}getIcon(){return"highlighter"}get lib(){return this.plugin.settings.libId}store;get follow(){return this.store.getState().follow}getState(){let r=super.getState(),n=this.store.getState(),o={itemId:n.doc?.docItem.itemID??-1,attachmentId:n.attachment?.itemID??-1,follow:n.follow};return{...r&&typeof r=="object"?r:{},...o}}async setState(r,n){await super.setState(r,n??{});let{itemId:o=-1,attachmentId:i=-1,follow:s="zt-reader"}=r;this.store.getState().setFollow(s),await this.store.getState().loadDocItem(o,i,this.lib)}async setStatePrev(r){await this.setState(r(this.getState()))}onSetFollowZt=async()=>{this.setStatePrev(r=>({...r,follow:"zt-reader"})),await this.setStatePrev(({attachmentId:r,...n})=>({...n,follow:"zt-reader",...this.#e===null?{attachmentId:r}:{itemId:this.#e}}))};onSetFollowOb=()=>{this.store.getState().setFollow("ob-note"),this.update()};onSetFollowNull=async()=>{let{plugin:r}=this,n=await Ih(r);if(!n)return;let{itemID:o}=n.value.item,i=r.settings.libId,s=await r.databaseAPI.getAttachments(o,i),c=await Zn(s,this.app);await this.setStatePrev(({attachmentId:l,...f})=>({...f,follow:null,itemId:o,attachmentId:c?.itemID}))};getContext(){let r=this,{plugin:n,store:o,app:i}=r;return{store:o,registerDbUpdate(s){return i.vault.on("zotero:db-refresh",s),()=>i.vault.off("zotero:db-refresh",s)},refreshConn:async()=>{await n.dbWorker.refresh({task:"dbConn"})},getImgSrc:s=>{let c=zo(s,n.settings.current?.zoteroDataDir);return wse(c)},onShowDetails:async(s,c)=>{let l=o.getState(),f=l.attachmentID??void 0;if(s==="doc-item")await hs("note",{docItem:c,attachment:f},n);else{let u=l.doc?.docItem.itemID;if(!u)throw new Error("Missing doc item when showing annotation details");await hs("annotation",{docItem:u,attachment:f,annot:c},n)}},onDragStart:Hq(n),onMoreOptions:Vq(r),annotRenderer:Kq(n),onSetFollow(s){let c=new Sg.Menu,l=o.getState().follow;if(l!=="zt-reader"&&c.addItem(f=>f.setIcon("book").setTitle("Follow active literature in Zotero reader").onClick(r.onSetFollowZt)),l!=="ob-note"&&c.addItem(f=>f.setIcon("file-edit").setTitle("Follow active literature note").onClick(r.onSetFollowOb)),c.addItem(f=>f.setIcon("file-lock-2").setTitle("Link with selected literature").onClick(async()=>{s.target.blur(),await r.onSetFollowNull()})),s.nativeEvent instanceof MouseEvent)c.showAtMouseEvent(s.nativeEvent);else{let u=s.target.getBoundingClientRect();c.showAtPosition({x:u.x,y:u.y})}}}}async onOpen(){await super.onOpen();let[r,n]=Ls(this.plugin);n&&this.register(n),this.contentEl.empty(),this.contentEl.createDiv({cls:"pane-empty p-2",text:"Loading..."}),r.then(()=>{this.contentEl.empty(),P.render(g(Zo.Provider,{value:Cj,children:g(Je.Provider,{value:this.getContext(),children:g(Eu,{})})}),this.contentEl)}).catch(o=>{this.contentEl.empty(),console.error("Failed to load annot view: ",o),this.contentEl.createDiv({cls:"pane-empty p-2",text:"Failed to load, Check console for details"})}),this.registerEvent(this.plugin.server.on("bg:notify",(o,i)=>{if(i.event!=="reader/annot-select")return;let s=i.updates.filter(([,l])=>l).pop();if(!s)return;let[c]=s;this.highlightAnnot(c)}))}async onClose(){P.unmountComponentAtNode(this.contentEl),await super.onClose()}async highlightAnnot(r){let n=this.contentEl.querySelector(`.annot-preview[data-id="${r}"]`);n instanceof HTMLElement&&(n.addClass("select-flashing"),n.scrollIntoView({behavior:"smooth",block:"center"}),await sleep(1500),n.removeClass("select-flashing"))}};function wse(t){return(Sg.Platform.resourcePathPrefix??"app://local/")+(0,Jq.pathToFileURL)(t).pathname.substring(1)+`?${Date.now()}`}a();var Yq=require("path/posix");var _g=require("obsidian");var xse=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to continue select note to import"},{command:"esc",purpose:"to dismiss"}],vE=class extends ro{constructor(r){super(r);this.plugin=r;this.setInstructions(xse)}};async function Xq(t){let e=await Gi(new vE(t));if(!e)return!1;let{value:{item:r}}=e,n=await t.databaseAPI.getNotes(r.itemID,t.settings.libId);if(n.length===0)return new _g.Notice("No note found for selected literature"),!1;let o=await DS(n,u=>u.title??u.note?.substring(0,20)??`No title (Key ${u.key})`);if(!o.item)return!1;let i=o.item;if(!i.note)return new _g.Notice("Selected note is empty"),!1;let s=await t.noteParser.turndown(i.note),c=t.settings.current?.literatureNoteFolder,l=(0,Yq.join)(c,"zt-import",ts(i.title??[i.note.substring(0,10),i.key].join("_"),{replacement:"_"})),f=await t.app.fileManager.createNewMarkdownFile(t.app.vault.getRoot(),l,s);return await t.app.workspace.openLinkText(f.path,"",!0),new _g.Notice(`Note imported: ${i.title??i.key}`),!0}a();var Sn=require("obsidian");var Tg=class extends de{plugin=this.use(Ie);onload(){this.registerEvent(this.plugin.server.on("zotero/open",e=>this.onZtOpen(Kf(e)))),this.registerEvent(this.plugin.server.on("zotero/export",e=>this.onZtExport(Kf(e)))),this.registerEvent(this.plugin.server.on("zotero/update",e=>this.onZtExport(Kf(e))))}async onZtOpen(e){if(e.type==="annotation"){new Sn.Notice("Not implemented yet");return}if(e.items.length<1){new Sn.Notice("No items to open");return}await this.plugin.noteFeatures.openNote(e.items[0])}async onZtUpdate(e){if(e.type==="annotation"){new Sn.Notice("Single annotation update not yet supported");return}if(e.items.length<1){new Sn.Notice("No items to open");return}if(e.items.length>1){new Sn.Notice("Multiple literature note update not yet supported");return}await this.plugin.noteFeatures.updateNoteFromId(e.items[0])}async onZtExport(e){if(e.type==="annotation"){new Sn.Notice("Not implemented yet");return}e.items.length<1?new Sn.Notice("No items to open"):e.items.length>1&&new Sn.Notice("Multiple items not yet supported");let{libraryID:r,id:n}=e.items[0],[o]=await this.plugin.databaseAPI.getItems([[n,r]]);if(!o){new Sn.Notice("Item not found: "+n);return}let i=await this.plugin.noteFeatures.createNoteForDocItemFull(o);await this.plugin.app.workspace.openLinkText(i,"",!1,{active:!0})}};a();a();var Qq=require("obsidian");var Ese=[{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to open/create literature note"},{command:"esc",purpose:"to dismiss"}],wE=class extends ro{constructor(r){super(r);this.plugin=r;this.setInstructions(Ese)}};async function xE(t){let e=await Gi(new wE(t));if(!e)return!1;let{value:{item:r},evt:n}=e;if(await t.noteFeatures.openNote(r,!0))return!0;let o=await t.noteFeatures.createNoteForDocItemFull(r);return await t.app.workspace.openLinkText(o,"",Qq.Keymap.isModEvent(n),{active:!0}),!0}var EE=class extends de{plugin=this.use(Ie);protocol=this.use(Tg);onload(){let{plugin:e}=this,{app:r}=e;e.addCommand({id:"note-quick-switcher",name:"Open quick switcher for literature notes",callback:()=>xE(e)}),e.registerView(Ig,o=>new Eg(o,e)),e.registerView(Ha,o=>new wg(o,e)),e.registerView(Wa,o=>new vg(o,e)),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{let s=St(i.path,e.settings.templateDir);s?.type==="ejectable"&&o.addItem(c=>c.setIcon("edit").setTitle("Open template preview").onClick(()=>{hs(s.name,null,e)}))})),e.addCommand({id:"zotero-annot-view",name:"Open Zotero annotation view in side panel",callback:()=>{r.workspace.ensureSideLeaf(Ig,"right",{active:!0,state:{file:r.workspace.getActiveFile()?.path}})}}),e.addCommand({id:"insert-markdown-citation",name:"Insert Markdown citation",editorCallback:(o,i)=>Wx(o,i.file,e)}),e.registerEditorSuggest(new Cu(e));let n=async(o,i)=>{let s=e.settings.libId,c=ns(o,r.metadataCache);if(!c)return new so.Notice("Cannot get zotero item key from file name"),!1;let[l]=await e.databaseAPI.getItems([[c,s]]);if(!l)return new so.Notice("Cannot find zotero item with key "+c),!1;await this.updateNote(l,i)};e.addCommand({id:"update-literature-note",name:"Update literature note",editorCheckCallback(o,i,s){let c=s.file&&yu(s.file,r);if(o)return!!c;c&&n(s.file)}}),e.addCommand({id:"overwrite-update-literature-note",name:"Force update literature note by overwriting",editorCheckCallback(o,i,s){let c=s.file&&yu(s.file,r);if(o)return!!c;c&&n(s.file,!0)}}),e.addCommand({id:"import-note",name:"Import note",callback:()=>Xq(e)}),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{yu(i,r)&&(o.addItem(s=>s.setTitle("Update literature note").setIcon("sync").onClick(()=>n(i))),e.settings.current?.updateOverwrite||o.addItem(s=>s.setTitle("Force update by overwriting").setIcon("sync").onClick(()=>n(i,!0))))})),e.registerEvent(e.app.workspace.on("file-menu",(o,i)=>{let s=St(i.path,e.settings.templateDir);s?.type==="ejectable"&&o.addItem(c=>c.setTitle("Reset to default").setIcon("reset").onClick(async()=>{activeWindow.confirm("Reset template to default?")&&await e.app.vault.modify(i,ht.Ejectable[s.name])}))}))}async openNote(e,r=!1){let{workspace:n}=this.plugin.app,{noteIndex:o}=this.plugin,i=o.getNotesFor(e);if(!i.length)return!r&&new so.Notice(`No literature note found for zotero item with key ${e.key}`),!1;let s=i.sort().shift();return await n.openLinkText(s,"",!1,{active:!0}),!0}async createNoteForDocItem(e,r){let{noteIndex:n}=this.plugin,o=n.getNotesFor(e);if(o.length)throw new Og(o,e.key);let{vault:i,fileManager:s}=this.plugin.app,{literatureNoteFolder:c}=this.plugin.settings.current,l=this.plugin.templateRenderer,f=(0,eB.join)(c,r.filename(l,{plugin:this.plugin})),u=i.getAbstractFileByPath(f);if(u&&ns(u,this.plugin.app.metadataCache))throw new Og([f],e.key);return await s.createNewMarkdownFile(i.getRoot(),f,r.note(l,{plugin:this.plugin,sourcePath:f}))}async createNoteForDocItemFull(e){let r=this.plugin.settings.libId,n=await this.plugin.databaseAPI.getAttachments(e.itemID,r),o=await Zn(n,this.plugin.app);o&&Ea(o,e);let i=await this.plugin.databaseAPI.getNotes(e.itemID,r).then(f=>this.plugin.noteParser.normalizeNotes(f)),s=await Ou(e,{all:n,selected:o?[o]:[],notes:i},this.plugin),c=Object.values(s)[0];return(await this.createNoteForDocItem(e,{note:(f,u)=>f.renderNote(c,u),filename:(f,u)=>f.renderFilename(c,u)})).path}async updateNoteFromId(e){let{noteIndex:r,databaseAPI:n}=this.plugin;if(!r.getNotesFor(e).length){new so.Notice(`No literature note found for zotero item with key ${e.key}`);return}let[i]=await n.getItems([[e.key,e.libraryID]]);if(!i){new so.Notice(`Cannot find zotero item with key ${e.key}`);return}await this.updateNote(i)}async updateNote(e,r){let n=await Rj(e,this.plugin,r);n?n.addedAnnots>0||n.updatedAnnots>0?new so.Notice(`Affected ${n.notes} notes, annotations: ${n.addedAnnots} added, ${n.updatedAnnots} updated`):new so.Notice(`Affected ${n.notes} notes, no annotation updated`):new so.Notice("No note found for this literature")}},tB=EE,Og=class extends Error{constructor(r,n){super(`Note linked to ${n} already exists: ${r.join(",")}`);this.targets=r;this.key=n;this.name="NoteExistsError"}};a();var kg=require("@codemirror/language");var SE=require("obsidian");var Cg=class extends de{plugin=this.use(Ie);onload(){this.patchEditorClick()}async patchEditorClick(){let{workspace:e}=this.plugin.app,{noteIndex:r,database:n,settings:o,noteFeatures:i}=this.plugin;await lC(this.plugin.app);let s=()=>e.getLeavesOfType("markdown").length>0,[c,l]=Dc({register:u=>e.on("layout-change",()=>{s()&&u()}),unregister:u=>e.offref(u),escape:s,timeout:null});l&&this.register(l),await c;let f=e.getLeavesOfType("markdown")[0].view;this.register(cr(f.editor.constructor.prototype,{getClickableTokenAt:u=>function(d,...m){let h=u.call(this,d,...m);return h||Sse.call(this,d,r)}})),this.register(cr(f.editMode.constructor.prototype,{triggerClickableToken:u=>function(d,m){if(d.type==="internal-link"&&d.citekey==="zotero")(async()=>{let h=d.text,{[h]:y}=await n.api.getItemIDsFromCitekey([d.text]);if(y<0){new SE.Notice(`Citekey ${h} not found in Zotero`);return}let[w]=await n.api.getItems([[y,o.libId]]);if(!w){new SE.Notice(`Item not found for citekey ${h}`);return}let v=await i.createNoteForDocItemFull(w);await e.openLinkText(v,"",!0,{active:!0})})();else return u.call(this,d,m)}}))}};function Sse(t,e){let r=this.cm,n=r.state.doc,o=[],i=n.line(t.line+1),s=(0,kg.syntaxTree)(r.state),c=i.from;s.iterate({from:i.from,to:i.to,enter:w=>{let v=w.type,x=w.from,S=w.to,k=v.prop(kg.tokenClassNodeProp);k&&(c=l){f=w;break}}if(f<0)return null;let u=o[f];if(!u.type.split(" ").includes("hmd-barelink"))return null;let m=n.sliceString(u.from,u.to);if(!m.startsWith("@"))return null;let h=m.slice(1),y={start:this.offsetToPos(u.from),end:this.offsetToPos(u.to)};if(e.citekeyCache.has(h)){let[w]=e.citekeyCache.get(h);return{type:"internal-link",text:w,...y}}else return{type:"internal-link",text:h,citekey:"zotero",...y}}a();var Ag=require("obsidian");var Va=class extends de{plugin=this.use(Ie);settings=this.use(be);app=this.use(Ag.App);get meta(){return this.app.metadataCache}get vault(){return this.app.vault}get literatureNoteFolder(){return this.settings.current?.literatureNoteFolder}get joinPath(){return Ise(this.literatureNoteFolder)}noteCache=new Map;blockCache={byFile:new Map,byKey:new Map};citekeyCache=new Map;#e(e,r){let n=px(r);if(n){if(!this.noteCache.has(n))return this.noteCache.set(n,new Set([e])),!0;let i=this.noteCache.get(n),s=i.size;return i.add(e).size!==s}let o=!1;for(let[i,s]of this.noteCache.entries()){let c=s.delete(e);o||=c,c&&s.size===0&&this.noteCache.delete(i)}return o}#t(e,r){let n=l=>{let f=this.blockCache.byFile.get(l);if(!f)return!1;this.blockCache.byFile.delete(l);for(let u of f){let d=this.blockCache.byKey.get(u.key);d.delete(u),d.size===0&&this.blockCache.byKey.delete(u.key)}return!0};if(!r)return n(e);let{blocks:o,sections:i}=r;if(!i||!o)return n(e);let s=i.filter(hu);if(s.length===0)return n(e);n(e);let c=wu(s.flatMap(l=>gu(l.id).map(f=>[f,l.position])),Ki(([l])=>l),xa((l,f)=>({file:e,key:l,blocks:f.map(([u,d])=>d)})),nm);this.blockCache.byFile.set(e,c);for(let l of c){let f=this.blockCache.byKey.get(l.key);f?f.add(l):this.blockCache.byKey.set(l.key,new Set([l]))}return!0}#n(e,r){let n=r?.frontmatter?.citekey;if(n){if(!this.citekeyCache.has(n))return this.citekeyCache.set(n,new Set([e])),!0;let i=this.citekeyCache.get(n),s=i.size;return i.add(e).size!==s}let o=!1;for(let[i,s]of this.citekeyCache.entries()){let c=s.delete(e);o||=c,c&&s.size===0&&this.citekeyCache.delete(i)}return o}getNotesFor(e){let r=this.noteCache.get(lr(e,!0));return r?[...r]:[]}getBlocksFor({file:e,item:r}){if(!e&&!r)throw new Error("no file or item provided");let n=r?this.blockCache.byKey.get(lr(r,!0)):null,o=e?this.blockCache.byFile.get(e):null;return e&&r?!o||!n?[]:o.filter(i=>n.has(i)):e?o?[...o]:[]:r?n?[...n]:[]:[]}getBlocksIn(e){let r=this.blockCache.byFile.get(e);return r?[...r]:null}#o(e,r){r===void 0&&(r=this.meta.getCache(e)),[this.#e(e,r),this.#t(e,r),this.#n(e,r)].some(o=>o)&&this.meta.trigger("zotero:index-update",e)}#i(e){this.#o(e,null)}#r(){this.noteCache.clear(),this.blockCache.byFile.clear(),this.blockCache.byKey.clear(),this.meta.trigger("zotero:index-clear")}onload(){this.settings.once(()=>{[this.meta.on("changed",this.onMetaChanged,this),this.vault.on("rename",this.onFileRenamed,this),this.vault.on("delete",this.onFileRemoved,this)].forEach(this.registerEvent.bind(this));let[e,r]=cC(this.plugin.app,{});r&&this.register(r),e.then(()=>{this.onMetaBuilt(),this.plugin.addCommand({id:"refresh-note-index",name:"Refresh literature notes index",callback:()=>{this.reload(),new Ag.Notice("Literature notes re-indexed")}})})}),this.register(Ge(ft(()=>this.reload(),()=>this.literatureNoteFolder,!0)))}onMetaBuilt(){for(let e of this.vault.getMarkdownFiles())this.#o(e.path)}onMetaChanged(e,r,n){this.#o(e.path,n)}onFileRemoved(e){wt(e)&&this.#i(e.path)}onFileRenamed(e,r){this.#i(r),wt(e)&&this.#o(e.path)}reload(){this.#r(),this.onMetaBuilt(),H.info("Note Index: Reloaded")}};he([ge],Va.prototype,"literatureNoteFolder",1);var Ise=t=>t==="/"?"":t+"/";a();a();var IE=require("crypto");a();var rB="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";var _se=128,gs,Ga,Tse=t=>{!gs||gs.lengthgs.length&&((0,IE.randomFillSync)(gs),Ga=0),Ga+=t};var Rg=(t=21)=>{Tse(t-=0);let e="";for(let r=Ga-t;r({filter:(e,r)=>e.nodeName==="SPAN"&&!!e.style.color,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let{color:o,colorName:i}=TE(r.style.color),s=r.firstChild,c={bgColor:null,bgColorName:null};if(s===r.lastChild&&s?.nodeName==="SPAN"&&s.style.backgroundColor){let{color:l,colorName:f}=TE(s.style.backgroundColor);c={bgColor:l,bgColorName:f}}return t.renderColored({content:e,color:o,colorName:i,...c})}}),sB=t=>({filter:(e,r)=>e.nodeName==="SPAN"&&!!e.style.backgroundColor,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let{color:o,colorName:i}=TE(r.style.backgroundColor),s=r.parentElement;return s?.nodeName==="SPAN"&&s.style.color&&!r.nextSibling?e:t.renderColored({content:e,color:null,colorName:null,bgColor:o,bgColorName:i})}});function TE(t){if(!t)return{colorName:null,color:null};let e=ar(t).toHex().toUpperCase();return{colorName:rh[e.substring(0,7)]??e,color:e}}var Ju={cite:{pattern:/%%ZTNOTE\.CITE:([\w-]{10})%%/g,create:t=>`%%ZTNOTE.CITE:${t}%%`},annot:{pattern:/%%ZTNOTE\.ANNOT:([\w-]{10})%%/g,create:t=>`%%ZTNOTE.ANNOT:${t}%%`}},OE=class{constructor(e){Object.assign(this,e)}toString(){return this.content}},Ng=class extends de{plugin=this.use(Ie);citations=new Map;annotations=new Map;tdService=new globalThis.TurndownService({headingStyle:"atx"}).addRule("color",iB(this.plugin.templateRenderer)).addRule("bg-color",sB(this.plugin.templateRenderer)).addRule("highlight-imported",{filter:(e,r)=>{if(e.tagName!=="P")return!1;let[n,o,i]=e.childNodes;return n instanceof HTMLElement&&n.classList.contains("highlight")?o instanceof HTMLElement?o.classList.contains("citation"):o instanceof Text&&o.textContent?.trim()===""?i instanceof HTMLElement&&i.classList.contains("citation"):!1:!1},replacement:(e,r,n)=>{let[o,i]=r.children;for(;r.firstChild!==i;)r.removeChild(r.firstChild);r.removeChild(i);let s=aB(o.dataset.annotation),c=r,l=Rg(10);return this.annotations.set(l,{annotationKey:s.annotationKey,citationKey:Za(s.citationItem.uris[0]),attachementKey:Za(s.attachmentURI),commentHTML:c.textContent?.trim()?c.innerHTML:null,inline:!1}),Ju.annot.create(l)}}).addRule("citation",{filter:(e,r)=>e.classList.contains("citation")&&!!e.dataset.citation,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let o=Ose(r.dataset.citation),i=Rg(10);return this.citations.set(i,{text:e,itemKeys:o.citationItems.map(({uris:[s]})=>Za(s))}),Ju.cite.create(i)}}).addRule("highlight",{filter:(e,r)=>e.classList.contains("highlight")&&!!e.dataset.annotation,replacement:(e,r,n)=>{if(!(r instanceof HTMLElement))throw new Error("Unexpected node");let o=aB(r.dataset.annotation),i=Rg(10);return this.annotations.set(i,{annotationKey:o.annotationKey,citationKey:Za(o.citationItem.uris[0]),attachementKey:Za(o.attachmentURI),commentHTML:null,inline:!0}),Ju.annot.create(i)}});onload(){}async normalizeNotes(e){let r=[];for(let{note:n,...o}of e)r.push(new OE({...o,content:n?await this.turndown(n):"",note:n}));return r}async turndown(e){this.citations.clear(),this.annotations.clear();let r=this.tdService.turndown(e),n={citations:[...this.citations.values()].flatMap(u=>u.itemKeys),annotations:[...this.annotations.values()].map(u=>u.citationKey)},o=new Set([...this.annotations.values()].map(u=>u.attachementKey)),i=this.plugin.settings.libId,s=Cse([...n.citations,...n.annotations]),c=await this.plugin.databaseAPI.getItems(s.map(u=>[u,i])).then(async u=>{let d=new Map;for(let m=0;mu?[u.item.itemID,...[...u.annotations.values()].map(d=>d.itemID)]:[]).map(u=>[u,i])),f=r.replaceAll(Ju.cite.pattern,(u,d)=>{let m=this.citations.get(d),h=m.itemKeys.map(w=>{let v=c.get(w);if(!v)throw H.error("citation not found, key: ",w,m),new Error(`citation not found: key ${w}`);return{allAttachments:v.attachments,annotations:[],docItem:v.item,attachment:null,tags:l,notes:[]}});return this.plugin.templateRenderer.renderCitations(h,{plugin:this.plugin})}).replaceAll(Ju.annot.pattern,(u,d)=>{let m=this.annotations.get(d),h=c.get(m.citationKey);if(!h)throw H.error("citation not found, key:",d,m),new Error(`citation key not found: ${d}`);let y=h.annotations.get(m.annotationKey);if(!y)throw H.error("annotation not found, key: ",m.annotationKey,m),new Error(`annotation key not found: ${m.annotationKey}`);let w=this.plugin.templateRenderer.renderAnnot({...y,ztnote:{comment:m.commentHTML,get commentMd(){return m.commentHTML?(0,cB.htmlToMarkdown)(m.commentHTML):""},inline:m.inline}},{allAttachments:h.attachments,annotations:[...h.annotations.values()],attachment:h.attachments.find(v=>v.itemID===y.parentItemID),docItem:h.item,notes:[],tags:l},{plugin:this.plugin});return m.inline?w:` +`+w+` `}).replace(/\n{3,}/g,` -`);return this.citations.clear(),this.annotations.clear(),u}};function sse(t){let e=JSON.parse(decodeURIComponent(t)),{data:r,problems:n}=Wq(e);if(n)throw W.error("Unexpected citation data",e,n),new Error("Unexpected citation data: "+n.summary);return r}function Gq(t){let e=JSON.parse(decodeURIComponent(t)),{data:r,problems:n}=Hq(e);if(n)throw W.error("Unexpected annotation data",e,n),new Error("Unexpected annotation data: "+n.summary);return r}function ase(t){return[...new Set(t)]}var Og=require("fs/promises");var lse=(t,e)=>e.some(r=>t instanceof r),Jq,Yq;function cse(){return Jq||(Jq=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function use(){return Yq||(Yq=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var Xq=new WeakMap,vE=new WeakMap,Qq=new WeakMap,bE=new WeakMap,xE=new WeakMap;function fse(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{r(xn(t.result)),o()},s=()=>{n(t.error),o()};t.addEventListener("success",i),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&Xq.set(r,t)}).catch(()=>{}),xE.set(e,t),e}function pse(t){if(vE.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{r(),o()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});vE.set(t,e)}var wE={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return vE.get(t);if(e==="objectStoreNames")return t.objectStoreNames||Qq.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return xn(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function eB(t){wE=t(wE)}function dse(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Ig(this),e,...r);return Qq.set(n,e.sort?e.sort():[e]),xn(n)}:use().includes(t)?function(...e){return t.apply(Ig(this),e),xn(Xq.get(this))}:function(...e){return xn(t.apply(Ig(this),e))}}function mse(t){return typeof t=="function"?dse(t):(t instanceof IDBTransaction&&pse(t),lse(t,cse())?new Proxy(t,wE):t)}function xn(t){if(t instanceof IDBRequest)return fse(t);if(bE.has(t))return bE.get(t);let e=mse(t);return e!==t&&(bE.set(t,e),xE.set(e,t)),e}var Ig=t=>xE.get(t);function rB(t,e,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){let s=indexedDB.open(t,e),a=xn(s);return n&&s.addEventListener("upgradeneeded",l=>{n(xn(s.result),l.oldVersion,l.newVersion,xn(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),a.then(l=>{i&&l.addEventListener("close",()=>i()),o&&l.addEventListener("versionchange",u=>o(u.oldVersion,u.newVersion,u))}).catch(()=>{}),a}var hse=["get","getKey","getAll","getAllKeys","count"],gse=["put","add","delete","clear"],EE=new Map;function tB(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(EE.get(e))return EE.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=gse.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||hse.includes(r)))return;let i=async function(s,...a){let l=this.transaction(s,o?"readwrite":"readonly"),u=l.store;return n&&(u=u.index(a.shift())),(await Promise.all([u[r](...a),o&&l.done]))[0]};return EE.set(e,i),i}eB(t=>({...t,get:(e,r,n)=>tB(e,r)||t.get(e,r,n),has:(e,r)=>!!tB(e,r)||t.has(e,r)}));var Tg=require("obsidian");var yse="zotlit",_g="pdf-outline",Uu=class extends fe{constructor(r){super();this.plugin=r}db=rB(yse,1,{upgrade(r){r.createObjectStore(_g,{keyPath:"path"})}});async getCachedOutlineKeys(){return await(await this.db).getAllKeys(_g)}async getPDFOutline(r,n=!1){let o=await this.db,i=await o.get(_g,r),s;try{s=await(0,Og.stat)(r)}catch(l){if(l.code==="ENOENT")return new Tg.Notice("PDF file not found"),null;throw l}if(i&&s.mtimeMs===i.mtime&&!n)return W.debug("PDF outline cache hit",r),i.outline;let a=await this.#e(r);return a?(await o.put(_g,{path:r,mtime:s.mtimeMs,outline:a,created:Date.now()}),W.debug("PDF outline cache miss and updated",r),a):null}pdfjs;async#e(r){this.pdfjs??=await(0,Tg.loadPdfJs)();let n=this.pdfjs.getDocument(await(0,Og.readFile)(r)),o=await n.promise,i=nB(await o.getOutline(),0),s=await Promise.all(i.map(async({dest:a,...l})=>{if(!Array.isArray(a))return{...l,page:null};let[u]=a,c=await o.getPageIndex(u);return{...l,page:c}}));return await o.cleanup(),await n.destroy(),s}},nB=(t,e)=>t.flatMap(({title:r,dest:n,items:o})=>[{title:r,dest:n,level:e},...nB(o,e+1)]);var SE=require("fs");var oB=require("obsidian");var oo=class extends fe{settings=this.use(ge);api=this.use(Vt).api;app=this.use(oB.App);get autoRefresh(){return this.settings.current?.autoRefresh}onDatabaseUpdate(e){return()=>this.app.vault.trigger("zotero:db-updated",e)}onload(){this.register(He(lt(()=>this.setAutoRefresh(this.autoRefresh),()=>this.autoRefresh))),W.debug("loading DatabaseWatcher")}onunload(){this.#e()}#e(){this.#n=!1,this.#t=ma(this.#t,e=>(e?.close(),null))}#t={main:null,bbt:null};#n=!1;async setAutoRefresh(e,r=!1){if(!(e===this.#n&&!r)&&(W.debug("Auto refresh set to "+e),this.#n=e,this.#e(),e)){this.#t.main=(0,SE.watch)(this.settings.zoteroDbPath,this.onDatabaseUpdate("main"));let n=await this.api.getLoadStatus();n.bbt&&(this.#t.bbt=(0,SE.watch)(n.bbtVersion==="v0"?this.settings.bbtSearchDbPath:this.settings.bbtMainDbPath,this.onDatabaseUpdate("bbt")))}}};de([me],oo.prototype,"autoRefresh",1);var Wu=class extends fe{onunload(){W.info("ZoteroDB unloaded")}get defaultLibId(){return this.settings.libId}settings=this.use(ge);#e=this.use(Vt);watcher=this.use(oo);get api(){return this.#e.api}async search(e){let n=this.defaultLibId;if(this.#e.status!==2)throw new Error("Search index not ready");let o=await this.api.search(n,{query:e,limit:50,index:bse});if(o.length===0)return[];let i=vse(o);return i.length===0?[]:(await this.api.getItems(i.map(a=>[a.id,n]))).map((a,l)=>{let{id:u,fields:c,score:f}=i[l];if(!a)throw new Error("Item not found: "+u);return{item:a,score:f,fields:[...c]}})}async getItemsOf(e=50,r=this.defaultLibId){if(this.#e.status!==2)throw new Error("Search index not ready");return(await this.api.getItemsFromCache(e,r)).map(o=>({item:o,score:-1,fields:[]}))}},bse=["title","creators[]:firstName","creators[]:lastName","date"];function vse(t){let{size:e}=new Set(t.flatMap(n=>n.result)),r=t.reduce((n,{field:o,result:i})=>(o.startsWith("creators[]")&&(o="creators"),i.forEach((s,a)=>{let l=e-a;switch(o){case"title":l*=100;break;case"creators":case"date":l*=5;break;default:throw new Error("Unknown field: "+o)}if(!n.has(+s))n.set(+s,{id:+s,score:l,fields:new Set([o])});else{let u=n.get(+s);u.fields.add(o),u.score+=l}}),n),new Map);return Array.from(r.values()).sort((n,o)=>o.score-n.score)}var Kr=require("fs/promises"),iB=require("path"),sB=require("path/posix");var Tr=require("obsidian");var Yo=class extends fe{onload(){W.debug("loading ImgCacheImporter")}async onunload(){await this.flush()}get app(){return this.use(xe).app}settings=this.use(ge);queue=new Map;getCachePath(e){return Lo(e,this.settings.current?.zoteroDataDir)}get mode(){return this.settings.current?.imgExcerptImport}get path(){return this.settings.current?.imgExcerptPath}get imgExcerptDir(){return this.mode?this.path:null}getInVaultPath(e){if(!this.imgExcerptDir||e.type!==Ae.image)return null;let r=this.getCachePath(e);return xse(e,r,this.imgExcerptDir)}import(e){let r=this.getCachePath(e),n=this.getInVaultPath(e);if(!n)return null;let o;return this.queue.has(n)?o=this.queue.get(n):(o=async()=>{let i=await this.linkToVault(n,r);return this.queue.delete(n),i},this.queue.set(n,o)),n}async flush(){return await Promise.all([...this.queue.values()].map(r=>r()))}cancel(){this.queue.clear()}async linkToVault(e,r){let n=await(0,Kr.stat)(r).then(s=>{if(!s.isFile()&&!s.isSymbolicLink()){let a=`failed to link image excerpt cache to vault: given path not file ${r}`;return new Tr.Notice(a),mt(a,null),-1}return s.mtimeMs}).catch(s=>{if(s.code==="ENOENT"){let a=`failed to link image excerpt cache to vault: file not found ${r}`;return new Tr.Notice(a),mt(a,s),-1}throw s});if(n===-1)return!1;let o=this.mode;if(o===!1)return W.trace("import mode disabled"),!1;let i=(0,sB.dirname)(e);if(i!=="."&&i!==".."&&await this.app.vault.createFolder(i).catch(()=>{}),this.app.vault.adapter instanceof Tr.FileSystemAdapter){let s=this.app.vault.adapter.getFullPath(e),a=await(0,Kr.lstat)(s).catch(l=>{if(l.code!=="ENOENT")throw l;return null});if(o==="copy"){let l=-1;if(a)if(a.isSymbolicLink())W.trace(s+" is symlink, unlinking"),await(0,Kr.rm)(s);else if(a.isFile())l=a.mtimeMs;else{let u="Failed to import image excerpt cache: cannot overwrite non-file "+s;return new Tr.Notice(u),mt(u,null),!1}if(l<0||n>l)return W.trace(s+" is file, "+(l<0?"creating":"overwritting")),await(0,Kr.copyFile)(r,s),new Tr.Notice(`Copied image excerpt cache to vault: ${e}`),!0;W.trace("mtime check pass, skipping")}else{if(a){if(a.isSymbolicLink())return W.trace(s+" is symlink, skipping"),!1;if(a.isFile())W.trace(s+" is file, remove before symlinking"),await(0,Kr.rm)(s);else{let l="Failed to import image excerpt cache: cannot overwrite non-file "+s;return new Tr.Notice(l),mt(l,null),!1}}try{await(0,Kr.symlink)(r,s,"file")}catch(l){if(l.code==="EPERM")return new Tr.Notice(`Failed to symlink image excerpt cache to vault: permission denied ${r}, check directory permission or change import mode to copy. If you are using FAT32 drive, symlink is not supported.`),mt(`Failed to symlink image excerpt cache to vault: permission denied ${r}`,l),!1;throw l}return new Tr.Notice(`linked image excerpt cache to vault: ${e}`),!0}return!1}else throw new Error("Mobile not supported")}};de([me],Yo.prototype,"mode",1),de([me],Yo.prototype,"path",1),de([me],Yo.prototype,"imgExcerptDir",1);var wse=(t,e)=>(e??"")+(0,iB.basename)(t),xse=(t,e,r)=>{let n=wse(e,t.groupID);return[(0,Tr.normalizePath)(r),n].join("/")};S();S();S();function Wa(t,e=[]){let r=[];function n(i,s){let a=We(s),l=r.length;r=[...r,s];function u(f){let{scope:p,children:d,...h}=f,b=p?.[t][l]||a,y=ie(()=>h,Object.values(h));return H(b.Provider,{value:y},d)}function c(f,p){let d=p?.[t][l]||a,h=te(d);if(h)return h;if(s!==void 0)return s;throw new Error(`\`${f}\` must be used within \`${i}\``)}return u.displayName=i+"Provider",[u,c]}let o=()=>{let i=r.map(s=>We(s));return function(a){let l=a?.[t]||i;return ie(()=>({[`__scope${t}`]:{...a,[t]:l}}),[a,l])}};return o.scopeName=t,[n,Ese(o,...e)]}function Ese(...t){let e=t[0];if(t.length===1)return e;let r=()=>{let n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){let s=n.reduce((a,{useScope:l,scopeName:u})=>{let f=l(i)[`__scope${u}`];return{...a,...f}},{});return ie(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return r.scopeName=e.scopeName,r}S();S();S();function Sse(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function IE(...t){return e=>t.forEach(r=>Sse(r,e))}function ds(...t){return X(IE(...t),t)}S();var Ha=Y((t,e)=>{let{children:r,...n}=t,o=Qe.toArray(r),i=o.find(_se);if(i){let s=i.props.children,a=o.map(l=>l===i?Qe.count(s)>1?Qe.only(null):Zt(s)?s.props.children:null:l);return H(_E,pe({},n,{ref:e}),Zt(s)?gr(s,void 0,a):null)}return H(_E,pe({},n,{ref:e}),r)});Ha.displayName="Slot";var _E=Y((t,e)=>{let{children:r,...n}=t;return Zt(r)?gr(r,{...Ose(n,r.props),ref:IE(e,r.ref)}):Qe.count(r)>1?Qe.only(null):null});_E.displayName="SlotClone";var Ise=({children:t})=>H(M,null,t);function _se(t){return Zt(t)&&t.type===Ise}function Ose(t,e){let r={...e};for(let n in e){let o=t[n],i=e[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...a)=>{i(...a),o(...a)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...t,...r}}function aB(t){let e=t+"CollectionProvider",[r,n]=Wa(e),[o,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),s=d=>{let{scope:h,children:b}=d,y=N.useRef(null),v=N.useRef(new Map).current;return N.createElement(o,{scope:h,itemMap:v,collectionRef:y},b)},a=t+"CollectionSlot",l=N.forwardRef((d,h)=>{let{scope:b,children:y}=d,v=i(a,b),x=ds(h,v.collectionRef);return N.createElement(Ha,{ref:x},y)}),u=t+"CollectionItemSlot",c="data-radix-collection-item",f=N.forwardRef((d,h)=>{let{scope:b,children:y,...v}=d,x=N.useRef(null),T=ds(h,x),$=i(u,b);return N.useEffect(()=>($.itemMap.set(x,{ref:x,...v}),()=>void $.itemMap.delete(x))),N.createElement(Ha,{[c]:"",ref:T},y)});function p(d){let h=i(t+"CollectionConsumer",d);return N.useCallback(()=>{let y=h.collectionRef.current;if(!y)return[];let v=Array.from(y.querySelectorAll(`[${c}]`));return Array.from(h.itemMap.values()).sort(($,V)=>v.indexOf($.ref.current)-v.indexOf(V.ref.current))},[h.collectionRef,h.itemMap])}return[{Provider:s,Slot:l,ItemSlot:f},p,n]}S();S();var Hu=globalThis?.document?Pt:()=>{};var Tse=Nr["useId".toString()]||(()=>{}),Cse=0;function Cg(t){let[e,r]=L(Tse());return Hu(()=>{t||r(n=>n??String(Cse++))},[t]),t||(e?`radix-${e}`:"")}S();S();var Ase=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Xo=Ase.reduce((t,e)=>{let r=Y((n,o)=>{let{asChild:i,...s}=n,a=i?Ha:e;return U(()=>{window[Symbol.for("radix-ui")]=!0},[]),H(a,pe({},s,{ref:o}))});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});S();function Ku(t){let e=P(t);return U(()=>{e.current=t}),ie(()=>(...r)=>{var n;return(n=e.current)===null||n===void 0?void 0:n.call(e,...r)},[])}S();function Ag({prop:t,defaultProp:e,onChange:r=()=>{}}){let[n,o]=kse({defaultProp:e,onChange:r}),i=t!==void 0,s=i?t:n,a=Ku(r),l=X(u=>{if(i){let f=typeof u=="function"?u(t):u;f!==t&&a(f)}else o(u)},[i,t,o,a]);return[s,l]}function kse({defaultProp:t,onChange:e}){let r=L(t),[n]=r,o=P(n),i=Ku(e);return U(()=>{o.current!==n&&(i(n),o.current=n)},[n,o,i]),r}S();var Rse=We(void 0);function kg(t){let e=te(Rse);return t||e||"ltr"}var OE="rovingFocusGroup.onEntryFocus",Nse={bubbles:!1,cancelable:!0},CE="RovingFocusGroup",[TE,lB,Dse]=aB(CE),[Fse,AE]=Wa(CE,[Dse]),[Pse,Mse]=Fse(CE),$se=Y((t,e)=>H(TE.Provider,{scope:t.__scopeRovingFocusGroup},H(TE.Slot,{scope:t.__scopeRovingFocusGroup},H(Lse,pe({},t,{ref:e}))))),Lse=Y((t,e)=>{let{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:a,onCurrentTabStopIdChange:l,onEntryFocus:u,...c}=t,f=P(null),p=ds(e,f),d=kg(i),[h=null,b]=Ag({prop:s,defaultProp:a,onChange:l}),[y,v]=L(!1),x=Ku(u),T=lB(r),$=P(!1),[V,J]=L(0);return U(()=>{let G=f.current;if(G)return G.addEventListener(OE,x),()=>G.removeEventListener(OE,x)},[x]),H(Pse,{scope:r,orientation:n,dir:d,loop:o,currentTabStopId:h,onItemFocus:X(G=>b(G),[b]),onItemShiftTab:X(()=>v(!0),[]),onFocusableItemAdd:X(()=>J(G=>G+1),[]),onFocusableItemRemove:X(()=>J(G=>G-1),[])},H(Xo.div,pe({tabIndex:y||V===0?-1:0,"data-orientation":n},c,{ref:p,style:{outline:"none",...t.style},onMouseDown:Bt(t.onMouseDown,()=>{$.current=!0}),onFocus:Bt(t.onFocus,G=>{let K=!$.current;if(G.target===G.currentTarget&&K&&!y){let F=new CustomEvent(OE,Nse);if(G.currentTarget.dispatchEvent(F),!F.defaultPrevented){let Q=T().filter(D=>D.focusable),O=Q.find(D=>D.active),_=Q.find(D=>D.id===h),B=[O,_,...Q].filter(Boolean).map(D=>D.ref.current);cB(B)}}$.current=!1}),onBlur:Bt(t.onBlur,()=>v(!1))})))}),jse="RovingFocusGroupItem",qse=Y((t,e)=>{let{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,...s}=t,a=Cg(),l=i||a,u=Mse(jse,r),c=u.currentTabStopId===l,f=lB(r),{onFocusableItemAdd:p,onFocusableItemRemove:d}=u;return U(()=>{if(n)return p(),()=>d()},[n,p,d]),H(TE.ItemSlot,{scope:r,id:l,focusable:n,active:o},H(Xo.span,pe({tabIndex:c?0:-1,"data-orientation":u.orientation},s,{ref:e,onMouseDown:Bt(t.onMouseDown,h=>{n?u.onItemFocus(l):h.preventDefault()}),onFocus:Bt(t.onFocus,()=>u.onItemFocus(l)),onKeyDown:Bt(t.onKeyDown,h=>{if(h.key==="Tab"&&h.shiftKey){u.onItemShiftTab();return}if(h.target!==h.currentTarget)return;let b=Use(h,u.orientation,u.dir);if(b!==void 0){h.preventDefault();let v=f().filter(x=>x.focusable).map(x=>x.ref.current);if(b==="last")v.reverse();else if(b==="prev"||b==="next"){b==="prev"&&v.reverse();let x=v.indexOf(h.currentTarget);v=u.loop?Wse(v,x+1):v.slice(x+1)}setTimeout(()=>cB(v))}})})))}),Bse={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function zse(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function Use(t,e,r){let n=zse(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return Bse[n]}function cB(t){let e=document.activeElement;for(let r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function Wse(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var uB=$se,fB=qse;S();S();function Hse(t,e){return an((r,n)=>{let o=e[r][n];return o??r},t)}var kE=t=>{let{present:e,children:r}=t,n=Kse(e),o=typeof r=="function"?r({present:n.isPresent}):Qe.only(r),i=ds(n.ref,o.ref);return typeof r=="function"||n.isPresent?gr(o,{ref:i}):null};kE.displayName="Presence";function Kse(t){let[e,r]=L(),n=P({}),o=P(t),i=P("none"),s=t?"mounted":"unmounted",[a,l]=Hse(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return U(()=>{let u=Rg(n.current);i.current=a==="mounted"?u:"none"},[a]),Hu(()=>{let u=n.current,c=o.current;if(c!==t){let p=i.current,d=Rg(u);t?l("MOUNT"):d==="none"||u?.display==="none"?l("UNMOUNT"):l(c&&p!==d?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Hu(()=>{if(e){let u=f=>{let d=Rg(n.current).includes(f.animationName);f.target===e&&d&&ln(()=>l("ANIMATION_END"))},c=f=>{f.target===e&&(i.current=Rg(n.current))};return e.addEventListener("animationstart",c),e.addEventListener("animationcancel",u),e.addEventListener("animationend",u),()=>{e.removeEventListener("animationstart",c),e.removeEventListener("animationcancel",u),e.removeEventListener("animationend",u)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(a),ref:X(u=>{u&&(n.current=getComputedStyle(u)),r(u)},[])}}function Rg(t){return t?.animationName||"none"}var pB="Tabs",[Vse,hBe]=Wa(pB,[AE]),dB=AE(),[Gse,RE]=Vse(pB),Zse=Y((t,e)=>{let{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:a,activationMode:l="automatic",...u}=t,c=kg(a),[f,p]=Ag({prop:n,onChange:o,defaultProp:i});return H(Gse,{scope:r,baseId:Cg(),value:f,onValueChange:p,orientation:s,dir:c,activationMode:l},H(Xo.div,pe({dir:c,"data-orientation":s},u,{ref:e})))}),Jse="TabsList",Yse=Y((t,e)=>{let{__scopeTabs:r,loop:n=!0,...o}=t,i=RE(Jse,r),s=dB(r);return H(uB,pe({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:n}),H(Xo.div,pe({role:"tablist","aria-orientation":i.orientation},o,{ref:e})))}),Xse="TabsTrigger",Qse=Y((t,e)=>{let{__scopeTabs:r,value:n,disabled:o=!1,...i}=t,s=RE(Xse,r),a=dB(r),l=mB(s.baseId,n),u=hB(s.baseId,n),c=n===s.value;return H(fB,pe({asChild:!0},a,{focusable:!o,active:c}),H(Xo.button,pe({type:"button",role:"tab","aria-selected":c,"aria-controls":u,"data-state":c?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:e,onMouseDown:Bt(t.onMouseDown,f=>{!o&&f.button===0&&f.ctrlKey===!1?s.onValueChange(n):f.preventDefault()}),onKeyDown:Bt(t.onKeyDown,f=>{[" ","Enter"].includes(f.key)&&s.onValueChange(n)}),onFocus:Bt(t.onFocus,()=>{let f=s.activationMode!=="manual";!c&&!o&&f&&s.onValueChange(n)})})))}),eae="TabsContent",tae=Y((t,e)=>{let{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=t,a=RE(eae,r),l=mB(a.baseId,n),u=hB(a.baseId,n),c=n===a.value,f=P(c);return U(()=>{let p=requestAnimationFrame(()=>f.current=!1);return()=>cancelAnimationFrame(p)},[]),H(kE,{present:o||c},({present:p})=>H(Xo.div,pe({"data-state":c?"active":"inactive","data-orientation":a.orientation,role:"tabpanel","aria-labelledby":l,hidden:!p,id:u,tabIndex:0},s,{ref:e,style:{...t.style,animationDuration:f.current?"0s":void 0}}),p&&i))});function mB(t,e){return`${t}-trigger-${e}`}function hB(t,e){return`${t}-content-${e}`}var gB=Zse,NE=Yse,DE=Qse,FE=tae;S();var yB=gB,PE=Y(({className:t,...e},r)=>m(NE,{ref:r,className:re("inline-flex items-center justify-center rounded-md bg-secondary p-1",t),...e}));PE.displayName=NE.displayName;var Qo=Y(({className:t,...e},r)=>m(DE,{className:re("obzt-btn-reset","inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium text-txt-muted transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-txt-normal data-[state=active]:shadow-sm",t),...e,ref:r}));Qo.displayName=DE.displayName;var ei=Y(({className:t,...e},r)=>m(FE,{className:re("mt-2 rounded-md border p-6",t),...e,ref:r}));ei.displayName=FE.displayName;S();S();function Ka(){return Ka=Object.assign||function(t){for(var e=1;eo(i=>!i),[])]}var IB=require("obsidian");S();S();var we=Y(function({name:e,description:r,heading:n,children:o,className:i},s){return m("div",{className:re("setting-item",n&&"setting-item-heading border-none",i),children:[m("div",{className:"setting-item-info",children:[m("div",{className:"setting-item-name",children:e}),r&&m("div",{className:"setting-item-description",children:r})]}),m("div",{className:"setting-item-control",ref:s,children:o})]})});function mae(t){let e=P(t);return e.current=t,ie(()=>rf(()=>e.current()),[])}function qe(t,e){let r=te(Ut).settings,n=mae(()=>t(r.current)).value,o=Yt(function(s){r.update(a=>e(s,a))});return[n,o]}function ME(t,e){let r=Yt(e),n=P(null);return U(()=>{n.current?.setValue(t)},[t]),X(o=>{if(!o)n.current?.toggleEl.remove(),n.current=null;else{let i=new IB.ToggleComponent(o);i.setValue(t),i.onChange(r),n.current=i}},[])}function Vr({name:t,children:e,get:r,set:n}){let o=ME(...qe(r,n));return m($E,{ref:o,name:t,children:e})}var $E=Y(function({name:e,children:r},n){return m(we,{className:"mod-toggle",ref:n,name:e,description:r})});var TB=Z(require("node:net"),1),CB=Z(require("node:os"),1),Pg=class extends Error{constructor(e){super(`${e} is locked`)}},Ga={old:new Set,young:new Set},hae=1e3*15;var Fg,gae=()=>{let t=CB.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(t))for(let n of r)e.add(n.address);return e},_B=t=>new Promise((e,r)=>{let n=TB.default.createServer();n.unref(),n.on("error",r),n.listen(t,()=>{let{port:o}=n.address();n.close(()=>{e(o)})})}),OB=async(t,e)=>{if(t.host||t.port===0)return _B(t);for(let r of e)try{await _B({port:t.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return t.port},yae=function*(t){t&&(yield*t),yield 0};async function LE(t){let e,r=new Set;if(t&&(t.port&&(e=typeof t.port=="number"?[t.port]:t.port),t.exclude)){let o=t.exclude;if(typeof o[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let i of o){if(typeof i!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(i))throw new TypeError(`Number ${i} in the exclude option is not a safe integer and can't be used`)}r=new Set(o)}Fg===void 0&&(Fg=setInterval(()=>{Ga.old=Ga.young,Ga.young=new Set},hae),Fg.unref&&Fg.unref());let n=gae();for(let o of yae(e))try{if(r.has(o))continue;let i=await OB({...t,port:o},n);for(;Ga.old.has(i)||Ga.young.has(i);){if(o!==0)throw new Pg(o);i=await OB({...t,port:o},n)}return Ga.young.add(i),i}catch(i){if(!["EADDRINUSE","EACCES"].includes(i.code)&&!(i instanceof Pg))throw i}throw new Error("No available ports found")}var jE=require("obsidian");S();function AB(){let[t,e]=qe(n=>n.enableServer,(n,o)=>({...o,enableServer:n})),r=ME(t,e);return m(M,{children:[m(we,{heading:!0,name:"Background connect",description:"Allow Zotero to send status in the background, which is required for some features like focus annotation on selection in Zotero"}),m($E,{ref:r,name:"Enable",children:"Remember to enable the server in Zotero as well"}),t&&m(bae,{})]})}function bae(){let[t,e]=qe(a=>a.serverPort,(a,l)=>({...l,serverPort:a})),[r]=qe(a=>a.serverHostname,(a,l)=>({...l,serverHostname:a})),[n,o]=L(t),[i]=Mt("check");async function s(){if(isNaN(n)||n<0||n>65535)return new jE.Notice("Invalid port number: "+n),o(t),!1;if(n===t)return!1;let a=await LE({host:r,port:[n]});return a!==n?(new jE.Notice(`Port is currently occupied, a different port is provided: ${a}, confirm again to apply the change.`),o(a),!1):(e(a),!0)}return m(we,{name:"Port number",description:`Default to ${t}`,children:[m("input",{type:"number",value:n,min:0,max:65535,onChange:a=>o(Number.parseInt(a.target.value,10))}),m("button",{"aria-label":"Apply",ref:i,onClick:s})]})}var RB=require("@electron/remote"),NB=require("obsidian");S();function qE({children:t,path:e,state:r}){return m("div",{children:[t,": ",r==="failed"&&"(Failed to load)",m(BE,{path:e,state:r})]})}function BE({path:t,state:e}){return m("code",{"data-state":e,className:re("data-[state=success]:text-txt-success","data-[state=failed]:text-txt-error","data-[state=disabled]:text-txt-muted"),children:t})}S();function zE(t){let{database:e}=te(Ut),[r,n]=Dg(()=>e.api.getLoadStatus().then(i=>t==="zotero"?i.main:i.bbt),[t]),o;return r.loading?o="disabled":r.error?o="failed":o=r.result?"success":"failed",[o,n]}function UE(){let t=kB("main"),e=kB("bbt"),[r,n]=zE("zotero"),[o,i]=zE("bbt"),[s,a,l]=vae(()=>{n(),i()});return m(we,{name:"Zotero data directory",description:m(M,{children:[m(qE,{path:t,state:r,children:"Zotero"}),m(qE,{path:e,state:o,children:"Better BibTeX"})]}),children:[m(BE,{path:s,state:a}),m("button",{onClick:l,children:"Select"})]})}function vae(t){let[e,r]=qe(s=>s.zoteroDataDir,(s,a)=>({...a,zoteroDataDir:s})),{app:n}=te(Ut),o=EB(async()=>{try{let{filePaths:[s]}=await RB.dialog.showOpenDialog({defaultPath:e,properties:["openDirectory"]});s&&e!==s&&(r(s),await new Promise((a,l)=>{function u(){a(),n.vault.off("zotero:db-refresh",u)}n.vault.on("zotero:db-refresh",u),setTimeout(()=>{l(new DOMException("Timeout after 5s","TimeoutError")),n.vault.off("zotero:db-refresh",u)},5e3)}),t())}catch(s){throw console.error("Failed to set data directory",s),new NB.Notice(`Failed to set data directory: ${s}`),s}}),i;return o.loading?i="disabled":o.error?i="failed":i="success",[e,i,o.execute]}function kB(t){let e=te(Ut).settings;return t==="main"?e.zoteroDbPath:e.bbtMainDbPath}function WE(){return m(M,{children:[m(UE,{}),m(Vr,{name:"Refresh automatically when Zotero updates database",get:t=>t.autoRefresh,set:(t,e)=>({...e,autoRefresh:t})}),m(AB,{})]})}S();function ms({name:t,children:e,normalize:r,get:n,set:o}){let[i,s]=qe(n,o),[a,l]=L(i);return m(HE,{name:t,value:a,onChange:u=>l(u.target.value),onSubmit:()=>{let u=r?.(a)??a;u!==a&&l(u),s(u)},children:e})}function HE({name:t,children:e,value:r,onChange:n,onSubmit:o}){let[i]=Mt("check");return m(we,{name:t,description:e,children:[m(gu,{className:"border",value:r,onChange:n}),m("button",{"aria-label":"Apply",ref:i,onClick:o})]})}function DB(){let[t,e]=qe(r=>r.imgExcerptImport===!1?"false":r.imgExcerptImport,(r,n)=>({...n,imgExcerptImport:r==="false"?!1:r}));return m(M,{children:[m(we,{heading:!0,name:"Image excerpt",description:"Controls how to import images in annotaion excerpts."}),m(we,{name:"Mode",description:m("dl",{className:"mt-2 grid grid-cols-3 gap-1",children:[m("div",{children:[m("dt",{className:"text-xs font-medium text-txt-normal",children:"Direct link"}),m("dd",{className:"mt-1",children:["Use image embed linked directly to the original image in Zotero cache using ",m("code",{children:"file://"})," url"]})]}),m("div",{children:[m("dt",{className:"text-xs font-medium text-txt-normal",children:"Symlink"}),m("dd",{className:"mt-1",children:["Create a symlink to the original image in Zotero cache within the specified folder",m("p",{className:"text-txt-error",children:"Don't use this option if your file system doesn't support symlink."})]})]}),m("div",{children:[m("dt",{className:"text-xs font-medium text-txt-normal",children:"Copy"}),m("dd",{className:"mt-1",children:"Copy the original image to the specified folder."})]})]}),children:m("select",{className:"dropdown",onChange:r=>e(r.target.value),value:t,children:[m("option",{value:"false",children:"direct link"},0),m("option",{value:"symlink",children:"symlink"},1),m("option",{value:"copy",children:"copy"},2)]})}),t!=="false"&&m(M,{children:m(ms,{name:"Default location",get:r=>r.imgExcerptPath,set:(r,n)=>({...n,imgExcerptPath:r}),normalize:Va,children:"The folder to store image excerpts."})})]})}S();function KE(){let{database:t}=te(Ut),[e,r]=qe(a=>a.citationLibrary,(a,l)=>({...l,citationLibrary:a})),[n,o]=Dg(()=>t.api.getLibs(),[]),i=n.result??[{groupID:null,libraryID:1,name:"My Library"}],[s]=Mt("switch");return m(we,{name:"Citation library",children:[m("select",{className:"dropdown",onChange:a=>r(Number.parseInt(a.target.value,10)),value:e,children:i.map(({groupID:a,libraryID:l,name:u})=>m("option",{value:l,children:u?a?`${u} (Group)`:u:`Library ${l}`},l))}),m("button",{"aria-label":"Refresh",ref:s,onClick:async()=>{await t.refresh({task:"full"}),o()}})]})}function VE(){return m(M,{children:[m(ms,{name:"Default location for new literature notes",get:t=>t.literatureNoteFolder,set:(t,e)=>({...e,literatureNoteFolder:t}),normalize:Va}),m(KE,{}),m(DB,{})]})}function GE(){let[t,e]=qe(r=>r.logLevel,(r,n)=>({...n,logLevel:r}));return m(M,{children:[m(we,{heading:!0,name:"Debug"}),m(we,{name:"Log Level",description:m(M,{children:["Change level of logs output to the console.",m("br",{}),"Set to DEBUG if you need to report a issue",m("br",{}),"To check console, ",cD()]}),children:m("select",{className:"dropdown",onChange:r=>{let n=r.target.value;e(n)},value:t,children:Object.entries(CS).map(([r,n])=>m("option",{value:n,children:r},n))})})]})}function ZE(){return m(M,{children:m(GE,{})})}var FB=require("obsidian");var Gu=class extends FB.PluginSettingTab{#e(){let e=this.containerEl.parentElement;if(!e)throw new Error("Setting tab is not mounted");if(!e.classList.contains("vertical-tab-content-container"))return W.error("Failed to patch unload, unexpected tabContentContainer"),console.error(e),!1;let r=this,n=or(e,{empty:o=>function(){r.unload(),o.call(this),n()}});return W.debug("Setting tab unload patched"),!0}#t=[];register(e){this.#t.push(e)}unload(){for(;this.#t.length>0;)this.#t.pop()()}display(){this.containerEl.empty(),this.#e()}};function JE(){return m(M,{children:[m(Vr,{name:"Citation editor suggester",get:t=>t.citationEditorSuggester,set:(t,e)=>({...e,citationEditorSuggester:t})}),m(Vr,{name:"Show BibTex citekey in suggester",get:t=>t.showCitekeyInSuggester,set:(t,e)=>({...e,showCitekeyInSuggester:t})})]})}S();function YE(){let[t,e]=qe(u=>u.autoTrim[0],(u,c)=>({...c,autoTrim:[u,c.autoTrim[1]]})),[r,n]=qe(u=>u.autoTrim[1],(u,c)=>({...c,autoTrim:[c.autoTrim[0],u]})),[o,i]=L(t),[s,a]=L(r),l=Yt(async function(c,f){let p=c==="false"?!1:c;f===0?(i(p),e(p)):(a(p),n(p))});return m(we,{name:"Auto trim",description:m(M,{children:[m("p",{className:"text-sm",children:["Controls default whitespace/new line trimming before/after a ejs"," ",m("code",{className:"whitespace-nowrap",children:"<% Tag %>"})]}),m("dl",{className:"mt-2",children:m("div",{className:"grid grid-cols-2 gap-1",children:[m("div",{children:[m("dt",{className:"text-xs font-medium text-txt-normal",children:"Newline slurp"}),m("dd",{className:"mt-1",children:"Removes the following newline before and after the tag."})]}),m("div",{children:[m("dt",{className:"text-xs font-medium text-txt-normal",children:"Whitespace slurp:"}),m("dd",{className:"mt-1",children:"Removes all whitespace before and after the tag."})]})]})})]}),children:m("div",{className:"flex flex-col gap-2",children:[0,1].map(u=>m("div",{className:"flex flex-col items-start gap-1 text-sm",children:[m("span",{children:u===0?"Leading":"Ending"}),m("select",{className:"dropdown",onChange:c=>l(c.target.value,u),value:String(u===0?o:s),children:[m("option",{value:"false",children:"Disable"},0),m("option",{value:"nl",children:"Newline slurp (-)"},1),m("option",{value:"slurp",children:"Whitespace slurp (_)"},2)]})]},u))})})}var ri=require("obsidian");S();var PB=require("obsidian");S();function XE(t,{icon:e,desc:r,disable:n}){let o=Yt(t),i=P(null);return U(()=>{i.current?.setIcon(e??"")},[e]),U(()=>{i.current?.setTooltip(r??"")},[r]),U(()=>{i.current?.setDisabled(n??!1)},[n]),X(s=>{if(!s)i.current?.extraSettingsEl.remove(),i.current=null;else{let a=new PB.ExtraButtonComponent(s);a.onClick(o),i.current=a}},[])}var ti={filename:{title:"Note filename",desc:"Used to render filename for each imported literature note"},cite:{title:"Primary Markdown citation",desc:"Used to render citation in literature note"},cite2:{title:"Secondary Markdown citation",desc:"Used to render alternative citation in literature note"},field:{title:"Note properties",desc:"Used to render Properties in literature note"},note:{title:"Note content",desc:"Used to render created literature note"},annotation:{title:"Single annotaion",desc:"Used to render single annotation"},annots:{title:"Annotations",desc:"Used to render annotation list when batch importing"},colored:{title:"Colored highlight",desc:"Used to render highlights with color in imported Zotero note"}};function MB({type:t}){let{app:e,settings:r}=te(Ut),[n]=Mt("arrow-up-right"),[o]=Mt("folder-input"),[i]=Mt("reset"),[s,a]=L(()=>QE(t,{app:e,folder:r.templateDir})),l=mi(t,r.templateDir);return U(()=>{let u=[e.vault.on("delete",c=>{c.path===l&&a(!1)}),e.vault.on("create",c=>{c.path===l&&a(!0)}),e.vault.on("rename",(c,f)=>{c.path===l&&a(!0),f===l&&a(!1)})];return()=>u.forEach(c=>e.vault.offref(c))},[l]),s?m(we,{name:ti[t].title,description:ti[t].desc,children:[m("code",{children:l}),m("button",{"aria-label":"Open template file",ref:n,onClick:async()=>{await fs(t,null,{app:e,settings:r})}}),m("button",{"aria-label":"Reset to default",ref:i,onClick:async()=>{if(!activeWindow.confirm("Reset template to default?"))return;let u=e.vault.getAbstractFileByPath(l);u instanceof ri.TFile?(await e.vault.modify(u,dt.Ejectable[t]),new ri.Notice(`Template '${l}' reset`)):a(!0)}})]}):m(we,{name:ti[t].title,description:ti[t].desc,children:[m("pre",{className:"text-left max-w-xs overflow-scroll rounded border p-4",children:dt.Ejectable[t]}),m("button",{"aria-label":"Save to template folder",ref:o,onClick:async()=>{let u=await $B(t,{app:e,folder:r.templateDir});a(u)}})]})}async function $B(t,{app:e,folder:r}){let n=mi(t,r),o=e.vault.getAbstractFileByPath(n);return o instanceof ri.TFile?!0:o?(new ri.Notice(`The path '${n}' is occupied by a folder`),!1):(await e.fileManager.createNewMarkdownFile(e.vault.getRoot(),n,dt.Ejectable[t]),new ri.Notice(`Template '${n}' created`),!0)}function QE(t,{app:e,folder:r}){let n=mi(t,r);return e.vault.getAbstractFileByPath(n)instanceof ri.TFile}function LB(){let{app:t,settings:e}=te(Ut),[r,n]=L(()=>en.Ejectable.every(i=>QE(i,{app:t,folder:e.templateDir}))),o=XE(async()=>{let i=en.Ejectable.filter(s=>!QE(s,{app:t,folder:e.templateDir}));await Promise.all(i.map(s=>$B(s,{app:t,folder:e.templateDir}))),n(!0)},{icon:r?"":"folder-input",desc:r?"":"Save template files to template folder",disable:r});return[r,o]}S();function jB({type:t}){let[e,r]=qe(i=>i.template.templates[t],(i,s)=>({...s,template:{...s.template,templates:{...s.template.templates,[t]:i}}})),[n,o]=L(e);return m(HE,{name:ti[t].title,value:n,onChange:i=>o(i.target.value),onSubmit:()=>{r(n)},children:ti[t].desc})}function eS(){let[t,e]=LB();return m(M,{children:[m(ms,{name:"Template location",get:r=>r.template.folder,set:(r,n)=>({...n,template:{...n.template,folder:r}}),normalize:Va,children:"The folder which templates are ejected into and stored"}),m(Vr,{name:"Auto pair for Eta",get:r=>r.autoPairEta,set:(r,n)=>({...n,autoPairEta:r}),children:["Pair `<` and `%` automatically in eta templates.",m("br",{}),"If you have issue with native auto pair features, you can disable this option and report the bug in GitHub"]}),m(YE,{}),m(we,{heading:!0,name:"Simple"}),en.Embeded.map(r=>m(jB,{type:r},r)),m(we,{heading:!0,name:"Ejectable",ref:e,description:"These templates can be customized once saved to the template folder",children:t||m("div",{children:"Eject"})}),en.Ejectable.map(r=>m(MB,{type:r},r))]})}function tS(){return m(M,{children:[m(we,{heading:!0,name:"Update note",description:m(M,{children:["You can find update note option in ",m("code",{children:"More Options"})," menu and command pallette inside a literature note. When update, all literature notes with the same ",m("code",{children:"zotero-key"})," will be updated."]})}),m(Vr,{name:"Overwrite existing note",get:t=>t.updateOverwrite,set:(t,e)=>({...e,updateOverwrite:t}),children:m("div",{className:"space-y-2",children:m("div",{className:"text-txt-error",children:"\u26A0 WARNING: This will overwrite the whole note content with latest one when update literature note, make sure you didn't add any custom content in the note before enable this option."})})}),m(Vr,{name:"In-place update of existing annotations",get:t=>t.updateAnnotBlock,set:(t,e)=>({...e,updateAnnotBlock:t}),children:m("div",{className:"space-y-2",children:[m("div",{children:"(Experimental)"}),m("div",{className:"text-txt-error",children:"\u26A0 WARNING: When enable, the plugin will try to update existing annotaion callouts marked with block-id in addition to appped newly-added ones, which may cause unexpected behavior. Make sure you have backup of your notes before enable this option."}),m("div",{className:"text-txt-accent",children:"\u24D8 Note: If you disable callout warpping in annotation template, you need to make sure the block-id is added properly in the template."}),m("div",{className:"text-txt-accent",children:"\u24D8 Note: This won't work on annotations imported before this feature is available, unless every annotation is inside a block with proper block-id"})]})})]})}var Zu=class extends Gu{constructor(r){super(r.app,r);this.plugin=r;this.containerEl.addClass("obzt")}display(){super.display(),N.render(m(Ut.Provider,{value:{settings:this.plugin.settings,app:this.app,database:this.plugin.dbWorker,closeTab:()=>this.setting.close()},children:m(wae,{})}),this.containerEl),this.register(()=>N.unmountComponentAtNode(this.containerEl))}};function wae(){let[t,e]=iv("obzt-setting-tab",{defaultValue:"general"});return m(yB,{value:t,onValueChange:e,className:"flex h-full flex-col",children:[m(PE,{className:"self-start max-w-full",children:[m(Qo,{value:"general",children:"General"}),m(Qo,{value:"connect",children:"Connect"}),m(Qo,{value:"suggester",children:"Suggester"}),m(Qo,{value:"template",children:"Template"}),m(Qo,{value:"update",children:"Note update"}),m(Qo,{value:"misc",children:"Misc"})]}),m(ei,{value:"general",className:"divide-y flex-grow overflow-y-scroll",children:m(VE,{})}),m(ei,{value:"connect",className:"divide-y flex-grow overflow-y-scroll",children:m(WE,{})}),m(ei,{value:"suggester",className:"divide-y flex-grow overflow-y-scroll",children:m(JE,{})}),m(ei,{value:"template",className:"divide-y flex-grow overflow-y-scroll",children:m(eS,{})}),m(ei,{value:"update",className:"divide-y flex-grow overflow-y-scroll",children:m(tS,{})}),m(ei,{value:"misc",className:"divide-y flex-grow overflow-y-scroll",children:m(ZE,{})})]})}var xe=class extends qB.Plugin{use=ys.plugin(this);constructor(e,r){if(super(e,r),!bN(r,e))throw new Error("Library check failed")}settings=HT(this);services={_log:this.use(zl)};noteIndex=this.use(Ba);server=this.use(Tn);citekeyClick=this.use(vg);templateEditor=this.use(Ia);noteFeatures=this.use(zq);noteParser=this.use(Sg);get databaseAPI(){return this.dbWorker.api}dbWorker=this.use(Vt);imgCacheImporter=this.use(Yo);dbWatcher=this.use(oo);database=this.use(Wu);templateRenderer=this.use(Wo);pdfParser=this.use(Uu);onload(){W.info("loading ZotLit"),this.addSettingTab(new Zu(this)),globalThis.zoteroAPI={version:this.manifest.version,getDocItems:e=>this.databaseAPI.getItems(e),getItemIDsFromCitekey:(...e)=>this.databaseAPI.getItemIDsFromCitekey(...e),getAnnotsFromKeys:(...e)=>this.databaseAPI.getAnnotFromKey(...e),getAnnotsOfAtch:(...e)=>this.databaseAPI.getAnnotations(...e),getAttachments:(...e)=>this.databaseAPI.getAttachments(...e),getLibs:()=>this.databaseAPI.getLibs()},this.register(()=>{delete globalThis.zoteroAPI})}onunload(){W.info("unloading ZotLit")}};0&&(module.exports={}); +`);return this.citations.clear(),this.annotations.clear(),f}};function Ose(t){let e=JSON.parse(decodeURIComponent(t)),{data:r,problems:n}=nB(e);if(n)throw H.error("Unexpected citation data",e,n),new Error("Unexpected citation data: "+n.summary);return r}function aB(t){let e=JSON.parse(decodeURIComponent(t)),{data:r,problems:n}=oB(e);if(n)throw H.error("Unexpected annotation data",e,n),new Error("Unexpected annotation data: "+n.summary);return r}function Cse(t){return[...new Set(t)]}a();var Fg=require("fs/promises");a();a();var kse=(t,e)=>e.some(r=>t instanceof r),lB,uB;function Ase(){return lB||(lB=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function Rse(){return uB||(uB=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var fB=new WeakMap,kE=new WeakMap,pB=new WeakMap,CE=new WeakMap,RE=new WeakMap;function Nse(t){let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("success",i),t.removeEventListener("error",s)},i=()=>{r(In(t.result)),o()},s=()=>{n(t.error),o()};t.addEventListener("success",i),t.addEventListener("error",s)});return e.then(r=>{r instanceof IDBCursor&&fB.set(r,t)}).catch(()=>{}),RE.set(e,t),e}function Dse(t){if(kE.has(t))return;let e=new Promise((r,n)=>{let o=()=>{t.removeEventListener("complete",i),t.removeEventListener("error",s),t.removeEventListener("abort",s)},i=()=>{r(),o()},s=()=>{n(t.error||new DOMException("AbortError","AbortError")),o()};t.addEventListener("complete",i),t.addEventListener("error",s),t.addEventListener("abort",s)});kE.set(t,e)}var AE={get(t,e,r){if(t instanceof IDBTransaction){if(e==="done")return kE.get(t);if(e==="objectStoreNames")return t.objectStoreNames||pB.get(t);if(e==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return In(t[e])},set(t,e,r){return t[e]=r,!0},has(t,e){return t instanceof IDBTransaction&&(e==="done"||e==="store")?!0:e in t}};function dB(t){AE=t(AE)}function Pse(t){return t===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(e,...r){let n=t.call(Dg(this),e,...r);return pB.set(n,e.sort?e.sort():[e]),In(n)}:Rse().includes(t)?function(...e){return t.apply(Dg(this),e),In(fB.get(this))}:function(...e){return In(t.apply(Dg(this),e))}}function Fse(t){return typeof t=="function"?Pse(t):(t instanceof IDBTransaction&&Dse(t),kse(t,Ase())?new Proxy(t,AE):t)}function In(t){if(t instanceof IDBRequest)return Nse(t);if(CE.has(t))return CE.get(t);let e=Fse(t);return e!==t&&(CE.set(t,e),RE.set(e,t)),e}var Dg=t=>RE.get(t);function hB(t,e,{blocked:r,upgrade:n,blocking:o,terminated:i}={}){let s=indexedDB.open(t,e),c=In(s);return n&&s.addEventListener("upgradeneeded",l=>{n(In(s.result),l.oldVersion,l.newVersion,In(s.transaction),l)}),r&&s.addEventListener("blocked",l=>r(l.oldVersion,l.newVersion,l)),c.then(l=>{i&&l.addEventListener("close",()=>i()),o&&l.addEventListener("versionchange",f=>o(f.oldVersion,f.newVersion,f))}).catch(()=>{}),c}var Mse=["get","getKey","getAll","getAllKeys","count"],$se=["put","add","delete","clear"],NE=new Map;function mB(t,e){if(!(t instanceof IDBDatabase&&!(e in t)&&typeof e=="string"))return;if(NE.get(e))return NE.get(e);let r=e.replace(/FromIndex$/,""),n=e!==r,o=$se.includes(r);if(!(r in(n?IDBIndex:IDBObjectStore).prototype)||!(o||Mse.includes(r)))return;let i=async function(s,...c){let l=this.transaction(s,o?"readwrite":"readonly"),f=l.store;return n&&(f=f.index(c.shift())),(await Promise.all([f[r](...c),o&&l.done]))[0]};return NE.set(e,i),i}dB(t=>({...t,get:(e,r,n)=>mB(e,r)||t.get(e,r,n),has:(e,r)=>!!mB(e,r)||t.has(e,r)}));var Mg=require("obsidian");var Lse="zotlit",Pg="pdf-outline",Yu=class extends de{constructor(r){super();this.plugin=r}db=hB(Lse,1,{upgrade(r){r.createObjectStore(Pg,{keyPath:"path"})}});async getCachedOutlineKeys(){return await(await this.db).getAllKeys(Pg)}async getPDFOutline(r,n=!1){let o=await this.db,i=await o.get(Pg,r),s;try{s=await(0,Fg.stat)(r)}catch(l){if(l.code==="ENOENT")return new Mg.Notice("PDF file not found"),null;throw l}if(i&&s.mtimeMs===i.mtime&&!n)return H.debug("PDF outline cache hit",r),i.outline;let c=await this.#e(r);return c?(await o.put(Pg,{path:r,mtime:s.mtimeMs,outline:c,created:Date.now()}),H.debug("PDF outline cache miss and updated",r),c):null}pdfjs;async#e(r){this.pdfjs??=await(0,Mg.loadPdfJs)();let n=this.pdfjs.getDocument(await(0,Fg.readFile)(r)),o=await n.promise,i=gB(await o.getOutline(),0),s=await Promise.all(i.map(async({dest:c,...l})=>{if(!Array.isArray(c))return{...l,page:null};let[f]=c,u=await o.getPageIndex(f);return{...l,page:u}}));return await o.cleanup(),await n.destroy(),s}},gB=(t,e)=>t.flatMap(({title:r,dest:n,items:o})=>[{title:r,dest:n,level:e},...gB(o,e+1)]);a();a();var DE=require("fs");var yB=require("obsidian");var ao=class extends de{settings=this.use(be);api=this.use(Yt).api;app=this.use(yB.App);get autoRefresh(){return this.settings.current?.autoRefresh}onDatabaseUpdate(e){return()=>this.app.vault.trigger("zotero:db-updated",e)}onload(){this.register(Ge(ft(()=>this.setAutoRefresh(this.autoRefresh),()=>this.autoRefresh))),H.debug("loading DatabaseWatcher")}onunload(){this.#e()}#e(){this.#n=!1,this.#t=wa(this.#t,e=>(e?.close(),null))}#t={main:null,bbt:null};#n=!1;async setAutoRefresh(e,r=!1){if(!(e===this.#n&&!r)&&(H.debug("Auto refresh set to "+e),this.#n=e,this.#e(),e)){this.#t.main=(0,DE.watch)(this.settings.zoteroDbPath,this.onDatabaseUpdate("main"));let n=await this.api.getLoadStatus();n.bbt&&(this.#t.bbt=(0,DE.watch)(n.bbtVersion==="v0"?this.settings.bbtSearchDbPath:this.settings.bbtMainDbPath,this.onDatabaseUpdate("bbt")))}}};he([ge],ao.prototype,"autoRefresh",1);a();var Xu=class extends de{onunload(){H.info("ZoteroDB unloaded")}get defaultLibId(){return this.settings.libId}settings=this.use(be);#e=this.use(Yt);watcher=this.use(ao);get api(){return this.#e.api}async search(e){let n=this.defaultLibId;if(this.#e.status!==2)throw new Error("Search index not ready");let o=await this.api.search(n,{query:e,limit:50,index:jse});if(o.length===0)return[];let i=qse(o);return i.length===0?[]:(await this.api.getItems(i.map(c=>[c.id,n]))).map((c,l)=>{let{id:f,fields:u,score:d}=i[l];if(!c)throw new Error("Item not found: "+f);return{item:c,score:d,fields:[...u]}})}async getItemsOf(e=50,r=this.defaultLibId){if(this.#e.status!==2)throw new Error("Search index not ready");return(await this.api.getItemsFromCache(e,r)).map(o=>({item:o,score:-1,fields:[]}))}},jse=["title","creators[]:firstName","creators[]:lastName","date"];function qse(t){let{size:e}=new Set(t.flatMap(n=>n.result)),r=t.reduce((n,{field:o,result:i})=>(o.startsWith("creators[]")&&(o="creators"),i.forEach((s,c)=>{let l=e-c;switch(o){case"title":l*=100;break;case"creators":case"date":l*=5;break;default:throw new Error("Unknown field: "+o)}if(!n.has(+s))n.set(+s,{id:+s,score:l,fields:new Set([o])});else{let f=n.get(+s);f.fields.add(o),f.score+=l}}),n),new Map);return Array.from(r.values()).sort((n,o)=>o.score-n.score)}a();var Zr=require("fs/promises"),bB=require("path"),vB=require("path/posix");var Rr=require("obsidian");var ti=class extends de{onload(){H.debug("loading ImgCacheImporter")}async onunload(){await this.flush()}get app(){return this.use(Ie).app}settings=this.use(be);queue=new Map;getCachePath(e){return zo(e,this.settings.current?.zoteroDataDir)}get mode(){return this.settings.current?.imgExcerptImport}get path(){return this.settings.current?.imgExcerptPath}get imgExcerptDir(){return this.mode?this.path:null}getInVaultPath(e){if(!this.imgExcerptDir||e.type!==Ne.image)return null;let r=this.getCachePath(e);return zse(e,r,this.imgExcerptDir)}import(e){let r=this.getCachePath(e),n=this.getInVaultPath(e);if(!n)return null;let o;return this.queue.has(n)?o=this.queue.get(n):(o=async()=>{let i=await this.linkToVault(n,r);return this.queue.delete(n),i},this.queue.set(n,o)),n}async flush(){return await Promise.all([...this.queue.values()].map(r=>r()))}cancel(){this.queue.clear()}async linkToVault(e,r){let n=await(0,Zr.stat)(r).then(s=>{if(!s.isFile()&&!s.isSymbolicLink()){let c=`failed to link image excerpt cache to vault: given path not file ${r}`;return new Rr.Notice(c),gt(c,null),-1}return s.mtimeMs}).catch(s=>{if(s.code==="ENOENT"){let c=`failed to link image excerpt cache to vault: file not found ${r}`;return new Rr.Notice(c),gt(c,s),-1}throw s});if(n===-1)return!1;let o=this.mode;if(o===!1)return H.trace("import mode disabled"),!1;let i=(0,vB.dirname)(e);if(i!=="."&&i!==".."&&await this.app.vault.createFolder(i).catch(()=>{}),this.app.vault.adapter instanceof Rr.FileSystemAdapter){let s=this.app.vault.adapter.getFullPath(e),c=await(0,Zr.lstat)(s).catch(l=>{if(l.code!=="ENOENT")throw l;return null});if(o==="copy"){let l=-1;if(c)if(c.isSymbolicLink())H.trace(s+" is symlink, unlinking"),await(0,Zr.rm)(s);else if(c.isFile())l=c.mtimeMs;else{let f="Failed to import image excerpt cache: cannot overwrite non-file "+s;return new Rr.Notice(f),gt(f,null),!1}if(l<0||n>l)return H.trace(s+" is file, "+(l<0?"creating":"overwritting")),await(0,Zr.copyFile)(r,s),new Rr.Notice(`Copied image excerpt cache to vault: ${e}`),!0;H.trace("mtime check pass, skipping")}else{if(c){if(c.isSymbolicLink())return H.trace(s+" is symlink, skipping"),!1;if(c.isFile())H.trace(s+" is file, remove before symlinking"),await(0,Zr.rm)(s);else{let l="Failed to import image excerpt cache: cannot overwrite non-file "+s;return new Rr.Notice(l),gt(l,null),!1}}try{await(0,Zr.symlink)(r,s,"file")}catch(l){if(l.code==="EPERM")return new Rr.Notice(`Failed to symlink image excerpt cache to vault: permission denied ${r}, check directory permission or change import mode to copy. If you are using FAT32 drive, symlink is not supported.`),gt(`Failed to symlink image excerpt cache to vault: permission denied ${r}`,l),!1;throw l}return new Rr.Notice(`linked image excerpt cache to vault: ${e}`),!0}return!1}else throw new Error("Mobile not supported")}};he([ge],ti.prototype,"mode",1),he([ge],ti.prototype,"path",1),he([ge],ti.prototype,"imgExcerptDir",1);var Bse=(t,e)=>(e??"")+(0,bB.basename)(t),zse=(t,e,r)=>{let n=Bse(e,t.groupID);return[(0,Rr.normalizePath)(r),n].join("/")};a();_();a();a();_();a();_();function Ja(t,e=[]){let r=[];function n(i,s){let c=Ve(s),l=r.length;r=[...r,s];function f(d){let{scope:m,children:h,...y}=d,w=m?.[t][l]||c,v=ae(()=>y,Object.values(y));return V(w.Provider,{value:v},h)}function u(d,m){let h=m?.[t][l]||c,y=ne(h);if(y)return y;if(s!==void 0)return s;throw new Error(`\`${d}\` must be used within \`${i}\``)}return f.displayName=i+"Provider",[f,u]}let o=()=>{let i=r.map(s=>Ve(s));return function(c){let l=c?.[t]||i;return ae(()=>({[`__scope${t}`]:{...c,[t]:l}}),[c,l])}};return o.scopeName=t,[n,Use(o,...e)]}function Use(...t){let e=t[0];if(t.length===1)return e;let r=()=>{let n=t.map(o=>({useScope:o(),scopeName:o.scopeName}));return function(i){let s=n.reduce((c,{useScope:l,scopeName:f})=>{let d=l(i)[`__scope${f}`];return{...c,...d}},{});return ae(()=>({[`__scope${e.scopeName}`]:s}),[s])}};return r.scopeName=e.scopeName,r}a();_();a();_();a();_();function Wse(t,e){typeof t=="function"?t(e):t!=null&&(t.current=e)}function PE(...t){return e=>t.forEach(r=>Wse(r,e))}function ys(...t){return ee(PE(...t),t)}a();_();var Ya=Q((t,e)=>{let{children:r,...n}=t,o=rt.toArray(r),i=o.find(Kse);if(i){let s=i.props.children,c=o.map(l=>l===i?rt.count(s)>1?rt.only(null):Qt(s)?s.props.children:null:l);return V(FE,me({},n,{ref:e}),Qt(s)?wr(s,void 0,c):null)}return V(FE,me({},n,{ref:e}),r)});Ya.displayName="Slot";var FE=Q((t,e)=>{let{children:r,...n}=t;return Qt(r)?wr(r,{...Vse(n,r.props),ref:PE(e,r.ref)}):rt.count(r)>1?rt.only(null):null});FE.displayName="SlotClone";var Hse=({children:t})=>V(L,null,t);function Kse(t){return Qt(t)&&t.type===Hse}function Vse(t,e){let r={...e};for(let n in e){let o=t[n],i=e[n];/^on[A-Z]/.test(n)?o&&i?r[n]=(...c)=>{i(...c),o(...c)}:o&&(r[n]=o):n==="style"?r[n]={...o,...i}:n==="className"&&(r[n]=[o,i].filter(Boolean).join(" "))}return{...t,...r}}function wB(t){let e=t+"CollectionProvider",[r,n]=Ja(e),[o,i]=r(e,{collectionRef:{current:null},itemMap:new Map}),s=h=>{let{scope:y,children:w}=h,v=P.useRef(null),x=P.useRef(new Map).current;return P.createElement(o,{scope:y,itemMap:x,collectionRef:v},w)},c=t+"CollectionSlot",l=P.forwardRef((h,y)=>{let{scope:w,children:v}=h,x=i(c,w),S=ys(y,x.collectionRef);return P.createElement(Ya,{ref:S},v)}),f=t+"CollectionItemSlot",u="data-radix-collection-item",d=P.forwardRef((h,y)=>{let{scope:w,children:v,...x}=h,S=P.useRef(null),k=ys(y,S),j=i(f,w);return P.useEffect(()=>(j.itemMap.set(S,{ref:S,...x}),()=>void j.itemMap.delete(S))),P.createElement(Ya,{[u]:"",ref:k},v)});function m(h){let y=i(t+"CollectionConsumer",h);return P.useCallback(()=>{let v=y.collectionRef.current;if(!v)return[];let x=Array.from(v.querySelectorAll(`[${u}]`));return Array.from(y.itemMap.values()).sort((j,Z)=>x.indexOf(j.ref.current)-x.indexOf(Z.ref.current))},[y.collectionRef,y.itemMap])}return[{Provider:s,Slot:l,ItemSlot:d},m,n]}a();_();a();_();var Qu=globalThis?.document?Lt:()=>{};var Gse=Mr["useId".toString()]||(()=>{}),Zse=0;function $g(t){let[e,r]=q(Gse());return Qu(()=>{t||r(n=>n??String(Zse++))},[t]),t||(e?`radix-${e}`:"")}a();_();_();var Jse=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ri=Jse.reduce((t,e)=>{let r=Q((n,o)=>{let{asChild:i,...s}=n,c=i?Ya:e;return K(()=>{window[Symbol.for("radix-ui")]=!0},[]),V(c,me({},s,{ref:o}))});return r.displayName=`Primitive.${e}`,{...t,[e]:r}},{});a();_();function ef(t){let e=$(t);return K(()=>{e.current=t}),ae(()=>(...r)=>{var n;return(n=e.current)===null||n===void 0?void 0:n.call(e,...r)},[])}a();_();function Lg({prop:t,defaultProp:e,onChange:r=()=>{}}){let[n,o]=Yse({defaultProp:e,onChange:r}),i=t!==void 0,s=i?t:n,c=ef(r),l=ee(f=>{if(i){let d=typeof f=="function"?f(t):f;d!==t&&c(d)}else o(f)},[i,t,o,c]);return[s,l]}function Yse({defaultProp:t,onChange:e}){let r=q(t),[n]=r,o=$(n),i=ef(e);return K(()=>{o.current!==n&&(i(n),o.current=n)},[n,o,i]),r}a();_();var Xse=Ve(void 0);function jg(t){let e=ne(Xse);return t||e||"ltr"}var ME="rovingFocusGroup.onEntryFocus",Qse={bubbles:!1,cancelable:!0},LE="RovingFocusGroup",[$E,xB,eae]=wB(LE),[tae,jE]=Ja(LE,[eae]),[rae,nae]=tae(LE),oae=Q((t,e)=>V($E.Provider,{scope:t.__scopeRovingFocusGroup},V($E.Slot,{scope:t.__scopeRovingFocusGroup},V(iae,me({},t,{ref:e}))))),iae=Q((t,e)=>{let{__scopeRovingFocusGroup:r,orientation:n,loop:o=!1,dir:i,currentTabStopId:s,defaultCurrentTabStopId:c,onCurrentTabStopIdChange:l,onEntryFocus:f,...u}=t,d=$(null),m=ys(e,d),h=jg(i),[y=null,w]=Lg({prop:s,defaultProp:c,onChange:l}),[v,x]=q(!1),S=ef(f),k=xB(r),j=$(!1),[Z,X]=q(0);return K(()=>{let J=d.current;if(J)return J.addEventListener(ME,S),()=>J.removeEventListener(ME,S)},[S]),V(rae,{scope:r,orientation:n,dir:h,loop:o,currentTabStopId:y,onItemFocus:ee(J=>w(J),[w]),onItemShiftTab:ee(()=>x(!0),[]),onFocusableItemAdd:ee(()=>X(J=>J+1),[]),onFocusableItemRemove:ee(()=>X(J=>J-1),[])},V(ri.div,me({tabIndex:v||Z===0?-1:0,"data-orientation":n},u,{ref:m,style:{outline:"none",...t.style},onMouseDown:Wt(t.onMouseDown,()=>{j.current=!0}),onFocus:Wt(t.onFocus,J=>{let G=!j.current;if(J.target===J.currentTarget&&G&&!v){let M=new CustomEvent(ME,Qse);if(J.currentTarget.dispatchEvent(M),!M.defaultPrevented){let te=k().filter(F=>F.focusable),C=te.find(F=>F.active),O=te.find(F=>F.id===y),U=[C,O,...te].filter(Boolean).map(F=>F.ref.current);EB(U)}}j.current=!1}),onBlur:Wt(t.onBlur,()=>x(!1))})))}),sae="RovingFocusGroupItem",aae=Q((t,e)=>{let{__scopeRovingFocusGroup:r,focusable:n=!0,active:o=!1,tabStopId:i,...s}=t,c=$g(),l=i||c,f=nae(sae,r),u=f.currentTabStopId===l,d=xB(r),{onFocusableItemAdd:m,onFocusableItemRemove:h}=f;return K(()=>{if(n)return m(),()=>h()},[n,m,h]),V($E.ItemSlot,{scope:r,id:l,focusable:n,active:o},V(ri.span,me({tabIndex:u?0:-1,"data-orientation":f.orientation},s,{ref:e,onMouseDown:Wt(t.onMouseDown,y=>{n?f.onItemFocus(l):y.preventDefault()}),onFocus:Wt(t.onFocus,()=>f.onItemFocus(l)),onKeyDown:Wt(t.onKeyDown,y=>{if(y.key==="Tab"&&y.shiftKey){f.onItemShiftTab();return}if(y.target!==y.currentTarget)return;let w=uae(y,f.orientation,f.dir);if(w!==void 0){y.preventDefault();let x=d().filter(S=>S.focusable).map(S=>S.ref.current);if(w==="last")x.reverse();else if(w==="prev"||w==="next"){w==="prev"&&x.reverse();let S=x.indexOf(y.currentTarget);x=f.loop?fae(x,S+1):x.slice(S+1)}setTimeout(()=>EB(x))}})})))}),cae={ArrowLeft:"prev",ArrowUp:"prev",ArrowRight:"next",ArrowDown:"next",PageUp:"first",Home:"first",PageDown:"last",End:"last"};function lae(t,e){return e!=="rtl"?t:t==="ArrowLeft"?"ArrowRight":t==="ArrowRight"?"ArrowLeft":t}function uae(t,e,r){let n=lae(t.key,r);if(!(e==="vertical"&&["ArrowLeft","ArrowRight"].includes(n))&&!(e==="horizontal"&&["ArrowUp","ArrowDown"].includes(n)))return cae[n]}function EB(t){let e=document.activeElement;for(let r of t)if(r===e||(r.focus(),document.activeElement!==e))return}function fae(t,e){return t.map((r,n)=>t[(e+n)%t.length])}var SB=oae,IB=aae;a();_();_();function pae(t,e){return un((r,n)=>{let o=e[r][n];return o??r},t)}var qE=t=>{let{present:e,children:r}=t,n=dae(e),o=typeof r=="function"?r({present:n.isPresent}):rt.only(r),i=ys(n.ref,o.ref);return typeof r=="function"||n.isPresent?wr(o,{ref:i}):null};qE.displayName="Presence";function dae(t){let[e,r]=q(),n=$({}),o=$(t),i=$("none"),s=t?"mounted":"unmounted",[c,l]=pae(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return K(()=>{let f=qg(n.current);i.current=c==="mounted"?f:"none"},[c]),Qu(()=>{let f=n.current,u=o.current;if(u!==t){let m=i.current,h=qg(f);t?l("MOUNT"):h==="none"||f?.display==="none"?l("UNMOUNT"):l(u&&m!==h?"ANIMATION_OUT":"UNMOUNT"),o.current=t}},[t,l]),Qu(()=>{if(e){let f=d=>{let h=qg(n.current).includes(d.animationName);d.target===e&&h&&fn(()=>l("ANIMATION_END"))},u=d=>{d.target===e&&(i.current=qg(n.current))};return e.addEventListener("animationstart",u),e.addEventListener("animationcancel",f),e.addEventListener("animationend",f),()=>{e.removeEventListener("animationstart",u),e.removeEventListener("animationcancel",f),e.removeEventListener("animationend",f)}}else l("ANIMATION_END")},[e,l]),{isPresent:["mounted","unmountSuspended"].includes(c),ref:ee(f=>{f&&(n.current=getComputedStyle(f)),r(f)},[])}}function qg(t){return t?.animationName||"none"}var _B="Tabs",[mae,MVe]=Ja(_B,[jE]),TB=jE(),[hae,BE]=mae(_B),gae=Q((t,e)=>{let{__scopeTabs:r,value:n,onValueChange:o,defaultValue:i,orientation:s="horizontal",dir:c,activationMode:l="automatic",...f}=t,u=jg(c),[d,m]=Lg({prop:n,onChange:o,defaultProp:i});return V(hae,{scope:r,baseId:$g(),value:d,onValueChange:m,orientation:s,dir:u,activationMode:l},V(ri.div,me({dir:u,"data-orientation":s},f,{ref:e})))}),yae="TabsList",bae=Q((t,e)=>{let{__scopeTabs:r,loop:n=!0,...o}=t,i=BE(yae,r),s=TB(r);return V(SB,me({asChild:!0},s,{orientation:i.orientation,dir:i.dir,loop:n}),V(ri.div,me({role:"tablist","aria-orientation":i.orientation},o,{ref:e})))}),vae="TabsTrigger",wae=Q((t,e)=>{let{__scopeTabs:r,value:n,disabled:o=!1,...i}=t,s=BE(vae,r),c=TB(r),l=OB(s.baseId,n),f=CB(s.baseId,n),u=n===s.value;return V(IB,me({asChild:!0},c,{focusable:!o,active:u}),V(ri.button,me({type:"button",role:"tab","aria-selected":u,"aria-controls":f,"data-state":u?"active":"inactive","data-disabled":o?"":void 0,disabled:o,id:l},i,{ref:e,onMouseDown:Wt(t.onMouseDown,d=>{!o&&d.button===0&&d.ctrlKey===!1?s.onValueChange(n):d.preventDefault()}),onKeyDown:Wt(t.onKeyDown,d=>{[" ","Enter"].includes(d.key)&&s.onValueChange(n)}),onFocus:Wt(t.onFocus,()=>{let d=s.activationMode!=="manual";!u&&!o&&d&&s.onValueChange(n)})})))}),xae="TabsContent",Eae=Q((t,e)=>{let{__scopeTabs:r,value:n,forceMount:o,children:i,...s}=t,c=BE(xae,r),l=OB(c.baseId,n),f=CB(c.baseId,n),u=n===c.value,d=$(u);return K(()=>{let m=requestAnimationFrame(()=>d.current=!1);return()=>cancelAnimationFrame(m)},[]),V(qE,{present:o||u},({present:m})=>V(ri.div,me({"data-state":u?"active":"inactive","data-orientation":c.orientation,role:"tabpanel","aria-labelledby":l,hidden:!m,id:f,tabIndex:0},s,{ref:e,style:{...t.style,animationDuration:d.current?"0s":void 0}}),m&&i))});function OB(t,e){return`${t}-trigger-${e}`}function CB(t,e){return`${t}-content-${e}`}var kB=gae,zE=bae,UE=wae,WE=Eae;_();var AB=kB,HE=Q(({className:t,...e},r)=>g(zE,{ref:r,className:oe("inline-flex items-center justify-center rounded-md bg-secondary p-1",t),...e}));HE.displayName=zE.displayName;var ni=Q(({className:t,...e},r)=>g(UE,{className:oe("obzt-btn-reset","inline-flex min-w-[100px] items-center justify-center rounded-[0.185rem] px-3 py-1.5 text-sm font-medium text-txt-muted transition-all disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-primary data-[state=active]:text-txt-normal data-[state=active]:shadow-sm",t),...e,ref:r}));ni.displayName=UE.displayName;var oi=Q(({className:t,...e},r)=>g(WE,{className:oe("mt-2 rounded-md border p-6",t),...e,ref:r}));oi.displayName=WE.displayName;a();_();a();_();function Xa(){return Xa=Object.assign||function(t){for(var e=1;eo(i=>!i),[])]}a();a();var KB=require("obsidian");_();a();a();var Fae=Symbol.for("preact-signals");function KE(){if(bs>1){bs--;return}let t,e=!1;for(function(){let r=Ug;for(Ug=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o}();rf!==void 0;){let r=rf;for(rf=void 0,Wg++;r!==void 0;){let n=r.u;if(r.u=void 0,r.f&=-3,!(8&r.f)&&BB(r))try{r.c()}catch(o){e||(t=o,e=!0)}r=n}}if(Wg=0,bs--,e)throw t}var we,rf;function jB(t){let e=we;we=void 0;try{return t()}finally{we=e}}var Ug,$B,bs=0,Wg=0;var LB=0,Hg=0;function qB(t){if(we===void 0)return;let e=t.n;if(e===void 0||e.t!==we)return e={i:0,S:t,p:we.s,n:void 0,t:we,e:void 0,x:void 0,r:e},we.s!==void 0&&(we.s.n=e),we.s=e,t.n=e,32&we.f&&t.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=we.s,e.n=void 0,we.s.n=e,we.s=e),e}function Vt(t,e){this.v=t,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}Vt.prototype.brand=Fae;Vt.prototype.h=function(){return!0};Vt.prototype.S=function(t){let e=this.t;e!==t&&t.e===void 0&&(t.x=e,this.t=t,e!==void 0?e.e=t:jB(()=>{var r;(r=this.W)==null||r.call(this)}))};Vt.prototype.U=function(t){if(this.t!==void 0){let e=t.e,r=t.x;e!==void 0&&(e.x=r,t.e=void 0),r!==void 0&&(r.e=e,t.x=void 0),t===this.t&&(this.t=r,r===void 0&&jB(()=>{var n;(n=this.Z)==null||n.call(this)}))}};Vt.prototype.subscribe=function(t){return $ae(()=>{let e=this.value,r=we;we=void 0;try{t(e)}finally{we=r}},{name:"sub"})};Vt.prototype.valueOf=function(){return this.value};Vt.prototype.toString=function(){return this.value+""};Vt.prototype.toJSON=function(){return this.value};Vt.prototype.peek=function(){let t=we;we=void 0;try{return this.value}finally{we=t}};Object.defineProperty(Vt.prototype,"value",{get(){let t=qB(this);return t!==void 0&&(t.i=this.i),this.v},set(t){if(t!==this.v){if(Wg>100)throw new Error("Cycle detected");(function(e){bs!==0&&Wg===0&&e.l!==LB&&(e.l=LB,Ug={S:e,v:e.v,i:e.i,o:Ug})})(this),this.v=t,this.i++,Hg++,bs++;try{for(let e=this.t;e!==void 0;e=e.x)e.t.N()}finally{KE()}}}});function BB(t){for(let e=t.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function zB(t){for(let e=t.s;e!==void 0;e=e.n){let r=e.S.n;if(r!==void 0&&(e.r=r),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function UB(t){let e,r=t.s;for(;r!==void 0;){let n=r.p;r.i===-1?(r.S.U(r),n!==void 0&&(n.n=r.n),r.n!==void 0&&(r.n.p=n)):e=r,r.S.n=r.r,r.r!==void 0&&(r.r=void 0),r=n}t.s=e}function vs(t,e){Vt.call(this,void 0),this.x=t,this.s=void 0,this.g=Hg-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}vs.prototype=new Vt;vs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hg))return!0;if(this.g=Hg,this.f|=1,this.i>0&&!BB(this))return this.f&=-2,!0;let t=we;try{zB(this),we=this;let e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return we=t,UB(this),this.f&=-2,!0};vs.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(let e=this.s;e!==void 0;e=e.n)e.S.S(e)}Vt.prototype.S.call(this,t)};vs.prototype.U=function(t){if(this.t!==void 0&&(Vt.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(let e=this.s;e!==void 0;e=e.n)e.S.U(e)}};vs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(vs.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");let t=qB(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function WB(t,e){return new vs(t,e)}function HB(t){let e=t.m;if(t.m=void 0,typeof e=="function"){bs++;let r=we;we=void 0;try{e()}catch(n){throw t.f&=-2,t.f|=8,VE(t),n}finally{we=r,KE()}}}function VE(t){for(let e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,HB(t)}function Mae(t){if(we!==this)throw new Error("Out-of-order effect");UB(this),we=t,this.f&=-2,8&this.f&&VE(this),KE()}function ec(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,$B&&$B.push(this)}ec.prototype.c=function(){let t=this.S();try{if(8&this.f||this.x===void 0)return;let e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};ec.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,HB(this),zB(this),bs++;let t=we;return we=this,Mae.bind(this,t)};ec.prototype.N=function(){2&this.f||(this.f|=2,this.u=rf,rf=this)};ec.prototype.d=function(){this.f|=8,1&this.f||VE(this)};ec.prototype.dispose=function(){this.d()};function $ae(t,e){let r=new ec(t,e);try{r.c()}catch(o){throw r.d(),o}let n=r.d.bind(r);return n[Symbol.dispose]=n,n}_();var Se=Q(function({name:e,description:r,heading:n,children:o,className:i},s){return g("div",{className:oe("setting-item",n&&"setting-item-heading border-none",i),children:[g("div",{className:"setting-item-info",children:[g("div",{className:"setting-item-name",children:e}),r&&g("div",{className:"setting-item-description",children:r})]}),g("div",{className:"setting-item-control",ref:s,children:o})]})});function Lae(t){let e=$(t);return e.current=t,ae(()=>WB(()=>e.current()),[])}function Ue(t,e){let r=ne(Kt).settings,n=Lae(()=>t(r.current)).value,o=tr(function(s){r.update(c=>e(s,c))});return[n,o]}function GE(t,e){let r=tr(e),n=$(null);return K(()=>{n.current?.setValue(t)},[t]),ee(o=>{if(!o)n.current?.toggleEl.remove(),n.current=null;else{let i=new KB.ToggleComponent(o);i.setValue(t),i.onChange(r),n.current=i}},[])}function Jr({name:t,children:e,get:r,set:n}){let o=GE(...Ue(r,n));return g(ZE,{ref:o,name:t,children:e})}var ZE=Q(function({name:e,children:r},n){return g(Se,{className:"mod-toggle",ref:n,name:e,description:r})});a();a();var ZB=Y(require("node:net"),1),JB=Y(require("node:os"),1),Vg=class extends Error{constructor(e){super(`${e} is locked`)}},tc={old:new Set,young:new Set},jae=1e3*15;var Kg,qae=()=>{let t=JB.default.networkInterfaces(),e=new Set([void 0,"0.0.0.0"]);for(let r of Object.values(t))for(let n of r)e.add(n.address);return e},VB=t=>new Promise((e,r)=>{let n=ZB.default.createServer();n.unref(),n.on("error",r),n.listen(t,()=>{let{port:o}=n.address();n.close(()=>{e(o)})})}),GB=async(t,e)=>{if(t.host||t.port===0)return VB(t);for(let r of e)try{await VB({port:t.port,host:r})}catch(n){if(!["EADDRNOTAVAIL","EINVAL"].includes(n.code))throw n}return t.port},Bae=function*(t){t&&(yield*t),yield 0};async function JE(t){let e,r=new Set;if(t&&(t.port&&(e=typeof t.port=="number"?[t.port]:t.port),t.exclude)){let o=t.exclude;if(typeof o[Symbol.iterator]!="function")throw new TypeError("The `exclude` option must be an iterable.");for(let i of o){if(typeof i!="number")throw new TypeError("Each item in the `exclude` option must be a number corresponding to the port you want excluded.");if(!Number.isSafeInteger(i))throw new TypeError(`Number ${i} in the exclude option is not a safe integer and can't be used`)}r=new Set(o)}Kg===void 0&&(Kg=setInterval(()=>{tc.old=tc.young,tc.young=new Set},jae),Kg.unref&&Kg.unref());let n=qae();for(let o of Bae(e))try{if(r.has(o))continue;let i=await GB({...t,port:o},n);for(;tc.old.has(i)||tc.young.has(i);){if(o!==0)throw new Vg(o);i=await GB({...t,port:o},n)}return tc.young.add(i),i}catch(i){if(!["EADDRINUSE","EACCES"].includes(i.code)&&!(i instanceof Vg))throw i}throw new Error("No available ports found")}var YE=require("obsidian");_();function YB(){let[t,e]=Ue(n=>n.enableServer,(n,o)=>({...o,enableServer:n})),r=GE(t,e);return g(L,{children:[g(Se,{heading:!0,name:"Background connect",description:"Allow Zotero to send status in the background, which is required for some features like focus annotation on selection in Zotero"}),g(ZE,{ref:r,name:"Enable",children:"Remember to enable the server in Zotero as well"}),t&&g(zae,{})]})}function zae(){let[t,e]=Ue(c=>c.serverPort,(c,l)=>({...l,serverPort:c})),[r]=Ue(c=>c.serverHostname,(c,l)=>({...l,serverHostname:c})),[n,o]=q(t),[i]=jt("check");async function s(){if(isNaN(n)||n<0||n>65535)return new YE.Notice("Invalid port number: "+n),o(t),!1;if(n===t)return!1;let c=await JE({host:r,port:[n]});return c!==n?(new YE.Notice(`Port is currently occupied, a different port is provided: ${c}, confirm again to apply the change.`),o(c),!1):(e(c),!0)}return g(Se,{name:"Port number",description:`Default to ${t}`,children:[g("input",{type:"number",value:n,min:0,max:65535,onChange:c=>o(Number.parseInt(c.target.value,10))}),g("button",{"aria-label":"Apply",ref:i,onClick:s})]})}a();var QB=require("@electron/remote"),ez=require("obsidian");_();a();function XE({children:t,path:e,state:r}){return g("div",{children:[t,": ",r==="failed"&&"(Failed to load)",g(QE,{path:e,state:r})]})}function QE({path:t,state:e}){return g("code",{"data-state":e,className:oe("data-[state=success]:text-txt-success","data-[state=failed]:text-txt-error","data-[state=disabled]:text-txt-muted"),children:t})}a();_();function eS(t){let{database:e}=ne(Kt),[r,n]=zg(()=>e.api.getLoadStatus().then(i=>t==="zotero"?i.main:i.bbt),[t]),o;return r.loading?o="disabled":r.error?o="failed":o=r.result?"success":"failed",[o,n]}function tS(){let t=XB("main"),e=XB("bbt"),[r,n]=eS("zotero"),[o,i]=eS("bbt"),[s,c,l]=Uae(()=>{n(),i()});return g(Se,{name:"Zotero data directory",description:g(L,{children:[g(XE,{path:t,state:r,children:"Zotero"}),g(XE,{path:e,state:o,children:"Better BibTeX"})]}),children:[g(QE,{path:s,state:c}),g("button",{onClick:l,children:"Select"})]})}function Uae(t){let[e,r]=Ue(s=>s.zoteroDataDir,(s,c)=>({...c,zoteroDataDir:s})),{app:n}=ne(Kt),o=FB(async()=>{try{let{filePaths:[s]}=await QB.dialog.showOpenDialog({defaultPath:e,properties:["openDirectory"]});s&&e!==s&&(r(s),await new Promise((c,l)=>{function f(){c(),n.vault.off("zotero:db-refresh",f)}n.vault.on("zotero:db-refresh",f),setTimeout(()=>{l(new DOMException("Timeout after 5s","TimeoutError")),n.vault.off("zotero:db-refresh",f)},5e3)}),t())}catch(s){throw console.error("Failed to set data directory",s),new ez.Notice(`Failed to set data directory: ${s}`),s}}),i;return o.loading?i="disabled":o.error?i="failed":i="success",[e,i,o.execute]}function XB(t){let e=ne(Kt).settings;return t==="main"?e.zoteroDbPath:e.bbtMainDbPath}function rS(){return g(L,{children:[g(tS,{}),g(Jr,{name:"Refresh automatically when Zotero updates database",get:t=>t.autoRefresh,set:(t,e)=>({...e,autoRefresh:t})}),g(YB,{})]})}a();a();_();function ws({name:t,children:e,normalize:r,get:n,set:o}){let[i,s]=Ue(n,o),[c,l]=q(i);return g(nS,{name:t,value:c,onChange:f=>l(f.target.value),onSubmit:()=>{let f=r?.(c)??c;f!==c&&l(f),s(f)},children:e})}function nS({name:t,children:e,value:r,onChange:n,onSubmit:o}){let[i]=jt("check");return g(Se,{name:t,description:e,children:[g(Iu,{className:"border",value:r,onChange:n}),g("button",{"aria-label":"Apply",ref:i,onClick:o})]})}a();function tz(){let[t,e]=Ue(r=>r.imgExcerptImport===!1?"false":r.imgExcerptImport,(r,n)=>({...n,imgExcerptImport:r==="false"?!1:r}));return g(L,{children:[g(Se,{heading:!0,name:"Image excerpt",description:"Controls how to import images in annotaion excerpts."}),g(Se,{name:"Mode",description:g("dl",{className:"mt-2 grid grid-cols-3 gap-1",children:[g("div",{children:[g("dt",{className:"text-xs font-medium text-txt-normal",children:"Direct link"}),g("dd",{className:"mt-1",children:["Use image embed linked directly to the original image in Zotero cache using ",g("code",{children:"file://"})," url"]})]}),g("div",{children:[g("dt",{className:"text-xs font-medium text-txt-normal",children:"Symlink"}),g("dd",{className:"mt-1",children:["Create a symlink to the original image in Zotero cache within the specified folder",g("p",{className:"text-txt-error",children:"Don't use this option if your file system doesn't support symlink."})]})]}),g("div",{children:[g("dt",{className:"text-xs font-medium text-txt-normal",children:"Copy"}),g("dd",{className:"mt-1",children:"Copy the original image to the specified folder."})]})]}),children:g("select",{className:"dropdown",onChange:r=>e(r.target.value),value:t,children:[g("option",{value:"false",children:"direct link"},0),g("option",{value:"symlink",children:"symlink"},1),g("option",{value:"copy",children:"copy"},2)]})}),t!=="false"&&g(L,{children:g(ws,{name:"Default location",get:r=>r.imgExcerptPath,set:(r,n)=>({...n,imgExcerptPath:r}),normalize:Qa,children:"The folder to store image excerpts."})})]})}a();_();function oS(){let{database:t}=ne(Kt),[e,r]=Ue(c=>c.citationLibrary,(c,l)=>({...l,citationLibrary:c})),[n,o]=zg(()=>t.api.getLibs(),[]),i=n.result??[{groupID:null,libraryID:1,name:"My Library"}],[s]=jt("switch");return g(Se,{name:"Citation library",children:[g("select",{className:"dropdown",onChange:c=>r(Number.parseInt(c.target.value,10)),value:e,children:i.map(({groupID:c,libraryID:l,name:f})=>g("option",{value:l,children:f?c?`${f} (Group)`:f:`Library ${l}`},l))}),g("button",{"aria-label":"Refresh",ref:s,onClick:async()=>{await t.refresh({task:"full"}),o()}})]})}function iS(){return g(L,{children:[g(ws,{name:"Default location for new literature notes",get:t=>t.literatureNoteFolder,set:(t,e)=>({...e,literatureNoteFolder:t}),normalize:Qa}),g(oS,{}),g(tz,{})]})}a();a();function sS(){let[t,e]=Ue(r=>r.logLevel,(r,n)=>({...n,logLevel:r}));return g(L,{children:[g(Se,{heading:!0,name:"Debug"}),g(Se,{name:"Log Level",description:g(L,{children:["Change level of logs output to the console.",g("br",{}),"Set to DEBUG if you need to report a issue",g("br",{}),"To check console, ",ED()]}),children:g("select",{className:"dropdown",onChange:r=>{let n=r.target.value;e(n)},value:t,children:Object.entries(BS).map(([r,n])=>g("option",{value:n,children:r},n))})})]})}function aS(){return g(L,{children:g(sS,{})})}a();var rz=require("obsidian");var nf=class extends rz.PluginSettingTab{#e(){let e=this.containerEl.parentElement;if(!e)throw new Error("Setting tab is not mounted");if(!e.classList.contains("vertical-tab-content-container"))return H.error("Failed to patch unload, unexpected tabContentContainer"),console.error(e),!1;let r=this,n=cr(e,{empty:o=>function(){r.unload(),o.call(this),n()}});return H.debug("Setting tab unload patched"),!0}#t=[];register(e){this.#t.push(e)}unload(){for(;this.#t.length>0;)this.#t.pop()()}display(){this.containerEl.empty(),this.#e()}};a();function cS(){return g(L,{children:[g(Jr,{name:"Citation editor suggester",get:t=>t.citationEditorSuggester,set:(t,e)=>({...e,citationEditorSuggester:t})}),g(Jr,{name:"Show BibTex citekey in suggester",get:t=>t.showCitekeyInSuggester,set:(t,e)=>({...e,showCitekeyInSuggester:t})})]})}a();a();_();function lS(){let[t,e]=Ue(f=>f.autoTrim[0],(f,u)=>({...u,autoTrim:[f,u.autoTrim[1]]})),[r,n]=Ue(f=>f.autoTrim[1],(f,u)=>({...u,autoTrim:[u.autoTrim[0],f]})),[o,i]=q(t),[s,c]=q(r),l=tr(async function(u,d){let m=u==="false"?!1:u;d===0?(i(m),e(m)):(c(m),n(m))});return g(Se,{name:"Auto trim",description:g(L,{children:[g("p",{className:"text-sm",children:["Controls default whitespace/new line trimming before/after a ejs"," ",g("code",{className:"whitespace-nowrap",children:"<% Tag %>"})]}),g("dl",{className:"mt-2",children:g("div",{className:"grid grid-cols-2 gap-1",children:[g("div",{children:[g("dt",{className:"text-xs font-medium text-txt-normal",children:"Newline slurp"}),g("dd",{className:"mt-1",children:"Removes the following newline before and after the tag."})]}),g("div",{children:[g("dt",{className:"text-xs font-medium text-txt-normal",children:"Whitespace slurp:"}),g("dd",{className:"mt-1",children:"Removes all whitespace before and after the tag."})]})]})})]}),children:g("div",{className:"flex flex-col gap-2",children:[0,1].map(f=>g("div",{className:"flex flex-col items-start gap-1 text-sm",children:[g("span",{children:f===0?"Leading":"Ending"}),g("select",{className:"dropdown",onChange:u=>l(u.target.value,f),value:String(f===0?o:s),children:[g("option",{value:"false",children:"Disable"},0),g("option",{value:"nl",children:"Newline slurp (-)"},1),g("option",{value:"slurp",children:"Whitespace slurp (_)"},2)]})]},f))})})}a();var si=require("obsidian");_();a();var nz=require("obsidian");_();function uS(t,{icon:e,desc:r,disable:n}){let o=tr(t),i=$(null);return K(()=>{i.current?.setIcon(e??"")},[e]),K(()=>{i.current?.setTooltip(r??"")},[r]),K(()=>{i.current?.setDisabled(n??!1)},[n]),ee(s=>{if(!s)i.current?.extraSettingsEl.remove(),i.current=null;else{let c=new nz.ExtraButtonComponent(s);c.onClick(o),i.current=c}},[])}a();var ii={filename:{title:"Note filename",desc:"Used to render filename for each imported literature note"},cite:{title:"Primary Markdown citation",desc:"Used to render citation in literature note"},cite2:{title:"Secondary Markdown citation",desc:"Used to render alternative citation in literature note"},field:{title:"Note properties",desc:"Used to render Properties in literature note"},note:{title:"Note content",desc:"Used to render created literature note"},annotation:{title:"Single annotaion",desc:"Used to render single annotation"},annots:{title:"Annotations",desc:"Used to render annotation list when batch importing"},colored:{title:"Colored highlight",desc:"Used to render highlights with color in imported Zotero note"}};function oz({type:t}){let{app:e,settings:r}=ne(Kt),[n]=jt("arrow-up-right"),[o]=jt("folder-input"),[i]=jt("reset"),[s,c]=q(()=>fS(t,{app:e,folder:r.templateDir})),l=bi(t,r.templateDir);return K(()=>{let f=[e.vault.on("delete",u=>{u.path===l&&c(!1)}),e.vault.on("create",u=>{u.path===l&&c(!0)}),e.vault.on("rename",(u,d)=>{u.path===l&&c(!0),d===l&&c(!1)})];return()=>f.forEach(u=>e.vault.offref(u))},[l]),s?g(Se,{name:ii[t].title,description:ii[t].desc,children:[g("code",{children:l}),g("button",{"aria-label":"Open template file",ref:n,onClick:async()=>{await hs(t,null,{app:e,settings:r})}}),g("button",{"aria-label":"Reset to default",ref:i,onClick:async()=>{if(!activeWindow.confirm("Reset template to default?"))return;let f=e.vault.getAbstractFileByPath(l);f instanceof si.TFile?(await e.vault.modify(f,ht.Ejectable[t]),new si.Notice(`Template '${l}' reset`)):c(!0)}})]}):g(Se,{name:ii[t].title,description:ii[t].desc,children:[g("pre",{className:"text-left max-w-xs overflow-scroll rounded border p-4",children:ht.Ejectable[t]}),g("button",{"aria-label":"Save to template folder",ref:o,onClick:async()=>{let f=await iz(t,{app:e,folder:r.templateDir});c(f)}})]})}async function iz(t,{app:e,folder:r}){let n=bi(t,r),o=e.vault.getAbstractFileByPath(n);return o instanceof si.TFile?!0:o?(new si.Notice(`The path '${n}' is occupied by a folder`),!1):(await e.fileManager.createNewMarkdownFile(e.vault.getRoot(),n,ht.Ejectable[t]),new si.Notice(`Template '${n}' created`),!0)}function fS(t,{app:e,folder:r}){let n=bi(t,r);return e.vault.getAbstractFileByPath(n)instanceof si.TFile}function sz(){let{app:t,settings:e}=ne(Kt),[r,n]=q(()=>nn.Ejectable.every(i=>fS(i,{app:t,folder:e.templateDir}))),o=uS(async()=>{let i=nn.Ejectable.filter(s=>!fS(s,{app:t,folder:e.templateDir}));await Promise.all(i.map(s=>iz(s,{app:t,folder:e.templateDir}))),n(!0)},{icon:r?"":"folder-input",desc:r?"":"Save template files to template folder",disable:r});return[r,o]}a();_();function az({type:t}){let[e,r]=Ue(i=>i.template.templates[t],(i,s)=>({...s,template:{...s.template,templates:{...s.template.templates,[t]:i}}})),[n,o]=q(e);return g(nS,{name:ii[t].title,value:n,onChange:i=>o(i.target.value),onSubmit:()=>{r(n)},children:ii[t].desc})}function pS(){let[t,e]=sz();return g(L,{children:[g(ws,{name:"Template location",get:r=>r.template.folder,set:(r,n)=>({...n,template:{...n.template,folder:r}}),normalize:Qa,children:"The folder which templates are ejected into and stored"}),g(Jr,{name:"Auto pair for Eta",get:r=>r.autoPairEta,set:(r,n)=>({...n,autoPairEta:r}),children:["Pair `<` and `%` automatically in eta templates.",g("br",{}),"If you have issue with native auto pair features, you can disable this option and report the bug in GitHub"]}),g(lS,{}),g(Se,{heading:!0,name:"Simple"}),nn.Embeded.map(r=>g(az,{type:r},r)),g(Se,{heading:!0,name:"Ejectable",ref:e,description:"These templates can be customized once saved to the template folder",children:t||g("div",{children:"Eject"})}),nn.Ejectable.map(r=>g(oz,{type:r},r))]})}a();function dS(){return g(L,{children:[g(Se,{heading:!0,name:"Update note",description:g(L,{children:["You can find update note option in ",g("code",{children:"More Options"})," menu and command pallette inside a literature note. When update, all literature notes with the same ",g("code",{children:"zotero-key"})," will be updated."]})}),g(Jr,{name:"Overwrite existing note",get:t=>t.updateOverwrite,set:(t,e)=>({...e,updateOverwrite:t}),children:g("div",{className:"space-y-2",children:g("div",{className:"text-txt-error",children:"\u26A0 WARNING: This will overwrite the whole note content with latest one when update literature note, make sure you didn't add any custom content in the note before enable this option."})})}),g(Jr,{name:"In-place update of existing annotations",get:t=>t.updateAnnotBlock,set:(t,e)=>({...e,updateAnnotBlock:t}),children:g("div",{className:"space-y-2",children:[g("div",{children:"(Experimental)"}),g("div",{className:"text-txt-error",children:"\u26A0 WARNING: When enable, the plugin will try to update existing annotaion callouts marked with block-id in addition to appped newly-added ones, which may cause unexpected behavior. Make sure you have backup of your notes before enable this option."}),g("div",{className:"text-txt-accent",children:"\u24D8 Note: If you disable callout warpping in annotation template, you need to make sure the block-id is added properly in the template."}),g("div",{className:"text-txt-accent",children:"\u24D8 Note: This won't work on annotations imported before this feature is available, unless every annotation is inside a block with proper block-id"})]})})]})}var of=class extends nf{constructor(r){super(r.app,r);this.plugin=r;this.containerEl.addClass("obzt")}display(){super.display(),P.render(g(Kt.Provider,{value:{settings:this.plugin.settings,app:this.app,database:this.plugin.dbWorker,closeTab:()=>this.setting.close()},children:g(Wae,{})}),this.containerEl),this.register(()=>P.unmountComponentAtNode(this.containerEl))}};function Wae(){let[t,e]=hv("obzt-setting-tab",{defaultValue:"general"});return g(AB,{value:t,onValueChange:e,className:"flex h-full flex-col",children:[g(HE,{className:"self-start max-w-full",children:[g(ni,{value:"general",children:"General"}),g(ni,{value:"connect",children:"Connect"}),g(ni,{value:"suggester",children:"Suggester"}),g(ni,{value:"template",children:"Template"}),g(ni,{value:"update",children:"Note update"}),g(ni,{value:"misc",children:"Misc"})]}),g(oi,{value:"general",className:"divide-y flex-grow overflow-y-scroll",children:g(iS,{})}),g(oi,{value:"connect",className:"divide-y flex-grow overflow-y-scroll",children:g(rS,{})}),g(oi,{value:"suggester",className:"divide-y flex-grow overflow-y-scroll",children:g(cS,{})}),g(oi,{value:"template",className:"divide-y flex-grow overflow-y-scroll",children:g(pS,{})}),g(oi,{value:"update",className:"divide-y flex-grow overflow-y-scroll",children:g(dS,{})}),g(oi,{value:"misc",className:"divide-y flex-grow overflow-y-scroll",children:g(aS,{})})]})}process.env.SQLITE_USE_URI="1";var Ie=class extends cz.Plugin{use=Ss.plugin(this);constructor(e,r){if(super(e,r),!RN(r,e))throw new Error("Library check failed")}settings=oC(this);services={_log:this.use(Jc)};noteIndex=this.use(Va);server=this.use(An);citekeyClick=this.use(Cg);templateEditor=this.use(Aa);noteFeatures=this.use(tB);noteParser=this.use(Ng);get databaseAPI(){return this.dbWorker.api}dbWorker=this.use(Yt);imgCacheImporter=this.use(ti);dbWatcher=this.use(ao);database=this.use(Xu);templateRenderer=this.use(Go);pdfParser=this.use(Yu);onload(){H.info("loading ZotLit"),this.addSettingTab(new of(this)),globalThis.zoteroAPI={version:this.manifest.version,getDocItems:e=>this.databaseAPI.getItems(e),getItemIDsFromCitekey:(...e)=>this.databaseAPI.getItemIDsFromCitekey(...e),getAnnotsFromKeys:(...e)=>this.databaseAPI.getAnnotFromKey(...e),getAnnotsOfAtch:(...e)=>this.databaseAPI.getAnnotations(...e),getAttachments:(...e)=>this.databaseAPI.getAttachments(...e),getLibs:()=>this.databaseAPI.getLibs()},this.register(()=>{delete globalThis.zoteroAPI})}onunload(){H.info("unloading ZotLit")}};0&&(module.exports={}); /*! Bundled license information: flatted/cjs/index.js: @@ -410,5 +410,3 @@ lodash-es/lodash.js: * LICENSE file in the root directory of this source tree. *) */ - -/* nosourcemap */ \ No newline at end of file diff --git a/PaperBell/.obsidian/plugins/zotlit/manifest.json b/PaperBell/.obsidian/plugins/zotlit/manifest.json index 76b8efce..e7bd05fd 100644 --- a/PaperBell/.obsidian/plugins/zotlit/manifest.json +++ b/PaperBell/.obsidian/plugins/zotlit/manifest.json @@ -3,9 +3,6 @@ "name": "ZotLit", "version": "1.1.11", "minAppVersion": "1.6.7", - "versions": { - "better-sqlite3": "v12.2.0" - }, "description": "Plugin to integrate with Zotero, create literature notes and insert citations from a Zotero library.", "author": "AidenLx", "authorUrl": "https://github.com/aidenlx",