/* THIS IS A GENERATED/BUNDLED FILE BY ESBUILD if you want to view the source, please visit the github repository of this plugin */ var D4=Object.create;var zh=Object.defineProperty;var F4=Object.getOwnPropertyDescriptor;var P4=Object.getOwnPropertyNames;var M4=Object.getPrototypeOf,$4=Object.prototype.hasOwnProperty;var U$=r=>{throw TypeError(r)};var O4=(r,e,t)=>e in r?zh(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var E=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var R4=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},fw=(r,e)=>{for(var t in e)zh(r,t,{get:e[t],enumerable:!0})},H$=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of P4(e))!$4.call(r,i)&&i!==t&&zh(r,i,{get:()=>e[i],enumerable:!(n=F4(e,i))||n.enumerable});return r};var z$=(r,e,t)=>(t=r!=null?D4(M4(r)):{},H$(e||!r||!r.__esModule?zh(t,"default",{value:r,enumerable:!0}):t,r)),N4=r=>H$(zh({},"__esModule",{value:!0}),r);var he=(r,e,t)=>O4(r,typeof e!="symbol"?e+"":e,t),m_=(r,e,t)=>e.has(r)||U$("Cannot "+t);var V=(r,e,t)=>(m_(r,e,"read from private field"),t?t.call(r):e.get(r)),rt=(r,e,t)=>e.has(r)?U$("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),Ge=(r,e,t,n)=>(m_(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),lt=(r,e,t)=>(m_(r,e,"access private method"),t);var $R,OR,RR=E(()=>{$R=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let p=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(f=>f(e,p))}},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},OR=(r=>r?$R(r):$R)});function Eg(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=s8(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 s8(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 a8(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function nC(r,e){let t=a8(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 iC(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=nC(n.id??n.name,r),t.add(n.id),e=!0}return e}function pc(r,e){return e&&e.name===r?e:void 0}function oC(r){return Tg[r].map(e=>({...e}))}var Tg,NR,l8,c8,sC,ro=E(()=>{Tg={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}]},NR={openai:["gpt-4-32k","gpt-4-1106-preview"],google:["gemini-1.5-pro","gemini-1.5-flash","gemini-1.5-flash-8b"]};l8={id:"openai",name:"OpenAI",endpoint:"https://api.openai.com/v1",kind:"openai",apiKey:"",models:oC("openai"),autoSyncModels:!0,modelSource:"modelsDev"},c8={id:"gemini",name:"Gemini",endpoint:"https://generativelanguage.googleapis.com",kind:"gemini",apiKey:"",models:oC("google"),autoSyncModels:!0,modelSource:"modelsDev"},sC=[l8,c8]});function LR(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function kg(r,e=Kp){let t=r.trim();if(!t)return r;let n=LR(e,t.toLowerCase());if(n)return n;let[i,...o]=t.split(/\s+/),s=LR(e,i.toLowerCase());return s?[s,...o].join(" "):r}function VR(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 bA(r){return Object.entries(r).filter(([e,t])=>e&&t).map(([e,t])=>`${e} = ${t}`).join(` `)}function Sg(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 aC(r){return Sg(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Kp,td=E(()=>{Kp={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 lC,wA=E(()=>{ro();td();lC={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,namePastedImagesAfterNoteTitle:!1,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Kp,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:sC,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 Ve(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return fc(r,new Map)}function fc(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(fc(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(fc(o,e),fc(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(fc(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(fc(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=fc(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:fc(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var Jr=E(()=>{});var X,dt=E(()=>{RR();wA();Jr();X=(()=>{let r=OR((i,o)=>({...Ve(lC)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var rd,_g,I,Ie=E(()=>{rd=class rd{register(e){return rd.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;rd.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;rd.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;rd.loggers.forEach(o=>o.logMessage(t,n,i))}};rd.loggers=[];_g=rd,I=new _g});var Or,BR,qR,no,nd,id,vs,UR,CA,HR,xA,el,od,Dke,sd,cC,uC,mc,EA,TA,Fke,Pke,Mke,Nt,cr,wn,kA,hc,Oo,dC,tl,pC,Ro,Ag,SA,_A,AA,zR,WR,jR,GR,YR,KR,QR,XR,ZR,JR,eN,IA,tN,rN,nN,iN,oN,sN,aN,lN,cN,uN,dN,pN,fN,mN,hN,fC,Ig,rl,gN,Xe=E(()=>{Or="{{value}}",BR="{{name}}",qR=new RegExp(/^-?[0-9]*$/),no="top",nd="bottom",id="cursor",vs="ordered",UR=new RegExp(/{{DATE(\+-?[0-9]+)?(?:\|((?:startof|endof):[a-z]+))?(?:\|case:([a-z-]+))?}}/i),CA=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),HR=new RegExp(/{{TIME(?:\|case:([a-z-]+))?}}/i),xA=new RegExp(/{{TIME:((?:\[[^\]\n\r]*\]|\[(?![^\]\n\r]*\])|[^}\n\r+|[]|\|(?!(?:case):[a-z-]+}}))*)(?:\|case:([a-z-]+))?}}/i),el=new RegExp(/{{(?:NAME|VALUE)(?!:)(?:\|[^\n\r}]*)?}}/i),od=new RegExp(/{{VALUE:([^\n\r}]*)}}/i),Dke=new RegExp(/{{FIELD:([^\n\r}]*)}}/i),sd="FIELD:",cC=new RegExp(/{{FIELD:([^\n\r}|{]*)(\|[^\n\r}{]*)?}}/i),uC=new RegExp(/{{FILE:([^\n\r{}]*)}}/i),mc=new RegExp(/{{VDATE:([^\n\r},|{]*)(?:,([^\n\r}|{]*))?(?:\|([^\n\r}{]*))?}}/i),EA=new RegExp(/{{LINKCURRENT}}/i),TA=new RegExp(/{{LINKSECTION}}/i),Fke=new RegExp(/{{FILENAMECURRENT}}/i),Pke=new RegExp(/{{FOLDERCURRENT(\|name)?}}/i),Mke=new RegExp(/{{FOLDER(\|name)?}}/i),Nt=new RegExp(/\.md$/i),cr=new RegExp(/\.canvas$/i),wn=new RegExp(/\.base$/i),kA=new RegExp(/\.js$/),hc=new RegExp(/{{MACRO:([^\n\r}]*)}}/i),Oo=new RegExp(/{{TEMPLATE:([^\n\r}]*\.(?:md|canvas|base))}}/i),dC=new RegExp(/{{GLOBAL_VAR:([^\n\r}]*)}}/i),tl=new RegExp(/`{3,}js quickadd([\s\S]*?)`{3,}/),pC=new RegExp(/{{MVALUE}}/i),Ro=new RegExp(/{{TITLE}}/i),Ag=new RegExp(/{{PROPERTY}}/i),SA=new RegExp(/{{SELECTED}}/i),_A=new RegExp(/{{CLIPBOARD}}/i),AA=new RegExp(/{{RANDOM:(\d+)}}/i),zR=new RegExp(/\[\[([^\]]*)$/),WR=new RegExp(/#([^ ]*)$/),jR=new RegExp(/{{[D]?[A]?[T]?[E]?[}]?[}]?$/i),GR=new RegExp(/{{[D]?[A]?[T]?[E]?[:]?$|{{DATE:[^\n\r}]*}}$/i),YR=new RegExp(/{{[N]?[A]?[M]?[E]?[}]?[}]?$/i),KR=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[}]?[}]?$/i),QR=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[:]?$|{{VALUE:[^\n\r}]*}}$/i),XR=new RegExp(/{{[V]?[D]?[A]?[T]?[E]?[:]?$|{{VDATE:[^\n\r}]*}}$/i),ZR=new RegExp(/{{[L]?[I]?[N]?[K]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),JR=new RegExp(/^\{\{(?:l(?:i(?:n(?:k(?:s(?:e(?:c(?:t(?:i(?:o(?:n(?:\}\}?)?)?)?)?)?)?)?)?)?)?)?)?$/i),eN=new RegExp(/{{[F]?[I]?[L]?[E]?[N]?[A]?[M]?[E]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),IA=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),tN=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[}]?[}]?$/i),rN=new RegExp(/{{[F]?[I]?[L]?[E]?[:]?$/i),nN=new RegExp(/{{[F]?[I]?[E]?[L]?[D]?[:]?$/i),iN=new RegExp(/{{[T]?[E]?[M]?[P]?[L]?[A]?[T]?[E]?[:]?$|{{TEMPLATE:[^\n\r}]*[}]?[}]?$/i),oN=new RegExp(/{{[M]?[A]?[C]?[R]?[O]?[:]?$|{{MACRO:[^\n\r}]*}}$/i),sN=new RegExp(/{{[M]?[V]?[A]?[L]?[U]?[E]?[}]?[}]?/i),aN=new RegExp(/{{[T]?[I]?[T]?[L]?[E]?[}]?[}]?/i),lN=new RegExp(/{{[P]?[R]?[O]?[P]?[E]?[R]?[T]?[Y]?[}]?[}]?$/i),cN=/{{(?:C(?:U(?:R(?:S(?:O(?:R)?)?)?)?)?)?[}]?[}]?$/i,uN=new RegExp(/{{[S]?[E]?[L]?[E]?[C]?[T]?[E]?[D]?[}]?[}]?/i),dN=new RegExp(/{{[C]?[L]?[I]?[P]?[B]?[O]?[A]?[R]?[D]?[}]?[}]?$/i),pN=new RegExp(/{{[R]?[A]?[N]?[D]?[O]?[M]?[:]?$|{{RANDOM:[^\n\r}]*}}$/i),fN=new RegExp(/{{[G]?[L]?[O]?[B]?[A]?[L]?[_]?[V]?[A]?[R]?[:]?$|{{GLOBAL_VAR:[^\n\r}]*}}$/i),mN=new RegExp(/{{[T]?[I]?[M]?[E]?[}]?[}]?/i),hN=new RegExp(/{{[T]?[I]?[M]?[E]?[:]?$|{{TIME:[^\n\r}]*}}$/i),fC="__qa.",Ig=`${fC}captureTargetFilePath`,rl=`${fC}dateOrigin`,gN=new RegExp(/\[\[([^\]]*)\]\]/)});var mC=E(()=>{});var yt,Ni=E(()=>{yt=class extends Error{constructor(e){super(e||"Macro execution aborted"),this.name="MacroAbortError"}}});function Rr(){return new at(vc)}var at,vc,ur=E(()=>{Ni();at=class extends yt{},vc="Input cancelled by user"});function nl(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}let t=e?`${e}: ${String(r)}`:String(r);return new Error(t)}function ot(r){return r instanceof at?!0:typeof r=="string"&&p8.has(r)}function xN(r){return typeof r=="object"&&r!==null||typeof r=="function"}function h8(r,e){let t=r;for(let n=0;n{ad(n,r)};return(...n)=>{try{let i=e(...n);typeof i?.then=="function"&&Promise.resolve(i).catch(t)}catch(i){t(i)}}}var PA,p8,CN,f8,m8,xt=E(()=>{Ie();mC();ur();PA=100;p8=new Set(["no input given.","No input given.","cancelled"]),CN=new WeakMap,f8=1e4,m8=8});function gC(r,e){try{let t=r.workspace.getActiveViewOfType(SN.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 v8(r,e){return r!==null&&e!==null&&(r.line!==e.line||r.ch!==e.ch)}function TN(r){return typeof r!="string"?null:[...r.matchAll(g8)].length}function _N(r,e){let t=TN(r),n=TN(e);return t!==null&&n!==null&&t>n}function kN(r,e){return v8(r.cursor,e.cursor)||_N(r.value,e.value)}async function vC(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()-swindow.setTimeout(e,r))}async function bC(r,e,t={}){if(e.extension!=="md"||!Xp(r))return;let i=cd(r)?.templater?.files_with_pending_templates;if(!(i instanceof Set)){await AN(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()-a0)&&t.size===0){if(Fg){await Fg;return}Fg=(async()=>{try{r.workspace.trigger("templater:all-templates-executed"),await e.templater?.functions_generator?.teardown?.()}catch(n){I.logWarning(`withTemplaterFileCreationSuppressed: teardown failed \u2013 ${n.message}`)}})();try{await Fg}finally{Fg=null}}}async function OA(r,e,t){let n=cd(r),i=n?.templater?.files_with_pending_templates;if(!n||!Xp(r)||!(i instanceof Set))return await t();$A++;let o=MA.get(e);o||(o={count:0,hadPathInitially:i.has(e)},MA.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--,$A--,o.count<=0&&(MA.delete(e),o.hadPathInitially||(s&&await Pg(y8),i.delete(e),await b8(r,n,i)))}}async function AN(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,p=50;for(;Date.now()-d=i)return}else if(m-d>=o)return;p=Math.min(Math.floor(p*1.5),200)}}catch(s){I.logWarning(`waitForFileToStopChanging: fallback due to adapter/stat failure \u2013 ${s.message}`)}}async function w8(r,e){let t=hC.get(r)??Promise.resolve(),n,i=new Promise(s=>{n=()=>s()}),o=t.catch(()=>{}).then(()=>i);hC.set(r,o),o.finally(()=>{hC.get(r)===o&&hC.delete(r)}).catch(()=>{}),await t.catch(()=>{});try{return await e()}finally{n()}}async function yc(r,e,t={}){if(e.extension!=="md")return!1;let n=cd(r),i=n?.templater,o=i?.overwrite_file_commands;if(!n||!i||typeof o!="function")return!1;let{skipIfNoTags:s=!0,postWait:a=!0}=t;return await w8(e.path,async()=>{await vC(r,e);let l;try{l=await r.vault.read(e)}catch(d){return Ze(d,`overwriteTemplaterOnce: failed to read ${e.path} before render`),!1}if(s&&!l.includes("<%"))return!1;let c=null,u=r.workspace.on("templater:overwrite-file",d=>{d.file.path===e.path&&(c=d.content)});try{await o.call(i,e);let d=_N(c,gC(r,e).value);return a&&await vC(r,e,800),d}catch(d){try{await r.vault.modify(e,l)}catch(p){I.logWarning(`Failed to rollback ${e.path} after Templater error: ${p.message}`)}return Ze(d,`Templater failed on ${e.path}. Rolled back to pre-render state.`),!1}finally{r.workspace.offref(u)}})}async function il(r,e,t){if(t.extension!=="md")return e;let n=cd(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 ol(r,e){if(e.extension!=="md"||r.workspace.getActiveFile()?.path!==e.path)return!1;let t=cd(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=gC(r,e);if(typeof o=="function")try{return await o.call(i,e,!0),kN(s,gC(r,e))}catch(a){I.logWarning(`jumpToNextTemplaterCursorIfPossible: API failed \u2013 ${a.message}`)}try{return!r.commands.executeCommandById?.("templater-obsidian:jump-to-next-cursor-location")?!1:kN(s,gC(r,e))}catch{}return!1}var SN,g8,MA,$A,Fg,y8,hC,IN=E(()=>{SN=require("obsidian");Ie();xt();g8=/<%\s*tp\.file\.cursor\((?:-?[0-9]+(?:\.[0-9]+)?)?\)\s*%>/g;MA=new Map,$A=0,Fg=null,y8=350;hC=new Map});function xn(r){let e=r.workspace.getActiveViewOfType(DN.MarkdownView);return e?.editor?e:null}function sl(r){return xn(r)?.editor.getSelection()??""}var DN,ys=E(()=>{DN=require("obsidian")});function Zp(r){return C8.has(r)}function al(r){return r==="inFrontmatter"}function wC(r){return x8.has(r)}function E8(r,e,t){return r==="embed"&&t.type==="activeFile"&&Zp(e)?"embed":"link"}function T8(r,e,t,n){return r==="selection"&&t.type==="activeFile"&&wC(e)&&n==="link"?"selection":"none"}function k8(r){return r?.type==="specifiedFile"?{type:"specifiedFile",path:typeof r.path=="string"?r.path.trim():""}:{type:"activeFile"}}function S8(r){return typeof r=="object"&&r!==null&&"enabled"in r&&"placement"in r}function bc(r){if(S8(r)){let e=r.placement??"replaceSelection",t=k8(r.destination),n=E8(r.linkType,e,t);return{enabled:r.enabled,placement:e,requireActiveFile:r.requireActiveFile??!0,linkType:n,displayText:T8(r.displayText,e,t,n),destination:t,frontmatterProperty:r.frontmatterProperty,frontmatterHandling:al(e)?r.frontmatterHandling??ud:r.frontmatterHandling}}return{enabled:r,placement:"replaceSelection",requireActiveFile:!!r,linkType:"link",displayText:"none",destination:{type:"activeFile"}}}var ud,C8,x8,wc=E(()=>{ud="alwaysAppend",C8=new Set(["replaceSelection","afterSelection","endOfLine","newLine"]);x8=new Set(["replaceSelection","afterSelection"])});function _8(r){return r.vault.getConfig?.("useMarkdownLinks")===!0}function A8(r,e){let t=e.replace(/\s+/g,n=>/[\r\n]/.test(n)?" ":n).trim();if(t){if(_8(r))return t.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(!(t.includes("]]")||t.includes("[[")||t.endsWith("]")))return t}}function I8(r){return`[[${r.path.replace(/\.md$/i,"")}]]`}function CC(r,e,t={}){let n=t.sourcePath??"";if(t.linkType==="embed"&&(!t.placement||Zp(t.placement)))return`![[${r.metadataCache.fileToLinktext(e,n)}]]`;let o=t.alias===void 0?void 0:A8(r,t.alias);return o===void 0?r.fileManager.generateMarkdownLink(e,n):r.fileManager.generateMarkdownLink(e,n,void 0,o)}function RA(r){let e=r.trim().replace(/^\/+/,"");return e?/\.md$/i.test(e)?e:`${e}.md`:""}function $g(r,e){if(e.type!=="specifiedFile")return null;let t=RA(e.path);if(!t)return null;let n=r.vault.getAbstractFileByPath(t);return!(n instanceof Mg.TFile)||n.extension!=="md"?null:n}function D8(r,e){return r.length===0?e:r.endsWith(` `)?`${r}${e}`:`${r} ${e}`}async function PN(r,e,t,n){let i=t.destination;if(i?.type!=="specifiedFile")return!1;let o=$g(r,i);if(!o)throw new Error(`Append link target file not found or is not a Markdown file: ${i.path}`);let s=CC(r,e,{sourcePath:o.path,linkType:"link"}),a;return await r.vault.process(o,l=>{let c=D8(l,s);return a={filePath:o.path,before:l,after:c,edits:[{from:l.length,to:l.length,text:c.slice(l.length)}]},c}),a&&n?.(a),!0}async function F8(r){let e=window.navigator?.clipboard;if(!e?.writeText)return I.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return I.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function MN(r){let e=I8(r);return await F8(e)?(new Mg.Notice(`Copied link to '${r.basename}' to clipboard.`,FN),!0):(new Mg.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,FN),!1)}var Mg,FN,Og=E(()=>{Mg=require("obsidian");Ie();wc();FN=4e3});function io(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 Rg(r){let e=io(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function er(r,e){return io(r).win.createEl(e)}function Ng(r,e){return io(r).createTextNode(e)}var bs=E(()=>{});function xC(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=io(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(P8))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 M8(r,e,t){let n=NN(r,e),i=r[n];if(Array.isArray(i)){i.push(t);return}if(i==null||i===""){r[n]=t;return}if(typeof i=="string"){r[n]=`${i} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${n}' because it contains a ${typeof i} value.`)}function RN(r,e,t,n=ud){let i=NN(r,e),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o===null||o===""){r[i]=[t];return}if(o===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${i}' because it does not exist.`);r[i]=[t];return}if(typeof o=="object")throw new Error(`Cannot append link to frontmatter property '${i}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${i}' because it is not a list and the link-handling mode is '${$N[n]}'. Choose '${$N.alwaysAppend}' to convert it into a list and append.`);r[i]=[o,t]}function NN(r,e){if(e=e.trim(),!e)throw new Error("Cannot append link to an empty frontmatter property key.");let t=ON(e),n=Object.keys(r).filter(i=>ON(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 ON(r){return r.trim().toLowerCase()}async function LN(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{M8(i,e.key,n)}),!0}catch(i){return I.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 $N,P8,Lg=E(()=>{Ie();wc();bs();$N={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},P8=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function VN(r,e,t,n){let i=No(e,t);return i?NA(r,i.editor,n):null}function NA(r,e,t){if(r.cursor.kind==="none")return null;let n=r.content.replace(/\r\n?/g,` `),i=r.content.slice(0,r.cursor.value).replace(/\r\n?/g,` `).length,o=d=>e.posToOffset(d),s=e.getCursor(),a;if(t==="currentLine")a=e.listSelections().map(({anchor:d,head:p})=>({from:o(d)<=o(p)?d:p,to:o(d)<=o(p)?p:d,text:n,cursor:i}));else if(t==="newLineAbove"||t==="newLineBelow"){let d=t==="newLineAbove";a=[{from:{line:s.line,ch:d?0:e.getLine(s.line).length},text:d?n+` `:` `+n,cursor:i+(d?0:1)}]}else return null;let l=[],c=[],u=0;a.sort((d,p)=>o(d.from)-o(p.from));for(let d of a)l.push(o(d.from)+u+d.cursor),c.push(o(d.from)+u+d.text.length-(t==="newLineAbove"?1:0)),u+=d.text.length-(o(d.to??d.from)-o(d.from));return e.transaction({changes:a.map(({from:d,to:p,text:f})=>({from:d,to:p,text:f}))}),e.setSelections(c.map(d=>({anchor:e.offsetToPos(d)}))),{offsets:l,content:e.getValue()}}function No(r,e){let t=xn(r);return t?.file?.path===e.path?t:null}function LA(r,e){try{let t=xn(e);return t?(t.editor.replaceSelection(r),!0):(I.logError(`unable to append '${r}' to current line.`),!1)}catch{return I.logError(`unable to append '${r}' to current line.`),!1}}function VA(r,e,t){try{let n=xn(t);if(!n)return I.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 I.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function BA(r,e){return VA(r,"above",e)}function qA(r,e){return VA(r,"below",e)}function $8(r,e,t,n,i){let o=c=>r.posToOffset(c),s=e.map(c=>{let[u,d]=o(c.anchor)<=o(c.head)?[c.anchor,c.head]:[c.head,c.anchor];return{from:u,to:d,text:n(r.getRange(u,d))}}).sort((c,u)=>o(c.from)-o(u.from)),a=s.map(({from:c,to:u,text:d})=>t==="replaceSelection"?{from:c,to:u,text:d}:{from:u,text:d}),l=[];if(t==="replaceSelection"){let c=0;for(let{from:u,to:d,text:p}of s)l.push(o(u)+c+p.length),c+=p.length-(o(d)-o(u))}i(a,()=>r.transaction({changes:a})),t==="replaceSelection"&&r.setSelections(l.map(c=>({anchor:r.offsetToPos(c)})))}async function BN(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=ud,textForSelection:a,onEditorTextMutation:l}=n,c=r.workspace.getActiveViewOfType(EC.MarkdownView);if(!c){let g="Cannot append link because no active Markdown view is available.";if(i)throw new Error(g);I.logMessage(g);return}if(t==="inFrontmatter"){let g=c.file;if(!g)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(g,v=>{RN(v,o??"",e,s)});return}let u=c.editor;if(!u){let g="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(g);I.logMessage(g);return}let d=(g,v)=>{if(!l){v();return}let y=u.getValue(),b=g.map(x=>({from:u.posToOffset(x.from),to:u.posToOffset(x.to??x.from),text:x.text}));v(),l({filePath:c.file?.path??null,before:y,after:u.getValue(),edits:b})},p=u.listSelections().map(g=>({anchor:{...g.anchor},head:{...g.head}}));if(a&&p.length>0&&(t==="replaceSelection"||t==="afterSelection")){$8(u,p,t,a,d);return}if(t==="replaceSelection"){let g=p.map(({anchor:v,head:y})=>({from:u.posToOffset(v)<=u.posToOffset(y)?v:y,to:u.posToOffset(v)<=u.posToOffset(y)?y:v,text:e}));d(g,()=>u.replaceSelection(e));return}let f=({line:g,ch:v})=>u.posToOffset({line:g,ch:v}),m=p.sort((g,v)=>f(v.head)-f(g.head));for(let g of m){let v=f(g.anchor)>f(g.head)?g.anchor:g.head;switch(t){case"afterSelection":{d([{from:v,text:e}],()=>u.replaceRange(e,v));break}case"endOfLine":case"newLine":{let y=u.getLine(v.line).length,b=t==="newLine"&&y>0?` `:"",x={line:v.line,ch:y};d([{from:x,text:b+e}],()=>u.replaceRange(b+e,x));break}}}}async function TC(r,e,t,n){if(!t?.enabled)return!1;let i=bc(t),o=r.workspace.getActiveViewOfType(EC.MarkdownView),s=i.placement!=="inFrontmatter";if(!o||!o.file||s&&!o.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let a=o.file.path,l=CC(r,e,{sourcePath:a,linkType:i.linkType,placement:i.placement}),c=i.displayText==="selection"?u=>CC(r,e,{sourcePath:a,linkType:i.linkType,placement:i.placement,alias:u}):void 0;return await BN(r,l,i.placement,{requireActiveView:!1,frontmatterProperty:i.frontmatterProperty,frontmatterHandling:i.frontmatterHandling,textForSelection:c,onEditorTextMutation:n}),!0}function UA(r,e,t,n){return Vg(r,e,[t],n)}function Vg(r,e,t,n){try{if(e.extension!=="md"||!t.length||t.some(c=>!Number.isSafeInteger(c)||c<0||c>n.length))return!1;let i=r.workspace.getActiveViewOfType(EC.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;if(!o)return!1;let s=o.getValue(),a=t;if(s!==n){if(s!==n.replace(/\r\n?/g,` `))return!1;a=t.map(c=>n.slice(0,c).replace(/\r\n?/g,` `).length)}a.length===1?o.setCursor(o.offsetToPos(a[0])):o.setSelections(a.map(c=>({anchor:o.offsetToPos(c)})));let l=i.containerEl?.ownerDocument;return l&&l.activeElement===l.body&&o.focus(),!0}catch{return I.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var EC,Bg=E(()=>{EC=require("obsidian");ys();Ie();wc();Og();Lg()});function kC(r){return Nt.test(r)||cr.test(r)||wn.test(r)}function Vn(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=kC(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof qN.TFile?i:null}function ri(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 HA(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var qN,qg=E(()=>{qN=require("obsidian");Xe()});function HN(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Ug(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function O8(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function UN(r){return r.parent?.id??r.parent??null}function R8(r,e){let t=UN(e),n=r.filter(s=>s===e||HN(s)?!1:t===null||UN(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 N8(r){return r instanceof Jp.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function L8(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&HN(n))return R8(O8(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 Hg(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(!N8(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??Ug(r),d=s?null:r.workspace.activeLeaf,p=L8(r,n,i,u);if(!p)throw new Error("Could not obtain a workspace leaf.");if(d&&r.workspace.activeLeaf!==d&&r.workspace.setActiveLeaf(d,{focus:!1}),s?await p.openFile(c):await p.openFile(c,{active:!1}),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=p.getViewState(),m={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(m.mode="preview",delete m.source):o==="source"?(m.mode="source",m.source=!0):o==="live"||o==="live-preview"?(m.mode="source",m.source=!1):typeof o=="object"&&o.mode==="source"&&(m.mode="source",m.source=o.source),await p.setViewState({...f,...!s&&{active:!1},state:{...m,...a}})}return s&&r.workspace.setActiveLeaf(p,{focus:!0}),p}function zA(r){return(0,Jp.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function zN(r,e){return zA(r)===zA(e)}function WA(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{if(n&&n===r.workspace.activeLeaf)return;let o=i.view;if(o instanceof Jp.FileView&&o.file&&(o.file===e||zN(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var Jp,WN=E(()=>{Jp=require("obsidian")});function ll(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=V8.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return jN(r.slice(o,e),s)}else if(d){let p=d[2].trim().split(/\s+/)[0]?.toLowerCase();(p==="js"||p==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?jN(r.slice(o),s):{code:null,error:B8}}function jN(r,e){return r.trim().length===0?{code:"",error:q8}:{code:` `.repeat(e)+r}}var V8,B8,q8,zg=E(()=>{V8=/^ {0,3}(`{3,})(.*)$/,B8="No ```js (or ```javascript) code block found in the note.",q8="The ```js code block is empty."});function GN(r){return r instanceof SC}function H8(r){return r.charCodeAt(0)===65279?r.slice(1):r}function z8(r){return H8(r).trimStart().slice(0,U8).toLowerCase()}function W8(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(z8(r))}function jA(r,e){let t=new SC(r);throw e.reportLoadErrors!==!1&&Ze(t),t}function j8(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 G8(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 Y8(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 K8(r){return YN(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function YN(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 Q8(r){return r!==null&&typeof r=="object"}function X8(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function Z8(r){return typeof r=="function"?!0:Q8(r)?X8(r):!1}function dd(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function AC(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=dd(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function Lo(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){I.logError(`failed to load file ${r.path}.`);return}if(n instanceof _C.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(Nt.test(n.path)){let{code:m,error:g}=ll(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new _C.Notice(`QuickAdd: ${g} (${r.path})`);return}l=m}W8(l)&&jA(j8(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw YN(m)&&jA(Y8(r.path,K8(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:p}=dd(r.name),f=!!(p&&p.length>0);if(p&&p.length>0){let m;for(;m=p.shift();)u=u[m]}return d&&!f&&!Z8(u)&&jA(G8(r.path),t),u}}var _C,U8,SC,IC=E(()=>{_C=require("obsidian");Xe();Ie();zg();xt();U8=1024,SC=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function ef(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 Wg(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(ef).filter(Boolean)}var GA=E(()=>{});var xi,pd=E(()=>{GA();xi=class{static filterFiles(e,t,n){let i=this.applyInclusionFilters(e,t,n);return this.applyExclusionFilters(i,t,n)}static applyInclusionFilters(e,t,n){let i=e,o=this.getIncludeFolders(t);return o.length>0&&(i=i.filter(s=>o.some(a=>this.matchesFolder(s,a)))),t.tags&&t.tags.length>0&&(i=i.filter(s=>this.matchesTags(s,t.tags??[],n,"all"))),i}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders?.length&&t.excludeFolders.some(o=>this.matchesFolder(i,o)))&&!(t.excludeTags?.length&&this.matchesTags(i,t.excludeTags,n,"any"))&&!(t.excludeFiles?.length&&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 matchesTags(e,t,n,i){let o=n(e);if(!o)return!1;let s=this.getAllTags(o),a=t.map(ef).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(...Wg(e.frontmatter.tags)),e.frontmatter?.tag&&t.push(...Wg(e.frontmatter.tag)),e.tags&&t.push(...e.tags.map(n=>ef(n.tag))),t.filter(Boolean)}static normalizePath(e){return e.replace(/^\/+|\/+$/g,"")}}});function Vo(r){return r.vault.getAllLoadedFiles().filter(e=>e instanceof YA.TFolder).map(e=>e.path)}function tf(r,e){let t=r.vault.getAbstractFileByPath(e);return!!t&&t instanceof YA.TFolder}function Bo(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 J8(r){return Object.entries(r.frontmatter??{}).filter(([e])=>["tag","tags"].includes(e.toLowerCase())).flatMap(([,e])=>Wg(e)).filter(Boolean)}function e5(r,e){let t=r.metadataCache.getFileCache(e);if(!t)return[];let n=[];return t.frontmatter&&n.push(...J8(t)),t.tags&&Array.isArray(t.tags)&&n.push(...t.tags.map(i=>ef(i.tag))),n}function KA(r,e){let t=e.replace(/^#/,"");return r.vault.getMarkdownFiles().filter(n=>e5(r,n).includes(t))}function jg(r,e){return xi.filterFiles(r.vault.getMarkdownFiles(),e,t=>r.metadataCache.getFileCache(t))}function t5(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 Gg(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:t5(c[1],t):!1});return n&&(n.folder||n.tags?.length||n.excludeFolders?.length||n.excludeTags?.length||n.excludeFiles?.length)&&(o=xi.filterFiles(o,n,a=>r.metadataCache.getFileCache(a))),o}var YA,KN=E(()=>{YA=require("obsidian");pd();GA()});function QN(r,e){return r.commands.findCommand(e)}function DC(r,e){QN(r,e)&&(delete r.commands.commands[e],delete r.commands.editorCommands[e])}var XN=E(()=>{});function qo(r){return r.split("|")}function ZN(r){return r.startsWith("|")?r.slice(1):r}function Uo(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 Cc(r){if(!r)return!0;let e=r.trim().toLowerCase();return!["false","no","0","off"].includes(e)}function ws(r,e){let t=!1;return{remaining:r.filter(i=>i.trim().toLowerCase()===e?(t=!0,!1):!0),found:t}}var xc=E(()=>{});function FC(r){let e=r.trim().toLowerCase(),t=r5[e];if(!t)throw new Error(`Unknown date unit "${r.trim()}". Valid units: ${n5}.`);return t}function JN(r){let e=Uo(r);return e?e.key==="startof"?{boundary:"start",unit:FC(e.value)}:e.key==="endof"?{boundary:"end",unit:FC(e.value)}:null:null}function rf(r,e){return e?e.boundary==="start"?r.startOf(e.unit):r.endOf(e.unit):r}var r5,n5,Yg=E(()=>{xc();r5={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"},n5="year, quarter, month, week, isoweek, day"});function i5(r){return r===void 0?window.moment():window.moment(r)}function o5(r){let e=i5(r?.now);return r?.origin?window.moment(r.origin).hour(e.hour()).minute(e.minute()).second(e.second()).millisecond(e.millisecond()):e}function aa(r){let e;return r?.offset!==null&&r?.offset!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),rf(o5(r).add(e),r?.snap).format(r?.format??"YYYY-MM-DD")}var eL=E(()=>{Yg()});var ht=E(()=>{IN();Bg();qg();WN();IC();KN();XN();eL()});function cl(r){return/\{\{[^}]*\}\}/.test(r)}var Kg=E(()=>{});var Cr,en,Nr,Ir,PC,Ec,ul,fd,tL,MC,nf,rL,QA,$C,s5,a5,l5,c5,u5,d5,p5,f5,m5,nL,oo=E(()=>{Cr="top",en="bottom",Nr="right",Ir="left",PC="auto",Ec=[Cr,en,Nr,Ir],ul="start",fd="end",tL="clippingParents",MC="viewport",nf="popper",rL="reference",QA=Ec.reduce(function(r,e){return r.concat([e+"-"+ul,e+"-"+fd])},[]),$C=[].concat(Ec,[PC]).reduce(function(r,e){return r.concat([e,e+"-"+ul,e+"-"+fd])},[]),s5="beforeRead",a5="read",l5="afterRead",c5="beforeMain",u5="main",d5="afterMain",p5="beforeWrite",f5="write",m5="afterWrite",nL=[s5,a5,l5,c5,u5,d5,p5,f5,m5]});function En(r){return r?(r.nodeName||"").toLowerCase():null}var Tc=E(()=>{});function dr(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}var Cs=E(()=>{});function Ho(r){var e=dr(r).Element;return r instanceof e||r instanceof Element}function tn(r){var e=dr(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function of(r){if(typeof ShadowRoot>"u")return!1;var e=dr(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}var so=E(()=>{Cs()});function h5(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];!tn(o)||!En(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 g5(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},{});!tn(i)||!En(i)||(Object.assign(i.style,a),Object.keys(o).forEach(function(l){i.removeAttribute(l)}))})}}var iL,oL=E(()=>{Tc();so();iL={name:"applyStyles",enabled:!0,phase:"write",fn:h5,effect:g5,requires:["computeStyles"]}});function Tn(r){return r.split("-")[0]}var kc=E(()=>{});var xs,md,dl,Sc=E(()=>{xs=Math.max,md=Math.min,dl=Math.round});function sf(){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 XA=E(()=>{});function Qg(){return!/^((?!chrome|android).)*safari/i.test(sf())}var ZA=E(()=>{XA()});function zo(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var n=r.getBoundingClientRect(),i=1,o=1;e&&tn(r)&&(i=r.offsetWidth>0&&dl(n.width)/r.offsetWidth||1,o=r.offsetHeight>0&&dl(n.height)/r.offsetHeight||1);var s=Ho(r)?dr(r):window,a=s.visualViewport,l=!Qg()&&t,c=(n.left+(l&&a?a.offsetLeft:0))/i,u=(n.top+(l&&a?a.offsetTop:0))/o,d=n.width/i,p=n.height/o;return{width:d,height:p,top:u,right:c+d,bottom:u+p,left:c,x:c,y:u}}var af=E(()=>{so();Sc();Cs();ZA()});function hd(r){var e=zo(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 OC=E(()=>{af()});function Xg(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&of(t)){var n=e;do{if(n&&r.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}var JA=E(()=>{so()});function Ei(r){return dr(r).getComputedStyle(r)}var lf=E(()=>{Cs()});function eI(r){return["table","td","th"].indexOf(En(r))>=0}var sL=E(()=>{Tc()});function Bn(r){return((Ho(r)?r.ownerDocument:r.document)||window.document).documentElement}var pl=E(()=>{so()});function fl(r){return En(r)==="html"?r:r.assignedSlot||r.parentNode||(of(r)?r.host:null)||Bn(r)}var Zg=E(()=>{Tc();pl();so()});function aL(r){return!tn(r)||Ei(r).position==="fixed"?null:r.offsetParent}function v5(r){var e=/firefox/i.test(sf()),t=/Trident/i.test(sf());if(t&&tn(r)){var n=Ei(r);if(n.position==="fixed")return null}var i=fl(r);for(of(i)&&(i=i.host);tn(i)&&["html","body"].indexOf(En(i))<0;){var o=Ei(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 Es(r){for(var e=dr(r),t=aL(r);t&&eI(t)&&Ei(t).position==="static";)t=aL(t);return t&&(En(t)==="html"||En(t)==="body"&&Ei(t).position==="static")?e:t||v5(r)||e}var cf=E(()=>{Cs();Tc();lf();so();sL();Zg();XA()});function gd(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}var RC=E(()=>{});function vd(r,e,t){return xs(r,md(e,t))}function lL(r,e,t){var n=vd(r,e,t);return n>t?t:n}var tI=E(()=>{Sc()});function Jg(){return{top:0,right:0,bottom:0,left:0}}var rI=E(()=>{});function ev(r){return Object.assign({},Jg(),r)}var nI=E(()=>{rI()});function tv(r,e){return e.reduce(function(t,n){return t[n]=r,t},{})}var iI=E(()=>{});function b5(r){var e,t=r.state,n=r.name,i=r.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,a=Tn(t.placement),l=gd(a),c=[Ir,Nr].indexOf(a)>=0,u=c?"height":"width";if(!(!o||!s)){var d=y5(i.padding,t),p=hd(o),f=l==="y"?Cr:Ir,m=l==="y"?en:Nr,g=t.rects.reference[u]+t.rects.reference[l]-s[l]-t.rects.popper[u],v=s[l]-t.rects.reference[l],y=Es(o),b=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,x=g/2-v/2,w=d[f],T=b-p[u]-d[m],C=b/2-p[u]/2+x,S=vd(w,C,T),A=l;t.modifiersData[n]=(e={},e[A]=S,e.centerOffset=S-C,e)}}function w5(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)||Xg(e.elements.popper,i)&&(e.elements.arrow=i))}var y5,cL,uL=E(()=>{kc();OC();JA();cf();RC();tI();nI();iI();oo();y5=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,ev(typeof e!="number"?e:tv(e,Ec))};cL={name:"arrow",enabled:!0,phase:"main",fn:b5,effect:w5,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]}});function Wo(r){return r.split("-")[1]}var uf=E(()=>{});function x5(r,e){var t=r.x,n=r.y,i=e.devicePixelRatio||1;return{x:dl(t*i)/i||0,y:dl(n*i)/i||0}}function dL(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,p=s.x,f=p===void 0?0:p,m=s.y,g=m===void 0?0:m,v=typeof u=="function"?u({x:f,y:g}):{x:f,y:g};f=v.x,g=v.y;var y=s.hasOwnProperty("x"),b=s.hasOwnProperty("y"),x=Ir,w=Cr,T=window;if(c){var C=Es(t),S="clientHeight",A="clientWidth";if(C===dr(t)&&(C=Bn(t),Ei(C).position!=="static"&&a==="absolute"&&(S="scrollHeight",A="scrollWidth")),C=C,i===Cr||(i===Ir||i===Nr)&&o===fd){w=en;var D=d&&C===T&&T.visualViewport?T.visualViewport.height:C[S];g-=D-n.height,g*=l?1:-1}if(i===Ir||(i===Cr||i===en)&&o===fd){x=Nr;var P=d&&C===T&&T.visualViewport?T.visualViewport.width:C[A];f-=P-n.width,f*=l?1:-1}}var U=Object.assign({position:a},c&&C5),K=u===!0?x5({x:f,y:g},dr(t)):{x:f,y:g};if(f=K.x,g=K.y,l){var W;return Object.assign({},U,(W={},W[w]=b?"0":"",W[x]=y?"0":"",W.transform=(T.devicePixelRatio||1)<=1?"translate("+f+"px, "+g+"px)":"translate3d("+f+"px, "+g+"px, 0)",W))}return Object.assign({},U,(e={},e[w]=b?g+"px":"",e[x]=y?f+"px":"",e.transform="",e))}function E5(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:Tn(e.placement),variation:Wo(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,dL(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,dL(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 C5,pL,fL=E(()=>{oo();cf();Cs();pl();lf();kc();uf();Sc();C5={top:"auto",right:"auto",bottom:"auto",left:"auto"};pL={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:E5,data:{}}});function T5(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=dr(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(u){u.addEventListener("scroll",t.update,NC)}),a&&l.addEventListener("resize",t.update,NC),function(){o&&c.forEach(function(u){u.removeEventListener("scroll",t.update,NC)}),a&&l.removeEventListener("resize",t.update,NC)}}var NC,mL,hL=E(()=>{Cs();NC={passive:!0};mL={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:T5,data:{}}});function df(r){return r.replace(/left|right|bottom|top/g,function(e){return k5[e]})}var k5,gL=E(()=>{k5={left:"right",right:"left",bottom:"top",top:"bottom"}});function LC(r){return r.replace(/start|end/g,function(e){return S5[e]})}var S5,vL=E(()=>{S5={start:"end",end:"start"}});function yd(r){var e=dr(r),t=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:t,scrollTop:n}}var VC=E(()=>{Cs()});function bd(r){return zo(Bn(r)).left+yd(r).scrollLeft}var BC=E(()=>{af();pl();VC()});function oI(r,e){var t=dr(r),n=Bn(r),i=t.visualViewport,o=n.clientWidth,s=n.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;var c=Qg();(c||!c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a+bd(r),y:l}}var yL=E(()=>{Cs();pl();BC();ZA()});function sI(r){var e,t=Bn(r),n=yd(r),i=(e=r.ownerDocument)==null?void 0:e.body,o=xs(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=xs(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-n.scrollLeft+bd(r),l=-n.scrollTop;return Ei(i||t).direction==="rtl"&&(a+=xs(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}var bL=E(()=>{pl();lf();BC();VC();Sc()});function wd(r){var e=Ei(r),t=e.overflow,n=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+n)}var qC=E(()=>{lf()});function UC(r){return["html","body","#document"].indexOf(En(r))>=0?r.ownerDocument.body:tn(r)&&wd(r)?r:UC(fl(r))}var wL=E(()=>{Zg();qC();Tc();so()});function _c(r,e){var t;e===void 0&&(e=[]);var n=UC(r),i=n===((t=r.ownerDocument)==null?void 0:t.body),o=dr(n),s=i?[o].concat(o.visualViewport||[],wd(n)?n:[]):n,a=e.concat(s);return i?a:a.concat(_c(fl(s)))}var aI=E(()=>{wL();Zg();Cs();qC()});function pf(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}var lI=E(()=>{});function _5(r,e){var t=zo(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 CL(r,e,t){return e===MC?pf(oI(r,t)):Ho(e)?_5(e,t):pf(sI(Bn(r)))}function A5(r){var e=_c(fl(r)),t=["absolute","fixed"].indexOf(Ei(r).position)>=0,n=t&&tn(r)?Es(r):r;return Ho(n)?e.filter(function(i){return Ho(i)&&Xg(i,n)&&En(i)!=="body"}):[]}function cI(r,e,t,n){var i=e==="clippingParents"?A5(r):[].concat(e),o=[].concat(i,[t]),s=o[0],a=o.reduce(function(l,c){var u=CL(r,c,n);return l.top=xs(u.top,l.top),l.right=md(u.right,l.right),l.bottom=md(u.bottom,l.bottom),l.left=xs(u.left,l.left),l},CL(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 xL=E(()=>{oo();yL();bL();aI();cf();pl();lf();so();af();Zg();JA();Tc();lI();Sc()});function rv(r){var e=r.reference,t=r.element,n=r.placement,i=n?Tn(n):null,o=n?Wo(n):null,s=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(i){case Cr:l={x:s,y:e.y-t.height};break;case en:l={x:s,y:e.y+e.height};break;case Nr:l={x:e.x+e.width,y:a};break;case Ir:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var c=i?gd(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(o){case ul:l[c]=l[c]-(e[u]/2-t[u]/2);break;case fd:l[c]=l[c]+(e[u]/2-t[u]/2);break;default:}}return l}var uI=E(()=>{kc();uf();RC();oo()});function Ts(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?tL:a,c=t.rootBoundary,u=c===void 0?MC:c,d=t.elementContext,p=d===void 0?nf:d,f=t.altBoundary,m=f===void 0?!1:f,g=t.padding,v=g===void 0?0:g,y=ev(typeof v!="number"?v:tv(v,Ec)),b=p===nf?rL:nf,x=r.rects.popper,w=r.elements[m?b:p],T=cI(Ho(w)?w:w.contextElement||Bn(r.elements.popper),l,u,s),C=zo(r.elements.reference),S=rv({reference:C,element:x,strategy:"absolute",placement:i}),A=pf(Object.assign({},x,S)),D=p===nf?A:C,P={top:T.top-D.top+y.top,bottom:D.bottom-T.bottom+y.bottom,left:T.left-D.left+y.left,right:D.right-T.right+y.right},U=r.modifiersData.offset;if(p===nf&&U){var K=U[i];Object.keys(P).forEach(function(W){var ee=[Nr,en].indexOf(W)>=0?1:-1,me=[Cr,en].indexOf(W)>=0?"y":"x";P[W]+=K[me]*ee})}return P}var nv=E(()=>{xL();pl();af();uI();lI();oo();so();nI();iI()});function dI(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?$C:l,u=Wo(n),d=u?a?QA:QA.filter(function(m){return Wo(m)===u}):Ec,p=d.filter(function(m){return c.indexOf(m)>=0});p.length===0&&(p=d);var f=p.reduce(function(m,g){return m[g]=Ts(r,{placement:g,boundary:i,rootBoundary:o,padding:s})[Tn(g)],m},{});return Object.keys(f).sort(function(m,g){return f[m]-f[g]})}var EL=E(()=>{uf();oo();nv();kc()});function I5(r){if(Tn(r)===PC)return[];var e=df(r);return[LC(r),e,LC(e)]}function D5(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,p=t.altBoundary,f=t.flipVariations,m=f===void 0?!0:f,g=t.allowedAutoPlacements,v=e.options.placement,y=Tn(v),b=y===v,x=l||(b||!m?[df(v)]:I5(v)),w=[v].concat(x).reduce(function(ue,be){return ue.concat(Tn(be)===PC?dI(e,{placement:be,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:g}):be)},[]),T=e.rects.reference,C=e.rects.popper,S=new Map,A=!0,D=w[0],P=0;P=0,me=ee?"width":"height",O=Ts(e,{placement:U,boundary:u,rootBoundary:d,altBoundary:p,padding:c}),H=ee?W?Nr:Ir:W?en:Cr;T[me]>C[me]&&(H=df(H));var ce=df(H),te=[];if(o&&te.push(O[K]<=0),a&&te.push(O[H]<=0,O[ce]<=0),te.every(function(ue){return ue})){D=U,A=!1;break}S.set(U,te)}if(A)for(var z=m?3:1,G=function(be){var Ke=w.find(function(Oe){var Ee=S.get(Oe);if(Ee)return Ee.slice(0,be).every(function(He){return He})});if(Ke)return D=Ke,"break"},ie=z;ie>0;ie--){var xe=G(ie);if(xe==="break")break}e.placement!==D&&(e.modifiersData[n]._skip=!0,e.placement=D,e.reset=!0)}}var TL,kL=E(()=>{gL();kc();vL();nv();EL();oo();uf();TL={name:"flip",enabled:!0,phase:"main",fn:D5,requiresIfExists:["offset"],data:{_skip:!1}}});function SL(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 _L(r){return[Cr,Nr,en,Ir].some(function(e){return r[e]>=0})}function F5(r){var e=r.state,t=r.name,n=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=Ts(e,{elementContext:"reference"}),a=Ts(e,{altBoundary:!0}),l=SL(s,n),c=SL(a,i,o),u=_L(l),d=_L(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 AL,IL=E(()=>{oo();nv();AL={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:F5}});function P5(r,e,t){var n=Tn(r),i=[Ir,Cr].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,[Ir,Nr].indexOf(n)>=0?{x:a,y:s}:{x:s,y:a}}function M5(r){var e=r.state,t=r.options,n=r.name,i=t.offset,o=i===void 0?[0,0]:i,s=$C.reduce(function(u,d){return u[d]=P5(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 DL,FL=E(()=>{kc();oo();DL={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:M5}});function $5(r){var e=r.state,t=r.name;e.modifiersData[t]=rv({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var PL,ML=E(()=>{uI();PL={name:"popperOffsets",enabled:!0,phase:"read",fn:$5,data:{}}});function pI(r){return r==="x"?"y":"x"}var $L=E(()=>{});function O5(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,p=t.tether,f=p===void 0?!0:p,m=t.tetherOffset,g=m===void 0?0:m,v=Ts(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),y=Tn(e.placement),b=Wo(e.placement),x=!b,w=gd(y),T=pI(w),C=e.modifiersData.popperOffsets,S=e.rects.reference,A=e.rects.popper,D=typeof g=="function"?g(Object.assign({},e.rects,{placement:e.placement})):g,P=typeof D=="number"?{mainAxis:D,altAxis:D}:Object.assign({mainAxis:0,altAxis:0},D),U=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,K={x:0,y:0};if(C){if(o){var W,ee=w==="y"?Cr:Ir,me=w==="y"?en:Nr,O=w==="y"?"height":"width",H=C[w],ce=H+v[ee],te=H-v[me],z=f?-A[O]/2:0,G=b===ul?S[O]:A[O],ie=b===ul?-A[O]:-S[O],xe=e.elements.arrow,ue=f&&xe?hd(xe):{width:0,height:0},be=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:Jg(),Ke=be[ee],Oe=be[me],Ee=vd(0,S[O],ue[O]),He=x?S[O]/2-z-Ee-Ke-P.mainAxis:G-Ee-Ke-P.mainAxis,Le=x?-S[O]/2+z+Ee+Oe+P.mainAxis:ie+Ee+Oe+P.mainAxis,At=e.elements.arrow&&Es(e.elements.arrow),mr=At?w==="y"?At.clientTop||0:At.clientLeft||0:0,zr=(W=U?.[w])!=null?W:0,ge=H+He-zr-mr,ve=H+Le-zr,Fe=vd(f?md(ce,ge):ce,H,f?xs(te,ve):te);C[w]=Fe,K[w]=Fe-H}if(a){var Je,mt=w==="x"?Cr:Ir,Ft=w==="x"?en:Nr,Qe=C[T],zt=T==="y"?"height":"width",rr=Qe+v[mt],Qn=Qe-v[Ft],di=[Cr,Ir].indexOf(y)!==-1,Z=(Je=U?.[T])!=null?Je:0,De=di?rr:Qe-S[zt]-A[zt]-Z+P.altAxis,Pt=di?Qe+S[zt]+A[zt]-Z-P.altAxis:Qn,It=f&&di?lL(De,Qe,Pt):vd(f?De:rr,Qe,f?Pt:Qn);C[T]=It,K[T]=It-Qe}e.modifiersData[n]=K}}var OL,RL=E(()=>{oo();kc();RC();$L();tI();OC();cf();nv();uf();rI();Sc();OL={name:"preventOverflow",enabled:!0,phase:"main",fn:O5,requiresIfExists:["offset"]}});var fI=E(()=>{});function mI(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}var NL=E(()=>{});function hI(r){return r===dr(r)||!tn(r)?yd(r):mI(r)}var LL=E(()=>{VC();Cs();so();NL()});function R5(r){var e=r.getBoundingClientRect(),t=dl(e.width)/r.offsetWidth||1,n=dl(e.height)/r.offsetHeight||1;return t!==1||n!==1}function gI(r,e,t){t===void 0&&(t=!1);var n=tn(e),i=tn(e)&&R5(e),o=Bn(e),s=zo(r,i,t),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(n||!n&&!t)&&((En(e)!=="body"||wd(o))&&(a=hI(e)),tn(e)?(l=zo(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):o&&(l.x=bd(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}var VL=E(()=>{af();LL();Tc();so();BC();pl();qC();Sc()});function N5(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 vI(r){var e=N5(r);return nL.reduce(function(t,n){return t.concat(e.filter(function(i){return i.phase===n}))},[])}var BL=E(()=>{oo()});function yI(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}var qL=E(()=>{});function bI(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 UL=E(()=>{});function zL(){for(var r=arguments.length,e=new Array(r),t=0;t{VL();OC();aI();cf();BL();qL();UL();so();HL={placement:"bottom",modifiers:[],strategy:"absolute"}});var L5,wI,GL=E(()=>{jL();hL();ML();fL();oL();FL();kL();RL();uL();IL();fI();L5=[mL,PL,pL,iL,DL,TL,OL,cL,AL],wI=WL({defaultModifiers:L5})});var YL=E(()=>{oo();fI();GL()});function KL(r,e){return V5.test(r[e])}function B5(r){if(!r.includes("![["))return r;let e="",t=0,n=0,i=0;for(;ne&&r.charCodeAt(t-1)===35){for(;t>e&&r.charCodeAt(t-1)===35;)t--;for(;t>e&&KL(r,t-1);)t--}return r.slice(e,t)}function H5(r){if(!r.includes("[[")&&!r.includes("]]"))return r;let e="",t=0,n=0;for(;n{V5=/^\s$/;z5=/[*_`~]/g});function kn(r){return typeof r=="string"?r:r==null?"":String(r)}function XL(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 ff(r){let e=!1;return t=>{e||(e=!0,I.logWarning(nl(t,r)))}}function Ac(r){return kn(r)}function tr(r){return r.normalize("NFC").toLowerCase()}function iv(r){return r.toLowerCase().endsWith(".md")?r.slice(0,-3):r}function HC(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 ZL(r,e,t){if(r.replaceChildren(),!t){r.textContent=e;return}let n="",i=[],o=[],s=0;for(let d of e){let p=d.toLowerCase(),f=s,m=s+d.length;for(let g=0;gd){d>l&&r.append(Ng(r,e.slice(l,d)));let f=er(r,"mark");f.className="qa-highlight",f.textContent=e.slice(d,p),r.append(f),l=p}c=u+a.length,u=n.indexOf(a,c)}l{Ie();bs();xt();QL()});var zC,W5,j5,xI,ov,xr,ks=E(()=>{YL();zC=require("obsidian");Ie();bs();rn();W5=(r,e)=>(r%e+e)%e,j5=0,xI=class{constructor(e,t,n,i,o){this.isOpen=!1;this.owner=e,this.containerEl=t,this.optionIdPrefix=i,this.onActiveOptionChange=o,this.clickListener=a=>{let l=this.findSuggestionItem(a.target);l&&this.onSuggestionClick(a,l)},this.mousemoveListener=a=>{let l=this.findSuggestionItem(a.target);l&&this.onSuggestionMouseover(a,l)},t.addEventListener("click",this.clickListener),t.addEventListener("mousemove",this.mousemoveListener);let s={ArrowUp:()=>this.selectedItem-1,ArrowDown:()=>this.selectedItem+1,PageUp:()=>Math.max(0,this.selectedItem-5),PageDown:()=>Math.min(this.suggestions.length-1,this.selectedItem+5)};for(let[a,l]of Object.entries(s))n.register([],a,c=>{if(!c.isComposing&&this.isOpen)return this.setSelectedItem(l(),!0),!1});n.register([],"Enter",a=>{if(!a.isComposing&&this.isOpen)return this.useSelectedItem(a),!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=[];if(e.forEach((n,i)=>{let o=this.containerEl.createDiv({cls:"suggestion-item"});o.setAttribute("role","option"),o.setAttribute("aria-selected","false"),o.setAttribute("id",`${this.optionIdPrefix}-option-${i}`),this.owner.renderSuggestion(n,o),t.push(o)}),this.values=e,this.suggestions=t,e.length===0){this.isOpen=!1,this.onActiveOptionChange(null);return}this.setSelectedItem(0,!1),this.isOpen=!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=W5(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.onActiveOptionChange(o?.id??null),this.selectedItem=n,t&&o.scrollIntoView(!1)}close(){this.isOpen=!1,this.onActiveOptionChange(null)}getIsOpen(){return this.isOpen}},ov=new WeakMap,xr=class{constructor(e,t,n){this.popper=null;this.currentRequestId=0;this.isOpen=!1;this.destroyed=!1;this.currentQuery="";this.renderMatch=ZL;let i=this.constructor.name,o=ov.get(t);o||(o=new Map,ov.set(t,o));let s=o.get(i);s&&s.destroy(),ov.set(t,o),o.set(i,this),this.app=e,this.inputEl=t,this.scope=new zC.Scope(n),this.suggestEl=this.inputEl.ownerDocument.win.createDiv(),this.suggestEl.classList.add("suggestion-container");let a=this.suggestEl.createDiv({cls:"suggestion"});this.listboxId=`qa-suggest-listbox-${++j5}`,a.id=this.listboxId,a.setAttribute("role","listbox"),a.setAttribute("aria-label","Suggestions"),this.suggest=new xI(this,a,this.scope,this.listboxId,l=>this.setActiveDescendant(l)),this.scope.register([],"Escape",this.close.bind(this)),this.debouncedOnInputChanged=(0,zC.debounce)(this.onInputChanged.bind(this),50),this.inputEventListener=l=>this.debouncedOnInputChanged(l),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("role","combobox"),this.inputEl.setAttribute("aria-autocomplete","list"),this.inputEl.setAttribute("aria-expanded","false"),this.inputEl.setAttribute("aria-controls",this.listboxId),this.inputEl.setAttribute("aria-haspopup","listbox"),this.suggestEl.addEventListener("mousedown",l=>{l.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||this.inputEl.closest("[hidden]"))return;let t=!!(e?.fromCompletion&&e.keepOpen);if(e?.fromCompletion&&!t)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?.length){(t||this.isOpen)&&this.close();return}this.suggest.setSuggestions(o),(!t||!this.isOpen)&&this.open(this.app.dom.appContainerEl,this.inputEl)}catch(o){I.logError(o),t||this.close()}}open(e,t){if(this.destroyed||t.closest("[hidden]"))return;this.isOpen||this.app.keymap.pushScope(this.scope),this.isOpen=!0,this.inputEl.setAttribute("aria-expanded","true"),this.inputEl.setAttribute("aria-controls",this.listboxId);let n=io(t);if((io(e)===n?e:n.body).appendChild(this.suggestEl),this.popper){this.popper.update();return}this.popper=wI(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=Rg(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.currentRequestId++,!this.isOpen)return;this.app.keymap.popScope(this.scope),this.isOpen=!1,this.inputEl.setAttribute("aria-expanded","false"),this.setActiveDescendant(null),this.suggest.close(),this.suggest.setSuggestions([]),this.popper&&(this.popper.destroy(),this.popper=null),this.suggestEl.remove();let e=io(this.inputEl),t=Rg(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=ov.get(this.inputEl);t&&(t.delete(e),t.size===0&&ov.delete(this.inputEl))}setActiveDescendant(e){if(e){this.inputEl.setAttribute("aria-activedescendant",e);return}this.inputEl.removeAttribute("aria-activedescendant")}getCurrentQuery(){return this.currentQuery}}});function sr(r){return Array.isArray(r)||r==null?!1:typeof r=="object"?Object.keys(r).length>0:!!r}var sv=E(()=>{});function JL(r,e=0){return(qn[r[e+0]]+qn[r[e+1]]+qn[r[e+2]]+qn[r[e+3]]+"-"+qn[r[e+4]]+qn[r[e+5]]+"-"+qn[r[e+6]]+qn[r[e+7]]+"-"+qn[r[e+8]]+qn[r[e+9]]+"-"+qn[r[e+10]]+qn[r[e+11]]+qn[r[e+12]]+qn[r[e+13]]+qn[r[e+14]]+qn[r[e+15]]).toLowerCase()}var qn,e1=E(()=>{qn=[];for(let r=0;r<256;++r)qn.push((r+256).toString(16).slice(1))});function EI(){return crypto.getRandomValues(G5)}var G5,t1=E(()=>{G5=new Uint8Array(16)});function Y5(r,e,t){return!e&&!r&&crypto.randomUUID?crypto.randomUUID():K5(r,e,t)}function K5(r,e,t){r=r||{};let n=r.random??r.rng?.()??EI();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 JL(n)}var Kt,r1=E(()=>{t1();e1();Kt=Y5});var Ss=E(()=>{r1()});function WC(r){return Ue(r)&&r.type==="Multi"}function Ue(r){return typeof r=="object"&&r!==null}function et(r){return WC(r)?Array.isArray(r.choices)?r.choices:[]:[]}function ml(r){return WC(r)&&Array.isArray(r.choices)}function mf(r){if(!Array.isArray(r))return!0;let e=t=>t.some(n=>{if(Array.isArray(n))return!0;if(!Ue(n)||n.type!=="Multi")return!1;let i=n.choices;return Array.isArray(i)?e(i):sr(i)});return e(r)}function Lr(r){return Array.isArray(r)?r:[]}function jo(r){return WC(r)?sr(r.choices):!1}function hf(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 xd(r){return(typeof r.icon=="string"?r.icon.trim():"")||hf(r.type)}function nn(r){let e=[],t=n=>{Ue(n)&&(e.push(n),et(n).forEach(t))};return Lr(r).forEach(t),e}function n1(r){let e=new Map,t=n=>{let i=[];for(let o of n){if(!Ue(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:Kt()}}e.set(s.id,s),WC(s)&&Array.isArray(s.choices)&&(s={...s,choices:t(s.choices)}),i.push(s)}return i};return t(r)}function i1(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(!Ue(l)){s=!0;continue}let c=l;if(ml(c)){let p=c.choices,f=n(p);f!==p&&(c={...c,choices:f},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:Kt()};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 av(r,e=[],t=0,n=null){let i=[];for(let o of Lr(r)){if(!Ue(o))continue;let s=[...e,o.name];i.push({choice:o,id:o.id,path:s,depth:t,parentId:n}),i.push(...av(et(o),s,t+1,o.id))}return i}var bt=E(()=>{sv();Ss();sv()});function Ic(r){return Array.isArray?Array.isArray(r):v1(r)==="[object Array]"}function pK(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 kI(r){return r==null?"":pK(r)}function ni(r){return typeof r=="string"}function GC(r){return typeof r=="number"}function fK(r){return r===!0||r===!1||mK(r)&&v1(r)=="[object Boolean]"}function g1(r){return typeof r=="object"}function mK(r){return g1(r)&&r!==null}function ao(r){return r!=null}function jC(r){return!r.trim().length}function v1(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}function y1(r){let e=null,t=null,n=null,i=1,o=null;if(ni(r)||Ic(r))n=r,e=u1(r),t=YC(r);else{if(!c1.call(r,"name"))throw new Error(yK("name"));let s=r.name;if(n=s,c1.call(r,"weight")&&r.weight!==void 0&&(i=r.weight,i<=0))throw new Error(bK(YC(s)));e=u1(s),t=YC(s),o=r.getFn??null}return{path:e,id:t,weight:i,src:n,getFn:o}}function u1(r){return Ic(r)?r:r.split(".")}function YC(r){return Ic(r)?r.join("."):r}function xK(r,e){let t=[],n=!1,i=(o,s,a,l)=>{if(ao(o))if(!s[a])t.push(l!==void 0?{v:o,i:l}:o);else{let c=o[s[a]];if(!ao(c))return;if(a===s.length-1&&(ni(c)||GC(c)||fK(c)||typeof c=="bigint"))t.push(l!==void 0?{v:kI(c),i:l}:kI(c));else if(Ic(c)){n=!0;for(let u=0,d=c.length;u=9&&r<=13||r===32||r===160}function AK(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=e&&t.push([n,i]),n=-1)}return r[o-1]&&o-n>=e&&t.push([n,o-1]),t}function FK(r,e,t,{location:n=tt.location,distance:i=tt.distance,threshold:o=tt.threshold,findAllMatches:s=tt.findAllMatches,minMatchCharLength:a=tt.minMatchCharLength,includeMatches:l=tt.includeMatches,ignoreLocation:c=tt.ignoreLocation}={}){if(e.length>32)throw new Error(vK(32));let u=e.length,d=r.length,p=Math.max(0,Math.min(n,d)),f=o,m=p,g=(D,P)=>{let U=D/u;if(c)return U;let K=Math.abs(p-P);return i?U+K/i:K?1:U},v=a>1||l,y=v?Array(d):[],b;for(;(b=r.indexOf(e,m))>-1;){let D=g(0,b);if(f=Math.min(D,f),m=b+u,v){let P=0;for(;P=K;me-=1){let O=me-1,H=t[r[O]];if(ee[me]=(ee[me+1]<<1|1)&H,D&&(ee[me]|=(x[me+1]|x[me])<<1|1|x[me+1]),ee[me]&S&&(w=g(D,O),w<=f)){if(f=w,m=O,T=D,m<=p)break;K=Math.max(1,2*p-m)}}if(g(D+1,p)>f)break;x=ee}if(v&&m>=0){let D=Math.min(d-1,m+u-1+T);for(let P=m;P<=D;P+=1)t[r[P]]&&(y[P]=1)}let A={isMatch:m>=0,score:Math.max(.001,w)};if(v){let D=DK(y,a);D.length?l&&(A.indices=D):A.isMatch=!1}return A}function PK(r){let e={};for(let t=0,n=r.length;tt[0]-n[0]||t[1]-n[1]);let e=[r[0]];for(let t=1,n=r.length;t=t)break;let i=n;for(;i=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{let n=LK(t.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),i=[];for(let o=0,s=n.length;o{if(ni(i)){let l={keyId:null,pattern:i};return t&&(l.searcher=KC(i,e)),l}let o=Object.keys(i),s=qK(i);if(!s&&o.length>1&&!DI(i))return n(f1(i));if(UK(i)){let l=s?i[II.PATH]:o[0],c=s?i[II.PATTERN]:i[l];if(!ni(c))throw new Error(gK(l));let u={keyId:YC(l),pattern:c};return t&&(u.searcher=KC(c,e)),u}let a={children:[],operator:o[0]};return o.forEach(l=>{let c=i[l];Ic(c)&&c.forEach(u=>{a.children.push(n(u))})}),a};return DI(r)||(r=f1(r)),n(r)}function FI(r,{ignoreFieldNorm:e=tt.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 HK(r,{ignoreFieldNorm:e=tt.ignoreFieldNorm}){r.forEach(t=>{t.score=FI(t.matches,{ignoreFieldNorm:e})})}function WK(r){let e=[];return r.matches.forEach(t=>{if(!ao(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 jK(r,e,{includeMatches:t=tt.includeMatches,includeScore:n=tt.includeScore}={}){return r.map(i=>{let{idx:o}=i,s={item:e[o],refIndex:o};return t&&(s.matches=WK(i)),n&&(s.score=i.score),s})}function YK(r){m1.has(r)||(m1.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 KK(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||YK(r),e=>e.match(r)||[]):e=>e.match(GK)||[]}function PI({isCaseSensitive:r=!1,ignoreDiacritics:e=!1,tokenize:t}={}){let n=KK(t);return{tokenize(i){return r||(i=i.toLowerCase()),e&&(i=lv(i)),n(i)}}}function TI(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 x1(r,e,t,n){let{i,v:o,$:s}=e;if(o!==void 0){TI(r,o,i,n);return}if(s)for(let a=0;aa-l);for(let a of t)JK(r,a);let n=a=>{let l=0,c=t.length;for(;l>>1;t[u]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 hK,SI,gK,vK,yK,bK,wK,c1,CK,EK,TK,kK,SK,tt,MI,w1,MK,lv,OI,$K,_I,d1,RK,NK,BK,AI,QC,II,DI,qK,UK,f1,zK,GK,m1,QK,Dc,Fc,XC=E(()=>{hK="Incorrect 'index' type",SI="Invalid doc index: must be a non-negative integer within the bounds of the docs array",gK=r=>`Invalid value for key ${r}`,vK=r=>`Pattern length exceeds max of ${r}.`,yK=r=>`Missing ${r} property in key`,bK=r=>`Property 'weight' in key '${r}' must be a positive integer`,wK="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.",c1=Object.prototype.hasOwnProperty,CK=class{constructor(r){this._keys=[],this._keyMap={};let e=0;r.forEach(t=>{let n=y1(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)}};EK={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},TK={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,e)=>r.score===e.score?r.idx{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(ni(this.docs[0]))for(let t=0;tr&&(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>>1;t[s]e),records:this.records}}};w1={\u0142:"l",\u0141:"L",\u0111:"d",\u0110:"D",\u00F8:"o",\u00D8:"O",\u0127:"h",\u0126:"H",\u0167:"t",\u0166:"T",\u0131:"i",\u00DF:"ss"},MK=new RegExp("["+Object.keys(w1).join("")+"]","g"),lv=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(MK,e=>w1[e]):r=>r,OI=class{constructor(r,{location:e=tt.location,threshold:t=tt.threshold,distance:n=tt.distance,includeMatches:i=tt.includeMatches,findAllMatches:o=tt.findAllMatches,minMatchCharLength:s=tt.minMatchCharLength,isCaseSensitive:a=tt.isCaseSensitive,ignoreDiacritics:l=tt.ignoreDiacritics,ignoreLocation:c=tt.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?lv(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;let u=(p,f)=>{this.chunks.push({pattern:p,alphabet:PK(p),startIndex:f})},d=this.pattern.length;if(d>32){let p=0,f=d%32,m=d-f;for(;p{let{isMatch:y,score:b,indices:x}=FK(r,m,g,{location:i+v,distance:o,threshold:s,findAllMatches:a,minMatchCharLength:l,includeMatches:n,ignoreLocation:c});y&&(p=!0),d+=b,y&&x&&u.push(...x)});let f={isMatch:p,score:p?d/this.chunks.length:1};return p&&n&&(f.indices=$I(u)),f}},$K=new Set(["fuzzy","include"]);_I=[{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 OI(r,{location:e.location??tt.location,threshold:e.threshold??tt.threshold,distance:e.distance??tt.distance,includeMatches:e.includeMatches??tt.includeMatches,findAllMatches:e.findAllMatches??tt.findAllMatches,minMatchCharLength:e.minMatchCharLength??tt.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??tt.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??tt.ignoreDiacritics,ignoreLocation:e.ignoreLocation??tt.ignoreLocation});return{type:"fuzzy",search(n){return t.searchIn(n)}}}}],d1=_I.length,RK="\0",NK="|";BK=class{constructor(r,{isCaseSensitive:e=tt.isCaseSensitive,ignoreDiacritics:t=tt.ignoreDiacritics,includeMatches:n=tt.includeMatches,minMatchCharLength:i=tt.minMatchCharLength,ignoreLocation:o=tt.ignoreLocation,findAllMatches:s=tt.findAllMatches,location:a=tt.location,threshold:l=tt.threshold,distance:c=tt.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?lv(r):r,this.pattern=r,this.query=VK(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?lv(r):r;let o=0,s=[],a=0,l=!1;for(let c=0,u=e.length;c!!(r[QC.AND]||r[QC.OR]),qK=r=>!!r[II.PATH],UK=r=>!Ic(r)&&g1(r)&&!DI(r),f1=r=>({[QC.AND]:Object.keys(r).map(e=>({[e]:r[e]}))});zK=class{constructor(r,e){this.limit=r,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(r){this.size0;){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(i0&&(n=i),o0&&(n=o),n!==r){let s=e[r];e[r]=e[n],e[n]=s}}while(n!==r)}};GK=/[\p{L}\p{M}\p{N}_]+/gu,m1=new WeakSet;QK=class{static condition(r,e){return e.useTokenSearch}constructor(r,e){this.options=e,this.analyzer=PI({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 OI(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;c0?1-t/n:0,l={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(l.indices=$I(e)),this.combineAll&&(this.useMask?l.matchedMask=o:l.matchedTerms=s,l.termCount=this.numTerms),l}};Dc=class{constructor(r,e,t){this.options={...tt,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new CK(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=KC(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 MI))throw new Error(hK);if(this._myIndex=e||b1(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let t=PI({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=XK(this._myIndex.records,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}add(r){if(!ao(r))return;this._docs.push(r);let e=this._myIndex.add(r,this._docs.length-1);if(this._invertedIndex&&e){let t=PI({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});ZK(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!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(SI);this._invertedIndex&&h1(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(ni(r)&&!r.trim()){let p=this._docs.map((f,m)=>({item:f,refIndex:m}));return GC(t)&&t>-1&&(p=p.slice(0,t)),p}let l=o&&GC(t)&&t>0&&ni(r),c=s,u=(p,f)=>c(p,f)||p.idx-f.idx,d;if(l){let p=new zK(t,u);ni(this._docs[0])?this._searchStringList(r,{heap:p,ignoreFieldNorm:a}):this._searchObjectList(r,{heap:p,ignoreFieldNorm:a}),d=p.extractSorted()}else d=ni(r)?ni(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r),HK(d,{ignoreFieldNorm:a}),o&&d.sort(ni(r)?u:c),GC(t)&&t>-1&&(d=d.slice(0,t));return jK(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(!ao(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 p=[d];if(!i||this._coversAllTokens(p)){let f={item:a,idx:l,matches:p};e?(f.score=FI(f.matches,{ignoreFieldNorm:t}),e.insert(f)):s.push(f)}}}),s}_searchLogical(r){let e=C1(r,this.options),t=this._normalizedKeys(),n=(a,l,c)=>{if(!("children"in a)){let{keyId:f,searcher:m}=a,g;return f===null?(g=[],t.forEach((v,y)=>{g.push(...this._findMatches({key:v,value:l[y],searcher:m}))})):g=this._findMatches({key:this._keyStore.get(f),value:this._myIndex.getValueForItemAtKeyId(l,f),searcher:m}),g&&g.length?[{idx:c,item:l,matches:g}]:[]}let{children:u,operator:d}=a,p=[];for(let f=0,m=u.length;f{if(ao(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(!ao(l))return;let u=[],d=!1,p=!1;if(s.forEach((f,m)=>{let g=this._findMatches({key:f,value:l[m],searcher:n});g.length?(u.push(...g),g[0].hasInverse&&(p=!0)):d=!0}),!(p&&d)&&u.length&&(!i||this._coversAllTokens(u))){let f={idx:c,item:l,matches:u};e?(f.score=FI(f.matches,{ignoreFieldNorm:t}),e.insert(f)):a.push(f)}}),a}_findMatches({key:r,value:e,searcher:t}){if(!ao(e))return[];let n=[];if(Ic(e))e.forEach(({v:i,i:o,n:s})=>{if(!ao(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;iRI(e))};Fc=Dc});function eQ(r){if(!r)return[];let e=[];for(let[t,n]of Object.entries(r)){let i=t.toLowerCase();if(i!=="alias"&&i!=="aliases")continue;let o=typeof n=="string"?n.split(","):n;Array.isArray(o)&&e.push(...o.filter(s=>typeof s=="string").map(s=>s.trim()).filter(Boolean))}return e}function E1(r,e,t){let n=r.metadataCache.getFileCache(e),i=n?.frontmatter,o=eQ(i),s=o.map(u=>tr(u)),a=(n?.headings??[]).map(u=>CI(u.heading)),l=[];if(n?.blocks)for(let u of Object.values(n.blocks))u.id&&l.push(u.id);let c=n?.tags?.map(u=>u.tag)??[];if(i?.tags){let u=Array.isArray(i.tags)?i.tags:[i.tags];c.push(...u.filter(d=>typeof d=="string"))}return{path:e.path,pathNormalized:tr(e.path),basename:e.basename,basenameNormalized:tr(e.basename),aliases:o,aliasesNormalized:s,headings:a,blockIds:l,tags:c,modified:e.stat.mtime,openedAt:t,folder:e.parent?.path??""}}var T1=E(()=>{rn()});function k1(r,e,t,n,i,o,s){let a=n;if(t.currentFolder&&r.folder===t.currentFolder&&(a+=i.boosts.sameFolder),r.openedAt&&(Date.now()-r.openedAt)/864e5o.tags.includes(m));f.length>0&&(a+=i.boosts.tagOverlap*Math.min(f.length,Math.abs(i.boosts.tagOverlapMax/i.boosts.tagOverlap)))}let l=tr(e),c=s==="alias"&&r.aliases.length>0?r.aliasesNormalized.findIndex(f=>f.includes(l)):-1,u=c>=0?r.aliases[c].length:r.basename.length;if(s==="alias"){let f=Math.max(0,(u-i.penalties.titleLengthThreshold)*i.penalties.aliasLengthMultiplier),m=Math.min(i.penalties.aliasMaxPenalty,i.penalties.aliasMinPenalty+f);a+=m}u>i.penalties.titleLengthThreshold&&(a+=(u-i.penalties.titleLengthThreshold)*i.penalties.titleLengthMultiplier);let p=(c>=0?r.aliasesNormalized[c]:r.basenameNormalized).indexOf(l);return p>=0&&(a+=p*i.penalties.positionMultiplier),a}var ZC,NI=E(()=>{rn();ZC={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}}});var cv,LI,tQ,rQ,nQ,gf,VI=E(()=>{cv=require("obsidian");XC();T1();NI();NI();rn();LI=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()}},tQ=20,rQ=100,nQ=/\w/,gf=class r{constructor(e,t){this.fileMap=new Map;this.recentFiles=new LI;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=ZC;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 Fc([],{...n,threshold:.2}),this.fuseRelaxed=new Fc([],{...n,threshold:.4}),this.setupEventListeners(),this.effectiveWeights=ZC}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 cv.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 cv.TFile&&e.extension==="md"&&this.addFile(e)})),this.plugin.registerEvent(this.app.vault.on("delete",e=>{e instanceof cv.TFile&&this.removeFile(e)})),this.plugin.registerEvent(this.app.vault.on("rename",(e,t)=>{e instanceof cv.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;awindow.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}}createIndexedFile(e){return E1(this.app,e,this.recentFiles.peek(e.path))}addFile(e){this.upsertFile(e,"add")}updateFile(e){this.upsertFile(e,"update"),this.unresolvedLinksDirty=!0}upsertFile(e,t){this.fileMap.set(e.path,this.createIndexedFile(e)),this.scheduleFuseUpdate(e.path,t),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==="add"&&t==="remove"){this.pendingFuseUpdates.delete(e);return}this.pendingFuseUpdates.set(e,n==="remove"&&t==="add"?"update":t),this.fuseUpdateTimeout!==null&&window.clearTimeout(this.fuseUpdateTimeout),this.fuseUpdateTimeout=window.setTimeout(()=>{this.processPendingFuseUpdates()},rQ)}processPendingFuseUpdates(){if(this.pendingFuseUpdates.size!==0){if(this.isIndexing){this.pendingFuseUpdates.clear();return}if(this.pendingFuseUpdates.size>tQ){this.updateFuseIndex(),this.pendingFuseUpdates.clear();return}for(let[e,t]of this.pendingFuseUpdates)for(let n of[this.fuseStrict,this.fuseRelaxed]){n.remove(o=>o.path===e);let i=t!=="remove"&&this.fileMap.get(e);i&&n.add(i)}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){if(this.unresolvedLinksDirty&&this.updateUnresolvedLinks(),e.includes("#"))return this.searchWithHeadings(e,t,n);let i=tr(e),o=this.matchFiles(e,t,n);if(e.length>=2){let s=0,a=e.length<3?10:20;for(let l of this.unresolvedLinks){if(s>=a)break;tr(l).includes(i)&&(o.push({file:{path:l,pathNormalized:tr(l),basename:l,basenameNormalized:tr(l),aliases:[],aliasesNormalized:[],headings:[],blockIds:[],tags:[],modified:0,folder:""},score:this.effectiveWeights.base.unresolvedLink,matchType:"unresolved",displayText:l}),s++)}}return o.sort((s,a)=>s.score-a.score).slice(0,n)}calculateScore(e,t,n,i,o){return k1(e,t,n,i,this.effectiveWeights,n.currentFile?this.fileMap.get(n.currentFile.path):void 0,o)}searchWithHeadings(e,t,n){let[i,o]=e.split("#"),s=tr(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 p of d.headings){if(l>=c)break;tr(p).includes(s)&&(a.push({file:d,score:this.calculateScore(d,e,t,.1),matchType:"heading",displayText:`${d.basename}#${p}`}),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)tr(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){return this.matchFiles(e,t,n,{...this.effectiveWeights.base,basenameExact:-1e3,basenamePrefix:-500,aliasPrefix:-500,substringBasename:-300}).sort((i,o)=>i.score-o.score).slice(0,n)}matchFiles(e,t,n,i=this.effectiveWeights.base){let o=[],s=tr(e),a=new Set,l=Array.from(this.fileMap.values()),c=(d,p,f,m)=>{a.has(d.path)||(o.push({file:d,score:this.calculateScore(d,e,t,p,f),matchType:f,displayText:m}),a.add(d.path))};for(let d of l)d.basenameNormalized===s&&c(d,i.basenameExact,"exact",d.basename);for(let d of l){let p=d.aliasesNormalized.indexOf(s);p!==-1&&c(d,i.aliasExact,"alias",d.aliases[p])}for(let d of l)d.basenameNormalized.startsWith(s)&&c(d,i.basenamePrefix,"fuzzy",d.basename);for(let d of l){let p=d.aliasesNormalized.findIndex(f=>f.startsWith(s));p!==-1&&c(d,i.aliasPrefix,"alias",d.aliases[p])}for(let d of l){let p=d.basenameNormalized.indexOf(s);p>0&&!nQ.test(d.basenameNormalized[p-1])&&c(d,i.substringBasename,"fuzzy",d.basename)}let u=this.fuseStrict.search(s,{limit:n*2});u.lengthv.key==="aliasesNormalized"),f=!!p,m=f?"alias":"fuzzy",g=d.item.basename;if(f){let v=typeof p?.value=="string"?p.value:void 0,y=v?d.item.aliasesNormalized.findIndex(b=>b===v):d.item.aliasesNormalized.findIndex(b=>b.includes(s));y>=0&&(g=d.item.aliases[y])}c(d.item,(d.score??.5)+i.fuzzyMatch,m,g)}return o}getFile(e){return this.fileMap.get(e)}getHeadings(e){return e.headings}getBlockIds(e){return e.blockIds}getIndexedFileCount(){return this.fileMap.size}}});function S1(r){BI=r}function on(){if(!BI)throw new Error("QuickAdd plugin instance accessed before it was initialised.");return BI}var BI,_s=E(()=>{});function iQ(r,e){let t=er(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 JC,vf,qI=E(()=>{ks();JC=require("obsidian");Xe();VI();rn();_s();bs();vf=class extends xr{constructor(t,n,i){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.sourcePathOverride=i?.sourcePath,this.fileIndex=gf.getInstance(t,on()),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=zR.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=tr(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(p=>i===""||tr(p).includes(s)).slice(0,20);for(let p of d)l.push({file:c,score:0,matchType:"heading",displayText:o?`#${p}`:`${c.basename}#${p}`})}return l}getBlockSuggestions(t){let[n,i]=t.split("#^"),o=tr(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===""||tr(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=tr(t);return n.filter(a=>i.includes(a.extension.toLowerCase())&&(t===""||tr(a.basename).includes(o))).slice(0,20).map(a=>({file:{path:a.path,pathNormalized:tr(a.path),basename:a.basename,basenameNormalized:tr(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":case"fuzzy":a=i.basename,l=i.path;break;case"alias":a=s,l=i.path;break;case"heading":{let[g,v]=s.split("#"),y=this.lastInput.includes("#")?this.lastInput.split("#")[1]:"",b=tr(y??"");y&&tr(v).includes(b)?(a=v,c=!0,u=y):a=v,l=g;break}case"block":{let[g,v]=s.split("#^");a=v,l=g;break}case"unresolved":a=s,l="Unresolved link";break}let d=er(n,"div");d.className="qa-suggestion-content";let p=er(n,"span");p.className="suggestion-main-text",c?this.renderMatch(p,a,u):p.textContent=a,d.appendChild(p);let f=iQ(n,o);f&&d.appendChild(f);let m=er(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=io(this.inputEl),o=()=>this.hideTooltip();i.addEventListener("scroll",o,{passive:!0}),this.scrollListener=o,this.scrollListenerDocument=i}}hideTooltip(){let t=io(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=io(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 JC.TFile))return null;let i=this.inputEl,o=er(i,"div");o.className="qa-file-tooltip";let s=er(i,"div");s.className="qa-tooltip-header",s.textContent=n.basename;let a=er(i,"div");a.className="qa-tooltip-content";let l=er(i,"div");l.textContent=`Path: ${n.path}`;let c=er(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,c=this.inputEl.value.slice(n-this.lastInput.length-3,n-this.lastInput.length)==="![["||t.matchType==="unresolved"||t.matchType==="heading"||t.matchType==="block"?void 0:this.app.vault.getAbstractFileByPath(t.file.path);c instanceof JC.TFile?s=this.makeLinkObsidianMethod(c,o,n,i,t.matchType==="alias"?t.displayText:void 0):s=this.makeLinkManually(o,t.matchType==="unresolved"?t.displayText.replace(/.md$/,""):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 JC.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 _1,ex,A1=E(()=>{XC();_1={threshold:.4,includeScore:!0,keys:[""]},ex=class r{constructor(e,t){this.sortedTags=[];this.fuse=new Fc([],_1);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 Fc(this.sortedTags,_1)}getSortedTags(){return this.sortedTags}search(e){return this.fuse.search(e)}}});function oQ(r,e){let t=r.slice(0,e),n=t.lastIndexOf("[[");return n===-1?!1:t.lastIndexOf("]]"){Xe();ks();rn();_s();A1();yf=class extends xr{constructor(t,n,i){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.lastInputStart=0;this.lastInputLength=0;this.tagIndex=ex.getInstance(t,on()),i?.refreshIndex!==!1&&this.tagIndex.refresh()}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.slice(0,n),o=WR.exec(i);if(!o)return[];if(o.index===void 0)return[];if(oQ(i,o.index))return[];let s=o[1];this.lastInput=s,this.lastInputStart=o.index,this.lastInputLength=o[0].length;let a=this.tagIndex.getSortedTags(),l=s.toLowerCase(),c=a.filter(f=>f.replace(/^#/,"").toLowerCase().startsWith(l)).slice(0,5),u=this.tagIndex.search(s).filter(f=>f.score!==void 0&&f.score<.8).map(f=>f.item).slice(0,10),d=new Set(c),p=[...c];for(let f of u)!d.has(f)&&p.length<15&&(p.push(f),d.add(f));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}`;HC(n,i,o,s,{fromCompletion:!0}),this.close()}}});var ii,bf=E(()=>{ii=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 tx,I1=E(()=>{dt();bf();tx=class{constructor(e,t){this.store=ii.getInstance();this.initialValue="";this.didChange=!1;this.draftKey=this.store.makeKey(e),this.shouldPersist=t??(()=>X.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 D1(r,e){if(r.focus(),e?.cursorAtEnd){let t=r.value.length;r.setSelectionRange(t,t);return}r.select()}var F1=E(()=>{});function P1(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 M1=E(()=>{});var wf,uv,dv=E(()=>{Ie();wf=r=>{I.logWarning(r)},uv=()=>{}});function sQ(r,e){let t=Math.min(r.length,e.length),n=0;for(;nt||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,ut)return t+1;n=i,i=o}return i[e.length]}function O1(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:$1(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:sQ(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:$1(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 R1=E(()=>{});function pv(r){let t=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(r);return t?[0,t[0].length]:null}function fv(r,e,t,n){let[i,o]=n??[Number.NaN,Number.NaN];if(!(n!==null&&e>=i&&e{});function N1(r){return r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(aQ,e=>`\\x${e.charCodeAt(0).toString(16).padStart(2,"0")}`)}function mv(r){return`"${N1(r)}"`}function zI(r,e,t){let n=fv(r,e,t,pv(r));return!n.isInYaml||!n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}function Ed(r,e,t,n){return zI(r,e,t)?r[e-1]==='"'?N1(n):n.replace(/'/g,"''"):n}function WI(r,e,t){let n=fv(r,e,t,pv(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var aQ,rx=E(()=>{HI();aQ=new RegExp("[\0-\x7F]","g")});function nx(r,e,t){let n=r.trim().toLowerCase();if(lQ.has(n))return n;t?.(`QuickAdd: Unsupported multi-select format "${r}" in "${e}". Supported formats: auto, inline, spaced, yaml, markdown.`)}function cQ(r,e){let t=r.lastIndexOf(` `,e-1)+1;return r.slice(t,e).match(/^\s*/)?.[0]??""}function uQ(r){return`- ${r.replace(/\r\n?|\n/g,` `)}`}function L1(r){let{input:e,matchStart:t,values:n,format:i}=r,o=n.map(s=>String(s));switch(i){case"auto":return;case"inline":return o.join(",");case"spaced":return o.join(", ");case"yaml":return`[${o.map(mv).join(", ")}]`;case"markdown":{if(o.length===0)return"";let s=cQ(e,t);return o.map(uQ).join(` ${s}`)}default:return i}}var lQ,ix=E(()=>{rx();lQ=new Set(["auto","inline","spaced","yaml","markdown"])});function sx(r,e){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function pQ(r){let e=r.map(t=>`"${t}"`);return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function V1(r,e){let t=sx(r,32),n=`{{FIELD:${sx(e,48)}}}`,i=dQ.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;let o=O1(r,ox);return o.length>0?`Unknown FIELD filter "${t}" - did you mean ${pQ(o)}? Ignored in ${n}.`:`Unknown FIELD filter "${t}" in ${n} was ignored. Supported filters: ${ox.join(", ")}.`}function fQ(r,e){let t=sx(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${sx(e,48)}}}.`}function mQ(r,e,t){(t.warn??wf)(V1(r,e))}var ox,dQ,oi,hl=E(()=>{dv();xc();R1();ix();ox=["folder","tag","inline","inline-code-blocks","exclude-folder","exclude-tag","exclude-file","default","default-from","default-empty","default-always","case-sensitive","multi","format"],dQ=new Map([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);oi=class{static parse(e,t){let n=qo(e).map(c=>c.trim()),i=n[0],o={},s=!1,a="auto",l=!1;for(let c=1;cm.trim().toLowerCase()).filter(m=>m.length>0));break;case"default":o.defaultValue=f;break;case"default-from":o.defaultFrom=f.toLowerCase();break;case"default-empty":o.defaultEmpty=f.toLowerCase()==="true";break;case"default-always":o.defaultAlways=f.toLowerCase()==="true";break;case"case-sensitive":o.caseSensitive=f.toLowerCase()==="true";break;case"exclude-folder":o.excludeFolders??(o.excludeFolders=[]),o.excludeFolders.push(f);break;case"exclude-tag":{o.excludeTags??(o.excludeTags=[]);let m=f.startsWith("#")?f.substring(1):f;o.excludeTags.push(m);break}case"exclude-file":o.excludeFiles??(o.excludeFiles=[]),o.excludeFiles.push(f);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 jI(r){return r.replace(/^\/+|\/+$/g,"")}function hv(r,e=t=>t){return JSON.stringify([...r].map(e).sort())}function B1(r,e){let t=[`folder=${jI(r)}`];return e.folders?.length&&t.push(`folders=${hv(e.folders,jI)}`),e.tags?.length&&t.push(`tags=${hv(e.tags)}`),e.excludeFolders?.length&&t.push(`xfolder=${hv(e.excludeFolders,jI)}`),e.excludeTags?.length&&t.push(`xtag=${hv(e.excludeTags)}`),e.excludeFiles?.length&&t.push(`xfile=${hv(e.excludeFiles)}`),t.join("|")}function gQ(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[B1(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 ax(r,e){if(!r)return null;let t=qo(r),n=(t.shift()??"").trim();if(!n)return null;let i=t,o=ws(i,"optional");i=o.remaining;let s=o.found,a=ws(i,"custom");i=a.remaining;let l=a.found,c=ws(i,"multi");i=c.remaining;let u=c.found,d="name",p=[];for(let w of i){let T=w.trim().toLowerCase();if(hQ.has(T)){d=T;continue}p.push(w)}let f,m;for(let w of p){let T=Uo(w);T&&(T.key==="label"&&T.value?f=T.value:T.key==="name"&&T.value&&(m=T.value))}let g=oi.parse(r,{warn:e?.warn}),v=u||(g.multiSelect??!1),y=g.multiFormat??"auto",b={folder:n,tags:g.filters.tags,excludeFolders:g.filters.excludeFolders,excludeTags:g.filters.excludeTags,excludeFiles:g.filters.excludeFiles},x=m?`${gv}name=${m}|${B1(n,b)}${v?"|multi":""}`:`${gv}${gQ({folderPath:n,mode:d,label:f,optional:s,allowCustomInput:l,multiSelect:v,filter:b})}`;return{raw:r,folderPath:n,mode:d,label:f,aliasName:m,optional:s,allowCustomInput:l,filter:b,multiSelect:v,multiFormat:y,variableKey:x}}function q1(r,e){if(!r)return r;for(let t of e)if(r===t)return r;return`${As}${r}`}function Td(r){return typeof r!="string"||r===""?{kind:"empty"}:r.startsWith(As)?{kind:"custom",text:r.slice(As.length)}:r.startsWith(Pc)?{kind:"file",path:r.slice(Pc.length)}:{kind:"raw",value:r}}function Mc(r){return(r.split("/").pop()??r).replace(/\.(md|canvas|base)$/i,"")}function U1(r){return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function vQ(r){if(!r)return;let e=Object.entries(r).find(([t])=>t.toLowerCase()==="title");return e?U1(e[1]):void 0}function yQ(r){let e=r?.headings?.find(t=>t.level===1);return U1(e?.heading)}function bQ(r){let e=r.parent?.path;return e&&e!=="/"?e:r.path.includes("/")?r.path.slice(0,r.path.lastIndexOf("/")):"vault root"}function wQ(r){return r.basename?r.basename:Mc(r.path)}function GI(r,e){let t=r.map(i=>{let o=e?.(i)??null,s=wQ(i),a=vQ(o?.frontmatter)??yQ(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} - ${bQ(i)}`;return{primary:o,secondary:i.path,label:a}})}function $c(r,e){return GI(r,e).map(t=>t.label)}var gv,Pc,As,hQ,lo=E(()=>{hl();xc();gv="FILE:",Pc="@file:",As="@filecustom:",hQ=new Set(["name","link","path"])});function kd(r){return CQ.has(r.toUpperCase())}function YI(r){if(r.length===0||r==="."||r===".."||r.startsWith(".")||vv.test(r)||yv.test(r)||bv.test(r))return!1;let e=r.split(".")[0]??"";return e.length===0||!kd(e)}var vv,yv,bv,CQ,wv=E(()=>{vv=new RegExp("[\0-]","u"),yv=/[\\/:*?"<>|]/u,bv=/[. ]$/u,CQ=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 xQ(r){return(r??"").trim().replace(/\\/g,"/")}function EQ(r){return r.startsWith("/")||/^[a-zA-Z]:/.test(r)}function TQ(r){return r.split("/").some(e=>/^\.\.[. ]*$/u.test(e))}function Dr(r){let e=xQ(r);return e?EQ(e)||TQ(e):!1}var la=E(()=>{});function vl(r){return Object.hasOwn(gl,r)}function H1(r){let e=r.toLowerCase();return e==="jpeg"||Object.values(gl).includes(e)}function kQ(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())}`}function _Q(r){return r.replace(SQ,"").replace(/\s+/g," ").replace(/[. ]+$/g,"").trim()}function lx(r){if(r.nameAfterNoteTitle){let e=_Q(Mc(r.sourcePath));if(e.length>0&&YI(e))return`${e}.${r.extension}`}return`Clipboard image ${kQ(r.now)}.${r.extension}`}function z1(r,e){if(!vl(r))throw new Error(`Unsupported clipboard image type: ${r}`);return lx({extension:gl[r],sourcePath:"",now:e,nameAfterNoteTitle:!1})}function W1(r){let e=r.split(/[\\/]/u).at(-1)??"",t=e.lastIndexOf("."),n=t>=0?e.slice(0,t):e;return YI(n)?n:null}async function KI(r,e,t,n,i){if(!vl(t))throw new Error(`Unsupported image type: ${t}`);let o=await r.fileManager.getAvailablePathForAttachment(i,n||void 0);if(Dr(o))throw new Error(`Refusing to save image outside the vault: '${o}'`);return r.vault.createBinary(o,e)}async function cx(r,e,t,n,i){if(!vl(t))throw new Error(`Unsupported clipboard image type: ${t}`);let o=i?.nameAfterNoteTitle??X.getState().namePastedImagesAfterNoteTitle;return KI(r,e,t,n,lx({extension:gl[t],sourcePath:n,now:i?.now??new Date,nameAfterNoteTitle:o}))}function ux(r,e,t){let n=r.fileManager.generateMarkdownLink(e,t);return n.startsWith("!")?n:`!${n}`}var gl,SQ,dx=E(()=>{dt();lo();wv();la();gl=Object.assign(Object.create(null),{"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"});SQ=/[/\\:*?"<>|#^[\]]/g});function AQ(){let r=px.filter(t=>t.inputEl.isConnected);return r.find(t=>document.activeElement!==null&&t.inputEl.contains(document.activeElement))??r.at(-1)??null}function mx(r,e,t={}){let n=t.sourcePath??"",i=null,o=!1,s=!1,a=()=>{s=!0},l=()=>{s=!1},c=(y,b,x,w)=>{switch(x.kind){case"stand-down":return;case"take":if(b.preventDefault(),i){new Cv.Notice(y==="paste"?"QuickAdd: an image is still being saved \u2014 paste again in a moment.":"QuickAdd: an image is still being saved \u2014 drop again in a moment.");return}i=m(x.images,w).then(()=>{}).finally(()=>{i=null});return;default:return fx(x)}},u=y=>{let b=y.clipboardData;if(!b||s)return;let x=new Date;c("paste",y,j1("paste",b,r),x)},d=y=>{if(s)return;let b=y.dataTransfer;!b||!Y1(b)||(y.preventDefault(),b.dropEffect="copy",e.classList.add("qa-image-drop-target"))},p=()=>{e.classList.remove("qa-image-drop-target")},f=y=>{if(p(),s)return;let b=y.dataTransfer;if(!b||!Y1(b))return;let x=new Date;c("drop",y,j1("drop",b,r),x)};async function m(y,b){let x=e.readOnly;e.readOnly=!0,e.setAttribute("aria-busy","true"),e.classList.add("qa-image-paste-busy");let w=[];try{for(let C of y){let S;switch(C.origin){case"vault":S=C.file;break;case"bytes":{let A=await C.file.arrayBuffer(),D=PQ(C,b,n);S=await MQ(()=>KI(r,A,C.mimeType,n,D));break}default:return fx(C)}w.push(ux(r,S,n))}}catch(C){I.logError(`Failed to save image: ${C instanceof Error?C.message:String(C)}`),new Cv.Notice("QuickAdd: failed to save image.")}finally{e.readOnly=x,e.removeAttribute("aria-busy"),e.classList.remove("qa-image-paste-busy")}if(w.length===0||o)return"";let T=w.join(e.tagName==="TEXTAREA"?` `:" ");try{return $Q(e,T),T}catch(C){return I.logError(`Failed to insert image link: ${C instanceof Error?C.message:String(C)}`),new Cv.Notice("QuickAdd: saved the image but could not insert its link."),""}}async function g(y){let b=new Date,x=FQ(y);if(x.length===0)return I.logMessage("QuickAdd: image ingest skipped (no-images)."),"";if(i)return new Cv.Notice("QuickAdd: an image is still being saved \u2014 drop again in a moment."),I.logMessage("QuickAdd: image ingest skipped (busy)."),"";let w="";return i=(async()=>{w=await m(x,b)})().finally(()=>{i=null}),await i,w.length>0&&I.logMessage(`QuickAdd: ingested ${x.length} image(s) into the active prompt.`),w}e.addEventListener("paste",u),e.addEventListener("dragenter",d),e.addEventListener("dragover",d),e.addEventListener("dragleave",p),e.addEventListener("drop",f),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l);let v={isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),ingestFiles:g,detach:()=>{o=!0,p(),e.removeEventListener("paste",u),e.removeEventListener("dragenter",d),e.removeEventListener("dragover",d),e.removeEventListener("dragleave",p),e.removeEventListener("drop",f),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l);let y=px.findIndex(b=>b.handle===v);y>=0&&px.splice(y,1)}};return px.push({handle:v,inputEl:e}),v}async function Q1(r){let e=AQ();if(!e)return I.logMessage("QuickAdd: image ingest skipped (no-active-prompt)."),{ok:!1,reason:"no-active-prompt"};if(e.handle.isBusy())return I.logMessage("QuickAdd: image ingest skipped (busy)."),{ok:!1,reason:"busy"};let t=await e.handle.ingestFiles(r);return t.length===0?{ok:!1,reason:"no-images"}:{ok:!0,inserted:t}}function j1(r,e,t){switch(r){case"paste":{if(e.getData("text/plain").length>0)return{kind:"stand-down"};let n=G1(e).map(i=>({origin:"bytes",...i,naming:{kind:"paste-name"}}));return n.length>0?{kind:"take",images:n}:{kind:"stand-down"}}case"drop":{let n=IQ(e,t);if(n.length>0)return{kind:"take",images:n};let i=G1(e).map(o=>({origin:"bytes",...o,naming:X1(o)}));return i.length>0?{kind:"take",images:i}:{kind:"stand-down"}}default:return fx(r)}}function IQ(r,e){let t=[];for(let n of r.getData("text/plain").split(/\r?\n/u)){let i=n.trim();if(i.length===0||i.toLowerCase().startsWith("file://")||Dr(i))continue;let o=e.vault.getAbstractFileByPath(i);DQ(o)&&t.push({origin:"vault",file:o})}return t}function DQ(r){return r!==null&&"extension"in r&&typeof r.extension=="string"&&H1(r.extension)}function G1(r){let e=[],t=0;for(let o of Array.from(r.items??[])){if(o.kind!=="file"||(t++,!vl(o.type)))continue;let s=o.getAsFile();s&&e.push({file:s,mimeType:o.type})}if(t>0&&e.length===t)return e;if(e.length===0){let o=[];for(let s of Array.from(r.files??[]))vl(s.type)&&o.push({file:s,mimeType:s.type});return o}let n=[...e],i=new Set(e.map(({file:o,mimeType:s})=>`${o.name}\0${o.size}\0${s}\0${o.lastModified}`));for(let o of Array.from(r.files??[])){if(!vl(o.type))continue;let s=`${o.name}\0${o.size}\0${o.type}\0${o.lastModified}`;i.has(s)||(i.add(s),n.push({file:o,mimeType:o.type}))}return n}function FQ(r){return r.flatMap(e=>{if(!vl(e.type))return[];let t={file:e,mimeType:e.type};return[{origin:"bytes",...t,naming:X1(t)}]})}function X1(r){let e=W1(r.file.name);return e===null?{kind:"clipboard-stamp"}:{kind:"original-stem",stem:e}}function PQ(r,e,t){switch(r.naming.kind){case"clipboard-stamp":return z1(r.mimeType,e);case"paste-name":return lx({extension:gl[r.mimeType],sourcePath:t,now:e,nameAfterNoteTitle:X.getState().namePastedImagesAfterNoteTitle});case"original-stem":return`${r.naming.stem}.${gl[r.mimeType]}`;default:return fx(r.naming)}}function Y1(r){return Array.from(r.types??[]).some(e=>e==="Files"||vl(e))}function fx(r){throw new Error(`Unexpected image intake value: ${String(r)}`)}function MQ(r){let e=K1.then(r,r);return K1=e.catch(()=>{}),e}function $Q(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 Cv,px,K1,hx=E(()=>{Cv=require("obsidian");Ie();dx();dt();la();px=[];K1=Promise.resolve()});function Z1(r,e){return!r.isComposing&&r.key.toLowerCase()===e.toLowerCase()&&r.shiftKey&&(r.ctrlKey||r.metaKey)}function J1(r){return Z1(r,"Enter")}function t2(r){return Z1(r,xv)}function r2(r){return r?`Look at the note without losing this draft. ${e2}`:"Look at the note without losing this draft."}function n2(){return`${e2} returns to the prompt`}var xv,e2,Ev=E(()=>{xv="E",e2="Ctrl/Cmd+Shift+E"});function i2(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 o2(r,e=42){let t=r.slice(0,e*4),n=t.replace(/\s+/g," ").trim();return n.length<=e?t.length{});function ZI(r){XI.add(r)}function JI(r){XI.delete(r)}function s2(){return XI.size>0}var XI,eD=E(()=>{XI=new Set});function OQ(r,e){let t=new Set([e]);return r.workspace.iterateAllLeaves?.(i=>{let o=i.view?.containerEl?.ownerDocument;o&&t.add(o)}),[...t]}var Hn,Is,yl,gx=E(()=>{Hn=require("obsidian");ys();bs();Ev();QI();eD();Is=class Is{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 Is.active!==null}static getActive(){return Is.active}static activate(e,t){let n=Is.active;if(n){let o=n.handle.title;n.cancel(),new Hn.Notice(`QuickAdd: cancelled the peeked prompt "${o}".`)}let i=new Is(e,t);return Is.active=i,i.mount(),i}static discard(){Is.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=sl(this.app);if(!e){this.resume();return}let t=this.handle;this.destroy(),t.insertSelectionAndResume(e)}canReturnNow(){return s2()?(new Hn.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=Hn.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.createSpan({cls:"qa-peek-chip-icon"});s.setAttribute("aria-hidden","true"),(0,Hn.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 Hn.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 Hn.ButtonComponent(l).setButtonText("Return").setTooltip("Go back to the prompt without inserting").onClick(()=>this.resume());let c=new Hn.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=er(c.buttonEl,"span");u.className="qa-peek-chip-cancel-icon",u.setAttribute("aria-hidden","true"),(0,Hn.setIcon)(u,"x"),c.buttonEl.replaceChildren(u)}else c.setButtonText("Cancel");Hn.Platform.isMobile||i.createEl("p",{cls:"qa-peek-chip-keys",text:n2()}),this.chipEl=i,this.refreshInsertButton(),this.listenForSelection(),this.listenForChipEscape(),this.pushReturnShortcut()}listenForSelection(){let e=(0,Hn.debounce)(()=>this.refreshInsertButton(),100,!0);this.selectionListener=e,this.selectionDocuments=OQ(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=sl(this.app),n=t.length>0,i=n&&!this.compactChrome?o2(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 Hn.Scope(this.app.scope),this.returnScope.register(["Mod","Shift"],xv,()=>(this.resume(),!1)),this.app.keymap.pushScope(this.returnScope)}destroy(){if(Is.active===this&&(Is.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}};Is.active=null;yl=Is});function RQ(r){xn(r)?.editor?.focus?.()}var a2,Cf,tD=E(()=>{ys();gx();QI();eD();a2="qa-prompt-peek-hidden",Cf=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=yl.activate(this.host.app,{title:this.host.title,resume:()=>this.resume(),cancel:()=>this.cancel(),insertSelectionAndResume:t=>this.insertSelectionAndResume(t)})}onHostOpened(){ZI(this.host)}onHostClosed(){JI(this.host),this.peeking&&(this.peeking=!1,this.session?.discard(),this.session=null)}hideModal(){JI(this.host),this.host.containerEl.addClass(a2),this.host.app.keymap.popScope(this.host.scope),RQ(this.host.app)}showModal(){this.host.app.keymap.pushScope(this.host.scope),this.host.containerEl.removeClass(a2),ZI(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=i2(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 l2(r){return Tv.Platform.isPhone||(r?.innerWidth??Number.POSITIVE_INFINITY)<=540}function vx(r){let e=l2(r.ownerDocument.defaultView);return r.classList.toggle("qa-prompt-compact",e),e}function yx(r){let e=l2(r.buttonEl.ownerDocument.defaultView);r.setButtonText(e?LQ:NQ),r.setTooltip(r2(!Tv.Platform.isMobile)),r.buttonEl.setAttribute("aria-label","Peek at the note. Your draft stays."),r.buttonEl.classList.add("qa-peek-button");let t=er(r.buttonEl,"span");return t.className="qa-peek-button-icon",t.setAttribute("aria-hidden","true"),(0,Tv.setIcon)(t,"eye"),r.buttonEl.prepend(t),r}var Tv,NQ,LQ,rD=E(()=>{Tv=require("obsidian");bs();Ev();NQ="Peek at note",LQ="Peek"});var bx,xf,nD=E(()=>{bx=require("obsidian");qI();UI();I1();F1();M1();hx();ur();tD();Ev();rD();xf=class extends bx.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()&&t2(t)){t.preventDefault(),this.peek.peek();return}if(this.isOptionalPrompt&&J1(t)){t.preventDefault(),this.skip();return}this.shouldSubmit(t)&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new tx({kind:this.getPromptKind(),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 Cf({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()}display(){this.containerEl.addClass("quickAddModal",this.getPromptKind()==="single"?"qaInputPrompt":"qaWideInputPrompt"),vx(this.containerEl),this.contentEl.empty(),this.titleEl.textContent=this.header,P1(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}configureInput(t,n,i){return t.setPlaceholder(n??"").setValue(i??"").onChange(o=>this.onInputChanged(o)),t.inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=mx(this.app,t.inputEl,this.options.imagePaste)),t}disposeInput(){}createButton(t,n,i){let o=new bx.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"});yx(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.getPromptKind()==="multi"&&this.didSubmit||(this.input="",this.didSubmit=!0,this.close())}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise(Rr())}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 vf(this.app,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new yf(this.app,this.inputComponent.inputEl)}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback),this.disposeInput(),this.imagePasteHandle?.detach()}onOpen(){super.onOpen(),this.peek.onHostOpened(),D1(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 c2,ar,Ds=E(()=>{c2=require("obsidian");nD();ar=class r extends xf{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}getPromptKind(){return"single"}createInputField(e,t,n){let i=new c2.TextComponent(e);return i.inputEl.setCssStyles({width:"100%"}),this.configureInput(i,t,n)}shouldSubmit(e){return!e.isComposing&&e.key==="Enter"}}});function zn(r){return r.replace(/\{\{CURSOR\}\}/gi,"")}function Tf(r){let e=/\{\{CURSOR\}\}/i.exec(r);return r=zn(r),{content:r,cursor:/^[ \t\r\n\f\v]*$/.test(r)?{kind:"none"}:{kind:"offset",value:e?.index??r.length,source:e?"marker":"defaultEnd"}}}function bl(r,e,t=""){return{content:e+r.content+t,cursor:r.cursor.kind==="none"?r.cursor:{...r.cursor,value:e.length+r.cursor.value}}}function Oc(r,e,t){return{content:e,cursor:r.cursor.kind==="none"||t===null?{kind:"none"}:{...r.cursor,value:t}}}var wl=E(()=>{});function ZQ(r){return KQ.test(r.trim())}function JQ(r){let e=r.replace(QQ,"");return e===r?!1:!XQ.test(e)}function Cx(r,e){return GQ.has(r)?JQ(e):ZQ(e)}function xx(r){return r==="noteTitle"||r==="captureTarget"||r==="propertyName"||r==="propertyValue"||r==="folder"||r==="templatePath"||r==="lineTarget"||r==="filePath"}function Ex(r){return r!=="templatePath"&&r!=="generic"}function Tx(r,e){if(r==="generic")return{};let t=YQ[r];return e?{title:t.ask,placeholder:t.hint}:{placeholder:t.partOf}}function eX(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=`${d2}/${n}`;return s.length{Xe();GQ=new Set(["captureText"]),YQ={noteTitle:{ask:"Note title",hint:"Title for the new note",partOf:"Part of the new note's title"},captureTarget:{ask:"Capture target",hint:"Where to capture to",partOf:"Part of the capture destination"},captureText:{ask:"Text to capture",hint:"Text to add to the note",partOf:"Part of the text added to the note"},propertyName:{ask:"Property",hint:"Property name",partOf:"Part of the property name"},propertyValue:{ask:"Property value",hint:"Value to capture",partOf:"Part of the property value"},noteBody:{ask:"Note content",hint:"Text inserted into the note",partOf:"Part of the text inserted into the note"},folder:{ask:"Folder",hint:"Folder for the new note",partOf:"Part of the folder path"},templatePath:{ask:"Template",hint:"Path to the template file",partOf:"Part of the template path"},lineTarget:{ask:"Line to find",hint:"Existing line to anchor the capture to",partOf:"Part of the line to find"},filePath:{ask:"File to open",hint:"Path to the file to open",partOf:"Part of the file path"}},KQ=new RegExp(`^(?:${el.source})$`,"i"),QQ=new RegExp(el.source,"gi"),XQ=/\{\{[^}\n\r]*\}\}/;d2="\u2026"});function ca(r,e,t={}){if(!r||!e)return null;let n=r,i=n.metadataTypeManager??n.metadataCache?.app?.metadataTypeManager;if(!i||typeof i.getTypeInfo!="function")return null;if(t.registeredOnly){let a=i.getAllProperties?.();if(!a||typeof a!="object"||!Object.keys(a).some(l=>l.toLowerCase()===e.toLowerCase()))return null}let o=i.getTypeInfo(e),s=o?.expected?.type??o?.inferred?.type;return typeof s=="string"?s:null}function nX(r){return r!==null&&tX.has(r.toLowerCase())}function p2(r,e){return rX.has(e.toLowerCase())||nX(ca(r,e))}var tX,rX,_f=E(()=>{tX=new Set(["aliases","list","multitext","tags"]),rX=new Set(["aliases","cssclasses","tags"])});function iX(r,e=","){let t=[],n="",i=[],o=null;for(let a=0;a=0&&r[u]==="\\";u--)c++;c%2===0&&(o=null)}continue}if(l==='"'){o=l,n+=l;continue}if(l in f2){i.push(f2[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 oX(r){return r.includes(` `)?r.replace(/\r?\n/g,` `):r.includes("\\n")?r.replace(/\\n/g,` `):r}function sX(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function m2(r,e){let t=r.trim();if(!t)return;let n=oX(t),i=e?.propertyType??ca(e?.app,e?.propertyKey),o=sX(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=iX(n);if(u.length>1)return u}}var f2,h2=E(()=>{_f();f2={"[":"]","(":")","{":"}","<":">"}});function Af(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 iD(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function g2(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function v2(r){if(iD(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var If=E(()=>{});var y2,co,Sv=E(()=>{HI();h2();If();_f();y2="\0",co=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=pv(t),u=fv(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),p=d.trim(),f=d.match(/^\s*([^:]+):/),m=f?f[1].trim():s,g=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,v=null;if(u.isKeyValuePosition?v=[m]:g.test(p)&&(v=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!v||v.length===0)return;let y=v[v.length-1],b=o;if(l&&typeof o=="string"){let w=m2(o,this.buildParseOptions(y));w!==void 0&&(b=w)}if(!iD(b)||Array.isArray(b)&&b.length===0||!l&&!g2(b))return;let x=v.join(y2);return this.map.set(x,b),b}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 f=(d[1]??"").length;if(f0?o:null}resolvePropertyType(e){if(!this.app)return null;if(this.propertyTypeCache.has(e))return this.propertyTypeCache.get(e)??null;let t=ca(this.app,e);return this.propertyTypeCache.set(e,t),t}};co.PATH_SEPARATOR=y2});function b2(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 _x(r){return b2(r)!==null}function oD(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function sD(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function kx(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function aX(r){return/^\p{Ll}/u.test(r)&&kx(r)}function lX(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 cX(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(lX).filter(Boolean)}function _v(r,e){let t=b2(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=cX(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?aX(i)?i:i.toLowerCase():"",a=o.map(l=>sD(l)||kx(l)?l:oD(l));return[s,...a].join("")}case"pascal":return n.map(i=>sD(i)||kx(i)?i:oD(i)).join("");case"title":return n.map(i=>sD(i)||kx(i)?i:oD(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return kd(i)?`${i}-`:i}default:return r}}var Sx,Ax=E(()=>{wv();Sx=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function Ix(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var aD=E(()=>{});function lD(r){let{remaining:e,found:t}=ws(r,"optional"),{remaining:n,found:i}=ws(e,"trim");return{remaining:n,optional:t,trim:i}}function cD(r,e,t,n,i){let o=r.map(d=>{let p=d.trim();return{raw:p,option:Uo(p)}}),s=t?dX:w2,a=o.some(({option:d})=>d?.key==="type"&&["number","slider"].includes(d.value.toLowerCase())),l=d=>s.has(d)||a&&uX.has(d);if(!o.some(({raw:d,option:p})=>p&&l(p.key)||e&&["custom","multi"].includes(d.toLowerCase())))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let u={defaultValue:"",allowCustomInput:!1,usesOptions:!0,multiSelect:!1};for(let{raw:d,option:p}of o){if(e&&d.toLowerCase()==="custom"){u.allowCustomInput=!0;continue}if(e&&d.toLowerCase()==="multi"){u.multiSelect=!0;continue}if(!p||!l(p.key))continue;let{key:f,value:m}=p;switch(f){case"label":m&&(u.label=m);break;case"case":m&&(u.caseStyle=m);break;case"default":u.defaultValue=m;break;case"custom":u.allowCustomInput=Cc(m);break;case"type":m&&(u.inputTypeOverride=m);break;case"min":u.minRaw=m;break;case"max":u.maxRaw=m;break;case"step":u.stepRaw=m;break;case"text":u.displayValuesRaw=m;break;case"optional":u.optionalExplicit=Cc(m);break;case"trim":u.trimExplicit=Cc(m);break;case"multi":u.multiSelect=!0,u.multiEmit=m.trim().toLowerCase()==="linklist"?"linklist":"text";break;case"format":u.multiFormat=nx(m,n,i);break;case"name":m?u.name=m:i(`QuickAdd: empty |name: ignored in "${n}"; provide a variable name, e.g. {{VALUE:a,b|name:category}}.`);break;default:break}}return u}var uX,w2,dX,C2=E(()=>{xc();ix();uX=new Set(["min","max","step"]),w2=new Set(["label","default","custom","type","case","text","optional","trim","multi","format"]),dX=new Set([...w2,"name"])});function Df(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 pX(r){return r.minRaw!==void 0||r.maxRaw!==void 0||r.stepRaw!==void 0}function x2(r,e,t){let n=Df(r.minRaw),i=Df(r.maxRaw),o=Df(r.stepRaw),s={};for(let[a,l,c]of[["min",r.minRaw,n],["max",r.maxRaw,i]])l!==void 0&&(c===void 0?t(`QuickAdd: Ignoring invalid ${a} in VALUE token "${e}".`):s[a]=c);return s.min!==void 0&&s.max!==void 0&&s.max0?s:void 0}function uD(r,e,t,n){if(t!=="number"&&t!=="slider")return pX(r)&&n(`QuickAdd: Ignoring numeric range options in "${e}" because type is not number or slider.`),{inputTypeOverride:t};if(t!=="slider"){let c=x2(r,e,n);return{inputTypeOverride:t,numericConfig:c}}let i=Df(r.minRaw),o=Df(r.maxRaw),s=r.stepRaw===void 0?1:Df(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:x2(r,e,uv)};let l={min:i,max:o,step:s};return{inputTypeOverride:t,numericConfig:l,sliderConfig:l}}function E2(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 fX(r,e){return String(Number(r.toFixed(e)))}function Go(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(E2(a),E2(e.step));return fX(s,c)}return String(s)}function Ff(r,e){return Go(r,e)||String(e.min)}var dD=E(()=>{dv()});function Dx(r){return r!==void 0&&mX.has(r)}function _d(r){let e=[],t="",n=!1;for(let i=0;i=r.length||r[s]===","){n=!1,i=s-1;continue}return r.split(",")}t+=o;continue}if(o===","){e.push(t),t="";continue}if(Dx(o)&&t.trim()===""){n=!0,t="";continue}t+=o}return n?r.split(","):(e.push(t),e)}function Av(r){let e=r.trim();if(!Dx(e[0]))return r;let t=_d(e);return t.length===1&&t[0]!==e?t[0].trim():r}var mX,hX,pD=E(()=>{mX=new Set(['"',"\u201C","\u201D"]);hX=/[^\S\r\n]/});function yX(r,e,t){return t&&e?`${r}${fD}${e}`:r}function Iv(r){let e=r.indexOf(fD);return e===-1?r:r.slice(0,e)}function bX(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 Rc(r,e){if(!e)return null;let t=[e],n=Iv(e);n!==e&&t.push(n);for(let i of t){if(r.has(i)&&r.get(i)!==void 0)return i;let o=bX(r,i);if(o)return o}return null}function T2(r,e,t){if(r&&!_x(r)){t(`QuickAdd: Unsupported |case style "${r}" in token "${e}". Supported styles: ${Sx.join(", ")}.`);return}return r}function k2(r,{tokenDisplay:e,hasOptions:t,allowCustomInput:n},i){if(!r)return;let o=r.trim().toLowerCase(),s=o==="boolean"?"checkbox":o;if(!gX.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 Ad(r,e){if(!r)return null;let t=e?.warn??wf,n=qo(r),i=(n.shift()??"").trim();if(!i)return null;let o=_d(i).map(P=>P.trim()).filter(Boolean),s=o.length>1,{remaining:a,optional:l,trim:c}=lD(n),u=`{{VALUE:${r}}}`,d=cD(a,s,!0,u,t),{label:p,caseStyle:f,defaultValue:m,allowCustomInput:g}=d,v=d.multiSelect??!1,y=d.multiEmit??"text",b=d.multiFormat??"auto",x=d.optionalExplicit??l,w=d.trimExplicit??c;if(!d.usesOptions){let P=m;g=s&&P.toLowerCase()==="custom",m=g?"":P}s&&m&&(m=Av(m));let T=k2(d.inputTypeOverride,{tokenDisplay:u,hasOptions:s,allowCustomInput:g},t),C=uD(d,u,T,t),S;if(d.displayValuesRaw!==void 0){if(!s)throw new Error(`QuickAdd: VALUE option "text" is only supported for option-list tokens in "${u}".`);if(S=_d(d.displayValuesRaw).map(P=>P.trim()).filter(Boolean),S.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(S).size!==S.length)throw new Error(`QuickAdd: VALUE token "${u}" has duplicate text entries. Text entries must be unique.`)}let A=d.name?.trim()||void 0;A&&A.includes(fD)&&(t(`QuickAdd: |name in "${u}" contains a reserved control character and was ignored.`),A=void 0),A&&vX.has(A.toLowerCase())&&(t(`QuickAdd: |name:${A} is reserved and was ignored in "${u}". Choose a different name.`),A=void 0),A&&!s&&t(`QuickAdd: |name on a single value in "${u}" is redundant \u2014 use {{VALUE:${A}}} directly.`),f=T2(f,u,t),v&&!s&&(t(`QuickAdd: |multi needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),v=!1),v&&f&&(t(`QuickAdd: |case is ignored with |multi in "${u}" \u2014 a list is not case-transformed.`),f=void 0),!v&&d.multiFormat!==void 0&&(t(`QuickAdd: |format: needs |multi in "${u}"; ignoring.`),b="auto"),!s&&!d.usesOptions&&a.some(P=>P.trim().toLowerCase()==="custom")&&(t(`QuickAdd: |custom needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),m.toLowerCase()==="custom"&&(m=""));let D=A||yX(i,p,s);return{raw:r,variableName:i,aliasName:A,variableKey:D,label:p,caseStyle:f,defaultValue:m,allowCustomInput:g,suggestedValues:o,displayValues:S,hasOptions:s,inputTypeOverride:C.inputTypeOverride,numericConfig:C.numericConfig,sliderConfig:C.sliderConfig,optional:x,trim:w,multiSelect:v,multiEmit:y,multiFormat:b}}function Dv(r,e){let t=e?.warn??wf,n=ZN(r),i=qo(n).map(g=>g.trim()).filter(Boolean),{remaining:o,optional:s,trim:a}=lD(i);if(o.length===0)return{defaultValue:"",optional:s,trim:a};let l=`{{VALUE${r}}}`,c=cD(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:p}=c;c.usesOptions||(p=p.trim()),d=T2(d,l,t);let f=k2(c.inputTypeOverride,{tokenDisplay:l,hasOptions:!1,allowCustomInput:c.allowCustomInput},t),m=uD(c,l,f,t);return{label:u,caseStyle:d,defaultValue:p,inputTypeOverride:m.inputTypeOverride,numericConfig:m.numericConfig,sliderConfig:m.sliderConfig,optional:c.optionalExplicit??s,trim:c.trimExplicit??a}}var fD,gX,vX,uo=E(()=>{C2();dD();pD();dD();pD();xc();Ax();dv();fD="",gX=new Set(["multiline","number","slider","checkbox","text"]),vX=new Set(["value","title"])});function ua(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 Nc(r){return wX.includes(r)}function A2(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 I2(r){if(!Nc(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 S2.has(t)?!0:_2.has(t)?!1:!!e}default:return e}}function mD(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(S2.has(t))return!0;if(_2.has(t))return!1}return!!r;default:return r==null?"":ua(r)}}function CX(r){if(!Nc(r.operator))return"";let e=r.expectedValue??"";return e.length===0?"(empty)":r.valueType==="string"?`"${e}"`:e}function xX(r){let e=r.variableName?`$${r.variableName}`:"(missing variable)",t=TX(r.operator),n=Nc(r.operator)?` ${CX(r)}`:"";return`${e} ${t}${n}`.trim()}function EX(r){let e=r.exportName?`::${r.exportName}`:"";return`script ${r.scriptPath}${e}`}function Pf(r){return r.mode==="variable"?xX(r):EX(r)}function TX(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 wX,S2,_2,Id=E(()=>{wX=["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","contains","notContains"],S2=new Set(["true","1","yes","on"]),_2=new Set(["false","0","no","off"])});var kX,Fx,hD=E(()=>{Xe();Sf();Ie();Sv();Ax();If();rx();ix();aD();uo();dv();Id();kX=new Set(["number","slider","checkbox"]),Fx=class{constructor(e){this.app=e;this.variables=new Map;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 co(e)}async preserveSingleTokenValue(e,t){let n=this.singleTokenValue,i=/^(?:\{\{(?:VALUE|NAME)(?::[^{}]+|\|[^{}]+)?\}\}|\{\{(?:FIELD|FILE):[^{}]+\}\}|\{\{PROPERTY\}\}|`{3,}js quickadd[\s\S]*`{3,})$/i.test(e)?{input:e}:void 0;this.singleTokenValue=i;try{let o=await t();return i?.result&&typeof i.result.value!="string"?i.result.value:o}finally{this.singleTokenValue=n}}retainSingleTokenValue(e,t,n,i){this.singleTokenValue?.input===e&&t===0&&n===e.length&&(this.singleTokenValue.result={value:i})}propertyTokenValue(e,t){if(t==="text")return ua(e);if(t==="checkbox"){if(typeof e=="boolean")return e;if(e==="true")return!0;if(e==="false")return!1;throw new Error("A checkbox property value must be true or false.")}if(t==="number"||t==="slider"){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e!="string"||!/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e.trim())||!Number.isFinite(Number(e)))throw new Error("A number property value must be a finite number.");return Number(e)}return e}warn(e){I.logWarning(e)}reportProblem(e){I.logError(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=Cx(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?_x(t)?_v(e,t):(this.warn(`QuickAdd: Unsupported |case style "${t}" in token "${n}". Supported styles: ${Sx.join(", ")}.`),e):e}async replaceValueInString(e){let t=e;if(!el.test(t))return t;if(this.valuePromptContext=this.getValuePromptContext(t),this.hasConcreteVariable("value")){let i=this.variables.get("value");this.value=ua(i)}this.value===void 0&&(this.value=await this.promptForValue());let n=new RegExp(el.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 this.retainSingleTokenValue(a,s,s+o.length,this.hasConcreteVariable("value")?this.variables.get("value"):this.value),Ed(a,s,s+o.length,this.value);let u=l.slice(c),d=Dv(u,{warn:this.warnSink}),p=this.value===""&&d.defaultValue&&!d.optional?d.defaultValue:this.value,f=this.applyValueTextOptions(p,d);if(this.singleTokenValue){let m=this.value===""&&d.defaultValue&&!d.optional?d.defaultValue:this.hasConcreteVariable("value")?this.variables.get("value"):this.value;this.retainSingleTokenValue(a,s,s+o.length,this.propertyTokenValue(this.applyValueTokenOptions(m,d),d.inputTypeOverride))}return d.inputTypeOverride==="text"&&f!==""&&WI(a,s,s+o.length)?mv(f):Ed(a,s,s+o.length,f)}),t}applyValueTextOptions(e,t){let n=String(e??""),i=t.trim?n.trim():n;return _v(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(el.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=Dv(l,{warn:uv});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}getAndClearTemplatePropertyVars(){return this.propertyCollector.drain()}mergeTemplatePropertyVars(e){this.propertyCollector.merge(e)}renderCollectedOrArrayValue(e){if((!e.multiFormat||e.multiFormat==="auto")&&this.retainSingleTokenValue(e.input,e.matchStart,e.matchEnd,e.rawValue),Array.isArray(e.rawValue)&&e.multiFormat){let i=L1({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=v2(t);if(n!==void 0)return n;if(Array.isArray(e.rawValue))return Ed(e.input,e.matchStart,e.matchEnd,e.rawValue.join(","))}async withTemplatePropertyCollection(e){this.templatePropertyCollectionDepth+=1;try{return await e()}finally{this.templatePropertyCollectionDepth-=1}}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=Rc(this.variables,n);if(u)return u;let d=!c&&i?i:void 0,p=c&&i?i:void 0;if(c&&e.multiSelect){let m=await this.suggestForValueMulti(a,s,{placeholder:p,variableKey:n,displayValues:l,optional:e.optional});return this.variables.set(n,e.multiEmit==="linklist"?m.map(Ix):m),n}let f="";return c?f=await this.suggestForValue(a,s,{placeholder:p,variableKey:n,displayValues:l,optional:e.optional}):f=await this.promptForVariable(t,{defaultValue:o,description:d,inputTypeOverride:e.inputTypeOverride,numericConfig:e.numericConfig,sliderConfig:e.sliderConfig,variableKey:n,optional:e.optional}),!f&&o&&!e.optional&&(f=o),this.variables.set(n,f),n}async resolveNamedSuggesterDefinitions(e){if(!/\|\s*name\s*:/i.test(e))return;let t=new RegExp(od.source,"gi"),n=[],i;for(;(i=t.exec(e))!==null;){if(!i[1])continue;let a;try{a=Ad(i[1],{warn:uv})}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(od.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=Ad(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);this.singleTokenValue&&(!s.multiFormat||s.multiFormat==="auto")&&this.retainSingleTokenValue(t,o.index,o.index+o[0].length,this.propertyTokenValue(u,s.inputTypeOverride));let d=this.renderCollectedOrArrayValue({input:t,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:this.singleTokenValue?.result?this.singleTokenValue.result.value:u,fallbackKey:a,heuristicEnabled:i&&this.templatePropertyCollectionDepth>0&&s.inputTypeOverride!=="text",multiFormat:s.multiFormat}),p,f=!1;if(d!==void 0)p=d;else{let v=String(this.applyValueTextOptions(this.getVariableValue(l),s)??"");s.inputTypeOverride==="text"&&v!==""&&WI(t,o.index,o.index+o[0].length)?p=mv(v):kX.has(s.inputTypeOverride??"")&&zI(t,o.index,o.index+o[0].length)?(f=!0,p=v):p=Ed(t,o.index,o.index+o[0].length,v)}let m=f?o.index-1:o.index,g=o.index+o[0].length+(f?1:0);t=t.slice(0,m)+p+t.slice(g),n.lastIndex=m+p.length}return t}suggestForValueMulti(e,t,n){return[]}}});function Fv(r){if(!r)return{optional:!1,withTime:!1};let{remaining:e,found:t}=ws(qo(r),"optional"),{remaining:n,found:i}=ws(e,"time"),{remaining:o,found:s}=ws(n,"datetime"),a,l=!1,c,u,d=[];for(let f of o){let m=Uo(f.trim());if(m?.key==="optional"){a=Cc(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:FC(m.value)});continue}if(m?.key==="case"){u=m.value.trim()||void 0;continue}d.push(f)}return{defaultValue:d.join("|").trim()||void 0,optional:a??t,withTime:i||s||l,snap:c,...u?{caseStyle:u}:{}}}function Px(r){try{return{options:Fv(r)}}catch(e){return{options:{optional:!1,withTime:!1},error:e instanceof Error?e.message:String(e)}}}var Pv=E(()=>{xc();Yg()});function D2(r,e,t){return r.replace(e,()=>t)}function Mf(r){return r?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"}function $f(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=X.getState().dateAliases,a=n.parseDate(kg(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:rf(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:ua(i)}:{text:""}}function F2(r,e){let t=r;for(let n of[UR,CA]){let i=n===CA;for(;n.test(t);){let o=n.exec(t);if(i&&!o)throw M2("date",t,n);let s=o?.[i?2:1]?.replace("+","").trim(),a=s&&qR.test(s)?parseInt(s):void 0,l=o?.[i?3:2],c=e.clocks(),u=aa({...i?{format:o?.[1]}:{},offset:a,snap:l?JN(l)??void 0:void 0,origin:c?.date,now:c?.now});t=D2(t,n,e.applyCase(u,o?.[i?4:3],o?.[0]??"{{DATE}}"))}}return t}function P2(r,e){let t=r;for(let n of[HR,xA]){let i=n===xA;for(;n.test(t);){let o=n.exec(t);if(!o)throw M2("time",t,n);let s=aa({format:i?o[1]:"HH:mm",now:e.clocks()?.now});t=D2(t,n,e.applyCase(s,o[i?2:1],o[0]))}}return t}function M2(r,e,t){let n=e.search(t);return new Error(`Unable to parse ${r} format. Invalid syntax in: "${e.substring(Math.max(0,n-10),Math.min(e.length,n+30))}..."`)}async function $2(r,e){let t=new RegExp(mc.source,"gi"),n="",i=0,o;for(;(o=t.exec(r))!==null;){n+=r.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}=Fv(o[3]),p=o[2]?.trim()||Mf(c);if(e.variables.get(s)===void 0){let g=await e.prompt(s,{type:"VDATE",dateFormat:p,defaultValue:a,optional:l,withTime:c});if(l&&!g?.trim())e.variables.set(s,"");else if(g?.startsWith("@date:"))e.variables.set(s,g);else{if(!e.dateParser)throw new Error("Date parser is not available");let v=X.getState().dateAliases,y=kg(g,v),b=e.dateParser.parseDate(y);if(b)e.variables.set(s,`@date:${b.moment.toISOString()}`);else throw new Error(`unable to parse date variable ${g}${l?"":". Tip: add |optional inside the {{VDATE}} token to allow leaving this date empty"}`)}}let m=$f(e.variables.get(s),p,u,e.dateParser);m?.normalized!==void 0&&e.variables.set(s,m.normalized),n+=e.applyCase(m?.text??"",d,o[0])}return n+r.slice(i)}var gD=E(()=>{Xe();ht();dt();td();Yg();Pv();Id()});function Dd(r){let e=[],t=r.length,n=0;for(;n=3){a=c;break}s=c}if(a===-1)break;e.push({start:i,end:a}),n=a}return e}function yD(r){let e=Dd(r),t=r.length,n=e.length>0?e[e.length-1].end:0;for(;n=3&&r.startsWith(vD,o))return!0;n=o}return!1}var vD,bD=E(()=>{vD="js quickadd"});function O2(r,e,t,n){let i=new Map,o=new Set,s={LINKCURRENT:e.links,LINKSECTION:e.links,FILENAMECURRENT:e.fileName,FOLDER:e.folder,FOLDERCURRENT:e.activeFolder,TITLE:e.title},a=r.replace(/{{(?:(LINKCURRENT|LINKSECTION|FILENAMECURRENT|TITLE)|(FOLDERCURRENT|FOLDER)(\|name)?)}}/gi,(c,u,d,p)=>{let f=(u??d??"").toUpperCase();if(!(f in t))return c;let m=f;if(!s[m])return c;i.has(m)||i.set(m,t[m]());let g=i.get(m)??null;return(m==="FOLDERCURRENT"?g===null:(m==="LINKCURRENT"||m==="LINKSECTION"||m==="FILENAMECURRENT")&&!g)&&o.add(m),p&&g!==null?g.slice(g.lastIndexOf("/")+1):g??""}),l="Unable to get the active file's folder. Make sure you have a file open in the editor.";if(o.has("FOLDERCURRENT")&&e.activeFolder==="path")throw new Error(l);if(o.size>0){if(n==="required")throw new Error(o.has("LINKCURRENT")||o.has("LINKSECTION")?"Unable to get current file path. Make sure you have a file open in the editor.":o.has("FILENAMECURRENT")?"Unable to get current file name. Make sure you have a file open in the editor.":l);I.logMessage("Skipping current-file token replacement because no active file is available.")}return a}var R2=E(()=>{Ie()});function L2(r,e,t){return Array.isArray(r)?r.map(n=>N2(n,e,t)):N2(r,e,t)}function N2(r,e,t){if(e==="link")return t(r);let n=Td(r);switch(n.kind){case"empty":return"";case"file":return e==="path"?n.path:Mc(n.path);case"custom":case"raw":return n.kind==="custom"?n.text:n.value}}var V2=E(()=>{lo()});function B2(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 q2=E(()=>{});function H2(r){let e=r.trim();if(!e||/[\r\n\0]/.test(e)||e==="__proto__")throw new Error("Property name must be nonempty and contain no line breaks or unsafe keys.");return e}function z2(r){return Ag.test(r)}function W2(r){if(r==null)return"";if(Array.isArray(r)){if(!r.every(e=>typeof e=="string"))throw new Error("{{PROPERTY}} only expands lists of text.");if(r.some(e=>/[\r\n]/.test(e)))throw new Error("{{PROPERTY}} cannot expand a list item that contains a line break. Return a rewritten array from an inline script instead.");return r.join(` `)}if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return String(r);throw new Error("{{PROPERTY}} only expands text, finite numbers, checkboxes, and lists of text.")}function G2(r){return j2.map(e=>({key:e,present:r.has(e),value:r.get(e)}))}function Y2(r,e){for(let t of e)t.present?r.set(t.key,t.value):r.delete(t.key)}function K2(r,e,t){for(let i of j2)if(!(!r.has(i)||r.get(i)===void 0))throw new Error(`Property Capture cannot seed '${i}' because that variable is already set. Rename your {{VALUE:${i}}} prompt (or other writer of this key) so it does not collide with the property snapshot.`);let n;t!=null&&(n=SX(t,e)),r.set("propertyKey",e),r.set("propertyValue",n),r.set("list",Array.isArray(n)?[...n]:[])}function SX(r,e){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(t=>typeof t=="string"))return[...r];throw new Error(`Property '${e}' supports text, finite numbers, checkboxes, and lists of text only.`)}function Mv(r,e){if(Object.prototype.hasOwnProperty.call(r,e))return e;let t=Object.keys(r).filter(n=>n.trim().toLowerCase()===e.trim().toLowerCase());if(t.length>1)throw new Error(`Property '${e}' matches multiple properties in the target note.`);return t[0]??e}function Q2(r){return r.split(/\r?\n/).map(e=>e.trim()).filter(e=>e!=="")}function X2(r){return typeof r=="string"?Q2(r).length===0:Array.isArray(r)&&r.length===0}function U2(r,e){if(typeof r=="string"||typeof r=="boolean"||typeof r=="number"&&Number.isFinite(r))return r;if(Array.isArray(r)&&r.every(t=>typeof t=="string"))return[...r];throw new Error(`Property '${e}' supports text, finite numbers, checkboxes, and lists of text only.`)}function _X(r,e){if(r===null&&["tags","aliases","cssclasses"].includes(e.toLowerCase()))return"list";if(r===null)return null;switch(r.toLowerCase()){case"text":return"text";case"number":return"number";case"checkbox":case"boolean":return"checkbox";case"list":case"multitext":case"tags":case"aliases":return"list";case"date":return"date";case"datetime":return"datetime";default:throw new Error(`Property '${e}' has unsupported type '${r}'.`)}}function Mx(r){return Array.isArray(r)?"list":typeof r=="boolean"?"checkbox":typeof r=="number"?"number":"text"}function AX(r,e,t){let n=Mx(r);if(e==="date"||e==="datetime"){if(typeof r=="string"&&(r===""||(e==="date"?/^\d{4}-\d{2}-\d{2}$/:/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?$/).test(r)&&Number.isFinite(Date.parse(r))&&new Date(r.slice(0,10)).toISOString().slice(0,10)===r.slice(0,10)))return}else if(n===e)return;throw new Error(`Property '${t}' requires ${e}; the capture is ${n}. Use a matching typed VALUE token or value.`)}function Z2(r){let{frontmatter:e,config:t}=r,n=Mv(e,r.key),i=Object.prototype.hasOwnProperty.call(e,n);if(!i&&!t.createIfMissing)throw new Error(`Property '${n}' is missing. Enable 'Create property if missing' to add it.`);let o=i?e[n]:void 0,s=U2(r.value,n),a=o==null?null:U2(o,n),l=_X(r.registeredType,n)??(a===null?null:Mx(a)),c=typeof s=="string"?Q2(s):null;if(t.action==="addToList"){if(a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' is ${Mx(a)}. 'Add to list' requires a list.`);if(l!==null&&l!=="list")throw new Error(`Property '${n}' is ${l}. 'Add to list' requires a list.`);let d=c??s;if(!Array.isArray(d))throw new Error(`Property '${n}' requires text or a list of text to add.`);return d.length===0?a??[]:r.compose?[...new Set(d)]:[...new Set([...a??[],...d])]}if(l==="list"&&a!==null&&!Array.isArray(a))throw new Error(`Property '${n}' contains ${Mx(a)}. Set a list only after correcting the existing property to a list.`);if(l===null&&c!==null&&c.length>1)throw new Error(`Property '${n}' has no type yet, so ${c.length} lines could be one text value or a list. Use 'Add to list' to write them as list items, or set the property's type in Obsidian first - Text keeps the lines as one value.`);let u=l==="list"?c??s:s;return l!==null&&AX(u,l,n),Array.isArray(u)?[...new Set(u)]:u}function J2(r){let e=(0,Fd.getFrontMatterInfo)(r);if(!e.exists||!e.frontmatter.trim())return{};let t=(0,Fd.parseYaml)(e.frontmatter);if(t===null)return{};if(!t||typeof t!="object"||Array.isArray(t))throw new Error("The capture target's frontmatter must be a property mapping.");return Object.fromEntries(Object.entries(t))}function eV(r,e){let t=(0,Fd.getFrontMatterInfo)(r),n=t.exists?r.slice(t.contentStart):r;return`--- ${(0,Fd.stringifyYaml)(e)}--- ${n}`}var Fd,j2,wD=E(()=>{Fd=require("obsidian");Xe();j2=["propertyKey","propertyValue","list"]});var tV,$x,Lc,Pd=E(()=>{hD();gD();gD();bD();R2();tV=require("obsidian");Xe();lo();V2();Ie();rx();hl();q2();wD();hD();bD();$x=10,Lc=class extends Fx{constructor(){super(...arguments);this.linkToCurrentFileBehavior="required";this.targetFolderPath=null;this.propertyTokenExpanded=!1}runClocks(){return this.clocks}setTemplateInclusionState(t){this.templateInclusion=t}replaceDateInString(t){return F2(t,{clocks:()=>this.runClocks(),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}replaceTimeInString(t){return P2(t,{clocks:()=>this.runClocks(),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}async replaceSelectedInString(t){if(!SA.test(t))return t;let n=await this.getSelectedText(),i=new RegExp(SA.source,"gi");return t.replace(i,()=>n)}async replaceClipboardInString(t){if(!_A.test(t))return t;let n=await this.getClipboardContent(),i=new RegExp(_A.source,"gi");return t.replace(i,()=>n)}async replaceLinkToCurrentFileInString(t){if(!EA.test(t))return t;let n=this.getCurrentFileLink();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");I.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.")}let i=new RegExp(EA.source,"gi");return t.replace(i,()=>n??"")}replaceLinkToCurrentSectionInString(t){if(!TA.test(t))return t;let n=this.getCurrentFileLinkToSection();if(!n){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");I.logMessage("Skipping {{LINKSECTION}} replacement because no active file is available.")}let i=new RegExp(TA.source,"gi");return t.replace(i,()=>n??"")}replaceCurrentFileLinksInString(t){return this.replaceCurrentFileTokensInString(t,{links:!0})}replaceCurrentFileTokensInString(t,n){return O2(t,n,{LINKCURRENT:()=>this.getCurrentFileLink(),LINKSECTION:()=>this.getCurrentFileLinkToSection(),FILENAMECURRENT:()=>this.getCurrentFileName(),FOLDER:()=>this.targetFolderPath??"",FOLDERCURRENT:()=>this.getCurrentFolderPath(),TITLE:()=>this.getVariableValue("title")},this.linkToCurrentFileBehavior)}async replaceCurrentFileNameInString(t){return this.replaceCurrentFileTokensInString(t,{fileName:!0})}setLinkToCurrentFileBehavior(t){this.linkToCurrentFileBehavior=t}setTargetFolderPath(t){if(t==null){this.targetFolderPath=null;return}let n=t.trim();this.targetFolderPath=n==="/"?"":n.replace(/^\/+/,"").replace(/\/+$/,"")}replaceTargetFolderInString(t){return this.replaceCurrentFileTokensInString(t,{folder:!0})}getCurrentFileLinkToSection(){return null}getCurrentFolderPath(){return null}async replaceFieldVarInString(t){let n=new RegExp(cC.source,"gi"),i="",o=0,s;for(;(s=n.exec(t))!==null;){i+=t.slice(o,s.index);let a=s[1]+(s[2]||"");if(a){let l=this.getFieldVariableKey(a),c=oi.parse(a,{warnUnknown:!0,warn:this.warnSink});this.hasConcreteVariable(l)||this.variables.set(l,await this.suggestForField(a,c));let u=this.hasConcreteVariable(l)?this.variables.get(l):this.getVariableValue(l);(!c.multiFormat||c.multiFormat==="auto")&&this.retainSingleTokenValue(t,s.index,s.index+s[0].length,u);let d;Array.isArray(u)?d=this.renderCollectedOrArrayValue({input:t,matchStart:s.index,matchEnd:s.index+s[0].length,rawValue:u,fallbackKey:c.fieldName,heuristicEnabled:!1,multiFormat:c.multiFormat??"auto"})??u.join(","):d=Ed(t,s.index,s.index+s[0].length,String(u??"")),i+=d}else i+=s[0];o=n.lastIndex}return i+t.slice(o)}getFieldVariableKey(t){return`${sd}${t}`}async replaceFileInString(t){let n=new RegExp(uC.source,"gi"),i="",o=0,s;for(;(s=n.exec(t))!==null;){i+=t.slice(o,s.index);let a=ax(s[1]??"",{warn:this.warnSink});if(!a){i+=s[0],o=n.lastIndex;continue}let l=a.variableKey;this.hasConcreteVariable(l)||this.variables.set(l,await this.suggestForFile(a));let c=L2(this.variables.get(l),a.mode,u=>this.getFileLinkForStoredValue(u));if(Array.isArray(c)){let u=this.renderCollectedOrArrayValue({input:t,matchStart:s.index,matchEnd:s.index+s[0].length,rawValue:c,fallbackKey:a.aliasName??a.folderPath,heuristicEnabled:!1,multiFormat:a.multiFormat});i+=u??c.join(",")}else i+=c;o=n.lastIndex}return i+t.slice(o)}getFileLinkForStoredValue(t){let n=Td(t);if(n.kind==="empty")return"";if(n.kind!=="file"){let s=n.kind==="custom"?n.text:n.value;return s?`[[${s}]]`:""}let i=n.path;if(!i)return"";let o=this.app?.vault.getAbstractFileByPath(i);return o instanceof tV.TFile?this.app?.fileManager.generateMarkdownLink(o,this.getLinkSourcePath()??"")??`[[${Mc(i)}]]`:`[[${Mc(i)}]]`}getLinkSourcePath(){return null}async replaceMathValueInString(t){let n=new RegExp(pC.source,"gi"),i=this.variables.get("mvalue"),o=typeof i=="string"&&i.trim()?i:null,s="",a=0,l;for(;(l=n.exec(t))!==null;)s+=t.slice(a,l.index),s+=o??await this.promptForMathValue(),a=l.index+l[0].length;return s+=t.slice(a),s}async replaceMacrosInString(t){let n=t;for(;hc.test(n);){let i=hc.exec(n);if(!i)continue;if(!i[1]){n=this.replacer(n,hc,"");continue}let o=B2(i[1]);if(!o){n=this.replacer(n,hc,"");continue}let{macroName:s,label:a}=o,l=await this.getMacroValue(s,a?{label:a}:void 0);n=this.replacer(n,hc,l?l.toString():"")}return n}async replaceDateVariableInString(t){return $2(t,{variables:this.variables,dateParser:this.dateParser,prompt:(n,i)=>this.promptForVariable(n,i),applyCase:(n,i,o)=>this.applyCaseOption(n,i,o)})}async replaceTemplateInString(t){let n=t;for(;Oo.test(n);){let i=Oo.exec(n);if(!i||!i[1])continue;let o=i[1];if(this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.visited.has(o)){let a=`[QuickAdd: template inclusion cycle detected at "${o}"]`;this.reportProblem(a),n=this.replacer(n,Oo,a);continue}if(this.templateInclusion.depth>=$x){let a=`[QuickAdd: max template inclusion depth (${$x}) exceeded at "${o}"]`;this.reportProblem(a),n=this.replacer(n,Oo,a);continue}this.templateInclusion.visited.add(o);let s;try{s=await this.getTemplateContent(o)}finally{this.templateInclusion.visited.delete(o)}n=this.replacer(n,Oo,s)}return n}replaceLinebreakInString(t){let n="";for(let i=0;i=p)break;if(pm.start){d=!0;break}}}if(u!==-1&&!d){i+=t.slice(o,u+2),o=u+2;continue}}let l=t[o],c=t[o+1];l==="\\"?c==="n"?(i+=` `,o+=2):c==="\\"?(i+="\\",o+=2):(i+="\\",o+=1):(i+=l,o+=1)}return i}replaceRandomInString(t){let n=t;for(;AA.test(n);){let i=AA.exec(n);if(!i||!i[1])continue;let o=parseInt(i[1]);if(o<=0||o>100)throw new Error(`Random string length must be between 1 and 100. Got: ${o}`);let s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",a="";for(let l=0;li)}}});function nV(r){return r<=31||r===127||r===8232||r===8233}function PX(r){let e="",t=0;for(;t0&&e.includes(r[t-1]);)t--;return r.slice(0,t)}function Md(r){return MX.filter(e=>r.includes(e))}function sV(r){return`A file or folder name cannot contain ${cV(r)}, so this choice would fail at run time. ${lV}`}function aV(r,e){return`Cannot create "${e}": a file or folder name cannot contain ${cV(r)}. ${lV}`}function cV(r){return r.map(e=>`"${e}"`).join(", ")}function Wn(r,e="File path"){let{path:t,problems:n}=dV(r,e);if(n.length>0)throw new Error(n[0]);return t}function uV(r,e="File path"){return dV(r,e)}function dV(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):$X(o,e,t)).join("/"),problems:t}}function $X(r,e,t){if(r.length===0)return r;let n=DX.test(r),i=FX.test(r),o=PX(r);n&&(o=o.replace(/^ /u,"")),i&&(o=o.replace(/ $/u,""));let s=iV(o," ");return s==="."||s===".."?(t.push(`${e} cannot contain "." or ".." path segments.`),s):(o=iV(o,". "),o||t.push(`${e} contains an empty path segment after formatting.`),o)}var oV,DX,FX,MX,lV,da=E(()=>{oV="\0-\x7F\u2028\u2029",DX=new RegExp(`^ *[${oV}]`,"u"),FX=new RegExp(`[${oV}] *$`,"u");MX=[":"];lV="Check your own text and tokens like {{TIME}}, which is HH:mm."});function Bc(r,e){let t=r,n=new RegExp(dC.source,"gi"),i=0;for(;n.test(t)&&!(++i>5);)t=t.replace(n,(o,s)=>{let a=String(s??"").trim();if(!a)return o;let l=e?.[a];return typeof l=="string"?l:""});return t}var $v=E(()=>{Xe()});var gt,Qt,po,Cl=E(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(gt||(gt={}));(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"})(Qt||(Qt={}));(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"})(po||(po={}))});function Fs(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function Bx(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?gt.AM:gt.PM)}function xl(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Ov(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?gt.AM:gt.PM)}var $d=E(()=>{Cl()});function qc(r,e,t,n,i=0){let o=0,s=0;for(;sn.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}var VX,CD=E(()=>{Cl();VX={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=>hV(r,po.MARCH,Qt.SUNDAY,2),dstEnd:r=>hV(r,po.OCTOBER,Qt.SUNDAY,3)},CHADT:825,CHAST:765,CKT:-600,CLST:-180,CLT:-240,COT:-300,CST:-360,CT:{timezoneOffsetDuringDst:-300,timezoneOffsetNonDst:-360,dstStart:r=>qc(r,po.MARCH,Qt.SUNDAY,2,2),dstEnd:r=>qc(r,po.NOVEMBER,Qt.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=>qc(r,po.MARCH,Qt.SUNDAY,2,2),dstEnd:r=>qc(r,po.NOVEMBER,Qt.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=>qc(r,po.MARCH,Qt.SUNDAY,2,2),dstEnd:r=>qc(r,po.NOVEMBER,Qt.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=>qc(r,po.MARCH,Qt.SUNDAY,2,2),dstEnd:r=>qc(r,po.NOVEMBER,Qt.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 _n(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 Uc(r){let e={};for(let t in r)e[t]=-r[t];return e}var gV,El=E(()=>{gV={day:0,second:0,millisecond:0}});var Hc,Tt,Tl,Ps=E(()=>{$d();CD();El();Hc=class r{constructor(e,t){he(this,"instant");he(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=qx(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()}},Tt=class r{constructor(e,t){he(this,"knownValues");he(this,"impliedValues");he(this,"reference");he(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=gV){let n=_n(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"),Bx(i,n),Fs(i,n),i.assign("timezoneOffset",e.getTimezoneOffset())):(Ov(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=_n(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}},Tl=class r{constructor(e,t,n,i,o){he(this,"refDate");he(this,"index");he(this,"text");he(this,"reference");he(this,"start");he(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new Tt(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 xD(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function BX(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function an(r){return`(?:${BX(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var kl=E(()=>{});function Ux(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function zc(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=_n(n,{year:1}),o=_n(n,{year:-1});return Math.abs(i.getTime()-r.getTime()){El()});function qX(r){let e=r.toLowerCase();return ED[e]!==void 0?ED[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 qf(r){let e=r.toLowerCase();return TD[e]!==void 0?TD[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function fa(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 Ux(e)}function Yo(r){let e={},t=r,n=vV.exec(t);for(;n;)HX(e,n),t=t.substring(n[0].length).trim(),n=vV.exec(t);return Object.keys(e).length==0?null:e}function HX(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=qX(e[1]),n=Rv[e[2].toLowerCase()];r[n]=t}var Hx,kD,ki,ED,TD,yV,Rv,bV,Bf,Wc,wV,vV,UX,CV,Sl,jc,Fr=E(()=>{kl();Vf();Hx={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},kD={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},ki={...kD,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},ED={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},TD={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},yV={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"},Rv={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",...yV},bV=`(?:${an(ED)}|[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)?)`;Bf=`(?:${an(TD)}|[0-9]{1,2}(?:st|nd|rd|th)?)`;Wc="(?:[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)))";wV=`(${bV})\\s{0,3}(${an(Rv)})`,vV=new RegExp(wV,"i"),UX=`(${bV})\\s{0,3}(${an(yV)})`,CV="\\s{0,5},?(?:\\s*and)?\\s{0,5}",Sl=xD("(?:(?:about|around)\\s{0,3})?",wV,CV),jc=xD("(?:(?:about|around)\\s{0,3})?",UX,CV)});var Dt,ai=E(()=>{Dt=class{constructor(){he(this,"cachedInnerPattern",null);he(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{Fr();Ps();ai();zX=new RegExp(`(?:(?:within|in|for)\\s*)?(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Sl})(?=\\W|$)`,"i"),WX=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Sl})(?=\\W|$)`,"i"),jX=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${jc})(?=\\W|$)`,"i"),Nv=class extends Dt{constructor(t){super();he(this,"strictMode");this.strictMode=t}innerPattern(t){return this.strictMode?jX:t.option.forwardDate?zX:WX}innerExtract(t,n){if(n[0].match(/^for\s*the\s*\w+/))return null;let i=Yo(n[1]);return i?Tt.createRelativeFromReference(t.reference,i):null}}});var GX,EV,TV,YX,kV,Lv,SV=E(()=>{Vf();Fr();Fr();Fr();kl();ai();GX=new RegExp(`(?:on\\s{0,3})?(${Bf})(?:\\s{0,3}(?:to|\\-|\\\u2013|until|through|till)\\s{0,3}(${Bf}))?(?:-|/|\\s{0,3}(?:of)?\\s{0,3})(${an(ki)})(?:(?:-|/|,?\\s{0,3})(${Wc}(?!\\w)))?(?=\\W|$)`,"i"),EV=1,TV=2,YX=3,kV=4,Lv=class extends Dt{innerPattern(){return GX}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=ki[t[YX].toLowerCase()],o=qf(t[EV]);if(o>31)return t.index=t.index+t[EV].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[kV]){let s=fa(t[kV]);n.start.assign("year",s)}else{let s=zc(e.refDate,o,i);n.start.imply("year",s)}if(t[TV]){let s=qf(t[TV]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var KX,QX,_V,SD,_D,Vv,AV=E(()=>{Vf();Fr();Fr();Fr();kl();ai();KX=new RegExp(`(${an(ki)})(?:-|/|\\s*,?\\s*)(${Bf})(?!\\s*(?:am|pm))\\s*(?:(?:to|\\-)\\s*(${Bf})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${Wc}))?(?=\\W|$)(?!\\:\\d)`,"i"),QX=1,_V=2,SD=3,_D=4,Vv=class extends Dt{constructor(t){super();he(this,"shouldSkipYearLikeDate");this.shouldSkipYearLikeDate=t}innerPattern(){return KX}innerExtract(t,n){let i=ki[n[QX].toLowerCase()],o=qf(n[_V]);if(o>31||this.shouldSkipYearLikeDate&&!n[SD]&&!n[_D]&&n[_V].match(/^\d{2}$/))return null;let s=t.createParsingComponents({day:o,month:i}).addTag("parser/ENMonthNameMiddleEndianParser");if(n[_D]){let c=fa(n[_D]);s.assign("year",c)}else{let c=zc(t.refDate,o,i);s.imply("year",c)}if(!n[SD])return s;let a=qf(n[SD]),l=t.createParsingResult(n.index,n[0]);return l.start=s,l.end=s.clone(),l.end.assign("day",a),l}}});var XX,ZX,JX,IV,Bv,DV=E(()=>{Fr();Vf();kl();Fr();ai();XX=new RegExp(`((?:in)\\s*)?(${an(ki)})\\s*(?:(?:,|-|of)?\\s*(${Wc})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),ZX=1,JX=2,IV=3,Bv=class extends Dt{innerPattern(){return XX}innerExtract(e,t){let n=t[JX].toLowerCase();if(t[0].length<=3&&!kD[n])return null;let i=e.createParsingResult(t.index+(t[ZX]||"").length,t.index+t[0].length);i.start.imply("day",1),i.start.addTag("parser/ENMonthNameParser");let o=ki[n];if(i.start.assign("month",o),t[IV]){let s=fa(t[IV]);i.start.assign("year",s)}else{let s=zc(e.refDate,1,o);i.start.imply("year",s)}return i}}});var e7,t7,r7,FV,n7,qv,PV=E(()=>{Fr();kl();ai();e7=new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${an(ki)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),t7=1,r7=2,FV=3,n7=4,qv=class extends Dt{constructor(t){super();he(this,"strictMonthDateOrder");this.strictMonthDateOrder=t}innerPattern(){return e7}innerExtract(t,n){let i=parseInt(n[t7]),o=parseInt(n[n7]),s=n[FV]?parseInt(n[FV]):ki[n[r7].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 i7,o7,s7,a7,Uv,MV=E(()=>{Fr();kl();Fr();ai();i7="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-9][0-9]{3})",o7=new RegExp(`(${i7})(?:\\s*[-.\\/,]?\\s*|\\s+of\\s+)(${an(ki)})(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),s7=1,a7=2,Uv=class extends Dt{innerPattern(){return o7}innerExtract(e,t){let n=fa(t[s7]),i=t[a7].toLowerCase(),o=ki[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 l7,c7,u7,Hv,$V=E(()=>{ai();l7=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),c7=1,u7=2,Hv=class extends Dt{innerPattern(){return l7}innerExtract(e,t){let n=parseInt(t[u7]),i=parseInt(t[c7]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});function d7(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 p7(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 AD,Od,zx,Wx,Uf,jx,OV=E(()=>{Cl();AD=2,Od=3,zx=4,Wx=5,Uf=6,jx=class{constructor(e=!1){he(this,"strictMode");he(this,"cachedPrimaryPrefix",null);he(this,"cachedPrimarySuffix",null);he(this,"cachedPrimaryTimePattern",null);he(this,"cachedFollowingPhase",null);he(this,"cachedFollowingSuffix",null);he(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[AD]);if(a>100){if(t[AD].length==4&&t[Od]==null&&!t[Uf]||this.strictMode||t[Od]!=null)return null;o=a%100,a=Math.floor(a/100)}if(a>24)return null;if(t[Od]!=null){if(t[Od].length==1&&!t[Uf])return null;o=parseInt(t[Od])}if(o>=60)return null;if(a>12&&(s=gt.PM),t[Uf]!=null){if(a>12)return null;let l=t[Uf][0].toLowerCase();l=="a"&&(s=gt.AM,a==12&&(a=0)),l=="p"&&(s=gt.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",gt.AM):i.imply("meridiem",gt.PM),t[Wx]!=null){let l=parseInt(t[Wx].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[zx]!=null){let l=parseInt(t[zx]);if(l>=60)return null;i.assign("second",l)}return i}extractFollowingTimeComponents(e,t,n){let i=e.createParsingComponents();if(t[Wx]!=null){let l=parseInt(t[Wx].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[zx]!=null){let l=parseInt(t[zx]);if(l>=60)return null;i.assign("second",l)}let o=parseInt(t[AD]),s=0,a=-1;if(t[Od]!=null?s=parseInt(t[Od]):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=gt.PM),t[Uf]!=null){if(o>12)return null;let l=t[Uf][0].toLowerCase();l=="a"&&(a=gt.AM,o==12&&(o=0,i.isCertain("day")||i.imply("day",i.get("day")+1))),l=="p"&&(a=gt.PM,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==gt.AM?(n.start.imply("meridiem",gt.AM),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",gt.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",gt.AM):o<=12&&(i.assign("hour",o+12),i.assign("meridiem",gt.PM)):o>12?i.imply("meridiem",gt.PM):o<=12&&i.imply("meridiem",gt.AM),i.date().getTime()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=d7(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=p7(e,t),this.cachedFollowingPhase=e,this.cachedFollowingSuffix=t,this.cachedFollowingTimePatten)}}});var zv,RV=E(()=>{Cl();OV();zv=class extends jx{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",gt.PM)):i<6&&n.assign("meridiem",gt.AM)}if(t[0].endsWith("afternoon")){n.assign("meridiem",gt.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",gt.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 f7,m7,Wv,NV=E(()=>{Fr();Ps();ai();El();f7=new RegExp(`(${Sl})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),m7=new RegExp(`(${jc})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),Wv=class extends Dt{constructor(t){super();he(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?m7:f7}innerExtract(t,n){let i=Yo(n[1]);return i?Tt.createRelativeFromReference(t.reference,Uc(i)):null}}});var h7,g7,v7,jv,LV=E(()=>{Fr();Ps();ai();h7=new RegExp(`(${Sl})\\s{0,5}(?:later|after|from now|henceforth|forward|out)(?=(?:\\W|$))`,"i"),g7=new RegExp(`(${jc})\\s{0,5}(later|after|from now)(?=\\W|$)`,"i"),v7=1,jv=class extends Dt{constructor(t){super();he(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?g7:h7}innerExtract(t,n){let i=Yo(n[v7]);return i?Tt.createRelativeFromReference(t.reference,i):null}}});var Hf,Ko,Gc=E(()=>{Hf=class{refine(e,t){return t.filter(n=>this.isValid(e,n))}},Ko=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0],o=null;for(let s=1;s{console.log(`${this.constructor.name} merged ${l} and ${c} into ${u}`)}),i=u}}return i!=null&&n.push(i),n}}});var Gv,VV=E(()=>{Gc();El();Gv=class extends Ko{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()&&_n(s,{day:7})>o?(s=_n(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()&&_n(o,{day:-7})o?(s=_n(s,{year:1}),n.start.imply("year",s.getFullYear())):t.start.isDateWithUnknownYear()&&_n(o,{year:-1}){VV();Yv=class extends Gv{patternBetween(){return/^\s*(to|-|–|until|through|till)\s*$/i}}});function ID(r,e){let t=r.clone(),n=r.start,i=e.start;if(t.start=qV(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=qV(o,s);if(r.end==null&&a.date().getTime()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")==gt.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 UV=E(()=>{Cl();$d()});var Kv,HV=E(()=>{Gc();UV();Kv=class extends Ko{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()?ID(t,n):ID(n,t);return i.index=t.index,i.text=t.text+e+n.text,i}}});var zf,zV=E(()=>{HV();zf=class extends Kv{patternBetween(){return new RegExp("^\\s*(T|at|after|before|on|of|,|-|\\.|\u2219|:)?\\s*$")}}});var y7,Qv,WV=E(()=>{CD();y7=new RegExp("^\\s*,?\\s*\\(?([A-Z]{2,4})\\)?(?=\\W|$)","i"),Qv=class{constructor(e){he(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=y7.exec(o);if(!s)return;let a=s[1].toUpperCase(),l=i.start.date()??i.refDate??new Date,c={...this.timezoneOverrides,...n},u=qx(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 b7,w7,C7,x7,Xv,jV=E(()=>{b7=new RegExp("^\\s*(?:\\(?(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?\\)?","i"),w7=1,C7=2,x7=3,Xv=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=b7.exec(i);if(!o)return;e.debug(()=>{console.log(`Extracting timezone: '${o[0]}' into : ${n}`)});let s=parseInt(o[C7]),a=parseInt(o[x7]||"0"),l=s*60+a;l>840||(o[w7]==="-"&&(l=-l),n.end!=null&&n.end.assign("timezoneOffset",l),n.start.assign("timezoneOffset",l),n.text+=o[0])}),t}}});var Yc,DD=E(()=>{Yc=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0];for(let o=1;o=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 GV(r,e,t){let n=r.getDateWithAdjustedTimezone(),i=E7(n,e,t),o=new Tt(r);return o=o.addDurationAsImplied({day:i}),o.assign("weekday",e),o}function E7(r,e,t){let n=r.getDay();switch(t){case"this":return Rd(r,e);case"last":return YV(r,e);case"next":return n==Qt.SUNDAY?e==Qt.SUNDAY?7:e:n==Qt.SATURDAY?e==Qt.SATURDAY?7:e==Qt.SUNDAY?8:1+e:e=0&&(n-=7),n}var FD=E(()=>{Cl();Ps()});var Zv,KV=E(()=>{$d();$d();El();FD();Zv=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),xl(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()&&(xl(n.end,s),n.start.date()>n.end.date()&&(s.setDate(s.getDate()+1),xl(n.end,s)))}if(n.start.isOnlyWeekdayComponent()&&i>n.start.date()){let o=Rd(i,n.start.get("weekday"))||7,s=_n(i,{day:o});if(xl(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=Rd(i,n.start.get("weekday"))||7,l=_n(i,{day:a});xl(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 Jv,QV=E(()=>{Gc();Jv=class extends Hf{constructor(t){super();he(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 k7,S7,_7,A7,XV,I7,ZV,JV,D7,eB,tB,ey,rB=E(()=>{ai();k7=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"),S7=1,_7=2,A7=3,XV=4,I7=5,ZV=6,JV=7,D7=8,eB=9,tB=10,ey=class extends Dt{innerPattern(){return k7}innerExtract(e,t){let n=e.createParsingComponents({year:parseInt(t[S7]),month:parseInt(t[_7]),day:parseInt(t[A7])});if(t[XV]!=null&&(n.assign("hour",parseInt(t[XV])),n.assign("minute",parseInt(t[I7])),t[ZV]!=null&&n.assign("second",parseInt(t[ZV])),t[JV]!=null&&n.assign("millisecond",parseInt(t[JV])),t[D7]!=null)){let i=0;if(t[eB]){let o=parseInt(t[eB]),s=0;t[tB]!=null&&(s=parseInt(t[tB])),i=o*60,i<0?i-=s:i+=s}n.assign("timezoneOffset",i)}return n.addTag("parser/ISOFormatParser")}}});var ty,nB=E(()=>{Gc();ty=class extends Ko{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 iB(r,e=!1){return r.parsers.unshift(new ey),r.refiners.unshift(new ty),r.refiners.unshift(new Xv),r.refiners.unshift(new Yc),r.refiners.push(new Qv),r.refiners.push(new Yc),r.refiners.push(new Zv),r.refiners.push(new Jv(e)),r}var oB=E(()=>{WV();jV();DD();KV();QV();rB();nB()});function sB(r){let e=r.getDateWithAdjustedTimezone(),t=new Tt(r,{});return Fs(t,e),Bx(t,e),t.assign("timezoneOffset",r.getTimezoneOffset()),t.addTag("casualReference/now"),t}function aB(r){let e=r.getDateWithAdjustedTimezone(),t=new Tt(r,{});return Fs(t,e),Ov(t,e),t.delete("meridiem"),t.addTag("casualReference/today"),t}function lB(r){return F7(r,1).addTag("casualReference/yesterday")}function cB(r){return Gx(r,1).addTag("casualReference/tomorrow")}function F7(r,e){return Gx(r,-e)}function Gx(r,e){let t=r.getDateWithAdjustedTimezone(),n=new Tt(r,{}),i=new Date(t.getTime());return i.setDate(i.getDate()+e),Fs(n,i),Ov(n,i),n.delete("meridiem"),n}function uB(r,e=22){let t=r.getDateWithAdjustedTimezone(),n=new Tt(r,{});return Fs(n,t),n.imply("hour",e),n.imply("meridiem",gt.PM),n.addTag("casualReference/tonight"),n}function dB(r,e=20){let t=new Tt(r,{});return t.imply("meridiem",gt.PM),t.imply("hour",e),t.addTag("casualReference/evening"),t}function pB(r){let e=new Tt(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 fB(r,e=6){let t=new Tt(r,{});return t.imply("meridiem",gt.AM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/morning"),t}function mB(r,e=15){let t=new Tt(r,{});return t.imply("meridiem",gt.PM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/afternoon"),t}function hB(r){let e=new Tt(r,{});return e.imply("meridiem",gt.AM),e.assign("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("millisecond",0),e.addTag("casualReference/noon"),e}var PD=E(()=>{Ps();$d();Cl()});var P7,ry,vB=E(()=>{ai();$d();PD();P7=/(now|today|tonight|tomorrow|overmorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i,ry=class extends Dt{innerPattern(e){return P7}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"now":o=sB(e.reference);break;case"today":o=aB(e.reference);break;case"yesterday":o=lB(e.reference);break;case"tomorrow":case"tmr":case"tmrw":o=cB(e.reference);break;case"tonight":o=uB(e.reference);break;case"overmorrow":o=Gx(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}Fs(o,n),o.imply("hour",0)}break}return o.addTag("parser/ENCasualDateParser"),o}}});var M7,ny,yB=E(()=>{ai();PD();M7=/(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|midday|noon)(?=\W|$)/i,ny=class extends Dt{innerPattern(){return M7}innerExtract(e,t){let n=null;switch(t[1].toLowerCase()){case"afternoon":n=mB(e.reference);break;case"evening":case"night":n=dB(e.reference);break;case"midnight":n=pB(e.reference);break;case"morning":n=fB(e.reference);break;case"noon":case"midday":n=hB(e.reference);break}return n&&n.addTag("parser/ENCasualTimeParser"),n}}});var $7,O7,R7,N7,iy,bB=E(()=>{Fr();kl();ai();FD();Cl();$7=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:on\\s*?)?(?:(this|last|past|next)\\s*)?(${an(Hx)}|weekend|weekday)(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(?:of\\s*)?(this|last|past|next)\\s*week)?(?=\\W|$)`,"i"),O7=1,R7=2,N7=3,iy=class extends Dt{innerPattern(){return $7}innerExtract(e,t){let n=t[O7],i=t[N7],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[R7].toLowerCase(),l;if(Hx[a]!==void 0)l=Hx[a];else if(a=="weekend")l=s=="last"?Qt.SUNDAY:Qt.SATURDAY;else if(a=="weekday"){let c=e.reference.getDateWithAdjustedTimezone().getDay();c==Qt.SUNDAY||c==Qt.SATURDAY?l=s=="last"?Qt.FRIDAY:Qt.MONDAY:(l=c-1,l=s=="last"?l-1:l+1,l=l%5+1)}else return null;return GV(e.reference,l,s)}}});var L7,V7,B7,oy,wB=E(()=>{Fr();Ps();ai();kl();L7=new RegExp(`(this|last|past|next|after\\s*this)\\s*(${an(Rv)})(?=\\s*)(?=\\W|$)`,"i"),V7=1,B7=2,oy=class extends Dt{innerPattern(){return L7}innerExtract(e,t){let n=t[V7].toLowerCase(),i=t[B7].toLowerCase(),o=Rv[i];if(n=="next"||n.startsWith("after")){let l={};return l[o]=1,Tt.createRelativeFromReference(e.reference,l)}if(n=="last"||n=="past"){let l={};return l[o]=-1,Tt.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 q7,U7,H7,CB,xB,MD,sy,EB=E(()=>{Vf();q7=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"),U7=1,H7=5,CB=2,xB=3,MD=4,sy=class{constructor(e){he(this,"groupNumberMonth");he(this,"groupNumberDay");this.groupNumberMonth=e?xB:CB,this.groupNumberDay=e?CB:xB}pattern(){return q7}extract(e,t){let n=t.index+t[U7].length,i=t.index+t[0].length-t[H7].length;if(n>0&&e.text.substring(0,n).match("\\d/?$")||i12)&&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[MD]){let c=parseInt(t[MD]),u=Ux(c);s.start.assign("year",u)}else{let c=zc(e.refDate,l,a);s.start.imply("year",c)}return s.addTag("parser/SlashDateFormatParser")}}});var z7,W7,ay,TB=E(()=>{Fr();Ps();ai();El();z7=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${Sl})(?=\\W|$)`,"i"),W7=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${jc})(?=\\W|$)`,"i"),ay=class extends Dt{constructor(t=!0){super();he(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?z7:W7}innerExtract(t,n){let i=n[1].toLowerCase(),o=Yo(n[2]);if(!o)return null;switch(i){case"last":case"past":case"-":o=Uc(o);break}return Tt.createRelativeFromReference(t.reference,o)}}});function j7(r){return r.text.match(/^[+-]/i)!=null}function kB(r){return r.text.match(/^-/i)!=null}var ly,SB=E(()=>{Gc();Ps();Fr();El();ly=class extends Ko{shouldMergeResults(e,t,n){return e.match(/^\s*$/i)?j7(n)||kB(n):!1}mergeResults(e,t,n,i){let o=Yo(n.text);kB(n)&&(o=Uc(o));let s=Tt.createRelativeFromReference(Hc.fromDate(t.start.date()),o);return new Tl(t.reference,t.index,`${t.text}${e}${n.text}`,s)}}});function _B(r){return r.text.match(/\s+(before|from)$/i)!=null}function G7(r){return r.text.match(/\s+(after|since)$/i)!=null}var cy,AB=E(()=>{Gc();Ps();Fr();El();cy=class extends Ko{patternBetween(){return/^\s*$/i}shouldMergeResults(e,t,n){return!e.match(this.patternBetween())||!_B(t)&&!G7(t)?!1:!!n.start.get("day")&&!!n.start.get("month")&&!!n.start.get("year")}mergeResults(e,t,n){let i=Yo(t.text);_B(t)&&(i=Uc(i));let o=Tt.createRelativeFromReference(Hc.fromDate(n.start.date()),i);return new Tl(n.reference,t.index,`${t.text}${e}${n.text}`,o)}}});var Y7,K7,uy,IB=E(()=>{Fr();Y7=new RegExp(`^\\s*(${Wc})`,"i"),K7=1,uy=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=Y7.exec(i);if(!o||o[0].trim().length<=3)return;e.debug(()=>{console.log(`Extracting year: '${o[0]}' into : ${n}`)});let s=fa(o[K7]);n.end!=null&&n.end.assign("year",s),n.start.assign("year",s),n.text+=o[0]}),t}}});var dy,DB=E(()=>{Gc();dy=class extends Hf{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 Nd,$D=E(()=>{xV();SV();AV();DV();PV();MV();$V();RV();NV();LV();BV();zV();oB();vB();yB();bB();wB();EB();TB();SB();AB();DD();IB();DB();Nd=class{createCasualConfiguration(e=!1){let t=this.createConfiguration(!1,e);return t.parsers.push(new ry),t.parsers.push(new ny),t.parsers.push(new Bv),t.parsers.push(new oy),t.parsers.push(new ay),t.refiners.push(new dy),t}createConfiguration(e=!0,t=!1){let n=iB({parsers:[new sy(t),new Nv(e),new Lv,new Vv(t),new iy,new Hv,new zv(e),new Wv(e),new jv(e),new Uv],refiners:[new zf]},e);return n.parsers.unshift(new qv(e)),n.refiners.unshift(new cy),n.refiners.unshift(new ly),n.refiners.unshift(new Yc),n.refiners.push(new zf),n.refiners.push(new uy),n.refiners.push(new Yv),n}}});var Wf,OD,FB=E(()=>{Ps();$D();Wf=class r{constructor(e){he(this,"parsers");he(this,"refiners");he(this,"defaultConfig",new Nd);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 OD(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 Tl?u=c:c instanceof Tt?(u=e.createParsingResult(a.index,a[0]),u.start=c):u=e.createParsingResult(a.index,a[0],c);let d=u.index,p=u.text;e.debug(()=>console.log(`${t.constructor.name} extracted (at index=${d}) '${p}'`)),n.push(u),s=o.substring(d+p.length),a=i.exec(s)}return n}},OD=class{constructor(e,t,n){he(this,"text");he(this,"option");he(this,"reference");he(this,"refDate");this.text=e,this.option=n??{},this.reference=Hc.fromInput(t,this.option.timezones),this.refDate=this.reference.instant}createParsingComponents(e){return e instanceof Tt?e:new Tt(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 Tl(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 RD,PB,Q7,BNe,MB=E(()=>{FB();$D();RD=new Nd,PB=new Wf(RD.createCasualConfiguration(!1)),Q7=new Wf(RD.createConfiguration(!0,!1)),BNe=new Wf(RD.createCasualConfiguration(!0))});function $B(r,e,t){return Z7.parseDate(r,e,t)}var Z7,OB=E(()=>{MB();Z7=PB});function r9(r){return!e9.test(r)}var e9,t9,ND,Qo,Ld=E(()=>{OB();e9=/\b(?:last|previous)\b|\bpast\s+(?:few\s+)?(?:\w*day|weekend|week|month|year|jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\w*\b/i,t9=/\bprevious\b/gi;ND=class{getParsedDate(e,t=new Date){let n=e.replace(t9,"last");return $B(n,t,{forwardDate:r9(n)})}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}}},Qo=new ND});function yy(r){return typeof r=="string"&&vy.includes(r)}function _l(r){if(!r||typeof r!="object")return;let e=r;switch(e.kind){case"now":return{kind:"now"};case"ask":{let t=typeof e.defaultValue=="string"?e.defaultValue.trim():"";return t?{kind:"ask",defaultValue:t}:{kind:"ask"}}case"relative":return typeof e.offset!="number"||!Number.isInteger(e.offset)||!yy(e.unit)?void 0:{kind:"relative",offset:e.offset,unit:e.unit};case"variable":return typeof e.name!="string"||!e.name.trim()?void 0:{kind:"variable",name:e.name.trim()};default:return}}var vy,Kf=E(()=>{vy=["days","weeks","months","years"]});function iE(r){return f9.has(r)}function Al(r){if(!r||r.kind==="now")return"today";if(r.kind==="ask")return"ask";if(r.kind==="variable")return"variable";for(let e of VD)if(r.offset===e.offset&&r.unit===e.unit)return e.id;return"custom"}function oE(r){let{preset:e,previous:t}=r;if(e!=="today"){if(e==="ask")return t?.kind==="ask"?t:VB(Al(t));if(e==="variable")return t?.kind==="variable"?t:{kind:"variable",name:""};if(e==="custom")return t?.kind==="relative"&&Al(t)==="custom"?t:{kind:"relative",offset:-2,unit:"days"};for(let n of VD)if(n.id===e)return{kind:"relative",offset:n.offset,unit:n.unit}}}function VB(r){for(let e of nE)if(e.id===r&&e.defaultValue)return{kind:"ask",defaultValue:e.defaultValue};return{kind:"ask"}}function Cy(r){let e=(r??"").trim().toLowerCase();for(let t of nE)if(t.aliases.some(n=>n===e))return t.id;return"kept"}function sE(r){let e=nE.map(t=>({value:t.id,label:t.label}));if(Cy(r)==="kept"){let t=r?.trim();t&&e.push({value:"kept",label:t})}return e}function aE(r,e){if(r==="kept"){let t=e?.trim();return t||void 0}for(let t of nE)if(t.id===r)return t.defaultValue}function BB(r){return typeof r=="string"&&r.trim().toLowerCase()==="ask"}function Qf(r){return r?.kind==="ask"?r:VB(Al(r))}var p9,Qx,Xx,Zx,Jx,by,eE,wy,tE,VD,rE,nE,f9,Kc=E(()=>{p9=["today","ask","yesterday","last-week","next-week","last-month","custom","variable"],Qx="Which day",Xx="The day {{DATE}} writes. The clock stays now. Hold Shift in the QuickAdd menu to pick a different day.",Zx="Picker starts on",Jx="The date the picker suggests first. You can still pick a different day.",by="How far from today",eE="How many days, weeks, months, or years from today. Negative is the past.",wy="Variable name",tE="A VDATE or script value that already has the day.",VD=[{id:"yesterday",label:"Yesterday",offset:-1,unit:"days"},{id:"last-week",label:"Last week",offset:-1,unit:"weeks"},{id:"next-week",label:"Next week",offset:1,unit:"weeks"},{id:"last-month",label:"Last month",offset:-1,unit:"months"}],rE=[{value:"today",label:"Today"},{value:"ask",label:"Ask each time"},...VD.map(r=>({value:r.id,label:r.label})),{value:"custom",label:"Custom\u2026"},{value:"variable",label:"A variable\u2026"}],nE=[{id:"today",label:"Today",defaultValue:void 0,aliases:["","today"]},{id:"yesterday",label:"Yesterday",defaultValue:"yesterday",aliases:["yesterday","yd"]},{id:"last-week",label:"Last week",defaultValue:"last week",aliases:["last week","lw"]},{id:"next-week",label:"Next week",defaultValue:"next week",aliases:["next week","nw"]},{id:"last-month",label:"Last month",defaultValue:"last month",aliases:["last month","lm"]}],f9=new Set(p9)});function I9(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 HB(r){let e=oi.parse(`__capture_scope|${r}`);return{filter:e.filters,multiSelect:e.multiSelect??!1}}function D9(r){return!!(r.folder||r.folders?.length||r.tags?.length||r.excludeFolders?.length||r.excludeTags?.length||r.excludeFiles?.length)}function Xf(r){let e=r.trim();if(!e)return null;if(e.startsWith("#")){let o=qo(e),s=(o.shift()??"").replace(/^#/,"").replace(/\.md$/i,"").trim();if(!s)return null;let a=o.length>0?HB(o.join("|")):{filter:{},multiSelect:!1};return{filter:{...a.filter,tags:I9(s,a.filter.tags)},multiSelect:a.multiSelect}}let t=qo(e)[0]??"",n=Uo(t);if(!n||!A9.has(n.key))return null;let i=HB(e);return D9(i.filter)?i:null}var A9,pE=E(()=>{hl();xc();A9=new Set(["folder","tag","exclude-folder","exclude-tag","exclude-file"])});function Zf(r){let e=r.trim();if(!zB.test(e))return null;let t=e.replace(zB,""),{fieldName:n,filters:i}=oi.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}}var zB,fE=E(()=>{hl();zB=/^property:/i});function rq(r){let e=vE.find(t=>t.id===(r===void 0?"open":r));if(!e)throw new Error(`Unknown existing-note action: ${String(r)}`);return e}function yE(r){return rq(r).id}function Zc(r){return rq(r).verb}function tm(r){let e=J9.get(r);if(!e)throw new Error(`Unknown file exists mode: ${r}`);return e}function nq(r){return ZD.filter(e=>e.category===r)}function iq(r){return tm(r).category}function oq(){return[...ZD]}function sq(r){return r.kind==="prompt"?"prompt":iq(r.mode)}function aq(r,e){return r==="prompt"?{kind:"prompt"}:e?.kind==="apply"&&iq(e.mode)===r?e:{kind:"apply",mode:eZ[r]}}function lq(r){return typeof r!="string"||!Object.prototype.hasOwnProperty.call(eq,r)?null:eq[r]??null}async function cq(r,e,t){return await tZ[e](r,t)}async function rZ(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=uq(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 nZ(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=uq(t),o=n.match(/^(.*) \((\d+)\)$/);t=`${o?`${o[1]} (${String(BigInt(o[2])+1n)})`:`${n} (1)`}${i}`}return t}function uq(r){return cr.test(r)?{basename:r.replace(cr,""),extension:".canvas"}:wn.test(r)?{basename:r.replace(wn,""),extension:".base"}:{basename:r.replace(Nt,""),extension:".md"}}var tq,ZD,vE,J9,eZ,eq,tZ,Dl=E(()=>{Xe();tq=[{id:"prompt",label:"Ask every time"},{id:"update",label:"Update existing file"},{id:"create",label:"Create another file"},{id:"keep",label:"Keep existing file"}],ZD=[{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"}],vE=[{id:"open",label:"Open note",verb:"Open"},{id:"appendBottom",label:"Append template to bottom",verb:"Append to"},{id:"appendTop",label:"Insert template at top",verb:"Insert into"},{id:"overwrite",label:"Replace entire note",verb:"Replace"}];J9=new Map(ZD.map(r=>[r.id,r])),eZ={update:"appendBottom",create:"duplicateSuffix",keep:"doNothing"},eq={"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"},tZ={increment:rZ,duplicateSuffix:nZ}});function yF(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Or.toLowerCase()||t===BR.toLowerCase()}function bF(r,e){return r.discoverExistingNotesBeforeCreate===!0&&yF(r,e)}function nu(r,e,t){return!(!bF(r,e)||t!=null)}var zd=E(()=>{Xe()});function Zq(r){let e=t=>{t.preventDefault(),t.stopPropagation()};r.addEventListener("pointerdown",e),r.addEventListener("mousedown",e)}function MJ(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 qy,Si,Wd=E(()=>{qy=require("obsidian"),Si=class r extends qy.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 qy.ButtonComponent(t).setButtonText("No").onClick(()=>this.submit(!1));Zq(n.buttonEl);let i=new qy.ButtonComponent(t).setButtonText("Yes").onClick(()=>this.submit(!0)).setDestructive();Zq(i.buttonEl),i.buttonEl.focus(),MJ([n.buttonEl,i.buttonEl])}submit(t){this.input=t,this.close()}onClose(){super.onClose(),this.resolvePromise(this.input)}}});var fr,vr=E(()=>{fr=(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))(fr||{})});function Os(r,e){let t=e;for(;t=r.length)break;let n=kF(r,t,new Map);if(!n?.name){t+=1;continue}if(t=Os(r,n.end),r[t]!==":"){t+=1;continue}if(t=Os(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let o=Uy(r,t);if(!o)break;e.set(n.name,o.value),t=o.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}let i=r[t];if(i==="{"||i==="["){let o=NE(r,t,i,i==="{"?"}":"]");if(o===-1)break;t=o+1;continue}for(;t=a)break;let c=kF(t,l,o);if(!c){l+=1;continue}if(l=Os(t,c.end),t[l]!==":"){l+=1;continue}if(l=Os(t,l+1),t[l]!=="{"){l+=1;continue}let u=NE(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);UJ(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}var VJ,nU=E(()=>{zg();VJ=/\.md$/i});function qr(r){return typeof r=="object"&&r!==null}function iu(r){return qr(r)&&!Array.isArray(r)}function HJ(r){return iu(r)?!1:Array.isArray(r)?r.length>0:sr(r)}function Er(r){return iu(r)?r.commands:HJ(r)?r:void 0}function Ht(r){return Array.isArray(r)?r:[]}function bm(r){return Array.isArray(r)?r:[]}function zy(r){return Array.isArray(r)}function SF(r){let e=Ht(r),t=new Set,n=!1,i=[];for(let o of e){if(Array.isArray(o)){let l=SF(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:Kt()};t.add(d.id),i.push(d)}n=!0;continue}if(!qr(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:Kt()};t.add(a.id),i.push(a),n=!0}return n?{commands:i,changed:n}:{commands:e,changed:!1}}function iU(r){oU(r,new Set)}function oU(r,e){qr(r)&&(e.has(r)||(e.add(r),iu(r)&&(r.id=Kt()),LE(Er(r),e)))}function LE(r,e){if(zy(r))for(let t of r){if(Array.isArray(t)){LE(t,e);continue}if(!qr(t)||e.has(t))continue;e.add(t),t.id=Kt();let n=t;LE(n.thenCommands,e),LE(n.elseCommands,e),sU(n.choice,e)}}function sU(r,e){if(!qr(r)||e.has(r))return;e.add(r);let t=r;if(t.id=Kt(),t.type==="Macro"&&oU(t.macro,e),t.type==="Multi"&&Array.isArray(t.choices))for(let n of t.choices)sU(n,e)}var un=E(()=>{sv();Ss();sv()});function Cm(r){return r!==null&&typeof r=="object"}function HE(r){return r?.secretStorage}function BE(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"setting"}function WJ(r){let e=5381;for(let t=0;t>>0).toString(36).slice(0,zJ)}function lU(r,e){return r.length<=e?r:r.slice(0,e).replace(/-+$/g,"")||"setting"}function uU(r,e){let t=e?.id;return typeof t=="string"&&t.trim().length>0?t:r}function _F(r,e,t){let i=(t?[VE,r,e,t]:[VE,r,e]).join("-");if(i.length<=aU)return i;let o=WJ([r,e,t].filter(Boolean).join(":")),s=t?4:3,a=aU-VE.length-o.length-(t?.length??0)-s,l=Math.max(8,Math.floor(a*.6)),c=Math.max(8,a-l);return[VE,lU(r,l),lU(e,c),...t?[t]:[],o].join("-")}function AF(r){return r?.message??String(r)}function xm(r){return Cm(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}function wm(r){return Cm(r)&&r[cU]===!0&&typeof r.secretRef=="string"&&r.secretRef.trim().length>0}function qE(r){return{[cU]:!0,secretRef:r}}function jJ(r,e,t){let n=r.id?.trim()||r.path||r.name||"script";return _F(BE(n),BE(uU(e,t)))}function GJ(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>xm(t)).map(([t])=>t):[]}function YJ(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>xm(t)):[]}function KJ(r){return typeof r.id=="string"&&r.id.trim().length>0}async function IF(r,e){let t=HE(r);if(!t?.getSecret)return null;try{return await Promise.resolve(t.getSecret(e))}catch(n){return I.logWarning(`Failed to read user script SecretStorage entry "${e}": ${AF(n)}`),null}}async function QJ(r,e,t){let n=HE(r);if(!n?.setSecret)return!1;try{return await Promise.resolve(n.setSecret(e,t)),!0}catch(i){return I.logWarning(`Failed to write user script SecretStorage entry "${e}": ${AF(i)}`),!1}}async function XJ(r,e,t,n,i){let o=e.id?.trim()||e.path||e.name||"script",s=BE(o),a=BE(uU(t,i)),l=_F(s,a),c=1;for(;;){let u=await IF(r,l);if(!u||u===n)return l;c+=1,l=_F(s,a,String(c))}}async function DF(r,e,t,n,i,o){if(n.length===0)return null;let s=i?.trim()||await XJ(r,e,t,n,o);return await QJ(r,s,n)?s:null}async function FF(r,e){let t=e?.trim();if(!t)return!0;let n=HE(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){I.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${AF(o)}`)}return!1}async function dU(r,e,t){let n=e.settings??{},i={...n},o=new Set(GJ(t));for(let[s,a]of Object.entries(n)){if(wm(a)){let l=await IF(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 zE(r,e,t){let n=YJ(t);if(n.length===0)return!1;let i=HE(r);if(!i?.getSecret||!i?.setSecret)return n.some(([a])=>{let l=e.settings?.[a];return typeof l=="string"&&l.length>0})&&I.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(wm(l))continue;if(typeof l!="string"||l.length===0){if(!KJ(a))continue;let u=jJ(e,s,a);if(!await IF(r,u))continue;e.settings[s]=qE(u);for(let[p,f]of Object.entries(e.settings))p!==s&&wm(f)&&f.secretRef===u&&delete e.settings[p];o=!0;continue}let c=await DF(r,e,s,l,void 0,a);c&&(e.settings[s]=qE(c),o=!0)}return o}function WE(r,e){let t=r.settings?.[e];return wm(t)?t.secretRef:void 0}async function ZJ(r,e){if(!Cm(e))return!0;let t=Object.values(e).filter(wm).map(i=>i.secretRef);return(await Promise.all(t.map(i=>FF(r,i)))).every(Boolean)}function*PF(r){if(Cm(r)&&(r.type==="Macro"&&(yield*UE(Er(r.macro))),r.type==="Multi"&&Array.isArray(r.choices)))for(let e of r.choices)yield*PF(e)}function*MF(r){Cm(r)&&(r.type==="UserScript"&&(yield r),yield*UE(r.thenCommands),yield*UE(r.elseCommands),yield*PF(r.choice))}function*UE(r){if(Array.isArray(r))for(let e of r)yield*Array.isArray(e)?UE(e):MF(e)}async function JJ(r,e){let t=!0;for(let n of e)t=await ZJ(r,n.settings)&&t;return t}async function jE(r,e){return JJ(r,MF(e))}function eee(r,e){let t=r.path;if(typeof t=="string")return e?.secretOptionNamesByPath?.get(t)}function tee(r,e,t){if(Cm(r))for(let[n,i]of Object.entries(r)){if(wm(i)){delete r[n];continue}typeof i=="string"&&(e===null||e?.has(n)||e===void 0&&t?.stripUnknownStringSettings===!0)&&delete r[n]}}function pU(r,e){for(let t of r)tee(t.settings,eee(t,e),e)}function fU(r,e){pU(MF(r),e)}function GE(r,e){pU(PF(r),e)}var VE,cU,aU,zJ,Ml=E(()=>{Ie();nU();un();VE="quickadd-user-script",cU="__quickaddSecret",aU=64,zJ=8});function Em(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&&!xm(e.options[t])&&(r[t]=e.options[t].defaultValue)}}var YE=E(()=>{Ml()});function Ui(r){if(r.length===0)return 0;let e=new TextEncoder().encode(r).length,t=!1;for(let i=0;i127){t=!0;break}return Math.max(1,Math.ceil(e/(t?3:4)))}function hU(r){return!Number.isFinite(r)||r<=0?1:Math.max(1,Math.floor(r*.45))}var Wy=E(()=>{});function bU(){return X.getState().ai.providers.flatMap(e=>e.models).map(e=>e.name)}function RF(){return X.getState().ai.providers}function gU(r,e){for(let t of r){let n=t.models.find(i=>i.name===e);if(n)return{provider:t,model:n}}}function OF(r){let e=RF();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 yU(r,e){vU.has(r)||(vU.add(r),I.logWarning(e))}function Gd(r,e){let t=RF(),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=gU(t,r.name);return l?(n||yU(`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=gU(t,r);if(i){let s=OF(r);return s.length>1&&!n&&yU(`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 wU(r.slice(0,o),r.slice(o+1))}function wU(r,e){let t=RF(),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 jy(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?wU(r.provider,e):Gd(e);if(!t){let n=e.includes("/")?e.slice(e.indexOf("/")+1):e,i=[...OF(e),...n!==e?OF(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 vU,Tm=E(()=>{Ie();dt();vU=new Set});var eT=E(()=>{});var ho=E(()=>{});var Pn,$l=E(()=>{Ss();Pn=class{constructor(e,t){this.name=e,this.type=t,this.id=Kt()}}});var _t,Rs=E(()=>{vr();$l();ys();Ie();_t=class extends Pn{constructor(e){super(e,"EditorCommand"),this.editorCommandType=e}static getSelectedText(e){return this.getActiveMarkdownView(e).editor.getSelection()}static getActiveMarkdownView(e){let t=xn(e);if(!t)throw I.logError("no active markdown editor."),new Error("no active markdown editor.");return t}}});var Sm,BF=E(()=>{ho();Rs();Sm=class extends _t{constructor(){super("Copy")}static async run(e){let t=_t.getSelectedText(e);await navigator.clipboard.writeText(t)}}});var _m,qF=E(()=>{ho();Rs();Ie();_m=class extends _t{constructor(){super("Cut")}static async run(e){let t=_t.getSelectedText(e),n=_t.getActiveMarkdownView(e);if(!t){I.logError("nothing selected.");return}await navigator.clipboard.writeText(t),n.editor.replaceSelection("")}}});var Am,UF=E(()=>{ho();Ie();Rs();Am=class extends _t{constructor(){super("Paste")}static async run(e){let t=await navigator.clipboard.readText(),n=_t.getActiveMarkdownView(e);if(!n){I.logError("no active markdown view.");return}n.editor.replaceSelection(t)}}});var kU,Im,HF=E(()=>{kU=require("obsidian");Ie();Rs();ho();Im=class extends _t{constructor(){super("Paste with format")}static async run(e){let t=_t.getActiveMarkdownView(e);if(!t){I.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,kU.htmlToMarkdown)(l),o=!0;break}o||(n=await navigator.clipboard.readText())}else n=await navigator.clipboard.readText();t.editor.replaceSelection(n)}catch(i){I.logWarning(`Formatted paste failed. Falling back to plain text: ${i}`);try{let o=await navigator.clipboard.readText();t.editor.replaceSelection(o)}catch(o){I.logError(`Failed to read clipboard text: ${o}`)}}}}});var Dm,zF=E(()=>{ho();Rs();Dm=class extends _t{constructor(){super("Select active line")}static run(e){let t=_t.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 Fm,WF=E(()=>{Rs();ho();Xe();Ie();Fm=class extends _t{constructor(){super("Select link on active line")}static run(e){let t=_t.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n),o=gN.exec(i);if(!o){I.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 Pm,jF=E(()=>{Rs();ho();Pm=class extends _t{constructor(){super("Move cursor to file start")}static run(e){_t.getActiveMarkdownView(e).editor.setCursor({line:0,ch:0})}}});var Mm,GF=E(()=>{Rs();ho();Mm=class extends _t{constructor(){super("Move cursor to file end")}static run(e){let t=_t.getActiveMarkdownView(e),n=t.editor.lastLine(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});var $m,YF=E(()=>{Rs();ho();$m=class extends _t{constructor(){super("Move cursor to line start")}static run(e){let t=_t.getActiveMarkdownView(e),{line:n}=t.editor.getCursor();t.editor.setCursor({line:n,ch:0})}}});var Om,KF=E(()=>{Rs();ho();Om=class extends _t{constructor(){super("Move cursor to line end")}static run(e){let t=_t.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});var DU,Nm,ZF=E(()=>{DU=require("obsidian");Ie();rn();ur();Nm=class extends DU.FuzzySuggestModal{constructor(t,n,i,o,s){super(t);this.warnedOnEmptyDisplay=!1;this.warnRenderItemFailure=ff("Custom renderItem threw an error; falling back to default rendering");this.renderItem=o,this.items=i,this.displayItems=n.map(a=>kn(a)),this.promise=new Promise((a,l)=>{this.resolvePromise=a,this.rejectPromise=l}),s?.skippable&&XL(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 kn(c??a)}))}getItemText(t){let n=this.items.indexOf(t),i=n>=0?this.displayItems[n]:void 0;return kn(i??t)}getItems(){return this.items}getSuggestions(t){let n=Ac(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)}}renderDefaultSuggestion(t,n){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(Rr())}warnIfEmptyDisplay(){if(this.warnedOnEmptyDisplay)return;this.displayItems.some(n=>n.length===0)&&(this.warnedOnEmptyDisplay=!0,I.logWarning("QuickAdd suggester received empty display values. Check your displayItems mapping."))}}});var FU,Mr,Ol=E(()=>{FU=require("obsidian");rn();ZF();Mr=class r extends Nm{constructor(t,n,i,o={}){super(t,n,i,o.renderItem,o);this.warnCustomValueFailure=ff("Custom create-row rendering threw an error; falling back to default rendering");this.allowCustomValue=!0;this.searchItems=o.searchItems?.map(s=>kn(s))??[],this.allowCustomValue=o.allowCustomValue??!0,this.customValueLabel=o.customValueLabel,this.valueExists=o.valueExists,o.placeholder&&this.setPlaceholder(o.placeholder),typeof o.limit=="number"&&(this.limit=o.limit),o.emptyStateText&&(this.emptyStateText=o.emptyStateText),this.searchItems.length!==this.items.length&&(this.searchItems=this.items.map((s,a)=>kn(this.searchItems[a]??this.displayItems[a]??s))),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 kn(i??t)}getSuggestions(t){let n=super.getSuggestions(t);if(!this.allowCustomValue)return n;let i=Ac(this.inputEl.value);if(!i||this.items.includes(i)||this.valueExists?.(i)||n.some(a=>a.item===i))return n;let s={item:i,match:{score:Number.NEGATIVE_INFINITY,matches:[]}};return this.customValueLabel?n.unshift(s):n.push(s),n}renderSuggestion(t,n){if(this.customValueLabel&&t.match.score===Number.NEGATIVE_INFINITY){this.renderCustomValue(t.item,n);return}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,FU.setIcon)(o.createSpan({cls:"suggestion-flair"}),"file-plus")}catch(i){this.warnCustomValueFailure(i),n.empty(),this.renderDefaultSuggestion({item:t,match:{score:0,matches:[]}},n)}}}});function GU(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 Nee){let o=t[i];o!==void 0&&n.push(...GU(o,e))}return n}function xT(r){return Number(r.replace(/,/g,""))}function Lee(r){let e=r.match(/context (?:length|window)(?:\s+is)?(?:\s+of)?\s*(\d[\d,]*)/i);return e?xT(e[1]):null}function Vee(r){let e=r.match(/(\d[\d,]*)\s*(?:tokens?\s+)?in the completion\b/i);if(e){let n=xT(e[1]),i=Lee(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=xT(t[2]),i=t[3]?xT(t[3]):null;return i===null?"input":n>=i?"output":"input"}return null}function eb(r){let e=GU(r).join(" "),t=Vee(e);return t==="output"?"output_budget":t==="input"?"input_context":Ree.some(n=>n.test(e))?"output_budget":Oee.some(n=>n.test(e))?"input_context":"other"}function YU(r){return eb(r)==="input_context"}function ET(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 Oee,Ree,Nee,Um=E(()=>{Oee=[/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],Ree=[/max_tokens/i,/max_completion_tokens/i,/max(?:imum)? output tokens/i,/output token limit/i],Nee=["message","code","type","status","statusText","providerCode","error","response","json","cause"]});function Qee(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function Xee(r){let e=r.name?.trim()||"provider";return`${Kee}-${Qee(e)}`}async function ZU(r,e){if(!r?.secretStorage?.getSecret)return null;try{return await Promise.resolve(r.secretStorage.getSecret(e))}catch(t){return I.logWarning(`Failed to read SecretStorage entry "${e}": ${t.message??t}`),null}}async function Ca(r,e){let t=e.apiKeyRef?.trim();if(t){let n=await ZU(r,t);if(n)return n}return e.apiKey??""}async function JU(r,e,t){let n=t?.trim();if(!n||!r?.secretStorage?.getSecret||!r.secretStorage?.setSecret)return null;let i=Xee(e),o=i,s=1;for(;;){let a=await ZU(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 I.logWarning(`Failed to write SecretStorage entry "${o}": ${a.message??a}`),null}}var Kee,Yd=E(()=>{Ie();Kee="quickadd-ai"});function VH(r){try{let e=window.require;return e?e(r):null}catch{return null}}async function Km(r,e){let t=r.vault.adapter;if(typeof EP.FileSystemAdapter!="function"||!(t instanceof EP.FileSystemAdapter))return;let n=VH("fs"),i=VH("path");if(!n?.promises||!i)return;let o=await n.promises.realpath(t.getBasePath()),a=t.getFullPath(e);for(;!sre(n,a);){let p=i.dirname(a);if(p===a)break;a=p}let l;try{l=await n.promises.realpath(a)}catch{throw new nb(`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 nb(`Refusing to write to "${e}": it resolves (via a symlink) outside the vault.`);if(c.split(i.sep).some(p=>p.startsWith(".")))throw new nb(`Refusing to write to "${e}": it resolves (via a symlink) into a config/hidden directory.`)}function sre(r,e){try{return r.lstatSync(e),!0}catch{return!1}}var EP,nb,TP=E(()=>{EP=require("obsidian"),nb=class extends Error{constructor(e){super(e),this.name="VaultWriteEscapeError"}}});async function cb(r,e,t){let n=Date.now();if(!(r instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");let i=!1,o=()=>{i=!0};for(r.then(o,o);!i;)e.setMessage(t[0],`${t[1]} (${((Date.now()-n)/1e3).toFixed(2)}s)`),await sleep(100);return e.setMessage("finished",`Took ${((Date.now()-n)/1e3).toFixed(2)}s.`),await r}function ub(r,e){return{[r]:e,[`${r}-quoted`]:("> "+e).replace(/\n/g,` > `)}}var XP=E(()=>{});var ye,Yn=E(()=>{Ni();ye=class extends yt{}});var Xt,Zo=E(()=>{ZF();Xt=class r extends Nm{static Suggest(e,t,n,i,o,s){let a=new r(e,t,n,o,s);return i&&a.setPlaceholder(i),a.promise}constructor(e,t,n,i,o){super(e,t,n,i,o),this.warnIfEmptyDisplay(),this.open()}}});function $n(r,e){if(!r)throw new Error(typeof e=="function"?e():e)}var Jm=E(()=>{});function eh(r){return ZP.filter(e=>typeof r[e]=="number")}function ok(r){let e={...r};for(let t of ZP)delete e[t];return e}function JP(r,e){return r.supportsTemperature===!1&&eh(e).length>0?ok(e):e}function vz(r,e){return e.length===0?!1:Mne.some(t=>t.test(r))}function e0(r){let e=r.map(t=>Pne[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]}`}function db(r,e){let t={};return typeof e.temperature=="number"&&(t.temperature=e.temperature),typeof e.top_p=="number"&&(t[r==="gemini"?"topP":"top_p"]=e.top_p),t}var ZP,Pne,ik,Mne,sk=E(()=>{ZP=["temperature","top_p","frequency_penalty","presence_penalty"],Pne={temperature:"Temperature",top_p:"Top P",frequency_penalty:"Frequency penalty",presence_penalty:"Presence penalty"};ik=ZP.join("|"),Mne=[new RegExp(`unsupported (?:parameter|value)[^.]{0,40}['\`"]?(?:${ik})['\`"]?`,"i"),new RegExp(`['\`"]?(?:${ik})['\`"]?[^.]{0,40}(?:is deprecated|is not supported|not supported|does not support)`,"i"),new RegExp(`unrecognized request argument[^.]{0,40}(?:${ik})`,"i"),new RegExp(`(?:${ik})[^.]{0,40}extra inputs are not permitted`,"i")]});function t0(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function r0(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return Jo.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),bz(),e}function pb(r,e){let t=Jo.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,bz())}function yz(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:Jo.slice(-e).map(t0).reverse()}function bz(){if(Jo.length<=25)return;let r=Jo.length-25;for(;r>0;){let e=Jo.findIndex(t=>t.status!=="pending");if(e===-1)break;Jo.splice(e,1),r-=1}}function wz(r){let e=Jo.find(t=>t.id===r);return e?t0(e):null}function Cz(){let r=Jo[Jo.length-1];return r?t0(r):null}function xz(){Jo.splice(0,Jo.length)}var Jo,n0=E(()=>{Jo=[]});function ak(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 i0=E(()=>{});function fb(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]=fb(o);e.properties=n}return e.items&&!Array.isArray(e.items)&&(e.items=fb(e.items)),t&&(e.additionalProperties=!1,e.required=e.properties?Object.keys(e.properties):[]),e}function $ne(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 One(r){return r.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.strict?fb(e.parameters):e.parameters,...e.strict?{strict:!0}:{}}}))}function Rne(r){return typeof r=="string"?r:{type:"function",function:{name:r.name}}}function Lne(r,e){let t={model:r,...e.modelParams??{},messages:$ne(e.messages)};return e.tools&&e.tools.length>0&&(t.tools=One(e.tools),e.toolChoice&&(t.tool_choice=Rne(e.toolChoice)),e.disableParallel&&(t.parallel_tool_calls=!1)),e.maxOutputTokens!==void 0&&(Nne.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?fb(e.responseFormat.schema):e.responseFormat.schema}}:{type:"json_object"}),t}function Vne(r){let e=r.choices?.[0]??{},t=e.message??{},i=(t.tool_calls??[]).map(a=>Bne(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 Ez(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:null}function Bne(r){let e=r.function.arguments;if(typeof e=="string")try{let n=Ez(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=Ez(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 qne(r,e,t){let n=[],i=[];for(let s of e.messages)if(s.role==="system")s.content&&n.push(s.content);else if(s.role==="user")i.push({role:"user",content:s.content});else if(s.role==="assistant"){let a=[];s.content&&a.push({type:"text",text:s.content});for(let l of s.toolCalls??[])a.push({type:"tool_use",id:l.id,name:l.name,input:l.args??{}});i.push({role:"assistant",content:a})}else i.push({role:"user",content:s.results.map(a=>({type:"tool_result",tool_use_id:a.toolCallId,content:a.content,...a.isError?{is_error:!0}:{}}))});let o={model:r,max_tokens:e.maxOutputTokens??t,messages:i};return n.length>0&&(o.system=n.join(` `)),Object.assign(o,db("anthropic",e.modelParams??{})),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(s=>({name:s.name,description:s.description,input_schema:s.parameters})),e.toolChoice?o.tool_choice=Une(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:fb(e.responseFormat.schema)}}),o}function Une(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 Hne(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 zne(r,e){let t=[],n=[];for(let s of e.messages)if(s.role==="system")s.content&&t.push(s.content);else if(s.role==="user")n.push({role:"user",parts:[{text:s.content}]});else if(s.role==="assistant")if(Array.isArray(s.providerRaw))n.push({role:"model",parts:s.providerRaw});else{let a=[];s.content&&a.push({text:s.content});for(let l of s.toolCalls??[])a.push({functionCall:{name:l.name,args:l.args??{}}});n.push({role:"model",parts:a})}else n.push({role:"user",parts:s.results.map(a=>({functionResponse:{name:a.name,response:a.isError?{error:a.content}:{result:a.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(` `)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(s=>({name:s.name,description:s.description,parameters:s.parameters}))}],e.toolChoice&&(i.toolConfig=Wne(e.toolChoice)));let o=db("gemini",e.modelParams??{});return 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 Wne(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function jne(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 o0(r,e,t,n=8192){switch(r){case"anthropic":return qne(e,t,n);case"gemini":return zne(e,t);default:return Lne(e,t)}}function Tz(r,e){switch(r){case"anthropic":return Hne(e);case"gemini":return jne(e);default:return Vne(e)}}var Nne,kz=E(()=>{sk();Nne=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function mb({kind:r,apiKey:e,provider:t,model:n,body:i,afterRequest:o}){let s={"Content-Type":"application/json"},a;switch(r){case"anthropic":a="/v1/messages",s["x-api-key"]=e,s["anthropic-version"]="2023-06-01";break;case"gemini":a=`/v1beta/models/${encodeURIComponent(n.name)}:generateContent`,s["x-goog-api-key"]=e;break;default:a="/chat/completions",s.Authorization=`Bearer ${e}`}let l=(0,Sz.requestUrl)({url:t.endpoint+a,method:"POST",headers:s,body:JSON.stringify(i),throw:!1});o?.();let c=await l;if(c.status>=400)throw ET(t.name,c);return c.json}function Gne(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 Yne(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()}}function hb(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}function Kne(r,e,t,n,i){if(r!=="anthropic"&&r!=="gemini")return{model:e.name,...n,messages:[{role:"system",content:t},{role:"user",content:i}]};let o=db(r,n);return r==="anthropic"?{model:e.name,max_tokens:hb(e),messages:[{role:"user",content:i}],...t&&t.trim().length>0?{system:t}:{},...o}:{contents:[{role:"user",parts:[{text:i}]}],...t&&t.trim().length>0?{systemInstruction:{role:"system",parts:[{text:t}]}}:{},...Object.keys(o).length?{generationConfig:o}:{}}}async function _z({kind:r,systemPrompt:e,params:t,prompt:n,...i}){let o=Kne(r,i.model,e,t,n),s={...i,kind:r,body:o};switch(r){case"anthropic":return Yne(await mb(s));case"gemini":return Qne(await mb(s));default:return Gne(await mb(s))}}function Qne(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()}}var Sz,s0=E(()=>{Sz=require("obsidian");Um();sk()});function gb(r,e,t,n,i,o={}){return async function(a){if(X.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let l=Ui(a)+Ui(i),c=Date.now(),u=r0({provider:n.name,endpoint:n.endpoint,model:t.name,systemPrompt:i,prompt:a,modelOptions:o});I.logMessage(`[AI Request ${u}] Started ${n.name}/${t.name}`),Number.isFinite(t.maxTokens)&&t.maxTokens>0&&l>t.maxTokens&&I.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=ak(r),p=Eg(n),f=b=>_z({kind:p,apiKey:e,model:t,provider:n,systemPrompt:i,params:b,prompt:a,afterRequest:d}),m=JP(t,o),g=eh(m);g.length===0&&eh(o).length>0&&I.logMessage(`[AI Request ${u}] ${t.name} uses fixed sampling; not sending ${e0(eh(o))}.`);let v=await Iz(()=>f(m),()=>f(ok(m)),{sentKeys:g,model:t,provider:n,logPrefix:`AI Request ${u}`,advancedSettings:!0}),y=Date.now()-c;return pb(u,{status:"success",durationMs:y,usage:v.usage}),I.logMessage(`[AI Request ${u}] Success in ${y}ms`),v}catch(d){let p=d.message??String(d),f=Date.now()-c;pb(u,{status:"error",durationMs:f,errorMessage:p}),I.logMessage(`[AI Request ${u}] Failed in ${f}ms: ${p}`);let m=eb(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.":"",g=new Error(`Error while making request to ${n.name}: ${p}${m}`,{cause:d});throw Ze(g),g}}}async function a0(r,e,t,n,i,o){if(X.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let s=Eg(n),a={...i,modelParams:JP(t,i.modelParams??{})},l=eh(a.modelParams??{}),c=o0(s,t.name,a,hb(t)),u=i.messages.find(m=>m.role==="system"),d=[...i.messages].reverse().find(m=>m.role==="user"),p=Date.now(),f=r0({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=b=>mb({kind:s,apiKey:e,provider:n,model:t,body:b,afterRequest:o}),g=await Iz(()=>m(c),()=>m(o0(s,t.name,{...a,modelParams:ok(a.modelParams??{})},hb(t))),{sentKeys:l,model:t,provider:n,logPrefix:`AI Chat ${f}`}),v=Tz(s,g),y=Date.now()-p;return pb(f,{status:"success",durationMs:y,usage:v.usage}),I.logMessage(`[AI Chat ${f}] Success in ${y}ms`),{id:g.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 g=m.message??String(m),v=Date.now()-p;pb(f,{status:"error",durationMs:v,errorMessage:g});let y=new Error(`Error while making request to ${n.name}: ${g}`,{cause:m});throw Ze(y),y}}async function Iz(r,e,t){try{return await r()}catch(n){let i=n.message??String(n),{sentKeys:o,model:s,provider:a,logPrefix:l,advancedSettings:c}=t;if(!vz(i,o))throw n;let u=e0(o),d=o.length>1?"them":"it";return I.logMessage(`[${l}] ${a.name} rejected ${u}; retrying without sampling parameters.`),new Az.Notice(`${s.name} doesn't accept the ${u} setting${o.length>1?"s":""}, so QuickAdd retried without ${d}.`+(c?` You can remove ${d} from this command's advanced settings.`:"")),e()}}var Az,lk=E(()=>{Az=require("obsidian");sk();dt();n0();i0();xt();ro();kz();Ie();Wy();Um();s0();s0()});function Kd(r){if(r){let e=new Fz.Notice(Dz("starting",""),1e6);return{setMessage:(t,n)=>{e.setMessage(Dz(t,n))},hide:()=>e.hide()}}return{setMessage:()=>{},hide:()=>{}}}var Fz,Dz,ck=E(()=>{Fz=require("obsidian"),Dz=(r,e)=>`${r==="dead"?"AI request failed.":`Assistant is ${r}.`}${e?` ${e}`:""}`});function Zne(){return Array.from(new Set([l0,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>_v(l0,r))])).filter(Boolean)}function Mz(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 p=d+a.length;if(p<=0||p>=r.length)continue;let f=Math.abs(p-e);f0&&n=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function Jne(r){let e=new RegExp(od.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function eie(r){return Oo.test(r)||hc.test(r)||dC.test(r)||tl.test(r)}function tie(r){return Pz.some(e=>r.includes(e))}function rie(r){return Pz.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function $z(r){if(r>dk)throw new Error(`QuickAdd would split this chunked AI request into more than ${dk} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function nie(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Ui(s)<=n?null:Mz(s);if(!l){t.push(s),o+=1,$z(o);continue}i.push(l[1],l[0])}}function iie(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function sie(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(iie(e)>0||oie.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{let u=[];nie(l,t,u),u.forEach((d,p)=>{i.push({text:d,joiner:p===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=Ui(l.text)+Math.max(1,Ui(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 lie(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 c0(r,e,t){if(X.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=Kd(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 p=e.chunkSeparator||/\n/g,{chunks:f,separators:m}=sie(u,p),g=await t(c,{chunk:l0});if(!(Jne(c)||eie(c)&&tie(g)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,b=hU(y),x=rie(g),w=Ui(l)+Ui(x);if(w>=y)throw new Error(`The estimated prompt overhead (${w} 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:T,clamped:C}=lie(b-w,e.maxChunkTokens);C&&I.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${T} estimated tokens per chunk instead.`);let S=e.shouldMerge??!0,A=aie(f,m,T,S);$z(A.length);let D=gb(r,i,o,s,l,d),P=["prompting",`${A.length} prompts being sent.`];n.setMessage(P[0],P[1]);let U=new uk(5,1e3*30),K=!1,W=0,ee=Promise.resolve(),me=G=>{let ie=ee.then(()=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:G})});return ee=ie.then(()=>{},()=>{}),ie},O=async(G,ie=0)=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await me(G)}catch(ue){throw K=!0,ue}try{return[(await U.add(()=>{if(K)throw new Error("Chunked prompt stopped after an earlier failure.");if(W+=1,W>dk)throw new Error(`Chunked AI request exceeded the safety limit of ${dk} provider requests.`);return D(xe)})).content]}catch(ue){let be=Mz(G);if(ie>=Xne||!be||!YU(ue))throw K=!0,ue;n.setMessage("prompting","Provider rejected a prompt for context length. Retrying with smaller chunks.");let[Ke,Oe]=be,Ee=await O(Ke,ie+1),He=await O(Oe,ie+1);return[...Ee,...He]}},H=Promise.all(A.map(G=>O(G))),z=(await cb(H,n,P)).flat().join(e.resultJoiner);return window.setTimeout(()=>n.hide(),5e3),ub(a,z)}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var uk,Xne,dk,l0,Pz,oie,Oz=E(()=>{dt();lk();Um();ck();Wy();Ie();Xe();Ax();XP();uk=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(i instanceof Error?i:new Error(String(i)))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;let e=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i=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()}},Xne=12,dk=500,l0="quickadd_chunk_probe_123456789";Pz=Zne();oie=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});async function cie(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 Xt.Suggest(r,c,t);else throw new ye("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.")}$n(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);$n(a instanceof Rz.TFile,`${s} is not a file`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function Nz(r,e,t){if(X.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=Kd(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=Bo(r,u),[p,f]=await cie(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(f),g=["prompting",`Using prompt template "${p}".`];n.setMessage(g[0],g[1]);let y=gb(r,i,o,s,c,e.modelOptions)(m),x=(await cb(y,n,g)).content;return window.setTimeout(()=>n.hide(),5e3),ub(a,x)}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),ot(i)?new at("Input cancelled by user"):i}}async function Lz(r,e,t){if(X.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=Kd(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),p=["prompting","Using custom prompt."];n.setMessage(p[0],p[1]);let m=gb(r,i,o,s,l,u)(d),v=(await cb(m,n,p)).content;return window.setTimeout(()=>n.hide(),5e3),ub(a,v)}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var Rz,u0=E(()=>{XP();Rz=require("obsidian");ur();Yn();Zo();dt();ht();Jm();xt();lk();ck();n0();Oz()});function uie(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,p)=>p===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(` `),selectionStart:e+i.length,selectionEnd:t+c}}function die(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 Vz(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;die(r,uie(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var Bz=E(()=>{});var qz,cu,d0=E(()=>{qz=require("obsidian");nD();Bz();cu=class r extends xf{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}getPromptKind(){return"multi"}createInputField(e,t,n){let i=new qz.TextAreaComponent(e);return i.inputEl.classList.add("wideInputPromptInputEl"),i.inputEl.setAttribute("dir","auto"),this.disposeIndent=Vz(i.inputEl),this.configureInput(i,t,n)}shouldSubmit(e){return(e.ctrlKey||e.metaKey)&&e.key==="Enter"}disposeInput(){this.disposeIndent?.()}}});var vb,Uz=E(()=>{Ds();uo();vb=class r extends ar{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?"":Go(e,this.options.numeric):e}}});var p0,yb,Hz=E(()=>{Ds();uo();p0={min:0,max:100,step:1},yb=class r extends ar{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??p0,o=this.isOptionalPrompt&&!n,s=Ff(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=Go(e,this.options?.slider??p0);t!==""&&(this.sliderEl.value=t),this.onInputChanged(e)}transformInputOnSubmit(e){return e===""&&this.isOptionalPrompt?"":Ff(e,this.options?.slider??p0)}}});var Qd,f0=E(()=>{d0();Ds();Uz();Hz();_s();Qd=class{factory(e){return e==="multiline"?cu:e==="number"?vb:e==="slider"?yb:on().settings.inputPrompt==="multi-line"?cu:ar}}});function zz(r){return r.normalize("NFKD").toLowerCase()}var pie,Xd,m0=E(()=>{pie=0;Xd=class{constructor(e,t){this.options=t;this.instanceId=++pie;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=e.createDiv({cls:"qa-searchable-multi-select"});let n=this.rootEl.createDiv({cls:"search-input-container qa-searchable-multi-select__search-container"});this.searchInputEl=n.createEl("input",{cls:"qa-searchable-multi-select__search",type:"search",placeholder:t.searchPlaceholder??"Search options..."}),this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),this.summaryEl=this.rootEl.createDiv({cls:"qa-searchable-multi-select__summary"}),this.summaryEl.setAttribute("aria-live","polite"),this.listEl=this.rootEl.createDiv({cls:"qa-searchable-multi-select__list"}),this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),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:zz(`${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=zz(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=this.listEl.createDiv({cls:"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"}for(let n of t)this.renderRow(n);if(e.length>t.length){let n=this.listEl.createDiv({cls:"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.updateSummary(e.length)}renderRow(e){let{item:t,index:n}=e,i=this.listEl.createEl("label",{cls:"qa-searchable-multi-select__option"});i.createSpan({cls:"qa-searchable-multi-select__option-label",text:t.label});let o=i.createEl("input",{type:"checkbox"});o.name=`qa-multi-select-${this.instanceId}`,o.id=`qa-multi-select-${this.instanceId}-${n}`,o.checked=this.options.isSelected(t),i.htmlFor=o.id,i.classList.toggle("is-selected",o.checked),o.addEventListener("change",()=>{this.options.onToggle(t,o.checked),this.refreshSelection()}),o.addEventListener("keydown",s=>{this.handleOptionKeydown(s,o)}),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 uu,du,h0=E(()=>{uu=require("obsidian");rn();ur();m0();du=class r extends uu.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}selectValue(t){!this.items.includes(t)&&!this.customValues.includes(t)&&this.customValues.push(t),this.selected.add(t)}seedPreselection(t){if(t?.length)for(let n of t){let i=n?.trim();i&&this.selectValue(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 Xd(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 uu.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 uu.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:kn(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 uu.Notice(`"${t}" is already added.`),!1):(this.selectValue(t),this.draft="",this.render(),this.focusCustomInput(),!0):(new uu.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.selectValue(t),this.draft=""}this.didSubmit=!0,this.close()}collectResult(){return[...this.items,...this.customValues].filter(t=>this.selected.has(t))}onClose(){super.onClose(),this.didSubmit?this.resolvePromise(this.skipped?[]:this.collectResult()):this.rejectPromise(Rr())}}});var y0,pu,fie,mie,hie,jz,g0,bb,v0,Wz,pk,b0=E(()=>{y0=require("obsidian"),pu=r=>r.toString().padStart(2,"0"),fie=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},mie=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))},hie=(r,e)=>new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(r,e,1)),jz=(r,e,t)=>`${r}-${pu(e+1)}-${pu(t)}`,g0=r=>jz(r.getFullYear(),r.getMonth(),r.getDate()),bb=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},v0=(r,e,t,n)=>{let i=jz(r,e,t);return n?`${i}T${pu(n.hour)}:${pu(n.minute)}:00`:i},Wz=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}},pk=r=>{let e=fie(r.weekStartsOn),t=mie(e),n=bb(r.initialIso)??new Date,i=n.getFullYear(),o=n.getMonth(),s=r.initialIso,a=r.withTime===!0,l=a?Wz(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 clickable-icon"});(0,y0.setIcon)(d,"chevron-left"),d.type="button",d.setAttr("aria-label","Previous month");let p=u.createDiv({cls:"qa-date-picker__label"}),f=u.createEl("button",{cls:"qa-date-picker__nav clickable-icon"});(0,y0.setIcon)(f,"chevron-right"),f.type="button",f.setAttr("aria-label","Next month");let m=c.createDiv({cls:"qa-date-picker__weekdays"});t.forEach(A=>{let D=m.createDiv({cls:"qa-date-picker__weekday"});D.textContent=A});let g=c.createDiv({cls:"qa-date-picker__grid"}),v=c.createDiv({cls:"qa-date-picker__actions"}),y=v.createEl("button",{cls:"qa-date-picker__action",text:"Today"});y.type="button";let b=v.createEl("button",{cls:"qa-date-picker__action",text:"Clear"});b.type="button";let x;if(a){let A=c.createDiv({cls:"qa-date-picker__time"});A.createEl("label",{cls:"qa-date-picker__time-label",text:"Time"}),x=A.createEl("input",{cls:"qa-date-picker__time-input"}),x.type="time",l&&(x.value=`${pu(l.hour)}:${pu(l.minute)}`)}let w=A=>{o+=A,o>11?(o=0,i+=1):o<0&&(o=11,i-=1),S()},T=(A,D)=>{s=A,r.onSelect(A,D),S()},C=A=>{s=void 0,r.onSelect(null,A),S()};d.addEventListener("click",()=>w(-1)),f.addEventListener("click",()=>w(1)),y.addEventListener("click",()=>{let A=new Date,D=v0(A.getFullYear(),A.getMonth(),A.getDate(),l);i=A.getFullYear(),o=A.getMonth(),T(D,"action")}),b.addEventListener("click",()=>C("action")),x&&x.addEventListener("change",()=>{if(x.value.trim()==="")l={hour:0,minute:0};else{let[A,D]=x.value.split(":").map(P=>Number.parseInt(P,10));if(Number.isNaN(A)||Number.isNaN(D))return;l={hour:A,minute:D}}if(s){let A=bb(s);A&&T(v0(A.getFullYear(),A.getMonth(),A.getDate(),l),"picker")}});let S=()=>{p.textContent=hie(i,o),g.empty();let D=(new Date(i,o,1).getDay()-e+7)%7,P=new Date(i,o,1-D),U=g0(new Date),K=s?bb(s):null,W=K?g0(K):void 0,ee=new Intl.DateTimeFormat(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"});for(let me=0;me<42;me+=1){let O=new Date(P);O.setDate(P.getDate()+me);let H=g0(O),ce=O.getMonth()!==o,te=H===U,z=W&&H===W,G=g.createEl("button",{cls:"qa-date-picker__day",text:String(O.getDate())});G.type="button",G.setAttr("aria-label",ee.format(O)),ce&&G.addClass("is-outside"),te&&G.addClass("is-today"),z&&(G.addClass("is-selected"),G.setAttr("aria-pressed","true")),G.addEventListener("click",()=>{let ie=v0(O.getFullYear(),O.getMonth(),O.getDate(),l);T(ie,"picker")})}};return S(),{setSelectedIso:(A,{updateView:D}={})=>{if(s=A,A&&D!==!1){let P=bb(A);P&&(i=P.getFullYear(),o=P.getMonth())}if(a&&A){let P=Wz(A);P&&(l=P,x&&(x.value=`${pu(P.hour)}:${pu(P.minute)}`))}S()},setViewFromIso:A=>{let D=bb(A);D&&(i=D.getFullYear(),o=D.getMonth(),S())},destroy:()=>{c.remove()}}}});function fu(r,e,t=Qo,n){if(!r||!r.trim())return{isValid:!1,error:"Empty input"};try{let i=n??X.getState().dateAliases,o=kg(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 Us(r,e){if(!window.moment)return null;try{let t=window.moment(r);if(t.isValid())return t.format(e)}catch{}return null}var Zd=E(()=>{Ld();dt();td()});var rh,th,Rl,fk=E(()=>{rh=require("obsidian");Ds();b0();Zd();dt();td();th=class th extends ar{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,rh.debounce)(this.updatePreview.bind(this),250,!0),this.updatePreview()}supportsPeek(){return!1}static Prompt(t,n,i,o,s,a,l){return new th(t,n,i,o,s,a,l).waitForClose}createInputField(t,n,i){t.addClass("qa-date-input");let o=new rh.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=pk({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.createDiv({text:"Preview:",cls:"vdate-preview-label"}),this.previewEl=n.createDiv({cls:"vdate-preview-text"}),this.previewEl.textContent=th.PREVIEW_PLACEHOLDER;let i=Sg(X.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.createDiv({cls:"vdate-alias-list"});a.textContent=aC(X.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":th.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=Us(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=fu(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=fu(this.defaultValue,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`}if(n){let i=fu(n,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`;new rh.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()}};th.PREVIEW_PLACEHOLDER="Preview will appear here";Rl=th});async function Gz(r,e,t){let n=r.executor?.promptProvider;if(n)return t?.type==="VDATE"?await n.datePrompt(e??t.label??"Enter date",{defaultValue:t.defaultValue,dateFormat:t.dateFormat??"YYYY-MM-DD",withTime:t.withTime}):t?.inputTypeOverride==="checkbox"?String(await n.suggester(["true","false"],["true","false"],t.description??e??t.label??"Choose value",!1)):await n.inputPrompt(e??t?.label??"Enter value",t?.placeholder,t?.defaultValue);r.assertInteractivePrompt(e?`{{VALUE:${e}}}`:"a template variable");try{let i=e??t?.label??"Enter value",o=Ex(r.scope),s=kf(r.runContext,i,{showDestination:o}),a=kf(r.runContext,i,{elide:!1,showDestination:o});return t?.type==="VDATE"?await Rl.Prompt(r.app,e??t.label??"Enter date",t.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')",t.defaultValue,t.dateFormat??"YYYY-MM-DD",{optional:t.optional,contextLine:s,contextLineFull:a,draftScopeId:r.runContext?.draftScopeId},t.withTime):t?.inputTypeOverride==="checkbox"?await Xt.Suggest(r.app,["true","false"],["true","false"],t.description??e??t.label??"Choose value",void 0,t.optional?{skippable:!0}:void 0):await new Qd().factory(t?.inputTypeOverride).Prompt(r.app,i,t?.placeholder??(t?.defaultValue?t.defaultValue:void 0),t?.defaultValue,t?.description,r.buildInputPromptOptions(t,s,a))}catch(i){throw ot(i)?new at("Input cancelled by user"):i}}async function Yz(r,e,t=!1,n){let i=r.executor?.promptProvider;if(i)return String(await i.suggester(n?.displayValues??e,e,n?.placeholder,t));r.assertInteractivePrompt(n?.variableKey?`{{VALUE:${n.variableKey}}}`:"a value choice");try{let o=n?.displayValues??e;return t?await Mr.Suggest(r.app,o,e,{...n?.placeholder?{placeholder:n.placeholder}:{},...n?.optional?{skippable:!0}:{}}):await Xt.Suggest(r.app,o,e,n?.placeholder,void 0,n?.optional?{skippable:!0}:void 0)}catch(o){throw ot(o)?new at("Input cancelled by user"):o}}async function Kz(r,e,t=!1,n){let i=n?.displayValues??e,o=r.executor?.promptProvider;if(o)return await o.suggesterMulti(i,e,{placeholder:n?.placeholder,allowCustomInput:t});r.assertInteractivePrompt(n?.variableKey?`{{VALUE:${n.variableKey}}}`:"a multi-select value");try{return await du.Suggest(r.app,i,e,{...n?.placeholder?{placeholder:n.placeholder}:{},allowCustomValue:t,...n?.optional?{skippable:!0}:{}})}catch(s){throw ot(s)?new at("Input cancelled by user"):s}}var Qz=E(()=>{Sf();f0();Ol();Zo();h0();fk();ur();xt()});var A3=R4(ka=>{"use strict";Object.defineProperty(ka,"__esModule",{value:!0});require("obsidian");var Ll=class extends Error{},A0=class extends Ll{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},I0=class extends Ll{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},D0=class extends Ll{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},tp=class extends Ll{},xk=class extends Ll{constructor(e){super(`Invalid unit ${e}`)}},zi=class extends Ll{},Ea=class extends Ll{constructor(){super("Zone is an abstract class")}},_e="numeric",js="short",bo="long",Ek={year:_e,month:_e,day:_e},AW={year:_e,month:js,day:_e},gie={year:_e,month:js,day:_e,weekday:js},IW={year:_e,month:bo,day:_e},DW={year:_e,month:bo,day:_e,weekday:bo},FW={hour:_e,minute:_e},PW={hour:_e,minute:_e,second:_e},MW={hour:_e,minute:_e,second:_e,timeZoneName:js},$W={hour:_e,minute:_e,second:_e,timeZoneName:bo},OW={hour:_e,minute:_e,hourCycle:"h23"},RW={hour:_e,minute:_e,second:_e,hourCycle:"h23"},NW={hour:_e,minute:_e,second:_e,hourCycle:"h23",timeZoneName:js},LW={hour:_e,minute:_e,second:_e,hourCycle:"h23",timeZoneName:bo},VW={year:_e,month:_e,day:_e,hour:_e,minute:_e},BW={year:_e,month:_e,day:_e,hour:_e,minute:_e,second:_e},qW={year:_e,month:js,day:_e,hour:_e,minute:_e},UW={year:_e,month:js,day:_e,hour:_e,minute:_e,second:_e},vie={year:_e,month:js,day:_e,weekday:js,hour:_e,minute:_e},HW={year:_e,month:bo,day:_e,hour:_e,minute:_e,timeZoneName:js},zW={year:_e,month:bo,day:_e,hour:_e,minute:_e,second:_e,timeZoneName:js},WW={year:_e,month:bo,day:_e,weekday:bo,hour:_e,minute:_e,timeZoneName:bo},jW={year:_e,month:bo,day:_e,weekday:bo,hour:_e,minute:_e,second:_e,timeZoneName:bo},ip=class{get type(){throw new Ea}get name(){throw new Ea}get ianaName(){return this.name}get isUniversal(){throw new Ea}offsetName(e,t){throw new Ea}formatOffset(e,t){throw new Ea}offset(e){throw new Ea}equals(e){throw new Ea}get isValid(){throw new Ea}},w0=null,Tk=class r extends ip{static get instance(){return w0===null&&(w0=new r),w0}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return YW(e,t,n)}formatOffset(e,t){return kb(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},wk={};function yie(r){return wk[r]||(wk[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"})),wk[r]}var bie={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function wie(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 Cie(r,e){let t=r.formatToParts(e),n=[];for(let i=0;i=0?m:1e3+m,(p-f)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},Xz={};function xie(r,e={}){let t=JSON.stringify([r,e]),n=Xz[t];return n||(n=new Intl.ListFormat(r,e),Xz[t]=n),n}var F0={};function P0(r,e={}){let t=JSON.stringify([r,e]),n=F0[t];return n||(n=new Intl.DateTimeFormat(r,e),F0[t]=n),n}var M0={};function Eie(r,e={}){let t=JSON.stringify([r,e]),n=M0[t];return n||(n=new Intl.NumberFormat(r,e),M0[t]=n),n}var $0={};function Tie(r,e={}){let{base:t,...n}=e,i=JSON.stringify([r,n]),o=$0[i];return o||(o=new Intl.RelativeTimeFormat(r,e),$0[i]=o),o}var Eb=null;function kie(){return Eb||(Eb=new Intl.DateTimeFormat().resolvedOptions().locale,Eb)}function Sie(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=P0(r).resolvedOptions(),i=r}catch{let l=r.substring(0,t);n=P0(l).resolvedOptions(),i=l}let{numberingSystem:o,calendar:s}=n;return[i,o,s]}}function _ie(r,e,t){return(t||e)&&(r.includes("-u-")||(r+="-u"),t&&(r+=`-ca-${t}`),e&&(r+=`-nu-${e}`)),r}function Aie(r){let e=[];for(let t=1;t<=12;t++){let n=pt.utc(2009,t,1);e.push(r(n))}return e}function Iie(r){let e=[];for(let t=1;t<=7;t++){let n=pt.utc(2016,11,13+t);e.push(r(n))}return e}function hk(r,e,t,n){let i=r.listingMode();return i==="error"?null:i==="en"?t(e):n(e)}function Die(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 O0=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=Eie(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):K0(e,3);return Ur(t,this.padTo)}}},R0=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&&vu.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=P0(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()}},N0=class{constructor(e,t,n){this.opts={style:"long",...n},!t&&GW()&&(this.rtf=Tie(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):jie(t,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},_r=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||Sr.defaultLocale,s=o||(i?"en-US":kie()),a=t||Sr.defaultNumberingSystem,l=n||Sr.defaultOutputCalendar;return new r(s,a,l,o)}static resetCache(){Eb=null,F0={},M0={},$0={}}static fromObject({locale:e,numberingSystem:t,outputCalendar:n}={}){return r.create(e,t,n)}constructor(e,t,n,i){let[o,s,a]=Sie(e);this.locale=o,this.numberingSystem=t||s||null,this.outputCalendar=n||a||null,this.intl=_ie(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=Die(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 hk(this,e,XW,()=>{let n=t?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";return this.monthsCache[i][e]||(this.monthsCache[i][e]=Aie(o=>this.extract(o,n,"month"))),this.monthsCache[i][e]})}weekdays(e,t=!1){return hk(this,e,e3,()=>{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]=Iie(o=>this.extract(o,n,"weekday"))),this.weekdaysCache[i][e]})}meridiems(){return hk(this,void 0,()=>t3,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[pt.utc(2016,11,13,9),pt.utc(2016,11,13,19)].map(t=>this.extract(t,e,"dayperiod"))}return this.meridiemCache})}eras(e){return hk(this,e,r3,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[pt.utc(-40,1,1),pt.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 O0(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new R0(e,this.intl,t)}relFormatter(e={}){return new N0(this.intl,this.isEnglish(),e)}listFormatter(e={}){return xie(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}},C0=null,rs=class r extends ip{static get utcInstance(){return C0===null&&(C0=new r(0)),C0}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($k(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${kb(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${kb(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return kb(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}},L0=class extends ip{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 gu(r,e){if(wt(r)||r===null)return e;if(r instanceof ip)return r;if(Fie(r)){let t=r.toLowerCase();return t==="default"?e:t==="local"||t==="system"?Tk.instance:t==="utc"||t==="gmt"?rs.utcInstance:rs.parseSpecifier(t)||vu.create(r)}else return np(r)?rs.instance(r):typeof r=="object"&&"offset"in r&&typeof r.offset=="function"?r:new L0(r)}var Zz=()=>Date.now(),Jz="system",eW=null,tW=null,rW=null,nW=60,iW,Sr=class{static get now(){return Zz}static set now(e){Zz=e}static set defaultZone(e){Jz=e}static get defaultZone(){return gu(Jz,Tk.instance)}static get defaultLocale(){return eW}static set defaultLocale(e){eW=e}static get defaultNumberingSystem(){return tW}static set defaultNumberingSystem(e){tW=e}static get defaultOutputCalendar(){return rW}static set defaultOutputCalendar(e){rW=e}static get twoDigitCutoffYear(){return nW}static set twoDigitCutoffYear(e){nW=e%100}static get throwOnInvalid(){return iW}static set throwOnInvalid(e){iW=e}static resetCaches(){_r.resetCache(),vu.resetCache()}};function wt(r){return typeof r>"u"}function np(r){return typeof r=="number"}function Pk(r){return typeof r=="number"&&r%1===0}function Fie(r){return typeof r=="string"}function Pie(r){return Object.prototype.toString.call(r)==="[object Date]"}function GW(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Mie(r){return Array.isArray(r)?r:[r]}function oW(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 $ie(r,e){return e.reduce((t,n)=>(t[n]=r[n],t),{})}function lh(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function Nl(r,e,t){return Pk(r)&&r>=e&&r<=t}function Oie(r,e){return r-e*Math.floor(r/e)}function Ur(r,e=2){let t=r<0,n;return t?n="-"+(""+-r).padStart(e,"0"):n=(""+r).padStart(e,"0"),n}function hu(r){if(!(wt(r)||r===null||r===""))return parseInt(r,10)}function Jd(r){if(!(wt(r)||r===null||r===""))return parseFloat(r)}function Y0(r){if(!(wt(r)||r===null||r==="")){let e=parseFloat("0."+r)*1e3;return Math.floor(e)}}function K0(r,e,t=!1){let n=10**e;return(t?Math.trunc:Math.round)(r*n)/n}function Ab(r){return r%4===0&&(r%100!==0||r%400===0)}function Tb(r){return Ab(r)?366:365}function kk(r,e){let t=Oie(e-1,12)+1,n=r+(e-t)/12;return t===2?Ab(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][t-1]}function Mk(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 Sk(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 V0(r){return r>99?r:r>Sr.twoDigitCutoffYear?1900+r:2e3+r}function YW(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 $k(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 KW(r){let e=Number(r);if(typeof r=="boolean"||r===""||Number.isNaN(e))throw new zi(`Invalid unit value ${r}`);return e}function _k(r,e){let t={};for(let n in r)if(lh(r,n)){let i=r[n];if(i==null)continue;t[e(n)]=KW(i)}return t}function kb(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}${Ur(t,2)}:${Ur(n,2)}`;case"narrow":return`${i}${t}${n>0?`:${n}`:""}`;case"techie":return`${i}${Ur(t,2)}${Ur(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function Ok(r){return $ie(r,["hour","minute","second","millisecond"])}var Rie=["January","February","March","April","May","June","July","August","September","October","November","December"],QW=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Nie=["J","F","M","A","M","J","J","A","S","O","N","D"];function XW(r){switch(r){case"narrow":return[...Nie];case"short":return[...QW];case"long":return[...Rie];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 ZW=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],JW=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Lie=["M","T","W","T","F","S","S"];function e3(r){switch(r){case"narrow":return[...Lie];case"short":return[...JW];case"long":return[...ZW];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var t3=["AM","PM"],Vie=["Before Christ","Anno Domini"],Bie=["BC","AD"],qie=["B","A"];function r3(r){switch(r){case"narrow":return[...qie];case"short":return[...Bie];case"long":return[...Vie];default:return null}}function Uie(r){return t3[r.hour<12?0:1]}function Hie(r,e){return e3(e)[r.weekday-1]}function zie(r,e){return XW(e)[r.month-1]}function Wie(r,e){return r3(e)[r.year<0?0:1]}function jie(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 sW(r,e){let t="";for(let n of r)n.literal?t+=n.val:t+=e(n.val);return t}var Gie={D:Ek,DD:AW,DDD:IW,DDDD:DW,t:FW,tt:PW,ttt:MW,tttt:$W,T:OW,TT:RW,TTT:NW,TTTT:LW,f:VW,ff:qW,fff:HW,ffff:WW,F:BW,FF:UW,FFF:zW,FFFF:jW},vo=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;s0&&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 Gie[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 Ur(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=(f,m)=>this.loc.extract(e,f,m),s=f=>e.isOffsetFixed&&e.offset===0&&f.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,f.format):"",a=()=>n?Uie(e):o({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(f,m)=>n?zie(e,f):o(m?{month:f}:{month:f,day:"numeric"},"month"),c=(f,m)=>n?Hie(e,f):o(m?{weekday:f}:{weekday:f,month:"long",day:"numeric"},"weekday"),u=f=>{let m=r.macroTokenToFormatOpts(f);return m?this.formatWithSystemDefault(e,m):f},d=f=>n?Wie(e,f):o({era:f},"era"),p=f=>{switch(f){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(f)}};return sW(r.parseFormat(t),p)}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 sW(o,i(a))}},yo=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},n3=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function ch(...r){let e=r.reduce((t,n)=>t+n.source,"");return RegExp(`^${e}$`)}function uh(...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 dh(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 i3(...r){return(e,t)=>{let n={},i;for(i=0;if!==void 0&&(m||f&&u)?-f:f;return[{years:p(Jd(t)),months:p(Jd(n)),weeks:p(Jd(i)),days:p(Jd(o)),hours:p(Jd(s)),minutes:p(Jd(a)),seconds:p(Jd(l),l==="-0"),milliseconds:p(Y0(c),d)}]}var soe={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function Z0(r,e,t,n,i,o,s){let a={year:e.length===2?V0(hu(e)):hu(e),month:QW.indexOf(t)+1,day:hu(n),hour:hu(i),minute:hu(o)};return s&&(a.second=hu(s)),r&&(a.weekday=r.length>3?ZW.indexOf(r)+1:JW.indexOf(r)+1),a}var aoe=/^(?:(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 loe(r){let[,e,t,n,i,o,s,a,l,c,u,d]=r,p=Z0(e,i,n,t,o,s,a),f;return l?f=soe[l]:c?f=0:f=$k(u,d),[p,new rs(f)]}function coe(r){return r.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var uoe=/^(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$/,doe=/^(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$/,poe=/^(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 aW(r){let[,e,t,n,i,o,s,a]=r;return[Z0(e,i,n,t,o,s,a),rs.utcInstance]}function foe(r){let[,e,t,n,i,o,s,a]=r;return[Z0(e,a,t,n,i,o,s),rs.utcInstance]}var moe=ch(Kie,X0),hoe=ch(Qie,X0),goe=ch(Xie,X0),voe=ch(s3),l3=uh(roe,ph,Ib,Db),yoe=uh(Zie,ph,Ib,Db),boe=uh(Jie,ph,Ib,Db),woe=uh(ph,Ib,Db);function Coe(r){return dh(r,[moe,l3],[hoe,yoe],[goe,boe],[voe,woe])}function xoe(r){return dh(coe(r),[aoe,loe])}function Eoe(r){return dh(r,[uoe,aW],[doe,aW],[poe,foe])}function Toe(r){return dh(r,[ioe,ooe])}var koe=uh(ph);function Soe(r){return dh(r,[noe,koe])}var _oe=ch(eoe,toe),Aoe=ch(a3),Ioe=uh(ph,Ib,Db);function Doe(r){return dh(r,[_oe,l3],[Aoe,Ioe])}var lW="Invalid Duration",c3={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}},Foe={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},...c3},es=146097/400,nh=146097/4800,Poe={years:{quarters:4,months:12,weeks:es/7,days:es,hours:es*24,minutes:es*24*60,seconds:es*24*60*60,milliseconds:es*24*60*60*1e3},quarters:{months:3,weeks:es/28,days:es/4,hours:es*24/4,minutes:es*24*60/4,seconds:es*24*60*60/4,milliseconds:es*24*60*60*1e3/4},months:{weeks:nh/7,days:nh,hours:nh*24,minutes:nh*24*60,seconds:nh*24*60*60,milliseconds:nh*24*60*60*1e3},...c3},rp=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Moe=rp.slice(0).reverse();function mu(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 je(n)}function u3(r,e){let t=e.milliseconds??0;for(let n of Moe.slice(1))e[n]&&(t+=e[n]*r[n].milliseconds);return t}function cW(r,e){let t=u3(r,e)<0?-1:1;rp.reduceRight((n,i)=>{if(wt(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),rp.reduce((n,i)=>{if(wt(e[i]))return n;if(n){let o=e[n]%1;e[n]-=o,e[i]+=o*r[n][i]}return i},null)}function $oe(r){let e={};for(let[t,n]of Object.entries(r))n!==0&&(e[t]=n);return e}var je=class r{constructor(e){let t=e.conversionAccuracy==="longterm"||!1,n=t?Poe:Foe;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||_r.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 zi(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new r({values:_k(e,r.normalizeUnit),loc:_r.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(np(e))return r.fromMillis(e);if(r.isDuration(e))return e;if(typeof e=="object")return r.fromObject(e);throw new zi(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){let[n]=Toe(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]=Soe(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 zi("need to specify a reason the Duration is invalid");let n=e instanceof yo?e:new yo(e,t);if(Sr.throwOnInvalid)throw new D0(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 xk(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?vo.create(this.loc,n).formatDurationFromString(this,e):lW}toHuman(e={}){if(!this.isValid)return lW;let t=rp.map(n=>{let i=this.values[n];return wt(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+=K0(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},pt.fromMillis(t,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}toMillis(){return this.isValid?u3(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 rp)(lh(t.values,i)||lh(this.values,i))&&(n[i]=t.get(i)+this.get(i));return mu(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]=KW(e(this.values[n],n));return mu(this,{values:t},!0)}get(e){return this[r.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let t={...this.values,..._k(e,r.normalizeUnit)};return mu(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 mu(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return cW(this.matrix,e),mu(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=$oe(this.normalize().shiftToAll().toObject());return mu(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 rp)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;np(i[s])&&(a+=i[s]);let l=Math.trunc(a);t[s]=l,n[s]=(a*1e3-l*1e3)/1e3}else np(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 cW(this.matrix,t),mu(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 mu(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 rp)if(!t(this.values[n],e.values[n]))return!1;return!0}},ih="Invalid Interval";function Ooe(r,e){return!r||!r.isValid?ah.invalid("missing or invalid start"):!e||!e.isValid?ah.invalid("missing or invalid end"):ee:!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(Cb).filter(s=>this.contains(s)).sort(),n=[],{s:i}=this,o=0;for(;i+this.e?this.e:s;n.push(r.fromDateTimes(i,a)),i=a,o+=1}return n}splitBy(e){let t=je.fromDurationLike(e);if(!this.isValid||!t.isValid||t.as("milliseconds")===0)return[];let{s:n}=this,i=1,o,s=[];for(;nl*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:!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=n?null:r.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;let t=this.se.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()})`:ih}toLocaleString(e=Ek,t={}){return this.isValid?vo.create(this.s.loc.clone(t),e).formatInterval(this):ih}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:ih}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:ih}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:ih}toFormat(e,{separator:t=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:ih}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):je.invalid(this.invalidReason)}mapEndpoints(e){return r.fromDateTimes(e(this.s),e(this.e))}},oh=class{static hasDST(e=Sr.defaultZone){let t=pt.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return vu.isValidZone(e)}static normalizeZone(e){return gu(e,Sr.defaultZone)}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||_r.create(t,n,o)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||_r.create(t,n,o)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||_r.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||_r.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return _r.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return _r.create(t,null,"gregory").eras(e)}static features(){return{relative:GW()}}};function uW(r,e){let t=i=>i.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=t(e)-t(r);return Math.floor(je.fromMillis(n).as("days"))}function Roe(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=uW(l,c);return(u-u%7)/7}],["days",uW]],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 Noe(r,e,t,n){let[i,o,s,a]=Roe(r,e,t),l=e-i,c=t.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(s0?je.fromMillis(l,n).shiftTo(...c).plus(u):u}var J0={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"},dW={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]},Loe=J0.hanidec.replace(/[\[|\]]/g,"").split("");function Voe(r){let e=parseInt(r,10);if(isNaN(e)){e="";for(let t=0;t=o&&n<=s&&(e+=n-o)}}return parseInt(e,10)}else return e}function Hs({numberingSystem:r},e=""){return new RegExp(`${J0[r||"latn"]}${e}`)}var Boe="missing Intl.DateTimeFormat.formatToParts support";function Mt(r,e=t=>t){return{regex:r,deser:([t])=>e(Voe(t))}}var qoe="\xA0",d3=`[ ${qoe}]`,p3=new RegExp(d3,"g");function Uoe(r){return r.replace(/\./g,"\\.?").replace(p3,d3)}function pW(r){return r.replace(/\./g,"").replace(p3," ").toLowerCase()}function zs(r,e){return r===null?null:{regex:RegExp(r.map(Uoe).join("|")),deser:([t])=>r.findIndex(n=>pW(t)===pW(n))+e}}function fW(r,e){return{regex:r,deser:([,t,n])=>$k(t,n),groups:e}}function gk(r){return{regex:r,deser:([e])=>e}}function Hoe(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function zoe(r,e){let t=Hs(e),n=Hs(e,"{2}"),i=Hs(e,"{3}"),o=Hs(e,"{4}"),s=Hs(e,"{6}"),a=Hs(e,"{1,2}"),l=Hs(e,"{1,3}"),c=Hs(e,"{1,6}"),u=Hs(e,"{1,9}"),d=Hs(e,"{2,4}"),p=Hs(e,"{4,6}"),f=v=>({regex:RegExp(Hoe(v.val)),deser:([y])=>y,literal:!0}),g=(v=>{if(r.literal)return f(v);switch(v.val){case"G":return zs(e.eras("short"),0);case"GG":return zs(e.eras("long"),0);case"y":return Mt(c);case"yy":return Mt(d,V0);case"yyyy":return Mt(o);case"yyyyy":return Mt(p);case"yyyyyy":return Mt(s);case"M":return Mt(a);case"MM":return Mt(n);case"MMM":return zs(e.months("short",!0),1);case"MMMM":return zs(e.months("long",!0),1);case"L":return Mt(a);case"LL":return Mt(n);case"LLL":return zs(e.months("short",!1),1);case"LLLL":return zs(e.months("long",!1),1);case"d":return Mt(a);case"dd":return Mt(n);case"o":return Mt(l);case"ooo":return Mt(i);case"HH":return Mt(n);case"H":return Mt(a);case"hh":return Mt(n);case"h":return Mt(a);case"mm":return Mt(n);case"m":return Mt(a);case"q":return Mt(a);case"qq":return Mt(n);case"s":return Mt(a);case"ss":return Mt(n);case"S":return Mt(l);case"SSS":return Mt(i);case"u":return gk(u);case"uu":return gk(a);case"uuu":return Mt(t);case"a":return zs(e.meridiems(),0);case"kkkk":return Mt(o);case"kk":return Mt(d,V0);case"W":return Mt(a);case"WW":return Mt(n);case"E":case"c":return Mt(t);case"EEE":return zs(e.weekdays("short",!1),1);case"EEEE":return zs(e.weekdays("long",!1),1);case"ccc":return zs(e.weekdays("short",!0),1);case"cccc":return zs(e.weekdays("long",!0),1);case"Z":case"ZZ":return fW(new RegExp(`([+-]${a.source})(?::(${n.source}))?`),2);case"ZZZ":return fW(new RegExp(`([+-]${a.source})(${n.source})?`),2);case"z":return gk(/[a-z_+-/]{1,256}?/i);case" ":return gk(/[^\S\n\r]/);default:return f(v)}})(r)||{invalidReason:Boe};return g.token=r,g}var Woe={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 joe(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=Woe[s];if(typeof a=="object"&&(a=a[o]),a)return{literal:!1,val:a}}function Goe(r){return[`^${r.map(t=>t.regex).reduce((t,n)=>`${t}(${n.source})`,"")}$`,r]}function Yoe(r,e,t){let n=r.match(e);if(n){let i={},o=1;for(let s in t)if(lh(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 Koe(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 wt(r.z)||(t=vu.create(r.z)),wt(r.Z)||(t||(t=new rs(r.Z)),n=r.Z),wt(r.q)||(r.M=(r.q-1)*3+1),wt(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),wt(r.u)||(r.S=Y0(r.u)),[Object.keys(r).reduce((o,s)=>{let a=e(s);return a&&(o[a]=r[s]),o},{}),t,n]}var x0=null;function Qoe(){return x0||(x0=pt.fromMillis(1555555555555)),x0}function Xoe(r,e){if(r.literal)return r;let t=vo.macroTokenToFormatOpts(r.val),n=h3(t,e);return n==null||n.includes(void 0)?r:n}function f3(r,e){return Array.prototype.concat(...r.map(t=>Xoe(t,e)))}function m3(r,e,t){let n=f3(vo.parseFormat(t),r),i=n.map(s=>zoe(s,r)),o=i.find(s=>s.invalidReason);if(o)return{input:e,tokens:n,invalidReason:o.invalidReason};{let[s,a]=Goe(i),l=RegExp(s,"i"),[c,u]=Yoe(e,l,a),[d,p,f]=u?Koe(u):[null,null,void 0];if(lh(u,"a")&&lh(u,"H"))throw new tp("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:n,regex:l,rawMatches:c,matches:u,result:d,zone:p,specificOffset:f}}}function Zoe(r,e,t){let{result:n,zone:i,specificOffset:o,invalidReason:s}=m3(r,e,t);return[n,i,o,s]}function h3(r,e){if(!r)return null;let n=vo.create(e,r).dtFormatter(Qoe()),i=n.formatToParts(),o=n.resolvedOptions();return i.map(s=>joe(s,r,o))}var g3=[0,31,59,90,120,151,181,212,243,273,304,334],v3=[0,31,60,91,121,152,182,213,244,274,305,335];function ts(r,e){return new yo("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${r}, which is invalid`)}function y3(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 b3(r,e,t){return t+(Ab(r)?v3:g3)[e-1]}function w3(r,e){let t=Ab(r)?v3:g3,n=t.findIndex(o=>oSk(e)?(a=e+1,s=1):a=e,{weekYear:a,weekNumber:s,weekday:o,...Ok(r)}}function mW(r){let{weekYear:e,weekNumber:t,weekday:n}=r,i=y3(e,1,4),o=Tb(e),s=t*7+n-i-3,a;s<1?(a=e-1,s+=Tb(a)):s>o?(a=e+1,s-=Tb(e)):a=e;let{month:l,day:c}=w3(a,s);return{year:a,month:l,day:c,...Ok(r)}}function E0(r){let{year:e,month:t,day:n}=r,i=b3(e,t,n);return{year:e,ordinal:i,...Ok(r)}}function hW(r){let{year:e,ordinal:t}=r,{month:n,day:i}=w3(e,t);return{year:e,month:n,day:i,...Ok(r)}}function Joe(r){let e=Pk(r.weekYear),t=Nl(r.weekNumber,1,Sk(r.weekYear)),n=Nl(r.weekday,1,7);return e?t?n?!1:ts("weekday",r.weekday):ts("week",r.week):ts("weekYear",r.weekYear)}function ese(r){let e=Pk(r.year),t=Nl(r.ordinal,1,Tb(r.year));return e?t?!1:ts("ordinal",r.ordinal):ts("year",r.year)}function C3(r){let e=Pk(r.year),t=Nl(r.month,1,12),n=Nl(r.day,1,kk(r.year,r.month));return e?t?n?!1:ts("day",r.day):ts("month",r.month):ts("year",r.year)}function x3(r){let{hour:e,minute:t,second:n,millisecond:i}=r,o=Nl(e,0,23)||e===24&&t===0&&n===0&&i===0,s=Nl(t,0,59),a=Nl(n,0,59),l=Nl(i,0,999);return o?s?a?l?!1:ts("millisecond",i):ts("second",n):ts("minute",t):ts("hour",e)}var T0="Invalid DateTime",gW=864e13;function vk(r){return new yo("unsupported zone",`the zone "${r.name}" is not supported`)}function k0(r){return r.weekData===null&&(r.weekData=B0(r.c)),r.weekData}function ep(r,e){let t={ts:r.ts,zone:r.zone,c:r.c,o:r.o,loc:r.loc,invalid:r.invalid};return new pt({...t,...e,old:t})}function E3(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 yk(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 Ck(r,e,t){return E3(Mk(r),e,t)}function vW(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,kk(n,i))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},s=je.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=Mk(o),[l,c]=E3(a,t,r.zone);return s!==0&&(l+=s,c=r.zone.offset(l)),{ts:l,o:c}}function wb(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=pt.fromObject(r,{...t,zone:l,specificOffset:o});return s?c:c.setZone(a)}else return pt.invalid(new yo("unparsable",`the input "${i}" can't be parsed as ${n}`))}function bk(r,e,t=!0){return r.isValid?vo.create(_r.create("en-US"),{allowZ:t,forceSimple:!0}).formatDateTimeFromString(r,e):null}function S0(r,e){let t=r.c.year>9999||r.c.year<0,n="";return t&&r.c.year>=0&&(n+="+"),n+=Ur(r.c.year,t?6:4),e?(n+="-",n+=Ur(r.c.month),n+="-",n+=Ur(r.c.day)):(n+=Ur(r.c.month),n+=Ur(r.c.day)),n}function yW(r,e,t,n,i,o){let s=Ur(r.c.hour);return e?(s+=":",s+=Ur(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=":")):s+=Ur(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=Ur(r.c.second),(r.c.millisecond!==0||!n)&&(s+=".",s+=Ur(r.c.millisecond,3))),i&&(r.isOffsetFixed&&r.offset===0&&!o?s+="Z":r.o<0?(s+="-",s+=Ur(Math.trunc(-r.o/60)),s+=":",s+=Ur(Math.trunc(-r.o%60))):(s+="+",s+=Ur(Math.trunc(r.o/60)),s+=":",s+=Ur(Math.trunc(r.o%60)))),o&&(s+="["+r.zone.ianaName+"]"),s}var T3={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},tse={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},rse={ordinal:1,hour:0,minute:0,second:0,millisecond:0},k3=["year","month","day","hour","minute","second","millisecond"],nse=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],ise=["year","ordinal","hour","minute","second","millisecond"];function bW(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 xk(r);return e}function wW(r,e){let t=gu(e.zone,Sr.defaultZone),n=_r.fromObject(e),i=Sr.now(),o,s;if(wt(r.year))o=i;else{for(let c of k3)wt(r[c])&&(r[c]=T3[c]);let a=C3(r)||x3(r);if(a)return pt.invalid(a);let l=t.offset(i);[o,s]=Ck(r,l,t)}return new pt({ts:o,zone:t,loc:n,o:s})}function CW(r,e,t){let n=wt(t.round)?!0:t.round,i=(s,a)=>(s=K0(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 xW(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 pt=class r{constructor(e){let t=e.zone||Sr.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new yo("invalid input"):null)||(t.isValid?null:vk(t));this.ts=wt(e.ts)?Sr.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=yk(this.ts,a),n=Number.isNaN(i.year)?new yo("invalid input"):null,i=n?null:i,o=n?null:a}this._zone=t,this.loc=e.loc||_r.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]=xW(arguments),[n,i,o,s,a,l,c]=t;return wW({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static utc(){let[e,t]=xW(arguments),[n,i,o,s,a,l,c]=t;return e.zone=rs.utcInstance,wW({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static fromJSDate(e,t={}){let n=Pie(e)?e.valueOf():NaN;if(Number.isNaN(n))return r.invalid("invalid input");let i=gu(t.zone,Sr.defaultZone);return i.isValid?new r({ts:n,zone:i,loc:_r.fromObject(t)}):r.invalid(vk(i))}static fromMillis(e,t={}){if(np(e))return e<-gW||e>gW?r.invalid("Timestamp out of range"):new r({ts:e,zone:gu(t.zone,Sr.defaultZone),loc:_r.fromObject(t)});throw new zi(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(np(e))return new r({ts:e*1e3,zone:gu(t.zone,Sr.defaultZone),loc:_r.fromObject(t)});throw new zi("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};let n=gu(t.zone,Sr.defaultZone);if(!n.isValid)return r.invalid(vk(n));let i=Sr.now(),o=wt(t.specificOffset)?n.offset(i):t.specificOffset,s=_k(e,bW),a=!wt(s.ordinal),l=!wt(s.year),c=!wt(s.month)||!wt(s.day),u=l||c,d=s.weekYear||s.weekNumber,p=_r.fromObject(t);if((u||a)&&d)throw new tp("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&a)throw new tp("Can't mix ordinal dates with month/day");let f=d||s.weekday&&!u,m,g,v=yk(i,o);f?(m=nse,g=tse,v=B0(v)):a?(m=ise,g=rse,v=E0(v)):(m=k3,g=T3);let y=!1;for(let A of m){let D=s[A];wt(D)?y?s[A]=g[A]:s[A]=v[A]:y=!0}let b=f?Joe(s):a?ese(s):C3(s),x=b||x3(s);if(x)return r.invalid(x);let w=f?mW(s):a?hW(s):s,[T,C]=Ck(w,o,n),S=new r({ts:T,zone:n,o:C,loc:p});return s.weekday&&u&&e.weekday!==S.weekday?r.invalid("mismatched weekday",`you can't specify both a weekday of ${s.weekday} and a date of ${S.toISO()}`):S}static fromISO(e,t={}){let[n,i]=Coe(e);return wb(n,i,t,"ISO 8601",e)}static fromRFC2822(e,t={}){let[n,i]=xoe(e);return wb(n,i,t,"RFC 2822",e)}static fromHTTP(e,t={}){let[n,i]=Eoe(e);return wb(n,i,t,"HTTP",t)}static fromFormat(e,t,n={}){if(wt(e)||wt(t))throw new zi("fromFormat requires an input string and a format");let{locale:i=null,numberingSystem:o=null}=n,s=_r.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0}),[a,l,c,u]=Zoe(s,e,t);return u?r.invalid(u):wb(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]=Doe(e);return wb(n,i,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new zi("need to specify a reason the DateTime is invalid");let n=e instanceof yo?e:new yo(e,t);if(Sr.throwOnInvalid)throw new A0(n);return new r({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=h3(e,_r.fromObject(t));return n?n.map(i=>i?i.val:null).join(""):null}static expandFormat(e,t={}){return f3(vo.parseFormat(e),_r.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?k0(this).weekYear:NaN}get weekNumber(){return this.isValid?k0(this).weekNumber:NaN}get weekday(){return this.isValid?k0(this).weekday:NaN}get ordinal(){return this.isValid?E0(this.c).ordinal:NaN}get monthShort(){return this.isValid?oh.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?oh.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?oh.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?oh.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=Mk(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=yk(l,s),d=yk(c,a);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[ep(this,{ts:l}),ep(this,{ts:c})]:[this]}get isInLeapYear(){return Ab(this.year)}get daysInMonth(){return kk(this.year,this.month)}get daysInYear(){return this.isValid?Tb(this.year):NaN}get weeksInWeekYear(){return this.isValid?Sk(this.weekYear):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:i}=vo.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:i}}toUTC(e=0,t={}){return this.setZone(rs.instance(e),t)}toLocal(){return this.setZone(Sr.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if(e=gu(e,Sr.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]=Ck(s,o,e)}return ep(this,{ts:i,zone:e})}else return r.invalid(vk(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let i=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return ep(this,{loc:i})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=_k(e,bW),n=!wt(t.weekYear)||!wt(t.weekNumber)||!wt(t.weekday),i=!wt(t.ordinal),o=!wt(t.year),s=!wt(t.month)||!wt(t.day),a=o||s,l=t.weekYear||t.weekNumber;if((a||i)&&l)throw new tp("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(s&&i)throw new tp("Can't mix ordinal dates with month/day");let c;n?c=mW({...B0(this.c),...t}):wt(t.ordinal)?(c={...this.toObject(),...t},wt(t.day)&&(c.day=Math.min(kk(c.year,c.month),c.day))):c=hW({...E0(this.c),...t});let[u,d]=Ck(c,this.o,this.zone);return ep(this,{ts:u,o:d})}plus(e){if(!this.isValid)return this;let t=je.fromDurationLike(e);return ep(this,vW(this,t))}minus(e){if(!this.isValid)return this;let t=je.fromDurationLike(e).negate();return ep(this,vW(this,t))}startOf(e){if(!this.isValid)return this;let t={},n=je.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?vo.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):T0}toLocaleString(e=Ek,t={}){return this.isValid?vo.create(this.loc.clone(t),e).formatDateTime(this):T0}toLocaleParts(e={}){return this.isValid?vo.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=S0(this,s);return a+="T",a+=yW(this,s,t,n,i,o),a}toISODate({format:e="extended"}={}){return this.isValid?S0(this,e==="extended"):null}toISOWeekDate(){return bk(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":"")+yW(this,s==="extended",t,e,n,o):null}toRFC2822(){return bk(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return bk(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?S0(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")),bk(this,i,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():T0}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 je.invalid("created by diffing an invalid DateTime");let i={locale:this.locale,numberingSystem:this.numberingSystem,...n},o=Mie(t).map(je.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,l=s?e:this,c=Noe(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?ah.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?thist.valueOf(),Math.min)}static max(...e){if(!e.every(r.isDateTime))throw new zi("max requires all arguments be DateTimes");return oW(e,t=>t.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:i=null,numberingSystem:o=null}=n,s=_r.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0});return m3(s,e,t)}static fromStringExplain(e,t,n={}){return r.fromFormatExplain(e,t,n)}static get DATE_SHORT(){return Ek}static get DATE_MED(){return AW}static get DATE_MED_WITH_WEEKDAY(){return gie}static get DATE_FULL(){return IW}static get DATE_HUGE(){return DW}static get TIME_SIMPLE(){return FW}static get TIME_WITH_SECONDS(){return PW}static get TIME_WITH_SHORT_OFFSET(){return MW}static get TIME_WITH_LONG_OFFSET(){return $W}static get TIME_24_SIMPLE(){return OW}static get TIME_24_WITH_SECONDS(){return RW}static get TIME_24_WITH_SHORT_OFFSET(){return NW}static get TIME_24_WITH_LONG_OFFSET(){return LW}static get DATETIME_SHORT(){return VW}static get DATETIME_SHORT_WITH_SECONDS(){return BW}static get DATETIME_MED(){return qW}static get DATETIME_MED_WITH_SECONDS(){return UW}static get DATETIME_MED_WITH_WEEKDAY(){return vie}static get DATETIME_FULL(){return HW}static get DATETIME_FULL_WITH_SECONDS(){return zW}static get DATETIME_HUGE(){return WW}static get DATETIME_HUGE_WITH_SECONDS(){return jW}};function Cb(r){if(pt.isDateTime(r))return r;if(r&&r.valueOf&&np(r.valueOf()))return pt.fromJSDate(r);if(r&&typeof r=="object")return pt.fromObject(r);throw new zi(`Unknown datetime argument: ${r}, of type ${typeof r}`)}var eM={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},ose={allowHtml:!0};({...eM,...ose});var q0=class r{constructor(e){he(this,"value");he(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}},U0=class r{constructor(e){he(this,"error");he(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)}},Ak;(function(r){function e(o){return new q0(o)}r.success=e;function t(o){return new U0(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})(Ak||(Ak={}));var sse=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ik={exports:{}};Ik.exports;(function(r,e){(function(t,n){r.exports=n()})(typeof self<"u"?self:sse,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(k){if(!(this instanceof o))return new o(k);this._=k}var s=o.prototype;function a(k,R){for(var q=0;q>7),buf:(function(se){var oe=l(function(de,$e,vt,nr){return de.concat(vt===nr.length-1?Buffer.from([$e,0]).readUInt16BE(0):nr.readUInt16BE(vt))},[],se);return Buffer.from(c(function(de){return(de<<1&65535)>>8},oe))})(q.buf)}}),q}function d(){return typeof Buffer<"u"}function p(){if(!d())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function f(k){p();var R=l(function(oe,de){return oe+de},0,k);if(R%8!=0)throw new Error("The bits ["+k.join(", ")+"] add up to "+R+" which is not an even number of bytes; the total should be divisible by 8");var q,J=R/8,se=(q=function(oe){return oe>48},l(function(oe,de){return oe||(q(de)?de:oe)},null,k));if(se)throw new Error(se+" bit range requested exceeds 48 bit (6 byte) Number max.");return new o(function(oe,de){var $e=J+de;return $e>oe.length?A(de,J.toString()+" bytes"):S($e,l(function(vt,nr){var lr=u(nr,vt.buf);return{coll:vt.coll.concat(lr.v),buf:lr.buf}},{coll:[],buf:oe.slice(de,$e)},k).coll)})}function m(k,R){return new o(function(q,J){return p(),J+R>q.length?A(J,R+" bytes for "+k):S(J+R,q.slice(J,J+R))})}function g(k,R){if(typeof(q=R)!="number"||Math.floor(q)!==q||R<0||R>6)throw new Error(k+" requires integer length in range [0, 6].");var q}function v(k){return g("uintBE",k),m("uintBE("+k+")",k).map(function(R){return R.readUIntBE(0,k)})}function y(k){return g("uintLE",k),m("uintLE("+k+")",k).map(function(R){return R.readUIntLE(0,k)})}function b(k){return g("intBE",k),m("intBE("+k+")",k).map(function(R){return R.readIntBE(0,k)})}function x(k){return g("intLE",k),m("intLE("+k+")",k).map(function(R){return R.readIntLE(0,k)})}function w(k){return k instanceof o}function T(k){return{}.toString.call(k)==="[object Array]"}function C(k){return d()&&Buffer.isBuffer(k)}function S(k,R){return{status:!0,index:k,value:R,furthest:-1,expected:[]}}function A(k,R){return T(R)||(R=[R]),{status:!1,index:-1,value:null,furthest:k,expected:R}}function D(k,R){if(!R||k.furthest>R.furthest)return k;var q=k.furthest===R.furthest?(function(J,se){if((function(){if(o._supportsSet!==void 0)return o._supportsSet;var Xn=typeof Set<"u";return o._supportsSet=Xn,Xn})()&&Array.from){for(var oe=new Set(J),de=0;de=0;){if(de in q){J=q[de].line,oe===0&&(oe=q[de].lineStart);break}(k.charAt(de)===` `||k.charAt(de)==="\r"&&k.charAt(de+1)!==` `)&&(se++,oe===0&&(oe=de+1)),de--}var $e=J+se,vt=R-oe;return q[R]={line:$e,lineStart:oe},{offset:R,line:$e+1,column:vt+1}}function K(k){if(!w(k))throw new Error("not a parser: "+k)}function W(k,R){return typeof k=="string"?k.charAt(R):k[R]}function ee(k){if(typeof k!="number")throw new Error("not a number: "+k)}function me(k){if(typeof k!="function")throw new Error("not a function: "+k)}function O(k){if(typeof k!="string")throw new Error("not a string: "+k)}var H=2,ce=3,te=8,z=5*te,G=4*te,ie=" ";function xe(k,R){return new Array(R+1).join(k)}function ue(k,R,q){var J=R-k.length;return J<=0?k:xe(q,J)+k}function be(k,R,q,J){return{from:k-R>0?k-R:0,to:k+q>J?J:k+q}}function Ke(k,R){var q,J,se,oe,de,$e=R.index,vt=$e.offset,nr=1;if(vt===k.length)return"Got the end of the input";if(C(k)){var lr=vt-vt%te,Wr=vt-lr,Wt=be(lr,z,G+te,k.length),Xn=c(function(ir){return c(function(La){return ue(La.toString(16),2,"0")},ir)},(function(ir,La){var Xl=ir.length,Va=[],Ys=0;if(Xl<=La)return[ir.slice()];for(var Ba=0;Ba=4&&(q+=1),nr=2,se=c(function(ir){return ir.length<=4?ir.join(" "):ir.slice(0,4).join(" ")+" "+ir.slice(4).join(" ")},Xn),(de=(8*(oe.to>0?oe.to-1:oe.to)).toString(16).length)<2&&(de=2)}else{var Gs=k.split(/\r\n|[\n\r\u2028\u2029]/);q=$e.column-1,J=$e.line-1,oe=be(J,H,ce,Gs.length),se=Gs.slice(oe.from,oe.to),de=oe.to.toString().length}var Hh=J-oe.from;return C(k)&&(de=(8*(oe.to>0?oe.to-1:oe.to)).toString(16).length)<2&&(de=2),l(function(ir,La,Xl){var Va,Ys=Xl===Hh,Ba=Ys?"> ":ie;return Va=C(k)?ue((8*(oe.from+Xl)).toString(16),de,"0"):ue((oe.from+Xl+1).toString(),de," "),[].concat(ir,[Ba+Va+" | "+La],Ys?[ie+xe(" ",de)+" | "+ue("",q," ")+xe("^",nr)]:[])},[],se).join(` `)}function Oe(k,R){return[` `,"-- PARSING FAILED "+xe("-",50),` `,Ke(k,R),` `,(q=R.expected,q.length===1?`Expected: `+q[0]:`Expected one of the following: `+q.join(", ")),` `].join("");var q}function Ee(k){return k.flags!==void 0?k.flags:[k.global?"g":"",k.ignoreCase?"i":"",k.multiline?"m":"",k.unicode?"u":"",k.sticky?"y":""].join("")}function He(){for(var k=[].slice.call(arguments),R=k.length,q=0;q=2?ee(R):R=0;var q=(function(se){return RegExp("^(?:"+se.source+")",Ee(se))})(k),J=""+k;return o(function(se,oe){var de=q.exec(se.slice(oe));if(de){if(0<=R&&R<=de.length){var $e=de[0],vt=de[R];return S(oe+$e.length,vt)}return A(oe,"valid match group (0 to "+de.length+") in "+J)}return A(oe,J)})}function Fe(k){return o(function(R,q){return S(q,k)})}function Je(k){return o(function(R,q){return A(q,k)})}function mt(k){if(w(k))return o(function(R,q){var J=k._(R,q);return J.index=q,J.value="",J});if(typeof k=="string")return mt(ge(k));if(k instanceof RegExp)return mt(ve(k));throw new Error("not a string, regexp, or parser: "+k)}function Ft(k){return K(k),o(function(R,q){var J=k._(R,q),se=R.slice(q,J.index);return J.status?A(q,'not "'+se+'"'):S(q,null)})}function Qe(k){return me(k),o(function(R,q){var J=W(R,q);return q=k.length?A(R,"any character/byte"):S(R+1,W(k,R))}),Z=o(function(k,R){return S(k.length,k.slice(R))}),De=o(function(k,R){return R=0}).desc(R)},o.optWhitespace=Au,o.Parser=o,o.range=function(k,R){return Qe(function(q){return k<=q&&q<=R}).desc(k+"-"+R)},o.regex=ve,o.regexp=ve,o.sepBy=mr,o.sepBy1=zr,o.seq=He,o.seqMap=Le,o.seqObj=function(){for(var k,R={},q=0,J=(k=arguments,Array.prototype.slice.call(k)),se=J.length,oe=0;oe255)throw new Error("Value specified to byte constructor ("+k+"=0x"+k.toString(16)+") is larger in value than a single byte.");var R=(k>15?"0x":"0x0")+k.toString(16);return o(function(q,J){var se=W(q,J);return se===k?S(J+1,se):A(J,R)})},buffer:function(k){return m("buffer",k).map(function(R){return Buffer.from(R)})},encodedString:function(k,R){return m("string",R).map(function(q){return q.toString(k)})},uintBE:v,uint8BE:v(1),uint16BE:v(2),uint32BE:v(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:b,int8BE:b(1),int16BE:b(2),int32BE:b(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(k){return k.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(k){return k.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(k){return k.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(k){return k.readDoubleLE(0)})},t.exports=o}])})})(Ik,Ik.exports);var $=Ik.exports,tM=()=>/[#*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 S3(r){return r==null?r:r.shiftToAll().normalize()}function EW(r){return r.includes("/")&&(r=r.substring(r.lastIndexOf("/")+1)),r.endsWith(".md")&&(r=r.substring(0,r.length-3)),r}$.alt($.regex(new RegExp(tM(),"")),$.regex(/[0-9\p{Letter}_-]+/u).map(r=>r.toLocaleLowerCase()),$.whitespace.map(r=>"-"),$.any.map(r=>"")).many().map(r=>r.join(""));var ase=$.alt($.regex(new RegExp(tM(),"")),$.regex(/[0-9\p{Letter}_-]+/u),$.whitespace.map(r=>" "),$.any.map(r=>" ")).many().map(r=>r.join("").split(/\s+/).join(" ").trim());function lse(r){return ase.tryParse(r)}function cse(r){return r=S3(r),r=je.fromObject(Object.fromEntries(Object.entries(r.toObject()).filter(([,e])=>e!=0))),r.toHuman()}var Sb;(function(r){function e(w,T=eM,C=!1){let S=t(w);if(!S)return T.renderNullAs;switch(S.type){case"null":return T.renderNullAs;case"string":return S.value;case"number":case"boolean":return""+S.value;case"html":return S.value.outerHTML;case"widget":return S.value.markdown();case"link":return S.value.markdown();case"function":return"";case"array":let A="";return C&&(A+="["),A+=S.value.map(D=>e(D,T,!0)).join(", "),C&&(A+="]"),A;case"object":return"{ "+Object.entries(S.value).map(D=>D[0]+": "+e(D[1],T,!0)).join(", ")+" }";case"date":return S.value.second==0&&S.value.hour==0&&S.value.minute==0?S.value.toFormat(T.defaultDateFormat):S.value.toFormat(T.defaultDateTimeFormat);case"duration":return cse(S.value)}}r.toString=e;function t(w){return p(w)?{type:"null",value:w}:c(w)?{type:"number",value:w}:l(w)?{type:"string",value:w}:m(w)?{type:"boolean",value:w}:d(w)?{type:"duration",value:w}:u(w)?{type:"date",value:w}:v(w)?{type:"widget",value:w}:f(w)?{type:"array",value:w}:g(w)?{type:"link",value:w}:x(w)?{type:"function",value:w}:y(w)?{type:"html",value:w}:b(w)?{type:"object",value:w}:void 0}r.wrapValue=t;function n(w,T){if(b(w)){let C={};for(let[S,A]of Object.entries(w))C[S]=n(A,T);return C}else if(f(w)){let C=[];for(let S of w)C.push(n(S,T));return C}else return T(w)}r.mapLeaves=n;function i(w,T,C){if(w===void 0&&(w=null),T===void 0&&(T=null),w===null&&T===null)return 0;if(w===null)return-1;if(T===null)return 1;let S=t(w),A=t(T);if(S===void 0&&A===void 0)return 0;if(S===void 0)return-1;if(A===void 0)return 1;if(S.type!=A.type)return S.type.localeCompare(A.type);if(S.value===A.value)return 0;switch(S.type){case"string":return S.value.localeCompare(A.value);case"number":return S.valueG),K=U(D.path).localeCompare(U(P.path));if(K!=0)return K;let W=D.type.localeCompare(P.type);return W!=0?W:D.subpath&&!P.subpath?1:!D.subpath&&P.subpath?-1:!D.subpath&&!P.subpath?0:(D.subpath??"").localeCompare(P.subpath??"");case"date":return S.value0;case"boolean":return T.value;case"link":return!!T.value.path;case"date":return T.value.toMillis()!=0;case"duration":return T.value.as("seconds")!=0;case"object":return Object.keys(T.value).length>0;case"array":return T.value.length>0;case"null":return!1;case"html":case"widget":case"function":return!0}}r.isTruthy=s;function a(w){if(w==null)return w;if(r.isArray(w))return[].concat(w.map(T=>a(T)));if(r.isObject(w)){let T={};for(let[C,S]of Object.entries(w))T[C]=a(S);return T}else return w}r.deepCopy=a;function l(w){return typeof w=="string"}r.isString=l;function c(w){return typeof w=="number"}r.isNumber=c;function u(w){return w instanceof pt}r.isDate=u;function d(w){return w instanceof je}r.isDuration=d;function p(w){return w==null}r.isNull=p;function f(w){return Array.isArray(w)}r.isArray=f;function m(w){return typeof w=="boolean"}r.isBoolean=m;function g(w){return w instanceof Dk}r.isLink=g;function v(w){return w instanceof _b}r.isWidget=v;function y(w){return typeof HTMLElement<"u"?w instanceof HTMLElement:!1}r.isHtml=y;function b(w){return typeof w=="object"&&!y(w)&&!v(w)&&!f(w)&&!d(w)&&!u(w)&&!g(w)&&w!==void 0&&!p(w)}r.isObject=b;function x(w){return typeof w=="function"}r.isFunction=x})(Sb||(Sb={}));var TW;(function(r){function e(i){return Sb.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})(TW||(TW={}));var Dk=class r{constructor(e){he(this,"path");he(this,"display");he(this,"subpath");he(this,"embed");he(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:lse(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+="|"+EW(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 EW(this.path).replace(".md","")}},_b=class{constructor(e){he(this,"$widget");this.$widget=e}},H0=class extends _b{constructor(t,n){super("dataview:list-pair");he(this,"key");he(this,"value");this.key=t,this.value=n}markdown(){return`${Sb.toString(this.key)}: ${Sb.toString(this.value)}`}},z0=class extends _b{constructor(t,n){super("dataview:external-link");he(this,"url");he(this,"display");this.url=t,this.display=n}markdown(){return`[${this.display??this.url}](${this.url})`}},kW;(function(r){function e(s,a){return new H0(s,a)}r.listPair=e;function t(s,a){return new z0(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})(kW||(kW={}));var kr;(function(r){function e(p){return{type:"variable",name:p}}r.variable=e;function t(p){return{type:"literal",value:p}}r.literal=t;function n(p,f,m){return{type:"binaryop",left:p,op:f,right:m}}r.binaryOp=n;function i(p,f){return{type:"index",object:p,index:f}}r.index=i;function o(p){let f=p.split("."),m=r.variable(f[0]);for(let g=1;g"||p==">="||p=="!="||p=="="}r.isCompareOp=d,r.NULL=r.literal(null)})(kr||(kr={}));var Ta;(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,p){return{type:"binaryop",left:u,op:d,right:p}}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})(Ta||(Ta={}));var SW=new RegExp(tM(),""),W0={year:je.fromObject({years:1}),years:je.fromObject({years:1}),yr:je.fromObject({years:1}),yrs:je.fromObject({years:1}),month:je.fromObject({months:1}),months:je.fromObject({months:1}),mo:je.fromObject({months:1}),mos:je.fromObject({months:1}),week:je.fromObject({weeks:1}),weeks:je.fromObject({weeks:1}),wk:je.fromObject({weeks:1}),wks:je.fromObject({weeks:1}),w:je.fromObject({weeks:1}),day:je.fromObject({days:1}),days:je.fromObject({days:1}),d:je.fromObject({days:1}),hour:je.fromObject({hours:1}),hours:je.fromObject({hours:1}),hr:je.fromObject({hours:1}),hrs:je.fromObject({hours:1}),h:je.fromObject({hours:1}),minute:je.fromObject({minutes:1}),minutes:je.fromObject({minutes:1}),min:je.fromObject({minutes:1}),mins:je.fromObject({minutes:1}),m:je.fromObject({minutes:1}),second:je.fromObject({seconds:1}),seconds:je.fromObject({seconds:1}),sec:je.fromObject({seconds:1}),secs:je.fromObject({seconds:1}),s:je.fromObject({seconds:1})},j0={now:()=>pt.local(),today:()=>pt.local().startOf("day"),yesterday:()=>pt.local().startOf("day").minus(je.fromObject({days:1})),tomorrow:()=>pt.local().startOf("day").plus(je.fromObject({days:1})),sow:()=>pt.local().startOf("week"),"start-of-week":()=>pt.local().startOf("week"),eow:()=>pt.local().endOf("week"),"end-of-week":()=>pt.local().endOf("week"),soy:()=>pt.local().startOf("year"),"start-of-year":()=>pt.local().startOf("year"),eoy:()=>pt.local().endOf("year"),"end-of-year":()=>pt.local().endOf("year"),som:()=>pt.local().startOf("month"),"start-of-month":()=>pt.local().startOf("month"),eom:()=>pt.local().endOf("month"),"end-of-month":()=>pt.local().endOf("month")},G0=["FROM","WHERE","LIMIT","GROUP","FLATTEN"];function use(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 dse(r){let[e,t]=use(r);return Dk.infer(e,!1,t)}function xb(r,e,t){return $.seqMap(r,$.seq($.optWhitespace,e,$.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,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 Ws=$.createLanguage({number:r=>$.regexp(/-?[0-9]+(\.[0-9]+)?/).map(e=>Number.parseFloat(e)).desc("number"),string:r=>$.string('"').then($.alt(r.escapeCharacter,$.noneOf('"\\')).atLeast(0).map(e=>e.join(""))).skip($.string('"')).desc("string"),escapeCharacter:r=>$.string("\\").then($.any).map(e=>e==='"'?'"':e==="\\"?"\\":"\\"+e),bool:r=>$.regexp(/true|false|True|False/).map(e=>e.toLowerCase()=="true").desc("boolean ('true' or 'false')"),tag:r=>$.seqMap($.string("#"),$.alt($.regexp(/[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s]/).desc("text")).many(),(e,t)=>e+t.join("")).desc("tag ('#hello/stuff')"),identifier:r=>$.seqMap($.alt($.regexp(/\p{Letter}/u),$.regexp(SW).desc("text")),$.alt($.regexp(/[0-9\p{Letter}_-]/u),$.regexp(SW).desc("text")).many(),(e,t)=>e+t.join("")).desc("variable identifier"),link:r=>$.regexp(/\[\[([^\[\]]*?)\]\]/u,1).map(e=>dse(e)).desc("file link"),embedLink:r=>$.seqMap($.string("!").atMost(1),r.link,(e,t)=>(e.length>0&&(t.embed=!0),t)).desc("file link"),binaryPlusMinus:r=>$.regexp(/\+|-/).map(e=>e).desc("'+' or '-'"),binaryMulDiv:r=>$.regexp(/\*|\/|%/).map(e=>e).desc("'*' or '/' or '%'"),binaryCompareOp:r=>$.regexp(/>=|<=|!=|>|<|=/).map(e=>e).desc("'>=' or '<=' or '!=' or '=' or '>' or '<'"),binaryBooleanOp:r=>$.regexp(/and|or|&|\|/i).map(e=>e.toLowerCase()=="and"?"&":e.toLowerCase()=="or"?"|":e).desc("'and' or 'or'"),rootDate:r=>$.seqMap($.regexp(/\d{4}/),$.string("-"),$.regexp(/\d{2}/),(e,t,n)=>pt.fromObject({year:Number.parseInt(e),month:Number.parseInt(n)})).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),dateShorthand:r=>$.alt(...Object.keys(j0).sort((e,t)=>t.length-e.length).map($.string)),date:r=>pse(r.rootDate,e=>$.seqMap($.string("-"),$.regexp(/\d{2}/),(t,n)=>e.set({day:Number.parseInt(n)})),e=>$.seqMap($.string("T"),$.regexp(/\d{2}/),(t,n)=>e.set({hour:Number.parseInt(n)})),e=>$.seqMap($.string(":"),$.regexp(/\d{2}/),(t,n)=>e.set({minute:Number.parseInt(n)})),e=>$.seqMap($.string(":"),$.regexp(/\d{2}/),(t,n)=>e.set({second:Number.parseInt(n)})),e=>$.alt($.seqMap($.string("."),$.regexp(/\d{3}/),(t,n)=>e.set({millisecond:Number.parseInt(n)})),$.succeed(e)),e=>$.alt($.seqMap($.string("+").or($.string("-")),$.regexp(/\d{1,2}(:\d{2})?/),(t,n)=>e.setZone("UTC"+t+n,{keepLocalTime:!0})),$.seqMap($.string("Z"),()=>e.setZone("utc",{keepLocalTime:!0})),$.seqMap($.string("["),$.regexp(/[0-9A-Za-z+-\/]+/u),$.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=>$.alt(r.dateShorthand.map(e=>j0[e]()),r.date).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS] or in shorthand"),durationType:r=>$.alt(...Object.keys(W0).sort((e,t)=>t.length-e.length).map($.string)),duration:r=>$.seqMap(r.number,$.optWhitespace,r.durationType,(e,t,n)=>W0[n].mapUnits(i=>i*e)).sepBy1($.string(",").trim($.optWhitespace).or($.optWhitespace)).map(e=>e.reduce((t,n)=>t.plus(n))).desc("duration like 4hr2min"),rawNull:r=>$.string("null"),tagSource:r=>r.tag.map(e=>Ta.tag(e)),csvSource:r=>$.seqMap($.string("csv(").skip($.optWhitespace),r.string,$.string(")"),(e,t,n)=>Ta.csv(t)),linkIncomingSource:r=>r.link.map(e=>Ta.link(e.path,!0)),linkOutgoingSource:r=>$.seqMap($.string("outgoing(").skip($.optWhitespace),r.link,$.string(")"),(e,t,n)=>Ta.link(t.path,!1)),folderSource:r=>r.string.map(e=>Ta.folder(e)),parensSource:r=>$.seqMap($.string("("),$.optWhitespace,r.source,$.optWhitespace,$.string(")"),(e,t,n,i,o)=>n),negateSource:r=>$.seqMap($.alt($.string("-"),$.string("!")),r.atomSource,(e,t)=>Ta.negate(t)),atomSource:r=>$.alt(r.parensSource,r.negateSource,r.linkOutgoingSource,r.linkIncomingSource,r.folderSource,r.tagSource,r.csvSource),binaryOpSource:r=>xb(r.atomSource,r.binaryBooleanOp.map(e=>e),Ta.binaryOp),source:r=>r.binaryOpSource,variableField:r=>r.identifier.chain(e=>G0.includes(e.toUpperCase())?$.fail("Variable fields cannot be a keyword ("+G0.join(" or ")+")"):$.succeed(kr.variable(e))).desc("variable"),numberField:r=>r.number.map(e=>kr.literal(e)).desc("number"),stringField:r=>r.string.map(e=>kr.literal(e)).desc("string"),boolField:r=>r.bool.map(e=>kr.literal(e)).desc("boolean"),dateField:r=>$.seqMap($.string("date("),$.optWhitespace,r.datePlus,$.optWhitespace,$.string(")"),(e,t,n,i,o)=>kr.literal(n)).desc("date"),durationField:r=>$.seqMap($.string("dur("),$.optWhitespace,r.duration,$.optWhitespace,$.string(")"),(e,t,n,i,o)=>kr.literal(n)).desc("duration"),nullField:r=>r.rawNull.map(e=>kr.NULL),linkField:r=>r.link.map(e=>kr.literal(e)),listField:r=>r.field.sepBy($.string(",").trim($.optWhitespace)).wrap($.string("[").skip($.optWhitespace),$.optWhitespace.then($.string("]"))).map(e=>kr.list(e)).desc("list ('[1, 2, 3]')"),objectField:r=>$.seqMap(r.identifier.or(r.string),$.string(":").trim($.optWhitespace),r.field,(e,t,n)=>({name:e,value:n})).sepBy($.string(",").trim($.optWhitespace)).wrap($.string("{").skip($.optWhitespace),$.optWhitespace.then($.string("}"))).map(e=>{let t={};for(let n of e)t[n.name]=n.value;return kr.object(t)}).desc("object ('{ a: 1, b: 2 }')"),atomInlineField:r=>$.alt(r.date,r.duration.map(e=>S3(e)),r.string,r.tag,r.embedLink,r.bool,r.number,r.rawNull),inlineFieldList:r=>r.atomInlineField.sepBy($.string(",").trim($.optWhitespace).lookahead(r.atomInlineField)),inlineField:r=>$.alt($.seqMap(r.atomInlineField,$.string(",").trim($.optWhitespace),r.inlineFieldList,(e,t,n)=>[e].concat(n)),r.atomInlineField),atomField:r=>$.alt(r.embedLink.map(e=>kr.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=>$.seqMap(r.atomField,$.alt(r.dotPostfix,r.indexPostfix,r.functionPostfix).many(),(e,t)=>{let n=e;for(let i of t)switch(i.type){case"dot":n=kr.index(n,kr.literal(i.field));break;case"index":n=kr.index(n,i.field);break;case"function":n=kr.func(n,i.fields);break}return n}),negatedField:r=>$.seqMap($.string("!"),r.indexField,(e,t)=>kr.negate(t)).desc("negated field"),parensField:r=>$.seqMap($.string("("),$.optWhitespace,r.field,$.optWhitespace,$.string(")"),(e,t,n,i,o)=>n),lambdaField:r=>$.seqMap(r.identifier.sepBy($.string(",").trim($.optWhitespace)).wrap($.string("(").trim($.optWhitespace),$.string(")").trim($.optWhitespace)),$.string("=>").trim($.optWhitespace),r.field,(e,t,n)=>({type:"lambda",arguments:e,value:n})),dotPostfix:r=>$.seqMap($.string("."),r.identifier,(e,t)=>({type:"dot",field:t})),indexPostfix:r=>$.seqMap($.string("["),$.optWhitespace,r.field,$.optWhitespace,$.string("]"),(e,t,n,i,o)=>({type:"index",field:n})),functionPostfix:r=>$.seqMap($.string("("),$.optWhitespace,r.field.sepBy($.string(",").trim($.optWhitespace)),$.optWhitespace,$.string(")"),(e,t,n,i,o)=>({type:"function",fields:n})),binaryMulDivField:r=>xb(r.indexField,r.binaryMulDiv,kr.binaryOp),binaryPlusMinusField:r=>xb(r.binaryMulDivField,r.binaryPlusMinus,kr.binaryOp),binaryCompareField:r=>xb(r.binaryPlusMinusField,r.binaryCompareOp,kr.binaryOp),binaryBooleanField:r=>xb(r.binaryCompareField,r.binaryBooleanOp,kr.binaryOp),binaryOpField:r=>r.binaryBooleanField,field:r=>r.binaryOpField});function fse(r){try{return Ak.success(Ws.field.tryParse(r))}catch(e){return Ak.failure(""+e)}}var Fk;(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})(Fk||(Fk={}));function mse(r){return $.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 hse(r){return r.split(/[\r\n]+/).map(e=>e.trim()).join("")}function _W(r,e){return $.eof.map(r).or($.whitespace.then(e))}var _3=$.createLanguage({queryType:r=>$.alt($.regexp(/TABLE|LIST|TASK|CALENDAR/i)).map(e=>e.toLowerCase()).desc("query type ('TABLE', 'LIST', 'TASK', or 'CALENDAR')"),explicitNamedField:r=>$.seqMap(Ws.field.skip($.whitespace),$.regexp(/AS/i).skip($.whitespace),Ws.identifier.or(Ws.string),(e,t,n)=>Fk.named(n,e)),comment:()=>$.Parser((r,e)=>{let t=r.substring(e);if(!t.startsWith("//"))return $.makeFailure(e,"Not a comment");t=t.split(` `)[0];let n=t.substring(2).trim();return $.makeSuccess(e+t.length,n)}),namedField:r=>$.alt(r.explicitNamedField,mse(Ws.field).map(([e,t])=>Fk.named(hse(t),e))),sortField:r=>$.seqMap(Ws.field.skip($.optWhitespace),$.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 _W(()=>({type:e,fields:[],showId:!0}),$.seqMap($.regexp(/WITHOUT\s+ID/i).skip($.optWhitespace).atMost(1),$.sepBy(r.namedField,$.string(",").trim($.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return _W(()=>({type:e,format:void 0,showId:!0}),$.seqMap($.regexp(/WITHOUT\s+ID/i).skip($.optWhitespace).atMost(1),Ws.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return $.succeed({type:e});case"calendar":return $.whitespace.then($.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return $.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>$.seqMap($.regexp(/FROM/i),$.whitespace,Ws.source,(e,t,n)=>n),whereClause:r=>$.seqMap($.regexp(/WHERE/i),$.whitespace,Ws.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE "),sortByClause:r=>$.seqMap($.regexp(/SORT/i),$.whitespace,r.sortField.sepBy1($.string(",").trim($.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>$.seqMap($.regexp(/LIMIT/i),$.whitespace,Ws.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT "),flattenClause:r=>$.seqMap($.regexp(/FLATTEN/i).skip($.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN [AS ]"),groupByClause:r=>$.seqMap($.regexp(/GROUP BY/i).skip($.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY [AS ]"),clause:r=>$.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>$.seqMap(r.headerClause.trim(_0),r.fromClause.trim(_0).atMost(1),r.clause.trim(_0).many(),(e,t,n)=>({header:e,source:t.length==0?Ta.folder(""):t[0],operations:n,settings:eM}))}),_0=$.alt($.whitespace,_3.comment).many().map(r=>r.join("")),gse=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,vse=r=>r.plugins.enabledPlugins.has("dataview");ka.DATE_SHORTHANDS=j0;ka.DURATION_TYPES=W0;ka.EXPRESSION=Ws;ka.KEYWORDS=G0;ka.QUERY_LANGUAGE=_3;ka.getAPI=gse;ka.isPluginEnabled=vse;ka.parseField=fse});function Rk(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o{});function Nk(r){return r.replace(/[\\"]/g,"\\$&")}function yse(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function I3(r){return Nk(yse(r))}function D3(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var nM,Fb,F3=E(()=>{nM=z$(A3());Ie();rM();Fb=class{static getDataviewAPI(e){let t=(0,nM.getAPI)(e);return t||(I.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){return this.queryFieldValues(e,t)}static async getFieldValuesWithFilter(e,t,n={}){return this.queryFieldValues(e,t,n)}static async queryFieldValues(e,t,n){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${Nk(t)}")`,l=[a],c=(n?.folders?.length?n.folders:n?.folder?[n.folder]:[]).map(g=>g.replace(/^\/+|\/+$/g,"")).filter(Boolean);if(c.length>0){let g=c.map(v=>`regexmatch("^${I3(v)}/", file.path)`);l.push(`(${g.join(" OR ")})`)}n?.tags?.length&&n.tags.forEach(g=>{let v=g.startsWith("#")?g:`#${g}`;l.push(`contains(file.tags, "${Nk(v)}")`)}),n?.excludeFolders?.length&&n.excludeFolders.forEach(g=>{let v=g.replace(/^\/+|\/+$/g,"");l.push(`!regexmatch("^${I3(v)}/", file.path)`)}),n?.excludeTags?.length&&n.excludeTags.forEach(g=>{let v=g.startsWith("#")?g:`#${g}`;l.push(`!contains(file.tags, "${Nk(v)}")`)});let u=l.join(" AND "),d=`TABLE ${a} WHERE ${u}`,p=await o.query(d),f=n?.excludeFiles??[],m=g=>{if(f.length===0)return!1;let v=g[0],y=v&&typeof v.path=="string"?v.path:null;if(!y)return!1;let b=y.split("/").pop()??y;return f.some(x=>x===y||x===b)};if(p.successful&&p.value.values)for(let g of p.value.values){if(m(g))continue;let v=g[1];Array.isArray(v)?v.forEach(y=>{y&&typeof y=="string"?i.add(y.trim()):D3(y)?i.add(y.path):y&&typeof y!="object"&&i.add(String(y).trim())}):D3(v)?i.add(v.path):v&&typeof v=="string"?Rk(v).forEach(y=>i.add(y)):v&&typeof v!="object"&&i.add(String(v).trim())}}catch(s){I.logError(new Error(`Failed to query Dataview for field ${t}${n?" with filters":""}: ${s}`))}return i}static isAvailable(e){return(0,nM.getAPI)(e)!==null}}});var Vl,Lk=E(()=>{Vl=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;for(let s of t){if(o.size>=this.MAX_VALUES_PER_ENTRY)break;o.add(s)}this.cache.size>=this.MAX_CACHE_ENTRIES&&!this.cache.has(i)&&this.evictOldestEntries(1),this.cache.set(i,{fieldName:e,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){this.cache.clear();return}for(let[t,n]of this.cache)n.fieldName===e&&this.cache.delete(t)}cleanExpired(){let e=Date.now();for(let[t,n]of this.cache)e-n.timestamp>this.TTL&&this.cache.delete(t)}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])}}});var Vk,P3=E(()=>{Vk=class{static deduplicate(e,t=!1){let n=new Map;for(let o of e){let s=t?o:o.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase();n.has(s)||n.set(s,o)}let i=Array.from(n.values());return i.sort((o,s)=>t?o.localeCompare(s):o.toLowerCase().localeCompare(s.toLowerCase())),{values:i,duplicatesRemoved:e.length-i.length}}}});var Sa,iM=E(()=>{Xe();P3();Sa=class{static processValues(e,t){let n=e.size,i=Array.from(e).filter(l=>!this.isUnresolvedFieldToken(l)),o=Vk.deduplicate(i,t.caseSensitive);i=o.values;let{processedValues:s,hasDefault:a}=this.applyDefaultValues(i,t);return i=s,{values:i,hasDefaultValue:a,duplicatesRemoved:o.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[]}};Sa.unresolvedFieldTokenRegex=new RegExp(`^${cC.source}$`,"i")});var Bl,fh,oM=E(()=>{rM();Bl=class Bl{static parseInlineFields(e,t){let n=new Map,i=this.removeCodeBlocksAndFrontmatter(e,t),o;for(;(o=Bl.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 Rk(a))n.get(s)?.add(l)}}return Bl.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(a=>a.trim().toLowerCase()).filter(a=>a.length>0)),i=e.split(` `),o=[],s=null;for(let a of i){if(!s){let l=this.matchFenceOpen(a);l?s={...l,lines:[a]}:o.push(a);continue}if(this.matchFenceClose(a,s.length)){let l=s.info.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&l!==void 0&&l.length>0&&n.has(l))for(let u=1;u=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}};Bl.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,Bl.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,Bl.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,Bl.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,Bl.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;fh=Bl});function sM(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 M3(r,e,t){return(await aM(r,e,t)).values}async function aM(r,e,t){let n=await bse(r,e,t),i=Sa.processValues(n,t);return{values:i.values,hasDefaultValue:i.hasDefaultValue}}async function bse(r,e,t){let n=Vl.getInstance(),i=sM(t),o=n.get(e,i);if(o)return o;let s=n.getRevision(),a=await lM(r,e,t);return n.setIfRevision(e,a,i,s),a}async function lM(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await wse(r,t);if(i.size>0)return i}try{if(!t.inline&&Fb.isAvailable(r)){let i=await Fb.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await Ese(r,e,t)}async function wse(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=Cse(r);if(n.size>0)return n}return await xse(r,e)}function Cse(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}function Pb(r,e){if(e!=null)for(let t of Array.isArray(e)?e:[e]){let n=String(t).trim();n&&r.add(n)}}async function $3(r,e,t){let n=new Set,i=xi.filterFiles(r.vault.getMarkdownFiles(),e,o=>r.metadataCache.getFileCache(o));for(let o=0;o{let l=new Set;try{await t(a,l)}catch{}return l}));for(let a of s)for(let l of a)n.add(l)}return n}async function xse(r,e){return $3(r,e,(t,n)=>{let i=r.metadataCache.getFileCache(t);Pb(n,i?.frontmatter?.tags),Pb(n,i?.frontmatter?.tag);for(let o of i?.tags??[]){let s=String(o.tag??"").trim().replace(/^#/,"");s&&n.add(s)}})}async function Ese(r,e,t){return $3(r,t,async(n,i)=>{let o=r.metadataCache.getFileCache(n)?.frontmatter?.[e];if(Array.isArray(o)?o.forEach(s=>Pb(i,[s])):typeof o!="object"&&Pb(i,o),t.inline){let s=await r.vault.read(n);Pb(i,[...fh.getFieldValues(s,e,{includeCodeBlocks:t.inlineCodeBlocks})])}})}var Bk=E(()=>{F3();pd();Lk();iM();oM()});function Tse(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=O3(o);s!==null&&i.push(s)}return i.length>0?i:null}return O3(n)}function qk(r,e,t){if(!e||e.extension!=="md")return null;let n=r.metadataCache.getFileCache(e)?.frontmatter;return Tse(n,t)}function O3(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 cM=E(()=>{});async function R3({app:r,executor:e,getSourcePath:t},n){let i=e?.promptProvider;try{let{fieldName:o,filters:s,multiSelect:a}=oi.parse(n),l=s.defaultFrom==="active"?qk(r,e?.triggerContext?.activeFile??null,o):null,{values:c,hasDefaultValue:u}=await aM(r,o,s),d=c,p=u,f=s.defaultValue;!a&&typeof l=="string"?(d=Sa.promoteValueToFront(d,l,s.caseSensitive),f=l,p=!0):!a&&Array.isArray(l)&&l.length>0&&I.logMessage(`{{FIELD:${o}|default-from:active}}: the active note's "${o}" is a list value, which applies only to |multi FIELD prompts, so no default was prefilled.`);let m=a?`Select values for ${o}`:`Enter value for ${o}`;if(p&&f&&(m=a?`Select values for ${o} (default: ${f})`:`Enter value for ${o} (default: ${f})`),a){let g=d;if(d.length===0&&!s.defaultValue){let y=Sa.getSmartDefaults(o,[]);y.length>0&&(g=y)}let v=l===null?void 0:(Array.isArray(l)?l:[l]).map(y=>Sa.canonicalizeAgainst(g,y,s.caseSensitive));return i?await i.suggesterMulti(g,g,{placeholder:m,allowCustomInput:!0,preselected:v&&v.length>0?v:void 0}):await du.Suggest(r,g,g,{placeholder:m,allowCustomValue:!0,...v&&v.length>0?{preselected:v}:{}})}if(d.length===0){let g="No existing values were found in your vault.";if(!s.defaultValue){let v=Sa.getSmartDefaults(o,[]);v.length>0&&(g+=` Suggested values for ${o}: ${v.slice(0,3).join(", ")}`)}return i?await i.inputPrompt(`Enter value for ${o}`,g):await ar.PromptWithContext(r,`Enter value for ${o}`,g,void 0,t()??void 0,void 0,{allowPeek:!0})}return i?String(await i.suggester(d,d,m,!0)):await Mr.Suggest(r,d,d,{placeholder:m})}catch(o){throw ot(o)?new at("Input cancelled by user"):o}}async function N3({app:r,executor:e,getSourcePath:t},n){let i=e?.promptProvider;try{let o=xi.filterFiles(r.vault.getMarkdownFiles(),n.filter,u=>r.metadataCache.getFileCache(u)),s=n.label??`Select a file from ${n.folderPath}`;if(o.length===0){let u=`No markdown files found in "${n.folderPath}". Type a value or leave empty.`,d=i?await i.inputPrompt(s,u):await ar.Prompt(r,s,u,void 0,void 0,{optional:n.optional||void 0,allowPeek:!0});return n.multiSelect?d?[`${As}${d}`]:[]:d?`${As}${d}`:""}let a=$c(o,u=>r.metadataCache.getFileCache(u)),l=o.map(u=>`${Pc}${u.path}`);if(n.multiSelect)return(i?await i.suggesterMulti(a,l,{placeholder:s,allowCustomInput:n.allowCustomInput}):await du.Suggest(r,a,l,{placeholder:s,allowCustomValue:n.allowCustomInput,...n.optional?{skippable:!0}:{}})).map(d=>l.includes(d)?d:`${As}${d}`);if(i){let u=String(await i.suggester(a,l,s,n.allowCustomInput));return u?l.includes(u)?u:`${As}${u}`:""}if(n.allowCustomInput){let u=new Set(o.map(f=>f.basename.toLowerCase())),d=new Set(a.map(f=>f.toLowerCase())),p=await Mr.Suggest(r,a,l,{placeholder:s,valueExists:f=>u.has(f.toLowerCase())||d.has(f.toLowerCase()),...n.optional?{skippable:!0}:{}});return p?l.includes(p)?p:`${As}${p}`:""}return await Xt.Suggest(r,a,l,s,void 0,n.optional?{skippable:!0}:void 0)??""}catch(o){throw ot(o)?new at("Input cancelled by user"):o}}var L3=E(()=>{Ds();Ol();h0();Zo();hl();pd();Bk();iM();cM();lo();ur();xt();Ie()});function _se(r){return`\\begin{${r}} \u261A \\end{${r}}\u261A`}var kse,Sse,V3,uM=E(()=>{kse=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\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"],Sse=["align","align*","alignat","alignat*","array","Bmatrix","bmatrix","cases","eqnarray","eqnarray*","equation","equation*","gather","gather*","matrix","pmatrix","smallmatrix","subarray","Vmatrix","vmatrix"];V3=[...kse,...Sse.map(_se)]});function Ise(r){if(dM.has(r))return dM.get(r)??null;let e=null;try{e=(0,B3.renderMath)(r,!0)}catch{e=null}return dM.set(r,e),e}function Dse(r){return pM===null&&(pM=new Fc(r,{findAllMatches:!0,threshold:.8})),pM}var B3,Ase,dM,pM,Uk,q3=E(()=>{ks();XC();B3=require("obsidian");uM();_s();Ase=new RegExp(/\\([a-z{}A-Z0-9]*)$/),dM=new Map,pM=null;Uk=class extends xr{constructor(t){super(on().app,t);this.inputEl=t;this.lastInput="";this.symbols=Object.assign([],V3)}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=Ase.exec(s),l=[];a&&(this.lastInput=a[1],l=this.symbols.filter(d=>d.toLowerCase().contains(this.lastInput)));let c=new Set(l);return Dse(this.symbols).search(this.lastInput).map(d=>d.item).filter(d=>c.has(d))}renderSuggestion(t,n){if(t){n.setText(t);let i=Ise(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 Wi,Hk,U3=E(()=>{Wi=require("obsidian");_s();uM();q3();ur();Hk=class r extends Wi.Modal{constructor(){super(on().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 Uk(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 Wi.TextAreaComponent(this.contentEl);n.inputEl.setCssStyles({width:"100%",height:"10rem"}),this.inputEl=n.inputEl,n.onChange((0,Wi.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,Wi.loadMathJax)()}async mathjaxLoop(t,n){let i=(0,Wi.renderMath)(n,!0);await(0,Wi.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 Wi.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(Rr())}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}}});function Mb(r){return r.replace(Fse," ").replace(/\s+/g," ").trim()}function H3(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 z3(r){let e=[],t=!1,n="",i=0;for(let o=0;o=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||!H3(r[o-2]);!u&&d&&H3(c)&&e.push({heading:c.trim(),level:l[1][0]==="="?1:2,line:o-1});continue}}return e}function Pse(r,e){let t=[],n=Mb(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].leveld!==t&&Mb(u.heading).toLowerCase()===i))return`#${n}`;let s=Pse(r,t);if(s.length<2)return null;let a=s.join("#"),l=a.toLowerCase();return Mse(r).some((u,d)=>d!==t&&u===l)?null:`#${a}`}function Mse(r){let e=new Array(r.length),t=[];for(let n=0;n0&&r[t[t.length-1]].level>=r[n].level;)t.pop();let i=t.length>0?e[t[t.length-1]]:[],o=Mb(r[n].heading);e[n]=o?[...i,o]:i,t.push(n)}return e.map(n=>n.join("#").toLowerCase())}var Fse,j3=E(()=>{Fse=/[!"#$%&()*+,.:;<=>?@^`{|}~/[\]\\\r\n]/g});async function zk(r,e,t,n){return await zE(r,t,n)&&await e.saveSettings?.(),dU(r,t,n)}var fM=E(()=>{Ml()});function bu(r,{logPrefix:e,noticePrefix:t=e,defaultReason:n}){if(!(r instanceof yt))return!1;let i=typeof r.message=="string"&&r.message.trim().length>0?r.message:n;return I.logMessage(`${e}: ${i}`),(!(r instanceof at||typeof r.message=="string"&&r.message.toLowerCase().includes("cancelled by user"))||X.getState().showInputCancellationNotification)&&new G3.Notice(`${t}: ${i}`),!0}var G3,$b=E(()=>{G3=require("obsidian");Ni();ur();dt();Ie()});var Y3={};fw(Y3,{SingleMacroEngine:()=>mM});function Ose(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 $se,mM,K3=E(()=>{Ie();vr();ht();bt();YE();fM();Ob();$b();un();Ni();$se=new Set(["settings","entry","quickadd"]);mM=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}=dd(e),o=c=>(c??"").trim(),s=nn(this.choices).find(c=>c.type==="Macro"&&o(c.name)===o(n));if(!s){let c=d=>o(d).toLowerCase(),u=nn(this.choices).filter(d=>d.type==="Macro"&&c(d.name)===c(n));if(u.length>1)throw I.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 I.logError(`macro '${e}' does not exist.`),new Error(`macro '${e}' does not exist.`);let a=new _a(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||I.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)),Ose(l)}getVariables(){return this.variables}async tryExecuteExport(e,t,n){let i=Ht(t.macro?.commands);if(!i.length)return{executed:!1};let o=i.map((c,u)=>({command:c,index:u})).filter(c=>qr(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=zy(c)?c:i,d;a!==void 0?d=u.findIndex(w=>qr(w)&&w.id===a&&w.type==="UserScript"):d=s.candidate.index;let p=d>=0?u[d]:void 0;if(!p||p.type!=="UserScript")throw new yt(`Could not resolve the member-access script for '${t.name}'.`);let f=p;f.settings||(f.settings={});let m=s.candidate.exportsRef!==void 0?s.candidate.exportsRef:await Lo(f,this.app);if(m==null)throw new yt(`Macro '${t.name}' could not load '${f.name}' for member access.`);let g=typeof m=="object"||typeof m=="function"?m.settings:void 0;g&&typeof g=="object"&&Em(f.settings,g);let v=s.candidate.resolvedMember??this.resolveMemberAccess(m,s.memberAccess);if(!v.found)throw new yt(`Macro '${t.name}' routes member access to '${f.name}', but that script does not export '${s.memberAccess.join("::")}'.`);let y=u.slice(d+1),b=f.settings;typeof v.value=="function"&&(b=await zk(this.app,this.plugin,f,g&&typeof g=="object"?g:void 0));let x=await this.executeResolvedMember(v.value,e,b);return this.ensureNotAborted(),e.setOutput(x),this.syncVariablesFromParams(e),y.length&&(await e.runSubset(y),this.ensureNotAborted()),{executed:!0,result:x}}catch(c){throw bu(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 Lo(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 yt(`Macro '${e.name}' could not find '${n.join("::")}' in any user script.`);if($se.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 yt(`Macro '${e.name}' has multiple user scripts exporting '${n.join("::")}': ${a}. Disambiguate with '{{MACRO:${e.name}::