Files

392 lines
1.1 MiB
JavaScript
Raw Permalink Normal View History

2026-10-09 22:06:40 +08:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var rY=Object.create;var Yf=Object.defineProperty;var nY=Object.getOwnPropertyDescriptor;var iY=Object.getOwnPropertyNames;var oY=Object.getPrototypeOf,sY=Object.prototype.hasOwnProperty;var vR=r=>{throw TypeError(r)};var aY=(r,t,e)=>t in r?Yf(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var x=(r,t,e)=>()=>{if(e)throw e[0];try{return r&&(t=r(r=0)),t}catch(n){throw e=[n],n}};var cb=(r,t)=>{for(var e in t)Yf(r,e,{get:t[e],enumerable:!0})},yR=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of iY(t))!sY.call(r,i)&&i!==e&&Yf(r,i,{get:()=>t[i],enumerable:!(n=nY(t,i))||n.enumerable});return r};var lY=(r,t,e)=>(e=r!=null?rY(oY(r)):{},yR(t||!r||!r.__esModule?Yf(e,"default",{value:r,enumerable:!0}):e,r)),cY=r=>yR(Yf({},"__esModule",{value:!0}),r);var fe=(r,t,e)=>aY(r,typeof t!="symbol"?t+"":t,e),fk=(r,t,e)=>t.has(r)||vR("Cannot "+e);var L=(r,t,e)=>(fk(r,t,"read from private field"),e?e.call(r):t.get(r)),qe=(r,t,e)=>t.has(r)?vR("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(r):t.set(r,e),Oe=(r,t,e,n)=>(fk(r,t,"write to private field"),n?n.call(r,e):t.set(r,e),e),tt=(r,t,e)=>(fk(r,t,"access private method"),e);var oD,sD,aD=x(()=>{oD=r=>{let t,e=new Set,n=(c,d)=>{let u=typeof c=="function"?c(t):c;if(!Object.is(u,t)){let p=t;t=d??(typeof u!="object"||u===null)?u:Object.assign({},t,u),e.forEach(m=>m(t,p))}},i=()=>t,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(e.add(c),()=>e.delete(c))},l=t=r(n,i,a);return a},sD=(r=>r?oD(r):oD)});function Sh(r){if(r.kind)return r.kind;let t=(r.name??"").toLowerCase(),e=cD(r.endpoint),n=i=>e===i||e.endsWith(`.${i}`);return t==="anthropic"||n("api.anthropic.com")?"anthropic":t==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}function lD(r){let t=Sh(r);return t==="openai"&&cD(r.endpoint)==="api.openai.com"?"openai-responses":t}function cD(r){let t=(r??"").trim();if(!t)return"";for(let e of[t,`https://${t}`])try{return new URL(e).hostname.toLowerCase()}catch{}return""}function $K(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function Qb(r,t){let e=$K(r),n=new Set(t.map(o=>o.id).filter(o=>!!o)),i=e;for(let o=2;n.has(i);o++)i=`${e}-${o}`;return i}function Xb(r){let t=!1,e=new Set;for(let n of r){if(n.id&&!e.has(n.id)){e.add(n.id);continue}n.id=Qb(n.id??n.name,r),e.add(n.id),t=!0}return t}function Nl(r,t){return t&&t.name===r?t:void 0}function lp(r){return r.map((t,e)=>({model:t,index:e})).sort((t,e)=>{let n=+!!t.model.deprecated-+!!e.model.deprecated;if(n!==0)return n;let i=t.model.releaseDate??"",o=e.model.releaseDate??"";return i!==o?i?o&&i<o?1:-1:1:t.index-e.index}).map(({model:t})=>t)}function Jb(r){return Ah[r].map(t=>({...t}))}var Ah,dD,FK,MK,Zb,gi=x(()=>{Ah={openai:[{name:"gpt-6-sol",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-6-luna",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-6-astra",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.6-sol",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.6-luna",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.6-terra",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.5",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!0},{name:"gpt-5.4-mini",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!0},{name:"gpt-5.4-nano",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!0},{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.8-flash",m
`)}function Ph(r){let t=Object.entries(r);if(t.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=t.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 ew(r){return Ph(r).map(([t,e])=>`${t}=${e}`).join(", ")}var cp,wd=x(()=>{cp={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 tw,bS=x(()=>{gi();wd();tw={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,namePastedImagesAfterNoteTitle:!1,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:cp,showDateCalendar:!0,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:Zb,confirmToolCalls:"destructive"},migrations:{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 ke(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return Vl(r,new Map)}function Vl(r,t){if(r===null||typeof r!="object")return r;if(t.has(r))return t.get(r);if(r instanceof Date){let i=new Date(r.getTime());return t.set(r,i),i}if(Array.isArray(r)){let i=[];t.set(r,i);for(let o of r)i.push(Vl(o,t));return i}if(r instanceof Map){let i=new Map;t.set(r,i);for(let[o,s]of r.entries())i.set(Vl(o,t),Vl(s,t));return i}if(r instanceof Set){let i=new Set;t.set(r,i);for(let o of r.values())i.add(Vl(o,t));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,t.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return t.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(Vl(r.buffer,t),r.byteOffset,r.byteLength);return t.set(r,a),a}let i=r,o=Vl(i.buffer,t),s=new i.constructor(o,i.byteOffset,i.length);return t.set(r,s),s}let e=Object.getPrototypeOf(r),n=Object.create(e);t.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:Vl(o,t),writable:!0,enumerable:!0,configurable:!0});return n}var tn=x(()=>{});var U,je=x(()=>{aD();bS();tn();U=(()=>{let r=sD((i,o)=>({...ke(tw)})),{getState:t,setState:e,subscribe:n}=r;return{getState:t,replaceState:i=>e(i,!0),setState:e,subscribe:n}})()});var Cd,$h,S,ye=x(()=>{Cd=class Cd{register(t){return Cd.loggers.push(t),this}logError(t){let e=t instanceof Error?t.message:t,n=t instanceof Error?t.stack:void 0,i=t instanceof Error?t:void 0;Cd.loggers.forEach(o=>o.logError(e,n,i))}logWarning(t){let e=t instanceof Error?t.message:t,n=t instanceof Error?t.
`,t-1)+1,a=r.slice(o,e).split(`
`),l=a.length-1,c=0,d=a.map((u,p)=>p===l&&u===""?u:(c+=i.length,i+u));return{regionStart:o,regionEnd:e,replacement:d.join(`
`),selectionStart:t+i.length,selectionEnd:e+c}}function yQ(r,t){r.setSelectionRange(t.regionStart,t.regionEnd);let e=r.ownerDocument,n=!1;try{n=typeof e.execCommand=="function"&&e.execCommand("insertText",!1,t.replacement)}catch{n=!1}if(!n){let i=r.value;r.value=i.slice(0,t.regionStart)+t.replacement+i.slice(t.regionEnd),r.setSelectionRange(t.selectionStart,t.selectionEnd),r.dispatchEvent(new Event("input",{bubbles:!0}));return}r.setSelectionRange(t.selectionStart,t.selectionEnd)}function zh(r,t={}){let e=t.passThroughUntilUsed??!1,n=!e,i=()=>{n=!e},o=()=>{n=!0},s=l=>{if(l.key!=="Tab"){gQ.has(l.key)||(n=!0);return}if(!n||l.shiftKey||l.ctrlKey||l.metaKey||l.altKey||l.isComposing||l.defaultPrevented)return;l.preventDefault();let c=r.selectionStart??r.value.length,d=r.selectionEnd??c;yQ(r,vQ(r.value,c,d,t))};r.addEventListener("keydown",s),r.addEventListener("focus",i),r.addEventListener("pointerup",o),r.addEventListener("input",o);let a=!1;return()=>{a||(a=!0,r.removeEventListener("keydown",s),r.removeEventListener("focus",i),r.removeEventListener("pointerup",o),r.removeEventListener("input",o))}}function pw(r){return{destroy:zh(r,{passThroughUntilUsed:!0})}}var gQ,Hh=x(()=>{gQ=new Set(["Shift","Control","Alt","Meta"])});function On(r){return r.replace(/\{\{CURSOR\}\}/gi,"")}function gp(r){let t=/\{\{CURSOR\}\}/i.exec(r);return r=On(r),{content:r,cursor:/^[ \t\r\n\f\v]*$/.test(r)?{kind:"none"}:{kind:"offset",value:t?.index??r.length,source:t?"marker":"defaultEnd"}}}function Fa(r,t,e=""){return{content:t+r.content+e,cursor:r.cursor.kind==="none"?r.cursor:{...r.cursor,value:t.length+r.cursor.value}}}function Wl(r,t,e){return{content:t,cursor:r.cursor.kind==="none"||e===null?{kind:"none"}:{...r.cursor,value:e}}}var Ma=x(()=>{});function SQ(r){return TQ.test(r.trim())}function AQ(r){let t=r.replace(_Q,"");return t===r?!1:!kQ.test(t)}function mw(r,t){return xQ.has(r)?AQ(t):SQ(t)}function fw(r){return r==="noteTitle"||r==="captureTarget"||r==="propertyName"||r==="propertyValue"||r==="folder"||r==="templatePath"||r==="lineTarget"||r==="filePath"}function hw(r){return r!=="templatePath"&&r!=="generic"}function gw(r,t){if(r==="generic")return{};let e=EQ[r];return t?{title:e.ask,placeholder:e.hint}:{placeholder:e.partOf}}function IQ(r,t=44){if(r.length<=t)return r;let e=r.split("/");if(e.length===1)return r;let n=e[e.length-1];if(e.length===2){let s=`${p0}/${n}`;return s.length<r.length?s:r}let o=`${e[0]}/${p0}/${n}`;return o.length<r.length?o:r}function vp(r,t,e){if(!r)return;let n=[],i=r.choiceName?.trim();i&&i!==t?.trim()&&n.push(i);let o=e?.showDestination===!1?void 0:r.destination?.trim();if(o){let s=e?.elide===!1?o:IQ(o);n.push(`\u2192 ${r.destinationKind==="folder"?`${s}/`:s}`)}return n.length?n.join(" "):void 0}var xQ,EQ,TQ,_Q,kQ,p0,yp=x(()=>{Le();xQ=new Set(["captureText"]),EQ={noteTitle:{ask:"Note title",hint:"Title for the new note",partOf:"Part of the new note's title"},captureTarget:{ask:"Capture target",hint:"Where to capture to",partOf:"Part of the capture destination"},captureText:{ask:"Text to capture",hint:"Text to add to the note",partOf:"Part of the text added to the note"},propertyName:{ask:"Property",hint:"Property name",partOf:"Part of the property name"},propertyValue:{ask:"Property value",hint:"Value to capture",partOf:"Part of the property value"},noteBody:{ask:"Note content",hint:"Text inserted into the note",partOf:"Part of the text inserted into the note"},folder:{ask:"Folder",hint:"Folder for the new note",partOf:"Part of the folder path"},templatePath:{ask:"Template",hint:"Path to the template file",partOf:"Part of the template path"},lineTarget:{ask:"Line to find",hint:"Existing line to anchor the capture to",partOf:"Part of the line to find"},filePath:{ask:"File to open",hint:"Path to the file to open",partOf:"Part of the file path"}},TQ=new RegExp(`^(?:${fo.source})$`,"i"),_Q=new RegExp(fo.source,"gi"),kQ=/\{\{[^}\n\r]*\}\}/;p0="\u2026"});function Wh(r){let e=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(r);return e?[0,e[0].length]:null}function Gh(r,t,e,n){let[i,o]=n??[Number.
`,t-1)+1,l=r.indexOf(`
`,Math.max(t,e)),c=l===-1?r.length:l,d=r.slice(a,t),u=r.slice(e,c),p=(d.match(/^\s*/)||[""])[0],m=r[t-1]==='"'&&r[e]==='"'||r[t-1]==="'"&&r[e]==="'",h=d.replace(/["']$/,""),v=u.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,b=/:\s*$/.test(h)&&v,y=/^\s*-\s*$/.test(h)&&v;return{isInYaml:!0,isQuoted:m,lineStart:a,lineEnd:c,baseIndent:p,isKeyValuePosition:b,isListItemPosition:y}}var US=x(()=>{});function Rs(r,t,e={}){if(!r||!t)return null;let n=r,i=n.metadataTypeManager??n.metadataCache?.app?.metadataTypeManager;if(!i||typeof i.getTypeInfo!="function")return null;if(e.registeredOnly){let a=i.getAllProperties?.();if(!a||typeof a!="object"||!Object.keys(a).some(l=>l.toLowerCase()===t.toLowerCase()))return null}let o=i.getTypeInfo(t),s=o?.expected?.type??o?.inferred?.type;return typeof s=="string"?s:null}function FQ(r){return r!==null&&PQ.has(r.toLowerCase())}function m0(r,t){return $Q.has(t.toLowerCase())||FQ(Rs(r,t))}var PQ,$Q,bp=x(()=>{PQ=new Set(["aliases","list","multitext","tags"]),$Q=new Set(["aliases","cssclasses","tags"])});function MQ(r,t=","){let e=[],n="",i=[],o=null;for(let a=0;a<r.length;a++){let l=r[a];if(o){if(n+=l,l===o){let c=0;for(let d=a-1;d>=0&&r[d]==="\\";d--)c++;c%2===0&&(o=null)}continue}if(l==='"'){o=l,n+=l;continue}if(l in f0){i.push(f0[l]),n+=l;continue}if(i.length>0){let c=i[i.length-1];l===c&&i.pop(),n+=l;continue}if(l===t){let c=n.trim();c.length>0&&e.push(c),n="";continue}n+=l}let s=n.trim();return s.length>0&&e.push(s),e}function RQ(r){return r.includes(`
`)?r.replace(/\r?\n/g,`
`):r.includes("\\n")?r.replace(/\\n/g,`
`):r}function OQ(r){if(!r)return!1;let t=r.toLowerCase();return t==="list"||t==="tags"||t==="multitext"}function h0(r,t){let e=r.trim();if(!e)return;let n=RQ(e),i=t?.propertyType??Rs(t?.app,t?.propertyKey),o=OQ(i),a=o||i===null,c=n.split(/\n/).map(d=>d.trim()).filter(d=>d.length>0);if(a&&c.length>0&&c.every(d=>/^-\s+/.test(d)))return c.map(d=>d.replace(/^-[\s]*/,"").trim());if(n.startsWith("[")&&n.endsWith("]")||n.startsWith("{")&&n.endsWith("}")){if(i&&!o&&i!=="list")return;try{return JSON.parse(n)}catch{}}if(n.includes(",")&&a){let d=MQ(n);if(d.length>1)return d}}var f0,g0=x(()=>{bp();f0={"[":"]","(":")","{":"}","<":">"}});function wp(r){if(typeof r=="string"&&r.startsWith("@date:")){let t=r.substring(6),e=new Date(t);if(!Number.isNaN(e.getTime()))return e}return r}function qS(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function v0(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function y0(r){if(qS(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var Cp=x(()=>{});var b0,Ui,jh=x(()=>{US();g0();Cp();bp();b0="\0",Ui=class{constructor(t){this.app=t;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(t){let{input:e,matchStart:n,matchEnd:i,rawValue:o,fallbackKey:s,collectionActive:a,heuristicEnabled:l}=t;if(!a)return;let c=Wh(e),d=Gh(e,n,i,c);if(!d.isInYaml)return;let u=e.slice(d.lineStart,d.lineEnd),p=u.trim(),m=u.match(/^\s*([^:]+):/),h=m?m[1].trim():s,g=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,v=null;if(d.isKeyValuePosition?v=[h]:g.test(p)&&(v=this.findListParentPath(e,d.lineStart,d.baseIndent??"")),!v||v.length===0)return;let b=v[v.length-1],y=o;if(l&&typeof o=="string"){let w=h0(o,this.buildParseOptions(b));w!==void 0&&(y=w)}if(!qS(y)||Array.isArray(y)&&y.length===0||!l&&!v0(y))return;let C=v.join(b0);return this.map.set(C,y),y}drain(){let t=new Map(this.map);return this.map.clear(),t}merge(t){for(let[e,n]of t)this.map.set(e,n)}buildParseOptions(t){return{propertyKey:t,propertyType:this.resolvePropertyType(t),app:this.app}}findListParentPath(t,e,n){let i=e-1,o=[],s=n.length;for(;i>=0;){let a=t.lastIndexOf(`
`,i),l=a===-1?0:a+1,c=t.slice(l,i+1),d=c.trim();if(d.length===0){i=l-2;continue}if(d==="---"||d==="...")break;if(d.startsWith("-")){i=l-2;continue}let u=c.match(/^(\s*)([^:\n]+):/);if(u){let m=(u[1]??"").length;if(m<s&&(o.unshift(u[2].trim()),s=m,s===0))break}i=l-2}return o.length>0?o:null}resolvePropertyType(t){if(!this.app)return null;if(this.propertyTypeCache.has(t))return this.propertyTypeCache.get(t)??null;let e=Rs(this.app,t);return this.propertyTypeCache.set(t,e),e}};Ui.PATH_SEPARATOR=b0});function Pd(r){return DQ.has(r.toUpperCase())}function zS(r){if(r.length===0||r==="."||r===".."||r.startsWith(".")||Yh.test(r)||Kh.test(r)||Qh.test(r))return!1;let t=r.split(".")[0]??"";return t.length===0||!Pd(t)}var Yh,Kh,Qh,DQ,Xh=x(()=>{Yh=new RegExp("[\0-]","u"),Kh=/[\\/:*?"<>|]/u,Qh=/[. ]$/u,DQ=new Set(["CON","PRN","AUX","NUL","COM1","COM2","COM3","COM4","COM5","COM6","COM7","COM8","COM9","LPT1","LPT2","LPT3","LPT4","LPT5","LPT6","LPT7","LPT8","LPT9"])});function w0(r){if(!r)return null;let t=r.trim().toLowerCase();switch(t){case"kebab":case"snake":case"camel":case"pascal":case"title":case"lower":case"upper":case"slug":return t;default:return null}}function bw(r){return w0(r)!==null}function HS(r){if(!r)return r;let t=r.toLowerCase();return t.slice(0,1).toUpperCase()+t.slice(1)}function WS(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function vw(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function LQ(r){return/^\p{Ll}/u.test(r)&&vw(r)}function NQ(r){if(!r)return[];{let e=r.match(/^([\p{Ll}][\p{Lu}]{2,})([\p{N}]+)?$/u);if(e){let n=[e[1]];return e[2]&&n.push(e[2]),n}}if(/^[\p{Ll}][\p{Lu}][\p{Ll}]+(?:[\p{Lu}][\p{Ll}]+)*$/u.test(r))return[r];let t=r;return t=t.replace(/([\p{Lu}])([\p{Lu}][\p{Ll}])/gu,"$1 $2"),t=t.replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2"),t=t.replace(/([\p{L}])([\p{N}])/gu,"$1 $2"),t=t.replace(/([\p{N}])([\p{L}])/gu,"$1 $2"),t.trim().split(/\s+/u).map(e=>e.trim()).filter(Boolean)}function VQ(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(NQ).filter(Boolean)}function Jh(r,t){let e=w0(t);if(!e)return r;if(e==="lower")return r.toLowerCase();if(e==="upper")return r.toUpperCase();let n=VQ(r);if(n.length===0)return"";switch(e){case"kebab":return n.map(i=>i.toLowerCase()).join("-");case"snake":return n.map(i=>i.toLowerCase()).join("_");case"camel":{let[i,...o]=n,s=i?LQ(i)?i:i.toLowerCase():"",a=o.map(l=>WS(l)||vw(l)?l:HS(l));return[s,...a].join("")}case"pascal":return n.map(i=>WS(i)||vw(i)?i:HS(i)).join("");case"title":return n.map(i=>WS(i)||vw(i)?i:HS(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return Pd(i)?`${i}-`:i}default:return r}}var yw,ww=x(()=>{Xh();yw=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function C0(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(BQ,t=>`\\x${t.charCodeAt(0).toString(16).padStart(2,"0")}`)}function Zh(r){return`"${C0(r)}"`}function GS(r,t,e){let n=Gh(r,t,e,Wh(r));return!n.isInYaml||!n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}function $d(r,t,e,n){return GS(r,t,e)?r[t-1]==='"'?C0(n):n.replace(/'/g,"''"):n}function jS(r,t,e){let n=Gh(r,t,e,Wh(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var BQ,Cw=x(()=>{US();BQ=new RegExp("[\0-\x7F]","g")});function xw(r,t,e){let n=r.trim().toLowerCase();if(UQ.has(n))return n;e?.(`QuickAdd: Unsupported multi-select format "${r}" in "${t}". Supported formats: auto, inline, spaced, yaml, markdown.`)}function qQ(r,t){let e=r.lastIndexOf(`
`,t-1)+1;return r.slice(e,t).match(/^\s*/)?.[0]??""}function x0(r){if(r.format==="inline"||r.format==="spaced")return!1;let t=r.input.lastIndexOf(`
`,r.matchStart-1)+1,e=r.input.indexOf(`
`,r.matchEnd);return r.input.slice(t,r.matchStart).trim()===""&&r.input.slice(r.matchEnd,e===-1?void 0:e).trim()===""}function zQ(r){return`- ${r.replace(/\r\n?|\n/g,`
`)}`}function E0(r){let{input:t,matchStart:e,values:n,format:i}=r,o=n.map(s=>String(s));switch(i){case"auto":return;case"inline":return o.join(",");case"spaced":return o.join(", ");case"yaml":return`[${o.map(Zh).join(", ")}]`;case"markdown":{if(o.length===0)return"";let s=qQ(t,e);return o.map(zQ).join(`
${s}`)}default:return i}}var UQ,Ew=x(()=>{Cw();UQ=new Set(["auto","inline","spaced","yaml","markdown"])});function Tw(r){let t=r.trim();return t&&(/^\[\[.*\]\]$/.test(t)?t:`[[${t}]]`)}var YS=x(()=>{});function bo(r){return r.split("|")}function T0(r){return r.startsWith("|")?r.slice(1):r}function wo(r){let t=r.indexOf(":");if(t===-1)return null;let e=r.slice(0,t).trim().toLowerCase();if(!e)return null;let n=r.slice(t+1).trim();return{key:e,value:n}}function Gl(r){if(!r)return!0;let t=r.trim().toLowerCase();return!["false","no","0","off"].includes(t)}function Xo(r,t){let e=!1;return{remaining:r.filter(i=>i.trim().toLowerCase()===t?(e=!0,!1):!0),found:e}}var jl=x(()=>{});function KS(r){let{remaining:t,found:e}=Xo(r,"optional"),{remaining:n,found:i}=Xo(t,"trim");return{remaining:n,optional:e,trim:i}}function QS(r,t,e,n,i){let o=r.map(u=>{let p=u.trim();return{raw:p,option:wo(p)}}),s=e?WQ:_0,a=o.some(({option:u})=>u?.key==="type"&&["number","slider"].includes(u.value.toLowerCase())),l=u=>s.has(u)||a&&HQ.has(u);if(!o.some(({raw:u,option:p})=>p&&l(p.key)||t&&["custom","multi"].includes(u.toLowerCase())))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let d={defaultValue:"",allowCustomInput:!1,usesOptions:!0,multiSelect:!1};for(let{raw:u,option:p}of o){if(t&&u.toLowerCase()==="custom"){d.allowCustomInput=!0;continue}if(t&&u.toLowerCase()==="multi"){d.multiSelect=!0;continue}if(!p||!l(p.key))continue;let{key:m,value:h}=p;switch(m){case"label":h&&(d.label=h);break;case"case":h&&(d.caseStyle=h);break;case"default":d.defaultValue=h;break;case"custom":d.allowCustomInput=Gl(h);break;case"type":h&&(d.inputTypeOverride=h);break;case"min":d.minRaw=h;break;case"max":d.maxRaw=h;break;case"step":d.stepRaw=h;break;case"text":d.displayValuesRaw=h;break;case"optional":d.optionalExplicit=Gl(h);break;case"trim":d.trimExplicit=Gl(h);break;case"multi":d.multiSelect=!0,d.multiEmit=h.trim().toLowerCase()==="linklist"?"linklist":"text";break;case"format":d.multiFormat=xw(h,n,i);break;case"name":h?d.name=h:i(`QuickAdd: empty |name: ignored in "${n}"; provide a variable name, e.g. {{VALUE:a,b|name:category}}.`);break;default:break}}return d}var HQ,_0,WQ,k0=x(()=>{jl();Ew();HQ=new Set(["min","max","step"]),_0=new Set(["label","default","custom","type","case","text","optional","trim","multi","format"]),WQ=new Set([..._0,"name"])});var xp,eg,tg=x(()=>{ye();xp=r=>{S.logWarning(r)},eg=()=>{}});function Ep(r){if(r===void 0)return;let t=r.trim();if(!t)return;let e=Number(t);return Number.isFinite(e)?e:void 0}function GQ(r){return r.minRaw!==void 0||r.maxRaw!==void 0||r.stepRaw!==void 0}function S0(r,t,e){let n=Ep(r.minRaw),i=Ep(r.maxRaw),o=Ep(r.stepRaw),s={};for(let[a,l,c]of[["min",r.minRaw,n],["max",r.maxRaw,i]])l!==void 0&&(c===void 0?e(`QuickAdd: Ignoring invalid ${a} in VALUE token "${t}".`):s[a]=c);return s.min!==void 0&&s.max!==void 0&&s.max<s.min&&(e(`QuickAdd: Ignoring invalid numeric range in VALUE token "${t}"; max must be greater than or equal to min.`),delete s.min,delete s.max),r.stepRaw!==void 0&&(o===void 0||o<=0?e(`QuickAdd: Ignoring invalid step in VALUE token "${t}"; step must be greater than 0.`):s.step=o),Object.keys(s).length>0?s:void 0}function XS(r,t,e,n){if(e!=="number"&&e!=="slider")return GQ(r)&&n(`QuickAdd: Ignoring numeric range options in "${t}" because type is not number or slider.`),{inputTypeOverride:e};if(e!=="slider"){let c=S0(r,t,n);return{inputTypeOverride:e,numericConfig:c}}let i=Ep(r.minRaw),o=Ep(r.maxRaw),s=r.stepRaw===void 0?1:Ep(r.stepRaw),a=i===void 0||o===void 0?"slider requires finite min and max values":o<=i?"max must be greater than min":s===void 0||s<=0?"step must be greater than 0":void 0;if(a)return n(`QuickAdd: Invalid slider configuration in "${t}" (${a}); falling back to type:number.`),{inputTypeOverride:"number",numericConfig:S0(r,t,eg)};let l={min:i,max:o,step:s};return{inputTypeOverride:e,numericConfig:l,sliderConfig:l}}function A0(r){let t=String(r),e=/e-(\d+)$/i.exec(t);if(e)return Number(e[1]);let n=t.indexOf(".");return n===-1?0:t.length-n-1}function jQ(r,t){return String(
`)}if((!t.multiFormat||t.multiFormat==="auto")&&this.retainSingleTokenValue(t.input,t.matchStart,t.matchEnd,t.rawValue),Array.isArray(t.rawValue)&&t.multiFormat){let i=E0({input:t.input,matchStart:t.matchStart,values:t.rawValue,format:t.multiFormat});if(i!==void 0)return i}let e=this.propertyCollector.maybeCollect({...t,collectionActive:this.templatePropertyCollectionDepth>0}),n=y0(e);if(n!==void 0)return n;if(Array.isArray(t.rawValue))return $d(t.input,t.matchStart,t.matchEnd,t.rawValue.join(","))}async withTemplatePropertyCollection(t){this.templatePropertyCollectionDepth+=1;try{return await t()}finally{this.templatePropertyCollectionDepth-=1}}warnOnNamedOptionConflict(t){if(!t.aliasName||!t.hasOptions)return;let e=t.variableKey.toLowerCase(),n=JSON.stringify([t.suggestedValues,t.allowCustomInput,t.displayValues??null,t.multiSelect,t.multiEmit]),i=this.namedSuggesterOptionSigs.get(e);if(i===void 0){this.namedSuggesterOptionSigs.set(e,n);return}i!==n&&!this.namedSuggesterConflictsWarned.has(e)&&(this.namedSuggesterConflictsWarned.add(e),this.warn(`QuickAdd: named value "${t.variableKey}" is defined with different option lists; the first definition's value is reused.`))}async ensureValueVariableResolved(t){let{variableName:e,variableKey:n,label:i,defaultValue:o,allowCustomInput:s,suggestedValues:a,displayValues:l,hasOptions:c}=t;this.warnOnNamedOptionConflict(t),await this.resolveIncludingTextDate(n);let d=Yl(this.variables,n);if(d)return d;let u=this.promptScope==="propertyValue"?this.variables.get("propertyKey"):void 0,p=c?i||(typeof u=="string"?u:void 0):void 0;if(c&&t.multiSelect){let h=await this.suggestForValueMulti(a,s,{placeholder:p,variableKey:n,displayValues:l,optional:t.optional});return this.variables.set(n,t.multiEmit==="linklist"?h.map(Tw):h),n}let m="";return c?m=await this.suggestForValue(a,s,{placeholder:p,variableKey:n,displayValues:l,optional:t.optional}):m=await this.promptForVariable(e,{defaultValue:o,label:i,inputTypeOverride:t.inputTypeOverride,numericConfig:t.numericConfig,sliderConfig:t.sliderConfig,variableKey:n,optional:t.optional}),!m&&o&&!t.optional&&(m=o),this.variables.set(n,m),n}async resolveNamedSuggesterDefinitions(t){if(!/\|\s*name\s*:/i.test(t))return;let e=new RegExp(Td.source,"gi"),n=[],i;for(;(i=e.exec(t))!==null;){if(!i[1])continue;let a;try{a=Md(i[1],{warn:eg})}catch{return}a&&n.push({parsed:a,index:i.index})}let o=new Map;for(let{parsed:a,index:l}of n){if(a.hasOptions&&a.aliasName)continue;let c=a.variableKey.toLowerCase();o.has(c)||o.set(c,l)}let s=new Set;for(let{parsed:a,index:l}of n){if(!a.hasOptions||!a.aliasName)continue;let c=a.variableKey.toLowerCase();(o.get(c)??l)>=l||s.has(c)||(s.add(c),await this.ensureValueVariableResolved(a))}}async replaceVariableInString(t){let e=t;await this.resolveNamedSuggesterDefinitions(e);let n=new RegExp(Td.source,"gi"),i=this.isTemplatePropertyTypesEnabled(),o;for(;(o=n.exec(e))!==null;){if(!o[1])throw new Error(`Unable to parse variable. Invalid syntax in: "${e.substring(Math.max(0,o.index-10),Math.min(e.length,o.index+30))}..."`);let s=Md(o[1],{warn:this.warnSink});if(!s)throw new Error(`Unable to parse variable. Invalid syntax in: "${e.substring(Math.max(0,o.index-10),Math.min(e.length,o.index+30))}..."`);let{variableName:a}=s,l=await this.ensureValueVariableResolved(s),c=this.variables.get(l),d=this.applyValueTokenOptions(c,s);this.singleTokenValue&&(!s.multiFormat||s.multiFormat==="auto")&&this.retainSingleTokenValue(e,o.index,o.index+o[0].length,this.propertyTokenValue(d,s.inputTypeOverride));let u=this.renderCollectedOrArrayValue({input:e,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:this.singleTokenValue?.result?this.singleTokenValue.result.value:d,fallbackKey:a,heuristicEnabled:i&&this.templatePropertyCollectionDepth>0&&s.inputTypeOverride!=="text",multiFormat:s.multiFormat}),p,m=!1;if(u!==void 0)p=u;else{let v=String(this.applyValueTextOptions(this.getValueTokenText(l),s)??"");s.inputTypeOverride==="text"&&v!==""&&jS(e,o.index,o.index+o[0].length)?p=Zh(v):o3.has(s.inputTypeOverride??"")&&GS(e,o.index,o.index+o[0].leng
`)}var Pp=x(()=>{});var Dw,fg,Eo,lA=x(()=>{Dw=class{isResolved(){return!this.hasConflicts}isConflicted(){return this.hasConflicts}},fg=class r extends Dw{constructor(t,e,n){super(),this.left=t,this.base=e,this.right=n,this.hasConflicts=!0}static create(t){return new r(t.left,t.base,t.right)}apply(t){return r.create({left:t(this.left),base:t(this.base),right:t(this.right)})}},Eo=class r extends Dw{constructor(t){super(),this.hasConflicts=!1,this.result=t}combine(t){this.result=this.result.concat(t.result)}apply(t){return new r(t(this.result))}}});var La,cA,$p,dA,uA,Ls,hg,Lw,Nw=x(()=>{La=class r{constructor(t,e){this.left=t,this.right=e}static executeDiff(t,e){if(!t.push)throw new Error("Argument is not an array");let n=r.diff(t,e);return new dA(t,e,n).convertToTypedOutput()}static diff(t,e){return new r(t,e).performDiff()}performDiff(){let t=this.identifyUniquePositions();t.sort((o,s)=>s[0]-o[0]);let[e,n]=this.findNextChange(),i=new Lw(e,n,[]);return t.forEach(o=>{i=this.getDifferences(i,o)}),i.changeRanges}getDifferences(t,e){let[n,i]=[t.leftChangePos,t.rightChangePos],[o,s]=e;if(o<n||s<i)return t;{let[a,l,c,d]=this.findPrevChange(n,i,o-1,s-1),[u,p]=this.findNextChange(o+1,s+1),m=this.appendChangeRange(t.changeRanges,a,l,c,d);return new Lw(u,p,m)}}findNextChange(t=0,e=0){let n=this.left.slice(t)||[],i=this.right.slice(e)||[],o=this.mismatchOffset(n,i);return[t+o,e+o]}findPrevChange(t,e,n,i){if(t>n||e>i)return[t,n,e,i];{let o=this.left.slice(t,n+1).reverse()||[],s=this.right.slice(e,i+1).reverse()||[],a=this.mismatchOffset(o,s);return[t,n-a,e,i-a]}}mismatchOffset(t,e){let n=Math.max(t.length,e.length);for(let i=0;i<n;i++)if(t[i]!==e[i])return i;return Math.min(t.length,e.length)}identifyUniquePositions(){let t=this.findUnique(this.left),e=this.findUnique(this.right),n=new Set(...t.keys()),i=new Set(...e.keys()),s=[...new Set([...n].filter(a=>i.has(a)))].map(a=>[t.get(a),e.get(a)]);return s.unshift([this.left.length,this.right.length]),s}findUnique(t){let e=new Map;t.forEach((i,o)=>{e.set(i,new cA(o,!e.has(i)))});let n=new Map;for(let[i,o]of e.entries())o.unique&&n.set(i,o.pos);return n}appendChangeRange(t,e,n,i,o){return e<=n&&i<=o?t.push(new hg(Ls.change,e+1,n+1,i+1,o+1)):e<=n?t.push(new hg(Ls.remove,e+1,n+1,i+1,i)):i<=o&&t.push(new hg(Ls.add,e+1,e,i+1,o+1)),t}},cA=class{constructor(t,e){this.pos=t,this.unique=e}},$p=class{constructor(t,e){this.text=t,this.low=e}},dA=class{constructor(t,e,n){this.oldTextArray=t,this.newTextArray=e,this.chunks=n,this.oldText=[],this.newText=[]}convertToTypedOutput(){let t=new uA(0,0);return this.chunks.forEach(e=>{let[n,i]=this.setTextNodeIndexes(e,t.oldIndex,t.newIndex),[o,s]=this.appendChanges(e,t.oldIndex+n,t.newIndex+i);t.oldIndex=o,t.newIndex=s}),this.setTheRemainingTextNodeIndexes(t.oldIndex,t.newIndex),{oldText:this.oldText,newText:this.newText}}setTextNodeIndexes(t,e,n){let i=0;for(;e+i<t.leftLo-1;)this.oldText.push(new $p(this.oldTextArray[e+i],n+i)),i+=1;let o=0;for(;n+o<t.rightLo-1;)this.newText.push(new $p(this.newTextArray[n+o],e+o)),o+=1;return[i,o]}appendChanges(t,e,n){for(;e<=t.leftHi-1;)this.oldText.push(this.oldTextArray[e]),e+=1;for(;n<=t.rightHi-1;)this.newText.push(this.newTextArray[n]),n+=1;return[e,n]}setTheRemainingTextNodeIndexes(t,e){let n=0;for(;t+n<this.oldTextArray.length;)this.oldText.push(new $p(this.oldTextArray[t+n],e+n)),n+=1;for(;e+n<this.newTextArray.length;)this.newText.push(new $p(this.newTextArray[e+n],t+n)),n+=1}},uA=class{constructor(t,e){this.oldIndex=t,this.newIndex=e}};(function(r){r.change="change",r.add="add",r.remove="remove"})(Ls||(Ls={}));hg=class{constructor(t,e,n,i,o){this.action=t,this.leftLo=e,this.leftHi=n,this.rightLo=i,this.rightHi=o}},Lw=class{constructor(t,e,n){this.leftChangePos=t,this.rightChangePos=e,this.changeRanges=n}}});var Vw,Fp,pA,Na,Nr,Bw,mA=x(()=>{Nw();Vw=class r{constructor(t,e,n,i,o){this.code=t,this.baseLo=e,this.baseHi=n,this.sideLo=i,this.sideHi=o}static fromChangeRange(t){return new r(t.action,t.leftLo,t.leftHi,t.rightLo,t.rightHi)}},Fp=class r{constructor(t,e,n){this.left=t,this.base=e,this.right=n}static execute
`)}}).join(`
`)}}var aL=x(()=>{});function hA(r,t,e,n={}){n=Object.assign({},A3,n);let[i,o,s]=[r,t,e].map(c=>n.splitFunction.call(n,c)),a=gg.merge(i,o,s);return vg.collateMerge(a,n.joinFunction,n.conflictFunction)}var lL,k3,S3,A3,cL=x(()=>{nL();oL();aL();lL=r=>r.join(""),k3=r=>r.split(/\b/),S3=sL("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",lL),A3={splitFunction:k3,joinFunction:lL,conflictFunction:S3}});var dL,uL=x(()=>{cL();mA();Nw();dL=hA});function Vr(r,t){if(!r)throw new Error(typeof t=="function"?t():t)}var Nd=x(()=>{});function vA(r,t){let e=i=>i instanceof gA.MarkdownView&&i.file===t&&!!i.editor&&i.getMode()==="source",n=r.workspace.getActiveViewOfType(gA.MarkdownView);return e(n)?n:r.workspace.getLeavesOfType("markdown").map(i=>i.view).find(e)??null}async function pL(r,t){let e=vA(r,t);e&&await yA(e)}async function Bd(r,t){return await pL(r,t),r.vault.read(t)}async function To(r,t,e){let n=vA(r,t);if(n){await yA(n);let i=await r.vault.read(t),{editor:o}=n,s=o.getValue();if(vA(r,t)===n&&s===Vd(i)){let a=Vd(e(s)),l=P3(s,a);return l&&(o.transaction({changes:[{from:o.offsetToPos(l.from),to:o.offsetToPos(l.to),text:l.text}]}),await yA(n).catch(c=>S.logWarning(`Could not save '${t.path}' yet: ${String(c)}`))),a}}return r.vault.process(t,e)}async function mL(r,t,e,n){let i=!1;return{content:await To(r,t,s=>{if(Vd(s)===Vd(e))return n;let a=dL(Vd(s),Vd(e),Vd(n));return Vr(a.isSuccess(),()=>`The file ${t.path} has been modified since the last read.
QuickAdd could not merge the two versions without conflicts, and will not modify the file.
This is in order to prevent data loss.`),i=!0,a.joinedResults()}),merged:i}}async function Va(r,t,e){await pL(r,t),await r.fileManager.processFrontMatter(t,e)}async function yA(r){await r.save();let t=()=>r.saving===!0;for(let e=0;t();e+=10){if(e>=I3)throw new Error(`Obsidian is still saving '${r.file?.path}'. Try again once it has saved.`);await Ow(10)}}function P3(r,t){if(r===t)return null;let e=Math.min(r.length,t.length),n=0;for(;n<e&&r.charCodeAt(n)===t.charCodeAt(n);)n++;let i=0;for(;i<e-n&&r.charCodeAt(r.length-1-i)===t.charCodeAt(t.length-1-i);)i++;return{from:n,to:r.length-i,text:t.slice(n,t.length-i)}}function Vd(r){return r.includes("\r")?r.replace(/\r\n?/g,`
`):r}var gA,I3,Ns=x(()=>{gA=require("obsidian");Pp();uL();Nd();ye();I3=1e4});function Mp(r){return $3.has(r)}function Ba(r){return r==="inFrontmatter"}function Uw(r){return F3.has(r)}function M3(r,t,e){return r==="embed"&&e.type==="activeFile"&&Mp(t)?"embed":"link"}function R3(r,t,e,n){return r==="selection"&&e.type==="activeFile"&&Uw(t)&&n==="link"?"selection":"none"}function O3(r){return r?.type==="specifiedFile"?{type:"specifiedFile",path:typeof r.path=="string"?r.path.trim():""}:{type:"activeFile"}}function D3(r){return typeof r=="object"&&r!==null&&"enabled"in r&&"placement"in r}function Zo(r){if(D3(r)){let t=r.placement??"replaceSelection",e=O3(r.destination),n=M3(r.linkType,t,e);return{enabled:r.enabled,placement:t,requireActiveFile:r.requireActiveFile??!0,linkType:n,displayText:R3(r.displayText,t,e,n),destination:e,frontmatterProperty:r.frontmatterProperty,frontmatterHandling:Ba(t)?r.frontmatterHandling??Ud:r.frontmatterHandling}}return{enabled:r,placement:"replaceSelection",requireActiveFile:!!r,linkType:"link",displayText:"none",destination:{type:"activeFile"}}}var Ud,$3,F3,Ua=x(()=>{Ud="alwaysAppend",$3=new Set(["replaceSelection","afterSelection","endOfLine","newLine"]);F3=new Set(["replaceSelection","afterSelection"])});function bA(r){return r.vault.getConfig?.("useMarkdownLinks")===!0}function L3(r,t){let e=t.replace(/\s+/g,n=>/[\r\n]/.test(n)?" ":n).trim();if(e){if(bA(r))return e.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(!(e.includes("]]")||e.includes("[[")||e.endsWith("]")))return e}}function N3(r){return`[[${r.path.replace(/\.md$/i,"")}]]`}function qw(r,t,e={}){let n=e.sourcePath??"";if(e.linkType==="embed"&&(!e.placement||Mp(e.placement)))return`![[${r.metadataCache.fileToLinktext(t,n)}]]`;let o=e.alias===void 0?void 0:L3(r,e.alias);return o===void 0?r.fileManager.generateMarkdownLink(t,n):r.fileManager.generateMarkdownLink(t,n,void 0,o)}function wA(r){let t=r.trim().replace(/^\/+/,"");return t?/\.md$/i.test(t)?t:`${t}.md`:""}function bg(r,t){if(t.type!=="specifiedFile")return null;let e=wA(t.path);if(!e)return null;let n=r.vault.getAbstractFileByPath(e);return!(n instanceof yg.TFile)||n.extension!=="md"?null:n}function V3(r,t){return r.length===0?t:r.endsWith(`
`)?`${r}${t}`:`${r}
${t}`}async function hL(r,t,e,n){let i=e.destination;if(i?.type!=="specifiedFile")return!1;let o=bg(r,i);if(!o)throw new Error(`Append link target file not found or is not a Markdown file: ${i.path}`);return await CA(r,o,qw(r,t,{sourcePath:o.path,linkType:"link"}),n),!0}async function CA(r,t,e,n){let i;await To(r,t,o=>{let s=V3(o,e);return i={filePath:t.path,before:o,after:s,edits:[{from:o.length,to:o.length,text:s.slice(o.length)}]},s}),i&&n?.(i)}async function B3(r){let t=window.navigator?.clipboard;if(!t?.writeText)return S.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await t.writeText(r),!0}catch(e){return S.logMessage(`QuickAdd: Could not copy link to clipboard: ${e instanceof Error?e.message:String(e)}`),!1}}async function gL(r){let t=N3(r);return await B3(t)?(new yg.Notice(`Copied link to '${r.basename}' to clipboard.`,fL),!0):(new yg.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,fL),!1)}var yg,fL,qd=x(()=>{yg=require("obsidian");Ns();ye();Ua();fL=4e3});function Rp(r){return r&&typeof r=="object"?r:void 0}function xA(r){return typeof r=="string"?r.trim():""}function vL(r){return r.replace(/[\\/]+/g,"/").replace(/^\/|\/$/g,"")}function yL(r){return`{{${r.toUpperCase()}}}`}function bL(r,t,e){return{source:r,folder:vL(xA(e.folder)),format:xA(e.format)||U3[t],template:vL(xA(e.template))}}function Hw(r,t){let e=Rp(Rp(r?.plugins?.plugins?.["periodic-notes"])?.settings);if(e&&"calendarSets"in e)throw new Error(`${yL(t)} can't read the settings of Periodic Notes 1.0. Use Periodic Notes 0.0.17, or turn it off and use the Daily notes core plugin.`);let n=Rp(e?.[t]);if(n?.enabled===!0)return bL("periodic-notes",t,n);if(t!=="daily")throw new Error(`${yL(t)} needs the Periodic Notes plugin with ${t} notes turned on.`);let i=Rp(r?.internalPlugins?.plugins?.["daily-notes"]);if(i?.enabled===!0)return bL("daily-notes",t,Rp(Rp(i.instance)?.options)??{});throw new Error("{{DAILY}} needs the Daily notes core plugin, or Periodic Notes with daily notes, turned on.")}function wL(r,t){return t.clone().startOf(q3[r])}function CL(r,t,e){let n=wL(t,e).format(r.format).trim().replace(/\.md$/i,"");if(!n)throw new Error(`The ${t} note format "${r.format}" gives an empty file name.`);return r.folder?`${r.folder}/${n}`:n}function xL(r,t,e){let n=r.vault.getAbstractFileByPath(`${t}.md`);if(n instanceof zw.TFile)return r.fileManager.generateMarkdownLink(n,e);if(!bA(r))return`[[${t}]]`;let i=encodeURI(`${t}.md`).replace(/\(/g,"%28").replace(/\)/g,"%29");return`[${(t.split("/").pop()??t).replace(/[\\[\]]/g,"\\$&")}](${i})`}async function EL(r,t,e){let{template:n}=t;if(!n)return null;let i=r.vault.getAbstractFileByPath(n),o=t.source==="periodic-notes"?r.metadataCache.getFirstLinkpathDest(n,""):i instanceof zw.TFile?i:r.vault.getAbstractFileByPath(`${n}.md`);if(!(o instanceof zw.TFile)){let s=t.source==="daily-notes"?"Daily notes":"Periodic Notes";throw new Error(`The ${e} note template "${n}" doesn't exist. Fix it in Settings \u2192 ${s}.`)}return r.vault.cachedRead(o)}function EA(r,t,e,n){return r.replace(/{{\s*(date|time)\s*(([+-]\d+)([yqmwdhs]))?\s*(:.+?)?}}/gi,(i,o,s,a,l,c)=>{let d=t.clone().set({hour:e.hour(),minute:e.minute(),second:e.second()});return s&&a&&l&&d.add(parseInt(a,10),l),c?d.format(c.substring(1).trim()):d.format(n)})}function TL(r,t,e,n,i){let{format:o}=t,s=wL(e,n);if(t.source==="daily-notes"){let c=s.format(o).trim();return r.replace(/{{(date|time|title)(?::([^}]*))?}}/gi,(d,u,p)=>{let m=u.toLowerCase();return m==="title"?p===void 0?c:d:i.format(p||(m==="date"?"YYYY-MM-DD":"HH:mm"))})}let a=s.format(o),l=i.format("HH:mm");if(e==="daily")return EA(r.replace(/{{\s*date\s*}}/gi,a).replace(/{{\s*time\s*}}/gi,l).replace(/{{\s*title\s*}}/gi,a),s,i,o).replace(/{{\s*yesterday\s*}}/gi,s.clone().subtract(1,"day").format(o)).replace(/{{\s*tomorrow\s*}}/gi,s.clone().add(1,"d").format(o));if(e==="weekly"){let c=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"],d=s.localeData().firstDayOfWeek(),u=[...c.slice(d),...c.slice(0,d)];return EA(r,s,i,o).replace
`)}if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return String(r);throw new Error("{{PROPERTY}} only expands text, finite numbers, checkboxes, and lists of text.")}function FL(r){return $L.map(t=>({key:t,present:r.has(t),value:r.get(t)}))}function ML(r,t){for(let e of t)e.present?r.set(e.key,e.value):r.delete(e.key)}function RL(r,t,e){for(let i of $L)if(!(!r.has(i)||r.get(i)===void 0))throw new Error(`Property Capture cannot seed '${i}' because that variable is already set. Rename your {{VALUE:${i}}} prompt (or other writer of this key) so it does not collide with the property snapshot.`);let n;e!=null&&(n=z3(e,t)),r.set("propertyKey",t),r.set("propertyValue",n),r.set("list",Array.isArray(n)?[...n]:[])}function z3(r,t){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(e=>typeof e=="string"))return[...r];throw new Error(`Property '${t}' supports text, finite numbers, checkboxes, and lists of text only.`)}function wg(r,t){if(Object.prototype.hasOwnProperty.call(r,t))return t;let e=Object.keys(r).filter(n=>n.trim().toLowerCase()===t.trim().toLowerCase());if(e.length>1)throw new Error(`Property '${t}' matches multiple properties in the target note.`);return e[0]??t}function OL(r){return r.split(/\r?\n/).map(t=>t.trim()).filter(t=>t!=="")}function DL(r){return typeof r=="string"?OL(r).length===0:Array.isArray(r)&&r.length===0}function SL(r,t){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(e=>typeof e=="string"))return[...r];throw new Error(`Property '${t}' supports text, finite numbers, checkboxes, and lists of text only.`)}function LL(r,t){if(r===null&&["tags","aliases","cssclasses"].includes(t.toLowerCase()))return"list";if(r===null)return null;switch(r.toLowerCase()){case"text":return"text";case"number":return"number";case"checkbox":case"boolean":return"checkbox";case"list":case"multitext":case"tags":case"aliases":return"list";case"date":return"date";case"datetime":return"datetime";default:throw new Error(`Property '${t}' has unsupported type '${r}'.`)}}function NL(r){if(r.action==="addToList")return!0;let t=LL(r.registeredType,r.key);return t==="list"||t===null&&Array.isArray(r.existing)}function Ww(r){return Array.isArray(r)?"list":typeof r=="boolean"?"checkbox":typeof r=="number"?"number":"text"}function H3(r,t,e){let n=Ww(r);if(t==="date"||t==="datetime"){if(typeof r=="string"&&(r===""||(t==="date"?/^\d{4}-\d{2}-\d{2}$/:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?$/).test(r)&&Number.isFinite(Date.parse(r))&&new Date(r.slice(0,10)).toISOString().slice(0,10)===r.slice(0,10)))return}else if(n===t)return;throw new Error(`Property '${e}' requires ${t}; the capture is ${n}. Use a matching typed VALUE token or value.`)}function VL(r){let{frontmatter:t,config:e}=r,n=wg(t,r.key),i=Object.prototype.hasOwnProperty.call(t,n);if(!i&&!e.createIfMissing)throw new Error(`Property '${n}' is missing. Enable 'Create property if missing' to add it.`);let o=i?t[n]:void 0,s=SL(r.value,n),a=o==null?null:SL(o,n),l=LL(r.registeredType,n)??(a===null?null:Ww(a)),c=typeof s=="string"?OL(s):null;if(e.action==="addToList"){if(a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' is ${Ww(a)}. 'Add to list' requires a list.`);if(l!==null&&l!=="list")throw new Error(`Property '${n}' is ${l}. 'Add to list' requires a list.`);let u=c??s;if(!Array.isArray(u))throw new Error(`Property '${n}' requires text or a list of text to add.`);return u.length===0?a??[]:r.compose?[...new Set(u)]:[...new Set([...a??[],...u])]}if(l==="list"&&a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' contains ${Ww(a)}. Set a list only after correcting the existing property to a list.`);if(l===null&&c!==null&&c.length>1)throw new Error(`Property '${n}' has no type yet, so ${c.length} lines could be one text value or a list. Use 'Add to list' to write them as list items, or set the property's type in Obsidian first - Text keeps the lines as one value.`);
${(0,zd.stringifyYaml)(t)}---
${n}`}var zd,$L,kA=x(()=>{zd=require("obsidian");Le();$L=["propertyKey","propertyValue","list"]});var qL,Gw,ec,Op=x(()=>{nA();Rd();Rd();Oa();sA();qL=require("obsidian");Le();Ln();rL();_A();ye();Cw();Da();kL();kA();nA();Oa();Gw=10,ec=class extends kw{constructor(){super(...arguments);this.linkToCurrentFileBehavior="required";this.targetFolderPath=null;this.periodicNoteTarget=null;this.propertyTokenExpanded=!1}runClocks(){return this.clocks}setTemplateInclusionState(e){this.templateInclusion=e}replaceDateInString(e){let n=N0(e,{clocks:()=>this.runClocks(),applyCase:(i,o,s)=>this.applyCaseOption(i,o,s)});return TA.test(n)?this.replacePeriodicNotesInString(n):n}outermostIncluder(){return this.templateInclusion?.includer?.outermostIncluder()??this}replacePeriodicNotesInString(e){let n=this.runClocks(),i=window.moment(n?.date??n?.now),o=new RegExp(TA.source,"gi");return e.replace(o,(s,a,l)=>{let c=a.toLowerCase(),d=CL(Hw(this.app,c),c,i);return l&&this.app?xL(this.app,d,this.getLinkSourcePath()??""):(this.promptScope==="captureTarget"&&(this.outermostIncluder().periodicNoteTarget={path:d,period:c}),d)})}replaceTimeInString(e){return V0(e,{clocks:()=>this.runClocks(),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}async replaceSelectedInString(e){if(!Oh.test(e))return e;let n=await this.getSelectedText(),i=new RegExp(Oh.source,"gi"),o=this.userText(n);return e.replace(i,()=>o)}async replaceClipboardInString(e){if(!TS.test(e))return e;let n=await this.getClipboardContent(),i=new RegExp(TS.source,"gi"),o=this.userText(n);return e.replace(i,()=>o)}async replaceLinkToCurrentFileInString(e){if(!xS.test(e))return e;let n=this.getCurrentFileLink();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");S.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.")}let i=new RegExp(xS.source,"gi");return e.replace(i,()=>n??"")}replaceLinkToCurrentSectionInString(e){if(!ES.test(e))return e;let n=this.getCurrentFileLinkToSection();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");S.logMessage("Skipping {{LINKSECTION}} replacement because no active file is available.")}let i=new RegExp(ES.source,"gi");return e.replace(i,()=>n??"")}replaceCurrentFileLinksInString(e){return this.replaceCurrentFileTokensInString(e,{links:!0})}replaceCurrentFileTokensInString(e,n){return W0(e,n,{LINKCURRENT:()=>this.getCurrentFileLink(),LINKSECTION:()=>this.getCurrentFileLinkToSection(),FILENAMECURRENT:()=>this.getCurrentFileName(),FOLDER:()=>this.targetFolderPath??"",FOLDERCURRENT:()=>this.getCurrentFolderPath(),TITLE:()=>this.getVariableValue("title")},this.linkToCurrentFileBehavior)}async replaceCurrentFileNameInString(e){return this.replaceCurrentFileTokensInString(e,{fileName:!0})}setLinkToCurrentFileBehavior(e){this.linkToCurrentFileBehavior=e}setTargetFolderPath(e){if(e==null){this.targetFolderPath=null;return}let n=e.trim();this.targetFolderPath=n==="/"?"":n.replace(/^\/+/,"").replace(/\/+$/,"")}replaceTargetFolderInString(e){return this.replaceCurrentFileTokensInString(e,{folder:!0})}getCurrentFileLinkToSection(){return null}getCurrentFolderPath(){return null}async replaceFieldVarInString(e){let n=new RegExp(dp.source,"gi"),i="",o=0,s;for(;(s=n.exec(e))!==null;){i+=e.slice(o,s.index);let a=s[1]+(s[2]||"");if(a){let l=this.getFieldVariableKey(a),c=Dn.parse(a,{warnUnknown:!0,warn:this.warnSink});this.hasConcreteVariable(l)||this.variables.set(l,await this.suggestForField(a,c));let d=this.hasConcreteVariable(l)?this.variables.get(l):this.getVariableValue(l);(!c.multiFormat||c.multiFormat==="auto")&&this.retainSingleTokenValue(e,s.index,s.index+s[0].length,d);let u;Array.isArray(d)?u=this.renderCollectedOrArrayValue({input:e,matchStart:s.index,matchEnd:s.index+s[0].length,rawValue:d,fallbackKey:c.fieldName,heuristicEnabled:!1,multiFormat:c.multiFormat??"auto"})??d.join(","):u=$d(e,s.index,s.index+s[0].length,String(d??"")),i+=this.
`,i++):s=="\\"?(n+="\\",i++):n+="\\":n+=o}return n}expandLinebreakEscapesOutsideTokens(e){let n=yi(e),i="",o=0,s=0;for(;o<e.length;){for(;s<n.length&&n[s].end<=o;)s++;let a=n[s];if(a&&a.start===o){i+=e.slice(a.start,a.end),o=a.end;continue}if(e[o]==="{"&&e[o+1]==="{"){let d=e.indexOf("}}",o+2),u=!1;if(d!==-1){let p=d+2;for(let m=s;m<n.length;m++){let h=n[m];if(h.start>=p)break;if(p<h.end&&p>h.start){u=!0;break}}}if(d!==-1&&!u){i+=e.slice(o,d+2),o=d+2;continue}}let l=e[o],c=e[o+1];l==="\\"?c==="n"?(i+=`
`,o+=2):c==="\\"?(i+="\\",o+=2):(i+="\\",o+=1):(i+=l,o+=1)}return i}replaceRandomInString(e){let n=e;for(;_S.test(n);){let i=_S.exec(n);if(!i||!i[1])continue;let o=parseInt(i[1]);if(o<=0||o>100)throw new Error(`Random string length must be between 1 and 100. Got: ${o}`);let s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a="";for(let l=0;l<o;l++)a+=s.charAt(Math.floor(Math.random()*s.length));n=n.replace(i[0],a)}return n}replaceTitleInString(e){return this.replaceCurrentFileTokensInString(e,{title:!0})}consumePropertyTokenExpanded(){let e=this.propertyTokenExpanded;return this.propertyTokenExpanded=!1,e}replacePropertyInString(e){if(!Rh.test(e))return e;if(this.promptScope!=="propertyValue")throw new Error("{{PROPERTY}} can only be used in a property Capture format.");this.propertyTokenExpanded=!0;let n=this.variables.get("propertyValue");/^{{PROPERTY}}$/i.test(e.trim())&&e.trim()===e&&this.retainSingleTokenValue(e,0,e.length,n===void 0?"":n);let i=this.userText(PL(n));return e.replace(new RegExp(Rh.source,"gi"),()=>i)}}});function HL(r){return r<=31||r===127||r===8232||r===8233}function j3(r){let t="",e=0;for(;e<r.length;){let n=e;for(;n<r.length&&r.charCodeAt(n)===32;)n++;if(n<r.length&&HL(r.charCodeAt(n))){for(;n<r.length&&HL(r.charCodeAt(n));)n++;for(;n<r.length&&r.charCodeAt(n)===32;)n++;t+=" ",e=n;continue}t+=r.slice(e,Math.min(n+1,r.length)),e=n+1}return t}function WL(r,t){let e=r.length;for(;e>0&&t.includes(r[e-1]);)e--;return r.slice(0,e)}function Hd(r){return Y3.filter(t=>r.includes(t))}function jL(r){return`A file or folder name cannot contain ${QL(r)}, so this choice would fail at run time. ${KL}`}function YL(r,t){return`Cannot create "${t}": a file or folder name cannot contain ${QL(r)}. ${KL}`}function QL(r){return r.map(t=>`"${t}"`).join(", ")}function Br(r,t="File path"){let{path:e,problems:n}=JL(r,t);if(n.length>0)throw new Error(n[0]);return e}function XL(r,t="File path"){return JL(r,t)}function JL(r,t){let e=[],n=r.replace(/\\/g,"/").split("/");return{path:n.map((o,s)=>o.length===0&&s!==0&&s!==n.length-1?(e.push(`${t} contains an empty path segment after formatting.`),o):K3(o,t,e)).join("/"),problems:e}}function K3(r,t,e){if(r.length===0)return r;let n=W3.test(r),i=G3.test(r),o=j3(r);n&&(o=o.replace(/^ /u,"")),i&&(o=o.replace(/ $/u,""));let s=WL(o," ");return s==="."||s===".."?(e.push(`${t} cannot contain "." or ".." path segments.`),s):(o=WL(o,". "),o||e.push(`${t} contains an empty path segment after formatting.`),o)}var GL,W3,G3,Y3,KL,es=x(()=>{GL="\0-\x7F\u2028\u2029",W3=new RegExp(`^ *[${GL}]`,"u"),G3=new RegExp(`[${GL}] *$`,"u");Y3=[":"];KL="Check your own text and tokens like {{TIME}}, which is HH:mm."});function Np(r){if(r==null||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return"";let t=String(r).trim();return t.startsWith("#")?t.substring(1).trim():t}function xg(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(Np).filter(Boolean)}var IA=x(()=>{});var Vs,jw=x(()=>{IA();Vs=class{static filterFiles(t,e,n){let i=this.applyInclusionFilters(t,e,n);return this.applyExclusionFilters(i,e,n)}static applyInclusionFilters(t,e,n){let i=t,o=this.getIncludeFolders(e);return o.length>0&&(i=i.filter(s=>o.some(a=>this.matchesFolder(s,a)))),e.tags&&e.tags.length>0&&(i=i.filter(s=>this.matchesTags(s,e.tags??[],n,"all"))),i}static applyExclusionFilters(t,e,n){return t.filter(i=>!(e.excludeFolders?.length&&e.excludeFolders.some(o=>this.matchesFolder(i,o)))&&!(e.excludeTags?.length&&this.matchesTags(i,e.excludeTags,n,"any"))&&!(e.excludeFiles?.length&&e.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(t){let e=t.folders?.length?t.folders:t.folder?[t.folder]:[];return[...new Set(e.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(t,e){let n=this.normalizePath(e),i=this.normalizePath(t.path);return i.startsWith(n+"/")||i.substring(0,i.lastIndexOf("/"))===n}static matchesTags(t,e,n,i){let o=n(t);if(!o)return!1;let s=this.getAllTags(o),a=e.map(Np).filter(Boolean),l=c=>s.some(d=>d===c||d.startsWith(c+"/"));
tags: ${JSON.stringify(Array.from(this._tags).sort())},
knownValues: ${JSON.stringify(this.knownValues)},
impliedValues: ${JSON.stringify(this.impliedValues)}},
reference: ${JSON.stringify(this.reference)}]`}date(){let t=this.get("timezoneOffset")??this.reference.timezoneOffset;if(t==null)return this.dateWithoutTimezoneAdjustment();let e=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return e.setUTCFullYear(this.get("year")),new Date(e.getTime()-t*6e4)}addTag(t){return this._tags.add(t),this}addTags(t){for(let e of t)this._tags.add(e);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let t=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return t.setFullYear(this.get("year")),t}},ja=class r{constructor(t,e,n,i,o){fe(this,"refDate");fe(this,"index");fe(this,"text");fe(this,"reference");fe(this,"start");fe(this,"end");this.reference=t,this.refDate=t.instant,this.index=e,this.text=n,this.start=i||new mt(t),this.end=o}clone(){let t=new r(this.reference,this.index,this.text);return t.start=this.start?this.start.clone():null,t.end=this.end?this.end.clone():null,t}date(){return this.start.date()}addTag(t){return this.start.addTag(t),this.end&&this.end.addTag(t),this}addTags(t){return this.start.addTags(t),this.end&&this.end.addTags(t),this}tags(){let t=new Set(this.start.tags());if(this.end)for(let e of this.end.tags())t.add(e);return t}toString(){let t=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(t)} ...}]`}}});function FA(r,t,e="\\s{0,5},?\\s{0,5}"){let n=t.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${e}${n}){0,10}`}function o4(r){let t;return r instanceof Array?t=[...r]:r instanceof Map?t=Array.from(r.keys()):t=Object.keys(r),t}function Ur(r){return`(?:${o4(r).sort((e,n)=>n.length-e.length).join("|").replace(/\./g,"\\.")})`}var Ya=x(()=>{});function Jw(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function sc(r,t,e){let n=new Date(r);n.setMonth(e-1),n.setDate(t);let i=cn(n,{year:1}),o=cn(n,{year:-1});return Math.abs(i.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())?n=i:Math.abs(o.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())&&(n=o),n.getFullYear()}var Up=x(()=>{Ga()});function s4(r){let t=r.toLowerCase();return MA[t]!==void 0?MA[t]:t==="a"||t==="an"||t=="the"?1:t.match(/few/)?3:t.match(/half/)?.5:t.match(/couple/)?2:t.match(/several/)?7:parseFloat(t)}function zp(r){let t=r.toLowerCase();return RA[t]!==void 0?RA[t]:(t=t.replace(/(?:st|nd|rd|th)$/i,""),parseInt(t))}function Bs(r){if(/BE/i.test(r))return r=r.replace(/BE/i,""),parseInt(r)-543;if(/BCE?/i.test(r))return r=r.replace(/BCE?/i,""),-parseInt(r);if(/(AD|CE)/i.test(r))return r=r.replace(/(AD|CE)/i,""),parseInt(r);let t=parseInt(r);return Jw(t)}function _o(r){let t={},e=r,n=pN.exec(e);for(;n;)l4(t,n),e=e.substring(n[0].length).trim(),n=pN.exec(e);return Object.keys(t).length==0?null:t}function l4(r,t){if(t[0].match(/^[a-zA-Z]+$/))return;let e=s4(t[1]),n=kg[t[2].toLowerCase()];r[n]=e}var Zw,OA,ii,MA,RA,mN,kg,fN,qp,ac,hN,pN,a4,gN,Ka,lc,fr=x(()=>{Ya();Up();Zw={sunday:0,sun:0,"sun.":0,monday:1,mon:1,"mon.":1,tuesday:2,tue:2,"tue.":2,wednesday:3,wed:3,"wed.":3,thursday:4,thurs:4,"thurs.":4,thur:4,"thur.":4,thu:4,"thu.":4,friday:5,fri:5,"fri.":5,saturday:6,sat:6,"sat.":6},OA={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},ii={...OA,jan:1,"jan.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,jun:6,"jun.":6,jul:7,"jul.":7,aug:8,"aug.":8,sep:9,"sep.":9,sept:9,"sept.":9,oct:10,"oct.":10,nov:11,"nov.":11,dec:12,"dec.":12},MA={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},RA={first:1,second:2,third:3,fourth:4,fifth:5,sixth:6,seventh:7,eighth:8,ninth:9,tenth:10,eleventh:11,twelfth:12,thirteenth:13,fourteenth:14,fifteenth:15,sixteenth:16,seventeenth:17,eighteenth:18,nineteenth:19,twentieth:20,"twenty first":21,"twenty-first":21,"twenty second":22,"twenty-second":22,"twenty third":23,"twenty-third":23,"twen
`,t),l=a===-1?r.length:a,c=r.slice(t,l).replace(/\r$/,""),d=a===-1?r.length+1:a+1,u=h8.exec(c);if(n){if(u&&u[1].length>=i&&u[2].trim().length===0)return nB(r.slice(o,t),s)}else if(u){let p=u[2].trim().split(/\s+/)[0]?.toLowerCase();(p==="js"||p==="javascript")&&(n=!0,i=u[1].length,o=d,s=e+1)}if(t=d,e++,a===-1)break}return n?nB(r.slice(o),s):{code:null,error:g8}}function nB(r,t){return r.trim().length===0?{code:"",error:v8}:{code:`
`.repeat(t)+r}}var h8,g8,v8,_m=x(()=>{h8=/^ {0,3}(`{3,})(.*)$/,g8="No ```js (or ```javascript) code block found in the note.",v8="The ```js code block is empty."});function as(r,t){let e=t;for(;e<r.length;){let n=r[e],i=r[e+1];if(/\s/.test(n)){e+=1;continue}if(n==="/"&&i==="/"){let o=r.indexOf(`
`,e+2);e=o===-1?r.length:o+1;continue}if(n==="/"&&i==="*"){let o=r.indexOf("*/",e+2);e=o===-1?r.length:o+2;continue}return e}return e}function Ov(r,t){let e=r[t];if(e!=='"'&&e!=="'"&&e!=="`")return null;let n="";for(let i=t+1;i<r.length;i++){let o=r[i];if(o==="\\"){let s=r[i+1];if(s===void 0)return null;n+=s,i+=1;continue}if(o===e)return{value:n,end:i+1};n+=o}return null}function iB(r,t){let e=/^[A-Za-z_$][\w$]*/.exec(r.slice(t));return e?{value:e[0],end:t+e[0].length}:null}function XC(r,t,e,n){let i=0;for(let o=t;o<r.length;o++){let s=r[o],a=r[o+1];if(s==='"'||s==="'"||s==="`"){let l=Ov(r,o);if(!l)return-1;o=l.end-1;continue}if(s==="/"&&a==="/"){let l=r.indexOf(`
`,o+2);o=l===-1?r.length:l;continue}if(s==="/"&&a==="*"){let l=r.indexOf("*/",o+2);if(l===-1)return-1;o=l+1;continue}if(s===e){i+=1;continue}if(s===n&&(i-=1,i===0))return o}return-1}function oB(r){let t=new Map,e=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'`])/g,n;for(;(n=e.exec(r))!==null;){let i=Ov(r,e.lastIndex-1);i&&(t.set(n[1],i.value),e.lastIndex=i.end)}return t}function b8(r){let t=[],e=oB(r),n=0;for(;n<r.length;){n=as(r,n);let i=r[n];if(i==='"'||i==="'"||i==="`"){let a=Ov(r,n);n=a?a.end:n+1;continue}let o=zI(r,n,e);if(!o){n+=1;continue}if(n=as(r,o.end),r[n]!==":"){n=o.end;continue}if(n=as(r,n+1),o.name!=="options"||r[n]!=="{")continue;let s=XC(r,n,"{","}");if(s===-1)break;t.push({start:n+1,end:s}),n=s+1}return t}function zI(r,t,e){if(r[t]==='"'||r[t]==="'"||r[t]==="`"){let i=Ov(r,t);return i?{name:i.value,end:i.end}:null}if(r[t]==="["){let i=as(r,t+1),o=iB(r,i),s=XC(r,t,"[","]");if(s===-1)return null;let a=o?as(r,o.end):i;return{name:o&&a===s?e.get(o.value)??null:null,end:s+1}}let n=iB(r,t);return n?{name:n.value,end:n.end}:null}function w8(r){let t=new Map,e=0;for(;e<r.length;){if(e=as(r,e),r[e]===","){e+=1;continue}if(e>=r.length)break;let n=zI(r,e,new Map);if(!n?.name){e+=1;continue}if(e=as(r,n.end),r[e]!==":"){e+=1;continue}if(e=as(r,e+1),r[e]==='"'||r[e]==="'"||r[e]==="`"){let o=Ov(r,e);if(!o)break;t.set(n.name,o.value),e=o.end;continue}if(r.slice(e,e+4)==="true"){t.set(n.name,!0),e+=4;continue}if(r.slice(e,e+5)==="false"){t.set(n.name,!1),e+=5;continue}let i=r[e];if(i==="{"||i==="["){let o=XC(r,e,i,i==="{"?"}":"]");if(o===-1)break;e=o+1;continue}for(;e<r.length&&r[e]!==",";)e+=1}return t}function C8(r){let t=w8(r),e=t.get("type"),n=t.get("secret");return e==="secret"||(e==="text"||e==="input")&&n===!0}function Dv(r,t){let e=t&&y8.test(t)?Ws(r).code??"":r,n=new Set,i=!1,o=oB(e);for(let{start:s,end:a}of b8(e)){let l=s;for(;l<a;){if(l=as(e,l),e[l]===","){l+=1;continue}if(l>=a)break;let c=zI(e,l,o);if(!c){l+=1;continue}if(l=as(e,c.end),e[l]!==":"){l+=1;continue}if(l=as(e,l+1),e[l]!=="{"){l+=1;continue}let d=XC(e,l,"{","}");if(d===-1||d>a)break;let u=e.slice(l+1,d);C8(u)&&(i=!0,c.name&&n.add(c.name)),l=d+1}}return{names:n,foundSecretOptions:i}}var y8,sB=x(()=>{_m();y8=/\.md$/i});function Tr(r){return typeof r=="object"&&r!==null}function rl(r){return Tr(r)&&!Array.isArray(r)}function x8(r){return rl(r)?!1:Array.isArray(r)?r.length>0:Wt(r)}function ur(r){return rl(r)?r.commands:x8(r)?r:void 0}function Mt(r){return Array.isArray(r)?r:[]}function km(r){return Array.isArray(r)?r:[]}function Lv(r){return Array.isArray(r)}function HI(r){let t=Mt(r),e=new Set,n=!1,i=[];for(let o of t){if(Array.isArray(o)){let l=HI(o);for(let c of l.commands){let d=c.id;if(typeof d=="string"&&d!==""&&!e.has(d)){e.add(d),i.push(c);continue}let u={...c,id:Vt()};e.add(u.id),i.push(u)}n=!0;continue}if(!Tr(o)){n=!0;continue}let s=o.id;if(typeof s=="string"&&s!==""&&!e.has(s)){e.add(s),i.push(o);continue}let a={...o,id:Vt()};e.add(a.id),i.push(a),n=!0}return n?{commands:i,changed:n}:{commands:t,changed:!1}}function aB(r){lB(r,new Set)}function lB(r,t){Tr(r)&&(t.has(r)||(t.add(r),rl(r)&&(r.id=Vt()),JC(ur(r),t)))}function JC(r,t){if(Lv(r))for(let e of r){if(Array.isArray(e)){JC(e,t);continue}if(!Tr(e)||t.has(e))continue;t.add(e),e.id=Vt();let n=e;JC(n.thenCommands,t),JC(n.elseCommands,t),cB(n.choice,t)}}function cB(r,t){if(!Tr(r)||t.has(r))return;t.add(r);let e=r;if(e.id=Vt(),e.type==="Macro"&&lB(e.macro,t),e.type==="Multi"&&Array.isArray(e.choices))for(let n of e.choices)cB(n,t)}var Gr=x(()=>{qh();Qo();qh()});function Am(r){return r!==null&&typeof r=="object"}function nx(r){return r?.secretStorage}function ex(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"setting"}function T8(r){let t=5381;for(let e=0;e<r.length;e+=1)t=t*33^r.charCodeAt(e);return(t>>>0).toString(36).slice(0,E8)}function uB(r,t){return r.length<=t?r:r.slice(0,t).replace(/-+$/g,"")||"setting"}function mB(r,t){let e=t?.id;return typeof e=="string"&&e.trim().length>0?e:r}function WI(r,t,e){let i=(e?[ZC,r,t,e]:[ZC,r,t]).join("-");if(i.length<
`:" ");try{return i7(t,T),T}catch(P){return S.logError(`Failed to insert image link: ${P instanceof Error?P.message:String(P)}`),new Uv.Notice("QuickAdd: saved the image but could not insert its link."),""}}async function g(b){let y=new Date,C=t7(b);if(C.length===0)return S.logMessage("QuickAdd: image ingest skipped (no-images)."),"";if(i)return new Uv.Notice("QuickAdd: an image is still being saved \u2014 drop again in a moment."),S.logMessage("QuickAdd: image ingest skipped (busy)."),"";let w="";return i=(async()=>{w=await h(C,y)})().finally(()=>{i=null}),await i,w.length>0&&S.logMessage(`QuickAdd: ingested ${C.length} image(s) into the active prompt.`),w}t.addEventListener("paste",d),t.addEventListener("dragenter",u),t.addEventListener("dragover",u),t.addEventListener("dragleave",p),t.addEventListener("drop",m),t.addEventListener("compositionstart",a),t.addEventListener("compositionend",l);let v={isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),ingestFiles:g,detach:()=>{o=!0,p(),t.removeEventListener("paste",d),t.removeEventListener("dragenter",u),t.removeEventListener("dragover",u),t.removeEventListener("dragleave",p),t.removeEventListener("drop",m),t.removeEventListener("compositionstart",a),t.removeEventListener("compositionend",l);let b=$x.findIndex(y=>y.handle===v);b>=0&&$x.splice(b,1)}};return $x.push({handle:v,inputEl:t}),v}async function JB(r){let t=J9();if(!t)return S.logMessage("QuickAdd: image ingest skipped (no-active-prompt)."),{ok:!1,reason:"no-active-prompt"};if(t.handle.isBusy())return S.logMessage("QuickAdd: image ingest skipped (busy)."),{ok:!1,reason:"busy"};let e=await t.handle.ingestFiles(r);return e.length===0?{ok:!1,reason:"no-images"}:{ok:!0,inserted:e}}function YB(r,t,e){switch(r){case"paste":{if(t.getData("text/plain").length>0)return{kind:"stand-down"};let n=KB(t).map(i=>({origin:"bytes",...i,naming:{kind:"paste-name"}}));return n.length>0?{kind:"take",images:n}:{kind:"stand-down"}}case"drop":{let n=Z9(t,e);if(n.length>0)return{kind:"take",images:n};let i=KB(t).map(o=>({origin:"bytes",...o,naming:ZB(o)}));return i.length>0?{kind:"take",images:i}:{kind:"stand-down"}}default:return Fx(r)}}function Z9(r,t){let e=[];for(let n of r.getData("text/plain").split(/\r?\n/u)){let i=n.trim();if(i.length===0||i.toLowerCase().startsWith("file://")||Ut(i))continue;let o=t.vault.getAbstractFileByPath(i);e7(o)&&e.push({origin:"vault",file:o})}return e}function e7(r){return r!==null&&"extension"in r&&typeof r.extension=="string"&&WB(r.extension)}function KB(r){let t=[],e=0;for(let o of Array.from(r.items??[])){if(o.kind!=="file"||(e++,!ol(o.type)))continue;let s=o.getAsFile();s&&t.push({file:s,mimeType:o.type})}if(e>0&&t.length===e)return t;if(t.length===0){let o=[];for(let s of Array.from(r.files??[]))ol(s.type)&&o.push({file:s,mimeType:s.type});return o}let n=[...t],i=new Set(t.map(({file:o,mimeType:s})=>`${o.name}\0${o.size}\0${s}\0${o.lastModified}`));for(let o of Array.from(r.files??[])){if(!ol(o.type))continue;let s=`${o.name}\0${o.size}\0${o.type}\0${o.lastModified}`;i.has(s)||(i.add(s),n.push({file:o,mimeType:o.type}))}return n}function t7(r){return r.flatMap(t=>{if(!ol(t.type))return[];let e={file:t,mimeType:t.type};return[{origin:"bytes",...e,naming:ZB(e)}]})}function ZB(r){let t=jB(r.file.name);return t===null?{kind:"clipboard-stamp"}:{kind:"original-stem",stem:t}}function r7(r,t,e){switch(r.naming.kind){case"clipboard-stamp":return GB(r.mimeType,t);case"paste-name":return Sx({extension:il[r.mimeType],sourcePath:e,now:t,nameAfterNoteTitle:U.getState().namePastedImagesAfterNoteTitle});case"original-stem":return`${r.naming.stem}.${il[r.mimeType]}`;default:return Fx(r.naming)}}function QB(r){return Array.from(r.types??[]).some(t=>t==="Files"||ol(t))}function Fx(r){throw new Error(`Unexpected image intake value: ${String(r)}`)}function n7(r){let t=XB.then(r,r);return XB=t.catch(()=>{}),t}function i7(r,t){r.focus();let e=!1;try{e=r.ownerDocument.execCommand("insertText",!1,t)}catch{e=!1}if(e)return;let n=r.selectionStart??r.value.length,i=r.selectionEnd??n;r.setRangeText(t,n,i,"end"),r.dispatchEve
`||d==="\r")break;a++}let l=r.slice(s,a);r[a]==="}"&&r[a+1]==="}"&&SJ.test(l)?(t.push({start:o,end:a+2,path:cr(l)}),n=a+2):n=a}return t}function Xs(r){let t=new Set;if(!r)return t;for(let e of sq(r))e.path&&t.add(e.path);return t}function hE(r,t){if(!r||t.size===0)return r;let e=sq(r);if(e.length===0)return r;let n="",i=0;for(let o of e){let s=t.get(o.path);s&&(n+=r.slice(i,o.start),n+=`${oq}${s}}}`,i=o.end)}return i===0?r:n+r.slice(i)}var oq,kJ,SJ,Ac=x(()=>{Dr();oq="{{TEMPLATE:",kJ=/{{TEMPLATE:/gi,SJ=/\.(?:md|canvas|base)$/i});function Aq(r){try{let t=window.require;return t?t(r):null}catch{return null}}async function cf(r,t){let e=r.vault.adapter;if(typeof h$.FileSystemAdapter!="function"||!(e instanceof h$.FileSystemAdapter))return;let n=Aq("fs"),i=Aq("path");if(!n?.promises||!i)return;let o=await n.promises.realpath(e.getBasePath()),a=e.getFullPath(t);for(;!QJ(n,a);){let p=i.dirname(a);if(p===a)break;a=p}let l;try{l=await n.promises.realpath(a)}catch{throw new ty(`Refusing to write to "${t}": it resolves through an unresolvable (dangling) symlink.`)}let c=i.relative(o,l);if(c===".."||c.startsWith(`..${i.sep}`)||i.isAbsolute(c))throw new ty(`Refusing to write to "${t}": it resolves (via a symlink) outside the vault.`);if(c.split(i.sep).some(p=>p.startsWith(".")))throw new ty(`Refusing to write to "${t}": it resolves (via a symlink) into a config/hidden directory.`)}function QJ(r,t){try{return r.lstatSync(t),!0}catch{return!1}}var h$,ty,g$=x(()=>{h$=require("obsidian"),ty=class extends Error{constructor(t){super(t),this.name="VaultWriteEscapeError"}}});function Q$(r,t=new Set){if(r==null||t.has(r))return[];if(t.add(r),typeof r=="string")return[r];if(typeof r!="object")return[String(r)];let e=r,n=[];for(let i of Ree){let o=e[i];o!==void 0&&n.push(...Q$(o,t))}return n}function QE(r){return Number(r.replace(/,/g,""))}function Oee(r){let t=r.match(/context (?:length|window)(?:\s+is)?(?:\s+of)?\s*(\d[\d,]*)/i);return t?QE(t[1]):null}function Dee(r){let t=r.match(/(\d[\d,]*)\s*(?:tokens?\s+)?in the completion\b/i);if(t){let n=QE(t[1]),i=Oee(r);return i===null?"input":n>=i?"output":"input"}let e=r.match(/input length and max_tokens exceed context limit:?\s*(\d[\d,]*)\s*\+\s*(\d[\d,]*)(?:\s*>\s*(\d[\d,]*))?/i);if(e){let n=QE(e[2]),i=e[3]?QE(e[3]):null;return i===null?"input":n>=i?"output":"input"}return null}function cy(r){let t=Q$(r).join(" "),e=Dee(t);return e==="output"?"output_budget":e==="input"?"input_context":Mee.some(n=>n.test(t))?"output_budget":Fee.some(n=>n.test(t))?"input_context":"other"}function dz(r){return cy(r)==="input_context"}function uz(r){return Lee.test(Q$(r).join(" "))}function XE(r,t){let e="",n="",i;try{i=t.json}catch{i=void 0}if(i&&typeof i=="object"){let s=i,a=s.error??s;e=String(a.message??s.message??""),n=String(a.code??a.type??a.status??"")}e||(e=typeof t.text=="string"&&t.text.length>0?t.text:`HTTP ${t.status}`);let o=new Error(`${r} request failed (HTTP ${t.status})${n?` [${n}]`:""}: ${e}`);return o.status=t.status,n&&(o.providerCode=n),o}var Fee,Mee,Ree,Lee,ff=x(()=>{Fee=[/context[_ -]?length[_ -]?exceeded/i,/context[_ -]?window[_ -]?exceeded/i,/maximum context length/i,/context window/i,/too many input tokens/i,/input(?: is)? too long/i,/prompt(?: is)? too long/i,/input token count/i,/reduce the length of (?:the |your )?(?:messages|prompt|input)/i,/exceed(?:s|ed|ing)? (?:the )?(?:maximum |allowed )?(?:input |prompt )?(?:token|context)/i],Mee=[/max_tokens/i,/max_completion_tokens/i,/max(?:imum)? output tokens/i,/output token limit/i],Ree=["message","code","type","status","statusText","providerCode","error","response","json","cause"];Lee=/tool_choice:\s*type\s*"tool"\s*and\s*"any"\s*are not supported/i});function Yee(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function Kee(r){let t=r.name?.trim()||"provider";return`${jee}-${Yee(t)}`}async function hz(r,t){if(!r?.secretStorage?.getSecret)return null;try{return await Promise.resolve(r.secretStorage.getSecret(t))}catch(e){return S.logWarning(`Failed to read SecretStorage entry "${t}": ${e.message??e}`),
> `)}}var nF=x(()=>{});var de,Sn=x(()=>{ri();de=class extends at{}});function gf(r){return iF.filter(t=>typeof r[t]=="number")}function pT(r){let t={...r};for(let e of iF)delete t[e];return t}function oF(r,t){return r.supportsTemperature===!1&&gf(t).length>0?pT(t):t}function Mz(r,t){return t.length===0?!1:ute.some(e=>e.test(r))}function sF(r){let t=r.map(e=>dte[e]);return t.length<=1?t.join(""):t.length===2?`${t[0]} and ${t[1]}`:`${t.slice(0,-1).join(", ")}, and ${t[t.length-1]}`}function hy(r,t){let e={};return typeof t.temperature=="number"&&(e.temperature=t.temperature),typeof t.top_p=="number"&&(e[r==="gemini"?"topP":"top_p"]=t.top_p),e}var iF,dte,uT,ute,mT=x(()=>{iF=["temperature","top_p","frequency_penalty","presence_penalty"],dte={temperature:"Temperature",top_p:"Top P",frequency_penalty:"Frequency penalty",presence_penalty:"Presence penalty"};uT=iF.join("|"),ute=[new RegExp(`unsupported (?:parameter|value)[^.]{0,40}['\`"]?(?:${uT})['\`"]?`,"i"),new RegExp(`['\`"]?(?:${uT})['\`"]?[^.]{0,40}(?:is deprecated|is not supported|not supported|does not support)`,"i"),new RegExp(`unrecognized request argument[^.]{0,40}(?:${uT})`,"i"),new RegExp(`(?:${uT})[^.]{0,40}extra inputs are not permitted`,"i")]});function aF(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function lF(r){let t=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,e=Date.now();return Fo.push({...r,modelOptions:{...r.modelOptions??{}},id:t,createdAt:e,status:"pending"}),Oz(),t}function gy(r,t){let e=Fo.find(n=>n.id===r);e&&(e.status=t.status,e.durationMs=t.durationMs,e.usage=t.usage,e.errorMessage=t.errorMessage,Oz())}function Rz(r=10){Number.isFinite(r)||(r=10);let t=Math.floor(r);return t<=0?[]:Fo.slice(-t).map(aF).reverse()}function Oz(){if(Fo.length<=25)return;let r=Fo.length-25;for(;r>0;){let t=Fo.findIndex(e=>e.status!=="pending");if(t===-1)break;Fo.splice(t,1),r-=1}}function Dz(r){let t=Fo.find(e=>e.id===r);return t?aF(t):null}function Lz(){let r=Fo[Fo.length-1];return r?aF(r):null}function Nz(){Fo.splice(0,Fo.length)}var Fo,cF=x(()=>{Fo=[]});function fT(r){let t=r.workspace.activeEditor?.editor?.getCursor(),e=r.workspace.activeEditor?.editor?.listSelections();return()=>{t&&r.workspace.activeEditor?.editor?.setCursor(t),e&&r.workspace.activeEditor?.editor?.setSelections(e)}}var dF=x(()=>{});function mu(r){let t=Array.isArray(r)?r:{...r},e=t.type==="object"||Array.isArray(t.type)&&t.type.includes("object")||t.properties!==void 0;if(t.properties){let n={};for(let[i,o]of Object.entries(t.properties))n[i]=mu(o);t.properties=n}return t.items&&!Array.isArray(t.items)&&(t.items=mu(t.items)),e&&(t.additionalProperties=!1,t.required=t.properties?Object.keys(t.properties):[]),t}function pte(r){let t=[];for(let e of r)if(e.role==="system")t.push({role:"system",content:e.content});else if(e.role==="user")t.push({role:"user",content:e.content});else if(e.role==="assistant"){let n={role:"assistant",content:e.content??""};e.toolCalls&&e.toolCalls.length>0&&(n.tool_calls=e.toolCalls.map(i=>({id:i.id,type:"function",function:{name:i.name,arguments:i.rawArgs??JSON.stringify(i.args??{})}}))),t.push(n)}else for(let n of e.results)t.push({role:"tool",tool_call_id:n.toolCallId,content:n.isError?`ERROR: ${n.content}`:n.content});return t}function mte(r){return r.map(t=>({type:"function",function:{name:t.name,description:t.description,parameters:t.strict?mu(t.parameters):t.parameters,...t.strict?{strict:!0}:{}}}))}function fte(r){return typeof r=="string"?r:{type:"function",function:{name:r.name}}}function gte(r,t){let e={model:r,...t.modelParams??{},messages:pte(t.messages)};return t.tools&&t.tools.length>0&&(e.tools=mte(t.tools),t.toolChoice&&(e.tool_choice=fte(t.toolChoice)),t.disableParallel&&(e.parallel_tool_calls=!1)),t.maxOutputTokens!==void 0&&(hte.test(r)?e.max_completion_tokens=t.maxOutputTokens:e.max_tokens=t.maxOutputTokens),t.responseFormat&&(e.response_format=t.responseFormat.schema?{type:"json_schema",json_schema:{name:t.responseFormat.name??"response",strict:t.responseFormat.strict??!0,schema:t.responseFormat.stri
`)),Object.assign(o,hy("anthropic",t.modelParams??{})),t.tools&&t.tools.length>0&&(o.tools=t.tools.map(s=>({name:s.name,description:s.description,input_schema:s.parameters})),t.toolChoice?o.tool_choice=Ete(t.toolChoice,t.disableParallel):t.disableParallel&&(o.tool_choice={type:"auto",disable_parallel_tool_use:!0})),t.responseFormat?.schema&&(o.output_config={format:{type:"json_schema",schema:mu(t.responseFormat.schema)}}),o}function Ete(r,t){let e=t?{disable_parallel_tool_use:!0}:{};return typeof r=="string"?r==="required"?{type:"any",...e}:r==="none"?{type:"none"}:{type:"auto",...e}:{type:"tool",name:r.name,...e}}function Tte(r){let t=r.content??[],e=t.filter(a=>a.type==="tool_use").map(a=>({id:a.id??"",name:a.name??"",args:a.input??{}})),n=String(r.stop_reason??""),i=r.usage??{},o=i.input_tokens??0,s=i.output_tokens??0;return{content:t.filter(a=>a.type==="text").map(a=>a.text??"").join(""),toolCalls:e,normalizedStopReason:n==="tool_use"||e.length>0?"tool_calls":n==="max_tokens"?"length":n==="end_turn"||n==="stop_sequence"?"stop":"other",rawStopReason:n,usage:{promptTokens:o,completionTokens:s,totalTokens:o+s}}}function _te(r,t){let e=[],n=[];for(let s of t.messages)if(s.role==="system")s.content&&e.push(s.content);else if(s.role==="user")n.push({role:"user",parts:[{text:s.content}]});else if(s.role==="assistant")if(Array.isArray(s.providerRaw))n.push({role:"model",parts:s.providerRaw});else{let a=[];s.content&&a.push({text:s.content});for(let l of s.toolCalls??[])a.push({functionCall:{name:l.name,args:l.args??{}}});n.push({role:"model",parts:a})}else n.push({role:"user",parts:s.results.map(a=>({functionResponse:{name:a.name,response:a.isError?{error:a.content}:{result:a.content}}}))});let i={contents:n};e.length>0&&(i.systemInstruction={role:"system",parts:[{text:e.join(`
`)}]}),t.tools&&t.tools.length>0&&(i.tools=[{functionDeclarations:t.tools.map(s=>({name:s.name,description:s.description,parameters:s.parameters}))}],t.toolChoice&&(i.toolConfig=kte(t.toolChoice)));let o=hy("gemini",t.modelParams??{});return t.maxOutputTokens!==void 0&&(o.maxOutputTokens=t.maxOutputTokens),t.responseFormat?.schema&&(o.responseMimeType="application/json",o.responseSchema=t.responseFormat.schema),Object.keys(o).length>0&&(i.generationConfig=o),i}function kte(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function Ste(r){let t=r.candidates?.[0]??{},n=(t.content??{}).parts??[],i=n.filter(a=>a.functionCall).map((a,l)=>({id:a.functionCall?.id??`gemini-call-${l}`,name:a.functionCall?.name??"",args:a.functionCall?.args??{}})),o=String(t.finishReason??""),s=r.usageMetadata??{};return{content:n.filter(a=>typeof a.text=="string").map(a=>a.text??"").join(""),toolCalls:i,normalizedStopReason:i.length>0?"tool_calls":o==="MAX_TOKENS"?"length":o==="STOP"?"stop":"other",rawStopReason:o,usage:{promptTokens:s.promptTokenCount??0,completionTokens:s.candidatesTokenCount??0,totalTokens:s.totalTokenCount??0},providerRaw:n}}function uF(r,t,e,n=8192){switch(r){case"anthropic":return xte(t,e,n);case"gemini":return _te(t,e);case"openai-responses":return wte(t,e);default:return gte(t,e)}}function Uz(r,t){switch(r){case"anthropic":return Tte(t);case"gemini":return Ste(t);case"openai-responses":return Cte(t);default:return vte(t)}}var hte,qz=x(()=>{mT();hte=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function vy({kind:r,apiKey:t,provider:e,model:n,body:i,afterRequest:o}){let s={"Content-Type":"application/json"},a;switch(r){case"anthropic":a="/v1/messages",s["x-api-key"]=t,s["anthropic-version"]="2023-06-01";break;case"gemini":a=`/v1beta/models/${encodeURIComponent(n.name)}:generateContent`,s["x-goog-api-key"]=t;break;case"openai-responses":a="/responses",s.Authorization=`Bearer ${t}`;break;default:a="/chat/completions",s.Authorization=`Bearer ${t}`}let l=(0,zz.requestUrl)({url:e.endpoint+a,method:"POST",headers:s,body:JSON.stringify(i),throw:!1});o?.();let c=await l;if(c.status>=400)throw XE(e.name,c);return c.json}function Ate(r){return{id:r.id,model:r.model,content:r.choices[0].message.content,usage:{promptTokens:r.usage.prompt_tokens,completionTokens:r.usage.completion_tokens,totalTokens:r.usage.total_tokens},stopReason:r.choices[0].finish_reason,stopSequence:null,created:r.created}}function Ite(r){return{id:r.id,model:r.model,content:r.content.filter(t=>t.type==="text").map(t=>t.text??"").join(""),usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},stopReason:r.stop_reason,stopSequence:r.stop_sequence,created:Date.now()}}function yy(r){if(typeof r.maxOutputTokens=="number"&&Number.isFinite(r.maxOutputTokens)&&r.maxOutputTokens>0)return Math.floor(r.maxOutputTokens);let t=4096;return Number.isFinite(r.maxTokens)&&r.maxTokens>0?Math.min(t,r.maxTokens):t}function Pte(r,t,e,n,i){if(r!=="anthropic"&&r!=="gemini")return{model:t.name,...n,messages:[{role:"system",content:e},{role:"user",content:i}]};let o=hy(r,n);return r==="anthropic"?{model:t.name,max_tokens:yy(t),messages:[{role:"user",content:i}],...e&&e.trim().length>0?{system:e}:{},...o}:{contents:[{role:"user",parts:[{text:i}]}],...e&&e.trim().length>0?{systemInstruction:{role:"system",parts:[{text:e}]}}:{},...Object.keys(o).length?{generationConfig:o}:{}}}async function Hz({kind:r,systemPrompt:t,params:e,prompt:n,...i}){let o=Pte(r,i.model,t,e,n),s={...i,kind:r,body:o};switch(r){case"anthropic":return Ite(await vy(s));case"gemini":return $te(await vy(s));default:return Ate(await vy(s))}}function $te(r){let t=r.candidates?.[0],n=(t?.content?.parts??[]).map(i=>typeof i.text=="string"?i.text:"").join("");return{id:`${Date.now()}`,model:r.modelVersion??"gemini",content:n,usage:{promptTokens:r.usageMetadata?.promptTokenCount??0,completionTokens:r.usageMetadata?.candidatesTokenC
${t}`:""}`});function Ote(){return Array.from(new Set([hF,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>Jh(hF,r))])).filter(Boolean)}function Kz(r){if(r.length<=1)return null;let t=Math.floor(r.length/2),e=[`
`,`
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(let a of e){let l=r.lastIndexOf(a,t),c=r.indexOf(a,t),d=[l,c].filter(u=>u>0);for(let u of d){let p=u+a.length;if(p<=0||p>=r.length)continue;let m=Math.abs(p-t);m<i&&(i=m,n=p)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=t,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function Dte(r){let t=new RegExp(Td.source,"gi"),e=qi(r),n;for(;(n=t.exec(e))!==null;)if(n[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function Lte(r){return As.test(r)||nw.test(r)||iw.test(r)||yi(r).length>0}function Nte(r){return Yz.some(t=>r.includes(t))}function Vte(r){return Yz.slice().sort((t,e)=>e.length-t.length).reduce((t,e)=>t.split(e).join(" "),r)}function Qz(r){if(r>yT)throw new Error(`This chunked AI request would split into more than ${yT} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function Bte(r,t,e){let n=Math.max(1,Math.floor(t)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Ti(s)<=n?null:Kz(s);if(!l){e.push(s),o+=1,Qz(o);continue}i.push(l[1],l[0])}}function Ute(r){let t=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",t).exec("").length-1}function zte(r,t){if(typeof t=="string"){let s=r.split(t);return{chunks:s,separators:new Array(Math.max(0,s.length-1)).fill(t)}}if(Ute(t)>0||qte.test(t.source))return{chunks:r.split(t),separators:null};let e=new RegExp(`(${t.source})`,t.flags),n=r.split(e),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function Hte(r,t,e,n){let i=[];if(r.forEach((l,c)=>{let d=[];Bte(l,e,d),d.forEach((u,p)=>{i.push({text:u,joiner:p===0&&c>0?t?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Ti(l.text)+Math.max(1,Ti(l.joiner));s!==""&&a+c>=e&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function Wte(r,t){let e=Math.max(1,Math.floor(r));if(t!==void 0&&Number.isFinite(t)&&t>0){let n=Math.floor(t);return{budget:Math.min(e,n),clamped:n>e}}return{budget:e,clamped:!1}}async function gF(r,t,e){if(U.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fu(t.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:d,modelOptions:u}=t;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let p=t.chunkSeparator||/\n/g,{chunks:m,separators:h}=zte(d,p),g=await e(c,{chunk:hF});if(!(Dte(c)||Lte(c)&&Nte(g)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let b=o.maxTokens,y=mU(b),C=Vte(g),w=Ti(l)+Ti(C);if(w>=b)throw new Error(`The estimated prompt overhead (${w} tokens) exceeds the model's entire context window (${b} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:T,clamped:P}=Wte(y-w,t.maxChunkTokens);P&&S.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${t.maxChunkTokens}) exceeds this model's estimated input budget; using ${T} estimated tokens per chunk instead.`);let _=t.shouldMerge??!0,I=Hte(m,h,T,_);Qz(I.length);let D=by(r,i,o,s,l,u,!t.showAssistantMessages),N=["prompting",`${I.length} prompts being sent.`];n.setMessage(N[0],N[1]);let K=new vT(5,1e3*30),ne=!1,H=0,O=Promise.resolve(),G=W=>{let Z=O.then(()=>{if(ne)throw new Error("Chunked prompt stopped after an earlier failure.");return e(c,{chunk:W})});return O=Z.then(()=>{},()=>{}),Z},V=async(W,Z=0)=>{if(ne)throw new Error("Chunked prompt stopped after an earlier failure.");let se;try{se=await G(W)}catch(ce){throw ne=!0,ce}try{return[(await K.add(()=>{if(ne)throw new Error("Chunked prompt stopped after an earlier failure.");if(H+=1,H>yT)throw new Error(`Chunked AI request exceeded the safety limit of ${yT} provider requests.`);return D(se)})).content]}catch(ce){let $e=Kz(W);if(Z>=Rte||!$e|
`),o=[],s=null;for(let a of i){if(!s){let l=this.matchFenceOpen(a);l?s={...l,lines:[a]}:o.push(a);continue}if(this.matchFenceClose(a,s.length)){let l=s.info.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&l!==void 0&&l.length>0&&n.has(l))for(let d=1;d<s.lines.length;d++)o.push(s.lines[d]);s=null}else s.lines.push(a)}if(s)for(let a of s.lines)o.push(a);return o.join(`
`)}static matchFenceOpen(t){let e=this.FENCE_OPEN_REGEX.exec(this.stripTrailingCarriage(t));return e?{length:e[1].length,info:e[2]}:null}static matchFenceClose(t,e){let n=this.FENCE_CLOSE_REGEX.exec(this.stripTrailingCarriage(t));return n!==null&&n[1].length>=e}static stripTrailingCarriage(t){return t.endsWith("\r")?t.slice(0,-1):t}static getFieldValues(t,e,n){return this.parseInlineFields(t,n).get(e)||new Set}};gl.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,gl.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,gl.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,gl.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,gl.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;wf=gl});function IF(r){let t=[];return r.folder&&t.push(`folder:${r.folder}`),r.folders?.length&&t.push(`folders:${r.folders.join(",")}`),r.tags&&t.push(`tags:${r.tags.join(",")}`),r.inline&&t.push("inline:true"),r.inlineCodeBlocks?.length&&t.push(`inline-code-blocks:${r.inlineCodeBlocks.join(",")}`),r.caseSensitive&&t.push("case-sensitive:true"),r.excludeFolders&&t.push(`exclude-folders:${r.excludeFolders.join(",")}`),r.excludeTags&&t.push(`exclude-tags:${r.excludeTags.join(",")}`),r.excludeFiles&&t.push(`exclude-files:${r.excludeFiles.join(",")}`),r.defaultValue&&t.push(`default:${r.defaultValue}`),r.defaultEmpty&&t.push("default-empty:true"),r.defaultAlways&&t.push("default-always:true"),t.join("|")}async function g2(r,t,e){return(await PF(r,t,e)).values}async function PF(r,t,e){let n=await Zte(r,t,e),i=ea.processValues(n,e);return{values:i.values,hasDefaultValue:i.hasDefaultValue}}async function Zte(r,t,e){let n=hl.getInstance(),i=IF(e),o=n.get(t,i);if(o)return o;let s=n.getRevision(),a=await $F(r,t,e);return n.setIfRevision(t,a,i,s),a}async function $F(r,t,e){let n=t.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await ere(r,e);if(i.size>0)return i}return await nre(r,t,e)}async function ere(r,t){if(!(!!t.folder||!!t.folders?.length||!!t.tags?.length||!!t.excludeFolders?.length||!!t.excludeTags?.length||!!t.excludeFiles?.length)){let n=tre(r);if(n.size>0)return n}return await rre(r,t)}function tre(r){let t=new Set;try{let e=r.metadataCache.getTags?.();if(!e)return t;for(let n of Object.keys(e)){let o=(n.startsWith("#")?n.substring(1):n).trim();o&&t.add(o)}}catch{}return t}function Ty(r,t){if(t!=null)for(let e of Array.isArray(t)?t:[t]){let n=String(e).trim();n&&r.add(n)}}async function v2(r,t,e){let n=new Set,i=Vs.filterFiles(r.vault.getMarkdownFiles(),t,o=>r.metadataCache.getFileCache(o));for(let o=0;o<i.length;o+=50){let s=await Promise.all(i.slice(o,o+50).map(async a=>{let l=new Set;try{await e(a,l)}catch{}return l}));for(let a of s)for(let l of a)n.add(l)}return n}async function rre(r,t){return v2(r,t,(e,n)=>{let i=r.metadataCache.getFileCache(e);Ty(n,i?.frontmatter?.tags),Ty(n,i?.frontmatter?.tag);for(let o of i?.tags??[]){let s=String(o.tag??"").trim().replace(/^#/,"");s&&n.add(s)}})}async function nre(r,t,e){return v2(r,e,async(n,i)=>{let o=r.metadataCache.getFileCache(n)?.frontmatter?.[t];if(Array.isArray(o)?o.forEach(s=>Ty(i,[s])):typeof o!="object"&&Ty(i,o),e.inline){let s=await r.vault.cachedRead(n);Ty(i,[...wf.getFieldValues(s,t,{includeCodeBlocks:e.inlineCodeBlocks})])}})}var kT=x(()=>{jw();TT();SF();AF()});function ire(r,t){let e=t.trim();if(!e||!r)return null;let n=r[e];if(n===void 0){let i=e.toLowerCase(),o=Object.keys(r).find(s=>s.toLowerCase()===i);o!==void 0&&(n=r[o])}if(n==null)return null;if(Array.isArray(n)){let i=[];for(let o of n){let s=y2(o);s!==null&&i.push(s)}return i.length>0?i:null}return y2(n)}function ST(r,t,e){if(!t||t.extension!=="md")return null;let n=r.metadataCache.getFileCache(t)?.frontmatter;return ire(n,e)}function y2(r){if(r==null)return null;let t=typeof r;if(t==="string"||t==="number"||t==="boolean"){let e=String(r).trim();return e.length>0?e:null}return null}var FF=x(()=>{});async function b2({app:r,executor:t,getSourcePath:e},n){let i=t?.promptProvider;try{let{fieldName:o,filters:s,multiSelect:a,label:l}=Dn.parse(n),c=s.defaultFrom==="active"?ST(r,t?.triggerContext?.activeFile??null,o):nu
Suggested values for ${o}: ${y.slice(0,3).join(", ")}`)}return i?await i.inputPrompt(g,b):await ir.Prompt(r,g,b,void 0,void 0,{allowPeek:!0,linkSourcePath:e()??void 0})}return i?String(await i.suggester(p,p,v,!0)):await vr.Suggest(r,p,p,{placeholder:v})}catch(o){throw Be(o)?new et("Input cancelled by user"):o}}async function w2({app:r,executor:t,getSourcePath:e},n){let i=t?.promptProvider;try{let o=Vp(r,n),s=n.label??`Select a file from ${n.folderPath}`;if(o.length===0){let p=`No matching files found in "${n.folderPath}". Type a value or leave empty.`,m=i?await i.inputPrompt(s,p):await ir.Prompt(r,s,p,void 0,void 0,{optional:n.optional||void 0,allowPeek:!0});return n.multiSelect?m?[`${Jo}${m}`]:[]:m?`${Jo}${m}`:""}let a=Ds(o,p=>r.metadataCache.getFileCache(p)),l=a.map(p=>p.label),c=a.map(p=>p.aliases),d=o.map(p=>`${Jl}${p.path}`);if(n.multiSelect)return(i?(await i.suggesterMulti(l,d,{placeholder:s,allowCustomInput:n.allowCustomInput})).map(m=>d.includes(m)?m:Dd(d,c,m)??m):await Fc.Suggest(r,l,d,{placeholder:s,allowCustomValue:n.allowCustomInput,aliases:c,...n.optional?{skippable:!0}:{}})).map(m=>d.includes(m)?m:`${Jo}${m}`);if(i){let p=String(await i.suggester(l,d,s,n.allowCustomInput));return p?d.includes(p)?p:Dd(d,c,p)??`${Jo}${p}`:""}if(n.allowCustomInput){let p=new Set(o.map(g=>g.basename.toLowerCase())),m=new Set([...l,...c.flat()].map(g=>g.toLowerCase())),h=await vr.Suggest(r,l,d,{placeholder:s,aliases:c,valueExists:g=>p.has(g.toLowerCase())||m.has(g.toLowerCase()),...n.optional?{skippable:!0}:{}});return h?d.includes(h)?h:`${Jo}${h}`:""}return await It.Suggest(r,l,d,s,void 0,{aliases:c,...n.optional?{skippable:!0}:{}})??""}catch(o){throw Be(o)?new et("Input cancelled by user"):o}}var C2=x(()=>{Gs();cl();EF();Qi();Da();kT();SF();FF();Ln();rr();nt();ye();bi()});function are(r){return`\\begin{${r}}
\u261A
\\end{${r}}\u261A`}var ore,sre,x2,MF=x(()=>{ore=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\u261A}\u261A","[\u261A]\u261A","\\above","\\abovewithdelims","\\acute","\\aleph","\\alpha","\\amalg","\\And","\\angle","\\approx","\\approxeq","\\arccos","\\arcsin","\\arctan","\\arg","\\array","\\arrowvert","\\Arrowvert","\\ast","\\asymp","\\atop","\\atopwithdelims","\\backepsilon","\\backprime","\\backsim","\\backsimeq","\\backslash","\\bar","\\barwedge","\\Bbb","\\Bbbk","\\because","\\begin","\\beta","\\beth","\\between","\\bf","\\Bigg","\\bigg","\\Big","\\big","\\Biggl","\\Biggm","\\Biggr","\\biggl","\\biggm","\\biggr","\\Bigl","\\Bigm","\\Bigl","\\bigl","\\bigm","\\bigr","\\bigcap","\\bigcirc","\\bigcup","\\bigodot","\\bigoplus","\\bigotimes","\\bigsqcup","\\bigstar","\\bigtriangledown","\\bigtriangleup","\\biguplus","\\bigvee","\\bigwedge","\\binom","\\blacklozenge","\\blacksquare","\\blacktriangle","\\blacktriangledown","\\blacktriangleleft","\\blacktriangleright","\\bmod","\\boldsymbol","\\bot","\\bowtie","\\Box","\\boxdot","\\boxed","\\boxminus","\\boxplus","\\boxtimes","\\brace","\\bracevert","\\brack","\\breve","\\bullet","\\Bumpeq","\\bumpeq","\\cal","\\cancel","\\Cap","\\cap","\\cases","\\cdot","\\cdotp","\\cdots","\\centerdot","\\cfrac{\u261A}{\u261A}\u261A","\\check","\\checkmark","\\chi","\\choose","\\circ","\\circeq","\\circlearrowleft","\\circlearrowright","\\circledast","\\circledcirc","\\circleddash","\\circledR","\\circledS","\\class","\\clubsuit","\\colon","\\color","\\complement","\\cong","\\coprod","\\cos","\\cosh","\\cot","\\coth","\\cr","\\csc","\\cssId","\\Cup","\\cup","\\curlyeqprec","\\curlyeqsucc","\\curlyvee","\\curlywedge","\\curvearrowleft","\\curvearrowright","\\dagger","\\ddagger","\\daleth","\\dashleftarrow","\\dashrightarrow","\\dashv","\\dbinom","\\dot","\\ddot","\\dddot","\\ddddot","\\ddots","\\DeclareMathOperator","\\def","\\deg","\\Delta","\\delta","\\det","\\dfrac{\u261A}{\u261A}\u261A","\\diagdown","\\diagup","\\Diamond","\\diamond","\\diamondsuit","\\digamma","\\dim","\\displaylines","\\displaystyle","\\div","\\divideontimes","\\Doteq","\\doteq","\\dotplus","\\dots","\\dotsb","\\dotsc","\\dotsi","\\dotsm","\\dotso","\\doublebarwedge","\\doublecap","\\doublecup","\\downarrow","\\Downarrow","\\downdownarrows","\\downharpoonleft","\\downharpoonright","\\ell","\\emptyset","\\end","\\enspace","\\epsilon","\\eqalign","\\eqalignno","\\eqcirc","\\eqsim","\\eqslantgtr","\\eqslantless","\\equiv","\\eta","\\eth","\\exists","\\exp","\\fallingdotseq","\\fbox","\\Finv","\\flat","\\forall","\\frac{\u261A}{\u261A}\u261A","\\frak","\\frown","\\Game","\\Gamma","\\gamma","\\gcd","\\ge","\\geq","\\geqq","\\geqslant","\\genfrac","\\gets","\\gg","\\ggg","\\gggtr","\\gimel","\\gtrapprox","\\gnapprox","\\gneq","\\gneqq","\\gvertneqq","\\gtrsim","\\gnsim","\\grave","\\gt","\\gtrdot","\\gtreqless","\\gtreqqless","\\gtrless","\\hat","\\hbar","\\hbox","\\hdashline","\\hline","\\heartsuit","\\hfil","\\hfill","\\hom","\\hookleftarrow","\\hookrightarrow","\\hphantom","\\href","\\hskip","\\hslash","\\hspace","\\Huge","\\huge","\\iddots","\\idotsint","\\iff","\\iiiint","\\iiint","\\iint","\\int","\\intop","\\Im","\\imath","\\impliedby","\\implies","\\in","\\inf","\\infty","\\injlim","\\intercal","\\iota","\\it","\\jmath","\\Join","\\kappa","\\ker","\\kern","\\Lambda","\\lambda","\\land","\\langle","\\LARGE","\\Large","\\large","\\LaTeX","\\lbrace","\\lbrack","\\lceil","\\ldotp","\\ldots","\\le","\\leq","\\leqq","\\leqslant","\\leadsto","\\left","\\leftarrow","\\Leftarrow","\\leftarrowtail","\\leftharpoondown","\\leftharpoonup","\\leftleftarrows","\\leftrightarrow","\\Leftrightarrow","\\leftrightarrows","\\leftrightharpoons","\\leftrightsquigarrow","\\leftroot","\\leftthreetimes","\\leqalignno","\\lessapprox","\\lessdot","\\lesseqgtr","\\lesseqqgtr","\\lessgtr","\\lesssim","\\lfloor","\\lg","\\lgroup","\\lhd","\\lim","\\liminf","\\limits","\\limsup","\\ll","\\llap","\\llcorner","\\lrcorner","\\Lleftarrow","\\lll","\\llless","\\lmoustache","\\ln","\\lnapprox","\\lneq","\\lneqq","\\lnot",
`).pop()??"",n=t.split(`
`,1)[0];return O2.test(e)&&O2.test(n)?`
`:""}function yl(r){let t=(0,D2.getFrontMatterInfo)(r);return t.exists?t.contentStart:0}function yre(r,t){let e=yl(r);if(e===0)return 0;if(R2.test(t))return e;let n=R2.exec(r.slice(e));return n?e+n[0].length:e}function wu(r,t,{separateBlockquotes:e=!1}={}){if(t.length===0)return{content:r,insertedStartOffset:null,insertedEndOffset:null};let n=yre(r,t),i=r.slice(0,n),o=r.slice(n),s=i.length>0&&!i.endsWith(`
`)&&!vre.test(t)?`
`:"",a=o.length>0&&!t.endsWith(`
`)?`
`:"",l=e?UF(t,o):"",c=i.length+s.length,d=c+t.length;return{content:`${i}${s}${t}${a}${l}${o}`,insertedStartOffset:c,insertedEndOffset:d}}function L2(r,t){return wu(r,t).content}var D2,R2,vre,O2,Lc=x(()=>{D2=require("obsidian"),R2=/^[^\S\r\n]*\r?\n/,vre=/^\r?\n/,O2=/^ {0,3}>/});function RT(r){let t=yl(r),e=/\{\{CURSOR\}\}/i.exec(r.slice(t));return{content:On(r),offsets:e?[On(r.slice(0,t)).length+e.index]:[]}}function qF(r,t){if(r.content===t)return r;r.content.includes("\r")&&!t.includes("\r")&&(r=bre(r));let e=yl(r.content),n=yl(t);return r.offsets.some(i=>i<e)||r.content.slice(e)!==t.slice(n)?null:{content:t,offsets:r.offsets.map(i=>i+n-e)}}function bre(r){let t=e=>e.replace(/\r\n?/g,`
`);return{content:t(r.content),offsets:r.offsets.map(e=>t(r.content.slice(0,e)).length)}}var zF=x(()=>{Ma();Lc()});function OT(r){for(let t of r.workspace.getLeavesOfType("markdown")){let e=t.view;if(!(!e.containerEl||!e.file||e.file.extension!=="md"))try{let n=Bi(e.containerEl).activeElement;if(!n||!e.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(wre))continue;let o=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:e.file,key:o}}catch{continue}}return null}function Cre(r,t,e){let n=B2(r,t),i=r[n];if(Array.isArray(i)){i.push(e);return}if(i==null||i===""){r[n]=e;return}if(typeof i=="string"){r[n]=`${i} ${e}`;return}throw new Error(`Cannot append link to frontmatter property '${n}' because it contains a ${typeof i} value.`)}function HF(r,t,e,n=Ud){let i=B2(r,t),o=r[i];if(Array.isArray(o)){o.push(e);return}if(o===null||o===""){r[i]=[e];return}if(o===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${i}' because it does not exist.`);r[i]=[e];return}if(typeof o=="object")throw new Error(`Cannot append link to frontmatter property '${i}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${i}' because it is not a list and the link-handling mode is '${N2[n]}'. Choose '${N2.alwaysAppend}' to convert it into a list and append.`);r[i]=[o,e]}function B2(r,t){if(t=t.trim(),!t)throw new Error("Cannot append link to an empty frontmatter property key.");let e=V2(t),n=Object.keys(r).filter(i=>V2(i)===e);if(n.length>1)throw new Error(`Cannot append link to frontmatter property '${t}' because the note has multiple properties that normalize to that key.`);return n[0]??t}function V2(r){return r.trim().toLowerCase()}async function U2(r,t,e){let n=r.fileManager.generateMarkdownLink(e,t.file.path);try{return await Va(r,t.file,i=>{Cre(i,t.key,n)}),!0}catch(i){return S.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${t.key}' in '${t.file.path}': ${i instanceof Error?i.message:String(i)}`),!1}}var N2,wre,Ay=x(()=>{Ns();ye();Ua();Ko();N2={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},wre=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function q2(r,t,e,n){let i=ai(t,e);return i?GF(r,i.editor,n):null}function GF(r,t,e){if(r.cursor.kind==="none")return null;let n=r.content.replace(/\r\n?/g,`
`),i=r.content.slice(0,r.cursor.value).replace(/\r\n?/g,`
`).length,o=u=>t.posToOffset(u),s=t.getCursor(),a;if(e==="currentLine")a=t.listSelections().map(({anchor:u,head:p})=>({from:o(u)<=o(p)?u:p,to:o(u)<=o(p)?p:u,text:n,cursor:i}));else if(e==="newLineAbove"||e==="newLineBelow"){let u=e==="newLineAbove";a=[{from:{line:s.line,ch:u?0:t.getLine(s.line).length},text:u?n+`
`:`
`+n,cursor:i+(u?0:1)}]}else return null;let l=[],c=[],d=0;a.sort((u,p)=>o(u.from)-o(p.from));for(let u of a)l.push(o(u.from)+d+u.cursor),c.push(o(u.from)+d+u.text.length-(e==="newLineAbove"?1:0)),d+=u.text.length-(o(u.to??u.from)-o(u.from));return t.transaction({changes:a.map(({from:u,to:p,text:m})=>({from:u,to:p,text:m}))}),t.setSelections(c.map(u=>({anchor:t.offsetToPos(u)}))),{offsets:l,content:t.getValue()}}function ai(r,t){let e=Un(r);return e?.file?.path===t.path?e:null}function z2(r,t,e){try{let n=ai(t,e);return n?(n.editor.replaceSelection(r),!0):(S.logError(`unable to append '${r}' to current line.`),!1)}catch{return S.logError(`unable to append '${r}' to current line.`),!1}}function H2(r,t,e,n){try{let i=ai(e,n);if(!i)return S.logError(`unable to insert '${r}' on new line ${t}.`),!1;let o=i.editor,a=o.getCursor().line,l=r.split(`
`),c=l.length,d=l[c-1]?.length??0;if(t==="above")o.replaceRange(r+`
`,{line:a,ch:0}),o.setCursor({line:a+c-1,ch:d});else{let u=o.getLine(a);o.replaceRange(`
`+r,{line:a,ch:u.length}),o.setCursor({line:a+c,ch:d})}return!0}catch{return S.logError(`unable to insert '${r}' on new line ${t}.`),!1}}function W2(r,t,e){return H2(r,"above",t,e)}function G2(r,t,e){return H2(r,"below",t,e)}function xre(r,t,e,n,i){let o=c=>r.posToOffset(c),s=t.map(c=>{let[d,u]=o(c.anchor)<=o(c.head)?[c.anchor,c.head]:[c.head,c.anchor];return{from:d,to:u,text:n(r.getRange(d,u))}}).sort((c,d)=>o(c.from)-o(d.from)),a=s.map(({from:c,to:d,text:u})=>e==="replaceSelection"?{from:c,to:d,text:u}:{from:d,text:u}),l=[];if(e==="replaceSelection"){let c=0;for(let{from:d,to:u,text:p}of s)l.push(o(d)+c+p.length),c+=p.length-(o(u)-o(d))}i(a,()=>r.transaction({changes:a})),e==="replaceSelection"&&r.setSelections(l.map(c=>({anchor:r.offsetToPos(c)})))}async function Ere(r,t,e="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=Ud,textForSelection:a,onEditorTextMutation:l}=n,c=r.workspace.getActiveViewOfType(WF.MarkdownView);if(!c){let g="Cannot append link because no active Markdown view is available.";if(i)throw new Error(g);S.logMessage(g);return}if(e==="inFrontmatter"){let g=c.file;if(!g)throw new Error("Cannot append link because the active Markdown view has no file.");await Va(r,g,v=>{HF(v,o??"",t,s)});return}let d=c.editor;if(!d){let g="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(g);S.logMessage(g);return}let u=(g,v)=>{if(!l){v();return}let b=d.getValue(),y=g.map(C=>({from:d.posToOffset(C.from),to:d.posToOffset(C.to??C.from),text:C.text}));v(),l({filePath:c.file?.path??null,before:b,after:d.getValue(),edits:y})},p=d.listSelections().map(g=>({anchor:{...g.anchor},head:{...g.head}}));if(a&&p.length>0&&(e==="replaceSelection"||e==="afterSelection")){xre(d,p,e,a,u);return}if(e==="replaceSelection"){let g=p.map(({anchor:v,head:b})=>({from:d.posToOffset(v)<=d.posToOffset(b)?v:b,to:d.posToOffset(v)<=d.posToOffset(b)?b:v,text:t}));u(g,()=>d.replaceSelection(t));return}let m=({line:g,ch:v})=>d.posToOffset({line:g,ch:v}),h=p.sort((g,v)=>m(v.head)-m(g.head));for(let g of h){let v=m(g.anchor)>m(g.head)?g.anchor:g.head;switch(e){case"afterSelection":{u([{from:v,text:t}],()=>d.replaceRange(t,v));break}case"endOfLine":case"newLine":{let b=d.getLine(v.line).length,y=e==="newLine"&&b>0?`
`:"",C={line:v.line,ch:b};u([{from:C,text:y+t}],()=>d.replaceRange(y+t,C));break}}}}async function j2(r,t,e,n,i,o=!1){if(!n?.enabled)return!1;let s=Zo(n);if(!e||e.extension!=="md"){if(n.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let a=e.path,l=qw(r,t,{sourcePath:a,linkType:s.linkType,placement:s.placement});if(!ai(r,e)){if(s.placement==="inFrontmatter")await Va(r,e,d=>{HF(d,s.frontmatterProperty??"",l,s.frontmatterHandling)});else if(o)await CA(r,e,l,i);else{if(n.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}return!0}let c=s.displayText==="selection"?d=>qw(r,t,{sourcePath:a,linkType:s.linkType,placement:s.placement,alias:d}):void 0;return await Ere(r,l,s.placement,{requireActiveView:!1,frontmatterProperty:s.frontmatterProperty,frontmatterHandling:s.frontmatterHandling,textForSelection:c,onEditorTextMutation:i}),!0}function Y2(r,t,e,n){return Iy(r,t,[e],n)}function Iy(r,t,e,n){try{if(t.extension!=="md"||!e.length||e.some(c=>!Number.isSafeInteger(c)||c<0||c>n.length))return!1;let i=r.workspace.getActiveViewOfType(WF.MarkdownView);if(!i||i.file?.path!==t.path||i.getMode()==="preview")return!1;let o=i.editor;if(!o)return!1;let s=o.getValue(),a=e;if(s!==n){if(s!==n.replace(/\r\n?/g,`
`))return!1;a=e.map(c=>n.slice(0,c).replace(/\r\n?/g,`
`).length)}a.length===1?o.setCursor(o.offsetToPos(a[0])):o.setSelections(a.map(c=>({anchor:o.offsetToPos(c)})));let l=i.containerEl?.ownerDocument;return l&&l.activeElement===l.body&&o.focus(),!0}catch{return S.logMessage(`Unable to place cursor after capture in '${t.path}'.`),!1}}var WF,Nc=x(()=>{WF=require("obsidian");sl();ye();Ua();qd();Ay();Ns();qd()});function LT(r,t){try{let e=r.workspace.getActiveViewOfType(NT.MarkdownView);if(!e||e.file?.path!==t.path)return{cursor:null,value:null};let n=e.editor,i=n?.getCursor?.(),o=i&&typeof i.line=="number"&&typeof i.ch=="number"?{line:i.line,ch:i.ch}:null,s=typeof n?.getValue=="function"?n.getValue():null;return{cursor:o,value:s}}catch{return{cursor:null,value:null}}}function _re(r,t){return r!==null&&t!==null&&(r.line!==t.line||r.ch!==t.ch)}function K2(r){return typeof r!="string"?null:[...r.matchAll(Tre)].length}function J2(r,t){let e=K2(r),n=K2(t);return e!==null&&n!==null&&e>n}function Q2(r,t){return _re(r.cursor,t.cursor)||J2(r.value,t.value)}async function YF(r,t,e=500){try{let n=r.vault.adapter;if(!("stat"in n)||typeof n.stat!="function")return;let i=await n.stat(t.path);if(!i)return;let o=i.mtime,s=Date.now(),a=30;for(;Date.now()-s<e;){await $y(a);let l=await n.stat(t.path);if(!l||l.mtime===o)return;o=l.mtime,a=Math.min(a*2,200)}}catch(n){S.logWarning(`waitForFileSettle: fallback due to adapter/stat failure \u2013 ${n.message}`)}}function QF(r){return r.plugins.plugins["templater-obsidian"]}function xu(r){let t=QF(r);return t||null}function Fy(r){let t=xu(r);if(!t)return!1;let e=t.settings?.trigger_on_file_creation;if(typeof e=="boolean")return e;let n=r.loadLocalStorage?.("templater-local-settings");return typeof n=="object"&&n!==null&&!Array.isArray(n)&&"trigger_on_file_creation"in n&&n.trigger_on_file_creation===!0}function $y(r){return new Promise(t=>window.setTimeout(t,r))}function kre(r,t){if(Vc)return;let e=function(...n){let i=t.apply(this,n),o=n[n.length-1]?.path;return typeof o=="string"&&Cu.has(o)&&Cu.set(o,Promise.resolve(i)),i};r.on_file_creation=e,Vc={owner:r,original:t,wrapper:e}}function Sre(){!Vc||Cu.size>0||(Vc.owner.on_file_creation===Vc.wrapper&&(Vc.owner.on_file_creation=Vc.original),Vc=null)}async function XF(r,t,e){let n=(0,NT.normalizePath)(t),i,o;try{i=Fy(r)?xu(r)?.templater?.constructor:void 0,o=i?.on_file_creation}catch{i=void 0}if(!(!!i&&typeof o=="function"&&!Cu.has(n))){let d=await e();return await X2(r,d),d}Cu.set(n,null),kre(i,o);let a,l;try{a=await e()}finally{l=Cu.get(n)??null,Cu.delete(n),Sre()}if(!l||a.path!==n)return await X2(r,a),a;let c;try{await Promise.race([l,new Promise(d=>{c=window.setTimeout(d,Are)})])}catch(d){S.logWarning(`Templater failed on new note ${a.path}: ${d.message}`)}finally{window.clearTimeout(c)}return a}async function X2(r,t,e={}){if(t.extension!=="md"||!Fy(r))return;let i=xu(r)?.templater?.files_with_pending_templates;if(!(i instanceof Set)){await $re(r,t,{timeoutMs:e.timeoutMs??5e3,gracePeriodMs:e.appearTimeoutMs??2500,quietPeriodMs:200});return}let{timeoutMs:o=5e3,appearTimeoutMs:s=2500}=e,a=Date.now();for(;Date.now()-a<s&&!i.has(t.path);)await $y(50);for(;Date.now()-a<o&&i.has(t.path);)await $y(50);await YF(r,t,800)}async function Pre(r,t,e){if(!(KF>0)&&e.size===0){if(Py){await Py;return}Py=(async()=>{try{r.workspace.trigger("templater:all-templates-executed"),await t.templater?.functions_generator?.teardown?.()}catch(n){S.logWarning(`withTemplaterFileCreationSuppressed: teardown failed \u2013 ${n.message}`)}})();try{await Py}finally{Py=null}}}async function Z2(r,t,e){let n=xu(r),i=n?.templater?.files_with_pending_templates;if(!n||!Fy(r)||!(i instanceof Set))return await e();KF++;let o=jF.get(t);o||(o={count:0,hadPathInitially:i.has(t)},jF.set(t,o),o.hadPathInitially||i.add(t)),o.count++;let s=!1;try{let a=await e();return s=!0,a}finally{o.count--,KF--,o.count<=0&&(jF.delete(t),o.hadPathInitially||(s&&await $y(Ire),i.delete(t),await Pre(r,n,i)))}}async function $re(r,t,e={}){let{timeoutMs:n=2e3,quietPeriodMs:i=150,gracePeriodMs:o=800}=e;try{let s=r.vault.adapter;if(!("stat"in s)||typeof s.stat!="function
${a}`:`${a}
${s}`;return await this.app.vault.modify(e,l),e}catch(o){if(nM(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),Me(o,"Could not append to file with template"),null}}async getTemplateContent(e){let n=nn(this.app,e);if(!n)throw new Error(`Template file not found at path "${e}".`);return await this.app.vault.cachedRead(n)}}});var nH={};cb(nH,{SingleTemplateEngine:()=>_f});var _f,iM=x(()=>{zT();ye();Dr();_f=class extends qc{constructor(e,n,i,o,s){super(e,n,o,s);this.templatePath=i;this.promptScope="noteBody";this.preserveCursorMarkers=!1;this.keepUserTextProtected=!1}setPreserveCursorMarkers(e){this.preserveCursorMarkers=e}setKeepUserTextProtected(e){this.keepUserTextProtected=e}setPromptScope(e){this.promptScope=e}setDestinationPath(e){this.formatter.setTitle(Is(e)),this.formatter.setTargetFolderPath(ei(e))}async run(){let e=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(e);n||S.logError(`Template ${e} not found.`);let i=()=>this.preserveCursorMarkers?this.formatter.formatTemplateContent(n):this.formatter.formatFileContent(n);return n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.keepUserTextProtected?this.formatter.withUserTextProtected(i):i())),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var iH={};cb(iH,{SingleInlineScriptEngine:()=>oM});var oM,oH=x(()=>{Sy();oM=class extends ta{constructor(t,e,n,i,o){super(t,e,null,n,i,void 0,void 0,null,o)}async runAndGetOutput(t){let e=Object.getPrototypeOf(async function(){}).constructor;return await new e(t).bind(this.params,this).call()}}});var sH,Ai,Su=x(()=>{Ma();vf();p2();C2();Tg();Wd();Oa();sH=require("obsidian");Le();Rd();Qi();wF();_2();Qd();Da();Ln();xo();kT();vl();Op();yp();bu();rr();Sn();nt();Ai=class extends ec{constructor(e,n,i,o){super(e);this.app=e;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.preserveTemplateCursorMarkers=!1;this.keepUserTextProtected=!1;this.choiceChain=[];this.skipPropertyExpansion=!1;this.includingText=null;this.dateParser=o||So,i&&(this.variables=i?.variables)}userText(e){return t2(e)}async withUserTextProtected(e){let n=this.keepUserTextProtected;this.keepUserTextProtected=!0;try{return await e()}finally{this.keepUserTextProtected=n}}runClocks(){return this.choiceExecutor?.clocks??this.clocks}async format(e){return this.formatScalarTokens(await this.expandCodeAndIncludes(e))}async expandCodeAndIncludes(e){let n=qi(e);n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n);let i=this.includingText;this.includingText=await this.replaceGlobalVarInString(n);try{n=await this.replaceTemplateInString(n)}finally{this.includingText=i}return this.replaceGlobalVarInString(n)}async formatScalarTokens(e){let n=e;return 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),this.defersPropertyExpansion()||(n=this.replacePropertyInString(n)),this.promptScope==="captureText"||this.promptScope==="noteBody"&&this.preserveTemplateCursorMarkers?n:On(n)}async replaceGlobalVarInString(e){return rc(e,this.plugin?.settings?.globalVariables)}async formatFileName(e,n="generic"){if(ho.test(e))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,e,()=>this.format(e));if(ho.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"}),An(i)}get incl
`)===s?this.app.metadataCache.getFileCache(e):null,d=(c?.headings??[]).map(y=>({heading:y.heading,level:y.level,line:y.position.start.line})),u=y=>`${y.level}:${yu(y.heading)}`,p=new Map(a.map(y=>[y.line,u(y)]));if(!(c&&d.every(y=>p.get(y.line)===u(y))))return NF(a,o.line);let h=new Set(d.map(y=>y.line)),g=(c.sections??[]).filter(y=>y.type==="html"||y.type==="comment"||y.type==="math"),v=a.filter(y=>!h.has(y.line)&&!g.some(C=>C.position.start.line<=y.line&&y.line<=C.position.end.line)),b=[...d,...v].sort((y,C)=>y.line-C.line);return NF(b,o.line)}getVariableValue(e){return this.variables.get(e)??""}shouldUseSelectionForValue(){return this.includer?.shouldUseSelectionForValue()??!0}async getSelectedTextForValue(){return this.includer?await this.includer.getSelectedTextForValue():await this.getSelectedText()}assertInteractivePrompt(e){if(this.choiceExecutor?.interactive===!1)throw new de(`This run is non-interactive but a value for ${e} was not provided up front. Pass it (e.g. a value- flag) or re-run with the ui flag.`)}describeAnonymousValuePrompt(){let e=gw(this.promptScope,this.promptScopeSoleValue),n=this.valuePromptContext?.label??e.title??(this.promptRunContext?.choiceName?.trim()||"Enter value"),i=hw(this.promptScope);return{title:n,placeholder:e.placeholder,contextLine:vp(this.promptRunContext,n,{showDestination:i}),contextLineFull:vp(this.promptRunContext,n,{elide:!1,showDestination:i})}}async promptForValue(e){if(this.value===void 0){if(this.shouldUseSelectionForValue()){let o=await this.getSelectedTextForValue();if(o){let s=this.normalizeSelectedTextForPrompt(o);if(s!==void 0)return this.value=s,this.value}}if(this.assertInteractivePrompt("{{VALUE}}"),this.valuePromptContext?.inputTypeOverride==="checkbox"){let o=this.choiceExecutor?.promptProvider;if(o)return this.value=String(await o.suggester(["true","false"],["true","false"],this.describeAnonymousValuePrompt().title,!1)),this.value;try{return this.value=await It.Suggest(this.app,["true","false"],["true","false"],this.describeAnonymousValuePrompt().title,void 0,this.valuePromptContext.optional?{skippable:!0}:void 0),this.value}catch(s){throw Be(s)?new et("Input cancelled by user"):s}}let n=this.describeAnonymousValuePrompt(),i=this.choiceExecutor?.promptProvider;if(i)return this.value=await i.inputPrompt(n.contextLine?`${n.title} (${n.contextLine})`:n.title,this.valuePromptContext?.placeholder??n.placeholder,this.valuePromptContext?.defaultValue),this.value;try{let o=this.getLinkSourcePath(),s=new hu().factory(this.valuePromptContext?.inputTypeOverride??this.defaultValueInputType),a=this.valuePromptContext?.defaultValue,l=this.buildInputPromptOptions(this.valuePromptContext,n.contextLine,n.contextLineFull),c=this.valuePromptContext?.placeholder??n.placeholder;this.value=await s.Prompt(this.app,n.title,c,a,void 0,{...l,linkSourcePath:o||void 0})}catch(o){throw Be(o)?new et("Input cancelled by user"):o}}return this.value}normalizeSelectedTextForPrompt(e){let n=this.valuePromptContext;if(n?.inputTypeOverride==="checkbox"){let s=e.trim().toLowerCase();return s==="true"||s==="false"?s:void 0}if(n?.inputTypeOverride!=="number"&&n?.inputTypeOverride!=="slider")return e;let i=n.sliderConfig??n.numericConfig,o=Co(e,i);return o===""?void 0:o}buildInputPromptOptions(e,n,i){let o=this.contentValuePromptsAcceptImagePaste&&e?.inputTypeOverride!=="number"&&e?.inputTypeOverride!=="slider"?{sourcePath:this.getLinkSourcePath()??""}:void 0,s=this.promptRunContext?.draftScopeId;return{optional:e?.optional,numeric:e?.numericConfig,slider:e?.sliderConfig,imagePaste:o,contextLine:n,contextLineFull:i,draftScopeId:s,allowPeek:!0}}promptRuntime(){return{app:this.app,executor:this.choiceExecutor,scope:this.promptScope,runContext:this.promptRunContext,assertInteractivePrompt:e=>this.assertInteractivePrompt(e),buildInputPromptOptions:(e,n,i)=>this.buildInputPromptOptions(e,n,i)}}async promptForVariable(e,n){return c2(this.promptRuntime(),e,n)}async promptForMathValue(){let e=this.choiceExecutor?.promptProvider;if(e)return await e.inputPrompt("Enter a math expression");this.assertInterac
`:"",o=i+t;return{content:o,insertedStartOffset:i.length,insertedEndOffset:o.length}}return wu(r,`${t}
`)}function zre(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function mH(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(t=>typeof t=="string")?null:r}function fH(r,t){let e=mH(r),n=mH(t);if(e===null||n===null)return;let i=[],o=new Set(e);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...e,...i]}var GT,Dy,Bre,Ure,kf,jT=x(()=>{GT=require("obsidian");ye();Nc();Uc();UT();Nd();jh();Cp();Dr();Lc();Ns();zF();zT();es();bp();vf();Dy=[{id:"cursor",label:"Insert at cursor",description:"Inserts the template at the cursor position in the editor."},{id:"top",label:"Insert at top",description:"Inserts the template below the note's frontmatter, or at the very top."},{id:"bottom",label:"Append to bottom",description:"Adds the template content to the end of the note."},{id:"replace",label:"Replace note content",description:"Replaces the entire note content with the template."}];Bre=/(?:\r?\n[^\S\r\n]*)+$/,Ure=/^(?:[^\S\r\n]*\r?\n)+/;kf=class extends qc{constructor(e,n,i,o,s,a,l){super(e,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.cursorView=null;this.resolvedTemplatePath=l??null}placeCursor(e){this.mode==="cursor"&&ai(this.app,e)!==this.cursorView||super.placeCursor(e)}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(this.cursorPlacement=null,Vr(this.templatePath,"Cannot apply template: no template path given."),this.mode){case"replace":return await this.overwriteFileWithTemplate(this.targetFile,await this.getResolvedTemplatePath());case"top":case"bottom":return await this.insertTemplateIntoFile(this.mode);case"cursor":return await this.insertTemplateAtCursor()}}async computeChoiceTargetPath(e){let n=e.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(e.fileNameFormat?.enabled&&e.fileNameFormat.format){this.formatter.setTargetFolderPath(i);let a=await this.formatter.formatFileName(e.fileNameFormat.format,"generic"),l=Br(a,"File name"),c=this.stripDuplicateFolderPrefix(l,i);o=c.fileName,s=this.shouldTreatFormattedNameAsVaultRelativePath(l,c.strippedPrefix,n?.enabled??!1)}return o.slice(o.lastIndexOf("/")+1).trim()?this.normalizeTemplateFilePath(s?"":i,o,await this.getResolvedTemplatePath()):null}async insertTemplateIntoFile(e){let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),o=pH(n),{frontmatterYaml:s}=o,a=e==="bottom"?o.body.replace(Ure,""):o.body,l=this.cursorPlacement;return(a.trim().length>0||l)&&await To(this.app,this.targetFile,c=>{let d=qre(c,a,e);if(l&&d.insertedStartOffset!==null){let u=d.insertedStartOffset,p=u-(n.length-a.length);this.cursorPlacement={content:d.content,offsets:l.offsets.map(m=>Math.max(u,p+m))}}return d.content}),await this.mergeFrontmatterProperties(s,i),await this.rebaseCursorAfterFileChanges(this.targetFile),this.targetFile}async insertTemplateAtCursor(){let e=ai(this.app,this.targetFile);Vr(e,"Cannot insert at cursor: the note is not open in the active editor."),this.cursorView=e;let n=e.editor,{formatted:i,templatePropertyVars:o}=await this.formatTemplateForTargetFile();Vr(e.file===this.targetFile&&e.editor===n&&this.app.workspace.getLeavesOfType("markdown").some(c=>c.view===e),"Cannot insert at cursor: the original editor was closed or changed notes.");let{frontmatterYaml:s,body:a}=pH(i),l=this.cursorPlacement?.offsets[0];return l!==void 0?this.cursorPlacement=GF({content:a,cursor:{kind:"offset",value:l-(i.length-a.length),source:"marker"}},n,"currentLine"):a.trim().length>0&&n.replaceSelection(a),this.cursorPlacement&&s&&await e.save(),await this
> `);this.choiceExecutor.variables.set(n,e),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(t){w_(t)}}});function xl(r,t,e=!1){let n=si(r),i=n.find(u=>u.line===t),o=!!i;if(!o&&e)throw new Error(`Target line ${t} is not a heading, but we are trying to find the end of its section.`);if(!o&&!e){let u=n.find(h=>h.line>t)?.line??null,p=jne(r,t,h=>h.trim()===""),m=[u,p].filter(h=>h!==null);return m.length>0?Math.min(...m)-1:r.length-1}let s=i,l=n.find(u=>u.line>s.line&&(!e||u.level<=s.level))?.line??r.length,c=S2(r,s),d=l-1;for(;d>c&&r[d].trim()==="";)d--;return d===0&&r[1]?.trim()===""?1:Math.max(d,c)}function jne(r,t,e){for(let n=t+1;n<r.length;n++)if(e(r[n]))return n;return null}var x_=x(()=>{bu()});function Xy(r){let t=LF(r);return r.map((e,n)=>t[n]?e.replace(/^(\s*)#+(\s)/,`$1${Yne}$2`):e)}function Kne(r){let t=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!t)return{value:0,parsed:!1};let e=n=>Math.min(Number(n??"0"),999999);return{value:e(t[1])*1e12+e(t[2])*1e6+e(t[3]),parsed:!0}}function gW(r,t,e){switch(t.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{let n=r.match(/^-?\d+(?:\.\d+)?/);return n?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{let n=e?e(r,t.dateFormat||void 0,!1):null;return n&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":return Kne(r);default:return{value:0,parsed:!0}}}function Qne(r,t){if(typeof r.value=="string"&&typeof t.value=="string")return r.value<t.value?-1:r.value>t.value?1:0;let e=r.value,n=t.value;return e<n?-1:e>n?1:0}function vW(r,t,e,n,i,o=0){let s=Xy(r),a=si(s).filter(p=>p.line>=o),l=a.filter(p=>p.level===e),c=gW(si([t])[0]?.heading.trim()??"",n,i);if(l.length===0){let p=a.filter(m=>m.level<e).pop();return p?{mode:"after",line:xl(s,p.line,!0)}:{mode:"bodyStart"}}let d=()=>{let p=l[l.length-1];return{mode:"after",line:xl(s,p.line,!0)}};if(n.by==="insertion")return n.direction==="desc"?{mode:"before",line:l[0].line}:d();if(!c.parsed)return d();let u=n.unparseable??"bottom";for(let p of l){let m=gW(p.heading.trim(),n,i),h;if(!m.parsed)h=u==="bottom";else{let g=Qne(c,m);h=n.direction==="desc"?g>0:g<0}if(h)return{mode:"before",line:p.line}}return d()}var Yne,$M=x(()=>{x_();bu();Yne="\u200B"});function FM(r){let t=r.split(`
`);for(;t.length>1&&t[t.length-1].trim()==="";)t.pop();return t}function MM(r){return r.length===0||r.length===1&&r[0].trim()===""}function RM(r,t){if(t.length<=1){let e=Xne(r,t[0]??"");return{start:e,end:e}}return Jne(r,t)}function Xne(r,t){let e=t.trimEnd(),n=-1;for(let i=0;i<r.length;i++){let o=r[i].trimStart();if(o===e)return i;if(o.startsWith(e)){let a=o.slice(e.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i);continue}let s=o.indexOf(e);if(s!==-1){let a=o.slice(s+e.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i)}}return n}function Jne(r,t){let e=t.length,n=t.map(i=>yW(i));for(let i=0;i+e<=r.length;i++){let o=!0;for(let s=0;s<e;s++)if(yW(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+e-1}}return{start:-1,end:-1}}function yW(r){return r.trimEnd()}function E_(r,t,e){return r?si(t).some(n=>n.line===e):!1}function Zne(r,t){return r==="skip"?!0:r==="none"?!1:eie(t)}function eie(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function T_(r,t,e,n){if(t<0)return t;let i=r[t]??"";if(!Zne(n,i))return t;let s=e.endsWith(`
`)?Math.max(r.length-1,0):r.length,a=t;for(let l=t+1;l<s;l++){if(r[l].trim().length===0){a=l;continue}break}return a}function Jy(r,t,e,n){if(t<0)return t;let i=t,o=t+1;for(;o<r.length&&r[o].trim().length===0;)i=o,o++;return i===t||o!==r.length||!n.endsWith(`
`)?t:e.endsWith(`
`)?Math.max(t,i-1):i}function bW(r){return r.includes(`
`)||r.includes("\r")}function wW(r,t){let e=r.indexOf(`
`,t);return e===-1?r.length:e>0&&r[e-1]==="\r"?e-1:e}function OM(r){let t=yl(r);return t>0?r.slice(0,t).split(`
`).length-1:0}function CW(r){return si([r.replace(/\r$/,"")]).length>0}function xW(r){let t=new Set(si(r.map(e=>e.replace(/\r$/,""))).map(e=>e.line));return r.map((e,n)=>t.has(n)?e:"")}function EW(r,t){let e=OM(t),n=r.map((i,o)=>o<e?"":i);return Xy(n).map(i=>i.replace(/\r$/,""))}function Df(r,t,e,n,i=r.length){let o=t.split(`
`),s=o.slice(0,e+1).join(`
`),a=o.slice(e+1).join(`
`),c=(o[e+1]??"").trim(),d=t.endsWith(`
`)&&e+1===o.length-1,u=e+1<o.length&&!d&&c==="",p=n&&r.endsWith(`
`)&&u?r.slice(0,-1):r,m=!r.endsWith(`
`)&&a.length>0?`
`:"";return{content:`${s}
${p}${m}${a}`,insertedEndOffset:s.length+1+Math.min(i,p.length)}}function TW(r,t,e,n=r.length){let i=t.length>0&&!r.endsWith(`
`)?`
`:"",o=Math.max(0,Math.min(n,r.length));if(e<=0)return{content:`${r}${i}${t}`,insertedEndOffset:o};let s=t.split(`
`),a=s.slice(0,e).join(`
`),l=s.slice(e).join(`
`);return{content:`${a}
${r}${i}${l}`,insertedEndOffset:a.length+1+o}}function _W(r,t,e,n,i){let o=n,s=o.includes(`\r
`)?`\r
`:`
`,a=t.mode==="before"?t.line:t.line+1,l=0;for(let C=0;C<a&&C<r.length;C++)l+=r[C].length+1;l>o.length&&(l=o.length);let c=o.slice(0,l),d=o.slice(l),u=a>0?(r[a-1]??"").replace(/\r$/,""):"",p=a<r.length?(r[a]??"").replace(/\r$/,""):"",m=e.split(`
`).map(C=>C.replace(/\r$/,""));m.length>1&&m[m.length-1]===""&&m.pop();let h=[];a>0&&u.trim()!==""&&h.push(""),h.push(...m),a<r.length&&p.trim()!==""&&h.push("");let g=h.join(s),v=c.length>0&&!/\n$/.test(c)?s:"",b=d.length>0||/\n$/.test(o)?s:"",y=c.length+v.length;return{content:`${c}${v}${g}${b}${d}`,insertedEndOffset:y+(i===void 0?g.length:(a>0&&u.trim()!==""?s.length:0)+Math.min(e.slice(0,i).split(`
`).map(C=>C.replace(/\r$/,"")).join(s).length,m.join(s).length))}}var __=x(()=>{bu();$M();Lc()});function DM(r){return cr(r)}function LM(r,t){return t.some(e=>r===e||r.startsWith(`${e}/`))}function Pu(r,t){let e=(t??[]).map(n=>DM(n)).filter(n=>n.length>0);return e.length===0?!0:r?LM(r.normalize("NFC"),e):!1}var k_=x(()=>{Dr()});function $u(r,t={}){let e=(r??"").trim();if(!e)throw new Ro("Path is empty.");let n=e.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new Ro(`Refusing to write to an absolute path outside the vault: "${n}".`);let i=n.replace(/\/+/g,"/").replace(/^\/+|\/+$/g,""),o=i.split("/").filter(a=>a.length>0);if(o.length===0)throw new Ro("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new Ro(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new Ro(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);tie(a,i)}let s=(t.allowedRoots??[]).map(a=>DM(a)).filter(a=>a.length>0);if(s.length>0&&!LM(i,s))throw new Ro(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function tie(r,t){if(Yh.test(r))throw new Ro(`Path segment "${r}" contains control characters: "${t}".`);if(Kh.test(r))throw new Ro(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${t}".`);if(Qh.test(r))throw new Ro(`Path segment "${r}" cannot end with a space or a period: "${t}".`);let e=r.split(".")[0]??"";if(e&&Pd(e))throw new Ro(`Path segment "${r}" is a reserved device name: "${t}".`)}var Ro,SW=x(()=>{Xh();k_();Ro=class extends Error{constructor(t){super(t),this.name="UnsafeVaultPathError"}}});function Lf(r,t){let e=Object.entries(r),n=new Set(e.map(([o])=>o));if(AW(t.only,n,"only"),AW(t.exclude,n,"exclude"),t.only){let o=new Set(t.only);e=e.filter(([s])=>o.has(s))}if(t.exclude){let o=new Set(t.exclude);e=e.filter(([s])=>!o.has(s))}let i=t.prefix??"";return Object.fromEntries(e.map(([o,s])=>[i+o,s]))}function Zy(r){return{...r,__qaTool:!0}}function AW(r,t,e){if(!r)return;let n=r.filter(i=>!t.has(i));n.length!==0&&S.logWarning(`AI tools: ${e} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...t].join(", ")}.`)}var S_=x(()=>{ye()});function OW(r,t={}){let e=t.allowedRoots,n={read_note:Fu({description:"Read a note's full markdown content by vault path.",inputSchema:Mu({path:Oo("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=$u(String(i),{allowedRoots:e}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof VM.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>IW?a.slice(0,IW)+`
\u2026[truncated]`:a}}}),list_notes:Fu({description:"List markdown notes, optionally within a folder.",inputSchema:Mu({folder:Oo("Folder to list (omit for the whole vault)."),limit:PW("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?$u(String(i),{allowedRoots:e}):"",a=MW(FW(o,rie),1,nie),l=ts(r,s).filter(c=>Pu(c.path,e));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:Fu({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:Mu({query:Oo("Text to search for."),in:$W(["name","content","both"],"Where to search (default both)."),limit:PW("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=MW(FW(s,iie),1,oie),d=r.vault.getMarkdownFiles().filter(h=>Pu(h.path,e)),u=[],p=0,m=!1;for(let h of d){if(u.length>=c)break;if(l!=="content"&&h.basename.toLowerCase().includes(a)){u.push({path:h.path});continue}if(l!=="name"){if(p>=sie){m=!0;continue}p++;let v=await r.vault.cachedRead(h),b=v.toLowerCase().indexOf(a);b>=0&&u.push({path:h.path,snippet:lie(v,b)})}}return{results:u,scannedFiles:p,truncated:u.length>=c||m}}}),get_property_values:Fu({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:Mu({field:Oo("Frontmatter property name."),folder:Oo("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?$u(String(o),{allowedRoots:e}):"",a=(o?ts(r,s):r.vault.getMarkdownFiles()).filter(c=>Pu(c.path,e)),l=new Set;for(let c of a){let u=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(u!=null){for(let p of Array.isArray(u)?u:[u])if(typeof p!="object"){let m=String(p).trim();m&&l.add(m)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:Fu({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:Mu({path:Oo("Vault path for the new note."),content:Oo("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=$u(NM(String(i)),{allowedRoots:e});return await cf(r,s),await aie(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:Fu({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:Mu({path:Oo("Vault path to the existing note."),content:Oo("Markdown to append."),position:$W(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=$u(NM(String(i)),{allowedRoots:e}),l=RW(r,a);await cf(r,a);let c=String(o);return await To(r,l,d=>s==="top"?L2(d,c.endsWith(`
`)?c:c+`
`):`${d}${d.endsWith(`
`)||d.length===0?"":`
`}${c}`),{appended:!0,path:a}}}),insert_under_heading:Fu({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:Mu({path:Oo("Vault path to the existing note."),heading:Oo("Exact heading text (without the # markers)."),content:Oo("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=$u(NM(String(i)),{allowedRoots:e}),l=RW(r,a);await cf(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],d=c.find(b=>b.heading===String(o));if(!d)throw new Error(`Heading "${o}" not found in ${a}`);let u=await r.vault.read(l),p=u.split(`
`),m=d.position.start.line,g=(c.find(b=>b.position.start.line>m&&b.level<=d.level)?.position.start.line??p.length)-1;for(;g>m&&p[g].trim()==="";)g--;let v=Df(String(s),u,g,!1);return await r.vault.modify(l,v.content),{inserted:!0,path:a,heading:String(o)}}})};return Lf(n,t)}function Fu(r){return{...r,__qaTool:!0}}function Mu(r,t){return{type:"object",properties:r,required:t}}function Oo(r){return{type:"string",description:r}}function PW(r){return{type:"integer",description:r}}function $W(r,t){return{type:"string",enum:r,description:t}}function FW(r,t){let e=Number(r);return Number.isFinite(e)?Math.floor(e):t}function MW(r,t,e){return Math.max(t,Math.min(e,r))}function NM(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 RW(r,t){let e=r.vault.getAbstractFileByPath(t);if(!(e instanceof VM.TFile))throw new Error(`Note not found: ${t}`);return e}async function aie(r,t){let e=t.lastIndexOf("/");if(e<=0)return;let n=t.slice(0,e);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function lie(r,t){let e=Math.max(0,t-40);return r.slice(e,t+80).replace(/\s+/g," ").trim()}var VM,IW,rie,nie,iie,oie,sie,DW=x(()=>{VM=require("obsidian");bi();__();Lc();Ns();k_();SW();g$();S_();IW=16e3,rie=100,nie=200,iie=25,oie=50,sie=400});function NW(r,t={}){let e=t.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof A_.TFile)||s.extension!=="md"?null:Pu(s.path,e)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(A_.MarkdownView);return s&&Pu(s.file?.path,e)?s:null},o={get_active_note:Zy({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>LW?a.slice(0,LW)+`
\u2026[truncated]`:a}}}}),get_selection:Zy({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 Lf(o,t)}var A_,LW,VW=x(()=>{A_=require("obsidian");k_();S_();LW=16e3});function BW(r={}){let t={get_date:Zy({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:e,offset:n})=>({date:Ra({format:e!=null?String(e):void 0,offset:n!=null?Number(n):void 0})})})};return Lf(t,r)}var UW=x(()=>{Aw();S_()});function zW(r,t,e,n){async function i(s,a){let l=U.getState();if(l.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let{model:c,provider:d}=jv(s),u=await Po(r,d);return a?.assignToVariable&&w_(a.assignToVariable),{model:c,provider:d,apiKey:u,modelOptions:a?.modelOptions??{},outputVariableName:a?.assignToVariable||a?.variableName||"output",showAssistantMessages:a?.showAssistantMessages??!0,systemPrompt:a?.systemPrompt??l.ai.defaultSystemPrompt}}function o(s,a,l){if(!s)return Me(new Error("AI Assistant returned null"),l),{};if(a?.shouldAssignVariables||a?.assignToVariable)for(let[c,d]of Object.entries(s))e.variables.set(c,d);return s}return{prompt:async(s,a,l)=>{let c=await e2(r,{...await i(a,l),prompt:s},(d,u)=>n(d,u,!1));return o(c,l,"AI Prompt error")},chunkedPrompt:async(s,a,l,c,d)=>{let u=await gF(r,{...await i(l,c),text:s,promptTemplate:a,chunkSeparator:c?.chunkSeparator??/\n/,resultJoiner:c?.chunkJoiner??`
`,shouldMerge:c?.shouldMerge??!0,maxChunkTokens:c?.maxChunkTokens},(p,m)=>n(p,{...d,...m},!1));return o(u,c,"Chunked AI Prompt error")},getModels:()=>vU(),getMaxTokens:s=>jv(s).model.maxTokens,estimateTokens(s){return Ti(s)},countTokens(s,a){return qW||(qW=!0,S.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Ti(s)},getRequestLogs(s=10){return Rz(s)},getRequestLogById(s){return Dz(s)},getLastRequestLog(){return Lz()},clearRequestLogs(){Nz()},agent:s=>new C_(r,t,e,s),tool:s=>({...s,__qaTool:!0}),stepCountIs:s=>({stepNumber:a})=>a>=s,hasToolCall:s=>({toolCallNames:a})=>a.includes(s),tools:{vault:s=>OW(r,s),workspace:s=>NW(r,s),system:s=>BW(s)}}}var qW,HW=x(()=>{vF();Vm();Ic();Gv();hW();IM();DW();VW();UW();je();nt();ye();qW=!1});function WW(r){return{getFieldValues:async(t,e)=>{let n=e?.includeInlineCodeBlocks?.map(a=>a.trim().toLowerCase()).filter(a=>a.length>0),i={folder:e?.folder,folders:e?.folders,tags:e?.tags,inline:e?.includeInline??!1,inlineCodeBlocks:n},o=r.vault.getMarkdownFiles();o=Vs.filterFiles(o,i,a=>r.metadataCache.getFileCache(a));let s=new Set;for(let a of o){let c=r.metadataCache.getFileCache(a)?.frontmatter?.[t];if(c!=null){if(Array.isArray(c))c.forEach(d=>{if(d==null||typeof d=="object")return;let u=String(d).trim();u&&s.add(u)});else if(typeof c!="object"){let d=String(c).trim();d&&s.add(d)}}if(i.inline)try{let d=await r.vault.cachedRead(a);wf.getFieldValues(d,t,{includeCodeBlocks:n}).forEach(p=>s.add(p))}catch{}}return Array.from(s).sort()},clearCache:t=>{hl.getInstance().clear(t)}}}var GW=x(()=>{TT();jw();AF()});function jW(r){return{entries:Array.from(r.entries()),dateFormats:L0(r)}}function YW(r,t){r.clear();for(let[e,n]of t.entries)r.set(e,n);cg(r,t.dateFormats)}var zn,Nf,BM=x(()=>{Su();Rd();YT();jT();sl();If();nt();Aw();aM();sW();HW();GW();zn=class zn{static GetApi(t,e,n,i){let o=async(a,l,c=!0)=>{let d=c?jW(n.variables):null;l&&Object.keys(l).forEach(u=>{n.variables.set(u,l[u])});try{let u=new Ai(t,e,n);return i&&(u.choiceChain=i),await u.formatFileContent(a)}finally{d&&YW(n.variables,d)}},s=async(a,l,c)=>{let d;try{d=e.getChoiceByName(a)}catch{d=void 0}if(!d){Me(new Error(`Choice named '${a}' not found`),"API executeChoice error");return}if(!Af(n,c?.date)){Me(new Error(`Could not parse date origin '${String(c?.date)}'`),"API executeChoice error");return}l&&Object.keys(l).forEach(p=>{n.variables.set(p,l[p])}),await n.execute(d,i);let u=n.consumeAbortSignal?.();if(n.variables.clear(),cg(n.variables,new Map),u)throw u};return{requestInputs:a=>oW(t,n,a),inputPrompt:(a,l,c,d)=>{let u=n?.promptProvider;return u?u.inputPrompt(a,l,c):zn.inputPrompt(t,a,l,c,d)},datePrompt:(a,l)=>{let c=n?.promptProvider;return c?c.datePrompt(a,l):zn.datePrompt(t,a,l)},wideInputPrompt:(a,l,c,d)=>{let u=n?.promptProvider;return u?u.wideInputPrompt(a,l,c):zn.wideInputPrompt(t,a,l,c,d)},yesNoPrompt:(a,l)=>{let c=n?.promptProvider;return c?c.yesNoPrompt(a,l):zn.yesNoPrompt(t,a,l)},infoDialog:(a,l)=>{let c=n?.promptProvider;return c?c.infoDialog(a,l):zn.infoDialog(t,a,l)},suggester:(a,l,c,d=!1,u)=>{let p=n?.promptProvider;return p?p.suggester(a,l,c,d):zn.suggester(t,a,l,c,d,u)},checkboxPrompt:(a,l,c)=>{let d=n?.promptProvider;return d?d.checkboxPrompt(a,l,c):zn.checkboxPrompt(t,a,l,c)},executeChoice:(...a)=>ZD(s(...a)),applyTemplateToActiveFile:async(a,l)=>{if(!a)throw new Error("applyTemplateToActiveFile requires a template path.");if(!Hc(a))throw new Error("applyTemplateToActiveFile only supports markdown templates. Canvas and base templates cannot be applied to a markdown note.");if(l?.mode!==void 0&&!hH(l.mode))throw new Error(`Invalid mode '${String(l.mode)}'. Valid modes: ${Dy.map(d=>d.id).join(", ")}.`);let c=jW(n.variables);try{return await Ly(t,e,{templatePath:a,mode:l?.mode,choiceExecutor:n,chain:i})}finally{YW(n.variables,c)}},format:o,ai:zW(t,e,n,o),utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async a=>await navigator.clipboard.writeText(a),getSelection:()=>qv(t)
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
https://svelte.dev/e/await_reactivity_loss`,ga,va):console.warn("https://svelte.dev/e/await_reactivity_loss")}function _R(r,t){j?console.warn(`%c[svelte] await_waterfall
%cAn async derived, \`${r}\` (${t}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
https://svelte.dev/e/await_waterfall`,ga,va):console.warn("https://svelte.dev/e/await_waterfall")}function kR(){j?console.warn(`%c[svelte] derived_inert
%cReading a derived belonging to a now-destroyed effect may result in stale values
https://svelte.dev/e/derived_inert`,ga,va):console.warn("https://svelte.dev/e/derived_inert")}function SR(r,t,e){j?console.warn(`%c[svelte] hydration_attribute_changed
%cThe \`${r}\` attribute on \`${t}\` changed its value between server and client renders. The client value, \`${e}\`, will be ignored in favour of the server value
https://svelte.dev/e/hydration_attribute_changed`,ga,va):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Qc(r){j?console.warn(`%c[svelte] hydration_mismatch
%c${r?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${r}`:"Hydration failed because the initial UI does not match what was rendered on the server"}
https://svelte.dev/e/hydration_mismatch`,ga,va):console.warn("https://svelte.dev/e/hydration_mismatch")}function AR(){j?console.warn(`%c[svelte] lifecycle_double_unmount
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,ga,va):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function IR(){j?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",ga,va):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function bb(r){j?console.warn(`%c[svelte] state_proxy_equality_mismatch
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${r}\` will produce unexpected results
https://svelte.dev/e/state_proxy_equality_mismatch`,ga,va):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function PR(){j?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",ga,va):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var xe=!1;function Pr(r){xe=r}var De;function Tt(r){if(r===null)throw Qc(),fa;return De=r}function Yr(){return Tt(wn(De))}function $(r){if(xe){if(wn(De)!==null)throw Qc(),fa;De=r}}function Xt(r=1){if(xe){for(var t=r,e=De;t--;)e=wn(e);De=e}}function fs(r=!0){for(var t=0,e=De;;){if(e.nodeType===Ii){var n=e.data;if(n==="]"){if(t===0)return e;t-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(t+=1)}var i=wn(e);r&&e.remove(),e=i}}function eh(r){if(!r||r.nodeType!==Ii)throw Qc(),fa;return r.data}function wb(r){return r===this.v}function Cb(r,t){return r!=r?t==t:r!==t||r!==null&&typeof r=="object"||typeof r=="function"}function xb(r){return!Cb(r,this.v)}function $R(r){if(j){let t=new Error(`invariant_violation
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${r}"
https://svelte.dev/e/invariant_violation`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/invariant_violation")}function th(r){if(j){let t=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function MR(){if(j){let r=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function bk(){if(j){let r=new Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function RR(){if(j){let r=new Error(`derived_references_self
A derived value cannot reference itself recursively
https://svelte.dev/e/derived_references_self`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/derived_references_self")}function wk(r,t,e){if(j){let n=new Error(`each_key_duplicate
${e?`Keyed each block has duplicate key \`${e}\` at indexes ${r} and ${t}`:`Keyed each block has duplicate key at indexes ${r} and ${t}`}
https://svelte.dev/e/each_key_duplicate`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function OR(r,t,e){if(j){let n=new Error(`each_key_volatile
Keyed each block has key that is not idempotent \u2014 the key for item at index ${r} was \`${t}\` but is now \`${e}\`. Keys must be the same each time for a given item
https://svelte.dev/e/each_key_volatile`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_volatile")}function DR(r){if(j){let t=new Error(`effect_in_teardown
\`${r}\` cannot be used inside an effect cleanup function
https://svelte.dev/e/effect_in_teardown`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function LR(){if(j){let r=new Error("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function NR(r){if(j){let t=new Error(`effect_orphan
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
https://svelte.dev/e/effect_orphan`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/effect_orphan")}function VR(){if(j){let r=new Error(`effect_update_depth_exceeded
Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
https://svelte.dev/e/effect_update_depth_exceeded`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function BR(){if(j){let r=new Error(`hydration_failed
Failed to hydrate the application
https://svelte.dev/e/hydration_failed`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/hydration_failed")}function UR(){if(j){let r=new Error("invalid_snippet\nCould not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`\nhttps://svelte.dev/e/invalid_snippet");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/invalid_snippet")}function qR(r){if(j){let t=new Error(`props_invalid_value
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
https://svelte.dev/e/props_invalid_value`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/props_invalid_value")}function zR(r){if(j){let t=new Error(`rune_outside_svelte
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
https://svelte.dev/e/rune_outside_svelte`);throw t.name="Svelte error",t}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function HR(){if(j){let r=new Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function WR(){if(j){let r=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function GR(){if(j){let r=new Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function jR(){if(j){let r=new Error("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}var pr=!1,ya=!1,No=!1;var pY="font-weight: bold",mY="font-weight: normal";function Ck(r){j?console.warn(`%c[svelte] state_snapshot_uncloneable
%c${r?`The following properties cannot be cloned with \`$state.snapshot\` \u2014 the return value contains the originals:
${r}`:"Value cannot be cloned with `$state.snapshot` \u2014 the original value was returned"}
https://svelte.dev/e/state_snapshot_uncloneable`,pY,mY):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var fY=[];function Xc(r,t=!1,e=!1){if(j&&!t){let n=[],i=rh(r,new Map,"",n,null,e);if(n.length===1&&n[0]==="")Ck();else if(n.length>0){let o=n.length>10?n.slice(0,7):n.slice(0,10),s=n.length-o.length,a=o.map(l=>`- <value>${l}`).join(`
`);s>0&&(a+=`
- ...and ${s} more`),Ck(a)}return i}return rh(r,new Map,"",fY,null,e)}function rh(r,t,e,n,i=null,o=!1){if(typeof r=="object"&&r!==null){var s=t.get(r);if(s!==void 0)return s;if(r instanceof Map)return new Map(r);if(r instanceof Set)return new Set(r);if(io(r)){var a=Array(r.length);t.set(r,a),i!==null&&t.set(i,a);for(var l=0;l<r.length;l+=1){var c=r[l];l in r&&(a[l]=rh(c,t,j?`${e}[${l}]`:e,n,null,o))}return a}if(kl(r)===pb){a={},t.set(r,a),i!==null&&t.set(i,a);for(var d of Object.keys(r))a[d]=rh(r[d],t,j?`${e}.${d}`:e,n,null,o);return a}if(r instanceof Date)return r.getTime(),structuredClone(r);if(typeof r.toJSON=="function"&&!o)return rh(r.toJSON(),t,j?`${e}.toJSON()`:e,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return j&&n.push(e),r}}var nh=null;function Pn(r,t){return r.label=t,Eb(r.v,t),r}function Eb(r,t){return r?.[gb]?.(t),r}function Vo(r){let t=new Error,e=hY();return e.length===0?null:(e.unshift(`
`),jr(t,"stack",{value:e.join(`
`)}),jr(t,"name",{value:r}),t)}function hY(){let r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let t=new Error().stack;if(Error.stackTraceLimit=r,!t)return[];let e=t.split(`
`),n=[];for(let i=0;i<e.length;i++){let o=e[i],s=o.replaceAll("\\","/");if(o.trim()!=="Error"){if(o.includes("validate_each_keys"))return[];s.includes("svelte/src/internal")||s.includes("node_modules/.vite")||n.push(o)}}return n}function KR(r,t){if(!j)throw new Error("invariant(...) was not guarded by if (DEV)");r||$R(t)}var rt=null;function ba(r){rt=r}var hs=null;function Vu(r){hs=r}var Bo=null;function Tb(r){Bo=r}function ie(r,t=!1,e){rt={p:rt,i:!1,c:null,e:null,s:r,x:null,r:we,l:ya&&!t?{s:null,u:null,$:[]}:null},j&&(rt.function=e,Bo=e)}function oe(r){var t=rt,e=t.e;if(e!==null){t.e=null;for(var n of e)xk(n)}return r!==void 0&&(t.x=r),t.i=!0,rt=t.p,j&&(Bo=rt?.function??null),ih(r)}function ih(r={}){return jr(r,hb,{value:!0}),r}function Uo(){return!ya||rt!==null&&rt.l===null}var Jc=[];function QR(){var r=Jc;Jc=[],mb(r)}function wr(r){if(Jc.length===0&&!Zc){var t=Jc;queueMicrotask(()=>{t===Jc&&QR()})}Jc.push(r)}function XR(){for(;Jc.length>0;)QR()}var gY=-7169;function _t(r,t){r.f=r.f&gY|t}function Bu(r){(r.f&512)!==0||r.deps===null?_t(r,1024):_t(r,4096)}function JR(r){if(r!==null)for(let t of r)(t.f&2)===0||(t.f&65536)===0||(t.f^=65536,JR(t.deps))}function _b(r,t,e){(r.f&2048)!==0?t.add(r):(r.f&4096)!==0&&e.add(r),JR(r.deps),_t(r,1024)}var ZR=!1,kb=!1;function Ek(r){var t=kb;try{return kb=!1,[r(),kb]}finally{kb=t}}function rd(r){xe&&Xr(r)!==null&&qu(r)}var eO=!1;function Sb(){eO||(eO=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let t of r.target.elements)t[Sl]?.()})},{capture:!0}))}function ao(r){var t=Pe,e=we;Mr(null),Rr(null);try{return r()}finally{Mr(t),Rr(e)}}function Ab(r,t,e,n=e){r.addEventListener(t,()=>ao(e));let i=r[Sl];i?r[Sl]=()=>{i(),n(!0)}:r[Sl]=()=>n(!0),Sb()}function Ib(r,t,e,n){let i=Uo()?Il:nd;var o=r.filter(m=>!m.settled),s=t.map(i);if(j&&s.forEach((m,h)=>{m.label=t[h].toString().replace("() => ","").replaceAll("$.eager(() => ","$state.eager(").replace(/\$\.get\((.+?)\)/g,(g,v)=>v)}),e.length===0&&o.length===0){n(s);return}var a=we,l=tO(),c=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(m=>m.promise)):null;function d(m){if((a.f&16384)===0){l();try{n([...s,...m])}catch(h){pi(h,a)}zu()}}var u=Tk();if(e.length===0){c.then(()=>d([])).finally(u);return}function p(){Promise.all(e.map(m=>kk(m))).then(d).catch(m=>pi(m,a)).finally(u)}c?c.then(()=>{l(),p(),zu()}):p()}function tO(){var r=we,t=Pe,e=rt,n=_e;if(j)var i=hs;return function(s=!0){Rr(r),Mr(t),ba(e),s&&(r.f&16384)===0&&(n?.activate(),n?.apply()),j&&(_k(null),Vu(i))}}var yY=!1;function zu(r=!0){yY=!1,Rr(null),Mr(null),ba(null),r&&_e?.deactivate(),j&&(_k(null),Vu(null))}function Tk(){var r=we,t=r.b,e=_e,n=!!t?.is_rendered();return t?.update_pending_count(1,e),e.increment(n,r),()=>{t?.update_pending_count(-1,e),e.decrement(n,r)}}var mi=null;function _k(r){mi=r}var sh=new Set;function Il(r){var t=2050;we!==null&&(we.f|=524288);let e={ctx:rt,deps:null,effects:null,equals:wb,f:t,fn:r,reactions:null,rv:0,v:Rt,wv:0,parent:we,ac:null};return j&&No&&(e.created=Vo("created at")),e}var Hu=Symbol("obsolete");function kk(r,t,e){let n=we;n===null&&MR();var i=void 0,o=Mn(Rt);j&&(o.label=t??r.toString());var s=!Pe,a=new Set;return iO(()=>{var l=we;j&&(mi={effect:l,effect_deps:new Set,warned:!1});var c=fb();i=c.promise;try{Promise.resolve(r()).then(c.resolve,m=>{m!==ha&&c.reject(m)}).finally(zu)}catch(m){c.reject(m),zu()}if(j){if(mi){if(l.deps!==null)for(let m=0;m<Wn;m+=1)mi.effect_deps.add(l.deps[m]);if(Jr!==null)for(let m=0;m<Jr.length;m+=1)mi.effect_deps.add(Jr[m])}mi=null}var d=_e;if(s){if((l.f&32768)!==0)var u=Tk();if(n.b?.is_rendered())d.async_deriveds.get(l)?.reject(Hu);else for(let m of a.values())m.reject(Hu);a.add(c),d.async_deriveds.set(l,c)}let p=(m,h=void 0)=>{j&&(mi=null),u?.(),a.delete(c),h!==Hu&&(d.activate(),h?(o.f|=8388608,zo(o,h)):((o.f&8388608)!==0&&(o.f^=8388608),j&&e!==void 0&&!o.equals(m)&&(sh.add(o),setTimeout(()=>{sh.has(o)&&(l.f&16384)===0&&(_R(o.label,e),sh.delete(o))})),zo(o,m)),d.deactivate())};c.promise.then(p,m=>p(null,m||"unknown"))}),Qr(()=>{for(let l of a)l.reject(Hu)}),j&&(o.f|=
${n}in ${t.fn?.name||"<unknown>"}`,o=t.ctx;o!==null;)i+=`
${n}in ${o.function?.[no].split("/").pop()}`,o=o.p;return{message:r.message+`
${i}
`,stack:r.stack?.split(`
`).filter(s=>!s.includes("svelte/src/internal")).join(`
`)}}}function xO(r){let t=Uk.get(r);t&&(jr(r,"message",{value:t.message}),jr(r,"stack",{value:t.stack}))}function TO(r){we===null&&(Pe===null&&NR(r),LR()),Pi&&DR(r)}function IY(r,t){var e=t.last;e===null?t.last=t.first=r:(e.next=r,r.prev=e,t.last=r)}function bs(r,t){var e=we;if(j)for(;e!==null&&(e.f&131072)!==0;)e=e.parent;e!==null&&(e.f&8192)!==0&&(r|=8192);var n={ctx:rt,deps:null,nodes:null,f:r|2048|512,first:null,fn:t,last:null,next:null,parent:e,b:e&&e.b,prev:null,teardown:null,wv:0,ac:null};j&&(n.component_function=Bo),_e?.register_created_effect(n);var i=n;if((r&4)!==0)sd!==null?sd.push(n):$i.ensure().schedule(n);else if(t!==null){try{vs(n)}catch(s){throw sr(n),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&524288)===0&&(i=i.first,(r&16)!==0&&(r&65536)!==0&&i!==null&&(i.f|=65536))}if(i!==null&&(i.parent=e,e!==null&&IY(i,e),Pe!==null&&(Pe.f&2)!==0&&(r&64)===0)){var o=Pe;(o.effects??(o.effects=[])).push(i)}return n}function Al(){return Pe!==null&&!jn}function Qr(r){let t=bs(8,null);return _t(t,1024),t.teardown=r,t}function Dt(r){TO("$effect"),j&&jr(r,"name",{value:"$effect"});var t=we.f,e=!Pe&&(t&32)!==0&&rt!==null&&!rt.i;if(e){var n=rt;(n.e??(n.e=[])).push(r)}else return xk(r)}function xk(r){return bs(1048580,r)}function Hk(r){$i.ensure();let t=bs(524352,r);return()=>{sr(t)}}function _O(r){$i.ensure();let t=bs(524352,r);return(e={})=>new Promise(n=>{e.outro?ws(t,()=>{sr(t),n(void 0)}):(sr(t),n(void 0))})}function Cr(r){return bs(4,r)}function iO(r){return bs(4718592,r)}function en(r,t=0){return bs(8|t,r)}function Q(r,t=[],e=[],n=[]){Ib(n,t,e,i=>{bs(8,()=>{r(...i.map(f))})})}function Yn(r,t=0){var e=bs(16|t,r);return j&&(e.dev_stack=hs),e}function Or(r){return bs(524320,r)}function Wk(r){var t=r.teardown;if(t!==null){let e=Pi,n=Pe;qk(!0),Mr(null);try{t.call(null)}catch(i){pi(i,r.parent)}finally{qk(e),Mr(n)}}}function lh(r,t=!1){var e=r.first;for(r.first=r.last=null;e!==null;){let i=e.ac;i!==null&&ao(()=>{i.abort(ha)});var n=e.next;(e.f&64)!==0?e.parent=null:sr(e,t),e=n}}function kO(r){for(var t=r.first;t!==null;){var e=t.next;(t.f&32)===0&&sr(t),t=e}}function sr(r,t=!0){var e=!1;(t||(r.f&262144)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(SO(r.nodes.start,r.nodes.end),e=!0),r.f|=33554432,lh(r,t&&!e),od(r,0);var n=r.nodes&&r.nodes.t;if(n!==null)for(let o of n)o.stop();Wk(r),r.f^=33554432,r.f|=16384;var i=r.parent;i!==null&&i.first!==null&&Dk(r),j&&(r.component_function=null),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=r.b=null}function SO(r,t){for(;r!==null;){var e=r===t?null:wn(r);r.remove(),r=e}}function Dk(r){var t=r.parent,e=r.prev,n=r.next;e!==null&&(e.next=n),n!==null&&(n.prev=e),t!==null&&(t.first===r&&(t.first=n),t.last===r&&(t.last=e))}function ws(r,t,e=!0){var n=[];r.f|=256,AO(r,n,!0);var i=()=>{e&&sr(r),t&&t()},o=n.length;if(o>0){var s=()=>--o||i();for(var a of n)a.out(s)}else i()}function AO(r,t,e){if((r.f&8192)===0){r.f^=8192;var n=r.nodes&&r.nodes.t;if(n!==null)for(let a of n)(a.is_global||e)&&t.push(a);for(var i=r.first;i!==null;){var o=i.next;if((i.f&64)===0){var s=(i.f&65536)!==0||(i.f&32)!==0&&(r.f&16)!==0;AO(i,t,s?e:!1)}i=o}}}function rp(r){r.f&=-257,IO(r,!0)}function IO(r,t){if((r.f&256)===0&&(r.f&8192)!==0){r.f^=8192,(r.f&1024)===0&&(_t(r,2048),$i.ensure().schedule(r));for(var e=r.first;e!==null;){var n=e.next,i=(e.f&65536)!==0||(e.f&32)!==0;IO(e,i?t:!1),e=n}var o=r.nodes&&r.nodes.t;if(o!==null)for(let s of o)(s.is_global||t)&&s.in()}}function np(r,t){if(r.nodes)for(var e=r.nodes.start,n=r.nodes.end;e!==null;){var i=e===n?null:wn(e);t.append(e),e=i}}var PO=null;var Vb=!1,Pi=!1;function qk(r){Pi=r}var Pe=null,jn=!1;function Mr(r){Pe=r}var we=null;function Rr(r){we=r}var uo=null;function Fb(r){Pe!==null&&(!pr||(Pe.f&2)!==0)&&(uo??(uo=new Set)).add(r)}var Jr=null,Wn=0,Fi=null;function gO(r){Fi=r}var FO=1,pd=0,Fl=pd;function Vk(r){Fl=r}function Wu(){return++FO}function $l(r){var t=r.f;if((t&2048)!==0)return!0;if(t&2&&(r.f&=-65537),(t&4096)!==0){for(var e=r.deps,n=e.length,i=0;i<n;i++){var o=e[i];if($l(o)&&Ak(o),o.wv>r.wv)return!0}(t&512)!==0&&Zr===null&&_t(r,102
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==fa&&console.warn("Failed to hydrate: ",s),t.recover===!1&&BR(),Lb(),qu(e),Pr(!1),gd(r,t)}finally{Pr(n),Tt(i)}}var Gb=new Map;function HO(r,{target:t,anchor:e,props:n={},events:i,context:o,intro:s=!0,transformError:a}){Lb();var l=void 0,c=_O(()=>{var d=e??t.appendChild(ar());wh(d,{pending:()=>{}},m=>{ie({});var h=rt;if(o&&(h.c=o),i&&(n.$$events=i),xe&&Mi(m,null),rS=s,l=r(m,n)||ih(),rS=!0,xe&&(we.nodes.end=De,De===null||De.nodeType!==Ii||De.data!=="]"))throw Qc(),fa;oe()},a);var u=new Set,p=m=>{for(var h=0;h<m.length;h++){var g=m[h];if(!u.has(g)){u.add(g);var v=NO(g);for(let C of[t,document]){var b=Gb.get(C);b===void 0&&(b=new Map,Gb.set(C,b));var y=b.get(g);y===void 0?(C.addEventListener(g,zb,{passive:v}),b.set(g,1)):b.set(g,y+1)}}}};return p(Du(Yk)),qb.add(p),()=>{for(var m of u)for(let v of[t,document]){var h=Gb.get(v),g=h.get(m);--g==0?(v.removeEventListener(m,zb),h.delete(m),h.size===0&&Gb.delete(v)):h.set(m,g)}qb.delete(p),d!==e&&d.parentNode?.removeChild(d)}});return nS.set(l,c),l}var nS=new WeakMap;function op(r,t){let e=nS.get(r);return e?(nS.delete(r),e(t)):(j&&AR(),Promise.resolve())}var Go,_s,Ni,vd,Ch,xh,jb,jo=class{constructor(t,e=!0){fe(this,"anchor");qe(this,Go,new Map);qe(this,_s,new Map);qe(this,Ni,new Map);qe(this,vd,new Set);qe(this,Ch,!0);qe(this,xh,t=>{if(L(this,Go).has(t)){var e=L(this,Go).get(t),n=L(this,_s).get(e);if(n)rp(n),L(this,vd).delete(e);else{var i=L(this,Ni).get(e);i&&(rp(i.effect),L(this,_s).set(e,i.effect),L(this,Ni).delete(e),j&&(i.fragment.lastChild[yk]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of L(this,Go)){if(L(this,Go).delete(o),o===t)break;let a=L(this,Ni).get(s);a&&(sr(a.effect),L(this,Ni).delete(s))}for(let[o,s]of L(this,_s)){if(o===e||L(this,vd).has(o))continue;let a=()=>{if(Array.from(L(this,Go).values()).includes(o)){var c=document.createDocumentFragment();np(s,c),c.append(ar()),L(this,Ni).set(o,{effect:s,fragment:c})}else sr(s);L(this,vd).delete(o),L(this,_s).delete(o)};L(this,Ch)||!n?(L(this,vd).add(o),ws(s,a,!1)):a()}}});qe(this,jb,t=>{L(this,Go).delete(t);let e=Array.from(L(this,Go).values());for(let[n,i]of L(this,Ni))e.includes(n)||(sr(i.effect),L(this,Ni).delete(n))});this.anchor=t,Oe(this,Ch,e)}ensure(t,e){var n=_e,i=Nb();if(e&&!L(this,_s).has(t)&&!L(this,Ni).has(t))if(i){var o=document.createDocumentFragment(),s=ar();o.append(s),L(this,Ni).set(t,{effect:Or(()=>e(s)),fragment:o})}else L(this,_s).set(t,Or(()=>e(this.anchor)));if(L(this,Go).set(n,t),i){for(let[a,l]of L(this,_s))a===t?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of L(this,Ni))a===t?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(L(this,xh)),n.ondiscard(L(this,jb))}else xe&&(this.anchor=De),L(this,xh).call(this,n)}};Go=new WeakMap,_s=new WeakMap,Ni=new WeakMap,vd=new WeakMap,Ch=new WeakMap,xh=new WeakMap,jb=new WeakMap;function Rl(r,t,...e){var n=new jo(r);Yn(()=>{let i=t()??null;j&&i==null&&UR(),n.ensure(i,i&&(o=>i(o,...e)))},65536)}if(j){let r=function(t){if(!(t in globalThis)){let e;Object.defineProperty(globalThis,t,{configurable:!0,get:()=>{if(e!==void 0)return e;zR(t)},set:n=>{e=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function Eh(r){rt===null&&th("onMount"),ya&&rt.l!==null?zY(rt).m.push(r):Dt(()=>{let t=pt(r);if(typeof t=="function")return t})}function GO(r){rt===null&&th("onDestroy"),Eh(()=>()=>pt(r))}function zY(r){var t=r.l;return t.u??(t.u={a:[],b:[],m:[]})}var YO=new Map;function KO(r,t){var e=YO.get(r);e||(e=new Set,YO.set(r,e)),e.add(t)}function z(r,t,e=!1){var n;xe&&(n=De,Yr());var i=new jo(r),o=e?65536:0;function s(a,l){if(xe){var c=eh(n);if(a!==parseInt(c.substring(1))){var d=fs();Tt(d),i.anchor=d,Pr(!1),i.ensure(a,l),Pr(!0);return}}i.ensure(a,l)}Yn(()=>{var a=!1;t((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var jY=Symbol("NaN");function Th(r,t,e){xe&&Yr();var n=new jo(r),i=!Uo();Yn(()=>{var o=t();o!==o&&(o=jY),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,e)})}function yd(r,t){return t}function JY(r,t,
\r\f\xA0\v\uFEFF`];function ZO(r,t,e){var n=r==null?"":""+r;if(t&&(n=n?n+" "+t:t),e){for(var i of Object.keys(e))if(e[i])n=n?n+" "+i:i;else if(n.length)for(var o=i.length,s=0;(s=n.indexOf(i,s))>=0;){var a=s+o;(s===0||XO.includes(n[s-1]))&&(a===n.length||XO.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function JO(r,t=!1){var e=t?" !important;":";",n="";for(var i of Object.keys(r)){var o=r[i];o!=null&&o!==""&&(n+=" "+i+": "+o+e)}return n}function sS(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function eD(r,t){if(t){var e="",n,i;if(Array.isArray(t)?(n=t[0],i=t[1]):n=t,r){r=String(r).replaceAll(/\/\*.*?\*\//g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(sS)),i&&l.push(...Object.keys(i).map(sS));var c=0,d=-1;let g=r.length;for(var u=0;u<g;u++){var p=r[u];if(a?p==="/"&&r[u-1]==="*"&&(a=!1):o?o===p&&(o=!1):p==="/"&&r[u+1]==="*"?a=!0:p==='"'||p==="'"?o=p:p==="("?s++:p===")"&&s--,!a&&o===!1&&s===0){if(p===":"&&d===-1)d=u;else if(p===";"||u===g-1){if(d!==-1){var m=sS(r.substring(c,d).trim());if(!l.includes(m)){p!==";"&&u++;var h=r.substring(c,u).trim();e+=" "+h+";"}}c=u+1,d=-1}}}}return n&&(e+=JO(n)),i&&(e+=JO(i,!0)),e=e.trim(),e===""?null:e}return r==null?null:String(r)}function Ge(r,t,e,n,i,o){var s=r[Qf];if(xe||s!==e||s===void 0){var a=ZO(e,n,o);(!xe||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):t?r.className=a:r.setAttribute("class",a)),r[Qf]=e}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&r.classList.toggle(l,c)}return o}function aS(r,t={},e,n){for(var i in e){var o=e[i];t[i]!==o&&(e[i]==null?r.style.removeProperty(i):r.style.setProperty(i,o,n))}}function sp(r,t,e,n){var i=r[Xf];if(xe||i!==t){var o=eD(t,n);(!xe||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[Xf]=t}else n&&(Array.isArray(n)?(aS(r,e?.[0],n[0]),aS(r,e?.[1],n[1],"important")):aS(r,e,n));return n}function lS(r,t){t?r.hasAttribute("selected")||r.setAttribute("selected",""):r.removeAttribute("selected")}function oK(r,t){var e=r.__defaultValue,n=r.multiple,i=n?e??[]:null;if(!(n&&!io(i))){var o=r.selectedIndex,s=t&&n?new Set(r.selectedOptions):null;for(var a of r.options){var l=ap(a);lS(a,n?i.includes(l):Db(l,e))}if(t)if(s!==null)for(a of r.options){var c=s.has(a);a.selected!==c&&(a.selected=c)}else r.selectedIndex!==o&&(r.selectedIndex=o)}}function Dl(r,t,e=!1){if(r.multiple){if(t==null)return;if(!io(t))return IR();for(var n of r.options)n.selected=t.includes(ap(n));return}for(n of r.options){var i=ap(n);if(Db(i,t)){n.selected=!0;return}}(!e||t!==void 0)&&(r.selectedIndex=-1)}function Ll(r){var t=new MutationObserver(e=>{e.every(sK)||("__defaultValue"in r&&oK(r,!1),"__value"in r&&Dl(r,r.__value))});t.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Qr(()=>{t.disconnect()})}function cS(r,t,e=t){var n=new WeakSet,i=!0;Ab(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),ap);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&ap(l)}e(a),r.__value=a,_e!==null&&n.add(_e)}),Cr(()=>{var o=t();if(r===document.activeElement){var s=pr?gs:_e;if(n.has(s))return}if(Dl(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=ap(a),e(o))}r.__value=o,i=!1})}function ap(r){return"__value"in r?r.__value:r.value}function sK(r){if(r.target.closest("selectedcontent")!==null)return!0;if(r.type==="childList"){var t=[...r.addedNodes,...r.removedNodes];return t.length>0&&t.every(e=>e.nodeName==="SELECTEDCONTENT")}return!1}var dK=Symbol("is custom element"),uK=Symbol("is html"),pK=yb?"link":"LINK";var mK=yb?"progress":"PROGRESS";function Ct(r){if(xe){var t=!1,e=()=>{if(!t){if(t=!0,r.hasAttribute("value")){var n=r.value;le(r,"value",null),r.value=n}if(r.hasAttribute("checked")){var i=r.checked;le(r,"checked",null),r.checked=i}}};r[Sl]=e,wr(e),Sb()}}function Jn(r,t){var e=uS(r);e.value===(e.value=t??void 0)||r.value===t&&(t!==0||r.nodeName!==mK)||(r.value=t??"")}function bd(r,t){var e=uS(r);e.checked!==(e.checked=t??void 0)&&(r
`).map(y=>y.trim()).filter(y=>y.length>0),g=FS(h[0]??"(empty text card)",90),v=[`${h.length} line${h.length===1?"":"s"}`];c&&v.push(c);let b=v.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:b,searchText:`${a.id} ${g} ${b}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let m=RK(a.file),h=xt.test(m),g=h?"":"Canvas file cards must link to markdown files (.md).",v=FS(m.split("/").pop()??m,90),b=[FS(m,120)];c&&b.push(c),h||b.push("Not capturable in this version");let y=b.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:h,capturableReason:g}}let u=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,p=c||"Type is not currently capturable";return{id:a.id,type:l,title:u,subtitle:p,searchText:`${a.id} ${u} ${p}`.toLowerCase(),capturable:!1,capturableReason:"This Canvas node type is not capturable."}}),s={text:0,file:1,other:2};return o.sort((a,l)=>{let c=s[a.type]-s[l.type];return c!==0?c:a.title.localeCompare(l.title)})}catch{return[]}}Jt();Nh();Ms();an();lt();Le();var JK=["noteContent","propertyValue","captureTarget","fileName","lineTarget"],ZK=["captureTarget","fileName"],dr=JK,s0=3;function Ce(r,t,e=r.endsWith(":}}")?2:0){return{insert:r,description:t,caretOffset:e}}var eQ=[{regex:xD,contexts:dr,suggestion:Ce("{{VALUE}}","Asks you for text when the choice runs")},{regex:ED,contexts:dr,suggestion:Ce("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Ce("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Ce("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Ce("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Ce("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Ce("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Ce("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Ce("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Ce("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Ce("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Ce("{{VALUE:title|trim}}","Trims whitespace off the answer"),Ce("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:CD,contexts:dr,suggestion:Ce("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:TD,contexts:dr,suggestion:Ce("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Ce("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Ce("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Ce("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Ce("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable"),Ce("{{VDATE:date,dddd, MMMM Do, YYYY|case:lower}}","Lowercases the picked date after formatting")]},{regex:PD,contexts:dr,suggestion:Ce("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:OD,contexts:["noteContent","propertyValue"],suggestion:Ce("{{PROPERTY}}","Inserts the property's current value (property Captures only)")},{regex:DD,contexts:["noteContent"],suggestion:Ce("{{CURSOR}}","Places the cursor here (Capture and Template bodies)")},{regex:ID,contexts:dr,suggestion:Ce("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let t=[Ce("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return ZK.includes(r)||t.push(Ce("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Ce("{{FILE:<folder>|path}}","Same, but inserts its full path"),Ce("{{FILE:<folder>|type:image|link}}","Same, but links an image instead of a note"),Ce("{{FILE:<folder>|optional}}","Same, but skippable")),t.push(Ce("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),t}},{regex:MD,contexts:dr,suggestion:Ce("{{MVALUE}}","Asks you for a ma
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-ecj6o4 > input:where(.svelte-ecj6o4) {pointer-events:none;}`};function vt(r,t){ie(t,!0),Ae(r,pQ);let e=X(t,"checked",15),n=X(t,"disabled",3,!1),i=X(t,"ariaLabel",3,void 0),o=X(t,"onchange",3,void 0),s=k(()=>e()??!1);function a(){n()||(e(!f(s)),o()?.(e()))}function l(p){(p.key==="Enter"||p.key===" ")&&(p.preventDefault(),a())}var c=uQ();let d;var u=R(c);Ct(u),$(c),Q(()=>{d=Ge(c,1,"checkbox-container svelte-ecj6o4",null,d,{"is-enabled":f(s),"is-disabled":n()}),le(c,"aria-checked",f(s)),le(c,"aria-label",i()),le(c,"tabindex",n()?-1:0),bd(u,f(s))}),ge("click",c,a),ge("keydown",c,l),A(r,c),oe()}He(["click","keydown"]);var mQ=F("<option> </option>"),fQ=F('<select class="dropdown"></select>');function it(r,t){ie(t,!0);let e=X(t,"value",15,""),n=X(t,"disabled",3,!1),i=X(t,"ariaLabel",3,void 0),o=X(t,"onchange",3,void 0);var s=fQ();gt(s,21,()=>t.options,a=>a.value,(a,l)=>{var c=mQ(),d=re(c,!0),u={};Q(()=>{ee(d,f(l).label),u!==(u=f(l).value)&&(c.value=(c.__value=u)??"")}),A(a,c)}),$(s),Ll(s),Q(()=>{s.disabled=n(),le(s,"aria-label",i())}),ge("change",s,()=>o()?.(e())),cS(s,e),A(r,s),oe()}He(["change"]);hp();Ms();an();var vi=class extends Er{constructor(e,n,i,o=1/0){super(e,n);this.app=e;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.matchesByItem=new Map;this.items=i.map(s=>sn(s))}getSuggestions(e){let n=Hl(zl(e),this.items,i=>i,{limit:this.maxSuggestions});return this.matchesByItem=new Map(n.map(({item:i,matches:o})=>[i,o])),n.map(({item:i})=>i)}selectSuggestion(e){this.inputEl.value=e,Pa(this.inputEl),this.close()}renderSuggestion(e,n){Fs(n,aw(e),this.matchesByItem.get(e)??[])}};function hQ(r){return r?Array.isArray(r)?r:[r]:[]}function Id(r,t){let e=hQ(t(r));return{destroy(){e.forEach(n=>n.destroy())}}}Hh();var bQ=F("<textarea></textarea>"),wQ=F('<input type="text"/>'),CQ=F('<!> <div aria-live="polite"> </div>',1);function Lr(r,t){ie(t,!0);let e=X(t,"value",15,""),n=X(t,"placeholder",3,void 0),i=X(t,"inputKind",3,"text"),o=X(t,"required",3,!1),s=X(t,"requiredMessage",3,"This field is required"),a=X(t,"disabled",3,!1),l=X(t,"validator",3,void 0),c=X(t,"trim",3,!0),d=X(t,"suggestions",3,void 0),u=X(t,"maxSuggestions",3,1/0),p=X(t,"makeSuggesters",19,()=>[]),m=X(t,"app",3,void 0),h=X(t,"id",3,void 0),g=X(t,"ariaLabel",3,void 0),v=X(t,"onChange",3,void 0),b=pe(!1),y=pe(!1),C=pe(""),w=pe("neutral"),T=0,P=!1,_=`qa-hint-${Math.random().toString(36).slice(2)}`,I=te=>c()?te.trim():te;function D(te,W=!1,Z="neutral"){q(b,W,!0),q(C,te??"",!0),q(w,W?"neutral":Z,!0)}async function N(te){if(o()&&I(te).length===0)return D(f(y)?s():void 0,f(y)),!1;if(!l())return D(void 0),!0;let W=++T,Z=await Promise.resolve(l()(te));return W!==T||P?!0:typeof Z=="boolean"?(D(Z?void 0:"Invalid value",!Z),Z):typeof Z=="string"?(D(Z,!0),!1):(D(Z.message??(Z.valid?void 0:"Invalid value"),!Z.valid,Z.valid?Z.variant??"neutral":"neutral"),Z.valid)}function K(te){let W=te.currentTarget.value;q(y,!0),e(W),v()?.(W)}Dt(()=>{o(),f(y);let te=e();N(te)}),Dt(()=>()=>{P=!0});function ne(te){let W=[];m()&&d()&&d().length&&W.push(new vi(m(),te,d(),u()));for(let Z of p()){let se=Z(te);se&&W.push(se)}return W}var H=CQ(),O=ae(H);{var G=te=>{var W=bQ();rd(W);let Z;le(W,"spellcheck",!1),Ft(W,(se,ce)=>Id?.(se,ce),()=>ne),Ft(W,se=>pw?.(se)),Q(()=>{Z=Ge(W,1,"qa-validated-input-full-width qa-validated-input-margin-8 qa-validated-input-textarea",null,Z,{"is-invalid":f(b),"is-valid":!f(b)&&f(w)==="success"&&f(C).length>0}),le(W,"id",h()),le(W,"placeholder",n()),W.disabled=a(),le(W,"aria-label",g()),le(W,"aria-invalid",f(b)),le(W,"aria-describedby",_),Jn(W,e())}),ge("input",W,K),Kn("blur",W,()=>q(y,!0)),A(te,W)},V=te=>{var W=wQ();Ct(W);let Z;le(W,"spellcheck",!1),Ft(W,(se,ce)=>Id?.(se,ce),()=>ne),Q(()=>{Z=Ge(W,1,"qa-validated-input-full-width qa-validated-input-margin-8",null,Z,{"is-invalid":f(b),"is-valid":!f(b)&&f(w)==="success"&&f(C).length>0}),le(W,"id",h()),le(W,"placeholder",n()),W.disabled=a(),le(W,"aria-label",g()),le(W,"aria-invalid",f(b)),le(W,"aria-describedby",_),J
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),q1=F("<!> <!>",1),tX=F(`<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>`),z1=F("<!> <!> <!>",1),rX=F(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),nX=F(`<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>`),iX=F(`<div class="setting-item-description">The "Insert after" heading is created at its sorted position among ALL
same-level headings in the note (it is not scoped to one parent section). It
does NOT re-sort headings you already have; only the new one is placed. Use
"Insert at end of section" above for newest-on-top vs. appended entries within
each section.</div> <!> <!> <!> <!> <!> <!>`,1),oX=F("<!> <!> <!> <!> <!>",1);function tI(r,t){ie(t,!0);let e=X(t,"insertAfter",15);e().inline===void 0&&e(e().inline=!1,!0),e().replaceExisting===void 0&&e(e().replaceExisting=!1,!0),e().promptHeading===void 0&&e(e().promptHeading=!1,!0),e().insertAtEnd===void 0&&e(e().insertAtEnd=!1,!0),e().considerSubsections===void 0&&e(e().considerSubsections=!1,!0),e().blankLineAfterMatchMode||e(e().blankLineAfterMatchMode="auto",!0),e().createIfNotFound||e(e().createIfNotFound=!1,!0),e().createIfNotFoundLocation||e(e().createIfNotFoundLocation=Vi,!0);let n=[V=>new ln(t.app,V,t.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=k(()=>e().inline?[{value:Vi,label:"Top"},{value:xd,label:"Bottom"},{value:Ed,label:"Cursor"}]:[{value:Vi,label:"Top"},{value:xd,label:"Bottom"},{value:Ed,label:"Cursor"},{value:Yo,label:"Ordered 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 to bottom"},{value:"top",label:"Sort to top"}],c=pe(!!e().orderBy),d=k(()=>e().createIfNotFoundLocation===Yo),u=k(()=>e().createIfNotFound&&f(d)),p=k(()=>new Yp(t.app,t.plugin)),m=pe(!1);Dt(()=>{let V=e().after??"",M=f(p);if(!e().inline||V===""){q(m,!1);return}let B=!1;return M.format(V).then(J=>{B||q(m,/[\n\r]/.test(J),!0)}).catch(()=>{B||q(m,!1)}),()=>{B=!0}});let h=k(()=>e().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),g=k(()=>/\{\{V?DATE\b/i.test(e().after??"")),v=k(()=>f(u)&&e().orderBy?.by==="insertion"&&f(g)&&!eI(e().after??""));Dt(()=>{if(!f(u))return;let V=eI(e().after??"");if(!e().orderBy){e(e().orderBy={by:V?"date":"insertion",direction:"desc",dateFormat:V,unparseable:"bottom"},!0);return}!f(c)&&(e().orderBy.by==="insertion"||e().orderBy.by==="date")&&(e(e().orderBy.by=V?"date":"insertion",!0),e(e().orderBy.dateFormat=V,!0))});function b(V){e(e().createIfNotFoundLocation=V,!0),V===Yo?e(e().inline=!1,!0):(e(e().orderBy=void 0,!0),q(c,!1))}function y(V){q(c,!0),e().orderBy&&e(e().orderBy.by=V,!0)}function C(V){e().promptHeading||V&&!e().after.startsWith("#")&&(e(e().considerSubsections=!1,!0),new H1.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function w(V){V&&(e(e().inline=!1,!0),e(e().replaceExisting=!1,!0))}var T=oX(),P=ae(T);be(P,{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:M=>{vt(M,{onchange:w,get checked(){return e().promptHeading},set checked(B){e(e().promptHeading=B,!0)}})},$$slots:{control:!0}});var _=E(P,2);{var I=V=>{var M=eX();A(V,M)},D=V=>{var M=z1(),B=ae(M);ni(B,{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:(se,ce=$t)=>{var $e=q1(),Xe=ae($e);Lr(Xe,{get id(){return ce()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return e().after},set value(he){e(e().after=he,!0)}});var Ye=E(Xe,2);Hi(Ye,{get value(){return e().after},formatterKind:"lineTarget",get app(){return t.app},get plugin(){return t.plugin}}),A(se,$e)},$$slots:{default:!0}});var J=E(B,2);{let Z=ce=>{vt(ce,{get disabled(){return f(d)},get checked(){return e().inline},set checked($e){e(e().inline=$e,!0)}})},se=k(()=>f(d)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");be(J,{name:"Inline insertion",get desc(){return f(se)},control:Z,$$slots:{control:!0}})}var te=E(J,2);{var W=Z=>{var se=tX();A(Z,se)};z(te,Z=>{f
for Canvas card capture. Use top, bottom, insert-after, or insert-before
placement.</div>`),lX=F("<!> <!> <!> <!> <!>",1);function sI(r,t){ie(t,!0);let e=X(t,"choice",15),n=k(()=>!!e().captureToActiveFile),i=k(()=>EC(e())),o=k(()=>[{value:"top",label:f(n)?"At cursor":"Top of file"},...f(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"},{value:"property",label:"Property"}]);function s(y){if(y==="property"){e().propertyCapture??e(e().propertyCapture={property:{kind:"named",format:""},action:"set",createIfMissing:!0},!0);return}if(delete e().propertyCapture,e(e().prepend=!1,!0),e(e().insertAfter.enabled=!1,!0),e(e().insertAfter.promptHeading=!1,!0),e(e().insertAfter.inline=!1,!0),e(e().insertAfter.replaceExisting=!1,!0),e().insertBefore||e(e().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),e(e().insertBefore.enabled=!1,!0),e().newLineCapture||e(e().newLineCapture={enabled:!1,direction:"below"},!0),e(e().newLineCapture.enabled=!1,!0),e(e().activeFileWritePosition="cursor",!0),y==="top"){f(n)||e(e().prepend=!1,!0);return}if(y==="activeTop"){f(n)&&e(e().activeFileWritePosition="top",!0);return}if(y==="bottom"){f(n)?e(e().activeFileWritePosition="bottom",!0):e(e().prepend=!0,!0);return}if(y==="newLineAbove"){e(e().newLineCapture.enabled=!0,!0),e(e().newLineCapture.direction="above",!0);return}if(y==="newLineBelow"){e(e().newLineCapture.enabled=!0,!0),e(e().newLineCapture.direction="below",!0);return}if(y==="before"){e(e().insertBefore.enabled=!0,!0);return}e(e().insertAfter.enabled=!0,!0)}let a=k(()=>{if(e().propertyCapture)return!1;let y=typeof e().captureTo=="string"&&Ul(e().captureTo),C=t.app.workspace.getActiveViewOfType(G1.FileView)?.getViewType()==="canvas",w=f(n)&&!e().insertAfter.enabled&&!e().insertBefore?.enabled&&!e().newLineCapture?.enabled&&(e().activeFileWritePosition??"cursor")==="cursor"&&!e().prepend;return!(!(e().newLineCapture?.enabled||w)||(f(n)?!C:!y))});var l=lX(),c=ae(l);{let y=w=>{it(w,{get value(){return f(i)},get options(){return f(o)},onchange:s})},C=k(()=>f(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");be(c,{name:"Write position",get desc(){return f(C)},control:y,$$slots:{control:!0}})}var d=E(c,2);{var u=y=>{iI(y,{get app(){return t.app},get plugin(){return t.plugin},get config(){return e().propertyCapture},set config(C){e(e().propertyCapture=C,!0)}})};z(d,y=>{e().propertyCapture&&y(u)})}var p=E(d,2);{var m=y=>{tI(y,{get app(){return t.app},get plugin(){return t.plugin},get insertAfter(){return e().insertAfter},set insertAfter(C){e(e().insertAfter=C,!0)}})};z(p,y=>{!e().propertyCapture&&e().insertAfter.enabled&&y(m)})}var h=E(p,2);{var g=y=>{nI(y,{get app(){return t.app},get plugin(){return t.plugin},get insertBefore(){return e().insertBefore},set insertBefore(C){e(e().insertBefore=C,!0)}})};z(h,y=>{!e().propertyCapture&&e().insertBefore?.enabled&&y(g)})}var v=E(h,2);{var b=y=>{var C=aX();A(y,C)};z(v,y=>{f(a)&&y(b)})}A(r,l),oe()}var cX=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","arc
was changed by the error. Include the message below if you report this.</p> <!></div>`),bX={hash:"svelte-1vm72jj",code:".qaMountFailed.svelte-1vm72jj {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaMountFailedHead.svelte-1vm72jj {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaMountFailedTitle.svelte-1vm72jj {font-weight:var(--font-semibold);color:var(--text-normal);}.qaMountFailedBody.svelte-1vm72jj {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaMountFailedDetail.svelte-1vm72jj {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function lI(r,t){Ae(r,bX);let e=X(t,"detail",3,"");var n=yX(),i=R(n),o=R(i);Qe(o,{iconId:"alert-triangle",size:16});var s=E(o,2),a=re(s);$(i);var l=E(i,4);{var c=d=>{var u=vX(),p=re(u,!0);Q(()=>ee(p,e())),A(d,u)};z(l,d=>{e()&&d(c)})}$(n),Q(()=>ee(a,`QuickAdd couldn't display ${t.what??""}`)),A(r,n)}var wX="this part of QuickAdd";function wi(r,t,e,n={}){let i=new Set(r.childNodes),o;try{o=gd(t,{target:r,props:e})}catch(a){return CX(r,i,Ia(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,op(o))}}}function CX(r,t,e,n){let i=n.what??wX;for(let l of Array.from(r.childNodes))t.has(l)||l.remove();Me(e,`Couldn't display ${i}`);let o=r.createDiv({cls:"qa-mount-failed-host"}),s=null;try{s=gd(n.fallbackComponent??lI,{target:o,props:{what:i,detail:e.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&op(s),o.remove())}}}function Wi(r){return Xc(r)}var nm=require("obsidian");var Y1=require("obsidian");ye();function xX(r,t){try{let e=r.setting;return!e?.open||!e?.openTabById?(S.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(e.open(),e.openTabById(t),!0)}catch(e){return S.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${e}`),!1}}function K1(r,t,e){try{let n=r.setting;return typeof n?.navigateToSearchResult!="function"?(S.logMessage("QuickAdd: Obsidian's settings page navigation is unavailable."),!1):(n.navigateToSearchResult({tab:t,pagePath:e},null),!0)}catch(n){return S.logMessage(`QuickAdd: Failed to open settings page: ${n}`),!1}}function Q1(r){return r.setting}function X1(r,t){try{let e=Q1(r);return typeof e?.openPage!="function"?(S.logMessage("QuickAdd: Obsidian's settings page navigation is unavailable."),!1):(e.openPage(t),!0)}catch(e){return S.logMessage(`QuickAdd: Failed to open settings page: ${e}`),!1}}function _C(r,t,e){t.title=e,t.titlebarEl.querySelector(".setting-page-title")?.setText(e),Q1(r)?.updatePageTitle?.()}function mc(r,t,e){let n=xX(r,t);return!n&&e?.notice!==!1&&new Y1.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}var Ao=class extends nm.SettingPage{constructor(e,n,i){super();this.app=e;this.onSave=i;this.rendered=!1;this.opener=null;this.title=n,this.rootEl.addClass("quickAddModal","qa-builder-page")}open(){return this.opener=EX(activeDocument.activeElement),X1(this.app,this)?!0:(new nm.Notice(`QuickAdd: Couldn't open the settings for \u201C${this.title}\u201D.`),!1)}display(){this.rendered||(this.rendered=!0,this.render(this.containerEl))}hide(){this.destroy(),super.hide(),this.onSave(this.result()),this.opener&&TX(this.opener)}save(){this.onSave(this.result())}destroy(){}addNameSetting(e,n,i,o){return new nm.SettingGroup(e).addSetting(s=>{s.setName("Name").addText(a=>{a.setValue(n).onChange(l=>{o(l),_C(this.app,this,l.trim()||i)})})})}};function EX(r){return r?.instanceOf(HTMLElement)?{el:r,label:r.closest("[data-choice-id]")?null:r.getAttribute("aria-label"),content:r.closest(".vertical-tab-content-container"),focusVisible:r.matches(":focus-visible")}:null}function TX({el:r,label:t,content:e,focusVisible:n}){window.setTimeout(()=>{let i=r.isConnected
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function LX(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ru(r,t){var e=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!e){if(Array.isArray(r)||(e=EI(r))||t&&r&&typeof r.length=="number"){e&&(r=e);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){e=e.call(r)},n:function(){var l=e.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&e.return!=null&&e.return()}finally{if(s)throw a}}}}function Gt(r){return r.ownerDocument.defaultView||window}function MC(r,t,e){return{win:r,id:r.setTimeout(t,e)}}function Iv(r){r&&r.win.clearTimeout(r.id)}function os(r){return JSON.stringify(r,null,2)}function RC(r){if(!r)throw new Error("cannot get depth of a falsy node");return TV(r,0)}function TV(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return r.parentElement?TV(r.parentElement,t+1):t-1}function NX(r,t){if(Object.keys(r).length!==Object.keys(t).length)return!1;for(var e in r)if(!{}.hasOwnProperty.call(t,e)||t[e]!==r[e])return!1;return!0}function VX(r,t){if(r.length!==t.length)return!1;for(var e=0;e<r.length;e++)if(r[e]!==t[e])return!1;return!0}var BX="finalize",UX="consider";function fm(r,t,e){r.dispatchEvent(new(Gt(r)).CustomEvent(BX,{detail:{items:t,info:e}}))}function Cc(r,t,e){r.dispatchEvent(new(Gt(r)).CustomEvent(UX,{detail:{items:t,info:e}}))}var qC="draggedEntered",Mv="draggedLeft",zC="draggedOverIndex",TI="draggedLeftDocument",OC={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function qX(r,t,e){r.dispatchEvent(new(Gt(r)).CustomEvent(qC,{detail:{indexObj:t,draggedEl:e}}))}function zX(r,t,e){r.dispatchEvent(new(Gt(r)).CustomEvent(Mv,{detail:{draggedEl:t,type:OC.LEFT_FOR_ANOTHER,theOtherDz:e}}))}function HX(r,t){r.dispatchEvent(new(Gt(r)).CustomEvent(Mv,{detail:{draggedEl:t,type:OC.OUTSIDE_OF_ANY}}))}function WX(r,t,e){r.dispatchEvent(new(Gt(r)).CustomEvent(zC,{detail:{indexObj:t,draggedEl:e}}))}function GX(r){var t=Gt(r);t.dispatchEvent(new t.CustomEvent(TI,{detail:{draggedEl:r}}))}var gr={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:qC,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:zC,DRAGGED_LEFT:Mv,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},fn={POINTER:"pointer",KEYBOARD:"keyboard"},jX={space:[" "],enter:["Enter"],space_or_enter:[" ","Enter"]},_V="space_or_enter",YX={space:"space-bar",enter:"enter",space_or_enter:"space-bar or enter"},hm="isDndShadowItem",HC="data-is-dnd-shadow-item-internal",KX="data-is-dnd-shadow-item-hint",gm="id:dnd-shadow-placeholder-0000",QX="dnd-action-dragged-el",nr="id",mI=0;function kV(){mI++}function SV(){if(mI===0)throw new Error("Bug! trying to decrement when there are no dropzones");mI--}var _I=typeof window>"u",We=function(){};function fI(r){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,e,n=t?ZX(r):r.getBoundingClientRect(),i=Gt(r).getComputedStyle(r),o=i.transform;if(o){var s,a,l,c;if(o.startsWith("matrix3d("))e=o.slice(9,-1).split(/, /),s=+e[0],a=+e[5],l=+e[12],c=+e[13];else if(o.startsWith("matrix("))e=o.slice(7,-1).split(/, /),s=+e[0],a=+e[3],l=+e[4],c=+e[5];else return n;var d=i.transformOrigin,u=n.left-l-(1-s)*parseFloat(d),p=n.top-c-(1-a)*parseFloat(d.slice(d.indexOf(" ")+1)),m=s?n.width/s:r.offsetWidth,h=a?n.height/a:r.offsetHeight;return{x:u,y:p,width:m,height:h,top:p,right:u+m,bottom:p+h,left:u}}else return n}function hI(r){var t=fI(r),e=Gt(r);return{top:t.top+e.scrollY,bottom:t.bottom+e.scrollY,left:t.left+e.scrollX,right:t.right+e.scrollX}}function AV(r){var t=r.getBoundingClientRect(),e=Gt(r);return{top:t.top+e.scrollY,bottom:t.bottom+e.scrollY,left:t.left+e.scrollX,right:t.right+e.scrollX}}function IV(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function XX(r,t){return Math.sqrt(Math.pow(r.x-t.x,2)+Math.pow(r.y-t.y,2))}function Tv(r,t){return r.y<=t.bottom&&r.y>=t.top&&r.x>=t.left&&r.x<=t.right}function PV(r){return IV(AV(r))}function mV(r,t){var e=PV(t);return XX(r,e)}function JX(r){var t=AV(r),e=r.ownerDocument.documentElement;return t.right<0||t.left>e.scrollWidth||t.bottom<0||t.top>e.scrollHeight}function ZX(r){for(var t=r.getBoundingClientRect(),e={top:t.top,bot
file's folder (or you'll be prompted to pick one if no file is open).</div>`),s8=F('<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),a8=F("<!> <!> <!>",1),DI=F("<!> <!>",1),l8=F("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1),c8=F("<!> <!> <!> <!>",1);function LI(r,t){ie(t,!0);let e=M=>{var B=s8(),J=ae(B),te=R(J),W=R(te);MI(W,{get folders(){return n().folder.folders},onChange:Ye=>n(n().folder.folders=Ye,!0)}),$(te);var Z=E(te,2),se=R(Z);Ct(se),Cr(()=>Zn(se,()=>f(v),Ye=>q(v,Ye))),Ft(se,(Ye,he)=>Id?.(Ye,he),()=>y);var ce=E(se,2);$(Z),$(J);var $e=E(J,2);{var Xe=Ye=>{var he=o8();A(Ye,he)};z($e,Ye=>{f(h)&&Ye(Xe)})}Kn("keypress",se,w),ge("click",ce,C),A(M,B)},n=X(t,"choice",15),i=X(t,"commitPending",15),o=k(()=>t.plugin.getTemplateFiles().map(M=>M.path)),s=k(()=>Ja(za(t.app)));function a(M){let B=M.trim();return B?Aa(B)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:nn(t.app,B)!==null||"Template not found":!0}let l=k(()=>n().fileNameFormat.enabled?n().fileNameFormat.format:""),c=[M=>new ln(t.app,M,t.plugin,"fileName")],d=k(()=>RI(n(),n().fileNameFormat.enabled?n().fileNameFormat.format:xr)),u=k(()=>f(d)?"Show matching notes and unresolved links in the note-title prompt.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),p=k(()=>iu(n().folder)),m=k(()=>JV[f(p)]),h=k(()=>f(p)==="specified"&&n().folder.folders.length===0);function g(M){n(n().folder=QV(n().folder,M),!0)}let v=pe(""),b;function y(M){return b=new IC(t.app,M,f(s),n().folder.folders),b}Dt(()=>{b?.updateCurrentItems(n().folder.folders)});function C(){let M=f(v).trim();if(M){if(n().folder.folders.some(B=>B===M)){S.logWarning("cannot add same folder twice.");return}n().folder.folders.push(M),q(v,"")}}function w(M){M.key==="Enter"&&C()}function T(){f(p)==="specified"&&C()}i(T),GO(T);let P=k(()=>aV(n().fileExistsBehavior)),_=k(()=>f(P)!=="prompt"&&f(P)!=="keep"),I=k(()=>iV(f(P)==="update"?"update":"create")),D=k(()=>n().fileExistsBehavior.kind==="apply"?n().fileExistsBehavior.mode:f(I)[0].id);function N(M){n(n().fileExistsBehavior=lV(M,n().fileExistsBehavior),!0)}function K(M){n(n().fileExistsBehavior={kind:"apply",mode:M},!0)}var ne=c8(),H=ae(ne);yo(H,{heading:"Template",children:(M,B)=>{var J=DI(),te=ae(J);ni(te,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(se,ce=$t)=>{Lr(se,{get id(){return ce()},get value(){return n().templatePath},placeholder:"Template path",get app(){return t.app},get suggestions(){return f(o)},maxSuggestions:50,validator:a,onChange:$e=>n(n().templatePath=$e.trim(),!0)})},$$slots:{default:!0}});var W=E(te,2);ni(W,{name:"File name",desc:"Leave empty to ask for the note title.",children:(se,ce=$t)=>{var $e=a8(),Xe=ae($e),Ye=()=>f(l),he=ve=>n(n().fileNameFormat={enabled:ve.trim()!=="",format:ve},!0);Lr(Xe,{get id(){return ce()},get value(){return Ye()},set value(ve){he(ve)},placeholder:"{{VALUE}}",get makeSuggesters(){return c}});var Re=E(Xe,2);Xd(Re,{get value(){return f(l)}});var Je=E(Re,2);{let ve=k(()=>YC(n().folder));Hi(Je,{get value(){return f(l)},formatterKind:"fileName",get targetFolderPath(){return f(ve)},get app(){return t.app},get plugin(){return t.plugin}})}A(se,$e)},$$slots:{default:!0}}),A(M,J)},$$slots:{default:!0}});var O=E(H,2);yo(O,{heading:"Location",children:(M,B)=>{var J=DI(),te=ae(J);{let se=$e=>{it($e,{get value(){return f(p)},get options(){return XV},ariaLabel:"New note location",onchange:g})},ce=k(()=>f(p)==="specified"?e:void 0);be(te,{name:"New note location",get desc(){return f(m)},get body(){return f(ce)},control:se,$$slots:{control:!0}})}var W=E(te,2);{var Z=se=>{be(se,{name:"Include subfolders",desc:"Get prompted to choose from both the selected folders and their subfolders when creating the note.",control:$e=>{vt($e,{get checked(){return n().folder.chooseFromSubfo
/* A macro without steps shows no blank list area. The zone type is unique
to this list, so an empty list is never a drop target. */.quickAddCommandList.is-empty.svelte-15ra1ch {display:none;}`};function FP(r,t){let e=Ri();ie(t,!0),Ae(r,b7);let n=X(t,"commands",31,()=>Ze([])),i=k(()=>{let M=new Set;return Array.isArray(n())?n().filter(B=>{if(typeof B!="object"||B===null)return!1;let J=B.id;return typeof J!="string"||J===""||M.has(J)?!1:(M.add(J),!0)}):[]}),o=`command:${e}`,s=xU.Platform.isMobile,a=xm(),l=k(()=>!s&&!a.armed),c=pe(void 0),d=M=>M,u=M=>M,p=M=>M,m=M=>M,h=M=>M,g=M=>M;function v(){t.saveCommands(Wi(n()))}let b=null,y=pe(!1);function C(M){a.markStarted(),q(y,M.detail.info.trigger!==gr.DRAG_STOPPED),wm(M,Ec);let B=M.detail.items;b=ym(B,M.detail.info.id)??b,n(xi(B))}function w(M){let B=xi(M.detail.items),J=M.detail.info.id;b?.item.id===J&&!B.some(te=>te.id===J)&&(B=[...B],B.splice(Math.min(b.index,B.length),0,b.item)),b=null,q(y,!1),n(B),M.detail.info.source===fn.POINTER&&a.reset(),v()}let T=()=>{a.startDrag()};function P(M,B){let J=document.activeElement?.getAttribute("aria-label"),te=xi(f(i)),W=bm(te,M,B);if(!W)return;let Z=W.findIndex(ce=>ce.id===M),se=W[Z];n(W),v(),nu(`Moved ${Ec(se)} to position ${Z+1} of ${W.length}`),J&&Em(f(c),J)}function _(M){n(jV(f(i),{...M})),v()}async function I(M){await t.onConfigureCondition?.(M)&&_(M)}function D(M){t.onEditThenBranch?.(M,()=>_(M))}function N(M){t.onEditElseBranch?.(M,()=>_(M))}function K(M){let B=te=>{let W={...M,choice:te,name:te.name};_(W)},J=M.choice;J.type==="Template"?new Tm(t.app,J,t.plugin,B).open():J.type==="Capture"&&new sm(t.app,J,t.plugin,B).open()}async function ne(M){let B;try{B=await su(M,t.app)}catch(te){if(px(te))return;throw te}if(!B?.script){S.logWarning(`${M.name} could not be loaded.`);return}let J=B.settings??{};new cx(t.app,M,J,()=>v()).open()}async function H(M){await new Ux(t.app,M).waitForClose&&_(M)}async function O(M){let B=await new zx(t.app,M).waitForClose;B&&_(B)}var G=y7();let V;gt(G,21,()=>xi(f(i)),M=>M.id,(M,B)=>{var J=bt(),te=ae(J);{var W=he=>{{let Re=k(()=>d(f(B)));BI(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onUpdateCommand:_,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},Z=he=>{{let Re=k(()=>u(f(B)));UI(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onConfigureChoice:K,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},se=he=>{{let Re=k(()=>p(f(B)));qI(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onConfigureScript:ne,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},ce=he=>{{let Re=k(()=>m(f(B)));ZI(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onConfigureAssistant:H,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},$e=he=>{{let Re=k(()=>h(f(B)));PP(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onConfigureOpenFile:O,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},Xe=he=>{{let Re=k(()=>g(f(B)));$P(he,{get command(){return f(Re)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onConfigureCondition:I,onEditThenBranch:D,onEditElseBranch:N,onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})}},Ye=he=>{VI(he,{get command(){return f(B)},get dragDisabled(){return f(l)},startDrag:T,get onDeleteCommand(){return t.deleteCommand},onMoveUp:()=>P(f(B).id,-1),onMoveDown:()=>P(f(B).id,1)})};z(te,he=>{f(B).type==="Wait"?he(W):f(B).type==="NestedChoice"?he(Z,1):f(B).type==="UserScript"?he(se,2):f(B).type==="AIAssistant"?he(ce,3):f(B).type==="OpenFile"?he($e,4):f(B).type==="Conditional"?he(Xe,5):he(Ye,-1)})}A(M,J)}),$(G),xn(G,M=>q(c,M),()=>f(c)),Ft(G,(M,B)=>vm?.(M,B),()=>Cm({items:f(i),dragDisabled:f(l),type:o,resolveLabel:Ec})),Q(()=>V=Ge(G,1,"quickAddCommandList svelte-15ra1ch",null,V,{"is-empty":f(i).length===0&&!f(y)})),Kn("consider",G,C),Kn("
or edited here. Nothing has been changed or deleted, and QuickAdd will not
overwrite it.</p> <p class="qaDataUnreadableBody svelte-sorpfp">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
vault. Make a copy of that file before editing it.</p></div>`),T7={hash:"svelte-sorpfp",code:".qaDataUnreadable.svelte-sorpfp {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-sorpfp {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-sorpfp {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-sorpfp {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};function GP(r,t){Ae(r,T7);var e=E7(),n=R(e),i=R(n);Qe(i,{iconId:"alert-triangle",size:16});var o=E(i,2),s=re(o);$(n),Xt(4),$(e),Q(()=>ee(s,`QuickAdd couldn't read ${t.what??""}`)),A(r,e)}var Zm=class{constructor(t){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=t.app,this.plugin=t.plugin,this.unreadable=Wt(t.commands),this.commandsRef=HI(t.commands).commands,this.choices=t.choices,this.onCommandsChange=t.onCommandsChange,this.conditionalHandlers=t.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(t){return this.destroy(),this.containerEl=t,t.empty(),t.addClass("quickAddCommandEditor"),this.unreadable?(this.renderUnreadableCard(t),!1):this.renderCommandList(t)?(this.renderCommandBar(t),this.renderAddObsidianCommandSetting(t),this.renderAddEditorCommandSetting(t),this.renderAddUserScriptSetting(t),this.renderAddChoiceSetting(t),!0):!1}renderUnreadableCard(t){let e=t.createDiv("commandList");this.unreadableCardHandle=wi(e,GP,{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(t=>{let e=this.app.commands.commands[t];this.obsidianCommands.push(new Yv(e.name,e.id))})}loadScriptCandidates(){this.scriptCandidates=Yx(this.app)}renderCommandList(t){let e=t.createDiv("commandList");return this.commandListProps=TU({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw S.logError("command not found"),new Error("command not found");if(!await Ei(this.app,{title:`Delete '${i.name}'?`,message:"The command will be removed from this macro.",action:"Delete"}))return;if(!await sx(this.app,i)){new _i.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=wi(e,FP,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(t){let e=t.createDiv("quickCommandContainer");this.addChoiceButton(e,"Capture",Sc),this.addChoiceButton(e,"Template",Ks),this.addCommandButton(e,"file-search","Add open file command",()=>new Xx),this.addCommandButton(e,"clock","Add wait command",()=>new Wx(100)),this.addCommandButton(e,"git-branch","Add conditional command",()=>new Jx),U.getState().disableOnlineFeatures||this.addCommandButton(e,"bot","Add AI Assistant command",()=>new Qx)}renderAddObsidianCommandSetting(t){let e,n=()=>{let i=e.getValue();if(!i.trim())return;let o=this.obsidianCommands.find(a=>a.name===i);if(!o){S.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new Yv(o.name,o.commandId);s.generateId(),this.addCommand(s),e.setValue("")};new _i.Setting(t).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{e=this.configureSuggestedInput(i,"Obsidian command",this.obsidianCommands.map(o=>o.name),n)}).addButto
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-jvakpr svg:last-child {margin-left:-0.1em;opacity:0.85;}
/* Per-folder ("compact") controls render as quiet, clickable text links \u2014 not
filled buttons \u2014 so they read as "add inside this folder" affordances and
don't compete with the global primary CTA, especially when repeated across
nested folders. */.qaAddChoiceControls.compact.svelte-jvakpr {gap:1rem;}.qaAddChoiceControls.compact.svelte-jvakpr button:where(.svelte-jvakpr) {font-size:var(--font-ui-smaller);padding:2px 0;gap:0.25em;background:transparent;border:none;box-shadow:none;color:var(--text-muted);}.qaAddChoiceControls.compact.svelte-jvakpr button:where(.svelte-jvakpr):hover {color:var(--text-accent);text-decoration:underline;}
/* Mobile/touch: stretch so the two buttons fill the bar width instead of
cramming to the right. Driven by \`fill\` (Platform.isMobile from the bottom
bar) because viewport media queries don't fire under desktop mobile-emulation. */.qaAddChoiceControls.fill.svelte-jvakpr {flex:1;}.qaAddChoiceControls.fill.svelte-jvakpr button:where(.svelte-jvakpr) {flex:1;justify-content:center;}
/* Narrow desktop windows stack the non-compact controls. Filled controls (the
mobile bottom bar) are excluded so this can't override \`.fill\`'s side-by-side
50/50 layout on a phone-width viewport (Platform.isMobile + width <= 800px). */
@media (max-width: 800px) {.qaAddChoiceControls.svelte-jvakpr:not(.compact):not(.fill) {flex-direction:column;align-items:stretch;}
}`};function rf(r,t){ie(t,!0),Ae(r,D7);let e=X(t,"targetFolderId",3,void 0),n=X(t,"targetFolderName",3,void 0),i=X(t,"compact",3,!1),o=X(t,"fill",3,!1),s=pe(!1);function a(N){let K=new lE.Menu;for(let H of zU)K.addItem(O=>O.setTitle(lE.Platform.isPhone?H.label:`${H.label} \u2014 ${H.description}`).setIcon(H.iconId).onClick(G=>{let V=G.altKey===!0;t.onAddChoice(aE(H.type),H.type,e(),V)}));q(s,!0),K.onHide(()=>{q(s,!1)});let ne=N.target?.closest("button");if(ne){let H=ne.getBoundingClientRect();K.showAtPosition({x:H.left,y:H.bottom+4,width:H.width,overlap:!0,left:!i()})}else K.showAtMouseEvent(N)}function l(){t.onAddChoice(aE("Multi"),"Multi",e(),!0)}let c=k(()=>i()?"Add choice":"New choice"),d=k(()=>i()?"Add folder":"New folder"),u=k(()=>n()?`Add choice to ${n()}`:f(c)),p=k(()=>n()?`Add folder to ${n()}`:f(d));var m=O7();let h;var g=R(m),v=R(g);Qe(v,{iconId:"folder-plus",size:14});var b=E(v,2),y=re(b,!0);$(g);var C=E(g,2);let w;var T=R(C);Qe(T,{iconId:"plus",size:14});var P=E(T,2),_=re(P,!0),I=E(P,2);{var D=N=>{Qe(N,{iconId:"chevron-down",size:12})};z(I,N=>{i()||N(D)})}$(C),$(m),Q(()=>{h=Ge(m,1,"qaAddChoiceControls svelte-jvakpr",null,h,{compact:i(),fill:o()&&!i()}),le(g,"aria-label",f(p)),le(g,"title",i()?f(p):void 0),ee(y,f(d)),w=Ge(C,1,"qaNewChoiceBtn svelte-jvakpr",null,w,{"mod-cta":!i()}),le(C,"aria-expanded",f(s)),le(C,"aria-label",f(u)),le(C,"title",i()?f(u):void 0),ee(_,f(c))}),ge("click",g,l),ge("click",C,a),A(r,m),oe()}He(["click"]);var L7=F('<div class="rightButtonsContainer svelte-1tlf1y8"><!> <!> <!> <!> <!> <!></div>'),N7={hash:"svelte-1tlf1y8",code:`.rightButtonsContainer.svelte-1tlf1y8 {display:flex;align-items:center;
/* Icons carry their own 3px padding inside the choice rows (24px hit
boxes), so a tight gap keeps the cluster compact without touching. */gap:2px;flex:0 0 auto;}`};function Zv(r,t){ie(t,!0),Ae(r,N7);let e=X(t,"showConfigureButton",3,!0),n=X(t,"showDuplicateButton",3,!0),i=X(t,"commandEnabled",3,!1),o=X(t,"choiceName",3,"");var s=L7(),a=R(s);{var l=v=>{{let b=k(()=>`Configure${o()?" "+o():""}`);Et(v,{iconId:"settings",get label(){return f(b)},extraClass:"qa-row-secondary-action",get onclick(){return t.onConfigureChoice}})}};z(a,v=>{e()&&v(l)})}var c=E(a,2);{var d=v=>{{let b=k(()=>`Duplicate${o()?" "+o():""}`);Et(v,{iconId:"copy",get label(){return f(b)},extraClass:"qa-row-secondary-action",get onclick(){return t.onDuplicateChoice}})}};z(c,v=>{n()&&v(d)})}var u=E(c,2);{let v=k(()=>`Delete${o()?" "+o():""}`);Et(u,{iconId:"trash-2",get label(){return f(v)},extraClass:"qa-row-secondary-action",get onclick(){return t.onDeleteChoice}})}var p=E(u,2);{var m=v=>{{let b=k(()=>`More options${o()?" for "+o():""}`);Et(v,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return f(b)},onclick:y=>t.onOpenMenu?.(y.currentTarget)})}};z(p,v=>{t.onOpenMenu&&v(m)})}var h=E(p,2);{let v=k(()=>`Command palette${o()?": "+o():""}`);Et(h,{iconId:"zap",get ariaPressed(){return i()},get label(){return f(v)},extraClass:"qa-row-secondary-action",get onclick(){return t.onToggleCommand}})}var g=E(h,2);{let v=k(()=>`Reorder${o()?" "+o():""}`);Hr(g,{get label(){return f(v)},get dragDisabled(){return t.dragDisabled},get onDragStart(){return t.onDragHandleDown},get onMoveUp(){return t.onMoveUp},get onMoveDown(){return t.onMoveDown}})}$(s),A(r,s),oe()}var pE=require("obsidian");var WU=require("obsidian");lt();var t$="quickadd:move-to-root";function V7(r,t){let e=mr(t);if(e.some(i=>Ee(i)&&i.id===r.id))return!1;let n=i=>{for(let o of i){if(!Ee(o))continue;let s=Ne(o);if(s.some(a=>a?.id===r.id)||n(s))return!0}return!1};return n(e)}function B7(r,t){let e=[],n=Array.isArray(t)?t:[],i=(o,s=[])=>{for(let a of o){if(!Ee(a))continue;let l=a.name??"";if(a.type==="Multi"){let c=[...s,l];U7(r,a)||e.push({id:a.id,path:c.join(" / ")}),i(Ne(a),[...s,l])}}};return i(n,[]),e}function U7(r,t){if(t.type!=="Multi"||r.id===t.id||vo(t))return!0;if(r.type==="Multi"){let e=new Set,n=i=>{Ee(i)&&(e.add(i.id),Ne(i).forEach(n))};if(Ne(r).forEach(n),e.has(t.id))return!0}return!1}function nf(r,t){return{onRename:()=>t.onRenameChoice(r),onToggle:()=>t.onToggleCommand(r),onConfigure:()=>t.onConfigureChoice(r),onDuplicate:()=>t.onDuplicateChoice(r),onDelete:()=>t.onDeleteChoice(r),onMove:e=>t.onMoveChoice(r,e)}}function GU(r,t,e,n){let i=new WU.Menu;i.addItem(s=>s.setTitle(t.command?"Disable in command palette":"Enable in command palette").setIcon("zap").onClick(n.onToggle)).addItem(s=>s.setTitle("Rename").setIcon("pencil").onClick(n.onRename)).addItem(s=>s.setTitle("Configure").setIcon("settings").onClick(n.onConfigure)).addItem(s=>s.setTitle("Duplicate").setIcon("copy").onClick(n.onDuplicate)).addItem(s=>s.setTitle("Delete").setIcon("trash-2").onClick(n.onDelete)).addSeparator(),V7(t,e)&&i.addItem(s=>s.setTitle("Move to: (root)").setIcon("folder-up").onClick(()=>n.onMove(t$)));let o=B7(t,e);return o.length===0?i.addItem(s=>s.setTitle("Move to: (no folders)").setDisabled(!0).setIcon("folder")):o.forEach(s=>i.addItem(a=>a.setTitle(`Move to: ${s.path}`).setIcon("folder-open").onClick(()=>n.onMove(s.id)))),i}function cE(r,t,e,n,i){t.preventDefault(),GU(r,e,n,i).showAtMouseEvent(t)}function dE(r,t,e,n,i){let o=t.getBoundingClientRect();GU(r,e,n,i).showAtPosition({x:o.left,y:o.bottom})}var jU=require("obsidian");function uE(r,t,e,n){t.replaceChildren(),jU.MarkdownRenderer.render(n,r,t,"/",e)}lt();var q7=F('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),z7={hash:"svelte-1xw9zlu",code:""};function r$(r,t){ie(t,!0),Ae(r,z7);let e=!0,n=pe(void 0),i=new pE.Component;Dt(()=>{f(n)&&uE(t.choice.name,f(n),i,t.app)}),Dt(()=>()=>i.unload());function o(p){cE(t.app,p,t.choice,t.roots,nf(t.choice,t.actions))}function s(p){dE(t.app,p,t.choice,t.roots,nf(t.choice,t.actions)
in <code class="svelte-gckzoy">data.json</code>.</p>`),G7=F('<div class="nestedAddRow svelte-gckzoy"><!></div>'),j7=F("<!> <!>",1),Y7=F('<div class="nestedChoiceList svelte-gckzoy"><!></div>'),K7=F('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-gckzoy"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),Q7={hash:"svelte-gckzoy",code:`
/* Row surface (min-height, padding, radius, hover, rhythm) is shared with
leaf rows and lives in styles.css \u2014 see "Choice list rows". Only the
folder-specific pieces stay here. */
/* Base icon = chevron-down (expanded); collapsed rotates to point RIGHT,
matching Obsidian's own collapse grammar (file explorer, outline). */.multiChoiceCollapseIcon.svelte-gckzoy {transition:transform 150ms ease;}.multiChoiceCollapseIcon.is-collapsed.svelte-gckzoy {transform:rotate(-90deg);}
@media (prefers-reduced-motion: reduce) {.multiChoiceCollapseIcon.svelte-gckzoy {transition:none;}
}
/* Full-width collapse toggle: reset native <button> chrome while keeping
native keyboard activation + aria-expanded. It hosts the shared icon
column (the chevron), so the folder NAME lands on the exact leaf-name x
for free \u2014 same 8px column gap as the leaf rows. */.multiChoiceListItemName.svelte-gckzoy {flex:1 1 auto;min-width:0;align-self:stretch;display:flex;align-items:center;
/* Obsidian's base button centers flex content; the name must not rely
on a growing child to stay left (it stopped growing for the count). */justify-content:flex-start;gap:8px;background:transparent;border:none;box-shadow:none;padding:0;
/* Obsidian's base button rule sets height: var(--input-height) (30px),
which would make folder rows 4px taller than leaf rows \u2014 the exact
rhythm break this redesign removes. */height:auto;min-height:0;font:inherit;color:inherit;text-align:left;cursor:pointer;
/* Suppress double-tap-zoom + its click delay on touch \u2014 proper touch hygiene
for a tap target, and reduces the ghost-click the dedupe above also guards. */touch-action:manipulation;}
/* The count reads as part of the label ("Misc \xB7 12"), so the name must not
grow \u2014 it keeps its ellipsis via flex-shrink + the shared min-width: 0. */.multiChoiceListItemName.svelte-gckzoy .choiceListItemName {flex:0 1 auto;}
/* Same slot, weight and colour as the empty-folder hint in ChoiceList, so a
folder we cannot read reads as a variation of "empty" rather than an alarm. */.qaUnreadableFolder.svelte-gckzoy {margin:0;padding:6px 8px 8px;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.4;}.qaUnreadableFolder.svelte-gckzoy code:where(.svelte-gckzoy) {font-size:inherit;}.qaFolderCount.svelte-gckzoy {flex:0 0 auto;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);font-variant-numeric:tabular-nums;line-height:1;}.multiChoiceListItemName.svelte-gckzoy:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;border-radius:var(--radius-s, 4px);}
/* Just the indent \u2014 the drop-into-folder ring is drawn on the ACTUAL dndzone
(.choiceList, in ChoiceList.svelte) so the highlighted area equals the
droppable area (WYSIWYG); it is NOT drawn on this wrapper, which extends past
the zone to the add-row/hint. The ::before is an indent GUIDE under the
parent's icon column (x = row padding 8px + half the 18px column, minus
half the line), clarifying what belongs to the open folder. */.nestedChoiceList.svelte-gckzoy {position:relative;padding-left:26px;}.nestedChoiceList.svelte-gckzoy::before {content:"";position:absolute;left:16px;top:3px;bottom:3px;width:1px;background:var(--background-modifier-border);pointer-events:none;}
/* The per-folder add-row reads as a ghost row of the folder: aligned to the
child rows' padding, one tight step (4px) below the last child. */.nestedAddRow.svelte-gckzoy {margin:2px 0 4px 0;padding:0 8px;}`};function n$(r,t){ie(t,!0),Ae(r,Q7);let e=X(t,"choice",7),n=X(t,"forceDragDisabled",3,!1),i=k(()=>Ne(e())),o=k(()=>vo(e())),s=!0,a=pe(void 0),l=new mE.Component;Dt(()=>{f(a)&&uE(e().name,f(a),l,t.app)}),Dt(()=>()=>l.unload());function c(D){cE(t.app,D,e(),t.roots,nf(e(),t.actions))}function d(D){dE(t.app,D,e(),t.roots,nf(e(),t.actions))}let u={...pt(()=>t.actions),onReorderChoices:D=>{e().choices=D,t.actions.onCommitFolder(e().id,D)}};function p(){n()||t.actions.onToggleCollapsed(e())}var m=K7(),h=R(m),g=R(h),v=R(g);let b;var y=R(v);Qe(y,{iconId:"chevron-down",size:16}),$(v);var C=E(v,2);xn(C,D=>q(a,D),()=>f(a));var w=E(C,2);{var T=D=>{var N=H7(),K=re(N,!0);Q(()=>ee(K,f(i).length)),A(D,N)};z(w,D=>{e().collapsed&&f(i).length>0&&D(T)})}$(g),Ft(g,D=>jC?.(D));var P=E(g,2);Zv(P,{get onDragHandleDown(){return t.startDrag},onDeleteChoice:()=>t.actions.onDeleteChoice(e()),onConfigureChoice:()=>t.actions.onConfigureChoice(e()),onToggleCommand:()=>t.actions.onToggleCommand(e()),onDuplicateChoice:()=>t.actions.onDuplicateChoice(e()),onOpenMenu:d,get onMoveUp(){return t.onMoveUp},get onMoveDown(){return t.onMoveDown},showConfigureButton:s,get dragDisabled(){return t.dragDisabled},get choiceName(){return e().name},get commandEnabled(){return e().command},showDuplicateButton:!0}),$(h);var _=E(h,2);{var I=D=>{var N=bt(),K=ae(N);{var ne=H=>{var O=Y7(),G=R(O);{var V=B=>{var J=W7();A(B,J)},M=B=>{var J=j7(),te=ae(J);{let se=k(()=>f(i).length===0),ce=k(()=>t.rootReorder??t.actions.onReorderChoices);of(te,{get app(){return t.app},get roots(){return t.roots},get choices(){return f(i)},nested:!0,get isEmptyFolder(){return f(se)},get forceDragDisabled(){return n()},get rootReorder(){return f(ce)},get actions(){return u}})}var W=E(te,2);{var Z=se=>{var ce=G7(),$e=R(ce);rf($e,{compact:!0,get targetFolderId(){return e().id},get targetFolderName(){return e().name},get onAddChoice(){return t.actions.onAddChoice}}),$(ce),A(se,ce)};z(W,se=>{n()||se(Z)})}A(B,J)};z(G,B=>{f(o)?B(V):B(M,-1)})}$(O),A(H,O)};z(K,H=>{e().collapsed||H(ne)})}A(D,N)};z(_,D=>{(!t.collapseId||t.collapseId&&e().id!==t.collapseId)&&D(I)})}$(m),Q(()=>{le(h,"data-choice-id",e().id),le(g,"aria-expanded",!e().collapsed),le(g,"aria-label",`Toggle ${e().name}`),b=Ge(v,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-gckzoy",null,b,{"is-collapsed":e().collapsed})}),ge("contextmenu",h,c),ge("click",h,D=>{mE.Platform.isMobile||D.target.closest("button, a")||p()}),ge("click",g,p),A(r,m),oe()}He(["contextmenu","click"]);var YU=require("obsidian");lt();var X7=F("<div><!></div>"),J7=F("<div></div>"),Z7={hash:"svelte-10tg5sy",code:`.choiceList.svelte-10tg5sy {width:auto;}
/* Root (non-nested) empty list keeps a little bottom breathing room. The only way to
render it empty is a zero-match filter \u2014 a truly empty tree shows the hero state. */.choiceList.qa-empty.svelte-10tg5sy:not(.qa-nested) {padding-bottom:0.5rem;}.choiceList.qa-nested.svelte-10tg5sy {
/* Own the 2px name->first-row gap so the empty drop band sits the same distance
below the folder name as a populated folder's first row (collapses with the
row's own margin-top, so populated folders look identical). */margin-top:2px;position:relative; /* anchor the ring (::before) */border-radius:var(--radius-m);transition:background-color 120ms ease;}
/* The drop ring is drawn a few px OUTSIDE the content as an absolutely-positioned
::before (adds no layout) \u2014 "synthetically" bigger than the rows so it doesn't
clamp straight against the choice names. The right edge stays at the content edge:
the settings pane is overflow-x:hidden, so extending the ring right would clip it. */.choiceList.qa-nested.svelte-10tg5sy::before {content:"";position:absolute;inset:-4px 0 -4px -6px;border-radius:var(--radius-m);border:2px dashed transparent;pointer-events:none;transition:border-color 120ms ease;}.choiceList.qa-nested.svelte-10tg5sy.qa-folder-droptarget {background-color:var(--background-modifier-hover);}.choiceList.qa-nested.svelte-10tg5sy.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-10tg5sy {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-10tg5sy::after {content:"Empty \u2014 add a choice or drag one here.";color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.3;padding-left:8px; /* align with the child rows' own left padding */pointer-events:none;user-select:none;}
@media (prefers-reduced-motion: reduce) {.choiceList.qa-nested.svelte-10tg5sy,
.choiceList.qa-nested.svelte-10tg5sy::before {transition:none;}
}`};function of(r,t){ie(t,!0),Ae(r,Z7);let e=X(t,"choices",31,()=>Ze([])),n=X(t,"forceDragDisabled",3,!1),i=X(t,"isEmptyFolder",3,!1),o=X(t,"nested",3,!1),s=k(()=>{let w=new Set;return mr(e()).filter(T=>{if(!Ee(T))return!1;let P=T.id;return typeof P!="string"||P===""||w.has(P)?!1:(w.add(P),!0)})}),a=k(()=>t.rootReorder??t.actions.onReorderChoices),l=YU.Platform.isMobile,c=pe(""),d=xm(),u=k(()=>n()||!l&&!d.armed),p=pe(void 0),m=null;function h(w){if(n())return;d.markStarted(),wm(w);let T=w.detail.items;m=ym(T,w.detail.info.id)??m,q(c,w.detail.info.id,!0),e(xi(T))}function g(w){if(n())return;q(c,"");let T=xi(w.detail.items),P=w.detail.info.id;w.detail.info.trigger===gr.DROPPED_INTO_ANOTHER?T=T.filter(_=>_.id!==P):m?.item.id===P&&!T.some(_=>_.id===P)&&(T=[...T],T.splice(Math.min(m.index,T.length),0,m.item)),m=null,e(T),d.reset(),t.actions.onReorderChoices(e())}let v=()=>{n()||d.startDrag()};function b(w,T){if(n())return;let P=document.activeElement?.getAttribute("aria-label"),_=xi(f(s)),I=bm(_,w.id,T);if(!I)return;let D=I.findIndex(N=>N.id===w.id);e(I),t.actions.onReorderChoices(e()),nu(`Moved ${w.name} to position ${D+1} of ${I.length}`),P&&Em(f(p),P)}var y=J7();let C;gt(y,21,()=>xi(f(s)),w=>w.id,(w,T)=>{var P=X7(),_=R(P);{var I=N=>{{let K=k(()=>t.roots??e()),ne=k(()=>n()?void 0:()=>b(f(T),-1)),H=k(()=>n()?void 0:()=>b(f(T),1));r$(N,{get app(){return t.app},get roots(){return f(K)},get dragDisabled(){return f(u)},startDrag:v,get actions(){return t.actions},get choice(){return f(T)},get onMoveUp(){return f(ne)},get onMoveDown(){return f(H)}})}},D=N=>{{let K=k(()=>t.roots??e()),ne=k(()=>n()?void 0:()=>b(f(T),-1)),H=k(()=>n()?void 0:()=>b(f(T),1));n$(N,{get app(){return t.app},get roots(){return f(K)},get dragDisabled(){return f(u)},startDrag:v,get actions(){return t.actions},get collapseId(){return f(c)},get forceDragDisabled(){return n()},get rootReorder(){return f(a)},get choice(){return f(T)},get onMoveUp(){return f(ne)},get onMoveDown(){return f(H)}})}};z(_,N=>{f(T).type!=="Multi"?N(I):N(D,-1)})}$(P),A(w,P)}),$(y),xn(y,w=>q(p,w),()=>f(p)),Ft(y,(w,T)=>vm?.(w,T),()=>Cm({items:f(s),dragDisabled:f(u),dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),Q(()=>C=Ge(y,1,"choiceList svelte-10tg5sy",null,C,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":f(s).length===0})),Kn("consider",y,h),Kn("finalize",y,g),A(r,y),oe()}var eJ=F('<pre class="qaChoicesUnavailableDetail svelte-1t3kvu9"> </pre>'),tJ=F(`<div class="qaChoicesUnavailable svelte-1t3kvu9"><div class="qaChoicesUnavailableHead svelte-1t3kvu9"><!> <span class="qaChoicesUnavailableTitle svelte-1t3kvu9"> </span></div> <p class="qaChoicesUnavailableBody svelte-1t3kvu9">Something in this vault's QuickAdd settings could not be read. Your choices
have not been changed or deleted, and QuickAdd will not overwrite them.</p> <p class="qaChoicesUnavailableBody svelte-1t3kvu9">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
copy of that file before editing it.</p> <!></div>`),rJ={hash:"svelte-1t3kvu9",code:".qaChoicesUnavailable.svelte-1t3kvu9 {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaChoicesUnavailableHead.svelte-1t3kvu9 {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaChoicesUnavailableTitle.svelte-1t3kvu9 {font-weight:var(--font-semibold);color:var(--text-normal);}.qaChoicesUnavailableBody.svelte-1t3kvu9 {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaChoicesUnavailableDetail.svelte-1t3kvu9 {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function sf(r,t){Ae(r,rJ);let e=X(t,"what",3,"your choices"),n=X(t,"detail",3,"");var i=tJ(),o=R(i),s=R(o);Qe(s,{iconId:"alert-triangle",size:16});var a=E(s,2),l=re(a);$(o);var c=E(o,6);{var d=u=>{var p=eJ(),m=re(p,!0);Q(()=>ee(m,n())),A(u,p)};z(c,u=>{n()&&u(d)})}$(i),Q(()=>ee(l,`QuickAdd couldn't display ${e()??""}`)),A(r,i)}var fE=require("obsidian");ye();nt();Gs();ye();nt();function nJ(r){return`${$U(r)} name`}async function KU(r,t,e){try{let i=(await ir.Prompt(r,nJ(e),void 0,t)).trim();return!i||i===t?null:i}catch(n){return Be(n)||S.logError(Ia(n,"Could not rename")),null}}var JU=require("obsidian");lt();ye();lt();var i$=new WeakMap;function QU(r){let t=i$.get(r);if(t)return t;let e=o0(r);return i$.set(r,e),e}function XU(r){return i$.has(r)}function o$(r,t){if(!Array.isArray(r))return r;let e=XU(r),{choices:n,repaired:i}=QU(r);if(e)return n;for(let{choice:o}of i)if(o.command)try{t.enableCommand(o)}catch(s){S.logError(`Could not register a command for the repaired choice "${o.name}": ${s instanceof Error?s.message:String(s)}`)}return n}function ZU(r,t){let e=t.trim();if(!e)return r;let n=(0,JU.prepareFuzzySearch)(e),i=e.toLowerCase(),o=(s,a=!1)=>{if(!Ee(s))return null;let l=typeof s.name=="string"?s.name:"";if(s.type!=="Multi")return a||n(l)?s:null;let c=a||l.toLowerCase().includes(i),d=p=>Ne(s).map(m=>o(m,p)).filter(m=>m!==null),u=d(a);return c&&u.length===0&&(u=d(!0)),c||u.length>0?{...s,collapsed:!1,choices:u}:null};return r.map(s=>o(s)).filter(s=>s!==null)}function s$(r){return Ee(r)?r.command?!0:Ne(r).some(s$):!1}function ey(r,t){if(!Ee(r))return r;if(r.id===t.id)return{...r,...t};if($a(r)){let e=Ne(r).map(i=>ey(i,t));return{...r,choices:e}}return r}tn();function _r(r,t){if(Object.is(r,t))return!0;if(r===null||t===null)return r===t;if(typeof r!=typeof t)return!1;if(Array.isArray(r)||Array.isArray(t))return!Array.isArray(r)||!Array.isArray(t)||r.length!==t.length?!1:r.every((e,n)=>_r(e,t[n]));if(typeof r=="object"&&typeof t=="object"){let e=r,n=t,i=Object.keys(e),o=Object.keys(n);return i.length!==o.length?!1:i.every(s=>Object.prototype.hasOwnProperty.call(n,s)&&_r(e[s],n[s]))}return!1}function dl(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)&&Object.getPrototypeOf(r)===Object.prototype}function iJ(r){return dl(r)&&typeof r.name=="string"&&Array.isArray(r.models)}function oJ(r){return dl(r)&&typeof r.name=="string"&&typeof r.maxTokens=="number"&&!Array.isArray(r.models)}function sJ(r){if(typeof r.id=="string"&&r.id.trim().length>0)return`id:${r.id.trim().toLowerCase()}`;let t=String(r.name??"").trim().toLowerCase(),e=String(r.endpoint??"").trim().toLowerCase().replace(/\/+$/,"");return`name:${t}\0${e}`}function aJ(r){return dl(r)&&typeof r.id=="string"&&r.id.trim().length>0}function lJ(r){return`id:${String(r.id).trim()}`}function cJ(r){return String(r.name??"").trim().toLowerCase()}function eq(r,t){let e=new Map;for(let n of r){if(!dl(n))continue;let i=t(n);!i||i==="id:"||i==="name:\0"||e.has(i)||e.set(i,n)}return e}function dJ(r,t,e,n,i){let o=eq(r??[],n),s=eq(e,n),a=[],l=new Set;for(let c of t){if(!dl(c)){a.push(ke(c));continue}let d=n(c);if(l.has(d))continue;l.add(d);let u=o.get(d),p=s.get(d);if(!s
text, or run a macro. Group them with folders. <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Learn more</a></p> <div class="choiceEmptyActions svelte-i6fsu8"><!></div> <!></div>`),hJ=F('<button class="search-input-clear-button qaFilterClearButton svelte-i6fsu8" aria-label="Clear filter"></button>'),gJ=F('<div class="choiceFilterEmpty svelte-i6fsu8">No choices match your filter.</div>'),vJ=F('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-i6fsu8" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),yJ=F('<div class="choiceFilterBar svelte-i6fsu8"><div class="search-input-container choiceFilterInput svelte-i6fsu8"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-i6fsu8"><!> <!></div>',1),bJ=F("<div><!></div>"),wJ={hash:"svelte-i6fsu8",code:`.qaAIAssistantEmptyBtn.svelte-i6fsu8 {display:inline-flex;align-items:center;gap:0.375rem;margin-top:0.75rem;width:auto;color:var(--text-muted);font-size:var(--font-ui-small);}.choiceViewBottomBar.svelte-i6fsu8 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
/* AI Assistant as a quiet icon button (matches the per-row action icons),
leading the right cluster so the bar's width barely changes when AI/online
features toggle. */.qaAIAssistantBtn.svelte-i6fsu8 {flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;color:var(--text-muted);}.qaAIAssistantBtn.svelte-i6fsu8:hover {color:var(--text-normal);}.choiceEmptyState.svelte-i6fsu8 {display:flex;flex-direction:column;align-items:center;text-align:center;gap:0.5rem;padding:2.5rem 1rem;color:var(--text-muted);}.choiceEmptyTitle.svelte-i6fsu8 {font-weight:var(--font-semibold);color:var(--text-normal);}.choiceEmptyBody.svelte-i6fsu8 {margin:0;max-width:42ch;}.choiceEmptyActions.svelte-i6fsu8 {margin-top:0.5rem;}.choiceFilterBar.svelte-i6fsu8 {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-i6fsu8 {width:100%;}
/* Obsidian styles .search-input-clear-button (position, the \xD7 glyph, hover)
\u2014 we only reset the <button> chrome so that styling shows through. A real
<button> (Obsidian uses a div) keeps it keyboard-operable. */.qaFilterClearButton.svelte-i6fsu8 {background:transparent;border:none;box-shadow:none;padding:0;margin:0;cursor:var(--cursor, pointer);}.choiceFilterEmpty.svelte-i6fsu8 {color:var(--text-faint);font-size:var(--font-ui-small, 13px);padding:12px 8px 16px;}`};function a$(r,t){ie(t,!0),Ae(r,wJ);let e=X(t,"choices",31,()=>Ze([])),n=pe(""),i=k(()=>!Array.isArray(e())),o=k(()=>`The "choices" value in data.json is ${e()===null?"null":`of type "${typeof e()}"`}, but QuickAdd expects a list.`),s=iq.Platform.isMobile,a=pe(Ze(U.getState().disableOnlineFeatures)),l=new sE(pt(()=>t.plugin));e(o$(e(),l)),Dt(()=>{let h=U.subscribe(g=>{e(o$(g.choices,l)),q(a,g.disableOnlineFeatures,!0)});return()=>h()});let c=nq({get app(){return t.app},get plugin(){return t.plugin},get choices(){return e()},set choices(h){e(h)},get filterQuery(){return f(n)},set filterQuery(h){q(n,h,!0)},commandRegistry:l,saveChoices:h=>t.saveChoices(h)});var d=bJ(),u=R(d);{var p=h=>{sf(h,{get detail(){return f(o)}})},m=h=>{var g=bt(),v=ae(g);wh(v,{onerror:y=>S.logError(`QuickAdd could not render the choice list: ${y instanceof Error?y.message:String(y)}`),failed:(y,C=$t)=>{{let w=k(()=>C()instanceof Error?C().message:String(C()));sf(y,{get detail(){return f(w)}})}}},y=>{var C=bt(),w=ae(C);{var T=I=>{var D=fJ(),N=R(D);Qe(N,{iconId:"folder-plus",size:28});var K=E(N,4),ne=E(R(K));$(K);var H=E(K,2),O=R(H);rf(O,{get onAddChoice(){return c.onAddChoice}}),$(H);var G=E(H,2);{var V=M=>{var B=mJ(),J=R(B);Qe(J,{iconId:"sparkles",size:16}),Xt(2),$(B),ge("click",B,function(...te){t.openAISettings?.apply(this,te)}),A(M,B)};z(G,M=>{f(a)||M(V)})}$(D),Q(()=>le(ne,"href",is.gettingStarted)),A(I,D)},P=k(()=>e().length===0&&f(n).trim().length===0),_=I=>{var D=yJ(),N=ae(D),K=R(N),ne=R(K);Ct(ne),le(ne,"spellcheck",!1);var H=E(ne,2);{var O=se=>{var ce=hJ();ge("click",ce,()=>q(n,"")),A(se,ce)};z(H,se=>{f(n)&&se(O)})}$(K),$(N);var G=E(N,2);{var V=se=>{of(se,{get app(){return t.app},get roots(){return e()},get actions(){return c},get choices(){return e()},set choices(ce){e(ce)}})},M=k(()=>f(n).trim().length===0),B=se=>{let ce=k(()=>ZU(e(),f(n)));var $e=bt(),Xe=ae($e);{var Ye=Re=>{var Je=gJ();A(Re,Je)},he=Re=>{of(Re,{get app(){return t.app},get roots(){return e()},get choices(){return f(ce)},forceDragDisabled:!0,get actions(){return c}})};z(Xe,Re=>{f(ce).length===0?Re(Ye):Re(he,-1)})}A(se,$e)};z(G,se=>{f(M)?se(V):se(B,-1)})}var J=E(G,2),te=R(J);{var W=se=>{var ce=vJ(),$e=R(ce);Qe($e,{iconId:"sparkles",size:16}),$(ce),ge("click",ce,function(...Xe){t.openAISettings?.apply(this,Xe)}),A(se,ce)};z(te,se=>{f(a)||se(W)})}var Z=E(te,2);rf(Z,{get onAddChoice(){return c.onAddChoice},get fill(){return s}}),$(J),ge("keydown",ne,se=>{se.key==="Escape"&&f(n)&&(q(n,""),se.stopPropagation())}),Zn(ne,()=>f(n),se=>q(n,se)),A(I,D)};z(w,I=>{f(P)?I(T):I(_,-1)})}A(y,C)}),A(h,g)};z(u,h=>{f(i)?h(p):h(m,-1)})}$(d),A(r,d),oe()}He(["click","keydown"]);Qi();je();Hh();var CJ=F('<div class="qa-gv__empty svelte-it20w4">No global variables yet.</div>'),xJ=F('<div class="qa-gv__row qa-gv__row--head svelte-it20w4"><div class="qa-gv__cell qa-gv__name">Name</div> <div class="qa-gv__cell qa-gv__value">Value</div> <div class="qa-gv__cell qa-gv__ops svelte-it20w4">Actions</div></div>'),EJ=F('<div class="qa-gv__row svelte-it20w4"><div class="qa-gv__cell qa-gv__name svelte-it20w4"><input type="text" placeholder="Name" class="svelte-it20w4"/></div> <div class="qa-gv__cell qa-gv__value svelte-it20w4"><textarea rows="2" placeholder="Snippet value (supports QuickAdd tokens)" class="svelte-it20w4"></textarea></div> <div class="qa-gv__cell qa-gv__ops svelte-it20w4"><button class="qa-gv__btn danger svelte-it20w4" title="Delete">Delete</button></div></div>'),TJ=F('<div class="qa-gv svelte-it20w4"><div class="qa-gv__desc svelte-it20w4">Define reusable snippets referenced as <code>&#123;&#123;GLOBAL_VAR:&lt;name&gt;&#125;&#125;</code>. Snippets support other QuickAdd tokens and expand before VALUE/VDATE/etc.</div> <div class="qa-gv__table svelte-it20w4"><!> <!></div> <div class="
/* Keeps "Add variable" right-aligned now that it is the row's only child. */.qa-gv__actions.svelte-it20w4 {display:flex;justify-content:flex-end;}.qa-gv__desc.svelte-it20w4 {color:var(--text-muted);font-size:12px;}.qa-gv__empty.svelte-it20w4 {color:var(--text-muted);font-size:var(--font-ui-smaller);padding:6px 0;}.qa-gv__table.svelte-it20w4 {display:grid;gap:8px;}.qa-gv__row.svelte-it20w4 {display:grid;grid-template-columns:180px 1fr 140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-it20w4 {font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-it20w4 input[type="text"]:where(.svelte-it20w4) {width:100%;}.qa-gv__cell.svelte-it20w4 textarea:where(.svelte-it20w4) {width:100%;resize:vertical;}.qa-gv__ops.svelte-it20w4 {display:flex;gap:6px;align-items:center;}.qa-gv__btn.svelte-it20w4 {padding:4px 8px;}.qa-gv__btn.danger.svelte-it20w4 {color:var(--text-error);}
@media (max-width: 900px) {.qa-gv__row.svelte-it20w4 {grid-template-columns:1fr;}.qa-gv__row--head.svelte-it20w4 {display:none;}
}`};function l$(r,t){ie(t,!0),Ae(r,_J);let e=pe(Ze([]));function n(w,T){if(!T.has(w))return w;let P=1;for(;T.has(`${w}${P}`);)P++;return`${w}${P}`}function i(){let T=U.getState().globalVariables||{};q(e,Object.keys(T).map(P=>({name:P,value:T[P]??""})),!0)}let o=!1;function s(){let w=f(e).map(I=>I.name.trim()),T=w.some(I=>!I),P=new Set(w).size!==w.length;if(T||P)return;let _={};for(let I of f(e))_[I.name.trim()]=I.value??"";o=!0;try{U.setState({globalVariables:_})}finally{o=!1}}function a(){let w=new Set(f(e).map(P=>P.name)),T=n("NewVar",w);q(e,[...f(e),{name:T,value:""}],!0),s()}function l(w){q(e,f(e).filter((T,P)=>P!==w),!0),s()}function c(w){return new ln(t.app,w,t.plugin),{destroy(){}}}let d;function u(w){d!==void 0&&window.clearTimeout(d),d=window.setTimeout(()=>{d=void 0,s()},200)}Dt(()=>{let w=U.subscribe(()=>{o||i()});return i(),()=>{d!==void 0&&(window.clearTimeout(d),s()),w()}});var p=TJ(),m=E(R(p),2),h=R(m);{var g=w=>{var T=CJ();A(w,T)},v=w=>{var T=xJ();A(w,T)};z(h,w=>{f(e).length===0?w(g):w(v,-1)})}var b=E(h,2);gt(b,17,()=>f(e),yd,(w,T,P)=>{var _=EJ(),I=R(_),D=R(I);Ct(D),Ft(D,O=>c?.(O)),Cr(()=>Zn(D,()=>f(T).name,O=>f(T).name=O)),$(I);var N=E(I,2),K=R(N);rd(K),Ft(K,O=>c?.(O)),Ft(K,O=>pw?.(O)),Cr(()=>Zn(K,()=>f(T).value,O=>f(T).value=O)),$(N);var ne=E(N,2),H=re(ne);$(_),ge("input",D,()=>{u(f(T))}),ge("input",K,()=>u(f(T))),ge("click",H,()=>l(f(e).indexOf(f(T)))),A(w,_)}),$(m);var y=E(m,2),C=re(y);$(p),ge("click",C,a),A(r,p),oe()}He(["input","click"]);je();bi();Jt();var kq=require("obsidian");ml();lt();Gr();Jt();Ac();er();var AJ=new Set;function c$(r,t,e){return r?t.has(r.id)?e.has(r.id):!0:!1}function IJ(r,t,e,n){switch(r.type){case"Choice":{let i=r;if(!e.has(i.choiceId))return!0;let o=t.get(i.choiceId);return o&&c$(o.choice,t,e)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&c$(i.choice,t,e)&&n(i.choice),!0}default:return!1}}function PJ(r){let t=new Map,e=(n,i,o)=>{for(let s of n){if(!Ee(s))continue;let a=[...o,s.name];t.set(s.id,{choice:s,parentId:i,path:a}),uu(s)&&Array.isArray(s.choices)&&e(s.choices,s.id,a)}};return e(mr(r),null,[]),t}function aq(r){let t=new Set;for(let e of Ne(r))Ee(e)&&t.add(e.id);return Xi(r)&&d$(r.macro?.commands,t),t}function d$(r,t){for(let e of Mt(r))if(Tr(e))switch(e.type){case"Choice":{let n=e;n.choiceId&&t.add(n.choiceId);break}case"Conditional":{let n=e;d$(n.thenCommands,t),d$(n.elseCommands,t);break}case"NestedChoice":{let i=e.choice;if(!i)break;let o=aq(i);for(let s of o)t.add(s);break}default:break}}function gE(r,t,e){let n=PJ(r),i=new Set,o=new Set,s=e?.excludedChoiceIds??AJ,a=t.filter(c=>!s.has(c)),l=[];for(;a.length>0;){let c=a.shift();if(i.has(c))continue;if(s.has(c)){i.add(c);continue}let d=n.get(c);if(!d){o.add(c);continue}i.add(c),l.push(c);let u=aq(d.choice);for(let p of u){if(!n.has(p)){o.add(p);continue}s.has(p)||a.push(p)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function lq(r,t,e,n){let i=new Set(t),o=new Set,s=l=>{!l||!c$(l,r,i)||o.has(l.id)||(o.add(l.id),e(l),uu(l)&&Array.isArray(l.choices)&&l.choices.forEach(s),Xi(l)&&a(l.macro?.commands))},a=l=>{for(let c of Mt(l))if(Tr(c)&&!IJ(c,r,i,s)&&(n(c),c.type==="Conditional")){let d=c;a(d.thenCommands),a(d.elseCommands)}};for(let l of t){let c=r.get(l);c&&s(c.choice)}}function vE(r,t){let e=new Set,n=new Set;return lq(r,t,()=>{},i=>{if(i.type==="UserScript"){let o=i;o.path&&e.add(o.path)}else if(i.type==="Conditional"){let{condition:o}=i;o.mode==="script"&&o.scriptPath&&n.add(o.scriptPath)}}),{userScriptPaths:e,conditionalScriptPaths:n}}function yE(r,t){let e=new Set,n=new Set,i=new Set;return lq(r,t,o=>{if(qn(o)&&o.templatePath&&e.add(En(o.templatePath)),pl(o)){let s=o.createFileIfItDoesntExist;s?.enabled&&s.createWithTemplate&&s.template&&n.add(En(s.template));for(let a of u$(o))i.add(a)}},()=>{}),{templatePaths:e,captureTemplatePaths:n,includePaths:i}}function u$(r){let t=r.format;return!t?.enabled||typeof t.format!="string"?new Set:Xs(t.format)}function cq(r,t){let e=t.trim().toLowerCase();return e?r.filter(n=>`${n.path.join(" ")} ${n.choice.type}`.toLowerCase().includes(e)):r}f
/* List padding + row padding lands on the 16px inset of the mod-list rows
below, so every row in the modal starts on the same edge. */.qa-export-choice.svelte-1way66v {display:flex;align-items:center;gap:var(--size-4-2);padding:var(--size-4-1) var(--size-4-3);padding-inline-start:calc(
var(--size-4-3) + var(--qa-export-depth, 0) * var(--size-4-4)
);font-size:var(--font-ui-small);border-radius:var(--radius-s);cursor:var(--cursor);}.qa-export-choice.svelte-1way66v:hover {background-color:var(--background-modifier-hover);}.qa-export-choice.svelte-1way66v input:where(.svelte-1way66v) {flex-shrink:0;margin:0;}.qa-export-choice-name.svelte-1way66v {min-width:0;overflow-wrap:anywhere;}.qa-export-choice-path.svelte-1way66v {min-width:0;color:var(--text-muted);font-size:var(--font-ui-smaller);overflow-wrap:anywhere;}.qa-export-choice-type.svelte-1way66v {margin-inline-start:auto;}.qa-export-count.svelte-1way66v {color:var(--text-normal);font-variant-numeric:tabular-nums;}.qa-export-callout.svelte-1way66v {margin:0;}.qa-export-callout.svelte-1way66v .callout-content:where(.svelte-1way66v) {font-size:var(--font-ui-small);}.qa-export-callout.svelte-1way66v p:where(.svelte-1way66v) {margin:var(--size-4-2) 0 0;}.qa-export-callout.svelte-1way66v ul:where(.svelte-1way66v) {margin:var(--size-4-1) 0 0;padding-inline-start:var(--size-4-5);}.qa-export-callout.svelte-1way66v code:where(.svelte-1way66v) {font-family:var(--font-monospace);font-size:var(--code-size);background-color:var(--code-background);border-radius:var(--code-radius);padding:0.1em 0.25em;overflow-wrap:anywhere;}.qa-export-asset-kind.svelte-1way66v {margin-inline-start:var(--size-4-1);color:var(--text-muted);font-size:var(--font-ui-smaller);}
/* Same inset as the mod-list summary rows above. Not mod-list itself:
Obsidian keeps mod-list rows horizontal on phones, where this row needs
to stack. */.qa-export-save-group.svelte-1way66v {--setting-items-padding-x: var(--size-4-4);--setting-items-padding-y: var(--size-4-3);}
/* The path is the point of this row: let the input take the width the
short name leaves over. */.qa-export-save.svelte-1way66v {align-items:center;}
/* Phones stack the row and make controls full width; wrap so the path
and Save each get a full line. */.is-phone .qa-export-save.svelte-1way66v .setting-item-control:where(.svelte-1way66v) {flex-wrap:wrap;}.qa-export-save.svelte-1way66v .setting-item-info:where(.svelte-1way66v) {flex:0 0 auto;}.qa-export-save.svelte-1way66v input:where(.svelte-1way66v) {flex:1 1 auto;min-width:0;}`};function p$(r,t){ie(t,!0),Ae(r,YJ);let e={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=pe(""),i=pe(Ze(new Set)),o=pe(Ze(new Set)),s=pe(Ze(Cq())),a=pe(null),l=pe(null),c=k(()=>Ad(t.allChoices)),d=k(()=>cq(f(c),f(n))),u=k(()=>dq(f(c),f(i))),p=k(()=>uq(t.allChoices,f(u),f(o))),m=k(()=>new Map(f(c).map(me=>[me.id,me.path.join(" / ")])));function h(me){let Fe=[];for(let ut of Ne(me))Ee(ut)&&Fe.push(ut.id,...h(ut));return Fe}function g(me,Fe){let ut=[me.id,...h(me)],Yt=new Set(f(i)),Kt=new Set(f(o));for(let qt of ut)Fe?(Yt.add(qt),Kt.delete(qt)):(Yt.delete(qt),Kt.add(qt));q(i,Yt,!0),(!Fe||f(o).size>0)&&q(o,Kt,!0)}function v(me){let Fe=f(c).find(Yt=>Yt.id===me);if(!Fe)return;let ut=f(i).has(me);g(Fe.choice,!ut),q(a,null)}function b(){for(let me of f(d))g(me.choice,!0);q(a,null)}function y(){q(i,new Set,!0),q(o,new Set,!0),q(a,null)}function C(me){let{missingChoiceIds:Fe,missingAssets:ut}=me;return Fe.length===0&&ut.length===0?null:{missingChoices:Fe,missingAssets:ut}}async function w(){if(f(u).length===0)return new ps.Notice("Select at least one choice to export."),null;try{let me=await xq(t.app,{choices:t.allChoices,rootChoiceIds:f(u),excludedChoiceIds:Array.from(f(o)),quickAddVersion:t.plugin.manifest.version});return q(a,C(me),!0),me}catch(me){return console.error(me),q(a,null),new ps.Notice(`Export failed: ${me?.message??String(me)}`),null}}async function T(){if(!f(l)){q(l,"copy");try{let me=await w();if(!me)return;let Fe=JSON.stringify(me.pkg,null,2);await navigator.clipboard.writeText(Fe),new ps.Notice(`Copied package (${me.pkg.choices.length} choice${me.pkg.choices.length===1?"":"s"}) to clipboard.`),f(a)?new ps.Notice("Package copied with warnings. Review details below."):t.close()}catch(me){console.error(me),new ps.Notice(`Copy failed: ${me?.message??String(me)}`)}finally{q(l,null)}}}async function P(){if(f(l))return;let me=f(s).trim();if(!me){new ps.Notice("Enter a file path before saving.");return}q(l,"save");try{let Fe=await w();if(!Fe)return;let{overwritten:ut}=await _q(t.app,Fe.pkg,me),Yt=Fe.pkg.choices.length,Kt=`${Yt} choice${Yt===1?"":"s"}`;new ps.Notice(ut?`Overwrote package (${Kt}) at '${me}'.`:`Saved package (${Kt}) to '${me}'.`),f(a)?new ps.Notice("Package saved with warnings. Review details below."):t.close()}catch(Fe){let ut=Fe?.message??String(Fe);if(ut.startsWith("Save cancelled:")){new ps.Notice("Save cancelled.");return}console.error(Fe),new ps.Notice(`Save failed: ${ut}`)}finally{q(l,null)}}var _=jJ(),I=R(_),D=R(I),N=R(D),K=R(N),ne=E(R(K),2);Ct(ne),le(ne,"spellcheck",!1),$(K);var H=E(K,2),O=E(H,2);$(N);var G=E(N,2),V=R(G),M=R(V);{var B=me=>{var Fe=NJ();A(me,Fe)},J=me=>{var Fe=bt(),ut=ae(Fe);gt(ut,17,()=>f(d),Yt=>Yt.id,(Yt,Kt)=>{var qt=BJ(),Qt=R(qt);Ct(Qt);var Se=E(Qt,2),st=re(Se,!0),yr=E(Se,2);{var zt=In=>{var ua=VJ(),Y=re(ua,!0);Q(ue=>ee(Y,ue),[()=>f(Kt).path.slice(0,-1).join(" \u203A ")]),A(In,ua)};z(yr,In=>{f(Kt).path.length>1&&In(zt)})}var Do=E(yr,2),Tl=re(Do,!0);$(qt),Q((In,ua)=>{sp(qt,`--qa-export-depth: ${f(Kt).depth}`),bd(Qt,In),ee(st,ua),ee(Tl,f(Kt).choice.type)},[()=>f(i).has(f(Kt).id),()=>f(Kt).path.at(-1)]),ge("change",Qt,()=>v(f(Kt).id)),A(Yt,qt)}),A(me,Fe)};z(M,me=>{f(d).length===0?me(B):me(J,-1)})}$(V),$(G),$(D);var te=E(D,2),W=E(R(te),2);gt(W,21,()=>[["Selected choices",f(p).rootCount],["Total packaged",f(p).totalChoices],["Auto-included",f(p).dependencyCount],["Scripts embedded",f(p).userScripts+f(p).conditionalScripts],["Templates embedded",f(p).templateFiles+f(p).captureTemplates]],([me,Fe])=>me,(me,Fe)=>{var ut=k(()=>vk(f(Fe),2));let Yt=()=>f(ut)[0],Kt=()=>f(ut)[1];var qt=UJ(),Qt=R(qt),Se=R(Qt),st=re(Se,!0);$(Qt);var yr=E(Qt,2),zt=R(yr),Do=re(zt,!0);$(yr),$(qt),Q(()=>{ee(st,Yt
${st??""}`),[()=>f(p).missingChoiceIds.join(", ")]),A(me,Fe)};z(Z,me=>{f(p).missingChoiceIds.length>0&&me(se)})}var ce=E(Z,2);{var $e=me=>{var Fe=GJ(),ut=R(Fe),Yt=R(ut),Kt=R(Yt);Qe(Kt,{iconId:"alert-triangle"}),$(Yt),Xt(2),$(ut);var qt=E(ut,2),Qt=R(qt);{var Se=zt=>{var Do=zJ(),Tl=re(Do);Q(In=>ee(Tl,`Missing choices:
${In??""}`),[()=>f(a).missingChoices.map(In=>f(m).get(In)??In).join(", ")]),A(zt,Do)};z(Qt,zt=>{f(a).missingChoices.length>0&&zt(Se)})}var st=E(Qt,2);{var yr=zt=>{var Do=WJ(),Tl=E(ae(Do),2);gt(Tl,21,()=>f(a).missingAssets,In=>In.path,(In,ua)=>{var Y=HJ(),ue=R(Y),Pt=re(ue,!0),br=E(ue,2),Lo=re(br,!0);$(Y),Q(()=>{ee(Pt,f(ua).path),ee(Lo,e[f(ua).kind])}),A(In,Y)}),$(Tl),A(zt,Do)};z(st,zt=>{f(a).missingAssets.length>0&&zt(yr)})}$(qt),$(Fe),A(me,Fe)};z(ce,me=>{f(a)&&me($e)})}var Xe=E(ce,2),Ye=R(Xe),he=R(Ye),Re=E(R(he),2),Je=R(Re);Ct(Je);var ve=E(Je,2),Ve=R(ve);{var Ie=me=>{var Fe=xs("Saving\u2026");A(me,Fe)},ze=me=>{var Fe=xs("Save");A(me,Fe)};z(Ve,me=>{f(l)==="save"?me(Ie):me(ze,-1)})}$(ve),$(Re),$(he),$(Ye),$(Xe),$(I);var ct=E(I,2),Ke=R(ct),ot=E(Ke,2),or=R(ot);{var Ir=me=>{var Fe=xs("Copying\u2026");A(me,Fe)},Hn=me=>{var Fe=xs("Copy JSON");A(me,Fe)};z(or,me=>{f(l)==="copy"?me(Ir):me(Hn,-1)})}$(ot),$(ct),$(_),Q(()=>{ve.disabled=f(l)!==null,Ke.disabled=f(l)!==null,ot.disabled=f(l)!==null}),Zn(ne,()=>f(n),me=>q(n,me)),ge("click",H,b),ge("click",O,y),Zn(Je,()=>f(s),me=>q(s,me)),ge("click",ve,P),ge("click",Ke,function(...me){t.close?.apply(this,me)}),ge("click",ot,T),A(r,_),oe()}He(["click","change"]);var EE=class extends kq.Modal{constructor(e,n,i){super(e);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","qa-package-modal","packageExportModal"),this.setTitle("Export QuickAdd package"),this.handle=wi(this.contentEl,p$,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var tz=require("obsidian");var ay=require("obsidian");je();var O$=require("obsidian");Dr();Qo();er();ml();er();lt();Gr();function _E(r,t,e){if(!(!r||typeof r!="object")){if(Array.isArray(r)){t.onUnreadable?.();return}if(!e.has(r)){if(e.add(r),t.onChoice?.(r),uu(r))if(Array.isArray(r.choices))for(let n of r.choices)_E(n,t,e);else Wt(r.choices)&&t.onUnreadable?.();Xi(r)&&TE(ur(r.macro),t,e)}}}function TE(r,t,e){if(!Array.isArray(r)){Wt(r)&&t.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){t.onUnreadable?.();continue}t.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(TE(i.thenCommands,t,e),TE(i.elseCommands,t,e));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&_E(a,t,e)}}function m$(r,t){let e=new Set;if(Array.isArray(r.choices))for(let i of r.choices)_E(i,t,e);else t.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)TE(ur(i),t,e);else Wt(n)&&t.onUnreadable?.()}function af(r){let t=!1;return m$(r,{onUnreadable:()=>{t=!0}}),t}function Sq(r,t){_E(r,{onChoice:t},new Set)}function lf(r,t){f$(r.settings,t)}function f$(r,t){m$(r,{onChoice:t})}function kE(r,t){m$(r,{onCommand:t})}function KJ(r){return r.type==="AIAssistant"}function SE(r,t,e){let n=0;return kE({choices:r},i=>{if(!KJ(i)||i.modelRef&&i.modelRef.name===i.model&&t.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=t.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++,e?.(i,s)}),n}ye();Le();lt();tn();_m();Jt();Ac();Yi();g$();Qo();Dr();Jt();Za();function AE(r){return typeof r=="object"&&r!==null&&"type"in r&&r.type==="Template"}function XJ(r){return r.fileExistsBehavior?r.fileExistsBehavior:r.setFileExistsBehavior?{kind:"apply",mode:cV(r.fileExistsMode)??"increment"}:r.incrementFileName?{kind:"apply",mode:"increment"}:{kind:"prompt"}}function IE(r){r.fileExistsBehavior=XJ(r),delete r.incrementFileName,delete r.setFileExistsBehavior,delete r.fileExistsMode}function df(r){if(r==null)return null;if(typeof r=="boolean")return{enabled:r};if(typeof r!="object")return null;let t=r;return{enabled:typeof t.enabled=="boolean"?t.enabled:void 0,direction:t.direction==="horizontal"||t.direction==="vertical"?t.direction:void 0,focus:typeof t.focus=="boolean"?t.focus:void 0}
`):null}var sZ=/\bai\s*\.\s*(?:tools|agent|tool)\b|\btools\s*\.\s*(?:vault|workspace|system)\s*\(/;function aZ(r){return sZ.test(r)}var RE={critical:0,warning:1,info:2};function Lq(r){return Array.from(Bq(r,I$(r).choiceWalks).keys())}var lZ=10;function Nq(r){return cr(r.originalPath)}function $$(r){let t=Nq(r),e=go(r.originalPath);return e===t?[t]:[t,e]}function Vq(r){return r.assets.filter(t=>kx(t.originalPath))}function Bq(r,t){let e=new Map,n=a=>{if(!a.path)return;let l=e.get(a.path)??[];l.push(a),e.set(a.path,l)};for(let a of t)for(let l of a.usages)n(l);let i=new Map(Vq(r).flatMap(a=>$$(a).map(l=>[l,a]))),o=new Set,s=Array.from(e.keys());for(let a=0;a<lZ&&s.length>0;a++){let l=[];for(let c of s){if(o.has(c))continue;let d=i.get(c);if(!d||!Ps(c))continue;let u=(e.get(c)??[]).filter(g=>!g.asScript);if(u.length===0)continue;o.add(c);let p;try{p=Js(d.content)}catch{continue}let m=Xs(p);if(m.size===0)continue;let h=new Map;for(let g of u)h.has(g.choiceId)||h.set(g.choiceId,g);for(let g of m){for(let v of h.values())n({choiceId:v.choiceId,path:g,asScript:!1,impliedKind:"template",breadcrumb:`${v.breadcrumb} \u203A {{TEMPLATE}} include`});o.has(g)||l.push(g)}}s=l}return e}function cZ(r){let t=r.length;if(t===0)return 0;let e=0;return r.endsWith("==")?e=2:r.endsWith("=")&&(e=1),Math.max(0,Math.floor(t*3/4)-e)}function dZ(r,t){return RE[pf(r)]-RE[pf(t)]}function Uq(r,t,e){let{choiceWalks:n}=I$(t),i=new Set(Zt(r).map(_=>_.id)),o=Bq(t,n),s=new Set;for(let[_,I]of o)I.some(D=>D.asScript)&&s.add(_);let a=new Set(Vq(t).flatMap($$)),l=new Map(t.assets.map(_=>[_.originalPath,oZ(Nq(_),_.content)])),c=t.assets.map(_=>{let I=$$(_),D=a.has(I[0]),N=D?I.flatMap(H=>o.get(H)??[]):[],K=I.some(H=>s.has(H)),ne=K||l.get(_.originalPath)!=null;return{originalPath:_.originalPath,kind:_.kind,bundled:!0,executable:K,requiresReview:ne,exists:D&&(I.some(H=>e.has(H))||e.has(_.originalPath)),sizeBytes:cZ(_.content),orphan:N.length===0,referencedBy:N}}),d=n.map(_=>{let I=i.has(_.choiceId),D=Array.from(_.flags);return I&&D.push("overwrites-existing-choice"),D.sort(dZ),{choiceId:_.choiceId,name:_.name,type:_.type,location:_.location,exists:I,registersCommand:_.registersCommand,flags:D,commands:_.commands,inlineScripts:_.inlineScripts}}),u=[];for(let[_,I]of o){if(a.has(_)||e.has(_))continue;let D=I.some(N=>N.asScript);u.push({path:_,asScript:D,breadcrumb:I[0]?.breadcrumb??_})}let p=c.filter(_=>_.orphan).map(_=>_.originalPath),m=[];for(let _ of n)for(let I of _.rows)m.push(I);for(let _ of c)_.executable&&(nZ(_.kind)||m.push({flag:"mislabeled-executable",severity:"critical",title:"Runs a file as code even though it is labeled a template",detail:_.originalPath,scriptPath:_.originalPath}));for(let _ of c)_.requiresReview&&(_.executable||m.push({flag:"bundled-script",severity:"critical",title:"Bundles a file that will be written to your vault and can be run as code",detail:_.originalPath,scriptPath:_.originalPath}));for(let _ of c){let I=l.get(_.originalPath);!I||!aZ(I)||m.push({flag:"ai-tools",severity:"critical",title:"Lets an AI model read and write your vault",detail:_.originalPath,scriptPath:_.originalPath})}let h=d.filter(_=>_.registersCommand).length;h>0&&m.push({flag:"registers-command",severity:"warning",title:"Adds commands to the command palette",detail:`${h} choice${h===1?"":"s"}`});let g=d.filter(_=>_.exists).length;g>0&&m.push({flag:"overwrites-existing-choice",severity:"warning",title:"Replaces choices that already exist in your vault",detail:`${g} choice${g===1?"":"s"}`});let v=c.filter(_=>_.exists).length;if(v>0&&m.push({flag:"overwrites-existing-file",severity:"warning",title:"Overwrites existing files in your vault",detail:`${v} file${v===1?"":"s"}`}),u.length>0){let _=u.filter(I=>I.asScript).length;m.push({flag:"missing-reference",severity:_>0?"critical":"warning",title:_>0?"References scripts that are not bundled, so they run from whatever exists at those paths after import":"References files that are not bundled and not in your vault",detail:`${u.length} reference${u.length===1?"":"s"}`})}m.sort((_,I)=>RE[_.severity]-RE[I.severity]);let b=
`?(n>t&&(t=n),n=0,e++):n++;n>t&&(t=n);let i=r.length/e;return t>1e3||i>250}function F$(r){let t=r.length>Dq,e=t?r.slice(0,Dq):r;return{found:!0,text:e,truncated:t,sizeBytes:uZ(r),looksMinified:pZ(e)}}function OE(r,t){let e=r.assets.find(n=>n.originalPath===t);if(!e)return{found:!1,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:"File is not bundled in this package."};try{return F$(Js(e.content))}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function DE(r){return r.summary.hasCritical}function qq(r,t,e){let n=r.criticalScriptPaths.filter(o=>!t.has(o)).length,i=r.choices.filter(o=>o.inlineScripts.length>0&&!e.has(o.choiceId)).length;return n+i}Gr();Dr();er();lt();function ry(r){let t;try{t=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!yq(t))throw new Error("Content is not a valid QuickAdd package.");if(t.schemaVersion>1)throw new Error(`Package schema version ${t.schemaVersion} is newer than this plugin supports (${1}).`);let e=mZ(t.assets);if(e!==null)throw new Error(`Package contains duplicate asset path "${e}". Each asset must have a unique path.`);let n=fZ(t.choices);if(n!==null)throw new Error(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);let i=hZ(t.choices);if(i!==null)throw new Error(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);return t}function mZ(r){let t=new Set;for(let e of r){let n=cr(e.originalPath??"");if(t.has(n))return e.originalPath;t.add(n)}return null}function fZ(r){let t=new Map,e=null,n=i=>{if(e!==null||!i||typeof i!="object")return;let o=i.id;if(typeof o=="string"){let s=R$(i),a=t.get(o);if(a===void 0)t.set(o,s);else if(a!==s){e=o;return}}if(i.type==="Multi"){let s=i;if(Array.isArray(s.choices))for(let a of s.choices)n(a)}i.type==="Macro"&&M$(Mt(ur(i.macro)),n)};for(let i of r){if(e!==null)break;n(i?.choice)}return e}function M$(r,t){if(Array.isArray(r)){for(let e of r)if(e){if(e.type==="NestedChoice")t(e.choice);else if(e.type==="Conditional"){let n=e;M$(n.thenCommands,t),M$(n.elseCommands,t)}}}}function R$(r){if(r===null||typeof r!="object"){let n=JSON.stringify(r);return n===void 0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(R$).join(",")}]`;let t=r;return`{${Object.keys(t).sort().map(n=>`${JSON.stringify(n)}:${R$(t[n])}`).join(",")}}`}function hZ(r){let t=new Map(r.map(e=>[e.choice.id,e]));for(let e of r){let n=e.parentChoiceId;if(n===null)continue;let i=t.get(n);if(!i)continue;let o=i.choice;if(!Ne(o).some(a=>a?.id===e.choice.id))return e.choice.id}return null}async function LE(r,t){if(Ut(t))throw new Error(`Refusing to read a package outside the vault: "${t}".`);let e=(0,O$.normalizePath)(t.trim());if(!e)throw new Error("Package path cannot be empty.");if(!await r.vault.adapter.exists(e))throw new Error(`Package file not found: ${e}`);let i=await r.vault.adapter.read(e);return{pkg:ry(i),path:e}}async function NE(r,t,e){let n=new Map(Zt(t).map(s=>[s.id,s])),i=e.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(let s of e.assets){let a=Ut(s.originalPath)?!1:await r.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}async function mf(r,t,e){let n=new Set([...e.assets.flatMap(a=>kx(a.originalPath)?[a.originalPath,cr(a.originalPath)]:[]),...Lq(e)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Ut(a)||await zq(r,a)&&i.add(a))}));let o=Uq(t,e,i),{summary:s}=o;return S.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
Obsidian starts or you reload QuickAdd.</p>`),TZ=F('<section class="callout qa-import-banner svelte-1l3m8bg" aria-labelledby="qa-import-banner-title"><div class="callout-title"><div class="callout-icon"><!></div> <div class="callout-title-inner" id="qa-import-banner-title">What this package can do</div></div> <div class="callout-content svelte-1l3m8bg"><ul class="qa-import-banner-rows svelte-1l3m8bg"></ul> <!></div></section>'),_Z={hash:"svelte-1l3m8bg",code:`.qa-import-banner.svelte-1l3m8bg {margin:0;}
/* Setting-row text size, so the callout sits level with the cards. */.qa-import-banner.svelte-1l3m8bg .callout-content:where(.svelte-1l3m8bg) {padding-top:var(--size-4-2);font-size:var(--font-ui-small);}.qa-import-banner-rows.svelte-1l3m8bg {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:var(--size-4-2);}
/* The flair is an inline lead-in to the sentence, so long titles wrap
full-width under it instead of leaving a dead column beside it. */.qa-import-banner-rows.svelte-1l3m8bg li:where(.svelte-1l3m8bg) {line-height:var(--line-height-tight);}.qa-import-banner-title.svelte-1l3m8bg {margin-inline-start:var(--size-4-1);}.qa-import-banner-detail.svelte-1l3m8bg {display:block;margin-top:var(--size-2-1);font-size:var(--font-ui-smaller);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-banner-note.svelte-1l3m8bg {margin:var(--size-4-3) 0 0;font-size:var(--font-ui-smaller);color:var(--text-muted);}`};function D$(r,t){ie(t,!0),Ae(r,_Z);let e=k(()=>t.preview.summary.hasCritical);var n=TZ(),i=R(n),o=R(i),s=R(o);{let u=k(()=>f(e)?"zap":"alert-triangle");Qe(s,{get iconId(){return f(u)}})}$(o),Xt(2),$(i);var a=E(i,2),l=R(a);gt(l,21,()=>t.preview.capabilityRows,u=>u.flag+u.detail,(u,p)=>{var m=xZ(),h=R(m);iy(h,{get flag(){return f(p).flag}});var g=E(h,2),v=re(g,!0),b=E(g,2);{var y=C=>{var w=CZ(),T=re(w,!0);Q(()=>ee(T,f(p).detail)),A(C,w)};z(b,C=>{f(p).detail&&C(y)})}$(m),Q(()=>ee(v,f(p).title)),A(u,m)}),$(l);var c=E(l,2);{var d=u=>{var p=EZ();A(u,p)};z(c,u=>{t.preview.summary.runsOnStartup&&u(d)})}$(a),$(n),Q(()=>le(n,"data-callout",f(e)?"danger":"warning")),A(r,n),oe()}var kZ=F('<p class="qa-code-preview-note mod-error svelte-azzakv"> </p>'),SZ=F(`<p class="qa-code-preview-note mod-warning svelte-azzakv">Minified: cannot be visually reviewed. Import only if you trust
the source.</p>`),AZ=F('<p class="qa-code-preview-note mod-warning svelte-azzakv"> </p>'),IZ=F('<!> <span class="qa-visually-hidden"> </span> <pre tabindex="0" role="region"> </pre> <!>',1),PZ=F('<div class="qa-code-preview svelte-azzakv"><!></div>'),$Z={hash:"svelte-azzakv",code:`.qa-code-preview.svelte-azzakv {display:flex;flex-direction:column;gap:var(--size-4-2);}.qa-code-preview-note.svelte-azzakv {margin:0;font-size:var(--font-ui-smaller);}.qa-code-preview-note.mod-error.svelte-azzakv {color:var(--text-error);}
/* Obsidian's code-block look. The card already uses --code-background, so
the block sits on the modal background instead to stay distinct. */.qa-code-preview-code.svelte-azzakv {margin:0;max-height:240px;overflow:auto;padding:var(--size-4-3) var(--size-4-4);border-radius:var(--code-radius);background-color:var(--background-primary);color:var(--code-normal);font-family:var(--font-monospace);font-size:var(--code-size);line-height:var(--line-height-normal);white-space:pre;tab-size:4;user-select:text;}.qa-code-preview-code.mod-wrap.svelte-azzakv {white-space:pre-wrap;overflow-wrap:anywhere;}.qa-code-preview-code.svelte-azzakv:focus-visible {outline:2px solid var(--background-modifier-border-focus);outline-offset:-2px;}`};function oy(r,t){let e=Ri();ie(t,!0),Ae(r,$Z);let n=X(t,"wrap",3,!1),i=`${e}-label`;var o=PZ(),s=R(o);{var a=c=>{var d=kZ(),u=re(d);Q(()=>ee(u,`Preview unavailable: ${t.content.error??""}`)),A(c,d)},l=c=>{var d=IZ(),u=ae(d);{var p=w=>{var T=SZ();A(w,T)};z(u,w=>{t.content.looksMinified&&w(p)})}var m=E(u,2),h=re(m,!0),g=E(m,2);let v;var b=re(g,!0),y=E(g,2);{var C=w=>{var T=AZ(),P=re(T);Q(()=>ee(P,`Preview truncated. The full ${t.executable?"script will run":"file will be imported"}.`)),A(w,T)};z(y,w=>{t.content.truncated&&w(C)})}Q(()=>{le(m,"id",i),ee(h,t.label),v=Ge(g,1,"qa-code-preview-code svelte-azzakv",null,v,{"mod-wrap":n()}),le(g,"aria-labelledby",i),ee(b,t.content.text)}),A(c,d)};z(s,c=>{t.content.error?c(a):c(l,-1)})}$(o),A(r,o),oe()}var FZ=F('<span class="flair qa-import-file-flair qa-flair-critical svelte-4j5ctu">Executable</span>'),MZ=F('<span class="flair qa-import-file-flair svelte-4j5ctu">Unused</span>'),RZ=F('<span class="qa-import-reviewed"><!> Reviewed</span>'),OZ=F('<span class="qa-import-file-folder svelte-4j5ctu">The destination is a folder. Add a file name.</span>'),DZ=F("<span> </span>"),LZ=F(`<div class="setting-item-description mod-warning" role="note">Won't be written. Any choice that uses this script will run
whatever file already exists at this path after import, not the
contents you reviewed.</div>`),NZ=F("<option>Overwrite</option>"),VZ=F('<div class="qa-import-file-preview svelte-4j5ctu"><!></div>'),BZ=F('<div class="setting-items qa-import-file"><div class="setting-item qa-import-file-main svelte-4j5ctu"><div class="setting-item-info"><div class="setting-item-name qa-import-file-name svelte-4j5ctu"><span class="qa-import-file-icon svelte-4j5ctu"><!></span> <span class="qa-import-file-label svelte-4j5ctu"> </span> <!> <!> <!></div> <div class="setting-item-description"><!> </div> <!> <button type="button" class="qa-link-button qa-import-file-toggle svelte-4j5ctu"><span><!></span> <span> </span></button></div> <div class="setting-item-control"><label class="qa-visually-hidden"> </label> <select class="dropdown"><option>Write</option><!><option>Skip</option></select></div> <div><div class="qa-import-file-preview-inner svelte-4j5ctu"><!></div></div></div> <div class="setting-item qa-import-file-destination svelte-4j5ctu"><div class="setting-item-info svelte-4j5ctu"><label class="setting-item-name">Destination <span class="qa-visually-hidden"> </span></label></div> <div class="setting-item-control"><input type="text" placeholder="vault/path/to/file" class="svelte-4j5ctu"/></div></div></div>'),UZ={hash:"svelte-4j5ctu",code:`.qa-import-file-name.svelte-4j5ctu {display:flex;flex-wrap:wrap;align-items:center;gap:var(--size-4-1) var(--size-4-2);}.qa-import-file-icon.svelte-4j5ctu {display:inline-flex;color:var(--text-muted);--icon-size: var(--icon-s);}.qa-import-file-label.svelte-4j5ctu {min-width:0;overflow-wrap:anywhere;}.qa-import-file-flair.svelte-4j5ctu {margin-inline-start:0;cursor:help;}.qa-import-file-folder.svelte-4j5ctu {color:var(--text-error);}
/* The path is the point of this row: let the input take the width the
short "Destination" name leaves over. */.qa-import-file-destination.svelte-4j5ctu {align-items:center;}.qa-import-file-destination.svelte-4j5ctu .setting-item-info:where(.svelte-4j5ctu) {flex:0 0 auto;}.qa-import-file-destination.svelte-4j5ctu input:where(.svelte-4j5ctu) {flex:1 1 auto;min-width:0;}.qa-import-file-destination.svelte-4j5ctu input:where(.svelte-4j5ctu):disabled {opacity:0.5;cursor:not-allowed;}
/* The preview opens under the row at full width. No row gap, so the
collapsed preview adds no space; the preview pads itself instead. */.qa-import-file-main.svelte-4j5ctu {flex-wrap:wrap;row-gap:0;}.qa-import-file-toggle.svelte-4j5ctu {margin-top:var(--size-4-1);font-size:var(--font-ui-smaller);}.qa-import-file-preview-wrap.svelte-4j5ctu {flex-basis:100%;min-width:0;}
/* Pulls the glyph's built-in side bearing back to the text edge. */.qa-import-file-chevron.svelte-4j5ctu {display:inline-flex;margin-inline-start:-3px;transition:transform 150ms ease;}.qa-import-file-chevron.open.svelte-4j5ctu {transform:rotate(90deg);}.qa-import-file-preview-wrap.svelte-4j5ctu {display:grid;grid-template-rows:0fr;transition:grid-template-rows 200ms ease;}.qa-import-file-preview-wrap.open.svelte-4j5ctu {grid-template-rows:1fr;}.qa-import-file-preview-inner.svelte-4j5ctu {overflow:hidden;min-height:0;}.qa-import-file-preview.svelte-4j5ctu {padding-top:var(--size-4-3);}
@media (prefers-reduced-motion: reduce) {.qa-import-file-chevron.svelte-4j5ctu,
.qa-import-file-preview-wrap.svelte-4j5ctu {transition:none;}
}`};function L$(r,t){let e=Ri();ie(t,!0),Ae(r,UZ);let n=X(t,"destinationIsFolder",3,!1),i=X(t,"reviewed",3,!1),o=pe(!1),s=k(()=>f(o)?OE(t.pkg,t.file.originalPath):null),a=`${e}-preview`,l=`${e}-destination`,c=`${e}-action`,d=`${e}-folder`,u=k(()=>t.file.originalPath.split("/").pop()??t.file.originalPath);function p(Se){return Se<1024?`${Se} B`:Se<1024*1024?`${(Se/1024).toFixed(1)} KB`:`${(Se/(1024*1024)).toFixed(1)} MB`}function m(){q(o,!f(o)),f(o)&&t.file.requiresReview&&t.onReviewed(t.file.originalPath)}function h(Se){t.onPathInput(Se.currentTarget.value)}function g(Se){t.onModeChange(Se.currentTarget.value)}var v=BZ(),b=R(v),y=R(b),C=R(y),w=R(C),T=R(w);{let Se=k(()=>t.destinationExists?"file-warning":"file-plus");Qe(T,{get iconId(){return f(Se)}})}$(w);var P=E(w,2),_=re(P,!0),I=E(P,2);{var D=Se=>{var st=FZ();Ft(st,(yr,zt)=>ny?.(yr,zt),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),A(Se,st)};z(I,Se=>{t.file.executable&&Se(D)})}var N=E(I,2);{var K=Se=>{var st=MZ();Ft(st,(yr,zt)=>ny?.(yr,zt),()=>"Bundled in this package but not referenced by any choice."),A(Se,st)};z(N,Se=>{t.file.orphan&&Se(K)})}var ne=E(N,2);{var H=Se=>{var st=RZ(),yr=R(st);Qe(yr,{iconId:"check",size:14}),Xt(),$(st),A(Se,st)};z(ne,Se=>{i()&&t.mode!=="skip"&&t.file.requiresReview&&Se(H)})}$(C);var O=E(C,2),G=R(O);{var V=Se=>{var st=OZ();Q(()=>le(st,"id",d)),A(Se,st)},M=Se=>{var st=DZ();let yr;var zt=re(st,!0);Q(()=>{yr=Ge(st,1,"",null,yr,{"mod-warning":t.destinationExists}),ee(zt,t.destinationExists?"Will overwrite":"New file")}),A(Se,st)};z(G,Se=>{n()?Se(V):Se(M,-1)})}var B=E(G);$(O);var J=E(O,2);{var te=Se=>{var st=LZ();A(Se,st)};z(J,Se=>{t.file.requiresReview&&t.mode==="skip"&&Se(te)})}var W=E(J,2),Z=R(W);let se;var ce=R(Z);Qe(ce,{iconId:"chevron-right",size:14}),$(Z);var $e=E(Z,2),Xe=re($e,!0);$(W),$(y);var Ye=E(y,2),he=R(Ye),Re=re(he),Je=E(he,2),ve=R(Je);ve.value=ve.__value="write";var Ve=E(ve);{var Ie=Se=>{var st=NZ();st.value=st.__value="overwrite",A(Se,st)};z(Ve,Se=>{t.destinationExists&&Se(Ie)})}var ze=E(Ve);ze.value=ze.__value="skip",$(Je);var ct;Ll(Je),$(Ye);var Ke=E(Ye,2);let ot;var or=R(Ke),Ir=R(or);{var Hn=Se=>{var st=VZ(),yr=R(st);{let zt=k(()=>`Contents of ${t.file.originalPath}`);oy(yr,{get content(){return f(s)},get label(){return f(zt)},get executable(){return t.file.executable}})}$(st),A(Se,st)};z(Ir,Se=>{f(s)&&Se(Hn)})}$(or),$(Ke),$(b);var me=E(b,2),Fe=R(me),ut=R(Fe),Yt=E(R(ut)),Kt=re(Yt);$(ut),$(Fe);var qt=E(Fe,2),Qt=R(qt);Ct(Qt),$(qt),$(me),$(v),Q(Se=>{ee(_,f(u)),ee(B,` \xB7 ${Se??""}`),le(W,"aria-expanded",f(o)),le(W,"aria-controls",a),se=Ge(Z,1,"qa-import-file-chevron svelte-4j5ctu",null,se,{open:f(o)}),ee(Xe,f(o)?"Hide contents":"View contents"),le(he,"for",c),ee(Re,`Action for ${t.file.originalPath??""}`),le(Je,"id",c),ct!==(ct=t.mode)&&(Je.value=(Je.__value=ct)??"",Dl(Je,ct)),ot=Ge(Ke,1,"qa-import-file-preview-wrap svelte-4j5ctu",null,ot,{open:f(o)}),le(Ke,"id",a),le(ut,"for",l),ee(Kt,`for ${t.file.originalPath??""}`),le(Qt,"id",l),Jn(Qt,t.destinationPath),le(Qt,"aria-invalid",n()),le(Qt,"aria-describedby",n()?d:void 0),Qt.disabled=t.mode==="skip"},[()=>p(t.file.sizeBytes)]),ge("click",W,m),ge("change",Je,g),ge("input",Qt,h),A(r,v),oe()}He(["click","change","input"]);var qZ=F('<section class="qa-import-ack"><label><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-w06gp4"/> <span> </span></label></section>'),zZ={hash:"svelte-w06gp4",code:".qa-import-ack-label.svelte-w06gp4 {display:flex;align-items:flex-start;gap:var(--size-4-2);font-size:var(--font-ui-small);line-height:var(--line-height-tight);cursor:var(--cursor);}.qa-import-ack-label.is-disabled.svelte-w06gp4 {cursor:not-allowed;color:var(--text-muted);}.qa-import-ack-label.svelte-w06gp4 input:where(.svelte-w06gp4) {flex-shrink:0;margin:0;}"};function N$(r,t){ie(t,!0),Ae(r,zZ);let e=X(t,"acknowledged",15,!1),n=k(()=>(t.preview?.criticalScriptPaths.length??0)+(t.preview?.choices.filter(p=>p.inlineScripts.length>0).length??0)),i=k(()=>t.preview?.missingReferences.some(p=>p.asScript)??!1),o
/* Obsidian's outline/file-tree indentation guide on the left. */.qa-macro-commands.svelte-131fx5e {list-style:none;margin:0;padding:0 0 0 var(--size-4-3);border-inline-start:var(--nav-indentation-guide-width, 1px) solid
var(--nav-indentation-guide-color, var(--background-modifier-border));display:flex;flex-direction:column;gap:var(--size-4-1);}.qa-macro-commands.svelte-131fx5e li:where(.svelte-131fx5e) {display:flex;flex-wrap:wrap;align-items:center;gap:var(--size-4-1) var(--size-4-2);padding-inline-start:calc(var(--qa-macro-depth, 0) * var(--size-4-4));font-size:var(--font-ui-smaller);line-height:var(--line-height-tight);}.qa-macro-command-type.svelte-131fx5e,
.qa-macro-command-summary.svelte-131fx5e {color:var(--text-muted);}.qa-macro-commands.svelte-131fx5e code:where(.svelte-131fx5e) {font-family:var(--font-monospace);font-size:var(--code-size);color:var(--text-muted);overflow-wrap:anywhere;}`};function V$(r,t){ie(t,!0),Ae(r,KZ);let e={UserScript:"User script",Conditional:"Conditional",NestedChoice:"Nested choice",Obsidian:"Obsidian command",Choice:"Choice",Wait:"Wait",EditorCommand:"Editor command",AIAssistant:"AI assistant",OpenFile:"Open file"};function n(o){return e[o]??o}var i=YZ();gt(i,21,()=>t.commands,yd,(o,s)=>{var a=jZ(),l=R(a),c=re(l,!0),d=E(l,2);{var u=v=>{iy(v,{get flag(){return f(s).flag}})},p=v=>{var b=HZ(),y=re(b,!0);Q(C=>ee(y,C),[()=>n(f(s).type)]),A(v,b)};z(d,v=>{f(s).flag?v(u):v(p,-1)})}var m=E(d,2);{var h=v=>{var b=bt(),y=ae(b);{var C=T=>{var P=WZ(),_=re(P,!0);Q(()=>ee(_,f(s).scriptPath)),A(T,P)},w=k(()=>!A$(f(s).name,f(s).scriptPath));z(y,T=>{f(w)&&T(C)})}A(v,b)},g=v=>{var b=GZ(),y=re(b,!0);Q(()=>ee(y,f(s).summary)),A(v,b)};z(m,v=>{f(s).scriptPath?v(h):f(s).summary&&v(g,1)})}$(a),Q(()=>{sp(a,`--qa-macro-depth: ${f(s).depth}`),ee(c,f(s).name)}),A(o,a)}),$(i),A(r,i),oe()}var QZ=F('<div class="setting-item mod-empty-state svelte-1vg70zw"><div class="setting-item-info"><div class="setting-item-name svelte-1vg70zw">No choices found in this package.</div></div></div>'),XZ=F('<span class="qa-import-reviewed"><!> Reviewed</span>'),JZ=F('<div class="setting-item-description"> </div>'),ZZ=F('<button type="button" class="qa-link-button svelte-1vg70zw"><span><!></span> <span> </span></button>'),eee=F('<div><button type="button" class="qa-link-button svelte-1vg70zw"><span><!></span> <span> </span></button></div>'),tee=F("<option>Overwrite</option>"),ree=F("<option>Import</option>"),nee=F('<div class="qa-import-choice-macro svelte-1vg70zw"><!></div>'),iee=F('<div class="qa-import-choice-code-setting svelte-1vg70zw"> </div> <!>',1),oee=F('<div class="qa-import-choice-code svelte-1vg70zw"></div>'),see=F('<div class="setting-item svelte-1vg70zw"><div class="setting-item-info"><div class="setting-item-name qa-import-choice-name svelte-1vg70zw"><span> </span> <!></div> <!> <!> <!></div> <div class="setting-item-control"><label class="qa-visually-hidden"> </label> <select class="dropdown"><!><option>Duplicate</option><option>Skip</option></select></div> <!> <!></div>'),aee=F('<section class="setting-group qa-import-choices svelte-1vg70zw"><div class="setting-item setting-item-heading svelte-1vg70zw"><div class="setting-item-name svelte-1vg70zw">Choices</div></div> <div class="setting-items"><!> <!></div></section>'),lee={hash:"svelte-1vg70zw",code:`.qa-import-choices.svelte-1vg70zw .setting-item:where(.svelte-1vg70zw) {flex-wrap:wrap;}.qa-import-choices.svelte-1vg70zw .setting-item-name:where(.svelte-1vg70zw) {overflow-wrap:anywhere;}.qa-import-choice-name.svelte-1vg70zw {display:flex;flex-wrap:wrap;align-items:center;gap:var(--size-4-1) var(--size-4-2);}.qa-import-choices.svelte-1vg70zw .qa-link-button:where(.svelte-1vg70zw) {margin-top:var(--size-4-1);font-size:var(--font-ui-smaller);}
/* Pulls the glyph's built-in side bearing back to the text edge. */.qa-import-choice-chevron.svelte-1vg70zw {display:inline-flex;margin-inline-start:-3px;transition:transform 150ms ease;}.qa-import-choice-chevron.open.svelte-1vg70zw {transform:rotate(90deg);}.qa-import-choice-macro.svelte-1vg70zw {flex-basis:100%;min-width:0;}
/* Opens under the row at full width, like a file's contents. */.qa-import-choice-code.svelte-1vg70zw {flex-basis:100%;min-width:0;display:flex;flex-direction:column;gap:var(--size-4-2);}.qa-import-choice-code-setting.svelte-1vg70zw {font-size:var(--font-ui-smaller);color:var(--text-muted);}
@media (prefers-reduced-motion: reduce) {.qa-import-choice-chevron.svelte-1vg70zw {transition:none;}
}`};function B$(r,t){let e=Ri();ie(t,!0),Ae(r,lee);function n(c){let d=(c.pathHint??[]).slice(0,-1),u=[];return d.length>0&&u.push(`In ${d.join(" \u203A ")}`),c.exists&&u.push("Already in vault"),u.join(" \xB7 ")}var i=aee(),o=E(R(i),2),s=R(o);{var a=c=>{var d=QZ();A(c,d)};z(s,c=>{t.conflicts.length===0&&c(a)})}var l=E(s,2);gt(l,19,()=>t.conflicts,c=>c.choiceId,(c,d,u)=>{let p=k(()=>sy(t.choiceDecisions.get(f(d).choiceId)??"import",f(d).exists)),m=k(()=>t.previewChoiceById.get(f(d).choiceId)),h=k(()=>(f(m)?.commands?.length??0)>0),g=k(()=>f(h)&&t.expandedMacros.has(f(d).choiceId)),v=k(()=>f(m)?.inlineScripts??[]),b=k(()=>f(v).length>0&&t.expandedCode.has(f(d).choiceId)),y=k(()=>n(f(d)));var C=see(),w=R(C),T=R(w),P=R(T),_=re(P,!0),I=E(P,2);{var D=ve=>{var Ve=XZ(),Ie=R(Ve);Qe(Ie,{iconId:"check",size:14}),Xt(),$(Ve),A(ve,Ve)},N=k(()=>t.reviewedChoiceIds.has(f(d).choiceId)&&f(p)!=="skip");z(I,ve=>{f(N)&&ve(D)})}$(T);var K=E(T,2);{var ne=ve=>{var Ve=JZ(),Ie=re(Ve,!0);Q(()=>ee(Ie,f(y))),A(ve,Ve)};z(K,ve=>{f(y)&&ve(ne)})}var H=E(K,2);{var O=ve=>{var Ve=ZZ(),Ie=R(Ve);let ze;var ct=R(Ie);Qe(ct,{iconId:"chevron-right",size:14}),$(Ie);var Ke=E(Ie,2),ot=re(Ke,!0);$(Ve),Q(()=>{le(Ve,"aria-expanded",f(g)),ze=Ge(Ie,1,"qa-import-choice-chevron svelte-1vg70zw",null,ze,{open:f(g)}),ee(ot,f(g)?"Hide macro":"Show macro")}),ge("click",Ve,()=>t.toggleMacro(f(d).choiceId)),A(ve,Ve)};z(H,ve=>{f(h)&&ve(O)})}var G=E(H,2);{var V=ve=>{var Ve=eee(),Ie=R(Ve),ze=R(Ie);let ct;var Ke=R(ze);Qe(Ke,{iconId:"chevron-right",size:14}),$(ze);var ot=E(ze,2),or=re(ot,!0);$(Ie),$(Ve),Q(()=>{le(Ie,"aria-expanded",f(b)),ct=Ge(ze,1,"qa-import-choice-chevron svelte-1vg70zw",null,ct,{open:f(b)}),ee(or,f(b)?"Hide code":"View code")}),ge("click",Ie,()=>t.toggleCode(f(d).choiceId)),A(ve,Ve)};z(G,ve=>{f(v).length>0&&ve(V)})}$(w);var M=E(w,2),B=R(M),J=re(B),te=E(B,2),W=R(te);{var Z=ve=>{var Ve=tee();Ve.value=Ve.__value="overwrite",A(ve,Ve)},se=ve=>{var Ve=ree();Ve.value=Ve.__value="import",A(ve,Ve)};z(W,ve=>{f(d).exists?ve(Z):ve(se,-1)})}var ce=E(W);ce.value=ce.__value="duplicate";var $e=E(ce);$e.value=$e.__value="skip",$(te);var Xe;Ll(te),$(M);var Ye=E(M,2);{var he=ve=>{var Ve=nee(),Ie=R(Ve);{let ze=k(()=>f(m)?.commands??[]);V$(Ie,{get commands(){return f(ze)}})}$(Ve),A(ve,Ve)};z(Ye,ve=>{f(g)&&ve(he)})}var Re=E(Ye,2);{var Je=ve=>{var Ve=oee();gt(Ve,21,()=>f(v),yd,(Ie,ze)=>{var ct=iee(),Ke=ae(ct),ot=re(Ke,!0),or=E(Ke,2);{let Ir=k(()=>F$(f(ze).text)),Hn=k(()=>`${f(d).name} \u203A ${f(ze).setting}`);oy(or,{get content(){return f(Ir)},get label(){return f(Hn)},executable:!0,wrap:!0})}Q(()=>ee(ot,f(ze).setting)),A(Ie,ct)}),$(Ve),A(ve,Ve)};z(Re,ve=>{f(b)&&ve(Je)})}$(C),Q(()=>{ee(_,f(d).name),le(B,"for",`${e}-action-${f(u)}`),ee(J,`Action for ${f(d).name??""}`),le(te,"id",`${e}-action-${f(u)}`),Xe!==(Xe=f(p))&&(te.value=(te.__value=Xe)??"",Dl(te,Xe))}),ge("change",te,ve=>t.onChoiceModeChange(f(d).choiceId,ve)),A(c,C)}),$(o),$(i),A(r,i),oe()}He(["click","change"]);var cee=F('<li class="svelte-88pyz9"><code class="svelte-88pyz9"> </code> <span class="qa-package-callout-loc svelte-88pyz9"> </span></li>'),dee=F('<section class="callout qa-package-callout svelte-88pyz9"><div class="callout-title"><div class="callout-icon"><!></div> <div class="callout-title-inner">Missing files</div></div> <div class="callout-content svelte-88pyz9"><ul class="svelte-88pyz9"></ul></div></section>'),uee=F('<li class="svelte-88pyz9"><code class="svelte-88pyz9"> </code>: bundled but not used by any choice</li>'),pee=F('<section class="callout qa-package-callout svelte-88pyz9" data-callout="info"><div class="callout-title"><div class="callout-icon"><!></div> <div class="callout-title-inner">Unreferenced files</div></div> <div class="callout-content svelte-88pyz9"><ul class="svelte-88pyz9"></ul></div></section>'),mee=F("<!> <!>",1),fee={hash:"svelte-88pyz9",code:`.qa-package-callout.svelte-88pyz9 {margin:0;}.qa-package-callout.svelte-88pyz9 .callout-content:where(.svelte-88pyz9) {font-size:var(--font-ui-small);}.qa-package-callout.svelte-88pyz9 ul:where(.svelte-88pyz9) {margin:var(--size-4-2) 0 0;padding
/* Obsidian's inline-code look, which is otherwise scoped to rendered notes. */.qa-package-callout.svelte-88pyz9 code:where(.svelte-88pyz9) {font-family:var(--font-monospace);font-size:var(--code-size);background-color:var(--code-background);border-radius:var(--code-radius);padding:0.1em 0.25em;}.qa-package-callout-loc.svelte-88pyz9 {display:block;color:var(--text-muted);font-size:var(--font-ui-smaller);}`};function U$(r,t){ie(t,!0),Ae(r,fee);let e=k(()=>t.preview?.missingReferences.some(l=>l.asScript)??!1);var n=mee(),i=ae(n);{var o=l=>{var c=dee(),d=R(c),u=R(d),p=R(u);{let g=k(()=>f(e)?"zap":"alert-triangle");Qe(p,{get iconId(){return f(g)}})}$(u),Xt(2),$(d);var m=E(d,2),h=R(m);gt(h,21,()=>t.preview.missingReferences,g=>g.path,(g,v)=>{var b=cee(),y=R(b),C=re(y,!0),w=E(y),T=E(w),P=re(T,!0);$(b),Q(()=>{ee(C,f(v).path),ee(w,`:
${f(v).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),ee(P,f(v).breadcrumb)}),A(g,b)}),$(h),$(m),$(c),Q(()=>le(c,"data-callout",f(e)?"danger":"warning")),A(l,c)};z(i,l=>{t.preview&&t.preview.missingReferences.length>0&&l(o)})}var s=E(i,2);{var a=l=>{var c=pee(),d=R(c),u=R(d),p=R(u);Qe(p,{iconId:"info"}),$(u),Xt(2),$(d);var m=E(d,2),h=R(m);gt(h,20,()=>t.preview.orphanAssets,g=>g,(g,v)=>{var b=uee(),y=R(b),C=re(y,!0);Xt(),$(b),Q(()=>ee(C,v)),A(g,b)}),$(h),$(m),$(c),A(l,c)};z(s,l=>{t.preview&&t.preview.orphanAssets.length>0&&l(a)})}A(r,n),oe()}var hee=F('<p class="qa-import-status mod-error svelte-dvnvtv"> </p>'),gee=F('<p class="qa-import-status svelte-dvnvtv">Analyzing package\u2026</p>'),vee=F('<p class="qa-import-status svelte-dvnvtv"> </p>'),yee=F('<div class="setting-items"><div class="setting-item mod-empty-state"><div class="setting-item-info"><div class="setting-item-name">No files bundled with this package.</div></div></div></div>'),bee=F("<h4> </h4> <!>",1),wee=F('<section class="callout qa-import-summary svelte-dvnvtv" data-callout="success" role="status"><div class="callout-title"><div class="callout-icon"><!></div> <div class="callout-title-inner"> </div></div></section>'),Cee=F('<!> <!> <section class="setting-group qa-import-files svelte-dvnvtv"><div class="setting-item setting-item-heading svelte-dvnvtv"><div class="setting-item-name">Files</div></div> <!></section> <!> <!>',1),xee=F('<p id="qa-import-reason" class="qa-import-reason svelte-dvnvtv"> </p>'),Eee=F('<button type="button">Cancel</button>'),Tee=F('<div class="qa-package-dialog"><div class="qa-package-body"><section class="qa-import-paste svelte-dvnvtv"><label class="qa-visually-hidden" for="qa-import-json">Package JSON</label> <textarea id="qa-import-json" placeholder="Paste the contents of a .quickadd.json package here" rows="8" class="svelte-dvnvtv"></textarea> <!></section> <!> <!></div> <div class="modal-button-container"><!> <!> <button type="button" class="mod-cta"><!></button></div></div>'),_ee={hash:"svelte-dvnvtv",code:`.qa-import-paste.svelte-dvnvtv {display:flex;flex-direction:column;gap:var(--size-4-2);}.qa-import-paste.svelte-dvnvtv textarea:where(.svelte-dvnvtv) {width:100%;font-family:var(--font-monospace);font-size:var(--font-ui-small);resize:vertical;}.qa-import-status.svelte-dvnvtv {margin:0;font-size:var(--font-ui-smaller);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-status.mod-error.svelte-dvnvtv {color:var(--text-error);}.qa-import-files.svelte-dvnvtv {display:flex;flex-direction:column;gap:var(--size-4-3);}.qa-import-files.svelte-dvnvtv .setting-item-heading:where(.svelte-dvnvtv) {margin-bottom:var(--size-4-1);}
/* Small muted group label, like Obsidian's settings sidebar sections. */.qa-import-files-group.svelte-dvnvtv {margin:var(--size-4-2) 0 0;padding:0 var(--size-4-4);font-size:var(--font-ui-smaller);font-weight:var(--font-semibold);color:var(--text-muted);}.qa-import-files-group.svelte-dvnvtv:first-of-type {margin-top:0;}.qa-import-files-group.mod-warning.svelte-dvnvtv {color:var(--text-warning);}.qa-import-summary.svelte-dvnvtv {margin:0;}
/* Left of the buttons; the text wraps before they do. */.qa-import-reason.svelte-dvnvtv {flex:1 1 0;align-self:center;margin:0;font-size:var(--font-ui-smaller);color:var(--text-muted);}
/* The phone footer stacks its buttons bottom-up; put the reason on top. */.is-phone .qa-import-reason.svelte-dvnvtv {flex:none;order:1;text-align:center;}`};function q$(r,t){ie(t,!0),Ae(r,_ee);let e;function n(){return e??(e=new UE(t.app))}let i=pe(null),o=pe(null),s=pe(null),a=pe(!1),l=pe(Ze(new Set)),c=pe(Ze(new Set)),d=pe(Ze(new Set)),u=pe(Ze(new Set)),p=pe(null),m=pe(!1),h=pe(null),g=pe(Ze(new Map)),v=pe(Ze(new Map)),b=pe(Ze(new Set)),y=pe(""),C=pe(!1),w=pe(0),T=pe(!1),P=pe(null),_=k(()=>f(s)?DE(f(s)):!1),I=k(()=>f(s)?qq(f(s),f(l),f(c)):0),D=k(()=>f(I)===0),N=k(()=>new Map((f(s)?.choices??[]).map(Y=>[Y.choiceId,Y]))),K=k(()=>new Map((f(s)?.files??[]).map(Y=>[Y.originalPath,Y]))),ne=k(()=>!!(f(s)&&(f(s).summary.hasCritical||f(s).summary.hasWarning))),H=k(()=>{let Y=f(h);if(!Y)return"";let ue=[];Y.added&&ue.push(`${Y.added} choice${Y.added===1?"":"s"} added`),Y.overwritten&&ue.push(`${Y.overwritten} overwritten`),Y.assetsWritten&&ue.push(`${Y.assetsWritten} file${Y.assetsWritten===1?"":"s"} written`);let Pt=Y.skipped+Y.assetsSkipped;return Pt&&ue.push(`${Pt} skipped`),ue.length?`Imported: ${ue.join(", ")}.`:"Nothing was imported."});function O(Y){if(f(l).has(Y))return;let ue=new Set(f(l));ue.add(Y),q(l,ue,!0)}function G(Y){let ue=new Set(f(d));ue.has(Y)?ue.delete(Y):ue.add(Y),q(d,ue,!0)}function V(Y){let ue=new Set(f(u));ue.has(Y)?ue.delete(Y):ue.add(Y),q(u,ue,!0),ue.has(Y)&&!f(c).has(Y)&&q(c,new Set(f(c)).add(Y),!0)}let M=Y=>n().optimistic(Y),B=k(()=>(f(o)?.assetConflicts??[]).map(Y=>{let ue=jq(f(v),Y,se,M);return{conflict:Y,state:ue,destinationIsFolder:ue.mode!=="skip"&&n().isFolder(ue.destinationPath),file:f(K).get(Y.originalPath)}})),J=k(()=>f(B).filter(Y=>!f(b).has(Y.conflict.originalPath))),te=k(()=>f(B).filter(Y=>f(b).has(Y.conflict.originalPath))),W=k(()=>!!(f(i)&&f(o))&&!f(C)&&!f(B).some(Y=>Y.destinationIsFolder)&&(!f(_)||f(a)&&f(D))),Z=k(()=>!f(i)||!f(o)||f(C)||f(T)?"":f(_)&&!f(D)?`View ${f(I)} script${f(I)===1?"":"s"} above to import.`:f(_)&&!f(a)?"Confirm the acknowledgement above to import.":f(B).some(Y=>Y.destinationIsFolder)?"A destination above is a folder. Add a file name to import.":"");function se(Y){return zE(Y,U.getState().templateFolderPaths)}function ce(Y,ue,Pt=!1){n().schedule(Y,ue,br=>{if(q(v,Jq(f(v),Y,br),!0),Pt&&br!==f(b).has(Y)){let Lo=new Set(f(b));br?Lo.add(Y):Lo.delete(Y),q(b,Lo,!0)}})}function $e(){if(!f(o)){q(g,new Map,!0),q(v,new Map,!0),q(b,new Set,!0);return}q(g,Yq(f(o).choiceConflicts),!0),q(v,Gq(f(o).assetConflicts,se,M),!0),q(b,new Set(f(o).assetConflicts.filter(Y=>f(v).get(Y.originalPath)?.destinationExists).map(Y=>Y.originalPath)),!0);for(let Y of f(o).assetConflicts){let ue=f(v).get(Y.originalPath);ue&&ce(Y.originalPath,ue.destinationPath,!0)}}function Xe(Y,ue){q(g,Kq(f(g),Y,ue),!0)}function Ye(Y,ue){q(v,Qq(f(v),Y,ue,M),!0)}function he(Y,ue){let{decisions:Pt,effectivePath:br}=Xq(f(v),Y.originalPath,ue,M);q(v,Pt,!0),ce(Y.originalPath,br)}function Re(Y,ue){let br=ue.currentTarget.value;Xe(Y,br)}function Je(){q(s,null),q(a,!1),q(l,new Set,!0),q(c,new Set,!0),q(d,new Set,!0),q(u,new Set,!0)}async function ve(Y){let ue=Y.trim(),Pt=Nk(w);if(q(h,null),q(T,!1),!ue){q(i,null),q(o,null),q(g,new Map,!0),q(v,new Map,!0),Je(),q(p,null);return}q(C,!0);try{let br=ry(ue),Lo=U.getState().choices,jf=await NE(t.app,Lo,br),sk=await mf(t.app,Lo,br);if(Pt!==f(w))return;q(i,{pkg:br,path:"[pasted]"},!0),q(o,jf,!0),Je(),q(s,sk,!0),q(p,null),$e()}catch(br){if(Pt!==f(w))return;q(p,br?.message??String(br),!0),q(i,null),q(o,null),q(g,new Map,!0),q(v,new Map,!0),Je()}finally{Pt===f(w)&&q(C,!1)}}function Ve(Y){let ue=Y.currentTarget.value;q(y,ue,!0),ve(ue)}async function Ie(){if(f(T)){new ay.Notice("This package has already been imported.");return}if(!f(i)||!f(o)){new ay.Notice("Load a package before importing.");return}q(m,!0),q(h,null);try{let Y=U.getState().choices,ue=await VE({app:t.app,existingChoices:Y,aiProviders:U.getState().ai.providers,pkg:f(i).pkg,choiceDecisions:Zq(f(o).choiceConflicts,f(g)),assetDecisions:ez(f(o).assetConflicts,f(v),M)});U.setState(Pt=>({...Pt,choices:ue.updatedChoices})),t.o
tm = tomorrow
yd = yesterday`).setValue(yS(U.getState().dateAliases)).onChange(o=>{U.setState({dateAliases:pD(o)})}),i.inputEl.addClass("qa-date-alias-input")}),e.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{U.setState({dateAliases:cp}),n?.setValue(yS(cp))}),i.buttonEl.addClass("qa-date-alias-reset")})}renderDevInfo(e){let n=e.settingEl.createDiv();n.addClass("qa-dev-info"),rz(n,{branch:null,commit:null,dirty:null})}};function lT(){return ti(U.getState().templateFolderPaths)}bS();ye();sw();nt();var py=class extends Dp{constructor(){super(...arguments);this.ErrorLog=[]}logError(e,n,i){let o=this.getQuickAddError(e,"ERROR",n,i);this.addMessageToErrorLog(o);let s=i||new Error(e);console.error(this.formatOutputString(o),s)}logWarning(e,n,i){let o=this.getQuickAddError(e,"WARNING",n,i);this.addMessageToErrorLog(o);let s=i||new Error(e);console.warn(this.formatOutputString(o),s)}logMessage(e,n,i){let o=this.getQuickAddError(e,"LOG",n,i);this.addMessageToErrorLog(o)}addMessageToErrorLog(e){this.ErrorLog.push(e),this.ErrorLog.length>OS&&(this.ErrorLog=this.ErrorLog.slice(-OS))}clearErrorLog(){this.ErrorLog=[]}};var rF=require("obsidian");sw();var dT=class extends Dp{constructor(e){super();this.plugin=e}logError(e,n,i){let o=this.getQuickAddError(e,"ERROR",n,i);new rF.Notice(this.formatOutputString(o),15e3)}logWarning(e,n,i){let o=this.getQuickAddError(e,"WARNING",n,i);new rF.Notice(this.formatOutputString(o))}logMessage(e,n,i){}};ye();nt();nt();var Pz=1e4,$z=50,ste=/plugin:([^\s:)]+)/;function ate(r){let t=r.stack??"",e=`${r.name}: ${r.message}`;return(t.startsWith(e)?t.slice(e.length):t).split(`
`)}function lte(r){for(let t of ate(r)){let e=ste.exec(t);if(e)return{pluginId:e[1],frame:t.trim()}}return null}function cte(r,t){return`${r.name}@${t}`}function Fz(r,t=Date.now){let e=r.manifest.id,n=new Map;r.registerDomEvent(window,"unhandledrejection",i=>{let o=i.reason,s=o instanceof Error?lte(o):null;if(s?.pluginId!==e)return;if(Be(o)){i.preventDefault();return}let a=o,l=cte(a,s.frame),c=t(),d=n.get(l);if(n.set(l,c),!(d!==void 0&&c-d<Pz)){if(n.size>=$z){for(let[u,p]of n)c-p>=Pz&&n.delete(u);if(n.size>=$z){let u=n.keys().next();!u.done&&u.value!==l&&n.delete(u.value)}}Me(a,"A QuickAdd action failed")&&i.preventDefault()}})}Sy();lt();nt();var M_=class{constructor(t,e,n,i){this.app=t;this.plugin=e;this.choices=n;this.choiceExecutor=i}async run(){let t=Zt(this.choices).filter(e=>e.type==="Macro"&&e.runOnStartup);for(let e of t)try{await new ta(this.app,this.plugin,e,this.choiceExecutor,new Map).run()}catch(n){Me(n,`Startup macro '${e.name}' failed`)}}};var PG=require("obsidian");MT();vl();ye();Ua();Nc();$_();qd();Ay();function R_(r,t){return!t.enabled||t.destination.type!=="specifiedFile"||bg(r,t.destination)?null:`Append link target file not found or is not a Markdown file: ${t.destination.path}`}async function O_(r,t,e,n,i){if(!e.enabled)return;let o=kr(r,n),s=PT(n),a=!s||n.focusedProperty?.file.path===o?.path?n.focusedProperty:null;e.destination?.type==="specifiedFile"?await hL(r,t,e,i):a&&!Ba(e.placement)?await U2(r,a,t):await j2(r,t,o,e,i,s)}async function D_(r){try{await gL(r)}catch(t){S.logWarning(`Could not copy link to clipboard for '${r.path}': ${t instanceof Error?t.message:String(t)}`)}}async function Bf({app:r,file:t,opening:e,originLeaf:n,forceFocus:i}){let o=rn(e),s=i??o.focus??!0;return tG(r,t,s)||await P_(r,t,{...o,...i===void 0?{}:{focus:i},originLeaf:n}),s}var qf=require("obsidian");Nd();Le();YT();Qi();ye();Za();var N_=require("obsidian");rr();Za();$f();var L_=class extends N_.FuzzySuggestModal{constructor(e,n,i){super(e);this.settled=!1;this.modalEl.addClass("qa-suggester"),this.rows=i.map(o=>({kind:"candidate",candidate:o})),this.action=fc(n.existingNoteAction),this.promise=new Promise((o,s)=>{this.resolvePromise=o,this.rejectPromise=s}).then(o=>o.kind==="candidate"?zy(o.candidate.item):oa(o.title)),this.setPlaceholder(`Search notes or create ${n.name}`),this.open()}getItems(){return this.rows}getItemText(e){return e.kind==="candidate"?e.candidate.display:e.title}getSuggestions(e){let n=e.trim(),i=to(n),o=a=>a.kind==="candidate"&&a.candidate.exactKeys.includes(i),s=super.getSuggestions(n).sort((a,l)=>Number(o(l.item))-Number(o(a.item)));return n&&!this.rows.some(o)&&s.unshift({item:{kind:"create",title:n},match:{score:Number.NEGATIVE_INFINITY,matches:[]}}),s}renderSuggestion({item:e},n){if(e.kind==="candidate"&&e.candidate.renderPath){let o=e.candidate;Jm(n,e.candidate.renderPath),this.action!=="Open"&&n.querySelector(".suggestion-title")?.prepend(`${this.action}: `),o.renderAlias&&n.querySelector(".suggestion-content")?.createDiv({cls:"suggestion-note",text:`Alias: ${o.renderAlias}`});return}n.addClass("mod-complex");let i=n.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text:e.kind==="create"?`Create new note: ${e.title}`:e.candidate.unresolvedTitle??e.candidate.title}),e.kind==="create"?(0,N_.setIcon)(n.createDiv({cls:"suggestion-aux"}).createSpan({cls:"suggestion-flair"}),"file-plus"):i.createDiv({cls:"suggestion-note",text:"Unresolved link"})}selectSuggestion(e,n){this.settled=!0,super.selectSuggestion(e,n)}onChooseItem(e){this.settled=!0,this.resolvePromise(e)}onClose(){super.onClose(),this.settled||this.rejectPromise(on())}};_u();ku();Sn();nt();rr();Za();$f();async function mG(r,t,e){let{candidates:n}=n_(r,t),i=`Search notes or create ${t.name}`,o=fc(t.existingNoteAction);try{let s=await Zi(e,{remote:async a=>{let l=await eo(a,{items:n.map(c=>({value:zy(c.item),title:c.renderPath&&o!=="Open"?`${o}: ${c.title}`:c.title})),placeholder:i,allowCustomInput:!0,what:"the note-discovery picker"});return typeof l=="string"?oa(l):l},headless:()=>{throw new de(`'${t.name}' n
`),d=()=>{let w=wu(e,c.content,{separateBlockquotes:!0});return Wl(c,w.content,w.insertedStartOffset===null||c.cursor.kind==="none"?null:w.insertedStartOffset+c.cursor.value)};if(l===0)return d();let u=Zl(e),p=u.map(w=>w.replace(/\r$/,"")),m=OM(e),h=Xy(p),g=a.replace(/\r$/,"").trimEnd(),v=h.findIndex((w,T)=>T>=m&&w.trimEnd()===g);if(v!==-1){let w=n?.insertAtEnd?Jy(h,xl(h,v,E_(!!n?.considerSubsections,h,v))??h.length-1,e,o):T_(h,v,e,n?.blankLineAfterMatchMode??"auto"),T=Df(o,e,w,i,r.cursor.kind==="offset"?r.cursor.value:void 0);return Wl(r,T.content,T.insertedEndOffset)}let b=typeof window<"u"?window.moment:void 0,y=vW(p,a,l,s,b,m);if(y.mode==="bodyStart")return d();let C=_W(u,y,c.content,e,c.cursor.kind==="offset"&&c.cursor.source==="marker"?c.cursor.value:void 0);return Wl(c,C.content,C.insertedEndOffset)}sl();Nc();vl();Pp();Le();Uc();Sn();Ma();Su();vf();__();Lc();Dr();Px();var bie=/^[ \t\r\n\f\v]*$/;function wie(r){return bie.test(r)}var q_=class extends Ai{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.useSelectionAsCaptureValue=!0;this.clipboardImageFallbackEnabled=!1;this.createdClipboardAttachmentPaths=[];this.templaterProcessed=!1;this.insertAfterTargetOverride=null;this.lastResolvedInsertAfterHeading=null;this.linebreaksProcessed=!1;this.splitValueLines=!1}setDestinationFile(e){this.file=e,this.sourcePath=e.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(ei(e.path)),this.setPromptRunContext({destination:e.path,destinationKind:"file"})}setDestinationSourcePath(e){this.sourcePath=e,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(ei(e)),this.setPromptRunContext({destination:e,destinationKind:"file"})}setUseSelectionAsCaptureValue(e){this.useSelectionAsCaptureValue=e}setInsertAfterTargetOverride(e){this.insertAfterTargetOverride=e}getResolvedInsertAfterHeading(){return this.lastResolvedInsertAfterHeading}consumeCreatedClipboardAttachmentPaths(){let e=this.createdClipboardAttachmentPaths;return this.createdClipboardAttachmentPaths=[],e}shouldUseSelectionForValue(){return this.useSelectionAsCaptureValue}async getSelectedTextForValue(){let e=await this.getSelectedText();return e.trim().length>0?e:""}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}async getClipboardContent(){let e=await super.getClipboardContent();return e.length>0||!this.clipboardImageFallbackEnabled?e:this.clipboardAttachmentLink!==void 0?this.clipboardAttachmentLink??"":(this.clipboardAttachmentLink=await this.saveClipboardImageAsAttachment(),this.clipboardAttachmentLink??"")}async withClipboardImageFallback(e){let n=this.clipboardImageFallbackEnabled;this.clipboardImageFallbackEnabled=!0;try{return await e()}finally{this.clipboardImageFallbackEnabled=n}}async saveClipboardImageAsAttachment(){let e=navigator.clipboard;if(typeof e?.read!="function")return null;let n,i;try{if(n=await this.getFirstClipboardImageItem(e),!n)return null;i=await(await n.clipboardItem.getType(n.mimeType)).arrayBuffer()}catch{return null}let o=this.getLinkSourcePath()??"",s=await Ax(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),Ix(this.app,s,o)}async getFirstClipboardImageItem(e){let n=await e.read();for(let i of n){let o=i.types.find(s=>il[s]!==void 0);if(o)return{clipboardItem:i,mimeType:o}}return null}getCurrentFileLink(){let e=kr(this.app,this.choiceExecutor);if(!e)return null;let n=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(e,n)}async formatContentWithFile(e,n,i,o){return this.captureIntoFile(e,n,i,o,!0)}async insertFormattedContent(e,n,i,o){return this.captureIntoFile(e,n,i,o,!1)}async captureIntoFile(e,n,i,o,s){if(this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null){let l=An(e);return{content:l,captureContent:l,cursor:{kind:"none"}}}this.setTargetFolderPath(ei(o.path));let a=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatCapture(e,a,s)}asyn
`)?`${e}
`:e}async formatContentOnly(e,n={}){let i=await this.withValueLines(n.eachLine??!1,()=>this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",e,async()=>this.withUserTextProtected(async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(e))))));return wie(i)?this.fileContent:i}async withValueLines(e,n){this.splitValueLines=e,this.defaultValueInputType=e?"multiline":void 0;try{return await n()}finally{this.splitValueLines=!1,this.defaultValueInputType=void 0}}async format(e){if(!this.splitValueLines)return super.format(e);this.splitValueLines=!1;let n=await this.expandCodeAndIncludes(e);if(!fo.test(n))return this.formatScalarTokens(n);let i=await this.resolveValue(n),o=i.split(/\r\n|\r|\n/).map(d=>d.trim()).filter(Boolean);if(o.length===0){let d=this.valuePromptContext;if(!d?.defaultValue||d.optional)return"";o.push("")}let s=await this.replaceMathValueInString(n),a=this.hasConcreteVariable("value"),l=this.variables.get("value"),c=[];try{for(let d of o)this.value=d,a&&this.variables.set("value",d),c.push(await this.formatScalarTokens(s))}finally{this.value=i,a&&this.variables.set("value",l)}return c.map((d,u)=>u<c.length-1&&!d.endsWith(`
`)?`${d}
`:d).join("")}async expandTemplateLinebreaksOnce(e){return this.linebreaksProcessed?e:(this.linebreaksProcessed=!0,this.expandFormatTemplateEscapes(e))}async expandFormatTemplateEscapes(e){let n=await this.replaceGlobalVarInString(e);return this.expandLinebreakEscapesOutsideTokens(n)}async insertAfterHandler(e){let n=e.content,i=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&i===null){let m=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(e,m)}let o=i??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(i===null){let m=o.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(m)?m.trim():null}let s=FM(o);if(MM(s))throw new de("Insert-after target is empty after formatting.");let a=Zl(this.fileContent),l=i!==null&&CW(i)?xW(a):this.isOrderedCreate()?EW(a,this.fileContent):a,{start:c,end:d}=RM(l,s);if(c===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(e,o);throw new de(`Insert-after target not found: '${o}'.`)}let p;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let m=xl(a,c,this.considerSubsectionsForAnchor(a,c)),h=Math.max(m??a.length-1,d);p=Jy(a,h,this.fileContent,n)}else{let m=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";p=T_(a,d,this.fileContent,m)}return this.insertTextAfterPositionInBody(e,this.fileContent,p)}async insertBeforeHandler(e){let n=this.choice.insertBefore;if(!n)throw new de("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=FM(i);if(MM(o))throw new de("Insert-before target is empty after formatting.");let s=Zl(this.fileContent),{start:a}=RM(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(e,i);throw new de(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(e,this.fileContent,a)}async insertAfterInlineHandler(e,n){if(bW(n))throw new de("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(e,n);throw new de(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length,s=this.choice.insertAfter?.replaceExisting?wW(this.fileContent,o):o;return Fa(e,this.fileContent.slice(0,o),this.fileContent.slice(s))}async createInsertAfterIfNotFound(e,n){let i=this.choice.insertAfter;if(i?.createIfNotFoundLocation===Yo)return this.createInsertAfterOrdered(e,n);let o=Fa(e,`${n}
`);return this.createMissingTarget({payload:o,location:i?.createIfNotFoundLocation,rawTarget:i.after,insertAtCursor:s=>{let a=s;if(i?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let l=Zl(this.fileContent),c=xl(l,s,this.considerSubsectionsForAnchor(l,s));a=Jy(l,c??l.length-1,this.fileContent,o.content)}return this.insertTextAfterPositionInBody(o,this.fileContent,a)}})}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===Yo}considerSubsectionsForAnchor(e,n){return E_(!!this.choice.insertAfter?.considerSubsections,e,n)}createInsertAfterOrdered(e,n){return hG({capture:e,targetString:n,fileContent:this.fileContent,insertAfter:this.choice.insertAfter,task:!!this.choice.task})}async createInsertBeforeIfNotFound(e,n){let i=this.choice.insertBefore;if(!i)throw new de("Insert-before settings are missing.");let o=Fa(e,"",`${e.content.endsWith(`
`)||e.content.length===0?"":`
`}${n}`);return this.createMissingTarget({payload:o,location:i.createIfNotFoundLocation,rawTarget:i.before,insertAtCursor:s=>this.insertTextBeforePositionInBody(o,this.fileContent,s)})}async createInlineInsertAfterIfNotFound(e,n){let i=Fa(e,n);return this.createMissingTarget({payload:i,location:this.choice.insertAfter?.createIfNotFoundLocation,rawTarget:this.choice.insertAfter.after,insertAtCursor:o=>this.insertTextAfterPositionInBody(i,this.fileContent,o)})}createMissingTarget({payload:e,location:n,rawTarget:i,insertAtCursor:o}){switch(n){case Vi:return this.insertAtNoteBodyStartTracking(e,!0);case xd:{let s=this.withLastLineEnded();return Fa(e,s+UF(s,e.content))}case Ed:{let s=this.file?ai(this.app,this.file):Un(this.app);if(!s)throw new de(`Unable to insert line '${i}' at cursor position: ${this.file?`'${this.file.path}' isn't open in the active editor`:"no active markdown editor"}.`);try{return o(s.editor.getCursor().line)}catch{throw new de(`Unable to insert line '${i}' at cursor position.`)}}default:throw new de(`Unknown createIfNotFoundLocation: ${n}`)}}insertAtNoteBodyStartTracking(e,n=!1){let i=wu(this.fileContent,e.content,{separateBlockquotes:n});return Wl(e,i.content,i.insertedStartOffset===null||e.cursor.kind==="none"?null:i.insertedStartOffset+e.cursor.value)}insertTextAfterPositionInBody(e,n,i){let o=Df(e.content,n,i,!!this.choice.task,e.cursor.kind==="offset"?e.cursor.value:void 0);return Wl(e,o.content,o.insertedEndOffset)}insertTextBeforePositionInBody(e,n,i){let o=TW(e.content,n,i,e.cursor.kind==="offset"?e.cursor.value:void 0);return Wl(e,o.content,o.insertedEndOffset)}};bu();Pp();ye();kA();bp();jh();Cp();bM();sM();Ua();Uc();nt();_u();ku();Dm();Dr();var yG=require("obsidian");UM();Le();bi();cl();Nd();EM();es();Yi();Dr();_u();ku();Sn();gM();Ln();vM();var gG=require("obsidian");Le();Sn();xC();CC();es();function vG(r,t){let e=r.trim().replace(/^\/+/,"");if(e==="")return{kind:"vault"};let n=tm(e);if(n){if(!n.field)throw new de("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=em(e);if(i){if(i.multiSelect)throw new de("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=Br(e,"Capture target file path");if(Rn.test(o))throw new de(`Capture to '.base' files is not supported (${o}). Use a Template choice instead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(xt.test(o)||lr.test(o))return{kind:"file",path:o};let l=t.normalizeMarkdownFilePath("",a),d=t.getAbstractFileByPath(l)instanceof gG.TFile;return t.isFolder(a)&&!d?{kind:"folder",folder:a}:{kind:"file",path:o}}vl();var z_=class extends Vf{async getFormattedPathToCaptureTo(t){if(t){let s=kr(this.app,this.choiceExecutor);return Vr(s,"Cannot capture to active file - no active file."),s.path}let e=this.getPreselectedCaptureTargetPath();if(e!==void 0){let s=p_({isFolder:a=>Eg(this.app,a),markdownFileExists:a=>this.app.vault.getAbstractFileByPath(u_(a))instanceof yG.TFile},this.choice.captureTo??"",!1);if(s){let a=this.confinePreselectedToScope(s,e);if(a!==null)return this.normalizeCaptureFilePath(a)}}let n=this.choice.captureTo,i=await this.formatter.formatFileName(n,"captureTarget");if(i===this.formatter.periodicNoteTarget?.path)return this.normalizeCaptureFilePath(`${i}.md`);let o=this.resolveCaptureTarget(i);switch(o.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(o.filter);case"property":return this.selectFileWithProperty(o.field,o.value,o.filter);case"folder":return this.selectFileInFolder(o.folder,!1);case"file":return this.normalizeCaptureFilePath(o.path)}}getPreselectedCaptureTargetPath(){return BH(this.choiceExecutor?.variables,this.choice.id)}confinePreselectedToScope(t,e){let n=this.stripLeadingSlash(e);if(t.kind==="folder")return t.folderPathSlash&&!n.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${n}`:n;if(this.resolveScopeFiles(t).some(a=>a.
`),e}async onFileExists(e,n,i=!1){let o=this.getFileByPath(e);if(!o)throw new Error("File not found");this.formatter.setTitle(o.basename),this.formatter.setDestinationFile(o);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n,{eachLine:this.choice.eachLine}));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a=await Bd(this.app,o);if(/{{CURSOR}}/i.test(s)&&gp(s).cursor.kind==="none")return{file:o,newFileContent:a,captureContent:"",priorContent:a,cursor:{kind:"none"},markerOnly:!0};if(i)return{file:o,newFileContent:a,captureContent:s,priorContent:a,cursor:{kind:"none"}};let l=await this.collectIfFrontmatter(()=>this.formatter.insertFormattedContent(s,this.choice,a,o));return this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),l.markerOnly?{file:o,newFileContent:a,captureContent:l.captureContent,priorContent:a,cursor:l.cursor,markerOnly:!0}:{file:o,newFileContent:l.content,captureContent:l.captureContent,priorContent:a,cursor:l.cursor}}periodicNoteFor(e){if(this.choice.captureToActiveFile||this.choice.createFileIfItDoesntExist.createWithTemplate)return null;let n=this.formatter.periodicNoteTarget;return!n||`${n.path}.md`!==e?null:{period:n.period,settings:Hw(this.app,n.period)}}async periodicNoteContent(e){let n=this.periodicNoteFor(e);if(!n)return null;let i=await EL(this.app,n.settings,n.period);if(i===null)return null;let o=this.choiceExecutor.clocks;return TL(i,n.settings,n.period,window.moment(o?.date??o?.now),window.moment(o?.now))}async onCreateFileIfItDoesntExist(e,n,i){Oy(e);let o=Is(e);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(e);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n,{eachLine:this.choice.eachLine}));if(this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),/{{CURSOR}}/i.test(s)&&gp(s).cursor.kind==="none")return null;let a="";if(!this.choice.createFileIfItDoesntExist.createWithTemplate)a=await this.periodicNoteContent(e)??"";else{let m=new _f(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&m.setLinkToCurrentFileBehavior("optional"),m.setTargetFolderPath(ei(e)),m.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:e,destinationKind:"file"}),m.choiceChain=this.chain,m.setKeepUserTextProtected(!0),a=await m.run();let h=m.getAndClearTemplatePropertyVars();S.logMessage(`CaptureChoiceEngine: Collected ${h.size} template property variables`),h.size>0&&S.logMessage(`Variables: ${Array.from(h.keys()).join(", ")}`),this.templatePropertyVars=h}let l=this.choice.createFileIfItDoesntExist.createWithTemplate,c=()=>this.createFileWithInput(e,a,{suppressTemplaterOnCreate:l}),d=l?await c():await XF(this.app,e,c);try{this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&Ef(d,this.templatePropertyVars)&&await Tf(this.app,d,this.templatePropertyVars),l&&a&&await Eu(this.app,d)}finally{a&&await this.restoreUserTextInNote(d)}let u=await this.app.vault.read(d),p=await this.collectIfFrontmatter(()=>this.formatter.insertFormattedContent(s,this.choice,u,d));return this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars()),{file:d,newFileContent:p.content,captureContent:p.captureContent,priorContent:u,cursor:p.cursor,markerOnly:p.markerOnly}}async restoreUserTextInNote(e){let n=await this.app.vault.read(e);An(n)!==n&&await To(this.app,e,An)}collectIfFrontmatter(e){return this.suppressFrontmatterCollection?e():this.formatter.withTemplatePropertyCollection(e)}mergeCapturePropertyVars(e){if(!(!e||e.size===0)){for(let[n,i]of e)this.capturePropertyVars.set(n,i);S.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(e){return this.capturePropertyVars.size===0?!1:Ef(e,this.capturePropertyVars)?(S.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.
${o}
QuickAdd will now revert to backup.`),r.settings=n,U.replaceState(ke(r.settings))}}r.saveSettings()}var KG=foe;je();var la=require("obsidian");ye();function Wf(r){if(!r||typeof r!="string")return null;let t=r.split("-")[0]?.split("+")[0]?.trim();if(!t)return null;let e=t.split(".");if(e.length!==3)return null;let n=Number.parseInt(e[0]??"",10),i=Number.parseInt(e[1]??"",10),o=Number.parseInt(e[2]??"",10);return Number.isNaN(n)||Number.isNaN(i)||Number.isNaN(o)||n<0||i<0||o<0?null:{major:n,minor:i,patch:o}}function QG(r,t){return r.major-t.major||r.minor-t.minor||r.patch-t.patch}async function hoe(r,t,e){let n=await(0,la.requestUrl)({url:`https://api.github.com/repos/${r}/${t}/releases?per_page=100`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){let s=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:"Unknown error";throw new Error(`Failed to fetch releases: ${s}`)}let o=Wf(e);if(!o)throw new Error(`Invalid version ${e}`);return i.filter(s=>{if(s.draft||s.prerelease)return!1;let a=Wf(s.tag_name);return a!==null&&QG(a,o)>0})}var JM=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,XG=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,goe=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function voe(r,t){let e=t?` poster="${t}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${e}></video>`}function yoe(r){let t=r.split(`
`),e=new Set;for(let s of t){let a=s.trim();JM.test(a)&&e.add(a)}let n=new Map;for(let s of t){let a=s.trim().match(XG);a&&e.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<t.length;s++)if(JM.test(t[s].trim()))for(let a of[1,-1]){let l=s+a;for(;l>=0&&l<t.length&&t[l].trim()==="";)l+=a;let c=l>=0&&l<t.length?t[l].trim().match(goe):null;if(c){n.set(t[s].trim(),c[1]),i.add(l);break}}let o=[];for(let s=0;s<t.length;s++){let a=t[s],l=a.trim();if(i.has(s))continue;let c=l.match(XG);if(!(c&&e.has(c[2]))){if(JM.test(l)){o.push(voe(l,n.get(l)));continue}o.push(a)}}return o.join(`
`)}var Q_=class extends la.Modal{constructor(e,n){super(e);this.markdownComponent=new la.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=hoe("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=>{S.logError(`Failed to fetch release notes: ${i}`),this.isClosed||this.close()})}onOpen(){let{contentEl:e}=this;e.empty(),e.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let e=this.contentEl.createDiv("quickadd-update-modal-footer");new la.ButtonComponent(e).setButtonText("Done").setCta().onClick(()=>this.close())}onClose(){let{contentEl:e}=this;this.isClosed=!0,this.markdownComponent.unload(),e.empty()}display(){let{contentEl:e}=this;e.empty(),e.classList.add("quickadd-update-modal-container");let n=`## New in QuickAdd v${this.releases[0].tag_name}
`,i="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",o='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',s=e.createDiv("quickadd-update-modal markdown-rendered"),a=this.releases.map(u=>yoe(u.body??"")).join(`
---
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,d=`${n}
${i}
${o}
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
${l}
---
${a}`;this.markdownComponent.load(),la.MarkdownRenderer.render(this.app,d,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};TT();tn();function ZM(r){if(r===!0||r==="true")return!0;if(r===!1||r==="false")return!1}function JG(r,t){if(t.cancelled!==void 0&&typeof t.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(t.cancelled===!0)return null;if(r==="confirm"){let e=t.value;if(ZM(e)===void 0)return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${eR(e)}.`}return null}function eR(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}rr();Sn();var boe=25e3,woe=6e4,Coe=3e4,xoe=75e3,Eoe=3e3,Toe=32;function _oe(r,t){if(r.length!==t.length)return!1;let e=0;for(let n=0;n<r.length;n++)e|=r.charCodeAt(n)^t.charCodeAt(n);return e===0}function koe(r){if(r.origin||r.referer)return!1;let t=(r.host??"").split(":")[0];return t==="127.0.0.1"||t==="localhost"}function Soe(r){try{let t=window.require;return t?t(r):null}catch{return null}}function X_(){let r=window.crypto;if(r?.randomUUID)return r.randomUUID();if(r?.getRandomValues){let t=r.getRandomValues(new Uint8Array(16));return Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}throw new Error("Interactive prompts require a secure random source (crypto), which is unavailable here.")}var J_="No pending prompt for that requestId",tR="The interactive client disconnected, so the run was ended.",rR=class{constructor(){this.server=null;this.port=0;this.sessions=new Map;this.startPromise=null;this.generation=0}async ensureStarted(){if(this.server)return this.port;if(this.startPromise)return this.startPromise;let t=Soe("http");if(!t)throw new Error("Interactive prompts require desktop Obsidian (Node http is unavailable).");let e=this.generation;return this.startPromise=new Promise((n,i)=>{let o=t.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===e&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==e){o.close(),i(new Error("Interactive server stopped during startup."));return}let s=o.address();this.port=typeof s=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=Toe)throw new Error("Too many active interactive sessions.");let t=X_(),e=X_()+X_(),n={id:t,token:e,queue:[],waiter:null,waiterTimer:null,pending:new Map,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null,disconnectGrace:null};return n.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},Coe),this.sessions.set(t,n),{id:t,token:e}}emitPrompt(t,e){let n=this.sessions.get(t);if(!n)return Promise.reject(new Error("Unknown session"));if(n.finished)return Promise.reject(new de(tR));if(n.aborted)return Promise.reject(new et(ql));let i=X_();return new Promise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:e.type}),this.push(n,{kind:"prompt",requestId:i,prompt:e})})}finish(t,e){let n=this.sessions.get(t);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),n.disconnectGrace&&(window.clearTimeout(n.disconnectGrace),n.disconnectGrace=null);for(let[,i]of n.pending)i.reject(new de(tR));n.pending.clear(),this.push(n,e),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),woe)}}abortSession(t){let e=this.sessions.get(t);if(!e||e.finished)return null;e.aborted=!0;let n=[...e.pending.values()];e.pending.clear();for(let i of n)i.reject(new et(ql));return e.queue=e.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(let t of this.sessions.values()){this.clearSessionTimers(t);for(let[,e]of t.pending)e.reject(new de("QuickA
`):"","path"]]}return[]}function $oe(r){return r.format?.enabled?r.format.format:"{{VALUE}}"}function tj(r){return r.folder??{enabled:!1,folders:[]}}function Foe(r,{templates:t}){let e=Zo(r.appendLink),n=[...nR(r),...t];return[r.captureToActiveFile?"required":"none",rj(e),...n.map(([i,o])=>nj(i,o,e)),...n.map(([i])=>ij(i)),...n.map(([i])=>oj(i))]}function Moe(r,{templates:t,newNotesInCurrentFolder:e}){let n=Zo(r.appendLink),i=iu(tj(r)),o=[...nR(r),...t];return[i==="active-file"||i==="obsidian-default"&&e?"required":"none",rj(n),...o.map(([s,a])=>nj(s,a,n)),...o.map(([s])=>ij(s)),...o.map(([s])=>oj(s))]}function rj(r){return!r.enabled||r.destination.type!=="activeFile"?"none":r.requireActiveFile?"required":"optional"}var Roe=new RegExp(H0.source,"gi");function nj(r,t,e){let n=t==="line"?r.replace(Roe,""):r;return z0.test(n)?t==="content"&&e.enabled&&!e.requireActiveFile?"optional":"required":"none"}var Ooe=/{{FIELD:[^}]*\|\s*default-from\s*:\s*active\s*(?:\||}})/i;function ij(r){return Ooe.test(r)?"optional":"none"}function oj(r){return Oh.test(r)?"optional":"none"}function ZG(r){return r.includes("required")?"required":r.includes("optional")?"optional":"none"}var iR={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"}},oR={value:"<json>",description:"Variables object as JSON"},sj={description:"Allow interactive prompts"},aj={value:"<when>",description:"Day for {{DATE}} (YYYY-MM-DD, last week, last friday, ask, @date:ISO)"},ek={value:"<vault-path|none>",description:"Current note for the run: a vault path, or none (default: the active tab)"},tk={...iR,vars:oR,ui:sj,verify:{description:"Report the verified outcome for Template/Capture choices (file path and effect on success, honest failure when the engine swallows an error)"},date:aj,current:ek},lj={type:{value:"<Template|Capture|Macro|Multi>",description:"Filter by choice type"},commands:{description:"Only include command-enabled choices"}},cj={kind:{value:"<links|tags>",description:"Which suggestions to list"},source:{value:"<vault-path>",description:"Note the link will be inserted in (link text follows the vault's link format from there)"}},sR={path:{value:"<vault-path>",description:"Path to a template file in the vault"},vars:oR,ui:sj,date:aj,current:ek},aR={...iR,vars:oR,fields:{description:"Include full field metadata (options, defaults, widget config)"},current:ek},lR={...iR,vars:{value:"<json>",description:"Variables object as JSON (pre-seeded inputs)"},current:ek},dj={path:{value:"<vault-path>",description:"Path to a .quickadd.json package file in the vault"},decode:{description:"Inline decoded contents for each bundled file"}},uj=new Set(Object.keys(tk)),cR=new Set(Object.keys(sR)),pj=new Set(Object.keys(aR)),mj=new Set(Object.keys(lR));function ca(r){if(r===void 0)return!1;let t=r.toLowerCase();return t==="true"||t==="1"||t==="yes"||t==="on"}function Doe(r){let t;try{t=JSON.parse(r)}catch(e){throw new Error(`Invalid vars JSON: ${e instanceof Error?e.message:String(e)}`)}if(!t||typeof t!="object"||Array.isArray(t))throw new Error("Invalid vars JSON: expected an object");return t}function Gf(r,t){let e={};typeof r.vars=="string"&&Object.assign(e,Doe(r.vars));for(let[n,i]of Object.entries(r)){if(n.startsWith("value-")){let o=n.slice(6);o&&(e[o]=i);continue}t.has(n)||(e[n]=i)}return e}function rb(r,t){if(typeof t.current!="string")return;let e=t.current.trim();if(e==="none")return null;let n=cr(e),i=r.vault.getFileByPath(n)??r.vault.getFileByPath(`${n}.md`);if(!i)throw new Error(`No note at '${e}'.`);return i}function nb(r,t){if(typeof t.id=="string"&&t.id.trim().length>0)return r.getChoiceById(t.id);if(typeof t.choice=="string"&&t.choice.trim().length>0)return r.getChoiceByName(t.choice);throw new Error("Missing choice selector. Provide either choice=<name> or id=<id>")}function ib(r){return{id:r.id,label:r.label,type:r.type,source:r.source??"collected",placeholder:r.placeholder,defaultValue:r.defaultValue,description:r.description,optionCount:r.options?.length??0}}function fj(r){return{...ib(r),options:r.options,displayOpti
/* nosourcemap */