varU7=Object.create;variv=Object.defineProperty;varV7=Object.getOwnPropertyDescriptor;varq7=Object.getOwnPropertyNames;varW7=Object.getPrototypeOf,z7=Object.prototype.hasOwnProperty;varWN=r=>{throwTypeError(r)};varH7=(r,e,t)=>einr?iv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;varb=(r,e,t)=>()=>{if(t)throwt[0];try{returnr&&(e=r(r=0)),e}catch(n){throwt=[n],n}};varj7=(r,e)=>()=>{try{returne||r((e={exports:{}}).exports,e),e.exports}catch(t){throwe=0,t}},Jr=(r,e)=>{for(vartine)iv(r,t,{get:e[t],enumerable:!0})},zN=(r,e,t,n)=>{if(e&&typeofe=="object"||typeofe=="function")for(letiofq7(e))!z7.call(r,i)&&i!==t&&iv(r,i,{get:()=>e[i],enumerable:!(n=V7(e,i))||n.enumerable});returnr};varHN=(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);varae=(r,e,t)=>H7(r,typeofe!="symbol"?e+"":e,t),sI=(r,e,t)=>e.has(r)||WN("Cannot "+t);varz=(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"):einstanceofWeakSet?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);varO2,N2,L2=b(()=>{O2=r=>{lete,t=newSet,n=(c,u)=>{letd=typeofc=="function"?c(e):c;if(!Object.is(d,e)){letf=e;e=u??(typeofd!="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);returna},N2=(r=>r?O2(r):O2)});functionNv(r){if(r.kind)returnr.kind;lete=(r.name??"").toLowerCase(),t=pX(r.endpoint),n=i=>t===i||t.endsWith(`.${i}`);returne==="anthropic"||n("api.anthropic.com")?"anthropic":e==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}functionpX(r){lete=(r??"").trim();if(!e)return"";for(lettof[e,`https://${e}`])try{returnnewURL(t).hostname.toLowerCase()}catch{}return""}functionfX(r){returnr.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}functionyT(r,e){lett=fX(r),n=newSet(e.map(o=>o.id).filter(o=>!!o)),i=t;for(leto=2;n.has(i);o++)i=`${t}-${o}`;returni}functionbT(r){lete=!1,t=newSet;for(letnofr){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}returne}functionmu(r,e){returne&&e.name===r?e:void0}functionwT(r){returnLv[r].map(e=>({...e}))}varLv,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=
${e}`}asyncfunctionRT(r,e,t){letn=t.destination;if(n?.type!=="specifiedFile")return!1;leti=Gv(r,n);if(!i)thrownewError(`Append link target file not found or is not a Markdown file: ${n.path}`);leto=MT(r,e,{sourcePath:i.path,linkType:"link"});returnawaitr.vault.process(i,s=>zX(s,o)),!0}asyncfunctionHX(r){lete=window.navigator?.clipboard;if(!e?.writeText)returnF.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{returnawaite.writeText(r),!0}catch(t){returnF.logMessage(`QuickAdd: Could not copy link to clipboard: ${tinstanceofError?t.message:String(t)}`),!1}}asyncfunction$T(r){lete=WX(r);returnawaitHX(e)?(newjv.Notice(`Copied link to '${r.basename}' to clipboard.`,SB),!0):(newjv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,SB),!1)}varjv,SB,Yv=b(()=>{jv=require("obsidian");Me();Jd();SB=4e3});functionts(r){if(r.nodeType===Node.DOCUMENT_NODE)returnr;lete=r.ownerDocument;if(!e)thrownewError("Unable to resolve owner document for DOM node.");returne}functionep(r){lete=ts(r).defaultView;if(!e)thrownewError("Unable to resolve owner window for DOM node.");returne}functionHr(r,e){returnts(r).createElement(e)}functionKv(r,e){returnts(r).createTextNode(e)}varpc=b(()=>{});functionOT(r){for(leteofr.workspace.getLeavesOfType("markdown")){lett=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{letn=ts(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(jX))continue;leto=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:t.file,key:o}}catch{continue}}returnnull}functionGX(r,e,t){letn=e.trim();if(!n)thrownewError("Cannot append link to an empty frontmatter property key.");leti=FB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeofo=="string"){r[i]=`${o}${t}`;return}thrownewError(`Cannot append link to frontmatter property '${i}' because it contains a ${typeofo} value.`)}functionPB(r,e,t,n=Xd){leti=e.trim();if(!i)thrownewError("Cannot append link to an empty frontmatter property key.");leto=FB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void0){if(n==="error")thrownewError(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeofs=="object")thrownewError(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")thrownewError(`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]}functionFB(r,e){lett=IB(e),n=Object.keys(r).filter(i=>IB(i)===t);if(n.length>1)thrownewError(`Cannot append link to frontmatter property '${e}' because the note has multiple properties that normalize to that key.`);returnn[0]??e}functionIB(r){returnr.trim().toLowerCase()}asyncfunctionNT(r,e,t){letn=r.fileManager.generateMarkdownLink(t,e.file.path);try{returnawaitr.fileManager.processFrontMatter(e.file,i=>{GX(i,e.key,n)}),!0}catch(i){returnF.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${iinstanceofError?i.message:String(i)}`),!1}}varDB,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(", ")});functionQv(r,e){lett=Nn(r);returnt?.file?.path===e.path?t:null}functionI0(r,e){try{lett=Nn(e);returnt?(t.editor.replaceSelection(r),!0):(F.logError(`unable to append '${r}' to current line.`),!1)}catch{returnF.logError(`unable to append '${r}' to current line.`),!1}}functionP0(r,e,t){try{letn=Nn(t);if(!n)returnF.logError(`unable to insert '${r}' on new line ${e}.`),!1;leti=n.editor,s=
`+r,{line:s,ch:u.length}),i.setCursor({line:s+l,ch:c})}return!0}catch{return F.logError(`unabletoinsert'${r}'onnewline${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(`Unabletoplacecursoraftercapturein'${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(`Filenotfound:${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
`.repeat(e)+r}}varJX,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."});functionVB(r){returnrinstanceofVT}functionnZ(r){returnr.charCodeAt(0)===65279?r.slice(1):r}functioniZ(r){returnnZ(r).trimStart().slice(0,rZ).toLowerCase()}functionoZ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(iZ(r))}functionN0(r,e){lett=newVT(r);throwe.reportLoadErrors!==!1&<(t),t}functionsZ(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.`}functionaZ(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.`}functionlZ(r,e){lett=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.`}functioncZ(r){returnqB(r)?(rinstanceofError?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void0}functionqB(r){return!r||typeofr!="object"?!1:r.code==="MODULE_NOT_FOUND"?!0:(rinstanceofError?r.message:String(r)).includes("Cannot find module")}functionuZ(r){returnr!==null&&typeofr=="object"}functiondZ(r){returntypeofr.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeoft=="function")}functionpZ(r){returntypeofr=="function"?!0:uZ(r)?dZ(r):!1}functionnp(r){lete=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}functionWT(r){lete=r.path??r.id;if(e===void0)return;let{memberAccess:t}=np(r.name??"");returnt&&t.length>0?`${e}::${t.join("::")}`:e}asyncfunctionka(r,e,t={}){letn=e.vault.getAbstractFileByPath(r.path);if(!n){F.logError(`failed to load file ${r.path}.`);return}if(ninstanceofqT.TFile){leti=m=>window.require&&window.require(m),o={},s={exports:o},a=awaite.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&&newqT.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}oZ(l)&&N0(sZ(r.path),t);try{newFunction("require","module","exports",l)(i,s,o)}catch(m){throwqB(m)&&N0(lZ(r.path,cZ(m)),t),m}letc=o.default||s.exports;if(!c)return;letu=c,d=!!o.default,{memberAccess:f}=np(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){letm;for(;m=f.shift();)u=u[m]}returnd&&!p&&!pZ(u)&&N0(aZ(r.path),t),u}}varqT,rZ,VT,zT=b(()=>{qT=require("obsidian");Tt();Me();Zv();Cr();rZ=1024,VT=classextendsError{constructor(e){super(e),this.name="UserScriptLoadError"}}});functionhc(r){if(r==null||typeofr!="string"&&typeofr!="number"&&typeofr!="boolean")return"";lete=String(r).trim();returne.startsWith("#")?e.substring(1).trim():e}functionEu(r){returnr==null?[]:(Array.isArray(r)?r:typeofr=="string"?r.split(/,|\s+/):[r]).map(hc).filter(Boolean)}varHT=b(()=>{});varzi,ip=b(()=>{HT();zi=class{staticfilterFiles(e,t,n){leti=e;returni=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}staticapplyInclusionFilters(e,t,n){leti=!1,o=e,s=this.getIncludeFolders(t);returns.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}staticapplyExclusionFilters(e,t,n){returne.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))))}staticgetIncludeFolders(e){lett=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...newSet(t.map(n=>this.normalizePath(n)).filter
`:" "))}catch(m){F.logError(`Failedtoinsertpastedimagelink:${minstanceofError?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
${s}`)}varSee,A_=b(()=>{VP();See=newSet(["auto","inline","yaml","markdown"])});functionS_(r,e){returnr.length<=e?r:`${r.slice(0,e)}\u2026`}functionFee(r){lete=r.map(t=>`"${t}"`);returne.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}functionkV(r,e){lett=S_(r,32),n=`{{FIELD:${S_(e,48)}}}`,i=Pee.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;leto=EV(r,k_);returno.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(", ")}.`}functionMee(r,e){lett=S_(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${S_(e,48)}}}.`}functionRee(r,e,t){(t.warn??Sm)(kV(r,e))}vark_,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=newMap([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);Yi=class{staticparse(e,t){letn=Bs(e).map(c=>c.trim()),i=n[0],o={},s=!1,a="auto",l=!1;for(letc=1;c<n.length;c++){letu=n[c];if(u.toLowerCase()==="multi"){s=!0;continue}letd=mo(u);if(!d){letm=u.toLowerCase();t?.warnUnknown&&m&&(t.warn??Sm)(k_.includes(m)?Mee(m,e):kV(m,e));continue}letf=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=[]);letm=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=[]);letm=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}:{}}}}});functionqP(r){returnr.replace(/^\/+|\/+$/g,"")}functionwy(r,e=t=>t){returnJSON.stringify([...r].map(e).sort())}functionSV(r,e){lett=[`folder=${qP(r)}`];returne.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("|")}functionOee(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[SV(e,a),`mode=${t}`];returnn&&l.push(`label=${n}`),i&&l.push("optional"),o&&l.push("custom"),s&&l.push("multi"),l.join("|")}functionD_(r,e){if(!r)returnnull;lett=Bs(r),n=(t.shift()??"").trim();if(!n)returnnull;leti=t,o=Sa(i,"optional");i=o.remaining;lets=o.found,a=Sa(i,"custom");i=a.remaining;letl=a.found,c=Sa(i,"multi");i=c.remaining;letu=c.found,d="name",f=[];for(letCofi){let_=C.trim().toLowerCase();if($ee.has(_)){d=_;continue}f.push(C)}letp,m;for(letCoff){let_=mo(C);_&&(_.key==="label"&&_.value?p=_.value:_.key==="name"&&_.value&&(m=_.value))}letv=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
`,i+=2):l==="\\"?(n+="\\",i+=2):(n+="\\",i+=1):(n+=a,i+=1)}returnn}replaceRandomInString(e){lett=e;for(;v0.test(t);){letn=v0.exec(t);if(!n||!n[1])continue;leti=parseInt(n[1]);if(i<=0||i>100)thrownewError(`Random string length must be between 1 and 100. Got: ${i}`);leto="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s="";for(leta=0;a<i;a++)s+=o.charAt(Math.floor(Math.random()*o.length));t=t.replace(n[0],s)}returnt}replaceTitleInString(e){returnthis.replaceCurrentFileTokensInString(e,{title:!0})}}});varG,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={}))});functionnt(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}functionK_(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)}functionTc(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}functionLt(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)}varon=b(()=>{pt()});functionLu(r,e,t,n,i=0){leto=0,s=0;for(;s<n;)o++,newDate(r,e-1,o).getDay()===t&&s++;returnnewDate(r,e-1,o,i)}functionoq(r,e,t,n=0){leti=t===0?7:t,o=newDate(r,e-1+1,1,12),s=o.getDay()===0?7:o.getDay(),a;returns===i?a=7:s<i?a=7+s-i:a=s-i,o.setDate(o.getDate()-a),newDate(r,e-1,o.getDate(),n)}functionQ_(r,e,t={}){if(r==null)returnnull;if(typeofr=="number")returnr;letn=t[r]??Tte[r];returnn==null?null:typeofn=="number"?n:e==null?null:e>n.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}varTte,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
`,n+2);n=l===-1?r.length:l+1;continue}if(i==="/"&&o==="*"){letl=r.indexOf("*/",n+2);n=l===-1?r.length:l+2;continue}lets=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;leta=gx(r,n,"{","}");if(a===-1)break;e.push({start:n+1,end:a}),n=a+1}returne}functionv$(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){leti=vx(r,e);returni?{name:i.value,end:i.end}:null}if(r[e]==="["){leti=La(r,e+1),o=VG(r,i),s=gx(r,e,"[","]");if(s===-1)returnnull;leta=o?La(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}letn=VG(r,e);returnn?{name:n.value,end:n.end}:null}functionwue(r){lete=newMap,t=0;for(;t<r.length;){if(t=La(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;letn=v$(r,t,newMap);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]==="`"){leti=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]==="{"){leti=gx(r,t,"{","}");if(i===-1)break;t=i+1;continue}if(r[t]==="["){leti=gx(r,t,"[","]");if(i===-1)break;t=i+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}returne}functionCue(r){lete=wue(r),t=e.get("type"),n=e.get("secret");returnt==="secret"||(t==="text"||t==="input")&&n===!0}functionRh(r,e){lett=e&&gue.test(e)?mc(r).code??"":r,n=newSet,i=!1,o=zG(t);for(let{start:s,end:a}ofbue(t)){letl=s;for(;l<a;){if(l=La(t,l),t[l]===","){l+=1;continue}if(l>=a)break;letc=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}letu=gx(t,l,"{","}");if(u===-1||u>a)break;letd=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){returntd(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}functionMh(r){returntd(r)&&r[qG]===!0&&typeofr.secretRef=="string"&&r.secretRef.trim().length>0}functionmk(r){return{[qG]:!0,secretRef:r}}functionxue(r,e,t){letn=r.id?.trim()||r.path||r.name||"script";returnh$(fk(n),fk(WG(e,t)))}functionEue(r){lete=r?.options;returne?Object.entries(e).filter(([,t])=>$h(t)).map(([t])=>t):[]}functionTue(r){lete=r?.options;returne?Object.entries(e).filter(([,t])=>$h(t)):[]}function_ue(r){returntypeofr.id=="string"&&r.id.trim().length>0}asyncfunctiony$(r,e){lett=vk(r);if(!t?.getSecret)returnnull;try{returnawaitPromise.resolve(t.getSecret(e))}catch(n){returnF.logWarning(`Failed to read user script SecretStorage entry "${e}": ${g$(n)}`),null}}asyncfunctionAue(r,e,t){letn=vk(r);if(!n?.setSecret)return!1;try{returnawaitPromise.resolve(n.setSecret(e,t)),!0}catch(i){returnF.logWarning(`Failed to write user script SecretStorage entry "${e}": ${g$(i)}`),!1}}asyncfunctionkue(r,e,t,n,i){leto=e.id?.trim()||e.path||e.name||"script",s=fk(o),a=fk(WG(t,i)),l=h$(s,a),c=1;for(;;){letu=awaity$(r,l);if(!u||u===n)returnl;c+=1,l=h$(s,a,String(c))}}asyncfunctionb$(r,e,t,n,i,o){if(n.length===0)returnnull;lets=i?.trim()||awaitkue(r,e,t,n,o);returnawaitAue(r,s,n)?s:null}asyncfunctionw$(r,e){lett=e?.trim();if(!t)return!0;letn=vk(r);if(!n)return!0;leti=n.deleteSecret??n.removeSecret??n.delete;try{if(i)returnawaitPromise.resolve(i.call(n,t)),!0;if(n.setSecret)returnawaitPromise.resolve(n.setSecret(t,"")),!0}catch(o){F.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${g$(o)}`)}return!1}asyncfunctionyk(r,e,t){letn=e.settings??{},i={...n},o=newSet(Eue(t));for(let[s,a]ofObject.entries(n)){if(Mh(a)){letl=awaity$(r,a.secretRef);if(l){i[s]=l;continue}thrownewError(`Secret setting "${s}" for user script "${e.name}" is unavailable. Re-enter it on this device.`)}o.has(s)&&(i[s]=typeofa=="string"?a:"")}returni}asyncfunctionOh(r,e,t){letn=Tue(t);if(n.length===0)return!1;leti=vk(r);if(!i?.getSecret||!i?.setSecret)returnn.some(([a])=>{letl=e.settings?.[a];returntypeofl=="string"&&l.length>0})&&F.logWarning(`SecretStorage unavailable; leavi
${e}`:""}`});functionUO(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void0}}functionOO(r){lete=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();returnta.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),X4(),e}functionNx(r,e){lett=ta.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,X4())}functionQ4(r=10){Number.isFinite(r)||(r=10);lete=Math.floor(r);returne<=0?[]:ta.slice(-e).map(UO).reverse()}functionX4(){if(ta.length<=Y4)return;letr=ta.length-Y4;for(;r>0;){lete=ta.findIndex(t=>t.status!=="pending");if(e===-1)break;ta.splice(e,1),r-=1}}functionZ4(r){lete=ta.find(t=>t.id===r);returne?UO(e):null}functionJ4(){letr=ta[ta.length-1];returnr?UO(r):null}functione5(){ta.splice(0,ta.length)}asyncfunctionSme(r,e,t){if(typeofr!="function")thrownewTypeError("Callback must be a function.");if(!(einstanceofPromise))thrownewTypeError("Promise must be an instance of Promise.");if(typeoft!="number"||t<=0)thrownewTypeError("Interval must be a positive number.");letn=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),awaitsleep(t)}functionDme(r){returnrinstanceofError?r:newError(String(r))}asyncfunctionIme(r,e,t,n=!0,i){leto;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{letc=t.map(u=>u.basename);if(i)o=awaiti.suggester(c,t,"Select a prompt template");elseif(n)o=awaitNr.Suggest(r,c,t);elsethrownewEe("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");lets=o.path,a=r.vault.getAbstractFileByPath(s);Mi(ainstanceofK4.TFile,`${s} is not a file`);letl=awaitr.vault.cachedRead(a);return[o.basename,l]}asyncfunctiont5(r,e,t){if(le.getState().disableOnlineFeatures)thrownewError("Online features are disabled in settings. Enable them to use the AI Assistant.");letn=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]=awaitIme(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");letm=awaitt(p),v=["prompting",`Using prompt template "${f}".`];n.setMessage(v[0],v[1]);lety=MS(r,i,o,s,c,e.modelOptions)(m),x=(awaitVO(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};returnwindow.setTimeout(()=>n.hide(),5e3),_}catch(i){thrown.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),Dt(i)?newSt("Input cancelled by user"):i}}asyncfunctionVO(r,e,t,n){leti=Date.now();returnawaitSme(()=>t(Date.now()-i),r,e),n(Date.now()-i),awaitr}asyncfunctionr5(r,e,t){if(le.getState().disableOnlineFeatures)thrownewError("Online features are disabled in settings. Enable them to use the AI Assistant.");letn=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.");letd=awaitt(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);letm=MS(r,i,o,s,l,u)(d),g=(awaitVO(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,`
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(letaoft){letl=r.lastIndexOf(a,e),c=r.indexOf(a,e),u=[l,c].filter(d=>d>0);for(letdofu){letf=d+a.length;if(f<=0||f>=r.length)continue;letp=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];leto=e,s=r.charCodeAt(o);returns>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}functionMme(r){lete=newRegExp(Hd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}functionRme(r){return$s.test(r)||vu.test(r)||fl.test(r)||uc.test(r)}function$me(r){returnn5.some(e=>r.includes(e))}functionOme(r){returnn5.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}functiono5(r){if(r>$S)thrownewError(`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.`)}functionNme(r,e,t){letn=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){lets=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])}}functionLme(r){lete=r.flags.replace(/[gy]/g,"");returnnewRegExp(r.source+"|",e).exec("").length-1}functionUme(r,e){if(typeofe=="string"){lets=r.split(e);return{chunks:s,separators:newArray(Math.max(0,s.length-1)).fill(e)}}if(Lme(e)>0||Bme.test(e.source))return{chunks:r.split(e),separators:null};lett=newRegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(lets=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}functionVme(r,e,t,n){leti=[];if(r.forEach((l,c)=>{letu=[];Nme(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)returni.map(l=>l.text);leto=[],s="",a=0;for(letlofi){letc=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}returns!==""&&o.push(s),o}functionqme(r,e){lett=Math.max(1,Math.floor(r));if(e!==void0&&Number.isFinite(e)&&e>0){letn=Math.floor(e);return{budget:Math.min(t,n),clamped:n>t}}return{budget:t,clamped:!1}}asyncfunctions5(r,e,t){if(le.getState().disableOnlineFeatures)thrownewError("Online features are disabled in settings. Enable them to use the AI Assistant.");letn=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");letf=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=Ume(u,f),v=awaitt(c,{chunk:BO});if(!(Mme(c)||Rme(c)&&$me(v)))thrownewError("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");lety=o.maxTokens,w=GG(y),x=Ome(v),C=Uo(l)+Uo(x);if(C>=y)thrownewError(`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.`);letD=e.shouldMerge??!0,P=Vme(p,m,_,D);o5(P.length);letH=MS(r,i,o,s,l,d),V=["prompting",`${P.length} prompts being sent.`];n.setMessage(V[0],V[1]);letoe=newLO(5,1e3*30),ce=!1,R=0,O=Promise.resolve(),q=ge=>{letbe=O.then(()=>{if(ce)thrownewError("Chunked prompt stopped after an earlier failure.");returnt(c,{chunk:ge})});returnO=be.then(()=>{},()=>{}),be},B=async(ge,be=0)=>{if(ce)thrownewError("Chunked prompt stopped after an earlier failure.");letxe;try{xe=awaitq(ge)}catch(Ue){throwce=!0,Ue}try{return[(awaitoe.add(()=>{if(ce)thrownewError("Chunked prompt stopped after an earlier failure.");if(R+=1,R>$S)thrownewError(`Chunked AI request exceeded the safety limit of ${$S} provider requests.`);returnH(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?`Nooptionsmatch\u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(let n o
`),selectionStart:e+i.length,selectionEnd:t+c}}functionYme(r,e){r.setSelectionRange(e.regionStart,e.regionEnd);lett=r.ownerDocument,n=!1;try{n=typeoft.execCommand=="function"&&t.execCommand("insertText",!1,e.replacement)}catch{n=!1}if(!n){leti=r.value;r.value=i.slice(0,e.regionStart)+e.replacement+i.slice(e.regionEnd),r.setSelectionRange(e.selectionStart,e.selectionEnd),r.dispatchEvent(newEvent("input",{bubbles:!0}));return}r.setSelectionRange(e.selectionStart,e.selectionEnd)}functiond5(r,e={}){lett=i=>{if(i.key!=="Tab"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey||i.isComposing||i.defaultPrevented)return;i.preventDefault();leto=r.selectionStart??r.value.length,s=r.selectionEnd??o;Yme(r,Gme(r.value,o,s,e))};r.addEventListener("keydown",t);letn=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}varp5=b(()=>{});varbg,ld,GO=b(()=>{bg=require("obsidian");PP();FP();MP();RP();$P();p5();Hs();x_();zr();ld=classrextendsbg.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()||void0,this.draftHandler=newTm({kind:"multi",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=newPromise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=newCm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=newxm(t,this.inputComponent.inputEl)}staticPrompt(t,n,i,o,s,a){returnnewr(t,n,i,o,void0,s,a).waitForClose}staticPromptWithContext(t,n,i,o,s,a,l){returnnewr(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"});lett=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}createInputField(t,n,i){leto=newbg.TextAreaComponent(t);returno.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){leto=newbg.ButtonComponent(t);returno.setButtonText(n).onClick(i),o}getisOptionalPrompt(){returnthis.options?.optional===!0}createButtonBar(t){letn=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){leti=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.
`)&&(J++,ue===0&&(ue=ve+1)),ve--}varVe=Q+J,yt=k-ue;returnL[k]={line:Ve,lineStart:ue},{offset:k,line:Ve+1,column:yt+1}}functionce(T){if(!C(T))thrownewError("not a parser: "+T)}functionR(T,k){returntypeofT=="string"?T.charAt(k):T[k]}functionO(T){if(typeofT!="number")thrownewError("not a number: "+T)}functionq(T){if(typeofT!="function")thrownewError("not a function: "+T)}functionB(T){if(typeofT!="string")thrownewError("not a string: "+T)}varie=2,j=3,Y=8,K=5*Y,se=4*Y,pe=" ";functionge(T,k){returnnewArray(k+1).join(T)}functionbe(T,k,L){varQ=k-T.length;returnQ<=0?T:ge(L,Q)+T}functionxe(T,k,L,Q){return{from:T-k>0?T-k:0,to:T+L>Q?Q:T+L}}functionUe(T,k){varL,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)){varjt=yt-yt%Y,$i=yt-jt,bt=xe(jt,K,se+Y,T.length),pr=c(function(kt){returnc(function(Eo){returnbe(Eo.toString(16),2,"0")},kt)},(function(kt,Eo){varda=kt.length,Ts=[],cn=0;if(da<=Eo)return[kt.slice()];for(varAn=0;An<da;An++)Ts[cn]||Ts.push([]),Ts[cn].push(kt[An]),(An+1)%Eo==0&&cn++;returnTs})(T.slice(bt.from,bt.to).toJSON().data,Y));ue=(function(kt){returnkt.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){returnkt.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{varkr=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}varYn=Q-ue.from;returnE(T)&&(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2),l(function(kt,Eo,da){varTs,cn=da===Yn,An=cn?"> ":pe;returnTs=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(`
`].join("");varL}functionNe(T){returnT.flags!==void0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}functionKe(){for(varT=[].slice.call(arguments),k=T.length,L=0;L<k;L+=1)ce(T[L]);returno(function(Q,J){for(varue,ve=newArray(k),Ve=0;Ve<k;Ve+=1){if(!(ue=H(T[Ve]._(Q,J),ue)).status)returnue;ve[Ve]=ue.value,J=ue.index}returnH(D(J,ve),ue)})}functionXe(){varT=[].slice.call(arguments);if(T.length===0)thrownewError("seqMap needs at least one argument");vark=T.pop();returnq(k),Ke.apply(null,T).map(function(L){returnk.apply(null,L)})}functionye(){varT=[].slice.call(arguments),k=T.length;if(k===0)returnut("zero alternates");for(varL=0;L<k;L+=1)ce(T[L]);returno(function(Q,J){for(varue,ve=0;ve<T.length;ve+=1)if((ue=H(T[ve]._(Q,J),ue)).status)returnue;returnue})}functionWe(T,k){returnht(T,k).or(Be([]))}functionht(T,k){returnce(T),ce(k),Xe(T,k.then(T).many(),function(L,Q){return[L].concat(Q)})}functionHe(T){B(T);vark="'"+T+"'";returno(function(L,Q){varJ=Q+T.length,ue=L.slice(Q,J);returnue===T?D(J,ue):P(Q,k)})}function_e(T,k){(function(J){if(!(JinstanceofRegExp))thrownewError("not a regexp: "+J);for(varue=Ne(J),ve=0;ve<ue.length;ve++){varVe=ue.charAt(ve);if(Ve!=="i"&&Ve!=="m"&&Ve!=="u"&&Ve!=="s")thrownewError('unsupported regexp flag "'+Ve+'": '+J)}})(T),arguments.length>=2?O(k):k=0;varL=(function(J){returnRegExp("^(?:"+J.source+")",Ne(J))})(T),Q=""+T;returno(function(J,ue){varve=L.exec(J.slice(ue));if(ve){if(0<=k&&k<=ve.length){varVe=ve[0],yt=ve[k];returnD(ue+Ve.length,yt)}returnP(ue,"valid match group (0 to "+ve.length+") in "+Q)}returnP(ue,Q)})}functionBe(T){returno(function(k,L){returnD(L,T)})}functionut(T){returno(function(k,L){returnP(L,T)})}functionor(T){if(C(T))returno(function(k,L){varQ=T._(k,L);returnQ.index=L,Q.value="",Q});if(typeofT=="string")returnor(He(T));if(TinstanceofRegExp)returnor(_e(T));thrownewError("not a string, regexp, or parser: "+T)}functionyr(T){returnce(T),o(function(k,L){varQ=T._(k,L),J=k.slice(L,Q.index);returnQ.status?P(L,'not "'+J+'"'):D(L,null)})}functionPt(T){returnq(T),o(function(k,L){varQ=R(k,L);returnL<k.length&&T(Q)?D(L+1,Q):P(L,"a character/byte matching "+T)})}functionAr(T,k){arguments.length<2&&(k=T,T=void0);varL=o(function(Q,J){returnL._=k()._,L._(Q,J)});returnT?L.desc(T):L}functionur(){returnut("fantasy-land/empty")}s.parse=function(T){if(typeofT!="string"&&!E(T))thrownewError(".parse must be called with a string or Buffer as its argument");vark,L=this.skip(xo)._(T,0);returnk=L.status?{status:!0,value:L.value}:{status:!1,index:oe(T,L.furthest),expected:L.expected},deleteV[T],k},s.tryParse=function(T){vark=this.parse(T);if(k.status)returnk.value;varL=$t(T,k),Q=newError(L);throwQ.type="ParsimmonError",Q.result=k,Q},s.assert=function(T,k){returnthis.chain(function(L){returnT(L)?Be(L):ut(k)})},s.or=function(T){returnye(this,T)},s.trim=function(T){returnthis.wrap(T,T)},s.wrap=function(T,k){returnXe(T,this,k,function(L,Q){returnQ})},s.thru=function(T){returnT(this)},s.then=function(T){returnce(T),Ke(this,T).map(function(k){returnk[1]})},s.many=function(){varT=this;returno(function(k,L){for(varQ=[],J=void0;;){if(!(J=H(T._(k,L),J)).status)returnH(D(L,Q),J);if(L===J.index)thrownewError("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){returnB(T),this.map(function(k){if((function(J){if(!_(J))thrownewError("not an array: "+J)})(k),k.length){B(k[0]);for(varL=k[0],Q=1;Q<k.length;Q++)B(k[Q]),L+=T+k[Q];returnL}return""})},s.tie=function(){returnthis.tieWith("")},s.times=function(T,k){varL=this;returnarguments.length<2&&(k=T),O(T),O(k),o(function(Q,J){for(varue=[],ve=void0,Ve=void0,yt=0;yt<T;yt+=1){if(Ve=H(ve=L._(Q,J),Ve),!ve.status)returnVe;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);returnH(D(J,ue),Ve)})},s.result=function(T){returnt
`),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];letn=t.substring(2).trim();returnM.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)=>{letn=t.length==0?"ascending":t[0].toLowerCase();returnn=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":returnQ5(()=>({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":returnQ5(()=>({type:e,format:void0,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]:void0,showId:t.length==0})));case"task":returnM.succeed({type:e});case"calendar":returnM.whitespace.then(M.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:returnM.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});functioneE(r){if(!r.includes(",")){leto=r.trim();returno?[o]:[]}lete=[],t="",n=!1;for(leto=0;o<r.length;o++){lets=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){letl=t.trim();l&&e.push(l),t="";continue}t+=s}leti=t.trim();returni&&e.push(i),e}varR1=b(()=>{});functiontE(r){returnr.replace(/[\\"]/g,"\\$&")}functionnve(r){returnr.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}functionZ8(r){returntE(nve(r))}functionaD(r){returntypeofr=="object"&&r!==null&&"path"inr&&typeofr.path=="string"}var$1,rE,J8=b(()=>{$1=HN(X8());Me();R1();rE=class{staticgetDataviewAPI(e){lett=(0,$1.getAPI)(e);returnt||(F.logMessage("Dataview plugin is not installed or enabled"),null)}staticasyncgetFieldValues(e,t){letn=newSet,i=this.getDataviewAPI(e);if(!i)returnn;try{lets=`field("${tE(t)}")`,a=`TABLE ${s} WHERE ${s}`,l=awaiti.query(a);if(l.successful&&l.value.values)for(letcofl.value.values){letu=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeofd=="string"?n.add(d.trim()):aD(d)?n.add(d.path):d&&typeofd!="object"&&n.add(String(d).trim())}):aD(u)?n.add(u.path):u&&typeofu=="string"?eE(u).forEach(d=>n.add(d)):u&&typeofu!="object"&&n.add(String(u).trim())}}catch(o){F.logError(newError(`Failed to query Dataview for field ${t}: ${o}`))}returnn}staticasyncgetFieldValuesWithFilter(e,t,n={}){leti=newSet,o=this.getDataviewAPI(e);if(!o)returni;try{leta=`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(`
${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(`Templatefilenotfoundatpath"${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}notfound.`),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(", ")}`)}returnn?awaitn.inputPrompt(`Enter value for ${i}`,m):awaitSr.PromptWithContext(this.app,`Enter value for ${i}`,m,void0,this.getLinkSourcePath()??void0)}returnn?String(awaitn.suggester(u,u,p,!0)):awaitln.Suggest(this.app,u,u,{placeholder:p})}catch(i){throwDt(i)?newSt("Input cancelled by user"):i}}generateCacheKey(t){returnL1(t)}asyncsuggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);letn=this.choiceExecutor?.promptProvider;try{leti=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){letc=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?awaitn.inputPrompt(o,c):awaitSr.Prompt(this.app,o,c,void0,void0,t.optional?{optional:!0}:void0);returnt.multiSelect?u?[`${as}${u}`]:[]:u?`${as}${u}`:""}lets=Ec(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${vl}${c.path}`);if(t.multiSelect)return(n?awaitn.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):awaitXp.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${as}${u}`);if(n){letc=String(awaitn.suggester(s,a,o,t.allowCustomInput));returnc?a.includes(c)?c:`${as}${c}`:""}if(t.allowCustomInput){letc=newSet(i.map(f=>f.basename.toLowerCase())),u=newSet(s.map(f=>f.toLowerCase())),d=awaitln.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});returnd?a.includes(d)?d:`${as}${d}`:""}returnawaitNr.Suggest(this.app,s,a,o,void0,t.optional?{skippable:!0}:void0)??""}catch(i){throwDt(i)?newSt("Input cancelled by user"):i}}asyncgetMacroValue(t,n){let{SingleMacroEngine:i}=awaitPromise.resolve().then(()=>(d9(),u9)),o=newi(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=awaito.runAndGetOutput(t,n)??"";returno.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}asyncgetTemplateContent(t){let{SingleTemplateEngine:n}=awaitPromise.resolve().then(()=>(Q1(),f9));this.templateInclusion??(this.templateInclusion={visited:newSet,depth:0});leti={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=newn(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}`});lets=awaito.run();returnthis.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}asyncgetSelectedText(){lett=Nn(this.app);returnt?t.editor.getSelection():""}asyncgetClipboardContent(){try{returnawaitnavigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){returnthis.plugin.settings.enableTemplatePropertyTypes}asyncreplaceInlineJavascriptInString(t){letn=t;for(;uc.test(n);){leti=uc.exec(n);if(!i)break;leto=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=awaitPromise.resolve().then(()=>(h9(),m9)),a=news(this.app,this.plugin,this.choiceExecutor,this.variables),l=awaita.runAndGetOutput(o);for(letuina.params.variables)this.variables.set(u,a.params.variables[u]);letc="";typeofl=="string"?c=l:(typeofl=="number"||typeofl=="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)}elsen=this.replacer(n,uc,"")}returnn}asynccollectValuesManually(t,n){returnawaitB1(this.app,t,n)}}});functionaf(r){returnnewTextEncoder().encode(r).length}functionbve(r){lete=0;for(lettofr){if(t.role==="tool"){for(letnoft.results)e+=af(n.content);continue}if(e+=af(t.content),t.role==="assistant"&&t.toolCalls){for(letnoft.toolCalls)if(typeofn
`:"",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(`Refusingtowritetoanabsolutepathoutsidethevault:"${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(`Refusingpathwithatraversalsegment("${a}"):"${i}".`);if(a.startsWith("."))throw new aa(`Refusingtowriteintoadot/configpathsegment("${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}"isnotunderanallowedroot(${s.join(", ")}).`);return i}function Ove(r,e){if(O_.test(r))throw new aa(`Pathsegment"${r}"containscontrolcharacters:"${e}".`);if(N_.test(r))throw new aa(`Pathsegment"${r}"containsanillegalcharacter(\\:*?" < > |): "${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:"Readanote'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}`;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(`
`)}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'sfrontmatter,orattheverytop."},{id:"bottom",label:"Appendtobottom",description:"Addsthetemplatecontenttotheendofthenote."},{id:"replace",label:"Replacenotecontent",description:"Replacestheentirenotecontentwiththetemplate."}];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,"Cannotapplytemplate:notemplatepathgiven."),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,"Filename"),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,"Cannotinsertatcursor:thenoteisnotopenintheactiveeditor.");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))
`)}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("Conditionalcommandskipped:Novariablenameconfigured."),!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("Conditionalcommand:'contains'operatorrequiresanon-emptycomparisonvalue."),!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("Conditionalcommandnumericcomparisonfailed:non-numericvalueencountered."),!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 "InfiniteAIAssistant" 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/lifecycle_outside_component`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/lifecycle_outside_component")}functionJN(){if(te){letr=newError("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/async_derived_orphan")}functiondI(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/bind_invalid_checkbox_value")}functioneL(){if(te){letr=newError(`derived_references_self
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/effect_in_teardown`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/effect_in_teardown")}functionnL(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/effect_in_unowned_derived")}functioniL(r){if(te){lete=newError(`effect_orphan
https://svelte.dev/e/hydration_failed`);throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/hydration_failed")}functionaL(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/invalid_snippet")}functionlL(r){if(te){lete=newError(`props_invalid_value
https://svelte.dev/e/rune_outside_svelte`);throwe.name="Svelte error",e}elsethrownewError("https://svelte.dev/e/rune_outside_svelte")}functionuL(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_descriptors_fixed")}functiondL(){if(te){letr=newError("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_prototype_fixed")}functionpL(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/state_unsafe_mutation")}functionfL(){if(te){letr=newError("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");throwr.name="Svelte error",r}elsethrownewError("https://svelte.dev/e/svelte_boundary_reset_onerror")}varJa="font-weight: bold",el="font-weight: normal";functionmL(r){te?console.warn(`%c[svelte] await_reactivity_loss
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
%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
%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/lifecycle_double_unmount`,Ja,el):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}functionbL(){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")}functionUE(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_unmount`,Ja,el):console.warn("https://svelte.dev/e/state_proxy_unmount")}functionCL(){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")}varRe=!1;functionIn(r){Re=r}varZe;functiontr(r){if(r===null)throwCd(),jl;returnZe=r}functionKn(){returntr(gi(Ze))}functionS(r){if(Re){if(gi(Ze)!==null)throwCd(),jl;Ze=r}}functionPn(r=1){if(Re){for(vare=r,t=Ze;e--;)t=gi(t);Ze=t}}functiontl(r=!0){for(vare=0,t=Ze;;){if(t.nodeType===jo){varn=t.data;if(n==="]"){if(e===0)returnt;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}vari=gi(t);r&&t.remove(),t=i}}functionuv(r){if(!r||r.nodeType!==jo)throwCd(),jl;returnr.data}functionVE(r){returnr===this.v}functionqE(r,e){returnr!=r?e==e:r!==e||r!==null&&typeofr=="object"||typeofr=="function"}functionWE(r){return!qE(r,this.v)}varen=!1,Yl=!1,fa=!1;varK7="font-weight: bold",Q7="font-weight: normal";functionfI(r){te?console.warn(`%c[svelte] state_snapshot_uncloneable
`),n=[];for(leti=0;i<t.length;i++){leto=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)}}returnn}functionEL(r,e){if(!te)thrownewError("invariant(...) was not guarded by if (DEV)");r||XN(e)}var_t=null;functionKl(r){_t=r}varrl=null;function_f(r){rl=r}varga=null;functionHE(r){ga=r}functionwe(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)}functionCe(r){vare=_t,t=e.e;if(t!==null){e.e=null;for(varnoft)mI(n)}returnr!==void0&&(e.x=r),e.i=!0,_t=e.p,te&&(ga=_t?.function??null),r??{}}functionva(){return!Yl||_t!==null&&_t.l===null}varxd=[];functionTL(){varr=xd;xd=[],RE(r)}functionUr(r){if(xd.length===0&&!Ed){vare=xd;queueMicrotask(()=>{e===xd&&TL()})}xd.push(r)}function_L(){for(;xd.length>0;)TL()}varhI=newWeakMap;functionjE(r){vare=Fe;if(e===null)returnje.f|=8388608,r;if(te&&rinstanceofError&&!hI.has(r)&&hI.set(r,J7(r,e)),(e.f&32768)===0&&(e.f&4)===0)throwte&&!e.parent&&rinstanceofError&&AL(r),r;ba(r,e)}functionba(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throwr;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throwte&&rinstanceofError&&AL(r),r}}functionJ7(r,e){lett=Ao(r,"message");if(!(t&&!t.configurable)){for(varn=mv?" ":" ",i=`
was changed by the error. Include the message below if you report this.</p> <!></div>`),TX={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn{border:1pxsolidvar(--background-modifier-border);border-radius:var(--radius-m);padding:12px14px;margin:4px08px;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:8px00;color:var(--text-muted);font-size:var(--font-ui-small,13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn{margin:10px00;padding:8px10px;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="thispartofQuickAdd";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:"(missingfilepath)"}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]??"(emptytextcard)",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?"":"Canvasfilecardsmustlinktomarkdownfiles(.md).",g=x0(p.split("/").pop()??p,90),y=[x0(p,120)];c&&y.push(c),m||y.push("Notcapturableinthisversion");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||"Typeisnotcurrentlycapturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.toLowerCase(),capturable:!1,capturableReason:"ThisCanvasnodetypeisnotcapturable."}}),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}}","Asksyoufortextwhenthechoiceruns")},{regex:K2,contexts:Ci,suggestion:Je("{{VALUE:}}","Asksonceandreusestheanswerbyname,orlistsoptionstopickfrom"),expansions:()=>[Je("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Je("{{VALUE:option1,option2,option3}}","Asksyoutopickoneoftheseoptions"),Je("{{VALUE:option1,option2,option3|custom}}","Same,butyoucanalsotypeyourown"),Je("{{VALUE:title|label:Notetitle}}","Wordsthepromptyourself"),Je("{{VALUE:option1,option2|label:Pickone}}","Alistwithyourownprompttext"),Je("{{VALUE:title|label:Notetitle|default:Untitled}}","Opensthepromptwithanansweralreadyfilledin"),Je("{{VALUE:<items>|text:<displayitems>}}","Showsonelabelinthelistandinsertsanother"),Je("{{VALUE:option1,option2|name:category}}","Namesthepick,so{{VALUE:category}}reusesit"),Je("{{VALUE:title|case:kebab}}","Reshapestheanswer;type|case:foreverystyle"),Je("{{VALUE:title|trim}}","Trimswhitespaceofftheanswer"),Je("{{VALUE:title|optional}}","Letsthepromptbeskipped,leavingitempty")]},{regex:G2,contexts:Ci,suggestion:Je("{{NAME}}","Anothernamefor{{VALUE}};theydothesamething")},{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,withtodayfilledin"),Je("{{VDATE:dueDate,YYYY-MM-DD|nextmonday}}","Same,startingatnextMonday"),Je("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same,butskippable")]},{regex:rB,contexts:Ci,suggestion:Je("{{FIELD:}}","Suggestsvaluesapropertyalreadyhasinyourvault,like{{FIELD:project}}")},{regex:tB,contexts:Ci,suggestion:Je("{{FILE:}}","Picksanotefromafolder"),expansions:({context:r})=>{let e=[Je("{{FILE:<folder>}}","Picksanotefromthatfolderandinsertsitsname")];return lJ.includes(r)||e.push(Je("{{FILE:<folder>|link}}","Same,butinsertsalinktothenote"),Je("{{FILE:<folder>|path}}","Same,butinsertsitsfullpath"),Je("{{FILE:<folder>|optional}}","Same,butskippable")),e.push(Je("{{FILE:<folder>|custom}}","Same,butyoucanalsotypeanamethatisnotthereyet")),e}},{regex:oB,contexts:Ci,suggestion:Je("{{MVALUE}}","Asksyouforamathformula(LaTeX),withalivepreview")},{regex:H2,contexts:Ci,suggestion:Je("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:j2,contexts:Ci,suggestion:Je("{{DATE:}}","Today'sdateinaformatyouchoose,like{{DATE:MMMMDo}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMMDo,YYYY","dddDMMM","gggg-[W]ww"].map(e=>Je(`{{DATE:${e}}}`,r(e))),Je("{{DATE+7}}","Sevendaysfromtoday"),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((
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
each section.</div> <!> <!> <!> <!> <!> <!>`,1),xle=W("<!> <!> <!> <!> <!>",1);functionOR(r,e){we(e,!0);lett=he(e,"insertAfter",15);t().inline===void0&&t(t().inline=!1,!0),t().replaceExisting===void0&&t(t().replaceExisting=!1,!0),t().promptHeading===void0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void0&&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);letn=[B=>newHi(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(()=>newfh(e.app,e.plugin)),p=Ae(!1);hr(()=>{letB=t().after??"",ie=h(f);if(!t().inline||B===""){Z(p,!1);return}letj=!1;returnie.format(B).then(Y=>{j||Z(p,/[\n\r]/.test(Y),!0)}).catch(()=>{j||Z(p,!1)}),()=>{j=!0}});letm=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;letB=$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))});functiony(B){t(t().createIfNotFoundLocation=B,!0),B===Aa?t(t().inline=!1,!0):(t(t().orderBy=void0,!0),Z(c,!1))}functionw(B){Z(c,!0),t().orderBy&&t(t().orderBy.by=B,!0)}functionx(B){t().promptHeading||B&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),newPj.Notice("Consider subsections requires the target to be a heading (starts with #)"))}functionC(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,getchecked(){returnt().promptHeading},setchecked(j){t(t().promptHeading=j,!0)}})},$$slots:{control:!0}});varD=A(E,2);{varP=B=>{varie=vle();$(B,ie)},H=B=>{varie=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)=>{varxe=Dj(),Ue=Pe(xe);xi(Ue,{getid(){returnbe()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",getmakeSuggesters(){returnn},getvalue(){returnt().after},setvalue(Ne){t(t().after=Ne,!0)}});var$t=A(Ue,2);hs($t,{getvalue(){returnt().after},formatterKind:"lineTarget",getapp(){returne.app},getplugin(){returne.plugin}}),$(ge,xe)},$$slots:{default:!0}});varY=A(j,2);{letpe=be=>{lr(be,{getdisabled(){returnh(u)},getchecked(){returnt().inline},setchecked(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",getdesc(){returnh(g
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
}.quickAddCommandList.svelte-ee11ws{max-width:50%;margin:12pxauto;}`};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(()=>`Removefolder${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(`<divclass="qa-folder-mode-warning">Addatleastonefolder.Withnone,thenotefallsbacktotheactive
file's folder (or you'llbepromptedtopickoneifnofileisopen).</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:
Inordertobeiterable,non-arrayobjectsmusthavea[Symbol.iterator]()method.`)}function Zle(){throw new TypeError(`Invalidattempttodestructurenon-iterableinstance.
Inordertobeiterable,non-arrayobjectsmusthavea[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(`Invalidattempttoiteratenon-iterableinstance.
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;}"};functionB$(r,e){ot(r,Que);vart=Kue(),n=I(t),i=I(n);Rt(i,{iconId:"alert-triangle",size:16});varo=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)}vareg=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){returnthis.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){lett=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=>{lett=this.app.commands.commands[e];this.obsidianCommands.push(newwx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=Pk(this.app)}renderCommandList(e){lett=e.createDiv("commandList");returnthis.commandListProps=nY({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:asyncn=>{leti=this.commandsRef.find(a=>a.id===n);if(!i)throwF.logError("command not found"),newError("command not found");if(!awaitQi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!awaityx(this.app,i)){newFi.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){lett=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){lett,n=()=>{leti=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){F.logError(`Could not find Obsidian command with name "${i}"`);return}lets=newwx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};newFi.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"),newii(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
/* 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-a7rp4hbutton: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). */
/* 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:11auto;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:01auto;}
/* 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:6px8px8px;color:var(--text-faint);font-size:var(--font-ui-smaller,12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06code:where(.svelte-1jxjn06){font-size:inherit;}.qaFolderCount.svelte-1jxjn06{flex:00auto;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:2pxsolidvar(--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
/* 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-color120msease;}
/* 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:-4px0-4px-6px;border-radius:var(--radius-m);border:2pxdashedtransparent;pointer-events:none;transition:border-color120msease;}.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;}
havenotbeenchangedordeleted,andQuickAddwillnotoverwritethem.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
/* 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:00auto;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.5rem1rem;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
/* Keeps "Add variable" right-aligned now that it is the row'sonlychild.*/.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:6px0;}.qa-gv__table.svelte-hx6w4t{display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t{display:grid;grid-template-columns:180px1fr140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t{font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4tinput[type="text"]:where(.svelte-hx6w4t){width:100%;}.qa-gv__cell.svelte-hx6w4ttextarea: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:4px8px;}.qa-gv__btn.danger.svelte-hx6w4t{color:var(--text-error);}
}`};functionoO(r,e){we(e,!0),ot(r,Ppe);lett={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ae(""),i=Ae(wt(newSet)),o=Ae(wt(newSet)),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(()=>newMap(h(c).map(k=>[k.id,k.path.join(" / ")])));functionm(k){returnk.type==="Multi"}functionv(k,L){letQ=L.trim().toLowerCase();returnQ?k.filter(J=>`${J.path.join(" ")}${J.choice.type}`.toLowerCase().includes(Q)):k}functiong(k){letL=[];for(letQofst(k))Ye(Q)&&L.push(Q.id,...g(Q));returnL}functiony(k,L){letQ=[k.id,...g(k)];if(L){letJ=newSet(h(i));for(letueofQ)J.add(ue);if(Z(i,J,!0),h(o).size>0){letue=newSet(h(o));for(letveofQ)ue.delete(ve);Z(o,ue,!0)}}else{letJ=newSet(h(i));for(letveofQ)J.delete(ve);Z(i,J,!0);letue=newSet(h(o));for(letveofQ)ue.add(ve);Z(o,ue,!0)}}functionw(k){letL=h(c).find(J=>J.id===k);if(!L)return;letQ=h(i).has(k);y(L.choice,!Q),Z(a,null)}functionx(){for(letkofh(u))y(k.choice,!0);Z(a,null)}functionC(){Z(i,newSet,!0),Z(o,newSet,!0),Z(a,null)}function_(k,L){letQ=[];for(letJofk)L.has(J.id)&&(!J.parentId||!L.has(J.parentId))&&Q.push(J.id);returnQ}functionE(k,L,Q){if(L.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};letJ=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}}functionD(k){let{missingChoiceIds:L,missingAssets:Q}=k;returnL.length===0&&Q.length===0?null:{missingChoices:L,missingAssets:Q}}asyncfunctionP(){if(h(d).length===0)returnnewWa.Notice("Select at least one choice to export."),null;try{letk=awaitt4(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});returnZ(a,D(k),!0),k}catch(k){returnconsole.error(k),Z(a,null),newWa.Notice(`Export failed: ${k?.message??String(k)}`),null}}asyncfunctionH(){if(!h(l)){Z(l,"copy");try{letk=awaitP();if(!k)return;letL=JSON.stringify(k.pkg,null,2);awaitoe(L),newWa.Notice(`Copied package (${k.pkg.choices.length} choice${k.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?newWa.Notice("Package copied with warnings. Review details below."):e.close()}catch(k){console.error(k),newWa.Notice(`Copy failed: ${k?.message??String(k)}`)}finally{Z(l,null)}}}asyncfunctionV(){if(h(l))return;letk=h(s).trim();if(!k){newWa.Notice("Enter a file path before saving.");return}Z(l,"save");try{letL=awaitP();if(!L)return;let{overwritten:Q}=awaitn4(e.app,L.pkg,k),J=L.pkg.choices.length,ue=`${J} choice${J===1?"":"s"}`;newWa.Notice(Q?`Overwrote package (${ue}) at '${k}'.`:`Saved package (${ue}) to '${k}'.`),h(a)?newWa.Notice("Package saved with warnings. Review details below."):e.close()}catch(L){letQ=L?.message??String(L);if(Q.startsWith("Save cancelled:")){newWa.Notice("Save cancelled.");return}console.error(L),newWa.Notice(`Save failed: ${Q}`)}finally{Z(l,null)}}asyncfunctionoe(k){if(navigator.clipboard?.writeText){awaitnavigator.clipboard.writeText(k);return}letL=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();letQ=document.execCommand("copy");if(document.body.removeChild(L),!Q)thrownewError("Clipboard copy is not supported in this environment.")}varce=Ipe(),R=A(I(ce),2),O=I(R);gr(O),ke(O,"spellcheck",!1);varq=A(O,2),B=I(q),ie=A(B,2);S(q),S(R);varj=A(R,2),Y=I(j);{varK=k=>{varL=Cpe();$(k,L)},se=k=>{varL=Tpe();ar(L,21,()=>h(u),Q=>Q.id,(Q,J)=>{varue=Epe(),ve=I(ue),Ve=I(ve);gr(
${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);leti=r.length/t;returne>1e3||i>250}functionwS(r,e){lett=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{letn=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:ninstanceofError?n.message:String(n)}}}functionf4(r){returnr.summary.hasCritical}functionm4(r,e){returnr.criticalScriptPaths.every(t=>e.has(t))}asyncfunctionh4(r,e){if(Vn(e))thrownewError(`Refusing to read a package outside the vault: "${e}".`);lett=(0,CS.normalizePath)(e.trim());if(!t)thrownewError("Package path cannot be empty.");if(!awaitr.vault.adapter.exists(t))thrownewError(`Package file not found: ${t}`);leti=awaitr.vault.adapter.read(t);return{pkg:vO(i),path:t}}functionvO(r){lete;try{e=JSON.parse(r)}catch(o){thrownewError(`Package content is not valid JSON: ${o?.message??o}`)}if(!GY(e))thrownewError("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)thrownewError(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);lett=Jpe(e.assets);if(t!==null)thrownewError(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);letn=efe(e.choices);if(n!==null)thrownewError(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);leti=tfe(e.choices);if(i!==null)thrownewError(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);returne}functionJpe(r){lete=newSet;for(lettofr){letn=(0,CS.normalizePath)(t.originalPath??"");if(e.has(n))returnt.originalPath;e.add(n)}returnnull}functionefe(r){lete=newMap,t=null,n=i=>{if(t!==null||!i||typeofi!="object")return;leto=i.id;if(typeofo=="string"){lets=mO(i),a=e.get(o);if(a===void0)e.set(o,s);elseif(a!==s){t=o;return}}if(i.type==="Multi"){lets=i;if(Array.isArray(s.choices))for(letaofs.choices)n(a)}i.type==="Macro"&&fO(i.macro?.commands,n)};for(letiofr){if(t!==null)break;n(i?.choice)}returnt}functionfO(r,e){if(Array.isArray(r)){for(lettofr)if(t){if(t.type==="NestedChoice")e(t.choice);elseif(t.type==="Conditional"){letn=t;fO(n.thenCommands,e),fO(n.elseCommands,e)}}}}functionmO(r){if(r===null||typeofr!="object"){letn=JSON.stringify(r);returnn===void0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(mO).join(",")}]`;lete=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${mO(e[n])}`).join(",")}}`}functiontfe(r){lete=newMap(r.map(t=>[t.choice.id,t]));for(lettofr){letn=t.parentChoiceId;if(n===null)continue;leti=e.get(n);if(!i)continue;leto=i.choice;if(!st(o).some(a=>a?.id===t.choice.id))returnt.choice.id}returnnull}asyncfunctiong4(r,e,t){letn=newMap(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(letsoft.assets){leta=Vn(s.originalPath)?!1:awaitr.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}asyncfunctionxS(r,e,t){letn=newSet([...t.assets.map(a=>a.originalPath),...d4(t)]),i=newSet;awaitPromise.all(Array.from(n,asynca=>{a&&(Vn(a)||awaity4(r,a)&&i.add(a))}));leto=p4(e,t,i),{summary:s}=o;returnF.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}functionrfe(r){lett=(r??"").trim();if(!t)thrownewError("Package asset has an empty destination path.");letn=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
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:1pxsolidvar(--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-tb9yzh3: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-tb9yzli:where(.svelte-tb9yz){display:block;padding:0.4rem0.5rem;border-radius:var(--radius-s,4px);}.qa-import-banner-tag.svelte-tb9yz{display:inline-block;vertical-align:middle;margin:00.4rem0.15rem0;}
/* Faint per-row severity wash so critical rows read hottest while warnings
recede, without saturating the whole banner. Composited over the banner
/* --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.05rem0.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:11auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5input:where(.svelte-lmqem5){flex:01300px;min-width:0;}.qa-import-file-field.svelte-lmqem5select:where(.svelte-lmqem5){flex:00auto;}
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5input: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.1rem0.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:2pxsolidvar(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5{display:inline-flex;transition:transform180msease;}.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-rows200msease;}.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.4rem0.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.5rem0.6rem;border-radius:var(--radius-s,4px);background:var(--background-modifier-form-field);border:1pxsolidvar(--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:2pxsolidvar(--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-lmqem5input:where(.svelte-lmqem5),
/* 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
/* 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),
}`};functionTO(r,e){we(e,!0),ot(r,tme);lett;functionn(){returnt??(t=new_S(e.app))}leti=Ae(null),o=Ae(null),s=Ae(null),a=Ae(!1),l=Ae(wt(newSet)),c=Ae(wt(newSet)),u=Ae(null),d=Ae(!1),f=Ae(null),p=Ae(wt(newMap)),m=Ae(wt(newMap)),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(()=>newMap((h(s)?.choices??[]).map(re=>[re.choiceId,re]))),E=N(()=>newMap((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(()=>{letre=h(f);if(!re)return"";letIe=[];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`);letdr=re.skipped+re.assetsSkipped;returndr&&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.");functionR(re){if(h(l).has(re))return;letIe=newSet(h(l));Ie.add(re),Z(l,Ie,!0)}functionO(re){letIe=newSet(h(c));Ie.has(re)?Ie.delete(re):Ie.add(re),Z(c,Ie,!0)}letq=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));functionY(re){let[Ie]=Wi(le.getState().templateFolderPaths),dr=re.kind==="template"||re.kind==="capture-template";if(Ie&&dr){letbr=re.originalPath.split("/").pop()??re.originalPath;return`${Ie}/${br}`}returnre.originalPath}functionK(re,Ie){n().schedule(re,Ie,dr=>{Z(m,P4(h(m),re,dr),!0)})}functionse(){if(!h(o)){Z(p,newMap,!0),Z(m,newMap,!0);return}Z(p,k4(h(o).choiceConflicts),!0),Z(m,_4(h(o).assetConflicts,Y,q),!0);for(letreofh(o).assetConflicts){letIe=h(m).get(re.originalPath);Ie&&K(re.originalPath,Ie.destinationPath)}}functionpe(re,Ie){Z(p,S4(h(p),re,Ie),!0)}functionge(re,Ie){Z(m,D4(h(m),re,Ie,q),!0)}functionbe(re,Ie){let{decisions:dr,effectivePath:br}=I4(h(m),re.originalPath,Ie,q);Z(m,dr,!0),K(re.originalPath,br)}functionxe(re,Ie){letbr=Ie.currentTarget.value;pe(re,br)}functionUe(){Z(s,null),Z(a,!1),Z(l,newSet,!0),Z(c,newSet,!0)}asyncfunction$t(re){letIe=re.trim(),dr=OI(y);if(Z(f,null),Z(w,!1),!Ie){Z(i,null),Z(o,null),Z(p,newMap,!0),Z(m,newMap,!0),Ue(),Z(u,null);return}Z(g,!0);try{letbr=vO(Ie),_n=le.getState().choices,Ho=awaitg4(e.app,_n,br),Qa=awaitxS(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,newMap,!0),Z(m,newMap,!0),Ue()}finally{dr===h(y)&&Z(g,!1)}}functionNe(re){letIe=re.currentTarget.value;Z(v,Ie,!0),$t(Ie)}functionKe(re){return!re||re.length===0?"Root":re.slice(0,-1).join(" \u203A ")||"Root"}asyncfunctionXe(){if(h(w)){newMx.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){newMx.Notice("Load a package before importing.");return}Z(d,!0),Z(f,null);try{letre=awaitv4({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),newMx.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)})}varnv=A(Hl,2);{varCf=fi=>{vareo=Gfe(),to=A(I(eo),2);ar(to,20,()=>h(s).orphanAssets,ro=>ro,(ro,To)=>{varkn=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)})}varjt=A(yt,2);{var$i=bt=>{varpr=Qfe(),kr=I(pr);Rt(kr,{iconId:"check-circle",size:16});varYn=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"}`)},[()=>newDate(h(i).pkg.createdAt).toLocaleDateString()]),$(re,Ie)};ne(or,re=>{h(i)&&h(o)&&re(yr)})}varPt=A(or,2);{varAr=re=>{varIe=Jfe();letdr;varbr=I(Ie),_n=I(br);gr(_n);varHo=A(_n,2),Qa=I(Ho,!0);S(Ho),S(br);varXa=A(br,2);{varJc=T=>{vark=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":void0),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)})}varur=A(Pt,2),dt=I(ur),Ft=A(dt,2),jn=I(Ft);{varxo=re=>{varIe=ul("Importing\u2026");$(re,Ie)},Es=re=>{varIe=ul("Close");$(re,Ie)},Gn=re=>{varIe=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":void0)}),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"]);varAS=classextendsR4.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){leti=Hr(r,"div"),o=Hr(r,"strong");returno.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){lett=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();varAO="Bundle or import QuickAdd automations as reusable packages.",kS=classextendsod.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){letn=le.getState();returnt==="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"){leti=!!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
`)}}varkK=r=>r.join(""),xye=r=>r.split(/\b/),Eye=AK("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",kK),Tye={splitFunction:xye,joinFunction:kK,conflictFunction:Eye};functionbN(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);returnxE.collateMerge(a,n.joinFunction,n.conflictFunction)}varSK=bN;Tt();Cu();ID();Tt();qt();Co();Vg();functionDK(r,e){returnr.line===e.line}functionXc(r){lete=[];returnr.forEach((t,n)=>{leti=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}functionvd(r,e,t=!1){letn=Xc(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)thrownewError(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){letc=IK(r,e,u=>u.trim()==="");returnc!==null&&c>e?c-1:e}lets=r.length-1,a=_ye(i,n,r,t),l=Sye(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)returne;letc=r[l+1].trim()==="";returnl+1===s&&!c?a:l===0?l+1:l}returna}function_ye(r,e,t,n){leti=e.findIndex(u=>DK(u,r)),o=i===e.length-1,s=t.length-1;if(o)returns;let[a,l]=Aye(r,e);if(l&&a===e.length)returns;if(l&&n)returne[a].line-1;if(l&&!n)returne[i+1].line;if(!n&&!l){letu=kye(r.line,e);returnu===null?s:u}returns}functionAye(r,e){lett=e.findIndex(i=>DK(i,r)),n=IK(e,t,i=>i.level<=r.level);returnn===null?[-1,!1]:[n,!0]}functionkye(r,e){lett=e.find(n=>n.line>r);returnt?t.line:null}functionSye(r,e,t){for(letn=e-1;n>=0;n--)if(t(r[n]))returnn;returnnull}functionIK(r,e,t){for(letn=e+1;n<r.length;n++)if(t(r[n]))returnn;returnnull}varDye="\u200B";functionEE(r){lete=r.slice(),t=!1,n="",i=0;for(leto=0;o<r.length;o++){lets=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)}returne}functionPK(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}functionIye(r){lete=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};lett=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}functionFK(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{letn=r.match(/^-?\d+(?:\.\d+)?/);returnn?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{letn=t?t(r,e.dateFormat||void0,!1):null;returnn&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":returnIye(r);default:return{value:0,parsed:!0}}}functionPye(r,e){if(typeofr.value=="string"&&typeofe.value=="string")returnr.value<e.value?-1:r.value>e.value?1:0;lett=r.value,n=e.value;returnt<n?-1:t>n?1:0}functionMK(r,e,t,n,i,o=0){lets=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){letf=a.filter(p=>p.level<t).pop();returnf?{mode:"after",line:vd(s,f.line,!0)}:{mode:"bodyStart"}}letu=()=>{letf=l[l.length-1];return{mode:"after",line:vd(s,f.line,!0)}};if(n.by==="insertion")returnn.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)returnu();letd=n.unparseable??"bottom";for(letfofl){letp=FK(PK(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{letv=Pye(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}returnu()}pE();functionwN(r){lete=r.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-aftertargetnotfound:'${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-beforetargetnotfound:'${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(`Inlineinsert-aftertargetnotfound:'${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}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===lc){let o=Nn(this.app);if(!o)throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition:noactivemarkdowneditor.`);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(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===Aa)return this.createInsertAfterOrdered(t,n);throw new Ee(`UnknowncreateIfNotFoundLocation:${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(`
${o}`;if(i.createIfNotFoundLocation===lc){let s=Nn(this.app);if(!s)throw new Ee(`Unabletoinsertline'${i.before}'atcursorposition:noactivemarkdowneditor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new Ee(`Unabletoinsertline'${i.before}'atcursorposition.`)}}throw new Ee(`UnknowncreateIfNotFoundLocation:${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(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition:noactivemarkdowneditor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unabletoinsertline'${this.choice.insertAfter.after}'atcursorposition.`)}}throw new Ee(`UnknowncreateIfNotFoundLocation:${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(`Captureto'.base'filesisnotsupported(${o}).UseaTemplatechoiceinstead.`);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}asyncgetFormattedPathToCaptureTo(t){if(t){leta=this.app.workspace.getActiveFile();returnMi(a,"Cannot capture to active file - no active file."),a.path}letn=this.getPreselectedCaptureTargetPath();if(n!==void0){leta=qD({isFolder:l=>im(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(VD(l))instanceofZc.TFile},this.choice.captureTo??"",!1);if(a){letl=this.confinePreselectedToScope(a,n);if(l!==null)returnthis.normalizeCaptureFilePath(l)}}leti=this.choice.captureTo,o=awaitthis.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":returnthis.selectFileInFolder("",!0);case"filter":returnthis.selectFileWithFilter(s.filter);case"property":returnthis.selectFileWithProperty(s.field,s.value,s.filter);case"folder":returnthis.selectFileInFolder(s.folder,!1);case"file":returnthis.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){lett=this.choiceExecutor?.variables?.get(Gd);returntypeoft=="string"&&t.length>0?t:void0}confinePreselectedToScope(t,n){leti=this.stripLeadingSlash(n);if(t.kind==="folder")returnt.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))returni;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))returnnull;leta=newSet(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));returnthis.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":returnom(this.app,t.filter);case"property":returnsm(this.app,t.field,t.value,t.filter);case"tag":returnJv(this.app,t.tag);case"folder":returnrs(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){returnzK(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>im(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){leti=n.startsWith(t)?n:`${t}${n}`,o;try{o=li(i,"Capture target file path")}catch{return!1}lets=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}asyncselectFileInFolder(t,n){leti=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.`);leta=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=newSet(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void0,p=String(awaitoa(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:()=>{throwthis.assertInteractiveCaptureTarget(),newError("unreachable")},app:()=>ln.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void0,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.");letm=p.startsWith(`${i}`)?p:`${i}${p}`;returnawaitthis.formatFilePath(m)}asyncselectFileWithFilter(t){letn=om(this.app,t);returnthis.selectFileFromSet(n,"No files matched the capture target filters.")}asyncselectFileWithProperty(t,n,i){leto=sm(this.app,t,n,i),s=n!==void0?`${t}=${n}`:t;returnthis.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){leti=t.trim();if(!i)return!1;leto;try{o=li(i,"Capture target file path")}catch{return!1}lets=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;letl=s.slice(s.lastIndexOf("/")+1);returnn.has(l.toLowerCase())}asyncselectFileFromSet(t,n){leti=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(i||t.length>0,n);leto=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=newSet(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCa
QuickAdd will now revert to backup.`),r.settings=n,le.replaceState(gt(r.settings))}}r.saveSettings()}var_7=zbe;It();varzl=require("obsidian");Me();asyncfunctionHbe(r,e,t){letn=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)){leta=typeofi=="object"&&i!==null&&"message"ini&&typeofi.message=="string"?i.message:"Unknown error";thrownewError(`Failed to fetch releases: ${a}`)}leto=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)thrownewError(`Could not find release with tag ${t}`);returno.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*-->$/;functionGbe(r,e){lett=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}functionYbe(r){lete=r.split(`
`)}varXD=classextendszl.Modal{constructor(t,n){super(t);this.markdownComponent=newzl.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(){lett=this.contentEl.createDiv("quickadd-update-modal-footer");newzl.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");letn=`### 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(`
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.
${Kbe(a)}`;this.markdownComponent.load(),zl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};lD();zr();Co();varQbe=25e3,Xbe=6e4,Zbe=3e4,Jbe=75e3,ewe=32;functiontwe(r,e){if(r.length!==e.length)return!1;lett=0;for(letn=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);returnt===0}functionrwe(r){if(r.origin||r.referer)return!1;lete=(r.host??"").split(":")[0];returne==="127.0.0.1"||e==="localhost"}functionnwe(r){try{lete=window.require;returne?e(r):null}catch{returnnull}}functionZD(){letr=window.crypto;if(r?.randomUUID)returnr.randomUUID();if(r?.getRandomValues){lete=r.getRandomValues(newUint8Array(16));returnArray.from(e,t=>t.toString(16).padStart(2,"0")).join("")}thrownewError("Interactive prompts require a secure random source (crypto), which is unavailable here.")}varJD="No pending prompt for that requestId",ON="The interactive client disconnected, so the run was ended.";functioniwe(r,e){if(e.cancelled!==void0&&typeofe.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)returnnull;if(r==="confirm"){lett=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)}.`}returnnull}functionowe(r){returnr===void0?"no value":r===null?"null":typeofr=="string"?JSON.stringify(r.slice(0,40)):typeofr=="number"||typeofr=="boolean"?String(r):Array.isArray(r)?"an array":typeofr}varNN=class{constructor(){this.server=null;this.port=0;this.sessions=newMap;this.startPromise=null;this.generation=0}asyncensureStarted(){if(this.server)returnthis.port;if(this.startPromise)returnthis.startPromise;lete=nwe("http");if(!e)thrownewError("Interactive prompts require desktop Obsidian (Node http is unavailable).");lett=this.generation;returnthis.startPromise=newPromise((n,i)=>{leto=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(newError("Interactive server stopped during startup."));return}lets=o.address();this.port=typeofs=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=ewe)thrownewError("Too many active interactive sessions.");lete=ZD(),t=ZD()+ZD(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:newMap,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};returnn.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){letn=this.sessions.get(e);if(!n)returnPromise.reject(newError("Unknown session"));if(n.finished)returnPromise.reject(newEe(ON));if(n.aborted)returnPromise.reject(newSt(yu));leti=ZD();returnnewPromise((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){letn=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]ofn.pending)i.reject(newEe(ON));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Xbe)}}abortSession(e){lett=this.sessions.get(e);if(!t||t.finished)returnnull;t.aborted=!0;letn=[...t.pending.values()];t.pending.clear();for(letiofn)i.reject(newSt(yu));returnt.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(leteofthis.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]ofe.pending)t