Files
2026-08-28 07:41:10 -04:00

424 lines
1.3 MiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
var hQ=Object.create;var uv=Object.defineProperty;var gQ=Object.getOwnPropertyDescriptor;var vQ=Object.getOwnPropertyNames;var yQ=Object.getPrototypeOf,bQ=Object.prototype.hasOwnProperty;var uL=r=>{throw TypeError(r)};var wQ=(r,e,t)=>e in r?uv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var CQ=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Jr=(r,e)=>{for(var t in e)uv(r,t,{get:e[t],enumerable:!0})},dL=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of vQ(e))!bQ.call(r,i)&&i!==t&&uv(r,i,{get:()=>e[i],enumerable:!(n=gQ(e,i))||n.enumerable});return r};var pL=(r,e,t)=>(t=r!=null?hQ(yQ(r)):{},dL(e||!r||!r.__esModule?uv(t,"default",{value:r,enumerable:!0}):t,r)),xQ=r=>dL(uv({},"__esModule",{value:!0}),r);var ae=(r,e,t)=>wQ(r,typeof e!="symbol"?e+"":e,t),CI=(r,e,t)=>e.has(r)||uL("Cannot "+t);var W=(r,e,t)=>(CI(r,e,"read from private field"),t?t.call(r):e.get(r)),it=(r,e,t)=>e.has(r)?uL("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,n)=>(CI(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),Et=(r,e,t)=>(CI(r,e,"access private method"),t);var rB,nB,iB=b(()=>{rB=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,f))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);return a},nB=(r=>r?rB(r):rB)});function Wv(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=UX(r.endpoint),n=i=>t===i||t.endsWith(`.${i}`);return e==="anthropic"||n("api.anthropic.com")?"anthropic":e==="gemini"||n("generativelanguage.googleapis.com")?"gemini":"openai"}function UX(r){let e=(r??"").trim();if(!e)return"";for(let t of[e,`https://${e}`])try{return new URL(t).hostname.toLowerCase()}catch{}return""}function qX(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function PT(r,e){let t=qX(r),n=new Set(e.map(o=>o.id).filter(o=>!!o)),i=t;for(let o=2;n.has(i);o++)i=`${t}-${o}`;return i}function FT(r){let e=!1,t=new Set;for(let n of r){if(n.id&&!t.has(n.id)){t.add(n.id);continue}n.id=PT(n.id??n.name,r),t.add(n.id),e=!0}return e}function vu(r,e){return e&&e.name===r?e:void 0}function MT(r){return zv[r].map(e=>({...e}))}var zv,oB,WX,zX,RT,ts=b(()=>{zv={openai:[{name:"gpt-5.5",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4",maxTokens:105e4,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-mini",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-5.4-nano",maxTokens:4e5,maxOutputTokens:128e3,supportsTemperature:!1},{name:"gpt-4.1",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4.1-mini",maxTokens:1047576,maxOutputTokens:32768,supportsTemperature:!0},{name:"gpt-4o",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"gpt-4o-mini",maxTokens:128e3,maxOutputTokens:16384,supportsTemperature:!0},{name:"o3",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1},{name:"o4-mini",maxTokens:2e5,maxOutputTokens:1e5,supportsTemperature:!1}],google:[{name:"gemini-3.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3.1-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-pro-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-3-flash-preview",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-pro",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0},{name:"gemini-2.5-flash-lite",maxTokens:1048576,maxOutputTokens:65536,supportsTemperature:!0}],anthropic:[{name:"claude-fable-5",maxTokens:1e6,maxOutputTokens:128e3,supportsTemperature:!1},{name:"claude-sonnet-5",maxTokens:1e6,maxOutputTokens:128e3,supportsTemperature:!1},{name:"claude-opus-4-8",maxTokens:1e6,maxOutputTokens:128e3,supportsTemperature:!1},{name:"claude-opus-4-5",maxTokens:2e5,maxOutputTokens:64e3,supportsTemperature:!0},{name:"claude-haiku-4-5",maxTokens:2e5,maxOutputTokens:64e3,supportsTemperature:!0}]},oB={openai:["gpt-4-32k","gpt-4-1106-preview"],google:["gemini-1.5-pro","gemini-1.5-flash","gemini-1.5-flash-8b"]};WX={id:"openai",name:"OpenAI",endpoint:"https://api.openai.com/v1",kind:"openai",apiKey:"",models:MT("openai"),autoSyncModels:!0,modelSource:"modelsDev"},zX={id:"gemini",name:"Gemini",endpoint:"https://generativelanguage.googleapis.com",kind:"gemini",apiKey:"",models:MT("google"),autoSyncModels:!0,modelSource:"modelsDev"},RT=[WX,zX]});function sB(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function Hv(r,e=Zf){let t=r.trim();if(!t)return r;let n=sB(e,t.toLowerCase());if(n)return n;let[i,...o]=t.split(/\s+/),s=sB(e,i.toLowerCase());return s?[s,...o].join(" "):r}function aB(r){let e={},t=r.split(/\r?\n/);for(let n of t){let i=n.trim();if(!i||i.startsWith("#"))continue;let o=i.indexOf("=");if(o===-1)continue;let s=i.slice(0,o).trim().toLowerCase(),a=i.slice(o+1).trim();!s||!a||Object.defineProperty(e,s,{value:a,enumerable:!0,writable:!0,configurable:!0})}return e}function T0(r){return Object.entries(r).filter(([e,t])=>e&&t).map(([e,t])=>`${e} = ${t}`).join(`
`)}function jv(r){let e=Object.entries(r);if(e.length===0)return[];let n=["t","tm","yd"].map(s=>{let a=r[s];return a?[s,a]:null}).filter(s=>s!==null),i=new Set(n.map(([s])=>s)),o=e.filter(([s])=>!i.has(s)).sort((s,a)=>{let l=s[0].length-a[0].length;return l!==0?l:s[0].localeCompare(a[0])});return[...n,...o]}function $T(r){return jv(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Zf,Gd=b(()=>{Zf={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 OT,_0=b(()=>{ts();Gd();OT={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Zf,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:RT,confirmToolCalls:"destructive"},migrations:{migrateToMacroIDFromEmbeddedMacro:!0,useQuickAddTemplateFolder:!1,incrementFileNameSettingMoveToDefaultBehavior:!1,consolidateFileExistsBehavior:!1,repairTemplateFileExistsBehavior:!1,mutualExclusionInsertAfterAndWriteToBottomOfFile:!1,setVersionAfterUpdateModalRelease:!1,addDefaultAIProviders:!1,removeMacroIndirection:!1,migrateFileOpeningSettings:!1,backfillFileOpeningDefaults:!1,setProviderModelDiscoveryMode:!1,migrateProviderApiKeysToSecretStorage:!1,migrateToMultipleTemplateFolders:!1,refreshStaleDefaultModelSeeds:!1,pinAiModelRefs:!1}}});function vt(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return yu(r,new Map)}function yu(r,e){if(r===null||typeof r!="object")return r;if(e.has(r))return e.get(r);if(r instanceof Date){let i=new Date(r.getTime());return e.set(r,i),i}if(Array.isArray(r)){let i=[];e.set(r,i);for(let o of r)i.push(yu(o,e));return i}if(r instanceof Map){let i=new Map;e.set(r,i);for(let[o,s]of r.entries())i.set(yu(o,e),yu(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(yu(o,e));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,e.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return e.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(yu(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=yu(i.buffer,e),s=new i.constructor(o,i.byteOffset,i.length);return e.set(r,s),s}let t=Object.getPrototypeOf(r),n=Object.create(t);e.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:yu(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var yi=b(()=>{});var le,Pt=b(()=>{iB();_0();yi();le=(()=>{let r=nB((i,o)=>({...vt(OT)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var Yd,Gv,M,Me=b(()=>{Yd=class Yd{register(e){return Yd.loggers.push(e),this}logError(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;Yd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;Yd.loggers.forEach(o=>o.logWarning(t,n,i))}logMessage(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;Yd.loggers.forEach(o=>o.logMessage(t,n,i))}};Yd.loggers=[];Gv=Yd,M=new Gv});var Os,lB,A0,fo,dc,pc,Aa,NT,Jf,em,tm,fc,Kd,z$e,Qd,LT,BT,bu,k0,S0,H$e,j$e,G$e,ir,zr,qi,D0,wu,Ns,gl,mc,VT,Ls,I0,P0,F0,cB,uB,dB,pB,fB,mB,hB,gB,vB,yB,bB,M0,wB,CB,xB,EB,TB,_B,AB,kB,SB,DB,IB,PB,FB,R0,Xd,MB,_t=b(()=>{Os="{{value}}",lB="{{name}}",A0=new RegExp(/^-?[0-9]*$/),fo="top",dc="bottom",pc="cursor",Aa="ordered",NT=new RegExp(/{{DATE(\+-?[0-9]+)?(?:\|((?:startof|endof):[a-z]+))?(?:\|case:([a-z-]+))?}}/i),Jf=new RegExp(/{{DATE:((?:\[[^\]\n\r]*\]|\[(?![^\]\n\r]*\])|[^}\n\r+|\[]|\|(?!(?:startof|endof):[a-z])(?!(?:case):[a-z-]+}}))*)(\+-?[0-9]+)?(?:\|((?:startof|endof):[a-z]+))?(?:\|case:([a-z-]+))?}}/i),em=new RegExp(/{{TIME(?:\|case:([a-z-]+))?}}/i),tm=new RegExp(/{{TIME:((?:\[[^\]\n\r]*\]|\[(?![^\]\n\r]*\])|[^}\n\r+|\[]|\|(?!(?:case):[a-z-]+}}))*)(?:\|case:([a-z-]+))?}}/i),fc=new RegExp(/{{(?:NAME|VALUE)(?!:)(?:\|[^\n\r}]*)?}}/i),Kd=new RegExp(/{{VALUE:([^\n\r}]*)}}/i),z$e=new RegExp(/{{FIELD:([^\n\r}]*)}}/i),Qd="FIELD:",LT=new RegExp(/{{FIELD:([^\n\r}|{]*)(\|[^\n\r}{]*)?}}/i),BT=new RegExp(/{{FILE:([^\n\r{}]*)}}/i),bu=new RegExp(/{{VDATE:([^\n\r},|{]*)(?:,([^\n\r}|{]*))?(?:\|([^\n\r}{]*))?}}/i),k0=new RegExp(/{{LINKCURRENT}}/i),S0=new RegExp(/{{LINKSECTION}}/i),H$e=new RegExp(/{{FILENAMECURRENT}}/i),j$e=new RegExp(/{{FOLDERCURRENT(\|name)?}}/i),G$e=new RegExp(/{{FOLDER(\|name)?}}/i),ir=new RegExp(/\.md$/i),zr=new RegExp(/\.canvas$/i),qi=new RegExp(/\.base$/i),D0=new RegExp(/\.js$/),wu=new RegExp(/{{MACRO:([^\n\r}]*)}}/i),Ns=new RegExp(/{{TEMPLATE:([^\n\r}]*\.(?:md|canvas|base))}}/i),gl=new RegExp(/{{GLOBAL_VAR:([^\n\r}]*)}}/i),mc=new RegExp(/`{3,}js quickadd([\s\S]*?)`{3,}/),VT=new RegExp(/{{MVALUE}}/i),Ls=new RegExp(/{{TITLE}}/i),I0=new RegExp(/{{SELECTED}}/i),P0=new RegExp(/{{CLIPBOARD}}/i),F0=new RegExp(/{{RANDOM:(\d+)}}/i),cB=new RegExp(/\[\[([^\]]*)$/),uB=new RegExp(/#([^ ]*)$/),dB=new RegExp(/{{[D]?[A]?[T]?[E]?[}]?[}]?$/i),pB=new RegExp(/{{[D]?[A]?[T]?[E]?[:]?$|{{DATE:[^\n\r}]*}}$/i),fB=new RegExp(/{{[N]?[A]?[M]?[E]?[}]?[}]?$/i),mB=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[}]?[}]?$/i),hB=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[:]?$|{{VALUE:[^\n\r}]*}}$/i),gB=new RegExp(/{{[V]?[D]?[A]?[T]?[E]?[:]?$|{{VDATE:[^\n\r}]*}}$/i),vB=new RegExp(/{{[L]?[I]?[N]?[K]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),yB=new RegExp(/^\{\{(?:l(?:i(?:n(?:k(?:s(?:e(?:c(?:t(?:i(?:o(?:n(?:\}\}?)?)?)?)?)?)?)?)?)?)?)?)?$/i),bB=new RegExp(/{{[F]?[I]?[L]?[E]?[N]?[A]?[M]?[E]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),M0=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),wB=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[}]?[}]?$/i),CB=new RegExp(/{{[F]?[I]?[L]?[E]?[:]?$/i),xB=new RegExp(/{{[F]?[I]?[E]?[L]?[D]?[:]?$/i),EB=new RegExp(/{{[T]?[E]?[M]?[P]?[L]?[A]?[T]?[E]?[:]?$|{{TEMPLATE:[^\n\r}]*[}]?[}]?$/i),TB=new RegExp(/{{[M]?[A]?[C]?[R]?[O]?[:]?$|{{MACRO:[^\n\r}]*}}$/i),_B=new RegExp(/{{[M]?[V]?[A]?[L]?[U]?[E]?[}]?[}]?/i),AB=new RegExp(/{{[T]?[I]?[T]?[L]?[E]?[}]?[}]?/i),kB=new RegExp(/{{[S]?[E]?[L]?[E]?[C]?[T]?[E]?[D]?[}]?[}]?/i),SB=new RegExp(/{{[C]?[L]?[I]?[P]?[B]?[O]?[A]?[R]?[D]?[}]?[}]?$/i),DB=new RegExp(/{{[R]?[A]?[N]?[D]?[O]?[M]?[:]?$|{{RANDOM:[^\n\r}]*}}$/i),IB=new RegExp(/{{[G]?[L]?[O]?[B]?[A]?[L]?[_]?[V]?[A]?[R]?[:]?$|{{GLOBAL_VAR:[^\n\r}]*}}$/i),PB=new RegExp(/{{[T]?[I]?[M]?[E]?[}]?[}]?/i),FB=new RegExp(/{{[T]?[I]?[M]?[E]?[:]?$|{{TIME:[^\n\r}]*}}$/i),R0="__qa.",Xd=`${R0}captureTargetFilePath`,MB=new RegExp(/\[\[([^\]]*)\]\]/)});var UT=b(()=>{});var Nt,Bs=b(()=>{Nt=class extends Error{constructor(e){super(e||"Macro execution aborted"),this.name="MacroAbortError"}}});function rn(){return new Dt(Cu)}var Dt,Cu,Hr=b(()=>{Bs();Dt=class extends Nt{},Cu="Input cancelled by user"});function Zd(r,e){if(r instanceof Error){if(!e)return r;let n=new Error(`${e}: ${r.message}`);return n.name=r.name,n.stack=r.stack,n}if(typeof r=="string")return new Error(e?`${e}: ${r}`:r);let t=e?`${e}: ${String(r)}`:String(r);return new Error(t)}function It(r){return r instanceof Dt?!0:typeof r=="string"&&HX.has(r)}function OB(r){return typeof r=="object"&&r!==null||typeof r=="function"}function YX(r,e){let t=r;for(let n=0;n<GX&&OB(t);n++){let i=$B.get(t);if(i!==void 0&&e-i<jX)return!0;t=t.cause}return!1}function lt(r,e,t="ERROR"){let n=Date.now();if(YX(r,n))return!1;OB(r)&&$B.set(r,n);let i=Zd(r,e);switch(t){case"ERROR":M.logError(i);break;case"WARNING":M.logWarning(i);break;case"LOG":M.logMessage(i);break;default:M.logError(i)}return!0}function rm(r,e,t="ERROR"){return It(r)?!1:lt(r,e,t)}function NB(r,e,t="ERROR"){try{return r()}catch(n){lt(n,e,t);return}}function nm(r,e){let t=n=>{rm(n,r)};return(...n)=>{try{let i=e(...n);typeof i?.then=="function"&&Promise.resolve(i).catch(t)}catch(i){t(i)}}}var $0,HX,$B,jX,GX,Cr=b(()=>{Me();UT();Hr();$0=100;HX=new Set(["no input given.","No input given.","cancelled"]),$B=new WeakMap,jX=1e4,GX=8});function B0(r,e){try{let t=r.workspace.getActiveViewOfType(zB.MarkdownView);if(!t||t.file?.path!==e.path)return{cursor:null,value:null};let n=t.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 oZ(r,e){return r!==null&&e!==null&&(r.line!==e.line||r.ch!==e.ch)}function qB(r){return typeof r!="string"?null:[...r.matchAll(iZ)].length}function sZ(r,e){let t=qB(r),n=qB(e);return t!==null&&n!==null&&t>n}function WB(r,e){return oZ(r.cursor,e.cursor)||sZ(r.value,e.value)}async function WT(r,e,t=500){try{let n=r.vault.adapter;if(!("stat"in n)||typeof n.stat!="function")return;let i=await n.stat(e.path);if(!i)return;let o=i.mtime,s=Date.now(),a=30;for(;Date.now()-s<t;){await Qv(a);let l=await n.stat(e.path);if(!l||l.mtime===o)return;o=l.mtime,a=Math.min(a*2,200)}}catch(n){M.logWarning(`waitForFileSettle: fallback due to adapter/stat failure \u2013 ${n.message}`)}}function zT(r){return r.plugins.plugins["templater-obsidian"]}function Jd(r){let e=zT(r);return e||null}function Xv(r){return!!Jd(r)?.settings?.trigger_on_file_creation}function Qv(r){return new Promise(e=>window.setTimeout(e,r))}async function q0(r,e,t={}){if(e.extension!=="md"||!Xv(r))return;let i=Jd(r)?.templater?.files_with_pending_templates;if(!(i instanceof Set)){await HB(r,e,{timeoutMs:t.timeoutMs??5e3,gracePeriodMs:t.appearTimeoutMs??2500,quietPeriodMs:200});return}let{timeoutMs:o=5e3,appearTimeoutMs:s=2500}=t,a=Date.now();for(;Date.now()-a<s&&!i.has(e.path);)await Qv(50);for(;Date.now()-a<o&&i.has(e.path);)await Qv(50);await WT(r,e,800)}async function lZ(r,e,t){if(!(U0>0)&&t.size===0){if(Kv){await Kv;return}Kv=(async()=>{try{r.workspace.trigger("templater:all-templates-executed"),await e.templater?.functions_generator?.teardown?.()}catch(n){M.logWarning(`withTemplaterFileCreationSuppressed: teardown failed \u2013 ${n.message}`)}})();try{await Kv}finally{Kv=null}}}async function W0(r,e,t){let n=Jd(r),i=n?.templater?.files_with_pending_templates;if(!n||!Xv(r)||!(i instanceof Set))return await t();U0++;let o=V0.get(e);o||(o={count:0,hadPathInitially:i.has(e)},V0.set(e,o),o.hadPathInitially||i.add(e)),o.count++;let s=!1;try{let a=await t();return s=!0,a}finally{o.count--,U0--,o.count<=0&&(V0.delete(e),o.hadPathInitially||(s&&await Qv(aZ),i.delete(e),await lZ(r,n,i)))}}async function HB(r,e,t={}){let{timeoutMs:n=2e3,quietPeriodMs:i=150,gracePeriodMs:o=800}=t;try{let s=r.vault.adapter;if(!("stat"in s)||typeof s.stat!="function")return;let a=await s.stat(e.path);if(!a)return;let l=a.mtime,c=Date.now(),u=!1,d=c,f=50;for(;Date.now()-d<n;){await Qv(f);let p=await s.stat(e.path);if(!p)return;let m=Date.now();if(p.mtime!==l){u=!0,l=p.mtime,c=m,f=50;continue}if(u){if(m-c>=i)return}else if(m-d>=o)return;f=Math.min(Math.floor(f*1.5),200)}}catch(s){M.logWarning(`waitForFileToStopChanging: fallback due to adapter/stat failure \u2013 ${s.message}`)}}async function cZ(r,e){let t=qT.get(r)??Promise.resolve(),n,i=new Promise(s=>{n=()=>s()}),o=t.catch(()=>{}).then(()=>i);qT.set(r,o),o.finally(()=>{qT.get(r)===o&&qT.delete(r)}).catch(()=>{}),await t.catch(()=>{});try{return await e()}finally{n()}}async function ep(r,e,t={}){if(e.extension!=="md")return;let n=Jd(r),i=n?.templater,o=i?.overwrite_file_commands;if(!n||!i||typeof o!="function")return;let{skipIfNoTags:s=!0,postWait:a=!0}=t;await cZ(e.path,async()=>{await WT(r,e);let l;try{l=await r.vault.read(e)}catch(c){lt(c,`overwriteTemplaterOnce: failed to read ${e.path} before render`);return}if(!(s&&!l.includes("<%")))try{await o.call(i,e),a&&await WT(r,e,800)}catch(c){try{await r.vault.modify(e,l)}catch(u){M.logWarning(`Failed to rollback ${e.path} after Templater error: ${u.message}`)}lt(c,`Templater failed on ${e.path}. Rolled back to pre-render state.`)}})}async function hc(r,e,t){if(t.extension!=="md")return e;let n=Jd(r),i=n?.templater,o=i?.parse_template;if(!n||!i||typeof o!="function")return e;let s=i.create_running_config,a=typeof s=="function"?s.call(i,void 0,t,4):{target_file:t,run_mode:4,frontmatter:{}};return await o.call(i,a,e)}async function Eu(r,e){if(e.extension!=="md"||r.workspace.getActiveFile()?.path!==e.path)return!1;let t=Jd(r),n=!!t?.settings?.auto_jump_to_cursor,i=t?.editor_handler,o=i?.jump_to_next_cursor_location;if(!n)return!1;let s=B0(r,e);if(typeof o=="function")try{return await o.call(i,e,!0),WB(s,B0(r,e))}catch(a){M.logWarning(`jumpToNextTemplaterCursorIfPossible: API failed \u2013 ${a.message}`)}try{return!r.commands.executeCommandById?.("templater-obsidian:jump-to-next-cursor-location")?!1:WB(s,B0(r,e))}catch{}return!1}var zB,iZ,V0,U0,Kv,aZ,qT,jB=b(()=>{zB=require("obsidian");Me();Cr();iZ=/<%\s*tp\.file\.cursor\([0-9]*\)\s*%>/g;V0=new Map,U0=0,Kv=null,aZ=350;qT=new Map});function Nn(r){let e=r.workspace.getActiveViewOfType(GB.MarkdownView);return e?.editor?e:null}function tp(r){return Nn(r)?.editor.getSelection()??""}var GB,vl=b(()=>{GB=require("obsidian")});function om(r){return uZ.has(r)}function np(r){return r==="inFrontmatter"}function HT(r){return dZ.has(r)}function pZ(r,e,t){return r==="embed"&&t.type==="activeFile"&&om(e)?"embed":"link"}function fZ(r,e,t,n){return r==="selection"&&t.type==="activeFile"&&HT(e)&&n==="link"?"selection":"none"}function mZ(r){return r?.type==="specifiedFile"?{type:"specifiedFile",path:typeof r.path=="string"?r.path.trim():""}:{type:"activeFile"}}function hZ(r){return typeof r=="object"&&r!==null&&"enabled"in r&&"placement"in r}function Tu(r){if(hZ(r)){let e=r.placement??"replaceSelection",t=mZ(r.destination),n=pZ(r.linkType,e,t);return{enabled:r.enabled,placement:e,requireActiveFile:r.requireActiveFile??!0,linkType:n,displayText:fZ(r.displayText,e,t,n),destination:t,frontmatterProperty:r.frontmatterProperty,frontmatterHandling:np(e)?r.frontmatterHandling??rp:r.frontmatterHandling}}return{enabled:r,placement:"replaceSelection",requireActiveFile:!!r,linkType:"link",displayText:"none",destination:{type:"activeFile"}}}var rp,uZ,dZ,ip=b(()=>{rp="alwaysAppend",uZ=new Set(["replaceSelection","afterSelection","endOfLine","newLine"]);dZ=new Set(["replaceSelection","afterSelection"])});function gZ(r){return r.vault.getConfig?.("useMarkdownLinks")===!0}function vZ(r,e){let t=e.replace(/\s+/g,n=>/[\r\n]/.test(n)?" ":n).trim();if(t){if(gZ(r))return t.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(!(t.includes("]]")||t.includes("[[")||t.endsWith("]")))return t}}function yZ(r){return`[[${r.path.replace(/\.md$/i,"")}]]`}function jT(r,e,t={}){let n=t.sourcePath??"";if(t.linkType==="embed"&&(!t.placement||om(t.placement)))return`![[${r.metadataCache.fileToLinktext(e,n)}]]`;let o=t.alias===void 0?void 0:vZ(r,t.alias);return o===void 0?r.fileManager.generateMarkdownLink(e,n):r.fileManager.generateMarkdownLink(e,n,void 0,o)}function z0(r){let e=r.trim().replace(/^\/+/,"");return e?/\.md$/i.test(e)?e:`${e}.md`:""}function Jv(r,e){if(e.type!=="specifiedFile")return null;let t=z0(e.path);if(!t)return null;let n=r.vault.getAbstractFileByPath(t);return!(n instanceof Zv.TFile)||n.extension!=="md"?null:n}function bZ(r,e){return r.length===0?e:r.endsWith(`
`)?`${r}${e}`:`${r}
${e}`}async function GT(r,e,t){let n=t.destination;if(n?.type!=="specifiedFile")return!1;let i=Jv(r,n);if(!i)throw new Error(`Append link target file not found or is not a Markdown file: ${n.path}`);let o=jT(r,e,{sourcePath:i.path,linkType:"link"});return await r.vault.process(i,s=>bZ(s,o)),!0}async function wZ(r){let e=window.navigator?.clipboard;if(!e?.writeText)return M.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return M.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function YT(r){let e=yZ(r);return await wZ(e)?(new Zv.Notice(`Copied link to '${r.basename}' to clipboard.`,YB),!0):(new Zv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,YB),!1)}var Zv,YB,ey=b(()=>{Zv=require("obsidian");Me();ip();YB=4e3});function rs(r){if(r.nodeType===Node.DOCUMENT_NODE)return r;let e=r.ownerDocument;if(!e)throw new Error("Unable to resolve owner document for DOM node.");return e}function op(r){let e=rs(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function xr(r,e){return rs(r).createElement(e)}function ty(r,e){return rs(r).createTextNode(e)}var ka=b(()=>{});function KT(r){for(let e of r.workspace.getLeavesOfType("markdown")){let t=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{let n=rs(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(CZ))continue;let o=n.closest(".metadata-property")?.getAttribute("data-property-key");if(!o)continue;return{file:t.file,key:o}}catch{continue}}return null}function xZ(r,e,t){let n=e.trim();if(!n)throw new Error("Cannot append link to an empty frontmatter property key.");let i=ZB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeof o=="string"){r[i]=`${o} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${i}' because it contains a ${typeof o} value.`)}function XB(r,e,t,n=rp){let i=e.trim();if(!i)throw new Error("Cannot append link to an empty frontmatter property key.");let o=ZB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeof s=="object")throw new Error(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${o}' because it is not a list and the link-handling mode is '${KB[n]}'. Choose '${KB.alwaysAppend}' to convert it into a list and append.`);r[o]=[s,t]}function ZB(r,e){let t=QB(e),n=Object.keys(r).filter(i=>QB(i)===t);if(n.length>1)throw new Error(`Cannot append link to frontmatter property '${e}' because the note has multiple properties that normalize to that key.`);return n[0]??e}function QB(r){return r.trim().toLowerCase()}async function QT(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{xZ(i,e.key,n)}),!0}catch(i){return M.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${i instanceof Error?i.message:String(i)}`),!1}}var KB,CZ,sm=b(()=>{Me();ip();ka();KB={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},CZ=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function ry(r,e){let t=Nn(r);return t?.file?.path===e.path?t:null}function H0(r,e){try{let t=Nn(e);return t?(t.editor.replaceSelection(r),!0):(M.logError(`unable to append '${r}' to current line.`),!1)}catch{return M.logError(`unable to append '${r}' to current line.`),!1}}function j0(r,e,t){try{let n=Nn(t);if(!n)return M.logError(`unable to insert '${r}' on new line ${e}.`),!1;let i=n.editor,s=i.getCursor().line,a=r.split(`
`),l=a.length,c=a[l-1]?.length??0;if(e==="above")i.replaceRange(r+`
`,{line:s,ch:0}),i.setCursor({line:s+l-1,ch:c});else{let u=i.getLine(s);i.replaceRange(`
`+r,{line:s,ch:u.length}),i.setCursor({line:s+l,ch:c})}return!0}catch{return M.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function G0(r,e){return j0(r,"above",e)}function Y0(r,e){return j0(r,"below",e)}function EZ(r,e,t,n){let i=l=>r.posToOffset(l),o=e.map(l=>{let[c,u]=i(l.anchor)<=i(l.head)?[l.anchor,l.head]:[l.head,l.anchor];return{from:c,to:u,text:n(r.getRange(c,u))}}).sort((l,c)=>i(l.from)-i(c.from)),s=o.map(({from:l,to:c,text:u})=>t==="replaceSelection"?{from:l,to:c,text:u}:{from:c,text:u}),a=[];if(t==="replaceSelection"){let l=0;for(let{from:c,to:u,text:d}of o)a.push(i(c)+l+d.length),l+=d.length-(i(u)-i(c))}r.transaction({changes:s}),t==="replaceSelection"&&r.setSelections(a.map(l=>({anchor:r.offsetToPos(l)})))}async function JB(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=rp,textForSelection:a}=n,l=r.workspace.getActiveViewOfType(XT.MarkdownView);if(!l){let p="Cannot append link because no active Markdown view is available.";if(i)throw new Error(p);M.logMessage(p);return}if(t==="inFrontmatter"){let p=l.file;if(!p)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(p,m=>{XB(m,o??"",e,s)});return}let c=l.editor;if(!c){let p="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(p);M.logMessage(p);return}let u=c.listSelections().map(p=>({anchor:{...p.anchor},head:{...p.head}}));if(a&&u.length>0&&(t==="replaceSelection"||t==="afterSelection")){EZ(c,u,t,a);return}if(t==="replaceSelection"){c.replaceSelection(e);return}let d=({line:p,ch:m})=>c.posToOffset({line:p,ch:m}),f=u.sort((p,m)=>d(m.head)-d(p.head));for(let p of f){let m=d(p.anchor)>d(p.head)?p.anchor:p.head;switch(t){case"afterSelection":{c.replaceRange(e,m);break}case"endOfLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length};c.replaceRange(e,g);break}case"newLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length},w=v.length===0?"":`
`;c.replaceRange(w+e,g);break}}}}async function sp(r,e,t){if(!t?.enabled)return!1;let n=Tu(t),i=r.workspace.getActiveViewOfType(XT.MarkdownView),o=n.placement!=="inFrontmatter";if(!i||!i.file||o&&!i.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let s=i.file.path,a=jT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement}),l=n.displayText==="selection"?c=>jT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement,alias:c}):void 0;return await JB(r,a,n.placement,{requireActiveView:!1,frontmatterProperty:n.frontmatterProperty,frontmatterHandling:n.frontmatterHandling,textForSelection:l}),!0}function K0(r,e,t,n){try{if(e.extension!=="md"||!Number.isSafeInteger(t)||t<0||t>n.length)return!1;let i=r.workspace.getActiveViewOfType(XT.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;return!o||o.getValue()!==n?!1:(o.setCursor(o.offsetToPos(t)),!0)}catch{return M.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var XT,eV=b(()=>{XT=require("obsidian");vl();Me();ip();ey();sm()});function ZT(r){return ir.test(r)||zr.test(r)||qi.test(r)}function mo(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=ZT(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof tV.TFile?i:null}function zi(r){if(!Array.isArray(r))return[];let e=new Set,t=[];for(let n of r){if(typeof n!="string")continue;let i=n.trim().replace(/^\/+/,"").replace(/\/+$/,"");!i||e.has(i)||(e.add(i),t.push(i))}return t}function Q0(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var tV,JT=b(()=>{tV=require("obsidian");_t()});function nV(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function ny(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function TZ(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function rV(r){return r.parent?.id??r.parent??null}function _Z(r,e){let t=rV(e),n=r.filter(s=>s===e||nV(s)?!1:t===null||rV(s)!==t);if(n.length===0)return null;let i=r.indexOf(e);return(i===-1?r:[...r.slice(i+1),...r.slice(0,i)]).find(s=>n.includes(s))??n[0]}function AZ(r){return r instanceof am.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function kZ(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&nV(n))return _Z(TZ(r),n)??r.workspace.getLeaf("tab");switch(e){case"reuse":return r.workspace.getLeaf(!1);case"tab":return r.workspace.getLeaf("tab");case"split":return r.workspace.getLeaf("split",t);case"window":return r.workspace.getLeaf("window");case"left-sidebar":return r.workspace.getLeftLeaf(!0);case"right-sidebar":return r.workspace.getRightLeaf(!0);default:return r.workspace.getLeaf("tab")}}async function gc(r,e,t={}){let{location:n="tab",direction:i="vertical",mode:o,focus:s=!0,eState:a,originLeaf:l}=t,c=typeof e=="string"?r.vault.getAbstractFileByPath(e):e;if(!AZ(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??ny(r),d=kZ(r,n,i,u);if(!d)throw new Error("Could not obtain a workspace leaf.");if(await d.openFile(c),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=d.getViewState(),p={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(p.mode="preview",delete p.source):o==="source"?(p.mode="source",p.source=!0):o==="live"||o==="live-preview"?(p.mode="source",p.source=!1):typeof o=="object"&&o.mode==="source"&&(p.mode="source",p.source=o.source),await d.setViewState({...f,state:{...p,...a}})}return s&&r.workspace.setActiveLeaf(d,{focus:!0}),d}function X0(r){return(0,am.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function iV(r,e){return X0(r)===X0(e)}function ap(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{let o=i.view;if(o instanceof am.FileView&&o.file&&(o.file===e||iV(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var am,oV=b(()=>{am=require("obsidian")});function vc(r){let e=0,t=0,n=!1,i=0,o=0,s=0;for(;e<=r.length;){let a=r.indexOf(`
`,e),l=a===-1?r.length:a,c=r.slice(e,l).replace(/\r$/,""),u=a===-1?r.length+1:a+1,d=SZ.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return sV(r.slice(o,e),s)}else if(d){let f=d[2].trim().split(/\s+/)[0]?.toLowerCase();(f==="js"||f==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?sV(r.slice(o),s):{code:null,error:DZ}}function sV(r,e){return r.trim().length===0?{code:"",error:IZ}:{code:`
`.repeat(e)+r}}var SZ,DZ,IZ,iy=b(()=>{SZ=/^ {0,3}(`{3,})(.*)$/,DZ="No ```js (or ```javascript) code block found in the note.",IZ="The ```js code block is empty."});function aV(r){return r instanceof e_}function FZ(r){return r.charCodeAt(0)===65279?r.slice(1):r}function MZ(r){return FZ(r).trimStart().slice(0,PZ).toLowerCase()}function RZ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(MZ(r))}function Z0(r,e){let t=new e_(r);throw e.reportLoadErrors!==!1&&lt(t),t}function $Z(r){return`QuickAdd could not load ${r}. This file looks like a saved webpage, not a JavaScript file. Open the script on GitHub, use the Raw button, then download the .js file and select that file in QuickAdd.`}function OZ(r){return`QuickAdd loaded ${r}, but its default export is not a function. Change it to module.exports = async (params) => { ... } or exports.default = async (params) => { ... }. If you meant to export several functions, use module.exports = { run } and select Script::run.`}function NZ(r,e){let t=e?`the required module "${e}"`:"a required module";return`QuickAdd could not load ${r} because it could not find ${t}. Check that the required file or package exists, and that the capitalization in require(...) matches the file name exactly.`}function LZ(r){return lV(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function lV(r){return!r||typeof r!="object"?!1:r.code==="MODULE_NOT_FOUND"?!0:(r instanceof Error?r.message:String(r)).includes("Cannot find module")}function BZ(r){return r!==null&&typeof r=="object"}function VZ(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function UZ(r){return typeof r=="function"?!0:BZ(r)?VZ(r):!1}function lp(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function r_(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=lp(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function Sa(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){M.logError(`failed to load file ${r.path}.`);return}if(n instanceof t_.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(ir.test(n.path)){let{code:m,error:v}=vc(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new t_.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}RZ(l)&&Z0($Z(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw lV(m)&&Z0(NZ(r.path,LZ(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:f}=lp(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){let m;for(;m=f.shift();)u=u[m]}return d&&!p&&!UZ(u)&&Z0(OZ(r.path),t),u}}var t_,PZ,e_,n_=b(()=>{t_=require("obsidian");_t();Me();iy();Cr();PZ=1024,e_=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function yc(r){if(r==null||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return"";let e=String(r).trim();return e.startsWith("#")?e.substring(1).trim():e}function _u(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(yc).filter(Boolean)}var i_=b(()=>{});var Hi,cp=b(()=>{i_();Hi=class{static filterFiles(e,t,n){let i=e;return i=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}static applyInclusionFilters(e,t,n){let i=!1,o=e,s=this.getIncludeFolders(t);return s.length>0&&(i=!0,o=o.filter(a=>s.some(l=>this.matchesFolder(a,l)))),t.tags&&t.tags.length>0&&(i=!0,o=o.filter(a=>this.matchesAllTags(a,t.tags??[],n))),i?o:e}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders&&t.excludeFolders.length>0&&t.excludeFolders.some(o=>this.matchesFolder(i,o))||t.excludeTags&&t.excludeTags.length>0&&this.matchesAnyTag(i,t.excludeTags,n)||t.excludeFiles&&t.excludeFiles.length>0&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(e,t){let n=this.normalizePath(t),i=this.normalizePath(e.path);return i.startsWith(n+"/")||i.substring(0,i.lastIndexOf("/"))===n}static matchesAllTags(e,t,n){return this.matchesTags(e,t,n,"all")}static matchesAnyTag(e,t,n){return this.matchesTags(e,t,n,"any")}static matchesTags(e,t,n,i){let o=n(e);if(!o)return!1;let s=this.getAllTags(o),a=t.map(c=>this.normalizeTag(c)).filter(Boolean),l=c=>s.some(u=>u===c||u.startsWith(c+"/"));return i==="all"?a.every(l):a.some(l)}static matchesFile(e,t){return e.name===t||e.path===t}static getAllTags(e){let t=[];return e.frontmatter?.tags&&t.push(..._u(e.frontmatter.tags)),e.frontmatter?.tag&&t.push(..._u(e.frontmatter.tag)),e.tags&&t.push(...e.tags.map(n=>yc(n.tag))),t.filter(Boolean)}static normalizeTag(e){return yc(e)}static normalizePath(e){return e.replace(/^\/+|\/+$/g,"")}}});function Vs(r){return r.vault.getAllLoadedFiles().filter(e=>e instanceof J0.TFolder).map(e=>e.path)}function lm(r,e){let t=r.vault.getAbstractFileByPath(e);return!!t&&t instanceof J0.TFolder}function ns(r,e){let t=e.replace(/\/+$/,"");if(t==="")return r.vault.getMarkdownFiles();let n=`${t}/`;return r.vault.getMarkdownFiles().filter(i=>i.path===t||i.path.startsWith(n))}function qZ(r){let e=r.frontmatter;if(!e)return[];let t=Object.entries(e);if(!t.length)return[];let n=t.filter(([o,s])=>{let a=o.toLowerCase();return a==="tags"||a==="tag"});return n?n.flatMap(([,o])=>_u(o)).filter(o=>!!o):[]}function WZ(r,e){let t=r.metadataCache.getFileCache(e);if(!t)return[];let n=[];return t.frontmatter&&n.push(...qZ(t)),t.tags&&Array.isArray(t.tags)&&n.push(...t.tags.map(i=>yc(i.tag))),n}function oy(r,e){let t=e.replace(/^#/,"");return r.vault.getMarkdownFiles().filter(n=>WZ(r,n).includes(t))}function cm(r,e){return Hi.filterFiles(r.vault.getMarkdownFiles(),e,t=>r.metadataCache.getFileCache(t))}function zZ(r,e){let t=e.trim().toLowerCase();return r==null?!1:Array.isArray(r)?r.some(n=>n!=null&&typeof n!="object"&&String(n).trim().toLowerCase()===t):typeof r=="object"?!1:String(r).trim().toLowerCase()===t}function um(r,e,t,n){let i=e.trim().toLowerCase();if(!i)return[];let o=r.vault.getMarkdownFiles().filter(a=>{let l=r.metadataCache.getFileCache(a)?.frontmatter;if(!l)return!1;let c=Object.entries(l).find(([u])=>u.toLowerCase()===i);return c?t===void 0?!0:zZ(c[1],t):!1});return n&&(n.folder||n.tags?.length||n.excludeFolders?.length||n.excludeTags?.length||n.excludeFiles?.length)&&(o=Hi.filterFiles(o,n,a=>r.metadataCache.getFileCache(a))),o}var J0,cV=b(()=>{J0=require("obsidian");cp();i_()});function uV(r,e){return r.commands.findCommand(e)}function eP(r,e){uV(r,e)&&(delete r.commands.commands[e],delete r.commands.editorCommands[e])}var dV=b(()=>{});function Us(r){return r.split("|")}function pV(r){return r.startsWith("|")?r.slice(1):r}function ho(r){let e=r.indexOf(":");if(e===-1)return null;let t=r.slice(0,e).trim().toLowerCase();if(!t)return null;let n=r.slice(e+1).trim();return{key:t,value:n}}function Au(r){if(!r)return!0;let e=r.trim().toLowerCase();return!["false","no","0","off"].includes(e)}function Da(r,e){let t=!1;return{remaining:r.filter(i=>i.trim().toLowerCase()===e?(t=!0,!1):!0),found:t}}var up=b(()=>{});function o_(r){let e=r.trim().toLowerCase(),t=HZ[e];if(!t)throw new Error(`Unknown date unit "${r.trim()}". Valid units: ${jZ}.`);return t}function tP(r){let e=ho(r);return e?e.key==="startof"?{boundary:"start",unit:o_(e.value)}:e.key==="endof"?{boundary:"end",unit:o_(e.value)}:null:null}function dm(r,e){return e?e.boundary==="start"?r.startOf(e.unit):r.endOf(e.unit):r}var HZ,jZ,sy=b(()=>{up();HZ={year:"year",years:"year",y:"year",quarter:"quarter",quarters:"quarter",q:"quarter",month:"month",months:"month",week:"week",weeks:"week",w:"week",isoweek:"isoWeek",isoweeks:"isoWeek",day:"day",days:"day",d:"day"},jZ="year, quarter, month, week, isoweek, day"});function qs(r){let e;return r?.offset!==null&&r?.offset!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),dm(window.moment().add(e),r?.snap).format(r?.format??"YYYY-MM-DD")}var fV=b(()=>{sy()});var qt=b(()=>{jB();eV();JT();oV();n_();cV();dV();fV()});var jr,Ln,fn,nn,s_,Su,bc,dp,mV,a_,pm,hV,rP,l_,GZ,YZ,KZ,QZ,XZ,ZZ,JZ,eJ,tJ,gV,is=b(()=>{jr="top",Ln="bottom",fn="right",nn="left",s_="auto",Su=[jr,Ln,fn,nn],bc="start",dp="end",mV="clippingParents",a_="viewport",pm="popper",hV="reference",rP=Su.reduce(function(r,e){return r.concat([e+"-"+bc,e+"-"+dp])},[]),l_=[].concat(Su,[s_]).reduce(function(r,e){return r.concat([e,e+"-"+bc,e+"-"+dp])},[]),GZ="beforeRead",YZ="read",KZ="afterRead",QZ="beforeMain",XZ="main",ZZ="afterMain",JZ="beforeWrite",eJ="write",tJ="afterWrite",gV=[GZ,YZ,KZ,QZ,XZ,ZZ,JZ,eJ,tJ]});function ti(r){return r?(r.nodeName||"").toLowerCase():null}var Du=b(()=>{});function Rr(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}var Ia=b(()=>{});function Ws(r){var e=Rr(r).Element;return r instanceof e||r instanceof Element}function Bn(r){var e=Rr(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function fm(r){if(typeof ShadowRoot>"u")return!1;var e=Rr(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}var os=b(()=>{Ia()});function rJ(r){var e=r.state;Object.keys(e.elements).forEach(function(t){var n=e.styles[t]||{},i=e.attributes[t]||{},o=e.elements[t];!Bn(o)||!ti(o)||(Object.assign(o.style,n),Object.keys(i).forEach(function(s){var a=i[s];a===!1?o.removeAttribute(s):o.setAttribute(s,a===!0?"":a)}))})}function nJ(r){var e=r.state,t={popper:{position:e.options.strategy,left:"0",top:"0",margin:"0"},arrow:{position:"absolute"},reference:{}};return Object.assign(e.elements.popper.style,t.popper),e.styles=t,e.elements.arrow&&Object.assign(e.elements.arrow.style,t.arrow),function(){Object.keys(e.elements).forEach(function(n){var i=e.elements[n],o=e.attributes[n]||{},s=Object.keys(e.styles.hasOwnProperty(n)?e.styles[n]:t[n]),a=s.reduce(function(l,c){return l[c]="",l},{});!Bn(i)||!ti(i)||(Object.assign(i.style,a),Object.keys(o).forEach(function(l){i.removeAttribute(l)}))})}}var vV,yV=b(()=>{Du();os();vV={name:"applyStyles",enabled:!0,phase:"write",fn:rJ,effect:nJ,requires:["computeStyles"]}});function ri(r){return r.split("-")[0]}var Iu=b(()=>{});var Pa,pp,wc,Pu=b(()=>{Pa=Math.max,pp=Math.min,wc=Math.round});function mm(){var r=navigator.userAgentData;return r!=null&&r.brands&&Array.isArray(r.brands)?r.brands.map(function(e){return e.brand+"/"+e.version}).join(" "):navigator.userAgent}var nP=b(()=>{});function ay(){return!/^((?!chrome|android).)*safari/i.test(mm())}var iP=b(()=>{nP()});function zs(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var n=r.getBoundingClientRect(),i=1,o=1;e&&Bn(r)&&(i=r.offsetWidth>0&&wc(n.width)/r.offsetWidth||1,o=r.offsetHeight>0&&wc(n.height)/r.offsetHeight||1);var s=Ws(r)?Rr(r):window,a=s.visualViewport,l=!ay()&&t,c=(n.left+(l&&a?a.offsetLeft:0))/i,u=(n.top+(l&&a?a.offsetTop:0))/o,d=n.width/i,f=n.height/o;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}var hm=b(()=>{os();Pu();Ia();iP()});function fp(r){var e=zs(r),t=r.offsetWidth,n=r.offsetHeight;return Math.abs(e.width-t)<=1&&(t=e.width),Math.abs(e.height-n)<=1&&(n=e.height),{x:r.offsetLeft,y:r.offsetTop,width:t,height:n}}var c_=b(()=>{hm()});function ly(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&fm(t)){var n=e;do{if(n&&r.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}var oP=b(()=>{os()});function go(r){return Rr(r).getComputedStyle(r)}var gm=b(()=>{Ia()});function sP(r){return["table","td","th"].indexOf(ti(r))>=0}var bV=b(()=>{Du()});function bi(r){return((Ws(r)?r.ownerDocument:r.document)||window.document).documentElement}var Cc=b(()=>{os()});function xc(r){return ti(r)==="html"?r:r.assignedSlot||r.parentNode||(fm(r)?r.host:null)||bi(r)}var cy=b(()=>{Du();Cc();os()});function wV(r){return!Bn(r)||go(r).position==="fixed"?null:r.offsetParent}function iJ(r){var e=/firefox/i.test(mm()),t=/Trident/i.test(mm());if(t&&Bn(r)){var n=go(r);if(n.position==="fixed")return null}var i=xc(r);for(fm(i)&&(i=i.host);Bn(i)&&["html","body"].indexOf(ti(i))<0;){var o=go(i);if(o.transform!=="none"||o.perspective!=="none"||o.contain==="paint"||["transform","perspective"].indexOf(o.willChange)!==-1||e&&o.willChange==="filter"||e&&o.filter&&o.filter!=="none")return i;i=i.parentNode}return null}function Fa(r){for(var e=Rr(r),t=wV(r);t&&sP(t)&&go(t).position==="static";)t=wV(t);return t&&(ti(t)==="html"||ti(t)==="body"&&go(t).position==="static")?e:t||iJ(r)||e}var vm=b(()=>{Ia();Du();gm();os();bV();cy();nP()});function mp(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}var u_=b(()=>{});function hp(r,e,t){return Pa(r,pp(e,t))}function CV(r,e,t){var n=hp(r,e,t);return n>t?t:n}var aP=b(()=>{Pu()});function uy(){return{top:0,right:0,bottom:0,left:0}}var lP=b(()=>{});function dy(r){return Object.assign({},uy(),r)}var cP=b(()=>{lP()});function py(r,e){return e.reduce(function(t,n){return t[n]=r,t},{})}var uP=b(()=>{});function sJ(r){var e,t=r.state,n=r.name,i=r.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,a=ri(t.placement),l=mp(a),c=[nn,fn].indexOf(a)>=0,u=c?"height":"width";if(!(!o||!s)){var d=oJ(i.padding,t),f=fp(o),p=l==="y"?jr:nn,m=l==="y"?Ln:fn,v=t.rects.reference[u]+t.rects.reference[l]-s[l]-t.rects.popper[u],g=s[l]-t.rects.reference[l],y=Fa(o),w=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,k=v/2-g/2,C=d[p],E=w-f[u]-d[m],x=w/2-f[u]/2+k,D=hp(C,x,E),P=l;t.modifiersData[n]=(e={},e[P]=D,e.centerOffset=D-x,e)}}function aJ(r){var e=r.state,t=r.options,n=t.element,i=n===void 0?"[data-popper-arrow]":n;i!=null&&(typeof i=="string"&&(i=e.elements.popper.querySelector(i),!i)||ly(e.elements.popper,i)&&(e.elements.arrow=i))}var oJ,xV,EV=b(()=>{Iu();c_();oP();vm();u_();aP();cP();uP();is();oJ=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,dy(typeof e!="number"?e:py(e,Su))};xV={name:"arrow",enabled:!0,phase:"main",fn:sJ,effect:aJ,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]}});function Hs(r){return r.split("-")[1]}var ym=b(()=>{});function cJ(r,e){var t=r.x,n=r.y,i=e.devicePixelRatio||1;return{x:wc(t*i)/i||0,y:wc(n*i)/i||0}}function TV(r){var e,t=r.popper,n=r.popperRect,i=r.placement,o=r.variation,s=r.offsets,a=r.position,l=r.gpuAcceleration,c=r.adaptive,u=r.roundOffsets,d=r.isFixed,f=s.x,p=f===void 0?0:f,m=s.y,v=m===void 0?0:m,g=typeof u=="function"?u({x:p,y:v}):{x:p,y:v};p=g.x,v=g.y;var y=s.hasOwnProperty("x"),w=s.hasOwnProperty("y"),k=nn,C=jr,E=window;if(c){var x=Fa(t),D="clientHeight",P="clientWidth";if(x===Rr(t)&&(x=bi(t),go(x).position!=="static"&&a==="absolute"&&(D="scrollHeight",P="scrollWidth")),x=x,i===jr||(i===nn||i===fn)&&o===dp){C=Ln;var H=d&&x===E&&E.visualViewport?E.visualViewport.height:x[D];v-=H-n.height,v*=l?1:-1}if(i===nn||(i===jr||i===Ln)&&o===dp){k=fn;var U=d&&x===E&&E.visualViewport?E.visualViewport.width:x[P];p-=U-n.width,p*=l?1:-1}}var oe=Object.assign({position:a},c&&lJ),ce=u===!0?cJ({x:p,y:v},Rr(t)):{x:p,y:v};if(p=ce.x,v=ce.y,l){var O;return Object.assign({},oe,(O={},O[C]=w?"0":"",O[k]=y?"0":"",O.transform=(E.devicePixelRatio||1)<=1?"translate("+p+"px, "+v+"px)":"translate3d("+p+"px, "+v+"px, 0)",O))}return Object.assign({},oe,(e={},e[C]=w?v+"px":"",e[k]=y?p+"px":"",e.transform="",e))}function uJ(r){var e=r.state,t=r.options,n=t.gpuAcceleration,i=n===void 0?!0:n,o=t.adaptive,s=o===void 0?!0:o,a=t.roundOffsets,l=a===void 0?!0:a,c={placement:ri(e.placement),variation:Hs(e.placement),popper:e.elements.popper,popperRect:e.rects.popper,gpuAcceleration:i,isFixed:e.options.strategy==="fixed"};e.modifiersData.popperOffsets!=null&&(e.styles.popper=Object.assign({},e.styles.popper,TV(Object.assign({},c,{offsets:e.modifiersData.popperOffsets,position:e.options.strategy,adaptive:s,roundOffsets:l})))),e.modifiersData.arrow!=null&&(e.styles.arrow=Object.assign({},e.styles.arrow,TV(Object.assign({},c,{offsets:e.modifiersData.arrow,position:"absolute",adaptive:!1,roundOffsets:l})))),e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-placement":e.placement})}var lJ,_V,AV=b(()=>{is();vm();Ia();Cc();gm();Iu();ym();Pu();lJ={top:"auto",right:"auto",bottom:"auto",left:"auto"};_V={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:uJ,data:{}}});function dJ(r){var e=r.state,t=r.instance,n=r.options,i=n.scroll,o=i===void 0?!0:i,s=n.resize,a=s===void 0?!0:s,l=Rr(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(u){u.addEventListener("scroll",t.update,d_)}),a&&l.addEventListener("resize",t.update,d_),function(){o&&c.forEach(function(u){u.removeEventListener("scroll",t.update,d_)}),a&&l.removeEventListener("resize",t.update,d_)}}var d_,kV,SV=b(()=>{Ia();d_={passive:!0};kV={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:dJ,data:{}}});function bm(r){return r.replace(/left|right|bottom|top/g,function(e){return pJ[e]})}var pJ,DV=b(()=>{pJ={left:"right",right:"left",bottom:"top",top:"bottom"}});function p_(r){return r.replace(/start|end/g,function(e){return fJ[e]})}var fJ,IV=b(()=>{fJ={start:"end",end:"start"}});function gp(r){var e=Rr(r),t=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:t,scrollTop:n}}var f_=b(()=>{Ia()});function vp(r){return zs(bi(r)).left+gp(r).scrollLeft}var m_=b(()=>{hm();Cc();f_()});function dP(r,e){var t=Rr(r),n=bi(r),i=t.visualViewport,o=n.clientWidth,s=n.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;var c=ay();(c||!c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a+vp(r),y:l}}var PV=b(()=>{Ia();Cc();m_();iP()});function pP(r){var e,t=bi(r),n=gp(r),i=(e=r.ownerDocument)==null?void 0:e.body,o=Pa(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=Pa(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-n.scrollLeft+vp(r),l=-n.scrollTop;return go(i||t).direction==="rtl"&&(a+=Pa(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}var FV=b(()=>{Cc();gm();m_();f_();Pu()});function yp(r){var e=go(r),t=e.overflow,n=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+n)}var h_=b(()=>{gm()});function g_(r){return["html","body","#document"].indexOf(ti(r))>=0?r.ownerDocument.body:Bn(r)&&yp(r)?r:g_(xc(r))}var MV=b(()=>{cy();h_();Du();os()});function Fu(r,e){var t;e===void 0&&(e=[]);var n=g_(r),i=n===((t=r.ownerDocument)==null?void 0:t.body),o=Rr(n),s=i?[o].concat(o.visualViewport||[],yp(n)?n:[]):n,a=e.concat(s);return i?a:a.concat(Fu(xc(s)))}var fP=b(()=>{MV();cy();Ia();h_()});function wm(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}var mP=b(()=>{});function mJ(r,e){var t=zs(r,!1,e==="fixed");return t.top=t.top+r.clientTop,t.left=t.left+r.clientLeft,t.bottom=t.top+r.clientHeight,t.right=t.left+r.clientWidth,t.width=r.clientWidth,t.height=r.clientHeight,t.x=t.left,t.y=t.top,t}function RV(r,e,t){return e===a_?wm(dP(r,t)):Ws(e)?mJ(e,t):wm(pP(bi(r)))}function hJ(r){var e=Fu(xc(r)),t=["absolute","fixed"].indexOf(go(r).position)>=0,n=t&&Bn(r)?Fa(r):r;return Ws(n)?e.filter(function(i){return Ws(i)&&ly(i,n)&&ti(i)!=="body"}):[]}function hP(r,e,t,n){var i=e==="clippingParents"?hJ(r):[].concat(e),o=[].concat(i,[t]),s=o[0],a=o.reduce(function(l,c){var u=RV(r,c,n);return l.top=Pa(u.top,l.top),l.right=pp(u.right,l.right),l.bottom=pp(u.bottom,l.bottom),l.left=Pa(u.left,l.left),l},RV(r,s,n));return a.width=a.right-a.left,a.height=a.bottom-a.top,a.x=a.left,a.y=a.top,a}var $V=b(()=>{is();PV();FV();fP();vm();Cc();gm();os();hm();cy();oP();Du();mP();Pu()});function fy(r){var e=r.reference,t=r.element,n=r.placement,i=n?ri(n):null,o=n?Hs(n):null,s=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(i){case jr:l={x:s,y:e.y-t.height};break;case Ln:l={x:s,y:e.y+e.height};break;case fn:l={x:e.x+e.width,y:a};break;case nn:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var c=i?mp(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(o){case bc:l[c]=l[c]-(e[u]/2-t[u]/2);break;case dp:l[c]=l[c]+(e[u]/2-t[u]/2);break;default:}}return l}var gP=b(()=>{Iu();ym();u_();is()});function Ma(r,e){e===void 0&&(e={});var t=e,n=t.placement,i=n===void 0?r.placement:n,o=t.strategy,s=o===void 0?r.strategy:o,a=t.boundary,l=a===void 0?mV:a,c=t.rootBoundary,u=c===void 0?a_:c,d=t.elementContext,f=d===void 0?pm:d,p=t.altBoundary,m=p===void 0?!1:p,v=t.padding,g=v===void 0?0:v,y=dy(typeof g!="number"?g:py(g,Su)),w=f===pm?hV:pm,k=r.rects.popper,C=r.elements[m?w:f],E=hP(Ws(C)?C:C.contextElement||bi(r.elements.popper),l,u,s),x=zs(r.elements.reference),D=fy({reference:x,element:k,strategy:"absolute",placement:i}),P=wm(Object.assign({},k,D)),H=f===pm?P:x,U={top:E.top-H.top+y.top,bottom:H.bottom-E.bottom+y.bottom,left:E.left-H.left+y.left,right:H.right-E.right+y.right},oe=r.modifiersData.offset;if(f===pm&&oe){var ce=oe[i];Object.keys(U).forEach(function(O){var G=[fn,Ln].indexOf(O)>=0?1:-1,V=[jr,Ln].indexOf(O)>=0?"y":"x";U[O]+=ce[V]*G})}return U}var my=b(()=>{$V();Cc();hm();gP();mP();is();os();cP();uP()});function vP(r,e){e===void 0&&(e={});var t=e,n=t.placement,i=t.boundary,o=t.rootBoundary,s=t.padding,a=t.flipVariations,l=t.allowedAutoPlacements,c=l===void 0?l_:l,u=Hs(n),d=u?a?rP:rP.filter(function(m){return Hs(m)===u}):Su,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var p=f.reduce(function(m,v){return m[v]=Ma(r,{placement:v,boundary:i,rootBoundary:o,padding:s})[ri(v)],m},{});return Object.keys(p).sort(function(m,v){return p[m]-p[v]})}var OV=b(()=>{ym();is();my();Iu()});function gJ(r){if(ri(r)===s_)return[];var e=bm(r);return[p_(r),e,p_(e)]}function vJ(r){var e=r.state,t=r.options,n=r.name;if(!e.modifiersData[n]._skip){for(var i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!0:s,l=t.fallbackPlacements,c=t.padding,u=t.boundary,d=t.rootBoundary,f=t.altBoundary,p=t.flipVariations,m=p===void 0?!0:p,v=t.allowedAutoPlacements,g=e.options.placement,y=ri(g),w=y===g,k=l||(w||!m?[bm(g)]:gJ(g)),C=[g].concat(k).reduce(function(be,Be){return be.concat(ri(Be)===s_?vP(e,{placement:Be,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:v}):Be)},[]),E=e.rects.reference,x=e.rects.popper,D=new Map,P=!0,H=C[0],U=0;U<C.length;U++){var oe=C[U],ce=ri(oe),O=Hs(oe)===bc,G=[jr,Ln].indexOf(ce)>=0,V=G?"width":"height",F=Ma(e,{placement:oe,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),Z=G?O?fn:nn:O?Ln:jr;E[V]>x[V]&&(Z=bm(Z));var z=bm(Z),Y=[];if(o&&Y.push(F[ce]<=0),a&&Y.push(F[Z]<=0,F[z]<=0),Y.every(function(be){return be})){H=oe,P=!1;break}D.set(oe,Y)}if(P)for(var K=m?3:1,se=function(Be){var Se=C.find(function(ut){var Ne=D.get(ut);if(Ne)return Ne.slice(0,Be).every(function(Qe){return Qe})});if(Se)return H=Se,"break"},pe=K;pe>0;pe--){var ge=se(pe);if(ge==="break")break}e.placement!==H&&(e.modifiersData[n]._skip=!0,e.placement=H,e.reset=!0)}}var NV,LV=b(()=>{DV();Iu();IV();my();OV();is();ym();NV={name:"flip",enabled:!0,phase:"main",fn:vJ,requiresIfExists:["offset"],data:{_skip:!1}}});function BV(r,e,t){return t===void 0&&(t={x:0,y:0}),{top:r.top-e.height-t.y,right:r.right-e.width+t.x,bottom:r.bottom-e.height+t.y,left:r.left-e.width-t.x}}function VV(r){return[jr,fn,Ln,nn].some(function(e){return r[e]>=0})}function yJ(r){var e=r.state,t=r.name,n=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=Ma(e,{elementContext:"reference"}),a=Ma(e,{altBoundary:!0}),l=BV(s,n),c=BV(a,i,o),u=VV(l),d=VV(c);e.modifiersData[t]={referenceClippingOffsets:l,popperEscapeOffsets:c,isReferenceHidden:u,hasPopperEscaped:d},e.attributes.popper=Object.assign({},e.attributes.popper,{"data-popper-reference-hidden":u,"data-popper-escaped":d})}var UV,qV=b(()=>{is();my();UV={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:yJ}});function bJ(r,e,t){var n=ri(r),i=[nn,jr].indexOf(n)>=0?-1:1,o=typeof t=="function"?t(Object.assign({},e,{placement:r})):t,s=o[0],a=o[1];return s=s||0,a=(a||0)*i,[nn,fn].indexOf(n)>=0?{x:a,y:s}:{x:s,y:a}}function wJ(r){var e=r.state,t=r.options,n=r.name,i=t.offset,o=i===void 0?[0,0]:i,s=l_.reduce(function(u,d){return u[d]=bJ(d,e.rects,o),u},{}),a=s[e.placement],l=a.x,c=a.y;e.modifiersData.popperOffsets!=null&&(e.modifiersData.popperOffsets.x+=l,e.modifiersData.popperOffsets.y+=c),e.modifiersData[n]=s}var WV,zV=b(()=>{Iu();is();WV={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:wJ}});function CJ(r){var e=r.state,t=r.name;e.modifiersData[t]=fy({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var HV,jV=b(()=>{gP();HV={name:"popperOffsets",enabled:!0,phase:"read",fn:CJ,data:{}}});function yP(r){return r==="x"?"y":"x"}var GV=b(()=>{});function xJ(r){var e=r.state,t=r.options,n=r.name,i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!1:s,l=t.boundary,c=t.rootBoundary,u=t.altBoundary,d=t.padding,f=t.tether,p=f===void 0?!0:f,m=t.tetherOffset,v=m===void 0?0:m,g=Ma(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),y=ri(e.placement),w=Hs(e.placement),k=!w,C=mp(y),E=yP(C),x=e.modifiersData.popperOffsets,D=e.rects.reference,P=e.rects.popper,H=typeof v=="function"?v(Object.assign({},e.rects,{placement:e.placement})):v,U=typeof H=="number"?{mainAxis:H,altAxis:H}:Object.assign({mainAxis:0,altAxis:0},H),oe=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,ce={x:0,y:0};if(x){if(o){var O,G=C==="y"?jr:nn,V=C==="y"?Ln:fn,F=C==="y"?"height":"width",Z=x[C],z=Z+g[G],Y=Z-g[V],K=p?-P[F]/2:0,se=w===bc?D[F]:P[F],pe=w===bc?-P[F]:-D[F],ge=e.elements.arrow,be=p&&ge?fp(ge):{width:0,height:0},Be=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:uy(),Se=Be[G],ut=Be[V],Ne=hp(0,D[F],be[F]),Qe=k?D[F]/2-K-Ne-Se-U.mainAxis:se-Ne-Se-U.mainAxis,Ze=k?-D[F]/2+K+Ne+ut+U.mainAxis:pe+Ne+ut+U.mainAxis,ye=e.elements.arrow&&Fa(e.elements.arrow),We=ye?C==="y"?ye.clientTop||0:ye.clientLeft||0:0,gt=(O=oe?.[C])!=null?O:0,He=Z+Qe-gt-We,Te=Z+Ze-gt,Ve=hp(p?pp(z,He):z,Z,p?Pa(Y,Te):Y);x[C]=Ve,ce[C]=Ve-Z}if(a){var dt,or=C==="x"?jr:nn,yr=C==="x"?Ln:fn,Ft=x[E],kr=E==="y"?"height":"width",ur=Ft+g[or],pt=Ft-g[yr],Mt=[jr,nn].indexOf(y)!==-1,jn=(dt=oe?.[E])!=null?dt:0,Eo=Mt?ur:Ft-D[kr]-P[kr]-jn+U.altAxis,Ts=Mt?Ft+D[kr]+P[kr]-jn-U.altAxis:pt,Gn=p&&Mt?CV(Eo,Ft,Ts):hp(p?Eo:ur,Ft,p?Ts:pt);x[E]=Gn,ce[E]=Gn-Ft}e.modifiersData[n]=ce}}var YV,KV=b(()=>{is();Iu();u_();GV();aP();c_();vm();my();ym();lP();Pu();YV={name:"preventOverflow",enabled:!0,phase:"main",fn:xJ,requiresIfExists:["offset"]}});var bP=b(()=>{});function wP(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}var QV=b(()=>{});function CP(r){return r===Rr(r)||!Bn(r)?gp(r):wP(r)}var XV=b(()=>{f_();Ia();os();QV()});function EJ(r){var e=r.getBoundingClientRect(),t=wc(e.width)/r.offsetWidth||1,n=wc(e.height)/r.offsetHeight||1;return t!==1||n!==1}function xP(r,e,t){t===void 0&&(t=!1);var n=Bn(e),i=Bn(e)&&EJ(e),o=bi(e),s=zs(r,i,t),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(n||!n&&!t)&&((ti(e)!=="body"||yp(o))&&(a=CP(e)),Bn(e)?(l=zs(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):o&&(l.x=vp(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}var ZV=b(()=>{hm();XV();Du();os();m_();Cc();h_();Pu()});function TJ(r){var e=new Map,t=new Set,n=[];r.forEach(function(o){e.set(o.name,o)});function i(o){t.add(o.name);var s=[].concat(o.requires||[],o.requiresIfExists||[]);s.forEach(function(a){if(!t.has(a)){var l=e.get(a);l&&i(l)}}),n.push(o)}return r.forEach(function(o){t.has(o.name)||i(o)}),n}function EP(r){var e=TJ(r);return gV.reduce(function(t,n){return t.concat(e.filter(function(i){return i.phase===n}))},[])}var JV=b(()=>{is()});function TP(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}var eU=b(()=>{});function _P(r){var e=r.reduce(function(t,n){var i=t[n.name];return t[n.name]=i?Object.assign({},i,n,{options:Object.assign({},i.options,n.options),data:Object.assign({},i.data,n.data)}):n,t},{});return Object.keys(e).map(function(t){return e[t]})}var tU=b(()=>{});function nU(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return!e.some(function(n){return!(n&&typeof n.getBoundingClientRect=="function")})}function iU(r){r===void 0&&(r={});var e=r,t=e.defaultModifiers,n=t===void 0?[]:t,i=e.defaultOptions,o=i===void 0?rU:i;return function(a,l,c){c===void 0&&(c=o);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},rU,o),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,p={state:u,setOptions:function(y){var w=typeof y=="function"?y(u.options):y;v(),u.options=Object.assign({},o,u.options,w),u.scrollParents={reference:Ws(a)?Fu(a):a.contextElement?Fu(a.contextElement):[],popper:Fu(l)};var k=EP(_P([].concat(n,u.options.modifiers)));return u.orderedModifiers=k.filter(function(C){return C.enabled}),m(),p.update()},forceUpdate:function(){if(!f){var y=u.elements,w=y.reference,k=y.popper;if(nU(w,k)){u.rects={reference:xP(w,Fa(k),u.options.strategy==="fixed"),popper:fp(k)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(U){return u.modifiersData[U.name]=Object.assign({},U.data)});for(var C=0;C<u.orderedModifiers.length;C++){if(u.reset===!0){u.reset=!1,C=-1;continue}var E=u.orderedModifiers[C],x=E.fn,D=E.options,P=D===void 0?{}:D,H=E.name;typeof x=="function"&&(u=x({state:u,options:P,name:H,instance:p})||u)}}}},update:TP(function(){return new Promise(function(g){p.forceUpdate(),g(u)})}),destroy:function(){v(),f=!0}};if(!nU(a,l))return p;p.setOptions(c).then(function(g){!f&&c.onFirstUpdate&&c.onFirstUpdate(g)});function m(){u.orderedModifiers.forEach(function(g){var y=g.name,w=g.options,k=w===void 0?{}:w,C=g.effect;if(typeof C=="function"){var E=C({state:u,name:y,instance:p,options:k}),x=function(){};d.push(E||x)}})}function v(){d.forEach(function(g){return g()}),d=[]}return p}}var rU,oU=b(()=>{ZV();c_();fP();vm();JV();eU();tU();os();rU={placement:"bottom",modifiers:[],strategy:"absolute"}});var _J,AP,sU=b(()=>{oU();SV();jV();AV();yV();zV();LV();KV();EV();qV();bP();_J=[kV,HV,_V,vV,WV,NV,YV,xV,UV],AP=iU({defaultModifiers:_J})});var aU=b(()=>{is();bP();sU()});function lU(r,e){return AJ.test(r[e])}function kJ(r){if(!r.includes("![["))return r;let e="",t=0,n=0,i=0;for(;n<r.length;){if(r.charCodeAt(n)===33&&r.charCodeAt(n+1)===91&&r.charCodeAt(n+2)===91){for(i<n+3&&(i=n+3);i<r.length&&r.charCodeAt(i)!==93;)i++;if(i<r.length&&r.charCodeAt(i+1)===93){e+=r.slice(t,n),n=i+2,t=n;continue}}n++}return e+r.slice(t)}function SJ(r){if(!r.includes("[["))return r;let e="",t=0,n=0,i=0,o=0;for(;n<r.length;){if(r.charCodeAt(n)===91&&r.charCodeAt(n+1)===91){for(i<n+2&&(i=n+2);i<r.length;){let s=r.charCodeAt(i);if(s===93||s===124)break;i++}if(i<r.length&&r.charCodeAt(i)===93){if(r.charCodeAt(i+1)===93){e+=r.slice(t,n)+r.slice(n+2,i),n=i+2,t=n;continue}}else if(i<r.length){for(o<i+1&&(o=i+1);o<r.length&&r.charCodeAt(o)!==93;)o++;if(o<r.length&&r.charCodeAt(o+1)===93){e+=r.slice(t,n)+r.slice(i+1,o),n=o+2,t=n;continue}}}n++}return e+r.slice(t)}function DJ(r){let e=0;if(r.charCodeAt(0)===35){for(;r.charCodeAt(e)===35;)e++;for(;e<r.length&&lU(r,e);)e++}let t=r.length;if(t>e&&r.charCodeAt(t-1)===35){for(;t>e&&r.charCodeAt(t-1)===35;)t--;for(;t>e&&lU(r,t-1);)t--}return r.slice(e,t)}function IJ(r){if(!r.includes("[[")&&!r.includes("]]"))return r;let e="",t=0,n=0;for(;n<r.length;){let i=r.charCodeAt(n);if(i===91&&r.charCodeAt(n+1)===91||i===93&&r.charCodeAt(n+1)===93){e+=r.slice(t,n),n+=2,t=n;continue}n++}return e+r.slice(t)}function kP(r){return IJ(DJ(SJ(kJ(r)).replace(PJ,""))).trim()}var AJ,PJ,cU=b(()=>{AJ=/^\s$/;PJ=/[*_`~]/g});function mn(r){return typeof r=="string"?r:r==null?"":String(r)}function v_(r,e){r.scope?.register(["Mod","Shift"],"Enter",()=>(e(),!1)),typeof r.setInstructions=="function"&&r.setInstructions([{command:"\u2191\u2193",purpose:"to navigate"},{command:"\u21B5",purpose:"to choose"},{command:"ctrl/cmd+shift+\u21B5",purpose:"to skip (leave empty)"},{command:"esc",purpose:"to cancel"}]);let t=r.modalEl;if(t&&typeof t.createDiv=="function"){let i=t.createDiv({cls:"qa-suggester-skip-bar"}).createEl("button",{text:"Skip (leave empty)",cls:"qa-suggester-skip-button"});i.type="button",i.setAttribute("aria-label","Skip and leave empty"),i.addEventListener("click",o=>{o.preventDefault(),e()})}}function bp(r){let e=!1;return t=>{e||(e=!0,M.logWarning(Zd(t,r)))}}function Ec(r){return mn(r)}function $r(r){return r.normalize("NFC").toLowerCase()}function hy(r){return r.toLowerCase().endsWith(".md")?r.slice(0,-3):r}function y_(r,e,t,n,i={}){let o=r.value;r.value=o.slice(0,e)+n+o.slice(t),r.setSelectionRange(e+n.length,e+n.length);let s=new Event("input",{bubbles:!0});i.fromCompletion&&(s.fromCompletion=!0),r.dispatchEvent(s)}function uU(r,e,t){if(r.replaceChildren(),!t){r.textContent=e;return}let n="",i=[],o=[],s=0;for(let d of e){let f=d.toLowerCase(),p=s,m=s+d.length;for(let v=0;v<f.length;v++)i.push(p),o.push(m);n+=f,s=m}let a="";for(let d of t)a+=d.toLowerCase();let l=0,c=0,u=n.indexOf(a,c);for(;u!==-1;){let d=Math.max(l,i[u]),f=o[u+a.length-1];if(f>d){d>l&&r.append(ty(r,e.slice(l,d)));let p=xr(r,"mark");p.className="qa-highlight",p.textContent=e.slice(d,f),r.append(p),l=f}c=u+a.length,u=n.indexOf(a,c)}l<e.length&&r.append(ty(r,e.slice(l)))}var Mo=b(()=>{Me();ka();Cr();cU()});var b_,FJ,SP,gy,hn,yl=b(()=>{aU();b_=require("obsidian");Me();ka();Mo();FJ=(r,e)=>(r%e+e)%e,SP=class{constructor(e,t,n){this.isOpen=!1;this.owner=e,this.containerEl=t,this.clickListener=i=>{let o=this.findSuggestionItem(i.target);o&&this.onSuggestionClick(i,o)},this.mousemoveListener=i=>{let o=this.findSuggestionItem(i.target);o&&this.onSuggestionMouseover(i,o)},t.addEventListener("click",this.clickListener),t.addEventListener("mousemove",this.mousemoveListener),n.register([],"ArrowUp",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(this.selectedItem-1,!0),!1}),n.register([],"ArrowDown",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(this.selectedItem+1,!0),!1}),n.register([],"Enter",i=>{if(!i.isComposing&&this.isOpen)return this.useSelectedItem(i),!1}),n.register([],"PageUp",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(Math.max(0,this.selectedItem-5),!0),!1}),n.register([],"PageDown",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(Math.min(this.suggestions.length-1,this.selectedItem+5),!0),!1})}findSuggestionItem(e){let t=this.containerEl.ownerDocument.defaultView;if(!t||!(e instanceof t.Element))return null;let n=e.closest(".suggestion-item");return n&&this.containerEl.contains(n)?n:null}onSuggestionClick(e,t){e.preventDefault();let n=this.suggestions.indexOf(t);this.setSelectedItem(n,!1),this.useSelectedItem(e)}onSuggestionMouseover(e,t){let n=this.suggestions.indexOf(t);this.setSelectedItem(n,!1)}setSuggestions(e){this.containerEl.replaceChildren();let t=[];e.forEach((n,i)=>{let o=this.containerEl.ownerDocument.createElement("div");o.classList.add("suggestion-item"),this.containerEl.appendChild(o),o.setAttribute("role","option"),o.setAttribute("aria-selected","false"),o.setAttribute("id",`suggestion-${i}`),this.owner.renderSuggestion(n,o),t.push(o)}),this.values=e,this.suggestions=t,this.setSelectedItem(0,!1),this.isOpen=e.length>0}useSelectedItem(e){let t=this.values[this.selectedItem];t&&this.owner.selectSuggestion(t,e)}setSelectedItem(e,t){if(!this.suggestions?.length)return;let n=FJ(e,this.suggestions.length),i=this.suggestions[this.selectedItem],o=this.suggestions[n];i?.classList.remove("is-selected"),o?.classList.add("is-selected"),i?.setAttribute("aria-selected","false"),o?.setAttribute("aria-selected","true"),this.selectedItem=n,t&&o.scrollIntoView(!1)}close(){this.isOpen=!1}getIsOpen(){return this.isOpen}},gy=new WeakMap,hn=class{constructor(e,t){this.popper=null;this.currentRequestId=0;this.isOpen=!1;this.destroyed=!1;this.noResultsTimeout=null;this.currentQuery="";this.renderMatch=uU;let n=this.constructor.name,i=gy.get(t);i||(i=new Map,gy.set(t,i));let o=i.get(n);o&&o.destroy(),gy.set(t,i),i.set(n,this),this.app=e,this.inputEl=t,this.scope=new b_.Scope,this.suggestEl=this.inputEl.ownerDocument.createElement("div"),this.suggestEl.classList.add("suggestion-container");let s=this.inputEl.ownerDocument.createElement("div");s.classList.add("suggestion"),this.suggestEl.appendChild(s),s.setAttribute("role","listbox"),s.setAttribute("aria-label","Suggestions"),this.suggest=new SP(this,s,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.debouncedOnInputChanged=(0,b_.debounce)(this.onInputChanged.bind(this),50),this.inputEventListener=a=>this.debouncedOnInputChanged(a),this.focusEventListener=()=>this.debouncedOnInputChanged(),this.inputBlurListener=this.close.bind(this),this.inputEl.addEventListener("input",this.inputEventListener),this.inputEl.addEventListener("focus",this.focusEventListener),this.inputEl.addEventListener("blur",this.inputBlurListener),this.inputEl.setAttribute("aria-autocomplete","list"),this.inputEl.setAttribute("aria-expanded","false"),this.suggestEl.addEventListener("mousedown",a=>{a.preventDefault()}),this.globalClickListener=this.onGlobalClick.bind(this),this.globalWheelListener=this.onGlobalWheel.bind(this),this.globalResizeListener=this.close.bind(this),this.globalBlurListener=this.close.bind(this)}onGlobalClick(e){if(!this.isOpen)return;let t=e.target;!this.suggestEl.contains(t)&&!this.inputEl.contains(t)&&this.close()}onGlobalWheel(e){if(!this.isOpen)return;let t=e.target;this.suggestEl.contains(t)||this.close()}async onInputChanged(e){if(this.destroyed)return;let t=e;if(t?.fromCompletion&&t.keepOpen){let o=this.inputEl.value,s=++this.currentRequestId;this.currentQuery=o;try{let a=await this.getSuggestions(o);s===this.currentRequestId&&(a?.length?(this.suggest.setSuggestions(a),this.isOpen||this.open(this.app.dom.appContainerEl,this.inputEl)):this.close())}catch(a){M.logError(a)}return}if(t?.fromCompletion)return;let n=this.inputEl.value,i=++this.currentRequestId;this.currentQuery=n;try{let o=await this.getSuggestions(n);if(i!==this.currentRequestId)return;if(!o||o.length===0){this.isOpen&&this.showNoResultsAndClose();return}this.suggest.setSuggestions(o),this.open(this.app.dom.appContainerEl,this.inputEl)}catch(o){M.logError(o),this.close()}}showNoResultsAndClose(){this.noResultsTimeout&&op(this.inputEl).clearTimeout(this.noResultsTimeout),this.close()}open(e,t){if(this.destroyed)return;this.isOpen||this.app.keymap.pushScope(this.scope),this.isOpen=!0,this.inputEl.setAttribute("aria-expanded","true");let n=rs(t);if((rs(e)===n?e:n.body).appendChild(this.suggestEl),this.popper){this.popper.update();return}this.popper=AP(t,this.suggestEl,{placement:"bottom-start",modifiers:[{name:"sameWidth",enabled:!0,fn:({state:l,instance:c})=>{let u=`${l.rects.reference.width}px`;l.styles.popper.width!==u&&(l.styles.popper.width=u,c.update())},phase:"beforeWrite",requires:["computeStyles"]},{name:"flip",enabled:!0},{name:"preventOverflow",enabled:!0},{name:"offset",enabled:!0,options:{offset:[0,4]}}]});let s=n,a=op(t);s.addEventListener("pointerdown",this.globalClickListener,!0),s.addEventListener("wheel",this.globalWheelListener,!0),a.addEventListener("resize",this.globalResizeListener),a.addEventListener("blur",this.globalBlurListener)}close(){if(!this.isOpen)return;this.app.keymap.popScope(this.scope),this.isOpen=!1,this.inputEl.setAttribute("aria-expanded","false"),this.suggest.close(),this.suggest.setSuggestions([]),this.popper&&(this.popper.destroy(),this.popper=null),this.suggestEl.remove(),this.noResultsTimeout&&(op(this.inputEl).clearTimeout(this.noResultsTimeout),this.noResultsTimeout=null);let e=rs(this.inputEl),t=op(this.inputEl);e.removeEventListener("pointerdown",this.globalClickListener,!0),e.removeEventListener("wheel",this.globalWheelListener,!0),t.removeEventListener("resize",this.globalResizeListener),t.removeEventListener("blur",this.globalBlurListener)}destroy(){this.destroyed=!0,this.close(),this.inputEl.removeEventListener("input",this.inputEventListener),this.inputEl.removeEventListener("focus",this.focusEventListener),this.inputEl.removeEventListener("blur",this.inputBlurListener);let e=this.constructor.name,t=gy.get(this.inputEl);t&&(t.delete(e),t.size===0&&gy.delete(this.inputEl))}getCurrentQuery(){return this.currentQuery}}});function dU(r,e=0){return(wi[r[e+0]]+wi[r[e+1]]+wi[r[e+2]]+wi[r[e+3]]+"-"+wi[r[e+4]]+wi[r[e+5]]+"-"+wi[r[e+6]]+wi[r[e+7]]+"-"+wi[r[e+8]]+wi[r[e+9]]+"-"+wi[r[e+10]]+wi[r[e+11]]+wi[r[e+12]]+wi[r[e+13]]+wi[r[e+14]]+wi[r[e+15]]).toLowerCase()}var wi,pU=b(()=>{wi=[];for(let r=0;r<256;++r)wi.push((r+256).toString(16).slice(1))});function DP(){return crypto.getRandomValues(MJ)}var MJ,fU=b(()=>{MJ=new Uint8Array(16)});function RJ(r,e,t){return!e&&!r&&crypto.randomUUID?crypto.randomUUID():$J(r,e,t)}function $J(r,e,t){r=r||{};let n=r.random??r.rng?.()??DP();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=n[i];return e}return dU(n)}var Er,mU=b(()=>{fU();pU();Er=RJ});var bl=b(()=>{mU()});function w_(r){return Ye(r)&&r.type==="Multi"}function Ye(r){return typeof r=="object"&&r!==null}function st(r){return w_(r)?Array.isArray(r.choices)?r.choices:[]:[]}function Tc(r){return w_(r)&&Array.isArray(r.choices)}function Cm(r){if(!Array.isArray(r))return!0;let e=t=>t.some(n=>{if(Array.isArray(n))return!0;if(!Ye(n)||n.type!=="Multi")return!1;let i=n.choices;return Array.isArray(i)?e(i):C_(i)});return e(r)}function gn(r){return Array.isArray(r)?r:[]}function C_(r){return Array.isArray(r)||r==null?!1:typeof r=="object"?Object.keys(r).length>0:!!r}function js(r){return w_(r)?C_(r.choices):!1}function xm(r){switch(r){case"Template":return"file-text";case"Capture":return"pencil";case"Macro":return"terminal";case"Multi":return"folder";default:return"file-plus"}}function Em(r){return(typeof r.icon=="string"?r.icon.trim():"")||xm(r.type)}function Vn(r){let e=[],t=n=>{Ye(n)&&(e.push(n),st(n).forEach(t))};return gn(r).forEach(t),e}function hU(r){let e=new Map,t=n=>{let i=[];for(let o of n){if(!Ye(o)){i.push(o);continue}let s=o,a=e.get(s.id);if(a){if(JSON.stringify(s)===JSON.stringify(a))continue;s={...s,id:Er()}}e.set(s.id,s),w_(s)&&Array.isArray(s.choices)&&(s={...s,choices:t(s.choices)}),i.push(s)}return i};return t(r)}function gU(r){if(!Array.isArray(r))return{choices:[],changed:!1,repaired:[]};let e=new Set,t=[],n=o=>{let s=!1,a=[];for(let l of o){if(Array.isArray(l)){s=!0,a.push(...n(l));continue}if(!Ye(l)){s=!0;continue}let c=l;if(Tc(c)){let f=c.choices,p=n(f);p!==f&&(c={...c,choices:p},s=!0)}let u=c.id;if(typeof u=="string"&&u!==""&&!e.has(u)){e.add(u),a.push(c);continue}let d={...c,id:Er()};e.add(d.id),t.push({previousId:u,choice:d}),a.push(d),s=!0}return s?a:o},i=n(r);return{choices:i,changed:i!==r,repaired:t}}function vy(r,e=[],t=0,n=null){let i=[];for(let o of gn(r)){if(!Ye(o))continue;let s=[...e,o.name];i.push({choice:o,id:o.id,path:s,depth:t,parentId:n}),i.push(...vy(st(o),s,t+1,o.id))}return i}var Wt=b(()=>{bl()});function Mu(r){return Array.isArray?Array.isArray(r):SU(r)==="[object Array]"}function QJ(r){if(typeof r=="string")return r;if(typeof r=="bigint")return r.toString();let e=r+"";return e=="0"&&1/r==-1/0?"-0":e}function PP(r){return r==null?"":QJ(r)}function Gi(r){return typeof r=="string"}function E_(r){return typeof r=="number"}function XJ(r){return r===!0||r===!1||ZJ(r)&&SU(r)=="[object Boolean]"}function kU(r){return typeof r=="object"}function ZJ(r){return kU(r)&&r!==null}function ss(r){return r!=null}function x_(r){return!r.trim().length}function SU(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}function DU(r){let e=null,t=null,n=null,i=1,o=null;if(Gi(r)||Mu(r))n=r,e=CU(r),t=T_(r);else{if(!wU.call(r,"name"))throw new Error(ree("name"));let s=r.name;if(n=s,wU.call(r,"weight")&&r.weight!==void 0&&(i=r.weight,i<=0))throw new Error(nee(T_(s)));e=CU(s),t=T_(s),o=r.getFn??null}return{path:e,id:t,weight:i,src:n,getFn:o}}function CU(r){return Mu(r)?r:r.split(".")}function T_(r){return Mu(r)?r.join("."):r}function see(r,e){let t=[],n=!1,i=(o,s,a,l)=>{if(ss(o))if(!s[a])t.push(l!==void 0?{v:o,i:l}:o);else{let c=o[s[a]];if(!ss(c))return;if(a===s.length-1&&(Gi(c)||E_(c)||XJ(c)||typeof c=="bigint"))t.push(l!==void 0?{v:PP(c),i:l}:PP(c));else if(Mu(c)){n=!0;for(let u=0,d=c.length;u<d;u+=1)i(c[u],s,a+1,u)}else s.length&&i(c,s,a+1,l)}};return i(r,Gi(e)?e.split("."):e,0),n?t:t[0]}function dee(r){return r>=9&&r<=13||r===32||r===160}function pee(r=1,e=3){let t=new Map,n=Math.pow(10,e);return{get(i){let o=0,s=!1;for(let l=0;l<i.length;l++)dee(i.charCodeAt(l))?s=!1:s||(o++,s=!0);if(o===0&&(o=1),t.has(o))return t.get(o);let a=Math.round(n/Math.pow(o,.5*r))/n;return t.set(o,a),a},clear(){t.clear()}}}function IU(r,e,{getFn:t=rt.getFn,fieldNormWeight:n=rt.fieldNormWeight}={}){let i=new BP({getFn:t,fieldNormWeight:n});return i.setKeys(r.map(DU)),i.setSources(e),i.create(),i}function fee(r,{getFn:e=rt.getFn,fieldNormWeight:t=rt.fieldNormWeight}={}){let{keys:n,records:i}=r,o=new BP({getFn:e,fieldNormWeight:t});return o.setKeys(n),o.setIndexRecords(i),o}function mee(r=[],e=rt.minMatchCharLength){let t=[],n=-1,i=-1,o=0;for(let s=r.length;o<s;o+=1){let a=r[o];a&&n===-1?n=o:!a&&n!==-1&&(i=o-1,i-n+1>=e&&t.push([n,i]),n=-1)}return r[o-1]&&o-n>=e&&t.push([n,o-1]),t}function hee(r,e,t,{location:n=rt.location,distance:i=rt.distance,threshold:o=rt.threshold,findAllMatches:s=rt.findAllMatches,minMatchCharLength:a=rt.minMatchCharLength,includeMatches:l=rt.includeMatches,ignoreLocation:c=rt.ignoreLocation}={}){if(e.length>32)throw new Error(tee(32));let u=e.length,d=r.length,f=Math.max(0,Math.min(n,d)),p=o,m=f,v=(H,U)=>{let oe=H/u;if(c)return oe;let ce=Math.abs(f-U);return i?oe+ce/i:ce?1:oe},g=a>1||l,y=g?Array(d):[],w;for(;(w=r.indexOf(e,m))>-1;){let H=v(0,w);if(p=Math.min(H,p),m=w+u,g){let U=0;for(;U<u;)y[w+U]=1,U+=1}}m=-1;let k=[],C=1,E=0,x=u+d,D=1<<u-1;for(let H=0;H<u;H+=1){let U=0,oe=x;for(;U<oe;)v(H,f+oe)<=p?U=oe:x=oe,oe=Math.floor((x-U)/2+U);x=oe;let ce=Math.max(1,f-oe+1),O=s?d:Math.min(f+oe,d)+u,G=Array(O+2);G[O+1]=(1<<H)-1;for(let V=O;V>=ce;V-=1){let F=V-1,Z=t[r[F]];if(G[V]=(G[V+1]<<1|1)&Z,H&&(G[V]|=(k[V+1]|k[V])<<1|1|k[V+1]),G[V]&D&&(C=v(H,F),C<=p)){if(p=C,m=F,E=H,m<=f)break;ce=Math.max(1,2*f-m)}}if(v(H+1,f)>p)break;k=G}if(g&&m>=0){let H=Math.min(d-1,m+u-1+E);for(let U=m;U<=H;U+=1)t[r[U]]&&(y[U]=1)}let P={isMatch:m>=0,score:Math.max(.001,C)};if(g){let H=mee(y,a);H.length?l&&(P.indices=H):P.isMatch=!1}return P}function gee(r){let e={};for(let t=0,n=r.length;t<n;t+=1){let i=r.charAt(t);e[i]=(e[i]||0)|1<<n-t-1}return e}function VP(r){if(r.length<=1)return r;r.sort((t,n)=>t[0]-n[0]||t[1]-n[1]);let e=[r[0]];for(let t=1,n=r.length;t<n;t+=1){let i=e[e.length-1],o=r[t];o[0]<=i[1]+1?i[1]=Math.max(i[1],o[1]):e.push(o)}return e}function bee(r){return r.startsWith("inverse")}function xee(r){let e=[],t=r.length,n=0;for(;n<t;){for(;n<t&&r[n]===" ";)n++;if(n>=t)break;let i=n;for(;i<t&&r[i]!==" "&&r[i]!=='"';)i++;if(i<t&&r[i]==='"'){for(i++;i<t;){if(r[i]==='"'){let o=i+1;if(o>=t||r[o]===" "){i++;break}if(r[o]==="$"&&(o+1>=t||r[o+1]===" ")){i+=2;break}}i++}e.push(r.substring(n,i)),n=i}else{for(;i<t&&r[i]!==" ";)i++;e.push(r.substring(n,i)),n=i}}return e}function EU(r,e){let t=r.match(e);return t?t[1]:null}function Eee(r,e={}){return r.replace(/\\\|/g,wee).split(Cee).map(t=>{let n=xee(t.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),i=[];for(let o=0,s=n.length;o<s;o+=1){let a=n[o],l=!1,c=-1;for(;!l&&++c<xU;){let u=MP[c],d=EU(a,u.multiRegex);d&&(i.push(u.create(d,e)),l=!0)}if(!l)for(c=-1;++c<xU;){let u=MP[c],d=EU(a,u.singleRegex);if(d){i.push(u.create(d,e));break}}}return i})}function qP(...r){RP.push(...r)}function __(r,e){for(let t=0,n=RP.length;t<n;t+=1){let i=RP[t];if(i.condition(r,e))return new i(r,e)}return new UP(r,e)}function FU(r,e,{auto:t=!0}={}){let n=i=>{if(Gi(i)){let l={keyId:null,pattern:i};return t&&(l.searcher=__(i,e)),l}let o=Object.keys(i),s=_ee(i);if(!s&&o.length>1&&!OP(i))return n(TU(i));if(Aee(i)){let l=s?i[$P.PATH]:o[0],c=s?i[$P.PATTERN]:i[l];if(!Gi(c))throw new Error(eee(l));let u={keyId:T_(l),pattern:c};return t&&(u.searcher=__(c,e)),u}let a={children:[],operator:o[0]};return o.forEach(l=>{let c=i[l];Mu(c)&&c.forEach(u=>{a.children.push(n(u))})}),a};return OP(r)||(r=TU(r)),n(r)}function NP(r,{ignoreFieldNorm:e=rt.ignoreFieldNorm}){let t=1;return r.forEach(({key:n,norm:i,score:o})=>{let s=n?n.weight:null;t*=Math.pow(o===0&&s?Number.EPSILON:o,(s||1)*(e?1:i))}),t}function kee(r,{ignoreFieldNorm:e=rt.ignoreFieldNorm}){r.forEach(t=>{t.score=NP(t.matches,{ignoreFieldNorm:e})})}function Dee(r){let e=[];return r.matches.forEach(t=>{if(!ss(t.indices)||!t.indices.length)return;let n={indices:t.indices,value:t.value};t.key&&(n.key=t.key.id),t.idx>-1&&(n.refIndex=t.idx),e.push(n)}),e}function Iee(r,e,{includeMatches:t=rt.includeMatches,includeScore:n=rt.includeScore}={}){return r.map(i=>{let{idx:o}=i,s={item:e[o],refIndex:o};return t&&(s.matches=Dee(i)),n&&(s.score=i.score),s})}function Fee(r){_U.has(r)||(_U.add(r),console.warn(`[Fuse] tokenize regex ${r} lacks the global flag; only the first match per text will be returned. Add the 'g' flag.`))}function Mee(r){if(typeof r=="function"){let e=!1;return t=>{let n=r(t);if(!e&&(e=!0,!Array.isArray(n)||n.some(i=>typeof i!="string")))throw new Error(`[Fuse] tokenize function must return string[]; received ${Array.isArray(n)?"array containing non-strings":typeof n}.`);return n}}return r instanceof RegExp?(r.global||Fee(r),e=>e.match(r)||[]):e=>e.match(Pee)||[]}function LP({isCaseSensitive:r=!1,ignoreDiacritics:e=!1,tokenize:t}={}){let n=Mee(t);return{tokenize(i){return r||(i=i.toLowerCase()),e&&(i=yy(i)),n(i)}}}function IP(r,e,t,n){let i=n.tokenize(e);if(!i.length)return;r.fieldCount++,r.docFieldCount.set(t,(r.docFieldCount.get(t)||0)+1);let o=new Set(i),s=r.docTermFieldHits.get(t);s||(s=new Map,r.docTermFieldHits.set(t,s));for(let a of o)s.set(a,(s.get(a)||0)+1),r.df.set(a,(r.df.get(a)||0)+1)}function MU(r,e,t,n){let{i,v:o,$:s}=e;if(o!==void 0){IP(r,o,i,n);return}if(s)for(let a=0;a<t;a++){let l=s[a];if(l)if(Array.isArray(l))for(let c of l)IP(r,c.v,i,n);else IP(r,l.v,i,n)}}function $ee(r,e,t){let n={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of r)MU(n,i,e,t);return n}function Oee(r,e,t,n){MU(r,e,t,n)}function Nee(r,e){let t=r.docFieldCount.get(e);if(t===void 0)return;r.fieldCount-=t,r.docFieldCount.delete(e);let n=r.docTermFieldHits.get(e);if(n){for(let[i,o]of n){let s=(r.df.get(i)||0)-o;s<=0?r.df.delete(i):r.df.set(i,s)}r.docTermFieldHits.delete(e)}}function AU(r,e){if(e.length===0)return;let t=Array.from(new Set(e)).sort((a,l)=>a-l);for(let a of t)Nee(r,a);let n=a=>{let l=0,c=t.length;for(;l<c;){let u=l+c>>>1;t[u]<a?l=u+1:c=u}return a-l},i=t[0],o=new Map;for(let[a,l]of r.docFieldCount)o.set(a>i?n(a):a,l);r.docFieldCount=o;let s=new Map;for(let[a,l]of r.docTermFieldHits)s.set(a>i?n(a):a,l);r.docTermFieldHits=s}var JJ,FP,eee,tee,ree,nee,iee,wU,oee,aee,lee,cee,uee,rt,BP,PU,vee,yy,UP,yee,MP,xU,wee,Cee,Tee,RP,A_,$P,OP,_ee,Aee,TU,See,Pee,_U,Ree,Ru,$u,k_=b(()=>{JJ="Incorrect 'index' type",FP="Invalid doc index: must be a non-negative integer within the bounds of the docs array",eee=r=>`Invalid value for key ${r}`,tee=r=>`Pattern length exceeds max of ${r}.`,ree=r=>`Missing ${r} property in key`,nee=r=>`Property 'weight' in key '${r}' must be a positive integer`,iee="Fuse.match does not support useTokenSearch: token search requires corpus-level statistics (df, fieldCount) that a one-off string comparison does not have. Use new Fuse(...).search(...) instead.",wU=Object.prototype.hasOwnProperty,oee=class{constructor(r){this._keys=[],this._keyMap={};let e=0;r.forEach(t=>{let n=DU(t);this._keys.push(n),this._keyMap[n.id]=n,e+=n.weight}),this._keys.forEach(t=>{t.weight/=e})}get(r){return this._keyMap[r]}keys(){return this._keys}toJSON(){return JSON.stringify(this._keys)}};aee={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},lee={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,e)=>r.score===e.score?r.idx<e.idx?-1:1:r.score<e.score?-1:1},cee={location:0,threshold:.6,distance:100},uee={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:see,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},rt=Object.freeze({...lee,...aee,...cee,...uee});BP=class{constructor({getFn:r=rt.getFn,fieldNormWeight:e=rt.fieldNormWeight}={}){this.norm=pee(e,3),this.getFn=r,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let r=this.docs.length;this.records=new Array(r);let e=0;if(Gi(this.docs[0]))for(let t=0;t<r;t++){let n=this._createStringRecord(this.docs[t],t);n&&(this.records[e++]=n)}else for(let t=0;t<r;t++)this.records[e++]=this._createObjectRecord(this.docs[t],t);this.records.length=e,this.norm.clear()}add(r,e){if(!Number.isInteger(e)||e<0)throw new Error(FP);if(Gi(r)){let n=this._createStringRecord(r,e);return n&&this.records.push(n),n}let t=this._createObjectRecord(r,e);return this.records.push(t),t}removeAt(r){if(!Number.isInteger(r)||r<0)throw new Error(FP);for(let e=0,t=this.records.length;e<t;e+=1)if(this.records[e].i===r){this.records.splice(e,1);break}for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i>r&&(this.records[e].i-=1)}removeAll(r){let e=new Set;for(let n of r)Number.isInteger(n)&&n>=0&&e.add(n);if(e.size===0)return;this.records=this.records.filter(n=>!e.has(n.i));let t=Array.from(e).sort((n,i)=>n-i);for(let n of this.records){let i=0,o=t.length;for(;i<o;){let s=i+o>>>1;t[s]<n.i?i=s+1:o=s}n.i-=i}}getValueForItemAtKeyId(r,e){return r[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(r,e){return!ss(r)||x_(r)?null:{v:r,i:e,n:this.norm.get(r)}}_createObjectRecord(r,e){let t={i:e,$:{}};for(let n=0,i=this.keys.length;n<i;n++){let o=this.keys[n],s=o.getFn?o.getFn(r):this.getFn(r,o.path);if(ss(s)){if(Mu(s)){let a=[];for(let l=0,c=s.length;l<c;l+=1){let u=s[l];if(ss(u)){if(Gi(u)){if(!x_(u)){let d={v:u,i:l,n:this.norm.get(u)};a.push(d)}}else if(ss(u.v)){let d=Gi(u.v)?u.v:PP(u.v);if(!x_(d)){let f={v:d,i:u.i,n:this.norm.get(d)};a.push(f)}}}}t.$[n]=a}else if(Gi(s)&&!x_(s)){let a={v:s,n:this.norm.get(s)};t.$[n]=a}}}return t}toJSON(){return{keys:this.keys.map(({getFn:r,...e})=>e),records:this.records}}};PU={\u0142:"l",\u0141:"L",\u0111:"d",\u0110:"D",\u00F8:"o",\u00D8:"O",\u0127:"h",\u0126:"H",\u0167:"t",\u0166:"T",\u0131:"i",\u00DF:"ss"},vee=new RegExp("["+Object.keys(PU).join("")+"]","g"),yy=typeof String.prototype.normalize=="function"?r=>r.normalize("NFD").replace(/[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u08D3-\u08E1\u08E3-\u0903\u093A-\u093C\u093E-\u094F\u0951-\u0957\u0962\u0963\u0981-\u0983\u09BC\u09BE-\u09C4\u09C7\u09C8\u09CB-\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01-\u0A03\u0A3C\u0A3E-\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81-\u0A83\u0ABC\u0ABE-\u0AC5\u0AC7-\u0AC9\u0ACB-\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01-\u0B03\u0B3C\u0B3E-\u0B44\u0B47\u0B48\u0B4B-\u0B4D\u0B56\u0B57\u0B62\u0B63\u0B82\u0BBE-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCD\u0BD7\u0C00-\u0C04\u0C3E-\u0C44\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81-\u0C83\u0CBC\u0CBE-\u0CC4\u0CC6-\u0CC8\u0CCA-\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00-\u0D03\u0D3B\u0D3C\u0D3E-\u0D44\u0D46-\u0D48\u0D4A-\u0D4D\u0D57\u0D62\u0D63\u0D82\u0D83\u0DCA\u0DCF-\u0DD4\u0DD6\u0DD8-\u0DDF\u0DF2\u0DF3\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EB9\u0EBB\u0EBC\u0EC8-\u0ECD\u0F18\u0F19\u0F35\u0F37\u0F39\u0F3E\u0F3F\u0F71-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102B-\u103E\u1056-\u1059\u105E-\u1060\u1062-\u1064\u1067-\u106D\u1071-\u1074\u1082-\u108D\u108F\u109A-\u109D\u135D-\u135F\u1712-\u1714\u1732-\u1734\u1752\u1753\u1772\u1773\u17B4-\u17D3\u17DD\u180B-\u180D\u1885\u1886\u18A9\u1920-\u192B\u1930-\u193B\u1A17-\u1A1B\u1A55-\u1A5E\u1A60-\u1A7C\u1A7F\u1AB0-\u1ABE\u1B00-\u1B04\u1B34-\u1B44\u1B6B-\u1B73\u1B80-\u1B82\u1BA1-\u1BAD\u1BE6-\u1BF3\u1C24-\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE8\u1CED\u1CF2-\u1CF4\u1CF7-\u1CF9\u1DC0-\u1DF9\u1DFB-\u1DFF\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA823-\uA827\uA880\uA881\uA8B4-\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA953\uA980-\uA983\uA9B3-\uA9C0\uA9E5\uAA29-\uAA36\uAA43\uAA4C\uAA4D\uAA7B-\uAA7D\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEB-\uAAEF\uAAF5\uAAF6\uABE3-\uABEA\uABEC\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F]/g,"").replace(vee,e=>PU[e]):r=>r,UP=class{constructor(r,{location:e=rt.location,threshold:t=rt.threshold,distance:n=rt.distance,includeMatches:i=rt.includeMatches,findAllMatches:o=rt.findAllMatches,minMatchCharLength:s=rt.minMatchCharLength,isCaseSensitive:a=rt.isCaseSensitive,ignoreDiacritics:l=rt.ignoreDiacritics,ignoreLocation:c=rt.ignoreLocation}={}){if(this.options={location:e,threshold:t,distance:n,includeMatches:i,findAllMatches:o,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c},r=a?r:r.toLowerCase(),r=l?yy(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;let u=(f,p)=>{this.chunks.push({pattern:f,alphabet:gee(f),startIndex:p})},d=this.pattern.length;if(d>32){let f=0,p=d%32,m=d-p;for(;f<m;)u(this.pattern.substr(f,32),f),f+=32;if(p){let v=d-32;u(this.pattern.substr(v),v)}}else u(this.pattern,0)}searchIn(r){let{isCaseSensitive:e,ignoreDiacritics:t,includeMatches:n}=this.options;if(r=e?r:r.toLowerCase(),r=t?yy(r):r,this.pattern===r){if(r.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};let m={isMatch:!0,score:0};return n&&(m.indices=[[0,r.length-1]]),m}let{location:i,distance:o,threshold:s,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:m,alphabet:v,startIndex:g})=>{let{isMatch:y,score:w,indices:k}=hee(r,m,v,{location:i+g,distance:o,threshold:s,findAllMatches:a,minMatchCharLength:l,includeMatches:n,ignoreLocation:c});y&&(f=!0),d+=w,y&&k&&u.push(...k)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&n&&(p.indices=VP(u)),p}},yee=new Set(["fuzzy","include"]);MP=[{type:"exact",multiRegex:/^="(.*)"$/,singleRegex:/^=(.*)$/,create:r=>({type:"exact",search(e){let t=e===r;return{isMatch:t,score:t?0:1,indices:[0,r.length-1]}}})},{type:"include",multiRegex:/^'"(.*)"$/,singleRegex:/^'(.*)$/,create:r=>({type:"include",search(e){let t=0,n,i=[],o=r.length;for(;(n=e.indexOf(r,t))>-1;)t=n+o,i.push([n,t-1]);let s=!!i.length;return{isMatch:s,score:s?0:1,indices:i}}})},{type:"prefix-exact",multiRegex:/^\^"(.*)"$/,singleRegex:/^\^(.*)$/,create:r=>({type:"prefix-exact",search(e){let t=e.startsWith(r);return{isMatch:t,score:t?0:1,indices:[0,r.length-1]}}})},{type:"inverse-prefix-exact",multiRegex:/^!\^"(.*)"$/,singleRegex:/^!\^(.*)$/,create:r=>({type:"inverse-prefix-exact",search(e){let t=!e.startsWith(r);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}})},{type:"inverse-suffix-exact",multiRegex:/^!"(.*)"\$$/,singleRegex:/^!(.*)\$$/,create:r=>({type:"inverse-suffix-exact",search(e){let t=!e.endsWith(r);return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}})},{type:"suffix-exact",multiRegex:/^"(.*)"\$$/,singleRegex:/^(.*)\$$/,create:r=>({type:"suffix-exact",search(e){let t=e.endsWith(r);return{isMatch:t,score:t?0:1,indices:[e.length-r.length,e.length-1]}}})},{type:"inverse-exact",multiRegex:/^!"(.*)"$/,singleRegex:/^!(.*)$/,create:r=>({type:"inverse-exact",search(e){let t=e.indexOf(r)===-1;return{isMatch:t,score:t?0:1,indices:[0,e.length-1]}}})},{type:"fuzzy",multiRegex:/^"(.*)"$/,singleRegex:/^(.*)$/,create:(r,e={})=>{let t=new UP(r,{location:e.location??rt.location,threshold:e.threshold??rt.threshold,distance:e.distance??rt.distance,includeMatches:e.includeMatches??rt.includeMatches,findAllMatches:e.findAllMatches??rt.findAllMatches,minMatchCharLength:e.minMatchCharLength??rt.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??rt.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??rt.ignoreDiacritics,ignoreLocation:e.ignoreLocation??rt.ignoreLocation});return{type:"fuzzy",search(n){return t.searchIn(n)}}}}],xU=MP.length,wee="\0",Cee="|";Tee=class{constructor(r,{isCaseSensitive:e=rt.isCaseSensitive,ignoreDiacritics:t=rt.ignoreDiacritics,includeMatches:n=rt.includeMatches,minMatchCharLength:i=rt.minMatchCharLength,ignoreLocation:o=rt.ignoreLocation,findAllMatches:s=rt.findAllMatches,location:a=rt.location,threshold:l=rt.threshold,distance:c=rt.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:t,includeMatches:n,minMatchCharLength:i,findAllMatches:s,ignoreLocation:o,location:a,threshold:l,distance:c},r=e?r:r.toLowerCase(),r=t?yy(r):r,this.pattern=r,this.query=Eee(this.pattern,this.options)}static condition(r,e){return e.useExtendedSearch}searchIn(r){let e=this.query;if(!e)return{isMatch:!1,score:1};let{includeMatches:t,isCaseSensitive:n,ignoreDiacritics:i}=this.options;r=n?r:r.toLowerCase(),r=i?yy(r):r;let o=0,s=[],a=0,l=!1;for(let c=0,u=e.length;c<u;c+=1){let d=e[c];s.length=0,o=0,l=!1;for(let f=0,p=d.length;f<p;f+=1){let m=d[f],{isMatch:v,indices:g,score:y}=m.search(r);if(v)o+=1,a+=y,bee(m.type)&&(l=!0),t&&(yee.has(m.type)?s.push(...g):s.push(g));else{a=0,o=0,s.length=0,l=!1;break}}if(o){let f={isMatch:!0,score:a/o};return l&&(f.hasInverse=!0),t&&(f.indices=VP(s)),f}}return{isMatch:!1,score:1}}},RP=[];A_={AND:"$and",OR:"$or"},$P={PATH:"$path",PATTERN:"$val"},OP=r=>!!(r[A_.AND]||r[A_.OR]),_ee=r=>!!r[$P.PATH],Aee=r=>!Mu(r)&&kU(r)&&!OP(r),TU=r=>({[A_.AND]:Object.keys(r).map(e=>({[e]:r[e]}))});See=class{constructor(r,e){this.limit=r,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(r){this.size<this.limit?(this.heap.push(r),this._bubbleUp(this.size-1)):this.comparator(r,this.heap[0])<0&&(this.heap[0]=r,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(r){let e=this.heap;for(;r>0;){let t=r-1>>1;if(this.comparator(e[r],e[t])<=0)break;let n=e[r];e[r]=e[t],e[t]=n,r=t}}_sinkDown(r){let e=this.heap,t=e.length,n=r;do{r=n;let i=2*r+1,o=2*r+2;if(i<t&&this.comparator(e[i],e[n])>0&&(n=i),o<t&&this.comparator(e[o],e[n])>0&&(n=o),n!==r){let s=e[r];e[r]=e[n],e[n]=s}}while(n!==r)}};Pee=/[\p{L}\p{M}\p{N}_]+/gu,_U=new WeakSet;Ree=class{static condition(r,e){return e.useTokenSearch}constructor(r,e){this.options=e,this.analyzer=LP({isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,tokenize:e.tokenize});let t=this.analyzer.tokenize(r),{df:n,fieldCount:i}=e._invertedIndex;this.termSearchers=[],this.idfWeights=[];for(let o of t){this.termSearchers.push(new UP(o,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));let s=n.get(o)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(r){if(!this.termSearchers.length)return{isMatch:!1,score:1};let e=[],t=0,n=0,i=0,o=0,s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){let u=this.termSearchers[c].searchIn(r),d=this.idfWeights[c];n+=d,u.isMatch&&(i++,t+=d*(1-u.score),u.indices&&e.push(...u.indices),this.combineAll&&(this.useMask?o|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};let a=n>0?1-t/n:0,l={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(l.indices=VP(e)),this.combineAll&&(this.useMask?l.matchedMask=o:l.matchedTerms=s,l.termCount=this.numTerms),l}};Ru=class{constructor(r,e,t){this.options={...rt,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new oee(this.options.keys),this._docs=r,this._myIndex=null,this._invertedIndex=null,this.setCollection(r,t),this._lastQuery=null,this._lastSearcher=null}_getSearcher(r){if(this._lastQuery===r)return this._lastSearcher;let e=__(r,this._invertedIndex?{...this.options,_invertedIndex:this._invertedIndex}:this.options);return this._lastQuery=r,this._lastSearcher=e,e}setCollection(r,e){if(this._docs=r,e&&!(e instanceof BP))throw new Error(JJ);if(this._myIndex=e||IU(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let t=LP({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=$ee(this._myIndex.records,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}add(r){if(!ss(r))return;this._docs.push(r);let e=this._myIndex.add(r,this._docs.length-1);if(this._invertedIndex&&e){let t=LP({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});Oee(this._invertedIndex,e,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}remove(r=()=>!1){let e=[],t=[];for(let n=0,i=this._docs.length;n<i;n+=1)r(this._docs[n],n)&&(e.push(this._docs[n]),t.push(n));if(t.length){this._invertedIndex&&AU(this._invertedIndex,t);let n=new Set(t);this._docs=this._docs.filter((i,o)=>!n.has(o)),this._myIndex.removeAll(t),this._invalidateSearcherCache()}return e}removeAt(r){if(!Number.isInteger(r)||r<0||r>=this._docs.length)throw new Error(FP);this._invertedIndex&&AU(this._invertedIndex,[r]);let e=this._docs.splice(r,1)[0];return this._myIndex.removeAt(r),this._invalidateSearcherCache(),e}_invalidateSearcherCache(){this._lastQuery=null,this._lastSearcher=null}getIndex(){return this._myIndex}_normalizedKeys(){return this._myIndex.keys.map(r=>this._keyStore.get(r.id)||r)}search(r,e){let{limit:t=-1}=e||{},{includeMatches:n,includeScore:i,shouldSort:o,sortFn:s,ignoreFieldNorm:a}=this.options;if(Gi(r)&&!r.trim()){let f=this._docs.map((p,m)=>({item:p,refIndex:m}));return E_(t)&&t>-1&&(f=f.slice(0,t)),f}let l=o&&E_(t)&&t>0&&Gi(r),c=s,u=(f,p)=>c(f,p)||f.idx-p.idx,d;if(l){let f=new See(t,u);Gi(this._docs[0])?this._searchStringList(r,{heap:f,ignoreFieldNorm:a}):this._searchObjectList(r,{heap:f,ignoreFieldNorm:a}),d=f.extractSorted()}else d=Gi(r)?Gi(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r),kee(d,{ignoreFieldNorm:a}),o&&d.sort(Gi(r)?u:c),E_(t)&&t>-1&&(d=d.slice(0,t));return Iee(d,this._docs,{includeMatches:n,includeScore:i})}_searchStringList(r,{heap:e,ignoreFieldNorm:t}={}){let n=this._getSearcher(r),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,s=e?null:[];return o.forEach(({v:a,i:l,n:c})=>{if(!ss(a))return;let u=n.searchIn(a);if(u.isMatch){let d={score:u.score,value:a,norm:c,indices:u.indices};i&&(d.matchedMask=u.matchedMask,d.matchedTerms=u.matchedTerms,d.termCount=u.termCount);let f=[d];if(!i||this._coversAllTokens(f)){let p={item:a,idx:l,matches:f};e?(p.score=NP(p.matches,{ignoreFieldNorm:t}),e.insert(p)):s.push(p)}}}),s}_searchLogical(r){let e=FU(r,this.options),t=this._normalizedKeys(),n=(a,l,c)=>{if(!("children"in a)){let{keyId:p,searcher:m}=a,v;return p===null?(v=[],t.forEach((g,y)=>{v.push(...this._findMatches({key:g,value:l[y],searcher:m}))})):v=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(l,p),searcher:m}),v&&v.length?[{idx:c,item:l,matches:v}]:[]}let{children:u,operator:d}=a,f=[];for(let p=0,m=u.length;p<m;p+=1){let v=u[p],g=n(v,l,c);if(g.length)f.push(...g);else if(d===A_.AND)return[]}return f},i=this._myIndex.records,o=new Map,s=[];return i.forEach(({$:a,i:l})=>{if(ss(a)){let c=n(e,a,l);c.length&&(o.has(l)||(o.set(l,{idx:l,item:a,matches:[]}),s.push(o.get(l))),c.forEach(({matches:u})=>{o.get(l).matches.push(...u)}))}}),s}_searchObjectList(r,{heap:e,ignoreFieldNorm:t}={}){let n=this._getSearcher(r),i=this.options.useTokenSearch&&this.options.tokenMatch==="all",{records:o}=this._myIndex,s=this._normalizedKeys(),a=e?null:[];return o.forEach(({$:l,i:c})=>{if(!ss(l))return;let u=[],d=!1,f=!1;if(s.forEach((p,m)=>{let v=this._findMatches({key:p,value:l[m],searcher:n});v.length?(u.push(...v),v[0].hasInverse&&(f=!0)):d=!0}),!(f&&d)&&u.length&&(!i||this._coversAllTokens(u))){let p={idx:c,item:l,matches:u};e?(p.score=NP(p.matches,{ignoreFieldNorm:t}),e.insert(p)):a.push(p)}}),a}_findMatches({key:r,value:e,searcher:t}){if(!ss(e))return[];let n=[];if(Mu(e))e.forEach(({v:i,i:o,n:s})=>{if(!ss(i))return;let a=t.searchIn(i);if(a.isMatch){let l={score:a.score,key:r,value:i,idx:o,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(l.matchedMask=a.matchedMask,l.matchedTerms=a.matchedTerms,l.termCount=a.termCount),n.push(l)}});else{let{v:i,n:o}=e,s=t.searchIn(i);if(s.isMatch){let a={score:s.score,key:r,value:i,norm:o,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),n.push(a)}}return n}_coversAllTokens(r){let e=r.length?r[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let n=0;for(let i=0;i<r.length;i++)n|=r[i].matchedMask||0;return n===2**e-1}let t=new Set;for(let n=0;n<r.length;n++){let i=r[n].matchedTerms;if(i)for(let o of i)t.add(o)}return t.size===e}};Ru.version="7.5.0";Ru.createIndex=IU;Ru.parseIndex=fee;Ru.config=rt;Ru.match=function(r,e,t){if(t&&t.useTokenSearch)throw new Error(iee);return __(r,{...rt,...t}).searchIn(e)};Ru.parseQuery=FU;qP(Tee);qP(Ree);Ru.use=function(...r){r.forEach(e=>qP(e))};$u=Ru});var by,WP,Lee,Bee,RU,$U,Tm,zP=b(()=>{by=require("obsidian");k_();Mo();WP=class{constructor(e=100){this.cache=new Map;this.maxSize=e}peek(e){return this.cache.get(e)}set(e,t){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.maxSize){let n=this.cache.keys().next().value;this.cache.delete(n)}this.cache.set(e,t)}clear(){this.cache.clear()}},Lee=20,Bee=100,RU=/\w/,$U={base:{basenameExact:-1e3,aliasExact:-900,basenamePrefix:-500,aliasPrefix:-500,substringBasename:-300,fuzzyMatch:0,unresolvedLink:1e3},boosts:{sameFolder:-.15,recency:-.1,tagOverlap:-.05,tagOverlapMax:-.2},penalties:{titleLengthThreshold:15,titleLengthMultiplier:.02,aliasMinPenalty:.05,aliasMaxPenalty:.6,aliasLengthMultiplier:.04,positionMultiplier:.05},thresholds:{recencyDays:1,fuzzyRelaxCount:5}},Tm=class r{constructor(e,t){this.fileMap=new Map;this.recentFiles=new WP;this.unresolvedLinks=new Set;this.unresolvedLinksDirty=!0;this.isIndexing=!1;this.indexPromise=null;this.reindexTimeout=null;this.fuseUpdateTimeout=null;this.pendingFuseUpdates=new Map;this.reindexBuffer=null;this.effectiveWeights=$U;this.app=e,this.plugin=t;let n={keys:[{name:"basenameNormalized",weight:.8},{name:"aliasesNormalized",weight:.6},{name:"pathNormalized",weight:.2}],ignoreLocation:!0,findAllMatches:!0,shouldSort:!1,includeMatches:!0};this.fuseStrict=new $u([],{...n,threshold:.2}),this.fuseRelaxed=new $u([],{...n,threshold:.4}),this.setupEventListeners(),this.effectiveWeights=$U}static getInstance(e,t){return r.instance||(r.instance=new r(e,t)),r.instance}static getInstanceIfExists(){return r.instance??void 0}getLastOpenedAt(e){return this.recentFiles.peek(e)}setupEventListeners(){this.plugin.registerEvent(this.app.workspace.on("file-open",e=>{if(e){this.recentFiles.set(e.path,Date.now());let t=this.fileMap.get(e.path);t&&(t.openedAt=Date.now())}})),this.plugin.registerEvent(this.app.metadataCache.on("changed",e=>{e instanceof by.TFile&&e.extension==="md"&&this.updateFile(e)})),this.plugin.registerEvent(this.app.metadataCache.on("resolved",()=>{this.unresolvedLinksDirty=!0,this.fileMap.size===0&&this.scheduleReindex()})),this.plugin.registerEvent(this.app.vault.on("create",e=>{e instanceof by.TFile&&e.extension==="md"&&this.addFile(e)})),this.plugin.registerEvent(this.app.vault.on("delete",e=>{e instanceof by.TFile&&this.removeFile(e)})),this.plugin.registerEvent(this.app.vault.on("rename",(e,t)=>{e instanceof by.TFile&&e.extension==="md"&&(this.removeFileByPath(t),this.addFile(e))}))}async ensureIndexed(){if(this.isIndexing&&this.indexPromise)return this.indexPromise;if(this.fileMap.size===0)return this.reindex()}scheduleReindex(){this.reindexTimeout!==null&&window.clearTimeout(this.reindexTimeout),this.reindexTimeout=window.setTimeout(()=>{this.reindex()},500)}async reindex(){if(this.isIndexing&&this.indexPromise)return this.indexPromise;this.isIndexing=!0,this.indexPromise=this.performReindex();try{await this.indexPromise}finally{this.isIndexing=!1,this.indexPromise=null}}async performReindex(){let e=new Map;this.reindexBuffer=e;try{let t=this.app.vault.getMarkdownFiles(),n=new Map;await(async(o,s=50)=>{for(let a=0;a<o.length;a+=s){let l=o.slice(a,a+s);for(let c of l){let u=this.createIndexedFile(c);n.set(c.path,u)}await new Promise(c=>window.setTimeout(c,0))}})(t),this.fileMap=n;for(let[o,s]of e)s.op==="remove"?this.fileMap.delete(o):s.file&&this.fileMap.set(o,this.createIndexedFile(s.file));this.updateFuseIndex(),this.updateUnresolvedLinks()}catch(t){try{this.updateFuseIndex()}catch{}throw t}finally{this.reindexBuffer=null}}extractAliases(e){if(!e)return[];let t=[];for(let[n,i]of Object.entries(e)){let o=n.toLowerCase();if(!(o!=="alias"&&o!=="aliases"))if(typeof i=="string"){let s=i.split(",").map(a=>a.trim()).filter(a=>a.length>0);t.push(...s)}else Array.isArray(i)&&t.push(...i.filter(s=>typeof s=="string").map(s=>s.trim()).filter(s=>s.length>0))}return t}createIndexedFile(e){let t=this.app.metadataCache.getFileCache(e),n=t?.frontmatter,i=this.extractAliases(n),o=i.map(c=>$r(c)),s=(t?.headings??[]).map(c=>kP(c.heading)),a=[];if(t?.blocks)for(let c of Object.values(t.blocks))c.id&&a.push(c.id);let l=t?.tags?.map(c=>c.tag)??[];if(n?.tags){let c=Array.isArray(n.tags)?n.tags:[n.tags];l.push(...c.filter(u=>typeof u=="string"))}return{path:e.path,pathNormalized:$r(e.path),basename:e.basename,basenameNormalized:$r(e.basename),aliases:i,aliasesNormalized:o,headings:s,blockIds:a,tags:l,modified:e.stat.mtime,openedAt:this.recentFiles.peek(e.path),folder:e.parent?.path??""}}addFile(e){let t=this.createIndexedFile(e);this.fileMap.set(e.path,t),this.scheduleFuseUpdate(e.path,"add"),this.reindexBuffer?.set(e.path,{op:"upsert",file:e})}updateFile(e){let t=this.createIndexedFile(e);this.fileMap.set(e.path,t),this.scheduleFuseUpdate(e.path,"update"),this.unresolvedLinksDirty=!0,this.reindexBuffer?.set(e.path,{op:"upsert",file:e})}removeFile(e){this.removeFileByPath(e.path)}removeFileByPath(e){this.fileMap.delete(e),this.scheduleFuseUpdate(e,"remove"),this.reindexBuffer?.set(e,{op:"remove"})}updateFuseIndex(){let e=Array.from(this.fileMap.values());this.fuseStrict.setCollection(e),this.fuseRelaxed.setCollection(e)}scheduleFuseUpdate(e,t){if(this.isIndexing)return;let n=this.pendingFuseUpdates.get(e);if(n)if(n==="add"&&t==="remove"){this.pendingFuseUpdates.delete(e);return}else n==="remove"&&t==="add"?this.pendingFuseUpdates.set(e,"update"):this.pendingFuseUpdates.set(e,t);else this.pendingFuseUpdates.set(e,t);this.fuseUpdateTimeout!==null&&window.clearTimeout(this.fuseUpdateTimeout),this.fuseUpdateTimeout=window.setTimeout(()=>{this.processPendingFuseUpdates()},Bee)}processPendingFuseUpdates(){if(this.pendingFuseUpdates.size!==0){if(this.isIndexing){this.pendingFuseUpdates.clear();return}if(this.pendingFuseUpdates.size>Lee){this.updateFuseIndex(),this.pendingFuseUpdates.clear();return}for(let[e,t]of this.pendingFuseUpdates)switch(t){case"add":{this.fuseStrict.remove(i=>i.path===e),this.fuseRelaxed.remove(i=>i.path===e);let n=this.fileMap.get(e);n&&(this.fuseStrict.add(n),this.fuseRelaxed.add(n));break}case"update":{this.fuseStrict.remove(i=>i.path===e),this.fuseRelaxed.remove(i=>i.path===e);let n=this.fileMap.get(e);n&&(this.fuseStrict.add(n),this.fuseRelaxed.add(n));break}case"remove":{this.fuseStrict.remove(n=>n.path===e),this.fuseRelaxed.remove(n=>n.path===e);break}}this.pendingFuseUpdates.clear()}}updateUnresolvedLinks(){let e=this.app.metadataCache.unresolvedLinks;this.unresolvedLinks.clear();for(let t in e)for(let n in e[t])this.unresolvedLinks.add(n);this.unresolvedLinksDirty=!1}search(e,t={},n=50){this.unresolvedLinksDirty&&this.updateUnresolvedLinks();let i=[],o=$r(e);if(e.includes("#"))return this.searchWithHeadings(e,t,n);let s=new Set,a=Array.from(this.fileMap.values());for(let c of a)c.basenameNormalized===o&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.basenameExact,"exact"),matchType:"exact",displayText:c.basename}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.aliasesNormalized.indexOf(o);u!==-1&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasExact,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path))}for(let c of a)c.basenameNormalized.startsWith(o)&&c.basenameNormalized!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.basenamePrefix,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path));for(let c of a)for(let[u,d]of c.aliasesNormalized.entries())d.startsWith(o)&&d!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasPrefix,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.basenameNormalized.indexOf(o);if(u>0){let d=c.basenameNormalized[u-1];RU.test(d)||(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.substringBasename,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path))}}let l=this.fuseStrict.search(o,{limit:n*2});l.length<this.effectiveWeights.thresholds.fuzzyRelaxCount&&(l=this.fuseRelaxed.search(o,{limit:n*2}));for(let c of l){if(!c||!c.item||!c.item.path||s.has(c.item.path))continue;let u=(c.matches??[]).find(m=>m.key==="aliasesNormalized"),d=!!u,f=d?"alias":"fuzzy",p=c.item.basename;if(d){let m=typeof u?.value=="string"?u.value:void 0,v=m?c.item.aliasesNormalized.findIndex(g=>g===m):c.item.aliasesNormalized.findIndex(g=>g.includes(o));v>=0&&(p=c.item.aliases[v])}i.push({file:c.item,score:this.calculateScore(c.item,e,t,(c.score??.5)+this.effectiveWeights.base.fuzzyMatch,f),matchType:f,displayText:p}),s.add(c.item.path)}if(e.length>=2){let c=0,u=e.length<3?10:20;for(let d of this.unresolvedLinks){if(c>=u)break;$r(d).includes(o)&&(i.push({file:{path:d,pathNormalized:$r(d),basename:d,basenameNormalized:$r(d),aliases:[],aliasesNormalized:[],headings:[],blockIds:[],tags:[],modified:0,folder:""},score:this.effectiveWeights.base.unresolvedLink,matchType:"unresolved",displayText:d}),c++)}}return i.sort((c,u)=>c.score-u.score).slice(0,n)}calculateScore(e,t,n,i,o){let s=i;if(n.currentFolder&&e.folder===n.currentFolder&&(s+=this.effectiveWeights.boosts.sameFolder),e.openedAt&&(Date.now()-e.openedAt)/864e5<this.effectiveWeights.thresholds.recencyDays&&(s+=this.effectiveWeights.boosts.recency),n.currentFile){let d=this.fileMap.get(n.currentFile.path);if(d){let f=e.tags.filter(p=>d.tags.includes(p));f.length>0&&(s+=this.effectiveWeights.boosts.tagOverlap*Math.min(f.length,Math.abs(this.effectiveWeights.boosts.tagOverlapMax/this.effectiveWeights.boosts.tagOverlap)))}}let a=$r(t),l=e.basename.length;if(o==="alias"&&e.aliases.length>0){let d=e.aliasesNormalized.findIndex(f=>f.includes(a));d>=0&&(l=e.aliases[d].length)}if(o==="alias"){let d=Math.max(0,(l-this.effectiveWeights.penalties.titleLengthThreshold)*this.effectiveWeights.penalties.aliasLengthMultiplier),f=Math.min(this.effectiveWeights.penalties.aliasMaxPenalty,this.effectiveWeights.penalties.aliasMinPenalty+d);s+=f}l>this.effectiveWeights.penalties.titleLengthThreshold&&(s+=(l-this.effectiveWeights.penalties.titleLengthThreshold)*this.effectiveWeights.penalties.titleLengthMultiplier);let c=e.basenameNormalized;if(o==="alias"&&e.aliases.length>0){let d=e.aliasesNormalized.findIndex(f=>f.includes(a));d>=0&&(c=e.aliasesNormalized[d])}let u=c.indexOf(a);return u>=0&&(s+=u*this.effectiveWeights.penalties.positionMultiplier),s}searchWithHeadings(e,t,n){let[i,o]=e.split("#"),s=$r(o??""),a=[];if(i===""){let l=0,c=200,u=Array.from(this.fileMap.values());for(let d of u){if(l>=c)break;for(let f of d.headings){if(l>=c)break;$r(f).includes(s)&&(a.push({file:d,score:this.calculateScore(d,e,t,.1),matchType:"heading",displayText:`${d.basename}#${f}`}),l++)}}}else{let l=this.searchFiles(i,t,n);if(l.length===0)return[];for(let c of l)for(let u of c.file.headings)$r(u).includes(s)&&a.push({file:c.file,score:c.score+.05,matchType:"heading",displayText:`${c.file.basename}#${u}`})}return a.sort((l,c)=>l.score-c.score).slice(0,n)}searchFiles(e,t,n){let i=[],o=$r(e),s=new Set,a=Array.from(this.fileMap.values());for(let c of a)c.basenameNormalized===o&&(i.push({file:c,score:this.calculateScore(c,e,t,-1e3,"exact"),matchType:"exact",displayText:c.basename}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.aliasesNormalized.indexOf(o);u!==-1&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasExact,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path))}for(let c of a)c.basenameNormalized.startsWith(o)&&c.basenameNormalized!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,-500,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path));for(let c of a)for(let[u,d]of c.aliasesNormalized.entries())d.startsWith(o)&&d!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,-500,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.basenameNormalized.indexOf(o);if(u>0){let d=c.basenameNormalized[u-1];RU.test(d)||(i.push({file:c,score:this.calculateScore(c,e,t,-300,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path))}}let l=this.fuseStrict.search(o,{limit:n*2});l.length<this.effectiveWeights.thresholds.fuzzyRelaxCount&&(l=this.fuseRelaxed.search(o,{limit:n*2}));for(let c of l){if(!c||!c.item||!c.item.path||s.has(c.item.path))continue;let u=(c.matches??[]).find(m=>m.key==="aliasesNormalized"),d=!!u,f=d?"alias":"fuzzy",p=c.item.basename;if(d){let m=typeof u?.value=="string"?u.value:void 0,v=m?c.item.aliasesNormalized.findIndex(g=>g===m):c.item.aliasesNormalized.findIndex(g=>g.includes(o));v>=0&&(p=c.item.aliases[v])}i.push({file:c.item,score:this.calculateScore(c.item,e,t,(c.score??.5)+this.effectiveWeights.base.fuzzyMatch,f),matchType:f,displayText:p}),s.add(c.item.path)}return i.sort((c,u)=>c.score-u.score).slice(0,n)}getFile(e){return this.fileMap.get(e)}getHeadings(e){return e.headings}getBlockIds(e){return e.blockIds}getIndexedFileCount(){return this.fileMap.size}}});function OU(r){HP=r}function ni(){if(!HP)throw new Error("QuickAdd plugin instance accessed before it was initialised.");return HP}var HP,wl=b(()=>{});function Vee(r,e){let t=xr(r,"span");switch(t.classList.add("qa-suggestion-pill"),e){case"alias":return t.classList.add("qa-alias-pill"),t.textContent="alias",t;case"heading":return t.classList.add("qa-heading-pill"),t.textContent="H",t;case"block":return t.classList.add("qa-block-pill"),t.textContent="^",t;case"unresolved":return t.classList.add("qa-unresolved-pill"),t.textContent="unresolved",t;default:return null}}var S_,_m,jP=b(()=>{yl();S_=require("obsidian");_t();zP();Mo();wl();ka();_m=class extends hn{constructor(t,n,i){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.sourcePathOverride=i?.sourcePath,this.fileIndex=Tm.getInstance(t,ni()),this.fileIndex.ensureIndexed()}normalizeFolderPath(t){return!t||t==="/"?"":t.replace(/\/+$/,"")}getSourcePath(){return this.sourcePathOverride??this.app.workspace.getActiveFile()?.path??""}getSourceFolder(){let t=this.getSourcePath();if(!t)return"";let n=this.app.fileManager.getNewFileParent(t);return this.normalizeFolderPath(n?.path)}resolveRelative(t,n){let i=this.normalizeFolderPath(t),o=n;for(o.startsWith("./")&&(o=o.slice(2));o.startsWith("../");){let s=i.split("/");if(!i||s.length===0||s.length===1&&s[0]==="")break;s.pop(),i=s.join("/"),o=o.slice(3)}return{folder:this.normalizeFolderPath(i),query:o}}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.slice(0,n),o=cB.exec(i);if(!o)return[];let s=o[1];if(this.lastInput=s,s.includes("#^"))return this.getBlockSuggestions(s);if(s.indexOf("#")>0)return this.getHeadingSuggestions(s);if(s.startsWith("./")||s.startsWith("../"))return this.getRelativePathSuggestions(s);if(i.includes("![["))return this.getAttachmentSuggestions(s);let c=this.getSourceFolder(),u=this.app.workspace.getActiveFile(),d={currentFile:this.sourcePathOverride?void 0:u??void 0,currentFolder:c};return this.fileIndex.search(s,d,50)}getHeadingSuggestions(t){let[n,i]=t.split("#"),o=n.trim()==="",s=$r(i??""),a=[];if(o){let c=this.app.workspace.getActiveFile();if(c){let u=this.fileIndex.getFile(c.path);u&&(a=[u])}}else a=this.fileIndex.search(n,{},1).map(c=>c.file);if(a.length===0)return[];let l=[];for(let c of a){let d=this.fileIndex.getHeadings(c).filter(f=>i===""||$r(f).includes(s)).slice(0,20);for(let f of d)l.push({file:c,score:0,matchType:"heading",displayText:o?`#${f}`:`${c.basename}#${f}`})}return l}getBlockSuggestions(t){let[n,i]=t.split("#^"),o=$r(i??""),s=this.fileIndex.search(n,{},1);if(s.length===0)return[];let a=s[0].file;return this.fileIndex.getBlockIds(a).filter(c=>i===""||$r(c).includes(o)).slice(0,20).map(c=>({file:a,score:0,matchType:"block",displayText:`${a.basename}#^${c}`}))}getRelativePathSuggestions(t){let n=this.getSourceFolder(),{folder:i,query:o}=this.resolveRelative(n,t);if(o)return this.fileIndex.search(o,{currentFolder:i},20);let s=this.fileIndex.search("",{currentFolder:i},50),a=l=>this.normalizeFolderPath(l||"");return s.filter(l=>a(l.file.folder)===a(i))}getAttachmentSuggestions(t){let n=this.app.vault.getFiles(),i=["png","jpg","jpeg","gif","svg","pdf","mp4","webm","mov","canvas"],o=$r(t);return n.filter(a=>i.includes(a.extension.toLowerCase())&&(t===""||$r(a.basename).includes(o))).slice(0,20).map(a=>({file:{path:a.path,pathNormalized:$r(a.path),basename:a.basename,basenameNormalized:$r(a.basename),aliases:[],aliasesNormalized:[],headings:[],blockIds:[],tags:[],modified:a.stat.mtime,folder:this.normalizeFolderPath(a.parent?.path||"")},score:0,matchType:"exact",displayText:a.name}))}renderSuggestion(t,n){let{file:i,matchType:o,displayText:s}=t;n.classList.add("qaFileSuggestionItem"),n.classList.add(`qa-suggest-${o}`);let a=s,l="",c=!1,u="";switch(o){case"exact":a=i.basename,l=i.path;break;case"alias":a=s,l=i.path;break;case"fuzzy":a=i.basename,l=i.path;break;case"heading":{let[v,g]=s.split("#"),y=this.lastInput.includes("#")?this.lastInput.split("#")[1]:"",w=$r(y??"");y&&$r(g).includes(w)?(a=g,c=!0,u=y):a=g,l=v;break}case"block":{let[v,g]=s.split("#^");a=g,l=v;break}case"unresolved":a=s,l="Unresolved link";break}let d=xr(n,"div");d.className="qa-suggestion-content";let f=xr(n,"span");f.className="suggestion-main-text",c?this.renderMatch(f,a,u):f.textContent=a,d.appendChild(f);let p=Vee(n,o);p&&d.appendChild(p);let m=xr(n,"span");m.className="suggestion-sub-text",m.textContent=l,n.replaceChildren(d,m),this.addHoverTooltip(n,i)}open(t,n){if(super.open(t,n),!this.scrollListener){let i=rs(this.inputEl),o=()=>this.hideTooltip();i.addEventListener("scroll",o,{passive:!0}),this.scrollListener=o,this.scrollListenerDocument=i}}hideTooltip(){let t=rs(this.inputEl);this.tooltipTimeout!==void 0&&(window.clearTimeout(this.tooltipTimeout),this.tooltipTimeout=void 0),t.querySelector(".qa-file-tooltip")?.remove()}addHoverTooltip(t,n){let i=rs(t);t.addEventListener("mouseenter",()=>{this.hideTooltip(),this.tooltipTimeout=window.setTimeout(()=>{let o=this.createTooltip(n);o&&(i.body.appendChild(o),this.positionTooltip(o,t))},200)}),t.addEventListener("mouseleave",()=>this.hideTooltip()),t.addEventListener("blur",()=>this.hideTooltip())}createTooltip(t){let n=this.app.vault.getAbstractFileByPath(t.path);if(!n||!(n instanceof S_.TFile))return null;let i=this.inputEl,o=xr(i,"div");o.className="qa-file-tooltip";let s=xr(i,"div");s.className="qa-tooltip-header",s.textContent=n.basename;let a=xr(i,"div");a.className="qa-tooltip-content";let l=xr(i,"div");l.textContent=`Path: ${n.path}`;let c=xr(i,"div");return c.textContent=`Modified: ${new Date(n.stat.mtime).toLocaleDateString()}`,a.append(l,c),o.append(s,a),o}positionTooltip(t,n){let i=n.getBoundingClientRect();t.style.left=`${i.right+10}px`,t.style.top=`${i.top}px`}close(){this.hideTooltip(),this.scrollListener&&this.scrollListenerDocument&&(this.scrollListenerDocument.removeEventListener("scroll",this.scrollListener),this.scrollListener=void 0,this.scrollListenerDocument=void 0),super.close()}selectSuggestion(t){if(this.inputEl.selectionStart===null)return;let n=this.inputEl.selectionStart,i=this.lastInput.length,o=this.inputEl.value,s=0,a=this.inputEl.value.slice(n-this.lastInput.length-3,n-this.lastInput.length)==="![[";if(t.matchType==="unresolved")s=this.makeLinkManually(o,t.displayText.replace(/.md$/,""),n,i);else if(t.matchType==="heading"||t.matchType==="block"){let l=t.displayText;s=this.makeLinkManually(o,l,n,i)}else if(a)s=this.makeLinkManually(o,t.displayText,n,i);else{let l=this.app.vault.getAbstractFileByPath(t.file.path);if(l instanceof S_.TFile){let c=t.matchType==="alias"?t.displayText:void 0;s=this.makeLinkObsidianMethod(l,o,n,i,c)}else s=this.makeLinkManually(o,t.displayText,n,i)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(s,s)}makeLinkObsidianMethod(t,n,i,o,s){let a=this.app.vault.getAbstractFileByPath(t.path);if(!(a instanceof S_.TFile))return this.makeLinkManually(n,t.path,i,o);let l=this.app.fileManager.generateMarkdownLink(a,this.getSourcePath(),"",s??"");return this.inputEl.value=this.getNewInputValueForFileLink(n,l,i,o),i-o+l.length+2}makeLinkManually(t,n,i,o){return this.inputEl.value=this.getNewInputValueForFileName(t,n,i,o),i-o+n.length+2}getNewInputValueForFileLink(t,n,i,o){return`${t.slice(0,i-o-2)}${n}${t.slice(i)}`}getNewInputValueForFileName(t,n,i,o){return`${t.slice(0,i-o)}${n}]]${t.slice(i)}`}}});var NU,D_,LU=b(()=>{k_();NU={threshold:.4,includeScore:!0,keys:[""]},D_=class r{constructor(e,t){this.sortedTags=[];this.fuse=new $u([],NU);this.app=e,this.refresh(),t.registerEvent(this.app.metadataCache.on("resolved",()=>this.refresh()))}static getInstance(e,t){return r.instance||(r.instance=new r(e,t)),r.instance}refresh(){let e=this.app.metadataCache.getTags(),t=Object.keys(e);this.sortedTags=t.sort((n,i)=>n.length!==i.length?n.length-i.length:n.localeCompare(i)),this.fuse=new $u(this.sortedTags,NU)}getSortedTags(){return this.sortedTags}search(e){return this.fuse.search(e)}}});var Am,GP=b(()=>{_t();yl();Mo();wl();LU();Am=class extends hn{constructor(t,n){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.lastInputStart=0;this.lastInputLength=0;this.tagIndex=D_.getInstance(t,ni()),this.tagIndex.refresh()}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.slice(0,n),o=uB.exec(i);if(!o)return[];let s=i.lastIndexOf("[[");if(o.index===void 0)return[];if(s!==-1&&s<o.index)return[];let a=o[1];this.lastInput=a,this.lastInputStart=o.index,this.lastInputLength=o[0].length;let l=this.tagIndex.getSortedTags(),c=a.toLowerCase(),u=l.filter(m=>m.replace(/^#/,"").toLowerCase().startsWith(c)).slice(0,5),d=this.tagIndex.search(a).filter(m=>m.score!==void 0&&m.score<.8).map(m=>m.item).slice(0,10),f=new Set(u),p=[...u];for(let m of d)!f.has(m)&&p.length<15&&(p.push(m),f.add(m));return p}renderSuggestion(t,n){this.renderMatch(n,t,this.lastInput)}selectSuggestion(t){let n=this.inputEl;if(n.selectionStart===null)return;let i=this.lastInputStart,o=i+this.lastInputLength,s=t.startsWith("#")?t:`#${t}`;y_(n,i,o,s,{fromCompletion:!0}),this.close()}}});var Yi,km=b(()=>{Yi=class r{constructor(){this.drafts=new Map;this.pendingSubmittedDraftKeys=new Set;this.executionScopeDepth=0;this.executionScopeFailed=!1;this.MAX_ENTRIES=100}static getInstance(){return r.instance||(r.instance=new r),r.instance}makeKey(e){return JSON.stringify({v:1,kind:e.kind,header:e.header,placeholder:e.placeholder??"",linkSourcePath:e.linkSourcePath??"",scopeId:e.scopeId??""})}get(e){let t=this.drafts.get(e);if(t)return t.timestamp=Date.now(),t.value}set(e,t){this.drafts.size>=this.MAX_ENTRIES&&!this.drafts.has(e)&&this.evictOldest(1),this.drafts.set(e,{value:t,timestamp:Date.now()})}handleSubmittedDraft(e,t){if(!this.hasActiveExecutionScope()){this.clear(e);return}this.set(e,t),this.pendingSubmittedDraftKeys.add(e)}beginExecutionScope(){this.executionScopeDepth+=1}commitExecutionScope(){if(this.hasActiveExecutionScope()&&(this.executionScopeDepth-=1,!(this.executionScopeDepth>0))){if(!this.executionScopeFailed)for(let e of this.pendingSubmittedDraftKeys)this.clear(e);this.resetExecutionScope()}}rollbackExecutionScope(){this.hasActiveExecutionScope()&&(this.executionScopeFailed=!0,this.executionScopeDepth-=1,this.executionScopeDepth===0&&this.resetExecutionScope())}markExecutionScopeFailed(){this.hasActiveExecutionScope()&&(this.executionScopeFailed=!0)}hasActiveExecutionScope(){return this.executionScopeDepth>0}clear(e){this.drafts.delete(e),this.pendingSubmittedDraftKeys.delete(e)}clearAll(){this.drafts.clear(),this.resetExecutionScope()}evictOldest(e){let t=Array.from(this.drafts.entries()).sort(([,n],[,i])=>n.timestamp-i.timestamp).slice(0,e);for(let[n]of t)this.drafts.delete(n),this.pendingSubmittedDraftKeys.delete(n)}resetExecutionScope(){this.pendingSubmittedDraftKeys.clear(),this.executionScopeDepth=0,this.executionScopeFailed=!1}}});var Sm,YP=b(()=>{Pt();km();Sm=class{constructor(e,t){this.store=Yi.getInstance();this.initialValue="";this.didChange=!1;this.draftKey=this.store.makeKey(e),this.shouldPersist=t??(()=>le.getState().persistInputPromptDrafts)}hydrate(e){return this.initialValue=e,this.shouldPersist()?this.store.get(this.draftKey)??e:e}markChanged(){this.didChange=!0}persist(e,t){if(this.shouldPersist()){if(t){this.store.handleSubmittedDraft(this.draftKey,e);return}if(!(!this.didChange||e===this.initialValue)){if(!e.trim()){this.store.clear(this.draftKey);return}this.store.set(this.draftKey,e)}}}}});function I_(r,e){if(r.focus(),e?.cursorAtEnd){let t=r.value.length;r.setSelectionRange(t,t);return}r.select()}var KP=b(()=>{});function P_(r,e,t){let n=e?.trim();if(!n)return;let i=r.createDiv({text:n,cls:"qa-prompt-context"});return i.setAttr("title",t?.trim()||n),i}var QP=b(()=>{});function Uee(r){return(r??"").trim().replace(/\\/g,"/")}function qee(r){return r.startsWith("/")||/^[a-zA-Z]:/.test(r)}function Wee(r){return r.split("/").some(e=>/^\.\.[. ]*$/u.test(e))}function Un(r){let e=Uee(r);return e?qee(e)||Wee(e):!1}var _c=b(()=>{});function zee(r){let e=t=>String(t).padStart(2,"0");return`${r.getFullYear()}-${e(r.getMonth()+1)}-${e(r.getDate())} ${e(r.getHours())}.${e(r.getMinutes())}.${e(r.getSeconds())}`}async function F_(r,e,t,n){let i=wy[t];if(!i)throw new Error(`Unsupported clipboard image type: ${t}`);let o=`Clipboard image ${zee(new Date)}.${i}`,s=await r.fileManager.getAvailablePathForAttachment(o,n||void 0);if(Un(s))throw new Error(`Refusing to save clipboard image outside the vault: '${s}'`);return r.vault.createBinary(s,e)}function M_(r,e,t){let n=r.fileManager.generateMarkdownLink(e,t);return n.startsWith("!")?n:`!${n}`}var wy,XP=b(()=>{_c();wy=Object.assign(Object.create(null),{"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"})});function Dm(r,e,t={}){let n=t.sourcePath??"",i=null,o=!1,s=!1,a=()=>{s=!0},l=()=>{s=!1},c=d=>{let f=d.clipboardData;if(!f||s||f.getData("text/plain").length>0)return;let p=jee(f);if(p.length!==0){if(d.preventDefault(),i){new R_.Notice("QuickAdd: an image is still being saved \u2014 paste again in a moment.");return}i=u(p).finally(()=>{i=null})}};async function u(d){let f=e.readOnly;e.readOnly=!0,e.setAttribute("aria-busy","true"),e.classList.add("qa-image-paste-busy");let p=[];try{for(let m of d){let v=await m.file.arrayBuffer(),g=await Hee(()=>F_(r,v,m.mimeType,n));p.push(M_(r,g,n))}}catch(m){M.logError(`Failed to save pasted image: ${m instanceof Error?m.message:String(m)}`),new R_.Notice("QuickAdd: failed to save pasted image.")}finally{e.readOnly=f,e.removeAttribute("aria-busy"),e.classList.remove("qa-image-paste-busy")}if(!(p.length===0||o))try{Gee(e,p.join(e.tagName==="TEXTAREA"?`
`:" "))}catch(m){M.logError(`Failed to insert pasted image link: ${m instanceof Error?m.message:String(m)}`),new R_.Notice("QuickAdd: saved the pasted image but could not insert its link.")}}return e.addEventListener("paste",c),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l),{isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),detach:()=>{o=!0,e.removeEventListener("paste",c),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l)}}}function Hee(r){let e=BU.then(r,r);return BU=e.catch(()=>{}),e}function VU(r){return Object.hasOwn(wy,r)}function jee(r){let e=[];for(let t of Array.from(r.items??[])){if(t.kind!=="file"||!VU(t.type))continue;let n=t.getAsFile();n&&e.push({file:n,mimeType:t.type})}if(e.length>0)return e;for(let t of Array.from(r.files??[]))VU(t.type)&&e.push({file:t,mimeType:t.type});return e}function Gee(r,e){r.focus();let t=!1;try{t=r.ownerDocument.execCommand("insertText",!1,e)}catch{t=!1}if(t)return;let n=r.selectionStart??r.value.length,i=r.selectionEnd??n;r.setRangeText(e,n,i,"end"),r.dispatchEvent(new Event("input",{bubbles:!0}))}var R_,BU,$_=b(()=>{R_=require("obsidian");Me();XP();BU=Promise.resolve()});function UU(r,e){return!r.isComposing&&r.key.toLowerCase()===e.toLowerCase()&&r.shiftKey&&(r.ctrlKey||r.metaKey)}function O_(r){return UU(r,"Enter")}function N_(r){return UU(r,ZP)}function WU(r){return r?`Look at the note without losing this draft. ${qU}`:"Look at the note without losing this draft."}function zU(){return`${qU} returns to the prompt`}var ZP,qU,Cy=b(()=>{ZP="E",qU="Ctrl/Cmd+Shift+E"});function HU(r,e,t,n){let i=Math.max(0,Math.min(e,r.length)),o=Math.max(i,Math.min(t,r.length));return{text:r.slice(0,i)+n+r.slice(o),cursor:i+n.length}}function jU(r,e=42){let t=r.slice(0,e*4),n=t.replace(/\s+/g," ").trim();return n.length<=e?t.length<r.length?`${n}\u2026`:n:`${n.slice(0,Math.max(0,e-1))}\u2026`}var JP=b(()=>{});function tF(r){eF.add(r)}function rF(r){eF.delete(r)}function GU(){return eF.size>0}var eF,nF=b(()=>{eF=new Set});function Yee(r,e){let t=new Set([e]);return r.workspace.iterateAllLeaves?.(i=>{let o=i.view?.containerEl?.ownerDocument;o&&t.add(o)}),[...t]}var xi,Ra,Ou,iF=b(()=>{xi=require("obsidian");vl();ka();Cy();JP();nF();Ra=class Ra{constructor(e,t){this.app=e;this.handle=t;this.chipEl=null;this.insertButton=null;this.compactChrome=!1;this.returnScope=null;this.selectionDocuments=[];this.selectionListener=null;this.chipKeyListener=null;this.hasSelection=null;this.selectionPreview=""}static isPeeking(){return Ra.active!==null}static getActive(){return Ra.active}static activate(e,t){let n=Ra.active;if(n){let o=n.handle.title;n.cancel(),new xi.Notice(`QuickAdd: cancelled the peeked prompt "${o}".`)}let i=new Ra(e,t);return Ra.active=i,i.mount(),i}static discard(){Ra.active?.destroy()}discard(){this.destroy()}resume(){if(!this.canReturnNow())return;let e=this.handle;this.destroy(),e.resume()}cancel(){let e=this.handle;this.destroy(),e.cancel()}insertSelectionAndResume(){if(!this.canReturnNow())return;let e=tp(this.app);if(!e){this.resume();return}let t=this.handle;this.destroy(),t.insertSelectionAndResume(e)}canReturnNow(){return GU()?(new xi.Notice("QuickAdd: close the open prompt before returning to the peeked one."),!1):!0}mount(){let n=(this.app.workspace.containerEl?.ownerDocument??document).body;this.compactChrome=xi.Platform.isPhone;let i=n.createDiv({cls:"qa-peek-chip"});i.setAttribute("role","status"),i.setAttribute("aria-live","polite"),this.compactChrome&&i.addClass("qa-peek-chip--compact","qa-peek-chip--top");let o=i.createDiv({cls:"qa-peek-chip-header"}),s=o.createEl("span",{cls:"qa-peek-chip-icon"});s.setAttribute("aria-hidden","true"),(0,xi.setIcon)(s,"eye");let a=o.createDiv({cls:"qa-peek-chip-titles"});a.createDiv({cls:"qa-peek-chip-title",text:this.compactChrome?this.handle.title:"QuickAdd is waiting"}),this.compactChrome||(a.createDiv({cls:"qa-peek-chip-subtitle",text:this.handle.title}),i.createEl("p",{cls:"qa-peek-chip-hint",text:"Look at the note, copy or select text, then come back. Your draft is still there."}));let l=i.createDiv({cls:"qa-peek-chip-actions"});this.insertButton=new xi.ButtonComponent(l).setButtonText(this.compactChrome?"Insert":"Insert selection").setCta().setTooltip("Drop the selected text into your draft and return").onClick(()=>this.insertSelectionAndResume()),this.insertButton.buttonEl.setAttribute("aria-label","Insert the selected text and return to QuickAdd"),new xi.ButtonComponent(l).setButtonText("Return").setTooltip("Go back to the prompt without inserting").onClick(()=>this.resume());let c=new xi.ButtonComponent(l).setTooltip("Discard this run").onClick(()=>this.cancel());if(c.buttonEl.addClass("qa-peek-chip-cancel"),c.buttonEl.setAttribute("aria-label","Cancel this run"),this.compactChrome){let u=xr(c.buttonEl,"span");u.className="qa-peek-chip-cancel-icon",u.setAttribute("aria-hidden","true"),(0,xi.setIcon)(u,"x"),c.buttonEl.replaceChildren(u)}else c.setButtonText("Cancel");xi.Platform.isMobile||i.createEl("p",{cls:"qa-peek-chip-keys",text:zU()}),this.chipEl=i,this.refreshInsertButton(),this.listenForSelection(),this.listenForChipEscape(),this.pushReturnShortcut()}listenForSelection(){let e=(0,xi.debounce)(()=>this.refreshInsertButton(),100,!0);this.selectionListener=e,this.selectionDocuments=Yee(this.app,this.chipEl?.ownerDocument??document);for(let t of this.selectionDocuments)t.addEventListener("selectionchange",e)}refreshInsertButton(){let e=this.insertButton;if(!e)return;let t=tp(this.app),n=t.length>0,i=n&&!this.compactChrome?jU(t):"";n===this.hasSelection&&i===this.selectionPreview||(this.hasSelection=n,this.selectionPreview=i,e.setDisabled(!n),e.buttonEl.classList.toggle("qa-peek-insert-ready",n),this.compactChrome||e.setButtonText(n?`Insert \u201C${i}\u201D`:"Insert selection"))}listenForChipEscape(){let e=this.chipEl;e&&(this.chipKeyListener=t=>{if(t.isComposing||t.key!=="Escape")return;let n=t.target;!(n instanceof Node)||!e.contains(n)||(t.preventDefault(),this.resume())},e.addEventListener("keydown",this.chipKeyListener))}pushReturnShortcut(){this.returnScope=new xi.Scope(this.app.scope),this.returnScope.register(["Mod","Shift"],ZP,()=>(this.resume(),!1)),this.app.keymap.pushScope(this.returnScope)}destroy(){if(Ra.active===this&&(Ra.active=null),this.returnScope&&(this.app.keymap.popScope(this.returnScope),this.returnScope=null),this.chipKeyListener&&this.chipEl&&(this.chipEl.removeEventListener("keydown",this.chipKeyListener),this.chipKeyListener=null),this.selectionListener){for(let e of this.selectionDocuments)e.removeEventListener("selectionchange",this.selectionListener);this.selectionListener.cancel?.(),this.selectionListener=null}this.selectionDocuments=[],this.chipEl?.remove(),this.chipEl=null,this.insertButton=null}};Ra.active=null;Ou=Ra});function Kee(r){Nn(r)?.editor?.focus?.()}var YU,Im,oF=b(()=>{vl();iF();JP();nF();YU="qa-prompt-peek-hidden",Im=class{constructor(e){this.host=e;this.peeking=!1;this.session=null}peek(){if(this.peeking)return;let e=this.host.getField();e&&this.host.setValue(e.value),this.host.persistDraft(),this.peeking=!0,this.hideModal(),this.session=Ou.activate(this.host.app,{title:this.host.title,resume:()=>this.resume(),cancel:()=>this.cancel(),insertSelectionAndResume:t=>this.insertSelectionAndResume(t)})}onHostOpened(){tF(this.host)}onHostClosed(){rF(this.host),this.peeking&&(this.peeking=!1,this.session?.discard(),this.session=null)}hideModal(){rF(this.host),this.host.containerEl.addClass(YU),this.host.app.keymap.popScope(this.host.scope),Kee(this.host.app)}showModal(){this.host.app.keymap.pushScope(this.host.scope),this.host.containerEl.removeClass(YU),tF(this.host),this.host.getField()?.focus()}resume(){this.peeking&&(this.peeking=!1,this.session=null,this.showModal())}insertSelectionAndResume(e){if(!this.peeking)return;let t=this.host.getField();if(t){let n=t.selectionStart??t.value.length,i=t.selectionEnd??n,o=HU(t.value,n,i,e);t.value=o.text,t.setSelectionRange(o.cursor,o.cursor),this.host.setValue(o.text)}else this.host.setValue(this.host.getValue()+e);this.host.markDraftChanged(),this.host.persistDraft(),this.resume()}cancel(){this.peeking&&(this.peeking=!1,this.session=null,this.host.app.keymap.pushScope(this.host.scope),this.host.close())}}});function KU(r){return xy.Platform.isPhone||(r?.innerWidth??Number.POSITIVE_INFINITY)<=540}function L_(r){let e=KU(r.ownerDocument.defaultView);return r.classList.toggle("qa-prompt-compact",e),e}function B_(r){let e=KU(r.buttonEl.ownerDocument.defaultView);r.setButtonText(e?Xee:Qee),r.setTooltip(WU(!xy.Platform.isMobile)),r.buttonEl.setAttribute("aria-label","Peek at the note. Your draft stays."),r.buttonEl.classList.add("qa-peek-button");let t=xr(r.buttonEl,"span");return t.className="qa-peek-button-icon",t.setAttribute("aria-hidden","true"),(0,xy.setIcon)(t,"eye"),r.buttonEl.prepend(t),r}var xy,Qee,Xee,sF=b(()=>{xy=require("obsidian");ka();Cy();Qee="Peek at note",Xee="Peek"});var Pm,Dr,$a=b(()=>{Pm=require("obsidian");jP();GP();YP();KP();QP();$_();Hr();oF();Cy();sF();Dr=class r extends Pm.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.supportsPeek()&&N_(t)){t.preventDefault(),this.peek.peek();return}if(this.isOptionalPrompt&&O_(t)){t.preventDefault(),this.skip();return}!t.isComposing&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new Sm({kind:"single",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.peek=new Im({app:t,title:this.header,containerEl:this.containerEl,scope:this.scope,getField:()=>this.inputComponent?.inputEl,getValue:()=>this.input,setValue:c=>{this.input=c},markDraftChanged:()=>this.draftHandler.markChanged(),persistDraft:()=>this.persistDraft(),close:()=>this.close()}),this.display(),this.open(),this.attachSuggesters()}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),L_(this.containerEl),this.contentEl.empty(),this.titleEl.textContent=this.header,P_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}get isOptionalPrompt(){return this.options?.optional===!0}supportsPeek(){return this.options?.allowPeek===!0}createInputField(t,n,i){let o=new Pm.TextComponent(t);return o.inputEl.setCssStyles({width:"100%"}),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=Dm(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new Pm.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv({cls:"qa-prompt-actions"}),i=n.createDiv({cls:"qa-prompt-actions-primary"});if(this.createButton(i,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(i,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let o=this.createButton(i,"Skip",this.skipClickCallback);o.setTooltip("Leave this field empty"),o.buttonEl.setAttribute("aria-label","Skip and leave empty")}if(this.supportsPeek()){let o=n.createDiv({cls:"qa-prompt-actions-secondary"});B_(this.createButton(o,"Peek at note",()=>this.peek.peek()))}}transformInputOnSubmit(t){return t}submit(){if(this.didSubmit||this.didClose)return;if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}let t=this.inputComponent?.inputEl?.value??this.input;this.input=this.transformInputOnSubmit(t),this.didSubmit=!0,this.close()}skip(){this.input="",this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise(rn())}onInputChanged(t){this.draftHandler.markChanged(),this.input=t}syncInputFromEl(){this.inputComponent?.inputEl&&(this.input=this.inputComponent.inputEl.value)}persistDraft(){this.draftHandler.persist(this.input,this.didSubmit)}attachSuggesters(){this.fileSuggester=new _m(this.app,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Am(this.app,this.inputComponent.inputEl)}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback),this.imagePasteHandle?.detach()}onOpen(){super.onOpen(),this.peek.onHostOpened(),I_(this.inputComponent.inputEl,this.options)}onClose(){this.didClose=!0,this.didSubmit||this.syncInputFromEl(),this.persistDraft(),this.peek.onHostClosed(),this.resolveInput(),this.removeInputListener(),this.fileSuggester?.destroy(),this.tagSuggester?.destroy(),super.onClose()}}});var Mm,Ty,U_=b(()=>{Me();Mm=r=>{M.logWarning(r)},Ty=()=>{}});function ste(r,e){let t=Math.min(r.length,e.length),n=0;for(;n<t&&r[n]===e[n];)n++;return n}function XU(r,e,t){if(r===e)return 0;if(Math.abs(r.length-e.length)>t||r.length>64||e.length>64)return t+1;let n=[],i=Array.from({length:e.length+1},(s,a)=>a),o=[];for(let s=1;s<=r.length;s++){o=new Array(e.length+1),o[0]=s;let a=o[0];for(let l=1;l<=e.length;l++){let c=r[s-1]===e[l-1]?0:1,u=Math.min(i[l]+1,o[l-1]+1,i[l-1]+c);s>1&&l>1&&r[s-1]===e[l-2]&&r[s-2]===e[l-1]&&(u=Math.min(u,n[l-2]+1)),o[l]=u,u<a&&(a=u)}if(a>t)return t+1;n=i,i=o}return i[e.length]}function ZU(r,e,t=3){let n=r.trim().toLowerCase();if(!n)return[];let i=e.map((a,l)=>({candidate:a,index:l})).filter(a=>a.candidate!==n),o=i.map(a=>({...a,distance:XU(n,a.candidate,2)})).filter(a=>a.distance<=1).sort((a,l)=>a.distance-l.distance||a.index-l.index);if(o.length>0)return o.slice(0,t).map(a=>a.candidate);if(n.length>=2){let a=i.map(l=>({...l,shared:ste(n,l.candidate)})).filter(l=>l.shared>=2).sort((l,c)=>c.shared-l.shared||l.index-c.index);if(a.length>0)return a.slice(0,t).map(l=>l.candidate)}return i.map(a=>({...a,distance:XU(n,a.candidate,2)})).filter(a=>a.distance<=2&&a.candidate.length>=10).sort((a,l)=>a.distance-l.distance||a.index-l.index).slice(0,t).map(a=>a.candidate)}var JU=b(()=>{});function _y(r){let t=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(r);return t?[0,t[0].length]:null}function Ay(r,e,t,n){let[i,o]=n??[Number.NaN,Number.NaN];if(!(n!==null&&e>=i&&e<=o))return{isInYaml:!1,isQuoted:!1,lineStart:0,lineEnd:0,baseIndent:"",isKeyValuePosition:!1,isListItemPosition:!1};let a=r.lastIndexOf(`
`,e-1)+1,l=r.indexOf(`
`,Math.max(e,t)),c=l===-1?r.length:l,u=r.slice(a,e),d=r.slice(t,c),f=(u.match(/^\s*/)||[""])[0],p=r[e-1]==='"'&&r[t]==='"'||r[e-1]==="'"&&r[t]==="'",m=u.replace(/["']$/,""),g=d.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,y=/:\s*$/.test(m)&&g,w=/^\s*-\s*$/.test(m)&&g;return{isInYaml:!0,isQuoted:p,lineStart:a,lineEnd:c,baseIndent:f,isKeyValuePosition:y,isListItemPosition:w}}var aF=b(()=>{});function eq(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(ate,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`)}function ky(r){return`"${eq(r)}"`}function lF(r,e,t){let n=Ay(r,e,t,_y(r));return!n.isInYaml||!n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}function Rm(r,e,t,n){return lF(r,e,t)?r[e-1]==='"'?eq(n):n.replace(/'/g,"''"):n}function cF(r,e,t){let n=Ay(r,e,t,_y(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var ate,uF=b(()=>{aF();ate=new RegExp("[\0-\x7F]","g")});function q_(r,e,t){let n=r.trim().toLowerCase();if(lte.has(n))return n;t?.(`QuickAdd: Unsupported multi-select format "${r}" in "${e}". Supported formats: auto, inline, yaml, markdown.`)}function cte(r,e){let t=r.lastIndexOf(`
`,e-1)+1;return r.slice(t,e).match(/^\s*/)?.[0]??""}function ute(r){return`- ${r.replace(/\r\n?|\n/g,`
`)}`}function tq(r){let{input:e,matchStart:t,values:n,format:i}=r;if(i==="auto")return;let o=n.map(a=>String(a));if(i==="inline")return o.join(",");if(i==="yaml")return`[${o.map(ky).join(", ")}]`;if(o.length===0)return"";let s=cte(e,t);return o.map(ute).join(`
${s}`)}var lte,W_=b(()=>{uF();lte=new Set(["auto","inline","yaml","markdown"])});function H_(r,e){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function pte(r){let e=r.map(t=>`"${t}"`);return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function rq(r,e){let t=H_(r,32),n=`{{FIELD:${H_(e,48)}}}`,i=dte.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;let o=ZU(r,z_);return o.length>0?`Unknown FIELD filter "${t}" - did you mean ${pte(o)}? Ignored in ${n}.`:`Unknown FIELD filter "${t}" in ${n} was ignored. Supported filters: ${z_.join(", ")}.`}function fte(r,e){let t=H_(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${H_(e,48)}}}.`}function mte(r,e,t){(t.warn??Mm)(rq(r,e))}var z_,dte,Ki,Nu=b(()=>{U_();up();JU();W_();z_=["folder","tag","inline","inline-code-blocks","exclude-folder","exclude-tag","exclude-file","default","default-from","default-empty","default-always","case-sensitive","multi","format"],dte=new Map([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);Ki=class{static parse(e,t){let n=Us(e).map(c=>c.trim()),i=n[0],o={},s=!1,a="auto",l=!1;for(let c=1;c<n.length;c++){let u=n[c];if(u.toLowerCase()==="multi"){s=!0;continue}let d=ho(u);if(!d){let m=u.toLowerCase();t?.warnUnknown&&m&&(t.warn??Mm)(z_.includes(m)?fte(m,e):rq(m,e));continue}let f=d.key,p=d.value;if(!z_.includes(f)){t?.warnUnknown&&mte(f,e,t);continue}switch(f){case"multi":s=Au(p);break;case"format":l=!0,a=q_(p,`{{FIELD:${e}}}`,t?.warn)??"auto";break;case"folder":o.folders||(o.folders=[]),o.folders.push(p),o.folder||(o.folder=p);break;case"tag":{o.tags||(o.tags=[]);let m=p.startsWith("#")?p.substring(1):p;o.tags.push(m);break}case"inline":o.inline=p.toLowerCase()==="true";break;case"inline-code-blocks":o.inlineCodeBlocks||(o.inlineCodeBlocks=[]),o.inlineCodeBlocks.push(...p.split(",").map(m=>m.trim().toLowerCase()).filter(m=>m.length>0));break;case"default":o.defaultValue=p;break;case"default-from":o.defaultFrom=p.toLowerCase();break;case"default-empty":o.defaultEmpty=p.toLowerCase()==="true";break;case"default-always":o.defaultAlways=p.toLowerCase()==="true";break;case"case-sensitive":o.caseSensitive=p.toLowerCase()==="true";break;case"exclude-folder":o.excludeFolders||(o.excludeFolders=[]),o.excludeFolders.push(p);break;case"exclude-tag":{o.excludeTags||(o.excludeTags=[]);let m=p.startsWith("#")?p.substring(1):p;o.excludeTags.push(m);break}case"exclude-file":o.excludeFiles||(o.excludeFiles=[]),o.excludeFiles.push(p);break}}return!s&&l&&(t?.warn?.(`QuickAdd: |format: needs |multi in "{{FIELD:${e}}}"; ignoring.`),a="auto"),{fieldName:i,filters:o,...s?{multiSelect:s}:{},...a!=="auto"?{multiFormat:a}:{}}}}});function dF(r){return r.replace(/^\/+|\/+$/g,"")}function Sy(r,e=t=>t){return JSON.stringify([...r].map(e).sort())}function nq(r,e){let t=[`folder=${dF(r)}`];return e.folders?.length&&t.push(`folders=${Sy(e.folders,dF)}`),e.tags?.length&&t.push(`tags=${Sy(e.tags)}`),e.excludeFolders?.length&&t.push(`xfolder=${Sy(e.excludeFolders,dF)}`),e.excludeTags?.length&&t.push(`xtag=${Sy(e.excludeTags)}`),e.excludeFiles?.length&&t.push(`xfile=${Sy(e.excludeFiles)}`),t.join("|")}function gte(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[nq(e,a),`mode=${t}`];return n&&l.push(`label=${n}`),i&&l.push("optional"),o&&l.push("custom"),s&&l.push("multi"),l.join("|")}function j_(r,e){if(!r)return null;let t=Us(r),n=(t.shift()??"").trim();if(!n)return null;let i=t,o=Da(i,"optional");i=o.remaining;let s=o.found,a=Da(i,"custom");i=a.remaining;let l=a.found,c=Da(i,"multi");i=c.remaining;let u=c.found,d="name",f=[];for(let C of i){let E=C.trim().toLowerCase();if(hte.has(E)){d=E;continue}f.push(C)}let p,m;for(let C of f){let E=ho(C);E&&(E.key==="label"&&E.value?p=E.value:E.key==="name"&&E.value&&(m=E.value))}let v=Ki.parse(r,{warn:e?.warn}),g=u||(v.multiSelect??!1),y=v.multiFormat??"auto",w={folder:n,tags:v.filters.tags,excludeFolders:v.filters.excludeFolders,excludeTags:v.filters.excludeTags,excludeFiles:v.filters.excludeFiles},k=m?`${Dy}name=${m}|${nq(n,w)}${g?"|multi":""}`:`${Dy}${gte({folderPath:n,mode:d,label:p,optional:s,allowCustomInput:l,multiSelect:g,filter:w})}`;return{raw:r,folderPath:n,mode:d,label:p,aliasName:m,optional:s,allowCustomInput:l,filter:w,multiSelect:g,multiFormat:y,variableKey:k}}function iq(r,e){if(!r)return r;for(let t of e)if(r===t)return r;return`${ls}${r}`}function Cp(r){return typeof r!="string"||r===""?{kind:"empty"}:r.startsWith(ls)?{kind:"custom",text:r.slice(ls.length)}:r.startsWith(Cl)?{kind:"file",path:r.slice(Cl.length)}:{kind:"raw",value:r}}function $m(r){return(r.split("/").pop()??r).replace(/\.(md|canvas|base)$/i,"")}function oq(r){return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function vte(r){if(!r)return;let e=Object.entries(r).find(([t])=>t.toLowerCase()==="title");return e?oq(e[1]):void 0}function yte(r){let e=r?.headings?.find(t=>t.level===1);return oq(e?.heading)}function bte(r){let e=r.parent?.path;return e&&e!=="/"?e:r.path.includes("/")?r.path.slice(0,r.path.lastIndexOf("/")):"vault root"}function wte(r){return r.basename?r.basename:$m(r.path)}function pF(r,e){let t=r.map(i=>{let o=e?.(i)??null,s=wte(i),a=vte(o?.frontmatter)??yte(o)??s,l=a===s?s:`${a} (${s})`;return{file:i,primary:a,label:l}}),n=new Map;for(let{label:i}of t)n.set(i,(n.get(i)??0)+1);return t.map(({file:i,primary:o,label:s})=>{let a=(n.get(s)??0)<=1?s:`${s} - ${bte(i)}`;return{primary:o,secondary:i.path,label:a}})}function Ac(r,e){return pF(r,e).map(t=>t.label)}var Dy,Cl,ls,hte,Gs=b(()=>{Nu();up();Dy="FILE:",Cl="@file:",ls="@filecustom:",hte=new Set(["name","link","path"])});function aq(r,e,t){return Array.isArray(r)?r.map(n=>sq(n,e,t)):sq(r,e,t)}function sq(r,e,t){if(e==="link")return t(r);let n=Cp(r);switch(n.kind){case"empty":return"";case"file":return e==="path"?n.path:$m(n.path);case"custom":case"raw":return n.kind==="custom"?n.text:n.value}}var lq=b(()=>{Gs()});function Ate(r){return Ete.test(r.trim())}function kte(r){let e=r.replace(Tte,"");return e===r?!1:!_te.test(e)}function G_(r,e){return Cte.has(r)?kte(e):Ate(e)}function Y_(r){return r==="noteTitle"||r==="captureTarget"||r==="folder"||r==="templatePath"||r==="lineTarget"||r==="filePath"}function fF(r){return r!=="templatePath"&&r!=="generic"}function K_(r,e){if(r==="generic")return{};let t=xte[r];return e?{title:t.ask,placeholder:t.hint}:{placeholder:t.partOf}}function Ste(r,e=44){if(r.length<=e)return r;let t=r.split("/");if(t.length===1)return r;let n=t[t.length-1];if(t.length===2){let s=`${cq}/${n}`;return s.length<r.length?s:r}let o=`${t[0]}/${cq}/${n}`;return o.length<r.length?o:r}function Iy(r,e,t){if(!r)return;let n=[],i=r.choiceName?.trim();i&&i!==e?.trim()&&n.push(i);let o=t?.showDestination===!1?void 0:r.destination?.trim();if(o){let s=t?.elide===!1?o:Ste(o);n.push(`\u2192 ${r.destinationKind==="folder"?`${s}/`:s}`)}return n.length?n.join(" "):void 0}var Cte,xte,Ete,Tte,_te,cq,Py=b(()=>{_t();Cte=new Set(["captureText"]),xte={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"},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"}},Ete=new RegExp(`^(?:${fc.source})$`,"i"),Tte=new RegExp(fc.source,"gi"),_te=/\{\{[^}\n\r]*\}\}/;cq="\u2026"});function Fy(r,e){if(!r||!e)return null;let t=r,n=t.metadataTypeManager??t.metadataCache?.app?.metadataTypeManager;if(!n||typeof n.getTypeInfo!="function")return null;let i=n.getTypeInfo(e),o=i?.expected?.type??i?.inferred?.type;return typeof o=="string"?o:null}function Pte(r){return r!==null&&Dte.has(r.toLowerCase())}function uq(r,e){return Ite.has(e.toLowerCase())||Pte(Fy(r,e))}var Dte,Ite,Q_=b(()=>{Dte=new Set(["aliases","list","multitext","tags"]),Ite=new Set(["aliases","cssclasses","tags"])});function Fte(r,e=","){let t=[],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 u=a-1;u>=0&&r[u]==="\\";u--)c++;c%2===0&&(o=null)}continue}if(l==='"'){o=l,n+=l;continue}if(l in dq){i.push(dq[l]),n+=l;continue}if(i.length>0){let c=i[i.length-1];l===c&&i.pop(),n+=l;continue}if(l===e){let c=n.trim();c.length>0&&t.push(c),n="";continue}n+=l}let s=n.trim();return s.length>0&&t.push(s),t}function Mte(r){return r.includes(`
`)?r.replace(/\r?\n/g,`
`):r.includes("\\n")?r.replace(/\\n/g,`
`):r}function Rte(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function pq(r,e){let t=r.trim();if(!t)return;let n=Mte(t),i=e?.propertyType??Fy(e?.app,e?.propertyKey),o=Rte(i),a=o||i===null,c=n.split(/\n/).map(u=>u.trim()).filter(u=>u.length>0);if(a&&c.length>0&&c.every(u=>/^-\s+/.test(u)))return c.map(u=>u.replace(/^-[\s]*/,"").trim());if(n.startsWith("[")&&n.endsWith("]")||n.startsWith("{")&&n.endsWith("}")){if(i&&!o&&i!=="list")return;try{return JSON.parse(n)}catch{}}if(n.includes(",")&&a){let u=Fte(n);if(u.length>1)return u}}var dq,fq=b(()=>{Q_();dq={"[":"]","(":")","{":"}","<":">"}});function X_(r){if(typeof r=="string"&&r.startsWith("@date:")){let e=r.substring(6),t=new Date(e);if(!Number.isNaN(t.getTime()))return t}return r}function mF(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function mq(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function hq(r){if(mF(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var My=b(()=>{});var gq,Oa,Z_=b(()=>{aF();fq();My();Q_();gq="\0",Oa=class{constructor(e){this.app=e;this.map=new Map;this.propertyTypeCache=new Map}maybeCollect(e){let{input:t,matchStart:n,matchEnd:i,rawValue:o,fallbackKey:s,collectionActive:a,heuristicEnabled:l}=e;if(!a)return;let c=_y(t),u=Ay(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),f=d.trim(),p=d.match(/^\s*([^:]+):/),m=p?p[1].trim():s,v=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,g=null;if(u.isKeyValuePosition?g=[m]:v.test(f)&&(g=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!g||g.length===0)return;let y=g[g.length-1],w=o;if(l&&typeof o=="string"){let C=pq(o,this.buildParseOptions(y));C!==void 0&&(w=C)}if(!mF(w)||Array.isArray(w)&&w.length===0||!l&&!mq(w))return;let k=g.join(gq);return this.map.set(k,w),w}drain(){let e=new Map(this.map);return this.map.clear(),e}merge(e){for(let[t,n]of e)this.map.set(t,n)}buildParseOptions(e){return{propertyKey:e,propertyType:this.resolvePropertyType(e),app:this.app}}findListParentPath(e,t,n){let i=t-1,o=[],s=n.length;for(;i>=0;){let a=e.lastIndexOf(`
`,i),l=a===-1?0:a+1,c=e.slice(l,i+1),u=c.trim();if(u.length===0){i=l-2;continue}if(u==="---"||u==="...")break;if(u.startsWith("-")){i=l-2;continue}let d=c.match(/^(\s*)([^:\n]+):/);if(d){let p=(d[1]??"").length;if(p<s&&(o.unshift(d[2].trim()),s=p,s===0))break}i=l-2}return o.length>0?o:null}resolvePropertyType(e){if(!this.app)return null;if(this.propertyTypeCache.has(e))return this.propertyTypeCache.get(e)??null;let t=Fy(this.app,e);return this.propertyTypeCache.set(e,t),t}};Oa.PATH_SEPARATOR=gq});function Om(r){return $te.has(r.toUpperCase())}var J_,eA,tA,$te,rA=b(()=>{J_=new RegExp("[\0-]","u"),eA=/[\\/:*?"<>|]/u,tA=/[. ]$/u,$te=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 vq(r){if(!r)return null;let e=r.trim().toLowerCase();switch(e){case"kebab":case"snake":case"camel":case"pascal":case"title":case"lower":case"upper":case"slug":return e;default:return null}}function $y(r){return vq(r)!==null}function hF(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function gF(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function nA(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function Ote(r){return/^\p{Ll}/u.test(r)&&nA(r)}function Nte(r){if(!r)return[];{let t=r.match(/^([\p{Ll}][\p{Lu}]{2,})([\p{N}]+)?$/u);if(t){let n=[t[1]];return t[2]&&n.push(t[2]),n}}if(/^[\p{Ll}][\p{Lu}][\p{Ll}]+(?:[\p{Lu}][\p{Ll}]+)*$/u.test(r))return[r];let e=r;return e=e.replace(/([\p{Lu}])([\p{Lu}][\p{Ll}])/gu,"$1 $2"),e=e.replace(/([\p{Ll}\p{N}])([\p{Lu}])/gu,"$1 $2"),e=e.replace(/([\p{L}])([\p{N}])/gu,"$1 $2"),e=e.replace(/([\p{N}])([\p{L}])/gu,"$1 $2"),e.trim().split(/\s+/u).map(t=>t.trim()).filter(Boolean)}function Lte(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(Nte).filter(Boolean)}function Oy(r,e){let t=vq(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=Lte(r);if(n.length===0)return"";switch(t){case"kebab":return n.map(i=>i.toLowerCase()).join("-");case"snake":return n.map(i=>i.toLowerCase()).join("_");case"camel":{let[i,...o]=n,s=i?Ote(i)?i:i.toLowerCase():"",a=o.map(l=>gF(l)||nA(l)?l:hF(l));return[s,...a].join("")}case"pascal":return n.map(i=>gF(i)||nA(i)?i:hF(i)).join("");case"title":return n.map(i=>gF(i)||nA(i)?i:hF(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return Om(i)?`${i}-`:i}default:return r}}var Ry,iA=b(()=>{rA();Ry=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function oA(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var vF=b(()=>{});function Ute(r,e,t){return t&&e?`${r}${yF}${e}`:r}function Ly(r){let e=r.indexOf(yF);return e===-1?r:r.slice(0,e)}function qte(r,e){let t=e.toLowerCase(),n=null;for(let i of r.keys())if(i.toLowerCase()===t&&r.get(i)!==void 0){if(n)return null;n=i}return n}function lA(r,e){if(!e)return null;let t=[e],n=Ly(e);n!==e&&t.push(n);for(let i of t){if(r.has(i)&&r.get(i)!==void 0)return i;let o=qte(r,i);if(o)return o}return null}function Wte(r){let{remaining:e,found:t}=Da(r,"optional");return{remaining:e,optional:t}}function Cq(r){let{remaining:e,optional:t}=Wte(r),{remaining:n,found:i}=Da(e,"trim");return{remaining:n,optional:t,trim:i}}function zte(r,e){let t=r.trim();if(!t)return!1;let n=ho(t);return n?(e?bF:aA).has(n.key):!1}function Hte(r,e){let t=e?bF:aA;return r.some(n=>{let i=ho(n.trim());if(!i||i.key!=="type"||!t.has("type"))return!1;let o=i.value.trim().toLowerCase();return o==="number"||o==="slider"})}function xq(r,e,t,n,i){if(r.length===0)return{defaultValue:"",allowCustomInput:!1,usesOptions:!1};let o=t?bF:aA,s=Hte(r,t),a=r.some(U=>zte(U,t)||s&&yq.has(ho(U.trim())?.key??"")),l=e&&r.some(U=>U.trim().toLowerCase()==="custom"),c=e&&r.some(U=>U.trim().toLowerCase()==="multi");if(!(a||l||c))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let d,f,p="",m=!1,v,g,y,w,k,C,E,x,D=!1,P,H;for(let U of r){let oe=U.trim();if(!oe)continue;if(e&&oe.toLowerCase()==="custom"){m=!0;continue}if(e&&oe.toLowerCase()==="multi"){D=!0;continue}let ce=ho(oe);if(!ce)continue;let{key:O,value:G}=ce;if(!(!o.has(O)&&!(s&&yq.has(O))))switch(O){case"label":G&&(d=G);break;case"case":G&&(f=G);break;case"default":p=G;break;case"custom":m=Au(G);break;case"type":G&&(v=G);break;case"min":g=G;break;case"max":y=G;break;case"step":w=G;break;case"text":k=G;break;case"optional":C=Au(G);break;case"trim":E=Au(G);break;case"multi":D=!0,P=G.trim().toLowerCase()==="linklist"?"linklist":"text";break;case"format":H=q_(G,n,i);break;case"name":G?x=G:i(`QuickAdd: empty |name: ignored in "${n}"; provide a variable name, e.g. {{VALUE:a,b|name:category}}.`);break;default:break}}return{label:d,caseStyle:f,defaultValue:p,allowCustomInput:m,name:x,usesOptions:!0,inputTypeOverride:v,minRaw:g,maxRaw:y,stepRaw:w,displayValuesRaw:k,optionalExplicit:C,trimExplicit:E,multiSelect:D,multiEmit:P,multiFormat:H}}function Eq(r,{tokenDisplay:e,hasOptions:t,allowCustomInput:n},i){if(!r)return;let o=r.trim().toLowerCase(),s=o==="boolean"?"checkbox":o;if(!Bte.has(s)){i(`QuickAdd: Unsupported VALUE type "${r}" in token "${e}". Supported types: multiline, number, slider, checkbox, text.`);return}if(t||n){i(`QuickAdd: Ignoring type:${s} for option-list VALUE token "${e}".`);return}return s}function Nm(r){if(r===void 0)return;let e=r.trim();if(!e)return;let t=Number(e);return Number.isFinite(t)?t:void 0}function jte(r){return r.minRaw!==void 0||r.maxRaw!==void 0||r.stepRaw!==void 0}function bq(r,e,t){let n=Nm(r.minRaw),i=Nm(r.maxRaw),o=Nm(r.stepRaw),s={};return r.minRaw!==void 0&&(n===void 0?t(`QuickAdd: Ignoring invalid min in VALUE token "${e}".`):s.min=n),r.maxRaw!==void 0&&(i===void 0?t(`QuickAdd: Ignoring invalid max in VALUE token "${e}".`):s.max=i),s.min!==void 0&&s.max!==void 0&&s.max<s.min&&(t(`QuickAdd: Ignoring invalid numeric range in VALUE token "${e}"; max must be greater than or equal to min.`),delete s.min,delete s.max),r.stepRaw!==void 0&&(o===void 0||o<=0?t(`QuickAdd: Ignoring invalid step in VALUE token "${e}"; step must be greater than 0.`):s.step=o),Object.keys(s).length>0?s:void 0}function Tq(r,e,t,n){if(t!=="number"&&t!=="slider")return jte(r)&&n(`QuickAdd: Ignoring numeric range options in "${e}" because type is not number or slider.`),{inputTypeOverride:t};if(t!=="slider"){let c=bq(r,e,n);return{inputTypeOverride:t,numericConfig:c}}let i=Nm(r.minRaw),o=Nm(r.maxRaw),s=r.stepRaw===void 0?1:Nm(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 "${e}" (${a}); falling back to type:number.`),{inputTypeOverride:"number",numericConfig:bq(r,e,Ty)};let l={min:i,max:o,step:s};return{inputTypeOverride:t,numericConfig:l,sliderConfig:l}}function wq(r){let e=String(r),t=/e-(\d+)$/i.exec(e);if(t)return Number(t[1]);let n=e.indexOf(".");return n===-1?0:e.length-n-1}function Gte(r,e){return String(Number(r.toFixed(e)))}function Na(r,e){let t=r?.trim()??"";if(!t)return"";let n=Number(t);if(!Number.isFinite(n))return"";let i=e?.min,o=e?.max,s=n;if(i!==void 0&&(s=Math.max(i,s)),o!==void 0&&(s=Math.min(o,s)),e?.step!==void 0&&e.step>0){let a=i??0,l=Math.round((s-a)/e.step);s=a+l*e.step,i!==void 0&&(s=Math.max(i,s)),o!==void 0&&(s=Math.min(o,s));let c=Math.max(wq(a),wq(e.step));return Gte(s,c)}return String(s)}function By(r,e){return Na(r,e)||String(e.min)}function sA(r){return r!==void 0&&Yte.has(r)}function Ny(r){let e=[],t="",n=!1;for(let i=0;i<r.length;i++){let o=r[i];if(n){if(sA(o)){if(sA(r[i+1])){t+='"',i++;continue}let s=i+1;for(;s<r.length&&Kte.test(r[s]);)s++;if(s>=r.length||r[s]===","){n=!1,i=s-1;continue}return r.split(",")}t+=o;continue}if(o===","){e.push(t),t="";continue}if(sA(o)&&t.trim()===""){n=!0,t="";continue}t+=o}return n?r.split(","):(e.push(t),e)}function wF(r){let e=r.trim();if(!sA(e[0]))return r;let t=Ny(e);return t.length===1&&t[0]!==e?t[0].trim():r}function Vy(r,e){if(!r)return null;let t=e?.warn??Mm,n=Us(r),i=(n.shift()??"").trim();if(!i)return null;let o=Ny(i).map(U=>U.trim()).filter(Boolean),s=o.length>1,{remaining:a,optional:l,trim:c}=Cq(n),u=`{{VALUE:${r}}}`,d=xq(a,s,!0,u,t),{label:f,caseStyle:p,defaultValue:m,allowCustomInput:v}=d,g=d.multiSelect??!1,y=d.multiEmit??"text",w=d.multiFormat??"auto",k=d.optionalExplicit??l,C=d.trimExplicit??c;if(!d.usesOptions){let U=m;v=s&&U.toLowerCase()==="custom",m=v?"":U}s&&m&&(m=wF(m));let E=Eq(d.inputTypeOverride,{tokenDisplay:u,hasOptions:s,allowCustomInput:v},t),x=Tq(d,u,E,t),D;if(d.displayValuesRaw!==void 0){if(!s)throw new Error(`QuickAdd: VALUE option "text" is only supported for option-list tokens in "${u}".`);if(D=Ny(d.displayValuesRaw).map(U=>U.trim()).filter(Boolean),D.length!==o.length)throw new Error(`QuickAdd: VALUE token "${u}" must define the same number of text entries and item entries. To include a comma inside one entry, wrap it in double quotes, e.g. "a, b".`);if(new Set(D).size!==D.length)throw new Error(`QuickAdd: VALUE token "${u}" has duplicate text entries. Text entries must be unique.`)}let P=d.name?.trim()||void 0;P&&P.includes(yF)&&(t(`QuickAdd: |name in "${u}" contains a reserved control character and was ignored.`),P=void 0),P&&Vte.has(P.toLowerCase())&&(t(`QuickAdd: |name:${P} is reserved and was ignored in "${u}". Choose a different name.`),P=void 0),P&&!s&&t(`QuickAdd: |name on a single value in "${u}" is redundant \u2014 use {{VALUE:${P}}} directly.`),p&&!$y(p)&&(t(`QuickAdd: Unsupported |case style "${p}" in token "${u}". Supported styles: ${Ry.join(", ")}.`),p=void 0),g&&!s&&(t(`QuickAdd: |multi needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),g=!1),g&&p&&(t(`QuickAdd: |case is ignored with |multi in "${u}" \u2014 a list is not case-transformed.`),p=void 0),!g&&d.multiFormat!==void 0&&(t(`QuickAdd: |format: needs |multi in "${u}"; ignoring.`),w="auto"),!s&&!d.usesOptions&&a.some(U=>U.trim().toLowerCase()==="custom")&&(t(`QuickAdd: |custom needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),m.toLowerCase()==="custom"&&(m=""));let H=P||Ute(i,f,s);return{raw:r,variableName:i,aliasName:P,variableKey:H,label:f,caseStyle:p,defaultValue:m,allowCustomInput:v,suggestedValues:o,displayValues:D,hasOptions:s,inputTypeOverride:x.inputTypeOverride,numericConfig:x.numericConfig,sliderConfig:x.sliderConfig,optional:k,trim:C,multiSelect:g,multiEmit:y,multiFormat:w}}function CF(r,e){let t=e?.warn??Mm,n=pV(r),i=Us(n).map(v=>v.trim()).filter(Boolean),{remaining:o,optional:s,trim:a}=Cq(i);if(o.length===0)return{defaultValue:"",optional:s,trim:a};let l=`{{VALUE${r}}}`,c=xq(o,!1,!1,l,t);if(c.displayValuesRaw!==void 0)throw new Error(`QuickAdd: VALUE option "text" is only supported for option-list tokens in "${l}".`);let{label:u,caseStyle:d,defaultValue:f}=c;c.usesOptions||(f=f.trim()),d&&!$y(d)&&(t(`QuickAdd: Unsupported |case style "${d}" in token "${l}". Supported styles: ${Ry.join(", ")}.`),d=void 0);let p=Eq(c.inputTypeOverride,{tokenDisplay:l,hasOptions:!1,allowCustomInput:c.allowCustomInput},t),m=Tq(c,l,p,t);return{label:u,caseStyle:d,defaultValue:f,inputTypeOverride:m.inputTypeOverride,numericConfig:m.numericConfig,sliderConfig:m.sliderConfig,optional:c.optionalExplicit??s,trim:c.trimExplicit??a}}var yF,Bte,yq,aA,bF,Vte,Yte,Kte,xl=b(()=>{up();iA();W_();U_();yF="",Bte=new Set(["multiline","number","slider","checkbox","text"]),yq=new Set(["min","max","step"]),aA=new Set(["label","default","custom","type","case","text","optional","trim","multi","format"]),bF=new Set([...aA,"name"]),Vte=new Set(["value","title"]);Yte=new Set(['"',"\u201C","\u201D"]);Kte=/[^\S\r\n]/});function Uy(r){if(!r)return{optional:!1,withTime:!1};let{remaining:e,found:t}=Da(Us(r),"optional"),{remaining:n,found:i}=Da(e,"time"),{remaining:o,found:s}=Da(n,"datetime"),a,l=!1,c,u,d=[];for(let p of o){let m=ho(p.trim());if(m?.key==="optional"){a=Au(m.value);continue}if(m?.key==="type"){m.value.trim().toLowerCase()==="datetime"&&(l=!0);continue}if(m?.key==="startof"||m?.key==="endof"){c||(c={boundary:m.key==="startof"?"start":"end",unit:o_(m.value)});continue}if(m?.key==="case"){u=m.value.trim()||void 0;continue}d.push(p)}return{defaultValue:d.join("|").trim()||void 0,optional:a??t,withTime:i||s||l,snap:c,...u?{caseStyle:u}:{}}}function cA(r){try{return{options:Uy(r)}}catch(e){return{options:{optional:!1,withTime:!1},error:e instanceof Error?e.message:String(e)}}}var qy=b(()=>{up();sy()});function _q(r){if(!r)return null;let e=r.indexOf("|");if(e===-1){let o=r.trim();return o?{macroName:o}:null}let t=r.slice(0,e).trim();if(!t)return null;let n=r.slice(e+1).trim();if(!n)return{macroName:t};if(!n.toLowerCase().startsWith("label:"))return null;let i=n.slice(6).trim();return{macroName:t,label:i||void 0}}var Aq=b(()=>{});function Lu(r){if(r==null)return"";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);if(typeof r=="bigint"||typeof r=="symbol")return r.toString();if(r instanceof Error)return r.message;try{return JSON.stringify(r)??Object.prototype.toString.call(r)}catch{return Object.prototype.toString.call(r)}}function Bu(r){return Qte.includes(r)}function Dq(r){switch(r){case"lessThan":case"lessThanOrEqual":case"greaterThan":case"greaterThanOrEqual":return"number";case"equals":case"notEquals":return"string";case"contains":case"notContains":return"string";default:return"boolean"}}function Iq(r){if(!Bu(r.operator)||r.expectedValue===void 0||r.expectedValue===null)return;let e=r.expectedValue.trim();switch(r.valueType){case"number":{let t=Number(e);return Number.isNaN(t)?NaN:t}case"boolean":{let t=e.toLowerCase();return kq.has(t)?!0:Sq.has(t)?!1:!!e}default:return e}}function xF(r,e){switch(e){case"number":return typeof r=="number"?r:typeof r=="boolean"?r?1:0:Number(r);case"boolean":if(typeof r=="boolean")return r;if(typeof r=="string"){let t=r.trim().toLowerCase();if(kq.has(t))return!0;if(Sq.has(t))return!1}return!!r;default:return r==null?"":Lu(r)}}function Xte(r){if(!Bu(r.operator))return"";let e=r.expectedValue??"";return e.length===0?"(empty)":r.valueType==="string"?`"${e}"`:e}function Zte(r){let e=r.variableName?`$${r.variableName}`:"(missing variable)",t=ere(r.operator),n=Bu(r.operator)?` ${Xte(r)}`:"";return`${e} ${t}${n}`.trim()}function Jte(r){let e=r.exportName?`::${r.exportName}`:"";return`script ${r.scriptPath}${e}`}function Lm(r){return r.mode==="variable"?Zte(r):Jte(r)}function ere(r){switch(r){case"equals":return"equals";case"notEquals":return"does not equal";case"lessThan":return"is less than";case"lessThanOrEqual":return"is less than or equal to";case"greaterThan":return"is greater than";case"greaterThanOrEqual":return"is greater than or equal to";case"contains":return"contains";case"notContains":return"does not contain";case"isTruthy":return"is truthy";case"isFalsy":return"is falsy";default:return r}}var Qte,kq,Sq,Bm=b(()=>{Qte=["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","contains","notContains"],kq=new Set(["true","1","yes","on"]),Sq=new Set(["false","0","no","off"])});function Wy(r){let e=[],t=r.length,n=0;for(;n<t;){let i=r.indexOf("`",n);if(i===-1)break;let o=i;for(;o<t&&r[o]==="`";)o++;if(o-i<3||!r.startsWith(EF,o)){n=o;continue}let s=o+EF.length,a=-1;for(;s<t;){let l=r.indexOf("`",s);if(l===-1)break;let c=l;for(;c<t&&r[c]==="`";)c++;if(c-l>=3){a=c;break}s=c}if(a===-1)break;e.push({start:i,end:a}),n=a}return e}function Fq(r){let e=Wy(r),t=r.length,n=e.length>0?e[e.length-1].end:0;for(;n<t;){let i=r.indexOf("`",n);if(i===-1)return!1;let o=i;for(;o<t&&r[o]==="`";)o++;if(o-i>=3&&r.startsWith(EF,o))return!0;n=o}return!1}function zy(r){return r?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"}function Hy(r,e,t,n){if(r===void 0)return null;let i=r,o;if(typeof i=="string"&&i&&!i.startsWith("@date:")){if(n){let s=le.getState().dateAliases,a=n.parseDate(Hv(i,s));a&&(o=`@date:${a.moment.toISOString()}`,i=o)}}else i instanceof Date&&(Number.isNaN(i.getTime())||(o=`@date:${i.toISOString()}`,i=o));if(typeof i=="string"&&i.startsWith("@date:")){let s=i.substring(6);if(n&&window.moment){let a=window.moment(s);if(a?.isValid())return{text:dm(a,t).format(e),...o!==void 0?{normalized:o}:{}}}return{text:"",...o!==void 0?{normalized:o}:{}}}return typeof i=="string"&&i?{text:i}:i!=null?{text:Lu(i)}:{text:""}}var Pq,tre,uA,EF,El,Vm=b(()=>{Pq=require("obsidian");_t();Gs();lq();Py();qt();Me();Z_();Pt();Gd();iA();My();uF();W_();vF();Nu();xl();U_();qy();sy();Aq();Bm();tre=new Set(["number","slider","checkbox"]),uA=10,EF="js quickadd";El=class{constructor(e){this.app=e;this.variables=new Map;this.linkToCurrentFileBehavior="required";this.targetFolderPath=null;this.promptScope="generic";this.promptScopeSoleValue=!1;this.templatePropertyCollectionDepth=0;this.namedSuggesterOptionSigs=new Map;this.namedSuggesterConflictsWarned=new Set;this.warnSink=e=>this.warn(e);this.propertyCollector=new Oa(e)}warn(e){M.logWarning(e)}reportProblem(e){M.logError(e)}setTemplateInclusionState(e){this.templateInclusion=e}setPromptRunContext(e){this.promptRunContext={...this.promptRunContext,...e}}getPromptRunContext(){return this.promptRunContext}async withPromptScope(e,t,n){let i=this.promptScope,o=this.promptScopeSoleValue;this.promptScope=e,this.promptScopeSoleValue=G_(e,t);try{return await n()}finally{this.promptScope=i,this.promptScopeSoleValue=o}}hasConcreteVariable(e){return this.variables.has(e)?this.variables.get(e)!==void 0:!1}setTitle(e){this.hasConcreteVariable("title")||this.variables.set("title",e)}getAnonymousValue(){return this.value}replacer(e,t,n){return e.replace(t,function(){return n})}applyCaseOption(e,t,n){return t?$y(t)?Oy(e,t):(this.warn(`QuickAdd: Unsupported |case style "${t}" in token "${n}". Supported styles: ${Ry.join(", ")}.`),e):e}replaceDateInString(e){let t=e;for(;NT.test(t);){let n=NT.exec(t),i;if(n&&n[1]){let a=n[1].replace("+","").trim();A0.test(a)&&(i=parseInt(a))}let o=n?.[2]?tP(n[2])??void 0:void 0,s=qs({offset:i,snap:o});t=this.replacer(t,NT,this.applyCaseOption(s,n?.[3],n?.[0]??"{{DATE}}"))}for(;Jf.test(t);){let n=Jf.exec(t);if(!n)throw new Error(`Unable to parse date format. Invalid syntax in: "${t.substring(Math.max(0,t.search(Jf)-10),Math.min(t.length,t.search(Jf)+30))}..."`);let i=n[1],o;if(n[2]){let l=n[2].replace("+","").trim();A0.test(l)&&(o=parseInt(l))}let s=n[3]?tP(n[3])??void 0:void 0,a=qs({format:i,offset:o,snap:s});t=this.replacer(t,Jf,this.applyCaseOption(a,n[4],n[0]))}return t}replaceTimeInString(e){let t=e;for(;em.test(t);){let n=em.exec(t);if(!n)throw new Error(`Unable to parse time format. Invalid syntax in: "${t.substring(Math.max(0,t.search(em)-10),Math.min(t.length,t.search(em)+30))}..."`);let i=qs({format:"HH:mm"});t=this.replacer(t,em,this.applyCaseOption(i,n[1],n[0]))}for(;tm.test(t);){let n=tm.exec(t);if(!n)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${t.substring(Math.max(0,t.search(tm)-10),Math.min(t.length,t.search(tm)+30))}..."`);let i=n[1],o=qs({format:i});t=this.replacer(t,tm,this.applyCaseOption(o,n[2],n[0]))}return t}async replaceValueInString(e){let t=e;if(!fc.test(t))return t;if(this.valuePromptContext=this.getValuePromptContext(t),this.hasConcreteVariable("value")){let i=this.variables.get("value");this.value=Lu(i)}this.value===void 0&&(this.value=await this.promptForValue());let n=new RegExp(fc.source,"gi");return t=t.replace(n,(...i)=>{let o=i[0],s=i[i.length-2],a=i[i.length-1],l=o.slice(2,-2),c=l.indexOf("|");if(c===-1)return Rm(a,s,s+o.length,this.value);let u=l.slice(c),d=CF(u,{warn:this.warnSink}),f=this.value===""&&d.defaultValue&&!d.optional?d.defaultValue:this.value,p=this.applyValueTextOptions(f,d);return d.inputTypeOverride==="text"&&p!==""&&cF(a,s,s+o.length)?ky(p):Rm(a,s,s+o.length,p)}),t}applyValueTextOptions(e,t){let n=String(e??""),i=t.trim?n.trim():n;return Oy(i,t.caseStyle)}applyValueTokenOptions(e,t){return Array.isArray(e)?t.trim?e.map(n=>typeof n=="string"?n.trim():n):e:typeof e=="string"?this.applyValueTextOptions(e,t):e}getValuePromptContext(e){let t=new RegExp(fc.source,"gi"),n,i;for(;(n=t.exec(e))!==null;){let s=n[0].slice(2,-2),a=s.indexOf("|");if(a===-1)continue;let l=s.slice(a),c=CF(l,{warn:Ty});i||(i={}),!i.description&&c.label&&(i.description=c.label),!i.defaultValue&&c.defaultValue&&(i.defaultValue=c.defaultValue),c.inputTypeOverride&&!i.inputTypeOverride&&(i.inputTypeOverride=c.inputTypeOverride),c.numericConfig&&!i.numericConfig&&(i.numericConfig=c.numericConfig),c.sliderConfig&&!i.sliderConfig&&(i.sliderConfig=c.sliderConfig),c.optional&&(i.optional=!0)}return i}async replaceSelectedInString(e){if(!I0.test(e))return e;let t=await this.getSelectedText(),n=new RegExp(I0.source,"gi");return e.replace(n,()=>t)}async replaceClipboardInString(e){if(!P0.test(e))return e;let t=await this.getClipboardContent(),n=new RegExp(P0.source,"gi");return e.replace(n,()=>t)}async replaceLinkToCurrentFileInString(e){if(!k0.test(e))return e;let t=this.getCurrentFileLink();if(!t){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");M.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.")}let n=new RegExp(k0.source,"gi");return e.replace(n,()=>t??"")}replaceLinkToCurrentSectionInString(e){if(!S0.test(e))return e;let t=this.getCurrentFileLinkToSection();if(!t){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");M.logMessage("Skipping {{LINKSECTION}} replacement because no active file is available.")}let n=new RegExp(S0.source,"gi");return e.replace(n,()=>t??"")}replaceCurrentFileLinksInString(e){return this.replaceCurrentFileTokensInString(e,{links:!0})}replaceCurrentFileTokensInString(e,t){let n=/{{(?:(LINKCURRENT|LINKSECTION|FILENAMECURRENT|TITLE)|(FOLDERCURRENT|FOLDER)(\|name)?)}}/gi,i,o,s,a,l,c,u,d,f=!1,p=!1,m=!1,v=e.replace(n,(y,w,k,C)=>{if(k!==void 0&&k.toUpperCase()==="FOLDERCURRENT"){if(!t.activeFolder)return y;if(c===void 0)if(c=this.getCurrentFolderPath(),c===null)u=null;else{let E=c.lastIndexOf("/");u=E===-1?c:c.slice(E+1)}return c===null&&(m=!0),(C?u:c)??""}if(k!==void 0){if(!t.folder)return y;if(a===void 0){a=this.targetFolderPath??"";let E=a.lastIndexOf("/");l=E===-1?a:a.slice(E+1)}return C?l:a}switch((w??"").toUpperCase()){case"LINKCURRENT":return t.links?(i===void 0&&(i=this.getCurrentFileLink()??null),i||(f=!0),i??""):y;case"LINKSECTION":return t.links?(o===void 0&&(o=this.getCurrentFileLinkToSection()??null),o||(f=!0),o??""):y;case"FILENAMECURRENT":return t.fileName?(s===void 0&&(s=this.getCurrentFileName()??null),s||(p=!0),s??""):y;case"TITLE":return t.title?(d===void 0&&(d=this.getVariableValue("title")),d):y}return y}),g="Unable to get the active file's folder. Make sure you have a file open in the editor.";if(m&&t.activeFolder==="path")throw new Error(g);if(f||p||m){if(this.linkToCurrentFileBehavior==="required")throw new Error(f?"Unable to get current file path. Make sure you have a file open in the editor.":p?"Unable to get current file name. Make sure you have a file open in the editor.":g);M.logMessage("Skipping current-file token replacement because no active file is available.")}return v}async replaceCurrentFileNameInString(e){return this.replaceCurrentFileTokensInString(e,{fileName:!0})}setLinkToCurrentFileBehavior(e){this.linkToCurrentFileBehavior=e}setTargetFolderPath(e){if(e==null){this.targetFolderPath=null;return}let t=e.trim();this.targetFolderPath=t==="/"?"":t.replace(/^\/+/,"").replace(/\/+$/,"")}replaceTargetFolderInString(e){return this.replaceCurrentFileTokensInString(e,{folder:!0})}getAndClearTemplatePropertyVars(){return this.propertyCollector.drain()}mergeTemplatePropertyVars(e){this.propertyCollector.merge(e)}renderCollectedOrArrayValue(e){if(Array.isArray(e.rawValue)&&e.multiFormat){let i=tq({input:e.input,matchStart:e.matchStart,values:e.rawValue,format:e.multiFormat});if(i!==void 0)return i}let t=this.propertyCollector.maybeCollect({...e,collectionActive:this.templatePropertyCollectionDepth>0}),n=hq(t);if(n!==void 0)return n;if(Array.isArray(e.rawValue))return Rm(e.input,e.matchStart,e.matchEnd,e.rawValue.join(","))}async withTemplatePropertyCollection(e){this.templatePropertyCollectionDepth+=1;try{return await e()}finally{this.templatePropertyCollectionDepth-=1}}getCurrentFileLinkToSection(){return null}getCurrentFolderPath(){return null}warnOnNamedOptionConflict(e){if(!e.aliasName||!e.hasOptions)return;let t=e.variableKey.toLowerCase(),n=JSON.stringify([e.suggestedValues,e.allowCustomInput,e.displayValues??null,e.multiSelect,e.multiEmit]),i=this.namedSuggesterOptionSigs.get(t);if(i===void 0){this.namedSuggesterOptionSigs.set(t,n);return}i!==n&&!this.namedSuggesterConflictsWarned.has(t)&&(this.namedSuggesterConflictsWarned.add(t),this.warn(`QuickAdd: named value "${e.variableKey}" is defined with different option lists; the first definition's value is reused.`))}async ensureValueVariableResolved(e){let{variableName:t,variableKey:n,label:i,defaultValue:o,allowCustomInput:s,suggestedValues:a,displayValues:l,hasOptions:c}=e;this.warnOnNamedOptionConflict(e);let u=lA(this.variables,n);if(u)return u;let d=!c&&i?i:void 0,f=c&&i?i:void 0;if(c&&e.multiSelect){let m=await this.suggestForValueMulti(a,s,{placeholder:f,variableKey:n,displayValues:l,optional:e.optional});return this.variables.set(n,e.multiEmit==="linklist"?m.map(oA):m),n}let p="";return c?p=await this.suggestForValue(a,s,{placeholder:f,variableKey:n,displayValues:l,optional:e.optional}):p=await this.promptForVariable(t,{defaultValue:o,description:d,inputTypeOverride:e.inputTypeOverride,numericConfig:e.numericConfig,sliderConfig:e.sliderConfig,variableKey:n,optional:e.optional}),!p&&o&&!e.optional&&(p=o),this.variables.set(n,p),n}async resolveNamedSuggesterDefinitions(e){if(!/\|\s*name\s*:/i.test(e))return;let t=new RegExp(Kd.source,"gi"),n=[],i;for(;(i=t.exec(e))!==null;){if(!i[1])continue;let a;try{a=Vy(i[1],{warn:Ty})}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(e){let t=e;await this.resolveNamedSuggesterDefinitions(t);let n=new RegExp(Kd.source,"gi"),i=this.isTemplatePropertyTypesEnabled(),o;for(;(o=n.exec(t))!==null;){if(!o[1])throw new Error(`Unable to parse variable. Invalid syntax in: "${t.substring(Math.max(0,o.index-10),Math.min(t.length,o.index+30))}..."`);let s=Vy(o[1],{warn:this.warnSink});if(!s)throw new Error(`Unable to parse variable. Invalid syntax in: "${t.substring(Math.max(0,o.index-10),Math.min(t.length,o.index+30))}..."`);let{variableName:a}=s,l=await this.ensureValueVariableResolved(s),c=this.variables.get(l),u=this.applyValueTokenOptions(c,s),d=this.renderCollectedOrArrayValue({input:t,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:u,fallbackKey:a,heuristicEnabled:i&&this.templatePropertyCollectionDepth>0&&s.inputTypeOverride!=="text",multiFormat:s.multiFormat}),f,p=!1;if(d!==void 0)f=d;else{let g=String(this.applyValueTextOptions(this.getVariableValue(l),s)??"");s.inputTypeOverride==="text"&&g!==""&&cF(t,o.index,o.index+o[0].length)?f=ky(g):tre.has(s.inputTypeOverride??"")&&lF(t,o.index,o.index+o[0].length)?(p=!0,f=g):f=Rm(t,o.index,o.index+o[0].length,g)}let m=p?o.index-1:o.index,v=o.index+o[0].length+(p?1:0);t=t.slice(0,m)+f+t.slice(v),n.lastIndex=m+f.length}return t}async replaceFieldVarInString(e){let t=new RegExp(LT.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index);let s=o[1]+(o[2]||"");if(s){let a=this.getFieldVariableKey(s),l=Ki.parse(s,{warnUnknown:!0,warn:this.warnSink});this.hasConcreteVariable(a)||this.variables.set(a,await this.suggestForField(s,l));let c=this.hasConcreteVariable(a)?this.variables.get(a):this.getVariableValue(a),u;Array.isArray(c)?u=this.renderCollectedOrArrayValue({input:e,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:c,fallbackKey:l.fieldName,heuristicEnabled:!1,multiFormat:l.multiFormat??"auto"})??c.join(","):u=Rm(e,o.index,o.index+o[0].length,String(c??"")),n+=u}else n+=o[0];i=t.lastIndex}return n+e.slice(i)}getFieldVariableKey(e){return`${Qd}${e}`}async replaceFileInString(e){let t=new RegExp(BT.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index);let s=j_(o[1]??"",{warn:this.warnSink});if(!s){n+=o[0],i=t.lastIndex;continue}let a=s.variableKey;this.hasConcreteVariable(a)||this.variables.set(a,await this.suggestForFile(s));let l=aq(this.variables.get(a),s.mode,c=>this.getFileLinkForStoredValue(c));if(Array.isArray(l)){let c=this.renderCollectedOrArrayValue({input:e,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:l,fallbackKey:s.aliasName??s.folderPath,heuristicEnabled:!1,multiFormat:s.multiFormat});n+=c??l.join(",")}else n+=l;i=t.lastIndex}return n+e.slice(i)}getFileLinkForStoredValue(e){let t=Cp(e);if(t.kind==="empty")return"";if(t.kind!=="file"){let o=t.kind==="custom"?t.text:t.value;return o?`[[${o}]]`:""}let n=t.path;if(!n)return"";let i=this.app?.vault.getAbstractFileByPath(n);return i instanceof Pq.TFile?this.app?.fileManager.generateMarkdownLink(i,this.getLinkSourcePath()??"")??`[[${$m(n)}]]`:`[[${$m(n)}]]`}getLinkSourcePath(){return null}async replaceMathValueInString(e){let t=new RegExp(VT.source,"gi"),n=this.variables.get("mvalue"),i=typeof n=="string"&&n.trim()?n:null,o="",s=0,a;for(;(a=t.exec(e))!==null;)o+=e.slice(s,a.index),o+=i??await this.promptForMathValue(),s=a.index+a[0].length;return o+=e.slice(s),o}async replaceMacrosInString(e){let t=e;for(;wu.test(t);){let n=wu.exec(t);if(!n)continue;if(!n[1]){t=this.replacer(t,wu,"");continue}let i=_q(n[1]);if(!i){t=this.replacer(t,wu,"");continue}let{macroName:o,label:s}=i,a=await this.getMacroValue(o,s?{label:s}:void 0);t=this.replacer(t,wu,a?a.toString():"")}return t}suggestForValueMulti(e,t,n){return[]}async replaceDateVariableInString(e){let t=new RegExp(bu.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index),i=o.index+o[0].length;let s=o[1]?.trim();if(!s){n+=o[0];continue}let{defaultValue:a,optional:l,withTime:c,snap:u,caseStyle:d}=Uy(o[3]),f=o[2]?.trim()||zy(c);if(this.variables.get(s)===void 0){let v=await this.promptForVariable(s,{type:"VDATE",dateFormat:f,defaultValue:a,optional:l,withTime:c});if(l&&!v?.trim())this.variables.set(s,"");else if(v?.startsWith("@date:"))this.variables.set(s,v);else{if(!this.dateParser)throw new Error("Date parser is not available");let g=le.getState().dateAliases,y=Hv(v,g),w=this.dateParser.parseDate(y);if(w)this.variables.set(s,`@date:${w.moment.toISOString()}`);else throw new Error(`unable to parse date variable ${v}${l?"":". Tip: add |optional inside the {{VDATE}} token to allow leaving this date empty"}`)}}let m=Hy(this.variables.get(s),f,u,this.dateParser);m?.normalized!==void 0&&this.variables.set(s,m.normalized),n+=this.applyCaseOption(m?.text??"",d,o[0])}return n+e.slice(i)}async replaceTemplateInString(e){let t=e;for(;Ns.test(t);){let n=Ns.exec(t);if(!n||!n[1])continue;let i=n[1];if(this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.visited.has(i)){let s=`[QuickAdd: template inclusion cycle detected at "${i}"]`;this.reportProblem(s),t=this.replacer(t,Ns,s);continue}if(this.templateInclusion.depth>=uA){let s=`[QuickAdd: max template inclusion depth (${uA}) exceeded at "${i}"]`;this.reportProblem(s),t=this.replacer(t,Ns,s);continue}this.templateInclusion.visited.add(i);let o;try{o=await this.getTemplateContent(i)}finally{this.templateInclusion.visited.delete(i)}t=this.replacer(t,Ns,o)}return t}replaceLinebreakInString(e){let t="";for(let n=0;n<e.length;n++){let i=e[n],o=e[n+1];i=="\\"?o=="n"?(t+=`
`,n++):o=="\\"?(t+="\\",n++):t+="\\":t+=i}return t}expandLinebreakEscapesOutsideTokens(e){let t=Wy(e),n="",i=0,o=0;for(;i<e.length;){for(;o<t.length&&t[o].end<=i;)o++;let s=t[o];if(s&&s.start===i){n+=e.slice(s.start,s.end),i=s.end;continue}if(e[i]==="{"&&e[i+1]==="{"){let c=e.indexOf("}}",i+2),u=!1;if(c!==-1){let d=c+2;for(let f=o;f<t.length;f++){let p=t[f];if(p.start>=d)break;if(d<p.end&&d>p.start){u=!0;break}}}if(c!==-1&&!u){n+=e.slice(i,c+2),i=c+2;continue}}let a=e[i],l=e[i+1];a==="\\"?l==="n"?(n+=`
`,i+=2):l==="\\"?(n+="\\",i+=2):(n+="\\",i+=1):(n+=a,i+=1)}return n}replaceRandomInString(e){let t=e;for(;F0.test(t);){let n=F0.exec(t);if(!n||!n[1])continue;let i=parseInt(n[1]);if(i<=0||i>100)throw new Error(`Random string length must be between 1 and 100. Got: ${i}`);let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s="";for(let a=0;a<i;a++)s+=o.charAt(Math.floor(Math.random()*o.length));t=t.replace(n[0],s)}return t}replaceTitleInString(e){return this.replaceCurrentFileTokensInString(e,{title:!0})}}});var j,Oe,cs,ft=b(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(j||(j={}));(function(r){r[r.SUNDAY=0]="SUNDAY",r[r.MONDAY=1]="MONDAY",r[r.TUESDAY=2]="TUESDAY",r[r.WEDNESDAY=3]="WEDNESDAY",r[r.THURSDAY=4]="THURSDAY",r[r.FRIDAY=5]="FRIDAY",r[r.SATURDAY=6]="SATURDAY"})(Oe||(Oe={}));(function(r){r[r.JANUARY=1]="JANUARY",r[r.FEBRUARY=2]="FEBRUARY",r[r.MARCH=3]="MARCH",r[r.APRIL=4]="APRIL",r[r.MAY=5]="MAY",r[r.JUNE=6]="JUNE",r[r.JULY=7]="JULY",r[r.AUGUST=8]="AUGUST",r[r.SEPTEMBER=9]="SEPTEMBER",r[r.OCTOBER=10]="OCTOBER",r[r.NOVEMBER=11]="NOVEMBER",r[r.DECEMBER=12]="DECEMBER"})(cs||(cs={}))});function nt(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function dA(r,e){r.assign("hour",e.getHours()),r.assign("minute",e.getMinutes()),r.assign("second",e.getSeconds()),r.assign("millisecond",e.getMilliseconds()),r.assign("meridiem",e.getHours()<12?j.AM:j.PM)}function kc(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Lt(r,e){r.imply("hour",e.getHours()),r.imply("minute",e.getMinutes()),r.imply("second",e.getSeconds()),r.imply("millisecond",e.getMilliseconds()),r.imply("meridiem",e.getHours()<12?j.AM:j.PM)}var on=b(()=>{ft()});function Uu(r,e,t,n,i=0){let o=0,s=0;for(;s<n;)o++,new Date(r,e-1,o).getDay()===t&&s++;return new Date(r,e-1,o,i)}function Rq(r,e,t,n=0){let i=t===0?7:t,o=new Date(r,e-1+1,1,12),s=o.getDay()===0?7:o.getDay(),a;return s===i?a=7:s<i?a=7+s-i:a=s-i,o.setDate(o.getDate()-a),new Date(r,e-1,o.getDate(),n)}function pA(r,e,t={}){if(r==null)return null;if(typeof r=="number")return r;let n=t[r]??ire[r];return n==null?null:typeof n=="number"?n:e==null?null:e>n.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}var ire,TF=b(()=>{ft();ire={ACDT:630,ACST:570,ADT:-180,AEDT:660,AEST:600,AFT:270,AKDT:-480,AKST:-540,ALMT:360,AMST:-180,AMT:-240,ANAST:720,ANAT:720,AQTT:300,ART:-180,AST:-240,AWDT:540,AWST:480,AZOST:0,AZOT:-60,AZST:300,AZT:240,BNT:480,BOT:-240,BRST:-120,BRT:-180,BST:60,BTT:360,CAST:480,CAT:120,CCT:390,CDT:-300,CEST:120,CET:{timezoneOffsetDuringDst:120,timezoneOffsetNonDst:60,dstStart:r=>Rq(r,cs.MARCH,Oe.SUNDAY,2),dstEnd:r=>Rq(r,cs.OCTOBER,Oe.SUNDAY,3)},CHADT:825,CHAST:765,CKT:-600,CLST:-180,CLT:-240,COT:-300,CST:-360,CT:{timezoneOffsetDuringDst:-300,timezoneOffsetNonDst:-360,dstStart:r=>Uu(r,cs.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Uu(r,cs.NOVEMBER,Oe.SUNDAY,1,2)},CVT:-60,CXT:420,ChST:600,DAVT:420,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEST:180,EET:120,EGST:0,EGT:-60,EST:-300,ET:{timezoneOffsetDuringDst:-240,timezoneOffsetNonDst:-300,dstStart:r=>Uu(r,cs.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Uu(r,cs.NOVEMBER,Oe.SUNDAY,1,2)},FJST:780,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GMT:0,GST:240,GYT:-240,HAA:-180,HAC:-300,HADT:-540,HAE:-240,HAP:-420,HAR:-360,HAST:-600,HAT:-90,HAY:-480,HKT:480,HLV:-210,HNA:-240,HNC:-360,HNE:-300,HNP:-480,HNR:-420,HNT:-150,HNY:-540,HOVT:420,ICT:420,IDT:180,IOT:360,IRDT:270,IRKST:540,IRKT:540,IRST:210,IST:330,JST:540,KGT:360,KRAST:480,KRAT:480,KST:540,KUYT:240,LHDT:660,LHST:630,LINT:840,MAGST:720,MAGT:720,MART:-510,MAWT:300,MDT:-360,MESZ:120,MEZ:60,MHT:720,MMT:390,MSD:240,MSK:180,MST:-420,MT:{timezoneOffsetDuringDst:-360,timezoneOffsetNonDst:-420,dstStart:r=>Uu(r,cs.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Uu(r,cs.NOVEMBER,Oe.SUNDAY,1,2)},MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:690,NOVST:420,NOVT:360,NPT:345,NST:-150,NUT:-660,NZDT:780,NZST:720,OMSST:420,OMST:420,PDT:-420,PET:-300,PETST:720,PETT:720,PGT:600,PHOT:780,PHT:480,PKT:300,PMDT:-120,PMST:-180,PONT:660,PST:-480,PT:{timezoneOffsetDuringDst:-420,timezoneOffsetNonDst:-480,dstStart:r=>Uu(r,cs.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Uu(r,cs.NOVEMBER,Oe.SUNDAY,1,2)},PWT:540,PYST:-180,PYT:-240,RET:240,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SRT:-180,SST:-660,TAHT:-600,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TVT:720,ULAT:480,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-210,VLAST:660,VLAT:660,VUT:660,WAST:120,WAT:60,WEST:60,WESZ:60,WET:0,WEZ:0,WFT:720,WGST:-120,WGT:-180,WIB:420,WIT:540,WITA:480,WST:780,WT:0,YAKST:600,YAKT:600,YAPT:600,YEKST:360,YEKT:360}});function yt(r,e){let t=new Date(r);if(e.y&&(e.year=e.y,delete e.y),e.mo&&(e.month=e.mo,delete e.mo),e.M&&(e.month=e.M,delete e.M),e.w&&(e.week=e.w,delete e.w),e.d&&(e.day=e.d,delete e.d),e.h&&(e.hour=e.h,delete e.h),e.m&&(e.minute=e.m,delete e.m),e.s&&(e.second=e.s,delete e.s),e.ms&&(e.millisecond=e.ms,delete e.ms),"year"in e){let n=Math.floor(e.year);t.setFullYear(t.getFullYear()+n);let i=e.year-n;i>0&&(e.month=e?.month??0,e.month+=i*12)}if("quarter"in e){let n=Math.floor(e.quarter);t.setMonth(t.getMonth()+n*3)}if("month"in e){let n=Math.floor(e.month);t.setMonth(t.getMonth()+n);let i=e.month-n;i>0&&(e.week=e?.week??0,e.week+=i*4)}if("week"in e){let n=Math.floor(e.week);t.setDate(t.getDate()+n*7);let i=e.week-n;i>0&&(e.day=e?.day??0,e.day+=Math.round(i*7))}if("day"in e){let n=Math.floor(e.day);t.setDate(t.getDate()+n);let i=e.day-n;i>0&&(e.hour=e?.hour??0,e.hour+=Math.round(i*24))}if("hour"in e){let n=Math.floor(e.hour);t.setHours(t.getHours()+n);let i=e.hour-n;i>0&&(e.minute=e?.minute??0,e.minute+=Math.round(i*60))}if("minute"in e){let n=Math.floor(e.minute);t.setMinutes(t.getMinutes()+n);let i=e.minute-n;i>0&&(e.second=e?.second??0,e.second+=Math.round(i*60))}if("second"in e){let n=Math.floor(e.second);t.setSeconds(t.getSeconds()+n);let i=e.second-n;i>0&&(e.millisecond=e?.millisecond??0,e.millisecond+=Math.round(i*1e3))}if("millisecond"in e){let n=Math.floor(e.millisecond);t.setMilliseconds(t.getMilliseconds()+n)}return t}function tt(r){let e={};for(let t in r)e[t]=-r[t];return e}var $q,Bt=b(()=>{$q={day:0,second:0,millisecond:0}});var ct,X,at,Le=b(()=>{on();TF();Bt();ct=class r{constructor(e,t){ae(this,"instant");ae(this,"timezoneOffset");this.instant=e??new Date,this.timezoneOffset=t??null}static fromDate(e){return new r(e)}static fromInput(e,t){if(e instanceof Date)return r.fromDate(e);let n=e?.instant??new Date,i=pA(e?.timezone,n,t);return new r(n,i)}getDateWithAdjustedTimezone(){let e=new Date(this.instant);return this.timezoneOffset!==null&&e.setMinutes(e.getMinutes()-this.getSystemTimezoneAdjustmentMinute(this.instant)),e}getSystemTimezoneAdjustmentMinute(e,t){e||(e=new Date);let n=-e.getTimezoneOffset(),i=t??this.timezoneOffset??n;return n-i}getTimezoneOffset(){return this.timezoneOffset??-this.instant.getTimezoneOffset()}},X=class r{constructor(e,t){ae(this,"knownValues");ae(this,"impliedValues");ae(this,"reference");ae(this,"_tags",new Set);if(this.reference=e,this.knownValues={},this.impliedValues={},t)for(let i in t)this.knownValues[i]=t[i];let n=e.getDateWithAdjustedTimezone();this.imply("day",n.getDate()),this.imply("month",n.getMonth()+1),this.imply("year",n.getFullYear()),this.imply("hour",12),this.imply("minute",0),this.imply("second",0),this.imply("millisecond",0)}static createRelativeFromReference(e,t=$q){let n=yt(e.getDateWithAdjustedTimezone(),t),i=new r(e);return i.addTag("result/relativeDate"),"hour"in t||"minute"in t||"second"in t||"millisecond"in t?(i.addTag("result/relativeDateAndTime"),dA(i,n),nt(i,n),i.assign("timezoneOffset",e.getTimezoneOffset())):(Lt(i,n),i.imply("timezoneOffset",e.getTimezoneOffset()),"day"in t?(i.assign("day",n.getDate()),i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear()),i.assign("weekday",n.getDay())):"week"in t?(i.assign("day",n.getDate()),i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear()),i.imply("weekday",n.getDay())):(i.imply("day",n.getDate()),"month"in t?(i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear())):(i.imply("month",n.getMonth()+1),"year"in t?i.assign("year",n.getFullYear()):i.imply("year",n.getFullYear())))),i}get(e){return e in this.knownValues?this.knownValues[e]:e in this.impliedValues?this.impliedValues[e]:null}isCertain(e){return e in this.knownValues}getCertainComponents(){return Object.keys(this.knownValues)}imply(e,t){return e in this.knownValues?this:(this.impliedValues[e]=t,this)}assign(e,t){return this.knownValues[e]=t,delete this.impliedValues[e],this}addDurationAsImplied(e){let t=this.dateWithoutTimezoneAdjustment(),n=yt(t,e);return("day"in e||"week"in e||"month"in e||"year"in e)&&(this.delete(["day","weekday","month","year"]),this.imply("day",n.getDate()),this.imply("weekday",n.getDay()),this.imply("month",n.getMonth()+1),this.imply("year",n.getFullYear())),("second"in e||"minute"in e||"hour"in e)&&(this.delete(["second","minute","hour"]),this.imply("second",n.getSeconds()),this.imply("minute",n.getMinutes()),this.imply("hour",n.getHours())),this}delete(e){typeof e=="string"&&(e=[e]);for(let t of e)delete this.knownValues[t],delete this.impliedValues[t]}clone(){let e=new r(this.reference);e.knownValues={},e.impliedValues={};for(let t in this.knownValues)e.knownValues[t]=this.knownValues[t];for(let t in this.impliedValues)e.impliedValues[t]=this.impliedValues[t];return e}isOnlyDate(){return!this.isCertain("hour")&&!this.isCertain("minute")&&!this.isCertain("second")}isOnlyTime(){return!this.isCertain("weekday")&&!this.isCertain("day")&&!this.isCertain("month")&&!this.isCertain("year")}isOnlyWeekdayComponent(){return this.isCertain("weekday")&&!this.isCertain("day")&&!this.isCertain("month")}isDateWithUnknownYear(){return this.isCertain("month")&&!this.isCertain("year")}isValidDate(){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")),!(e.getUTCFullYear()!==this.get("year")||e.getUTCMonth()!==this.get("month")-1||e.getUTCDate()!==this.get("day")||this.get("hour")!=null&&e.getUTCHours()!=this.get("hour")||this.get("minute")!=null&&e.getUTCMinutes()!=this.get("minute"))}toString(){return`[ParsingComponents {
tags: ${JSON.stringify(Array.from(this._tags).sort())},
knownValues: ${JSON.stringify(this.knownValues)},
impliedValues: ${JSON.stringify(this.impliedValues)}},
reference: ${JSON.stringify(this.reference)}]`}date(){let e=this.get("timezoneOffset")??this.reference.timezoneOffset;if(e==null)return this.dateWithoutTimezoneAdjustment();let t=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return t.setUTCFullYear(this.get("year")),new Date(t.getTime()-e*6e4)}addTag(e){return this._tags.add(e),this}addTags(e){for(let t of e)this._tags.add(t);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let e=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return e.setFullYear(this.get("year")),e}},at=class r{constructor(e,t,n,i,o){ae(this,"refDate");ae(this,"index");ae(this,"text");ae(this,"reference");ae(this,"start");ae(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new X(e),this.end=o}clone(){let e=new r(this.reference,this.index,this.text);return e.start=this.start?this.start.clone():null,e.end=this.end?this.end.clone():null,e}date(){return this.start.date()}addTag(e){return this.start.addTag(e),this.end&&this.end.addTag(e),this}addTags(e){return this.start.addTags(e),this.end&&this.end.addTags(e),this}tags(){let e=new Set(this.start.tags());if(this.end)for(let t of this.end.tags())e.add(t);return e}toString(){let e=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(e)} ...}]`}}});function Tr(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function ore(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function te(r){return`(?:${ore(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var ze=b(()=>{});function Gr(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function mt(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=yt(n,{year:1}),o=yt(n,{year:-1});return Math.abs(i.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())?n=i:Math.abs(o.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())&&(n=o),n.getFullYear()}var zt=b(()=>{Bt()});function sre(r){let e=r.toLowerCase();return _F[e]!==void 0?_F[e]:e==="a"||e==="an"||e=="the"?1:e.match(/few/)?3:e.match(/half/)?.5:e.match(/couple/)?2:e.match(/several/)?7:parseFloat(e)}function Wm(r){let e=r.toLowerCase();return AF[e]!==void 0?AF[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function Tl(r){if(/BE/i.test(r))return r=r.replace(/BE/i,""),parseInt(r)-543;if(/BCE?/i.test(r))return r=r.replace(/BCE?/i,""),-parseInt(r);if(/(AD|CE)/i.test(r))return r=r.replace(/(AD|CE)/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function Ys(r){let e={},t=r,n=Oq.exec(t);for(;n;)lre(e,n),t=t.substring(n[0].length).trim(),n=Oq.exec(t);return Object.keys(e).length==0?null:e}function lre(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=sre(e[1]),n=jy[e[2].toLowerCase()];r[n]=t}var fA,kF,vo,_F,AF,Nq,jy,Lq,qm,qu,Bq,Oq,are,Vq,Sc,Wu,sn=b(()=>{ze();zt();fA={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},kF={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},vo={...kF,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},_F={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},AF={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,"twenty fourth":24,"twenty-fourth":24,"twenty fifth":25,"twenty-fifth":25,"twenty sixth":26,"twenty-sixth":26,"twenty seventh":27,"twenty-seventh":27,"twenty eighth":28,"twenty-eighth":28,"twenty ninth":29,"twenty-ninth":29,thirtieth:30,"thirty first":31,"thirty-first":31},Nq={second:"second",seconds:"second",minute:"minute",minutes:"minute",hour:"hour",hours:"hour",day:"day",days:"day",week:"week",weeks:"week",month:"month",months:"month",quarter:"quarter",quarters:"quarter",year:"year",years:"year"},jy={s:"second",sec:"second",second:"second",seconds:"second",m:"minute",min:"minute",mins:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hrs:"hour",hour:"hour",hours:"hour",d:"day",day:"day",days:"day",w:"week",week:"week",weeks:"week",mo:"month",mon:"month",mos:"month",month:"month",months:"month",qtr:"quarter",quarter:"quarter",quarters:"quarter",y:"year",yr:"year",year:"year",years:"year",...Nq},Lq=`(?:${te(_F)}|[0-9]+|[0-9]+\\.[0-9]+|half(?:\\s{0,2}an?)?|an?\\b(?:\\s{0,2}few)?|few|several|the|a?\\s{0,2}couple\\s{0,2}(?:of)?)`;qm=`(?:${te(AF)}|[0-9]{1,2}(?:st|nd|rd|th)?)`;qu="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-9][0-9]{3}|[0-9]{2}(?!\\w|:\\d|\\s+(?:am|pm|o\\s*clock|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)))";Bq=`(${Lq})\\s{0,3}(${te(jy)})`,Oq=new RegExp(Bq,"i"),are=`(${Lq})\\s{0,3}(${te(Nq)})`,Vq="\\s{0,5},?(?:\\s*and)?\\s{0,5}",Sc=Tr("(?:(?:about|around)\\s{0,3})?",Bq,Vq),Wu=Tr("(?:(?:about|around)\\s{0,3})?",are,Vq)});var B,fe=b(()=>{B=class{constructor(){ae(this,"cachedInnerPattern",null);ae(this,"cachedPattern",null)}innerPatternHasChange(e,t){return this.innerPattern(e)!==t}patternLeftBoundary(){return"(\\W|^)"}pattern(e){return this.cachedInnerPattern&&!this.innerPatternHasChange(e,this.cachedInnerPattern)?this.cachedPattern:(this.cachedInnerPattern=this.innerPattern(e),this.cachedPattern=new RegExp(`${this.patternLeftBoundary()}${this.cachedInnerPattern.source}`,this.cachedInnerPattern.flags),this.cachedPattern)}extract(e,t){let n=t[1]??"";t.index=t.index+n.length,t[0]=t[0].substring(n.length);for(let i=2;i<t.length;i++)t[i-1]=t[i];return this.innerExtract(e,t)}}});var cre,ure,dre,Gy,Uq=b(()=>{sn();Le();fe();cre=new RegExp(`(?:(?:within|in|for)\\s*)?(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Sc})(?=\\W|$)`,"i"),ure=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Sc})(?=\\W|$)`,"i"),dre=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Wu})(?=\\W|$)`,"i"),Gy=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(t){return this.strictMode?dre:t.option.forwardDate?cre:ure}innerExtract(t,n){if(n[0].match(/^for\s*the\s*\w+/))return null;let i=Ys(n[1]);return i?X.createRelativeFromReference(t.reference,i):null}}});var pre,qq,Wq,fre,zq,Yy,Hq=b(()=>{zt();sn();sn();sn();ze();fe();pre=new RegExp(`(?:on\\s{0,3})?(${qm})(?:\\s{0,3}(?:to|\\-|\\\u2013|until|through|till)\\s{0,3}(${qm}))?(?:-|/|\\s{0,3}(?:of)?\\s{0,3})(${te(vo)})(?:(?:-|/|,?\\s{0,3})(${qu}(?!\\w)))?(?=\\W|$)`,"i"),qq=1,Wq=2,fre=3,zq=4,Yy=class extends B{innerPattern(){return pre}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=vo[t[fre].toLowerCase()],o=Wm(t[qq]);if(o>31)return t.index=t.index+t[qq].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[zq]){let s=Tl(t[zq]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[Wq]){let s=Wm(t[Wq]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var mre,hre,jq,SF,DF,Ky,Gq=b(()=>{zt();sn();sn();sn();ze();fe();mre=new RegExp(`(${te(vo)})(?:-|/|\\s*,?\\s*)(${qm})(?!\\s*(?:am|pm))\\s*(?:(?:to|\\-)\\s*(${qm})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${qu}))?(?=\\W|$)(?!\\:\\d)`,"i"),hre=1,jq=2,SF=3,DF=4,Ky=class extends B{constructor(t){super();ae(this,"shouldSkipYearLikeDate");this.shouldSkipYearLikeDate=t}innerPattern(){return mre}innerExtract(t,n){let i=vo[n[hre].toLowerCase()],o=Wm(n[jq]);if(o>31||this.shouldSkipYearLikeDate&&!n[SF]&&!n[DF]&&n[jq].match(/^\d{2}$/))return null;let s=t.createParsingComponents({day:o,month:i}).addTag("parser/ENMonthNameMiddleEndianParser");if(n[DF]){let c=Tl(n[DF]);s.assign("year",c)}else{let c=mt(t.refDate,o,i);s.imply("year",c)}if(!n[SF])return s;let a=Wm(n[SF]),l=t.createParsingResult(n.index,n[0]);return l.start=s,l.end=s.clone(),l.end.assign("day",a),l}}});var gre,vre,yre,Yq,Qy,Kq=b(()=>{sn();zt();ze();sn();fe();gre=new RegExp(`((?:in)\\s*)?(${te(vo)})\\s*(?:(?:,|-|of)?\\s*(${qu})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),vre=1,yre=2,Yq=3,Qy=class extends B{innerPattern(){return gre}innerExtract(e,t){let n=t[yre].toLowerCase();if(t[0].length<=3&&!kF[n])return null;let i=e.createParsingResult(t.index+(t[vre]||"").length,t.index+t[0].length);i.start.imply("day",1),i.start.addTag("parser/ENMonthNameParser");let o=vo[n];if(i.start.assign("month",o),t[Yq]){let s=Tl(t[Yq]);i.start.assign("year",s)}else{let s=mt(e.refDate,1,o);i.start.imply("year",s)}return i}}});var bre,wre,Cre,Qq,xre,Xy,Xq=b(()=>{sn();ze();fe();bre=new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${te(vo)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),wre=1,Cre=2,Qq=3,xre=4,Xy=class extends B{constructor(t){super();ae(this,"strictMonthDateOrder");this.strictMonthDateOrder=t}innerPattern(){return bre}innerExtract(t,n){let i=parseInt(n[wre]),o=parseInt(n[xre]),s=n[Qq]?parseInt(n[Qq]):vo[n[Cre].toLowerCase()];if(s<1||s>12){if(this.strictMonthDateOrder)return null;o>=1&&o<=12&&([s,o]=[o,s])}return o<1||o>31?null:{day:o,month:s,year:i}}}});var Ere,Tre,_re,Are,Zy,Zq=b(()=>{sn();ze();sn();fe();Ere="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-9][0-9]{3})",Tre=new RegExp(`(${Ere})(?:\\s*[-.\\/,]?\\s*|\\s+of\\s+)(${te(vo)})(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),_re=1,Are=2,Zy=class extends B{innerPattern(){return Tre}innerExtract(e,t){let n=Tl(t[_re]),i=t[Are].toLowerCase(),o=vo[i],s=e.createParsingResult(t.index,t[0]);return s.start.imply("day",1),s.start.assign("month",o),s.start.assign("year",n),s.start.addTag("parser/ENYearMonthNameParser"),s}}});var kre,Sre,Dre,Jy,Jq=b(()=>{fe();kre=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),Sre=1,Dre=2,Jy=class extends B{innerPattern(){return kre}innerExtract(e,t){let n=parseInt(t[Dre]),i=parseInt(t[Sre]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});function Ire(r,e,t,n){return new RegExp(`${r}${e}(\\d{1,4})(?:(?:\\.|:|\uFF1A)(\\d{1,2})(?:(?::|\uFF1A)(\\d{2})(?:\\.(\\d{1,6}))?)?)?(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?${t}`,n)}function Pre(r,e){return new RegExp(`^(${r})(\\d{1,4})(?:(?:\\.|\\:|\\\uFF1A)(\\d{1,2})(?:(?:\\.|\\:|\\\uFF1A)(\\d{1,2})(?:\\.(\\d{1,6}))?)?)?(?:\\s*(a\\.m\\.|p\\.m\\.|am?|pm?))?${e}`,"i")}var IF,xp,mA,hA,zm,Yr,La=b(()=>{ft();IF=2,xp=3,mA=4,hA=5,zm=6,Yr=class{constructor(e=!1){ae(this,"strictMode");ae(this,"cachedPrimaryPrefix",null);ae(this,"cachedPrimarySuffix",null);ae(this,"cachedPrimaryTimePattern",null);ae(this,"cachedFollowingPhase",null);ae(this,"cachedFollowingSuffix",null);ae(this,"cachedFollowingTimePatten",null);this.strictMode=e}patternFlags(){return"i"}primaryPatternLeftBoundary(){return"(^|\\s|T|\\b)"}primarySuffix(){return"(?!/)(?=\\W|$)"}followingSuffix(){return"(?!/)(?=\\W|$)"}pattern(e){return this.getPrimaryTimePatternThroughCache()}extract(e,t){let n=this.extractPrimaryTimeComponents(e,t);if(!n)return t[0].match(/^\d{4}/)?(t.index+=4,null):(t.index+=t[0].length,null);let i=t.index+t[1].length,o=t[0].substring(t[1].length),s=e.createParsingResult(i,o,n);t.index+=t[0].length;let a=e.text.substring(t.index),c=this.getFollowingTimePatternThroughCache().exec(a);return o.match(/^\d{3,4}/)&&c&&(c[0].match(/^\s*([+-])\s*\d{2,4}$/)||c[0].match(/^\s*([+-])\s*\d{2}\W\d{2}/))?null:!c||c[0].match(/^\s*([+-])\s*\d{3,4}$/)?this.checkAndReturnWithoutFollowingPattern(s):(s.end=this.extractFollowingTimeComponents(e,c,s),s.end&&(s.text+=c[0]),this.checkAndReturnWithFollowingPattern(s))}extractPrimaryTimeComponents(e,t,n=!1){let i=e.createParsingComponents(),o=0,s=null,a=parseInt(t[IF]);if(a>100){if(t[IF].length==4&&t[xp]==null&&!t[zm]||this.strictMode||t[xp]!=null)return null;o=a%100,a=Math.floor(a/100)}if(a>24)return null;if(t[xp]!=null){if(t[xp].length==1&&!t[zm])return null;o=parseInt(t[xp])}if(o>=60)return null;if(a>12&&(s=j.PM),t[zm]!=null){if(a>12)return null;let l=t[zm][0].toLowerCase();l=="a"&&(s=j.AM,a==12&&(a=0)),l=="p"&&(s=j.PM,a!=12&&(a+=12))}if(i.assign("hour",a),i.assign("minute",o),s!==null?i.assign("meridiem",s):a<12?i.imply("meridiem",j.AM):i.imply("meridiem",j.PM),t[hA]!=null){let l=parseInt(t[hA].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[mA]!=null){let l=parseInt(t[mA]);if(l>=60)return null;i.assign("second",l)}return i}extractFollowingTimeComponents(e,t,n){let i=e.createParsingComponents();if(t[hA]!=null){let l=parseInt(t[hA].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[mA]!=null){let l=parseInt(t[mA]);if(l>=60)return null;i.assign("second",l)}let o=parseInt(t[IF]),s=0,a=-1;if(t[xp]!=null?s=parseInt(t[xp]):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=j.PM),t[zm]!=null){if(o>12)return null;let l=t[zm][0].toLowerCase();l=="a"&&(a=j.AM,o==12&&(o=0,i.isCertain("day")||i.imply("day",i.get("day")+1))),l=="p"&&(a=j.PM,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==j.AM?(n.start.imply("meridiem",j.AM),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",j.PM),n.start.get("hour")!=12&&n.start.assign("hour",n.start.get("hour")+12)))}return i.assign("hour",o),i.assign("minute",s),a>=0?i.assign("meridiem",a):n.start.isCertain("meridiem")&&n.start.get("hour")>12?n.start.get("hour")-12>o?i.imply("meridiem",j.AM):o<=12&&(i.assign("hour",o+12),i.assign("meridiem",j.PM)):o>12?i.imply("meridiem",j.PM):o<=12&&i.imply("meridiem",j.AM),i.date().getTime()<n.start.date().getTime()&&i.imply("day",i.get("day")+1),i}checkAndReturnWithoutFollowingPattern(e){if(e.text.match(/^\d$/)||e.text.match(/^\d\d\d+$/)||e.text.match(/\d[apAP]$/))return null;let t=e.text.match(/[^\d:.](\d[\d.]+)$/);if(t){let n=t[1];if(this.strictMode||n.includes(".")&&!n.match(/\d(\.\d{2})+$/)||parseInt(n)>24)return null}return e}checkAndReturnWithFollowingPattern(e){if(e.text.match(/^\d+-\d+$/))return null;let t=e.text.match(/[^\d:.](\d[\d.]+)\s*-\s*(\d[\d.]+)$/);if(t){if(this.strictMode)return null;let n=t[1],i=t[2];if(i.includes(".")&&!i.match(/\d(\.\d{2})+$/))return null;let o=parseInt(i),s=parseInt(n);if(o>24||s>24)return null}return e}getPrimaryTimePatternThroughCache(){let e=this.primaryPrefix(),t=this.primarySuffix();return this.cachedPrimaryPrefix===e&&this.cachedPrimarySuffix===t?this.cachedPrimaryTimePattern:(this.cachedPrimaryTimePattern=Ire(this.primaryPatternLeftBoundary(),e,t,this.patternFlags()),this.cachedPrimaryPrefix=e,this.cachedPrimarySuffix=t,this.cachedPrimaryTimePattern)}getFollowingTimePatternThroughCache(){let e=this.followingPhase(),t=this.followingSuffix();return this.cachedFollowingPhase===e&&this.cachedFollowingSuffix===t?this.cachedFollowingTimePatten:(this.cachedFollowingTimePatten=Pre(e,t),this.cachedFollowingPhase=e,this.cachedFollowingSuffix=t,this.cachedFollowingTimePatten)}}});var eb,eW=b(()=>{ft();La();eb=class extends Yr{constructor(e){super(e)}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|to|until|through|till|\\?)\\s*"}primaryPrefix(){return"(?:(?:at|from)\\s*)??"}primarySuffix(){return"(?:\\s*(?:o\\W*clock|at\\s*night|in\\s*the\\s*(?:morning|afternoon)))?(?!/)(?=\\W|$)"}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(!n)return n;if(t[0].endsWith("night")){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",j.PM)):i<6&&n.assign("meridiem",j.AM)}if(t[0].endsWith("afternoon")){n.assign("meridiem",j.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}return t[0].endsWith("morning")&&(n.assign("meridiem",j.AM),n.get("hour")<12&&n.assign("hour",n.get("hour"))),n.addTag("parser/ENTimeExpressionParser")}extractFollowingTimeComponents(e,t,n){let i=super.extractFollowingTimeComponents(e,t,n);return i&&i.addTag("parser/ENTimeExpressionParser"),i}}});var Fre,Mre,tb,tW=b(()=>{sn();Le();fe();Bt();Fre=new RegExp(`(${Sc})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),Mre=new RegExp(`(${Wu})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),tb=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Mre:Fre}innerExtract(t,n){let i=Ys(n[1]);return i?X.createRelativeFromReference(t.reference,tt(i)):null}}});var Rre,$re,Ore,rb,rW=b(()=>{sn();Le();fe();Rre=new RegExp(`(${Sc})\\s{0,5}(?:later|after|from now|henceforth|forward|out)(?=(?:\\W|$))`,"i"),$re=new RegExp(`(${Wu})\\s{0,5}(later|after|from now)(?=\\W|$)`,"i"),Ore=1,rb=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?$re:Rre}innerExtract(t,n){let i=Ys(n[Ore]);return i?X.createRelativeFromReference(t.reference,i):null}}});var zu,oi,Ks=b(()=>{zu=class{refine(e,t){return t.filter(n=>this.isValid(e,n))}},oi=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0],o=null;for(let s=1;s<t.length;s++){o=t[s];let a=e.text.substring(i.index+i.text.length,o.index);if(!this.shouldMergeResults(a,i,o,e))n.push(i),i=o;else{let l=i,c=o,u=this.mergeResults(a,l,c,e);e.debug(()=>{console.log(`${this.constructor.name} merged ${l} and ${c} into ${u}`)}),i=u}}return i!=null&&n.push(i),n}}});var Yt,yo=b(()=>{Ks();Bt();Yt=class extends oi{shouldMergeResults(e,t,n){return!t.end&&!n.end&&e.match(this.patternBetween())!=null}mergeResults(e,t,n){if(!t.start.isOnlyWeekdayComponent()&&!n.start.isOnlyWeekdayComponent()&&(n.start.getCertainComponents().forEach(o=>{t.start.isCertain(o)||t.start.imply(o,n.start.get(o))}),t.start.getCertainComponents().forEach(o=>{n.start.isCertain(o)||n.start.imply(o,t.start.get(o))})),t.start.date()>n.start.date()){let o=t.start.date(),s=n.start.date();n.start.isOnlyWeekdayComponent()&&yt(s,{day:7})>o?(s=yt(s,{day:7}),n.start.imply("day",s.getDate()),n.start.imply("month",s.getMonth()+1),n.start.imply("year",s.getFullYear())):t.start.isOnlyWeekdayComponent()&&yt(o,{day:-7})<s?(o=yt(o,{day:-7}),t.start.imply("day",o.getDate()),t.start.imply("month",o.getMonth()+1),t.start.imply("year",o.getFullYear())):n.start.isDateWithUnknownYear()&&yt(s,{year:1})>o?(s=yt(s,{year:1}),n.start.imply("year",s.getFullYear())):t.start.isDateWithUnknownYear()&&yt(o,{year:-1})<s?(o=yt(o,{year:-1}),t.start.imply("year",o.getFullYear())):[n,t]=[t,n]}let i=t.clone();return i.start=t.start,i.end=n.start,i.index=Math.min(t.index,n.index),t.index<n.index?i.text=t.text+e+n.text:i.text=n.text+e+t.text,i}}});var nb,nW=b(()=>{yo();nb=class extends Yt{patternBetween(){return/^\s*(to|-||until|through|till)\s*$/i}}});function PF(r,e){let t=r.clone(),n=r.start,i=e.start;if(t.start=iW(n,i),r.end!=null||e.end!=null){let o=r.end==null?r.start:r.end,s=e.end==null?e.start:e.end,a=iW(o,s);if(r.end==null&&a.date().getTime()<t.start.date().getTime()){let l=new Date(a.date().getTime());l.setDate(l.getDate()+1),a.isCertain("day")?nt(a,l):kc(a,l)}t.end=a}return t}function iW(r,e){let t=r.clone();e.isCertain("hour")?(t.assign("hour",e.get("hour")),t.assign("minute",e.get("minute")),e.isCertain("second")?(t.assign("second",e.get("second")),e.isCertain("millisecond")?t.assign("millisecond",e.get("millisecond")):t.imply("millisecond",e.get("millisecond"))):(t.imply("second",e.get("second")),t.imply("millisecond",e.get("millisecond")))):(t.imply("hour",e.get("hour")),t.imply("minute",e.get("minute")),t.imply("second",e.get("second")),t.imply("millisecond",e.get("millisecond"))),e.isCertain("timezoneOffset")&&t.assign("timezoneOffset",e.get("timezoneOffset"));let n=r.get("meridiem")!=null&&(r.isCertain("meridiem")||Array.from(r.tags()).some(i=>i.startsWith("casualReference/")));return e.isCertain("meridiem")?t.assign("meridiem",e.get("meridiem")):e.get("meridiem")!=null&&!n&&t.imply("meridiem",e.get("meridiem")),t.get("meridiem")==j.PM&&t.get("hour")<12&&(e.isCertain("hour")?t.assign("hour",t.get("hour")+12):t.imply("hour",t.get("hour")+12)),t.addTags(r.tags()),t.addTags(e.tags()),t}var oW=b(()=>{ft();on()});var Kt,bo=b(()=>{Ks();oW();Kt=class extends oi{shouldMergeResults(e,t,n){return(t.start.isOnlyDate()&&n.start.isOnlyTime()||n.start.isOnlyDate()&&t.start.isOnlyTime())&&e.match(this.patternBetween())!=null}mergeResults(e,t,n){let i=t.start.isOnlyDate()?PF(t,n):PF(n,t);return i.index=t.index,i.text=t.text+e+n.text,i}}});var Hm,sW=b(()=>{bo();Hm=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|at|after|before|on|of|,|-|\\.|\u2219|:)?\\s*$")}}});var Nre,ib,aW=b(()=>{TF();Nre=new RegExp("^\\s*,?\\s*\\(?([A-Z]{2,4})\\)?(?=\\W|$)","i"),ib=class{constructor(e){ae(this,"timezoneOverrides");this.timezoneOverrides=e}refine(e,t){let n=e.option.timezones??{};return t.forEach(i=>{let o=e.text.substring(i.index+i.text.length),s=Nre.exec(o);if(!s)return;let a=s[1].toUpperCase(),l=i.start.date()??i.refDate??new Date,c={...this.timezoneOverrides,...n},u=pA(a,l,c);if(u==null)return;e.debug(()=>{console.log(`Extracting timezone: '${a}' into: ${u} for: ${i.start}`)});let d=i.start.get("timezoneOffset");d!==null&&u!=d&&(i.start.isCertain("timezoneOffset")||a!=s[1])||i.start.isOnlyDate()&&a!=s[1]||(i.text+=s[0],i.start.isCertain("timezoneOffset")||i.start.assign("timezoneOffset",u),i.end!=null&&!i.end.isCertain("timezoneOffset")&&i.end.assign("timezoneOffset",u))}),t}}});var Lre,Bre,Vre,Ure,Ba,ob=b(()=>{Lre=new RegExp("^\\s*(?:\\(?(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?\\)?","i"),Bre=1,Vre=2,Ure=3,Ba=class{refine(e,t){return t.forEach(function(n){if(n.start.isCertain("timezoneOffset"))return;let i=e.text.substring(n.index+n.text.length),o=Lre.exec(i);if(!o)return;e.debug(()=>{console.log(`Extracting timezone: '${o[0]}' into : ${n}`)});let s=parseInt(o[Vre]),a=parseInt(o[Ure]||"0"),l=s*60+a;l>840||(o[Bre]==="-"&&(l=-l),n.end!=null&&n.end.assign("timezoneOffset",l),n.start.assign("timezoneOffset",l),n.text+=o[0])}),t}}});var _l,gA=b(()=>{_l=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0];for(let o=1;o<t.length;o++){let s=t[o];if(s.index>=i.index+i.text.length){n.push(i),i=s;continue}let a=null,l=null;s.text.length>i.text.length?(a=s,l=i):(a=i,l=s),e.debug(()=>{console.log(`${this.constructor.name} remove ${l} by ${a}`)}),i=a}return i!=null&&n.push(i),n}}});function cr(r,e,t){let n=r.getDateWithAdjustedTimezone(),i=qre(n,e,t),o=new X(r);return o=o.addDurationAsImplied({day:i}),o.assign("weekday",e),o}function qre(r,e,t){let n=r.getDay();switch(t){case"this":return Ep(r,e);case"last":return lW(r,e);case"next":return n==Oe.SUNDAY?e==Oe.SUNDAY?7:e:n==Oe.SATURDAY?e==Oe.SATURDAY?7:e==Oe.SUNDAY?8:1+e:e<n&&e!=Oe.SUNDAY?Ep(r,e):Ep(r,e)+7}return Wre(r,e)}function Wre(r,e){let t=lW(r,e),n=Ep(r,e);return n<-t?n:t}function Ep(r,e){let t=r.getDay(),n=e-t;return n<0&&(n+=7),n}function lW(r,e){let t=r.getDay(),n=e-t;return n>=0&&(n-=7),n}var Qi=b(()=>{ft();Le()});var sb,cW=b(()=>{on();on();Bt();Qi();sb=class{refine(e,t){return e.option.forwardDate&&t.forEach(n=>{let i=e.reference.getDateWithAdjustedTimezone();if(n.start.isOnlyTime()&&e.reference.instant>n.start.date()){let o=e.reference.getDateWithAdjustedTimezone(),s=new Date(o);s.setDate(s.getDate()+1),kc(n.start,s),e.debug(()=>{console.log(`${this.constructor.name} adjusted ${n} time from the ref date (${o}) to the following day (${s})`)}),n.end&&n.end.isOnlyTime()&&(kc(n.end,s),n.start.date()>n.end.date()&&(s.setDate(s.getDate()+1),kc(n.end,s)))}if(n.start.isOnlyWeekdayComponent()&&i>n.start.date()){let o=Ep(i,n.start.get("weekday"))||7,s=yt(i,{day:o});if(kc(n.start,s),e.debug(()=>{console.log(`${this.constructor.name} adjusted ${n} weekday (${n.start})`)}),n.end&&n.start.date()>n.end.date()){let a=Ep(i,n.start.get("weekday"))||7,l=yt(i,{day:a});kc(n.end,l),e.debug(()=>{console.log(`${this.constructor.name} adjusted ${n} weekday (${n.end})`)})}}if(n.start.isDateWithUnknownYear()&&i>n.start.date())for(let o=0;o<3&&i>n.start.date();o++)n.start.imply("year",n.start.get("year")+1),e.debug(()=>{console.log(`${this.constructor.name} adjusted ${n} year (${n.start})`)}),n.end&&!n.end.isCertain("year")&&(n.end.imply("year",n.end.get("year")+1),e.debug(()=>{console.log(`${this.constructor.name} adjusted ${n} month (${n.start})`)}))}),t}}});var ab,uW=b(()=>{Ks();ab=class extends zu{constructor(t){super();ae(this,"strictMode");this.strictMode=t}isValid(t,n){return n.text.replace(" ","").match(/^\d*(\.\d*)?$/)?(t.debug(()=>{console.log(`Removing unlikely result '${n.text}'`)}),!1):n.start.isValidDate()?n.end&&!n.end.isValidDate()?(t.debug(()=>{console.log(`Removing invalid result: ${n} (${n.end})`)}),!1):this.strictMode?this.isStrictModeValid(t,n):!0:(t.debug(()=>{console.log(`Removing invalid result: ${n} (${n.start})`)}),!1)}isStrictModeValid(t,n){return n.start.isOnlyWeekdayComponent()?(t.debug(()=>{console.log(`(Strict) Removing weekday only component: ${n} (${n.end})`)}),!1):!0}}});var zre,Hre,jre,Gre,dW,Yre,pW,fW,Kre,mW,hW,wo,Tp=b(()=>{fe();zre=new RegExp("([0-9]{4})\\-([0-9]{1,2})\\-([0-9]{1,2})(?:T([0-9]{1,2}):([0-9]{1,2})(?::([0-9]{1,2})(?:\\.(\\d{1,4}))?)?(Z|([+-]\\d{2}):?(\\d{2})?)?)?(?=\\W|$)","i"),Hre=1,jre=2,Gre=3,dW=4,Yre=5,pW=6,fW=7,Kre=8,mW=9,hW=10,wo=class extends B{innerPattern(){return zre}innerExtract(e,t){let n=e.createParsingComponents({year:parseInt(t[Hre]),month:parseInt(t[jre]),day:parseInt(t[Gre])});if(t[dW]!=null&&(n.assign("hour",parseInt(t[dW])),n.assign("minute",parseInt(t[Yre])),t[pW]!=null&&n.assign("second",parseInt(t[pW])),t[fW]!=null&&n.assign("millisecond",parseInt(t[fW])),t[Kre]!=null)){let i=0;if(t[mW]){let o=parseInt(t[mW]),s=0;t[hW]!=null&&(s=parseInt(t[hW])),i=o*60,i<0?i-=s:i+=s}n.assign("timezoneOffset",i)}return n.addTag("parser/ISOFormatParser")}}});var Dc,vA=b(()=>{Ks();Dc=class extends oi{mergeResults(e,t,n){let i=n.clone();return i.index=t.index,i.text=t.text+e+i.text,i.start.assign("weekday",t.start.get("weekday")),i.end&&i.end.assign("weekday",t.start.get("weekday")),i}shouldMergeResults(e,t,n){return t.start.isOnlyWeekdayComponent()&&!t.start.isCertain("hour")&&n.start.isCertain("day")&&e.match(/^,?\s*$/)!=null}}});function Ht(r,e=!1){return r.parsers.unshift(new wo),r.refiners.unshift(new Dc),r.refiners.unshift(new Ba),r.refiners.unshift(new _l),r.refiners.push(new ib),r.refiners.push(new _l),r.refiners.push(new sb),r.refiners.push(new ab(e)),r}var Ti=b(()=>{aW();ob();gA();cW();uW();Tp();vA()});function Or(r){let e=r.getDateWithAdjustedTimezone(),t=new X(r,{});return nt(t,e),dA(t,e),t.assign("timezoneOffset",r.getTimezoneOffset()),t.addTag("casualReference/now"),t}function _r(r){let e=r.getDateWithAdjustedTimezone(),t=new X(r,{});return nt(t,e),Lt(t,e),t.delete("meridiem"),t.addTag("casualReference/today"),t}function vn(r){return Ic(r,1).addTag("casualReference/yesterday")}function yn(r){return Ro(r,1).addTag("casualReference/tomorrow")}function Ic(r,e){return Ro(r,-e)}function Ro(r,e){let t=r.getDateWithAdjustedTimezone(),n=new X(r,{}),i=new Date(t.getTime());return i.setDate(i.getDate()+e),nt(n,i),Lt(n,i),n.delete("meridiem"),n}function yA(r,e=22){let t=r.getDateWithAdjustedTimezone(),n=new X(r,{});return nt(n,t),n.imply("hour",e),n.imply("meridiem",j.PM),n.addTag("casualReference/tonight"),n}function bA(r,e=0){let t=r.getDateWithAdjustedTimezone(),n=new X(r,{});return t.getHours()<6&&(t=new Date(t.getTime()-1440*60*1e3)),nt(n,t),n.imply("hour",e),n}function Pc(r,e=20){let t=new X(r,{});return t.imply("meridiem",j.PM),t.imply("hour",e),t.addTag("casualReference/evening"),t}function wA(r,e=20){let t=r.getDateWithAdjustedTimezone(),n=new X(r,{});return t=new Date(t.getTime()-1440*60*1e3),nt(n,t),n.imply("hour",e),n.imply("meridiem",j.PM),n.addTag("casualReference/yesterday"),n.addTag("casualReference/evening"),n}function Fc(r){let e=new X(r,{});return r.getDateWithAdjustedTimezone().getHours()>2&&e.addDurationAsImplied({day:1}),e.assign("hour",0),e.imply("minute",0),e.imply("second",0),e.imply("millisecond",0),e.addTag("casualReference/midnight"),e}function Mc(r,e=6){let t=new X(r,{});return t.imply("meridiem",j.AM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/morning"),t}function CA(r,e=15){let t=new X(r,{});return t.imply("meridiem",j.PM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/afternoon"),t}function Hu(r){let e=new X(r,{});return e.imply("meridiem",j.AM),e.assign("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("millisecond",0),e.addTag("casualReference/noon"),e}var si=b(()=>{Le();on();ft()});var Qre,lb,gW=b(()=>{fe();on();si();Qre=/(now|today|tonight|tomorrow|overmorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i,lb=class extends B{innerPattern(e){return Qre}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"now":o=Or(e.reference);break;case"today":o=_r(e.reference);break;case"yesterday":o=vn(e.reference);break;case"tomorrow":case"tmr":case"tmrw":o=yn(e.reference);break;case"tonight":o=yA(e.reference);break;case"overmorrow":o=Ro(e.reference,2);break;default:if(i.match(/last\s*night/)){if(n.getHours()>6){let s=new Date(n.getTime());s.setDate(s.getDate()-1),n=s}nt(o,n),o.imply("hour",0)}break}return o.addTag("parser/ENCasualDateParser"),o}}});var Xre,cb,vW=b(()=>{fe();si();Xre=/(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|midday|noon)(?=\W|$)/i,cb=class extends B{innerPattern(){return Xre}innerExtract(e,t){let n=null;switch(t[1].toLowerCase()){case"afternoon":n=CA(e.reference);break;case"evening":case"night":n=Pc(e.reference);break;case"midnight":n=Fc(e.reference);break;case"morning":n=Mc(e.reference);break;case"noon":case"midday":n=Hu(e.reference);break}return n&&n.addTag("parser/ENCasualTimeParser"),n}}});var Zre,Jre,ene,tne,ub,yW=b(()=>{sn();ze();fe();Qi();ft();Zre=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:on\\s*?)?(?:(this|last|past|next)\\s*)?(${te(fA)}|weekend|weekday)(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(?:of\\s*)?(this|last|past|next)\\s*week)?(?=\\W|$)`,"i"),Jre=1,ene=2,tne=3,ub=class extends B{innerPattern(){return Zre}innerExtract(e,t){let n=t[Jre],i=t[tne],o=n||i;o=o||"",o=o.toLowerCase();let s=null;o=="last"||o=="past"?s="last":o=="next"?s="next":o=="this"&&(s="this");let a=t[ene].toLowerCase(),l;if(fA[a]!==void 0)l=fA[a];else if(a=="weekend")l=s=="last"?Oe.SUNDAY:Oe.SATURDAY;else if(a=="weekday"){let c=e.reference.getDateWithAdjustedTimezone().getDay();c==Oe.SUNDAY||c==Oe.SATURDAY?l=s=="last"?Oe.FRIDAY:Oe.MONDAY:(l=c-1,l=s=="last"?l-1:l+1,l=l%5+1)}else return null;return cr(e.reference,l,s)}}});var rne,nne,ine,db,bW=b(()=>{sn();Le();fe();ze();rne=new RegExp(`(this|last|past|next|after\\s*this)\\s*(${te(jy)})(?=\\s*)(?=\\W|$)`,"i"),nne=1,ine=2,db=class extends B{innerPattern(){return rne}innerExtract(e,t){let n=t[nne].toLowerCase(),i=t[ine].toLowerCase(),o=jy[i];if(n=="next"||n.startsWith("after")){let l={};return l[o]=1,X.createRelativeFromReference(e.reference,l)}if(n=="last"||n=="past"){let l={};return l[o]=-1,X.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return i.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):i.match(/month/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):i.match(/year/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var one,sne,ane,wW,CW,FF,vr,us=b(()=>{zt();one=new RegExp("([^\\d]|^)([0-3]{0,1}[0-9]{1})[\\/\\.\\-]([0-3]{0,1}[0-9]{1})(?:[\\/\\.\\-]([0-9]{4}|[0-9]{2}))?(\\W|$)","i"),sne=1,ane=5,wW=2,CW=3,FF=4,vr=class{constructor(e){ae(this,"groupNumberMonth");ae(this,"groupNumberDay");this.groupNumberMonth=e?CW:wW,this.groupNumberDay=e?wW:CW}pattern(){return one}extract(e,t){let n=t.index+t[sne].length,i=t.index+t[0].length-t[ane].length;if(n>0&&e.text.substring(0,n).match("\\d/?$")||i<e.text.length&&e.text.substring(i).match("^/?\\d"))return;let o=e.text.substring(n,i);if(o.match(/^\d\.\d$/)||o.match(/^\d\.\d{1,2}\.\d{1,2}\s*$/)||!t[FF]&&o.indexOf("/")<0)return;let s=e.createParsingResult(n,o),a=parseInt(t[this.groupNumberMonth]),l=parseInt(t[this.groupNumberDay]);if((a<1||a>12)&&a>12)if(l>=1&&l<=12&&a<=31)[l,a]=[a,l];else return null;if(l<1||l>31)return null;if(s.start.assign("day",l),s.start.assign("month",a),t[FF]){let c=parseInt(t[FF]),u=Gr(c);s.start.assign("year",u)}else{let c=mt(e.refDate,l,a);s.start.imply("year",c)}return s.addTag("parser/SlashDateFormatParser")}}});var lne,cne,pb,xW=b(()=>{sn();Le();fe();Bt();lne=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${Sc})(?=\\W|$)`,"i"),cne=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${Wu})(?=\\W|$)`,"i"),pb=class extends B{constructor(t=!0){super();ae(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?lne:cne}innerExtract(t,n){let i=n[1].toLowerCase(),o=Ys(n[2]);if(!o)return null;switch(i){case"last":case"past":case"-":o=tt(o);break}return X.createRelativeFromReference(t.reference,o)}}});function une(r){return r.text.match(/^[+-]/i)!=null}function EW(r){return r.text.match(/^-/i)!=null}var fb,TW=b(()=>{Ks();Le();sn();Bt();fb=class extends oi{shouldMergeResults(e,t,n){return e.match(/^\s*$/i)?une(n)||EW(n):!1}mergeResults(e,t,n,i){let o=Ys(n.text);EW(n)&&(o=tt(o));let s=X.createRelativeFromReference(ct.fromDate(t.start.date()),o);return new at(t.reference,t.index,`${t.text}${e}${n.text}`,s)}}});function _W(r){return r.text.match(/\s+(before|from)$/i)!=null}function dne(r){return r.text.match(/\s+(after|since)$/i)!=null}var mb,AW=b(()=>{Ks();Le();sn();Bt();mb=class extends oi{patternBetween(){return/^\s*$/i}shouldMergeResults(e,t,n){return!e.match(this.patternBetween())||!_W(t)&&!dne(t)?!1:!!n.start.get("day")&&!!n.start.get("month")&&!!n.start.get("year")}mergeResults(e,t,n){let i=Ys(t.text);_W(t)&&(i=tt(i));let o=X.createRelativeFromReference(ct.fromDate(n.start.date()),i);return new at(n.reference,t.index,`${t.text}${e}${n.text}`,o)}}});var pne,fne,hb,kW=b(()=>{sn();pne=new RegExp(`^\\s*(${qu})`,"i"),fne=1,hb=class{refine(e,t){return t.forEach(function(n){if(!n.start.isDateWithUnknownYear())return;let i=e.text.substring(n.index+n.text.length),o=pne.exec(i);if(!o||o[0].trim().length<=3)return;e.debug(()=>{console.log(`Extracting year: '${o[0]}' into : ${n}`)});let s=Tl(o[fne]);n.end!=null&&n.end.assign("year",s),n.start.assign("year",s),n.text+=o[0]}),t}}});var gb,SW=b(()=>{Ks();gb=class extends zu{constructor(){super()}isValid(e,t){let n=t.text.trim();return n===e.text.trim()?!0:n.toLowerCase()==="may"&&!e.text.substring(0,t.index).trim().match(/\b(in)$/i)?(e.debug(()=>{console.log(`Removing unlikely result: ${t}`)}),!1):n.toLowerCase().endsWith("the second")?(e.text.substring(t.index+t.text.length).trim().length>0&&e.debug(()=>{console.log(`Removing unlikely result: ${t}`)}),!1):!0}}});var _p,MF=b(()=>{Uq();Hq();Gq();Kq();Xq();Zq();Jq();eW();tW();rW();nW();sW();Ti();gW();vW();yW();bW();us();xW();TW();AW();gA();kW();SW();_p=class{createCasualConfiguration(e=!1){let t=this.createConfiguration(!1,e);return t.parsers.push(new lb),t.parsers.push(new cb),t.parsers.push(new Qy),t.parsers.push(new db),t.parsers.push(new pb),t.refiners.push(new gb),t}createConfiguration(e=!0,t=!1){let n=Ht({parsers:[new vr(t),new Gy(e),new Yy,new Ky(t),new ub,new Jy,new eb(e),new tb(e),new rb(e),new Zy],refiners:[new Hm]},e);return n.parsers.unshift(new Xy(e)),n.refiners.unshift(new mb),n.refiners.unshift(new fb),n.refiners.unshift(new _l),n.refiners.push(new Hm),n.refiners.push(new hb),n.refiners.push(new nb),n}}});var ke,vb,ai=b(()=>{Le();MF();ke=class r{constructor(e){ae(this,"parsers");ae(this,"refiners");ae(this,"defaultConfig",new _p);e=e||this.defaultConfig.createCasualConfiguration(),this.parsers=[...e.parsers],this.refiners=[...e.refiners]}clone(){return new r({parsers:[...this.parsers],refiners:[...this.refiners]})}parseDate(e,t,n){let i=this.parse(e,t,n);return i.length>0?i[0].start.date():null}parse(e,t,n){let i=new vb(e,t,n),o=[];return this.parsers.forEach(s=>{let a=r.executeParser(i,s);o=o.concat(a)}),o.sort((s,a)=>s.index-a.index),this.refiners.forEach(function(s){o=s.refine(i,o)}),o}static executeParser(e,t){let n=[],i=t.pattern(e),o=e.text,s=e.text,a=i.exec(s);for(;a;){let l=a.index+o.length-s.length;a.index=l;let c=t.extract(e,a);if(!c){s=o.substring(a.index+1),a=i.exec(s);continue}let u=null;c instanceof at?u=c:c instanceof X?(u=e.createParsingResult(a.index,a[0]),u.start=c):u=e.createParsingResult(a.index,a[0],c);let d=u.index,f=u.text;e.debug(()=>console.log(`${t.constructor.name} extracted (at index=${d}) '${f}'`)),n.push(u),s=o.substring(d+f.length),a=i.exec(s)}return n}},vb=class{constructor(e,t,n){ae(this,"text");ae(this,"option");ae(this,"reference");ae(this,"refDate");this.text=e,this.option=n??{},this.reference=ct.fromInput(t,this.option.timezones),this.refDate=this.reference.instant}createParsingComponents(e){return e instanceof X?e:new X(this.reference,e)}createParsingResult(e,t,n,i){let o=typeof t=="string"?t:this.text.substring(e,t),s=n?this.createParsingComponents(n):null,a=i?this.createParsingComponents(i):null;return new at(this.reference,e,o,s,a)}debug(e){this.option.debug&&(this.option.debug instanceof Function?this.option.debug(e):this.option.debug.debug(e))}}});var $F={};Jr($F,{Chrono:()=>ke,GB:()=>mne,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>yb,configuration:()=>xA,parse:()=>hne,parseDate:()=>gne,strict:()=>RF});function hne(r,e,t){return yb.parse(r,e,t)}function gne(r,e,t){return yb.parseDate(r,e,t)}var xA,yb,RF,mne,DW=b(()=>{ai();Le();ft();MF();xA=new _p,yb=new ke(xA.createCasualConfiguration(!1)),RF=new ke(xA.createConfiguration(!0,!1)),mne=new ke(xA.createCasualConfiguration(!0))});var bb,IW=b(()=>{La();bb=class extends Yr{primaryPrefix(){return"(?:(?:um|von)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|bis)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});function VF(r){let e=r.toLowerCase();return OF[e]!==void 0?OF[e]:e==="ein"||e==="einer"||e==="einem"||e==="einen"||e==="eine"?1:e.match(/wenigen/)?2:e.match(/halb/)||e.match(/halben/)?.5:e.match(/einigen/)?3:e.match(/mehreren/)?7:parseFloat(e)}function MW(r){if(/v/i.test(r))return-parseInt(r.replace(/[^0-9]+/gi,""));if(/n/i.test(r))return parseInt(r.replace(/[^0-9]+/gi,""));if(/z/i.test(r))return parseInt(r.replace(/[^0-9]+/gi,""));let e=parseInt(r);return Gr(e)}function OW(r){let e={},t=r,n=PW.exec(t);for(;n;)vne(e,n),t=t.substring(n[0].length),n=PW.exec(t);return e}function vne(r,e){let t=VF(e[1]),n=wb[e[2].toLowerCase()];r[n]=t}var NF,LF,OF,wb,BF,FW,RW,PW,$W,jm=b(()=>{ze();zt();NF={sonntag:0,so:0,montag:1,mo:1,dienstag:2,di:2,mittwoch:3,mi:3,donnerstag:4,do:4,freitag:5,fr:5,samstag:6,sa:6},LF={januar:1,j\u00E4nner:1,janner:1,jan:1,"jan.":1,februar:2,feber:2,feb:2,"feb.":2,m\u00E4rz:3,maerz:3,m\u00E4r:3,"m\xE4r.":3,mrz:3,"mrz.":3,april:4,apr:4,"apr.":4,mai:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,august:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,"sept.":9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,dezember:12,dez:12,"dez.":12},OF={eins:1,eine:1,einem:1,einen:1,einer:1,zwei:2,drei:3,vier:4,f\u00FCnf:5,fuenf:5,sechs:6,sieben:7,acht:8,neun:9,zehn:10,elf:11,zw\u00F6lf:12,zwoelf:12},wb={sek:"second",sekunde:"second",sekunden:"second",min:"minute",minute:"minute",minuten:"minute",h:"hour",std:"hour",stunde:"hour",stunden:"hour",tag:"day",tage:"day",tagen:"day",woche:"week",wochen:"week",monat:"month",monate:"month",monaten:"month",monats:"month",quartal:"quarter",quartals:"quarter",quartale:"quarter",quartalen:"quarter",a:"year",j:"year",jr:"year",jahr:"year",jahre:"year",jahren:"year",jahres:"year"},BF=`(?:${te(OF)}|[0-9]+|[0-9]+\\.[0-9]+|halb?|halbe?|einigen?|wenigen?|mehreren?)`;FW="(?:[0-9]{1,4}(?:\\s*[vn]\\.?\\s*(?:C(?:hr)?|(?:u\\.?|d\\.?(?:\\s*g\\.?)?)?\\s*Z)\\.?|\\s*(?:u\\.?|d\\.?(?:\\s*g\\.)?)\\s*Z\\.?)?)";RW=`(${BF})\\s{0,5}(${te(wb)})\\s{0,5}`,PW=new RegExp(RW,"i"),$W=Tr("",RW)});var yne,bne,wne,Cne,Cb,NW=b(()=>{jm();ze();fe();Qi();yne=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:a[mn]\\s*?)?(?:(diese[mn]|letzte[mn]|n(?:\xE4|ae)chste[mn])\\s*)?(${te(NF)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(diese|letzte|n(?:\xE4|ae)chste)\\s*woche)?(?=\\W|$)`,"i"),bne=1,wne=3,Cne=2,Cb=class extends B{innerPattern(){return yne}innerExtract(e,t){let n=t[Cne].toLowerCase(),i=NF[n],o=t[bne],s=t[wne],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/letzte/)?l="last":a.match(/chste/)?l="next":a.match(/diese/)&&(l="this"),cr(e.reference,i,l)}}});var xne,Ene,Tne,LW,BW,VW,xb,UW=b(()=>{ft();xne=new RegExp("(^|\\s|T)(?:(?:um|von)\\s*)?(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s)?)?(?:\\s*Uhr)?(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?(?=\\W|$)","i"),Ene=new RegExp("^\\s*(\\-|\\\u2013|\\~|\\\u301C|bis(?:\\s+um)?|\\?)\\s*(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s)?)?(?:\\s*Uhr)?(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?(?=\\W|$)","i"),Tne=2,LW=3,BW=4,VW=5,xb=class r{pattern(e){return xne}extract(e,t){let n=e.createParsingResult(t.index+t[1].length,t[0].substring(t[1].length));if(n.text.match(/^\d{4}$/)||(n.start=r.extractTimeComponent(n.start.clone(),t),!n.start))return t.index+=t[0].length,null;let i=e.text.substring(t.index+t[0].length),o=Ene.exec(i);return o&&(n.end=r.extractTimeComponent(n.start.clone(),o),n.end&&(n.text+=o[0])),n}static extractTimeComponent(e,t){let n=0,i=0,o=null;if(n=parseInt(t[Tne]),t[LW]!=null&&(i=parseInt(t[LW])),i>=60||n>24)return null;if(n>=12&&(o=j.PM),t[VW]!=null){if(n>12)return null;let s=t[VW].toLowerCase();s.match(/morgen|vormittag/)&&(o=j.AM,n==12&&(n=0)),s.match(/nachmittag|abend/)&&(o=j.PM,n!=12&&(n+=12)),s.match(/nacht/)&&(n==12?(o=j.AM,n=0):n<6?o=j.AM:(o=j.PM,n+=12))}if(e.assign("hour",n),e.assign("minute",i),o!==null?e.assign("meridiem",o):n<12?e.imply("meridiem",j.AM):e.imply("meridiem",j.PM),t[BW]!=null){let s=parseInt(t[BW]);if(s>=60)return null;e.assign("second",s)}return e}}});var Eb,qW=b(()=>{yo();Eb=class extends Yt{patternBetween(){return/^\s*(bis(?:\s*(?:am|zum))?|-)\s*$/i}}});var Tb,WW=b(()=>{bo();Tb=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|um|am|,|-)?\\s*$")}}});var Ap,UF=b(()=>{ft();fe();on();Ap=class r extends B{innerPattern(e){return/(diesen)?\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[2].toLowerCase(),o=e.createParsingComponents();return Lt(o,n),r.extractTimeComponents(o,i)}static extractTimeComponents(e,t){switch(t){case"morgen":e.imply("hour",6),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/morning");break;case"vormittag":e.imply("hour",9),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/morning");break;case"mittag":case"mittags":e.imply("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/noon");break;case"nachmittag":e.imply("hour",15),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/afternoon");break;case"abend":e.imply("hour",18),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/evening");break;case"nacht":e.imply("hour",22),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/evening");break;case"mitternacht":e.get("hour")>1&&e.addDurationAsImplied({day:1}),e.imply("hour",0),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/midnight");break}return e}}});var _ne,Ane,kne,_b,zW=b(()=>{fe();on();UF();si();Bt();_ne=new RegExp("(jetzt|heute|morgen|\xFCbermorgen|uebermorgen|gestern|vorgestern|letzte\\s*nacht)(?:\\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht))?(?=\\W|$)","i"),Ane=1,kne=2,_b=class extends B{innerPattern(e){return _ne}innerExtract(e,t){let n=e.reference.getDateWithAdjustedTimezone(),i=(t[Ane]||"").toLowerCase(),o=(t[kne]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"jetzt":s=Or(e.reference);break;case"heute":s=_r(e.reference);break;case"morgen":n=yt(n,{day:1}),nt(s,n),Lt(s,n);break;case"\xFCbermorgen":case"uebermorgen":n=yt(n,{day:2}),nt(s,n),Lt(s,n);break;case"gestern":n=yt(n,{day:-1}),nt(s,n),Lt(s,n);break;case"vorgestern":n=yt(n,{day:-2}),nt(s,n),Lt(s,n);break;default:i.match(/letzte\s*nacht/)&&(n.getHours()>6&&(n=yt(n,{day:-1})),nt(s,n),s.imply("hour",0));break}return o&&(s=Ap.extractTimeComponents(s,o)),s}}});var Sne,HW,jW,Dne,GW,Ab,YW=b(()=>{zt();jm();jm();ze();fe();Sne=new RegExp(`(?:am\\s*?)?(?:den\\s*?)?([0-9]{1,2})\\.(?:\\s*(?:bis(?:\\s*(?:am|zum))?|\\-|\\\u2013|\\s)\\s*([0-9]{1,2})\\.?)?\\s*(${te(LF)})(?:(?:-|/|,?\\s*)(${FW}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),HW=1,jW=2,Dne=3,GW=4,Ab=class extends B{innerPattern(){return Sne}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=LF[t[Dne].toLowerCase()],o=parseInt(t[HW]);if(o>31)return t.index=t.index+t[HW].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[GW]){let s=MW(t[GW]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[jW]){let s=parseInt(t[jW]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var kb,KW=b(()=>{jm();Le();fe();ze();Bt();kb=class extends B{constructor(){super()}innerPattern(){return new RegExp(`(?:\\s*((?:n\xE4chste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?|vor|in)\\s*)?(${BF})?(?:\\s*(n\xE4chste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?)?\\s*(${te(wb)})(?=\\W|$)`,"i")}innerExtract(e,t){let n=t[2]?VF(t[2]):1,i=wb[t[4].toLowerCase()],o={};o[i]=n;let s=t[1]||t[3]||"";if(s=s.toLowerCase(),!!s)return(/vor/.test(s)||/letzte/.test(s)||/vergangen/.test(s))&&(o=tt(o)),X.createRelativeFromReference(e.reference,o)}}});var Sb,QW=b(()=>{jm();Le();fe();Sb=class extends B{innerPattern(){return new RegExp(`(?:in|f\xFCr|w\xE4hrend)\\s*(${$W})(?=\\W|$)`,"i")}innerExtract(e,t){let n=OW(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var zF={};Jr(zF,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>qF,createCasualConfiguration:()=>XW,createConfiguration:()=>WF,parse:()=>Pne,parseDate:()=>Fne,strict:()=>Ine});function Pne(r,e,t){return qF.parse(r,e,t)}function Fne(r,e,t){return qF.parseDate(r,e,t)}function XW(r=!0){let e=WF(!1,r);return e.parsers.unshift(new Ap),e.parsers.unshift(new _b),e.parsers.unshift(new kb),e}function WF(r=!0,e=!0){return Ht({parsers:[new wo,new vr(e),new bb,new xb,new Ab,new Cb,new Sb],refiners:[new Eb,new Tb]},r)}var qF,Ine,ZW=b(()=>{Ti();ai();Le();ft();us();Tp();IW();NW();UW();qW();WW();zW();UF();YW();KW();QW();qF=new ke(XW()),Ine=new ke(WF(!0))});var Db,JW=b(()=>{ft();fe();on();si();Db=class extends B{innerPattern(e){return/(maintenant|aujourd'hui|demain|hier|cette\s*nuit|la\s*veille)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"maintenant":return Or(e.reference);case"aujourd'hui":return _r(e.reference);case"hier":return vn(e.reference);case"demain":return yn(e.reference);default:if(i.match(/cette\s*nuit/))nt(o,n),o.imply("hour",22),o.imply("meridiem",j.PM);else if(i.match(/la\s*veille/)){let s=new Date(n.getTime());s.setDate(s.getDate()-1),nt(o,s),o.imply("hour",0)}}return o}}});var Ib,ez=b(()=>{ft();fe();Ib=class extends B{innerPattern(e){return/(cet?)?\s*(matin|soir|après-midi|aprem|a midi|à minuit)(?=\W|$)/i}innerExtract(e,t){let n=t[2].toLowerCase(),i=e.createParsingComponents();switch(n){case"apr\xE8s-midi":case"aprem":i.imply("hour",14),i.imply("minute",0),i.imply("meridiem",j.PM),i.addTag("casualReference/afternoon");break;case"soir":i.imply("hour",18),i.imply("minute",0),i.imply("meridiem",j.PM),i.addTag("casualReference/evening");break;case"matin":i.imply("hour",8),i.imply("minute",0),i.imply("meridiem",j.AM),i.addTag("casualReference/morning");break;case"a midi":i.imply("hour",12),i.imply("minute",0),i.imply("meridiem",j.AM),i.addTag("casualReference/noon");break;case"\xE0 minuit":i.imply("hour",0),i.imply("meridiem",j.AM),i.addTag("casualReference/midnight");break}return i}}});var Pb,tz=b(()=>{La();Pb=class extends Yr{primaryPrefix(){return"(?:(?:[\xE0a])\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|[\xE0a]|\\?)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});var Fb,rz=b(()=>{bo();Fb=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\xE0|a|au|vers|de|,|-)?\\s*$")}}});var Mb,nz=b(()=>{yo();Mb=class extends Yt{patternBetween(){return/^\s*(à|a|au|-)\s*$/i}}});function KF(r){let e=r.toLowerCase();return HF[e]!==void 0?HF[e]:e==="une"||e==="un"?1:e.match(/quelques?/)?3:e.match(/demi-?/)?.5:parseFloat(e)}function XF(r){let e=r.toLowerCase();return e=e.replace(/(?:er)$/i,""),parseInt(e)}function sz(r){if(/AC/i.test(r))return r=r.replace(/BC/i,""),-parseInt(r);if(/AD/i.test(r)||/C/i.test(r))return r=r.replace(/[^\d]+/i,""),parseInt(r);let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}function TA(r){let e={},t=r,n=iz.exec(t);for(;n;)Mne(e,n),t=t.substring(n[0].length),n=iz.exec(t);return e}function Mne(r,e){let t=KF(e[1]),n=Rb[e[2].toLowerCase()];r[n]=t}var jF,GF,HF,Rb,YF,QF,oz,az,iz,EA,ju=b(()=>{ze();jF={dimanche:0,dim:0,lundi:1,lun:1,mardi:2,mar:2,mercredi:3,mer:3,jeudi:4,jeu:4,vendredi:5,ven:5,samedi:6,sam:6},GF={janvier:1,jan:1,"jan.":1,janv:1,"janv.":1,f\u00E9vrier:2,f\u00E9v:2,"f\xE9v.":2,f\u00E9vr:2,"f\xE9vr.":2,fevrier:2,fev:2,"fev.":2,fevr:2,"fevr.":2,mars:3,mar:3,"mar.":3,avril:4,avr:4,"avr.":4,mai:5,juin:6,"juin.":6,jun:6,"jun.":6,juillet:7,juil:7,"juil.":7,jul:7,"jul.":7,ao\u00FBt:8,"ao\xFBt.":8,aout:8,"aout.":8,septembre:9,sep:9,"sep.":9,sept:9,"sept.":9,octobre:10,oct:10,"oct.":10,novembre:11,nov:11,"nov.":11,d\u00E9cembre:12,decembre:12,dec:12,"dec.":12,d\u00E9c:12,"d\xE9c.":12},HF={un:1,deux:2,trois:3,quatre:4,cinq:5,six:6,sept:7,huit:8,neuf:9,dix:10,onze:11,douze:12,treize:13},Rb={sec:"second",seconde:"second",secondes:"second",min:"minute",mins:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hrs:"hour",heure:"hour",heures:"hour",jour:"day",jours:"day",semaine:"week",semaines:"week",mois:"month",trimestre:"quarter",trimestres:"quarter",ans:"year",ann\u00E9e:"year",ann\u00E9es:"year"},YF=`(?:${te(HF)}|[0-9]+|[0-9]+\\.[0-9]+|une?\\b|quelques?|demi-?)`;QF="(?:[0-9]{1,2}(?:er)?)";oz="(?:[1-9][0-9]{0,3}\\s*(?:AC|AD|p\\.\\s*C(?:hr?)?\\.\\s*n\\.)|[1-2][0-9]{3}|[5-9][0-9])";az=`(${YF})\\s{0,5}(${te(Rb)})\\s{0,5}`,iz=new RegExp(az,"i"),EA=Tr("",az)});var Rne,$ne,One,$b,lz=b(()=>{ju();ze();fe();Qi();Rne=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(?:ce)\\s*)?(${te(jF)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(dernier|prochain)\\s*)?(?=\\W|\\d|$)`,"i"),$ne=1,One=2,$b=class extends B{innerPattern(){return Rne}innerExtract(e,t){let n=t[$ne].toLowerCase(),i=jF[n];if(i===void 0)return null;let o=t[One];o=o||"",o=o.toLowerCase();let s=null;return o=="dernier"?s="last":o=="prochain"&&(s="next"),cr(e.reference,i,s)}}});var Nne,Lne,Bne,cz,uz,dz,Ob,pz=b(()=>{ft();Nne=new RegExp("(^|\\s|T)(?:(?:[\xE0a])\\s*)?(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s|:)?)?(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?(?=\\W|$)","i"),Lne=new RegExp("^\\s*(\\-|\\\u2013|\\~|\\\u301C|[\xE0a]|\\?)\\s*(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s|:)?)?(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?(?=\\W|$)","i"),Bne=2,cz=3,uz=4,dz=5,Ob=class r{pattern(e){return Nne}extract(e,t){let n=e.createParsingResult(t.index+t[1].length,t[0].substring(t[1].length));if(n.text.match(/^\d{4}$/)||(n.start=r.extractTimeComponent(n.start.clone(),t),!n.start))return t.index+=t[0].length,null;let i=e.text.substring(t.index+t[0].length),o=Lne.exec(i);return o&&(n.end=r.extractTimeComponent(n.start.clone(),o),n.end&&(n.text+=o[0])),n}static extractTimeComponent(e,t){let n=0,i=0,o=null;if(n=parseInt(t[Bne]),t[cz]!=null&&(i=parseInt(t[cz])),i>=60||n>24)return null;if(n>=12&&(o=j.PM),t[dz]!=null){if(n>12)return null;let s=t[dz][0].toLowerCase();s=="a"&&(o=j.AM,n==12&&(n=0)),s=="p"&&(o=j.PM,n!=12&&(n+=12))}if(e.assign("hour",n),e.assign("minute",i),o!==null?e.assign("meridiem",o):n<12?e.imply("meridiem",j.AM):e.imply("meridiem",j.PM),t[uz]!=null){let s=parseInt(t[uz]);if(s>=60)return null;e.assign("second",s)}return e}}});var Vne,fz,mz,Une,hz,Nb,gz=b(()=>{zt();ju();ju();ju();ze();fe();Vne=new RegExp(`(?:on\\s*?)?(${QF})(?:\\s*(?:au|\\-|\\\u2013|jusqu'au?|\\s)\\s*(${QF}))?(?:-|/|\\s*(?:de)?\\s*)(${te(GF)})(?:(?:-|/|,?\\s*)(${oz}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),fz=1,mz=2,Une=3,hz=4,Nb=class extends B{innerPattern(){return Vne}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=GF[t[Une].toLowerCase()],o=XF(t[fz]);if(o>31)return t.index=t.index+t[fz].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[hz]){let s=sz(t[hz]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[mz]){let s=XF(t[mz]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Lb,vz=b(()=>{ju();Le();fe();Bt();Lb=class extends B{constructor(){super()}innerPattern(){return new RegExp(`il y a\\s*(${EA})(?=(?:\\W|$))`,"i")}innerExtract(e,t){let n=TA(t[1]),i=tt(n);return X.createRelativeFromReference(e.reference,i)}}});var Bb,yz=b(()=>{ju();Le();fe();Bb=class extends B{innerPattern(){return new RegExp(`(?:dans|en|pour|pendant|de)\\s*(${EA})(?=\\W|$)`,"i")}innerExtract(e,t){let n=TA(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var Vb,bz=b(()=>{ju();Le();fe();ze();Bt();Vb=class extends B{constructor(){super()}innerPattern(){return new RegExp(`(?:les?|la|l'|du|des?)\\s*(${YF})?(?:\\s*(prochaine?s?|derni[e\xE8]re?s?|pass[\xE9e]e?s?|pr[\xE9e]c[\xE9e]dents?|suivante?s?))?\\s*(${te(Rb)})(?:\\s*(prochaine?s?|derni[e\xE8]re?s?|pass[\xE9e]e?s?|pr[\xE9e]c[\xE9e]dents?|suivante?s?))?(?=\\W|$)`,"i")}innerExtract(e,t){let n=t[1]?KF(t[1]):1,i=Rb[t[3].toLowerCase()],o={};o[i]=n;let s=t[2]||t[4]||"";if(s=s.toLowerCase(),!!s)return(/derni[eè]re?s?/.test(s)||/pass[ée]e?s?/.test(s)||/pr[ée]c[ée]dents?/.test(s))&&(o=tt(o)),X.createRelativeFromReference(e.reference,o)}}});var eM={};Jr(eM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>ZF,createCasualConfiguration:()=>wz,createConfiguration:()=>JF,parse:()=>Wne,parseDate:()=>zne,strict:()=>qne});function Wne(r,e,t){return ZF.parse(r,e,t)}function zne(r,e,t){return ZF.parseDate(r,e,t)}function wz(r=!0){let e=JF(!1,r);return e.parsers.unshift(new Db),e.parsers.unshift(new Ib),e.parsers.unshift(new Vb),e}function JF(r=!0,e=!0){return Ht({parsers:[new vr(e),new Nb,new Pb,new Ob,new Lb,new Bb,new $b],refiners:[new Fb,new Mb]},r)}var ZF,qne,Cz=b(()=>{Ti();ai();Le();ft();JW();ez();us();tz();rz();nz();lz();pz();gz();vz();yz();bz();ZF=new ke(wz()),qne=new ke(JF(!0))});function Qs(r){return String(r).replace(/\u2019/g,"'").replace(/\u201D/g,'"').replace(/\u3000/g," ").replace(/\uFFE5/g,"\xA5").replace(/[\uFF01\uFF03-\uFF06\uFF08\uFF09\uFF0C-\uFF19\uFF1C-\uFF1F\uFF21-\uFF3B\uFF3D\uFF3F\uFF41-\uFF5B\uFF5D\uFF5E]/g,Hne)}function Hne(r){return String.fromCharCode(r.charCodeAt(0)-65248)}function _A(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?Al[n]:e*Al[n]:e+=Al[n]}return e}var Al,Gm,Ym=b(()=>{Al={\u96F6:0,"\u3007":0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10},Gm={\u65E5:0,\u6708:1,\u706B:2,\u6C34:3,\u6728:4,\u91D1:5,\u571F:6}});var jne,xz,Gne,tM,Yne,Kne,Qne,Ub,Ez=b(()=>{Ym();zt();jne=/(?:(?:([同今本])|((昭和|平成|令和)?([0-9-]{1,4}|元)))年\s*)?([0-9-]{1,2})月\s*([0-9-]{1,2})日/i,xz=1,Gne=2,tM=3,Yne=4,Kne=5,Qne=6,Ub=class{pattern(){return jne}extract(e,t){let n=parseInt(Qs(t[Kne])),i=parseInt(Qs(t[Qne])),o=e.createParsingComponents({day:i,month:n});if(t[xz]&&t[xz].match("\u540C|\u4ECA|\u672C")&&o.assign("year",e.reference.getDateWithAdjustedTimezone().getFullYear()),t[Gne]){let s=t[Yne],a=s=="\u5143"?1:parseInt(Qs(s));t[tM]=="\u4EE4\u548C"?a+=2018:t[tM]=="\u5E73\u6210"?a+=1988:t[tM]=="\u662D\u548C"&&(a+=1925),o.assign("year",a)}else{let s=mt(e.refDate,i,n);o.imply("year",s)}return o}}});var qb,Tz=b(()=>{yo();qb=class extends Yt{patternBetween(){return/^\s*(から||ー|-||~)\s*$/i}}});function Zne(r){switch(r){case"\u304D\u3087\u3046":return"\u4ECA\u65E5";case"\u307B\u3093\u3058\u3064":return"\u672C\u65E5";case"\u304D\u306E\u3046":return"\u6628\u65E5";case"\u3042\u3057\u305F":return"\u660E\u65E5";case"\u3053\u3093\u3084":return"\u4ECA\u591C";case"\u3053\u3093\u3086\u3046":return"\u4ECA\u5915";case"\u3053\u3093\u3070\u3093":return"\u4ECA\u6669";case"\u3051\u3055":return"\u4ECA\u671D";default:return r}}var Xne,Wb,_z=b(()=>{ft();si();Xne=/今日|きょう|本日|ほんじつ|昨日|きのう|明日|あした|今夜|こんや|今夕|こんゆう|今晩|こんばん|今朝|けさ/i;Wb=class{pattern(){return Xne}extract(e,t){let n=Zne(t[0]),i=e.createParsingComponents();switch(n){case"\u6628\u65E5":return vn(e.reference);case"\u660E\u65E5":return yn(e.reference);case"\u672C\u65E5":case"\u4ECA\u65E5":return _r(e.reference)}n=="\u4ECA\u591C"||n=="\u4ECA\u5915"||n=="\u4ECA\u6669"?(i.imply("hour",22),i.assign("meridiem",j.PM)):n.match("\u4ECA\u671D")&&(i.imply("hour",6),i.assign("meridiem",j.AM));let o=e.refDate;return i.assign("day",o.getDate()),i.assign("month",o.getMonth()+1),i.assign("year",o.getFullYear()),i}}});var Jne,zb,Az=b(()=>{Ym();Qi();Jne=new RegExp("((?<prefix>\u524D\u306E|\u6B21\u306E|\u4ECA\u9031))?(?<weekday>"+Object.keys(Gm).join("|")+")(?:\u66DC\u65E5|\u66DC)","i"),zb=class{pattern(){return Jne}extract(e,t){let n=t.groups.weekday,i=Gm[n];if(i===void 0)return null;let o=t.groups.prefix||"",s=null;return o.match(/前の/)?s="last":o.match(/次の/)?s="next":o.match(/今週/)&&(s="this"),cr(e.reference,i,s)}}});var eie,kz,tie,rie,Hb,Sz=b(()=>{zt();Ym();eie=new RegExp("([0-9\uFF10-\uFF19]{4}[\\/|\\\uFF0F])?([0-1\uFF10-\uFF11]{0,1}[0-9\uFF10-\uFF19]{1})(?:[\\/|\\\uFF0F]([0-3\uFF10-\uFF13]{0,1}[0-9\uFF10-\uFF19]{1}))","i"),kz=1,tie=2,rie=3,Hb=class{pattern(){return eie}extract(e,t){let n=e.createParsingComponents(),i=parseInt(Qs(t[tie])),o=parseInt(Qs(t[rie]));if(i<1||i>12||o<1||o>31)return null;if(n.assign("day",o),n.assign("month",i),t[kz]){let s=parseInt(Qs(t[kz])),a=Gr(s);n.assign("year",a)}else{let s=mt(e.reference.instant,o,i);n.imply("year",s)}return n}}});function Rz(r,e,t,n,i){let o=0,s=-1,a=r.createParsingComponents();if(o=parseInt(Qs(e)),isNaN(o)&&(o=_A(e)),o>24)return null;if(t){let l;if(t==="\u534A"?l=30:(l=parseInt(Qs(t)),isNaN(l)&&(l=_A(t))),l>=60)return null;a.assign("minute",l)}if(n){let l=parseInt(Qs(n));if(isNaN(l)&&(l=_A(n)),l>=60)return null;a.assign("second",l)}if(i){if(o>12)return null;let l=i;l==="\u5348\u524D"||l[0].toLowerCase()==="a"?(s=j.AM,o===12&&(o=0)):(l==="\u5348\u5F8C"||l[0].toLowerCase()==="p")&&(s=j.PM,o!=12&&(o+=12))}return a.assign("hour",o),s>=0?a.assign("meridiem",s):o<12?a.imply("meridiem",j.AM):a.imply("meridiem",j.PM),a}var nie,iie,Dz,Iz,Pz,Fz,Mz,jb,$z=b(()=>{fe();ft();Ym();nie=new RegExp("(?:(\u5348\u524D|\u5348\u5F8C|A.M.|P.M.|AM|PM))?(?:[\\s,\uFF0C\u3001]*)(?:([0-9\uFF10-\uFF19]+|["+Object.keys(Al).join("")+"]+)(?:\\s*)(?:\u6642(?!\u9593)|:|\uFF1A)(?:\\s*)([0-9\uFF10-\uFF19]+|\u534A|["+Object.keys(Al).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)([0-9\uFF10-\uFF19]+|["+Object.keys(Al).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),iie=new RegExp("(?:^\\s*(?:\u304B\u3089|\\-|\\\u2013|\\\uFF0D|\\~|\\\u301C)\\s*)(?:(\u5348\u524D|\u5348\u5F8C|A.M.|P.M.|AM|PM))?(?:[\\s,\uFF0C\u3001]*)(?:([0-9\uFF10-\uFF19]+|["+Object.keys(Al).join("")+"]+)(?:\\s*)(?:\u6642|:|\uFF1A)(?:\\s*)([0-9\uFF10-\uFF19]+|\u534A|["+Object.keys(Al).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)([0-9\uFF10-\uFF19]+|["+Object.keys(Al).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),Dz=1,Iz=2,Pz=3,Fz=4,Mz=5,jb=class extends B{innerPattern(){return nie}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]);return n.start=Rz(e,t[Iz],t[Pz],t[Fz],t[Dz]??t[Mz]),n.start?(t=iie.exec(e.text.substring(n.index+n.text.length)),t?(n.text=n.text+t[0],n.end=Rz(e,t[Iz],t[Pz],t[Fz],t[Dz]??t[Mz]),n.end?(!n.end.isCertain("meridiem")&&n.start.isCertain("meridiem")&&(n.end.imply("meridiem",n.start.get("meridiem")),n.start.get("meridiem")===j.PM&&(n.start.get("hour")-12>n.end.get("hour")?n.end.imply("meridiem",j.AM):n.end.get("hour")<12&&n.end.assign("hour",n.end.get("hour")+12))),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n):null):n):(t.index+=t[0].length,null)}}});var Gb,Oz=b(()=>{bo();Gb=class extends Kt{patternBetween(){return/^\s*(の)?\s*$/i}}});var Yb,Nz=b(()=>{Ks();Yb=class extends oi{mergeResults(e,t,n){let i=t.clone();return i.text=t.text+e+n.text,i.start.assign("weekday",n.start.get("weekday")),i.end&&i.end.assign("weekday",n.start.get("weekday")),i}shouldMergeResults(e,t,n){return t.start.isCertain("day")&&n.start.isOnlyWeekdayComponent()&&!n.start.isCertain("hour")&&e.match(/^[,、の]?\s*$/)!==null}}});var oie,Kb,Lz=b(()=>{Ym();Qi();oie=new RegExp("(?:\\(|\\\uFF08)(?<weekday>"+Object.keys(Gm).join("|")+")(?:\\)|\\\uFF09)","i"),Kb=class{pattern(){return oie}extract(e,t){let n=t.groups.weekday,i=Gm[n];return i===void 0?null:cr(e.reference,i)}}});var iM={};Jr(iM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>rM,createCasualConfiguration:()=>Bz,createConfiguration:()=>nM,parse:()=>aie,parseDate:()=>lie,strict:()=>sie});function aie(r,e,t){return rM.parse(r,e,t)}function lie(r,e,t){return rM.parseDate(r,e,t)}function Bz(){let r=nM(!1);return r.parsers.unshift(new Wb),r}function nM(r=!0){let e=Ht({parsers:[new Ub,new zb,new Kb,new Hb,new jb],refiners:[new Yb,new Gb,new qb]},r);return e.refiners=e.refiners.filter(t=>!(t instanceof Dc)),e}var rM,sie,Vz=b(()=>{Ez();Tz();_z();Az();Sz();$z();Oz();ai();Le();ft();Nz();Lz();Ti();vA();rM=new ke(Bz()),sie=new ke(nM(!0))});function qz(r){if(r.match(/^[0-9]{1,4}$/)){let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}return r.match(/a\.?\s*c\.?/i)?(r=r.replace(/a\.?\s*c\.?/i,""),-parseInt(r)):parseInt(r)}var oM,sM,Uz,AA=b(()=>{oM={domingo:0,dom:0,segunda:1,"segunda-feira":1,seg:1,ter\u00E7a:2,"ter\xE7a-feira":2,ter:2,quarta:3,"quarta-feira":3,qua:3,quinta:4,"quinta-feira":4,qui:4,sexta:5,"sexta-feira":5,sex:5,s\u00E1bado:6,sabado:6,sab:6},sM={janeiro:1,jan:1,"jan.":1,fevereiro:2,fev:2,"fev.":2,mar\u00E7o:3,mar:3,"mar.":3,abril:4,abr:4,"abr.":4,maio:5,mai:5,"mai.":5,junho:6,jun:6,"jun.":6,julho:7,jul:7,"jul.":7,agosto:8,ago:8,"ago.":8,setembro:9,set:9,"set.":9,outubro:10,out:10,"out.":10,novembro:11,nov:11,"nov.":11,dezembro:12,dez:12,"dez.":12},Uz="[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?"});var cie,uie,die,pie,Qb,Wz=b(()=>{AA();ze();fe();Qi();cie=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(este|esta|passado|pr[o\xF3]ximo)\\s*)?(${te(oM)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(este|esta|passado|pr[\xF3o]ximo)\\s*semana)?(?=\\W|\\d|$)`,"i"),uie=1,die=2,pie=3,Qb=class extends B{innerPattern(){return cie}innerExtract(e,t){let n=t[die].toLowerCase(),i=oM[n];if(i===void 0)return null;let o=t[uie],s=t[pie],a=o||s||"";a=a.toLowerCase();let l=null;return a=="passado"?l="this":a=="pr\xF3ximo"||a=="proximo"?l="next":a=="este"&&(l="this"),cr(e.reference,i,l)}}});var Xb,zz=b(()=>{La();Xb=class extends Yr{primaryPrefix(){return"(?:(?:ao?|\xE0s?|das|da|de|do)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a(?:o)?|\\?)\\s*"}}});var Zb,Hz=b(()=>{bo();Zb=class extends Kt{patternBetween(){return new RegExp("^\\s*(?:,|\xE0)?\\s*$")}}});var Jb,jz=b(()=>{yo();Jb=class extends Yt{patternBetween(){return/^\s*(?:-)\s*$/i}}});var fie,Gz,Yz,mie,Kz,ew,Qz=b(()=>{zt();AA();AA();ze();fe();fie=new RegExp(`([0-9]{1,2})(?:\xBA|\xAA|\xB0)?(?:\\s*(?:desde|de|\\-|\\\u2013|ao?|\\s)\\s*([0-9]{1,2})(?:\xBA|\xAA|\xB0)?)?\\s*(?:de)?\\s*(?:-|/|\\s*(?:de|,)?\\s*)(${te(sM)})(?:\\s*(?:de|,)?\\s*(${Uz}))?(?=\\W|$)`,"i"),Gz=1,Yz=2,mie=3,Kz=4,ew=class extends B{innerPattern(){return fie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=sM[t[mie].toLowerCase()],o=parseInt(t[Gz]);if(o>31)return t.index=t.index+t[Gz].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[Kz]){let s=qz(t[Kz]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[Yz]){let s=parseInt(t[Yz]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var tw,Xz=b(()=>{fe();si();tw=class extends B{innerPattern(e){return/(agora|hoje|amanha|amanhã|ontem)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"agora":return Or(e.reference);case"hoje":return _r(e.reference);case"amanha":case"amanh\xE3":return yn(e.reference);case"ontem":return vn(e.reference)}return i}}});var rw,Zz=b(()=>{ft();fe();on();rw=class extends B{innerPattern(){return/(?:esta\s*)?(manha|manhã|tarde|meia-noite|meio-dia|noite)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[1].toLowerCase()){case"tarde":i.imply("meridiem",j.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"noite":i.imply("meridiem",j.PM),i.imply("hour",22),i.addTag("casualReference/evening");break;case"manha":case"manh\xE3":i.imply("meridiem",j.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"meia-noite":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"meio-dia":i.imply("meridiem",j.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});var cM={};Jr(cM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>aM,createCasualConfiguration:()=>Jz,createConfiguration:()=>lM,parse:()=>gie,parseDate:()=>vie,strict:()=>hie});function gie(r,e,t){return aM.parse(r,e,t)}function vie(r,e,t){return aM.parseDate(r,e,t)}function Jz(r=!0){let e=lM(!1,r);return e.parsers.push(new tw),e.parsers.push(new rw),e}function lM(r=!0,e=!0){return Ht({parsers:[new vr(e),new Qb,new Xb,new ew],refiners:[new Zb,new Jb]},r)}var aM,hie,e3=b(()=>{Ti();ai();Le();ft();us();Wz();zz();Hz();jz();Qz();Xz();Zz();aM=new ke(Jz()),hie=new ke(lM(!0))});var nw,t3=b(()=>{yo();nw=class extends Yt{patternBetween(){return/^\s*(tot|-)\s*$/i}}});var iw,r3=b(()=>{bo();iw=class extends Kt{patternBetween(){return new RegExp("^\\s*(om|na|voor|in de|,|-)?\\s*$")}}});var ow,n3=b(()=>{fe();si();ow=class extends B{innerPattern(e){return/(nu|vandaag|morgen|morgend|gisteren)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"nu":return Or(e.reference);case"vandaag":return _r(e.reference);case"morgen":case"morgend":return yn(e.reference);case"gisteren":return vn(e.reference)}return i}}});var yie,bie,sw,i3=b(()=>{ft();fe();on();yie=1,bie=2,sw=class extends B{innerPattern(){return/(deze)?\s*(namiddag|avond|middernacht|ochtend|middag|'s middags|'s avonds|'s ochtends)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[yie]==="deze"&&(i.assign("day",e.refDate.getDate()),i.assign("month",e.refDate.getMonth()+1),i.assign("year",e.refDate.getFullYear())),t[bie].toLowerCase()){case"namiddag":case"'s namiddags":i.imply("meridiem",j.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"avond":case"'s avonds'":i.imply("meridiem",j.PM),i.imply("hour",20),i.addTag("casualReference/evening");break;case"middernacht":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"ochtend":case"'s ochtends":i.imply("meridiem",j.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"middag":case"'s middags":i.imply("meridiem",j.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});function Cie(r){let e=r.toLowerCase();return uM[e]!==void 0?uM[e]:e==="paar"?2:e==="half"||e.match(/halve?/)?.5:parseFloat(e.replace(",","."))}function mM(r){let e=r.toLowerCase();return dM[e]!==void 0?dM[e]:(e=e.replace(/(?:ste|de)$/i,""),parseInt(e))}function SA(r){if(/voor Christus/i.test(r))return r=r.replace(/voor Christus/i,""),-parseInt(r);if(/na Christus/i.test(r))return r=r.replace(/na Christus/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function Gu(r){let e={},t=r,n=o3.exec(t);for(;n;)xie(e,n),t=t.substring(n[0].length),n=o3.exec(t);return e}function xie(r,e){let t=Cie(e[1]),n=aw[e[2].toLowerCase()];r[n]=t}var pM,Rc,uM,dM,aw,wie,fM,kA,s3,o3,kl,ds=b(()=>{ze();zt();pM={zondag:0,zon:0,"zon.":0,zo:0,"zo.":0,maandag:1,ma:1,"ma.":1,dinsdag:2,din:2,"din.":2,di:2,"di.":2,woensdag:3,woe:3,"woe.":3,wo:3,"wo.":3,donderdag:4,dond:4,"dond.":4,do:4,"do.":4,vrijdag:5,vrij:5,"vrij.":5,vr:5,"vr.":5,zaterdag:6,zat:6,"zat.":6,za:6,"za.":6},Rc={januari:1,jan:1,"jan.":1,februari:2,feb:2,"feb.":2,maart:3,mar:3,"mar.":3,mrt:3,"mrt.":3,april:4,apr:4,"apr.":4,mei:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,augustus:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,"sept.":9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,december:12,dec:12,"dec.":12},uM={een:1,twee:2,drie:3,vier:4,vijf:5,zes:6,zeven:7,acht:8,negen:9,tien:10,elf:11,twaalf:12},dM={eerste:1,tweede:2,derde:3,vierde:4,vijfde:5,zesde:6,zevende:7,achtste:8,negende:9,tiende:10,elfde:11,twaalfde:12,dertiende:13,veertiende:14,vijftiende:15,zestiende:16,zeventiende:17,achttiende:18,negentiende:19,twintigste:20,eenentwintigste:21,twee\u00EBntwintigste:22,drieentwintigste:23,vierentwintigste:24,vijfentwintigste:25,zesentwintigste:26,zevenentwintigste:27,achtentwintig:28,negenentwintig:29,dertigste:30,eenendertigste:31},aw={sec:"second",second:"second",seconden:"second",min:"minute",mins:"minute",minute:"minute",minuut:"minute",minuten:"minute",minuutje:"minute",h:"hour",hr:"hour",hrs:"hour",uur:"hour",u:"hour",uren:"hour",dag:"day",dagen:"day",week:"week",weken:"week",maand:"month",maanden:"month",jaar:"year",jr:"year",jaren:"year"},wie=`(?:${te(uM)}|[0-9]+|[0-9]+[\\.,][0-9]+|halve?|half|paar)`;fM=`(?:${te(dM)}|[0-9]{1,2}(?:ste|de)?)`;kA="(?:[1-9][0-9]{0,3}\\s*(?:voor Christus|na Christus)|[1-2][0-9]{3}|[5-9][0-9])";s3=`(${wie})\\s{0,5}(${te(aw)})\\s{0,5}`,o3=new RegExp(s3,"i"),kl=Tr("(?:(?:binnen|in)\\s*)?",s3)});var lw,a3=b(()=>{ds();Le();fe();lw=class extends B{innerPattern(){return new RegExp("(?:binnen|in|binnen de|voor)\\s*("+kl+")(?=\\W|$)","i")}innerExtract(e,t){let n=Gu(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var Eie,Tie,_ie,Aie,cw,l3=b(()=>{ds();ze();fe();Qi();Eie=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:op\\s*?)?(?:(deze|vorige|volgende)\\s*(?:week\\s*)?)?(${te(pM)})(?=\\W|$)`,"i"),Tie=1,_ie=2,Aie=3,cw=class extends B{innerPattern(){return Eie}innerExtract(e,t){let n=t[_ie].toLowerCase(),i=pM[n],o=t[Tie],s=t[Aie],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a=="vorige"?l="last":a=="volgende"?l="next":a=="deze"&&(l="this"),cr(e.reference,i,l)}}});var kie,Sie,c3,u3,d3,uw,p3=b(()=>{zt();ds();ds();ds();ze();fe();kie=new RegExp(`(?:on\\s*?)?(${fM})(?:\\s*(?:tot|\\-|\\\u2013|until|through|till|\\s)\\s*(${fM}))?(?:-|/|\\s*(?:of)?\\s*)(`+te(Rc)+`)(?:(?:-|/|,?\\s*)(${kA}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),Sie=3,c3=1,u3=2,d3=4,uw=class extends B{innerPattern(){return kie}innerExtract(e,t){let n=Rc[t[Sie].toLowerCase()],i=mM(t[c3]);if(i>31)return t.index=t.index+t[c3].length,null;let o=e.createParsingComponents({day:i,month:n});if(t[d3]){let l=SA(t[d3]);o.assign("year",l)}else{let l=mt(e.refDate,i,n);o.imply("year",l)}if(!t[u3])return o;let s=mM(t[u3]),a=e.createParsingResult(t.index,t[0]);return a.start=o,a.end=o.clone(),a.end.assign("day",s),a}}});var Die,Iie,f3,Km,m3=b(()=>{ds();zt();ze();ds();fe();Die=new RegExp(`(${te(Rc)})\\s*(?:[,-]?\\s*(${kA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),Iie=1,f3=2,Km=class extends B{innerPattern(){return Die}innerExtract(e,t){let n=e.createParsingComponents();n.imply("day",1);let i=t[Iie],o=Rc[i.toLowerCase()];if(n.assign("month",o),t[f3]){let s=SA(t[f3]);n.assign("year",s)}else{let s=mt(e.refDate,1,o);n.imply("year",s)}return n}}});var Pie,Fie,Mie,dw,h3=b(()=>{fe();Pie=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),Fie=1,Mie=2,dw=class extends B{innerPattern(){return Pie}innerExtract(e,t){let n=parseInt(t[Mie]),i=parseInt(t[Fie]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});var pw,g3=b(()=>{La();pw=class extends Yr{primaryPrefix(){return"(?:(?:om)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|om|\\?)\\s*"}primarySuffix(){return"(?:\\s*(?:uur))?(?!/)(?=\\W|$)"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});var Rie,$ie,Oie,v3,Nie,fw,y3=b(()=>{ds();ze();fe();Rie=new RegExp(`([0-9]{4})[\\.\\/\\s](?:(${te(Rc)})|([0-9]{1,2}))[\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),$ie=1,Oie=2,v3=3,Nie=4,fw=class extends B{innerPattern(){return Rie}innerExtract(e,t){let n=t[v3]?parseInt(t[v3]):Rc[t[Oie].toLowerCase()];if(n<1||n>12)return null;let i=parseInt(t[$ie]);return{day:parseInt(t[Nie]),month:n,year:i}}}});var Lie,Bie,mw,b3=b(()=>{fe();ft();on();Lie=1,Bie=2,mw=class extends B{innerPattern(e){return/(gisteren|morgen|van)(ochtend|middag|namiddag|avond|nacht)(?=\W|$)/i}innerExtract(e,t){let n=t[Lie].toLowerCase(),i=t[Bie].toLowerCase(),o=e.createParsingComponents(),s=e.refDate;switch(n){case"gisteren":let a=new Date(s.getTime());a.setDate(a.getDate()-1),nt(o,a);break;case"van":nt(o,s);break;case"morgen":let l=new Date(s.getTime());l.setDate(l.getDate()+1),nt(o,l),Lt(o,l);break}switch(i){case"ochtend":o.imply("meridiem",j.AM),o.imply("hour",6);break;case"middag":o.imply("meridiem",j.AM),o.imply("hour",12);break;case"namiddag":o.imply("meridiem",j.PM),o.imply("hour",15);break;case"avond":o.imply("meridiem",j.PM),o.imply("hour",20);break}return o}}});var Vie,Uie,qie,hw,w3=b(()=>{ds();Le();fe();Bt();Vie=new RegExp(`(dit|deze|vorig|afgelopen|(?:aan)?komend|over|\\+|-)e?\\s*(${kl})(?=\\W|$)`,"i"),Uie=1,qie=2,hw=class extends B{innerPattern(){return Vie}innerExtract(e,t){let n=t[Uie].toLowerCase(),i=Gu(t[qie]);switch(n){case"vorig":case"afgelopen":case"-":i=tt(i);break}return X.createRelativeFromReference(e.reference,i)}}});var Wie,zie,Hie,gw,C3=b(()=>{ds();Le();fe();ze();Wie=new RegExp(`(dit|deze|(?:aan)?komend|volgend|afgelopen|vorig)e?\\s*(${te(aw)})(?=\\s*)(?=\\W|$)`,"i"),zie=1,Hie=2,gw=class extends B{innerPattern(){return Wie}innerExtract(e,t){let n=t[zie].toLowerCase(),i=t[Hie].toLowerCase(),o=aw[i];if(n=="volgend"||n=="komend"||n=="aankomend"){let l={};return l[o]=1,X.createRelativeFromReference(e.reference,l)}if(n=="afgelopen"||n=="vorig"){let l={};return l[o]=-1,X.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return i.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):i.match(/maand/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):i.match(/jaar/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var jie,Gie,vw,x3=b(()=>{ds();Le();fe();Bt();jie=new RegExp("("+kl+")(?:geleden|voor|eerder)(?=(?:\\W|$))","i"),Gie=new RegExp("("+kl+")geleden(?=(?:\\W|$))","i"),vw=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Gie:jie}innerExtract(t,n){let i=Gu(n[1]),o=tt(i);return X.createRelativeFromReference(t.reference,o)}}});var Yie,Kie,Qie,yw,E3=b(()=>{ds();Le();fe();Yie=new RegExp("("+kl+")(later|na|vanaf nu|voortaan|vooruit|uit)(?=(?:\\W|$))","i"),Kie=new RegExp("("+kl+")(later|vanaf nu)(?=(?:\\W|$))","i"),Qie=1,yw=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Kie:Yie}innerExtract(t,n){let i=Gu(n[Qie]);return X.createRelativeFromReference(t.reference,i)}}});var vM={};Jr(vM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>hM,createCasualConfiguration:()=>T3,createConfiguration:()=>gM,parse:()=>Zie,parseDate:()=>Jie,strict:()=>Xie});function Zie(r,e,t){return hM.parse(r,e,t)}function Jie(r,e,t){return hM.parseDate(r,e,t)}function T3(r=!0){let e=gM(!1,r);return e.parsers.unshift(new ow),e.parsers.unshift(new sw),e.parsers.unshift(new mw),e.parsers.unshift(new Km),e.parsers.unshift(new gw),e.parsers.unshift(new hw),e}function gM(r=!0,e=!0){return Ht({parsers:[new vr(e),new lw,new uw,new Km,new cw,new fw,new dw,new pw(r),new vw(r),new yw(r)],refiners:[new iw,new nw]},r)}var hM,Xie,_3=b(()=>{Ti();ai();Le();ft();t3();r3();n3();i3();us();a3();l3();p3();m3();h3();g3();y3();b3();w3();C3();x3();E3();hM=new ke(T3()),Xie=new ke(gM(!0))});function $o(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?bn[n]:e*bn[n]:e+=bn[n]}return e}function A3(r){let e="";for(let t=0;t<r.length;t++){let n=r[t];e=e+bn[n]}return parseInt(e)}var bn,Qm,kp=b(()=>{bn={\u96F6:0,"\u3007":0,\u4E00:1,\u4E8C:2,\u4E24:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10},Qm={\u5929:0,\u65E5:0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6}});var yM,k3,bM,Sp,wM=b(()=>{fe();kp();yM=1,k3=2,bM=3,Sp=class extends B{innerPattern(){return new RegExp("(\\d{2,4}|["+Object.keys(bn).join("")+"]{4}|["+Object.keys(bn).join("")+"]{2})?(?:\\s*)(?:\u5E74)?(?:[\\s|,|\uFF0C]*)(\\d{1,2}|["+Object.keys(bn).join("")+"]{1,3})(?:\\s*)(?:\u6708)(?:\\s*)(\\d{1,2}|["+Object.keys(bn).join("")+"]{1,3})?(?:\\s*)(?:\u65E5|\u53F7)?")}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[k3]);if(isNaN(i)&&(i=$o(t[k3])),n.start.assign("month",i),t[bM]){let o=parseInt(t[bM]);isNaN(o)&&(o=$o(t[bM])),n.start.assign("day",o)}else n.start.imply("day",e.refDate.getDate());if(t[yM]){let o=parseInt(t[yM]);isNaN(o)&&(o=A3(t[yM])),n.start.assign("year",o)}else n.start.imply("year",e.refDate.getFullYear());return n}}});var eoe,CM,toe,Dp,xM=b(()=>{fe();Bt();kp();eoe=new RegExp("(\\d+|["+Object.keys(bn).join("")+"]+|\u534A|\u51E0)(?:\\s*)(?:\u4E2A)?(\u79D2(?:\u949F)?|\u5206\u949F|\u5C0F\u65F6|\u949F|\u65E5|\u5929|\u661F\u671F|\u793C\u62DC|\u6708|\u5E74)(?:(?:\u4E4B|\u8FC7)?\u540E|(?:\u4E4B)?\u5185)","i"),CM=1,toe=2,Dp=class extends B{innerPattern(){return eoe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[CM]);if(isNaN(i)&&(i=$o(t[CM])),isNaN(i)){let c=t[CM];if(c==="\u51E0")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[toe][0];if(a.match(/[日天星礼月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u793C"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i);let c=yt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u949F")&&(o.hour=i);let l=yt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var roe,Ip,EM=b(()=>{fe();kp();roe=new RegExp("(?<prefix>\u4E0A|\u4E0B|\u8FD9)(?:\u4E2A)?(?:\u661F\u671F|\u793C\u62DC|\u5468)(?<weekday>"+Object.keys(Qm).join("|")+")"),Ip=class extends B{innerPattern(){return roe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Qm[i];if(o===void 0)return null;let s=null,a=t.groups.prefix;a=="\u4E0A"?s="last":a=="\u4E0B"?s="next":a=="\u8FD9"&&(s="this");let l=new Date(e.refDate.getTime()),c=!1,u=l.getDay();if(s=="last"||s=="past")l.setDate(l.getDate()+(o-7-u)),c=!0;else if(s=="next")l.setDate(l.getDate()+(o+7-u)),c=!0;else if(s=="this")l.setDate(l.getDate()+(o-u));else{let d=o-u;Math.abs(d-7)<Math.abs(d)&&(d-=7),Math.abs(d+7)<Math.abs(d)&&(d+=7),l.setDate(l.getDate()+d)}return n.start.assign("weekday",o),c?(n.start.assign("day",l.getDate()),n.start.assign("month",l.getMonth()+1),n.start.assign("year",l.getFullYear())):(n.start.imply("day",l.getDate()),n.start.imply("month",l.getMonth()+1),n.start.imply("year",l.getFullYear())),n}}});var noe,ioe,bw,DA,IA,ww,PA,FA,Xs,Xm,MA,Pp,TM=b(()=>{fe();kp();noe=new RegExp("(?:\u4ECE|\u81EA)?(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(bn).join("")+"]+)(?:\\s*)(?:\u70B9|\u65F6|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),ioe=new RegExp("(?:^\\s*(?:\u5230|\u81F3|\\-|\\\u2013|\\~|\\\u301C)\\s*)(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(bn).join("")+"]+)(?:\\s*)(?:\u70B9|\u65F6|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),bw=1,DA=2,IA=3,ww=4,PA=5,FA=6,Xs=7,Xm=8,MA=9,Pp=class extends B{patternLeftBoundary(){return"()"}innerPattern(){return noe}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]),i=new Date(e.reference.instant.getTime());if(t[bw]){let u=t[bw];u=="\u660E"?e.reference.instant.getHours()>1&&i.setDate(i.getDate()+1):u=="\u6628"?i.setDate(i.getDate()-1):u=="\u524D"?i.setDate(i.getDate()-2):u=="\u5927\u524D"?i.setDate(i.getDate()-3):u=="\u540E"?i.setDate(i.getDate()+2):u=="\u5927\u540E"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else if(t[ww]){let u=t[ww];u=="\u660E"?i.setDate(i.getDate()+1):u=="\u6628"?i.setDate(i.getDate()-1):u=="\u524D"?i.setDate(i.getDate()-2):u=="\u5927\u524D"?i.setDate(i.getDate()-3):u=="\u540E"?i.setDate(i.getDate()+2):u=="\u5927\u540E"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else n.start.imply("day",i.getDate()),n.start.imply("month",i.getMonth()+1),n.start.imply("year",i.getFullYear());let o=0,s=0,a=-1;if(t[Xm]){let u=parseInt(t[Xm]);if(isNaN(u)&&(u=$o(t[Xm])),u>=60)return null;n.start.assign("second",u)}if(o=parseInt(t[FA]),isNaN(o)&&(o=$o(t[FA])),t[Xs]?t[Xs]=="\u534A"?s=30:t[Xs]=="\u6B63"||t[Xs]=="\u6574"?s=0:(s=parseInt(t[Xs]),isNaN(s)&&(s=$o(t[Xs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),t[MA]){if(o>12)return null;let u=t[MA][0].toLowerCase();u=="a"&&(a=0,o==12&&(o=0)),u=="p"&&(a=1,o!=12&&(o+=12))}else if(t[DA]){let d=t[DA][0];d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(t[IA]){let d=t[IA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(t[PA]){let d=t[PA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}n.start.assign("hour",o),n.start.assign("minute",s),a>=0?n.start.assign("meridiem",a):o<12?n.start.imply("meridiem",0):n.start.imply("meridiem",1);let l=ioe.exec(e.text.substring(n.index+n.text.length));if(!l)return n.text.match(/^\d+$/)?null:n;let c=new Date(i.getTime());if((l[bw]||l[ww])&&(c=new Date(e.reference.instant.getTime())),n.end=e.createParsingComponents(),l[bw]){let u=l[bw];u=="\u660E"?e.reference.instant.getHours()>1&&c.setDate(c.getDate()+1):u=="\u6628"?c.setDate(c.getDate()-1):u=="\u524D"?c.setDate(c.getDate()-2):u=="\u5927\u524D"?c.setDate(c.getDate()-3):u=="\u540E"?c.setDate(c.getDate()+2):u=="\u5927\u540E"&&c.setDate(c.getDate()+3),n.end.assign("day",c.getDate()),n.end.assign("month",c.getMonth()+1),n.end.assign("year",c.getFullYear())}else if(l[ww]){let u=l[ww];u=="\u660E"?c.setDate(c.getDate()+1):u=="\u6628"?c.setDate(c.getDate()-1):u=="\u524D"?c.setDate(c.getDate()-2):u=="\u5927\u524D"?c.setDate(c.getDate()-3):u=="\u540E"?c.setDate(c.getDate()+2):u=="\u5927\u540E"&&c.setDate(c.getDate()+3),n.end.assign("day",c.getDate()),n.end.assign("month",c.getMonth()+1),n.end.assign("year",c.getFullYear())}else n.end.imply("day",c.getDate()),n.end.imply("month",c.getMonth()+1),n.end.imply("year",c.getFullYear());if(o=0,s=0,a=-1,l[Xm]){let u=parseInt(l[Xm]);if(isNaN(u)&&(u=$o(l[Xm])),u>=60)return null;n.end.assign("second",u)}if(o=parseInt(l[FA]),isNaN(o)&&(o=$o(l[FA])),l[Xs]?l[Xs]=="\u534A"?s=30:l[Xs]=="\u6B63"||l[Xs]=="\u6574"?s=0:(s=parseInt(l[Xs]),isNaN(s)&&(s=$o(l[Xs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),l[MA]){if(o>12)return null;let u=l[MA][0].toLowerCase();u=="a"&&(a=0,o==12&&(o=0)),u=="p"&&(a=1,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==0?(n.start.imply("meridiem",0),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",1),n.start.get("hour")!=12&&n.start.assign("hour",n.start.get("hour")+12)))}else if(l[DA]){let d=l[DA][0];d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(l[IA]){let d=l[IA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(l[PA]){let d=l[PA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}return n.text=n.text+l[0],n.end.assign("hour",o),n.end.assign("minute",s),a>=0?n.end.assign("meridiem",a):n.start.isCertain("meridiem")&&n.start.get("meridiem")==1&&n.start.get("hour")>o?n.end.imply("meridiem",0):o>12&&n.end.imply("meridiem",1),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n}}});var ooe,Fp,_M=b(()=>{fe();kp();ooe=new RegExp("(?:\u661F\u671F|\u793C\u62DC|\u5468)(?<weekday>"+Object.keys(Qm).join("|")+")"),Fp=class extends B{innerPattern(){return ooe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Qm[i];if(o===void 0)return null;let s=new Date(e.refDate.getTime()),a=!1,l=s.getDay(),c=o-l;return Math.abs(c-7)<Math.abs(c)&&(c-=7),Math.abs(c+7)<Math.abs(c)&&(c+=7),s.setDate(s.getDate()+c),n.start.assign("weekday",o),a?(n.start.assign("day",s.getDate()),n.start.assign("month",s.getMonth()+1),n.start.assign("year",s.getFullYear())):(n.start.imply("day",s.getDate()),n.start.imply("month",s.getMonth()+1),n.start.imply("year",s.getFullYear())),n}}});var soe,S3,aoe,D3,I3,loe,Mp,AM=b(()=>{fe();soe=1,S3=2,aoe=3,D3=4,I3=5,loe=6,Mp=class extends B{innerPattern(e){return new RegExp("(\u800C\u5BB6|\u7ACB(?:\u523B|\u5373)|\u5373\u523B)|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s|,|\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?","i")}innerExtract(e,t){let n=t.index,i=e.createParsingResult(n,t[0]),o=e.refDate,s=new Date(o.getTime());if(t[soe])i.start.imply("hour",o.getHours()),i.start.imply("minute",o.getMinutes()),i.start.imply("second",o.getSeconds()),i.start.imply("millisecond",o.getMilliseconds());else if(t[S3]){let a=t[S3],l=t[aoe];a=="\u660E"||a=="\u807D"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"||a=="\u5C0B"||a=="\u7434"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u5F8C"?s.setDate(s.getDate()+2):a=="\u5927\u5F8C"&&s.setDate(s.getDate()+3),l=="\u65E9"||l=="\u671D"?i.start.imply("hour",6):l=="\u665A"&&(i.start.imply("hour",22),i.start.imply("meridiem",1))}else if(t[D3]){let l=t[D3][0];l=="\u65E9"||l=="\u671D"||l=="\u4E0A"?i.start.imply("hour",6):l=="\u4E0B"||l=="\u664F"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):l=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):l=="\u591C"||l=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):l=="\u51CC"&&i.start.imply("hour",0)}else if(t[I3]){let a=t[I3];a=="\u660E"||a=="\u807D"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"||a=="\u5C0B"||a=="\u7434"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u5F8C"?s.setDate(s.getDate()+2):a=="\u5927\u5F8C"&&s.setDate(s.getDate()+3);let l=t[loe];if(l){let c=l[0];c=="\u65E9"||c=="\u671D"||c=="\u4E0A"?i.start.imply("hour",6):c=="\u4E0B"||c=="\u664F"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):c=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):c=="\u591C"||c=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):c=="\u51CC"&&i.start.imply("hour",0)}}return i.start.assign("day",s.getDate()),i.start.assign("month",s.getMonth()+1),i.start.assign("year",s.getFullYear()),i}}});function Oo(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?wn[n]:e*wn[n]:e+=wn[n]}return e}function P3(r){let e="";for(let t=0;t<r.length;t++){let n=r[t];e=e+wn[n]}return parseInt(e)}var wn,Zm,Rp=b(()=>{wn={\u96F6:0,\u4E00:1,\u4E8C:2,\u5169:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10,\u5EFF:20,\u5345:30},Zm={\u5929:0,\u65E5:0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6}});var kM,F3,SM,$p,DM=b(()=>{fe();Rp();kM=1,F3=2,SM=3,$p=class extends B{innerPattern(){return new RegExp("(\\d{2,4}|["+Object.keys(wn).join("")+"]{4}|["+Object.keys(wn).join("")+"]{2})?(?:\\s*)(?:\u5E74)?(?:[\\s|,|\uFF0C]*)(\\d{1,2}|["+Object.keys(wn).join("")+"]{1,2})(?:\\s*)(?:\u6708)(?:\\s*)(\\d{1,2}|["+Object.keys(wn).join("")+"]{1,2})?(?:\\s*)(?:\u65E5|\u865F)?")}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[F3]);if(isNaN(i)&&(i=Oo(t[F3])),n.start.assign("month",i),t[SM]){let o=parseInt(t[SM]);isNaN(o)&&(o=Oo(t[SM])),n.start.assign("day",o)}else n.start.imply("day",e.refDate.getDate());if(t[kM]){let o=parseInt(t[kM]);isNaN(o)&&(o=P3(t[kM])),n.start.assign("year",o)}else n.start.imply("year",e.refDate.getFullYear());return n}}});var coe,IM,uoe,Op,PM=b(()=>{fe();Bt();Rp();coe=new RegExp("(\\d+|["+Object.keys(wn).join("")+"]+|\u534A|\u5E7E)(?:\\s*)(?:\u500B)?(\u79D2(?:\u9418)?|\u5206\u9418|\u5C0F\u6642|\u9418|\u65E5|\u5929|\u661F\u671F|\u79AE\u62DC|\u6708|\u5E74)(?:(?:\u4E4B|\u904E)?\u5F8C|(?:\u4E4B)?\u5167)","i"),IM=1,uoe=2,Op=class extends B{innerPattern(){return coe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[IM]);if(isNaN(i)&&(i=Oo(t[IM])),isNaN(i)){let c=t[IM];if(c==="\u5E7E")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[uoe][0];if(a.match(/[日天星禮月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u79AE"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i);let c=yt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u9418")&&(o.hour=i);let l=yt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var doe,Np,FM=b(()=>{fe();Rp();doe=new RegExp("(?<prefix>\u4E0A|\u4ECA|\u4E0B|\u9019|\u5462)(?:\u500B)?(?:\u661F\u671F|\u79AE\u62DC|\u9031)(?<weekday>"+Object.keys(Zm).join("|")+")"),Np=class extends B{innerPattern(){return doe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Zm[i];if(o===void 0)return null;let s=null,a=t.groups.prefix;a=="\u4E0A"?s="last":a=="\u4E0B"?s="next":(a=="\u4ECA"||a=="\u9019"||a=="\u5462")&&(s="this");let l=new Date(e.refDate.getTime()),c=!1,u=l.getDay();if(s=="last"||s=="past")l.setDate(l.getDate()+(o-7-u)),c=!0;else if(s=="next")l.setDate(l.getDate()+(o+7-u)),c=!0;else if(s=="this")l.setDate(l.getDate()+(o-u));else{let d=o-u;Math.abs(d-7)<Math.abs(d)&&(d-=7),Math.abs(d+7)<Math.abs(d)&&(d+=7),l.setDate(l.getDate()+d)}return n.start.assign("weekday",o),c?(n.start.assign("day",l.getDate()),n.start.assign("month",l.getMonth()+1),n.start.assign("year",l.getFullYear())):(n.start.imply("day",l.getDate()),n.start.imply("month",l.getMonth()+1),n.start.imply("year",l.getFullYear())),n}}});var poe,foe,Cw,RA,$A,xw,OA,NA,Zs,Jm,LA,Lp,MM=b(()=>{fe();Rp();poe=new RegExp("(?:\u7531|\u5F9E|\u81EA)?(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(wn).join("")+"]+)(?:\\s*)(?:\u9EDE|\u6642|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(wn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(wn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),foe=new RegExp("(?:^\\s*(?:\u5230|\u81F3|\\-|\\\u2013|\\~|\\\u301C)\\s*)(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(wn).join("")+"]+)(?:\\s*)(?:\u9EDE|\u6642|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(wn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(wn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),Cw=1,RA=2,$A=3,xw=4,OA=5,NA=6,Zs=7,Jm=8,LA=9,Lp=class extends B{patternLeftBoundary(){return"()"}innerPattern(){return poe}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]),i=new Date(e.reference.instant.getTime());if(t[Cw]){let w=t[Cw];w=="\u660E"||w=="\u807D"?e.refDate.getHours()>1&&i.setDate(i.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?i.setDate(i.getDate()-1):w=="\u524D"?i.setDate(i.getDate()-2):w=="\u5927\u524D"?i.setDate(i.getDate()-3):w=="\u5F8C"?i.setDate(i.getDate()+2):w=="\u5927\u5F8C"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else if(t[xw]){let w=t[xw];w=="\u660E"||w=="\u807D"?i.setDate(i.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?i.setDate(i.getDate()-1):w=="\u524D"?i.setDate(i.getDate()-2):w=="\u5927\u524D"?i.setDate(i.getDate()-3):w=="\u5F8C"?i.setDate(i.getDate()+2):w=="\u5927\u5F8C"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else n.start.imply("day",i.getDate()),n.start.imply("month",i.getMonth()+1),n.start.imply("year",i.getFullYear());let o=0,s=0,a=-1;if(t[Jm]){var l=parseInt(t[Jm]);if(isNaN(l)&&(l=Oo(t[Jm])),l>=60)return null;n.start.assign("second",l)}if(o=parseInt(t[NA]),isNaN(o)&&(o=Oo(t[NA])),t[Zs]?t[Zs]=="\u534A"?s=30:t[Zs]=="\u6B63"||t[Zs]=="\u6574"?s=0:(s=parseInt(t[Zs]),isNaN(s)&&(s=Oo(t[Zs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),t[LA]){if(o>12)return null;var c=t[LA][0].toLowerCase();c=="a"&&(a=0,o==12&&(o=0)),c=="p"&&(a=1,o!=12&&(o+=12))}else if(t[RA]){var u=t[RA],d=u[0];d=="\u671D"||d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(t[$A]){var f=t[$A],p=f[0];p=="\u4E0A"||p=="\u671D"||p=="\u65E9"||p=="\u51CC"?(a=0,o==12&&(o=0)):(p=="\u4E0B"||p=="\u664F"||p=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(t[OA]){var m=t[OA],v=m[0];v=="\u4E0A"||v=="\u671D"||v=="\u65E9"||v=="\u51CC"?(a=0,o==12&&(o=0)):(v=="\u4E0B"||v=="\u664F"||v=="\u665A")&&(a=1,o!=12&&(o+=12))}n.start.assign("hour",o),n.start.assign("minute",s),a>=0?n.start.assign("meridiem",a):o<12?n.start.imply("meridiem",0):n.start.imply("meridiem",1);let g=foe.exec(e.text.substring(n.index+n.text.length));if(!g)return n.text.match(/^\d+$/)?null:n;let y=new Date(i.getTime());if((g[Cw]||g[xw])&&(y=new Date(e.reference.instant.getTime())),n.end=e.createParsingComponents(),g[Cw]){let w=g[Cw];w=="\u660E"||w=="\u807D"?e.refDate.getHours()>1&&y.setDate(y.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?y.setDate(y.getDate()-1):w=="\u524D"?y.setDate(y.getDate()-2):w=="\u5927\u524D"?y.setDate(y.getDate()-3):w=="\u5F8C"?y.setDate(y.getDate()+2):w=="\u5927\u5F8C"&&y.setDate(y.getDate()+3),n.end.assign("day",y.getDate()),n.end.assign("month",y.getMonth()+1),n.end.assign("year",y.getFullYear())}else if(g[xw]){let w=g[xw];w=="\u660E"||w=="\u807D"?y.setDate(y.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?y.setDate(y.getDate()-1):w=="\u524D"?y.setDate(y.getDate()-2):w=="\u5927\u524D"?y.setDate(y.getDate()-3):w=="\u5F8C"?y.setDate(y.getDate()+2):w=="\u5927\u5F8C"&&y.setDate(y.getDate()+3),n.end.assign("day",y.getDate()),n.end.assign("month",y.getMonth()+1),n.end.assign("year",y.getFullYear())}else n.end.imply("day",y.getDate()),n.end.imply("month",y.getMonth()+1),n.end.imply("year",y.getFullYear());if(o=0,s=0,a=-1,g[Jm]){let w=parseInt(g[Jm]);if(isNaN(w)&&(w=Oo(g[Jm])),w>=60)return null;n.end.assign("second",w)}if(o=parseInt(g[NA]),isNaN(o)&&(o=Oo(g[NA])),g[Zs]?g[Zs]=="\u534A"?s=30:g[Zs]=="\u6B63"||g[Zs]=="\u6574"?s=0:(s=parseInt(g[Zs]),isNaN(s)&&(s=Oo(g[Zs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),g[LA]){if(o>12)return null;var c=g[LA][0].toLowerCase();c=="a"&&(a=0,o==12&&(o=0)),c=="p"&&(a=1,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==0?(n.start.imply("meridiem",0),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",1),n.start.get("hour")!=12&&n.start.assign("hour",n.start.get("hour")+12)))}else if(g[RA]){var d=g[RA][0];d=="\u671D"||d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(g[$A]){var p=g[$A][0];p=="\u4E0A"||p=="\u671D"||p=="\u65E9"||p=="\u51CC"?(a=0,o==12&&(o=0)):(p=="\u4E0B"||p=="\u664F"||p=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(g[OA]){var v=g[OA][0];v=="\u4E0A"||v=="\u671D"||v=="\u65E9"||v=="\u51CC"?(a=0,o==12&&(o=0)):(v=="\u4E0B"||v=="\u664F"||v=="\u665A")&&(a=1,o!=12&&(o+=12))}return n.text=n.text+g[0],n.end.assign("hour",o),n.end.assign("minute",s),a>=0?n.end.assign("meridiem",a):n.start.isCertain("meridiem")&&n.start.get("meridiem")==1&&n.start.get("hour")>o?n.end.imply("meridiem",0):o>12&&n.end.imply("meridiem",1),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n}}});var moe,Bp,RM=b(()=>{fe();Rp();moe=new RegExp("(?:\u661F\u671F|\u79AE\u62DC|\u9031)(?<weekday>"+Object.keys(Zm).join("|")+")"),Bp=class extends B{innerPattern(){return moe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Zm[i];if(o===void 0)return null;let s=new Date(e.refDate.getTime()),a=!1,l=s.getDay(),c=o-l;return Math.abs(c-7)<Math.abs(c)&&(c-=7),Math.abs(c+7)<Math.abs(c)&&(c+=7),s.setDate(s.getDate()+c),n.start.assign("weekday",o),a?(n.start.assign("day",s.getDate()),n.start.assign("month",s.getMonth()+1),n.start.assign("year",s.getFullYear())):(n.start.imply("day",s.getDate()),n.start.imply("month",s.getMonth()+1),n.start.imply("year",s.getFullYear())),n}}});var Vp,$M=b(()=>{yo();Vp=class extends Yt{patternBetween(){return/^\s*(至|到|\-|\~|||ー)\s*$/i}}});var Up,OM=b(()=>{bo();Up=class extends Kt{patternBetween(){return/^\s*$/i}}});var hoe,NM,goe,Ew,M3=b(()=>{fe();Bt();Rp();hoe=new RegExp("(\\d+|["+Object.keys(wn).join("")+"]+|\u534A|\u5E7E)(?:\\s*)(?:\u500B)?(\u79D2(?:\u9418)?|\u5206\u9418|\u5C0F\u6642|\u9418|\u65E5|\u5929|\u661F\u671F|\u79AE\u62DC|\u6708|\u5E74)(?:\u4E4B)?\u524D","i"),NM=1,goe=2,Ew=class extends B{innerPattern(){return hoe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[NM]);if(isNaN(i)&&(i=Oo(t[NM])),isNaN(i)){let c=t[NM];if(c==="\u5E7E")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[goe][0];if(a.match(/[日天星禮月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u79AE"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i),o=tt(o);let c=yt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u9418")&&(o.hour=i),o=tt(o);let l=yt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var UM={};Jr(UM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>LM,createCasualConfiguration:()=>BM,createConfiguration:()=>VM,hant:()=>voe,parse:()=>boe,parseDate:()=>woe,strict:()=>yoe});function boe(r,e,t){return LM.parse(r,e,t)}function woe(r,e,t){return LM.parseDate(r,e,t)}function BM(){let r=VM();return r.parsers.unshift(new Mp),r}function VM(){let r=Ht({parsers:[new $p,new Np,new Bp,new Lp,new Op,new Ew],refiners:[new Vp,new Up]});return r.refiners=r.refiners.filter(e=>!(e instanceof Ba)),r}var voe,LM,yoe,R3=b(()=>{ob();Ti();ai();Le();ft();AM();DM();PM();M3();FM();MM();RM();$M();OM();voe=new ke(BM()),LM=new ke(BM()),yoe=new ke(VM())});var Coe,$3,xoe,O3,N3,Eoe,Tw,L3=b(()=>{fe();Coe=1,$3=2,xoe=3,O3=4,N3=5,Eoe=6,Tw=class extends B{innerPattern(e){return new RegExp("(\u73B0\u5728|\u7ACB(?:\u523B|\u5373)|\u5373\u523B)|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s|,|\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?","i")}innerExtract(e,t){let n=t.index,i=e.createParsingResult(n,t[0]),o=e.refDate,s=new Date(o.getTime());if(t[Coe])i.start.imply("hour",o.getHours()),i.start.imply("minute",o.getMinutes()),i.start.imply("second",o.getSeconds()),i.start.imply("millisecond",o.getMilliseconds());else if(t[$3]){let a=t[$3],l=t[xoe];a=="\u660E"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u540E"?s.setDate(s.getDate()+2):a=="\u5927\u540E"&&s.setDate(s.getDate()+3),l=="\u65E9"?i.start.imply("hour",6):l=="\u665A"&&(i.start.imply("hour",22),i.start.imply("meridiem",1))}else if(t[O3]){let l=t[O3][0];l=="\u65E9"||l=="\u4E0A"?i.start.imply("hour",6):l=="\u4E0B"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):l=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):l=="\u591C"||l=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):l=="\u51CC"&&i.start.imply("hour",0)}else if(t[N3]){let a=t[N3];a=="\u660E"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u540E"?s.setDate(s.getDate()+2):a=="\u5927\u540E"&&s.setDate(s.getDate()+3);let l=t[Eoe];if(l){let c=l[0];c=="\u65E9"||c=="\u4E0A"?i.start.imply("hour",6):c=="\u4E0B"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):c=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):c=="\u591C"||c=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):c=="\u51CC"&&i.start.imply("hour",0)}}return i.start.assign("day",s.getDate()),i.start.assign("month",s.getMonth()+1),i.start.assign("year",s.getFullYear()),i}}});var Toe,qM,_oe,_w,B3=b(()=>{fe();Bt();kp();Toe=new RegExp("(\\d+|["+Object.keys(bn).join("")+"]+|\u534A|\u51E0)(?:\\s*)(?:\u4E2A)?(\u79D2(?:\u949F)?|\u5206\u949F|\u5C0F\u65F6|\u949F|\u65E5|\u5929|\u661F\u671F|\u793C\u62DC|\u6708|\u5E74)(?:\u4E4B)?\u524D","i"),qM=1,_oe=2,_w=class extends B{innerPattern(){return Toe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[qM]);if(isNaN(i)&&(i=$o(t[qM])),isNaN(i)){let c=t[qM];if(c==="\u51E0")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[_oe][0];if(a.match(/[日天星礼月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u793C"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i),o=tt(o);let c=yt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u949F")&&(o.hour=i),o=tt(o);let l=yt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var Aw,V3=b(()=>{yo();Aw=class extends Yt{patternBetween(){return/^\s*(至|到|-|~|||ー)\s*$/i}}});var kw,U3=b(()=>{bo();kw=class extends Kt{patternBetween(){return/^\s*$/i}}});var jM={};Jr(jM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>WM,createCasualConfiguration:()=>zM,createConfiguration:()=>HM,hans:()=>Aoe,parse:()=>Soe,parseDate:()=>Doe,strict:()=>koe});function Soe(r,e,t){return WM.parse(r,e,t)}function Doe(r,e,t){return WM.parseDate(r,e,t)}function zM(){let r=HM();return r.parsers.unshift(new Tw),r}function HM(){let r=Ht({parsers:[new Sp,new Ip,new Fp,new Pp,new Dp,new _w],refiners:[new Aw,new kw]});return r.refiners=r.refiners.filter(e=>!(e instanceof Ba)),r}var Aoe,WM,koe,q3=b(()=>{ob();Ti();ai();Le();ft();L3();wM();xM();B3();EM();TM();_M();V3();U3();Aoe=new ke(zM()),WM=new ke(zM()),koe=new ke(HM())});var KM={};Jr(KM,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>GM,createCasualConfiguration:()=>W3,createConfiguration:()=>YM,hans:()=>jM,hant:()=>UM,parse:()=>Poe,parseDate:()=>Foe,strict:()=>Ioe});function Poe(r,e,t){return GM.parse(r,e,t)}function Foe(r,e,t){return GM.parseDate(r,e,t)}function W3(){let r=YM();return r.parsers.unshift(new Mp),r}function YM(){let r=Ht({parsers:[new $p,new Sp,new Np,new Ip,new Bp,new Fp,new Lp,new Pp,new Op,new Dp],refiners:[new Vp,new Up]});return r.refiners=r.refiners.filter(e=>!(e instanceof Ba)),r}var GM,Ioe,z3=b(()=>{Ti();ai();Le();ft();ob();wM();xM();EM();TM();_M();AM();DM();PM();FM();MM();RM();$M();OM();R3();q3();GM=new ke(W3()),Ioe=new ke(YM())});function Roe(r){let e=r.toLowerCase();return XM[e]!==void 0?XM[e]:e.match(/несколько/)?3:e.match(/пол/)?.5:e.match(/пар/)?2:e===""?1:parseFloat(e)}function rR(r){let e=r.toLowerCase();return ZM[e]!==void 0?ZM[e]:parseInt(e)}function VA(r){if(/(год|года|г|г.)/i.test(r)&&(r=r.replace(/(год|года|г|г.)/i,"")),/(до н.э.|до н. э.)/i.test(r))return r=r.replace(/(до н.э.|до н. э.)/i,""),-parseInt(r);if(/(н. э.|н.э.)/i.test(r))return r=r.replace(/(н. э.|н.э.)/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function rh(r){let e={},t=r,n=H3.exec(t);for(;n;)$oe(e,n),t=t.substring(n[0].length).trim(),n=H3.exec(t);return e}function $oe(r,e){let t=Roe(e[1]),n=Sw[e[2].toLowerCase()];r[n]=t}var ps,JM,eR,eh,XM,ZM,Sw,Moe,tR,QM,BA,j3,H3,th,fs=b(()=>{ze();zt();ps={leftBoundary:"([^\\p{L}\\p{N}_]|^)",rightBoundary:"(?=[^\\p{L}\\p{N}_]|$)",flags:"iu"},JM={\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435:0,\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u044F:0,\u0432\u0441\u043A:0,"\u0432\u0441\u043A.":0,\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A:1,\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A\u0430:1,\u043F\u043D:1,"\u043F\u043D.":1,\u0432\u0442\u043E\u0440\u043D\u0438\u043A:2,\u0432\u0442\u043E\u0440\u043D\u0438\u043A\u0430:2,\u0432\u0442:2,"\u0432\u0442.":2,\u0441\u0440\u0435\u0434\u0430:3,\u0441\u0440\u0435\u0434\u044B:3,\u0441\u0440\u0435\u0434\u0443:3,\u0441\u0440:3,"\u0441\u0440.":3,\u0447\u0435\u0442\u0432\u0435\u0440\u0433:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0430:4,\u0447\u0442:4,"\u0447\u0442.":4,\u043F\u044F\u0442\u043D\u0438\u0446\u0430:5,\u043F\u044F\u0442\u043D\u0438\u0446\u0443:5,\u043F\u044F\u0442\u043D\u0438\u0446\u044B:5,\u043F\u0442:5,"\u043F\u0442.":5,\u0441\u0443\u0431\u0431\u043E\u0442\u0430:6,\u0441\u0443\u0431\u0431\u043E\u0442\u0443:6,\u0441\u0443\u0431\u0431\u043E\u0442\u044B:6,\u0441\u0431:6,"\u0441\u0431.":6},eR={\u044F\u043D\u0432\u0430\u0440\u044C:1,\u044F\u043D\u0432\u0430\u0440\u044F:1,\u044F\u043D\u0432\u0430\u0440\u0435:1,\u0444\u0435\u0432\u0440\u0430\u043B\u044C:2,\u0444\u0435\u0432\u0440\u0430\u043B\u044F:2,\u0444\u0435\u0432\u0440\u0430\u043B\u0435:2,\u043C\u0430\u0440\u0442:3,\u043C\u0430\u0440\u0442\u0430:3,\u043C\u0430\u0440\u0442\u0435:3,\u0430\u043F\u0440\u0435\u043B\u044C:4,\u0430\u043F\u0440\u0435\u043B\u044F:4,\u0430\u043F\u0440\u0435\u043B\u0435:4,\u043C\u0430\u0439:5,\u043C\u0430\u044F:5,\u043C\u0430\u0435:5,\u0438\u044E\u043D\u044C:6,\u0438\u044E\u043D\u044F:6,\u0438\u044E\u043D\u0435:6,\u0438\u044E\u043B\u044C:7,\u0438\u044E\u043B\u044F:7,\u0438\u044E\u043B\u0435:7,\u0430\u0432\u0433\u0443\u0441\u0442:8,\u0430\u0432\u0433\u0443\u0441\u0442\u0430:8,\u0430\u0432\u0433\u0443\u0441\u0442\u0435:8,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C:9,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F:9,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u0435:9,\u043E\u043A\u0442\u044F\u0431\u0440\u044C:10,\u043E\u043A\u0442\u044F\u0431\u0440\u044F:10,\u043E\u043A\u0442\u044F\u0431\u0440\u0435:10,\u043D\u043E\u044F\u0431\u0440\u044C:11,\u043D\u043E\u044F\u0431\u0440\u044F:11,\u043D\u043E\u044F\u0431\u0440\u0435:11,\u0434\u0435\u043A\u0430\u0431\u0440\u044C:12,\u0434\u0435\u043A\u0430\u0431\u0440\u044F:12,\u0434\u0435\u043A\u0430\u0431\u0440\u0435:12},eh={...eR,\u044F\u043D\u0432:1,"\u044F\u043D\u0432.":1,\u0444\u0435\u0432:2,"\u0444\u0435\u0432.":2,\u043C\u0430\u0440:3,"\u043C\u0430\u0440.":3,\u0430\u043F\u0440:4,"\u0430\u043F\u0440.":4,\u0430\u0432\u0433:8,"\u0430\u0432\u0433.":8,\u0441\u0435\u043D:9,"\u0441\u0435\u043D.":9,\u043E\u043A\u0442:10,"\u043E\u043A\u0442.":10,\u043D\u043E\u044F:11,"\u043D\u043E\u044F.":11,\u0434\u0435\u043A:12,"\u0434\u0435\u043A.":12},XM={\u043E\u0434\u0438\u043D:1,\u043E\u0434\u043D\u0430:1,\u043E\u0434\u043D\u043E\u0439:1,\u043E\u0434\u043D\u0443:1,\u0434\u0432\u0435:2,\u0434\u0432\u0430:2,\u0434\u0432\u0443\u0445:2,\u0442\u0440\u0438:3,\u0442\u0440\u0435\u0445:3,\u0442\u0440\u0451\u0445:3,\u0447\u0435\u0442\u044B\u0440\u0435:4,\u0447\u0435\u0442\u044B\u0440\u0435\u0445:4,\u0447\u0435\u0442\u044B\u0440\u0451\u0445:4,\u043F\u044F\u0442\u044C:5,\u043F\u044F\u0442\u0438:5,\u0448\u0435\u0441\u0442\u044C:6,\u0448\u0435\u0441\u0442\u0438:6,\u0441\u0435\u043C\u044C:7,\u0441\u0435\u043C\u0438:7,\u0432\u043E\u0441\u0435\u043C\u044C:8,\u0432\u043E\u0441\u044C\u043C\u0438:8,\u0434\u0435\u0432\u044F\u0442\u044C:9,\u0434\u0435\u0432\u044F\u0442\u0438:9,\u0434\u0435\u0441\u044F\u0442\u044C:10,\u0434\u0435\u0441\u044F\u0442\u0438:10,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u044C:11,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u0438:11,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u044C:12,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u0438:12},ZM={\u043F\u0435\u0440\u0432\u043E\u0435:1,\u043F\u0435\u0440\u0432\u043E\u0433\u043E:1,\u0432\u0442\u043E\u0440\u043E\u0435:2,\u0432\u0442\u043E\u0440\u043E\u0433\u043E:2,\u0442\u0440\u0435\u0442\u044C\u0435:3,\u0442\u0440\u0435\u0442\u044C\u0435\u0433\u043E:3,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0435:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E:4,\u043F\u044F\u0442\u043E\u0435:5,\u043F\u044F\u0442\u043E\u0433\u043E:5,\u0448\u0435\u0441\u0442\u043E\u0435:6,\u0448\u0435\u0441\u0442\u043E\u0433\u043E:6,\u0441\u0435\u0434\u044C\u043C\u043E\u0435:7,\u0441\u0435\u0434\u044C\u043C\u043E\u0433\u043E:7,\u0432\u043E\u0441\u044C\u043C\u043E\u0435:8,\u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E:8,\u0434\u0435\u0432\u044F\u0442\u043E\u0435:9,\u0434\u0435\u0432\u044F\u0442\u043E\u0433\u043E:9,\u0434\u0435\u0441\u044F\u0442\u043E\u0435:10,\u0434\u0435\u0441\u044F\u0442\u043E\u0433\u043E:10,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:11,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:11,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:12,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:12,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:13,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:13,\u0447\u0435\u0442\u044B\u0440\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:14,\u0447\u0435\u0442\u044B\u0440\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:14,\u043F\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:15,\u043F\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:15,\u0448\u0435\u0441\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:16,\u0448\u0435\u0441\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:16,\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:17,\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:17,\u0432\u043E\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:18,\u0432\u043E\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:18,\u0434\u0435\u0432\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:19,\u0434\u0435\u0432\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:19,\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043E\u0435:20,\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:20,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0435":21,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0433\u043E":21,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u0442\u043E\u0440\u043E\u0435":22,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u0442\u043E\u0440\u043E\u0433\u043E":22,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u0435":23,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u0435\u0433\u043E":23,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0435":24,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E":24,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u044F\u0442\u043E\u0435":25,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u044F\u0442\u043E\u0433\u043E":25,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0448\u0435\u0441\u0442\u043E\u0435":26,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0448\u0435\u0441\u0442\u043E\u0433\u043E":26,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0441\u0435\u0434\u044C\u043C\u043E\u0435":27,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0441\u0435\u0434\u044C\u043C\u043E\u0433\u043E":27,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0435":28,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E":28,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0434\u0435\u0432\u044F\u0442\u043E\u0435":29,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0434\u0435\u0432\u044F\u0442\u043E\u0433\u043E":29,\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u043E\u0435:30,\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u043E\u0433\u043E:30,"\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0435":31,"\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0433\u043E":31},Sw={\u0441\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u044B:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0443:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0443:"second",\u043C\u0438\u043D:"minute",\u043C\u0438\u043D\u0443\u0442\u0430:"minute",\u043C\u0438\u043D\u0443\u0442:"minute",\u043C\u0438\u043D\u0443\u0442\u044B:"minute",\u043C\u0438\u043D\u0443\u0442\u0443:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u043A:"minute",\u043C\u0438\u043D\u0443\u0442\u043A\u0438:"minute",\u043C\u0438\u043D\u0443\u0442\u043A\u0443:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u0435\u043A:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u043A\u0438:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u043A\u0443:"minute",\u0447\u0430\u0441:"hour",\u0447\u0430\u0441\u043E\u0432:"hour",\u0447\u0430\u0441\u0430:"hour",\u0447\u0430\u0441\u0443:"hour",\u0447\u0430\u0441\u0438\u043A\u043E\u0432:"hour",\u0447\u0430\u0441\u0438\u043A\u0430:"hour",\u0447\u0430\u0441\u0438\u043A\u0435:"hour",\u0447\u0430\u0441\u0438\u043A:"hour",\u0434\u0435\u043D\u044C:"day",\u0434\u043D\u044F:"day",\u0434\u043D\u0435\u0439:"day",\u0441\u0443\u0442\u043E\u043A:"day",\u0441\u0443\u0442\u043A\u0438:"day",\u043D\u0435\u0434\u0435\u043B\u044F:"week",\u043D\u0435\u0434\u0435\u043B\u0435:"week",\u043D\u0435\u0434\u0435\u043B\u0438:"week",\u043D\u0435\u0434\u0435\u043B\u044E:"week",\u043D\u0435\u0434\u0435\u043B\u044C:"week",\u043D\u0435\u0434\u0435\u043B\u044C\u043A\u0435:"week",\u043D\u0435\u0434\u0435\u043B\u044C\u043A\u0438:"week",\u043D\u0435\u0434\u0435\u043B\u0435\u043A:"week",\u043C\u0435\u0441\u044F\u0446:"month",\u043C\u0435\u0441\u044F\u0446\u0435:"month",\u043C\u0435\u0441\u044F\u0446\u0435\u0432:"month",\u043C\u0435\u0441\u044F\u0446\u0430:"month",\u043A\u0432\u0430\u0440\u0442\u0430\u043B:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0435:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u043E\u0432:"quarter",\u0433\u043E\u0434:"year",\u0433\u043E\u0434\u0430:"year",\u0433\u043E\u0434\u0443:"year",\u0433\u043E\u0434\u043E\u0432:"year",\u043B\u0435\u0442:"year",\u0433\u043E\u0434\u0438\u043A:"year",\u0433\u043E\u0434\u0438\u043A\u0430:"year",\u0433\u043E\u0434\u0438\u043A\u043E\u0432:"year"},Moe=`(?:${te(XM)}|[0-9]+|[0-9]+\\.[0-9]+|\u043F\u043E\u043B|\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E|\u043F\u0430\u0440(?:\u044B|\u0443)|\\s{0,3})`;tR=`(?:${te(ZM)}|[0-9]{1,2}(?:\u0433\u043E|\u043E\u0433\u043E|\u0435|\u043E\u0435)?)`;QM="(?:\\s+(?:\u0433\u043E\u0434\u0443|\u0433\u043E\u0434\u0430|\u0433\u043E\u0434|\u0433|\u0433.))?",BA=`(?:[1-9][0-9]{0,3}${QM}\\s*(?:\u043D.\u044D.|\u0434\u043E \u043D.\u044D.|\u043D. \u044D.|\u0434\u043E \u043D. \u044D.)|[1-2][0-9]{3}${QM}|[5-9][0-9]${QM})`;j3=`(${Moe})\\s{0,3}(${te(Sw)})`,H3=new RegExp(j3,"i"),th=Tr("(?:(?:\u043E\u043A\u043E\u043B\u043E|\u043F\u0440\u0438\u043C\u0435\u0440\u043D\u043E)\\s{0,3})?",j3)});var G3,Dw,Y3=b(()=>{fs();Le();fe();G3=`(?:(?:\u043E\u043A\u043E\u043B\u043E|\u043F\u0440\u0438\u043C\u0435\u0440\u043D\u043E)\\s*(?:~\\s*)?)?(${th})${ps.rightBoundary}`,Dw=class extends B{patternLeftBoundary(){return ps.leftBoundary}innerPattern(e){return e.option.forwardDate?new RegExp(G3,ps.flags):new RegExp(`(?:\u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435|\u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0438)\\s*${G3}`,ps.flags)}innerExtract(e,t){let n=rh(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var qp,No,$c=b(()=>{fe();fs();qp=class extends B{patternLeftBoundary(){return ps.leftBoundary}innerPattern(e){return new RegExp(this.innerPatternString(e),ps.flags)}innerPatternHasChange(e,t){return!1}},No=class extends qp{innerPattern(e){return new RegExp(`${this.innerPatternString(e)}${ps.rightBoundary}`,ps.flags)}}});var K3,Q3,Ooe,X3,Iw,Z3=b(()=>{zt();fs();fs();fs();ze();$c();K3=1,Q3=2,Ooe=3,X3=4,Iw=class extends No{innerPatternString(e){return`(?:\u0441)?\\s*(${tR})(?:\\s{0,3}(?:\u043F\u043E|-|\u2013|\u0434\u043E)?\\s{0,3}(${tR}))?(?:-|\\/|\\s{0,3}(?:of)?\\s{0,3})(${te(eh)})(?:(?:-|\\/|,?\\s{0,3})(${BA}(?![^\\s]\\d)))?`}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=eh[t[Ooe].toLowerCase()],o=rR(t[K3]);if(o>31)return t.index=t.index+t[K3].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[X3]){let s=VA(t[X3]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[Q3]){let s=rR(t[Q3]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Noe,J3,Pw,eH=b(()=>{fs();zt();ze();fs();$c();Noe=2,J3=3,Pw=class extends qp{innerPatternString(e){return`((?:\u0432)\\s*)?(${te(eh)})\\s*(?:[,-]?\\s*(${BA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`}innerExtract(e,t){let n=t[Noe].toLowerCase();if(t[0].length<=3&&!eR[n])return null;let i=e.createParsingResult(t.index,t.index+t[0].length);i.start.imply("day",1);let o=eh[n];if(i.start.assign("month",o),t[J3]){let s=VA(t[J3]);i.start.assign("year",s)}else{let s=mt(e.refDate,1,o);i.start.imply("year",s)}return i}}});var Fw,tH=b(()=>{ft();La();fs();Fw=class extends Yr{constructor(e){super(e)}patternFlags(){return ps.flags}primaryPatternLeftBoundary(){return"(^|\\s|T|(?:[^\\p{L}\\p{N}_]))"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|\u0434\u043E|\u0438|\u043F\u043E|\\?)\\s*"}primaryPrefix(){return"(?:(?:\u0432|\u0441)\\s*)??"}primarySuffix(){return`(?:\\s*(?:\u0443\u0442\u0440\u0430|\u0432\u0435\u0447\u0435\u0440\u0430|\u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0434\u043D\u044F))?(?!\\/)${ps.rightBoundary}`}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(n){if(t[0].endsWith("\u0432\u0435\u0447\u0435\u0440\u0430")){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",j.PM)):i<6&&n.assign("meridiem",j.AM)}if(t[0].endsWith("\u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0434\u043D\u044F")){n.assign("meridiem",j.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}t[0].endsWith("\u0443\u0442\u0440\u0430")&&(n.assign("meridiem",j.AM),n.get("hour")<12&&n.assign("hour",n.get("hour")))}return n}}});var Mw,rH=b(()=>{fs();Le();$c();Bt();Mw=class extends qp{innerPatternString(e){return`(${th})\\s{0,5}\u043D\u0430\u0437\u0430\u0434(?=(?:\\W|$))`}innerExtract(e,t){let n=rh(t[1]),i=tt(n);return X.createRelativeFromReference(e.reference,i)}}});var Rw,nH=b(()=>{yo();Rw=class extends Yt{patternBetween(){return/^\s*(и до|и по|до|по|-)\s*$/i}}});var $w,iH=b(()=>{bo();$w=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\u0432|,|-)?\\s*$")}}});var Ow,oH=b(()=>{si();$c();Ow=class extends No{innerPatternString(e){return"(?:\u0441|\u0441\u043E)?\\s*(\u0441\u0435\u0433\u043E\u0434\u043D\u044F|\u0432\u0447\u0435\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0441\u043B\u0435\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430|\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430)"}innerExtract(e,t){let n=t[1].toLowerCase(),i=e.createParsingComponents();switch(n){case"\u0441\u0435\u0433\u043E\u0434\u043D\u044F":return _r(e.reference);case"\u0432\u0447\u0435\u0440\u0430":return vn(e.reference);case"\u0437\u0430\u0432\u0442\u0440\u0430":return yn(e.reference);case"\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430":return Ro(e.reference,2);case"\u043F\u043E\u0441\u043B\u0435\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430":return Ro(e.reference,3);case"\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430":return Ic(e.reference,2);case"\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430":return Ic(e.reference,3)}return i}}});var Nw,sH=b(()=>{si();on();$c();Nw=class extends No{innerPatternString(e){return"(\u0441\u0435\u0439\u0447\u0430\u0441|\u043F\u0440\u043E\u0448\u043B\u044B\u043C\\s*\u0432\u0435\u0447\u0435\u0440\u043E\u043C|\u043F\u0440\u043E\u0448\u043B\u043E\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u0441\u0435\u0433\u043E\u0434\u043D\u044F\\s*\u043D\u043E\u0447\u044C\u044E|\u044D\u0442\u043E\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u043D\u043E\u0447\u044C\u044E|\u044D\u0442\u0438\u043C \u0443\u0442\u0440\u043E\u043C|\u0443\u0442\u0440\u043E\u043C|\u0443\u0442\u0440\u0430|\u0432\\s*\u043F\u043E\u043B\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440\u043E\u043C|\u0432\u0435\u0447\u0435\u0440\u0430|\u0432\\s*\u043F\u043E\u043B\u043D\u043E\u0447\u044C)"}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();if(i==="\u0441\u0435\u0439\u0447\u0430\u0441")return Or(e.reference);if(i==="\u0432\u0435\u0447\u0435\u0440\u043E\u043C"||i==="\u0432\u0435\u0447\u0435\u0440\u0430")return Pc(e.reference);if(i.endsWith("\u0443\u0442\u0440\u043E\u043C")||i.endsWith("\u0443\u0442\u0440\u0430"))return Mc(e.reference);if(i.match(/в\s*полдень/))return Hu(e.reference);if(i.match(/прошлой\s*ночью/))return bA(e.reference);if(i.match(/прошлым\s*вечером/))return wA(e.reference);if(i.match(/следующей\s*ночью/)){let s=n.getHours()<22?1:2,a=new Date(n.getTime());a.setDate(a.getDate()+s),nt(o,a),o.imply("hour",0)}return i.match(/в\s*полночь/)||i.endsWith("\u043D\u043E\u0447\u044C\u044E")?Fc(e.reference):o}}});var Loe,Boe,Voe,Lw,aH=b(()=>{fs();ze();Qi();$c();Loe=1,Boe=2,Voe=3,Lw=class extends No{innerPatternString(e){return`(?:(?:,|\\(|\uFF08)\\s*)?(?:\u0432\\s*?)?(?:(\u044D\u0442\u0443|\u044D\u0442\u043E\u0442|\u043F\u0440\u043E\u0448\u043B\u044B\u0439|\u043F\u0440\u043E\u0448\u043B\u0443\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0443\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E)\\s*)?(${te(JM)})(?:\\s*(?:,|\\)|\uFF09))?(?:\\s*\u043D\u0430\\s*(\u044D\u0442\u043E\u0439|\u043F\u0440\u043E\u0448\u043B\u043E\u0439|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439)\\s*\u043D\u0435\u0434\u0435\u043B\u0435)?`}innerExtract(e,t){let n=t[Boe].toLowerCase(),i=JM[n],o=t[Loe],s=t[Voe],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a=="\u043F\u0440\u043E\u0448\u043B\u044B\u0439"||a=="\u043F\u0440\u043E\u0448\u043B\u0443\u044E"||a=="\u043F\u0440\u043E\u0448\u043B\u043E\u0439"?l="last":a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0443\u044E"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E"?l="next":(a=="\u044D\u0442\u043E\u0442"||a=="\u044D\u0442\u0443"||a=="\u044D\u0442\u043E\u0439")&&(l="this"),cr(e.reference,i,l)}}});var Uoe,qoe,Bw,lH=b(()=>{fs();Le();ze();$c();Uoe=1,qoe=2,Bw=class extends No{innerPatternString(e){return`(\u0432 \u043F\u0440\u043E\u0448\u043B\u043E\u043C|\u043D\u0430 \u043F\u0440\u043E\u0448\u043B\u043E\u0439|\u043D\u0430 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439|\u0432 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C|\u043D\u0430 \u044D\u0442\u043E\u0439|\u0432 \u044D\u0442\u043E\u043C)\\s*(${te(Sw)})`}innerExtract(e,t){let n=t[Uoe].toLowerCase(),i=t[qoe].toLowerCase(),o=Sw[i];if(n=="\u043D\u0430 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439"||n=="\u0432 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C"){let l={};return l[o]=1,X.createRelativeFromReference(e.reference,l)}if(n=="\u0432 \u043F\u0440\u043E\u0448\u043B\u043E\u043C"||n=="\u043D\u0430 \u043F\u0440\u043E\u0448\u043B\u043E\u0439"){let l={};return l[o]=-1,X.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return o.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):o.match(/month/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):o.match(/year/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var Vw,cH=b(()=>{fs();Le();$c();Bt();Vw=class extends No{innerPatternString(e){return`(\u044D\u0442\u0438|\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435|\u043F\u0440\u043E\u0448\u043B\u044B\u0435|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435|\u043F\u043E\u0441\u043B\u0435|\u0441\u043F\u0443\u0441\u0442\u044F|\u0447\u0435\u0440\u0435\u0437|\\+|-)\\s*(${th})`}innerExtract(e,t){let n=t[1].toLowerCase(),i=rh(t[2]);switch(n){case"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435":case"\u043F\u0440\u043E\u0448\u043B\u044B\u0435":case"-":i=tt(i);break}return X.createRelativeFromReference(e.reference,i)}}});var oR={};Jr(oR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>nR,createCasualConfiguration:()=>uH,createConfiguration:()=>iR,parse:()=>zoe,parseDate:()=>Hoe,strict:()=>Woe});function zoe(r,e,t){return nR.parse(r,e,t)}function Hoe(r,e,t){return nR.parseDate(r,e,t)}function uH(){let r=iR(!1);return r.parsers.unshift(new Ow),r.parsers.unshift(new Nw),r.parsers.unshift(new Pw),r.parsers.unshift(new Bw),r.parsers.unshift(new Vw),r}function iR(r=!0){return Ht({parsers:[new vr(!0),new Dw,new Iw,new Lw,new Fw(r),new Mw],refiners:[new $w,new Rw]},r)}var nR,Woe,dH=b(()=>{Y3();Z3();eH();tH();rH();nH();iH();Ti();oH();sH();aH();lH();ai();Le();ft();us();cH();nR=new ke(uH()),Woe=new ke(iR(!0))});function Goe(r){let e=r.toLowerCase();return sR[e]!==void 0?sR[e]:e==="un"||e==="una"||e==="uno"?1:e.match(/algunos?/)||e.match(/unos?/)?3:e.match(/media?/)?.5:parseFloat(e)}function hH(r){if(r.match(/^[0-9]{1,4}$/)){let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}return r.match(/a\.?\s*c\.?/i)?(r=r.replace(/a\.?\s*c\.?/i,""),-parseInt(r)):parseInt(r)}function yH(r){let e={},t=r,n=pH.exec(t);for(;n;)Yoe(e,n),t=t.substring(n[0].length),n=pH.exec(t);return e}function Yoe(r,e){let t=Goe(e[1]),n=fH[e[2].toLowerCase()];r[n]=t}var aR,lR,sR,fH,joe,mH,gH,pH,vH,Uw=b(()=>{ze();aR={domingo:0,dom:0,lunes:1,lun:1,martes:2,mar:2,mi\u00E9rcoles:3,miercoles:3,mi\u00E9:3,mie:3,jueves:4,jue:4,viernes:5,vie:5,s\u00E1bado:6,sabado:6,s\u00E1b:6,sab:6},lR={enero:1,ene:1,"ene.":1,febrero:2,feb:2,"feb.":2,marzo:3,mar:3,"mar.":3,abril:4,abr:4,"abr.":4,mayo:5,may:5,"may.":5,junio:6,jun:6,"jun.":6,julio:7,jul:7,"jul.":7,agosto:8,ago:8,"ago.":8,septiembre:9,setiembre:9,sep:9,"sep.":9,octubre:10,oct:10,"oct.":10,noviembre:11,nov:11,"nov.":11,diciembre:12,dic:12,"dic.":12},sR={uno:1,dos:2,tres:3,cuatro:4,cinco:5,seis:6,siete:7,ocho:8,nueve:9,diez:10,once:11,doce:12,trece:13},fH={sec:"second",segundo:"second",segundos:"second",min:"minute",mins:"minute",minuto:"minute",minutos:"minute",h:"hour",hr:"hour",hrs:"hour",hora:"hour",horas:"hour",d\u00EDa:"day",d\u00EDas:"day",semana:"week",semanas:"week",mes:"month",meses:"month",cuarto:"quarter",cuartos:"quarter",a\u00F1o:"year",a\u00F1os:"year"},joe=`(?:${te(sR)}|[0-9]+|[0-9]+\\.[0-9]+|un?|uno?|una?|algunos?|unos?|demi-?)`;mH="[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?";gH=`(${joe})\\s{0,5}(${te(fH)})\\s{0,5}`,pH=new RegExp(gH,"i"),vH=Tr("",gH)});var Koe,Qoe,Xoe,Zoe,qw,bH=b(()=>{Uw();ze();fe();Qi();Koe=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(este|esta|pasado|pr[o\xF3]ximo)\\s*)?(${te(aR)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(este|esta|pasado|pr[\xF3o]ximo)\\s*semana)?(?=\\W|\\d|$)`,"i"),Qoe=1,Xoe=2,Zoe=3,qw=class extends B{innerPattern(){return Koe}innerExtract(e,t){let n=t[Xoe].toLowerCase(),i=aR[n];if(i===void 0)return null;let o=t[Qoe],s=t[Zoe],a=o||s||"";a=a.toLowerCase();let l=null;return a=="pasado"?l="this":a=="pr\xF3ximo"||a=="proximo"?l="next":a=="este"&&(l="this"),cr(e.reference,i,l)}}});var Ww,wH=b(()=>{La();Ww=class extends Yr{primaryPrefix(){return"(?:(?:aslas|deslas|las?|al?|de|del)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a(?:l)?|\\?)\\s*"}}});var zw,CH=b(()=>{bo();zw=class extends Kt{patternBetween(){return new RegExp("^\\s*(?:,|de|aslas|a)?\\s*$")}}});var Hw,xH=b(()=>{yo();Hw=class extends Yt{patternBetween(){return/^\s*(?:-)\s*$/i}}});var Joe,EH,TH,ese,_H,jw,AH=b(()=>{zt();Uw();Uw();ze();fe();Joe=new RegExp(`([0-9]{1,2})(?:\xBA|\xAA|\xB0)?(?:\\s*(?:desde|de|\\-|\\\u2013|ao?|\\s)\\s*([0-9]{1,2})(?:\xBA|\xAA|\xB0)?)?\\s*(?:de)?\\s*(?:-|/|\\s*(?:de|,)?\\s*)(${te(lR)})(?:\\s*(?:de|,)?\\s*(${mH}))?(?=\\W|$)`,"i"),EH=1,TH=2,ese=3,_H=4,jw=class extends B{innerPattern(){return Joe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=lR[t[ese].toLowerCase()],o=parseInt(t[EH]);if(o>31)return t.index=t.index+t[EH].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[_H]){let s=hH(t[_H]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[TH]){let s=parseInt(t[TH]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Gw,kH=b(()=>{fe();si();Gw=class extends B{innerPattern(e){return/(ahora|hoy|mañana|ayer)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"ahora":return Or(e.reference);case"hoy":return _r(e.reference);case"ma\xF1ana":return yn(e.reference);case"ayer":return vn(e.reference)}return i}}});var Yw,SH=b(()=>{ft();fe();on();Yw=class extends B{innerPattern(){return/(?:esta\s*)?(mañana|tarde|medianoche|mediodia|mediodía|noche)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[1].toLowerCase()){case"tarde":i.imply("meridiem",j.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"noche":i.imply("meridiem",j.PM),i.imply("hour",22),i.addTag("casualReference/evening");break;case"ma\xF1ana":i.imply("meridiem",j.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"medianoche":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"mediodia":case"mediod\xEDa":i.imply("meridiem",j.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});var Kw,DH=b(()=>{Uw();Le();fe();Kw=class extends B{innerPattern(){return new RegExp(`(?:en|por|durante|de|dentro de)\\s*(${vH})(?=\\W|$)`,"i")}innerExtract(e,t){let n=yH(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var dR={};Jr(dR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>cR,createCasualConfiguration:()=>IH,createConfiguration:()=>uR,parse:()=>rse,parseDate:()=>nse,strict:()=>tse});function rse(r,e,t){return cR.parse(r,e,t)}function nse(r,e,t){return cR.parseDate(r,e,t)}function IH(r=!0){let e=uR(!1,r);return e.parsers.push(new Gw),e.parsers.push(new Yw),e}function uR(r=!0,e=!0){return Ht({parsers:[new vr(e),new qw,new Ww,new jw,new Kw],refiners:[new zw,new Hw]},r)}var cR,tse,PH=b(()=>{Ti();ai();Le();ft();us();bH();wH();CH();xH();AH();kH();SH();DH();cR=new ke(IH()),tse=new ke(uR(!0))});function ose(r){let e=r.toLowerCase();return fR[e]!==void 0?fR[e]:e.match(/декілька/)?2:e.match(/пів/)?.5:e.match(/пар/)?2:e===""?1:parseFloat(e)}function yR(r){let e=r.toLowerCase();return mR[e]!==void 0?mR[e]:parseInt(e)}function qA(r){if(/(рік|року|р|р.)/i.test(r)&&(r=r.replace(/(рік|року|р|р.)/i,"")),/(до н.е.|до н. е.)/i.test(r))return r=r.replace(/(до н.е.|до н. е.)/i,""),-parseInt(r);if(/(н. е.|н.е.)/i.test(r))return r=r.replace(/(н. е.|н.е.)/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function oh(r){let e={},t=r,n=FH.exec(t);for(;n;)sse(e,n),t=t.substring(n[0].length).trim(),n=FH.exec(t);return e}function sse(r,e){let t=ose(e[1]),n=Qw[e[2].toLowerCase()];r[n]=t}var ms,hR,gR,nh,fR,mR,Qw,ise,vR,pR,UA,MH,FH,ih,hs=b(()=>{ze();zt();ms={leftBoundary:"([^\\p{L}\\p{N}_]|^)",rightBoundary:"(?=[^\\p{L}\\p{N}_]|$)",flags:"iu"},hR={\u043D\u0435\u0434\u0456\u043B\u044F:0,\u043D\u0435\u0434\u0456\u043B\u0456:0,\u043D\u0435\u0434\u0456\u043B\u044E:0,\u043D\u0434:0,"\u043D\u0434.":0,\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043E\u043A:1,\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043A\u0430:1,\u043F\u043D:1,"\u043F\u043D.":1,\u0432\u0456\u0432\u0442\u043E\u0440\u043E\u043A:2,\u0432\u0456\u0432\u0442\u043E\u0440\u043A\u0430:2,\u0432\u0442:2,"\u0432\u0442.":2,\u0441\u0435\u0440\u0435\u0434\u0430:3,\u0441\u0435\u0440\u0435\u0434\u0438:3,\u0441\u0435\u0440\u0435\u0434\u0443:3,\u0441\u0440:3,"\u0441\u0440.":3,\u0447\u0435\u0442\u0432\u0435\u0440:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0430:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0443:4,\u0447\u0442:4,"\u0447\u0442.":4,"\u043F'\u044F\u0442\u043D\u0438\u0446\u044F":5,"\u043F'\u044F\u0442\u043D\u0438\u0446\u0456":5,"\u043F'\u044F\u0442\u043D\u0438\u0446\u044E":5,\u043F\u0442:5,"\u043F\u0442.":5,\u0441\u0443\u0431\u043E\u0442\u0430:6,\u0441\u0443\u0431\u043E\u0442\u0438:6,\u0441\u0443\u0431\u043E\u0442\u0443:6,\u0441\u0431:6,"\u0441\u0431.":6},gR={\u0441\u0456\u0447\u0435\u043D\u044C:1,\u0441\u0456\u0447\u043D\u044F:1,\u0441\u0456\u0447\u043D\u0456:1,\u043B\u044E\u0442\u0438\u0439:2,\u043B\u044E\u0442\u043E\u0433\u043E:2,\u043B\u044E\u0442\u043E\u043C\u0443:2,\u0431\u0435\u0440\u0435\u0437\u0435\u043D\u044C:3,\u0431\u0435\u0440\u0435\u0437\u043D\u044F:3,\u0431\u0435\u0440\u0435\u0437\u043D\u0456:3,\u043A\u0432\u0456\u0442\u0435\u043D\u044C:4,\u043A\u0432\u0456\u0442\u043D\u044F:4,\u043A\u0432\u0456\u0442\u043D\u0456:4,\u0442\u0440\u0430\u0432\u0435\u043D\u044C:5,\u0442\u0440\u0430\u0432\u043D\u044F:5,\u0442\u0440\u0430\u0432\u043D\u0456:5,\u0447\u0435\u0440\u0432\u0435\u043D\u044C:6,\u0447\u0435\u0440\u0432\u043D\u044F:6,\u0447\u0435\u0440\u0432\u043D\u0456:6,\u043B\u0438\u043F\u0435\u043D\u044C:7,\u043B\u0438\u043F\u043D\u044F:7,\u043B\u0438\u043F\u043D\u0456:7,\u0441\u0435\u0440\u043F\u0435\u043D\u044C:8,\u0441\u0435\u0440\u043F\u043D\u044F:8,\u0441\u0435\u0440\u043F\u043D\u0456:8,\u0432\u0435\u0440\u0435\u0441\u0435\u043D\u044C:9,\u0432\u0435\u0440\u0435\u0441\u043D\u044F:9,\u0432\u0435\u0440\u0435\u0441\u043D\u0456:9,\u0436\u043E\u0432\u0442\u0435\u043D\u044C:10,\u0436\u043E\u0432\u0442\u043D\u044F:10,\u0436\u043E\u0432\u0442\u043D\u0456:10,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434:11,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0430:11,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0443:11,\u0433\u0440\u0443\u0434\u0435\u043D\u044C:12,\u0433\u0440\u0443\u0434\u043D\u044F:12,\u0433\u0440\u0443\u0434\u043D\u0456:12},nh={...gR,\u0441\u0456\u0447:1,"\u0441\u0456\u0447.":1,\u043B\u044E\u0442:2,"\u043B\u044E\u0442.":2,\u0431\u0435\u0440:3,"\u0431\u0435\u0440.":3,\u043A\u0432\u0456\u0442:4,"\u043A\u0432\u0456\u0442.":4,\u0442\u0440\u0430\u0432:5,"\u0442\u0440\u0430\u0432.":5,\u0447\u0435\u0440\u0432:6,"\u0447\u0435\u0440\u0432.":6,\u043B\u0438\u043F:7,"\u043B\u0438\u043F.":7,\u0441\u0435\u0440\u043F:8,"\u0441\u0435\u0440\u043F.":8,\u0441\u0435\u0440:8,"c\u0435\u0440.":8,\u0432\u0435\u0440:9,"\u0432\u0435\u0440.":9,\u0432\u0435\u0440\u0435\u0441:9,"\u0432\u0435\u0440\u0435\u0441.":9,\u0436\u043E\u0432\u0442:10,"\u0436\u043E\u0432\u0442.":10,\u043B\u0438\u0441\u0442\u043E\u043F:11,"\u043B\u0438\u0441\u0442\u043E\u043F.":11,\u0433\u0440\u0443\u0434:12,"\u0433\u0440\u0443\u0434.":12},fR={\u043E\u0434\u0438\u043D:1,\u043E\u0434\u043D\u0430:1,\u043E\u0434\u043D\u043E\u0457:1,\u043E\u0434\u043D\u0443:1,\u0434\u0432\u0456:2,\u0434\u0432\u0430:2,\u0434\u0432\u043E\u0445:2,\u0442\u0440\u0438:3,\u0442\u0440\u044C\u043E\u0445:3,\u0447\u043E\u0442\u0438\u0440\u0438:4,\u0447\u043E\u0442\u0438\u0440\u044C\u043E\u0445:4,"\u043F'\u044F\u0442\u044C":5,"\u043F'\u044F\u0442\u0438":5,\u0448\u0456\u0441\u0442\u044C:6,\u0448\u0435\u0441\u0442\u0438:6,\u0441\u0456\u043C:7,\u0441\u0435\u043C\u0438:7,\u0432\u0456\u0441\u0456\u043C:8,\u0432\u043E\u0441\u044C\u043C\u0438:8,"\u0434\u0435\u0432'\u044F\u0442\u044C":9,"\u0434\u0435\u0432'\u044F\u0442\u0438":9,\u0434\u0435\u0441\u044F\u0442\u044C:10,\u0434\u0435\u0441\u044F\u0442\u0438:10,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u044C:11,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0438:11,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u044C:12,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u0438:12},mR={\u043F\u0435\u0440\u0448\u0435:1,\u043F\u0435\u0440\u0448\u043E\u0433\u043E:1,\u0434\u0440\u0443\u0433\u0435:2,\u0434\u0440\u0443\u0433\u043E\u0433\u043E:2,\u0442\u0440\u0435\u0442\u0454:3,\u0442\u0440\u0435\u0442\u044C\u043E\u0433\u043E:3,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0435:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E:4,"\u043F'\u044F\u0442\u0435":5,"\u043F'\u044F\u0442\u043E\u0433\u043E":5,\u0448\u043E\u0441\u0442\u0435:6,\u0448\u043E\u0441\u0442\u043E\u0433\u043E:6,\u0441\u044C\u043E\u043C\u0435:7,\u0441\u044C\u043E\u043C\u043E\u0433\u043E:7,\u0432\u043E\u0441\u044C\u043C\u0435:8,\u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E:8,"\u0434\u0435\u0432'\u044F\u0442\u0435":9,"\u0434\u0435\u0432'\u044F\u0442\u043E\u0433\u043E":9,\u0434\u0435\u0441\u044F\u0442\u0435:10,\u0434\u0435\u0441\u044F\u0442\u043E\u0433\u043E:10,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0435:11,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:11,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u0435:12,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:12,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0435:13,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:13,\u0447\u043E\u0442\u0438\u0440\u043D\u0430\u0434\u0446\u044F\u0442\u0435:14,\u0447\u043E\u0442\u0438\u043D\u0440\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:14,"\u043F'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435":15,"\u043F'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E":15,\u0448\u0456\u0441\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435:16,\u0448\u0456\u0441\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:16,\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u0435:17,\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:17,\u0432\u0456\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u0435:18,\u0432\u0456\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:18,"\u0434\u0435\u0432'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435":19,"\u0434\u0435\u0432'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E":19,\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u0435:20,\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:20,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u0435":21,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u043E\u0433\u043E":21,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0440\u0443\u0433\u0435":22,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0440\u0443\u0433\u043E\u0433\u043E":22,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0442\u0440\u0435\u0442\u0454":23,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u043E\u0433\u043E":23,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0435":24,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E":24,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F'\u044F\u0442\u0435":25,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F'\u044F\u0442\u043E\u0433\u043E":25,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0448\u043E\u0441\u0442\u0435":26,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0448\u043E\u0441\u0442\u043E\u0433\u043E":26,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0441\u044C\u043E\u043C\u0435":27,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0441\u044C\u043E\u043C\u043E\u0433\u043E":27,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u0435":28,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E":28,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0435\u0432'\u044F\u0442\u0435":29,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0435\u0432'\u044F\u0442\u043E\u0433\u043E":29,\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u0435:30,\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u043E\u0433\u043E:30,"\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u0435":31,"\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u043E\u0433\u043E":31},Qw={\u0441\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0443:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043E\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0443:"second",\u0445\u0432:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0430:"minute",\u0445\u0432\u0438\u043B\u0438\u043D:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0443:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u043A:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043A\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043A\u0443:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043E\u043A:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043A\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043A\u0443:"minute",\u0433\u043E\u0434:"hour",\u0433\u043E\u0434\u0438\u043D\u0430:"hour",\u0433\u043E\u0434\u0438\u043D:"hour",\u0433\u043E\u0434\u0438\u043D\u0438:"hour",\u0433\u043E\u0434\u0438\u043D\u0443:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0430:"hour",\u0433\u043E\u0434\u0438\u043D\u043E\u043A:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0438:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0443:"hour",\u0434\u0435\u043D\u044C:"day",\u0434\u043D\u044F:"day",\u0434\u043D\u0456\u0432:"day",\u0434\u043D\u0456:"day",\u0434\u043E\u0431\u0430:"day",\u0434\u043E\u0431\u0443:"day",\u0442\u0438\u0436\u0434\u0435\u043D\u044C:"week",\u0442\u0438\u0436\u043D\u044E:"week",\u0442\u0438\u0436\u043D\u044F:"week",\u0442\u0438\u0436\u043D\u0456:"week",\u0442\u0438\u0436\u043D\u0456\u0432:"week",\u043C\u0456\u0441\u044F\u0446\u044C:"month",\u043C\u0456\u0441\u044F\u0446\u0456\u0432:"month",\u043C\u0456\u0441\u044F\u0446\u0456:"month",\u043C\u0456\u0441\u044F\u0446\u044F:"month",\u043A\u0432\u0430\u0440\u0442\u0430\u043B:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0443:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0430:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0456\u0432:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0456:"quarter",\u0440\u0456\u043A:"year",\u0440\u043E\u043A\u0443:"year",\u0440\u043E\u0446\u0456:"year",\u0440\u043E\u043A\u0456\u0432:"year",\u0440\u043E\u043A\u0438:"year"},ise=`(?:${te(fR)}|[0-9]+|[0-9]+\\.[0-9]+|\u043F\u0456\u0432|\u0434\u0435\u043A\u0456\u043B\u044C\u043A\u0430|\u043F\u0430\u0440(?:\u0443)|\\s{0,3})`;vR=`(?:${te(mR)}|[0-9]{1,2}(?:\u0433\u043E|\u043E\u0433\u043E|\u0435)?)`;pR="(?:\\s+(?:\u0440\u043E\u043A\u0443|\u0440\u0456\u043A|\u0440|\u0440.))?",UA=`(?:[1-9][0-9]{0,3}${pR}\\s*(?:\u043D.\u0435.|\u0434\u043E \u043D.\u0435.|\u043D. \u0435.|\u0434\u043E \u043D. \u0435.)|[1-2][0-9]{3}${pR}|[5-9][0-9]${pR})`;MH=`(${ise})\\s{0,3}(${te(Qw)})`,FH=new RegExp(MH,"i"),ih=Tr("(?:(?:\u0431\u043B\u0438\u0437\u044C\u043A\u043E|\u043F\u0440\u0438\u0431\u043B\u0438\u0437\u043D\u043E)\\s{0,3})?",MH)});var RH,Xw,$H=b(()=>{hs();Le();fe();RH=`(?:(?:\u043F\u0440\u0438\u0431\u043B\u0438\u0437\u043D\u043E|\u043E\u0440\u0456\u0454\u043D\u0442\u043E\u0432\u043D\u043E)\\s*(?:~\\s*)?)?(${ih})${ms.rightBoundary}`,Xw=class extends B{patternLeftBoundary(){return ms.leftBoundary}innerPattern(e){return e.option.forwardDate?new RegExp(RH,ms.flags):new RegExp(`(?:\u043F\u0440\u043E\u0442\u044F\u0433\u043E\u043C|\u043D\u0430 \u043F\u0440\u043E\u0442\u044F\u0437\u0456|\u043F\u0440\u043E\u0442\u044F\u0433\u043E\u043C|\u0443\u043F\u0440\u043E\u0434\u043E\u0432\u0436|\u0432\u043F\u0440\u043E\u0434\u043E\u0432\u0436)\\s*${RH}`,ms.flags)}innerExtract(e,t){let n=oh(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var Wp,Lo,Oc=b(()=>{fe();hs();Wp=class extends B{patternLeftBoundary(){return ms.leftBoundary}innerPattern(e){return new RegExp(this.innerPatternString(e),ms.flags)}innerPatternHasChange(e,t){return!1}},Lo=class extends Wp{innerPattern(e){return new RegExp(`${this.innerPatternString(e)}${ms.rightBoundary}`,ms.flags)}}});var OH,NH,ase,LH,Zw,BH=b(()=>{zt();hs();hs();hs();ze();Oc();OH=1,NH=2,ase=3,LH=4,Zw=class extends Lo{innerPatternString(e){return`(?:\u0437|\u0456\u0437)?\\s*(${vR})(?:\\s{0,3}(?:\u043F\u043E|-|\u2013|\u0434\u043E)?\\s{0,3}(${vR}))?(?:-|\\/|\\s{0,3}(?:of)?\\s{0,3})(${te(nh)})(?:(?:-|\\/|,?\\s{0,3})(${UA}(?![^\\s]\\d)))?`}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=nh[t[ase].toLowerCase()],o=yR(t[OH]);if(o>31)return t.index=t.index+t[OH].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[LH]){let s=qA(t[LH]);n.start.assign("year",s)}else{let s=mt(e.reference.instant,o,i);n.start.imply("year",s)}if(t[NH]){let s=yR(t[NH]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var lse,VH,Jw,UH=b(()=>{hs();zt();ze();hs();Oc();lse=2,VH=3,Jw=class extends Wp{innerPatternString(e){return`((?:\u0432|\u0443)\\s*)?(${te(nh)})\\s*(?:[,-]?\\s*(${UA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`}innerExtract(e,t){let n=t[lse].toLowerCase();if(t[0].length<=3&&!gR[n])return null;let i=e.createParsingResult(t.index,t.index+t[0].length);i.start.imply("day",1);let o=nh[n];if(i.start.assign("month",o),t[VH]){let s=qA(t[VH]);i.start.assign("year",s)}else{let s=mt(e.reference.instant,1,o);i.start.imply("year",s)}return i}}});var eC,qH=b(()=>{ft();La();hs();eC=class extends Yr{constructor(e){super(e)}patternFlags(){return ms.flags}primaryPatternLeftBoundary(){return"(^|\\s|T|(?:[^\\p{L}\\p{N}_]))"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|\u0434\u043E|\u0456|\u043F\u043E|\\?)\\s*"}primaryPrefix(){return"(?:(?:\u0432|\u0443|\u043E|\u043E\u0431|\u0437|\u0456\u0437|\u0432\u0456\u0434)\\s*)??"}primarySuffix(){return`(?:\\s*(?:\u0440\u0430\u043D\u043A\u0443|\u0432\u0435\u0447\u043E\u0440\u0430|\u043F\u043E \u043E\u0431\u0456\u0434\u0456|\u043F\u0456\u0441\u043B\u044F \u043E\u0431\u0456\u0434\u0443))?(?!\\/)${ms.rightBoundary}`}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(n){if(t[0].endsWith("\u0432\u0435\u0447\u043E\u0440\u0430")){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",j.PM)):i<6&&n.assign("meridiem",j.AM)}if(t[0].endsWith("\u043F\u043E \u043E\u0431\u0456\u0434\u0456")||t[0].endsWith("\u043F\u0456\u0441\u043B\u044F \u043E\u0431\u0456\u0434\u0443")){n.assign("meridiem",j.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}t[0].endsWith("\u0440\u0430\u043D\u043A\u0443")&&(n.assign("meridiem",j.AM),n.get("hour")<12&&n.assign("hour",n.get("hour")))}return n}}});var tC,WH=b(()=>{hs();Le();Oc();Bt();tC=class extends Wp{innerPatternString(e){return`(${ih})\\s{0,5}\u0442\u043E\u043C\u0443(?=(?:\\W|$))`}innerExtract(e,t){let n=oh(t[1]),i=tt(n);return X.createRelativeFromReference(e.reference,i)}}});var rC,zH=b(()=>{yo();rC=class extends Yt{patternBetween(){return/^\s*(і до|і по|до|по|-)\s*$/i}}});var nC,HH=b(()=>{bo();nC=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\u0432|\u0443|\u043E|,|-)?\\s*$")}}});var iC,jH=b(()=>{si();Oc();iC=class extends Lo{innerPatternString(e){return"(?:\u0437|\u0456\u0437|\u0432\u0456\u0434)?\\s*(\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456|\u0432\u0447\u043E\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u0456\u0441\u043B\u044F\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430|\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430)"}innerExtract(e,t){let n=t[1].toLowerCase(),i=e.createParsingComponents();switch(n){case"\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456":return _r(e.reference);case"\u0432\u0447\u043E\u0440\u0430":return vn(e.reference);case"\u0437\u0430\u0432\u0442\u0440\u0430":return yn(e.reference);case"\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430":return Ro(e.reference,2);case"\u043F\u0456\u0441\u043B\u044F\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430":return Ro(e.reference,3);case"\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430":return Ic(e.reference,2);case"\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430":return Ic(e.reference,3)}return i}}});var oC,GH=b(()=>{si();on();Oc();oC=class extends Lo{innerPatternString(e){return"(\u0437\u0430\u0440\u0430\u0437|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E\\s*\u0432\u0435\u0447\u043E\u0440\u0430|\u043C\u0438\u043D\u0443\u043B\u043E\u0457\\s*\u043D\u043E\u0447\u0456|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0457\\s*\u043D\u043E\u0447\u0456|\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456\\s*\u0432\u043D\u043E\u0447\u0456|\u0446\u0456\u0454\u0457\\s*\u043D\u043E\u0447\u0456|\u0446\u044C\u043E\u0433\u043E \u0440\u0430\u043D\u043A\u0443|\u0432\u0440\u0430\u043D\u0446\u0456|\u0440\u0430\u043D\u043A\u0443|\u0437\u0440\u0430\u043D\u043A\u0443|\u043E\u043F\u0456\u0432\u0434\u043D\u0456|\u0432\u0432\u0435\u0447\u0435\u0440\u0456|\u0432\u0435\u0447\u043E\u0440\u0430|\u043E\u043F\u0456\u0432\u043D\u043E\u0447\u0456|\u0432\u043D\u043E\u0447\u0456)"}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();if(i==="\u0437\u0430\u0440\u0430\u0437")return Or(e.reference);if(i==="\u0432\u0432\u0435\u0447\u0435\u0440\u0456"||i==="\u0432\u0435\u0447\u043E\u0440\u0430")return Pc(e.reference);if(i.endsWith("\u0432\u0440\u0430\u043D\u0446\u0456")||i.endsWith("\u0440\u0430\u043D\u043A\u0443")||i.endsWith("\u0437\u0440\u0430\u043D\u043A\u0443"))return Mc(e.reference);if(i.endsWith("\u043E\u043F\u0456\u0432\u0434\u043D\u0456"))return Hu(e.reference);if(i.match(/минулої\s*ночі/))return bA(e.reference);if(i.match(/минулого\s*вечора/))return wA(e.reference);if(i.match(/наступної\s*ночі/)){let s=n.getHours()<22?1:2,a=new Date(n.getTime());a.setDate(a.getDate()+s),nt(o,a),o.imply("hour",1)}return i.match(/цієї\s*ночі/)?Fc(e.reference):i.endsWith("\u043E\u043F\u0456\u0432\u043D\u043E\u0447\u0456")||i.endsWith("\u0432\u043D\u043E\u0447\u0456")?Fc(e.reference):o}}});var cse,use,dse,sC,YH=b(()=>{hs();ze();Qi();Oc();cse=1,use=2,dse=3,sC=class extends Lo{innerPatternString(e){return`(?:(?:,|\\(|\uFF08)\\s*)?(?:\u0432\\s*?)?(?:\u0443\\s*?)?(?:(\u0446\u0435\u0439|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E|\u043C\u0438\u043D\u0443\u043B\u0438\u0439|\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439|\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044C\u043E\u0433\u043E|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443)\\s*)?(${te(hR)})(?:\\s*(?:,|\\)|\uFF09))?(?:\\s*(\u043D\u0430|\u0443|\u0432)\\s*(\u0446\u044C\u043E\u043C\u0443|\u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443)\\s*\u0442\u0438\u0436\u043D\u0456)?`}innerExtract(e,t){let n=t[use].toLocaleLowerCase(),i=hR[n],o=t[cse],s=t[dse],a=o||s;a=a||"",a=a.toLocaleLowerCase();let l=null;return a=="\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E"||a=="\u043C\u0438\u043D\u0443\u043B\u0438\u0439"||a=="\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439"||a=="\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044C\u043E\u0433\u043E"?l="last":a=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E"||a=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439"?l="next":(a=="\u0446\u0435\u0439"||a=="\u0446\u044C\u043E\u0433\u043E"||a=="\u0446\u044C\u043E\u043C\u0443")&&(l="this"),cr(e.reference,i,l)}}});var pse,fse,aC,KH=b(()=>{hs();Le();ze();Oc();pse=1,fse=2,aC=class extends Lo{innerPatternString(e){return`(\u0432 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u0443 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043D\u0430 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E|\u043D\u0430 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u0432 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u0443 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E|\u043D\u0430 \u0446\u044C\u043E\u043C\u0443|\u0432 \u0446\u044C\u043E\u043C\u0443|\u0443 \u0446\u044C\u043E\u043C\u0443|\u0446\u044C\u043E\u0433\u043E)\\s*(${te(Qw)})(?=\\s*)`}innerExtract(e,t){let n=t[pse].toLowerCase(),i=t[fse].toLowerCase(),o=Qw[i];if(n=="\u043D\u0430 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u0432 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u0443 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E"){let l={};return l[o]=1,X.createRelativeFromReference(e.reference,l)}if(n=="\u043D\u0430 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u0432 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u0443 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E"){let l={};return l[o]=-1,X.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return o.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):o.match(/month/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):o.match(/year/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var lC,QH=b(()=>{hs();Le();Oc();Bt();lC=class extends Lo{innerPatternString(e){return`(\u0446\u0456|\u043E\u0441\u0442\u0430\u043D\u043D\u0456|\u043C\u0438\u043D\u0443\u043B\u0456|\u043C\u0430\u0439\u0431\u0443\u0442\u043D\u0456|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0456|\u043F\u0456\u0441\u043B\u044F|\u0447\u0435\u0440\u0435\u0437|\\+|-)\\s*(${ih})`}innerExtract(e,t){let n=t[1].toLowerCase(),i=oh(t[3]);switch(n){case"\u043E\u0441\u0442\u0430\u043D\u043D\u0456":case"\u043C\u0438\u043D\u0443\u043B\u0456":case"-":i=tt(i);break}return X.createRelativeFromReference(e.reference,i)}}});var CR={};Jr(CR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>bR,createCasualConfiguration:()=>XH,createConfiguration:()=>wR,parse:()=>hse,parseDate:()=>gse,strict:()=>mse});function XH(){let r=wR(!1);return r.parsers.unshift(new iC),r.parsers.unshift(new oC),r.parsers.unshift(new Jw),r.parsers.unshift(new aC),r.parsers.unshift(new lC),r}function wR(r){return Ht({parsers:[new wo,new vr(!0),new Xw,new Zw,new sC,new eC(r),new tC],refiners:[new nC,new rC]},r)}function hse(r,e,t){return bR.parse(r,e,t)}function gse(r,e,t){return bR.parseDate(r,e,t)}var bR,mse,ZH=b(()=>{$H();BH();UH();qH();WH();zH();HH();Ti();jH();GH();YH();KH();ai();Le();ft();us();QH();Tp();bR=new ke(XH()),mse=new ke(wR(!0))});function vse(r){let e=r.toLowerCase();return xR[e]!==void 0?xR[e]:e==="un"||e==="un'"||e==="una"||e==="uno"?1:e.match(/qualche/)?3:e.match(/mezz/)?.5:e.match(/paio/)?2:e.match(/alcuni/)?7:parseFloat(e)}function lh(r){let e=r.toLowerCase();return ER[e]!==void 0?ER[e]:(e=e.replace(/(?:°|ª|º)$/i,""),parseInt(e))}function Ku(r){if(/BE/i.test(r))return r=r.replace(/BE/i,""),parseInt(r)-543;if(/BCE?/i.test(r))return r=r.replace(/BCE?/i,""),-parseInt(r);if(/(AD|CE)/i.test(r))return r=r.replace(/(AD|CE)/i,""),parseInt(r);let e=parseInt(r);return Gr(e)}function ea(r){let e={},t=r,n=JH.exec(t);for(;n;)bse(e,n),t=t.substring(n[0].length).trim(),n=JH.exec(t);return Object.keys(e).length==0?null:e}function bse(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=vse(e[1]),n=sh[e[2].toLowerCase()];r[n]=t}var WA,TR,Js,xR,ER,e6,sh,t6,ah,Yu,r6,JH,yse,n6,Nc,Qu,qn=b(()=>{ze();zt();WA={domenica:0,dom:0,"dom.":0,luned\u00EC:1,lunedi:1,lun:1,"lun.":1,marted\u00EC:2,martedi:2,mar:2,"mar.":2,mercoled\u00EC:3,mercoledi:3,mer:3,"mer.":3,gioved\u00EC:4,giovedi:4,gio:4,"gio.":4,venerd\u00EC:5,venerdi:5,ven:5,"ven.":5,sabato:6,sab:6,"sab.":6},TR={gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12},Js={...TR,gen:1,"gen.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,mag:5,"mag.":5,giu:6,"giu.":6,lug:7,"lug.":7,ago:8,"ago.":8,set:9,"set.":9,sett:9,"sett.":9,ott:10,"ott.":10,nov:11,"nov.":11,dic:12,"dic.":12},xR={uno:1,una:1,un:1,due:2,tre:3,quattro:4,cinque:5,sei:6,sette:7,otto:8,nove:9,dieci:10,undici:11,dodici:12},ER={primo:1,prima:1,"1\xB0":1,"1\xAA":1,secondo:2,seconda:2,"2\xB0":2,"2\xAA":2,terzo:3,terza:3,"3\xB0":3,"3\xAA":3,quarto:4,quarta:4,"4\xB0":4,"4\xAA":4,quinto:5,quinta:5,"5\xB0":5,"5\xAA":5,sesto:6,sesta:6,"6\xB0":6,"6\xAA":6,settimo:7,settima:7,"7\xB0":7,"7\xAA":7,ottavo:8,ottava:8,"8\xB0":8,"8\xAA":8,nono:9,nona:9,"9\xB0":9,"9\xAA":9,decimo:10,decima:10,"10\xB0":10,"10\xAA":10,undicesimo:11,undicesima:11,"11\xB0":11,"11\xAA":11,dodicesimo:12,dodicesima:12,"12\xB0":12,"12\xAA":12,tredicesimo:13,tredicesima:13,"13\xB0":13,"13\xAA":13,quattordicesimo:14,quattordicesima:14,"14\xB0":14,"14\xAA":14,quindicesimo:15,quindicesima:15,"15\xB0":15,"15\xAA":15,sedicesimo:16,sedicesima:16,"16\xB0":16,"16\xAA":16,diciassettesimo:17,diciassettesima:17,"17\xB0":17,"17\xAA":17,diciottesimo:18,diciottesima:18,"18\xB0":18,"18\xAA":18,diciannovesimo:19,diciannovesima:19,"19\xB0":19,"19\xAA":19,ventesimo:20,ventesima:20,"20\xB0":20,"20\xAA":20,ventunesimo:21,ventunesima:21,"21\xB0":21,"21\xAA":21,ventiduesimo:22,ventiduesima:22,"22\xB0":22,"22\xAA":22,ventitreesimo:23,ventitreesima:23,"23\xB0":23,"23\xAA":23,ventiquattresimo:24,ventiquattresima:24,"24\xB0":24,"24\xAA":24,venticinquesimo:25,venticinquesima:25,"25\xB0":25,"25\xAA":25,ventiseiesimo:26,ventiseiesima:26,"26\xB0":26,"26\xAA":26,ventisettesimo:27,ventisettesima:27,"27\xB0":27,"27\xAA":27,ventottesimo:28,ventottesima:28,"28\xB0":28,"28\xAA":28,ventinovesimo:29,ventinovesima:29,"29\xB0":29,"29\xAA":29,trentesimo:30,trentesima:30,"30\xB0":30,"30\xAA":30,trentunesimo:31,trentunesima:31,"31\xB0":31,"31\xAA":31},e6={secondo:"second",secondi:"second",minuto:"minute",minuti:"minute",ora:"hour",ore:"hour",giorno:"day",giorni:"day",settimana:"week",settimane:"week",mese:"month",mesi:"month",trimestre:"quarter",trimestri:"quarter",anno:"year",anni:"year"},sh={s:"second",sec:"second",secondo:"second",secondi:"second",m:"minute",min:"minute",minuto:"minute",minuti:"minute",h:"hour",ora:"hour",ore:"hour",g:"day",gg:"day",giorno:"day",giorni:"day",sett:"week",settimana:"week",settimane:"week",mese:"month",mesi:"month",trim:"quarter",trimestre:"quarter",trimestri:"quarter",anno:"year",anni:"year",...e6},t6=`(?:${te(xR)}|[0-9]+|[0-9]+\\.[0-9]+|mezz[oa]?(?:\\s{0,2})?|un(?:'|\\s{0,2})?|qualche|alcuni|paio\\s{0,2}(?:di)?)`;ah=`(?:${te(ER)}|[0-9]{1,2}(?:\xB0|\xAA|\xBA)?)`;Yu="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9]|2[0-5])";r6=`(${t6})\\s{0,3}(${te(sh)})`,JH=new RegExp(r6,"i"),yse=`(${t6})\\s{0,3}(${te(e6)})`,n6="\\s{0,5},?(?:\\s*e)?\\s{0,5}",Nc=Tr("(?:(?:circa|approssimativamente)\\s{0,3})?",r6,n6),Qu=Tr("(?:(?:circa|approssimativamente)\\s{0,3})?",yse,n6)});var wse,Cse,xse,cC,i6=b(()=>{qn();Le();fe();wse=new RegExp(`(?:(?:entro|tra|fra|in|per)\\s*)?(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${Nc})(?=\\W|$)`,"i"),Cse=new RegExp(`(?:entro|tra|fra|in|per)\\s*(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${Nc})(?=\\W|$)`,"i"),xse=new RegExp(`(?:entro|tra|fra|in|per)\\s*(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${Qu})(?=\\W|$)`,"i"),cC=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(t){return this.strictMode?xse:t.option.forwardDate?wse:Cse}innerExtract(t,n){if(n[0].match(/^per\s*(il|la|l')\s*\w+/))return null;let i=ea(n[1]);return i?X.createRelativeFromReference(t.reference,i):null}}});var Ese,o6,s6,Tse,a6,uC,l6=b(()=>{zt();qn();qn();qn();ze();fe();Ese=new RegExp(`(?:il\\s{0,3})?(${ah})(?:\\s{0,3}(?:al|\\-|\\\u2013|fino\\s*al?)?\\s{0,3}(${ah}))?(?:-|/|\\s{0,3}(?:di)?\\s{0,3})(${te(Js)})(?:(?:-|/|,?\\s{0,3})(${Yu}(?!\\w)))?(?=\\W|$)`,"i"),o6=1,s6=2,Tse=3,a6=4,uC=class extends B{innerPattern(){return Ese}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=Js[t[Tse].toLowerCase()],o=lh(t[o6]);if(o>31)return t.index=t.index+t[o6].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[a6]){let s=Ku(t[a6]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[s6]){let s=lh(t[s6]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var _se,Ase,c6,_R,AR,dC,u6=b(()=>{zt();qn();qn();qn();ze();fe();_se=new RegExp(`(${te(Js)})(?:-|/|\\s*,?\\s*)(${ah})(?!\\s*(?:am|pm))\\s*(?:(?:al|\\-)\\s*(${ah})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${Yu}))?(?=\\W|$)(?!\\:\\d)`,"i"),Ase=1,c6=2,_R=3,AR=4,dC=class extends B{constructor(t){super();ae(this,"shouldSkipYearLikeDate");this.shouldSkipYearLikeDate=t}innerPattern(){return _se}innerExtract(t,n){let i=Js[n[Ase].toLowerCase()],o=lh(n[c6]);if(o>31||this.shouldSkipYearLikeDate&&!n[_R]&&!n[AR]&&n[c6].match(/^2[0-5]$/))return null;let s=t.createParsingComponents({day:o,month:i}).addTag("parser/ITMonthNameMiddleEndianParser");if(n[AR]){let c=Ku(n[AR]);s.assign("year",c)}else{let c=mt(t.refDate,o,i);s.imply("year",c)}if(!n[_R])return s;let a=lh(n[_R]),l=t.createParsingResult(n.index,n[0]);return l.start=s,l.end=s.clone(),l.end.assign("day",a),l}}});var kse,Sse,Dse,d6,pC,p6=b(()=>{qn();zt();ze();qn();fe();kse=new RegExp(`((?:a|in|di|del)\\s*)?(${te(Js)})\\s*(?:(?:,|-|del)?\\s*(${Yu})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),Sse=1,Dse=2,d6=3,pC=class extends B{innerPattern(){return kse}innerExtract(e,t){let n=t[Dse].toLowerCase();if(t[0].length<=3&&!TR[n])return null;let i=e.createParsingResult(t.index+(t[Sse]||"").length,t.index+t[0].length);i.start.imply("day",1),i.start.addTag("parser/ITMonthNameParser");let o=Js[n];if(i.start.assign("month",o),t[d6]){let s=Ku(t[d6]);i.start.assign("year",s)}else{let s=mt(e.refDate,1,o);i.start.imply("year",s)}return i}}});var Ise,Pse,Fse,f6,Mse,fC,m6=b(()=>{qn();ze();fe();Ise=new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${te(Js)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),Pse=1,Fse=2,f6=3,Mse=4,fC=class extends B{constructor(t){super();ae(this,"strictMonthDateOrder");this.strictMonthDateOrder=t}innerPattern(){return Ise}innerExtract(t,n){let i=parseInt(n[Pse]),o=parseInt(n[Mse]),s=n[f6]?parseInt(n[f6]):Js[n[Fse].toLowerCase()];if(s<1||s>12){if(this.strictMonthDateOrder)return null;o>=1&&o<=12&&([s,o]=[o,s])}return o<1||o>31?null:{day:o,month:s,year:i}}}});var Rse,$se,Ose,mC,h6=b(()=>{fe();Rse=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),$se=1,Ose=2,mC=class extends B{innerPattern(){return Rse}innerExtract(e,t){let n=parseInt(t[Ose]),i=parseInt(t[$se]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});var hC,g6=b(()=>{ft();La();hC=class extends Yr{constructor(e){super(e)}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a|fino\\s*a|alle?|\\?)\\s*"}primaryPrefix(){return"(?:(?:alle?|dalle?)\\s*)??"}primarySuffix(){return"(?:\\s*(?:di\\s*(?:sera|notte|mattina|pomeriggio)))?(?!/)(?=\\W|$)"}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(!n)return n;if(t[0].match(/di\s*(?:sera|notte)/i)){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",j.PM)):i<6&&n.assign("meridiem",j.AM)}if(t[0].match(/di\s*pomeriggio/i)){n.assign("meridiem",j.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}return t[0].match(/di\s*mattina/i)&&(n.assign("meridiem",j.AM),n.get("hour")<12&&n.assign("hour",n.get("hour"))),n.addTag("parser/ITTimeExpressionParser")}extractFollowingTimeComponents(e,t,n){let i=super.extractFollowingTimeComponents(e,t,n);return i&&i.addTag("parser/ITTimeExpressionParser"),i}}});var Nse,Lse,gC,v6=b(()=>{qn();Le();fe();Bt();Nse=new RegExp(`(${Nc})\\s{0,5}(?:fa|prima)(?=\\W|$)`,"i"),Lse=new RegExp(`(${Qu})\\s{0,5}(?:fa|prima)(?=\\W|$)`,"i"),gC=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Lse:Nse}innerExtract(t,n){let i=ea(n[1]);return i?X.createRelativeFromReference(t.reference,tt(i)):null}}});var Bse,Vse,Use,vC,y6=b(()=>{qn();Le();fe();Bse=new RegExp(`(${Nc})\\s{0,5}(?:dopo|pi\xF9\\s*tardi|da\\s*adesso|da\\s*ora)(?=(?:\\W|$))`,"i"),Vse=new RegExp(`(${Qu})\\s{0,5}(dopo|pi\xF9\\s*tardi|da\\s*adesso|da\\s*ora)(?=\\W|$)`,"i"),Use=1,vC=class extends B{constructor(t){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Vse:Bse}innerExtract(t,n){let i=ea(n[Use]);return i?X.createRelativeFromReference(t.reference,i):null}}});var yC,b6=b(()=>{yo();yC=class extends Yt{patternBetween(){return/^\s*(a|al|-||fino\s*a|fino\s*al)\s*$/i}}});var ch,w6=b(()=>{bo();ch=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|alle?|dopo\\s*le|prima\\s*delle?|,|-|\\.|\u2219|:)?\\s*$")}}});var qse,bC,C6=b(()=>{fe();on();si();qse=/(adesso|ora|oggi|stasera|stanotte|domani|dopodomani|ieri|ieri\s*sera|ieri\s*notte)(?=\W|$)/i,bC=class extends B{innerPattern(e){return qse}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"adesso":case"ora":o=Or(e.reference);break;case"oggi":o=_r(e.reference);break;case"ieri":o=vn(e.reference);break;case"domani":o=yn(e.reference);break;case"stasera":case"stanotte":o=yA(e.reference);break;case"dopodomani":o=Ro(e.reference,2);break;default:if(i.match(/ieri\s*sera/)||i.match(/ieri\s*notte/)){if(n.getHours()>6){let s=new Date(n.getTime());s.setDate(s.getDate()-1),n=s}nt(o,n),o.imply("hour",0)}break}return o.addTag("parser/ITCasualDateParser"),o}}});var Wse,wC,x6=b(()=>{fe();si();Wse=/(stamattina|stasera|stanotte|stamani)|(questa\s*)?(mattina|pomeriggio|sera|notte|mezzanotte|mezzogiorno)(?=\W|$)/i,wC=class extends B{innerPattern(){return Wse}innerExtract(e,t){let n=null;if(t[1])switch(t[1].toLowerCase()){case"stamattina":case"stamani":n=Mc(e.reference);break;case"stasera":case"stanotte":n=Pc(e.reference);break}else if(t[3])switch(t[3].toLowerCase()){case"pomeriggio":n=CA(e.reference);break;case"sera":case"notte":n=Pc(e.reference);break;case"mezzanotte":n=Fc(e.reference);break;case"mattina":n=Mc(e.reference);break;case"mezzogiorno":n=Hu(e.reference);break}return n&&n.addTag("parser/ITCasualTimeParser"),n}}});var zse,Hse,jse,Gse,CC,E6=b(()=>{qn();ze();fe();Qi();ft();zse=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(questo|questa|quest'|scorso|scorsa|prossimo|prossima)\\s*)?(${te(WA)}|weekend|fine\\s*settimana)(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(scorso|scorsa|prossimo|prossima)(?:\\s*settimana)?)?(?=\\W|$)`,"i"),Hse=1,jse=2,Gse=3,CC=class extends B{innerPattern(){return zse}innerExtract(e,t){let n=t[Hse],i=t[Gse],o=n||i;o=o||"",o=o.toLowerCase();let s=null;o=="scorso"||o=="scorsa"?s="last":o=="prossimo"||o=="prossima"?s="next":(o=="questo"||o=="questa"||o=="quest'")&&(s="this");let a=t[jse].toLowerCase(),l;if(WA[a]!==void 0)l=WA[a];else if(a=="weekend"||a.match(/fine\s*settimana/))l=s=="last"?Oe.SUNDAY:Oe.SATURDAY;else return null;return cr(e.reference,l,s)}}});var Yse,T6,Kse,Qse,Xse,xC,_6=b(()=>{qn();Le();fe();ze();Yse=new RegExp(`(?:(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo\\s*questo|dopo\\s*questa)\\s*(${te(sh)})|(?:il\\s*|la\\s*|l'\\s*)(${te(sh)})\\s*(scorso|scorsa|prossimo|prossima))(?=\\W|$)`,"i"),T6=1,Kse=2,Qse=3,Xse=4,xC=class extends B{innerPattern(){return Yse}innerExtract(e,t){let n,i;t[T6]?(n=t[T6].toLowerCase(),i=t[Kse].toLowerCase()):(n=t[Xse].toLowerCase(),i=t[Qse].toLowerCase());let o=sh[i];if(n=="prossimo"||n=="prossima"||n.startsWith("dopo")){let l={};return l[o]=1,X.createRelativeFromReference(e.reference,l)}if(n=="scorso"||n=="scorsa"){let l={};return l[o]=-1,X.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return i.match(/settimana/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):i.match(/mese/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):i.match(/anno/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var Zse,Jse,EC,A6=b(()=>{qn();Le();fe();Bt();Zse=new RegExp(`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${Nc})(?=\\W|$)`,"i"),Jse=new RegExp(`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${Qu})(?=\\W|$)`,"i"),EC=class extends B{constructor(t=!0){super();ae(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?Zse:Jse}innerExtract(t,n){let i=n[1].toLowerCase(),o=ea(n[2]);if(!o)return null;switch(i){case"scorso":case"scorsa":case"-":o=tt(o);break}return X.createRelativeFromReference(t.reference,o)}}});function eae(r){return r.text.match(/^[+-]/i)!=null}function k6(r){return r.text.match(/^-/i)!=null}var TC,S6=b(()=>{Ks();Le();qn();Bt();TC=class extends oi{shouldMergeResults(e,t,n){return e.match(/^\s*$/i)?eae(n)||k6(n):!1}mergeResults(e,t,n,i){let o=ea(n.text);k6(n)&&(o=tt(o));let s=X.createRelativeFromReference(ct.fromDate(t.start.date()),o);return new at(t.reference,t.index,`${t.text}${e}${n.text}`,s)}}});function D6(r){return r.text.match(/\s+(prima|da)$/i)!=null}function tae(r){return r.text.match(/\s+(dopo|dal?)$/i)!=null}var _C,I6=b(()=>{Ks();Le();qn();Bt();_C=class extends oi{patternBetween(){return/^\s*$/i}shouldMergeResults(e,t,n){return!e.match(this.patternBetween())||!D6(t)&&!tae(t)?!1:!!n.start.get("day")&&!!n.start.get("month")&&!!n.start.get("year")}mergeResults(e,t,n){let i=ea(t.text);D6(t)&&(i=tt(i));let o=X.createRelativeFromReference(ct.fromDate(n.start.date()),i);return new at(n.reference,t.index,`${t.text}${e}${n.text}`,o)}}});var rae,nae,AC,P6=b(()=>{qn();rae=new RegExp(`^\\s*(${Yu})`,"i"),nae=1,AC=class{refine(e,t){return t.forEach(function(n){if(!n.start.isDateWithUnknownYear())return;let i=e.text.substring(n.index+n.text.length),o=rae.exec(i);if(!o||o[0].trim().length<=3)return;e.debug(()=>{console.log(`Extracting year: '${o[0]}' into : ${n}`)});let s=Ku(o[nae]);n.end!=null&&n.end.assign("year",s),n.start.assign("year",s),n.text+=o[0]}),t}}});var kC,F6=b(()=>{Ks();kC=class extends zu{constructor(){super()}isValid(e,t){let n=t.text.trim();return n===e.text.trim()?!0:n.toLowerCase().endsWith("il secondo")||n.toLowerCase()==="secondo"?(e.text.substring(t.index+t.text.length).trim().length>0&&e.debug(()=>{console.log(`Removing unlikely result: ${t}`)}),!1):!0}}});var SC,M6=b(()=>{i6();l6();u6();p6();m6();h6();g6();v6();y6();b6();w6();Ti();C6();x6();E6();_6();us();A6();S6();I6();gA();P6();F6();SC=class{createCasualConfiguration(){let e=this.createConfiguration(!1);return e.parsers.push(new bC),e.parsers.push(new wC),e.parsers.push(new pC),e.parsers.push(new xC),e.parsers.push(new EC),e.refiners.push(new kC),e}createConfiguration(e=!0){let t=Ht({parsers:[new vr(!0),new cC(e),new uC,new dC(!0),new CC,new mC,new hC(e),new gC(e),new vC(e)],refiners:[new ch]},e);return t.parsers.unshift(new fC(e)),t.refiners.unshift(new _C),t.refiners.unshift(new TC),t.refiners.unshift(new _l),t.refiners.push(new ch),t.refiners.push(new AC),t.refiners.push(new yC),t}}});var DR={};Jr(DR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>SR,configuration:()=>kR,parse:()=>oae,parseDate:()=>sae,strict:()=>iae});function oae(r,e,t){return SR.parse(r,e,t)}function sae(r,e,t){return SR.parseDate(r,e,t)}var kR,SR,iae,R6=b(()=>{ai();Le();ft();M6();kR=new SC,SR=new ke(kR.createCasualConfiguration()),iae=new ke(kR.createConfiguration(!0))});function O6(r){let e={},t=r,n=$6.exec(t);for(;n;)cae(e,n),t=t.substring(n[0].length),n=$6.exec(t);return e}function cae(r,e){let t=dae(e[1]),n=FR[e[2].toLowerCase()];r[n]=t}function dae(r){let e=r.toLowerCase();return DC[e]!==void 0?DC[e]:parseInt(e)}function U6(r){if(/\d+/.test(r)){let t=parseInt(r);return t<100&&(t=Gr(t)),t}let e=r.toLowerCase();return DC[e]!==void 0?DC[e]:parseInt(r)}var IR,PR,aae,DC,FR,lae,N6,jXe,GXe,L6,$6,uae,B6,V6,IC=b(()=>{ze();zt();IR={s\u00F6ndag:0,s\u00F6n:0,so:0,m\u00E5ndag:1,m\u00E5n:1,m\u00E5:1,tisdag:2,tis:2,ti:2,onsdag:3,ons:3,on:3,torsdag:4,tors:4,to:4,fredag:5,fre:5,fr:5,l\u00F6rdag:6,l\u00F6r:6,l\u00F6:6},PR={januari:1,jan:1,"jan.":1,februari:2,feb:2,"feb.":2,mars:3,mar:3,"mar.":3,april:4,apr:4,"apr.":4,maj:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,augusti:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,december:12,dec:12,"dec.":12},aae={f\u00F6rsta:1,andra:2,tredje:3,fj\u00E4rde:4,femte:5,sj\u00E4tte:6,sjunde:7,\u00E5ttonde:8,nionde:9,tionde:10,elfte:11,tolfte:12,trettonde:13,fjortonde:14,femtonde:15,sextonde:16,sjuttonde:17,artonde:18,nittonde:19,tjugonde:20,tjugof\u00F6rsta:21,tjugoandra:22,tjugotredje:23,tjugofj\u00E4rde:24,tjugofemte:25,tjugosj\u00E4tte:26,tjugosjunde:27,tjugo\u00E5ttonde:28,tjugonionde:29,trettionde:30,trettiof\u00F6rsta:31},DC={en:1,ett:1,tv\u00E5:2,tre:3,fyra:4,fem:5,sex:6,sju:7,\u00E5tta:8,nio:9,tio:10,elva:11,tolv:12,tretton:13,fjorton:14,femton:15,sexton:16,sjutton:17,arton:18,nitton:19,tjugo:20,tretti\u043E:30,fyrtio:40,femtio:50,sextio:60,sjuttio:70,\u00E5ttio:80,nittio:90,hundra:100,tusen:1e3},FR={sek:"second",sekund:"second",sekunder:"second",min:"minute",minut:"minute",minuter:"minute",tim:"hour",timme:"hour",timmar:"hour",dag:"day",dagar:"day",vecka:"week",veckor:"week",m\u00E5n:"month",m\u00E5nad:"month",m\u00E5nader:"month",\u00E5r:"year",kvart\u0430l:"quarter",kvartal:"quarter"},lae={sekund:"second",sekunder:"second",minut:"minute",minuter:"minute",timme:"hour",timmar:"hour",dag:"day",dagar:"day",vecka:"week",veckor:"week",m\u00E5nad:"month",m\u00E5nader:"month",\u00E5r:"year",kvartal:"quarter"};N6=`(?:${te(DC)}|\\d+)`,jXe=`(?:${te(aae)}|\\d{1,2}(?:e|:e))`,GXe=`(?:${te(FR)})`,L6=`(${N6})\\s{0,5}(${te(FR)})\\s{0,5}`,$6=new RegExp(L6,"i"),uae=`(${N6})\\s{0,5}(${te(lae)})\\s{0,5}`,B6=Tr("",L6),V6=Tr("",uae)});var pae,fae,mae,hae,PC,q6=b(()=>{IC();ze();fe();Qi();pae=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:p\xE5\\s*?)?(?:(f\xF6rra|senaste|n\xE4sta|kommande)\\s*)?(${te(IR)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(f\xF6rra|senaste|n\xE4sta|kommande)\\s*vecka)?(?=\\W|$)`,"i"),fae=1,mae=3,hae=2,PC=class extends B{innerPattern(){return pae}innerExtract(e,t){let n=t[hae].toLowerCase(),i=IR[n],o=t[fae],s=t[mae],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/förra|senaste/)?l="last":a.match(/nästa|kommande/)&&(l="next"),cr(e.reference,i,l)}}});var gae,W6,z6,vae,H6,FC,j6=b(()=>{zt();IC();IC();ze();fe();gae=new RegExp(`(?:den\\s*?)?([0-9]{1,2})(?:\\s*(?:till|\\-|\\\u2013|\\s)\\s*([0-9]{1,2}))?\\s*(${te(PR)})(?:(?:-|/|,?\\s*)([0-9]{4}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),W6=1,z6=2,vae=3,H6=4,FC=class extends B{innerPattern(){return gae}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=PR[t[vae].toLowerCase()],o=parseInt(t[W6]);if(o>31)return t.index=t.index+t[W6].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[H6]){let s=U6(t[H6]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[z6]){let s=parseInt(t[z6]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var yae,bae,MC,G6=b(()=>{IC();Le();fe();Bt();yae=new RegExp(`(denna|den h\xE4r|f\xF6rra|passerade|n\xE4sta|kommande|efter|\\+|-)\\s*(${B6})(?=\\W|$)`,"i"),bae=new RegExp(`(denna|den h\xE4r|f\xF6rra|passerade|n\xE4sta|kommande|efter|\\+|-)\\s*(${V6})(?=\\W|$)`,"i"),MC=class extends B{constructor(t=!0){super();ae(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?yae:bae}innerExtract(t,n){let i=n[1].toLowerCase(),o=O6(n[2]);if(!o)return null;switch(i){case"f\xF6rra":case"passerade":case"-":o=tt(o);break}return X.createRelativeFromReference(t.reference,o)}}});var wae,Cae,xae,RC,Y6=b(()=>{fe();on();si();wae=new RegExp("(nu|idag|imorgon|\xF6vermorgon|ig\xE5r|f\xF6rrg\xE5r|i\\s*f\xF6rrg\xE5r)(?:\\s*(?:p\xE5\\s*)?(morgonen?|f\xF6rmiddagen?|middagen?|eftermiddagen?|kv\xE4llen?|natten?|midnatt))?(?=\\W|$)","i"),Cae=1,xae=2,RC=class extends B{innerPattern(e){return wae}innerExtract(e,t){let n=e.refDate,i=(t[Cae]||"").toLowerCase(),o=(t[xae]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"nu":s=Or(e.reference);break;case"idag":s=_r(e.reference);break;case"imorgon":case"imorn":let a=new Date(n.getTime());a.setDate(a.getDate()+1),nt(s,a),Lt(s,a);break;case"ig\xE5r":let l=new Date(n.getTime());l.setDate(l.getDate()-1),nt(s,l),Lt(s,l);break;case"f\xF6rrg\xE5r":case"i f\xF6rrg\xE5r":let c=new Date(n.getTime());c.setDate(c.getDate()-2),nt(s,c),Lt(s,c);break}switch(o){case"morgon":case"morgonen":s.imply("hour",6),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"f\xF6rmiddag":case"f\xF6rmiddagen":s.imply("hour",9),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"middag":case"middagen":s.imply("hour",12),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"eftermiddag":case"eftermiddagen":s.imply("hour",15),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"kv\xE4ll":case"kv\xE4llen":s.imply("hour",20),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"natt":case"natten":case"midnatt":o==="midnatt"?s.imply("hour",0):s.imply("hour",2),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break}return s}}});var $R={};Jr($R,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>MR,createCasualConfiguration:()=>K6,createConfiguration:()=>RR,parse:()=>Tae,parseDate:()=>_ae,strict:()=>Eae});function Tae(r,e,t){return MR.parse(r,e,t)}function _ae(r,e,t){return MR.parseDate(r,e,t)}function K6(r=!0){let e=RR(!1,r);return e.parsers.unshift(new RC),e}function RR(r=!0,e=!0){return Ht({parsers:[new wo,new vr(e),new FC,new PC,new MC],refiners:[]},r)}var MR,Eae,Q6=b(()=>{Ti();ai();Le();ft();us();Tp();q6();j6();G6();Y6();MR=new ke(K6()),Eae=new ke(RR(!0))});var $C,X6=b(()=>{La();$C=class extends Yr{primaryPrefix(){return"(?:(?:klo|kello)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});function uh(r){let e={},t=r,n=Z6.exec(t);for(;n;)kae(e,n),t=t.substring(n[0].length),n=Z6.exec(t);return e}function kae(r,e){let t=Dae(e[1]),n=LR[e[2].toLowerCase()];r[n]=t}function Dae(r){let e=r.toLowerCase();return OC[e]!==void 0?OC[e]:parseInt(e)}function rj(r){if(/\d+/.test(r)){let t=parseInt(r);return t<100&&(t=Gr(t)),t}let e=r.toLowerCase();return OC[e]!==void 0?OC[e]:parseInt(r)}var OR,NR,OC,LR,Aae,J6,DZe,ej,Z6,Sae,dh,tj,zp=b(()=>{ze();zt();OR={sunnuntai:0,sunnuntaina:0,su:0,maanantai:1,maanantaina:1,ma:1,tiistai:2,tiistaina:2,ti:2,keskiviikko:3,keskiviikkona:3,ke:3,torstai:4,torstaina:4,to:4,perjantai:5,perjantaina:5,pe:5,lauantai:6,lauantaina:6,la:6},NR={tammikuu:1,tammikuuta:1,tammikuun:1,tammi:1,helmikuu:2,helmikuuta:2,helmikuun:2,helmi:2,maaliskuu:3,maaliskuuta:3,maaliskuun:3,maalis:3,huhtikuu:4,huhtikuuta:4,huhtikuun:4,huhti:4,toukokuu:5,toukokuuta:5,toukokuun:5,touko:5,kes\u00E4kuu:6,kes\u00E4kuuta:6,kes\u00E4kuun:6,kes\u00E4:6,hein\u00E4kuu:7,hein\u00E4kuuta:7,hein\u00E4kuun:7,hein\u00E4:7,elokuu:8,elokuuta:8,elokuun:8,elo:8,syyskuu:9,syyskuuta:9,syyskuun:9,syys:9,lokakuu:10,lokakuuta:10,lokakuun:10,loka:10,marraskuu:11,marraskuuta:11,marraskuun:11,marras:11,joulukuu:12,joulukuuta:12,joulukuun:12,joulu:12},OC={yksi:1,yhden:1,kaksi:2,kahden:2,kolme:3,kolmen:3,nelj\u00E4:4,nelj\u00E4n:4,viisi:5,viiden:5,kuusi:6,kuuden:6,seitsem\u00E4n:7,kahdeksan:8,yhdeks\u00E4n:9,kymmenen:10},LR={s:"second",sek:"second",sekunti:"second",sekuntia:"second",sekunnin:"second",min:"minute",minuutti:"minute",minuuttia:"minute",minuutin:"minute",t:"hour",tunti:"hour",tuntia:"hour",tunnin:"hour",pv:"day",p\u00E4iv\u00E4:"day",p\u00E4iv\u00E4\u00E4:"day",p\u00E4iv\u00E4n:"day",vk:"week",viikko:"week",viikkoa:"week",viikon:"week",kk:"month",kuukausi:"month",kuukautta:"month",kuukauden:"month",vuosi:"year",vuotta:"year",vuoden:"year"},Aae={sekunti:"second",sekuntia:"second",sekunnin:"second",minuutti:"minute",minuuttia:"minute",minuutin:"minute",tunti:"hour",tuntia:"hour",tunnin:"hour",p\u00E4iv\u00E4:"day",p\u00E4iv\u00E4\u00E4:"day",p\u00E4iv\u00E4n:"day",viikko:"week",viikkoa:"week",viikon:"week",kuukausi:"month",kuukautta:"month",kuukauden:"month",vuosi:"year",vuotta:"year",vuoden:"year"};J6=`(?:${te(OC)}|\\d+)`,DZe=`(?:${te(LR)})`,ej=`(${J6})\\s{0,5}(${te(LR)})\\s{0,5}`,Z6=new RegExp(ej,"i"),Sae=`(${J6})\\s{0,5}(${te(Aae)})\\s{0,5}`,dh=Tr("",ej),tj=Tr("",Sae)});var Iae,Pae,Fae,Mae,NC,nj=b(()=>{zp();ze();fe();Qi();Iae=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(viime|edellinen|edellisen\xE4|ensi|seuraava|seuraavana|t\xE4m\xE4|t\xE4n\xE4)\\s*)?(${te(OR)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(viime|ensi|seuraava)\\s*viikolla)?(?=\\W|$)`,"i"),Pae=1,Fae=2,Mae=3,NC=class extends B{innerPattern(){return Iae}innerExtract(e,t){let n=t[Fae].toLowerCase(),i=OR[n],o=t[Pae],s=t[Mae],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/viime|edellinen|edellisenä/)?l="last":a.match(/ensi|seuraava|seuraavana/)&&(l="next"),cr(e.reference,i,l)}}});var Rae,ij,oj,$ae,sj,LC,aj=b(()=>{zt();zp();zp();ze();fe();Rae=new RegExp(`([0-9]{1,2})\\.?(?:\\s*(?:\\-|\\\u2013|\\s)\\s*([0-9]{1,2})\\.?)?\\s*(${te(NR)})(?:(?:-|/|,?\\s*)([0-9]{4}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),ij=1,oj=2,$ae=3,sj=4,LC=class extends B{innerPattern(){return Rae}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=NR[t[$ae].toLowerCase()],o=parseInt(t[ij]);if(o>31)return t.index=t.index+t[ij].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[sj]){let s=rj(t[sj]);n.start.assign("year",s)}else{let s=mt(e.refDate,o,i);n.start.imply("year",s)}if(t[oj]){let s=parseInt(t[oj]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Oae,Nae,BC,lj=b(()=>{zp();Le();fe();Bt();Oae=new RegExp(`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${dh})(?=\\W|$)`,"i"),Nae=new RegExp(`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${tj})(?=\\W|$)`,"i"),BC=class extends B{constructor(t=!0){super();ae(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?Oae:Nae}innerExtract(t,n){let i=n[1].toLowerCase(),o=uh(n[2]);if(!o)return null;switch(i){case"edellinen":case"edelliset":case"edellisten":case"viimeiset":case"viimeisten":case"kuluneet":case"kuluneiden":case"-":o=tt(o);break}return X.createRelativeFromReference(t.reference,o)}}});var VC,cj=b(()=>{zp();Le();fe();Bt();VC=class extends B{innerPattern(){return new RegExp(`(${dh})\\s*sitten(?=\\W|$)`,"i")}innerExtract(e,t){let n=uh(t[1]),i=tt(n);return X.createRelativeFromReference(e.reference,i)}}});var UC,uj=b(()=>{zp();Le();fe();UC=class extends B{innerPattern(){return new RegExp(`(${dh})\\s*(?:sis\xE4ll\xE4|kuluessa|p\xE4\xE4st\xE4)(?=\\W|$)`,"i")}innerExtract(e,t){let n=uh(t[1]);return X.createRelativeFromReference(e.reference,n)}}});var Hp,BR=b(()=>{ft();fe();on();Hp=class r extends B{innerPattern(e){return/(tänä\s*)?(aamulla|aamuna|aamupäivällä|päivällä|iltapäivällä|illalla|yöllä|keskiyöllä)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[2].toLowerCase(),o=e.createParsingComponents();return Lt(o,n),r.extractTimeComponents(o,i)}static extractTimeComponents(e,t){switch(t){case"aamulla":case"aamuna":e.imply("hour",6),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/morning");break;case"aamup\xE4iv\xE4ll\xE4":e.imply("hour",9),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/morning");break;case"p\xE4iv\xE4ll\xE4":e.imply("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/noon");break;case"iltap\xE4iv\xE4ll\xE4":e.imply("hour",15),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/afternoon");break;case"illalla":e.imply("hour",18),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/evening");break;case"y\xF6ll\xE4":e.imply("hour",22),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.PM),e.addTag("casualReference/evening");break;case"keskiy\xF6ll\xE4":e.get("hour")>1&&e.addDurationAsImplied({day:1}),e.imply("hour",0),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",j.AM),e.addTag("casualReference/midnight");break}return e}}});var Lae,Bae,Vae,qC,dj=b(()=>{fe();on();BR();si();Bt();Lae=new RegExp("(nyt|t\xE4n\xE4\xE4n|huomenna|ylihuomenna|eilen|toissap\xE4iv\xE4n\xE4|viime\\s*y\xF6n\xE4)(?:\\s*(aamulla|aamuna|aamup\xE4iv\xE4ll\xE4|p\xE4iv\xE4ll\xE4|iltap\xE4iv\xE4ll\xE4|illalla|y\xF6ll\xE4|keskiy\xF6ll\xE4))?(?=\\W|$)","i"),Bae=1,Vae=2,qC=class extends B{innerPattern(e){return Lae}innerExtract(e,t){let n=e.reference.getDateWithAdjustedTimezone(),i=(t[Bae]||"").toLowerCase(),o=(t[Vae]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"nyt":s=Or(e.reference);break;case"t\xE4n\xE4\xE4n":s=_r(e.reference);break;case"huomenna":n=yt(n,{day:1}),nt(s,n),Lt(s,n);break;case"ylihuomenna":n=yt(n,{day:2}),nt(s,n),Lt(s,n);break;case"eilen":n=yt(n,{day:-1}),nt(s,n),Lt(s,n);break;case"toissap\xE4iv\xE4n\xE4":n=yt(n,{day:-2}),nt(s,n),Lt(s,n);break;default:i.match(/viime\s*yönä/)&&(n.getHours()>6&&(n=yt(n,{day:-1})),nt(s,n),s.imply("hour",0));break}return o&&(s=Hp.extractTimeComponents(s,o)),s}}});var WC,pj=b(()=>{yo();WC=class extends Yt{patternBetween(){return/^\s*(-|)\s*$/i}}});var zC,fj=b(()=>{bo();zC=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|klo|kello|,|-)?\\s*$")}}});var qR={};Jr(qR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>VR,createCasualConfiguration:()=>mj,createConfiguration:()=>UR,parse:()=>qae,parseDate:()=>Wae,strict:()=>Uae});function qae(r,e,t){return VR.parse(r,e,t)}function Wae(r,e,t){return VR.parseDate(r,e,t)}function mj(r=!0){let e=UR(!1,r);return e.parsers.unshift(new Hp),e.parsers.unshift(new qC),e.parsers.unshift(new BC),e}function UR(r=!0,e=!0){return Ht({parsers:[new wo,new vr(e),new $C,new LC,new NC,new UC,new VC],refiners:[new WC,new zC]},r)}var VR,Uae,hj=b(()=>{Ti();ai();Le();ft();us();Tp();X6();nj();aj();lj();cj();uj();dj();BR();pj();fj();VR=new ke(mj()),Uae=new ke(UR(!0))});function zae(r){let e=r.toLowerCase();return WR[e]!==void 0?WR[e]:parseFloat(e)}function fh(r){let e=r.toUpperCase(),t=parseInt(r.replace(/[^0-9]+/g,""));return/TCN/.test(e)?-t:Gr(t)}function Xu(r){let e={},t=r,n=gj.exec(t);for(;n;){let i=zae(n[1]),o=HC[n[2].toLowerCase()];e[o]=i,t=t.substring(n[0].length),n=gj.exec(t)}return e}var zR,HR,WR,HC,jR,ph,vj,gj,mh,Lc=b(()=>{ze();zt();zR={"ch\u1EE7 nh\u1EADt":0,cn:0,"th\u1EE9 hai":1,t2:1,"th\u1EE9 ba":2,t3:2,"th\u1EE9 t\u01B0":3,t4:3,"th\u1EE9 n\u0103m":4,t5:4,"th\u1EE9 s\xE1u":5,t6:5,"th\u1EE9 b\u1EA3y":6,t7:6},HR={"th\xE1ng 1":1,"th\xE1ng m\u1ED9t":1,"th\xE1ng gi\xEAng":1,"th\xE1ng 2":2,"th\xE1ng hai":2,"th\xE1ng 3":3,"th\xE1ng ba":3,"th\xE1ng 4":4,"th\xE1ng t\u01B0":4,"th\xE1ng 5":5,"th\xE1ng n\u0103m":5,"th\xE1ng 6":6,"th\xE1ng s\xE1u":6,"th\xE1ng 7":7,"th\xE1ng b\u1EA3y":7,"th\xE1ng 8":8,"th\xE1ng t\xE1m":8,"th\xE1ng 9":9,"th\xE1ng ch\xEDn":9,"th\xE1ng 10":10,"th\xE1ng m\u01B0\u1EDDi":10,"th\xE1ng 11":11,"th\xE1ng m\u01B0\u1EDDi m\u1ED9t":11,"th\xE1ng 12":12,"th\xE1ng m\u01B0\u1EDDi hai":12,"th\xE1ng ch\u1EA1p":12},WR={m\u1ED9t:1,hai:2,ba:3,b\u1ED1n:4,n\u0103m:5,s\u00E1u:6,b\u1EA3y:7,t\u00E1m:8,ch\u00EDn:9,m\u01B0\u1EDDi:10,"m\u01B0\u1EDDi m\u1ED9t":11,"m\u01B0\u1EDDi hai":12},HC={gi\u00E2y:"second",ph\u00FAt:"minute",gi\u1EDD:"hour",ng\u00E0y:"day",tu\u1EA7n:"week",th\u00E1ng:"month",n\u0103m:"year"},jR="(?:"+te(WR)+"|[0-9]+|[0-9]+\\.[0-9]+)";ph="(?:[0-9]{1,4}(?:\\s*TCN)?)";vj="("+jR+")\\s{0,5}("+te(HC)+")\\s{0,5}",gj=new RegExp(vj,"i"),mh=Tr("",vj)});var Hae,jae,Gae,yj,jC,bj=b(()=>{zt();Lc();fe();Hae=new RegExp("(?:ng\xE0y\\s*)?([0-9]{1,2})\\s*th\xE1ng\\s*([0-9]{1,2})(?:\\s*n\u0103m\\s*("+ph+"))?(?=\\W|$)","i"),jae=1,Gae=2,yj=3,jC=class extends B{innerPattern(){return Hae}innerExtract(e,t){let n=parseInt(t[jae]),i=parseInt(t[Gae]);if(n>31||i>12)return null;let o=e.createParsingResult(t.index,t[0]);return o.start.assign("day",n),o.start.assign("month",i),t[yj]?o.start.assign("year",fh(t[yj])):o.start.imply("year",mt(e.refDate,n,i)),o}}});var Yae,Kae,wj,GC,Cj=b(()=>{Lc();ze();fe();Yae=new RegExp("("+te(HR)+")(?:\\s*(?:n\u0103m|/)\\s*("+ph+"))?(?=\\W|$)","i"),Kae=1,wj=2,GC=class extends B{innerPattern(){return Yae}innerExtract(e,t){let n=HR[t[Kae].toLowerCase()];if(!n)return null;let i=e.createParsingResult(t.index,t[0]);return i.start.assign("month",n),i.start.imply("day",1),t[wj]?i.start.assign("year",fh(t[wj])):i.start.imply("year",e.reference.getDateWithAdjustedTimezone().getFullYear()),i}}});var Qae,xj,Xae,Zae,YC,Ej=b(()=>{Lc();fe();Qae=new RegExp("(?:\\bn\u0103m\\s*("+ph+")|\\b([0-9]{1,4})\\s*(TCN))(?=\\W|$)","i"),xj=1,Xae=2,Zae=3,YC=class extends B{innerPattern(){return Qae}innerExtract(e,t){let n;t[xj]?n=t[xj]:n=t[Xae]+" "+t[Zae];let i=e.createParsingResult(t.index,t[0]);return i.start.assign("year",fh(n)),i.start.imply("month",1),i.start.imply("day",1),i}}});var Jae,KC,Tj=b(()=>{fe();si();Jae=/\b(hôm nay|hôm qua|hôm kia|ngày mai|ngày kia|bây giờ|lúc này)(?=\W|$)/i,KC=class extends B{innerPattern(){return Jae}innerExtract(e,t){switch(t[1].toLowerCase()){case"b\xE2y gi\u1EDD":case"l\xFAc n\xE0y":return Or(e.reference);case"h\xF4m nay":return _r(e.reference);case"h\xF4m qua":return vn(e.reference);case"h\xF4m kia":return Ic(e.reference,2);case"ng\xE0y mai":return yn(e.reference);case"ng\xE0y kia":return Ro(e.reference,2)}return e.createParsingComponents()}}});var ele,QC,_j=b(()=>{ft();fe();on();ele=/(buổi\s*)?(sáng sớm|sáng|trưa|chiều|tối|đêm|nửa đêm|bình minh)(?=\W|$)/i,QC=class r extends B{innerPattern(){return ele}innerExtract(e,t){let n=e.createParsingComponents();return Lt(n,e.refDate),r.extractTimeComponents(n,t[2].toLowerCase())}static extractTimeComponents(e,t){switch(t){case"b\xECnh minh":case"s\xE1ng s\u1EDBm":e.imply("hour",6),e.imply("minute",0),e.imply("meridiem",j.AM);break;case"s\xE1ng":e.imply("hour",9),e.imply("minute",0),e.imply("meridiem",j.AM);break;case"tr\u01B0a":e.imply("hour",12),e.imply("minute",0),e.imply("meridiem",j.PM);break;case"chi\u1EC1u":e.imply("hour",15),e.imply("minute",0),e.imply("meridiem",j.PM);break;case"t\u1ED1i":e.imply("hour",19),e.imply("minute",0),e.imply("meridiem",j.PM);break;case"\u0111\xEAm":e.imply("hour",22),e.imply("minute",0),e.imply("meridiem",j.PM);break;case"n\u1EEDa \u0111\xEAm":e.imply("hour",0),e.imply("minute",0),e.imply("meridiem",j.AM);break}return e}}});var tle,rle,nle,XC,Aj=b(()=>{Lc();ze();fe();Qi();tle=new RegExp("("+te(zR)+")(?:\\s*(n\xE0y|t\u1EDBi|sau(?!\\s*khi)|qua))?(?=\\W|$)","i"),rle=1,nle=2,XC=class extends B{innerPattern(){return tle}innerExtract(e,t){let n=t[rle].toLowerCase(),i=zR[n];if(i===void 0)return null;let o=t[nle],s=null;if(o){let a=o.toLowerCase();a.includes("t\u1EDBi")||a.includes("sau")?s="next":a.includes("qua")&&(s="last")}return cr(e.reference,i,s)}}});var ile,ole,kj,sle,Sj,ZC,Dj=b(()=>{fe();ft();ile=new RegExp("(?:l\xFAc\\s*|v\xE0o\\s*)?([0-9]{1,2})(?:\\s*gi\u1EDD\\s*([0-9]{1,2})?\\s*(?:ph\xFAt\\s*)?(s\xE1ng|tr\u01B0a|chi\u1EC1u|t\u1ED1i|\u0111\xEAm)?|:([0-9]{2}))(?=\\W|$)","i"),ole=1,kj=2,sle=3,Sj=4,ZC=class extends B{innerPattern(){return ile}innerExtract(e,t){let n=parseInt(t[ole]);if(n>23)return null;let i=e.createParsingResult(t.index,t[0]);i.start.assign("hour",n);let o=t[Sj]?parseInt(t[Sj]):t[kj]?parseInt(t[kj]):0;if(o>=60)return null;i.start.assign("minute",o);let s=t[sle]?.toLowerCase();return s==="s\xE1ng"?(i.start.assign("meridiem",j.AM),n===12&&i.start.assign("hour",0)):s==="tr\u01B0a"?n<10?(i.start.assign("meridiem",j.PM),i.start.assign("hour",n+12)):i.start.assign("meridiem",n>=12?j.PM:j.AM):(s==="chi\u1EC1u"||s==="t\u1ED1i"||s==="\u0111\xEAm")&&(i.start.assign("meridiem",j.PM),n<12&&i.start.assign("hour",n+12)),i.start.imply("second",0),i.start.imply("millisecond",0),i}}});var ale,JC,Ij=b(()=>{Lc();Le();fe();Bt();ale=new RegExp("("+mh+")\\s{0,5}(?:tr\u01B0\u1EDBc|qua)(?=\\W|$)","i"),JC=class extends B{constructor(t=!1){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return ale}innerExtract(t,n){let i=Xu(n[1]);return i?X.createRelativeFromReference(t.reference,tt(i)):null}}});var lle,ex,Pj=b(()=>{Lc();Le();fe();lle=new RegExp("("+mh+")\\s{0,5}(?:sau|n\u1EEFa|t\u1EDBi|ti\u1EBFp)(?=\\W|$)","i"),ex=class extends B{constructor(t=!1){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return lle}innerExtract(t,n){let i=Xu(n[1]);return i?X.createRelativeFromReference(t.reference,i):null}}});var cle,tx,Fj=b(()=>{Lc();Le();fe();cle=new RegExp("(?:trong\\s*(?:v\xF2ng\\s*)?)("+mh+")(?=\\W|$)","i"),tx=class extends B{constructor(t=!1){super();ae(this,"strictMode");this.strictMode=t}innerPattern(){return cle}innerExtract(t,n){let i=Xu(n[1]);return i?X.createRelativeFromReference(t.reference,i):null}}});var Mj,ule,rx,Rj=b(()=>{Lc();Le();fe();Bt();ze();Mj="(?:"+jR+"\\s{0,5})?(?:"+te(HC)+")",ule=new RegExp("(n\xE0y|tr\u01B0\u1EDBc|qua|sau|t\u1EDBi|ti\u1EBFp)\\s*("+Mj+")|("+Mj+")\\s*(n\xE0y|tr\u01B0\u1EDBc|qua|sau|t\u1EDBi|ti\u1EBFp)(?=\\W|$)","i"),rx=class extends B{innerPattern(){return ule}innerExtract(e,t){let n=(t[1]||t[4]||"").toLowerCase(),i=(t[2]||t[3]||"").toLowerCase(),o=Xu(i);if(Object.keys(o).length===0){let s=HC[i];if(!s)return null;o={[s]:1}}return(n==="tr\u01B0\u1EDBc"||n==="qua")&&(o=tt(o)),X.createRelativeFromReference(e.reference,o)}}});var nx,$j=b(()=>{yo();nx=class extends Yt{patternBetween(){return/^\s*(?:|-|đến|tới|và)\s*$/}}});var ix,Oj=b(()=>{bo();ix=class extends Kt{patternBetween(){return/^\s*(?:lúc|vào|,|T|-)?\s*$/}}});var ox,Nj=b(()=>{vA();ox=class extends Dc{}});var KR={};Jr(KR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>GR,createCasualConfiguration:()=>Lj,createConfiguration:()=>YR,parse:()=>ple,parseDate:()=>fle,strict:()=>dle});function ple(r,e,t){return GR.parse(r,e,t)}function fle(r,e,t){return GR.parseDate(r,e,t)}function Lj(r=!0){let e=YR(!1,r);return e.parsers.unshift(new QC),e.parsers.unshift(new KC),e.parsers.unshift(new rx),e}function YR(r=!0,e=!0){return Ht({parsers:[new wo,new vr(e),new jC,new GC,new YC,new XC,new ZC,new JC(r),new ex(r),new tx(r)],refiners:[new ox,new nx,new ix]},r)}var GR,dle,Bj=b(()=>{Ti();ai();Le();ft();Tp();us();bj();Cj();Ej();Tj();_j();Aj();Dj();Ij();Pj();Fj();Rj();$j();Oj();Nj();GR=new ke(Lj()),dle=new ke(YR(!0))});var XR={};Jr(XR,{Chrono:()=>ke,Meridiem:()=>j,ParsingComponents:()=>X,ParsingContext:()=>vb,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>QR,de:()=>zF,en:()=>$F,es:()=>dR,fi:()=>qR,fr:()=>eM,it:()=>DR,ja:()=>iM,nl:()=>vM,parse:()=>hle,parseDate:()=>gle,pt:()=>cM,ru:()=>oR,strict:()=>mle,sv:()=>$R,uk:()=>CR,vi:()=>KR,zh:()=>KM});function hle(r,e,t){return QR.parse(r,e,t)}function gle(r,e,t){return QR.parseDate(r,e,t)}var mle,QR,Vj=b(()=>{DW();ai();Le();ft();ZW();Cz();Vz();e3();_3();z3();dH();PH();ZH();R6();Q6();hj();Bj();mle=RF,QR=yb});function vle(){return XR}var ZR,Sl,hh=b(()=>{Vj();ZR=class{constructor(){this.chrono=vle()}getParsedDate(e){return this.chrono.parseDate(e,new Date,{forwardDate:!0})}parseDate(e){if(!e||!e.trim())return null;try{let t=this.getParsedDate(e);return t?window.moment?{moment:window.moment(t)}:(console.warn("Moment.js is not available"),null):null}catch(t){return console.warn("Failed to parse date:",e,t),null}}},Sl=new ZR});function Uj(r){return r<=31||r===127||r===8232||r===8233}function wle(r){let e="",t=0;for(;t<r.length;){let n=t;for(;n<r.length&&r.charCodeAt(n)===32;)n++;if(n<r.length&&Uj(r.charCodeAt(n))){for(;n<r.length&&Uj(r.charCodeAt(n));)n++;for(;n<r.length&&r.charCodeAt(n)===32;)n++;e+=" ",t=n;continue}e+=r.slice(t,Math.min(n+1,r.length)),t=n+1}return e}function qj(r,e){let t=r.length;for(;t>0&&e.includes(r[t-1]);)t--;return r.slice(0,t)}function jp(r){return Cle.filter(e=>r.includes(e))}function zj(r){return`A file or folder name cannot contain ${Gj(r)}, so this choice would fail at run time. ${jj}`}function Hj(r,e){return`Cannot create "${e}": a file or folder name cannot contain ${Gj(r)}. ${jj}`}function Gj(r){return r.map(e=>`"${e}"`).join(", ")}function li(r,e="File path"){let{path:t,problems:n}=Kj(r,e);if(n.length>0)throw new Error(n[0]);return t}function Yj(r,e="File path"){return Kj(r,e)}function Kj(r,e){let t=[],n=r.replace(/\\/g,"/").split("/");return{path:n.map((o,s)=>o.length===0&&s!==0&&s!==n.length-1?(t.push(`${e} contains an empty path segment after formatting.`),o):xle(o,e,t)).join("/"),problems:t}}function xle(r,e,t){if(r.length===0)return r;let n=yle.test(r),i=ble.test(r),o=wle(r);n&&(o=o.replace(/^ /u,"")),i&&(o=o.replace(/ $/u,""));let s=qj(o," ");return s==="."||s===".."?(t.push(`${e} cannot contain "." or ".." path segments.`),s):(o=qj(o,". "),o||t.push(`${e} contains an empty path segment after formatting.`),o)}var Wj,yle,ble,Cle,jj,Dl=b(()=>{Wj="\0-\x7F\u2028\u2029",yle=new RegExp(`^ *[${Wj}]`,"u"),ble=new RegExp(`[${Wj}] *$`,"u");Cle=[":"];jj="Check your own text and tokens like {{TIME}}, which is HH:mm."});function AG(r){let e=t=>{t.preventDefault(),t.stopPropagation()};r.addEventListener("pointerdown",e),r.addEventListener("mousedown",e)}function Ece(r){r.forEach(e=>{e.addEventListener("keydown",t=>{if(t.key==="ArrowRight"||t.key==="ArrowLeft"){let i=(r.indexOf(e)+(t.key==="ArrowRight"?1:-1)+r.length)%r.length;r[i].focus(),t.preventDefault()}})})}var hx,Xi,Yp=b(()=>{hx=require("obsidian"),Xi=class r extends hx.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.input=null;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Ask(t,n,i){return new r(t,n,i).waitForClose}static async Prompt(t,n,i){return await r.Ask(t,n,i)===!0}display(){this.containerEl.addClass("quickAddModal","qaYesNoPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,this.contentEl.createEl("p",{text:this.text});let t=this.contentEl.createDiv({cls:"yesNoPromptButtonContainer"}),n=new hx.ButtonComponent(t).setButtonText("No").onClick(()=>this.submit(!1));AG(n.buttonEl);let i=new hx.ButtonComponent(t).setButtonText("Yes").onClick(()=>this.submit(!0)).setDestructive();AG(i.buttonEl),i.buttonEl.focus(),Ece([n.buttonEl,i.buttonEl])}submit(t){this.input=t,this.close()}onClose(){super.onClose(),this.resolvePromise(this.input)}}});var Vr,Kr=b(()=>{Vr=(c=>(c.Obsidian="Obsidian",c.UserScript="UserScript",c.Choice="Choice",c.Wait="Wait",c.NestedChoice="NestedChoice",c.EditorCommand="EditorCommand",c.AIAssistant="AIAssistant",c.OpenFile="OpenFile",c.Conditional="Conditional",c))(Vr||{})});function Di(r){return typeof r=="object"&&r!==null}function nd(r){return Di(r)&&!Array.isArray(r)}function Kue(r){return nd(r)?!1:Array.isArray(r)?r.length>0:Ii(r)}function zn(r){return nd(r)?r.commands:Kue(r)?r:void 0}function Ir(r){return Array.isArray(r)?r:[]}function Lh(r){return Array.isArray(r)?r:[]}function kx(r){return Array.isArray(r)}function Ii(r){return Array.isArray(r)||r==null?!1:typeof r=="object"?Object.keys(r).length>0:!!r}function $$(r){let e=Ir(r),t=new Set,n=!1,i=[];for(let o of e){if(Array.isArray(o)){let l=$$(o);for(let c of l.commands){let u=c.id;if(typeof u=="string"&&u!==""&&!t.has(u)){t.add(u),i.push(c);continue}let d={...c,id:Er()};t.add(d.id),i.push(d)}n=!0;continue}if(!Di(o)){n=!0;continue}let s=o.id;if(typeof s=="string"&&s!==""&&!t.has(s)){t.add(s),i.push(o);continue}let a={...o,id:Er()};t.add(a.id),i.push(a),n=!0}return n?{commands:i,changed:n}:{commands:e,changed:!1}}function dY(r){pY(r,new Set)}function pY(r,e){Di(r)&&(e.has(r)||(e.add(r),nd(r)&&(r.id=Er()),Ak(zn(r),e)))}function Ak(r,e){if(kx(r))for(let t of r){if(Array.isArray(t)){Ak(t,e);continue}if(!Di(t)||e.has(t))continue;e.add(t),t.id=Er();let n=t;Ak(n.thenCommands,e),Ak(n.elseCommands,e),fY(n.choice,e)}}function fY(r,e){if(!Di(r)||e.has(r))return;e.add(r);let t=r;if(t.id=Er(),t.type==="Macro"&&pY(t.macro,e),t.type==="Multi"&&Array.isArray(t.choices))for(let n of t.choices)fY(n,e)}var Pi=b(()=>{bl()});function id(r){return r!==null&&typeof r=="object"}function Fk(r){return r?.secretStorage}function Sk(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"setting"}function Zue(r){let e=5381;for(let t=0;t<r.length;t+=1)e=e*33^r.charCodeAt(t);return(e>>>0).toString(36).slice(0,Xue)}function hY(r,e){return r.length<=e?r:r.slice(0,e).replace(/-+$/g,"")||"setting"}function yY(r,e){let t=e?.id;return typeof t=="string"&&t.trim().length>0?t:r}function O$(r,e,t){let i=(t?[kk,r,e,t]:[kk,r,e]).join("-");if(i.length<=mY)return i;let o=Zue([r,e,t].filter(Boolean).join(":")),s=t?4:3,a=mY-kk.length-o.length-(t?.length??0)-s,l=Math.max(8,Math.floor(a*.6)),c=Math.max(8,a-l);return[kk,hY(r,l),hY(e,c),...t?[t]:[],o].join("-")}function N$(r){return r?.message??String(r)}function Ua(r,e){let t=e;for(;t<r.length;){let n=r[t],i=r[t+1];if(/\s/.test(n)){t+=1;continue}if(n==="/"&&i==="/"){let o=r.indexOf(`
`,t+2);t=o===-1?r.length:o+1;continue}if(n==="/"&&i==="*"){let o=r.indexOf("*/",t+2);t=o===-1?r.length:o+2;continue}return t}return t}function Dx(r,e){let t=r[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let n="";for(let i=e+1;i<r.length;i++){let o=r[i];if(o==="\\"){let s=r[i+1];if(s===void 0)return null;n+=s,i+=1;continue}if(o===t)return{value:n,end:i+1};n+=o}return null}function gY(r,e){let t=/^[A-Za-z_$][\w$]*/.exec(r.slice(e));return t?{value:t[0],end:e+t[0].length}:null}function Sx(r,e,t,n){let i=0;for(let o=e;o<r.length;o++){let s=r[o],a=r[o+1];if(s==='"'||s==="'"||s==="`"){let l=Dx(r,o);if(!l)return-1;o=l.end-1;continue}if(s==="/"&&a==="/"){let l=r.indexOf(`
`,o+2);o=l===-1?r.length:l;continue}if(s==="/"&&a==="*"){let l=r.indexOf("*/",o+2);if(l===-1)return-1;o=l+1;continue}if(s===t){i+=1;continue}if(s===n&&(i-=1,i===0))return o}return-1}function bY(r){let e=new Map,t=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'`])/g,n;for(;(n=t.exec(r))!==null;){let i=Dx(r,t.lastIndex-1);i&&(e.set(n[1],i.value),t.lastIndex=i.end)}return e}function Jue(r){let e=[],t=bY(r),n=0;for(;n<r.length;){n=Ua(r,n);let i=r[n],o=r[n+1];if(i==='"'||i==="'"||i==="`"){let l=Dx(r,n);n=l?l.end:n+1;continue}if(i==="/"&&o==="/"){let l=r.indexOf(`
`,n+2);n=l===-1?r.length:l+1;continue}if(i==="/"&&o==="*"){let l=r.indexOf("*/",n+2);n=l===-1?r.length:l+2;continue}let s=L$(r,n,t);if(!s){n+=1;continue}if(n=Ua(r,s.end),r[n]!==":"){n=s.end;continue}if(n=Ua(r,n+1),s.name!=="options"||r[n]!=="{")continue;let a=Sx(r,n,"{","}");if(a===-1)break;e.push({start:n+1,end:a}),n=a+1}return e}function L$(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){let i=Dx(r,e);return i?{name:i.value,end:i.end}:null}if(r[e]==="["){let i=Ua(r,e+1),o=gY(r,i),s=Sx(r,e,"[","]");if(s===-1)return null;let a=o?Ua(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}let n=gY(r,e);return n?{name:n.value,end:n.end}:null}function ede(r){let e=new Map,t=0;for(;t<r.length;){if(t=Ua(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;let n=L$(r,t,new Map);if(!n?.name){t+=1;continue}if(t=Ua(r,n.end),r[t]!==":"){t+=1;continue}if(t=Ua(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let i=Dx(r,t);if(!i)break;e.set(n.name,i.value),t=i.end;continue}if(r.slice(t,t+4)==="true"){e.set(n.name,!0),t+=4;continue}if(r.slice(t,t+5)==="false"){e.set(n.name,!1),t+=5;continue}if(r[t]==="{"){let i=Sx(r,t,"{","}");if(i===-1)break;t=i+1;continue}if(r[t]==="["){let i=Sx(r,t,"[","]");if(i===-1)break;t=i+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}return e}function tde(r){let e=ede(r),t=e.get("type"),n=e.get("secret");return t==="secret"||(t==="text"||t==="input")&&n===!0}function Vh(r,e){let t=e&&Que.test(e)?vc(r).code??"":r,n=new Set,i=!1,o=bY(t);for(let{start:s,end:a}of Jue(t)){let l=s;for(;l<a;){if(l=Ua(t,l),t[l]===","){l+=1;continue}if(l>=a)break;let c=L$(t,l,o);if(!c){l+=1;continue}if(l=Ua(t,c.end),t[l]!==":"){l+=1;continue}if(l=Ua(t,l+1),t[l]!=="{"){l+=1;continue}let u=Sx(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);tde(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}function Uh(r){return id(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}function Bh(r){return id(r)&&r[vY]===!0&&typeof r.secretRef=="string"&&r.secretRef.trim().length>0}function Dk(r){return{[vY]:!0,secretRef:r}}function rde(r,e,t){let n=r.id?.trim()||r.path||r.name||"script";return O$(Sk(n),Sk(yY(e,t)))}function nde(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Uh(t)).map(([t])=>t):[]}function ide(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Uh(t)):[]}function ode(r){return typeof r.id=="string"&&r.id.trim().length>0}async function B$(r,e){let t=Fk(r);if(!t?.getSecret)return null;try{return await Promise.resolve(t.getSecret(e))}catch(n){return M.logWarning(`Failed to read user script SecretStorage entry "${e}": ${N$(n)}`),null}}async function sde(r,e,t){let n=Fk(r);if(!n?.setSecret)return!1;try{return await Promise.resolve(n.setSecret(e,t)),!0}catch(i){return M.logWarning(`Failed to write user script SecretStorage entry "${e}": ${N$(i)}`),!1}}async function ade(r,e,t,n,i){let o=e.id?.trim()||e.path||e.name||"script",s=Sk(o),a=Sk(yY(t,i)),l=O$(s,a),c=1;for(;;){let u=await B$(r,l);if(!u||u===n)return l;c+=1,l=O$(s,a,String(c))}}async function V$(r,e,t,n,i,o){if(n.length===0)return null;let s=i?.trim()||await ade(r,e,t,n,o);return await sde(r,s,n)?s:null}async function U$(r,e){let t=e?.trim();if(!t)return!0;let n=Fk(r);if(!n)return!0;let i=n.deleteSecret??n.removeSecret??n.delete;try{if(i)return await Promise.resolve(i.call(n,t)),!0;if(n.setSecret)return await Promise.resolve(n.setSecret(t,"")),!0}catch(o){M.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${N$(o)}`)}return!1}async function Mk(r,e,t){let n=e.settings??{},i={...n},o=new Set(nde(t));for(let[s,a]of Object.entries(n)){if(Bh(a)){let l=await B$(r,a.secretRef);if(l){i[s]=l;continue}throw new Error(`Secret setting "${s}" for user script "${e.name}" is unavailable. Re-enter it on this device.`)}o.has(s)&&(i[s]=typeof a=="string"?a:"")}return i}async function qh(r,e,t){let n=ide(t);if(n.length===0)return!1;let i=Fk(r);if(!i?.getSecret||!i?.setSecret)return n.some(([a])=>{let l=e.settings?.[a];return typeof l=="string"&&l.length>0})&&M.logWarning(`SecretStorage unavailable; leaving plaintext user script secret settings for "${e.name}" unchanged.`),!1;let o=!1;for(let[s,a]of n){let l=e.settings?.[s];if(Bh(l))continue;if(typeof l!="string"||l.length===0){if(!ode(a))continue;let u=rde(e,s,a);if(!await B$(r,u))continue;e.settings[s]=Dk(u);for(let[f,p]of Object.entries(e.settings))f!==s&&Bh(p)&&p.secretRef===u&&delete e.settings[f];o=!0;continue}let c=await V$(r,e,s,l,void 0,a);c&&(e.settings[s]=Dk(c),o=!0)}return o}function Rk(r,e){let t=r.settings?.[e];return Bh(t)?t.secretRef:void 0}async function lde(r,e){if(!id(e))return!0;let t=Object.values(e).filter(Bh).map(i=>i.secretRef);return(await Promise.all(t.map(i=>U$(r,i)))).every(Boolean)}async function wY(r,e){if(!id(e))return!0;let t=!0;if(e.type==="Macro"&&(t=await Ik(r,zn(e.macro))&&t),e.type==="Multi"&&Array.isArray(e.choices))for(let n of e.choices)t=await wY(r,n)&&t;return t}async function Ix(r,e){if(!id(e))return!0;let t=!0;return e.type==="UserScript"&&(t=await lde(r,e.settings)&&t),Array.isArray(e.thenCommands)&&(t=await Ik(r,e.thenCommands)&&t),Array.isArray(e.elseCommands)&&(t=await Ik(r,e.elseCommands)&&t),t=await wY(r,e.choice)&&t,t}async function Ik(r,e){if(!Array.isArray(e))return!0;let t=!0;for(let n of e){if(Array.isArray(n)){t=await Ik(r,n)&&t;continue}t=await Ix(r,n)&&t}return t}function cde(r,e){let t=r.path;if(typeof t=="string")return e?.secretOptionNamesByPath?.get(t)}function ude(r,e,t){if(id(r))for(let[n,i]of Object.entries(r)){if(Bh(i)){delete r[n];continue}typeof i=="string"&&(e===null||e?.has(n)||e===void 0&&t?.stripUnknownStringSettings===!0)&&delete r[n]}}function q$(r,e){id(r)&&(r.type==="UserScript"&&ude(r.settings,cde(r,e),e),Array.isArray(r.thenCommands)&&Pk(r.thenCommands,e),Array.isArray(r.elseCommands)&&Pk(r.elseCommands,e),Wh(r.choice,e))}function Pk(r,e){if(Array.isArray(r))for(let t of r){if(Array.isArray(t)){Pk(t,e);continue}q$(t,e)}}function Wh(r,e){if(id(r)&&(r.type==="Macro"&&Pk(zn(r.macro),e),r.type==="Multi"&&Array.isArray(r.choices)))for(let t of r.choices)Wh(t,e)}var kk,vY,Que,mY,Xue,qc=b(()=>{Me();iy();Pi();kk="quickadd-user-script",vY="__quickaddSecret",Que=/\.md$/i,mY=64,Xue=8});function zh(r,e){if(e.options)for(let t in e.options){let n=r[t]===void 0,i="defaultValue"in e.options[t]&&e.options[t].defaultValue!==void 0;n&&i&&!Uh(e.options[t])&&(r[t]=e.options[t].defaultValue)}}var $k=b(()=>{qc()});function Uo(r){if(r.length===0)return 0;let e=new TextEncoder().encode(r).length,t=!1;for(let i=0;i<r.length;i++)if(r.charCodeAt(i)>127){t=!0;break}return Math.max(1,Math.ceil(e/(t?3:4)))}function xY(r){return!Number.isFinite(r)||r<=0?1:Math.max(1,Math.floor(r*.45))}var Px=b(()=>{});function AY(){return le.getState().ai.providers.flatMap(e=>e.models).map(e=>e.name)}function H$(){return le.getState().ai.providers}function EY(r,e){for(let t of r){let n=t.models.find(i=>i.name===e);if(n)return{provider:t,model:n}}}function z$(r){let e=H$();return e.filter(t=>t.models.some(n=>n.name===r)).map(t=>{let n=`${t.id??t.name}/${r}`;return e.some(o=>o.models.some(s=>s.name===n))?`{ name: "${r}", provider: "${t.id??t.name}" } (the string "${n}" is itself a model id on another provider)`:n})}function _Y(r,e){TY.has(r)||(TY.add(r),M.logWarning(e))}function Jp(r,e){let t=H$(),n=e?.silent===!0;if(r==null)return;if(typeof r!="string"){let s=t.find(c=>c.id===r.providerId),a=s?.models.find(c=>c.name===r.name);if(s&&a)return{provider:s,model:a};let l=EY(t,r.name);return l?(n||_Y(`pin:${r.providerId}/${r.name}\u2192${l.provider.id??l.provider.name}`,`Model "${r.name}" is pinned to provider "${r.providerId}", which no longer serves it. Using "${l.provider.name}" instead \u2014 re-select the model in the command's settings to pin it again.`),l):void 0}let i=EY(t,r);if(i){let s=z$(r);return s.length>1&&!n&&_Y(`ambiguous:${r}\u2192${i.provider.id??i.provider.name}`,`Model "${r}" is served by ${s.length} providers; using "${i.provider.name}". Qualify it to choose explicitly: ${s.join(", ")}.`),i}let o=r.indexOf("/");if(!(o<=0||o===r.length-1))return kY(r.slice(0,o),r.slice(o+1))}function kY(r,e){let t=H$(),n=r.trim().toLowerCase(),i=t.find(s=>s.id?.toLowerCase()===n)??t.find(s=>s.name.trim().toLowerCase()===n),o=i?.models.find(s=>s.name===e);if(i&&o)return{provider:i,model:o}}function Hh(r){let e=typeof r=="string"?r:r?.name;if(!e)throw new Error('Invalid model parameter. Expected a string (e.g., "gpt-4o" or "openai/gpt-4o") or an object with a name property (e.g., {name: "gpt-4o", provider: "openai"})');let t=typeof r!="string"&&r.provider?kY(r.provider,e):Jp(e);if(!t){let n=e.includes("/")?e.slice(e.indexOf("/")+1):e,i=[...z$(e),...n!==e?z$(n):[]],o=i.length?` Did you mean ${i.join(" or ")}?`:" Add it under Edit providers in QuickAdd's AI Assistant settings (the sparkles button below the choice list), or enable auto-sync for that provider.";throw new Error(`Model '${typeof r=="string"?r:`${r.provider??""}/${e}`}' not found in configured providers.${o}`)}return t}var TY,jh=b(()=>{Me();Pt();TY=new Set});var Uk=b(()=>{});var di,Wc=b(()=>{bl();di=class{constructor(e,t){this.name=e,this.type=t,this.id=Er()}}});var Yk,ln,sd=b(()=>{Yk=require("obsidian");Me();Mo();Hr();ln=class r extends Yk.FuzzySuggestModal{constructor(t,n,i,o={}){super(t);this.warnedOnEmptyDisplay=!1;this.warnRenderItemFailure=bp("Custom renderItem threw an error; falling back to default rendering");this.warnCustomValueFailure=bp("Custom create-row rendering threw an error; falling back to default rendering");this.allowCustomValue=!0;this.items=i,this.displayItems=n.map(s=>mn(s)),this.searchItems=o.searchItems?.map(s=>mn(s))??[],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.renderItem=o.renderItem,this.allowCustomValue=o.allowCustomValue??!0,this.customValueLabel=o.customValueLabel,this.valueExists=o.valueExists,this.inputEl.addEventListener("keydown",s=>{if(s.code!=="Tab"||!("chooser"in this))return;let{values:a,selectedItem:l}=this.chooser,{value:c}=this.inputEl;this.inputEl.value=a[l]?.item??c}),o.placeholder&&this.setPlaceholder(o.placeholder),typeof o.limit=="number"&&(this.limit=o.limit),o.emptyStateText&&(this.emptyStateText=o.emptyStateText),this.displayItems.length!==this.items.length&&(this.displayItems=this.items.map((s,a)=>{let l=this.displayItems[a];return mn(l??s)})),this.searchItems.length!==this.items.length&&(this.searchItems=this.items.map((s,a)=>mn(this.searchItems[a]??this.displayItems[a]??s))),o.skippable&&v_(this,()=>this.skip()),this.warnIfEmptyDisplay(),this.open()}static Suggest(t,n,i,o={}){return new r(t,n,i,o).promise}getItemText(t){if(t===this.inputEl.value)return t;let n=this.items.indexOf(t),i=n>=0?this.searchItems[n]:void 0;return mn(i??t)}getItems(){return this.items}getSuggestions(t){let n=Ec(t),i=super.getSuggestions(n);if(!this.allowCustomValue)return i;let o=Ec(this.inputEl.value);if(!o||this.items.includes(o)||this.valueExists?.(o)||i.some(l=>l.item===o))return i;let a={item:o,match:{score:Number.NEGATIVE_INFINITY,matches:[]}};return this.customValueLabel?i.unshift(a):i.push(a),i}selectSuggestion(t,n){this.resolved=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){if(this.customValueLabel&&t.match.score===Number.NEGATIVE_INFINITY){this.renderCustomValue(t.item,n);return}if(!this.renderItem){super.renderSuggestion(t,n);return}try{n.empty(),this.renderItem(t.item,n)}catch(i){this.warnRenderItemFailure(i),n.empty(),super.renderSuggestion(t,n)}}renderCustomValue(t,n){try{n.empty(),n.addClass("mod-complex"),n.createDiv({cls:"suggestion-content"}).createDiv({cls:"suggestion-title",text:this.customValueLabel?.(t)??t});let o=n.createDiv({cls:"suggestion-aux"});(0,Yk.setIcon)(o.createSpan({cls:"suggestion-flair"}),"file-plus")}catch(i){this.warnCustomValueFailure(i),n.empty(),super.renderSuggestion({item:t,match:{score:0,matches:[]}},n)}}onChooseItem(t,n){this.resolved=!0,this.resolvePromise(t)}skip(){this.resolved=!0,this.resolvePromise(""),this.close()}onClose(){super.onClose(),this.resolved||this.rejectPromise(rn())}warnIfEmptyDisplay(){if(this.warnedOnEmptyDisplay)return;this.displayItems.some(n=>n.length===0)&&(this.warnedOnEmptyDisplay=!0,M.logWarning("QuickAdd suggester received empty display values. Check your displayItems mapping."))}}});var ys=b(()=>{});var Vt,qa=b(()=>{Kr();Wc();vl();Me();Vt=class extends di{constructor(e){super(e,"EditorCommand"),this.editorCommandType=e}static getSelectedText(e){return this.getActiveMarkdownView(e).editor.getSelection()}static getActiveMarkdownView(e){let t=Nn(e);if(!t)throw M.logError("no active markdown editor."),new Error("no active markdown editor.");return t}}});var Qh,Q$=b(()=>{ys();qa();Qh=class extends Vt{constructor(){super("Copy")}static async run(e){let t=Vt.getSelectedText(e);await navigator.clipboard.writeText(t)}}});var Xh,X$=b(()=>{ys();qa();Me();Xh=class extends Vt{constructor(){super("Cut")}static async run(e){let t=Vt.getSelectedText(e),n=Vt.getActiveMarkdownView(e);if(!t){M.logError("nothing selected.");return}await navigator.clipboard.writeText(t),n.editor.replaceSelection("")}}});var Zh,Z$=b(()=>{ys();Me();qa();Zh=class extends Vt{constructor(){super("Paste")}static async run(e){let t=await navigator.clipboard.readText(),n=Vt.getActiveMarkdownView(e);if(!n){M.logError("no active markdown view.");return}n.editor.replaceSelection(t)}}});var OY,Jh,J$=b(()=>{OY=require("obsidian");Me();qa();ys();Jh=class extends Vt{constructor(){super("Paste with format")}static async run(e){let t=Vt.getActiveMarkdownView(e);if(!t){M.logError("no active markdown view.");return}let n="";try{if("read"in navigator.clipboard&&navigator.clipboard.read){let i=await navigator.clipboard.read(),o=!1;for(let s of i)if(s.types.includes("text/html")){let l=await(await s.getType("text/html")).text();n=(0,OY.htmlToMarkdown)(l),o=!0;break}o||(n=await navigator.clipboard.readText())}else n=await navigator.clipboard.readText();t.editor.replaceSelection(n)}catch(i){M.logWarning(`Formatted paste failed. Falling back to plain text: ${i}`);try{let o=await navigator.clipboard.readText();t.editor.replaceSelection(o)}catch(o){M.logError(`Failed to read clipboard text: ${o}`)}}}}});var eg,eO=b(()=>{ys();qa();eg=class extends Vt{constructor(){super("Select active line")}static run(e){let t=Vt.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),o=t.editor.getLine(n).length;t.editor.setSelection({line:n,ch:0},{line:n,ch:o})}}});var tg,tO=b(()=>{qa();ys();_t();Me();tg=class extends Vt{constructor(){super("Select link on active line")}static run(e){let t=Vt.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n),o=MB.exec(i);if(!o){M.logError(`no internal link found on line ${n}.`);return}let s=o.index,a=o[0].length+s;t.editor.setSelection({line:n,ch:s},{line:n,ch:a})}}});var rg,rO=b(()=>{qa();ys();rg=class extends Vt{constructor(){super("Move cursor to file start")}static run(e){Vt.getActiveMarkdownView(e).editor.setCursor({line:0,ch:0})}}});var ng,nO=b(()=>{qa();ys();ng=class extends Vt{constructor(){super("Move cursor to file end")}static run(e){let t=Vt.getActiveMarkdownView(e),n=t.editor.lastLine(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});var ig,iO=b(()=>{qa();ys();ig=class extends Vt{constructor(){super("Move cursor to line start")}static run(e){let t=Vt.getActiveMarkdownView(e),{line:n}=t.editor.getCursor();t.editor.setCursor({line:n,ch:0})}}});var og,oO=b(()=>{qa();ys();og=class extends Vt{constructor(){super("Move cursor to line end")}static run(e){let t=Vt.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});function e4(r,e=new Set){if(r==null||e.has(r))return[];if(e.add(r),typeof r=="string")return[r];if(typeof r!="object")return[String(r)];let t=r,n=[];for(let i of Kde){let o=t[i];o!==void 0&&n.push(...e4(o,e))}return n}function uS(r){return Number(r.replace(/,/g,""))}function Qde(r){let e=r.match(/context (?:length|window)(?:\s+is)?(?:\s+of)?\s*(\d[\d,]*)/i);return e?uS(e[1]):null}function Xde(r){let e=r.match(/(\d[\d,]*)\s*(?:tokens?\s+)?in the completion\b/i);if(e){let n=uS(e[1]),i=Qde(r);return i===null?"input":n>=i?"output":"input"}let t=r.match(/input length and max_tokens exceed context limit:?\s*(\d[\d,]*)\s*\+\s*(\d[\d,]*)(?:\s*>\s*(\d[\d,]*))?/i);if(t){let n=uS(t[2]),i=t[3]?uS(t[3]):null;return i===null?"input":n>=i?"output":"input"}return null}function Bx(r){let e=e4(r).join(" "),t=Xde(e);return t==="output"?"output_budget":t==="input"?"input_context":Yde.some(n=>n.test(e))?"output_budget":Gde.some(n=>n.test(e))?"input_context":"other"}function t4(r){return Bx(r)==="input_context"}function dS(r,e){let t="",n="",i;try{i=e.json}catch{i=void 0}if(i&&typeof i=="object"){let s=i,a=s.error??s;t=String(a.message??s.message??""),n=String(a.code??a.type??a.status??"")}t||(t=typeof e.text=="string"&&e.text.length>0?e.text:`HTTP ${e.status}`);let o=new Error(`${r} request failed (HTTP ${e.status})${n?` [${n}]`:""}: ${t}`);return o.status=e.status,n&&(o.providerCode=n),o}var Gde,Yde,Kde,Vx=b(()=>{Gde=[/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],Yde=[/max_tokens/i,/max_completion_tokens/i,/max(?:imum)? output tokens/i,/output token limit/i],Kde=["message","code","type","status","statusText","providerCode","error","response","json","cause"]});function lpe(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function cpe(r){let e=r.name?.trim()||"provider";return`${ape}-${lpe(e)}`}async function o4(r,e){if(!r?.secretStorage?.getSecret)return null;try{return await Promise.resolve(r.secretStorage.getSecret(e))}catch(t){return M.logWarning(`Failed to read SecretStorage entry "${e}": ${t.message??t}`),null}}async function za(r,e){let t=e.apiKeyRef?.trim();if(t){let n=await o4(r,t);if(n)return n}return e.apiKey??""}async function s4(r,e,t){let n=t?.trim();if(!n||!r?.secretStorage?.getSecret||!r.secretStorage?.setSecret)return null;let i=cpe(e),o=i,s=1;for(;;){let a=await o4(r,o);if(!a)break;if(a===n)return o;s+=1,o=`${i}-${s}`}try{return await Promise.resolve(r.secretStorage.setSecret(o,n)),o}catch(a){return M.logWarning(`Failed to write SecretStorage entry "${o}": ${a.message??a}`),null}}var ape,ef=b(()=>{Me();ape="quickadd-ai"});function R4(r){try{let e=window.require;return e?e(r):null}catch{return null}}async function vg(r,e){let t=r.vault.adapter;if(typeof DO.FileSystemAdapter!="function"||!(t instanceof DO.FileSystemAdapter))return;let n=R4("fs"),i=R4("path");if(!n?.promises||!i)return;let o=await n.promises.realpath(t.getBasePath()),a=t.getFullPath(e);for(;!hfe(n,a);){let f=i.dirname(a);if(f===a)break;a=f}let l;try{l=await n.promises.realpath(a)}catch{throw new qx(`Refusing to write to "${e}": it resolves through an unresolvable (dangling) symlink.`)}let c=i.relative(o,l);if(c===".."||c.startsWith(`..${i.sep}`)||i.isAbsolute(c))throw new qx(`Refusing to write to "${e}": it resolves (via a symlink) outside the vault.`);if(c.split(i.sep).some(f=>f.startsWith(".")))throw new qx(`Refusing to write to "${e}": it resolves (via a symlink) into a config/hidden directory.`)}function hfe(r,e){try{return r.lstatSync(e),!0}catch{return!1}}var DO,qx,IO=b(()=>{DO=require("obsidian"),qx=class extends Error{constructor(e){super(e),this.name="VaultWriteEscapeError"}}});var xe,xo=b(()=>{Bs();xe=class extends Nt{}});var h5,Lr,Hc=b(()=>{h5=require("obsidian");Me();Mo();Hr();Lr=class r extends h5.FuzzySuggestModal{constructor(t,n,i,o,s){super(t);this.warnedOnEmptyDisplay=!1;this.warnRenderItemFailure=bp("Custom renderItem threw an error; falling back to default rendering");this.renderItem=o,this.items=i,this.displayItems=n.map(a=>mn(a)),this.promise=new Promise((a,l)=>{this.resolvePromise=a,this.rejectPromise=l}),s?.skippable&&v_(this,()=>this.skip()),this.inputEl.addEventListener("keydown",a=>{if(a.code!=="Tab"||!("chooser"in this))return;let{values:l,selectedItem:c}=this.chooser,{value:u}=this.inputEl;this.inputEl.value=l[c]?.item??u}),this.displayItems.length!==this.items.length&&(this.displayItems=this.items.map((a,l)=>{let c=this.displayItems[l];return mn(c??a)})),this.warnIfEmptyDisplay(),this.open()}static Suggest(t,n,i,o,s,a){let l=new r(t,n,i,s,a);return o&&l.setPlaceholder(o),l.promise}getItemText(t){let n=this.items.indexOf(t),i=n>=0?this.displayItems[n]:void 0;return mn(i??t)}getItems(){return this.items}getSuggestions(t){let n=Ec(t);return super.getSuggestions(n)}selectSuggestion(t,n){this.resolved=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){if(!this.renderItem){super.renderSuggestion(t,n);return}try{n.empty(),this.renderItem(t.item,n)}catch(i){this.warnRenderItemFailure(i),n.empty(),super.renderSuggestion(t,n)}}onChooseItem(t,n){this.resolved=!0,this.resolvePromise(t)}skip(){this.resolved=!0,this.resolvePromise(""),this.close()}onClose(){super.onClose(),this.resolved||this.rejectPromise(rn())}warnIfEmptyDisplay(){if(this.warnedOnEmptyDisplay)return;this.displayItems.some(n=>n.length===0)&&(this.warnedOnEmptyDisplay=!0,M.logWarning("QuickAdd suggester received empty display values. Check your displayItems mapping."))}}});function Ri(r,e){if(!r)throw new Error(typeof e=="function"?e():e)}var Gx=b(()=>{});function wg(r){return KO.filter(e=>typeof r[e]=="number")}function HS(r){let e={...r};for(let t of KO)delete e[t];return e}function QO(r,e){return r.supportsTemperature===!1&&wg(e).length>0?HS(e):e}function XO(r,e){return e.length===0?!1:qme.some(t=>t.test(r))}function jS(r){let e=r.map(t=>Ume[t]);return e.length<=1?e.join(""):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}var KO,Ume,zS,qme,g5=b(()=>{KO=["temperature","top_p","frequency_penalty","presence_penalty"],Ume={temperature:"Temperature",top_p:"Top P",frequency_penalty:"Frequency penalty",presence_penalty:"Presence penalty"};zS=KO.join("|"),qme=[new RegExp(`unsupported (?:parameter|value)[^.]{0,40}['\`"]?(?:${zS})['\`"]?`,"i"),new RegExp(`['\`"]?(?:${zS})['\`"]?[^.]{0,40}(?:is deprecated|is not supported|not supported|does not support)`,"i"),new RegExp(`unrecognized request argument[^.]{0,40}(?:${zS})`,"i"),new RegExp(`(?:${zS})[^.]{0,40}extra inputs are not permitted`,"i")]});function GS(r){let e=r.workspace.activeEditor?.editor?.getCursor(),t=r.workspace.activeEditor?.editor?.listSelections();return()=>{e&&r.workspace.activeEditor?.editor?.setCursor(e),t&&r.workspace.activeEditor?.editor?.setSelections(t)}}var ZO=b(()=>{});function Yx(r){let e=Array.isArray(r)?r:{...r},t=e.type==="object"||Array.isArray(e.type)&&e.type.includes("object")||e.properties!==void 0;if(e.properties){let n={};for(let[i,o]of Object.entries(e.properties))n[i]=Yx(o);e.properties=n}return e.items&&!Array.isArray(e.items)&&(e.items=Yx(e.items)),t&&(e.additionalProperties=!1,e.required=e.properties?Object.keys(e.properties):[]),e}function Wme(r){let e=[];for(let t of r)if(t.role==="system")e.push({role:"system",content:t.content});else if(t.role==="user")e.push({role:"user",content:t.content});else if(t.role==="assistant"){let n={role:"assistant",content:t.content??""};t.toolCalls&&t.toolCalls.length>0&&(n.tool_calls=t.toolCalls.map(i=>({id:i.id,type:"function",function:{name:i.name,arguments:i.rawArgs??JSON.stringify(i.args??{})}}))),e.push(n)}else for(let n of t.results)e.push({role:"tool",tool_call_id:n.toolCallId,content:n.isError?`ERROR: ${n.content}`:n.content});return e}function zme(r){return r.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.strict?Yx(e.parameters):e.parameters,...e.strict?{strict:!0}:{}}}))}function Hme(r){return typeof r=="string"?r:{type:"function",function:{name:r.name}}}function Gme(r,e){let t={model:r,...e.modelParams??{},messages:Wme(e.messages)};return e.tools&&e.tools.length>0&&(t.tools=zme(e.tools),e.toolChoice&&(t.tool_choice=Hme(e.toolChoice)),e.disableParallel&&(t.parallel_tool_calls=!1)),e.maxOutputTokens!==void 0&&(jme.test(r)?t.max_completion_tokens=e.maxOutputTokens:t.max_tokens=e.maxOutputTokens),e.responseFormat&&(t.response_format=e.responseFormat.schema?{type:"json_schema",json_schema:{name:e.responseFormat.name??"response",strict:e.responseFormat.strict??!0,schema:e.responseFormat.strict??!0?Yx(e.responseFormat.schema):e.responseFormat.schema}}:{type:"json_object"}),t}function Yme(r){let e=r.choices?.[0]??{},t=e.message??{},i=(t.tool_calls??[]).map(a=>Kme(a)),o=String(e.finish_reason??""),s=r.usage??{};return{content:t.content??"",toolCalls:i,normalizedStopReason:i.length>0||o==="tool_calls"?"tool_calls":o==="length"?"length":o==="stop"?"stop":"other",rawStopReason:o,usage:{promptTokens:s.prompt_tokens??0,completionTokens:s.completion_tokens??0,totalTokens:s.total_tokens??0}}}function v5(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:null}function Kme(r){let e=r.function.arguments;if(typeof e=="string")try{let n=v5(JSON.parse(e||"{}"));if(!n)throw new Error("tool arguments are not a JSON object");return{id:r.id,name:r.function.name,args:n,rawArgs:e}}catch{return{id:r.id,name:r.function.name,args:null,rawArgs:e,parseError:!0}}let t=v5(e);return t?{id:r.id,name:r.function.name,args:t}:{id:r.id,name:r.function.name,args:null,rawArgs:typeof e=="string"?e:JSON.stringify(e??{}),parseError:!0}}function Qme(r,e,t){let n=[],i=[];for(let a of e.messages)if(a.role==="system")a.content&&n.push(a.content);else if(a.role==="user")i.push({role:"user",content:a.content});else if(a.role==="assistant"){let l=[];a.content&&l.push({type:"text",text:a.content});for(let c of a.toolCalls??[])l.push({type:"tool_use",id:c.id,name:c.name,input:c.args??{}});i.push({role:"assistant",content:l})}else i.push({role:"user",content:a.results.map(l=>({type:"tool_result",tool_use_id:l.toolCallId,content:l.content,...l.isError?{is_error:!0}:{}}))});let o={model:r,max_tokens:e.maxOutputTokens??t,messages:i};n.length>0&&(o.system=n.join(`
`));let s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.top_p=s.top_p),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(a=>({name:a.name,description:a.description,input_schema:a.parameters})),e.toolChoice?o.tool_choice=Xme(e.toolChoice,e.disableParallel):e.disableParallel&&(o.tool_choice={type:"auto",disable_parallel_tool_use:!0})),e.responseFormat?.schema&&(o.output_config={format:{type:"json_schema",schema:Yx(e.responseFormat.schema)}}),o}function Xme(r,e){let t=e?{disable_parallel_tool_use:!0}:{};return typeof r=="string"?r==="required"?{type:"any",...t}:r==="none"?{type:"none"}:{type:"auto",...t}:{type:"tool",name:r.name,...t}}function Zme(r){let e=r.content??[],t=e.filter(a=>a.type==="tool_use").map(a=>({id:a.id??"",name:a.name??"",args:a.input??{}})),n=String(r.stop_reason??""),i=r.usage??{},o=i.input_tokens??0,s=i.output_tokens??0;return{content:e.filter(a=>a.type==="text").map(a=>a.text??"").join(""),toolCalls:t,normalizedStopReason:n==="tool_use"||t.length>0?"tool_calls":n==="max_tokens"?"length":n==="end_turn"||n==="stop_sequence"?"stop":"other",rawStopReason:n,usage:{promptTokens:o,completionTokens:s,totalTokens:o+s}}}function Jme(r,e){let t=[],n=[];for(let a of e.messages)if(a.role==="system")a.content&&t.push(a.content);else if(a.role==="user")n.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(Array.isArray(a.providerRaw))n.push({role:"model",parts:a.providerRaw});else{let l=[];a.content&&l.push({text:a.content});for(let c of a.toolCalls??[])l.push({functionCall:{name:c.name,args:c.args??{}}});n.push({role:"model",parts:l})}else n.push({role:"user",parts:a.results.map(l=>({functionResponse:{name:l.name,response:l.isError?{error:l.content}:{result:l.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(`
`)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(a=>({name:a.name,description:a.description,parameters:a.parameters}))}],e.toolChoice&&(i.toolConfig=ehe(e.toolChoice)));let o={},s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.topP=s.top_p),e.maxOutputTokens!==void 0&&(o.maxOutputTokens=e.maxOutputTokens),e.responseFormat?.schema&&(o.responseMimeType="application/json",o.responseSchema=e.responseFormat.schema),Object.keys(o).length>0&&(i.generationConfig=o),i}function ehe(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function the(r){let e=r.candidates?.[0]??{},n=(e.content??{}).parts??[],i=n.filter(a=>a.functionCall).map((a,l)=>({id:a.functionCall?.id??`gemini-call-${l}`,name:a.functionCall?.name??"",args:a.functionCall?.args??{}})),o=String(e.finishReason??""),s=r.usageMetadata??{};return{content:n.filter(a=>typeof a.text=="string").map(a=>a.text??"").join(""),toolCalls:i,normalizedStopReason:i.length>0?"tool_calls":o==="MAX_TOKENS"?"length":o==="STOP"?"stop":"other",rawStopReason:o,usage:{promptTokens:s.promptTokenCount??0,completionTokens:s.candidatesTokenCount??0,totalTokens:s.totalTokenCount??0},providerRaw:n}}function JO(r,e,t,n=8192){switch(r){case"anthropic":return Qme(e,t,n);case"gemini":return Jme(e,t);default:return Gme(e,t)}}function y5(r,e){switch(r){case"anthropic":return Zme(e);case"gemini":return the(e);default:return Yme(e)}}var jme,b5=b(()=>{jme=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function Cg(r,e,t){let n=(0,Qx.requestUrl)({...r,throw:!1});t&&t();let i=await n;if(i.status>=400)throw dS(e,i);return i.json}function rhe(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 nhe(r){return{id:r.id,model:r.model,content:r.content.filter(e=>e.type==="text").map(e=>e.text??"").join(""),usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},stopReason:r.stop_reason,stopSequence:r.stop_sequence,created:Date.now()}}async function ihe(r,e,t,n,i,o,s){return Cg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:e.name,...i,messages:[{role:"system",content:n},{role:"user",content:o}]})},t.name,s)}function e1(r){if(typeof r.maxOutputTokens=="number"&&Number.isFinite(r.maxOutputTokens)&&r.maxOutputTokens>0)return Math.floor(r.maxOutputTokens);let e=4096;return Number.isFinite(r.maxTokens)&&r.maxTokens>0?Math.min(e,r.maxTokens):e}async function ohe(r,e,t,n,i,o,s){let a={model:e.name,max_tokens:e1(e),messages:[{role:"user",content:o}]};return n&&n.trim().length>0&&(a.system=n),typeof i.temperature=="number"&&(a.temperature=i.temperature),typeof i.top_p=="number"&&(a.top_p=i.top_p),Cg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":r,"anthropic-version":"2023-06-01"},body:JSON.stringify(a)},t.name,s)}async function she(r,e,t,n,i,o,s){let a=`${t.endpoint}/v1beta/models/${encodeURIComponent(e.name)}:generateContent`,l={};typeof i.temperature=="number"&&(l.temperature=i.temperature),typeof i.top_p=="number"&&(l.topP=i.top_p);let c={contents:[{role:"user",parts:[{text:o}]}]};return n&&n.trim().length>0&&(c.systemInstruction={role:"system",parts:[{text:n}]}),Object.keys(l).length>0&&(c.generationConfig=l),Cg({url:a,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":r},body:JSON.stringify(c)},t.name,s)}function ahe(r){let e=r.candidates?.[0],n=(e?.content?.parts??[]).map(i=>typeof i.text=="string"?i.text:"").join("");return{id:`${Date.now()}`,model:r.modelVersion??"gemini",content:n,usage:{promptTokens:r.usageMetadata?.promptTokenCount??0,completionTokens:r.usageMetadata?.candidatesTokenCount??0,totalTokens:r.usageMetadata?.totalTokenCount??0},stopReason:e?.finishReason??"",stopSequence:null,created:Date.now()}}function YS(r,e,t,n,i,o={}){return async function(a){if(le.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let l=Uo(a)+Uo(i),c=Date.now(),u=n1({provider:n.name,endpoint:n.endpoint,model:t.name,systemPrompt:i,prompt:a,modelOptions:o});M.logMessage(`[AI Request ${u}] Started ${n.name}/${t.name}`),Number.isFinite(t.maxTokens)&&t.maxTokens>0&&l>t.maxTokens&&M.logMessage(`[AI Request ${u}] Estimated prompt size is ${l} tokens, above the configured ${t.maxTokens} token context. Sending anyway; the provider will enforce the exact limit.`);try{let d=GS(r),f=Wv(n),p=async w=>f==="anthropic"?nhe(await ohe(e,t,n,i,w,a,d)):f==="gemini"?ahe(await she(e,t,n,i,w,a,d)):rhe(await ihe(e,t,n,i,w,a,d)),m=QO(t,o),v=wg(m);v.length===0&&wg(o).length>0&&M.logMessage(`[AI Request ${u}] ${t.name} uses fixed sampling; not sending ${jS(wg(o))}.`);let g;try{g=await p(m)}catch(w){let k=w.message??String(w);if(!XO(k,v))throw w;let C=jS(v);M.logMessage(`[AI Request ${u}] ${n.name} rejected ${C}; retrying without sampling parameters.`),new Qx.Notice(`${t.name} doesn't accept the ${C} setting${v.length>1?"s":""}, so QuickAdd retried without ${v.length>1?"them":"it"}. You can remove ${v.length>1?"them":"it"} from this command's advanced settings.`),g=await p(HS(m))}let y=Date.now()-c;return Kx(u,{status:"success",durationMs:y,usage:g.usage}),M.logMessage(`[AI Request ${u}] Success in ${y}ms`),g}catch(d){let f=d.message??String(d),p=Date.now()-c;Kx(u,{status:"error",durationMs:p,errorMessage:f}),M.logMessage(`[AI Request ${u}] Failed in ${p}ms: ${f}`);let m=Bx(d)==="input_context"?" The prompt likely exceeds the model's context window \u2014 shorten it, choose a model with a larger context, or use the chunked AI prompt API.":"",v=new Error(`Error while making request to ${n.name}: ${f}${m}`,{cause:d});throw lt(v),v}}}async function w5(r,e,t,n,i,o){if(r==="anthropic")return Cg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":e,"anthropic-version":"2023-06-01"},body:JSON.stringify(i)},t.name,o);if(r==="gemini"){let s=`${t.endpoint}/v1beta/models/${encodeURIComponent(n.name)}:generateContent`;return Cg({url:s,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":e},body:JSON.stringify(i)},t.name,o)}return Cg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(i)},t.name,o)}async function t1(r,e,t,n,i,o){if(le.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let s=Wv(n),a={...i,modelParams:QO(t,i.modelParams??{})},l=wg(a.modelParams??{}),c=JO(s,t.name,a,e1(t)),u=i.messages.find(m=>m.role==="system"),d=[...i.messages].reverse().find(m=>m.role==="user"),f=Date.now(),p=n1({provider:n.name,endpoint:n.endpoint,model:t.name,systemPrompt:u&&u.role==="system"?u.content:"",prompt:d&&d.role==="user"?d.content:"[tool-calling turn]",modelOptions:i.modelParams??{}});try{let m;try{m=await w5(s,e,n,t,c,o)}catch(y){let w=y.message??String(y);if(!XO(w,l))throw y;let k=jS(l);M.logMessage(`[AI Chat ${p}] ${n.name} rejected ${k}; retrying without sampling parameters.`),new Qx.Notice(`${t.name} doesn't accept the ${k} setting${l.length>1?"s":""}, so QuickAdd retried without ${l.length>1?"them":"it"}.`);let C=JO(s,t.name,{...a,modelParams:HS(a.modelParams??{})},e1(t));m=await w5(s,e,n,t,C,o)}let v=y5(s,m),g=Date.now()-f;return Kx(p,{status:"success",durationMs:g,usage:v.usage}),M.logMessage(`[AI Chat ${p}] Success in ${g}ms`),{id:m.id??`${Date.now()}`,model:t.name,content:v.content,usage:v.usage,stopReason:v.rawStopReason,stopSequence:null,created:Date.now(),toolCalls:v.toolCalls,normalizedStopReason:v.normalizedStopReason,providerRaw:v.providerRaw}}catch(m){let v=m.message??String(m),g=Date.now()-f;Kx(p,{status:"error",durationMs:g,errorMessage:v});let y=new Error(`Error while making request to ${n.name}: ${v}`,{cause:m});throw lt(y),y}}var Qx,r1=b(()=>{Qx=require("obsidian");g5();Pt();KS();ZO();Cr();ts();b5();Me();Px();Vx()});function xg(r){if(r){let e=new x5.Notice(C5("starting",""),1e6);return{setMessage:(t,n)=>{e.setMessage(C5(t,n))},hide:()=>e.hide()}}return{setMessage:()=>{},hide:()=>{}}}var x5,C5,i1=b(()=>{x5=require("obsidian"),C5=(r,e)=>`${r==="dead"?"AI request failed.":`Assistant is ${r}.`}${e?`
${e}`:""}`});function a1(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function n1(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return ra.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),A5(),e}function Kx(r,e){let t=ra.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,A5())}function _5(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:ra.slice(-e).map(a1).reverse()}function A5(){if(ra.length<=E5)return;let r=ra.length-E5;for(;r>0;){let e=ra.findIndex(t=>t.status!=="pending");if(e===-1)break;ra.splice(e,1),r-=1}}function k5(r){let e=ra.find(t=>t.id===r);return e?a1(e):null}function S5(){let r=ra[ra.length-1];return r?a1(r):null}function D5(){ra.splice(0,ra.length)}async function lhe(r,e,t){if(typeof r!="function")throw new TypeError("Callback must be a function.");if(!(e instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof t!="number"||t<=0)throw new TypeError("Interval must be a positive number.");let n=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),await sleep(t)}function che(r){return r instanceof Error?r:new Error(String(r))}async function uhe(r,e,t,n=!0,i){let o;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{let c=t.map(u=>u.basename);if(i)o=await i.suggester(c,t,"Select a prompt template");else if(n)o=await Lr.Suggest(r,c,t);else throw new xe("This AI command asks which prompt template to use, but this run is non-interactive. Enable a specific prompt template in the command, or re-run with the ui flag.")}Ri(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);Ri(a instanceof T5.TFile,`${s} is not a file`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function I5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=xg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=ns(r,u),[f,p]=await uhe(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(p),v=["prompting",`Using prompt template "${f}".`];n.setMessage(v[0],v[1]);let y=YS(r,i,o,s,c,e.modelOptions)(m),k=(await l1(y,100,x=>{n.setMessage(v[0],`${v[1]} (${(x/1e3).toFixed(2)}s)`)},x=>{n.setMessage("finished",`Took ${(x/1e3).toFixed(2)}s.`)})).content,C=("> "+k).replace(/\n/g,`
> `),E={[a]:k,[`${a}-quoted`]:C};return window.setTimeout(()=>n.hide(),5e3),E}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),It(i)?new Dt("Input cancelled by user"):i}}async function l1(r,e,t,n){let i=Date.now();return await lhe(()=>t(Date.now()-i),r,e),n(Date.now()-i),await r}async function P5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=xg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,prompt:c,modelOptions:u}=e;n.setMessage("waiting","QuickAdd is formatting the prompt template.");let d=await t(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);let m=YS(r,i,o,s,l,u)(d),g=(await l1(m,100,k=>{n.setMessage(f[0],`${f[1]} (${(k/1e3).toFixed(2)}s)`)},k=>{n.setMessage("finished",`Took ${(k/1e3).toFixed(2)}s.`)})).content,y=("> "+g).replace(/\n/g,`
> `),w={[a]:g,[`${a}-quoted`]:y};return window.setTimeout(()=>n.hide(),5e3),w}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}function phe(){return Array.from(new Set([s1,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>Oy(s1,r))])).filter(Boolean)}function M5(r){if(r.length<=1)return null;let e=Math.floor(r.length/2),t=[`
`,`
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(let a of t){let l=r.lastIndexOf(a,e),c=r.indexOf(a,e),u=[l,c].filter(d=>d>0);for(let d of u){let f=d+a.length;if(f<=0||f>=r.length)continue;let p=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=e,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function fhe(r){let e=new RegExp(Kd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function mhe(r){return Ns.test(r)||wu.test(r)||gl.test(r)||mc.test(r)}function hhe(r){return F5.some(e=>r.includes(e))}function ghe(r){return F5.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function R5(r){if(r>QS)throw new Error(`QuickAdd would split this chunked AI request into more than ${QS} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function vhe(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Uo(s)<=n?null:M5(s);if(!l){t.push(s),o+=1,R5(o);continue}i.push(l[1],l[0])}}function yhe(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function whe(r,e){if(typeof e=="string"){let s=r.split(e);return{chunks:s,separators:new Array(Math.max(0,s.length-1)).fill(e)}}if(yhe(e)>0||bhe.test(e.source))return{chunks:r.split(e),separators:null};let t=new RegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function Che(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];vhe(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Uo(l.text)+Math.max(1,Uo(l.joiner));s!==""&&a+c>=t&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function xhe(r,e){let t=Math.max(1,Math.floor(r));if(e!==void 0&&Number.isFinite(e)&&e>0){let n=Math.floor(e);return{budget:Math.min(t,n),clamped:n>t}}return{budget:t,clamped:!1}}async function $5(r,e,t){if(le.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=xg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:u,modelOptions:d}=e;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let f=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=whe(u,f),v=await t(c,{chunk:s1});if(!(fhe(c)||mhe(c)&&hhe(v)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,w=xY(y),k=ghe(v),C=Uo(l)+Uo(k);if(C>=y)throw new Error(`The estimated prompt overhead (${C} tokens) exceeds the model's entire context window (${y} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:E,clamped:x}=xhe(w-C,e.maxChunkTokens);x&&M.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${E} estimated tokens per chunk instead.`);let D=e.shouldMerge??!0,P=Che(p,m,E,D);R5(P.length);let H=YS(r,i,o,s,l,d),U=["prompting",`${P.length} prompts being sent.`];n.setMessage(U[0],U[1]);let oe=new o1(5,1e3*30),ce=!1,O=0,G=Promise.resolve(),V=ge=>{let be=G.then(()=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:ge})});return G=be.then(()=>{},()=>{}),be},F=async(ge,be=0)=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");let Be;try{Be=await V(ge)}catch(Se){throw ce=!0,Se}try{return[(await oe.add(()=>{if(ce)throw new Error("Chunked prompt stopped after an earlier failure.");if(O+=1,O>QS)throw new Error(`Chunked AI request exceeded the safety limit of ${QS} provider requests.`);return H(Be)})).content]}catch(Se){let ut=M5(ge);if(be>=dhe||!ut||!t4(Se))throw ce=!0,Se;n.setMessage("prompting","Provider rejected a prompt for context length. Retrying with smaller chunks.");let[Ne,Qe]=ut,Ze=await F(Ne,be+1),ye=await F(Qe,be+1);return[...Ze,...ye]}},Z=Promise.all(P.map(ge=>F(ge))),K=(await l1(Z,100,ge=>{n.setMessage(U[0],`${U[1]} (${(ge/1e3).toFixed(2)}s)`)},ge=>{n.setMessage("finished",`Took ${(ge/1e3).toFixed(2)}s.`)})).flat().join(e.resultJoiner),se=("> "+K).replace(/\n/g,`
> `),pe={[a]:K,[`${a}-quoted`]:se};return window.setTimeout(()=>n.hide(),5e3),pe}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var T5,E5,ra,o1,dhe,QS,s1,F5,bhe,KS=b(()=>{T5=require("obsidian");Hr();xo();Hc();Pt();qt();Gx();Cr();r1();Vx();i1();Px();Me();_t();iA();E5=25,ra=[];o1=class{constructor(e,t){this.maxRequests=e;this.intervalMs=t;this.queue=[];this.startTimes=[]}add(e){return new Promise((t,n)=>{this.queue.push(async()=>{try{t(await e())}catch(i){n(che(i))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;let e=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i<this.intervalMs),this.startTimes.length>=this.maxRequests){let i=this.startTimes[0],o=Math.max(0,this.intervalMs-(e-i));window.setTimeout(()=>this.schedule(),o+1);return}let t=this.queue.shift();if(!t)return;this.startTimes.push(e);let n=t();window.setTimeout(()=>this.schedule(),this.intervalMs),this.schedule()}},dhe=12,QS=500,s1="quickadd_chunk_probe_123456789";F5=phe();bhe=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});function O5(r){return r.normalize("NFKD").toLowerCase()}var Ehe,tf,c1=b(()=>{Ehe=0;tf=class{constructor(e,t){this.options=t;this.instanceId=++Ehe;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=document.createElement("div"),this.rootEl.className="qa-searchable-multi-select";let n=document.createElement("div");n.className="search-input-container qa-searchable-multi-select__search-container",this.searchInputEl=document.createElement("input"),this.searchInputEl.className="qa-searchable-multi-select__search",this.searchInputEl.type="search",this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.placeholder=t.searchPlaceholder??"Search options...",this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),n.appendChild(this.searchInputEl),this.summaryEl=document.createElement("div"),this.summaryEl.className="qa-searchable-multi-select__summary",this.summaryEl.setAttribute("aria-live","polite"),this.listEl=document.createElement("div"),this.listEl.className="qa-searchable-multi-select__list",this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),this.rootEl.append(n,this.summaryEl,this.listEl),e.appendChild(this.rootEl),this.searchInputEl.addEventListener("input",()=>{this.query=this.searchInputEl.value,this.renderList()}),this.searchInputEl.addEventListener("keydown",i=>{if(i.key==="ArrowDown"){i.preventDefault(),this.renderedRows[0]?.input.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}i.key==="Escape"&&this.query&&(i.preventDefault(),i.stopPropagation(),this.query="",this.searchInputEl.value="",this.renderList())}),this.setItems(t.items)}setItems(e){this.indexedItems=e.map((t,n)=>({item:t,index:n,searchableText:O5(`${t.label} ${t.searchText??""}`)})),this.searchInputEl.disabled=e.length===0,this.renderList()}focusSearchOnOpen(){document.body.classList.contains("is-mobile")||this.searchInputEl.focus()}refreshSelection(){for(let{item:e,input:t}of this.renderedRows)t.checked=this.options.isSelected(e),t.closest("label")?.classList.toggle("is-selected",t.checked);this.updateSummary()}getMatchingItems(){let e=O5(this.query.trim()).split(/\s+/).filter(Boolean);return e.length===0?this.indexedItems:this.indexedItems.filter(({searchableText:t})=>e.every(n=>t.includes(n)))}getVisibleItems(e){if(e.length<=200)return e;let t=[],n=[];for(let i of e)(this.options.isSelected(i.item)?t:n).push(i);return[...t,...n].slice(0,200)}renderList(){this.listEl.replaceChildren(),this.renderedRows=[];let e=this.getMatchingItems(),t=this.getVisibleItems(e);if(t.length===0){let n=document.createElement("div");n.className="qa-searchable-multi-select__empty",n.setAttribute("role","status"),n.textContent=this.indexedItems.length?`No options match \u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(let n of t)this.renderRow(n);if(e.length>t.length){let n=document.createElement("div");n.className="qa-searchable-multi-select__limit",n.setAttribute("role","status"),n.textContent=`Showing ${t.length} of ${e.length} options. Refine your search to see the rest.`,this.listEl.appendChild(n)}this.updateSummary(e.length)}renderRow(e){let{item:t,index:n}=e,i=document.createElement("label");i.className="qa-searchable-multi-select__option";let o=document.createElement("input");o.type="checkbox",o.name=`qa-multi-select-${this.instanceId}`,o.id=`qa-multi-select-${this.instanceId}-${n}`,o.checked=this.options.isSelected(t);let s=document.createElement("span");s.className="qa-searchable-multi-select__option-label",s.textContent=t.label,i.htmlFor=o.id,i.classList.toggle("is-selected",o.checked),i.append(s,o),o.addEventListener("change",()=>{this.options.onToggle(t,o.checked),this.refreshSelection()}),o.addEventListener("keydown",a=>{this.handleOptionKeydown(a,o)}),this.listEl.appendChild(i),this.renderedRows.push({item:t,input:o})}handleOptionKeydown(e,t){let n=this.renderedRows.findIndex(i=>i.input===t);if(e.key==="ArrowDown"){e.preventDefault(),this.renderedRows[n+1]?.input.focus();return}if(e.key==="ArrowUp"){e.preventDefault(),n===0?this.searchInputEl.focus():this.renderedRows[n-1]?.input.focus();return}if(e.key==="Home"){e.preventDefault(),this.renderedRows[0]?.input.focus();return}if(e.key==="End"){e.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),t.checked=!t.checked,t.dispatchEvent(new Event("change",{bubbles:!0}));return}e.key==="/"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),this.searchInputEl.focus())}updateSummary(e=this.getMatchingItems().length){let n=`${this.options.getSelectedCount?.()??new Set(this.indexedItems.filter(({item:i})=>this.options.isSelected(i)).map(({item:i})=>i.key)).size} selected`;if(!this.query.trim()){this.summaryEl.textContent=`${n} \xB7 ${this.indexedItems.length} options`;return}this.summaryEl.textContent=`${n} \xB7 ${e} matches`}}});var cd,rf,N5=b(()=>{cd=require("obsidian");Mo();Hr();c1();rf=class r extends cd.Modal{constructor(t,n,i,o={}){super(t);this.didSubmit=!1;this.skipped=!1;this.selected=new Set;this.customValues=[];this.draft="";this.items=i,this.displayItems=n.length===i.length?n:i,this.opts=o,this.seedPreselection(o.preselected),this.waitForClose=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.render(),this.open(),this.picker.focusSearchOnOpen()}static Suggest(t,n,i,o={}){return new r(t,n,i,o).waitForClose}seedPreselection(t){if(t?.length)for(let n of t){let i=n?.trim();i&&(!this.items.includes(i)&&!this.customValues.includes(i)&&this.customValues.push(i),this.selected.add(i))}}render(){this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","qaMultiSuggester"),this.titleEl.setText(this.opts.placeholder??"Select one or more");let{contentEl:t}=this;t.empty();let n=t.createDiv({cls:"qa-multi-list"});this.picker=new tf(n,{items:this.getSearchableItems(),isSelected:({value:o})=>this.selected.has(o),onToggle:({value:o},s)=>{s?this.selected.add(o):this.selected.delete(o)},getSelectedCount:()=>this.selected.size}),this.opts.allowCustomValue&&new cd.Setting(t).setName("Add a custom value").addText(s=>{s.setPlaceholder("Not in the list\u2026").setValue(this.draft).onChange(a=>this.draft=a),s.inputEl.addClass("qa-multi-custom-input"),s.inputEl.addEventListener("keydown",a=>{a.key==="Enter"&&(a.preventDefault(),this.commitDraft())})}).addButton(s=>s.setButtonText("Add").onClick(()=>this.commitDraft())).settingEl.addClass("qa-multi-custom");let i=new cd.Setting(t);i.settingEl.addClass("qa-multi-actions"),i.addButton(o=>o.setButtonText("Done").setCta().onClick(()=>this.submit())),i.addButton(o=>o.setButtonText("Cancel").onClick(()=>this.close())),this.opts.skippable&&i.addButton(o=>o.setButtonText("Skip").setTooltip("Leave empty").onClick(()=>{this.skipped=!0,this.didSubmit=!0,this.close()}))}getSearchableItems(){return[...this.items.map((t,n)=>({key:t,value:t,label:mn(this.displayItems[n]??t),searchText:t})),...this.customValues.map(t=>({key:t,value:t,label:t}))]}commitDraft(){let t=this.draft.trim();return t?(this.items.includes(t)||this.customValues.includes(t))&&this.selected.has(t)?(new cd.Notice(`"${t}" is already added.`),!1):(!this.items.includes(t)&&!this.customValues.includes(t)&&this.customValues.push(t),this.selected.add(t),this.draft="",this.render(),this.focusCustomInput(),!0):(new cd.Notice("Enter a value to add."),!1)}focusCustomInput(){this.contentEl.querySelector(".qa-multi-custom-input")?.focus()}submit(){if(this.opts.allowCustomValue&&this.draft.trim()){let t=this.draft.trim();!this.items.includes(t)&&!this.customValues.includes(t)&&this.customValues.push(t),this.selected.add(t),this.draft=""}this.didSubmit=!0,this.close()}collectResult(){let t=[];for(let n of this.items)this.selected.has(n)&&t.push(n);for(let n of this.customValues)this.selected.has(n)&&t.push(n);return t}onClose(){super.onClose(),this.didSubmit?this.resolvePromise(this.skipped?[]:this.collectResult()):this.rejectPromise(rn())}}});var ud,The,_he,Ahe,B5,u1,Xx,d1,L5,XS,p1=b(()=>{ud=r=>r.toString().padStart(2,"0"),The=r=>{if(typeof r=="number"&&r>=0&&r<=6)return r;let t=window.moment?.localeData?.()?.firstDayOfWeek?.();return typeof t=="number"&&t>=0&&t<=6?t:0},_he=r=>{let e=new Intl.DateTimeFormat(void 0,{weekday:"short"}),t=new Date(2021,7,1),n=Array.from({length:7},(i,o)=>{let s=new Date(t.getFullYear(),t.getMonth(),t.getDate()+o);return e.format(s)});return n.slice(r).concat(n.slice(0,r))},Ahe=(r,e)=>new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(r,e,1)),B5=(r,e,t)=>`${r}-${ud(e+1)}-${ud(t)}`,u1=r=>B5(r.getFullYear(),r.getMonth(),r.getDate()),Xx=r=>{if(!r)return null;let e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(r);if(e){let[,n,i,o]=e;return new Date(Number.parseInt(n,10),Number.parseInt(i,10)-1,Number.parseInt(o,10))}let t=new Date(r);return Number.isNaN(t.getTime())?null:t},d1=(r,e,t,n)=>{let i=B5(r,e,t);return n?`${i}T${ud(n.hour)}:${ud(n.minute)}:00`:i},L5=r=>{if(!r)return null;let e=/[T ](\d{2}):(\d{2})/.exec(r);if(!e)return null;let t=Number.parseInt(e[1],10),n=Number.parseInt(e[2],10);return Number.isNaN(t)||Number.isNaN(n)||t<0||t>23||n<0||n>59?null:{hour:t,minute:n}},XS=r=>{let e=The(r.weekStartsOn),t=_he(e),n=Xx(r.initialIso)??new Date,i=n.getFullYear(),o=n.getMonth(),s=r.initialIso,a=r.withTime===!0,l=a?L5(r.initialIso)??{hour:0,minute:0}:null,c=r.container.createDiv({cls:"qa-date-picker"}),u=c.createDiv({cls:"qa-date-picker__header"}),d=u.createEl("button",{cls:"qa-date-picker__nav",text:"\u2039"});d.type="button",d.setAttr("aria-label","Previous month");let f=u.createDiv({cls:"qa-date-picker__label"}),p=u.createEl("button",{cls:"qa-date-picker__nav",text:"\u203A"});p.type="button",p.setAttr("aria-label","Next month");let m=c.createDiv({cls:"qa-date-picker__weekdays"});t.forEach(P=>{let H=m.createDiv({cls:"qa-date-picker__weekday"});H.textContent=P});let v=c.createDiv({cls:"qa-date-picker__grid"}),g=c.createDiv({cls:"qa-date-picker__actions"}),y=g.createEl("button",{cls:"qa-date-picker__action",text:"Today"});y.type="button";let w=g.createEl("button",{cls:"qa-date-picker__action",text:"Clear"});w.type="button";let k;if(a){let P=c.createDiv({cls:"qa-date-picker__time"});P.createEl("label",{cls:"qa-date-picker__time-label",text:"Time"}),k=P.createEl("input",{cls:"qa-date-picker__time-input"}),k.type="time",l&&(k.value=`${ud(l.hour)}:${ud(l.minute)}`)}let C=P=>{o+=P,o>11?(o=0,i+=1):o<0&&(o=11,i-=1),D()},E=(P,H)=>{s=P,r.onSelect(P,H),D()},x=P=>{s=void 0,r.onSelect(null,P),D()};d.addEventListener("click",()=>C(-1)),p.addEventListener("click",()=>C(1)),y.addEventListener("click",()=>{let P=new Date,H=d1(P.getFullYear(),P.getMonth(),P.getDate(),l);i=P.getFullYear(),o=P.getMonth(),E(H,"action")}),w.addEventListener("click",()=>x("action")),k&&k.addEventListener("change",()=>{if(k.value.trim()==="")l={hour:0,minute:0};else{let[P,H]=k.value.split(":").map(U=>Number.parseInt(U,10));if(Number.isNaN(P)||Number.isNaN(H))return;l={hour:P,minute:H}}if(s){let P=Xx(s);P&&E(d1(P.getFullYear(),P.getMonth(),P.getDate(),l),"picker")}});let D=()=>{f.textContent=Ahe(i,o),v.empty();let H=(new Date(i,o,1).getDay()-e+7)%7,U=new Date(i,o,1-H),oe=u1(new Date),ce=s?Xx(s):null,O=ce?u1(ce):void 0,G=new Intl.DateTimeFormat(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"});for(let V=0;V<42;V+=1){let F=new Date(U);F.setDate(U.getDate()+V);let Z=u1(F),z=F.getMonth()!==o,Y=Z===oe,K=O&&Z===O,se=v.createEl("button",{cls:"qa-date-picker__day",text:String(F.getDate())});se.type="button",se.setAttr("aria-label",G.format(F)),z&&se.addClass("is-outside"),Y&&se.addClass("is-today"),K&&(se.addClass("is-selected"),se.setAttr("aria-pressed","true")),se.addEventListener("click",()=>{let pe=d1(F.getFullYear(),F.getMonth(),F.getDate(),l);E(pe,"picker")})}};return D(),{setSelectedIso:(P,{updateView:H}={})=>{if(s=P,P&&H!==!1){let U=Xx(P);U&&(i=U.getFullYear(),o=U.getMonth())}if(a&&P){let U=L5(P);U&&(l=U,k&&(k.value=`${ud(U.hour)}:${ud(U.minute)}`))}D()},setViewFromIso:P=>{let H=Xx(P);H&&(i=H.getFullYear(),o=H.getMonth(),D())},destroy:()=>{c.remove()}}}});function nf(r,e,t=Sl,n){if(!r||!r.trim())return{isValid:!1,error:"Empty input"};try{let i=n??le.getState().dateAliases,o=Hv(r,i),s=t.parseDate(o);if(s?.moment?.isValid()){let a=s.moment.toISOString(),l=e?s.moment.format(e):s.moment.format("YYYY-MM-DD");return{isValid:!0,isoString:a,formatted:l}}else return{isValid:!1,error:"Unable to parse date"}}catch(i){return{isValid:!1,error:`Parse error: ${i instanceof Error?i.message:"Unknown error"}`}}}function Ul(r,e){if(!window.moment)return null;try{let t=window.moment(r);if(t.isValid())return t.format(e)}catch{}return null}var Zx=b(()=>{hh();Pt();Gd()});var Tg,Eg,of,f1=b(()=>{Tg=require("obsidian");$a();p1();Zx();Pt();Gd();Eg=class Eg extends Dr{constructor(t,n,i,o,s,a,l){super(t,n,i,o??"",void 0,void 0,a);this.isOpen=!0;this.containerEl.addClass("qaDatePrompt"),this.withTime=l===!0,this.dateFormat=s||(this.withTime?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"),this.defaultValue=o,this.currentInput=this.inputComponent?.inputEl?.value??o??"",this.mountDatePicker(),this.updatePreviewDebounced=(0,Tg.debounce)(this.updatePreview.bind(this),250,!0),this.updatePreview()}supportsPeek(){return!1}static Prompt(t,n,i,o,s,a,l){return new Eg(t,n,i,o,s,a,l).waitForClose}createInputField(t,n,i){t.addClass("qa-date-input");let o=new Tg.TextComponent(t);return o.inputEl.addClass("qa-vdate-input"),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>{this.lastPickerDisplayValue=void 0,this.onInputChanged(s),this.currentInput=s,this.updatePreviewDebounced()}).inputEl.addEventListener("keydown",this.submitEnterCallback),this.currentInput=i??"",this.pickerHostEl=t.createDiv({cls:"qa-date-picker-container"}),this.createPreviewElement(t),o}mountDatePicker(){this.datePicker=XS({container:this.pickerHostEl,initialIso:this.selectedIso,withTime:this.withTime,onSelect:t=>{t?this.applyPickerSelection(t):this.clearPickerSelection()}})}createPreviewElement(t){let n=t.createDiv("vdate-preview-container");n.createEl("div",{text:"Preview:",cls:"vdate-preview-label"}),this.previewEl=n.createEl("div",{cls:"vdate-preview-text"}),this.previewEl.textContent=Eg.PREVIEW_PLACEHOLDER;let i=jv(le.getState().dateAliases);if(i.length>0){let o=n.createEl("details",{cls:"vdate-alias-details"});o.createEl("summary",{text:`Aliases (${i.length})`}).addClass("vdate-alias-summary");let a=o.createEl("div",{cls:"vdate-alias-list"});a.textContent=$T(le.getState().dateAliases)}}updatePreview(){if(!this.isOpen)return;let t=this.currentInput.trim();if(!t&&this.defaultValue&&!this.isOptionalPrompt){this.renderPreviewFromInput(this.defaultValue);return}if(!t){this.selectedIso=void 0,this.lastPickerDisplayValue=void 0,this.syncPickerSelection(),this.setPreviewText(this.isOptionalPrompt?"Will be left empty":Eg.PREVIEW_PLACEHOLDER,!1);return}if(t.startsWith("@date:")){let n=t.slice(6).trim();if(n){this.selectedIso=n,this.lastPickerDisplayValue=void 0,this.syncPickerSelection(n),this.renderPreviewFromIso(n);return}}if(this.selectedIso&&this.lastPickerDisplayValue&&t===this.lastPickerDisplayValue){this.syncPickerSelection(this.selectedIso,!1),this.renderPreviewFromIso(this.selectedIso);return}this.renderPreviewFromInput(t)}formatIsoForInput(t){let n=Ul(t,this.dateFormat);return n||(t.length>=10?t.slice(0,10):t)}syncPickerSelection(t,n=!0){this.datePicker?.setSelectedIso(t,{updateView:n})}applyPickerSelection(t){let n=this.formatIsoForInput(t);this.selectedIso=t,this.lastPickerDisplayValue=n,this.inputComponent?.inputEl&&(this.inputComponent.inputEl.value=n),this.onInputChanged(n),this.currentInput=n,this.syncPickerSelection(t),this.renderPreviewFromIso(t)}clearPickerSelection(){this.inputComponent?.inputEl&&(this.inputComponent.inputEl.value=""),this.onInputChanged(""),this.currentInput="",this.selectedIso=void 0,this.lastPickerDisplayValue=void 0,this.syncPickerSelection(),this.updatePreview()}renderPreviewFromIso(t){this.setPreviewText(this.formatIsoForInput(t),!1)}renderPreviewFromInput(t){let n=nf(t,this.dateFormat);if(n.isValid&&n.isoString){this.selectedIso=n.isoString,this.lastPickerDisplayValue=void 0,this.syncPickerSelection(n.isoString);let i=n.formatted??this.formatIsoForInput(n.isoString);this.setPreviewText(i,!1)}else{this.selectedIso=void 0,this.lastPickerDisplayValue=void 0,this.syncPickerSelection();let i=n.error||"Unable to parse date";this.setPreviewText(i,!0)}}setPreviewText(t,n){this.previewEl.textContent=t,this.previewEl.toggleClass("is-error",n)}onOpen(){super.onOpen()}transformInputOnSubmit(t){let n=t.trim();if(n.startsWith("@date:"))return n;if(this.selectedIso&&this.lastPickerDisplayValue&&n===this.lastPickerDisplayValue)return`@date:${this.selectedIso}`;if(!n&&this.defaultValue&&!this.isOptionalPrompt){let i=nf(this.defaultValue,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`}if(n){let i=nf(n,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`;new Tg.Notice(`QuickAdd: "${n}" could not be parsed as a date; using it as-is.`)}return t}onClose(){this.isOpen=!1,this.updatePreviewDebounced.cancel(),!this.input.trim()&&this.defaultValue&&!this.isOptionalPrompt&&(this.input=this.defaultValue),super.onClose()}};Eg.PREVIEW_PLACEHOLDER="Preview will appear here";of=Eg});function khe(r,e,t,n={}){let i=n.tab??" ";if(e===t){let d=e+i.length;return{regionStart:e,regionEnd:e,replacement:i,selectionStart:d,selectionEnd:d}}let o=e===0?0:r.lastIndexOf(`
`,e-1)+1,a=r.slice(o,t).split(`
`),l=a.length-1,c=0,u=a.map((d,f)=>f===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(`
`),selectionStart:e+i.length,selectionEnd:t+c}}function She(r,e){r.setSelectionRange(e.regionStart,e.regionEnd);let t=r.ownerDocument,n=!1;try{n=typeof t.execCommand=="function"&&t.execCommand("insertText",!1,e.replacement)}catch{n=!1}if(!n){let i=r.value;r.value=i.slice(0,e.regionStart)+e.replacement+i.slice(e.regionEnd),r.setSelectionRange(e.selectionStart,e.selectionEnd),r.dispatchEvent(new Event("input",{bubbles:!0}));return}r.setSelectionRange(e.selectionStart,e.selectionEnd)}function V5(r,e={}){let t=i=>{if(i.key!=="Tab"||i.shiftKey||i.ctrlKey||i.metaKey||i.altKey||i.isComposing||i.defaultPrevented)return;i.preventDefault();let o=r.selectionStart??r.value.length,s=r.selectionEnd??o;She(r,khe(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var U5=b(()=>{});var _g,dd,m1=b(()=>{_g=require("obsidian");jP();GP();YP();KP();QP();U5();$_();Hr();oF();Cy();sF();dd=class r extends _g.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.supportsPeek()&&N_(t)){t.preventDefault(),this.peek.peek();return}if(this.isOptionalPrompt&&O_(t)){t.preventDefault(),this.skip();return}(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new Sm({kind:"multi",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.peek=new Im({app:t,title:this.header,containerEl:this.containerEl,scope:this.scope,getField:()=>this.inputComponent?.inputEl,getValue:()=>this.input,setValue:c=>{this.input=c},markDraftChanged:()=>this.draftHandler.markChanged(),persistDraft:()=>this.persistDraft(),close:()=>this.close()}),this.display(),this.open(),this.attachSuggesters()}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaWideInputPrompt"),L_(this.containerEl),this.contentEl.empty(),this.titleEl.textContent=this.header,P_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}createInputField(t,n,i){let o=new _g.TextAreaComponent(t);return o.inputEl.classList.add("wideInputPromptInputEl"),o.inputEl.setAttribute("dir","auto"),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.disposeIndent=V5(o.inputEl),this.options?.imagePaste&&(this.imagePasteHandle=Dm(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new _g.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}get isOptionalPrompt(){return this.options?.optional===!0}supportsPeek(){return this.options?.allowPeek===!0}createButtonBar(t){let n=t.createDiv({cls:"qa-prompt-actions"}),i=n.createDiv({cls:"qa-prompt-actions-primary"});if(this.createButton(i,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(i,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let o=this.createButton(i,"Skip",this.skipClickCallback);o.setTooltip("Leave this field empty"),o.buttonEl.setAttribute("aria-label","Skip and leave empty")}if(this.supportsPeek()){let o=n.createDiv({cls:"qa-prompt-actions-secondary"});B_(this.createButton(o,"Peek at note",()=>this.peek.peek()))}}submit(){if(!(this.didSubmit||this.didClose)){if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}this.input=this.inputComponent?.inputEl?.value??this.input,this.didSubmit=!0,this.close()}}skip(){this.didSubmit||(this.input="",this.didSubmit=!0,this.close())}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise(rn())}onInputChanged(t){this.draftHandler.markChanged(),this.input=t}syncInputFromEl(){this.inputComponent?.inputEl&&(this.input=this.inputComponent.inputEl.value)}persistDraft(){this.draftHandler.persist(this.input,this.didSubmit)}attachSuggesters(){this.fileSuggester=new _m(this.app,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Am(this.app,this.inputComponent.inputEl)}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback),this.disposeIndent?.(),this.imagePasteHandle?.detach()}onOpen(){super.onOpen(),this.peek.onHostOpened(),I_(this.inputComponent.inputEl,this.options)}onClose(){this.didClose=!0,this.didSubmit||this.syncInputFromEl(),this.persistDraft(),this.peek.onHostClosed(),this.resolveInput(),this.removeInputListener(),this.fileSuggester?.destroy(),this.tagSuggester?.destroy(),super.onClose()}}});var Jx,q5=b(()=>{$a();xl();Jx=class r extends Dr{supportsPeek(){return!1}static Prompt(e,t,n,i,o,s){return new r(e,t,n,i,void 0,o,s).waitForClose}static PromptWithContext(e,t,n,i,o,s,a){return new r(e,t,n,i,o,s,a).waitForClose}createInputField(e,t,n){let i=super.createInputField(e,t,n);i.inputEl.type="number",i.inputEl.inputMode="decimal";let o=this.options?.numeric;return o?.min!==void 0&&(i.inputEl.min=String(o.min)),o?.max!==void 0&&(i.inputEl.max=String(o.max)),i.inputEl.setAttr("step",o?.step!==void 0?String(o.step):"any"),i}transformInputOnSubmit(e){return this.options?.numeric?e===""&&this.isOptionalPrompt?"":Na(e,this.options.numeric):e}}});var h1,eE,W5=b(()=>{$a();xl();h1={min:0,max:100,step:1},eE=class r extends Dr{supportsPeek(){return!1}static Prompt(e,t,n,i,o,s){return new r(e,t,n,i,void 0,o,s).waitForClose}static PromptWithContext(e,t,n,i,o,s,a){return new r(e,t,n,i,o,s,a).waitForClose}createInputField(e,t,n){let i=this.options?.slider??h1,o=this.isOptionalPrompt&&!n,s=By(n,i);this.sliderEl=e.createEl("input"),this.sliderEl.type="range",this.sliderEl.min=String(i.min),this.sliderEl.max=String(i.max),this.sliderEl.step=String(i.step),this.sliderEl.value=s,this.sliderEl.setCssStyles({width:"100%"});let a=super.createInputField(e,void 0,s);return this.numberEl=a.inputEl,this.numberEl.type="number",this.numberEl.inputMode="decimal",this.numberEl.min=String(i.min),this.numberEl.max=String(i.max),this.numberEl.step=String(i.step),o&&(this.numberEl.value=""),this.sliderEl.addEventListener("input",()=>this.syncFromSlider()),this.numberEl.addEventListener("input",()=>this.syncFromNumber()),a}syncFromSlider(){!this.sliderEl||!this.numberEl||(this.numberEl.value=this.sliderEl.value,this.onInputChanged(this.sliderEl.value))}syncFromNumber(){if(!this.sliderEl||!this.numberEl)return;let e=this.numberEl.value;if(e===""&&this.isOptionalPrompt){this.onInputChanged("");return}let t=Na(e,this.options?.slider??h1);t!==""&&(this.sliderEl.value=t),this.onInputChanged(e)}transformInputOnSubmit(e){return e===""&&this.isOptionalPrompt?"":By(e,this.options?.slider??h1)}}});var Ag,z5=b(()=>{m1();$a();q5();W5();wl();Ag=class{factory(e){return e==="multiline"?dd:e==="number"?Jx:e==="slider"?eE:ni().settings.inputPrompt==="multi-line"?dd:Dr}}});function Phe(r){return`\\begin{${r}}
\u261A
\\end{${r}}\u261A`}var Dhe,Ihe,H5,g1=b(()=>{Dhe=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\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","\\lnsim","\\log","\\longleftarrow","\\Longleftarrow","\\longrightarrow","\\Longrightarrow","\\longleftrightarrow","\\Longleftrightarrow","\\longmapsto","\\looparrowleft","\\looparrowright","\\lor","\\lower","\\lozenge","\\Lsh","\\lt","\\ltimes","\\lvert","\\lVert","\\lvertneqq","\\maltese","\\mapsto","\\mathbb","\\mathbf","\\mathbin","\\mathcal","\\mathchoice","\\mathclose","\\mathfrak","\\mathinner","\\mathit","\\mathop","\\mathopen","\\mathord","\\mathpunct","\\mathrel","\\mathring","\\mathrm","\\mathscr","\\mathsf","\\mathstrut","\\mathtt","\\matrix","\\max","\\mbox","\\measuredangle","\\mho","\\mid","\\min","\\mit","\\mod","\\models","\\moveleft","\\moveright","\\mp","\\mskip","\\mspace","\\mu","\\multimap","\\nabla","\\natural","\\ncong","\\ne","\\nearrow","\\neg","\\negthinspace","\\negmedspace","\\negthickspace","\\neq","\\newcommand","\\newenvironment","\\newline","\\nexists","\\ngeq","\\ngeqq","\\ngeqslant","\\ngtr","\\ni","\\nleftarrow","\\nLeftarrow","\\nleftrightarrow","\\nLeftrightarrow","\\nleq","\\nleqq","\\nleqslant","\\nless","\\nmid","\\nobreakspace","\\nolimits","\\normalsize","\\not","\\notag","\\notin","\\nparallel","\\nprec","\\npreceq","\\nrightarrow","\\nRightarrow","\\nshortmid","\\nshortparallel","\\nsim","\\nsubseteq","\\nsubseteqq","\\nsucc","\\nsucceq","\\nsupseteq","\\nsupseteqq","\\ntriangleleft","\\ntrianglelefteq","\\ntriangleright","\\ntrianglerighteq","\\nu","\\nVDash","\\nVdash","\\nvDash","\\nvdash","\\nwarrow","\\odot","\\ominus","\\oplus","\\oslash","\\otimes","\\oint","\\oldstyle","\\omega","\\Omega","\\omicron","\\operatorname","\\over","\\overbrace","\\overleftarrow","\\overrightarrow","\\overleftrightarrow","\\overline","\\overparen","\\overset","\\overwithdelims","\\owns","\\parallel","\\partial","\\perp","\\phantom","\\phi","\\Phi","\\pi","\\Pi","\\pitchfork","\\pm","\\pmatrix","\\pmb","\\pmod","\\pod","\\Pr","\\prec","\\precapprox","\\precnapprox","\\preccurlyeq","\\preceq","\\precneqq","\\precsim","\\precnsim","\\prime","\\prod","\\projlim","\\propto","\\psi","\\Psi","\\quad","\\qquad","\\raise","\\rangle","\\rbrace","\\rbrack","\\rceil","\\Re","\\renewcommand","\\require (non-standard)","\\restriction","\\rfloor","\\rgroup","\\rhd","\\rho","\\right","\\rightarrow","\\Rightarrow","\\rightarrowtail","\\rightharpoondown","\\rightharpoonup","\\rightleftarrows","\\rightleftharpoons","\\rightrightarrows","\\rightsquigarrow","\\rightthreetimes","\\risingdotseq","\\rlap","\\rm","\\rmoustache","\\Rrightarrow","\\Rsh","\\rtimes","\\Rule (non-standard)","\\rvert","\\rVert","\\S","\\scr","\\scriptscriptstyle","\\scriptsize","\\scriptstyle","\\searrow","\\sec","\\setminus","\\sf","\\sharp","\\shortmid","\\shortparallel","\\shoveleft","\\shoveright","\\sideset","\\sigma","\\Sigma","\\sim","\\simeq","\\sin","\\sinh","\\skew","\\small","\\smallfrown","\\smallint","\\smallsetminus","\\smallsmile","\\smash","\\smile","\\space","\\Space (non-standard)","\\spadesuit","\\sphericalangle","\\sqcap","\\sqcup","\\sqrt","\\sqsubset","\\sqsupset","\\sqsubseteq","\\sqsupseteq","\\square","\\stackrel","\\star","\\strut","\\style","\\subset","\\Subset","\\subseteq","\\subsetneq","\\subseteqq","\\subsetneqq","\\substack","\\succ","\\succapprox","\\succnapprox","\\succcurlyeq","\\succeq","\\succneqq","\\succsim","\\succnsim","\\sum","\\sup","\\supset","\\Supset","\\supseteq","\\supsetneq","\\supseteqq","\\supsetneqq","\\surd","\\swarrow","\\tag","\\tan","\\tanh","\\tau","\\tbinom","\\TeX","\\text{\u261A}\u261A","\\textbf{\u261A}\u261A","\\textit{\u261A}\u261A","\\textrm{\u261A}\u261A","\\textsf{\u261A}\u261A","\\texttt{\u261A}\u261A","\\textstyle","\\tfrac{\u261A}{\u261A}\u261A","\\therefore","\\theta","\\Theta","\\thickapprox","\\thicksim","\\thinspace","\\tilde","\\times","\\tiny","\\Tiny","\\to","\\top","\\triangle","\\triangledown","\\triangleleft","\\triangleright","\\trianglelefteq","\\trianglerighteq","\\triangleq","\\tt","\\twoheadleftarrow","\\twoheadrightarrow","\\ulcorner","\\urcorner","\\underbrace","\\underleftarrow","\\underrightarrow","\\underleftrightarrow","\\underline","\\underparen","\\underset","\\unicode","\\unlhd","\\unrhd","\\uparrow","\\Uparrow","\\updownarrow","\\Updownarrow","\\upharpoonleft","\\upharpoonright","\\uplus","\\uproot","\\upsilon","\\Upsilon","\\upuparrows","\\varDelta","\\varepsilon","\\varGamma","\\varinjlim","\\varkappa","\\varLambda","\\varlimsup","\\varliminf","\\varnothing","\\varOmega","\\varphi","\\varPhi","\\varpi","\\varPi","\\varprojlim","\\varpropto","\\varPsi","\\varrho","\\varsigma","\\varSigma","\\varsubsetneq","\\varsubsetneqq","\\varsupsetneq","\\varsupsetneqq","\\vartheta","\\varTheta","\\vartriangle","\\vartriangleleft","\\vartriangleright","\\varUpsilon","\\varXi","\\vcenter","\\vdash","\\Vdash","\\vDash","\\vdots","\\vec","\\vee","\\veebar","\\verb","\\vert","\\Vert","\\vphantom","\\Vvdash","\\wedge","\\widehat","\\widetilde","\\wp","\\wr","\\Xi","\\xi","\\xleftarrow","\\xrightarrow","\\yen","\\zeta","\\{%C\\}%C","\\langle %C \\rangle%C"],Ihe=["align","align*","alignat","alignat*","array","Bmatrix","bmatrix","cases","eqnarray","eqnarray*","equation","equation*","gather","gather*","matrix","pmatrix","smallmatrix","subarray","Vmatrix","vmatrix"];H5=[...Dhe,...Ihe.map(Phe)]});function Mhe(r){if(v1.has(r))return v1.get(r)??null;let e=null;try{e=(0,j5.renderMath)(r,!0)}catch{e=null}return v1.set(r,e),e}function Rhe(r){return y1===null&&(y1=new $u(r,{findAllMatches:!0,threshold:.8})),y1}var j5,Fhe,v1,y1,ZS,G5=b(()=>{yl();k_();j5=require("obsidian");g1();wl();Fhe=new RegExp(/\\([a-z{}A-Z0-9]*)$/),v1=new Map,y1=null;ZS=class extends hn{constructor(t){super(ni().app,t);this.inputEl=t;this.lastInput="";this.symbols=Object.assign([],H5)}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.slice(0,n),o=i.lastIndexOf("\\"),s=i.slice(o),a=Fhe.exec(s),l=[];a&&(this.lastInput=a[1],l=this.symbols.filter(d=>d.toLowerCase().contains(this.lastInput)));let c=new Set(l);return Rhe(this.symbols).search(this.lastInput).map(d=>d.item).filter(d=>c.has(d))}renderSuggestion(t,n){if(t){n.setText(t);let i=Mhe(t);i&&n.append(i.cloneNode(!0))}}selectSuggestion(t){if(this.inputEl.selectionStart===null)return;let n=this.inputEl.selectionStart,i=this.lastInput.length,o=this.inputEl.value,s=0,a=t.replace(/\\\\/g,"\\");if(this.inputEl.value=`${o.slice(0,n-i-1)}${a}${o.slice(n)}`,s=n-i+t.length-1,this.inputEl.trigger("input"),this.close(),t.contains("\u261A")){let l=this.inputEl.value.indexOf("\u261A");this.inputEl.value=this.inputEl.value.replace("\u261A",""),this.inputEl.setSelectionRange(l,l)}else this.inputEl.setSelectionRange(s,s)}}});var qo,JS,Y5=b(()=>{qo=require("obsidian");wl();g1();G5();Hr();JS=class r extends qo.Modal{constructor(){super(ni().app);this.didSubmit=!1;this.keybindListener=t=>{(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&this.submit(),t.key==="Tab"&&(t.preventDefault(),this.cursorToGoTo())};this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.open(),this.display(),this.waitForClose=new Promise((t,n)=>{this.resolvePromise=t,this.rejectPromise=n}),new ZS(this.inputEl),this.inputEl.focus(),this.inputEl.select()}static Prompt(){return new r().waitForClose}display(){this.containerEl.addClass("quickAddModal","qaMathModal"),this.contentEl.empty();let t=this.contentEl.createDiv();t.className="math math-block is-loaded";let n=new qo.TextAreaComponent(this.contentEl);n.inputEl.setCssStyles({width:"100%",height:"10rem"}),this.inputEl=n.inputEl,n.onChange((0,qo.debounce)(async o=>await this.mathjaxLoop(t,o),50)),n.inputEl.addEventListener("keydown",this.keybindListener),this.contentEl.createDiv({text:"Ctrl/Cmd+Enter to submit \xB7 Tab to jump to the cursor marker",cls:"setting-item-description"}).setCssStyles({marginTop:"0.5rem"}),this.createButtonBar(this.contentEl.createDiv())}async onOpen(){super.onOpen(),await(0,qo.loadMathJax)()}async mathjaxLoop(t,n){let i=(0,qo.renderMath)(n,!0);await(0,qo.finishRenderMath)(),t.empty(),t.append(i)}cursorToGoTo(){if(this.inputEl.value.contains("\u261A")){let t=this.inputEl.value.indexOf("\u261A");this.inputEl.value=this.inputEl.value.replace("\u261A",""),this.inputEl.setSelectionRange(t,t)}}createButton(t,n,i){let o=new qo.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv();this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marginTop:"1rem",gap:"0.5rem"})}removeInputListeners(){this.inputEl.removeEventListener("keydown",this.keybindListener)}resolveInput(){let t=this.inputEl.value.replace(/\\n/g,"\\\\n").replace(new RegExp("\u261A","g"),"");this.didSubmit?this.resolvePromise(t):this.rejectPromise(rn())}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}}});var A9=CQ(zl=>{"use strict";Object.defineProperty(zl,"__esModule",{value:!0});require("obsidian");var Gc=class extends Error{},k1=class extends Gc{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},S1=class extends Gc{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},D1=class extends Gc{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},lf=class extends Gc{},lD=class extends Gc{constructor(e){super(`Invalid unit ${e}`)}},Wo=class extends Gc{},ql=class extends Gc{constructor(){super("Zone is an abstract class")}},Ee="numeric",Xa="short",Cs="long",cD={year:Ee,month:Ee,day:Ee},A8={year:Ee,month:Xa,day:Ee},$he={year:Ee,month:Xa,day:Ee,weekday:Xa},k8={year:Ee,month:Cs,day:Ee},S8={year:Ee,month:Cs,day:Ee,weekday:Cs},D8={hour:Ee,minute:Ee},I8={hour:Ee,minute:Ee,second:Ee},P8={hour:Ee,minute:Ee,second:Ee,timeZoneName:Xa},F8={hour:Ee,minute:Ee,second:Ee,timeZoneName:Cs},M8={hour:Ee,minute:Ee,hourCycle:"h23"},R8={hour:Ee,minute:Ee,second:Ee,hourCycle:"h23"},$8={hour:Ee,minute:Ee,second:Ee,hourCycle:"h23",timeZoneName:Xa},O8={hour:Ee,minute:Ee,second:Ee,hourCycle:"h23",timeZoneName:Cs},N8={year:Ee,month:Ee,day:Ee,hour:Ee,minute:Ee},L8={year:Ee,month:Ee,day:Ee,hour:Ee,minute:Ee,second:Ee},B8={year:Ee,month:Xa,day:Ee,hour:Ee,minute:Ee},V8={year:Ee,month:Xa,day:Ee,hour:Ee,minute:Ee,second:Ee},Ohe={year:Ee,month:Xa,day:Ee,weekday:Xa,hour:Ee,minute:Ee},U8={year:Ee,month:Cs,day:Ee,hour:Ee,minute:Ee,timeZoneName:Xa},q8={year:Ee,month:Cs,day:Ee,hour:Ee,minute:Ee,second:Ee,timeZoneName:Xa},W8={year:Ee,month:Cs,day:Ee,weekday:Cs,hour:Ee,minute:Ee,timeZoneName:Cs},z8={year:Ee,month:Cs,day:Ee,weekday:Cs,hour:Ee,minute:Ee,second:Ee,timeZoneName:Cs},df=class{get type(){throw new ql}get name(){throw new ql}get ianaName(){return this.name}get isUniversal(){throw new ql}offsetName(e,t){throw new ql}formatOffset(e,t){throw new ql}offset(e){throw new ql}equals(e){throw new ql}get isValid(){throw new ql}},b1=null,uD=class r extends df{static get instance(){return b1===null&&(b1=new r),b1}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return j8(e,t,n)}formatOffset(e,t){return sE(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},sD={};function Nhe(r){return sD[r]||(sD[r]=new Intl.DateTimeFormat("en-US",{hour12:!1,timeZone:r,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit",era:"short"})),sD[r]}var Lhe={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Bhe(r,e){let t=r.format(e).replace(/\u200E/g,""),n=/(\d+)\/(\d+)\/(\d+) (AD|BC),? (\d+):(\d+):(\d+)/.exec(t),[,i,o,s,a,l,c,u]=n;return[s,i,o,a,l,c,u]}function Vhe(r,e){let t=r.formatToParts(e),n=[];for(let i=0;i<t.length;i++){let{type:o,value:s}=t[i],a=Lhe[o];o==="era"?n[a]=s:Rt(a)||(n[a]=parseInt(s,10))}return n}var eD={},gd=class r extends df{static create(e){return eD[e]||(eD[e]=new r(e)),eD[e]}static resetCache(){eD={},sD={}}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=r.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return j8(e,t,n,this.name)}formatOffset(e,t){return sE(this.offset(e),t)}offset(e){let t=new Date(e);if(isNaN(t))return NaN;let n=Nhe(this.name),[i,o,s,a,l,c,u]=n.formatToParts?Vhe(n,t):Bhe(n,t);a==="BC"&&(i=-Math.abs(i)+1);let f=bD({year:i,month:o,day:s,hour:l===24?0:l,minute:c,second:u,millisecond:0}),p=+t,m=p%1e3;return p-=m>=0?m:1e3+m,(f-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},K5={};function Uhe(r,e={}){let t=JSON.stringify([r,e]),n=K5[t];return n||(n=new Intl.ListFormat(r,e),K5[t]=n),n}var I1={};function P1(r,e={}){let t=JSON.stringify([r,e]),n=I1[t];return n||(n=new Intl.DateTimeFormat(r,e),I1[t]=n),n}var F1={};function qhe(r,e={}){let t=JSON.stringify([r,e]),n=F1[t];return n||(n=new Intl.NumberFormat(r,e),F1[t]=n),n}var M1={};function Whe(r,e={}){let{base:t,...n}=e,i=JSON.stringify([r,n]),o=M1[i];return o||(o=new Intl.RelativeTimeFormat(r,e),M1[i]=o),o}var iE=null;function zhe(){return iE||(iE=new Intl.DateTimeFormat().resolvedOptions().locale,iE)}function Hhe(r){let e=r.indexOf("-x-");e!==-1&&(r=r.substring(0,e));let t=r.indexOf("-u-");if(t===-1)return[r];{let n,i;try{n=P1(r).resolvedOptions(),i=r}catch{let l=r.substring(0,t);n=P1(l).resolvedOptions(),i=l}let{numberingSystem:o,calendar:s}=n;return[i,o,s]}}function jhe(r,e,t){return(t||e)&&(r.includes("-u-")||(r+="-u"),t&&(r+=`-ca-${t}`),e&&(r+=`-nu-${e}`)),r}function Ghe(r){let e=[];for(let t=1;t<=12;t++){let n=kt.utc(2009,t,1);e.push(r(n))}return e}function Yhe(r){let e=[];for(let t=1;t<=7;t++){let n=kt.utc(2016,11,13+t);e.push(r(n))}return e}function tD(r,e,t,n){let i=r.listingMode();return i==="error"?null:i==="en"?t(e):n(e)}function Khe(r){return r.numberingSystem&&r.numberingSystem!=="latn"?!1:r.numberingSystem==="latn"||!r.locale||r.locale.startsWith("en")||new Intl.DateTimeFormat(r.intl).resolvedOptions().numberingSystem==="latn"}var R1=class{constructor(e,t,n){this.padTo=n.padTo||0,this.floor=n.floor||!1;let{padTo:i,floor:o,...s}=n;if(!t||Object.keys(s).length>0){let a={useGrouping:!1,...n};n.padTo>0&&(a.minimumIntegerDigits=n.padTo),this.inf=qhe(e,a)}}format(e){if(this.inf){let t=this.floor?Math.floor(e):e;return this.inf.format(t)}else{let t=this.floor?Math.floor(e):Y1(e,3);return En(t,this.padTo)}}},$1=class{constructor(e,t,n){this.opts=n,this.originalZone=void 0;let i;if(this.opts.timeZone)this.dt=e;else if(e.zone.type==="fixed"){let s=-1*(e.offset/60),a=s>=0?`Etc/GMT+${s}`:`Etc/GMT${s}`;e.offset!==0&&gd.create(a).valid?(i=a,this.dt=e):(i="UTC",this.dt=e.offset===0?e:e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone)}else e.zone.type==="system"?this.dt=e:e.zone.type==="iana"?(this.dt=e,i=e.zone.name):(i="UTC",this.dt=e.setZone("UTC").plus({minutes:e.offset}),this.originalZone=e.zone);let o={...this.opts};o.timeZone=o.timeZone||i,this.dtf=P1(t,o)}format(){return this.originalZone?this.formatToParts().map(({value:e})=>e).join(""):this.dtf.format(this.dt.toJSDate())}formatToParts(){let e=this.dtf.formatToParts(this.dt.toJSDate());return this.originalZone?e.map(t=>{if(t.type==="timeZoneName"){let n=this.originalZone.offsetName(this.dt.ts,{locale:this.dt.locale,format:this.opts.timeZoneName});return{...t,value:n}}else return t}):e}resolvedOptions(){return this.dtf.resolvedOptions()}},O1=class{constructor(e,t,n){this.opts={style:"long",...n},!t&&H8()&&(this.rtf=Whe(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):dge(t,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},Zr=class r{static fromOpts(e){return r.create(e.locale,e.numberingSystem,e.outputCalendar,e.defaultToEN)}static create(e,t,n,i=!1){let o=e||Xr.defaultLocale,s=o||(i?"en-US":zhe()),a=t||Xr.defaultNumberingSystem,l=n||Xr.defaultOutputCalendar;return new r(s,a,l,o)}static resetCache(){iE=null,I1={},F1={},M1={}}static fromObject({locale:e,numberingSystem:t,outputCalendar:n}={}){return r.create(e,t,n)}constructor(e,t,n,i){let[o,s,a]=Hhe(e);this.locale=o,this.numberingSystem=t||s||null,this.outputCalendar=n||a||null,this.intl=jhe(this.locale,this.numberingSystem,this.outputCalendar),this.weekdaysCache={format:{},standalone:{}},this.monthsCache={format:{},standalone:{}},this.meridiemCache=null,this.eraCache={},this.specifiedLocale=i,this.fastNumbersCached=null}get fastNumbers(){return this.fastNumbersCached==null&&(this.fastNumbersCached=Khe(this)),this.fastNumbersCached}listingMode(){let e=this.isEnglish(),t=(this.numberingSystem===null||this.numberingSystem==="latn")&&(this.outputCalendar===null||this.outputCalendar==="gregory");return e&&t?"en":"intl"}clone(e){return!e||Object.getOwnPropertyNames(e).length===0?this:r.create(e.locale||this.specifiedLocale,e.numberingSystem||this.numberingSystem,e.outputCalendar||this.outputCalendar,e.defaultToEN||!1)}redefaultToEN(e={}){return this.clone({...e,defaultToEN:!0})}redefaultToSystem(e={}){return this.clone({...e,defaultToEN:!1})}months(e,t=!1){return tD(this,e,K8,()=>{let n=t?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";return this.monthsCache[i][e]||(this.monthsCache[i][e]=Ghe(o=>this.extract(o,n,"month"))),this.monthsCache[i][e]})}weekdays(e,t=!1){return tD(this,e,Z8,()=>{let n=t?{weekday:e,year:"numeric",month:"long",day:"numeric"}:{weekday:e},i=t?"format":"standalone";return this.weekdaysCache[i][e]||(this.weekdaysCache[i][e]=Yhe(o=>this.extract(o,n,"weekday"))),this.weekdaysCache[i][e]})}meridiems(){return tD(this,void 0,()=>J8,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[kt.utc(2016,11,13,9),kt.utc(2016,11,13,19)].map(t=>this.extract(t,e,"dayperiod"))}return this.meridiemCache})}eras(e){return tD(this,e,e9,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[kt.utc(-40,1,1),kt.utc(2017,1,1)].map(n=>this.extract(n,t,"era"))),this.eraCache[e]})}extract(e,t,n){let i=this.dtFormatter(e,t),o=i.formatToParts(),s=o.find(a=>a.type.toLowerCase()===n);return s?s.value:null}numberFormatter(e={}){return new R1(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new $1(e,this.intl,t)}relFormatter(e={}){return new O1(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Uhe(this.intl,e)}isEnglish(){return this.locale==="en"||this.locale.toLowerCase()==="en-us"||new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us")}equals(e){return this.locale===e.locale&&this.numberingSystem===e.numberingSystem&&this.outputCalendar===e.outputCalendar}},w1=null,oa=class r extends df{static get utcInstance(){return w1===null&&(w1=new r(0)),w1}static instance(e){return e===0?r.utcInstance:new r(e)}static parseSpecifier(e){if(e){let t=e.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);if(t)return new r(wD(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${sE(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${sE(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return sE(this.fixed,t)}get isUniversal(){return!0}offset(){return this.fixed}equals(e){return e.type==="fixed"&&e.fixed===this.fixed}get isValid(){return!0}},N1=class extends df{constructor(e){super(),this.zoneName=e}get type(){return"invalid"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(){return null}formatOffset(){return""}offset(){return NaN}equals(){return!1}get isValid(){return!1}};function hd(r,e){if(Rt(r)||r===null)return e;if(r instanceof df)return r;if(Qhe(r)){let t=r.toLowerCase();return t==="default"?e:t==="local"||t==="system"?uD.instance:t==="utc"||t==="gmt"?oa.utcInstance:oa.parseSpecifier(t)||gd.create(r)}else return uf(r)?oa.instance(r):typeof r=="object"&&"offset"in r&&typeof r.offset=="function"?r:new N1(r)}var Q5=()=>Date.now(),X5="system",Z5=null,J5=null,e8=null,t8=60,r8,Xr=class{static get now(){return Q5}static set now(e){Q5=e}static set defaultZone(e){X5=e}static get defaultZone(){return hd(X5,uD.instance)}static get defaultLocale(){return Z5}static set defaultLocale(e){Z5=e}static get defaultNumberingSystem(){return J5}static set defaultNumberingSystem(e){J5=e}static get defaultOutputCalendar(){return e8}static set defaultOutputCalendar(e){e8=e}static get twoDigitCutoffYear(){return t8}static set twoDigitCutoffYear(e){t8=e%100}static get throwOnInvalid(){return r8}static set throwOnInvalid(e){r8=e}static resetCaches(){Zr.resetCache(),gd.resetCache()}};function Rt(r){return typeof r>"u"}function uf(r){return typeof r=="number"}function yD(r){return typeof r=="number"&&r%1===0}function Qhe(r){return typeof r=="string"}function Xhe(r){return Object.prototype.toString.call(r)==="[object Date]"}function H8(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Zhe(r){return Array.isArray(r)?r:[r]}function n8(r,e,t){if(r.length!==0)return r.reduce((n,i)=>{let o=[e(i),i];return n&&t(n[0],o[0])===n[0]?n:o},null)[1]}function Jhe(r,e){return e.reduce((t,n)=>(t[n]=r[n],t),{})}function Fg(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function jc(r,e,t){return yD(r)&&r>=e&&r<=t}function ege(r,e){return r-e*Math.floor(r/e)}function En(r,e=2){let t=r<0,n;return t?n="-"+(""+-r).padStart(e,"0"):n=(""+r).padStart(e,"0"),n}function md(r){if(!(Rt(r)||r===null||r===""))return parseInt(r,10)}function sf(r){if(!(Rt(r)||r===null||r===""))return parseFloat(r)}function G1(r){if(!(Rt(r)||r===null||r==="")){let e=parseFloat("0."+r)*1e3;return Math.floor(e)}}function Y1(r,e,t=!1){let n=10**e;return(t?Math.trunc:Math.round)(r*n)/n}function cE(r){return r%4===0&&(r%100!==0||r%400===0)}function oE(r){return cE(r)?366:365}function dD(r,e){let t=ege(e-1,12)+1,n=r+(e-t)/12;return t===2?cE(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][t-1]}function bD(r){let e=Date.UTC(r.year,r.month-1,r.day,r.hour,r.minute,r.second,r.millisecond);return r.year<100&&r.year>=0&&(e=new Date(e),e.setUTCFullYear(r.year,r.month-1,r.day)),+e}function pD(r){let e=(r+Math.floor(r/4)-Math.floor(r/100)+Math.floor(r/400))%7,t=r-1,n=(t+Math.floor(t/4)-Math.floor(t/100)+Math.floor(t/400))%7;return e===4||n===3?53:52}function L1(r){return r>99?r:r>Xr.twoDigitCutoffYear?1900+r:2e3+r}function j8(r,e,t,n=null){let i=new Date(r),o={hourCycle:"h23",year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"};n&&(o.timeZone=n);let s={timeZoneName:e,...o},a=new Intl.DateTimeFormat(t,s).formatToParts(i).find(l=>l.type.toLowerCase()==="timezonename");return a?a.value:null}function wD(r,e){let t=parseInt(r,10);Number.isNaN(t)&&(t=0);let n=parseInt(e,10)||0,i=t<0||Object.is(t,-0)?-n:n;return t*60+i}function G8(r){let e=Number(r);if(typeof r=="boolean"||r===""||Number.isNaN(e))throw new Wo(`Invalid unit value ${r}`);return e}function fD(r,e){let t={};for(let n in r)if(Fg(r,n)){let i=r[n];if(i==null)continue;t[e(n)]=G8(i)}return t}function sE(r,e){let t=Math.trunc(Math.abs(r/60)),n=Math.trunc(Math.abs(r%60)),i=r>=0?"+":"-";switch(e){case"short":return`${i}${En(t,2)}:${En(n,2)}`;case"narrow":return`${i}${t}${n>0?`:${n}`:""}`;case"techie":return`${i}${En(t,2)}${En(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function CD(r){return Jhe(r,["hour","minute","second","millisecond"])}var tge=["January","February","March","April","May","June","July","August","September","October","November","December"],Y8=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],rge=["J","F","M","A","M","J","J","A","S","O","N","D"];function K8(r){switch(r){case"narrow":return[...rge];case"short":return[...Y8];case"long":return[...tge];case"numeric":return["1","2","3","4","5","6","7","8","9","10","11","12"];case"2-digit":return["01","02","03","04","05","06","07","08","09","10","11","12"];default:return null}}var Q8=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],X8=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],nge=["M","T","W","T","F","S","S"];function Z8(r){switch(r){case"narrow":return[...nge];case"short":return[...X8];case"long":return[...Q8];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var J8=["AM","PM"],ige=["Before Christ","Anno Domini"],oge=["BC","AD"],sge=["B","A"];function e9(r){switch(r){case"narrow":return[...sge];case"short":return[...oge];case"long":return[...ige];default:return null}}function age(r){return J8[r.hour<12?0:1]}function lge(r,e){return Z8(e)[r.weekday-1]}function cge(r,e){return K8(e)[r.month-1]}function uge(r,e){return e9(e)[r.year<0?0:1]}function dge(r,e,t="always",n=!1){let i={years:["year","yr."],quarters:["quarter","qtr."],months:["month","mo."],weeks:["week","wk."],days:["day","day","days"],hours:["hour","hr."],minutes:["minute","min."],seconds:["second","sec."]},o=["hours","minutes","seconds"].indexOf(r)===-1;if(t==="auto"&&o){let d=r==="days";switch(e){case 1:return d?"tomorrow":`next ${i[r][0]}`;case-1:return d?"yesterday":`last ${i[r][0]}`;case 0:return d?"today":`this ${i[r][0]}`}}let s=Object.is(e,-0)||e<0,a=Math.abs(e),l=a===1,c=i[r],u=n?l?c[1]:c[2]||c[1]:l?i[r][0]:r;return s?`${a} ${u} ago`:`in ${a} ${u}`}function i8(r,e){let t="";for(let n of r)n.literal?t+=n.val:t+=e(n.val);return t}var pge={D:cD,DD:A8,DDD:k8,DDDD:S8,t:D8,tt:I8,ttt:P8,tttt:F8,T:M8,TT:R8,TTT:$8,TTTT:O8,f:N8,ff:B8,fff:U8,ffff:W8,F:L8,FF:V8,FFF:q8,FFFF:z8},bs=class r{static create(e,t={}){return new r(e,t)}static parseFormat(e){let t=null,n="",i=!1,o=[];for(let s=0;s<e.length;s++){let a=e.charAt(s);a==="'"?(n.length>0&&o.push({literal:i||/^\s+$/.test(n),val:n}),t=null,n="",i=!i):i||a===t?n+=a:(n.length>0&&o.push({literal:/^\s+$/.test(n),val:n}),n=a,t=a)}return n.length>0&&o.push({literal:i||/^\s+$/.test(n),val:n}),o}static macroTokenToFormatOpts(e){return pge[e]}constructor(e,t){this.opts=t,this.loc=e,this.systemLoc=null}formatWithSystemDefault(e,t){return this.systemLoc===null&&(this.systemLoc=this.loc.redefaultToSystem()),this.systemLoc.dtFormatter(e,{...this.opts,...t}).format()}dtFormatter(e,t={}){return this.loc.dtFormatter(e,{...this.opts,...t})}formatDateTime(e,t){return this.dtFormatter(e,t).format()}formatDateTimeParts(e,t){return this.dtFormatter(e,t).formatToParts()}formatInterval(e,t){return this.dtFormatter(e.start,t).dtf.formatRange(e.start.toJSDate(),e.end.toJSDate())}resolvedOptions(e,t){return this.dtFormatter(e,t).resolvedOptions()}num(e,t=0){if(this.opts.forceSimple)return En(e,t);let n={...this.opts};return t>0&&(n.padTo=t),this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,t){let n=this.loc.listingMode()==="en",i=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",o=(p,m)=>this.loc.extract(e,p,m),s=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",a=()=>n?age(e):o({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,m)=>n?cge(e,p):o(m?{month:p}:{month:p,day:"numeric"},"month"),c=(p,m)=>n?lge(e,p):o(m?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),u=p=>{let m=r.macroTokenToFormatOpts(p);return m?this.formatWithSystemDefault(e,m):p},d=p=>n?uge(e,p):o({era:p},"era"),f=p=>{switch(p){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return s({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return s({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return s({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return a();case"d":return i?o({day:"numeric"},"day"):this.num(e.day);case"dd":return i?o({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return i?o({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return i?o({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return i?o({month:"numeric"},"month"):this.num(e.month);case"MM":return i?o({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return i?o({year:"numeric"},"year"):this.num(e.year);case"yy":return i?o({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return i?o({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return i?o({year:"numeric"},"year"):this.num(e.year,6);case"G":return d("short");case"GG":return d("long");case"GGGGG":return d("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return u(p)}};return i8(r.parseFormat(t),f)}formatDurationFromString(e,t){let n=l=>{switch(l[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},i=l=>c=>{let u=n(c);return u?this.num(l.get(u),c.length):c},o=r.parseFormat(t),s=o.reduce((l,{literal:c,val:u})=>c?l:l.concat(u),[]),a=e.shiftTo(...s.map(n).filter(l=>l));return i8(o,i(a))}},ws=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},t9=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Mg(...r){let e=r.reduce((t,n)=>t+n.source,"");return RegExp(`^${e}$`)}function Rg(...r){return e=>r.reduce(([t,n,i],o)=>{let[s,a,l]=o(e,i);return[{...t,...s},a||n,l]},[{},null,1]).slice(0,2)}function $g(r,...e){if(r==null)return[null,null];for(let[t,n]of e){let i=t.exec(r);if(i)return n(i)}return[null,null]}function r9(...r){return(e,t)=>{let n={},i;for(i=0;i<r.length;i++)n[r[i]]=md(e[t+i]);return[n,null,t+i]}}var n9=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,fge=`(?:${n9.source}?(?:\\[(${t9.source})\\])?)?`,K1=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,i9=RegExp(`${K1.source}${fge}`),Q1=RegExp(`(?:T${i9.source})?`),mge=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,hge=/(\d{4})-?W(\d\d)(?:-?(\d))?/,gge=/(\d{4})-?(\d{3})/,vge=r9("weekYear","weekNumber","weekDay"),yge=r9("year","ordinal"),bge=/(\d{4})-(\d\d)-(\d\d)/,o9=RegExp(`${K1.source} ?(?:${n9.source}|(${t9.source}))?`),wge=RegExp(`(?: ${o9.source})?`);function Ig(r,e,t){let n=r[e];return Rt(n)?t:md(n)}function Cge(r,e){return[{year:Ig(r,e),month:Ig(r,e+1,1),day:Ig(r,e+2,1)},null,e+3]}function Og(r,e){return[{hours:Ig(r,e,0),minutes:Ig(r,e+1,0),seconds:Ig(r,e+2,0),milliseconds:G1(r[e+3])},null,e+4]}function uE(r,e){let t=!r[e]&&!r[e+1],n=wD(r[e+1],r[e+2]),i=t?null:oa.instance(n);return[{},i,e+3]}function dE(r,e){let t=r[e]?gd.create(r[e]):null;return[{},t,e+1]}var xge=RegExp(`^T?${K1.source}$`),Ege=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function Tge(r){let[e,t,n,i,o,s,a,l,c]=r,u=e[0]==="-",d=l&&l[0]==="-",f=(p,m=!1)=>p!==void 0&&(m||p&&u)?-p:p;return[{years:f(sf(t)),months:f(sf(n)),weeks:f(sf(i)),days:f(sf(o)),hours:f(sf(s)),minutes:f(sf(a)),seconds:f(sf(l),l==="-0"),milliseconds:f(G1(c),d)}]}var _ge={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function X1(r,e,t,n,i,o,s){let a={year:e.length===2?L1(md(e)):md(e),month:Y8.indexOf(t)+1,day:md(n),hour:md(i),minute:md(o)};return s&&(a.second=md(s)),r&&(a.weekday=r.length>3?Q8.indexOf(r)+1:X8.indexOf(r)+1),a}var Age=/^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;function kge(r){let[,e,t,n,i,o,s,a,l,c,u,d]=r,f=X1(e,i,n,t,o,s,a),p;return l?p=_ge[l]:c?p=0:p=wD(u,d),[f,new oa(p)]}function Sge(r){return r.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var Dge=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/,Ige=/^(Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/,Pge=/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;function o8(r){let[,e,t,n,i,o,s,a]=r;return[X1(e,i,n,t,o,s,a),oa.utcInstance]}function Fge(r){let[,e,t,n,i,o,s,a]=r;return[X1(e,a,t,n,i,o,s),oa.utcInstance]}var Mge=Mg(mge,Q1),Rge=Mg(hge,Q1),$ge=Mg(gge,Q1),Oge=Mg(i9),s9=Rg(Cge,Og,uE,dE),Nge=Rg(vge,Og,uE,dE),Lge=Rg(yge,Og,uE,dE),Bge=Rg(Og,uE,dE);function Vge(r){return $g(r,[Mge,s9],[Rge,Nge],[$ge,Lge],[Oge,Bge])}function Uge(r){return $g(Sge(r),[Age,kge])}function qge(r){return $g(r,[Dge,o8],[Ige,o8],[Pge,Fge])}function Wge(r){return $g(r,[Ege,Tge])}var zge=Rg(Og);function Hge(r){return $g(r,[xge,zge])}var jge=Mg(bge,wge),Gge=Mg(o9),Yge=Rg(Og,uE,dE);function Kge(r){return $g(r,[jge,s9],[Gge,Yge])}var s8="Invalid Duration",a9={weeks:{days:7,hours:168,minutes:10080,seconds:10080*60,milliseconds:10080*60*1e3},days:{hours:24,minutes:1440,seconds:1440*60,milliseconds:1440*60*1e3},hours:{minutes:60,seconds:3600,milliseconds:3600*1e3},minutes:{seconds:60,milliseconds:60*1e3},seconds:{milliseconds:1e3}},Qge={years:{quarters:4,months:12,weeks:52,days:365,hours:365*24,minutes:365*24*60,seconds:365*24*60*60,milliseconds:365*24*60*60*1e3},quarters:{months:3,weeks:13,days:91,hours:2184,minutes:2184*60,seconds:2184*60*60,milliseconds:2184*60*60*1e3},months:{weeks:4,days:30,hours:720,minutes:720*60,seconds:720*60*60,milliseconds:720*60*60*1e3},...a9},na=146097/400,kg=146097/4800,Xge={years:{quarters:4,months:12,weeks:na/7,days:na,hours:na*24,minutes:na*24*60,seconds:na*24*60*60,milliseconds:na*24*60*60*1e3},quarters:{months:3,weeks:na/28,days:na/4,hours:na*24/4,minutes:na*24*60/4,seconds:na*24*60*60/4,milliseconds:na*24*60*60*1e3/4},months:{weeks:kg/7,days:kg,hours:kg*24,minutes:kg*24*60,seconds:kg*24*60*60,milliseconds:kg*24*60*60*1e3},...a9},cf=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Zge=cf.slice(0).reverse();function fd(r,e,t=!1){let n={values:t?e.values:{...r.values,...e.values||{}},loc:r.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||r.conversionAccuracy,matrix:e.matrix||r.matrix};return new Xe(n)}function l9(r,e){let t=e.milliseconds??0;for(let n of Zge.slice(1))e[n]&&(t+=e[n]*r[n].milliseconds);return t}function a8(r,e){let t=l9(r,e)<0?-1:1;cf.reduceRight((n,i)=>{if(Rt(e[i]))return n;if(n){let o=e[n]*t,s=r[i][n],a=Math.floor(o/s);e[i]+=a*t,e[n]-=a*s*t}return i},null),cf.reduce((n,i)=>{if(Rt(e[i]))return n;if(n){let o=e[n]%1;e[n]-=o,e[i]+=o*r[n][i]}return i},null)}function Jge(r){let e={};for(let[t,n]of Object.entries(r))n!==0&&(e[t]=n);return e}var Xe=class r{constructor(e){let t=e.conversionAccuracy==="longterm"||!1,n=t?Xge:Qge;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Zr.create(),this.conversionAccuracy=t?"longterm":"casual",this.invalid=e.invalid||null,this.matrix=n,this.isLuxonDuration=!0}static fromMillis(e,t){return r.fromObject({milliseconds:e},t)}static fromObject(e,t={}){if(e==null||typeof e!="object")throw new Wo(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new r({values:fD(e,r.normalizeUnit),loc:Zr.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(uf(e))return r.fromMillis(e);if(r.isDuration(e))return e;if(typeof e=="object")return r.fromObject(e);throw new Wo(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){let[n]=Wge(e);return n?r.fromObject(n,t):r.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static fromISOTime(e,t){let[n]=Hge(e);return n?r.fromObject(n,t):r.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static invalid(e,t=null){if(!e)throw new Wo("need to specify a reason the Duration is invalid");let n=e instanceof ws?e:new ws(e,t);if(Xr.throwOnInvalid)throw new D1(n);return new r({invalid:n})}static normalizeUnit(e){let t={year:"years",years:"years",quarter:"quarters",quarters:"quarters",month:"months",months:"months",week:"weeks",weeks:"weeks",day:"days",days:"days",hour:"hours",hours:"hours",minute:"minutes",minutes:"minutes",second:"seconds",seconds:"seconds",millisecond:"milliseconds",milliseconds:"milliseconds"}[e&&e.toLowerCase()];if(!t)throw new lD(e);return t}static isDuration(e){return e&&e.isLuxonDuration||!1}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}toFormat(e,t={}){let n={...t,floor:t.round!==!1&&t.floor!==!1};return this.isValid?bs.create(this.loc,n).formatDurationFromString(this,e):s8}toHuman(e={}){if(!this.isValid)return s8;let t=cf.map(n=>{let i=this.values[n];return Rt(i)?null:this.loc.numberFormatter({style:"unit",unitDisplay:"long",...e,unit:n.slice(0,-1)}).format(i)}).filter(n=>n);return this.loc.listFormatter({type:"conjunction",style:e.listStyle||"narrow",...e}).format(t)}toObject(){return this.isValid?{...this.values}:{}}toISO(){if(!this.isValid)return null;let e="P";return this.years!==0&&(e+=this.years+"Y"),(this.months!==0||this.quarters!==0)&&(e+=this.months+this.quarters*3+"M"),this.weeks!==0&&(e+=this.weeks+"W"),this.days!==0&&(e+=this.days+"D"),(this.hours!==0||this.minutes!==0||this.seconds!==0||this.milliseconds!==0)&&(e+="T"),this.hours!==0&&(e+=this.hours+"H"),this.minutes!==0&&(e+=this.minutes+"M"),(this.seconds!==0||this.milliseconds!==0)&&(e+=Y1(this.seconds+this.milliseconds/1e3,3)+"S"),e==="P"&&(e+="T0S"),e}toISOTime(e={}){if(!this.isValid)return null;let t=this.toMillis();return t<0||t>=864e5?null:(e={suppressMilliseconds:!1,suppressSeconds:!1,includePrefix:!1,format:"extended",...e,includeOffset:!1},kt.fromMillis(t,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}toMillis(){return this.isValid?l9(this.matrix,this.values):NaN}valueOf(){return this.toMillis()}plus(e){if(!this.isValid)return this;let t=r.fromDurationLike(e),n={};for(let i of cf)(Fg(t.values,i)||Fg(this.values,i))&&(n[i]=t.get(i)+this.get(i));return fd(this,{values:n},!0)}minus(e){if(!this.isValid)return this;let t=r.fromDurationLike(e);return this.plus(t.negate())}mapUnits(e){if(!this.isValid)return this;let t={};for(let n of Object.keys(this.values))t[n]=G8(e(this.values[n],n));return fd(this,{values:t},!0)}get(e){return this[r.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let t={...this.values,...fD(e,r.normalizeUnit)};return fd(this,{values:t})}reconfigure({locale:e,numberingSystem:t,conversionAccuracy:n,matrix:i}={}){let s={loc:this.loc.clone({locale:e,numberingSystem:t}),matrix:i,conversionAccuracy:n};return fd(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return a8(this.matrix,e),fd(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=Jge(this.normalize().shiftToAll().toObject());return fd(this,{values:e},!0)}shiftTo(...e){if(!this.isValid)return this;if(e.length===0)return this;e=e.map(s=>r.normalizeUnit(s));let t={},n={},i=this.toObject(),o;for(let s of cf)if(e.indexOf(s)>=0){o=s;let a=0;for(let c in n)a+=this.matrix[c][s]*n[c],n[c]=0;uf(i[s])&&(a+=i[s]);let l=Math.trunc(a);t[s]=l,n[s]=(a*1e3-l*1e3)/1e3}else uf(i[s])&&(n[s]=i[s]);for(let s in n)n[s]!==0&&(t[o]+=s===o?n[s]:n[s]/this.matrix[o][s]);return a8(this.matrix,t),fd(this,{values:t},!0)}shiftToAll(){return this.isValid?this.shiftTo("years","months","weeks","days","hours","minutes","seconds","milliseconds"):this}negate(){if(!this.isValid)return this;let e={};for(let t of Object.keys(this.values))e[t]=this.values[t]===0?0:-this.values[t];return fd(this,{values:e},!0)}get years(){return this.isValid?this.values.years||0:NaN}get quarters(){return this.isValid?this.values.quarters||0:NaN}get months(){return this.isValid?this.values.months||0:NaN}get weeks(){return this.isValid?this.values.weeks||0:NaN}get days(){return this.isValid?this.values.days||0:NaN}get hours(){return this.isValid?this.values.hours||0:NaN}get minutes(){return this.isValid?this.values.minutes||0:NaN}get seconds(){return this.isValid?this.values.seconds||0:NaN}get milliseconds(){return this.isValid?this.values.milliseconds||0:NaN}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}equals(e){if(!this.isValid||!e.isValid||!this.loc.equals(e.loc))return!1;function t(n,i){return n===void 0||n===0?i===void 0||i===0:n===i}for(let n of cf)if(!t(this.values[n],e.values[n]))return!1;return!0}},Sg="Invalid Interval";function eve(r,e){return!r||!r.isValid?Pg.invalid("missing or invalid start"):!e||!e.isValid?Pg.invalid("missing or invalid end"):e<r?Pg.invalid("end before start",`The end of an interval must be after its start, but you had start=${r.toISO()} and end=${e.toISO()}`):null}var Pg=class r{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,t=null){if(!e)throw new Wo("need to specify a reason the Interval is invalid");let n=e instanceof ws?e:new ws(e,t);if(Xr.throwOnInvalid)throw new S1(n);return new r({invalid:n})}static fromDateTimes(e,t){let n=rE(e),i=rE(t),o=eve(n,i);return o??new r({start:n,end:i})}static after(e,t){let n=Xe.fromDurationLike(t),i=rE(e);return r.fromDateTimes(i,i.plus(n))}static before(e,t){let n=Xe.fromDurationLike(t),i=rE(e);return r.fromDateTimes(i.minus(n),i)}static fromISO(e,t){let[n,i]=(e||"").split("/",2);if(n&&i){let o,s;try{o=kt.fromISO(n,t),s=o.isValid}catch{s=!1}let a,l;try{a=kt.fromISO(i,t),l=a.isValid}catch{l=!1}if(s&&l)return r.fromDateTimes(o,a);if(s){let c=Xe.fromISO(i,t);if(c.isValid)return r.after(o,c)}else if(l){let c=Xe.fromISO(n,t);if(c.isValid)return r.before(a,c)}}return r.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds"){if(!this.isValid)return NaN;let t=this.start.startOf(e),n=this.end.startOf(e);return Math.floor(n.diff(t,e).get(e))+(n.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:t}={}){return this.isValid?r.fromDateTimes(e||this.s,t||this.e):this}splitAt(...e){if(!this.isValid)return[];let t=e.map(rE).filter(s=>this.contains(s)).sort(),n=[],{s:i}=this,o=0;for(;i<this.e;){let s=t[o]||this.e,a=+s>+this.e?this.e:s;n.push(r.fromDateTimes(i,a)),i=a,o+=1}return n}splitBy(e){let t=Xe.fromDurationLike(e);if(!this.isValid||!t.isValid||t.as("milliseconds")===0)return[];let{s:n}=this,i=1,o,s=[];for(;n<this.e;){let a=this.start.plus(t.mapUnits(l=>l*i));o=+a>+this.e?this.e:a,s.push(r.fromDateTimes(n,o)),n=o,i+=1}return s}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;let t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return t>=n?null:r.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;let t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return r.fromDateTimes(t,n)}static merge(e){let[t,n]=e.sort((i,o)=>i.s-o.s).reduce(([i,o],s)=>o?o.overlaps(s)||o.abutsStart(s)?[i,o.union(s)]:[i.concat([o]),s]:[i,s],[[],null]);return n&&t.push(n),t}static xor(e){let t=null,n=0,i=[],o=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),s=Array.prototype.concat(...o),a=s.sort((l,c)=>l.time-c.time);for(let l of a)n+=l.type==="s"?1:-1,n===1?t=l.time:(t&&+t!=+l.time&&i.push(r.fromDateTimes(t,l.time)),t=null);return r.merge(i)}difference(...e){return r.xor([this].concat(e)).map(t=>this.intersection(t)).filter(t=>t&&!t.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \u2013 ${this.e.toISO()})`:Sg}toLocaleString(e=cD,t={}){return this.isValid?bs.create(this.s.loc.clone(t),e).formatInterval(this):Sg}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:Sg}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:Sg}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:Sg}toFormat(e,{separator:t=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:Sg}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Xe.invalid(this.invalidReason)}mapEndpoints(e){return r.fromDateTimes(e(this.s),e(this.e))}},Dg=class{static hasDST(e=Xr.defaultZone){let t=kt.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return gd.isValidZone(e)}static normalizeZone(e){return hd(e,Xr.defaultZone)}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||Zr.create(t,n,o)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||Zr.create(t,n,o)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||Zr.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||Zr.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Zr.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Zr.create(t,null,"gregory").eras(e)}static features(){return{relative:H8()}}};function l8(r,e){let t=i=>i.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=t(e)-t(r);return Math.floor(Xe.fromMillis(n).as("days"))}function tve(r,e,t){let n=[["years",(l,c)=>c.year-l.year],["quarters",(l,c)=>c.quarter-l.quarter+(c.year-l.year)*4],["months",(l,c)=>c.month-l.month+(c.year-l.year)*12],["weeks",(l,c)=>{let u=l8(l,c);return(u-u%7)/7}],["days",l8]],i={},o=r,s,a;for(let[l,c]of n)t.indexOf(l)>=0&&(s=l,i[l]=c(r,e),a=o.plus(i),a>e?(i[l]--,r=o.plus(i),r>e&&(a=r,i[l]--,r=o.plus(i))):r=a);return[r,i,a,s]}function rve(r,e,t,n){let[i,o,s,a]=tve(r,e,t),l=e-i,c=t.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(s<e&&(s=i.plus({[a]:1})),s!==i&&(o[a]=(o[a]||0)+l/(s-i)));let u=Xe.fromObject(o,n);return c.length>0?Xe.fromMillis(l,n).shiftTo(...c).plus(u):u}var Z1={arab:"[\u0660-\u0669]",arabext:"[\u06F0-\u06F9]",bali:"[\u1B50-\u1B59]",beng:"[\u09E6-\u09EF]",deva:"[\u0966-\u096F]",fullwide:"[\uFF10-\uFF19]",gujr:"[\u0AE6-\u0AEF]",hanidec:"[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",khmr:"[\u17E0-\u17E9]",knda:"[\u0CE6-\u0CEF]",laoo:"[\u0ED0-\u0ED9]",limb:"[\u1946-\u194F]",mlym:"[\u0D66-\u0D6F]",mong:"[\u1810-\u1819]",mymr:"[\u1040-\u1049]",orya:"[\u0B66-\u0B6F]",tamldec:"[\u0BE6-\u0BEF]",telu:"[\u0C66-\u0C6F]",thai:"[\u0E50-\u0E59]",tibt:"[\u0F20-\u0F29]",latn:"\\d"},c8={arab:[1632,1641],arabext:[1776,1785],bali:[6992,7001],beng:[2534,2543],deva:[2406,2415],fullwide:[65296,65303],gujr:[2790,2799],khmr:[6112,6121],knda:[3302,3311],laoo:[3792,3801],limb:[6470,6479],mlym:[3430,3439],mong:[6160,6169],mymr:[4160,4169],orya:[2918,2927],tamldec:[3046,3055],telu:[3174,3183],thai:[3664,3673],tibt:[3872,3881]},nve=Z1.hanidec.replace(/[\[|\]]/g,"").split("");function ive(r){let e=parseInt(r,10);if(isNaN(e)){e="";for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(r[t].search(Z1.hanidec)!==-1)e+=nve.indexOf(r[t]);else for(let i in c8){let[o,s]=c8[i];n>=o&&n<=s&&(e+=n-o)}}return parseInt(e,10)}else return e}function Ya({numberingSystem:r},e=""){return new RegExp(`${Z1[r||"latn"]}${e}`)}var ove="missing Intl.DateTimeFormat.formatToParts support";function Qt(r,e=t=>t){return{regex:r,deser:([t])=>e(ive(t))}}var sve="\xA0",c9=`[ ${sve}]`,u9=new RegExp(c9,"g");function ave(r){return r.replace(/\./g,"\\.?").replace(u9,c9)}function u8(r){return r.replace(/\./g,"").replace(u9," ").toLowerCase()}function Ka(r,e){return r===null?null:{regex:RegExp(r.map(ave).join("|")),deser:([t])=>r.findIndex(n=>u8(t)===u8(n))+e}}function d8(r,e){return{regex:r,deser:([,t,n])=>wD(t,n),groups:e}}function rD(r){return{regex:r,deser:([e])=>e}}function lve(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function cve(r,e){let t=Ya(e),n=Ya(e,"{2}"),i=Ya(e,"{3}"),o=Ya(e,"{4}"),s=Ya(e,"{6}"),a=Ya(e,"{1,2}"),l=Ya(e,"{1,3}"),c=Ya(e,"{1,6}"),u=Ya(e,"{1,9}"),d=Ya(e,"{2,4}"),f=Ya(e,"{4,6}"),p=g=>({regex:RegExp(lve(g.val)),deser:([y])=>y,literal:!0}),v=(g=>{if(r.literal)return p(g);switch(g.val){case"G":return Ka(e.eras("short"),0);case"GG":return Ka(e.eras("long"),0);case"y":return Qt(c);case"yy":return Qt(d,L1);case"yyyy":return Qt(o);case"yyyyy":return Qt(f);case"yyyyyy":return Qt(s);case"M":return Qt(a);case"MM":return Qt(n);case"MMM":return Ka(e.months("short",!0),1);case"MMMM":return Ka(e.months("long",!0),1);case"L":return Qt(a);case"LL":return Qt(n);case"LLL":return Ka(e.months("short",!1),1);case"LLLL":return Ka(e.months("long",!1),1);case"d":return Qt(a);case"dd":return Qt(n);case"o":return Qt(l);case"ooo":return Qt(i);case"HH":return Qt(n);case"H":return Qt(a);case"hh":return Qt(n);case"h":return Qt(a);case"mm":return Qt(n);case"m":return Qt(a);case"q":return Qt(a);case"qq":return Qt(n);case"s":return Qt(a);case"ss":return Qt(n);case"S":return Qt(l);case"SSS":return Qt(i);case"u":return rD(u);case"uu":return rD(a);case"uuu":return Qt(t);case"a":return Ka(e.meridiems(),0);case"kkkk":return Qt(o);case"kk":return Qt(d,L1);case"W":return Qt(a);case"WW":return Qt(n);case"E":case"c":return Qt(t);case"EEE":return Ka(e.weekdays("short",!1),1);case"EEEE":return Ka(e.weekdays("long",!1),1);case"ccc":return Ka(e.weekdays("short",!0),1);case"cccc":return Ka(e.weekdays("long",!0),1);case"Z":case"ZZ":return d8(new RegExp(`([+-]${a.source})(?::(${n.source}))?`),2);case"ZZZ":return d8(new RegExp(`([+-]${a.source})(${n.source})?`),2);case"z":return rD(/[a-z_+-/]{1,256}?/i);case" ":return rD(/[^\S\n\r]/);default:return p(g)}})(r)||{invalidReason:ove};return v.token=r,v}var uve={year:{"2-digit":"yy",numeric:"yyyyy"},month:{numeric:"M","2-digit":"MM",short:"MMM",long:"MMMM"},day:{numeric:"d","2-digit":"dd"},weekday:{short:"EEE",long:"EEEE"},dayperiod:"a",dayPeriod:"a",hour12:{numeric:"h","2-digit":"hh"},hour24:{numeric:"H","2-digit":"HH"},minute:{numeric:"m","2-digit":"mm"},second:{numeric:"s","2-digit":"ss"},timeZoneName:{long:"ZZZZZ",short:"ZZZ"}};function dve(r,e,t){let{type:n,value:i}=r;if(n==="literal"){let l=/^\s+$/.test(i);return{literal:!l,val:l?" ":i}}let o=e[n],s=n;n==="hour"&&(e.hour12!=null?s=e.hour12?"hour12":"hour24":e.hourCycle!=null?e.hourCycle==="h11"||e.hourCycle==="h12"?s="hour12":s="hour24":s=t.hour12?"hour12":"hour24");let a=uve[s];if(typeof a=="object"&&(a=a[o]),a)return{literal:!1,val:a}}function pve(r){return[`^${r.map(t=>t.regex).reduce((t,n)=>`${t}(${n.source})`,"")}$`,r]}function fve(r,e,t){let n=r.match(e);if(n){let i={},o=1;for(let s in t)if(Fg(t,s)){let a=t[s],l=a.groups?a.groups+1:1;!a.literal&&a.token&&(i[a.token.val[0]]=a.deser(n.slice(o,o+l))),o+=l}return[n,i]}else return[n,{}]}function mve(r){let e=o=>{switch(o){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":case"H":return"hour";case"d":return"day";case"o":return"ordinal";case"L":case"M":return"month";case"y":return"year";case"E":case"c":return"weekday";case"W":return"weekNumber";case"k":return"weekYear";case"q":return"quarter";default:return null}},t=null,n;return Rt(r.z)||(t=gd.create(r.z)),Rt(r.Z)||(t||(t=new oa(r.Z)),n=r.Z),Rt(r.q)||(r.M=(r.q-1)*3+1),Rt(r.h)||(r.h<12&&r.a===1?r.h+=12:r.h===12&&r.a===0&&(r.h=0)),r.G===0&&r.y&&(r.y=-r.y),Rt(r.u)||(r.S=G1(r.u)),[Object.keys(r).reduce((o,s)=>{let a=e(s);return a&&(o[a]=r[s]),o},{}),t,n]}var C1=null;function hve(){return C1||(C1=kt.fromMillis(1555555555555)),C1}function gve(r,e){if(r.literal)return r;let t=bs.macroTokenToFormatOpts(r.val),n=f9(t,e);return n==null||n.includes(void 0)?r:n}function d9(r,e){return Array.prototype.concat(...r.map(t=>gve(t,e)))}function p9(r,e,t){let n=d9(bs.parseFormat(t),r),i=n.map(s=>cve(s,r)),o=i.find(s=>s.invalidReason);if(o)return{input:e,tokens:n,invalidReason:o.invalidReason};{let[s,a]=pve(i),l=RegExp(s,"i"),[c,u]=fve(e,l,a),[d,f,p]=u?mve(u):[null,null,void 0];if(Fg(u,"a")&&Fg(u,"H"))throw new lf("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:n,regex:l,rawMatches:c,matches:u,result:d,zone:f,specificOffset:p}}}function vve(r,e,t){let{result:n,zone:i,specificOffset:o,invalidReason:s}=p9(r,e,t);return[n,i,o,s]}function f9(r,e){if(!r)return null;let n=bs.create(e,r).dtFormatter(hve()),i=n.formatToParts(),o=n.resolvedOptions();return i.map(s=>dve(s,r,o))}var m9=[0,31,59,90,120,151,181,212,243,273,304,334],h9=[0,31,60,91,121,152,182,213,244,274,305,335];function ia(r,e){return new ws("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${r}, which is invalid`)}function g9(r,e,t){let n=new Date(Date.UTC(r,e-1,t));r<100&&r>=0&&n.setUTCFullYear(n.getUTCFullYear()-1900);let i=n.getUTCDay();return i===0?7:i}function v9(r,e,t){return t+(cE(r)?h9:m9)[e-1]}function y9(r,e){let t=cE(r)?h9:m9,n=t.findIndex(o=>o<e),i=e-t[n];return{month:n+1,day:i}}function B1(r){let{year:e,month:t,day:n}=r,i=v9(e,t,n),o=g9(e,t,n),s=Math.floor((i-o+10)/7),a;return s<1?(a=e-1,s=pD(a)):s>pD(e)?(a=e+1,s=1):a=e,{weekYear:a,weekNumber:s,weekday:o,...CD(r)}}function p8(r){let{weekYear:e,weekNumber:t,weekday:n}=r,i=g9(e,1,4),o=oE(e),s=t*7+n-i-3,a;s<1?(a=e-1,s+=oE(a)):s>o?(a=e+1,s-=oE(e)):a=e;let{month:l,day:c}=y9(a,s);return{year:a,month:l,day:c,...CD(r)}}function x1(r){let{year:e,month:t,day:n}=r,i=v9(e,t,n);return{year:e,ordinal:i,...CD(r)}}function f8(r){let{year:e,ordinal:t}=r,{month:n,day:i}=y9(e,t);return{year:e,month:n,day:i,...CD(r)}}function yve(r){let e=yD(r.weekYear),t=jc(r.weekNumber,1,pD(r.weekYear)),n=jc(r.weekday,1,7);return e?t?n?!1:ia("weekday",r.weekday):ia("week",r.week):ia("weekYear",r.weekYear)}function bve(r){let e=yD(r.year),t=jc(r.ordinal,1,oE(r.year));return e?t?!1:ia("ordinal",r.ordinal):ia("year",r.year)}function b9(r){let e=yD(r.year),t=jc(r.month,1,12),n=jc(r.day,1,dD(r.year,r.month));return e?t?n?!1:ia("day",r.day):ia("month",r.month):ia("year",r.year)}function w9(r){let{hour:e,minute:t,second:n,millisecond:i}=r,o=jc(e,0,23)||e===24&&t===0&&n===0&&i===0,s=jc(t,0,59),a=jc(n,0,59),l=jc(i,0,999);return o?s?a?l?!1:ia("millisecond",i):ia("second",n):ia("minute",t):ia("hour",e)}var E1="Invalid DateTime",m8=864e13;function nD(r){return new ws("unsupported zone",`the zone "${r.name}" is not supported`)}function T1(r){return r.weekData===null&&(r.weekData=B1(r.c)),r.weekData}function af(r,e){let t={ts:r.ts,zone:r.zone,c:r.c,o:r.o,loc:r.loc,invalid:r.invalid};return new kt({...t,...e,old:t})}function C9(r,e,t){let n=r-e*60*1e3,i=t.offset(n);if(e===i)return[n,e];n-=(i-e)*60*1e3;let o=t.offset(n);return i===o?[n,i]:[r-Math.min(i,o)*60*1e3,Math.max(i,o)]}function iD(r,e){r+=e*60*1e3;let t=new Date(r);return{year:t.getUTCFullYear(),month:t.getUTCMonth()+1,day:t.getUTCDate(),hour:t.getUTCHours(),minute:t.getUTCMinutes(),second:t.getUTCSeconds(),millisecond:t.getUTCMilliseconds()}}function aD(r,e,t){return C9(bD(r),e,t)}function h8(r,e){let t=r.o,n=r.c.year+Math.trunc(e.years),i=r.c.month+Math.trunc(e.months)+Math.trunc(e.quarters)*3,o={...r.c,year:n,month:i,day:Math.min(r.c.day,dD(n,i))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},s=Xe.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),a=bD(o),[l,c]=C9(a,t,r.zone);return s!==0&&(l+=s,c=r.zone.offset(l)),{ts:l,o:c}}function tE(r,e,t,n,i,o){let{setZone:s,zone:a}=t;if(r&&Object.keys(r).length!==0||e){let l=e||a,c=kt.fromObject(r,{...t,zone:l,specificOffset:o});return s?c:c.setZone(a)}else return kt.invalid(new ws("unparsable",`the input "${i}" can't be parsed as ${n}`))}function oD(r,e,t=!0){return r.isValid?bs.create(Zr.create("en-US"),{allowZ:t,forceSimple:!0}).formatDateTimeFromString(r,e):null}function _1(r,e){let t=r.c.year>9999||r.c.year<0,n="";return t&&r.c.year>=0&&(n+="+"),n+=En(r.c.year,t?6:4),e?(n+="-",n+=En(r.c.month),n+="-",n+=En(r.c.day)):(n+=En(r.c.month),n+=En(r.c.day)),n}function g8(r,e,t,n,i,o){let s=En(r.c.hour);return e?(s+=":",s+=En(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=":")):s+=En(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=En(r.c.second),(r.c.millisecond!==0||!n)&&(s+=".",s+=En(r.c.millisecond,3))),i&&(r.isOffsetFixed&&r.offset===0&&!o?s+="Z":r.o<0?(s+="-",s+=En(Math.trunc(-r.o/60)),s+=":",s+=En(Math.trunc(-r.o%60))):(s+="+",s+=En(Math.trunc(r.o/60)),s+=":",s+=En(Math.trunc(r.o%60)))),o&&(s+="["+r.zone.ianaName+"]"),s}var x9={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},wve={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},Cve={ordinal:1,hour:0,minute:0,second:0,millisecond:0},E9=["year","month","day","hour","minute","second","millisecond"],xve=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],Eve=["year","ordinal","hour","minute","second","millisecond"];function v8(r){let e={year:"year",years:"year",month:"month",months:"month",day:"day",days:"day",hour:"hour",hours:"hour",minute:"minute",minutes:"minute",quarter:"quarter",quarters:"quarter",second:"second",seconds:"second",millisecond:"millisecond",milliseconds:"millisecond",weekday:"weekday",weekdays:"weekday",weeknumber:"weekNumber",weeksnumber:"weekNumber",weeknumbers:"weekNumber",weekyear:"weekYear",weekyears:"weekYear",ordinal:"ordinal"}[r.toLowerCase()];if(!e)throw new lD(r);return e}function y8(r,e){let t=hd(e.zone,Xr.defaultZone),n=Zr.fromObject(e),i=Xr.now(),o,s;if(Rt(r.year))o=i;else{for(let c of E9)Rt(r[c])&&(r[c]=x9[c]);let a=b9(r)||w9(r);if(a)return kt.invalid(a);let l=t.offset(i);[o,s]=aD(r,l,t)}return new kt({ts:o,zone:t,loc:n,o:s})}function b8(r,e,t){let n=Rt(t.round)?!0:t.round,i=(s,a)=>(s=Y1(s,n||t.calendary?0:2,!0),e.loc.clone(t).relFormatter(t).format(s,a)),o=s=>t.calendary?e.hasSame(r,s)?0:e.startOf(s).diff(r.startOf(s),s).get(s):e.diff(r,s).get(s);if(t.unit)return i(o(t.unit),t.unit);for(let s of t.units){let a=o(s);if(Math.abs(a)>=1)return i(a,s)}return i(r>e?-0:0,t.units[t.units.length-1])}function w8(r){let e={},t;return r.length>0&&typeof r[r.length-1]=="object"?(e=r[r.length-1],t=Array.from(r).slice(0,r.length-1)):t=Array.from(r),[e,t]}var kt=class r{constructor(e){let t=e.zone||Xr.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new ws("invalid input"):null)||(t.isValid?null:nD(t));this.ts=Rt(e.ts)?Xr.now():e.ts;let i=null,o=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[i,o]=[e.old.c,e.old.o];else{let a=t.offset(this.ts);i=iD(this.ts,a),n=Number.isNaN(i.year)?new ws("invalid input"):null,i=n?null:i,o=n?null:a}this._zone=t,this.loc=e.loc||Zr.create(),this.invalid=n,this.weekData=null,this.c=i,this.o=o,this.isLuxonDateTime=!0}static now(){return new r({})}static local(){let[e,t]=w8(arguments),[n,i,o,s,a,l,c]=t;return y8({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static utc(){let[e,t]=w8(arguments),[n,i,o,s,a,l,c]=t;return e.zone=oa.utcInstance,y8({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static fromJSDate(e,t={}){let n=Xhe(e)?e.valueOf():NaN;if(Number.isNaN(n))return r.invalid("invalid input");let i=hd(t.zone,Xr.defaultZone);return i.isValid?new r({ts:n,zone:i,loc:Zr.fromObject(t)}):r.invalid(nD(i))}static fromMillis(e,t={}){if(uf(e))return e<-m8||e>m8?r.invalid("Timestamp out of range"):new r({ts:e,zone:hd(t.zone,Xr.defaultZone),loc:Zr.fromObject(t)});throw new Wo(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(uf(e))return new r({ts:e*1e3,zone:hd(t.zone,Xr.defaultZone),loc:Zr.fromObject(t)});throw new Wo("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};let n=hd(t.zone,Xr.defaultZone);if(!n.isValid)return r.invalid(nD(n));let i=Xr.now(),o=Rt(t.specificOffset)?n.offset(i):t.specificOffset,s=fD(e,v8),a=!Rt(s.ordinal),l=!Rt(s.year),c=!Rt(s.month)||!Rt(s.day),u=l||c,d=s.weekYear||s.weekNumber,f=Zr.fromObject(t);if((u||a)&&d)throw new lf("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&a)throw new lf("Can't mix ordinal dates with month/day");let p=d||s.weekday&&!u,m,v,g=iD(i,o);p?(m=xve,v=wve,g=B1(g)):a?(m=Eve,v=Cve,g=x1(g)):(m=E9,v=x9);let y=!1;for(let P of m){let H=s[P];Rt(H)?y?s[P]=v[P]:s[P]=g[P]:y=!0}let w=p?yve(s):a?bve(s):b9(s),k=w||w9(s);if(k)return r.invalid(k);let C=p?p8(s):a?f8(s):s,[E,x]=aD(C,o,n),D=new r({ts:E,zone:n,o:x,loc:f});return s.weekday&&u&&e.weekday!==D.weekday?r.invalid("mismatched weekday",`you can't specify both a weekday of ${s.weekday} and a date of ${D.toISO()}`):D}static fromISO(e,t={}){let[n,i]=Vge(e);return tE(n,i,t,"ISO 8601",e)}static fromRFC2822(e,t={}){let[n,i]=Uge(e);return tE(n,i,t,"RFC 2822",e)}static fromHTTP(e,t={}){let[n,i]=qge(e);return tE(n,i,t,"HTTP",t)}static fromFormat(e,t,n={}){if(Rt(e)||Rt(t))throw new Wo("fromFormat requires an input string and a format");let{locale:i=null,numberingSystem:o=null}=n,s=Zr.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0}),[a,l,c,u]=vve(s,e,t);return u?r.invalid(u):tE(a,l,n,`format ${t}`,e,c)}static fromString(e,t,n={}){return r.fromFormat(e,t,n)}static fromSQL(e,t={}){let[n,i]=Kge(e);return tE(n,i,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new Wo("need to specify a reason the DateTime is invalid");let n=e instanceof ws?e:new ws(e,t);if(Xr.throwOnInvalid)throw new k1(n);return new r({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=f9(e,Zr.fromObject(t));return n?n.map(i=>i?i.val:null).join(""):null}static expandFormat(e,t={}){return d9(bs.parseFormat(e),Zr.fromObject(t)).map(i=>i.val).join("")}get(e){return this[e]}get isValid(){return this.invalid===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}get locale(){return this.isValid?this.loc.locale:null}get numberingSystem(){return this.isValid?this.loc.numberingSystem:null}get outputCalendar(){return this.isValid?this.loc.outputCalendar:null}get zone(){return this._zone}get zoneName(){return this.isValid?this.zone.name:null}get year(){return this.isValid?this.c.year:NaN}get quarter(){return this.isValid?Math.ceil(this.c.month/3):NaN}get month(){return this.isValid?this.c.month:NaN}get day(){return this.isValid?this.c.day:NaN}get hour(){return this.isValid?this.c.hour:NaN}get minute(){return this.isValid?this.c.minute:NaN}get second(){return this.isValid?this.c.second:NaN}get millisecond(){return this.isValid?this.c.millisecond:NaN}get weekYear(){return this.isValid?T1(this).weekYear:NaN}get weekNumber(){return this.isValid?T1(this).weekNumber:NaN}get weekday(){return this.isValid?T1(this).weekday:NaN}get ordinal(){return this.isValid?x1(this.c).ordinal:NaN}get monthShort(){return this.isValid?Dg.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?Dg.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?Dg.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?Dg.weekdays("long",{locObj:this.loc})[this.weekday-1]:null}get offset(){return this.isValid?+this.o:NaN}get offsetNameShort(){return this.isValid?this.zone.offsetName(this.ts,{format:"short",locale:this.locale}):null}get offsetNameLong(){return this.isValid?this.zone.offsetName(this.ts,{format:"long",locale:this.locale}):null}get isOffsetFixed(){return this.isValid?this.zone.isUniversal:null}get isInDST(){return this.isOffsetFixed?!1:this.offset>this.set({month:1,day:1}).offset||this.offset>this.set({month:5}).offset}getPossibleOffsets(){if(!this.isValid||this.isOffsetFixed)return[this];let e=864e5,t=6e4,n=bD(this.c),i=this.zone.offset(n-e),o=this.zone.offset(n+e),s=this.zone.offset(n-i*t),a=this.zone.offset(n-o*t);if(s===a)return[this];let l=n-s*t,c=n-a*t,u=iD(l,s),d=iD(c,a);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[af(this,{ts:l}),af(this,{ts:c})]:[this]}get isInLeapYear(){return cE(this.year)}get daysInMonth(){return dD(this.year,this.month)}get daysInYear(){return this.isValid?oE(this.year):NaN}get weeksInWeekYear(){return this.isValid?pD(this.weekYear):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:i}=bs.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:i}}toUTC(e=0,t={}){return this.setZone(oa.instance(e),t)}toLocal(){return this.setZone(Xr.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if(e=hd(e,Xr.defaultZone),e.equals(this.zone))return this;if(e.isValid){let i=this.ts;if(t||n){let o=e.offset(this.ts),s=this.toObject();[i]=aD(s,o,e)}return af(this,{ts:i,zone:e})}else return r.invalid(nD(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let i=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return af(this,{loc:i})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=fD(e,v8),n=!Rt(t.weekYear)||!Rt(t.weekNumber)||!Rt(t.weekday),i=!Rt(t.ordinal),o=!Rt(t.year),s=!Rt(t.month)||!Rt(t.day),a=o||s,l=t.weekYear||t.weekNumber;if((a||i)&&l)throw new lf("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(s&&i)throw new lf("Can't mix ordinal dates with month/day");let c;n?c=p8({...B1(this.c),...t}):Rt(t.ordinal)?(c={...this.toObject(),...t},Rt(t.day)&&(c.day=Math.min(dD(c.year,c.month),c.day))):c=f8({...x1(this.c),...t});let[u,d]=aD(c,this.o,this.zone);return af(this,{ts:u,o:d})}plus(e){if(!this.isValid)return this;let t=Xe.fromDurationLike(e);return af(this,h8(this,t))}minus(e){if(!this.isValid)return this;let t=Xe.fromDurationLike(e).negate();return af(this,h8(this,t))}startOf(e){if(!this.isValid)return this;let t={},n=Xe.normalizeUnit(e);switch(n){case"years":t.month=1;case"quarters":case"months":t.day=1;case"weeks":case"days":t.hour=0;case"hours":t.minute=0;case"minutes":t.second=0;case"seconds":t.millisecond=0;break}if(n==="weeks"&&(t.weekday=1),n==="quarters"){let i=Math.ceil(this.month/3);t.month=(i-1)*3+1}return this.set(t)}endOf(e){return this.isValid?this.plus({[e]:1}).startOf(e).minus(1):this}toFormat(e,t={}){return this.isValid?bs.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):E1}toLocaleString(e=cD,t={}){return this.isValid?bs.create(this.loc.clone(t),e).formatDateTime(this):E1}toLocaleParts(e={}){return this.isValid?bs.create(this.loc.clone(e),e).formatDateTimeParts(this):[]}toISO({format:e="extended",suppressSeconds:t=!1,suppressMilliseconds:n=!1,includeOffset:i=!0,extendedZone:o=!1}={}){if(!this.isValid)return null;let s=e==="extended",a=_1(this,s);return a+="T",a+=g8(this,s,t,n,i,o),a}toISODate({format:e="extended"}={}){return this.isValid?_1(this,e==="extended"):null}toISOWeekDate(){return oD(this,"kkkk-'W'WW-c")}toISOTime({suppressMilliseconds:e=!1,suppressSeconds:t=!1,includeOffset:n=!0,includePrefix:i=!1,extendedZone:o=!1,format:s="extended"}={}){return this.isValid?(i?"T":"")+g8(this,s==="extended",t,e,n,o):null}toRFC2822(){return oD(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return oD(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?_1(this,!0):null}toSQLTime({includeOffset:e=!0,includeZone:t=!1,includeOffsetSpace:n=!0}={}){let i="HH:mm:ss.SSS";return(t||e)&&(n&&(i+=" "),t?i+="z":e&&(i+="ZZ")),oD(this,i,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():E1}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid)return Xe.invalid("created by diffing an invalid DateTime");let i={locale:this.locale,numberingSystem:this.numberingSystem,...n},o=Zhe(t).map(Xe.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,l=s?e:this,c=rve(a,l,o,i);return s?c.negate():c}diffNow(e="milliseconds",t={}){return this.diff(r.now(),e,t)}until(e){return this.isValid?Pg.fromDateTimes(this,e):this}hasSame(e,t){if(!this.isValid)return!1;let n=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t)<=n&&n<=i.endOf(t)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;let t=e.base||r.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0,i=["years","months","days","hours","minutes","seconds"],o=e.unit;return Array.isArray(e.unit)&&(i=e.unit,o=void 0),b8(t,this.plus(n),{...e,numeric:"always",units:i,unit:o})}toRelativeCalendar(e={}){return this.isValid?b8(e.base||r.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(r.isDateTime))throw new Wo("min requires all arguments be DateTimes");return n8(e,t=>t.valueOf(),Math.min)}static max(...e){if(!e.every(r.isDateTime))throw new Wo("max requires all arguments be DateTimes");return n8(e,t=>t.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:i=null,numberingSystem:o=null}=n,s=Zr.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0});return p9(s,e,t)}static fromStringExplain(e,t,n={}){return r.fromFormatExplain(e,t,n)}static get DATE_SHORT(){return cD}static get DATE_MED(){return A8}static get DATE_MED_WITH_WEEKDAY(){return $he}static get DATE_FULL(){return k8}static get DATE_HUGE(){return S8}static get TIME_SIMPLE(){return D8}static get TIME_WITH_SECONDS(){return I8}static get TIME_WITH_SHORT_OFFSET(){return P8}static get TIME_WITH_LONG_OFFSET(){return F8}static get TIME_24_SIMPLE(){return M8}static get TIME_24_WITH_SECONDS(){return R8}static get TIME_24_WITH_SHORT_OFFSET(){return $8}static get TIME_24_WITH_LONG_OFFSET(){return O8}static get DATETIME_SHORT(){return N8}static get DATETIME_SHORT_WITH_SECONDS(){return L8}static get DATETIME_MED(){return B8}static get DATETIME_MED_WITH_SECONDS(){return V8}static get DATETIME_MED_WITH_WEEKDAY(){return Ohe}static get DATETIME_FULL(){return U8}static get DATETIME_FULL_WITH_SECONDS(){return q8}static get DATETIME_HUGE(){return W8}static get DATETIME_HUGE_WITH_SECONDS(){return z8}};function rE(r){if(kt.isDateTime(r))return r;if(r&&r.valueOf&&uf(r.valueOf()))return kt.fromJSDate(r);if(r&&typeof r=="object")return kt.fromObject(r);throw new Wo(`Unknown datetime argument: ${r}, of type ${typeof r}`)}var J1={renderNullAs:"\\-",taskCompletionTracking:!1,taskCompletionUseEmojiShorthand:!1,taskCompletionText:"completion",taskCompletionDateFormat:"yyyy-MM-dd",recursiveSubTaskCompletion:!1,warnOnEmptyResult:!0,refreshEnabled:!0,refreshInterval:2500,defaultDateFormat:"MMMM dd, yyyy",defaultDateTimeFormat:"h:mm a - MMMM dd, yyyy",maxRecursiveRenderDepth:4,tableIdColumnName:"File",tableGroupColumnName:"Group",showResultCount:!0},Tve={allowHtml:!0};({...J1,...Tve});var V1=class r{constructor(e){ae(this,"value");ae(this,"successful");this.value=e,this.successful=!0}map(e){return new r(e(this.value))}flatMap(e){return e(this.value)}mapErr(e){return this}bimap(e,t){return this.map(e)}orElse(e){return this.value}cast(){return this}orElseThrow(e){return this.value}},U1=class r{constructor(e){ae(this,"error");ae(this,"successful");this.error=e,this.successful=!1}map(e){return this}flatMap(e){return this}mapErr(e){return new r(e(this.error))}bimap(e,t){return this.mapErr(t)}orElse(e){return e}cast(){return this}orElseThrow(e){throw e?new Error(e(this.error)):new Error(""+this.error)}},mD;(function(r){function e(o){return new V1(o)}r.success=e;function t(o){return new U1(o)}r.failure=t;function n(o,s,a){return o.successful?s.successful?a(o.value,s.value):t(s.error):t(o.error)}r.flatMap2=n;function i(o,s,a){return n(o,s,(l,c)=>e(a(l,c)))}r.map2=i})(mD||(mD={}));var _ve=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},hD={exports:{}};hD.exports;(function(r,e){(function(t,n){r.exports=n()})(typeof self<"u"?self:_ve,function(){return(function(t){var n={};function i(o){if(n[o])return n[o].exports;var s=n[o]={i:o,l:!1,exports:{}};return t[o].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=n,i.d=function(o,s,a){i.o(o,s)||Object.defineProperty(o,s,{configurable:!1,enumerable:!0,get:a})},i.r=function(o){Object.defineProperty(o,"__esModule",{value:!0})},i.n=function(o){var s=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(s,"a",s),s},i.o=function(o,s){return Object.prototype.hasOwnProperty.call(o,s)},i.p="",i(i.s=0)})([function(t,n,i){function o(T){if(!(this instanceof o))return new o(T);this._=T}var s=o.prototype;function a(T,A){for(var L=0;L<T;L++)A(L)}function l(T,A,L){return(function(Q,ee){a(ee.length,function(ue){Q(ee[ue],ue,ee)})})(function(Q,ee,ue){A=T(A,Q,ee,ue)},L),A}function c(T,A){return l(function(L,Q,ee,ue){return L.concat([T(Q,ee,ue)])},[],A)}function u(T,A){var L={v:0,buf:A};return a(T,function(){var Q;L={v:L.v<<1|(Q=L.buf,Q[0]>>7),buf:(function(ee){var ue=l(function(ve,Ue,bt,Fr){return ve.concat(bt===Fr.length-1?Buffer.from([Ue,0]).readUInt16BE(0):Fr.readUInt16BE(bt))},[],ee);return Buffer.from(c(function(ve){return(ve<<1&65535)>>8},ue))})(L.buf)}}),L}function d(){return typeof Buffer<"u"}function f(){if(!d())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function p(T){f();var A=l(function(ue,ve){return ue+ve},0,T);if(A%8!=0)throw new Error("The bits ["+T.join(", ")+"] add up to "+A+" which is not an even number of bytes; the total should be divisible by 8");var L,Q=A/8,ee=(L=function(ue){return ue>48},l(function(ue,ve){return ue||(L(ve)?ve:ue)},null,T));if(ee)throw new Error(ee+" bit range requested exceeds 48 bit (6 byte) Number max.");return new o(function(ue,ve){var Ue=Q+ve;return Ue>ue.length?P(ve,Q.toString()+" bytes"):D(Ue,l(function(bt,Fr){var jt=u(Fr,bt.buf);return{coll:bt.coll.concat(jt.v),buf:jt.buf}},{coll:[],buf:ue.slice(ve,Ue)},T).coll)})}function m(T,A){return new o(function(L,Q){return f(),Q+A>L.length?P(Q,A+" bytes for "+T):D(Q+A,L.slice(Q,Q+A))})}function v(T,A){if(typeof(L=A)!="number"||Math.floor(L)!==L||A<0||A>6)throw new Error(T+" requires integer length in range [0, 6].");var L}function g(T){return v("uintBE",T),m("uintBE("+T+")",T).map(function(A){return A.readUIntBE(0,T)})}function y(T){return v("uintLE",T),m("uintLE("+T+")",T).map(function(A){return A.readUIntLE(0,T)})}function w(T){return v("intBE",T),m("intBE("+T+")",T).map(function(A){return A.readIntBE(0,T)})}function k(T){return v("intLE",T),m("intLE("+T+")",T).map(function(A){return A.readIntLE(0,T)})}function C(T){return T instanceof o}function E(T){return{}.toString.call(T)==="[object Array]"}function x(T){return d()&&Buffer.isBuffer(T)}function D(T,A){return{status:!0,index:T,value:A,furthest:-1,expected:[]}}function P(T,A){return E(A)||(A=[A]),{status:!1,index:-1,value:null,furthest:T,expected:A}}function H(T,A){if(!A||T.furthest>A.furthest)return T;var L=T.furthest===A.furthest?(function(Q,ee){if((function(){if(o._supportsSet!==void 0)return o._supportsSet;var pr=typeof Set<"u";return o._supportsSet=pr,pr})()&&Array.from){for(var ue=new Set(Q),ve=0;ve<ee.length;ve++)ue.add(ee[ve]);var Ue=Array.from(ue);return Ue.sort(),Ue}for(var bt={},Fr=0;Fr<Q.length;Fr++)bt[Q[Fr]]=!0;for(var jt=0;jt<ee.length;jt++)bt[ee[jt]]=!0;var Oi=[];for(var wt in bt)({}).hasOwnProperty.call(bt,wt)&&Oi.push(wt);return Oi.sort(),Oi})(T.expected,A.expected):A.expected;return{status:T.status,index:T.index,value:T.value,furthest:A.furthest,expected:L}}var U={};function oe(T,A){if(x(T))return{offset:A,line:-1,column:-1};T in U||(U[T]={});for(var L=U[T],Q=0,ee=0,ue=0,ve=A;ve>=0;){if(ve in L){Q=L[ve].line,ue===0&&(ue=L[ve].lineStart);break}(T.charAt(ve)===`
`||T.charAt(ve)==="\r"&&T.charAt(ve+1)!==`
`)&&(ee++,ue===0&&(ue=ve+1)),ve--}var Ue=Q+ee,bt=A-ue;return L[A]={line:Ue,lineStart:ue},{offset:A,line:Ue+1,column:bt+1}}function ce(T){if(!C(T))throw new Error("not a parser: "+T)}function O(T,A){return typeof T=="string"?T.charAt(A):T[A]}function G(T){if(typeof T!="number")throw new Error("not a number: "+T)}function V(T){if(typeof T!="function")throw new Error("not a function: "+T)}function F(T){if(typeof T!="string")throw new Error("not a string: "+T)}var Z=2,z=3,Y=8,K=5*Y,se=4*Y,pe=" ";function ge(T,A){return new Array(A+1).join(T)}function be(T,A,L){var Q=A-T.length;return Q<=0?T:ge(L,Q)+T}function Be(T,A,L,Q){return{from:T-A>0?T-A:0,to:T+L>Q?Q:T+L}}function Se(T,A){var L,Q,ee,ue,ve,Ue=A.index,bt=Ue.offset,Fr=1;if(bt===T.length)return"Got the end of the input";if(x(T)){var jt=bt-bt%Y,Oi=bt-jt,wt=Be(jt,K,se+Y,T.length),pr=c(function(St){return c(function(To){return be(To.toString(16),2,"0")},St)},(function(St,To){var pa=St.length,_s=[],cn=0;if(pa<=To)return[St.slice()];for(var An=0;An<pa;An++)_s[cn]||_s.push([]),_s[cn].push(St[An]),(An+1)%To==0&&cn++;return _s})(T.slice(wt.from,wt.to).toJSON().data,Y));ue=(function(St){return St.from===0&&St.to===1?{from:St.from,to:St.to}:{from:St.from/Y,to:Math.floor(St.to/Y)}})(wt),Q=jt/Y,L=3*Oi,Oi>=4&&(L+=1),Fr=2,ee=c(function(St){return St.length<=4?St.join(" "):St.slice(0,4).join(" ")+" "+St.slice(4).join(" ")},pr),(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2)}else{var Sr=T.split(/\r\n|[\n\r\u2028\u2029]/);L=Ue.column-1,Q=Ue.line-1,ue=Be(Q,Z,z,Sr.length),ee=Sr.slice(ue.from,ue.to),ve=ue.to.toString().length}var Yn=Q-ue.from;return x(T)&&(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2),l(function(St,To,pa){var _s,cn=pa===Yn,An=cn?"> ":pe;return _s=x(T)?be((8*(ue.from+pa)).toString(16),ve,"0"):be((ue.from+pa+1).toString(),ve," "),[].concat(St,[An+_s+" | "+To],cn?[pe+ge(" ",ve)+" | "+be("",L," ")+ge("^",Fr)]:[])},[],ee).join(`
`)}function ut(T,A){return[`
`,"-- PARSING FAILED "+ge("-",50),`
`,Se(T,A),`
`,(L=A.expected,L.length===1?`Expected:
`+L[0]:`Expected one of the following:
`+L.join(", ")),`
`].join("");var L}function Ne(T){return T.flags!==void 0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}function Qe(){for(var T=[].slice.call(arguments),A=T.length,L=0;L<A;L+=1)ce(T[L]);return o(function(Q,ee){for(var ue,ve=new Array(A),Ue=0;Ue<A;Ue+=1){if(!(ue=H(T[Ue]._(Q,ee),ue)).status)return ue;ve[Ue]=ue.value,ee=ue.index}return H(D(ee,ve),ue)})}function Ze(){var T=[].slice.call(arguments);if(T.length===0)throw new Error("seqMap needs at least one argument");var A=T.pop();return V(A),Qe.apply(null,T).map(function(L){return A.apply(null,L)})}function ye(){var T=[].slice.call(arguments),A=T.length;if(A===0)return dt("zero alternates");for(var L=0;L<A;L+=1)ce(T[L]);return o(function(Q,ee){for(var ue,ve=0;ve<T.length;ve+=1)if((ue=H(T[ve]._(Q,ee),ue)).status)return ue;return ue})}function We(T,A){return gt(T,A).or(Ve([]))}function gt(T,A){return ce(T),ce(A),Ze(T,A.then(T).many(),function(L,Q){return[L].concat(Q)})}function He(T){F(T);var A="'"+T+"'";return o(function(L,Q){var ee=Q+T.length,ue=L.slice(Q,ee);return ue===T?D(ee,ue):P(Q,A)})}function Te(T,A){(function(ee){if(!(ee instanceof RegExp))throw new Error("not a regexp: "+ee);for(var ue=Ne(ee),ve=0;ve<ue.length;ve++){var Ue=ue.charAt(ve);if(Ue!=="i"&&Ue!=="m"&&Ue!=="u"&&Ue!=="s")throw new Error('unsupported regexp flag "'+Ue+'": '+ee)}})(T),arguments.length>=2?G(A):A=0;var L=(function(ee){return RegExp("^(?:"+ee.source+")",Ne(ee))})(T),Q=""+T;return o(function(ee,ue){var ve=L.exec(ee.slice(ue));if(ve){if(0<=A&&A<=ve.length){var Ue=ve[0],bt=ve[A];return D(ue+Ue.length,bt)}return P(ue,"valid match group (0 to "+ve.length+") in "+Q)}return P(ue,Q)})}function Ve(T){return o(function(A,L){return D(L,T)})}function dt(T){return o(function(A,L){return P(L,T)})}function or(T){if(C(T))return o(function(A,L){var Q=T._(A,L);return Q.index=L,Q.value="",Q});if(typeof T=="string")return or(He(T));if(T instanceof RegExp)return or(Te(T));throw new Error("not a string, regexp, or parser: "+T)}function yr(T){return ce(T),o(function(A,L){var Q=T._(A,L),ee=A.slice(L,Q.index);return Q.status?P(L,'not "'+ee+'"'):D(L,null)})}function Ft(T){return V(T),o(function(A,L){var Q=O(A,L);return L<A.length&&T(Q)?D(L+1,Q):P(L,"a character/byte matching "+T)})}function kr(T,A){arguments.length<2&&(A=T,T=void 0);var L=o(function(Q,ee){return L._=A()._,L._(Q,ee)});return T?L.desc(T):L}function ur(){return dt("fantasy-land/empty")}s.parse=function(T){if(typeof T!="string"&&!x(T))throw new Error(".parse must be called with a string or Buffer as its argument");var A,L=this.skip(Eo)._(T,0);return A=L.status?{status:!0,value:L.value}:{status:!1,index:oe(T,L.furthest),expected:L.expected},delete U[T],A},s.tryParse=function(T){var A=this.parse(T);if(A.status)return A.value;var L=ut(T,A),Q=new Error(L);throw Q.type="ParsimmonError",Q.result=A,Q},s.assert=function(T,A){return this.chain(function(L){return T(L)?Ve(L):dt(A)})},s.or=function(T){return ye(this,T)},s.trim=function(T){return this.wrap(T,T)},s.wrap=function(T,A){return Ze(T,this,A,function(L,Q){return Q})},s.thru=function(T){return T(this)},s.then=function(T){return ce(T),Qe(this,T).map(function(A){return A[1]})},s.many=function(){var T=this;return o(function(A,L){for(var Q=[],ee=void 0;;){if(!(ee=H(T._(A,L),ee)).status)return H(D(L,Q),ee);if(L===ee.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");L=ee.index,Q.push(ee.value)}})},s.tieWith=function(T){return F(T),this.map(function(A){if((function(ee){if(!E(ee))throw new Error("not an array: "+ee)})(A),A.length){F(A[0]);for(var L=A[0],Q=1;Q<A.length;Q++)F(A[Q]),L+=T+A[Q];return L}return""})},s.tie=function(){return this.tieWith("")},s.times=function(T,A){var L=this;return arguments.length<2&&(A=T),G(T),G(A),o(function(Q,ee){for(var ue=[],ve=void 0,Ue=void 0,bt=0;bt<T;bt+=1){if(Ue=H(ve=L._(Q,ee),Ue),!ve.status)return Ue;ee=ve.index,ue.push(ve.value)}for(;bt<A&&(Ue=H(ve=L._(Q,ee),Ue),ve.status);bt+=1)ee=ve.index,ue.push(ve.value);return H(D(ee,ue),Ue)})},s.result=function(T){return this.map(function(){return T})},s.atMost=function(T){return this.times(0,T)},s.atLeast=function(T){return Ze(this.times(T),this.many(),function(A,L){return A.concat(L)})},s.map=function(T){V(T);var A=this;return o(function(L,Q){var ee=A._(L,Q);return ee.status?H(D(ee.index,T(ee.value)),ee):ee})},s.contramap=function(T){V(T);var A=this;return o(function(L,Q){var ee=A.parse(T(L.slice(Q)));return ee.status?D(Q+L.length,ee.value):ee})},s.promap=function(T,A){return V(T),V(A),this.contramap(T).map(A)},s.skip=function(T){return Qe(this,T).map(function(A){return A[0]})},s.mark=function(){return Ze(pt,this,pt,function(T,A,L){return{start:T,value:A,end:L}})},s.node=function(T){return Ze(pt,this,pt,function(A,L,Q){return{name:T,value:L,start:A,end:Q}})},s.sepBy=function(T){return We(this,T)},s.sepBy1=function(T){return gt(this,T)},s.lookahead=function(T){return this.skip(or(T))},s.notFollowedBy=function(T){return this.skip(yr(T))},s.desc=function(T){E(T)||(T=[T]);var A=this;return o(function(L,Q){var ee=A._(L,Q);return ee.status||(ee.expected=T),ee})},s.fallback=function(T){return this.or(Ve(T))},s.ap=function(T){return Ze(T,this,function(A,L){return A(L)})},s.chain=function(T){var A=this;return o(function(L,Q){var ee=A._(L,Q);return ee.status?H(T(ee.value)._(L,ee.index),ee):ee})},s.concat=s.or,s.empty=ur,s.of=Ve,s["fantasy-land/ap"]=s.ap,s["fantasy-land/chain"]=s.chain,s["fantasy-land/concat"]=s.concat,s["fantasy-land/empty"]=s.empty,s["fantasy-land/of"]=s.of,s["fantasy-land/map"]=s.map;var pt=o(function(T,A){return D(A,oe(T,A))}),Mt=o(function(T,A){return A>=T.length?P(A,"any character/byte"):D(A+1,O(T,A))}),jn=o(function(T,A){return D(T.length,T.slice(A))}),Eo=o(function(T,A){return A<T.length?P(A,"EOF"):D(A,null)}),Ts=Te(/[0-9]/).desc("a digit"),Gn=Te(/[0-9]*/).desc("optional digits"),ne=Te(/[a-z]/i).desc("a letter"),Ie=Te(/[a-z]*/i).desc("optional letters"),dr=Te(/\s*/).desc("optional whitespace"),br=Te(/\s+/).desc("whitespace"),_n=He("\r"),jo=He(`
`),Ja=He(`\r
`),el=ye(Ja,jo,_n).desc("newline"),ru=ye(el,Eo);o.all=jn,o.alt=ye,o.any=Mt,o.cr=_n,o.createLanguage=function(T){var A={};for(var L in T)({}).hasOwnProperty.call(T,L)&&(function(Q){A[Q]=kr(function(){return T[Q](A)})})(L);return A},o.crlf=Ja,o.custom=function(T){return o(T(D,P))},o.digit=Ts,o.digits=Gn,o.empty=ur,o.end=ru,o.eof=Eo,o.fail=dt,o.formatError=ut,o.index=pt,o.isParser=C,o.lazy=kr,o.letter=ne,o.letters=Ie,o.lf=jo,o.lookahead=or,o.makeFailure=P,o.makeSuccess=D,o.newline=el,o.noneOf=function(T){return Ft(function(A){return T.indexOf(A)<0}).desc("none of '"+T+"'")},o.notFollowedBy=yr,o.of=Ve,o.oneOf=function(T){for(var A=T.split(""),L=0;L<A.length;L++)A[L]="'"+A[L]+"'";return Ft(function(Q){return T.indexOf(Q)>=0}).desc(A)},o.optWhitespace=dr,o.Parser=o,o.range=function(T,A){return Ft(function(L){return T<=L&&L<=A}).desc(T+"-"+A)},o.regex=Te,o.regexp=Te,o.sepBy=We,o.sepBy1=gt,o.seq=Qe,o.seqMap=Ze,o.seqObj=function(){for(var T,A={},L=0,Q=(T=arguments,Array.prototype.slice.call(T)),ee=Q.length,ue=0;ue<ee;ue+=1){var ve=Q[ue];if(!C(ve)){if(E(ve)&&ve.length===2&&typeof ve[0]=="string"&&C(ve[1])){var Ue=ve[0];if(Object.prototype.hasOwnProperty.call(A,Ue))throw new Error("seqObj: duplicate key "+Ue);A[Ue]=!0,L++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(L===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(bt,Fr){for(var jt,Oi={},wt=0;wt<ee;wt+=1){var pr,Sr;if(E(Q[wt])?(pr=Q[wt][0],Sr=Q[wt][1]):(pr=null,Sr=Q[wt]),!(jt=H(Sr._(bt,Fr),jt)).status)return jt;pr&&(Oi[pr]=jt.value),Fr=jt.index}return H(D(Fr,Oi),jt)})},o.string=He,o.succeed=Ve,o.takeWhile=function(T){return V(T),o(function(A,L){for(var Q=L;Q<A.length&&T(O(A,Q));)Q++;return D(Q,A.slice(L,Q))})},o.test=Ft,o.whitespace=br,o["fantasy-land/empty"]=ur,o["fantasy-land/of"]=Ve,o.Binary={bitSeq:p,bitSeqObj:function(T){f();var A={},L=0,Q=c(function(ue){if(E(ue)){var ve=ue;if(ve.length!==2)throw new Error("["+ve.join(", ")+"] should be length 2, got length "+ve.length);if(F(ve[0]),G(ve[1]),Object.prototype.hasOwnProperty.call(A,ve[0]))throw new Error("duplicate key in bitSeqObj: "+ve[0]);return A[ve[0]]=!0,L++,ve}return G(ue),[null,ue]},T);if(L<1)throw new Error("bitSeqObj expects at least one named pair, got ["+T.join(", ")+"]");var ee=c(function(ue){return ue[0]},Q);return p(c(function(ue){return ue[1]},Q)).map(function(ue){return l(function(ve,Ue){return Ue[0]!==null&&(ve[Ue[0]]=Ue[1]),ve},{},c(function(ve,Ue){return[ve,ue[Ue]]},ee))})},byte:function(T){if(f(),G(T),T>255)throw new Error("Value specified to byte constructor ("+T+"=0x"+T.toString(16)+") is larger in value than a single byte.");var A=(T>15?"0x":"0x0")+T.toString(16);return o(function(L,Q){var ee=O(L,Q);return ee===T?D(Q+1,ee):P(Q,A)})},buffer:function(T){return m("buffer",T).map(function(A){return Buffer.from(A)})},encodedString:function(T,A){return m("string",A).map(function(L){return L.toString(T)})},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:w,int8BE:w(1),int16BE:w(2),int32BE:w(4),intLE:k,int8LE:k(1),int16LE:k(2),int32LE:k(4),floatBE:m("floatBE",4).map(function(T){return T.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(T){return T.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(T){return T.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(T){return T.readDoubleLE(0)})},t.exports=o}])})})(hD,hD.exports);var R=hD.exports,eN=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26D3\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26F9(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC3\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF5\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC08\uDC26](?:\u200D\u2B1B)?|[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E\uDC70\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4-\uDEB6](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED7\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E[\uDDAF-\uDDB3\uDDBC\uDDBD])|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE])))?))?|\uDC6F(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDD75(?:\uFE0F|\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3D\uDD3E\uDDB8\uDDB9\uDDCD-\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE88\uDE90-\uDEBD\uDEBF-\uDEC2\uDECE-\uDEDB\uDEE0-\uDEE8]|\uDD3C(?:\u200D[\u2640\u2642]\uFE0F?|\uD83C[\uDFFB-\uDFFF])?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF-\uDDB3\uDDBC\uDDBD]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;function T9(r){return r==null?r:r.shiftToAll().normalize()}function C8(r){return r.includes("/")&&(r=r.substring(r.lastIndexOf("/")+1)),r.endsWith(".md")&&(r=r.substring(0,r.length-3)),r}R.alt(R.regex(new RegExp(eN(),"")),R.regex(/[0-9\p{Letter}_-]+/u).map(r=>r.toLocaleLowerCase()),R.whitespace.map(r=>"-"),R.any.map(r=>"")).many().map(r=>r.join(""));var Ave=R.alt(R.regex(new RegExp(eN(),"")),R.regex(/[0-9\p{Letter}_-]+/u),R.whitespace.map(r=>" "),R.any.map(r=>" ")).many().map(r=>r.join("").split(/\s+/).join(" ").trim());function kve(r){return Ave.tryParse(r)}function Sve(r){return r=T9(r),r=Xe.fromObject(Object.fromEntries(Object.entries(r.toObject()).filter(([,e])=>e!=0))),r.toHuman()}var aE;(function(r){function e(C,E=J1,x=!1){let D=t(C);if(!D)return E.renderNullAs;switch(D.type){case"null":return E.renderNullAs;case"string":return D.value;case"number":case"boolean":return""+D.value;case"html":return D.value.outerHTML;case"widget":return D.value.markdown();case"link":return D.value.markdown();case"function":return"<function>";case"array":let P="";return x&&(P+="["),P+=D.value.map(H=>e(H,E,!0)).join(", "),x&&(P+="]"),P;case"object":return"{ "+Object.entries(D.value).map(H=>H[0]+": "+e(H[1],E,!0)).join(", ")+" }";case"date":return D.value.second==0&&D.value.hour==0&&D.value.minute==0?D.value.toFormat(E.defaultDateFormat):D.value.toFormat(E.defaultDateTimeFormat);case"duration":return Sve(D.value)}}r.toString=e;function t(C){return f(C)?{type:"null",value:C}:c(C)?{type:"number",value:C}:l(C)?{type:"string",value:C}:m(C)?{type:"boolean",value:C}:d(C)?{type:"duration",value:C}:u(C)?{type:"date",value:C}:g(C)?{type:"widget",value:C}:p(C)?{type:"array",value:C}:v(C)?{type:"link",value:C}:k(C)?{type:"function",value:C}:y(C)?{type:"html",value:C}:w(C)?{type:"object",value:C}:void 0}r.wrapValue=t;function n(C,E){if(w(C)){let x={};for(let[D,P]of Object.entries(C))x[D]=n(P,E);return x}else if(p(C)){let x=[];for(let D of C)x.push(n(D,E));return x}else return E(C)}r.mapLeaves=n;function i(C,E,x){if(C===void 0&&(C=null),E===void 0&&(E=null),C===null&&E===null)return 0;if(C===null)return-1;if(E===null)return 1;let D=t(C),P=t(E);if(D===void 0&&P===void 0)return 0;if(D===void 0)return-1;if(P===void 0)return 1;if(D.type!=P.type)return D.type.localeCompare(P.type);if(D.value===P.value)return 0;switch(D.type){case"string":return D.value.localeCompare(P.value);case"number":return D.value<P.value?-1:D.value==P.value?0:1;case"null":return 0;case"boolean":return D.value==P.value?0:D.value?1:-1;case"link":let H=D.value,U=P.value,oe=x??(se=>se),ce=oe(H.path).localeCompare(oe(U.path));if(ce!=0)return ce;let O=H.type.localeCompare(U.type);return O!=0?O:H.subpath&&!U.subpath?1:!H.subpath&&U.subpath?-1:!H.subpath&&!U.subpath?0:(H.subpath??"").localeCompare(U.subpath??"");case"date":return D.value<P.value?-1:D.value.equals(P.value)?0:1;case"duration":return D.value<P.value?-1:D.value.equals(P.value)?0:1;case"array":let G=D.value,V=P.value;for(let se=0;se<Math.min(G.length,V.length);se++){let pe=i(G[se],V[se]);if(pe!=0)return pe}return G.length-V.length;case"object":let F=D.value,Z=P.value,z=Array.from(Object.keys(F)),Y=Array.from(Object.keys(Z));z.sort(),Y.sort();let K=i(z,Y);if(K!=0)return K;for(let se of z){let pe=i(F[se],Z[se]);if(pe!=0)return pe}return 0;case"widget":case"html":case"function":return 0}}r.compareValue=i;function o(C){return t(C)?.type}r.typeOf=o;function s(C){let E=t(C);if(!E)return!1;switch(E.type){case"number":return E.value!=0;case"string":return E.value.length>0;case"boolean":return E.value;case"link":return!!E.value.path;case"date":return E.value.toMillis()!=0;case"duration":return E.value.as("seconds")!=0;case"object":return Object.keys(E.value).length>0;case"array":return E.value.length>0;case"null":return!1;case"html":case"widget":case"function":return!0}}r.isTruthy=s;function a(C){if(C==null)return C;if(r.isArray(C))return[].concat(C.map(E=>a(E)));if(r.isObject(C)){let E={};for(let[x,D]of Object.entries(C))E[x]=a(D);return E}else return C}r.deepCopy=a;function l(C){return typeof C=="string"}r.isString=l;function c(C){return typeof C=="number"}r.isNumber=c;function u(C){return C instanceof kt}r.isDate=u;function d(C){return C instanceof Xe}r.isDuration=d;function f(C){return C==null}r.isNull=f;function p(C){return Array.isArray(C)}r.isArray=p;function m(C){return typeof C=="boolean"}r.isBoolean=m;function v(C){return C instanceof gD}r.isLink=v;function g(C){return C instanceof lE}r.isWidget=g;function y(C){return typeof HTMLElement<"u"?C instanceof HTMLElement:!1}r.isHtml=y;function w(C){return typeof C=="object"&&!y(C)&&!g(C)&&!p(C)&&!d(C)&&!u(C)&&!v(C)&&C!==void 0&&!f(C)}r.isObject=w;function k(C){return typeof C=="function"}r.isFunction=k})(aE||(aE={}));var x8;(function(r){function e(i){return aE.isObject(i)&&Object.keys(i).length==2&&"key"in i&&"rows"in i}r.isElementGroup=e;function t(i){for(let o of i)if(!e(o))return!1;return!0}r.isGrouping=t;function n(i){if(t(i)){let o=0;for(let s of i)o+=n(s.rows);return o}else return i.length}r.count=n})(x8||(x8={}));var gD=class r{constructor(e){ae(this,"path");ae(this,"display");ae(this,"subpath");ae(this,"embed");ae(this,"type");Object.assign(this,e)}static file(e,t=!1,n){return new r({path:e,embed:t,display:n,subpath:void 0,type:"file"})}static infer(e,t=!1,n){if(e.includes("#^")){let i=e.split("#^");return r.block(i[0],i[1],t,n)}else if(e.includes("#")){let i=e.split("#");return r.header(i[0],i[1],t,n)}else return r.file(e,t,n)}static header(e,t,n,i){return new r({path:e,embed:n,display:i,subpath:kve(t),type:"header"})}static block(e,t,n,i){return new r({path:e,embed:n,display:i,subpath:t,type:"block"})}static fromObject(e){return new r(e)}equals(e){return e==null||e==null?!1:this.path==e.path&&this.type==e.type&&this.subpath==e.subpath}toString(){return this.markdown()}toObject(){return{path:this.path,type:this.type,subpath:this.subpath,display:this.display,embed:this.embed}}withPath(e){return new r(Object.assign({},this,{path:e}))}withDisplay(e){return new r(Object.assign({},this,{display:e}))}withHeader(e){return r.header(this.path,e,this.embed,this.display)}toFile(){return r.file(this.path,this.embed,this.display)}toEmbed(){if(this.embed)return this;{let e=new r(this);return e.embed=!0,e}}fromEmbed(){if(this.embed){let e=new r(this);return e.embed=!1,e}else return this}markdown(){let e=(this.embed?"!":"")+"[["+this.obsidianLink();return this.display?e+="|"+this.display:(e+="|"+C8(this.path),(this.type=="header"||this.type=="block")&&(e+=" > "+this.subpath)),e+="]]",e}obsidianLink(){let e=this.path.replaceAll("|","\\|");return this.type=="header"?e+"#"+this.subpath?.replaceAll("|","\\|"):this.type=="block"?e+"#^"+this.subpath?.replaceAll("|","\\|"):e}fileName(){return C8(this.path).replace(".md","")}},lE=class{constructor(e){ae(this,"$widget");this.$widget=e}},q1=class extends lE{constructor(t,n){super("dataview:list-pair");ae(this,"key");ae(this,"value");this.key=t,this.value=n}markdown(){return`${aE.toString(this.key)}: ${aE.toString(this.value)}`}},W1=class extends lE{constructor(t,n){super("dataview:external-link");ae(this,"url");ae(this,"display");this.url=t,this.display=n}markdown(){return`[${this.display??this.url}](${this.url})`}},E8;(function(r){function e(s,a){return new q1(s,a)}r.listPair=e;function t(s,a){return new W1(s,a)}r.externalLink=t;function n(s){return s.$widget==="dataview:list-pair"}r.isListPair=n;function i(s){return s.$widget==="dataview:external-link"}r.isExternalLink=i;function o(s){return n(s)||i(s)}r.isBuiltin=o})(E8||(E8={}));var Qr;(function(r){function e(f){return{type:"variable",name:f}}r.variable=e;function t(f){return{type:"literal",value:f}}r.literal=t;function n(f,p,m){return{type:"binaryop",left:f,op:p,right:m}}r.binaryOp=n;function i(f,p){return{type:"index",object:f,index:p}}r.index=i;function o(f){let p=f.split("."),m=r.variable(p[0]);for(let v=1;v<p.length;v++)m=r.index(m,r.literal(p[v]));return m}r.indexVariable=o;function s(f,p){return{type:"lambda",arguments:f,value:p}}r.lambda=s;function a(f,p){return{type:"function",func:f,arguments:p}}r.func=a;function l(f){return{type:"list",values:f}}r.list=l;function c(f){return{type:"object",values:f}}r.object=c;function u(f){return{type:"negated",child:f}}r.negate=u;function d(f){return f=="<="||f=="<"||f==">"||f==">="||f=="!="||f=="="}r.isCompareOp=d,r.NULL=r.literal(null)})(Qr||(Qr={}));var Wl;(function(r){function e(u){return{type:"tag",tag:u}}r.tag=e;function t(u){return{type:"csv",path:u}}r.csv=t;function n(u){return{type:"folder",folder:u}}r.folder=n;function i(u,d){return{type:"link",file:u,direction:d?"incoming":"outgoing"}}r.link=i;function o(u,d,f){return{type:"binaryop",left:u,op:d,right:f}}r.binaryOp=o;function s(u,d){return{type:"binaryop",left:u,op:"&",right:d}}r.and=s;function a(u,d){return{type:"binaryop",left:u,op:"|",right:d}}r.or=a;function l(u){return{type:"negate",child:u}}r.negate=l;function c(){return{type:"empty"}}r.empty=c})(Wl||(Wl={}));var T8=new RegExp(eN(),""),z1={year:Xe.fromObject({years:1}),years:Xe.fromObject({years:1}),yr:Xe.fromObject({years:1}),yrs:Xe.fromObject({years:1}),month:Xe.fromObject({months:1}),months:Xe.fromObject({months:1}),mo:Xe.fromObject({months:1}),mos:Xe.fromObject({months:1}),week:Xe.fromObject({weeks:1}),weeks:Xe.fromObject({weeks:1}),wk:Xe.fromObject({weeks:1}),wks:Xe.fromObject({weeks:1}),w:Xe.fromObject({weeks:1}),day:Xe.fromObject({days:1}),days:Xe.fromObject({days:1}),d:Xe.fromObject({days:1}),hour:Xe.fromObject({hours:1}),hours:Xe.fromObject({hours:1}),hr:Xe.fromObject({hours:1}),hrs:Xe.fromObject({hours:1}),h:Xe.fromObject({hours:1}),minute:Xe.fromObject({minutes:1}),minutes:Xe.fromObject({minutes:1}),min:Xe.fromObject({minutes:1}),mins:Xe.fromObject({minutes:1}),m:Xe.fromObject({minutes:1}),second:Xe.fromObject({seconds:1}),seconds:Xe.fromObject({seconds:1}),sec:Xe.fromObject({seconds:1}),secs:Xe.fromObject({seconds:1}),s:Xe.fromObject({seconds:1})},H1={now:()=>kt.local(),today:()=>kt.local().startOf("day"),yesterday:()=>kt.local().startOf("day").minus(Xe.fromObject({days:1})),tomorrow:()=>kt.local().startOf("day").plus(Xe.fromObject({days:1})),sow:()=>kt.local().startOf("week"),"start-of-week":()=>kt.local().startOf("week"),eow:()=>kt.local().endOf("week"),"end-of-week":()=>kt.local().endOf("week"),soy:()=>kt.local().startOf("year"),"start-of-year":()=>kt.local().startOf("year"),eoy:()=>kt.local().endOf("year"),"end-of-year":()=>kt.local().endOf("year"),som:()=>kt.local().startOf("month"),"start-of-month":()=>kt.local().startOf("month"),eom:()=>kt.local().endOf("month"),"end-of-month":()=>kt.local().endOf("month")},j1=["FROM","WHERE","LIMIT","GROUP","FLATTEN"];function Dve(r){let e=-1;for(;(e=r.indexOf("|",e+1))>=0;)if(!(e>0&&r[e-1]=="\\"))return[r.substring(0,e).replace(/\\\|/g,"|"),r.substring(e+1)];return[r.replace(/\\\|/g,"|"),void 0]}function Ive(r){let[e,t]=Dve(r);return gD.infer(e,!1,t)}function nE(r,e,t){return R.seqMap(r,R.seq(R.optWhitespace,e,R.optWhitespace,r).many(),(n,i)=>{if(i.length==0)return n;let o=t(n,i[0][1],i[0][3]);for(let s=1;s<i.length;s++)o=t(o,i[s][1],i[s][3]);return o})}function Pve(r,...e){return R.custom((t,n)=>(i,o)=>{let s=r._(i,o);if(!s.status)return s;for(let a of e){let l=a(s.value)._(i,s.index);if(!l.status)return s;s=l}return s})}var Qa=R.createLanguage({number:r=>R.regexp(/-?[0-9]+(\.[0-9]+)?/).map(e=>Number.parseFloat(e)).desc("number"),string:r=>R.string('"').then(R.alt(r.escapeCharacter,R.noneOf('"\\')).atLeast(0).map(e=>e.join(""))).skip(R.string('"')).desc("string"),escapeCharacter:r=>R.string("\\").then(R.any).map(e=>e==='"'?'"':e==="\\"?"\\":"\\"+e),bool:r=>R.regexp(/true|false|True|False/).map(e=>e.toLowerCase()=="true").desc("boolean ('true' or 'false')"),tag:r=>R.seqMap(R.string("#"),R.alt(R.regexp(/[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s]/).desc("text")).many(),(e,t)=>e+t.join("")).desc("tag ('#hello/stuff')"),identifier:r=>R.seqMap(R.alt(R.regexp(/\p{Letter}/u),R.regexp(T8).desc("text")),R.alt(R.regexp(/[0-9\p{Letter}_-]/u),R.regexp(T8).desc("text")).many(),(e,t)=>e+t.join("")).desc("variable identifier"),link:r=>R.regexp(/\[\[([^\[\]]*?)\]\]/u,1).map(e=>Ive(e)).desc("file link"),embedLink:r=>R.seqMap(R.string("!").atMost(1),r.link,(e,t)=>(e.length>0&&(t.embed=!0),t)).desc("file link"),binaryPlusMinus:r=>R.regexp(/\+|-/).map(e=>e).desc("'+' or '-'"),binaryMulDiv:r=>R.regexp(/\*|\/|%/).map(e=>e).desc("'*' or '/' or '%'"),binaryCompareOp:r=>R.regexp(/>=|<=|!=|>|<|=/).map(e=>e).desc("'>=' or '<=' or '!=' or '=' or '>' or '<'"),binaryBooleanOp:r=>R.regexp(/and|or|&|\|/i).map(e=>e.toLowerCase()=="and"?"&":e.toLowerCase()=="or"?"|":e).desc("'and' or 'or'"),rootDate:r=>R.seqMap(R.regexp(/\d{4}/),R.string("-"),R.regexp(/\d{2}/),(e,t,n)=>kt.fromObject({year:Number.parseInt(e),month:Number.parseInt(n)})).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),dateShorthand:r=>R.alt(...Object.keys(H1).sort((e,t)=>t.length-e.length).map(R.string)),date:r=>Pve(r.rootDate,e=>R.seqMap(R.string("-"),R.regexp(/\d{2}/),(t,n)=>e.set({day:Number.parseInt(n)})),e=>R.seqMap(R.string("T"),R.regexp(/\d{2}/),(t,n)=>e.set({hour:Number.parseInt(n)})),e=>R.seqMap(R.string(":"),R.regexp(/\d{2}/),(t,n)=>e.set({minute:Number.parseInt(n)})),e=>R.seqMap(R.string(":"),R.regexp(/\d{2}/),(t,n)=>e.set({second:Number.parseInt(n)})),e=>R.alt(R.seqMap(R.string("."),R.regexp(/\d{3}/),(t,n)=>e.set({millisecond:Number.parseInt(n)})),R.succeed(e)),e=>R.alt(R.seqMap(R.string("+").or(R.string("-")),R.regexp(/\d{1,2}(:\d{2})?/),(t,n)=>e.setZone("UTC"+t+n,{keepLocalTime:!0})),R.seqMap(R.string("Z"),()=>e.setZone("utc",{keepLocalTime:!0})),R.seqMap(R.string("["),R.regexp(/[0-9A-Za-z+-\/]+/u),R.string("]"),(t,n,i)=>e.setZone(n,{keepLocalTime:!0})))).assert(e=>e.isValid,"valid date").desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),datePlus:r=>R.alt(r.dateShorthand.map(e=>H1[e]()),r.date).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS] or in shorthand"),durationType:r=>R.alt(...Object.keys(z1).sort((e,t)=>t.length-e.length).map(R.string)),duration:r=>R.seqMap(r.number,R.optWhitespace,r.durationType,(e,t,n)=>z1[n].mapUnits(i=>i*e)).sepBy1(R.string(",").trim(R.optWhitespace).or(R.optWhitespace)).map(e=>e.reduce((t,n)=>t.plus(n))).desc("duration like 4hr2min"),rawNull:r=>R.string("null"),tagSource:r=>r.tag.map(e=>Wl.tag(e)),csvSource:r=>R.seqMap(R.string("csv(").skip(R.optWhitespace),r.string,R.string(")"),(e,t,n)=>Wl.csv(t)),linkIncomingSource:r=>r.link.map(e=>Wl.link(e.path,!0)),linkOutgoingSource:r=>R.seqMap(R.string("outgoing(").skip(R.optWhitespace),r.link,R.string(")"),(e,t,n)=>Wl.link(t.path,!1)),folderSource:r=>r.string.map(e=>Wl.folder(e)),parensSource:r=>R.seqMap(R.string("("),R.optWhitespace,r.source,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>n),negateSource:r=>R.seqMap(R.alt(R.string("-"),R.string("!")),r.atomSource,(e,t)=>Wl.negate(t)),atomSource:r=>R.alt(r.parensSource,r.negateSource,r.linkOutgoingSource,r.linkIncomingSource,r.folderSource,r.tagSource,r.csvSource),binaryOpSource:r=>nE(r.atomSource,r.binaryBooleanOp.map(e=>e),Wl.binaryOp),source:r=>r.binaryOpSource,variableField:r=>r.identifier.chain(e=>j1.includes(e.toUpperCase())?R.fail("Variable fields cannot be a keyword ("+j1.join(" or ")+")"):R.succeed(Qr.variable(e))).desc("variable"),numberField:r=>r.number.map(e=>Qr.literal(e)).desc("number"),stringField:r=>r.string.map(e=>Qr.literal(e)).desc("string"),boolField:r=>r.bool.map(e=>Qr.literal(e)).desc("boolean"),dateField:r=>R.seqMap(R.string("date("),R.optWhitespace,r.datePlus,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>Qr.literal(n)).desc("date"),durationField:r=>R.seqMap(R.string("dur("),R.optWhitespace,r.duration,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>Qr.literal(n)).desc("duration"),nullField:r=>r.rawNull.map(e=>Qr.NULL),linkField:r=>r.link.map(e=>Qr.literal(e)),listField:r=>r.field.sepBy(R.string(",").trim(R.optWhitespace)).wrap(R.string("[").skip(R.optWhitespace),R.optWhitespace.then(R.string("]"))).map(e=>Qr.list(e)).desc("list ('[1, 2, 3]')"),objectField:r=>R.seqMap(r.identifier.or(r.string),R.string(":").trim(R.optWhitespace),r.field,(e,t,n)=>({name:e,value:n})).sepBy(R.string(",").trim(R.optWhitespace)).wrap(R.string("{").skip(R.optWhitespace),R.optWhitespace.then(R.string("}"))).map(e=>{let t={};for(let n of e)t[n.name]=n.value;return Qr.object(t)}).desc("object ('{ a: 1, b: 2 }')"),atomInlineField:r=>R.alt(r.date,r.duration.map(e=>T9(e)),r.string,r.tag,r.embedLink,r.bool,r.number,r.rawNull),inlineFieldList:r=>r.atomInlineField.sepBy(R.string(",").trim(R.optWhitespace).lookahead(r.atomInlineField)),inlineField:r=>R.alt(R.seqMap(r.atomInlineField,R.string(",").trim(R.optWhitespace),r.inlineFieldList,(e,t,n)=>[e].concat(n)),r.atomInlineField),atomField:r=>R.alt(r.embedLink.map(e=>Qr.literal(e)),r.negatedField,r.linkField,r.listField,r.objectField,r.lambdaField,r.parensField,r.boolField,r.numberField,r.stringField,r.dateField,r.durationField,r.nullField,r.variableField),indexField:r=>R.seqMap(r.atomField,R.alt(r.dotPostfix,r.indexPostfix,r.functionPostfix).many(),(e,t)=>{let n=e;for(let i of t)switch(i.type){case"dot":n=Qr.index(n,Qr.literal(i.field));break;case"index":n=Qr.index(n,i.field);break;case"function":n=Qr.func(n,i.fields);break}return n}),negatedField:r=>R.seqMap(R.string("!"),r.indexField,(e,t)=>Qr.negate(t)).desc("negated field"),parensField:r=>R.seqMap(R.string("("),R.optWhitespace,r.field,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>n),lambdaField:r=>R.seqMap(r.identifier.sepBy(R.string(",").trim(R.optWhitespace)).wrap(R.string("(").trim(R.optWhitespace),R.string(")").trim(R.optWhitespace)),R.string("=>").trim(R.optWhitespace),r.field,(e,t,n)=>({type:"lambda",arguments:e,value:n})),dotPostfix:r=>R.seqMap(R.string("."),r.identifier,(e,t)=>({type:"dot",field:t})),indexPostfix:r=>R.seqMap(R.string("["),R.optWhitespace,r.field,R.optWhitespace,R.string("]"),(e,t,n,i,o)=>({type:"index",field:n})),functionPostfix:r=>R.seqMap(R.string("("),R.optWhitespace,r.field.sepBy(R.string(",").trim(R.optWhitespace)),R.optWhitespace,R.string(")"),(e,t,n,i,o)=>({type:"function",fields:n})),binaryMulDivField:r=>nE(r.indexField,r.binaryMulDiv,Qr.binaryOp),binaryPlusMinusField:r=>nE(r.binaryMulDivField,r.binaryPlusMinus,Qr.binaryOp),binaryCompareField:r=>nE(r.binaryPlusMinusField,r.binaryCompareOp,Qr.binaryOp),binaryBooleanField:r=>nE(r.binaryCompareField,r.binaryBooleanOp,Qr.binaryOp),binaryOpField:r=>r.binaryBooleanField,field:r=>r.binaryOpField});function Fve(r){try{return mD.success(Qa.field.tryParse(r))}catch(e){return mD.failure(""+e)}}var vD;(function(r){function e(n,i){return{name:n,field:i}}r.named=e;function t(n,i){return{field:n,direction:i}}r.sortBy=t})(vD||(vD={}));function Mve(r){return R.custom((e,t)=>(n,i)=>{let o=r._(n,i);return o.status?Object.assign({},o,{value:[o.value,n.substring(i,o.index)]}):o})}function Rve(r){return r.split(/[\r\n]+/).map(e=>e.trim()).join("")}function _8(r,e){return R.eof.map(r).or(R.whitespace.then(e))}var _9=R.createLanguage({queryType:r=>R.alt(R.regexp(/TABLE|LIST|TASK|CALENDAR/i)).map(e=>e.toLowerCase()).desc("query type ('TABLE', 'LIST', 'TASK', or 'CALENDAR')"),explicitNamedField:r=>R.seqMap(Qa.field.skip(R.whitespace),R.regexp(/AS/i).skip(R.whitespace),Qa.identifier.or(Qa.string),(e,t,n)=>vD.named(n,e)),comment:()=>R.Parser((r,e)=>{let t=r.substring(e);if(!t.startsWith("//"))return R.makeFailure(e,"Not a comment");t=t.split(`
`)[0];let n=t.substring(2).trim();return R.makeSuccess(e+t.length,n)}),namedField:r=>R.alt(r.explicitNamedField,Mve(Qa.field).map(([e,t])=>vD.named(Rve(t),e))),sortField:r=>R.seqMap(Qa.field.skip(R.optWhitespace),R.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(e,t)=>{let n=t.length==0?"ascending":t[0].toLowerCase();return n=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":return _8(()=>({type:e,fields:[],showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),R.sepBy(r.namedField,R.string(",").trim(R.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return _8(()=>({type:e,format:void 0,showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),Qa.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return R.succeed({type:e});case"calendar":return R.whitespace.then(R.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return R.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>R.seqMap(R.regexp(/FROM/i),R.whitespace,Qa.source,(e,t,n)=>n),whereClause:r=>R.seqMap(R.regexp(/WHERE/i),R.whitespace,Qa.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>R.seqMap(R.regexp(/SORT/i),R.whitespace,r.sortField.sepBy1(R.string(",").trim(R.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>R.seqMap(R.regexp(/LIMIT/i),R.whitespace,Qa.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>R.seqMap(R.regexp(/FLATTEN/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>R.seqMap(R.regexp(/GROUP BY/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>R.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>R.seqMap(r.headerClause.trim(A1),r.fromClause.trim(A1).atMost(1),r.clause.trim(A1).many(),(e,t,n)=>({header:e,source:t.length==0?Wl.folder(""):t[0],operations:n,settings:J1}))}),A1=R.alt(R.whitespace,_9.comment).many().map(r=>r.join("")),$ve=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,Ove=r=>r.plugins.enabledPlugins.has("dataview");zl.DATE_SHORTHANDS=H1;zl.DURATION_TYPES=z1;zl.EXPRESSION=Qa;zl.KEYWORDS=j1;zl.QUERY_LANGUAGE=_9;zl.getAPI=$ve;zl.isPluginEnabled=Ove;zl.parseField=Fve});function pE(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o+1];if(s==="["&&a==="["){n=!0,t+=s;continue}if(s==="]"&&a==="]"){n=!1,t+=s;continue}if(s===","&&!n){let l=t.trim();l&&e.push(l),t="";continue}t+=s}let i=t.trim();return i&&e.push(i),e}var tN=b(()=>{});function fE(r){return r.replace(/[\\"]/g,"\\$&")}function Nve(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function k9(r){return fE(Nve(r))}function xD(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var rN,mE,S9=b(()=>{rN=pL(A9());Me();tN();mE=class{static getDataviewAPI(e){let t=(0,rN.getAPI)(e);return t||(M.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){let n=new Set,i=this.getDataviewAPI(e);if(!i)return n;try{let s=`field("${fE(t)}")`,a=`TABLE ${s} WHERE ${s}`,l=await i.query(a);if(l.successful&&l.value.values)for(let c of l.value.values){let u=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeof d=="string"?n.add(d.trim()):xD(d)?n.add(d.path):d&&typeof d!="object"&&n.add(String(d).trim())}):xD(u)?n.add(u.path):u&&typeof u=="string"?pE(u).forEach(d=>n.add(d)):u&&typeof u!="object"&&n.add(String(u).trim())}}catch(o){M.logError(new Error(`Failed to query Dataview for field ${t}: ${o}`))}return n}static async getFieldValuesWithFilter(e,t,n={}){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${fE(t)}")`,l=[a],c=(n.folders?.length?n.folders:n.folder?[n.folder]:[]).map(v=>v.replace(/^\/+|\/+$/g,"")).filter(Boolean);if(c.length>0){let v=c.map(g=>`regexmatch("^${k9(g)}/", file.path)`);l.push(`(${v.join(" OR ")})`)}n.tags&&n.tags.length>0&&n.tags.forEach(v=>{let g=v.startsWith("#")?v:`#${v}`;l.push(`contains(file.tags, "${fE(g)}")`)}),n.excludeFolders&&n.excludeFolders.length>0&&n.excludeFolders.forEach(v=>{let g=v.replace(/^\/+|\/+$/g,"");l.push(`!regexmatch("^${k9(g)}/", file.path)`)}),n.excludeTags&&n.excludeTags.length>0&&n.excludeTags.forEach(v=>{let g=v.startsWith("#")?v:`#${v}`;l.push(`!contains(file.tags, "${fE(g)}")`)});let u=l.join(" AND "),d=`TABLE ${a} WHERE ${u}`,f=await o.query(d),p=n.excludeFiles??[],m=v=>{if(p.length===0)return!1;let g=v[0],y=g&&typeof g.path=="string"?g.path:null;if(!y)return!1;let w=y.split("/").pop()??y;return p.some(k=>k===y||k===w)};if(f.successful&&f.value.values)for(let v of f.value.values){if(m(v))continue;let g=v[1];Array.isArray(g)?g.forEach(y=>{y&&typeof y=="string"?i.add(y.trim()):xD(y)?i.add(y.path):y&&typeof y!="object"&&i.add(String(y).trim())}):xD(g)?i.add(g.path):g&&typeof g=="string"?pE(g).forEach(y=>i.add(y)):g&&typeof g!="object"&&i.add(String(g).trim())}}catch(s){M.logError(new Error(`Failed to query Dataview for field ${t} with filters: ${s}`))}return i}static isAvailable(e){return(0,rN.getAPI)(e)!==null}}});var Yc,ED=b(()=>{Yc=class r{constructor(){this.cache=new Map;this.TTL=300*1e3;this.MAX_CACHE_ENTRIES=100;this.MAX_VALUES_PER_ENTRY=1e3;this.cleanupInterval=null;this.revision=0}static getInstance(){return r.instance||(r.instance=new r),r.instance}startAutomaticCleanup(e){if(this.cleanupInterval===null&&typeof window<"u"){let t=window.setInterval(()=>{this.cleanExpired()},6e4);this.cleanupInterval=e(t)}}registerInvalidationListeners(e,t){let n=()=>this.clear();t(e.metadataCache.on("changed",n)),t(e.metadataCache.on("deleted",n)),t(e.vault.on("rename",n))}get(e,t){let n=this.makeKey(e,t),i=this.cache.get(n);return i?Date.now()-i.timestamp>this.TTL?(this.cache.delete(n),null):new Set(i.values):null}set(e,t,n){let i=this.makeKey(e,n),o=new Set,s=0;for(let a of t){if(s>=this.MAX_VALUES_PER_ENTRY)break;o.add(a),s++}this.cache.size>=this.MAX_CACHE_ENTRIES&&!this.cache.has(i)&&this.evictOldestEntries(1),this.cache.set(i,{values:o,timestamp:Date.now()})}getRevision(){return this.revision}setIfRevision(e,t,n,i){return this.revision!==i?!1:(this.set(e,t,n),!0)}evictOldestEntries(e){let t=Array.from(this.cache.entries()).sort(([,n],[,i])=>n.timestamp-i.timestamp).slice(0,e);for(let[n]of t)this.cache.delete(n)}clear(e){if(this.revision++,e){let t=[];for(let n of this.cache.keys())this.keyFieldName(n)===e&&t.push(n);for(let n of t)this.cache.delete(n)}else this.cache.clear()}cleanExpired(){let e=Date.now(),t=[];for(let[n,i]of this.cache.entries())e-i.timestamp>this.TTL&&t.push(n);for(let n of t)this.cache.delete(n)}getStats(){return{size:this.cache.size,maxSize:this.MAX_CACHE_ENTRIES,cleanupInterval:this.cleanupInterval}}destroy(){this.cleanupInterval=null,this.clear()}makeKey(e,t){return JSON.stringify([e,t||null])}keyFieldName(e){try{let t=JSON.parse(e);if(Array.isArray(t)&&typeof t[0]=="string")return t[0]}catch{}}}});var Ng,D9=b(()=>{Ng=class{static deduplicate(e,t={}){let{strategy:n="case-insensitive",preserveFirstOccurrence:i=!0,sortResult:o=!0}=t,s=e.length,a;switch(n){case"exact":a=this.deduplicateExact(e);break;case"case-sensitive":a=this.deduplicateCaseSensitive(e,i);break;default:a=this.deduplicateCaseInsensitive(e,i);break}return o&&(a=this.sortValues(a,n)),{values:a,duplicatesRemoved:s-a.length,strategy:n}}static deduplicateExact(e){return this.deduplicateWithSet(e)}static deduplicateCaseSensitive(e,t){if(t){let n=new Set;return e.filter(i=>n.has(i)?!1:(n.add(i),!0))}return this.deduplicateWithSet(e)}static deduplicateWithSet(e){return Array.from(new Set(e))}static deduplicateCaseInsensitive(e,t){let n=new Map;for(let i of e){let o=this.normalizeForComparison(i);n.has(o)&&t||n.set(o,i)}return Array.from(n.values())}static normalizeForComparison(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}static sortValues(e,t){return e.sort((n,i)=>{if(t==="case-insensitive"){let o=n.toLowerCase(),s=i.toLowerCase();return o===s?this.getCasePriority(n)-this.getCasePriority(i):o.localeCompare(s)}return n.localeCompare(i)})}static getCasePriority(e){return e===e.toUpperCase()?3:e===e.toLowerCase()?2:e[0]===e[0].toUpperCase()?1:0}static analyzeVariations(e){let t=new Map;for(let o of e){let s=this.normalizeForComparison(o);t.has(s)||t.set(s,[]);let a=t.get(s);a&&a.push(o)}let n=0,i="";for(let[o,s]of t)s.length>n&&(n=s.length,i=o);return{totalValues:e.length,uniqueValues:t.size,caseVariations:t,mostCommonCase:i}}static getSuggestions(e,t,n=.8){let i=this.normalizeForComparison(e),o=[];for(let s of t){let a=this.normalizeForComparison(s);this.calculateSimilarity(i,a)>=n&&i!==a&&o.push(s)}return o.slice(0,5)}static calculateSimilarity(e,t){if(e.length===0)return t.length===0?1:0;if(t.length===0)return 0;let n=[];for(let o=0;o<=t.length;o++)n[o]=[o];for(let o=0;o<=e.length;o++)n[0][o]=o;for(let o=1;o<=t.length;o++)for(let s=1;s<=e.length;s++)t.charAt(o-1)===e.charAt(s-1)?n[o][s]=n[o-1][s-1]:n[o][s]=Math.min(n[o-1][s-1]+1,n[o][s-1]+1,n[o-1][s]+1);let i=Math.max(e.length,t.length);return 1-n[t.length][e.length]/i}}});var Za,nN=b(()=>{_t();D9();Za=class{static processValues(e,t){let n=e.size,i=Array.from(e).filter(c=>!this.isUnresolvedFieldToken(c)),o={strategy:t.caseSensitive?"case-sensitive":"case-insensitive",preserveFirstOccurrence:!0,sortResult:!0},s=Ng.deduplicate(i,o);i=s.values;let{processedValues:a,hasDefault:l}=this.applyDefaultValues(i,t);return i=a,{values:i,hasDefaultValue:l,duplicatesRemoved:s.duplicatesRemoved,totalProcessed:n}}static isUnresolvedFieldToken(e){return this.unresolvedFieldTokenRegex.test(e.trim())}static applyDefaultValues(e,t){if(!t.defaultValue)return{processedValues:e,hasDefault:!1};let n=t.defaultValue,i=[...e],o=!1,s=a=>t.caseSensitive?a===n:this.normalizeForComparison(a)===this.normalizeForComparison(n);return t.defaultAlways?(i=i.filter(a=>!s(a)),i.unshift(n),o=!0):t.defaultEmpty&&e.length===0?(i=[n],o=!0):!t.defaultEmpty&&!t.defaultAlways&&(i.some(s)||(i.unshift(n),o=!0)),{processedValues:i,hasDefault:o}}static promoteValueToFront(e,t,n=!1){let i=o=>n?o===t:this.normalizeForComparison(o)===this.normalizeForComparison(t);return[t,...e.filter(o=>!i(o))]}static canonicalizeAgainst(e,t,n=!1){if(n)return t;let i=this.normalizeForComparison(t);return e.find(o=>this.normalizeForComparison(o)===i)??t}static normalizeForComparison(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}static getSmartDefaults(e,t){let n={status:["To Do","In Progress","Done","Cancelled"],priority:["High","Medium","Low"],type:["Note","Task","Project","Reference"],category:["Personal","Work","Study"],mood:["\u{1F60A} Good","\u{1F610} Neutral","\u{1F614} Bad"],rating:["\u2B50","\u2B50\u2B50","\u2B50\u2B50\u2B50","\u2B50\u2B50\u2B50\u2B50","\u2B50\u2B50\u2B50\u2B50\u2B50"],progress:["0%","25%","50%","75%","100%"],difficulty:["Easy","Medium","Hard"],size:["Small","Medium","Large"]},i=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(n,i))return n[i];for(let[o,s]of Object.entries(n))if(i.includes(o)||o.includes(i))return s;if(t.length>0){let o=new Map;for(let s of t)o.set(s,(o.get(s)||0)+1);return Array.from(o.entries()).sort((s,a)=>a[1]-s[1]).slice(0,5).map(([s])=>s)}return[]}static validateDefaultValue(e,t,n){let i=[],o=[];if(t.length>0){let l=Ng.analyzeVariations(t),c=e.toLowerCase();for(let[d,f]of l.caseVariations)if(d===c){f.includes(e)||(o.push(...f.slice(0,3)),i.push(`Consider using existing case: ${f[0]}`));break}let u=Ng.getSuggestions(e,t,.8);u.length>0&&(o.push(...u),i.push(`Similar existing values found: ${u.slice(0,3).join(", ")}`))}let a=this.getSmartDefaults(n,t);return a.length>0&&!a.includes(e)&&(a.map(c=>c.toLowerCase()).includes(e.toLowerCase())||(o.push(...a.slice(0,3)),i.push(`Consider common values for ${n}: ${a.slice(0,3).join(", ")}`))),{isValid:!0,suggestions:[...new Set(o)],warnings:i}}};Za.unresolvedFieldTokenRegex=new RegExp(`^${LT.source}$`,"i")});var Kc,Lg,iN=b(()=>{tN();Kc=class Kc{static parseInlineFields(e,t){let n=new Map,i=this.removeCodeBlocksAndFrontmatter(e,t),o;for(;(o=Kc.INLINE_FIELD_REGEX.exec(i))!==null;){let s=o[1].trim(),a=o[2].trim();if(a){n.has(s)||n.set(s,new Set);for(let l of pE(a))n.get(s)?.add(l)}}return Kc.INLINE_FIELD_REGEX.lastIndex=0,n}static removeCodeBlocksAndFrontmatter(e,t){return e=e.replace(this.FRONTMATTER_REGEX,""),e=this.filterFencedCodeBlocks(e,t?.includeCodeBlocks),e.replace(this.INLINE_CODE_SPAN_REGEX,"")}static filterFencedCodeBlocks(e,t){if(!e.includes("```"))return e;let n=new Set((t??[]).map(u=>u.trim().toLowerCase()).filter(u=>u.length>0)),i=e.split(`
`),o=[],s=!1,a=0,l="",c=[];for(let u of i){if(!s){let d=this.matchFenceOpen(u);d?(s=!0,a=d.length,l=d.info,c=[u]):o.push(u);continue}if(this.matchFenceClose(u,a)){let d=l.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&d!==void 0&&d.length>0&&n.has(d))for(let p=1;p<c.length;p++)o.push(c[p]);s=!1,c=[]}else c.push(u)}if(s)for(let u of c)o.push(u);return o.join(`
`)}static matchFenceOpen(e){let t=this.FENCE_OPEN_REGEX.exec(this.stripTrailingCarriage(e));return t?{length:t[1].length,info:t[2]}:null}static matchFenceClose(e,t){let n=this.FENCE_CLOSE_REGEX.exec(this.stripTrailingCarriage(e));return n!==null&&n[1].length>=t}static stripTrailingCarriage(e){return e.endsWith("\r")?e.slice(0,-1):e}static getFieldValues(e,t,n){return this.parseInlineFields(e,n).get(t)||new Set}};Kc.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,Kc.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,Kc.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,Kc.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,Kc.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;Lg=Kc});function oN(r){let e=[];return r.folder&&e.push(`folder:${r.folder}`),r.folders?.length&&e.push(`folders:${r.folders.join(",")}`),r.tags&&e.push(`tags:${r.tags.join(",")}`),r.inline&&e.push("inline:true"),r.inlineCodeBlocks?.length&&e.push(`inline-code-blocks:${r.inlineCodeBlocks.join(",")}`),r.caseSensitive&&e.push("case-sensitive:true"),r.excludeFolders&&e.push(`exclude-folders:${r.excludeFolders.join(",")}`),r.excludeTags&&e.push(`exclude-tags:${r.excludeTags.join(",")}`),r.excludeFiles&&e.push(`exclude-files:${r.excludeFiles.join(",")}`),r.defaultValue&&e.push(`default:${r.defaultValue}`),r.defaultEmpty&&e.push("default-empty:true"),r.defaultAlways&&e.push("default-always:true"),e.join("|")}async function I9(r,e,t){let n=await F9(r,e,t);return Za.processValues(n,t).values}async function P9(r,e,t){let n=await F9(r,e,t),i=Za.processValues(n,t);return{values:i.values,hasDefaultValue:i.hasDefaultValue}}async function F9(r,e,t){let n=Yc.getInstance(),i=oN(t),o=n.get(e,i);if(o)return o;let s=n.getRevision(),a=await sN(r,e,t);return n.setIfRevision(e,a,i,s),a}async function sN(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await Lve(r,t);if(i.size>0)return i}try{if(!t.inline&&mE.isAvailable(r)){let i=await mE.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await Uve(r,e,t)}async function Lve(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=Bve(r);if(n.size>0)return n}return await Vve(r,e)}function Bve(r){let e=new Set;try{let t=r.metadataCache.getTags?.();if(!t)return e;for(let n of Object.keys(t)){let o=(n.startsWith("#")?n.substring(1):n).trim();o&&e.add(o)}}catch{}return e}async function Vve(r,e){let t=new Set,n=r.vault.getMarkdownFiles();n=Hi.filterFiles(n,e,o=>r.metadataCache.getFileCache(o));let i=50;for(let o=0;o<n.length;o+=i){let a=n.slice(o,o+i).map(async c=>{let u=new Set;try{let d=r.metadataCache.getFileCache(c),f=d?.frontmatter?.tags;if(f!=null){let m=Array.isArray(f)?f:[f];for(let v of m){let g=String(v).trim();g&&u.add(g)}}let p=d?.frontmatter?.tag;if(p!=null){let m=Array.isArray(p)?p:[p];for(let v of m){let g=String(v).trim();g&&u.add(g)}}if(d?.tags)for(let m of d.tags){let v=String(m.tag??"").trim(),g=v.startsWith("#")?v.substring(1):v;g&&u.add(g)}}catch{}return u}),l=await Promise.all(a);for(let c of l)for(let u of c)t.add(u)}return t}async function Uve(r,e,t){let n=new Set,i=r.vault.getMarkdownFiles();i=Hi.filterFiles(i,t,s=>r.metadataCache.getFileCache(s));let o=50;for(let s=0;s<i.length;s+=o){let l=i.slice(s,s+o).map(async u=>{let d=new Set;try{let p=r.metadataCache.getFileCache(u)?.frontmatter?.[e];if(p!=null){if(Array.isArray(p))p.forEach(m=>{let v=String(m).trim();v&&d.add(v)});else if(typeof p!="object"){let m=String(p).trim();m&&d.add(m)}}if(t.inline)try{let m=await r.vault.read(u);Lg.getFieldValues(m,e,{includeCodeBlocks:t.inlineCodeBlocks}).forEach(g=>{let y=String(g).trim();y&&d.add(y)})}catch{}}catch{}return d}),c=await Promise.all(l);for(let u of c)for(let d of u)n.add(d)}return n}var aN=b(()=>{S9();cp();ED();nN();iN()});function qve(r,e){let t=e.trim();if(!t||!r)return null;let n=r[t];if(n===void 0){let i=t.toLowerCase(),o=Object.keys(r).find(s=>s.toLowerCase()===i);o!==void 0&&(n=r[o])}if(n==null)return null;if(Array.isArray(n)){let i=[];for(let o of n){let s=M9(o);s!==null&&i.push(s)}return i.length>0?i:null}return M9(n)}function TD(r,e,t){if(!e||e.extension!=="md")return null;let n=r.metadataCache.getFileCache(e)?.frontmatter;return qve(n,t)}function M9(r){if(r==null)return null;let e=typeof r;if(e==="string"||e==="number"||e==="boolean"){let t=String(r).trim();return t.length>0?t:null}return null}var lN=b(()=>{});function hE(r){return r.replace(Wve," ").replace(/\s+/g," ").trim()}function R9(r){return!(r.trim()===""||/^( {4,}|\t)/.test(r)||/^ {0,3}#{1,6}[ \t]/.test(r)||/^ {0,3}(`{3,}|~{3,})/.test(r)||/^ {0,3}>/.test(r)||/^ {0,3}([-*+]|\d{1,9}[.)])[ \t]/.test(r)||/^ {0,3}(=+|-+)\s*$/.test(r)||/^ {0,3}([*_-])([ \t]*\1){2,}[ \t]*$/.test(r))}function $9(r){let e=[],t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=r[o];if(o===0&&/^---\s*$/.test(s)){let c=o+1;for(;c<r.length&&!/^---\s*$/.test(r[c]);)c++;o=c;continue}if(t){let c=s.match(/^ {0,3}(`{3,}|~{3,})\s*$/);c&&c[1][0]===n&&c[1].length>=i&&(t=!1,n="",i=0);continue}else{let c=s.match(/^ {0,3}(`{3,}|~{3,})/);if(c){t=!0,n=c[1][0],i=c[1].length;continue}}let a=s.match(/^ {0,3}(#{1,6})[ \t]+(.*)$/);if(a){e.push({heading:a[2],level:a[1].length,line:o});continue}let l=s.match(/^ {0,3}(=+|-+)\s*$/);if(l&&o>0){let c=r[o-1],u=e.length>0&&e[e.length-1].line===o-1,d=o<2||!R9(r[o-2]);!u&&d&&R9(c)&&e.push({heading:c.trim(),level:l[1][0]==="="?1:2,line:o-1});continue}}return e}function zve(r,e){let t=[],n=hE(r[e].heading);n&&t.push(n);let i=r[e].level;for(let o=e-1;o>=0&&i>1;o--)if(r[o].level<i){i=r[o].level;let s=hE(r[o].heading);s&&t.unshift(s)}return t}function O9(r,e){if(r.length===0)return null;let t=-1;for(let u=0;u<r.length&&r[u].line<=e;u++)t=u;if(t===-1)return null;let n=hE(r[t].heading);if(!n)return null;let i=n.toLowerCase();if(!r.some((u,d)=>d!==t&&hE(u.heading).toLowerCase()===i))return`#${n}`;let s=zve(r,t);if(s.length<2)return null;let a=s.join("#"),l=a.toLowerCase();return Hve(r).some((u,d)=>d!==t&&u===l)?null:`#${a}`}function Hve(r){let e=new Array(r.length),t=[];for(let n=0;n<r.length;n++){for(;t.length>0&&r[t[t.length-1]].level>=r[n].level;)t.pop();let i=t.length>0?e[t[t.length-1]]:[],o=hE(r[n].heading);e[n]=o?[...i,o]:i,t.push(n)}return e.map(n=>n.join("#").toLowerCase())}var Wve,N9=b(()=>{Wve=/[!"#$%&()*+,.:;<=>?@^`{|}~/[\]\\\r\n]/g});function vd(r,{logPrefix:e,noticePrefix:t=e,defaultReason:n}){if(!(r instanceof Nt))return!1;let i=typeof r.message=="string"&&r.message.trim().length>0?r.message:n;return M.logMessage(`${e}: ${i}`),(!(r instanceof Dt||typeof r.message=="string"&&r.message.toLowerCase().includes("cancelled by user"))||le.getState().showInputCancellationNotification)&&new L9.Notice(`${t}: ${i}`),!0}var L9,gE=b(()=>{L9=require("obsidian");Bs();Hr();Pt();Me()});var B9={};Jr(B9,{SingleMacroEngine:()=>cN});function Gve(r){if(r==null)return"";if(typeof r=="string")return r;if(typeof r=="number"||typeof r=="boolean")return String(r);if(typeof r=="bigint"||typeof r=="symbol")return r.toString();if(r instanceof Error)return r.message;try{return JSON.stringify(r)}catch{return Object.prototype.toString.call(r)}}var jve,cN,V9=b(()=>{Me();Kr();qt();Wt();$k();qc();vE();gE();Pi();Bs();jve=new Set(["settings","entry","quickadd"]);cN=class{constructor(e,t,n,i,o){this.app=e;this.plugin=t;this.choices=n;this.emittedConflictNotice=!1;this.choiceExecutor=i,o?(this.variables=o,this.choiceExecutor.variables=o):i.variables?this.variables=i.variables:(this.variables=new Map,this.choiceExecutor.variables=this.variables)}async runAndGetOutput(e,t){this.emittedConflictNotice=!1;let{basename:n,memberAccess:i}=lp(e),o=c=>(c??"").trim(),s=Vn(this.choices).find(c=>c.type==="Macro"&&o(c.name)===o(n));if(!s){let c=d=>o(d).toLowerCase(),u=Vn(this.choices).filter(d=>d.type==="Macro"&&c(d.name)===c(n));if(u.length>1)throw M.logError(`Ambiguous macro reference '${e}'. Multiple choices match when ignoring case.`),new Error(`Ambiguous macro reference '${e}'. Please disambiguate by renaming macros.`);s=u[0]}if(!s)throw M.logError(`macro '${e}' does not exist.`),new Error(`macro '${e}' does not exist.`);let a=new Hl(this.app,this.plugin,s,this.choiceExecutor,this.variables,void 0,t?.label);if(i?.length){let c=await this.tryExecuteExport(a,s,i);if(this.ensureNotAborted(),c.executed)return this.formatResult(c.result)}await a.run(),this.ensureNotAborted();let l=a.getOutput();if(i?.length){let c=this.resolveMemberAccess(l,i);c.found||M.logWarning(`Macro '${s.name}' was asked for member '${i.join("::")}', but it has no user script exporting it; the result is empty.`),l=c.value}return typeof l=="function"?l=await l():l&&typeof l=="object"&&(l=JSON.stringify(l)),Gve(l)}getVariables(){return this.variables}async tryExecuteExport(e,t,n){let i=Ir(t.macro?.commands);if(!i.length)return{executed:!1};let o=i.map((c,u)=>({command:c,index:u})).filter(c=>Di(c.command)&&c.command.type==="UserScript");if(o.length===0)return{executed:!1};let s=await this.selectUserScriptCandidate(t,o,n),a=s.candidate.command.id,l=i.slice(0,s.candidate.index);try{l.length&&(await e.runSubset(l),this.ensureNotAborted());let c=t.macro?.commands,u=kx(c)?c:i,d;a!==void 0?d=u.findIndex(C=>Di(C)&&C.id===a&&C.type==="UserScript"):d=s.candidate.index;let f=d>=0?u[d]:void 0;if(!f||f.type!=="UserScript")throw new Nt(`Could not resolve the member-access script for '${t.name}'.`);let p=f;p.settings||(p.settings={});let m=s.candidate.exportsRef!==void 0?s.candidate.exportsRef:await Sa(p,this.app);if(m==null)throw new Nt(`Macro '${t.name}' could not load '${p.name}' for member access.`);let v=typeof m=="object"||typeof m=="function"?m.settings:void 0;v&&typeof v=="object"&&zh(p.settings,v);let g=s.candidate.resolvedMember??this.resolveMemberAccess(m,s.memberAccess);if(!g.found)throw new Nt(`Macro '${t.name}' routes member access to '${p.name}', but that script does not export '${s.memberAccess.join("::")}'.`);let y=u.slice(d+1),w=p.settings;typeof g.value=="function"&&(await qh(this.app,p,v&&typeof v=="object"?v:void 0)&&await this.plugin.saveSettings?.(),w=await Mk(this.app,p,v&&typeof v=="object"?v:void 0));let k=await this.executeResolvedMember(g.value,e,w);return this.ensureNotAborted(),e.setOutput(k),this.syncVariablesFromParams(e),y.length&&(await e.runSubset(y),this.ensureNotAborted()),{executed:!0,result:k}}catch(c){throw vd(c,{logPrefix:"Macro execution aborted",noticePrefix:"Macro execution aborted",defaultReason:"Macro execution aborted"})&&this.choiceExecutor.signalAbort?.(c),c}}resolveMemberAccess(e,t){let n=e;for(let i of t){if(n==null||typeof n!="object"&&typeof n!="function")return{found:!1};let o=n;if(!(i in o))return{found:!1};n=o[i]}return{found:!0,value:n}}async executeResolvedMember(e,t,n){return typeof e=="function"?await e(t.params,n):e}async selectUserScriptCandidate(e,t,n){if(t.length===1)return{candidate:{command:t[0].command,index:t[0].index},memberAccess:n};let i=this.resolveScriptSelector(e,t,n);if(i)return{candidate:{command:i.command,index:i.index},memberAccess:i.memberAccess};let o=[];for(let l of t){let c=await Sa(l.command,this.app);o.push({command:l.command,index:l.index,exportsRef:c,resolvedMember:this.resolveMemberAccess(c,n)})}let s=o.filter(l=>l.resolvedMember.found);if(s.length===1)return{candidate:s[0],memberAccess:n};if(s.length===0)throw new Nt(`Macro '${e.name}' could not find '${n.join("::")}' in any user script.`);if(jve.has(n[0])){let l=s[0];return this.warnReservedKeyConflict(e,n,l,s),{candidate:l,memberAccess:n}}let a=s.map(l=>`'${l.command.name}'`).join(", ");throw new Nt(`Macro '${e.name}' has multiple user scripts exporting '${n.join("::")}': ${a}. Disambiguate with '{{MACRO:${e.name}::<Script Name>::${n.join("::")}}}'.`)}warnReservedKeyConflict(e,t,n,i){if(this.emittedConflictNotice)return;this.emittedConflictNotice=!0;let o=i.map(s=>`'${s.command.name}'`).join(", ");M.logWarning(`Macro '${e.name}': multiple user scripts export '${t.join("::")}' (${o}); using '${n.command.name}'. Disambiguate with '{{MACRO:${e.name}::<Script Name>::${t.join("::")}}}'.`)}resolveScriptSelector(e,t,n){if(n.length<2)return null;let i=n[0]?.trim(),o=t.filter(s=>s.command.name.trim()===i);if(o.length===0)return null;if(o.length>1)throw new Nt(`Macro '${e.name}' has multiple user scripts named '${i}'. Rename one of them before using '{{MACRO:${e.name}::${i}::${n.slice(1).join("::")}}}'.`);return{command:o[0].command,index:o[0].index,memberAccess:n.slice(1)}}syncVariablesFromParams(e){Object.keys(e.params.variables).forEach(t=>{this.choiceExecutor.variables.set(t,e.params.variables[t])})}formatResult(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(typeof e=="object")try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)}ensureNotAborted(){let e=this.choiceExecutor.consumeAbortSignal?.();if(e)throw e}}});var yE,Bg,uN=b(()=>{yE=require("obsidian");_t();Me();qt();_c();Bg=class{constructor(e){this.app=e}async createFolder(e){await this.app.vault.adapter.exists(e)||await this.app.vault.createFolder(e)}stripLeadingSlash(e){return e.replace(/^\/+/,"")}normalizeMarkdownFilePath(e,t){let n=this.stripLeadingSlash(e),i=n?`${n}/`:"",o=this.stripLeadingSlash(t).replace(ir,"");return`${i}${o}.md`}async fileExists(e){return await this.app.vault.adapter.exists(e)}getFileByPath(e){let t=this.app.vault.getAbstractFileByPath(e);if(!t)throw M.logError(`${e} not found`),new Error(`${e} not found`);if(t instanceof yE.TFolder)throw M.logError(`${e} found but it's a folder`),new Error(`${e} found but it's a folder`);if(!(t instanceof yE.TFile))throw new Error(`${e} is not a file`);return t}async createFileWithInput(e,t,n={}){if(Un(e))throw new Error(`Refusing to create a file outside the vault: "${e}".`);let i=e.match(/(.*)[/\\]/),o="";i&&(o=i[1]);let s=this.app.vault.getAbstractFileByPath(o);(!s||!(s instanceof yE.TFolder))&&await this.createFolder(o);let a=()=>this.app.vault.create(e,t);return n.suppressTemplaterOnCreate&&e.toLowerCase().endsWith(".md")?await W0(this.app,e,a):await a()}}});function Kve(r){let e=[],t=[];for(let[n,i]of r){let o=pN(n,i,new Set,0);e.push(...o.warnings),t.push(...o.errors)}return{isValid:t.length===0,warnings:e,errors:t}}function pN(r,e,t,n){let i=[],o=[];if(typeof e=="function")return o.push(`Variable "${r}" contains a function, which cannot be serialized to YAML`),{warnings:i,errors:o};if(typeof e=="symbol")return o.push(`Variable "${r}" contains a symbol, which cannot be serialized to YAML`),{warnings:i,errors:o};if(typeof e=="bigint")return i.push(`Variable "${r}" contains a BigInt, which will be converted to a string`),{warnings:i,errors:o};if(e==null)return{warnings:i,errors:o};if(typeof e!="object")return{warnings:i,errors:o};if(t.has(e))return o.push(`Variable "${r}" contains a circular reference`),{warnings:i,errors:o};if(n>=dN.MAX_NESTING_DEPTH)return o.push(`Variable "${r}" exceeds maximum nesting depth of ${dN.MAX_NESTING_DEPTH}`),{warnings:i,errors:o};t.add(e);try{if(Array.isArray(e))for(let s=0;s<e.length;s++){let a=pN(`${r}[${s}]`,e[s],t,n+1);i.push(...a.warnings),o.push(...a.errors)}else for(let[s,a]of Object.entries(e)){let l=pN(`${r}.${s}`,a,t,n+1);i.push(...l.warnings),o.push(...l.errors)}}finally{t.delete(e)}return{warnings:i,errors:o}}function Vg(r,e){return Yve.includes(r.extension)&&e.size>0}async function Ug(r,e,t){let n=Kve(t);if(n.warnings.length>0)for(let i of n.warnings)M.logWarning(`Structured variable validation warning: ${i}`);if(!n.isValid){let i=n.errors.join("; ");M.logError(`Cannot post-process front matter for file ${e.path} due to validation errors: ${i}. The file was created successfully, but some structured variables may not be properly formatted. Please check the variable values and ensure they don't contain circular references, exceed nesting depth of ${dN.MAX_NESTING_DEPTH}, or contain unsupported types (functions, symbols).`);return}try{M.logMessage(`Post-processing front matter for ${e.path} with ${t.size} structured variables`),M.logMessage(`Variable types: ${Array.from(t.entries()).map(([i,o])=>`${i}:${typeof o}`).join(", ")}`),await r.fileManager.processFrontMatter(e,i=>{for(let[o,s]of t){let a=o.includes(Oa.PATH_SEPARATOR)?o.split(Oa.PATH_SEPARATOR):[o],l=X_(s);mN(i,a,l)}}),M.logMessage(`Successfully post-processed front matter for ${e.path}`)}catch(i){M.logError(`Failed to post-process front matter for file ${e.path}: ${i}. The file was created successfully, but structured variables may not be properly formatted. This usually happens when variable values contain unexpected types or when Obsidian's YAML processor encounters an issue. Check the console for more details about which variables caused the problem.`)}}function fN(r){return r.some((e,t)=>e==="__proto__"?!0:!(t===r.length-1)&&Qve.has(e))}function mN(r,e,t){if(e.length===0)return;if(fN(e)){M.logWarning(`Skipping front matter assignment for unsafe key path "${e.join(".")}" to avoid prototype pollution.`);return}let n=r;for(let i=0;i<e.length-1;i++){let o=e[i],s=n[o];(typeof s!="object"||s===null||Array.isArray(s))&&(n[o]={}),n=n[o]}n[e[e.length-1]]=t}var dN,Yve,Qve,_D=b(()=>{Me();My();Z_();dN={MAX_NESTING_DEPTH:10},Yve=["md"];Qve=new Set(["prototype","constructor"])});function qg(r){return((0,hN.normalizePath)(r).split("/").pop()??"").replace(/\.(md|canvas|base)$/i,"")}function zo(r){let e=(0,hN.normalizePath)(r),t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}var hN,Wg=b(()=>{hN=require("obsidian")});async function sa(r,e){try{return r.promptProvider?await e.remote(r.promptProvider):r.interactive===!1?await e.headless():await e.app()}catch(t){throw It(t)?new Dt("Input cancelled by user"):t}}var zg=b(()=>{Hr();Cr()});async function aa(r,e){let t=e.items.map((s,a)=>`${Xve}${a}`),n=await r.suggester(e.items.map(s=>s.title),t,e.placeholder,e.allowCustomInput??!1),i=n==null?"":String(n),o=t.indexOf(i);if(o!==-1)return e.items[o].value;if(i==="")throw new Dt("Input cancelled by user");if(e.allowCustomInput)return i;throw new Error(`A reply to ${e.what} has to be one of the offered options, and "${i.slice(0,60)}" is not. Reply with the item's \`value\` token exactly as it was sent, or \`{"cancelled": true}\` to dismiss it.`)}var Xve,Hg=b(()=>{Hr();Xve="\0qa-eng:"});function bE(r){let e=jp(r);if(e.length!==0)throw new xe(Hj(e,r))}function U9(r){return jp(r).length===0}var AD=b(()=>{xo();Dl()});function kD(r){let e=r.map(n=>n||"/");return`Folder must be under: ${e.length>3?`${e.slice(0,3).join(", ")}...`:e.join(", ")}`}function gN(r){return r instanceof Nt||!!r&&typeof r=="object"&&"name"in r&&r.name==="MacroAbortError"}var jg,Zve,jl,yd,SD=b(()=>{uN();_D();Gg();jg=require("obsidian");qt();Hc();sd();_t();Cr();Dl();_c();Wg();rA();Bs();xo();zg();Hg();Me();AD();Zve=3,jl=class extends Error{constructor(e){super(e),this.name="InvalidFolderPathError"}};yd=class extends Bg{constructor(t,n,i,o){super(t);this.plugin=n;this.lastTemplateFileFailure=null;this.templater=zT(t),this.formatter=new xs(t,n,i),o&&this.formatter.setTemplateInclusionState(o)}async getOrCreateFolder(t,n){let i=this.buildFolderSelectionContext(t,n);if(!this.shouldPromptForFolder(i))return await this.handleSingleSelection(i);let o=await this.promptUntilAllowed(i,n.executor);return o.isEmpty?"":o.resolved}buildFolderSelectionContext(t,n){let i=n.allowCreate??!1,o=n.allowedRoots?.map(d=>this.normalizeFolderPath(d))??[],{items:s,displayItems:a,normalizedItems:l,canonicalByNormalized:c,displayByNormalized:u}=this.buildFolderSuggestions(t,n.topItems??[],o.length>0?o:void 0);return{items:s,displayItems:a,normalizedItems:l,canonicalByNormalized:c,displayByNormalized:u,existingSet:new Set(l),allowCreate:i,allowedRoots:o,placeholder:n.placeholder}}shouldPromptForFolder(t){return t.items.length>1||t.allowCreate&&t.items.length===0}async promptForFolder(t,n){let i=t.placeholder??"Choose a folder or type to create one";return String(await sa(n,{remote:o=>aa(o,{items:t.items.map((s,a)=>({value:s,title:t.displayItems[a]??s})),placeholder:i,allowCustomInput:t.allowCreate,what:"the folder chooser"}),headless:()=>{throw new xe("This choice needs to ask which folder to create the note in, but this run is non-interactive. Configure a single target folder, or re-run with the ui flag.")},app:()=>t.allowCreate?ln.Suggest(this.app,t.displayItems,t.items,{placeholder:i,renderItem:(o,s)=>{this.renderFolderSuggestion(o,s,t.existingSet,t.displayByNormalized)}}):Lr.Suggest(this.app,t.displayItems,t.items,t.placeholder)}))}async resolveSelection(t,n){let i=this.normalizeFolderPath(t),o=i.length===0,s=n.canonicalByNormalized.get(i),a=s??i,l=o?!1:s!==void 0||await this.app.vault.adapter.exists(a),c=n.allowedRoots.length===0?!0:this.isPathAllowed(o?"":a,n.allowedRoots);return{raw:t,normalized:i,resolved:a,exists:l,isAllowed:c,isEmpty:o}}async promptUntilAllowed(t,n){let i=n.promptProvider?Zve:0,o=null;for(;;){if(n.promptProvider&&i--<=0)throw new xe(o??kD(t.allowedRoots));let s=await this.promptForFolder(t,n),a=await this.resolveSelection(s,t);if(a.isEmpty){if(!a.isAllowed){o=kD(t.allowedRoots),this.showFolderNotAllowedNotice(t.allowedRoots);continue}return a}if(!a.isAllowed){o=kD(t.allowedRoots),this.showFolderNotAllowedNotice(t.allowedRoots);continue}try{this.validateFolderPath(a.resolved)}catch(l){if(l instanceof jl){o=l.message,new jg.Notice(l.message);continue}throw l}return await this.ensureFolderExists(a),a}}async ensureFolderExists(t){t.isEmpty||t.exists||await this.createFolder(t.resolved)}async handleSingleSelection(t){let n=t.items[0]??"",i=await this.resolveSelection(n,t);if(i.isEmpty)return"";if(!i.isAllowed)throw this.showFolderNotAllowedNotice(t.allowedRoots),new Nt("Selected folder not allowed.");if(i.resolved)try{this.validateFolderPath(i.resolved)}catch(o){if(o instanceof jl)return new jg.Notice(o.message),"";throw o}return await this.ensureFolderExists(i),i.resolved}normalizeFolderPath(t){return t.trim().replace(/^\/+/,"").replace(/\/+$/,"")}validateFolderPath(t){let n=t.trim();if(!n)return;let i=n.split("/");for(let o of i)this.validateFolderSegment(o)}validateFolderSegment(t){if(!t)throw new jl("Folder name cannot be empty.");if(t==="."||t==="..")throw new jl("Folder name cannot be '.' or '..'.");if(J_.test(t))throw new jl("Folder name cannot contain control characters.");if(eA.test(t))throw new jl('Folder name cannot contain any of the following characters: \\ / : * ? " < > |');if(tA.test(t))throw new jl("Folder name cannot end with a space or a period.");let n=t.split(".")[0]??"";if(n&&Om(n))throw new jl("Folder name cannot be a reserved name like CON, PRN, AUX, NUL, COM1-9, or LPT1-9.")}isPathAllowed(t,n){let i=this.normalizeFolderPath(t);for(let o of n)if(!o||i===o||i.startsWith(`${o}/`))return!0;return!1}showFolderNotAllowedNotice(t){new jg.Notice(kD(t))}buildFolderSuggestions(t,n,i){let o=[],s=[],a=[],l=new Map,c=new Map,u=new Set,d=(f,p)=>{let m=this.normalizeFolderPath(f);u.has(m)||i&&i.length>0&&!this.isPathAllowed(m,i)||(u.add(m),o.push(f),s.push(p??f),a.push(m),l.set(m,f),p&&c.set(m,p))};for(let f of n)d(f.path,f.label);for(let f of t)d(f);return{items:o,displayItems:s,normalizedItems:a,canonicalByNormalized:l,displayByNormalized:c}}renderFolderSuggestion(t,n,i,o){n.empty(),n.classList.add("mod-complex");let s=this.normalizeFolderPath(t),a=o.get(s),l=t||"/",c=i.has(s),u="";a==="<current folder>"?u="Current folder":c||(u="Create folder"),n.createDiv("suggestion-content").createDiv("suggestion-title").createSpan({text:l}),u&&n.createDiv("suggestion-aux").createEl("kbd",{cls:"suggestion-hotkey",text:u})}stripDuplicateFolderPrefix(t,n){let i=this.stripLeadingSlash(n),o=this.stripLeadingSlash(t);return i?o.startsWith(`${i}/`)?{fileName:o.slice(i.length+1),strippedPrefix:!0}:{fileName:o,strippedPrefix:!1}:{fileName:o,strippedPrefix:!1}}shouldTreatFormattedNameAsVaultRelativePath(t,n,i){if(i||n)return!1;let o=t.trim();if(!o.includes("/")||o.startsWith("./"))return!1;if(o.startsWith("/"))return!0;let[s]=this.stripLeadingSlash(o).split("/");return s?this.app.vault.getAbstractFileByPath(s)instanceof jg.TFolder:!1}getTemplateExtension(t){return zr.test(t)?".canvas":qi.test(t)?".base":".md"}normalizeTemplateFilePath(t,n,i){let o=this.stripLeadingSlash(t),s=o?`${o}/`:"",a=this.getTemplateExtension(i),l=li(this.stripLeadingSlash(n),"File name"),c=li(l.replace(ir,"").replace(zr,"").replace(qi,""),"File name");if(!c.slice(c.lastIndexOf("/")+1).trim())throw new Error("File name is empty after formatting. Make sure the tokens in the file name format produce a value (an optional token left empty can cause this).");let d=`${s}${c}${a}`;if(Un(d))throw new Error(`Refusing to build a file path outside the vault: "${d}".`);return d}noteTemplateFileFailure(t,n){this.lastTemplateFileFailure=t instanceof Error&&t.message?t.message:n}async createFileWithTemplate(t,n){this.lastTemplateFileFailure=null,bE(t);try{let i=await this.getTemplateContent(n),o=qg(t);this.formatter.setTitle(o),this.formatter.setTargetFolderPath(zo(t)),this.formatter.setPromptRunContext({destination:t,destinationKind:"file"});let s=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",i,()=>this.formatter.formatFileContent(i))),a=this.formatter.getAndClearTemplatePropertyVars();M.logMessage(`TemplateEngine.createFileWithTemplate: Collected ${a.size} template property variables for ${t}`),a.size>0&&M.logMessage(`Variables: ${Array.from(a.keys()).join(", ")}`);let l=t.toLowerCase().endsWith(".md"),c=await this.createFileWithInput(t,s,{suppressTemplaterOnCreate:l});return Vg(c,a)&&await Ug(this.app,c,a),await ep(this.app,c),c}catch(i){if(gN(i))throw i;return this.noteTemplateFileFailure(i,`Could not create file with template at ${t}`),lt(i,`Could not create file with template at ${t}`),null}}setLinkToCurrentFileBehavior(t){this.formatter.setLinkToCurrentFileBehavior(t)}setTargetFolderPath(t){this.formatter.setTargetFolderPath(t)}setPromptRunContext(t){this.formatter.setPromptRunContext(t)}async resolveTemplateSourcePath(t){return this.formatter.formatTemplateFilePath(t)}async overwriteFileWithTemplate(t,n){this.lastTemplateFileFailure=null;try{let i=await this.getTemplateContent(n),o=t.basename;this.formatter.setTitle(o),this.formatter.setTargetFolderPath(zo(t.path)),this.formatter.setPromptRunContext({destination:t.path,destinationKind:"file"});let s=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",i,()=>this.formatter.formatFileContent(i))),a=this.formatter.getAndClearTemplatePropertyVars();return M.logMessage(`TemplateEngine.overwriteFileWithTemplate: Collected ${a.size} template property variables for ${t.path}`),a.size>0&&M.logMessage(`Variables: ${Array.from(a.keys()).join(", ")}`),await this.app.vault.modify(t,s),Vg(t,a)&&await Ug(this.app,t,a),await ep(this.app,t),t}catch(i){if(gN(i))throw i;return this.noteTemplateFileFailure(i,"Could not overwrite file with template"),lt(i,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(t,n,i){this.lastTemplateFileFailure=null;try{let o=await this.getTemplateContent(n),s=t.basename;this.formatter.setTitle(s),this.formatter.setTargetFolderPath(zo(t.path)),this.formatter.setPromptRunContext({destination:t.path,destinationKind:"file"});let a=await this.formatter.withPromptScope("noteBody",o,()=>this.formatter.formatFileContent(o));t.extension==="md"&&(a=await hc(this.app,a,t));let l=await this.app.vault.cachedRead(t),c=i==="top"?`${a}
${l}`:`${l}
${a}`;return await this.app.vault.modify(t,c),t}catch(o){if(gN(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),lt(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=mo(this.app,t);if(!n)throw new Error(`Template file not found at path "${t}".`);return await this.app.vault.cachedRead(n)}}});var q9={};Jr(q9,{SingleTemplateEngine:()=>wE});var wE,vN=b(()=>{SD();Me();wE=class extends yd{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody"}setPromptScope(t){this.promptScope=t}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||M.logError(`Template ${t} not found.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var W9={};Jr(W9,{SingleInlineScriptEngine:()=>yN});var yN,z9=b(()=>{vE();yN=class extends Hl{constructor(e,t,n,i){super(e,t,null,n,i)}async runAndGetOutput(e){let t=Object.getPrototypeOf(async function(){}).constructor;return await new t(e).bind(this.params,this).call()}}});var H9,xs,Gg=b(()=>{H9=require("obsidian");$a();sd();N5();f1();_t();Hc();z5();Y5();hh();Nu();cp();Gs();xl();aN();nN();lN();vl();Me();Vm();Py();N9();Hr();xo();Cr();xs=class extends El{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.dateParser=o||Sl,i&&(this.variables=i?.variables)}async format(t){let n=t;return n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n),n=await this.replaceTemplateInString(n),n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n),n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(gl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}async formatFileName(t,n="generic"){if(Ls.test(t))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");let i=await this.withPromptScope(n,t,()=>this.format(t));if(Ls.test(i))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return i=this.replaceCurrentFileTokensInString(i,{fileName:!0,folder:!0,activeFolder:"path"}),i}async formatFileContent(t){let n=t,i=this.contentValuePromptsAcceptImagePaste;this.contentValuePromptsAcceptImagePaste=!Y_(this.promptScope);try{n=await this.format(n)}finally{this.contentValuePromptsAcceptImagePaste=i}return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),n}async formatFolderPath(t){if(Ls.test(t))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");let n=await this.withPromptScope("folder",t,()=>this.format(t));if(Ls.test(n))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return this.replaceCurrentFileTokensInString(n,{folder:!0,activeFolder:"path"}).replace(/^\/+/,"")}async formatTemplateFilePath(t){if(Ls.test(t))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");let n=t;if(n=await this.replaceGlobalVarInString(n),Ls.test(n))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");return n=await this.withPromptScope("templatePath",t,async()=>{let i=this.replaceDateInString(n);return i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),this.replaceRandomInString(i)}),n.trim()}async formatLocationString(t){let n=await this.withPromptScope("lineTarget",t,()=>this.format(t));return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,title:!0}),n}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();return t?this.app.fileManager.generateMarkdownLink(t,""):null}getCurrentFileName(){let t=this.app.workspace.getActiveFile();return t?t.basename:null}getCurrentFolderPath(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=t.parent?.path??"";return n==="/"?"":n}getCurrentFileLinkToSection(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.getLinkSourcePath()??"",i=null;try{i=this.getActiveHeadingSubpath(t)}catch{i=null}return i?this.app.fileManager.generateMarkdownLink(t,n,i):this.app.fileManager.generateMarkdownLink(t,n)}getActiveHeadingSubpath(t){let n=this.app.workspace.getActiveViewOfType(H9.MarkdownView);if(!n||n.file?.path!==t.path||n.getMode()==="preview")return null;let i=n.editor,o=i?.getCursor();if(!i||!o)return null;let s=$9(i.getValue().split(/\r?\n/));return O9(s,o.line)}getVariableValue(t){return this.variables.get(t)??""}shouldUseSelectionForValue(){return!0}async getSelectedTextForValue(){return await this.getSelectedText()}assertInteractivePrompt(t){if(this.choiceExecutor?.interactive===!1)throw new xe(`This run is non-interactive but a value for ${t} was not provided up front. Pass it (e.g. a value- flag) or re-run with the ui flag.`)}describeAnonymousValuePrompt(){let t=K_(this.promptScope,this.promptScopeSoleValue),n=t.title??(this.promptRunContext?.choiceName?.trim()||"Enter value"),i=fF(this.promptScope);return{title:n,placeholder:t.placeholder,contextLine:Iy(this.promptRunContext,n,{showDestination:i}),contextLineFull:Iy(this.promptRunContext,n,{elide:!1,showDestination:i})}}async promptForValue(t){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.valuePromptContext.description??this.describeAnonymousValuePrompt().title,!1)),this.value;try{return this.value=await Lr.Suggest(this.app,["true","false"],["true","false"],this.valuePromptContext.description??this.describeAnonymousValuePrompt().title,void 0,this.valuePromptContext.optional?{skippable:!0}:void 0),this.value}catch(s){throw It(s)?new Dt("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 Ag().factory(this.valuePromptContext?.inputTypeOverride),a=this.valuePromptContext?.defaultValue,l=this.valuePromptContext?.description,c=this.buildInputPromptOptions(this.valuePromptContext,n.contextLine,n.contextLineFull),u=this.valuePromptContext?.placeholder??n.placeholder;o?this.value=await s.PromptWithContext(this.app,n.title,u,a,o,l,c):this.value=await s.Prompt(this.app,n.title,u,a,l,c)}catch(o){throw It(o)?new Dt("Input cancelled by user"):o}}return this.value}normalizeSelectedTextForPrompt(t){let n=this.valuePromptContext;if(n?.inputTypeOverride==="checkbox"){let s=t.trim().toLowerCase();return s==="true"||s==="false"?s:void 0}if(n?.inputTypeOverride!=="number"&&n?.inputTypeOverride!=="slider")return t;let i=n.sliderConfig??n.numericConfig,o=Na(t,i);return o===""?void 0:o}buildInputPromptOptions(t,n,i){let o=this.contentValuePromptsAcceptImagePaste&&t?.inputTypeOverride!=="number"&&t?.inputTypeOverride!=="slider"?{sourcePath:this.getLinkSourcePath()??""}:void 0,s=this.promptRunContext?.draftScopeId;return{optional:t?.optional,numeric:t?.numericConfig,slider:t?.sliderConfig,imagePaste:o,contextLine:n,contextLineFull:i,draftScopeId:s,allowPeek:!0}}async promptForVariable(t,n){let i=this.choiceExecutor?.promptProvider;if(i)return n?.type==="VDATE"?await i.datePrompt(t??n.label??"Enter date",{defaultValue:n.defaultValue,dateFormat:n.dateFormat??"YYYY-MM-DD",withTime:n.withTime}):n?.inputTypeOverride==="checkbox"?String(await i.suggester(["true","false"],["true","false"],n.description??t??n.label??"Choose value",!1)):await i.inputPrompt(t??n?.label??"Enter value",n?.placeholder,n?.defaultValue);this.assertInteractivePrompt(t?`{{VALUE:${t}}}`:"a template variable");try{let o=t??n?.label??"Enter value",s=fF(this.promptScope),a=Iy(this.promptRunContext,o,{showDestination:s}),l=Iy(this.promptRunContext,o,{elide:!1,showDestination:s});return n?.type==="VDATE"?await of.Prompt(this.app,t??n.label??"Enter date",n.withTime?"Enter a date & time (e.g., 'tomorrow at 3pm', '2025-12-25 14:30')":"Enter a date (e.g., 'tomorrow', 'next friday', '2025-12-25')",n.defaultValue,n.dateFormat??"YYYY-MM-DD",{optional:n.optional,contextLine:a,contextLineFull:l,draftScopeId:this.promptRunContext?.draftScopeId},n.withTime):n?.inputTypeOverride==="checkbox"?await Lr.Suggest(this.app,["true","false"],["true","false"],n.description??t??n.label??"Choose value",void 0,n.optional?{skippable:!0}:void 0):await new Ag().factory(n?.inputTypeOverride).Prompt(this.app,o,n?.placeholder??(n?.defaultValue?n.defaultValue:void 0),n?.defaultValue,n?.description,this.buildInputPromptOptions(n,a,l))}catch(o){throw It(o)?new Dt("Input cancelled by user"):o}}async promptForMathValue(){let t=this.choiceExecutor?.promptProvider;if(t)return await t.inputPrompt("Enter a math expression");this.assertInteractivePrompt("a {{MVALUE}} math expression");try{return await JS.Prompt()}catch(n){throw It(n)?new Dt("Input cancelled by user"):n}}async suggestForValue(t,n=!1,i){let o=this.choiceExecutor?.promptProvider;if(o)return String(await o.suggester(i?.displayValues??t,t,i?.placeholder,n));this.assertInteractivePrompt(i?.variableKey?`{{VALUE:${i.variableKey}}}`:"a value choice");try{let s=i?.displayValues??t;return n?await ln.Suggest(this.app,s,t,{...i?.placeholder?{placeholder:i.placeholder}:{},...i?.optional?{skippable:!0}:{}}):await Lr.Suggest(this.app,s,t,i?.placeholder,void 0,i?.optional?{skippable:!0}:void 0)}catch(s){throw It(s)?new Dt("Input cancelled by user"):s}}async suggestForValueMulti(t,n=!1,i){let o=i?.displayValues??t,s=this.choiceExecutor?.promptProvider;if(s)return await s.suggesterMulti(o,t,{placeholder:i?.placeholder,allowCustomInput:n});this.assertInteractivePrompt(i?.variableKey?`{{VALUE:${i.variableKey}}}`:"a multi-select value");try{return await rf.Suggest(this.app,o,t,{...i?.placeholder?{placeholder:i.placeholder}:{},allowCustomValue:n,...i?.optional?{skippable:!0}:{}})}catch(a){throw It(a)?new Dt("Input cancelled by user"):a}}async suggestForField(t){this.assertInteractivePrompt(`{{FIELD:${t}}}`);let n=this.choiceExecutor?.promptProvider;try{let{fieldName:i,filters:o,multiSelect:s}=Ki.parse(t),a=o.defaultFrom==="active"?TD(this.app,this.choiceExecutor?.triggerContext?.activeFile??null,i):null,{values:l,hasDefaultValue:c}=await P9(this.app,i,o),u=l,d=c,f=o.defaultValue;!s&&typeof a=="string"?(u=Za.promoteValueToFront(u,a,o.caseSensitive),f=a,d=!0):!s&&Array.isArray(a)&&a.length>0&&M.logMessage(`{{FIELD:${i}|default-from:active}}: the active note's "${i}" is a list value, which applies only to |multi FIELD prompts, so no default was prefilled.`);let p=s?`Select values for ${i}`:`Enter value for ${i}`;if(d&&f&&(p=s?`Select values for ${i} (default: ${f})`:`Enter value for ${i} (default: ${f})`),s){let m=u;if(u.length===0&&!o.defaultValue){let g=Za.getSmartDefaults(i,[]);g.length>0&&(m=g)}let v=a===null?void 0:(Array.isArray(a)?a:[a]).map(g=>Za.canonicalizeAgainst(m,g,o.caseSensitive));return n?await n.suggesterMulti(m,m,{placeholder:p,allowCustomInput:!0,preselected:v&&v.length>0?v:void 0}):await rf.Suggest(this.app,m,m,{placeholder:p,allowCustomValue:!0,...v&&v.length>0?{preselected:v}:{}})}if(u.length===0){let m="No existing values were found in your vault.";if(!o.defaultValue){let v=Za.getSmartDefaults(i,[]);v.length>0&&(m+=`
Suggested values for ${i}: ${v.slice(0,3).join(", ")}`)}return n?await n.inputPrompt(`Enter value for ${i}`,m):await Dr.PromptWithContext(this.app,`Enter value for ${i}`,m,void 0,this.getLinkSourcePath()??void 0,void 0,{allowPeek:!0})}return n?String(await n.suggester(u,u,p,!0)):await ln.Suggest(this.app,u,u,{placeholder:p})}catch(i){throw It(i)?new Dt("Input cancelled by user"):i}}generateCacheKey(t){return oN(t)}async suggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);let n=this.choiceExecutor?.promptProvider;try{let i=Hi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,c=>this.app.metadataCache.getFileCache(c)),o=t.label??`Select a file from ${t.folderPath}`;if(i.length===0){let c=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?await n.inputPrompt(o,c):await Dr.Prompt(this.app,o,c,void 0,void 0,{optional:t.optional||void 0,allowPeek:!0});return t.multiSelect?u?[`${ls}${u}`]:[]:u?`${ls}${u}`:""}let s=Ac(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${Cl}${c.path}`);if(t.multiSelect)return(n?await n.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):await rf.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${ls}${u}`);if(n){let c=String(await n.suggester(s,a,o,t.allowCustomInput));return c?a.includes(c)?c:`${ls}${c}`:""}if(t.allowCustomInput){let c=new Set(i.map(f=>f.basename.toLowerCase())),u=new Set(s.map(f=>f.toLowerCase())),d=await ln.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});return d?a.includes(d)?d:`${ls}${d}`:""}return await Lr.Suggest(this.app,s,a,o,void 0,t.optional?{skippable:!0}:void 0)??""}catch(i){throw It(i)?new Dt("Input cancelled by user"):i}}async getMacroValue(t,n){let{SingleMacroEngine:i}=await Promise.resolve().then(()=>(V9(),B9)),o=new i(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=await o.runAndGetOutput(t,n)??"";return o.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}async getTemplateContent(t){let{SingleTemplateEngine:n}=await Promise.resolve().then(()=>(vN(),q9));this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0});let i={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=new n(this.app,this.plugin,t,this.choiceExecutor,i);o.setTargetFolderPath(this.targetFolderPath),this.promptScope!=="generic"&&o.setPromptScope(this.promptScope),this.promptRunContext&&o.setPromptRunContext({...this.promptRunContext,draftScopeId:`${this.promptRunContext.draftScopeId??""}#${t}`});let s=await o.run();return this.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}async getSelectedText(){let t=Nn(this.app);return t?t.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){return this.plugin.settings.enableTemplatePropertyTypes}async replaceInlineJavascriptInString(t){let n=t;for(;mc.test(n);){let i=mc.exec(n);if(!i)break;let o=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=await Promise.resolve().then(()=>(z9(),W9)),a=new s(this.app,this.plugin,this.choiceExecutor,this.variables),l=await a.runAndGetOutput(o);for(let u in a.params.variables)this.variables.set(u,a.params.variables[u]);let c="";typeof l=="string"?c=l:(typeof l=="number"||typeof l=="boolean"||Array.isArray(l))&&(c=this.renderCollectedOrArrayValue({input:n,matchStart:i.index,matchEnd:i.index+i[0].length,rawValue:l,fallbackKey:"inlineScript",heuristicEnabled:this.isTemplatePropertyTypesEnabled()})??String(l)),n=this.replacer(n,mc,c)}else n=this.replacer(n,mc,"")}return n}async collectValuesManually(t,n){return await sN(this.app,t,n)}}});function pf(r){return new TextEncoder().encode(r).length}function Jve(r){let e=0;for(let t of r){if(t.role==="tool"){for(let n of t.results)e+=pf(n.content);continue}if(e+=pf(t.content),t.role==="assistant"&&t.toolCalls){for(let n of t.toolCalls)if(typeof n.rawArgs=="string")e+=pf(n.rawArgs);else if(n.args)try{e+=pf(JSON.stringify(n.args))}catch{}}}return e}function eye(r,e){let t;if(typeof r=="string")t=r;else if(r==null)t='{"ok":true}';else try{t=JSON.stringify(r)}catch{return{content:"tool returned a value that could not be serialized",isError:!0}}if(pf(t)>e){let n=" \u2026[truncated]",i=Math.max(0,e-pf(n)),o=Math.min(t.length,i);for(;o>0&&pf(t.slice(0,o))>i;)o=Math.floor(o*.9)||o-1;t=t.slice(0,o)+n}return{content:t,isError:!1}}async function j9(r){let e=r.maxResultBytes??32768,t=r.maxTranscriptBytes??524288,n=Math.max(1,r.maxSteps),i=[...r.request.messages],o=[],s={promptTokens:0,completionTokens:0,totalTokens:0},a=0,l=!1,c=null;for(let p=0;p<n;p++){if(p>0&&r.isOnlineDisabled?.())return u("aborted");let m=p===n-1,v=l||m,g={...r.request,messages:i,...v?{toolChoice:"none"}:{}};a+=Jve(i);let y;try{y=await r.dispatch(g,{isFinalStep:v})}catch(k){if(r.isContextOverflow?.(k))return u("context-overflow");throw k}if(c=y,s.promptTokens+=y.usage.promptTokens,s.completionTokens+=y.usage.completionTokens,s.totalTokens+=y.usage.totalTokens,y.normalizedStopReason!=="tool_calls"||y.toolCalls.length===0||v){o.push({stepNumber:p,text:y.content,toolCalls:y.toolCalls,toolResults:[],finishReason:y.rawStopReason,usage:y.usage}),await r.onStepFinish?.(o[o.length-1]);let k=y.normalizedStopReason==="length"?"length":m&&!l&&p>0?"max-steps":"stop";return u(k)}i.push({role:"assistant",content:y.content,toolCalls:y.toolCalls,providerRaw:y.providerRaw});let w=[];for(let k of y.toolCalls)w.push(await d(k));i.push({role:"tool",results:w}),o.push({stepNumber:p,text:y.content,toolCalls:y.toolCalls,toolResults:w,finishReason:y.rawStopReason,usage:y.usage}),await r.onStepFinish?.(o[o.length-1]),a>t&&(l=!0),r.shouldStop?.({steps:o})&&(l=!0)}return u("max-steps");function u(p){return{text:c?.content??"",steps:o,finishReason:p,usage:s,messages:i,finalTurn:c??{content:"",toolCalls:[],normalizedStopReason:"stop",rawStopReason:"",usage:{promptTokens:0,completionTokens:0,totalTokens:0}}}}async function d(p){if(p.parseError)return f(p,"could not parse the tool arguments as JSON");let m=r.getTool(p.name);if(!m)return f(p,`unknown tool "${p.name}"`);let v=p.args??{},g=r.validateArgs(m,v);if(g)return f(p,`invalid arguments: ${g}`);if(!await r.confirm(p,m))return f(p,"tool call denied by user");let w;try{w=await m.execute(v,{toolCallId:p.id,toolName:p.name})}catch(E){if(r.isAbortError(E))throw E;return f(p,`tool execution failed: ${E instanceof Error?E.message:String(E)}`)}let{content:k,isError:C}=eye(w,e);return{toolCallId:p.id,name:p.name,content:k,isError:C}}function f(p,m){return{toolCallId:p.id,name:p.name,content:m,isError:!0}}}var G9=b(()=>{});function ID(r,e="schema"){if(r===null||typeof r!="object"||Array.isArray(r))throw new Qc(`${e} must be a JSON Schema object.`);for(let t of Object.keys(r))if(!Y9.has(t))throw new Qc(`${e} uses unsupported JSON Schema keyword "${t}". QuickAdd tool schemas support only: ${[...Y9].join(", ")}. (Constraints like pattern/minLength/additionalProperties/$ref/allOf/anyOf/format are rejected because at least one provider would silently drop them.)`);if(r.type!==void 0){let t=Array.isArray(r.type)?r.type:[r.type];for(let n of t)if(!tye.has(n))throw new Qc(`${e} has invalid type "${String(n)}".`)}if(r.properties!==void 0){if(r.properties===null||typeof r.properties!="object"||Array.isArray(r.properties))throw new Qc(`${e}.properties must be an object.`);for(let[t,n]of Object.entries(r.properties))ID(n,`${e}.properties.${t}`)}if(r.required!==void 0&&(!Array.isArray(r.required)||r.required.some(t=>typeof t!="string")))throw new Qc(`${e}.required must be an array of strings.`);if(r.items!==void 0){if(Array.isArray(r.items))throw new Qc(`${e}.items as an array (tuple validation) is not supported in QuickAdd's schema subset.`);ID(r.items,`${e}.items`)}if(r.enum!==void 0&&!Array.isArray(r.enum))throw new Qc(`${e}.enum must be an array.`)}function DD(r){return r===null?"null":Array.isArray(r)?"array":typeof r=="number"?Number.isInteger(r)?"integer":"number":typeof r=="boolean"?"boolean":typeof r=="string"?"string":"object"}function rye(r,e){let t=DD(r);return t===e||e==="number"&&t==="integer"}function CE(r,e,t="$"){if(e.type!==void 0){let n=Array.isArray(e.type)?e.type:[e.type];if(!n.some(i=>rye(r,i)))return`${t}: expected ${n.join(" | ")}, got ${DD(r)}`}if(Array.isArray(e.enum)&&!e.enum.some(i=>PD(i,r)))return`${t}: value is not one of the allowed enum values`;if("const"in e&&!PD(e.const,r))return`${t}: value does not equal the required const`;if(DD(r)==="object"){let n=r;if(Array.isArray(e.required)){for(let i of e.required)if(!Object.prototype.hasOwnProperty.call(n,i))return`${t}.${i}: required property is missing`}if(e.properties){for(let[i,o]of Object.entries(e.properties))if(i in n){let s=CE(n[i],o,`${t}.${i}`);if(s)return s}}}if(DD(r)==="array"&&e.items&&!Array.isArray(e.items)){let n=r;for(let i=0;i<n.length;i++){let o=CE(n[i],e.items,`${t}[${i}]`);if(o)return o}}return null}function PD(r,e){if(r===e)return!0;if(typeof r!=typeof e)return!1;if(r===null||e===null)return r===e;if(Array.isArray(r)&&Array.isArray(e))return r.length===e.length&&r.every((t,n)=>PD(t,e[n]));if(typeof r=="object"&&typeof e=="object"){let t=Object.keys(r),n=Object.keys(e);return t.length!==n.length?!1:t.every(i=>PD(r[i],e[i]))}return!1}var Y9,tye,Qc,K9=b(()=>{Y9=new Set(["type","properties","required","items","enum","const","description","title"]),tye=new Set(["object","array","string","number","integer","boolean","null"]),Qc=class extends Error{constructor(e){super(e),this.name="ToolSchemaError"}}});function FD(r){return r.toLowerCase().startsWith(R0)}var bN=b(()=>{_t()});function xE(r){let e=r.trim();if(!e)throw new Error("assignToVariable cannot be empty.");if(new Set(["value","title","text","meta"]).has(e.toLowerCase()))throw new Error(`assignToVariable "${e}" is reserved (it would hijack a built-in formatter token).`);if(e.toLowerCase().endsWith("-quoted"))throw new Error(`assignToVariable "${e}" cannot end with "-quoted" (collides with the quoted output variable).`);if(FD(e))throw new Error(`assignToVariable "${e}" uses the reserved "__qa." prefix for QuickAdd internal variables.`);if(/[|,]/.test(e))throw new Error(`assignToVariable "${e}" contains characters unreachable by {{VALUE:name}}.`)}var wN=b(()=>{bN()});function nye(r,e){if(!e||typeof e!="object")return"";let t=e,n=typeof t.path=="string"?t.path.trim():"",i=typeof t.heading=="string"?t.heading.trim():"";if(!n&&!i)return"";let o=[];return n&&o.push(`Target: ${n}`),i&&o.push(`Heading: ${i}`),o.join(" \xB7 ")}function iye(r){try{return JSON.stringify(r,null,2)??String(r)}catch{return String(r)}}function oye(r){r.forEach(e=>{e.addEventListener("keydown",t=>{if(t.key==="ArrowRight"||t.key==="ArrowLeft"){let i=(r.indexOf(e)+(t.key==="ArrowRight"?1:-1)+r.length)%r.length;r[i].focus(),t.preventDefault()}})})}var ff,EE,Q9=b(()=>{ff=require("obsidian"),EE=class r extends ff.Modal{constructor(t,n,i){super(t);this.toolName=n;this.args=i;this.outcome=null;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Prompt(t,n,i){return new r(t,n,i).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaAIToolConfirm"),this.contentEl.empty(),this.titleEl.textContent=`Run AI tool: ${this.toolName}?`,this.contentEl.createEl("p",{text:"The AI requested this tool call with the arguments below."});let t=nye(this.toolName,this.args);t&&this.contentEl.createEl("p",{cls:"qaAIToolSummary",text:t});let n=this.contentEl.createEl("pre",{cls:"qaAIToolArgs"});n.textContent=iye(this.args),n.setCssStyles({whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"16rem",overflowY:"auto"});let i=this.contentEl.createDiv({cls:"yesNoPromptButtonContainer"}),o=new ff.ButtonComponent(i).setButtonText("Abort run").onClick(()=>this.submit("abort")),s=new ff.ButtonComponent(i).setButtonText("Deny").onClick(()=>this.submit("deny")),a=new ff.ButtonComponent(i).setButtonText("Approve all this run").onClick(()=>this.submit("allow-all")),l=new ff.ButtonComponent(i).setButtonText("Approve").onClick(()=>this.submit("allow"));s.buttonEl.focus(),oye([o.buttonEl,s.buttonEl,a.buttonEl,l.buttonEl])}submit(t){this.outcome=t,this.close()}onClose(){super.onClose(),this.resolvePromise(this.outcome??"deny")}}});function lye(r){return r instanceof Nt}function cye(r){return{content:r.content,toolCalls:r.toolCalls??[],normalizedStopReason:r.normalizedStopReason??"stop",rawStopReason:r.stopReason,usage:r.usage,providerRaw:r.providerRaw}}function uye(r){if(r)return typeof r=="string"?r:{name:r.toolName}}function dye(r){return{toolCallId:r.id,toolName:r.name,input:r.args}}function pye(r){return{toolCallId:r.toolCallId,toolName:r.name,output:r.content,isError:r.isError??!1}}function Z9(r,e){let t;try{t=JSON.parse(fye(r))}catch(i){return{ok:!1,error:`not valid JSON (${i instanceof Error?i.message:String(i)})`}}let n=CE(t,e);return n?{ok:!1,error:n}:{ok:!0,value:t}}function fye(r){let e=r.trim(),t=e.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);return t?t[1]:e}var X9,sye,aye,CN,MD,J9=b(()=>{Pt();Gg();i1();xo();Bs();jh();ef();Vx();ZO();r1();G9();K9();wN();Q9();X9=/^[a-zA-Z0-9_-]{1,64}$/,sye=20,aye=100,CN=new WeakSet;MD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choiceExecutor=n;this.config=i;this.running=!1;this.approveAllThisRun=!1;let o=new Set;for(let[s,a]of Object.entries(i.tools??{})){if(!X9.test(s))throw new Error(`Invalid tool name "${s}". Tool names must match ${X9}.`);if(o.has(s))throw new Error(`Duplicate tool name "${s}".`);o.add(s),ID(a.inputSchema,`tool "${s}".inputSchema`)}}async generate(e={}){if(this.running)throw new Error("This agent is already running a generate() call. Await it, or create a separate agent for concurrent runs.");let t=typeof e.assignToVariable=="string"&&e.assignToVariable.length>0;if(t&&(this.assertAssignableName(e.assignToVariable),CN.has(this.choiceExecutor)))throw new Error("Another AI run with assignToVariable is already in flight in this context \u2014 they would race the shared variables. Run them sequentially.");this.running=!0,t&&CN.add(this.choiceExecutor);let n=GS(this.app);try{return await this.run(e,n)}finally{this.running=!1,t&&CN.delete(this.choiceExecutor);try{n()}catch{}}}async run(e,t){this.approveAllThisRun=!1;let n=le.getState();if(n.disableOnlineFeatures)throw new Error("Rejecting AI request: Online features are disabled in settings.");let{model:i,provider:o}=Hh(this.config.model),s=await za(this.app,o),a=await this.buildSeedMessages(e),l=this.buildToolDefinitions(),c=this.buildRegistry(),u=e.schema?{schema:e.schema,name:"response",strict:!0}:void 0,d={messages:a,...l.length>0?{tools:l}:{},toolChoice:uye(e.toolChoice??this.config.toolChoice)??"auto",maxOutputTokens:e.maxOutputTokens??this.config.maxOutputTokens,modelParams:this.config.modelOptions},f=Math.max(1,Math.min(this.config.maxSteps??sye,aye)),p=xg(n.ai.showAssistant);p.setMessage("starting","QuickAdd is running the AI agent.");try{let m=await j9({request:d,maxSteps:f,dispatch:async(g,y)=>{let w=this.buildTurnRequest(g,y.isFinalStep,u),k=await t1(this.app,s,i,o,w,t);return cye(k)},getTool:g=>c.get(g),confirm:(g,y)=>this.confirm(g,y),validateArgs:(g,y)=>CE(y,g.definition.parameters),isAbortError:lye,isContextOverflow:g=>Bx(g)==="input_context",isOnlineDisabled:()=>le.getState().disableOnlineFeatures,shouldStop:this.buildShouldStop(),onStepFinish:g=>this.reportStep(p,g)}),v=this.toGenerateResult(m);return e.schema&&(v.object=await this.resolveStructuredObject(m,d,i,o,s,e.schema,t)),typeof e.assignToVariable=="string"&&e.assignToVariable&&this.assignVariable(e.assignToVariable,v.text),p.setMessage("finished",`Ran ${v.steps.length} step${v.steps.length===1?"":"s"}.`),window.setTimeout(()=>p.hide(),5e3),v}catch(m){throw p.setMessage("dead",m?.message??""),window.setTimeout(()=>p.hide(),5e3),m}}reportStep(e,t){let n=t.toolCalls.map(o=>o.name),i=n.length>0?`Step ${t.stepNumber+1}: running ${n.join(", ")}.`:`Step ${t.stepNumber+1}: generating a response.`;e.setMessage("thinking",i)}async buildSeedMessages(e){let t=[],n=e.system??this.config.system??le.getState().ai.defaultSystemPrompt;n&&n.trim().length>0&&t.push({role:"system",content:n});let i=e.prompt??"",o=i?await new xs(this.app,this.plugin,this.choiceExecutor).formatFileContent(i):"";return t.push({role:"user",content:o}),t}buildToolDefinitions(){return Object.entries(this.config.tools??{}).map(([e,t])=>({name:e,description:t.description,parameters:t.inputSchema,...t.strict?{strict:!0}:{}}))}buildRegistry(){let e=new Map;for(let[t,n]of Object.entries(this.config.tools??{}))e.set(t,{definition:{name:t,description:n.description,parameters:n.inputSchema,strict:n.strict},execute:(i,o)=>n.execute(i,o),readOnly:n.readOnly});return e}buildShouldStop(){let e=this.config.stopWhen?Array.isArray(this.config.stopWhen)?this.config.stopWhen:[this.config.stopWhen]:[];if(e.length!==0)return({steps:t})=>{let n=t.flatMap(i=>i.toolCalls.map(o=>o.name));return e.some(i=>i({stepNumber:t.length,toolCallNames:n}))}}buildTurnRequest(e,t,n){return!!(e.tools&&e.tools.length>0)&&!t?{...e,responseFormat:void 0}:{...e,tools:void 0,toolChoice:t?"none":e.toolChoice,responseFormat:n}}async confirm(e,t){let n=e.args??{},i=await this.resolvePerToolApproval(t,n);if(!(i||this.needsGlobalConfirmation(t))||this.approveAllThisRun&&!i)return!0;if(this.choiceExecutor.interactive===!1)throw new xe(`'${e.name}' needs approval before it runs, but this run is non-interactive. Set the AI assistant's tool-confirmation to "never", mark the tool readOnly, or re-run with the ui flag.`);let s=await EE.Prompt(this.app,e.name,e.args??{});if(s==="abort")throw new Nt("AI tool run aborted by user");return s==="allow-all"?(this.approveAllThisRun=!0,!0):s==="allow"}async resolvePerToolApproval(e,t){let i=this.config.tools?.[e.definition.name]?.needsApproval;return typeof i=="function"?await i({args:t}):i===!0}needsGlobalConfirmation(e){let t=le.getState().ai.confirmToolCalls??"destructive";return t==="always"?!0:t==="destructive"?e.readOnly!==!0:!1}async resolveStructuredObject(e,t,n,i,o,s,a){let l=Z9(e.finalTurn.content,s);if(l.ok)return l.value;if(e.finishReason==="aborted"||e.finishReason==="context-overflow"||le.getState().disableOnlineFeatures)return;let c=[...e.messages,{role:"assistant",content:e.finalTurn.content},{role:"user",content:`Your previous reply was not valid JSON matching the required schema (${l.error}). Reply with ONLY a JSON object that matches the schema \u2014 no prose, no code fences.`}],u={...t,messages:c,tools:void 0,toolChoice:"none",responseFormat:{schema:s,name:"response",strict:!0}};try{let d=await t1(this.app,o,n,i,u,a),f=Z9(d.content,s);return f.ok?f.value:void 0}catch{return}}toGenerateResult(e){let t=e.steps.map(i=>({stepNumber:i.stepNumber,text:i.text,toolCalls:i.toolCalls.map(dye),toolResults:i.toolResults.map(pye),finishReason:i.finishReason})),n=t[t.length-1];return{text:e.text,steps:t,toolCalls:n?.toolCalls??[],toolResults:n?.toolResults??[],usage:{inputTokens:e.usage.promptTokens,outputTokens:e.usage.completionTokens,totalTokens:e.usage.totalTokens},finishReason:e.finishReason}}assignVariable(e,t){let n=e.trim(),i=("> "+t).replace(/\n/g,`
> `);this.choiceExecutor.variables.set(n,t),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(e){xE(e)}}});function xN(r){let e=(0,tK.getFrontMatterInfo)(r);return e.exists?e.contentStart:0}function hye(r,e){let t=xN(r);if(t===0)return 0;if(eK.test(e))return t;let n=eK.exec(r.slice(t));return n?t+n[0].length:t}function EN(r,e){if(e.length===0)return{content:r,insertedStartOffset:null,insertedEndOffset:null};let t=hye(r,e),n=r.slice(0,t),i=r.slice(t),o=n.length>0&&!n.endsWith(`
`)&&!mye.test(e)?`
`:"",s=i.length>0&&!e.endsWith(`
`)?`
`:"",a=n.length+o.length,l=a+e.length;return{content:`${n}${o}${e}${s}${i}`,insertedStartOffset:a,insertedEndOffset:l}}function RD(r,e){return EN(r,e).content}var tK,eK,mye,TE=b(()=>{tK=require("obsidian"),eK=/^[^\S\r\n]*\r?\n/,mye=/^\r?\n/});function TN(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function _N(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function mf(r,e){let t=(e??[]).map(n=>TN(n)).filter(n=>n.length>0);return t.length===0?!0:r?_N(r.normalize("NFC"),t):!1}var $D=b(()=>{});function hf(r,e={}){let t=(r??"").trim();if(!t)throw new la("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new la(`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 la("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new la(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new la(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);gye(a,i)}let s=(e.allowedRoots??[]).map(a=>TN(a)).filter(a=>a.length>0);if(s.length>0&&!_N(i,s))throw new la(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function gye(r,e){if(J_.test(r))throw new la(`Path segment "${r}" contains control characters: "${e}".`);if(eA.test(r))throw new la(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${e}".`);if(tA.test(r))throw new la(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&Om(t))throw new la(`Path segment "${r}" is a reserved device name: "${e}".`)}var la,rK=b(()=>{rA();$D();la=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function Yg(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(nK(e.only,n,"only"),nK(e.exclude,n,"exclude"),e.only){let o=new Set(e.only);t=t.filter(([s])=>o.has(s))}if(e.exclude){let o=new Set(e.exclude);t=t.filter(([s])=>!o.has(s))}let i=e.prefix??"";return Object.fromEntries(t.map(([o,s])=>[i+o,s]))}function _E(r){return{...r,__qaTool:!0}}function nK(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&M.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...e].join(", ")}.`)}var OD=b(()=>{Me()});function uK(r,e={}){let t=e.allowedRoots,n={read_note:gf({description:"Read a note's full markdown content by vault path.",inputSchema:vf({path:ca("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=hf(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof kN.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>iK?a.slice(0,iK)+`
\u2026[truncated]`:a}}}),list_notes:gf({description:"List markdown notes, optionally within a folder.",inputSchema:vf({folder:ca("Folder to list (omit for the whole vault)."),limit:oK("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?hf(String(i),{allowedRoots:t}):"",a=lK(aK(o,vye),1,yye),l=ns(r,s).filter(c=>mf(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:gf({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:vf({query:ca("Text to search for."),in:sK(["name","content","both"],"Where to search (default both)."),limit:oK("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=lK(aK(s,bye),1,wye),u=r.vault.getMarkdownFiles().filter(m=>mf(m.path,t)),d=[],f=0,p=!1;for(let m of u){if(d.length>=c)break;if(l!=="content"&&m.basename.toLowerCase().includes(a)){d.push({path:m.path});continue}if(l!=="name"){if(f>=Cye){p=!0;continue}f++;let g=await r.vault.cachedRead(m),y=g.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:Eye(g,y)})}}return{results:d,scannedFiles:f,truncated:d.length>=c||p}}}),get_property_values:gf({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:vf({field:ca("Frontmatter property name."),folder:ca("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?hf(String(o),{allowedRoots:t}):"",a=(o?ns(r,s):r.vault.getMarkdownFiles()).filter(c=>mf(c.path,t)),l=new Set;for(let c of a){let d=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(d!=null){for(let f of Array.isArray(d)?d:[d])if(typeof f!="object"){let p=String(f).trim();p&&l.add(p)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:gf({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:vf({path:ca("Vault path for the new note."),content:ca("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=hf(AN(String(i)),{allowedRoots:t});return await vg(r,s),await xye(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:gf({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:vf({path:ca("Vault path to the existing note."),content:ca("Markdown to append."),position:sK(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=hf(AN(String(i)),{allowedRoots:t}),l=cK(r,a);await vg(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?RD(c,u.endsWith(`
`)?u:u+`
`):`${c}${c.endsWith(`
`)||c.length===0?"":`
`}${u}`;return await r.vault.modify(l,d),{appended:!0,path:a}}}),insert_under_heading:gf({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:vf({path:ca("Vault path to the existing note."),heading:ca("Exact heading text (without the # markers)."),content:ca("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=hf(AN(String(i)),{allowedRoots:t}),l=cK(r,a);await vg(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(p=>p.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),f=Tye(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,f),{inserted:!0,path:a,heading:String(o)}}})};return Yg(n,e)}function gf(r){return{...r,__qaTool:!0}}function vf(r,e){return{type:"object",properties:r,required:e}}function ca(r){return{type:"string",description:r}}function oK(r){return{type:"integer",description:r}}function sK(r,e){return{type:"string",enum:r,description:e}}function aK(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function lK(r,e,t){return Math.max(e,Math.min(t,r))}function AN(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 cK(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof kN.TFile))throw new Error(`Note not found: ${e}`);return t}async function xye(r,e){let t=e.lastIndexOf("/");if(t<=0)return;let n=e.slice(0,t);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function Eye(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function Tye(r,e,t,n,i){let o=r.split(`
`),s=o.length;for(let u of i)if(u.position.start.line>e&&u.level<=t){s=u.position.start.line;break}let a=n.endsWith(`
`)?n:n+`
`,l=o.slice(0,s),c=o.slice(s);for(;l.length>e+1&&l[l.length-1].trim()==="";)l.pop();return[...l,a.replace(/\n$/,""),...c].join(`
`)}var kN,iK,vye,yye,bye,wye,Cye,dK=b(()=>{kN=require("obsidian");qt();TE();$D();rK();IO();OD();iK=16e3,vye=100,yye=200,bye=25,wye=50,Cye=400});function fK(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof ND.TFile)||s.extension!=="md"?null:mf(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(ND.MarkdownView);return s&&mf(s.file?.path,t)?s:null},o={get_active_note:_E({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>pK?a.slice(0,pK)+`
\u2026[truncated]`:a}}}}),get_selection:_E({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 Yg(o,e)}var ND,pK,mK=b(()=>{ND=require("obsidian");$D();OD();pK=16e3});function hK(r={}){let e={get_date:_E({description:"Get the current date/time. Optionally pass a moment.js format and a day offset.",inputSchema:{type:"object",properties:{format:{type:"string",description:"moment.js format, e.g. YYYY-MM-DD"},offset:{type:"integer",description:"Day offset from today (e.g. 1 = tomorrow)."}}},readOnly:!0,execute:async({format:t,offset:n})=>({date:qs({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return Yg(e,r)}var gK=b(()=>{qt();OD()});var AE,Kg,vK=b(()=>{AE=require("obsidian");Hr();c1();Kg=class r extends AE.Modal{constructor(t,n,i=[],o){super(t);this.items=n;this.selectedItems=i;this.header=o;this._selectedItems=[...i],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open(),this.picker.focusSearchOnOpen()}static Open(t,n,i,o){return new r(t,n,i,o).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","checkboxPrompt"),this.header&&(this.titleEl.textContent=this.header),this.addSearchableOptions(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise(rn())}addSearchableOptions(){this.picker=new tf(this.contentEl,{items:this.items.map(t=>({key:t,value:t,label:t})),isSelected:({value:t})=>this._selectedItems.includes(t),onToggle:({value:t},n)=>{if(n){this._selectedItems.includes(t)||this._selectedItems.push(t);return}this._selectedItems=this._selectedItems.filter(i=>i!==t)},getSelectedCount:()=>new Set(this._selectedItems).size})}addSubmitButton(){let t=this.contentEl.createDiv("submitButtonContainer");new AE.ButtonComponent(t).setButtonText("Submit").setCta().onClick(()=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()}),new AE.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.close()})}}});var LD,kE,yK=b(()=>{LD=require("obsidian"),kE=class r extends LD.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Show(t,n,i){return new r(t,n,i).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(i=>this.contentEl.createEl("p",{text:i}));let t=this.contentEl.createDiv(),n=new LD.ButtonComponent(t).setButtonText("OK").onClick(()=>this.close());Object.assign(t.style,{display:"flex",justifyContent:"flex-end"}),n.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}}});var BD,bK=b(()=>{Nu();aN();yl();BD=class extends hn{constructor(e,t,n){super(e,t),this.fieldInput=n;let i=Ki.parse(n);this.fieldName=i.fieldName,this.filters=i.filters}async getSuggestions(e){let t=await I9(this.app,this.fieldName,this.filters),n=(e||"").toLowerCase();return n?t.filter(i=>i.toLowerCase().includes(n)).slice(0,200):t.slice(0,200)}renderSuggestion(e,t){this.renderMatch(t,e,this.getCurrentQuery())}selectSuggestion(e){this.inputEl.value=e;let t=new Event("input",{bubbles:!0});t.fromCompletion=!0,this.inputEl.dispatchEvent(t),this.close()}}});var wK,SN,VD,CK=b(()=>{wK=require("obsidian");yl();SN=200,VD=class extends hn{constructor(t,n,i,o,s,a,l){super(t,n);this.getOptions=i;this.isSelected=o;this.onSelect=s;this.multiSelect=a;this.allowCustomInput=l;a&&n.setAttribute("aria-multiselectable","true")}getSuggestions(t){let n=t.trim(),i=this.getOptions().filter(u=>!this.isSelected(u.value));if(!n)return i.slice(0,SN);let o=(0,wK.prepareFuzzySearch)(n),s=i.map(u=>({option:u,match:o(`${u.label} ${u.path}`)})).filter(u=>u.match!==null).sort((u,d)=>d.match.score-u.match.score).slice(0,SN).map(({option:u})=>u);if(!this.allowCustomInput)return s;let a=n.toLocaleLowerCase(),l=this.getOptions().some(u=>u.label.toLocaleLowerCase()===a||u.path.toLocaleLowerCase()===a),c=this.isSelected(n);return l||c?s:[{value:n,label:`Use \u201C${n}\u201D`,path:"Custom value",isCustom:!0},...s].slice(0,SN)}renderSuggestion(t,n){n.addClass("qa-onepage-file-suggestion");let i=n.createDiv({cls:"qa-onepage-file-suggestion__text"}),o=i.createDiv({cls:"qa-onepage-file-suggestion__label"});t.isCustom?o.setText(t.label):this.renderMatch(o,t.label,this.getCurrentQuery().trim()),i.createDiv({cls:"qa-onepage-file-suggestion__path",text:t.path})}selectSuggestion(t){if(this.onSelect(t),this.inputEl.value="",!this.multiSelect){this.close();return}let n=new Event("input",{bubbles:!0});n.fromCompletion=!0,n.keepOpen=!0,this.inputEl.dispatchEvent(n),this.inputEl.focus()}}});var UD,xK=b(()=>{yl();Mo();UD=class extends hn{constructor(e,t,n,i=!1,o=!1,s){super(e,t),this.options=n.map(a=>mn(a)),this.caseSensitive=i,this.multiSelect=o,this.onSelect=s,this.multiSelect&&this.inputEl.setAttribute("aria-multiselectable","true")}parseMultiSelectInput(e){if(!this.multiSelect)return{alreadySelected:[],activeTerm:e};let t=e.split(",").map(n=>n.trim());return{alreadySelected:t.slice(0,-1).filter(Boolean),activeTerm:t[t.length-1]||""}}getRemainingOptions(e){return this.options.filter(t=>!e.includes(t))}getSuggestions(e){let t=Ec(e),{alreadySelected:n,activeTerm:i}=this.parseMultiSelectInput(t),o=this.caseSensitive?i:i.toLowerCase(),s=this.getRemainingOptions(n);return o?s.filter(a=>(this.caseSensitive?a:a.toLowerCase()).includes(o)).slice(0,200):s.slice(0,200)}renderSuggestion(e,t){this.renderMatch(t,e,this.getCurrentQuery())}selectSuggestion(e){this.multiSelect?this.selectMultipleItem(e):this.selectSingleItem(e)}selectSingleItem(e){this.inputEl.value=e;let t=new Event("input",{bubbles:!0});t.fromCompletion=!0,this.inputEl.dispatchEvent(t),this.close()}selectMultipleItem(e){let{alreadySelected:t}=this.parseMultiSelectInput(this.inputEl.value);t.push(e),this.onSelect?.(e);let n=this.getRemainingOptions(t).length>0;this.inputEl.value=n?t.join(", ")+", ":t.join(", "),this.inputEl.setSelectionRange(this.inputEl.value.length,this.inputEl.value.length);let i=new Event("input",{bubbles:!0}),o=i;o.fromCompletion=!0,n?(o.keepOpen=!0,this.inputEl.dispatchEvent(i),this.inputEl.focus()):(this.inputEl.dispatchEvent(i),this.close())}}});function EK(r,e,t){return t?e.get(r)??r:r}function TK(r,e){return e.length===0?r:r===""?e[0]??"":e.includes(r)?r:e[0]??""}var _K=b(()=>{});var Xt,Qg,DN=b(()=>{Xt=require("obsidian");_t();p1();bK();CK();xK();Zx();Gd();Pt();$_();_K();xl();Hr();Gs();Qg=class extends Xt.Modal{constructor(t,n,i,o){super(t);this.result=new Map;this.multiSelections=new Map;this.fileSelections=new Map;this.dateParseErrors=new Set;this.previewContainerEl=null;this.previewToken=0;this.settled=!1;this.imagePasteHandles=[];this.filePickerSuggesters=[];this.requirements=n,this.initialValues=new Map,this.computePreview=o,i?.forEach((s,a)=>{typeof s=="string"&&this.initialValues.set(a,s)}),this.updatePreviewDebounced=(0,Xt.debounce)(this.updatePreviews.bind(this),150,!0),this.waitForClose=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open()}display(){this.containerEl.addClass("quickAddModal","onePageInputModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:"Provide inputs"}).addClass("qa-onepage-title"),this.computePreview&&(this.previewContainerEl=this.contentEl.createDiv(),this.previewContainerEl.addClass("qa-onepage-preview","qa-hidden")),this.requirements.forEach(i=>this.renderField(i)),this.computePreview&&this.updatePreviews();let n=this.contentEl.createDiv();new Xt.Setting(n).addButton(i=>i.setButtonText("Submit").setCta().onClick(()=>this.submit())).addButton(i=>i.setButtonText("Cancel").onClick(()=>this.cancel()))}onOpen(){this.contentEl.querySelector("input, textarea, select")?.focus();let n=this.scope;typeof n?.register=="function"&&n.register(["Mod"],"Enter",()=>(this.submit(),!1))}renderField(t){let n=(o,s)=>{this.result.set(o,s),this.updatePreviewDebounced()},i=this.initialValues.get(t.id)??t.defaultValue??"";switch(t.type){case"textarea":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Xt.TextAreaComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),s.inputEl.addClass("qa-onepage-textarea"),this.enableImagePaste(t,s.inputEl);break}case"text":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Xt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),this.enableImagePaste(t,s.inputEl);break}case"number":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Xt.TextComponent(o.controlEl);s.inputEl.type="number",s.inputEl.inputMode="decimal",t.numericConfig?.min!==void 0&&(s.inputEl.min=String(t.numericConfig.min)),t.numericConfig?.max!==void 0&&(s.inputEl.max=String(t.numericConfig.max)),s.inputEl.step=t.numericConfig?.step!==void 0?String(t.numericConfig.step):"any";let a=t.numericConfig?Na(i,t.numericConfig):i;s.setPlaceholder(t.placeholder??"").setValue(a).onChange(l=>n(t.id,t.numericConfig?Na(l,t.numericConfig):l)),n(t.id,a);break}case"slider":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));o.controlEl.parentElement?.addClass("qa-onepage-slider-setting"),t.description&&o.setDesc(t.description);let s=t.sliderConfig??{min:0,max:100,step:1},a=t.optional&&i==="",l=By(i,s),c=o.controlEl.createDiv({cls:"qa-onepage-slider"}),u=c.createEl("input");u.type="range",u.min=String(s.min),u.max=String(s.max),u.step=String(s.step),u.value=l;let d=new Xt.TextComponent(c);d.inputEl.type="number",d.inputEl.inputMode="decimal",d.inputEl.min=String(s.min),d.inputEl.max=String(s.max),d.inputEl.step=String(s.step),d.setValue(a?"":l),n(t.id,a?"":l),u.addEventListener("input",()=>{d.inputEl.value=u.value,n(t.id,u.value)}),d.onChange(f=>{if(f===""&&t.optional){n(t.id,"");return}let p=Na(f,s);p!==""&&(u.value=p,d.inputEl.value=p,n(t.id,p))});break}case"dropdown":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Xt.DropdownComponent(o.controlEl),a=t.options??[],l=t.displayOptions??a;if(a.length>0){t.optional&&s.addOption("","Skip (leave empty)"),a.forEach((u,d)=>{let f=l[d]??u;s.addOption(u,f)});let c=TK(i,a);s.setValue(c),n(t.id,c),s.onChange(u=>n(t.id,u))}else s.setDisabled(!0),o.controlEl.createDiv({text:t.placeholder||"No options available"}).addClass("qa-onepage-dropdown-note");break}case"date":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=o.controlEl.createDiv({cls:"qa-date-input"}),a=new Xt.TextComponent(s),l="Enter a date (e.g., 'today', 'next friday', '2025-12-25')",c,u=i;i?.startsWith("@date:")&&(c=i.slice(6),u=(t.dateFormat?Ul(c,t.dateFormat):void 0)??(c.length>=10?c.slice(0,10):c)),a.setPlaceholder(l).setValue(u??"");let d=s.createDiv({cls:"qa-date-picker-container"}),f=XS({container:d,initialIso:c,withTime:t.withTime===!0,onSelect:E=>{E?w(E):k()}}),p=s.createDiv();p.addClass("qa-date-preview-text");let m=jv(le.getState().dateAliases);if(m.length>0){let E=s.createEl("details");E.addClass("qa-date-alias-details"),E.createEl("summary",{text:`Aliases (${m.length})`}).addClass("qa-date-alias-summary");let D=E.createEl("div");D.textContent=$T(le.getState().dateAliases),D.addClass("qa-date-alias-list")}let v=E=>{if(t.dateFormat){let x=Ul(E,t.dateFormat);if(x)return x}return E.length>=10?E.slice(0,10):E},g=(E,x)=>{p.setText(E),p.toggleClass("is-error",x)},y=E=>{f.setSelectedIso(E)},w=E=>{c=E,this.dateParseErrors.delete(t.id);let x=v(E);a.inputEl.value=x,n(t.id,`@date:${E}`),g(x,!1),y(E)},k=()=>{a.inputEl.value="",C("")},C=E=>{let x=(E??"").trim();if(!x&&t.defaultValue&&!t.optional){let P=nf(t.defaultValue,t.dateFormat);if(P.isValid&&P.isoString){c=P.isoString,this.dateParseErrors.delete(t.id),n(t.id,`@date:${P.isoString}`),y(P.isoString);let H=P.formatted??v(P.isoString);g(H,!1);return}g(P.error||"Unable to parse date",!0),this.dateParseErrors.add(t.id),n(t.id,""),y();return}if(!x){c=void 0,this.dateParseErrors.delete(t.id),n(t.id,""),y(),g(t.optional?"Will be left empty":"Preview will appear here",!1);return}if(x.startsWith("@date:")){let P=x.slice(6).trim();if(P){this.dateParseErrors.delete(t.id),w(P);return}}let D=nf(x,t.dateFormat);if(D.isValid&&D.isoString){c=D.isoString,this.dateParseErrors.delete(t.id),n(t.id,`@date:${D.isoString}`),y(D.isoString);let P=D.formatted??v(D.isoString);g(P,!1)}else c=void 0,this.dateParseErrors.add(t.id),n(t.id,""),y(),g(D.error||"Unable to parse date",!0)};a.onChange(E=>C(E)),c?w(c):C(u??"");break}case"field-suggest":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Xt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(l=>n(t.id,l));let a=t.id.startsWith(Qd)?t.id.slice(Qd.length):t.id;try{new BD(this.app,s.inputEl,a)}catch{}break}case"suggester":{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=t.options??[],a=t.displayOptions??s,l=new Map,c=new Map;s.forEach((f,p)=>{let m=a[p]??f;l.set(m,f),c.has(f)||c.set(f,m)});let u=c.get(i)??i,d=new Xt.TextComponent(o.controlEl);if(d.setPlaceholder(t.placeholder??"Type to search...").setValue(u).onChange(f=>n(t.id,f)),d.inputEl.addEventListener("input",f=>{let p=!!f.fromCompletion,m=d.inputEl.value,v=EK(m,l,p);(v!==m||p)&&n(t.id,v)}),a.length>0)try{let f=t.suggesterConfig?.caseSensitive??!1,p=t.suggesterConfig?.multiSelect??!1;new UD(this.app,d.inputEl,a,f,p,p?m=>{let v=this.multiSelections.get(t.id)??[];v.push(m),this.multiSelections.set(t.id,v)}:void 0)}catch{}break}case"file-picker":{this.renderFilePickerField(t,i,n);break}default:{let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t)),s=new Xt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),this.enableImagePaste(t,s.inputEl)}}this.result.has(t.id)||this.result.set(t.id,i)}renderFilePickerField(t,n,i){let o=new Xt.Setting(this.contentEl).setName(this.decorateLabel(t));o.settingEl.addClass("qa-onepage-file-picker-setting"),t.description&&o.setDesc(t.description);let s=t.options??[],a=t.displayOptions??s,l=s.map((E,x)=>{let D=Cp(E);return{value:E,label:a[x]??E,path:D.kind==="file"?D.path:E}}),c=new Map(l.map(E=>[E.value,E])),u=t.suggesterConfig?.multiSelect??!1,d=t.suggesterConfig?.allowCustomInput??!1,f=new Set,p=new Map,m=E=>{let x=p.get(E);if(x)return x;let D={value:E,label:E,path:"Custom value",isCustom:!0};return p.set(E,D),D};if(n&&c.has(n))f.add(n);else if(n&&d){let E=Cp(n),x=E.kind==="custom"?E.text:n;m(x),f.add(x)}else!u&&l.length>0&&f.add(l[0].value);let v=o.controlEl.createDiv({cls:"qa-onepage-file-picker"}),g=v.createDiv({cls:"qa-onepage-file-picker__selection"});g.setAttribute("aria-live","polite");let y=new Xt.TextComponent(v);y.inputEl.addClass("qa-onepage-file-picker__input"),y.setPlaceholder(t.placeholder??(u?"Search and add files...":"Search files...")),y.inputEl.setAttribute("aria-label",u?`Add files for ${t.label}`:`Choose file for ${t.label}`);let w=()=>{let E=l.filter(x=>f.has(x.value));for(let x of p.values())f.has(x.value)&&E.push(x);return E},k=()=>{let E=w(),x=E.map(D=>D.value);this.fileSelections.set(t.id,x),i(t.id,u?x.join(", "):x[0]??""),g.empty(),g.toggleClass("qa-hidden",E.length===0);for(let D of E){let P=g.createDiv({cls:"qa-onepage-file-picker__chip"});P.setAttribute("title",D.path),P.createSpan({cls:"qa-onepage-file-picker__chip-label",text:D.label});let H=P.createEl("button",{cls:"qa-onepage-file-picker__remove",text:"\xD7"});H.type="button",H.setAttribute("aria-label",`Remove ${D.label}`),H.addEventListener("click",()=>{f.delete(D.value),k(),y.inputEl.focus()})}},C=E=>{let x=E.isCustom?m(E.value):E;u||f.clear(),f.add(x.value),k()};y.inputEl.addEventListener("keydown",E=>{if(E.key==="Backspace"&&y.inputEl.value===""&&f.size>0){let x=w().at(-1);if(!x)return;E.preventDefault(),f.delete(x.value),k()}});try{let E=new VD(this.app,y.inputEl,()=>[...l,...p.values()],x=>f.has(x),C,u,d);this.filePickerSuggesters.push(E)}catch{y.setDisabled(!0)}k()}enableImagePaste(t,n){t.pathContext||this.imagePasteHandles.push(Dm(this.app,n,{}))}decorateLabel(t){if(!t.optional)return t.label;let n=this.contentEl.ownerDocument,i=n.createDocumentFragment();i.appendChild(n.createTextNode(t.label));let o=n.createElement("span");return o.textContent=" (optional)",o.className="qa-onepage-optional-badge",i.appendChild(o),i}submit(){if(this.settled)return;let t=this.imagePasteHandles.find(o=>o.isBusy());if(t){t.whenIdle().then(()=>this.submit());return}let n={},i=this.requirements.find(o=>o.type==="date"&&!o.optional&&this.dateParseErrors.has(o.id));if(i){new Xt.Notice(`QuickAdd: "${i.label}" is not a valid date. Fix it or clear it before submitting.`);return}for(let[o,s]of this.multiSelections){let a=(this.result.get(o)??"").replace(/,\s*$/,"").trim();s.join(", ")!==a&&this.multiSelections.delete(o)}Object.assign(n,this.collectAnswers()),this.settled=!0,this.close(),this.resolvePromise(n)}collectAnswers(){let t=new Map(this.requirements.map(i=>[i.id,i])),n={};return this.result.forEach((i,o)=>{let s=t.get(o);if(s?.type==="date"&&i===""){let a=this.dateParseErrors.has(o);if(!s.optional||a)return}n[o]=i}),n}collectPreviewAnswers(){let t=this.collectAnswers(),n=new Map(this.requirements.map(i=>[i.id,i]));for(let[i,o]of this.fileSelections)t[i]=n.get(i)?.suggesterConfig?.multiSelect?[...o]:o[0]??"";return t}cancel(){this.settled=!0,this.close(),this.rejectPromise(rn())}onClose(){for(let t of this.imagePasteHandles)t.detach();this.imagePasteHandles.length=0;for(let t of this.filePickerSuggesters)t.destroy();this.filePickerSuggesters.length=0,this.settled||(this.settled=!0,this.rejectPromise(rn()))}async updatePreviews(){if(!this.computePreview||!this.previewContainerEl)return;let t=++this.previewToken;try{let n=await this.computePreview(this.collectPreviewAnswers());if(t!==this.previewToken||!this.previewContainerEl)return;this.previewContainerEl.empty(),this.previewContainerEl.toggleClass("qa-hidden",n.length===0);for(let i of n){let o=i.diagnostics.filter(u=>u.severity==="error"),a=o.some(u=>u.kind!=="path")?"Unresolved":o.length>0?"Won't be created":i.label,l=this.previewContainerEl.createDiv({cls:"qa-onepage-preview-row"});l.createEl("div",{text:`${a}:`,cls:"qa-preview-key"}),l.createEl("div",{text:i.text,cls:"qa-preview-val"}).setAttribute("title",i.text);for(let u of i.diagnostics){let d=this.previewContainerEl.createDiv({cls:"qa-preview-issue"});d.toggleClass("qa-preview-issue--error",u.severity==="error"),d.createSpan({cls:"qa-visually-hidden",text:u.severity==="error"?"Error: ":"Warning: "}),d.appendText(u.message),d.setAttribute("title",u.message)}}}catch{}}}});var qD,AK=b(()=>{i_();qD=class{static filterFiles(e,t,n){return Object.keys(t).length===0?e:e.filter(i=>{let o=this.getIncludeFolders(t);return!(o.length>0&&!o.some(s=>this.matchesFolder(i,s))||t.tags&&t.tags.length>0&&!this.matchesTags(i,t.tags,n))})}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(e,t){let n=this.normalizePath(t),i=this.normalizePath(e.path);return i.startsWith(n+"/")||i.substring(0,i.lastIndexOf("/"))===n}static matchesTags(e,t,n){let i=n(e);if(!i)return!1;let o=this.getAllTags(i);return t.map(yc).filter(Boolean).every(a=>o.some(l=>l===a||l.startsWith(a+"/")))}static getAllTags(e){let t=[];return e.frontmatter?.tags&&t.push(..._u(e.frontmatter.tags)),e.frontmatter?.tag&&t.push(..._u(e.frontmatter.tag)),e.tags&&t.push(...e.tags.map(n=>yc(n.tag))),t.filter(Boolean)}static normalizePath(e){return e.replace(/^\/+|\/+$/g,"")}}});function IK(r){return SE.some(e=>e.id===r)}function kK(r){let e=(0,WD.getFrontMatterInfo)(r);return e.exists?{frontmatterYaml:e.frontmatter,body:r.slice(e.contentStart)}:{frontmatterYaml:null,body:r}}function _ye(r,e,t){return t==="bottom"?`${r}
${e}`:RD(r,`${e}
`)}function Aye(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function SK(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function DK(r,e){let t=SK(r),n=SK(e);if(t===null||n===null)return;let i=[],o=new Set(t);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...t,...i]}var WD,SE,Xg,zD=b(()=>{WD=require("obsidian");Me();qt();_D();Gx();Z_();My();Wg();TE();SD();Dl();Q_();SE=[{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."}];Xg=class extends yd{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.resolvedTemplatePath=l??null}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(Ri(this.templatePath,"Cannot apply template: no template path given."),this.mode){case"replace":return await this.overwriteFileWithTemplate(this.targetFile,await this.getResolvedTemplatePath());case"top":case"bottom":return await this.insertTemplateIntoFile(this.mode);case"cursor":return await this.insertTemplateAtCursor()}}async computeChoiceTargetPath(t){let n=t.folder,i;if(this.formatter.setTargetFolderPath(null),n?.enabled){if(n.chooseWhenCreatingNote)return null;if(n.createInSameFolderAsActiveFile)i=this.targetFile.parent?.path??"";else{if(n.chooseFromSubfolders)return null;if(n.folders.length===1)i=await this.formatter.formatFolderPath(n.folders[0]);else return null}}else i=this.targetFile.parent?.path??"";i==="/"&&(i="");let o=this.targetFile.basename,s=!1;if(t.fileNameFormat?.enabled&&t.fileNameFormat.format){this.formatter.setTargetFolderPath(i);let a=await this.formatter.formatFileName(t.fileNameFormat.format,"generic"),l=li(a,"File name"),c=this.stripDuplicateFolderPrefix(l,i);o=c.fileName,s=this.shouldTreatFormattedNameAsVaultRelativePath(l,c.strippedPrefix,n?.enabled??!1)}return o.slice(o.lastIndexOf("/")+1).trim()?this.normalizeTemplateFilePath(s?"":i,o,await this.getResolvedTemplatePath()):null}async insertTemplateIntoFile(t){let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=kK(n);return s.trim().length>0&&await this.app.vault.process(this.targetFile,a=>_ye(a,s,t)),await this.mergeFrontmatterProperties(o,i),this.targetFile}async insertTemplateAtCursor(){let t=ry(this.app,this.targetFile);Ri(t,"Cannot insert at cursor: the note is not open in the active editor.");let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=kK(n);return s.trim().length>0&&t.editor.replaceSelection(s),await this.mergeFrontmatterProperties(o,i),this.targetFile}async formatTemplateForTargetFile(){let t=await this.getTemplateContent(await this.getResolvedTemplatePath());this.formatter.setTitle(this.targetFile.basename),this.formatter.setTargetFolderPath(zo(this.targetFile.path));let n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",t,()=>this.formatter.formatFileContent(t))),i=this.formatter.getAndClearTemplatePropertyVars();return this.targetFile.extension==="md"&&(n=await hc(this.app,n,this.targetFile)),{formatted:n,templatePropertyVars:i}}async mergeFrontmatterProperties(t,n){if(!t||this.targetFile.extension!=="md")return;let i;try{i=(0,WD.parseYaml)(t)}catch(o){M.logWarning(`Could not parse template frontmatter for merging: ${o}`);return}if(!(!i||typeof i!="object"||Array.isArray(i))){if(n&&n.size>0)for(let[o,s]of n){let a=o.includes(Oa.PATH_SEPARATOR)?o.split(Oa.PATH_SEPARATOR):[o];mN(i,a,X_(s))}await this.app.fileManager.processFrontMatter(this.targetFile,o=>{for(let[s,a]of Object.entries(i)){if(fN([s])){M.logWarning(`Skipping front matter merge for unsafe key "${s}" to avoid prototype pollution.`);continue}let l=Object.hasOwn(o,s)?o[s]:void 0,c=uq(this.app,s);if(Aye(l)){c&&Array.isArray(a)?o[s]=DK([],a)??[]:o[s]=a;continue}if(c){let u=DK(l,a);u!==void 0&&(o[s]=u)}}})}}}});function kye(r){return r.trim().length===0}function Jg(r){return!zr.test(r)&&!qi.test(r)}function Sye(r){return r.kind==="choice"?`Choice: ${r.choice.name}`:`Template: ${r.path}`}function PK(r){let e=r.replace(/^\/+/,"").toLowerCase();return/\.(md|canvas|base)$/.test(e)?e:`${e}.md`}function Dye(r,e){let t=Vn(r).filter(o=>o.type==="Template"&&!!o.templatePath&&Jg(o.templatePath)),n=new Set(t.map(o=>PK(o.templatePath))),i=t.map(o=>({kind:"choice",choice:o}));for(let o of e)Jg(o)&&(n.has(PK(o))||i.push({kind:"file",path:o}));return i}async function DE(r,e,t){let n=t.file??r.workspace.getActiveFile();if(!n||n.extension!=="md")return new Zg.Notice("QuickAdd: No active markdown note to apply a template to."),null;let i=t.choiceExecutor.triggerContext;i==null&&(t.choiceExecutor.triggerContext={activeFile:n});try{let o=!t.templatePath,s;if(t.templatePath)s={kind:"file",path:t.templatePath};else{let m=await Iye(r,e);if(!m)return null;s=m}let a=s.kind==="choice"?s.choice.templatePath:s.path;if(!Jg(a))return new Zg.Notice("QuickAdd: Only markdown templates can be applied to a note. Canvas and base templates create their own file types."),null;let l=await r.vault.cachedRead(n),c=kye(l),u;if(t.mode)u=t.mode;else if(c)u="replace";else if(!o)u="bottom";else{let m=await Pye(r,n);if(!m)return null;u=m}t.choiceExecutor.variables.has("value")||t.choiceExecutor.variables.set("value",n.basename);let d=new Xg(r,e,n,a,u,t.choiceExecutor);d.setPromptRunContext({choiceName:s.kind==="choice"?s.choice.name:void 0,draftScopeId:s.kind==="choice"?s.choice.id:`template-insert#${a}`,destination:n.path,destinationKind:"file"});let f=await d.getResolvedTemplatePath();return Jg(f)?await d.apply()?(o&&s.kind==="choice"&&(d.setPromptRunContext({destination:void 0,destinationKind:void 0}),await Fye(r,d,s.choice,n)),await Eu(r,n),new Zg.Notice(`Applied template to '${n.basename}'.`),n):null:(new Zg.Notice("QuickAdd: Only markdown templates can be applied to a note. Canvas and base templates create their own file types."),null)}catch(o){return It(o)||FK(o)||lt(o,"Error applying template to note"),null}finally{t.choiceExecutor.triggerContext=i}}function FK(r){return!!r&&typeof r=="object"&&r.name==="MacroAbortError"}async function Iye(r,e){let t=Dye(e.settings.choices,e.getTemplateFiles().map(n=>n.path));if(t.length===0)return new Zg.Notice("QuickAdd: No Template choices or template files found. Create a Template choice or set the template folder path in settings."),null;try{return await Lr.Suggest(r,t.map(Sye),t,"Apply template to note")}catch(n){if(It(n))return null;throw n}}async function Pye(r,e){let t=!!ry(r,e),n=SE.filter(i=>i.id!=="cursor"||t);try{return await Lr.Suggest(r,n.map(i=>i.label),n.map(i=>i.id),"How should the template be applied?")}catch(i){if(It(i))return null;throw i}}async function Fye(r,e,t,n){try{let i=await e.computeChoiceTargetPath(t);if(!i||i===n.path||await r.vault.adapter.exists(i)||!U9(i)||!await Xi.Prompt(r,"Move note to match choice settings?",`'${t.name}' creates notes at '${i}'. Move '${n.path}' there? Links to the note will be updated.`))return;let s=i.lastIndexOf("/"),a=s===-1?"":i.slice(0,s);a&&!await r.vault.adapter.exists(a)&&await r.vault.createFolder(a),await r.fileManager.renameFile(n,i)}catch(i){if(It(i)||FK(i))return;M.logWarning(`Could not move note to match choice settings: ${i}`)}}var Zg,IN=b(()=>{Zg=require("obsidian");_t();Hc();Yp();Me();qt();Wt();AD();Cr();zD()});function RK(r){return Array.from(r.entries())}function $K(r,e){r.clear();for(let[t,n]of e)r.set(t,n)}function Mye(r){if(!r||typeof r!="object")return;let e={};return typeof r.min=="number"&&Number.isFinite(r.min)&&(e.min=r.min),typeof r.max=="number"&&Number.isFinite(r.max)&&(e.max=r.max),e.min!==void 0&&e.max!==void 0&&e.max<e.min&&(delete e.min,delete e.max),typeof r.step=="number"&&Number.isFinite(r.step)&&r.step>0&&(e.step=r.step),Object.keys(e).length>0?e:void 0}function Rye(r){if(!r||typeof r!="object")return;let{min:e,max:t}=r,n=r.step??1;if(!(typeof e!="number"||typeof t!="number"||typeof n!="number"||!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||t<=e||n<=0))return{min:e,max:t,step:n}}function Xc(r){throw r instanceof Nt?r:It(r)?new Dt(Cu):r}var MK,ev,PN=b(()=>{vl();KS();Px();jh();ef();J9();dK();mK();gK();wN();Gg();vK();yK();$a();Hc();m1();Yp();sd();f1();Mo();DN();Pt();Me();qt();Cr();ED();AK();iN();Bs();Hr();Zx();IN();zD();MK=!1;ev=class r{static GetApi(e,t,n){return{requestInputs:async i=>{let o={},s=[];for(let u of i){let d=n.variables.get(u.id);if(d!=null){o[u.id]=String(d);continue}let f=Rye(u.sliderConfig),p=f??Mye(u.numericConfig),m=u.type==="slider"&&!f?"number":u.type;s.push({id:u.id,label:u.label??u.id,type:m,placeholder:u.placeholder,defaultValue:u.defaultValue,numericConfig:p,sliderConfig:f,options:u.options,dateFormat:u.dateFormat,description:u.description,optional:u.optional,suggesterConfig:u.suggesterConfig,source:"script"})}let a={};if(s.length>0){let u=n?.promptProvider;if(u)try{let d=await u.requestInputs(s);a=Object.fromEntries(Object.entries(d).map(([f,p])=>[f,Array.isArray(p)?p.join(", "):p]))}catch(d){Xc(d)}else{let d=new Qg(e,s,n.variables);try{a=await d.waitForClose}catch(f){Xc(f)}}}let l={...o,...a};for(let u of i)l[u.id]===void 0&&(l[u.id]="");Object.entries(l).forEach(([u,d])=>n.variables.set(u,d));let c={};for(let u of i){let d=l[u.id];if(d===void 0)continue;let f=d;if(u.type==="date"&&u.dateFormat&&typeof d=="string"&&d.startsWith("@date:")){let p=d.slice(6),m=Ul(p,u.dateFormat);m&&(f=m)}c[u.id]=f}return c},inputPrompt:(i,o,s,a)=>{let l=n?.promptProvider;return l?l.inputPrompt(i,o,s):r.inputPrompt(e,i,o,s,a)},datePrompt:(i,o)=>{let s=n?.promptProvider;return s?s.datePrompt(i,o):r.datePrompt(e,i,o)},wideInputPrompt:(i,o,s,a)=>{let l=n?.promptProvider;return l?l.wideInputPrompt(i,o,s):r.wideInputPrompt(e,i,o,s,a)},yesNoPrompt:(i,o)=>{let s=n?.promptProvider;return s?s.yesNoPrompt(i,o):r.yesNoPrompt(e,i,o)},infoDialog:(i,o)=>{let s=n?.promptProvider;return s?s.infoDialog(i,o):r.infoDialog(e,i,o)},suggester:(i,o,s,a=!1,l)=>{let c=n?.promptProvider;return c?c.suggester(i,o,s,a):r.suggester(e,i,o,s,a,l)},checkboxPrompt:(i,o,s)=>{let a=n?.promptProvider;return a?a.checkboxPrompt(i,o,s):r.checkboxPrompt(e,i,o,s)},executeChoice:async(i,o)=>{let s;try{s=t.getChoiceByName(i)}catch{s=void 0}if(!s){lt(new Error(`Choice named '${i}' not found`),"API executeChoice error");return}o&&Object.keys(o).forEach(l=>{n.variables.set(l,o[l])}),await n.execute(s);let a=n.consumeAbortSignal?.();if(n.variables.clear(),a)throw a},applyTemplateToActiveFile:async(i,o)=>{if(!i)throw new Error("applyTemplateToActiveFile requires a template path.");if(!Jg(i))throw new Error("applyTemplateToActiveFile only supports markdown templates. Canvas and base templates cannot be applied to a markdown note.");if(o?.mode!==void 0&&!IK(o.mode))throw new Error(`Invalid mode '${String(o.mode)}'. Valid modes: ${SE.map(a=>a.id).join(", ")}.`);let s=RK(n.variables);try{return await DE(e,t,{templatePath:i,mode:o?.mode,choiceExecutor:n})}finally{$K(n.variables,s)}},format:async(i,o,s=!0)=>{let a=s?RK(n.variables):null;o&&Object.keys(o).forEach(c=>{n.variables.set(c,o[c])});let l=await new xs(e,t,n).formatFileContent(i);return s&&a&&$K(n.variables,a),l},ai:{prompt:async(i,o,s)=>{let a=le.getState(),l=a.ai;if(a.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let c=r.GetApi(e,t,n).format,{model:u,provider:d}=Hh(o),f=await za(e,d);s?.assignToVariable&&xE(s.assignToVariable);let p=await P5(e,{model:u,provider:d,prompt:i,apiKey:f,modelOptions:s?.modelOptions??{},outputVariableName:s?.assignToVariable||s?.variableName||"output",showAssistantMessages:s?.showAssistantMessages??!0,systemPrompt:s?.systemPrompt??l.defaultSystemPrompt},(m,v)=>c(m,v,!1));return p?((s?.shouldAssignVariables||s?.assignToVariable)&&Object.entries(p).forEach(([m,v])=>{n.variables.set(m,v)}),p):(lt(new Error("AI Assistant returned null"),"AI Prompt error"),{})},chunkedPrompt:async(i,o,s,a,l)=>{let c=le.getState(),u=c.ai;if(c.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let d=r.GetApi(e,t,n).format,{model:f,provider:p}=Hh(s),m=await za(e,p);a?.assignToVariable&&xE(a.assignToVariable);let v=await $5(e,{model:f,provider:p,text:i,promptTemplate:o,chunkSeparator:a?.chunkSeparator??/\n/,apiKey:m,modelOptions:a?.modelOptions??{},outputVariableName:a?.assignToVariable||a?.variableName||"output",showAssistantMessages:a?.showAssistantMessages??!0,systemPrompt:a?.systemPrompt??u.defaultSystemPrompt,resultJoiner:a?.chunkJoiner??`
`,shouldMerge:a?.shouldMerge??!0,maxChunkTokens:a?.maxChunkTokens},(g,y)=>{let w={...l,...y};return d(g,w,!1)});return v?((a?.shouldAssignVariables||a?.assignToVariable)&&Object.entries(v).forEach(([g,y])=>{n.variables.set(g,y)}),v):(lt(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>AY(),getMaxTokens:i=>Hh(i).model.maxTokens,estimateTokens(i){return Uo(i)},countTokens(i,o){return MK||(MK=!0,M.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Uo(i)},getRequestLogs(i=10){return _5(i)},getRequestLogById(i){return k5(i)},getLastRequestLog(){return S5()},clearRequestLogs(){D5()},agent:i=>new MD(e,t,n,i),tool:i=>({...i,__qaTool:!0}),stepCountIs:i=>({stepNumber:o})=>o>=i,hasToolCall:i=>({toolCallNames:o})=>o.includes(i),tools:{vault:i=>uK(e,i),workspace:i=>fK(e,i),system:i=>hK(i)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async i=>await navigator.clipboard.writeText(i),getSelection:()=>tp(e),getSelectedText:()=>{let i=Nn(e);return i?i.editor.somethingSelected()?i.editor.getSelection():(lt(new Error("No text selected"),"Could not get selected text"),""):(lt(new Error("No active Markdown editor"),"Could not get selected text"),"")}},date:{now:(i,o)=>qs({format:i,offset:o}),tomorrow:i=>qs({format:i,offset:1}),yesterday:i=>qs({format:i,offset:-1})},fieldSuggestions:{getFieldValues:async(i,o)=>{let s=o?.includeInlineCodeBlocks?.map(u=>u.trim().toLowerCase()).filter(u=>u.length>0),a={folder:o?.folder,folders:o?.folders,tags:o?.tags,inline:o?.includeInline??!1,inlineCodeBlocks:s},l=e.vault.getMarkdownFiles();l=qD.filterFiles(l,a,u=>e.metadataCache.getFileCache(u));let c=new Set;for(let u of l){let f=e.metadataCache.getFileCache(u)?.frontmatter?.[i];if(f!=null){if(Array.isArray(f))f.forEach(p=>{if(p==null||typeof p=="object")return;let m=String(p).trim();m&&c.add(m)});else if(typeof f!="object"){let p=String(f).trim();p&&c.add(p)}}if(a.inline)try{let p=await e.vault.read(u);Lg.getFieldValues(p,i,{includeCodeBlocks:s}).forEach(v=>c.add(v))}catch{}}return Array.from(c).sort()},clearCache:i=>{Yc.getInstance().clear(i)}}}}static async inputPrompt(e,t,n,i,o){try{return await Dr.Prompt(e,t,n,i,void 0,{allowPeek:!0,...o})}catch(s){Xc(s)}}static async datePrompt(e,t,n){try{let i=await of.Prompt(e,t,n?.placeholder,n?.defaultValue,n?.dateFormat);if(i&&i.startsWith("@date:")){let o=i.slice(6);return(n?.dateFormat?Ul(o,n.dateFormat):null)??o}return i}catch(i){Xc(i)}}static async wideInputPrompt(e,t,n,i,o){try{return await dd.Prompt(e,t,n,i,void 0,{allowPeek:!0,...o})}catch(s){Xc(s)}}static async yesNoPrompt(e,t,n){let i;try{i=await Xi.Ask(e,t,n)}catch(o){Xc(o)}if(i===null)throw new Dt(Cu);return i}static async infoDialog(e,t,n){try{return await kE.Show(e,t,n)}catch(i){Xc(i)}}static async suggester(e,t,n,i,o=!1,s){try{let a;return typeof t=="function"?a=n.map((l,c,u)=>mn(t(l,c,u))):a=t.map(l=>mn(l)),o?await ln.Suggest(e,a,n,{...i?{placeholder:i}:{},...s?.renderItem?{renderItem:s.renderItem}:{}}):await Lr.Suggest(e,a,n,i,s?.renderItem)}catch(a){Xc(a)}}static async checkboxPrompt(e,t,n,i){try{return await(i===void 0?Kg.Open(e,t,n):Kg.Open(e,t,n,i))}catch(o){Xc(o)}}}});var tv,FN=b(()=>{uN();tv=class extends Bg{}});function OK(r){return new Promise(e=>window.setTimeout(e,r))}function yf(r){return r.split(`
`)}var HD=b(()=>{});async function LK(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):$ye(r,e.variables)}function $ye(r,e){let t=r.variableName?.trim();if(!t)return M.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(t in e))return M.logWarning(`Conditional command skipped: Variable '${t}' is not defined.`),!1;let n=e[t];switch(r.operator){case"isTruthy":return!!n;case"isFalsy":return!n}if(Bu(r.operator)){let i=Iq(r);return i===void 0?(M.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?NK(n,i,r):r.operator==="notContains"?!NK(n,i,r):Oye(n,i,r)}return!1}function NK(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return M.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1;if(Array.isArray(r))return r.map(o=>xF(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes(Lu(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=Lu(r),i=Lu(e);return typeof n=="string"&&n.includes(i)}function Oye(r,e,t){let n=xF(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return jD(n,e,(i,o)=>i<o);case"lessThanOrEqual":return jD(n,e,(i,o)=>i<=o);case"greaterThan":return jD(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return jD(n,e,(i,o)=>i>=o);default:return!1}}function jD(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(M.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):t(n,i)}var BK=b(()=>{Me();Bm()});function VK(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function bd(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function UK(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return bd("reuse",e);case"tab":return bd("tab",e);case"split":return bd("split",e,VK(r.direction,"vertical"));case"window":return bd("window",e);case"left-sidebar":return bd("left-sidebar",e);case"right-sidebar":return bd("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=VK(r.direction);return t?bd("split",e,n??"vertical"):bd("reuse",e)}var qK=b(()=>{Uk()});function WK(r){let e={hasOwnProperty:t=>r.has(t)};return new Proxy(e,{get(t,n){if(n==="hasOwnProperty")return e.hasOwnProperty;if(typeof n=="string")return r.get(n)},set(t,n,i){return typeof n!="string"||r.set(n,i),!0},deleteProperty(t,n){return typeof n!="string"||r.delete(n),!0},has(t,n){return typeof n=="string"&&r.has(n)},ownKeys(){return Array.from(r.keys())},getOwnPropertyDescriptor(t,n){if(n==="hasOwnProperty")return{value:e.hasOwnProperty,writable:!0,configurable:!0,enumerable:!1};if(!(typeof n!="string"||!r.has(n)))return{value:r.get(n),writable:!0,configurable:!0,enumerable:!0}}})}var zK=b(()=>{});function YK(r){return r!==null&&typeof r=="object"}function Lye(r){return typeof r=="function"}function KK(r){return YK(r)}function Bye(r){if(!KK(r))return;let{settings:e}=r;return YK(e)?e:void 0}function HK(r,e="command"){if(typeof r!="string"||!r.trim())return`the saved entry has no ${e} type, so QuickAdd cannot tell what it was meant to do. It is in .obsidian/plugins/quickadd/data.json.`;let t=e==="command"?Vye.get(r):void 0;return t||`QuickAdd does not recognise the ${e} type '${r}'. It can come from a newer version of QuickAdd, an imported package, or a hand-edited .obsidian/plugins/quickadd/data.json.`}function jK(r){return`${r.scriptPath}::${r.exportName??"default"}`}var Nye,GK,Vye,Hl,vE=b(()=>{Nye=pL(require("obsidian"));Me();Cr();Kr();PN();FN();Hc();zg();Hg();wl();qt();ys();X$();Q$();Z$();J$();eO();tO();rO();nO();iO();oO();HD();KS();ef();Pt();Gg();jh();ts();qt();GK=require("obsidian");Bs();Hr();xo();$k();n_();qc();BK();gE();qK();zK();Pi();Vye=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "Infinite AI Assistant" command type - no released version could ever run one. Delete the step from the macro. For chunked AI prompts, use quickAddApi.ai.chunkedPrompt() in a user script.']]);Hl=class extends tv{constructor(t,n,i,o,s,a,l,c=null){super(t);this.originLeaf=c;this.conditionalScriptCache=new Map;this.choice=i,this.plugin=n,this.macro=i?.macro,this.choiceExecutor=o,this.preloadedUserScripts=a??new Map,this.promptLabel=l,this.userScriptSettingsDefinition=void 0;let u=this.initSharedVariables(o,s);this.choiceExecutor.variables=u,this.params=this.buildParams(t,n,o,u)}buildParams(t,n,i,o){let s=WK(o),a={app:t,quickAddApi:ev.GetApi(t,n,i),obsidian:Nye,abort:l=>{throw new Nt(l)}};return Object.defineProperty(a,"variables",{get:()=>s,set:l=>{if(l===o||l===s)return;let c=l instanceof Map?Array.from(l.entries()).filter(([u])=>typeof u=="string"):l&&typeof l=="object"?Object.entries(l):null;c&&(o.clear(),c?.forEach(([u,d])=>o.set(u,d)))},enumerable:!0,configurable:!1}),a}initSharedVariables(t,n){let i=t.variables;return n?(i&&n!==i&&i.forEach((o,s)=>{n.has(s)||n.set(s,o)}),n):i??new Map}async run(){if(Ii(this.macro?.commands))throw new Error(`Could not read the commands for macro '${this.choice.name}'. The saved value is not a list of commands - QuickAdd has not changed it. It is in .obsidian/plugins/quickadd/data.json.`);let t=Ir(this.macro?.commands);if(t.length===0){kx(this.macro?.commands)||M.logError(`No commands in the macro for choice '${this.choice.name}'`);return}await this.executeCommands(t)}getOutput(){return this.output}async executeCommands(t){try{for(let n of t)if(n)switch(n.type){case"Obsidian":this.executeObsidianCommand(n);break;case"UserScript":await this.executeUserScript(n);break;case"Choice":await this.executeChoice(n);break;case"Wait":await OK(n.time);break;case"NestedChoice":await this.executeNestedChoice(n);break;case"EditorCommand":await this.executeEditorCommand(n);break;case"AIAssistant":await this.executeAIAssistant(n);break;case"OpenFile":await this.executeOpenFile(n);break;case"Conditional":await this.executeConditional(n);break;default:{let i=n.type;this.reportUnrunnableCommand(n,HK(i));break}}}catch(n){if(vd(n,{logPrefix:"Macro execution aborted",noticePrefix:"Macro execution aborted",defaultReason:"Macro execution aborted"})){this.choiceExecutor.signalAbort?.(n);return}throw n}}reportUnrunnableCommand(t,n){let i=typeof t?.name=="string"&&t.name.trim()?`'${t.name}'`:"an unnamed command";M.logError(`Skipped ${i} in the macro for '${this.choice.name}': ${n} QuickAdd did not stop the macro, so its result may be incomplete.`)}async executeUserScript(t){let n=r_(t),i;if(n!==void 0){let s=this.preloadedUserScripts.get(n);s!==void 0&&(i=s,this.preloadedUserScripts.delete(n))}if(i===void 0&&(i=await Sa(t,this.app)),!i){M.logError(`failed to load user script ${t.path}.`);return}t.settings||(t.settings={});let o=Bye(i);o&&zh(t.settings,o),this.userScriptCommand=t,this.userScriptSettingsDefinition=o;try{await this.userScriptDelegator(i)}catch(s){throw s instanceof Nt||lt(s,`Failed to run user script ${t.name} in "${this.choice.name}"`),s}finally{this.userScriptCommand=null,this.userScriptSettingsDefinition=void 0}}async getResolvedUserScriptSettings(t){return await qh(this.app,t,this.userScriptSettingsDefinition)&&await this.plugin.saveSettings?.(),Mk(this.app,t,this.userScriptSettingsDefinition)}async runScriptWithSettings(t,n){if(typeof t!="function"&&t.entry&&typeof t.entry=="function")return await this.onExportIsFunction(t.entry,await this.getResolvedUserScriptSettings(n));if(typeof t=="function")return await this.onExportIsFunction(t,await this.getResolvedUserScriptSettings(n))}async userScriptDelegator(t){switch(typeof t){case"function":if(!Lye(t))break;this.userScriptCommand?await this.runScriptWithSettings(t,this.userScriptCommand):await this.onExportIsFunction(t);break;case"object":KK(t)&&await this.onExportIsObject(t);break;case"bigint":case"boolean":case"number":case"string":this.output=t.toString();break;default:M.logError(`user script in macro for '${this.choice.name}' is invalid`)}}async onExportIsFunction(t,n){this.output=await t(this.params,n||{})}async onExportIsObject(t){if(Object.keys(t).length===0)throw new Error(`user script in macro for '${this.choice.name}' is an empty object`);if(this.userScriptCommand&&typeof t.entry=="function"){await this.runScriptWithSettings(t,this.userScriptCommand);return}let n=Object.keys(t);try{let i=String(await sa(this.choiceExecutor,{remote:o=>aa(o,{items:n.map(s=>({value:s,title:s})),placeholder:this.promptLabel,what:"the user-script member picker"}),headless:()=>{if(n.length===1)return Promise.resolve(n[0]);throw new xe("This macro's user script exports multiple members and needs to ask which one to run, but this run is non-interactive. Reference a single member (e.g. myScript::start), or re-run with the ui flag.")},app:()=>Lr.Suggest(this.app,n,n,this.promptLabel)}));if(!Object.hasOwn(t,i))throw new Error(`This macro's user script does not export a member named "${i}".`);await this.userScriptDelegator(t[i])}catch(i){throw i instanceof Nt?i:It(i)?new Dt("Input cancelled by user"):i}}executeObsidianCommand(t){let n=this.app.commands.commands;if(n&&!n[t.commandId]){M.logError(`Obsidian command '${t.name}' is no longer available.`);return}this.app.commands.executeCommandById(t.commandId)}async executeChoice(t){let n;try{n=this.plugin.getChoiceById(t.choiceId)}catch(o){let s=o instanceof Error?o.message:String(o);if(!/not found/i.test(s))throw o;M.logError(`choice '${t.name}' could not be found.`);return}await this.choiceExecutor.execute(n);let i=this.choiceExecutor.consumeAbortSignal?.();if(i)throw i}async executeNestedChoice(t){let n=t.choice;if(!n){M.logError(`choice in ${t.name} is invalid`);return}await this.choiceExecutor.execute(n);let i=this.choiceExecutor.consumeAbortSignal?.();if(i)throw i}async executeEditorCommand(t){switch(t.editorCommandType){case"Cut":await Xh.run(this.app);break;case"Copy":await Qh.run(this.app);break;case"Paste":await Zh.run(this.app);break;case"Paste with format":await Jh.run(this.app);break;case"Select active line":eg.run(this.app);break;case"Select link on active line":tg.run(this.app);break;case"Move cursor to file start":rg.run(this.app);break;case"Move cursor to file end":ng.run(this.app);break;case"Move cursor to line start":ig.run(this.app);break;case"Move cursor to line end":og.run(this.app);break;default:{let n=t.editorCommandType;this.reportUnrunnableCommand(t,HK(n,"editor command"))}}}async executeAIAssistant(t){if(le.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let n=le.getState().ai,i;if(t.model==="Ask me")i=await this.pickModelInteractively();else if(i=Jp(vu(t.model,t.modelRef)??t.model),!i)throw new Error(`Model ${t.model} not found with any provider.`);let{model:o,provider:s}=i,a=new xs(this.app,ni(),this.choiceExecutor);a.setPromptRunContext({choiceName:this.choice?.name,draftScopeId:`${this.choice?.id??"macro"}#aiAssistant:${t.id}`});let l=await za(this.app,s),c=await I5(this.app,{apiKey:l,model:o,provider:s,outputVariableName:t.outputVariableName,promptTemplate:t.promptTemplate,promptTemplateFolder:n.promptTemplatesFolderPath,systemPrompt:t.systemPrompt,showAssistantMessages:n.showAssistant,modelOptions:t.modelParameters,interactive:this.choiceExecutor.interactive,promptProvider:this.choiceExecutor.promptProvider},async u=>a.formatFileContent(u));for(let u in c)this.choiceExecutor.variables.set(u,c[u])}async pickModelInteractively(){let n=le.getState().ai.providers.flatMap(o=>o.models.map(s=>({label:`${s.name} (${o.name})`,qualified:`${o.id??o.name}/${s.name}`,resolved:{provider:o,model:s}})));if(n.length===0)throw new Error("No AI models are configured. Add a provider with models in the AI Assistant settings.");let i=this.choiceExecutor.promptProvider;if(i){let o=String(await i.suggester(n.map(a=>a.label),n.map(a=>a.qualified),"Select a model")),s=n.find(a=>a.qualified===o);if(!s)throw new Error(`Model ${o} not found with any provider.`);return s.resolved}if(this.choiceExecutor.interactive===!1)throw new xe('This AI command is set to "Ask me" for the model, but this run is non-interactive. Pick a specific model in the command, or re-run with the ui flag.');try{return await Lr.Suggest(this.app,n.map(o=>o.label),n.map(o=>o.resolved),"Select a model")}catch(o){throw It(o)?new Dt("Input cancelled by user"):o}}async executeConditional(t){let n=await LK(t.condition,{variables:this.params.variables,evaluateScriptCondition:async s=>await this.evaluateScriptCondition(s)}),i=n?t.thenCommands:t.elseCommands;if(Ii(i))throw new Error(`Could not read the ${n?"then":"else"} commands for '${t.name}'. The saved value is not a list of commands - QuickAdd has not changed it. It is in .obsidian/plugins/quickadd/data.json.`);if(!Array.isArray(i)||i.length===0)return;await this.executeCommands(i);let o=this.choiceExecutor.consumeAbortSignal?.();if(o)throw o}async runSubset(t){t?.length&&await this.executeCommands(t)}setOutput(t){this.output=t}async evaluateScriptCondition(t){let n=jK(t),i=this.conditionalScriptCache.get(n);if(!i){if(i=await this.loadConditionalScript(t),!i)return!1;this.conditionalScriptCache.set(n,i)}let o;try{o=await i()}catch(s){throw lt(s,`Failed to evaluate conditional script '${t.scriptPath}'.`),s}return typeof o!="boolean"?(M.logWarning(`Conditional script '${t.scriptPath}' must return a boolean result.`),!1):o}async loadConditionalScript(t){try{let n=await Sa(this.buildConditionalUserScript(t),this.app);return n==null?void 0:typeof n=="function"?async()=>await n(this.params):async()=>n}catch(n){throw lt(n,`Failed to load conditional script '${t.scriptPath}'.`),n}}buildConditionalUserScript(t){return{id:`conditional-script-${jK(t)}`,name:t.exportName?`${t.scriptPath}::${t.exportName}`:t.scriptPath,type:"UserScript",path:t.scriptPath,settings:{}}}async executeOpenFile(t){try{let n=new xs(this.app,ni(),this.choiceExecutor);n.setPromptRunContext({choiceName:this.choice?.name,draftScopeId:`${this.choice?.id??"macro"}#openFile:${t.id}`});let o=(await n.formatFileName(t.filePath,"filePath")).replace(/\\/g,"/"),s=o.split("/");if(s.some((u,d)=>u===".."||u===""&&d!==0&&d!==s.length-1)){M.logError(`OpenFile: Path traversal not allowed in '${o}'`);return}let l=this.app.vault.getAbstractFileByPath(o);if(!l||!(l instanceof GK.TFile)){M.logError(`OpenFile: '${o}' does not exist or is not a file`);return}let c=UK(t);await gc(this.app,l,{...c,originLeaf:this.originLeaf})}catch(n){M.logError(`OpenFile: Failed to open file '${t.filePath}': ${n.message}`)}}}});var iCe={};Jr(iCe,{default:()=>yI});module.exports=xQ(iCe);var lv=require("obsidian");var ld=require("obsidian");var fL;typeof window<"u"&&((fL=window.__svelte??(window.__svelte={})).v??(fL.v=new Set)).add("5");var Ql={};var fr=Symbol("uninitialized"),As=Symbol("filename");var qE="http://www.w3.org/1999/xhtml";var WE=!0;var mL=globalThis.process?.env?.NODE_ENV,re=mL&&!mL.toLowerCase().startsWith("prod");var fa=Array.isArray,hL=Array.prototype.indexOf,su=Array.prototype.includes,Af=Array.from,xI=Object.keys,Ni=Object.defineProperty,ko=Object.getOwnPropertyDescriptor,zE=Object.getOwnPropertyDescriptors,HE=Object.prototype,gL=Array.prototype,au=Object.getPrototypeOf,EI=Object.isExtensible;function TI(r){return typeof r=="function"}var Ut=()=>{};function jE(r){for(var e=0;e<r.length;e++)r[e]()}function GE(){var r,e,t=new Promise((n,i)=>{r=n,e=i});return{promise:t,resolve:r,reject:e}}var Dn=Symbol("$state"),dv=Symbol("legacy props"),vL=Symbol(""),YE=Symbol("proxy path"),KE=Symbol("attributes"),pv=Symbol("class"),fv=Symbol("style"),mv=Symbol("text"),lu=Symbol("form reset"),_I=Symbol("hmr anchor"),Xl=new class extends Error{constructor(){super(...arguments);ae(this,"name","StaleReactionError");ae(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},QE=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml");var Td=3,Go=8;function yL(r){if(re){let e=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 e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function XE(r){if(re){let e=new Error(`lifecycle_outside_component
\`${r}(...)\` can only be used during component initialisation
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function wL(){if(re){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 AI(){if(re){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 CL(){if(re){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 kI(r,e,t){if(re){let n=new Error(`each_key_duplicate
${t?`Keyed each block has duplicate key \`${t}\` at indexes ${r} and ${e}`:`Keyed each block has duplicate key at indexes ${r} and ${e}`}
https://svelte.dev/e/each_key_duplicate`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function xL(r,e,t){if(re){let n=new Error(`each_key_volatile
Keyed each block has key that is not idempotent \u2014 the key for item at index ${r} was \`${e}\` but is now \`${t}\`. Keys must be the same each time for a given item
https://svelte.dev/e/each_key_volatile`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_volatile")}function EL(r){if(re){let e=new Error(`effect_in_teardown
\`${r}\` cannot be used inside an effect cleanup function
https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function TL(){if(re){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 _L(r){if(re){let e=new Error(`effect_orphan
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function AL(){if(re){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 kL(){if(re){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 SL(){if(re){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 DL(r){if(re){let e=new Error(`props_invalid_value
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function IL(r){if(re){let e=new Error(`rune_outside_svelte
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function PL(){if(re){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 FL(){if(re){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 ML(){if(re){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 RL(){if(re){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 rl="font-weight: bold",nl="font-weight: normal";function $L(r){re?console.warn(`%c[svelte] await_reactivity_loss
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
https://svelte.dev/e/await_reactivity_loss`,rl,nl):console.warn("https://svelte.dev/e/await_reactivity_loss")}function OL(r,e){re?console.warn(`%c[svelte] await_waterfall
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
https://svelte.dev/e/await_waterfall`,rl,nl):console.warn("https://svelte.dev/e/await_waterfall")}function NL(){re?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`,rl,nl):console.warn("https://svelte.dev/e/derived_inert")}function LL(r,e,t){re?console.warn(`%c[svelte] hydration_attribute_changed
%cThe \`${r}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${t}\`, will be ignored in favour of the server value
https://svelte.dev/e/hydration_attribute_changed`,rl,nl):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function _d(r){re?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`,rl,nl):console.warn("https://svelte.dev/e/hydration_mismatch")}function BL(){re?console.warn(`%c[svelte] lifecycle_double_unmount
%cTried to unmount a component that was not mounted
https://svelte.dev/e/lifecycle_double_unmount`,rl,nl):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function VL(){re?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",rl,nl):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ZE(r){re?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`,rl,nl):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function UL(){re?console.warn(`%c[svelte] state_proxy_unmount
%cTried to unmount a state proxy, rather than a component
https://svelte.dev/e/state_proxy_unmount`,rl,nl):console.warn("https://svelte.dev/e/state_proxy_unmount")}function qL(){re?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",rl,nl):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var Re=!1;function In(r){Re=r}var Je;function tr(r){if(r===null)throw _d(),Ql;return Je=r}function Kn(){return tr(gi(Je))}function S(r){if(Re){if(gi(Je)!==null)throw _d(),Ql;Je=r}}function Pn(r=1){if(Re){for(var e=r,t=Je;e--;)t=gi(t);Je=t}}function il(r=!0){for(var e=0,t=Je;;){if(t.nodeType===Go){var n=t.data;if(n==="]"){if(e===0)return t;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}var i=gi(t);r&&t.remove(),t=i}}function gv(r){if(!r||r.nodeType!==Go)throw _d(),Ql;return r.data}function JE(r){return r===this.v}function eT(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function tT(r){return!eT(r,this.v)}var en=!1,Zl=!1,ma=!1;var TQ="font-weight: bold",_Q="font-weight: normal";function SI(r){re?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`,TQ,_Q):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var AQ=[];function ha(r,e=!1,t=!1){if(re&&!e){let n=[],i=vv(r,new Map,"",n,null,t);if(n.length===1&&n[0]==="")SI();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`),SI(a)}return i}return vv(r,new Map,"",AQ,null,t)}function vv(r,e,t,n,i=null,o=!1){if(typeof r=="object"&&r!==null){var s=e.get(r);if(s!==void 0)return s;if(r instanceof Map)return new Map(r);if(r instanceof Set)return new Set(r);if(fa(r)){var a=Array(r.length);e.set(r,a),i!==null&&e.set(i,a);for(var l=0;l<r.length;l+=1){var c=r[l];l in r&&(a[l]=vv(c,e,re?`${t}[${l}]`:t,n,null,o))}return a}if(au(r)===HE){a={},e.set(r,a),i!==null&&e.set(i,a);for(var u of Object.keys(r))a[u]=vv(r[u],e,re?`${t}.${u}`:t,n,null,o);return a}if(r instanceof Date)return structuredClone(r);if(typeof r.toJSON=="function"&&!o)return vv(r.toJSON(),e,re?`${t}.toJSON()`:t,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return re&&n.push(t),r}}var yv=null;function Li(r,e){return r.label=e,rT(r.v,e),r}function rT(r,e){return r?.[YE]?.(e),r}function ga(r){let e=new Error,t=kQ();return t.length===0?null:(t.unshift(`
`),Ni(e,"stack",{value:t.join(`
`)}),Ni(e,"name",{value:r}),e)}function kQ(){let r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let e=new Error().stack;if(Error.stackTraceLimit=r,!e)return[];let t=e.split(`
`),n=[];for(let i=0;i<t.length;i++){let o=t[i],s=o.replaceAll("\\","/");if(o.trim()!=="Error"){if(o.includes("validate_each_keys"))return[];s.includes("svelte/src/internal")||s.includes("node_modules/.vite")||n.push(o)}}return n}function zL(r,e){if(!re)throw new Error("invariant(...) was not guarded by if (DEV)");r||yL(e)}var At=null;function Jl(r){At=r}var ol=null;function Df(r){ol=r}var va=null;function nT(r){va=r}function we(r,e=!1,t){At={p:At,i:!1,c:null,e:null,s:r,x:null,r:Fe,l:Zl&&!e?{s:null,u:null,$:[]}:null},re&&(At.function=t,va=t)}function Ce(r){var e=At,t=e.e;if(t!==null){e.e=null;for(var n of t)DI(n)}return r!==void 0&&(e.x=r),e.i=!0,At=e.p,re&&(va=At?.function??null),r??{}}function ya(){return!Zl||At!==null&&At.l===null}var Ad=[];function HL(){var r=Ad;Ad=[],jE(r)}function Ur(r){if(Ad.length===0&&!kd){var e=Ad;queueMicrotask(()=>{e===Ad&&HL()})}Ad.push(r)}function jL(){for(;Ad.length>0;)HL()}var II=new WeakMap;function iT(r){var e=Fe;if(e===null)return je.f|=8388608,r;if(re&&r instanceof Error&&!II.has(r)&&II.set(r,SQ(r,e)),(e.f&32768)===0&&(e.f&4)===0)throw re&&!e.parent&&r instanceof Error&&GL(r),r;wa(r,e)}function wa(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throw r;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throw re&&r instanceof Error&&GL(r),r}}function SQ(r,e){let t=ko(r,"message");if(!(t&&!t.configurable)){for(var n=wv?" ":" ",i=`
${n}in ${e.fn?.name||"<unknown>"}`,o=e.ctx;o!==null;)i+=`
${n}in ${o.function?.[As].split("/").pop()}`,o=o.p;return{message:r.message+`
${i}
`,stack:r.stack?.split(`
`).filter(s=>!s.includes("svelte/src/internal")).join(`
`)}}}function GL(r){let e=II.get(r);e&&(Ni(r,"message",{value:e.message}),Ni(r,"stack",{value:e.stack}))}var DQ=-7169;function rr(r,e){r.f=r.f&DQ|e}function If(r){(r.f&512)!==0||r.deps===null?rr(r,1024):rr(r,4096)}function YL(r){if(r!==null)for(let e of r)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,YL(e.deps))}function oT(r,e,t){(r.f&2048)!==0?e.add(r):(r.f&4096)!==0&&t.add(r),YL(r.deps),rr(r,1024)}var KL=!1,sT=!1;function PI(r){var e=sT;try{return sT=!1,[r(),sT]}finally{sT=e}}function Id(r){Re&&vi(r)!==null&&Ff(r)}var QL=!1;function aT(){QL||(QL=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let e of r.target.elements)e[lu]?.()})},{capture:!0}))}function Ds(r){var e=je,t=Fe;Rn(null),$n(null);try{return r()}finally{Rn(e),$n(t)}}function lT(r,e,t,n=t){r.addEventListener(e,()=>Ds(t));let i=r[lu];i?r[lu]=()=>{i(),n(!0)}:r[lu]=()=>n(!0),aT()}function XL(r){let e=0,t=Ui(0),n;return re&&Li(t,"createSubscriber version"),()=>{cu()&&(h(t),Zn(()=>(e===0&&(n=Ot(()=>r(()=>Pd(t)))),e+=1,()=>{Ur(()=>{e-=1,e===0&&(n?.(),n=void 0,Pd(t))})})))}}var PQ=589824;function Tv(r,e,t,n){new FI(r,e,t,n)}var Yo,Cv,Is,Fd,Io,Ps,so,Ko,tc,Md,uu,Mf,xv,Ev,sl,dT,sr,JL,e2,MI,t2,RI,cT,uT,$I,OI,FI=class{constructor(e,t,n,i){it(this,sr);ae(this,"parent");ae(this,"is_pending",!1);ae(this,"transform_error");it(this,Yo);it(this,Cv,Re?Je:null);it(this,Is);it(this,Fd);it(this,Io);it(this,Ps,null);it(this,so,null);it(this,Ko,null);it(this,tc,null);it(this,Md,0);it(this,uu,0);it(this,Mf,!1);it(this,xv,new Set);it(this,Ev,new Set);it(this,sl,null);it(this,dT,XL(()=>(et(this,sl,Ui(W(this,Md))),re&&Li(W(this,sl),"$effect.pending()"),()=>{et(this,sl,null)})));et(this,Yo,e),et(this,Is,t),et(this,Fd,o=>{var s=Fe;s.b=this,s.f|=128,n(o)}),this.parent=Fe.b,this.transform_error=i??this.parent?.transform_error??(o=>o),et(this,Io,ao(()=>{if(Re){let o=W(this,Cv);Kn();let s=o.data==="[!";if(o.data.startsWith("[?")){let l=JSON.parse(o.data.slice("[?".length));Et(this,sr,e2).call(this,l)}else s?Et(this,sr,t2).call(this):Et(this,sr,JL).call(this)}else Et(this,sr,RI).call(this)},PQ)),Re&&et(this,Yo,Je)}defer_effect(e){oT(e,W(this,xv),W(this,Ev))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!W(this,Is).pending}update_pending_count(e,t){Et(this,sr,$I).call(this,e,t),et(this,Md,W(this,Md)+e),!(!W(this,sl)||W(this,Mf))&&(et(this,Mf,!0),Ur(()=>{et(this,Mf,!1),W(this,sl)&&Ca(W(this,sl),W(this,Md))}))}get_effect_pending(){return W(this,dT).call(this),h(W(this,sl))}error(e){if(!W(this,Is).onerror&&!W(this,Is).failed)throw e;qe?.is_fork?(W(this,Ps)&&qe.skip_effect(W(this,Ps)),W(this,so)&&qe.skip_effect(W(this,so)),W(this,Ko)&&qe.skip_effect(W(this,Ko)),qe.oncommit(()=>{Et(this,sr,OI).call(this,e)})):Et(this,sr,OI).call(this,e)}};Yo=new WeakMap,Cv=new WeakMap,Is=new WeakMap,Fd=new WeakMap,Io=new WeakMap,Ps=new WeakMap,so=new WeakMap,Ko=new WeakMap,tc=new WeakMap,Md=new WeakMap,uu=new WeakMap,Mf=new WeakMap,xv=new WeakMap,Ev=new WeakMap,sl=new WeakMap,dT=new WeakMap,sr=new WeakSet,JL=function(){try{et(this,Ps,On(()=>W(this,Fd).call(this,W(this,Yo))))}catch(e){this.error(e)}},e2=function(e){let t=W(this,Is).failed,{reset:n,invoke_onerror:i}=Et(this,sr,MI).call(this,e);Ur(i),t&&et(this,Ko,On(()=>{t(W(this,Yo),()=>e,()=>n)}))},MI=function(e){var t=!1,n=!1;let i=()=>{if(t){qL();return}t=!0,n&&RL(),W(this,Ko)!==null&&al(W(this,Ko),()=>{et(this,Ko,null)}),Et(this,sr,uT).call(this,()=>{Et(this,sr,RI).call(this)})};return{reset:i,invoke_onerror:()=>{try{n=!0,W(this,Is).onerror?.(e,i),n=!1}catch(s){wa(s,W(this,Io)&&W(this,Io).parent)}}}},t2=function(){let e=W(this,Is).pending;e&&(this.is_pending=!0,et(this,so,On(()=>e(W(this,Yo)))),Ur(()=>{var t=et(this,tc,document.createDocumentFragment()),n=tn();t.append(n),et(this,Ps,Et(this,sr,uT).call(this,()=>On(()=>W(this,Fd).call(this,n)))),W(this,uu)===0&&(W(this,Yo).before(t),et(this,tc,null),al(W(this,so),()=>{et(this,so,null)}),Et(this,sr,cT).call(this,qe))}))},RI=function(){try{if(this.is_pending=this.has_pending_snippet(),et(this,uu,0),et(this,Md,0),et(this,Ps,On(()=>{W(this,Fd).call(this,W(this,Yo))})),W(this,uu)>0){var e=et(this,tc,document.createDocumentFragment());Rf(W(this,Ps),e);let t=W(this,Is).pending;et(this,so,On(()=>t(W(this,Yo))))}else Et(this,sr,cT).call(this,qe)}catch(t){this.error(t)}},cT=function(e){this.is_pending=!1,e.transfer_effects(W(this,xv),W(this,Ev))},uT=function(e){var t=Fe,n=je,i=At;$n(W(this,Io)),Rn(W(this,Io)),Jl(W(this,Io).ctx);try{return Qo.ensure(),e()}catch(o){return iT(o),null}finally{$n(t),Rn(n),Jl(i)}},$I=function(e,t){var n;if(!this.has_pending_snippet()){this.parent&&Et(n=this.parent,sr,$I).call(n,e,t);return}et(this,uu,W(this,uu)+e),W(this,uu)===0&&(Et(this,sr,cT).call(this,t),W(this,so)&&al(W(this,so),()=>{et(this,so,null)}),W(this,tc)&&(W(this,Yo).before(W(this,tc)),et(this,tc,null)))},OI=function(e){W(this,Ps)&&(Wr(W(this,Ps)),et(this,Ps,null)),W(this,so)&&(Wr(W(this,so)),et(this,so,null)),W(this,Ko)&&(Wr(W(this,Ko)),et(this,Ko,null)),Re&&(tr(W(this,Cv)),Pn(),tr(il()));let t=W(this,Is).failed,n=i=>{let{reset:o,invoke_onerror:s}=Et(this,sr,MI).call(this,i);s(),t&&et(this,Ko,Et(this,sr,uT).call(this,()=>{try{return On(()=>{var a=Fe;a.b=this,a.f|=128,t(W(this,Yo),()=>i,()=>o)})}catch(a){return wa(a,W(this,Io).parent),null}}))};Ur(()=>{var i;try{i=this.transform_error(e)}catch(o){wa(o,W(this,Io)&&W(this,Io).parent);return}i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(n,o=>wa(o,W(this,Io)&&W(this,Io).parent)):n(i)})};function pT(r,e,t,n){let i=ya()?du:Rd;var o=r.filter(p=>!p.settled),s=e.map(i);if(re&&s.forEach((p,m)=>{p.label=e[m].toString().replace("() => ","").replaceAll("$.eager(() => ","$state.eager(").replace(/\$\.get\((.+?)\)/g,(v,g)=>g)}),t.length===0&&o.length===0){n(s);return}var a=Fe,l=r2(),c=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(p=>p.promise)):null;function u(p){if((a.f&16384)===0){l();try{n([...s,...p])}catch(m){wa(m,a)}$f()}}var d=NI();if(t.length===0){c.then(()=>u([])).finally(d);return}function f(){Promise.all(t.map(p=>BI(p))).then(u).catch(p=>wa(p,a)).finally(d)}c?c.then(()=>{l(),f(),$f()}):f()}function r2(){var r=Fe,e=je,t=At,n=qe;if(re)var i=ol;return function(s=!0){$n(r),Rn(e),Jl(t),s&&(r.f&16384)===0&&(n?.activate(),n?.apply()),re&&(LI(null),Df(i))}}function $f(r=!0){$n(null),Rn(null),Jl(null),r&&qe?.deactivate(),re&&(LI(null),Df(null))}function NI(){var r=Fe,e=r.b,t=qe,n=!!e?.is_rendered();return e?.update_pending_count(1,t),t.increment(n,r),()=>{e?.update_pending_count(-1,t),t.decrement(n,r)}}var Fo=null;function LI(r){Fo=r}var _v=new Set;function du(r){var e=2050;Fe!==null&&(Fe.f|=524288);let t={ctx:At,deps:null,effects:null,equals:JE,f:e,fn:r,reactions:null,rv:0,v:fr,wv:0,parent:Fe,ac:null};return re&&ma&&(t.created=ga("created at")),t}var Of=Symbol("obsolete");function BI(r,e,t){let n=Fe;n===null&&wL();var i=void 0,o=Ui(fr);re&&(o.label=e??r.toString());var s=!je,a=new Set;return o2(()=>{var l=Fe;re&&(Fo={effect:l,effect_deps:new Set,warned:!1});var c=GE();i=c.promise;try{Promise.resolve(r()).then(c.resolve,p=>{p!==Xl&&c.reject(p)}).finally($f)}catch(p){c.reject(p),$f()}if(re){if(Fo){if(l.deps!==null)for(let p=0;p<lo;p+=1)Fo.effect_deps.add(l.deps[p]);if(Jn!==null)for(let p=0;p<Jn.length;p+=1)Fo.effect_deps.add(Jn[p])}Fo=null}var u=qe;if(s){if((l.f&32768)!==0)var d=NI();if(n.b?.is_rendered())u.async_deriveds.get(l)?.reject(Of);else for(let p of a.values())p.reject(Of);a.add(c),u.async_deriveds.set(l,c)}let f=(p,m=void 0)=>{re&&(Fo=null),d?.(),a.delete(c),m!==Of&&(u.activate(),m?(o.f|=8388608,Ca(o,m)):((o.f&8388608)!==0&&(o.f^=8388608),re&&t!==void 0&&!o.equals(p)&&(_v.add(o),setTimeout(()=>{_v.has(o)&&(l.f&16384)===0&&(OL(o.label,t),_v.delete(o))})),Ca(o,p)),u.deactivate())};c.promise.then(f,p=>f(null,p||"unknown"))}),Xn(()=>{for(let l of a)l.reject(Of)}),re&&(o.f|=4194304),new Promise(l=>{function c(u){function d(){u===i?l(o):c(i)}u.then(d,d)}c(i)})}function N(r){let e=du(r);return en||hT(e),e}function Rd(r){let e=du(r);return e.equals=tT,e}function n2(r){var e=r.effects;if(e!==null){r.effects=null;for(var t=0;t<e.length;t+=1)Wr(e[t])}}var VI=[];function Av(r){var e,t=Fe,n=r.parent;if(!Xo&&n!==null&&r.v!==fr&&(n.f&24576)!==0)return NL(),r.v;if($n(n),re){let i=$d;fT(new Set);try{su.call(VI,r)&&CL(),VI.push(r),r.f&=-65537,n2(r),e=mT(r)}finally{$n(t),fT(i),VI.pop()}}else try{r.f&=-65537,n2(r),e=mT(r)}finally{$n(t)}return e}function UI(r){var e=Av(r);if(!r.equals(e)&&(r.wv=Nf(),(!qe?.is_fork||r.deps===null)&&(qe!==null?(qe.capture(r,e,!0),ll?.capture(r,e,!0)):r.v=e,r.deps===null))){rr(r,1024);return}Xo||(ei!==null?(cu()||qe?.is_fork)&&ei.set(r,e):If(r))}function i2(r){if(r.effects!==null)for(let e of r.effects)(e.teardown||e.ac)&&(e.teardown?.(),e.ac!==null&&Ds(()=>{e.ac.abort(Xl),e.ac=null}),e.fn!==null&&(e.teardown=Ut),Od(e,0),kv(e))}function qI(r){if(r.effects!==null)for(let e of r.effects)e.teardown&&e.fn!==null&&cl(e)}var gT=null,Lf=null,qe=null,ll=null,ei=null,HI=null,kd=!1,WI=!1,Nd=null,Iv=null,s2=0,zI=new Set,RQ=1,Vf,nc,ic,Uf,qf,Wf,oc,zf,co,Pv,sc,xa,ul,Hf,pu,Zt,jI,Sv,GI,l2,c2,Bf,u2,Dv,vT=class vT{constructor(){it(this,Zt);ae(this,"id",RQ++);it(this,Vf,!1);ae(this,"linked",!0);it(this,nc,null);it(this,ic,null);ae(this,"async_deriveds",new Map);ae(this,"current",new Map);ae(this,"previous",new Map);it(this,Uf,new Set);it(this,qf,new Set);it(this,Wf,0);it(this,oc,new Map);it(this,zf,null);it(this,co,[]);it(this,Pv,[]);it(this,sc,new Set);it(this,xa,new Set);it(this,ul,new Map);it(this,Hf,new Set);ae(this,"is_fork",!1);it(this,pu,!1);Lf===null?gT=Lf=this:(et(Lf,ic,this),et(this,nc,Lf)),Lf=this}skip_effect(e){W(this,ul).has(e)||W(this,ul).set(e,{d:[],m:[]}),W(this,Hf).delete(e)}unskip_effect(e,t=n=>this.schedule(n)){var n=W(this,ul).get(e);if(n){W(this,ul).delete(e);for(var i of n.d)rr(i,2048),t(i);for(i of n.m)rr(i,4096),t(i)}W(this,Hf).add(e)}capture(e,t,n=!1){e.v!==fr&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&8388608)===0&&(this.current.set(e,[t,n]),ei?.set(e,t)),this.is_fork||(e.v=t)}activate(){qe=this}deactivate(){qe=null,ei=null}flush(){try{re&&zI.clear(),WI=!0,qe=this,Et(this,Zt,Sv).call(this)}finally{if(s2=0,HI=null,Nd=null,Iv=null,WI=!1,qe=null,ei=null,ac.clear(),re)for(let e of zI)e.updated=null}}discard(){for(let e of W(this,qf))e(this);W(this,qf).clear();for(let e of this.async_deriveds.values())e.reject(Of);Et(this,Zt,Dv).call(this),W(this,zf)?.resolve()}register_created_effect(e){W(this,Pv).push(e)}increment(e,t){if(et(this,Wf,W(this,Wf)+1),e){let n=W(this,oc).get(t)??0;W(this,oc).set(t,n+1)}}decrement(e,t){if(et(this,Wf,W(this,Wf)-1),e){let n=W(this,oc).get(t)??0;n===1?W(this,oc).delete(t):W(this,oc).set(t,n-1)}W(this,pu)||(et(this,pu,!0),Ur(()=>{et(this,pu,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(let n of e)W(this,sc).add(n);for(let n of t)W(this,xa).add(n);e.clear(),t.clear()}oncommit(e){W(this,Uf).add(e)}ondiscard(e){W(this,qf).add(e)}settled(){return(W(this,zf)??et(this,zf,GE())).promise}static ensure(){if(qe===null){let e=qe=new vT;!WI&&!kd&&Ur(()=>{W(e,Vf)||e.flush()})}return qe}apply(){if(!en||!this.is_fork&&W(this,nc)===null&&W(this,ic)===null){ei=null;return}ei=new Map;for(let[t,[n]]of this.current)ei.set(t,n);for(let t=gT;t!==null;t=W(t,ic))if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,i]]of t.current)if(!i&&this.current.has(n)){e=!0;break}}if(!e)for(let[n,i]of t.previous)ei.has(n)||ei.set(n,i)}}schedule(e){if(HI=e,e.b?.is_pending&&(e.f&16777228)!==0&&(e.f&32768)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Nd!==null&&t===Fe&&(en||(je===null||(je.f&2)===0)&&!KL))return;if((n&96)!==0){if((n&1024)===0)return;t.f^=1024}}W(this,co).push(t)}};Vf=new WeakMap,nc=new WeakMap,ic=new WeakMap,Uf=new WeakMap,qf=new WeakMap,Wf=new WeakMap,oc=new WeakMap,zf=new WeakMap,co=new WeakMap,Pv=new WeakMap,sc=new WeakMap,xa=new WeakMap,ul=new WeakMap,Hf=new WeakMap,pu=new WeakMap,Zt=new WeakSet,jI=function(){if(this.is_fork)return!0;for(let n of W(this,oc).keys()){for(var e=n,t=!1;e.parent!==null;){if(W(this,ul).has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1},Sv=function(){var l,c,u;if(et(this,Vf,!0),s2++>1e3&&(Et(this,Zt,Dv).call(this),$Q()),re)for(let d of this.current.keys())zI.add(d);for(let d of W(this,sc))W(this,xa).delete(d),rr(d,2048),this.schedule(d);for(let d of W(this,xa))rr(d,4096),this.schedule(d);let e=W(this,co);et(this,co,[]),this.apply();var t=Nd=[],n=[],i=Iv=[];for(let d of e)try{Et(this,Zt,GI).call(this,d,t,n)}catch(f){throw f2(d),Et(this,Zt,jI).call(this)||this.discard(),f}if(qe=null,i.length>0){var o=vT.ensure();for(let d of i)o.schedule(d)}if(Nd=null,Iv=null,Et(this,Zt,jI).call(this)){Et(this,Zt,Bf).call(this,n),Et(this,Zt,Bf).call(this,t);for(let[d,f]of W(this,ul))p2(d,f);i.length>0&&Et(l=qe,Zt,Sv).call(l);return}let s=Et(this,Zt,l2).call(this);if(s){Et(this,Zt,Bf).call(this,n),Et(this,Zt,Bf).call(this,t),Et(c=s,Zt,c2).call(c,this);return}W(this,sc).clear(),W(this,xa).clear();for(let d of W(this,Uf))d(this);W(this,Uf).clear(),ll=this,a2(n),a2(t),ll=null,W(this,zf)?.resolve();var a=qe;if(W(this,Wf)===0&&(W(this,co).length===0||a!==null)&&(Et(this,Zt,Dv).call(this),en&&(Et(this,Zt,u2).call(this),qe=a)),W(this,co).length>0)if(a!==null){let d=a;W(d,co).push(...W(this,co).filter(f=>!W(d,co).includes(f)))}else a=this;a!==null&&Et(u=a,Zt,Sv).call(u)},GI=function(e,t,n){e.f^=1024;for(var i=e.first;i!==null;){var o=i.f,s=(o&96)!==0,a=s&&(o&1024)!==0,l=a||(o&8192)!==0||W(this,ul).has(i);if(!l&&i.fn!==null){s?i.f^=1024:(o&4)!==0?t.push(i):en&&(o&16777224)!==0?n.push(i):fu(i)&&((o&16)!==0&&W(this,xa).add(i),cl(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var u=i.next;if(u!==null){i=u;break}i=i.parent}}},l2=function(){for(var e=W(this,nc);e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=W(e,nc)}return null},c2=function(e){var n;for(let[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(let[i,o]of e.async_deriveds){let s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve).catch(s.reject)}e.async_deriveds.clear(),this.transfer_effects(W(e,sc),W(e,xa));let t=i=>{var o=i.reactions;if(o!==null&&!((i.f&2)!==0&&(i.f&6144)===0))for(let l of o){var s=l.f;if((s&2)!==0)t(l);else{var a=l;s&4194320&&!this.async_deriveds.has(a)&&(W(this,xa).delete(a),rr(a,2048),this.schedule(a))}}};for(let i of this.current.keys())t(i);this.oncommit(()=>e.discard()),Et(n=e,Zt,Dv).call(n),qe=this,Et(this,Zt,Sv).call(this)},Bf=function(e){for(var t=0;t<e.length;t+=1)oT(e[t],W(this,sc),W(this,xa))},u2=function(){var d;for(let f=gT;f!==null;f=W(f,ic)){var e=f.id<this.id,t=[];for(let[p,[m,v]]of this.current){if(f.current.has(p)){var n=f.current.get(p)[0];if(e&&m!==n)f.current.set(p,[m,v]);else continue}t.push(p)}if(e)for(let[p,m]of this.async_deriveds){let v=f.async_deriveds.get(p);v&&m.promise.then(v.resolve).catch(v.reject)}var i=[...f.current.keys()].filter(p=>!f.current.get(p)[1]);if(!(!W(f,Vf)||i.length===0)){var o=i.filter(p=>!this.current.has(p));if(o.length===0)e&&f.discard();else if(t.length>0){if(re&&!W(f,pu)&&zL(W(f,co).length===0,"Batch has scheduled roots"),e)for(let p of W(this,Hf))f.unskip_effect(p,m=>{var v;(m.f&4194320)!==0?f.schedule(m):Et(v=f,Zt,Bf).call(v,[m])});f.activate();var s=new Set,a=new Map;for(var l of t)d2(l,o,s,a);a=new Map;var c=[...f.current].filter(([p,m])=>{let v=this.current.get(p);return v?v[0]!==m[0]||v[1]!==m[1]:!0}).map(([p])=>p);if(c.length>0)for(let p of W(this,Pv))(p.f&155648)===0&&YI(p,c,a)&&((p.f&4194320)!==0?(rr(p,2048),f.schedule(p)):W(f,sc).add(p));if(W(f,co).length>0&&!W(f,pu)){f.apply();for(var u of W(f,co))Et(d=f,Zt,GI).call(d,u,[],[]);et(f,co,[])}f.deactivate()}}}},Dv=function(){if(this.linked){var e=W(this,nc),t=W(this,ic);e===null?gT=t:et(e,ic,t),t===null?Lf=e:et(t,nc,e),this.linked=!1}};var Qo=vT;function Bd(r){var e=kd;kd=!0;try{var t;for(r&&(qe!==null&&!qe.is_fork&&qe.flush(),t=r());;){if(jL(),qe===null)return t;qe.flush()}}finally{kd=e}}function $Q(){if(re){var r=new Map;for(let t of qe.current.keys())for(let[n,i]of t.updated??[]){var e=r.get(n);e||(e={error:i.error,count:0},r.set(n,e)),e.count+=i.count}for(let t of r.values())t.error&&console.error(t.error)}try{AL()}catch(t){re&&Ni(t,"stack",{value:""}),wa(t,HI)}}var Fs=null;function a2(r){var e=r.length;if(e!==0){for(var t=0;t<e;){var n=r[t++];if((n.f&24576)===0&&fu(n)&&(Fs=new Set,cl(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&KI(n),Fs?.size>0)){ac.clear();for(let i of Fs){if((i.f&24576)!==0)continue;let o=[i],s=i.parent;for(;s!==null;)Fs.has(s)&&(Fs.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){let l=o[a];(l.f&24576)===0&&cl(l)}}Fs.clear()}}Fs=null}}function d2(r,e,t,n){if(!t.has(r)&&(t.add(r),r.reactions!==null))for(let i of r.reactions){let o=i.f;(o&2)!==0?d2(i,e,t,n):(o&4194320)!==0&&(o&2048)===0&&YI(i,e,n)&&(rr(i,2048),Mv(i))}}function YI(r,e,t){let n=t.get(r);if(n!==void 0)return n;if(r.deps!==null)for(let i of r.deps){if(su.call(e,i))return!0;if((i.f&2)!==0&&YI(i,e,t))return t.set(i,!0),!0}return t.set(r,!1),!1}function Mv(r){qe.schedule(r)}function p2(r,e){if(!((r.f&32)!==0&&(r.f&1024)!==0)){(r.f&2048)!==0?e.d.push(r):(r.f&4096)!==0&&e.m.push(r),rr(r,1024);for(var t=r.first;t!==null;)p2(t,e),t=t.next}}function f2(r){rr(r,1024);for(var e=r.first;e!==null;)f2(e),e=e.next}var $d=new Set,ac=new Map;function fT(r){$d=r}var QI=!1;function h2(){QI=!0}function Ui(r,e){var t={f:0,v:r,reactions:null,equals:JE,rv:0,wv:0};return re&&ma&&(t.created=e??ga("created at"),t.updated=null,t.set_during_effect=!1,t.trace=null),t}function _e(r,e){let t=Ui(r,e);return hT(t),t}function Sd(r,e=!1,t=!0){var i;let n=Ui(r);return e||(n.equals=tT),Zl&&t&&At!==null&&At.l!==null&&((i=At.l).s??(i.s=[])).push(n),n}function J(r,e,t=!1){je!==null&&(!uo||(je.f&131072)!==0)&&ya()&&(je.f&4325394)!==0&&(Ms===null||!Ms.has(r))&&ML();let n=t?Ct(e):e;return re&&rT(n,r.label),Ca(r,n,Iv)}function Ca(r,e,t=null){if(!r.equals(e)){ac.set(r,Xo?e:r.v);var n=Qo.ensure();if(n.capture(r,e),re){if(ma||Fe!==null){r.updated??(r.updated=new Map);let i=(r.updated.get("")?.count??0)+1;if(r.updated.set("",{error:null,count:i}),ma||i>5){let o=ga("updated at");if(o!==null){let s=r.updated.get(o.stack);s||(s={error:o,count:0},r.updated.set(o.stack,s)),s.count++}}}Fe!==null&&(r.set_during_effect=!0)}if((r.f&2)!==0){let i=r;(r.f&2048)!==0&&Av(i),ei===null&&If(i)}r.wv=Nf(),g2(r,2048,t),ya()&&Fe!==null&&(Fe.f&1024)!==0&&(Fe.f&96)===0&&(Zo===null?v2([r]):Zo.push(r)),!n.is_fork&&$d.size>0&&!QI&&yT()}return e}function yT(){QI=!1;for(let r of $d){(r.f&1024)!==0&&rr(r,4096);let e;try{e=fu(r)}catch{e=!0}e&&cl(r)}$d.clear()}function XI(r,e=1){var t=h(r);return J(r,e===1?++t:--t)}function Pd(r){J(r,r.v+1)}function g2(r,e,t){var n=r.reactions;if(n!==null)for(var i=ya(),o=n.length,s=0;s<o;s++){var a=n[s],l=a.f;if(!(!i&&a===Fe)){var c=(l&2048)===0;if(c&&rr(a,e),(l&131072)!==0)$d.add(a);else if((l&2)!==0){var u=a;ei?.delete(u),(l&65536)===0&&(l&512&&(Fe===null||(Fe.f&2097152)===0)&&(a.f|=65536),g2(u,4096,t))}else if(c){var d=a;(l&16)!==0&&Fs!==null&&Fs.add(d),t!==null?t.push(d):Mv(d)}}}}var NQ=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function Ct(r){if(typeof r!="object"||r===null||Dn in r)return r;let e=au(r);if(e!==HE&&e!==gL)return r;var t=new Map,n=fa(r),i=_e(0),o=re&&ma?ga("created at"):null,s=mu,a=d=>{if(mu===s)return d();var f=je,p=mu;Rn(null),ZI(s);var m=d();return Rn(f),ZI(p),m};n&&(t.set("length",_e(r.length,o)),re&&(r=BQ(r)));var l="";let c=!1;function u(d){if(!c){c=!0,l=d,Li(i,`${l} version`);for(let[f,p]of t)Li(p,Vd(l,f));c=!1}}return new Proxy(r,{defineProperty(d,f,p){(!("value"in p)||p.configurable===!1||p.enumerable===!1||p.writable===!1)&&PL();var m=t.get(f);return m===void 0?a(()=>{var v=_e(p.value,o);return t.set(f,v),re&&typeof f=="string"&&Li(v,Vd(l,f)),v}):J(m,p.value,!0),!0},deleteProperty(d,f){var p=t.get(f);if(p===void 0){if(f in d){let m=a(()=>_e(fr,o));t.set(f,m),Pd(i),re&&Li(m,Vd(l,f))}}else J(p,fr),Pd(i);return!0},get(d,f,p){if(f===Dn)return r;if(re&&f===YE)return u;var m=t.get(f),v=f in d;if(m===void 0&&(!v||ko(d,f)?.writable)&&(m=a(()=>{var y=Ct(v?d[f]:fr),w=_e(y,o);return re&&Li(w,Vd(l,f)),w}),t.set(f,m)),m!==void 0){var g=h(m);return g===fr?void 0:g}return Reflect.get(d,f,p)},getOwnPropertyDescriptor(d,f){var p=Reflect.getOwnPropertyDescriptor(d,f);if(p&&"value"in p){var m=t.get(f);m&&(p.value=h(m))}else if(p===void 0){var v=t.get(f),g=v?.v;if(v!==void 0&&g!==fr)return{enumerable:!0,configurable:!0,value:g,writable:!0}}return p},has(d,f){if(f===Dn)return!0;var p=t.get(f),m=p!==void 0&&p.v!==fr||Reflect.has(d,f);if(p!==void 0||Fe!==null&&(!m||ko(d,f)?.writable)){p===void 0&&(p=a(()=>{var g=m?Ct(d[f]):fr,y=_e(g,o);return re&&Li(y,Vd(l,f)),y}),t.set(f,p));var v=h(p);if(v===fr)return!1}return m},set(d,f,p,m){var v=t.get(f),g=f in d;if(n&&f==="length")for(var y=p;y<v.v;y+=1){var w=t.get(y+"");w!==void 0?J(w,fr):y in d&&(w=a(()=>_e(fr,o)),t.set(y+"",w),re&&Li(w,Vd(l,y)))}if(v===void 0)(!g||ko(d,f)?.writable)&&(v=a(()=>_e(void 0,o)),re&&Li(v,Vd(l,f)),J(v,Ct(p)),t.set(f,v));else{g=v.v!==fr;var k=a(()=>Ct(p));J(v,k)}var C=Reflect.getOwnPropertyDescriptor(d,f);if(C?.set&&C.set.call(m,p),!g){if(n&&typeof f=="string"){var E=t.get("length"),x=Number(f);Number.isInteger(x)&&x>=E.v&&J(E,x+1)}Pd(i)}return!0},ownKeys(d){h(i);var f=Reflect.ownKeys(d).filter(v=>{var g=t.get(v);return g===void 0||g.v!==fr});for(var[p,m]of t)m.v!==fr&&!(p in d)&&f.push(p);return f},setPrototypeOf(){FL()}})}function Vd(r,e){return typeof e=="symbol"?`${r}[Symbol(${e.description??""})]`:NQ.test(e)?`${r}.${e}`:/^\d+$/.test(e)?`${r}[${e}]`:`${r}['${e}']`}function Gf(r){try{if(r!==null&&typeof r=="object"&&Dn in r)return r[Dn]}catch{}return r}function JI(r,e){return Object.is(Gf(r),Gf(e))}var LQ=new Set(["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"]);function BQ(r){return new Proxy(r,{get(e,t,n){var i=Reflect.get(e,t,n);return LQ.has(t)?function(...o){h2();var s=i.apply(this,o);return yT(),s}:i}})}function y2(){let r=Array.prototype,e=Array.__svelte_cleanup;e&&e();let{indexOf:t,lastIndexOf:n,includes:i}=r;r.indexOf=function(o,s){let a=t.call(this,o,s);if(a===-1){for(let l=s??0;l<this.length;l+=1)if(Gf(this[l])===o){ZE("array.indexOf(...)");break}}return a},r.lastIndexOf=function(o,s){let a=n.call(this,o,s??this.length-1);if(a===-1){for(let l=0;l<=(s??this.length-1);l+=1)if(Gf(this[l])===o){ZE("array.lastIndexOf(...)");break}}return a},r.includes=function(o,s){let a=i.call(this,o,s);if(!a){for(let l=0;l<this.length;l+=1)if(Gf(this[l])===o){ZE("array.includes(...)");break}}return a},Array.__svelte_cleanup=()=>{r.indexOf=t,r.lastIndexOf=n,r.includes=i}}var e0,b2,wv,w2,C2;function bT(){if(e0===void 0){e0=window,b2=document,wv=/Firefox/.test(navigator.userAgent);var r=Element.prototype,e=Node.prototype,t=Text.prototype;w2=ko(e,"firstChild").get,C2=ko(e,"nextSibling").get,EI(r)&&(r[pv]=void 0,r[KE]=null,r[fv]=void 0,r.__e=void 0),EI(t)&&(t[mv]=void 0),re&&(r.__svelte_meta=null,y2())}}function tn(r=""){return document.createTextNode(r)}function vi(r){return w2.call(r)}function gi(r){return C2.call(r)}function I(r,e){if(!Re)return vi(r);var t=vi(Je);if(t===null)t=Je.appendChild(tn());else if(e&&t.nodeType!==Td){var n=tn();return t?.before(n),tr(n),n}return e&&Rv(t),tr(t),t}function Pe(r,e=!1){if(!Re){var t=vi(r);return t instanceof Comment&&t.data===""?gi(t):t}if(e){if(Je?.nodeType!==Td){var n=tn();return Je?.before(n),tr(n),n}Rv(Je)}return Je}function _(r,e=1,t=!1){let n=Re?Je:r;for(var i;e--;)i=n,n=gi(n);if(!Re)return n;if(t){if(n?.nodeType!==Td){var o=tn();return n===null?i?.after(o):n.before(o),tr(o),o}Rv(n)}return tr(n),n}function Ff(r){r.textContent=""}function wT(){if(!en||Fs!==null)return!1;var r=Fe.f;return(r&32768)!==0}function dl(r,e,t){return e==null||e===qE?t?document.createElement(r,{is:t}):document.createElement(r):t?document.createElementNS(e,r,{is:t}):document.createElementNS(e,r)}function Rv(r){if(r.nodeValue.length<65536)return;let e=r.nextSibling;for(;e!==null&&e.nodeType===Td;)e.remove(),r.nodeValue+=e.nodeValue,e=r.nextSibling}function E2(r){Fe===null&&(je===null&&_L(r),TL()),Xo&&EL(r)}function UQ(r,e){var t=e.last;t===null?e.last=e.first=r:(t.next=r,r.prev=t,e.last=r)}function pl(r,e){var t=Fe;if(re)for(;t!==null&&(t.f&131072)!==0;)t=t.parent;t!==null&&(t.f&8192)!==0&&(r|=8192);var n={ctx:At,deps:null,nodes:null,f:r|2048|512,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};re&&(n.component_function=va),qe?.register_created_effect(n);var i=n;if((r&4)!==0)Nd!==null?Nd.push(n):Qo.ensure().schedule(n);else if(e!==null){try{cl(n)}catch(s){throw Wr(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=t,t!==null&&UQ(i,t),je!==null&&(je.f&2)!==0&&(r&64)===0)){var o=je;(o.effects??(o.effects=[])).push(i)}return n}function cu(){return je!==null&&!uo}function Xn(r){let e=pl(8,null);return rr(e,1024),e.teardown=r,e}function hr(r){E2("$effect"),re&&Ni(r,"name",{value:"$effect"});var e=Fe.f,t=!je&&(e&32)!==0&&At!==null&&!At.i;if(t){var n=At;(n.e??(n.e=[])).push(r)}else return DI(r)}function DI(r){return pl(1048580,r)}function r0(r){Qo.ensure();let e=pl(524352,r);return()=>{Wr(e)}}function T2(r){Qo.ensure();let e=pl(524352,r);return(t={})=>new Promise(n=>{t.outro?al(e,()=>{Wr(e),n(void 0)}):(Wr(e),n(void 0))})}function un(r){return pl(4,r)}function o2(r){return pl(4718592,r)}function Zn(r,e=0){return pl(8|e,r)}function de(r,e=[],t=[],n=[]){pT(n,e,t,i=>{pl(8,()=>{r(...i.map(h))})})}function ao(r,e=0){var t=pl(16|e,r);return re&&(t.dev_stack=ol),t}function On(r){return pl(524320,r)}function n0(r){var e=r.teardown;if(e!==null){let t=Xo,n=je;t0(!0),Rn(null);try{e.call(null)}finally{t0(t),Rn(n)}}}function kv(r,e=!1){var t=r.first;for(r.first=r.last=null;t!==null;){let i=t.ac;i!==null&&Ds(()=>{i.abort(Xl)});var n=t.next;(t.f&64)!==0?t.parent=null:Wr(t,e),t=n}}function _2(r){for(var e=r.first;e!==null;){var t=e.next;(e.f&32)===0&&Wr(e),e=t}}function Wr(r,e=!0){var t=!1;(e||(r.f&262144)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(A2(r.nodes.start,r.nodes.end),t=!0),r.f|=33554432,kv(r,e&&!t),Od(r,0);var n=r.nodes&&r.nodes.t;if(n!==null)for(let o of n)o.stop();n0(r),r.f^=33554432,r.f|=16384;var i=r.parent;i!==null&&i.first!==null&&KI(r),re&&(r.component_function=null),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=r.b=null}function A2(r,e){for(;r!==null;){var t=r===e?null:gi(r);r.remove(),r=t}}function KI(r){var e=r.parent,t=r.prev,n=r.next;t!==null&&(t.next=n),n!==null&&(n.prev=t),e!==null&&(e.first===r&&(e.first=n),e.last===r&&(e.last=t))}function al(r,e,t=!0){var n=[];k2(r,n,!0);var i=()=>{t&&Wr(r),e&&e()},o=n.length;if(o>0){var s=()=>--o||i();for(var a of n)a.out(s)}else i()}function k2(r,e,t){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||t)&&e.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;k2(i,e,s?t:!1)}i=o}}}function Yf(r){S2(r,!0)}function S2(r,e){if((r.f&8192)!==0){r.f^=8192,(r.f&1024)===0&&(rr(r,2048),Qo.ensure().schedule(r));for(var t=r.first;t!==null;){var n=t.next,i=(t.f&65536)!==0||(t.f&32)!==0;S2(t,i?e:!1),t=n}var o=r.nodes&&r.nodes.t;if(o!==null)for(let s of o)(s.is_global||e)&&s.in()}}function Rf(r,e){if(r.nodes)for(var t=r.nodes.start,n=r.nodes.end;t!==null;){var i=t===n?null:gi(t);e.append(t),t=i}}var D2=null;var CT=!1,Xo=!1;function t0(r){Xo=r}var je=null,uo=!1;function Rn(r){je=r}var Fe=null;function $n(r){Fe=r}var Ms=null;function hT(r){je!==null&&(!en||(je.f&2)!==0)&&(Ms??(Ms=new Set)).add(r)}var Jn=null,lo=0,Zo=null;function v2(r){Zo=r}var I2=1,Ud=0,mu=Ud;function ZI(r){mu=r}function Nf(){return++I2}function fu(r){var e=r.f;if((e&2048)!==0)return!0;if(e&2&&(r.f&=-65537),(e&4096)!==0){for(var t=r.deps,n=t.length,i=0;i<n;i++){var o=t[i];if(fu(o)&&UI(o),o.wv>r.wv)return!0}(e&512)!==0&&ei===null&&rr(r,1024)}return!1}function P2(r,e,t=!0){var n=r.reactions;if(n!==null&&!(!en&&Ms!==null&&Ms.has(r)))for(var i=0;i<n.length;i++){var o=n[i];(o.f&2)!==0?P2(o,e,!1):e===o&&(t?rr(o,2048):(o.f&1024)!==0&&rr(o,4096),Mv(o))}}function mT(r){var v;var e=Jn,t=lo,n=Zo,i=je,o=Ms,s=At,a=uo,l=mu,c=r.f;Jn=null,lo=0,Zo=null,je=(c&96)===0?r:null,Ms=null,Jl(r.ctx),uo=!1,mu=++Ud,r.ac!==null&&(Ds(()=>{r.ac.abort(Xl)}),r.ac=null);try{r.f|=2097152;var u=r.fn,d=u();r.f|=32768;var f=r.deps,p=qe?.is_fork;if(Jn!==null){var m;if(p||Od(r,lo),f!==null&&lo>0)for(f.length=lo+Jn.length,m=0;m<Jn.length;m++)f[lo+m]=Jn[m];else r.deps=f=Jn;if(cu()&&(r.f&512)!==0)for(m=lo;m<f.length;m++)((v=f[m]).reactions??(v.reactions=[])).push(r)}else!p&&f!==null&&lo<f.length&&(Od(r,lo),f.length=lo);if(ya()&&Zo!==null&&!uo&&f!==null&&(r.f&6146)===0)for(m=0;m<Zo.length;m++)P2(Zo[m],r);if(i!==null&&i!==r){if(Ud++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=Ud;if(e!==null)for(let g of e)g.rv=Ud;Zo!==null&&(n===null?n=Zo:n.push(...Zo))}return(r.f&8388608)!==0&&(r.f^=8388608),d}catch(g){return iT(g)}finally{r.f^=2097152,Jn=e,lo=t,Zo=n,je=i,Ms=o,Jl(s),uo=a,mu=l}}function qQ(r,e){let t=e.reactions;if(t!==null){var n=hL.call(t,r);if(n!==-1){var i=t.length-1;i===0?t=e.reactions=null:(t[n]=t[i],t.pop())}}if(t===null&&(e.f&2)!==0&&(Jn===null||!su.call(Jn,e))){var o=e;(o.f&512)!==0&&(o.f^=512,o.f&=-65537),o.v!==fr&&If(o),o.ac!==null&&Ds(()=>{o.ac.abort(Xl),o.ac=null,rr(o,2048)}),i2(o),Od(o,0)}}function Od(r,e){var t=r.deps;if(t!==null)for(var n=e;n<t.length;n++)qQ(r,t[n])}function cl(r){var e=r.f;if((e&16384)===0){rr(r,1024);var t=Fe,n=CT;if(Fe=r,CT=(e&96)===0,re){var i=va;nT(r.component_function);var o=ol;Df(r.dev_stack??ol)}try{(e&16777232)!==0?_2(r):kv(r),n0(r);var s=mT(r);if(r.teardown=typeof s=="function"?s:null,r.wv=I2,re&&ma&&(r.f&2048)!==0&&r.deps!==null)for(var a of r.deps)a.set_during_effect&&(a.wv=Nf(),a.set_during_effect=!1)}finally{CT=n,Fe=t,re&&(nT(i),Df(o))}}}async function Kf(){if(en)return new Promise(r=>{requestAnimationFrame(()=>r()),setTimeout(()=>r())});await Promise.resolve(),Bd()}function h(r){var e=r.f,t=(e&2)!==0;if(D2?.add(r),je!==null&&!uo){var n=Fe!==null&&(Fe.f&16384)!==0;if(!n&&(Ms===null||!Ms.has(r))){var i=je.deps;if((je.f&2097152)!==0)r.rv<Ud&&(r.rv=Ud,Jn===null&&i!==null&&i[lo]===r?lo++:Jn===null?Jn=[r]:Jn.push(r));else{je.deps??(je.deps=[]),su.call(je.deps,r)||je.deps.push(r);var o=r.reactions;o===null?r.reactions=[je]:su.call(o,je)||o.push(je)}}}if(re){if(!uo&&Fo&&qe===null&&ll===null&&!Fo.warned&&(Fo.effect.f&2097152)===0&&!Fo.effect_deps.has(r)){Fo.warned=!0,$L(r.label);var s=ga("traced at");s&&console.warn(s)}if(_v.delete(r),ma&&!uo&&yv!==null&&je!==null&&yv.reaction===je){if(r.trace)r.trace();else if(s=ga("traced at"),s){var a=yv.entries.get(r);a===void 0&&(a={traces:[]},yv.entries.set(r,a));var l=a.traces[a.traces.length-1];s.stack!==l?.stack&&a.traces.push(s)}}}if(Xo&&ac.has(r))return ac.get(r);if(t){var c=r;if(Xo){var u=c.v;return((c.f&1024)===0&&c.reactions!==null||M2(c))&&(u=Av(c)),ac.set(c,u),u}var d=(c.f&512)===0&&!uo&&je!==null&&(CT||(je.f&512)!==0),f=(c.f&32768)===0;fu(c)&&(d&&(c.f|=512),UI(c)),d&&!f&&(qI(c),F2(c))}if(ei?.has(r))return ei.get(r);if((r.f&8388608)!==0)throw r.v;return r.v}function F2(r){if(r.f|=512,r.deps!==null)for(let e of r.deps)(e.reactions??(e.reactions=[])).push(r),(e.f&2)!==0&&(e.f&512)===0&&(qI(e),F2(e))}function M2(r){if(r.v===fr)return!0;if(r.deps===null)return!1;for(let e of r.deps)if(ac.has(e)||(e.f&2)!==0&&M2(e))return!0;return!1}function Ot(r){var e=uo;try{return uo=!0,r()}finally{uo=e}}function ET(r){if(!(typeof r!="object"||!r||r instanceof EventTarget)){if(Dn in r)xT(r);else if(!Array.isArray(r))for(let e in r){let t=r[e];typeof t=="object"&&t&&Dn in t&&xT(t)}}}function xT(r,e=new Set){if(typeof r=="object"&&r!==null&&!(r instanceof EventTarget)&&!e.has(r)){e.add(r),r instanceof Date&&r.getTime();for(let n in r)try{xT(r[n],e)}catch{}let t=au(r);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){let n=zE(t);for(let i in n){let o=n[i].get;if(o)try{o.call(r)}catch{}}}}}var qd=Symbol("events"),i0=new Set,TT=new Set;function $2(r,e,t,n={}){function i(o){if(n.capture||_T.call(e,o),!o.cancelBubble)return Ds(()=>t?.call(this,o))}return r.startsWith("pointer")||r.startsWith("touch")||r==="wheel"?Ur(()=>{e.addEventListener(r,i,n)}):e.addEventListener(r,i,n),i}function lc(r,e,t,n,i){var o={capture:n,passive:i},s=$2(r,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Xn(()=>{e.removeEventListener(r,s,o)})}function De(r,e,t){(e[qd]??(e[qd]={}))[r]=t}function Tt(r){for(var e=0;e<r.length;e++)i0.add(r[e]);for(var t of TT)t(r)}var R2=null;function _T(r){var e=this,t=e.ownerDocument,n=r.type,i=r.composedPath?.()||[],o=i[0]||r.target;R2=r;var s=0,a=R2===r&&r[qd];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){r[qd]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||r.target,o!==e){Ni(r,"currentTarget",{configurable:!0,get(){return o||t}});var u=je,d=Fe;Rn(null),$n(null);try{for(var f,p=[];o!==null&&o!==e;){try{var m=o[qd]?.[n];m!=null&&(!o.disabled||r.target===o)&&m.call(o,r)}catch(v){f?p.push(v):f=v}if(r.cancelBubble)break;s++,o=s<i.length?i[s]:null}if(f){for(let v of p)queueMicrotask(()=>{throw v});throw f}}finally{r[qd]=e,delete r.currentTarget,Rn(u),$n(d)}}}var WQ=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:r=>r});function O2(r){return WQ?.createHTML(r)??r}function o0(r){var e=dl("template");return e.innerHTML=O2(r.replaceAll("<!>","<!---->")),e.content}function Jo(r,e){var t=Fe;t.nodes===null&&(t.nodes={start:r,end:e,a:null,t:null})}function q(r,e){var t=(e&1)!==0,n=(e&2)!==0,i,o=!r.startsWith("<!>");return()=>{if(Re)return Jo(Je,null),Je;i===void 0&&(i=o0(o?r:"<!>"+r),t||(i=vi(i)));var s=n||wv?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=vi(s),l=s.lastChild;Jo(a,l)}else Jo(s,s);return s}}function fl(r=""){if(!Re){var e=tn(r+"");return Jo(e,e),e}var t=Je;return t.nodeType!==Td?(t.before(t=tn()),tr(t)):Rv(t),Jo(t,t),t}function dn(){if(Re)return Jo(Je,null),Je;var r=document.createDocumentFragment(),e=document.createComment(""),t=tn();return r.append(e,t),Jo(e,t),r}function $(r,e){if(Re){var t=Fe;((t.f&32768)===0||t.nodes.end===null)&&(t.nodes.end=Je),Kn();return}r!==null&&r.before(e)}function $v(){var r;if(Re&&Je&&Je.nodeType===Go&&Je.textContent?.startsWith("$")){let e=Je.textContent.substring(1);return Kn(),e}return(r=window.__svelte??(window.__svelte={})).uid??(r.uid=1),`c${window.__svelte.uid++}`}var KQ=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","webkitdirectory","defer","disablepictureinpicture","disableremoteplayback"];var tAe=[...KQ,"formNoValidate","isMap","noModule","playsInline","readOnly","value","volume","defaultValue","defaultChecked","srcObject","noValidate","allowFullscreen","disablePictureInPicture","disableRemotePlayback"];var QQ=["touchstart","touchmove"];function N2(r){return QQ.includes(r)}var XQ=["$state","$state.raw","$derived","$derived.by"],rAe=[...XQ,"$state.eager","$state.snapshot","$props","$props.id","$bindable","$effect","$effect.pre","$effect.tracking","$effect.root","$effect.pending","$inspect","$inspect().with","$inspect.trace","$host"];var a0=!0;function me(r,e){var n;var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(r[n=mv]??(r[n]=r.nodeValue))&&(r[mv]=t,r.nodeValue=`${t}`)}function Wd(r,e){return L2(r,e)}function c0(r,e){bT(),e.intro=e.intro??!1;let t=e.target,n=Re,i=Je;try{for(var o=vi(t);o&&(o.nodeType!==Go||o.data!=="[");)o=gi(o);if(!o)throw Ql;In(!0),tr(o);let s=L2(r,{...e,anchor:o});return In(!1),s}catch(s){if(s instanceof Error&&s.message.split(`
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==Ql&&console.warn("Failed to hydrate: ",s),e.recover===!1&&kL(),bT(),Ff(t),In(!1),Wd(r,e)}finally{In(n),tr(i)}}var AT=new Map;function L2(r,{target:e,anchor:t,props:n={},events:i,context:o,intro:s=!0,transformError:a}){bT();var l=void 0,c=T2(()=>{var u=t??e.appendChild(tn());Tv(u,{pending:()=>{}},p=>{we({});var m=At;if(o&&(m.c=o),i&&(n.$$events=i),Re&&Jo(p,null),a0=s,l=r(p,n)||{},a0=!0,Re&&(Fe.nodes.end=Je,Je===null||Je.nodeType!==Go||Je.data!=="]"))throw _d(),Ql;Ce()},a);var d=new Set,f=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!d.has(v)){d.add(v);var g=N2(v);for(let k of[e,document]){var y=AT.get(k);y===void 0&&(y=new Map,AT.set(k,y));var w=y.get(v);w===void 0?(k.addEventListener(v,_T,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return f(Af(i0)),TT.add(f),()=>{for(var p of d)for(let g of[e,document]){var m=AT.get(g),v=m.get(p);--v==0?(g.removeEventListener(p,_T),m.delete(p),m.size===0&&AT.delete(g)):m.set(p,v)}TT.delete(f),u!==t&&u.parentNode?.removeChild(u)}});return l0.set(l,c),l}var l0=new WeakMap;function Qf(r,e){let t=l0.get(r);return t?(l0.delete(r),t(e)):(re&&(Dn in r?UL():BL()),Promise.resolve())}var Ea,ml,es,zd,Ov,Nv,kT,Ta=class{constructor(e,t=!0){ae(this,"anchor");it(this,Ea,new Map);it(this,ml,new Map);it(this,es,new Map);it(this,zd,new Set);it(this,Ov,!0);it(this,Nv,e=>{if(W(this,Ea).has(e)){var t=W(this,Ea).get(e),n=W(this,ml).get(t);if(n)Yf(n),W(this,zd).delete(t);else{var i=W(this,es).get(t);i&&(Yf(i.effect),W(this,ml).set(t,i.effect),W(this,es).delete(t),re&&(i.fragment.lastChild[_I]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of W(this,Ea)){if(W(this,Ea).delete(o),o===e)break;let a=W(this,es).get(s);a&&(Wr(a.effect),W(this,es).delete(s))}for(let[o,s]of W(this,ml)){if(o===t||W(this,zd).has(o))continue;let a=()=>{if(Array.from(W(this,Ea).values()).includes(o)){var c=document.createDocumentFragment();Rf(s,c),c.append(tn()),W(this,es).set(o,{effect:s,fragment:c})}else Wr(s);W(this,zd).delete(o),W(this,ml).delete(o)};W(this,Ov)||!n?(W(this,zd).add(o),al(s,a,!1)):a()}}});it(this,kT,e=>{W(this,Ea).delete(e);let t=Array.from(W(this,Ea).values());for(let[n,i]of W(this,es))t.includes(n)||(Wr(i.effect),W(this,es).delete(n))});this.anchor=e,et(this,Ov,t)}ensure(e,t){var n=qe,i=wT();if(t&&!W(this,ml).has(e)&&!W(this,es).has(e))if(i){var o=document.createDocumentFragment(),s=tn();o.append(s),W(this,es).set(e,{effect:On(()=>t(s)),fragment:o})}else W(this,ml).set(e,On(()=>t(this.anchor)));if(W(this,Ea).set(n,e),i){for(let[a,l]of W(this,ml))a===e?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of W(this,es))a===e?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(W(this,Nv)),n.ondiscard(W(this,kT))}else Re&&(this.anchor=Je),W(this,Nv).call(this,n)}};Ea=new WeakMap,ml=new WeakMap,es=new WeakMap,zd=new WeakMap,Ov=new WeakMap,Nv=new WeakMap,kT=new WeakMap;function Lv(r,e,...t){var n=new Ta(r);ao(()=>{let i=e()??null;re&&i==null&&SL(),n.ensure(i,i&&(o=>i(o,...t)))},65536)}if(re){let r=function(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;IL(e)},set:n=>{t=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function ST(r){At===null&&XE("onMount"),Zl&&At.l!==null?eX(At).m.push(r):hr(()=>{let e=Ot(r);if(typeof e=="function")return e})}function eX(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}var U2=new Map;function q2(r,e){var t=U2.get(r);t||(t=new Set,U2.set(r,t)),t.add(e)}function ie(r,e,t=!1){var n;Re&&(n=Je,Kn());var i=new Ta(r),o=t?65536:0;function s(a,l){if(Re){var c=gv(n);if(a!==parseInt(c.substring(1))){var u=il();tr(u),i.anchor=u,In(!1),i.ensure(a,l),In(!0);return}}i.ensure(a,l)}ao(()=>{var a=!1;e((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var iX=Symbol("NaN");function u0(r,e,t){Re&&Kn();var n=new Ta(r),i=!ya();ao(()=>{var o=e();o!==o&&(o=iX),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function Uv(r,e){return e}function cX(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=0;a<i;a++){let d=e[a];al(d,()=>{if(o){if(o.pending.delete(d),o.done.add(d),o.pending.size===0){var f=r.outrogroups;d0(r,Af(o.done)),f.delete(o),f.size===0&&(r.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=n.length===0&&t!==null&&r.pending.size===0;if(l){var c=t,u=c.parentNode;Ff(u),u.append(c),r.items.clear()}d0(r,e,!l)}else o={pending:new Set(e),done:new Set},(r.outrogroups??(r.outrogroups=new Set)).add(o)}function d0(r,e,t=!0){var n;if(r.pending.size>0){n=new Set;for(let s of r.pending.values())for(let a of s)n.add(r.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(n?.has(o)){o.f|=33554432;let s=document.createDocumentFragment();Rf(o,s)}else Wr(e[i],t)}}var DT;function ar(r,e,t,n,i,o=null){var s=r,a=new Map,l=(e&4)!==0;if(l){var c=r;s=Re?tr(vi(c)):c.appendChild(tn())}Re&&Kn();var u=null,d=Rd(()=>{var k=t();return fa(k)?k:k==null?[]:Af(k)});re&&Li(d,"{#each ...}");var f,p=new Map,m=!0;function v(k){(w.effect.f&16384)===0&&(w.pending.delete(k),w.fallback=u,uX(w,f,s,e,n),u!==null&&(f.length===0?(u.f&33554432)===0?Yf(u):(u.f^=33554432,Vv(u,null,s)):al(u,()=>{u=null})))}function g(k){w.pending.delete(k)}var y=ao(()=>{f=h(d);var k=f.length;let C=!1;if(Re){var E=gv(s)==="[!";E!==(k===0)&&(s=il(),tr(s),In(!1),C=!0)}for(var x=new Set,D=qe,P=wT(),H=0;H<k;H+=1){Re&&Je.nodeType===Go&&Je.data==="]"&&(s=Je,C=!0,In(!1));var U=f[H],oe=n(U,H);if(re){var ce=n(U,H);oe!==ce&&xL(String(H),String(oe),String(ce))}var O=m?null:a.get(oe);O?(O.v&&Ca(O.v,U),O.i&&Ca(O.i,H),P&&D.unskip_effect(O.e)):(O=dX(a,m?s:DT??(DT=tn()),U,oe,H,i,e,t),m||(O.e.f|=33554432),a.set(oe,O)),x.add(oe)}if(k===0&&o&&!u&&(m?u=On(()=>o(s)):(u=On(()=>o(DT??(DT=tn()))),u.f|=33554432)),k>x.size&&(re?pX(f,n):kI("","","")),Re&&k>0&&tr(il()),!m)if(p.set(D,x),P){for(let[G,V]of a)x.has(G)||D.skip_effect(V.e);D.oncommit(v),D.ondiscard(g)}else v(D);C&&In(!0),h(d)}),w={effect:y,flags:e,items:a,pending:p,outrogroups:null,fallback:u};m=!1,Re&&(s=Je)}function Bv(r){for(;r!==null&&(r.f&32)===0;)r=r.next;return r}function uX(r,e,t,n,i){var o=(n&8)!==0,s=e.length,a=r.items,l=Bv(r.effect.first),c,u=null,d,f=[],p=[],m,v,g,y;if(o)for(y=0;y<s;y+=1)m=e[y],v=i(m,y),g=a.get(v).e,(g.f&33554432)===0&&(g.nodes?.a?.measure(),(d??(d=new Set)).add(g));for(y=0;y<s;y+=1){if(m=e[y],v=i(m,y),g=a.get(v).e,r.outrogroups!==null)for(let U of r.outrogroups)U.pending.delete(g),U.done.delete(g);if((g.f&8192)!==0&&(Yf(g),o&&(g.nodes?.a?.unfix(),(d??(d=new Set)).delete(g))),(g.f&33554432)!==0)if(g.f^=33554432,g===l)Vv(g,null,t);else{var w=u?u.next:l;g===r.effect.last&&(r.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),hu(r,u,g),hu(r,g,w),Vv(g,w,t),u=g,f=[],p=[],l=Bv(u.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(f.length<p.length){var k=p[0],C;u=k.prev;var E=f[0],x=f[f.length-1];for(C=0;C<f.length;C+=1)Vv(f[C],k,t);for(C=0;C<p.length;C+=1)c.delete(p[C]);hu(r,E.prev,x.next),hu(r,u,E),hu(r,x,k),l=k,u=x,y-=1,f=[],p=[]}else c.delete(g),Vv(g,l,t),hu(r,g.prev,g.next),hu(r,g,u===null?r.effect.first:u.next),hu(r,u,g),u=g;continue}for(f=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Bv(l.next);if(l===null)continue}(g.f&33554432)===0&&f.push(g),u=g,l=Bv(g.next)}if(r.outrogroups!==null){for(let U of r.outrogroups)U.pending.size===0&&(d0(r,Af(U.done)),r.outrogroups?.delete(U));r.outrogroups.size===0&&(r.outrogroups=null)}if(l!==null||c!==void 0){var D=[];if(c!==void 0)for(g of c)(g.f&8192)===0&&D.push(g);for(;l!==null;)(l.f&8192)===0&&l!==r.fallback&&D.push(l),l=Bv(l.next);var P=D.length;if(P>0){var H=(n&4)!==0&&s===0?t:null;if(o){for(y=0;y<P;y+=1)D[y].nodes?.a?.measure();for(y=0;y<P;y+=1)D[y].nodes?.a?.fix()}cX(r,D,H)}}o&&Ur(()=>{if(d!==void 0)for(g of d)g.nodes?.a?.apply()})}function dX(r,e,t,n,i,o,s,a){var l=(s&1)!==0?(s&16)===0?Sd(t,!1,!1):Ui(t):null,c=(s&2)!==0?Ui(i):null;return re&&l&&(l.trace=()=>{a()[c?.v??i]}),{v:l,i:c,e:On(()=>(o(e,l??t,c??i,a),()=>{r.delete(n)}))}}function Vv(r,e,t){if(r.nodes)for(var n=r.nodes.start,i=r.nodes.end,o=e&&(e.f&33554432)===0?e.nodes.start:t;n!==null;){var s=gi(n);if(o.before(n),n===i)return;n=s}}function hu(r,e,t){e===null?r.effect.first=t:e.next=t,t===null?r.effect.last=e:t.prev=e}function pX(r,e){let t=new Map,n=r.length;for(let i=0;i<n;i++){let o=e(r[i],i);if(t.has(o)){let s=String(t.get(o)),a=String(i),l=String(o);l.startsWith("[object ")&&(l=null),kI(s,a,l)}t.set(o,i)}}var fX=WE?()=>performance.now():()=>Date.now(),_a={tick:r=>(WE?requestAnimationFrame:Ut)(r),now:()=>fX(),tasks:new Set};function z2(){let r=_a.now();_a.tasks.forEach(e=>{e.c(r)||(_a.tasks.delete(e),e.f())}),_a.tasks.size!==0&&_a.tick(z2)}function H2(r){let e;return _a.tasks.size===0&&_a.tick(z2),{promise:new Promise(t=>{_a.tasks.add(e={c:r,f:t})}),abort(){_a.tasks.delete(e)}}}function mX(r){if(r==="float")return"cssFloat";if(r==="offset")return"cssOffset";if(r.startsWith("--"))return r;let e=r.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function j2(r){let e={},t=r.split(";");for(let n of t){let[i,o]=n.split(":");if(!i||o===void 0)break;let s=mX(i.trim());e[s]=o.trim()}return e}var hX=r=>r,gX=null;function p0(r,e,t){var n=gX??Fe,i=n.nodes,o,s,a,l=null;i.a??(i.a={element:r,measure(){o=this.element.getBoundingClientRect()},apply(){if(a?.abort(),s=this.element.getBoundingClientRect(),o.left!==s.left||o.right!==s.right||o.top!==s.top||o.bottom!==s.bottom){let c=e()(this.element,{from:o,to:s},t?.());a=G2(this.element,c,void 0,1,()=>{},()=>{a?.abort(),a=void 0})}},fix(){if(!r.getAnimations().length){var{position:c,width:u,height:d}=getComputedStyle(r);if(c!=="absolute"&&c!=="fixed"){var f=r.style;l={position:f.position,width:f.width,height:f.height,transform:f.transform},f.position="absolute",f.width=u,f.height=d;var p=r.getBoundingClientRect();if(o.left!==p.left||o.top!==p.top){var m=`translate(${o.left-p.left}px, ${o.top-p.top}px)`;f.transform=f.transform?`${f.transform} ${m}`:m}}}},unfix(){if(l){var c=r.style;c.position=l.position,c.width=l.width,c.height=l.height,c.transform=l.transform}}}),i.a.element=r}function G2(r,e,t,n,i,o){var s=n===1;if(TI(e)){var a,l=!1;return Ur(()=>{if(!l){var y=e({direction:s?"in":"out"});a=G2(r,y,t,n,i,o)}}),{abort:()=>{l=!0,a?.abort()},deactivate:()=>a.deactivate(),reset:()=>a.reset(),t:()=>a.t()}}if(t?.deactivate(),!e?.duration&&!e?.delay)return i(),o(),{abort:Ut,deactivate:Ut,reset:Ut,t:()=>n};let{delay:c=0,css:u,tick:d,easing:f=hX}=e;var p=[];if(s&&t===void 0&&(d&&d(0,1),u)){var m=j2(u(0,1));p.push(m,m)}var v=()=>1-n,g=r.animate(p,{duration:c,fill:"forwards"});return g.onfinish=()=>{g.cancel(),i();var y=t?.t()??1-n;t?.abort();var w=n-y,k=e.duration*Math.abs(w),C=[];if(k>0){var E=!1;if(u)for(var x=Math.ceil(k/16.666666666666668),D=0;D<=x;D+=1){var P=y+w*f(D/x),H=j2(u(P,1-P));C.push(H),E||(E=H.overflow==="hidden")}E&&(r.style.overflow="hidden"),v=()=>{var U=g.currentTime;return y+w*f(U/k)},d&&H2(()=>{if(g.playState!=="running")return!1;var U=v();return d(U,1-U),!0})}g=r.animate(C,{duration:k,fill:"forwards"}),g.onfinish=()=>{v=()=>n,d?.(n,1-n),o()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=Ut)},deactivate:()=>{o=Ut},reset:()=>{n===0&&d?.(1,0)},t:()=>v()}}function ot(r,e){un(()=>{var t=r.getRootNode(),n=t.host?t:t.head??t.ownerDocument.head;if(!n.querySelector("#"+e.hash)){let i=dl("style");i.id=e.hash,i.textContent=e.code,n.appendChild(i),re&&q2(e.hash,i)}})}function Mr(r,e,t){un(()=>{var n=Ot(()=>e(r,t?.())||{});if(t&&n?.update){var i=!1,o={};Zn(()=>{var s=t();ET(s),i&&eT(o,s)&&(o=s,n.update(s))}),i=!0}if(n?.destroy)return()=>n.destroy()})}var Y2=[...`
\r\f\xA0\v\uFEFF`];function Q2(r,e,t){var n=r==null?"":""+r;if(e&&(n=n?n+" "+e:e),t){for(var i of Object.keys(t))if(t[i])n=n?n+" "+i:i;else if(n.length)for(var o=i.length,s=0;(s=n.indexOf(i,s))>=0;){var a=s+o;(s===0||Y2.includes(n[s-1]))&&(a===n.length||Y2.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function K2(r,e=!1){var t=e?" !important;":";",n="";for(var i of Object.keys(r)){var o=r[i];o!=null&&o!==""&&(n+=" "+i+": "+o+t)}return n}function f0(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function X2(r,e){if(e){var t="",n,i;if(Array.isArray(e)?(n=e[0],i=e[1]):n=e,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(f0)),i&&l.push(...Object.keys(i).map(f0));var c=0,u=-1;let v=r.length;for(var d=0;d<v;d++){var f=r[d];if(a?f==="/"&&r[d-1]==="*"&&(a=!1):o?o===f&&(o=!1):f==="/"&&r[d+1]==="*"?a=!0:f==='"'||f==="'"?o=f:f==="("?s++:f===")"&&s--,!a&&o===!1&&s===0){if(f===":"&&u===-1)u=d;else if(f===";"||d===v-1){if(u!==-1){var p=f0(r.substring(c,u).trim());if(!l.includes(p)){f!==";"&&d++;var m=r.substring(c,d).trim();t+=" "+m+";"}}c=d+1,u=-1}}}}return n&&(t+=K2(n)),i&&(t+=K2(i,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function xt(r,e,t,n,i,o){var s=r[pv];if(Re||s!==t||s===void 0){var a=Q2(t,n,o);(!Re||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r[pv]=t}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&r.classList.toggle(l,c)}return o}function m0(r,e={},t,n){for(var i in t){var o=t[i];e[i]!==o&&(t[i]==null?r.style.removeProperty(i):r.style.setProperty(i,o,n))}}function Xf(r,e,t,n){var i=r[fv];if(Re||i!==e){var o=X2(e,n);(!Re||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[fv]=e}else n&&(Array.isArray(n)?(m0(r,t?.[0],n[0]),m0(r,t?.[1],n[1],"important")):m0(r,t,n));return n}function gu(r,e,t=!1){if(r.multiple){if(e==null)return;if(!fa(e))return VL();for(var n of r.options)n.selected=e.includes(qv(n));return}for(n of r.options){var i=qv(n);if(JI(i,e)){n.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function Hd(r){var e=new MutationObserver(()=>{"__value"in r&&gu(r,r.__value)});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Xn(()=>{e.disconnect()})}function h0(r,e,t=e){var n=new WeakSet,i=!0;lT(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),qv);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&qv(l)}t(a),r.__value=a,qe!==null&&n.add(qe)}),un(()=>{var o=e();if(r===document.activeElement){var s=en?ll:qe;if(n.has(s))return}if(gu(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=qv(a),t(o))}r.__value=o,i=!1}),Hd(r)}function qv(r){return"__value"in r?r.__value:r.value}var wX=Symbol("is custom element"),CX=Symbol("is html"),xX=QE?"link":"LINK";var EX=QE?"progress":"PROGRESS";function gr(r){if(Re){var e=!1,t=()=>{if(!e){if(e=!0,r.hasAttribute("value")){var n=r.value;Ae(r,"value",null),r.value=n}if(r.hasAttribute("checked")){var i=r.checked;Ae(r,"checked",null),r.checked=i}}};r[lu]=t,Ur(t),aT()}}function Rs(r,e){var t=v0(r);t.value===(t.value=e??void 0)||r.value===e&&(e!==0||r.nodeName!==EX)||(r.value=e??"")}function jd(r,e){var t=v0(r);t.checked!==(t.checked=e??void 0)&&(r.checked=e)}function Ae(r,e,t,n){var i=v0(r);if(Re&&(i[e]=r.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&r.nodeName===xX)){n||_X(r,e,t??"");return}i[e]!==(i[e]=t)&&(e==="loading"&&(r[vL]=t),t==null?r.removeAttribute(e):typeof t!="string"&&TX(r).includes(e)?r[e]=t:r.setAttribute(e,t))}function v0(r){var e;return r[e=KE]??(r[e]={[wX]:r.nodeName.includes("-"),[CX]:r.namespaceURI===qE})}var Z2=new Map;function TX(r){var e=r.getAttribute("is")||r.nodeName,t=Z2.get(e);if(t)return t;Z2.set(e,t=[]);for(var n,i=r,o=Element.prototype;o!==i;){n=zE(i);for(var s in n)n[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&t.push(s);i=au(i)}return t}function _X(r,e,t){re&&(e==="srcset"&&AX(r,t)||g0(r.getAttribute(e)??"",t)||LL(e,r.outerHTML.replace(r.innerHTML,r.innerHTML&&"..."),String(t)))}function g0(r,e){return r===e?!0:new URL(r,document.baseURI).href===new URL(e,document.baseURI).href}function J2(r){return r.split(",").map(e=>e.trim().split(" ").filter(Boolean))}function AX(r,e){var t=J2(r.srcset),n=J2(e);return n.length===t.length&&n.every(([i,o],s)=>o===t[s][1]&&(g0(t[s][0],i)||g0(i,t[s][0])))}function po(r,e,t=e){var n=new WeakSet;lT(r,"input",async i=>{re&&r.type==="checkbox"&&AI();var o=i?r.defaultValue:r.value;if(o=y0(r)?b0(o):o,t(o),qe!==null&&n.add(qe),await Kf(),o!==(o=e())){var s=r.selectionStart,a=r.selectionEnd,l=r.value.length;if(r.value=o??"",a!==null){var c=r.value.length;s===a&&a===l&&c>l?(r.selectionStart=c,r.selectionEnd=c):(r.selectionStart=s,r.selectionEnd=Math.min(a,c))}}}),(Re&&r.defaultValue!==r.value||Ot(e)==null&&r.value)&&(t(y0(r)?b0(r.value):r.value),qe!==null&&n.add(qe)),Zn(()=>{re&&r.type==="checkbox"&&AI();var i=e();if(r===document.activeElement){var o=en?ll:qe;if(n.has(o))return}y0(r)&&i===b0(r.value)||r.type==="date"&&!i&&!r.value||i!==r.value&&(r.value=i??"")})}function y0(r){var e=r.type;return e==="number"||e==="range"}function b0(r){return r===""?null:+r}function w0(r,e){return r===e||r?.[Dn]===e}function cc(r={},e,t,n){var i=At.r,o=Fe;return un(()=>{var s,a;return Zn(()=>{s=a,a=n?.()||[],Ot(()=>{w0(t(...a),r)||(e(r,...a),s&&w0(t(...s),r)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&33554432;)l=l.parent;let c=()=>{a&&w0(t(...a),r)&&e(null,...a)},u=l.teardown;l.teardown=()=>{c(),u?.()}}}),r}function he(r,e,t,n){var i=!Zl||(t&2)!==0,o=(t&8)!==0,s=(t&16)!==0,a=n,l=!0,c=void 0,u=()=>s&&i?(c??(c=du(n)),h(c)):(l&&(l=!1,a=s?Ot(n):n),a);let d;if(o){var f=Dn in r||dv in r;d=ko(r,e)?.set??(f&&e in r?C=>r[e]=C:void 0)}var p,m=!1;o?[p,m]=PI(()=>r[e]):p=r[e],p===void 0&&n!==void 0&&(p=u(),d&&(i&&DL(e),d(p)));var v;if(i?v=()=>{var C=r[e];return C===void 0?u():(l=!0,C)}:v=()=>{var C=r[e];return C!==void 0&&(a=void 0),C===void 0?a:C},i&&(t&4)===0)return v;if(d){var g=r.$$legacy;return(function(C,E){return arguments.length>0?((!i||!E||g||m)&&d(E?v():C),C):v()})}var y=!1,w=((t&1)!==0?du:Rd)(()=>(y=!1,v()));re&&(w.label=e),o&&h(w);var k=Fe;return(function(C,E){if(arguments.length>0){let x=E?h(w):i&&o?Ct(C):C;return J(w,x),y=!0,a!==void 0&&(a=x),C}return Xo&&y||(k.f&16384)!==0?w.v:h(w)})}function tB(r){return new x0(r)}var uc,$s,x0=class{constructor(e){it(this,uc);it(this,$s);var t=new Map,n=(o,s)=>{var a=Sd(s,!1,!1);return t.set(o,a),a};let i=new Proxy({...e.props||{},$$events:{}},{get(o,s){return h(t.get(s)??n(s,Reflect.get(o,s)))},has(o,s){return s===dv?!0:(h(t.get(s)??n(s,Reflect.get(o,s))),Reflect.has(o,s))},set(o,s,a){return J(t.get(s)??n(s,a),a),Reflect.set(o,s,a)}});et(this,$s,(e.hydrate?c0:Wd)(e.component,{target:e.target,anchor:e.anchor,props:i,context:e.context,intro:e.intro??!1,recover:e.recover,transformError:e.transformError})),!en&&(!e?.props?.$$host||e.sync===!1)&&Bd(),et(this,uc,i.$$events);for(let o of Object.keys(W(this,$s)))o==="$set"||o==="$destroy"||o==="$on"||Ni(this,o,{get(){return W(this,$s)[o]},set(s){W(this,$s)[o]=s},enumerable:!0});W(this,$s).$set=o=>{Object.assign(i,o)},W(this,$s).$destroy=()=>{Qf(W(this,$s))}}$set(e){W(this,$s).$set(e)}$on(e,t){W(this,uc)[e]=W(this,uc)[e]||[];let n=(...i)=>t.call(this,...i);return W(this,uc)[e].push(n),()=>{W(this,uc)[e]=W(this,uc)[e].filter(i=>i!==n)}}$destroy(){W(this,$s).$destroy()}};uc=new WeakMap,$s=new WeakMap;var BX;typeof HTMLElement=="function"&&(BX=class extends HTMLElement{constructor(e,t,n){super();ae(this,"$$ctor");ae(this,"$$s");ae(this,"$$c");ae(this,"$$cn",!1);ae(this,"$$d",{});ae(this,"$$r",!1);ae(this,"$$p_d",{});ae(this,"$$l",{});ae(this,"$$l_u",new Map);ae(this,"$$me");ae(this,"$$shadowRoot",null);this.$$ctor=e,this.$$s=t,n&&(this.$$shadowRoot=this.attachShadow(n))}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let i=this.$$c.$on(e,t);this.$$l_u.set(t,i)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){let i=this.$$l_u.get(t);i&&(i(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return o=>{let s=dl("slot");i!=="default"&&(s.name=i),$(o,s)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},n=VX(this);for(let i of this.$$s)i in n&&(i==="default"&&!this.$$d.children?(this.$$d.children=e(i),t.default=!0):t[i]=e(i));for(let i of this.attributes){let o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=E0(o,i.value,this.$$p_d,"toProp"))}for(let i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=tB({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=r0(()=>{Zn(()=>{this.$$r=!0;for(let i of xI(this.$$c)){if(!this.$$p_d[i]?.reflect)continue;this.$$d[i]=this.$$c[i];let o=E0(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1})});for(let i in this.$$l)for(let o of this.$$l[i]){let s=this.$$c.$on(i,o);this.$$l_u.set(o,s)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=E0(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return xI(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function E0(r,e,t,n){let i=t[r]?.type;if(e=i==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[r])return e;if(n==="toAttribute")switch(i){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(i){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function VX(r){let e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}var mg=require("obsidian");Pt();Me();var LY=require("obsidian");_t();var Yv={location:"tab",direction:"vertical",mode:"default",focus:!0};function pn(r,e){if(!(e?.fillMissingOnly??!0))return{...Yv,...r??{}};let n={...r??{}};return n.location==null&&(n.location=Yv.location),n.direction==null&&(n.direction=Yv.direction),n.mode==null&&(n.mode=Yv.mode),n.focus==null&&(n.focus=Yv.focus),n}Cr();var LB=require("obsidian"),KX=q('<span class="quickadd-icon svelte-1fiwm9k"></span>'),QX={hash:"svelte-1fiwm9k",code:".quickadd-icon.svelte-1fiwm9k {display:inline-flex;align-items:center;}.quickadd-icon.svelte-1fiwm9k svg {display:inline-block;vertical-align:middle;}"};function $t(r,e){we(e,!0),ot(r,QX);let t=he(e,"size",3,16),n=_e(void 0);hr(()=>{if(!h(n)||!e.iconId)return;(0,LB.setIcon)(h(n),e.iconId);let o=h(n).querySelector("svg");o&&(o.setAttribute("width",`${t()}`),o.setAttribute("height",`${t()}`))});var i=KX();cc(i,o=>J(n,o),()=>h(n)),$(r,i),Ce()}var XX=q('<pre class="qaMountFailedDetail svelte-bhgeqn"> </pre>'),ZX=q(`<div class="qaMountFailed svelte-bhgeqn"><div class="qaMountFailedHead svelte-bhgeqn"><!> <span class="qaMountFailedTitle svelte-bhgeqn"> </span></div> <p class="qaMountFailedBody svelte-bhgeqn">This part of QuickAdd could not be drawn, so it has been left out. Nothing
was changed by the error. Include the message below if you report this.</p> <!></div>`),JX={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaMountFailedHead.svelte-bhgeqn {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaMountFailedTitle.svelte-bhgeqn {font-weight:var(--font-semibold);color:var(--text-normal);}.qaMountFailedBody.svelte-bhgeqn {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function O0(r,e){ot(r,JX);let t=he(e,"detail",3,"");var n=ZX(),i=I(n),o=I(i);$t(o,{iconId:"alert-triangle",size:16});var s=_(o,2),a=I(s);S(s),S(i);var l=_(i,4);{var c=u=>{var d=XX(),f=I(d,!0);S(d),de(()=>me(f,t())),$(u,d)};ie(l,u=>{t()&&u(c)})}S(n),de(()=>me(a,`QuickAdd couldn't display ${e.what??""}`)),$(r,n)}var eZ="this part of QuickAdd";function Wi(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Wd(e,{target:r,props:t})}catch(a){return tZ(r,i,Zd(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,Qf(o))}}}function tZ(r,e,t,n){let i=n.what??eZ;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();lt(t,`Couldn't display ${i}`);let o=r.ownerDocument.createElement("div");o.className="qa-mount-failed-host",r.appendChild(o);let s=null;try{s=Wd(n.fallbackComponent??O0,{target:o,props:{what:i,detail:t.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&Qf(s),o.remove())}}}var BB=require("obsidian");_t();function im(r){return r.trim().replace(/^\/+/,"")}function xu(r){return r.trim().toLowerCase().endsWith(".canvas")}function L0(r,e){let t=im(e);if(!t||t.includes("{{"))return null;let n=r.vault.getAbstractFileByPath(t);return!n||!(n instanceof BB.TFile)||n.extension!=="canvas"?null:n}function VB(r,e){let n=r.workspace.getMostRecentLeaf?.()?.view;if(!n||n.getViewType?.()!=="canvas")return null;let i=im(e),o=im(n.file?.path??r.workspace.getActiveFile()?.path??"");if(!i||i!==o)return null;let s=n.canvas?.selection?Array.from(n.canvas.selection):[];if(s.length!==1)return null;let a=s[0]?.id;return typeof a=="string"&&a.length>0?a:null}function rZ(r){return typeof r=="string"?r:r&&typeof r=="object"&&"path"in r&&typeof r.path=="string"?r.path:"(missing file path)"}function nZ(r){return typeof r.x!="number"||typeof r.y!="number"||typeof r.width!="number"||typeof r.height!="number"?"":`${Math.round(r.x)},${Math.round(r.y)} \xB7 ${Math.round(r.width)}x${Math.round(r.height)}`}function N0(r,e){return r.length<=e?r:r.slice(0,e-1)+"\u2026"}async function UB(r,e){try{let t=await r.vault.cachedRead(e),n=JSON.parse(t);if(!n||typeof n!="object")return[];let i=n.nodes;if(!Array.isArray(i))return[];let o=i.filter(a=>!!a&&typeof a=="object"&&typeof a.id=="string").map(a=>{let l=a.type==="text"?"text":a.type==="file"?"file":"other",c=nZ(a);if(l==="text"){let m=(typeof a.text=="string"?a.text:"").split(`
`).map(w=>w.trim()).filter(w=>w.length>0),v=N0(m[0]??"(empty text card)",90),g=[`${m.length} line${m.length===1?"":"s"}`];c&&g.push(c);let y=g.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let p=rZ(a.file),m=ir.test(p),v=m?"":"Canvas file cards must link to markdown files (.md).",g=N0(p.split("/").pop()??p,90),y=[N0(p,120)];c&&y.push(c),m||y.push("Not capturable in this version");let w=y.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:w,searchText:`${a.id} ${g} ${w}`.toLowerCase(),capturable:m,capturableReason:v}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,f=c||"Type is not currently capturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.toLowerCase(),capturable:!1,capturableReason:"This Canvas node type is not capturable."}}),s={text:0,file:1,other:2};return o.sort((a,l)=>{let c=s[a.type]-s[l.type];return c!==0?c:a.title.localeCompare(l.title)})}catch{return[]}}qt();function ku(r){return/\{\{[^}]*\}\}/.test(r)}yl();Mo();Wt();_t();var OJ=["noteContent","captureTarget","fileName","lineTarget"],NJ=["captureTarget","fileName"],Ci=OJ,vU=3;function Ke(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var LJ=[{regex:mB,contexts:Ci,suggestion:Ke("{{VALUE}}","Asks you for text when the choice runs")},{regex:hB,contexts:Ci,suggestion:Ke("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Ke("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Ke("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Ke("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Ke("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Ke("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Ke("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Ke("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Ke("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Ke("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Ke("{{VALUE:title|trim}}","Trims whitespace off the answer"),Ke("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:fB,contexts:Ci,suggestion:Ke("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:gB,contexts:Ci,suggestion:Ke("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Ke("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Ke("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Ke("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Ke("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable"),Ke("{{VDATE:date,dddd, MMMM Do, YYYY|case:lower}}","Lowercases the picked date after formatting")]},{regex:xB,contexts:Ci,suggestion:Ke("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:CB,contexts:Ci,suggestion:Ke("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let e=[Ke("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return NJ.includes(r)||e.push(Ke("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Ke("{{FILE:<folder>|path}}","Same, but inserts its full path"),Ke("{{FILE:<folder>|optional}}","Same, but skippable")),e.push(Ke("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),e}},{regex:_B,contexts:Ci,suggestion:Ke("{{MVALUE}}","Asks you for a math formula (LaTeX), with a live preview")},{regex:dB,contexts:Ci,suggestion:Ke("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:pB,contexts:Ci,suggestion:Ke("{{DATE:}}","Today's date in a format you choose, like {{DATE:MMMM Do}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMM Do, YYYY","ddd D MMM","gggg-[W]ww"].map(e=>Ke(`{{DATE:${e}}}`,r(e))),Ke("{{DATE+7}}","Seven days from today"),Ke("{{DATE:YYYY-MM-DD|startof:week}}","Snapped to the start of the week, month, quarter or year"),Ke("{{DATE:dddd, MMMM Do, YYYY|case:lower}}","Lowercases the formatted date")]},{regex:PB,contexts:Ci,suggestion:Ke("{{TIME}}","The current time, as HH:mm")},{regex:FB,contexts:Ci,suggestion:Ke("{{TIME:}}","The current time in a format you choose, like {{TIME:HH.mm}}"),expansions:()=>[Ke("{{TIME:A|case:lower}}","Lowercases formatted text, such as AM to am")]},{regex:vB,contexts:["noteContent","lineTarget"],suggestion:Ke("{{LINKCURRENT}}","A link to that note: [[That note]]")},{regex:yB,contexts:["noteContent","lineTarget"],suggestion:Ke("{{LINKSECTION}}","A link to the section your cursor is in")},{regex:bB,contexts:["noteContent","captureTarget","fileName","lineTarget"],suggestion:Ke("{{FILENAMECURRENT}}","That note's file name")},{regex:M0,contexts:["noteContent","captureTarget"],suggestion:Ke("{{FOLDERCURRENT}}","That note's folder")},{regex:M0,contexts:["fileName"],suggestion:Ke("{{FOLDERCURRENT|name}}","That note's folder name, without the path")},{regex:kB,contexts:Ci,suggestion:Ke("{{SELECTED}}","The text you had selected in the editor")},{regex:AB,contexts:["noteContent","lineTarget"],suggestion:Ke("{{TITLE}}","The new note's file name")},{regex:wB,contexts:["fileName"],suggestion:Ke("{{FOLDER|name}}","The name of the folder the new note lands in")},{regex:SB,contexts:Ci,suggestion:Ke("{{CLIPBOARD}}","Whatever you copied last")},{regex:EB,contexts:Ci,suggestion:Ke("{{TEMPLATE:}}","The contents of a template file"),expansions:({templatePaths:r})=>r.map(e=>Ke(`{{TEMPLATE:${e}}}`,"Inserts this template's contents"))},{regex:TB,contexts:Ci,suggestion:Ke("{{MACRO:}}","Whatever a macro returns"),expansions:({macroNames:r})=>[...r.map(e=>Ke(`{{MACRO:${e}}}`,`Runs your "${e}" macro`)),Ke("{{MACRO:MyMacro|label:Label}}","Word the macro's own prompt yourself")]},{regex:IB,contexts:Ci,suggestion:Ke("{{GLOBAL_VAR:}}","A snippet you defined in QuickAdd's settings"),expansions:({globalVariableNames:r})=>r.map(e=>Ke(`{{GLOBAL_VAR:${e}}}`,`Inserts your "${e}" snippet`))},{regex:DB,contexts:Ci,suggestion:Ke("{{RANDOM:}}","A random ID of the length you give, like {{RANDOM:6}}")}],yU=[{insert:"kebab",description:"my-note-title",caretOffset:0,isFragment:!0},{insert:"snake",description:"my_note_title",caretOffset:0,isFragment:!0},{insert:"camel",description:"myNoteTitle",caretOffset:0,isFragment:!0},{insert:"pascal",description:"MyNoteTitle",caretOffset:0,isFragment:!0},{insert:"title",description:"My Note Title",caretOffset:0,isFragment:!0},{insert:"lower",description:"my note title",caretOffset:0,isFragment:!0},{insert:"upper",description:"MY NOTE TITLE",caretOffset:0,isFragment:!0},{insert:"slug",description:"my-note-title, guarded against reserved file names",caretOffset:0,isFragment:!0}];function bU(r){return LJ.filter(e=>e.contexts.includes(r))}var BJ=/^\{\{(VALUE|NAME|DATE|TIME|VDATE)([^\n\r}]*)\|case:([a-z-]*)$/i,VJ=new Set(["DATE","TIME","VDATE"]),UJ=/<[^<>\n\r]+>/,ji=class extends hn{constructor(t,n,i,o="noteContent"){super(t,n);this.app=t;this.inputEl=n;this.plugin=i;this.context=o;this.replaceFrom=0;this.matchedQuery="";this.macroNames=Vn(this.plugin.settings.choices).filter(s=>s.type==="Macro").map(s=>s.name),this.templatePaths=this.plugin.getTemplateFiles().map(s=>s.path)}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.lastIndexOf("{{",n-1);if(i===-1)return[];let o=t.slice(i,n);if(o.includes("}}"))return[];let s=o.match(BJ);if(s){let m=s[1]?.toUpperCase()??"",v=s[2]??"";if(VJ.has(m)&&v.lastIndexOf("[")>v.lastIndexOf("]"))return[];let g=s[3]??"";this.matchedQuery=g,this.replaceFrom=n-g.length;let y=g.toLowerCase();return yU.filter(w=>w.insert.startsWith(y)).map(w=>({...w}))}if(o.includes(":"))return[];let a=[],l=new Set,c=m=>{l.has(m.insert)||(l.add(m.insert),a.push(m))};this.replaceFrom=i,this.matchedQuery=o.slice(2);let u=bU(this.context).filter(m=>{let v=m.regex.exec(o);return v!==null&&v.index+v[0].length===o.length}),d=this.matchedQuery.toLowerCase(),f=m=>m.suggestion.insert.slice(2).toLowerCase().startsWith(d),p=[...u.filter(f),...u.filter(m=>!f(m))];for(let m of p)if(c(m.suggestion),!!m.expansions&&!(this.matchedQuery.length<vU))for(let v of m.expansions({templatePaths:this.templatePaths,macroNames:this.macroNames,globalVariableNames:Object.keys(this.plugin?.settings?.globalVariables??{}),context:this.context,formatDate:g=>typeof window.moment=="function"?window.moment().format(g):g}))c(v);return a}selectSuggestion(t){if(this.inputEl.selectionStart===null)return;let n=this.inputEl.selectionStart,i=this.replaceFrom;y_(this.inputEl,i,n,t.insert,{fromCompletion:!0});let o=UJ.exec(t.insert);if(o){let s=i+o.index;this.inputEl.setSelectionRange(s,s+o[0].length)}else if(t.caretOffset>0){let s=i+t.insert.length-t.caretOffset;this.inputEl.setSelectionRange(s,s)}this.close()}renderSuggestion(t,n){if(!t)return;n.classList.add("qa-format-suggestion");let i=n.ownerDocument.createElement("span");i.className=t.isFragment?"qa-format-suggestion-token qa-format-suggestion-token-fragment":"qa-format-suggestion-token",this.renderMatch(i,t.insert,this.matchedQuery),n.appendChild(i);let o=n.ownerDocument.createElement("span");o.className="qa-format-suggestion-description",o.textContent=t.description,n.appendChild(o)}};var qJ=q('<label class="setting-item-name"> </label>'),WJ=q('<div class="setting-item-name"> </div>'),zJ=q('<div class="setting-item-description"> </div>'),HJ=q('<div><div class="setting-item-info"><!> <!></div> <div class="setting-item-control"><!></div></div>');function $e(r,e){let t=he(e,"name",3,void 0),n=he(e,"desc",3,void 0),i=he(e,"heading",3,!1),o=he(e,"labelFor",3,void 0),s=he(e,"control",3,void 0),a=he(e,"children",3,void 0);var l=HJ();let c;var u=I(l),d=I(u);{var f=y=>{var w=dn(),k=Pe(w);{var C=x=>{var D=qJ(),P=I(D,!0);S(D),de(()=>{Ae(D,"for",o()),me(P,t())}),$(x,D)},E=x=>{var D=WJ(),P=I(D,!0);S(D),de(()=>me(P,t())),$(x,D)};ie(k,x=>{o()?x(C):x(E,-1)})}$(y,w)};ie(d,y=>{t()&&y(f)})}var p=_(d,2);{var m=y=>{var w=zJ(),k=I(w,!0);S(w),de(()=>me(k,n())),$(y,w)};ie(p,y=>{n()&&y(m)})}S(u);var v=_(u,2),g=I(v);Lv(g,()=>s()??a()??Ut),S(v),S(l),de(()=>c=xt(l,1,"setting-item",null,c,{"setting-item-heading":i()})),$(r,l)}var jJ=q('<div role="switch"><input type="checkbox" tabindex="-1" aria-hidden="true" class="svelte-1bigjf0"/></div>'),GJ={hash:"svelte-1bigjf0",code:`
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-1bigjf0 > input:where(.svelte-1bigjf0) {pointer-events:none;}`};function lr(r,e){we(e,!0),ot(r,GJ);let t=he(e,"checked",15),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0),s=N(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a())}var c=jJ();let u;var d=I(c);gr(d),S(c),de(()=>{u=xt(c,1,"checkbox-container svelte-1bigjf0",null,u,{"is-enabled":h(s),"is-disabled":n()}),Ae(c,"aria-checked",h(s)),Ae(c,"aria-label",i()),Ae(c,"tabindex",n()?-1:0),jd(d,h(s))}),De("click",c,a),De("keydown",c,l),$(r,c),Ce()}Tt(["click","keydown"]);var YJ=q("<option> </option>"),KJ=q('<select class="dropdown"></select>');function Jt(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0);var s=KJ();ar(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=YJ(),u=I(c,!0);S(c);var d={};de(()=>{me(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=h(l).value)??"")}),$(a,c)}),S(s),de(()=>{s.disabled=n(),Ae(s,"aria-label",i())}),De("change",s,()=>o()?.(t())),h0(s,t),$(r,s),Ce()}Tt(["change"]);$a();Me();Cr();function Fm(r){return r==="Multi"?"folder":"choice"}function QU(r){return r==="Multi"?"Folder":"Choice"}function Zee(r){return`${QU(r)} name`}async function V_(r,e,t){try{let i=(await Dr.Prompt(r,Zee(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return It(n)||M.logError(Zd(n,"Could not rename")),null}}var Jee=q('<h2 class="choiceNameHeader"><button type="button" class="choiceNameHeaderButton qa-rename-title-button"><span class="choiceNameHeaderText"> </span> <span class="choiceNameHeaderIcon" aria-hidden="true"><!></span></button></h2>');function Ey(r,e){we(e,!0);let t=he(e,"name",15);async function n(){let u=await V_(e.app,t());u&&t(u)}var i=Jee(),o=I(i),s=I(o),a=I(s,!0);S(s);var l=_(s,2),c=I(l);$t(c,{iconId:"pencil",size:16}),S(l),S(o),S(i),de(()=>{Ae(o,"aria-label",`Rename ${t()}`),me(a,t())}),De("click",o,n),$(r,i),Ce()}Tt(["click"]);yl();Mo();var ii=class extends hn{constructor(t,n,i,o=1/0){super(t,n);this.app=t;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.items=i.map(s=>mn(s))}getSuggestions(t){let n=Ec(t).toLowerCase(),i=this.items.filter(s=>s.toLowerCase().includes(n));return i.length===0&&this.close(),i.slice(0,this.maxSuggestions)}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){if(!t)return;let i=hy(t),o=hy(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function ete(r){return r?Array.isArray(r)?r:[r]:[]}function wp(r,e){let t=ete(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var tte=q("<textarea></textarea>"),rte=q('<input type="text"/>'),nte=q('<!> <div aria-live="polite"> </div>',1);function Ei(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"placeholder",3,void 0),i=he(e,"inputKind",3,"text"),o=he(e,"required",3,!1),s=he(e,"requiredMessage",3,"This field is required"),a=he(e,"disabled",3,!1),l=he(e,"validator",3,void 0),c=he(e,"trim",3,!0),u=he(e,"suggestions",3,void 0),d=he(e,"maxSuggestions",3,1/0),f=he(e,"makeSuggesters",19,()=>[]),p=he(e,"app",3,void 0),m=he(e,"id",3,void 0),v=he(e,"ariaLabel",3,void 0),g=he(e,"onChange",3,void 0),y=_e(!1),w=_e(""),k=_e("neutral"),C=0,E=!1,x=`qa-hint-${Math.random().toString(36).slice(2)}`,D=Y=>c()?Y.trim():Y;function P(Y,K=!1,se="neutral"){J(y,K,!0),J(w,Y??"",!0),J(k,K?"neutral":se,!0)}async function H(Y){if(o()&&D(Y).length===0)return P(s(),!0),!1;if(!l())return P(void 0),!0;let K=++C,se=await Promise.resolve(l()(Y));return K!==C||E?!0:typeof se=="boolean"?(P(se?void 0:"Invalid value",!se),se):typeof se=="string"?(P(se,!0),!1):(P(se.message??(se.valid?void 0:"Invalid value"),!se.valid,se.valid?se.variant??"neutral":"neutral"),se.valid)}function U(Y){let K=Y.currentTarget.value;t(K),g()?.(K)}hr(()=>{o();let Y=t();H(Y)}),hr(()=>()=>{E=!0});function oe(Y){let K=[];p()&&u()&&u().length&&K.push(new ii(p(),Y,u(),d()));for(let se of f()){let pe=se(Y);pe&&K.push(pe)}return K}var ce=nte(),O=Pe(ce);{var G=Y=>{var K=tte();Id(K);let se;Mr(K,(pe,ge)=>wp?.(pe,ge),()=>oe),de(()=>{se=xt(K,1,"qa-validated-input-full-width qa-validated-input-margin-8 qa-validated-input-textarea",null,se,{"is-invalid":h(y),"is-valid":!h(y)&&h(k)==="success"&&h(w).length>0}),Ae(K,"id",m()),Ae(K,"placeholder",n()),K.disabled=a(),Ae(K,"aria-label",v()),Ae(K,"aria-invalid",h(y)),Ae(K,"aria-describedby",x),Rs(K,t())}),De("input",K,U),$(Y,K)},V=Y=>{var K=rte();gr(K);let se;Mr(K,(pe,ge)=>wp?.(pe,ge),()=>oe),de(()=>{se=xt(K,1,"qa-validated-input-full-width qa-validated-input-margin-8",null,se,{"is-invalid":h(y),"is-valid":!h(y)&&h(k)==="success"&&h(w).length>0}),Ae(K,"id",m()),Ae(K,"placeholder",n()),K.disabled=a(),Ae(K,"aria-label",v()),Ae(K,"aria-invalid",h(y)),Ae(K,"aria-describedby",x),Rs(K,t())}),De("input",K,U),$(Y,K)};ie(O,Y=>{i()==="textarea"?Y(G):Y(V,-1)})}var F=_(O,2);let Z;var z=I(F,!0);S(F),de(()=>{Z=xt(F,1,"qa-field-hint",null,Z,{"qa-field-hint--neutral":!h(y)&&h(k)==="neutral","qa-field-hint--success":!h(y)&&h(k)==="success"}),Ae(F,"id",x),me(z,h(w))}),$(r,ce),Ce()}Tt(["input"]);var ite=q('<div class="qa-field-body"><!></div>'),ote=q('<div class="qa-field"><!> <!></div>');function as(r,e){let t=$v(),n=he(e,"desc",3,void 0),i=he(e,"control",3,void 0),o=he(e,"bodyVisible",3,!0);var s=ote(),a=I(s);{let u=N(()=>o()?t:void 0);$e(a,{get name(){return e.name},get desc(){return n()},get control(){return i()},get labelFor(){return h(u)}})}var l=_(a,2);{var c=u=>{var d=ite(),f=I(d);Lv(f,()=>e.children,()=>t),S(d),$(u,d)};ie(l,u=>{o()&&u(c)})}S(s),$(r,s)}Vm();Cr();var Vu=class{constructor(){this.entries=[];this.seen=new Set}add(e,t,n){let i=rre(t).trim();if(!i)return;let o=`${e} ${i}`;this.seen.has(o)||(this.seen.add(o),this.entries.push({severity:e,message:i,...n?{kind:n}:{}}))}list(){return this.entries}get hasError(){return this.entries.some(e=>e.severity==="error")}};function rre(r){return r.replace(/^\[(QuickAdd:[\s\S]*)\]$/i,"$1").replace(/^QuickAdd:\s*/i,"")}function Um(r){if(It(r))return null;if(!(r instanceof Error))return Mq;let e=r.message??"";return It(e)?null:e.startsWith("Unable to parse variable")?"This token is incomplete. {{VALUE:}} needs a name, for example {{VALUE:title}}.":e.trim()?e:Mq}var Mq="Preview unavailable - this format could not be resolved.";JT();_t();hh();Dl();var Ele={title:"My Document Title",name:"Document Name",project:"Project Alpha",category:"Notes",author:"Your Name",status:"Draft",priority:"High",tag:"important",type:"meeting",client:"Acme Corp"},Tle={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},_le=[{pattern:/date|time/i,example:"2024-01-15"},{pattern:/title|name/i,example:"Example Title"},{pattern:/tag/i,example:"important"},{pattern:/category|type/i,example:"Notes"},{pattern:/author|user/i,example:"Your Name"},{pattern:/project/i,example:"Project Alpha"},{pattern:/status/i,example:"In Progress"},{pattern:/priority/i,example:"High"},{pattern:/number|count|id/i,example:"001"}];function zA(r){let e=r.toLowerCase(),t=Ele[e];return t||`${r}_example`}function HA(r){return Tle[r.toLowerCase()]||`${r}_output`}function jA(r){for(let{pattern:e,example:t}of _le)if(e.test(r))return t;return`${r}_value`}function GA(r){return r.length>0?`${r[0]} (${r.length} options)`:"suggestion_list"}function gh(r,e){return jp(r).length>0?e:r}function YA(r){let e=r.fieldName.trim();return e?`${e}_field_value`:"field_value"}function KA(r){return r?.path?r.basename:"current_file"}function vh(r){return`${r?.path?r.basename:"current_file"}#Section`}function QA(r){return r?.basename||"current_filename"}function XA(r){if(!r)return"current_folder";let e=r.parent?.path??"";return e==="/"?"":e}var Il=class{static generate(e,t=new Date){let n=t.getFullYear(),i=this.getWeekNumber(t),o=t.getDate(),s=[["YYYY",n.toString()],["YY",n.toString().slice(-2)],["MMMM",this.MONTH_NAMES[t.getMonth()]],["MMM",this.MONTH_NAMES_SHORT[t.getMonth()]],["MM",(t.getMonth()+1).toString().padStart(2,"0")],["M",(t.getMonth()+1).toString()],["dddd",this.DAY_NAMES[t.getDay()]],["ddd",this.DAY_NAMES_SHORT[t.getDay()]],["Do",`${o}${this.ordinalSuffix(o)}`],["DD",t.getDate().toString().padStart(2,"0")],["D",o.toString()],["HH",t.getHours().toString().padStart(2,"0")],["H",t.getHours().toString()],["mm",t.getMinutes().toString().padStart(2,"0")],["m",t.getMinutes().toString()],["ss",t.getSeconds().toString().padStart(2,"0")],["s",t.getSeconds().toString()],["ww",i.toString().padStart(2,"0")],["w",i.toString()]],a="",l=0;for(;l<e.length;){let c=!1;for(let[u,d]of s)if(e.startsWith(u,l)){a+=d,l+=u.length,c=!0;break}c||(a+=e[l],l+=1)}return a}static ordinalSuffix(e){let t=e%100;if(t>=11&&t<=13)return"th";switch(e%10){case 1:return"st";case 2:return"nd";case 3:return"rd";default:return"th"}}static getWeekNumber(e){let t=new Date(e.getFullYear(),0,1),n=(e.getTime()-t.getTime())/864e5;return Math.ceil((n+t.getDay()+1)/7)}};Il.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],Il.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Il.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Il.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];xl();qy();sy();function ZA(r){let e=new Date;return r?dm(window.moment(e),r).toDate():e}cp();Gs();var yh=class extends El{constructor(t,n,i,o={}){super(t);this.plugin=n;this.opts=o;this.diagnostics=new Vu;this.dateParser=i||Sl}warn(t){this.diagnostics.add("warning",t)}reportProblem(t){this.diagnostics.add("error",t)}async format(t){this.diagnostics=new Vu;try{return await this.formatInternal(t,{expandLinebreakEscapes:!0})}catch(n){let i=Um(n);return i&&this.diagnostics.add("error",i),t}}async formatInternal(t,{expandLinebreakEscapes:n}){let i=t;return i=await this.replaceGlobalVarInString(i),n&&(i=this.expandLinebreakEscapesOutsideTokens(i)),i=this.replaceDateInString(i),i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=this.replaceCurrentFileTokensInString(i,{links:!0,fileName:!0,folder:!0,...this.opts.resolveActiveFolder===!1?{}:{activeFolder:"content"}}),i=await this.replaceMacrosInString(i),i=await this.replaceTemplateInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),i=this.replaceRandomInString(i),i}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(gl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}promptForValue(t){return t||"user input"}getVariableValue(t){let n=this.variables.get(t);if(typeof n=="string")return n;let i=Ly(t);return zA(i)}getCurrentFileLink(){return this.app?KA(this.app.workspace.getActiveFile()):null}getCurrentFileLinkToSection(){return this.app?vh(this.app.workspace.getActiveFile()):vh(null)}getCurrentFileName(){return this.app?QA(this.app.workspace.getActiveFile()):"current_filename"}getCurrentFolderPath(){return this.app?XA(this.app.workspace.getActiveFile()):"current_folder"}suggestForValue(t,n=!1,i){return GA(i?.displayValues??t)}getMacroValue(t,n){return HA(t)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(t,n){return Promise.resolve(jA(t))}async getTemplateContent(t){let n=this.app;if(!n)return this.reportProblem(`Template preview unavailable: ${t}`),`[QuickAdd: template preview unavailable] ${t}`;let i=mo(n,t);if(!i)return this.reportProblem(`Template not found: ${t}`),`[QuickAdd: template not found] ${t}`;this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.depth++;try{return await this.formatInternal(await n.vault.cachedRead(i),{expandLinebreakEscapes:!1})}catch(o){let s=Um(o);return s&&this.diagnostics.add("error",s),`[QuickAdd: template preview failed] ${t}`}finally{this.templateInclusion.depth--}}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(t,n){return Promise.resolve(YA(n))}suggestForFile(t){let n=this.app?Hi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,i=>this.app.metadataCache.getFileCache(i)):[];return n.length>0?`${Cl}${n[0].path}`:`${ls}${t.folderPath||"file"}`}async replaceDateVariableInString(t){let n=t;return n=n.replace(new RegExp(bu.source,"gi"),(i,o,s,a)=>{let l=o?.trim(),{options:c,error:u}=cA(a);u&&this.reportProblem(u);let{defaultValue:d,optional:f,withTime:p,snap:m,caseStyle:v}=c,g=s?.trim()||zy(p);if(!l)return i;let y=Hy(this.variables.get(l),g,m,this.dateParser);if(y)return this.applyCaseOption(y.text,v,i);let w;try{w=this.applyCaseOption(Il.generate(g,ZA(m)),v,i)}catch{w=`[${g} format]`}return d&&(w+=` (default: ${d})`),f&&(w+=" (optional)"),w}),n}replaceRandomInString(t){let n=t;return n=n.replace(/{{RANDOM:(\d+)}}/gi,(i,o)=>{let s=parseInt(o);if(s<=0||s>100)return i;let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",l="";for(let c=0;c<Math.min(s,8);c++)l+=a.charAt(Math.floor(Math.random()*a.length));return s>8&&(l+=`... (${s} chars)`),l}),n}isTemplatePropertyTypesEnabled(){return!1}};Vm();qy();var bh=require("obsidian");_t();hh();Dl();JT();xl();cp();Gs();var Qj=25;function Ale(r){let e=r.lastIndexOf("{{");return e===-1?!1:r.indexOf("}}",e+2)===-1}function kle(r){let e=Wy(r);if(e.length===0)return r;let t="",n=0;for(let i of e)t+=r.slice(n,i.start),n=i.end;return t+r.slice(n)}var wh=class extends El{constructor(t,n,i){super(t);this.plugin=n;this.diagnostics=new Vu;this.templateIncludeBudget=Qj;this.dateParser=i||Sl}warn(t){this.diagnostics.add("warning",t)}reportProblem(t){this.diagnostics.add("error",t)}async format(t){let n=t;this.diagnostics=new Vu,this.templateIncludeBudget=Qj;try{n=await this.formatInternal(t,{included:!1})}catch(o){let s=Um(o);return s&&this.diagnostics.add("error",s),t}this.reportCircularTitle(t,n);let i=Yj(n);for(let o of i.problems)this.diagnostics.add("error",o,"path");return this.reportIllegalChars(t,n),i.path}reportCircularTitle(t,n){!Ls.test(t)&&!Ls.test(n)||this.reportProblem("A file name cannot contain {{title}}, because the title is derived from the file name itself - so this choice would fail at run time.")}reportIllegalChars(t,n){if(this.diagnostics.hasError||Ale(t)||Fq(t))return;let i=jp(kle(n));i.length!==0&&(this.existsInVault(n)||this.diagnostics.add("error",zj(i),"path"))}existsInVault(t){let n=this.app?.vault;if(typeof n?.getAbstractFileByPath!="function")return!1;let i=t.trim();return i?i.endsWith("/")?n.getAbstractFileByPath(i.slice(0,-1))instanceof bh.TFolder:n.getAbstractFileByPath(i)instanceof bh.TFile||n.getAbstractFileByPath(`${i}.md`)instanceof bh.TFile?!0:n.getAbstractFileByPath(i)instanceof bh.TFolder:!1}async formatInternal(t,{included:n}){let i=t;return i=await this.replaceTemplateOutsideScripts(i),i=await this.replaceGlobalVarInString(i),i=await this.replaceMacrosInString(i),i=this.replaceDateInString(i),i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),i=this.replaceCurrentFileTokensInString(i,n?{links:!0,fileName:!0,folder:!0,activeFolder:"content"}:{fileName:!0,folder:!0,activeFolder:"path"}),i=this.replaceRandomInString(i),i}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(gl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}promptForValue(t){return gh(t||"user input","user input")}getVariableValue(t){let n=this.variables.get(t);if(typeof n=="string")return n;let i=Ly(t);return gh(zA(i),"user input")}getCurrentFileLink(){return this.app?KA(this.app.workspace.getActiveFile()):null}getCurrentFileName(){return this.app?QA(this.app.workspace.getActiveFile()):"current_filename"}getCurrentFolderPath(){return this.app?XA(this.app.workspace.getActiveFile()):"current_folder"}suggestForValue(t,n=!1,i){return t[0]??GA(t)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(t,n){return gh(HA(t),"macro_output")}async promptForVariable(t,n){return gh(jA(t),"user input")}async replaceTemplateOutsideScripts(t){let n=Wy(t);if(n.length===0)return this.replaceTemplateInString(t);let i="",o=0;for(let s of n)i+=await this.replaceTemplateInString(t.slice(o,s.start)),i+=t.slice(s.start,s.end),o=s.end;return i+await this.replaceTemplateInString(t.slice(o))}async getTemplateContent(t){let n=this.app;if(!n)return this.reportProblem(`Template preview unavailable: ${t}`),`[QuickAdd: template preview unavailable] ${t}`;if(this.templateIncludeBudget<=0){let o="[QuickAdd: too many template includes to preview]";return this.reportProblem(o),o}let i=mo(n,t);if(!i)return this.reportProblem(`Template not found: ${t}`),`[QuickAdd: template not found] ${t}`;this.templateIncludeBudget--,this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.depth++;try{let o=await n.vault.cachedRead(i),s=this.resolveTitleInIncludedBody(await this.formatInternal(o,{included:!0}));return this.warnIfJoinedIntoOneLine(t,s),s}catch(o){let s=Um(o);return s&&this.diagnostics.add("error",s),`[QuickAdd: template preview failed] ${t}`}finally{this.templateInclusion.depth--}}resolveTitleInIncludedBody(t){if(!Ls.test(t))return t;let n=this.variables.get("title"),i=typeof n=="string"?n:"";return t.replace(new RegExp(Ls.source,"gi"),()=>i)}warnIfJoinedIntoOneLine(t,n){let i=n.split(/\r?\n/).filter(o=>o.trim());i.length<2||this.warn(`Template "${t}" is ${i.length} lines; a file name is one line, so they are joined with spaces.`)}getCurrentFileLinkToSection(){return this.app?vh(this.app.workspace.getActiveFile()):vh(null)}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(t,n){return gh(YA(n),"field_value")}suggestForFile(t){let n=this.app?Hi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,i=>this.app.metadataCache.getFileCache(i)):[];return n.length>0?`${Cl}${n[0].path}`:`${ls}${t.folderPath||"file"}`}async replaceDateVariableInString(t){let n=t;return n=n.replace(new RegExp(bu.source,"gi"),(i,o,s,a)=>{let l=o?.trim();if(!l)return i;let{options:c,error:u}=cA(a);u&&this.reportProblem(u);let{withTime:d,snap:f,caseStyle:p}=c,m=s?.trim()||zy(d),v=Hy(this.variables.get(l),m,f,this.dateParser);if(v)return this.applyCaseOption(v.text,p,i);try{return this.applyCaseOption(Il.generate(m,ZA(f)),p,i)}catch{return`[${m}]`}}),n}replaceRandomInString(t){let n=t;return n=n.replace(/{{RANDOM:(\d+)}}/gi,(i,o)=>{let s=parseInt(o);if(s<=0||s>100)return i;let a="ABC123",l="";for(let c=0;c<Math.min(s,6);c++)l+=a.charAt(c%a.length);return s>6&&(l+="..."),l}),n}isTemplatePropertyTypesEnabled(){return!1}};var Sle=q('<div><span class="qa-visually-hidden"> </span> </div>'),Dle=q('<div class="qa-preview-issues"></div>'),Ile=q('<div><span class="qa-preview-label"> </span><span class="qa-preview-value" aria-live="polite"> </span></div> <!>',1);function gs(r,e){we(e,!0);let t=he(e,"formatterKind",3,"format"),n=500,i=_e(""),o=_e(Ct([])),s=_e(!1),a=0,l=N(()=>e.value.trim().length>0),c=N(()=>e.hideWhen?e.hideWhen(h(i))&&!h(o).some(g=>g.severity==="error"&&g.kind!=="path"):!1),u=N(()=>h(s)?h(o).filter(g=>g.severity==="error"):[]),d=N(()=>h(u).some(g=>g.kind!=="path")),f=N(()=>!h(d)&&h(u).length>0);hr(()=>{let g=e.value;if(!g.trim()){a++,J(i,""),J(o,[],!0);return}let y=t()==="fileName"?new wh(e.app,e.plugin):new yh(e.app,e.plugin,void 0,{resolveActiveFolder:t()!=="lineTarget"});y.setTargetFolderPath(e.targetFolderPath===null?null:e.targetFolderPath?.trim()?e.targetFolderPath:"Folder/Name");let w=++a;(async()=>{try{let k=await y.format(g);if(w!==a)return;J(i,k,!0),J(o,y.diagnostics.list(),!0)}catch{if(w!==a)return;J(i,g,!0),J(o,[{severity:"error",message:"Preview unavailable."}],!0)}})()}),hr(()=>{e.value,J(s,!1);let g=setTimeout(()=>{J(s,!0)},n);return()=>clearTimeout(g)});var p=dn(),m=Pe(p);{var v=g=>{var y=Ile(),w=Pe(y);let k;var C=I(w),E=I(C,!0);S(C);var x=_(C),D=I(x,!0);S(x),S(w);var P=_(w,2);{var H=U=>{var oe=Dle();ar(oe,21,()=>h(o),ce=>ce.severity+ce.message,(ce,O)=>{var G=Sle();let V;var F=I(G),Z=I(F,!0);S(F);var z=_(F,1,!0);S(G),de(()=>{V=xt(G,1,"qa-preview-issue",null,V,{"qa-preview-issue--error":h(O).severity==="error"}),Ae(G,"title",h(O).message),me(Z,h(O).severity==="error"?"Error: ":"Warning: "),me(z,h(O).message)}),$(ce,G)}),S(oe),$(U,oe)};ie(P,U=>{h(s)&&h(o).length>0&&U(H)})}de(()=>{k=xt(w,1,"qa-preview-row",null,k,{"qa-preview-row--one-line":t()==="fileName"}),Ae(w,"title",t()==="fileName"?h(i):void 0),me(E,h(d)?"Unresolved: ":h(f)?"Won't be created: ":"Preview: "),me(D,h(i))}),$(g,y)};ie(m,g=>{h(l)&&!h(c)&&g(v)})}$(r,p),Ce()}ka();Me();var sx="https://quickadd.obsidian.guide",Pl={gettingStarted:`${sx}/docs/`,formatSyntax:`${sx}/docs/FormatSyntax/`,onePageInputs:`${sx}/docs/Advanced/onePageInputs/`,userScripts:`${sx}/docs/Choices/MacroChoice/#user-scripts`,packages:`${sx}/docs/Choices/Packages/`};function Xj(r,e){try{(e?op(e):window).open(r,"_blank","noopener,noreferrer")}catch(t){M.logError(`QuickAdd: Failed to open documentation (${r}): ${t}`)}}function JA(r,e,t){let n=xr(r,"a");return n.textContent=t,n.href=e,n.target="_blank",n.rel="noopener noreferrer",n.classList.add("quickadd-docs-link"),r.append(n),n}var Ple=q('<div class="qa-token-hint">Type <code>&#123;&#123;</code> to insert a token &middot; <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Format syntax</a></div>');function Gp(r,e){we(e,!0);let t=N(()=>!e.value.includes("{{"));var n=dn(),i=Pe(n);{var o=s=>{var a=Ple(),l=_(I(a),3);S(a),de(()=>Ae(l,"href",Pl.formatSyntax)),$(s,a)};ie(i,s=>{h(t)&&s(o)})}$(r,n),Ce()}var Zj=require("obsidian");ip();ey();var Fle=q('<input type="text" class="text-input" aria-label="Frontmatter property" placeholder="related" required=""/>'),JR=q("<!> <!>",1),Mle=q("<!> <!> <!> <!>",1);function ax(r,e){we(e,!0);let t=he(e,"appendLink",15),n=he(e,"app",3,void 0),i=N(()=>Tu(t())),o=N(()=>h(i).linkType??"link"),s=N(()=>h(i).displayText),a=N(()=>h(i).frontmatterHandling??rp),l=N(()=>h(i).destination.type==="specifiedFile"?h(i).destination.path:""),c=N(()=>h(i).enabled?h(i).requireActiveFile?"required":"optional":"disabled"),u=N(()=>h(i).destination.type),d=N(()=>n()?n().vault.getMarkdownFiles().map(F=>F.path):[]),f=[{value:"required",label:"Enabled (strict)"},{value:"optional",label:"Enabled (skip if unavailable)"},{value:"disabled",label:"Disabled"}],p=[{value:"activeFile",label:"Current note"},{value:"specifiedFile",label:"Specified note"}],m=[{value:"replaceSelection",label:"Replace selection"},{value:"afterSelection",label:"After selection"},{value:"endOfLine",label:"End of line"},{value:"newLine",label:"New line"},{value:"inFrontmatter",label:"In frontmatter property"}],v=[{value:"link",label:"Link"},{value:"embed",label:"Embed"}],g=[{value:"none",label:"Default"},{value:"selection",label:"Selected text"}],y=[{value:"alwaysAppend",label:"Create or convert"},{value:"createProperty",label:"Create if missing"},{value:"error",label:"Require list"}];function w(F){let Z=t(),z=typeof Z=="boolean"?h(i):Z,Y=F.placement??z.placement,K=F.destination??z.destination??h(i).destination,se=K.type==="activeFile"&&om(Y)?F.linkType??z.linkType??h(o):"link",pe=K.type==="activeFile"&&HT(Y)&&se==="link"?F.displayText??h(s):"none";return{enabled:F.enabled??!0,placement:Y,requireActiveFile:F.requireActiveFile??z.requireActiveFile??h(i).requireActiveFile,linkType:se,displayText:pe,destination:K,frontmatterProperty:F.frontmatterProperty??z.frontmatterProperty,frontmatterHandling:F.frontmatterHandling??z.frontmatterHandling}}function k(F){switch(F){case"disabled":t(w({enabled:!1}));break;case"required":t(w({requireActiveFile:!0}));break;case"optional":t(w({requireActiveFile:!1}));break}}function C(F){t(w({placement:F}))}function E(F){t(w({linkType:F}))}function x(F){t(w({displayText:F}))}function D(F){t(w({frontmatterProperty:F.currentTarget.value}))}function P(F){t(w({frontmatterHandling:F}))}function H(F){let Z=F==="specifiedFile"?{type:"specifiedFile",path:h(l)}:{type:"activeFile"};t(w({destination:Z}))}function U(F){t(w({destination:{type:"specifiedFile",path:F.trim()}}))}function oe(F){let Z=F.trim();if(!Z)return"Destination file is required";if(!n())return!0;let z=n().vault.getAbstractFileByPath(z0(Z));return z instanceof Zj.TFile&&z.extension==="md"?!0:"Markdown file not found"}var ce=JR(),O=Pe(ce);{let F=Y=>{Jt(Y,{get value(){return h(c)},get options(){return f},onchange:k})},Z=N(()=>`Link to ${e.fileLabel} file`),z=N(()=>`Choose whether QuickAdd should insert a link to the ${e.fileLabel} file.`);$e(O,{get name(){return h(Z)},get desc(){return h(z)},control:F,$$slots:{control:!0}})}var G=_(O,2);{var V=F=>{var Z=JR(),z=Pe(Z);{let pe=be=>{Jt(be,{get value(){return h(u)},get options(){return p},onchange:H})},ge=N(()=>`Where QuickAdd writes the link to the ${e.fileLabel} file.`);$e(z,{name:"Link destination",get desc(){return h(ge)},control:pe,$$slots:{control:!0}})}var Y=_(z,2);{var K=pe=>{var ge=Mle(),be=Pe(ge);$e(be,{name:"Link placement",desc:"Where to place the link when appending",control:Te=>{Jt(Te,{get value(){return h(i).placement},get options(){return m},onchange:C})},$$slots:{control:!0}});var Be=_(be,2);{var Se=He=>{$e(He,{name:"Link type",desc:"Choose whether to insert a link or an embed. Embeds transclude the note's contents at the placement position.",control:Ve=>{Jt(Ve,{get value(){return h(o)},get options(){return v},onchange:E})},$$slots:{control:!0}})},ut=N(()=>om(h(i).placement));ie(Be,He=>{h(ut)&&He(Se)})}var Ne=_(Be,2);{var Qe=He=>{$e(He,{name:"Link display text",desc:"What the inserted link displays. 'Selected text' keeps the highlighted text as the link's display text; with nothing selected, the plain link is inserted.",control:Ve=>{Jt(Ve,{get value(){return h(s)},get options(){return g},onchange:x})},$$slots:{control:!0}})},Ze=N(()=>HT(h(i).placement)&&h(o)==="link");ie(Ne,He=>{h(Ze)&&He(Qe)})}var ye=_(Ne,2);{var We=He=>{var Te=JR(),Ve=Pe(Te);$e(Ve,{name:"Frontmatter property",desc:"Required property to insert the link into.",control:yr=>{var Ft=Fle();gr(Ft),de(kr=>{Rs(Ft,h(i).frontmatterProperty??""),Ae(Ft,"aria-invalid",kr)},[()=>!h(i).frontmatterProperty?.trim()]),De("input",Ft,D),$(yr,Ft)},$$slots:{control:!0}});var dt=_(Ve,2);$e(dt,{name:"Property handling",desc:"Choose how strict QuickAdd should be when the property is missing or not a list.",control:yr=>{Jt(yr,{get value(){return h(a)},get options(){return y},onchange:P})},$$slots:{control:!0}}),$(He,Te)},gt=N(()=>np(h(i).placement));ie(ye,He=>{h(gt)&&He(We)})}$(pe,ge)},se=pe=>{$e(pe,{name:"Destination file",desc:"Existing Markdown note that receives the link at the bottom.",control:be=>{Ei(be,{get value(){return h(l)},placeholder:"Index.md",get app(){return n()},get suggestions(){return h(d)},maxSuggestions:50,required:!0,requiredMessage:"Destination file is required",validator:oe,ariaLabel:"Append link destination file",onChange:U})},$$slots:{control:!0}})};ie(Y,pe=>{h(u)==="activeFile"?pe(K):pe(se,-1)})}$(F,Z)};ie(G,F=>{h(c)!=="disabled"&&F(V)})}$(r,ce),Ce()}Tt(["input"]);function lx(r,e){we(e,!0);let t=he(e,"openFile",15);$e(r,{name:"Open",get desc(){return e.description},control:i=>{lr(i,{get checked(){return t()},set checked(o){t(o)}})},$$slots:{control:!0}}),Ce()}var Rle=q("<!> <!> <!> <!>",1);function cx(r,e){we(e,!0);let t=he(e,"fileOpening",15);t(pn(t()));let n=[{value:"reuse",label:"Reuse current tab"},{value:"tab",label:"New tab"},{value:"split",label:"Split pane"},{value:"window",label:"New window"},{value:"left-sidebar",label:"Left sidebar"},{value:"right-sidebar",label:"Right sidebar"}],i=[{value:"vertical",label:"Split right"},{value:"horizontal",label:"Split down"}],o=[{value:"source",label:"Source"},{value:"preview",label:"Preview"},{value:"live",label:"Live Preview"},{value:"default",label:"Default"}],s=N(()=>typeof t().mode=="string"?t().mode:"default");var a=Rle(),l=Pe(a);{let m=g=>{Jt(g,{get value(){return t().location},get options(){return n},onchange:y=>t(t().location=y,!0)})},v=N(()=>`Where to open the ${e.contextLabel} file`);$e(l,{name:"File opening location",get desc(){return h(v)},control:m,$$slots:{control:!0}})}var c=_(l,2);{var u=m=>{$e(m,{name:"Split direction",desc:"How to arrange the new pane relative to the current one",control:g=>{Jt(g,{get value(){return t().direction},get options(){return i},onchange:y=>t(t().direction=y,!0)})},$$slots:{control:!0}})};ie(c,m=>{t().location==="split"&&m(u)})}var d=_(c,2);$e(d,{name:"View mode",desc:"How to display the opened file",control:v=>{Jt(v,{get value(){return h(s)},get options(){return o},onchange:g=>t(t().mode=g,!0)})},$$slots:{control:!0}});var f=_(d,2);{var p=m=>{$e(m,{name:"Focus new pane",desc:"Focus the opened tab immediately after opening",control:g=>{lr(g,{get checked(){return t().focus},set checked(y){t(t().focus=y,!0)}})},$$slots:{control:!0}})};ie(f,m=>{t().location!=="reuse"&&m(p)})}$(r,a),Ce()}function ux(r,e){we(e,!0);let t=he(e,"onePageInput",15),n=[{value:"",label:"Follow global setting"},{value:"always",label:"Always"},{value:"never",label:"Never"}],i=N(()=>t()??"");function o(s){t(s==="always"||s==="never"?s:void 0)}$e(r,{name:"One-page input override",desc:"Override the global setting for this choice. 'Always' forces the one-page modal even if disabled globally; 'Never' disables it even if enabled globally.",control:a=>{Jt(a,{get value(){return h(i)},get options(){return n},onchange:o})},$$slots:{control:!0}}),Ce()}qt();var $le=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),Ole=new Intl.Collator(void 0,{numeric:!0,sensitivity:"variant"});function ek(r){return r.trim().replace(/^\/+/,"").replace(/\/+$/,"")}function Nle(r,e){let t=ek(r),n=ek(e);if(t===n)return 0;let i=t===""?[]:t.split("/"),o=n===""?[]:n.split("/"),s=Math.min(i.length,o.length);for(let a=0;a<s;a++){let l=$le.compare(i[a],o[a]);if(l!==0)return l;let c=Ole.compare(i[a],o[a]);if(c!==0)return c}return i.length-o.length}function Bc(r){return[...r].sort(Nle)}function Lle(r,e){let t=ek(r),n=ek(e);return n?t===n||t.startsWith(`${n}/`):!0}function Jj(r,e){return r.filter(t=>e.some(n=>Lle(t,n)))}var Zu=require("obsidian");var Ble=q('<div class="qa-canvas-node-empty"> </div>'),Vle=q('<div class="qa-canvas-node-empty">No nodes match the current filter.</div>'),Ule=q('<button type="button"> </button>'),qle=q('<button type="button" disabled="">Unavailable</button>'),Wle=q('<div><div class="qa-canvas-node-item-header"><span> </span> <span class="qa-canvas-node-title"> </span></div> <div class="qa-canvas-node-subtitle"> </div> <div class="qa-canvas-node-meta"><code> </code></div> <div class="qa-canvas-node-item-actions"><!> <button type="button">Copy ID</button></div></div>'),zle=q('<div class="qa-canvas-node-picker"><div class="qa-canvas-node-actions"><button type="button">Open target canvas</button> <button type="button">Use selected in open canvas</button> <button type="button">Clear</button></div> <div class="qa-canvas-node-filter"><input type="text" placeholder="Filter by card text, file path, or node id\u2026" aria-label="Filter canvas nodes"/></div> <div class="qa-canvas-node-status"> </div> <div class="qa-canvas-node-list"><!></div></div>');function e$(r,e){we(e,!0);let t=he(e,"nodeId",15),n=_e(Ct([])),i=_e("loading"),o=_e(""),s=_e(""),a=N(()=>{let O=h(s).trim().toLowerCase();return O.length?h(n).filter(G=>G.searchText.includes(O)):h(n)}),l=N(()=>(t()??"").trim()),c=N(()=>h(i)==="ready"?`Showing ${h(a).length} of ${h(n).length} nodes`:h(i)==="empty"?h(o):"Loading canvas nodes\u2026");ST(()=>{(async()=>{let O=L0(e.app,e.canvasTargetPath);if(!O){J(o,"Node picker works for direct .canvas paths that already exist in your vault. Format syntax paths cannot be listed here."),J(i,"empty");return}if(J(n,await UB(e.app,O),!0),h(n).length===0){J(o,"No selectable nodes found in the target canvas."),J(i,"empty");return}J(i,"ready")})()});function u(O){t(O)}function d(){let O=L0(e.app,e.canvasTargetPath);if(!O){new Zu.Notice("Target canvas file was not found.");return}e.app.workspace.getLeaf(!0).openFile(O).catch(()=>new Zu.Notice("Could not open target canvas."))}function f(){let O=VB(e.app,e.canvasTargetPath);if(!O){new Zu.Notice("Open the target canvas and select exactly one card to use this action.");return}let G=h(n).find(V=>V.id===O);if(!G){new Zu.Notice(h(i)==="ready"?"The selected node was not found in the loaded canvas.":"Canvas nodes are still loading. Wait a moment and try again.");return}if(!G.capturable){new Zu.Notice(G.capturableReason);return}u(O)}function p(O){(async()=>{try{await navigator.clipboard.writeText(O),new Zu.Notice(`Copied node id ${O}`)}catch{new Zu.Notice("Could not copy node id automatically.")}})()}function m(O){return O==="text"?"TEXT":O==="file"?"FILE":"NODE"}var v=zle(),g=I(v),y=I(g),w=_(y,2),k=_(w,2);S(g);var C=_(g,2),E=I(C);gr(E),S(C);var x=_(C,2),D=I(x,!0);S(x);var P=_(x,2),H=I(P);{var U=O=>{var G=Ble(),V=I(G,!0);S(G),de(()=>me(V,h(o))),$(O,G)},oe=O=>{var G=Vle();$(O,G)},ce=O=>{var G=dn(),V=Pe(G);ar(V,17,()=>h(a),F=>F.id,(F,Z)=>{let z=N(()=>h(l)===h(Z).id);var Y=Wle();let K;var se=I(Y),pe=I(se),ge=I(pe,!0);S(pe);var be=_(pe,2),Be=I(be,!0);S(be),S(se);var Se=_(se,2),ut=I(Se,!0);S(Se);var Ne=_(Se,2),Qe=I(Ne),Ze=I(Qe,!0);S(Qe),S(Ne);var ye=_(Ne,2),We=I(ye);{var gt=Ve=>{var dt=Ule();let or;var yr=I(dt,!0);S(dt),de(()=>{or=xt(dt,1,"",null,or,{"mod-cta":h(z)}),me(yr,h(z)?"Selected":"Use node")}),De("click",dt,()=>u(h(Z).id)),$(Ve,dt)},He=Ve=>{var dt=qle();de(()=>Ae(dt,"title",h(Z).capturableReason)),$(Ve,dt)};ie(We,Ve=>{h(Z).capturable?Ve(gt):Ve(He,-1)})}var Te=_(We,2);S(ye),S(Y),de(Ve=>{K=xt(Y,1,"qa-canvas-node-item",null,K,{"is-selected":h(z)}),xt(pe,1,`qa-canvas-node-type is-${h(Z).type??""}`),me(ge,Ve),me(Be,h(Z).title),me(ut,h(Z).subtitle),me(Ze,h(Z).id)},[()=>m(h(Z).type)]),De("click",Te,()=>p(h(Z).id)),$(F,Y)}),$(O,G)};ie(H,O=>{h(i)==="empty"?O(U):h(i)==="ready"&&h(a).length===0?O(oe,1):O(ce,-1)})}S(P),S(v),de(()=>me(D,h(c))),De("click",y,d),De("click",w,f),De("click",k,()=>u("")),po(E,()=>h(s),O=>J(s,O)),$(r,v),Ce()}Tt(["click"]);Nu();up();var Hle=new Set(["folder","tag","exclude-folder","exclude-tag","exclude-file"]);function jle(r,e){let t=[r,...e??[]].filter(n=>typeof n=="string").map(n=>n.trim()).filter(Boolean);return t.length>0?t:void 0}function eG(r){let e=Ki.parse(`__capture_scope|${r}`);return{filter:e.filters,multiSelect:e.multiSelect??!1}}function Gle(r){return!!(r.folder||r.folders?.length||r.tags?.length||r.excludeFolders?.length||r.excludeTags?.length||r.excludeFiles?.length)}function Ch(r){let e=r.trim();if(!e)return null;if(e.startsWith("#")){let o=Us(e),s=(o.shift()??"").replace(/^#/,"").replace(/\.md$/i,"").trim();if(!s)return null;let a=o.length>0?eG(o.join("|")):{filter:{},multiSelect:!1};return{filter:{...a.filter,tags:jle(s,a.filter.tags)},multiSelect:a.multiSelect}}let t=Us(e)[0]??"",n=ho(t);if(!n||!Hle.has(n.key))return null;let i=eG(e);return Gle(i.filter)?i:null}Nu();var tG=/^property:/i;function xh(r){let e=r.trim();if(!tG.test(e))return null;let t=e.replace(tG,""),{fieldName:n,filters:i}=Ki.parse(t),o=n.indexOf("="),s=(o>=0?n.slice(0,o):n).trim(),a=o>=0?n.slice(o+1).trim():"",l=a.length>0?a:void 0;return{field:s,value:l,filter:i}}function Yle(r){return r.trim().replace(/^\/+/,"")}function dx(r){return[...new Set((r??[]).map(e=>e.trim()).filter(Boolean))]}function px(r,e="or"){return r.length<=1?r[0]??"":e==="+"?r.join(" + "):r.length===2?`${r[0]} ${e} ${r[1]}`:`${r.slice(0,-1).join(", ")}, ${e} ${r[r.length-1]}`}function rG(r){let e=dx(r.folders??(r.folder?[r.folder]:[])),t=dx(r.tags),n=dx(r.excludeFolders),i=dx(r.excludeTags),o=dx(r.excludeFiles),s=[];return e.length>0&&s.push(`${e.length===1?"folder":"folders"} ${px(e)}`),t.length>0&&s.push(`${t.length===1?"tag":"tags"} ${px(t,"+")}`),n.length>0&&s.push(`excluding ${n.length===1?"folder":"folders"} ${px(n)}`),i.length>0&&s.push(`excluding ${i.length===1?"tag":"tags"} ${px(i,"+")}`),o.length>0&&s.push(`excluding ${o.length===1?"file":"files"} ${px(o)}`),s.length>0?s.join("; "):"all notes"}function fx(r){let e=Yle(r),t=xh(e);if(t){if(!t.field)return{recognized:!0,valid:!1,variant:"error",message:"Property capture target needs a field name, e.g. property:type=draft."};let i=t.value?`frontmatter ${t.field} = ${t.value}`:`frontmatter field ${t.field}`,o=rG(t.filter),s=o==="all notes"?"":`; ${o}`;return{recognized:!0,valid:!0,variant:"success",message:`Recognized property target: ${i}${s}.`}}let n=Ch(e);return n?n.multiSelect?{recognized:!0,valid:!1,variant:"error",message:"Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata."}:{recognized:!0,valid:!0,variant:"success",message:`Recognized filtered picker: ${rG(n.filter)}.`}:null}var Kle=q("<!> <!> <!>",1),Qle=q('<!> <div class="qa-canvas-node-helper">Tip: open this canvas and select one card to grab its id instantly.</div> <!>',1),nG=q("<!> <!>",1);function t$(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>{let g=Bc(Vs(e.app)).filter(k=>k.length>0).map(k=>k.endsWith("/")?k:k+"/"),y=e.app.vault.getMarkdownFiles().map(k=>k.path),w=e.app.vault.getFiles().filter(k=>k.extension==="canvas").map(k=>k.path);return Array.from(new Set([...g,...y,...w]))}),i=[g=>new ji(e.app,g,e.plugin,"captureTarget")],o=N(()=>fx(t().captureTo??"")),s=N(()=>h(o)!==null),a=g=>fx(g)!==null,l=N(()=>!h(s)&&xu(t().captureTo));function c(g){let y=!!t().captureToActiveFile&&t().activeFileWritePosition==="bottom";t(t().captureToActiveFile=g,!0),!g&&y&&t(t().prepend=!0,!0),!g&&t().newLineCapture?.enabled&&t(t().newLineCapture.enabled=!1,!0)}function u(g){let y=im(t().captureTo),w=xu(t().captureTo),k=fx(g)!==null;t(t().captureTo=g,!0);let C=im(g),E=xu(g);(k||!E||w&&E&&y!==C)&&t(t().captureToCanvasNodeId="",!0)}function d(g){let y=fx(g);return y?{valid:y.valid,message:y.message,variant:y.valid?"success":void 0}:g.trim()?!0:{valid:!0,message:"Leave empty to pick the note each time this choice runs."}}var f=nG(),p=Pe(f);$e(p,{name:"Capture to active file",desc:"Capture into whichever note is open when the choice runs, instead of a fixed target.",control:y=>{lr(y,{get checked(){return t().captureToActiveFile},onchange:c})},$$slots:{control:!0}});var m=_(p,2);{var v=g=>{var y=nG(),w=Pe(y);as(w,{name:"Capture to",desc:"Vault-relative path to a file or folder, a #tag, or property:field=value. Supports format syntax like {{DATE}}; end with '/' to capture into a folder.",children:(x,D=Ut)=>{var P=Kle(),H=Pe(P);Ei(H,{get id(){return D()},get value(){return t().captureTo},placeholder:"Daily/{{DATE}}.md",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,get makeSuggesters(){return i},validator:d,onChange:u});var U=_(H,2);Gp(U,{get value(){return t().captureTo}});var oe=_(U,2);{var ce=O=>{gs(O,{get value(){return t().captureTo},formatterKind:"fileName",get app(){return e.app},get plugin(){return e.plugin},hideWhen:a})};ie(oe,O=>{h(s)||O(ce)})}$(x,P)},$$slots:{default:!0}});var k=_(w,2);{var C=E=>{var x=Qle(),D=Pe(x);$e(D,{name:"Target canvas node",desc:"Choose a card from the canvas below, or paste an exact node id.",control:U=>{{let oe=N(()=>t().captureToCanvasNodeId??"");Ei(U,{get value(){return h(oe)},placeholder:"Canvas node id",ariaLabel:"Canvas node id",required:!0,requiredMessage:"A canvas capture target requires a node id \u2014 pick a card below or paste an exact node id.",onChange:ce=>t(t().captureToCanvasNodeId=ce.trim(),!0)})}},$$slots:{control:!0}});var P=_(D,4);u0(P,()=>t().captureTo,H=>{e$(H,{get canvasTargetPath(){return t().captureTo},get app(){return e.app},get nodeId(){return t().captureToCanvasNodeId},set nodeId(U){t(t().captureToCanvasNodeId=U,!0)}})}),$(E,x)};ie(k,E=>{h(l)&&E(C)})}$(g,y)};ie(m,g=>{t().captureToActiveFile||g(v)})}$(r,f),Ce()}var aG=require("obsidian");var sG=require("obsidian");_t();function r$(r){let t=r.match(/\{\{DATE:((?:\[[^\]\n\r]*\]|\[(?![^\]\n\r]*\])|[^}\n\r+|\[]|\|(?!(?:startof|endof):[a-z])(?!(?:case):[a-z-]+\}\}))*)(?:\+-?\d+)?(?:\|(?:startof|endof):[a-z]+)?(?:\|case:[a-z-]+)?\}\}/i)?.[1]?.trim();if(t)return t;let i=r.match(/\{\{VDATE:[^,}]+,([^}\n\r]*)\}\}/i)?.[1]?.split("|")[0]?.trim();if(i)return i}var Xle=q(`<div class="setting-item-description">You'll pick a heading from the target note when you run this capture, and the
text is inserted under it. Use the toggles below to control placement within that
section.</div>`),iG=q("<!> <!>",1),Zle=q(`<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>`),oG=q("<!> <!> <!>",1),Jle=q(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
oldest-first appends it below.</div>`),ece=q(`<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>`),tce=q(`<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),rce=q("<!> <!> <!> <!> <!>",1);function n$(r,e){we(e,!0);let t=he(e,"insertAfter",15);t().inline===void 0&&t(t().inline=!1,!0),t().replaceExisting===void 0&&t(t().replaceExisting=!1,!0),t().promptHeading===void 0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void 0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void 0&&t(t().considerSubsections=!1,!0),t().blankLineAfterMatchMode||t(t().blankLineAfterMatchMode="auto",!0),t().createIfNotFound||t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=fo,!0);let n=[F=>new ji(e.app,F,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=N(()=>t().inline?[{value:fo,label:"Top"},{value:dc,label:"Bottom"},{value:pc,label:"Cursor"}]:[{value:fo,label:"Top"},{value:dc,label:"Bottom"},{value:pc,label:"Cursor"},{value:Aa,label:"Ordered (place new section among siblings)"}]),s=[{value:"insertion",label:"Insertion order (no sorting)"},{value:"lexical",label:"Text (A\u2192Z)"},{value:"numeric",label:"Number"},{value:"date",label:"Date"},{value:"semver",label:"Version (semver)"}],a=[{value:"desc",label:"Newest / highest first"},{value:"asc",label:"Oldest / lowest first"}],l=[{value:"bottom",label:"Sort existing unparseable headings to bottom"},{value:"top",label:"Sort existing unparseable headings to top"}],c=_e(!!t().orderBy),u=N(()=>t().createIfNotFoundLocation===Aa),d=N(()=>t().createIfNotFound&&h(u)),f=N(()=>new yh(e.app,e.plugin)),p=_e(!1);hr(()=>{let F=t().after??"",Z=h(f);if(!t().inline||F===""){J(p,!1);return}let z=!1;return Z.format(F).then(Y=>{z||J(p,/[\n\r]/.test(Y),!0)}).catch(()=>{z||J(p,!1)}),()=>{z=!0}});let m=N(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),v=N(()=>/\{\{V?DATE\b/i.test(t().after??"")),g=N(()=>h(d)&&t().orderBy?.by==="insertion"&&h(v)&&!r$(t().after??""));hr(()=>{if(!h(d))return;let F=r$(t().after??"");if(!t().orderBy){t(t().orderBy={by:F?"date":"insertion",direction:"desc",dateFormat:F,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=F?"date":"insertion",!0),t(t().orderBy.dateFormat=F,!0))});function y(F){t(t().createIfNotFoundLocation=F,!0),F===Aa?t(t().inline=!1,!0):(t(t().orderBy=void 0,!0),J(c,!1))}function w(F){J(c,!0),t().orderBy&&t(t().orderBy.by=F,!0)}function k(F){t().promptHeading||F&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),new sG.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function C(F){F&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var E=rce(),x=Pe(E);$e(x,{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:Z=>{lr(Z,{onchange:C,get checked(){return t().promptHeading},set checked(z){t(t().promptHeading=z,!0)}})},$$slots:{control:!0}});var D=_(x,2);{var P=F=>{var Z=Xle();$(F,Z)},H=F=>{var Z=oG(),z=Pe(Z);as(z,{name:"Insert after",desc:"Insert capture after specified text. Accepts format syntax. Tip: use a heading (starts with #) to target a section. Blank line handling is configurable below.",children:(ge,be=Ut)=>{var Be=iG(),Se=Pe(Be);Ei(Se,{get id(){return be()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return t().after},set value(Ne){t(t().after=Ne,!0)}});var ut=_(Se,2);gs(ut,{get value(){return t().after},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(ge,Be)},$$slots:{default:!0}});var Y=_(z,2);{let pe=be=>{lr(be,{get disabled(){return h(u)},get checked(){return t().inline},set checked(Be){t(t().inline=Be,!0)}})},ge=N(()=>h(u)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");$e(Y,{name:"Inline insertion",get desc(){return h(ge)},control:pe,$$slots:{control:!0}})}var K=_(Y,2);{var se=pe=>{var ge=Zle();$(pe,ge)};ie(K,pe=>{h(p)&&pe(se)})}$(F,Z)};ie(D,F=>{t().promptHeading?F(P):F(H,-1)})}var U=_(D,2);{var oe=F=>{$e(F,{name:"Replace existing value",desc:"Replace everything after the matched text up to end-of-line.",control:z=>{lr(z,{get checked(){return t().replaceExisting},set checked(Y){t(t().replaceExisting=Y,!0)}})},$$slots:{control:!0}})},ce=F=>{var Z=oG(),z=Pe(Z);$e(z,{name:"Insert at end of section",desc:"Place the text at the end of the matched section instead of the top.",control:pe=>{lr(pe,{get checked(){return t().insertAtEnd},set checked(ge){t(t().insertAtEnd=ge,!0)}})},$$slots:{control:!0}});var Y=_(z,2);{let se=ge=>{{let be=N(()=>t().blankLineAfterMatchMode??"auto");Jt(ge,{get value(){return h(be)},get options(){return i},get disabled(){return t().insertAtEnd},onchange:Be=>t(t().blankLineAfterMatchMode=Be,!0)})}},pe=N(()=>t().insertAtEnd?"Not used when inserting at end of section.":"Controls whether Insert After skips existing blank lines after the matched line.");$e(Y,{name:"Blank lines after match",get desc(){return h(pe)},control:se,$$slots:{control:!0}})}var K=_(Y,2);{let se=ge=>{{let be=N(()=>!t().insertAtEnd);lr(ge,{get disabled(){return h(be)},onchange:k,get checked(){return t().considerSubsections},set checked(Be){t(t().considerSubsections=Be,!0)}})}},pe=N(()=>t().insertAtEnd?t().promptHeading?"Also include the chosen heading\u2019s subsections (nested headings inside its section).":"Also include the section\u2019s subsections (requires target to be a heading starting with #). Subsections are headings inside the section.":"Only affects placement when \u201CInsert at end of section\u201D is on.");$e(K,{name:"Consider subsections",get desc(){return h(pe)},control:se,$$slots:{control:!0}})}$(F,Z)};ie(U,F=>{t().inline?F(oe):F(ce,-1)})}var O=_(U,2);$e(O,{name:"Create line if not found",desc:"Creates the 'insert after' line if it is not found.",control:Z=>{var z=iG(),Y=Pe(z);lr(Y,{get checked(){return t().createIfNotFound},set checked(se){t(t().createIfNotFound=se,!0)}});var K=_(Y,2);{let se=N(()=>t().createIfNotFoundLocation||fo);Jt(K,{get value(){return h(se)},get options(){return h(o)},onchange:y})}$(Z,z)},$$slots:{control:!0}});var G=_(O,2);{var V=F=>{var Z=tce(),z=_(Pe(Z),2);$e(z,{name:"Sort sections by",control:Qe=>{Jt(Qe,{get value(){return h(m).by},get options(){return s},onchange:w})},$$slots:{control:!0}});var Y=_(z,2);$e(Y,{name:"Section order",control:Qe=>{Jt(Qe,{get value(){return h(m).direction},get options(){return a},onchange:Ze=>{t().orderBy&&t(t().orderBy.direction=Ze,!0)}})},$$slots:{control:!0}});var K=_(Y,2);{var se=Ne=>{$e(Ne,{name:"Date format",desc:"Moment format used to parse existing heading dates for sorting (e.g. YYYY-MM-DD).",control:Ze=>{{let ye=N(()=>h(m).dateFormat??"");Ei(Ze,{get value(){return h(ye)},placeholder:"YYYY-MM-DD",ariaLabel:"Date format",onChange:We=>{J(c,!0),t().orderBy&&t(t().orderBy.dateFormat=We,!0)}})}},$$slots:{control:!0}})};ie(K,Ne=>{h(m).by==="date"&&Ne(se)})}var pe=_(K,2);{var ge=Ne=>{$e(Ne,{name:"Existing unparseable headings",desc:"Where to rank EXISTING headings whose text can't be parsed for this sort. (A new heading that can't be parsed is appended at the end.)",control:Ze=>{{let ye=N(()=>h(m).unparseable??"bottom");Jt(Ze,{get value(){return h(ye)},get options(){return l},onchange:We=>{t().orderBy&&t(t().orderBy.unparseable=We,!0)}})}},$$slots:{control:!0}})};ie(pe,Ne=>{(h(m).by==="date"||h(m).by==="numeric"||h(m).by==="semver")&&Ne(ge)})}var be=_(pe,2);{var Be=Ne=>{var Qe=Jle();$(Ne,Qe)};ie(be,Ne=>{h(m).by==="insertion"&&Ne(Be)})}var Se=_(be,2);{var ut=Ne=>{var Qe=ece();$(Ne,Qe)};ie(Se,Ne=>{h(g)&&Ne(ut)})}$(F,Z)};ie(G,F=>{h(d)&&t().orderBy&&F(V)})}$(r,E),Ce()}_t();var i$=q("<!> <!>",1);function o$(r,e){we(e,!0);let t=he(e,"insertBefore",15);t().createIfNotFound===void 0&&t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=fo,!0);let n=[l=>new ji(e.app,l,e.plugin,"lineTarget")],i=[{value:fo,label:"Top"},{value:dc,label:"Bottom"},{value:pc,label:"Cursor"}];var o=i$(),s=Pe(o);as(s,{name:"Insert before",desc:"Insert capture before specified text. Accepts format syntax.",children:(c,u=Ut)=>{var d=i$(),f=Pe(d);Ei(f,{get id(){return u()},placeholder:"Insert before",required:!0,requiredMessage:"Insert before text is required",get makeSuggesters(){return n},get value(){return t().before},set value(m){t(t().before=m,!0)}});var p=_(f,2);gs(p,{get value(){return t().before},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(c,d)},$$slots:{default:!0}});var a=_(s,2);$e(a,{name:"Create line if not found",desc:"Creates the 'insert before' line if it is not found.",control:c=>{var u=i$(),d=Pe(u);lr(d,{get checked(){return t().createIfNotFound},set checked(p){t(t().createIfNotFound=p,!0)}});var f=_(d,2);{let p=N(()=>t().createIfNotFoundLocation||fo);Jt(f,{get value(){return h(p)},get options(){return i},onchange:m=>t(t().createIfNotFoundLocation=m,!0)})}$(c,u)},$$slots:{control:!0}}),$(r,o),Ce()}var nce=q(`<div class="setting-item-description">Canvas note: 'At cursor' and 'New line above/below cursor' are not supported
for Canvas card capture. Use top, bottom, insert-after, or insert-before
placement.</div>`),ice=q("<!> <!> <!> <!>",1);function s$(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>!!t().captureToActiveFile),i=N(()=>t().insertAfter?.enabled?"after":t().insertBefore?.enabled?"before":t().newLineCapture?.enabled?t().newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":h(n)?t().activeFileWritePosition==="top"?"activeTop":t().activeFileWritePosition==="bottom"||t().prepend?"bottom":"top":t().prepend?"bottom":"top"),o=N(()=>[{value:"top",label:h(n)?"At cursor":"Top of file"},...h(n)?[{value:"activeTop",label:"Top of file (after frontmatter)"},{value:"newLineAbove",label:"New line above cursor"},{value:"newLineBelow",label:"New line below cursor"}]:[],{value:"after",label:"After line\u2026"},{value:"before",label:"Before line\u2026"},{value:"bottom",label:"Bottom of file"}]);function s(g){if(t(t().prepend=!1,!0),t(t().insertAfter.enabled=!1,!0),t(t().insertAfter.promptHeading=!1,!0),t(t().insertAfter.inline=!1,!0),t(t().insertAfter.replaceExisting=!1,!0),t().insertBefore||t(t().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),t(t().insertBefore.enabled=!1,!0),t().newLineCapture||t(t().newLineCapture={enabled:!1,direction:"below"},!0),t(t().newLineCapture.enabled=!1,!0),t(t().activeFileWritePosition="cursor",!0),g==="top"){h(n)||t(t().prepend=!1,!0);return}if(g==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(g==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(g==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(g==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(g==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=N(()=>{let g=typeof t().captureTo=="string"&&xu(t().captureTo),y=e.app.workspace.getActiveViewOfType(aG.FileView)?.getViewType()==="canvas",w=h(n)&&!t().insertAfter.enabled&&!t().insertBefore?.enabled&&!t().newLineCapture?.enabled&&(t().activeFileWritePosition??"cursor")==="cursor"&&!t().prepend;return!(!(t().newLineCapture?.enabled||w)||(h(n)?!y:!g))});var l=ice(),c=Pe(l);{let g=w=>{Jt(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},y=N(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");$e(c,{name:"Write position",get desc(){return h(y)},control:g,$$slots:{control:!0}})}var u=_(c,2);{var d=g=>{n$(g,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(y){t(t().insertAfter=y,!0)}})};ie(u,g=>{t().insertAfter.enabled&&g(d)})}var f=_(u,2);{var p=g=>{o$(g,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(y){t(t().insertBefore=y,!0)}})};ie(f,g=>{t().insertBefore?.enabled&&g(p)})}var m=_(f,2);{var v=g=>{var y=nce();$(g,y)};ie(m,g=>{h(a)&&g(v)})}$(r,l),Ce()}var oce=new Set(["activity","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","aperture","archive","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-right","arrow-left","arrow-right-circle","arrow-right","arrow-up-circle","arrow-up-left","arrow-up-right","arrow-up","asterisk","at-sign","award","axe","banknote","bar-chart-2","bar-chart","baseline","battery-charging","battery-full","battery-low","battery-medium","battery","beaker","bell-minus","bell-off","bell-plus","bell-ring","bell","bike","binary","bitcoin","bluetooth-connected","bluetooth-off","bluetooth-searching","bluetooth","bold","book-open","book","bookmark-minus","bookmark-plus","bookmark","bot","box-select","box","briefcase","brush","bug","building-2","building","bus","calculator","calendar","camera-off","camera","car","carrot","cast","check-circle-2","check-circle","check-square","check","chevron-down","chevron-first","chevron-last","chevron-left","chevron-right","chevron-up","chevrons-down-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up-down","chevrons-up","chrome","circle-slashed","circle","clipboard-check","clipboard-copy","clipboard-list","clipboard-x","clipboard","clock-1","clock-10","clock-11","clock-12","clock-2","clock-3","clock-4","clock-5","clock-6","clock-7","clock-8","clock-9","clock","cloud-drizzle","cloud-fog","cloud-hail","cloud-lightning","cloud-moon","cloud-off","cloud-rain-wind","cloud-rain","cloud-snow","cloud-sun","cloud","cloudy","clover","code-2","code","codepen","codesandbox","coffee","coins","columns","command","compass","contact","contrast","cookie","copy","copyleft","copyright","corner-down-left","corner-down-right","corner-left-down","corner-left-up","corner-right-down","corner-right-up","corner-up-left","corner-up-right","cpu","credit-card","crop","cross","crosshair","crown","currency","database","delete","dice-1","dice-2","dice-3","dice-4","dice-5","dice-6","disc","divide-circle","divide-square","divide","dollar-sign","download-cloud","download","dribbble","droplet","droplets","drumstick","edit-2","edit-3","edit","egg","equal-not","equal","eraser","euro","expand","external-link","eye-off","eye","facebook","fast-forward","feather","figma","file-check-2","file-check","file-code","file-digit","file-input","file-minus-2","file-minus","file-output","file-plus-2","file-plus","file-search","file-text","file-x-2","file-x","file","files","film","filter","flag-off","flag-triangle-left","flag-triangle-right","flag","flame","flashlight-off","flashlight","flask-conical","flask-round","folder-minus","folder-open","folder-plus","folder","form-input","forward","frame","framer","frown","function-square","gamepad-2","gamepad","gauge","gavel","gem","ghost","gift","git-branch-plus","git-branch","git-commit","git-fork","git-merge","git-pull-request","github","gitlab","glasses","globe-2","globe","grab","graduation-cap","grid","grip-horizontal","grip-vertical","hammer","hand-metal","hand","hard-drive","hard-hat","hash","haze","headphones","heart","help-circle","hexagon","highlighter","history","home","image-minus","image-off","image-plus","image","import","inbox","indent","indian-rupee","infinity","info","inspect","instagram","italic","japanese-yen","key","keyboard","landmark","languages","laptop-2","laptop","lasso-select","lasso","layers","layout-dashboard","layout-grid","layout-list","layout-template","layout","library","life-buoy","lightbulb-off","lightbulb","link-2-off","link-2","link","linkedin","list-checks","list-minus","list-ordered","list-plus","list-x","list","loader-2","loader","locate-fixed","locate-off","locate","lock","log-in","log-out","mail","map-pin","map","maximize-2","maximize","megaphone","meh","menu","message-circle","message-square","mic-off","mic","minimize-2","minimize","minus-circle","minus-square","minus","monitor-off","monitor-speaker","monitor","moon","more-horizontal","more-vertical","mountain-snow","mountain","mouse-pointer-2","mouse-pointer-click","mouse-pointer","mouse","move-diagonal-2","move-diagonal","move-horizontal","move-vertical","move","music","navigation-2","navigation","network","octagon","option","outdent","package-check","package-minus","package-plus","package-search","package-x","package","palette","palmtree","paperclip","pause-circle","pause-octagon","pause","pen-tool","pencil","percent","person-standing","phone-call","phone-forwarded","phone-incoming","phone-missed","phone-off","phone-outgoing","phone","pie-chart","piggy-bank","pin","pipette","plane","play-circle","play","plug-zap","plus-circle","plus-square","plus","pocket","podcast","pointer","pound-sterling","power-off","power","printer","qr-code","quote","radio-receiver","radio","redo","refresh-ccw","refresh-cw","regex","repeat-1","repeat","reply-all","reply","rewind","rocket","rocking-chair","rotate-ccw","rotate-cw","rss","ruler","russian-ruble","save","scale","scan-line","scan","scissors","screen-share-off","screen-share","search","send","separator-horizontal","separator-vertical","server-crash","server-off","server","settings-2","settings","share-2","share","sheet","shield-alert","shield-check","shield-close","shield-off","shield","shirt","shopping-bag","shopping-cart","shovel","shrink","shuffle","sidebar-close","sidebar-open","sidebar","sigma","signal-high","signal-low","signal-medium","signal-zero","signal","skip-back","skip-forward","skull","slack","slash","sliders","smartphone-charging","smartphone","smile","snowflake","sort-asc","sort-desc","speaker","sprout","square","star-half","star","stop-circle","stretch-horizontal","stretch-vertical","strikethrough","subscript","sun","sunrise","sunset","superscript","swiss-franc","switch-camera","table","tablet","tag","target","tent","terminal-square","terminal","text-cursor-input","text-cursor","thermometer-snowflake","thermometer-sun","thermometer","thumbs-down","thumbs-up","ticket","timer-off","timer-reset","timer","toggle-left","toggle-right","tornado","trash-2","trash","trello","trending-down","trending-up","triangle","truck","tv-2","tv","twitch","twitter","type","umbrella","underline","undo","unlink-2","unlink","unlock","upload-cloud","upload","user-check","user-minus","user-plus","user-x","user","users","verified","vibrate","video-off","video","view","voicemail","volume-1","volume-2","volume-x","volume","wallet","wand","watch","waves","webcam","wifi-off","wifi","wind","wrap-text","wrench","x-circle","x-octagon","x-square","x","youtube","zap-off","zap","zoom-in","zoom-out","search-large","lucide-clock","lucide-cloud","lucide-cross","lucide-folder","lucide-info","lucide-languages","lucide-link","lucide-pencil","lucide-pin","lucide-search","lucide-star","lucide-trash"]),tk=Array.from(oce);Wt();var sce=q('<div class="qa-choice-icon-setting-control svelte-p1gcdx"><span class="qa-choice-icon-setting-preview svelte-p1gcdx" aria-hidden="true"><!></span> <input type="text" class="qa-choice-icon-input svelte-p1gcdx" aria-label="Choice icon"/></div>'),ace={hash:"svelte-p1gcdx",code:".qa-choice-icon-setting-control.svelte-p1gcdx {display:flex;align-items:center;gap:8px;min-width:min(18rem, 100%);}.qa-choice-icon-setting-preview.svelte-p1gcdx {display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--text-muted);}.qa-choice-icon-input.svelte-p1gcdx {width:100%;min-width:0;}"};function mx(r,e){we(e,!0),ot(r,ace);let t=he(e,"icon",15),n=N(()=>xm(e.type)),i=N(()=>typeof t()=="string"?t():""),o=N(()=>h(i).trim()||h(n));function s(l){return new ii(e.app,l,tk,50)}function a(l){let c=l.currentTarget.value.trim();t(c||void 0)}{let l=u=>{var d=sce(),f=I(d),p=I(f);$t(p,{get iconId(){return h(o)},size:18}),S(f);var m=_(f,2);gr(m),Mr(m,(v,g)=>wp?.(v,g),()=>s),S(d),de(()=>{Rs(m,h(i)),Ae(m,"placeholder",h(n))}),De("input",m,a),$(u,d)},c=N(()=>`Lucide/Obsidian icon id. Leave empty to use ${h(n)}.`);$e(r,{name:"Icon",get desc(){return h(c)},control:l,$$slots:{control:!0}})}Ce()}Tt(["input"]);var lG=q("<!> <!>",1),lce=q("<!> <!> <!>",1),cce=q("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function a$(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>e.plugin.getTemplateFiles().map(V=>V.path)),i=[V=>new ji(e.app,V,e.plugin)];function o(V){let F=V.trim();return F?ku(F)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:mo(e.app,F)!==null||"Template not found":!0}let s=[{value:"",label:"Follow global setting"},{value:"enabled",label:"Use selection"},{value:"disabled",label:"Ignore selection"}],a=N(()=>typeof t().useSelectionAsCaptureValue=="boolean"?t().useSelectionAsCaptureValue?"enabled":"disabled":"");function l(V){if(V===""){t(t().useSelectionAsCaptureValue=void 0,!0);return}t(t().useSelectionAsCaptureValue=V==="enabled",!0)}function c(V){t().templater||t(t().templater={},!0),t(t().templater.afterCapture=V?"wholeFile":"none",!0)}var u=cce(),d=Pe(u);Ey(d,{get app(){return e.app},get name(){return t().name},set name(V){t(t().name=V,!0)}});var f=_(d,2);$e(f,{name:"Location",heading:!0});var p=_(f,2);t$(p,{get app(){return e.app},get plugin(){return e.plugin},get choice(){return t()},set choice(V){t(V)}});var m=_(p,2);{var v=V=>{var F=lG(),Z=Pe(F);$e(Z,{name:"Create file if it doesn't exist",control:se=>{lr(se,{get checked(){return t().createFileIfItDoesntExist.enabled},set checked(pe){t(t().createFileIfItDoesntExist.enabled=pe,!0)}})},$$slots:{control:!0}});var z=_(Z,2);{var Y=K=>{as(K,{name:"Create file with a template",desc:"Path to the template QuickAdd applies to the new file.",get bodyVisible(){return t().createFileIfItDoesntExist.createWithTemplate},control:ge=>{lr(ge,{get checked(){return t().createFileIfItDoesntExist.createWithTemplate},set checked(be){t(t().createFileIfItDoesntExist.createWithTemplate=be,!0)}})},children:(ge,be=Ut)=>{Ei(ge,{get id(){return be()},get value(){return t().createFileIfItDoesntExist.template},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:Be=>t(t().createFileIfItDoesntExist.template=Be.trim(),!0)})},$$slots:{control:!0,default:!0}})};ie(z,K=>{t().createFileIfItDoesntExist.enabled&&K(Y)})}$(V,F)};ie(m,V=>{t().captureToActiveFile||V(v)})}var g=_(m,2);$e(g,{name:"Position",heading:!0});var y=_(g,2);s$(y,{get app(){return e.app},get plugin(){return e.plugin},get choice(){return t()},set choice(V){t(V)}});var w=_(y,2);$e(w,{name:"Linking",heading:!0});var k=_(w,2);ax(k,{fileLabel:"captured",get app(){return e.app},get appendLink(){return t().appendLink},set appendLink(V){t(t().appendLink=V,!0)}});var C=_(k,2);$e(C,{name:"Copy link to clipboard",desc:"Copy a link to the captured file after the Capture choice runs.",control:F=>{{let Z=N(()=>t().copyLinkToClipboard??!1);lr(F,{get checked(){return h(Z)},onchange:z=>t(t().copyLinkToClipboard=z,!0)})}},$$slots:{control:!0}});var E=_(C,2);$e(E,{name:"Content",heading:!0});var x=_(E,2);$e(x,{name:"Task",desc:"Formats the value as a task.",control:F=>{lr(F,{get checked(){return t().task},set checked(Z){t(t().task=Z,!0)}})},$$slots:{control:!0}});var D=_(x,2);as(D,{name:"Capture format",desc:"Set the format of the capture. When off, QuickAdd captures {{VALUE}} on its own - what you type at the prompt, or the current selection.",get bodyVisible(){return t().format.enabled},control:Z=>{lr(Z,{get checked(){return t().format.enabled},set checked(z){t(t().format.enabled=z,!0)}})},children:(Z,z=Ut)=>{var Y=lce(),K=Pe(Y);Ei(K,{get id(){return z()},inputKind:"textarea",placeholder:"Format",required:!0,requiredMessage:"Capture format is required when enabled",get makeSuggesters(){return i},get value(){return t().format.format},set value(ge){t(t().format.format=ge,!0)}});var se=_(K,2);Gp(se,{get value(){return t().format.format}});var pe=_(se,2);gs(pe,{get value(){return t().format.format},get app(){return e.app},get plugin(){return e.plugin}}),$(Z,Y)},$$slots:{control:!0,default:!0}});var P=_(D,2);$e(P,{name:"Behavior",heading:!0});var H=_(P,2);{var U=V=>{var F=lG(),Z=Pe(F);lx(Z,{description:"Open the captured file.",get openFile(){return t().openFile},set openFile(K){t(t().openFile=K,!0)}});var z=_(Z,2);{var Y=K=>{cx(K,{contextLabel:"captured",get fileOpening(){return t().fileOpening},set fileOpening(se){t(t().fileOpening=se,!0)}})};ie(z,K=>{t().openFile&&K(Y)})}$(V,F)};ie(H,V=>{t().captureToActiveFile||V(U)})}var oe=_(H,2);$e(oe,{name:"Use editor selection as default value",desc:"Controls whether this Capture uses the current editor selection as {{VALUE}}. Does not affect {{SELECTED}}.",control:F=>{Jt(F,{get value(){return h(a)},get options(){return s},onchange:l})},$$slots:{control:!0}});var ce=_(oe,2);$e(ce,{name:"Run Templater on entire destination file after capture",desc:"Advanced / legacy: this executes any <% %> anywhere in the destination file (including inside code blocks).",control:F=>{{let Z=N(()=>t().templater?.afterCapture==="wholeFile");lr(F,{get checked(){return h(Z)},onchange:c})}},$$slots:{control:!0}});var O=_(ce,2);ux(O,{get onePageInput(){return t().onePageInput},set onePageInput(V){t(t().onePageInput=V,!0)}});var G=_(O,2);mx(G,{get type(){return t().type},get app(){return e.app},get icon(){return t().icon},set icon(V){t(t().icon=V,!0)}}),$(r,u),Ce()}function cG(r){return Ct({...r,choice:ha(r.choice)})}var uG=require("obsidian");function Eh(r){return ha(r)}function rk(r,e){if(r.containerEl.addClass("qa-choice-builder"),r.modalEl.querySelector(".qa-builder-footer"))return;let t=r.modalEl.ownerDocument,n=t.createElement("div");n.className="qa-builder-footer";let i=t.createElement("span");i.className="qa-builder-footer-note",i.textContent=`Changes to this ${e} are saved automatically`,n.appendChild(i);let o=t.createElement("button");o.type="button",o.className="mod-cta",o.textContent="Done",o.addEventListener("click",()=>r.close()),n.appendChild(o),r.modalEl.appendChild(n)}var Th=class extends uG.Modal{constructor(t){super(t);this.svelteElements=[];this.waitForClose=new Promise(n=>{this.resolvePromise=n}),this.containerEl.addClass("quickAddModal"),rk(this,"choice"),this.open()}destroySvelteElements(){this.svelteElements.forEach(t=>t.destroy()),this.svelteElements=[]}getResultChoice(){return this.choice}onClose(){super.onClose(),this.destroySvelteElements(),this.resolvePromise(Eh(this.getResultChoice()))}};var _h=class extends Th{constructor(t,n,i){super(t);this.plugin=i;this.choice=n,this.normalizeChoice(),this.display()}normalizeChoice(){this.choice.insertBefore||(this.choice.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:fo}),this.choice.activeFileWritePosition||(this.choice.activeFileWritePosition="cursor"),this.choice.createFileIfItDoesntExist||(this.choice.createFileIfItDoesntExist={enabled:!1,createWithTemplate:!1,template:""}),!this.choice.captureToActiveFile&&!xu(this.choice.captureTo)&&(this.choice.captureToCanvasNodeId=""),this.choice.openFile&&(this.choice.fileOpening=pn(this.choice.fileOpening))}display(){this.containerEl.addClass("captureChoiceBuilder"),this.formProps=cG({choice:this.choice,app:this.app,plugin:this.plugin});let t=Wi(this.contentEl,a$,this.formProps,{what:"this capture choice's settings"});t.ok||(this.formProps=void 0),this.svelteElements.push(t)}getResultChoice(){return this.formProps?.choice??this.choice}};_t();var pG=[{id:"prompt",label:"Ask every time"},{id:"update",label:"Update existing file"},{id:"create",label:"Create another file"},{id:"keep",label:"Keep existing file"}],l$=[{id:"appendBottom",category:"update",label:"Append to bottom",description:"Adds the template content to the end of the existing file.",requiresExistingFile:!0,resolutionKind:"modifyExisting"},{id:"appendTop",category:"update",label:"Append to top",description:"Adds the template content to the beginning of the existing file.",requiresExistingFile:!0,resolutionKind:"modifyExisting"},{id:"overwrite",category:"update",label:"Overwrite file",description:"Replaces the existing file content with the template.",requiresExistingFile:!0,resolutionKind:"modifyExisting"},{id:"increment",category:"create",label:"Increment trailing number",description:"Changes trailing digits only. Example: Draft009.md -> Draft010.md.",requiresExistingFile:!1,resolutionKind:"createNew"},{id:"duplicateSuffix",category:"create",label:"Append duplicate suffix",description:"Keeps the original name and adds a duplicate marker. Example: Project Plan.md -> Project Plan (1).md.",requiresExistingFile:!1,resolutionKind:"createNew"},{id:"doNothing",category:"keep",label:"Do nothing",description:"Leaves the file unchanged and opens the existing file.",requiresExistingFile:!0,resolutionKind:"reuseExisting"}],uce=new Map(l$.map(r=>[r.id,r])),dce={update:"appendBottom",create:"duplicateSuffix",keep:"doNothing"},dG={"Append to the bottom of the file":"appendBottom","Append to the top of the file":"appendTop","Overwrite the file":"overwrite","Increment the file name":"increment","Append duplicate suffix":"duplicateSuffix",Nothing:"doNothing",appendBottom:"appendBottom",appendTop:"appendTop",overwrite:"overwrite",increment:"increment",duplicateSuffix:"duplicateSuffix",doNothing:"doNothing"},pce={increment:fce,duplicateSuffix:mce};function Ah(r){let e=uce.get(r);if(!e)throw new Error(`Unknown file exists mode: ${r}`);return e}function fG(r){return l$.filter(e=>e.category===r)}function mG(r){return Ah(r).category}function hG(){return[...l$]}function gG(r){return r.kind==="prompt"?"prompt":mG(r.mode)}function vG(r,e){return r==="prompt"?{kind:"prompt"}:e?.kind==="apply"&&mG(e.mode)===r?e:{kind:"apply",mode:dce[r]}}function yG(r){return typeof r!="string"||!Object.prototype.hasOwnProperty.call(dG,r)?null:dG[r]??null}async function bG(r,e,t){return await pce[e](r,t)}async function fce(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=wG(t),o=n.match(/^(.*?)(\d+)$/);t=`${o?`${o[1]}${String(BigInt(o[2])+1n).padStart(o[2].length,"0")}`:`${n}1`}${i}`}return t}async function mce(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=wG(t),o=n.match(/^(.*) \((\d+)\)$/);t=`${o?`${o[1]} (${String(BigInt(o[2])+1n)})`:`${n} (1)`}${i}`}return t}function wG(r){return zr.test(r)?{basename:r.replace(zr,""),extension:".canvas"}:qi.test(r)?{basename:r.replace(qi,""),extension:".base"}:{basename:r.replace(ir,""),extension:".md"}}Me();qt();yl();var nk=class extends hn{constructor(t,n,i,o){super(t,n);this.app=t;this.inputEl=n;this.suggestItems=i;this.currentItems=o}updateCurrentItems(t){this.currentItems=t}getSuggestions(t){return this.suggestItems.filter(n=>n.contains(t))}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){t&&n.setText(t)}};function ik(r){let e=t=>t.stopPropagation();return r.addEventListener("mousedown",e),r.addEventListener("touchstart",e,{passive:!0}),{destroy(){r.removeEventListener("mousedown",e),r.removeEventListener("touchstart",e)}}}var hce=q('<button type="button"><!></button>');function er(r,e){let t=he(e,"size",3,16),n=he(e,"extraClass",3,""),i=he(e,"disabled",3,!1);var o=hce();let s;var a=I(o);$t(a,{get iconId(){return e.iconId},get size(){return t()}}),S(o),Mr(o,l=>ik?.(l)),de(()=>{s=xt(o,1,`qa-icon-button ${n()}`,null,s,{"is-pressed":e.ariaPressed===!0}),Ae(o,"aria-label",e.label),Ae(o,"aria-pressed",e.ariaPressed),Ae(o,"aria-haspopup",e.ariaHasPopup),Ae(o,"title",e.title),o.disabled=i()}),De("click",o,function(...l){e.onclick?.apply(this,l)}),$(r,o)}Tt(["click"]);var gce=q('<div class="quickAddCommandListItem svelte-ee11ws"><span> </span> <!></div>'),vce=q('<div class="quickAddFolderListGrid quickAddCommandList svelte-ee11ws"></div>'),yce={hash:"svelte-ee11ws",code:`.quickAddCommandListItem.svelte-ee11ws {display:flex;align-items:center;justify-content:space-between;}
@media (min-width: 768px) {.quickAddFolderListGrid.svelte-ee11ws {display:grid;grid-template-columns:repeat(2, 1fr);column-gap:20px;}
}.quickAddCommandList.svelte-ee11ws {max-width:50%;margin:12px auto;}`};function c$(r,e){we(e,!0),ot(r,yce);var t=vce();ar(t,20,()=>e.folders,n=>n,(n,i)=>{var o=gce(),s=I(o),a=I(s,!0);S(s);var l=_(s,2);{let c=N(()=>`Remove folder ${i}`);er(l,{iconId:"trash-2",get label(){return h(c)},onclick:()=>e.deleteFolder(i)})}S(o),de(()=>me(a,i)),$(n,o)}),S(t),$(r,t),Ce()}function CG(r){return r.enabled?r.chooseWhenCreatingNote?"prompt":r.createInSameFolderAsActiveFile?"active-file":"specified":"obsidian-default"}function xG(r,e){switch(e){case"obsidian-default":return{...r,enabled:!1,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"specified":return{...r,enabled:!0,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"active-file":return{...r,enabled:!0,createInSameFolderAsActiveFile:!0,chooseWhenCreatingNote:!1};case"prompt":return{...r,enabled:!0,chooseWhenCreatingNote:!0,createInSameFolderAsActiveFile:!1}}}var EG=[{value:"obsidian-default",label:"Obsidian default"},{value:"specified",label:"In a specific folder"},{value:"active-file",label:"Same folder as current file"},{value:"prompt",label:"Ask for folder each time"}],TG={"obsidian-default":"Use Obsidian's \u201CDefault location for new notes\u201D setting.",specified:"Create the note in the folder(s) below. With multiple folders, you'll be asked which one when the note is created.","active-file":"Create the note next to the currently active file (falls back to the vault root if no file is open).",prompt:"Choose any folder in the vault when the note is created."};_t();_t();function ok(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Os.toLowerCase()||t===lB.toLowerCase()}function u$(r,e){return r.discoverExistingNotesBeforeCreate===!0&&ok(r,e)}function d$(r,e,t){return!(!u$(r,e)||t!=null)}_t();function sk(r){if(!r?.enabled||r.chooseWhenCreatingNote||r.chooseFromSubfolders||r.createInSameFolderAsActiveFile)return;let e=r.folders??[];if(e.length!==1)return;let t=e[0]?.trim();if(t&&!t.includes("{{")&&!mc.test(t))return t}var bce=q("<!> <!> <!>",1),wce=q(`<div class="qa-folder-mode-warning">Add at least one folder. With none, the note falls back to the active
file's folder (or you'll be prompted to pick one if no file is open).</div>`),Cce=q('<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),xce=q("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function p$(r,e){we(e,!0);let t=he(e,"choice",15),n=N(()=>e.plugin.getTemplateFiles().map(ye=>ye.path)),i=N(()=>Bc(Vs(e.app)));function o(ye){let We=ye.trim();return We?ku(We)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:mo(e.app,We)!==null||"Template not found":!0}let s=[ye=>new ji(e.app,ye,e.plugin,"fileName")],a=N(()=>ok(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Os)),l=N(()=>h(a)?"For the default note-title prompt, show matching notes first. Choosing one opens it unchanged; choosing the create row continues with this template.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=N(()=>CG(t().folder)),u=N(()=>TG[h(c)]),d=N(()=>h(c)==="specified"&&t().folder.folders.length===0);function f(ye){t(t().folder=xG(t().folder,ye),!0)}let p=_e(""),m;function v(ye){return m=new nk(e.app,ye,h(i),t().folder.folders),m}hr(()=>{m?.updateCurrentItems(t().folder.folders)});function g(){let ye=h(p).trim();if(ye){if(t().folder.folders.some(We=>We===ye)){M.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ye),J(p,"")}}function y(ye){t(t().folder.folders=t().folder.folders.filter(We=>We!==ye),!0)}function w(ye){ye.key==="Enter"&&g()}let k=N(()=>gG(t().fileExistsBehavior)),C=N(()=>h(k)!=="prompt"&&h(k)!=="keep"),E=N(()=>fG(h(k)==="update"?"update":"create")),x=N(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(E)[0].id);function D(ye){t(t().fileExistsBehavior=vG(ye,t().fileExistsBehavior),!0)}function P(ye){t(t().fileExistsBehavior={kind:"apply",mode:ye},!0)}var H=xce(),U=Pe(H);Ey(U,{get app(){return e.app},get name(){return t().name},set name(ye){t(t().name=ye,!0)}});var oe=_(U,2);$e(oe,{name:"Template",heading:!0});var ce=_(oe,2);as(ce,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(We,gt=Ut)=>{Ei(We,{get id(){return gt()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:He=>t(t().templatePath=He.trim(),!0)})},$$slots:{default:!0}});var O=_(ce,2);as(O,{name:"File name format",desc:"Set the file name format. When off, QuickAdd asks for the note title.",get bodyVisible(){return t().fileNameFormat.enabled},control:gt=>{lr(gt,{get checked(){return t().fileNameFormat.enabled},set checked(He){t(t().fileNameFormat.enabled=He,!0)}})},children:(gt,He=Ut)=>{var Te=bce(),Ve=Pe(Te);Ei(Ve,{get id(){return He()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(yr){t(t().fileNameFormat.format=yr,!0)}});var dt=_(Ve,2);Gp(dt,{get value(){return t().fileNameFormat.format}});var or=_(dt,2);{let yr=N(()=>sk(t().folder));gs(or,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(yr)},get app(){return e.app},get plugin(){return e.plugin}})}$(gt,Te)},$$slots:{control:!0,default:!0}});var G=_(O,2);$e(G,{name:"Location",heading:!0});var V=_(G,2);$e(V,{name:"New note location",get desc(){return h(u)},control:We=>{Jt(We,{get value(){return h(c)},get options(){return EG},ariaLabel:"New note location",onchange:f})},$$slots:{control:!0}});var F=_(V,2);{var Z=ye=>{var We=Cce(),gt=Pe(We),He=I(gt),Te=I(He);c$(Te,{get folders(){return t().folder.folders},deleteFolder:y}),S(He);var Ve=_(He,2),dt=I(Ve);gr(dt),un(()=>po(dt,()=>h(p),ur=>J(p,ur))),Mr(dt,(ur,pt)=>wp?.(ur,pt),()=>v);var or=_(dt,2);S(Ve),S(gt);var yr=_(gt,2);{var Ft=ur=>{var pt=wce();$(ur,pt)};ie(yr,ur=>{h(d)&&ur(Ft)})}var kr=_(yr,2);$e(kr,{name:"Include subfolders",desc:"Get prompted to choose from both the selected folders and their subfolders when creating the note.",control:pt=>{lr(pt,{get checked(){return t().folder.chooseFromSubfolders},set checked(Mt){t(t().folder.chooseFromSubfolders=Mt,!0)}})},$$slots:{control:!0}}),lc("keypress",dt,w),De("click",or,g),$(ye,We)};ie(F,ye=>{h(c)==="specified"&&ye(Z)})}var z=_(F,2);$e(z,{name:"Linking",heading:!0});var Y=_(z,2);ax(Y,{fileLabel:"created",get app(){return e.app},get appendLink(){return t().appendLink},set appendLink(ye){t(t().appendLink=ye,!0)}});var K=_(Y,2);$e(K,{name:"Copy link to clipboard",desc:"Copy a link to the created file after the Template choice runs.",control:We=>{{let gt=N(()=>t().copyLinkToClipboard??!1);lr(We,{get checked(){return h(gt)},onchange:He=>t(t().copyLinkToClipboard=He,!0)})}},$$slots:{control:!0}});var se=_(K,2);$e(se,{name:"Behavior",heading:!0});var pe=_(se,2);$e(pe,{name:"Search existing notes before creating",get desc(){return h(l)},control:We=>{{let gt=N(()=>h(a)?t().discoverExistingNotesBeforeCreate??!1:!1),He=N(()=>!h(a));lr(We,{get checked(){return h(gt)},get disabled(){return h(He)},onchange:Te=>t(t().discoverExistingNotesBeforeCreate=Te,!0)})}},$$slots:{control:!0}});var ge=_(pe,2);$e(ge,{name:"If the target file already exists",desc:"Choose whether QuickAdd should ask what to do, update the existing file, create another file, or keep the existing file.",control:We=>{{let gt=N(()=>pG.map(He=>({value:He.id,label:He.label})));Jt(We,{get value(){return h(k)},get options(){return h(gt)},onchange:D})}},$$slots:{control:!0}});var be=_(ge,2);{var Be=ye=>{{let We=Te=>{{let Ve=N(()=>h(E).map(dt=>({value:dt.id,label:dt.label})));Jt(Te,{get value(){return h(x)},get options(){return h(Ve)},onchange:P})}},gt=N(()=>h(k)==="update"?"Update action":"New file naming"),He=N(()=>Ah(h(x)).description);$e(ye,{get name(){return h(gt)},get desc(){return h(He)},control:We,$$slots:{control:!0}})}};ie(be,ye=>{h(C)&&ye(Be)})}var Se=_(be,2);lx(Se,{description:"Open the created file.",get openFile(){return t().openFile},set openFile(ye){t(t().openFile=ye,!0)}});var ut=_(Se,2);{var Ne=ye=>{cx(ye,{contextLabel:"created",get fileOpening(){return t().fileOpening},set fileOpening(We){t(t().fileOpening=We,!0)}})};ie(ut,ye=>{t().openFile&&ye(Ne)})}var Qe=_(ut,2);ux(Qe,{get onePageInput(){return t().onePageInput},set onePageInput(ye){t(t().onePageInput=ye,!0)}});var Ze=_(Qe,2);mx(Ze,{get type(){return t().type},get app(){return e.app},get icon(){return t().icon},set icon(ye){t(t().icon=ye,!0)}}),$(r,H),Ce()}Tt(["click"]);function _G(r){return Ct({...r,choice:ha(r.choice)})}var kh=class extends Th{constructor(t,n,i){super(t);this.plugin=i;this.choice=n,this.normalizeChoice(),this.display()}normalizeChoice(){var t,n,i,o,s,a,l,c,u,d,f;(t=this.choice).fileExistsBehavior??(t.fileExistsBehavior={kind:"prompt"}),this.choice.fileOpening=pn(this.choice.fileOpening),(n=this.choice).templatePath??(n.templatePath=""),(i=this.choice).fileNameFormat??(i.fileNameFormat={enabled:!1,format:""}),(o=this.choice.fileNameFormat).enabled??(o.enabled=!1),(s=this.choice.fileNameFormat).format??(s.format=""),(a=this.choice).folder??(a.folder={enabled:!1,folders:[],chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1,chooseFromSubfolders:!1}),(l=this.choice.folder).enabled??(l.enabled=!1),(c=this.choice.folder).folders??(c.folders=[]),(u=this.choice.folder).chooseWhenCreatingNote??(u.chooseWhenCreatingNote=!1),(d=this.choice.folder).createInSameFolderAsActiveFile??(d.createInSameFolderAsActiveFile=!1),(f=this.choice.folder).chooseFromSubfolders??(f.chooseFromSubfolders=!1)}display(){this.containerEl.addClass("templateChoiceBuilder"),this.formProps=_G({choice:this.choice,app:this.app,plugin:this.plugin});let t=Wi(this.contentEl,p$,this.formProps,{what:"this template choice's settings"});t.ok||(this.formProps=void 0),this.svelteElements.push(t)}getResultChoice(){return this.formProps?.choice??this.choice}};Yp();var nS=require("obsidian");$a();var Mi=require("obsidian");var PY=require("obsidian");function kG(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function Cx(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?kG(Object(t),!0).forEach(function(n){Mh(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):kG(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Sh(r){"@babel/helpers - typeof";return Sh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Sh(r)}function Mh(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Tce(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,o;for(o=0;o<n.length;o++)i=n[o],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function _ce(r,e){if(r==null)return{};var t=Tce(r,e),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(i=0;i<o.length;i++)n=o[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function Ace(r,e){return Sce(r)||Ice(r,e)||T$(r,e)||Fce()}function ta(r){return kce(r)||Dce(r)||T$(r)||Pce()}function kce(r){if(Array.isArray(r))return h$(r)}function Sce(r){if(Array.isArray(r))return r}function Dce(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Ice(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n=[],i=!0,o=!1,s,a;try{for(t=t.call(r);!(i=(s=t.next()).done)&&(n.push(s.value),!(e&&n.length===e));i=!0);}catch(l){o=!0,a=l}finally{try{!i&&t.return!=null&&t.return()}finally{if(o)throw a}}return n}}function T$(r,e){if(r){if(typeof r=="string")return h$(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return h$(r,e)}}function h$(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Pce(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Fce(){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 Xp(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=T$(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){t=t.call(r)},n:function(){var l=t.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&t.return!=null&&t.return()}finally{if(s)throw a}}}}var Mce="finalize",Rce="consider";function Rh(r,e,t){r.dispatchEvent(new CustomEvent(Mce,{detail:{items:e,info:t}}))}function rd(r,e,t){r.dispatchEvent(new CustomEvent(Rce,{detail:{items:e,info:t}}))}var vk="draggedEntered",Ex="draggedLeft",yk="draggedOverIndex",_$="draggedLeftDocument",uk={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function $ce(r,e,t){r.dispatchEvent(new CustomEvent(vk,{detail:{indexObj:e,draggedEl:t}}))}function Oce(r,e,t){r.dispatchEvent(new CustomEvent(Ex,{detail:{draggedEl:e,type:uk.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function Nce(r,e){r.dispatchEvent(new CustomEvent(Ex,{detail:{draggedEl:e,type:uk.OUTSIDE_OF_ANY}}))}function Lce(r,e,t){r.dispatchEvent(new CustomEvent(yk,{detail:{indexObj:e,draggedEl:t}}))}function Bce(r){window.dispatchEvent(new CustomEvent(_$,{detail:{draggedEl:r}}))}var ki={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:vk,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:yk,DRAGGED_LEFT:Ex,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Ji={POINTER:"pointer",KEYBOARD:"keyboard"},Vce={space:[" "],enter:["Enter"],space_or_enter:[" ","Enter"]},BG="space_or_enter",Uce={space:"space-bar",enter:"enter",space_or_enter:"space-bar or enter"},Nh="isDndShadowItem",bk="data-is-dnd-shadow-item-internal",qce="data-is-dnd-shadow-item-hint",Tx="id:dnd-shadow-placeholder-0000",Wce="dnd-action-dragged-el",Br="id",g$=0;function VG(){g$++}function UG(){if(g$===0)throw new Error("Bug! trying to decrement when there are no dropzones");g$--}var A$=typeof window>"u",ht=function(){};function v$(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t,n=e?jce(r):r.getBoundingClientRect(),i=getComputedStyle(r),o=i.transform;if(o){var s,a,l,c;if(o.startsWith("matrix3d("))t=o.slice(9,-1).split(/, /),s=+t[0],a=+t[5],l=+t[12],c=+t[13];else if(o.startsWith("matrix("))t=o.slice(7,-1).split(/, /),s=+t[0],a=+t[3],l=+t[4],c=+t[5];else return n;var u=i.transformOrigin,d=n.x-l-(1-s)*parseFloat(u),f=n.y-c-(1-a)*parseFloat(u.slice(u.indexOf(" ")+1)),p=s?n.width/s:r.offsetWidth,m=a?n.height/a:r.offsetHeight;return{x:d,y:f,width:p,height:m,top:f,right:d+p,bottom:f+m,left:d}}else return n}function y$(r){var e=v$(r);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function qG(r){var e=r.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function WG(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function zce(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}function bx(r,e){return r.y<=e.bottom&&r.y>=e.top&&r.x>=e.left&&r.x<=e.right}function zG(r){return WG(qG(r))}function SG(r,e){var t=zG(e);return zce(r,t)}function Hce(r){var e=qG(r);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}function jce(r){for(var e=r.getBoundingClientRect(),t={top:e.top,bottom:e.bottom,left:e.left,right:e.right},n=!1,i=!1,o=r.parentElement;o&&o!==document.body;){var s=window.getComputedStyle(o),a=s.overflowY,l=s.overflowX,c=a==="scroll"||a==="auto",u=l==="scroll"||l==="auto";if(c||u){var d=o.getBoundingClientRect();if(c){var f=Math.max(t.top,d.top),p=Math.min(t.bottom,d.bottom);(f!==t.top||p!==t.bottom)&&(n=!0),t.top=f,t.bottom=p}if(u){var m=Math.max(t.left,d.left),v=Math.min(t.right,d.right);(m!==t.left||v!==t.right)&&(i=!0),t.left=m,t.right=v}}o=o.parentElement}return n||i?{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:Math.max(0,t.bottom-t.top)}:{top:e.top,bottom:e.bottom,left:e.left,right:e.right,width:Math.max(0,e.right-e.left),height:Math.max(0,e.bottom-e.top)}}var Ih;function k$(){ht(function(){return"resetting indexes cache"}),Ih=new Map}k$();function Gce(r){var e=Array.from(r.children).findIndex(function(t){return t.getAttribute(bk)});if(e>=0)return Ih.has(r)||Ih.set(r,new Map),Ih.get(r).set(e,y$(r.children[e])),e}function Yce(r,e){var t=y$(e);if(!bx(r,t))return null;var n=e.children;if(n.length===0)return{index:0,isProximityBased:!0};for(var i=Gce(e),o=0;o<n.length;o++){var s=y$(n[o]);if(bx(r,s)){var a=Ih.has(e)&&Ih.get(e).get(o);return a&&!bx(r,a)?{index:i,isProximityBased:!1}:{index:o,isProximityBased:!1}}}for(var l=Number.MAX_VALUE,c=void 0,u=0;u<n.length;u++){var d=SG(r,n[u]);d<l&&(l=d,c=u)}if(n.length>0){var f=n.length,p=n[f-1],m=p.cloneNode(!1);m.style.visibility="hidden",m.style.pointerEvents="none",e.appendChild(m);var v=SG(r,m);v<l&&(c=f),e.removeChild(m)}return{index:c,isProximityBased:!0}}function Va(r){return JSON.stringify(r,null,2)}function dk(r){if(!r)throw new Error("cannot get depth of a falsy node");return HG(r,0)}function HG(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return r.parentElement?HG(r.parentElement,e+1):e-1}function Kce(r,e){if(Object.keys(r).length!==Object.keys(e).length)return!1;for(var t in r)if(!{}.hasOwnProperty.call(e,t)||e[t]!==r[t])return!1;return!0}function Qce(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}var Xce=200,DG=10,b$;function Zce(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Xce,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o,s,a=!1,l,c=Array.from(e).sort(function(d,f){return dk(f)-dk(d)});function u(){var d=i(),f=n.multiScrollIfNeeded();if(!f&&l&&Math.abs(l.x-d.x)<DG&&Math.abs(l.y-d.y)<DG){b$=window.setTimeout(u,t);return}if(Hce(r)){ht(function(){return"off document"}),Bce(r);return}l=d;var p=!1,m=Xp(c),v;try{for(m.s();!(v=m.n()).done;){var g=v.value;f&&k$();var y=Yce(d,g);if(y!==null){var w=y.index;p=!0,g!==o?(o&&Oce(o,r,g),$ce(g,y,r),o=g):w!==s&&(Lce(g,y,r),s=w);break}}}catch(k){m.e(k)}finally{m.f()}!p&&a&&o?(Nce(o,r),o=void 0,s=void 0,a=!1):a=!0,b$=window.setTimeout(u,t)}u()}function Jce(){ht(function(){return"unobserving"}),clearTimeout(b$),k$()}var gx=30;function eue(){var r;function e(){r={directionObj:void 0,stepPx:0}}e();function t(o){var s=r,a=s.directionObj,l=s.stepPx;a&&(o.scrollBy(a.x*l,a.y*l),window.requestAnimationFrame(function(){return t(o)}))}function n(o){return gx-o}function i(o,s){if(!s)return!1;var a=tue(o,s),l=!!r.directionObj;if(a===null)return l&&e(),!1;var c=!1,u=!1;return s.scrollHeight>s.clientHeight&&(a.bottom<gx?(c=!0,r.directionObj={x:0,y:1},r.stepPx=n(a.bottom)):a.top<gx&&(c=!0,r.directionObj={x:0,y:-1},r.stepPx=n(a.top)),!l&&c)||s.scrollWidth>s.clientWidth&&(a.right<gx?(u=!0,r.directionObj={x:1,y:0},r.stepPx=n(a.right)):a.left<gx&&(u=!0,r.directionObj={x:-1,y:0},r.stepPx=n(a.left)),!l&&u)?(t(s),!0):(e(),!1)}return{scrollIfNeeded:i,resetScrolling:e}}function tue(r,e){var t=e===document.scrollingElement?{top:0,bottom:window.innerHeight,left:0,right:window.innerWidth}:e.getBoundingClientRect();return bx(r,t)?{top:r.y-t.top,bottom:t.bottom-r.y,left:r.x-t.left,right:t.right-r.x}:null}function rue(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;ht(function(){return"creating multi-scroller"});var t=iue(r),n=Array.from(t).sort(function(l,c){return dk(c)-dk(l)}),i=eue(),o=i.scrollIfNeeded,s=i.resetScrolling;function a(){var l=e();if(!l||!n)return!1;for(var c=n.filter(function(f){return bx(l,f.getBoundingClientRect())||f===document.scrollingElement}),u=0;u<c.length;u++){var d=o(l,c[u]);if(d)return!0}return!1}return{multiScrollIfNeeded:t.size>0?a:function(){return!1},destroy:function(){return s()}}}function nue(r){if(!r)return[];for(var e=[],t=r;t;){var n=window.getComputedStyle(t),i=n.overflow;i.split(" ").some(function(o){return o.includes("auto")||o.includes("scroll")})&&e.push(t),t=t.parentElement}return e}function iue(r){var e=new Set,t=Xp(r),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;nue(i).forEach(function(o){return e.add(o)})}}catch(o){t.e(o)}finally{t.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&e.add(document.scrollingElement),e}function oue(r){var e=r.cloneNode(!0),t=[],n=r.tagName==="SELECT",i=n?[r]:ta(r.querySelectorAll("select")),o=Xp(i),s;try{for(o.s();!(s=o.n()).done;){var a=s.value;t.push(a.value)}}catch(k){o.e(k)}finally{o.f()}if(i.length>0)for(var l=n?[e]:ta(e.querySelectorAll("select")),c=0;c<l.length;c++){var u=l[c],d=t[c],f=u.querySelector('option[value="'.concat(d,'"'));f&&f.setAttribute("selected",!0)}var p=r.tagName==="CANVAS",m=p?[r]:ta(r.querySelectorAll("canvas"));if(m.length>0)for(var v=p?[e]:ta(e.querySelectorAll("canvas")),g=0;g<v.length;g++){var y=m[g],w=v[g];w.width=y.width,w.height=y.height,y.width>0&&y.height>0&&w.getContext("2d").drawImage(y,0,0)}return e}var xx=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),sue=Mh({},xx.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function jG(r){if(!xx[r])throw new Error("Can't get non existing feature flag ".concat(r,"! Supported flags: ").concat(Object.keys(xx)));return sue[r]}var aue=.2;function Kp(r){return"".concat(r," ").concat(aue,"s ease")}function GG(r){var e=r.style.transitionProperty.split(",").map(function(t){return t.trim()});e.includes("all")||(e.includes("width")||(r.style.transition+=", ".concat(Kp("width"))),e.includes("height")||(r.style.transition+=", ".concat(Kp("height"))))}function lue(r,e){var t=r.getBoundingClientRect(),n=oue(r);YG(r,n),n.id=Wce,n.style.position="fixed";var i=t.top,o=t.left;if(n.style.top="".concat(i,"px"),n.style.left="".concat(o,"px"),e){var s=WG(t);i-=s.y-e.y,o-=s.x-e.x,window.setTimeout(function(){n.style.top="".concat(i,"px"),n.style.left="".concat(o,"px")},0)}return n.style.margin="0",n.style.boxSizing="border-box",n.style.height="".concat(t.height,"px"),n.style.width="".concat(t.width,"px"),n.style.transition="".concat(Kp("top"),", ").concat(Kp("left"),", ").concat(Kp("background-color"),", ").concat(Kp("opacity"),", ").concat(Kp("color")," "),window.setTimeout(function(){return GG(n)},0),n.style.zIndex="9999",n.style.cursor="grabbing",n}function cue(r){r.style.cursor="grab"}function uue(r,e,t,n){GG(r),YG(e,r);var i=e.getBoundingClientRect(),o=r.getBoundingClientRect(),s=window.getComputedStyle(r),a=parseFloat(s.left),l=parseFloat(s.top),c=i.width-o.width,u=i.height-o.height;if(c||u){var d={left:o.width?(t-o.left)/o.width:0,top:o.height?(n-o.top)/o.height:0};jG(xx.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)||(r.style.height="".concat(i.height,"px"),r.style.width="".concat(i.width,"px")),r.style.left="".concat(a-d.left*c,"px"),r.style.top="".concat(l-d.top*u,"px")}}function YG(r,e){var t=window.getComputedStyle(r);Array.from(t).filter(function(n){return n.startsWith("background")||n.startsWith("padding")||n.startsWith("font")||n.startsWith("text")||n.startsWith("align")||n.startsWith("justify")||n.startsWith("display")||n.startsWith("flex")||n.startsWith("border")||n==="opacity"||n==="color"||n==="list-style-type"||jG(xx.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)&&(n==="width"||n==="height")}).forEach(function(n){return e.style.setProperty(n,t.getPropertyValue(n),t.getPropertyPriority(n))})}function due(r,e){r.draggable=!1,r.ondragstart=function(){return!1},e?(r.style.userSelect="",r.style.WebkitUserSelect="",r.style.cursor=""):(r.style.userSelect="none",r.style.WebkitUserSelect="none",r.style.cursor="grab")}function KG(r){r.style.display="none",r.style.position="fixed",r.style.zIndex="-5"}function pue(r){r.style.visibility="hidden",r.setAttribute(bk,"true")}function fue(r){r.style.visibility="",r.removeAttribute(bk)}function ck(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};r.forEach(function(n){var i=e(n);Object.keys(i).forEach(function(o){n.style[o]=i[o]}),t(n).forEach(function(o){return n.classList.add(o)})})}function pk(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};r.forEach(function(n){var i=e(n);Object.keys(i).forEach(function(o){n.style[o]=""}),t(n).forEach(function(o){return n.classList.contains(o)&&n.classList.remove(o)})})}function mue(r){var e=r.style.minHeight;r.style.minHeight=window.getComputedStyle(r).getPropertyValue("height");var t=r.style.minWidth;return r.style.minWidth=window.getComputedStyle(r).getPropertyValue("width"),function(){r.style.minHeight=e,r.style.minWidth=t}}var hue="--any--",gue=100,vue=20,ak=3,yue=80,IG={outline:"rgba(255, 255, 102, 0.7) solid 2px"},PG="data-is-dnd-original-dragged-item",Ai,xn,Vo,S$,Nr,wk,td,ui,Ml,ci,Vc=!1,fk=!1,D$,_x=!1,Dh=[],wx,Rl,yx=!1,I$=!1,Fl,Ju=new Set,Uc=new Map,an=new Map,vx=new WeakMap;function bue(r,e){ht(function(){return"registering drop-zone if absent"}),Uc.has(e)||Uc.set(e,new Set),Uc.get(e).has(r)||(Uc.get(e).add(r),VG())}function FG(r,e){var t=Uc.get(e);!t||!t.delete(r)||(UG(),t.size===0&&Uc.delete(e))}function wue(){ht(function(){return"watching dragged element"});var r=Uc.get(S$);if(!(!r||r.size===0)){Ju.size>0&&w$(),Ju=new Set(r);var e=Xp(Ju),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.addEventListener(vk,QG),n.addEventListener(Ex,XG),n.addEventListener(yk,ZG)}}catch(a){e.e(a)}finally{e.f()}window.addEventListener(_$,$h);var i=Math.max.apply(Math,ta(Array.from(Ju).map(function(a){return an.get(a).dropAnimationDurationMs}))),o=i===0?vue:Math.max(i,gue);wx=rue(Ju,function(){return ci});var s=I$?function(){return{x:ci.x+window.scrollX,y:ci.y+window.scrollY}}:function(){return zG(xn)};Zce(xn,Ju,o*1.07,wx,s)}}function w$(){ht(function(){return"unwatching dragged element"});var r=Xp(Ju),e;try{for(r.s();!(e=r.n()).done;){var t=e.value;t.removeEventListener(vk,QG),t.removeEventListener(Ex,XG),t.removeEventListener(yk,ZG)}}catch(n){r.e(n)}finally{r.f()}Ju=new Set,window.removeEventListener(_$,$h),wx&&(wx.destroy(),wx=void 0),Jce()}function Ck(r){return r.findIndex(function(e){return!!e[Nh]})}function Cue(r){var e;return Cx(Cx({},r),{},(e={},Mh(e,Nh,!0),Mh(e,Br,Tx),e))}function QG(r){ht(function(){return["dragged entered",r.currentTarget,r.detail]});var e=an.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Nr){ht(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(_x=!1,t=t.filter(function(a){return a[Br]!==td[Br]&&a[Br]!==Tx}),ht(function(){return"dragged entered items ".concat(Va(t))}),Nr!==r.currentTarget){var i=an.get(Nr).items,o=i.filter(function(a){return!a[Nh]});rd(Nr,o,{trigger:ki.DRAGGED_ENTERED_ANOTHER,id:Vo[Br],source:Ji.POINTER})}var s=r.detail.indexObj.index;ui=r.currentTarget,t.splice(s,0,td),rd(r.currentTarget,t,{trigger:ki.DRAGGED_ENTERED,id:Vo[Br],source:Ji.POINTER})}function XG(r){if(Vc){ht(function(){return["dragged left",r.currentTarget,r.detail]});var e=an.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Nr&&r.currentTarget!==ui){ht(function(){return"drop is currently disabled"});return}var i=ta(t),o=Ck(i);o!==-1&&i.splice(o,1);var s=ui;ui=void 0;var a=r.detail,l=a.type,c=a.theOtherDz;if(l===uk.OUTSIDE_OF_ANY||l===uk.LEFT_FOR_ANOTHER&&c!==Nr&&an.get(c).dropFromOthersDisabled){ht(function(){return"dragged left all, putting shadow element back in the origin dz"}),_x=!0,ui=Nr;var u=s===Nr?i:ta(an.get(Nr).items);u.splice(wk,0,td),rd(Nr,u,{trigger:ki.DRAGGED_LEFT_ALL,id:Vo[Br],source:Ji.POINTER})}rd(r.currentTarget,i,{trigger:ki.DRAGGED_LEFT,id:Vo[Br],source:Ji.POINTER})}}function ZG(r){ht(function(){return["dragged is over index",r.currentTarget,r.detail]});var e=an.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Nr){ht(function(){return"drop is currently disabled"});return}var i=ta(t);_x=!1;var o=r.detail.indexObj.index,s=Ck(i);s!==-1&&i.splice(s,1),i.splice(o,0,td),rd(r.currentTarget,i,{trigger:ki.DRAGGED_OVER_INDEX,id:Vo[Br],source:Ji.POINTER})}function mk(r){r.preventDefault();var e=r.touches?r.touches[0]:r;ci={x:e.clientX,y:e.clientY},xn.style.transform="translate3d(".concat(ci.x-Ml.x,"px, ").concat(ci.y-Ml.y,"px, 0)")}function $h(){ht(function(){return"dropped"}),fk=!0,window.removeEventListener("mousemove",mk),window.removeEventListener("touchmove",mk),window.removeEventListener("mouseup",$h),window.removeEventListener("touchend",$h),w$(),cue(xn),ui||(ht(function(){return"element was dropped right after it left origin but before entering somewhere else"}),ui=Nr),ht(function(){return["dropped in dz",ui]});var r=an.get(ui),e=r.items,t=r.type;pk(Uc.get(t),function(o){return an.get(o).dropTargetStyle},function(o){return an.get(o).dropTargetClasses});var n=Ck(e);n===-1&&ui===Nr&&(n=wk),e=e.map(function(o){return o[Nh]?Vo:o});function i(){w$(),D$(),Rh(ui,e,{trigger:_x?ki.DROPPED_OUTSIDE_OF_ANY:ki.DROPPED_INTO_ZONE,id:Vo[Br],source:Ji.POINTER}),ui!==Nr&&Rh(Nr,an.get(Nr).items,{trigger:ki.DROPPED_INTO_ANOTHER,id:Vo[Br],source:Ji.POINTER});var o=Array.from(ui.children).find(function(s){return s.getAttribute(bk)});o&&fue(o),Tue()}an.get(ui).dropAnimationDisabled?i():xue(n,i)}function xue(r,e){var t=r>-1?v$(ui.children[r],!1):v$(ui,!1),n={x:t.left-parseFloat(xn.style.left),y:t.top-parseFloat(xn.style.top)},i=an.get(ui),o=i.dropAnimationDurationMs,s="transform ".concat(o,"ms ease");xn.style.transition=xn.style.transition?xn.style.transition+","+s:s,xn.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0)"),window.setTimeout(e,o)}function Eue(r,e){var t={dz:r,destroy:e};Dh.push(t),window.requestAnimationFrame(function(){Dh.includes(t)&&(KG(r),document.body.appendChild(r))})}function Tue(){xn&&xn.remove&&xn.remove(),Ai&&Ai.remove&&Ai.remove(),xn=void 0,Ai=void 0,Vo=void 0,S$=void 0,Nr=void 0,wk=void 0,td=void 0,ui=void 0,Ml=void 0,ci=void 0,Vc=!1,fk=!1,D$=void 0,_x=!1,Rl&&clearTimeout(Rl),Rl=void 0,yx=!1,I$=!1,Fl=void 0,Dh.length&&(ht(function(){return["will destroy zones that were removed during drag",Dh]}),Dh.forEach(function(r){var e=r.dz,t=r.destroy;t(),e.remove()}),Dh=[])}function _ue(r,e){var t=!1,n=!1,i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:IG,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1,useCursorForDetection:!1,dropAnimationDisabled:!1,delayTouchStartMs:0};ht(function(){return["dndzone good to go options: ".concat(Va(e),", config: ").concat(Va(i)),{node:r}]});var o=new Map;function s(){window.addEventListener("mousemove",u,{passive:!1}),window.addEventListener("touchmove",u,{passive:!1,capture:!1}),window.addEventListener("mouseup",c,{passive:!1}),window.addEventListener("touchend",c,{passive:!1})}function a(){window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",c),window.removeEventListener("touchend",c),Rl&&(clearTimeout(Rl),Rl=void 0,yx=!1)}function l(){Fl===r&&(a(),Fl=void 0,Ai=void 0,Ml=void 0,ci=void 0)}function c(m){if(Fl===r&&(l(),m.type==="touchend")){var v=new Event("click",{bubbles:!0,cancelable:!0});m.target.dispatchEvent(v)}}function u(m){if(!(n||Fl!==r)){var v=!!m.touches,g=v?m.touches[0]:m;if(v&&i.delayTouchStartMs>0&&!yx){ci={x:g.clientX,y:g.clientY},(Math.abs(ci.x-Ml.x)>=ak||Math.abs(ci.y-Ml.y)>=ak)&&(Rl&&(clearTimeout(Rl),Rl=void 0),c(m));return}m.preventDefault(),ci={x:g.clientX,y:g.clientY},(Math.abs(ci.x-Ml.x)>=ak||Math.abs(ci.y-Ml.y)>=ak)&&f()}}function d(m){if(m.target!==m.currentTarget&&(m.target.value!==void 0||m.target.isContentEditable)){ht(function(){return"won't initiate drag on a nested input element"});return}if(m.button){ht(function(){return"ignoring none left click button: ".concat(m.button)});return}if(n||Vc||Fl){ht(function(){return"cannot start a new drag before finalizing the current drag or pending gesture"});return}var v=!!m.touches,g=v&&i.delayTouchStartMs>0;g||m.preventDefault(),m.stopPropagation(),Fl=r;var y=v?m.touches[0]:m;if(Ml={x:y.clientX,y:y.clientY},ci=Cx({},Ml),Ai=m.currentTarget,g){var w=Ai;yx=!1,Rl=window.setTimeout(function(){n||Fl!==r||Ai!==w||(yx=!0,f())},i.delayTouchStartMs)}s()}function f(){var m;if(n||Fl!==r||Vc||!((m=Ai)!==null&&m!==void 0&&m.parentElement)){l();return}a(),Fl=void 0,ht(function(){return["drag start config: ".concat(Va(i)),Ai]}),Vc=!0;var v=o.get(Ai);wk=v,Nr=Ai.parentElement;var g=Nr.closest("dialog")||Nr.closest("[popover]")||Nr.getRootNode(),y=g.body||g,w=i.items,k=i.type,C=i.centreDraggedOnCursor,E=i.useCursorForDetection,x=ta(w);Vo=x[v],S$=k,td=Cue(Vo),I$=E,xn=lue(Ai,C&&ci),y.appendChild(xn);function D(){!xn||fk||(Ai.parentElement?window.requestAnimationFrame(D):(Ai.setAttribute(PG,!0),y.appendChild(Ai),wue(),KG(Ai),td[Br]=Vo[Br],xn.focus()))}window.requestAnimationFrame(D),ck(Array.from(Uc.get(i.type)).filter(function(P){return P===Nr||!an.get(P).dropFromOthersDisabled}),function(P){return an.get(P).dropTargetStyle},function(P){return an.get(P).dropTargetClasses}),x.splice(v,1,td),D$=mue(Nr),rd(Nr,x,{trigger:ki.DRAG_STARTED,id:Vo[Br],source:Ji.POINTER}),window.addEventListener("mousemove",mk,{passive:!1}),window.addEventListener("touchmove",mk,{passive:!1,capture:!1}),window.addEventListener("mouseup",$h,{passive:!1}),window.addEventListener("touchend",$h,{passive:!1})}function p(m){var v=m.items,g=v===void 0?void 0:v,y=m.flipDurationMs,w=y===void 0?0:y,k=m.type,C=k===void 0?hue:k,E=m.dragDisabled,x=E===void 0?!1:E,D=m.morphDisabled,P=D===void 0?!1:D,H=m.dropFromOthersDisabled,U=H===void 0?!1:H,oe=m.dropTargetStyle,ce=oe===void 0?IG:oe,O=m.dropTargetClasses,G=O===void 0?[]:O,V=m.transformDraggedElement,F=V===void 0?function(){}:V,Z=m.centreDraggedOnCursor,z=Z===void 0?!1:Z,Y=m.useCursorForDetection,K=Y===void 0?!1:Y,se=m.dropAnimationDisabled,pe=se===void 0?!1:se,ge=m.delayTouchStart,be=ge===void 0?!1:ge;i.dropAnimationDurationMs=w;var Be=0;be===!0?Be=yue:typeof be=="number"&&isFinite(be)&&be>=0&&(Be=be),i.delayTouchStartMs=Be,i.type&&C!==i.type&&FG(r,i.type),i.type=C,i.items=ta(g),i.dragDisabled=x,i.morphDisabled=P,i.transformDraggedElement=F,i.centreDraggedOnCursor=z,i.useCursorForDetection=K,i.dropAnimationDisabled=pe,t&&Vc&&!fk&&(!Kce(ce,i.dropTargetStyle)||!Qce(G,i.dropTargetClasses))&&(pk([r],function(){return i.dropTargetStyle},function(){return G}),ck([r],function(){return ce},function(){return G})),i.dropTargetStyle=ce,i.dropTargetClasses=ta(G);function Se(Ze,ye){return an.get(Ze)?an.get(Ze)[ye]:i[ye]}t&&Vc&&i.dropFromOthersDisabled!==U&&(U?pk([r],function(Ze){return Se(Ze,"dropTargetStyle")},function(Ze){return Se(Ze,"dropTargetClasses")}):ck([r],function(Ze){return Se(Ze,"dropTargetStyle")},function(Ze){return Se(Ze,"dropTargetClasses")})),i.dropFromOthersDisabled=U,an.set(r,i),bue(r,C);for(var ut=Vc?Ck(i.items):-1,Ne=0;Ne<r.children.length;Ne++){var Qe=r.children[Ne];if(due(Qe,x),Ne===ut){P||uue(xn,Qe,ci.x,ci.y),i.transformDraggedElement(xn,Vo,Ne),pue(Qe);continue}Qe.removeEventListener("mousedown",vx.get(Qe)),Qe.removeEventListener("touchstart",vx.get(Qe)),x||(Qe.addEventListener("mousedown",d),Qe.addEventListener("touchstart",d),vx.set(Qe,d)),o.set(Qe,Ne),t||(t=!0)}}return p(e),{update:function(v){ht(function(){return"pointer dndzone will update newOptions: ".concat(Va(v))}),p(v)},destroy:function(){if(n)return;n=!0,l();var v=Xp(r.children),g;try{for(v.s();!(g=v.n()).done;){var y=g.value;y.removeEventListener("mousedown",vx.get(y)),y.removeEventListener("touchstart",vx.get(y))}}catch(k){v.e(k)}finally{v.f()}function w(){ht(function(){return"pointer dndzone will destroy"});var k=an.get(r);k&&(FG(r,k.type),an.delete(r))}Vc&&!r.closest("[".concat(PG,"]"))?(ht(function(){return"pointer dndzone will be scheduled for destruction"}),Eue(r,w)):w()}}}var lk,C$={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},JG=(lk={},Mh(lk,C$.DND_ZONE_ACTIVE,"zoneActiveInstruction"),Mh(lk,C$.DND_ZONE_DRAG_DISABLED,"zoneDragDisabledInstruction"),lk),eY={dragStarted:function(e){var t=e.itemLabel,n=e.zoneLabel,i=e.canMoveBetweenZones;return"Started dragging item ".concat(t,". Use the arrow keys to move it within its list ").concat(n)+(i?", or tab to another list in order to move the item into it":"")},movedToPosition:function(e){var t=e.itemLabel,n=e.zoneLabel,i=e.position;return"Moved item ".concat(t," to position ").concat(i," in the list ").concat(n)},movedToZoneEnd:function(e){var t=e.itemLabel,n=e.zoneLabel;return"Moved item ".concat(t," to the end of the list ").concat(n)},movedToZoneStart:function(e){var t=e.itemLabel,n=e.zoneLabel;return"Moved item ".concat(t," to the beginning of the list ").concat(n)},dropped:function(e){var t=e.itemLabel;return"Stopped dragging item ".concat(t)},zoneActiveInstruction:function(e){var t=e.keyboardDragTrigger;return"Tab to one the items and press ".concat(Uce[t]," to start dragging it")},zoneDragDisabledInstruction:"This is a disabled drag and drop list"};var Aue=Cx({},eY),kue={keyboardDragTrigger:BG},Sue="dnd-action-aria-alert",Cn;function x$(){Cn||(Cn=document.createElement("div"),(function(){Cn.id=Sue,Cn.style.position="fixed",Cn.style.bottom="0",Cn.style.left="0",Cn.style.zIndex="-5",Cn.style.opacity="0",Cn.style.height="0",Cn.style.width="0",Cn.setAttribute("role","alert")})(),document.body.prepend(Cn),Object.entries(JG).forEach(function(r){var e=Ace(r,2),t=e[0],n=e[1];return document.body.prepend(Pue(t,tY(n,kue)))}))}function Due(){return A$?null:(document.readyState==="complete"?x$():window.addEventListener("DOMContentLoaded",x$),Cx({},C$))}function Iue(){A$||!Cn||(Object.keys(JG).forEach(function(r){var e;return(e=document.getElementById(r))===null||e===void 0?void 0:e.remove()}),Cn.remove(),Cn=void 0)}function Pue(r,e){var t=document.createElement("div");return t.id=r,Fue(t,e),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Fue(r,e){r.replaceChildren();var t=document.createElement("p");t.textContent=e,r.appendChild(t)}function Ax(r){if(!A$){Cn||x$(),Cn.innerHTML="";var e=document.createTextNode(r);Cn.appendChild(e),Cn.style.display="none",Cn.style.display="inline"}}function MG(r,e,t){var n=r[e];return typeof n=="function"?n(t):n}function tY(r,e){try{return MG(Aue,r,e)}catch(t){ht(function(){return['aria string formatter for "'.concat(r,'" threw, falling back to the default'),t]});try{return MG(eY,r,e)}catch(n){return ht(function(){return['default aria string formatter for "'.concat(r,'" also threw'),n]}),""}}}function Ph(r,e){Ax(tY(r,e))}var Mue=BG;function Rue(r){return Vce[Mue].includes(r)}var $ue="--any--",RG={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Bo=!1,Fh,Zi,$l="",Qp,vs,ed="",hk=new WeakSet,f$=new WeakMap,m$=new WeakMap,E$=new Map,Wn=new Map,Ol=new Map,gk;function Oue(r,e){ht(function(){return"registering drop-zone if absent"}),Ol.size===0&&(ht(function(){return"adding global keydown and click handlers"}),gk=Due(),window.addEventListener("keydown",rY),window.addEventListener("click",nY)),Ol.has(e)||Ol.set(e,new Set),Ol.get(e).has(r)||(Ol.get(e).add(r),VG())}function $G(r,e){ht(function(){return"unregistering drop-zone"}),Bo&&Zi===r&&Oh();var t=Ol.get(e);!t||!t.delete(r)||(UG(),t.size===0&&Ol.delete(e),Ol.size===0&&(ht(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",rY),window.removeEventListener("click",nY),gk=void 0,Iue()))}function rY(r){Bo&&r.key==="Escape"&&Oh()}function nY(){Bo&&(hk.has(document.activeElement)||(ht(function(){return"clicked outside of any draggable"}),Oh()))}function iY(r,e){return r===Zi||Qp.contains(r)||e.dropFromOthersDisabled||e.type!==Fh?-1:0}function Nue(){Wn.forEach(function(r,e){e.tabIndex=iY(e,r)})}function Lue(){var r=Wn.get(Zi);return r!=null&&r.items.some(function(e){return e[Br]===vs})?!0:(ht(function(){return"dragged item is gone, dropping"}),Oh(),!1)}function OG(r){if(ht(function(){return"zone focus"}),!!Bo){var e=r.currentTarget;if(e!==Zi&&Lue()){$l=e.getAttribute("aria-label")||"";var t=Wn.get(Zi),n=t.items,i=n.find(function(f){return f[Br]===vs}),o=n.indexOf(i),s=n.splice(o,1)[0],a=Wn.get(e),l=a.items,c=a.autoAriaDisabled;e.getBoundingClientRect().top<Zi.getBoundingClientRect().top||e.getBoundingClientRect().left<Zi.getBoundingClientRect().left?(l.push(s),c||Ph("movedToZoneEnd",{itemLabel:ed,zoneLabel:$l,position:l.length,count:l.length})):(l.unshift(s),c||Ph("movedToZoneStart",{itemLabel:ed,zoneLabel:$l,position:1,count:l.length}));var u=Zi,d=vs;Zi=e,Rh(u,n,{trigger:ki.DROPPED_INTO_ANOTHER,id:d,source:Ji.KEYBOARD}),Wn.has(e)&&Rh(e,l,{trigger:ki.DROPPED_INTO_ZONE,id:d,source:Ji.KEYBOARD})}}}function oY(){E$.forEach(function(r,e){var t=r.update;return t(Wn.get(e))})}function Oh(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;if(!(!Bo||!Zi)){ht(function(){return"drop"});var e=Zi,t=Wn.get(e),n=vs,i=Fh;if(t){if(!t.autoAriaDisabled){var o=t.items,s=o.findIndex(function(l){return l[Br]===n});Ph("dropped",{itemLabel:ed,zoneLabel:$l,position:(s<0?0:s)+1,count:o.length})}hk.has(document.activeElement)&&document.activeElement.blur(),Qp=null,vs=null,ed="",Fh=null,Zi=null,$l="",Bo=!1,r&&rd(e,t.items,{trigger:ki.DRAG_STOPPED,id:n,source:Ji.KEYBOARD});var a=Ol.get(i);a&&pk(a,function(l){return Wn.get(l).dropTargetStyle},function(l){return Wn.get(l).dropTargetClasses}),oY()}}}function Bue(r,e){var t=!1,n={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:RG,dropTargetClasses:[],autoAriaDisabled:!1};function i(d,f,p){d.length<=1||d.splice(p,1,d.splice(f,1,d[p])[0])}function o(d){switch(ht(function(){return["handling key down",d.key]}),d.key){case"Enter":case" ":{if(!Rue(d.key)||(d.target.disabled!==void 0||d.target.href||d.target.isContentEditable)&&!hk.has(d.target))return;d.preventDefault(),d.stopPropagation(),Bo?Oh():s(d);break}case"ArrowDown":case"ArrowRight":{if(!Bo)return;d.preventDefault(),d.stopPropagation();var f=Wn.get(r),p=f.items,m=Array.from(r.children),v=m.indexOf(d.currentTarget);ht(function(){return["arrow down",v]}),v<m.length-1&&(n.autoAriaDisabled||Ph("movedToPosition",{itemLabel:ed,zoneLabel:$l,position:v+2,count:p.length}),i(p,v,v+1),Rh(r,p,{trigger:ki.DROPPED_INTO_ZONE,id:vs,source:Ji.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!Bo)return;d.preventDefault(),d.stopPropagation();var g=Wn.get(r),y=g.items,w=Array.from(r.children),k=w.indexOf(d.currentTarget);ht(function(){return["arrow up",k]}),k>0&&(n.autoAriaDisabled||Ph("movedToPosition",{itemLabel:ed,zoneLabel:$l,position:k,count:y.length}),i(y,k,k-1),Rh(r,y,{trigger:ki.DROPPED_INTO_ZONE,id:vs,source:Ji.KEYBOARD}));break}}}function s(d){ht(function(){return"drag start"}),l(d.currentTarget),Zi=r,$l=r.getAttribute("aria-label")||"",Fh=n.type,Bo=!0;var f=Array.from(Ol.get(n.type)).filter(function(v){return v===Zi||!Wn.get(v).dropFromOthersDisabled});if(ck(f,function(v){return Wn.get(v).dropTargetStyle},function(v){return Wn.get(v).dropTargetClasses}),!n.autoAriaDisabled){var p=Wn.get(r).items,m=p.findIndex(function(v){return v[Br]===vs});Ph("dragStarted",{itemLabel:ed,zoneLabel:$l,position:(m<0?0:m)+1,count:p.length,canMoveBetweenZones:f.length>1})}rd(r,Wn.get(r).items,{trigger:ki.DRAG_STARTED,id:vs,source:Ji.KEYBOARD}),oY()}function a(d){Bo&&d.currentTarget!==Qp&&(d.stopPropagation(),Oh(!1),s(d))}function l(d){var f=Wn.get(r),p=f.items,m=Array.from(r.children),v=m.indexOf(d);Qp=d,Qp.tabIndex=n.zoneItemTabIndex,vs=p[v][Br],ed=m[v].getAttribute("aria-label")||""}function c(d){var f=d.items,p=f===void 0?[]:f,m=d.type,v=m===void 0?$ue:m,g=d.dragDisabled,y=g===void 0?!1:g,w=d.zoneTabIndex,k=w===void 0?0:w,C=d.zoneItemTabIndex,E=C===void 0?0:C,x=d.dropFromOthersDisabled,D=x===void 0?!1:x,P=d.dropTargetStyle,H=P===void 0?RG:P,U=d.dropTargetClasses,oe=U===void 0?[]:U,ce=d.autoAriaDisabled,O=ce===void 0?!1:ce;n.items=ta(p),n.dragDisabled=y,n.dropFromOthersDisabled=D,n.zoneTabIndex=k,n.zoneItemTabIndex=E,n.dropTargetStyle=H,n.dropTargetClasses=oe,n.autoAriaDisabled=O,n.type&&v!==n.type&&$G(r,n.type),n.type=v,Oue(r,v),O||(r.setAttribute("role","list"),r.setAttribute("aria-describedby",y?gk.DND_ZONE_DRAG_DISABLED:gk.DND_ZONE_ACTIVE)),Wn.set(r,n);var G=!1;Bo?(G=n.type===Fh&&n.items.some(function(Z){return Z[Br]===vs})&&r!==Zi,G&&(Zi=r,$l=r.getAttribute("aria-label")||""),r.tabIndex=iY(r,n)):r.tabIndex=n.zoneTabIndex,r.addEventListener("focus",OG);for(var V=function(z){var Y,K=r.children[z];hk.add(K),K.tabIndex=Bo?-1:n.zoneItemTabIndex,O||K.setAttribute("role","listitem"),K.removeEventListener("keydown",f$.get(K)),K.removeEventListener("click",m$.get(K)),y||(K.addEventListener("keydown",o),f$.set(K,o),K.addEventListener("click",a),m$.set(K,a)),Bo&&n.type===Fh&&((Y=n.items[z])===null||Y===void 0?void 0:Y[Br])===vs&&(ht(function(){return["focusing on",{i:z,focusedItemId:vs}]}),Qp=K,Qp.tabIndex=n.zoneItemTabIndex,K.focus())},F=0;F<r.children.length;F++)V(F);G&&Nue()}c(e);var u={update:function(f){ht(function(){return"keyboard dndzone will update newOptions: ".concat(Va(f))}),c(f)},destroy:function(){if(!t){t=!0,ht(function(){return"keyboard dndzone will destroy"}),r.removeEventListener("focus",OG);var f=Xp(r.children),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;m.removeEventListener("keydown",f$.get(m)),m.removeEventListener("click",m$.get(m))}}catch(v){f.e(v)}finally{f.f()}$G(r,n.type),Wn.delete(r),E$.delete(r)}}};return E$.set(r,u),u}var Vue=["items","flipDurationMs","type","dragDisabled","morphDisabled","dropFromOthersDisabled","zoneTabIndex","zoneItemTabIndex","dropTargetStyle","dropTargetClasses","transformDraggedElement","autoAriaDisabled","centreDraggedOnCursor","useCursorForDetection","delayTouchStart","dropAnimationDisabled"];function xk(r,e){if(Uue(r))return{update:function(){},destroy:function(){}};NG(e);var t=_ue(r,e),n=Bue(r,e);return{update:function(o){NG(o),t.update(o),n.update(o)},destroy:function(){t.destroy(),n.destroy()}}}function Uue(r){return!!r.closest("[".concat(qce,'="true"]'))}function NG(r){var e=r.items;r.flipDurationMs,r.type,r.dragDisabled,r.morphDisabled,r.dropFromOthersDisabled;var t=r.zoneTabIndex,n=r.zoneItemTabIndex;r.dropTargetStyle;var i=r.dropTargetClasses;r.transformDraggedElement,r.autoAriaDisabled,r.centreDraggedOnCursor,r.useCursorForDetection;var o=r.delayTouchStart;r.dropAnimationDisabled;var s=_ce(r,Vue);if(Object.keys(s).length>0&&console.warn("dndzone will ignore unknown options",s),!e)throw new Error("no 'items' key provided to dndzone");var a=e.find(function(u){return!{}.hasOwnProperty.call(u,Br)});if(a)throw new Error("missing '".concat(Br,"' property for item ").concat(Va(a)));if(i&&!Array.isArray(i))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Sh(i),", ").concat(Va(i)));if(t&&!LG(t))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Sh(t),", ").concat(Va(t)));if(n&&!LG(n))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Sh(n),", ").concat(Va(n)));if(o!==void 0&&o!==!1){var l=o===!0,c=typeof o=="number"&&isFinite(o)&&o>=0;if(!l&&!c)throw new Error("delayTouchStart should be a boolean (true/false) or a non-negative number but instead it is a ".concat(Sh(o),", ").concat(Va(o)))}}function LG(r){return!isNaN(r)&&(function(e){return(e|0)===e})(parseFloat(r))}function sY(r){var e=r,t=new Set;return{get:function(){return e},set:function(i){e=i,Array.from(t).forEach(function(o){return o(e)})},subscribe:function(i){t.add(i),i(e)},unsubscribe:function(i){t.delete(i)}}}var iot=sY(!0),oot=sY(!1);var que=[[9,5],[9,12],[9,19],[15,5],[15,12],[15,19]];function aY(r,e,t=!1){if(!r)return;r.classList.add("qa-drag-clone"),r.dataset.qaMulti=t?"true":"false";let n=r.querySelector(":scope > .qa-drag-pill");if(!n){n=r.createDiv({cls:"qa-drag-pill"});let s=n.createSpan({cls:"qa-drag-pill-grip"}).createSvg("svg",{attr:{viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"}});for(let[a,l]of que)s.createSvg("circle",{attr:{cx:a,cy:l,r:1}});n.createSpan({cls:"qa-drag-pill-label"})}let i=n.querySelector(".qa-drag-pill-label");i&&i.textContent!==e&&(i.textContent=e)}function Nl(r){return r.filter(e=>e.id!==Tx)}function Ek(r,e){let t=r.findIndex(i=>i.id===Tx);if(t===-1)return null;let n={...r[t]};return delete n[Nh],{item:{...n,id:e},index:t}}function lY(r,e){return r.map(t=>t.id===e.id?e:t)}function Tk(r){let e=r.resolveLabel??(t=>t.name??"");return{items:r.items,dragDisabled:r.dragDisabled,flipDurationMs:r.flipDurationMs??0,morphDisabled:!0,useCursorForDetection:!0,centreDraggedOnCursor:!1,transformDraggedElement:(t,n)=>aY(t,n?e(n):"",n?.type==="Multi"),dropTargetStyle:{},dropTargetClasses:r.dropTargetClasses??[],dropAnimationDisabled:!0,autoAriaDisabled:!0,zoneItemTabIndex:-1,delayTouchStart:200,...r.type?{type:r.type}:{}}}function _k(){let r=_e(!1),e=!1;function t(){J(r,!0),e=!1;let n=()=>{window.removeEventListener("pointerup",n,!0),window.removeEventListener("pointercancel",n,!0),e||J(r,!1)};window.addEventListener("pointerup",n,!0),window.addEventListener("pointercancel",n,!0)}return{get armed(){return h(r)},markStarted(){e=!0},reset(){J(r,!1),e=!1},startDrag:t}}wl();Kr();Bm();function Zp(r){if(r.type==="Choice")try{return ni().getChoiceById(r.choiceId).name}catch{return"(missing choice)"}if(r.type==="Conditional"){let e=r.condition;return`If ${Lm(e)}`}return r.name}var Wue=q('<button type="button"><!></button>');function Si(r,e){we(e,!0);let t=he(e,"size",3,16),n=N(()=>!!(e.onMoveUp||e.onMoveDown));function i(l){l.key==="ArrowUp"&&e.onMoveUp?(l.preventDefault(),l.stopPropagation(),e.onMoveUp()):l.key==="ArrowDown"&&e.onMoveDown&&(l.preventDefault(),l.stopPropagation(),e.onMoveDown())}var o=Wue();let s;var a=I(o);$t(a,{iconId:"grip-vertical",get size(){return t()}}),S(o),de(()=>{s=xt(o,1,"qa-icon-button qa-drag-handle",null,s,{"qa-drag-handle-ready":e.dragDisabled,"qa-drag-handle-active":!e.dragDisabled}),Ae(o,"aria-label",e.label),Ae(o,"aria-keyshortcuts",h(n)?"ArrowUp ArrowDown":void 0),Ae(o,"tabindex",e.dragDisabled?0:-1)}),De("pointerdown",o,()=>e.onDragStart()),De("keydown",o,i),$(r,o),Ce()}Tt(["pointerdown","keydown"]);var zue=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!></div></li>');function P$(r,e){we(e,!0);var t=zue(),n=I(t),i=I(n,!0);S(n);var o=_(n,2),s=I(o);{let l=N(()=>`Delete ${Zp(e.command)}`);er(s,{iconId:"trash-2",get label(){return h(l)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var a=_(s,2);{let l=N(()=>`Reorder ${Zp(e.command)}`);Si(a,{get label(){return h(l)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(l=>me(i,l),[()=>Zp(e.command)]),$(r,t),Ce()}Kr();var Hue=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> <input type="number" min="0" placeholder=" " class="dotInput svelte-1h5tx3b" aria-label="Wait duration in milliseconds"/>ms</span> <div class="quickAddCommandControls"><!> <!></div></li>'),jue={hash:"svelte-1h5tx3b",code:".dotInput.svelte-1h5tx3b {border:none;display:inline;font-family:inherit;font-size:inherit;padding:0;width:var(--qa-wait-input-width, 2ch);text-decoration:underline dotted;background-color:transparent;}.dotInput.svelte-1h5tx3b:hover {background-color:transparent;}"};function F$(r,e){we(e,!0),ot(r,jue);let t=_e(void 0),n=_e(Ct(Ot(()=>e.command.time)));function i(){if(!h(t))return;let p=String(h(t).value).length;h(t).style.setProperty("--qa-wait-input-width",`${p===0?2:p}ch`)}function o(p){let m=p.currentTarget.valueAsNumber;J(n,Number.isNaN(m)||m<0?0:m,!0),i(),e.onUpdateCommand({...e.command,time:h(n)})}ST(i);var s=Hue(),a=I(s),l=I(a),c=_(l);gr(c),cc(c,p=>J(t,p),()=>h(t)),Pn(),S(a);var u=_(a,2),d=I(u);{let p=N(()=>`Delete ${e.command.name}`);er(d,{iconId:"trash-2",get label(){return h(p)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var f=_(d,2);{let p=N(()=>`Reorder ${e.command.name}`);Si(f,{get label(){return h(p)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(u),S(s),de(()=>{me(l,`${e.command.name??""} for `),Rs(c,h(n))}),De("input",c,o),$(r,s),Ce()}Tt(["input"]);var Gue=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function M$(r,e){we(e,!0);var t=Gue(),n=I(t),i=I(n,!0);S(n);var o=_(n,2),s=I(o);{let c=N(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureChoice(e.command)})}var a=_(s,2);{let c=N(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=_(a,2);{let c=N(()=>`Reorder ${e.command.name}`);Si(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Yue=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function R$(r,e){we(e,!0);var t=Yue(),n=I(t),i=I(n,!0);S(n);var o=_(n,2),s=I(o);{let c=N(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureScript(e.command)})}var a=_(s,2);{let c=N(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=_(a,2);{let c=N(()=>`Reorder ${e.command.name}`);Si(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Fi=require("obsidian");wl();function cY(r,e){let t=r.ownerDocument.createElement("div");t.className="qa-format-preview-host",r.appendChild(t);let n=Ct({value:e.value,app:e.app,plugin:e.plugin,targetFolderPath:null}),i=Wi(t,gs,n,{what:"the preview for this field"}),o=!1;return{setValue(s){o||(n.value=s)},destroy(){o||(o=!0,i.destroy(),t.remove())}}}function uY(r){r.addEventListener("focus",()=>{r.type="text"}),r.addEventListener("blur",()=>{r.type="password"}),r.type="password"}$k();qc();function dde(r){return typeof r=="string"?r:r==null?"":String(r)}function CY(r){if(typeof r=="string")return r;if(r==null)return"";if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r)??String(r)}catch{return String(r)}}var Ok=class extends Fi.Modal{constructor(t,n,i,o){super(t);this.command=n;this.settings=i;this.onCommandChange=o;this.previewHandles=[];this.command.settings||(this.command.settings={}),zh(this.command.settings,this.settings),this.display(),this.migrateSecretSettings()}display(){this.containerEl.addClass("quickAddModal","userScriptSettingsModal"),this.destroyPreviews(),this.contentEl.empty();let t=CY(this.settings?.name??this.command.name),n=CY(this.settings?.author);this.titleEl.innerText=`${t}${n?` by ${n}`:""}`;let i=this.settings.options;if(i)for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let s=i[o];if(Uh(s)){let u=this.addSecretInput(o,"placeholder"in s?s.placeholder:void 0);s.description&&u.setDesc(s.description);continue}let a=s.defaultValue;this.command.settings[o]!==void 0&&(a=this.command.settings[o]);let l,c=s.type;c==="text"||c==="input"?l=this.addInputBox(o,a,s?.placeholder,s.secret):c==="textarea"?l=this.addTextArea(o,a,s?.placeholder):c==="checkbox"||c==="toggle"?l=this.addToggle(o,a):c==="dropdown"||c==="select"?l=this.addDropdown(o,s.options,a):c==="format"&&(l=this.addFormatInput(o,a,s.placeholder)),s.description&&l&&l.setDesc(s.description)}}addInputBox(t,n,i,o){return new Fi.Setting(this.contentEl).setName(t).addText(s=>{s.setValue(n).onChange(a=>{this.command.settings[t]=a,this.onCommandChange?.()}).setPlaceholder(i??""),o&&uY(s.inputEl)})}addSecretInput(t,n){let i=new Fi.Setting(this.contentEl).setName(t),o="",s,a=()=>{let c=this.command.settings?.[t];return Rk(this.command,t)!==void 0||typeof c=="string"&&c.length>0},l=()=>{s&&(s.placeholder=a()?"Secret saved":n??"Paste secret")};return i.addText(c=>{c.setValue("").onChange(u=>{o=u}),c.inputEl.type="password",c.inputEl.addClass("qa-user-script-secret-input"),c.inputEl.setAttribute("aria-label",t),s=c.inputEl,l()}),i.addButton(c=>{c.setIcon("save").setTooltip("Save secret").onClick(async()=>{if(o.length===0){new Fi.Notice("Paste a secret before saving.");return}let u=await V$(this.app,this.command,t,o,Rk(this.command,t),this.settings.options?.[t]);if(!u){new Fi.Notice("SecretStorage is unavailable. Secret was not saved.");return}this.command.settings[t]=Dk(u),o="",s&&(s.value=""),l(),this.onCommandChange?.(),new Fi.Notice("Secret saved.")}),c.buttonEl.setAttribute("aria-label",`Save ${t}`)}),i.addButton(c=>{c.setIcon("trash-2").setTooltip("Clear secret").onClick(async()=>{let u=Rk(this.command,t);if(u&&!await U$(this.app,u)){new Fi.Notice("SecretStorage is unavailable. Secret was not cleared.");return}delete this.command.settings[t],o="",s&&(s.value=""),l(),this.onCommandChange?.(),new Fi.Notice("Secret cleared.")}),c.buttonEl.setAttribute("aria-label",`Clear ${t}`)}),i}addTextArea(t,n,i){return new Fi.Setting(this.contentEl).setName(t).addTextArea(o=>{o.setValue(n).onChange(s=>{this.command.settings[t]=s,this.onCommandChange?.()}).setPlaceholder(i??""),o.inputEl.addClass("qa-user-script-argument-textarea")})}addToggle(t,n){return new Fi.Setting(this.contentEl).setName(t).addToggle(i=>i.setValue(n).onChange(o=>{this.command.settings[t]=o,this.onCommandChange?.()}))}addDropdown(t,n,i){return new Fi.Setting(this.contentEl).setName(t).addDropdown(o=>{n.forEach(s=>{o.addOption(s,s)}),o.setValue(i),o.onChange(s=>{this.command.settings[t]=s,this.onCommandChange?.()})})}addFormatInput(t,n,i){let o=new Fi.Setting(this.contentEl).setName(t),s=dde(n),a=new Fi.TextAreaComponent(this.contentEl);new ji(this.app,a.inputEl,ni()),a.inputEl.addClass("qa-user-script-format-textarea"),a.inputEl.setAttribute("aria-label",t);let l=cY(this.contentEl,{app:this.app,plugin:ni(),value:s});return this.previewHandles.push(l),a.setValue(s).onChange(c=>{this.command.settings[t]=c,l.setValue(c),this.onCommandChange?.()}).setPlaceholder(i??""),o}destroyPreviews(){for(let t of this.previewHandles)t.destroy();this.previewHandles=[]}onClose(){this.destroyPreviews(),super.onClose()}async migrateSecretSettings(){await qh(this.app,this.command,this.settings)&&(this.onCommandChange?.(),this.display())}};Me();qt();var pde=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function W$(r,e){we(e,!0);var t=pde(),n=I(t),i=I(n,!0);S(n);var o=_(n,2),s=I(o);{let c=N(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureAssistant(e.command)})}var a=_(s,2);{let c=N(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=_(a,2);{let c=N(()=>`Reorder ${e.command.name}`);Si(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Co=require("obsidian");var fde="QuickAdd sends the system prompt to the model as written - format syntax like {{DATE}} is not resolved here. Only the prompt template is formatted.",mde=0;function Nk(r,e,t){let n=r.createEl("div",{text:fde,cls:"qa-literal-format-note"}),i=`qa-literal-format-note-${++mde}`;n.id=i;let o=s=>{let a=s.includes("{{");n.classList.toggle("qa-literal-format-note--shown",a),a?e.setAttribute("aria-describedby",i):e.removeAttribute("aria-describedby")};return o(t),o}qt();Pt();$a();Px();var SY=require("obsidian");jh();var bde=[{key:"temperature",name:"Temperature",desc:"Sampling temperature (0-1, the range every provider accepts). Higher values like 0.8 make the output more random; lower values like 0.2 make it more focused and deterministic.",min:0,max:1,step:.1,fallback:1},{key:"top_p",name:"Top P",desc:"Nucleus sampling - an alternative to temperature. The model considers only the tokens comprising the top P probability mass, so 0.1 means the top 10%.",min:0,max:1,step:.1,fallback:1},{key:"frequency_penalty",name:"Frequency penalty",desc:"Positive values penalize tokens by how often they already appear, reducing verbatim repetition; negative values encourage it. Only sent to providers that support it.",min:-2,max:2,step:.1,fallback:0},{key:"presence_penalty",name:"Presence penalty",desc:"Positive values penalize tokens that have appeared at all, encouraging new topics; negative values do the opposite. Only sent to providers that support it.",min:-2,max:2,step:.1,fallback:0}];function DY(r,e,t,n){let i=Jp(t,{silent:!0})?.model;i?.supportsTemperature===!1&&r.createEl("div",{text:`${i.name} uses fixed sampling, so these settings are not sent to it.`,cls:"setting-item-description"});for(let o of bde){let s=typeof e[o.key]=="number";new SY.Setting(r).setName(o.name).setDesc(s?o.desc:`${o.desc} Currently using the provider's default.`).addSlider(a=>{a.setLimits(o.min,o.max,o.step),a.setDynamicTooltip(),a.setValue(e[o.key]??o.fallback),a.onChange(l=>{e[o.key]=l})}).addExtraButton(a=>{a.setIcon("rotate-ccw"),a.setTooltip("Reset to provider default"),a.setDisabled(!s),a.onClick(()=>{delete e[o.key],n()})})}}jh();ts();Pt();var Gh="Ask me",Lk="__qa-missing-model__";function Bk(r,e,t){let n=le.getState().ai.providers,i=r.selectEl,o=i.ownerDocument;e={model:e.model,modelRef:vu(e.model,e.modelRef)},r.addOption(Gh,Gh);let s=new Map,a=0;for(let c of n){if(c.models.length===0)continue;let u=o.createElement("optgroup");u.label=c.name,i.appendChild(u);for(let d of c.models){let f=`${c.id??c.name}/${d.name}:${a++}`;s.set(f,{providerId:c.id,modelName:d.name});let p=o.createElement("option");p.value=f,p.text=d.name,u.appendChild(p)}}let l=wde(e,s);if(l)r.setValue(l);else{let c=e.modelRef?`${e.modelRef.providerId}/${e.modelRef.name}`:e.model;r.addOption(Lk,`(missing) ${c}`);let u=Array.from(i.options).find(d=>d.value===Lk);u&&(u.disabled=!0),r.setValue(Lk)}r.onChange(c=>{if(c===Lk)return;if(c===Gh){t({model:Gh,modelRef:void 0});return}let u=s.get(c);u&&t({model:u.modelName,modelRef:u.providerId?{providerId:u.providerId,name:u.modelName}:void 0})})}function wde(r,e){if(!r.model||r.model===Gh)return Gh;if(r.modelRef){for(let[n,i]of e)if(i.providerId===r.modelRef.providerId&&i.modelName===r.modelRef.name)return n;return}let t=Jp(r.model,{silent:!0});if(t){for(let[n,i]of e)if(i.providerId===t.provider.id&&i.modelName===t.model.name)return n}}ts();var Vk=class extends Co.Modal{constructor(t,n){super(t);this.isResolved=!1;this.showAdvancedSettings=!1;this.settings=n,this.originalSettings=this.cloneSettings(n),this.waitForClose=new Promise((i,o)=>{this.rejectPromise=o,this.resolvePromise=i}),this.open(),this.display()}get systemPromptTokenLength(){return Uo(this.settings.systemPrompt)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}cloneSettings(t){return{...t,promptTemplate:{...t.promptTemplate},modelParameters:{...t.modelParameters}}}restoreOriginal(){let t=this.cloneSettings(this.originalSettings);Object.assign(this.settings,t),this.settings.promptTemplate=t.promptTemplate,this.settings.modelParameters=t.modelParameters}display(){let t=this.contentEl.createEl("h2");t.addClass("qa-clickable-modal-title"),t.createEl("button",{cls:"qa-rename-title-button",text:`${this.settings.name} settings`,attr:{type:"button","aria-label":`Rename ${this.settings.name}`}}).addEventListener("click",()=>{(async()=>{try{let i=await Dr.Prompt(this.app,"New name",this.settings.name,this.settings.name);i&&i!==this.settings.name&&(this.settings.name=i,this.reload())}catch{}})()}),this.addPromptTemplateSetting(this.contentEl),this.addModelSetting(this.contentEl),this.addOutputVariableNameSetting(this.contentEl),this.addShowAdvancedSettingsToggle(this.contentEl),this.showAdvancedSettings&&(this.settings.modelParameters||(this.settings.modelParameters={}),DY(this.contentEl,this.settings.modelParameters,vu(this.settings.model,this.settings.modelRef)??this.settings.model,()=>this.reload())),this.addSystemPromptSetting(this.contentEl),this.addButtonBar(this.contentEl)}addButtonBar(t){let n=t.createDiv({cls:"qa-command-button-row"});new Co.ButtonComponent(n).setButtonText("Cancel").onClick(()=>{this.restoreOriginal(),this.resolve(null),this.close()}),new Co.ButtonComponent(n).setButtonText("Save").setCta().onClick(()=>{this.resolve(this.settings),this.close()})}reload(){this.contentEl.empty(),this.display()}addPromptTemplateSetting(t){let n=le.getState().ai.promptTemplatesFolderPath,i=ns(this.app,n).map(o=>o.name);new Co.Setting(t).setName("Prompt template").setDesc("Enabling this will have the assistant use the prompt template you specify. If disable, the assistant will ask you for a prompt template to use.").addToggle(o=>{o.setValue(this.settings.promptTemplate.enable),o.onChange(s=>{this.settings.promptTemplate.enable=s})}).addText(o=>{o.setValue(this.settings.promptTemplate.name).onChange(s=>{this.settings.promptTemplate.name=s}),new ii(this.app,o.inputEl,i)})}addModelSetting(t){new Co.Setting(t).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(n=>{Bk(n,this.settings,i=>{this.settings.model=i.model,this.settings.modelRef=i.modelRef,this.reload()})})}addOutputVariableNameSetting(t){new Co.Setting(t).setName("Output variable name").setDesc("The name of the variable used to store the AI Assistant output, i.e. {{value:output}}.").addText(n=>{n.setValue(this.settings.outputVariableName).onChange(i=>{this.settings.outputVariableName=i})})}addSystemPromptSetting(t){new Co.Setting(t).setName("System prompt").setDesc("The system prompt for the AI Assistant");let n=this.contentEl.createEl("div"),i=n.createEl("span",{cls:"qa-ai-token-count"}),o=n.createEl("div",{text:"Estimated locally. Providers enforce exact context limits.",cls:"qa-ai-token-note"});n.appendChild(i),n.appendChild(o);let s=new Co.TextAreaComponent(t);s.inputEl.addClass("qa-ai-prompt-textarea"),s.inputEl.setAttribute("aria-label","System prompt");let a=Nk(t,s.inputEl,this.settings.systemPrompt??""),l=(0,Co.debounce)(()=>{i.innerText=`Estimated tokens: ${this.systemPromptTokenLength}`},50);s.setValue(this.settings.systemPrompt).onChange(c=>{this.settings.systemPrompt=c,a(c),l()}),l()}addShowAdvancedSettingsToggle(t){new Co.Setting(t).setName("Show advanced settings").setDesc("Sampling settings such as temperature and top p. Untouched settings use the provider's defaults.").addToggle(n=>{n.setValue(this.showAdvancedSettings),n.onChange(i=>{this.showAdvancedSettings=i,this.reload()})})}onClose(){this.isResolved||(this.restoreOriginal(),this.resolve(null)),super.onClose()}};var Cde=q('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function j$(r,e){we(e,!0);var t=Cde(),n=I(t),i=I(n,!0);S(n);var o=_(n,2),s=I(o);{let c=N(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureOpenFile(e.command)})}var a=_(s,2);{let c=N(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=_(a,2);{let c=N(()=>`Reorder ${e.command.name}`);Si(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Ll=require("obsidian");Uk();Kr();var qk=class extends Ll.Modal{constructor(t,n){super(t);this.isResolved=!1;this.originalCommand=n,this.command={...n,type:"OpenFile"},this.command.focus=this.command.focus??!0,this.command.location=this.command.location??this.deriveLocation(),this.syncLegacyFlagsFromLocation(this.command.location),this.waitForClose=new Promise(i=>{this.resolvePromise=i}),this.display(),this.open()}onClose(){super.onClose(),this.isResolved||(this.resolvePromise(null),this.isResolved=!0)}resolveWithGuard(t){this.isResolved||(this.resolvePromise(t),this.isResolved=!0)}display(){this.containerEl.addClass("quickAddModal","openFileCommandSettingsModal"),this.contentEl.empty();let t=this.contentEl.createEl("h2");t.textContent="Open file command settings",t.addClass("qa-modal-title"),this.addFilePathSetting(),this.addOpenLocationSetting(),this.addFocusSetting(),this.addButtonBar()}addFilePathSetting(){new Ll.Setting(this.contentEl).setName("File path").setDesc("Path to the file. Supports formatting like {{DATE}}, {{VALUE}}, etc.").addText(t=>t.setPlaceholder("{{DATE}}todo.md").setValue(this.command.filePath).onChange(n=>{this.command.filePath=n,this.command.name=`Open file: ${n}`}))}addOpenLocationSetting(){let t=[{value:"reuse",label:"Reuse active tab"},{value:"tab",label:"New tab"},{value:"split",label:"Split"},{value:"window",label:"New window"},{value:"left-sidebar",label:"Left sidebar"},{value:"right-sidebar",label:"Right sidebar"}];new Ll.Setting(this.contentEl).setName("Where to open").setDesc("Choose tab, split, window, or sidebar").addDropdown(n=>{for(let{value:i,label:o}of t)n.addOption(i,o);n.setValue(this.deriveLocation()).onChange(i=>{this.command.location=i,this.syncLegacyFlagsFromLocation(i),this.reload()})}),this.deriveLocation()==="split"&&this.addDirectionSetting()}syncLegacyFlagsFromLocation(t){switch(t){case"split":this.command.openInNewTab=!0,this.command.direction||(this.command.direction="vertical");break;case"tab":case"reuse":this.command.openInNewTab=!1,this.command.direction=void 0;break;default:this.command.openInNewTab=!0,this.command.direction=void 0;break}}addDirectionSetting(){new Ll.Setting(this.contentEl).setName("Split direction").setDesc("How to arrange the new pane relative to the current one").addDropdown(t=>{t.addOption("vertical","Split right").addOption("horizontal","Split down").setValue(this.command.direction??"vertical").onChange(n=>{this.command.direction=n})})}addFocusSetting(){new Ll.Setting(this.contentEl).setName("Focus opened file").setDesc("Bring the opened file to the foreground").addToggle(t=>t.setValue(this.command.focus??!0).onChange(n=>{this.command.focus=n}))}deriveLocation(){return this.command.location?this.command.location:this.command.openInNewTab?"split":"reuse"}addButtonBar(){let t=this.contentEl.createDiv({cls:"qa-command-button-row qa-command-button-row-compact"});new Ll.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.resolveWithGuard(null),this.close()}),new Ll.ButtonComponent(t).setButtonText("Save").setCta().onClick(()=>{this.resolveWithGuard(this.command),this.close()})}reload(){this.display()}};Bm();Pi();var xde=q('<li class="quickAddCommandListItem conditionalCommand svelte-p3uofi"><div class="quickAddCommandLabel"><div class="conditionalSummary svelte-p3uofi"> </div> <div class="conditionalBranches svelte-p3uofi"><span> </span> <span> </span></div></div> <div class="quickAddCommandControls"><!> <!> <!> <!> <!></div></li>'),Ede={hash:"svelte-p3uofi",code:".conditionalCommand.svelte-p3uofi {flex-wrap:wrap;}.conditionalSummary.svelte-p3uofi {font-weight:600;margin-bottom:4px;}.conditionalBranches.svelte-p3uofi {display:flex;gap:12px;font-size:0.9em;opacity:0.8;}"};function G$(r,e){we(e,!0),ot(r,Ede);let t=N(()=>Lm(e.command.condition)),n=N(()=>Ir(e.command.thenCommands).length),i=N(()=>Ir(e.command.elseCommands).length);var o=xde(),s=I(o),a=I(s),l=I(a,!0);S(a);var c=_(a,2),u=I(c),d=I(u);S(u);var f=_(u,2),p=I(f);S(f),S(c),S(s);var m=_(s,2),v=I(m);{let C=N(()=>`Edit condition for ${h(t)}`);er(v,{iconId:"settings",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onConfigureCondition(e.command)})}var g=_(v,2);{let C=N(()=>`Edit then branch for ${h(t)}`);er(g,{iconId:"corner-down-right",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onEditThenBranch(e.command)})}var y=_(g,2);{let C=N(()=>`Edit else branch for ${h(t)}`);er(y,{iconId:"corner-down-left",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onEditElseBranch(e.command)})}var w=_(y,2);{let C=N(()=>`Delete ${e.command.name}`);er(w,{iconId:"trash-2",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var k=_(w,2);{let C=N(()=>`Reorder ${e.command.name}`);Si(k,{get label(){return h(C)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(m),S(o),de(()=>{me(l,h(t)),me(d,`Then: ${h(n)??""}`),me(p,`Else: ${h(i)??""}`)}),$(r,o),Ce()}var Tde=q('<ol class="quickAddCommandList svelte-16btmqx"></ol>'),_de={hash:"svelte-16btmqx",code:".quickAddCommandList.svelte-16btmqx {display:grid;grid-template-columns:auto;width:auto;border:0 solid black;overflow-y:auto;height:auto;margin-bottom:8px;padding:20px;}"};function Y$(r,e){let t=$v();we(e,!0),ot(r,_de);let n=he(e,"commands",31,()=>Ct([])),i=N(()=>{let V=new Set;return Array.isArray(n())?n().filter(F=>{if(typeof F!="object"||F===null)return!1;let Z=F.id;return typeof Z!="string"||Z===""||V.has(Z)?!1:(V.add(Z),!0)}):[]}),o=`command:${t}`,s=PY.Platform.isMobile,a=_k(),l=N(()=>!s&&!a.armed),c=V=>V,u=V=>V,d=V=>V,f=V=>V,p=V=>V,m=V=>V;function v(){e.saveCommands(Eh(n()))}let g=null;function y(V){a.markStarted();let F=V.detail.items;g=Ek(F,V.detail.info.id)??g,n(Nl(F))}function w(V){let F=Nl(V.detail.items),Z=V.detail.info.id;g?.item.id===Z&&!F.some(z=>z.id===Z)&&(F=[...F],F.splice(Math.min(g.index,F.length),0,g.item)),g=null,n(F),V.detail.info.source===Ji.POINTER&&a.reset(),v()}let k=()=>{a.startDrag()};function C(V,F){let Z=Nl(h(i)),z=Z.findIndex(pe=>pe.id===V);if(z===-1)return;let Y=z+F;if(Y<0||Y>=Z.length)return;let K=[...Z],[se]=K.splice(z,1);K.splice(Y,0,se),n(K),v(),Ax(`Moved ${Zp(se)} to position ${Y+1} of ${Z.length}`)}function E(V){n(lY(h(i),V)),v()}async function x(V){await e.onConfigureCondition?.(V)&&E(V)}async function D(V){await e.onEditThenBranch?.(V)&&E(V)}async function P(V){await e.onEditElseBranch?.(V)&&E(V)}async function H(V){let F=await U(V.choice)?.waitForClose;if(!F)return;let Z={...V,choice:F,name:F.name};E(Z)}function U(V){switch(V.type){case"Template":return new kh(e.app,V,e.plugin);case"Capture":return new _h(e.app,V,e.plugin);default:break}}async function oe(V){let F=await Sa(V,e.app);if(!F){M.logWarning(`${V.name} could not be loaded.`);return}let Z=F.settings??{};new Ok(e.app,V,Z,()=>v()).open()}async function ce(V){await new Vk(e.app,V).waitForClose&&E(V)}async function O(V){let F=await new qk(e.app,V).waitForClose;F&&E(F)}var G=Tde();ar(G,21,()=>Nl(h(i)),V=>V.id,(V,F)=>{var Z=dn(),z=Pe(Z);{var Y=Se=>{{let ut=N(()=>c(h(F)));F$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onUpdateCommand:E,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},K=Se=>{{let ut=N(()=>u(h(F)));M$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onConfigureChoice:H,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},se=Se=>{{let ut=N(()=>d(h(F)));R$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onConfigureScript:oe,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},pe=Se=>{{let ut=N(()=>f(h(F)));W$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onConfigureAssistant:ce,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},ge=Se=>{{let ut=N(()=>p(h(F)));j$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onConfigureOpenFile:O,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},be=Se=>{{let ut=N(()=>m(h(F)));G$(Se,{get command(){return h(ut)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onConfigureCondition:x,onEditThenBranch:D,onEditElseBranch:P,onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})}},Be=Se=>{P$(Se,{get command(){return h(F)},get dragDisabled(){return h(l)},startDrag:k,get onDeleteCommand(){return e.deleteCommand},onMoveUp:()=>C(h(F).id,-1),onMoveDown:()=>C(h(F).id,1)})};ie(z,Se=>{h(F).type==="Wait"?Se(Y):h(F).type==="NestedChoice"?Se(K,1):h(F).type==="UserScript"?Se(se,2):h(F).type==="AIAssistant"?Se(pe,3):h(F).type==="OpenFile"?Se(ge,4):h(F).type==="Conditional"?Se(be,5):Se(Be,-1)})}$(V,Z)}),S(G),Mr(G,(V,F)=>xk?.(V,F),()=>Tk({items:h(i),dragDisabled:h(l),type:o,resolveLabel:Zp})),lc("consider",G,y),lc("finalize",G,w),$(r,G),Ce()}function FY(r){return Ct(r)}Wc();Kr();bl();var Fx=class extends di{constructor(t,n){super(t,"Obsidian");this.generateId=()=>this.id=Er();this.commandId=n}};Wc();Kr();var Wk=class extends di{constructor(e,t){super(e,"Choice"),this.choiceId=t}};Wc();Kr();var zk=class extends di{constructor(e){super("Wait","Wait"),this.time=e}};Kr();Wc();var Hk=class extends di{constructor(e){super(e.name,"NestedChoice"),this.choice=e}};bl();var Bl=class{constructor(e,t){this.id=Er(),this.name=e,this.type=t,this.command=!1,this.onePageInput=void 0}};_t();var Yh=class extends Bl{constructor(e){super(e,"Capture"),this.appendLink=!1,this.copyLinkToClipboard=!1,this.captureTo="",this.captureToActiveFile=!1,this.captureToCanvasNodeId="",this.activeFileWritePosition="cursor",this.createFileIfItDoesntExist={enabled:!1,createWithTemplate:!1,template:""},this.format={enabled:!1,format:""},this.insertAfter={enabled:!1,after:"",insertAtEnd:!1,considerSubsections:!1,createIfNotFound:!1,createIfNotFoundLocation:"top",inline:!1,replaceExisting:!1,blankLineAfterMatchMode:"auto",promptHeading:!1},this.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},this.newLineCapture={enabled:!1,direction:"below"},this.prepend=!1,this.task=!1,this.openFile=!1,this.fileOpening=pn(),this.templater={afterCapture:"none"}}static Load(e){let t=e;return t.activeFileWritePosition!=="cursor"&&t.activeFileWritePosition!=="top"&&t.activeFileWritePosition!=="bottom"&&(t.activeFileWritePosition="cursor"),typeof t.captureToCanvasNodeId!="string"&&(t.captureToCanvasNodeId=""),t.insertBefore||(t.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"}),t.captureToActiveFile&&t.prepend&&!t.insertAfter?.enabled&&!t.insertBefore.enabled&&!t.newLineCapture?.enabled&&(t.activeFileWritePosition!=="top"&&(t.activeFileWritePosition="bottom"),t.prepend=!1),t.templater||(t.templater={afterCapture:"none"}),t.templater.afterCapture!=="wholeFile"&&(t.templater.afterCapture="none"),t.insertAfter&&!t.insertAfter.blankLineAfterMatchMode&&(t.insertAfter.blankLineAfterMatchMode="auto"),t.insertAfter&&t.insertAfter.inline===void 0&&(t.insertAfter.inline=!1),t.insertAfter&&t.insertAfter.replaceExisting===void 0&&(t.insertAfter.replaceExisting=!1),t.insertAfter&&t.insertAfter.promptHeading===void 0&&(t.insertAfter.promptHeading=!1),t.insertAfter?.createIfNotFoundLocation===Aa&&(t.insertAfter.createIfNotFound&&!t.insertAfter.orderBy&&(t.insertAfter.orderBy={by:"insertion",direction:"desc",unparseable:"bottom"}),t.insertAfter.inline=!1),t}};var od=class extends Bl{constructor(e){super(e,"Template"),this.templatePath="",this.fileNameFormat={enabled:!1,format:""},this.discoverExistingNotesBeforeCreate=!1,this.folder={enabled:!1,folders:[],chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1,chooseFromSubfolders:!1},this.appendLink=!1,this.copyLinkToClipboard=!1,this.openFile=!1,this.fileOpening=pn(),this.fileExistsBehavior={kind:"prompt"}}static Load(e){return e}};var MY=require("obsidian");_t();iy();function jk(r){let e=[];for(let t of r.vault.getFiles())D0.test(t.path)?e.push({file:t,isMarkdown:!1}):ir.test(t.path)&&Ade(r,t)&&e.push({file:t,isMarkdown:!0});return e}function Ade(r,e){return r.metadataCache.getFileCache(e)?.sections?.some(n=>n.type==="code")??!1}function RY(r,e,t){let n=e.find(s=>s.file.path===t);if(n)return n;let i=e.find(s=>!s.isMarkdown&&s.file.basename===t);if(i)return i;let o=r.vault.getAbstractFileByPath(t);if(o instanceof MY.TFile){if(D0.test(o.path))return{file:o,isMarkdown:!1};if(ir.test(o.path))return{file:o,isMarkdown:!0}}return null}async function Mx(r,e){let t=await r.vault.read(e),{code:n,error:i}=vc(t);return n!==null&&n.length>0?null:i??"No ```js code block found in the note."}function K$(r){return r.isMarkdown?r.file.path:r.file.basename}Wc();Kr();var Rx=class extends di{constructor(e,t){super(e,"UserScript"),this.path=t,this.settings={}}};Yp();var $Y=require("obsidian");function Gk(r){let t=new $Y.Notice("",1e4).messageEl;t.replaceChildren(),Kh(t,"No scripts found","quickadd-notice-title");let n=t.ownerDocument,i=n.createElement("div");t.append(i),Kh(i,"QuickAdd cannot find any .js files or notes with a ```js code block in your vault."),i.append(n.createElement("br")),Kh(i,"Please make sure your scripts are:"),Kh(i,`\u2713 In your vault (not in ${r.vault.configDir} folder)`),Kh(i,"\u2713 Not in hidden folders (starting with a dot)"),Kh(i,"\u2713 A .js file, or a note containing a ```js code block"),i.append(n.createElement("br")),JA(i,Pl.userScripts,"View documentation")}function Kh(r,e,t){let n=r.ownerDocument.createElement("div");return n.textContent=e,t&&n.classList.add(t),r.append(n),n}sd();Me();ys();Q$();X$();Z$();J$();eO();tO();rO();nO();iO();oO();Wc();Kr();Pt();ts();var Kk=class extends di{constructor(){super("AI Assistant","AIAssistant");let e=le.getState().ai;this.model=e.defaultModel;let t=vu(e.defaultModel,e.defaultModelRef);this.modelRef=t?{...t}:void 0,this.systemPrompt=e.defaultSystemPrompt,this.outputVariableName="output",this.promptTemplate={enable:!1,name:""},this.modelParameters={}}};Pt();Kr();bl();Uk();var Qk=class{constructor(e="{{DATE}}.md",t=!1,n,i,o=!0){this.filePath=e;this.type="OpenFile";this.id=Er();this.openInNewTab=t,this.direction=n,this.location=i,this.focus=o,this.name=`Open file: ${this.filePath}`,this.applyLegacyFromLocation()}applyLegacyFromLocation(){if(this.location)switch(this.location){case"split":this.openInNewTab=!0,this.direction||(this.direction="vertical");break;case"tab":case"reuse":this.openInNewTab=!1,this.direction=void 0;break;default:this.openInNewTab=!0,this.direction=void 0;break}}};qt();Wc();Kr();function kde(){return{mode:"variable",variableName:"",operator:"isTruthy",valueType:"string"}}function Sde(r){return r.mode==="variable"?{...r}:{...r}}var Xk=class extends di{constructor(e){super(e?.name??"If condition","Conditional"),this.condition=e?.condition?Sde(e.condition):kde(),this.thenCommands=e?.thenCommands?[...e.thenCommands]:[],this.elseCommands=e?.elseCommands?[...e.elseCommands]:[]}};qc();Pi();var Dde=q(`<div class="qaDataUnreadable svelte-ktqmtm"><div class="qaDataUnreadableHead svelte-ktqmtm"><!> <span class="qaDataUnreadableTitle svelte-ktqmtm"> </span></div> <p class="qaDataUnreadableBody svelte-ktqmtm">The saved value isn't in a shape QuickAdd understands, so it can't be shown
or edited here. Nothing has been changed or deleted, and QuickAdd will not
overwrite it.</p> <p class="qaDataUnreadableBody svelte-ktqmtm">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
vault. Make a copy of that file before editing it.</p></div>`),Ide={hash:"svelte-ktqmtm",code:".qaDataUnreadable.svelte-ktqmtm {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaDataUnreadableHead.svelte-ktqmtm {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-ktqmtm {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-ktqmtm {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};function sO(r,e){ot(r,Ide);var t=Dde(),n=I(t),i=I(n);$t(i,{iconId:"alert-triangle",size:16});var o=_(i,2),s=I(o);S(o),S(n),Pn(4),S(t),de(()=>me(s,`QuickAdd couldn't read ${e.what??""}`)),$(r,t)}var sg=class{constructor(e){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=e.app,this.plugin=e.plugin,this.unreadable=Ii(e.commands),this.commandsRef=$$(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){return this.destroy(),this.containerEl=e,e.empty(),e.addClass("quickAddCommandEditor"),this.unreadable?(this.renderUnreadableCard(e),!1):this.renderCommandList(e)?(this.renderCommandBar(e),this.renderAddObsidianCommandSetting(e),this.renderAddEditorCommandSetting(e),this.renderAddUserScriptSetting(e),this.renderAddChoiceSetting(e),!0):!1}renderUnreadableCard(e){let t=e.createDiv("commandList");this.unreadableCardHandle=Wi(t,sO,{what:"this macro's commands"},{what:"this macro's commands"})}destroy(){this.commandListHandle?.destroy(),this.commandListHandle=null,this.commandListProps=null,this.unreadableCardHandle?.destroy(),this.unreadableCardHandle=null}loadObsidianCommands(){Object.keys(this.app.commands.commands).forEach(e=>{let t=this.app.commands.commands[e];this.obsidianCommands.push(new Fx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=jk(this.app)}renderCommandList(e){let t=e.createDiv("commandList");return this.commandListProps=FY({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw M.logError("command not found"),new Error("command not found");if(!await Xi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!await Ix(this.app,i)){new Mi.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(t,Y$,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){let t=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",Yh),this.addChoiceButton(t,"Template",od),this.addOpenFileCommandButton(t),this.addWaitCommandButton(t),this.addConditionalCommandButton(t),le.getState().disableOnlineFeatures||this.addAIAssistantCommandButton(t)}renderAddObsidianCommandSetting(e){let t,n=()=>{let i=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){M.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new Fx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};new Mi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Obsidian command"),new ii(this.app,i.inputEl,this.obsidianCommands.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}renderAddEditorCommandSetting(e){let t,n=()=>{let i=t.getValue(),o;switch(i){case"Copy":o=new Qh;break;case"Cut":o=new Xh;break;case"Paste":o=new Zh;break;case"Paste with format":o=new Jh;break;case"Select active line":o=new eg;break;case"Select link on active line":o=new tg;break;case"Move cursor to file start":o=new rg;break;case"Move cursor to file end":o=new ng;break;case"Move cursor to line start":o=new ig;break;case"Move cursor to line end":o=new og;break;default:throw M.logError("invalid editor command type"),new Error("invalid editor command type")}this.addCommand(o),t.setValue("")};new Mi.Setting(e).setName("Editor commands").setDesc("Add editor command").addDropdown(i=>{t=i,i.selectEl.addClass("qa-command-sequence-input"),i.addOption("","Select command").addOption("Copy","Copy").addOption("Cut","Cut").addOption("Paste","Paste").addOption("Paste with format","Paste with format").addOption("Select active line","Select active line").addOption("Select link on active line","Select link on active line").addOption("Move cursor to file start","Move cursor to file start").addOption("Move cursor to file end","Move cursor to file end").addOption("Move cursor to line start","Move cursor to line start").addOption("Move cursor to line end","Move cursor to line end")}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}renderAddUserScriptSetting(e){let t,n=null,i=async()=>{this.loadScriptCandidates();let o=t.getValue().trim();if(!o)return;let s=lp(o).basename??o,a=RY(this.app,this.scriptCandidates,s);if(!a){new Mi.Notice(`QuickAdd: No script or js-block note named "${o}" found.`);return}if(a.isMarkdown){let l=await Mx(this.app,a.file);if(l){new Mi.Notice(`QuickAdd: "${a.file.path}" \u2014 ${l}`);return}}this.addCommand(new Rx(o,a.file.path)),t.setValue(""),n&&n.buttonEl.addClass("qa-hidden")};new Mi.Setting(e).setName("User scripts").setDesc("Add a .js file or a note with a ```js code block - type the name or click Browse").addText(o=>{t=o,o.inputEl.addClass("qa-command-sequence-input"),o.setPlaceholder("Start typing script name..."),new ii(this.app,o.inputEl,this.scriptCandidates.map(s=>K$(s))),o.inputEl.addEventListener("keypress",s=>{s.key==="Enter"&&i()})}).addButton(o=>o.setButtonText("Browse").setTooltip("Browse and select a script (.js file or note)").onClick(async()=>{let s=await this.showScriptPicker();if(s){let a=s.isMarkdown?s.file.path:s.file.basename;this.addCommand(new Rx(a,s.file.path))}})).addButton(o=>{n=o,o.setButtonText("Add").setCta().onClick(()=>{i()}),o.buttonEl.addClass("qa-hidden")}),t.onChange(o=>{n&&n.buttonEl.toggleClass("qa-hidden",o.trim().length===0)})}renderAddChoiceSetting(e){let t,n=()=>{let i=t.getValue(),o=this.choices.find(s=>s.name===i);if(!o){new Mi.Notice(`QuickAdd: No choice named "${i}".`);return}this.addCommand(new Wk(o.name,o.id)),t.setValue("")};new Mi.Setting(e).setName("Choices").setDesc("Add existing choice").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Choice"),new ii(this.app,i.inputEl,this.choices.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}addChoiceButton(e,t,n){new Mi.ButtonComponent(e).setButtonText(t).setTooltip(`Add ${t} choice`).onClick(()=>{let o=new n(`Untitled ${t} Choice`);this.addCommand(new Hk(o))})}addOpenFileCommandButton(e){new Mi.ButtonComponent(e).setIcon("file-search").setTooltip("Add open file command").onClick(()=>{this.addCommand(new Qk)})}addAIAssistantCommandButton(e){new Mi.ButtonComponent(e).setIcon("bot").setTooltip("Add AI Assistant command").onClick(()=>{this.addCommand(new Kk)})}addWaitCommandButton(e){new Mi.ButtonComponent(e).setIcon("clock").setTooltip("Add wait command").onClick(()=>{this.addCommand(new zk(100))})}addConditionalCommandButton(e){new Mi.ButtonComponent(e).setIcon("git-branch").setTooltip("Add conditional command").onClick(()=>{this.addCommand(new Xk)})}async showScriptPicker(){if(this.loadScriptCandidates(),this.scriptCandidates.length===0)return Gk(this.app),null;let e=this.scriptCandidates.map(o=>o.file.path),t=this.scriptCandidates.map(o=>K$(o)),n=await ln.Suggest(this.app,t,e,{placeholder:"Select a script (.js file or note with a ```js block)",emptyStateText:"No scripts found in your vault"});if(!n)return null;let i=this.scriptCandidates.find(o=>o.file.path===n);if(!i)return null;if(i.isMarkdown){let o=await Mx(this.app,i.file);if(o)return new Mi.Notice(`QuickAdd: "${i.file.path}" \u2014 ${o}`),null}return i}addCommand(e){this.commandsRef=[...this.commandsRef,e],this.emitCommandsChanged()}emitCommandsChanged(){this.commandListProps&&(this.commandListProps.commands=[...this.commandsRef]),this.onCommandsChange?.(this.commandsRef)}};var pi=require("obsidian");Bm();sd();function NY(r){return r.mode==="variable"?{...r}:{...r}}function Pde(){return{mode:"variable",variableName:"",operator:"isTruthy",valueType:"boolean"}}function Fde(){return{mode:"script",scriptPath:""}}var Zk=class extends pi.Modal{constructor(t,n){super(t);this.isResolved=!1;this.scriptCandidates=[];this.originalCommand=n,this.workingCommand={...n,condition:NY(n.condition)},this.waitForClose=new Promise(i=>{this.resolvePromise=i}),this.loadScriptCandidates(),this.display(),this.open()}onClose(){super.onClose(),this.isResolved||this.resolve(null)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}loadScriptCandidates(){this.scriptCandidates=jk(this.app)}reload(){this.display()}display(){this.containerEl.addClass("quickAddModal","conditionalSettingsModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:"Configure conditional command"}).addClass("qa-modal-title"),this.renderModeSelector(),this.workingCommand.condition.mode==="variable"?this.renderVariableConfiguration(this.workingCommand.condition):this.renderScriptConfiguration(this.workingCommand.condition),this.renderButtonBar()}renderModeSelector(){new pi.Setting(this.contentEl).setName("Condition type").setDesc("Choose how this condition should be evaluated.").addDropdown(t=>{t.addOption("variable","Macro variable").addOption("script","Run script").setValue(this.workingCommand.condition.mode).onChange(n=>{n!==this.workingCommand.condition.mode&&(this.workingCommand.condition=n==="variable"?Pde():Fde(),this.reload())})})}renderVariableConfiguration(t){this.renderVariableNameSetting(t),this.renderOperatorSetting(t),this.renderValueTypeSetting(t),Bu(t.operator)&&this.renderExpectedValueSetting(t)}renderVariableNameSetting(t){new pi.Setting(this.contentEl).setName("Variable name").setDesc("Name of the macro variable to inspect (without the $ prefix).").addText(n=>n.setPlaceholder("e.g. projectStatus").setValue(t.variableName).onChange(i=>{t.variableName=i.trim()}))}renderOperatorSetting(t){let n=[{value:"equals",label:"Equals"},{value:"notEquals",label:"Does not equal"},{value:"lessThan",label:"Less than"},{value:"lessThanOrEqual",label:"Less than or equal"},{value:"greaterThan",label:"Greater than"},{value:"greaterThanOrEqual",label:"Greater than or equal"},{value:"contains",label:"Contains"},{value:"notContains",label:"Does not contain"},{value:"isTruthy",label:"Is truthy"},{value:"isFalsy",label:"Is falsy"}];new pi.Setting(this.contentEl).setName("Operator").setDesc("How to compare the variable value.").addDropdown(i=>{i.addOptions(n.reduce((o,s)=>(o[s.value]=s.label,o),{})),i.setValue(t.operator),i.onChange(o=>{t.operator=o,t.valueType=Dq(t.operator),Bu(t.operator)||delete t.expectedValue,this.reload()})})}renderValueTypeSetting(t){new pi.Setting(this.contentEl).setName("Value type").setDesc("How to interpret the comparison value.").addDropdown(n=>{n.addOption("string","Text").addOption("number","Number").addOption("boolean","Boolean").setValue(t.valueType).onChange(i=>{t.valueType=i,this.reload()})})}renderExpectedValueSetting(t){if(t.valueType==="boolean"){new pi.Setting(this.contentEl).setName("Expected value").setDesc("Choose true or false.").addDropdown(n=>{n.addOption("true","True").addOption("false","False").setValue(t.expectedValue??"true").onChange(i=>{t.expectedValue=i})});return}new pi.Setting(this.contentEl).setName("Expected value").setDesc("Value to compare against.").addText(n=>{n.setPlaceholder("Enter comparison value").setValue(t.expectedValue??"").onChange(i=>{t.expectedValue=i})})}renderScriptConfiguration(t){this.renderScriptPathSetting(t),this.renderScriptExportSetting(t)}renderScriptPathSetting(t){let n;new pi.Setting(this.contentEl).setName("Script path").setDesc("Vault-relative path to a .js file or a note with a ```js code block.").addText(i=>{n=i,i.setPlaceholder("scripts/myCheck.js or Notes/myCheck.md").setValue(t.scriptPath).onChange(o=>{t.scriptPath=o.trim()})}).addButton(i=>i.setButtonText("Browse").setTooltip("Select a script (.js file or note)").onClick(async()=>{if(this.loadScriptCandidates(),this.scriptCandidates.length===0){Gk(this.app);return}let o=this.scriptCandidates.map(l=>l.file.path),s=await ln.Suggest(this.app,o,o,{placeholder:"Select a script (.js file or note with a ```js block)",emptyStateText:"No scripts found in your vault"});if(!s)return;let a=this.scriptCandidates.find(l=>l.file.path===s);if(a?.isMarkdown){let l=await Mx(this.app,a.file);if(l){new pi.Notice(`QuickAdd: "${a.file.path}" \u2014 ${l}`);return}}t.scriptPath=s,n.setValue(s)}))}renderScriptExportSetting(t){new pi.Setting(this.contentEl).setName("Export name").setDesc("Optional export or member to call (use :: to access nested members).").addText(n=>n.setPlaceholder("default").setValue(t.exportName??"").onChange(i=>{t.exportName=i.trim()||void 0}))}renderButtonBar(){let t=this.contentEl.createDiv({cls:"qa-command-button-row"});new pi.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.resolve(null),this.close()}),new pi.ButtonComponent(t).setCta().setButtonText("Save").onClick(()=>{this.validateCondition()&&(this.applyChanges(),this.resolve(this.originalCommand),this.close())})}validateCondition(){let t=this.workingCommand.condition;return t.mode==="variable"?t.variableName.trim()?!0:(new pi.Notice("QuickAdd: Enter a variable name before saving."),!1):t.scriptPath.trim()?!0:(new pi.Notice("QuickAdd: Enter a script path before saving."),!1)}applyChanges(){this.originalCommand.condition=NY(this.workingCommand.condition);let t=Lm(this.originalCommand.condition);this.originalCommand.name=`If ${t}`}};var ag=require("obsidian");yi();Pi();var Jk=class extends ag.Modal{constructor(t){super(t.app);this.commandEditor=null;this.isResolved=!1;this.plugin=t.plugin,this.choices=t.choices,this.conditionalHandlers=t.conditionalHandlers,this.workingCommands=vt(t.commands),this.waitForClose=new Promise(n=>{this.resolvePromise=n}),this.display(t.title),this.open()}onClose(){super.onClose(),this.commandEditor?.destroy(),this.isResolved||this.resolve(null)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}display(t){this.containerEl.addClass("quickAddModal","conditionalBranchModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:t}).addClass("qa-modal-title");let i=this.contentEl.createDiv("branchCommandEditor");this.commandEditor=new sg({app:this.app,plugin:this.plugin,commands:this.workingCommands,choices:this.choices,onCommandsChange:s=>{this.workingCommands=s},conditionalHandlers:this.conditionalHandlers});let o=this.commandEditor.render(i);this.renderButtonBar(o)}renderButtonBar(t){let n=this.contentEl.createDiv({cls:"qa-command-button-row"});if(!t){new ag.ButtonComponent(n).setCta().setButtonText("Close").onClick(()=>{this.resolve(null),this.close()});return}new ag.ButtonComponent(n).setButtonText("Cancel").onClick(()=>{this.resolve(null),this.close()}),new ag.ButtonComponent(n).setCta().setButtonText("Save").onClick(()=>{this.resolve(Ir(this.workingCommands)),this.close()})}};var eS=require("obsidian");Wt();ka();function Mde(r){let e=r.trim();return e||void 0}function Rde(r){return(typeof r.icon=="string"?r.icon.trim():"")||xm(r.type)}function tS(r,e,t,n){let i=xm(t.type),o=new eS.Setting(e).setName("Icon").setDesc(`Lucide/Obsidian icon id. Leave empty to use ${i}.`);o.settingEl.addClass("qa-choice-icon-setting");let s=xr(e,"span");s.classList.add("qa-choice-icon-setting-preview"),s.setAttribute("aria-hidden","true"),o.controlEl.appendChild(s);function a(){s.replaceChildren(),(0,eS.setIcon)(s,Rde(t))}o.addText(l=>{l.setPlaceholder(i),l.setValue(typeof t.icon=="string"?t.icon:""),l.inputEl.addClass("qa-choice-icon-input"),l.inputEl.setAttribute("aria-label","Choice icon"),new ii(r,l.inputEl,tk,50),l.onChange(c=>{let u=Mde(c);t.icon=u,n(u),a()})}),a()}Wt();Pi();bl();function $de(r){let e=[],t=n=>{n.forEach(i=>{Ye(i)&&(i.type==="Multi"?t(st(i)):e.push(i))})};return t(gn(r)),e}var rS=class extends nS.Modal{constructor(t,n,i,o){super(t);this.choices=[];this.commandEditor=null;this.choice=i,this.macro=i.macro,this.choices=$de(o),this.plugin=n,this.waitForClose=new Promise(s=>{this.resolvePromise=s}),this.display(),rk(this,"macro"),this.open()}onClose(){super.onClose(),this.resolvePromise(this.choice),this.commandEditor?.destroy(),this.commandEditor=null}display(){this.containerEl.addClass("quickAddModal","macroBuilder"),this.contentEl.empty(),this.addCenteredHeader(this.choice.name),this.addCommandEditor(),this.addRunOnStartupSetting(),this.addIconSetting()}addCenteredHeader(t){let n=this.contentEl.createEl("h2");n.addClass("qa-clickable-modal-title"),n.createEl("button",{cls:"qa-rename-title-button",text:t,attr:{type:"button","aria-label":`Rename ${t}`}}).addEventListener("click",()=>{(async()=>{try{let o=await Dr.Prompt(this.app,`Update name for ${this.choice.name}`,this.choice.name,this.choice.name);if(!o)return;this.choice.name=o,nd(this.macro)&&(this.macro.name=o),this.reload()}catch{}})()})}addRunOnStartupSetting(){new nS.Setting(this.contentEl).setName("Run on startup").setDesc("Execute this macro when Obsidian starts").addToggle(t=>t.setValue(this.choice.runOnStartup).onChange(n=>{this.choice.runOnStartup=n}))}addIconSetting(){tS(this.app,this.contentEl,this.choice,t=>{this.choice.icon=t})}reload(){this.commandEditor?.destroy(),this.commandEditor=null,this.display()}macroCommandsValue(){return zn(this.macro)}setMacroCommands(t){if(!nd(this.macro)){this.macro={id:Er(),name:this.choice.name,commands:t},this.choice.macro=this.macro;return}this.macro.commands=t}addCommandEditor(){let t=this.contentEl.createDiv("macroBuilder__editor");this.commandEditor=new sg({app:this.app,plugin:this.plugin,commands:this.macroCommandsValue(),choices:this.choices,onCommandsChange:n=>{this.setMacroCommands(n)},conditionalHandlers:this.buildConditionalHandlers()}),this.commandEditor.render(t)}buildConditionalHandlers(){return{configureCondition:t=>this.configureConditionalCondition(t),editThenBranch:t=>this.configureConditionalBranch(t,"then"),editElseBranch:t=>this.configureConditionalBranch(t,"else")}}async configureConditionalCondition(t){return await new Zk(this.app,t).waitForClose!==null}async configureConditionalBranch(t,n){let i=n==="then"?"Then branch":"Else branch",s=await new Jk({app:this.app,plugin:this.plugin,choices:this.choices,title:`Edit ${i} commands`,commands:n==="then"?t.thenCommands:t.elseCommands,conditionalHandlers:this.buildConditionalHandlers()}).waitForClose;return s?(n==="then"?t.thenCommands=s:t.elseCommands=s,!0):!1}};var ad=require("obsidian");Hr();var iS=class extends ad.Modal{constructor(t,n){super(t);this.choice=n;this.didSubmit=!1;this.name=n.name,this.placeholder=n.placeholder??"",this.icon=typeof n.icon=="string"?n.icon:void 0,this.waitForClose=new Promise((i,o)=>{this.resolvePromise=i,this.rejectPromise=o}),this.containerEl.addClass("quickAddModal","qaMultiChoiceSettingsModal"),this.display(),this.open()}display(){this.contentEl.empty(),this.titleEl.setText("Edit folder"),new ad.Setting(this.contentEl).setName("Name").addText(n=>{n.setValue(this.name).onChange(i=>{this.name=i})}),new ad.Setting(this.contentEl).setName("Placeholder").setDesc("Shown in the choice picker search box when this folder opens. Leave blank to use the folder name.").addText(n=>{n.setPlaceholder("Defaults to the folder name"),n.setValue(this.placeholder).onChange(i=>{this.placeholder=i})}),tS(this.app,this.contentEl,{type:this.choice.type,icon:this.icon},n=>{this.icon=n});let t=this.contentEl.createDiv();new ad.ButtonComponent(t).setButtonText("Save").setCta().onClick(()=>this.submit()),new ad.ButtonComponent(t).setButtonText("Cancel").onClick(()=>this.cancel()),t.addClass("qa-modal-button-row")}submit(){this.didSubmit||(this.didSubmit=!0,this.close())}cancel(){this.close()}onClose(){if(super.onClose(),!this.didSubmit){this.rejectPromise(rn());return}let t=this.placeholder.trim(),n={...this.choice,name:this.name.trim()||this.choice.name,placeholder:t||void 0,icon:this.icon};this.resolvePromise(n)}};Pt();bl();var oS=class{constructor(e){this.name=e,this.id=Er(),this.commands=[]}};var lg=class extends Bl{constructor(t){super(t,"Macro");this.runOnStartup=!1;this.macro=new oS(t)}};var cg=class extends Bl{constructor(t){super(t,"Multi");this.choices=[];this.collapsed=!1}addChoice(t){return this.choices.push(t),this}addChoices(t){return this.choices.push(...t),this}};Pi();Wt();yi();function aO(r,e){let t=vt(r);for(let n of e)delete t[n];return t}yi();qc();Me();_c();var Ode={Template:od,Capture:Yh,Macro:lg,Multi:cg};function cO(r,e){let t=Ode[r];if(!t)throw new Error(`Unknown choice type: ${r}`);return new t(e)}function BY(r,e){let t=cO(r.type,`${r.name} (copy)`);if(r.type==="Multi"){let n=t,i=r;return Object.assign(n,aO(i,["id","name","choices"])),Tc(i)?n.choices=st(i).filter(Ye).map(o=>BY(o,e)):n.choices=i.choices,n}return Object.assign(t,aO(r,["id","name"])),r.type==="Macro"&&(t.macro=vt(r.macro),dY(t.macro),Wh(t,e)),t}async function VY(r,e){let t=await Nde(e,r);return BY(r,{secretOptionNamesByPath:t,stripUnknownStringSettings:!0})}function UY(r){return r!==null&&typeof r=="object"}function lO(r,e){if(UY(r)){if(r.type==="UserScript"&&typeof r.path=="string"&&e.add(r.path),Array.isArray(r.thenCommands))for(let t of r.thenCommands)lO(t,e);if(Array.isArray(r.elseCommands))for(let t of r.elseCommands)lO(t,e);uO(r.choice,e)}}function uO(r,e){if(UY(r)){if(r.type==="Macro"){let t=zn(r.macro);if(Array.isArray(t))for(let n of t)lO(n,e)}if(r.type==="Multi"&&Array.isArray(r.choices))for(let t of r.choices)uO(t,e)}}async function Nde(r,e){let t=new Set;uO(e,t);let n=new Map;for(let i of t)try{if(Un(i)||!await r.vault.adapter.exists(i))continue;let s=Vh(await r.vault.adapter.read(i),i);n.set(i,s.foundSecretOptions&&s.names.size===0?null:s.names)}catch(o){M.logWarning(`QuickAdd could not inspect user-script settings '${i}' while duplicating choice: ${o?.message??o}`)}return n}function Lde(r,e,t){let i={Template:()=>new kh(e,r,t),Capture:()=>new _h(e,r,t),Macro:()=>new rS(e,t,r,le.getState().choices),Multi:()=>{}}[r.type];return typeof i=="function"?i():void 0}async function qY(r,e){let t=r.type==="Multi",n=r.type==="Macro",i=l=>{if(js(l))return"QuickAdd couldn't read this folder's contents. Deleting it also deletes whatever is still stored under it in data.json.";let c=Vn(st(l));if(c.length===0)return"";let u=c.filter(p=>p.type==="Multi").length,d=c.length-u,f=[];return d>0&&f.push(`${d} ${d===1?"choice":"choices"}`),u>0&&f.push(`${u} ${u===1?"folder":"folders"}`),`Deleting this folder will also delete everything inside it: ${f.join(" and ")}.`},o=l=>Ii(zn(l.macro))?"QuickAdd couldn't read this macro's commands. Deleting it also deletes whatever is still stored under it in data.json.":"Deleting this choice will also delete its macro commands.",s=[`Are you sure you want to delete '${r.name}'?`,t?i(r):"",n?o(r):""].filter(Boolean).join(" ");return await Xi.Prompt(e,`Delete ${Fm(r.type)}`,s)?(n||t)&&!await Ix(e,{type:"NestedChoice",choice:r})?(new LY.Notice(`Could not clear user script secrets. The ${Fm(r.type)} was not deleted.`),!1):!0:!1}async function WY(r,e,t){if(r.type==="Multi")try{return await new iS(e,r).waitForClose}catch{return}let n=Lde(r,e,t);if(!n)throw new Error("Invalid choice type");return await n.waitForClose}function zY(r){return{...r,command:!r.command}}var sS=class{constructor(e){this.plugin=e}enableCommand(e){this.plugin.addCommandForChoice(e)}disableCommand(e,t){t?this.plugin.removeCommandForChoice(e,t):this.plugin.removeCommandForChoice(e)}updateCommand(e,t){this.plugin.removeCommandForChoice(e),this.plugin.addCommandForChoice(t)}};function HY(r,e,t){if(!e||!t)return r;let n=$x(r,e),i=$x(r,t);if(!n||!i||i.type!=="Multi"||n.type==="Multi"&&(n.id===i.id||Bde(n).has(i.id)))return r;let{updated:o,removed:s}=Ox(r,e);return s?dO(o,t,s)??r:r}function jY(r,e){if(!e||r.some(i=>Ye(i)&&i.id===e))return r;let{updated:t,removed:n}=Ox(r,e);return n?[...t,n]:r}function $x(r,e){for(let t of r){if(!Ye(t))continue;if(t.id===e)return t;let n=$x(st(t),e);if(n)return n}}function Bde(r){let e=new Set,t=n=>{Ye(n)&&(e.add(n.id),st(n).forEach(t))};return st(r).forEach(t),e}function Ox(r,e){let t;return{updated:r.map(i=>{if(!Ye(i))return i;if(i.id===e){t=i;return}if(!Tc(i))return i;let o=Ox(st(i),e);return o.removed&&(t=o.removed),o.removed?{...i,choices:o.updated}:i}).filter(Boolean),removed:t}}function dO(r,e,t){let n=!1,i=r.map(o=>{if(!Ye(o))return o;if(o.id===e&&o.type==="Multi"){if(js(o))return o;n=!0;let a=o;return{...a,choices:[...st(a),t]}}if(!Tc(o))return o;let s=dO(st(o),e,t);return s?(n=!0,{...o,choices:s}):o});return n?i:void 0}function pO(r,e,t){let n=r.findIndex(s=>Ye(s)&&s.id===e);if(n!==-1){let s=[...r];return s.splice(n+1,0,t),s}let i=!1,o=r.map(s=>{if(!Ye(s)||!Tc(s))return s;let a=pO(st(s),e,t);return a?(i=!0,{...s,choices:a}):s});return i?o:void 0}function GY(r,e,t){if(!t)return[...r,e];let n=dO(r,t,e)??[...r,e];return Vde(n,t)}function fO(r,e,t){return r.map(n=>{if(!Ye(n)||n.type!=="Multi")return n;let i=n;return i.id===e?t(i):Tc(i)?{...i,choices:fO(st(i),e,t)}:n})}function mO(r,e,t){return fO(r,e,n=>({...n,collapsed:t}))}function Vde(r,e){return mO(r,e,!1)}function YY(r,e,t){return fO(r,e,n=>({...n,choices:t}))}var KY=require("obsidian");Wt();var hO="quickadd:move-to-root";function Ude(r,e){let t=gn(e);if(t.some(i=>Ye(i)&&i.id===r.id))return!1;let n=i=>{for(let o of i){if(!Ye(o))continue;let s=st(o);if(s.some(a=>a?.id===r.id)||n(s))return!0}return!1};return n(t)}function qde(r,e){let t=[],n=Array.isArray(e)?e:[],i=(o,s=[])=>{for(let a of o){if(!Ye(a))continue;let l=a.name??"";if(a.type==="Multi"){let c=[...s,l];Wde(r,a)||t.push({id:a.id,path:c.join(" / ")}),i(st(a),[...s,l])}}};return i(n,[]),t}function Wde(r,e){if(e.type!=="Multi"||r.id===e.id||js(e))return!0;if(r.type==="Multi"){let t=new Set,n=i=>{Ye(i)&&(t.add(i.id),st(i).forEach(n))};if(st(r).forEach(n),t.has(e.id))return!0}return!1}function QY(r,e,t,n){let i=new KY.Menu;i.addItem(s=>s.setTitle(e.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(),Ude(e,t)&&i.addItem(s=>s.setTitle("Move to: (root)").setIcon("folder-up").onClick(()=>n.onMove(hO)));let o=qde(e,t);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 aS(r,e,t,n,i){e.preventDefault(),QY(r,t,n,i).showAtMouseEvent(e)}function lS(r,e,t,n,i){let o=e.getBoundingClientRect();QY(r,t,n,i).showAtPosition({x:o.left,y:o.bottom})}var Ha=require("obsidian");var Pr=require("obsidian");ts();var XY=require("obsidian");Pt();var cS=null,zde=1440*60*1e3;async function gO(){if(cS&&Date.now()-cS.fetchedAt<zde)return cS.data;if(le.getState().disableOnlineFeatures)throw new Error("Fetching models directory is disabled: Online features are turned off.");let e=await(await(0,XY.requestUrl)({url:"https://models.dev/api.json",method:"GET"})).json;return cS={data:e,fetchedAt:Date.now()},e}function Hde(r){for(let e of[r,`https://${r}`])try{let t=new URL(e).hostname.toLowerCase();if(t)return t}catch{}return""}function Nx(r){let e=r.toLowerCase(),t=Hde(r),n=i=>t===i||t.endsWith(`.${i}`);return n("openai.com")?"openai":n("openrouter.ai")?"openrouter":n("generativelanguage.googleapis.com")?"google":e.includes("anthropic")?"anthropic":n("groq.com")?"groq":n("together.ai")||n("together.xyz")?"togetherai":e.includes("huggingface")?"huggingface":e.includes("github")&&e.includes("models")?"github-models":e.includes("bedrock")||e.includes("aws")?"amazon-bedrock":e.includes("modelscope")?"modelscope":e.includes("dashscope")?"alibaba":n("fireworks.ai")?"fireworks-ai":e.includes("vercel")?"vercel":n("inference.net")?"inference":n("z.ai")||e.includes("zhipu")?"zhipuai":n("deepseek.com")?"deepseek":n("mistral.ai")?"mistral":e.includes("cerebras")?"cerebras":n("venice.ai")?"venice":n("upstage.ai")?"upstage":n("llama.com")?"llama":e.includes("morphllm")?"morph":n("inceptionlabs.ai")?"inception":e.includes("deepinfra")?"deepinfra":n("opencode.ai")?"opencode":n("inference.wandb.ai")?"wandb":n("githubcopilot.com")?"github-copilot":null}function jde(r){let e=r.modalities?.output;if(Array.isArray(e)&&!e.includes("text"))return!1;let t=r.limit??{};if(typeof t.context=="number"&&t.context<=0||typeof t.output=="number"&&t.output<=1)return!1;let n=(r.family??"").toLowerCase(),i=r.id.toLowerCase();return!(n.includes("embedding")||i.includes("embedding"))}function ZY(r){return r.filter(jde).map(e=>{let t={name:e.id,maxTokens:Math.max(1,Math.floor(e.limit?.context??128e3))};return typeof e.limit?.output=="number"&&e.limit.output>0&&(t.maxOutputTokens=Math.floor(e.limit.output)),typeof e.temperature=="boolean"&&(t.supportsTemperature=e.temperature),t})}async function JY(r,e){let t=Nx(r);if(!t)return e;let n;try{n=await gO()}catch{return e}let i=n[t]?.models;return i?e.map(o=>{let s=i[o.name];if(!s)return o;let a={...o};return typeof s.limit?.context=="number"&&s.limit.context>0&&(a.maxTokens=Math.floor(s.limit.context)),a.maxOutputTokens===void 0&&typeof s.limit?.output=="number"&&s.limit.output>0&&(a.maxOutputTokens=Math.floor(s.limit.output)),a.supportsTemperature===void 0&&typeof s.temperature=="boolean"&&(a.supportsTemperature=s.temperature),a}):e}function Lx(r,e){let t=new Map(e.map(s=>[s.name,s])),n=r.map(s=>{let a=t.get(s.name);return a?{...s,maxTokens:a.maxTokens,maxOutputTokens:a.maxOutputTokens??s.maxOutputTokens,supportsTemperature:a.supportsTemperature??s.supportsTemperature}:s}),i=new Set(r.map(s=>s.name)),o=e.filter(s=>!i.has(s.name));return n.concat(o)}Me();Pt();var i4=require("obsidian");ts();Vx();Pt();var pS=128e3;async function fS(r,e){let t=r.modelSource??"providerApi";if(t==="modelsDev")return r4(r);if(t==="providerApi")return n4(r,e);try{return await n4(r,e)}catch(n){if(!Nx(r.endpoint))throw n;return r4(r,n)}}async function r4(r,e){try{let t=await gO(),n=Nx(r.endpoint);if(!n||!(n in t))throw new Error(`models.dev does not list a provider that matches ${r.endpoint}.`);let i=Object.values(t[n].models);return ZY(i)}catch(t){throw e?new Error(`Provider API failed (${e.message}). Fallback to models.dev also failed: ${t.message}`):t}}async function n4(r,e){let{disableOnlineFeatures:t}=le.getState();if(t)throw new Error("Online features are disabled \u2014 enable them to browse provider models.");if(!r.endpoint)throw new Error("Provider is missing an endpoint URL.");let n=e??r.apiKey??"",i=Wv(r),o=i==="anthropic"?await tpe(r,n):i==="gemini"?await rpe(r,n):await epe(r,n);if(!o.length)throw new Error("The provider's models endpoint did not include any usable models.");let s=await JY(r.endpoint,o);return Zde(r.endpoint,s)}function Zde(r,e){let t=Nx(r);if(t!=="openai"&&t!=="google"&&t!=="anthropic")return e;let n=new Map(zv[t].map(i=>[i.name,i]));return e.map(i=>{let o=n.get(i.name);return o?{...i,maxTokens:i.maxTokens===pS?o.maxTokens:i.maxTokens,maxOutputTokens:i.maxOutputTokens??o.maxOutputTokens,supportsTemperature:i.supportsTemperature??o.supportsTemperature}:i})}async function vO(r,e,t){try{let n=await(0,i4.requestUrl)({url:e,headers:t,throw:!1});if(n.status>=400)throw dS(r.name,n);return await n.json}catch(n){throw new Error(`Provider rejected the models request: ${n.message}`)}}var Jde=/(whisper|-tts|tts-|embed|dall-e|image|moderation|transcribe|realtime|rerank)/i;async function epe(r,e){let t=r.endpoint.replace(/\/+$/,""),n=t.endsWith("/v1")?`${t}/models`:`${t}/v1/models`,i={};e&&(i.Authorization=`Bearer ${e}`);let o=await vO(r,n,i),s=npe(o),a=[];for(let l of s){let c=ipe(l);c&&!Jde.test(c.name)&&a.push(c)}return a}async function tpe(r,e){let t=r.endpoint.replace(/\/+$/,""),n={"anthropic-version":"2023-06-01"};e&&(n["x-api-key"]=e);let i=[],o=null;for(let s=0;s<10;s++){let a=`${t}/v1/models?limit=1000`+(o?`&after_id=${encodeURIComponent(o)}`:""),l=await vO(r,a,n);for(let c of l.data??[])c.id&&i.push({name:c.id,maxTokens:pS});if(!l.has_more||!l.last_id)break;o=l.last_id}return i}async function rpe(r,e){let t=r.endpoint.replace(/\/+$/,""),n={};e&&(n["x-goog-api-key"]=e);let i=[],o=null;for(let s=0;s<10;s++){let a=`${t}/v1beta/models?pageSize=1000`+(o?`&pageToken=${encodeURIComponent(o)}`:""),l=await vO(r,a,n);for(let c of l.models??[]){if(!c.name)continue;let u=c.supportedGenerationMethods;if(Array.isArray(u)&&!u.includes("generateContent"))continue;let d={name:c.name.replace(/^models\//,""),maxTokens:typeof c.inputTokenLimit=="number"&&c.inputTokenLimit>0?c.inputTokenLimit:pS};typeof c.outputTokenLimit=="number"&&c.outputTokenLimit>0&&(d.maxOutputTokens=c.outputTokenLimit),i.push(d)}if(!l.nextPageToken)break;o=l.nextPageToken}return i}function npe(r){if(Array.isArray(r))return r;if(r&&typeof r=="object"&&Array.isArray(r.data))return r.data;throw new Error("The provider's models response was not a list.")}function ipe(r){let e=r.id??r.name;return e?{name:e,maxTokens:ope(r)}:null}function ope(r){let e=[r.context_length,r.contextLength,r.context_tokens,r.max_context_tokens,r.max_context_length,r.max_input_tokens,r.max_tokens,r.limit?.context];for(let t of e){let n=spe(t);if(n&&n>0)return Math.floor(n)}return pS}function spe(r){if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let e=Number(r);if(Number.isFinite(e))return e}return null}ef();var upe=1440*60*1e3;function dpe(r,e){let t=new Map(r.map(i=>[i.name,JSON.stringify(i)])),n=0;for(let i of e){let o=t.get(i.name);o!==void 0&&o!==JSON.stringify(i)&&(n+=1)}return n}async function ug(r,e){let t=await za(r,e),n=await fS(e,t),i=e.models;return e.models=Lx(e.models,n),{added:e.models.length-i.length,updated:dpe(i,e.models)}}function a4(r){return`${(r.name??"").trim().toLowerCase()}\0${(r.endpoint??"").trim().toLowerCase().replace(/\/+$/,"")}`}async function l4(r,e={}){let t=le.getState();if(t.disableOnlineFeatures)return[];let n=t.ai.providers.filter(l=>l.autoSyncModels);if(n.length===0)return[];let i=t.ai.lastModelAutoSyncAt??0;if(!e.ignoreThrottle&&Date.now()-i<upe)return[];let o=[],s=new Map;for(let l of n){let c={...l,models:l.models.map(u=>({...u}))};try{let{added:u,updated:d}=await ug(r,c);o.push({provider:c.name,added:u,updated:d}),s.set(a4(c),c)}catch(u){o.push({provider:c.name,added:0,updated:0,error:u.message??String(u)})}}let a=o.some(l=>!l.error);le.setState(l=>({...l,ai:{...l.ai,providers:l.ai.providers.map(c=>{let u=s.get(a4(c));return u?{...c,models:Lx(c.models,u.models)}:c}),lastModelAutoSyncAt:a?Date.now():l.ai.lastModelAutoSyncAt}}));for(let l of o)l.error?M.logMessage(`[Model auto-sync] ${l.provider}: failed (${l.error})`):(l.added>0||l.updated>0)&&M.logMessage(`[Model auto-sync] ${l.provider}: ${l.added} new model(s), ${l.updated} updated.`);return o}Pt();var Vl=require("obsidian");ef();var mS=class extends Vl.Modal{constructor(t,n){super(t);this.allModels=[];this.filtered=[];this.selectedIds=new Set;this.mode="add";this.resolved=!1;this.loadError=null;this.provider=n,this.waitForClose=new Promise((i,o)=>{this.resolvePromise=i,this.rejectPromise=o}),this.open(),this.loadData().then(()=>this.display())}async loadData(){try{let t=await za(this.app,this.provider);this.allModels=await fS(this.provider,t),this.filtered=this.allModels.slice(),this.loadError=null}catch(t){this.loadError=`${t.message??t}`,new Vl.Notice(`Failed to load model directory: ${this.loadError}`)}}display(){this.contentEl.empty(),this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.contentEl.createEl("h2",{text:`Browse models for ${this.provider.name}`,cls:"qa-modal-title"}),new Vl.Setting(this.contentEl).setName("Search").addText(t=>{t.setPlaceholder("Filter by name").onChange(n=>{let i=n.trim().toLowerCase();this.filtered=this.allModels.filter(o=>o.name.toLowerCase().includes(i)),this.renderList()})}).addExtraButton(t=>{t.setIcon("check"),t.setTooltip("Select all"),t.onClick(()=>{this.filtered.forEach(n=>this.selectedIds.add(n.name)),this.renderList()})}).addExtraButton(t=>{t.setIcon("x"),t.setTooltip("Clear selection"),t.onClick(()=>{this.selectedIds.clear(),this.renderList()})}),new Vl.Setting(this.contentEl).setName("Import mode").setDesc("Add will append new models. Replace will overwrite existing models with the selected list.").addDropdown(t=>{t.addOption("add","Add only"),t.addOption("replace","Replace existing"),t.setValue(this.mode),t.onChange(n=>this.mode=n)}).addButton(t=>{t.setButtonText("Import selected").setCta().onClick(()=>this.importSelected())}),this.contentEl.createDiv({cls:"qa-model-directory"}),this.renderList()}renderList(){let t=this.contentEl.querySelector(".qa-model-directory");if(t){if(t.empty(),this.filtered.length===0){let n=this.loadError?`Couldn't load models: ${this.loadError}. Check the API key and endpoint.`:this.allModels.length===0?"No models available for this provider.":"No models match your filter.";t.createDiv({text:n,cls:"qa-model-directory-empty"});return}for(let n of this.filtered){let i=t.createEl("label",{cls:"qa-model-row"}),o=this.contentEl.ownerDocument.createElement("input");o.type="checkbox",o.checked=this.selectedIds.has(n.name),o.onchange=()=>{o.checked?this.selectedIds.add(n.name):this.selectedIds.delete(n.name)},i.appendChild(o),i.createDiv({text:n.name,cls:"qa-model-row-title"}),i.createDiv({text:`${n.maxTokens.toLocaleString()} tokens max`,cls:"qa-model-row-meta"})}}}importSelected(){if(this.selectedIds.size===0){new Vl.Notice("Select at least one model.");return}try{let n=this.allModels.filter(i=>this.selectedIds.has(i.name)).map(i=>({...i}));if(!n.length){new Vl.Notice("No models selected to import.");return}this.resolved=!0,this.resolvePromise({imported:n,mode:this.mode}),this.close()}catch(t){new Vl.Notice(`Import failed: ${t.message??t}`)}}onClose(){this.resolved||this.resolvePromise(null),super.onClose()}};yi();$a();var eo=require("obsidian");ts();var c4=[{id:"openai",name:"OpenAI",endpoint:"https://api.openai.com/v1",doc:"https://platform.openai.com/docs/models",kind:"openai",modelSource:"modelsDev",seedKey:"openai"},{id:"gemini",name:"Gemini",endpoint:"https://generativelanguage.googleapis.com",doc:"https://ai.google.dev/gemini-api/docs",kind:"gemini",modelSource:"auto",seedKey:"google"},{id:"anthropic",name:"Anthropic",endpoint:"https://api.anthropic.com",doc:"https://docs.anthropic.com/",kind:"anthropic",modelSource:"auto",seedKey:"anthropic"},{id:"groq",name:"Groq",endpoint:"https://api.groq.com/openai/v1",doc:"https://console.groq.com/docs/models",kind:"openai",modelSource:"auto"},{id:"togetherai",name:"TogetherAI",endpoint:"https://api.together.xyz/v1",doc:"https://docs.together.ai/docs/serverless-models",kind:"openai",modelSource:"auto"},{id:"openrouter",name:"OpenRouter",endpoint:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models",kind:"openai",modelSource:"auto"},{id:"hugging-face",name:"Hugging Face",endpoint:"https://router.huggingface.co/v1",doc:"https://huggingface.co/docs/inference-providers",kind:"openai",modelSource:"auto"},{id:"mistral",name:"Mistral",endpoint:"https://api.mistral.ai/v1",doc:"https://docs.mistral.ai/getting-started/models/",kind:"openai",modelSource:"auto"},{id:"deepseek",name:"DeepSeek",endpoint:"https://api.deepseek.com",doc:"https://platform.deepseek.com/api-docs/",kind:"openai",modelSource:"auto"}];var hS=class extends eo.Modal{constructor(e,t){super(e),this.providers=t,this.waitForClose=new Promise((n,i)=>{this.resolvePromise=n,this.rejectPromise=i}),this.open(),this.display()}addHeader(e){e.createEl("h2",{text:"Add a provider",cls:"qa-modal-title"})}display(){this.contentEl.empty(),this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.addHeader(this.contentEl);let e=this.contentEl.createDiv({cls:"qa-provider-grid"});for(let t of c4){let n=e.createDiv({cls:"qa-provider-card"});if(n.createEl("div",{text:t.name,cls:"qa-provider-card-title"}),n.createEl("div",{text:t.endpoint,cls:"qa-provider-card-endpoint"}),t.doc){let s=n.createEl("a",{text:"Docs",href:t.doc});s.target="_blank",s.rel="noopener noreferrer"}let i="",o=new eo.Setting(n).setName("API key").setDesc("Select a secret from SecretStorage").addComponent(s=>new eo.SecretComponent(this.app,s).setValue(i).onChange(a=>{i=a}));o.settingEl.addClass("qa-provider-api-setting"),o.addButton(s=>{s.setButtonText("Connect").setCta().onClick(async()=>{try{let a=i.trim();try{new URL(t.endpoint)}catch{new eo.Notice(`Invalid endpoint URL for ${t.name}.`);return}let l=t.endpoint.toLowerCase();if(["openai.com","generativelanguage.googleapis.com","anthropic","api.groq.com","together.xyz","openrouter.ai","router.huggingface.co","api.mistral.ai","api.deepseek.com"].some(m=>l.includes(m))&&!a){new eo.Notice(`${t.name} requires an API key.`);return}let u=m=>m.trim().toLowerCase(),d=m=>m.trim().toLowerCase().replace(/\/+$/,"");if(this.providers.some(m=>u(m.name)===u(t.name)&&d(m.endpoint)===d(t.endpoint))){new eo.Notice(`${t.name} is already configured.`);return}let p={name:t.name,endpoint:t.endpoint,id:PT(t.id,this.providers),kind:t.kind,apiKey:"",apiKeyRef:a,models:[],modelSource:t.modelSource??"auto",autoSyncModels:!0};s.setButtonText("Connecting..."),s.setDisabled(!0),await this.importInitialModels(p,t),this.providers.push(p),this.close()}catch(a){s.setButtonText("Connect"),s.setDisabled(!1),new eo.Notice(`Failed to add provider: ${a.message??a}`)}})})}new eo.Setting(this.contentEl).setName("Custom provider").setDesc("Create any custom endpoint (OpenAI-compatible or otherwise)").addButton(t=>{t.setButtonText("Add custom...").onClick(()=>{let n={id:PT("custom",this.providers),name:"Custom",endpoint:"",apiKey:"",apiKeyRef:"",models:[],modelSource:"providerApi"};this.providers.push(n),new eo.Notice("Custom provider added. Click Edit to configure."),this.close()})})}async importInitialModels(e,t){try{await ug(this.app,e),new eo.Notice(`${t.name} connected with ${e.models.length} models.`)}catch(n){let i=n.message??String(n);t.seedKey?(e.models=MT(t.seedKey),new eo.Notice(`${t.name} added with its built-in model list. Live model loading failed: ${i}`)):new eo.Notice(`${t.name} added, but loading models failed: ${i} Use "Sync now" in the provider's settings to retry.`)}}onClose(){this.resolvePromise(this.providers??null),super.onClose()}};Yp();var gS=class extends Pr.Modal{constructor(e,t){super(t),this.providers=e,FT(this.providers),this.waitForClose=new Promise((n,i)=>{this.rejectPromise=i,this.resolvePromise=n}),this.open(),this.display(),this.autoSyncOnOpen()}async autoSyncOnOpen(){if(le.getState().disableOnlineFeatures)return;let e=!1;for(let t of this.providers)if(t.autoSyncModels)try{let{added:n}=await ug(this.app,t);e=e||n>0}catch{}e&&!this.selectedProvider&&this.reload()}display(){let e=this.selectedProvider?`${this.selectedProvider.name}`:"Providers";if(this.contentEl.createEl("h2",{text:e,cls:"qa-modal-title"}),this.selectedProvider){this.addProviderSetting(this.contentEl);return}this.addProvidersSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addProvidersSetting(e){new Pr.Setting(e).setName("Providers").setDesc("Providers for the AI Assistant").addButton(n=>{n.setButtonText("Add provider").onClick(async()=>{await new hS(this.app,this.providers).waitForClose,this.reload()}),n.setCta()});let t=e.createDiv({cls:"providers-container qa-ai-list-container"});this.providers.forEach((n,i)=>{new Pr.Setting(t).setName(n.name).setDesc(n.endpoint).addButton(o=>{o.onClick(async()=>{await Xi.Prompt(this.app,`Are you sure you want to delete ${n.name}?`)&&(this.providers.splice(i,1),this.reload())}),o.setDestructive(),o.setIcon("trash")}).addButton(o=>{o.setButtonText("Edit").onClick(()=>{this.selectedProvider=n,this._selectedProviderClone=vt(n),this.reload()})})})}addProviderSetting(e){this.addNameSetting(e),this.addEndpointSetting(e),this.addApiKeySetting(e),this.addKindSetting(e),this.addModelSourceSetting(e),this.addProviderModelsSetting(e),this.addImportModelsFromDirectorySetting(e),this.addAutoSyncSetting(e),this.addProviderSettingButtonRow(this.contentEl)}addNameSetting(e){let t=this.selectedProvider.id;new Pr.Setting(e).setName("Name").setDesc(t?`The display name of the provider. Its stable ID is "${t}" \u2014 use that to qualify models in scripts, e.g. ai.prompt with "${t}/model-name".`:"The display name of the provider").addText(n=>{n.setValue(this.selectedProvider.name).onChange(i=>{this.selectedProvider.name=i})})}addEndpointSetting(e){new Pr.Setting(e).setName("Endpoint").setDesc("The endpoint for the AI Assistant").addText(t=>{t.setValue(this.selectedProvider.endpoint).onChange(n=>{this.selectedProvider.endpoint=n})})}addApiKeySetting(e){let n=!!this.selectedProvider?.apiKey&&!this.selectedProvider?.apiKeyRef?"Legacy API key detected. Select a SecretStorage entry to migrate.":"Select a secret from SecretStorage";new Pr.Setting(e).setName("API key").setDesc(n).addComponent(i=>new Pr.SecretComponent(this.app,i).setValue(this.selectedProvider?.apiKeyRef??"").onChange(o=>{this.selectedProvider&&(this.selectedProvider.apiKeyRef=o,this.selectedProvider.apiKey="")}))}addKindSetting(e){new Pr.Setting(e).setName("Provider type").setDesc("The request format this provider expects. Auto-detect recognizes the official Anthropic and Gemini endpoints and treats everything else as OpenAI-compatible; pick a type explicitly for a proxy or custom endpoint.").addDropdown(t=>{t.addOption("","Auto-detect"),t.addOption("openai","OpenAI-compatible"),t.addOption("anthropic","Anthropic"),t.addOption("gemini","Gemini"),t.setValue(this.selectedProvider?.kind??""),t.onChange(n=>{this.selectedProvider&&(this.selectedProvider.kind=n||void 0)})})}addModelSourceSetting(e){let t=this.selectedProvider;new Pr.Setting(e).setName("Model source").setDesc("Choose where QuickAdd looks when browsing or syncing models for this provider.").addDropdown(n=>{n.addOption("providerApi","Provider models endpoint (requires API key)"),n.addOption("modelsDev","models.dev directory"),n.addOption("auto","Automatic (try provider, fallback to models.dev)");let i=t?.modelSource??"providerApi";n.setValue(i),n.onChange(o=>{this.selectedProvider&&(this.selectedProvider.modelSource=o,this.reload())})})}addProviderModelsSetting(e){let t=e.createDiv({cls:"models-container qa-ai-list-container"});this.selectedProvider.models.forEach((n,i)=>{let o=[`Context: ${n.maxTokens.toLocaleString()} tokens`];n.maxOutputTokens&&o.push(`Output: ${n.maxOutputTokens.toLocaleString()} tokens`),n.supportsTemperature===!1&&o.push("Fixed sampling (no temperature)"),new Pr.Setting(t).setName(n.name).setDesc(o.join(" \xB7 ")).addButton(s=>{s.onClick(async()=>{await Xi.Prompt(this.app,`Are you sure you want to delete ${n.name}?`)&&(this.selectedProvider.models.splice(i,1),this.reload())}),s.setDestructive(),s.setIcon("trash")})}),new Pr.Setting(t).setName("Add model").addButton(n=>{n.setButtonText("Add model").onClick(async()=>{let i,o;try{i=await Dr.Prompt(this.app,"Model name"),o=await Dr.Prompt(this.app,"Max tokens")}catch{return}let s=i.trim();if(!s){new Pr.Notice("Model name cannot be empty.");return}let a=o.trim();if(!/^[1-9]\d*$/.test(a)){new Pr.Notice("Max tokens must be a positive number.");return}let l=Number(a);this.selectedProvider.models.push({name:s,maxTokens:l}),this.reload()}),n.setCta()})}addImportModelsFromDirectorySetting(e){let t=this.describeModelSource(this.selectedProvider);new Pr.Setting(e).setName("Import models").setDesc(`Browse and import models from ${t}.`).addButton(n=>{n.setButtonText("Browse models").onClick(async()=>{let i=await new mS(this.app,this.selectedProvider).waitForClose;if(!i)return;let{imported:o,mode:s}=i;s==="replace"?this.selectedProvider.models=o:this.selectedProvider.models=Lx(this.selectedProvider.models,o),new Pr.Notice(`Imported ${o.length} models${s==="replace"?" (replaced)":" (added)"}.`),this.reload()}),n.setCta()})}addAutoSyncSetting(e){let t=this.describeModelSource(this.selectedProvider);new Pr.Setting(e).setName("Auto-sync models").setDesc(`Keep this provider's models current automatically: QuickAdd imports new models and refreshed context limits from ${t} once a day and when these settings open.`).addToggle(n=>{let i=!!this.selectedProvider?.autoSyncModels;n.setValue(i).onChange(o=>{this.selectedProvider&&(this.selectedProvider.autoSyncModels=o)})}).addButton(n=>{n.setButtonText("Sync now").onClick(async()=>{try{let{added:i,updated:o}=await ug(this.app,this.selectedProvider);new Pr.Notice(i>0||o>0?`Synced from ${t}: ${i} new model(s), ${o} updated.`:`Synced from ${t}: already up to date.`),this.reload()}catch(i){new Pr.Notice(`Sync failed: ${i.message??i}`)}}),n.setCta()})}restoreSelectedProviderFromClone(){if(!this.selectedProvider||!this._selectedProviderClone)return;let e=this.providers.indexOf(this.selectedProvider);e!==-1&&(this.providers[e]=this._selectedProviderClone),this.selectedProvider=null,this._selectedProviderClone=null}addProviderSettingButtonRow(e){let t=e.createDiv({cls:"button-row qa-ai-provider-button-row"}),n=new Pr.ButtonComponent(t);n.setButtonText("Cancel"),n.setDestructive(),n.onClick(()=>{this.restoreSelectedProviderFromClone(),this.reload()});let i=new Pr.ButtonComponent(t);i.setButtonText("Save"),i.setCta(),i.onClick(()=>{this.selectedProvider=null,this.reload()})}describeModelSource(e){switch(e?.modelSource??"providerApi"){case"modelsDev":return"the models.dev directory";case"auto":return"the provider's models endpoint (falls back to models.dev)";default:return"the provider's models endpoint"}}onClose(){this.restoreSelectedProviderFromClone(),this.resolvePromise(this.providers),super.onClose()}};qt();var vS=class extends Ha.Modal{constructor(e,t){super(e),this.settings=t,this.waitForClose=new Promise((n,i)=>{this.rejectPromise=i,this.resolvePromise=n}),this.open(),this.display()}display(){this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.contentEl.createEl("h2",{text:"AI Assistant settings",cls:"qa-modal-title"}),this.addProvidersSetting(this.contentEl),this.addDefaultModelSetting(this.contentEl),this.addPromptTemplateFolderPathSetting(this.contentEl),this.addShowAssistantSetting(this.contentEl),this.addConfirmToolCallsSetting(this.contentEl),this.addDefaultSystemPromptSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addProvidersSetting(e){new Ha.Setting(e).setName("Providers").setDesc("The providers for the AI Assistant").addButton(t=>{t.setButtonText("Edit providers").onClick(()=>{new gS(this.settings.providers,this.app).waitForClose.then(()=>{this.reload()})})})}addDefaultModelSetting(e){new Ha.Setting(e).setName("Default model").setDesc("The default model for the AI Assistant").addDropdown(t=>{Bk(t,{model:this.settings.defaultModel,modelRef:this.settings.defaultModelRef},n=>{this.settings.defaultModel=n.model,this.settings.defaultModelRef=n.modelRef})})}addPromptTemplateFolderPathSetting(e){new Ha.Setting(e).setName("Prompt template folder path").setDesc("Path to your folder with prompt templates").addText(t=>{t.setValue(this.settings.promptTemplatesFolderPath).onChange(n=>{this.settings.promptTemplatesFolderPath=n}),new ii(this.app,t.inputEl,Vs(this.app))})}addShowAssistantSetting(e){new Ha.Setting(e).setName("Show assistant").setDesc("Show status messages from the AI Assistant").addToggle(t=>{t.setValue(this.settings.showAssistant),t.onChange(n=>{this.settings.showAssistant=n})})}addConfirmToolCallsSetting(e){new Ha.Setting(e).setName("Confirm AI tool calls").setDesc("When an AI agent runs script-defined or built-in tools, ask before executing. 'Destructive only' confirms tools not marked read-only; 'Always' confirms every tool; 'Never' defers to each tool's own setting. A tool that requires approval is always confirmed regardless.").addDropdown(t=>{t.addOption("destructive","Destructive tools only (recommended)"),t.addOption("always","Always confirm every tool"),t.addOption("never","Never (use each tool's own setting)"),t.setValue(this.settings.confirmToolCalls??"destructive"),t.onChange(n=>{this.settings.confirmToolCalls=n})})}addDefaultSystemPromptSetting(e){new Ha.Setting(e).setName("Default system prompt").setDesc("The default system prompt for the AI Assistant");let t=new Ha.TextAreaComponent(e);t.inputEl.addClass("qa-ai-prompt-textarea"),t.inputEl.setAttribute("aria-label","Default system prompt");let n=Nk(e,t.inputEl,this.settings.defaultSystemPrompt??"");t.setValue(this.settings.defaultSystemPrompt).onChange(i=>{this.settings.defaultSystemPrompt=i,n(i)})}onClose(){this.resolvePromise(this.settings),super.onClose()}};var p4=require("obsidian");Wt();var u4=[{type:"Template",label:"Template",description:"Create a note from a template file.",iconId:"file-text"},{type:"Capture",label:"Capture",description:"Add text to a note \u2014 append, prepend, or insert.",iconId:"pencil"},{type:"Macro",label:"Macro",description:"Run a sequence of commands and scripts.",iconId:"terminal"}];function yS(r){switch(r){case"Template":return"New template";case"Capture":return"New capture";case"Macro":return"New macro";case"Multi":return"New folder"}}function d4(r,e){let t=yS(r),n=new Set(Vn(e).map(o=>o.name));if(!n.has(t))return t;let i=2;for(;n.has(`${t} ${i}`);)i++;return`${t} ${i}`}var ppe=q('<div><button type="button" class="qaNewFolderBtn svelte-a7rp4h"><!> <span> </span></button> <button type="button" aria-haspopup="menu"><!> <span> </span> <!></button></div>'),fpe={hash:"svelte-a7rp4h",code:`.qaAddChoiceControls.svelte-a7rp4h {display:flex;flex-direction:row;align-items:center;gap:0.5rem;}.qaAddChoiceControls.svelte-a7rp4h button:where(.svelte-a7rp4h) {display:inline-flex;align-items:center;gap:0.35em;}
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-a7rp4h svg:last-child {margin-left:-0.1em;opacity:0.85;}
/* Per-folder ("compact") controls render as quiet, clickable text links \u2014 not
filled buttons \u2014 so they read as "add inside this folder" affordances and
don't compete with the global primary CTA, especially when repeated across
nested folders. */.qaAddChoiceControls.compact.svelte-a7rp4h {gap:1rem;}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h) {font-size:var(--font-ui-smaller);padding:2px 0;gap:0.25em;background:transparent;border:none;box-shadow:none;color:var(--text-muted);}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h):hover {color:var(--text-accent);text-decoration:underline;}
/* Mobile/touch: stretch so the two buttons fill the bar width instead of
cramming to the right. Driven by \`fill\` (Platform.isMobile from the bottom
bar) because viewport media queries don't fire under desktop mobile-emulation. */.qaAddChoiceControls.fill.svelte-a7rp4h {flex:1;}.qaAddChoiceControls.fill.svelte-a7rp4h button:where(.svelte-a7rp4h) {flex:1;justify-content:center;}
/* Narrow desktop windows stack the non-compact controls. Filled controls (the
mobile bottom bar) are excluded so this can't override \`.fill\`'s side-by-side
50/50 layout on a phone-width viewport (Platform.isMobile + width <= 800px). */
@media (max-width: 800px) {.qaAddChoiceControls.svelte-a7rp4h:not(.compact):not(.fill) {flex-direction:column;align-items:stretch;}
}`};function dg(r,e){we(e,!0),ot(r,fpe);let t=he(e,"targetFolderId",3,void 0),n=he(e,"targetFolderName",3,void 0),i=he(e,"compact",3,!1),o=he(e,"fill",3,!1),s=_e(!1);function a(U){let oe=new p4.Menu;for(let O of u4)oe.addItem(G=>G.setTitle(`${O.label} \u2014 ${O.description}`).setIcon(O.iconId).onClick(V=>{let F=V.altKey===!0;e.onAddChoice(yS(O.type),O.type,t(),F)}));J(s,!0),oe.onHide(()=>{J(s,!1)});let ce=U.target?.closest("button");if(ce){let O=ce.getBoundingClientRect();oe.showAtPosition({x:O.left,y:O.bottom+4})}else oe.showAtMouseEvent(U)}function l(){e.onAddChoice(yS("Multi"),"Multi",t(),!0)}let c=N(()=>i()?"Add choice":"New choice"),u=N(()=>i()?"Add folder":"New folder"),d=N(()=>n()?`Add choice to ${n()}`:h(c)),f=N(()=>n()?`Add folder to ${n()}`:h(u));var p=ppe();let m;var v=I(p),g=I(v);$t(g,{iconId:"folder-plus",size:14});var y=_(g,2),w=I(y,!0);S(y),S(v);var k=_(v,2);let C;var E=I(k);$t(E,{iconId:"plus",size:14});var x=_(E,2),D=I(x,!0);S(x);var P=_(x,2);{var H=U=>{$t(U,{iconId:"chevron-down",size:12})};ie(P,U=>{i()||U(H)})}S(k),S(p),de(()=>{m=xt(p,1,"qaAddChoiceControls svelte-a7rp4h",null,m,{compact:i(),fill:o()&&!i()}),Ae(v,"aria-label",h(f)),Ae(v,"title",i()?h(f):void 0),me(w,h(u)),C=xt(k,1,"qaNewChoiceBtn svelte-a7rp4h",null,C,{"mod-cta":!i()}),Ae(k,"aria-expanded",h(s)),Ae(k,"aria-label",h(d)),Ae(k,"title",i()?h(d):void 0),me(D,h(c))}),De("click",v,l),De("click",k,a),$(r,p),Ce()}Tt(["click"]);var mpe=q('<div class="rightButtonsContainer svelte-1es4f02"><!> <!> <!> <!> <!> <!></div>'),hpe={hash:"svelte-1es4f02",code:`.rightButtonsContainer.svelte-1es4f02 {display:flex;align-items:center;
/* Icons carry their own 3px padding inside the choice rows (24px hit
boxes), so a tight gap keeps the cluster compact without touching. */gap:2px;flex:0 0 auto;}`};function Ux(r,e){we(e,!0),ot(r,hpe);let t=he(e,"showConfigureButton",3,!0),n=he(e,"showDuplicateButton",3,!0),i=he(e,"commandEnabled",3,!1),o=he(e,"choiceName",3,"");var s=mpe(),a=I(s);{var l=g=>{{let y=N(()=>`Configure${o()?" "+o():""}`);er(g,{iconId:"settings",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onConfigureChoice}})}};ie(a,g=>{t()&&g(l)})}var c=_(a,2);{var u=g=>{{let y=N(()=>`Duplicate${o()?" "+o():""}`);er(g,{iconId:"copy",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDuplicateChoice}})}};ie(c,g=>{n()&&g(u)})}var d=_(c,2);{let g=N(()=>`Delete${o()?" "+o():""}`);er(d,{iconId:"trash-2",get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDeleteChoice}})}var f=_(d,2);{var p=g=>{{let y=N(()=>`More options${o()?" for "+o():""}`);er(g,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return h(y)},onclick:w=>e.onOpenMenu?.(w.currentTarget)})}};ie(f,g=>{e.onOpenMenu&&g(p)})}var m=_(f,2);{let g=N(()=>`Command palette${o()?": "+o():""}`);er(m,{iconId:"zap",get ariaPressed(){return i()},get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onToggleCommand}})}var v=_(m,2);{let g=N(()=>`Reorder${o()?" "+o():""}`);Si(v,{get label(){return h(g)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.onDragHandleDown},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(s),$(r,s),Ce()}var wS=require("obsidian");var f4=require("obsidian");function bS(r,e,t,n){e.replaceChildren(),f4.MarkdownRenderer.render(n,r,e,"/",t)}Wt();var gpe=q('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),vpe={hash:"svelte-1aljzaf",code:""};function yO(r,e){we(e,!0),ot(r,vpe);let t=!0,n=_e(void 0),i=new wS.Component;hr(()=>{h(n)&&bS(e.choice.name,h(n),i,e.app)}),hr(()=>()=>i.unload());let o=()=>({onRename:()=>e.actions.onRenameChoice(e.choice),onToggle:()=>e.actions.onToggleCommand(e.choice),onConfigure:()=>e.actions.onConfigureChoice(e.choice),onDuplicate:()=>e.actions.onDuplicateChoice(e.choice),onDelete:()=>e.actions.onDeleteChoice(e.choice),onMove:p=>e.actions.onMoveChoice(e.choice,p)});function s(p){aS(e.app,p,e.choice,e.roots,o())}function a(p){lS(e.app,p,e.choice,e.roots,o())}var l=gpe(),c=I(l),u=I(c);{let p=N(()=>Em(e.choice));$t(u,{get iconId(){return h(p)},size:15})}S(c);var d=_(c,2);cc(d,p=>J(n,p),()=>h(n));var f=_(d,2);Ux(f,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(e.choice),onConfigureChoice:()=>e.actions.onConfigureChoice(e.choice),onToggleCommand:()=>e.actions.onToggleCommand(e.choice),onDuplicateChoice:()=>e.actions.onDuplicateChoice(e.choice),onOpenMenu:a,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},get choiceName(){return e.choice.name},get commandEnabled(){return e.choice.command},showConfigureButton:t,get dragDisabled(){return e.dragDisabled},showDuplicateButton:!0}),S(l),de(()=>Ae(l,"data-choice-id",e.choice.id)),De("contextmenu",l,s),De("dblclick",l,p=>{wS.Platform.isMobile||p.target.closest("button, a")||e.actions.onConfigureChoice(e.choice)}),$(r,l),Ce()}Tt(["contextmenu","dblclick"]);var CS=require("obsidian");Wt();var ype=q('<span class="qaFolderCount svelte-1jxjn06" aria-hidden="true"> </span>'),bpe=q(`<p class="qaUnreadableFolder svelte-1jxjn06">QuickAdd couldn't read this folder's contents. They're still
in <code class="svelte-1jxjn06">data.json</code>.</p>`),wpe=q('<div class="nestedAddRow svelte-1jxjn06"><!></div>'),Cpe=q("<!> <!>",1),xpe=q('<div class="nestedChoiceList svelte-1jxjn06"><!></div>'),Epe=q('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-1jxjn06"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),Tpe={hash:"svelte-1jxjn06",code:`
/* Row surface (min-height, padding, radius, hover, rhythm) is shared with
leaf rows and lives in styles.css \u2014 see "Choice list rows". Only the
folder-specific pieces stay here. */
/* Base icon = chevron-down (expanded); collapsed rotates to point RIGHT,
matching Obsidian's own collapse grammar (file explorer, outline). */.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:transform 150ms ease;}.multiChoiceCollapseIcon.is-collapsed.svelte-1jxjn06 {transform:rotate(-90deg);}
@media (prefers-reduced-motion: reduce) {.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:none;}
}
/* Full-width collapse toggle: reset native <button> chrome while keeping
native keyboard activation + aria-expanded. It hosts the shared icon
column (the chevron), so the folder NAME lands on the exact leaf-name x
for free \u2014 same 8px column gap as the leaf rows. */.multiChoiceListItemName.svelte-1jxjn06 {flex:1 1 auto;min-width:0;align-self:stretch;display:flex;align-items:center;
/* Obsidian's base button centers flex content; the name must not rely
on a growing child to stay left (it stopped growing for the count). */justify-content:flex-start;gap:8px;background:transparent;border:none;box-shadow:none;padding:0;
/* Obsidian's base button rule sets height: var(--input-height) (30px),
which would make folder rows 4px taller than leaf rows \u2014 the exact
rhythm break this redesign removes. */height:auto;min-height:0;font:inherit;color:inherit;text-align:left;cursor:pointer;
/* Suppress double-tap-zoom + its click delay on touch \u2014 proper touch hygiene
for a tap target, and reduces the ghost-click the dedupe above also guards. */touch-action:manipulation;}
/* The count reads as part of the label ("Misc \xB7 12"), so the name must not
grow \u2014 it keeps its ellipsis via flex-shrink + the shared min-width: 0. */.multiChoiceListItemName.svelte-1jxjn06 .choiceListItemName {flex:0 1 auto;}
/* Same slot, weight and colour as the empty-folder hint in ChoiceList, so a
folder we cannot read reads as a variation of "empty" rather than an alarm. */.qaUnreadableFolder.svelte-1jxjn06 {margin:0;padding:6px 8px 8px;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06 code:where(.svelte-1jxjn06) {font-size:inherit;}.qaFolderCount.svelte-1jxjn06 {flex:0 0 auto;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);font-variant-numeric:tabular-nums;line-height:1;}.multiChoiceListItemName.svelte-1jxjn06:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;border-radius:var(--radius-s, 4px);}
/* Just the indent \u2014 the drop-into-folder ring is drawn on the ACTUAL dndzone
(.choiceList, in ChoiceList.svelte) so the highlighted area equals the
droppable area (WYSIWYG); it is NOT drawn on this wrapper, which extends past
the zone to the add-row/hint. The ::before is an indent GUIDE under the
parent's icon column (x = row padding 8px + half the 18px column, minus
half the line), clarifying what belongs to the open folder. */.nestedChoiceList.svelte-1jxjn06 {position:relative;padding-left:26px;}.nestedChoiceList.svelte-1jxjn06::before {content:"";position:absolute;left:16px;top:3px;bottom:3px;width:1px;background:var(--background-modifier-border);pointer-events:none;}
/* The per-folder add-row reads as a ghost row of the folder: aligned to the
child rows' padding, one tight step (4px) below the last child. */.nestedAddRow.svelte-1jxjn06 {margin:2px 0 4px 0;padding:0 8px;}`};function bO(r,e){we(e,!0),ot(r,Tpe);let t=he(e,"choice",7),n=he(e,"forceDragDisabled",3,!1),i=N(()=>st(t())),o=N(()=>js(t())),s=!0,a=_e(void 0),l=new CS.Component;hr(()=>{h(a)&&bS(t().name,h(a),l,e.app)}),hr(()=>()=>l.unload());let c=()=>({onRename:()=>e.actions.onRenameChoice(t()),onToggle:()=>e.actions.onToggleCommand(t()),onConfigure:()=>e.actions.onConfigureChoice(t()),onDuplicate:()=>e.actions.onDuplicateChoice(t()),onDelete:()=>e.actions.onDeleteChoice(t()),onMove:U=>e.actions.onMoveChoice(t(),U)});function u(U){aS(e.app,U,t(),e.roots,c())}function d(U){lS(e.app,U,t(),e.roots,c())}let f={...Ot(()=>e.actions),onReorderChoices:U=>{t().choices=U,e.actions.onCommitFolder(t().id,U)}};function p(){n()||e.actions.onToggleCollapsed(t())}var m=Epe(),v=I(m),g=I(v),y=I(g);let w;var k=I(y);$t(k,{iconId:"chevron-down",size:16}),S(y);var C=_(y,2);cc(C,U=>J(a,U),()=>h(a));var E=_(C,2);{var x=U=>{var oe=ype(),ce=I(oe,!0);S(oe),de(()=>me(ce,h(i).length)),$(U,oe)};ie(E,U=>{t().collapsed&&h(i).length>0&&U(x)})}S(g),Mr(g,U=>ik?.(U));var D=_(g,2);Ux(D,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(t()),onConfigureChoice:()=>e.actions.onConfigureChoice(t()),onToggleCommand:()=>e.actions.onToggleCommand(t()),onDuplicateChoice:()=>e.actions.onDuplicateChoice(t()),onOpenMenu:d,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},showConfigureButton:s,get dragDisabled(){return e.dragDisabled},get choiceName(){return t().name},get commandEnabled(){return t().command},showDuplicateButton:!0}),S(v);var P=_(v,2);{var H=U=>{var oe=dn(),ce=Pe(oe);{var O=G=>{var V=xpe(),F=I(V);{var Z=Y=>{var K=bpe();$(Y,K)},z=Y=>{var K=Cpe(),se=Pe(K);{let be=N(()=>h(i).length===0),Be=N(()=>e.rootReorder??e.actions.onReorderChoices);pg(se,{get app(){return e.app},get roots(){return e.roots},get choices(){return h(i)},nested:!0,get isEmptyFolder(){return h(be)},get forceDragDisabled(){return n()},get rootReorder(){return h(Be)},get actions(){return f}})}var pe=_(se,2);{var ge=be=>{var Be=wpe(),Se=I(Be);dg(Se,{compact:!0,get targetFolderId(){return t().id},get targetFolderName(){return t().name},get onAddChoice(){return e.actions.onAddChoice}}),S(Be),$(be,Be)};ie(pe,be=>{n()||be(ge)})}$(Y,K)};ie(F,Y=>{h(o)?Y(Z):Y(z,-1)})}S(V),$(G,V)};ie(ce,G=>{t().collapsed||G(O)})}$(U,oe)};ie(P,U=>{(!e.collapseId||e.collapseId&&t().id!==e.collapseId)&&U(H)})}S(m),de(()=>{Ae(v,"data-choice-id",t().id),Ae(g,"aria-expanded",!t().collapsed),Ae(g,"aria-label",`Toggle ${t().name}`),w=xt(y,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-1jxjn06",null,w,{"is-collapsed":t().collapsed})}),De("contextmenu",v,u),De("click",v,U=>{CS.Platform.isMobile||U.target.closest("button, a")||p()}),De("click",g,p),$(r,m),Ce()}Tt(["contextmenu","click"]);function m4(r){let e=r-1;return e*e*e+1}function h4(r,{from:e,to:t},n={}){var{delay:i=0,duration:o=x=>Math.sqrt(x)*120,easing:s=m4}=n,a=getComputedStyle(r),l=a.transform==="none"?"":a.transform,[c,u]=a.transformOrigin.split(" ").map(parseFloat);c/=r.clientWidth,u/=r.clientHeight;var d=_pe(r),f=r.clientWidth/t.width/d,p=r.clientHeight/t.height/d,m=e.left+e.width*c,v=e.top+e.height*u,g=t.left+t.width*c,y=t.top+t.height*u,w=(m-g)*f,k=(v-y)*p,C=e.width/t.width,E=e.height/t.height;return{delay:i,duration:typeof o=="function"?o(Math.sqrt(w*w+k*k)):o,easing:s,css:(x,D)=>{var P=D*w,H=D*k,U=x+D*C,oe=x+D*E;return`transform: ${l} translate(${P}px, ${H}px) scale(${U}, ${oe});`}}}function _pe(r){if("currentCSSZoom"in r)return r.currentCSSZoom;for(var e=r,t=1;e!==null;)t*=+getComputedStyle(e).zoom,e=e.parentElement;return t}var g4=require("obsidian");Wt();var Ape=q("<div><!></div>"),kpe=q("<div></div>"),Spe={hash:"svelte-2ry05y",code:`.choiceList.svelte-2ry05y {width:auto;}
/* Root (non-nested) empty list keeps a little bottom breathing room. The only way to
render it empty is a zero-match filter \u2014 a truly empty tree shows the hero state. */.choiceList.qa-empty.svelte-2ry05y:not(.qa-nested) {padding-bottom:0.5rem;}.choiceList.qa-nested.svelte-2ry05y {
/* Own the 2px name->first-row gap so the empty drop band sits the same distance
below the folder name as a populated folder's first row (collapses with the
row's own margin-top, so populated folders look identical). */margin-top:2px;position:relative; /* anchor the ring (::before) */border-radius:var(--radius-m);transition:background-color 120ms ease;}
/* The drop ring is drawn a few px OUTSIDE the content as an absolutely-positioned
::before (adds no layout) \u2014 "synthetically" bigger than the rows so it doesn't
clamp straight against the choice names. The right edge stays at the content edge:
the settings pane is overflow-x:hidden, so extending the ring right would clip it. */.choiceList.qa-nested.svelte-2ry05y::before {content:"";position:absolute;inset:-4px 0 -4px -6px;border-radius:var(--radius-m);border:2px dashed transparent;pointer-events:none;transition:border-color 120ms ease;}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget {background-color:var(--background-modifier-hover);}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget::before {border-color:var(--interactive-accent);}
/* Empty folder: a GENEROUS, STABLE drop target. The band is sized by the folder's
PERSISTED emptiness (qa-folder-empty), NOT the live \`choices\` length \u2014 so when a
dragged item is previewed into the zone (filling \`choices\`, toggling qa-empty off)
the band keeps its height instead of collapsing/expanding under the cursor (the
"jumps all over the place"). Only persisted-empty folders get it, so populated
folders never heave at drag start. */.choiceList.qa-nested.qa-folder-empty.svelte-2ry05y {min-height:3rem;display:flex;align-items:center;}
/* Hint shows only when the folder is persisted-empty AND nothing is previewed in it
(qa-empty = live \`choices\` empty), so it cleanly swaps out for the previewed row
without changing the band's size. */.choiceList.qa-nested.qa-folder-empty.qa-empty.svelte-2ry05y::after {content:"Empty \u2014 add a choice or drag one here.";color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.3;padding-left:8px; /* align with the child rows' own left padding */pointer-events:none;user-select:none;}
@media (prefers-reduced-motion: reduce) {.choiceList.qa-nested.svelte-2ry05y,
.choiceList.qa-nested.svelte-2ry05y::before {transition:none;}
}`};function pg(r,e){we(e,!0),ot(r,Spe);let t=he(e,"choices",31,()=>Ct([])),n=he(e,"forceDragDisabled",3,!1),i=he(e,"isEmptyFolder",3,!1),o=he(e,"nested",3,!1),s=N(()=>{let C=new Set;return gn(t()).filter(E=>{if(!Ye(E))return!1;let x=E.id;return typeof x!="string"||x===""||C.has(x)?!1:(C.add(x),!0)})}),a=N(()=>e.rootReorder??e.actions.onReorderChoices),l=0,c=g4.Platform.isMobile,u=_e(""),d=_k(),f=N(()=>n()||!c&&!d.armed),p=null;function m(C){if(n())return;d.markStarted();let E=C.detail.items;p=Ek(E,C.detail.info.id)??p,J(u,C.detail.info.id,!0),t(Nl(E))}function v(C){if(n())return;J(u,"");let E=Nl(C.detail.items),x=C.detail.info.id;C.detail.info.trigger===ki.DROPPED_INTO_ANOTHER?E=E.filter(D=>D.id!==x):p?.item.id===x&&!E.some(D=>D.id===x)&&(E=[...E],E.splice(Math.min(p.index,E.length),0,p.item)),p=null,t(E),d.reset(),e.actions.onReorderChoices(t())}let g=()=>{n()||d.startDrag()};function y(C,E){if(n())return;let x=Nl(h(s)),D=x.findIndex(oe=>oe.id===C.id);if(D===-1)return;let P=D+E;if(P<0||P>=x.length)return;let H=[...x],[U]=H.splice(D,1);H.splice(P,0,U),t(H),e.actions.onReorderChoices(t()),Ax(`Moved ${C.name} to position ${P+1} of ${x.length}`)}var w=kpe();let k;ar(w,29,()=>Nl(h(s)),C=>C.id,(C,E)=>{var x=Ape(),D=I(x);{var P=U=>{{let oe=N(()=>e.roots??t()),ce=N(()=>n()?void 0:()=>y(h(E),-1)),O=N(()=>n()?void 0:()=>y(h(E),1));yO(U,{get app(){return e.app},get roots(){return h(oe)},get dragDisabled(){return h(f)},startDrag:g,get actions(){return e.actions},get choice(){return h(E)},get onMoveUp(){return h(ce)},get onMoveDown(){return h(O)}})}},H=U=>{{let oe=N(()=>e.roots??t()),ce=N(()=>n()?void 0:()=>y(h(E),-1)),O=N(()=>n()?void 0:()=>y(h(E),1));bO(U,{get app(){return e.app},get roots(){return h(oe)},get dragDisabled(){return h(f)},startDrag:g,get actions(){return e.actions},get collapseId(){return h(u)},get forceDragDisabled(){return n()},get rootReorder(){return h(a)},get choice(){return h(E)},get onMoveUp(){return h(ce)},get onMoveDown(){return h(O)}})}};ie(D,U=>{h(E).type!=="Multi"?U(P):U(H,-1)})}S(x),p0(x,()=>h4,()=>({duration:l})),$(C,x)}),S(w),Mr(w,(C,E)=>xk?.(C,E),()=>Tk({items:h(s),dragDisabled:h(f),flipDurationMs:l,dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),de(()=>k=xt(w,1,"choiceList svelte-2ry05y",null,k,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":h(s).length===0})),lc("consider",w,m),lc("finalize",w,v),$(r,w),Ce()}var Dpe=q('<pre class="qaChoicesUnavailableDetail svelte-1fs8ikt"> </pre>'),Ipe=q(`<div class="qaChoicesUnavailable svelte-1fs8ikt"><div class="qaChoicesUnavailableHead svelte-1fs8ikt"><!> <span class="qaChoicesUnavailableTitle svelte-1fs8ikt"> </span></div> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">Something in this vault's QuickAdd settings could not be read. Your choices
have not been changed or deleted, and QuickAdd will not overwrite them.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
copy of that file before editing it.</p> <!></div>`),Ppe={hash:"svelte-1fs8ikt",code:".qaChoicesUnavailable.svelte-1fs8ikt {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaChoicesUnavailableHead.svelte-1fs8ikt {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaChoicesUnavailableTitle.svelte-1fs8ikt {font-weight:var(--font-semibold);color:var(--text-normal);}.qaChoicesUnavailableBody.svelte-1fs8ikt {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaChoicesUnavailableDetail.svelte-1fs8ikt {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function fg(r,e){ot(r,Ppe);let t=he(e,"what",3,"your choices"),n=he(e,"detail",3,"");var i=Ipe(),o=I(i),s=I(o);$t(s,{iconId:"alert-triangle",size:16});var a=_(s,2),l=I(a);S(a),S(o);var c=_(o,6);{var u=d=>{var f=Dpe(),p=I(f,!0);S(f),de(()=>me(p,n())),$(d,f)};ie(c,d=>{n()&&d(u)})}S(i),de(()=>me(l,`QuickAdd couldn't display ${t()??""}`)),$(r,i)}Wt();Wt();var wO=new WeakMap;function v4(r){let e=wO.get(r);if(e)return e;let t=gU(r);return wO.set(r,t),t}function y4(r){return wO.has(r)}Cr();var Fpe=q(`<div class="choiceEmptyState svelte-1r4uuo1"><!> <div class="choiceEmptyTitle svelte-1r4uuo1">No choices yet</div> <p class="choiceEmptyBody svelte-1r4uuo1">A choice is an action QuickAdd can run: create a note, capture
text, or run a macro. Group them with folders. <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Learn more</a></p> <div class="choiceEmptyActions svelte-1r4uuo1"><!></div></div>`),Mpe=q('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),Rpe=q('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),$pe=q('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),Ope=q('<div class="choiceFilterBar svelte-1r4uuo1"><div class="search-input-container choiceFilterInput svelte-1r4uuo1"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-1r4uuo1"><!> <!></div>',1),Npe=q("<div><!></div>"),Lpe={hash:"svelte-1r4uuo1",code:`.choiceViewBottomBar.svelte-1r4uuo1 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
/* AI Assistant as a quiet icon button (matches the per-row action icons),
leading the right cluster so the bar's width barely changes when AI/online
features toggle. */.qaAIAssistantBtn.svelte-1r4uuo1 {flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;color:var(--text-muted);}.qaAIAssistantBtn.svelte-1r4uuo1:hover {color:var(--text-normal);}.choiceEmptyState.svelte-1r4uuo1 {display:flex;flex-direction:column;align-items:center;text-align:center;gap:0.5rem;padding:2.5rem 1rem;color:var(--text-muted);}.choiceEmptyTitle.svelte-1r4uuo1 {font-weight:var(--font-semibold);color:var(--text-normal);}.choiceEmptyBody.svelte-1r4uuo1 {margin:0;max-width:42ch;}.choiceEmptyActions.svelte-1r4uuo1 {margin-top:0.5rem;}.choiceFilterBar.svelte-1r4uuo1 {margin-bottom:8px;}
/* The native container is inline-block by default in some contexts; span
the full row so the filter aligns with the list edges. */.choiceFilterInput.svelte-1r4uuo1 {width:100%;}
/* Obsidian styles .search-input-clear-button (position, the \xD7 glyph, hover)
\u2014 we only reset the <button> chrome so that styling shows through. A real
<button> (Obsidian uses a div) keeps it keyboard-operable. */.qaFilterClearButton.svelte-1r4uuo1 {background:transparent;border:none;box-shadow:none;padding:0;margin:0;cursor:var(--cursor, pointer);}.choiceFilterEmpty.svelte-1r4uuo1 {color:var(--text-faint);font-size:var(--font-ui-small, 13px);padding:12px 8px 16px;}`};function CO(r,e){we(e,!0),ot(r,Lpe);let t=he(e,"choices",31,()=>Ct([])),n=_e(""),i=N(()=>!Array.isArray(t())),o=N(()=>`The "choices" value in data.json is ${t()===null?"null":`of type "${typeof t()}"`}, but QuickAdd expects a list.`),s=mg.Platform.isMobile,a=_e(Ct(le.getState().disableOnlineFeatures)),l=new sS(Ot(()=>e.plugin));function c(z){if(!Array.isArray(z))return z;let Y=y4(z),{choices:K,repaired:se}=v4(z);if(Y)return K;for(let{choice:pe}of se)if(pe.command)try{l.enableCommand(pe)}catch(ge){M.logError(`Could not register a command for the repaired choice "${pe.name}": ${ge instanceof Error?ge.message:String(ge)}`)}return K}t(c(t())),hr(()=>{let z=le.subscribe(Y=>{t(c(Y.choices)),J(a,Y.disableOnlineFeatures,!0)});return()=>z()});function u(){e.saveChoices(Eh(t()))}let d=z=>z.type==="Multi";function f(z,Y){let K=Y.trim();if(!K)return z;let se=(0,mg.prepareFuzzySearch)(K),pe=ge=>{if(!Ye(ge))return null;let be=!!se(ge.name??"");if(!d(ge))return be?ge:null;let Be=st(ge).map(Se=>pe(Se)).filter(Boolean);return be||Be.length>0?{...ge,collapsed:!1,choices:Be}:null};return z.map(ge=>pe(ge)).filter(Boolean)}async function p(z,Y,K,se=!1){let pe=d4(Y,t()),ge=cO(Y,pe);if(t(GY(t(),ge,K)),!K&&h(n).trim().length>0&&J(n,""),Y==="Multi")u(),await C(ge),await m(ge.id);else if(se)u(),await m(ge.id);else{u();try{await w(ge)}catch(be){M.logError(`Failed to configure the new choice: ${be instanceof Error?be.message:String(be)}`),u()}await m(ge.id)}}async function m(z){await Kf();try{document.querySelector(`[data-choice-id="${z}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function v(z){return $x(t(),z.id)??z}function g(z){return Ye(z)?z.command?!0:st(z).some(g):!1}async function y(z){let Y=v(z);await qY(Y,e.app)&&(t(Ox(t(),z.id).updated),l.disableCommand(Y,{recursive:!0}),u())}async function w(z){let Y=v(z),K=await WY(Y,e.app,e.plugin);K&&(t(t().map(se=>k(se,K))),l.updateCommand(Y,K),u())}function k(z,Y){if(!Ye(z))return z;if(z.id===Y.id)return{...z,...Y};if(Tc(z)){let K=st(z).map(pe=>k(pe,Y));return{...z,choices:K}}return z}async function C(z){if(!z)return;let Y=await V_(e.app,z.name,z.type);if(!Y)return;let K=v(z),se={...K,name:Y};t(t().map(pe=>k(pe,se))),l.updateCommand(K,se),u()}function E(z){let Y=zY(v(z));t(t().map(K=>k(K,Y))),Y.command?l.enableCommand(Y):l.disableCommand(Y),u()}async function x(z){let Y=await VY(v(z),e.app);t(pO(t(),z.id,Y)??[...t(),Y]),g(Y)&&l.enableCommand(Y),u(),new mg.Notice(`Duplicated "${z.name}".`),await m(Y.id)}function D(z,Y){t(Y===hO?jY(t(),z.id):HY(t(),z.id,Y)),u()}function P(z){t(z),u()}function H(z,Y){t(YY(t(),z,Y)),u()}function U(z){t(mO(t(),z.id,!z.collapsed)),u()}function oe(z,Y){return(K,...se)=>{let pe=Fm(K?.type),ge=K?.name?`the ${pe} \u201C${K.name}\u201D`:`that ${pe}`;nm(`Couldn't ${z} ${ge}`,Y)(K,...se)}}let ce={onDeleteChoice:oe("delete",y),onConfigureChoice:oe("open the settings for",w),onToggleCommand:oe("update the command palette entry for",E),onDuplicateChoice:oe("duplicate",x),onRenameChoice:oe("rename",C),onMoveChoice:oe("move",D),onToggleCollapsed:oe("open or close",U),onReorderChoices:nm("Couldn't save the new order",P),onCommitFolder:nm("Couldn't save that folder's contents",H),onAddChoice:(z,Y,K,se)=>nm(`Couldn't add that ${Fm(Y)}`,p)(z,Y,K,se)},O=nm("Couldn't open the AI assistant settings",async()=>{let z=await new vS(e.app,le.getState().ai).waitForClose;z&&le.setState(Y=>({...Y,ai:z}))});var G=Npe(),V=I(G);{var F=z=>{fg(z,{get detail(){return h(o)}})},Z=z=>{var Y=dn(),K=Pe(Y);Tv(K,{onerror:pe=>M.logError(`QuickAdd could not render the choice list: ${pe instanceof Error?pe.message:String(pe)}`),failed:(pe,ge=Ut)=>{{let be=N(()=>ge()instanceof Error?ge().message:String(ge()));fg(pe,{get detail(){return h(be)}})}}},pe=>{var ge=dn(),be=Pe(ge);{var Be=Ne=>{var Qe=Fpe(),Ze=I(Qe);$t(Ze,{iconId:"folder-plus",size:28});var ye=_(Ze,4),We=_(I(ye));S(ye);var gt=_(ye,2),He=I(gt);dg(He,{get onAddChoice(){return ce.onAddChoice}}),S(gt),S(Qe),de(()=>Ae(We,"href",Pl.gettingStarted)),$(Ne,Qe)},Se=N(()=>t().length===0&&h(n).trim().length===0),ut=Ne=>{var Qe=Ope(),Ze=Pe(Qe),ye=I(Ze),We=I(ye);gr(We),Ae(We,"spellcheck",!1);var gt=_(We,2);{var He=pt=>{var Mt=Mpe();De("click",Mt,()=>J(n,"")),$(pt,Mt)};ie(gt,pt=>{h(n)&&pt(He)})}S(ye),S(Ze);var Te=_(Ze,2);{var Ve=pt=>{pg(pt,{get app(){return e.app},get roots(){return t()},get actions(){return ce},get choices(){return t()},set choices(Mt){t(Mt)}})},dt=N(()=>h(n).trim().length===0),or=pt=>{let Mt=N(()=>f(t(),h(n)));var jn=dn(),Eo=Pe(jn);{var Ts=ne=>{var Ie=Rpe();$(ne,Ie)},Gn=ne=>{pg(ne,{get app(){return e.app},get roots(){return t()},get choices(){return h(Mt)},forceDragDisabled:!0,get actions(){return ce}})};ie(Eo,ne=>{h(Mt).length===0?ne(Ts):ne(Gn,-1)})}$(pt,jn)};ie(Te,pt=>{h(dt)?pt(Ve):pt(or,-1)})}var yr=_(Te,2),Ft=I(yr);{var kr=pt=>{var Mt=$pe(),jn=I(Mt);$t(jn,{iconId:"sparkles",size:16}),S(Mt),De("click",Mt,O),$(pt,Mt)};ie(Ft,pt=>{h(a)||pt(kr)})}var ur=_(Ft,2);dg(ur,{get onAddChoice(){return ce.onAddChoice},get fill(){return s}}),S(yr),De("keydown",We,pt=>{pt.key==="Escape"&&h(n)&&(J(n,""),pt.stopPropagation())}),po(We,()=>h(n),pt=>J(n,pt)),$(Ne,Qe)};ie(be,Ne=>{h(Se)?Ne(Be):Ne(ut,-1)})}$(pe,ge)}),$(z,Y)};ie(V,z=>{h(i)?z(F):z(Z,-1)})}S(G),$(r,G),Ce()}Tt(["keydown","click"]);Pt();var Bpe=q('<div class="qa-gv__empty svelte-hx6w4t">No global variables yet.</div>'),Vpe=q('<div class="qa-gv__row qa-gv__row--head svelte-hx6w4t"><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-hx6w4t">Actions</div></div>'),Upe=q('<div class="qa-gv__row svelte-hx6w4t"><div class="qa-gv__cell qa-gv__name svelte-hx6w4t"><input type="text" placeholder="Name" class="svelte-hx6w4t"/></div> <div class="qa-gv__cell qa-gv__value svelte-hx6w4t"><textarea rows="2" placeholder="Snippet value (supports QuickAdd tokens)" class="svelte-hx6w4t"></textarea></div> <div class="qa-gv__cell qa-gv__ops svelte-hx6w4t"><button class="qa-gv__btn danger svelte-hx6w4t" title="Delete">Delete</button></div></div>'),qpe=q('<div class="qa-gv svelte-hx6w4t"><div class="qa-gv__desc svelte-hx6w4t">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-hx6w4t"><!> <!></div> <div class="qa-gv__actions svelte-hx6w4t"><button class="mod-cta">Add variable</button></div></div>'),Wpe={hash:"svelte-hx6w4t",code:`.qa-gv.svelte-hx6w4t {display:flex;flex-direction:column;gap:8px;}
/* Keeps "Add variable" right-aligned now that it is the row's only child. */.qa-gv__actions.svelte-hx6w4t {display:flex;justify-content:flex-end;}.qa-gv__desc.svelte-hx6w4t {color:var(--text-muted);font-size:12px;}
/* Mirrors .qa-template-folder-empty, the sibling list's empty state. */.qa-gv__empty.svelte-hx6w4t {color:var(--text-muted);font-size:var(--font-ui-smaller);padding:6px 0;}.qa-gv__table.svelte-hx6w4t {display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t {display:grid;grid-template-columns:180px 1fr 140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t {font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4t input[type="text"]:where(.svelte-hx6w4t) {width:100%;}.qa-gv__cell.svelte-hx6w4t textarea:where(.svelte-hx6w4t) {width:100%;resize:vertical;}.qa-gv__ops.svelte-hx6w4t {display:flex;gap:6px;align-items:center;}.qa-gv__btn.svelte-hx6w4t {padding:4px 8px;}.qa-gv__btn.danger.svelte-hx6w4t {color:var(--text-error);}
@media (max-width: 900px) {.qa-gv__row.svelte-hx6w4t {grid-template-columns:1fr;}.qa-gv__row--head.svelte-hx6w4t {display:none;}
}`};function xO(r,e){we(e,!0),ot(r,Wpe);let t=_e(Ct([]));function n(C,E){if(!E.has(C))return C;let x=1;for(;E.has(`${C}${x}`);)x++;return`${C}${x}`}function i(){let E=le.getState().globalVariables||{};J(t,Object.keys(E).map(x=>({name:x,value:E[x]??""})),!0)}let o=!1;function s(){let C=h(t).map(P=>P.name.trim()),E=C.some(P=>!P),x=new Set(C).size!==C.length;if(E||x)return;let D={};for(let P of h(t))D[P.name.trim()]=P.value??"";o=!0;try{le.setState({globalVariables:D})}finally{o=!1}}function a(){let C=new Set(h(t).map(x=>x.name)),E=n("NewVar",C);J(t,[...h(t),{name:E,value:""}],!0),s()}function l(C){J(t,h(t).filter((E,x)=>x!==C),!0),s()}function c(C){return new ji(e.app,C,e.plugin),{destroy(){}}}let u;function d(C){u!==void 0&&window.clearTimeout(u),u=window.setTimeout(()=>{s()},200)}hr(()=>{let C=le.subscribe(()=>{o||i()});return i(),()=>{u!==void 0&&window.clearTimeout(u),C()}});var f=qpe(),p=_(I(f),2),m=I(p);{var v=C=>{var E=Bpe();$(C,E)},g=C=>{var E=Vpe();$(C,E)};ie(m,C=>{h(t).length===0?C(v):C(g,-1)})}var y=_(m,2);ar(y,17,()=>h(t),Uv,(C,E,x)=>{var D=Upe(),P=I(D),H=I(P);gr(H),Mr(H,G=>c?.(G)),un(()=>po(H,()=>h(E).name,G=>h(E).name=G)),S(P);var U=_(P,2),oe=I(U);Id(oe),Mr(oe,G=>c?.(G)),un(()=>po(oe,()=>h(E).value,G=>h(E).value=G)),S(U);var ce=_(U,2),O=I(ce);S(ce),S(D),De("input",H,()=>{d(h(E))}),De("input",oe,()=>d(h(E))),De("click",O,()=>l(h(t).indexOf(h(E)))),$(C,D)}),S(p);var w=_(p,2),k=I(w);S(w),S(f),De("click",k,a),$(r,f),Ce()}Tt(["input","click"]);Pt();qt();var M4=require("obsidian");var ja=require("obsidian");Wt();Pi();Kr();var zpe=new Set;function TO(r){return r.type==="Multi"}function _O(r){return r.type==="Macro"}function Hpe(r){return r.type==="Template"}function jpe(r){return r.type==="Capture"}function xS(r,e,t){return r?e.has(r.id)?t.has(r.id):!0:!1}function b4(r,e,t,n){switch(r.type){case"Choice":{let i=r;if(!t.has(i.choiceId))return!0;let o=e.get(i.choiceId);return o&&xS(o.choice,e,t)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&xS(i.choice,e,t)&&n(i.choice),!0}default:return!1}}function Gpe(r){let e=new Map,t=(n,i,o)=>{for(let s of n){if(!Ye(s))continue;let a=[...o,s.name];e.set(s.id,{choice:s,parentId:i,path:a}),TO(s)&&Array.isArray(s.choices)&&t(s.choices,s.id,a)}};return t(gn(r),null,[]),e}function w4(r){let e=new Set;for(let t of st(r))Ye(t)&&e.add(t.id);return _O(r)&&EO(r.macro?.commands,e),e}function EO(r,e){for(let t of Ir(r))if(Di(t))switch(t.type){case"Choice":{let n=t;n.choiceId&&e.add(n.choiceId);break}case"Conditional":{let n=t;EO(n.thenCommands,e),EO(n.elseCommands,e);break}case"NestedChoice":{let i=t.choice;if(!i)break;let o=w4(i);for(let s of o)e.add(s);break}default:break}}function ES(r,e,t){let n=Gpe(r),i=new Set,o=new Set,s=t?.excludedChoiceIds??zpe,a=e.filter(c=>!s.has(c)),l=[];for(;a.length>0;){let c=a.shift();if(i.has(c))continue;if(s.has(c)){i.add(c);continue}let u=n.get(c);if(!u){o.add(c);continue}i.add(c),l.push(c);let d=w4(u.choice);for(let f of d){if(!n.has(f)){o.add(f);continue}s.has(f)||a.push(f)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function TS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&xS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),TO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);_O(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Ir(l))if(Di(c)&&!b4(c,r,t,s))switch(c.type){case"UserScript":{let u=c;u.path&&i.add(u.path);break}case"Conditional":{let u=c,d=u.condition;d.mode==="script"&&d.scriptPath&&o.add(d.scriptPath),a(u.thenCommands),a(u.elseCommands);break}default:break}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{userScriptPaths:i,conditionalScriptPaths:o}}function _S(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&xS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),Hpe(l)&&l.templatePath&&i.add(l.templatePath),jpe(l)&&l.createFileIfItDoesntExist?.enabled&&l.createFileIfItDoesntExist.createWithTemplate&&l.createFileIfItDoesntExist.template&&o.add(l.createFileIfItDoesntExist.template),TO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);_O(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Ir(l))if(Di(c)&&!b4(c,r,t,s)&&c.type==="Conditional"){let u=c;a(u.thenCommands),a(u.elseCommands)}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{templatePaths:i,captureTemplatePaths:o}}Wt();var S4=require("obsidian");function AS(r){return!!r&&typeof r=="object"}function C4(r){return Array.isArray(r)&&r.every(e=>typeof e=="string")}function Ype(r){return AS(r)?typeof r.id=="string"&&typeof r.name=="string"&&typeof r.type=="string":!1}function Kpe(r){return AS(r)?Ype(r.choice)&&C4(r.pathHint)&&(r.parentChoiceId===null||typeof r.parentChoiceId=="string"):!1}function Qpe(r){if(!AS(r))return!1;let{kind:e,originalPath:t,contentEncoding:n,content:i}=r;return(e==="user-script"||e==="conditional-script"||e==="template"||e==="capture-template")&&typeof t=="string"&&n==="base64"&&typeof i=="string"}function x4(r){if(!AS(r))return!1;let{schemaVersion:e,quickAddVersion:t,createdAt:n,rootChoiceIds:i,choices:o,assets:s}=r;return typeof e=="number"&&Number.isInteger(e)&&e>=1&&typeof t=="string"&&typeof n=="string"&&C4(i)&&Array.isArray(o)&&o.every(Kpe)&&Array.isArray(s)&&s.every(Qpe)}Me();Yp();var E4=typeof TextEncoder<"u"?new TextEncoder:void 0,T4=typeof TextDecoder<"u"?new TextDecoder:void 0;function _4(r){return typeof window>"u"?!1:typeof window[r]=="function"}function A4(){if(!(typeof Buffer>"u"))return Buffer}function k4(r){if(E4&&_4("btoa")){let t=E4.encode(r),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return window.btoa(n)}let e=A4();if(e)return e.from(r,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this environment.")}function zc(r){if(T4&&_4("atob")){let t=window.atob(r),n=Uint8Array.from(t,i=>i.charCodeAt(0));return T4.decode(n)}let e=A4();if(e)return e.from(r,"base64").toString("utf8");throw new Error("Base64 decoding is not supported in this environment.")}yi();Wt();async function kS(r,e){let t=e.lastIndexOf("/");if(t<0)return;let n=e.slice(0,t);if(!n)return;let i=n.split("/").filter(Boolean),o="";for(let s of i)o=o?`${o}/${s}`:s,await r.vault.adapter.exists(o)||await r.vault.createFolder(o)}qc();function D4(){return`QuickAdd Packages/quickadd-package-${new Date().toISOString().replace(/[:.]/g,"-")}.quickadd.json`}async function I4(r,e){let{choices:t,rootChoiceIds:n,quickAddVersion:i}=e,o=new Set(e.excludedChoiceIds??[]),s=e.createdAt??new Date().toISOString(),a=ES(t,n,{excludedChoiceIds:o}),l=new Set(a.choiceIds),c=TS(a.catalog,a.choiceIds),u=_S(a.catalog,a.choiceIds),d=Xpe(c,u),f=await Zpe(r,d),p=Jpe(f.encodedAssets),m=a.choiceIds.map(y=>{let w=a.catalog.get(y);if(!w)throw new Error(`Choice '${y}' missing from catalog.`);let k=vt(w.choice);return P4(k,l),Wh(k,{secretOptionNamesByPath:p,stripUnknownStringSettings:!0}),{choice:k,pathHint:[...w.path],parentChoiceId:w.parentId}}),v=n.filter(y=>l.has(y));return{pkg:{schemaVersion:1,quickAddVersion:i,createdAt:s,rootChoiceIds:[...v],choices:m,assets:f.encodedAssets},missingChoiceIds:a.missingChoiceIds,missingAssets:f.missingAssets}}function Xpe(r,e){let t=new Map;for(let n of r.userScriptPaths)n&&t.set(n,"user-script");for(let n of r.conditionalScriptPaths)n&&t.set(n,"conditional-script");for(let n of e.templatePaths)n&&(t.has(n)||t.set(n,"template"));for(let n of e.captureTemplatePaths)n&&(t.has(n)||t.set(n,"capture-template"));return Array.from(t.entries()).map(([n,i])=>({path:n,kind:i}))}async function Zpe(r,e){let t=[],n=[];for(let{path:i,kind:o}of e)try{if(!await r.vault.adapter.exists(i)){n.push({path:i,kind:o}),M.logWarning(`QuickAdd export skipped missing ${o}: ${i}`);continue}let a=await r.vault.adapter.read(i);t.push({kind:o,originalPath:i,contentEncoding:"base64",content:k4(a)})}catch(s){n.push({path:i,kind:o}),M.logWarning(`QuickAdd export failed to read ${o} '${i}': ${s?.message??s}`)}return{encodedAssets:t,missingAssets:n}}function Jpe(r){let e=new Map;for(let t of r)if(t.kind==="user-script")try{let n=Vh(zc(t.content),t.originalPath);e.set(t.originalPath,n.foundSecretOptions&&n.names.size===0?null:n.names)}catch(n){M.logWarning(`QuickAdd export could not inspect user-script settings '${t.originalPath}': ${n?.message??n}`)}return e}function P4(r,e){if(r.type!=="Multi")return;let t=r;if(!Array.isArray(t.choices)||t.choices.length===0){t.choices=[];return}t.choices=t.choices.filter(n=>Ye(n)&&e.has(n.id)).map(n=>(P4(n,e),n))}async function efe(r,e){return Xi.Prompt(r,"Overwrite existing file?",`A file already exists at '${e}'. Saving the package will overwrite it. Continue?`)}async function F4(r,e,t,n={}){let i=(0,S4.normalizePath)(t.trim());if(!i)throw new Error("Output path cannot be empty.");let o=await r.vault.adapter.exists(i);if(o&&!await(n.confirmOverwrite??(c=>efe(r,c)))(i))throw new Error(`Save cancelled: '${i}' already exists.`);await kS(r,i);let s=JSON.stringify(e,null,2);return await r.vault.adapter.write(i,s),{overwritten:o}}var tfe=q('<p class="emptyState svelte-llmxn2">No choices match the current filter.</p>'),rfe=q('<span class="choicePath svelte-llmxn2"> </span>'),nfe=q('<li><label class="svelte-llmxn2"><input type="checkbox"/> <span class="choiceName svelte-llmxn2"> </span> <!> <span class="choiceType svelte-llmxn2"> </span></label></li>'),ife=q('<ul class="svelte-llmxn2"></ul>'),ofe=q('<div class="warning svelte-llmxn2"><strong>Missing dependencies detected</strong> <p> </p></div>'),sfe=q("<p> </p>"),afe=q('<li> <span class="assetKind svelte-llmxn2"> </span></li>'),lfe=q('<div><p>Missing assets:</p> <ul class="svelte-llmxn2"></ul></div>'),cfe=q('<section class="warning svelte-llmxn2"><h4>Warnings</h4> <!> <!></section>'),ufe=q('<div class="exportPackageModal svelte-llmxn2"><header class="svelte-llmxn2"><h2>Export QuickAdd package</h2> <p class="svelte-llmxn2">Select choices to bundle. Dependencies are added automatically.</p></header> <section class="controls svelte-llmxn2"><input type="text" placeholder="Filter choices" autocapitalize="off" autocorrect="off" class="svelte-llmxn2"/> <div class="controlButtons svelte-llmxn2"><button type="button" class="svelte-llmxn2">Select visible</button> <button type="button" class="svelte-llmxn2">Clear selection</button></div></section> <section class="choiceList svelte-llmxn2"><!></section> <section class="summary svelte-llmxn2"><h3 class="svelte-llmxn2">Package summary</h3> <div class="summaryGrid svelte-llmxn2"><div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Selected choices</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Total packaged</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Auto-included</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Scripts embedded</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Templates embedded</span></div></div> <!></section> <!> <section class="actions svelte-llmxn2"><div class="actionGroup svelte-llmxn2"><button type="button" class="secondary svelte-llmxn2"><!></button></div> <div class="actionGroup svelte-llmxn2"><label><span>Save to file</span> <div class="saveRow svelte-llmxn2"><input type="text" placeholder="QuickAdd Packages/quickadd-package-YYYY-MM-DD.quickadd.json" class="svelte-llmxn2"/> <button type="button" class="svelte-llmxn2"><!></button></div></label></div></section> <section class="footer svelte-llmxn2"><button type="button" class="secondary svelte-llmxn2">Cancel</button></section></div>'),dfe={hash:"svelte-llmxn2",code:`.exportPackageModal.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;width:min(640px, 100%);min-width:0;max-height:75vh;}header.svelte-llmxn2 p:where(.svelte-llmxn2) {margin:0;color:var(--text-muted);}.controls.svelte-llmxn2 {display:flex;gap:0.75rem;align-items:center;flex-wrap:wrap;}.controls.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.controlButtons.svelte-llmxn2 {display:flex;gap:0.5rem;flex-wrap:wrap;justify-content:flex-end;}.choiceList.svelte-llmxn2 {flex:1;min-height:180px;max-height:260px;overflow:auto;border:1px solid var(--background-modifier-border);border-radius:6px;padding:0.5rem;}.choiceList.svelte-llmxn2 ul:where(.svelte-llmxn2) {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.choiceList.svelte-llmxn2 label:where(.svelte-llmxn2) {display:flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;border-radius:4px;}.choiceList.svelte-llmxn2 label:where(.svelte-llmxn2):hover {background:var(--background-modifier-hover);}.choiceName.svelte-llmxn2 {font-weight:600;}.choicePath.svelte-llmxn2 {color:var(--text-muted);font-size:0.8rem;}.choiceType.svelte-llmxn2 {margin-left:auto;font-size:0.75rem;text-transform:uppercase;color:var(--text-faint);}.emptyState.svelte-llmxn2 {margin:0;color:var(--text-muted);text-align:center;}.summary.svelte-llmxn2 {border:1px solid var(--background-modifier-border);border-radius:6px;padding:0.75rem;display:flex;flex-direction:column;gap:0.5rem;}.summary.svelte-llmxn2 h3:where(.svelte-llmxn2) {margin:0 0 0.5rem 0;font-size:1rem;}.summaryGrid.svelte-llmxn2 {display:grid;grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));gap:0.75rem;}.summaryGrid.svelte-llmxn2 div:where(.svelte-llmxn2) {display:flex;flex-direction:column;}.summaryGrid.svelte-llmxn2 strong:where(.svelte-llmxn2) {font-size:1.1rem;}
/* Neutral surface with an amber-tinted border (these are warnings, not
critical danger): ranked, not a blanket-red fill \u2014 matches the import
modal's CapabilityBanner treatment. */.warning.svelte-llmxn2 {border:1px solid var(--qa-sev-warning-border);background:var(--background-secondary);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;color:var(--text-normal);}.warning.svelte-llmxn2 ul:where(.svelte-llmxn2) {margin:0.25rem 0 0 1rem;padding:0;}.assetKind.svelte-llmxn2 {color:var(--text-muted);}.actions.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;}.actionGroup.svelte-llmxn2 {display:flex;flex-direction:column;gap:0.5rem;}.saveRow.svelte-llmxn2 {display:flex;gap:0.5rem;}.saveRow.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.footer.svelte-llmxn2 {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-llmxn2 button.secondary:where(.svelte-llmxn2) {background:transparent;}
@media (max-width: 600px) {.exportPackageModal.svelte-llmxn2 {max-height:90vh;padding-bottom:0.5rem;}.controls.svelte-llmxn2 {flex-direction:column;align-items:stretch;gap:0.5rem;}.controlButtons.svelte-llmxn2 {width:100%;flex-direction:column;gap:0.5rem;align-items:stretch;}.controlButtons.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.choiceList.svelte-llmxn2 {min-height:160px;max-height:40vh;}.summaryGrid.svelte-llmxn2 {grid-template-columns:1fr;}.actions.svelte-llmxn2 {gap:0.75rem;}.actionGroup.svelte-llmxn2 {align-items:stretch;}.actionGroup.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.saveRow.svelte-llmxn2 {flex-direction:column;}.saveRow.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.footer.svelte-llmxn2 {flex-direction:column-reverse;align-items:stretch;}.footer.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}
}`};function AO(r,e){we(e,!0),ot(r,dfe);let t={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=_e(""),i=_e(Ct(new Set)),o=_e(Ct(new Set)),s=_e(Ct(D4())),a=_e(null),l=_e(null),c=N(()=>vy(e.allChoices)),u=N(()=>v(h(c),h(n))),d=N(()=>E(h(c),h(i))),f=N(()=>x(e.allChoices,h(d),h(o))),p=N(()=>new Map(h(c).map(A=>[A.id,A.path.join(" / ")])));function m(A){return A.type==="Multi"}function v(A,L){let Q=L.trim().toLowerCase();return Q?A.filter(ee=>`${ee.path.join(" ")} ${ee.choice.type}`.toLowerCase().includes(Q)):A}function g(A){let L=[];for(let Q of st(A))Ye(Q)&&L.push(Q.id,...g(Q));return L}function y(A,L){let Q=[A.id,...g(A)];if(L){let ee=new Set(h(i));for(let ue of Q)ee.add(ue);if(J(i,ee,!0),h(o).size>0){let ue=new Set(h(o));for(let ve of Q)ue.delete(ve);J(o,ue,!0)}}else{let ee=new Set(h(i));for(let ve of Q)ee.delete(ve);J(i,ee,!0);let ue=new Set(h(o));for(let ve of Q)ue.add(ve);J(o,ue,!0)}}function w(A){let L=h(c).find(ee=>ee.id===A);if(!L)return;let Q=h(i).has(A);y(L.choice,!Q),J(a,null)}function k(){for(let A of h(u))y(A.choice,!0);J(a,null)}function C(){J(i,new Set,!0),J(o,new Set,!0),J(a,null)}function E(A,L){let Q=[];for(let ee of A)L.has(ee.id)&&(!ee.parentId||!L.has(ee.parentId))&&Q.push(ee.id);return Q}function x(A,L,Q){if(L.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};let ee=ES(A,L,{excludedChoiceIds:Q}),ue=TS(ee.catalog,ee.choiceIds),ve=_S(ee.catalog,ee.choiceIds);return{rootCount:L.length,totalChoices:ee.choiceIds.length,dependencyCount:Math.max(ee.choiceIds.length-L.length,0),missingChoiceIds:ee.missingChoiceIds,userScripts:ue.userScriptPaths.size,conditionalScripts:ue.conditionalScriptPaths.size,templateFiles:ve.templatePaths.size,captureTemplates:ve.captureTemplatePaths.size}}function D(A){let{missingChoiceIds:L,missingAssets:Q}=A;return L.length===0&&Q.length===0?null:{missingChoices:L,missingAssets:Q}}async function P(){if(h(d).length===0)return new ja.Notice("Select at least one choice to export."),null;try{let A=await I4(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});return J(a,D(A),!0),A}catch(A){return console.error(A),J(a,null),new ja.Notice(`Export failed: ${A?.message??String(A)}`),null}}async function H(){if(!h(l)){J(l,"copy");try{let A=await P();if(!A)return;let L=JSON.stringify(A.pkg,null,2);await oe(L),new ja.Notice(`Copied package (${A.pkg.choices.length} choice${A.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?new ja.Notice("Package copied with warnings. Review details below."):e.close()}catch(A){console.error(A),new ja.Notice(`Copy failed: ${A?.message??String(A)}`)}finally{J(l,null)}}}async function U(){if(h(l))return;let A=h(s).trim();if(!A){new ja.Notice("Enter a file path before saving.");return}J(l,"save");try{let L=await P();if(!L)return;let{overwritten:Q}=await F4(e.app,L.pkg,A),ee=L.pkg.choices.length,ue=`${ee} choice${ee===1?"":"s"}`;new ja.Notice(Q?`Overwrote package (${ue}) at '${A}'.`:`Saved package (${ue}) to '${A}'.`),h(a)?new ja.Notice("Package saved with warnings. Review details below."):e.close()}catch(L){let Q=L?.message??String(L);if(Q.startsWith("Save cancelled:")){new ja.Notice("Save cancelled.");return}console.error(L),new ja.Notice(`Save failed: ${Q}`)}finally{J(l,null)}}async function oe(A){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(A);return}let L=document.createElement("textarea");L.value=A,L.setAttribute("readonly","true"),L.style.position="fixed",L.style.opacity="0",document.body.appendChild(L),L.focus(),L.select();let Q=document.execCommand("copy");if(document.body.removeChild(L),!Q)throw new Error("Clipboard copy is not supported in this environment.")}var ce=ufe(),O=_(I(ce),2),G=I(O);gr(G),Ae(G,"spellcheck",!1);var V=_(G,2),F=I(V),Z=_(F,2);S(V),S(O);var z=_(O,2),Y=I(z);{var K=A=>{var L=tfe();$(A,L)},se=A=>{var L=ife();ar(L,21,()=>h(u),Q=>Q.id,(Q,ee)=>{var ue=nfe(),ve=I(ue),Ue=I(ve);gr(Ue);var bt=_(Ue,2),Fr=I(bt,!0);S(bt);var jt=_(bt,2);{var Oi=Sr=>{var Yn=rfe(),St=I(Yn,!0);S(Yn),de(To=>me(St,To),[()=>h(ee).path.slice(0,-1).join(" \u203A ")]),$(Sr,Yn)};ie(jt,Sr=>{h(ee).path.length>1&&Sr(Oi)})}var wt=_(jt,2),pr=I(wt,!0);S(wt),S(ve),S(ue),de((Sr,Yn)=>{Xf(ue,`padding-left: ${h(ee).depth*16}px`),jd(Ue,Sr),me(Fr,Yn),me(pr,h(ee).choice.type)},[()=>h(i).has(h(ee).id),()=>h(ee).path.at(-1)]),De("change",Ue,()=>w(h(ee).id)),$(Q,ue)}),S(L),$(A,L)};ie(Y,A=>{h(u).length===0?A(K):A(se,-1)})}S(z);var pe=_(z,2),ge=_(I(pe),2),be=I(ge),Be=I(be),Se=I(Be,!0);S(Be),Pn(2),S(be);var ut=_(be,2),Ne=I(ut),Qe=I(Ne,!0);S(Ne),Pn(2),S(ut);var Ze=_(ut,2),ye=I(Ze),We=I(ye,!0);S(ye),Pn(2),S(Ze);var gt=_(Ze,2),He=I(gt),Te=I(He,!0);S(He),Pn(2),S(gt);var Ve=_(gt,2),dt=I(Ve),or=I(dt,!0);S(dt),Pn(2),S(Ve),S(ge);var yr=_(ge,2);{var Ft=A=>{var L=ofe(),Q=_(I(L),2),ee=I(Q);S(Q),S(L),de(ue=>me(ee,`The following choice IDs were referenced but not found:
${ue??""}`),[()=>h(f).missingChoiceIds.join(", ")]),$(A,L)};ie(yr,A=>{h(f).missingChoiceIds.length>0&&A(Ft)})}S(pe);var kr=_(pe,2);{var ur=A=>{var L=cfe(),Q=_(I(L),2);{var ee=Ue=>{var bt=sfe(),Fr=I(bt);S(bt),de(jt=>me(Fr,`Missing choices:
${jt??""}`),[()=>h(a).missingChoices.map(jt=>h(p).get(jt)??jt).join(", ")]),$(Ue,bt)};ie(Q,Ue=>{h(a).missingChoices.length>0&&Ue(ee)})}var ue=_(Q,2);{var ve=Ue=>{var bt=lfe(),Fr=_(I(bt),2);ar(Fr,21,()=>h(a).missingAssets,jt=>jt.path,(jt,Oi)=>{var wt=afe(),pr=I(wt),Sr=_(pr),Yn=I(Sr);S(Sr),S(wt),de(()=>{me(pr,`${h(Oi).path??""} `),me(Yn,`(${t[h(Oi).kind]??""})`)}),$(jt,wt)}),S(Fr),S(bt),$(Ue,bt)};ie(ue,Ue=>{h(a).missingAssets.length>0&&Ue(ve)})}S(L),$(A,L)};ie(kr,A=>{h(a)&&A(ur)})}var pt=_(kr,2),Mt=I(pt),jn=I(Mt),Eo=I(jn);{var Ts=A=>{var L=fl("Copying\u2026");$(A,L)},Gn=A=>{var L=fl("Copy JSON");$(A,L)};ie(Eo,A=>{h(l)==="copy"?A(Ts):A(Gn,-1)})}S(jn),S(Mt);var ne=_(Mt,2),Ie=I(ne),dr=_(I(Ie),2),br=I(dr);gr(br);var _n=_(br,2),jo=I(_n);{var Ja=A=>{var L=fl("Saving\u2026");$(A,L)},el=A=>{var L=fl("Save to file");$(A,L)};ie(jo,A=>{h(l)==="save"?A(Ja):A(el,-1)})}S(_n),S(dr),S(Ie),S(ne),S(pt);var ru=_(pt,2),T=I(ru);S(ru),S(ce),de(()=>{me(Se,h(f).rootCount),me(Qe,h(f).totalChoices),me(We,h(f).dependencyCount),me(Te,h(f).userScripts+h(f).conditionalScripts),me(or,h(f).templateFiles+h(f).captureTemplates),jn.disabled=h(l)!==null,_n.disabled=h(l)!==null,T.disabled=h(l)!==null}),po(G,()=>h(n),A=>J(n,A)),De("click",F,k),De("click",Z,C),De("click",jn,H),po(br,()=>h(s),A=>J(s,A)),De("click",_n,U),De("click",T,function(...A){e.close?.apply(this,A)}),$(r,ce),Ce()}Tt(["click","change"]);var DS=class extends M4.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=Wi(this.contentEl,AO,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var c5=require("obsidian");var Hx=require("obsidian");Pt();qt();var OS=require("obsidian");bl();Wt();Pi();Kr();Kr();Kr();Wt();Pi();function pfe(r){return r.type==="Multi"}function ffe(r){return r.type==="Macro"}function kO(r,e,t){if(!(!r||typeof r!="object")){if(Array.isArray(r)){e.onUnreadable?.();return}if(!t.has(r)){if(t.add(r),e.onChoice?.(r),pfe(r))if(Array.isArray(r.choices))for(let n of r.choices)kO(n,e,t);else C_(r.choices)&&e.onUnreadable?.();ffe(r)&&IS(zn(r.macro),e,t)}}}function IS(r,e,t){if(!Array.isArray(r)){Ii(r)&&e.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){e.onUnreadable?.();continue}e.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(IS(i.thenCommands,e,t),IS(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&kO(a,e,t)}}function SO(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)kO(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)IS(zn(i),e,t);else Ii(n)&&e.onUnreadable?.()}function hg(r){let e=!1;return SO(r,{onUnreadable:()=>{e=!0}}),e}function gg(r,e){SO(r.settings,{onChoice:e})}function PS(r,e){SO(r,{onCommand:e})}function mfe(r){return r.type==="AIAssistant"}function FS(r,e,t){let n=0;return PS({choices:r},i=>{if(!mfe(i)||i.modelRef&&i.modelRef.name===i.model&&e.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=e.find(a=>a.models.some(l=>l.name===i.model));if(!o?.id)return;let s={providerId:o.id,name:i.model};i.modelRef=s,n++,t?.(i,s)}),n}Me();yi();IO();_c();qc();Kr();Wt();Pi();iy();_t();var FO={"user-script":{severity:"critical",label:"SCRIPT",description:"Runs custom JavaScript with full access to your vault and the network."},"conditional-script":{severity:"critical",label:"CONDITIONAL",description:"Runs custom JavaScript to decide which branch executes."},"bundled-script":{severity:"critical",label:"SCRIPT FILE",description:"Bundles a file that will be written to your vault and can be run as code."},"run-on-startup":{severity:"critical",label:"STARTUP",description:"Runs automatically every time Obsidian starts."},"mislabeled-executable":{severity:"critical",label:"EXECUTABLE",description:"A bundled file is run as code even though it is labeled a template."},"registers-command":{severity:"warning",label:"COMMAND",description:"Adds a command to the command palette."},"obsidian-command":{severity:"warning",label:"OBSIDIAN",description:"Triggers another Obsidian command."},ai:{severity:"warning",label:"AI",description:"Sends note content to your AI provider over the network."},"ai-tools":{severity:"critical",label:"AI TOOLS",description:"Lets an AI model read and write your vault: the script gives the model tools (functions) it calls with model-chosen arguments."},"capture-writes":{severity:"warning",label:"WRITES",description:"Writes captured text into your notes."},"template-write":{severity:"warning",label:"TEMPLATE",description:"Creates notes from a bundled template."},"overwrites-existing-choice":{severity:"warning",label:"OVERWRITES",description:"Replaces a choice that already exists in your vault."},"overwrites-existing-file":{severity:"warning",label:"OVERWRITES",description:"Overwrites a file that already exists in your vault."},"missing-reference":{severity:"warning",label:"MISSING",description:"References a file that is not bundled in this package."},"unknown-command":{severity:"warning",label:"UNKNOWN",description:"An unrecognised command type. Review it manually."},"editor-command":{severity:"info",label:"EDITOR",description:"Runs a built-in editor command."},"open-file":{severity:"info",label:"OPEN FILE",description:"Opens a file in your vault."}};function MS(r){return FO[r].severity}function O4(r){return FO[r].label}function N4(r){return FO[r].description}function L4(r){return r==="user-script"||r==="conditional-script"}function gfe(r,e){return L4(r)||!ir.test(e)}function vfe(r,e){if(!ir.test(r))return!1;let t;try{t=zc(e)}catch{return!1}let{code:n}=vc(t);return n!==null&&n.length>0}function yfe(r,e){let t;try{t=zc(e)}catch{return null}if(ir.test(r)){let{code:n}=vc(t);return n!==null&&n.length>0?n:null}return t}var bfe=/\bai\s*\.\s*(?:tools|agent|tool)\b|\btools\s*\.\s*(?:vault|workspace|system)\s*\(/;function wfe(r){return bfe.test(r)}var RS={critical:0,warning:1,info:2},Cfe=new Set(Object.values(Vr));function Ga(r){return r.filter(e=>!!e).join(" \u203A ")}function xfe(r){let e=r.name?.trim();return e&&e.length>0?e:String(r.type)}function Efe(r){if(r.mode==="script")return`script: ${r.scriptPath}${r.exportName?` (${r.exportName})`:""}`;let e=r.expectedValue!==void 0?` ${r.expectedValue}`:"";return`${r.variableName} ${r.operator}${e}`}function Tfe(r){return r.type==="Macro"}function _fe(r){return r.type==="Multi"}function Afe(r){return r.type==="Template"}function kfe(r){return r.type==="Capture"}function Sfe(r){let e=r.fileExistsBehavior;return!e||e.kind!=="apply"?!1:e.mode==="overwrite"||e.mode==="appendTop"||e.mode==="appendBottom"}function B4(r){let e=[],t=new Set(r.choices.map(n=>n.choice.id));for(let n of r.choices){let i=n.choice,o=Ga(n.pathHint.slice(0,-1))||"Root",s={choiceId:i.id,name:i.name,type:i.type,location:o,registersCommand:!1,flags:new Set,commands:[],usages:[],rows:[]};MO(i,s,[i.name],t,0),e.push(s)}return{choiceWalks:e}}function MO(r,e,t,n,i){if(r.command&&(e.registersCommand=!0,e.flags.add("registers-command")),Tfe(r)&&(r.runOnStartup&&(e.flags.add("run-on-startup"),e.rows.push({flag:"run-on-startup",severity:"critical",title:"Runs automatically every time Obsidian starts",detail:Ga(t)})),PO(r.macro?.commands,e,t,n,i)),Afe(r)&&(r.templatePath&&e.usages.push({choiceId:e.choiceId,path:r.templatePath,asScript:!1,impliedKind:"template",breadcrumb:Ga([...t,"template"])}),Sfe(r)&&e.flags.add("template-write")),kfe(r)){e.flags.add("capture-writes");let o=r.createFileIfItDoesntExist;o?.enabled&&o.createWithTemplate&&o.template&&e.usages.push({choiceId:e.choiceId,path:o.template,asScript:!1,impliedKind:"capture-template",breadcrumb:Ga([...t,"new-file template"])})}if(_fe(r)&&Array.isArray(r.choices))for(let o of r.choices)Ye(o)&&(n.has(o.id)||MO(o,e,[...t,o.name],n,i))}function PO(r,e,t,n,i){for(let o of Ir(r)){if(!Di(o))continue;let s=xfe(o),a=[...t,s];switch(o.type){case"UserScript":{let l=o;e.flags.add("user-script"),e.commands.push({name:s,type:o.type,depth:i,flag:"user-script",scriptPath:l.path}),l.path&&(e.usages.push({choiceId:e.choiceId,path:l.path,asScript:!0,impliedKind:"user-script",breadcrumb:Ga(a)}),e.rows.push({flag:"user-script",severity:"critical",title:"Runs custom JavaScript with full access to your vault and the network",detail:`${Ga(a)} (${l.path})`,scriptPath:l.path}));break}case"Conditional":{let l=o,c=l.condition,u=c?Efe(c):void 0,d=c?.mode==="script"&&!!c.scriptPath;if(e.commands.push({name:s,type:o.type,depth:i,flag:d?"conditional-script":void 0,scriptPath:d?c.scriptPath:void 0,summary:u}),d){let f=c.scriptPath;e.flags.add("conditional-script"),e.usages.push({choiceId:e.choiceId,path:f,asScript:!0,impliedKind:"conditional-script",breadcrumb:Ga(a)}),e.rows.push({flag:"conditional-script",severity:"critical",title:"Runs custom JavaScript chosen by a condition",detail:`${Ga(a)} (${f})`,scriptPath:f})}PO(l.thenCommands??[],e,[...a,"then"],n,i+1),PO(l.elseCommands??[],e,[...a,"else"],n,i+1);break}case"NestedChoice":{let l=o;e.commands.push({name:s,type:o.type,depth:i}),l.choice&&MO(l.choice,e,[...a,l.choice.name],n,i+1);break}case"Obsidian":{let l=o;e.flags.add("obsidian-command"),e.commands.push({name:s,type:o.type,depth:i}),e.rows.push({flag:"obsidian-command",severity:"warning",title:"Triggers another Obsidian command",detail:`${Ga(a)}${l.commandId?` (${l.commandId})`:""}`});break}case"AIAssistant":{e.flags.add("ai"),e.commands.push({name:s,type:o.type,depth:i}),e.rows.push({flag:"ai",severity:"warning",title:"Sends note content to your AI provider over the network",detail:Ga(a)});break}case"EditorCommand":{e.flags.add("editor-command"),e.commands.push({name:s,type:o.type,depth:i});break}case"OpenFile":{e.flags.add("open-file"),e.commands.push({name:s,type:o.type,depth:i});break}case"Choice":case"Wait":{e.commands.push({name:s,type:o.type,depth:i});break}default:{Cfe.has(String(o.type))?e.commands.push({name:s,type:String(o.type),depth:i}):(e.flags.add("unknown-command"),e.commands.push({name:s,type:String(o.type),depth:i,flag:"unknown-command"}),e.rows.push({flag:"unknown-command",severity:"warning",title:"Unknown capability. Review it manually.",detail:`${Ga(a)} (${String(o.type)})`}));break}}}}function V4(r){let{choiceWalks:e}=B4(r),t=new Set;for(let n of e)for(let i of n.usages)i.path&&t.add(i.path);return Array.from(t)}function Dfe(r){let e=r.length;if(e===0)return 0;let t=0;return r.endsWith("==")?t=2:r.endsWith("=")&&(t=1),Math.max(0,Math.floor(e*3/4)-t)}function Ife(r,e){return RS[MS(r)]-RS[MS(e)]}function U4(r,e,t){let{choiceWalks:n}=B4(e),i=new Set(Vn(r).map(x=>x.id)),o=new Map;for(let x of n)for(let D of x.usages){let P=o.get(D.path)??[];P.push(D),o.set(D.path,P)}let s=new Set;for(let[x,D]of o)D.some(P=>P.asScript)&&s.add(x);let a=new Set(e.assets.map(x=>x.originalPath)),l=e.assets.map(x=>{let D=o.get(x.originalPath)??[],P=s.has(x.originalPath),H=P||gfe(x.kind,x.originalPath)||vfe(x.originalPath,x.content);return{originalPath:x.originalPath,kind:x.kind,bundled:!0,executable:P,requiresReview:H,exists:t.has(x.originalPath),sizeBytes:Dfe(x.content),orphan:D.length===0,referencedBy:D}}),c=n.map(x=>{let D=i.has(x.choiceId),P=Array.from(x.flags);return D&&P.push("overwrites-existing-choice"),P.sort(Ife),{choiceId:x.choiceId,name:x.name,type:x.type,location:x.location,exists:D,registersCommand:x.registersCommand,flags:P,commands:x.commands}}),u=[];for(let[x,D]of o){if(a.has(x)||t.has(x))continue;let P=D.some(H=>H.asScript);u.push({path:x,asScript:P,breadcrumb:D[0]?.breadcrumb??x})}let d=l.filter(x=>x.orphan).map(x=>x.originalPath),f=[];for(let x of n)for(let D of x.rows)f.push(D);for(let x of l)x.executable&&(L4(x.kind)||f.push({flag:"mislabeled-executable",severity:"critical",title:"Runs a file as code even though it is labeled a template",detail:x.originalPath,scriptPath:x.originalPath}));for(let x of l)x.requiresReview&&(x.executable||f.push({flag:"bundled-script",severity:"critical",title:"Bundles a file that will be written to your vault and can be run as code",detail:x.originalPath,scriptPath:x.originalPath}));for(let x of l){if(!x.requiresReview)continue;let D=e.assets.find(H=>H.originalPath===x.originalPath);if(!D)continue;let P=yfe(D.originalPath,D.content);!P||!wfe(P)||f.push({flag:"ai-tools",severity:"critical",title:"Lets an AI model read and write your vault",detail:x.originalPath,scriptPath:x.originalPath})}let p=c.filter(x=>x.registersCommand).length;p>0&&f.push({flag:"registers-command",severity:"warning",title:"Adds commands to the command palette",detail:`${p} choice${p===1?"":"s"}`});let m=c.filter(x=>x.exists).length;m>0&&f.push({flag:"overwrites-existing-choice",severity:"warning",title:"Replaces choices that already exist in your vault",detail:`${m} choice${m===1?"":"s"}`});let v=l.filter(x=>x.exists).length;if(v>0&&f.push({flag:"overwrites-existing-file",severity:"warning",title:"Overwrites existing files in your vault",detail:`${v} file${v===1?"":"s"}`}),u.length>0){let x=u.filter(D=>D.asScript).length;f.push({flag:"missing-reference",severity:x>0?"critical":"warning",title:x>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"}`})}f.sort((x,D)=>RS[x.severity]-RS[D.severity]);let g=l.filter(x=>x.requiresReview).map(x=>x.originalPath),y=s.size,w=n.some(x=>x.flags.has("run-on-startup")),k=f.filter(x=>x.severity==="critical").length,C=f.filter(x=>x.severity==="warning").length,E={hasCritical:k>0,hasWarning:C>0,criticalCount:k,warningCount:C,runsOnStartup:w,scriptCount:y,registersCommandCount:p,overwritesChoices:m,overwritesFiles:v,missingCount:u.length};return{quickAddVersion:e.quickAddVersion,createdAt:e.createdAt,choiceCount:e.choices.length,fileCount:e.assets.length,choices:c,files:l,capabilityRows:f,missingReferences:u,orphanAssets:d,criticalScriptPaths:g,summary:E}}var $4=1e5;function Pfe(r){return typeof TextEncoder<"u"?new TextEncoder().encode(r).length:r.length}function Ffe(r){if(r.length<1e3)return!1;let e=0,t=1,n=0;for(let o=0;o<r.length;o++)r[o]===`
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);let i=r.length/t;return e>1e3||i>250}function $S(r,e){let t=r.assets.find(n=>n.originalPath===e);if(!t)return{found:!1,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:"File is not bundled in this package."};try{let n=zc(t.content),i=n.length>$4,o=i?n.slice(0,$4):n;return{found:!0,text:o,truncated:i,sizeBytes:Pfe(n),looksMinified:Ffe(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function q4(r){return r.summary.hasCritical}function W4(r,e){return r.criticalScriptPaths.every(t=>e.has(t))}async function z4(r,e){if(Un(e))throw new Error(`Refusing to read a package outside the vault: "${e}".`);let t=(0,OS.normalizePath)(e.trim());if(!t)throw new Error("Package path cannot be empty.");if(!await r.vault.adapter.exists(t))throw new Error(`Package file not found: ${t}`);let i=await r.vault.adapter.read(t);return{pkg:LO(i),path:t}}function LO(r){let e;try{e=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!x4(e))throw new Error("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)throw new Error(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);let t=Mfe(e.assets);if(t!==null)throw new Error(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);let n=Rfe(e.choices);if(n!==null)throw new Error(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);let i=$fe(e.choices);if(i!==null)throw new Error(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);return e}function Mfe(r){let e=new Set;for(let t of r){let n=(0,OS.normalizePath)(t.originalPath??"");if(e.has(n))return t.originalPath;e.add(n)}return null}function Rfe(r){let e=new Map,t=null,n=i=>{if(t!==null||!i||typeof i!="object")return;let o=i.id;if(typeof o=="string"){let s=$O(i),a=e.get(o);if(a===void 0)e.set(o,s);else if(a!==s){t=o;return}}if(i.type==="Multi"){let s=i;if(Array.isArray(s.choices))for(let a of s.choices)n(a)}i.type==="Macro"&&RO(i.macro?.commands,n)};for(let i of r){if(t!==null)break;n(i?.choice)}return t}function RO(r,e){if(Array.isArray(r)){for(let t of r)if(t){if(t.type==="NestedChoice")e(t.choice);else if(t.type==="Conditional"){let n=t;RO(n.thenCommands,e),RO(n.elseCommands,e)}}}}function $O(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($O).join(",")}]`;let e=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${$O(e[n])}`).join(",")}}`}function $fe(r){let e=new Map(r.map(t=>[t.choice.id,t]));for(let t of r){let n=t.parentChoiceId;if(n===null)continue;let i=e.get(n);if(!i)continue;let o=i.choice;if(!st(o).some(a=>a?.id===t.choice.id))return t.choice.id}return null}async function H4(r,e,t){let n=new Map(Vn(e).map(s=>[s.id,s])),i=t.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(let s of t.assets){let a=Un(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 NS(r,e,t){let n=new Set([...t.assets.map(a=>a.originalPath),...V4(t)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Un(a)||await G4(r,a)&&i.add(a))}));let o=U4(e,t,i),{summary:s}=o;return M.logMessage(`QuickAdd import preview: choices=${o.choiceCount} files=${o.fileCount} scripts=${s.scriptCount} runOnStartup=${s.runsOnStartup} registersCommands=${s.registersCommandCount} overwritesChoices=${s.overwritesChoices} overwritesFiles=${s.overwritesFiles} missing=${s.missingCount} critical=${s.criticalCount} warning=${s.warningCount}`),o}function Ofe(r){let t=(r??"").trim();if(!t)throw new Error("Package asset has an empty destination path.");let n=t.replace(/\\/g,"/");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new Error(`Refusing to import asset to an absolute path outside the vault: "${n}".`);let i=(0,OS.normalizePath)(t);if(!i||i.trim()==="")throw new Error("Package asset has an empty destination path.");let o=i.split("/").filter(a=>a.length>0);if(o.some(a=>a===".."))throw new Error(`Refusing to import asset with a path-traversal segment ("..") in: "${i}".`);if(o.find(a=>a.startsWith(".")&&!a.startsWith("..%")))throw new Error(`Refusing to import asset into a config directory: "${i}".`);return i}async function j4(r){let{app:e,existingChoices:t,pkg:n}=r,i=new Map(r.choiceDecisions.map(O=>[O.choiceId,O.mode])),o=new Map(r.assetDecisions.map(O=>[O.originalPath,O])),s=new Map(n.choices.map(O=>[O.choice.id,O])),a=Nfe(n),l=new Set,c=new Map,u=new Set,d=O=>{let G=K=>(c.set(O,K),u.delete(O),K);if(c.has(O))return c.get(O);if(u.has(O))return!0;if(u.add(O),i.get(O)==="skip")return G(!1);let F=s.get(O);if(!F)return G(!1);let Z=F.parentChoiceId;if(!Z||!s.has(Z)||i.get(Z)==="skip")return G(!0);let Y=d(Z);return G(Y)};for(let O of n.choices)d(O.choice.id)&&l.add(O.choice.id);let f=new Set,p=new Set,m=new Set,v=new Map,g=O=>{let G=()=>(f.add(O),p.delete(O),!0),V=()=>(p.add(O),!1);if(!l.has(O))return!1;if(f.has(O))return!0;if(p.has(O))return!1;if(m.has(O))return V();m.add(O);try{if(i.get(O)==="duplicate")return G();let z=s.get(O)?.parentChoiceId??null;return z&&(i.get(z)==="duplicate"||l.has(z)&&g(z))?G():V()}finally{m.delete(O)}};for(let O of n.choices){if(!l.has(O.choice.id))continue;let V=g(O.choice.id)?Er():O.choice.id;v.set(O.choice.id,V)}let y=vt(t),w=[],k=[],C=[],E=new Map;for(let O of n.choices){if(!l.has(O.choice.id)){C.push(O.choice.id);continue}let G=vt(O.choice),V=BO(G,v,l,{secretOptionNamesByPath:a,stripUnknownStringSettings:!0});E.set(O.choice.id,V)}r.aiProviders?.length&&FS(Array.from(E.values()),r.aiProviders);let x=new Set;for(let O of n.choices){let G=O.choice.id;if(!l.has(G)||x.has(G))continue;let V=E.get(G);if(!V)continue;let F=V.id,Z=i.get(G)??"import",z=O.parentChoiceId;if(z&&l.has(z)?E.get(z):null){x.add(G);continue}if((Z==="overwrite"||Z==="import")&&Y4(y,V)){k.push(F),x.add(G);continue}if(z){let se=v.get(z)??z;if(K4(y,se,V)){w.push(F),x.add(G);continue}let ge=Bfe(y,O.pathHint.slice(0,-1));if(ge&&Q4(ge,V)){w.push(F),x.add(G);continue}M.logWarning(`QuickAdd import: could not locate parent for '${O.choice.name}'. Adding to root.`)}let K=y.findIndex(se=>Ye(se)&&se.id===F);K!==-1?(y.splice(K,1,V),k.push(F)):(y.push(V),w.push(F)),x.add(G)}let D=new Map,P=[],H=[],U=n.assets.map(O=>{let V=o.get(O.originalPath)?.destinationPath?.trim(),F=Ofe(V||O.originalPath);return{asset:O,destinationPath:F}}),oe=await Lfe(e),ce=new Map;for(let{asset:O,destinationPath:G}of U){if(o.get(O.originalPath)?.mode==="skip")continue;let V=oe?G.toLowerCase():G,F=ce.get(V);if(F)throw new Error(`Refusing to import: assets "${F.originalPath}" and "${O.originalPath}" resolve to the same destination ("${G}"). Rename one so each imported file is unique.`);ce.set(V,{originalPath:O.originalPath,destinationPath:G})}for(let{destinationPath:O}of U)await vg(e,O);for(let{asset:O,destinationPath:G}of U){let V=o.get(O.originalPath),F=await G4(e,G);if((V?.mode??(F?"overwrite":"write"))==="skip"){H.push(G);continue}await kS(e,G);let z=zc(O.content);await e.vault.adapter.write(G,z),P.push(G),D.set(O.originalPath,G)}for(let O of E.values())VO(O,D);return{updatedChoices:y,addedChoiceIds:w,overwrittenChoiceIds:k,skippedChoiceIds:C,writtenAssets:P,skippedAssets:H}}function Nfe(r){let e=new Map;for(let t of r.assets)if(t.kind==="user-script")try{let n=Vh(zc(t.content),t.originalPath);e.set(t.originalPath,n.foundSecretOptions&&n.names.size===0?null:n.names)}catch(n){M.logWarning(`QuickAdd import could not inspect user-script settings '${t.originalPath}': ${n?.message??n}`)}return e}async function G4(r,e){try{return await r.vault.adapter.exists(e)}catch{return!1}}async function Lfe(r){let e=r.vault.configDir;if(!e)return!1;let t=e===e.toLowerCase()?e.toUpperCase():e.toLowerCase();if(t===e)return!1;try{return await r.vault.adapter.exists(t)}catch{return!1}}function BO(r,e,t,n){let i=r.id,o=e.get(i)??i;r.id=o;let s=o!==i;if(r.type==="Macro"){let a=r;s&&nd(a.macro)&&(a.macro.id=Er()),OO(zn(a.macro),e,t,s,n)}if(r.type==="Multi"){let a=r;Array.isArray(a.choices)&&(a.choices=a.choices.filter(l=>Ye(l)&&t.has(l.id)).map(l=>BO(l,e,t,n)))}return r}function OO(r,e,t,n,i){for(let o of Ir(r))if(Di(o))switch(q$(o,i),n&&(o.id=Er()),o.type){case"Choice":{let s=o,a=e.get(s.choiceId);a&&(s.choiceId=a);break}case"Conditional":{let s=o;OO(s.thenCommands,e,t,n,i),OO(s.elseCommands,e,t,n,i);break}case"NestedChoice":{let s=o;s.choice&&t.has(s.choice.id)&&(s.choice=BO(s.choice,e,t,i));break}default:break}}function Y4(r,e){for(let t=0;t<r.length;t++){let n=r[t];if(Ye(n)){if(n.id===e.id)return r.splice(t,1,e),!0;if(Y4(st(n),e))return!0}}return!1}function K4(r,e,t){for(let n of r)if(Ye(n)){if(n.id===e&&n.type==="Multi")return Q4(n,t);if(K4(st(n),e,t))return!0}return!1}function Q4(r,e){if(!Array.isArray(r.choices)){if(js(r))return!1;r.choices=[]}let t=r.choices.findIndex(n=>Ye(n)&&n.id===e.id);return t!==-1?r.choices.splice(t,1,e):r.choices.push(e),!0}function Bfe(r,e){if(e.length===0)return null;let t=r,n=null;for(let i of e){let o=t.find(s=>Ye(s)&&s.type==="Multi"&&s.name===i);if(!o)return null;n=o,t=st(o)}return n}function VO(r,e){switch(r.type){case"Macro":{NO(zn(r.macro),e);break}case"Template":{let t=r,n=e.get(t.templatePath);n&&(t.templatePath=n);break}case"Capture":{let t=r,n=t.createFileIfItDoesntExist?.template;if(n){let i=e.get(n);i&&(t.createFileIfItDoesntExist={...t.createFileIfItDoesntExist,template:i})}break}case"Multi":{r.choices?.forEach(n=>VO(n,e));break}default:break}}function NO(r,e){for(let t of Ir(r))if(Di(t))switch(t.type){case"UserScript":{let n=t,i=e.get(n.path);i&&(n.name===n.path?n.name=i:n.name.startsWith(`${n.path}::`)&&(n.name=i+n.name.slice(n.path.length)),n.path=i);break}case"Conditional":{let n=t;if(n.condition.mode==="script"&&n.condition.scriptPath){let i=e.get(n.condition.scriptPath);i&&(n.condition={...n.condition,scriptPath:i})}NO(n.thenCommands,e),NO(n.elseCommands,e);break}case"NestedChoice":{let n=t;n.choice&&VO(n.choice,e);break}default:break}}var LS=require("obsidian");function Wx(r,e){return e&&(0,LS.setTooltip)(r,e),{update(t){(0,LS.setTooltip)(r,t??"")},destroy(){(0,LS.setTooltip)(r,"")}}}var Vfe=q("<span> </span>"),Ufe={hash:"svelte-5jkd35",code:`.qa-import-tag.svelte-5jkd35 {display:inline-flex;align-items:center;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;font-weight:600;letter-spacing:0.02em;text-transform:uppercase;line-height:1.45;white-space:nowrap;cursor:help;}
/* Critical: darkened red so white text clears WCAG AA (~5:1) at this size,
where Obsidian's stock --color-red (#e93147) lands at ~3.5:1. */.qa-import-tag.critical.svelte-5jkd35 {background:var(--qa-sev-critical-pill);color:#fff;}
/* Warning: amber is medium-luminance in both themes, so near-black text
(~8:1) beats white-on-amber (~2.9:1). Fallback #ff8c00 matches styles.css
and clears AA (~5.9:1) with #1a1a1a. */.qa-import-tag.warning.svelte-5jkd35 {background:var(--color-orange, #ff8c00);color:#1a1a1a;}.qa-import-tag.info.svelte-5jkd35 {background:var(--background-modifier-border);color:var(--text-normal);}`};function zx(r,e){we(e,!0),ot(r,Ufe);let t=N(()=>MS(e.flag)),n=N(()=>O4(e.flag)),i=N(()=>N4(e.flag));var o=Vfe();let s;var a=I(o,!0);S(o),Mr(o,(l,c)=>Wx?.(l,c),()=>h(i)),de(()=>{s=xt(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),me(a,h(n))}),$(r,o),Ce()}var qfe=q('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),Wfe=q('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),zfe=q('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),Hfe=q('<section aria-label="What this package can do"><div class="qa-import-banner-head svelte-tb9yz"><span class="qa-import-banner-icon svelte-tb9yz"><!></span> <h3 class="svelte-tb9yz">What this package can do</h3></div> <ul class="qa-import-banner-rows svelte-tb9yz"></ul> <!></section>'),jfe={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz {background:var(--background-secondary);border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.85rem;display:flex;flex-direction:column;gap:0.5rem;}
/* Critical packages get a red-tinted hairline + red icon, not a blanket-red
fill: severity stays ranked and all text keeps its contrast on the neutral
surface. (A solid colored side-stripe would be the banned pattern.) */.qa-import-banner.critical.svelte-tb9yz {border-color:var(--qa-sev-critical-border);}.qa-import-banner-head.svelte-tb9yz {display:flex;align-items:center;gap:0.5rem;}.qa-import-banner-icon.svelte-tb9yz {display:inline-flex;color:var(--text-warning, var(--text-muted));}.qa-import-banner.critical.svelte-tb9yz .qa-import-banner-icon:where(.svelte-tb9yz) {color:var(--text-error);}.qa-import-banner-head.svelte-tb9yz h3:where(.svelte-tb9yz) {margin:0;font-size:1rem;}.qa-import-banner-rows.svelte-tb9yz {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}
/* The pill is an inline lead-in to the sentence (not a fixed left column),
so long titles wrap full-width under it instead of leaving a dead column
of whitespace beside a one-line pill. */.qa-import-banner-rows.svelte-tb9yz li:where(.svelte-tb9yz) {display:block;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);}.qa-import-banner-tag.svelte-tb9yz {display:inline-block;vertical-align:middle;margin:0 0.4rem 0.15rem 0;}
/* Faint per-row severity wash so critical rows read hottest while warnings
recede, without saturating the whole banner. Composited over the banner
surface (not transparent) so the tint is a solid, predictable colour. */.qa-import-banner-rows.svelte-tb9yz li.sev-critical:where(.svelte-tb9yz) {background:var(--qa-sev-critical-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-warning:where(.svelte-tb9yz) {background:var(--qa-sev-warning-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-info:where(.svelte-tb9yz) {background:var(--qa-sev-info-wash);}.qa-import-banner-title.svelte-tb9yz {line-height:1.4;}.qa-import-banner-detail.svelte-tb9yz {display:block;margin-top:0.15rem;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-banner-note.svelte-tb9yz {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}`};function UO(r,e){we(e,!0),ot(r,jfe);let t=N(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=Hfe();let i;var o=I(n),s=I(o),a=I(s);$t(a,{iconId:"alert-triangle",size:17}),S(s),Pn(2),S(o);var l=_(o,2);ar(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,f)=>{var p=Wfe();let m;var v=I(p),g=I(v);zx(g,{get flag(){return h(f).flag}}),S(v);var y=_(v),w=I(y,!0);S(y);var k=_(y,2);{var C=E=>{var x=qfe(),D=I(x,!0);S(x),de(()=>me(D,h(f).detail)),$(E,x)};ie(k,E=>{h(f).detail&&E(C)})}S(p),de(()=>{m=xt(p,1,"svelte-tb9yz",null,m,{"sev-critical":h(f).severity==="critical","sev-warning":h(f).severity==="warning","sev-info":h(f).severity==="info"}),me(w,h(f).title)}),$(d,p)}),S(l);var c=_(l,2);{var u=d=>{var f=zfe();$(d,f)};ie(c,d=>{h(t)&&d(u)})}S(n),de(()=>i=xt(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),$(r,n),Ce()}var Gfe=q('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),Yfe=q('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),Kfe=q('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),Qfe=q("<option>Overwrite</option>"),Xfe=q(`<p class="qa-import-file-skip-warn svelte-lmqem5" role="note">Won't be written. Any choice that uses this script will run whatever
file already exists at this path after import, not the contents you
reviewed.</p>`),Zfe=q('<p class="qa-import-file-error svelte-lmqem5"> </p>'),Jfe=q(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
only if you trust the source.</p>`),eme=q('<p class="qa-import-file-warn svelte-lmqem5"> </p>'),tme=q('<!> <pre class="qa-import-file-code svelte-lmqem5" tabindex="0" role="region"> </pre> <!>',1),rme=q('<div class="qa-import-file-preview svelte-lmqem5"><!></div>'),nme=q('<div><div class="qa-import-file-head svelte-lmqem5"><!> <span> </span> <span class="qa-import-file-arrow svelte-lmqem5" aria-hidden="true">\u2192</span> <span class="qa-import-file-dest svelte-lmqem5"> </span></div> <div class="qa-import-file-badges svelte-lmqem5"><!> <!> <!> <span class="qa-import-file-size svelte-lmqem5"> </span></div> <div class="qa-import-file-fields svelte-lmqem5"><label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Destination</span> <input type="text" placeholder="vault/path/to/file" class="svelte-lmqem5"/></label> <label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Action</span> <select class="dropdown svelte-lmqem5"><option>Write</option><!><option>Skip</option></select></label></div> <!> <button type="button" class="qa-import-file-toggle svelte-lmqem5"><span><!></span> <span> </span></button> <div><div class="qa-import-file-preview-inner svelte-lmqem5"><!></div></div></div>'),ime={hash:"svelte-lmqem5",code:`.qa-import-file.svelte-lmqem5 {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;display:flex;flex-direction:column;gap:0.5rem;background:var(--background-secondary);}.qa-import-file.overwrite.svelte-lmqem5 {border-color:var(--qa-sev-critical-border);}.qa-import-file-head.svelte-lmqem5 {display:flex;align-items:center;gap:0.4rem;flex-wrap:wrap;}.qa-import-file-status.svelte-lmqem5 {font-size:0.78rem;font-weight:700;letter-spacing:0.01em;color:var(--text-muted);}.qa-import-file-status.overwrite.svelte-lmqem5 {color:var(--text-error);}.qa-import-file-arrow.svelte-lmqem5 {color:var(--text-muted);}.qa-import-file-dest.svelte-lmqem5 {font-family:var(--font-monospace);font-size:0.85rem;overflow-wrap:anywhere;}.qa-import-file-badges.svelte-lmqem5 {display:flex;flex-wrap:wrap;gap:0.35rem;align-items:center;}.qa-import-file-orphan.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;background:var(--background-modifier-hover);
/* --text-normal (not --text-muted) so the badge clears AA on the hover
surface in dark themes too. */color:var(--text-normal);cursor:help;}.qa-import-file-exec.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;font-weight:700;letter-spacing:0.02em;text-transform:uppercase;background:var(--qa-sev-critical-pill);color:#fff;cursor:help;}.qa-import-file-reviewed.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.15rem;font-size:0.72rem;color:var(--text-success, var(--color-green, #0aa344));}.qa-import-file-size.svelte-lmqem5 {font-size:0.72rem;color:var(--text-faint);margin-left:auto;}
/* Obsidian Setting-row geometry: field name on the left at --text-normal,
control docked right at its native height \u2014 not a stacked label-above
form field (which read as non-native). */.qa-import-file-fields.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;}.qa-import-file-field.svelte-lmqem5 {display:flex;align-items:center;gap:1rem;}.qa-import-file-field-name.svelte-lmqem5 {flex:1 1 auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5) {flex:0 1 300px;min-width:0;}.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:0 0 auto;}
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5):disabled {opacity:0.5;cursor:not-allowed;}.qa-import-file-toggle.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.3rem;align-self:flex-start;background:transparent;border:none;box-shadow:none;padding:0.1rem 0.2rem;margin-left:-0.2rem;cursor:pointer;color:var(--text-accent);font-size:0.85rem;border-radius:var(--radius-s, 4px);}.qa-import-file-toggle.svelte-lmqem5:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.qa-import-file-toggle.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5 {display:inline-flex;transition:transform 180ms ease;}.qa-import-file-chevron.open.svelte-lmqem5 {transform:rotate(90deg);}.qa-import-file-preview-wrap.svelte-lmqem5 {display:grid;grid-template-rows:0fr;transition:grid-template-rows 200ms ease;}.qa-import-file-preview-wrap.open.svelte-lmqem5 {grid-template-rows:1fr;}.qa-import-file-preview-inner.svelte-lmqem5 {overflow:hidden;min-height:0;}.qa-import-file-preview.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;padding-top:0.2rem;}.qa-import-file-warn.svelte-lmqem5 {margin:0;color:var(--text-warning, var(--text-muted));font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-skip-warn.svelte-lmqem5 {margin:0;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-warning-wash);color:var(--text-normal);font-size:var(--font-ui-smaller, 0.85rem);line-height:1.4;}.qa-import-file-error.svelte-lmqem5 {margin:0;color:var(--text-error);font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-code.svelte-lmqem5 {margin:0;max-height:240px;overflow:auto;padding:0.5rem 0.6rem;border-radius:var(--radius-s, 4px);background:var(--background-modifier-form-field);border:1px solid var(--background-modifier-border);font-family:var(--font-monospace);font-size:0.8rem;line-height:1.5;white-space:pre;tab-size:4;}.qa-import-file-code.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}
@media (max-width: 600px) {
/* Stack control under its name and let it use the full width on narrow
screens, where a right-docked control would be cramped. */.qa-import-file-field.svelte-lmqem5 {flex-wrap:wrap;gap:0.25rem;}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5),
.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:1 1 100%;}.qa-import-file-size.svelte-lmqem5 {margin-left:0;}
}.is-mobile .qa-import-file-toggle.svelte-lmqem5 {min-height:36px;padding:0.4rem 0.3rem;}
@media (prefers-reduced-motion: reduce) {.qa-import-file-chevron.svelte-lmqem5,
.qa-import-file-preview-wrap.svelte-lmqem5 {transition:none;}
}`};function BS(r,e){we(e,!0),ot(r,ime);let t=he(e,"reviewed",3,!1),n=_e(!1),i=N(()=>h(n)?$S(e.pkg,e.file.originalPath):null),o=N(()=>`qa-file-preview-${e.file.originalPath.replace(/[^a-zA-Z0-9_-]/g,"-")}`);function s(Te){return Te<1024?`${Te} B`:Te<1024*1024?`${(Te/1024).toFixed(1)} KB`:`${(Te/(1024*1024)).toFixed(1)} MB`}function a(){J(n,!h(n)),h(n)&&e.file.requiresReview&&e.onReviewed(e.file.originalPath)}function l(Te){e.onPathInput(Te.currentTarget.value)}function c(Te){e.onModeChange(Te.currentTarget.value)}var u=nme();let d;var f=I(u),p=I(f);{let Te=N(()=>e.destinationExists?"file-warning":"file-plus");$t(p,{get iconId(){return h(Te)},size:16})}var m=_(p,2);let v;var g=I(m,!0);S(m);var y=_(m,4),w=I(y,!0);S(y),S(f);var k=_(f,2),C=I(k);{var E=Te=>{var Ve=Gfe();Mr(Ve,(dt,or)=>Wx?.(dt,or),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),$(Te,Ve)};ie(C,Te=>{e.file.executable&&Te(E)})}var x=_(C,2);{var D=Te=>{var Ve=Yfe(),dt=I(Ve);$t(dt,{iconId:"check",size:12}),Pn(),S(Ve),$(Te,Ve)};ie(x,Te=>{t()&&e.mode!=="skip"&&e.file.requiresReview&&Te(D)})}var P=_(x,2);{var H=Te=>{var Ve=Kfe();Mr(Ve,(dt,or)=>Wx?.(dt,or),()=>"Bundled in this package but not referenced by any choice."),$(Te,Ve)};ie(P,Te=>{e.file.orphan&&Te(H)})}var U=_(P,2),oe=I(U,!0);S(U),S(k);var ce=_(k,2),O=I(ce),G=_(I(O),2);gr(G),S(O);var V=_(O,2),F=_(I(V),2),Z=I(F);Z.value=Z.__value="write";var z=_(Z);{var Y=Te=>{var Ve=Qfe();Ve.value=Ve.__value="overwrite",$(Te,Ve)};ie(z,Te=>{e.destinationExists&&Te(Y)})}var K=_(z);K.value=K.__value="skip",S(F);var se;Hd(F),S(V),S(ce);var pe=_(ce,2);{var ge=Te=>{var Ve=Xfe();$(Te,Ve)};ie(pe,Te=>{e.file.requiresReview&&e.mode==="skip"&&Te(ge)})}var be=_(pe,2),Be=I(be);let Se;var ut=I(Be);$t(ut,{iconId:"chevron-right",size:14}),S(Be);var Ne=_(Be,2),Qe=I(Ne,!0);S(Ne),S(be);var Ze=_(be,2);let ye;var We=I(Ze),gt=I(We);{var He=Te=>{var Ve=rme(),dt=I(Ve);{var or=Ft=>{var kr=Zfe(),ur=I(kr);S(kr),de(()=>me(ur,`Preview unavailable: ${h(i).error??""}`)),$(Ft,kr)},yr=Ft=>{var kr=tme(),ur=Pe(kr);{var pt=Gn=>{var ne=Jfe();$(Gn,ne)};ie(ur,Gn=>{h(i).looksMinified&&Gn(pt)})}var Mt=_(ur,2),jn=I(Mt,!0);S(Mt);var Eo=_(Mt,2);{var Ts=Gn=>{var ne=eme(),Ie=I(ne);S(ne),de(()=>me(Ie,`Preview truncated. The full ${e.file.executable?"script will run":"file will be imported"}.`)),$(Gn,ne)};ie(Eo,Gn=>{h(i).truncated&&Gn(Ts)})}de(()=>{Ae(Mt,"aria-label",`Contents of ${e.file.originalPath??""}`),me(jn,h(i).text)}),$(Ft,kr)};ie(dt,Ft=>{h(i).error?Ft(or):Ft(yr,-1)})}S(Ve),$(Te,Ve)};ie(gt,Te=>{h(i)&&Te(He)})}S(We),S(Ze),S(u),de(Te=>{d=xt(u,1,"qa-import-file svelte-lmqem5",null,d,{overwrite:e.destinationExists}),v=xt(m,1,"qa-import-file-status svelte-lmqem5",null,v,{overwrite:e.destinationExists}),me(g,e.destinationExists?"Will overwrite":"New file"),me(w,e.destinationPath),me(oe,Te),Rs(G,e.destinationPath),G.disabled=e.mode==="skip",se!==(se=e.mode)&&(F.value=(F.__value=e.mode)??"",gu(F,e.mode)),Ae(be,"aria-expanded",h(n)),Ae(be,"aria-controls",h(o)),Se=xt(Be,1,"qa-import-file-chevron svelte-lmqem5",null,Se,{open:h(n)}),me(Qe,h(n)?"Hide contents":"View contents"),ye=xt(Ze,1,"qa-import-file-preview-wrap svelte-lmqem5",null,ye,{open:h(n)}),Ae(Ze,"id",h(o))},[()=>s(e.file.sizeBytes)]),De("input",G,l),De("change",F,c),De("click",be,a),$(r,u),Ce()}Tt(["input","change","click"]);var ome=q('<span class="macroCommandType svelte-1qj0pve"> </span>'),sme=q("<code> </code>"),ame=q('<span class="macroCommandSummary svelte-1qj0pve"> </span>'),lme=q('<li class="svelte-1qj0pve"><span class="macroCommandName svelte-1qj0pve"> </span> <!> <!></li>'),cme=q('<ul class="macroCommands svelte-1qj0pve"></ul>'),ume={hash:"svelte-1qj0pve",code:".macroCommands.svelte-1qj0pve {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.macroCommands.svelte-1qj0pve li:where(.svelte-1qj0pve) {display:flex;flex-wrap:wrap;align-items:center;gap:0.4rem;font-size:var(--font-ui-smaller, 0.85rem);}.macroCommandName.svelte-1qj0pve {font-weight:500;}.macroCommandType.svelte-1qj0pve {color:var(--text-muted);font-size:0.72rem;}.macroCommandSummary.svelte-1qj0pve {color:var(--text-muted);}"};function qO(r,e){ot(r,ume);let t={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 t[o]??o}var i=cme();ar(i,21,()=>e.commands,Uv,(o,s)=>{var a=lme(),l=I(a),c=I(l,!0);S(l);var u=_(l,2);{var d=g=>{zx(g,{get flag(){return h(s).flag}})},f=g=>{var y=ome(),w=I(y,!0);S(y),de(k=>me(w,k),[()=>n(h(s).type)]),$(g,y)};ie(u,g=>{h(s).flag?g(d):g(f,-1)})}var p=_(u,2);{var m=g=>{var y=sme(),w=I(y,!0);S(y),de(()=>me(w,h(s).scriptPath)),$(g,y)},v=g=>{var y=ame(),w=I(y,!0);S(y),de(()=>me(w,h(s).summary)),$(g,y)};ie(p,g=>{h(s).scriptPath?g(m):h(s).summary&&g(v,1)})}S(a),de(()=>{Xf(a,`padding-left:${h(s).depth*1}rem`),me(c,h(s).name)}),$(o,a)}),S(i),$(r,i)}var WO=require("obsidian");_c();function X4(r,e){return r==="skip"?r:e&&r==="write"?"overwrite":!e&&r==="overwrite"?"write":r}function zO(r,e){return!e&&r==="overwrite"?"import":r}function Z4(r,e,t){let n=e(r),i=r.exists||t(n);return{mode:i?"overwrite":"write",destinationPath:n,destinationExists:i}}function J4(r,e){let t=e(r);return{mode:t?"overwrite":"write",destinationPath:r,destinationExists:t}}function e5(r,e,t){let n=new Map;for(let i of r)n.set(i.originalPath,Z4(i,e,t));return n}function t5(r,e,t,n){return r.get(e.originalPath)??Z4(e,t,n)}function r5(r){let e=new Map;for(let t of r)e.set(t.choiceId,t.exists?"overwrite":"import");return e}function n5(r,e,t){let n=new Map(r);return n.set(e,t),n}function i5(r,e,t,n){let i=r.get(e)??J4(e,n),o=new Map(r);return o.set(e,{...i,mode:t}),o}function o5(r,e,t,n){let i=r.get(e)??J4(e,n),o=t.trim(),s=o||e,a=o||t,l=n(s),c=new Map(r);return c.set(e,{...i,mode:X4(i.mode,l),destinationPath:a,destinationExists:l}),{decisions:c,effectivePath:s}}function s5(r,e,t){let n=r.get(e);if(!n||n.destinationExists===t)return r;let i=new Map(r);return i.set(e,{...n,destinationExists:t,mode:X4(n.mode,t)}),i}function a5(r,e){return r.map(t=>({choiceId:t.choiceId,mode:zO(e.get(t.choiceId)??"import",t.exists)}))}function l5(r,e,t){return r.map(n=>{let i=e.get(n.originalPath),o=i?.destinationPath?.trim()||n.originalPath,s=i?.destinationExists??(n.exists||t(o)),a=i?.mode??(s?"overwrite":"write");return{originalPath:n.originalPath,destinationPath:o,mode:a}})}var VS=class{constructor(e){this.app=e;this.tokens=new Map}optimistic(e){let t=e.trim();return!t||Un(t)?!1:!!this.app.vault.getAbstractFileByPath((0,WO.normalizePath)(t))}async resolve(e){let t=e.trim();if(!t||Un(t))return!1;try{return await this.app.vault.adapter.exists((0,WO.normalizePath)(t))}catch{return!1}}schedule(e,t,n){let i=(this.tokens.get(e)??0)+1;this.tokens.set(e,i),this.resolve(t).then(o=>{this.tokens.get(e)===i&&n(o)})}};var dme=q('<div class="errorMessage svelte-1nd6fqb"> </div>'),pme=q('<div class="info svelte-1nd6fqb">Analyzing package\u2026</div>'),fme=q('<p class="svelte-1nd6fqb">No choices found in this package.</p>'),mme=q('<div class="choiceExists svelte-1nd6fqb">already in vault</div>'),hme=q('<button type="button" class="macroToggle svelte-1nd6fqb"> </button>'),gme=q('<option class="svelte-1nd6fqb">Overwrite</option>'),vme=q('<tr class="macroRow svelte-1nd6fqb"><td colspan="3" class="svelte-1nd6fqb"><!></td></tr>'),yme=q('<tr class="svelte-1nd6fqb"><td data-label="Name" class="svelte-1nd6fqb"><div class="choiceName svelte-1nd6fqb"> </div> <!> <!></td><td data-label="Location" class="svelte-1nd6fqb"> </td><td data-label="Action" class="svelte-1nd6fqb"><select class="dropdown svelte-1nd6fqb"><option class="svelte-1nd6fqb">Import</option><!><option class="svelte-1nd6fqb">Duplicate</option><option class="svelte-1nd6fqb">Skip</option></select></td></tr> <!>',1),bme=q('<table class="svelte-1nd6fqb"><colgroup class="svelte-1nd6fqb"><col class="colName svelte-1nd6fqb"/><col class="colLocation svelte-1nd6fqb"/><col class="colAction svelte-1nd6fqb"/></colgroup><thead class="svelte-1nd6fqb"><tr class="svelte-1nd6fqb"><th class="svelte-1nd6fqb">Name</th><th class="svelte-1nd6fqb">Location</th><th class="svelte-1nd6fqb">Action</th></tr></thead><tbody class="svelte-1nd6fqb"></tbody></table>'),wme=q('<p class="svelte-1nd6fqb">No files bundled with this package.</p>'),Cme=q('<h4 class="filesGroupHeading svelte-1nd6fqb"> </h4> <div class="fileRows svelte-1nd6fqb"></div>',1),xme=q('<h4 class="filesGroupHeading overwrite svelte-1nd6fqb"> </h4> <div class="fileRows svelte-1nd6fqb"></div>',1),Eme=q("<!> <!>",1),Tme=q('<li><code class="svelte-1nd6fqb"> </code> <span class="warnLoc svelte-1nd6fqb"> </span></li>'),_me=q('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Missing files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),Ame=q(`<li class="svelte-1nd6fqb"><code class="svelte-1nd6fqb"> </code>: bundled but not
used by any choice</li>`),kme=q('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Unreferenced files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),Sme=q('<section class="warningsBand svelte-1nd6fqb"><!> <!></section>'),Dme=q('<section class="filesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Files</h3> <!></section> <!>',1),Ime=q('<section class="summary svelte-1nd6fqb"><!> <span class="svelte-1nd6fqb"> </span></section>'),Pme=q('<section class="packageMeta svelte-1nd6fqb"><span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Version</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Created</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span></section> <!> <section class="choicesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Choices</h3> <!></section> <!> <!>',1),Fme=q('<p id="qa-import-ack-hint" class="ackGate-hint svelte-1nd6fqb"> </p>'),Mme=q('<section><label class="ackGate-label svelte-1nd6fqb"><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-1nd6fqb"/> <span class="svelte-1nd6fqb"> </span></label> <!></section>'),Rme=q('<div class="importPackageModal svelte-1nd6fqb"><header class="svelte-1nd6fqb"><h2 class="svelte-1nd6fqb">Import QuickAdd package</h2> <p class="svelte-1nd6fqb">Review what this package adds and runs before importing.</p></header> <section class="pasteSection svelte-1nd6fqb"><label class="svelte-1nd6fqb"><span class="svelte-1nd6fqb">Paste package JSON</span> <textarea placeholder="Paste the contents of a .quickadd.json package here" rows="8" class="svelte-1nd6fqb"></textarea></label> <!></section> <!> <!> <section class="footer svelte-1nd6fqb"><button type="button" class="secondary svelte-1nd6fqb">Cancel</button> <button type="button" class="primary svelte-1nd6fqb"><!></button></section></div>'),$me={hash:"svelte-1nd6fqb",code:`.importPackageModal.svelte-1nd6fqb {display:flex;flex-direction:column;gap:1rem;width:min(720px, 100%);max-height:80vh;overflow-y:auto;
/* overflow-x:hidden (paired with overflow-y:auto) clips child focus rings
at the flush left/right edges; the inline padding gives the ring room. */overflow-x:hidden;box-sizing:border-box;padding:2px 4px;}.importPackageModal.svelte-1nd6fqb :where(.svelte-1nd6fqb) {box-sizing:border-box;}.importPackageModal.svelte-1nd6fqb > section:where(.svelte-1nd6fqb) {max-width:100%;}.pasteSection.svelte-1nd6fqb label:where(.svelte-1nd6fqb) {display:flex;flex-direction:column;gap:0.5rem;}.pasteSection.svelte-1nd6fqb textarea:where(.svelte-1nd6fqb) {width:100%;font-family:var(--font-monospace);resize:vertical;}.errorMessage.svelte-1nd6fqb {color:var(--text-error);}.info.svelte-1nd6fqb {color:var(--text-muted);}
/* A single compact line that sizes to content and wraps naturally, instead
of a 4-equal-column grid where the date wraps to 3 lines and the rest
leave dead space. */.packageMeta.svelte-1nd6fqb {display:flex;flex-wrap:wrap;align-items:baseline;gap:0.3rem 0.6rem;padding:0.55rem 0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);width:100%;font-size:var(--font-ui-small, 0.9rem);overflow-wrap:anywhere;}.metaLabel.svelte-1nd6fqb {color:var(--text-muted);}.metaSep.svelte-1nd6fqb {color:var(--text-faint);}.choicesSection.svelte-1nd6fqb,
.filesSection.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.75rem;}.filesGroupHeading.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-small, 0.9rem);font-weight:600;color:var(--text-muted);}.filesGroupHeading.overwrite.svelte-1nd6fqb {color:var(--text-error);}.fileRows.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.5rem;}.choiceName.svelte-1nd6fqb {font-weight:500;}
/* A plain inline text link, not a chrome button: neutralise Obsidian's
default button background/shadow on every state (!important to win over
the global button:hover / :focus rules that paint the grey box). */.macroToggle.svelte-1nd6fqb {display:inline-block;margin-top:0.35rem;padding:0;background:transparent !important;border:none;box-shadow:none !important;color:var(--text-accent);cursor:pointer;font-size:var(--font-ui-smaller, 0.8rem);border-radius:var(--radius-s, 4px);}.macroToggle.svelte-1nd6fqb:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-1nd6fqb:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {background:var(--background-primary-alt, var(--background-secondary));}.warningsBand.svelte-1nd6fqb {display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;gap:0.5rem;}.warnItem.svelte-1nd6fqb h4:where(.svelte-1nd6fqb) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-1nd6fqb ul:where(.svelte-1nd6fqb) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-1nd6fqb li:where(.svelte-1nd6fqb) {overflow-wrap:anywhere;}
/* A missing SCRIPT reference is an execution-hijack risk, not a broken
link: it runs from whatever exists at that path. Mark it as critical. */.warnItem.svelte-1nd6fqb li.script:where(.svelte-1nd6fqb) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-1nd6fqb {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-1nd6fqb col.colName:where(.svelte-1nd6fqb) {width:52%;}.choicesSection.svelte-1nd6fqb col.colLocation:where(.svelte-1nd6fqb) {width:26%;}.choicesSection.svelte-1nd6fqb col.colAction:where(.svelte-1nd6fqb) {width:22%;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.5rem;border-bottom:1px solid var(--background-modifier-border);text-align:left;word-break:break-word;overflow-wrap:anywhere;white-space:normal;vertical-align:top;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb) {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);font-weight:600;}.choiceExists.svelte-1nd6fqb {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);margin-top:0.1rem;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow):hover td:where(.svelte-1nd6fqb) {background:var(--background-modifier-hover);}.choicesSection.svelte-1nd6fqb select:where(.svelte-1nd6fqb) {max-width:100%;}
/* Narrow viewports (mobile): a 3-column table can't breathe, so each row
becomes a stacked card with the column name as an inline label. */
@media (max-width: 500px) {.choicesSection.svelte-1nd6fqb thead:where(.svelte-1nd6fqb) {display:none;}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb tr:where(.svelte-1nd6fqb),
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {display:block;width:100%;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow) {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.5rem 0.6rem;margin-bottom:0.5rem;}.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {border-bottom:none;padding:0.15rem 0;}.choicesSection.svelte-1nd6fqb td[data-label="Location"]:where(.svelte-1nd6fqb)::before,
.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb)::before {content:attr(data-label) ": ";font-weight:600;color:var(--text-muted);}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) {display:flex;align-items:center;gap:0.4rem;margin-top:0.25rem;}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) select:where(.svelte-1nd6fqb) {flex:1;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.25rem 0;}
}.summary.svelte-1nd6fqb {display:flex;align-items:center;gap:0.5rem;padding:0.55rem 0.7rem;border-radius:var(--radius-m, 8px);border:1px solid var(--qa-sev-success-border);background:var(--qa-sev-success-wash);color:var(--text-normal);}.summary.svelte-1nd6fqb .quickadd-icon {color:var(--text-success, var(--color-green, #0aa344));flex-shrink:0;}.ackGate.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.4rem;padding:0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);background:var(--background-secondary);}.ackGate.critical.svelte-1nd6fqb {border-color:var(--qa-sev-critical-border);}.ackGate-label.svelte-1nd6fqb {display:flex;align-items:flex-start;gap:0.5rem;font-weight:600;cursor:pointer;}.ackGate-label.svelte-1nd6fqb:has(input:where(.svelte-1nd6fqb):disabled) {cursor:not-allowed;opacity:0.6;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb) {margin-top:0.2rem;flex-shrink:0;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.ackGate-hint.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}.footer.svelte-1nd6fqb {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb) {background:var(--interactive-accent);color:var(--text-on-accent);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--interactive-accent-hover);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:translateY(1px);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {background:transparent;}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--background-modifier-hover);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}
/* Accent background needs a light outline to stay visible. */.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--text-on-accent);outline-offset:-4px;}.is-mobile .macroToggle.svelte-1nd6fqb {min-height:36px;padding:0.4rem 0.3rem;}
@media (prefers-reduced-motion: reduce) {.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {transition:none;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:none;}
}`};function HO(r,e){we(e,!0),ot(r,$me);let t;function n(){return t??(t=new VS(e.app))}let i=_e(null),o=_e(null),s=_e(null),a=_e(!1),l=_e(Ct(new Set)),c=_e(Ct(new Set)),u=_e(null),d=_e(!1),f=_e(null),p=_e(Ct(new Map)),m=_e(Ct(new Map)),v=_e(""),g=_e(!1),y=_e(0),w=_e(!1),k=N(()=>h(s)?q4(h(s)):!1),C=N(()=>h(s)?W4(h(s),h(l)):!0),E=N(()=>new Map((h(s)?.choices??[]).map(ne=>[ne.choiceId,ne]))),x=N(()=>new Map((h(s)?.files??[]).map(ne=>[ne.originalPath,ne]))),D=N(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),P=N(()=>!!(h(i)&&h(o))&&!h(g)&&(!h(k)||h(a)&&h(C))),H=N(()=>h(s)?.criticalScriptPaths.length??0),U=N(()=>h(s)?.missingReferences.some(ne=>ne.asScript)??!1),oe=N(()=>{let ne=h(f);if(!ne)return"";let Ie=[];ne.added&&Ie.push(`${ne.added} choice${ne.added===1?"":"s"} added`),ne.overwritten&&Ie.push(`${ne.overwritten} overwritten`),ne.assetsWritten&&Ie.push(`${ne.assetsWritten} file${ne.assetsWritten===1?"":"s"} written`);let dr=ne.skipped+ne.assetsSkipped;return dr&&Ie.push(`${dr} skipped`),Ie.length?`Imported: ${Ie.join(", ")}.`:"Nothing was imported."}),ce=N(()=>h(H)>0?h(U)?"I have reviewed each bundled script above and trust the source, including scripts that are not included and cannot be shown.":"I have reviewed each script above and trust the source.":h(U)?"This package runs scripts that are not included and cannot be reviewed. I trust the source.":"I understand this package can run code, and I trust the source.");function O(ne){if(h(l).has(ne))return;let Ie=new Set(h(l));Ie.add(ne),J(l,Ie,!0)}function G(ne){let Ie=new Set(h(c));Ie.has(ne)?Ie.delete(ne):Ie.add(ne),J(c,Ie,!0)}let V=ne=>n().optimistic(ne),F=N(()=>(h(o)?.assetConflicts??[]).map(ne=>({conflict:ne,state:t5(h(m),ne,Y,V),file:h(x).get(ne.originalPath)}))),Z=N(()=>h(F).filter(ne=>!ne.state.destinationExists)),z=N(()=>h(F).filter(ne=>ne.state.destinationExists));function Y(ne){let[Ie]=zi(le.getState().templateFolderPaths),dr=ne.kind==="template"||ne.kind==="capture-template";if(Ie&&dr){let br=ne.originalPath.split("/").pop()??ne.originalPath;return`${Ie}/${br}`}return ne.originalPath}function K(ne,Ie){n().schedule(ne,Ie,dr=>{J(m,s5(h(m),ne,dr),!0)})}function se(){if(!h(o)){J(p,new Map,!0),J(m,new Map,!0);return}J(p,r5(h(o).choiceConflicts),!0),J(m,e5(h(o).assetConflicts,Y,V),!0);for(let ne of h(o).assetConflicts){let Ie=h(m).get(ne.originalPath);Ie&&K(ne.originalPath,Ie.destinationPath)}}function pe(ne,Ie){J(p,n5(h(p),ne,Ie),!0)}function ge(ne,Ie){J(m,i5(h(m),ne,Ie,V),!0)}function be(ne,Ie){let{decisions:dr,effectivePath:br}=o5(h(m),ne.originalPath,Ie,V);J(m,dr,!0),K(ne.originalPath,br)}function Be(ne,Ie){let br=Ie.currentTarget.value;pe(ne,br)}function Se(){J(s,null),J(a,!1),J(l,new Set,!0),J(c,new Set,!0)}async function ut(ne){let Ie=ne.trim(),dr=XI(y);if(J(f,null),J(w,!1),!Ie){J(i,null),J(o,null),J(p,new Map,!0),J(m,new Map,!0),Se(),J(u,null);return}J(g,!0);try{let br=LO(Ie),_n=le.getState().choices,jo=await H4(e.app,_n,br),Ja=await NS(e.app,_n,br);if(dr!==h(y))return;J(i,{pkg:br,path:"[pasted]"},!0),J(o,jo,!0),Se(),J(s,Ja,!0),J(u,null),se()}catch(br){if(dr!==h(y))return;J(u,br?.message??String(br),!0),J(i,null),J(o,null),J(p,new Map,!0),J(m,new Map,!0),Se()}finally{dr===h(y)&&J(g,!1)}}function Ne(ne){let Ie=ne.currentTarget.value;J(v,Ie,!0),ut(Ie)}function Qe(ne){return!ne||ne.length===0?"Root":ne.slice(0,-1).join(" \u203A ")||"Root"}async function Ze(){if(h(w)){new Hx.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){new Hx.Notice("Load a package before importing.");return}J(d,!0),J(f,null);try{let ne=await j4({app:e.app,existingChoices:le.getState().choices,aiProviders:le.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:a5(h(o).choiceConflicts,h(p)),assetDecisions:l5(h(o).assetConflicts,h(m),V)});le.setState(Ie=>({...Ie,choices:ne.updatedChoices})),J(f,{added:ne.addedChoiceIds.length,overwritten:ne.overwrittenChoiceIds.length,skipped:ne.skippedChoiceIds.length,assetsWritten:ne.writtenAssets.length,assetsSkipped:ne.skippedAssets.length},!0),J(w,!0),new Hx.Notice(`Imported ${ne.addedChoiceIds.length+ne.overwrittenChoiceIds.length} choice${ne.addedChoiceIds.length+ne.overwrittenChoiceIds.length===1?"":"s"} successfully.`)}catch(ne){console.error(ne),new Hx.Notice(`Import failed: ${ne?.message??ne}`)}finally{J(d,!1)}}var ye=Rme(),We=_(I(ye),2),gt=I(We),He=_(I(gt),2);Id(He),S(gt);var Te=_(gt,2);{var Ve=ne=>{var Ie=dme(),dr=I(Ie,!0);S(Ie),de(()=>me(dr,h(u))),$(ne,Ie)},dt=ne=>{var Ie=pme();$(ne,Ie)};ie(Te,ne=>{h(u)?ne(Ve):h(g)&&ne(dt,1)})}S(We);var or=_(We,2);{var yr=ne=>{var Ie=Pme(),dr=Pe(Ie),br=I(dr),_n=_(I(br));S(br);var jo=_(br,4),Ja=_(I(jo));S(jo);var el=_(jo,4),ru=I(el);S(el);var T=_(el,4),A=I(T);S(T),S(dr);var L=_(dr,2);{var Q=wt=>{UO(wt,{get preview(){return h(s)}})};ie(L,wt=>{h(D)&&h(s)&&wt(Q)})}var ee=_(L,2),ue=_(I(ee),2);{var ve=wt=>{var pr=fme();$(wt,pr)},Ue=wt=>{var pr=bme(),Sr=_(I(pr),2);ar(Sr,21,()=>h(o).choiceConflicts,Yn=>Yn.choiceId,(Yn,St)=>{let To=N(()=>zO(h(p).get(h(St).choiceId)??"import",h(St).exists)),pa=N(()=>h(E).get(h(St).choiceId)),_s=N(()=>(h(pa)?.commands?.length??0)>0);var cn=yme(),An=Pe(cn),Kl=I(An),Ed=I(Kl),cv=I(Ed,!0);S(Ed);var _f=_(Ed,2);{var fi=Sn=>{var oo=mme();$(Sn,oo)};ie(_f,Sn=>{h(St).exists&&Sn(fi)})}var to=_(_f,2);{var ro=Sn=>{var oo=hme(),UE=I(oo,!0);S(oo),de((bI,wI)=>{Ae(oo,"aria-expanded",bI),me(UE,wI)},[()=>h(c).has(h(St).choiceId),()=>h(c).has(h(St).choiceId)?"Hide macro":"Show macro"]),De("click",oo,()=>G(h(St).choiceId)),$(Sn,oo)};ie(to,Sn=>{h(_s)&&Sn(ro)})}S(Kl);var no=_(Kl),_o=I(no,!0);S(no);var kn=_(no),Gt=I(kn),io=I(Gt);io.value=io.__value="import";var nu=_(io);{var iu=Sn=>{var oo=gme();oo.value=oo.__value="overwrite",$(Sn,oo)};ie(nu,Sn=>{h(St).exists&&Sn(iu)})}var Ao=_(nu);Ao.value=Ao.__value="duplicate";var ou=_(Ao);ou.value=ou.__value="skip",S(Gt);var tl;Hd(Gt),S(kn),S(An);var pQ=_(An,2);{var fQ=Sn=>{var oo=vme(),UE=I(oo),bI=I(UE);{let wI=N(()=>h(pa)?.commands??[]);qO(bI,{get commands(){return h(wI)}})}S(UE),S(oo),$(Sn,oo)},mQ=N(()=>h(_s)&&h(c).has(h(St).choiceId));ie(pQ,Sn=>{h(mQ)&&Sn(fQ)})}de(Sn=>{me(cv,h(St).name),me(_o,Sn),tl!==(tl=h(To))&&(Gt.value=(Gt.__value=h(To))??"",gu(Gt,h(To)))},[()=>Qe(h(St).pathHint)]),De("change",Gt,Sn=>Be(h(St).choiceId,Sn)),$(Yn,cn)}),S(Sr),S(pr),$(wt,pr)};ie(ue,wt=>{h(o).choiceConflicts.length===0?wt(ve):wt(Ue,-1)})}S(ee);var bt=_(ee,2);{var Fr=wt=>{var pr=Dme(),Sr=Pe(pr),Yn=_(I(Sr),2);{var St=cn=>{var An=wme();$(cn,An)},To=cn=>{var An=Eme(),Kl=Pe(An);{var Ed=fi=>{var to=Cme(),ro=Pe(to),no=I(ro);S(ro);var _o=_(ro,2);ar(_o,21,()=>h(Z),kn=>kn.conflict.originalPath,(kn,Gt)=>{var io=dn(),nu=Pe(io);{var iu=Ao=>{{let ou=N(()=>h(l).has(h(Gt).file.originalPath));BS(Ao,{get file(){return h(Gt).file},get pkg(){return h(i).pkg},get mode(){return h(Gt).state.mode},get destinationPath(){return h(Gt).state.destinationPath},get destinationExists(){return h(Gt).state.destinationExists},onPathInput:tl=>be(h(Gt).conflict,tl),onModeChange:tl=>ge(h(Gt).conflict.originalPath,tl),get reviewed(){return h(ou)},onReviewed:O})}};ie(nu,Ao=>{h(Gt).file&&Ao(iu)})}$(kn,io)}),S(_o),de(()=>me(no,`Added (${h(Z).length??""})`)),$(fi,to)};ie(Kl,fi=>{h(Z).length>0&&fi(Ed)})}var cv=_(Kl,2);{var _f=fi=>{var to=xme(),ro=Pe(to),no=I(ro);S(ro);var _o=_(ro,2);ar(_o,21,()=>h(z),kn=>kn.conflict.originalPath,(kn,Gt)=>{var io=dn(),nu=Pe(io);{var iu=Ao=>{{let ou=N(()=>h(l).has(h(Gt).file.originalPath));BS(Ao,{get file(){return h(Gt).file},get pkg(){return h(i).pkg},get mode(){return h(Gt).state.mode},get destinationPath(){return h(Gt).state.destinationPath},get destinationExists(){return h(Gt).state.destinationExists},onPathInput:tl=>be(h(Gt).conflict,tl),onModeChange:tl=>ge(h(Gt).conflict.originalPath,tl),get reviewed(){return h(ou)},onReviewed:O})}};ie(nu,Ao=>{h(Gt).file&&Ao(iu)})}$(kn,io)}),S(_o),de(()=>me(no,`Will overwrite (${h(z).length??""})`)),$(fi,to)};ie(cv,fi=>{h(z).length>0&&fi(_f)})}$(cn,An)};ie(Yn,cn=>{h(F).length===0?cn(St):cn(To,-1)})}S(Sr);var pa=_(Sr,2);{var _s=cn=>{var An=Sme(),Kl=I(An);{var Ed=fi=>{var to=_me(),ro=_(I(to),2);ar(ro,21,()=>h(s).missingReferences,no=>no.path,(no,_o)=>{var kn=Tme();let Gt;var io=I(kn),nu=I(io,!0);S(io);var iu=_(io),Ao=_(iu),ou=I(Ao,!0);S(Ao),S(kn),de(()=>{Gt=xt(kn,1,"svelte-1nd6fqb",null,Gt,{script:h(_o).asScript}),me(nu,h(_o).path),me(iu,`:
${h(_o).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),me(ou,h(_o).breadcrumb)}),$(no,kn)}),S(ro),S(to),$(fi,to)};ie(Kl,fi=>{h(s).missingReferences.length>0&&fi(Ed)})}var cv=_(Kl,2);{var _f=fi=>{var to=kme(),ro=_(I(to),2);ar(ro,20,()=>h(s).orphanAssets,no=>no,(no,_o)=>{var kn=Ame(),Gt=I(kn),io=I(Gt,!0);S(Gt),Pn(),S(kn),de(()=>me(io,_o)),$(no,kn)}),S(ro),S(to),$(fi,to)};ie(cv,fi=>{h(s).orphanAssets.length>0&&fi(_f)})}S(An),$(cn,An)};ie(pa,cn=>{h(s)&&(h(s).missingReferences.length>0||h(s).orphanAssets.length>0)&&cn(_s)})}$(wt,pr)};ie(bt,wt=>{h(i)&&wt(Fr)})}var jt=_(bt,2);{var Oi=wt=>{var pr=Ime(),Sr=I(pr);$t(Sr,{iconId:"check-circle",size:16});var Yn=_(Sr,2),St=I(Yn,!0);S(Yn),S(pr),de(()=>me(St,h(oe))),$(wt,pr)};ie(jt,wt=>{h(f)&&wt(Oi)})}de(wt=>{me(_n,` ${h(i).pkg.quickAddVersion??""}`),me(Ja,` ${wt??""}`),me(ru,`${h(o).choiceConflicts.length??""} choice${h(o).choiceConflicts.length===1?"":"s"}`),me(A,`${h(i).pkg.assets.length??""} file${h(i).pkg.assets.length===1?"":"s"}`)},[()=>new Date(h(i).pkg.createdAt).toLocaleDateString()]),$(ne,Ie)};ie(or,ne=>{h(i)&&h(o)&&ne(yr)})}var Ft=_(or,2);{var kr=ne=>{var Ie=Mme();let dr;var br=I(Ie),_n=I(br);gr(_n);var jo=_(_n,2),Ja=I(jo,!0);S(jo),S(br);var el=_(br,2);{var ru=T=>{var A=Fme(),L=I(A);S(A),de(()=>me(L,`Open \u201CView contents\u201D on each of the ${h(H)??""} executable
script${h(H)===1?"":"s"} above to enable this.`)),$(T,A)};ie(el,T=>{h(H)>0&&!h(C)&&T(ru)})}S(Ie),de(()=>{dr=xt(Ie,1,"ackGate svelte-1nd6fqb",null,dr,{critical:h(s)?.summary.hasCritical}),jd(_n,h(a)),_n.disabled=!h(C),Ae(_n,"aria-describedby",h(H)>0&&!h(C)?"qa-import-ack-hint":void 0),me(Ja,h(ce))}),De("change",_n,T=>J(a,T.currentTarget.checked,!0)),$(ne,Ie)};ie(Ft,ne=>{h(i)&&h(k)&&!h(w)&&ne(kr)})}var ur=_(Ft,2),pt=I(ur),Mt=_(pt,2),jn=I(Mt);{var Eo=ne=>{var Ie=fl("Importing\u2026");$(ne,Ie)},Ts=ne=>{var Ie=fl("Close");$(ne,Ie)},Gn=ne=>{var Ie=fl("Import package");$(ne,Ie)};ie(jn,ne=>{h(d)?ne(Eo):h(w)?ne(Ts,1):ne(Gn,-1)})}S(Mt),S(ur),S(ye),de(()=>{pt.disabled=h(d),Mt.disabled=h(d)||!h(w)&&!h(P),Ae(Mt,"title",!h(w)&&h(k)&&h(C)&&!h(a)?"Confirm the acknowledgement above to continue":void 0)}),De("input",He,Ne),po(He,()=>h(v),ne=>J(v,ne)),De("click",pt,function(...ne){e.close?.apply(this,ne)}),De("click",Mt,function(...ne){(h(w)?e.close:Ze)?.apply(this,ne)}),$(r,ye),Ce()}Tt(["input","click","change"]);var US=class extends c5.Modal{constructor(t){super(t);this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageImportModal"),this.handle=Wi(this.contentEl,HO,{app:this.app,close:()=>this.close()},{what:"the package importer"})}onClose(){this.handle?.destroy(),this.handle=null}};km();Gd();ka();function jO(r,e,t,n){let i=xr(r,"div"),o=xr(r,"strong");return o.textContent=e,i.appendChild(o),i.appendChild(ty(r,` ${t}`)),n?.className&&i.classList.add(n.className),i.classList.add("qa-dev-info-row"),r.appendChild(i),i}function u5(r,e){if(e.branch!==null&&jO(r,"Branch:",e.branch),e.commit!==null&&jO(r,"Commit:",e.commit),e.dirty!==null){let t=e.dirty?"Yes (uncommitted changes)":"No",n=e.dirty?"qa-dev-dirty-status":"qa-dev-clean-status";jO(r,"Uncommitted changes:",t,{className:n})}}Wt();var GO="Bundle or import QuickAdd automations as reusable packages.",qS=class extends ld.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){let n=le.getState();return t==="inputPrompt"?n.inputPrompt==="multi-line":n[t]}setControlValue(t,n){if(t==="inputPrompt"){le.setState({inputPrompt:n?"multi-line":"single-line"});return}if(t==="persistInputPromptDrafts"){let i=!!n;le.setState({persistInputPromptDrafts:i}),i||Yi.getInstance().clearAll();return}le.setState({[t]:n})}getSettingDefinitions(){return[this.choicesAndPackagesGroup(),this.choicePickerGroup(),this.inputGroup(),this.templatesGroup(),this.notificationsGroup(),this.globalVariablesGroup(),this.aiAndOnlineGroup(),this.appearanceGroup()]}hide(){super.hide(),this.destroySettingViews()}destroySettingViews(){this.choiceViewHandle?.destroy(),this.choiceViewHandle=null,this.globalVariablesViewHandle?.destroy(),this.globalVariablesViewHandle=null,this.packagesUnsubscribe?.(),this.packagesUnsubscribe=null}choicesAndPackagesGroup(){return{type:"group",heading:"Choices & packages",extraButtons:[t=>t.setIcon("help-circle").setTooltip("QuickAdd documentation").onClick(()=>Xj(Pl.gettingStarted,t.extraSettingsEl))],items:[{name:"Choices",render:t=>this.renderChoicesView(t)},{name:"Packages",desc:GO,render:t=>this.renderPackages(t)}]}}choicePickerGroup(){return{type:"group",heading:"Choice picker",items:[{name:"Search nested choices",desc:"When searching in the choice picker, also match choices nested inside folders and show their path. Note that nested matches can outrank same-level ones. Disable to search only the open level.",control:{type:"toggle",key:"searchNestedChoices"}},{name:"\u201CNew note from template\u201D in the launcher",desc:"Add a row to Run QuickAdd that lists templates from your configured template folder, so you can create a note from a template without a dedicated Template choice. Only appears when a template folder is configured; the command palette entry works regardless.",control:{type:"dropdown",key:"templateFolderLauncherRow",defaultValue:"bottom",options:{bottom:"Show at the bottom (keeps your top choice first)",top:"Show at the top",off:"Hide"}}}]}}inputGroup(){return{type:"group",heading:"Input",items:[{name:"Use multi-line input prompt",desc:"Use multi-line input prompt instead of single-line input prompt. Submit multi-line prompts with Ctrl/Cmd+Enter; Enter inserts a newline.",control:{type:"toggle",key:"inputPrompt"}},{name:"Persist input prompt drafts",desc:"Keep drafts when closing input prompts so they can be restored on reopen. Drafts are stored only for this session.",control:{type:"toggle",key:"persistInputPromptDrafts"}},{name:"Use editor selection as default Capture value",desc:"When enabled, Capture uses the current editor selection as {{VALUE}} and may skip the prompt. When disabled, Capture always prompts for {{VALUE}}.",control:{type:"toggle",key:"useSelectionAsCaptureValue"}},{name:"One-page input for choices",desc:this.descWithDocsLink("Collect a choice's inputs in one form before it runs, instead of one prompt at a time. Works with Template and Capture choices, and with Macros whose scripts declare inputs. Template and Capture choices can override this individually. ",Pl.onePageInputs,"Learn more about one-page inputs"),control:{type:"toggle",key:"onePageInputEnabled"}},{name:"Date aliases",desc:"Shortcodes for natural language date parsing. One per line: alias = phrase. Example: tm = tomorrow.",render:t=>this.renderDateAliases(t)}]}}templatesGroup(){return{type:"group",heading:"Templates & properties",items:[{name:"Template folder paths",desc:"Folders where templates are stored. Used to suggest template files when configuring QuickAdd. Add as many as you like; leave empty to suggest every template file in the vault.",render:t=>this.renderTemplateFolderPaths(t)},{name:"Convert string front matter variables to typed properties (Beta)",desc:'List/object values from scripts are always written as proper Obsidian properties (a list becomes a List). This toggle additionally converts string values into typed properties: a comma or bullet-list string becomes a List, "42" becomes a Number, "true" becomes a Checkbox, etc. Disabled by default; the string conversion is a beta heuristic that may have edge cases.',control:{type:"toggle",key:"enableTemplatePropertyTypes"}}]}}notificationsGroup(){return{type:"group",heading:"Notifications",items:[{name:"Announce updates",desc:"Display release notes when a new version is installed. This includes new features, demo videos, and bug fixes.",control:{type:"dropdown",key:"announceUpdates",defaultValue:"major",options:{all:"Show updates on each new release",major:"Show updates only on major releases (new features, breaking changes)",none:"Don't show"}}},{name:"Show capture notifications",desc:"Display a notification when content is captured successfully to confirm the operation completed.",control:{type:"toggle",key:"showCaptureNotification"}},{name:"Show input cancellation notifications",desc:"Display a notification when an input prompt is cancelled without submitting. Disable this to avoid extra notices when dismissing prompts.",control:{type:"toggle",key:"showInputCancellationNotification"}}]}}globalVariablesGroup(){return{type:"group",heading:"Global variables",items:[{name:"Global variables",render:t=>this.renderGlobalVariablesView(t)}]}}aiAndOnlineGroup(){return{type:"group",heading:"AI & online",items:[{name:"Disable AI & online features",desc:"This prevents the plugin from making requests to external providers like OpenAI. You can still use user scripts to execute arbitrary code, including contacting external providers. However, this setting disables plugin features like the AI Assistant from doing so. You need to disable this setting to use the AI Assistant.",control:{type:"toggle",key:"disableOnlineFeatures"}},{name:"Allow URI x-callback-url",desc:"When on, an obsidian://quickadd URI may open a callback URL (x-success / x-error / x-cancel) after a Template or Capture choice finishes \u2014 sending the outcome and the affected note's vault path and URL to that callback. While on, a URI that carries x-* callback params is restricted to Template and Capture choices (other choice types are warned and skipped). Off by default because the callback URL is set by whoever creates the obsidian:// link. Only shortcuts: and obsidian: callback URLs are permitted.",control:{type:"toggle",key:"enableUriCallbacks"}}]}}appearanceGroup(){return{type:"group",heading:"Appearance",items:[{name:"Show icon in sidebar",desc:"Add QuickAdd icon to the sidebar ribbon. Requires a reload.",control:{type:"toggle",key:"enableRibbonIcon"}}]}}developerGroup(){return{type:"group",heading:"Developer",items:[{name:"Development information",desc:"Git information for developers.",render:t=>this.renderDevInfo(t)}]}}descWithDocsLink(t,n,i="Learn more"){let o=document.createDocumentFragment();return o.append(document.createTextNode(t)),JA(o,n,i),o}prepareFullWidthSetting(t){t.infoEl.remove(),t.settingEl.addClass("qa-setting-full-width"),t.controlEl.addClass("qa-setting-full-width-control")}renderChoicesView(t){this.prepareFullWidthSetting(t),this.choiceViewHandle?.destroy();let n=Wi(t.controlEl,CO,{app:this.app,plugin:this.plugin,choices:le.getState().choices,saveChoices:i=>{le.setState({choices:i})}},{what:"your choices",fallbackComponent:fg});return this.choiceViewHandle=n,()=>{n.destroy(),this.choiceViewHandle===n&&(this.choiceViewHandle=null)}}renderGlobalVariablesView(t){this.prepareFullWidthSetting(t),this.globalVariablesViewHandle?.destroy();let n=Wi(t.controlEl,xO,{app:this.app,plugin:this.plugin},{what:"your global variables"});return this.globalVariablesViewHandle=n,()=>{n.destroy(),this.globalVariablesViewHandle===n&&(this.globalVariablesViewHandle=null)}}packagesDesc(t){return this.descWithDocsLink(t?`${GO} Export becomes available once you have a choice. `:`${GO} `,Pl.packages,"Learn more about packages")}renderPackages(t){let n;t.addButton(a=>{n=a,a.setButtonText("Export package\u2026").onClick(()=>{let l=gn(le.getState().choices);new DS(this.app,this.plugin,l).open()})}),t.addButton(a=>a.setButtonText("Import package\u2026").onClick(()=>{new US(this.app).open()}));let i=a=>{t.setDesc(this.packagesDesc(a)),n&&(n.setDisabled(a),a?n.setTooltip("Nothing to export yet"):n.buttonEl.removeAttribute("aria-label"))},o=gn(le.getState().choices).length===0;i(o),this.packagesUnsubscribe?.();let s=le.subscribe(a=>{let l=gn(a.choices).length===0;l!==o&&(o=l,i(l))});return this.packagesUnsubscribe=s,()=>{s(),this.packagesUnsubscribe===s&&(this.packagesUnsubscribe=null)}}renderDateAliases(t){t.settingEl.addClass("qa-date-alias-setting"),t.controlEl.addClass("qa-date-alias-control");let n=null;t.addTextArea(i=>{n=i,i.setPlaceholder(`t = today
tm = tomorrow
yd = yesterday`).setValue(T0(le.getState().dateAliases)).onChange(o=>{le.setState({dateAliases:aB(o)})}),i.inputEl.addClass("qa-date-alias-input")}),t.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{le.setState({dateAliases:Zf}),n?.setValue(T0(Zf))}),i.buttonEl.addClass("qa-date-alias-reset")})}renderTemplateFolderPaths(t){t.settingEl.addClass("qa-template-folders-setting");let n=t.controlEl.createDiv("qa-template-folders"),i=n.createDiv("qa-template-folder-list"),o=()=>zi(le.getState().templateFolderPaths),s=p=>{le.setState({templateFolderPaths:p})},a=()=>{i.empty();let p=o();if(p.length===0){i.createDiv({cls:"qa-template-folder-empty",text:"No folders added yet."});return}for(let m of p){let v=i.createDiv("qa-template-folder-row");v.createSpan({cls:"qa-template-folder-name",text:m,attr:{title:m}}),new ld.ExtraButtonComponent(v).setIcon("trash-2").setTooltip(`Remove ${m}`).onClick(()=>{s(o().filter(g=>g!==m)),a()})}},l=n.createDiv("qa-template-folder-input-row"),c=new ld.TextComponent(l);c.setPlaceholder("templates/"),c.inputEl.addClass("qa-template-folder-input");let u=new ii(this.app,c.inputEl,Bc(Vs(this.app)).filter(p=>p!=="/")),d=()=>{let[p]=zi([c.inputEl.value]);if(c.inputEl.value="",!p)return;let m=o();m.includes(p)||(s([...m,p]),a())},f=p=>{p.key==="Enter"&&(p.preventDefault(),d())};return c.inputEl.addEventListener("keydown",f),new ld.ButtonComponent(l).setCta().setButtonText("Add").onClick(()=>d()),a(),()=>{c.inputEl.removeEventListener("keydown",f),u.destroy()}}renderDevInfo(t){let n=t.settingEl.createDiv();n.addClass("qa-dev-info"),u5(n,{branch:null,commit:null,dirty:null})}};_0();Me();UT();var yg=class{formatOutputString(e){return`QuickAdd: (${e.level}) ${e.message}`}getQuickAddError(e,t,n,i){return{message:e,level:t,time:Date.now(),stack:n,originalError:i}}};Cr();var jx=class extends yg{constructor(){super(...arguments);this.ErrorLog=[]}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.error(this.formatOutputString(o),s)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.warn(this.formatOutputString(o),s)}logMessage(t,n,i){let o=this.getQuickAddError(t,"LOG",n,i);this.addMessageToErrorLog(o),i?console.log(this.formatOutputString(o),i):console.log(this.formatOutputString(o))}addMessageToErrorLog(t){this.ErrorLog.push(t),this.ErrorLog.length>$0&&(this.ErrorLog=this.ErrorLog.slice(-$0))}clearErrorLog(){this.ErrorLog=[]}};var YO=require("obsidian");UT();var WS=class extends yg{constructor(t){super();this.plugin=t}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);new YO.Notice(this.formatOutputString(o),15e3)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);new YO.Notice(this.formatOutputString(o))}logMessage(t,n,i){}};Me();Cr();Cr();var d5=1e4,p5=50,Ome=/plugin:([^\s:)]+)/;function Nme(r){let e=r.stack??"",t=`${r.name}: ${r.message}`;return(e.startsWith(t)?e.slice(t.length):e).split(`
`)}function Lme(r){for(let e of Nme(r)){let t=Ome.exec(e);if(t)return{pluginId:t[1],frame:e.trim()}}return null}function Bme(r,e){return`${r.name}@${e}`}function f5(r,e=Date.now){let t=r.manifest.id,n=new Map;r.registerDomEvent(window,"unhandledrejection",i=>{let o=i.reason,s=o instanceof Error?Lme(o):null;if(s?.pluginId!==t)return;if(It(o)){i.preventDefault();return}let a=o,l=Bme(a,s.frame),c=e(),u=n.get(l);if(n.set(l,c),!(u!==void 0&&c-u<d5)){if(n.size>=p5){for(let[d,f]of n)c-f>=d5&&n.delete(d);if(n.size>=p5){let d=n.keys().next();!d.done&&d.value!==l&&n.delete(d.value)}}lt(a,"A QuickAdd action failed")&&i.preventDefault()}})}var m5=require("obsidian");Me();function Vme(r,e){try{let t=r.setting;return!t?.open||!t?.openTabById?(M.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(t.open(),t.openTabById(e),!0)}catch(t){return M.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${t}`),!1}}function bg(r,e,t){let n=Vme(r,e);return!n&&t?.notice!==!1&&new m5.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}vE();Wt();Cr();var GD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choices=n;this.choiceExecutor=i}async run(){let e=Vn(this.choices).filter(t=>t.type==="Macro"&&t.runOnStartup);for(let t of e)try{await new Hl(this.app,this.plugin,t,this.choiceExecutor,new Map).run()}catch(n){lt(n,`Startup macro '${t.name}' failed`)}}};var M7=require("obsidian");var nv=require("obsidian");Gx();_t();Hc();Me();var XK=require("obsidian");sd();zg();Hg();xo();var QK=require("obsidian");Gs();Mo();function IE(r,e,t){let n=e.lastIndexOf("/"),i=n>=0?e.slice(0,n):"",o=hy(n>=0?e.slice(n+1):e),s=t?.vault.getAbstractFileByPath(e),a=t&&s instanceof QK.TFile?pF([s],d=>t.metadataCache.getFileCache(d))[0]:null,l=a?.primary??o,c=a?.secondary??i;r.addClass("mod-complex");let u=r.createDiv({cls:"suggestion-content"});u.createDiv({cls:"suggestion-title",text:l}),c&&u.createDiv({cls:"suggestion-note",text:c})}function bf(r,e={}){let{openedAtOf:t,recentRankOf:n,isExcluded:i}=e;return r.map(o=>({file:o,name:o.basename||o.path,excluded:i?.(o.path)??!1,openedAt:t?.(o.path),recentRank:n?.(o.path)})).sort((o,s)=>{if(o.excluded!==s.excluded)return o.excluded?1:-1;let a=o.openedAt!=null,l=s.openedAt!=null;if(a!==l)return a?-1:1;if(a&&l&&o.openedAt!==s.openedAt)return s.openedAt-o.openedAt;let c=o.recentRank??Number.POSITIVE_INFINITY,u=s.recentRank??Number.POSITIVE_INFINITY;return c!==u?c-u:o.name.localeCompare(s.name)}).map(o=>o.file)}zP();function wf(r){let e=r.workspace?.getLastOpenFiles?.(),t=Array.isArray(e)?e:[],n=new Map;t.forEach((s,a)=>{n.has(s)||n.set(s,a)});let i;try{i=Tm.getInstanceIfExists()}catch{i=void 0}let o=r.metadataCache;return{openedAtOf:s=>i?.getLastOpenedAt(s),recentRankOf:s=>n.get(s),isExcluded:s=>o?.isUserIgnored?.(s)??!1}}Cr();Hr();Dl();_c();var MN="@quickadd-existing-note:",RN="@quickadd-unresolved-note:";function Uye(r){return`${MN}${r}`}function qye(r){return`${RN}${r}`}function Wye(r){return r.startsWith(MN)}function zye(r){return r.startsWith(RN)}function Hye(r){return r.slice(MN.length)}function jye(r){return r.slice(RN.length)}function Cf(r){return r.trim().replace(/\.md$/i,"").toLowerCase()}function ZK(r){return r.trim().replace(/^\/+/,"")}function Gye(r){return r.trim().length>0&&!r.includes("{{")}function Yye(r){if(!Gye(r.templatePath))return new Set;let e=ZK(r.templatePath),t=/\.md$/i.test(e)?e:`${e}.md`;return new Set([t.toLowerCase()])}function Kye(r,e,t){let n=e.replace(/\.md$/i,"");r.add(Cf(e)),r.add(Cf(n)),r.add(Cf(t))}function Qye(r,e){let t=r.metadataCache.getFileCache(e)?.frontmatter;if(!t)return[];let n=[];for(let[i,o]of Object.entries(t)){let s=i.toLowerCase();s!=="alias"&&s!=="aliases"||(typeof o=="string"?n.push(...o.split(",").map(a=>a.trim()).filter(Boolean)):Array.isArray(o)&&n.push(...o.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)))}return n}function Xye(r){let n=((r.split("|")[0]?.trim()??"").split("#")[0]?.trim()??"").replace(/\.md$/i,"").trim();return!n||n==="/"||Un(n)?null:n}function Zye(r){let e=r.metadataCache.unresolvedLinks??{},t=new Map;for(let n of Object.values(e))for(let i of Object.keys(n)){let o=Xye(i);if(!o)continue;let s=Cf(o);t.has(s)||t.set(s,o)}return[...t.values()].sort((n,i)=>n.localeCompare(i))}function Jye(r,e){let t=new Set,n=Yye(e),i=bf(r.vault.getMarkdownFiles(),wf(r)),o=[];for(let s of i){if(n.has(ZK(s.path).toLowerCase()))continue;Kye(t,s.path,s.basename);let a=Qye(r,s),l=[s.basename,s.path,...a].join(" ");o.push({item:Uye(s.path),display:l,title:a[0]?`${s.basename} (${s.path})`:s.path,renderPath:s.path,renderAlias:a[0]})}for(let s of Zye(r)){let a=Cf(s);t.has(a)||o.push({item:qye(s),display:s,title:`${s} (unresolved link)`,unresolvedTitle:s})}return{candidates:o,existingKeys:t}}function ebe(r,e){r.addClass("mod-complex");let t=r.createDiv({cls:"suggestion-content"});t.createDiv({cls:"suggestion-title",text:e}),t.createDiv({cls:"suggestion-note",text:"Unresolved link"})}function tbe(r,e,t){if(IE(r,e),!t)return;r.querySelector(".suggestion-content")?.createDiv({cls:"suggestion-note",text:`Alias: ${t}`})}async function JK(r,e,t){let{candidates:n,existingKeys:i}=Jye(r,e),o=new Map(n.map(a=>[a.item,a])),s=`Search notes or create ${e.name}`;try{let a=String(await sa(t,{remote:c=>aa(c,{items:n.map(u=>({value:u.item,title:u.title})),placeholder:s,allowCustomInput:!0,what:"the note-discovery picker"}),headless:()=>{throw new xe(`'${e.name}' needs to ask which note to open or create, but this run is non-interactive. Pass the note name (e.g. value-value=<name>), or re-run with the ui flag.`)},app:()=>ln.Suggest(r,n.map(c=>c.display),n.map(c=>c.item),{placeholder:s,allowCustomValue:!0,customValueLabel:c=>`Create new note: ${c}`,valueExists:c=>{let u=Cf(c);return i.has(u)||n.some(d=>d.unresolvedTitle&&Cf(d.unresolvedTitle)===u)},renderItem:(c,u)=>{let d=o.get(c);if(d){if(d.renderPath){tbe(u,d.renderPath,d.renderAlias);return}d.unresolvedTitle&&ebe(u,d.unresolvedTitle)}}})}));if(Wye(a)){let c=r.vault.getAbstractFileByPath(Hye(a));if(c instanceof XK.TFile)return{kind:"openExisting",file:c};throw new Error("Selected note no longer exists. Please run QuickAdd again.")}if(zye(a)){let c=li(jye(a),"Note title");return{kind:"create",title:c,...c.includes("/")?{vaultRelativePath:c}:{}}}let l=li(a,"Note title");return{kind:"create",title:l,...l.includes("/")?{vaultRelativePath:l}:{}}}catch(a){throw It(a)?new Dt("Input cancelled by user"):a}}zg();Hg();ip();qt();Cr();var rv=class{constructor(e){this.executor=e;this.closed=!1}success(e,t){this.closed=!0,this.executor.recordExecutionResult?.({status:"success",file:e,effect:t})}failure(e){this.closed||this.executor.recordExecutionResult?.({status:"error",reason:e})}};function YD(r){return r instanceof Error?r.message||e7:String(r)||e7}var e7="Choice execution failed.";Dl();ey();sm();km();SD();zD();Bs();xo();gE();Wg();var KD=class extends yd{constructor(t,n,i,o,s=null){super(t,n,o);this.originLeaf=s;this.choiceExecutor=o,this.outcome=new rv(o),this.choice=i,this.formatter.setPromptRunContext({draftScopeId:i.id,choiceName:i.name})}async run(){let t=null,n=null;try{Ri(this.choice.templatePath,()=>`Invalid template path for ${this.choice.name}. ${this.choice.templatePath.length===0?"Template path is empty.":`Template path is not valid: ${this.choice.templatePath}`}`);let i=Tu(this.choice.appendLink);if(this.setLinkToCurrentFileBehavior(i.enabled&&!i.requireActiveFile?"optional":"required"),!this.validateAppendLinkDestination(i))return;let o=this.choice.fileNameFormat.enabled?this.choice.fileNameFormat.format:Os;if(d$(this.choice,o,this.choiceExecutor.variables.get("value"))){let w=await JK(this.app,this.choice,this.choiceExecutor);if(w.kind==="openExisting"){await this.openDiscoveredExistingNote(w.file),this.outcome.success(w.file,"unchanged");return}t=this.setTemporaryValueVariable(w.title),n=w.vaultRelativePath??null}let s=await this.resolveTemplateSourcePath(this.choice.templatePath),a="";if(n)a=zo(n);else if(this.choice.folder.enabled)a=await this.getFolderPath();else{let w=this.app.fileManager.getNewFileParent(this.app.workspace.getActiveFile()?.path??"");a=w===this.app.vault.getRoot()?"":w.path}this.formatter.setTargetFolderPath(a),this.choice.folder.enabled&&this.formatter.setPromptRunContext({destination:a,destinationKind:"folder"});let l=n||await this.formatter.formatFileName(o,"noteTitle"),c=li(l,"File name"),{fileName:u,strippedPrefix:d}=n?{fileName:c,strippedPrefix:!1}:this.stripDuplicateFolderPrefix(c,a),f=this.shouldTreatFormattedNameAsVaultRelativePath(c,d,this.choice.folder.enabled),p=this.normalizeTemplateFilePath(n||f?"":a,u,s),m,v=!1,g=!1,y="created";if(await this.app.vault.adapter.exists(p)){let w=await this.getSelectedFileExistsMode(),k=Ah(w);y=k.resolutionKind==="reuseExisting"?"unchanged":k.resolutionKind==="createNew"?"created":"changed";let C=k.requiresExistingFile?this.findExistingFile(p):null;if(k.requiresExistingFile&&(!(C instanceof nv.TFile)||C.extension!=="md"&&C.extension!=="canvas"&&C.extension!=="base")){this.failRun(`'${p}' already exists but could not be resolved as a markdown, canvas, or base file.`);return}if({createdFile:m,shouldAutoOpen:v}=await this.applyFileExistsMode(w,p,C,s,i),!m){this.lastTemplateFileFailure?this.failRun(this.lastTemplateFileFailure,"none"):this.failRun(`Could not resolve file exists behavior for '${p}'.`,"warning");return}}else{if(m=await this.createFileWithTemplate(p,s),!m){this.failRun(this.lastTemplateFileFailure??`Could not create file '${p}'.`,"none");return}g=!0}if(this.outcome.success(m,y),i.enabled&&m)try{i.destination.type==="specifiedFile"?await GT(this.app,m,i):np(i.placement)?await sp(this.app,m,i):this.choiceExecutor.focusedProperty?await QT(this.app,this.choiceExecutor.focusedProperty,m):await sp(this.app,m,i)}catch(w){if(w instanceof Nt)throw w;M.logWarning(`Created '${m.basename}' but could not insert the link: ${w instanceof Error?w.message:String(w)}`)}if(this.choice.copyLinkToClipboard&&m)try{await YT(m)}catch(w){M.logWarning(`Could not copy link to clipboard for '${m.path}': ${w instanceof Error?w.message:String(w)}`)}if((this.choice.openFile||v)&&m){let w=pn(this.choice.fileOpening),k=w.focus??!0;ap(this.app,m,k)||await gc(this.app,m,{...w,originLeaf:this.originLeaf}),await Eu(this.app,m)}else g&&!i.enabled&&!this.choice.copyLinkToClipboard&&new nv.Notice(`Created '${m.basename}'.`)}catch(i){if(vd(i,{logPrefix:"Template execution aborted",noticePrefix:"Template execution aborted",defaultReason:"Template execution aborted"})){this.choiceExecutor.signalAbort?.(i);return}Yi.getInstance().markExecutionScopeFailed(),this.outcome.failure(YD(i)),lt(i,`Error running template choice "${this.choice.name}"`)}finally{t?.()}}failRun(t,n="error"){Yi.getInstance().markExecutionScopeFailed(),n==="warning"?M.logWarning(t):n==="error"&&M.logError(t),this.outcome.failure(t)}setTemporaryValueVariable(t){let n=this.choiceExecutor.variables,i=n.has("value"),o=n.get("value");return n.set("value",t),()=>{if(i){n.set("value",o);return}n.delete("value")}}validateAppendLinkDestination(t){return!t.enabled||t.destination.type!=="specifiedFile"||Jv(this.app,t.destination)?!0:(this.failRun(`Append link target file not found or is not a Markdown file: ${t.destination.path}`),!1)}async getSelectedFileExistsMode(){var i;if((i=this.choice).fileExistsBehavior??(i.fileExistsBehavior={kind:"prompt"}),this.choice.fileExistsBehavior.kind==="apply")return this.choice.fileExistsBehavior.mode;let t=hG(),n="If the target file already exists";return await sa(this.choiceExecutor,{remote:o=>aa(o,{items:t.map(s=>({value:s.id,title:s.label})),placeholder:n,what:'the "file already exists" chooser'}),headless:()=>{throw new xe(`'${this.choice.name}' needs to ask what to do because a note with that name already exists, but this run is non-interactive. Set the choice's "If the file already exists" behaviour to a specific action (e.g. Increment, Overwrite), or re-run with the ui flag.`)},app:()=>Lr.Suggest(this.app,t.map(o=>o.label),t.map(o=>o.id),n)})}async applyFileExistsMode(t,n,i,o,s){let a=Ah(t);switch(a.resolutionKind){case"modifyExisting":return{createdFile:await this.applyExistingFileUpdate(a.id,i,o,s),shouldAutoOpen:!1};case"createNew":{let l=await bG(n,a.id,async u=>await this.app.vault.adapter.exists(u)),c=await this.createFileWithTemplate(l,o);return c&&l!==n&&!this.choice.openFile&&new nv.Notice(`Created '${c.basename}'.`),{createdFile:c,shouldAutoOpen:!1}}case"reuseExisting":return M.logMessage(`Opening existing file: ${i.path}`),{createdFile:i,shouldAutoOpen:!0}}}async openDiscoveredExistingNote(t){let n=pn(this.choice.fileOpening);ap(this.app,t,!0)||await gc(this.app,t,{...n,focus:!0,originLeaf:this.originLeaf})}async applyExistingFileUpdate(t,n,i,o){switch(t){case"appendTop":return await this.appendToExistingFileWithTemplate(n,i,"top",o);case"appendBottom":return await this.appendToExistingFileWithTemplate(n,i,"bottom",o);case"overwrite":return await this.overwriteFileWithTemplate(n,i)}}async appendToExistingFileWithTemplate(t,n,i,o){if(t.extension==="canvas"||t.extension==="base")return this.lastTemplateFileFailure=`Cannot append to '${t.path}': appending a template to a ${t.extension} file would corrupt it. Use the "Overwrite" file-exists option instead.`,Yi.getInstance().markExecutionScopeFailed(),M.logError(this.lastTemplateFileFailure),null;if(t.extension!=="md")return await this.appendToFileWithTemplate(t,n,i);let s=new Xg(this.app,this.plugin,t,n,i,this.choiceExecutor,n);return s.setPromptRunContext({draftScopeId:this.choice.id,choiceName:this.choice.name,destination:t.path,destinationKind:"file"}),s.setLinkToCurrentFileBehavior(o.enabled&&!o.requireActiveFile?"optional":"required"),await this.withAnonymousValueForInsertEngine(()=>s.apply())}async withAnonymousValueForInsertEngine(t){let n=this.formatter.getAnonymousValue(),i=this.choiceExecutor.variables;if(!(n!==void 0&&!i.has("value")))return await t();i.set("value",n);try{return await t()}finally{i.delete("value")}}findExistingFile(t){let n=this.app.vault.getAbstractFileByPath(t);if(n instanceof nv.TFile)return n;if(n)return null;let i=t.toLowerCase(),o=this.app.vault.getFiles().filter(s=>s.path.toLowerCase()===i);if(o.length===1)return o[0];if(o.length>1){let s=o.map(a=>a.path).join(", ");M.logError(`Multiple files match '${t}' when ignoring case: ${s}`)}return null}async formatFolderPaths(t){let n=[];for(let i of t)n.push(await this.formatter.formatFolderPath(i));return n}async getFolderPath(){let t=await this.formatFolderPaths([...this.choice.folder.folders]),n=this.getCurrentFolderSuggestion(),i=n?[n]:[],o=this.choiceExecutor;if(this.choice.folder?.chooseFromSubfolders&&!(this.choice.folder?.chooseWhenCreatingNote||this.choice.folder?.createInSameFolderAsActiveFile)){let s=Bc(Vs(this.app)),a=Jj(s,t);return await this.getOrCreateFolder(a,{allowCreate:!0,allowedRoots:t,topItems:i,executor:o})}if(this.choice.folder?.chooseWhenCreatingNote){let s=Bc(Vs(this.app));return await this.getOrCreateFolder(s,{allowCreate:!0,topItems:i,executor:o})}if(this.choice.folder?.createInSameFolderAsActiveFile){let s=this.app.workspace.getActiveFile();return!s||!s.parent?(M.logWarning("No active file or active file has no parent. Cannot create file in same folder as active file. Creating in root folder."),""):await this.getOrCreateFolder([s.parent.path],{allowCreate:!0,topItems:i,executor:o})}return await this.getOrCreateFolder(t,{allowCreate:!0,allowedRoots:t,topItems:i,executor:o})}getCurrentFolderSuggestion(){let t=this.app.workspace.getActiveFile(),n=t?.parent;return!t||!n?null:{path:n.path??"",label:"<current folder>"}}};var tu=require("obsidian");vl();sd();Gx();var QD=class{isResolved(){return!this.hasConflicts}isConflicted(){return this.hasConflicts}},PE=class r extends QD{constructor(e,t,n){super(),this.left=e,this.base=t,this.right=n,this.hasConflicts=!0}static create(e){return new r(e.left,e.base,e.right)}apply(e){return r.create({left:e(this.left),base:e(this.base),right:e(this.right)})}},ua=class r extends QD{constructor(e){super(),this.hasConflicts=!1,this.result=e}combine(e){this.result=this.result.concat(e.result)}apply(e){return new r(e(this.result))}};var Zc=class r{constructor(e,t){this.left=e,this.right=t}static executeDiff(e,t){if(!e.push)throw new Error("Argument is not an array");let n=r.diff(e,t);return new ON(e,t,n).convertToTypedOutput()}static diff(e,t){return new r(e,t).performDiff()}performDiff(){let e=this.identifyUniquePositions();e.sort((o,s)=>s[0]-o[0]);let[t,n]=this.findNextChange(),i=new XD(t,n,[]);return e.forEach(o=>{i=this.getDifferences(i,o)}),i.changeRanges}getDifferences(e,t){let[n,i]=[e.leftChangePos,e.rightChangePos],[o,s]=t;if(o<n||s<i)return e;{let[a,l,c,u]=this.findPrevChange(n,i,o-1,s-1),[d,f]=this.findNextChange(o+1,s+1),p=this.appendChangeRange(e.changeRanges,a,l,c,u);return new XD(d,f,p)}}findNextChange(e=0,t=0){let n=this.left.slice(e)||[],i=this.right.slice(t)||[],o=this.mismatchOffset(n,i);return[e+o,t+o]}findPrevChange(e,t,n,i){if(e>n||t>i)return[e,n,t,i];{let o=this.left.slice(e,n+1).reverse()||[],s=this.right.slice(t,i+1).reverse()||[],a=this.mismatchOffset(o,s);return[e,n-a,t,i-a]}}mismatchOffset(e,t){let n=Math.max(e.length,t.length);for(let i=0;i<n;i++)if(e[i]!==t[i])return i;return Math.min(e.length,t.length)}identifyUniquePositions(){let e=this.findUnique(this.left),t=this.findUnique(this.right),n=new Set(...e.keys()),i=new Set(...t.keys()),s=[...new Set([...n].filter(a=>i.has(a)))].map(a=>[e.get(a),t.get(a)]);return s.unshift([this.left.length,this.right.length]),s}findUnique(e){let t=new Map;e.forEach((i,o)=>{t.set(i,new $N(o,!t.has(i)))});let n=new Map;for(let[i,o]of t.entries())o.unique&&n.set(i,o.pos);return n}appendChangeRange(e,t,n,i,o){return t<=n&&i<=o?e.push(new FE(Gl.change,t+1,n+1,i+1,o+1)):t<=n?e.push(new FE(Gl.remove,t+1,n+1,i+1,i)):i<=o&&e.push(new FE(Gl.add,t+1,t,i+1,o+1)),e}},$N=class{constructor(e,t){this.pos=e,this.unique=t}},iv=class{constructor(e,t){this.text=e,this.low=t}},ON=class{constructor(e,t,n){this.oldTextArray=e,this.newTextArray=t,this.chunks=n,this.oldText=[],this.newText=[]}convertToTypedOutput(){let e=new NN(0,0);return this.chunks.forEach(t=>{let[n,i]=this.setTextNodeIndexes(t,e.oldIndex,e.newIndex),[o,s]=this.appendChanges(t,e.oldIndex+n,e.newIndex+i);e.oldIndex=o,e.newIndex=s}),this.setTheRemainingTextNodeIndexes(e.oldIndex,e.newIndex),{oldText:this.oldText,newText:this.newText}}setTextNodeIndexes(e,t,n){let i=0;for(;t+i<e.leftLo-1;)this.oldText.push(new iv(this.oldTextArray[t+i],n+i)),i+=1;let o=0;for(;n+o<e.rightLo-1;)this.newText.push(new iv(this.newTextArray[n+o],t+o)),o+=1;return[i,o]}appendChanges(e,t,n){for(;t<=e.leftHi-1;)this.oldText.push(this.oldTextArray[t]),t+=1;for(;n<=e.rightHi-1;)this.newText.push(this.newTextArray[n]),n+=1;return[t,n]}setTheRemainingTextNodeIndexes(e,t){let n=0;for(;e+n<this.oldTextArray.length;)this.oldText.push(new iv(this.oldTextArray[e+n],t+n)),n+=1;for(;t+n<this.newTextArray.length;)this.newText.push(new iv(this.newTextArray[t+n],e+n)),n+=1}},NN=class{constructor(e,t){this.oldIndex=e,this.newIndex=t}},Gl;(function(r){r.change="change",r.add="add",r.remove="remove"})(Gl||(Gl={}));var FE=class{constructor(e,t,n,i,o){this.action=e,this.leftLo=t,this.leftHi=n,this.rightLo=i,this.rightHi=o}},XD=class{constructor(e,t,n){this.leftChangePos=e,this.rightChangePos=t,this.changeRanges=n}};var ZD=class r{constructor(e,t,n,i,o){this.code=e,this.baseLo=t,this.baseHi=n,this.sideLo=i,this.sideHi=o}static fromChangeRange(e){return new r(e.action,e.leftLo,e.leftHi,e.rightLo,e.rightHi)}},ov=class r{constructor(e,t,n){this.left=e,this.base=t,this.right=n}static executeDiff(e,t,n){return new r(e,t,n).getDifferences()}getDifferences(){let e=Zc.diff(this.base,this.left).map(n=>ZD.fromChangeRange(n)),t=Zc.diff(this.base,this.right).map(n=>ZD.fromChangeRange(n));return this.collapseDifferences(new JD(e,t))}collapseDifferences(e,t=[]){if(e.isFinished())return t;{let n=new JD,i=e.chooseSide(),o=e.dequeue();return n.enqueue(i,o),e.switchSides(),this.buildResultQueue(e,o.baseHi,n),t.push(this.determineDifference(n,i,e.switchSides())),this.collapseDifferences(e,t)}}buildResultQueue(e,t,n){if(this.queueIsFinished(e.peek(),t))return n;{let i=e.dequeue();return n.enqueue(e.currentSide,i),t<i.baseHi?(e.switchSides(),this.buildResultQueue(e,i.baseHi,n)):this.buildResultQueue(e,t,n)}}queueIsFinished(e,t){return e.length===0||e[0].baseLo>t+1}determineDifference(e,t,n){let i=e.get(t)[0].baseLo,o=e.get(n),s=o[o.length-1].baseHi,[a,l]=this.diffableEndpoints(e.get(Hn.left),i,s),[c,u]=this.diffableEndpoints(e.get(Hn.right),i,s),d=this.left.slice(a-1,l),f=this.right.slice(c-1,u),p=this.decideAction(e,d,f);return new LN(p,a,l,c,u,i,s)}diffableEndpoints(e,t,n){if(e.length){let i=e[0],o=e[e.length-1],s=i.sideLo-i.baseLo+t,a=o.sideHi-o.baseHi+n;return[s,a]}else return[t,n]}decideAction(e,t,n){return e.isEmpty(Hn.left)?Jc.chooseRight:e.isEmpty(Hn.right)?Jc.chooseLeft:t.every((i,o)=>n[o]===i)?Jc.noConflictFound:Jc.possibleConflict}},LN=class{constructor(e,t,n,i,o,s,a){this.changeType=e,this.leftLo=t,this.leftHi=n,this.rightLo=i,this.rightHi=o,this.baseLo=s,this.baseHi=a}},Jc;(function(r){r.chooseRight="choose_right",r.chooseLeft="choose_left",r.possibleConflict="possible_conflict",r.noConflictFound="no_conflict_found"})(Jc||(Jc={}));var Hn;(function(r){r.left="left",r.right="right"})(Hn||(Hn={}));var JD=class{constructor(e=[],t=[]){this.diffs={left:e,right:t}}dequeue(e=this.currentSide){return this.diffs[e].shift()}peek(e=this.currentSide){return this.diffs[e]}isFinished(){return this.isEmpty(Hn.left)&&this.isEmpty(Hn.right)}enqueue(e=this.currentSide,t){return this.diffs[e].push(t)}get(e=this.currentSide){return this.diffs[e]}isEmpty(e=this.currentSide){return this.diffs[e].length===0}switchSides(e=this.currentSide){return this.currentSide=e===Hn.left?Hn.right:Hn.left}chooseSide(){return this.isEmpty(Hn.left)?this.currentSide=Hn.right:this.isEmpty(Hn.right)?this.currentSide=Hn.left:this.currentSide=this.get(Hn.left)[0].baseLo<=this.get(Hn.right)[0].baseLo?Hn.left:Hn.right,this.currentSide}};var ME=class r{static merge(e,t,n){let i=new r(e,t,n);return i.executeThreeWayMerge(),i.result}constructor(e,t,n){this.result=[],this.text3=new BN(e,n,t)}executeThreeWayMerge(){let e=ov.executeDiff(this.text3.left,this.text3.base,this.text3.right),t=1;e.forEach(i=>{let o=[];for(let s=t;s<i.baseLo;s++)o.push(this.text3.base[s-1]);o.length&&this.result.push(new ua(o)),this.interpretChunk(i),t=i.baseHi+1});let n=this.accumulateLines(t,this.text3.base.length,this.text3.base);n.length&&this.result.push(new ua(n))}setConflict(e){let t=PE.create({left:this.accumulateLines(e.leftLo,e.leftHi,this.text3.left),base:this.accumulateLines(e.baseLo,e.baseHi,this.text3.base),right:this.accumulateLines(e.rightLo,e.rightHi,this.text3.right)});this.result.push(t)}determineConflict(e,t,n){let i=1;e.forEach(s=>{for(let l=i;l<=s.leftLo;l++)this.result.push(new ua(this.accumulateLines(i,l,n)));let a=this.determineOutcome(s,t,n);i=s.rightHi+1,a&&this.result.push(a)});let o=this.accumulateLines(i,n.length+1,n);o.length&&this.result.push(new ua(o))}determineOutcome(e,t,n){return e.action===Gl.change?PE.create({left:this.accumulateLines(e.rightLo,e.rightHi,t),right:this.accumulateLines(e.leftLo,e.leftHi,n),base:[]}):e.action===Gl.add?new ua(this.accumulateLines(e.rightLo,e.rightHi,t)):null}setText(e,t,n){let i=[];for(let o=t;o<=n;o++)i.push(e[o-1]);return i}_conflictRange(e){let t=this.setText(this.text3.right,e.rightLo,e.rightHi),n=this.setText(this.text3.left,e.leftLo,e.leftHi),i=Zc.diff(t,n);(this._assocRange(i,Gl.change)||this._assocRange(i,Gl.remove))&&e.baseLo<=e.baseHi?this.setConflict(e):this.determineConflict(i,n,t)}interpretChunk(e){if(e.changeType==Jc.chooseLeft){let t=this.accumulateLines(e.leftLo,e.leftHi,this.text3.left);t.length&&this.result.push(new ua(t))}else if(e.changeType!==Jc.possibleConflict){let t=this.accumulateLines(e.rightLo,e.rightHi,this.text3.right);t.length&&this.result.push(new ua(t))}else this._conflictRange(e)}_assocRange(e,t){for(let n=0;n<e.length;n++){let i=e[n];if(i.action===t)return i}return null}accumulateLines(e,t,n){let i=[];for(let o=e;o<=t;o++)n[o-1]&&i.push(n[o-1]);return i}},BN=class{constructor(e,t,n){this.left=e,this.right=t,this.base=n}};var xf=class{constructor(e,t,n={}){this.results=e,this.joinFunction=t,this.conflictHandler=n.conflictHandler,this.conflict=n.conflict||!1}isSuccess(){return!this.conflict}isConflict(){return!!this.conflict}joinedResults(){if(this.isConflict())return this.conflictHandler?this.conflictHandler(this.results):this.results;{let[e,t]=[this.results[0],this.results.slice(1)],n=e;return t.forEach(i=>n.combine(i)),n.apply(this.joinFunction).result}}};var RE=class r{static collateMerge(e,t,n){return e.length?(e=r.combineNonConflicts(e),e.length===1&&e[0].isResolved()?new xf(e,t):new xf(e,t,{conflict:!0,conflictHandler:n})):new xf([new ua([])],t)}static combineNonConflicts(e){let t=[];return e.forEach(n=>{t.length&&t[t.length-1].isResolved()&&n.isResolved()?t[t.length-1].combine(n):t.push(n)}),t}};function t7(r,e,t,n){return function(o){return o.map(s=>{if(s.isResolved())return s.apply(n).result;{let a=s.apply(n),{left:l,right:c}=a;return[r,l,e,c,t].join(`
`)}}).join(`
`)}}var r7=r=>r.join(""),rbe=r=>r.split(/\b/),nbe=t7("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",r7),ibe={splitFunction:rbe,joinFunction:r7,conflictFunction:nbe};function VN(r,e,t,n={}){n=Object.assign({},ibe,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=ME.merge(i,o,s);return RE.collateMerge(a,n.joinFunction,n.conflictFunction)}var n7=VN;_t();vl();HD();_t();qt();xo();Gg();function i7(r,e){return r.line===e.line}function eu(r){let e=[];return r.forEach((t,n)=>{let i=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}function wd(r,e,t=!1){let n=eu(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)throw new Error(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){let c=o7(r,e,u=>u.trim()==="");return c!==null&&c>e?c-1:e}let s=r.length-1,a=obe(i,n,r,t),l=lbe(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)return e;let c=r[l+1].trim()==="";return l+1===s&&!c?a:l===0?l+1:l}return a}function obe(r,e,t,n){let i=e.findIndex(u=>i7(u,r)),o=i===e.length-1,s=t.length-1;if(o)return s;let[a,l]=sbe(r,e);if(l&&a===e.length)return s;if(l&&n)return e[a].line-1;if(l&&!n)return e[i+1].line;if(!n&&!l){let u=abe(r.line,e);return u===null?s:u}return s}function sbe(r,e){let t=e.findIndex(i=>i7(i,r)),n=o7(e,t,i=>i.level<=r.level);return n===null?[-1,!1]:[n,!0]}function abe(r,e){let t=e.find(n=>n.line>r);return t?t.line:null}function lbe(r,e,t){for(let n=e-1;n>=0;n--)if(t(r[n]))return n;return null}function o7(r,e,t){for(let n=e+1;n<r.length;n++)if(t(r[n]))return n;return null}var cbe="\u200B";function $E(r){let e=r.slice(),t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=r[o].match(/^(\s*)(`{3,}|~{3,})/);if(!t){s&&(t=!0,n=s[2][0],i=s[2].length);continue}e[o]=r[o].replace(/^(\s*)#+(\s)/,`$1${cbe}$2`),s&&s[2][0]===n&&s[2].length>=i&&r[o].slice(s[1].length+s[2].length).trim()===""&&(t=!1,n="",i=0)}return e}function s7(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}function ube(r){let e=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};let t=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}function a7(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{let n=r.match(/^-?\d+(?:\.\d+)?/);return n?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{let n=t?t(r,e.dateFormat||void 0,!1):null;return n&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":return ube(r);default:return{value:0,parsed:!0}}}function dbe(r,e){if(typeof r.value=="string"&&typeof e.value=="string")return r.value<e.value?-1:r.value>e.value?1:0;let t=r.value,n=e.value;return t<n?-1:t>n?1:0}function l7(r,e,t,n,i,o=0){let s=$E(r),a=eu(s).filter(f=>f.line>=o),l=a.filter(f=>f.level===t),c=a7(s7(e),n,i);if(l.length===0){let f=a.filter(p=>p.level<t).pop();return f?{mode:"after",line:wd(s,f.line,!0)}:{mode:"bodyStart"}}let u=()=>{let f=l[l.length-1];return{mode:"after",line:wd(s,f.line,!0)}};if(n.by==="insertion")return n.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)return u();let d=n.unparseable??"bottom";for(let f of l){let p=a7(s7(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{let v=dbe(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}return u()}TE();function UN(r){let e=r.split(`
`);for(;e.length>1&&e[e.length-1].trim()==="";)e.pop();return e}function qN(r){return r.length===0||r.length===1&&r[0].trim()===""}function WN(r,e){if(e.length<=1){let t=pbe(r,e[0]??"");return{start:t,end:t}}return fbe(r,e)}function pbe(r,e){let t=e.trimEnd(),n=-1;for(let i=0;i<r.length;i++){let o=r[i].trimStart();if(o===t)return i;if(o.startsWith(t)){let a=o.slice(t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i);continue}let s=o.indexOf(t);if(s!==-1){let a=o.slice(s+t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i)}}return n}function fbe(r,e){let t=e.length,n=e.map(i=>c7(i));for(let i=0;i+t<=r.length;i++){let o=!0;for(let s=0;s<t;s++)if(c7(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+t-1}}return{start:-1,end:-1}}function c7(r){return r.trimEnd()}function u7(r,e,t){return r?eu([e[t]??""]).length>0:!1}function mbe(r,e){return r==="skip"?!0:r==="none"?!1:hbe(e)}function hbe(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function zN(r,e,t,n){if(e<0)return e;let i=r[e]??"";if(!mbe(n,i))return e;let s=t.endsWith(`
`)?Math.max(r.length-1,0):r.length,a=e;for(let l=e+1;l<s;l++){if(r[l].trim().length===0){a=l;continue}break}return a}function eI(r,e,t,n){if(e<0)return e;let i=e,o=e+1;for(;o<r.length&&r[o].trim().length===0;)i=o,o++;return i===e||o!==r.length||!n.endsWith(`
`)?e:t.endsWith(`
`)?Math.max(e,i-1):i}function d7(r){return r.includes(`
`)||r.includes("\r")}function p7(r,e){let t=r.indexOf(`
`,e);return t===-1?r.length:t>0&&r[t-1]==="\r"?t-1:t}function HN(r){let e=xN(r);return e>0?r.slice(0,e).split(`
`).length-1:0}function f7(r,e){let t=HN(e),n=r.map((i,o)=>o<t?"":i);return $E(n).map(i=>i.replace(/\r$/,""))}function m7(r,e,t,n){let i=e.split(`
`),o=i.slice(0,t+1).join(`
`),s=i.slice(t+1).join(`
`),l=(i[t+1]??"").trim(),c=e.endsWith(`
`)&&t+1===i.length-1,u=t+1<i.length&&!c&&l==="",d=n&&r.endsWith(`
`)&&u?r.slice(0,-1):r,f=!d.endsWith(`
`)&&l!==""?`
`:"";return{content:`${o}
${d}${f}${s}`,insertedEndOffset:o.length+1+d.length}}function h7(r,e,t,n=r.length){let i=e.length>0&&!r.endsWith(`
`)?`
`:"",o=Math.max(0,Math.min(n,r.length));if(t<=0)return{content:`${r}${i}${e}`,insertedEndOffset:o};let s=e.split(`
`),a=s.slice(0,t).join(`
`),l=s.slice(t).join(`
`);return{content:`${a}
${r}${i}${l}`,insertedEndOffset:a.length+1+o}}function g7(r,e,t,n){let i=n,o=i.includes(`\r
`)?`\r
`:`
`,s=e.mode==="before"?e.line:e.line+1,a=0;for(let w=0;w<s&&w<r.length;w++)a+=r[w].length+1;a>i.length&&(a=i.length);let l=i.slice(0,a),c=i.slice(a),u=s>0?(r[s-1]??"").replace(/\r$/,""):"",d=s<r.length?(r[s]??"").replace(/\r$/,""):"",f=t.split(`
`).map(w=>w.replace(/\r$/,""));f.length>1&&f[f.length-1]===""&&f.pop();let p=[];s>0&&u.trim()!==""&&p.push(""),p.push(...f),s<r.length&&d.trim()!==""&&p.push("");let m=p.join(o),v=l.length>0&&!/\n$/.test(l)?o:"",g=c.length>0||/\n$/.test(i)?o:"",y=l.length+v.length;return{content:`${l}${v}${m}${g}${c}`,insertedEndOffset:y+m.length}}TE();Wg();XP();var vbe=/^[ \t\r\n\f\v]*$/;function v7(r){return vbe.test(r)}var tI=class extends xs{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.useSelectionAsCaptureValue=!0;this.clipboardImageFallbackEnabled=!1;this.createdClipboardAttachmentPaths=[];this.templaterProcessed=!1;this.insertAfterTargetOverride=null;this.lastResolvedInsertAfterHeading=null;this.linebreaksProcessed=!1;this.captureInsertionEndOffset=null}setDestinationFile(t){this.file=t,this.sourcePath=t.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(zo(t.path)),this.setPromptRunContext({destination:t.path,destinationKind:"file"})}setDestinationSourcePath(t){this.sourcePath=t,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(zo(t)),this.setPromptRunContext({destination:t,destinationKind:"file"})}setUseSelectionAsCaptureValue(t){this.useSelectionAsCaptureValue=t}setInsertAfterTargetOverride(t){this.insertAfterTargetOverride=t}getResolvedInsertAfterHeading(){return this.lastResolvedInsertAfterHeading}consumeCreatedClipboardAttachmentPaths(){let t=this.createdClipboardAttachmentPaths;return this.createdClipboardAttachmentPaths=[],t}getCaptureInsertionEndOffset(){return this.captureInsertionEndOffset}setCaptureInsertionEndOffset(t){this.captureInsertionEndOffset=typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}shouldUseSelectionForValue(){return this.useSelectionAsCaptureValue}async getSelectedTextForValue(){let t=await this.getSelectedText();return t.trim().length>0?t:""}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}async getClipboardContent(){let t=await super.getClipboardContent();return t.length>0||!this.clipboardImageFallbackEnabled?t:this.clipboardAttachmentLink!==void 0?this.clipboardAttachmentLink??"":(this.clipboardAttachmentLink=await this.saveClipboardImageAsAttachment(),this.clipboardAttachmentLink??"")}async withClipboardImageFallback(t){let n=this.clipboardImageFallbackEnabled;this.clipboardImageFallbackEnabled=!0;try{return await t()}finally{this.clipboardImageFallbackEnabled=n}}async saveClipboardImageAsAttachment(){let t=navigator.clipboard;if(typeof t?.read!="function")return null;let n,i;try{if(n=await this.getFirstClipboardImageItem(t),!n)return null;i=await(await n.clipboardItem.getType(n.mimeType)).arrayBuffer()}catch{return null}let o=this.getLinkSourcePath()??"",s=await F_(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),M_(this.app,s,o)}async getFirstClipboardImageItem(t){let n=await t.read();for(let i of n){let o=i.types.find(s=>wy[s]!==void 0);if(o)return{clipboardItem:i,mimeType:o}}return null}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(t,n)}async formatContentWithFile(t,n,i,o){if(this.setCaptureInsertionEndOffset(null),this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null)return t;this.setTargetFolderPath(zo(o.path));let s=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatFileContent(t,s)}async formatContent(t,n){return this.choice=n,n?await this.formatFileContent(t):t}async formatFileContent(t,n=!0){let i=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));if(n&&this.file&&!this.templaterProcessed){let a=await hc(this.app,i,this.file);a&&(i=a),this.templaterProcessed=!0}if(v7(i))return this.fileContent;if(this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWritePosition==="bottom"){let a=!this.choice.task,l=this.fileContent.length>0&&!this.fileContent.endsWith(`
`)&&!i.startsWith(`
`),c=a||l?`
`:"";return this.setCaptureInsertionEndOffset(this.fileContent.length+c.length+i.length),`${this.fileContent}${c}${i}`}return this.choice.insertAfter.enabled?await this.insertAfterHandler(i):this.choice.insertBefore?.enabled?await this.insertBeforeHandler(i):this.insertAtNoteBodyStartTracking(i)}async formatContentOnly(t){let n=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));return v7(n)?this.fileContent:n}async expandTemplateLinebreaksOnce(t){return this.linebreaksProcessed?t:(this.linebreaksProcessed=!0,this.expandFormatTemplateEscapes(t))}async expandFormatTemplateEscapes(t){let n=await this.replaceGlobalVarInString(t);return this.expandLinebreakEscapesOutsideTokens(n)}async insertAfterHandler(t){let n=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&n===null){let f=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(t,f)}let i=n??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(n===null){let f=i.split(`
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let o=UN(i);if(qN(o))throw new xe("Insert-after target is empty after formatting.");let s=yf(this.fileContent),a=this.isOrderedCreate()?f7(s,this.fileContent):s,{start:l,end:c}=WN(a,o);if(l===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,i);throw new xe(`Insert-after target not found: '${i}'.`)}let d;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=wd(s,l,this.considerSubsectionsForAnchor(s,l)),p=Math.max(f??s.length-1,c);d=eI(s,p,this.fileContent,t)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";d=zN(s,c,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,d)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new xe("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=UN(i);if(qN(o))throw new xe("Insert-before target is empty after formatting.");let s=yf(this.fileContent),{start:a}=WN(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new xe(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(d7(n))throw new xe("Inline insert-after target must be a single line \u2014 remove the line break (\\n) or turn off inline insertion.");let i=this.fileContent.indexOf(n);if(i===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInlineInsertAfterIfNotFound(t,n);throw new xe(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length;if(this.setCaptureInsertionEndOffset(o+t.length),this.choice.insertAfter?.replaceExisting){let s=p7(this.fileContent,o);return this.fileContent.slice(0,o)+t+this.fileContent.slice(s)}return this.fileContent.slice(0,o)+t+this.fileContent.slice(o)}async createInsertAfterIfNotFound(t,n){let i=`${n}
${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===fo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===dc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===pc){let o=Nn(this.app);if(!o)throw new xe(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let c=yf(this.fileContent),u=wd(c,a,this.considerSubsectionsForAnchor(c,a));a=eI(c,u??c.length-1,this.fileContent,i)}return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new xe(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===Aa)return this.createInsertAfterOrdered(t,n);throw new xe(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===Aa}considerSubsectionsForAnchor(t,n){return u7(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){let i=this.choice.insertAfter?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},o=n.split(/\r?\n/,1)[0],s=eu([o])[0]?.level??0,a=`${n}
${t}`;if(s===0)return this.insertAtNoteBodyStartTracking(a);let l=yf(this.fileContent),c=l.map(g=>g.replace(/\r$/,"")),u=HN(this.fileContent),d=$E(c),f=o.replace(/\r$/,"").trimEnd(),p=d.findIndex((g,y)=>y>=u&&g.trimEnd()===f);if(p!==-1){let g=this.choice.insertAfter?.insertAtEnd?eI(d,wd(d,p,this.considerSubsectionsForAnchor(d,p))??d.length-1,this.fileContent,t):zN(d,p,this.fileContent,this.choice.insertAfter?.blankLineAfterMatchMode??"auto");return this.insertTextAfterPositionInBody(t,this.fileContent,g)}let m=typeof window<"u"?window.moment:void 0,v=l7(c,o,s,i,m,u);return v.mode==="bodyStart"?this.insertAtNoteBodyStartTracking(a):this.spliceOrderedSection(l,v,a)}spliceOrderedSection(t,n,i){let{content:o,insertedEndOffset:s}=g7(t,n,i,this.fileContent);return this.setCaptureInsertionEndOffset(s),o}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new xe("Insert-before settings are missing.");let o=t.endsWith(`
`)||t.length===0?`${t}${n}`:`${t}
${n}`;if(i.createIfNotFoundLocation===fo)return this.insertAtNoteBodyStartTracking(o,t.length);if(i.createIfNotFoundLocation===dc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+t.length),`${this.fileContent}
${o}`;if(i.createIfNotFoundLocation===pc){let s=Nn(this.app);if(!s)throw new xe(`Unable to insert line '${i.before}' at cursor position: no active markdown editor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new xe(`Unable to insert line '${i.before}' at cursor position.`)}}throw new xe(`Unknown createIfNotFoundLocation: ${i.createIfNotFoundLocation}`)}async createInlineInsertAfterIfNotFound(t,n){let i=`${n}${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===fo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===dc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===pc){let o=Nn(this.app);if(!o)throw new xe(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new xe(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}throw new xe(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}insertAtNoteBodyStartTracking(t,n=t.length){let i=EN(this.fileContent,t);if(i.insertedStartOffset===null)return this.setCaptureInsertionEndOffset(null),i.content;let o=Math.max(0,Math.min(n,t.length));return this.setCaptureInsertionEndOffset(i.insertedStartOffset+o),i.content}insertTextAfterPositionInBody(t,n,i){let{content:o,insertedEndOffset:s}=m7(t,n,i,!!this.choice.task);return this.setCaptureInsertionEndOffset(s),o}insertTextBeforePositionInBody(t,n,i,o=t.length){let{content:s,insertedEndOffset:a}=h7(t,n,i,o);return this.setCaptureInsertionEndOffset(a),s}};HD();Me();ip();qt();Cr();zg();Hg();var y7=require("obsidian");_t();xo();Dl();function b7(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=xh(t);if(n){if(!n.field)throw new xe("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=Ch(t);if(i){if(i.multiSelect)throw new xe("Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata.");return{kind:"filter",filter:i.filter}}let o=li(t,"Capture target file path");if(qi.test(o))throw new xe(`Capture to '.base' files is not supported (${o}). Use a Template choice instead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(ir.test(o)||zr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof y7.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}_t();function rI(r){return`${r.replace(/^\/+/,"").replace(ir,"")}.md`}function nI(r,e,t){if(t)return null;let n=(e??"").trim().replace(/^\/+/,"");if(ku(n))return null;let i=xh(n),o=!!i&&!!i.field,s=o?null:Ch(n),a=!!s&&!s.multiSelect,l=!o&&!s&&n.startsWith("#"),c=n.endsWith("/"),u=!l&&!o&&!a&&!c&&(ir.test(n)||zr.test(n)||qi.test(n)),d=n.replace(/\/+$/,""),f=!l&&!o&&!a&&!u&&(n===""||r.isFolder(d)&&!r.markdownFileExists(d)),p=!o&&!a&&c;if(o&&i)return{kind:"property",field:i.field,value:i.value,filter:i.filter};if(a&&s)return{kind:"filter",filter:s.filter};if(l)return{kind:"tag",tag:n};if(f||p){let m=d;return{kind:"folder",folderPathSlash:m===""?"":`${m}/`}}return null}ey();Dl();_c();km();sm();Wg();Gs();FN();_D();xo();AD();vN();function w7(r){let e=r.insertAfter.enabled||!!r.insertBefore?.enabled;return r.captureToActiveFile&&!e&&r.newLineCapture?.enabled?r.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":r.captureToActiveFile&&!e?r.activeFileWritePosition==="top"?"activeFileTop":r.activeFileWritePosition==="bottom"||r.prepend?"append":"currentLine":r.insertAfter.enabled?"insertAfter":r.insertBefore?.enabled?"insertBefore":r.prepend?"prepend":"append"}_t();xo();function jN(r){return r?.type==="text"?"text":r?.type==="file"||r?.file?"file":typeof r?.text=="string"?"text":"unsupported"}function ybe(r,e){let t=e.id;if(!t)return null;let n=r.getData?.();return n?.nodes?.length?n.nodes.find(i=>i.id===t)??null:null}function C7(r,e){if(r==="text"){if(e==="currentLine")return"Canvas capture does not support 'At cursor' for text cards. Use top, bottom, insert-after, or insert-before placement.";if(e==="newLineAbove"||e==="newLineBelow")return"Canvas capture does not support 'New line above/below cursor' for text cards. Use top, bottom, insert-after, or insert-before placement."}return r==="file"&&(e==="currentLine"||e==="newLineAbove"||e==="newLineBelow")?"Canvas file cards do not support cursor-based capture modes. Use top, bottom, insert-after, or insert-before modes.":null}function bbe(r){let e=r.file;return e?typeof e=="string"?e:typeof e=="object"&&"path"in e&&typeof e.path=="string"?e.path:null:null}function GN(r){return!!r&&"path"in r&&"extension"in r}function wbe(r){let t=(r.workspace.activeLeaf??r.workspace.getMostRecentLeaf?.()??null)?.view;return!t||t.getViewType?.()!=="canvas"?null:t}function Cbe(r,e){let t=e.file??r.workspace.getActiveFile?.();if(!t)throw new xe("Cannot capture to Canvas because no active Canvas file is available.");return t}function xbe(r){let e=r.selection?Array.from(r.selection):[];if(e.length!==1)throw new xe("Canvas capture requires exactly one selected node.");return e[0]}function x7(r){let e=bbe(r);if(!e)throw new xe("Selected Canvas file card does not have a valid linked file path.");if(!ir.test(e))throw new xe("Canvas file card targets markdown files only in this version.");return e}function Ebe(r,e){let t=x7(e),n=r.vault.getAbstractFileByPath(t);if(!GN(n))throw new xe(`Selected Canvas file card target not found: ${t}`);return n}function Tbe(r,e){let t=x7(e),n=r.vault.getAbstractFileByPath(t);if(!n)return{targetPath:t};if(!GN(n))throw new xe(`Selected Canvas file card target not found: ${t}`);return{targetPath:t,targetFile:n}}function _be(r,e){let t;try{t=JSON.parse(r)}catch{throw new xe(`Canvas file is not valid JSON: ${e}`)}if(!t||typeof t!="object")throw new xe(`Canvas file has invalid structure: ${e}`);if(!Array.isArray(t.nodes))throw new xe(`Canvas file has no nodes array: ${e}`);return t}function E7(r,e){let t=r,n=wbe(t);if(!n)return null;let i=n.canvas;if(!i)throw new xe("Canvas capture is unavailable in this Obsidian version.");let o=Cbe(t,n),s=xbe(i),a=ybe(i,s),l=jN(s);if(l==="unsupported"&&a&&(l=jN(a)),l==="unsupported")throw new xe("Canvas capture currently supports only text and file cards.");let c=C7(l,e);if(c)throw new xe(c);if(l==="text")return{kind:"text",source:"active",canvas:i,canvasFile:o,node:s,nodeData:a};let u=s.file||!a?.file?s:{...s,file:a.file};return{kind:"file",source:"active",canvasFile:o,node:u,targetFile:Ebe(t,u)}}async function T7(r,e,t,n){let i=t.trim();if(!i)throw new xe("Canvas node id is required for Canvas node capture.");let o=r.vault.getAbstractFileByPath(e);if(!GN(o))throw new xe(`Canvas target not found: ${e}`);if(!zr.test(o.path))throw new xe("Canvas node capture requires the target path to be a .canvas file.");let s=await r.vault.read(o),a=_be(s,o.path),l=a.nodes.findIndex(v=>v.id===i);if(l===-1)throw new xe(`Canvas node id '${i}' was not found in ${o.path}.`);let c=a.nodes[l],u=jN(c);if(u==="unsupported")throw new xe("Canvas capture currently supports only text and file cards.");let d=C7(u,n);if(d)throw new xe(d);if(u==="text")return{kind:"text",source:"configured",canvasFile:o,rawCanvas:s,canvasData:a,nodeData:c,nodeIndex:l};let f=r,{targetPath:p,targetFile:m}=Tbe(f,c);return{kind:"file",source:"configured",canvasFile:o,nodeData:c,targetPath:p,targetFile:m}}function _7(r){return r.source==="active"?typeof r.node.text=="string"?r.node.text:typeof r.nodeData?.text=="string"?r.nodeData.text:"":typeof r.nodeData.text=="string"?r.nodeData.text:""}async function A7(r,e,t){if(e.source==="active"){typeof e.node.setText=="function"?e.node.setText(t):e.node.text=t,e.canvas.requestSave?.();return}if(await r.vault.read(e.canvasFile)!==e.rawCanvas)throw new xe("Canvas target changed while capture was running. Re-run capture to avoid overwriting newer Canvas edits.");e.nodeData.text=t,e.canvasData.nodes[e.nodeIndex]=e.nodeData,await r.vault.modify(e.canvasFile,JSON.stringify(e.canvasData,null," "))}gE();var iI=4e3,Abe=/^[ \t\r\n\f\v]*$/;function kbe(r){return Abe.test(r)}var Sbe=/\{\{(?:VALUE|FILE|FIELD):[^}]*\|\s*multi\s*(?=[:}|]|$)[^}]*\}\}/gi,Dbe=/\|\s*format\s*:\s*(?:inline|yaml|markdown)\s*(?=\||}})/i;function Ibe(r){return Array.from(r.matchAll(Sbe)).some(e=>!Dbe.test(e[0]))}var oI=class extends tv{constructor(t,n,i,o,s=null){super(t);this.choiceExecutor=o;this.originLeaf=s;this.capturePropertyVars=new Map;this.suppressFrontmatterCollection=!1;this.resolvedInsertAfterHeading=null;this.choice=i,this.plugin=n,this.outcome=new rv(o),this.formatter=new tI(t,n,o),this.formatter.setPromptRunContext({draftScopeId:i.id,choiceName:i.name})}captureResolvedOrderedHeading(){if(this.choice.insertAfter?.enabled&&this.choice.insertAfter.createIfNotFoundLocation===Aa){let t=this.formatter.getResolvedInsertAfterHeading();t&&(this.resolvedInsertAfterHeading=t)}}showSuccessNotice(t,{wasNewFile:n,action:i}){let o=`'${t.basename}'`;if(n){new tu.Notice(`Created and captured to ${o}`,iI);return}let s=this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWritePosition==="bottom",a="";switch(i){case"currentLine":a=`Captured to current line in ${o}`;break;case"newLineAbove":a=`Captured on a new line above cursor in ${o}`;break;case"newLineBelow":a=`Captured on a new line below cursor in ${o}`;break;case"activeFileTop":a=`Captured to top of ${o}`;break;case"prepend":case"append":a=s?`Captured to bottom of ${o}`:`Captured to top of ${o}`;break;case"insertAfter":{let l=this.resolvedInsertAfterHeading??this.choice.insertAfter.after;a=l?`Captured to ${o} under '${l}'`:`Captured to ${o}`;break}case"insertBefore":{let l=this.choice.insertBefore?.before;a=l?`Captured to ${o} before '${l}'`:`Captured to ${o}`;break}default:a=`Captured to ${o}`;break}new tu.Notice(a,iI)}showNothingToCaptureNotice(t,{wasNewFile:n}){let i=`'${t.basename}'`;new tu.Notice(n?`Created ${i} \u2014 nothing to capture (no content)`:`Nothing to capture \u2014 ${i} unchanged`,iI)}hasActiveMarkdownCaptureContext(){let t=!!this.app.workspace.getActiveFile(),n=!!Nn(this.app);return t&&n}shouldSkipRequiredCanvasLinkInsertion(t,n){return n&&t.destination?.type!=="specifiedFile"&&t.requireActiveFile&&!this.hasActiveMarkdownCaptureContext()}async insertCaptureLink(t,n,{isCanvasTriggered:i}){if(!n.enabled)return;if(n.destination?.type==="specifiedFile"){await GT(this.app,t,n);return}if(np(n.placement)){await sp(this.app,t,n);return}if(this.shouldSkipRequiredCanvasLinkInsertion(n,i)){this.plugin.settings.showCaptureNotification&&new tu.Notice("Canvas capture skipped link insertion because no Markdown editor is focused.",iI);return}let o=this.choiceExecutor.focusedProperty;if(o){await QT(this.app,o,t);return}await sp(this.app,t,n)}async copyCapturedFileLinkToClipboard(t){if(this.choice.copyLinkToClipboard)try{await YT(t)}catch(n){M.logWarning(`Could not copy link to clipboard for '${t.path}': ${n instanceof Error?n.message:String(n)}`)}}validateAppendLinkDestination(t){return!t.enabled||t.destination.type!=="specifiedFile"||Jv(this.app,t.destination)?!0:(this.failRun(`Append link target file not found or is not a Markdown file: ${t.destination.path}`),!1)}async run(){let t=!1;try{this.capturePropertyVars.clear();let n=Tu(this.choice.appendLink);if(this.formatter.setLinkToCurrentFileBehavior(n.enabled&&!n.requireActiveFile?"optional":"required"),!this.validateAppendLinkDestination(n))return;let i=this.choice.useSelectionAsCaptureValue,o=this.plugin.settings.useSelectionAsCaptureValue??!0,s=typeof i=="boolean"?i:o;this.formatter.setUseSelectionAsCaptureValue(s);let a=w7(this.choice),l=a==="currentLine"||a==="newLineAbove"||a==="newLineBelow",c=this.choice.captureToActiveFile?E7(this.app,a):null,u=await this.resolveConfiguredCanvasTarget(a),d=c??u;if(d?.kind==="text"){await this.handleCanvasTextCapture(d,a,n,()=>{t=!0});return}if(d?.kind==="file"&&(a==="insertAfter"&&this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation==="cursor"||a==="insertBefore"&&this.choice.insertBefore?.createIfNotFound&&this.choice.insertBefore?.createIfNotFoundLocation==="cursor"))throw new xe("Canvas file cards do not support creating missing line targets at cursor. Use top or bottom.");let f=d?.kind==="file"?d.source==="configured"?d.targetFile?.path??d.targetPath:d.targetFile.path:await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile);if(!d&&!this.choice.captureToActiveFile&&zr.test(f))throw new xe("Capture to a .canvas file requires a target canvas node id.");let p=this.getCaptureContent(),m,v=await this.fileExists(f);!v&&this.choice?.createFileIfItDoesntExist?.enabled&&bE(f),this.isInsertAfterHeadingMode()&&!zr.test(f)&&await this.maybeResolveInsertAfterHeading(await this.readNoteBodyForHeadingPicker(f,v));let g=!v&&!!this.choice?.createFileIfItDoesntExist?.enabled&&!this.choice?.createFileIfItDoesntExist?.createWithTemplate;if(this.suppressFrontmatterCollection=!g,this.suppressFrontmatterCollection&&Ibe(this.choice?.format?.format??"")&&M.logWarning("QuickAdd: {{VALUE:\u2026|multi}}, {{FILE:\u2026|multi}} and {{FIELD:\u2026|multi}} in this capture write comma-separated strings by default. Add |format:yaml, |format:markdown or |format:inline to choose the output explicitly."),v)m=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)m=((ce,O,G)=>this.onCreateFileIfItDoesntExist(ce,O,n));else throw new xe(`Target file missing: ${f}. Enable "Create file if it doesn't exist" or choose an existing file.`);let{file:y,newFileContent:w,captureContent:k,priorContent:C,cursorEndOffset:E,cursorPlacementSafe:x=!0}=await m(f,p),D=null,P=x,H=!1,U=kbe(k);if(this.captureResolvedOrderedHeading(),l)if(U)t=!0;else{let ce=await hc(this.app,k,y),O=!1;switch(a){case"currentLine":O=H0(ce,this.app);break;case"newLineAbove":O=G0(ce,this.app);break;case"newLineBelow":O=Y0(ce,this.app);break}if(!O){await this.cleanupCreatedClipboardAttachments(),this.failRun(`Capture "${this.choice.name}": no active Markdown editor to insert into.`);return}t=!0}else{await this.app.vault.modify(y,w),t=!0,this.choice.templater?.afterCapture==="wholeFile"&&(await ep(this.app,y),P=!1,H=!0);let ce=await this.applyCapturePropertyVars(y);ce&&(P=!1),ce&&(H=!0),D=P?w:null}let oe=l?U?"unchanged":"changed":v?w!==C||H?"changed":"unchanged":"created";if(this.outcome.success(y,oe),this.plugin.settings.showCaptureNotification&&(U?this.showNothingToCaptureNotice(y,{wasNewFile:!v}):this.showSuccessNotice(y,{wasNewFile:!v,action:a})),await this.copyCapturedFileLinkToClipboard(y),await this.insertCaptureLink(y,n,{isCanvasTriggered:!!d}),this.choice.openFile&&y){let ce=pn(this.choice.fileOpening),O=ce.focus??!0;ap(this.app,y,O)||await gc(this.app,y,{...ce,originLeaf:this.originLeaf}),!await Eu(this.app,y)&&P&&O&&D!==null&&typeof E=="number"&&K0(this.app,y,E,D)}}catch(n){if(t||await this.cleanupCreatedClipboardAttachments(),vd(n,{logPrefix:"Capture execution aborted",noticePrefix:"Capture execution aborted",defaultReason:"Capture aborted"})){this.choiceExecutor.signalAbort?.(n);return}Yi.getInstance().markExecutionScopeFailed(),this.outcome.failure(YD(n)),lt(n,`Error running capture choice "${this.choice.name}"`)}finally{t&&this.formatter.consumeCreatedClipboardAttachmentPaths()}}failRun(t){Yi.getInstance().markExecutionScopeFailed(),M.logError(t),this.outcome.failure(t)}async cleanupCreatedClipboardAttachments(){let t=this.formatter.consumeCreatedClipboardAttachmentPaths();for(let n of t)try{let i=this.app.vault.getAbstractFileByPath(n);i instanceof tu.TFile&&await this.app.fileManager.trashFile(i)}catch(i){M.logWarning(`QuickAdd: failed to clean up clipboard attachment '${n}': ${String(i)}`)}}async handleCanvasTextCapture(t,n,i,o){if(n==="currentLine"||n==="newLineAbove"||n==="newLineBelow")throw new xe("Canvas text cards support top, bottom, insert-after, and insert-before positions only.");if(n==="insertAfter"&&this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation==="cursor"||n==="insertBefore"&&this.choice.insertBefore?.createIfNotFound&&this.choice.insertBefore?.createIfNotFoundLocation==="cursor")throw new xe("Canvas text cards do not support creating missing line targets at cursor. Use top or bottom.");let s=t.canvasFile;this.formatter.setTitle(qg(s.basename)),this.formatter.setDestinationFile(s);let a=this.getCaptureContent(),l=_7(t);this.isInsertAfterHeadingMode()&&await this.maybeResolveInsertAfterHeading(l);let c=await this.formatter.formatContentWithFile(a,this.choice,l,s);this.captureResolvedOrderedHeading();let u=c===l;if(u||await A7(this.app,t,c),o(),this.outcome.success(s,u?"unchanged":"changed"),this.plugin.settings.showCaptureNotification&&(u?this.showNothingToCaptureNotice(s,{wasNewFile:!1}):this.showSuccessNotice(s,{wasNewFile:!1,action:n})),await this.copyCapturedFileLinkToClipboard(s),await this.insertCaptureLink(s,i,{isCanvasTriggered:!0}),this.choice.openFile&&s){let d=pn(this.choice.fileOpening),f=d.focus??!0;ap(this.app,s,f)||await gc(this.app,s,{...d,originLeaf:this.originLeaf}),await Eu(this.app,s)}}async resolveConfiguredCanvasTarget(t){if(this.choice.captureToActiveFile)return null;let n=this.choice.captureTo?.trim()??"",i=this.choice.captureToCanvasNodeId?.trim()??"";if(!n||!i)return null;let o=await this.formatFilePath(n);return zr.test(o)?await T7(this.app,o,i,t):null}assertInteractiveCaptureTarget(){if(this.choiceExecutor.interactive===!1)throw new xe(`'${this.choice.name}' needs to ask which note to capture into, but this run is non-interactive. Point "Capture to" at a specific file, or re-run with the ui flag.`)}async maybeResolveInsertAfterHeading(t){let n=this.choice.insertAfter;if(!n?.enabled||!n.promptHeading)return;let i=!!n.createIfNotFound,o=yf(t),s=eu(o),a=s.map(p=>o[p.line]),l=s.map(p=>`${" ".repeat(Math.max(0,p.level-1))}${p.text}`),c=s.map(p=>p.text),u="Choose a heading to insert under",d=String(await sa(this.choiceExecutor,{remote:p=>aa(p,{items:a.map((m,v)=>({value:m,title:l[v]??m})),placeholder:u,allowCustomInput:i,what:"the heading picker"}),headless:()=>{throw new xe(`'${this.choice.name}' needs to ask which heading to capture under, but this run is non-interactive. Turn off "Choose heading when capturing" and set a fixed heading, or re-run with the ui flag.`)},app:()=>ln.Suggest(this.app,l,a,{allowCustomValue:i,placeholder:u,emptyStateText:i?"No headings found \u2014 type a heading to create":"No headings found in the target note",customValueLabel:p=>`Insert after new line: ${p}`})}));Ri(!!d&&d.length>0,"No heading selected for capture."),this.formatter.setInsertAfterTargetOverride(d);let f=a.indexOf(d);this.resolvedInsertAfterHeading=f>=0?c[f]:d}isInsertAfterHeadingMode(){return!!this.choice.insertAfter?.enabled&&!!this.choice.insertAfter.promptHeading}async readNoteBodyForHeadingPicker(t,n){if(!n)return"";let i=this.app.vault.getAbstractFileByPath(t);return i instanceof tu.TFile?await this.app.vault.read(i):""}getCaptureContent(){let t;return this.choice.format.enabled?t=this.choice.format.format:t=Os,this.choice.task&&(t=`- [ ] ${t}
`),t}async getFormattedPathToCaptureTo(t){if(t){let a=this.app.workspace.getActiveFile();return Ri(a,"Cannot capture to active file - no active file."),a.path}let n=this.getPreselectedCaptureTargetPath();if(n!==void 0){let a=nI({isFolder:l=>lm(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(rI(l))instanceof tu.TFile},this.choice.captureTo??"",!1);if(a){let l=this.confinePreselectedToScope(a,n);if(l!==null)return this.normalizeCaptureFilePath(l)}}let i=this.choice.captureTo,o=await this.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(s.filter);case"property":return this.selectFileWithProperty(s.field,s.value,s.filter);case"folder":return this.selectFileInFolder(s.folder,!1);case"file":return this.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){let t=this.choiceExecutor?.variables?.get(Xd);return typeof t=="string"&&t.length>0?t:void 0}confinePreselectedToScope(t,n){let i=this.stripLeadingSlash(n);if(t.kind==="folder")return t.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))return i;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))return null;let a=new Set(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));return this.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":return cm(this.app,t.filter);case"property":return um(this.app,t.field,t.value,t.filter);case"tag":return oy(this.app,t.tag);case"folder":return ns(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){return b7(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>lm(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){let i=n.startsWith(t)?n:`${t}${n}`,o;try{o=li(i,"Capture target file path")}catch{return!1}let s=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}async selectFileInFolder(t,n){let i=t.endsWith("/")||n?t:`${t}/`,o=ns(this.app,i),s=this.choice.createFileIfItDoesntExist?.enabled??!1;Ri(s||o.length>0,`Folder ${i} is empty.`);let a=bf(o,wf(this.app)),l=a.map(v=>v.path),c=Ac(a,v=>this.app.metadataCache.getFileCache(v)),u=l.map((v,g)=>`${c[g]??v} ${v}`),d=new Set(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void 0,p=String(await sa(this.choiceExecutor,{remote:v=>aa(v,{items:l.map((g,y)=>({value:g,title:c[y]??g})),placeholder:f,allowCustomInput:s,what:"the capture-target picker"}),headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>ln.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void 0,renderItem:(v,g)=>IE(g,v,this.app),searchItems:u,allowCustomValue:s,customValueLabel:v=>`Create new note: ${v}`,valueExists:v=>d.has(v.toLowerCase())||this.captureTargetExists(i,v)})}));Ri(!!p&&p.length>0,"No file selected for capture.");let m=p.startsWith(`${i}`)?p:`${i}${p}`;return await this.formatFilePath(m)}async selectFileWithFilter(t){let n=cm(this.app,t);return this.selectFileFromSet(n,"No files matched the capture target filters.")}async selectFileWithProperty(t,n,i){let o=um(this.app,t,n,i),s=n!==void 0?`${t}=${n}`:t;return this.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){let i=t.trim();if(!i)return!1;let o;try{o=li(i,"Capture target file path")}catch{return!1}let s=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;let l=s.slice(s.lastIndexOf("/")+1);return n.has(l.toLowerCase())}async selectFileFromSet(t,n){let i=this.choice.createFileIfItDoesntExist?.enabled??!1;Ri(i||t.length>0,n);let o=bf(t,wf(this.app)),s=o.map(m=>m.path),a=Ac(o,m=>this.app.metadataCache.getFileCache(m)),l=s.map((m,v)=>`${a[v]??m} ${m}`),c=new Set(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCase())),u=new Set(a.map(m=>m.toLowerCase())),d=m=>u.has(m.toLowerCase())||this.captureTargetAlreadyExists(m,c),f=i?"Choose a note or type to create one":void 0,p=String(await sa(this.choiceExecutor,{remote:async m=>{let v=await aa(m,{items:s.map((g,y)=>({value:g,title:a[y]??g})),placeholder:f,allowCustomInput:i,what:"the capture-target picker"});if(!s.includes(v)&&d(v))throw new Error(`"${v}" already exists but is not one of the notes this capture targets. Pick one of the offered notes, or type a name that does not exist yet.`);return v},headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>ln.Suggest(this.app,a,s,{placeholder:f,emptyStateText:i?"Type a note name to create it":void 0,renderItem:(m,v)=>IE(v,m,this.app),searchItems:l,allowCustomValue:i,customValueLabel:m=>`Create new note: ${m}`,valueExists:d})}));return Ri(!!p&&p.length>0,"No file selected for capture."),await this.formatFilePath(p)}async onFileExists(t,n){let i=this.getFileByPath(t);if(!i)throw new Error("File not found");this.formatter.setTitle(i.basename),this.formatter.setDestinationFile(i);let o=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let s=await this.app.vault.read(i),a=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(o,this.choice,s,i));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let l=this.formatter.getCaptureInsertionEndOffset(),c=await this.app.vault.read(i),u=a,d=!0;if(c!==s){let f=n7(c,s,a);Ri(f.isSuccess(),()=>`The file ${t} has been modified since the last read.
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
This is in order to prevent data loss.`),u=f.joinedResults(),d=!1}return{file:i,newFileContent:u,captureContent:o,priorContent:c,cursorEndOffset:l??void 0,cursorPlacementSafe:d}}async onCreateFileIfItDoesntExist(t,n,i){bE(t);let o=qg(t);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(t);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let f=new wE(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&f.setLinkToCurrentFileBehavior("optional"),f.setTargetFolderPath(zo(t)),f.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:t,destinationKind:"file"}),a=await f.run();let p=f.getAndClearTemplatePropertyVars();M.logMessage(`CaptureChoiceEngine: Collected ${p.size} template property variables`),p.size>0&&M.logMessage(`Variables: ${Array.from(p.keys()).join(", ")}`),this.templatePropertyVars=p}let l=await this.createFileWithInput(t,a,{suppressTemplaterOnCreate:this.choice.createFileIfItDoesntExist.createWithTemplate});this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&Vg(l,this.templatePropertyVars)&&await Ug(this.app,l,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&a?await ep(this.app,l):Xv(this.app)&&await q0(this.app,l);let c=await this.app.vault.read(l),u=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,c,l));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let d=this.formatter.getCaptureInsertionEndOffset();return{file:l,newFileContent:u,captureContent:s,priorContent:c,cursorEndOffset:d??void 0,cursorPlacementSafe:!0}}async formatFilePath(t){let n=await this.formatter.formatFileName(t,"captureTarget");return this.normalizeCaptureFilePath(n)}normalizeCaptureFilePath(t){let n=li(this.stripLeadingSlash(t),"Capture target file path");if(qi.test(n))throw new xe(`Capture to '.base' files is not supported (${n}). Use a Template choice instead.`);let i=this.normalizeCaptureFilePathExtension(n);if(!qg(i).trim())throw new xe(`Capture target file name is empty after formatting ('${i}'). Make sure the tokens in 'Capture to' produce a value.`);if(Un(i))throw new xe(`Refusing to capture to a file outside the vault: "${i}".`);return i}normalizeCaptureFilePathExtension(t){let n=t.match(ir)?.[0];if(n)return`${li(t.replace(ir,""),"Capture target file path")}${n}`;let i=t.match(zr)?.[0];return i?`${li(t.replace(zr,""),"Capture target file path")}${i}`:this.normalizeMarkdownFilePath("",t)}collectIfFrontmatter(t){return this.suppressFrontmatterCollection?t():this.formatter.withTemplatePropertyCollection(t)}mergeCapturePropertyVars(t){if(!(!t||t.size===0)){for(let[n,i]of t)this.capturePropertyVars.set(n,i);M.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(t){return this.capturePropertyVars.size===0?!1:Vg(t,this.capturePropertyVars)?(M.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await Ug(this.app,t,this.capturePropertyVars),this.capturePropertyVars.clear(),!0):(this.capturePropertyVars.clear(),!1)}};vE();var Es=require("obsidian");Mo();Cr();Hr();Pt();Wt();sm();var YN=require("obsidian");_t();Hc();qt();Cr();function k7(r){let e=r.split("/").pop()??r,t=e.lastIndexOf(".");return t>0?e.slice(0,t):e}function KN(r){let e=new od(k7(r));return e.id=`folder-template:${r}`,e.templatePath=r,e.openFile=!0,e.fileNameFormat={enabled:!0,format:Os},e.discoverExistingNotesBeforeCreate=!0,e}function QN(r){return zi(r.settings.templateFolderPaths).length>0}function Pbe(r,e){let t=r.lastIndexOf("/"),n=t===-1?"":r.slice(0,t),i=e.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text:k7(r)}),n&&(e.classList.add("mod-complex"),i.createDiv({cls:"suggestion-note",text:n}))}async function Fbe(r,e){let n=[...e].sort((i,o)=>i.path.localeCompare(o.path)).map(i=>i.path);try{return await Lr.Suggest(r,n,n,"New note from template",(i,o)=>Pbe(i,o))}catch(i){if(It(i))return null;throw i}}async function sI(r,e,t){try{let n=t.templatePath?.trim()||void 0;if(!n){if(!QN(e)){new YN.Notice("QuickAdd: Set a template folder in Settings \u2192 QuickAdd \u2192 Templates & properties to use \u201CNew note from template\u201D.",8e3),bg(r,e.manifest.id,{notice:!1});return}let i=e.getTemplateFiles();if(i.length===0){new YN.Notice("QuickAdd: No template files found in your configured template folder(s).");return}let o=await Fbe(r,i);if(!o)return;n=o}await t.choiceExecutor.execute(KN(n))}catch(n){if(It(n))return;lt(n,"Error running template from folder")}}Wt();ka();var Mbe="\u2190 Back",Rbe="Select a choice";function NE(r){return js(r)?`QuickAdd couldn't read the contents of "${r.name}". They're still in data.json.`:`Folder "${r.name}" is empty.`}var $be="Empty",Obe="Unreadable";function Nbe(r){return XN(r)?js(r)?Obe:$be:""}var OE="quickadd:run-template-from-folder",Lbe="New note from template\u2026",sv="quickadd:back";function XN(r){return r.type==="Multi"&&r.id!==sv&&st(r).length===0}var Bbe=.5;function Vbe(r){return r.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g,"$2").replace(/\[\[([^\]]+)\]\]/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__)(.+?)\1/g,"$2").replace(/\*(.+?)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/~~(.+?)~~/g,"$1")}function ZN(r){return(r.settings.templateFolderLauncherRow??"bottom")!=="off"&&QN(r)}function Ube(){return{id:OE,name:Lbe,type:"Template",command:!1}}var Ef=class r extends Es.FuzzySuggestModal{constructor(t,n,i){super(t.app);this.plugin=t;this.choices=n;this.focusedProperty=null;this.triggerContext=null;this.placeholderStack=[];this.selectionDispatched=!1;this.breadcrumbById=new Map;this.markdownComponent=new Es.Component;this.warnRenderFailure=bp("Could not render a choice name as Markdown; showing it as plain text");if(this.choiceExecutor=i?.choiceExecutor??new $i(this.app,this.plugin),this.focusedProperty=i&&"focusedProperty"in i?i.focusedProperty??null:KT(this.app),this.triggerContext=i&&"triggerContext"in i?i.triggerContext??null:{activeFile:this.app.workspace.getActiveFile()},this.placeholderStack=i?.placeholderStack??[],this.completion=i?.completion,this.currentPlaceholder=i?.placeholder?.trim()||Rbe,this.setPlaceholder(this.currentPlaceholder),this.markdownComponent.load(),i?.includeTemplateFolderRow){let o=this.plugin.settings.templateFolderLauncherRow??"bottom";if(ZN(this.plugin)){let s=Ube();this.choices=o==="top"?[s,...this.choices]:[...this.choices,s]}}}static Open(t,n,i){new r(t,n,i).open()}onClose(){super.onClose(),this.markdownComponent.unload(),this.completion&&!this.selectionDispatched&&this.completion(rn())}getSuggestions(t){let n=t.trim();if(!n||!le.getState().searchNestedChoices)return super.getSuggestions(n);let i=(0,Es.prepareFuzzySearch)(n),o=[];for(let s of this.getNestedSearchCandidates()){let a=i(s.text);a&&(s.nameOffset>0&&a.matches.length>0&&a.matches.every(([,l])=>l<=s.nameOffset)&&(a.score-=Bbe),o.push({item:s.choice,match:a}))}return o.sort((s,a)=>a.match.score-s.match.score),o}getNestedSearchCandidates(){if(!this.nestedSearchCandidates){let t=this.choices.filter(n=>n.id!==sv&&n.id!==OE);this.nestedSearchCandidates=vy(t).map(({choice:n,path:i})=>{let o=i.slice(0,-1);o.length>0&&this.breadcrumbById.set(n.id,o.map(Vbe).join(" / "));let s=i.join(" / ");return{choice:n,text:s,nameOffset:s.length-n.name.length}})}return this.nestedSearchCandidates}selectSuggestion(t,n){if(XN(t.item)){if("repeat"in n&&n.repeat)return;new Es.Notice(NE(t.item)),this.inputEl.focus();return}this.selectionDispatched=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){n.empty(),n.classList.remove("mod-complex");let i=this.breadcrumbById.get(t.item.id),o=n.createDiv({cls:"quickadd-choice-suggestion-content"});this.renderChoiceIcon(t.item,o);let s;if(i){n.classList.add("mod-complex");let c=o.createDiv({cls:"suggestion-content quickadd-choice-suggestion-text"});s=c.createDiv({cls:"suggestion-title"}),c.createDiv({cls:"suggestion-note",text:i})}else s=o.createDiv({cls:"quickadd-choice-suggestion-title quickadd-choice-suggestion-text"});Es.MarkdownRenderer.render(this.app,t.item.name,s,"",this.markdownComponent).catch(c=>{s.textContent=t.item.name,this.warnRenderFailure(c)}),n.classList.add("quickadd-choice-suggestion"),t.item.id===sv&&n.classList.add("quickadd-choice-suggestion-back"),t.item.id===OE&&n.classList.add("quickadd-choice-suggestion-run-template");let a=Nbe(t.item),l=a!=="";if(n.classList.toggle("quickadd-choice-suggestion-empty",l),l){n.setAttribute("aria-disabled","true");let c=xr(o,"span");c.classList.add("quickadd-choice-suggestion-empty-flair"),c.textContent=a,o.appendChild(c)}else n.removeAttribute("aria-disabled")}renderChoiceIcon(t,n){let i=this.getChoiceSuggestionIcon(t);if(!i)return;let o=xr(n,"span");o.classList.add("quickadd-choice-icon"),o.setAttribute("aria-hidden","true"),n.appendChild(o),(0,Es.setIcon)(o,i)}getChoiceSuggestionIcon(t){if(t.id!==sv)return t.id===OE?"file-plus":Em(t)}getItemText(t){return t.name}getItems(){return this.choices}settleCompletion(t,n){t.then(()=>this.completion?.(),i=>{rm(i,n),this.completion?.(i)})}onChooseItem(t,n){if(t.id===OE){this.settleCompletion(sI(this.app,this.plugin,{choiceExecutor:this.choiceExecutor}),"Could not run a template from that folder");return}if(t.type==="Multi")this.onChooseMultiType(t);else{let i=this.choiceExecutor.executeWithFocusedProperty?this.choiceExecutor.executeWithFocusedProperty(t,this.focusedProperty,this.triggerContext):this.choiceExecutor.execute(t);this.settleCompletion(i,`Could not run "${t.name}"`)}}onChooseMultiType(t){let n=t.id===sv;if(!n&&XN(t)){new Es.Notice(NE(t)),this.completion?.();return}let i=[...st(t)];if(!n){let a=new cg(Mbe).addChoices(this.choices);a.id=sv,i.push(a)}let o=n?this.placeholderStack[this.placeholderStack.length-1]:t.placeholder?.trim()||t.name,s=n?this.placeholderStack.slice(0,-1):[...this.placeholderStack,this.currentPlaceholder];r.Open(this.plugin,i,{choiceExecutor:this.choiceExecutor,focusedProperty:this.focusedProperty,triggerContext:this.triggerContext,placeholder:o,placeholderStack:s,completion:this.completion})}};Pt();_t();Bs();Me();DN();Gs();vF();var S7=require("obsidian");vl();Vm();_t();Kr();Pi();qt();Me();n_();Gs();xl();_t();Vm();Py();hh();xl();qy();cp();Nu();lN();Gs();var LE=class extends El{constructor(t,n,i){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.requirements=new Map;this.templatesToScan=new Set;this.scannedTemplateRefDepths=new Map;this.scanningPathContext=!1;this.scanningScope="generic";this.scanningSoleValue=!1;this.dateParser=Sl,i&&(this.variables=new Map(i.variables))}warn(){}reportProblem(){}async scanString(t,n=!1,i="generic"){let o=this.scanningPathContext,s=this.scanningScope,a=this.scanningSoleValue;this.scanningPathContext=n,this.scanningScope=i,this.scanningSoleValue=G_(i,t);try{let l=await this.replaceGlobalVarInString(t);if(this.scanVariableTokens(l),this.scanDateTokens(l),this.scanFileTokens(l),n){if(new RegExp(fc.source,"i").test(l)){let c=this.requirements.get("value");c&&(c.pathContext=!0)}if(new RegExp(VT.source,"i").test(l)){let c=this.requirements.get("mvalue");c&&(c.pathContext=!0)}}await this.format(l)}finally{this.scanningPathContext=o,this.scanningScope=s,this.scanningSoleValue=a}}markScanContext(t){this.scanningPathContext&&(t.pathContext=!0)}async format(t){let n=t;n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n);{let i=new RegExp(Ns.source,"gi"),o;for(;(o=i.exec(n))!==null;){let s=o[1];s&&this.templatesToScan.add(s)}}return n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(gl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}scanVariableTokens(t){let n=new RegExp(Kd.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=(i[1]??"").trim();if(!o)continue;let s=Vy(o,{warn:this.warnSink});if(!s)continue;let{variableName:a,variableKey:l,label:c,defaultValue:u,displayValues:d,hasOptions:f}=s;if(!a)continue;let p=f&&c?c:a,m=!f&&c?c:void 0,v=l;if(this.requirements.has(v)){let g=this.requirements.get(v);if(this.markScanContext(g),f&&!this.hasOptionList(g)&&(g.type=this.optionFieldType(s),g.label=p,this.applyOptionFields(g,s),g.defaultValue!==void 0&&!s.allowCustomInput)){let y=wF(g.defaultValue);g.defaultValue=s.suggestedValues.includes(y)?y:void 0}u&&g.defaultValue===void 0&&(g.defaultValue=u),!g.displayOptions&&d&&(g.displayOptions=d),g.optional=(g.optional??!1)&&s.optional}else{let g=!f&&s.inputTypeOverride==="checkbox",y=!f&&s.inputTypeOverride==="number",w=!f&&s.inputTypeOverride==="slider",k=s.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",C={id:v,label:p,type:f?this.optionFieldType(s):g?"dropdown":y?"number":w?"slider":k,description:m,optional:s.optional};f?this.applyOptionFields(C,s):g?C.options=["true","false"]:y?C.numericConfig=s.numericConfig:w&&(C.numericConfig=s.numericConfig,C.sliderConfig=s.sliderConfig),u&&(C.defaultValue=u),this.markScanContext(C),this.requirements.set(v,C)}}}optionFieldType(t){return t.allowCustomInput||t.multiSelect?"suggester":"dropdown"}hasOptionList(t){return Array.isArray(t.options)&&t.options.length>0}applyOptionFields(t,n){t.options=n.suggestedValues,n.displayValues&&(t.displayOptions=n.displayValues),n.multiSelect?t.multiEmit=n.multiEmit??"text":delete t.multiEmit,n.allowCustomInput||n.multiSelect?t.suggesterConfig={allowCustomInput:n.allowCustomInput,caseSensitive:!1,multiSelect:n.multiSelect??!1}:delete t.suggesterConfig}scanDateTokens(t){let n=new RegExp(bu.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=i[1]?.trim();if(!o)continue;let{defaultValue:s,optional:a,withTime:l}=Uy(i[3]),c=i[2]?.trim()||(l?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"),u=this.requirements.get(o);u?(u.type==="date"&&s&&u.defaultValue===void 0&&(u.defaultValue=s),u.optional=(u.optional??!1)&&a,u.type==="date"&&l&&!u.withTime&&(u.withTime=!0,i[2]?.trim()||(u.dateFormat="YYYY-MM-DD HH:mm"))):this.requirements.set(o,{id:o,label:o,type:"date",defaultValue:s,dateFormat:c,withTime:l,optional:a,source:"collected"})}}async promptForValue(t){let n="value";if(!this.requirements.has(n)){let i=this.valuePromptContext?.inputTypeOverride==="checkbox",o=this.valuePromptContext?.inputTypeOverride==="number",s=this.valuePromptContext?.inputTypeOverride==="slider",a=K_(this.scanningScope,this.scanningSoleValue);this.requirements.set(n,{id:n,label:a.title||t||"Enter value",type:i?"dropdown":o?"number":s?"slider":this.valuePromptContext?.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",description:this.valuePromptContext?.description,placeholder:a.placeholder,defaultValue:this.valuePromptContext?.defaultValue,numericConfig:this.valuePromptContext?.numericConfig,sliderConfig:this.valuePromptContext?.sliderConfig,options:i?["true","false"]:void 0,source:"collected",optional:this.valuePromptContext?.optional})}return this.markScanContext(this.requirements.get(n)),""}async promptForVariable(t,n){if(!t)return"";let i=n?.variableKey??t;if(n?.type==="VDATE")return n.defaultValue??"@date:1970-01-01T00:00:00.000Z";if(!this.requirements.has(i)){let o=Ny(t).map(f=>f.trim()).filter(Boolean),s=o.length>1,a=!s&&n?.inputTypeOverride==="number",l=!s&&n?.inputTypeOverride==="slider",c=!s&&n?.inputTypeOverride==="checkbox",u=n?.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",d={id:i,label:t,type:s||c?"dropdown":a?"number":l?"slider":u,description:n?.description,numericConfig:n?.numericConfig,sliderConfig:n?.sliderConfig,source:"collected"};s?d.options=o:c&&(d.options=["true","false"]),n?.defaultValue&&(d.defaultValue=n.defaultValue),this.requirements.set(i,d)}return this.markScanContext(this.requirements.get(i)),n?.defaultValue??""}async promptForMathValue(){let t="mvalue";return this.requirements.has(t)||this.requirements.set(t,{id:t,label:"Math expression",type:"text",placeholder:"e.g., 2+2*3"}),this.markScanContext(this.requirements.get(t)),""}async suggestForField(t){let n=Ki.parse(t),i=`${Qd}${t}`;if(!this.requirements.has(i)){let o={id:i,label:n.fieldName||t,type:"field-suggest",source:"collected",runtimeOnly:n.multiSelect};if(!n.multiSelect&&n.filters.defaultFrom==="active"){let s=TD(this.app,this.choiceExecutor?.triggerContext?.activeFile??null,n.fieldName),a=(typeof s=="string"?s:void 0)??n.filters.defaultValue;a!==void 0&&(o.defaultValue=a)}this.requirements.set(i,o)}return""}scanFileTokens(t){let n=new RegExp(BT.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=j_(i[1]??"");o&&this.recordFileRequirement(o)}}recordFileRequirement(t){let n=t.variableKey,i=this.requirements.get(n);if(i){i.optional=(i.optional??!1)&&t.optional,i.type="file-picker",i.suggesterConfig={allowCustomInput:(i.suggesterConfig?.allowCustomInput??!1)||t.allowCustomInput,caseSensitive:!1,multiSelect:(i.suggesterConfig?.multiSelect??!1)||t.multiSelect};return}let o=Hi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,u=>this.app.metadataCache.getFileCache(u)),s=o.map(u=>`${Cl}${u.path}`),a=Ac(o,u=>this.app.metadataCache.getFileCache(u)),l=t.allowCustomInput||s.length===0,c=t.mode==="name"?`File from ${t.folderPath}`:`File from ${t.folderPath} (${t.mode})`;this.requirements.set(n,{id:n,label:t.label??c,type:"file-picker",source:"collected",options:s,displayOptions:a,optional:t.optional,suggesterConfig:{allowCustomInput:l,caseSensitive:!1,multiSelect:t.multiSelect}})}suggestForFile(t){return""}async suggestForValue(t,n,i){return""}getVariableValue(t){return""}async getTemplateContent(t){return""}async getSelectedText(){return""}async getClipboardContent(){return""}getCurrentFileLink(){return null}getCurrentFileName(){return null}async getMacroValue(t,n){return""}isTemplatePropertyTypesEnabled(){return!1}};Py();var qbe=["text","number","textarea","dropdown","slider","date","field-suggest","file-picker","suggester"];function Wbe(r){return typeof r=="string"&&qbe.includes(r)}function zbe(r){if(!r||typeof r!="object")return null;let e=r,t=e.id,n=e.type;if(typeof t!="string"||!Wbe(n))return null;let i=Hbe(e.numericConfig),o=jbe(e.sliderConfig),s=n==="slider"&&!o?"number":n;return{id:t,label:typeof e.label=="string"?e.label:t,type:s,placeholder:typeof e.placeholder=="string"?e.placeholder:void 0,defaultValue:typeof e.defaultValue=="string"?e.defaultValue:void 0,numericConfig:o??i,sliderConfig:o,options:Array.isArray(e.options)?e.options.filter(a=>typeof a=="string"):void 0,dateFormat:typeof e.dateFormat=="string"?e.dateFormat:void 0,description:typeof e.description=="string"?e.description:void 0,optional:typeof e.optional=="boolean"?e.optional:void 0,source:"script"}}function Hbe(r){if(!r||typeof r!="object")return;let e=r,t=typeof e.min=="number"&&Number.isFinite(e.min)?e.min:void 0,n=typeof e.max=="number"&&Number.isFinite(e.max)?e.max:void 0,i=typeof e.step=="number"&&Number.isFinite(e.step)&&e.step>0?e.step:void 0;if(t!==void 0&&n!==void 0&&n<t)return i===void 0?void 0:{step:i};let o={};return t!==void 0&&(o.min=t),n!==void 0&&(o.max=n),i!==void 0&&(o.step=i),Object.keys(o).length>0?o:void 0}function jbe(r){if(!r||typeof r!="object")return;let e=r,t=typeof e.min=="number"?e.min:void 0,n=typeof e.max=="number"?e.max:void 0,i=e.step===void 0?1:typeof e.step=="number"?e.step:void 0;if(!(t===void 0||n===void 0||i===void 0||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(i)||n<=t||i<=0))return{min:t,max:n,step:i}}function Gbe(r){let e=t=>{if(!t||typeof t!="object"&&typeof t!="function")return[];let n=t.quickadd;if(!n||typeof n!="object")return[];let i=n.inputs;return Array.isArray(i)?i:[]};return e(r)}async function D7(r,e){let t=mo(r,e);return t?await r.vault.cachedRead(t):""}function Ybe(r){let e=new Set,t=new RegExp(Ns.source,"gi"),n;for(;(n=t.exec(r))!==null;)n[1]&&e.add(n[1]);return e}async function Cd(r,e,t,n=new Set,i=0,o="generic"){let s=Y_(o),a=Ybe(t);e.templatesToScan.clear(),await e.scanString(t,s,o);let l=[...e.templatesToScan].filter(c=>a.has(c));if(e.templatesToScan.clear(),!(i>=uA))for(let c of l){if(n.has(c))continue;let u=`${s?"path":"content"}:${c}`,d=e.scannedTemplateRefDepths.get(u);if(!(d!==void 0&&d<=i)){e.scannedTemplateRefDepths.set(u,i),n.add(c);try{await Cd(r,e,await D7(r,c),n,i+1,o)}finally{n.delete(c)}}}}async function I7(r,e,t){if(await e.scanString(t,!0,"templatePath"),ku(t)){M.logMessage(`Preflight: template path "${t}" uses format syntax; its body's prompts are collected at run time, not in the one-page form.`);return}await Cd(r,e,await D7(r,t),new Set([t]),0,"noteBody")}async function Kbe(r,e,t,n){let i=new LE(r,e,t);if(n.fileNameFormat?.enabled&&await Cd(r,i,n.fileNameFormat.format,void 0,0,"noteTitle"),n.folder?.enabled)for(let o of n.folder.folders??[])await Cd(r,i,o,void 0,0,"folder");return n.templatePath&&await I7(r,i,n.templatePath),i}async function Qbe(r,e,t,n,i){let o=new LE(r,e,t);await Cd(r,o,n.captureTo,void 0,0,"captureTarget"),n.format?.enabled&&await Cd(r,o,n.format.format,void 0,0,"captureText"),n.insertAfter?.enabled&&!n.insertAfter.promptHeading&&await Cd(r,o,n.insertAfter.after,void 0,0,"lineTarget"),n.insertBefore?.enabled&&await Cd(r,o,n.insertBefore.before,void 0,0,"lineTarget");let s=n.createFileIfItDoesntExist;s?.enabled&&s.createWithTemplate&&s.template&&await I7(r,o,s.template);let a=nI({isFolder:l=>lm(r,l),markdownFileExists:l=>r.vault.getAbstractFileByPath(rI(l))instanceof S7.TFile},n.captureTo??"",n.captureToActiveFile);if(a){let l=[];switch(a.kind){case"property":l=um(r,a.field,a.value,a.filter);break;case"filter":l=cm(r,a.filter);break;case"tag":l=oy(r,a.tag);break;case"folder":l=ns(r,a.folderPathSlash);break}let c=bf(l,wf(r)),u=c.map(p=>p.path),d=Ac(c,p=>r.metadataCache?.getFileCache(p)??null),f=n.createFileIfItDoesntExist?.enabled??!1;u.length===0&&f?o.requirements.set(Xd,{id:Xd,label:"Select capture target file",type:"file-picker",source:"collected",options:u,displayOptions:d,runtimeOnly:!0,placeholder:"Type a new note name in the capture target picker"}):o.requirements.set(Xd,{id:Xd,label:"Select capture target file",type:"dropdown",options:u,displayOptions:d,placeholder:u.length?void 0:"No files found in target scope"})}if(i){let l=n.useSelectionAsCaptureValue,c=e.settings.useSelectionAsCaptureValue??!0;if(typeof l=="boolean"?l:c){let d=t.variables.get("value");if(d==null){let f=tp(r);f.trim().length>0&&t.variables.set("value",f)}}}return o}async function Xbe(r,e,t){let n=[],i=Ir(e?.macro?.commands);for(let o of i){if(o?.type!=="UserScript")continue;let s=o;try{let a=r_(s),l=a!==void 0?t?.get(a):void 0;l===void 0&&(l=await Sa(s,r,{reportLoadErrors:!1}),a!==void 0&&l!==void 0&&t?.set(a,l));let c=Gbe(l);for(let u of c){let d=zbe(u);d&&n.push(d)}}catch(a){let l=s.path??s.id,c=a instanceof Error?a.message:String(a);if(aV(a)){M.logMessage(`QuickAdd preflight could not inspect user script '${l}': ${c}`);continue}M.logWarning(`Preflight could not inspect user script '${l}': ${c}`)}}return n}async function BE(r,e,t,n,i){let o=null,s=[];if(n.type==="Template")o=await Kbe(r,e,t,n);else if(n.type==="Capture")o=await Qbe(r,e,t,n,i?.seedCaptureSelectionAsValue??!1);else if(n.type==="Macro")s=await Xbe(r,n,i?.preloadedUserScripts);else return[];let a=new Map;for(let l of o?Array.from(o.requirements.values()):[])a.set(l.id,l);for(let l of s)a.has(l.id)||a.set(l.id,l);return Array.from(a.values())}function VE(r,e){return r.filter(t=>{let n=lA(e,t.id);return n?e.get(n)==null:!0})}function P7(r,e){let t=r.trim();if(!t)return[];let n=Array.from(e.keys()).sort((s,a)=>a.length-s.length),i=[],o=t;for(;o.length>0;){let s=n.find(a=>o===a||o.startsWith(`${a}, `));if(!s)break;i.push(s),o=o===s?"":o.slice(s.length+2)}if(o.length>0)for(let s of o.split(",")){let a=s.trim();a&&i.push(a)}return i}function Zbe(r,e,t){let n=r.filter(o=>t||e.includes(o)),i=new Set(n);return[...e.filter(o=>i.has(o)),...n.filter((o,s)=>!e.includes(o)&&n.indexOf(o)===s)]}function Jbe(r,e){if(r.type!=="Template"||e!=="value")return!1;let t=r,n=t.fileNameFormat?.enabled?t.fileNameFormat.format:Os;return u$(t,n)}async function F7(r,e,t,n){try{let i=await BE(r,e,t,n,{seedCaptureSelectionAsValue:!0,preloadedUserScripts:t.preloadedUserScripts});if(i.length===0)return!1;let o=VE(i,t.variables);if(o.length===0)return!1;let s=o.filter(p=>!p.runtimeOnly&&!Jbe(n,p.id));if(s.length===0)return!1;let a=async p=>{try{let m=new wh(r,e),v=[];if(n.type==="Template"){let g=n;if(g.fileNameFormat?.enabled){m.setTargetFolderPath(sk(g.folder)??"Folder/Name");for(let[y,w]of Object.entries(p))m.variables.set(y,w);v.push({label:"File name",text:await m.format(g.fileNameFormat.format),diagnostics:m.diagnostics.list()})}}return v}catch{return[]}},l=t.promptProvider,c=null,u;l?u=await l.requestInputs(s):(c=new Qg(r,s,t.variables,a),u=await c.waitForClose);let d=new Map,f=new Map;for(let p of s){if(p.id.startsWith(Dy)){let m=p.options??[],v=p.displayOptions??m;d.set(p.id,{options:m,displayToValue:new Map(m.map((g,y)=>[(v[y]??g).trim(),g])),allowCustom:p.suggesterConfig?.allowCustomInput??!1,multiSelect:p.suggesterConfig?.multiSelect??!1})}if(p.suggesterConfig?.multiSelect&&!p.id.startsWith(Dy)){let m=p.options??[],v=p.displayOptions??m,g=new Map;m.forEach((y,w)=>{g.set((v[w]??y).trim(),y)}),f.set(p.id,{emit:p.multiEmit??"text",allowCustom:p.suggesterConfig.allowCustomInput??!1,displayToValue:g})}}return Object.entries(u).forEach(([p,m])=>{let v=d.get(p);if(v!==void 0){let w=c?.fileSelections.get(p)??(Array.isArray(m)?m.map(String):void 0)??(v.multiSelect?P7(String(m),v.displayToValue).map(E=>v.displayToValue.get(E)??E):[String(m)]),C=Zbe(w,v.options,v.allowCustom).map(E=>iq(E,v.options));t.variables.set(p,v.multiSelect?C:C[0]??"");return}let g=f.get(p);if(g!==void 0){let w=(c?.multiSelections.get(p)??P7(String(m),g.displayToValue)).filter(k=>g.allowCustom||g.displayToValue.has(k)).map(k=>g.displayToValue.get(k)??k);t.variables.set(p,g.emit==="linklist"?w.map(oA):w);return}t.variables.set(p,m)}),!0}catch(i){if(i instanceof Nt)throw i;return t.promptProvider||M.logWarning(`One-page input failed for choice "${n.name}"; falling back to step-by-step prompts: ${i instanceof Error?i.message:String(i)}`),!1}}Bs();xo();Hr();Cr();qt();km();sm();Wt();var $i=class{constructor(e,t){this.app=e;this.plugin=t;this.variables=new Map;this.interactive=!0;this.preloadedUserScripts=new Map;this.focusedProperty=null;this.triggerContext=null;this.pendingAbort=null;this.pendingResult=null;this.executionDepth=0}signalAbort(e){this.pendingAbort=e}consumeAbortSignal(){let e=this.pendingAbort;return this.pendingAbort=null,e??null}recordExecutionResult(e){this.pendingResult=e}beginExecutionContext(){this.executionDepth===0&&(this.focusedProperty=this.focusedPropertyOverride!==void 0?this.focusedPropertyOverride:KT(this.app),this.triggerContext=this.triggerContextOverride!==void 0?this.triggerContextOverride:{activeFile:this.app.workspace.getActiveFile()}),this.executionDepth++}endExecutionContext(){this.executionDepth=Math.max(0,this.executionDepth-1),this.executionDepth===0&&(this.focusedProperty=null,this.triggerContext=null,this.preloadedUserScripts.clear())}async execute(e){this.pendingAbort=null;let t=this.pendingResult;this.beginExecutionContext();let n=ny(this.app),i=Yi.getInstance();i.beginExecutionScope();try{switch(await this.runOnePagePreflightIfEnabled(e),e.type){case"Template":{let o=e;await this.onChooseTemplateType(o,n);break}case"Capture":{let o=e;await this.onChooseCaptureType(o,n);break}case"Macro":{let o=e;await this.onChooseMacroType(o,n);break}case"Multi":{let o=e;await this.onChooseMultiType(o);break}default:break}if(this.pendingAbort){i.rollbackExecutionScope();return}i.commitExecutionScope()}catch(o){throw i.rollbackExecutionScope(),o}finally{this.pendingResult=t,this.endExecutionContext()}}async executeWithFocusedProperty(e,t,n){let i=this.focusedPropertyOverride,o=this.triggerContextOverride;this.focusedPropertyOverride=t,this.triggerContextOverride=n;try{await this.execute(e)}finally{this.focusedPropertyOverride=i,this.triggerContextOverride=o}}async executeWithOutcome(e){this.pendingAbort=null,this.pendingResult=null,this.beginExecutionContext();let t=ny(this.app),n=Yi.getInstance();n.beginExecutionScope();try{if(await this.runOnePagePreflightIfEnabled(e),e.type==="Template"?await this.onChooseTemplateType(e,t):await this.onChooseCaptureType(e,t),this.pendingAbort){n.rollbackExecutionScope();let o=this.consumeAbortSignal(),s=o instanceof Dt;return{status:"cancelled",cancelKind:s?"user":"aborted",reason:s?void 0:o?.message}}n.commitExecutionScope();let i=this.pendingResult;return this.pendingResult=null,i??{status:"error"}}catch(i){return n.rollbackExecutionScope(),i instanceof Dt?{status:"cancelled",cancelKind:"user"}:i instanceof Nt?{status:"cancelled",cancelKind:"aborted",reason:i.message}:(lt(i,"Error executing choice from URI"),{status:"error",reason:i instanceof Error?i.message:String(i)})}finally{this.endExecutionContext()}}async runOnePagePreflightIfEnabled(e){let t=le.getState().onePageInputEnabled,n=e.onePageInput,i=this.promptProvider!=null;if((n==="always"||n!=="never"&&(t||i))&&(e.type==="Template"||e.type==="Capture"||e.type==="Macro"))try{await F7(this.app,this.plugin,this,e)}catch(s){throw It(s)?new Dt("One-page input cancelled by user"):s}}async onChooseTemplateType(e,t){await new KD(this.app,this.plugin,e,this,t).run()}async onChooseCaptureType(e,t){await new oI(this.app,this.plugin,e,this,t).run()}async onChooseMacroType(e,t){let n=new Hl(this.app,this.plugin,e,this,this.variables,this.preloadedUserScripts,void 0,t);await n.run(),Object.entries(n.params.variables).forEach(([i,o])=>{this.variables.set(i,o)})}async onChooseMultiType(e){let t=st(e);if(this.promptProvider||this.interactive===!1){let n=this.promptProvider?"Run one of its choices directly.":"Run one of its choices directly, or re-run with the ui flag.";this.signalAbort(new xe(t.length===0?NE(e):`"${e.name}" is a folder of choices, and picking from it needs someone at the window. ${n}`));return}if(t.length===0){new M7.Notice(NE(e));return}await new Promise((n,i)=>{Ef.Open(this.plugin,t,{choiceExecutor:this,focusedProperty:this.focusedProperty,triggerContext:this.triggerContext,placeholder:e.placeholder?.trim()||e.name,completion:o=>o===void 0?n():i(o)})})}};qt();var R7=require("obsidian");var ewe="QuickAdd: No choices yet. Create your first one in Settings \u2192 QuickAdd.";function JN(r){let e=Array.isArray(r.settings.choices)?r.settings.choices:[];if(!(e.length>0||ZN(r))){new R7.Notice(ewe,8e3),bg(r.app,r.manifest.id,{notice:!1});return}Ef.Open(r,e,{includeTemplateFolderRow:!0})}PN();Me();Me();qt();var $7={description:"Use QuickAdd template folder instead of Obsidian templates plugin folder / Templater templates folder.",migrate:async r=>{try{let e=r.app.plugins.plugins.templater,t=r.app.internalPlugins.plugins.templates;if(!e&&!t){M.logMessage("No template plugin found. Skipping migration.");return}let n=[];if(t){let s=t.instance.options;s.folder&&(n.push(s.folder),M.logMessage("Migrated template folder path to Obsidian Templates' setting."))}if(e){let s=e.settings;s.template_folder&&(n.push(s.template_folder),M.logMessage("Migrated template folder path to Templaters setting."))}let i=zi(r.settings.templateFolderPaths),o=zi([...i,...n]);o.length>0&&(r.settings.templateFolderPaths=o)}catch(e){throw M.logError("Failed to migrate template folder path."),e}}};yi();function aI(r){return r===null||typeof r!="object"||!("type"in r)||!("choices"in r)?!1:r.type==="Multi"&&Array.isArray(r.choices)}function lI(r){return r===null||typeof r!="object"||!("choice"in r)?!1:r.choice!==void 0}Wt();Pi();function O7(r){return typeof r=="object"&&r!==null&&"type"in r&&r.type==="Template"&&"incrementFileName"in r}function N7(r){for(let e of r)aI(e)&&(e.choices=N7(e.choices)),O7(e)&&(e.setFileExistsBehavior=!0,e.fileExistsMode="Increment the file name",delete e.incrementFileName);return r}function twe(r){for(let e of r)for(let t of Ir(zn(e)))lI(t)&&O7(t.choice)&&(t.choice.setFileExistsBehavior=!0,t.choice.fileExistsMode="Increment the file name",delete t.choice.incrementFileName);return r}var rwe={description:"'Increment file name' setting moved to 'Set default behavior if file already exists' setting",migrate:async r=>{let e=r.settings,t=!Cm(r.settings.choices)&&!Ii(e.macros);if(Array.isArray(r.settings.choices)){let o=vt(r.settings.choices);r.settings.choices=vt(N7(o))}let n=vt(Lh(e.macros)),i=twe(n);if(Array.isArray(e.macros)&&(e.macros=i),!t)return{complete:!1}}},L7=rwe;yi();function B7(r){return typeof r=="object"&&r!==null&&"type"in r&&r.type==="Template"}function nwe(r){return r.fileExistsBehavior?r.fileExistsBehavior:r.setFileExistsBehavior?{kind:"apply",mode:yG(r.fileExistsMode)??"increment"}:r.incrementFileName?{kind:"apply",mode:"increment"}:{kind:"prompt"}}function V7(r){r.fileExistsBehavior=nwe(r),delete r.incrementFileName,delete r.setFileExistsBehavior,delete r.fileExistsMode}var iwe={description:"Re-run template file collision normalization for users with older migration state",migrate:async r=>{let e=r.settings,t=!hg(e);if(Array.isArray(r.settings.choices)&&(r.settings.choices=vt(r.settings.choices)),Array.isArray(e.macros)&&(e.macros=vt(e.macros)),gg(r,n=>{B7(n)&&V7(n)}),!t)return{complete:!1}}},cI=iwe;var owe={description:"Repair template file collision settings that may have been left in legacy format",migrate:cI.migrate},U7=owe;Wt();function eL(r){return Ye(r)&&r.type==="Capture"}yi();Wt();Pi();function q7(r){for(let e of r)aI(e)&&(e.choices=q7(e.choices)),eL(e)&&e.insertAfter?.enabled&&e.prepend&&(e.prepend=!1);return r}function swe(r){for(let e of r)for(let t of Ir(zn(e)))lI(t)&&eL(t.choice)&&t.choice.insertAfter?.enabled&&t.choice.prepend&&(t.choice.prepend=!1);return r}var awe={description:"Mutual exclusion of insertAfter and writeToBottomOfFile settings. If insertAfter is enabled, writeToBottomOfFile is disabled. To support changes in settings UI.",migrate:async r=>{let e=r.settings,t=!Cm(r.settings.choices)&&!Ii(e.macros);if(Array.isArray(r.settings.choices)){let o=vt(r.settings.choices);r.settings.choices=q7(o)}let n=vt(Lh(e.macros)),i=swe(n);if(Array.isArray(e.macros)&&(e.macros=i),!t)return{complete:!1}}},W7=awe;Pt();var lwe={description:"Set version to the current plugin version.",migrate:async r=>{le.setState({version:r.manifest.version})}},z7=lwe;ts();Pt();yi();var cwe={description:"Add default AI providers to the settings.",migrate:async r=>{let e=le.getState().ai,t=vt(RT);if("OpenAIApiKey"in e&&typeof e.OpenAIApiKey=="string"){let n=t.find(i=>i.name==="OpenAI");n&&(n.apiKey=e.OpenAIApiKey)}"OpenAIApiKey"in e&&delete e.OpenAIApiKey,le.setState({ai:{...le.getState().ai,providers:t}})}},H7=cwe;Me();Wt();Pi();var uwe={description:"Remove macro indirection - embed macros directly in macro choices",migrate:async r=>{let e=r.settings;if(Cm(e.choices))return M.logMessage("QuickAdd could not read part of the choice list, so legacy macros were left in place to be migrated later."),{complete:!1};if(!Array.isArray(e.choices))return M.logMessage("QuickAdd could not read the choice list, so legacy macros were left in place to be migrated later."),{complete:!1};if(Ii(e.macros))return M.logMessage("QuickAdd could not read the legacy macro list, so it was left in place to be migrated later."),{complete:!1};let t=Lh(e.macros),n=new Map,i=Vn(e.choices);for(let o of i)if(o.type==="Macro"){let s=o;if(s.macroId){let a=s.macroId;n.has(a)||n.set(a,[]),n.get(a).push(s)}}for(let o of t){if(!o||typeof o!="object"||typeof o.id!="string"||o.id==="")continue;let s=n.get(o.id)??i.filter(a=>a.type==="Macro"&&a.macro?.id===o.id);if(s.length===0){let a=new lg(o.name);a.macro={id:o.id,name:o.name,commands:o.commands||[]},a.runOnStartup=o.runOnStartup||!1,e.choices.push(a)}else for(let a of s)a.macro={id:o.id,name:o.name,commands:o.commands||[]},a.runOnStartup??(a.runOnStartup=o.runOnStartup??!1),delete a.macroId}for(let o of i)if(o.type==="Macro"){let s=o;s.macroId&&(M.logMessage(`Removing orphaned macroId reference: ${s.macroId}`),delete s.macroId)}"macros"in e&&delete e.macros}},j7=uwe;Me();function uI(r){if(r==null)return null;if(typeof r=="boolean")return{enabled:r};if(typeof r!="object")return null;let e=r;return{enabled:typeof e.enabled=="boolean"?e.enabled:void 0,direction:e.direction==="horizontal"||e.direction==="vertical"?e.direction:void 0,focus:typeof e.focus=="boolean"?e.focus:void 0}}function dI(r,e){let t=r.direction==="horizontal"?"horizontal":"vertical",n=typeof e=="string"&&e!=="default"?e:"default";return pn({location:r.enabled?"split":"tab",direction:t,focus:r.focus??!0,mode:n})}var dwe={description:"Migrate legacy openFileInNewTab settings to new fileOpening format",migrate:async r=>{M.logMessage("Starting migration of file opening settings...");let e=hg(r.settings),t=0;if(gg(r,i=>{if(i.type!=="Template"&&i.type!=="Capture")return;let o=i,s=o.openFileInNewTab,a=o.openFileInMode,l=uI(s);if(!o.fileOpening&&l){let c={enabled:l?.enabled??!1,direction:l?.direction??"vertical",focus:l?.focus??!0};o.fileOpening=dI(c,a??"default"),t++,M.logMessage(`Migrated file opening settings for choice: ${i.name}`)}}),M.logMessage(`Migration complete. Migrated ${t} choices.`),e)return{complete:!1}}},G7=dwe;Me();var pwe={description:"Backfill missing file opening defaults for older choices",migrate:async r=>{M.logMessage("Starting file opening defaults backfill...");let e=hg(r.settings),t=0;if(gg(r,i=>{if(i.type!=="Template"&&i.type!=="Capture")return;let o=i,s=typeof o.fileOpening=="object"&&o.fileOpening!==null?o.fileOpening:void 0,a=o,l=a.openFileInNewTab,c=a.openFileInMode,u=uI(l);(!s||s.location==null||s.direction==null||s.mode==null||s.focus==null)&&(!s&&u?o.fileOpening=dI(u,c):o.fileOpening=pn(s),t++)}),M.logMessage(`File opening defaults backfill complete. Updated ${t} choice(s).`),e)return{complete:!1}}},Y7=pwe;Pt();yi();var fwe={description:"Ensure every AI provider has a discovery mode so browsing works without models.dev",migrate:async r=>{let t=le.getState().ai.providers??[],n=!1;for(let i of t)i.modelSource||(i.modelSource="auto",n=!0);n&&le.setState(i=>({...i,ai:{...i.ai,providers:vt(t)}}))}},K7=fwe;yi();Me();Pt();yi();ef();var mwe={description:"Move AI provider API keys into Obsidian SecretStorage",migrate:async r=>{let e=le.getState().ai.providers??[],t=()=>e.some(o=>(o.apiKey?.trim()??"")!==""),n=r.app?.secretStorage;if(!n?.getSecret||!n?.setSecret)return t()?(M.logWarning("SecretStorage unavailable; deferring AI provider API key migration until it is available."),{complete:!1}):void 0;let i=!1;for(let o of e){let s=o.apiKey?.trim(),a=o.apiKeyRef?.trim();if(a){try{let l=await Promise.resolve(n.getSecret(a));!l&&s?(await Promise.resolve(n.setSecret(a,s)),o.apiKey="",i=!0):l&&s&&(o.apiKey="",i=!0)}catch(l){M.logWarning(`Failed to migrate secret for ${o.name}: ${l.message??l}`)}continue}if(s)try{let l=await s4(r.app,o,s);l&&(o.apiKeyRef=l,o.apiKey="",i=!0)}catch(l){M.logWarning(`Failed to store API key for ${o.name}: ${l.message??l}`)}}if(i&&le.setState(o=>({...o,ai:{...o.ai,providers:vt(e)}})),t())return{complete:!1}}},Q7=mwe;qt();var X7={description:"Move the single template folder path into the multi-folder list.",migrate:async r=>{let e=r.settings,t=zi(e.templateFolderPaths);t.length>0?e.templateFolderPaths=t:e.templateFolderPaths=zi([e.templateFolderPath]),delete e.templateFolderPath}};ts();Kr();Pt();yi();Me();function hwe(r){for(let e of[r,`https://${r}`])try{let t=new URL(e).hostname.toLowerCase();if(t)return t}catch{}return""}function gwe(r){let e=hwe(r.endpoint??"");return e==="api.openai.com"?"openai":e==="generativelanguage.googleapis.com"?"google":e==="api.anthropic.com"?"anthropic":null}function vwe(r,e,t){let n=new Set(e==="anthropic"?[]:oB[e]);r.models=r.models.filter(o=>!n.has(o.name));let i=new Map(r.models.map(o=>[o.name,o]));for(let o of zv[e]){let s=i.get(o.name);s?(s.maxTokens=o.maxTokens,s.maxOutputTokens=o.maxOutputTokens,s.supportsTemperature=o.supportsTemperature):t.has(o.name)||r.models.push({...o})}}var ywe={temperature:1,top_p:1,frequency_penalty:0,presence_penalty:0};function bwe(r){return r.type==="AIAssistant"}var wwe={description:"Refresh built-in AI provider model lists: drop retired models, add the current generation, and turn on auto-sync.",migrate:async r=>{let e=le.getState(),t=vt(e.ai.providers??[]),n=vt(e.choices??[]),i=new Set;for(let l of t){let c=gwe(l);if(!c)continue;let u=new Set(t.filter(p=>p!==l).flatMap(p=>p.models.map(m=>m.name))),d=l.models.map(p=>p.name);vwe(l,c,u);let f=new Set(l.models.map(p=>p.name));for(let p of d)f.has(p)||i.add(p);l.autoSyncModels=!0,c==="openai"&&(l.modelSource="modelsDev")}let o=new Set(t.flatMap(l=>l.models.map(c=>c.name))),s=new Set([...i].filter(l=>!o.has(l)));PS({choices:n},l=>{if(!bwe(l))return;l.model&&s.has(l.model)&&(M.logMessage(`AI command "${l.name}" used ${l.model}, which its provider has retired. It now asks for a model when it runs.`),l.model="Ask me");let c=l.modelParameters;if(c&&typeof c=="object")for(let[u,d]of Object.entries(ywe))c[u]===d&&delete c[u]});let a=s.has(e.ai.defaultModel)?"Ask me":e.ai.defaultModel;le.setState({choices:n,ai:{...le.getState().ai,defaultModel:a,providers:t}})}},Z7=wwe;ts();Pt();yi();Me();function Cwe(r,e){return r.find(t=>t.models.some(n=>n.name===e))}var xwe={description:"Pin AI commands' models to the provider they currently resolve to, and give every provider a stable id.",migrate:async r=>{let e=le.getState(),t=vt(e.ai.providers??[]),n=vt(e.choices??[]);FT(t),FS(n,t,(s,a)=>{M.logMessage(`Pinned AI command "${s.name}"'s model to ${a.providerId}/${a.name}.`)});let i,o=e.ai.defaultModel;if(e.ai.defaultModelRef&&e.ai.defaultModelRef.name===o)i=e.ai.defaultModelRef;else if(o&&o!=="Ask me"){let s=Cwe(t,o);s?.id&&(i={providerId:s.id,name:o},M.logMessage(`Pinned the default model to ${s.id}/${o}.`))}le.setState({choices:n,ai:{...le.getState().ai,providers:t,...i?{defaultModelRef:i}:{}}})}},J7=xwe;Pt();var tL={useQuickAddTemplateFolder:$7,incrementFileNameSettingMoveToDefaultBehavior:L7,consolidateFileExistsBehavior:cI,repairTemplateFileExistsBehavior:U7,mutualExclusionInsertAfterAndWriteToBottomOfFile:W7,setVersionAfterUpdateModalRelease:z7,addDefaultAIProviders:H7,removeMacroIndirection:j7,migrateFileOpeningSettings:G7,backfillFileOpeningDefaults:Y7,setProviderModelDiscoveryMode:K7,migrateProviderApiKeysToSecretStorage:Q7,migrateToMultipleTemplateFolders:X7,refreshStaleDefaultModelSeeds:Z7,pinAiModelRefs:J7};async function Ewe(r){let e=Object.keys(tL).filter(t=>!r.settings.migrations[t]);if(e.length===0){M.logMessage("No migrations to run.");return}le.replaceState(vt(r.settings));for(let t of e){M.logMessage(`Running migration ${t}: ${tL[t].description}`);let n=vt(r.settings),i=le.getState();try{let o=await tL[t].migrate(r);le.getState()!==i&&(r.settings=vt(le.getState()));let s=o?.complete===!1;s||(r.settings.migrations[t]=!0),le.replaceState(vt(r.settings)),M.logMessage(s?`Migration ${t} incomplete; will retry on a later launch.`:`Migration ${t} successful.`)}catch(o){M.logError(`Migration '${t}' was unsuccessful. Please create an issue with the following error message:
${o}
QuickAdd will now revert to backup.`),r.settings=n,le.replaceState(vt(r.settings))}}r.saveSettings()}var eQ=Ewe;Pt();var Yl=require("obsidian");Me();async function Twe(r,e,t){let n=await(0,Yl.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){let a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:"Unknown error";throw new Error(`Failed to fetch releases: ${a}`)}let o=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)throw new Error(`Could not find release with tag ${t}`);return o.slice(0,s).filter(a=>!a.draft&&!a.prerelease)}var rL=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,tQ=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,_we=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function Awe(r,e){let t=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}function kwe(r){let e=r.split(`
`),t=new Set;for(let s of e){let a=s.trim();rL.test(a)&&t.add(a)}let n=new Map;for(let s of e){let a=s.trim().match(tQ);a&&t.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<e.length;s++)if(rL.test(e[s].trim()))for(let a of[1,-1]){let l=s+a;for(;l>=0&&l<e.length&&e[l].trim()==="";)l+=a;let c=l>=0&&l<e.length?e[l].trim().match(_we):null;if(c){n.set(e[s].trim(),c[1]),i.add(l);break}}let o=[];for(let s=0;s<e.length;s++){let a=e[s],l=a.trim();if(i.has(s))continue;let c=l.match(tQ);if(!(c&&t.has(c[2]))){if(rL.test(l)){o.push(Awe(l,n.get(l)));continue}o.push(a)}}return o.join(`
`)}function Swe(r,e=1){let t=r.split(`
`);for(let n=0;n<t.length;n++)t[n].startsWith("#")&&(t[n]="#".repeat(e)+t[n]);return t.join(`
`)}var pI=class extends Yl.Modal{constructor(t,n){super(t);this.markdownComponent=new Yl.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=Twe("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=>{M.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let t=this.contentEl.createDiv("quickadd-update-modal-footer");new Yl.ButtonComponent(t).setButtonText("Done").setCta().onClick(()=>this.close())}onClose(){let{contentEl:t}=this;this.isClosed=!0,this.markdownComponent.unload(),t.empty()}display(){let{contentEl:t}=this;t.empty(),t.classList.add("quickadd-update-modal-container");let n=`### New in QuickAdd v${this.releases[0].tag_name}
`,i="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",o='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',s=t.createDiv("quickadd-update-modal"),a=this.releases.map(d=>kwe(d.body??"")).join(`
---
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,u=`${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}
---
${Swe(a)}`;this.markdownComponent.load(),Yl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};ED();Hr();xo();var Dwe=25e3,Iwe=6e4,Pwe=3e4,Fwe=75e3,Mwe=32;function Rwe(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}function $we(r){if(r.origin||r.referer)return!1;let e=(r.host??"").split(":")[0];return e==="127.0.0.1"||e==="localhost"}function Owe(r){try{let e=window.require;return e?e(r):null}catch{return null}}function fI(){let r=window.crypto;if(r?.randomUUID)return r.randomUUID();if(r?.getRandomValues){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}throw new Error("Interactive prompts require a secure random source (crypto), which is unavailable here.")}var mI="No pending prompt for that requestId",nL="The interactive client disconnected, so the run was ended.";function Nwe(r,e){if(e.cancelled!==void 0&&typeof e.cancelled!="boolean")return`The "cancelled" flag must be the literal true (or omitted). A cancel that is not recognised would otherwise be answered on the user's behalf.`;if(e.cancelled===!0)return null;if(r==="confirm"){let t=e.value;if(!(t===!0||t===!1||t==="true"||t==="false"))return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Lwe(t)}.`}return null}function Lwe(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}var iL=class{constructor(){this.server=null;this.port=0;this.sessions=new Map;this.startPromise=null;this.generation=0}async ensureStarted(){if(this.server)return this.port;if(this.startPromise)return this.startPromise;let e=Owe("http");if(!e)throw new Error("Interactive prompts require desktop Obsidian (Node http is unavailable).");let t=this.generation;return this.startPromise=new Promise((n,i)=>{let o=e.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===t&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==t){o.close(),i(new Error("Interactive server stopped during startup."));return}let s=o.address();this.port=typeof s=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=Mwe)throw new Error("Too many active interactive sessions.");let e=fI(),t=fI()+fI(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:new Map,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};return n.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},Pwe),this.sessions.set(e,n),{id:e,token:t}}emitPrompt(e,t){let n=this.sessions.get(e);if(!n)return Promise.reject(new Error("Unknown session"));if(n.finished)return Promise.reject(new xe(nL));if(n.aborted)return Promise.reject(new Dt(Cu));let i=fI();return new Promise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:t.type}),this.push(n,{kind:"prompt",requestId:i,prompt:t})})}finish(e,t){let n=this.sessions.get(e);if(!(!n||n.finished)){n.finished=!0,n.attachTimer&&(window.clearTimeout(n.attachTimer),n.attachTimer=null),n.pollWatchdog&&(window.clearTimeout(n.pollWatchdog),n.pollWatchdog=null);for(let[,i]of n.pending)i.reject(new xe(nL));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Iwe)}}abortSession(e){let t=this.sessions.get(e);if(!t||t.finished)return null;t.aborted=!0;let n=[...t.pending.values()];t.pending.clear();for(let i of n)i.reject(new Dt(Cu));return t.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(let e of this.sessions.values()){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t.reject(new xe("QuickAdd was unloaded during an interactive run."));if(e.waiter){let t=e.waiter;e.waiter=null,t({kind:"error",error:"QuickAdd unloaded"})}}this.sessions.clear(),this.server?.close(),this.server=null,this.port=0,this.startPromise=null}push(e,t){if(e.waiter){let n=e.waiter;e.waiter=null,e.waiterTimer&&(window.clearTimeout(e.waiterTimer),e.waiterTimer=null),n(t)}else e.queue.push(t)}destroySession(e){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t.reject(new xe(nL));e.pending.clear(),this.sessions.delete(e.id),this.sessions.size===0&&(this.server?.close(),this.server=null,this.port=0,this.startPromise=null)}authed(e,t){return!!e&&!!t&&Rwe(e.token,t)}originAllowed(e){return $we({origin:e.headers.origin,referer:e.headers.referer,host:e.headers.host})}submitReply(e,t,n,i=!1){let o=this.sessions.get(e);if(!o)return!1;let s=o.pending.get(t);return s?(o.pending.delete(t),i===!0?s.promptType==="info"?s.resolve(n):s.reject(new Dt(Cu)):s.resolve(n),!0):!1}pendingPromptType(e,t){return e.pending.get(t)?.promptType}send(e,t,n){let i=JSON.stringify(n);e.writeHead(t,{"content-type":"application/json","cache-control":"no-store"}),e.end(i)}async drainBody(e){let t=0;for await(let n of e)if(t+=n.length,t>1e6)throw new Error("Request body too large")}async readBody(e){let t=[],n=0;for await(let i of e){if(n+=i.length,n>1e6)throw new Error("Request body too large");t.push(i)}return t.length===0?{}:JSON.parse(Buffer.concat(t).toString("utf8"))}async handle(e,t){try{if(!this.originAllowed(e)){this.send(t,403,{ok:!1,error:"Forbidden"});return}let n=new URL(e.url??"/","http://127.0.0.1"),i=n.searchParams.get("session"),o=n.searchParams.get("token"),s=i?this.sessions.get(i):void 0;if(!this.authed(s,o)){this.send(t,404,{ok:!1,error:"Unknown session or token"});return}if(e.method==="GET"&&n.pathname==="/poll"){this.handlePoll(s,t);return}if(e.method==="POST"&&n.pathname==="/abort"){await this.drainBody(e);let a=this.abortSession(s.id);if(a===null){this.send(t,409,{ok:!1,error:"The interactive session has already ended"});return}this.send(t,200,{ok:!0,interrupted:a});return}if(e.method==="POST"&&n.pathname==="/reply"){let a=await this.readBody(e),l=this.submitWireReply(s.id,a);l.ok?this.send(t,200,{ok:!0}):this.send(t,l.status,{ok:!1,error:l.error});return}this.send(t,404,{ok:!1,error:"Not found"})}catch(n){this.send(t,400,{ok:!1,error:n instanceof Error?n.message:String(n)})}}handlePoll(e,t){e.attached||(e.attached=!0,e.attachTimer&&(window.clearTimeout(e.attachTimer),e.attachTimer=null)),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog),e.pollWatchdog=window.setTimeout(()=>{this.finish(e.id,{kind:"error",error:"Interactive client disconnected."})},Fwe);let n=e.queue.shift();if(n){this.send(t,200,n);return}if(e.waiter){this.send(t,200,{kind:"idle"});return}let i=o=>this.send(t,200,o);e.waiter=i,e.waiterTimer=window.setTimeout(()=>{e.waiter===i&&(e.waiter=null,e.waiterTimer=null,this.send(t,200,{kind:"idle"}))},Dwe),t.on("close",()=>{e.waiter===i&&(e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.waiter=null,e.waiterTimer=null)})}submitWireReply(e,t){let n=this.sessions.get(e);if(!n)return{ok:!1,status:409,error:mI};if(!t.requestId)return{ok:!1,status:409,error:mI};let i=this.pendingPromptType(n,t.requestId);if(!i)return{ok:!1,status:409,error:mI};let o=Nwe(i,t);return o?{ok:!1,status:400,error:o}:this.submitReply(n.id,t.requestId,t.value,t.cancelled)?{ok:!0}:{ok:!1,status:409,error:mI}}},da=new iL;function oL(r){if(!r||typeof r!="string")return null;let e=r.split("-")[0]?.split("+")[0]?.trim();if(!e)return null;let t=e.split(".");if(t.length!==3)return null;let n=Number.parseInt(t[0]??"",10),i=Number.parseInt(t[1]??"",10),o=Number.parseInt(t[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}}Wt();bN();qt();Me();Zx();var Tf="\0qa-idx:";function Bwe(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}var hI=class{constructor(e,t=da){this.sessionId=e;this.server=t}async suggester(e,t,n,i=!1){let o=typeof e=="function"?t.map((c,u,d)=>String(e(c,u,d))):e.map(c=>String(c)),s=t.map((c,u)=>({title:o[u]??String(c),value:`${Tf}${u}`})),a=await this.server.emitPrompt(this.sessionId,{type:"suggester",placeholder:n,allowCustomInput:i,items:s});if(a==null)return"";let l=String(a);if(l.startsWith(Tf)){let c=Number(l.slice(Tf.length));if(Number.isInteger(c)&&c>=0&&c<t.length)return t[c]}return l}async suggesterMulti(e,t,n){let i=t.map((a,l)=>({title:e[l]??String(a),value:`${Tf}${l}`})),o=[];for(let a of n?.preselected??[]){let l=t.indexOf(a);if(l>=0)o.push(`${Tf}${l}`);else{let c=String(a);i.push({title:c,value:c}),o.push(c)}}let s=await this.server.emitPrompt(this.sessionId,{type:"multiselect",placeholder:n?.placeholder,allowCustomInput:n?.allowCustomInput??!1,items:i,preselected:o});return Array.isArray(s)?s.map(a=>{let l=String(a);if(l.startsWith(Tf)){let c=Number(l.slice(Tf.length));if(Number.isInteger(c)&&c>=0&&c<t.length)return t[c]}return l}):[]}async inputPrompt(e,t,n){return this.textPrompt(e,t,n,!1)}async wideInputPrompt(e,t,n){return this.textPrompt(e,t,n,!0)}async textPrompt(e,t,n,i){let o=await this.server.emitPrompt(this.sessionId,{type:"input",header:e,placeholder:t,defaultValue:n,multiline:i});return o==null?"":String(o)}async datePrompt(e,t){let n=await this.server.emitPrompt(this.sessionId,{type:"date",header:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue,dateFormat:t?.dateFormat,withTime:t?.withTime}),i=String(n??"");if(!i)return"";let o=i.startsWith("@date:")?i.slice(6):i,s=t?.dateFormat;return(s?Ul(o,s):null)??o}async yesNoPrompt(e,t){let n=await this.server.emitPrompt(this.sessionId,{type:"confirm",header:e,text:t});if(n===!0||n==="true")return!0;if(n===!1||n==="false")return!1;throw new Error(`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Bwe(n)}.`)}async checkboxPrompt(e,t,n){let i=new Set(t??[]),o=await this.server.emitPrompt(this.sessionId,{type:"checkbox",header:n,items:e.map(s=>({title:String(s),value:String(s),checked:i.has(s)}))});return Array.isArray(o)?o.map(s=>String(s)):[]}async infoDialog(e,t){await this.server.emitPrompt(this.sessionId,{type:"info",header:e,text:Array.isArray(t)?t:[t]})}async requestInputs(e){let t=e.map(s=>({id:s.id,label:s.label??s.id,type:s.type==="file-picker"?"suggester":s.type,placeholder:s.placeholder,defaultValue:s.defaultValue,description:s.description,options:s.options,displayOptions:s.displayOptions,dateFormat:s.dateFormat,optional:s.optional,numericConfig:s.numericConfig,suggesterConfig:s.suggesterConfig?{allowCustomInput:s.suggesterConfig.allowCustomInput,multiSelect:s.suggesterConfig.multiSelect}:void 0})),n=await this.server.emitPrompt(this.sessionId,{type:"form",fields:t});if(!n||typeof n!="object")return{};let i=new Set(e.filter(s=>s.type==="date").map(s=>s.id)),o={};for(let[s,a]of Object.entries(n)){if(Array.isArray(a)){o[s]=a.map(c=>String(c));continue}let l=a==null?"":String(a);l&&i.has(s)&&!l.startsWith("@date:")&&(l=`@date:${l}`),o[s]=l}return o}};Wt();var rQ={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON"},ui:{description:"Allow interactive prompts"},verify:{description:"Report the verified outcome for Template/Capture choices (file path and effect on success, honest failure when the engine swallows an error)"}},Vwe={type:{value:"<Template|Capture|Macro|Multi>",description:"Filter by choice type"},commands:{description:"Only include command-enabled choices"}},Uwe={path:{value:"<vault-path>",description:"Path to a template file in the vault"},vars:{value:"<json>",description:"Variables object as JSON"},ui:{description:"Allow interactive prompts"}},qwe={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON"},fields:{description:"Include full field metadata (options, defaults, widget config)"}},Wwe={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON (pre-seeded inputs)"}},zwe={path:{value:"<vault-path>",description:"Path to a .quickadd.json package file in the vault"},decode:{description:"Inline decoded contents for each bundled file"}},Hwe=new Set(["choice","id","vars","ui","verify"]),nQ=new Set(["path","vars","ui"]),jwe=new Set(["choice","id","vars","fields"]),Gwe=new Set(["choice","id","vars"]),Tn={runDefault:"quickadd",run:"quickadd:run",runTemplate:"quickadd:run-template",list:"quickadd:list",check:"quickadd:check",preview:"quickadd:package-preview",interactive:"quickadd:interactive"},Ywe=new Set(["template","capture","macro","multi"]);function Ar(r){return JSON.stringify(r)}function av(r){if(r===void 0)return!1;let e=r.toLowerCase();return e==="true"||e==="1"||e==="yes"||e==="on"}function Kwe(r){let e;try{e=JSON.parse(r)}catch(t){throw new Error(`Invalid vars JSON: ${t instanceof Error?t.message:String(t)}`)}if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid vars JSON: expected an object");return e}function gI(r,e){let t={};typeof r.vars=="string"&&Object.assign(t,Kwe(r.vars));for(let[n,i]of Object.entries(r)){if(n.startsWith("value-")){let o=n.slice(6);o&&(t[o]=i);continue}e.has(n)||(t[n]=i)}return t}function oQ(r,e=[]){let t=[];for(let n of gn(r)){if(!Ye(n))continue;let i=[...e,n.name],o=i.join(" / "),s=n.type==="Multi";t.push({id:n.id,name:n.name,type:n.type,command:n.command,path:o,runnable:!s}),s&&t.push(...oQ(st(n),i))}return t}function sL(r,e){if(typeof e.id=="string"&&e.id.trim().length>0)return r.getChoiceById(e.id);if(typeof e.choice=="string"&&e.choice.trim().length>0)return r.getChoiceByName(e.choice);throw new Error("Missing choice selector. Provide either choice=<name> or id=<id>")}function aL(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 Qwe(r){return{...aL(r),options:r.options,displayOptions:r.displayOptions,dateFormat:r.dateFormat,withTime:r.withTime,optional:r.optional,runtimeOnly:r.runtimeOnly,multiEmit:r.multiEmit,filters:r.filters,numericConfig:r.numericConfig,sliderConfig:r.sliderConfig,suggesterConfig:r.suggesterConfig}}function lL(r,e){for(let[t,n]of Object.entries(e))r.variables.set(t,n)}function Ho(r){return{id:r.id,name:r.name,type:r.type}}async function sQ(r,e,t,n,i,o=!1){let s=Date.now();try{if(n.type==="Multi")return Ar({ok:!1,command:t,error:"Multi choices are interactive and cannot be run via CLI.",choice:Ho(n)});let a=gI(e,i),l=new $i(r.app,r);lL(l,a);let c=av(e.ui);if(l.interactive=c,!c){let f=await BE(r.app,r,l,n,{preloadedUserScripts:l.preloadedUserScripts}),p=VE(f,l.variables);if(p.length>0)return Ar({ok:!1,command:t,error:"Missing required inputs for non-interactive CLI run.",choice:Ho(n),missing:p.map(aL),missingFlags:p.map(m=>`value-${m.id}=<value>`)})}if(o&&(n.type==="Template"||n.type==="Capture")&&typeof l.executeWithOutcome=="function"){let f=await l.executeWithOutcome(n),p=Date.now()-s;return f.status==="success"?Ar({ok:!0,command:t,choice:Ho(n),file:f.file?.path,verified:!0,effect:f.effect,durationMs:p}):f.status==="cancelled"?Ar({ok:!1,command:t,error:f.reason||(f.cancelKind==="user"?"Execution cancelled by user":"Execution aborted"),aborted:!0,choice:Ho(n),durationMs:p}):Ar({ok:!1,command:t,error:f.reason||"Choice execution failed; no file was created.",choice:Ho(n),durationMs:p})}await l.execute(n);let u=l.consumeAbortSignal?.(),d=Date.now()-s;return Ar(u?{ok:!1,command:t,error:u.message||"Choice execution aborted",aborted:!0,choice:Ho(n),durationMs:d}:{ok:!0,command:t,choice:Ho(n),verified:!1,effect:"unknown",durationMs:d})}catch(a){return Ar({ok:!1,command:t,error:a instanceof Error?a.message:String(a)})}}async function iQ(r,e,t){let n;try{n=sL(r,e)}catch(i){return Ar({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}return sQ(r,e,t,n,Hwe,av(e.verify))}async function Xwe(r,e){let t=Tn.runTemplate;try{let n=typeof e.path=="string"?e.path.trim():"";if(!n)return Ar({ok:!1,command:t,error:"Missing template path. Provide path=<vault-path>."});let i=mo(r.app,n);if(!i)return Ar({ok:!1,command:t,error:`No template file found at '${n}'.`});let o=KN(i.path);if(!av(e.ui)){let a=gI(e,nQ).value;if(a==null||String(a).trim().length===0)return Ar({ok:!1,command:t,error:"Missing required inputs for non-interactive CLI run.",choice:Ho(o),missing:[{id:"value",label:"New note name",type:"text",source:"collected",optionCount:0}],missingFlags:["value-value=<value>"]})}return await sQ(r,e,t,o,nQ,!0)}catch(n){return Ar({ok:!1,command:t,error:n instanceof Error?n.message:String(n)})}}function Zwe(r,e){try{let t=typeof e.type=="string"?e.type.trim():"",n=t.toLowerCase(),i=av(e.commands);if(n&&!Ywe.has(n))return Ar({ok:!1,command:Tn.list,error:`Invalid type filter '${t}'.`});let s=oQ(r.settings.choices).filter(a=>!(n&&a.type.toLowerCase()!==n||i&&!a.command));return Ar({ok:!0,command:Tn.list,count:s.length,choices:s})}catch(t){return Ar({ok:!1,command:Tn.list,error:t instanceof Error?t.message:String(t)})}}async function Jwe(r,e){try{let t=sL(r,e);if(t.type==="Multi")return Ar({ok:!1,command:Tn.check,error:"Multi choices are interactive and cannot be checked via CLI.",choice:Ho(t)});let n=gI(e,jwe),i=new $i(r.app,r);lL(i,n);let o=await BE(r.app,r,i,t),s=VE(o,i.variables),a=av(e.fields)?Qwe:aL;return Ar({ok:s.length===0,command:Tn.check,choice:Ho(t),requiredInputCount:o.length,missingInputCount:s.length,missing:s.map(a),missingFlags:s.map(l=>`value-${l.id}=<value>`)})}catch(t){return Ar({ok:!1,command:Tn.check,error:t instanceof Error?t.message:String(t)})}}async function eCe(r,e){let t=Tn.interactive,n;try{n=sL(r,e)}catch(i){return Ar({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}if(n.type==="Multi")return Ar({ok:!1,command:t,error:"Multi choices cannot be run interactively via CLI.",choice:Ho(n)});try{let i=await da.ensureStarted(),{id:o,token:s}=da.createSession(),a=new $i(r.app,r);return lL(a,gI(e,Gwe)),a.interactive=!0,a.promptProvider=new hI(o),(async()=>{try{if((n.type==="Template"||n.type==="Capture")&&typeof a.executeWithOutcome=="function"){let c=await a.executeWithOutcome(n);if(c.status==="success"){da.finish(o,{kind:"done",result:{ok:!0,choice:Ho(n),file:c.file?.path,verified:!0,effect:c.effect}});return}da.finish(o,{kind:"error",error:c.status==="cancelled"?c.reason||(c.cancelKind==="user"?"Execution cancelled by user":"Execution aborted"):c.reason||"Choice execution failed; no file was created."});return}await a.execute(n);let l=a.consumeAbortSignal?.();if(l){da.finish(o,{kind:"error",error:l.message||"Choice execution aborted"});return}da.finish(o,{kind:"done",result:{ok:!0,choice:Ho(n),verified:!1,effect:"unknown"}})}catch(l){da.finish(o,{kind:"error",error:l instanceof Error?l.message:String(l)})}})(),Ar({ok:!0,command:t,choice:Ho(n),host:"127.0.0.1",port:i,sessionId:o,token:s,capabilities:["abort","outcome-effect"]})}catch(i){return Ar({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}}async function tCe(r,e){try{let t=typeof e.path=="string"?e.path.trim():"";if(!t)return Ar({ok:!1,command:Tn.preview,error:"Missing package path. Provide path=<vault-path>."});let{pkg:n}=await z4(r.app,t),i=await NS(r.app,r.settings.choices,n),o={ok:!0,command:Tn.preview,preview:i};return av(e.decode)&&(o.contents=i.files.map(s=>({path:s.originalPath,...$S(n,s.originalPath)}))),Ar(o)}catch(t){return Ar({ok:!1,command:Tn.preview,error:t instanceof Error?t.message:String(t)})}}function aQ(r){let e=r;if(typeof e.registerCliHandler!="function")return M.logMessage("Skipping QuickAdd CLI handler registration: registerCliHandler is unavailable."),!1;let t=e.registerCliHandler.bind(e);return t(Tn.runDefault,"Run a QuickAdd choice (ok:true reports the choice ran without aborting; check verified to know QuickAdd confirmed the run, and effect to know whether the vault changed: created/changed/unchanged/unknown)",rQ,n=>iQ(r,n,Tn.runDefault)),t(Tn.run,"Run a QuickAdd choice (ok:true reports the choice ran without aborting; check verified to know QuickAdd confirmed the run, and effect to know whether the vault changed: created/changed/unchanged/unknown)",rQ,n=>iQ(r,n,Tn.run)),t(Tn.runTemplate,"Create a new note from a template file (no Template choice required)",Uwe,n=>Xwe(r,n)),t(Tn.list,"List QuickAdd choices",Vwe,n=>Zwe(r,n)),t(Tn.check,"Check missing inputs for a QuickAdd choice",qwe,n=>Jwe(r,n)),t(Tn.preview,"Preview a QuickAdd package before importing (files + capabilities)",zwe,n=>tCe(r,n)),t(Tn.interactive,"Run a choice interactively: forwards its runtime prompts to the caller over a local server (returns host/port/sessionId/token to attach)",Wwe,n=>eCe(r,n)),M.logMessage("Registered QuickAdd CLI handlers."),!0}var xd={run:"Run",runTemplateFromFolder:"New note from template",applyTemplate:"Apply template to active note",reloadDev:"Reload (dev)",openSettings:"Open settings",resumePrompt:"Return to prompt"};iF();wl();IN();var rCe=new Set(["shortcuts:","obsidian:"]);function vI(r){return typeof r=="string"&&r.length>0?r:void 0}function lQ(r){let e=vI(r["x-success"]),t=vI(r["x-error"]),n=vI(r["x-cancel"]);if(e||t||n)return{success:e,error:t,cancel:n,any:!0};let i=vI(r["x-callback-url"]);return i?{success:i,cancel:i,any:!0}:{any:!1}}function cQ(r){return[r.success,r.error,r.cancel].filter(e=>typeof e=="string"&&e.length>0)}function cL(r){try{let e=new URL(r).protocol.toLowerCase();return rCe.has(e)}catch{return!1}}function uQ(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))t.searchParams.set(n,i);return t.toString()}function dQ(r,e){return"obsidian://open?vault="+encodeURIComponent(r)+"&file="+encodeURIComponent(e)}var nCe=1e3,yI=class extends lv.Plugin{constructor(){super(...arguments);this.requestSave=(0,lv.debounce)(()=>{(async()=>await this.saveData(this.settings))()},nCe)}get api(){return ev.GetApi(this.app,this,new $i(this.app,this))}async onload(){M.logMessage("Loading QuickAdd"),OU(this),await this.loadSettings(),le.replaceState(this.settings),this.unsubscribeSettingsStore=le.subscribe(o=>{this.settings=o,this.requestSave()}),this.addCommand({id:"runQuickAdd",name:xd.run,callback:()=>{JN(this)}}),this.addCommand({id:"resumePrompt",name:xd.resumePrompt,checkCallback:o=>Ou.isPeeking()?(o||Ou.getActive()?.resume(),!0):!1}),this.addCommand({id:"runTemplateFromFolder",name:xd.runTemplateFromFolder,callback:()=>{sI(this.app,this,{choiceExecutor:new $i(this.app,this)})}}),this.addCommand({id:"applyTemplateToActiveFile",name:xd.applyTemplate,checkCallback:o=>{let s=this.app.workspace.getActiveFile(),a=s?.extension==="md";if(o)return a;a&&DE(this.app,this,{file:s,choiceExecutor:new $i(this.app,this)})}}),this.registerEvent(this.app.workspace.on("file-menu",(o,s)=>{s instanceof lv.TFile&&s.extension==="md"&&o.addItem(a=>a.setTitle(`QuickAdd: ${xd.applyTemplate}`).setIcon("file-plus").onClick(()=>{DE(this.app,this,{file:s,choiceExecutor:new $i(this.app,this)})}))})),this.addCommand({id:"reloadQuickAdd",name:xd.reloadDev,checkCallback:o=>{if(o)return this.settings.devMode;let s=this.manifest.id,a=this.app.plugins;a.disablePlugin(s).then(()=>a.enablePlugin(s))}});let t=Yc.getInstance();t.startAutomaticCleanup(o=>this.registerInterval(o)),t.registerInvalidationListeners(this.app,o=>this.registerEvent(o)),this.addCommand({id:"openQuickAddSettings",name:xd.openSettings,callback:()=>{bg(this.app,this.manifest.id)}}),this.registerObsidianProtocolHandler("quickadd",async o=>{let s=o,a=this.settings.enableUriCallbacks?lQ(s):{any:!1};if(!a.any){await this.runUriChoiceLegacy(s);return}let l=cQ(a).filter(f=>!cL(f));if(l.length>0){M.logWarning(`QuickAdd URI: ignoring disallowed callback URL(s): ${l.join(", ")}`),a.error&&cL(a.error)&&this.openUriCallback(a.error,{status:"error",errorCode:"bad-callback-url"});return}if(!s.choice){M.logWarning("URI was executed without a `choice` parameter."),this.fireUriError(a,"choice-not-found");return}let c=this.getChoice("name",s.choice);if(!c){M.logWarning(`URI could not find any choice named '${s.choice}'`),this.fireUriError(a,"choice-not-found");return}if(this.warnIfChoiceNameAmbiguous(s.choice),c.type!=="Template"&&c.type!=="Capture"){M.logWarning(`QuickAdd URI x-callback supports Template and Capture choices only ('${c.name}' is ${c.type}). A URI with x-* callback params cannot run a ${c.type} choice while "Enable URI callbacks" is on; remove the x-* params to run it on the legacy path.`),this.fireUriError(a,"unsupported-choice-type");return}let u=new $i(this.app,this);this.applyUriValueParameters(u,s);let d=await u.executeWithOutcome(c);switch(d.status){case"success":this.fireUriSuccess(a,d.file,d.effect);break;case"cancelled":d.cancelKind==="user"?this.fireUriCancel(a):this.fireUriError(a,"execution-aborted");break;case"error":this.fireUriError(a,"execution-failed");break}}),M.register(new jx).register(new WS(this)),f5(this),this.settings.enableRibbonIcon&&this.addRibbonIcon("file-plus","QuickAdd",()=>{JN(this)}),this.addSettingTab(new qS(this.app,this)),this.addCommandsForChoices(this.settings.choices);try{await eQ(this)}catch(o){lt(o,"QuickAdd could not run its settings migrations")}let n=()=>{try{aQ(this)}catch(o){lt(o,"QuickAdd could not register its CLI handlers")}};this.app.workspace.layoutReady?n():this.app.workspace.onLayoutReady(n);let i=async()=>{try{await new GD(this.app,this,this.settings.choices,new $i(this.app,this)).run()}catch(o){lt(o,"QuickAdd could not run its startup macros")}};this.app.workspace.layoutReady?i():this.app.workspace.onLayoutReady(i),this.app.workspace.onLayoutReady(()=>{window.setTimeout(()=>{l4(this.app)},5e3)}),this.announceUpdate()}async runUriChoiceLegacy(t){if(!t.choice){M.logWarning("URI was executed without a `choice` parameter.");return}let n=this.getChoice("name",t.choice);if(!n){lt(new Error(`URI could not find any choice named '${t.choice}'`),"URI handler error");return}this.warnIfChoiceNameAmbiguous(t.choice);let i=new $i(this.app,this);this.applyUriValueParameters(i,t);try{await i.execute(n)}catch(o){rm(o,`Could not run "${n.name}"`)}}applyUriValueParameters(t,n){Object.entries(n).filter(([i])=>i.startsWith("value-")).forEach(([i,o])=>{let s=i.slice(6);s&&typeof o=="string"&&!FD(s)&&t.variables.set(s,o)})}fireUriSuccess(t,n,i){let o={status:"success",effect:i};n&&(o.path=n.path,o.url=dQ(this.app.vault.getName(),n.path)),t.success&&this.openUriCallback(t.success,o)}fireUriError(t,n){t.error&&this.openUriCallback(t.error,{status:"error",errorCode:n})}fireUriCancel(t){t.cancel&&this.openUriCallback(t.cancel,{status:"cancel"})}openUriCallback(t,n){NB(()=>{window.open(uQ(t,n))},"QuickAdd URI: failed to open callback URL")}onunload(){M.logMessage("Unloading QuickAdd"),this.requestSave.run(),this.unsubscribeSettingsStore?.call(this),Gv.loggers.forEach(n=>{n instanceof jx&&n.clearErrorLog()}),Yc.getInstance().destroy(),da.stop(),Ou.getActive()?.cancel()}async loadSettings(){let t=await this.loadData(),n=Object.assign({},OT,t);typeof n.announceUpdates=="boolean"&&(n.announceUpdates=n.announceUpdates?"all":"none"),Array.isArray(n.choices)&&(n.choices=hU(n.choices)),this.settings=n}async saveSettings(){this.requestSave.cancel(),await this.saveData(this.settings)}addCommandsForChoices(t){for(let n of gn(t))if(Ye(n))try{this.addCommandForChoice(n)}catch(i){lt(i,"Could not add a command for a QuickAdd choice")}}addCommandForChoice(t){if(t.type==="Multi"&&this.addCommandsForChoices(st(t)),t.command){let n=t.id;this.addCommand({id:`choice:${n}`,name:t.name,icon:Em(t),callback:async()=>{let i;try{i=this.getChoiceById(n),await new $i(this.app,this).execute(i)}catch(o){rm(o,`Could not run "${i?.name??t.name}"`)}}})}}getChoiceById(t){let n=this.getChoice("id",t);if(!n)throw new Error(`Choice ${t} not found`);return n}getChoiceByName(t){let n=this.getChoice("name",t);if(!n)throw new Error(`Choice ${t} not found`);return n}getChoice(t,n,i=this.settings.choices){for(let o of gn(i))if(Ye(o)){if(o[t]===n)return o;if(o.type==="Multi"){let s=this.getChoice(t,n,st(o));if(s)return s}}return null}countChoicesByName(t,n=this.settings.choices){let i=0;for(let o of gn(n))Ye(o)&&(o.name===t&&i++,o.type==="Multi"&&(i+=this.countChoicesByName(t,st(o))));return i}warnIfChoiceNameAmbiguous(t){let n=this.countChoicesByName(t);n>1&&M.logWarning(`QuickAdd URI: ${n} choices are named '${t}'. Ran the first match \u2014 rename choices to keep names unique so URIs target the right one.`)}removeCommandForChoice(t,n){if(n?.recursive&&t.type==="Multi")for(let i of st(t))Ye(i)&&this.removeCommandForChoice(i,n);eP(this.app,`quickadd:choice:${t.id}`)}getTemplateFiles(){let t=zi(this.settings.templateFolderPaths);return this.app.vault.getFiles().filter(n=>ZT(n.path)).filter(n=>Q0(n.path,t))}announceUpdate(){let t=(l,c)=>{let u=oL(l),d=oL(c);return!u||!d?!0:u.major!==d.major?u.major>d.major:u.minor>d.minor},n=this.manifest.version,i=this.settings.version;if(n===i)return;let o=this.settings.announceUpdates,s=!0;if((o==="none"||o==="major"&&!t(n,i))&&(s=!1),this.settings.version=n,this.saveSettings(),!s)return;new pI(this.app,i).open()}};
/* nosourcemap */