Files
my-vault/.obsidian/plugins/quickadd/main.js
T

424 lines
1.3 MiB
JavaScript
Raw Normal View History

2026-01-05 19:25:56 +08:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var U7=Object.create;var iv=Object.defineProperty;var V7=Object.getOwnPropertyDescriptor;var q7=Object.getOwnPropertyNames;var W7=Object.getPrototypeOf,z7=Object.prototype.hasOwnProperty;var WN=r=>{throw TypeError(r)};var H7=(r,e,t)=>e in r?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var j7=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Jr=(r,e)=>{for(var t in e)iv(r,t,{get:e[t],enumerable:!0})},zN=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of q7(e))!z7.call(r,i)&&i!==t&&iv(r,i,{get:()=>e[i],enumerable:!(n=V7(e,i))||n.enumerable});return r};var HN=(r,e,t)=>(t=r!=null?U7(W7(r)):{},zN(e||!r||!r.__esModule?iv(t,"default",{value:r,enumerable:!0}):t,r)),G7=r=>zN(iv({},"__esModule",{value:!0}),r);var ae=(r,e,t)=>H7(r,typeof e!="symbol"?e+"":e,t),sI=(r,e,t)=>e.has(r)||WN("Cannot "+t);var z=(r,e,t)=>(sI(r,e,"read from private field"),t?t.call(r):e.get(r)),it=(r,e,t)=>e.has(r)?WN("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,n)=>(sI(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),xt=(r,e,t)=>(sI(r,e,"access private method"),t);var O2,N2,L2=b(()=>{O2=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,f))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);return a},N2=(r=>r?O2(r):O2)});function Nv(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=pX(r.endpoint),n=i=>t===i||t.endsWith(`.${i}`);return e==="anthropic"||n("api.anthropic.com")?"anthropic":e==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}function pX(r){let e=(r??"").trim();if(!e)return"";for(let t of[e,`https://${e}`])try{return new URL(t).hostname.toLowerCase()}catch{}return""}function fX(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function yT(r,e){let t=fX(r),n=new Set(e.map(o=>o.id).filter(o=>!!o)),i=t;for(let o=2;n.has(i);o++)i=`${t}-${o}`;return i}function bT(r){let e=!1,t=new Set;for(let n of r){if(n.id&&!t.has(n.id)){t.add(n.id);continue}n.id=yT(n.id??n.name,r),t.add(n.id),e=!0}return e}function mu(r,e){return e&&e.name===r?e:void 0}function wT(r){return Lv[r].map(e=>({...e}))}var Lv,B2,mX,hX,CT,es=b(()=>{Lv={openai:[{name:"gpt-5.5",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-mini",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-nano",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-4.1",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4.1-mini",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4o",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"gpt-4o-mini",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"o3",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1},{name:"o4-mini",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1}],google:[{name:"gemini-3.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-flash-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-pro",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0}],anthropic:[{name:"claude-fable-5",maxTokens:1e6,maxO
`)}function Uv(r){let e=Object.entries(r);if(e.length===0)return[];let n=["t","tm","yd"].map(s=>{let a=r[s];return a?[s,a]:null}).filter(s=>s!==null),i=new Set(n.map(([s])=>s)),o=e.filter(([s])=>!i.has(s)).sort((s,a)=>{let l=s[0].length-a[0].length;return l!==0?l:s[0].localeCompare(a[0])});return[...n,...o]}function xT(r){return Uv(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Yf,Wd=b(()=>{Yf={t:"today",tm:"tomorrow",yd:"yesterday",nw:"next week",nm:"next month",ny:"next year",lw:"last week",lm:"last month",ly:"last year"}});var ET,u0=b(()=>{es();Wd();ET={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Yf,ai:{defaultModel:"Ask me",defaultSystemPrompt:'As an AI assistant within Obsidian, your primary goal is to help users manage their ideas and knowledge more effectively. Format your responses using Markdown syntax. Please use the [[Obsidian]] link format. You can write aliases for the links by writing [[Obsidian|the alias after the pipe symbol]]. To use mathematical notation, use LaTeX syntax. LaTeX syntax for larger equations should be on separate lines, surrounded with double dollar signs ($$). You can also inline math expressions by wrapping it in $ symbols. For example, use $$w_{ij}^{\\text{new}}:=w_{ij}^{\\text{current}}+\\eta\\cdot\\delta_j\\cdot x_{ij}$$ on a separate line, but you can write "($\\eta$ = learning rate, $\\delta_j$ = error term, $x_{ij}$ = input)" inline.',promptTemplatesFolderPath:"",showAssistant:!0,providers:CT,confirmToolCalls:"destructive"},migrations:{migrateToMacroIDFromEmbeddedMacro:!0,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,consolidateFileExistsBehavior:!1,repairTemplateFileExistsBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1,removeMacroIndirection:!1,migrateFileOpeningSettings:!1,backfillFileOpeningDefaults:!1,setProviderModelDiscoveryMode:!1,migrateProviderApiKeysToSecretStorage:!1,migrateToMultipleTemplateFolders:!1,refreshStaleDefaultModelSeeds:!1,pinAiModelRefs:!1}}});function gt(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return hu(r,new Map)}function hu(r,e){if(r===null||typeof r!="object")return r;if(e.has(r))return e.get(r);if(r instanceof Date){let i=new Date(r.getTime());return e.set(r,i),i}if(Array.isArray(r)){let i=[];e.set(r,i);for(let o of r)i.push(hu(o,e));return i}if(r instanceof Map){let i=new Map;e.set(r,i);for(let[o,s]of r.entries())i.set(hu(o,e),hu(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(hu(o,e));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,e.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return e.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(hu(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=hu(i.buffer,e),s=new i.constructor(o,i.byteOffset,i.length);return e.set(r,s),s}let t=Object.getPrototypeOf(r),n=Object.create(t);e.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:hu(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var yi=b(()=>{});var le,It=b(()=>{L2();u0();yi();le=(()=>{let r=N2((i,o)=>({...gt(ET)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var zd,Vv,F,Me=b(()=>{zd=class zd{register(e){return zd.loggers.push(e),this}logError(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;zd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=
`)?`${r}${e}`:`${r}
${e}`}async function RT(r,e,t){let n=t.destination;if(n?.type!=="specifiedFile")return!1;let i=Gv(r,n);if(!i)throw new Error(`Append link target file not found or is not a Markdown file: ${n.path}`);let o=MT(r,e,{sourcePath:i.path,linkType:"link"});return await r.vault.process(i,s=>zX(s,o)),!0}async function HX(r){let e=window.navigator?.clipboard;if(!e?.writeText)return F.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return F.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function $T(r){let e=WX(r);return await HX(e)?(new jv.Notice(`Copied link to '${r.basename}' to clipboard.`,SB),!0):(new jv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,SB),!1)}var jv,SB,Yv=b(()=>{jv=require("obsidian");Me();Jd();SB=4e3});function ts(r){if(r.nodeType===Node.DOCUMENT_NODE)return r;let e=r.ownerDocument;if(!e)throw new Error("Unable to resolve owner document for DOM node.");return e}function ep(r){let e=ts(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function Hr(r,e){return ts(r).createElement(e)}function Kv(r,e){return ts(r).createTextNode(e)}var pc=b(()=>{});function OT(r){for(let e of r.workspace.getLeavesOfType("markdown")){let t=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{let n=ts(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(jX))continue;let o=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:t.file,key:o}}catch{continue}}return null}function GX(r,e,t){let n=e.trim();if(!n)throw new Error("Cannot append link to an empty frontmatter property key.");let i=FB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeof o=="string"){r[i]=`${o} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${i}' because it contains a ${typeof o} value.`)}function PB(r,e,t,n=Xd){let i=e.trim();if(!i)throw new Error("Cannot append link to an empty frontmatter property key.");let o=FB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeof s=="object")throw new Error(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${o}' because it is not a list and the link-handling mode is '${DB[n]}'. Choose '${DB.alwaysAppend}' to convert it into a list and append.`);r[o]=[s,t]}function FB(r,e){let t=IB(e),n=Object.keys(r).filter(i=>IB(i)===t);if(n.length>1)throw new Error(`Cannot append link to frontmatter property '${e}' because the note has multiple properties that normalize to that key.`);return n[0]??e}function IB(r){return r.trim().toLowerCase()}async function NT(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{GX(i,e.key,n)}),!0}catch(i){return F.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${i instanceof Error?i.message:String(i)}`),!1}}var DB,jX,rm=b(()=>{Me();Jd();pc();DB={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},jX=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function Qv(r,e){let t=Nn(r);return t?.file?.path===e.path?t:null}function I0(r,e){try{let t=Nn(e);return t?(t.editor.replaceSelection(r),!0):(F.logError(`unable to append '${r}' to current line.`),!1)}catch{return F.logError(`unable to append '${r}' to current line.`),!1}}function P0(r,e,t){try{let n=Nn(t);if(!n)return F.logError(`unable to insert '${r}' on new line ${e}.`),!1;let i=n.editor,s=
`),l=a.length,c=a[l-1]?.length??0;if(e==="above")i.replaceRange(r+`
`,{line:s,ch:0}),i.setCursor({line:s+l-1,ch:c});else{let u=i.getLine(s);i.replaceRange(`
`+r,{line:s,ch:u.length}),i.setCursor({line:s+l,ch:c})}return!0}catch{return F.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function F0(r,e){return P0(r,"above",e)}function M0(r,e){return P0(r,"below",e)}function YX(r,e,t,n){let i=l=>r.posToOffset(l),o=e.map(l=>{let[c,u]=i(l.anchor)<=i(l.head)?[l.anchor,l.head]:[l.head,l.anchor];return{from:c,to:u,text:n(r.getRange(c,u))}}).sort((l,c)=>i(l.from)-i(c.from)),s=o.map(({from:l,to:c,text:u})=>t==="replaceSelection"?{from:l,to:c,text:u}:{from:c,text:u}),a=[];if(t==="replaceSelection"){let l=0;for(let{from:c,to:u,text:d}of o)a.push(i(c)+l+d.length),l+=d.length-(i(u)-i(c))}r.transaction({changes:s}),t==="replaceSelection"&&r.setSelections(a.map(l=>({anchor:r.offsetToPos(l)})))}async function MB(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=Xd,textForSelection:a}=n,l=r.workspace.getActiveViewOfType(LT.MarkdownView);if(!l){let p="Cannot append link because no active Markdown view is available.";if(i)throw new Error(p);F.logMessage(p);return}if(t==="inFrontmatter"){let p=l.file;if(!p)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(p,m=>{PB(m,o??"",e,s)});return}let c=l.editor;if(!c){let p="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(p);F.logMessage(p);return}let u=c.listSelections().map(p=>({anchor:{...p.anchor},head:{...p.head}}));if(a&&u.length>0&&(t==="replaceSelection"||t==="afterSelection")){YX(c,u,t,a);return}if(t==="replaceSelection"){c.replaceSelection(e);return}let d=({line:p,ch:m})=>c.posToOffset({line:p,ch:m}),f=u.sort((p,m)=>d(m.head)-d(p.head));for(let p of f){let m=d(p.anchor)>d(p.head)?p.anchor:p.head;switch(t){case"afterSelection":{c.replaceRange(e,m);break}case"endOfLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length};c.replaceRange(e,g);break}case"newLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length},w=v.length===0?"":`
`;c.replaceRange(w+e,g);break}}}}async function tp(r,e,t){if(!t?.enabled)return!1;let n=xu(t),i=r.workspace.getActiveViewOfType(LT.MarkdownView),o=n.placement!=="inFrontmatter";if(!i||!i.file||o&&!i.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let s=i.file.path,a=MT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement}),l=n.displayText==="selection"?c=>MT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement,alias:c}):void 0;return await MB(r,a,n.placement,{requireActiveView:!1,frontmatterProperty:n.frontmatterProperty,frontmatterHandling:n.frontmatterHandling,textForSelection:l}),!0}function R0(r,e,t,n){try{if(e.extension!=="md"||!Number.isSafeInteger(t)||t<0||t>n.length)return!1;let i=r.workspace.getActiveViewOfType(LT.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;return!o||o.getValue()!==n?!1:(o.setCursor(o.offsetToPos(t)),!0)}catch{return F.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var LT,RB=b(()=>{LT=require("obsidian");Cu();Me();Jd();Yv();rm()});function BT(r){return ir.test(r)||Wr.test(r)||Vi.test(r)}function fo(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=BT(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof $B.TFile?i:null}function Wi(r){if(!Array.isArray(r))return[];let e=new Set,t=[];for(let n of r){if(typeof n!="string")continue;let i=n.trim().replace(/^\/+/,"").replace(/\/+$/,"");!i||e.has(i)||(e.add(i),t.push(i))}return t}function $0(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var $B,UT=b(()=>{$B=require("obsidian");Tt()});function NB(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Xv(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function KX(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function OB(r){return r.parent?.id??r.parent??null}function QX(r,e){let t=OB(e),n=r.filter(s=>s===e||NB(s)?!1:t===null||OB(s)!==t);if(n.length===0)return null;let i=r.indexOf(e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(s=>n.includes(s))??n[0]}function XX(r){return r instanceof nm.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function ZX(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&NB(n))return QX(KX(r),n)??r.workspace.getLeaf("tab");switch(e){case"reuse":return r.workspace.getLeaf(!1);case"tab":return r.workspace.getLeaf("tab");case"split":return r.workspace.getLeaf("split",t);case"window":return r.workspace.getLeaf("window");case"left-sidebar":return r.workspace.getLeftLeaf(!0);case"right-sidebar":return r.workspace.getRightLeaf(!0);default:return r.workspace.getLeaf("tab")}}async function fc(r,e,t={}){let{location:n="tab",direction:i="vertical",mode:o,focus:s=!0,eState:a,originLeaf:l}=t,c=typeof e=="string"?r.vault.getAbstractFileByPath(e):e;if(!XX(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??Xv(r),d=ZX(r,n,i,u);if(!d)throw new Error("Could not obtain a workspace leaf.");if(await d.openFile(c),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=d.getViewState(),p={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(p.mode="preview",delete p.source):o==="source"?(p.mode="source",p.source=!0):o==="live"||o==="live-preview"?(p.mode="source",p.source=!1):typeof o=="object"&&o.mode==="source"&&(p.mode="source",p.source=o.source),await d.setViewState({...f,state:{...p,...a}})}return s&&r.workspace.setActiveLeaf(d,{focus:!0}),d}function O0(r){return(0,nm.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function LB(r,e){return O0(r)===O0(e)}function rp(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{let o=i.view;if(o instanceof nm.FileView&&o.file&&(o.file===e||LB(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var nm,B
`,e),l=a===-1?r.length:a,c=r.slice(e,l).replace(/\r$/,""),u=a===-1?r.length+1:a+1,d=JX.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return UB(r.slice(o,e),s)}else if(d){let f=d[2].trim().split(/\s+/)[0]?.toLowerCase();(f==="js"||f==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?UB(r.slice(o),s):{code:null,error:eZ}}function UB(r,e){return r.trim().length===0?{code:"",error:tZ}:{code:`
`.repeat(e)+r}}var JX,eZ,tZ,Zv=b(()=>{JX=/^ {0,3}(`{3,})(.*)$/,eZ="No ```js (or ```javascript) code block found in the note.",tZ="The ```js code block is empty."});function VB(r){return r instanceof VT}function nZ(r){return r.charCodeAt(0)===65279?r.slice(1):r}function iZ(r){return nZ(r).trimStart().slice(0,rZ).toLowerCase()}function oZ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(iZ(r))}function N0(r,e){let t=new VT(r);throw e.reportLoadErrors!==!1&&lt(t),t}function sZ(r){return`QuickAdd could not load ${r}. This file looks like a saved webpage, not a JavaScript file. Open the script on GitHub, use the Raw button, then download the .js file and select that file in QuickAdd.`}function aZ(r){return`QuickAdd loaded ${r}, but its default export is not a function. Change it to module.exports = async (params) => { ... } or exports.default = async (params) => { ... }. If you meant to export several functions, use module.exports = { run } and select Script::run.`}function lZ(r,e){let t=e?`the required module "${e}"`:"a required module";return`QuickAdd could not load ${r} because it could not find ${t}. Check that the required file or package exists, and that the capitalization in require(...) matches the file name exactly.`}function cZ(r){return qB(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function qB(r){return!r||typeof r!="object"?!1:r.code==="MODULE_NOT_FOUND"?!0:(r instanceof Error?r.message:String(r)).includes("Cannot find module")}function uZ(r){return r!==null&&typeof r=="object"}function dZ(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function pZ(r){return typeof r=="function"?!0:uZ(r)?dZ(r):!1}function np(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function WT(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=np(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function ka(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){F.logError(`failed to load file ${r.path}.`);return}if(n instanceof qT.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(ir.test(n.path)){let{code:m,error:v}=mc(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new qT.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}oZ(l)&&N0(sZ(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw qB(m)&&N0(lZ(r.path,cZ(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:f}=np(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){let m;for(;m=f.shift();)u=u[m]}return d&&!p&&!pZ(u)&&N0(aZ(r.path),t),u}}var qT,rZ,VT,zT=b(()=>{qT=require("obsidian");Tt();Me();Zv();Cr();rZ=1024,VT=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function hc(r){if(r==null||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return"";let e=String(r).trim();return e.startsWith("#")?e.substring(1).trim():e}function Eu(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(hc).filter(Boolean)}var HT=b(()=>{});var zi,ip=b(()=>{HT();zi=class{static filterFiles(e,t,n){let i=e;return i=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}static applyInclusionFilters(e,t,n){let i=!1,o=e,s=this.getIncludeFolders(t);return s.length>0&&(i=!0,o=o.filter(a=>s.some(l=>this.matchesFolder(a,l)))),t.tags&&t.tags.length>0&&(i=!0,o=o.filter(a=>this.matchesAllTags(a,t.tags??[],n))),i?o:e}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders&&t.excludeFolders.length>0&&t.excludeFolders.some(o=>this.matchesFolder(i,o))||t.excludeTags&&t.excludeTags.length>0&&this.matchesAnyTag(i,t.excludeTags,n)||t.excludeFiles&&t.excludeFiles.length>0&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter
`:" "))}catch(m){F.logError(`Failed to insert pasted image link: ${m instanceof Error?m.message:String(m)}`),new C_.Notice("QuickAdd: saved the pasted image but could not insert its link.")}}return e.addEventListener("paste",c),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l),{isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),detach:()=>{o=!0,e.removeEventListener("paste",c),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l)}}}function hee(r){let e=bV.then(r,r);return bV=e.catch(()=>{}),e}function wV(r){return Object.hasOwn(my,r)}function gee(r){let e=[];for(let t of Array.from(r.items??[])){if(t.kind!=="file"||!wV(t.type))continue;let n=t.getAsFile();n&&e.push({file:n,mimeType:t.type})}if(e.length>0)return e;for(let t of Array.from(r.files??[]))wV(t.type)&&e.push({file:t,mimeType:t.type});return e}function vee(r,e){r.focus();let t=!1;try{t=r.ownerDocument.execCommand("insertText",!1,e)}catch{t=!1}if(t)return;let n=r.selectionStart??r.value.length,i=r.selectionEnd??n;r.setRangeText(e,n,i,"end"),r.dispatchEvent(new Event("input",{bubbles:!0}))}var C_,bV,x_=b(()=>{C_=require("obsidian");Me();OP();bV=Promise.resolve()});function NP(r){return!r.isComposing&&r.key==="Enter"&&r.shiftKey&&(r.ctrlKey||r.metaKey)}var Am,Sr,Hs=b(()=>{Am=require("obsidian");PP();FP();MP();RP();$P();x_();zr();Sr=class r extends Am.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&NP(t)){t.preventDefault(),this.skip();return}!t.isComposing&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new Tm({kind:"single",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new Cm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new xm(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,y_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}get isOptionalPrompt(){return this.options?.optional===!0}createInputField(t,n,i){let o=new Am.TextComponent(t);return o.inputEl.setCssStyles({width:"100%"}),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=_m(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new Am.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marg
`,e-1)+1,l=r.indexOf(`
`,Math.max(e,t)),c=l===-1?r.length:l,u=r.slice(a,e),d=r.slice(t,c),f=(u.match(/^\s*/)||[""])[0],p=r[e-1]==='"'&&r[t]==='"'||r[e-1]==="'"&&r[t]==="'",m=u.replace(/["']$/,""),g=d.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,y=/:\s*$/.test(m)&&g,w=/^\s*-\s*$/.test(m)&&g;return{isInYaml:!0,isQuoted:p,lineStart:a,lineEnd:c,baseIndent:f,isKeyValuePosition:y,isListItemPosition:w}}var LP=b(()=>{});function _V(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(kee,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`)}function by(r){return`"${_V(r)}"`}function BP(r,e,t){let n=yy(r,e,t,vy(r));return!n.isInYaml||!n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}function Dm(r,e,t,n){return BP(r,e,t)?r[e-1]==='"'?_V(n):n.replace(/'/g,"''"):n}function UP(r,e,t){let n=yy(r,e,t,vy(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var kee,VP=b(()=>{LP();kee=new RegExp("[\0-\x7F]","g")});function __(r,e,t){let n=r.trim().toLowerCase();if(See.has(n))return n;t?.(`QuickAdd: Unsupported multi-select format "${r}" in "${e}". Supported formats: auto, inline, yaml, markdown.`)}function Dee(r,e){let t=r.lastIndexOf(`
`,e-1)+1;return r.slice(t,e).match(/^\s*/)?.[0]??""}function Iee(r){return`- ${r.replace(/\r\n?|\n/g,`
`)}`}function AV(r){let{input:e,matchStart:t,values:n,format:i}=r;if(i==="auto")return;let o=n.map(a=>String(a));if(i==="inline")return o.join(",");if(i==="yaml")return`[${o.map(by).join(", ")}]`;if(o.length===0)return"";let s=Dee(e,t);return o.map(Iee).join(`
${s}`)}var See,A_=b(()=>{VP();See=new Set(["auto","inline","yaml","markdown"])});function S_(r,e){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function Fee(r){let e=r.map(t=>`"${t}"`);return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function kV(r,e){let t=S_(r,32),n=`{{FIELD:${S_(e,48)}}}`,i=Pee.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;let o=EV(r,k_);return o.length>0?`Unknown FIELD filter "${t}" - did you mean ${Fee(o)}? Ignored in ${n}.`:`Unknown FIELD filter "${t}" in ${n} was ignored. Supported filters: ${k_.join(", ")}.`}function Mee(r,e){let t=S_(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${S_(e,48)}}}.`}function Ree(r,e,t){(t.warn??Sm)(kV(r,e))}var k_,Pee,Yi,Ru=b(()=>{T_();op();TV();A_();k_=["folder","tag","inline","inline-code-blocks","exclude-folder","exclude-tag","exclude-file","default","default-from","default-empty","default-always","case-sensitive","multi","format"],Pee=new Map([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);Yi=class{static parse(e,t){let n=Bs(e).map(c=>c.trim()),i=n[0],o={},s=!1,a="auto",l=!1;for(let c=1;c<n.length;c++){let u=n[c];if(u.toLowerCase()==="multi"){s=!0;continue}let d=mo(u);if(!d){let m=u.toLowerCase();t?.warnUnknown&&m&&(t.warn??Sm)(k_.includes(m)?Mee(m,e):kV(m,e));continue}let f=d.key,p=d.value;if(!k_.includes(f)){t?.warnUnknown&&Ree(f,e,t);continue}switch(f){case"multi":s=Tu(p);break;case"format":l=!0,a=__(p,`{{FIELD:${e}}}`,t?.warn)??"auto";break;case"folder":o.folders||(o.folders=[]),o.folders.push(p),o.folder||(o.folder=p);break;case"tag":{o.tags||(o.tags=[]);let m=p.startsWith("#")?p.substring(1):p;o.tags.push(m);break}case"inline":o.inline=p.toLowerCase()==="true";break;case"inline-code-blocks":o.inlineCodeBlocks||(o.inlineCodeBlocks=[]),o.inlineCodeBlocks.push(...p.split(",").map(m=>m.trim().toLowerCase()).filter(m=>m.length>0));break;case"default":o.defaultValue=p;break;case"default-from":o.defaultFrom=p.toLowerCase();break;case"default-empty":o.defaultEmpty=p.toLowerCase()==="true";break;case"default-always":o.defaultAlways=p.toLowerCase()==="true";break;case"case-sensitive":o.caseSensitive=p.toLowerCase()==="true";break;case"exclude-folder":o.excludeFolders||(o.excludeFolders=[]),o.excludeFolders.push(p);break;case"exclude-tag":{o.excludeTags||(o.excludeTags=[]);let m=p.startsWith("#")?p.substring(1):p;o.excludeTags.push(m);break}case"exclude-file":o.excludeFiles||(o.excludeFiles=[]),o.excludeFiles.push(p);break}}return!s&&l&&(t?.warn?.(`QuickAdd: |format: needs |multi in "{{FIELD:${e}}}"; ignoring.`),a="auto"),{fieldName:i,filters:o,...s?{multiSelect:s}:{},...a!=="auto"?{multiFormat:a}:{}}}}});function qP(r){return r.replace(/^\/+|\/+$/g,"")}function wy(r,e=t=>t){return JSON.stringify([...r].map(e).sort())}function SV(r,e){let t=[`folder=${qP(r)}`];return e.folders?.length&&t.push(`folders=${wy(e.folders,qP)}`),e.tags?.length&&t.push(`tags=${wy(e.tags)}`),e.excludeFolders?.length&&t.push(`xfolder=${wy(e.excludeFolders,qP)}`),e.excludeTags?.length&&t.push(`xtag=${wy(e.excludeTags)}`),e.excludeFiles?.length&&t.push(`xfile=${wy(e.excludeFiles)}`),t.join("|")}function Oee(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[SV(e,a),`mode=${t}`];return n&&l.push(`label=${n}`),i&&l.push("optional"),o&&l.push("custom"),s&&l.push("multi"),l.join("|")}function D_(r,e){if(!r)return null;let t=Bs(r),n=(t.shift()??"").trim();if(!n)return null;let i=t,o=Sa(i,"optional");i=o.remaining;let s=o.found,a=Sa(i,"custom");i=a.remaining;let l=a.found,c=Sa(i,"multi");i=c.remaining;let u=c.found,d="name",f=[];for(let C of i){let _=C.trim().toLowerCase();if($ee.has(_)){d=_;continue}f.push(C)}let p,m;for(let C of f){let _=mo(C);_&&(_.key==="label"&&_.value?p=_.value:_.key==="name"&&_.value&&(m=_.value))}let v=Yi.parse(r,{warn:e?.warn}),g=u||(v.multiSelect??!1),y=v.multiFormat??"auto",w={folder:n,tags:v.filters.tags,excludeFolders:v.filters.excludeFolders,excludeTags:v.filters.excludeTag
`)?r.replace(/\r?\n/g,`
`):r.includes("\\n")?r.replace(/\\n/g,`
`):r}function ete(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function NV(r,e){let t=r.trim();if(!t)return;let n=Jee(t),i=e?.propertyType??Ty(e?.app,e?.propertyKey),o=ete(i),a=o||i===null,c=n.split(/\n/).map(u=>u.trim()).filter(u=>u.length>0);if(a&&c.length>0&&c.every(u=>/^-\s+/.test(u)))return c.map(u=>u.replace(/^-[\s]*/,"").trim());if(n.startsWith("[")&&n.endsWith("]")||n.startsWith("{")&&n.endsWith("}")){if(i&&!o&&i!=="list")return;try{return JSON.parse(n)}catch{}}if(n.includes(",")&&a){let u=Zee(n);if(u.length>1)return u}}var OV,LV=b(()=>{M_();OV={"[":"]","(":")","{":"}","<":">"}});function R_(r){if(typeof r=="string"&&r.startsWith("@date:")){let e=r.substring(6),t=new Date(e);if(!Number.isNaN(t.getTime()))return t}return r}function HP(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function BV(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function UV(r){if(HP(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var _y=b(()=>{});var VV,Ma,$_=b(()=>{LP();LV();_y();M_();VV="\0",Ma=class{constructor(e){this.app=e;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(e){let{input:t,matchStart:n,matchEnd:i,rawValue:o,fallbackKey:s,collectionActive:a,heuristicEnabled:l}=e;if(!a)return;let c=vy(t),u=yy(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),f=d.trim(),p=d.match(/^\s*([^:]+):/),m=p?p[1].trim():s,v=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,g=null;if(u.isKeyValuePosition?g=[m]:v.test(f)&&(g=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!g||g.length===0)return;let y=g[g.length-1],w=o;if(l&&typeof o=="string"){let C=NV(o,this.buildParseOptions(y));C!==void 0&&(w=C)}if(!HP(w)||Array.isArray(w)&&w.length===0||!l&&!BV(w))return;let x=g.join(VV);return this.map.set(x,w),w}drain(){let e=new Map(this.map);return this.map.clear(),e}merge(e){for(let[t,n]of e)this.map.set(t,n)}buildParseOptions(e){return{propertyKey:e,propertyType:this.resolvePropertyType(e),app:this.app}}findListParentPath(e,t,n){let i=t-1,o=[],s=n.length;for(;i>=0;){let a=e.lastIndexOf(`
`,i),l=a===-1?0:a+1,c=e.slice(l,i+1),u=c.trim();if(u.length===0){i=l-2;continue}if(u==="---"||u==="...")break;if(u.startsWith("-")){i=l-2;continue}let d=c.match(/^(\s*)([^:\n]+):/);if(d){let p=(d[1]??"").length;if(p<s&&(o.unshift(d[2].trim()),s=p,s===0))break}i=l-2}return o.length>0?o:null}resolvePropertyType(e){if(!this.app)return null;if(this.propertyTypeCache.has(e))return this.propertyTypeCache.get(e)??null;let t=Ty(this.app,e);return this.propertyTypeCache.set(e,t),t}};Ma.PATH_SEPARATOR=VV});function Pm(r){return tte.has(r.toUpperCase())}var O_,N_,L_,tte,B_=b(()=>{O_=new RegExp("[\0-]","u"),N_=/[\\/:*?"<>|]/u,L_=/[. ]$/u,tte=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});function qV(r){if(!r)return null;let e=r.trim().toLowerCase();switch(e){case"kebab":case"snake":case"camel":case"pascal":case"title":case"lower":case"upper":case"slug":return e;default:return null}}function KP(r){return qV(r)!==null}function jP(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function GP(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function U_(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function rte(r){return/^\p{Ll}/u.test(r)&&U_(r)}function nte(r){if(!r)return[];{let t=r.match(/^([\p{Ll}][\p{Lu}]{2,})([\p{N}]+)?$/u);if(t){let n=[t[1]];return t[2]&&n.push(t[2]),n}}if(/^[\p{Ll}][\p{Lu}][\p{Ll}]+(?:[\p{Lu}][\p{Ll}]+)*$/u.test(r))return[r];let e=r;return e=e.replace(/([\p{Lu}])([\p{Lu}][\p{Ll}])/gu,"$1 $2"),e=e.replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2"),e=e.replace(/([\p{L}])([\p{N}])/gu,"$1 $2"),e=e.replace(/([\p{N}])([\p{L}])/gu,"$1 $2"),e.trim().split(/\s+/u).map(t=>t.trim()).filter(Boolean)}function ite(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(nte).filter(Boolean)}function V_(r,e){let t=qV(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=ite(r);if(n.length===0)return"";switch(t){case"kebab":return n.map(i=>i.toLowerCase()).join("-");case"snake":return n.map(i=>i.toLowerCase()).join("_");case"camel":{let[i,...o]=n,s=i?rte(i)?i:i.toLowerCase():"",a=o.map(l=>GP(l)||U_(l)?l:jP(l));return[s,...a].join("")}case"pascal":return n.map(i=>GP(i)||U_(i)?i:jP(i)).join("");case"title":return n.map(i=>GP(i)||U_(i)?i:jP(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return Pm(i)?`${i}-`:i}default:return r}}var YP,q_=b(()=>{B_();YP=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function W_(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var QP=b(()=>{});function ate(r,e,t){return t&&e?`${r}${XP}${e}`:r}function ky(r){let e=r.indexOf(XP);return e===-1?r:r.slice(0,e)}function lte(r,e){let t=e.toLowerCase(),n=null;for(let i of r.keys())if(i.toLowerCase()===t&&r.get(i)!==void 0){if(n)return null;n=i}return n}function j_(r,e){if(!e)return null;let t=[e],n=ky(e);n!==e&&t.push(n);for(let i of t){if(r.has(i)&&r.get(i)!==void 0)return i;let o=lte(r,i);if(o)return o}return null}function cte(r){let{remaining:e,found:t}=Sa(r,"optional");return{remaining:e,optional:t}}function jV(r){let{remaining:e,optional:t}=cte(r),{remaining:n,found:i}=Sa(e,"trim");return{remaining:n,optional:t,trim:i}}function ute(r,e){let t=r.trim();if(!t)return!1;let n=mo(t);return n?(e?ZP:H_).has(n.key):!1}function dte(r,e){let t=e?ZP:H_;return r.some(n=>{let i=mo(n.trim());if(!i||i.key!=="type"||!t.has("type"))return!1;let o=i.value.trim().toLowerCase();return o==="number"||o==="slider"})}function GV(r,e,t,n,i){if(r.length===0)return{defaultValue:"",allowCustomInput:!1,usesOptions:!1};let o=t?ZP:H_,s=dte(r,t),a=r.some(V=>ute(V,t)||s&&WV.has(mo(V.trim())?.key??"")),l=e&&r.some(V=>V.trim().toLowerCase()==="custom"),c=e&&r.some(V=>V.trim().toLowerCase()==="multi");if(!(a||l||c))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let d,f,p="",m=!1,v,g,y,w,x,C,_,E,D=!1,P,H;for(let V of r){let oe=V.trim();if(!oe)continue;if(e&&oe.toLowerCase()==="custom"){
`,n++):o=="\\"?(t+="\\",n++):t+="\\":t+=i}return t}expandLinebreakEscapesOutsideTokens(e){let t=Fy(e),n="",i=0,o=0;for(;i<e.length;){for(;o<t.length&&t[o].end<=i;)o++;let s=t[o];if(s&&s.start===i){n+=e.slice(s.start,s.end),i=s.end;continue}if(e[i]==="{"&&e[i+1]==="{"){let c=e.indexOf("}}",i+2),u=!1;if(c!==-1){let d=c+2;for(let f=o;f<t.length;f++){let p=t[f];if(p.start>=d)break;if(d<p.end&&d>p.start){u=!0;break}}}if(c!==-1&&!u){n+=e.slice(i,c+2),i=c+2;continue}}let a=e[i],l=e[i+1];a==="\\"?l==="n"?(n+=`
`,i+=2):l==="\\"?(n+="\\",i+=2):(n+="\\",i+=1):(n+=a,i+=1)}return n}replaceRandomInString(e){let t=e;for(;v0.test(t);){let n=v0.exec(t);if(!n||!n[1])continue;let i=parseInt(n[1]);if(i<=0||i>100)throw new Error(`Random string length must be between 1 and 100. Got: ${i}`);let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s="";for(let a=0;a<i;a++)s+=o.charAt(Math.floor(Math.random()*o.length));t=t.replace(n[0],s)}return t}replaceTitleInString(e){return this.replaceCurrentFileTokensInString(e,{title:!0})}}});var G,Oe,ls,pt=b(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(G||(G={}));(function(r){r[r.SUNDAY=0]="SUNDAY",r[r.MONDAY=1]="MONDAY",r[r.TUESDAY=2]="TUESDAY",r[r.WEDNESDAY=3]="WEDNESDAY",r[r.THURSDAY=4]="THURSDAY",r[r.FRIDAY=5]="FRIDAY",r[r.SATURDAY=6]="SATURDAY"})(Oe||(Oe={}));(function(r){r[r.JANUARY=1]="JANUARY",r[r.FEBRUARY=2]="FEBRUARY",r[r.MARCH=3]="MARCH",r[r.APRIL=4]="APRIL",r[r.MAY=5]="MAY",r[r.JUNE=6]="JUNE",r[r.JULY=7]="JULY",r[r.AUGUST=8]="AUGUST",r[r.SEPTEMBER=9]="SEPTEMBER",r[r.OCTOBER=10]="OCTOBER",r[r.NOVEMBER=11]="NOVEMBER",r[r.DECEMBER=12]="DECEMBER"})(ls||(ls={}))});function nt(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function K_(r,e){r.assign("hour",e.getHours()),r.assign("minute",e.getMinutes()),r.assign("second",e.getSeconds()),r.assign("millisecond",e.getMilliseconds()),r.assign("meridiem",e.getHours()<12?G.AM:G.PM)}function Tc(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Lt(r,e){r.imply("hour",e.getHours()),r.imply("minute",e.getMinutes()),r.imply("second",e.getSeconds()),r.imply("millisecond",e.getMilliseconds()),r.imply("meridiem",e.getHours()<12?G.AM:G.PM)}var on=b(()=>{pt()});function Lu(r,e,t,n,i=0){let o=0,s=0;for(;s<n;)o++,new Date(r,e-1,o).getDay()===t&&s++;return new Date(r,e-1,o,i)}function oq(r,e,t,n=0){let i=t===0?7:t,o=new Date(r,e-1+1,1,12),s=o.getDay()===0?7:o.getDay(),a;return s===i?a=7:s<i?a=7+s-i:a=s-i,o.setDate(o.getDate()-a),new Date(r,e-1,o.getDate(),n)}function Q_(r,e,t={}){if(r==null)return null;if(typeof r=="number")return r;let n=t[r]??Tte[r];return n==null?null:typeof n=="number"?n:e==null?null:e>n.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}var Tte,nF=b(()=>{pt();Tte={ACDT:630,ACST:570,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,ALMT:360,AMST:-180,AMT:-240,ANAST:720,ANAT:720,AQTT:300,ART:-180,AST:-240,AWDT:540,AWST:480,AZOST:0,AZOT:-60,AZST:300,AZT:240,BNT:480,BOT:-240,BRST:-120,BRT:-180,BST:60,BTT:360,CAST:480,CAT:120,CCT:390,CDT:-300,CEST:120,CET:{timezoneOffsetDuringDst:120,timezoneOffsetNonDst:60,dstStart:r=>oq(r,ls.MARCH,Oe.SUNDAY,2),dstEnd:r=>oq(r,ls.OCTOBER,Oe.SUNDAY,3)},CHADT:825,CHAST:765,CKT:-600,CLST:-180,CLT:-240,COT:-300,CST:-360,CT:{timezoneOffsetDuringDst:-300,timezoneOffsetNonDst:-360,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},CVT:-60,CXT:420,ChST:600,DAVT:420,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEST:180,EET:120,EGST:0,EGT:-60,EST:-300,ET:{timezoneOffsetDuringDst:-240,timezoneOffsetNonDst:-300,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},FJST:780,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GMT:0,GST:240,GYT:-240,HAA:-180,HAC:-300,HADT:-540,HAE:-240,HAP:-420,HAR:-360,HAST:-600,HAT:-90,HAY:-480,HKT:480,HLV:-210,HNA:-240,HNC:-360,HNE:-300,HNP:-480,HNR:-420,HNT:-150,HNY:-540,HOVT:420,ICT:420,IDT:180,IOT:360,IRDT:270,IRKST:540,IRKT:540,IRST:210,IST:330,JST:540,KGT:360,KRAST:480,KRAT:480,KST:540,KUYT:240,LHDT:660,LHST:630,LINT:840,MAGST:720,MAGT:720,MART:-510,MAWT:300,MDT:-360,MESZ:120,MEZ:60,MHT:720,MMT:390,MSD:240,MSK:180,MST:-420,MT:{timezoneOffsetDuringDst:-360,timezoneOffsetNonDst:-420,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:690,NOVST:420,NOVT:360,NPT:345,NST:-150,NUT:-660,NZDT:780,NZST:720,OMSST:420,OMST:420,PDT:-420,PET:-300,PE
2026-01-05 19:25:56 +08:00
tags: ${JSON.stringify(Array.from(this._tags).sort())},
knownValues: ${JSON.stringify(this.knownValues)},
impliedValues: ${JSON.stringify(this.impliedValues)}},
reference: ${JSON.stringify(this.reference)}]`}date(){let e=this.get("timezoneOffset")??this.reference.timezoneOffset;if(e==null)return this.dateWithoutTimezoneAdjustment();let t=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return t.setUTCFullYear(this.get("year")),new Date(t.getTime()-e*6e4)}addTag(e){return this._tags.add(e),this}addTags(e){for(let t of e)this._tags.add(t);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let e=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return e.setFullYear(this.get("year")),e}},at=class r{constructor(e,t,n,i,o){ae(this,"refDate");ae(this,"index");ae(this,"text");ae(this,"reference");ae(this,"start");ae(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new X(e),this.end=o}clone(){let e=new r(this.reference,this.index,this.text);return e.start=this.start?this.start.clone():null,e.end=this.end?this.end.clone():null,e}date(){return this.start.date()}addTag(e){return this.start.addTag(e),this.end&&this.end.addTag(e),this}addTags(e){return this.start.addTags(e),this.end&&this.end.addTags(e),this}tags(){let e=new Set(this.start.tags());if(this.end)for(let t of this.end.tags())e.add(t);return e}toString(){let e=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(e)} ...}]`}}});function Er(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function _te(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function ee(r){return`(?:${_te(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var ze=b(()=>{});function Gr(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function ft(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=vt(n,{year:1}),o=vt(n,{year:-1});return Math.abs(i.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())?n=i:Math.abs(o.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())&&(n=o),n.getFullYear()}var zt=b(()=>{Bt()});function Ate(r){let e=r.toLowerCase();return iF[e]!==void 0?iF[e]:e==="a"||e==="an"||e=="the"?1:e.match(/few/)?3:e.match(/half/)?.5:e.match(/couple/)?2:e.match(/several/)?7:parseFloat(e)}function Lm(r){let e=r.toLowerCase();return oF[e]!==void 0?oF[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function wl(r){if(/BE/i.test(r))return r=r.replace(/BE/i,""),parseInt(r)-543;if(/BCE?/i.test(r))return r=r.replace(/BCE?/i,""),-parseInt(r);if(/(AD|CE)/i.test(r))return r=r.replace(/(AD|CE)/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function Gs(r){let e={},t=r,n=aq.exec(t);for(;n;)Ste(e,n),t=t.substring(n[0].length).trim(),n=aq.exec(t);return Object.keys(e).length==0?null:e}function Ste(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=Ate(e[1]),n=$y[e[2].toLowerCase()];r[n]=t}var X_,sF,go,iF,oF,lq,$y,cq,Nm,Bu,uq,aq,kte,dq,_c,Uu,sn=b(()=>{ze();zt();X_={sunday:0,sun:0,"sun.":0,monday:1,mon:1,"mon.":1,tuesday:2,tue:2,"tue.":2,wednesday:3,wed:3,"wed.":3,thursday:4,thurs:4,"thurs.":4,thur:4,"thur.":4,thu:4,"thu.":4,friday:5,fri:5,"fri.":5,saturday:6,sat:6,"sat.":6},sF={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},go={...sF,jan:1,"jan.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,jun:6,"jun.":6,jul:7,"jul.":7,aug:8,"aug.":8,sep:9,"sep.":9,sept:9,"sept.":9,oct:10,"oct.":10,nov:11,"nov.":11,dec:12,"dec.":12},iF={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},oF={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6,seventh:7,eighth:8,ninth:9,tenth:10,eleventh:11,twelfth:12,thirteenth:13,fourteenth:14,fifteenth:15,sixteenth:16,seventeenth:17,eighteenth:18,nineteenth:19,twentieth:20,"twenty first":21,"twenty-first":21,"twenty second":22,"twenty-second":22,"twenty third":23,"twenty-third":23
`,t+2);t=o===-1?r.length:o+1;continue}if(n==="/"&&i==="*"){let o=r.indexOf("*/",t+2);t=o===-1?r.length:o+2;continue}return t}return t}function vx(r,e){let t=r[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let n="";for(let i=e+1;i<r.length;i++){let o=r[i];if(o==="\\"){let s=r[i+1];if(s===void 0)return null;n+=s,i+=1;continue}if(o===t)return{value:n,end:i+1};n+=o}return null}function VG(r,e){let t=/^[A-Za-z_$][\w$]*/.exec(r.slice(e));return t?{value:t[0],end:e+t[0].length}:null}function gx(r,e,t,n){let i=0;for(let o=e;o<r.length;o++){let s=r[o],a=r[o+1];if(s==='"'||s==="'"||s==="`"){let l=vx(r,o);if(!l)return-1;o=l.end-1;continue}if(s==="/"&&a==="/"){let l=r.indexOf(`
`,o+2);o=l===-1?r.length:l;continue}if(s==="/"&&a==="*"){let l=r.indexOf("*/",o+2);if(l===-1)return-1;o=l+1;continue}if(s===t){i+=1;continue}if(s===n&&(i-=1,i===0))return o}return-1}function zG(r){let e=new Map,t=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'`])/g,n;for(;(n=t.exec(r))!==null;){let i=vx(r,t.lastIndex-1);i&&(e.set(n[1],i.value),t.lastIndex=i.end)}return e}function bue(r){let e=[],t=zG(r),n=0;for(;n<r.length;){n=La(r,n);let i=r[n],o=r[n+1];if(i==='"'||i==="'"||i==="`"){let l=vx(r,n);n=l?l.end:n+1;continue}if(i==="/"&&o==="/"){let l=r.indexOf(`
`,n+2);n=l===-1?r.length:l+1;continue}if(i==="/"&&o==="*"){let l=r.indexOf("*/",n+2);n=l===-1?r.length:l+2;continue}let s=v$(r,n,t);if(!s){n+=1;continue}if(n=La(r,s.end),r[n]!==":"){n=s.end;continue}if(n=La(r,n+1),s.name!=="options"||r[n]!=="{")continue;let a=gx(r,n,"{","}");if(a===-1)break;e.push({start:n+1,end:a}),n=a+1}return e}function v$(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){let i=vx(r,e);return i?{name:i.value,end:i.end}:null}if(r[e]==="["){let i=La(r,e+1),o=VG(r,i),s=gx(r,e,"[","]");if(s===-1)return null;let a=o?La(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}let n=VG(r,e);return n?{name:n.value,end:n.end}:null}function wue(r){let e=new Map,t=0;for(;t<r.length;){if(t=La(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;let n=v$(r,t,new Map);if(!n?.name){t+=1;continue}if(t=La(r,n.end),r[t]!==":"){t+=1;continue}if(t=La(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let i=vx(r,t);if(!i)break;e.set(n.name,i.value),t=i.end;continue}if(r.slice(t,t+4)==="true"){e.set(n.name,!0),t+=4;continue}if(r.slice(t,t+5)==="false"){e.set(n.name,!1),t+=5;continue}if(r[t]==="{"){let i=gx(r,t,"{","}");if(i===-1)break;t=i+1;continue}if(r[t]==="["){let i=gx(r,t,"[","]");if(i===-1)break;t=i+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}return e}function Cue(r){let e=wue(r),t=e.get("type"),n=e.get("secret");return t==="secret"||(t==="text"||t==="input")&&n===!0}function Rh(r,e){let t=e&&gue.test(e)?mc(r).code??"":r,n=new Set,i=!1,o=zG(t);for(let{start:s,end:a}of bue(t)){let l=s;for(;l<a;){if(l=La(t,l),t[l]===","){l+=1;continue}if(l>=a)break;let c=v$(t,l,o);if(!c){l+=1;continue}if(l=La(t,c.end),t[l]!==":"){l+=1;continue}if(l=La(t,l+1),t[l]!=="{"){l+=1;continue}let u=gx(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);Cue(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}function $h(r){return td(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}function Mh(r){return td(r)&&r[qG]===!0&&typeof r.secretRef=="string"&&r.secretRef.trim().length>0}function mk(r){return{[qG]:!0,secretRef:r}}function xue(r,e,t){let n=r.id?.trim()||r.path||r.name||"script";return h$(fk(n),fk(WG(e,t)))}function Eue(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>$h(t)).map(([t])=>t):[]}function Tue(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>$h(t)):[]}function _ue(r){return typeof r.id=="string"&&r.id.trim().length>0}async function y$(r,e){let t=vk(r);if(!t?.getSecret)return null;try{return await Promise.resolve(t.getSecret(e))}catch(n){return F.logWarning(`Failed to read user script SecretStorage entry "${e}": ${g$(n)}`),null}}async function Aue(r,e,t){let n=vk(r);if(!n?.setSecret)return!1;try{return await Promise.resolve(n.setSecret(e,t)),!0}catch(i){return F.logWarning(`Failed to write user script SecretStorage entry "${e}": ${g$(i)}`),!1}}async function kue(r,e,t,n,i){let o=e.id?.trim()||e.path||e.name||"script",s=fk(o),a=fk(WG(t,i)),l=h$(s,a),c=1;for(;;){let u=await y$(r,l);if(!u||u===n)return l;c+=1,l=h$(s,a,String(c))}}async function b$(r,e,t,n,i,o){if(n.length===0)return null;let s=i?.trim()||await kue(r,e,t,n,o);return await Aue(r,s,n)?s:null}async function w$(r,e){let t=e?.trim();if(!t)return!0;let n=vk(r);if(!n)return!0;let i=n.deleteSecret??n.removeSecret??n.delete;try{if(i)return await Promise.resolve(i.call(n,t)),!0;if(n.setSecret)return await Promise.resolve(n.setSecret(t,"")),!0}catch(o){F.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${g$(o)}`)}return!1}async function yk(r,e,t){let n=e.settings??{},i={...n},o=new Set(Eue(t));for(let[s,a]of Object.entries(n)){if(Mh(a)){let l=await y$(r,a.secretRef);if(l){i[s]=l;continue}throw new Error(`Secret setting "${s}" for user script "${e.name}" is unavailable. Re-enter it on this device.`)}o.has(s)&&(i[s]=typeof a=="string"?a:"")}return i}async function Oh(r,e,t){let n=Tue(t);if(n.length===0)return!1;let i=vk(r);if(!i?.getSecret||!i?.setSecret)return n.some(([a])=>{let l=e.settings?.[a];return typeof l=="string"&&l.length>0})&&F.logWarning(`SecretStorage unavailable; leavi
2026-01-05 19:25:56 +08:00
`));let s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.top_p=s.top_p),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(a=>({name:a.name,description:a.description,input_schema:a.parameters})),e.toolChoice?o.tool_choice=vme(e.toolChoice,e.disableParallel):e.disableParallel&&(o.tool_choice={type:"auto",disable_parallel_tool_use:!0})),e.responseFormat?.schema&&(o.output_config={format:{type:"json_schema",schema:Ox(e.responseFormat.schema)}}),o}function vme(r,e){let t=e?{disable_parallel_tool_use:!0}:{};return typeof r=="string"?r==="required"?{type:"any",...t}:r==="none"?{type:"none"}:{type:"auto",...t}:{type:"tool",name:r.name,...t}}function yme(r){let e=r.content??[],t=e.filter(a=>a.type==="tool_use").map(a=>({id:a.id??"",name:a.name??"",args:a.input??{}})),n=String(r.stop_reason??""),i=r.usage??{},o=i.input_tokens??0,s=i.output_tokens??0;return{content:e.filter(a=>a.type==="text").map(a=>a.text??"").join(""),toolCalls:t,normalizedStopReason:n==="tool_use"||t.length>0?"tool_calls":n==="max_tokens"?"length":n==="end_turn"||n==="stop_sequence"?"stop":"other",rawStopReason:n,usage:{promptTokens:o,completionTokens:s,totalTokens:o+s}}}function bme(r,e){let t=[],n=[];for(let a of e.messages)if(a.role==="system")a.content&&t.push(a.content);else if(a.role==="user")n.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(Array.isArray(a.providerRaw))n.push({role:"model",parts:a.providerRaw});else{let l=[];a.content&&l.push({text:a.content});for(let c of a.toolCalls??[])l.push({functionCall:{name:c.name,args:c.args??{}}});n.push({role:"model",parts:l})}else n.push({role:"user",parts:a.results.map(l=>({functionResponse:{name:l.name,response:l.isError?{error:l.content}:{result:l.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(`
2026-01-05 19:25:56 +08:00
`)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(a=>({name:a.name,description:a.description,parameters:a.parameters}))}],e.toolChoice&&(i.toolConfig=wme(e.toolChoice)));let o={},s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.topP=s.top_p),e.maxOutputTokens!==void 0&&(o.maxOutputTokens=e.maxOutputTokens),e.responseFormat?.schema&&(o.responseMimeType="application/json",o.responseSchema=e.responseFormat.schema),Object.keys(o).length>0&&(i.generationConfig=o),i}function wme(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function Cme(r){let e=r.candidates?.[0]??{},n=(e.content??{}).parts??[],i=n.filter(a=>a.functionCall).map((a,l)=>({id:a.functionCall?.id??`gemini-call-${l}`,name:a.functionCall?.name??"",args:a.functionCall?.args??{}})),o=String(e.finishReason??""),s=r.usageMetadata??{};return{content:n.filter(a=>typeof a.text=="string").map(a=>a.text??"").join(""),toolCalls:i,normalizedStopReason:i.length>0?"tool_calls":o==="MAX_TOKENS"?"length":o==="STOP"?"stop":"other",rawStopReason:o,usage:{promptTokens:s.promptTokenCount??0,completionTokens:s.candidatesTokenCount??0,totalTokens:s.totalTokenCount??0},providerRaw:n}}function FO(r,e,t,n=8192){switch(r){case"anthropic":return gme(e,t,n);case"gemini":return bme(e,t);default:return fme(e,t)}}function W4(r,e){switch(r){case"anthropic":return yme(e);case"gemini":return Cme(e);default:return mme(e)}}var pme,z4=b(()=>{pme=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function hg(r,e,t){let n=(0,Lx.requestUrl)({...r,throw:!1});t&&t();let i=await n;if(i.status>=400)throw Qk(e,i);return i.json}function xme(r){return{id:r.id,model:r.model,content:r.choices[0].message.content,usage:{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens},stopReason:r.choices[0].finish_reason,stopSequence:null,created:r.created}}function Eme(r){return{id:r.id,model:r.model,content:r.content.filter(e=>e.type==="text").map(e=>e.text??"").join(""),usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},stopReason:r.stop_reason,stopSequence:r.stop_sequence,created:Date.now()}}async function Tme(r,e,t,n,i,o,s){return hg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:e.name,...i,messages:[{role:"system",content:n},{role:"user",content:o}]})},t.name,s)}function MO(r){if(typeof r.maxOutputTokens=="number"&&Number.isFinite(r.maxOutputTokens)&&r.maxOutputTokens>0)return Math.floor(r.maxOutputTokens);let e=4096;return Number.isFinite(r.maxTokens)&&r.maxTokens>0?Math.min(e,r.maxTokens):e}async function _me(r,e,t,n,i,o,s){let a={model:e.name,max_tokens:MO(e),messages:[{role:"user",content:o}]};return n&&n.trim().length>0&&(a.system=n),typeof i.temperature=="number"&&(a.temperature=i.temperature),typeof i.top_p=="number"&&(a.top_p=i.top_p),hg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":r,"anthropic-version":"2023-06-01"},body:JSON.stringify(a)},t.name,s)}async function Ame(r,e,t,n,i,o,s){let a=`${t.endpoint}/v1beta/models/${encodeURIComponent(e.name)}:generateContent`,l={};typeof i.temperature=="number"&&(l.temperature=i.temperature),typeof i.top_p=="number"&&(l.topP=i.top_p);let c={contents:[{role:"user",parts:[{text:o}]}]};return n&&n.trim().length>0&&(c.systemInstruction={role:"system",parts:[{text:n}]}),Object.keys(l).length>0&&(c.generationConfig=l),hg({url:a,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":r},body:JSON.stringify(c)},t.name,s)}function kme(r){let e=r.candidates?.[0],n=(e?.content?.parts??[]).map(i=>typeof i.text=="string"?i.text:"").join("");return{id:`${Date.now()}`,model:r.modelVersion??"gemini",content:n,usage:{promptTokens:r.usageMetadata?.promptTokenCount
${e}`:""}`});function UO(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function OO(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return ta.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),X4(),e}function Nx(r,e){let t=ta.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,X4())}function Q4(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:ta.slice(-e).map(UO).reverse()}function X4(){if(ta.length<=Y4)return;let r=ta.length-Y4;for(;r>0;){let e=ta.findIndex(t=>t.status!=="pending");if(e===-1)break;ta.splice(e,1),r-=1}}function Z4(r){let e=ta.find(t=>t.id===r);return e?UO(e):null}function J4(){let r=ta[ta.length-1];return r?UO(r):null}function e5(){ta.splice(0,ta.length)}async function Sme(r,e,t){if(typeof r!="function")throw new TypeError("Callback must be a function.");if(!(e instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof t!="number"||t<=0)throw new TypeError("Interval must be a positive number.");let n=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),await sleep(t)}function Dme(r){return r instanceof Error?r:new Error(String(r))}async function Ime(r,e,t,n=!0,i){let o;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{let c=t.map(u=>u.basename);if(i)o=await i.suggester(c,t,"Select a prompt template");else if(n)o=await Nr.Suggest(r,c,t);else throw new Ee("This AI command asks which prompt template to use, but this run is non-interactive. Enable a specific prompt template in the command, or re-run with the ui flag.")}Mi(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);Mi(a instanceof K4.TFile,`${s} is not a file`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function t5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=gg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=rs(r,u),[f,p]=await Ime(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(p),v=["prompting",`Using prompt template "${f}".`];n.setMessage(v[0],v[1]);let y=MS(r,i,o,s,c,e.modelOptions)(m),x=(await VO(y,100,E=>{n.setMessage(v[0],`${v[1]} (${(E/1e3).toFixed(2)}s)`)},E=>{n.setMessage("finished",`Took ${(E/1e3).toFixed(2)}s.`)})).content,C=("> "+x).replace(/\n/g,`
> `),_={[a]:x,[`${a}-quoted`]:C};return window.setTimeout(()=>n.hide(),5e3),_}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),Dt(i)?new St("Input cancelled by user"):i}}async function VO(r,e,t,n){let i=Date.now();return await Sme(()=>t(Date.now()-i),r,e),n(Date.now()-i),await r}async function r5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=gg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,prompt:c,modelOptions:u}=e;n.setMessage("waiting","QuickAdd is formatting the prompt template.");let d=await t(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);let m=MS(r,i,o,s,l,u)(d),g=(await VO(m,100,x=>{n.setMessage(f[0],`${f[1]} (${(x/1e3).toFixed(2)}s)`)},x=>{n.setMessage("finished",`Took ${(x/1e3).toFixed(2)}s.`)})).content,y=("> "+g).replace(/\n/g,`
> `),w={[a]:g,[`${a}-quoted`]:y};return window.setTimeout(()=>n.hide(),5e3),w}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}function Fme(){return Array.from(new Set([BO,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>V_(BO,r))])).filter(Boolean)}function i5(r){if(r.length<=1)return null;let e=Math.floor(r.length/2),t=[`
`,`
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(let a of t){let l=r.lastIndexOf(a,e),c=r.indexOf(a,e),u=[l,c].filter(d=>d>0);for(let d of u){let f=d+a.length;if(f<=0||f>=r.length)continue;let p=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=e,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function Mme(r){let e=new RegExp(Hd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function Rme(r){return $s.test(r)||vu.test(r)||fl.test(r)||uc.test(r)}function $me(r){return n5.some(e=>r.includes(e))}function Ome(r){return n5.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function o5(r){if(r>$S)throw new Error(`QuickAdd would split this chunked AI request into more than ${$S} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function Nme(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Uo(s)<=n?null:i5(s);if(!l){t.push(s),o+=1,o5(o);continue}i.push(l[1],l[0])}}function Lme(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function Ume(r,e){if(typeof e=="string"){let s=r.split(e);return{chunks:s,separators:new Array(Math.max(0,s.length-1)).fill(e)}}if(Lme(e)>0||Bme.test(e.source))return{chunks:r.split(e),separators:null};let t=new RegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function Vme(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];Nme(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Uo(l.text)+Math.max(1,Uo(l.joiner));s!==""&&a+c>=t&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function qme(r,e){let t=Math.max(1,Math.floor(r));if(e!==void 0&&Number.isFinite(e)&&e>0){let n=Math.floor(e);return{budget:Math.min(t,n),clamped:n>t}}return{budget:t,clamped:!1}}async function s5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=gg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:u,modelOptions:d}=e;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let f=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=Ume(u,f),v=await t(c,{chunk:BO});if(!(Mme(c)||Rme(c)&&$me(v)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,w=GG(y),x=Ome(v),C=Uo(l)+Uo(x);if(C>=y)throw new Error(`The estimated prompt overhead (${C} tokens) exceeds the model's entire context window (${y} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:_,clamped:E}=qme(w-C,e.maxChunkTokens);E&&F.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${_} estimated tokens per chunk instead.`);let D=e.shouldMerge??!0,P=Vme(p,m,_,D);o5(P.length);let H=MS(r,i,o,s,l,d),V=["prompting",`${P.length} prompts being sent.`];n.setMessage(V[0],V[1]);let oe=new LO(5,1e3*30),ce=!1,R=0,O=Promise.resolve(),q=ge=>{let be=O.then(()=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:ge})});return O=be.then(()=>{},()=>{}),be},B=async(ge,be=0)=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await q(ge)}catch(Ue){throw ce=!0,Ue}try{return[(await oe.add(()=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");if(R+=1,R>$S)throw new Error(`Chunked AI request exceeded the safety limit of ${$S} provider requests.`);return H(xe)})).content]}catch(Ue){let $t=i5(ge);if(be>=Pme||!$t||!AY(Ue))throw
> `),pe={[a]:K,[`${a}-quoted`]:se};return window.setTimeout(()=>n.hide(),5e3),pe}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var K4,Y4,ta,LO,Pme,$S,BO,n5,Bme,RS=b(()=>{K4=require("obsidian");zr();Co();qc();It();qt();$x();Cr();$O();Sx();NO();bx();Me();Tt();q_();Y4=25,ta=[];LO=class{constructor(e,t){this.maxRequests=e;this.intervalMs=t;this.queue=[];this.startTimes=[]}add(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{t(await e())}catch(i){n(Dme(i))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;let e=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i<this.intervalMs),this.startTimes.length>=this.maxRequests){let i=this.startTimes[0],o=Math.max(0,this.intervalMs-(e-i));window.setTimeout(()=>this.schedule(),o+1);return}let t=this.queue.shift();if(!t)return;this.startTimes.push(e);let n=t();window.setTimeout(()=>this.schedule(),this.intervalMs),this.schedule()}},Pme=12,$S=500,BO="quickadd_chunk_probe_123456789";n5=Fme();Bme=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});function a5(r){return r.normalize("NFKD").toLowerCase()}var Wme,Qp,qO=b(()=>{Wme=0;Qp=class{constructor(e,t){this.options=t;this.instanceId=++Wme;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=document.createElement("div"),this.rootEl.className="qa-searchable-multi-select";let n=document.createElement("div");n.className="search-input-container qa-searchable-multi-select__search-container",this.searchInputEl=document.createElement("input"),this.searchInputEl.className="qa-searchable-multi-select__search",this.searchInputEl.type="search",this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.placeholder=t.searchPlaceholder??"Search options...",this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),n.appendChild(this.searchInputEl),this.summaryEl=document.createElement("div"),this.summaryEl.className="qa-searchable-multi-select__summary",this.summaryEl.setAttribute("aria-live","polite"),this.listEl=document.createElement("div"),this.listEl.className="qa-searchable-multi-select__list",this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),this.rootEl.append(n,this.summaryEl,this.listEl),e.appendChild(this.rootEl),this.searchInputEl.addEventListener("input",()=>{this.query=this.searchInputEl.value,this.renderList()}),this.searchInputEl.addEventListener("keydown",i=>{if(i.key==="ArrowDown"){i.preventDefault(),this.renderedRows[0]?.input.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}i.key==="Escape"&&this.query&&(i.preventDefault(),i.stopPropagation(),this.query="",this.searchInputEl.value="",this.renderList())}),this.setItems(t.items)}setItems(e){this.indexedItems=e.map((t,n)=>({item:t,index:n,searchableText:a5(`${t.label} ${t.searchText??""}`)})),this.searchInputEl.disabled=e.length===0,this.renderList()}focusSearchOnOpen(){document.body.classList.contains("is-mobile")||this.searchInputEl.focus()}refreshSelection(){for(let{item:e,input:t}of this.renderedRows)t.checked=this.options.isSelected(e),t.closest("label")?.classList.toggle("is-selected",t.checked);this.updateSummary()}getMatchingItems(){let e=a5(this.query.trim()).split(/\s+/).filter(Boolean);return e.length===0?this.indexedItems:this.indexedItems.filter(({searchableText:t})=>e.every(n=>t.includes(n)))}getVisibleItems(e){if(e.length<=200)return e;let t=[],n=[];for(let i of e)(this.options.isSelected(i.item)?t:n).push(i);return[...t,...n].slice(0,200)}renderList(){this.listEl.replaceChildren(),this.renderedRows=[];let e=this.getMatchingItems(),t=this.getVisibleItems(e);if(t.length===0){let n=document.createElement("div");n.className="qa-searchable-multi-select__empty",n.setAttribute("role","status"),n.textContent=this.indexedItems.length?`No options match \u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(let n o
`,e-1)+1,a=r.slice(o,t).split(`
`),l=a.length-1,c=0,u=a.map((d,f)=>f===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(`
`),selectionStart:e+i.length,selectionEnd:t+c}}function Yme(r,e){r.setSelectionRange(e.regionStart,e.regionEnd);let t=r.ownerDocument,n=!1;try{n=typeof t.execCommand=="function"&&t.execCommand("insertText",!1,e.replacement)}catch{n=!1}if(!n){let i=r.value;r.value=i.slice(0,e.regionStart)+e.replacement+i.slice(e.regionEnd),r.setSelectionRange(e.selectionStart,e.selectionEnd),r.dispatchEvent(new Event("input",{bubbles:!0}));return}r.setSelectionRange(e.selectionStart,e.selectionEnd)}function d5(r,e={}){let t=i=>{if(i.key!=="Tab"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey||i.isComposing||i.defaultPrevented)return;i.preventDefault();let o=r.selectionStart??r.value.length,s=r.selectionEnd??o;Yme(r,Gme(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var p5=b(()=>{});var bg,ld,GO=b(()=>{bg=require("obsidian");PP();FP();MP();RP();$P();p5();Hs();x_();zr();ld=class r extends bg.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&NP(t)){t.preventDefault(),this.skip();return}(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new Tm({kind:"multi",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new Cm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new xm(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaWideInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,y_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}createInputField(t,n,i){let o=new bg.TextAreaComponent(t);return o.inputEl.classList.add("wideInputPromptInputEl"),o.inputEl.setAttribute("dir","auto"),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.disposeIndent=d5(o.inputEl),this.options?.imagePaste&&(this.imagePasteHandle=_m(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new bg.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}get isOptionalPrompt(){return this.options?.optional===!0}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marginTop:"1rem",gap:"0.5rem"})}submit(){if(!(this.didSubmit||this.didClose)){if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}this.input=this.inputComponent?.inputEl?.value??this.input,this.didSubmit=!0,this.close()}}skip(){this.didSubmit||(this.input="",this.didSubmit=!0,this.close())}cancel(){this.
\u261A
\\end{${r}}\u261A`}var Kme,Qme,g5,KO=b(()=>{Kme=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\u261A}\u261A","[\u261A]\u261A","\\above","\\abovewithdelims","\\acute","\\aleph","\\alpha","\\amalg","\\And","\\angle","\\approx","\\approxeq","\\arccos","\\arcsin","\\arctan","\\arg","\\array","\\arrowvert","\\Arrowvert","\\ast","\\asymp","\\atop","\\atopwithdelims","\\backepsilon","\\backprime","\\backsim","\\backsimeq","\\backslash","\\bar","\\barwedge","\\Bbb","\\Bbbk","\\because","\\begin","\\beta","\\beth","\\between","\\bf","\\Bigg","\\bigg","\\Big","\\big","\\Biggl","\\Biggm","\\Biggr","\\biggl","\\biggm","\\biggr","\\Bigl","\\Bigm","\\Bigl","\\bigl","\\bigm","\\bigr","\\bigcap","\\bigcirc","\\bigcup","\\bigodot","\\bigoplus","\\bigotimes","\\bigsqcup","\\bigstar","\\bigtriangledown","\\bigtriangleup","\\biguplus","\\bigvee","\\bigwedge","\\binom","\\blacklozenge","\\blacksquare","\\blacktriangle","\\blacktriangledown","\\blacktriangleleft","\\blacktriangleright","\\bmod","\\boldsymbol","\\bot","\\bowtie","\\Box","\\boxdot","\\boxed","\\boxminus","\\boxplus","\\boxtimes","\\brace","\\bracevert","\\brack","\\breve","\\bullet","\\Bumpeq","\\bumpeq","\\cal","\\cancel","\\Cap","\\cap","\\cases","\\cdot","\\cdotp","\\cdots","\\centerdot","\\cfrac{\u261A}{\u261A}\u261A","\\check","\\checkmark","\\chi","\\choose","\\circ","\\circeq","\\circlearrowleft","\\circlearrowright","\\circledast","\\circledcirc","\\circleddash","\\circledR","\\circledS","\\class","\\clubsuit","\\colon","\\color","\\complement","\\cong","\\coprod","\\cos","\\cosh","\\cot","\\coth","\\cr","\\csc","\\cssId","\\Cup","\\cup","\\curlyeqprec","\\curlyeqsucc","\\curlyvee","\\curlywedge","\\curvearrowleft","\\curvearrowright","\\dagger","\\ddagger","\\daleth","\\dashleftarrow","\\dashrightarrow","\\dashv","\\dbinom","\\dot","\\ddot","\\dddot","\\ddddot","\\ddots","\\DeclareMathOperator","\\def","\\deg","\\Delta","\\delta","\\det","\\dfrac{\u261A}{\u261A}\u261A","\\diagdown","\\diagup","\\Diamond","\\diamond","\\diamondsuit","\\digamma","\\dim","\\displaylines","\\displaystyle","\\div","\\divideontimes","\\Doteq","\\doteq","\\dotplus","\\dots","\\dotsb","\\dotsc","\\dotsi","\\dotsm","\\dotso","\\doublebarwedge","\\doublecap","\\doublecup","\\downarrow","\\Downarrow","\\downdownarrows","\\downharpoonleft","\\downharpoonright","\\ell","\\emptyset","\\end","\\enspace","\\epsilon","\\eqalign","\\eqalignno","\\eqcirc","\\eqsim","\\eqslantgtr","\\eqslantless","\\equiv","\\eta","\\eth","\\exists","\\exp","\\fallingdotseq","\\fbox","\\Finv","\\flat","\\forall","\\frac{\u261A}{\u261A}\u261A","\\frak","\\frown","\\Game","\\Gamma","\\gamma","\\gcd","\\ge","\\geq","\\geqq","\\geqslant","\\genfrac","\\gets","\\gg","\\ggg","\\gggtr","\\gimel","\\gtrapprox","\\gnapprox","\\gneq","\\gneqq","\\gvertneqq","\\gtrsim","\\gnsim","\\grave","\\gt","\\gtrdot","\\gtreqless","\\gtreqqless","\\gtrless","\\hat","\\hbar","\\hbox","\\hdashline","\\hline","\\heartsuit","\\hfil","\\hfill","\\hom","\\hookleftarrow","\\hookrightarrow","\\hphantom","\\href","\\hskip","\\hslash","\\hspace","\\Huge","\\huge","\\iddots","\\idotsint","\\iff","\\iiiint","\\iiint","\\iint","\\int","\\intop","\\Im","\\imath","\\impliedby","\\implies","\\in","\\inf","\\infty","\\injlim","\\intercal","\\iota","\\it","\\jmath","\\Join","\\kappa","\\ker","\\kern","\\Lambda","\\lambda","\\land","\\langle","\\LARGE","\\Large","\\large","\\LaTeX","\\lbrace","\\lbrack","\\lceil","\\ldotp","\\ldots","\\le","\\leq","\\leqq","\\leqslant","\\leadsto","\\left","\\leftarrow","\\Leftarrow","\\leftarrowtail","\\leftharpoondown","\\leftharpoonup","\\leftleftarrows","\\leftrightarrow","\\Leftrightarrow","\\leftrightarrows","\\leftrightharpoons","\\leftrightsquigarrow","\\leftroot","\\leftthreetimes","\\leqalignno","\\lessapprox","\\lessdot","\\lesseqgtr","\\lesseqqgtr","\\lessgtr","\\lesssim","\\lfloor","\\lg","\\lgroup","\\lhd","\\lim","\\liminf","\\limits","\\limsup","\\ll","\\llap","\\llcorner","\\lrcorner","\\Lleftarrow","\\lll","\\llless","\\lmoustache","\\ln","\\lnapprox","\\lneq","\\lneqq","\\lnot",
`||T.charAt(ve)==="\r"&&T.charAt(ve+1)!==`
`)&&(J++,ue===0&&(ue=ve+1)),ve--}var Ve=Q+J,yt=k-ue;return L[k]={line:Ve,lineStart:ue},{offset:k,line:Ve+1,column:yt+1}}function ce(T){if(!C(T))throw new Error("not a parser: "+T)}function R(T,k){return typeof T=="string"?T.charAt(k):T[k]}function O(T){if(typeof T!="number")throw new Error("not a number: "+T)}function q(T){if(typeof T!="function")throw new Error("not a function: "+T)}function B(T){if(typeof T!="string")throw new Error("not a string: "+T)}var ie=2,j=3,Y=8,K=5*Y,se=4*Y,pe=" ";function ge(T,k){return new Array(k+1).join(T)}function be(T,k,L){var Q=k-T.length;return Q<=0?T:ge(L,Q)+T}function xe(T,k,L,Q){return{from:T-k>0?T-k:0,to:T+L>Q?Q:T+L}}function Ue(T,k){var L,Q,J,ue,ve,Ve=k.index,yt=Ve.offset,Pr=1;if(yt===T.length)return"Got the end of the input";if(E(T)){var jt=yt-yt%Y,$i=yt-jt,bt=xe(jt,K,se+Y,T.length),pr=c(function(kt){return c(function(Eo){return be(Eo.toString(16),2,"0")},kt)},(function(kt,Eo){var da=kt.length,Ts=[],cn=0;if(da<=Eo)return[kt.slice()];for(var An=0;An<da;An++)Ts[cn]||Ts.push([]),Ts[cn].push(kt[An]),(An+1)%Eo==0&&cn++;return Ts})(T.slice(bt.from,bt.to).toJSON().data,Y));ue=(function(kt){return kt.from===0&&kt.to===1?{from:kt.from,to:kt.to}:{from:kt.from/Y,to:Math.floor(kt.to/Y)}})(bt),Q=jt/Y,L=3*$i,$i>=4&&(L+=1),Pr=2,J=c(function(kt){return kt.length<=4?kt.join(" "):kt.slice(0,4).join(" ")+" "+kt.slice(4).join(" ")},pr),(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2)}else{var kr=T.split(/\r\n|[\n\r\u2028\u2029]/);L=Ve.column-1,Q=Ve.line-1,ue=xe(Q,ie,j,kr.length),J=kr.slice(ue.from,ue.to),ve=ue.to.toString().length}var Yn=Q-ue.from;return E(T)&&(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2),l(function(kt,Eo,da){var Ts,cn=da===Yn,An=cn?"> ":pe;return Ts=E(T)?be((8*(ue.from+da)).toString(16),ve,"0"):be((ue.from+da+1).toString(),ve," "),[].concat(kt,[An+Ts+" | "+Eo],cn?[pe+ge(" ",ve)+" | "+be("",L," ")+ge("^",Pr)]:[])},[],J).join(`
`)}function $t(T,k){return[`
`,"-- PARSING FAILED "+ge("-",50),`
`,Ue(T,k),`
`,(L=k.expected,L.length===1?`Expected:
`+L[0]:`Expected one of the following:
`+L.join(", ")),`
`].join("");var L}function Ne(T){return T.flags!==void 0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}function Ke(){for(var T=[].slice.call(arguments),k=T.length,L=0;L<k;L+=1)ce(T[L]);return o(function(Q,J){for(var ue,ve=new Array(k),Ve=0;Ve<k;Ve+=1){if(!(ue=H(T[Ve]._(Q,J),ue)).status)return ue;ve[Ve]=ue.value,J=ue.index}return H(D(J,ve),ue)})}function Xe(){var T=[].slice.call(arguments);if(T.length===0)throw new Error("seqMap needs at least one argument");var k=T.pop();return q(k),Ke.apply(null,T).map(function(L){return k.apply(null,L)})}function ye(){var T=[].slice.call(arguments),k=T.length;if(k===0)return ut("zero alternates");for(var L=0;L<k;L+=1)ce(T[L]);return o(function(Q,J){for(var ue,ve=0;ve<T.length;ve+=1)if((ue=H(T[ve]._(Q,J),ue)).status)return ue;return ue})}function We(T,k){return ht(T,k).or(Be([]))}function ht(T,k){return ce(T),ce(k),Xe(T,k.then(T).many(),function(L,Q){return[L].concat(Q)})}function He(T){B(T);var k="'"+T+"'";return o(function(L,Q){var J=Q+T.length,ue=L.slice(Q,J);return ue===T?D(J,ue):P(Q,k)})}function _e(T,k){(function(J){if(!(J instanceof RegExp))throw new Error("not a regexp: "+J);for(var ue=Ne(J),ve=0;ve<ue.length;ve++){var Ve=ue.charAt(ve);if(Ve!=="i"&&Ve!=="m"&&Ve!=="u"&&Ve!=="s")throw new Error('unsupported regexp flag "'+Ve+'": '+J)}})(T),arguments.length>=2?O(k):k=0;var L=(function(J){return RegExp("^(?:"+J.source+")",Ne(J))})(T),Q=""+T;return o(function(J,ue){var ve=L.exec(J.slice(ue));if(ve){if(0<=k&&k<=ve.length){var Ve=ve[0],yt=ve[k];return D(ue+Ve.length,yt)}return P(ue,"valid match group (0 to "+ve.length+") in "+Q)}return P(ue,Q)})}function Be(T){return o(function(k,L){return D(L,T)})}function ut(T){return o(function(k,L){return P(L,T)})}function or(T){if(C(T))return o(function(k,L){var Q=T._(k,L);return Q.index=L,Q.value="",Q});if(typeof T=="string")return or(He(T));if(T instanceof RegExp)return or(_e(T));throw new Error("not a string, regexp, or parser: "+T)}function yr(T){return ce(T),o(function(k,L){var Q=T._(k,L),J=k.slice(L,Q.index);return Q.status?P(L,'not "'+J+'"'):D(L,null)})}function Pt(T){return q(T),o(function(k,L){var Q=R(k,L);return L<k.length&&T(Q)?D(L+1,Q):P(L,"a character/byte matching "+T)})}function Ar(T,k){arguments.length<2&&(k=T,T=void 0);var L=o(function(Q,J){return L._=k()._,L._(Q,J)});return T?L.desc(T):L}function ur(){return ut("fantasy-land/empty")}s.parse=function(T){if(typeof T!="string"&&!E(T))throw new Error(".parse must be called with a string or Buffer as its argument");var k,L=this.skip(xo)._(T,0);return k=L.status?{status:!0,value:L.value}:{status:!1,index:oe(T,L.furthest),expected:L.expected},delete V[T],k},s.tryParse=function(T){var k=this.parse(T);if(k.status)return k.value;var L=$t(T,k),Q=new Error(L);throw Q.type="ParsimmonError",Q.result=k,Q},s.assert=function(T,k){return this.chain(function(L){return T(L)?Be(L):ut(k)})},s.or=function(T){return ye(this,T)},s.trim=function(T){return this.wrap(T,T)},s.wrap=function(T,k){return Xe(T,this,k,function(L,Q){return Q})},s.thru=function(T){return T(this)},s.then=function(T){return ce(T),Ke(this,T).map(function(k){return k[1]})},s.many=function(){var T=this;return o(function(k,L){for(var Q=[],J=void 0;;){if(!(J=H(T._(k,L),J)).status)return H(D(L,Q),J);if(L===J.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");L=J.index,Q.push(J.value)}})},s.tieWith=function(T){return B(T),this.map(function(k){if((function(J){if(!_(J))throw new Error("not an array: "+J)})(k),k.length){B(k[0]);for(var L=k[0],Q=1;Q<k.length;Q++)B(k[Q]),L+=T+k[Q];return L}return""})},s.tie=function(){return this.tieWith("")},s.times=function(T,k){var L=this;return arguments.length<2&&(k=T),O(T),O(k),o(function(Q,J){for(var ue=[],ve=void 0,Ve=void 0,yt=0;yt<T;yt+=1){if(Ve=H(ve=L._(Q,J),Ve),!ve.status)return Ve;J=ve.index,ue.push(ve.value)}for(;yt<k&&(Ve=H(ve=L._(Q,J),Ve),ve.status);yt+=1)J=ve.index,ue.push(ve.value);return H(D(J,ue),Ve)})},s.result=function(T){return t
`),Qa=He(`\r
`),Xa=ye(Qa,Ho,_n).desc("newline"),Jc=ye(Xa,xo);o.all=jn,o.alt=ye,o.any=Ft,o.cr=_n,o.createLanguage=function(T){var k={};for(var L in T)({}).hasOwnProperty.call(T,L)&&(function(Q){k[Q]=Ar(function(){return T[Q](k)})})(L);return k},o.crlf=Qa,o.custom=function(T){return o(T(D,P))},o.digit=Es,o.digits=Gn,o.empty=ur,o.end=Jc,o.eof=xo,o.fail=ut,o.formatError=$t,o.index=dt,o.isParser=C,o.lazy=Ar,o.letter=re,o.letters=Ie,o.lf=Ho,o.lookahead=or,o.makeFailure=P,o.makeSuccess=D,o.newline=Xa,o.noneOf=function(T){return Pt(function(k){return T.indexOf(k)<0}).desc("none of '"+T+"'")},o.notFollowedBy=yr,o.of=Be,o.oneOf=function(T){for(var k=T.split(""),L=0;L<k.length;L++)k[L]="'"+k[L]+"'";return Pt(function(Q){return T.indexOf(Q)>=0}).desc(k)},o.optWhitespace=dr,o.Parser=o,o.range=function(T,k){return Pt(function(L){return T<=L&&L<=k}).desc(T+"-"+k)},o.regex=_e,o.regexp=_e,o.sepBy=We,o.sepBy1=ht,o.seq=Ke,o.seqMap=Xe,o.seqObj=function(){for(var T,k={},L=0,Q=(T=arguments,Array.prototype.slice.call(T)),J=Q.length,ue=0;ue<J;ue+=1){var ve=Q[ue];if(!C(ve)){if(_(ve)&&ve.length===2&&typeof ve[0]=="string"&&C(ve[1])){var Ve=ve[0];if(Object.prototype.hasOwnProperty.call(k,Ve))throw new Error("seqObj: duplicate key "+Ve);k[Ve]=!0,L++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(L===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(yt,Pr){for(var jt,$i={},bt=0;bt<J;bt+=1){var pr,kr;if(_(Q[bt])?(pr=Q[bt][0],kr=Q[bt][1]):(pr=null,kr=Q[bt]),!(jt=H(kr._(yt,Pr),jt)).status)return jt;pr&&($i[pr]=jt.value),Pr=jt.index}return H(D(Pr,$i),jt)})},o.string=He,o.succeed=Be,o.takeWhile=function(T){return q(T),o(function(k,L){for(var Q=L;Q<k.length&&T(R(k,Q));)Q++;return D(Q,k.slice(L,Q))})},o.test=Pt,o.whitespace=br,o["fantasy-land/empty"]=ur,o["fantasy-land/of"]=Be,o.Binary={bitSeq:p,bitSeqObj:function(T){f();var k={},L=0,Q=c(function(ue){if(_(ue)){var ve=ue;if(ve.length!==2)throw new Error("["+ve.join(", ")+"] should be length 2, got length "+ve.length);if(B(ve[0]),O(ve[1]),Object.prototype.hasOwnProperty.call(k,ve[0]))throw new Error("duplicate key in bitSeqObj: "+ve[0]);return k[ve[0]]=!0,L++,ve}return O(ue),[null,ue]},T);if(L<1)throw new Error("bitSeqObj expects at least one named pair, got ["+T.join(", ")+"]");var J=c(function(ue){return ue[0]},Q);return p(c(function(ue){return ue[1]},Q)).map(function(ue){return l(function(ve,Ve){return Ve[0]!==null&&(ve[Ve[0]]=Ve[1]),ve},{},c(function(ve,Ve){return[ve,ue[Ve]]},J))})},byte:function(T){if(f(),O(T),T>255)throw new Error("Value specified to byte constructor ("+T+"=0x"+T.toString(16)+") is larger in value than a single byte.");var k=(T>15?"0x":"0x0")+T.toString(16);return o(function(L,Q){var J=R(L,Q);return J===T?D(Q+1,J):P(Q,k)})},buffer:function(T){return m("buffer",T).map(function(k){return Buffer.from(k)})},encodedString:function(T,k){return m("string",k).map(function(L){return L.toString(T)})},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:w,int8BE:w(1),int16BE:w(2),int32BE:w(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(T){return T.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(T){return T.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(T){return T.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(T){return T.readDoubleLE(0)})},t.exports=o}])})})(eD,eD.exports);var M=eD.exports,M1=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u293
`)[0];let n=t.substring(2).trim();return M.makeSuccess(e+t.length,n)}),namedField:r=>M.alt(r.explicitNamedField,Jge(Ga.field).map(([e,t])=>rD.named(eve(t),e))),sortField:r=>M.seqMap(Ga.field.skip(M.optWhitespace),M.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(e,t)=>{let n=t.length==0?"ascending":t[0].toLowerCase();return n=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":return Q5(()=>({type:e,fields:[],showId:!0}),M.seqMap(M.regexp(/WITHOUT\s+ID/i).skip(M.optWhitespace).atMost(1),M.sepBy(r.namedField,M.string(",").trim(M.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return Q5(()=>({type:e,format:void 0,showId:!0}),M.seqMap(M.regexp(/WITHOUT\s+ID/i).skip(M.optWhitespace).atMost(1),Ga.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return M.succeed({type:e});case"calendar":return M.whitespace.then(M.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return M.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>M.seqMap(M.regexp(/FROM/i),M.whitespace,Ga.source,(e,t,n)=>n),whereClause:r=>M.seqMap(M.regexp(/WHERE/i),M.whitespace,Ga.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>M.seqMap(M.regexp(/SORT/i),M.whitespace,r.sortField.sepBy1(M.string(",").trim(M.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>M.seqMap(M.regexp(/LIMIT/i),M.whitespace,Ga.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>M.seqMap(M.regexp(/FLATTEN/i).skip(M.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>M.seqMap(M.regexp(/GROUP BY/i).skip(M.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>M.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>M.seqMap(r.headerClause.trim(o1),r.fromClause.trim(o1).atMost(1),r.clause.trim(o1).many(),(e,t,n)=>({header:e,source:t.length==0?Bl.folder(""):t[0],operations:n,settings:F1}))}),o1=M.alt(M.whitespace,Q8.comment).many().map(r=>r.join("")),tve=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,rve=r=>r.plugins.enabledPlugins.has("dataview");Ul.DATE_SHORTHANDS=T1;Ul.DURATION_TYPES=E1;Ul.EXPRESSION=Ga;Ul.KEYWORDS=_1;Ul.QUERY_LANGUAGE=Q8;Ul.getAPI=tve;Ul.isPluginEnabled=rve;Ul.parseField=Zge});function eE(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o+1];if(s==="["&&a==="["){n=!0,t+=s;continue}if(s==="]"&&a==="]"){n=!1,t+=s;continue}if(s===","&&!n){let l=t.trim();l&&e.push(l),t="";continue}t+=s}let i=t.trim();return i&&e.push(i),e}var R1=b(()=>{});function tE(r){return r.replace(/[\\"]/g,"\\$&")}function nve(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Z8(r){return tE(nve(r))}function aD(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var $1,rE,J8=b(()=>{$1=HN(X8());Me();R1();rE=class{static getDataviewAPI(e){let t=(0,$1.getAPI)(e);return t||(F.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){let n=new Set,i=this.getDataviewAPI(e);if(!i)return n;try{let s=`field("${tE(t)}")`,a=`TABLE ${s} WHERE ${s}`,l=await i.query(a);if(l.successful&&l.value.values)for(let c of l.value.values){let u=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeof d=="string"?n.add(d.trim()):aD(d)?n.add(d.path):d&&typeof d!="object"&&n.add(String(d).trim())}):aD(u)?n.add(u.path):u&&typeof u=="string"?eE(u).forEach(d=>n.add(d)):u&&typeof u!="object"&&n.add(String(u).trim())}}catch(o){F.logError(new Error(`Failed to query Dataview for field ${t}: ${o}`))}return n}static async getFieldValuesWithFilter(e,t,n={}){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${tE(t)}")`,l=[a],c=(n.folders?.length?n.folders:n.folder?[n.folder]:[]).map(v=>v.replace(/^\/+|\/+$/g,
`),o=[],s=!1,a=0,l="",c=[];for(let u of i){if(!s){let d=this.matchFenceOpen(u);d?(s=!0,a=d.length,l=d.info,c=[u]):o.push(u);continue}if(this.matchFenceClose(u,a)){let d=l.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&d!==void 0&&d.length>0&&n.has(d))for(let p=1;p<c.length;p++)o.push(c[p]);s=!1,c=[]}else c.push(u)}if(s)for(let u of c)o.push(u);return o.join(`
`)}static matchFenceOpen(e){let t=this.FENCE_OPEN_REGEX.exec(this.stripTrailingCarriage(e));return t?{length:t[1].length,info:t[2]}:null}static matchFenceClose(e,t){let n=this.FENCE_CLOSE_REGEX.exec(this.stripTrailingCarriage(e));return n!==null&&n[1].length>=t}static stripTrailingCarriage(e){return e.endsWith("\r")?e.slice(0,-1):e}static getFieldValues(e,t,n){return this.parseInlineFields(e,n).get(t)||new Set}};jc.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,jc.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,jc.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,jc.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,jc.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;Fg=jc});function L1(r){let e=[];return r.folder&&e.push(`folder:${r.folder}`),r.folders?.length&&e.push(`folders:${r.folders.join(",")}`),r.tags&&e.push(`tags:${r.tags.join(",")}`),r.inline&&e.push("inline:true"),r.inlineCodeBlocks?.length&&e.push(`inline-code-blocks:${r.inlineCodeBlocks.join(",")}`),r.caseSensitive&&e.push("case-sensitive:true"),r.excludeFolders&&e.push(`exclude-folders:${r.excludeFolders.join(",")}`),r.excludeTags&&e.push(`exclude-tags:${r.excludeTags.join(",")}`),r.excludeFiles&&e.push(`exclude-files:${r.excludeFiles.join(",")}`),r.defaultValue&&e.push(`default:${r.defaultValue}`),r.defaultEmpty&&e.push("default-empty:true"),r.defaultAlways&&e.push("default-always:true"),e.join("|")}async function t9(r,e,t){let n=await n9(r,e,t);return Ka.processValues(n,t).values}async function r9(r,e,t){let n=await n9(r,e,t),i=Ka.processValues(n,t);return{values:i.values,hasDefaultValue:i.hasDefaultValue}}async function n9(r,e,t){let n=Hc.getInstance(),i=L1(t),o=n.get(e,i);if(o)return o;let s=n.getRevision(),a=await B1(r,e,t);return n.setIfRevision(e,a,i,s),a}async function B1(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await ive(r,t);if(i.size>0)return i}try{if(!t.inline&&rE.isAvailable(r)){let i=await rE.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await ave(r,e,t)}async function ive(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=ove(r);if(n.size>0)return n}return await sve(r,e)}function ove(r){let e=new Set;try{let t=r.metadataCache.getTags?.();if(!t)return e;for(let n of Object.keys(t)){let o=(n.startsWith("#")?n.substring(1):n).trim();o&&e.add(o)}}catch{}return e}async function sve(r,e){let t=new Set,n=r.vault.getMarkdownFiles();n=zi.filterFiles(n,e,o=>r.metadataCache.getFileCache(o));let i=50;for(let o=0;o<n.length;o+=i){let a=n.slice(o,o+i).map(async c=>{let u=new Set;try{let d=r.metadataCache.getFileCache(c),f=d?.frontmatter?.tags;if(f!=null){let m=Array.isArray(f)?f:[f];for(let v of m){let g=String(v).trim();g&&u.add(g)}}let p=d?.frontmatter?.tag;if(p!=null){let m=Array.isArray(p)?p:[p];for(let v of m){let g=String(v).trim();g&&u.add(g)}}if(d?.tags)for(let m of d.tags){let v=String(m.tag??"").trim(),g=v.startsWith("#")?v.substring(1):v;g&&u.add(g)}}catch{}return u}),l=await Promise.all(a);for(let c of l)for(let u of c)t.add(u)}return t}async function ave(r,e,t){let n=new Set,i=r.vault.getMarkdownFiles();i=zi.filterFiles(i,t,s=>r.metadataCache.getFileCache(s));let o=50;for(let s=0;s<i.length;s+=o){let l=i.slice(s,s+o).map(async u=>{let d=new Set;try{let p=r.metadataCache.getFileCache(u)?.frontmatter?.[e];if(p!=null){if(Array.isArray(p))p.forEach(m=>{let v=String(m).trim();v&&d.add(v)});else if(typeof p!="object"){let m=String(p).trim();m&&d.add(m)}}if(t.inline)try{let m=await r.vault.read(u);Fg.getFieldValues(m,e,{includeCodeBlocks:t.inlineCodeBlocks}).forEach(g=>{let y=String(g).trim();y&&d.add(y)})}catch{}}catch{}return d}),c=await Promise.all(l);for(let u of c)for(let d of u)n.add(d)}return n}var U1=b(()=>{J8();ip();lD();O1();N1()});function lve(r,e){let t=e.trim();if(!t||!r)return null;let n=r[t];if(n===void 0){let i=t.toLowerCase(),o=Object.keys(r).find(s=>s.toLowerCase()===i);o!==void 0&&(n=r[o])}if(n==null)return null;if(Array.isArray(n)){let i=[];for(let o of n){let s=i9(o);s!
${l}`:`${l}
${a}`;return await this.app.vault.modify(t,c),t}catch(o){if(K1(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),lt(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=fo(this.app,t);if(!n)throw new Error(`Template file not found at path "${t}".`);return await this.app.vault.cachedRead(n)}}});var f9={};Jr(f9,{SingleTemplateEngine:()=>lE});var lE,Q1=b(()=>{fD();Me();lE=class extends hd{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody"}setPromptScope(t){this.promptScope=t}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||F.logError(`Template ${t} not found.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var m9={};Jr(m9,{SingleInlineScriptEngine:()=>X1});var X1,h9=b(()=>{oE();X1=class extends Vl{constructor(e,t,n,i){super(e,t,null,n,i)}async runAndGetOutput(e){let t=Object.getPrototypeOf(async function(){}).constructor;return await new t(e).bind(this.params,this).call()}}});var g9,Cs,Vg=b(()=>{g9=require("obsidian");Hs();nd();l5();jO();Tt();qc();h5();b5();uh();Ru();ip();js();yl();U1();O1();V1();Cu();Me();$m();Ey();l9();zr();Co();Cr();Cs=class extends bl{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.dateParser=o||Tl,i&&(this.variables=i?.variables)}async format(t){let n=t;return n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n),n=await this.replaceTemplateInString(n),n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n),n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(fl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}async formatFileName(t,n="generic"){if(Os.test(t))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");let i=await this.withPromptScope(n,t,()=>this.format(t));if(Os.test(i))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return i=this.replaceCurrentFileTokensInString(i,{fileName:!0,folder:!0,activeFolder:"path"}),i}async formatFileContent(t){let n=t,i=this.contentValuePromptsAcceptImagePaste;this.contentValuePromptsAcceptImagePaste=!P_(this.promptScope);try{n=await this.format(n)}finally{this.contentValuePromptsAcceptImagePaste=i}return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),n}async formatFolderPath(t){if(Os.test(t))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");let n=await this.withPromptScope("folder",t,()=>this.format(t));if(Os.test(n))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return this.replaceCurrentFileTokensInString(n,{folder:!0,activeFolder:"path"}).replace(/^\/+/,"")}async formatTemplateFilePath(t){if(Os.test(t))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");let n=t;if(n=await this.replaceGlobalVarInString(n),Os.tes
Suggested values for ${i}: ${v.slice(0,3).join(", ")}`)}return n?await n.inputPrompt(`Enter value for ${i}`,m):await Sr.PromptWithContext(this.app,`Enter value for ${i}`,m,void 0,this.getLinkSourcePath()??void 0)}return n?String(await n.suggester(u,u,p,!0)):await ln.Suggest(this.app,u,u,{placeholder:p})}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}generateCacheKey(t){return L1(t)}async suggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);let n=this.choiceExecutor?.promptProvider;try{let i=zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,c=>this.app.metadataCache.getFileCache(c)),o=t.label??`Select a file from ${t.folderPath}`;if(i.length===0){let c=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?await n.inputPrompt(o,c):await Sr.Prompt(this.app,o,c,void 0,void 0,t.optional?{optional:!0}:void 0);return t.multiSelect?u?[`${as}${u}`]:[]:u?`${as}${u}`:""}let s=Ec(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${vl}${c.path}`);if(t.multiSelect)return(n?await n.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):await Xp.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${as}${u}`);if(n){let c=String(await n.suggester(s,a,o,t.allowCustomInput));return c?a.includes(c)?c:`${as}${c}`:""}if(t.allowCustomInput){let c=new Set(i.map(f=>f.basename.toLowerCase())),u=new Set(s.map(f=>f.toLowerCase())),d=await ln.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});return d?a.includes(d)?d:`${as}${d}`:""}return await Nr.Suggest(this.app,s,a,o,void 0,t.optional?{skippable:!0}:void 0)??""}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}async getMacroValue(t,n){let{SingleMacroEngine:i}=await Promise.resolve().then(()=>(d9(),u9)),o=new i(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=await o.runAndGetOutput(t,n)??"";return o.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}async getTemplateContent(t){let{SingleTemplateEngine:n}=await Promise.resolve().then(()=>(Q1(),f9));this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0});let i={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=new n(this.app,this.plugin,t,this.choiceExecutor,i);o.setTargetFolderPath(this.targetFolderPath),this.promptScope!=="generic"&&o.setPromptScope(this.promptScope),this.promptRunContext&&o.setPromptRunContext({...this.promptRunContext,draftScopeId:`${this.promptRunContext.draftScopeId??""}#${t}`});let s=await o.run();return this.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}async getSelectedText(){let t=Nn(this.app);return t?t.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){return this.plugin.settings.enableTemplatePropertyTypes}async replaceInlineJavascriptInString(t){let n=t;for(;uc.test(n);){let i=uc.exec(n);if(!i)break;let o=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=await Promise.resolve().then(()=>(h9(),m9)),a=new s(this.app,this.plugin,this.choiceExecutor,this.variables),l=await a.runAndGetOutput(o);for(let u in a.params.variables)this.variables.set(u,a.params.variables[u]);let c="";typeof l=="string"?c=l:(typeof l=="number"||typeof l=="boolean"||Array.isArray(l))&&(c=this.renderCollectedOrArrayValue({input:n,matchStart:i.index,matchEnd:i.index+i[0].length,rawValue:l,fallbackKey:"inlineScript",heuristicEnabled:this.isTemplatePropertyTypesEnabled()})??String(l)),n=this.replacer(n,uc,c)}else n=this.replacer(n,uc,"")}return n}async collectValuesManually(t,n){return await B1(this.app,t,n)}}});function af(r){return new TextEncoder().encode(r).length}function bve(r){let e=0;for(let t of r){if(t.role==="tool"){for(let n of t.results)e+=af(n.content);continue}if(e+=af(t.content),t.role==="assistant"&&t.toolCalls){for(let n of t.toolCalls)if(typeof n
> `);this.choiceExecutor.variables.set(n,t),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(e){uE(e)}}});function tN(r){let e=(0,A9.getFrontMatterInfo)(r);return e.exists?e.contentStart:0}function $ve(r,e){let t=tN(r);if(t===0)return 0;if(_9.test(e))return t;let n=_9.exec(r.slice(t));return n?t+n[0].length:t}function rN(r,e){if(e.length===0)return{content:r,insertedStartOffset:null,insertedEndOffset:null};let t=$ve(r,e),n=r.slice(0,t),i=r.slice(t),o=n.length>0&&!n.endsWith(`
`)&&!Rve.test(e)?`
`:"",s=i.length>0&&!e.endsWith(`
`)?`
`:"",a=n.length+o.length,l=a+e.length;return{content:`${n}${o}${e}${s}${i}`,insertedStartOffset:a,insertedEndOffset:l}}function bD(r,e){return rN(r,e).content}var A9,_9,Rve,pE=b(()=>{A9=require("obsidian"),_9=/^[^\S\r\n]*\r?\n/,Rve=/^\r?\n/});function nN(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function iN(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function cf(r,e){let t=(e??[]).map(n=>nN(n)).filter(n=>n.length>0);return t.length===0?!0:r?iN(r.normalize("NFC"),t):!1}var wD=b(()=>{});function uf(r,e={}){let t=(r??"").trim();if(!t)throw new aa("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new aa(`Refusing to write to an absolute path outside the vault: "${n}".`);let i=n.replace(/\/+/g,"/").replace(/^\/+|\/+$/g,""),o=i.split("/").filter(a=>a.length>0);if(o.length===0)throw new aa("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new aa(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new aa(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);Ove(a,i)}let s=(e.allowedRoots??[]).map(a=>nN(a)).filter(a=>a.length>0);if(s.length>0&&!iN(i,s))throw new aa(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function Ove(r,e){if(O_.test(r))throw new aa(`Path segment "${r}" contains control characters: "${e}".`);if(N_.test(r))throw new aa(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${e}".`);if(L_.test(r))throw new aa(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&Pm(t))throw new aa(`Path segment "${r}" is a reserved device name: "${e}".`)}var aa,k9=b(()=>{B_();wD();aa=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function qg(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(S9(e.only,n,"only"),S9(e.exclude,n,"exclude"),e.only){let o=new Set(e.only);t=t.filter(([s])=>o.has(s))}if(e.exclude){let o=new Set(e.exclude);t=t.filter(([s])=>!o.has(s))}let i=e.prefix??"";return Object.fromEntries(t.map(([o,s])=>[i+o,s]))}function fE(r){return{...r,__qaTool:!0}}function S9(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&F.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...e].join(", ")}.`)}var CD=b(()=>{Me()});function $9(r,e={}){let t=e.allowedRoots,n={read_note:df({description:"Read a note's full markdown content by vault path.",inputSchema:pf({path:la("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=uf(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof sN.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>D9?a.slice(0,D9)+`
\u2026[truncated]`:a}}}),list_notes:df({description:"List markdown notes, optionally within a folder.",inputSchema:pf({folder:la("Folder to list (omit for the whole vault)."),limit:I9("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?uf(String(i),{allowedRoots:t}):"",a=M9(F9(o,Nve),1,Lve),l=rs(r,s).filter(c=>cf(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:df({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:pf({query:la("Text to search for."),in:P9(["name","content","both"],"Where to search (default both)."),limit:I9("Max results (default 25, capped at 50).")},["query"]),readOnly:!0,execute:async({query:i,in:o,limit:s})=>{let a=String(i).toLowerCase(),l=o??"both",c=M9(F9(s,Bve),1,Uve),u=r.vault.getMarkdownFiles().filter(m=>cf(m.path,t)),d=[],f=0,p=!1;for(let m of u){if(d.length>=c)break;if(l!=="content"&&m.basename.toLowerCase().includes(a)){d.push({path:m.path});continue}if(l!=="name"){if(f>=Vve){p=!0;continue}f++;let g=await r.vault.cachedRead(m),y=g.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:Wve(g,y)})}}return{results:d,scannedFiles:f,truncated:d.length>=c||p}}}),get_property_values:df({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:pf({field:la("Frontmatter property name."),folder:la("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?uf(String(o),{allowedRoots:t}):"",a=(o?rs(r,s):r.vault.getMarkdownFiles()).filter(c=>cf(c.path,t)),l=new Set;for(let c of a){let d=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(d!=null){for(let f of Array.isArray(d)?d:[d])if(typeof f!="object"){let p=String(f).trim();p&&l.add(p)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:df({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:pf({path:la("Vault path for the new note."),content:la("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=uf(oN(String(i)),{allowedRoots:t});return await dg(r,s),await qve(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:df({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:pf({path:la("Vault path to the existing note."),content:la("Markdown to append."),position:P9(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=uf(oN(String(i)),{allowedRoots:t}),l=R9(r,a);await dg(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?bD(c,u.endsWith(`
`)?u:u+`
`):`${c}${c.endsWith(`
`)||c.length===0?"":`
`}${u}`;return await r.vault.modify(l,d),{appended:!0,path:a}}}),insert_under_heading:df({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:pf({path:la("Vault path to the existing note."),heading:la("Exact heading text (without the # markers)."),content:la("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=uf(oN(String(i)),{allowedRoots:t}),l=R9(r,a);await dg(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(p=>p.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),f=zve(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,f),{inserted:!0,path:a,heading:String(o)}}})};return qg(n,e)}function df(r){return{...r,__qaTool:!0}}function pf(r,e){return{type:"object",properties:r,required:e}}function la(r){return{type:"string",description:r}}function I9(r){return{type:"integer",description:r}}function P9(r,e){return{type:"string",enum:r,description:e}}function F9(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function M9(r,e,t){return Math.max(e,Math.min(t,r))}function oN(r){if(/\.md$/i.test(r))return r;if(/\.[a-z0-9]+$/i.test(r))throw new Error(`This tool only operates on markdown notes (.md); refused path: "${r}".`);return`${r}.md`}function R9(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof sN.TFile))throw new Error(`Note not found: ${e}`);return t}async function qve(r,e){let t=e.lastIndexOf("/");if(t<=0)return;let n=e.slice(0,t);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function Wve(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function zve(r,e,t,n,i){let o=r.split(`
`),s=o.length;for(let u of i)if(u.position.start.line>e&&u.level<=t){s=u.position.start.line;break}let a=n.endsWith(`
`)?n:n+`
`,l=o.slice(0,s),c=o.slice(s);for(;l.length>e+1&&l[l.length-1].trim()==="";)l.pop();return[...l,a.replace(/\n$/,""),...c].join(`
`)}var sN,D9,Nve,Lve,Bve,Uve,Vve,O9=b(()=>{sN=require("obsidian");qt();pE();wD();k9();cO();CD();D9=16e3,Nve=100,Lve=200,Bve=25,Uve=50,Vve=400});function L9(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof xD.TFile)||s.extension!=="md"?null:cf(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(xD.MarkdownView);return s&&cf(s.file?.path,t)?s:null},o={get_active_note:fE({description:"Get the currently active note (path, basename, and content). Returns active:null if there is none.",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>{let s=n();if(!s)return{active:null};let a=await r.vault.cachedRead(s);return{active:{path:s.path,basename:s.basename,content:a.length>N9?a.slice(0,N9)+`
\u2026[truncated]`:a}}}}),get_selection:fE({description:"Get the text currently selected in the active editor (empty string if none).",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>({selection:i()?.editor?.getSelection()??""})})};return qg(o,e)}var xD,N9,B9=b(()=>{xD=require("obsidian");wD();CD();N9=16e3});function U9(r={}){let e={get_date:fE({description:"Get the current date/time. Optionally pass a moment.js format and a day offset.",inputSchema:{type:"object",properties:{format:{type:"string",description:"moment.js format, e.g. YYYY-MM-DD"},offset:{type:"integer",description:"Day offset from today (e.g. 1 = tomorrow)."}}},readOnly:!0,execute:async({format:t,offset:n})=>({date:Us({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return qg(e,r)}var V9=b(()=>{qt();CD()});var mE,Wg,q9=b(()=>{mE=require("obsidian");zr();qO();Wg=class r extends mE.Modal{constructor(t,n,i=[],o){super(t);this.items=n;this.selectedItems=i;this.header=o;this._selectedItems=[...i],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open(),this.picker.focusSearchOnOpen()}static Open(t,n,i,o){return new r(t,n,i,o).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","checkboxPrompt"),this.header&&(this.titleEl.textContent=this.header),this.addSearchableOptions(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise(rn())}addSearchableOptions(){this.picker=new Qp(this.contentEl,{items:this.items.map(t=>({key:t,value:t,label:t})),isSelected:({value:t})=>this._selectedItems.includes(t),onToggle:({value:t},n)=>{if(n){this._selectedItems.includes(t)||this._selectedItems.push(t);return}this._selectedItems=this._selectedItems.filter(i=>i!==t)},getSelectedCount:()=>new Set(this._selectedItems).size})}addSubmitButton(){let t=this.contentEl.createDiv("submitButtonContainer");new mE.ButtonComponent(t).setButtonText("Submit").setCta().onClick(()=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()}),new mE.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.close()})}}});var ED,hE,W9=b(()=>{ED=require("obsidian"),hE=class r extends ED.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Show(t,n,i){return new r(t,n,i).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(i=>this.contentEl.createEl("p",{text:i}));let t=this.contentEl.createDiv(),n=new ED.ButtonComponent(t).setButtonText("OK").onClick(()=>this.close());Object.assign(t.style,{display:"flex",justifyContent:"flex-end"}),n.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}}});var TD,z9=b(()=>{Ru();U1();ml();TD=class extends hn{constructor(e,t,n){super(e,t),this.fieldInput=n;let i=Yi.parse(n);this.fieldName=i.fieldName,this.filters=i.filters}async getSuggestions(e){let t=await t9(this.app,this.fieldName,this.filters),n=(e||"").toLowerCase();return n?t.filter(i=>i.toLowerCase().includes(n)).slice(0,200):t.slice(0,200)}renderSuggestion(e,t){this.renderMatch(t,e,this.getCurrentQuery())}selectSuggestion(e){this.inputEl.value=e;let t=new Event("input",{bubbles:!0});t.fromCompletion=!0,this.inputEl.dispatchEvent(t),this.close()}}});var H9,aN,_D,j9=b(()=>{H9=require("obsidian");ml();aN=200,_D=class extends hn{constructor(t,n,i,o,s,a,l){super(t,n);this.getOptions=i;this.isSelected=o;this.onSelect=s;this.multiSelect=a;this.allowCustomInput=l;a&&n.setAttribute("aria-multiselectable","true")}getSuggestions(t){let n=t.trim(),i=this.getOptions().filter(u=>!this.isSelected(u.value));if(!n)return i.slice(0,aN);let o=(0,H9.prepareFuzzySearch)(n),s=i.map(u=>({option:u,match:o(`${u.label} ${u.path}`)})).filter(u=>u.match!==null).sort((u,d)=>d.match.score-u.match.score).slice(0,aN).map(({option:u})=>u);if(!this.allowCustomInput)return s;let a=n.toLocaleL
${e}`:bD(r,`${e}
`)}function jve(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function J9(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function eK(r,e){let t=J9(r),n=J9(e);if(t===null||n===null)return;let i=[],o=new Set(t);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...t,...i]}var SD,gE,Hg,DD=b(()=>{SD=require("obsidian");Me();qt();uD();$x();$_();_y();Ng();pE();fD();_l();M_();gE=[{id:"cursor",label:"Insert at cursor",description:"Inserts the template at the cursor position in the editor."},{id:"top",label:"Insert at top",description:"Inserts the template below the note's frontmatter, or at the very top."},{id:"bottom",label:"Append to bottom",description:"Adds the template content to the end of the note."},{id:"replace",label:"Replace note content",description:"Replaces the entire note content with the template."}];Hg=class extends hd{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.resolvedTemplatePath=l??null}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(Mi(this.templatePath,"Cannot apply template: no template path given."),this.mode){case"replace":return await this.overwriteFileWithTemplate(this.targetFile,await this.getResolvedTemplatePath());case"top":case"bottom":return await this.insertTemplateIntoFile(this.mode);case"cursor":return await this.insertTemplateAtCursor()}}async computeChoiceTargetPath(t){let n=t.folder,i;if(this.formatter.setTargetFolderPath(null),n?.enabled){if(n.chooseWhenCreatingNote)return null;if(n.createInSameFolderAsActiveFile)i=this.targetFile.parent?.path??"";else{if(n.chooseFromSubfolders)return null;if(n.folders.length===1)i=await this.formatter.formatFolderPath(n.folders[0]);else return null}}else i=this.targetFile.parent?.path??"";i==="/"&&(i="");let o=this.targetFile.basename,s=!1;if(t.fileNameFormat?.enabled&&t.fileNameFormat.format){this.formatter.setTargetFolderPath(i);let a=await this.formatter.formatFileName(t.fileNameFormat.format,"generic"),l=li(a,"File name"),c=this.stripDuplicateFolderPrefix(l,i);o=c.fileName,s=this.shouldTreatFormattedNameAsVaultRelativePath(l,c.strippedPrefix,n?.enabled??!1)}return o.slice(o.lastIndexOf("/")+1).trim()?this.normalizeTemplateFilePath(s?"":i,o,await this.getResolvedTemplatePath()):null}async insertTemplateIntoFile(t){let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=Z9(n);return s.trim().length>0&&await this.app.vault.process(this.targetFile,a=>Hve(a,s,t)),await this.mergeFrontmatterProperties(o,i),this.targetFile}async insertTemplateAtCursor(){let t=Qv(this.app,this.targetFile);Mi(t,"Cannot insert at cursor: the note is not open in the active editor.");let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=Z9(n);return s.trim().length>0&&t.editor.replaceSelection(s),await this.mergeFrontmatterProperties(o,i),this.targetFile}async formatTemplateForTargetFile(){let t=await this.getTemplateContent(await this.getResolvedTemplatePath());this.formatter.setTitle(this.targetFile.basename),this.formatter.setTargetFolderPath(Wo(this.targetFile.path));let n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",t,()=>this.formatter.formatFileContent(t))),i=this.formatter.getAndClearTemplatePropertyVars();return this.targetFile.extension==="md"&&(n=await dc(this.app,n,this.targetFile)),{formatted:n,templatePropertyVars:i}}async mergeFrontmatterProperties(t,n){if(!t||this.targetFile.extension!=="md")return;let i;try{i=(0,SD.parseYaml)(t)}catch(o){F.logWarning(`Could not parse template frontmatter for merging: ${o}`);return}if(!(!i||typeof i!="object"||Array.isArray(i))){if(n&&n.size>0)for(let[o,s]of n){let a=o.includes(Ma.PATH_SEPARATOR)?o.split(Ma.PATH_SEPARATOR):[o];G1(i,a,R_(s))
`,shouldMerge:a?.shouldMerge??!0,maxChunkTokens:a?.maxChunkTokens},(g,y)=>{let w={...l,...y};return d(g,w,!1)});return v?((a?.shouldAssignVariables||a?.assignToVariable)&&Object.entries(v).forEach(([g,y])=>{n.variables.set(g,y)}),v):(lt(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>XG(),getMaxTokens:i=>Bh(i).model.maxTokens,estimateTokens(i){return Uo(i)},countTokens(i,o){return iK||(iK=!0,F.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Uo(i)},getRequestLogs(i=10){return Q4(i)},getRequestLogById(i){return Z4(i)},getLastRequestLog(){return J4()},clearRequestLogs(){e5()},agent:i=>new yD(e,t,n,i),tool:i=>({...i,__qaTool:!0}),stepCountIs:i=>({stepNumber:o})=>o>=i,hasToolCall:i=>({toolCallNames:o})=>o.includes(i),tools:{vault:i=>$9(e,i),workspace:i=>L9(e,i),system:i=>U9(i)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async i=>await navigator.clipboard.writeText(i),getSelection:()=>{let i=Nn(e);return i?i.editor.getSelection()??"":""},getSelectedText:()=>{let i=Nn(e);return i?i.editor.somethingSelected()?i.editor.getSelection():(lt(new Error("No text selected"),"Could not get selected text"),""):(lt(new Error("No active Markdown editor"),"Could not get selected text"),"")}},date:{now:(i,o)=>Us({format:i,offset:o}),tomorrow:i=>Us({format:i,offset:1}),yesterday:i=>Us({format:i,offset:-1})},fieldSuggestions:{getFieldValues:async(i,o)=>{let s=o?.includeInlineCodeBlocks?.map(u=>u.trim().toLowerCase()).filter(u=>u.length>0),a={folder:o?.folder,folders:o?.folders,tags:o?.tags,inline:o?.includeInline??!1,inlineCodeBlocks:s},l=e.vault.getMarkdownFiles();l=kD.filterFiles(l,a,u=>e.metadataCache.getFileCache(u));let c=new Set;for(let u of l){let f=e.metadataCache.getFileCache(u)?.frontmatter?.[i];if(f!=null){if(Array.isArray(f))f.forEach(p=>{if(p==null||typeof p=="object")return;let m=String(p).trim();m&&c.add(m)});else if(typeof f!="object"){let p=String(f).trim();p&&c.add(p)}}if(a.inline)try{let p=await e.vault.read(u);Fg.getFieldValues(p,i,{includeCodeBlocks:s}).forEach(v=>c.add(v))}catch{}}return Array.from(c).sort()},clearCache:i=>{Hc.getInstance().clear(i)}}}}static async inputPrompt(e,t,n,i,o){try{return await Sr.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async datePrompt(e,t,n){try{let i=await Jp.Prompt(e,t,n?.placeholder,n?.defaultValue,n?.dateFormat);if(i&&i.startsWith("@date:")){let o=i.slice(6);return(n?.dateFormat?Nl(o,n.dateFormat):null)??o}return i}catch(i){Yc(i)}}static async wideInputPrompt(e,t,n,i,o){try{return await ld.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async yesNoPrompt(e,t,n){let i;try{i=await Qi.Ask(e,t,n)}catch(o){Yc(o)}if(i===null)throw new St(yu);return i}static async infoDialog(e,t,n){try{return await hE.Show(e,t,n)}catch(i){Yc(i)}}static async suggester(e,t,n,i,o=!1,s){try{let a;return typeof t=="function"?a=n.map((l,c,u)=>mn(t(l,c,u))):a=t.map(l=>mn(l)),o?await ln.Suggest(e,a,n,{...i?{placeholder:i}:{},...s?.renderItem?{renderItem:s.renderItem}:{}}):await Nr.Suggest(e,a,n,i,s?.renderItem)}catch(a){Yc(a)}}static async checkboxPrompt(e,t,n,i){try{return await(i===void 0?Wg.Open(e,t,n):Wg.Open(e,t,n,i))}catch(o){Yc(o)}}}});var Kg,dN=b(()=>{W1();Kg=class extends Mg{}});function aK(r){return new Promise(e=>window.setTimeout(e,r))}function ff(r){return r.split(`
`)}var ID=b(()=>{});async function cK(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):tye(r,e.variables)}function tye(r,e){let t=r.variableName?.trim();if(!t)return F.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(t in e))return F.logWarning(`Conditional command skipped: Variable '${t}' is not defined.`),!1;let n=e[t];switch(r.operator){case"isTruthy":return!!n;case"isFalsy":return!n}if(Ou(r.operator)){let i=tq(r);return i===void 0?(F.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?lK(n,i,r):r.operator==="notContains"?!lK(n,i,r):rye(n,i,r)}return!1}function lK(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return F.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1;if(Array.isArray(r))return r.map(o=>tF(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes($u(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=$u(r),i=$u(e);return typeof n=="string"&&n.includes(i)}function rye(r,e,t){let n=tF(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return PD(n,e,(i,o)=>i<o);case"lessThanOrEqual":return PD(n,e,(i,o)=>i<=o);case"greaterThan":return PD(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return PD(n,e,(i,o)=>i>=o);default:return!1}}function PD(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(F.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):t(n,i)}var uK=b(()=>{Me();Rm()});function dK(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function gd(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function pK(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return gd("reuse",e);case"tab":return gd("tab",e);case"split":return gd("split",e,dK(r.direction,"vertical"));case"window":return gd("window",e);case"left-sidebar":return gd("left-sidebar",e);case"right-sidebar":return gd("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=dK(r.direction);return t?gd("split",e,n??"vertical"):gd("reuse",e)}var fK=b(()=>{Ak()});function mK(r){let e={hasOwnProperty:t=>r.has(t)};return new Proxy(e,{get(t,n){if(n==="hasOwnProperty")return e.hasOwnProperty;if(typeof n=="string")return r.get(n)},set(t,n,i){return typeof n!="string"||r.set(n,i),!0},deleteProperty(t,n){return typeof n!="string"||r.delete(n),!0},has(t,n){return typeof n=="string"&&r.has(n)},ownKeys(){return Array.from(r.keys())},getOwnPropertyDescriptor(t,n){if(n==="hasOwnProperty")return{value:e.hasOwnProperty,writable:!0,configurable:!0,enumerable:!1};if(!(typeof n!="string"||!r.has(n)))return{value:r.get(n),writable:!0,configurable:!0,enumerable:!0}}})}var hK=b(()=>{});function bK(r){return r!==null&&typeof r=="object"}function iye(r){return typeof r=="function"}function wK(r){return bK(r)}function oye(r){if(!wK(r))return;let{settings:e}=r;return bK(e)?e:void 0}function gK(r,e="command"){if(typeof r!="string"||!r.trim())return`the saved entry has no ${e} type, so QuickAdd cannot tell what it was meant to do. It is in .obsidian/plugins/quickadd/data.json.`;let t=e==="command"?sye.get(r):void 0;return t||`QuickAdd does not recognise the ${e} type '${r}'. It can come from a newer version of QuickAdd, an imported package, or a hand-edited .obsidian/plugins/quickadd/data.json.`}function vK(r){return`${r.scriptPath}::${r.exportName??"default"}`}var nye,yK,sye,Vl,oE=b(()=>{nye=HN(require("obsidian"));Me();Cr();Kr();uN();dN();qc();Lg();Bg();gl();qt();vs();I$();D$();P$();F$();M$();R$();$$();O$();N$();L$();ID();RS();Kp();It();Vg();Uh();es();qt();yK=require("obsidian");Ns();zr();Co();wk();zT();Bc();uK();iE();fK();hK();Ii();sye=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "Infinite AI Assistant" command type - no released version could ever run one. Delete the step from the macro. For chunked AI prompts, use quickAddApi.ai.chunkedPrompt() in a use
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${r}"
https://svelte.dev/e/invariant_violation`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function BE(r){if(te){let e=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function JN(){if(te){let r=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function dI(){if(te){let r=new Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function eL(){if(te){let r=new Error(`derived_references_self
A derived value cannot reference itself recursively
https://svelte.dev/e/derived_references_self`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/derived_references_self")}function pI(r,e,t){if(te){let n=new Error(`each_key_duplicate
${t?`Keyed each block has duplicate key \`${t}\` at indexes ${r} and ${e}`:`Keyed each block has duplicate key at indexes ${r} and ${e}`}
https://svelte.dev/e/each_key_duplicate`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function tL(r,e,t){if(te){let n=new Error(`each_key_volatile
Keyed each block has key that is not idempotent \u2014 the key for item at index ${r} was \`${e}\` but is now \`${t}\`. Keys must be the same each time for a given item
https://svelte.dev/e/each_key_volatile`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_volatile")}function rL(r){if(te){let e=new Error(`effect_in_teardown
\`${r}\` cannot be used inside an effect cleanup function
https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function nL(){if(te){let r=new Error("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function iL(r){if(te){let e=new Error(`effect_orphan
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function oL(){if(te){let r=new Error(`effect_update_depth_exceeded
Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
https://svelte.dev/e/effect_update_depth_exceeded`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function sL(){if(te){let r=new Error(`hydration_failed
Failed to hydrate the application
https://svelte.dev/e/hydration_failed`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/hydration_failed")}function aL(){if(te){let r=new Error("invalid_snippet\nCould not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`\nhttps://svelte.dev/e/invalid_snippet");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/invalid_snippet")}function lL(r){if(te){let e=new Error(`props_invalid_value
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function cL(r){if(te){let e=new Error(`rune_outside_svelte
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function uL(){if(te){let r=new Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function dL(){if(te){let r=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function pL(){if(te){let r=new Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function fL(){if(te){let r=new Error("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}var Ja="font-weight: bold",el="font-weight: normal";function mL(r){te?console.warn(`%c[svelte] await_reactivity_loss
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
https://svelte.dev/e/await_reactivity_loss`,Ja,el):console.warn("https://svelte.dev/e/await_reactivity_loss")}function hL(r,e){te?console.warn(`%c[svelte] await_waterfall
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
https://svelte.dev/e/await_waterfall`,Ja,el):console.warn("https://svelte.dev/e/await_waterfall")}function gL(){te?console.warn(`%c[svelte] derived_inert
%cReading a derived belonging to a now-destroyed effect may result in stale values
https://svelte.dev/e/derived_inert`,Ja,el):console.warn("https://svelte.dev/e/derived_inert")}function vL(r,e,t){te?console.warn(`%c[svelte] hydration_attribute_changed
%cThe \`${r}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${t}\`, will be ignored in favour of the server value
https://svelte.dev/e/hydration_attribute_changed`,Ja,el):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Cd(r){te?console.warn(`%c[svelte] hydration_mismatch
%c${r?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${r}`:"Hydration failed because the initial UI does not match what was rendered on the server"}
https://svelte.dev/e/hydration_mismatch`,Ja,el):console.warn("https://svelte.dev/e/hydration_mismatch")}function yL(){te?console.warn(`%c[svelte] lifecycle_double_unmount
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,Ja,el):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function bL(){te?console.warn("%c[svelte] select_multiple_invalid_value\n%cThe `value` property of a `<select multiple>` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value",Ja,el):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function UE(r){te?console.warn(`%c[svelte] state_proxy_equality_mismatch
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${r}\` will produce unexpected results
https://svelte.dev/e/state_proxy_equality_mismatch`,Ja,el):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function wL(){te?console.warn(`%c[svelte] state_proxy_unmount
%cTried to unmount a state proxy, rather than a component
https://svelte.dev/e/state_proxy_unmount`,Ja,el):console.warn("https://svelte.dev/e/state_proxy_unmount")}function CL(){te?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Ja,el):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var Re=!1;function In(r){Re=r}var Ze;function tr(r){if(r===null)throw Cd(),jl;return Ze=r}function Kn(){return tr(gi(Ze))}function S(r){if(Re){if(gi(Ze)!==null)throw Cd(),jl;Ze=r}}function Pn(r=1){if(Re){for(var e=r,t=Ze;e--;)t=gi(t);Ze=t}}function tl(r=!0){for(var e=0,t=Ze;;){if(t.nodeType===jo){var n=t.data;if(n==="]"){if(e===0)return t;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}var i=gi(t);r&&t.remove(),t=i}}function uv(r){if(!r||r.nodeType!==jo)throw Cd(),jl;return r.data}function VE(r){return r===this.v}function qE(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function WE(r){return!qE(r,this.v)}var en=!1,Yl=!1,fa=!1;var K7="font-weight: bold",Q7="font-weight: normal";function fI(r){te?console.warn(`%c[svelte] state_snapshot_uncloneable
%c${r?`The following properties cannot be cloned with \`$state.snapshot\` \u2014 the return value contains the originals:
${r}`:"Value cannot be cloned with `$state.snapshot` \u2014 the original value was returned"}
https://svelte.dev/e/state_snapshot_uncloneable`,K7,Q7):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var X7=[];function ma(r,e=!1,t=!1){if(te&&!e){let n=[],i=dv(r,new Map,"",n,null,t);if(n.length===1&&n[0]==="")fI();else if(n.length>0){let o=n.length>10?n.slice(0,7):n.slice(0,10),s=n.length-o.length,a=o.map(l=>`- <value>${l}`).join(`
`);s>0&&(a+=`
- ...and ${s} more`),fI(a)}return i}return dv(r,new Map,"",X7,null,t)}function dv(r,e,t,n,i=null,o=!1){if(typeof r=="object"&&r!==null){var s=e.get(r);if(s!==void 0)return s;if(r instanceof Map)return new Map(r);if(r instanceof Set)return new Set(r);if(pa(r)){var a=Array(r.length);e.set(r,a),i!==null&&e.set(i,a);for(var l=0;l<r.length;l+=1){var c=r[l];l in r&&(a[l]=dv(c,e,te?`${t}[${l}]`:t,n,null,o))}return a}if(iu(r)===ME){a={},e.set(r,a),i!==null&&e.set(i,a);for(var u of Object.keys(r))a[u]=dv(r[u],e,te?`${t}.${u}`:t,n,null,o);return a}if(r instanceof Date)return structuredClone(r);if(typeof r.toJSON=="function"&&!o)return dv(r.toJSON(),e,te?`${t}.toJSON()`:t,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return te&&n.push(t),r}}var pv=null;function Ni(r,e){return r.label=e,zE(r.v,e),r}function zE(r,e){return r?.[OE]?.(e),r}function ha(r){let e=new Error,t=Z7();return t.length===0?null:(t.unshift(`
`),Oi(e,"stack",{value:t.join(`
`)}),Oi(e,"name",{value:r}),e)}function Z7(){let r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let e=new Error().stack;if(Error.stackTraceLimit=r,!e)return[];let t=e.split(`
`),n=[];for(let i=0;i<t.length;i++){let o=t[i],s=o.replaceAll("\\","/");if(o.trim()!=="Error"){if(o.includes("validate_each_keys"))return[];s.includes("svelte/src/internal")||s.includes("node_modules/.vite")||n.push(o)}}return n}function EL(r,e){if(!te)throw new Error("invariant(...) was not guarded by if (DEV)");r||XN(e)}var _t=null;function Kl(r){_t=r}var rl=null;function _f(r){rl=r}var ga=null;function HE(r){ga=r}function we(r,e=!1,t){_t={p:_t,i:!1,c:null,e:null,s:r,x:null,r:Fe,l:Yl&&!e?{s:null,u:null,$:[]}:null},te&&(_t.function=t,ga=t)}function Ce(r){var e=_t,t=e.e;if(t!==null){e.e=null;for(var n of t)mI(n)}return r!==void 0&&(e.x=r),e.i=!0,_t=e.p,te&&(ga=_t?.function??null),r??{}}function va(){return!Yl||_t!==null&&_t.l===null}var xd=[];function TL(){var r=xd;xd=[],RE(r)}function Ur(r){if(xd.length===0&&!Ed){var e=xd;queueMicrotask(()=>{e===xd&&TL()})}xd.push(r)}function _L(){for(;xd.length>0;)TL()}var hI=new WeakMap;function jE(r){var e=Fe;if(e===null)return je.f|=8388608,r;if(te&&r instanceof Error&&!hI.has(r)&&hI.set(r,J7(r,e)),(e.f&32768)===0&&(e.f&4)===0)throw te&&!e.parent&&r instanceof Error&&AL(r),r;ba(r,e)}function ba(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throw r;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throw te&&r instanceof Error&&AL(r),r}}function J7(r,e){let t=Ao(r,"message");if(!(t&&!t.configurable)){for(var n=mv?" ":" ",i=`
${n}in ${e.fn?.name||"<unknown>"}`,o=e.ctx;o!==null;)i+=`
${n}in ${o.function?.[_s].split("/").pop()}`,o=o.p;return{message:r.message+`
${i}
`,stack:r.stack?.split(`
`).filter(s=>!s.includes("svelte/src/internal")).join(`
`)}}}function AL(r){let e=hI.get(r);e&&(Oi(r,"message",{value:e.message}),Oi(r,"stack",{value:e.stack}))}var eQ=-7169;function rr(r,e){r.f=r.f&eQ|e}function Af(r){(r.f&512)!==0||r.deps===null?rr(r,1024):rr(r,4096)}function kL(r){if(r!==null)for(let e of r)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,kL(e.deps))}function GE(r,e,t){(r.f&2048)!==0?e.add(r):(r.f&4096)!==0&&t.add(r),kL(r.deps),rr(r,1024)}var SL=!1,YE=!1;function gI(r){var e=YE;try{return YE=!1,[r(),YE]}finally{YE=e}}function Ad(r){Re&&vi(r)!==null&&Sf(r)}var DL=!1;function KE(){DL||(DL=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let e of r.target.elements)e[ou]?.()})},{capture:!0}))}function Ss(r){var e=je,t=Fe;Rn(null),$n(null);try{return r()}finally{Rn(e),$n(t)}}function QE(r,e,t,n=t){r.addEventListener(e,()=>Ss(t));let i=r[ou];i?r[ou]=()=>{i(),n(!0)}:r[ou]=()=>n(!0),KE()}function IL(r){let e=0,t=Ui(0),n;return te&&Ni(t,"createSubscriber version"),()=>{su()&&(h(t),Zn(()=>(e===0&&(n=Ot(()=>r(()=>kd(t)))),e+=1,()=>{Ur(()=>{e-=1,e===0&&(n?.(),n=void 0,kd(t))})})))}}var rQ=589824;function yv(r,e,t,n){new vI(r,e,t,n)}var Go,hv,Ds,Sd,Do,Is,oo,Yo,Xl,Dd,au,Df,gv,vv,nl,JE,sr,FL,ML,yI,RL,bI,XE,ZE,wI,CI,vI=class{constructor(e,t,n,i){it(this,sr);ae(this,"parent");ae(this,"is_pending",!1);ae(this,"transform_error");it(this,Go);it(this,hv,Re?Ze:null);it(this,Ds);it(this,Sd);it(this,Do);it(this,Is,null);it(this,oo,null);it(this,Yo,null);it(this,Xl,null);it(this,Dd,0);it(this,au,0);it(this,Df,!1);it(this,gv,new Set);it(this,vv,new Set);it(this,nl,null);it(this,JE,IL(()=>(et(this,nl,Ui(z(this,Dd))),te&&Ni(z(this,nl),"$effect.pending()"),()=>{et(this,nl,null)})));et(this,Go,e),et(this,Ds,t),et(this,Sd,o=>{var s=Fe;s.b=this,s.f|=128,n(o)}),this.parent=Fe.b,this.transform_error=i??this.parent?.transform_error??(o=>o),et(this,Do,so(()=>{if(Re){let o=z(this,hv);Kn();let s=o.data==="[!";if(o.data.startsWith("[?")){let l=JSON.parse(o.data.slice("[?".length));xt(this,sr,ML).call(this,l)}else s?xt(this,sr,RL).call(this):xt(this,sr,FL).call(this)}else xt(this,sr,bI).call(this)},rQ)),Re&&et(this,Go,Ze)}defer_effect(e){GE(e,z(this,gv),z(this,vv))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!z(this,Ds).pending}update_pending_count(e,t){xt(this,sr,wI).call(this,e,t),et(this,Dd,z(this,Dd)+e),!(!z(this,nl)||z(this,Df))&&(et(this,Df,!0),Ur(()=>{et(this,Df,!1),z(this,nl)&&wa(z(this,nl),z(this,Dd))}))}get_effect_pending(){return z(this,JE).call(this),h(z(this,nl))}error(e){if(!z(this,Ds).onerror&&!z(this,Ds).failed)throw e;qe?.is_fork?(z(this,Is)&&qe.skip_effect(z(this,Is)),z(this,oo)&&qe.skip_effect(z(this,oo)),z(this,Yo)&&qe.skip_effect(z(this,Yo)),qe.oncommit(()=>{xt(this,sr,CI).call(this,e)})):xt(this,sr,CI).call(this,e)}};Go=new WeakMap,hv=new WeakMap,Ds=new WeakMap,Sd=new WeakMap,Do=new WeakMap,Is=new WeakMap,oo=new WeakMap,Yo=new WeakMap,Xl=new WeakMap,Dd=new WeakMap,au=new WeakMap,Df=new WeakMap,gv=new WeakMap,vv=new WeakMap,nl=new WeakMap,JE=new WeakMap,sr=new WeakSet,FL=function(){try{et(this,Is,On(()=>z(this,Sd).call(this,z(this,Go))))}catch(e){this.error(e)}},ML=function(e){let t=z(this,Ds).failed,{reset:n,invoke_onerror:i}=xt(this,sr,yI).call(this,e);Ur(i),t&&et(this,Yo,On(()=>{t(z(this,Go),()=>e,()=>n)}))},yI=function(e){var t=!1,n=!1;let i=()=>{if(t){CL();return}t=!0,n&&fL(),z(this,Yo)!==null&&il(z(this,Yo),()=>{et(this,Yo,null)}),xt(this,sr,ZE).call(this,()=>{xt(this,sr,bI).call(this)})};return{reset:i,invoke_onerror:()=>{try{n=!0,z(this,Ds).onerror?.(e,i),n=!1}catch(s){ba(s,z(this,Do)&&z(this,Do).parent)}}}},RL=function(){let e=z(this,Ds).pending;e&&(this.is_pending=!0,et(this,oo,On(()=>e(z(this,Go)))),Ur(()=>{var t=et(this,Xl,document.createDocumentFragment()),n=tn();t.append(n),et(this,Is,xt(this,sr,ZE).call(this,()=>On(()=>z(this,Sd).call(this,n)))),z(this,au)===0&&(z(this,Go).before(t),et(this,Xl,null),il(z(this,oo),()=>{et(this,oo,null)}),xt(this,sr,XE).call(this,qe))}))},bI=function(){try{if(this.is_pending=this.has_pending_snippet(),et(this,au,0),et(this,D
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==jl&&console.warn("Failed to hydrate: ",s),e.recover===!1&&sL(),aT(),Sf(t),In(!1),Bd(r,e)}finally{In(n),tr(i)}}var mT=new Map;function v2(r,{target:e,anchor:t,props:n={},events:i,context:o,intro:s=!0,transformError:a}){aT();var l=void 0,c=n2(()=>{var u=t??e.appendChild(tn());yv(u,{pending:()=>{}},p=>{we({});var m=_t;if(o&&(m.c=o),i&&(n.$$events=i),Re&&Zo(p,null),jI=s,l=r(p,n)||{},jI=!0,Re&&(Fe.nodes.end=Ze,Ze===null||Ze.nodeType!==jo||Ze.data!=="]"))throw Cd(),jl;Ce()},a);var d=new Set,f=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!d.has(v)){d.add(v);var g=g2(v);for(let x of[e,document]){var y=mT.get(x);y===void 0&&(y=new Map,mT.set(x,y));var w=y.get(v);w===void 0?(x.addEventListener(v,fT,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return f(xf(WI)),pT.add(f),()=>{for(var p of d)for(let g of[e,document]){var m=mT.get(g),v=m.get(p);--v==0?(g.removeEventListener(p,fT),m.delete(p),m.size===0&&mT.delete(g)):m.set(p,v)}pT.delete(f),u!==t&&u.parentNode?.removeChild(u)}});return GI.set(l,c),l}var GI=new WeakMap;function jf(r,e){let t=GI.get(r);return t?(GI.delete(r),t(e)):(te&&(Dn in r?wL():yL()),Promise.resolve())}var Ea,dl,Jo,Ud,Iv,Pv,hT,Ta=class{constructor(e,t=!0){ae(this,"anchor");it(this,Ea,new Map);it(this,dl,new Map);it(this,Jo,new Map);it(this,Ud,new Set);it(this,Iv,!0);it(this,Pv,e=>{if(z(this,Ea).has(e)){var t=z(this,Ea).get(e),n=z(this,dl).get(t);if(n)zf(n),z(this,Ud).delete(t);else{var i=z(this,Jo).get(t);i&&(zf(i.effect),z(this,dl).set(t,i.effect),z(this,Jo).delete(t),te&&(i.fragment.lastChild[uI]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of z(this,Ea)){if(z(this,Ea).delete(o),o===e)break;let a=z(this,Jo).get(s);a&&(qr(a.effect),z(this,Jo).delete(s))}for(let[o,s]of z(this,dl)){if(o===t||z(this,Ud).has(o))continue;let a=()=>{if(Array.from(z(this,Ea).values()).includes(o)){var c=document.createDocumentFragment();If(s,c),c.append(tn()),z(this,Jo).set(o,{effect:s,fragment:c})}else qr(s);z(this,Ud).delete(o),z(this,dl).delete(o)};z(this,Iv)||!n?(z(this,Ud).add(o),il(s,a,!1)):a()}}});it(this,hT,e=>{z(this,Ea).delete(e);let t=Array.from(z(this,Ea).values());for(let[n,i]of z(this,Jo))t.includes(n)||(qr(i.effect),z(this,Jo).delete(n))});this.anchor=e,et(this,Iv,t)}ensure(e,t){var n=qe,i=lT();if(t&&!z(this,dl).has(e)&&!z(this,Jo).has(e))if(i){var o=document.createDocumentFragment(),s=tn();o.append(s),z(this,Jo).set(e,{effect:On(()=>t(s)),fragment:o})}else z(this,dl).set(e,On(()=>t(this.anchor)));if(z(this,Ea).set(n,e),i){for(let[a,l]of z(this,dl))a===e?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of z(this,Jo))a===e?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(z(this,Pv)),n.ondiscard(z(this,hT))}else Re&&(this.anchor=Ze),z(this,Pv).call(this,n)}};Ea=new WeakMap,dl=new WeakMap,Jo=new WeakMap,Ud=new WeakMap,Iv=new WeakMap,Pv=new WeakMap,hT=new WeakMap;function Fv(r,e,...t){var n=new Ta(r);so(()=>{let i=e()??null;te&&i==null&&aL(),n.ensure(i,i&&(o=>i(o,...t)))},65536)}if(te){let r=function(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;cL(e)},set:n=>{t=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function gT(r){_t===null&&BE("onMount"),Yl&&_t.l!==null?_Q(_t).m.push(r):hr(()=>{let e=Ot(r);if(typeof e=="function")return e})}function _Q(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}var w2=new Map;function C2(r,e){var t=w2.get(r);t||(t=new Set,w2.set(r,t)),t.add(e)}function ne(r,e,t=!1){var n;Re&&(n=Ze,Kn());var i=new Ta(r),o=t?65536:0;function s(a,l){if(Re){var c=uv(n);if(a!==parseInt(c.substring(1))){var u=tl();tr(u),i.anchor=u,In(!1),i.ensure(a,l),In(!0);return}}i.ensure(a,l)}so(()=>{var a=!1;e((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var DQ=Symbol("NaN");function KI(r,e,t){Re&&Kn();var n=new Ta(r),i=!va();so(()=>{var o=e();o!==o&&(o=DQ),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function $v(r,e){return e}function RQ(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=
\r\f\xA0\v\uFEFF`];function I2(r,e,t){var n=r==null?"":""+r;if(e&&(n=n?n+" "+e:e),t){for(var i of Object.keys(t))if(t[i])n=n?n+" "+i:i;else if(n.length)for(var o=i.length,s=0;(s=n.indexOf(i,s))>=0;){var a=s+o;(s===0||S2.includes(n[s-1]))&&(a===n.length||S2.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function D2(r,e=!1){var t=e?" !important;":";",n="";for(var i of Object.keys(r)){var o=r[i];o!=null&&o!==""&&(n+=" "+i+": "+o+t)}return n}function ZI(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function P2(r,e){if(e){var t="",n,i;if(Array.isArray(e)?(n=e[0],i=e[1]):n=e,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(ZI)),i&&l.push(...Object.keys(i).map(ZI));var c=0,u=-1;let v=r.length;for(var d=0;d<v;d++){var f=r[d];if(a?f==="/"&&r[d-1]==="*"&&(a=!1):o?o===f&&(o=!1):f==="/"&&r[d+1]==="*"?a=!0:f==='"'||f==="'"?o=f:f==="("?s++:f===")"&&s--,!a&&o===!1&&s===0){if(f===":"&&u===-1)u=d;else if(f===";"||d===v-1){if(u!==-1){var p=ZI(r.substring(c,u).trim());if(!l.includes(p)){f!==";"&&d++;var m=r.substring(c,d).trim();t+=" "+m+";"}}c=d+1,u=-1}}}}return n&&(t+=D2(n)),i&&(t+=D2(i,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function Ct(r,e,t,n,i,o){var s=r[sv];if(Re||s!==t||s===void 0){var a=I2(t,n,o);(!Re||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r[sv]=t}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&r.classList.toggle(l,c)}return o}function JI(r,e={},t,n){for(var i in t){var o=t[i];e[i]!==o&&(t[i]==null?r.style.removeProperty(i):r.style.setProperty(i,o,n))}}function Gf(r,e,t,n){var i=r[av];if(Re||i!==e){var o=P2(e,n);(!Re||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[av]=e}else n&&(Array.isArray(n)?(JI(r,t?.[0],n[0]),JI(r,t?.[1],n[1],"important")):JI(r,t,n));return n}function fu(r,e,t=!1){if(r.multiple){if(e==null)return;if(!pa(e))return bL();for(var n of r.options)n.selected=e.includes(Ov(n));return}for(n of r.options){var i=Ov(n);if(LI(i,e)){n.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function Vd(r){var e=new MutationObserver(()=>{"__value"in r&&fu(r,r.__value)});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Xn(()=>{e.disconnect()})}function e0(r,e,t=e){var n=new WeakSet,i=!0;QE(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),Ov);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&Ov(l)}t(a),r.__value=a,qe!==null&&n.add(qe)}),un(()=>{var o=e();if(r===document.activeElement){var s=en?ol:qe;if(n.has(s))return}if(fu(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=Ov(a),t(o))}r.__value=o,i=!1}),Vd(r)}function Ov(r){return"__value"in r?r.__value:r.value}var HQ=Symbol("is custom element"),jQ=Symbol("is html"),GQ=LE?"link":"LINK";var YQ=LE?"progress":"PROGRESS";function gr(r){if(Re){var e=!1,t=()=>{if(!e){if(e=!0,r.hasAttribute("value")){var n=r.value;ke(r,"value",null),r.value=n}if(r.hasAttribute("checked")){var i=r.checked;ke(r,"checked",null),r.checked=i}}};r[ou]=t,Ur(t),KE()}}function Fs(r,e){var t=r0(r);t.value===(t.value=e??void 0)||r.value===e&&(e!==0||r.nodeName!==YQ)||(r.value=e??"")}function qd(r,e){var t=r0(r);t.checked!==(t.checked=e??void 0)&&(r.checked=e)}function ke(r,e,t,n){var i=r0(r);if(Re&&(i[e]=r.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&r.nodeName===GQ)){n||QQ(r,e,t??"");return}i[e]!==(i[e]=t)&&(e==="loading"&&(r[QN]=t),t==null?r.removeAttribute(e):typeof t!="string"&&KQ(r).includes(e)?r[e]=t:r.setAttribute(e,t))}function r0(r){var e;return r[e=NE]??(r[e]={[HQ]:r.nodeName.includes("-"),[jQ]:r.namespaceURI===IE})}var F2=new Map;function KQ(r){var e=r.getAttribute("is")||r.nodeName,t=F2.get(e);if(t)return t;F2.set(e,t=[]);for(var n,i=r,o=Element.prototype;o!==i;){n=FE(i);for(var s in n)n[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&t.push(s);i=iu(i)}return t}function QQ(r,e,t){te&&(e==="sr
was changed by the error. Include the message below if you report this.</p> <!></div>`),TX={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaMountFailedHead.svelte-bhgeqn {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaMountFailedTitle.svelte-bhgeqn {font-weight:var(--font-semibold);color:var(--text-normal);}.qaMountFailedBody.svelte-bhgeqn {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function C0(r,e){ot(r,TX);let t=he(e,"detail",3,"");var n=EX(),i=I(n),o=I(i);Rt(o,{iconId:"alert-triangle",size:16});var s=A(o,2),a=I(s);S(s),S(i);var l=A(i,4);{var c=u=>{var d=xX(),f=I(d,!0);S(d),de(()=>me(f,t())),$(u,d)};ne(l,u=>{t()&&u(c)})}S(n),de(()=>me(a,`QuickAdd couldn't display ${e.what??""}`)),$(r,n)}var _X="this part of QuickAdd";function qi(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Bd(e,{target:r,props:t})}catch(a){return AX(r,i,Yd(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,jf(o))}}}function AX(r,e,t,n){let i=n.what??_X;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();lt(t,`Couldn't display ${i}`);let o=r.ownerDocument.createElement("div");o.className="qa-mount-failed-host",r.appendChild(o);let s=null;try{s=Bd(n.fallbackComponent??C0,{target:o,props:{what:i,detail:t.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&jf(s),o.remove())}}}var bB=require("obsidian");Tt();function em(r){return r.trim().replace(/^\/+/,"")}function bu(r){return r.trim().toLowerCase().endsWith(".canvas")}function E0(r,e){let t=em(e);if(!t||t.includes("{{"))return null;let n=r.vault.getAbstractFileByPath(t);return!n||!(n instanceof bB.TFile)||n.extension!=="canvas"?null:n}function wB(r,e){let n=r.workspace.getMostRecentLeaf?.()?.view;if(!n||n.getViewType?.()!=="canvas")return null;let i=em(e),o=em(n.file?.path??r.workspace.getActiveFile()?.path??"");if(!i||i!==o)return null;let s=n.canvas?.selection?Array.from(n.canvas.selection):[];if(s.length!==1)return null;let a=s[0]?.id;return typeof a=="string"&&a.length>0?a:null}function kX(r){return typeof r=="string"?r:r&&typeof r=="object"&&"path"in r&&typeof r.path=="string"?r.path:"(missing file path)"}function SX(r){return typeof r.x!="number"||typeof r.y!="number"||typeof r.width!="number"||typeof r.height!="number"?"":`${Math.round(r.x)},${Math.round(r.y)} \xB7 ${Math.round(r.width)}x${Math.round(r.height)}`}function x0(r,e){return r.length<=e?r:r.slice(0,e-1)+"\u2026"}async function CB(r,e){try{let t=await r.vault.cachedRead(e),n=JSON.parse(t);if(!n||typeof n!="object")return[];let i=n.nodes;if(!Array.isArray(i))return[];let o=i.filter(a=>!!a&&typeof a=="object"&&typeof a.id=="string").map(a=>{let l=a.type==="text"?"text":a.type==="file"?"file":"other",c=SX(a);if(l==="text"){let m=(typeof a.text=="string"?a.text:"").split(`
`).map(w=>w.trim()).filter(w=>w.length>0),v=x0(m[0]??"(empty text card)",90),g=[`${m.length} line${m.length===1?"":"s"}`];c&&g.push(c);let y=g.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let p=kX(a.file),m=ir.test(p),v=m?"":"Canvas file cards must link to markdown files (.md).",g=x0(p.split("/").pop()??p,90),y=[x0(p,120)];c&&y.push(c),m||y.push("Not capturable in this version");let w=y.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:w,searchText:`${a.id} ${g} ${w}`.toLowerCase(),capturable:m,capturableReason:v}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,f=c||"Type is not currently capturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.toLowerCase(),capturable:!1,capturableReason:"This Canvas node type is not capturable."}}),s={text:0,file:1,other:2};return o.sort((a,l)=>{let c=s[a.type]-s[l.type];return c!==0?c:a.title.localeCompare(l.title)})}catch{return[]}}qt();function _u(r){return/\{\{[^}]*\}\}/.test(r)}ml();Fo();Wt();Tt();var aJ=["noteContent","captureTarget","fileName","lineTarget"],lJ=["captureTarget","fileName"],Ci=aJ,XU=3;function Je(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var cJ=[{regex:Y2,contexts:Ci,suggestion:Je("{{VALUE}}","Asks you for text when the choice runs")},{regex:K2,contexts:Ci,suggestion:Je("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Je("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Je("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Je("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Je("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Je("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Je("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Je("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Je("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Je("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Je("{{VALUE:title|trim}}","Trims whitespace off the answer"),Je("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:G2,contexts:Ci,suggestion:Je("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:Q2,contexts:Ci,suggestion:Je("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Je("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Je("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Je("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Je("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable")]},{regex:rB,contexts:Ci,suggestion:Je("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:tB,contexts:Ci,suggestion:Je("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let e=[Je("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return lJ.includes(r)||e.push(Je("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Je("{{FILE:<folder>|path}}","Same, but inserts its full path"),Je("{{FILE:<folder>|optional}}","Same, but skippable")),e.push(Je("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),e}},{regex:oB,contexts:Ci,suggestion:Je("{{MVALUE}}","Asks you for a math formula (LaTeX), with a live preview")},{regex:H2,contexts:Ci,suggestion:Je("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:j2,contexts:Ci,suggestion:Je("{{DATE:}}","Today's date in a format you choose, like {{DATE:MMMM Do}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMM Do, YYYY","ddd D MMM","gggg-[W]ww"].map(e=>Je(`{{DATE:${e}}}`,r(e))),Je("{{DATE+7}}","Seven days from today"),Je("{{DATE:YYYY-MM-DD|startof
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-1bigjf0 > input:where(.svelte-1bigjf0) {pointer-events:none;}`};function lr(r,e){we(e,!0),ot(r,vJ);let t=he(e,"checked",15),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0),s=N(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a())}var c=gJ();let u;var d=I(c);gr(d),S(c),de(()=>{u=Ct(c,1,"checkbox-container svelte-1bigjf0",null,u,{"is-enabled":h(s),"is-disabled":n()}),ke(c,"aria-checked",h(s)),ke(c,"aria-label",i()),ke(c,"tabindex",n()?-1:0),qd(d,h(s))}),De("click",c,a),De("keydown",c,l),$(r,c),Ce()}Et(["click","keydown"]);var yJ=W("<option> </option>"),bJ=W('<select class="dropdown"></select>');function Jt(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0);var s=bJ();ar(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=yJ(),u=I(c,!0);S(c);var d={};de(()=>{me(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=h(l).value)??"")}),$(a,c)}),S(s),de(()=>{s.disabled=n(),ke(s,"aria-label",i())}),De("change",s,()=>o()?.(t())),e0(s,t),$(r,s),Ce()}Et(["change"]);Hs();Me();Cr();function km(r){return r==="Multi"?"folder":"choice"}function CV(r){return r==="Multi"?"Folder":"Choice"}function yee(r){return`${CV(r)} name`}async function E_(r,e,t){try{let i=(await Sr.Prompt(r,yee(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return Dt(n)||F.logError(Yd(n,"Could not rename")),null}}var bee=W('<h2 class="choiceNameHeader"><button type="button" class="choiceNameHeaderButton qa-rename-title-button"><span class="choiceNameHeaderText"> </span> <span class="choiceNameHeaderIcon" aria-hidden="true"><!></span></button></h2>');function hy(r,e){we(e,!0);let t=he(e,"name",15);async function n(){let u=await E_(e.app,t());u&&t(u)}var i=bee(),o=I(i),s=I(o),a=I(s,!0);S(s);var l=A(s,2),c=I(l);Rt(c,{iconId:"pencil",size:16}),S(l),S(o),S(i),de(()=>{ke(o,"aria-label",`Rename ${t()}`),me(a,t())}),De("click",o,n),$(r,i),Ce()}Et(["click"]);ml();Fo();var ii=class extends hn{constructor(t,n,i,o=1/0){super(t,n);this.app=t;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.items=i.map(s=>mn(s))}getSuggestions(t){let n=wc(t).toLowerCase(),i=this.items.filter(s=>s.toLowerCase().includes(n));return i.length===0&&this.close(),i.slice(0,this.maxSuggestions)}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){if(!t)return;let i=cy(t),o=cy(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function wee(r){return r?Array.isArray(r)?r:[r]:[]}function hp(r,e){let t=wee(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var Cee=W("<textarea></textarea>"),xee=W('<input type="text"/>'),Eee=W('<!> <div aria-live="polite"> </div>',1);function xi(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"placeholder",3,void 0),i=he(e,"inputKind",3,"text"),o=he(e,"required",3,!1),s=he(e,"requiredMessage",3,"This field is required"),a=he(e,"disabled",3,!1),l=he(e,"validator",3,void 0),c=he(e,"trim",3,!0),u=he(e,"suggestions",3,void 0),d=he(e,"maxSuggestions",3,1/0),f=he(e,"makeSuggesters",19,()=>[]),p=he(e,"app",3,void 0),m=he(e,"id",3,void 0),v=he(e,"ariaLabel",3,void 0),g=he(e,"onChange",3,void 0),y=Ae(!1),w=Ae(""),x=Ae("neutral"),C=0,_=!1,E=`qa-hint-${Math.random().toString(36).slice(2)}`,D=Y=>c()?Y.trim():Y;function P(Y,K=!1,se="neutral"){Z(y,K,!0),Z(w,Y??"",!0),Z(x,K?"neutral":se,!0)}async function H(Y){if(o()&&D(Y).length===0)return P(s(),!0),!1;if(!l())return P(void 0),!0;let K=++C,se=await Promise.resolve(l()(Y));return K!==C||_?!0:typeof se=="boolean"?(P(se?void 0:"Invalid value",!se),se):typeof se=="string"?(P(se,!0),!1):(P(se.message??(se.valid?void 0:"Invalid value"),!se.valid,se.valid?se.variant??"neutral":"neutral"),se.valid)}function V(Y){let K=Y.currentTarget.value;t(K),g()?.(K)}hr(()=>{o();let Y=t();H(Y)}),hr((
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),Dj=W("<!> <!>",1),yle=W(`<div class="setting-item-description">Inline insertion needs a single-line target. The line break (\\n) can't be
matched on the same line \u2014 remove it, or turn off "Inline insertion".</div>`),Ij=W("<!> <!> <!>",1),ble=W(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),wle=W(`<div class="setting-item-description">This heading uses a date token QuickAdd can't auto-read for sorting. Pick
"Date" and enter the format, or sections stay in insertion order.</div>`),Cle=W(`<div class="setting-item-description">The "Insert after" heading is created at its sorted position among ALL
same-level headings in the note (it is not scoped to one parent section). It
does NOT re-sort headings you already have; only the new one is placed. Use
"Insert at end of section" above for newest-on-top vs. appended entries within
each section.</div> <!> <!> <!> <!> <!> <!>`,1),xle=W("<!> <!> <!> <!> <!>",1);function OR(r,e){we(e,!0);let t=he(e,"insertAfter",15);t().inline===void 0&&t(t().inline=!1,!0),t().replaceExisting===void 0&&t(t().replaceExisting=!1,!0),t().promptHeading===void 0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void 0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void 0&&t(t().considerSubsections=!1,!0),t().blankLineAfterMatchMode||t(t().blankLineAfterMatchMode="auto",!0),t().createIfNotFound||t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=po,!0);let n=[B=>new Hi(e.app,B,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=N(()=>t().inline?[{value:po,label:"Top"},{value:ac,label:"Bottom"},{value:lc,label:"Cursor"}]:[{value:po,label:"Top"},{value:ac,label:"Bottom"},{value:lc,label:"Cursor"},{value:Aa,label:"Ordered (place new section among siblings)"}]),s=[{value:"insertion",label:"Insertion order (no sorting)"},{value:"lexical",label:"Text (A\u2192Z)"},{value:"numeric",label:"Number"},{value:"date",label:"Date"},{value:"semver",label:"Version (semver)"}],a=[{value:"desc",label:"Newest / highest first"},{value:"asc",label:"Oldest / lowest first"}],l=[{value:"bottom",label:"Sort existing unparseable headings to bottom"},{value:"top",label:"Sort existing unparseable headings to top"}],c=Ae(!!t().orderBy),u=N(()=>t().createIfNotFoundLocation===Aa),d=N(()=>t().createIfNotFound&&h(u)),f=N(()=>new fh(e.app,e.plugin)),p=Ae(!1);hr(()=>{let B=t().after??"",ie=h(f);if(!t().inline||B===""){Z(p,!1);return}let j=!1;return ie.format(B).then(Y=>{j||Z(p,/[\n\r]/.test(Y),!0)}).catch(()=>{j||Z(p,!1)}),()=>{j=!0}});let m=N(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),v=N(()=>/\{\{V?DATE\b/i.test(t().after??"")),g=N(()=>h(d)&&t().orderBy?.by==="insertion"&&h(v)&&!$R(t().after??""));hr(()=>{if(!h(d))return;let B=$R(t().after??"");if(!t().orderBy){t(t().orderBy={by:B?"date":"insertion",direction:"desc",dateFormat:B,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=B?"date":"insertion",!0),t(t().orderBy.dateFormat=B,!0))});function y(B){t(t().createIfNotFoundLocation=B,!0),B===Aa?t(t().inline=!1,!0):(t(t().orderBy=void 0,!0),Z(c,!1))}function w(B){Z(c,!0),t().orderBy&&t(t().orderBy.by=B,!0)}function x(B){t().promptHeading||B&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),new Pj.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function C(B){B&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var _=xle(),E=Pe(_);$e(E,{name:"Choose heading when capturing",desc:"Instead of typing a target line now, show a dropdown of the target note's headings when you run this capture and insert under the one you pick.",control:ie=>{lr(ie,{onchange:C,get checked(){return t().promptHeading},set checked(j){t(t().promptHeading=j,!0)}})},$$slots:{control:!0}});var D=A(E,2);{var P=B=>{var ie=vle();$(B,ie)},H=B=>{var ie=Ij(),j=Pe(ie);ss(j,{name:"Insert after",desc:"Insert capture after specified text. Accepts format syntax. Tip: use a heading (starts with #) to target a section. Blank line handling is configurable below.",children:(ge,be=Vt)=>{var xe=Dj(),Ue=Pe(xe);xi(Ue,{get id(){return be()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return t().after},set value(Ne){t(t().after=Ne,!0)}});var $t=A(Ue,2);hs($t,{get value(){return t().after},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(ge,xe)},$$slots:{default:!0}});var Y=A(j,2);{let pe=be=>{lr(be,{get disabled(){return h(u)},get checked(){return t().inline},set checked(xe){t(t().inline=xe,!0)}})},ge=N(()=>h(u)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");$e(Y,{name:"Inline insertion",get desc(){return h(g
for Canvas card capture. Use top, bottom, insert-after, or insert-before
placement.</div>`),Tle=W("<!> <!> <!> <!>",1);function BR(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>!!t().captureToActiveFile),i=N(()=>t().insertAfter?.enabled?"after":t().insertBefore?.enabled?"before":t().newLineCapture?.enabled?t().newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":h(n)?t().activeFileWritePosition==="top"?"activeTop":t().activeFileWritePosition==="bottom"||t().prepend?"bottom":"top":t().prepend?"bottom":"top"),o=N(()=>[{value:"top",label:h(n)?"At cursor":"Top of file"},...h(n)?[{value:"activeTop",label:"Top of file (after frontmatter)"},{value:"newLineAbove",label:"New line above cursor"},{value:"newLineBelow",label:"New line below cursor"}]:[],{value:"after",label:"After line\u2026"},{value:"before",label:"Before line\u2026"},{value:"bottom",label:"Bottom of file"}]);function s(g){if(t(t().prepend=!1,!0),t(t().insertAfter.enabled=!1,!0),t(t().insertAfter.promptHeading=!1,!0),t(t().insertAfter.inline=!1,!0),t(t().insertAfter.replaceExisting=!1,!0),t().insertBefore||t(t().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),t(t().insertBefore.enabled=!1,!0),t().newLineCapture||t(t().newLineCapture={enabled:!1,direction:"below"},!0),t(t().newLineCapture.enabled=!1,!0),t(t().activeFileWritePosition="cursor",!0),g==="top"){h(n)||t(t().prepend=!1,!0);return}if(g==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(g==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(g==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(g==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(g==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=N(()=>{let g=typeof t().captureTo=="string"&&bu(t().captureTo),y=e.app.workspace.getActiveViewOfType(Fj.FileView)?.getViewType()==="canvas",w=h(n)&&!t().insertAfter.enabled&&!t().insertBefore?.enabled&&!t().newLineCapture?.enabled&&(t().activeFileWritePosition??"cursor")==="cursor"&&!t().prepend;return!(!(t().newLineCapture?.enabled||w)||(h(n)?!y:!g))});var l=Tle(),c=Pe(l);{let g=w=>{Jt(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},y=N(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");$e(c,{name:"Write position",get desc(){return h(y)},control:g,$$slots:{control:!0}})}var u=A(c,2);{var d=g=>{OR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(y){t(t().insertAfter=y,!0)}})};ne(u,g=>{t().insertAfter.enabled&&g(d)})}var f=A(u,2);{var p=g=>{LR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(y){t(t().insertBefore=y,!0)}})};ne(f,g=>{t().insertBefore?.enabled&&g(p)})}var m=A(f,2);{var v=g=>{var y=Ele();$(g,y)};ne(m,g=>{h(a)&&g(v)})}$(r,l),Ce()}var _le=new Set(["activity","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","aperture","archive","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-righ
@media (min-width: 768px) {.quickAddFolderListGrid.svelte-ee11ws {display:grid;grid-template-columns:repeat(2, 1fr);column-gap:20px;}
}.quickAddCommandList.svelte-ee11ws {max-width:50%;margin:12px auto;}`};function qR(r,e){we(e,!0),ot(r,Lle);var t=Nle();ar(t,20,()=>e.folders,n=>n,(n,i)=>{var o=Ole(),s=I(o),a=I(s,!0);S(s);var l=A(s,2);{let c=N(()=>`Remove folder ${i}`);er(l,{iconId:"trash-2",get label(){return h(c)},onclick:()=>e.deleteFolder(i)})}S(o),de(()=>me(a,i)),$(n,o)}),S(t),$(r,t),Ce()}function jj(r){return r.enabled?r.chooseWhenCreatingNote?"prompt":r.createInSameFolderAsActiveFile?"active-file":"specified":"obsidian-default"}function Gj(r,e){switch(e){case"obsidian-default":return{...r,enabled:!1,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"specified":return{...r,enabled:!0,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"active-file":return{...r,enabled:!0,createInSameFolderAsActiveFile:!0,chooseWhenCreatingNote:!1};case"prompt":return{...r,enabled:!0,chooseWhenCreatingNote:!0,createInSameFolderAsActiveFile:!1}}}var Yj=[{value:"obsidian-default",label:"Obsidian default"},{value:"specified",label:"In a specific folder"},{value:"active-file",label:"Same folder as current file"},{value:"prompt",label:"Ask for folder each time"}],Kj={"obsidian-default":"Use Obsidian's \u201CDefault location for new notes\u201D setting.",specified:"Create the note in the folder(s) below. With multiple folders, you'll be asked which one when the note is created.","active-file":"Create the note next to the currently active file (falls back to the vault root if no file is open).",prompt:"Choose any folder in the vault when the note is created."};Tt();Tt();function WA(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Rs.toLowerCase()||t===q2.toLowerCase()}function WR(r,e){return r.discoverExistingNotesBeforeCreate===!0&&WA(r,e)}function zR(r,e,t){return!(!WR(r,e)||t!=null)}Tt();function zA(r){if(!r?.enabled||r.chooseWhenCreatingNote||r.chooseFromSubfolders||r.createInSameFolderAsActiveFile)return;let e=r.folders??[];if(e.length!==1)return;let t=e[0]?.trim();if(t&&!t.includes("{{")&&!uc.test(t))return t}var Ble=W("<!> <!> <!>",1),Ule=W(`<div class="qa-folder-mode-warning">Add at least one folder. With none, the note falls back to the active
file's folder (or you'll be prompted to pick one if no file is open).</div>`),Vle=W('<div class="folderSelectionContainer"><div class="folderList"><!></div> <div class="folderInputContainer"><input type="text" class="qa-folder-path-input" placeholder="Folder path" aria-label="Folder path"/> <button type="button" class="mod-cta">Add</button></div></div> <!> <!>',1),qle=W("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function HR(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>e.plugin.getTemplateFiles().map(ye=>ye.path)),i=N(()=>Oc(Ls(e.app)));function o(ye){let We=ye.trim();return We?_u(We)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:fo(e.app,We)!==null||"Template not found":!0}let s=[ye=>new Hi(e.app,ye,e.plugin,"fileName")],a=N(()=>WA(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Rs)),l=N(()=>h(a)?"For the default note-title prompt, show matching notes first. Choosing one opens it unchanged; choosing the create row continues with this template.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=N(()=>jj(t().folder)),u=N(()=>Kj[h(c)]),d=N(()=>h(c)==="specified"&&t().folder.folders.length===0);function f(ye){t(t().folder=Gj(t().folder,ye),!0)}let p=Ae(""),m;function v(ye){return m=new VA(e.app,ye,h(i),t().folder.folders),m}hr(()=>{m?.updateCurrentItems(t().folder.folders)});function g(){let ye=h(p).trim();if(ye){if(t().folder.folders.some(We=>We===ye)){F.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ye),Z(p,"")}}function y(ye){t(t().folder.folders=t().folder.folders.filter(We=>We!==ye),!0)}function w(ye){ye.key==="Enter"&&g()}let x=N(()=>Vj(t().fileExistsBehavior)),C=N(()=>h(x)!=="prompt"&&h(x)!=="keep"),_=N(()=>Lj(h(x)==="update"?"update":"create")),E=N(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(_)[0].id);function D(ye){t(t().fileExistsBehavior=qj(ye,t().fileExistsBehavior),!0)}function P(ye){t(t().fileExistsBehavior={kind:"apply",mode:ye},!0)}var H=qle(),V=Pe(H);hy(V,{get app(){return e.app},get name(){return t().name},set name(ye){t(t().name=ye,!0)}});var oe=A(V,2);$e(oe,{name:"Template",heading:!0});var ce=A(oe,2);ss(ce,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(We,ht=Vt)=>{xi(We,{get id(){return ht()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:He=>t(t().templatePath=He.trim(),!0)})},$$slots:{default:!0}});var R=A(ce,2);ss(R,{name:"File name format",desc:"Set the file name format. When off, QuickAdd asks for the note title.",get bodyVisible(){return t().fileNameFormat.enabled},control:ht=>{lr(ht,{get checked(){return t().fileNameFormat.enabled},set checked(He){t(t().fileNameFormat.enabled=He,!0)}})},children:(ht,He=Vt)=>{var _e=Ble(),Be=Pe(_e);xi(Be,{get id(){return He()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(yr){t(t().fileNameFormat.format=yr,!0)}});var ut=A(Be,2);qp(ut,{get value(){return t().fileNameFormat.format}});var or=A(ut,2);{let yr=N(()=>zA(t().folder));hs(or,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(yr)},get app(){return e.app},get plugin(){return e.plugin}})}$(ht,_e)},$$slots:{control:!0,default:!0}});var O=A(R,2);$e(O,{name:"Location",heading:!0});var q=A(O,2);$e(q,{name:"New note location",get desc(){return h(u)},control:We=>{Jt(We,{get value(){return h(c)},get options(){return Yj},ariaLabel:"New note location",onchange:f})},$$slots:{control:!0}});var B=A(q,2);{var ie=ye=>{var We=Vle(),ht=Pe(We),He=I(ht),_e=I(He);qR(_e,{get folders(){return t().folder.folders},deleteFolder:y}),S(He);var Be=A(He,2),ut=I(Be);gr(ut),un(()=>uo(ut,()=>h(p),ur=>Z(p,ur))),Fr(ut,(ur,dt)=>hp?.(ur,dt),()=>v);var or=A(ut,2);S(Be),S(ht);var yr=A(ht,2);{var Pt=ur=>{var dt=Ule();$(ur,dt)};ne(yr,ur=>{h(d)&&ur(Pt)})}var Ar=A(yr,2);$e(Ar,{name:
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Zle(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function jp(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=n$(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){t=t.call(r)},n:function(){var l=t.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&t.return!=null&&t.return()}finally{if(s)throw a}}}}var Jle="finalize",ece="consider";function Dh(r,e,t){r.dispatchEvent(new CustomEvent(Jle,{detail:{items:e,info:t}}))}function Ju(r,e,t){r.dispatchEvent(new CustomEvent(ece,{detail:{items:e,info:t}}))}var tk="draggedEntered",px="draggedLeft",rk="draggedOverIndex",i$="draggedLeftDocument",YA={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function tce(r,e,t){r.dispatchEvent(new CustomEvent(tk,{detail:{indexObj:e,draggedEl:t}}))}function rce(r,e,t){r.dispatchEvent(new CustomEvent(px,{detail:{draggedEl:e,type:YA.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function nce(r,e){r.dispatchEvent(new CustomEvent(px,{detail:{draggedEl:e,type:YA.OUTSIDE_OF_ANY}}))}function ice(r,e,t){r.dispatchEvent(new CustomEvent(rk,{detail:{indexObj:e,draggedEl:t}}))}function oce(r){window.dispatchEvent(new CustomEvent(i$,{detail:{draggedEl:r}}))}var Ai={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:tk,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:rk,DRAGGED_LEFT:px,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Zi={POINTER:"pointer",KEYBOARD:"keyboard"},sce={space:[" "],enter:["Enter"],space_or_enter:[" ","Enter"]},uG="space_or_enter",ace={space:"space-bar",enter:"enter",space_or_enter:"space-bar or enter"},nk="isDndShadowItem",ik="data-is-dnd-shadow-item-internal",lce="data-is-dnd-shadow-item-hint",ok="id:dnd-shadow-placeholder-0000",cce="dnd-action-dragged-el",Lr="id",KR=0;function dG(){KR++}function pG(){if(KR===0)throw new Error("Bug! trying to decrement when there are no dropzones");KR--}var o$=typeof window>"u",mt=function(){};function QR(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t,n=e?pce(r):r.getBoundingClientRect(),i=getComputedStyle(r),o=i.transform;if(o){var s,a,l,c;if(o.startsWith("matrix3d("))t=o.slice(9,-1).split(/, /),s=+t[0],a=+t[5],l=+t[12],c=+t[13];else if(o.startsWith("matrix("))t=o.slice(7,-1).split(/, /),s=+t[0],a=+t[3],l=+t[4],c=+t[5];else return n;var u=i.transformOrigin,d=n.x-l-(1-s)*parseFloat(u),f=n.y-c-(1-a)*parseFloat(u.slice(u.indexOf(" ")+1)),p=s?n.width/s:r.offsetWidth,m=a?n.height/a:r.offsetHeight;return{x:d,y:f,width:p,height:m,top:f,right:d+p,bottom:f+m,left:d}}else return n}function XR(r){var e=QR(r);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function fG(r){var e=r.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function mG(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function uce(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}function lx(r,e){return r.y<=e.bottom&&r.y>=e.top&&r.x>=e.left&&r.x<=e.right}function hG(r){return mG(fG(r))}function Jj(r,e){var t=hG(e);return uce(r,t)}function dce(r){var e=fG(r);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}function pce(r){for(var e=r.getBoundingClientRect(),t={top:e.top,bottom:e.bottom,left:e.left,right:e.right},n=!1,i=!1,o=r.parentElement;o&&o!==document.body;){var s=window.getComputedStyle(o),a=s.overflowY,l=s.overflowX,c=a==="scroll"||a==="auto",u=l==="scroll"||l==="auto";if(c||u){var d=o.getBoundingClientRect();if(c){var f=Math.max(t.top,d.top),p=Math.min(t.bottom,d.bottom);(f!==t.top||p!==t.bottom)&&(n=!0),t.top=f,t.bottom=p}if(u){var m=Math.max(t.left,d.left),v=Math.min(t.right,d.right);(m!==t.left||v!==t.right)&&(i=!0),t.left=m,t.right=v}}o=o.parentElement}return n||i?{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:Math.max(0,t.bottom-t.top)}:{top:e.top,bottom:e.bottom,left:e.left,right:e.right,wid
or edited here. Nothing has been changed or deleted, and QuickAdd will not
overwrite it.</p> <p class="qaDataUnreadableBody svelte-ktqmtm">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
vault. Make a copy of that file before editing it.</p></div>`),Que={hash:"svelte-ktqmtm",code:".qaDataUnreadable.svelte-ktqmtm {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaDataUnreadableHead.svelte-ktqmtm {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-ktqmtm {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-ktqmtm {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};function B$(r,e){ot(r,Que);var t=Kue(),n=I(t),i=I(n);Rt(i,{iconId:"alert-triangle",size:16});var o=A(i,2),s=I(o);S(o),S(n),Pn(4),S(t),de(()=>me(s,`QuickAdd couldn't read ${e.what??""}`)),$(r,t)}var eg=class{constructor(e){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=e.app,this.plugin=e.plugin,this.unreadable=Di(e.commands),this.commandsRef=m$(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){return this.destroy(),this.containerEl=e,e.empty(),e.addClass("quickAddCommandEditor"),this.unreadable?(this.renderUnreadableCard(e),!1):this.renderCommandList(e)?(this.renderCommandBar(e),this.renderAddObsidianCommandSetting(e),this.renderAddEditorCommandSetting(e),this.renderAddUserScriptSetting(e),this.renderAddChoiceSetting(e),!0):!1}renderUnreadableCard(e){let t=e.createDiv("commandList");this.unreadableCardHandle=qi(t,B$,{what:"this macro's commands"},{what:"this macro's commands"})}destroy(){this.commandListHandle?.destroy(),this.commandListHandle=null,this.commandListProps=null,this.unreadableCardHandle?.destroy(),this.unreadableCardHandle=null}loadObsidianCommands(){Object.keys(this.app.commands.commands).forEach(e=>{let t=this.app.commands.commands[e];this.obsidianCommands.push(new wx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=Pk(this.app)}renderCommandList(e){let t=e.createDiv("commandList");return this.commandListProps=nY({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw F.logError("command not found"),new Error("command not found");if(!await Qi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!await yx(this.app,i)){new Fi.Notice("Could not clear user script secrets. Command was not deleted.");return}this.commandsRef=this.commandsRef.filter(a=>a.id!==n),this.emitCommandsChanged()},saveCommands:n=>{this.commandsRef=n,this.onCommandsChange?.(n)},onConfigureCondition:this.conditionalHandlers?.configureCondition,onEditThenBranch:this.conditionalHandlers?.editThenBranch,onEditElseBranch:this.conditionalHandlers?.editElseBranch}),this.commandListHandle=qi(t,k$,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){let t=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",qh),this.addChoiceButton(t,"Template",rd),this.addOpenFileCommandButton(t),this.addWaitCommandButton(t),this.addConditionalCommandButton(t),le.getState().disableOnlineFeatures||this.addAIAssistantCommandButton(t)}renderAddObsidianCommandSetting(e){let t,n=()=>{let i=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){F.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new wx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};new Fi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Obsidian command"),new ii(this.app,i.inputEl,this.obsidianCommands.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").o
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-a7rp4h svg:last-child {margin-left:-0.1em;opacity:0.85;}
/* Per-folder ("compact") controls render as quiet, clickable text links \u2014 not
filled buttons \u2014 so they read as "add inside this folder" affordances and
don't compete with the global primary CTA, especially when repeated across
nested folders. */.qaAddChoiceControls.compact.svelte-a7rp4h {gap:1rem;}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h) {font-size:var(--font-ui-smaller);padding:2px 0;gap:0.25em;background:transparent;border:none;box-shadow:none;color:var(--text-muted);}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h):hover {color:var(--text-accent);text-decoration:underline;}
/* Mobile/touch: stretch so the two buttons fill the bar width instead of
cramming to the right. Driven by \`fill\` (Platform.isMobile from the bottom
bar) because viewport media queries don't fire under desktop mobile-emulation. */.qaAddChoiceControls.fill.svelte-a7rp4h {flex:1;}.qaAddChoiceControls.fill.svelte-a7rp4h button:where(.svelte-a7rp4h) {flex:1;justify-content:center;}
/* Narrow desktop windows stack the non-compact controls. Filled controls (the
mobile bottom bar) are excluded so this can't override \`.fill\`'s side-by-side
50/50 layout on a phone-width viewport (Platform.isMobile + width <= 800px). */
@media (max-width: 800px) {.qaAddChoiceControls.svelte-a7rp4h:not(.compact):not(.fill) {flex-direction:column;align-items:stretch;}
}`};function og(r,e){we(e,!0),ot(r,Mde);let t=he(e,"targetFolderId",3,void 0),n=he(e,"targetFolderName",3,void 0),i=he(e,"compact",3,!1),o=he(e,"fill",3,!1),s=Ae(!1);function a(V){let oe=new NY.Menu;for(let R of $Y)oe.addItem(O=>O.setTitle(`${R.label} \u2014 ${R.description}`).setIcon(R.iconId).onClick(q=>{let B=q.altKey===!0;e.onAddChoice(nS(R.type),R.type,t(),B)}));Z(s,!0),oe.onHide(()=>{Z(s,!1)});let ce=V.target?.closest("button");if(ce){let R=ce.getBoundingClientRect();oe.showAtPosition({x:R.left,y:R.bottom+4})}else oe.showAtMouseEvent(V)}function l(){e.onAddChoice(nS("Multi"),"Multi",t(),!0)}let c=N(()=>i()?"Add choice":"New choice"),u=N(()=>i()?"Add folder":"New folder"),d=N(()=>n()?`Add choice to ${n()}`:h(c)),f=N(()=>n()?`Add folder to ${n()}`:h(u));var p=Fde();let m;var v=I(p),g=I(v);Rt(g,{iconId:"folder-plus",size:14});var y=A(g,2),w=I(y,!0);S(y),S(v);var x=A(v,2);let C;var _=I(x);Rt(_,{iconId:"plus",size:14});var E=A(_,2),D=I(E,!0);S(E);var P=A(E,2);{var H=V=>{Rt(V,{iconId:"chevron-down",size:12})};ne(P,V=>{i()||V(H)})}S(x),S(p),de(()=>{m=Ct(p,1,"qaAddChoiceControls svelte-a7rp4h",null,m,{compact:i(),fill:o()&&!i()}),ke(v,"aria-label",h(f)),ke(v,"title",i()?h(f):void 0),me(w,h(u)),C=Ct(x,1,"qaNewChoiceBtn svelte-a7rp4h",null,C,{"mod-cta":!i()}),ke(x,"aria-expanded",h(s)),ke(x,"aria-label",h(d)),ke(x,"title",i()?h(d):void 0),me(D,h(c))}),De("click",v,l),De("click",x,a),$(r,p),Ce()}Et(["click"]);var Rde=W('<div class="rightButtonsContainer svelte-1es4f02"><!> <!> <!> <!> <!> <!></div>'),$de={hash:"svelte-1es4f02",code:`.rightButtonsContainer.svelte-1es4f02 {display:flex;align-items:center;
/* Icons carry their own 3px padding inside the choice rows (24px hit
boxes), so a tight gap keeps the cluster compact without touching. */gap:2px;flex:0 0 auto;}`};function Dx(r,e){we(e,!0),ot(r,$de);let t=he(e,"showConfigureButton",3,!0),n=he(e,"showDuplicateButton",3,!0),i=he(e,"commandEnabled",3,!1),o=he(e,"choiceName",3,"");var s=Rde(),a=I(s);{var l=g=>{{let y=N(()=>`Configure${o()?" "+o():""}`);er(g,{iconId:"settings",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onConfigureChoice}})}};ne(a,g=>{t()&&g(l)})}var c=A(a,2);{var u=g=>{{let y=N(()=>`Duplicate${o()?" "+o():""}`);er(g,{iconId:"copy",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDuplicateChoice}})}};ne(c,g=>{n()&&g(u)})}var d=A(c,2);{let g=N(()=>`Delete${o()?" "+o():""}`);er(d,{iconId:"trash-2",get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDeleteChoice}})}var f=A(d,2);{var p=g=>{{let y=N(()=>`More options${o()?" for "+o():""}`);er(g,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return h(y)},onclick:w=>e.onOpenMenu?.(w.currentTarget)})}};ne(f,g=>{e.onOpenMenu&&g(p)})}var m=A(f,2);{let g=N(()=>`Command palette${o()?": "+o():""}`);er(m,{iconId:"zap",get ariaPressed(){return i()},get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onToggleCommand}})}var v=A(m,2);{let g=N(()=>`Reorder${o()?" "+o():""}`);ki(v,{get label(){return h(g)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.onDragHandleDown},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(s),$(r,s),Ce()}var oS=require("obsidian");var LY=require("obsidian");function iS(r,e,t,n){e.replaceChildren(),LY.MarkdownRenderer.render(n,r,e,"/",t)}Wt();var Ode=W('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),Nde={hash:"svelte-1aljzaf",code:""};function X$(r,e){we(e,!0),ot(r,Nde);let t=!0,n=Ae(void 0),i=new oS.Component;hr(()=>{h(n)&&iS(e.choice.name,h(n),i,e.app)}),hr(()=>()=>i.unload());let o=()=>({onRename:()=>e.actions.onRenameChoice(e.choice),onToggle:()=>e.actions.onToggleCommand(e.choice),onConfigure:()=>e.actions.onConfigureChoice(e.choice),onDuplicate:()=>e.actions.onDuplicateChoice(e.choice),onDelete:()=>e.actions.onDeleteChoice(e.choice),onMove:p=>e.actions.onMoveChoice(e.choice,p)});function s(p){jk(e.app,p,e.choice,e.roots,o())}function a(p){Gk(e.app,p,e.choice,e.roots,o())}var l=Ode(),c=I(l),u=I(c);{let p=N(()=>bm(e.choice));Rt(u,{get iconId(){return h(p)},size:15})}S(c);var d=A(c,2);oc(d,p=>Z(n,p),()=>h(n));var f=A(d,2);Dx(f,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(e.choice),onConfigureChoice:()=>e.actions.onConfigureChoice(e.choice),onToggleCommand:()=>e.actions.onToggleCommand(e.choice),onDuplicateChoice:()=>e.actions.onDuplicateChoice(e.choice),onOpenMenu:a,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},get choiceName(){return e.choice.name},get commandEnabled(){return e.choice.command},showConfigureButton:t,get dragDisabled(){return e.dragDisabled},showDuplicateButton:!0}),S(l),de(()=>ke(l,"data-choice-id",e.choice.id)),De("contextmenu",l,s),De("dblclick",l,p=>{oS.Platform.isMobile||p.target.closest("button, a")||e.actions.onConfigureChoice(e.choice)}),$(r,l),Ce()}Et(["contextmenu","dblclick"]);var sS=require("obsidian");Wt();var Lde=W('<span class="qaFolderCount svelte-1jxjn06" aria-hidden="true"> </span>'),Bde=W(`<p class="qaUnreadableFolder svelte-1jxjn06">QuickAdd couldn't read this folder's contents. They're still
in <code class="svelte-1jxjn06">data.json</code>.</p>`),Ude=W('<div class="nestedAddRow svelte-1jxjn06"><!></div>'),Vde=W("<!> <!>",1),qde=W('<div class="nestedChoiceList svelte-1jxjn06"><!></div>'),Wde=W('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-1jxjn06"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),zde={hash:"svelte-1jxjn06",code:`
/* Row surface (min-height, padding, radius, hover, rhythm) is shared with
leaf rows and lives in styles.css \u2014 see "Choice list rows". Only the
folder-specific pieces stay here. */
/* Base icon = chevron-down (expanded); collapsed rotates to point RIGHT,
matching Obsidian's own collapse grammar (file explorer, outline). */.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:transform 150ms ease;}.multiChoiceCollapseIcon.is-collapsed.svelte-1jxjn06 {transform:rotate(-90deg);}
@media (prefers-reduced-motion: reduce) {.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:none;}
}
/* Full-width collapse toggle: reset native <button> chrome while keeping
native keyboard activation + aria-expanded. It hosts the shared icon
column (the chevron), so the folder NAME lands on the exact leaf-name x
for free \u2014 same 8px column gap as the leaf rows. */.multiChoiceListItemName.svelte-1jxjn06 {flex:1 1 auto;min-width:0;align-self:stretch;display:flex;align-items:center;
/* Obsidian's base button centers flex content; the name must not rely
on a growing child to stay left (it stopped growing for the count). */justify-content:flex-start;gap:8px;background:transparent;border:none;box-shadow:none;padding:0;
/* Obsidian's base button rule sets height: var(--input-height) (30px),
which would make folder rows 4px taller than leaf rows \u2014 the exact
rhythm break this redesign removes. */height:auto;min-height:0;font:inherit;color:inherit;text-align:left;cursor:pointer;
/* Suppress double-tap-zoom + its click delay on touch \u2014 proper touch hygiene
for a tap target, and reduces the ghost-click the dedupe above also guards. */touch-action:manipulation;}
/* The count reads as part of the label ("Misc \xB7 12"), so the name must not
grow \u2014 it keeps its ellipsis via flex-shrink + the shared min-width: 0. */.multiChoiceListItemName.svelte-1jxjn06 .choiceListItemName {flex:0 1 auto;}
/* Same slot, weight and colour as the empty-folder hint in ChoiceList, so a
folder we cannot read reads as a variation of "empty" rather than an alarm. */.qaUnreadableFolder.svelte-1jxjn06 {margin:0;padding:6px 8px 8px;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06 code:where(.svelte-1jxjn06) {font-size:inherit;}.qaFolderCount.svelte-1jxjn06 {flex:0 0 auto;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);font-variant-numeric:tabular-nums;line-height:1;}.multiChoiceListItemName.svelte-1jxjn06:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;border-radius:var(--radius-s, 4px);}
/* Just the indent \u2014 the drop-into-folder ring is drawn on the ACTUAL dndzone
(.choiceList, in ChoiceList.svelte) so the highlighted area equals the
droppable area (WYSIWYG); it is NOT drawn on this wrapper, which extends past
the zone to the add-row/hint. The ::before is an indent GUIDE under the
parent's icon column (x = row padding 8px + half the 18px column, minus
half the line), clarifying what belongs to the open folder. */.nestedChoiceList.svelte-1jxjn06 {position:relative;padding-left:26px;}.nestedChoiceList.svelte-1jxjn06::before {content:"";position:absolute;left:16px;top:3px;bottom:3px;width:1px;background:var(--background-modifier-border);pointer-events:none;}
/* The per-folder add-row reads as a ghost row of the folder: aligned to the
child rows' padding, one tight step (4px) below the last child. */.nestedAddRow.svelte-1jxjn06 {margin:2px 0 4px 0;padding:0 8px;}`};function Z$(r,e){we(e,!0),ot(r,zde);let t=he(e,"choice",7),n=he(e,"forceDragDisabled",3,!1),i=N(()=>st(t())),o=N(()=>zs(t())),s=!0,a=Ae(void 0),l=new sS.Component;hr(()=>{h(a)&&iS(t().name,h(a),l,e.app)}),hr(()=>()=>l.unload());let c=()=>({onRename:()=>e.actions.onRenameChoice(t()),onToggle:()=>e.actions.onToggleCommand(t()),onConfigure:()=>e.actions.onConfigureChoice(t()),onDuplicate:()=>e.actions.onDuplicateChoice(t()),onDelete:()=>e.actions.onDeleteChoice(t()),onMove:V=>e.actions.onMoveChoice(t(),V)});function u(V){jk(e.app,V,t(),e.roots,c())}function d(V){Gk(e.app,V,t(),e.roots,c())}let f={...Ot(()=>e.actions),onReorderChoices:V=>{t().choices=V,e.actions.onCommitFolder(t().id,V)}};function p(){n()||e.actions.onToggleCollapsed(t())}var m=Wde(),v=I(m),g=I(v),y=I(g);let w;var x=I(y);Rt(x,{iconId:"chevron-down",size:16}),S(y);var C=A(y,2);oc(C,V=>Z(a,V),()=>h(a));var _=A(C,2);{var E=V=>{var oe=Lde(),ce=I(oe,!0);S(oe),de(()=>me(ce,h(i).length)),$(V,oe)};ne(_,V=>{t().collapsed&&h(i).length>0&&V(E)})}S(g),Fr(g,V=>qA?.(V));var D=A(g,2);Dx(D,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(t()),onConfigureChoice:()=>e.actions.onConfigureChoice(t()),onToggleCommand:()=>e.actions.onToggleCommand(t()),onDuplicateChoice:()=>e.actions.onDuplicateChoice(t()),onOpenMenu:d,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},showConfigureButton:s,get dragDisabled(){return e.dragDisabled},get choiceName(){return t().name},get commandEnabled(){return t().command},showDuplicateButton:!0}),S(v);var P=A(v,2);{var H=V=>{var oe=dn(),ce=Pe(oe);{var R=O=>{var q=qde(),B=I(q);{var ie=Y=>{var K=Bde();$(Y,K)},j=Y=>{var K=Vde(),se=Pe(K);{let be=N(()=>h(i).length===0),xe=N(()=>e.rootReorder??e.actions.onReorderChoices);sg(se,{get app(){return e.app},get roots(){return e.roots},get choices(){return h(i)},nested:!0,get isEmptyFolder(){return h(be)},get forceDragDisabled(){return n()},get rootReorder(){return h(xe)},get actions(){return f}})}var pe=A(se,2);{var ge=be=>{var xe=Ude(),Ue=I(xe);og(Ue,{compact:!0,get targetFolderId(){return t().id},get targetFolderName(){return t().name},get onAddChoice(){return e.actions.onAddChoice}}),S(xe),$(be,xe)};ne(pe,be=>{n()||be(ge)})}$(Y,K)};ne(B,Y=>{h(o)?Y(ie):Y(j,-1)})}S(q),$(O,q)};ne(ce,O=>{t().collapsed||O(R)})}$(V,oe)};ne(P,V=>{(!e.collapseId||e.collapseId&&t().id!==e.collapseId)&&V(H)})}S(m),de(()=>{ke(v,"data-choice-id",t().id),ke(g,"aria-expanded",!t().collapsed),ke(g,"aria-label",`Toggle ${t().name}`),w=Ct(y,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-1jxjn06",null,w,{"is-collapsed":t().collapsed})}),De("contextmenu",v,u),De("click",v,V=>{sS.Platform.isMobile||V.target.closest("button, a")||p()}),De("click",g,p),$(r,m),Ce()}Et(["contextmenu","click"]);function BY(r){let e=r-1;return e*e*e+1}function UY(r,{from:e,to:t},n={}){var{delay:i=0,duration:o=E=>Math.sqrt(E)*120,easing:s=BY}=n,a=getComputedStyle(r),l=a.transform==="none"?"":a.transform,[c,u]=a.transformOrigin.split(" ").map(parseFloat);c/=r.clientWidth,u/=r.clientHeight;var d=Hde(r),f=r.clientWidth/t.width/d,p=r.clientHeight/t.height/d,m=e.left+e.width*c,v=e.top+e.height*u,g=t.left+t.width*c,y=t.top+t.height*u,w=(m-g)*f,x=(v-y)*p,C=e.width/t.width,_=e.height/t.height;return{delay:i,duration:typeof o=="function"?o(Math.sqrt(w*w+x*x)):o,easing:s,css:(E,D)=>{var P=D*w,H=D*x,V=E+D*C,oe=E+D*_;return`transform: ${l} translate(${P}px, ${H}px) scale(${V}, ${oe});`}}}function Hde(r){if("currentCSSZoom"in r)return r.currentCSSZoom;for(var e=r,t=1;e!==null;)t*=+getComputedStyle(e).zoom,e=e.parentElement;return t}var VY=require("obsidian");Wt();var jde=W("<div><!></div>"),Gde=W("<div></div>"),Yde={hash:"svelte-2ry05y",code:`.choiceList.svelte-2ry05y {width:auto;}
/* Root (non-nested) empty list keeps a little bottom breathing room. The only way to
render it empty is a zero-match filter \u2014 a truly empty tree shows the hero state. */.choiceList.qa-empty.svelte-2ry05y:not(.qa-nested) {padding-bottom:0.5rem;}.choiceList.qa-nested.svelte-2ry05y {
/* Own the 2px name->first-row gap so the empty drop band sits the same distance
below the folder name as a populated folder's first row (collapses with the
row's own margin-top, so populated folders look identical). */margin-top:2px;position:relative; /* anchor the ring (::before) */border-radius:var(--radius-m);transition:background-color 120ms ease;}
/* The drop ring is drawn a few px OUTSIDE the content as an absolutely-positioned
::before (adds no layout) \u2014 "synthetically" bigger than the rows so it doesn't
clamp straight against the choice names. The right edge stays at the content edge:
the settings pane is overflow-x:hidden, so extending the ring right would clip it. */.choiceList.qa-nested.svelte-2ry05y::before {content:"";position:absolute;inset:-4px 0 -4px -6px;border-radius:var(--radius-m);border:2px dashed transparent;pointer-events:none;transition:border-color 120ms ease;}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget {background-color:var(--background-modifier-hover);}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget::before {border-color:var(--interactive-accent);}
/* Empty folder: a GENEROUS, STABLE drop target. The band is sized by the folder's
PERSISTED emptiness (qa-folder-empty), NOT the live \`choices\` length \u2014 so when a
dragged item is previewed into the zone (filling \`choices\`, toggling qa-empty off)
the band keeps its height instead of collapsing/expanding under the cursor (the
"jumps all over the place"). Only persisted-empty folders get it, so populated
folders never heave at drag start. */.choiceList.qa-nested.qa-folder-empty.svelte-2ry05y {min-height:3rem;display:flex;align-items:center;}
/* Hint shows only when the folder is persisted-empty AND nothing is previewed in it
(qa-empty = live \`choices\` empty), so it cleanly swaps out for the previewed row
without changing the band's size. */.choiceList.qa-nested.qa-folder-empty.qa-empty.svelte-2ry05y::after {content:"Empty \u2014 add a choice or drag one here.";color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.3;padding-left:8px; /* align with the child rows' own left padding */pointer-events:none;user-select:none;}
@media (prefers-reduced-motion: reduce) {.choiceList.qa-nested.svelte-2ry05y,
.choiceList.qa-nested.svelte-2ry05y::before {transition:none;}
}`};function sg(r,e){we(e,!0),ot(r,Yde);let t=he(e,"choices",31,()=>wt([])),n=he(e,"forceDragDisabled",3,!1),i=he(e,"isEmptyFolder",3,!1),o=he(e,"nested",3,!1),s=N(()=>{let x=new Set;return gn(t()).filter(C=>{if(!Ye(C))return!1;let _=C.id;return typeof _!="string"||_===""||x.has(_)?!1:(x.add(_),!0)})}),a=N(()=>e.rootReorder??e.actions.onReorderChoices),l=0,c=VY.Platform.isMobile,u=Ae(""),d=uk(),f=N(()=>n()||!c&&!d.armed);function p(x){n()||(d.markStarted(),Z(u,x.detail.info.id,!0),t(Ml(x.detail.items)))}function m(x){if(n())return;Z(u,"");let C=Ml(x.detail.items);x.detail.info.trigger===Ai.DROPPED_INTO_ANOTHER&&(C=C.filter(_=>_.id!==x.detail.info.id)),t(C),d.reset(),e.actions.onReorderChoices(t())}let v=()=>{n()||d.startDrag()};function g(x,C){if(n())return;let _=Ml(h(s)),E=_.findIndex(V=>V.id===x.id);if(E===-1)return;let D=E+C;if(D<0||D>=_.length)return;let P=[..._],[H]=P.splice(E,1);P.splice(D,0,H),t(P),e.actions.onReorderChoices(t()),mx(`Moved ${x.name} to position ${D+1} of ${_.length}`)}var y=Gde();let w;ar(y,29,()=>Ml(h(s)),x=>x.id,(x,C)=>{var _=jde(),E=I(_);{var D=H=>{{let V=N(()=>e.roots??t()),oe=N(()=>n()?void 0:()=>g(h(C),-1)),ce=N(()=>n()?void 0:()=>g(h(C),1));X$(H,{get app(){return e.app},get roots(){return h(V)},get dragDisabled(){return h(f)},startDrag:v,get actions(){return e.actions},get choice(){return h(C)},get onMoveUp(){return h(oe)},get onMoveDown(){return h(ce)}})}},P=H=>{{let V=N(()=>e.roots??t()),oe=N(()=>n()?void 0:()=>g(h(C),-1)),ce=N(()=>n()?void 0:()=>g(h(C),1));Z$(H,{get app(){return e.app},get roots(){return h(V)},get dragDisabled(){return h(f)},startDrag:v,get actions(){return e.actions},get collapseId(){return h(u)},get forceDragDisabled(){return n()},get rootReorder(){return h(a)},get choice(){return h(C)},get onMoveUp(){return h(oe)},get onMoveDown(){return h(ce)}})}};ne(E,H=>{h(C).type!=="Multi"?H(D):H(P,-1)})}S(_),XI(_,()=>UY,()=>({duration:l})),$(x,_)}),S(y),Fr(y,(x,C)=>lk?.(x,C),()=>ck({items:h(s),dragDisabled:h(f),flipDurationMs:l,dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),de(()=>w=Ct(y,1,"choiceList svelte-2ry05y",null,w,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":h(s).length===0})),ic("consider",y,p),ic("finalize",y,m),$(r,y),Ce()}var Kde=W('<pre class="qaChoicesUnavailableDetail svelte-1fs8ikt"> </pre>'),Qde=W(`<div class="qaChoicesUnavailable svelte-1fs8ikt"><div class="qaChoicesUnavailableHead svelte-1fs8ikt"><!> <span class="qaChoicesUnavailableTitle svelte-1fs8ikt"> </span></div> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">Something in this vault's QuickAdd settings could not be read. Your choices
have not been changed or deleted, and QuickAdd will not overwrite them.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
copy of that file before editing it.</p> <!></div>`),Xde={hash:"svelte-1fs8ikt",code:".qaChoicesUnavailable.svelte-1fs8ikt {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaChoicesUnavailableHead.svelte-1fs8ikt {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaChoicesUnavailableTitle.svelte-1fs8ikt {font-weight:var(--font-semibold);color:var(--text-normal);}.qaChoicesUnavailableBody.svelte-1fs8ikt {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaChoicesUnavailableDetail.svelte-1fs8ikt {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function ag(r,e){ot(r,Xde);let t=he(e,"what",3,"your choices"),n=he(e,"detail",3,"");var i=Qde(),o=I(i),s=I(o);Rt(s,{iconId:"alert-triangle",size:16});var a=A(s,2),l=I(a);S(a),S(o);var c=A(o,6);{var u=d=>{var f=Kde(),p=I(f,!0);S(f),de(()=>me(p,n())),$(d,f)};ne(c,d=>{n()&&d(u)})}S(i),de(()=>me(l,`QuickAdd couldn't display ${t()??""}`)),$(r,i)}Wt();Wt();var J$=new WeakMap;function qY(r){let e=J$.get(r);if(e)return e;let t=QU(r);return J$.set(r,t),t}function WY(r){return J$.has(r)}Cr();var Zde=W(`<div class="choiceEmptyState svelte-1r4uuo1"><!> <div class="choiceEmptyTitle svelte-1r4uuo1">No choices yet</div> <p class="choiceEmptyBody svelte-1r4uuo1">A choice is an action QuickAdd can run: create a note, capture
text, or run a macro. Group them with folders. <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Learn more</a></p> <div class="choiceEmptyActions svelte-1r4uuo1"><!></div></div>`),Jde=W('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),epe=W('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),tpe=W('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),rpe=W('<div class="choiceFilterBar svelte-1r4uuo1"><div class="search-input-container choiceFilterInput svelte-1r4uuo1"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-1r4uuo1"><!> <!></div>',1),npe=W("<div><!></div>"),ipe={hash:"svelte-1r4uuo1",code:`.choiceViewBottomBar.svelte-1r4uuo1 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
/* AI Assistant as a quiet icon button (matches the per-row action icons),
leading the right cluster so the bar's width barely changes when AI/online
features toggle. */.qaAIAssistantBtn.svelte-1r4uuo1 {flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;color:var(--text-muted);}.qaAIAssistantBtn.svelte-1r4uuo1:hover {color:var(--text-normal);}.choiceEmptyState.svelte-1r4uuo1 {display:flex;flex-direction:column;align-items:center;text-align:center;gap:0.5rem;padding:2.5rem 1rem;color:var(--text-muted);}.choiceEmptyTitle.svelte-1r4uuo1 {font-weight:var(--font-semibold);color:var(--text-normal);}.choiceEmptyBody.svelte-1r4uuo1 {margin:0;max-width:42ch;}.choiceEmptyActions.svelte-1r4uuo1 {margin-top:0.5rem;}.choiceFilterBar.svelte-1r4uuo1 {margin-bottom:8px;}
/* The native container is inline-block by default in some contexts; span
the full row so the filter aligns with the list edges. */.choiceFilterInput.svelte-1r4uuo1 {width:100%;}
/* Obsidian styles .search-input-clear-button (position, the \xD7 glyph, hover)
\u2014 we only reset the <button> chrome so that styling shows through. A real
<button> (Obsidian uses a div) keeps it keyboard-operable. */.qaFilterClearButton.svelte-1r4uuo1 {background:transparent;border:none;box-shadow:none;padding:0;margin:0;cursor:var(--cursor, pointer);}.choiceFilterEmpty.svelte-1r4uuo1 {color:var(--text-faint);font-size:var(--font-ui-small, 13px);padding:12px 8px 16px;}`};function eO(r,e){we(e,!0),ot(r,ipe);let t=he(e,"choices",31,()=>wt([])),n=Ae(""),i=N(()=>!Array.isArray(t())),o=N(()=>`The "choices" value in data.json is ${t()===null?"null":`of type "${typeof t()}"`}, but QuickAdd expects a list.`),s=lg.Platform.isMobile,a=Ae(wt(le.getState().disableOnlineFeatures)),l=new Hk(Ot(()=>e.plugin));function c(j){if(!Array.isArray(j))return j;let Y=WY(j),{choices:K,repaired:se}=qY(j);if(Y)return K;for(let{choice:pe}of se)if(pe.command)try{l.enableCommand(pe)}catch(ge){F.logError(`Could not register a command for the repaired choice "${pe.name}": ${ge instanceof Error?ge.message:String(ge)}`)}return K}t(c(t())),hr(()=>{let j=le.subscribe(Y=>{t(c(Y.choices)),Z(a,Y.disableOnlineFeatures,!0)});return()=>j()});function u(){e.saveChoices(yh(t()))}let d=j=>j.type==="Multi";function f(j,Y){let K=Y.trim();if(!K)return j;let se=(0,lg.prepareFuzzySearch)(K),pe=ge=>{if(!Ye(ge))return null;let be=!!se(ge.name??"");if(!d(ge))return be?ge:null;let xe=st(ge).map(Ue=>pe(Ue)).filter(Boolean);return be||xe.length>0?{...ge,collapsed:!1,choices:xe}:null};return j.map(ge=>pe(ge)).filter(Boolean)}async function p(j,Y,K,se=!1){let pe=OY(Y,t()),ge=q$(Y,pe);if(t(yY(t(),ge,K)),!K&&h(n).trim().length>0&&Z(n,""),Y==="Multi")u(),await C(ge),await m(ge.id);else if(se)u(),await m(ge.id);else{u();try{await w(ge)}catch(be){F.logError(`Failed to configure the new choice: ${be instanceof Error?be.message:String(be)}`),u()}await m(ge.id)}}async function m(j){await Hf();try{document.querySelector(`[data-choice-id="${j}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function v(j){return Ex(t(),j.id)??j}function g(j){return Ye(j)?j.command?!0:st(j).some(g):!1}async function y(j){let Y=v(j);await fY(Y,e.app)&&(t(Tx(t(),j.id).updated),l.disableCommand(Y,{recursive:!0}),u())}async function w(j){let Y=v(j),K=await mY(Y,e.app,e.plugin);K&&(t(t().map(se=>x(se,K))),l.updateCommand(Y,K),u())}function x(j,Y){if(!Ye(j))return j;if(j.id===Y.id)return{...j,...Y};if(Cc(j)){let K=st(j).map(pe=>x(pe,Y));return{...j,choices:K}}return j}async function C(j){if(!j)return;let Y=await E_(e.app,j.name,j.type);if(!Y)return;let K=v(j),se={...K,name:Y};t(t().map(pe=>x(pe,se))),l.updateCommand(K,se),u()}function _(j){let Y=hY(v(j));t(t().map(K=>x(K,Y))),Y.command?l.enableCommand(Y):l.disableCommand(Y),u()}async function E(j){let Y=await dY(v(j),e.app);t(H$(t(),j.id,Y)??[...t(),Y]),g(Y)&&l.enableCommand(Y),u(),new lg.Notice(`Duplicated "${j.name}".`),await m(Y.id)}function D(j,Y){t(Y===Y$?vY(t(),j.id):gY(t(),j.id,Y)),u()}function P(j){t(j),u()}function H(j,Y){t(bY(t(),j,Y)),u()}function V(j){t(G$(t(),j.id,!j.collapsed)),u()}function oe(j,Y){return(K,...se)=>{let pe=km(K?.type),ge=K?.name?`the ${pe} \u201C${K.name}\u201D`:`that ${pe}`;Jf(`Couldn't ${j} ${ge}`,Y)(K,...se)}}let ce={onDeleteChoice:oe("delete",y),onConfigureChoice:oe("open the settings for",w),onToggleCommand:oe("update the command palette entry for",_),onDuplicateChoice:oe("duplicate",E),onRenameChoice:oe("rename",C),onMoveChoice:oe("move",D),onToggleCollapsed:oe("open or close",V),onReorderChoices:Jf("Couldn't save the new order",P),onCommitFolder:Jf("Couldn't save that folder's contents",H),onAddChoice:(j,Y,K,se)=>Jf(`Couldn't add that ${km(Y)}`,p)(j,Y,K,se)},R=Jf("Couldn't open the AI assistant settings",async()=>{let j=await new rS(e.app,le.getState().ai).waitForClose;j&&le.setState(Y=>({...Y,ai:j}))});var O=npe(),q=I(O);{var B=j=>{ag(j,{get detail(){return h(o)}})},ie=j=>{var Y=dn(),K=Pe(Y);yv(K,{onerror:pe=>F.logError(`QuickAdd could not render the choice list: ${pe instanceof Error?pe.message:String(pe)}`),failed:(pe,ge=Vt)=>{{let be=N(()=>ge()instanceof Error?ge().message:String(ge()));ag(pe,{get detail(){return h(be)}})}}},pe=>{var ge=dn(),be=Pe(ge);{var xe=Ne=>{var
/* Keeps "Add variable" right-aligned now that it is the row's only child. */.qa-gv__actions.svelte-hx6w4t {display:flex;justify-content:flex-end;}.qa-gv__desc.svelte-hx6w4t {color:var(--text-muted);font-size:12px;}
/* Mirrors .qa-template-folder-empty, the sibling list's empty state. */.qa-gv__empty.svelte-hx6w4t {color:var(--text-muted);font-size:var(--font-ui-smaller);padding:6px 0;}.qa-gv__table.svelte-hx6w4t {display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t {display:grid;grid-template-columns:180px 1fr 140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t {font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4t input[type="text"]:where(.svelte-hx6w4t) {width:100%;}.qa-gv__cell.svelte-hx6w4t textarea:where(.svelte-hx6w4t) {width:100%;resize:vertical;}.qa-gv__ops.svelte-hx6w4t {display:flex;gap:6px;align-items:center;}.qa-gv__btn.svelte-hx6w4t {padding:4px 8px;}.qa-gv__btn.danger.svelte-hx6w4t {color:var(--text-error);}
@media (max-width: 900px) {.qa-gv__row.svelte-hx6w4t {grid-template-columns:1fr;}.qa-gv__row--head.svelte-hx6w4t {display:none;}
}`};function tO(r,e){we(e,!0),ot(r,cpe);let t=Ae(wt([]));function n(C,_){if(!_.has(C))return C;let E=1;for(;_.has(`${C}${E}`);)E++;return`${C}${E}`}function i(){let _=le.getState().globalVariables||{};Z(t,Object.keys(_).map(E=>({name:E,value:_[E]??""})),!0)}let o=!1;function s(){let C=h(t).map(P=>P.name.trim()),_=C.some(P=>!P),E=new Set(C).size!==C.length;if(_||E)return;let D={};for(let P of h(t))D[P.name.trim()]=P.value??"";o=!0;try{le.setState({globalVariables:D})}finally{o=!1}}function a(){let C=new Set(h(t).map(E=>E.name)),_=n("NewVar",C);Z(t,[...h(t),{name:_,value:""}],!0),s()}function l(C){Z(t,h(t).filter((_,E)=>E!==C),!0),s()}function c(C){return new Hi(e.app,C,e.plugin),{destroy(){}}}let u;function d(C){u!==void 0&&window.clearTimeout(u),u=window.setTimeout(()=>{s()},200)}hr(()=>{let C=le.subscribe(()=>{o||i()});return i(),()=>{u!==void 0&&window.clearTimeout(u),C()}});var f=lpe(),p=A(I(f),2),m=I(p);{var v=C=>{var _=ope();$(C,_)},g=C=>{var _=spe();$(C,_)};ne(m,C=>{h(t).length===0?C(v):C(g,-1)})}var y=A(m,2);ar(y,17,()=>h(t),$v,(C,_,E)=>{var D=ape(),P=I(D),H=I(P);gr(H),Fr(H,O=>c?.(O)),un(()=>uo(H,()=>h(_).name,O=>h(_).name=O)),S(P);var V=A(P,2),oe=I(V);Ad(oe),Fr(oe,O=>c?.(O)),un(()=>uo(oe,()=>h(_).value,O=>h(_).value=O)),S(V);var ce=A(V,2),R=I(ce);S(ce),S(D),De("input",H,()=>{d(h(_))}),De("input",oe,()=>d(h(_))),De("click",R,()=>l(h(t).indexOf(h(_)))),$(C,D)}),S(p);var w=A(p,2),x=I(w);S(w),S(f),De("click",x,a),$(r,f),Ce()}Et(["input","click"]);It();qt();var i4=require("obsidian");var Wa=require("obsidian");Wt();Ii();Kr();var upe=new Set;function nO(r){return r.type==="Multi"}function iO(r){return r.type==="Macro"}function dpe(r){return r.type==="Template"}function ppe(r){return r.type==="Capture"}function aS(r,e,t){return r?e.has(r.id)?t.has(r.id):!0:!1}function zY(r,e,t,n){switch(r.type){case"Choice":{let i=r;if(!t.has(i.choiceId))return!0;let o=e.get(i.choiceId);return o&&aS(o.choice,e,t)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&aS(i.choice,e,t)&&n(i.choice),!0}default:return!1}}function fpe(r){let e=new Map,t=(n,i,o)=>{for(let s of n){if(!Ye(s))continue;let a=[...o,s.name];e.set(s.id,{choice:s,parentId:i,path:a}),nO(s)&&Array.isArray(s.choices)&&t(s.choices,s.id,a)}};return t(gn(r),null,[]),e}function HY(r){let e=new Set;for(let t of st(r))Ye(t)&&e.add(t.id);return iO(r)&&rO(r.macro?.commands,e),e}function rO(r,e){for(let t of Dr(r))if(Si(t))switch(t.type){case"Choice":{let n=t;n.choiceId&&e.add(n.choiceId);break}case"Conditional":{let n=t;rO(n.thenCommands,e),rO(n.elseCommands,e);break}case"NestedChoice":{let i=t.choice;if(!i)break;let o=HY(i);for(let s of o)e.add(s);break}default:break}}function lS(r,e,t){let n=fpe(r),i=new Set,o=new Set,s=t?.excludedChoiceIds??upe,a=e.filter(c=>!s.has(c)),l=[];for(;a.length>0;){let c=a.shift();if(i.has(c))continue;if(s.has(c)){i.add(c);continue}let u=n.get(c);if(!u){o.add(c);continue}i.add(c),l.push(c);let d=HY(u.choice);for(let f of d){if(!n.has(f)){o.add(f);continue}s.has(f)||a.push(f)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function cS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&aS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),nO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);iO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l))if(Si(c)&&!zY(c,r,t,s))switch(c.type){case"UserScript":{let u=c;u.path&&i.add(u.path);break}case"Conditional":{let u=c,d=u.condition;d.mode==="script"&&d.scriptPath&&o.add(d.scriptPath),a(u.thenCommands),a(u.elseCommands);break}default:break}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{userScriptPaths:i,conditionalScriptPaths:o}}function uS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&aS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),dpe(l)&&l.templatePath&&i.add(l.templatePath),ppe(l)&&l.createFileIfItDoesntExist?.enabled&&l.createFileIfItDoesntExist.createWithTemplate&&l.createFileIfItDoesntExist.template&&o.add(l.createFileIfItDoesntExist.template),nO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);iO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l
/* Neutral surface with an amber-tinted border (these are warnings, not
critical danger): ranked, not a blanket-red fill \u2014 matches the import
modal's CapabilityBanner treatment. */.warning.svelte-llmxn2 {border:1px solid var(--qa-sev-warning-border);background:var(--background-secondary);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;color:var(--text-normal);}.warning.svelte-llmxn2 ul:where(.svelte-llmxn2) {margin:0.25rem 0 0 1rem;padding:0;}.assetKind.svelte-llmxn2 {color:var(--text-muted);}.actions.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;}.actionGroup.svelte-llmxn2 {display:flex;flex-direction:column;gap:0.5rem;}.saveRow.svelte-llmxn2 {display:flex;gap:0.5rem;}.saveRow.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.footer.svelte-llmxn2 {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-llmxn2 button.secondary:where(.svelte-llmxn2) {background:transparent;}
@media (max-width: 600px) {.exportPackageModal.svelte-llmxn2 {max-height:90vh;padding-bottom:0.5rem;}.controls.svelte-llmxn2 {flex-direction:column;align-items:stretch;gap:0.5rem;}.controlButtons.svelte-llmxn2 {width:100%;flex-direction:column;gap:0.5rem;align-items:stretch;}.controlButtons.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.choiceList.svelte-llmxn2 {min-height:160px;max-height:40vh;}.summaryGrid.svelte-llmxn2 {grid-template-columns:1fr;}.actions.svelte-llmxn2 {gap:0.75rem;}.actionGroup.svelte-llmxn2 {align-items:stretch;}.actionGroup.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.saveRow.svelte-llmxn2 {flex-direction:column;}.saveRow.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.footer.svelte-llmxn2 {flex-direction:column-reverse;align-items:stretch;}.footer.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}
}`};function oO(r,e){we(e,!0),ot(r,Ppe);let t={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ae(""),i=Ae(wt(new Set)),o=Ae(wt(new Set)),s=Ae(wt(e4())),a=Ae(null),l=Ae(null),c=N(()=>dy(e.allChoices)),u=N(()=>v(h(c),h(n))),d=N(()=>_(h(c),h(i))),f=N(()=>E(e.allChoices,h(d),h(o))),p=N(()=>new Map(h(c).map(k=>[k.id,k.path.join(" / ")])));function m(k){return k.type==="Multi"}function v(k,L){let Q=L.trim().toLowerCase();return Q?k.filter(J=>`${J.path.join(" ")} ${J.choice.type}`.toLowerCase().includes(Q)):k}function g(k){let L=[];for(let Q of st(k))Ye(Q)&&L.push(Q.id,...g(Q));return L}function y(k,L){let Q=[k.id,...g(k)];if(L){let J=new Set(h(i));for(let ue of Q)J.add(ue);if(Z(i,J,!0),h(o).size>0){let ue=new Set(h(o));for(let ve of Q)ue.delete(ve);Z(o,ue,!0)}}else{let J=new Set(h(i));for(let ve of Q)J.delete(ve);Z(i,J,!0);let ue=new Set(h(o));for(let ve of Q)ue.add(ve);Z(o,ue,!0)}}function w(k){let L=h(c).find(J=>J.id===k);if(!L)return;let Q=h(i).has(k);y(L.choice,!Q),Z(a,null)}function x(){for(let k of h(u))y(k.choice,!0);Z(a,null)}function C(){Z(i,new Set,!0),Z(o,new Set,!0),Z(a,null)}function _(k,L){let Q=[];for(let J of k)L.has(J.id)&&(!J.parentId||!L.has(J.parentId))&&Q.push(J.id);return Q}function E(k,L,Q){if(L.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};let J=lS(k,L,{excludedChoiceIds:Q}),ue=cS(J.catalog,J.choiceIds),ve=uS(J.catalog,J.choiceIds);return{rootCount:L.length,totalChoices:J.choiceIds.length,dependencyCount:Math.max(J.choiceIds.length-L.length,0),missingChoiceIds:J.missingChoiceIds,userScripts:ue.userScriptPaths.size,conditionalScripts:ue.conditionalScriptPaths.size,templateFiles:ve.templatePaths.size,captureTemplates:ve.captureTemplatePaths.size}}function D(k){let{missingChoiceIds:L,missingAssets:Q}=k;return L.length===0&&Q.length===0?null:{missingChoices:L,missingAssets:Q}}async function P(){if(h(d).length===0)return new Wa.Notice("Select at least one choice to export."),null;try{let k=await t4(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});return Z(a,D(k),!0),k}catch(k){return console.error(k),Z(a,null),new Wa.Notice(`Export failed: ${k?.message??String(k)}`),null}}async function H(){if(!h(l)){Z(l,"copy");try{let k=await P();if(!k)return;let L=JSON.stringify(k.pkg,null,2);await oe(L),new Wa.Notice(`Copied package (${k.pkg.choices.length} choice${k.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?new Wa.Notice("Package copied with warnings. Review details below."):e.close()}catch(k){console.error(k),new Wa.Notice(`Copy failed: ${k?.message??String(k)}`)}finally{Z(l,null)}}}async function V(){if(h(l))return;let k=h(s).trim();if(!k){new Wa.Notice("Enter a file path before saving.");return}Z(l,"save");try{let L=await P();if(!L)return;let{overwritten:Q}=await n4(e.app,L.pkg,k),J=L.pkg.choices.length,ue=`${J} choice${J===1?"":"s"}`;new Wa.Notice(Q?`Overwrote package (${ue}) at '${k}'.`:`Saved package (${ue}) to '${k}'.`),h(a)?new Wa.Notice("Package saved with warnings. Review details below."):e.close()}catch(L){let Q=L?.message??String(L);if(Q.startsWith("Save cancelled:")){new Wa.Notice("Save cancelled.");return}console.error(L),new Wa.Notice(`Save failed: ${Q}`)}finally{Z(l,null)}}async function oe(k){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(k);return}let L=document.createElement("textarea");L.value=k,L.setAttribute("readonly","true"),L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.focus(),L.select();let Q=document.execCommand("copy");if(document.body.removeChild(L),!Q)throw new Error("Clipboard copy is not supported in this environment.")}var ce=Ipe(),R=A(I(ce),2),O=I(R);gr(O),ke(O,"spellcheck",!1);var q=A(O,2),B=I(q),ie=A(B,2);S(q),S(R);var j=A(R,2),Y=I(j);{var K=k=>{var L=Cpe();$(k,L)},se=k=>{var L=Tpe();ar(L,21,()=>h(u),Q=>Q.id,(Q,J)=>{var ue=Epe(),ve=I(ue),Ve=I(ve);gr(
${ue??""}`),[()=>h(f).missingChoiceIds.join(", ")]),$(k,L)};ne(yr,k=>{h(f).missingChoiceIds.length>0&&k(Pt)})}S(pe);var Ar=A(pe,2);{var ur=k=>{var L=Dpe(),Q=A(I(L),2);{var J=Ve=>{var yt=Ape(),Pr=I(yt);S(yt),de(jt=>me(Pr,`Missing choices:
${jt??""}`),[()=>h(a).missingChoices.map(jt=>h(p).get(jt)??jt).join(", ")]),$(Ve,yt)};ne(Q,Ve=>{h(a).missingChoices.length>0&&Ve(J)})}var ue=A(Q,2);{var ve=Ve=>{var yt=Spe(),Pr=A(I(yt),2);ar(Pr,21,()=>h(a).missingAssets,jt=>jt.path,(jt,$i)=>{var bt=kpe(),pr=I(bt),kr=A(pr),Yn=I(kr);S(kr),S(bt),de(()=>{me(pr,`${h($i).path??""} `),me(Yn,`(${t[h($i).kind]??""})`)}),$(jt,bt)}),S(Pr),S(yt),$(Ve,yt)};ne(ue,Ve=>{h(a).missingAssets.length>0&&Ve(ve)})}S(L),$(k,L)};ne(Ar,k=>{h(a)&&k(ur)})}var dt=A(Ar,2),Ft=I(dt),jn=I(Ft),xo=I(jn);{var Es=k=>{var L=ul("Copying\u2026");$(k,L)},Gn=k=>{var L=ul("Copy JSON");$(k,L)};ne(xo,k=>{h(l)==="copy"?k(Es):k(Gn,-1)})}S(jn),S(Ft);var re=A(Ft,2),Ie=I(re),dr=A(I(Ie),2),br=I(dr);gr(br);var _n=A(br,2),Ho=I(_n);{var Qa=k=>{var L=ul("Saving\u2026");$(k,L)},Xa=k=>{var L=ul("Save to file");$(k,L)};ne(Ho,k=>{h(l)==="save"?k(Qa):k(Xa,-1)})}S(_n),S(dr),S(Ie),S(re),S(dt);var Jc=A(dt,2),T=I(Jc);S(Jc),S(ce),de(()=>{me(Ue,h(f).rootCount),me(Ke,h(f).totalChoices),me(We,h(f).dependencyCount),me(_e,h(f).userScripts+h(f).conditionalScripts),me(or,h(f).templateFiles+h(f).captureTemplates),jn.disabled=h(l)!==null,_n.disabled=h(l)!==null,T.disabled=h(l)!==null}),uo(O,()=>h(n),k=>Z(n,k)),De("click",B,x),De("click",ie,C),De("click",jn,H),uo(br,()=>h(s),k=>Z(s,k)),De("click",_n,V),De("click",T,function(...k){e.close?.apply(this,k)}),$(r,ce),Ce()}Et(["click","change"]);var mS=class extends i4.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=qi(this.contentEl,oO,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var R4=require("obsidian");var Mx=require("obsidian");It();qt();var CS=require("obsidian");hl();Wt();Ii();Kr();Kr();Kr();Wt();Ii();function Fpe(r){return r.type==="Multi"}function Mpe(r){return r.type==="Macro"}function sO(r,e,t){if(!(!r||typeof r!="object")){if(Array.isArray(r)){e.onUnreadable?.();return}if(!t.has(r)){if(t.add(r),e.onChoice?.(r),Fpe(r))if(Array.isArray(r.choices))for(let n of r.choices)sO(n,e,t);else l_(r.choices)&&e.onUnreadable?.();Mpe(r)&&hS(zn(r.macro),e,t)}}}function hS(r,e,t){if(!Array.isArray(r)){Di(r)&&e.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){e.onUnreadable?.();continue}e.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(hS(i.thenCommands,e,t),hS(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&sO(a,e,t)}}function aO(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)sO(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)hS(zn(i),e,t);else Di(n)&&e.onUnreadable?.()}function cg(r){let e=!1;return aO(r,{onUnreadable:()=>{e=!0}}),e}function ug(r,e){aO(r.settings,{onChoice:e})}function gS(r,e){aO(r,{onCommand:e})}function Rpe(r){return r.type==="AIAssistant"}function vS(r,e,t){let n=0;return gS({choices:r},i=>{if(!Rpe(i)||i.modelRef&&i.modelRef.name===i.model&&e.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=e.find(a=>a.models.some(l=>l.name===i.model));if(!o?.id)return;let s={providerId:o.id,name:i.model};i.modelRef=s,n++,t?.(i,s)}),n}Me();yi();cO();xc();Bc();Kr();Wt();Ii();Zv();Tt();var dO={"user-script":{severity:"critical",label:"SCRIPT",description:"Runs custom JavaScript with full access to your vault and the network."},"conditional-script":{severity:"critical",label:"CONDITIONAL",description:"Runs custom JavaScript to decide which branch executes."},"bundled-script":{severity:"critical",label:"SCRIPT FILE",description:"Bundles a file that will be written to your vault and can be run as code."},"run-on-startup":{severity:"critical",label:"STARTUP",description:"Runs automatically every time Obsidian starts."},"mislabeled-executable":{severity:"critical",label:"EXECUTABLE"
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);let i=r.length/t;return e>1e3||i>250}function wS(r,e){let t=r.assets.find(n=>n.originalPath===e);if(!t)return{found:!1,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:"File is not bundled in this package."};try{let n=Vc(t.content),i=n.length>s4,o=i?n.slice(0,s4):n;return{found:!0,text:o,truncated:i,sizeBytes:Xpe(n),looksMinified:Zpe(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function f4(r){return r.summary.hasCritical}function m4(r,e){return r.criticalScriptPaths.every(t=>e.has(t))}async function h4(r,e){if(Vn(e))throw new Error(`Refusing to read a package outside the vault: "${e}".`);let t=(0,CS.normalizePath)(e.trim());if(!t)throw new Error("Package path cannot be empty.");if(!await r.vault.adapter.exists(t))throw new Error(`Package file not found: ${t}`);let i=await r.vault.adapter.read(t);return{pkg:vO(i),path:t}}function vO(r){let e;try{e=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!GY(e))throw new Error("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)throw new Error(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);let t=Jpe(e.assets);if(t!==null)throw new Error(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);let n=efe(e.choices);if(n!==null)throw new Error(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);let i=tfe(e.choices);if(i!==null)throw new Error(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);return e}function Jpe(r){let e=new Set;for(let t of r){let n=(0,CS.normalizePath)(t.originalPath??"");if(e.has(n))return t.originalPath;e.add(n)}return null}function efe(r){let e=new Map,t=null,n=i=>{if(t!==null||!i||typeof i!="object")return;let o=i.id;if(typeof o=="string"){let s=mO(i),a=e.get(o);if(a===void 0)e.set(o,s);else if(a!==s){t=o;return}}if(i.type==="Multi"){let s=i;if(Array.isArray(s.choices))for(let a of s.choices)n(a)}i.type==="Macro"&&fO(i.macro?.commands,n)};for(let i of r){if(t!==null)break;n(i?.choice)}return t}function fO(r,e){if(Array.isArray(r)){for(let t of r)if(t){if(t.type==="NestedChoice")e(t.choice);else if(t.type==="Conditional"){let n=t;fO(n.thenCommands,e),fO(n.elseCommands,e)}}}}function mO(r){if(r===null||typeof r!="object"){let n=JSON.stringify(r);return n===void 0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(mO).join(",")}]`;let e=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${mO(e[n])}`).join(",")}}`}function tfe(r){let e=new Map(r.map(t=>[t.choice.id,t]));for(let t of r){let n=t.parentChoiceId;if(n===null)continue;let i=e.get(n);if(!i)continue;let o=i.choice;if(!st(o).some(a=>a?.id===t.choice.id))return t.choice.id}return null}async function g4(r,e,t){let n=new Map(Un(e).map(s=>[s.id,s])),i=t.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(let s of t.assets){let a=Vn(s.originalPath)?!1:await r.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}async function xS(r,e,t){let n=new Set([...t.assets.map(a=>a.originalPath),...d4(t)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Vn(a)||await y4(r,a)&&i.add(a))}));let o=p4(e,t,i),{summary:s}=o;return F.logMessage(`QuickAdd import preview: choices=${o.choiceCount} files=${o.fileCount} scripts=${s.scriptCount} runOnStartup=${s.runsOnStartup} registersCommands=${s.registersCommandCount} overwritesChoices=${s.overwritesChoices} overwritesFiles=${s.overwritesFiles} missing=${s.missingCount} critical=${s.criticalCount} warning=${s.warningCount}`),o}function rfe(r){let t=(r??"").trim();if(!t)throw new Error("Package asset has an empty destination path.");let n=t.replace(/\\/g,"/");if(n.startsWith("/"
/* Critical: darkened red so white text clears WCAG AA (~5:1) at this size,
where Obsidian's stock --color-red (#e93147) lands at ~3.5:1. */.qa-import-tag.critical.svelte-5jkd35 {background:var(--qa-sev-critical-pill);color:#fff;}
/* Warning: amber is medium-luminance in both themes, so near-black text
(~8:1) beats white-on-amber (~2.9:1). Fallback #ff8c00 matches styles.css
and clears AA (~5.9:1) with #1a1a1a. */.qa-import-tag.warning.svelte-5jkd35 {background:var(--color-orange, #ff8c00);color:#1a1a1a;}.qa-import-tag.info.svelte-5jkd35 {background:var(--background-modifier-border);color:var(--text-normal);}`};function Fx(r,e){we(e,!0),ot(r,afe);let t=N(()=>yS(e.flag)),n=N(()=>a4(e.flag)),i=N(()=>l4(e.flag));var o=sfe();let s;var a=I(o,!0);S(o),Fr(o,(l,c)=>Px?.(l,c),()=>h(i)),de(()=>{s=Ct(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),me(a,h(n))}),$(r,o),Ce()}var lfe=W('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),cfe=W('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),ufe=W('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),dfe=W('<section aria-label="What this package can do"><div class="qa-import-banner-head svelte-tb9yz"><span class="qa-import-banner-icon svelte-tb9yz"><!></span> <h3 class="svelte-tb9yz">What this package can do</h3></div> <ul class="qa-import-banner-rows svelte-tb9yz"></ul> <!></section>'),pfe={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz {background:var(--background-secondary);border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.85rem;display:flex;flex-direction:column;gap:0.5rem;}
/* Critical packages get a red-tinted hairline + red icon, not a blanket-red
fill: severity stays ranked and all text keeps its contrast on the neutral
surface. (A solid colored side-stripe would be the banned pattern.) */.qa-import-banner.critical.svelte-tb9yz {border-color:var(--qa-sev-critical-border);}.qa-import-banner-head.svelte-tb9yz {display:flex;align-items:center;gap:0.5rem;}.qa-import-banner-icon.svelte-tb9yz {display:inline-flex;color:var(--text-warning, var(--text-muted));}.qa-import-banner.critical.svelte-tb9yz .qa-import-banner-icon:where(.svelte-tb9yz) {color:var(--text-error);}.qa-import-banner-head.svelte-tb9yz h3:where(.svelte-tb9yz) {margin:0;font-size:1rem;}.qa-import-banner-rows.svelte-tb9yz {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}
/* The pill is an inline lead-in to the sentence (not a fixed left column),
so long titles wrap full-width under it instead of leaving a dead column
of whitespace beside a one-line pill. */.qa-import-banner-rows.svelte-tb9yz li:where(.svelte-tb9yz) {display:block;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);}.qa-import-banner-tag.svelte-tb9yz {display:inline-block;vertical-align:middle;margin:0 0.4rem 0.15rem 0;}
/* Faint per-row severity wash so critical rows read hottest while warnings
recede, without saturating the whole banner. Composited over the banner
surface (not transparent) so the tint is a solid, predictable colour. */.qa-import-banner-rows.svelte-tb9yz li.sev-critical:where(.svelte-tb9yz) {background:var(--qa-sev-critical-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-warning:where(.svelte-tb9yz) {background:var(--qa-sev-warning-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-info:where(.svelte-tb9yz) {background:var(--qa-sev-info-wash);}.qa-import-banner-title.svelte-tb9yz {line-height:1.4;}.qa-import-banner-detail.svelte-tb9yz {display:block;margin-top:0.15rem;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-banner-note.svelte-tb9yz {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}`};function wO(r,e){we(e,!0),ot(r,pfe);let t=N(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=dfe();let i;var o=I(n),s=I(o),a=I(s);Rt(a,{iconId:"alert-triangle",size:17}),S(s),Pn(2),S(o);var l=A(o,2);ar(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,f)=>{var p=cfe();let m;var v=I(p),g=I(v);Fx(g,{get flag(){return h(f).flag}}),S(v);var y=A(v),w=I(y,!0);S(y);var x=A(y,2);{var C=_=>{var E=lfe(),D=I(E,!0);S(E),de(()=>me(D,h(f).detail)),$(_,E)};ne(x,_=>{h(f).detail&&_(C)})}S(p),de(()=>{m=Ct(p,1,"svelte-tb9yz",null,m,{"sev-critical":h(f).severity==="critical","sev-warning":h(f).severity==="warning","sev-info":h(f).severity==="info"}),me(w,h(f).title)}),$(d,p)}),S(l);var c=A(l,2);{var u=d=>{var f=ufe();$(d,f)};ne(c,d=>{h(t)&&d(u)})}S(n),de(()=>i=Ct(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),$(r,n),Ce()}var ffe=W('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),mfe=W('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),hfe=W('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),gfe=W("<option>Overwrite</option>"),vfe=W(`<p class="qa-import-file-skip-warn svelte-lmqem5" role="note">Won't be written. Any choice that uses this script will run whatever
file already exists at this path after import, not the contents you
reviewed.</p>`),yfe=W('<p class="qa-import-file-error svelte-lmqem5"> </p>'),bfe=W(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
only if you trust the source.</p>`),wfe=W('<p class="qa-import-file-warn svelte-lmqem5"> </p>'),Cfe=W('<!> <pre class="qa-import-file-code svelte-lmqem5" tabindex="0" role="region"> </pre> <!>',1),xfe=W('<div class="qa-import-file-preview svelte-lmqem5"><!></div>'),Efe=W('<div><div class="qa-import-file-head svelte-lmqem5"><!> <span> </span> <span class="qa-import-file-arrow svelte-lmqem5" aria-hidden="true">\u2192</span> <span class="qa-import-file-dest svelte-lmqem5"> </span></div> <div class="qa-import-file-badges svelte-lmqem5"><!> <!> <!> <span class="qa-import-file-size svelte-lmqem5"> </span></div> <div class="qa-import-file-fields svelte-lmqem5"><label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Destination</span> <input type="text" placeholder="vault/path/to/file" class="svelte-lmqem5"/></label> <label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Action</span> <select class="dropdown svelte-lmqem5"><option>Write</option><!><option>Skip</option></select></label></div> <!> <button type="button" class="qa-import-file-toggle svelte-lmqem5"><span><!></span> <span> </span></button> <div><div class="qa-import-file-preview-inner svelte-lmqem5"><!></div></div></div>'),Tfe={hash:"svelte-lmqem5",code:`.qa-import-file.svelte-lmqem5 {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;display:flex;flex-direction:column;gap:0.5rem;background:var(--background-secondary);}.qa-import-file.overwrite.svelte-lmqem5 {border-color:var(--qa-sev-critical-border);}.qa-import-file-head.svelte-lmqem5 {display:flex;align-items:center;gap:0.4rem;flex-wrap:wrap;}.qa-import-file-status.svelte-lmqem5 {font-size:0.78rem;font-weight:700;letter-spacing:0.01em;color:var(--text-muted);}.qa-import-file-status.overwrite.svelte-lmqem5 {color:var(--text-error);}.qa-import-file-arrow.svelte-lmqem5 {color:var(--text-muted);}.qa-import-file-dest.svelte-lmqem5 {font-family:var(--font-monospace);font-size:0.85rem;overflow-wrap:anywhere;}.qa-import-file-badges.svelte-lmqem5 {display:flex;flex-wrap:wrap;gap:0.35rem;align-items:center;}.qa-import-file-orphan.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;background:var(--background-modifier-hover);
/* --text-normal (not --text-muted) so the badge clears AA on the hover
surface in dark themes too. */color:var(--text-normal);cursor:help;}.qa-import-file-exec.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;font-weight:700;letter-spacing:0.02em;text-transform:uppercase;background:var(--qa-sev-critical-pill);color:#fff;cursor:help;}.qa-import-file-reviewed.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.15rem;font-size:0.72rem;color:var(--text-success, var(--color-green, #0aa344));}.qa-import-file-size.svelte-lmqem5 {font-size:0.72rem;color:var(--text-faint);margin-left:auto;}
/* Obsidian Setting-row geometry: field name on the left at --text-normal,
control docked right at its native height \u2014 not a stacked label-above
form field (which read as non-native). */.qa-import-file-fields.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;}.qa-import-file-field.svelte-lmqem5 {display:flex;align-items:center;gap:1rem;}.qa-import-file-field-name.svelte-lmqem5 {flex:1 1 auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5) {flex:0 1 300px;min-width:0;}.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:0 0 auto;}
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5):disabled {opacity:0.5;cursor:not-allowed;}.qa-import-file-toggle.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.3rem;align-self:flex-start;background:transparent;border:none;box-shadow:none;padding:0.1rem 0.2rem;margin-left:-0.2rem;cursor:pointer;color:var(--text-accent);font-size:0.85rem;border-radius:var(--radius-s, 4px);}.qa-import-file-toggle.svelte-lmqem5:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.qa-import-file-toggle.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5 {display:inline-flex;transition:transform 180ms ease;}.qa-import-file-chevron.open.svelte-lmqem5 {transform:rotate(90deg);}.qa-import-file-preview-wrap.svelte-lmqem5 {display:grid;grid-template-rows:0fr;transition:grid-template-rows 200ms ease;}.qa-import-file-preview-wrap.open.svelte-lmqem5 {grid-template-rows:1fr;}.qa-import-file-preview-inner.svelte-lmqem5 {overflow:hidden;min-height:0;}.qa-import-file-preview.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;padding-top:0.2rem;}.qa-import-file-warn.svelte-lmqem5 {margin:0;color:var(--text-warning, var(--text-muted));font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-skip-warn.svelte-lmqem5 {margin:0;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-warning-wash);color:var(--text-normal);font-size:var(--font-ui-smaller, 0.85rem);line-height:1.4;}.qa-import-file-error.svelte-lmqem5 {margin:0;color:var(--text-error);font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-code.svelte-lmqem5 {margin:0;max-height:240px;overflow:auto;padding:0.5rem 0.6rem;border-radius:var(--radius-s, 4px);background:var(--background-modifier-form-field);border:1px solid var(--background-modifier-border);font-family:var(--font-monospace);font-size:0.8rem;line-height:1.5;white-space:pre;tab-size:4;}.qa-import-file-code.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}
@media (max-width: 600px) {
/* Stack control under its name and let it use the full width on narrow
screens, where a right-docked control would be cramped. */.qa-import-file-field.svelte-lmqem5 {flex-wrap:wrap;gap:0.25rem;}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5),
.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:1 1 100%;}.qa-import-file-size.svelte-lmqem5 {margin-left:0;}
}.is-mobile .qa-import-file-toggle.svelte-lmqem5 {min-height:36px;padding:0.4rem 0.3rem;}
@media (prefers-reduced-motion: reduce) {.qa-import-file-chevron.svelte-lmqem5,
.qa-import-file-preview-wrap.svelte-lmqem5 {transition:none;}
}`};function TS(r,e){we(e,!0),ot(r,Tfe);let t=he(e,"reviewed",3,!1),n=Ae(!1),i=N(()=>h(n)?wS(e.pkg,e.file.originalPath):null),o=N(()=>`qa-file-preview-${e.file.originalPath.replace(/[^a-zA-Z0-9_-]/g,"-")}`);function s(_e){return _e<1024?`${_e} B`:_e<1024*1024?`${(_e/1024).toFixed(1)} KB`:`${(_e/(1024*1024)).toFixed(1)} MB`}function a(){Z(n,!h(n)),h(n)&&e.file.requiresReview&&e.onReviewed(e.file.originalPath)}function l(_e){e.onPathInput(_e.currentTarget.value)}function c(_e){e.onModeChange(_e.currentTarget.value)}var u=Efe();let d;var f=I(u),p=I(f);{let _e=N(()=>e.destinationExists?"file-warning":"file-plus");Rt(p,{get iconId(){return h(_e)},size:16})}var m=A(p,2);let v;var g=I(m,!0);S(m);var y=A(m,4),w=I(y,!0);S(y),S(f);var x=A(f,2),C=I(x);{var _=_e=>{var Be=ffe();Fr(Be,(ut,or)=>Px?.(ut,or),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),$(_e,Be)};ne(C,_e=>{e.file.executable&&_e(_)})}var E=A(C,2);{var D=_e=>{var Be=mfe(),ut=I(Be);Rt(ut,{iconId:"check",size:12}),Pn(),S(Be),$(_e,Be)};ne(E,_e=>{t()&&e.mode!=="skip"&&e.file.requiresReview&&_e(D)})}var P=A(E,2);{var H=_e=>{var Be=hfe();Fr(Be,(ut,or)=>Px?.(ut,or),()=>"Bundled in this package but not referenced by any choice."),$(_e,Be)};ne(P,_e=>{e.file.orphan&&_e(H)})}var V=A(P,2),oe=I(V,!0);S(V),S(x);var ce=A(x,2),R=I(ce),O=A(I(R),2);gr(O),S(R);var q=A(R,2),B=A(I(q),2),ie=I(B);ie.value=ie.__value="write";var j=A(ie);{var Y=_e=>{var Be=gfe();Be.value=Be.__value="overwrite",$(_e,Be)};ne(j,_e=>{e.destinationExists&&_e(Y)})}var K=A(j);K.value=K.__value="skip",S(B);var se;Vd(B),S(q),S(ce);var pe=A(ce,2);{var ge=_e=>{var Be=vfe();$(_e,Be)};ne(pe,_e=>{e.file.requiresReview&&e.mode==="skip"&&_e(ge)})}var be=A(pe,2),xe=I(be);let Ue;var $t=I(xe);Rt($t,{iconId:"chevron-right",size:14}),S(xe);var Ne=A(xe,2),Ke=I(Ne,!0);S(Ne),S(be);var Xe=A(be,2);let ye;var We=I(Xe),ht=I(We);{var He=_e=>{var Be=xfe(),ut=I(Be);{var or=Pt=>{var Ar=yfe(),ur=I(Ar);S(Ar),de(()=>me(ur,`Preview unavailable: ${h(i).error??""}`)),$(Pt,Ar)},yr=Pt=>{var Ar=Cfe(),ur=Pe(Ar);{var dt=Gn=>{var re=bfe();$(Gn,re)};ne(ur,Gn=>{h(i).looksMinified&&Gn(dt)})}var Ft=A(ur,2),jn=I(Ft,!0);S(Ft);var xo=A(Ft,2);{var Es=Gn=>{var re=wfe(),Ie=I(re);S(re),de(()=>me(Ie,`Preview truncated. The full ${e.file.executable?"script will run":"file will be imported"}.`)),$(Gn,re)};ne(xo,Gn=>{h(i).truncated&&Gn(Es)})}de(()=>{ke(Ft,"aria-label",`Contents of ${e.file.originalPath??""}`),me(jn,h(i).text)}),$(Pt,Ar)};ne(ut,Pt=>{h(i).error?Pt(or):Pt(yr,-1)})}S(Be),$(_e,Be)};ne(ht,_e=>{h(i)&&_e(He)})}S(We),S(Xe),S(u),de(_e=>{d=Ct(u,1,"qa-import-file svelte-lmqem5",null,d,{overwrite:e.destinationExists}),v=Ct(m,1,"qa-import-file-status svelte-lmqem5",null,v,{overwrite:e.destinationExists}),me(g,e.destinationExists?"Will overwrite":"New file"),me(w,e.destinationPath),me(oe,_e),Fs(O,e.destinationPath),O.disabled=e.mode==="skip",se!==(se=e.mode)&&(B.value=(B.__value=e.mode)??"",fu(B,e.mode)),ke(be,"aria-expanded",h(n)),ke(be,"aria-controls",h(o)),Ue=Ct(xe,1,"qa-import-file-chevron svelte-lmqem5",null,Ue,{open:h(n)}),me(Ke,h(n)?"Hide contents":"View contents"),ye=Ct(Xe,1,"qa-import-file-preview-wrap svelte-lmqem5",null,ye,{open:h(n)}),ke(Xe,"id",h(o))},[()=>s(e.file.sizeBytes)]),De("input",O,l),De("change",B,c),De("click",be,a),$(r,u),Ce()}Et(["input","change","click"]);var _fe=W('<span class="macroCommandType svelte-1qj0pve"> </span>'),Afe=W("<code> </code>"),kfe=W('<span class="macroCommandSummary svelte-1qj0pve"> </span>'),Sfe=W('<li class="svelte-1qj0pve"><span class="macroCommandName svelte-1qj0pve"> </span> <!> <!></li>'),Dfe=W('<ul class="macroCommands svelte-1qj0pve"></ul>'),Ife={hash:"svelte-1qj0pve",code:".macroCommands.svelte-1qj0pve {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.macroCommands.svelte-1qj0pve li:where(.svelte-1qj0pve) {display:flex;flex-wrap:wrap;align-items:center;gap:0.4rem;font-size:var(--font-ui-smaller, 0.85rem);}.macroCommandName.svelte-1qj0pve {font-weight:500;}.macroCommandType.svelte-1qj0pve {color:var(--text-mute
used by any choice</li>`),Gfe=W('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Unreferenced files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),Yfe=W('<section class="warningsBand svelte-1nd6fqb"><!> <!></section>'),Kfe=W('<section class="filesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Files</h3> <!></section> <!>',1),Qfe=W('<section class="summary svelte-1nd6fqb"><!> <span class="svelte-1nd6fqb"> </span></section>'),Xfe=W('<section class="packageMeta svelte-1nd6fqb"><span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Version</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Created</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span></section> <!> <section class="choicesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Choices</h3> <!></section> <!> <!>',1),Zfe=W('<p id="qa-import-ack-hint" class="ackGate-hint svelte-1nd6fqb"> </p>'),Jfe=W('<section><label class="ackGate-label svelte-1nd6fqb"><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-1nd6fqb"/> <span class="svelte-1nd6fqb"> </span></label> <!></section>'),eme=W('<div class="importPackageModal svelte-1nd6fqb"><header class="svelte-1nd6fqb"><h2 class="svelte-1nd6fqb">Import QuickAdd package</h2> <p class="svelte-1nd6fqb">Review what this package adds and runs before importing.</p></header> <section class="pasteSection svelte-1nd6fqb"><label class="svelte-1nd6fqb"><span class="svelte-1nd6fqb">Paste package JSON</span> <textarea placeholder="Paste the contents of a .quickadd.json package here" rows="8" class="svelte-1nd6fqb"></textarea></label> <!></section> <!> <!> <section class="footer svelte-1nd6fqb"><button type="button" class="secondary svelte-1nd6fqb">Cancel</button> <button type="button" class="primary svelte-1nd6fqb"><!></button></section></div>'),tme={hash:"svelte-1nd6fqb",code:`.importPackageModal.svelte-1nd6fqb {display:flex;flex-direction:column;gap:1rem;width:min(720px, 100%);max-height:80vh;overflow-y:auto;
/* overflow-x:hidden (paired with overflow-y:auto) clips child focus rings
at the flush left/right edges; the inline padding gives the ring room. */overflow-x:hidden;box-sizing:border-box;padding:2px 4px;}.importPackageModal.svelte-1nd6fqb :where(.svelte-1nd6fqb) {box-sizing:border-box;}.importPackageModal.svelte-1nd6fqb > section:where(.svelte-1nd6fqb) {max-width:100%;}.pasteSection.svelte-1nd6fqb label:where(.svelte-1nd6fqb) {display:flex;flex-direction:column;gap:0.5rem;}.pasteSection.svelte-1nd6fqb textarea:where(.svelte-1nd6fqb) {width:100%;font-family:var(--font-monospace);resize:vertical;}.errorMessage.svelte-1nd6fqb {color:var(--text-error);}.info.svelte-1nd6fqb {color:var(--text-muted);}
/* A single compact line that sizes to content and wraps naturally, instead
of a 4-equal-column grid where the date wraps to 3 lines and the rest
leave dead space. */.packageMeta.svelte-1nd6fqb {display:flex;flex-wrap:wrap;align-items:baseline;gap:0.3rem 0.6rem;padding:0.55rem 0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);width:100%;font-size:var(--font-ui-small, 0.9rem);overflow-wrap:anywhere;}.metaLabel.svelte-1nd6fqb {color:var(--text-muted);}.metaSep.svelte-1nd6fqb {color:var(--text-faint);}.choicesSection.svelte-1nd6fqb,
.filesSection.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.75rem;}.filesGroupHeading.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-small, 0.9rem);font-weight:600;color:var(--text-muted);}.filesGroupHeading.overwrite.svelte-1nd6fqb {color:var(--text-error);}.fileRows.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.5rem;}.choiceName.svelte-1nd6fqb {font-weight:500;}
/* A plain inline text link, not a chrome button: neutralise Obsidian's
default button background/shadow on every state (!important to win over
the global button:hover / :focus rules that paint the grey box). */.macroToggle.svelte-1nd6fqb {display:inline-block;margin-top:0.35rem;padding:0;background:transparent !important;border:none;box-shadow:none !important;color:var(--text-accent);cursor:pointer;font-size:var(--font-ui-smaller, 0.8rem);border-radius:var(--radius-s, 4px);}.macroToggle.svelte-1nd6fqb:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-1nd6fqb:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {background:var(--background-primary-alt, var(--background-secondary));}.warningsBand.svelte-1nd6fqb {display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;gap:0.5rem;}.warnItem.svelte-1nd6fqb h4:where(.svelte-1nd6fqb) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-1nd6fqb ul:where(.svelte-1nd6fqb) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-1nd6fqb li:where(.svelte-1nd6fqb) {overflow-wrap:anywhere;}
/* A missing SCRIPT reference is an execution-hijack risk, not a broken
link: it runs from whatever exists at that path. Mark it as critical. */.warnItem.svelte-1nd6fqb li.script:where(.svelte-1nd6fqb) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-1nd6fqb {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-1nd6fqb col.colName:where(.svelte-1nd6fqb) {width:52%;}.choicesSection.svelte-1nd6fqb col.colLocation:where(.svelte-1nd6fqb) {width:26%;}.choicesSection.svelte-1nd6fqb col.colAction:where(.svelte-1nd6fqb) {width:22%;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.5rem;border-bottom:1px solid var(--background-modifier-border);text-align:left;word-break:break-word;overflow-wrap:anywhere;white-space:normal;vertical-align:top;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb) {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);font-weight:600;}.choiceExists.svelte-1nd6fqb {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);margin-top:0.1rem;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow):hover td:where(.svelte-1nd6fqb) {background:var(--background-modifier-hover);}.choicesSection.svelte-1nd6fqb select:where(.svelte-1nd6fqb) {max-width:100%;}
/* Narrow viewports (mobile): a 3-column table can't breathe, so each row
becomes a stacked card with the column name as an inline label. */
@media (max-width: 500px) {.choicesSection.svelte-1nd6fqb thead:where(.svelte-1nd6fqb) {display:none;}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tr:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {display:block;width:100%;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow) {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.5rem 0.6rem;margin-bottom:0.5rem;}.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {border-bottom:none;padding:0.15rem 0;}.choicesSection.svelte-1nd6fqb td[data-label="Location"]:where(.svelte-1nd6fqb)::before,
.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb)::before {content:attr(data-label) ": ";font-weight:600;color:var(--text-muted);}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) {display:flex;align-items:center;gap:0.4rem;margin-top:0.25rem;}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) select:where(.svelte-1nd6fqb) {flex:1;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.25rem 0;}
}.summary.svelte-1nd6fqb {display:flex;align-items:center;gap:0.5rem;padding:0.55rem 0.7rem;border-radius:var(--radius-m, 8px);border:1px solid var(--qa-sev-success-border);background:var(--qa-sev-success-wash);color:var(--text-normal);}.summary.svelte-1nd6fqb .quickadd-icon {color:var(--text-success, var(--color-green, #0aa344));flex-shrink:0;}.ackGate.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.4rem;padding:0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);background:var(--background-secondary);}.ackGate.critical.svelte-1nd6fqb {border-color:var(--qa-sev-critical-border);}.ackGate-label.svelte-1nd6fqb {display:flex;align-items:flex-start;gap:0.5rem;font-weight:600;cursor:pointer;}.ackGate-label.svelte-1nd6fqb:has(input:where(.svelte-1nd6fqb):disabled) {cursor:not-allowed;opacity:0.6;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb) {margin-top:0.2rem;flex-shrink:0;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.ackGate-hint.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}.footer.svelte-1nd6fqb {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb) {background:var(--interactive-accent);color:var(--text-on-accent);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--interactive-accent-hover);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:translateY(1px);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {background:transparent;}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--background-modifier-hover);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}
/* Accent background needs a light outline to stay visible. */.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--text-on-accent);outline-offset:-4px;}.is-mobile .macroToggle.svelte-1nd6fqb {min-height:36px;padding:0.4rem 0.3rem;}
@media (prefers-reduced-motion: reduce) {.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {transition:none;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:none;}
}`};function TO(r,e){we(e,!0),ot(r,tme);let t;function n(){return t??(t=new _S(e.app))}let i=Ae(null),o=Ae(null),s=Ae(null),a=Ae(!1),l=Ae(wt(new Set)),c=Ae(wt(new Set)),u=Ae(null),d=Ae(!1),f=Ae(null),p=Ae(wt(new Map)),m=Ae(wt(new Map)),v=Ae(""),g=Ae(!1),y=Ae(0),w=Ae(!1),x=N(()=>h(s)?f4(h(s)):!1),C=N(()=>h(s)?m4(h(s),h(l)):!0),_=N(()=>new Map((h(s)?.choices??[]).map(re=>[re.choiceId,re]))),E=N(()=>new Map((h(s)?.files??[]).map(re=>[re.originalPath,re]))),D=N(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),P=N(()=>!!(h(i)&&h(o))&&!h(g)&&(!h(x)||h(a)&&h(C))),H=N(()=>h(s)?.criticalScriptPaths.length??0),V=N(()=>h(s)?.missingReferences.some(re=>re.asScript)??!1),oe=N(()=>{let re=h(f);if(!re)return"";let Ie=[];re.added&&Ie.push(`${re.added} choice${re.added===1?"":"s"} added`),re.overwritten&&Ie.push(`${re.overwritten} overwritten`),re.assetsWritten&&Ie.push(`${re.assetsWritten} file${re.assetsWritten===1?"":"s"} written`);let dr=re.skipped+re.assetsSkipped;return dr&&Ie.push(`${dr} skipped`),Ie.length?`Imported: ${Ie.join(", ")}.`:"Nothing was imported."}),ce=N(()=>h(H)>0?h(V)?"I have reviewed each bundled script above and trust the source, including scripts that are not included and cannot be shown.":"I have reviewed each script above and trust the source.":h(V)?"This package runs scripts that are not included and cannot be reviewed. I trust the source.":"I understand this package can run code, and I trust the source.");function R(re){if(h(l).has(re))return;let Ie=new Set(h(l));Ie.add(re),Z(l,Ie,!0)}function O(re){let Ie=new Set(h(c));Ie.has(re)?Ie.delete(re):Ie.add(re),Z(c,Ie,!0)}let q=re=>n().optimistic(re),B=N(()=>(h(o)?.assetConflicts??[]).map(re=>({conflict:re,state:A4(h(m),re,Y,q),file:h(E).get(re.originalPath)}))),ie=N(()=>h(B).filter(re=>!re.state.destinationExists)),j=N(()=>h(B).filter(re=>re.state.destinationExists));function Y(re){let[Ie]=Wi(le.getState().templateFolderPaths),dr=re.kind==="template"||re.kind==="capture-template";if(Ie&&dr){let br=re.originalPath.split("/").pop()??re.originalPath;return`${Ie}/${br}`}return re.originalPath}function K(re,Ie){n().schedule(re,Ie,dr=>{Z(m,P4(h(m),re,dr),!0)})}function se(){if(!h(o)){Z(p,new Map,!0),Z(m,new Map,!0);return}Z(p,k4(h(o).choiceConflicts),!0),Z(m,_4(h(o).assetConflicts,Y,q),!0);for(let re of h(o).assetConflicts){let Ie=h(m).get(re.originalPath);Ie&&K(re.originalPath,Ie.destinationPath)}}function pe(re,Ie){Z(p,S4(h(p),re,Ie),!0)}function ge(re,Ie){Z(m,D4(h(m),re,Ie,q),!0)}function be(re,Ie){let{decisions:dr,effectivePath:br}=I4(h(m),re.originalPath,Ie,q);Z(m,dr,!0),K(re.originalPath,br)}function xe(re,Ie){let br=Ie.currentTarget.value;pe(re,br)}function Ue(){Z(s,null),Z(a,!1),Z(l,new Set,!0),Z(c,new Set,!0)}async function $t(re){let Ie=re.trim(),dr=OI(y);if(Z(f,null),Z(w,!1),!Ie){Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue(),Z(u,null);return}Z(g,!0);try{let br=vO(Ie),_n=le.getState().choices,Ho=await g4(e.app,_n,br),Qa=await xS(e.app,_n,br);if(dr!==h(y))return;Z(i,{pkg:br,path:"[pasted]"},!0),Z(o,Ho,!0),Ue(),Z(s,Qa,!0),Z(u,null),se()}catch(br){if(dr!==h(y))return;Z(u,br?.message??String(br),!0),Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue()}finally{dr===h(y)&&Z(g,!1)}}function Ne(re){let Ie=re.currentTarget.value;Z(v,Ie,!0),$t(Ie)}function Ke(re){return!re||re.length===0?"Root":re.slice(0,-1).join(" \u203A ")||"Root"}async function Xe(){if(h(w)){new Mx.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){new Mx.Notice("Load a package before importing.");return}Z(d,!0),Z(f,null);try{let re=await v4({app:e.app,existingChoices:le.getState().choices,aiProviders:le.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:F4(h(o).choiceConflicts,h(p)),assetDecisions:M4(h(o).assetConflicts,h(m),q)});le.setState(Ie=>({...Ie,choices:re.updatedChoices})),Z(f,{added:re.addedChoiceIds.length,overwritten:re.overwrittenChoiceIds.length,skipped:re.skippedChoiceIds.length,assetsWritten:re.writtenAssets.length,assetsSkipped:re.skippedAssets.length},!0),Z(w,!0),new Mx.Notice(`Imported ${re.addedChoiceIds.length+re.overw
${h(To).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),me(ru,h(To).breadcrumb)}),$(ro,kn)}),S(to),S(eo),$(fi,eo)};ne(Hl,fi=>{h(s).missingReferences.length>0&&fi(bd)})}var nv=A(Hl,2);{var Cf=fi=>{var eo=Gfe(),to=A(I(eo),2);ar(to,20,()=>h(s).orphanAssets,ro=>ro,(ro,To)=>{var kn=jfe(),Gt=I(kn),no=I(Gt,!0);S(Gt),Pn(),S(kn),de(()=>me(no,To)),$(ro,kn)}),S(to),S(eo),$(fi,eo)};ne(nv,fi=>{h(s).orphanAssets.length>0&&fi(Cf)})}S(An),$(cn,An)};ne(da,cn=>{h(s)&&(h(s).missingReferences.length>0||h(s).orphanAssets.length>0)&&cn(Ts)})}$(bt,pr)};ne(yt,bt=>{h(i)&&bt(Pr)})}var jt=A(yt,2);{var $i=bt=>{var pr=Qfe(),kr=I(pr);Rt(kr,{iconId:"check-circle",size:16});var Yn=A(kr,2),kt=I(Yn,!0);S(Yn),S(pr),de(()=>me(kt,h(oe))),$(bt,pr)};ne(jt,bt=>{h(f)&&bt($i)})}de(bt=>{me(_n,` ${h(i).pkg.quickAddVersion??""}`),me(Qa,` ${bt??""}`),me(Jc,`${h(o).choiceConflicts.length??""} choice${h(o).choiceConflicts.length===1?"":"s"}`),me(k,`${h(i).pkg.assets.length??""} file${h(i).pkg.assets.length===1?"":"s"}`)},[()=>new Date(h(i).pkg.createdAt).toLocaleDateString()]),$(re,Ie)};ne(or,re=>{h(i)&&h(o)&&re(yr)})}var Pt=A(or,2);{var Ar=re=>{var Ie=Jfe();let dr;var br=I(Ie),_n=I(br);gr(_n);var Ho=A(_n,2),Qa=I(Ho,!0);S(Ho),S(br);var Xa=A(br,2);{var Jc=T=>{var k=Zfe(),L=I(k);S(k),de(()=>me(L,`Open \u201CView contents\u201D on each of the ${h(H)??""} executable
script${h(H)===1?"":"s"} above to enable this.`)),$(T,k)};ne(Xa,T=>{h(H)>0&&!h(C)&&T(Jc)})}S(Ie),de(()=>{dr=Ct(Ie,1,"ackGate svelte-1nd6fqb",null,dr,{critical:h(s)?.summary.hasCritical}),qd(_n,h(a)),_n.disabled=!h(C),ke(_n,"aria-describedby",h(H)>0&&!h(C)?"qa-import-ack-hint":void 0),me(Qa,h(ce))}),De("change",_n,T=>Z(a,T.currentTarget.checked,!0)),$(re,Ie)};ne(Pt,re=>{h(i)&&h(x)&&!h(w)&&re(Ar)})}var ur=A(Pt,2),dt=I(ur),Ft=A(dt,2),jn=I(Ft);{var xo=re=>{var Ie=ul("Importing\u2026");$(re,Ie)},Es=re=>{var Ie=ul("Close");$(re,Ie)},Gn=re=>{var Ie=ul("Import package");$(re,Ie)};ne(jn,re=>{h(d)?re(xo):h(w)?re(Es,1):re(Gn,-1)})}S(Ft),S(ur),S(ye),de(()=>{dt.disabled=h(d),Ft.disabled=h(d)||!h(w)&&!h(P),ke(Ft,"title",!h(w)&&h(x)&&h(C)&&!h(a)?"Confirm the acknowledgement above to continue":void 0)}),De("input",He,Ne),uo(He,()=>h(v),re=>Z(v,re)),De("click",dt,function(...re){e.close?.apply(this,re)}),De("click",Ft,function(...re){(h(w)?e.close:Xe)?.apply(this,re)}),$(r,ye),Ce()}Et(["input","click","change"]);var AS=class extends R4.Modal{constructor(t){super(t);this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageImportModal"),this.handle=qi(this.contentEl,TO,{app:this.app,close:()=>this.close()},{what:"the package importer"})}onClose(){this.handle?.destroy(),this.handle=null}};Em();Wd();pc();function _O(r,e,t,n){let i=Hr(r,"div"),o=Hr(r,"strong");return o.textContent=e,i.appendChild(o),i.appendChild(Kv(r,` ${t}`)),n?.className&&i.classList.add(n.className),i.classList.add("qa-dev-info-row"),r.appendChild(i),i}function $4(r,e){if(e.branch!==null&&_O(r,"Branch:",e.branch),e.commit!==null&&_O(r,"Commit:",e.commit),e.dirty!==null){let t=e.dirty?"Yes (uncommitted changes)":"No",n=e.dirty?"qa-dev-dirty-status":"qa-dev-clean-status";_O(r,"Uncommitted changes:",t,{className:n})}}Wt();var AO="Bundle or import QuickAdd automations as reusable packages.",kS=class extends od.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){let n=le.getState();return t==="inputPrompt"?n.inputPrompt==="multi-line":n[t]}setControlValue(t,n){if(t==="inputPrompt"){le.setState({inputPrompt:n?"multi-line":"single-line"});return}if(t==="persistInputPromptDrafts"){let i=!!n;le.setState({persistInputPromptDrafts:i}),i||Gi.getInstance().clearAll();return}le.setState({[t]:n})}getSettingDefinitions(){return[this.choicesAndPackagesGroup(),this.choicePickerGroup(),this.inputGroup(),this.templatesGroup(),this.notificationsGroup(),this.globalVariablesGroup(),this.aiAndOnlineGroup(),this.appearanceGroup()]}hide(){super.hide(),this.destroySettingViews()}destroySettingViews(){this.choiceViewHandle?.destroy(),this.choiceViewHandle=null,this.globalVariablesViewHandle?.destroy(),this.globalVariablesViewHandle=null,this.packagesUnsubscribe?.(),this.packagesUnsubscribe=null}choicesAndPackagesGroup(){return{type:"group",heading:"Choices & packages",extraButtons:[t=>t.setIcon("help-circle").setTooltip("QuickAdd documentation").onClick(()=>xj(kl.gettingStarted,t.extraSettingsEl))],items:[{name:"Choices",render:t=>this.renderChoicesView(t)},{name:"Packages",desc:AO,render:t=>this.renderPackages(t)}]}}choicePickerGroup(){return{type:"group",heading:"Choice picker",items:[{name:"Search nested choices",desc:"When searching in the choice picker, also match choices nested inside folders and show their path. Note that nested matches can outrank same-level ones. Disable to search only the open level.",control:{type:"toggle",key:"searchNestedChoices"}},{name:"\u201CNew note from template\u201D in the launcher",desc:"Add a row to Run QuickAdd that lists templates from your configured template folder, so you can create a note from a template without a dedicated Template choice. Only appears when a template folder is configured; the command palette entry works regardless.",control:{type:"dropdown",key:"templateFolderLauncherRow",defaultValue:"bottom",options:{bottom:"Show at the bottom (keeps your top choice first)",top:"Show at the top",of
2026-01-31 08:25:19 +08:00
tm = tomorrow
yd = yesterday`).setValue(c0(le.getState().dateAliases)).onChange(o=>{le.setState({dateAliases:V2(o)})}),i.inputEl.addClass("qa-date-alias-input")}),t.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{le.setState({dateAliases:Yf}),n?.setValue(c0(Yf))}),i.buttonEl.addClass("qa-date-alias-reset")})}renderTemplateFolderPaths(t){t.settingEl.addClass("qa-template-folders-setting");let n=t.controlEl.createDiv("qa-template-folders"),i=n.createDiv("qa-template-folder-list"),o=()=>Wi(le.getState().templateFolderPaths),s=p=>{le.setState({templateFolderPaths:p})},a=()=>{i.empty();let p=o();if(p.length===0){i.createDiv({cls:"qa-template-folder-empty",text:"No folders added yet."});return}for(let m of p){let v=i.createDiv("qa-template-folder-row");v.createSpan({cls:"qa-template-folder-name",text:m,attr:{title:m}}),new od.ExtraButtonComponent(v).setIcon("trash-2").setTooltip(`Remove ${m}`).onClick(()=>{s(o().filter(g=>g!==m)),a()})}},l=n.createDiv("qa-template-folder-input-row"),c=new od.TextComponent(l);c.setPlaceholder("templates/"),c.inputEl.addClass("qa-template-folder-input");let u=new ii(this.app,c.inputEl,Oc(Ls(this.app)).filter(p=>p!=="/")),d=()=>{let[p]=Wi([c.inputEl.value]);if(c.inputEl.value="",!p)return;let m=o();m.includes(p)||(s([...m,p]),a())},f=p=>{p.key==="Enter"&&(p.preventDefault(),d())};return c.inputEl.addEventListener("keydown",f),new od.ButtonComponent(l).setCta().setButtonText("Add").onClick(()=>d()),a(),()=>{c.inputEl.removeEventListener("keydown",f),u.destroy()}}renderDevInfo(t){let n=t.settingEl.createDiv();n.addClass("qa-dev-info"),$4(n,{branch:null,commit:null,dirty:null})}};u0();Me();ST();var pg=class{formatOutputString(e){return`QuickAdd: (${e.level}) ${e.message}`}getQuickAddError(e,t,n,i){return{message:e,level:t,time:Date.now(),stack:n,originalError:i}}};Cr();var Rx=class extends pg{constructor(){super(...arguments);this.ErrorLog=[]}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.error(this.formatOutputString(o),s)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.warn(this.formatOutputString(o),s)}logMessage(t,n,i){let o=this.getQuickAddError(t,"LOG",n,i);this.addMessageToErrorLog(o),i?console.log(this.formatOutputString(o),i):console.log(this.formatOutputString(o))}addMessageToErrorLog(t){this.ErrorLog.push(t),this.ErrorLog.length>w0&&(this.ErrorLog=this.ErrorLog.slice(-w0))}clearErrorLog(){this.ErrorLog=[]}};var kO=require("obsidian");ST();var SS=class extends pg{constructor(t){super();this.plugin=t}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);new kO.Notice(this.formatOutputString(o),15e3)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);new kO.Notice(this.formatOutputString(o))}logMessage(t,n,i){}};Me();Cr();Cr();var O4=1e4,N4=50,rme=/plugin:([^\s:)]+)/;function nme(r){let e=r.stack??"",t=`${r.name}: ${r.message}`;return(e.startsWith(t)?e.slice(t.length):e).split(`
`)}function ime(r){for(let e of nme(r)){let t=rme.exec(e);if(t)return{pluginId:t[1],frame:e.trim()}}return null}function ome(r,e){return`${r.name}@${e}`}function L4(r,e=Date.now){let t=r.manifest.id,n=new Map;r.registerDomEvent(window,"unhandledrejection",i=>{let o=i.reason,s=o instanceof Error?ime(o):null;if(s?.pluginId!==t)return;if(Dt(o)){i.preventDefault();return}let a=o,l=ome(a,s.frame),c=e(),u=n.get(l);if(n.set(l,c),!(u!==void 0&&c-u<O4)){if(n.size>=N4){for(let[d,f]of n)c-f>=O4&&n.delete(d);if(n.size>=N4){let d=n.keys().next();!d.done&&d.value!==l&&n.delete(d.value)}}lt(a,"A QuickAdd action failed")&&i.preventDefault()}})}var B4=require("obsidian");Me();function sme(r,e){try{let t=r.setting;return!t?.open||!t?.openTabById?(F.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(t.open(),t.openTabById(e),!0)}catch(t){return F.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${t}`),!1}}function fg(r,e,t){let n=sme(r,e);return!n&&t?.notice!==!1&&new B4.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}oE();Wt();Cr();var FD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choices=n;this.choiceExecutor=i}async run(){let e=Un(this.choices).filter(t=>t.type==="Macro"&&t.runOnStartup);for(let t of e)try{await new Vl(this.app,this.plugin,t,this.choiceExecutor,new Map).run()}catch(n){lt(n,`Startup macro '${t.name}' failed`)}}};var i7=require("obsidian");var Xg=require("obsidian");$x();Tt();qc();Me();var xK=require("obsidian");nd();Lg();Bg();Co();var CK=require("obsidian");js();Fo();function yE(r,e,t){let n=e.lastIndexOf("/"),i=n>=0?e.slice(0,n):"",o=cy(n>=0?e.slice(n+1):e),s=t?.vault.getAbstractFileByPath(e),a=t&&s instanceof CK.TFile?WP([s],d=>t.metadataCache.getFileCache(d))[0]:null,l=a?.primary??o,c=a?.secondary??i;r.addClass("mod-complex");let u=r.createDiv({cls:"suggestion-content"});u.createDiv({cls:"suggestion-title",text:l}),c&&u.createDiv({cls:"suggestion-note",text:c})}function mf(r,e={}){let{openedAtOf:t,recentRankOf:n,isExcluded:i}=e;return r.map(o=>({file:o,name:o.basename||o.path,excluded:i?.(o.path)??!1,openedAt:t?.(o.path),recentRank:n?.(o.path)})).sort((o,s)=>{if(o.excluded!==s.excluded)return o.excluded?1:-1;let a=o.openedAt!=null,l=s.openedAt!=null;if(a!==l)return a?-1:1;if(a&&l&&o.openedAt!==s.openedAt)return s.openedAt-o.openedAt;let c=o.recentRank??Number.POSITIVE_INFINITY,u=s.recentRank??Number.POSITIVE_INFINITY;return c!==u?c-u:o.name.localeCompare(s.name)}).map(o=>o.file)}DP();function hf(r){let e=r.workspace?.getLastOpenFiles?.(),t=Array.isArray(e)?e:[],n=new Map;t.forEach((s,a)=>{n.has(s)||n.set(s,a)});let i;try{i=wm.getInstanceIfExists()}catch{i=void 0}let o=r.metadataCache;return{openedAtOf:s=>i?.getLastOpenedAt(s),recentRankOf:s=>n.get(s),isExcluded:s=>o?.isUserIgnored?.(s)??!1}}Cr();zr();_l();xc();var pN="@quickadd-existing-note:",fN="@quickadd-unresolved-note:";function aye(r){return`${pN}${r}`}function lye(r){return`${fN}${r}`}function cye(r){return r.startsWith(pN)}function uye(r){return r.startsWith(fN)}function dye(r){return r.slice(pN.length)}function pye(r){return r.slice(fN.length)}function gf(r){return r.trim().replace(/\.md$/i,"").toLowerCase()}function EK(r){return r.trim().replace(/^\/+/,"")}function fye(r){return r.trim().length>0&&!r.includes("{{")}function mye(r){if(!fye(r.templatePath))return new Set;let e=EK(r.templatePath),t=/\.md$/i.test(e)?e:`${e}.md`;return new Set([t.toLowerCase()])}function hye(r,e,t){let n=e.replace(/\.md$/i,"");r.add(gf(e)),r.add(gf(n)),r.add(gf(t))}function gye(r,e){let t=r.metadataCache.getFileCache(e)?.frontmatter;if(!t)return[];let n=[];for(let[i,o]of Object.entries(t)){let s=i.toLowerCase();s!=="alias"&&s!=="aliases"||(typeof o=="string"?n.push(...o.split(",").map(a=>a.trim()).filter(Boolean)):Array.isArray(o)&&n.push(...o.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)))}return n}function vye(r){let n=((r.split("|")[0]?.trim()??"").split("#")[0]?.trim()??"").replace(/\.md$/i,"").trim();return!n||n==="/"||Vn(n)?null:n}function yye(r){
2026-01-05 19:25:56 +08:00
`)}}).join(`
`)}}var kK=r=>r.join(""),xye=r=>r.split(/\b/),Eye=AK("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",kK),Tye={splitFunction:xye,joinFunction:kK,conflictFunction:Eye};function bN(r,e,t,n={}){n=Object.assign({},Tye,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=CE.merge(i,o,s);return xE.collateMerge(a,n.joinFunction,n.conflictFunction)}var SK=bN;Tt();Cu();ID();Tt();qt();Co();Vg();function DK(r,e){return r.line===e.line}function Xc(r){let e=[];return r.forEach((t,n)=>{let i=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}function vd(r,e,t=!1){let n=Xc(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)throw new Error(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){let c=IK(r,e,u=>u.trim()==="");return c!==null&&c>e?c-1:e}let s=r.length-1,a=_ye(i,n,r,t),l=Sye(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)return e;let c=r[l+1].trim()==="";return l+1===s&&!c?a:l===0?l+1:l}return a}function _ye(r,e,t,n){let i=e.findIndex(u=>DK(u,r)),o=i===e.length-1,s=t.length-1;if(o)return s;let[a,l]=Aye(r,e);if(l&&a===e.length)return s;if(l&&n)return e[a].line-1;if(l&&!n)return e[i+1].line;if(!n&&!l){let u=kye(r.line,e);return u===null?s:u}return s}function Aye(r,e){let t=e.findIndex(i=>DK(i,r)),n=IK(e,t,i=>i.level<=r.level);return n===null?[-1,!1]:[n,!0]}function kye(r,e){let t=e.find(n=>n.line>r);return t?t.line:null}function Sye(r,e,t){for(let n=e-1;n>=0;n--)if(t(r[n]))return n;return null}function IK(r,e,t){for(let n=e+1;n<r.length;n++)if(t(r[n]))return n;return null}var Dye="\u200B";function EE(r){let e=r.slice(),t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=r[o].match(/^(\s*)(`{3,}|~{3,})/);if(!t){s&&(t=!0,n=s[2][0],i=s[2].length);continue}e[o]=r[o].replace(/^(\s*)#+(\s)/,`$1${Dye}$2`),s&&s[2][0]===n&&s[2].length>=i&&r[o].slice(s[1].length+s[2].length).trim()===""&&(t=!1,n="",i=0)}return e}function PK(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}function Iye(r){let e=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};let t=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}function FK(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{let n=r.match(/^-?\d+(?:\.\d+)?/);return n?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{let n=t?t(r,e.dateFormat||void 0,!1):null;return n&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":return Iye(r);default:return{value:0,parsed:!0}}}function Pye(r,e){if(typeof r.value=="string"&&typeof e.value=="string")return r.value<e.value?-1:r.value>e.value?1:0;let t=r.value,n=e.value;return t<n?-1:t>n?1:0}function MK(r,e,t,n,i,o=0){let s=EE(r),a=Xc(s).filter(f=>f.line>=o),l=a.filter(f=>f.level===t),c=FK(PK(e),n,i);if(l.length===0){let f=a.filter(p=>p.level<t).pop();return f?{mode:"after",line:vd(s,f.line,!0)}:{mode:"bodyStart"}}let u=()=>{let f=l[l.length-1];return{mode:"after",line:vd(s,f.line,!0)}};if(n.by==="insertion")return n.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)return u();let d=n.unparseable??"bottom";for(let f of l){let p=FK(PK(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{let v=Pye(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}return u()}pE();function wN(r){let e=r.split(`
`);for(;e.length>1&&e[e.length-1].trim()==="";)e.pop();return e}function CN(r){return r.length===0||r.length===1&&r[0].trim()===""}function xN(r,e){if(e.length<=1){let t=Fye(r,e[0]??"");return{start:t,end:t}}return Mye(r,e)}function Fye(r,e){let t=e.trimEnd(),n=-1;for(let i=0;i<r.length;i++){let o=r[i].trimStart();if(o===t)return i;if(o.startsWith(t)){let a=o.slice(t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i);continue}let s=o.indexOf(t);if(s!==-1){let a=o.slice(s+t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i)}}return n}function Mye(r,e){let t=e.length,n=e.map(i=>RK(i));for(let i=0;i+t<=r.length;i++){let o=!0;for(let s=0;s<t;s++)if(RK(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+t-1}}return{start:-1,end:-1}}function RK(r){return r.trimEnd()}function $K(r,e,t){return r?Xc([e[t]??""]).length>0:!1}function Rye(r,e){return r==="skip"?!0:r==="none"?!1:$ye(e)}function $ye(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function EN(r,e,t,n){if(e<0)return e;let i=r[e]??"";if(!Rye(n,i))return e;let s=t.endsWith(`
`)?Math.max(r.length-1,0):r.length,a=e;for(let l=e+1;l<s;l++){if(r[l].trim().length===0){a=l;continue}break}return a}function BD(r,e,t,n){if(e<0)return e;let i=e,o=e+1;for(;o<r.length&&r[o].trim().length===0;)i=o,o++;return i===e||o!==r.length||!n.endsWith(`
`)?e:t.endsWith(`
`)?Math.max(e,i-1):i}function OK(r){return r.includes(`
`)||r.includes("\r")}function NK(r,e){let t=r.indexOf(`
`,e);return t===-1?r.length:t>0&&r[t-1]==="\r"?t-1:t}function TN(r){let e=tN(r);return e>0?r.slice(0,e).split(`
`).length-1:0}function LK(r,e){let t=TN(e),n=r.map((i,o)=>o<t?"":i);return EE(n).map(i=>i.replace(/\r$/,""))}function BK(r,e,t,n){let i=e.split(`
`),o=i.slice(0,t+1).join(`
`),s=i.slice(t+1).join(`
`),l=(i[t+1]??"").trim(),c=e.endsWith(`
`)&&t+1===i.length-1,u=t+1<i.length&&!c&&l==="",d=n&&r.endsWith(`
`)&&u?r.slice(0,-1):r,f=!d.endsWith(`
`)&&l!==""?`
`:"";return{content:`${o}
${d}${f}${s}`,insertedEndOffset:o.length+1+d.length}}function UK(r,e,t,n=r.length){let i=e.length>0&&!r.endsWith(`
`)?`
`:"",o=Math.max(0,Math.min(n,r.length));if(t<=0)return{content:`${r}${i}${e}`,insertedEndOffset:o};let s=e.split(`
`),a=s.slice(0,t).join(`
`),l=s.slice(t).join(`
`);return{content:`${a}
${r}${i}${l}`,insertedEndOffset:a.length+1+o}}function VK(r,e,t,n){let i=n,o=i.includes(`\r
`)?`\r
`:`
`,s=e.mode==="before"?e.line:e.line+1,a=0;for(let w=0;w<s&&w<r.length;w++)a+=r[w].length+1;a>i.length&&(a=i.length);let l=i.slice(0,a),c=i.slice(a),u=s>0?(r[s-1]??"").replace(/\r$/,""):"",d=s<r.length?(r[s]??"").replace(/\r$/,""):"",f=t.split(`
`).map(w=>w.replace(/\r$/,""));f.length>1&&f[f.length-1]===""&&f.pop();let p=[];s>0&&u.trim()!==""&&p.push(""),p.push(...f),s<r.length&&d.trim()!==""&&p.push("");let m=p.join(o),v=l.length>0&&!/\n$/.test(l)?o:"",g=c.length>0||/\n$/.test(i)?o:"",y=l.length+v.length;return{content:`${l}${v}${m}${g}${c}`,insertedEndOffset:y+m.length}}pE();Ng();OP();var Nye=/^[ \t\r\n\f\v]*$/;function qK(r){return Nye.test(r)}var UD=class extends Cs{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.useSelectionAsCaptureValue=!0;this.clipboardImageFallbackEnabled=!1;this.createdClipboardAttachmentPaths=[];this.templaterProcessed=!1;this.insertAfterTargetOverride=null;this.lastResolvedInsertAfterHeading=null;this.linebreaksProcessed=!1;this.captureInsertionEndOffset=null}setDestinationFile(t){this.file=t,this.sourcePath=t.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(t.path)),this.setPromptRunContext({destination:t.path,destinationKind:"file"})}setDestinationSourcePath(t){this.sourcePath=t,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(t)),this.setPromptRunContext({destination:t,destinationKind:"file"})}setUseSelectionAsCaptureValue(t){this.useSelectionAsCaptureValue=t}setInsertAfterTargetOverride(t){this.insertAfterTargetOverride=t}getResolvedInsertAfterHeading(){return this.lastResolvedInsertAfterHeading}consumeCreatedClipboardAttachmentPaths(){let t=this.createdClipboardAttachmentPaths;return this.createdClipboardAttachmentPaths=[],t}getCaptureInsertionEndOffset(){return this.captureInsertionEndOffset}setCaptureInsertionEndOffset(t){this.captureInsertionEndOffset=typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}shouldUseSelectionForValue(){return this.useSelectionAsCaptureValue}async getSelectedTextForValue(){let t=await this.getSelectedText();return t.trim().length>0?t:""}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}async getClipboardContent(){let t=await super.getClipboardContent();return t.length>0||!this.clipboardImageFallbackEnabled?t:this.clipboardAttachmentLink!==void 0?this.clipboardAttachmentLink??"":(this.clipboardAttachmentLink=await this.saveClipboardImageAsAttachment(),this.clipboardAttachmentLink??"")}async withClipboardImageFallback(t){let n=this.clipboardImageFallbackEnabled;this.clipboardImageFallbackEnabled=!0;try{return await t()}finally{this.clipboardImageFallbackEnabled=n}}async saveClipboardImageAsAttachment(){let t=navigator.clipboard;if(typeof t?.read!="function")return null;let n,i;try{if(n=await this.getFirstClipboardImageItem(t),!n)return null;i=await(await n.clipboardItem.getType(n.mimeType)).arrayBuffer()}catch{return null}let o=this.getLinkSourcePath()??"",s=await b_(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),w_(this.app,s,o)}async getFirstClipboardImageItem(t){let n=await t.read();for(let i of n){let o=i.types.find(s=>my[s]!==void 0);if(o)return{clipboardItem:i,mimeType:o}}return null}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(t,n)}async formatContentWithFile(t,n,i,o){if(this.setCaptureInsertionEndOffset(null),this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null)return t;this.setTargetFolderPath(Wo(o.path));let s=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatFileContent(t,s)}async formatContent(t,n){return this.choice=n,n?await this.formatFileContent(t):t}async formatFileContent(t,n=!0){let i=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));if(n&&this.file&&!this.templaterProcessed){let a=await dc(this.app,i,this.file);a&&(i=a),this.templaterProcessed=!0}if(qK(i))return this.fileContent;if(this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWrite
`)&&!i.startsWith(`
`),c=a||l?`
`:"";return this.setCaptureInsertionEndOffset(this.fileContent.length+c.length+i.length),`${this.fileContent}${c}${i}`}return this.choice.insertAfter.enabled?await this.insertAfterHandler(i):this.choice.insertBefore?.enabled?await this.insertBeforeHandler(i):this.insertAtNoteBodyStartTracking(i)}async formatContentOnly(t){let n=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));return qK(n)?this.fileContent:n}async expandTemplateLinebreaksOnce(t){return this.linebreaksProcessed?t:(this.linebreaksProcessed=!0,this.expandFormatTemplateEscapes(t))}async expandFormatTemplateEscapes(t){let n=await this.replaceGlobalVarInString(t);return this.expandLinebreakEscapesOutsideTokens(n)}async insertAfterHandler(t){let n=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&n===null){let f=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(t,f)}let i=n??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(n===null){let f=i.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let o=wN(i);if(CN(o))throw new Ee("Insert-after target is empty after formatting.");let s=ff(this.fileContent),a=this.isOrderedCreate()?LK(s,this.fileContent):s,{start:l,end:c}=xN(a,o);if(l===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,i);throw new Ee(`Insert-after target not found: '${i}'.`)}let d;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=vd(s,l,this.considerSubsectionsForAnchor(s,l)),p=Math.max(f??s.length-1,c);d=BD(s,p,this.fileContent,t)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";d=EN(s,c,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,d)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new Ee("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=wN(i);if(CN(o))throw new Ee("Insert-before target is empty after formatting.");let s=ff(this.fileContent),{start:a}=xN(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new Ee(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(OK(n))throw new Ee("Inline insert-after target must be a single line \u2014 remove the line break (\\n) or turn off inline insertion.");let i=this.fileContent.indexOf(n);if(i===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInlineInsertAfterIfNotFound(t,n);throw new Ee(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length;if(this.setCaptureInsertionEndOffset(o+t.length),this.choice.insertAfter?.replaceExisting){let s=NK(this.fileContent,o);return this.fileContent.slice(0,o)+t+this.fileContent.slice(s)}return this.fileContent.slice(0,o)+t+this.fileContent.slice(o)}async createInsertAfterIfNotFound(t,n){let i=`${n}
${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===po)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===ac)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===lc){let o=Nn(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let c=ff(this.fileContent),u=vd(c,a,this.considerSubsectionsForAnchor(c,a));a=BD(c,u??c.length-1,this.fileContent,i)}return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===Aa)return this.createInsertAfterOrdered(t,n);throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===Aa}considerSubsectionsForAnchor(t,n){return $K(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){let i=this.choice.insertAfter?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},o=n.split(/\r?\n/,1)[0],s=Xc([o])[0]?.level??0,a=`${n}
${t}`;if(s===0)return this.insertAtNoteBodyStartTracking(a);let l=ff(this.fileContent),c=l.map(g=>g.replace(/\r$/,"")),u=TN(this.fileContent),d=EE(c),f=o.replace(/\r$/,"").trimEnd(),p=d.findIndex((g,y)=>y>=u&&g.trimEnd()===f);if(p!==-1){let g=this.choice.insertAfter?.insertAtEnd?BD(d,vd(d,p,this.considerSubsectionsForAnchor(d,p))??d.length-1,this.fileContent,t):EN(d,p,this.fileContent,this.choice.insertAfter?.blankLineAfterMatchMode??"auto");return this.insertTextAfterPositionInBody(t,this.fileContent,g)}let m=typeof window<"u"?window.moment:void 0,v=MK(c,o,s,i,m,u);return v.mode==="bodyStart"?this.insertAtNoteBodyStartTracking(a):this.spliceOrderedSection(l,v,a)}spliceOrderedSection(t,n,i){let{content:o,insertedEndOffset:s}=VK(t,n,i,this.fileContent);return this.setCaptureInsertionEndOffset(s),o}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new Ee("Insert-before settings are missing.");let o=t.endsWith(`
`)||t.length===0?`${t}${n}`:`${t}
${n}`;if(i.createIfNotFoundLocation===po)return this.insertAtNoteBodyStartTracking(o,t.length);if(i.createIfNotFoundLocation===ac)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+t.length),`${this.fileContent}
${o}`;if(i.createIfNotFoundLocation===lc){let s=Nn(this.app);if(!s)throw new Ee(`Unable to insert line '${i.before}' at cursor position: no active markdown editor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new Ee(`Unable to insert line '${i.before}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${i.createIfNotFoundLocation}`)}async createInlineInsertAfterIfNotFound(t,n){let i=`${n}${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===po)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===ac)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===lc){let o=Nn(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}insertAtNoteBodyStartTracking(t,n=t.length){let i=rN(this.fileContent,t);if(i.insertedStartOffset===null)return this.setCaptureInsertionEndOffset(null),i.content;let o=Math.max(0,Math.min(n,t.length));return this.setCaptureInsertionEndOffset(i.insertedStartOffset+o),i.content}insertTextAfterPositionInBody(t,n,i){let{content:o,insertedEndOffset:s}=BK(t,n,i,!!this.choice.task);return this.setCaptureInsertionEndOffset(s),o}insertTextBeforePositionInBody(t,n,i,o=t.length){let{content:s,insertedEndOffset:a}=UK(t,n,i,o);return this.setCaptureInsertionEndOffset(a),s}};ID();Me();Jd();qt();Cr();Lg();Bg();var WK=require("obsidian");Tt();Co();_l();function zK(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=vh(t);if(n){if(!n.field)throw new Ee("Property capture target needs a field name, e.g. property:type=draft");return{kind:"property",field:n.field,value:n.value,filter:n.filter}}let i=gh(t);if(i){if(i.multiSelect)throw new Ee("Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata.");return{kind:"filter",filter:i.filter}}let o=li(t,"Capture target file path");if(Vi.test(o))throw new Ee(`Capture to '.base' files is not supported (${o}). Use a Template choice instead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(ir.test(o)||Wr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof WK.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}Tt();function VD(r){return`${r.replace(/^\/+/,"").replace(ir,"")}.md`}function qD(r,e,t){if(t)return null;let n=(e??"").trim().replace(/^\/+/,"");if(_u(n))return null;let i=vh(n),o=!!i&&!!i.field,s=o?null:gh(n),a=!!s&&!s.multiSelect,l=!o&&!s&&n.startsWith("#"),c=n.endsWith("/"),u=!l&&!o&&!a&&!c&&(ir.test(n)||Wr.test(n)||Vi.test(n)),d=n.replace(/\/+$/,""),f=!l&&!o&&!a&&!u&&(n===""||r.isFolder(d)&&!r.markdownFileExists(d)),p=!o&&!a&&c;if(o&&i)return{kind:"property",field:i.field,value:i.value,filter:i.filter};if(a&&s)return{kind:"filter",filter:s.filter};if(l)return{kind:"tag",tag:n};if(f||p){let m=d;return{kind:"folder",folderPathSlash:m===""?"":`${m}/`}}return null}Yv();_l();xc();Em();rm();Ng();js();dN();uD();Co();dD();Q1();function HK(r){let e=r.insertAfter.enabled||!!r.insertBefore?.enabled;return r.captureToActiveFile&&!e&&r.newLineCapture?.enabled?r.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":r.captureToActiveFile&&!e?r.activeFileWritePosition==="top"?"activeFileTop":r.activeFileWritePosition==="bottom"||r.prepend?"append":"currentLine":r.insertAfter.enabled?"insertAfter":r.insertBefore?.enabled?"insertBefore":r.prepend?"prepend":"append"}Tt();Co();function _N(r){return r?.type==="text"?"text":r?.type==="file"||r?.file?"file":typeof r?.text=="string"?"text":"unsupported"}function Lye(r,e){let t=e.id;if(!t)return null;let n=r.getData?.();return n?.nodes?.length?n.nodes.find(i=>i.id===t)??null:null}function jK(r,e){if(r==="text"){if(e==="currentLine")return"Canvas capture does not support 'At cursor' for text cards. Use top, bottom, insert-after, or insert-before placement.";if(e==="newLineAbove"||e==="newLineBelow")return"Canvas capture does not support 'New line above/below cursor' for text cards. Use top, bottom, insert-after, or insert-before placement."}return r==="file"&&(e==="currentLine"||e==="newLineAbove"||e==="newLineBelow")?"Canvas file cards do not support cursor-based capture modes. Use top, bottom, insert-after, or insert-before modes.":null}fun
`),t}async getFormattedPathToCaptureTo(t){if(t){let a=this.app.workspace.getActiveFile();return Mi(a,"Cannot capture to active file - no active file."),a.path}let n=this.getPreselectedCaptureTargetPath();if(n!==void 0){let a=qD({isFolder:l=>im(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(VD(l))instanceof Zc.TFile},this.choice.captureTo??"",!1);if(a){let l=this.confinePreselectedToScope(a,n);if(l!==null)return this.normalizeCaptureFilePath(l)}}let i=this.choice.captureTo,o=await this.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(s.filter);case"property":return this.selectFileWithProperty(s.field,s.value,s.filter);case"folder":return this.selectFileInFolder(s.folder,!1);case"file":return this.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){let t=this.choiceExecutor?.variables?.get(Gd);return typeof t=="string"&&t.length>0?t:void 0}confinePreselectedToScope(t,n){let i=this.stripLeadingSlash(n);if(t.kind==="folder")return t.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))return i;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))return null;let a=new Set(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));return this.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":return om(this.app,t.filter);case"property":return sm(this.app,t.field,t.value,t.filter);case"tag":return Jv(this.app,t.tag);case"folder":return rs(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){return zK(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>im(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){let i=n.startsWith(t)?n:`${t}${n}`,o;try{o=li(i,"Capture target file path")}catch{return!1}let s=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}async selectFileInFolder(t,n){let i=t.endsWith("/")||n?t:`${t}/`,o=rs(this.app,i),s=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(s||o.length>0,`Folder ${i} is empty.`);let a=mf(o,hf(this.app)),l=a.map(v=>v.path),c=Ec(a,v=>this.app.metadataCache.getFileCache(v)),u=l.map((v,g)=>`${c[g]??v} ${v}`),d=new Set(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void 0,p=String(await oa(this.choiceExecutor,{remote:v=>sa(v,{items:l.map((g,y)=>({value:g,title:c[y]??g})),placeholder:f,allowCustomInput:s,what:"the capture-target picker"}),headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>ln.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void 0,renderItem:(v,g)=>yE(g,v,this.app),searchItems:u,allowCustomValue:s,customValueLabel:v=>`Create new note: ${v}`,valueExists:v=>d.has(v.toLowerCase())||this.captureTargetExists(i,v)})}));Mi(!!p&&p.length>0,"No file selected for capture.");let m=p.startsWith(`${i}`)?p:`${i}${p}`;return await this.formatFilePath(m)}async selectFileWithFilter(t){let n=om(this.app,t);return this.selectFileFromSet(n,"No files matched the capture target filters.")}async selectFileWithProperty(t,n,i){let o=sm(this.app,t,n,i),s=n!==void 0?`${t}=${n}`:t;return this.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){let i=t.trim();if(!i)return!1;let o;try{o=li(i,"Capture target file path")}catch{return!1}let s=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;let l=s.slice(s.lastIndexOf("/")+1);return n.has(l.toLowerCase())}async selectFileFromSet(t,n){let i=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(i||t.length>0,n);let o=mf(t,hf(this.app)),s=o.map(m=>m.path),a=Ec(o,m=>this.app.metadataCache.getFileCache(m)),l=s.map((m,v)=>`${a[v]??m} ${m}`),c=new Set(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCa
2026-01-05 19:25:56 +08:00
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
This is in order to prevent data loss.`),u=f.joinedResults(),d=!1}return{file:i,newFileContent:u,captureContent:o,priorContent:c,cursorEndOffset:l??void 0,cursorPlacementSafe:d}}async onCreateFileIfItDoesntExist(t,n,i){aE(t);let o=Og(t);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(t);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let f=new lE(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&f.setLinkToCurrentFileBehavior("optional"),f.setTargetFolderPath(Wo(t)),f.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:t,destinationKind:"file"}),a=await f.run();let p=f.getAndClearTemplatePropertyVars();F.logMessage(`CaptureChoiceEngine: Collected ${p.size} template property variables`),p.size>0&&F.logMessage(`Variables: ${Array.from(p.keys()).join(", ")}`),this.templatePropertyVars=p}let l=await this.createFileWithInput(t,a,{suppressTemplaterOnCreate:this.choice.createFileIfItDoesntExist.createWithTemplate});this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&Rg(l,this.templatePropertyVars)&&await $g(this.app,l,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&a?await Qd(this.app,l):Hv(this.app)&&await k0(this.app,l);let c=await this.app.vault.read(l),u=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,c,l));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let d=this.formatter.getCaptureInsertionEndOffset();return{file:l,newFileContent:u,captureContent:s,priorContent:c,cursorEndOffset:d??void 0,cursorPlacementSafe:!0}}async formatFilePath(t){let n=await this.formatter.formatFileName(t,"captureTarget");return this.normalizeCaptureFilePath(n)}normalizeCaptureFilePath(t){let n=li(this.stripLeadingSlash(t),"Capture target file path");if(Vi.test(n))throw new Ee(`Capture to '.base' files is not supported (${n}). Use a Template choice instead.`);let i=this.normalizeCaptureFilePathExtension(n);if(!Og(i).trim())throw new Ee(`Capture target file name is empty after formatting ('${i}'). Make sure the tokens in 'Capture to' produce a value.`);if(Vn(i))throw new Ee(`Refusing to capture to a file outside the vault: "${i}".`);return i}normalizeCaptureFilePathExtension(t){let n=t.match(ir)?.[0];if(n)return`${li(t.replace(ir,""),"Capture target file path")}${n}`;let i=t.match(Wr)?.[0];return i?`${li(t.replace(Wr,""),"Capture target file path")}${i}`:this.normalizeMarkdownFilePath("",t)}collectIfFrontmatter(t){return this.suppressFrontmatterCollection?t():this.formatter.withTemplatePropertyCollection(t)}mergeCapturePropertyVars(t){if(!(!t||t.size===0)){for(let[n,i]of t)this.capturePropertyVars.set(n,i);F.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(t){return this.capturePropertyVars.size===0?!1:Rg(t,this.capturePropertyVars)?(F.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await $g(this.app,t,this.capturePropertyVars),this.capturePropertyVars.clear(),!0):(this.capturePropertyVars.clear(),!1)}};oE();var xs=require("obsidian");Fo();Cr();zr();It();Wt();rm();var kN=require("obsidian");Tt();qc();qt();Cr();function ZK(r){let e=r.split("/").pop()??r,t=e.lastIndexOf(".");return t>0?e.slice(0,t):e}function SN(r){let e=new rd(ZK(r));return e.id=`folder-template:${r}`,e.templatePath=r,e.openFile=!0,e.fileNameFormat={enabled:!0,format:Rs},e.discoverExistingNotesBeforeCreate=!0,e}function DN(r){return Wi(r.settings.templateFolderPaths).length>0}function Xye(r,e){let t=r.lastIndexOf("/"),n=t===-1?"":r.slice(0,t),i=e.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text
2026-01-05 19:25:56 +08:00
${o}
2026-01-05 19:25:56 +08:00
QuickAdd will now revert to backup.`),r.settings=n,le.replaceState(gt(r.settings))}}r.saveSettings()}var _7=zbe;It();var zl=require("obsidian");Me();async function Hbe(r,e,t){let n=await(0,zl.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){let a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:"Unknown error";throw new Error(`Failed to fetch releases: ${a}`)}let o=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)throw new Error(`Could not find release with tag ${t}`);return o.slice(0,s).filter(a=>!a.draft&&!a.prerelease)}var $N=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,A7=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,jbe=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function Gbe(r,e){let t=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}function Ybe(r){let e=r.split(`
`),t=new Set;for(let s of e){let a=s.trim();$N.test(a)&&t.add(a)}let n=new Map;for(let s of e){let a=s.trim().match(A7);a&&t.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<e.length;s++)if($N.test(e[s].trim()))for(let a of[1,-1]){let l=s+a;for(;l>=0&&l<e.length&&e[l].trim()==="";)l+=a;let c=l>=0&&l<e.length?e[l].trim().match(jbe):null;if(c){n.set(e[s].trim(),c[1]),i.add(l);break}}let o=[];for(let s=0;s<e.length;s++){let a=e[s],l=a.trim();if(i.has(s))continue;let c=l.match(A7);if(!(c&&t.has(c[2]))){if($N.test(l)){o.push(Gbe(l,n.get(l)));continue}o.push(a)}}return o.join(`
`)}function Kbe(r,e=1){let t=r.split(`
`);for(let n=0;n<t.length;n++)t[n].startsWith("#")&&(t[n]="#".repeat(e)+t[n]);return t.join(`
`)}var XD=class extends zl.Modal{constructor(t,n){super(t);this.markdownComponent=new zl.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=Hbe("chhoumann","quickadd",n),this.releaseNotesPromise.then(i=>{if(!this.isClosed){if(this.releases=i,this.releases.length===0){this.close();return}this.display()}}).catch(i=>{F.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let t=this.contentEl.createDiv("quickadd-update-modal-footer");new zl.ButtonComponent(t).setButtonText("Done").setCta().onClick(()=>this.close())}onClose(){let{contentEl:t}=this;this.isClosed=!0,this.markdownComponent.unload(),t.empty()}display(){let{contentEl:t}=this;t.empty(),t.classList.add("quickadd-update-modal-container");let n=`### New in QuickAdd v${this.releases[0].tag_name}
`,i="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",o='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',s=t.createDiv("quickadd-update-modal"),a=this.releases.map(d=>Ybe(d.body??"")).join(`
2026-01-05 19:25:56 +08:00
---
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,u=`${n}
${i}
${o}
2026-01-05 19:25:56 +08:00
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
${l}
2026-01-05 19:25:56 +08:00
---
${Kbe(a)}`;this.markdownComponent.load(),zl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};lD();zr();Co();var Qbe=25e3,Xbe=6e4,Zbe=3e4,Jbe=75e3,ewe=32;function twe(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}function rwe(r){if(r.origin||r.referer)return!1;let e=(r.host??"").split(":")[0];return e==="127.0.0.1"||e==="localhost"}function nwe(r){try{let e=window.require;return e?e(r):null}catch{return null}}function ZD(){let r=window.crypto;if(r?.randomUUID)return r.randomUUID();if(r?.getRandomValues){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}throw new Error("Interactive prompts require a secure random source (crypto), which is unavailable here.")}var JD="No pending prompt for that requestId",ON="The interactive client disconnected, so the run was ended.";function iwe(r,e){if(e.cancelled!==void 0&&typeof e.cancelled!="boolean")return`The "cancelled" flag must be the literal true (or omitted). A cancel that is not recognised would otherwise be answered on the user's behalf.`;if(e.cancelled===!0)return null;if(r==="confirm"){let t=e.value;if(!(t===!0||t===!1||t==="true"||t==="false"))return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${owe(t)}.`}return null}function owe(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}var NN=class{constructor(){this.server=null;this.port=0;this.sessions=new Map;this.startPromise=null;this.generation=0}async ensureStarted(){if(this.server)return this.port;if(this.startPromise)return this.startPromise;let e=nwe("http");if(!e)throw new Error("Interactive prompts require desktop Obsidian (Node http is unavailable).");let t=this.generation;return this.startPromise=new Promise((n,i)=>{let o=e.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===t&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==t){o.close(),i(new Error("Interactive server stopped during startup."));return}let s=o.address();this.port=typeof s=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=ewe)throw new Error("Too many active interactive sessions.");let e=ZD(),t=ZD()+ZD(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:new Map,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};return n.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},Zbe),this.sessions.set(e,n),{id:e,token:t}}emitPrompt(e,t){let n=this.sessions.get(e);if(!n)return Promise.reject(new Error("Unknown session"));if(n.finished)return Promise.reject(new Ee(ON));if(n.aborted)return Promise.reject(new St(yu));let i=ZD();return new Promise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:t.type}),this.push(n,{kind:"prompt",requestId:i,prompt:t})})}finish(e,t){let n=this.sessions.get(e);if(!(!n||n.finished)){n.finished=!0,n.attachTimer&&(window.clearTimeout(n.attachTimer),n.attachTimer=null),n.pollWatchdog&&(window.clearTimeout(n.pollWatchdog),n.pollWatchdog=null);for(let[,i]of n.pending)i.reject(new Ee(ON));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Xbe)}}abortSession(e){let t=this.sessions.get(e);if(!t||t.finished)return null;t.aborted=!0;let n=[...t.pending.values()];t.pending.clear();for(let i of n)i.reject(new St(yu));return t.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(let e of this.sessions.values()){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t
2026-01-05 19:25:56 +08:00
/* nosourcemap */