421 lines
1.2 MiB
Plaintext
421 lines
1.2 MiB
Plaintext
/*
|
||
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
||
if you want to view the source, please visit the github repository of this plugin
|
||
*/
|
||
|
||
var k7=Object.create;var tv=Object.defineProperty;var S7=Object.getOwnPropertyDescriptor;var D7=Object.getOwnPropertyNames;var I7=Object.getPrototypeOf,P7=Object.prototype.hasOwnProperty;var LN=r=>{throw TypeError(r)};var F7=(r,e,t)=>e in r?tv(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var b=(r,e,t)=>()=>{if(t)throw t[0];try{return r&&(e=r(r=0)),e}catch(n){throw t=[n],n}};var M7=(r,e)=>()=>{try{return e||r((e={exports:{}}).exports,e),e.exports}catch(t){throw e=0,t}},Zr=(r,e)=>{for(var t in e)tv(r,t,{get:e[t],enumerable:!0})},BN=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of D7(e))!P7.call(r,i)&&i!==t&&tv(r,i,{get:()=>e[i],enumerable:!(n=S7(e,i))||n.enumerable});return r};var UN=(r,e,t)=>(t=r!=null?k7(I7(r)):{},BN(e||!r||!r.__esModule?tv(t,"default",{value:r,enumerable:!0}):t,r)),R7=r=>BN(tv({},"__esModule",{value:!0}),r);var le=(r,e,t)=>F7(r,typeof e!="symbol"?e+"":e,t),nI=(r,e,t)=>e.has(r)||LN("Cannot "+t);var H=(r,e,t)=>(nI(r,e,"read from private field"),t?t.call(r):e.get(r)),it=(r,e,t)=>e.has(r)?LN("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(r):e.set(r,t),et=(r,e,t,n)=>(nI(r,e,"write to private field"),n?n.call(r,t):e.set(r,t),t),xt=(r,e,t)=>(nI(r,e,"access private method"),t);var P2,F2,M2=b(()=>{P2=r=>{let e,t=new Set,n=(c,u)=>{let d=typeof c=="function"?c(e):c;if(!Object.is(d,e)){let f=e;e=u??(typeof d!="object"||d===null)?d:Object.assign({},e,d),t.forEach(p=>p(e,f))}},i=()=>e,a={setState:n,getState:i,getInitialState:()=>l,subscribe:c=>(t.add(c),()=>t.delete(c))},l=e=r(n,i,a);return a},F2=(r=>r?P2(r):P2)});function Rv(r){if(r.kind)return r.kind;let e=(r.name??"").toLowerCase(),t=JX(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 JX(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 eQ(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function dT(r,e){let t=eQ(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 pT(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=dT(n.id??n.name,r),t.add(n.id),e=!0}return e}function mu(r,e){return e&&e.name===r?e:void 0}function fT(r){return $v[r].map(e=>({...e}))}var $v,R2,tQ,rQ,mT,es=b(()=>{$v={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}]},R2={openai:["gpt-4-32k","gpt-4-1106-preview"],google:["gemini-1.5-pro","gemini-1.5-flash","gemini-1.5-flash-8b"]};tQ={id:"openai",name:"OpenAI",endpoint:"https://api.openai.com/v1",kind:"openai",apiKey:"",models:fT("openai"),autoSyncModels:!0,modelSource:"modelsDev"},rQ={id:"gemini",name:"Gemini",endpoint:"https://generativelanguage.googleapis.com",kind:"gemini",apiKey:"",models:fT("google"),autoSyncModels:!0,modelSource:"modelsDev"},mT=[tQ,rQ]});function $2(r,e){return Object.prototype.hasOwnProperty.call(r,e)?r[e]:void 0}function Ov(r,e=Kf){let t=r.trim();if(!t)return r;let n=$2(e,t.toLowerCase());if(n)return n;let[i,...o]=t.split(/\s+/),s=$2(e,i.toLowerCase());return s?[s,...o].join(" "):r}function O2(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 s0(r){return Object.entries(r).filter(([e,t])=>e&&t).map(([e,t])=>`${e} = ${t}`).join(`
|
||
`)}function Nv(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 hT(r){return Nv(r).map(([e,t])=>`${e}=${t}`).join(", ")}var Kf,Wd=b(()=>{Kf={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 gT,a0=b(()=>{es();Wd();gT={choices:[],inputPrompt:"single-line",persistInputPromptDrafts:!0,useSelectionAsCaptureValue:!0,searchNestedChoices:!0,templateFolderLauncherRow:"bottom",devMode:!1,templateFolderPaths:[],announceUpdates:"major",version:"0.0.0",globalVariables:{},onePageInputEnabled:!1,disableOnlineFeatures:!0,enableUriCallbacks:!1,enableRibbonIcon:!1,showCaptureNotification:!0,showInputCancellationNotification:!1,enableTemplatePropertyTypes:!1,dateAliases:Kf,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:mT,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 ht(r){if(typeof structuredClone=="function")try{return structuredClone(r)}catch{}return hu(r,new Map)}function hu(r,e){if(r===null||typeof r!="object")return r;if(e.has(r))return e.get(r);if(r instanceof Date){let i=new Date(r.getTime());return e.set(r,i),i}if(Array.isArray(r)){let i=[];e.set(r,i);for(let o of r)i.push(hu(o,e));return i}if(r instanceof Map){let i=new Map;e.set(r,i);for(let[o,s]of r.entries())i.set(hu(o,e),hu(s,e));return i}if(r instanceof Set){let i=new Set;e.set(r,i);for(let o of r.values())i.add(hu(o,e));return i}if(r instanceof RegExp){let i=new RegExp(r.source,r.flags);return i.lastIndex=r.lastIndex,e.set(r,i),i}if(r instanceof ArrayBuffer){let i=r.slice(0);return e.set(r,i),i}if(ArrayBuffer.isView(r)){if(r instanceof DataView){let a=new DataView(hu(r.buffer,e),r.byteOffset,r.byteLength);return e.set(r,a),a}let i=r,o=hu(i.buffer,e),s=new i.constructor(o,i.byteOffset,i.length);return e.set(r,s),s}let t=Object.getPrototypeOf(r),n=Object.create(t);e.set(r,n);for(let[i,o]of Object.entries(r))Object.defineProperty(n,i,{value:hu(o,e),writable:!0,enumerable:!0,configurable:!0});return n}var vi=b(()=>{});var ce,It=b(()=>{M2();a0();vi();ce=(()=>{let r=F2((i,o)=>({...ht(gT)})),{getState:e,setState:t,subscribe:n}=r;return{getState:e,replaceState:i=>t(i,!0),setState:t,subscribe:n}})()});var zd,Lv,F,Me=b(()=>{zd=class zd{register(e){return zd.loggers.push(e),this}logError(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;zd.loggers.forEach(o=>o.logError(t,n,i))}logWarning(e){let t=e instanceof Error?e.message:e,n=e instanceof Error?e.stack:void 0,i=e instanceof Error?e:void 0;zd.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;zd.loggers.forEach(o=>o.logMessage(t,n,i))}};zd.loggers=[];Lv=zd,F=new Lv});var Ms,N2,l0,uo,lc,cc,_a,vT,Xf,Qf,Zf,uc,Hd,$Re,jd,yT,bT,gu,c0,u0,ORe,NRe,LRe,ir,qr,Vi,d0,vu,Rs,pl,dc,wT,$s,p0,f0,m0,L2,B2,U2,V2,q2,W2,z2,H2,j2,G2,Y2,h0,K2,X2,Q2,Z2,J2,eB,tB,rB,nB,iB,oB,sB,aB,g0,Gd,lB,Tt=b(()=>{Ms="{{value}}",N2="{{name}}",l0=new RegExp(/^-?[0-9]*$/),uo="top",lc="bottom",cc="cursor",_a="ordered",vT=new RegExp(/{{DATE(\+-?[0-9]+)?(?:\|((?:startof|endof):[a-z]+))?}}/i),Xf=new RegExp(/{{DATE:((?:[^}\n\r+|]|\|(?!(?:startof|endof):[a-z]))*)(\+-?[0-9]+)?(?:\|((?:startof|endof):[a-z]+))?}}/i),Qf=new RegExp(/{{TIME}}/i),Zf=new RegExp(/{{TIME:([^}\n\r+]*)}}/i),uc=new RegExp(/{{(?:NAME|VALUE)(?!:)(?:\|[^\n\r}]*)?}}/i),Hd=new RegExp(/{{VALUE:([^\n\r}]*)}}/i),$Re=new RegExp(/{{FIELD:([^\n\r}]*)}}/i),jd="FIELD:",yT=new RegExp(/{{FIELD:([^\n\r}|{]*)(\|[^\n\r}{]*)?}}/i),bT=new RegExp(/{{FILE:([^\n\r{}]*)}}/i),gu=new RegExp(/{{VDATE:([^\n\r},|{]*)(?:,([^\n\r}|{]*))?(?:\|([^\n\r}{]*))?}}/i),c0=new RegExp(/{{LINKCURRENT}}/i),u0=new RegExp(/{{LINKSECTION}}/i),ORe=new RegExp(/{{FILENAMECURRENT}}/i),NRe=new RegExp(/{{FOLDERCURRENT(\|name)?}}/i),LRe=new RegExp(/{{FOLDER(\|name)?}}/i),ir=new RegExp(/\.md$/i),qr=new RegExp(/\.canvas$/i),Vi=new RegExp(/\.base$/i),d0=new RegExp(/\.js$/),vu=new RegExp(/{{MACRO:([^\n\r}]*)}}/i),Rs=new RegExp(/{{TEMPLATE:([^\n\r}]*\.(?:md|canvas|base))}}/i),pl=new RegExp(/{{GLOBAL_VAR:([^\n\r}]*)}}/i),dc=new RegExp(/`{3,}js quickadd([\s\S]*?)`{3,}/),wT=new RegExp(/{{MVALUE}}/i),$s=new RegExp(/{{TITLE}}/i),p0=new RegExp(/{{SELECTED}}/i),f0=new RegExp(/{{CLIPBOARD}}/i),m0=new RegExp(/{{RANDOM:(\d+)}}/i),L2=new RegExp(/\[\[([^\]]*)$/),B2=new RegExp(/#([^ ]*)$/),U2=new RegExp(/{{[D]?[A]?[T]?[E]?[}]?[}]?$/i),V2=new RegExp(/{{[D]?[A]?[T]?[E]?[:]?$|{{DATE:[^\n\r}]*}}$/i),q2=new RegExp(/{{[N]?[A]?[M]?[E]?[}]?[}]?$/i),W2=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[}]?[}]?$/i),z2=new RegExp(/{{[V]?[A]?[L]?[U]?[E]?[:]?$|{{VALUE:[^\n\r}]*}}$/i),H2=new RegExp(/{{[V]?[D]?[A]?[T]?[E]?[:]?$|{{VDATE:[^\n\r}]*}}$/i),j2=new RegExp(/{{[L]?[I]?[N]?[K]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),G2=new RegExp(/^\{\{(?:l(?:i(?:n(?:k(?:s(?:e(?:c(?:t(?:i(?:o(?:n(?:\}\}?)?)?)?)?)?)?)?)?)?)?)?)?$/i),Y2=new RegExp(/{{[F]?[I]?[L]?[E]?[N]?[A]?[M]?[E]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),h0=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[C]?[U]?[R]?[R]?[E]?[N]?[T]?[}]?[}]?$/i),K2=new RegExp(/{{[F]?[O]?[L]?[D]?[E]?[R]?[}]?[}]?$/i),X2=new RegExp(/{{[F]?[I]?[L]?[E]?[:]?$/i),Q2=new RegExp(/{{[F]?[I]?[E]?[L]?[D]?[:]?$/i),Z2=new RegExp(/{{[T]?[E]?[M]?[P]?[L]?[A]?[T]?[E]?[:]?$|{{TEMPLATE:[^\n\r}]*[}]?[}]?$/i),J2=new RegExp(/{{[M]?[A]?[C]?[R]?[O]?[:]?$|{{MACRO:[^\n\r}]*}}$/i),eB=new RegExp(/{{[M]?[V]?[A]?[L]?[U]?[E]?[}]?[}]?/i),tB=new RegExp(/{{[T]?[I]?[T]?[L]?[E]?[}]?[}]?/i),rB=new RegExp(/{{[S]?[E]?[L]?[E]?[C]?[T]?[E]?[D]?[}]?[}]?/i),nB=new RegExp(/{{[C]?[L]?[I]?[P]?[B]?[O]?[A]?[R]?[D]?[}]?[}]?$/i),iB=new RegExp(/{{[R]?[A]?[N]?[D]?[O]?[M]?[:]?$|{{RANDOM:[^\n\r}]*}}$/i),oB=new RegExp(/{{[G]?[L]?[O]?[B]?[A]?[L]?[_]?[V]?[A]?[R]?[:]?$|{{GLOBAL_VAR:[^\n\r}]*}}$/i),sB=new RegExp(/{{[T]?[I]?[M]?[E]?[}]?[}]?/i),aB=new RegExp(/{{[T]?[I]?[M]?[E]?[:]?$|{{TIME:[^\n\r}]*}}$/i),g0="__qa.",Gd=`${g0}captureTargetFilePath`,lB=new RegExp(/\[\[([^\]]*)\]\]/)});var CT=b(()=>{});var Nt,Os=b(()=>{Nt=class extends Error{constructor(e){super(e||"Macro execution aborted"),this.name="MacroAbortError"}}});function tn(){return new St(yu)}var St,yu,Wr=b(()=>{Os();St=class extends Nt{},yu="Input cancelled by user"});function Yd(r,e){if(r instanceof Error){if(!e)return r;let n=new Error(`${e}: ${r.message}`);return n.name=r.name,n.stack=r.stack,n}if(typeof r=="string")return new Error(e?`${e}: ${r}`:r);let t=e?`${e}: ${String(r)}`:String(r);return new Error(t)}function Dt(r){return r instanceof St?!0:typeof r=="string"&&nQ.has(r)}function dB(r){return typeof r=="object"&&r!==null||typeof r=="function"}function sQ(r,e){let t=r;for(let n=0;n<oQ&&dB(t);n++){let i=uB.get(t);if(i!==void 0&&e-i<iQ)return!0;t=t.cause}return!1}function lt(r,e,t="ERROR"){let n=Date.now();if(sQ(r,n))return!1;dB(r)&&uB.set(r,n);let i=Yd(r,e);switch(t){case"ERROR":F.logError(i);break;case"WARNING":F.logWarning(i);break;case"LOG":F.logMessage(i);break;default:F.logError(i)}return!0}function Jf(r,e,t="ERROR"){return Dt(r)?!1:lt(r,e,t)}function pB(r,e,t="ERROR"){try{return r()}catch(n){lt(n,e,t);return}}function em(r,e){let t=n=>{Jf(n,r)};return(...n)=>{try{let i=e(...n);typeof i?.then=="function"&&Promise.resolve(i).catch(t)}catch(i){t(i)}}}var v0,nQ,uB,iQ,oQ,Cr=b(()=>{Me();CT();Wr();v0=100;nQ=new Set(["no input given.","No input given.","cancelled"]),uB=new WeakMap,iQ=1e4,oQ=8});function C0(r,e){try{let t=r.workspace.getActiveViewOfType(bB.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 vQ(r,e){return r!==null&&e!==null&&(r.line!==e.line||r.ch!==e.ch)}function vB(r){return typeof r!="string"?null:[...r.matchAll(gQ)].length}function yQ(r,e){let t=vB(r),n=vB(e);return t!==null&&n!==null&&t>n}function yB(r,e){return vQ(r.cursor,e.cursor)||yQ(r.value,e.value)}async function ET(r,e,t=500){try{let n=r.vault.adapter;if(!("stat"in n)||typeof n.stat!="function")return;let i=await n.stat(e.path);if(!i)return;let o=i.mtime,s=Date.now(),a=30;for(;Date.now()-s<t;){await Vv(a);let l=await n.stat(e.path);if(!l||l.mtime===o)return;o=l.mtime,a=Math.min(a*2,200)}}catch(n){F.logWarning(`waitForFileSettle: fallback due to adapter/stat failure \u2013 ${n.message}`)}}function TT(r){return r.plugins.plugins["templater-obsidian"]}function Kd(r){let e=TT(r);return e||null}function qv(r){return!!Kd(r)?.settings?.trigger_on_file_creation}function Vv(r){return new Promise(e=>window.setTimeout(e,r))}async function T0(r,e,t={}){if(e.extension!=="md"||!qv(r))return;let i=Kd(r)?.templater?.files_with_pending_templates;if(!(i instanceof Set)){await wB(r,e,{timeoutMs:t.timeoutMs??5e3,gracePeriodMs:t.appearTimeoutMs??2500,quietPeriodMs:200});return}let{timeoutMs:o=5e3,appearTimeoutMs:s=2500}=t,a=Date.now();for(;Date.now()-a<s&&!i.has(e.path);)await Vv(50);for(;Date.now()-a<o&&i.has(e.path);)await Vv(50);await ET(r,e,800)}async function wQ(r,e,t){if(!(E0>0)&&t.size===0){if(Uv){await Uv;return}Uv=(async()=>{try{r.workspace.trigger("templater:all-templates-executed"),await e.templater?.functions_generator?.teardown?.()}catch(n){F.logWarning(`withTemplaterFileCreationSuppressed: teardown failed \u2013 ${n.message}`)}})();try{await Uv}finally{Uv=null}}}async function _0(r,e,t){let n=Kd(r),i=n?.templater?.files_with_pending_templates;if(!n||!qv(r)||!(i instanceof Set))return await t();E0++;let o=x0.get(e);o||(o={count:0,hadPathInitially:i.has(e)},x0.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--,E0--,o.count<=0&&(x0.delete(e),o.hadPathInitially||(s&&await Vv(bQ),i.delete(e),await wQ(r,n,i)))}}async function wB(r,e,t={}){let{timeoutMs:n=2e3,quietPeriodMs:i=150,gracePeriodMs:o=800}=t;try{let s=r.vault.adapter;if(!("stat"in s)||typeof s.stat!="function")return;let a=await s.stat(e.path);if(!a)return;let l=a.mtime,c=Date.now(),u=!1,d=c,f=50;for(;Date.now()-d<n;){await Vv(f);let p=await s.stat(e.path);if(!p)return;let m=Date.now();if(p.mtime!==l){u=!0,l=p.mtime,c=m,f=50;continue}if(u){if(m-c>=i)return}else if(m-d>=o)return;f=Math.min(Math.floor(f*1.5),200)}}catch(s){F.logWarning(`waitForFileToStopChanging: fallback due to adapter/stat failure \u2013 ${s.message}`)}}async function CQ(r,e){let t=xT.get(r)??Promise.resolve(),n,i=new Promise(s=>{n=()=>s()}),o=t.catch(()=>{}).then(()=>i);xT.set(r,o),o.finally(()=>{xT.get(r)===o&&xT.delete(r)}).catch(()=>{}),await t.catch(()=>{});try{return await e()}finally{n()}}async function Xd(r,e,t={}){if(e.extension!=="md")return;let n=Kd(r),i=n?.templater,o=i?.overwrite_file_commands;if(!n||!i||typeof o!="function")return;let{skipIfNoTags:s=!0,postWait:a=!0}=t;await CQ(e.path,async()=>{await ET(r,e);let l;try{l=await r.vault.read(e)}catch(c){lt(c,`overwriteTemplaterOnce: failed to read ${e.path} before render`);return}if(!(s&&!l.includes("<%")))try{await o.call(i,e),a&&await ET(r,e,800)}catch(c){try{await r.vault.modify(e,l)}catch(u){F.logWarning(`Failed to rollback ${e.path} after Templater error: ${u.message}`)}lt(c,`Templater failed on ${e.path}. Rolled back to pre-render state.`)}})}async function pc(r,e,t){if(t.extension!=="md")return e;let n=Kd(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 wu(r,e){if(e.extension!=="md"||r.workspace.getActiveFile()?.path!==e.path)return!1;let t=Kd(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=C0(r,e);if(typeof o=="function")try{return await o.call(i,e,!0),yB(s,C0(r,e))}catch(a){F.logWarning(`jumpToNextTemplaterCursorIfPossible: API failed \u2013 ${a.message}`)}try{return!r.commands.executeCommandById?.("templater-obsidian:jump-to-next-cursor-location")?!1:yB(s,C0(r,e))}catch{}return!1}var bB,gQ,x0,E0,Uv,bQ,xT,CB=b(()=>{bB=require("obsidian");Me();Cr();gQ=/<%\s*tp\.file\.cursor\([0-9]*\)\s*%>/g;x0=new Map,E0=0,Uv=null,bQ=350;xT=new Map});function On(r){let e=r.workspace.getActiveViewOfType(xB.MarkdownView);return e?.editor?e:null}var xB,Cu=b(()=>{xB=require("obsidian")});function rm(r){return xQ.has(r)}function Zd(r){return r==="inFrontmatter"}function _T(r){return EQ.has(r)}function TQ(r,e,t){return r==="embed"&&t.type==="activeFile"&&rm(e)?"embed":"link"}function _Q(r,e,t,n){return r==="selection"&&t.type==="activeFile"&&_T(e)&&n==="link"?"selection":"none"}function AQ(r){return r?.type==="specifiedFile"?{type:"specifiedFile",path:typeof r.path=="string"?r.path.trim():""}:{type:"activeFile"}}function kQ(r){return typeof r=="object"&&r!==null&&"enabled"in r&&"placement"in r}function xu(r){if(kQ(r)){let e=r.placement??"replaceSelection",t=AQ(r.destination),n=TQ(r.linkType,e,t);return{enabled:r.enabled,placement:e,requireActiveFile:r.requireActiveFile??!0,linkType:n,displayText:_Q(r.displayText,e,t,n),destination:t,frontmatterProperty:r.frontmatterProperty,frontmatterHandling:Zd(e)?r.frontmatterHandling??Qd:r.frontmatterHandling}}return{enabled:r,placement:"replaceSelection",requireActiveFile:!!r,linkType:"link",displayText:"none",destination:{type:"activeFile"}}}var Qd,xQ,EQ,Jd=b(()=>{Qd="alwaysAppend",xQ=new Set(["replaceSelection","afterSelection","endOfLine","newLine"]);EQ=new Set(["replaceSelection","afterSelection"])});function SQ(r){return r.vault.getConfig?.("useMarkdownLinks")===!0}function DQ(r,e){let t=e.replace(/\s+/g,n=>/[\r\n]/.test(n)?" ":n).trim();if(t){if(SQ(r))return t.replace(/\\/g,"\\\\").replace(/\[/g,"\\[").replace(/\]/g,"\\]");if(!(t.includes("]]")||t.includes("[[")||t.endsWith("]")))return t}}function IQ(r){return`[[${r.path.replace(/\.md$/i,"")}]]`}function AT(r,e,t={}){let n=t.sourcePath??"";if(t.linkType==="embed"&&(!t.placement||rm(t.placement)))return`![[${r.metadataCache.fileToLinktext(e,n)}]]`;let o=t.alias===void 0?void 0:DQ(r,t.alias);return o===void 0?r.fileManager.generateMarkdownLink(e,n):r.fileManager.generateMarkdownLink(e,n,void 0,o)}function A0(r){let e=r.trim().replace(/^\/+/,"");return e?/\.md$/i.test(e)?e:`${e}.md`:""}function zv(r,e){if(e.type!=="specifiedFile")return null;let t=A0(e.path);if(!t)return null;let n=r.vault.getAbstractFileByPath(t);return!(n instanceof Wv.TFile)||n.extension!=="md"?null:n}function PQ(r,e){return r.length===0?e:r.endsWith(`
|
||
`)?`${r}${e}`:`${r}
|
||
${e}`}async function kT(r,e,t){let n=t.destination;if(n?.type!=="specifiedFile")return!1;let i=zv(r,n);if(!i)throw new Error(`Append link target file not found or is not a Markdown file: ${n.path}`);let o=AT(r,e,{sourcePath:i.path,linkType:"link"});return await r.vault.process(i,s=>PQ(s,o)),!0}async function FQ(r){let e=window.navigator?.clipboard;if(!e?.writeText)return F.logMessage("QuickAdd: Clipboard API is unavailable."),!1;try{return await e.writeText(r),!0}catch(t){return F.logMessage(`QuickAdd: Could not copy link to clipboard: ${t instanceof Error?t.message:String(t)}`),!1}}async function ST(r){let e=IQ(r);return await FQ(e)?(new Wv.Notice(`Copied link to '${r.basename}' to clipboard.`,EB),!0):(new Wv.Notice(`Created '${r.basename}', but QuickAdd could not copy its link to the clipboard.`,EB),!1)}var Wv,EB,Hv=b(()=>{Wv=require("obsidian");Me();Jd();EB=4e3});function ts(r){if(r.nodeType===Node.DOCUMENT_NODE)return r;let e=r.ownerDocument;if(!e)throw new Error("Unable to resolve owner document for DOM node.");return e}function ep(r){let e=ts(r).defaultView;if(!e)throw new Error("Unable to resolve owner window for DOM node.");return e}function zr(r,e){return ts(r).createElement(e)}function jv(r,e){return ts(r).createTextNode(e)}var fc=b(()=>{});function DT(r){for(let e of r.workspace.getLeavesOfType("markdown")){let t=e.view;if(!(!t.containerEl||!t.file||t.file.extension!=="md"))try{let n=ts(t.containerEl).activeElement;if(!n||!t.containerEl.contains(n)||!n.closest(".metadata-property-value")||n.matches(MQ))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 RQ(r,e,t){let n=e.trim();if(!n)throw new Error("Cannot append link to an empty frontmatter property key.");let i=kB(r,n),o=r[i];if(Array.isArray(o)){o.push(t);return}if(o==null||o===""){r[i]=t;return}if(typeof o=="string"){r[i]=`${o} ${t}`;return}throw new Error(`Cannot append link to frontmatter property '${i}' because it contains a ${typeof o} value.`)}function AB(r,e,t,n=Qd){let i=e.trim();if(!i)throw new Error("Cannot append link to an empty frontmatter property key.");let o=kB(r,i),s=r[o];if(Array.isArray(s)){s.push(t);return}if(s===null||s===""){r[o]=[t];return}if(s===void 0){if(n==="error")throw new Error(`Cannot append link to frontmatter property '${o}' because it does not exist.`);r[o]=[t];return}if(typeof s=="object")throw new Error(`Cannot append link to frontmatter property '${o}' because it contains an object value.`);if(n!=="alwaysAppend")throw new Error(`Cannot append link to frontmatter property '${o}' because it is not a list and the link-handling mode is '${TB[n]}'. Choose '${TB.alwaysAppend}' to convert it into a list and append.`);r[o]=[s,t]}function kB(r,e){let t=_B(e),n=Object.keys(r).filter(i=>_B(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 _B(r){return r.trim().toLowerCase()}async function IT(r,e,t){let n=r.fileManager.generateMarkdownLink(t,e.file.path);try{return await r.fileManager.processFrontMatter(e.file,i=>{RQ(i,e.key,n)}),!0}catch(i){return F.logError(`QuickAdd: created the file but could not append the link to frontmatter property '${e.key}' in '${e.file.path}': ${i instanceof Error?i.message:String(i)}`),!1}}var TB,MQ,nm=b(()=>{Me();Jd();fc();TB={alwaysAppend:"Create or convert",createProperty:"Create if missing",error:"Require list"},MQ=['input[type="number"]','input[type="date"]','input[type="datetime-local"]','input[type="time"]','input[type="month"]','input[type="checkbox"]'].join(", ")});function Gv(r,e){let t=On(r);return t?.file?.path===e.path?t:null}function k0(r,e){try{let t=On(e);return t?(t.editor.replaceSelection(r),!0):(F.logError(`unable to append '${r}' to current line.`),!1)}catch{return F.logError(`unable to append '${r}' to current line.`),!1}}function S0(r,e,t){try{let n=On(t);if(!n)return F.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 F.logError(`unable to insert '${r}' on new line ${e}.`),!1}}function D0(r,e){return S0(r,"above",e)}function I0(r,e){return S0(r,"below",e)}function $Q(r,e,t,n){let i=l=>r.posToOffset(l),o=e.map(l=>{let[c,u]=i(l.anchor)<=i(l.head)?[l.anchor,l.head]:[l.head,l.anchor];return{from:c,to:u,text:n(r.getRange(c,u))}}).sort((l,c)=>i(l.from)-i(c.from)),s=o.map(({from:l,to:c,text:u})=>t==="replaceSelection"?{from:l,to:c,text:u}:{from:c,text:u}),a=[];if(t==="replaceSelection"){let l=0;for(let{from:c,to:u,text:d}of o)a.push(i(c)+l+d.length),l+=d.length-(i(u)-i(c))}r.transaction({changes:s}),t==="replaceSelection"&&r.setSelections(a.map(l=>({anchor:r.offsetToPos(l)})))}async function SB(r,e,t="replaceSelection",n={}){let{requireActiveView:i=!0,frontmatterProperty:o,frontmatterHandling:s=Qd,textForSelection:a}=n,l=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!l){let p="Cannot append link because no active Markdown view is available.";if(i)throw new Error(p);F.logMessage(p);return}if(t==="inFrontmatter"){let p=l.file;if(!p)throw new Error("Cannot append link because the active Markdown view has no file.");await r.fileManager.processFrontMatter(p,m=>{AB(m,o??"",e,s)});return}let c=l.editor;if(!c){let p="Cannot append link because the active Markdown view has no editor.";if(i)throw new Error(p);F.logMessage(p);return}let u=c.listSelections().map(p=>({anchor:{...p.anchor},head:{...p.head}}));if(a&&u.length>0&&(t==="replaceSelection"||t==="afterSelection")){$Q(c,u,t,a);return}if(t==="replaceSelection"){c.replaceSelection(e);return}let d=({line:p,ch:m})=>c.posToOffset({line:p,ch:m}),f=u.sort((p,m)=>d(m.head)-d(p.head));for(let p of f){let m=d(p.anchor)>d(p.head)?p.anchor:p.head;switch(t){case"afterSelection":{c.replaceRange(e,m);break}case"endOfLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length};c.replaceRange(e,g);break}case"newLine":{let v=c.getLine(m.line),g={line:m.line,ch:v.length},w=v.length===0?"":`
|
||
`;c.replaceRange(w+e,g);break}}}}async function tp(r,e,t){if(!t?.enabled)return!1;let n=xu(t),i=r.workspace.getActiveViewOfType(PT.MarkdownView),o=n.placement!=="inFrontmatter";if(!i||!i.file||o&&!i.editor){if(t.requireActiveFile)throw new Error("Cannot append link because no active Markdown view is available.");return!1}let s=i.file.path,a=AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement}),l=n.displayText==="selection"?c=>AT(r,e,{sourcePath:s,linkType:n.linkType,placement:n.placement,alias:c}):void 0;return await SB(r,a,n.placement,{requireActiveView:!1,frontmatterProperty:n.frontmatterProperty,frontmatterHandling:n.frontmatterHandling,textForSelection:l}),!0}function P0(r,e,t,n){try{if(e.extension!=="md"||!Number.isSafeInteger(t)||t<0||t>n.length)return!1;let i=r.workspace.getActiveViewOfType(PT.MarkdownView);if(!i||i.file?.path!==e.path||i.getMode()==="preview")return!1;let o=i.editor;return!o||o.getValue()!==n?!1:(o.setCursor(o.offsetToPos(t)),!0)}catch{return F.logMessage(`Unable to place cursor after capture in '${e.path}'.`),!1}}var PT,DB=b(()=>{PT=require("obsidian");Cu();Me();Jd();Hv();nm()});function FT(r){return ir.test(r)||qr.test(r)||Vi.test(r)}function po(r,e){let t=e.trim().replace(/^\/+/,"");if(!t)return null;let n=FT(t)?t:`${t}.md`,i=r.vault.getAbstractFileByPath(n);return i instanceof IB.TFile?i:null}function Wi(r){if(!Array.isArray(r))return[];let e=new Set,t=[];for(let n of r){if(typeof n!="string")continue;let i=n.trim().replace(/^\/+/,"").replace(/\/+$/,"");!i||e.has(i)||(e.add(i),t.push(i))}return t}function F0(r,e){return e.length===0?!0:e.some(t=>r===t||r.startsWith(`${t}/`))}var IB,MT=b(()=>{IB=require("obsidian");Tt()});function FB(r){if(!r)return!1;let e=r,t=e.getViewState?.();return!!e.pinned||!!t?.pinned||!!t?.state?.pinned}function Yv(r){let e=r.workspace;return(e.rootSplit?e.getMostRecentLeaf?.(e.rootSplit):null)??e.getMostRecentLeaf?.()??null}function OQ(r){let e=[];return r.workspace.iterateRootLeaves(t=>{e.includes(t)||e.push(t)}),e}function PB(r){return r.parent?.id??r.parent??null}function NQ(r,e){let t=PB(e),n=r.filter(s=>s===e||FB(s)?!1:t===null||PB(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 LQ(r){return r instanceof im.TFile?!0:typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"&&"extension"in r&&typeof r.extension=="string"}function BQ(r,e,t,n){if(n&&(e==="tab"||e==="reuse")&&FB(n))return NQ(OQ(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 mc(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(!LQ(c)){let f=typeof e=="string"?e:e.path;throw new Error(`File not found: ${f}`)}let u=l??Yv(r),d=BQ(r,n,i,u);if(!d)throw new Error("Could not obtain a workspace leaf.");if(await d.openFile(c),o&&o!=="default"&&!(typeof o=="object"&&o.mode==="default")){let f=d.getViewState(),p={...f.state??{}};o==="preview"||typeof o=="object"&&o.mode==="preview"?(p.mode="preview",delete p.source):o==="source"?(p.mode="source",p.source=!0):o==="live"||o==="live-preview"?(p.mode="source",p.source=!1):typeof o=="object"&&o.mode==="source"&&(p.mode="source",p.source=o.source),await d.setViewState({...f,state:{...p,...a}})}return s&&r.workspace.setActiveLeaf(d,{focus:!0}),d}function M0(r){return(0,im.normalizePath)(r).replace(/\/{2,}/g,"/").replace(/^\/+/,"")}function MB(r,e){return M0(r)===M0(e)}function rp(r,e,t=!0){let n;return r.workspace.iterateRootLeaves(i=>{let o=i.view;if(o instanceof im.FileView&&o.file&&(o.file===e||MB(e.path,o.file.path))){n=i;return}}),n!==void 0?(t&&r.workspace.setActiveLeaf(n,{focus:!0}),n):null}var im,RB=b(()=>{im=require("obsidian")});function hc(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=UQ.exec(c);if(n){if(d&&d[1].length>=i&&d[2].trim().length===0)return $B(r.slice(o,e),s)}else if(d){let f=d[2].trim().split(/\s+/)[0]?.toLowerCase();(f==="js"||f==="javascript")&&(n=!0,i=d[1].length,o=u,s=t+1)}if(e=u,t++,a===-1)break}return n?$B(r.slice(o),s):{code:null,error:VQ}}function $B(r,e){return r.trim().length===0?{code:"",error:qQ}:{code:`
|
||
`.repeat(e)+r}}var UQ,VQ,qQ,Kv=b(()=>{UQ=/^ {0,3}(`{3,})(.*)$/,VQ="No ```js (or ```javascript) code block found in the note.",qQ="The ```js code block is empty."});function OB(r){return r instanceof RT}function zQ(r){return r.charCodeAt(0)===65279?r.slice(1):r}function HQ(r){return zQ(r).trimStart().slice(0,WQ).toLowerCase()}function jQ(r){return/^<(?:!doctype\s+html|html\b|head\b|body\b|script\b|meta\b|title\b|div\b)/.test(HQ(r))}function R0(r,e){let t=new RT(r);throw e.reportLoadErrors!==!1&<(t),t}function GQ(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 YQ(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 KQ(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 XQ(r){return NB(r)?(r instanceof Error?r.message:String(r)).match(/Cannot find module ['"]([^'"]+)['"]/)?.[1]:void 0}function NB(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 QQ(r){return r!==null&&typeof r=="object"}function ZQ(r){return typeof r.entry=="function"?!0:Object.entries(r).some(([e,t])=>e!=="settings"&&e!=="quickadd"&&typeof t=="function")}function JQ(r){return typeof r=="function"?!0:QQ(r)?ZQ(r):!1}function np(r){let e=r.split("::").map(t=>t.trim()).filter(Boolean);return{basename:e[0],memberAccess:e.slice(1)}}function OT(r){let e=r.path??r.id;if(e===void 0)return;let{memberAccess:t}=np(r.name??"");return t&&t.length>0?`${e}::${t.join("::")}`:e}async function Aa(r,e,t={}){let n=e.vault.getAbstractFileByPath(r.path);if(!n){F.logError(`failed to load file ${r.path}.`);return}if(n instanceof $T.TFile){let i=m=>window.require&&window.require(m),o={},s={exports:o},a=await e.vault.read(n),l=a;if(ir.test(n.path)){let{code:m,error:v}=hc(a);if(m===null||m.length===0){t.reportLoadErrors!==!1&&new $T.Notice(`QuickAdd: ${v} (${r.path})`);return}l=m}jQ(l)&&R0(GQ(r.path),t);try{new Function("require","module","exports",l)(i,s,o)}catch(m){throw NB(m)&&R0(KQ(r.path,XQ(m)),t),m}let c=o.default||s.exports;if(!c)return;let u=c,d=!!o.default,{memberAccess:f}=np(r.name),p=!!(f&&f.length>0);if(f&&f.length>0){let m;for(;m=f.shift();)u=u[m]}return d&&!p&&!JQ(u)&&R0(YQ(r.path),t),u}}var $T,WQ,RT,NT=b(()=>{$T=require("obsidian");Tt();Me();Kv();Cr();WQ=1024,RT=class extends Error{constructor(e){super(e),this.name="UserScriptLoadError"}}});function gc(r){if(r==null||typeof r!="string"&&typeof r!="number"&&typeof r!="boolean")return"";let e=String(r).trim();return e.startsWith("#")?e.substring(1).trim():e}function Eu(r){return r==null?[]:(Array.isArray(r)?r:typeof r=="string"?r.split(/,|\s+/):[r]).map(gc).filter(Boolean)}var LT=b(()=>{});var zi,ip=b(()=>{LT();zi=class{static filterFiles(e,t,n){let i=e;return i=this.applyInclusionFilters(i,t,n),i=this.applyExclusionFilters(i,t,n),i}static applyInclusionFilters(e,t,n){let i=!1,o=e,s=this.getIncludeFolders(t);return s.length>0&&(i=!0,o=o.filter(a=>s.some(l=>this.matchesFolder(a,l)))),t.tags&&t.tags.length>0&&(i=!0,o=o.filter(a=>this.matchesAllTags(a,t.tags??[],n))),i?o:e}static applyExclusionFilters(e,t,n){return e.filter(i=>!(t.excludeFolders&&t.excludeFolders.length>0&&t.excludeFolders.some(o=>this.matchesFolder(i,o))||t.excludeTags&&t.excludeTags.length>0&&this.matchesAnyTag(i,t.excludeTags,n)||t.excludeFiles&&t.excludeFiles.length>0&&t.excludeFiles.some(o=>this.matchesFile(i,o))))}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(e,t){let n=this.normalizePath(t),i=this.normalizePath(e.path);return i.startsWith(n+"/")||i.substring(0,i.lastIndexOf("/"))===n}static matchesAllTags(e,t,n){return this.matchesTags(e,t,n,"all")}static matchesAnyTag(e,t,n){return this.matchesTags(e,t,n,"any")}static matchesTags(e,t,n,i){let o=n(e);if(!o)return!1;let s=this.getAllTags(o),a=t.map(c=>this.normalizeTag(c)).filter(Boolean),l=c=>s.some(u=>u===c||u.startsWith(c+"/"));return i==="all"?a.every(l):a.some(l)}static matchesFile(e,t){return e.name===t||e.path===t}static getAllTags(e){let t=[];return e.frontmatter?.tags&&t.push(...Eu(e.frontmatter.tags)),e.frontmatter?.tag&&t.push(...Eu(e.frontmatter.tag)),e.tags&&t.push(...e.tags.map(n=>gc(n.tag))),t.filter(Boolean)}static normalizeTag(e){return gc(e)}static normalizePath(e){return e.replace(/^\/+|\/+$/g,"")}}});function Ns(r){return r.vault.getAllLoadedFiles().filter(e=>e instanceof $0.TFolder).map(e=>e.path)}function om(r,e){let t=r.vault.getAbstractFileByPath(e);return!!t&&t instanceof $0.TFolder}function rs(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 eZ(r){let e=r.frontmatter;if(!e)return[];let t=Object.entries(e);if(!t.length)return[];let n=t.filter(([o,s])=>{let a=o.toLowerCase();return a==="tags"||a==="tag"});return n?n.flatMap(([,o])=>Eu(o)).filter(o=>!!o):[]}function tZ(r,e){let t=r.metadataCache.getFileCache(e);if(!t)return[];let n=[];return t.frontmatter&&n.push(...eZ(t)),t.tags&&Array.isArray(t.tags)&&n.push(...t.tags.map(i=>gc(i.tag))),n}function Xv(r,e){let t=e.replace(/^#/,"");return r.vault.getMarkdownFiles().filter(n=>tZ(r,n).includes(t))}function sm(r,e){return zi.filterFiles(r.vault.getMarkdownFiles(),e,t=>r.metadataCache.getFileCache(t))}function rZ(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 am(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:rZ(c[1],t):!1});return n&&(n.folder||n.tags?.length||n.excludeFolders?.length||n.excludeTags?.length||n.excludeFiles?.length)&&(o=zi.filterFiles(o,n,a=>r.metadataCache.getFileCache(a))),o}var $0,LB=b(()=>{$0=require("obsidian");ip();LT()});function BB(r,e){return r.commands.findCommand(e)}function O0(r,e){BB(r,e)&&(delete r.commands.commands[e],delete r.commands.editorCommands[e])}var UB=b(()=>{});function Ls(r){return r.split("|")}function VB(r){return r.startsWith("|")?r.slice(1):r}function fo(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 Tu(r){if(!r)return!0;let e=r.trim().toLowerCase();return!["false","no","0","off"].includes(e)}function ka(r,e){let t=!1;return{remaining:r.filter(i=>i.trim().toLowerCase()===e?(t=!0,!1):!0),found:t}}var op=b(()=>{});function BT(r){let e=r.trim().toLowerCase(),t=nZ[e];if(!t)throw new Error(`Unknown date unit "${r.trim()}". Valid units: ${iZ}.`);return t}function N0(r){let e=fo(r);return e?e.key==="startof"?{boundary:"start",unit:BT(e.value)}:e.key==="endof"?{boundary:"end",unit:BT(e.value)}:null:null}function lm(r,e){return e?e.boundary==="start"?r.startOf(e.unit):r.endOf(e.unit):r}var nZ,iZ,Qv=b(()=>{op();nZ={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"},iZ="year, quarter, month, week, isoweek, day"});function Bs(r){let e;return r?.offset!==null&&r?.offset!==void 0&&typeof r.offset=="number"&&(e=window.moment.duration(r.offset,"days")),lm(window.moment().add(e),r?.snap).format(r?.format??"YYYY-MM-DD")}var qB=b(()=>{Qv()});var qt=b(()=>{CB();DB();MT();RB();NT();LB();UB();qB()});var Hr,Nn,pn,rn,UT,Au,vc,sp,WB,VT,cm,zB,L0,qT,oZ,sZ,aZ,lZ,cZ,uZ,dZ,pZ,fZ,HB,ns=b(()=>{Hr="top",Nn="bottom",pn="right",rn="left",UT="auto",Au=[Hr,Nn,pn,rn],vc="start",sp="end",WB="clippingParents",VT="viewport",cm="popper",zB="reference",L0=Au.reduce(function(r,e){return r.concat([e+"-"+vc,e+"-"+sp])},[]),qT=[].concat(Au,[UT]).reduce(function(r,e){return r.concat([e,e+"-"+vc,e+"-"+sp])},[]),oZ="beforeRead",sZ="read",aZ="afterRead",lZ="beforeMain",cZ="main",uZ="afterMain",dZ="beforeWrite",pZ="write",fZ="afterWrite",HB=[oZ,sZ,aZ,lZ,cZ,uZ,dZ,pZ,fZ]});function ei(r){return r?(r.nodeName||"").toLowerCase():null}var ku=b(()=>{});function Mr(r){if(r==null)return window;if(r.toString()!=="[object Window]"){var e=r.ownerDocument;return e&&e.defaultView||window}return r}var Sa=b(()=>{});function Us(r){var e=Mr(r).Element;return r instanceof e||r instanceof Element}function Ln(r){var e=Mr(r).HTMLElement;return r instanceof e||r instanceof HTMLElement}function um(r){if(typeof ShadowRoot>"u")return!1;var e=Mr(r).ShadowRoot;return r instanceof e||r instanceof ShadowRoot}var is=b(()=>{Sa()});function mZ(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];!Ln(o)||!ei(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 hZ(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},{});!Ln(i)||!ei(i)||(Object.assign(i.style,a),Object.keys(o).forEach(function(l){i.removeAttribute(l)}))})}}var jB,GB=b(()=>{ku();is();jB={name:"applyStyles",enabled:!0,phase:"write",fn:mZ,effect:hZ,requires:["computeStyles"]}});function ti(r){return r.split("-")[0]}var Su=b(()=>{});var Da,ap,yc,Du=b(()=>{Da=Math.max,ap=Math.min,yc=Math.round});function dm(){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 B0=b(()=>{});function Zv(){return!/^((?!chrome|android).)*safari/i.test(dm())}var U0=b(()=>{B0()});function Vs(r,e,t){e===void 0&&(e=!1),t===void 0&&(t=!1);var n=r.getBoundingClientRect(),i=1,o=1;e&&Ln(r)&&(i=r.offsetWidth>0&&yc(n.width)/r.offsetWidth||1,o=r.offsetHeight>0&&yc(n.height)/r.offsetHeight||1);var s=Us(r)?Mr(r):window,a=s.visualViewport,l=!Zv()&&t,c=(n.left+(l&&a?a.offsetLeft:0))/i,u=(n.top+(l&&a?a.offsetTop:0))/o,d=n.width/i,f=n.height/o;return{width:d,height:f,top:u,right:c+d,bottom:u+f,left:c,x:c,y:u}}var pm=b(()=>{is();Du();Sa();U0()});function lp(r){var e=Vs(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 WT=b(()=>{pm()});function Jv(r,e){var t=e.getRootNode&&e.getRootNode();if(r.contains(e))return!0;if(t&&um(t)){var n=e;do{if(n&&r.isSameNode(n))return!0;n=n.parentNode||n.host}while(n)}return!1}var V0=b(()=>{is()});function mo(r){return Mr(r).getComputedStyle(r)}var fm=b(()=>{Sa()});function q0(r){return["table","td","th"].indexOf(ei(r))>=0}var YB=b(()=>{ku()});function yi(r){return((Us(r)?r.ownerDocument:r.document)||window.document).documentElement}var bc=b(()=>{is()});function wc(r){return ei(r)==="html"?r:r.assignedSlot||r.parentNode||(um(r)?r.host:null)||yi(r)}var ey=b(()=>{ku();bc();is()});function KB(r){return!Ln(r)||mo(r).position==="fixed"?null:r.offsetParent}function gZ(r){var e=/firefox/i.test(dm()),t=/Trident/i.test(dm());if(t&&Ln(r)){var n=mo(r);if(n.position==="fixed")return null}var i=wc(r);for(um(i)&&(i=i.host);Ln(i)&&["html","body"].indexOf(ei(i))<0;){var o=mo(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 Ia(r){for(var e=Mr(r),t=KB(r);t&&q0(t)&&mo(t).position==="static";)t=KB(t);return t&&(ei(t)==="html"||ei(t)==="body"&&mo(t).position==="static")?e:t||gZ(r)||e}var mm=b(()=>{Sa();ku();fm();is();YB();ey();B0()});function cp(r){return["top","bottom"].indexOf(r)>=0?"x":"y"}var zT=b(()=>{});function up(r,e,t){return Da(r,ap(e,t))}function XB(r,e,t){var n=up(r,e,t);return n>t?t:n}var W0=b(()=>{Du()});function ty(){return{top:0,right:0,bottom:0,left:0}}var z0=b(()=>{});function ry(r){return Object.assign({},ty(),r)}var H0=b(()=>{z0()});function ny(r,e){return e.reduce(function(t,n){return t[n]=r,t},{})}var j0=b(()=>{});function yZ(r){var e,t=r.state,n=r.name,i=r.options,o=t.elements.arrow,s=t.modifiersData.popperOffsets,a=ti(t.placement),l=cp(a),c=[rn,pn].indexOf(a)>=0,u=c?"height":"width";if(!(!o||!s)){var d=vZ(i.padding,t),f=lp(o),p=l==="y"?Hr:rn,m=l==="y"?Nn:pn,v=t.rects.reference[u]+t.rects.reference[l]-s[l]-t.rects.popper[u],g=s[l]-t.rects.reference[l],y=Ia(o),w=y?l==="y"?y.clientHeight||0:y.clientWidth||0:0,x=v/2-g/2,C=d[p],_=w-f[u]-d[m],E=w/2-f[u]/2+x,D=up(C,E,_),P=l;t.modifiersData[n]=(e={},e[P]=D,e.centerOffset=D-E,e)}}function bZ(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)||Jv(e.elements.popper,i)&&(e.elements.arrow=i))}var vZ,QB,ZB=b(()=>{Su();WT();V0();mm();zT();W0();H0();j0();ns();vZ=function(e,t){return e=typeof e=="function"?e(Object.assign({},t.rects,{placement:t.placement})):e,ry(typeof e!="number"?e:ny(e,Au))};QB={name:"arrow",enabled:!0,phase:"main",fn:yZ,effect:bZ,requires:["popperOffsets"],requiresIfExists:["preventOverflow"]}});function qs(r){return r.split("-")[1]}var hm=b(()=>{});function CZ(r,e){var t=r.x,n=r.y,i=e.devicePixelRatio||1;return{x:yc(t*i)/i||0,y:yc(n*i)/i||0}}function JB(r){var e,t=r.popper,n=r.popperRect,i=r.placement,o=r.variation,s=r.offsets,a=r.position,l=r.gpuAcceleration,c=r.adaptive,u=r.roundOffsets,d=r.isFixed,f=s.x,p=f===void 0?0:f,m=s.y,v=m===void 0?0:m,g=typeof u=="function"?u({x:p,y:v}):{x:p,y:v};p=g.x,v=g.y;var y=s.hasOwnProperty("x"),w=s.hasOwnProperty("y"),x=rn,C=Hr,_=window;if(c){var E=Ia(t),D="clientHeight",P="clientWidth";if(E===Mr(t)&&(E=yi(t),mo(E).position!=="static"&&a==="absolute"&&(D="scrollHeight",P="scrollWidth")),E=E,i===Hr||(i===rn||i===pn)&&o===sp){C=Nn;var V=d&&E===_&&_.visualViewport?_.visualViewport.height:E[D];v-=V-n.height,v*=l?1:-1}if(i===rn||(i===Hr||i===Nn)&&o===sp){x=pn;var j=d&&E===_&&_.visualViewport?_.visualViewport.width:E[P];p-=j-n.width,p*=l?1:-1}}var oe=Object.assign({position:a},c&&wZ),se=u===!0?CZ({x:p,y:v},Mr(t)):{x:p,y:v};if(p=se.x,v=se.y,l){var M;return Object.assign({},oe,(M={},M[C]=w?"0":"",M[x]=y?"0":"",M.transform=(_.devicePixelRatio||1)<=1?"translate("+p+"px, "+v+"px)":"translate3d("+p+"px, "+v+"px, 0)",M))}return Object.assign({},oe,(e={},e[C]=w?v+"px":"",e[x]=y?p+"px":"",e.transform="",e))}function xZ(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:ti(e.placement),variation:qs(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,JB(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,JB(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 wZ,eU,tU=b(()=>{ns();mm();Sa();bc();fm();Su();hm();Du();wZ={top:"auto",right:"auto",bottom:"auto",left:"auto"};eU={name:"computeStyles",enabled:!0,phase:"beforeWrite",fn:xZ,data:{}}});function EZ(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=Mr(e.elements.popper),c=[].concat(e.scrollParents.reference,e.scrollParents.popper);return o&&c.forEach(function(u){u.addEventListener("scroll",t.update,HT)}),a&&l.addEventListener("resize",t.update,HT),function(){o&&c.forEach(function(u){u.removeEventListener("scroll",t.update,HT)}),a&&l.removeEventListener("resize",t.update,HT)}}var HT,rU,nU=b(()=>{Sa();HT={passive:!0};rU={name:"eventListeners",enabled:!0,phase:"write",fn:function(){},effect:EZ,data:{}}});function gm(r){return r.replace(/left|right|bottom|top/g,function(e){return TZ[e]})}var TZ,iU=b(()=>{TZ={left:"right",right:"left",bottom:"top",top:"bottom"}});function jT(r){return r.replace(/start|end/g,function(e){return _Z[e]})}var _Z,oU=b(()=>{_Z={start:"end",end:"start"}});function dp(r){var e=Mr(r),t=e.pageXOffset,n=e.pageYOffset;return{scrollLeft:t,scrollTop:n}}var GT=b(()=>{Sa()});function pp(r){return Vs(yi(r)).left+dp(r).scrollLeft}var YT=b(()=>{pm();bc();GT()});function G0(r,e){var t=Mr(r),n=yi(r),i=t.visualViewport,o=n.clientWidth,s=n.clientHeight,a=0,l=0;if(i){o=i.width,s=i.height;var c=Zv();(c||!c&&e==="fixed")&&(a=i.offsetLeft,l=i.offsetTop)}return{width:o,height:s,x:a+pp(r),y:l}}var sU=b(()=>{Sa();bc();YT();U0()});function Y0(r){var e,t=yi(r),n=dp(r),i=(e=r.ownerDocument)==null?void 0:e.body,o=Da(t.scrollWidth,t.clientWidth,i?i.scrollWidth:0,i?i.clientWidth:0),s=Da(t.scrollHeight,t.clientHeight,i?i.scrollHeight:0,i?i.clientHeight:0),a=-n.scrollLeft+pp(r),l=-n.scrollTop;return mo(i||t).direction==="rtl"&&(a+=Da(t.clientWidth,i?i.clientWidth:0)-o),{width:o,height:s,x:a,y:l}}var aU=b(()=>{bc();fm();YT();GT();Du()});function fp(r){var e=mo(r),t=e.overflow,n=e.overflowX,i=e.overflowY;return/auto|scroll|overlay|hidden/.test(t+i+n)}var KT=b(()=>{fm()});function XT(r){return["html","body","#document"].indexOf(ei(r))>=0?r.ownerDocument.body:Ln(r)&&fp(r)?r:XT(wc(r))}var lU=b(()=>{ey();KT();ku();is()});function Iu(r,e){var t;e===void 0&&(e=[]);var n=XT(r),i=n===((t=r.ownerDocument)==null?void 0:t.body),o=Mr(n),s=i?[o].concat(o.visualViewport||[],fp(n)?n:[]):n,a=e.concat(s);return i?a:a.concat(Iu(wc(s)))}var K0=b(()=>{lU();ey();Sa();KT()});function vm(r){return Object.assign({},r,{left:r.x,top:r.y,right:r.x+r.width,bottom:r.y+r.height})}var X0=b(()=>{});function AZ(r,e){var t=Vs(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 cU(r,e,t){return e===VT?vm(G0(r,t)):Us(e)?AZ(e,t):vm(Y0(yi(r)))}function kZ(r){var e=Iu(wc(r)),t=["absolute","fixed"].indexOf(mo(r).position)>=0,n=t&&Ln(r)?Ia(r):r;return Us(n)?e.filter(function(i){return Us(i)&&Jv(i,n)&&ei(i)!=="body"}):[]}function Q0(r,e,t,n){var i=e==="clippingParents"?kZ(r):[].concat(e),o=[].concat(i,[t]),s=o[0],a=o.reduce(function(l,c){var u=cU(r,c,n);return l.top=Da(u.top,l.top),l.right=ap(u.right,l.right),l.bottom=ap(u.bottom,l.bottom),l.left=Da(u.left,l.left),l},cU(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 uU=b(()=>{ns();sU();aU();K0();mm();bc();fm();is();pm();ey();V0();ku();X0();Du()});function iy(r){var e=r.reference,t=r.element,n=r.placement,i=n?ti(n):null,o=n?qs(n):null,s=e.x+e.width/2-t.width/2,a=e.y+e.height/2-t.height/2,l;switch(i){case Hr:l={x:s,y:e.y-t.height};break;case Nn:l={x:s,y:e.y+e.height};break;case pn:l={x:e.x+e.width,y:a};break;case rn:l={x:e.x-t.width,y:a};break;default:l={x:e.x,y:e.y}}var c=i?cp(i):null;if(c!=null){var u=c==="y"?"height":"width";switch(o){case vc:l[c]=l[c]-(e[u]/2-t[u]/2);break;case sp:l[c]=l[c]+(e[u]/2-t[u]/2);break;default:}}return l}var Z0=b(()=>{Su();hm();zT();ns()});function Pa(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?WB:a,c=t.rootBoundary,u=c===void 0?VT:c,d=t.elementContext,f=d===void 0?cm:d,p=t.altBoundary,m=p===void 0?!1:p,v=t.padding,g=v===void 0?0:v,y=ry(typeof g!="number"?g:ny(g,Au)),w=f===cm?zB:cm,x=r.rects.popper,C=r.elements[m?w:f],_=Q0(Us(C)?C:C.contextElement||yi(r.elements.popper),l,u,s),E=Vs(r.elements.reference),D=iy({reference:E,element:x,strategy:"absolute",placement:i}),P=vm(Object.assign({},x,D)),V=f===cm?P:E,j={top:_.top-V.top+y.top,bottom:V.bottom-_.bottom+y.bottom,left:_.left-V.left+y.left,right:V.right-_.right+y.right},oe=r.modifiersData.offset;if(f===cm&&oe){var se=oe[i];Object.keys(j).forEach(function(M){var U=[pn,Nn].indexOf(M)>=0?1:-1,q=[Hr,Nn].indexOf(M)>=0?"y":"x";j[M]+=se[q]*U})}return j}var oy=b(()=>{uU();bc();pm();Z0();X0();ns();is();H0();j0()});function J0(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?qT:l,u=qs(n),d=u?a?L0:L0.filter(function(m){return qs(m)===u}):Au,f=d.filter(function(m){return c.indexOf(m)>=0});f.length===0&&(f=d);var p=f.reduce(function(m,v){return m[v]=Pa(r,{placement:v,boundary:i,rootBoundary:o,padding:s})[ti(v)],m},{});return Object.keys(p).sort(function(m,v){return p[m]-p[v]})}var dU=b(()=>{hm();ns();oy();Su()});function SZ(r){if(ti(r)===UT)return[];var e=gm(r);return[jT(r),e,jT(e)]}function DZ(r){var e=r.state,t=r.options,n=r.name;if(!e.modifiersData[n]._skip){for(var i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!0:s,l=t.fallbackPlacements,c=t.padding,u=t.boundary,d=t.rootBoundary,f=t.altBoundary,p=t.flipVariations,m=p===void 0?!0:p,v=t.allowedAutoPlacements,g=e.options.placement,y=ti(g),w=y===g,x=l||(w||!m?[gm(g)]:SZ(g)),C=[g].concat(x).reduce(function(be,xe){return be.concat(ti(xe)===UT?J0(e,{placement:xe,boundary:u,rootBoundary:d,padding:c,flipVariations:m,allowedAutoPlacements:v}):xe)},[]),_=e.rects.reference,E=e.rects.popper,D=new Map,P=!0,V=C[0],j=0;j<C.length;j++){var oe=C[j],se=ti(oe),M=qs(oe)===vc,U=[Hr,Nn].indexOf(se)>=0,q=U?"width":"height",B=Pa(e,{placement:oe,boundary:u,rootBoundary:d,altBoundary:f,padding:c}),ie=U?M?pn:rn:M?Nn:Hr;_[q]>E[q]&&(ie=gm(ie));var W=gm(ie),Y=[];if(o&&Y.push(B[se]<=0),a&&Y.push(B[ie]<=0,B[W]<=0),Y.every(function(be){return be})){V=oe,P=!1;break}D.set(oe,Y)}if(P)for(var X=m?3:1,ae=function(xe){var Ue=C.find(function($t){var Ne=D.get($t);if(Ne)return Ne.slice(0,xe).every(function(Ke){return Ke})});if(Ue)return V=Ue,"break"},pe=X;pe>0;pe--){var ge=ae(pe);if(ge==="break")break}e.placement!==V&&(e.modifiersData[n]._skip=!0,e.placement=V,e.reset=!0)}}var pU,fU=b(()=>{iU();Su();oU();oy();dU();ns();hm();pU={name:"flip",enabled:!0,phase:"main",fn:DZ,requiresIfExists:["offset"],data:{_skip:!1}}});function mU(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 hU(r){return[Hr,pn,Nn,rn].some(function(e){return r[e]>=0})}function IZ(r){var e=r.state,t=r.name,n=e.rects.reference,i=e.rects.popper,o=e.modifiersData.preventOverflow,s=Pa(e,{elementContext:"reference"}),a=Pa(e,{altBoundary:!0}),l=mU(s,n),c=mU(a,i,o),u=hU(l),d=hU(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 gU,vU=b(()=>{ns();oy();gU={name:"hide",enabled:!0,phase:"main",requiresIfExists:["preventOverflow"],fn:IZ}});function PZ(r,e,t){var n=ti(r),i=[rn,Hr].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,[rn,pn].indexOf(n)>=0?{x:a,y:s}:{x:s,y:a}}function FZ(r){var e=r.state,t=r.options,n=r.name,i=t.offset,o=i===void 0?[0,0]:i,s=qT.reduce(function(u,d){return u[d]=PZ(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 yU,bU=b(()=>{Su();ns();yU={name:"offset",enabled:!0,phase:"main",requires:["popperOffsets"],fn:FZ}});function MZ(r){var e=r.state,t=r.name;e.modifiersData[t]=iy({reference:e.rects.reference,element:e.rects.popper,strategy:"absolute",placement:e.placement})}var wU,CU=b(()=>{Z0();wU={name:"popperOffsets",enabled:!0,phase:"read",fn:MZ,data:{}}});function eP(r){return r==="x"?"y":"x"}var xU=b(()=>{});function RZ(r){var e=r.state,t=r.options,n=r.name,i=t.mainAxis,o=i===void 0?!0:i,s=t.altAxis,a=s===void 0?!1:s,l=t.boundary,c=t.rootBoundary,u=t.altBoundary,d=t.padding,f=t.tether,p=f===void 0?!0:f,m=t.tetherOffset,v=m===void 0?0:m,g=Pa(e,{boundary:l,rootBoundary:c,padding:d,altBoundary:u}),y=ti(e.placement),w=qs(e.placement),x=!w,C=cp(y),_=eP(C),E=e.modifiersData.popperOffsets,D=e.rects.reference,P=e.rects.popper,V=typeof v=="function"?v(Object.assign({},e.rects,{placement:e.placement})):v,j=typeof V=="number"?{mainAxis:V,altAxis:V}:Object.assign({mainAxis:0,altAxis:0},V),oe=e.modifiersData.offset?e.modifiersData.offset[e.placement]:null,se={x:0,y:0};if(E){if(o){var M,U=C==="y"?Hr:rn,q=C==="y"?Nn:pn,B=C==="y"?"height":"width",ie=E[C],W=ie+g[U],Y=ie-g[q],X=p?-P[B]/2:0,ae=w===vc?D[B]:P[B],pe=w===vc?-P[B]:-D[B],ge=e.elements.arrow,be=p&&ge?lp(ge):{width:0,height:0},xe=e.modifiersData["arrow#persistent"]?e.modifiersData["arrow#persistent"].padding:ty(),Ue=xe[U],$t=xe[q],Ne=up(0,D[B],be[B]),Ke=x?D[B]/2-X-Ne-Ue-j.mainAxis:ae-Ne-Ue-j.mainAxis,Qe=x?-D[B]/2+X+Ne+$t+j.mainAxis:pe+Ne+$t+j.mainAxis,ye=e.elements.arrow&&Ia(e.elements.arrow),We=ye?C==="y"?ye.clientTop||0:ye.clientLeft||0:0,mt=(M=oe?.[C])!=null?M:0,He=ie+Ke-mt-We,_e=ie+Qe-mt,Be=up(p?ap(W,He):W,ie,p?Da(Y,_e):Y);E[C]=Be,se[C]=Be-ie}if(a){var ut,or=C==="x"?Hr:rn,yr=C==="x"?Nn:pn,Pt=E[_],Ar=_==="y"?"height":"width",ur=Pt+g[or],dt=Pt-g[yr],Ft=[Hr,rn].indexOf(y)!==-1,Hn=(ut=oe?.[_])!=null?ut:0,xo=Ft?ur:Pt-D[Ar]-P[Ar]-Hn+j.altAxis,xs=Ft?Pt+D[Ar]+P[Ar]-Hn-j.altAxis:dt,jn=p&&Ft?XB(xo,Pt,xs):up(p?xo:ur,Pt,p?xs:dt);E[_]=jn,se[_]=jn-Pt}e.modifiersData[n]=se}}var EU,TU=b(()=>{ns();Su();zT();xU();W0();WT();mm();oy();hm();z0();Du();EU={name:"preventOverflow",enabled:!0,phase:"main",fn:RZ,requiresIfExists:["offset"]}});var tP=b(()=>{});function rP(r){return{scrollLeft:r.scrollLeft,scrollTop:r.scrollTop}}var _U=b(()=>{});function nP(r){return r===Mr(r)||!Ln(r)?dp(r):rP(r)}var AU=b(()=>{GT();Sa();is();_U()});function $Z(r){var e=r.getBoundingClientRect(),t=yc(e.width)/r.offsetWidth||1,n=yc(e.height)/r.offsetHeight||1;return t!==1||n!==1}function iP(r,e,t){t===void 0&&(t=!1);var n=Ln(e),i=Ln(e)&&$Z(e),o=yi(e),s=Vs(r,i,t),a={scrollLeft:0,scrollTop:0},l={x:0,y:0};return(n||!n&&!t)&&((ei(e)!=="body"||fp(o))&&(a=nP(e)),Ln(e)?(l=Vs(e,!0),l.x+=e.clientLeft,l.y+=e.clientTop):o&&(l.x=pp(o))),{x:s.left+a.scrollLeft-l.x,y:s.top+a.scrollTop-l.y,width:s.width,height:s.height}}var kU=b(()=>{pm();AU();ku();is();YT();bc();KT();Du()});function OZ(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 oP(r){var e=OZ(r);return HB.reduce(function(t,n){return t.concat(e.filter(function(i){return i.phase===n}))},[])}var SU=b(()=>{ns()});function sP(r){var e;return function(){return e||(e=new Promise(function(t){Promise.resolve().then(function(){e=void 0,t(r())})})),e}}var DU=b(()=>{});function aP(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 IU=b(()=>{});function FU(){for(var r=arguments.length,e=new Array(r),t=0;t<r;t++)e[t]=arguments[t];return!e.some(function(n){return!(n&&typeof n.getBoundingClientRect=="function")})}function MU(r){r===void 0&&(r={});var e=r,t=e.defaultModifiers,n=t===void 0?[]:t,i=e.defaultOptions,o=i===void 0?PU:i;return function(a,l,c){c===void 0&&(c=o);var u={placement:"bottom",orderedModifiers:[],options:Object.assign({},PU,o),modifiersData:{},elements:{reference:a,popper:l},attributes:{},styles:{}},d=[],f=!1,p={state:u,setOptions:function(y){var w=typeof y=="function"?y(u.options):y;v(),u.options=Object.assign({},o,u.options,w),u.scrollParents={reference:Us(a)?Iu(a):a.contextElement?Iu(a.contextElement):[],popper:Iu(l)};var x=oP(aP([].concat(n,u.options.modifiers)));return u.orderedModifiers=x.filter(function(C){return C.enabled}),m(),p.update()},forceUpdate:function(){if(!f){var y=u.elements,w=y.reference,x=y.popper;if(FU(w,x)){u.rects={reference:iP(w,Ia(x),u.options.strategy==="fixed"),popper:lp(x)},u.reset=!1,u.placement=u.options.placement,u.orderedModifiers.forEach(function(j){return u.modifiersData[j.name]=Object.assign({},j.data)});for(var C=0;C<u.orderedModifiers.length;C++){if(u.reset===!0){u.reset=!1,C=-1;continue}var _=u.orderedModifiers[C],E=_.fn,D=_.options,P=D===void 0?{}:D,V=_.name;typeof E=="function"&&(u=E({state:u,options:P,name:V,instance:p})||u)}}}},update:sP(function(){return new Promise(function(g){p.forceUpdate(),g(u)})}),destroy:function(){v(),f=!0}};if(!FU(a,l))return p;p.setOptions(c).then(function(g){!f&&c.onFirstUpdate&&c.onFirstUpdate(g)});function m(){u.orderedModifiers.forEach(function(g){var y=g.name,w=g.options,x=w===void 0?{}:w,C=g.effect;if(typeof C=="function"){var _=C({state:u,name:y,instance:p,options:x}),E=function(){};d.push(_||E)}})}function v(){d.forEach(function(g){return g()}),d=[]}return p}}var PU,RU=b(()=>{kU();WT();K0();mm();SU();DU();IU();is();PU={placement:"bottom",modifiers:[],strategy:"absolute"}});var NZ,lP,$U=b(()=>{RU();nU();CU();tU();GB();bU();fU();TU();ZB();vU();tP();NZ=[rU,wU,eU,jB,yU,pU,EU,QB,gU],lP=MU({defaultModifiers:NZ})});var OU=b(()=>{ns();tP();$U()});function NU(r,e){return LZ.test(r[e])}function BZ(r){if(!r.includes("![["))return r;let e="",t=0,n=0,i=0;for(;n<r.length;){if(r.charCodeAt(n)===33&&r.charCodeAt(n+1)===91&&r.charCodeAt(n+2)===91){for(i<n+3&&(i=n+3);i<r.length&&r.charCodeAt(i)!==93;)i++;if(i<r.length&&r.charCodeAt(i+1)===93){e+=r.slice(t,n),n=i+2,t=n;continue}}n++}return e+r.slice(t)}function UZ(r){if(!r.includes("[["))return r;let e="",t=0,n=0,i=0,o=0;for(;n<r.length;){if(r.charCodeAt(n)===91&&r.charCodeAt(n+1)===91){for(i<n+2&&(i=n+2);i<r.length;){let s=r.charCodeAt(i);if(s===93||s===124)break;i++}if(i<r.length&&r.charCodeAt(i)===93){if(r.charCodeAt(i+1)===93){e+=r.slice(t,n)+r.slice(n+2,i),n=i+2,t=n;continue}}else if(i<r.length){for(o<i+1&&(o=i+1);o<r.length&&r.charCodeAt(o)!==93;)o++;if(o<r.length&&r.charCodeAt(o+1)===93){e+=r.slice(t,n)+r.slice(i+1,o),n=o+2,t=n;continue}}}n++}return e+r.slice(t)}function VZ(r){let e=0;if(r.charCodeAt(0)===35){for(;r.charCodeAt(e)===35;)e++;for(;e<r.length&&NU(r,e);)e++}let t=r.length;if(t>e&&r.charCodeAt(t-1)===35){for(;t>e&&r.charCodeAt(t-1)===35;)t--;for(;t>e&&NU(r,t-1);)t--}return r.slice(e,t)}function qZ(r){if(!r.includes("[[")&&!r.includes("]]"))return r;let e="",t=0,n=0;for(;n<r.length;){let i=r.charCodeAt(n);if(i===91&&r.charCodeAt(n+1)===91||i===93&&r.charCodeAt(n+1)===93){e+=r.slice(t,n),n+=2,t=n;continue}n++}return e+r.slice(t)}function cP(r){return qZ(VZ(UZ(BZ(r)).replace(WZ,""))).trim()}var LZ,WZ,LU=b(()=>{LZ=/^\s$/;WZ=/[*_`~]/g});function fn(r){return typeof r=="string"?r:r==null?"":String(r)}function QT(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 mp(r){let e=!1;return t=>{e||(e=!0,F.logWarning(Yd(t,r)))}}function Cc(r){return fn(r)}function Rr(r){return r.normalize("NFC").toLowerCase()}function sy(r){return r.toLowerCase().endsWith(".md")?r.slice(0,-3):r}function ZT(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 BU(r,e,t){if(r.replaceChildren(),!t){r.textContent=e;return}let n="",i=[],o=[],s=0;for(let d of e){let f=d.toLowerCase(),p=s,m=s+d.length;for(let v=0;v<f.length;v++)i.push(p),o.push(m);n+=f,s=m}let a="";for(let d of t)a+=d.toLowerCase();let l=0,c=0,u=n.indexOf(a,c);for(;u!==-1;){let d=Math.max(l,i[u]),f=o[u+a.length-1];if(f>d){d>l&&r.append(jv(r,e.slice(l,d)));let p=zr(r,"mark");p.className="qa-highlight",p.textContent=e.slice(d,f),r.append(p),l=f}c=u+a.length,u=n.indexOf(a,c)}l<e.length&&r.append(jv(r,e.slice(l)))}var Fo=b(()=>{Me();fc();Cr();LU()});var JT,zZ,uP,ay,mn,fl=b(()=>{OU();JT=require("obsidian");Me();fc();Fo();zZ=(r,e)=>(r%e+e)%e,uP=class{constructor(e,t,n){this.isOpen=!1;this.owner=e,this.containerEl=t,this.clickListener=i=>{let o=this.findSuggestionItem(i.target);o&&this.onSuggestionClick(i,o)},this.mousemoveListener=i=>{let o=this.findSuggestionItem(i.target);o&&this.onSuggestionMouseover(i,o)},t.addEventListener("click",this.clickListener),t.addEventListener("mousemove",this.mousemoveListener),n.register([],"ArrowUp",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(this.selectedItem-1,!0),!1}),n.register([],"ArrowDown",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(this.selectedItem+1,!0),!1}),n.register([],"Enter",i=>{if(!i.isComposing&&this.isOpen)return this.useSelectedItem(i),!1}),n.register([],"PageUp",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(Math.max(0,this.selectedItem-5),!0),!1}),n.register([],"PageDown",i=>{if(!i.isComposing&&this.isOpen)return this.setSelectedItem(Math.min(this.suggestions.length-1,this.selectedItem+5),!0),!1})}findSuggestionItem(e){let t=this.containerEl.ownerDocument.defaultView;if(!t||!(e instanceof t.Element))return null;let n=e.closest(".suggestion-item");return n&&this.containerEl.contains(n)?n:null}onSuggestionClick(e,t){e.preventDefault();let n=this.suggestions.indexOf(t);this.setSelectedItem(n,!1),this.useSelectedItem(e)}onSuggestionMouseover(e,t){let n=this.suggestions.indexOf(t);this.setSelectedItem(n,!1)}setSuggestions(e){this.containerEl.replaceChildren();let t=[];e.forEach((n,i)=>{let o=this.containerEl.ownerDocument.createElement("div");o.classList.add("suggestion-item"),this.containerEl.appendChild(o),o.setAttribute("role","option"),o.setAttribute("aria-selected","false"),o.setAttribute("id",`suggestion-${i}`),this.owner.renderSuggestion(n,o),t.push(o)}),this.values=e,this.suggestions=t,this.setSelectedItem(0,!1),this.isOpen=e.length>0}useSelectedItem(e){let t=this.values[this.selectedItem];t&&this.owner.selectSuggestion(t,e)}setSelectedItem(e,t){if(!this.suggestions?.length)return;let n=zZ(e,this.suggestions.length),i=this.suggestions[this.selectedItem],o=this.suggestions[n];i?.classList.remove("is-selected"),o?.classList.add("is-selected"),i?.setAttribute("aria-selected","false"),o?.setAttribute("aria-selected","true"),this.selectedItem=n,t&&o.scrollIntoView(!1)}close(){this.isOpen=!1}getIsOpen(){return this.isOpen}},ay=new WeakMap,mn=class{constructor(e,t){this.popper=null;this.currentRequestId=0;this.isOpen=!1;this.destroyed=!1;this.noResultsTimeout=null;this.currentQuery="";this.renderMatch=BU;let n=this.constructor.name,i=ay.get(t);i||(i=new Map,ay.set(t,i));let o=i.get(n);o&&o.destroy(),ay.set(t,i),i.set(n,this),this.app=e,this.inputEl=t,this.scope=new JT.Scope,this.suggestEl=this.inputEl.ownerDocument.createElement("div"),this.suggestEl.classList.add("suggestion-container");let s=this.inputEl.ownerDocument.createElement("div");s.classList.add("suggestion"),this.suggestEl.appendChild(s),s.setAttribute("role","listbox"),s.setAttribute("aria-label","Suggestions"),this.suggest=new uP(this,s,this.scope),this.scope.register([],"Escape",this.close.bind(this)),this.debouncedOnInputChanged=(0,JT.debounce)(this.onInputChanged.bind(this),50),this.inputEventListener=a=>this.debouncedOnInputChanged(a),this.focusEventListener=()=>this.debouncedOnInputChanged(),this.inputBlurListener=this.close.bind(this),this.inputEl.addEventListener("input",this.inputEventListener),this.inputEl.addEventListener("focus",this.focusEventListener),this.inputEl.addEventListener("blur",this.inputBlurListener),this.inputEl.setAttribute("aria-autocomplete","list"),this.inputEl.setAttribute("aria-expanded","false"),this.suggestEl.addEventListener("mousedown",a=>{a.preventDefault()}),this.globalClickListener=this.onGlobalClick.bind(this),this.globalWheelListener=this.onGlobalWheel.bind(this),this.globalResizeListener=this.close.bind(this),this.globalBlurListener=this.close.bind(this)}onGlobalClick(e){if(!this.isOpen)return;let t=e.target;!this.suggestEl.contains(t)&&!this.inputEl.contains(t)&&this.close()}onGlobalWheel(e){if(!this.isOpen)return;let t=e.target;this.suggestEl.contains(t)||this.close()}async onInputChanged(e){if(this.destroyed)return;let t=e;if(t?.fromCompletion&&t.keepOpen){let o=this.inputEl.value,s=++this.currentRequestId;this.currentQuery=o;try{let a=await this.getSuggestions(o);s===this.currentRequestId&&(a?.length?(this.suggest.setSuggestions(a),this.isOpen||this.open(this.app.dom.appContainerEl,this.inputEl)):this.close())}catch(a){F.logError(a)}return}if(t?.fromCompletion)return;let n=this.inputEl.value,i=++this.currentRequestId;this.currentQuery=n;try{let o=await this.getSuggestions(n);if(i!==this.currentRequestId)return;if(!o||o.length===0){this.isOpen&&this.showNoResultsAndClose();return}this.suggest.setSuggestions(o),this.open(this.app.dom.appContainerEl,this.inputEl)}catch(o){F.logError(o),this.close()}}showNoResultsAndClose(){this.noResultsTimeout&&ep(this.inputEl).clearTimeout(this.noResultsTimeout),this.close()}open(e,t){if(this.destroyed)return;this.isOpen||this.app.keymap.pushScope(this.scope),this.isOpen=!0,this.inputEl.setAttribute("aria-expanded","true");let n=ts(t);if((ts(e)===n?e:n.body).appendChild(this.suggestEl),this.popper){this.popper.update();return}this.popper=lP(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=ep(t);s.addEventListener("pointerdown",this.globalClickListener,!0),s.addEventListener("wheel",this.globalWheelListener,!0),a.addEventListener("resize",this.globalResizeListener),a.addEventListener("blur",this.globalBlurListener)}close(){if(!this.isOpen)return;this.app.keymap.popScope(this.scope),this.isOpen=!1,this.inputEl.setAttribute("aria-expanded","false"),this.suggest.close(),this.suggest.setSuggestions([]),this.popper&&(this.popper.destroy(),this.popper=null),this.suggestEl.remove(),this.noResultsTimeout&&(ep(this.inputEl).clearTimeout(this.noResultsTimeout),this.noResultsTimeout=null);let e=ts(this.inputEl),t=ep(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=ay.get(this.inputEl);t&&(t.delete(e),t.size===0&&ay.delete(this.inputEl))}getCurrentQuery(){return this.currentQuery}}});function UU(r,e=0){return(bi[r[e+0]]+bi[r[e+1]]+bi[r[e+2]]+bi[r[e+3]]+"-"+bi[r[e+4]]+bi[r[e+5]]+"-"+bi[r[e+6]]+bi[r[e+7]]+"-"+bi[r[e+8]]+bi[r[e+9]]+"-"+bi[r[e+10]]+bi[r[e+11]]+bi[r[e+12]]+bi[r[e+13]]+bi[r[e+14]]+bi[r[e+15]]).toLowerCase()}var bi,VU=b(()=>{bi=[];for(let r=0;r<256;++r)bi.push((r+256).toString(16).slice(1))});function dP(){return crypto.getRandomValues(HZ)}var HZ,qU=b(()=>{HZ=new Uint8Array(16)});function jZ(r,e,t){return!e&&!r&&crypto.randomUUID?crypto.randomUUID():GZ(r,e,t)}function GZ(r,e,t){r=r||{};let n=r.random??r.rng?.()??dP();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,e){if(t=t||0,t<0||t+16>e.length)throw new RangeError(`UUID byte range ${t}:${t+15} is out of buffer bounds`);for(let i=0;i<16;++i)e[t+i]=n[i];return e}return UU(n)}var xr,WU=b(()=>{qU();VU();xr=jZ});var ml=b(()=>{WU()});function e_(r){return Ye(r)&&r.type==="Multi"}function Ye(r){return typeof r=="object"&&r!==null}function st(r){return e_(r)?Array.isArray(r.choices)?r.choices:[]:[]}function xc(r){return e_(r)&&Array.isArray(r.choices)}function ym(r){if(!Array.isArray(r))return!0;let e=t=>t.some(n=>{if(Array.isArray(n))return!0;if(!Ye(n)||n.type!=="Multi")return!1;let i=n.choices;return Array.isArray(i)?e(i):t_(i)});return e(r)}function hn(r){return Array.isArray(r)?r:[]}function t_(r){return Array.isArray(r)||r==null?!1:typeof r=="object"?Object.keys(r).length>0:!!r}function Ws(r){return e_(r)?t_(r.choices):!1}function bm(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 wm(r){return(typeof r.icon=="string"?r.icon.trim():"")||bm(r.type)}function Bn(r){let e=[],t=n=>{Ye(n)&&(e.push(n),st(n).forEach(t))};return hn(r).forEach(t),e}function zU(r){let e=new Map,t=n=>{let i=[];for(let o of n){if(!Ye(o)){i.push(o);continue}let s=o,a=e.get(s.id);if(a){if(JSON.stringify(s)===JSON.stringify(a))continue;s={...s,id:xr()}}e.set(s.id,s),e_(s)&&Array.isArray(s.choices)&&(s={...s,choices:t(s.choices)}),i.push(s)}return i};return t(r)}function HU(r){if(!Array.isArray(r))return{choices:[],changed:!1,repaired:[]};let e=new Set,t=[],n=o=>{let s=!1,a=[];for(let l of o){if(Array.isArray(l)){s=!0,a.push(...n(l));continue}if(!Ye(l)){s=!0;continue}let c=l;if(xc(c)){let f=c.choices,p=n(f);p!==f&&(c={...c,choices:p},s=!0)}let u=c.id;if(typeof u=="string"&&u!==""&&!e.has(u)){e.add(u),a.push(c);continue}let d={...c,id:xr()};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 ly(r,e=[],t=0,n=null){let i=[];for(let o of hn(r)){if(!Ye(o))continue;let s=[...e,o.name];i.push({choice:o,id:o.id,path:s,depth:t,parentId:n}),i.push(...ly(st(o),s,t+1,o.id))}return i}var Wt=b(()=>{ml()});function Pu(r){return Array.isArray?Array.isArray(r):nV(r)==="[object Array]"}function aJ(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 fP(r){return r==null?"":aJ(r)}function ji(r){return typeof r=="string"}function n_(r){return typeof r=="number"}function lJ(r){return r===!0||r===!1||cJ(r)&&nV(r)=="[object Boolean]"}function rV(r){return typeof r=="object"}function cJ(r){return rV(r)&&r!==null}function os(r){return r!=null}function r_(r){return!r.trim().length}function nV(r){return r==null?r===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(r)}function iV(r){let e=null,t=null,n=null,i=1,o=null;if(ji(r)||Pu(r))n=r,e=XU(r),t=i_(r);else{if(!KU.call(r,"name"))throw new Error(fJ("name"));let s=r.name;if(n=s,KU.call(r,"weight")&&r.weight!==void 0&&(i=r.weight,i<=0))throw new Error(mJ(i_(s)));e=XU(s),t=i_(s),o=r.getFn??null}return{path:e,id:t,weight:i,src:n,getFn:o}}function XU(r){return Pu(r)?r:r.split(".")}function i_(r){return Pu(r)?r.join("."):r}function vJ(r,e){let t=[],n=!1,i=(o,s,a,l)=>{if(os(o))if(!s[a])t.push(l!==void 0?{v:o,i:l}:o);else{let c=o[s[a]];if(!os(c))return;if(a===s.length-1&&(ji(c)||n_(c)||lJ(c)||typeof c=="bigint"))t.push(l!==void 0?{v:fP(c),i:l}:fP(c));else if(Pu(c)){n=!0;for(let u=0,d=c.length;u<d;u+=1)i(c[u],s,a+1,u)}else s.length&&i(c,s,a+1,l)}};return i(r,ji(e)?e.split("."):e,0),n?t:t[0]}function xJ(r){return r>=9&&r<=13||r===32||r===160}function EJ(r=1,e=3){let t=new Map,n=Math.pow(10,e);return{get(i){let o=0,s=!1;for(let l=0;l<i.length;l++)xJ(i.charCodeAt(l))?s=!1:s||(o++,s=!0);if(o===0&&(o=1),t.has(o))return t.get(o);let a=Math.round(n/Math.pow(o,.5*r))/n;return t.set(o,a),a},clear(){t.clear()}}}function oV(r,e,{getFn:t=rt.getFn,fieldNormWeight:n=rt.fieldNormWeight}={}){let i=new CP({getFn:t,fieldNormWeight:n});return i.setKeys(r.map(iV)),i.setSources(e),i.create(),i}function TJ(r,{getFn:e=rt.getFn,fieldNormWeight:t=rt.fieldNormWeight}={}){let{keys:n,records:i}=r,o=new CP({getFn:e,fieldNormWeight:t});return o.setKeys(n),o.setIndexRecords(i),o}function _J(r=[],e=rt.minMatchCharLength){let t=[],n=-1,i=-1,o=0;for(let s=r.length;o<s;o+=1){let a=r[o];a&&n===-1?n=o:!a&&n!==-1&&(i=o-1,i-n+1>=e&&t.push([n,i]),n=-1)}return r[o-1]&&o-n>=e&&t.push([n,o-1]),t}function AJ(r,e,t,{location:n=rt.location,distance:i=rt.distance,threshold:o=rt.threshold,findAllMatches:s=rt.findAllMatches,minMatchCharLength:a=rt.minMatchCharLength,includeMatches:l=rt.includeMatches,ignoreLocation:c=rt.ignoreLocation}={}){if(e.length>32)throw new Error(pJ(32));let u=e.length,d=r.length,f=Math.max(0,Math.min(n,d)),p=o,m=f,v=(V,j)=>{let oe=V/u;if(c)return oe;let se=Math.abs(f-j);return i?oe+se/i:se?1:oe},g=a>1||l,y=g?Array(d):[],w;for(;(w=r.indexOf(e,m))>-1;){let V=v(0,w);if(p=Math.min(V,p),m=w+u,g){let j=0;for(;j<u;)y[w+j]=1,j+=1}}m=-1;let x=[],C=1,_=0,E=u+d,D=1<<u-1;for(let V=0;V<u;V+=1){let j=0,oe=E;for(;j<oe;)v(V,f+oe)<=p?j=oe:E=oe,oe=Math.floor((E-j)/2+j);E=oe;let se=Math.max(1,f-oe+1),M=s?d:Math.min(f+oe,d)+u,U=Array(M+2);U[M+1]=(1<<V)-1;for(let q=M;q>=se;q-=1){let B=q-1,ie=t[r[B]];if(U[q]=(U[q+1]<<1|1)&ie,V&&(U[q]|=(x[q+1]|x[q])<<1|1|x[q+1]),U[q]&D&&(C=v(V,B),C<=p)){if(p=C,m=B,_=V,m<=f)break;se=Math.max(1,2*f-m)}}if(v(V+1,f)>p)break;x=U}if(g&&m>=0){let V=Math.min(d-1,m+u-1+_);for(let j=m;j<=V;j+=1)t[r[j]]&&(y[j]=1)}let P={isMatch:m>=0,score:Math.max(.001,C)};if(g){let V=_J(y,a);V.length?l&&(P.indices=V):P.isMatch=!1}return P}function kJ(r){let e={};for(let t=0,n=r.length;t<n;t+=1){let i=r.charAt(t);e[i]=(e[i]||0)|1<<n-t-1}return e}function xP(r){if(r.length<=1)return r;r.sort((t,n)=>t[0]-n[0]||t[1]-n[1]);let e=[r[0]];for(let t=1,n=r.length;t<n;t+=1){let i=e[e.length-1],o=r[t];o[0]<=i[1]+1?i[1]=Math.max(i[1],o[1]):e.push(o)}return e}function IJ(r){return r.startsWith("inverse")}function MJ(r){let e=[],t=r.length,n=0;for(;n<t;){for(;n<t&&r[n]===" ";)n++;if(n>=t)break;let i=n;for(;i<t&&r[i]!==" "&&r[i]!=='"';)i++;if(i<t&&r[i]==='"'){for(i++;i<t;){if(r[i]==='"'){let o=i+1;if(o>=t||r[o]===" "){i++;break}if(r[o]==="$"&&(o+1>=t||r[o+1]===" ")){i+=2;break}}i++}e.push(r.substring(n,i)),n=i}else{for(;i<t&&r[i]!==" ";)i++;e.push(r.substring(n,i)),n=i}}return e}function ZU(r,e){let t=r.match(e);return t?t[1]:null}function RJ(r,e={}){return r.replace(/\\\|/g,PJ).split(FJ).map(t=>{let n=MJ(t.replace(/\u0000/g,"|").trim()).filter(o=>o&&!!o.trim()),i=[];for(let o=0,s=n.length;o<s;o+=1){let a=n[o],l=!1,c=-1;for(;!l&&++c<QU;){let u=hP[c],d=ZU(a,u.multiRegex);d&&(i.push(u.create(d,e)),l=!0)}if(!l)for(c=-1;++c<QU;){let u=hP[c],d=ZU(a,u.singleRegex);if(d){i.push(u.create(d,e));break}}}return i})}function TP(...r){gP.push(...r)}function o_(r,e){for(let t=0,n=gP.length;t<n;t+=1){let i=gP[t];if(i.condition(r,e))return new i(r,e)}return new EP(r,e)}function aV(r,e,{auto:t=!0}={}){let n=i=>{if(ji(i)){let l={keyId:null,pattern:i};return t&&(l.searcher=o_(i,e)),l}let o=Object.keys(i),s=OJ(i);if(!s&&o.length>1&&!yP(i))return n(JU(i));if(NJ(i)){let l=s?i[vP.PATH]:o[0],c=s?i[vP.PATTERN]:i[l];if(!ji(c))throw new Error(dJ(l));let u={keyId:i_(l),pattern:c};return t&&(u.searcher=o_(c,e)),u}let a={children:[],operator:o[0]};return o.forEach(l=>{let c=i[l];Pu(c)&&c.forEach(u=>{a.children.push(n(u))})}),a};return yP(r)||(r=JU(r)),n(r)}function bP(r,{ignoreFieldNorm:e=rt.ignoreFieldNorm}){let t=1;return r.forEach(({key:n,norm:i,score:o})=>{let s=n?n.weight:null;t*=Math.pow(o===0&&s?Number.EPSILON:o,(s||1)*(e?1:i))}),t}function LJ(r,{ignoreFieldNorm:e=rt.ignoreFieldNorm}){r.forEach(t=>{t.score=bP(t.matches,{ignoreFieldNorm:e})})}function UJ(r){let e=[];return r.matches.forEach(t=>{if(!os(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 VJ(r,e,{includeMatches:t=rt.includeMatches,includeScore:n=rt.includeScore}={}){return r.map(i=>{let{idx:o}=i,s={item:e[o],refIndex:o};return t&&(s.matches=UJ(i)),n&&(s.score=i.score),s})}function WJ(r){eV.has(r)||(eV.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 zJ(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||WJ(r),e=>e.match(r)||[]):e=>e.match(qJ)||[]}function wP({isCaseSensitive:r=!1,ignoreDiacritics:e=!1,tokenize:t}={}){let n=zJ(t);return{tokenize(i){return r||(i=i.toLowerCase()),e&&(i=cy(i)),n(i)}}}function pP(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 lV(r,e,t,n){let{i,v:o,$:s}=e;if(o!==void 0){pP(r,o,i,n);return}if(s)for(let a=0;a<t;a++){let l=s[a];if(l)if(Array.isArray(l))for(let c of l)pP(r,c.v,i,n);else pP(r,l.v,i,n)}}function jJ(r,e,t){let n={fieldCount:0,df:new Map,docFieldCount:new Map,docTermFieldHits:new Map};for(let i of r)lV(n,i,e,t);return n}function GJ(r,e,t,n){lV(r,e,t,n)}function YJ(r,e){let t=r.docFieldCount.get(e);if(t===void 0)return;r.fieldCount-=t,r.docFieldCount.delete(e);let n=r.docTermFieldHits.get(e);if(n){for(let[i,o]of n){let s=(r.df.get(i)||0)-o;s<=0?r.df.delete(i):r.df.set(i,s)}r.docTermFieldHits.delete(e)}}function tV(r,e){if(e.length===0)return;let t=Array.from(new Set(e)).sort((a,l)=>a-l);for(let a of t)YJ(r,a);let n=a=>{let l=0,c=t.length;for(;l<c;){let u=l+c>>>1;t[u]<a?l=u+1:c=u}return a-l},i=t[0],o=new Map;for(let[a,l]of r.docFieldCount)o.set(a>i?n(a):a,l);r.docFieldCount=o;let s=new Map;for(let[a,l]of r.docTermFieldHits)s.set(a>i?n(a):a,l);r.docTermFieldHits=s}var uJ,mP,dJ,pJ,fJ,mJ,hJ,KU,gJ,yJ,bJ,wJ,CJ,rt,CP,sV,SJ,cy,EP,DJ,hP,QU,PJ,FJ,$J,gP,s_,vP,yP,OJ,NJ,JU,BJ,qJ,eV,HJ,Fu,Mu,a_=b(()=>{uJ="Incorrect 'index' type",mP="Invalid doc index: must be a non-negative integer within the bounds of the docs array",dJ=r=>`Invalid value for key ${r}`,pJ=r=>`Pattern length exceeds max of ${r}.`,fJ=r=>`Missing ${r} property in key`,mJ=r=>`Property 'weight' in key '${r}' must be a positive integer`,hJ="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.",KU=Object.prototype.hasOwnProperty,gJ=class{constructor(r){this._keys=[],this._keyMap={};let e=0;r.forEach(t=>{let n=iV(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)}};yJ={includeMatches:!1,findAllMatches:!1,minMatchCharLength:1},bJ={isCaseSensitive:!1,ignoreDiacritics:!1,includeScore:!1,keys:[],shouldSort:!0,sortFn:(r,e)=>r.score===e.score?r.idx<e.idx?-1:1:r.score<e.score?-1:1},wJ={location:0,threshold:.6,distance:100},CJ={useExtendedSearch:!1,useTokenSearch:!1,tokenize:void 0,tokenMatch:"any",getFn:vJ,ignoreLocation:!1,ignoreFieldNorm:!1,fieldNormWeight:1},rt=Object.freeze({...bJ,...yJ,...wJ,...CJ});CP=class{constructor({getFn:r=rt.getFn,fieldNormWeight:e=rt.fieldNormWeight}={}){this.norm=EJ(e,3),this.getFn=r,this.isCreated=!1,this.docs=[],this.keys=[],this._keysMap={},this.setIndexRecords()}setSources(r=[]){this.docs=r}setIndexRecords(r=[]){this.records=r}setKeys(r=[]){this.keys=r,this._keysMap={},r.forEach((e,t)=>{this._keysMap[e.id]=t})}create(){if(this.isCreated||!this.docs.length)return;this.isCreated=!0;let r=this.docs.length;this.records=new Array(r);let e=0;if(ji(this.docs[0]))for(let t=0;t<r;t++){let n=this._createStringRecord(this.docs[t],t);n&&(this.records[e++]=n)}else for(let t=0;t<r;t++)this.records[e++]=this._createObjectRecord(this.docs[t],t);this.records.length=e,this.norm.clear()}add(r,e){if(!Number.isInteger(e)||e<0)throw new Error(mP);if(ji(r)){let n=this._createStringRecord(r,e);return n&&this.records.push(n),n}let t=this._createObjectRecord(r,e);return this.records.push(t),t}removeAt(r){if(!Number.isInteger(r)||r<0)throw new Error(mP);for(let e=0,t=this.records.length;e<t;e+=1)if(this.records[e].i===r){this.records.splice(e,1);break}for(let e=0,t=this.records.length;e<t;e+=1)this.records[e].i>r&&(this.records[e].i-=1)}removeAll(r){let e=new Set;for(let n of r)Number.isInteger(n)&&n>=0&&e.add(n);if(e.size===0)return;this.records=this.records.filter(n=>!e.has(n.i));let t=Array.from(e).sort((n,i)=>n-i);for(let n of this.records){let i=0,o=t.length;for(;i<o;){let s=i+o>>>1;t[s]<n.i?i=s+1:o=s}n.i-=i}}getValueForItemAtKeyId(r,e){return r[this._keysMap[e]]}size(){return this.records.length}_createStringRecord(r,e){return!os(r)||r_(r)?null:{v:r,i:e,n:this.norm.get(r)}}_createObjectRecord(r,e){let t={i:e,$:{}};for(let n=0,i=this.keys.length;n<i;n++){let o=this.keys[n],s=o.getFn?o.getFn(r):this.getFn(r,o.path);if(os(s)){if(Pu(s)){let a=[];for(let l=0,c=s.length;l<c;l+=1){let u=s[l];if(os(u)){if(ji(u)){if(!r_(u)){let d={v:u,i:l,n:this.norm.get(u)};a.push(d)}}else if(os(u.v)){let d=ji(u.v)?u.v:fP(u.v);if(!r_(d)){let f={v:d,i:u.i,n:this.norm.get(d)};a.push(f)}}}}t.$[n]=a}else if(ji(s)&&!r_(s)){let a={v:s,n:this.norm.get(s)};t.$[n]=a}}}return t}toJSON(){return{keys:this.keys.map(({getFn:r,...e})=>e),records:this.records}}};sV={\u0142:"l",\u0141:"L",\u0111:"d",\u0110:"D",\u00F8:"o",\u00D8:"O",\u0127:"h",\u0126:"H",\u0167:"t",\u0166:"T",\u0131:"i",\u00DF:"ss"},SJ=new RegExp("["+Object.keys(sV).join("")+"]","g"),cy=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(SJ,e=>sV[e]):r=>r,EP=class{constructor(r,{location:e=rt.location,threshold:t=rt.threshold,distance:n=rt.distance,includeMatches:i=rt.includeMatches,findAllMatches:o=rt.findAllMatches,minMatchCharLength:s=rt.minMatchCharLength,isCaseSensitive:a=rt.isCaseSensitive,ignoreDiacritics:l=rt.ignoreDiacritics,ignoreLocation:c=rt.ignoreLocation}={}){if(this.options={location:e,threshold:t,distance:n,includeMatches:i,findAllMatches:o,minMatchCharLength:s,isCaseSensitive:a,ignoreDiacritics:l,ignoreLocation:c},r=a?r:r.toLowerCase(),r=l?cy(r):r,this.pattern=r,this.chunks=[],!this.pattern.length)return;let u=(f,p)=>{this.chunks.push({pattern:f,alphabet:kJ(f),startIndex:p})},d=this.pattern.length;if(d>32){let f=0,p=d%32,m=d-p;for(;f<m;)u(this.pattern.substr(f,32),f),f+=32;if(p){let v=d-32;u(this.pattern.substr(v),v)}}else u(this.pattern,0)}searchIn(r){let{isCaseSensitive:e,ignoreDiacritics:t,includeMatches:n}=this.options;if(r=e?r:r.toLowerCase(),r=t?cy(r):r,this.pattern===r){if(r.length<this.options.minMatchCharLength)return{isMatch:!1,score:1};let m={isMatch:!0,score:0};return n&&(m.indices=[[0,r.length-1]]),m}let{location:i,distance:o,threshold:s,findAllMatches:a,minMatchCharLength:l,ignoreLocation:c}=this.options,u=[],d=0,f=!1;this.chunks.forEach(({pattern:m,alphabet:v,startIndex:g})=>{let{isMatch:y,score:w,indices:x}=AJ(r,m,v,{location:i+g,distance:o,threshold:s,findAllMatches:a,minMatchCharLength:l,includeMatches:n,ignoreLocation:c});y&&(f=!0),d+=w,y&&x&&u.push(...x)});let p={isMatch:f,score:f?d/this.chunks.length:1};return f&&n&&(p.indices=xP(u)),p}},DJ=new Set(["fuzzy","include"]);hP=[{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 EP(r,{location:e.location??rt.location,threshold:e.threshold??rt.threshold,distance:e.distance??rt.distance,includeMatches:e.includeMatches??rt.includeMatches,findAllMatches:e.findAllMatches??rt.findAllMatches,minMatchCharLength:e.minMatchCharLength??rt.minMatchCharLength,isCaseSensitive:e.isCaseSensitive??rt.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics??rt.ignoreDiacritics,ignoreLocation:e.ignoreLocation??rt.ignoreLocation});return{type:"fuzzy",search(n){return t.searchIn(n)}}}}],QU=hP.length,PJ="\0",FJ="|";$J=class{constructor(r,{isCaseSensitive:e=rt.isCaseSensitive,ignoreDiacritics:t=rt.ignoreDiacritics,includeMatches:n=rt.includeMatches,minMatchCharLength:i=rt.minMatchCharLength,ignoreLocation:o=rt.ignoreLocation,findAllMatches:s=rt.findAllMatches,location:a=rt.location,threshold:l=rt.threshold,distance:c=rt.distance}={}){this.query=null,this.options={isCaseSensitive:e,ignoreDiacritics:t,includeMatches:n,minMatchCharLength:i,findAllMatches:s,ignoreLocation:o,location:a,threshold:l,distance:c},r=e?r:r.toLowerCase(),r=t?cy(r):r,this.pattern=r,this.query=RJ(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?cy(r):r;let o=0,s=[],a=0,l=!1;for(let c=0,u=e.length;c<u;c+=1){let d=e[c];s.length=0,o=0,l=!1;for(let f=0,p=d.length;f<p;f+=1){let m=d[f],{isMatch:v,indices:g,score:y}=m.search(r);if(v)o+=1,a+=y,IJ(m.type)&&(l=!0),t&&(DJ.has(m.type)?s.push(...g):s.push(g));else{a=0,o=0,s.length=0,l=!1;break}}if(o){let f={isMatch:!0,score:a/o};return l&&(f.hasInverse=!0),t&&(f.indices=xP(s)),f}}return{isMatch:!1,score:1}}},gP=[];s_={AND:"$and",OR:"$or"},vP={PATH:"$path",PATTERN:"$val"},yP=r=>!!(r[s_.AND]||r[s_.OR]),OJ=r=>!!r[vP.PATH],NJ=r=>!Pu(r)&&rV(r)&&!yP(r),JU=r=>({[s_.AND]:Object.keys(r).map(e=>({[e]:r[e]}))});BJ=class{constructor(r,e){this.limit=r,this.heap=[],this.comparator=e}get size(){return this.heap.length}insert(r){this.size<this.limit?(this.heap.push(r),this._bubbleUp(this.size-1)):this.comparator(r,this.heap[0])<0&&(this.heap[0]=r,this._sinkDown(0))}extractSorted(){return this.heap.sort(this.comparator)}_bubbleUp(r){let e=this.heap;for(;r>0;){let t=r-1>>1;if(this.comparator(e[r],e[t])<=0)break;let n=e[r];e[r]=e[t],e[t]=n,r=t}}_sinkDown(r){let e=this.heap,t=e.length,n=r;do{r=n;let i=2*r+1,o=2*r+2;if(i<t&&this.comparator(e[i],e[n])>0&&(n=i),o<t&&this.comparator(e[o],e[n])>0&&(n=o),n!==r){let s=e[r];e[r]=e[n],e[n]=s}}while(n!==r)}};qJ=/[\p{L}\p{M}\p{N}_]+/gu,eV=new WeakSet;HJ=class{static condition(r,e){return e.useTokenSearch}constructor(r,e){this.options=e,this.analyzer=wP({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 EP(o,{location:e.location,threshold:e.threshold,distance:e.distance,includeMatches:e.includeMatches,findAllMatches:e.findAllMatches,minMatchCharLength:e.minMatchCharLength,isCaseSensitive:e.isCaseSensitive,ignoreDiacritics:e.ignoreDiacritics,ignoreLocation:!0}));let s=n.get(o)||0,a=Math.log(1+(i-s+.5)/(s+.5));this.idfWeights.push(a)}this.combineAll=e.tokenMatch==="all",this.numTerms=this.termSearchers.length,this.useMask=this.numTerms<=31}searchIn(r){if(!this.termSearchers.length)return{isMatch:!1,score:1};let e=[],t=0,n=0,i=0,o=0,s=this.combineAll&&!this.useMask?new Set:null;for(let c=0;c<this.termSearchers.length;c++){let u=this.termSearchers[c].searchIn(r),d=this.idfWeights[c];n+=d,u.isMatch&&(i++,t+=d*(1-u.score),u.indices&&e.push(...u.indices),this.combineAll&&(this.useMask?o|=1<<c:s.add(c)))}if(i===0)return{isMatch:!1,score:1};let a=n>0?1-t/n:0,l={isMatch:!0,score:Math.max(.001,a)};return this.options.includeMatches&&e.length&&(l.indices=xP(e)),this.combineAll&&(this.useMask?l.matchedMask=o:l.matchedTerms=s,l.termCount=this.numTerms),l}};Fu=class{constructor(r,e,t){this.options={...rt,...e},this.options.useExtendedSearch,this.options.useTokenSearch,this._keyStore=new gJ(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=o_(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 CP))throw new Error(uJ);if(this._myIndex=e||oV(this.options.keys,this._docs,{getFn:this.options.getFn,fieldNormWeight:this.options.fieldNormWeight}),this.options.useTokenSearch){let t=wP({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});this._invertedIndex=jJ(this._myIndex.records,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}add(r){if(!os(r))return;this._docs.push(r);let e=this._myIndex.add(r,this._docs.length-1);if(this._invertedIndex&&e){let t=wP({isCaseSensitive:this.options.isCaseSensitive,ignoreDiacritics:this.options.ignoreDiacritics,tokenize:this.options.tokenize});GJ(this._invertedIndex,e,this._myIndex.keys.length,t)}this._invalidateSearcherCache()}remove(r=()=>!1){let e=[],t=[];for(let n=0,i=this._docs.length;n<i;n+=1)r(this._docs[n],n)&&(e.push(this._docs[n]),t.push(n));if(t.length){this._invertedIndex&&tV(this._invertedIndex,t);let n=new Set(t);this._docs=this._docs.filter((i,o)=>!n.has(o)),this._myIndex.removeAll(t),this._invalidateSearcherCache()}return e}removeAt(r){if(!Number.isInteger(r)||r<0||r>=this._docs.length)throw new Error(mP);this._invertedIndex&&tV(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(ji(r)&&!r.trim()){let f=this._docs.map((p,m)=>({item:p,refIndex:m}));return n_(t)&&t>-1&&(f=f.slice(0,t)),f}let l=o&&n_(t)&&t>0&&ji(r),c=s,u=(f,p)=>c(f,p)||f.idx-p.idx,d;if(l){let f=new BJ(t,u);ji(this._docs[0])?this._searchStringList(r,{heap:f,ignoreFieldNorm:a}):this._searchObjectList(r,{heap:f,ignoreFieldNorm:a}),d=f.extractSorted()}else d=ji(r)?ji(this._docs[0])?this._searchStringList(r):this._searchObjectList(r):this._searchLogical(r),LJ(d,{ignoreFieldNorm:a}),o&&d.sort(ji(r)?u:c),n_(t)&&t>-1&&(d=d.slice(0,t));return VJ(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(!os(a))return;let u=n.searchIn(a);if(u.isMatch){let d={score:u.score,value:a,norm:c,indices:u.indices};i&&(d.matchedMask=u.matchedMask,d.matchedTerms=u.matchedTerms,d.termCount=u.termCount);let f=[d];if(!i||this._coversAllTokens(f)){let p={item:a,idx:l,matches:f};e?(p.score=bP(p.matches,{ignoreFieldNorm:t}),e.insert(p)):s.push(p)}}}),s}_searchLogical(r){let e=aV(r,this.options),t=this._normalizedKeys(),n=(a,l,c)=>{if(!("children"in a)){let{keyId:p,searcher:m}=a,v;return p===null?(v=[],t.forEach((g,y)=>{v.push(...this._findMatches({key:g,value:l[y],searcher:m}))})):v=this._findMatches({key:this._keyStore.get(p),value:this._myIndex.getValueForItemAtKeyId(l,p),searcher:m}),v&&v.length?[{idx:c,item:l,matches:v}]:[]}let{children:u,operator:d}=a,f=[];for(let p=0,m=u.length;p<m;p+=1){let v=u[p],g=n(v,l,c);if(g.length)f.push(...g);else if(d===s_.AND)return[]}return f},i=this._myIndex.records,o=new Map,s=[];return i.forEach(({$:a,i:l})=>{if(os(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(!os(l))return;let u=[],d=!1,f=!1;if(s.forEach((p,m)=>{let v=this._findMatches({key:p,value:l[m],searcher:n});v.length?(u.push(...v),v[0].hasInverse&&(f=!0)):d=!0}),!(f&&d)&&u.length&&(!i||this._coversAllTokens(u))){let p={idx:c,item:l,matches:u};e?(p.score=bP(p.matches,{ignoreFieldNorm:t}),e.insert(p)):a.push(p)}}),a}_findMatches({key:r,value:e,searcher:t}){if(!os(e))return[];let n=[];if(Pu(e))e.forEach(({v:i,i:o,n:s})=>{if(!os(i))return;let a=t.searchIn(i);if(a.isMatch){let l={score:a.score,key:r,value:i,idx:o,norm:s,indices:a.indices,hasInverse:a.hasInverse};a.termCount!==void 0&&(l.matchedMask=a.matchedMask,l.matchedTerms=a.matchedTerms,l.termCount=a.termCount),n.push(l)}});else{let{v:i,n:o}=e,s=t.searchIn(i);if(s.isMatch){let a={score:s.score,key:r,value:i,norm:o,indices:s.indices,hasInverse:s.hasInverse};s.termCount!==void 0&&(a.matchedMask=s.matchedMask,a.matchedTerms=s.matchedTerms,a.termCount=s.termCount),n.push(a)}}return n}_coversAllTokens(r){let e=r.length?r[0].termCount:void 0;if(e===void 0)return!0;if(e<=31){let n=0;for(let i=0;i<r.length;i++)n|=r[i].matchedMask||0;return n===2**e-1}let t=new Set;for(let n=0;n<r.length;n++){let i=r[n].matchedTerms;if(i)for(let o of i)t.add(o)}return t.size===e}};Fu.version="7.5.0";Fu.createIndex=oV;Fu.parseIndex=TJ;Fu.config=rt;Fu.match=function(r,e,t){if(t&&t.useTokenSearch)throw new Error(hJ);return o_(r,{...rt,...t}).searchIn(e)};Fu.parseQuery=aV;TP($J);TP(HJ);Fu.use=function(...r){r.forEach(e=>TP(e))};Mu=Fu});var uy,_P,KJ,XJ,cV,uV,Cm,AP=b(()=>{uy=require("obsidian");a_();Fo();_P=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()}},KJ=20,XJ=100,cV=/\w/,uV={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}},Cm=class r{constructor(e,t){this.fileMap=new Map;this.recentFiles=new _P;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=uV;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 Mu([],{...n,threshold:.2}),this.fuseRelaxed=new Mu([],{...n,threshold:.4}),this.setupEventListeners(),this.effectiveWeights=uV}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 uy.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 uy.TFile&&e.extension==="md"&&this.addFile(e)})),this.plugin.registerEvent(this.app.vault.on("delete",e=>{e instanceof uy.TFile&&this.removeFile(e)})),this.plugin.registerEvent(this.app.vault.on("rename",(e,t)=>{e instanceof uy.TFile&&e.extension==="md"&&(this.removeFileByPath(t),this.addFile(e))}))}async ensureIndexed(){if(this.isIndexing&&this.indexPromise)return this.indexPromise;if(this.fileMap.size===0)return this.reindex()}scheduleReindex(){this.reindexTimeout!==null&&window.clearTimeout(this.reindexTimeout),this.reindexTimeout=window.setTimeout(()=>{this.reindex()},500)}async reindex(){if(this.isIndexing&&this.indexPromise)return this.indexPromise;this.isIndexing=!0,this.indexPromise=this.performReindex();try{await this.indexPromise}finally{this.isIndexing=!1,this.indexPromise=null}}async performReindex(){let e=new Map;this.reindexBuffer=e;try{let t=this.app.vault.getMarkdownFiles(),n=new Map;await(async(o,s=50)=>{for(let a=0;a<o.length;a+=s){let l=o.slice(a,a+s);for(let c of l){let u=this.createIndexedFile(c);n.set(c.path,u)}await new Promise(c=>window.setTimeout(c,0))}})(t),this.fileMap=n;for(let[o,s]of e)s.op==="remove"?this.fileMap.delete(o):s.file&&this.fileMap.set(o,this.createIndexedFile(s.file));this.updateFuseIndex(),this.updateUnresolvedLinks()}catch(t){try{this.updateFuseIndex()}catch{}throw t}finally{this.reindexBuffer=null}}extractAliases(e){if(!e)return[];let t=[];for(let[n,i]of Object.entries(e)){let o=n.toLowerCase();if(!(o!=="alias"&&o!=="aliases"))if(typeof i=="string"){let s=i.split(",").map(a=>a.trim()).filter(a=>a.length>0);t.push(...s)}else Array.isArray(i)&&t.push(...i.filter(s=>typeof s=="string").map(s=>s.trim()).filter(s=>s.length>0))}return t}createIndexedFile(e){let t=this.app.metadataCache.getFileCache(e),n=t?.frontmatter,i=this.extractAliases(n),o=i.map(c=>Rr(c)),s=(t?.headings??[]).map(c=>cP(c.heading)),a=[];if(t?.blocks)for(let c of Object.values(t.blocks))c.id&&a.push(c.id);let l=t?.tags?.map(c=>c.tag)??[];if(n?.tags){let c=Array.isArray(n.tags)?n.tags:[n.tags];l.push(...c.filter(u=>typeof u=="string"))}return{path:e.path,pathNormalized:Rr(e.path),basename:e.basename,basenameNormalized:Rr(e.basename),aliases:i,aliasesNormalized:o,headings:s,blockIds:a,tags:l,modified:e.stat.mtime,openedAt:this.recentFiles.peek(e.path),folder:e.parent?.path??""}}addFile(e){let t=this.createIndexedFile(e);this.fileMap.set(e.path,t),this.scheduleFuseUpdate(e.path,"add"),this.reindexBuffer?.set(e.path,{op:"upsert",file:e})}updateFile(e){let t=this.createIndexedFile(e);this.fileMap.set(e.path,t),this.scheduleFuseUpdate(e.path,"update"),this.unresolvedLinksDirty=!0,this.reindexBuffer?.set(e.path,{op:"upsert",file:e})}removeFile(e){this.removeFileByPath(e.path)}removeFileByPath(e){this.fileMap.delete(e),this.scheduleFuseUpdate(e,"remove"),this.reindexBuffer?.set(e,{op:"remove"})}updateFuseIndex(){let e=Array.from(this.fileMap.values());this.fuseStrict.setCollection(e),this.fuseRelaxed.setCollection(e)}scheduleFuseUpdate(e,t){if(this.isIndexing)return;let n=this.pendingFuseUpdates.get(e);if(n)if(n==="add"&&t==="remove"){this.pendingFuseUpdates.delete(e);return}else n==="remove"&&t==="add"?this.pendingFuseUpdates.set(e,"update"):this.pendingFuseUpdates.set(e,t);else this.pendingFuseUpdates.set(e,t);this.fuseUpdateTimeout!==null&&window.clearTimeout(this.fuseUpdateTimeout),this.fuseUpdateTimeout=window.setTimeout(()=>{this.processPendingFuseUpdates()},XJ)}processPendingFuseUpdates(){if(this.pendingFuseUpdates.size!==0){if(this.isIndexing){this.pendingFuseUpdates.clear();return}if(this.pendingFuseUpdates.size>KJ){this.updateFuseIndex(),this.pendingFuseUpdates.clear();return}for(let[e,t]of this.pendingFuseUpdates)switch(t){case"add":{this.fuseStrict.remove(i=>i.path===e),this.fuseRelaxed.remove(i=>i.path===e);let n=this.fileMap.get(e);n&&(this.fuseStrict.add(n),this.fuseRelaxed.add(n));break}case"update":{this.fuseStrict.remove(i=>i.path===e),this.fuseRelaxed.remove(i=>i.path===e);let n=this.fileMap.get(e);n&&(this.fuseStrict.add(n),this.fuseRelaxed.add(n));break}case"remove":{this.fuseStrict.remove(n=>n.path===e),this.fuseRelaxed.remove(n=>n.path===e);break}}this.pendingFuseUpdates.clear()}}updateUnresolvedLinks(){let e=this.app.metadataCache.unresolvedLinks;this.unresolvedLinks.clear();for(let t in e)for(let n in e[t])this.unresolvedLinks.add(n);this.unresolvedLinksDirty=!1}search(e,t={},n=50){this.unresolvedLinksDirty&&this.updateUnresolvedLinks();let i=[],o=Rr(e);if(e.includes("#"))return this.searchWithHeadings(e,t,n);let s=new Set,a=Array.from(this.fileMap.values());for(let c of a)c.basenameNormalized===o&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.basenameExact,"exact"),matchType:"exact",displayText:c.basename}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.aliasesNormalized.indexOf(o);u!==-1&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasExact,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path))}for(let c of a)c.basenameNormalized.startsWith(o)&&c.basenameNormalized!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.basenamePrefix,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path));for(let c of a)for(let[u,d]of c.aliasesNormalized.entries())d.startsWith(o)&&d!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasPrefix,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.basenameNormalized.indexOf(o);if(u>0){let d=c.basenameNormalized[u-1];cV.test(d)||(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.substringBasename,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path))}}let l=this.fuseStrict.search(o,{limit:n*2});l.length<this.effectiveWeights.thresholds.fuzzyRelaxCount&&(l=this.fuseRelaxed.search(o,{limit:n*2}));for(let c of l){if(!c||!c.item||!c.item.path||s.has(c.item.path))continue;let u=(c.matches??[]).find(m=>m.key==="aliasesNormalized"),d=!!u,f=d?"alias":"fuzzy",p=c.item.basename;if(d){let m=typeof u?.value=="string"?u.value:void 0,v=m?c.item.aliasesNormalized.findIndex(g=>g===m):c.item.aliasesNormalized.findIndex(g=>g.includes(o));v>=0&&(p=c.item.aliases[v])}i.push({file:c.item,score:this.calculateScore(c.item,e,t,(c.score??.5)+this.effectiveWeights.base.fuzzyMatch,f),matchType:f,displayText:p}),s.add(c.item.path)}if(e.length>=2){let c=0,u=e.length<3?10:20;for(let d of this.unresolvedLinks){if(c>=u)break;Rr(d).includes(o)&&(i.push({file:{path:d,pathNormalized:Rr(d),basename:d,basenameNormalized:Rr(d),aliases:[],aliasesNormalized:[],headings:[],blockIds:[],tags:[],modified:0,folder:""},score:this.effectiveWeights.base.unresolvedLink,matchType:"unresolved",displayText:d}),c++)}}return i.sort((c,u)=>c.score-u.score).slice(0,n)}calculateScore(e,t,n,i,o){let s=i;if(n.currentFolder&&e.folder===n.currentFolder&&(s+=this.effectiveWeights.boosts.sameFolder),e.openedAt&&(Date.now()-e.openedAt)/864e5<this.effectiveWeights.thresholds.recencyDays&&(s+=this.effectiveWeights.boosts.recency),n.currentFile){let d=this.fileMap.get(n.currentFile.path);if(d){let f=e.tags.filter(p=>d.tags.includes(p));f.length>0&&(s+=this.effectiveWeights.boosts.tagOverlap*Math.min(f.length,Math.abs(this.effectiveWeights.boosts.tagOverlapMax/this.effectiveWeights.boosts.tagOverlap)))}}let a=Rr(t),l=e.basename.length;if(o==="alias"&&e.aliases.length>0){let d=e.aliasesNormalized.findIndex(f=>f.includes(a));d>=0&&(l=e.aliases[d].length)}if(o==="alias"){let d=Math.max(0,(l-this.effectiveWeights.penalties.titleLengthThreshold)*this.effectiveWeights.penalties.aliasLengthMultiplier),f=Math.min(this.effectiveWeights.penalties.aliasMaxPenalty,this.effectiveWeights.penalties.aliasMinPenalty+d);s+=f}l>this.effectiveWeights.penalties.titleLengthThreshold&&(s+=(l-this.effectiveWeights.penalties.titleLengthThreshold)*this.effectiveWeights.penalties.titleLengthMultiplier);let c=e.basenameNormalized;if(o==="alias"&&e.aliases.length>0){let d=e.aliasesNormalized.findIndex(f=>f.includes(a));d>=0&&(c=e.aliasesNormalized[d])}let u=c.indexOf(a);return u>=0&&(s+=u*this.effectiveWeights.penalties.positionMultiplier),s}searchWithHeadings(e,t,n){let[i,o]=e.split("#"),s=Rr(o??""),a=[];if(i===""){let l=0,c=200,u=Array.from(this.fileMap.values());for(let d of u){if(l>=c)break;for(let f of d.headings){if(l>=c)break;Rr(f).includes(s)&&(a.push({file:d,score:this.calculateScore(d,e,t,.1),matchType:"heading",displayText:`${d.basename}#${f}`}),l++)}}}else{let l=this.searchFiles(i,t,n);if(l.length===0)return[];for(let c of l)for(let u of c.file.headings)Rr(u).includes(s)&&a.push({file:c.file,score:c.score+.05,matchType:"heading",displayText:`${c.file.basename}#${u}`})}return a.sort((l,c)=>l.score-c.score).slice(0,n)}searchFiles(e,t,n){let i=[],o=Rr(e),s=new Set,a=Array.from(this.fileMap.values());for(let c of a)c.basenameNormalized===o&&(i.push({file:c,score:this.calculateScore(c,e,t,-1e3,"exact"),matchType:"exact",displayText:c.basename}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.aliasesNormalized.indexOf(o);u!==-1&&(i.push({file:c,score:this.calculateScore(c,e,t,this.effectiveWeights.base.aliasExact,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path))}for(let c of a)c.basenameNormalized.startsWith(o)&&c.basenameNormalized!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,-500,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path));for(let c of a)for(let[u,d]of c.aliasesNormalized.entries())d.startsWith(o)&&d!==o&&!s.has(c.path)&&(i.push({file:c,score:this.calculateScore(c,e,t,-500,"alias"),matchType:"alias",displayText:c.aliases[u]}),s.add(c.path));for(let c of a){if(s.has(c.path))continue;let u=c.basenameNormalized.indexOf(o);if(u>0){let d=c.basenameNormalized[u-1];cV.test(d)||(i.push({file:c,score:this.calculateScore(c,e,t,-300,"fuzzy"),matchType:"fuzzy",displayText:c.basename}),s.add(c.path))}}let l=this.fuseStrict.search(o,{limit:n*2});l.length<this.effectiveWeights.thresholds.fuzzyRelaxCount&&(l=this.fuseRelaxed.search(o,{limit:n*2}));for(let c of l){if(!c||!c.item||!c.item.path||s.has(c.item.path))continue;let u=(c.matches??[]).find(m=>m.key==="aliasesNormalized"),d=!!u,f=d?"alias":"fuzzy",p=c.item.basename;if(d){let m=typeof u?.value=="string"?u.value:void 0,v=m?c.item.aliasesNormalized.findIndex(g=>g===m):c.item.aliasesNormalized.findIndex(g=>g.includes(o));v>=0&&(p=c.item.aliases[v])}i.push({file:c.item,score:this.calculateScore(c.item,e,t,(c.score??.5)+this.effectiveWeights.base.fuzzyMatch,f),matchType:f,displayText:p}),s.add(c.item.path)}return i.sort((c,u)=>c.score-u.score).slice(0,n)}getFile(e){return this.fileMap.get(e)}getHeadings(e){return e.headings}getBlockIds(e){return e.blockIds}getIndexedFileCount(){return this.fileMap.size}}});function dV(r){kP=r}function ri(){if(!kP)throw new Error("QuickAdd plugin instance accessed before it was initialised.");return kP}var kP,hl=b(()=>{});function QJ(r,e){let t=zr(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 l_,xm,SP=b(()=>{fl();l_=require("obsidian");Tt();AP();Fo();hl();fc();xm=class extends mn{constructor(t,n,i){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.sourcePathOverride=i?.sourcePath,this.fileIndex=Cm.getInstance(t,ri()),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=L2.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=Rr(i??""),a=[];if(o){let c=this.app.workspace.getActiveFile();if(c){let u=this.fileIndex.getFile(c.path);u&&(a=[u])}}else a=this.fileIndex.search(n,{},1).map(c=>c.file);if(a.length===0)return[];let l=[];for(let c of a){let d=this.fileIndex.getHeadings(c).filter(f=>i===""||Rr(f).includes(s)).slice(0,20);for(let f of d)l.push({file:c,score:0,matchType:"heading",displayText:o?`#${f}`:`${c.basename}#${f}`})}return l}getBlockSuggestions(t){let[n,i]=t.split("#^"),o=Rr(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===""||Rr(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=Rr(t);return n.filter(a=>i.includes(a.extension.toLowerCase())&&(t===""||Rr(a.basename).includes(o))).slice(0,20).map(a=>({file:{path:a.path,pathNormalized:Rr(a.path),basename:a.basename,basenameNormalized:Rr(a.basename),aliases:[],aliasesNormalized:[],headings:[],blockIds:[],tags:[],modified:a.stat.mtime,folder:this.normalizeFolderPath(a.parent?.path||"")},score:0,matchType:"exact",displayText:a.name}))}renderSuggestion(t,n){let{file:i,matchType:o,displayText:s}=t;n.classList.add("qaFileSuggestionItem"),n.classList.add(`qa-suggest-${o}`);let a=s,l="",c=!1,u="";switch(o){case"exact":a=i.basename,l=i.path;break;case"alias":a=s,l=i.path;break;case"fuzzy":a=i.basename,l=i.path;break;case"heading":{let[v,g]=s.split("#"),y=this.lastInput.includes("#")?this.lastInput.split("#")[1]:"",w=Rr(y??"");y&&Rr(g).includes(w)?(a=g,c=!0,u=y):a=g,l=v;break}case"block":{let[v,g]=s.split("#^");a=g,l=v;break}case"unresolved":a=s,l="Unresolved link";break}let d=zr(n,"div");d.className="qa-suggestion-content";let f=zr(n,"span");f.className="suggestion-main-text",c?this.renderMatch(f,a,u):f.textContent=a,d.appendChild(f);let p=QJ(n,o);p&&d.appendChild(p);let m=zr(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=ts(this.inputEl),o=()=>this.hideTooltip();i.addEventListener("scroll",o,{passive:!0}),this.scrollListener=o,this.scrollListenerDocument=i}}hideTooltip(){let t=ts(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=ts(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 l_.TFile))return null;let i=this.inputEl,o=zr(i,"div");o.className="qa-file-tooltip";let s=zr(i,"div");s.className="qa-tooltip-header",s.textContent=n.basename;let a=zr(i,"div");a.className="qa-tooltip-content";let l=zr(i,"div");l.textContent=`Path: ${n.path}`;let c=zr(i,"div");return c.textContent=`Modified: ${new Date(n.stat.mtime).toLocaleDateString()}`,a.append(l,c),o.append(s,a),o}positionTooltip(t,n){let i=n.getBoundingClientRect();t.style.left=`${i.right+10}px`,t.style.top=`${i.top}px`}close(){this.hideTooltip(),this.scrollListener&&this.scrollListenerDocument&&(this.scrollListenerDocument.removeEventListener("scroll",this.scrollListener),this.scrollListener=void 0,this.scrollListenerDocument=void 0),super.close()}selectSuggestion(t){if(this.inputEl.selectionStart===null)return;let n=this.inputEl.selectionStart,i=this.lastInput.length,o=this.inputEl.value,s=0,a=this.inputEl.value.slice(n-this.lastInput.length-3,n-this.lastInput.length)==="![[";if(t.matchType==="unresolved")s=this.makeLinkManually(o,t.displayText.replace(/.md$/,""),n,i);else if(t.matchType==="heading"||t.matchType==="block"){let l=t.displayText;s=this.makeLinkManually(o,l,n,i)}else if(a)s=this.makeLinkManually(o,t.displayText,n,i);else{let l=this.app.vault.getAbstractFileByPath(t.file.path);if(l instanceof l_.TFile){let c=t.matchType==="alias"?t.displayText:void 0;s=this.makeLinkObsidianMethod(l,o,n,i,c)}else s=this.makeLinkManually(o,t.displayText,n,i)}this.inputEl.trigger("input"),this.close(),this.inputEl.setSelectionRange(s,s)}makeLinkObsidianMethod(t,n,i,o,s){let a=this.app.vault.getAbstractFileByPath(t.path);if(!(a instanceof l_.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 pV,c_,fV=b(()=>{a_();pV={threshold:.4,includeScore:!0,keys:[""]},c_=class r{constructor(e,t){this.sortedTags=[];this.fuse=new Mu([],pV);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 Mu(this.sortedTags,pV)}getSortedTags(){return this.sortedTags}search(e){return this.fuse.search(e)}}});var Em,DP=b(()=>{Tt();fl();Fo();hl();fV();Em=class extends mn{constructor(t,n){super(t,n);this.app=t;this.inputEl=n;this.lastInput="";this.lastInputStart=0;this.lastInputLength=0;this.tagIndex=c_.getInstance(t,ri()),this.tagIndex.refresh()}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.slice(0,n),o=B2.exec(i);if(!o)return[];let s=i.lastIndexOf("[[");if(o.index===void 0)return[];if(s!==-1&&s<o.index)return[];let a=o[1];this.lastInput=a,this.lastInputStart=o.index,this.lastInputLength=o[0].length;let l=this.tagIndex.getSortedTags(),c=a.toLowerCase(),u=l.filter(m=>m.replace(/^#/,"").toLowerCase().startsWith(c)).slice(0,5),d=this.tagIndex.search(a).filter(m=>m.score!==void 0&&m.score<.8).map(m=>m.item).slice(0,10),f=new Set(u),p=[...u];for(let m of d)!f.has(m)&&p.length<15&&(p.push(m),f.add(m));return p}renderSuggestion(t,n){this.renderMatch(n,t,this.lastInput)}selectSuggestion(t){let n=this.inputEl;if(n.selectionStart===null)return;let i=this.lastInputStart,o=i+this.lastInputLength,s=t.startsWith("#")?t:`#${t}`;ZT(n,i,o,s,{fromCompletion:!0}),this.close()}}});var Gi,Tm=b(()=>{Gi=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 _m,IP=b(()=>{It();Tm();_m=class{constructor(e,t){this.store=Gi.getInstance();this.initialValue="";this.didChange=!1;this.draftKey=this.store.makeKey(e),this.shouldPersist=t??(()=>ce.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 u_(r,e){if(r.focus(),e?.cursorAtEnd){let t=r.value.length;r.setSelectionRange(t,t);return}r.select()}var PP=b(()=>{});function d_(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 FP=b(()=>{});function ZJ(r){return(r??"").trim().replace(/\\/g,"/")}function JJ(r){return r.startsWith("/")||/^[a-zA-Z]:/.test(r)}function eee(r){return r.split("/").some(e=>/^\.\.[. ]*$/u.test(e))}function Un(r){let e=ZJ(r);return e?JJ(e)||eee(e):!1}var Ec=b(()=>{});function tee(r){let e=t=>String(t).padStart(2,"0");return`${r.getFullYear()}-${e(r.getMonth()+1)}-${e(r.getDate())} ${e(r.getHours())}.${e(r.getMinutes())}.${e(r.getSeconds())}`}async function p_(r,e,t,n){let i=dy[t];if(!i)throw new Error(`Unsupported clipboard image type: ${t}`);let o=`Clipboard image ${tee(new Date)}.${i}`,s=await r.fileManager.getAvailablePathForAttachment(o,n||void 0);if(Un(s))throw new Error(`Refusing to save clipboard image outside the vault: '${s}'`);return r.vault.createBinary(s,e)}function f_(r,e,t){let n=r.fileManager.generateMarkdownLink(e,t);return n.startsWith("!")?n:`!${n}`}var dy,MP=b(()=>{Ec();dy=Object.assign(Object.create(null),{"image/png":"png","image/jpeg":"jpg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg"})});function Am(r,e,t={}){let n=t.sourcePath??"",i=null,o=!1,s=!1,a=()=>{s=!0},l=()=>{s=!1},c=d=>{let f=d.clipboardData;if(!f||s||f.getData("text/plain").length>0)return;let p=nee(f);if(p.length!==0){if(d.preventDefault(),i){new m_.Notice("QuickAdd: an image is still being saved \u2014 paste again in a moment.");return}i=u(p).finally(()=>{i=null})}};async function u(d){let f=e.readOnly;e.readOnly=!0,e.setAttribute("aria-busy","true"),e.classList.add("qa-image-paste-busy");let p=[];try{for(let m of d){let v=await m.file.arrayBuffer(),g=await ree(()=>p_(r,v,m.mimeType,n));p.push(f_(r,g,n))}}catch(m){F.logError(`Failed to save pasted image: ${m instanceof Error?m.message:String(m)}`),new m_.Notice("QuickAdd: failed to save pasted image.")}finally{e.readOnly=f,e.removeAttribute("aria-busy"),e.classList.remove("qa-image-paste-busy")}if(!(p.length===0||o))try{iee(e,p.join(e.tagName==="TEXTAREA"?`
|
||
`:" "))}catch(m){F.logError(`Failed to insert pasted image link: ${m instanceof Error?m.message:String(m)}`),new m_.Notice("QuickAdd: saved the pasted image but could not insert its link.")}}return e.addEventListener("paste",c),e.addEventListener("compositionstart",a),e.addEventListener("compositionend",l),{isBusy:()=>i!==null,whenIdle:()=>i??Promise.resolve(),detach:()=>{o=!0,e.removeEventListener("paste",c),e.removeEventListener("compositionstart",a),e.removeEventListener("compositionend",l)}}}function ree(r){let e=mV.then(r,r);return mV=e.catch(()=>{}),e}function hV(r){return Object.hasOwn(dy,r)}function nee(r){let e=[];for(let t of Array.from(r.items??[])){if(t.kind!=="file"||!hV(t.type))continue;let n=t.getAsFile();n&&e.push({file:n,mimeType:t.type})}if(e.length>0)return e;for(let t of Array.from(r.files??[]))hV(t.type)&&e.push({file:t,mimeType:t.type});return e}function iee(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 m_,mV,h_=b(()=>{m_=require("obsidian");Me();MP();mV=Promise.resolve()});function RP(r){return!r.isComposing&&r.key==="Enter"&&r.shiftKey&&(r.ctrlKey||r.metaKey)}var km,Sr,zs=b(()=>{km=require("obsidian");SP();DP();IP();PP();FP();h_();Wr();Sr=class r extends km.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&RP(t)){t.preventDefault(),this.skip();return}!t.isComposing&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new _m({kind:"single",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new xm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Em(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,d_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}get isOptionalPrompt(){return this.options?.optional===!0}createInputField(t,n,i){let o=new km.TextComponent(t);return o.inputEl.setCssStyles({width:"100%"}),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.options?.imagePaste&&(this.imagePasteHandle=Am(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new km.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marginTop:"1rem",gap:"0.5rem"})}transformInputOnSubmit(t){return t}submit(){if(this.didSubmit||this.didClose)return;if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}let t=this.inputComponent?.inputEl?.value??this.input;this.input=this.transformInputOnSubmit(t),this.didSubmit=!0,this.close()}skip(){this.input="",this.didSubmit=!0,this.close()}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise(tn())}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)}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback),this.imagePasteHandle?.detach()}onOpen(){super.onOpen(),u_(this.inputComponent.inputEl,this.options)}onClose(){this.didClose=!0,this.didSubmit||this.syncInputFromEl(),this.persistDraft(),this.resolveInput(),this.removeInputListener(),this.fileSuggester?.destroy(),this.tagSuggester?.destroy(),super.onClose()}}});var Dm,fy,v_=b(()=>{Me();Dm=r=>{F.logWarning(r)},fy=()=>{}});function fee(r,e){let t=Math.min(r.length,e.length),n=0;for(;n<t&&r[n]===e[n];)n++;return n}function vV(r,e,t){if(r===e)return 0;if(Math.abs(r.length-e.length)>t||r.length>64||e.length>64)return t+1;let n=[],i=Array.from({length:e.length+1},(s,a)=>a),o=[];for(let s=1;s<=r.length;s++){o=new Array(e.length+1),o[0]=s;let a=o[0];for(let l=1;l<=e.length;l++){let c=r[s-1]===e[l-1]?0:1,u=Math.min(i[l]+1,o[l-1]+1,i[l-1]+c);s>1&&l>1&&r[s-1]===e[l-2]&&r[s-2]===e[l-1]&&(u=Math.min(u,n[l-2]+1)),o[l]=u,u<a&&(a=u)}if(a>t)return t+1;n=i,i=o}return i[e.length]}function yV(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:vV(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:fee(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:vV(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 bV=b(()=>{});function b_(r,e){return r.length<=e?r:`${r.slice(0,e)}\u2026`}function hee(r){let e=r.map(t=>`"${t}"`);return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} or ${e[e.length-1]}`}function wV(r,e){let t=b_(r,32),n=`{{FIELD:${b_(e,48)}}}`,i=mee.get(r);if(i)return`Unknown FIELD filter "${t}" - ${i}. Ignored in ${n}.`;let o=yV(r,y_);return o.length>0?`Unknown FIELD filter "${t}" - did you mean ${hee(o)}? Ignored in ${n}.`:`Unknown FIELD filter "${t}" in ${n} was ignored. Supported filters: ${y_.join(", ")}.`}function gee(r,e){let t=b_(r,32);return`FIELD filter "${t}" needs a value - write "${t}:value". Ignored in {{FIELD:${b_(e,48)}}}.`}function vee(r,e,t){(t.warn??Dm)(wV(r,e))}var y_,mee,Yi,Ru=b(()=>{v_();op();bV();y_=["folder","tag","inline","inline-code-blocks","exclude-folder","exclude-tag","exclude-file","default","default-from","default-empty","default-always","case-sensitive","multi"],mee=new Map([["case-insensitive",'matching is already case-insensitive; use "case-sensitive:true" to match exactly']]);Yi=class{static parse(e,t){let n=Ls(e).map(a=>a.trim()),i=n[0],o={},s=!1;for(let a=1;a<n.length;a++){let l=n[a];if(l.toLowerCase()==="multi"){s=!0;continue}let c=fo(l);if(!c){let f=l.toLowerCase();t?.warnUnknown&&f&&(t.warn??Dm)(y_.includes(f)?gee(f,e):wV(f,e));continue}let u=c.key,d=c.value;if(!y_.includes(u)){t?.warnUnknown&&vee(u,e,t);continue}switch(u){case"multi":s=Tu(d);break;case"folder":o.folders||(o.folders=[]),o.folders.push(d),o.folder||(o.folder=d);break;case"tag":{o.tags||(o.tags=[]);let f=d.startsWith("#")?d.substring(1):d;o.tags.push(f);break}case"inline":o.inline=d.toLowerCase()==="true";break;case"inline-code-blocks":o.inlineCodeBlocks||(o.inlineCodeBlocks=[]),o.inlineCodeBlocks.push(...d.split(",").map(f=>f.trim().toLowerCase()).filter(f=>f.length>0));break;case"default":o.defaultValue=d;break;case"default-from":o.defaultFrom=d.toLowerCase();break;case"default-empty":o.defaultEmpty=d.toLowerCase()==="true";break;case"default-always":o.defaultAlways=d.toLowerCase()==="true";break;case"case-sensitive":o.caseSensitive=d.toLowerCase()==="true";break;case"exclude-folder":o.excludeFolders||(o.excludeFolders=[]),o.excludeFolders.push(d);break;case"exclude-tag":{o.excludeTags||(o.excludeTags=[]);let f=d.startsWith("#")?d.substring(1):d;o.excludeTags.push(f);break}case"exclude-file":o.excludeFiles||(o.excludeFiles=[]),o.excludeFiles.push(d);break}}return s?{fieldName:i,filters:o,multiSelect:s}:{fieldName:i,filters:o}}}});function $P(r){return r.replace(/^\/+|\/+$/g,"")}function my(r,e=t=>t){return JSON.stringify([...r].map(e).sort())}function CV(r,e){let t=[`folder=${$P(r)}`];return e.folders?.length&&t.push(`folders=${my(e.folders,$P)}`),e.tags?.length&&t.push(`tags=${my(e.tags)}`),e.excludeFolders?.length&&t.push(`xfolder=${my(e.excludeFolders,$P)}`),e.excludeTags?.length&&t.push(`xtag=${my(e.excludeTags)}`),e.excludeFiles?.length&&t.push(`xfile=${my(e.excludeFiles)}`),t.join("|")}function bee(r){let{folderPath:e,mode:t,label:n,optional:i,allowCustomInput:o,multiSelect:s,filter:a}=r,l=[CV(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 w_(r){if(!r)return null;let e=Ls(r),t=(e.shift()??"").trim();if(!t)return null;let n=e,i=ka(n,"optional");n=i.remaining;let o=i.found,s=ka(n,"custom");n=s.remaining;let a=s.found,l=ka(n,"multi");n=l.remaining;let c=l.found,u="name",d=[];for(let w of n){let x=w.trim().toLowerCase();if(yee.has(x)){u=x;continue}d.push(w)}let f,p;for(let w of d){let x=fo(w);x&&(x.key==="label"&&x.value?f=x.value:x.key==="name"&&x.value&&(p=x.value))}let m=Yi.parse(r),v=c||(m.multiSelect??!1),g={folder:t,tags:m.filters.tags,excludeFolders:m.filters.excludeFolders,excludeTags:m.filters.excludeTags,excludeFiles:m.filters.excludeFiles},y=p?`${hy}name=${p}|${CV(t,g)}${v?"|multi":""}`:`${hy}${bee({folderPath:t,mode:u,label:f,optional:o,allowCustomInput:a,multiSelect:v,filter:g})}`;return{raw:r,folderPath:t,mode:u,label:f,aliasName:p,optional:o,allowCustomInput:a,filter:g,multiSelect:v,variableKey:y}}function xV(r,e){if(!r)return r;for(let t of e)if(r===t)return r;return`${as}${r}`}function gp(r){return typeof r!="string"||r===""?{kind:"empty"}:r.startsWith(as)?{kind:"custom",text:r.slice(as.length)}:r.startsWith(gl)?{kind:"file",path:r.slice(gl.length)}:{kind:"raw",value:r}}function Im(r){return(r.split("/").pop()??r).replace(/\.(md|canvas|base)$/i,"")}function EV(r){return typeof r=="string"&&r.trim().length>0?r.trim():void 0}function wee(r){if(!r)return;let e=Object.entries(r).find(([t])=>t.toLowerCase()==="title");return e?EV(e[1]):void 0}function Cee(r){let e=r?.headings?.find(t=>t.level===1);return EV(e?.heading)}function xee(r){let e=r.parent?.path;return e&&e!=="/"?e:r.path.includes("/")?r.path.slice(0,r.path.lastIndexOf("/")):"vault root"}function Eee(r){return r.basename?r.basename:Im(r.path)}function OP(r,e){let t=r.map(i=>{let o=e?.(i)??null,s=Eee(i),a=wee(o?.frontmatter)??Cee(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} - ${xee(i)}`;return{primary:o,secondary:i.path,label:a}})}function Tc(r,e){return OP(r,e).map(t=>t.label)}var hy,gl,as,yee,Hs=b(()=>{Ru();op();hy="FILE:",gl="@file:",as="@filecustom:",yee=new Set(["name","link","path"])});function _V(r,e,t){return Array.isArray(r)?r.map(n=>TV(n,e,t)):TV(r,e,t)}function TV(r,e,t){if(e==="link")return t(r);let n=gp(r);switch(n.kind){case"empty":return"";case"file":return e==="path"?n.path:Im(n.path);case"custom":case"raw":return n.kind==="custom"?n.text:n.value}}var AV=b(()=>{Hs()});function Dee(r){return Aee.test(r.trim())}function Iee(r){let e=r.replace(kee,"");return e===r?!1:!See.test(e)}function C_(r,e){return Tee.has(r)?Iee(e):Dee(e)}function x_(r){return r==="noteTitle"||r==="captureTarget"||r==="folder"||r==="templatePath"||r==="lineTarget"||r==="filePath"}function NP(r){return r!=="templatePath"&&r!=="generic"}function E_(r,e){if(r==="generic")return{};let t=_ee[r];return e?{title:t.ask,placeholder:t.hint}:{placeholder:t.partOf}}function Pee(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=`${kV}/${n}`;return s.length<r.length?s:r}let o=`${t[0]}/${kV}/${n}`;return o.length<r.length?o:r}function gy(r,e,t){if(!r)return;let n=[],i=r.choiceName?.trim();i&&i!==e?.trim()&&n.push(i);let o=t?.showDestination===!1?void 0:r.destination?.trim();if(o){let s=t?.elide===!1?o:Pee(o);n.push(`\u2192 ${r.destinationKind==="folder"?`${s}/`:s}`)}return n.length?n.join(" "):void 0}var Tee,_ee,Aee,kee,See,kV,vy=b(()=>{Tt();Tee=new Set(["captureText"]),_ee={noteTitle:{ask:"Note title",hint:"Title for the new note",partOf:"Part of the new note's title"},captureTarget:{ask:"Capture target",hint:"Where to capture to",partOf:"Part of the capture destination"},captureText:{ask:"Text to capture",hint:"Text to add to the note",partOf:"Part of the text added to the note"},noteBody:{ask:"Note content",hint:"Text inserted into the note",partOf:"Part of the text inserted into the note"},folder:{ask:"Folder",hint:"Folder for the new note",partOf:"Part of the folder path"},templatePath:{ask:"Template",hint:"Path to the template file",partOf:"Part of the template path"},lineTarget:{ask:"Line to find",hint:"Existing line to anchor the capture to",partOf:"Part of the line to find"},filePath:{ask:"File to open",hint:"Path to the file to open",partOf:"Part of the file path"}},Aee=new RegExp(`^(?:${uc.source})$`,"i"),kee=new RegExp(uc.source,"gi"),See=/\{\{[^}\n\r]*\}\}/;kV="\u2026"});function T_(r){let t=/^(\s*---\r?\n)([\s\S]*?)(\r?\n(?:---|\.\.\.)\s*(?:\r?\n|$))/.exec(r);return t?[0,t[0].length]:null}function __(r,e,t,n){let[i,o]=n??[Number.NaN,Number.NaN];if(!(n!==null&&e>=i&&e<=o))return{isInYaml:!1,isQuoted:!1,lineStart:0,lineEnd:0,baseIndent:"",isKeyValuePosition:!1,isListItemPosition:!1};let a=r.lastIndexOf(`
|
||
`,e-1)+1,l=r.indexOf(`
|
||
`,Math.max(e,t)),c=l===-1?r.length:l,u=r.slice(a,e),d=r.slice(t,c),f=(u.match(/^\s*/)||[""])[0],p=r[e-1]==='"'&&r[t]==='"'||r[e-1]==="'"&&r[t]==="'",m=u.replace(/["']$/,""),g=d.replace(/^["']/,"").replace(/\s+#.*$/,"").trim().length===0,y=/:\s*$/.test(m)&&g,w=/^\s*-\s*$/.test(m)&&g;return{isInYaml:!0,isQuoted:p,lineStart:a,lineEnd:c,baseIndent:f,isKeyValuePosition:y,isListItemPosition:w}}var LP=b(()=>{});function yy(r,e){if(!r||!e)return null;let t=r,n=t.metadataTypeManager??t.metadataCache?.app?.metadataTypeManager;if(!n||typeof n.getTypeInfo!="function")return null;let i=n.getTypeInfo(e),o=i?.expected?.type??i?.inferred?.type;return typeof o=="string"?o:null}function Ree(r){return r!==null&&Fee.has(r.toLowerCase())}function SV(r,e){return Mee.has(e.toLowerCase())||Ree(yy(r,e))}var Fee,Mee,A_=b(()=>{Fee=new Set(["aliases","list","multitext","tags"]),Mee=new Set(["aliases","cssclasses","tags"])});function $ee(r,e=","){let t=[],n="",i=[],o=null;for(let a=0;a<r.length;a++){let l=r[a];if(o){if(n+=l,l===o){let c=0;for(let u=a-1;u>=0&&r[u]==="\\";u--)c++;c%2===0&&(o=null)}continue}if(l==='"'){o=l,n+=l;continue}if(l in DV){i.push(DV[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 Oee(r){return r.includes(`
|
||
`)?r.replace(/\r?\n/g,`
|
||
`):r.includes("\\n")?r.replace(/\\n/g,`
|
||
`):r}function Nee(r){if(!r)return!1;let e=r.toLowerCase();return e==="list"||e==="tags"||e==="multitext"}function IV(r,e){let t=r.trim();if(!t)return;let n=Oee(t),i=e?.propertyType??yy(e?.app,e?.propertyKey),o=Nee(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=$ee(n);if(u.length>1)return u}}var DV,PV=b(()=>{A_();DV={"[":"]","(":")","{":"}","<":">"}});function k_(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 BP(r){return typeof r!="string"&&(Array.isArray(r)||typeof r=="object"&&r!==null||typeof r=="number"||typeof r=="boolean"||r===null)}function FV(r){return Array.isArray(r)||typeof r=="object"&&r!==null}function S_(r){if(BP(r))return Array.isArray(r)?"[]":r===null?"null":typeof r=="object"?"{}":String(r)}var by=b(()=>{});var MV,Fa,D_=b(()=>{LP();PV();by();A_();MV="\0",Fa=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=T_(t),u=__(t,n,i,c);if(!u.isInYaml)return;let d=t.slice(u.lineStart,u.lineEnd),f=d.trim(),p=d.match(/^\s*([^:]+):/),m=p?p[1].trim():s,v=/^-\s*['"]?\{\{(?:VALUE|FIELD|FILE):[^}]+\}\}['"]?\s*$/i,g=null;if(u.isKeyValuePosition?g=[m]:v.test(f)&&(g=this.findListParentPath(t,u.lineStart,u.baseIndent??"")),!g||g.length===0)return;let y=g[g.length-1],w=o;if(l&&typeof o=="string"){let C=IV(o,this.buildParseOptions(y));C!==void 0&&(w=C)}if(!BP(w)||!l&&!FV(w))return;let x=g.join(MV);return this.map.set(x,w),w}drain(){let e=new Map(this.map);return this.map.clear(),e}merge(e){for(let[t,n]of e)this.map.set(t,n)}buildParseOptions(e){return{propertyKey:e,propertyType:this.resolvePropertyType(e),app:this.app}}findListParentPath(e,t,n){let i=t-1,o=[],s=n.length;for(;i>=0;){let a=e.lastIndexOf(`
|
||
`,i),l=a===-1?0:a+1,c=e.slice(l,i+1),u=c.trim();if(u.length===0){i=l-2;continue}if(u==="---"||u==="...")break;if(u.startsWith("-")){i=l-2;continue}let d=c.match(/^(\s*)([^:\n]+):/);if(d){let p=(d[1]??"").length;if(p<s&&(o.unshift(d[2].trim()),s=p,s===0))break}i=l-2}return o.length>0?o:null}resolvePropertyType(e){if(!this.app)return null;if(this.propertyTypeCache.has(e))return this.propertyTypeCache.get(e)??null;let t=yy(this.app,e);return this.propertyTypeCache.set(e,t),t}};Fa.PATH_SEPARATOR=MV});function Pm(r){return Lee.has(r.toUpperCase())}var I_,P_,F_,Lee,M_=b(()=>{I_=new RegExp("[\0-]","u"),P_=/[\\/:*?"<>|]/u,F_=/[. ]$/u,Lee=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 RV(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 WP(r){return RV(r)!==null}function UP(r){if(!r)return r;let e=r.toLowerCase();return e.slice(0,1).toUpperCase()+e.slice(1)}function VP(r){return/\p{L}/u.test(r)?/\p{Lu}/u.test(r)&&!/\p{Ll}/u.test(r):!1}function R_(r){return/\p{Lu}/u.test(r)&&/\p{Ll}/u.test(r)}function Bee(r){return/^\p{Ll}/u.test(r)&&R_(r)}function Uee(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 Vee(r){return r.split(/[^\p{L}\p{N}\p{M}]+/gu).filter(Boolean).flatMap(Uee).filter(Boolean)}function $_(r,e){let t=RV(e);if(!t)return r;if(t==="lower")return r.toLowerCase();if(t==="upper")return r.toUpperCase();let n=Vee(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?Bee(i)?i:i.toLowerCase():"",a=o.map(l=>VP(l)||R_(l)?l:UP(l));return[s,...a].join("")}case"pascal":return n.map(i=>VP(i)||R_(i)?i:UP(i)).join("");case"title":return n.map(i=>VP(i)||R_(i)?i:UP(i)).join(" ");case"slug":{let i=n.map(o=>o.toLowerCase()).join("-");return Pm(i)?`${i}-`:i}default:return r}}var qP,O_=b(()=>{M_();qP=["kebab","snake","camel","pascal","title","lower","upper","slug"]});function zP(r){return`"${r.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t")}"`}function HP(r,e,t){let n=__(r,e,t,T_(r));return!n.isInYaml||n.isQuoted?!1:n.isKeyValuePosition||n.isListItemPosition}var $V=b(()=>{LP()});function N_(r){let e=r.trim();return e&&(/^\[\[.*\]\]$/.test(e)?e:`[[${e}]]`)}var jP=b(()=>{});function zee(r,e,t){return t&&e?`${r}${GP}${e}`:r}function Cy(r){let e=r.indexOf(GP);return e===-1?r:r.slice(0,e)}function Hee(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 U_(r,e){if(!e)return null;let t=[e],n=Cy(e);n!==e&&t.push(n);for(let i of t){if(r.has(i)&&r.get(i)!==void 0)return i;let o=Hee(r,i);if(o)return o}return null}function jee(r){let{remaining:e,found:t}=ka(r,"optional");return{remaining:e,optional:t}}function BV(r){let{remaining:e,optional:t}=jee(r),{remaining:n,found:i}=ka(e,"trim");return{remaining:n,optional:t,trim:i}}function Gee(r,e){let t=r.trim();if(!t)return!1;let n=fo(t);return n?(e?YP:B_).has(n.key):!1}function Yee(r,e){let t=e?YP:B_;return r.some(n=>{let i=fo(n.trim());if(!i||i.key!=="type"||!t.has("type"))return!1;let o=i.value.trim().toLowerCase();return o==="number"||o==="slider"})}function UV(r,e,t,n,i){if(r.length===0)return{defaultValue:"",allowCustomInput:!1,usesOptions:!1};let o=t?YP:B_,s=Yee(r,t),a=r.some(V=>Gee(V,t)||s&&OV.has(fo(V.trim())?.key??"")),l=e&&r.some(V=>V.trim().toLowerCase()==="custom"),c=e&&r.some(V=>V.trim().toLowerCase()==="multi");if(!(a||l||c))return{defaultValue:r.join("|").trim(),allowCustomInput:!1,usesOptions:!1};let d,f,p="",m=!1,v,g,y,w,x,C,_,E,D=!1,P;for(let V of r){let j=V.trim();if(!j)continue;if(e&&j.toLowerCase()==="custom"){m=!0;continue}if(e&&j.toLowerCase()==="multi"){D=!0;continue}let oe=fo(j);if(!oe)continue;let{key:se,value:M}=oe;if(!(!o.has(se)&&!(s&&OV.has(se))))switch(se){case"label":M&&(d=M);break;case"case":M&&(f=M);break;case"default":p=M;break;case"custom":m=Tu(M);break;case"type":M&&(v=M);break;case"min":g=M;break;case"max":y=M;break;case"step":w=M;break;case"text":x=M;break;case"optional":C=Tu(M);break;case"trim":_=Tu(M);break;case"multi":D=!0,P=M.trim().toLowerCase()==="linklist"?"linklist":"text";break;case"name":M?E=M:i(`QuickAdd: empty |name: ignored in "${n}"; provide a variable name, e.g. {{VALUE:a,b|name:category}}.`);break;default:break}}return{label:d,caseStyle:f,defaultValue:p,allowCustomInput:m,name:E,usesOptions:!0,inputTypeOverride:v,minRaw:g,maxRaw:y,stepRaw:w,displayValuesRaw:x,optionalExplicit:C,trimExplicit:_,multiSelect:D,multiEmit:P}}function VV(r,{tokenDisplay:e,hasOptions:t,allowCustomInput:n},i){if(!r)return;let o=r.trim().toLowerCase(),s=o==="boolean"?"checkbox":o;if(!qee.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 Fm(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 Kee(r){return r.minRaw!==void 0||r.maxRaw!==void 0||r.stepRaw!==void 0}function NV(r,e,t){let n=Fm(r.minRaw),i=Fm(r.maxRaw),o=Fm(r.stepRaw),s={};return r.minRaw!==void 0&&(n===void 0?t(`QuickAdd: Ignoring invalid min in VALUE token "${e}".`):s.min=n),r.maxRaw!==void 0&&(i===void 0?t(`QuickAdd: Ignoring invalid max in VALUE token "${e}".`):s.max=i),s.min!==void 0&&s.max!==void 0&&s.max<s.min&&(t(`QuickAdd: Ignoring invalid numeric range in VALUE token "${e}"; max must be greater than or equal to min.`),delete s.min,delete s.max),r.stepRaw!==void 0&&(o===void 0||o<=0?t(`QuickAdd: Ignoring invalid step in VALUE token "${e}"; step must be greater than 0.`):s.step=o),Object.keys(s).length>0?s:void 0}function qV(r,e,t,n){if(t!=="number"&&t!=="slider")return Kee(r)&&n(`QuickAdd: Ignoring numeric range options in "${e}" because type is not number or slider.`),{inputTypeOverride:t};if(t!=="slider"){let c=NV(r,e,n);return{inputTypeOverride:t,numericConfig:c}}let i=Fm(r.minRaw),o=Fm(r.maxRaw),s=r.stepRaw===void 0?1:Fm(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:NV(r,e,fy)};let l={min:i,max:o,step:s};return{inputTypeOverride:t,numericConfig:l,sliderConfig:l}}function LV(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 Xee(r,e){return String(Number(r.toFixed(e)))}function Ma(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(LV(a),LV(e.step));return Xee(s,c)}return String(s)}function xy(r,e){return Ma(r,e)||String(e.min)}function L_(r){return r!==void 0&&Qee.has(r)}function wy(r){let e=[],t="",n=!1;for(let i=0;i<r.length;i++){let o=r[i];if(n){if(L_(o)){if(L_(r[i+1])){t+='"',i++;continue}let s=i+1;for(;s<r.length&&Zee.test(r[s]);)s++;if(s>=r.length||r[s]===","){n=!1,i=s-1;continue}return r.split(",")}t+=o;continue}if(o===","){e.push(t),t="";continue}if(L_(o)&&t.trim()===""){n=!0,t="";continue}t+=o}return n?r.split(","):(e.push(t),e)}function KP(r){let e=r.trim();if(!L_(e[0]))return r;let t=wy(e);return t.length===1&&t[0]!==e?t[0].trim():r}function Ey(r,e){if(!r)return null;let t=e?.warn??Dm,n=Ls(r),i=(n.shift()??"").trim();if(!i)return null;let o=wy(i).map(V=>V.trim()).filter(Boolean),s=o.length>1,{remaining:a,optional:l,trim:c}=BV(n),u=`{{VALUE:${r}}}`,d=UV(a,s,!0,u,t),{label:f,caseStyle:p,defaultValue:m,allowCustomInput:v}=d,g=d.multiSelect??!1,y=d.multiEmit??"text",w=d.optionalExplicit??l,x=d.trimExplicit??c;if(!d.usesOptions){let V=m;v=s&&V.toLowerCase()==="custom",m=v?"":V}s&&m&&(m=KP(m));let C=VV(d.inputTypeOverride,{tokenDisplay:u,hasOptions:s,allowCustomInput:v},t),_=qV(d,u,C,t),E;if(d.displayValuesRaw!==void 0){if(!s)throw new Error(`QuickAdd: VALUE option "text" is only supported for option-list tokens in "${u}".`);if(E=wy(d.displayValuesRaw).map(V=>V.trim()).filter(Boolean),E.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(E).size!==E.length)throw new Error(`QuickAdd: VALUE token "${u}" has duplicate text entries. Text entries must be unique.`)}let D=d.name?.trim()||void 0;D&&D.includes(GP)&&(t(`QuickAdd: |name in "${u}" contains a reserved control character and was ignored.`),D=void 0),D&&Wee.has(D.toLowerCase())&&(t(`QuickAdd: |name:${D} is reserved and was ignored in "${u}". Choose a different name.`),D=void 0),D&&!s&&t(`QuickAdd: |name on a single value in "${u}" is redundant \u2014 use {{VALUE:${D}}} directly.`),p&&!WP(p)&&(t(`QuickAdd: Unsupported |case style "${p}" in token "${u}". Supported styles: ${qP.join(", ")}.`),p=void 0),g&&!s&&(t(`QuickAdd: |multi needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),g=!1),g&&p&&(t(`QuickAdd: |case is ignored with |multi in "${u}" \u2014 a list is not case-transformed.`),p=void 0),!s&&!d.usesOptions&&a.some(V=>V.trim().toLowerCase()==="custom")&&(t(`QuickAdd: |custom needs an option list (2+ comma-separated values) in "${u}"; ignoring.`),m.toLowerCase()==="custom"&&(m=""));let P=D||zee(i,f,s);return{raw:r,variableName:i,aliasName:D,variableKey:P,label:f,caseStyle:p,defaultValue:m,allowCustomInput:v,suggestedValues:o,displayValues:E,hasOptions:s,inputTypeOverride:_.inputTypeOverride,numericConfig:_.numericConfig,sliderConfig:_.sliderConfig,optional:w,trim:x,multiSelect:g,multiEmit:y}}function XP(r,e){let t=e?.warn??Dm,n=VB(r),i=Ls(n).map(v=>v.trim()).filter(Boolean),{remaining:o,optional:s,trim:a}=BV(i);if(o.length===0)return{defaultValue:"",optional:s,trim:a};let l=`{{VALUE${r}}}`,c=UV(o,!1,!1,l,t);if(c.displayValuesRaw!==void 0)throw new Error(`QuickAdd: VALUE option "text" is only supported for option-list tokens in "${l}".`);let{label:u,caseStyle:d,defaultValue:f}=c;c.usesOptions||(f=f.trim()),d&&!WP(d)&&(t(`QuickAdd: Unsupported |case style "${d}" in token "${l}". Supported styles: ${qP.join(", ")}.`),d=void 0);let p=VV(c.inputTypeOverride,{tokenDisplay:l,hasOptions:!1,allowCustomInput:c.allowCustomInput},t),m=qV(c,l,p,t);return{label:u,caseStyle:d,defaultValue:f,inputTypeOverride:m.inputTypeOverride,numericConfig:m.numericConfig,sliderConfig:m.sliderConfig,optional:c.optionalExplicit??s,trim:c.trimExplicit??a}}var GP,qee,OV,B_,YP,Wee,Qee,Zee,vl=b(()=>{op();O_();v_();GP="",qee=new Set(["multiline","number","slider","checkbox","text"]),OV=new Set(["min","max","step"]),B_=new Set(["label","default","custom","type","case","text","optional","trim","multi"]),YP=new Set([...B_,"name"]),Wee=new Set(["value","title"]);Qee=new Set(['"',"\u201C","\u201D"]);Zee=/[^\S\r\n]/});function Ty(r){if(!r)return{optional:!1,withTime:!1};let{remaining:e,found:t}=ka(Ls(r),"optional"),{remaining:n,found:i}=ka(e,"time"),{remaining:o,found:s}=ka(n,"datetime"),a,l=!1,c,u=[];for(let f of o){let p=fo(f.trim());if(p?.key==="optional"){a=Tu(p.value);continue}if(p?.key==="type"){p.value.trim().toLowerCase()==="datetime"&&(l=!0);continue}if(p?.key==="startof"||p?.key==="endof"){c||(c={boundary:p.key==="startof"?"start":"end",unit:BT(p.value)});continue}u.push(f)}return{defaultValue:u.join("|").trim()||void 0,optional:a??t,withTime:i||s||l,snap:c}}function V_(r){try{return{options:Ty(r)}}catch(e){return{options:{optional:!1,withTime:!1},error:e instanceof Error?e.message:String(e)}}}var _y=b(()=>{op();Qv()});function WV(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 zV=b(()=>{});function $u(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 Ou(r){return Jee.includes(r)}function GV(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 YV(r){if(!Ou(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 HV.has(t)?!0:jV.has(t)?!1:!!e}default:return e}}function QP(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(HV.has(t))return!0;if(jV.has(t))return!1}return!!r;default:return r==null?"":$u(r)}}function ete(r){if(!Ou(r.operator))return"";let e=r.expectedValue??"";return e.length===0?"(empty)":r.valueType==="string"?`"${e}"`:e}function tte(r){let e=r.variableName?`$${r.variableName}`:"(missing variable)",t=nte(r.operator),n=Ou(r.operator)?` ${ete(r)}`:"";return`${e} ${t}${n}`.trim()}function rte(r){let e=r.exportName?`::${r.exportName}`:"";return`script ${r.scriptPath}${e}`}function Mm(r){return r.mode==="variable"?tte(r):rte(r)}function nte(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 Jee,HV,jV,Rm=b(()=>{Jee=["equals","notEquals","lessThan","lessThanOrEqual","greaterThan","greaterThanOrEqual","contains","notContains"],HV=new Set(["true","1","yes","on"]),jV=new Set(["false","0","no","off"])});function Ay(r){let e=[],t=r.length,n=0;for(;n<t;){let i=r.indexOf("`",n);if(i===-1)break;let o=i;for(;o<t&&r[o]==="`";)o++;if(o-i<3||!r.startsWith(ZP,o)){n=o;continue}let s=o+ZP.length,a=-1;for(;s<t;){let l=r.indexOf("`",s);if(l===-1)break;let c=l;for(;c<t&&r[c]==="`";)c++;if(c-l>=3){a=c;break}s=c}if(a===-1)break;e.push({start:i,end:a}),n=a}return e}function XV(r){let e=Ay(r),t=r.length,n=e.length>0?e[e.length-1].end:0;for(;n<t;){let i=r.indexOf("`",n);if(i===-1)return!1;let o=i;for(;o<t&&r[o]==="`";)o++;if(o-i>=3&&r.startsWith(ZP,o))return!0;n=o}return!1}function ky(r){return r?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"}function Sy(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=ce.getState().dateAliases,a=n.parseDate(Ov(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:lm(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:$u(i)}:{text:""}}var KV,q_,ZP,yl,$m=b(()=>{KV=require("obsidian");Tt();Hs();AV();vy();qt();Me();D_();It();Wd();O_();by();$V();jP();Ru();vl();v_();_y();Qv();zV();Rm();q_=10,ZP="js quickadd";yl=class{constructor(e){this.app=e;this.variables=new Map;this.linkToCurrentFileBehavior="required";this.targetFolderPath=null;this.promptScope="generic";this.promptScopeSoleValue=!1;this.templatePropertyCollectionDepth=0;this.namedSuggesterOptionSigs=new Map;this.namedSuggesterConflictsWarned=new Set;this.warnSink=e=>this.warn(e);this.propertyCollector=new Fa(e)}warn(e){F.logWarning(e)}reportProblem(e){F.logError(e)}setTemplateInclusionState(e){this.templateInclusion=e}setPromptRunContext(e){this.promptRunContext={...this.promptRunContext,...e}}getPromptRunContext(){return this.promptRunContext}async withPromptScope(e,t,n){let i=this.promptScope,o=this.promptScopeSoleValue;this.promptScope=e,this.promptScopeSoleValue=C_(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})}replaceDateInString(e){let t=e;for(;vT.test(t);){let n=vT.exec(t),i;if(n&&n[1]){let s=n[1].replace("+","").trim();l0.test(s)&&(i=parseInt(s))}let o=n?.[2]?N0(n[2])??void 0:void 0;t=this.replacer(t,vT,Bs({offset:i,snap:o}))}for(;Xf.test(t);){let n=Xf.exec(t);if(!n)throw new Error(`Unable to parse date format. Invalid syntax in: "${t.substring(Math.max(0,t.search(Xf)-10),Math.min(t.length,t.search(Xf)+30))}..."`);let i=n[1],o;if(n[2]){let a=n[2].replace("+","").trim();l0.test(a)&&(o=parseInt(a))}let s=n[3]?N0(n[3])??void 0:void 0;t=this.replacer(t,Xf,Bs({format:i,offset:o,snap:s}))}return t}replaceTimeInString(e){let t=e;for(;Qf.test(t);){if(!Qf.exec(t))throw new Error(`Unable to parse time format. Invalid syntax in: "${t.substring(Math.max(0,t.search(Qf)-10),Math.min(t.length,t.search(Qf)+30))}..."`);t=this.replacer(t,Qf,Bs({format:"HH:mm"}))}for(;Zf.test(t);){let n=Zf.exec(t);if(!n)throw new Error(`Unable to parse formatted time. Invalid syntax in: "${t.substring(Math.max(0,t.search(Zf)-10),Math.min(t.length,t.search(Zf)+30))}..."`);let i=n[1];t=this.replacer(t,Zf,Bs({format:i}))}return t}async replaceValueInString(e){let t=e;if(!uc.test(t))return t;if(this.valuePromptContext=this.getValuePromptContext(t),this.hasConcreteVariable("value")){let i=this.variables.get("value");this.value=$u(i)}this.value===void 0&&(this.value=await this.promptForValue());let n=new RegExp(uc.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.value;let u=l.slice(c),d=XP(u,{warn:this.warnSink}),f=this.value===""&&d.defaultValue&&!d.optional?d.defaultValue:this.value,p=this.applyValueTextOptions(f,d);return d.inputTypeOverride==="text"&&p!==""&&HP(a,s,s+o.length)?zP(p):p}),t}applyValueTextOptions(e,t){let n=String(e??""),i=t.trim?n.trim():n;return $_(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(uc.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=XP(l,{warn:fy});i||(i={}),!i.description&&c.label&&(i.description=c.label),!i.defaultValue&&c.defaultValue&&(i.defaultValue=c.defaultValue),c.inputTypeOverride&&!i.inputTypeOverride&&(i.inputTypeOverride=c.inputTypeOverride),c.numericConfig&&!i.numericConfig&&(i.numericConfig=c.numericConfig),c.sliderConfig&&!i.sliderConfig&&(i.sliderConfig=c.sliderConfig),c.optional&&(i.optional=!0)}return i}async replaceSelectedInString(e){if(!p0.test(e))return e;let t=await this.getSelectedText(),n=new RegExp(p0.source,"gi");return e.replace(n,()=>t)}async replaceClipboardInString(e){if(!f0.test(e))return e;let t=await this.getClipboardContent(),n=new RegExp(f0.source,"gi");return e.replace(n,()=>t)}async replaceLinkToCurrentFileInString(e){if(!c0.test(e))return e;let t=this.getCurrentFileLink();if(!t){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");F.logMessage("Skipping {{LINKCURRENT}} replacement because no active file is available.")}let n=new RegExp(c0.source,"gi");return e.replace(n,()=>t??"")}replaceLinkToCurrentSectionInString(e){if(!u0.test(e))return e;let t=this.getCurrentFileLinkToSection();if(!t){if(this.linkToCurrentFileBehavior==="required")throw new Error("Unable to get current file path. Make sure you have a file open in the editor.");F.logMessage("Skipping {{LINKSECTION}} replacement because no active file is available.")}let n=new RegExp(u0.source,"gi");return e.replace(n,()=>t??"")}replaceCurrentFileLinksInString(e){return this.replaceCurrentFileTokensInString(e,{links:!0})}replaceCurrentFileTokensInString(e,t){let n=/{{(?:(LINKCURRENT|LINKSECTION|FILENAMECURRENT|TITLE)|(FOLDERCURRENT|FOLDER)(\|name)?)}}/gi,i,o,s,a,l,c,u,d,f=!1,p=!1,m=!1,v=e.replace(n,(y,w,x,C)=>{if(x!==void 0&&x.toUpperCase()==="FOLDERCURRENT"){if(!t.activeFolder)return y;if(c===void 0)if(c=this.getCurrentFolderPath(),c===null)u=null;else{let _=c.lastIndexOf("/");u=_===-1?c:c.slice(_+1)}return c===null&&(m=!0),(C?u:c)??""}if(x!==void 0){if(!t.folder)return y;if(a===void 0){a=this.targetFolderPath??"";let _=a.lastIndexOf("/");l=_===-1?a:a.slice(_+1)}return C?l:a}switch((w??"").toUpperCase()){case"LINKCURRENT":return t.links?(i===void 0&&(i=this.getCurrentFileLink()??null),i||(f=!0),i??""):y;case"LINKSECTION":return t.links?(o===void 0&&(o=this.getCurrentFileLinkToSection()??null),o||(f=!0),o??""):y;case"FILENAMECURRENT":return t.fileName?(s===void 0&&(s=this.getCurrentFileName()??null),s||(p=!0),s??""):y;case"TITLE":return t.title?(d===void 0&&(d=this.getVariableValue("title")),d):y}return y}),g="Unable to get the active file's folder. Make sure you have a file open in the editor.";if(m&&t.activeFolder==="path")throw new Error(g);if(f||p||m){if(this.linkToCurrentFileBehavior==="required")throw new Error(f?"Unable to get current file path. Make sure you have a file open in the editor.":p?"Unable to get current file name. Make sure you have a file open in the editor.":g);F.logMessage("Skipping current-file token replacement because no active file is available.")}return v}async replaceCurrentFileNameInString(e){return this.replaceCurrentFileTokensInString(e,{fileName:!0})}setLinkToCurrentFileBehavior(e){this.linkToCurrentFileBehavior=e}setTargetFolderPath(e){if(e==null){this.targetFolderPath=null;return}let t=e.trim();this.targetFolderPath=t==="/"?"":t.replace(/^\/+/,"").replace(/\/+$/,"")}replaceTargetFolderInString(e){return this.replaceCurrentFileTokensInString(e,{folder:!0})}getAndClearTemplatePropertyVars(){return this.propertyCollector.drain()}mergeTemplatePropertyVars(e){this.propertyCollector.merge(e)}renderCollectedOrArrayValue(e){let t=this.propertyCollector.maybeCollect({...e,collectionActive:this.templatePropertyCollectionDepth>0}),n=S_(t);if(n!==void 0)return n;if(Array.isArray(e.rawValue))return e.rawValue.join(",")}async withTemplatePropertyCollection(e){this.templatePropertyCollectionDepth+=1;try{return await e()}finally{this.templatePropertyCollectionDepth-=1}}getCurrentFileLinkToSection(){return null}getCurrentFolderPath(){return null}warnOnNamedOptionConflict(e){if(!e.aliasName||!e.hasOptions)return;let t=e.variableKey.toLowerCase(),n=JSON.stringify([e.suggestedValues,e.allowCustomInput,e.displayValues??null,e.multiSelect,e.multiEmit]),i=this.namedSuggesterOptionSigs.get(t);if(i===void 0){this.namedSuggesterOptionSigs.set(t,n);return}i!==n&&!this.namedSuggesterConflictsWarned.has(t)&&(this.namedSuggesterConflictsWarned.add(t),this.warn(`QuickAdd: named value "${e.variableKey}" is defined with different option lists; the first definition's value is reused.`))}async ensureValueVariableResolved(e){let{variableName:t,variableKey:n,label:i,defaultValue:o,allowCustomInput:s,suggestedValues:a,displayValues:l,hasOptions:c}=e;this.warnOnNamedOptionConflict(e);let u=U_(this.variables,n);if(u)return u;let d=!c&&i?i:void 0,f=c&&i?i:void 0;if(c&&e.multiSelect){let m=await this.suggestForValueMulti(a,s,{placeholder:f,variableKey:n,displayValues:l,optional:e.optional});return this.variables.set(n,e.multiEmit==="linklist"?m.map(N_):m),n}let p="";return c?p=await this.suggestForValue(a,s,{placeholder:f,variableKey:n,displayValues:l,optional:e.optional}):p=await this.promptForVariable(t,{defaultValue:o,description:d,inputTypeOverride:e.inputTypeOverride,numericConfig:e.numericConfig,sliderConfig:e.sliderConfig,variableKey:n,optional:e.optional}),!p&&o&&!e.optional&&(p=o),this.variables.set(n,p),n}async resolveNamedSuggesterDefinitions(e){if(!/\|\s*name\s*:/i.test(e))return;let t=new RegExp(Hd.source,"gi"),n=[],i;for(;(i=t.exec(e))!==null;){if(!i[1])continue;let a;try{a=Ey(i[1],{warn:fy})}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(Hd.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=Ey(o[1],{warn:this.warnSink});if(!s)throw new Error(`Unable to parse variable. Invalid syntax in: "${t.substring(Math.max(0,o.index-10),Math.min(t.length,o.index+30))}..."`);let{variableName:a}=s,l=await this.ensureValueVariableResolved(s),c=this.variables.get(l),u=this.applyValueTokenOptions(c,s),d=this.renderCollectedOrArrayValue({input:t,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:u,fallbackKey:a,heuristicEnabled:i&&this.templatePropertyCollectionDepth>0&&s.inputTypeOverride!=="text"}),f;if(d!==void 0)f=d;else{let p=String(this.applyValueTextOptions(this.getVariableValue(l),s)??"");f=s.inputTypeOverride==="text"&&p!==""&&HP(t,o.index,o.index+o[0].length)?zP(p):p}t=t.slice(0,o.index)+f+t.slice(o.index+o[0].length),n.lastIndex=o.index+f.length}return t}async replaceFieldVarInString(e){let t=new RegExp(yT.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index);let s=o[1]+(o[2]||"");if(s){let a=this.getFieldVariableKey(s),l=Yi.parse(s,{warnUnknown:!0,warn:this.warnSink});this.hasConcreteVariable(a)||this.variables.set(a,await this.suggestForField(s,l));let c=this.hasConcreteVariable(a)?this.variables.get(a):this.getVariableValue(a),u;if(Array.isArray(c)){let d=this.propertyCollector.maybeCollect({input:e,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:c,fallbackKey:l.fieldName,collectionActive:this.templatePropertyCollectionDepth>0,heuristicEnabled:!1});u=S_(d)??c.join(",")}else u=String(c??"");n+=u}else n+=o[0];i=t.lastIndex}return n+e.slice(i)}getFieldVariableKey(e){return`${jd}${e}`}async replaceFileInString(e){let t=new RegExp(bT.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index);let s=w_(o[1]??"");if(!s){n+=o[0],i=t.lastIndex;continue}let a=s.variableKey;this.hasConcreteVariable(a)||this.variables.set(a,await this.suggestForFile(s));let l=_V(this.variables.get(a),s.mode,c=>this.getFileLinkForStoredValue(c));if(Array.isArray(l)){let c=this.propertyCollector.maybeCollect({input:e,matchStart:o.index,matchEnd:o.index+o[0].length,rawValue:l,fallbackKey:s.aliasName??s.folderPath,collectionActive:this.templatePropertyCollectionDepth>0,heuristicEnabled:!1});n+=S_(c)??l.join(",")}else n+=l;i=t.lastIndex}return n+e.slice(i)}getFileLinkForStoredValue(e){let t=gp(e);if(t.kind==="empty")return"";if(t.kind!=="file"){let o=t.kind==="custom"?t.text:t.value;return o?`[[${o}]]`:""}let n=t.path;if(!n)return"";let i=this.app?.vault.getAbstractFileByPath(n);return i instanceof KV.TFile?this.app?.fileManager.generateMarkdownLink(i,this.getLinkSourcePath()??"")??`[[${Im(n)}]]`:`[[${Im(n)}]]`}getLinkSourcePath(){return null}async replaceMathValueInString(e){let t=new RegExp(wT.source,"gi"),n=this.variables.get("mvalue"),i=typeof n=="string"&&n.trim()?n:null,o="",s=0,a;for(;(a=t.exec(e))!==null;)o+=e.slice(s,a.index),o+=i??await this.promptForMathValue(),s=a.index+a[0].length;return o+=e.slice(s),o}async replaceMacrosInString(e){let t=e;for(;vu.test(t);){let n=vu.exec(t);if(!n)continue;if(!n[1]){t=this.replacer(t,vu,"");continue}let i=WV(n[1]);if(!i){t=this.replacer(t,vu,"");continue}let{macroName:o,label:s}=i,a=await this.getMacroValue(o,s?{label:s}:void 0);t=this.replacer(t,vu,a?a.toString():"")}return t}suggestForValueMulti(e,t,n){return[]}async replaceDateVariableInString(e){let t=new RegExp(gu.source,"gi"),n="",i=0,o;for(;(o=t.exec(e))!==null;){n+=e.slice(i,o.index),i=o.index+o[0].length;let s=o[1]?.trim();if(!s){n+=o[0];continue}let{defaultValue:a,optional:l,withTime:c,snap:u}=Ty(o[3]),d=o[2]?.trim()||ky(c);if(this.variables.get(s)===void 0){let m=await this.promptForVariable(s,{type:"VDATE",dateFormat:d,defaultValue:a,optional:l,withTime:c});if(l&&!m?.trim())this.variables.set(s,"");else if(m?.startsWith("@date:"))this.variables.set(s,m);else{if(!this.dateParser)throw new Error("Date parser is not available");let v=ce.getState().dateAliases,g=Ov(m,v),y=this.dateParser.parseDate(g);if(y)this.variables.set(s,`@date:${y.moment.toISOString()}`);else throw new Error(`unable to parse date variable ${m}${l?"":". Tip: add |optional inside the {{VDATE}} token to allow leaving this date empty"}`)}}let p=Sy(this.variables.get(s),d,u,this.dateParser);p?.normalized!==void 0&&this.variables.set(s,p.normalized),n+=p?.text??""}return n+e.slice(i)}async replaceTemplateInString(e){let t=e;for(;Rs.test(t);){let n=Rs.exec(t);if(!n||!n[1])continue;let i=n[1];if(this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.visited.has(i)){let s=`[QuickAdd: template inclusion cycle detected at "${i}"]`;this.reportProblem(s),t=this.replacer(t,Rs,s);continue}if(this.templateInclusion.depth>=q_){let s=`[QuickAdd: max template inclusion depth (${q_}) exceeded at "${i}"]`;this.reportProblem(s),t=this.replacer(t,Rs,s);continue}this.templateInclusion.visited.add(i);let o;try{o=await this.getTemplateContent(i)}finally{this.templateInclusion.visited.delete(i)}t=this.replacer(t,Rs,o)}return t}replaceLinebreakInString(e){let t="";for(let n=0;n<e.length;n++){let i=e[n],o=e[n+1];i=="\\"?o=="n"?(t+=`
|
||
`,n++):o=="\\"?(t+="\\",n++):t+="\\":t+=i}return t}expandLinebreakEscapesOutsideTokens(e){let t=Ay(e),n="",i=0,o=0;for(;i<e.length;){for(;o<t.length&&t[o].end<=i;)o++;let s=t[o];if(s&&s.start===i){n+=e.slice(s.start,s.end),i=s.end;continue}if(e[i]==="{"&&e[i+1]==="{"){let c=e.indexOf("}}",i+2),u=!1;if(c!==-1){let d=c+2;for(let f=o;f<t.length;f++){let p=t[f];if(p.start>=d)break;if(d<p.end&&d>p.start){u=!0;break}}}if(c!==-1&&!u){n+=e.slice(i,c+2),i=c+2;continue}}let a=e[i],l=e[i+1];a==="\\"?l==="n"?(n+=`
|
||
`,i+=2):l==="\\"?(n+="\\",i+=2):(n+="\\",i+=1):(n+=a,i+=1)}return n}replaceRandomInString(e){let t=e;for(;m0.test(t);){let n=m0.exec(t);if(!n||!n[1])continue;let i=parseInt(n[1]);if(i<=0||i>100)throw new Error(`Random string length must be between 1 and 100. Got: ${i}`);let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",s="";for(let a=0;a<i;a++)s+=o.charAt(Math.floor(Math.random()*o.length));t=t.replace(n[0],s)}return t}replaceTitleInString(e){return this.replaceCurrentFileTokensInString(e,{title:!0})}}});var G,Oe,ls,pt=b(()=>{(function(r){r[r.AM=0]="AM",r[r.PM=1]="PM"})(G||(G={}));(function(r){r[r.SUNDAY=0]="SUNDAY",r[r.MONDAY=1]="MONDAY",r[r.TUESDAY=2]="TUESDAY",r[r.WEDNESDAY=3]="WEDNESDAY",r[r.THURSDAY=4]="THURSDAY",r[r.FRIDAY=5]="FRIDAY",r[r.SATURDAY=6]="SATURDAY"})(Oe||(Oe={}));(function(r){r[r.JANUARY=1]="JANUARY",r[r.FEBRUARY=2]="FEBRUARY",r[r.MARCH=3]="MARCH",r[r.APRIL=4]="APRIL",r[r.MAY=5]="MAY",r[r.JUNE=6]="JUNE",r[r.JULY=7]="JULY",r[r.AUGUST=8]="AUGUST",r[r.SEPTEMBER=9]="SEPTEMBER",r[r.OCTOBER=10]="OCTOBER",r[r.NOVEMBER=11]="NOVEMBER",r[r.DECEMBER=12]="DECEMBER"})(ls||(ls={}))});function nt(r,e){r.assign("day",e.getDate()),r.assign("month",e.getMonth()+1),r.assign("year",e.getFullYear())}function W_(r,e){r.assign("hour",e.getHours()),r.assign("minute",e.getMinutes()),r.assign("second",e.getSeconds()),r.assign("millisecond",e.getMilliseconds()),r.assign("meridiem",e.getHours()<12?G.AM:G.PM)}function _c(r,e){r.imply("day",e.getDate()),r.imply("month",e.getMonth()+1),r.imply("year",e.getFullYear())}function Lt(r,e){r.imply("hour",e.getHours()),r.imply("minute",e.getMinutes()),r.imply("second",e.getSeconds()),r.imply("millisecond",e.getMilliseconds()),r.imply("meridiem",e.getHours()<12?G.AM:G.PM)}var nn=b(()=>{pt()});function Lu(r,e,t,n,i=0){let o=0,s=0;for(;s<n;)o++,new Date(r,e-1,o).getDay()===t&&s++;return new Date(r,e-1,o,i)}function ZV(r,e,t,n=0){let i=t===0?7:t,o=new Date(r,e-1+1,1,12),s=o.getDay()===0?7:o.getDay(),a;return s===i?a=7:s<i?a=7+s-i:a=s-i,o.setDate(o.getDate()-a),new Date(r,e-1,o.getDate(),n)}function z_(r,e,t={}){if(r==null)return null;if(typeof r=="number")return r;let n=t[r]??ste[r];return n==null?null:typeof n=="number"?n:e==null?null:e>n.dstStart(e.getFullYear())&&!(e>n.dstEnd(e.getFullYear()))?n.timezoneOffsetDuringDst:n.timezoneOffsetNonDst}var ste,JP=b(()=>{pt();ste={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=>ZV(r,ls.MARCH,Oe.SUNDAY,2),dstEnd:r=>ZV(r,ls.OCTOBER,Oe.SUNDAY,3)},CHADT:825,CHAST:765,CKT:-600,CLST:-180,CLT:-240,COT:-300,CST:-360,CT:{timezoneOffsetDuringDst:-300,timezoneOffsetNonDst:-360,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},CVT:-60,CXT:420,ChST:600,DAVT:420,EASST:-300,EAST:-360,EAT:180,ECT:-300,EDT:-240,EEST:180,EET:120,EGST:0,EGT:-60,EST:-300,ET:{timezoneOffsetDuringDst:-240,timezoneOffsetNonDst:-300,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},FJST:780,FJT:720,FKST:-180,FKT:-240,FNT:-120,GALT:-360,GAMT:-540,GET:240,GFT:-180,GILT:720,GMT:0,GST:240,GYT:-240,HAA:-180,HAC:-300,HADT:-540,HAE:-240,HAP:-420,HAR:-360,HAST:-600,HAT:-90,HAY:-480,HKT:480,HLV:-210,HNA:-240,HNC:-360,HNE:-300,HNP:-480,HNR:-420,HNT:-150,HNY:-540,HOVT:420,ICT:420,IDT:180,IOT:360,IRDT:270,IRKST:540,IRKT:540,IRST:210,IST:330,JST:540,KGT:360,KRAST:480,KRAT:480,KST:540,KUYT:240,LHDT:660,LHST:630,LINT:840,MAGST:720,MAGT:720,MART:-510,MAWT:300,MDT:-360,MESZ:120,MEZ:60,MHT:720,MMT:390,MSD:240,MSK:180,MST:-420,MT:{timezoneOffsetDuringDst:-360,timezoneOffsetNonDst:-420,dstStart:r=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},MUT:240,MVT:300,MYT:480,NCT:660,NDT:-90,NFT:690,NOVST:420,NOVT:360,NPT:345,NST:-150,NUT:-660,NZDT:780,NZST:720,OMSST:420,OMST:420,PDT:-420,PET:-300,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=>Lu(r,ls.MARCH,Oe.SUNDAY,2,2),dstEnd:r=>Lu(r,ls.NOVEMBER,Oe.SUNDAY,1,2)},PWT:540,PYST:-180,PYT:-240,RET:240,SAMT:240,SAST:120,SBT:660,SCT:240,SGT:480,SRT:-180,SST:-660,TAHT:-600,TFT:300,TJT:300,TKT:780,TLT:540,TMT:300,TVT:720,ULAT:480,UTC:0,UYST:-120,UYT:-180,UZT:300,VET:-210,VLAST:660,VLAT:660,VUT:660,WAST:120,WAT:60,WEST:60,WESZ:60,WET:0,WEZ:0,WFT:720,WGST:-120,WGT:-180,WIB:420,WIT:540,WITA:480,WST:780,WT:0,YAKST:600,YAKT:600,YAPT:600,YEKST:360,YEKT:360}});function gt(r,e){let t=new Date(r);if(e.y&&(e.year=e.y,delete e.y),e.mo&&(e.month=e.mo,delete e.mo),e.M&&(e.month=e.M,delete e.M),e.w&&(e.week=e.w,delete e.w),e.d&&(e.day=e.d,delete e.d),e.h&&(e.hour=e.h,delete e.h),e.m&&(e.minute=e.m,delete e.m),e.s&&(e.second=e.s,delete e.s),e.ms&&(e.millisecond=e.ms,delete e.ms),"year"in e){let n=Math.floor(e.year);t.setFullYear(t.getFullYear()+n);let i=e.year-n;i>0&&(e.month=e?.month??0,e.month+=i*12)}if("quarter"in e){let n=Math.floor(e.quarter);t.setMonth(t.getMonth()+n*3)}if("month"in e){let n=Math.floor(e.month);t.setMonth(t.getMonth()+n);let i=e.month-n;i>0&&(e.week=e?.week??0,e.week+=i*4)}if("week"in e){let n=Math.floor(e.week);t.setDate(t.getDate()+n*7);let i=e.week-n;i>0&&(e.day=e?.day??0,e.day+=Math.round(i*7))}if("day"in e){let n=Math.floor(e.day);t.setDate(t.getDate()+n);let i=e.day-n;i>0&&(e.hour=e?.hour??0,e.hour+=Math.round(i*24))}if("hour"in e){let n=Math.floor(e.hour);t.setHours(t.getHours()+n);let i=e.hour-n;i>0&&(e.minute=e?.minute??0,e.minute+=Math.round(i*60))}if("minute"in e){let n=Math.floor(e.minute);t.setMinutes(t.getMinutes()+n);let i=e.minute-n;i>0&&(e.second=e?.second??0,e.second+=Math.round(i*60))}if("second"in e){let n=Math.floor(e.second);t.setSeconds(t.getSeconds()+n);let i=e.second-n;i>0&&(e.millisecond=e?.millisecond??0,e.millisecond+=Math.round(i*1e3))}if("millisecond"in e){let n=Math.floor(e.millisecond);t.setMilliseconds(t.getMilliseconds()+n)}return t}function tt(r){let e={};for(let t in r)e[t]=-r[t];return e}var JV,Bt=b(()=>{JV={day:0,second:0,millisecond:0}});var ct,Q,at,Le=b(()=>{nn();JP();Bt();ct=class r{constructor(e,t){le(this,"instant");le(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=z_(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()}},Q=class r{constructor(e,t){le(this,"knownValues");le(this,"impliedValues");le(this,"reference");le(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=JV){let n=gt(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"),W_(i,n),nt(i,n),i.assign("timezoneOffset",e.getTimezoneOffset())):(Lt(i,n),i.imply("timezoneOffset",e.getTimezoneOffset()),"day"in t?(i.assign("day",n.getDate()),i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear()),i.assign("weekday",n.getDay())):"week"in t?(i.assign("day",n.getDate()),i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear()),i.imply("weekday",n.getDay())):(i.imply("day",n.getDate()),"month"in t?(i.assign("month",n.getMonth()+1),i.assign("year",n.getFullYear())):(i.imply("month",n.getMonth()+1),"year"in t?i.assign("year",n.getFullYear()):i.imply("year",n.getFullYear())))),i}get(e){return e in this.knownValues?this.knownValues[e]:e in this.impliedValues?this.impliedValues[e]:null}isCertain(e){return e in this.knownValues}getCertainComponents(){return Object.keys(this.knownValues)}imply(e,t){return e in this.knownValues?this:(this.impliedValues[e]=t,this)}assign(e,t){return this.knownValues[e]=t,delete this.impliedValues[e],this}addDurationAsImplied(e){let t=this.dateWithoutTimezoneAdjustment(),n=gt(t,e);return("day"in e||"week"in e||"month"in e||"year"in e)&&(this.delete(["day","weekday","month","year"]),this.imply("day",n.getDate()),this.imply("weekday",n.getDay()),this.imply("month",n.getMonth()+1),this.imply("year",n.getFullYear())),("second"in e||"minute"in e||"hour"in e)&&(this.delete(["second","minute","hour"]),this.imply("second",n.getSeconds()),this.imply("minute",n.getMinutes()),this.imply("hour",n.getHours())),this}delete(e){typeof e=="string"&&(e=[e]);for(let t of e)delete this.knownValues[t],delete this.impliedValues[t]}clone(){let e=new r(this.reference);e.knownValues={},e.impliedValues={};for(let t in this.knownValues)e.knownValues[t]=this.knownValues[t];for(let t in this.impliedValues)e.impliedValues[t]=this.impliedValues[t];return e}isOnlyDate(){return!this.isCertain("hour")&&!this.isCertain("minute")&&!this.isCertain("second")}isOnlyTime(){return!this.isCertain("weekday")&&!this.isCertain("day")&&!this.isCertain("month")&&!this.isCertain("year")}isOnlyWeekdayComponent(){return this.isCertain("weekday")&&!this.isCertain("day")&&!this.isCertain("month")}isDateWithUnknownYear(){return this.isCertain("month")&&!this.isCertain("year")}isValidDate(){let e=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return e.setUTCFullYear(this.get("year")),!(e.getUTCFullYear()!==this.get("year")||e.getUTCMonth()!==this.get("month")-1||e.getUTCDate()!==this.get("day")||this.get("hour")!=null&&e.getUTCHours()!=this.get("hour")||this.get("minute")!=null&&e.getUTCMinutes()!=this.get("minute"))}toString(){return`[ParsingComponents {
|
||
tags: ${JSON.stringify(Array.from(this._tags).sort())},
|
||
knownValues: ${JSON.stringify(this.knownValues)},
|
||
impliedValues: ${JSON.stringify(this.impliedValues)}},
|
||
reference: ${JSON.stringify(this.reference)}]`}date(){let e=this.get("timezoneOffset")??this.reference.timezoneOffset;if(e==null)return this.dateWithoutTimezoneAdjustment();let t=new Date(Date.UTC(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond")));return t.setUTCFullYear(this.get("year")),new Date(t.getTime()-e*6e4)}addTag(e){return this._tags.add(e),this}addTags(e){for(let t of e)this._tags.add(t);return this}tags(){return new Set(this._tags)}dateWithoutTimezoneAdjustment(){let e=new Date(this.get("year"),this.get("month")-1,this.get("day"),this.get("hour"),this.get("minute"),this.get("second"),this.get("millisecond"));return e.setFullYear(this.get("year")),e}},at=class r{constructor(e,t,n,i,o){le(this,"refDate");le(this,"index");le(this,"text");le(this,"reference");le(this,"start");le(this,"end");this.reference=e,this.refDate=e.instant,this.index=t,this.text=n,this.start=i||new Q(e),this.end=o}clone(){let e=new r(this.reference,this.index,this.text);return e.start=this.start?this.start.clone():null,e.end=this.end?this.end.clone():null,e}date(){return this.start.date()}addTag(e){return this.start.addTag(e),this.end&&this.end.addTag(e),this}addTags(e){return this.start.addTags(e),this.end&&this.end.addTags(e),this}tags(){let e=new Set(this.start.tags());if(this.end)for(let t of this.end.tags())e.add(t);return e}toString(){let e=Array.from(this.tags()).sort();return`[ParsingResult {index: ${this.index}, text: '${this.text}', tags: ${JSON.stringify(e)} ...}]`}}});function Er(r,e,t="\\s{0,5},?\\s{0,5}"){let n=e.replace(/\((?!\?)/g,"(?:");return`${r}${n}(?:${t}${n}){0,10}`}function ate(r){let e;return r instanceof Array?e=[...r]:r instanceof Map?e=Array.from(r.keys()):e=Object.keys(r),e}function ee(r){return`(?:${ate(r).sort((t,n)=>n.length-t.length).join("|").replace(/\./g,"\\.")})`}var ze=b(()=>{});function jr(r){return r<100&&(r>50?r=r+1900:r=r+2e3),r}function ft(r,e,t){let n=new Date(r);n.setMonth(t-1),n.setDate(e);let i=gt(n,{year:1}),o=gt(n,{year:-1});return Math.abs(i.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())?n=i:Math.abs(o.getTime()-r.getTime())<Math.abs(n.getTime()-r.getTime())&&(n=o),n.getFullYear()}var zt=b(()=>{Bt()});function lte(r){let e=r.toLowerCase();return eF[e]!==void 0?eF[e]:e==="a"||e==="an"||e=="the"?1:e.match(/few/)?3:e.match(/half/)?.5:e.match(/couple/)?2:e.match(/several/)?7:parseFloat(e)}function Lm(r){let e=r.toLowerCase();return tF[e]!==void 0?tF[e]:(e=e.replace(/(?:st|nd|rd|th)$/i,""),parseInt(e))}function bl(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 jr(e)}function js(r){let e={},t=r,n=eq.exec(t);for(;n;)ute(e,n),t=t.substring(n[0].length).trim(),n=eq.exec(t);return Object.keys(e).length==0?null:e}function ute(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=lte(e[1]),n=Dy[e[2].toLowerCase()];r[n]=t}var H_,rF,ho,eF,tF,tq,Dy,rq,Nm,Bu,nq,eq,cte,iq,Ac,Uu,on=b(()=>{ze();zt();H_={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},rF={january:1,february:2,march:3,april:4,may:5,june:6,july:7,august:8,september:9,october:10,november:11,december:12},ho={...rF,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},eF={one:1,two:2,three:3,four:4,five:5,six:6,seven:7,eight:8,nine:9,ten:10,eleven:11,twelve:12},tF={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},tq={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"},Dy={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",...tq},rq=`(?:${ee(eF)}|[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)?)`;Nm=`(?:${ee(tF)}|[0-9]{1,2}(?:st|nd|rd|th)?)`;Bu="(?:[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)))";nq=`(${rq})\\s{0,3}(${ee(Dy)})`,eq=new RegExp(nq,"i"),cte=`(${rq})\\s{0,3}(${ee(tq)})`,iq="\\s{0,5},?(?:\\s*and)?\\s{0,5}",Ac=Er("(?:(?:about|around)\\s{0,3})?",nq,iq),Uu=Er("(?:(?:about|around)\\s{0,3})?",cte,iq)});var L,fe=b(()=>{L=class{constructor(){le(this,"cachedInnerPattern",null);le(this,"cachedPattern",null)}innerPatternHasChange(e,t){return this.innerPattern(e)!==t}patternLeftBoundary(){return"(\\W|^)"}pattern(e){return this.cachedInnerPattern&&!this.innerPatternHasChange(e,this.cachedInnerPattern)?this.cachedPattern:(this.cachedInnerPattern=this.innerPattern(e),this.cachedPattern=new RegExp(`${this.patternLeftBoundary()}${this.cachedInnerPattern.source}`,this.cachedInnerPattern.flags),this.cachedPattern)}extract(e,t){let n=t[1]??"";t.index=t.index+n.length,t[0]=t[0].substring(n.length);for(let i=2;i<t.length;i++)t[i-1]=t[i];return this.innerExtract(e,t)}}});var dte,pte,fte,Iy,oq=b(()=>{on();Le();fe();dte=new RegExp(`(?:(?:within|in|for)\\s*)?(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Ac})(?=\\W|$)`,"i"),pte=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Ac})(?=\\W|$)`,"i"),fte=new RegExp(`(?:within|in|for)\\s*(?:(?:about|around|roughly|approximately|just)\\s*(?:~\\s*)?)?(${Uu})(?=\\W|$)`,"i"),Iy=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(t){return this.strictMode?fte:t.option.forwardDate?dte:pte}innerExtract(t,n){if(n[0].match(/^for\s*the\s*\w+/))return null;let i=js(n[1]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var mte,sq,aq,hte,lq,Py,cq=b(()=>{zt();on();on();on();ze();fe();mte=new RegExp(`(?:on\\s{0,3})?(${Nm})(?:\\s{0,3}(?:to|\\-|\\\u2013|until|through|till)\\s{0,3}(${Nm}))?(?:-|/|\\s{0,3}(?:of)?\\s{0,3})(${ee(ho)})(?:(?:-|/|,?\\s{0,3})(${Bu}(?!\\w)))?(?=\\W|$)`,"i"),sq=1,aq=2,hte=3,lq=4,Py=class extends L{innerPattern(){return mte}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=ho[t[hte].toLowerCase()],o=Lm(t[sq]);if(o>31)return t.index=t.index+t[sq].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[lq]){let s=bl(t[lq]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[aq]){let s=Lm(t[aq]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var gte,vte,uq,nF,iF,Fy,dq=b(()=>{zt();on();on();on();ze();fe();gte=new RegExp(`(${ee(ho)})(?:-|/|\\s*,?\\s*)(${Nm})(?!\\s*(?:am|pm))\\s*(?:(?:to|\\-)\\s*(${Nm})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${Bu}))?(?=\\W|$)(?!\\:\\d)`,"i"),vte=1,uq=2,nF=3,iF=4,Fy=class extends L{constructor(t){super();le(this,"shouldSkipYearLikeDate");this.shouldSkipYearLikeDate=t}innerPattern(){return gte}innerExtract(t,n){let i=ho[n[vte].toLowerCase()],o=Lm(n[uq]);if(o>31||this.shouldSkipYearLikeDate&&!n[nF]&&!n[iF]&&n[uq].match(/^\d{2}$/))return null;let s=t.createParsingComponents({day:o,month:i}).addTag("parser/ENMonthNameMiddleEndianParser");if(n[iF]){let c=bl(n[iF]);s.assign("year",c)}else{let c=ft(t.refDate,o,i);s.imply("year",c)}if(!n[nF])return s;let a=Lm(n[nF]),l=t.createParsingResult(n.index,n[0]);return l.start=s,l.end=s.clone(),l.end.assign("day",a),l}}});var yte,bte,wte,pq,My,fq=b(()=>{on();zt();ze();on();fe();yte=new RegExp(`((?:in)\\s*)?(${ee(ho)})\\s*(?:(?:,|-|of)?\\s*(${Bu})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),bte=1,wte=2,pq=3,My=class extends L{innerPattern(){return yte}innerExtract(e,t){let n=t[wte].toLowerCase();if(t[0].length<=3&&!rF[n])return null;let i=e.createParsingResult(t.index+(t[bte]||"").length,t.index+t[0].length);i.start.imply("day",1),i.start.addTag("parser/ENMonthNameParser");let o=ho[n];if(i.start.assign("month",o),t[pq]){let s=bl(t[pq]);i.start.assign("year",s)}else{let s=ft(e.refDate,1,o);i.start.imply("year",s)}return i}}});var Cte,xte,Ete,mq,Tte,Ry,hq=b(()=>{on();ze();fe();Cte=new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${ee(ho)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),xte=1,Ete=2,mq=3,Tte=4,Ry=class extends L{constructor(t){super();le(this,"strictMonthDateOrder");this.strictMonthDateOrder=t}innerPattern(){return Cte}innerExtract(t,n){let i=parseInt(n[xte]),o=parseInt(n[Tte]),s=n[mq]?parseInt(n[mq]):ho[n[Ete].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 _te,Ate,kte,Ste,$y,gq=b(()=>{on();ze();on();fe();_te="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-9][0-9]{3})",Ate=new RegExp(`(${_te})(?:\\s*[-.\\/,]?\\s*|\\s+of\\s+)(${ee(ho)})(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),kte=1,Ste=2,$y=class extends L{innerPattern(){return Ate}innerExtract(e,t){let n=bl(t[kte]),i=t[Ste].toLowerCase(),o=ho[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 Dte,Ite,Pte,Oy,vq=b(()=>{fe();Dte=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),Ite=1,Pte=2,Oy=class extends L{innerPattern(){return Dte}innerExtract(e,t){let n=parseInt(t[Pte]),i=parseInt(t[Ite]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});function Fte(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 Mte(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 oF,vp,j_,G_,Bm,Gr,Ra=b(()=>{pt();oF=2,vp=3,j_=4,G_=5,Bm=6,Gr=class{constructor(e=!1){le(this,"strictMode");le(this,"cachedPrimaryPrefix",null);le(this,"cachedPrimarySuffix",null);le(this,"cachedPrimaryTimePattern",null);le(this,"cachedFollowingPhase",null);le(this,"cachedFollowingSuffix",null);le(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[oF]);if(a>100){if(t[oF].length==4&&t[vp]==null&&!t[Bm]||this.strictMode||t[vp]!=null)return null;o=a%100,a=Math.floor(a/100)}if(a>24)return null;if(t[vp]!=null){if(t[vp].length==1&&!t[Bm])return null;o=parseInt(t[vp])}if(o>=60)return null;if(a>12&&(s=G.PM),t[Bm]!=null){if(a>12)return null;let l=t[Bm][0].toLowerCase();l=="a"&&(s=G.AM,a==12&&(a=0)),l=="p"&&(s=G.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",G.AM):i.imply("meridiem",G.PM),t[G_]!=null){let l=parseInt(t[G_].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[j_]!=null){let l=parseInt(t[j_]);if(l>=60)return null;i.assign("second",l)}return i}extractFollowingTimeComponents(e,t,n){let i=e.createParsingComponents();if(t[G_]!=null){let l=parseInt(t[G_].substring(0,3));if(l>=1e3)return null;i.assign("millisecond",l)}if(t[j_]!=null){let l=parseInt(t[j_]);if(l>=60)return null;i.assign("second",l)}let o=parseInt(t[oF]),s=0,a=-1;if(t[vp]!=null?s=parseInt(t[vp]):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=G.PM),t[Bm]!=null){if(o>12)return null;let l=t[Bm][0].toLowerCase();l=="a"&&(a=G.AM,o==12&&(o=0,i.isCertain("day")||i.imply("day",i.get("day")+1))),l=="p"&&(a=G.PM,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==G.AM?(n.start.imply("meridiem",G.AM),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",G.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",G.AM):o<=12&&(i.assign("hour",o+12),i.assign("meridiem",G.PM)):o>12?i.imply("meridiem",G.PM):o<=12&&i.imply("meridiem",G.AM),i.date().getTime()<n.start.date().getTime()&&i.imply("day",i.get("day")+1),i}checkAndReturnWithoutFollowingPattern(e){if(e.text.match(/^\d$/)||e.text.match(/^\d\d\d+$/)||e.text.match(/\d[apAP]$/))return null;let t=e.text.match(/[^\d:.](\d[\d.]+)$/);if(t){let n=t[1];if(this.strictMode||n.includes(".")&&!n.match(/\d(\.\d{2})+$/)||parseInt(n)>24)return null}return e}checkAndReturnWithFollowingPattern(e){if(e.text.match(/^\d+-\d+$/))return null;let t=e.text.match(/[^\d:.](\d[\d.]+)\s*-\s*(\d[\d.]+)$/);if(t){if(this.strictMode)return null;let n=t[1],i=t[2];if(i.includes(".")&&!i.match(/\d(\.\d{2})+$/))return null;let o=parseInt(i),s=parseInt(n);if(o>24||s>24)return null}return e}getPrimaryTimePatternThroughCache(){let e=this.primaryPrefix(),t=this.primarySuffix();return this.cachedPrimaryPrefix===e&&this.cachedPrimarySuffix===t?this.cachedPrimaryTimePattern:(this.cachedPrimaryTimePattern=Fte(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=Mte(e,t),this.cachedFollowingPhase=e,this.cachedFollowingSuffix=t,this.cachedFollowingTimePatten)}}});var Ny,yq=b(()=>{pt();Ra();Ny=class extends Gr{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",G.PM)):i<6&&n.assign("meridiem",G.AM)}if(t[0].endsWith("afternoon")){n.assign("meridiem",G.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",G.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 Rte,$te,Ly,bq=b(()=>{on();Le();fe();Bt();Rte=new RegExp(`(${Ac})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),$te=new RegExp(`(${Uu})\\s{0,5}(?:ago|before|earlier)(?=\\W|$)`,"i"),Ly=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?$te:Rte}innerExtract(t,n){let i=js(n[1]);return i?Q.createRelativeFromReference(t.reference,tt(i)):null}}});var Ote,Nte,Lte,By,wq=b(()=>{on();Le();fe();Ote=new RegExp(`(${Ac})\\s{0,5}(?:later|after|from now|henceforth|forward|out)(?=(?:\\W|$))`,"i"),Nte=new RegExp(`(${Uu})\\s{0,5}(later|after|from now)(?=\\W|$)`,"i"),Lte=1,By=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Nte:Ote}innerExtract(t,n){let i=js(n[Lte]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var Vu,ii,Gs=b(()=>{Vu=class{refine(e,t){return t.filter(n=>this.isValid(e,n))}},ii=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0],o=null;for(let s=1;s<t.length;s++){o=t[s];let a=e.text.substring(i.index+i.text.length,o.index);if(!this.shouldMergeResults(a,i,o,e))n.push(i),i=o;else{let l=i,c=o,u=this.mergeResults(a,l,c,e);e.debug(()=>{console.log(`${this.constructor.name} merged ${l} and ${c} into ${u}`)}),i=u}}return i!=null&&n.push(i),n}}});var Yt,go=b(()=>{Gs();Bt();Yt=class extends ii{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()&>(s,{day:7})>o?(s=gt(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()&>(o,{day:-7})<s?(o=gt(o,{day:-7}),t.start.imply("day",o.getDate()),t.start.imply("month",o.getMonth()+1),t.start.imply("year",o.getFullYear())):n.start.isDateWithUnknownYear()&>(s,{year:1})>o?(s=gt(s,{year:1}),n.start.imply("year",s.getFullYear())):t.start.isDateWithUnknownYear()&>(o,{year:-1})<s?(o=gt(o,{year:-1}),t.start.imply("year",o.getFullYear())):[n,t]=[t,n]}let i=t.clone();return i.start=t.start,i.end=n.start,i.index=Math.min(t.index,n.index),t.index<n.index?i.text=t.text+e+n.text:i.text=n.text+e+t.text,i}}});var Uy,Cq=b(()=>{go();Uy=class extends Yt{patternBetween(){return/^\s*(to|-|–|until|through|till)\s*$/i}}});function sF(r,e){let t=r.clone(),n=r.start,i=e.start;if(t.start=xq(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=xq(o,s);if(r.end==null&&a.date().getTime()<t.start.date().getTime()){let l=new Date(a.date().getTime());l.setDate(l.getDate()+1),a.isCertain("day")?nt(a,l):_c(a,l)}t.end=a}return t}function xq(r,e){let t=r.clone();e.isCertain("hour")?(t.assign("hour",e.get("hour")),t.assign("minute",e.get("minute")),e.isCertain("second")?(t.assign("second",e.get("second")),e.isCertain("millisecond")?t.assign("millisecond",e.get("millisecond")):t.imply("millisecond",e.get("millisecond"))):(t.imply("second",e.get("second")),t.imply("millisecond",e.get("millisecond")))):(t.imply("hour",e.get("hour")),t.imply("minute",e.get("minute")),t.imply("second",e.get("second")),t.imply("millisecond",e.get("millisecond"))),e.isCertain("timezoneOffset")&&t.assign("timezoneOffset",e.get("timezoneOffset"));let n=r.get("meridiem")!=null&&(r.isCertain("meridiem")||Array.from(r.tags()).some(i=>i.startsWith("casualReference/")));return e.isCertain("meridiem")?t.assign("meridiem",e.get("meridiem")):e.get("meridiem")!=null&&!n&&t.imply("meridiem",e.get("meridiem")),t.get("meridiem")==G.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 Eq=b(()=>{pt();nn()});var Kt,vo=b(()=>{Gs();Eq();Kt=class extends ii{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()?sF(t,n):sF(n,t);return i.index=t.index,i.text=t.text+e+n.text,i}}});var Um,Tq=b(()=>{vo();Um=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|at|after|before|on|of|,|-|\\.|\u2219|:)?\\s*$")}}});var Bte,Vy,_q=b(()=>{JP();Bte=new RegExp("^\\s*,?\\s*\\(?([A-Z]{2,4})\\)?(?=\\W|$)","i"),Vy=class{constructor(e){le(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=Bte.exec(o);if(!s)return;let a=s[1].toUpperCase(),l=i.start.date()??i.refDate??new Date,c={...this.timezoneOverrides,...n},u=z_(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 Ute,Vte,qte,Wte,$a,qy=b(()=>{Ute=new RegExp("^\\s*(?:\\(?(?:GMT|UTC)\\s?)?([+-])(\\d{1,2})(?::?(\\d{2}))?\\)?","i"),Vte=1,qte=2,Wte=3,$a=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=Ute.exec(i);if(!o)return;e.debug(()=>{console.log(`Extracting timezone: '${o[0]}' into : ${n}`)});let s=parseInt(o[qte]),a=parseInt(o[Wte]||"0"),l=s*60+a;l>840||(o[Vte]==="-"&&(l=-l),n.end!=null&&n.end.assign("timezoneOffset",l),n.start.assign("timezoneOffset",l),n.text+=o[0])}),t}}});var wl,Y_=b(()=>{wl=class{refine(e,t){if(t.length<2)return t;let n=[],i=t[0];for(let o=1;o<t.length;o++){let s=t[o];if(s.index>=i.index+i.text.length){n.push(i),i=s;continue}let a=null,l=null;s.text.length>i.text.length?(a=s,l=i):(a=i,l=s),e.debug(()=>{console.log(`${this.constructor.name} remove ${l} by ${a}`)}),i=a}return i!=null&&n.push(i),n}}});function cr(r,e,t){let n=r.getDateWithAdjustedTimezone(),i=zte(n,e,t),o=new Q(r);return o=o.addDurationAsImplied({day:i}),o.assign("weekday",e),o}function zte(r,e,t){let n=r.getDay();switch(t){case"this":return yp(r,e);case"last":return Aq(r,e);case"next":return n==Oe.SUNDAY?e==Oe.SUNDAY?7:e:n==Oe.SATURDAY?e==Oe.SATURDAY?7:e==Oe.SUNDAY?8:1+e:e<n&&e!=Oe.SUNDAY?yp(r,e):yp(r,e)+7}return Hte(r,e)}function Hte(r,e){let t=Aq(r,e),n=yp(r,e);return n<-t?n:t}function yp(r,e){let t=r.getDay(),n=e-t;return n<0&&(n+=7),n}function Aq(r,e){let t=r.getDay(),n=e-t;return n>=0&&(n-=7),n}var Ki=b(()=>{pt();Le()});var Wy,kq=b(()=>{nn();nn();Bt();Ki();Wy=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),_c(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()&&(_c(n.end,s),n.start.date()>n.end.date()&&(s.setDate(s.getDate()+1),_c(n.end,s)))}if(n.start.isOnlyWeekdayComponent()&&i>n.start.date()){let o=yp(i,n.start.get("weekday"))||7,s=gt(i,{day:o});if(_c(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=yp(i,n.start.get("weekday"))||7,l=gt(i,{day:a});_c(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 zy,Sq=b(()=>{Gs();zy=class extends Vu{constructor(t){super();le(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 jte,Gte,Yte,Kte,Dq,Xte,Iq,Pq,Qte,Fq,Mq,yo,bp=b(()=>{fe();jte=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"),Gte=1,Yte=2,Kte=3,Dq=4,Xte=5,Iq=6,Pq=7,Qte=8,Fq=9,Mq=10,yo=class extends L{innerPattern(){return jte}innerExtract(e,t){let n=e.createParsingComponents({year:parseInt(t[Gte]),month:parseInt(t[Yte]),day:parseInt(t[Kte])});if(t[Dq]!=null&&(n.assign("hour",parseInt(t[Dq])),n.assign("minute",parseInt(t[Xte])),t[Iq]!=null&&n.assign("second",parseInt(t[Iq])),t[Pq]!=null&&n.assign("millisecond",parseInt(t[Pq])),t[Qte]!=null)){let i=0;if(t[Fq]){let o=parseInt(t[Fq]),s=0;t[Mq]!=null&&(s=parseInt(t[Mq])),i=o*60,i<0?i-=s:i+=s}n.assign("timezoneOffset",i)}return n.addTag("parser/ISOFormatParser")}}});var kc,K_=b(()=>{Gs();kc=class extends ii{mergeResults(e,t,n){let i=n.clone();return i.index=t.index,i.text=t.text+e+i.text,i.start.assign("weekday",t.start.get("weekday")),i.end&&i.end.assign("weekday",t.start.get("weekday")),i}shouldMergeResults(e,t,n){return t.start.isOnlyWeekdayComponent()&&!t.start.isCertain("hour")&&n.start.isCertain("day")&&e.match(/^,?\s*$/)!=null}}});function Ht(r,e=!1){return r.parsers.unshift(new yo),r.refiners.unshift(new kc),r.refiners.unshift(new $a),r.refiners.unshift(new wl),r.refiners.push(new Vy),r.refiners.push(new wl),r.refiners.push(new Wy),r.refiners.push(new zy(e)),r}var xi=b(()=>{_q();qy();Y_();kq();Sq();bp();K_()});function $r(r){let e=r.getDateWithAdjustedTimezone(),t=new Q(r,{});return nt(t,e),W_(t,e),t.assign("timezoneOffset",r.getTimezoneOffset()),t.addTag("casualReference/now"),t}function Tr(r){let e=r.getDateWithAdjustedTimezone(),t=new Q(r,{});return nt(t,e),Lt(t,e),t.delete("meridiem"),t.addTag("casualReference/today"),t}function gn(r){return Sc(r,1).addTag("casualReference/yesterday")}function vn(r){return Mo(r,1).addTag("casualReference/tomorrow")}function Sc(r,e){return Mo(r,-e)}function Mo(r,e){let t=r.getDateWithAdjustedTimezone(),n=new Q(r,{}),i=new Date(t.getTime());return i.setDate(i.getDate()+e),nt(n,i),Lt(n,i),n.delete("meridiem"),n}function X_(r,e=22){let t=r.getDateWithAdjustedTimezone(),n=new Q(r,{});return nt(n,t),n.imply("hour",e),n.imply("meridiem",G.PM),n.addTag("casualReference/tonight"),n}function Q_(r,e=0){let t=r.getDateWithAdjustedTimezone(),n=new Q(r,{});return t.getHours()<6&&(t=new Date(t.getTime()-1440*60*1e3)),nt(n,t),n.imply("hour",e),n}function Dc(r,e=20){let t=new Q(r,{});return t.imply("meridiem",G.PM),t.imply("hour",e),t.addTag("casualReference/evening"),t}function Z_(r,e=20){let t=r.getDateWithAdjustedTimezone(),n=new Q(r,{});return t=new Date(t.getTime()-1440*60*1e3),nt(n,t),n.imply("hour",e),n.imply("meridiem",G.PM),n.addTag("casualReference/yesterday"),n.addTag("casualReference/evening"),n}function Ic(r){let e=new Q(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 Pc(r,e=6){let t=new Q(r,{});return t.imply("meridiem",G.AM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/morning"),t}function J_(r,e=15){let t=new Q(r,{});return t.imply("meridiem",G.PM),t.imply("hour",e),t.imply("minute",0),t.imply("second",0),t.imply("millisecond",0),t.addTag("casualReference/afternoon"),t}function qu(r){let e=new Q(r,{});return e.imply("meridiem",G.AM),e.assign("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("millisecond",0),e.addTag("casualReference/noon"),e}var oi=b(()=>{Le();nn();pt()});var Zte,Hy,Rq=b(()=>{fe();nn();oi();Zte=/(now|today|tonight|tomorrow|overmorrow|tmr|tmrw|yesterday|last\s*night)(?=\W|$)/i,Hy=class extends L{innerPattern(e){return Zte}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"now":o=$r(e.reference);break;case"today":o=Tr(e.reference);break;case"yesterday":o=gn(e.reference);break;case"tomorrow":case"tmr":case"tmrw":o=vn(e.reference);break;case"tonight":o=X_(e.reference);break;case"overmorrow":o=Mo(e.reference,2);break;default:if(i.match(/last\s*night/)){if(n.getHours()>6){let s=new Date(n.getTime());s.setDate(s.getDate()-1),n=s}nt(o,n),o.imply("hour",0)}break}return o.addTag("parser/ENCasualDateParser"),o}}});var Jte,jy,$q=b(()=>{fe();oi();Jte=/(?:this)?\s{0,3}(morning|afternoon|evening|night|midnight|midday|noon)(?=\W|$)/i,jy=class extends L{innerPattern(){return Jte}innerExtract(e,t){let n=null;switch(t[1].toLowerCase()){case"afternoon":n=J_(e.reference);break;case"evening":case"night":n=Dc(e.reference);break;case"midnight":n=Ic(e.reference);break;case"morning":n=Pc(e.reference);break;case"noon":case"midday":n=qu(e.reference);break}return n&&n.addTag("parser/ENCasualTimeParser"),n}}});var ere,tre,rre,nre,Gy,Oq=b(()=>{on();ze();fe();Ki();pt();ere=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:on\\s*?)?(?:(this|last|past|next)\\s*)?(${ee(H_)}|weekend|weekday)(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(?:of\\s*)?(this|last|past|next)\\s*week)?(?=\\W|$)`,"i"),tre=1,rre=2,nre=3,Gy=class extends L{innerPattern(){return ere}innerExtract(e,t){let n=t[tre],i=t[nre],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[rre].toLowerCase(),l;if(H_[a]!==void 0)l=H_[a];else if(a=="weekend")l=s=="last"?Oe.SUNDAY:Oe.SATURDAY;else if(a=="weekday"){let c=e.reference.getDateWithAdjustedTimezone().getDay();c==Oe.SUNDAY||c==Oe.SATURDAY?l=s=="last"?Oe.FRIDAY:Oe.MONDAY:(l=c-1,l=s=="last"?l-1:l+1,l=l%5+1)}else return null;return cr(e.reference,l,s)}}});var ire,ore,sre,Yy,Nq=b(()=>{on();Le();fe();ze();ire=new RegExp(`(this|last|past|next|after\\s*this)\\s*(${ee(Dy)})(?=\\s*)(?=\\W|$)`,"i"),ore=1,sre=2,Yy=class extends L{innerPattern(){return ire}innerExtract(e,t){let n=t[ore].toLowerCase(),i=t[sre].toLowerCase(),o=Dy[i];if(n=="next"||n.startsWith("after")){let l={};return l[o]=1,Q.createRelativeFromReference(e.reference,l)}if(n=="last"||n=="past"){let l={};return l[o]=-1,Q.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 are,lre,cre,Lq,Bq,aF,vr,cs=b(()=>{zt();are=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"),lre=1,cre=5,Lq=2,Bq=3,aF=4,vr=class{constructor(e){le(this,"groupNumberMonth");le(this,"groupNumberDay");this.groupNumberMonth=e?Bq:Lq,this.groupNumberDay=e?Lq:Bq}pattern(){return are}extract(e,t){let n=t.index+t[lre].length,i=t.index+t[0].length-t[cre].length;if(n>0&&e.text.substring(0,n).match("\\d/?$")||i<e.text.length&&e.text.substring(i).match("^/?\\d"))return;let o=e.text.substring(n,i);if(o.match(/^\d\.\d$/)||o.match(/^\d\.\d{1,2}\.\d{1,2}\s*$/)||!t[aF]&&o.indexOf("/")<0)return;let s=e.createParsingResult(n,o),a=parseInt(t[this.groupNumberMonth]),l=parseInt(t[this.groupNumberDay]);if((a<1||a>12)&&a>12)if(l>=1&&l<=12&&a<=31)[l,a]=[a,l];else return null;if(l<1||l>31)return null;if(s.start.assign("day",l),s.start.assign("month",a),t[aF]){let c=parseInt(t[aF]),u=jr(c);s.start.assign("year",u)}else{let c=ft(e.refDate,l,a);s.start.imply("year",c)}return s.addTag("parser/SlashDateFormatParser")}}});var ure,dre,Ky,Uq=b(()=>{on();Le();fe();Bt();ure=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${Ac})(?=\\W|$)`,"i"),dre=new RegExp(`(this|last|past|next|after|\\+|-)\\s*(${Uu})(?=\\W|$)`,"i"),Ky=class extends L{constructor(t=!0){super();le(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?ure:dre}innerExtract(t,n){let i=n[1].toLowerCase(),o=js(n[2]);if(!o)return null;switch(i){case"last":case"past":case"-":o=tt(o);break}return Q.createRelativeFromReference(t.reference,o)}}});function pre(r){return r.text.match(/^[+-]/i)!=null}function Vq(r){return r.text.match(/^-/i)!=null}var Xy,qq=b(()=>{Gs();Le();on();Bt();Xy=class extends ii{shouldMergeResults(e,t,n){return e.match(/^\s*$/i)?pre(n)||Vq(n):!1}mergeResults(e,t,n,i){let o=js(n.text);Vq(n)&&(o=tt(o));let s=Q.createRelativeFromReference(ct.fromDate(t.start.date()),o);return new at(t.reference,t.index,`${t.text}${e}${n.text}`,s)}}});function Wq(r){return r.text.match(/\s+(before|from)$/i)!=null}function fre(r){return r.text.match(/\s+(after|since)$/i)!=null}var Qy,zq=b(()=>{Gs();Le();on();Bt();Qy=class extends ii{patternBetween(){return/^\s*$/i}shouldMergeResults(e,t,n){return!e.match(this.patternBetween())||!Wq(t)&&!fre(t)?!1:!!n.start.get("day")&&!!n.start.get("month")&&!!n.start.get("year")}mergeResults(e,t,n){let i=js(t.text);Wq(t)&&(i=tt(i));let o=Q.createRelativeFromReference(ct.fromDate(n.start.date()),i);return new at(n.reference,t.index,`${t.text}${e}${n.text}`,o)}}});var mre,hre,Zy,Hq=b(()=>{on();mre=new RegExp(`^\\s*(${Bu})`,"i"),hre=1,Zy=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=mre.exec(i);if(!o||o[0].trim().length<=3)return;e.debug(()=>{console.log(`Extracting year: '${o[0]}' into : ${n}`)});let s=bl(o[hre]);n.end!=null&&n.end.assign("year",s),n.start.assign("year",s),n.text+=o[0]}),t}}});var Jy,jq=b(()=>{Gs();Jy=class extends Vu{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 wp,lF=b(()=>{oq();cq();dq();fq();hq();gq();vq();yq();bq();wq();Cq();Tq();xi();Rq();$q();Oq();Nq();cs();Uq();qq();zq();Y_();Hq();jq();wp=class{createCasualConfiguration(e=!1){let t=this.createConfiguration(!1,e);return t.parsers.push(new Hy),t.parsers.push(new jy),t.parsers.push(new My),t.parsers.push(new Yy),t.parsers.push(new Ky),t.refiners.push(new Jy),t}createConfiguration(e=!0,t=!1){let n=Ht({parsers:[new vr(t),new Iy(e),new Py,new Fy(t),new Gy,new Oy,new Ny(e),new Ly(e),new By(e),new $y],refiners:[new Um]},e);return n.parsers.unshift(new Ry(e)),n.refiners.unshift(new Qy),n.refiners.unshift(new Xy),n.refiners.unshift(new wl),n.refiners.push(new Um),n.refiners.push(new Zy),n.refiners.push(new Uy),n}}});var Se,eb,si=b(()=>{Le();lF();Se=class r{constructor(e){le(this,"parsers");le(this,"refiners");le(this,"defaultConfig",new wp);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 eb(e,t,n),o=[];return this.parsers.forEach(s=>{let a=r.executeParser(i,s);o=o.concat(a)}),o.sort((s,a)=>s.index-a.index),this.refiners.forEach(function(s){o=s.refine(i,o)}),o}static executeParser(e,t){let n=[],i=t.pattern(e),o=e.text,s=e.text,a=i.exec(s);for(;a;){let l=a.index+o.length-s.length;a.index=l;let c=t.extract(e,a);if(!c){s=o.substring(a.index+1),a=i.exec(s);continue}let u=null;c instanceof at?u=c:c instanceof Q?(u=e.createParsingResult(a.index,a[0]),u.start=c):u=e.createParsingResult(a.index,a[0],c);let d=u.index,f=u.text;e.debug(()=>console.log(`${t.constructor.name} extracted (at index=${d}) '${f}'`)),n.push(u),s=o.substring(d+f.length),a=i.exec(s)}return n}},eb=class{constructor(e,t,n){le(this,"text");le(this,"option");le(this,"reference");le(this,"refDate");this.text=e,this.option=n??{},this.reference=ct.fromInput(t,this.option.timezones),this.refDate=this.reference.instant}createParsingComponents(e){return e instanceof Q?e:new Q(this.reference,e)}createParsingResult(e,t,n,i){let o=typeof t=="string"?t:this.text.substring(e,t),s=n?this.createParsingComponents(n):null,a=i?this.createParsingComponents(i):null;return new at(this.reference,e,o,s,a)}debug(e){this.option.debug&&(this.option.debug instanceof Function?this.option.debug(e):this.option.debug.debug(e))}}});var uF={};Zr(uF,{Chrono:()=>Se,GB:()=>gre,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>tb,configuration:()=>eA,parse:()=>vre,parseDate:()=>yre,strict:()=>cF});function vre(r,e,t){return tb.parse(r,e,t)}function yre(r,e,t){return tb.parseDate(r,e,t)}var eA,tb,cF,gre,Gq=b(()=>{si();Le();pt();lF();eA=new wp,tb=new Se(eA.createCasualConfiguration(!1)),cF=new Se(eA.createConfiguration(!0,!1)),gre=new Se(eA.createCasualConfiguration(!0))});var rb,Yq=b(()=>{Ra();rb=class extends Gr{primaryPrefix(){return"(?:(?:um|von)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|bis)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});function hF(r){let e=r.toLowerCase();return dF[e]!==void 0?dF[e]:e==="ein"||e==="einer"||e==="einem"||e==="einen"||e==="eine"?1:e.match(/wenigen/)?2:e.match(/halb/)||e.match(/halben/)?.5:e.match(/einigen/)?3:e.match(/mehreren/)?7:parseFloat(e)}function Qq(r){if(/v/i.test(r))return-parseInt(r.replace(/[^0-9]+/gi,""));if(/n/i.test(r))return parseInt(r.replace(/[^0-9]+/gi,""));if(/z/i.test(r))return parseInt(r.replace(/[^0-9]+/gi,""));let e=parseInt(r);return jr(e)}function eW(r){let e={},t=r,n=Kq.exec(t);for(;n;)bre(e,n),t=t.substring(n[0].length),n=Kq.exec(t);return e}function bre(r,e){let t=hF(e[1]),n=nb[e[2].toLowerCase()];r[n]=t}var pF,fF,dF,nb,mF,Xq,Zq,Kq,Jq,Vm=b(()=>{ze();zt();pF={sonntag:0,so:0,montag:1,mo:1,dienstag:2,di:2,mittwoch:3,mi:3,donnerstag:4,do:4,freitag:5,fr:5,samstag:6,sa:6},fF={januar:1,j\u00E4nner:1,janner:1,jan:1,"jan.":1,februar:2,feber:2,feb:2,"feb.":2,m\u00E4rz:3,maerz:3,m\u00E4r:3,"m\xE4r.":3,mrz:3,"mrz.":3,april:4,apr:4,"apr.":4,mai:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,august:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,"sept.":9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,dezember:12,dez:12,"dez.":12},dF={eins:1,eine:1,einem:1,einen:1,einer:1,zwei:2,drei:3,vier:4,f\u00FCnf:5,fuenf:5,sechs:6,sieben:7,acht:8,neun:9,zehn:10,elf:11,zw\u00F6lf:12,zwoelf:12},nb={sek:"second",sekunde:"second",sekunden:"second",min:"minute",minute:"minute",minuten:"minute",h:"hour",std:"hour",stunde:"hour",stunden:"hour",tag:"day",tage:"day",tagen:"day",woche:"week",wochen:"week",monat:"month",monate:"month",monaten:"month",monats:"month",quartal:"quarter",quartals:"quarter",quartale:"quarter",quartalen:"quarter",a:"year",j:"year",jr:"year",jahr:"year",jahre:"year",jahren:"year",jahres:"year"},mF=`(?:${ee(dF)}|[0-9]+|[0-9]+\\.[0-9]+|halb?|halbe?|einigen?|wenigen?|mehreren?)`;Xq="(?:[0-9]{1,4}(?:\\s*[vn]\\.?\\s*(?:C(?:hr)?|(?:u\\.?|d\\.?(?:\\s*g\\.?)?)?\\s*Z)\\.?|\\s*(?:u\\.?|d\\.?(?:\\s*g\\.)?)\\s*Z\\.?)?)";Zq=`(${mF})\\s{0,5}(${ee(nb)})\\s{0,5}`,Kq=new RegExp(Zq,"i"),Jq=Er("",Zq)});var wre,Cre,xre,Ere,ib,tW=b(()=>{Vm();ze();fe();Ki();wre=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:a[mn]\\s*?)?(?:(diese[mn]|letzte[mn]|n(?:\xE4|ae)chste[mn])\\s*)?(${ee(pF)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(diese|letzte|n(?:\xE4|ae)chste)\\s*woche)?(?=\\W|$)`,"i"),Cre=1,xre=3,Ere=2,ib=class extends L{innerPattern(){return wre}innerExtract(e,t){let n=t[Ere].toLowerCase(),i=pF[n],o=t[Cre],s=t[xre],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/letzte/)?l="last":a.match(/chste/)?l="next":a.match(/diese/)&&(l="this"),cr(e.reference,i,l)}}});var Tre,_re,Are,rW,nW,iW,ob,oW=b(()=>{pt();Tre=new RegExp("(^|\\s|T)(?:(?:um|von)\\s*)?(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s)?)?(?:\\s*Uhr)?(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?(?=\\W|$)","i"),_re=new RegExp("^\\s*(\\-|\\\u2013|\\~|\\\u301C|bis(?:\\s+um)?|\\?)\\s*(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s)?)?(?:\\s*Uhr)?(?:\\s*(morgens|vormittags|nachmittags|abends|nachts|am\\s+(?:Morgen|Vormittag|Nachmittag|Abend)|in\\s+der\\s+Nacht))?(?=\\W|$)","i"),Are=2,rW=3,nW=4,iW=5,ob=class r{pattern(e){return Tre}extract(e,t){let n=e.createParsingResult(t.index+t[1].length,t[0].substring(t[1].length));if(n.text.match(/^\d{4}$/)||(n.start=r.extractTimeComponent(n.start.clone(),t),!n.start))return t.index+=t[0].length,null;let i=e.text.substring(t.index+t[0].length),o=_re.exec(i);return o&&(n.end=r.extractTimeComponent(n.start.clone(),o),n.end&&(n.text+=o[0])),n}static extractTimeComponent(e,t){let n=0,i=0,o=null;if(n=parseInt(t[Are]),t[rW]!=null&&(i=parseInt(t[rW])),i>=60||n>24)return null;if(n>=12&&(o=G.PM),t[iW]!=null){if(n>12)return null;let s=t[iW].toLowerCase();s.match(/morgen|vormittag/)&&(o=G.AM,n==12&&(n=0)),s.match(/nachmittag|abend/)&&(o=G.PM,n!=12&&(n+=12)),s.match(/nacht/)&&(n==12?(o=G.AM,n=0):n<6?o=G.AM:(o=G.PM,n+=12))}if(e.assign("hour",n),e.assign("minute",i),o!==null?e.assign("meridiem",o):n<12?e.imply("meridiem",G.AM):e.imply("meridiem",G.PM),t[nW]!=null){let s=parseInt(t[nW]);if(s>=60)return null;e.assign("second",s)}return e}}});var sb,sW=b(()=>{go();sb=class extends Yt{patternBetween(){return/^\s*(bis(?:\s*(?:am|zum))?|-)\s*$/i}}});var ab,aW=b(()=>{vo();ab=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|um|am|,|-)?\\s*$")}}});var Cp,gF=b(()=>{pt();fe();nn();Cp=class r extends L{innerPattern(e){return/(diesen)?\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[2].toLowerCase(),o=e.createParsingComponents();return Lt(o,n),r.extractTimeComponents(o,i)}static extractTimeComponents(e,t){switch(t){case"morgen":e.imply("hour",6),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/morning");break;case"vormittag":e.imply("hour",9),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/morning");break;case"mittag":case"mittags":e.imply("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/noon");break;case"nachmittag":e.imply("hour",15),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/afternoon");break;case"abend":e.imply("hour",18),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/evening");break;case"nacht":e.imply("hour",22),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/evening");break;case"mitternacht":e.get("hour")>1&&e.addDurationAsImplied({day:1}),e.imply("hour",0),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/midnight");break}return e}}});var kre,Sre,Dre,lb,lW=b(()=>{fe();nn();gF();oi();Bt();kre=new RegExp("(jetzt|heute|morgen|\xFCbermorgen|uebermorgen|gestern|vorgestern|letzte\\s*nacht)(?:\\s*(morgen|vormittag|mittags?|nachmittag|abend|nacht|mitternacht))?(?=\\W|$)","i"),Sre=1,Dre=2,lb=class extends L{innerPattern(e){return kre}innerExtract(e,t){let n=e.reference.getDateWithAdjustedTimezone(),i=(t[Sre]||"").toLowerCase(),o=(t[Dre]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"jetzt":s=$r(e.reference);break;case"heute":s=Tr(e.reference);break;case"morgen":n=gt(n,{day:1}),nt(s,n),Lt(s,n);break;case"\xFCbermorgen":case"uebermorgen":n=gt(n,{day:2}),nt(s,n),Lt(s,n);break;case"gestern":n=gt(n,{day:-1}),nt(s,n),Lt(s,n);break;case"vorgestern":n=gt(n,{day:-2}),nt(s,n),Lt(s,n);break;default:i.match(/letzte\s*nacht/)&&(n.getHours()>6&&(n=gt(n,{day:-1})),nt(s,n),s.imply("hour",0));break}return o&&(s=Cp.extractTimeComponents(s,o)),s}}});var Ire,cW,uW,Pre,dW,cb,pW=b(()=>{zt();Vm();Vm();ze();fe();Ire=new RegExp(`(?:am\\s*?)?(?:den\\s*?)?([0-9]{1,2})\\.(?:\\s*(?:bis(?:\\s*(?:am|zum))?|\\-|\\\u2013|\\s)\\s*([0-9]{1,2})\\.?)?\\s*(${ee(fF)})(?:(?:-|/|,?\\s*)(${Xq}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),cW=1,uW=2,Pre=3,dW=4,cb=class extends L{innerPattern(){return Ire}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=fF[t[Pre].toLowerCase()],o=parseInt(t[cW]);if(o>31)return t.index=t.index+t[cW].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[dW]){let s=Qq(t[dW]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[uW]){let s=parseInt(t[uW]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var ub,fW=b(()=>{Vm();Le();fe();ze();Bt();ub=class extends L{constructor(){super()}innerPattern(){return new RegExp(`(?:\\s*((?:n\xE4chste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?|vor|in)\\s*)?(${mF})?(?:\\s*(n\xE4chste|kommende|folgende|letzte|vergangene|vorige|vor(?:her|an)gegangene)(?:s|n|m|r)?)?\\s*(${ee(nb)})(?=\\W|$)`,"i")}innerExtract(e,t){let n=t[2]?hF(t[2]):1,i=nb[t[4].toLowerCase()],o={};o[i]=n;let s=t[1]||t[3]||"";if(s=s.toLowerCase(),!!s)return(/vor/.test(s)||/letzte/.test(s)||/vergangen/.test(s))&&(o=tt(o)),Q.createRelativeFromReference(e.reference,o)}}});var db,mW=b(()=>{Vm();Le();fe();db=class extends L{innerPattern(){return new RegExp(`(?:in|f\xFCr|w\xE4hrend)\\s*(${Jq})(?=\\W|$)`,"i")}innerExtract(e,t){let n=eW(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var bF={};Zr(bF,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>vF,createCasualConfiguration:()=>hW,createConfiguration:()=>yF,parse:()=>Mre,parseDate:()=>Rre,strict:()=>Fre});function Mre(r,e,t){return vF.parse(r,e,t)}function Rre(r,e,t){return vF.parseDate(r,e,t)}function hW(r=!0){let e=yF(!1,r);return e.parsers.unshift(new Cp),e.parsers.unshift(new lb),e.parsers.unshift(new ub),e}function yF(r=!0,e=!0){return Ht({parsers:[new yo,new vr(e),new rb,new ob,new cb,new ib,new db],refiners:[new sb,new ab]},r)}var vF,Fre,gW=b(()=>{xi();si();Le();pt();cs();bp();Yq();tW();oW();sW();aW();lW();gF();pW();fW();mW();vF=new Se(hW()),Fre=new Se(yF(!0))});var pb,vW=b(()=>{pt();fe();nn();oi();pb=class extends L{innerPattern(e){return/(maintenant|aujourd'hui|demain|hier|cette\s*nuit|la\s*veille)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"maintenant":return $r(e.reference);case"aujourd'hui":return Tr(e.reference);case"hier":return gn(e.reference);case"demain":return vn(e.reference);default:if(i.match(/cette\s*nuit/))nt(o,n),o.imply("hour",22),o.imply("meridiem",G.PM);else if(i.match(/la\s*veille/)){let s=new Date(n.getTime());s.setDate(s.getDate()-1),nt(o,s),o.imply("hour",0)}}return o}}});var fb,yW=b(()=>{pt();fe();fb=class extends L{innerPattern(e){return/(cet?)?\s*(matin|soir|après-midi|aprem|a midi|à minuit)(?=\W|$)/i}innerExtract(e,t){let n=t[2].toLowerCase(),i=e.createParsingComponents();switch(n){case"apr\xE8s-midi":case"aprem":i.imply("hour",14),i.imply("minute",0),i.imply("meridiem",G.PM),i.addTag("casualReference/afternoon");break;case"soir":i.imply("hour",18),i.imply("minute",0),i.imply("meridiem",G.PM),i.addTag("casualReference/evening");break;case"matin":i.imply("hour",8),i.imply("minute",0),i.imply("meridiem",G.AM),i.addTag("casualReference/morning");break;case"a midi":i.imply("hour",12),i.imply("minute",0),i.imply("meridiem",G.AM),i.addTag("casualReference/noon");break;case"\xE0 minuit":i.imply("hour",0),i.imply("meridiem",G.AM),i.addTag("casualReference/midnight");break}return i}}});var mb,bW=b(()=>{Ra();mb=class extends Gr{primaryPrefix(){return"(?:(?:[\xE0a])\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|[\xE0a]|\\?)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});var hb,wW=b(()=>{vo();hb=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\xE0|a|au|vers|de|,|-)?\\s*$")}}});var gb,CW=b(()=>{go();gb=class extends Yt{patternBetween(){return/^\s*(à|a|au|-)\s*$/i}}});function TF(r){let e=r.toLowerCase();return wF[e]!==void 0?wF[e]:e==="une"||e==="un"?1:e.match(/quelques?/)?3:e.match(/demi-?/)?.5:parseFloat(e)}function AF(r){let e=r.toLowerCase();return e=e.replace(/(?:er)$/i,""),parseInt(e)}function TW(r){if(/AC/i.test(r))return r=r.replace(/BC/i,""),-parseInt(r);if(/AD/i.test(r)||/C/i.test(r))return r=r.replace(/[^\d]+/i,""),parseInt(r);let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}function rA(r){let e={},t=r,n=xW.exec(t);for(;n;)$re(e,n),t=t.substring(n[0].length),n=xW.exec(t);return e}function $re(r,e){let t=TF(e[1]),n=vb[e[2].toLowerCase()];r[n]=t}var CF,xF,wF,vb,EF,_F,EW,_W,xW,tA,Wu=b(()=>{ze();CF={dimanche:0,dim:0,lundi:1,lun:1,mardi:2,mar:2,mercredi:3,mer:3,jeudi:4,jeu:4,vendredi:5,ven:5,samedi:6,sam:6},xF={janvier:1,jan:1,"jan.":1,janv:1,"janv.":1,f\u00E9vrier:2,f\u00E9v:2,"f\xE9v.":2,f\u00E9vr:2,"f\xE9vr.":2,fevrier:2,fev:2,"fev.":2,fevr:2,"fevr.":2,mars:3,mar:3,"mar.":3,avril:4,avr:4,"avr.":4,mai:5,juin:6,"juin.":6,jun:6,"jun.":6,juillet:7,juil:7,"juil.":7,jul:7,"jul.":7,ao\u00FBt:8,"ao\xFBt.":8,aout:8,"aout.":8,septembre:9,sep:9,"sep.":9,sept:9,"sept.":9,octobre:10,oct:10,"oct.":10,novembre:11,nov:11,"nov.":11,d\u00E9cembre:12,decembre:12,dec:12,"dec.":12,d\u00E9c:12,"d\xE9c.":12},wF={un:1,deux:2,trois:3,quatre:4,cinq:5,six:6,sept:7,huit:8,neuf:9,dix:10,onze:11,douze:12,treize:13},vb={sec:"second",seconde:"second",secondes:"second",min:"minute",mins:"minute",minute:"minute",minutes:"minute",h:"hour",hr:"hour",hrs:"hour",heure:"hour",heures:"hour",jour:"day",jours:"day",semaine:"week",semaines:"week",mois:"month",trimestre:"quarter",trimestres:"quarter",ans:"year",ann\u00E9e:"year",ann\u00E9es:"year"},EF=`(?:${ee(wF)}|[0-9]+|[0-9]+\\.[0-9]+|une?\\b|quelques?|demi-?)`;_F="(?:[0-9]{1,2}(?:er)?)";EW="(?:[1-9][0-9]{0,3}\\s*(?:AC|AD|p\\.\\s*C(?:hr?)?\\.\\s*n\\.)|[1-2][0-9]{3}|[5-9][0-9])";_W=`(${EF})\\s{0,5}(${ee(vb)})\\s{0,5}`,xW=new RegExp(_W,"i"),tA=Er("",_W)});var Ore,Nre,Lre,yb,AW=b(()=>{Wu();ze();fe();Ki();Ore=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(?:ce)\\s*)?(${ee(CF)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(dernier|prochain)\\s*)?(?=\\W|\\d|$)`,"i"),Nre=1,Lre=2,yb=class extends L{innerPattern(){return Ore}innerExtract(e,t){let n=t[Nre].toLowerCase(),i=CF[n];if(i===void 0)return null;let o=t[Lre];o=o||"",o=o.toLowerCase();let s=null;return o=="dernier"?s="last":o=="prochain"&&(s="next"),cr(e.reference,i,s)}}});var Bre,Ure,Vre,kW,SW,DW,bb,IW=b(()=>{pt();Bre=new RegExp("(^|\\s|T)(?:(?:[\xE0a])\\s*)?(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s|:)?)?(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?(?=\\W|$)","i"),Ure=new RegExp("^\\s*(\\-|\\\u2013|\\~|\\\u301C|[\xE0a]|\\?)\\s*(\\d{1,2})(?:h|:)?(?:(\\d{1,2})(?:m|:)?)?(?:(\\d{1,2})(?:s|:)?)?(?:\\s*(A\\.M\\.|P\\.M\\.|AM?|PM?))?(?=\\W|$)","i"),Vre=2,kW=3,SW=4,DW=5,bb=class r{pattern(e){return Bre}extract(e,t){let n=e.createParsingResult(t.index+t[1].length,t[0].substring(t[1].length));if(n.text.match(/^\d{4}$/)||(n.start=r.extractTimeComponent(n.start.clone(),t),!n.start))return t.index+=t[0].length,null;let i=e.text.substring(t.index+t[0].length),o=Ure.exec(i);return o&&(n.end=r.extractTimeComponent(n.start.clone(),o),n.end&&(n.text+=o[0])),n}static extractTimeComponent(e,t){let n=0,i=0,o=null;if(n=parseInt(t[Vre]),t[kW]!=null&&(i=parseInt(t[kW])),i>=60||n>24)return null;if(n>=12&&(o=G.PM),t[DW]!=null){if(n>12)return null;let s=t[DW][0].toLowerCase();s=="a"&&(o=G.AM,n==12&&(n=0)),s=="p"&&(o=G.PM,n!=12&&(n+=12))}if(e.assign("hour",n),e.assign("minute",i),o!==null?e.assign("meridiem",o):n<12?e.imply("meridiem",G.AM):e.imply("meridiem",G.PM),t[SW]!=null){let s=parseInt(t[SW]);if(s>=60)return null;e.assign("second",s)}return e}}});var qre,PW,FW,Wre,MW,wb,RW=b(()=>{zt();Wu();Wu();Wu();ze();fe();qre=new RegExp(`(?:on\\s*?)?(${_F})(?:\\s*(?:au|\\-|\\\u2013|jusqu'au?|\\s)\\s*(${_F}))?(?:-|/|\\s*(?:de)?\\s*)(${ee(xF)})(?:(?:-|/|,?\\s*)(${EW}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),PW=1,FW=2,Wre=3,MW=4,wb=class extends L{innerPattern(){return qre}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=xF[t[Wre].toLowerCase()],o=AF(t[PW]);if(o>31)return t.index=t.index+t[PW].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[MW]){let s=TW(t[MW]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[FW]){let s=AF(t[FW]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Cb,$W=b(()=>{Wu();Le();fe();Bt();Cb=class extends L{constructor(){super()}innerPattern(){return new RegExp(`il y a\\s*(${tA})(?=(?:\\W|$))`,"i")}innerExtract(e,t){let n=rA(t[1]),i=tt(n);return Q.createRelativeFromReference(e.reference,i)}}});var xb,OW=b(()=>{Wu();Le();fe();xb=class extends L{innerPattern(){return new RegExp(`(?:dans|en|pour|pendant|de)\\s*(${tA})(?=\\W|$)`,"i")}innerExtract(e,t){let n=rA(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var Eb,NW=b(()=>{Wu();Le();fe();ze();Bt();Eb=class extends L{constructor(){super()}innerPattern(){return new RegExp(`(?:les?|la|l'|du|des?)\\s*(${EF})?(?:\\s*(prochaine?s?|derni[e\xE8]re?s?|pass[\xE9e]e?s?|pr[\xE9e]c[\xE9e]dents?|suivante?s?))?\\s*(${ee(vb)})(?:\\s*(prochaine?s?|derni[e\xE8]re?s?|pass[\xE9e]e?s?|pr[\xE9e]c[\xE9e]dents?|suivante?s?))?(?=\\W|$)`,"i")}innerExtract(e,t){let n=t[1]?TF(t[1]):1,i=vb[t[3].toLowerCase()],o={};o[i]=n;let s=t[2]||t[4]||"";if(s=s.toLowerCase(),!!s)return(/derni[eè]re?s?/.test(s)||/pass[ée]e?s?/.test(s)||/pr[ée]c[ée]dents?/.test(s))&&(o=tt(o)),Q.createRelativeFromReference(e.reference,o)}}});var DF={};Zr(DF,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>kF,createCasualConfiguration:()=>LW,createConfiguration:()=>SF,parse:()=>Hre,parseDate:()=>jre,strict:()=>zre});function Hre(r,e,t){return kF.parse(r,e,t)}function jre(r,e,t){return kF.parseDate(r,e,t)}function LW(r=!0){let e=SF(!1,r);return e.parsers.unshift(new pb),e.parsers.unshift(new fb),e.parsers.unshift(new Eb),e}function SF(r=!0,e=!0){return Ht({parsers:[new vr(e),new wb,new mb,new bb,new Cb,new xb,new yb],refiners:[new hb,new gb]},r)}var kF,zre,BW=b(()=>{xi();si();Le();pt();vW();yW();cs();bW();wW();CW();AW();IW();RW();$W();OW();NW();kF=new Se(LW()),zre=new Se(SF(!0))});function Ys(r){return String(r).replace(/\u2019/g,"'").replace(/\u201D/g,'"').replace(/\u3000/g," ").replace(/\uFFE5/g,"\xA5").replace(/[\uFF01\uFF03-\uFF06\uFF08\uFF09\uFF0C-\uFF19\uFF1C-\uFF1F\uFF21-\uFF3B\uFF3D\uFF3F\uFF41-\uFF5B\uFF5D\uFF5E]/g,Gre)}function Gre(r){return String.fromCharCode(r.charCodeAt(0)-65248)}function nA(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?Cl[n]:e*Cl[n]:e+=Cl[n]}return e}var Cl,qm,Wm=b(()=>{Cl={\u96F6:0,"\u3007":0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10},qm={\u65E5:0,\u6708:1,\u706B:2,\u6C34:3,\u6728:4,\u91D1:5,\u571F:6}});var Yre,UW,Kre,IF,Xre,Qre,Zre,Tb,VW=b(()=>{Wm();zt();Yre=/(?:(?:([同今本])|((昭和|平成|令和)?([0-90-9]{1,4}|元)))年\s*)?([0-90-9]{1,2})月\s*([0-90-9]{1,2})日/i,UW=1,Kre=2,IF=3,Xre=4,Qre=5,Zre=6,Tb=class{pattern(){return Yre}extract(e,t){let n=parseInt(Ys(t[Qre])),i=parseInt(Ys(t[Zre])),o=e.createParsingComponents({day:i,month:n});if(t[UW]&&t[UW].match("\u540C|\u4ECA|\u672C")&&o.assign("year",e.reference.getDateWithAdjustedTimezone().getFullYear()),t[Kre]){let s=t[Xre],a=s=="\u5143"?1:parseInt(Ys(s));t[IF]=="\u4EE4\u548C"?a+=2018:t[IF]=="\u5E73\u6210"?a+=1988:t[IF]=="\u662D\u548C"&&(a+=1925),o.assign("year",a)}else{let s=ft(e.refDate,i,n);o.imply("year",s)}return o}}});var _b,qW=b(()=>{go();_b=class extends Yt{patternBetween(){return/^\s*(から|-|ー|-|~|~)\s*$/i}}});function ene(r){switch(r){case"\u304D\u3087\u3046":return"\u4ECA\u65E5";case"\u307B\u3093\u3058\u3064":return"\u672C\u65E5";case"\u304D\u306E\u3046":return"\u6628\u65E5";case"\u3042\u3057\u305F":return"\u660E\u65E5";case"\u3053\u3093\u3084":return"\u4ECA\u591C";case"\u3053\u3093\u3086\u3046":return"\u4ECA\u5915";case"\u3053\u3093\u3070\u3093":return"\u4ECA\u6669";case"\u3051\u3055":return"\u4ECA\u671D";default:return r}}var Jre,Ab,WW=b(()=>{pt();oi();Jre=/今日|きょう|本日|ほんじつ|昨日|きのう|明日|あした|今夜|こんや|今夕|こんゆう|今晩|こんばん|今朝|けさ/i;Ab=class{pattern(){return Jre}extract(e,t){let n=ene(t[0]),i=e.createParsingComponents();switch(n){case"\u6628\u65E5":return gn(e.reference);case"\u660E\u65E5":return vn(e.reference);case"\u672C\u65E5":case"\u4ECA\u65E5":return Tr(e.reference)}n=="\u4ECA\u591C"||n=="\u4ECA\u5915"||n=="\u4ECA\u6669"?(i.imply("hour",22),i.assign("meridiem",G.PM)):n.match("\u4ECA\u671D")&&(i.imply("hour",6),i.assign("meridiem",G.AM));let o=e.refDate;return i.assign("day",o.getDate()),i.assign("month",o.getMonth()+1),i.assign("year",o.getFullYear()),i}}});var tne,kb,zW=b(()=>{Wm();Ki();tne=new RegExp("((?<prefix>\u524D\u306E|\u6B21\u306E|\u4ECA\u9031))?(?<weekday>"+Object.keys(qm).join("|")+")(?:\u66DC\u65E5|\u66DC)","i"),kb=class{pattern(){return tne}extract(e,t){let n=t.groups.weekday,i=qm[n];if(i===void 0)return null;let o=t.groups.prefix||"",s=null;return o.match(/前の/)?s="last":o.match(/次の/)?s="next":o.match(/今週/)&&(s="this"),cr(e.reference,i,s)}}});var rne,HW,nne,ine,Sb,jW=b(()=>{zt();Wm();rne=new RegExp("([0-9\uFF10-\uFF19]{4}[\\/|\\\uFF0F])?([0-1\uFF10-\uFF11]{0,1}[0-9\uFF10-\uFF19]{1})(?:[\\/|\\\uFF0F]([0-3\uFF10-\uFF13]{0,1}[0-9\uFF10-\uFF19]{1}))","i"),HW=1,nne=2,ine=3,Sb=class{pattern(){return rne}extract(e,t){let n=e.createParsingComponents(),i=parseInt(Ys(t[nne])),o=parseInt(Ys(t[ine]));if(i<1||i>12||o<1||o>31)return null;if(n.assign("day",o),n.assign("month",i),t[HW]){let s=parseInt(Ys(t[HW])),a=jr(s);n.assign("year",a)}else{let s=ft(e.reference.instant,o,i);n.imply("year",s)}return n}}});function ZW(r,e,t,n,i){let o=0,s=-1,a=r.createParsingComponents();if(o=parseInt(Ys(e)),isNaN(o)&&(o=nA(e)),o>24)return null;if(t){let l;if(t==="\u534A"?l=30:(l=parseInt(Ys(t)),isNaN(l)&&(l=nA(t))),l>=60)return null;a.assign("minute",l)}if(n){let l=parseInt(Ys(n));if(isNaN(l)&&(l=nA(n)),l>=60)return null;a.assign("second",l)}if(i){if(o>12)return null;let l=i;l==="\u5348\u524D"||l[0].toLowerCase()==="a"?(s=G.AM,o===12&&(o=0)):(l==="\u5348\u5F8C"||l[0].toLowerCase()==="p")&&(s=G.PM,o!=12&&(o+=12))}return a.assign("hour",o),s>=0?a.assign("meridiem",s):o<12?a.imply("meridiem",G.AM):a.imply("meridiem",G.PM),a}var one,sne,GW,YW,KW,XW,QW,Db,JW=b(()=>{fe();pt();Wm();one=new RegExp("(?:(\u5348\u524D|\u5348\u5F8C|A.M.|P.M.|AM|PM))?(?:[\\s,\uFF0C\u3001]*)(?:([0-9\uFF10-\uFF19]+|["+Object.keys(Cl).join("")+"]+)(?:\\s*)(?:\u6642(?!\u9593)|:|\uFF1A)(?:\\s*)([0-9\uFF10-\uFF19]+|\u534A|["+Object.keys(Cl).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)([0-9\uFF10-\uFF19]+|["+Object.keys(Cl).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),sne=new RegExp("(?:^\\s*(?:\u304B\u3089|\\-|\\\u2013|\\\uFF0D|\\~|\\\u301C)\\s*)(?:(\u5348\u524D|\u5348\u5F8C|A.M.|P.M.|AM|PM))?(?:[\\s,\uFF0C\u3001]*)(?:([0-9\uFF10-\uFF19]+|["+Object.keys(Cl).join("")+"]+)(?:\\s*)(?:\u6642|:|\uFF1A)(?:\\s*)([0-9\uFF10-\uFF19]+|\u534A|["+Object.keys(Cl).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)([0-9\uFF10-\uFF19]+|["+Object.keys(Cl).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),GW=1,YW=2,KW=3,XW=4,QW=5,Db=class extends L{innerPattern(){return one}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]);return n.start=ZW(e,t[YW],t[KW],t[XW],t[GW]??t[QW]),n.start?(t=sne.exec(e.text.substring(n.index+n.text.length)),t?(n.text=n.text+t[0],n.end=ZW(e,t[YW],t[KW],t[XW],t[GW]??t[QW]),n.end?(!n.end.isCertain("meridiem")&&n.start.isCertain("meridiem")&&(n.end.imply("meridiem",n.start.get("meridiem")),n.start.get("meridiem")===G.PM&&(n.start.get("hour")-12>n.end.get("hour")?n.end.imply("meridiem",G.AM):n.end.get("hour")<12&&n.end.assign("hour",n.end.get("hour")+12))),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n):null):n):(t.index+=t[0].length,null)}}});var Ib,e3=b(()=>{vo();Ib=class extends Kt{patternBetween(){return/^\s*(の)?\s*$/i}}});var Pb,t3=b(()=>{Gs();Pb=class extends ii{mergeResults(e,t,n){let i=t.clone();return i.text=t.text+e+n.text,i.start.assign("weekday",n.start.get("weekday")),i.end&&i.end.assign("weekday",n.start.get("weekday")),i}shouldMergeResults(e,t,n){return t.start.isCertain("day")&&n.start.isOnlyWeekdayComponent()&&!n.start.isCertain("hour")&&e.match(/^[,、の]?\s*$/)!==null}}});var ane,Fb,r3=b(()=>{Wm();Ki();ane=new RegExp("(?:\\(|\\\uFF08)(?<weekday>"+Object.keys(qm).join("|")+")(?:\\)|\\\uFF09)","i"),Fb=class{pattern(){return ane}extract(e,t){let n=t.groups.weekday,i=qm[n];return i===void 0?null:cr(e.reference,i)}}});var MF={};Zr(MF,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>PF,createCasualConfiguration:()=>n3,createConfiguration:()=>FF,parse:()=>cne,parseDate:()=>une,strict:()=>lne});function cne(r,e,t){return PF.parse(r,e,t)}function une(r,e,t){return PF.parseDate(r,e,t)}function n3(){let r=FF(!1);return r.parsers.unshift(new Ab),r}function FF(r=!0){let e=Ht({parsers:[new Tb,new kb,new Fb,new Sb,new Db],refiners:[new Pb,new Ib,new _b]},r);return e.refiners=e.refiners.filter(t=>!(t instanceof kc)),e}var PF,lne,i3=b(()=>{VW();qW();WW();zW();jW();JW();e3();si();Le();pt();t3();r3();xi();K_();PF=new Se(n3()),lne=new Se(FF(!0))});function s3(r){if(r.match(/^[0-9]{1,4}$/)){let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}return r.match(/a\.?\s*c\.?/i)?(r=r.replace(/a\.?\s*c\.?/i,""),-parseInt(r)):parseInt(r)}var RF,$F,o3,iA=b(()=>{RF={domingo:0,dom:0,segunda:1,"segunda-feira":1,seg:1,ter\u00E7a:2,"ter\xE7a-feira":2,ter:2,quarta:3,"quarta-feira":3,qua:3,quinta:4,"quinta-feira":4,qui:4,sexta:5,"sexta-feira":5,sex:5,s\u00E1bado:6,sabado:6,sab:6},$F={janeiro:1,jan:1,"jan.":1,fevereiro:2,fev:2,"fev.":2,mar\u00E7o:3,mar:3,"mar.":3,abril:4,abr:4,"abr.":4,maio:5,mai:5,"mai.":5,junho:6,jun:6,"jun.":6,julho:7,jul:7,"jul.":7,agosto:8,ago:8,"ago.":8,setembro:9,set:9,"set.":9,outubro:10,out:10,"out.":10,novembro:11,nov:11,"nov.":11,dezembro:12,dez:12,"dez.":12},o3="[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?"});var dne,pne,fne,mne,Mb,a3=b(()=>{iA();ze();fe();Ki();dne=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(este|esta|passado|pr[o\xF3]ximo)\\s*)?(${ee(RF)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(este|esta|passado|pr[\xF3o]ximo)\\s*semana)?(?=\\W|\\d|$)`,"i"),pne=1,fne=2,mne=3,Mb=class extends L{innerPattern(){return dne}innerExtract(e,t){let n=t[fne].toLowerCase(),i=RF[n];if(i===void 0)return null;let o=t[pne],s=t[mne],a=o||s||"";a=a.toLowerCase();let l=null;return a=="passado"?l="this":a=="pr\xF3ximo"||a=="proximo"?l="next":a=="este"&&(l="this"),cr(e.reference,i,l)}}});var Rb,l3=b(()=>{Ra();Rb=class extends Gr{primaryPrefix(){return"(?:(?:ao?|\xE0s?|das|da|de|do)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a(?:o)?|\\?)\\s*"}}});var $b,c3=b(()=>{vo();$b=class extends Kt{patternBetween(){return new RegExp("^\\s*(?:,|\xE0)?\\s*$")}}});var Ob,u3=b(()=>{go();Ob=class extends Yt{patternBetween(){return/^\s*(?:-)\s*$/i}}});var hne,d3,p3,gne,f3,Nb,m3=b(()=>{zt();iA();iA();ze();fe();hne=new RegExp(`([0-9]{1,2})(?:\xBA|\xAA|\xB0)?(?:\\s*(?:desde|de|\\-|\\\u2013|ao?|\\s)\\s*([0-9]{1,2})(?:\xBA|\xAA|\xB0)?)?\\s*(?:de)?\\s*(?:-|/|\\s*(?:de|,)?\\s*)(${ee($F)})(?:\\s*(?:de|,)?\\s*(${o3}))?(?=\\W|$)`,"i"),d3=1,p3=2,gne=3,f3=4,Nb=class extends L{innerPattern(){return hne}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=$F[t[gne].toLowerCase()],o=parseInt(t[d3]);if(o>31)return t.index=t.index+t[d3].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[f3]){let s=s3(t[f3]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[p3]){let s=parseInt(t[p3]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Lb,h3=b(()=>{fe();oi();Lb=class extends L{innerPattern(e){return/(agora|hoje|amanha|amanhã|ontem)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"agora":return $r(e.reference);case"hoje":return Tr(e.reference);case"amanha":case"amanh\xE3":return vn(e.reference);case"ontem":return gn(e.reference)}return i}}});var Bb,g3=b(()=>{pt();fe();nn();Bb=class extends L{innerPattern(){return/(?:esta\s*)?(manha|manhã|tarde|meia-noite|meio-dia|noite)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[1].toLowerCase()){case"tarde":i.imply("meridiem",G.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"noite":i.imply("meridiem",G.PM),i.imply("hour",22),i.addTag("casualReference/evening");break;case"manha":case"manh\xE3":i.imply("meridiem",G.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"meia-noite":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"meio-dia":i.imply("meridiem",G.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});var LF={};Zr(LF,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>OF,createCasualConfiguration:()=>v3,createConfiguration:()=>NF,parse:()=>yne,parseDate:()=>bne,strict:()=>vne});function yne(r,e,t){return OF.parse(r,e,t)}function bne(r,e,t){return OF.parseDate(r,e,t)}function v3(r=!0){let e=NF(!1,r);return e.parsers.push(new Lb),e.parsers.push(new Bb),e}function NF(r=!0,e=!0){return Ht({parsers:[new vr(e),new Mb,new Rb,new Nb],refiners:[new $b,new Ob]},r)}var OF,vne,y3=b(()=>{xi();si();Le();pt();cs();a3();l3();c3();u3();m3();h3();g3();OF=new Se(v3()),vne=new Se(NF(!0))});var Ub,b3=b(()=>{go();Ub=class extends Yt{patternBetween(){return/^\s*(tot|-)\s*$/i}}});var Vb,w3=b(()=>{vo();Vb=class extends Kt{patternBetween(){return new RegExp("^\\s*(om|na|voor|in de|,|-)?\\s*$")}}});var qb,C3=b(()=>{fe();oi();qb=class extends L{innerPattern(e){return/(nu|vandaag|morgen|morgend|gisteren)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"nu":return $r(e.reference);case"vandaag":return Tr(e.reference);case"morgen":case"morgend":return vn(e.reference);case"gisteren":return gn(e.reference)}return i}}});var wne,Cne,Wb,x3=b(()=>{pt();fe();nn();wne=1,Cne=2,Wb=class extends L{innerPattern(){return/(deze)?\s*(namiddag|avond|middernacht|ochtend|middag|'s middags|'s avonds|'s ochtends)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[wne]==="deze"&&(i.assign("day",e.refDate.getDate()),i.assign("month",e.refDate.getMonth()+1),i.assign("year",e.refDate.getFullYear())),t[Cne].toLowerCase()){case"namiddag":case"'s namiddags":i.imply("meridiem",G.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"avond":case"'s avonds'":i.imply("meridiem",G.PM),i.imply("hour",20),i.addTag("casualReference/evening");break;case"middernacht":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"ochtend":case"'s ochtends":i.imply("meridiem",G.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"middag":case"'s middags":i.imply("meridiem",G.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});function Ene(r){let e=r.toLowerCase();return BF[e]!==void 0?BF[e]:e==="paar"?2:e==="half"||e.match(/halve?/)?.5:parseFloat(e.replace(",","."))}function WF(r){let e=r.toLowerCase();return UF[e]!==void 0?UF[e]:(e=e.replace(/(?:ste|de)$/i,""),parseInt(e))}function sA(r){if(/voor Christus/i.test(r))return r=r.replace(/voor Christus/i,""),-parseInt(r);if(/na Christus/i.test(r))return r=r.replace(/na Christus/i,""),parseInt(r);let e=parseInt(r);return jr(e)}function zu(r){let e={},t=r,n=E3.exec(t);for(;n;)Tne(e,n),t=t.substring(n[0].length),n=E3.exec(t);return e}function Tne(r,e){let t=Ene(e[1]),n=zb[e[2].toLowerCase()];r[n]=t}var VF,Fc,BF,UF,zb,xne,qF,oA,T3,E3,xl,us=b(()=>{ze();zt();VF={zondag:0,zon:0,"zon.":0,zo:0,"zo.":0,maandag:1,ma:1,"ma.":1,dinsdag:2,din:2,"din.":2,di:2,"di.":2,woensdag:3,woe:3,"woe.":3,wo:3,"wo.":3,donderdag:4,dond:4,"dond.":4,do:4,"do.":4,vrijdag:5,vrij:5,"vrij.":5,vr:5,"vr.":5,zaterdag:6,zat:6,"zat.":6,za:6,"za.":6},Fc={januari:1,jan:1,"jan.":1,februari:2,feb:2,"feb.":2,maart:3,mar:3,"mar.":3,mrt:3,"mrt.":3,april:4,apr:4,"apr.":4,mei:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,augustus:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,"sept.":9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,december:12,dec:12,"dec.":12},BF={een:1,twee:2,drie:3,vier:4,vijf:5,zes:6,zeven:7,acht:8,negen:9,tien:10,elf:11,twaalf:12},UF={eerste:1,tweede:2,derde:3,vierde:4,vijfde:5,zesde:6,zevende:7,achtste:8,negende:9,tiende:10,elfde:11,twaalfde:12,dertiende:13,veertiende:14,vijftiende:15,zestiende:16,zeventiende:17,achttiende:18,negentiende:19,twintigste:20,eenentwintigste:21,twee\u00EBntwintigste:22,drieentwintigste:23,vierentwintigste:24,vijfentwintigste:25,zesentwintigste:26,zevenentwintigste:27,achtentwintig:28,negenentwintig:29,dertigste:30,eenendertigste:31},zb={sec:"second",second:"second",seconden:"second",min:"minute",mins:"minute",minute:"minute",minuut:"minute",minuten:"minute",minuutje:"minute",h:"hour",hr:"hour",hrs:"hour",uur:"hour",u:"hour",uren:"hour",dag:"day",dagen:"day",week:"week",weken:"week",maand:"month",maanden:"month",jaar:"year",jr:"year",jaren:"year"},xne=`(?:${ee(BF)}|[0-9]+|[0-9]+[\\.,][0-9]+|halve?|half|paar)`;qF=`(?:${ee(UF)}|[0-9]{1,2}(?:ste|de)?)`;oA="(?:[1-9][0-9]{0,3}\\s*(?:voor Christus|na Christus)|[1-2][0-9]{3}|[5-9][0-9])";T3=`(${xne})\\s{0,5}(${ee(zb)})\\s{0,5}`,E3=new RegExp(T3,"i"),xl=Er("(?:(?:binnen|in)\\s*)?",T3)});var Hb,_3=b(()=>{us();Le();fe();Hb=class extends L{innerPattern(){return new RegExp("(?:binnen|in|binnen de|voor)\\s*("+xl+")(?=\\W|$)","i")}innerExtract(e,t){let n=zu(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var _ne,Ane,kne,Sne,jb,A3=b(()=>{us();ze();fe();Ki();_ne=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:op\\s*?)?(?:(deze|vorige|volgende)\\s*(?:week\\s*)?)?(${ee(VF)})(?=\\W|$)`,"i"),Ane=1,kne=2,Sne=3,jb=class extends L{innerPattern(){return _ne}innerExtract(e,t){let n=t[kne].toLowerCase(),i=VF[n],o=t[Ane],s=t[Sne],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a=="vorige"?l="last":a=="volgende"?l="next":a=="deze"&&(l="this"),cr(e.reference,i,l)}}});var Dne,Ine,k3,S3,D3,Gb,I3=b(()=>{zt();us();us();us();ze();fe();Dne=new RegExp(`(?:on\\s*?)?(${qF})(?:\\s*(?:tot|\\-|\\\u2013|until|through|till|\\s)\\s*(${qF}))?(?:-|/|\\s*(?:of)?\\s*)(`+ee(Fc)+`)(?:(?:-|/|,?\\s*)(${oA}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),Ine=3,k3=1,S3=2,D3=4,Gb=class extends L{innerPattern(){return Dne}innerExtract(e,t){let n=Fc[t[Ine].toLowerCase()],i=WF(t[k3]);if(i>31)return t.index=t.index+t[k3].length,null;let o=e.createParsingComponents({day:i,month:n});if(t[D3]){let l=sA(t[D3]);o.assign("year",l)}else{let l=ft(e.refDate,i,n);o.imply("year",l)}if(!t[S3])return o;let s=WF(t[S3]),a=e.createParsingResult(t.index,t[0]);return a.start=o,a.end=o.clone(),a.end.assign("day",s),a}}});var Pne,Fne,P3,zm,F3=b(()=>{us();zt();ze();us();fe();Pne=new RegExp(`(${ee(Fc)})\\s*(?:[,-]?\\s*(${oA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),Fne=1,P3=2,zm=class extends L{innerPattern(){return Pne}innerExtract(e,t){let n=e.createParsingComponents();n.imply("day",1);let i=t[Fne],o=Fc[i.toLowerCase()];if(n.assign("month",o),t[P3]){let s=sA(t[P3]);n.assign("year",s)}else{let s=ft(e.refDate,1,o);n.imply("year",s)}return n}}});var Mne,Rne,$ne,Yb,M3=b(()=>{fe();Mne=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),Rne=1,$ne=2,Yb=class extends L{innerPattern(){return Mne}innerExtract(e,t){let n=parseInt(t[$ne]),i=parseInt(t[Rne]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});var Kb,R3=b(()=>{Ra();Kb=class extends Gr{primaryPrefix(){return"(?:(?:om)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|om|\\?)\\s*"}primarySuffix(){return"(?:\\s*(?:uur))?(?!/)(?=\\W|$)"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});var One,Nne,Lne,$3,Bne,Xb,O3=b(()=>{us();ze();fe();One=new RegExp(`([0-9]{4})[\\.\\/\\s](?:(${ee(Fc)})|([0-9]{1,2}))[\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),Nne=1,Lne=2,$3=3,Bne=4,Xb=class extends L{innerPattern(){return One}innerExtract(e,t){let n=t[$3]?parseInt(t[$3]):Fc[t[Lne].toLowerCase()];if(n<1||n>12)return null;let i=parseInt(t[Nne]);return{day:parseInt(t[Bne]),month:n,year:i}}}});var Une,Vne,Qb,N3=b(()=>{fe();pt();nn();Une=1,Vne=2,Qb=class extends L{innerPattern(e){return/(gisteren|morgen|van)(ochtend|middag|namiddag|avond|nacht)(?=\W|$)/i}innerExtract(e,t){let n=t[Une].toLowerCase(),i=t[Vne].toLowerCase(),o=e.createParsingComponents(),s=e.refDate;switch(n){case"gisteren":let a=new Date(s.getTime());a.setDate(a.getDate()-1),nt(o,a);break;case"van":nt(o,s);break;case"morgen":let l=new Date(s.getTime());l.setDate(l.getDate()+1),nt(o,l),Lt(o,l);break}switch(i){case"ochtend":o.imply("meridiem",G.AM),o.imply("hour",6);break;case"middag":o.imply("meridiem",G.AM),o.imply("hour",12);break;case"namiddag":o.imply("meridiem",G.PM),o.imply("hour",15);break;case"avond":o.imply("meridiem",G.PM),o.imply("hour",20);break}return o}}});var qne,Wne,zne,Zb,L3=b(()=>{us();Le();fe();Bt();qne=new RegExp(`(dit|deze|vorig|afgelopen|(?:aan)?komend|over|\\+|-)e?\\s*(${xl})(?=\\W|$)`,"i"),Wne=1,zne=2,Zb=class extends L{innerPattern(){return qne}innerExtract(e,t){let n=t[Wne].toLowerCase(),i=zu(t[zne]);switch(n){case"vorig":case"afgelopen":case"-":i=tt(i);break}return Q.createRelativeFromReference(e.reference,i)}}});var Hne,jne,Gne,Jb,B3=b(()=>{us();Le();fe();ze();Hne=new RegExp(`(dit|deze|(?:aan)?komend|volgend|afgelopen|vorig)e?\\s*(${ee(zb)})(?=\\s*)(?=\\W|$)`,"i"),jne=1,Gne=2,Jb=class extends L{innerPattern(){return Hne}innerExtract(e,t){let n=t[jne].toLowerCase(),i=t[Gne].toLowerCase(),o=zb[i];if(n=="volgend"||n=="komend"||n=="aankomend"){let l={};return l[o]=1,Q.createRelativeFromReference(e.reference,l)}if(n=="afgelopen"||n=="vorig"){let l={};return l[o]=-1,Q.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return i.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):i.match(/maand/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):i.match(/jaar/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var Yne,Kne,ew,U3=b(()=>{us();Le();fe();Bt();Yne=new RegExp("("+xl+")(?:geleden|voor|eerder)(?=(?:\\W|$))","i"),Kne=new RegExp("("+xl+")geleden(?=(?:\\W|$))","i"),ew=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Kne:Yne}innerExtract(t,n){let i=zu(n[1]),o=tt(i);return Q.createRelativeFromReference(t.reference,o)}}});var Xne,Qne,Zne,tw,V3=b(()=>{us();Le();fe();Xne=new RegExp("("+xl+")(later|na|vanaf nu|voortaan|vooruit|uit)(?=(?:\\W|$))","i"),Qne=new RegExp("("+xl+")(later|vanaf nu)(?=(?:\\W|$))","i"),Zne=1,tw=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Qne:Xne}innerExtract(t,n){let i=zu(n[Zne]);return Q.createRelativeFromReference(t.reference,i)}}});var jF={};Zr(jF,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>zF,createCasualConfiguration:()=>q3,createConfiguration:()=>HF,parse:()=>eie,parseDate:()=>tie,strict:()=>Jne});function eie(r,e,t){return zF.parse(r,e,t)}function tie(r,e,t){return zF.parseDate(r,e,t)}function q3(r=!0){let e=HF(!1,r);return e.parsers.unshift(new qb),e.parsers.unshift(new Wb),e.parsers.unshift(new Qb),e.parsers.unshift(new zm),e.parsers.unshift(new Jb),e.parsers.unshift(new Zb),e}function HF(r=!0,e=!0){return Ht({parsers:[new vr(e),new Hb,new Gb,new zm,new jb,new Xb,new Yb,new Kb(r),new ew(r),new tw(r)],refiners:[new Vb,new Ub]},r)}var zF,Jne,W3=b(()=>{xi();si();Le();pt();b3();w3();C3();x3();cs();_3();A3();I3();F3();M3();R3();O3();N3();L3();B3();U3();V3();zF=new Se(q3()),Jne=new Se(HF(!0))});function Ro(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?yn[n]:e*yn[n]:e+=yn[n]}return e}function z3(r){let e="";for(let t=0;t<r.length;t++){let n=r[t];e=e+yn[n]}return parseInt(e)}var yn,Hm,xp=b(()=>{yn={\u96F6:0,"\u3007":0,\u4E00:1,\u4E8C:2,\u4E24:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10},Hm={\u5929:0,\u65E5:0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6}});var GF,H3,YF,Ep,KF=b(()=>{fe();xp();GF=1,H3=2,YF=3,Ep=class extends L{innerPattern(){return new RegExp("(\\d{2,4}|["+Object.keys(yn).join("")+"]{4}|["+Object.keys(yn).join("")+"]{2})?(?:\\s*)(?:\u5E74)?(?:[\\s|,|\uFF0C]*)(\\d{1,2}|["+Object.keys(yn).join("")+"]{1,3})(?:\\s*)(?:\u6708)(?:\\s*)(\\d{1,2}|["+Object.keys(yn).join("")+"]{1,3})?(?:\\s*)(?:\u65E5|\u53F7)?")}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[H3]);if(isNaN(i)&&(i=Ro(t[H3])),n.start.assign("month",i),t[YF]){let o=parseInt(t[YF]);isNaN(o)&&(o=Ro(t[YF])),n.start.assign("day",o)}else n.start.imply("day",e.refDate.getDate());if(t[GF]){let o=parseInt(t[GF]);isNaN(o)&&(o=z3(t[GF])),n.start.assign("year",o)}else n.start.imply("year",e.refDate.getFullYear());return n}}});var rie,XF,nie,Tp,QF=b(()=>{fe();Bt();xp();rie=new RegExp("(\\d+|["+Object.keys(yn).join("")+"]+|\u534A|\u51E0)(?:\\s*)(?:\u4E2A)?(\u79D2(?:\u949F)?|\u5206\u949F|\u5C0F\u65F6|\u949F|\u65E5|\u5929|\u661F\u671F|\u793C\u62DC|\u6708|\u5E74)(?:(?:\u4E4B|\u8FC7)?\u540E|(?:\u4E4B)?\u5185)","i"),XF=1,nie=2,Tp=class extends L{innerPattern(){return rie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[XF]);if(isNaN(i)&&(i=Ro(t[XF])),isNaN(i)){let c=t[XF];if(c==="\u51E0")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[nie][0];if(a.match(/[日天星礼月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u793C"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i);let c=gt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u949F")&&(o.hour=i);let l=gt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var iie,_p,ZF=b(()=>{fe();xp();iie=new RegExp("(?<prefix>\u4E0A|\u4E0B|\u8FD9)(?:\u4E2A)?(?:\u661F\u671F|\u793C\u62DC|\u5468)(?<weekday>"+Object.keys(Hm).join("|")+")"),_p=class extends L{innerPattern(){return iie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Hm[i];if(o===void 0)return null;let s=null,a=t.groups.prefix;a=="\u4E0A"?s="last":a=="\u4E0B"?s="next":a=="\u8FD9"&&(s="this");let l=new Date(e.refDate.getTime()),c=!1,u=l.getDay();if(s=="last"||s=="past")l.setDate(l.getDate()+(o-7-u)),c=!0;else if(s=="next")l.setDate(l.getDate()+(o+7-u)),c=!0;else if(s=="this")l.setDate(l.getDate()+(o-u));else{let d=o-u;Math.abs(d-7)<Math.abs(d)&&(d-=7),Math.abs(d+7)<Math.abs(d)&&(d+=7),l.setDate(l.getDate()+d)}return n.start.assign("weekday",o),c?(n.start.assign("day",l.getDate()),n.start.assign("month",l.getMonth()+1),n.start.assign("year",l.getFullYear())):(n.start.imply("day",l.getDate()),n.start.imply("month",l.getMonth()+1),n.start.imply("year",l.getFullYear())),n}}});var oie,sie,rw,aA,lA,nw,cA,uA,Ks,jm,dA,Ap,JF=b(()=>{fe();xp();oie=new RegExp("(?:\u4ECE|\u81EA)?(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(yn).join("")+"]+)(?:\\s*)(?:\u70B9|\u65F6|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(yn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(yn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),sie=new RegExp("(?:^\\s*(?:\u5230|\u81F3|\\-|\\\u2013|\\~|\\\u301C)\\s*)(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(yn).join("")+"]+)(?:\\s*)(?:\u70B9|\u65F6|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(yn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(yn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),rw=1,aA=2,lA=3,nw=4,cA=5,uA=6,Ks=7,jm=8,dA=9,Ap=class extends L{patternLeftBoundary(){return"()"}innerPattern(){return oie}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]),i=new Date(e.reference.instant.getTime());if(t[rw]){let u=t[rw];u=="\u660E"?e.reference.instant.getHours()>1&&i.setDate(i.getDate()+1):u=="\u6628"?i.setDate(i.getDate()-1):u=="\u524D"?i.setDate(i.getDate()-2):u=="\u5927\u524D"?i.setDate(i.getDate()-3):u=="\u540E"?i.setDate(i.getDate()+2):u=="\u5927\u540E"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else if(t[nw]){let u=t[nw];u=="\u660E"?i.setDate(i.getDate()+1):u=="\u6628"?i.setDate(i.getDate()-1):u=="\u524D"?i.setDate(i.getDate()-2):u=="\u5927\u524D"?i.setDate(i.getDate()-3):u=="\u540E"?i.setDate(i.getDate()+2):u=="\u5927\u540E"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else n.start.imply("day",i.getDate()),n.start.imply("month",i.getMonth()+1),n.start.imply("year",i.getFullYear());let o=0,s=0,a=-1;if(t[jm]){let u=parseInt(t[jm]);if(isNaN(u)&&(u=Ro(t[jm])),u>=60)return null;n.start.assign("second",u)}if(o=parseInt(t[uA]),isNaN(o)&&(o=Ro(t[uA])),t[Ks]?t[Ks]=="\u534A"?s=30:t[Ks]=="\u6B63"||t[Ks]=="\u6574"?s=0:(s=parseInt(t[Ks]),isNaN(s)&&(s=Ro(t[Ks]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),t[dA]){if(o>12)return null;let u=t[dA][0].toLowerCase();u=="a"&&(a=0,o==12&&(o=0)),u=="p"&&(a=1,o!=12&&(o+=12))}else if(t[aA]){let d=t[aA][0];d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(t[lA]){let d=t[lA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(t[cA]){let d=t[cA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}n.start.assign("hour",o),n.start.assign("minute",s),a>=0?n.start.assign("meridiem",a):o<12?n.start.imply("meridiem",0):n.start.imply("meridiem",1);let l=sie.exec(e.text.substring(n.index+n.text.length));if(!l)return n.text.match(/^\d+$/)?null:n;let c=new Date(i.getTime());if((l[rw]||l[nw])&&(c=new Date(e.reference.instant.getTime())),n.end=e.createParsingComponents(),l[rw]){let u=l[rw];u=="\u660E"?e.reference.instant.getHours()>1&&c.setDate(c.getDate()+1):u=="\u6628"?c.setDate(c.getDate()-1):u=="\u524D"?c.setDate(c.getDate()-2):u=="\u5927\u524D"?c.setDate(c.getDate()-3):u=="\u540E"?c.setDate(c.getDate()+2):u=="\u5927\u540E"&&c.setDate(c.getDate()+3),n.end.assign("day",c.getDate()),n.end.assign("month",c.getMonth()+1),n.end.assign("year",c.getFullYear())}else if(l[nw]){let u=l[nw];u=="\u660E"?c.setDate(c.getDate()+1):u=="\u6628"?c.setDate(c.getDate()-1):u=="\u524D"?c.setDate(c.getDate()-2):u=="\u5927\u524D"?c.setDate(c.getDate()-3):u=="\u540E"?c.setDate(c.getDate()+2):u=="\u5927\u540E"&&c.setDate(c.getDate()+3),n.end.assign("day",c.getDate()),n.end.assign("month",c.getMonth()+1),n.end.assign("year",c.getFullYear())}else n.end.imply("day",c.getDate()),n.end.imply("month",c.getMonth()+1),n.end.imply("year",c.getFullYear());if(o=0,s=0,a=-1,l[jm]){let u=parseInt(l[jm]);if(isNaN(u)&&(u=Ro(l[jm])),u>=60)return null;n.end.assign("second",u)}if(o=parseInt(l[uA]),isNaN(o)&&(o=Ro(l[uA])),l[Ks]?l[Ks]=="\u534A"?s=30:l[Ks]=="\u6B63"||l[Ks]=="\u6574"?s=0:(s=parseInt(l[Ks]),isNaN(s)&&(s=Ro(l[Ks]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),l[dA]){if(o>12)return null;let u=l[dA][0].toLowerCase();u=="a"&&(a=0,o==12&&(o=0)),u=="p"&&(a=1,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==0?(n.start.imply("meridiem",0),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",1),n.start.get("hour")!=12&&n.start.assign("hour",n.start.get("hour")+12)))}else if(l[aA]){let d=l[aA][0];d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(l[lA]){let d=l[lA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(l[cA]){let d=l[cA][0];d=="\u4E0A"||d=="\u65E9"||d=="\u51CC"?(a=0,o==12&&(o=0)):(d=="\u4E0B"||d=="\u665A")&&(a=1,o!=12&&(o+=12))}return n.text=n.text+l[0],n.end.assign("hour",o),n.end.assign("minute",s),a>=0?n.end.assign("meridiem",a):n.start.isCertain("meridiem")&&n.start.get("meridiem")==1&&n.start.get("hour")>o?n.end.imply("meridiem",0):o>12&&n.end.imply("meridiem",1),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n}}});var aie,kp,eM=b(()=>{fe();xp();aie=new RegExp("(?:\u661F\u671F|\u793C\u62DC|\u5468)(?<weekday>"+Object.keys(Hm).join("|")+")"),kp=class extends L{innerPattern(){return aie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Hm[i];if(o===void 0)return null;let s=new Date(e.refDate.getTime()),a=!1,l=s.getDay(),c=o-l;return Math.abs(c-7)<Math.abs(c)&&(c-=7),Math.abs(c+7)<Math.abs(c)&&(c+=7),s.setDate(s.getDate()+c),n.start.assign("weekday",o),a?(n.start.assign("day",s.getDate()),n.start.assign("month",s.getMonth()+1),n.start.assign("year",s.getFullYear())):(n.start.imply("day",s.getDate()),n.start.imply("month",s.getMonth()+1),n.start.imply("year",s.getFullYear())),n}}});var lie,j3,cie,G3,Y3,uie,Sp,tM=b(()=>{fe();lie=1,j3=2,cie=3,G3=4,Y3=5,uie=6,Sp=class extends L{innerPattern(e){return new RegExp("(\u800C\u5BB6|\u7ACB(?:\u523B|\u5373)|\u5373\u523B)|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s|,|\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?","i")}innerExtract(e,t){let n=t.index,i=e.createParsingResult(n,t[0]),o=e.refDate,s=new Date(o.getTime());if(t[lie])i.start.imply("hour",o.getHours()),i.start.imply("minute",o.getMinutes()),i.start.imply("second",o.getSeconds()),i.start.imply("millisecond",o.getMilliseconds());else if(t[j3]){let a=t[j3],l=t[cie];a=="\u660E"||a=="\u807D"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"||a=="\u5C0B"||a=="\u7434"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u5F8C"?s.setDate(s.getDate()+2):a=="\u5927\u5F8C"&&s.setDate(s.getDate()+3),l=="\u65E9"||l=="\u671D"?i.start.imply("hour",6):l=="\u665A"&&(i.start.imply("hour",22),i.start.imply("meridiem",1))}else if(t[G3]){let l=t[G3][0];l=="\u65E9"||l=="\u671D"||l=="\u4E0A"?i.start.imply("hour",6):l=="\u4E0B"||l=="\u664F"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):l=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):l=="\u591C"||l=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):l=="\u51CC"&&i.start.imply("hour",0)}else if(t[Y3]){let a=t[Y3];a=="\u660E"||a=="\u807D"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"||a=="\u5C0B"||a=="\u7434"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u5F8C"?s.setDate(s.getDate()+2):a=="\u5927\u5F8C"&&s.setDate(s.getDate()+3);let l=t[uie];if(l){let c=l[0];c=="\u65E9"||c=="\u671D"||c=="\u4E0A"?i.start.imply("hour",6):c=="\u4E0B"||c=="\u664F"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):c=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):c=="\u591C"||c=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):c=="\u51CC"&&i.start.imply("hour",0)}}return i.start.assign("day",s.getDate()),i.start.assign("month",s.getMonth()+1),i.start.assign("year",s.getFullYear()),i}}});function $o(r){let e=0;for(let t=0;t<r.length;t++){let n=r[t];n==="\u5341"?e=e===0?bn[n]:e*bn[n]:e+=bn[n]}return e}function K3(r){let e="";for(let t=0;t<r.length;t++){let n=r[t];e=e+bn[n]}return parseInt(e)}var bn,Gm,Dp=b(()=>{bn={\u96F6:0,\u4E00:1,\u4E8C:2,\u5169:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6,\u4E03:7,\u516B:8,\u4E5D:9,\u5341:10,\u5EFF:20,\u5345:30},Gm={\u5929:0,\u65E5:0,\u4E00:1,\u4E8C:2,\u4E09:3,\u56DB:4,\u4E94:5,\u516D:6}});var rM,X3,nM,Ip,iM=b(()=>{fe();Dp();rM=1,X3=2,nM=3,Ip=class extends L{innerPattern(){return new RegExp("(\\d{2,4}|["+Object.keys(bn).join("")+"]{4}|["+Object.keys(bn).join("")+"]{2})?(?:\\s*)(?:\u5E74)?(?:[\\s|,|\uFF0C]*)(\\d{1,2}|["+Object.keys(bn).join("")+"]{1,2})(?:\\s*)(?:\u6708)(?:\\s*)(\\d{1,2}|["+Object.keys(bn).join("")+"]{1,2})?(?:\\s*)(?:\u65E5|\u865F)?")}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[X3]);if(isNaN(i)&&(i=$o(t[X3])),n.start.assign("month",i),t[nM]){let o=parseInt(t[nM]);isNaN(o)&&(o=$o(t[nM])),n.start.assign("day",o)}else n.start.imply("day",e.refDate.getDate());if(t[rM]){let o=parseInt(t[rM]);isNaN(o)&&(o=K3(t[rM])),n.start.assign("year",o)}else n.start.imply("year",e.refDate.getFullYear());return n}}});var die,oM,pie,Pp,sM=b(()=>{fe();Bt();Dp();die=new RegExp("(\\d+|["+Object.keys(bn).join("")+"]+|\u534A|\u5E7E)(?:\\s*)(?:\u500B)?(\u79D2(?:\u9418)?|\u5206\u9418|\u5C0F\u6642|\u9418|\u65E5|\u5929|\u661F\u671F|\u79AE\u62DC|\u6708|\u5E74)(?:(?:\u4E4B|\u904E)?\u5F8C|(?:\u4E4B)?\u5167)","i"),oM=1,pie=2,Pp=class extends L{innerPattern(){return die}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[oM]);if(isNaN(i)&&(i=$o(t[oM])),isNaN(i)){let c=t[oM];if(c==="\u5E7E")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[pie][0];if(a.match(/[日天星禮月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u79AE"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i);let c=gt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u9418")&&(o.hour=i);let l=gt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var fie,Fp,aM=b(()=>{fe();Dp();fie=new RegExp("(?<prefix>\u4E0A|\u4ECA|\u4E0B|\u9019|\u5462)(?:\u500B)?(?:\u661F\u671F|\u79AE\u62DC|\u9031)(?<weekday>"+Object.keys(Gm).join("|")+")"),Fp=class extends L{innerPattern(){return fie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Gm[i];if(o===void 0)return null;let s=null,a=t.groups.prefix;a=="\u4E0A"?s="last":a=="\u4E0B"?s="next":(a=="\u4ECA"||a=="\u9019"||a=="\u5462")&&(s="this");let l=new Date(e.refDate.getTime()),c=!1,u=l.getDay();if(s=="last"||s=="past")l.setDate(l.getDate()+(o-7-u)),c=!0;else if(s=="next")l.setDate(l.getDate()+(o+7-u)),c=!0;else if(s=="this")l.setDate(l.getDate()+(o-u));else{let d=o-u;Math.abs(d-7)<Math.abs(d)&&(d-=7),Math.abs(d+7)<Math.abs(d)&&(d+=7),l.setDate(l.getDate()+d)}return n.start.assign("weekday",o),c?(n.start.assign("day",l.getDate()),n.start.assign("month",l.getMonth()+1),n.start.assign("year",l.getFullYear())):(n.start.imply("day",l.getDate()),n.start.imply("month",l.getMonth()+1),n.start.imply("year",l.getFullYear())),n}}});var mie,hie,iw,pA,fA,ow,mA,hA,Xs,Ym,gA,Mp,lM=b(()=>{fe();Dp();mie=new RegExp("(?:\u7531|\u5F9E|\u81EA)?(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(bn).join("")+"]+)(?:\\s*)(?:\u9EDE|\u6642|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),hie=new RegExp("(?:^\\s*(?:\u5230|\u81F3|\\-|\\\u2013|\\~|\\\u301C)\\s*)(?:(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(\u65E9|\u671D|\u665A)|(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u5F8C|\u5927\u5F8C|\u807D|\u6628|\u5C0B|\u7434)(?:\u65E5|\u5929)(?:[\\s,\uFF0C]*)(?:(\u4E0A(?:\u5348|\u665D)|\u671D(?:\u65E9)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348|\u665D)|\u664F(?:\u665D)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?)?(?:[\\s,\uFF0C]*)(?:(\\d+|["+Object.keys(bn).join("")+"]+)(?:\\s*)(?:\u9EDE|\u6642|:|\uFF1A)(?:\\s*)(\\d+|\u534A|\u6B63|\u6574|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u5206|:|\uFF1A)?(?:\\s*)(\\d+|["+Object.keys(bn).join("")+"]+)?(?:\\s*)(?:\u79D2)?)(?:\\s*(A.M.|P.M.|AM?|PM?))?","i"),iw=1,pA=2,fA=3,ow=4,mA=5,hA=6,Xs=7,Ym=8,gA=9,Mp=class extends L{patternLeftBoundary(){return"()"}innerPattern(){return mie}innerExtract(e,t){if(t.index>0&&e.text[t.index-1].match(/\w/))return null;let n=e.createParsingResult(t.index,t[0]),i=new Date(e.reference.instant.getTime());if(t[iw]){let w=t[iw];w=="\u660E"||w=="\u807D"?e.refDate.getHours()>1&&i.setDate(i.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?i.setDate(i.getDate()-1):w=="\u524D"?i.setDate(i.getDate()-2):w=="\u5927\u524D"?i.setDate(i.getDate()-3):w=="\u5F8C"?i.setDate(i.getDate()+2):w=="\u5927\u5F8C"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else if(t[ow]){let w=t[ow];w=="\u660E"||w=="\u807D"?i.setDate(i.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?i.setDate(i.getDate()-1):w=="\u524D"?i.setDate(i.getDate()-2):w=="\u5927\u524D"?i.setDate(i.getDate()-3):w=="\u5F8C"?i.setDate(i.getDate()+2):w=="\u5927\u5F8C"&&i.setDate(i.getDate()+3),n.start.assign("day",i.getDate()),n.start.assign("month",i.getMonth()+1),n.start.assign("year",i.getFullYear())}else n.start.imply("day",i.getDate()),n.start.imply("month",i.getMonth()+1),n.start.imply("year",i.getFullYear());let o=0,s=0,a=-1;if(t[Ym]){var l=parseInt(t[Ym]);if(isNaN(l)&&(l=$o(t[Ym])),l>=60)return null;n.start.assign("second",l)}if(o=parseInt(t[hA]),isNaN(o)&&(o=$o(t[hA])),t[Xs]?t[Xs]=="\u534A"?s=30:t[Xs]=="\u6B63"||t[Xs]=="\u6574"?s=0:(s=parseInt(t[Xs]),isNaN(s)&&(s=$o(t[Xs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),t[gA]){if(o>12)return null;var c=t[gA][0].toLowerCase();c=="a"&&(a=0,o==12&&(o=0)),c=="p"&&(a=1,o!=12&&(o+=12))}else if(t[pA]){var u=t[pA],d=u[0];d=="\u671D"||d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(t[fA]){var f=t[fA],p=f[0];p=="\u4E0A"||p=="\u671D"||p=="\u65E9"||p=="\u51CC"?(a=0,o==12&&(o=0)):(p=="\u4E0B"||p=="\u664F"||p=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(t[mA]){var m=t[mA],v=m[0];v=="\u4E0A"||v=="\u671D"||v=="\u65E9"||v=="\u51CC"?(a=0,o==12&&(o=0)):(v=="\u4E0B"||v=="\u664F"||v=="\u665A")&&(a=1,o!=12&&(o+=12))}n.start.assign("hour",o),n.start.assign("minute",s),a>=0?n.start.assign("meridiem",a):o<12?n.start.imply("meridiem",0):n.start.imply("meridiem",1);let g=hie.exec(e.text.substring(n.index+n.text.length));if(!g)return n.text.match(/^\d+$/)?null:n;let y=new Date(i.getTime());if((g[iw]||g[ow])&&(y=new Date(e.reference.instant.getTime())),n.end=e.createParsingComponents(),g[iw]){let w=g[iw];w=="\u660E"||w=="\u807D"?e.refDate.getHours()>1&&y.setDate(y.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?y.setDate(y.getDate()-1):w=="\u524D"?y.setDate(y.getDate()-2):w=="\u5927\u524D"?y.setDate(y.getDate()-3):w=="\u5F8C"?y.setDate(y.getDate()+2):w=="\u5927\u5F8C"&&y.setDate(y.getDate()+3),n.end.assign("day",y.getDate()),n.end.assign("month",y.getMonth()+1),n.end.assign("year",y.getFullYear())}else if(g[ow]){let w=g[ow];w=="\u660E"||w=="\u807D"?y.setDate(y.getDate()+1):w=="\u6628"||w=="\u5C0B"||w=="\u7434"?y.setDate(y.getDate()-1):w=="\u524D"?y.setDate(y.getDate()-2):w=="\u5927\u524D"?y.setDate(y.getDate()-3):w=="\u5F8C"?y.setDate(y.getDate()+2):w=="\u5927\u5F8C"&&y.setDate(y.getDate()+3),n.end.assign("day",y.getDate()),n.end.assign("month",y.getMonth()+1),n.end.assign("year",y.getFullYear())}else n.end.imply("day",y.getDate()),n.end.imply("month",y.getMonth()+1),n.end.imply("year",y.getFullYear());if(o=0,s=0,a=-1,g[Ym]){let w=parseInt(g[Ym]);if(isNaN(w)&&(w=$o(g[Ym])),w>=60)return null;n.end.assign("second",w)}if(o=parseInt(g[hA]),isNaN(o)&&(o=$o(g[hA])),g[Xs]?g[Xs]=="\u534A"?s=30:g[Xs]=="\u6B63"||g[Xs]=="\u6574"?s=0:(s=parseInt(g[Xs]),isNaN(s)&&(s=$o(g[Xs]))):o>100&&(s=o%100,o=Math.floor(o/100)),s>=60||o>24)return null;if(o>=12&&(a=1),g[gA]){if(o>12)return null;var c=g[gA][0].toLowerCase();c=="a"&&(a=0,o==12&&(o=0)),c=="p"&&(a=1,o!=12&&(o+=12)),n.start.isCertain("meridiem")||(a==0?(n.start.imply("meridiem",0),n.start.get("hour")==12&&n.start.assign("hour",0)):(n.start.imply("meridiem",1),n.start.get("hour")!=12&&n.start.assign("hour",n.start.get("hour")+12)))}else if(g[pA]){var d=g[pA][0];d=="\u671D"||d=="\u65E9"?(a=0,o==12&&(o=0)):d=="\u665A"&&(a=1,o!=12&&(o+=12))}else if(g[fA]){var p=g[fA][0];p=="\u4E0A"||p=="\u671D"||p=="\u65E9"||p=="\u51CC"?(a=0,o==12&&(o=0)):(p=="\u4E0B"||p=="\u664F"||p=="\u665A")&&(a=1,o!=12&&(o+=12))}else if(g[mA]){var v=g[mA][0];v=="\u4E0A"||v=="\u671D"||v=="\u65E9"||v=="\u51CC"?(a=0,o==12&&(o=0)):(v=="\u4E0B"||v=="\u664F"||v=="\u665A")&&(a=1,o!=12&&(o+=12))}return n.text=n.text+g[0],n.end.assign("hour",o),n.end.assign("minute",s),a>=0?n.end.assign("meridiem",a):n.start.isCertain("meridiem")&&n.start.get("meridiem")==1&&n.start.get("hour")>o?n.end.imply("meridiem",0):o>12&&n.end.imply("meridiem",1),n.end.date().getTime()<n.start.date().getTime()&&n.end.imply("day",n.end.get("day")+1),n}}});var gie,Rp,cM=b(()=>{fe();Dp();gie=new RegExp("(?:\u661F\u671F|\u79AE\u62DC|\u9031)(?<weekday>"+Object.keys(Gm).join("|")+")"),Rp=class extends L{innerPattern(){return gie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=t.groups.weekday,o=Gm[i];if(o===void 0)return null;let s=new Date(e.refDate.getTime()),a=!1,l=s.getDay(),c=o-l;return Math.abs(c-7)<Math.abs(c)&&(c-=7),Math.abs(c+7)<Math.abs(c)&&(c+=7),s.setDate(s.getDate()+c),n.start.assign("weekday",o),a?(n.start.assign("day",s.getDate()),n.start.assign("month",s.getMonth()+1),n.start.assign("year",s.getFullYear())):(n.start.imply("day",s.getDate()),n.start.imply("month",s.getMonth()+1),n.start.imply("year",s.getFullYear())),n}}});var $p,uM=b(()=>{go();$p=class extends Yt{patternBetween(){return/^\s*(至|到|\-|\~|~|-|ー)\s*$/i}}});var Op,dM=b(()=>{vo();Op=class extends Kt{patternBetween(){return/^\s*$/i}}});var vie,pM,yie,sw,Q3=b(()=>{fe();Bt();Dp();vie=new RegExp("(\\d+|["+Object.keys(bn).join("")+"]+|\u534A|\u5E7E)(?:\\s*)(?:\u500B)?(\u79D2(?:\u9418)?|\u5206\u9418|\u5C0F\u6642|\u9418|\u65E5|\u5929|\u661F\u671F|\u79AE\u62DC|\u6708|\u5E74)(?:\u4E4B)?\u524D","i"),pM=1,yie=2,sw=class extends L{innerPattern(){return vie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[pM]);if(isNaN(i)&&(i=$o(t[pM])),isNaN(i)){let c=t[pM];if(c==="\u5E7E")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[yie][0];if(a.match(/[日天星禮月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u79AE"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i),o=tt(o);let c=gt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u9418")&&(o.hour=i),o=tt(o);let l=gt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var gM={};Zr(gM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>fM,createCasualConfiguration:()=>mM,createConfiguration:()=>hM,hant:()=>bie,parse:()=>Cie,parseDate:()=>xie,strict:()=>wie});function Cie(r,e,t){return fM.parse(r,e,t)}function xie(r,e,t){return fM.parseDate(r,e,t)}function mM(){let r=hM();return r.parsers.unshift(new Sp),r}function hM(){let r=Ht({parsers:[new Ip,new Fp,new Rp,new Mp,new Pp,new sw],refiners:[new $p,new Op]});return r.refiners=r.refiners.filter(e=>!(e instanceof $a)),r}var bie,fM,wie,Z3=b(()=>{qy();xi();si();Le();pt();tM();iM();sM();Q3();aM();lM();cM();uM();dM();bie=new Se(mM()),fM=new Se(mM()),wie=new Se(hM())});var Eie,J3,Tie,ez,tz,_ie,aw,rz=b(()=>{fe();Eie=1,J3=2,Tie=3,ez=4,tz=5,_ie=6,aw=class extends L{innerPattern(e){return new RegExp("(\u73B0\u5728|\u7ACB(?:\u523B|\u5373)|\u5373\u523B)|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(\u65E9|\u665A)|(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668))|(\u4ECA|\u660E|\u524D|\u5927\u524D|\u540E|\u5927\u540E|\u6628)(?:\u65E5|\u5929)(?:[\\s|,|\uFF0C]*)(?:(\u4E0A(?:\u5348)|\u65E9(?:\u4E0A)|\u4E0B(?:\u5348)|\u665A(?:\u4E0A)|\u591C(?:\u665A)?|\u4E2D(?:\u5348)|\u51CC(?:\u6668)))?","i")}innerExtract(e,t){let n=t.index,i=e.createParsingResult(n,t[0]),o=e.refDate,s=new Date(o.getTime());if(t[Eie])i.start.imply("hour",o.getHours()),i.start.imply("minute",o.getMinutes()),i.start.imply("second",o.getSeconds()),i.start.imply("millisecond",o.getMilliseconds());else if(t[J3]){let a=t[J3],l=t[Tie];a=="\u660E"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u540E"?s.setDate(s.getDate()+2):a=="\u5927\u540E"&&s.setDate(s.getDate()+3),l=="\u65E9"?i.start.imply("hour",6):l=="\u665A"&&(i.start.imply("hour",22),i.start.imply("meridiem",1))}else if(t[ez]){let l=t[ez][0];l=="\u65E9"||l=="\u4E0A"?i.start.imply("hour",6):l=="\u4E0B"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):l=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):l=="\u591C"||l=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):l=="\u51CC"&&i.start.imply("hour",0)}else if(t[tz]){let a=t[tz];a=="\u660E"?o.getHours()>1&&s.setDate(s.getDate()+1):a=="\u6628"?s.setDate(s.getDate()-1):a=="\u524D"?s.setDate(s.getDate()-2):a=="\u5927\u524D"?s.setDate(s.getDate()-3):a=="\u540E"?s.setDate(s.getDate()+2):a=="\u5927\u540E"&&s.setDate(s.getDate()+3);let l=t[_ie];if(l){let c=l[0];c=="\u65E9"||c=="\u4E0A"?i.start.imply("hour",6):c=="\u4E0B"?(i.start.imply("hour",15),i.start.imply("meridiem",1)):c=="\u4E2D"?(i.start.imply("hour",12),i.start.imply("meridiem",1)):c=="\u591C"||c=="\u665A"?(i.start.imply("hour",22),i.start.imply("meridiem",1)):c=="\u51CC"&&i.start.imply("hour",0)}}return i.start.assign("day",s.getDate()),i.start.assign("month",s.getMonth()+1),i.start.assign("year",s.getFullYear()),i}}});var Aie,vM,kie,lw,nz=b(()=>{fe();Bt();xp();Aie=new RegExp("(\\d+|["+Object.keys(yn).join("")+"]+|\u534A|\u51E0)(?:\\s*)(?:\u4E2A)?(\u79D2(?:\u949F)?|\u5206\u949F|\u5C0F\u65F6|\u949F|\u65E5|\u5929|\u661F\u671F|\u793C\u62DC|\u6708|\u5E74)(?:\u4E4B)?\u524D","i"),vM=1,kie=2,lw=class extends L{innerPattern(){return Aie}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=parseInt(t[vM]);if(isNaN(i)&&(i=Ro(t[vM])),isNaN(i)){let c=t[vM];if(c==="\u51E0")i=3;else if(c==="\u534A")i=.5;else return null}let o={},a=t[kie][0];if(a.match(/[日天星礼月年]/)){a=="\u65E5"||a=="\u5929"?o.day=i:a=="\u661F"||a=="\u793C"?o.week=i:a=="\u6708"?o.month=i:a=="\u5E74"&&(o.year=i),o=tt(o);let c=gt(e.refDate,o);return n.start.assign("year",c.getFullYear()),n.start.assign("month",c.getMonth()+1),n.start.assign("day",c.getDate()),n}a=="\u79D2"?o.second=i:a=="\u5206"?o.minute=i:(a=="\u5C0F"||a=="\u949F")&&(o.hour=i),o=tt(o);let l=gt(e.refDate,o);return n.start.imply("year",l.getFullYear()),n.start.imply("month",l.getMonth()+1),n.start.imply("day",l.getDate()),n.start.assign("hour",l.getHours()),n.start.assign("minute",l.getMinutes()),n.start.assign("second",l.getSeconds()),n}}});var cw,iz=b(()=>{go();cw=class extends Yt{patternBetween(){return/^\s*(至|到|-|~|~|-|ー)\s*$/i}}});var uw,oz=b(()=>{vo();uw=class extends Kt{patternBetween(){return/^\s*$/i}}});var CM={};Zr(CM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>yM,createCasualConfiguration:()=>bM,createConfiguration:()=>wM,hans:()=>Sie,parse:()=>Iie,parseDate:()=>Pie,strict:()=>Die});function Iie(r,e,t){return yM.parse(r,e,t)}function Pie(r,e,t){return yM.parseDate(r,e,t)}function bM(){let r=wM();return r.parsers.unshift(new aw),r}function wM(){let r=Ht({parsers:[new Ep,new _p,new kp,new Ap,new Tp,new lw],refiners:[new cw,new uw]});return r.refiners=r.refiners.filter(e=>!(e instanceof $a)),r}var Sie,yM,Die,sz=b(()=>{qy();xi();si();Le();pt();rz();KF();QF();nz();ZF();JF();eM();iz();oz();Sie=new Se(bM()),yM=new Se(bM()),Die=new Se(wM())});var TM={};Zr(TM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>xM,createCasualConfiguration:()=>az,createConfiguration:()=>EM,hans:()=>CM,hant:()=>gM,parse:()=>Mie,parseDate:()=>Rie,strict:()=>Fie});function Mie(r,e,t){return xM.parse(r,e,t)}function Rie(r,e,t){return xM.parseDate(r,e,t)}function az(){let r=EM();return r.parsers.unshift(new Sp),r}function EM(){let r=Ht({parsers:[new Ip,new Ep,new Fp,new _p,new Rp,new kp,new Mp,new Ap,new Pp,new Tp],refiners:[new $p,new Op]});return r.refiners=r.refiners.filter(e=>!(e instanceof $a)),r}var xM,Fie,lz=b(()=>{xi();si();Le();pt();qy();KF();QF();ZF();JF();eM();tM();iM();sM();aM();lM();cM();uM();dM();Z3();sz();xM=new Se(az()),Fie=new Se(EM())});function Oie(r){let e=r.toLowerCase();return AM[e]!==void 0?AM[e]:e.match(/несколько/)?3:e.match(/пол/)?.5:e.match(/пар/)?2:e===""?1:parseFloat(e)}function PM(r){let e=r.toLowerCase();return kM[e]!==void 0?kM[e]:parseInt(e)}function yA(r){if(/(год|года|г|г.)/i.test(r)&&(r=r.replace(/(год|года|г|г.)/i,"")),/(до н.э.|до н. э.)/i.test(r))return r=r.replace(/(до н.э.|до н. э.)/i,""),-parseInt(r);if(/(н. э.|н.э.)/i.test(r))return r=r.replace(/(н. э.|н.э.)/i,""),parseInt(r);let e=parseInt(r);return jr(e)}function Qm(r){let e={},t=r,n=cz.exec(t);for(;n;)Nie(e,n),t=t.substring(n[0].length).trim(),n=cz.exec(t);return e}function Nie(r,e){let t=Oie(e[1]),n=dw[e[2].toLowerCase()];r[n]=t}var ds,SM,DM,Km,AM,kM,dw,$ie,IM,_M,vA,uz,cz,Xm,ps=b(()=>{ze();zt();ds={leftBoundary:"([^\\p{L}\\p{N}_]|^)",rightBoundary:"(?=[^\\p{L}\\p{N}_]|$)",flags:"iu"},SM={\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u0435:0,\u0432\u043E\u0441\u043A\u0440\u0435\u0441\u0435\u043D\u044C\u044F:0,\u0432\u0441\u043A:0,"\u0432\u0441\u043A.":0,\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A:1,\u043F\u043E\u043D\u0435\u0434\u0435\u043B\u044C\u043D\u0438\u043A\u0430:1,\u043F\u043D:1,"\u043F\u043D.":1,\u0432\u0442\u043E\u0440\u043D\u0438\u043A:2,\u0432\u0442\u043E\u0440\u043D\u0438\u043A\u0430:2,\u0432\u0442:2,"\u0432\u0442.":2,\u0441\u0440\u0435\u0434\u0430:3,\u0441\u0440\u0435\u0434\u044B:3,\u0441\u0440\u0435\u0434\u0443:3,\u0441\u0440:3,"\u0441\u0440.":3,\u0447\u0435\u0442\u0432\u0435\u0440\u0433:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0430:4,\u0447\u0442:4,"\u0447\u0442.":4,\u043F\u044F\u0442\u043D\u0438\u0446\u0430:5,\u043F\u044F\u0442\u043D\u0438\u0446\u0443:5,\u043F\u044F\u0442\u043D\u0438\u0446\u044B:5,\u043F\u0442:5,"\u043F\u0442.":5,\u0441\u0443\u0431\u0431\u043E\u0442\u0430:6,\u0441\u0443\u0431\u0431\u043E\u0442\u0443:6,\u0441\u0443\u0431\u0431\u043E\u0442\u044B:6,\u0441\u0431:6,"\u0441\u0431.":6},DM={\u044F\u043D\u0432\u0430\u0440\u044C:1,\u044F\u043D\u0432\u0430\u0440\u044F:1,\u044F\u043D\u0432\u0430\u0440\u0435:1,\u0444\u0435\u0432\u0440\u0430\u043B\u044C:2,\u0444\u0435\u0432\u0440\u0430\u043B\u044F:2,\u0444\u0435\u0432\u0440\u0430\u043B\u0435:2,\u043C\u0430\u0440\u0442:3,\u043C\u0430\u0440\u0442\u0430:3,\u043C\u0430\u0440\u0442\u0435:3,\u0430\u043F\u0440\u0435\u043B\u044C:4,\u0430\u043F\u0440\u0435\u043B\u044F:4,\u0430\u043F\u0440\u0435\u043B\u0435:4,\u043C\u0430\u0439:5,\u043C\u0430\u044F:5,\u043C\u0430\u0435:5,\u0438\u044E\u043D\u044C:6,\u0438\u044E\u043D\u044F:6,\u0438\u044E\u043D\u0435:6,\u0438\u044E\u043B\u044C:7,\u0438\u044E\u043B\u044F:7,\u0438\u044E\u043B\u0435:7,\u0430\u0432\u0433\u0443\u0441\u0442:8,\u0430\u0432\u0433\u0443\u0441\u0442\u0430:8,\u0430\u0432\u0433\u0443\u0441\u0442\u0435:8,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044C:9,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u044F:9,\u0441\u0435\u043D\u0442\u044F\u0431\u0440\u0435:9,\u043E\u043A\u0442\u044F\u0431\u0440\u044C:10,\u043E\u043A\u0442\u044F\u0431\u0440\u044F:10,\u043E\u043A\u0442\u044F\u0431\u0440\u0435:10,\u043D\u043E\u044F\u0431\u0440\u044C:11,\u043D\u043E\u044F\u0431\u0440\u044F:11,\u043D\u043E\u044F\u0431\u0440\u0435:11,\u0434\u0435\u043A\u0430\u0431\u0440\u044C:12,\u0434\u0435\u043A\u0430\u0431\u0440\u044F:12,\u0434\u0435\u043A\u0430\u0431\u0440\u0435:12},Km={...DM,\u044F\u043D\u0432:1,"\u044F\u043D\u0432.":1,\u0444\u0435\u0432:2,"\u0444\u0435\u0432.":2,\u043C\u0430\u0440:3,"\u043C\u0430\u0440.":3,\u0430\u043F\u0440:4,"\u0430\u043F\u0440.":4,\u0430\u0432\u0433:8,"\u0430\u0432\u0433.":8,\u0441\u0435\u043D:9,"\u0441\u0435\u043D.":9,\u043E\u043A\u0442:10,"\u043E\u043A\u0442.":10,\u043D\u043E\u044F:11,"\u043D\u043E\u044F.":11,\u0434\u0435\u043A:12,"\u0434\u0435\u043A.":12},AM={\u043E\u0434\u0438\u043D:1,\u043E\u0434\u043D\u0430:1,\u043E\u0434\u043D\u043E\u0439:1,\u043E\u0434\u043D\u0443:1,\u0434\u0432\u0435:2,\u0434\u0432\u0430:2,\u0434\u0432\u0443\u0445:2,\u0442\u0440\u0438:3,\u0442\u0440\u0435\u0445:3,\u0442\u0440\u0451\u0445:3,\u0447\u0435\u0442\u044B\u0440\u0435:4,\u0447\u0435\u0442\u044B\u0440\u0435\u0445:4,\u0447\u0435\u0442\u044B\u0440\u0451\u0445:4,\u043F\u044F\u0442\u044C:5,\u043F\u044F\u0442\u0438:5,\u0448\u0435\u0441\u0442\u044C:6,\u0448\u0435\u0441\u0442\u0438:6,\u0441\u0435\u043C\u044C:7,\u0441\u0435\u043C\u0438:7,\u0432\u043E\u0441\u0435\u043C\u044C:8,\u0432\u043E\u0441\u044C\u043C\u0438:8,\u0434\u0435\u0432\u044F\u0442\u044C:9,\u0434\u0435\u0432\u044F\u0442\u0438:9,\u0434\u0435\u0441\u044F\u0442\u044C:10,\u0434\u0435\u0441\u044F\u0442\u0438:10,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u044C:11,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u0438:11,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u044C:12,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u0438:12},kM={\u043F\u0435\u0440\u0432\u043E\u0435:1,\u043F\u0435\u0440\u0432\u043E\u0433\u043E:1,\u0432\u0442\u043E\u0440\u043E\u0435:2,\u0432\u0442\u043E\u0440\u043E\u0433\u043E:2,\u0442\u0440\u0435\u0442\u044C\u0435:3,\u0442\u0440\u0435\u0442\u044C\u0435\u0433\u043E:3,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0435:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E:4,\u043F\u044F\u0442\u043E\u0435:5,\u043F\u044F\u0442\u043E\u0433\u043E:5,\u0448\u0435\u0441\u0442\u043E\u0435:6,\u0448\u0435\u0441\u0442\u043E\u0433\u043E:6,\u0441\u0435\u0434\u044C\u043C\u043E\u0435:7,\u0441\u0435\u0434\u044C\u043C\u043E\u0433\u043E:7,\u0432\u043E\u0441\u044C\u043C\u043E\u0435:8,\u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E:8,\u0434\u0435\u0432\u044F\u0442\u043E\u0435:9,\u0434\u0435\u0432\u044F\u0442\u043E\u0433\u043E:9,\u0434\u0435\u0441\u044F\u0442\u043E\u0435:10,\u0434\u0435\u0441\u044F\u0442\u043E\u0433\u043E:10,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:11,\u043E\u0434\u0438\u043D\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:11,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:12,\u0434\u0432\u0435\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:12,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:13,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:13,\u0447\u0435\u0442\u044B\u0440\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:14,\u0447\u0435\u0442\u044B\u0440\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:14,\u043F\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:15,\u043F\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:15,\u0448\u0435\u0441\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:16,\u0448\u0435\u0441\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:16,\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:17,\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:17,\u0432\u043E\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:18,\u0432\u043E\u0441\u0435\u043C\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:18,\u0434\u0435\u0432\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0435:19,\u0434\u0435\u0432\u044F\u0442\u043D\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:19,\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043E\u0435:20,\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u043E\u0433\u043E:20,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0435":21,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0433\u043E":21,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u0442\u043E\u0440\u043E\u0435":22,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u0442\u043E\u0440\u043E\u0433\u043E":22,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u0435":23,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u0435\u0433\u043E":23,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0435":24,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E":24,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u044F\u0442\u043E\u0435":25,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u043F\u044F\u0442\u043E\u0433\u043E":25,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0448\u0435\u0441\u0442\u043E\u0435":26,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0448\u0435\u0441\u0442\u043E\u0433\u043E":26,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0441\u0435\u0434\u044C\u043C\u043E\u0435":27,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0441\u0435\u0434\u044C\u043C\u043E\u0433\u043E":27,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0435":28,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E":28,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0434\u0435\u0432\u044F\u0442\u043E\u0435":29,"\u0434\u0432\u0430\u0434\u0446\u0430\u0442\u044C \u0434\u0435\u0432\u044F\u0442\u043E\u0433\u043E":29,\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u043E\u0435:30,\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u043E\u0433\u043E:30,"\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0435":31,"\u0442\u0440\u0438\u0434\u0446\u0430\u0442\u044C \u043F\u0435\u0440\u0432\u043E\u0433\u043E":31},dw={\u0441\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u044B:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0443:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0443:"second",\u043C\u0438\u043D:"minute",\u043C\u0438\u043D\u0443\u0442\u0430:"minute",\u043C\u0438\u043D\u0443\u0442:"minute",\u043C\u0438\u043D\u0443\u0442\u044B:"minute",\u043C\u0438\u043D\u0443\u0442\u0443:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u043A:"minute",\u043C\u0438\u043D\u0443\u0442\u043A\u0438:"minute",\u043C\u0438\u043D\u0443\u0442\u043A\u0443:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u0435\u043A:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u043A\u0438:"minute",\u043C\u0438\u043D\u0443\u0442\u043E\u0447\u043A\u0443:"minute",\u0447\u0430\u0441:"hour",\u0447\u0430\u0441\u043E\u0432:"hour",\u0447\u0430\u0441\u0430:"hour",\u0447\u0430\u0441\u0443:"hour",\u0447\u0430\u0441\u0438\u043A\u043E\u0432:"hour",\u0447\u0430\u0441\u0438\u043A\u0430:"hour",\u0447\u0430\u0441\u0438\u043A\u0435:"hour",\u0447\u0430\u0441\u0438\u043A:"hour",\u0434\u0435\u043D\u044C:"day",\u0434\u043D\u044F:"day",\u0434\u043D\u0435\u0439:"day",\u0441\u0443\u0442\u043E\u043A:"day",\u0441\u0443\u0442\u043A\u0438:"day",\u043D\u0435\u0434\u0435\u043B\u044F:"week",\u043D\u0435\u0434\u0435\u043B\u0435:"week",\u043D\u0435\u0434\u0435\u043B\u0438:"week",\u043D\u0435\u0434\u0435\u043B\u044E:"week",\u043D\u0435\u0434\u0435\u043B\u044C:"week",\u043D\u0435\u0434\u0435\u043B\u044C\u043A\u0435:"week",\u043D\u0435\u0434\u0435\u043B\u044C\u043A\u0438:"week",\u043D\u0435\u0434\u0435\u043B\u0435\u043A:"week",\u043C\u0435\u0441\u044F\u0446:"month",\u043C\u0435\u0441\u044F\u0446\u0435:"month",\u043C\u0435\u0441\u044F\u0446\u0435\u0432:"month",\u043C\u0435\u0441\u044F\u0446\u0430:"month",\u043A\u0432\u0430\u0440\u0442\u0430\u043B:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0435:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u043E\u0432:"quarter",\u0433\u043E\u0434:"year",\u0433\u043E\u0434\u0430:"year",\u0433\u043E\u0434\u0443:"year",\u0433\u043E\u0434\u043E\u0432:"year",\u043B\u0435\u0442:"year",\u0433\u043E\u0434\u0438\u043A:"year",\u0433\u043E\u0434\u0438\u043A\u0430:"year",\u0433\u043E\u0434\u0438\u043A\u043E\u0432:"year"},$ie=`(?:${ee(AM)}|[0-9]+|[0-9]+\\.[0-9]+|\u043F\u043E\u043B|\u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E|\u043F\u0430\u0440(?:\u044B|\u0443)|\\s{0,3})`;IM=`(?:${ee(kM)}|[0-9]{1,2}(?:\u0433\u043E|\u043E\u0433\u043E|\u0435|\u043E\u0435)?)`;_M="(?:\\s+(?:\u0433\u043E\u0434\u0443|\u0433\u043E\u0434\u0430|\u0433\u043E\u0434|\u0433|\u0433.))?",vA=`(?:[1-9][0-9]{0,3}${_M}\\s*(?:\u043D.\u044D.|\u0434\u043E \u043D.\u044D.|\u043D. \u044D.|\u0434\u043E \u043D. \u044D.)|[1-2][0-9]{3}${_M}|[5-9][0-9]${_M})`;uz=`(${$ie})\\s{0,3}(${ee(dw)})`,cz=new RegExp(uz,"i"),Xm=Er("(?:(?:\u043E\u043A\u043E\u043B\u043E|\u043F\u0440\u0438\u043C\u0435\u0440\u043D\u043E)\\s{0,3})?",uz)});var dz,pw,pz=b(()=>{ps();Le();fe();dz=`(?:(?:\u043E\u043A\u043E\u043B\u043E|\u043F\u0440\u0438\u043C\u0435\u0440\u043D\u043E)\\s*(?:~\\s*)?)?(${Xm})${ds.rightBoundary}`,pw=class extends L{patternLeftBoundary(){return ds.leftBoundary}innerPattern(e){return e.option.forwardDate?new RegExp(dz,ds.flags):new RegExp(`(?:\u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0435|\u0432 \u0442\u0435\u0447\u0435\u043D\u0438\u0438)\\s*${dz}`,ds.flags)}innerExtract(e,t){let n=Qm(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var Np,Oo,Mc=b(()=>{fe();ps();Np=class extends L{patternLeftBoundary(){return ds.leftBoundary}innerPattern(e){return new RegExp(this.innerPatternString(e),ds.flags)}innerPatternHasChange(e,t){return!1}},Oo=class extends Np{innerPattern(e){return new RegExp(`${this.innerPatternString(e)}${ds.rightBoundary}`,ds.flags)}}});var fz,mz,Lie,hz,fw,gz=b(()=>{zt();ps();ps();ps();ze();Mc();fz=1,mz=2,Lie=3,hz=4,fw=class extends Oo{innerPatternString(e){return`(?:\u0441)?\\s*(${IM})(?:\\s{0,3}(?:\u043F\u043E|-|\u2013|\u0434\u043E)?\\s{0,3}(${IM}))?(?:-|\\/|\\s{0,3}(?:of)?\\s{0,3})(${ee(Km)})(?:(?:-|\\/|,?\\s{0,3})(${vA}(?![^\\s]\\d)))?`}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=Km[t[Lie].toLowerCase()],o=PM(t[fz]);if(o>31)return t.index=t.index+t[fz].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[hz]){let s=yA(t[hz]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[mz]){let s=PM(t[mz]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Bie,vz,mw,yz=b(()=>{ps();zt();ze();ps();Mc();Bie=2,vz=3,mw=class extends Np{innerPatternString(e){return`((?:\u0432)\\s*)?(${ee(Km)})\\s*(?:[,-]?\\s*(${vA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`}innerExtract(e,t){let n=t[Bie].toLowerCase();if(t[0].length<=3&&!DM[n])return null;let i=e.createParsingResult(t.index,t.index+t[0].length);i.start.imply("day",1);let o=Km[n];if(i.start.assign("month",o),t[vz]){let s=yA(t[vz]);i.start.assign("year",s)}else{let s=ft(e.refDate,1,o);i.start.imply("year",s)}return i}}});var hw,bz=b(()=>{pt();Ra();ps();hw=class extends Gr{constructor(e){super(e)}patternFlags(){return ds.flags}primaryPatternLeftBoundary(){return"(^|\\s|T|(?:[^\\p{L}\\p{N}_]))"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|\u0434\u043E|\u0438|\u043F\u043E|\\?)\\s*"}primaryPrefix(){return"(?:(?:\u0432|\u0441)\\s*)??"}primarySuffix(){return`(?:\\s*(?:\u0443\u0442\u0440\u0430|\u0432\u0435\u0447\u0435\u0440\u0430|\u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0434\u043D\u044F))?(?!\\/)${ds.rightBoundary}`}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(n){if(t[0].endsWith("\u0432\u0435\u0447\u0435\u0440\u0430")){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",G.PM)):i<6&&n.assign("meridiem",G.AM)}if(t[0].endsWith("\u043F\u043E\u0441\u043B\u0435 \u043F\u043E\u043B\u0443\u0434\u043D\u044F")){n.assign("meridiem",G.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}t[0].endsWith("\u0443\u0442\u0440\u0430")&&(n.assign("meridiem",G.AM),n.get("hour")<12&&n.assign("hour",n.get("hour")))}return n}}});var gw,wz=b(()=>{ps();Le();Mc();Bt();gw=class extends Np{innerPatternString(e){return`(${Xm})\\s{0,5}\u043D\u0430\u0437\u0430\u0434(?=(?:\\W|$))`}innerExtract(e,t){let n=Qm(t[1]),i=tt(n);return Q.createRelativeFromReference(e.reference,i)}}});var vw,Cz=b(()=>{go();vw=class extends Yt{patternBetween(){return/^\s*(и до|и по|до|по|-)\s*$/i}}});var yw,xz=b(()=>{vo();yw=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\u0432|,|-)?\\s*$")}}});var bw,Ez=b(()=>{oi();Mc();bw=class extends Oo{innerPatternString(e){return"(?:\u0441|\u0441\u043E)?\\s*(\u0441\u0435\u0433\u043E\u0434\u043D\u044F|\u0432\u0447\u0435\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0441\u043B\u0435\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430|\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430)"}innerExtract(e,t){let n=t[1].toLowerCase(),i=e.createParsingComponents();switch(n){case"\u0441\u0435\u0433\u043E\u0434\u043D\u044F":return Tr(e.reference);case"\u0432\u0447\u0435\u0440\u0430":return gn(e.reference);case"\u0437\u0430\u0432\u0442\u0440\u0430":return vn(e.reference);case"\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430":return Mo(e.reference,2);case"\u043F\u043E\u0441\u043B\u0435\u043F\u043E\u0441\u043B\u0435\u0437\u0430\u0432\u0442\u0440\u0430":return Mo(e.reference,3);case"\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430":return Sc(e.reference,2);case"\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u0435\u0440\u0430":return Sc(e.reference,3)}return i}}});var ww,Tz=b(()=>{oi();nn();Mc();ww=class extends Oo{innerPatternString(e){return"(\u0441\u0435\u0439\u0447\u0430\u0441|\u043F\u0440\u043E\u0448\u043B\u044B\u043C\\s*\u0432\u0435\u0447\u0435\u0440\u043E\u043C|\u043F\u0440\u043E\u0448\u043B\u043E\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u0441\u0435\u0433\u043E\u0434\u043D\u044F\\s*\u043D\u043E\u0447\u044C\u044E|\u044D\u0442\u043E\u0439\\s*\u043D\u043E\u0447\u044C\u044E|\u043D\u043E\u0447\u044C\u044E|\u044D\u0442\u0438\u043C \u0443\u0442\u0440\u043E\u043C|\u0443\u0442\u0440\u043E\u043C|\u0443\u0442\u0440\u0430|\u0432\\s*\u043F\u043E\u043B\u0434\u0435\u043D\u044C|\u0432\u0435\u0447\u0435\u0440\u043E\u043C|\u0432\u0435\u0447\u0435\u0440\u0430|\u0432\\s*\u043F\u043E\u043B\u043D\u043E\u0447\u044C)"}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();if(i==="\u0441\u0435\u0439\u0447\u0430\u0441")return $r(e.reference);if(i==="\u0432\u0435\u0447\u0435\u0440\u043E\u043C"||i==="\u0432\u0435\u0447\u0435\u0440\u0430")return Dc(e.reference);if(i.endsWith("\u0443\u0442\u0440\u043E\u043C")||i.endsWith("\u0443\u0442\u0440\u0430"))return Pc(e.reference);if(i.match(/в\s*полдень/))return qu(e.reference);if(i.match(/прошлой\s*ночью/))return Q_(e.reference);if(i.match(/прошлым\s*вечером/))return Z_(e.reference);if(i.match(/следующей\s*ночью/)){let s=n.getHours()<22?1:2,a=new Date(n.getTime());a.setDate(a.getDate()+s),nt(o,a),o.imply("hour",0)}return i.match(/в\s*полночь/)||i.endsWith("\u043D\u043E\u0447\u044C\u044E")?Ic(e.reference):o}}});var Uie,Vie,qie,Cw,_z=b(()=>{ps();ze();Ki();Mc();Uie=1,Vie=2,qie=3,Cw=class extends Oo{innerPatternString(e){return`(?:(?:,|\\(|\uFF08)\\s*)?(?:\u0432\\s*?)?(?:(\u044D\u0442\u0443|\u044D\u0442\u043E\u0442|\u043F\u0440\u043E\u0448\u043B\u044B\u0439|\u043F\u0440\u043E\u0448\u043B\u0443\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0443\u044E|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E)\\s*)?(${ee(SM)})(?:\\s*(?:,|\\)|\uFF09))?(?:\\s*\u043D\u0430\\s*(\u044D\u0442\u043E\u0439|\u043F\u0440\u043E\u0448\u043B\u043E\u0439|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439)\\s*\u043D\u0435\u0434\u0435\u043B\u0435)?`}innerExtract(e,t){let n=t[Vie].toLowerCase(),i=SM[n],o=t[Uie],s=t[qie],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a=="\u043F\u0440\u043E\u0448\u043B\u044B\u0439"||a=="\u043F\u0440\u043E\u0448\u043B\u0443\u044E"||a=="\u043F\u0440\u043E\u0448\u043B\u043E\u0439"?l="last":a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0443\u044E"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439"||a=="\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0433\u043E"?l="next":(a=="\u044D\u0442\u043E\u0442"||a=="\u044D\u0442\u0443"||a=="\u044D\u0442\u043E\u0439")&&(l="this"),cr(e.reference,i,l)}}});var Wie,zie,xw,Az=b(()=>{ps();Le();ze();Mc();Wie=1,zie=2,xw=class extends Oo{innerPatternString(e){return`(\u0432 \u043F\u0440\u043E\u0448\u043B\u043E\u043C|\u043D\u0430 \u043F\u0440\u043E\u0448\u043B\u043E\u0439|\u043D\u0430 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439|\u0432 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C|\u043D\u0430 \u044D\u0442\u043E\u0439|\u0432 \u044D\u0442\u043E\u043C)\\s*(${ee(dw)})`}innerExtract(e,t){let n=t[Wie].toLowerCase(),i=t[zie].toLowerCase(),o=dw[i];if(n=="\u043D\u0430 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u0439"||n=="\u0432 \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0435\u043C"){let l={};return l[o]=1,Q.createRelativeFromReference(e.reference,l)}if(n=="\u0432 \u043F\u0440\u043E\u0448\u043B\u043E\u043C"||n=="\u043D\u0430 \u043F\u0440\u043E\u0448\u043B\u043E\u0439"){let l={};return l[o]=-1,Q.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return o.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):o.match(/month/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):o.match(/year/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var Ew,kz=b(()=>{ps();Le();Mc();Bt();Ew=class extends Oo{innerPatternString(e){return`(\u044D\u0442\u0438|\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435|\u043F\u0440\u043E\u0448\u043B\u044B\u0435|\u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0435|\u043F\u043E\u0441\u043B\u0435|\u0441\u043F\u0443\u0441\u0442\u044F|\u0447\u0435\u0440\u0435\u0437|\\+|-)\\s*(${Xm})`}innerExtract(e,t){let n=t[1].toLowerCase(),i=Qm(t[2]);switch(n){case"\u043F\u043E\u0441\u043B\u0435\u0434\u043D\u0438\u0435":case"\u043F\u0440\u043E\u0448\u043B\u044B\u0435":case"-":i=tt(i);break}return Q.createRelativeFromReference(e.reference,i)}}});var RM={};Zr(RM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>FM,createCasualConfiguration:()=>Sz,createConfiguration:()=>MM,parse:()=>jie,parseDate:()=>Gie,strict:()=>Hie});function jie(r,e,t){return FM.parse(r,e,t)}function Gie(r,e,t){return FM.parseDate(r,e,t)}function Sz(){let r=MM(!1);return r.parsers.unshift(new bw),r.parsers.unshift(new ww),r.parsers.unshift(new mw),r.parsers.unshift(new xw),r.parsers.unshift(new Ew),r}function MM(r=!0){return Ht({parsers:[new vr(!0),new pw,new fw,new Cw,new hw(r),new gw],refiners:[new yw,new vw]},r)}var FM,Hie,Dz=b(()=>{pz();gz();yz();bz();wz();Cz();xz();xi();Ez();Tz();_z();Az();si();Le();pt();cs();kz();FM=new Se(Sz()),Hie=new Se(MM(!0))});function Kie(r){let e=r.toLowerCase();return $M[e]!==void 0?$M[e]:e==="un"||e==="una"||e==="uno"?1:e.match(/algunos?/)||e.match(/unos?/)?3:e.match(/media?/)?.5:parseFloat(e)}function Mz(r){if(r.match(/^[0-9]{1,4}$/)){let e=parseInt(r);return e<100&&(e>50?e=e+1900:e=e+2e3),e}return r.match(/a\.?\s*c\.?/i)?(r=r.replace(/a\.?\s*c\.?/i,""),-parseInt(r)):parseInt(r)}function Oz(r){let e={},t=r,n=Iz.exec(t);for(;n;)Xie(e,n),t=t.substring(n[0].length),n=Iz.exec(t);return e}function Xie(r,e){let t=Kie(e[1]),n=Pz[e[2].toLowerCase()];r[n]=t}var OM,NM,$M,Pz,Yie,Fz,Rz,Iz,$z,Tw=b(()=>{ze();OM={domingo:0,dom:0,lunes:1,lun:1,martes:2,mar:2,mi\u00E9rcoles:3,miercoles:3,mi\u00E9:3,mie:3,jueves:4,jue:4,viernes:5,vie:5,s\u00E1bado:6,sabado:6,s\u00E1b:6,sab:6},NM={enero:1,ene:1,"ene.":1,febrero:2,feb:2,"feb.":2,marzo:3,mar:3,"mar.":3,abril:4,abr:4,"abr.":4,mayo:5,may:5,"may.":5,junio:6,jun:6,"jun.":6,julio:7,jul:7,"jul.":7,agosto:8,ago:8,"ago.":8,septiembre:9,setiembre:9,sep:9,"sep.":9,octubre:10,oct:10,"oct.":10,noviembre:11,nov:11,"nov.":11,diciembre:12,dic:12,"dic.":12},$M={uno:1,dos:2,tres:3,cuatro:4,cinco:5,seis:6,siete:7,ocho:8,nueve:9,diez:10,once:11,doce:12,trece:13},Pz={sec:"second",segundo:"second",segundos:"second",min:"minute",mins:"minute",minuto:"minute",minutos:"minute",h:"hour",hr:"hour",hrs:"hour",hora:"hour",horas:"hour",d\u00EDa:"day",d\u00EDas:"day",semana:"week",semanas:"week",mes:"month",meses:"month",cuarto:"quarter",cuartos:"quarter",a\u00F1o:"year",a\u00F1os:"year"},Yie=`(?:${ee($M)}|[0-9]+|[0-9]+\\.[0-9]+|un?|uno?|una?|algunos?|unos?|demi-?)`;Fz="[0-9]{1,4}(?![^\\s]\\d)(?:\\s*[a|d]\\.?\\s*c\\.?|\\s*a\\.?\\s*d\\.?)?";Rz=`(${Yie})\\s{0,5}(${ee(Pz)})\\s{0,5}`,Iz=new RegExp(Rz,"i"),$z=Er("",Rz)});var Qie,Zie,Jie,eoe,_w,Nz=b(()=>{Tw();ze();fe();Ki();Qie=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(este|esta|pasado|pr[o\xF3]ximo)\\s*)?(${ee(OM)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(este|esta|pasado|pr[\xF3o]ximo)\\s*semana)?(?=\\W|\\d|$)`,"i"),Zie=1,Jie=2,eoe=3,_w=class extends L{innerPattern(){return Qie}innerExtract(e,t){let n=t[Jie].toLowerCase(),i=OM[n];if(i===void 0)return null;let o=t[Zie],s=t[eoe],a=o||s||"";a=a.toLowerCase();let l=null;return a=="pasado"?l="this":a=="pr\xF3ximo"||a=="proximo"?l="next":a=="este"&&(l="this"),cr(e.reference,i,l)}}});var Aw,Lz=b(()=>{Ra();Aw=class extends Gr{primaryPrefix(){return"(?:(?:aslas|deslas|las?|al?|de|del)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a(?:l)?|\\?)\\s*"}}});var kw,Bz=b(()=>{vo();kw=class extends Kt{patternBetween(){return new RegExp("^\\s*(?:,|de|aslas|a)?\\s*$")}}});var Sw,Uz=b(()=>{go();Sw=class extends Yt{patternBetween(){return/^\s*(?:-)\s*$/i}}});var toe,Vz,qz,roe,Wz,Dw,zz=b(()=>{zt();Tw();Tw();ze();fe();toe=new RegExp(`([0-9]{1,2})(?:\xBA|\xAA|\xB0)?(?:\\s*(?:desde|de|\\-|\\\u2013|ao?|\\s)\\s*([0-9]{1,2})(?:\xBA|\xAA|\xB0)?)?\\s*(?:de)?\\s*(?:-|/|\\s*(?:de|,)?\\s*)(${ee(NM)})(?:\\s*(?:de|,)?\\s*(${Fz}))?(?=\\W|$)`,"i"),Vz=1,qz=2,roe=3,Wz=4,Dw=class extends L{innerPattern(){return toe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=NM[t[roe].toLowerCase()],o=parseInt(t[Vz]);if(o>31)return t.index=t.index+t[Vz].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[Wz]){let s=Mz(t[Wz]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[qz]){let s=parseInt(t[qz]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Iw,Hz=b(()=>{fe();oi();Iw=class extends L{innerPattern(e){return/(ahora|hoy|mañana|ayer)(?=\W|$)/i}innerExtract(e,t){let n=t[0].toLowerCase(),i=e.createParsingComponents();switch(n){case"ahora":return $r(e.reference);case"hoy":return Tr(e.reference);case"ma\xF1ana":return vn(e.reference);case"ayer":return gn(e.reference)}return i}}});var Pw,jz=b(()=>{pt();fe();nn();Pw=class extends L{innerPattern(){return/(?:esta\s*)?(mañana|tarde|medianoche|mediodia|mediodía|noche)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=e.createParsingComponents();switch(t[1].toLowerCase()){case"tarde":i.imply("meridiem",G.PM),i.imply("hour",15),i.addTag("casualReference/afternoon");break;case"noche":i.imply("meridiem",G.PM),i.imply("hour",22),i.addTag("casualReference/evening");break;case"ma\xF1ana":i.imply("meridiem",G.AM),i.imply("hour",6),i.addTag("casualReference/morning");break;case"medianoche":let o=new Date(n.getTime());o.setDate(o.getDate()+1),nt(i,o),Lt(i,o),i.imply("hour",0),i.imply("minute",0),i.imply("second",0),i.addTag("casualReference/midnight");break;case"mediodia":case"mediod\xEDa":i.imply("meridiem",G.AM),i.imply("hour",12),i.addTag("casualReference/noon");break}return i}}});var Fw,Gz=b(()=>{Tw();Le();fe();Fw=class extends L{innerPattern(){return new RegExp(`(?:en|por|durante|de|dentro de)\\s*(${$z})(?=\\W|$)`,"i")}innerExtract(e,t){let n=Oz(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var UM={};Zr(UM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>LM,createCasualConfiguration:()=>Yz,createConfiguration:()=>BM,parse:()=>ioe,parseDate:()=>ooe,strict:()=>noe});function ioe(r,e,t){return LM.parse(r,e,t)}function ooe(r,e,t){return LM.parseDate(r,e,t)}function Yz(r=!0){let e=BM(!1,r);return e.parsers.push(new Iw),e.parsers.push(new Pw),e}function BM(r=!0,e=!0){return Ht({parsers:[new vr(e),new _w,new Aw,new Dw,new Fw],refiners:[new kw,new Sw]},r)}var LM,noe,Kz=b(()=>{xi();si();Le();pt();cs();Nz();Lz();Bz();Uz();zz();Hz();jz();Gz();LM=new Se(Yz()),noe=new Se(BM(!0))});function aoe(r){let e=r.toLowerCase();return qM[e]!==void 0?qM[e]:e.match(/декілька/)?2:e.match(/пів/)?.5:e.match(/пар/)?2:e===""?1:parseFloat(e)}function GM(r){let e=r.toLowerCase();return WM[e]!==void 0?WM[e]:parseInt(e)}function wA(r){if(/(рік|року|р|р.)/i.test(r)&&(r=r.replace(/(рік|року|р|р.)/i,"")),/(до н.е.|до н. е.)/i.test(r))return r=r.replace(/(до н.е.|до н. е.)/i,""),-parseInt(r);if(/(н. е.|н.е.)/i.test(r))return r=r.replace(/(н. е.|н.е.)/i,""),parseInt(r);let e=parseInt(r);return jr(e)}function eh(r){let e={},t=r,n=Xz.exec(t);for(;n;)loe(e,n),t=t.substring(n[0].length).trim(),n=Xz.exec(t);return e}function loe(r,e){let t=aoe(e[1]),n=Mw[e[2].toLowerCase()];r[n]=t}var fs,zM,HM,Zm,qM,WM,Mw,soe,jM,VM,bA,Qz,Xz,Jm,ms=b(()=>{ze();zt();fs={leftBoundary:"([^\\p{L}\\p{N}_]|^)",rightBoundary:"(?=[^\\p{L}\\p{N}_]|$)",flags:"iu"},zM={\u043D\u0435\u0434\u0456\u043B\u044F:0,\u043D\u0435\u0434\u0456\u043B\u0456:0,\u043D\u0435\u0434\u0456\u043B\u044E:0,\u043D\u0434:0,"\u043D\u0434.":0,\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043E\u043A:1,\u043F\u043E\u043D\u0435\u0434\u0456\u043B\u043A\u0430:1,\u043F\u043D:1,"\u043F\u043D.":1,\u0432\u0456\u0432\u0442\u043E\u0440\u043E\u043A:2,\u0432\u0456\u0432\u0442\u043E\u0440\u043A\u0430:2,\u0432\u0442:2,"\u0432\u0442.":2,\u0441\u0435\u0440\u0435\u0434\u0430:3,\u0441\u0435\u0440\u0435\u0434\u0438:3,\u0441\u0435\u0440\u0435\u0434\u0443:3,\u0441\u0440:3,"\u0441\u0440.":3,\u0447\u0435\u0442\u0432\u0435\u0440:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0430:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0433\u0443:4,\u0447\u0442:4,"\u0447\u0442.":4,"\u043F'\u044F\u0442\u043D\u0438\u0446\u044F":5,"\u043F'\u044F\u0442\u043D\u0438\u0446\u0456":5,"\u043F'\u044F\u0442\u043D\u0438\u0446\u044E":5,\u043F\u0442:5,"\u043F\u0442.":5,\u0441\u0443\u0431\u043E\u0442\u0430:6,\u0441\u0443\u0431\u043E\u0442\u0438:6,\u0441\u0443\u0431\u043E\u0442\u0443:6,\u0441\u0431:6,"\u0441\u0431.":6},HM={\u0441\u0456\u0447\u0435\u043D\u044C:1,\u0441\u0456\u0447\u043D\u044F:1,\u0441\u0456\u0447\u043D\u0456:1,\u043B\u044E\u0442\u0438\u0439:2,\u043B\u044E\u0442\u043E\u0433\u043E:2,\u043B\u044E\u0442\u043E\u043C\u0443:2,\u0431\u0435\u0440\u0435\u0437\u0435\u043D\u044C:3,\u0431\u0435\u0440\u0435\u0437\u043D\u044F:3,\u0431\u0435\u0440\u0435\u0437\u043D\u0456:3,\u043A\u0432\u0456\u0442\u0435\u043D\u044C:4,\u043A\u0432\u0456\u0442\u043D\u044F:4,\u043A\u0432\u0456\u0442\u043D\u0456:4,\u0442\u0440\u0430\u0432\u0435\u043D\u044C:5,\u0442\u0440\u0430\u0432\u043D\u044F:5,\u0442\u0440\u0430\u0432\u043D\u0456:5,\u0447\u0435\u0440\u0432\u0435\u043D\u044C:6,\u0447\u0435\u0440\u0432\u043D\u044F:6,\u0447\u0435\u0440\u0432\u043D\u0456:6,\u043B\u0438\u043F\u0435\u043D\u044C:7,\u043B\u0438\u043F\u043D\u044F:7,\u043B\u0438\u043F\u043D\u0456:7,\u0441\u0435\u0440\u043F\u0435\u043D\u044C:8,\u0441\u0435\u0440\u043F\u043D\u044F:8,\u0441\u0435\u0440\u043F\u043D\u0456:8,\u0432\u0435\u0440\u0435\u0441\u0435\u043D\u044C:9,\u0432\u0435\u0440\u0435\u0441\u043D\u044F:9,\u0432\u0435\u0440\u0435\u0441\u043D\u0456:9,\u0436\u043E\u0432\u0442\u0435\u043D\u044C:10,\u0436\u043E\u0432\u0442\u043D\u044F:10,\u0436\u043E\u0432\u0442\u043D\u0456:10,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434:11,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0430:11,\u043B\u0438\u0441\u0442\u043E\u043F\u0430\u0434\u0443:11,\u0433\u0440\u0443\u0434\u0435\u043D\u044C:12,\u0433\u0440\u0443\u0434\u043D\u044F:12,\u0433\u0440\u0443\u0434\u043D\u0456:12},Zm={...HM,\u0441\u0456\u0447:1,"\u0441\u0456\u0447.":1,\u043B\u044E\u0442:2,"\u043B\u044E\u0442.":2,\u0431\u0435\u0440:3,"\u0431\u0435\u0440.":3,\u043A\u0432\u0456\u0442:4,"\u043A\u0432\u0456\u0442.":4,\u0442\u0440\u0430\u0432:5,"\u0442\u0440\u0430\u0432.":5,\u0447\u0435\u0440\u0432:6,"\u0447\u0435\u0440\u0432.":6,\u043B\u0438\u043F:7,"\u043B\u0438\u043F.":7,\u0441\u0435\u0440\u043F:8,"\u0441\u0435\u0440\u043F.":8,\u0441\u0435\u0440:8,"c\u0435\u0440.":8,\u0432\u0435\u0440:9,"\u0432\u0435\u0440.":9,\u0432\u0435\u0440\u0435\u0441:9,"\u0432\u0435\u0440\u0435\u0441.":9,\u0436\u043E\u0432\u0442:10,"\u0436\u043E\u0432\u0442.":10,\u043B\u0438\u0441\u0442\u043E\u043F:11,"\u043B\u0438\u0441\u0442\u043E\u043F.":11,\u0433\u0440\u0443\u0434:12,"\u0433\u0440\u0443\u0434.":12},qM={\u043E\u0434\u0438\u043D:1,\u043E\u0434\u043D\u0430:1,\u043E\u0434\u043D\u043E\u0457:1,\u043E\u0434\u043D\u0443:1,\u0434\u0432\u0456:2,\u0434\u0432\u0430:2,\u0434\u0432\u043E\u0445:2,\u0442\u0440\u0438:3,\u0442\u0440\u044C\u043E\u0445:3,\u0447\u043E\u0442\u0438\u0440\u0438:4,\u0447\u043E\u0442\u0438\u0440\u044C\u043E\u0445:4,"\u043F'\u044F\u0442\u044C":5,"\u043F'\u044F\u0442\u0438":5,\u0448\u0456\u0441\u0442\u044C:6,\u0448\u0435\u0441\u0442\u0438:6,\u0441\u0456\u043C:7,\u0441\u0435\u043C\u0438:7,\u0432\u0456\u0441\u0456\u043C:8,\u0432\u043E\u0441\u044C\u043C\u0438:8,"\u0434\u0435\u0432'\u044F\u0442\u044C":9,"\u0434\u0435\u0432'\u044F\u0442\u0438":9,\u0434\u0435\u0441\u044F\u0442\u044C:10,\u0434\u0435\u0441\u044F\u0442\u0438:10,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u044C:11,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0438:11,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u044C:12,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u0438:12},WM={\u043F\u0435\u0440\u0448\u0435:1,\u043F\u0435\u0440\u0448\u043E\u0433\u043E:1,\u0434\u0440\u0443\u0433\u0435:2,\u0434\u0440\u0443\u0433\u043E\u0433\u043E:2,\u0442\u0440\u0435\u0442\u0454:3,\u0442\u0440\u0435\u0442\u044C\u043E\u0433\u043E:3,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0435:4,\u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E:4,"\u043F'\u044F\u0442\u0435":5,"\u043F'\u044F\u0442\u043E\u0433\u043E":5,\u0448\u043E\u0441\u0442\u0435:6,\u0448\u043E\u0441\u0442\u043E\u0433\u043E:6,\u0441\u044C\u043E\u043C\u0435:7,\u0441\u044C\u043E\u043C\u043E\u0433\u043E:7,\u0432\u043E\u0441\u044C\u043C\u0435:8,\u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E:8,"\u0434\u0435\u0432'\u044F\u0442\u0435":9,"\u0434\u0435\u0432'\u044F\u0442\u043E\u0433\u043E":9,\u0434\u0435\u0441\u044F\u0442\u0435:10,\u0434\u0435\u0441\u044F\u0442\u043E\u0433\u043E:10,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0435:11,\u043E\u0434\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:11,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u0435:12,\u0434\u0432\u0430\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:12,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u0435:13,\u0442\u0440\u0438\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:13,\u0447\u043E\u0442\u0438\u0440\u043D\u0430\u0434\u0446\u044F\u0442\u0435:14,\u0447\u043E\u0442\u0438\u043D\u0440\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:14,"\u043F'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435":15,"\u043F'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E":15,\u0448\u0456\u0441\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435:16,\u0448\u0456\u0441\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:16,\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u0435:17,\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:17,\u0432\u0456\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u0435:18,\u0432\u0456\u0441\u0456\u043C\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:18,"\u0434\u0435\u0432'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u0435":19,"\u0434\u0435\u0432'\u044F\u0442\u043D\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E":19,\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u0435:20,\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u043E\u0433\u043E:20,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u0435":21,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u043E\u0433\u043E":21,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0440\u0443\u0433\u0435":22,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0440\u0443\u0433\u043E\u0433\u043E":22,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0442\u0440\u0435\u0442\u0454":23,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0442\u0440\u0435\u0442\u044C\u043E\u0433\u043E":23,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u0435":24,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0447\u0435\u0442\u0432\u0435\u0440\u0442\u043E\u0433\u043E":24,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F'\u044F\u0442\u0435":25,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u043F'\u044F\u0442\u043E\u0433\u043E":25,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0448\u043E\u0441\u0442\u0435":26,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0448\u043E\u0441\u0442\u043E\u0433\u043E":26,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0441\u044C\u043E\u043C\u0435":27,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0441\u044C\u043E\u043C\u043E\u0433\u043E":27,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u0435":28,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0432\u043E\u0441\u044C\u043C\u043E\u0433\u043E":28,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0435\u0432'\u044F\u0442\u0435":29,"\u0434\u0432\u0430\u0434\u0446\u044F\u0442\u044C \u0434\u0435\u0432'\u044F\u0442\u043E\u0433\u043E":29,\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u0435:30,\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u043E\u0433\u043E:30,"\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u0435":31,"\u0442\u0440\u0438\u0434\u0446\u044F\u0442\u044C \u043F\u0435\u0440\u0448\u043E\u0433\u043E":31},Mw={\u0441\u0435\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0430:"second",\u0441\u0435\u043A\u0443\u043D\u0434:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u0443:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043E\u043A:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0438:"second",\u0441\u0435\u043A\u0443\u043D\u0434\u043E\u0447\u043A\u0443:"second",\u0445\u0432:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0430:"minute",\u0445\u0432\u0438\u043B\u0438\u043D:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u0443:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u043A:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043A\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043A\u0443:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043E\u043A:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043A\u0438:"minute",\u0445\u0432\u0438\u043B\u0438\u043D\u043E\u0447\u043A\u0443:"minute",\u0433\u043E\u0434:"hour",\u0433\u043E\u0434\u0438\u043D\u0430:"hour",\u0433\u043E\u0434\u0438\u043D:"hour",\u0433\u043E\u0434\u0438\u043D\u0438:"hour",\u0433\u043E\u0434\u0438\u043D\u0443:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0430:"hour",\u0433\u043E\u0434\u0438\u043D\u043E\u043A:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0438:"hour",\u0433\u043E\u0434\u0438\u043D\u043A\u0443:"hour",\u0434\u0435\u043D\u044C:"day",\u0434\u043D\u044F:"day",\u0434\u043D\u0456\u0432:"day",\u0434\u043D\u0456:"day",\u0434\u043E\u0431\u0430:"day",\u0434\u043E\u0431\u0443:"day",\u0442\u0438\u0436\u0434\u0435\u043D\u044C:"week",\u0442\u0438\u0436\u043D\u044E:"week",\u0442\u0438\u0436\u043D\u044F:"week",\u0442\u0438\u0436\u043D\u0456:"week",\u0442\u0438\u0436\u043D\u0456\u0432:"week",\u043C\u0456\u0441\u044F\u0446\u044C:"month",\u043C\u0456\u0441\u044F\u0446\u0456\u0432:"month",\u043C\u0456\u0441\u044F\u0446\u0456:"month",\u043C\u0456\u0441\u044F\u0446\u044F:"month",\u043A\u0432\u0430\u0440\u0442\u0430\u043B:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0443:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0430:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0456\u0432:"quarter",\u043A\u0432\u0430\u0440\u0442\u0430\u043B\u0456:"quarter",\u0440\u0456\u043A:"year",\u0440\u043E\u043A\u0443:"year",\u0440\u043E\u0446\u0456:"year",\u0440\u043E\u043A\u0456\u0432:"year",\u0440\u043E\u043A\u0438:"year"},soe=`(?:${ee(qM)}|[0-9]+|[0-9]+\\.[0-9]+|\u043F\u0456\u0432|\u0434\u0435\u043A\u0456\u043B\u044C\u043A\u0430|\u043F\u0430\u0440(?:\u0443)|\\s{0,3})`;jM=`(?:${ee(WM)}|[0-9]{1,2}(?:\u0433\u043E|\u043E\u0433\u043E|\u0435)?)`;VM="(?:\\s+(?:\u0440\u043E\u043A\u0443|\u0440\u0456\u043A|\u0440|\u0440.))?",bA=`(?:[1-9][0-9]{0,3}${VM}\\s*(?:\u043D.\u0435.|\u0434\u043E \u043D.\u0435.|\u043D. \u0435.|\u0434\u043E \u043D. \u0435.)|[1-2][0-9]{3}${VM}|[5-9][0-9]${VM})`;Qz=`(${soe})\\s{0,3}(${ee(Mw)})`,Xz=new RegExp(Qz,"i"),Jm=Er("(?:(?:\u0431\u043B\u0438\u0437\u044C\u043A\u043E|\u043F\u0440\u0438\u0431\u043B\u0438\u0437\u043D\u043E)\\s{0,3})?",Qz)});var Zz,Rw,Jz=b(()=>{ms();Le();fe();Zz=`(?:(?:\u043F\u0440\u0438\u0431\u043B\u0438\u0437\u043D\u043E|\u043E\u0440\u0456\u0454\u043D\u0442\u043E\u0432\u043D\u043E)\\s*(?:~\\s*)?)?(${Jm})${fs.rightBoundary}`,Rw=class extends L{patternLeftBoundary(){return fs.leftBoundary}innerPattern(e){return e.option.forwardDate?new RegExp(Zz,fs.flags):new RegExp(`(?:\u043F\u0440\u043E\u0442\u044F\u0433\u043E\u043C|\u043D\u0430 \u043F\u0440\u043E\u0442\u044F\u0437\u0456|\u043F\u0440\u043E\u0442\u044F\u0433\u043E\u043C|\u0443\u043F\u0440\u043E\u0434\u043E\u0432\u0436|\u0432\u043F\u0440\u043E\u0434\u043E\u0432\u0436)\\s*${Zz}`,fs.flags)}innerExtract(e,t){let n=eh(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var Lp,No,Rc=b(()=>{fe();ms();Lp=class extends L{patternLeftBoundary(){return fs.leftBoundary}innerPattern(e){return new RegExp(this.innerPatternString(e),fs.flags)}innerPatternHasChange(e,t){return!1}},No=class extends Lp{innerPattern(e){return new RegExp(`${this.innerPatternString(e)}${fs.rightBoundary}`,fs.flags)}}});var eH,tH,coe,rH,$w,nH=b(()=>{zt();ms();ms();ms();ze();Rc();eH=1,tH=2,coe=3,rH=4,$w=class extends No{innerPatternString(e){return`(?:\u0437|\u0456\u0437)?\\s*(${jM})(?:\\s{0,3}(?:\u043F\u043E|-|\u2013|\u0434\u043E)?\\s{0,3}(${jM}))?(?:-|\\/|\\s{0,3}(?:of)?\\s{0,3})(${ee(Zm)})(?:(?:-|\\/|,?\\s{0,3})(${bA}(?![^\\s]\\d)))?`}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=Zm[t[coe].toLowerCase()],o=GM(t[eH]);if(o>31)return t.index=t.index+t[eH].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[rH]){let s=wA(t[rH]);n.start.assign("year",s)}else{let s=ft(e.reference.instant,o,i);n.start.imply("year",s)}if(t[tH]){let s=GM(t[tH]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var uoe,iH,Ow,oH=b(()=>{ms();zt();ze();ms();Rc();uoe=2,iH=3,Ow=class extends Lp{innerPatternString(e){return`((?:\u0432|\u0443)\\s*)?(${ee(Zm)})\\s*(?:[,-]?\\s*(${bA})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`}innerExtract(e,t){let n=t[uoe].toLowerCase();if(t[0].length<=3&&!HM[n])return null;let i=e.createParsingResult(t.index,t.index+t[0].length);i.start.imply("day",1);let o=Zm[n];if(i.start.assign("month",o),t[iH]){let s=wA(t[iH]);i.start.assign("year",s)}else{let s=ft(e.reference.instant,1,o);i.start.imply("year",s)}return i}}});var Nw,sH=b(()=>{pt();Ra();ms();Nw=class extends Gr{constructor(e){super(e)}patternFlags(){return fs.flags}primaryPatternLeftBoundary(){return"(^|\\s|T|(?:[^\\p{L}\\p{N}_]))"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|\u0434\u043E|\u0456|\u043F\u043E|\\?)\\s*"}primaryPrefix(){return"(?:(?:\u0432|\u0443|\u043E|\u043E\u0431|\u0437|\u0456\u0437|\u0432\u0456\u0434)\\s*)??"}primarySuffix(){return`(?:\\s*(?:\u0440\u0430\u043D\u043A\u0443|\u0432\u0435\u0447\u043E\u0440\u0430|\u043F\u043E \u043E\u0431\u0456\u0434\u0456|\u043F\u0456\u0441\u043B\u044F \u043E\u0431\u0456\u0434\u0443))?(?!\\/)${fs.rightBoundary}`}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(n){if(t[0].endsWith("\u0432\u0435\u0447\u043E\u0440\u0430")){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",G.PM)):i<6&&n.assign("meridiem",G.AM)}if(t[0].endsWith("\u043F\u043E \u043E\u0431\u0456\u0434\u0456")||t[0].endsWith("\u043F\u0456\u0441\u043B\u044F \u043E\u0431\u0456\u0434\u0443")){n.assign("meridiem",G.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}t[0].endsWith("\u0440\u0430\u043D\u043A\u0443")&&(n.assign("meridiem",G.AM),n.get("hour")<12&&n.assign("hour",n.get("hour")))}return n}}});var Lw,aH=b(()=>{ms();Le();Rc();Bt();Lw=class extends Lp{innerPatternString(e){return`(${Jm})\\s{0,5}\u0442\u043E\u043C\u0443(?=(?:\\W|$))`}innerExtract(e,t){let n=eh(t[1]),i=tt(n);return Q.createRelativeFromReference(e.reference,i)}}});var Bw,lH=b(()=>{go();Bw=class extends Yt{patternBetween(){return/^\s*(і до|і по|до|по|-)\s*$/i}}});var Uw,cH=b(()=>{vo();Uw=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|\u0432|\u0443|\u043E|,|-)?\\s*$")}}});var Vw,uH=b(()=>{oi();Rc();Vw=class extends No{innerPatternString(e){return"(?:\u0437|\u0456\u0437|\u0432\u0456\u0434)?\\s*(\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456|\u0432\u0447\u043E\u0440\u0430|\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u0456\u0441\u043B\u044F\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430|\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430|\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430)"}innerExtract(e,t){let n=t[1].toLowerCase(),i=e.createParsingComponents();switch(n){case"\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456":return Tr(e.reference);case"\u0432\u0447\u043E\u0440\u0430":return gn(e.reference);case"\u0437\u0430\u0432\u0442\u0440\u0430":return vn(e.reference);case"\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430":return Mo(e.reference,2);case"\u043F\u0456\u0441\u043B\u044F\u043F\u0456\u0441\u043B\u044F\u0437\u0430\u0432\u0442\u0440\u0430":return Mo(e.reference,3);case"\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430":return Sc(e.reference,2);case"\u043F\u043E\u0437\u0430\u043F\u043E\u0437\u0430\u0432\u0447\u043E\u0440\u0430":return Sc(e.reference,3)}return i}}});var qw,dH=b(()=>{oi();nn();Rc();qw=class extends No{innerPatternString(e){return"(\u0437\u0430\u0440\u0430\u0437|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E\\s*\u0432\u0435\u0447\u043E\u0440\u0430|\u043C\u0438\u043D\u0443\u043B\u043E\u0457\\s*\u043D\u043E\u0447\u0456|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0457\\s*\u043D\u043E\u0447\u0456|\u0441\u044C\u043E\u0433\u043E\u0434\u043D\u0456\\s*\u0432\u043D\u043E\u0447\u0456|\u0446\u0456\u0454\u0457\\s*\u043D\u043E\u0447\u0456|\u0446\u044C\u043E\u0433\u043E \u0440\u0430\u043D\u043A\u0443|\u0432\u0440\u0430\u043D\u0446\u0456|\u0440\u0430\u043D\u043A\u0443|\u0437\u0440\u0430\u043D\u043A\u0443|\u043E\u043F\u0456\u0432\u0434\u043D\u0456|\u0432\u0432\u0435\u0447\u0435\u0440\u0456|\u0432\u0435\u0447\u043E\u0440\u0430|\u043E\u043F\u0456\u0432\u043D\u043E\u0447\u0456|\u0432\u043D\u043E\u0447\u0456)"}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();if(i==="\u0437\u0430\u0440\u0430\u0437")return $r(e.reference);if(i==="\u0432\u0432\u0435\u0447\u0435\u0440\u0456"||i==="\u0432\u0435\u0447\u043E\u0440\u0430")return Dc(e.reference);if(i.endsWith("\u0432\u0440\u0430\u043D\u0446\u0456")||i.endsWith("\u0440\u0430\u043D\u043A\u0443")||i.endsWith("\u0437\u0440\u0430\u043D\u043A\u0443"))return Pc(e.reference);if(i.endsWith("\u043E\u043F\u0456\u0432\u0434\u043D\u0456"))return qu(e.reference);if(i.match(/минулої\s*ночі/))return Q_(e.reference);if(i.match(/минулого\s*вечора/))return Z_(e.reference);if(i.match(/наступної\s*ночі/)){let s=n.getHours()<22?1:2,a=new Date(n.getTime());a.setDate(a.getDate()+s),nt(o,a),o.imply("hour",1)}return i.match(/цієї\s*ночі/)?Ic(e.reference):i.endsWith("\u043E\u043F\u0456\u0432\u043D\u043E\u0447\u0456")||i.endsWith("\u0432\u043D\u043E\u0447\u0456")?Ic(e.reference):o}}});var doe,poe,foe,Ww,pH=b(()=>{ms();ze();Ki();Rc();doe=1,poe=2,foe=3,Ww=class extends No{innerPatternString(e){return`(?:(?:,|\\(|\uFF08)\\s*)?(?:\u0432\\s*?)?(?:\u0443\\s*?)?(?:(\u0446\u0435\u0439|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E|\u043C\u0438\u043D\u0443\u043B\u0438\u0439|\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439|\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044C\u043E\u0433\u043E|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443)\\s*)?(${ee(zM)})(?:\\s*(?:,|\\)|\uFF09))?(?:\\s*(\u043D\u0430|\u0443|\u0432)\\s*(\u0446\u044C\u043E\u043C\u0443|\u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443)\\s*\u0442\u0438\u0436\u043D\u0456)?`}innerExtract(e,t){let n=t[poe].toLocaleLowerCase(),i=zM[n],o=t[doe],s=t[foe],a=o||s;a=a||"",a=a.toLocaleLowerCase();let l=null;return a=="\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E"||a=="\u043C\u0438\u043D\u0443\u043B\u0438\u0439"||a=="\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u0456\u0439"||a=="\u043F\u043E\u043F\u0435\u0440\u0435\u0434\u043D\u044C\u043E\u0433\u043E"?l="last":a=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E"||a=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0438\u0439"?l="next":(a=="\u0446\u0435\u0439"||a=="\u0446\u044C\u043E\u0433\u043E"||a=="\u0446\u044C\u043E\u043C\u0443")&&(l="this"),cr(e.reference,i,l)}}});var moe,hoe,zw,fH=b(()=>{ms();Le();ze();Rc();moe=1,hoe=2,zw=class extends No{innerPatternString(e){return`(\u0432 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u0443 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043D\u0430 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443|\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E|\u043D\u0430 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u0432 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u0443 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E|\u043D\u0430 \u0446\u044C\u043E\u043C\u0443|\u0432 \u0446\u044C\u043E\u043C\u0443|\u0443 \u0446\u044C\u043E\u043C\u0443|\u0446\u044C\u043E\u0433\u043E)\\s*(${ee(Mw)})(?=\\s*)`}innerExtract(e,t){let n=t[moe].toLowerCase(),i=t[hoe].toLowerCase(),o=Mw[i];if(n=="\u043D\u0430 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u0432 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u0443 \u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u043C\u0443"||n=="\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u043E\u0433\u043E"){let l={};return l[o]=1,Q.createRelativeFromReference(e.reference,l)}if(n=="\u043D\u0430 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u0432 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u0443 \u043C\u0438\u043D\u0443\u043B\u043E\u043C\u0443"||n=="\u043C\u0438\u043D\u0443\u043B\u043E\u0433\u043E"){let l={};return l[o]=-1,Q.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return o.match(/week/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):o.match(/month/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):o.match(/year/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var Hw,mH=b(()=>{ms();Le();Rc();Bt();Hw=class extends No{innerPatternString(e){return`(\u0446\u0456|\u043E\u0441\u0442\u0430\u043D\u043D\u0456|\u043C\u0438\u043D\u0443\u043B\u0456|\u043C\u0430\u0439\u0431\u0443\u0442\u043D\u0456|\u043D\u0430\u0441\u0442\u0443\u043F\u043D\u0456|\u043F\u0456\u0441\u043B\u044F|\u0447\u0435\u0440\u0435\u0437|\\+|-)\\s*(${Jm})`}innerExtract(e,t){let n=t[1].toLowerCase(),i=eh(t[3]);switch(n){case"\u043E\u0441\u0442\u0430\u043D\u043D\u0456":case"\u043C\u0438\u043D\u0443\u043B\u0456":case"-":i=tt(i);break}return Q.createRelativeFromReference(e.reference,i)}}});var XM={};Zr(XM,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>YM,createCasualConfiguration:()=>hH,createConfiguration:()=>KM,parse:()=>voe,parseDate:()=>yoe,strict:()=>goe});function hH(){let r=KM(!1);return r.parsers.unshift(new Vw),r.parsers.unshift(new qw),r.parsers.unshift(new Ow),r.parsers.unshift(new zw),r.parsers.unshift(new Hw),r}function KM(r){return Ht({parsers:[new yo,new vr(!0),new Rw,new $w,new Ww,new Nw(r),new Lw],refiners:[new Uw,new Bw]},r)}function voe(r,e,t){return YM.parse(r,e,t)}function yoe(r,e,t){return YM.parseDate(r,e,t)}var YM,goe,gH=b(()=>{Jz();nH();oH();sH();aH();lH();cH();xi();uH();dH();pH();fH();si();Le();pt();cs();mH();bp();YM=new Se(hH()),goe=new Se(KM(!0))});function boe(r){let e=r.toLowerCase();return QM[e]!==void 0?QM[e]:e==="un"||e==="un'"||e==="una"||e==="uno"?1:e.match(/qualche/)?3:e.match(/mezz/)?.5:e.match(/paio/)?2:e.match(/alcuni/)?7:parseFloat(e)}function nh(r){let e=r.toLowerCase();return ZM[e]!==void 0?ZM[e]:(e=e.replace(/(?:°|ª|º)$/i,""),parseInt(e))}function ju(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 jr(e)}function Zs(r){let e={},t=r,n=vH.exec(t);for(;n;)Coe(e,n),t=t.substring(n[0].length).trim(),n=vH.exec(t);return Object.keys(e).length==0?null:e}function Coe(r,e){if(e[0].match(/^[a-zA-Z]+$/))return;let t=boe(e[1]),n=th[e[2].toLowerCase()];r[n]=t}var CA,JM,Qs,QM,ZM,yH,th,bH,rh,Hu,wH,vH,woe,CH,$c,Gu,Vn=b(()=>{ze();zt();CA={domenica:0,dom:0,"dom.":0,luned\u00EC:1,lunedi:1,lun:1,"lun.":1,marted\u00EC:2,martedi:2,mar:2,"mar.":2,mercoled\u00EC:3,mercoledi:3,mer:3,"mer.":3,gioved\u00EC:4,giovedi:4,gio:4,"gio.":4,venerd\u00EC:5,venerdi:5,ven:5,"ven.":5,sabato:6,sab:6,"sab.":6},JM={gennaio:1,febbraio:2,marzo:3,aprile:4,maggio:5,giugno:6,luglio:7,agosto:8,settembre:9,ottobre:10,novembre:11,dicembre:12},Qs={...JM,gen:1,"gen.":1,feb:2,"feb.":2,mar:3,"mar.":3,apr:4,"apr.":4,mag:5,"mag.":5,giu:6,"giu.":6,lug:7,"lug.":7,ago:8,"ago.":8,set:9,"set.":9,sett:9,"sett.":9,ott:10,"ott.":10,nov:11,"nov.":11,dic:12,"dic.":12},QM={uno:1,una:1,un:1,due:2,tre:3,quattro:4,cinque:5,sei:6,sette:7,otto:8,nove:9,dieci:10,undici:11,dodici:12},ZM={primo:1,prima:1,"1\xB0":1,"1\xAA":1,secondo:2,seconda:2,"2\xB0":2,"2\xAA":2,terzo:3,terza:3,"3\xB0":3,"3\xAA":3,quarto:4,quarta:4,"4\xB0":4,"4\xAA":4,quinto:5,quinta:5,"5\xB0":5,"5\xAA":5,sesto:6,sesta:6,"6\xB0":6,"6\xAA":6,settimo:7,settima:7,"7\xB0":7,"7\xAA":7,ottavo:8,ottava:8,"8\xB0":8,"8\xAA":8,nono:9,nona:9,"9\xB0":9,"9\xAA":9,decimo:10,decima:10,"10\xB0":10,"10\xAA":10,undicesimo:11,undicesima:11,"11\xB0":11,"11\xAA":11,dodicesimo:12,dodicesima:12,"12\xB0":12,"12\xAA":12,tredicesimo:13,tredicesima:13,"13\xB0":13,"13\xAA":13,quattordicesimo:14,quattordicesima:14,"14\xB0":14,"14\xAA":14,quindicesimo:15,quindicesima:15,"15\xB0":15,"15\xAA":15,sedicesimo:16,sedicesima:16,"16\xB0":16,"16\xAA":16,diciassettesimo:17,diciassettesima:17,"17\xB0":17,"17\xAA":17,diciottesimo:18,diciottesima:18,"18\xB0":18,"18\xAA":18,diciannovesimo:19,diciannovesima:19,"19\xB0":19,"19\xAA":19,ventesimo:20,ventesima:20,"20\xB0":20,"20\xAA":20,ventunesimo:21,ventunesima:21,"21\xB0":21,"21\xAA":21,ventiduesimo:22,ventiduesima:22,"22\xB0":22,"22\xAA":22,ventitreesimo:23,ventitreesima:23,"23\xB0":23,"23\xAA":23,ventiquattresimo:24,ventiquattresima:24,"24\xB0":24,"24\xAA":24,venticinquesimo:25,venticinquesima:25,"25\xB0":25,"25\xAA":25,ventiseiesimo:26,ventiseiesima:26,"26\xB0":26,"26\xAA":26,ventisettesimo:27,ventisettesima:27,"27\xB0":27,"27\xAA":27,ventottesimo:28,ventottesima:28,"28\xB0":28,"28\xAA":28,ventinovesimo:29,ventinovesima:29,"29\xB0":29,"29\xAA":29,trentesimo:30,trentesima:30,"30\xB0":30,"30\xAA":30,trentunesimo:31,trentunesima:31,"31\xB0":31,"31\xAA":31},yH={secondo:"second",secondi:"second",minuto:"minute",minuti:"minute",ora:"hour",ore:"hour",giorno:"day",giorni:"day",settimana:"week",settimane:"week",mese:"month",mesi:"month",trimestre:"quarter",trimestri:"quarter",anno:"year",anni:"year"},th={s:"second",sec:"second",secondo:"second",secondi:"second",m:"minute",min:"minute",minuto:"minute",minuti:"minute",h:"hour",ora:"hour",ore:"hour",g:"day",gg:"day",giorno:"day",giorni:"day",sett:"week",settimana:"week",settimane:"week",mese:"month",mesi:"month",trim:"quarter",trimestre:"quarter",trimestri:"quarter",anno:"year",anni:"year",...yH},bH=`(?:${ee(QM)}|[0-9]+|[0-9]+\\.[0-9]+|mezz[oa]?(?:\\s{0,2})?|un(?:'|\\s{0,2})?|qualche|alcuni|paio\\s{0,2}(?:di)?)`;rh=`(?:${ee(ZM)}|[0-9]{1,2}(?:\xB0|\xAA|\xBA)?)`;Hu="(?:[1-9][0-9]{0,3}\\s{0,2}(?:BE|AD|BC|BCE|CE)|[1-2][0-9]{3}|[5-9][0-9]|2[0-5])";wH=`(${bH})\\s{0,3}(${ee(th)})`,vH=new RegExp(wH,"i"),woe=`(${bH})\\s{0,3}(${ee(yH)})`,CH="\\s{0,5},?(?:\\s*e)?\\s{0,5}",$c=Er("(?:(?:circa|approssimativamente)\\s{0,3})?",wH,CH),Gu=Er("(?:(?:circa|approssimativamente)\\s{0,3})?",woe,CH)});var xoe,Eoe,Toe,jw,xH=b(()=>{Vn();Le();fe();xoe=new RegExp(`(?:(?:entro|tra|fra|in|per)\\s*)?(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${$c})(?=\\W|$)`,"i"),Eoe=new RegExp(`(?:entro|tra|fra|in|per)\\s*(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${$c})(?=\\W|$)`,"i"),Toe=new RegExp(`(?:entro|tra|fra|in|per)\\s*(?:(?:circa|approssimativamente)\\s*(?:~\\s*)?)?(${Gu})(?=\\W|$)`,"i"),jw=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(t){return this.strictMode?Toe:t.option.forwardDate?xoe:Eoe}innerExtract(t,n){if(n[0].match(/^per\s*(il|la|l')\s*\w+/))return null;let i=Zs(n[1]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var _oe,EH,TH,Aoe,_H,Gw,AH=b(()=>{zt();Vn();Vn();Vn();ze();fe();_oe=new RegExp(`(?:il\\s{0,3})?(${rh})(?:\\s{0,3}(?:al|\\-|\\\u2013|fino\\s*al?)?\\s{0,3}(${rh}))?(?:-|/|\\s{0,3}(?:di)?\\s{0,3})(${ee(Qs)})(?:(?:-|/|,?\\s{0,3})(${Hu}(?!\\w)))?(?=\\W|$)`,"i"),EH=1,TH=2,Aoe=3,_H=4,Gw=class extends L{innerPattern(){return _oe}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=Qs[t[Aoe].toLowerCase()],o=nh(t[EH]);if(o>31)return t.index=t.index+t[EH].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[_H]){let s=ju(t[_H]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[TH]){let s=nh(t[TH]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var koe,Soe,kH,eR,tR,Yw,SH=b(()=>{zt();Vn();Vn();Vn();ze();fe();koe=new RegExp(`(${ee(Qs)})(?:-|/|\\s*,?\\s*)(${rh})(?!\\s*(?:am|pm))\\s*(?:(?:al|\\-)\\s*(${rh})\\s*)?(?:(?:-|/|\\s*,\\s*|\\s+)(${Hu}))?(?=\\W|$)(?!\\:\\d)`,"i"),Soe=1,kH=2,eR=3,tR=4,Yw=class extends L{constructor(t){super();le(this,"shouldSkipYearLikeDate");this.shouldSkipYearLikeDate=t}innerPattern(){return koe}innerExtract(t,n){let i=Qs[n[Soe].toLowerCase()],o=nh(n[kH]);if(o>31||this.shouldSkipYearLikeDate&&!n[eR]&&!n[tR]&&n[kH].match(/^2[0-5]$/))return null;let s=t.createParsingComponents({day:o,month:i}).addTag("parser/ITMonthNameMiddleEndianParser");if(n[tR]){let c=ju(n[tR]);s.assign("year",c)}else{let c=ft(t.refDate,o,i);s.imply("year",c)}if(!n[eR])return s;let a=nh(n[eR]),l=t.createParsingResult(n.index,n[0]);return l.start=s,l.end=s.clone(),l.end.assign("day",a),l}}});var Doe,Ioe,Poe,DH,Kw,IH=b(()=>{Vn();zt();ze();Vn();fe();Doe=new RegExp(`((?:a|in|di|del)\\s*)?(${ee(Qs)})\\s*(?:(?:,|-|del)?\\s*(${Hu})?)?(?=[^\\s\\w]|\\s+[^0-9]|\\s+$|$)`,"i"),Ioe=1,Poe=2,DH=3,Kw=class extends L{innerPattern(){return Doe}innerExtract(e,t){let n=t[Poe].toLowerCase();if(t[0].length<=3&&!JM[n])return null;let i=e.createParsingResult(t.index+(t[Ioe]||"").length,t.index+t[0].length);i.start.imply("day",1),i.start.addTag("parser/ITMonthNameParser");let o=Qs[n];if(i.start.assign("month",o),t[DH]){let s=ju(t[DH]);i.start.assign("year",s)}else{let s=ft(e.refDate,1,o);i.start.imply("year",s)}return i}}});var Foe,Moe,Roe,PH,$oe,Xw,FH=b(()=>{Vn();ze();fe();Foe=new RegExp(`([0-9]{4})[-\\.\\/\\s](?:(${ee(Qs)})|([0-9]{1,2}))[-\\.\\/\\s]([0-9]{1,2})(?=\\W|$)`,"i"),Moe=1,Roe=2,PH=3,$oe=4,Xw=class extends L{constructor(t){super();le(this,"strictMonthDateOrder");this.strictMonthDateOrder=t}innerPattern(){return Foe}innerExtract(t,n){let i=parseInt(n[Moe]),o=parseInt(n[$oe]),s=n[PH]?parseInt(n[PH]):Qs[n[Roe].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 Ooe,Noe,Loe,Qw,MH=b(()=>{fe();Ooe=new RegExp("([0-9]|0[1-9]|1[012])/([0-9]{4})","i"),Noe=1,Loe=2,Qw=class extends L{innerPattern(){return Ooe}innerExtract(e,t){let n=parseInt(t[Loe]),i=parseInt(t[Noe]);return e.createParsingComponents().imply("day",1).assign("month",i).assign("year",n)}}});var Zw,RH=b(()=>{pt();Ra();Zw=class extends Gr{constructor(e){super(e)}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C|a|fino\\s*a|alle?|\\?)\\s*"}primaryPrefix(){return"(?:(?:alle?|dalle?)\\s*)??"}primarySuffix(){return"(?:\\s*(?:di\\s*(?:sera|notte|mattina|pomeriggio)))?(?!/)(?=\\W|$)"}extractPrimaryTimeComponents(e,t){let n=super.extractPrimaryTimeComponents(e,t);if(!n)return n;if(t[0].match(/di\s*(?:sera|notte)/i)){let i=n.get("hour");i>=6&&i<12?(n.assign("hour",n.get("hour")+12),n.assign("meridiem",G.PM)):i<6&&n.assign("meridiem",G.AM)}if(t[0].match(/di\s*pomeriggio/i)){n.assign("meridiem",G.PM);let i=n.get("hour");i>=0&&i<=6&&n.assign("hour",n.get("hour")+12)}return t[0].match(/di\s*mattina/i)&&(n.assign("meridiem",G.AM),n.get("hour")<12&&n.assign("hour",n.get("hour"))),n.addTag("parser/ITTimeExpressionParser")}extractFollowingTimeComponents(e,t,n){let i=super.extractFollowingTimeComponents(e,t,n);return i&&i.addTag("parser/ITTimeExpressionParser"),i}}});var Boe,Uoe,Jw,$H=b(()=>{Vn();Le();fe();Bt();Boe=new RegExp(`(${$c})\\s{0,5}(?:fa|prima)(?=\\W|$)`,"i"),Uoe=new RegExp(`(${Gu})\\s{0,5}(?:fa|prima)(?=\\W|$)`,"i"),Jw=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?Uoe:Boe}innerExtract(t,n){let i=Zs(n[1]);return i?Q.createRelativeFromReference(t.reference,tt(i)):null}}});var Voe,qoe,Woe,eC,OH=b(()=>{Vn();Le();fe();Voe=new RegExp(`(${$c})\\s{0,5}(?:dopo|pi\xF9\\s*tardi|da\\s*adesso|da\\s*ora)(?=(?:\\W|$))`,"i"),qoe=new RegExp(`(${Gu})\\s{0,5}(dopo|pi\xF9\\s*tardi|da\\s*adesso|da\\s*ora)(?=\\W|$)`,"i"),Woe=1,eC=class extends L{constructor(t){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return this.strictMode?qoe:Voe}innerExtract(t,n){let i=Zs(n[Woe]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var tC,NH=b(()=>{go();tC=class extends Yt{patternBetween(){return/^\s*(a|al|-|–|fino\s*a|fino\s*al)\s*$/i}}});var ih,LH=b(()=>{vo();ih=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|alle?|dopo\\s*le|prima\\s*delle?|,|-|\\.|\u2219|:)?\\s*$")}}});var zoe,rC,BH=b(()=>{fe();nn();oi();zoe=/(adesso|ora|oggi|stasera|stanotte|domani|dopodomani|ieri|ieri\s*sera|ieri\s*notte)(?=\W|$)/i,rC=class extends L{innerPattern(e){return zoe}innerExtract(e,t){let n=e.refDate,i=t[0].toLowerCase(),o=e.createParsingComponents();switch(i){case"adesso":case"ora":o=$r(e.reference);break;case"oggi":o=Tr(e.reference);break;case"ieri":o=gn(e.reference);break;case"domani":o=vn(e.reference);break;case"stasera":case"stanotte":o=X_(e.reference);break;case"dopodomani":o=Mo(e.reference,2);break;default:if(i.match(/ieri\s*sera/)||i.match(/ieri\s*notte/)){if(n.getHours()>6){let s=new Date(n.getTime());s.setDate(s.getDate()-1),n=s}nt(o,n),o.imply("hour",0)}break}return o.addTag("parser/ITCasualDateParser"),o}}});var Hoe,nC,UH=b(()=>{fe();oi();Hoe=/(stamattina|stasera|stanotte|stamani)|(questa\s*)?(mattina|pomeriggio|sera|notte|mezzanotte|mezzogiorno)(?=\W|$)/i,nC=class extends L{innerPattern(){return Hoe}innerExtract(e,t){let n=null;if(t[1])switch(t[1].toLowerCase()){case"stamattina":case"stamani":n=Pc(e.reference);break;case"stasera":case"stanotte":n=Dc(e.reference);break}else if(t[3])switch(t[3].toLowerCase()){case"pomeriggio":n=J_(e.reference);break;case"sera":case"notte":n=Dc(e.reference);break;case"mezzanotte":n=Ic(e.reference);break;case"mattina":n=Pc(e.reference);break;case"mezzogiorno":n=qu(e.reference);break}return n&&n.addTag("parser/ITCasualTimeParser"),n}}});var joe,Goe,Yoe,Koe,iC,VH=b(()=>{Vn();ze();fe();Ki();pt();joe=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(questo|questa|quest'|scorso|scorsa|prossimo|prossima)\\s*)?(${ee(CA)}|weekend|fine\\s*settimana)(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(scorso|scorsa|prossimo|prossima)(?:\\s*settimana)?)?(?=\\W|$)`,"i"),Goe=1,Yoe=2,Koe=3,iC=class extends L{innerPattern(){return joe}innerExtract(e,t){let n=t[Goe],i=t[Koe],o=n||i;o=o||"",o=o.toLowerCase();let s=null;o=="scorso"||o=="scorsa"?s="last":o=="prossimo"||o=="prossima"?s="next":(o=="questo"||o=="questa"||o=="quest'")&&(s="this");let a=t[Yoe].toLowerCase(),l;if(CA[a]!==void 0)l=CA[a];else if(a=="weekend"||a.match(/fine\s*settimana/))l=s=="last"?Oe.SUNDAY:Oe.SATURDAY;else return null;return cr(e.reference,l,s)}}});var Xoe,qH,Qoe,Zoe,Joe,oC,WH=b(()=>{Vn();Le();fe();ze();Xoe=new RegExp(`(?:(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo\\s*questo|dopo\\s*questa)\\s*(${ee(th)})|(?:il\\s*|la\\s*|l'\\s*)(${ee(th)})\\s*(scorso|scorsa|prossimo|prossima))(?=\\W|$)`,"i"),qH=1,Qoe=2,Zoe=3,Joe=4,oC=class extends L{innerPattern(){return Xoe}innerExtract(e,t){let n,i;t[qH]?(n=t[qH].toLowerCase(),i=t[Qoe].toLowerCase()):(n=t[Joe].toLowerCase(),i=t[Zoe].toLowerCase());let o=th[i];if(n=="prossimo"||n=="prossima"||n.startsWith("dopo")){let l={};return l[o]=1,Q.createRelativeFromReference(e.reference,l)}if(n=="scorso"||n=="scorsa"){let l={};return l[o]=-1,Q.createRelativeFromReference(e.reference,l)}let s=e.createParsingComponents(),a=new Date(e.reference.instant.getTime());return i.match(/settimana/i)?(a.setDate(a.getDate()-a.getDay()),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.imply("year",a.getFullYear())):i.match(/mese/i)?(a.setDate(1),s.imply("day",a.getDate()),s.assign("year",a.getFullYear()),s.assign("month",a.getMonth()+1)):i.match(/anno/i)&&(a.setDate(1),a.setMonth(0),s.imply("day",a.getDate()),s.imply("month",a.getMonth()+1),s.assign("year",a.getFullYear())),s}}});var ese,tse,sC,zH=b(()=>{Vn();Le();fe();Bt();ese=new RegExp(`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${$c})(?=\\W|$)`,"i"),tse=new RegExp(`(?:il\\s*|la\\s*|l'\\s*)?(questo|questa|quest'|scorso|scorsa|prossimo|prossima|dopo|\\+|-)\\s*(${Gu})(?=\\W|$)`,"i"),sC=class extends L{constructor(t=!0){super();le(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?ese:tse}innerExtract(t,n){let i=n[1].toLowerCase(),o=Zs(n[2]);if(!o)return null;switch(i){case"scorso":case"scorsa":case"-":o=tt(o);break}return Q.createRelativeFromReference(t.reference,o)}}});function rse(r){return r.text.match(/^[+-]/i)!=null}function HH(r){return r.text.match(/^-/i)!=null}var aC,jH=b(()=>{Gs();Le();Vn();Bt();aC=class extends ii{shouldMergeResults(e,t,n){return e.match(/^\s*$/i)?rse(n)||HH(n):!1}mergeResults(e,t,n,i){let o=Zs(n.text);HH(n)&&(o=tt(o));let s=Q.createRelativeFromReference(ct.fromDate(t.start.date()),o);return new at(t.reference,t.index,`${t.text}${e}${n.text}`,s)}}});function GH(r){return r.text.match(/\s+(prima|da)$/i)!=null}function nse(r){return r.text.match(/\s+(dopo|dal?)$/i)!=null}var lC,YH=b(()=>{Gs();Le();Vn();Bt();lC=class extends ii{patternBetween(){return/^\s*$/i}shouldMergeResults(e,t,n){return!e.match(this.patternBetween())||!GH(t)&&!nse(t)?!1:!!n.start.get("day")&&!!n.start.get("month")&&!!n.start.get("year")}mergeResults(e,t,n){let i=Zs(t.text);GH(t)&&(i=tt(i));let o=Q.createRelativeFromReference(ct.fromDate(n.start.date()),i);return new at(n.reference,t.index,`${t.text}${e}${n.text}`,o)}}});var ise,ose,cC,KH=b(()=>{Vn();ise=new RegExp(`^\\s*(${Hu})`,"i"),ose=1,cC=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=ise.exec(i);if(!o||o[0].trim().length<=3)return;e.debug(()=>{console.log(`Extracting year: '${o[0]}' into : ${n}`)});let s=ju(o[ose]);n.end!=null&&n.end.assign("year",s),n.start.assign("year",s),n.text+=o[0]}),t}}});var uC,XH=b(()=>{Gs();uC=class extends Vu{constructor(){super()}isValid(e,t){let n=t.text.trim();return n===e.text.trim()?!0:n.toLowerCase().endsWith("il secondo")||n.toLowerCase()==="secondo"?(e.text.substring(t.index+t.text.length).trim().length>0&&e.debug(()=>{console.log(`Removing unlikely result: ${t}`)}),!1):!0}}});var dC,QH=b(()=>{xH();AH();SH();IH();FH();MH();RH();$H();OH();NH();LH();xi();BH();UH();VH();WH();cs();zH();jH();YH();Y_();KH();XH();dC=class{createCasualConfiguration(){let e=this.createConfiguration(!1);return e.parsers.push(new rC),e.parsers.push(new nC),e.parsers.push(new Kw),e.parsers.push(new oC),e.parsers.push(new sC),e.refiners.push(new uC),e}createConfiguration(e=!0){let t=Ht({parsers:[new vr(!0),new jw(e),new Gw,new Yw(!0),new iC,new Qw,new Zw(e),new Jw(e),new eC(e)],refiners:[new ih]},e);return t.parsers.unshift(new Xw(e)),t.refiners.unshift(new lC),t.refiners.unshift(new aC),t.refiners.unshift(new wl),t.refiners.push(new ih),t.refiners.push(new cC),t.refiners.push(new tC),t}}});var iR={};Zr(iR,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>nR,configuration:()=>rR,parse:()=>ase,parseDate:()=>lse,strict:()=>sse});function ase(r,e,t){return nR.parse(r,e,t)}function lse(r,e,t){return nR.parseDate(r,e,t)}var rR,nR,sse,ZH=b(()=>{si();Le();pt();QH();rR=new dC,nR=new Se(rR.createCasualConfiguration()),sse=new Se(rR.createConfiguration(!0))});function e6(r){let e={},t=r,n=JH.exec(t);for(;n;)dse(e,n),t=t.substring(n[0].length),n=JH.exec(t);return e}function dse(r,e){let t=fse(e[1]),n=aR[e[2].toLowerCase()];r[n]=t}function fse(r){let e=r.toLowerCase();return pC[e]!==void 0?pC[e]:parseInt(e)}function o6(r){if(/\d+/.test(r)){let t=parseInt(r);return t<100&&(t=jr(t)),t}let e=r.toLowerCase();return pC[e]!==void 0?pC[e]:parseInt(r)}var oR,sR,cse,pC,aR,use,t6,pXe,fXe,r6,JH,pse,n6,i6,fC=b(()=>{ze();zt();oR={s\u00F6ndag:0,s\u00F6n:0,so:0,m\u00E5ndag:1,m\u00E5n:1,m\u00E5:1,tisdag:2,tis:2,ti:2,onsdag:3,ons:3,on:3,torsdag:4,tors:4,to:4,fredag:5,fre:5,fr:5,l\u00F6rdag:6,l\u00F6r:6,l\u00F6:6},sR={januari:1,jan:1,"jan.":1,februari:2,feb:2,"feb.":2,mars:3,mar:3,"mar.":3,april:4,apr:4,"apr.":4,maj:5,juni:6,jun:6,"jun.":6,juli:7,jul:7,"jul.":7,augusti:8,aug:8,"aug.":8,september:9,sep:9,"sep.":9,sept:9,oktober:10,okt:10,"okt.":10,november:11,nov:11,"nov.":11,december:12,dec:12,"dec.":12},cse={f\u00F6rsta:1,andra:2,tredje:3,fj\u00E4rde:4,femte:5,sj\u00E4tte:6,sjunde:7,\u00E5ttonde:8,nionde:9,tionde:10,elfte:11,tolfte:12,trettonde:13,fjortonde:14,femtonde:15,sextonde:16,sjuttonde:17,artonde:18,nittonde:19,tjugonde:20,tjugof\u00F6rsta:21,tjugoandra:22,tjugotredje:23,tjugofj\u00E4rde:24,tjugofemte:25,tjugosj\u00E4tte:26,tjugosjunde:27,tjugo\u00E5ttonde:28,tjugonionde:29,trettionde:30,trettiof\u00F6rsta:31},pC={en:1,ett:1,tv\u00E5:2,tre:3,fyra:4,fem:5,sex:6,sju:7,\u00E5tta:8,nio:9,tio:10,elva:11,tolv:12,tretton:13,fjorton:14,femton:15,sexton:16,sjutton:17,arton:18,nitton:19,tjugo:20,tretti\u043E:30,fyrtio:40,femtio:50,sextio:60,sjuttio:70,\u00E5ttio:80,nittio:90,hundra:100,tusen:1e3},aR={sek:"second",sekund:"second",sekunder:"second",min:"minute",minut:"minute",minuter:"minute",tim:"hour",timme:"hour",timmar:"hour",dag:"day",dagar:"day",vecka:"week",veckor:"week",m\u00E5n:"month",m\u00E5nad:"month",m\u00E5nader:"month",\u00E5r:"year",kvart\u0430l:"quarter",kvartal:"quarter"},use={sekund:"second",sekunder:"second",minut:"minute",minuter:"minute",timme:"hour",timmar:"hour",dag:"day",dagar:"day",vecka:"week",veckor:"week",m\u00E5nad:"month",m\u00E5nader:"month",\u00E5r:"year",kvartal:"quarter"};t6=`(?:${ee(pC)}|\\d+)`,pXe=`(?:${ee(cse)}|\\d{1,2}(?:e|:e))`,fXe=`(?:${ee(aR)})`,r6=`(${t6})\\s{0,5}(${ee(aR)})\\s{0,5}`,JH=new RegExp(r6,"i"),pse=`(${t6})\\s{0,5}(${ee(use)})\\s{0,5}`,n6=Er("",r6),i6=Er("",pse)});var mse,hse,gse,vse,mC,s6=b(()=>{fC();ze();fe();Ki();mse=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:p\xE5\\s*?)?(?:(f\xF6rra|senaste|n\xE4sta|kommande)\\s*)?(${ee(oR)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(f\xF6rra|senaste|n\xE4sta|kommande)\\s*vecka)?(?=\\W|$)`,"i"),hse=1,gse=3,vse=2,mC=class extends L{innerPattern(){return mse}innerExtract(e,t){let n=t[vse].toLowerCase(),i=oR[n],o=t[hse],s=t[gse],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/förra|senaste/)?l="last":a.match(/nästa|kommande/)&&(l="next"),cr(e.reference,i,l)}}});var yse,a6,l6,bse,c6,hC,u6=b(()=>{zt();fC();fC();ze();fe();yse=new RegExp(`(?:den\\s*?)?([0-9]{1,2})(?:\\s*(?:till|\\-|\\\u2013|\\s)\\s*([0-9]{1,2}))?\\s*(${ee(sR)})(?:(?:-|/|,?\\s*)([0-9]{4}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),a6=1,l6=2,bse=3,c6=4,hC=class extends L{innerPattern(){return yse}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=sR[t[bse].toLowerCase()],o=parseInt(t[a6]);if(o>31)return t.index=t.index+t[a6].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[c6]){let s=o6(t[c6]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[l6]){let s=parseInt(t[l6]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var wse,Cse,gC,d6=b(()=>{fC();Le();fe();Bt();wse=new RegExp(`(denna|den h\xE4r|f\xF6rra|passerade|n\xE4sta|kommande|efter|\\+|-)\\s*(${n6})(?=\\W|$)`,"i"),Cse=new RegExp(`(denna|den h\xE4r|f\xF6rra|passerade|n\xE4sta|kommande|efter|\\+|-)\\s*(${i6})(?=\\W|$)`,"i"),gC=class extends L{constructor(t=!0){super();le(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?wse:Cse}innerExtract(t,n){let i=n[1].toLowerCase(),o=e6(n[2]);if(!o)return null;switch(i){case"f\xF6rra":case"passerade":case"-":o=tt(o);break}return Q.createRelativeFromReference(t.reference,o)}}});var xse,Ese,Tse,vC,p6=b(()=>{fe();nn();oi();xse=new RegExp("(nu|idag|imorgon|\xF6vermorgon|ig\xE5r|f\xF6rrg\xE5r|i\\s*f\xF6rrg\xE5r)(?:\\s*(?:p\xE5\\s*)?(morgonen?|f\xF6rmiddagen?|middagen?|eftermiddagen?|kv\xE4llen?|natten?|midnatt))?(?=\\W|$)","i"),Ese=1,Tse=2,vC=class extends L{innerPattern(e){return xse}innerExtract(e,t){let n=e.refDate,i=(t[Ese]||"").toLowerCase(),o=(t[Tse]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"nu":s=$r(e.reference);break;case"idag":s=Tr(e.reference);break;case"imorgon":case"imorn":let a=new Date(n.getTime());a.setDate(a.getDate()+1),nt(s,a),Lt(s,a);break;case"ig\xE5r":let l=new Date(n.getTime());l.setDate(l.getDate()-1),nt(s,l),Lt(s,l);break;case"f\xF6rrg\xE5r":case"i f\xF6rrg\xE5r":let c=new Date(n.getTime());c.setDate(c.getDate()-2),nt(s,c),Lt(s,c);break}switch(o){case"morgon":case"morgonen":s.imply("hour",6),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"f\xF6rmiddag":case"f\xF6rmiddagen":s.imply("hour",9),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"middag":case"middagen":s.imply("hour",12),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"eftermiddag":case"eftermiddagen":s.imply("hour",15),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"kv\xE4ll":case"kv\xE4llen":s.imply("hour",20),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break;case"natt":case"natten":case"midnatt":o==="midnatt"?s.imply("hour",0):s.imply("hour",2),s.imply("minute",0),s.imply("second",0),s.imply("millisecond",0);break}return s}}});var uR={};Zr(uR,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>lR,createCasualConfiguration:()=>f6,createConfiguration:()=>cR,parse:()=>Ase,parseDate:()=>kse,strict:()=>_se});function Ase(r,e,t){return lR.parse(r,e,t)}function kse(r,e,t){return lR.parseDate(r,e,t)}function f6(r=!0){let e=cR(!1,r);return e.parsers.unshift(new vC),e}function cR(r=!0,e=!0){return Ht({parsers:[new yo,new vr(e),new hC,new mC,new gC],refiners:[]},r)}var lR,_se,m6=b(()=>{xi();si();Le();pt();cs();bp();s6();u6();d6();p6();lR=new Se(f6()),_se=new Se(cR(!0))});var yC,h6=b(()=>{Ra();yC=class extends Gr{primaryPrefix(){return"(?:(?:klo|kello)\\s*)?"}followingPhase(){return"\\s*(?:\\-|\\\u2013|\\~|\\\u301C)\\s*"}extractPrimaryTimeComponents(e,t){return t[0].match(/^\s*\d{4}\s*$/)?null:super.extractPrimaryTimeComponents(e,t)}}});function oh(r){let e={},t=r,n=g6.exec(t);for(;n;)Dse(e,n),t=t.substring(n[0].length),n=g6.exec(t);return e}function Dse(r,e){let t=Pse(e[1]),n=fR[e[2].toLowerCase()];r[n]=t}function Pse(r){let e=r.toLowerCase();return bC[e]!==void 0?bC[e]:parseInt(e)}function w6(r){if(/\d+/.test(r)){let t=parseInt(r);return t<100&&(t=jr(t)),t}let e=r.toLowerCase();return bC[e]!==void 0?bC[e]:parseInt(r)}var dR,pR,bC,fR,Sse,v6,KXe,y6,g6,Ise,sh,b6,Bp=b(()=>{ze();zt();dR={sunnuntai:0,sunnuntaina:0,su:0,maanantai:1,maanantaina:1,ma:1,tiistai:2,tiistaina:2,ti:2,keskiviikko:3,keskiviikkona:3,ke:3,torstai:4,torstaina:4,to:4,perjantai:5,perjantaina:5,pe:5,lauantai:6,lauantaina:6,la:6},pR={tammikuu:1,tammikuuta:1,tammikuun:1,tammi:1,helmikuu:2,helmikuuta:2,helmikuun:2,helmi:2,maaliskuu:3,maaliskuuta:3,maaliskuun:3,maalis:3,huhtikuu:4,huhtikuuta:4,huhtikuun:4,huhti:4,toukokuu:5,toukokuuta:5,toukokuun:5,touko:5,kes\u00E4kuu:6,kes\u00E4kuuta:6,kes\u00E4kuun:6,kes\u00E4:6,hein\u00E4kuu:7,hein\u00E4kuuta:7,hein\u00E4kuun:7,hein\u00E4:7,elokuu:8,elokuuta:8,elokuun:8,elo:8,syyskuu:9,syyskuuta:9,syyskuun:9,syys:9,lokakuu:10,lokakuuta:10,lokakuun:10,loka:10,marraskuu:11,marraskuuta:11,marraskuun:11,marras:11,joulukuu:12,joulukuuta:12,joulukuun:12,joulu:12},bC={yksi:1,yhden:1,kaksi:2,kahden:2,kolme:3,kolmen:3,nelj\u00E4:4,nelj\u00E4n:4,viisi:5,viiden:5,kuusi:6,kuuden:6,seitsem\u00E4n:7,kahdeksan:8,yhdeks\u00E4n:9,kymmenen:10},fR={s:"second",sek:"second",sekunti:"second",sekuntia:"second",sekunnin:"second",min:"minute",minuutti:"minute",minuuttia:"minute",minuutin:"minute",t:"hour",tunti:"hour",tuntia:"hour",tunnin:"hour",pv:"day",p\u00E4iv\u00E4:"day",p\u00E4iv\u00E4\u00E4:"day",p\u00E4iv\u00E4n:"day",vk:"week",viikko:"week",viikkoa:"week",viikon:"week",kk:"month",kuukausi:"month",kuukautta:"month",kuukauden:"month",vuosi:"year",vuotta:"year",vuoden:"year"},Sse={sekunti:"second",sekuntia:"second",sekunnin:"second",minuutti:"minute",minuuttia:"minute",minuutin:"minute",tunti:"hour",tuntia:"hour",tunnin:"hour",p\u00E4iv\u00E4:"day",p\u00E4iv\u00E4\u00E4:"day",p\u00E4iv\u00E4n:"day",viikko:"week",viikkoa:"week",viikon:"week",kuukausi:"month",kuukautta:"month",kuukauden:"month",vuosi:"year",vuotta:"year",vuoden:"year"};v6=`(?:${ee(bC)}|\\d+)`,KXe=`(?:${ee(fR)})`,y6=`(${v6})\\s{0,5}(${ee(fR)})\\s{0,5}`,g6=new RegExp(y6,"i"),Ise=`(${v6})\\s{0,5}(${ee(Sse)})\\s{0,5}`,sh=Er("",y6),b6=Er("",Ise)});var Fse,Mse,Rse,$se,wC,C6=b(()=>{Bp();ze();fe();Ki();Fse=new RegExp(`(?:(?:\\,|\\(|\\\uFF08)\\s*)?(?:(viime|edellinen|edellisen\xE4|ensi|seuraava|seuraavana|t\xE4m\xE4|t\xE4n\xE4)\\s*)?(${ee(dR)})(?:\\s*(?:\\,|\\)|\\\uFF09))?(?:\\s*(viime|ensi|seuraava)\\s*viikolla)?(?=\\W|$)`,"i"),Mse=1,Rse=2,$se=3,wC=class extends L{innerPattern(){return Fse}innerExtract(e,t){let n=t[Rse].toLowerCase(),i=dR[n],o=t[Mse],s=t[$se],a=o||s;a=a||"",a=a.toLowerCase();let l=null;return a.match(/viime|edellinen|edellisenä/)?l="last":a.match(/ensi|seuraava|seuraavana/)&&(l="next"),cr(e.reference,i,l)}}});var Ose,x6,E6,Nse,T6,CC,_6=b(()=>{zt();Bp();Bp();ze();fe();Ose=new RegExp(`([0-9]{1,2})\\.?(?:\\s*(?:\\-|\\\u2013|\\s)\\s*([0-9]{1,2})\\.?)?\\s*(${ee(pR)})(?:(?:-|/|,?\\s*)([0-9]{4}(?![^\\s]\\d)))?(?=\\W|$)`,"i"),x6=1,E6=2,Nse=3,T6=4,CC=class extends L{innerPattern(){return Ose}innerExtract(e,t){let n=e.createParsingResult(t.index,t[0]),i=pR[t[Nse].toLowerCase()],o=parseInt(t[x6]);if(o>31)return t.index=t.index+t[x6].length,null;if(n.start.assign("month",i),n.start.assign("day",o),t[T6]){let s=w6(t[T6]);n.start.assign("year",s)}else{let s=ft(e.refDate,o,i);n.start.imply("year",s)}if(t[E6]){let s=parseInt(t[E6]);n.end=n.start.clone(),n.end.assign("day",s)}return n}}});var Lse,Bse,xC,A6=b(()=>{Bp();Le();fe();Bt();Lse=new RegExp(`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${sh})(?=\\W|$)`,"i"),Bse=new RegExp(`(seuraava|seuraavat|seuraavien|edellinen|edelliset|edellisten|viimeiset|viimeisten|kuluneet|kuluneiden|\\+|-)\\s*(${b6})(?=\\W|$)`,"i"),xC=class extends L{constructor(t=!0){super();le(this,"allowAbbreviations");this.allowAbbreviations=t}innerPattern(){return this.allowAbbreviations?Lse:Bse}innerExtract(t,n){let i=n[1].toLowerCase(),o=oh(n[2]);if(!o)return null;switch(i){case"edellinen":case"edelliset":case"edellisten":case"viimeiset":case"viimeisten":case"kuluneet":case"kuluneiden":case"-":o=tt(o);break}return Q.createRelativeFromReference(t.reference,o)}}});var EC,k6=b(()=>{Bp();Le();fe();Bt();EC=class extends L{innerPattern(){return new RegExp(`(${sh})\\s*sitten(?=\\W|$)`,"i")}innerExtract(e,t){let n=oh(t[1]),i=tt(n);return Q.createRelativeFromReference(e.reference,i)}}});var TC,S6=b(()=>{Bp();Le();fe();TC=class extends L{innerPattern(){return new RegExp(`(${sh})\\s*(?:sis\xE4ll\xE4|kuluessa|p\xE4\xE4st\xE4)(?=\\W|$)`,"i")}innerExtract(e,t){let n=oh(t[1]);return Q.createRelativeFromReference(e.reference,n)}}});var Up,mR=b(()=>{pt();fe();nn();Up=class r extends L{innerPattern(e){return/(tänä\s*)?(aamulla|aamuna|aamupäivällä|päivällä|iltapäivällä|illalla|yöllä|keskiyöllä)(?=\W|$)/i}innerExtract(e,t){let n=e.refDate,i=t[2].toLowerCase(),o=e.createParsingComponents();return Lt(o,n),r.extractTimeComponents(o,i)}static extractTimeComponents(e,t){switch(t){case"aamulla":case"aamuna":e.imply("hour",6),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/morning");break;case"aamup\xE4iv\xE4ll\xE4":e.imply("hour",9),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/morning");break;case"p\xE4iv\xE4ll\xE4":e.imply("hour",12),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/noon");break;case"iltap\xE4iv\xE4ll\xE4":e.imply("hour",15),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/afternoon");break;case"illalla":e.imply("hour",18),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/evening");break;case"y\xF6ll\xE4":e.imply("hour",22),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.PM),e.addTag("casualReference/evening");break;case"keskiy\xF6ll\xE4":e.get("hour")>1&&e.addDurationAsImplied({day:1}),e.imply("hour",0),e.imply("minute",0),e.imply("second",0),e.imply("meridiem",G.AM),e.addTag("casualReference/midnight");break}return e}}});var Use,Vse,qse,_C,D6=b(()=>{fe();nn();mR();oi();Bt();Use=new RegExp("(nyt|t\xE4n\xE4\xE4n|huomenna|ylihuomenna|eilen|toissap\xE4iv\xE4n\xE4|viime\\s*y\xF6n\xE4)(?:\\s*(aamulla|aamuna|aamup\xE4iv\xE4ll\xE4|p\xE4iv\xE4ll\xE4|iltap\xE4iv\xE4ll\xE4|illalla|y\xF6ll\xE4|keskiy\xF6ll\xE4))?(?=\\W|$)","i"),Vse=1,qse=2,_C=class extends L{innerPattern(e){return Use}innerExtract(e,t){let n=e.reference.getDateWithAdjustedTimezone(),i=(t[Vse]||"").toLowerCase(),o=(t[qse]||"").toLowerCase(),s=e.createParsingComponents();switch(i){case"nyt":s=$r(e.reference);break;case"t\xE4n\xE4\xE4n":s=Tr(e.reference);break;case"huomenna":n=gt(n,{day:1}),nt(s,n),Lt(s,n);break;case"ylihuomenna":n=gt(n,{day:2}),nt(s,n),Lt(s,n);break;case"eilen":n=gt(n,{day:-1}),nt(s,n),Lt(s,n);break;case"toissap\xE4iv\xE4n\xE4":n=gt(n,{day:-2}),nt(s,n),Lt(s,n);break;default:i.match(/viime\s*yönä/)&&(n.getHours()>6&&(n=gt(n,{day:-1})),nt(s,n),s.imply("hour",0));break}return o&&(s=Up.extractTimeComponents(s,o)),s}}});var AC,I6=b(()=>{go();AC=class extends Yt{patternBetween(){return/^\s*(-|–)\s*$/i}}});var kC,P6=b(()=>{vo();kC=class extends Kt{patternBetween(){return new RegExp("^\\s*(T|klo|kello|,|-)?\\s*$")}}});var vR={};Zr(vR,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>hR,createCasualConfiguration:()=>F6,createConfiguration:()=>gR,parse:()=>zse,parseDate:()=>Hse,strict:()=>Wse});function zse(r,e,t){return hR.parse(r,e,t)}function Hse(r,e,t){return hR.parseDate(r,e,t)}function F6(r=!0){let e=gR(!1,r);return e.parsers.unshift(new Up),e.parsers.unshift(new _C),e.parsers.unshift(new xC),e}function gR(r=!0,e=!0){return Ht({parsers:[new yo,new vr(e),new yC,new CC,new wC,new TC,new EC],refiners:[new AC,new kC]},r)}var hR,Wse,M6=b(()=>{xi();si();Le();pt();cs();bp();h6();C6();_6();A6();k6();S6();D6();mR();I6();P6();hR=new Se(F6()),Wse=new Se(gR(!0))});function jse(r){let e=r.toLowerCase();return yR[e]!==void 0?yR[e]:parseFloat(e)}function lh(r){let e=r.toUpperCase(),t=parseInt(r.replace(/[^0-9]+/g,""));return/TCN/.test(e)?-t:jr(t)}function Yu(r){let e={},t=r,n=R6.exec(t);for(;n;){let i=jse(n[1]),o=SC[n[2].toLowerCase()];e[o]=i,t=t.substring(n[0].length),n=R6.exec(t)}return e}var bR,wR,yR,SC,CR,ah,$6,R6,ch,Oc=b(()=>{ze();zt();bR={"ch\u1EE7 nh\u1EADt":0,cn:0,"th\u1EE9 hai":1,t2:1,"th\u1EE9 ba":2,t3:2,"th\u1EE9 t\u01B0":3,t4:3,"th\u1EE9 n\u0103m":4,t5:4,"th\u1EE9 s\xE1u":5,t6:5,"th\u1EE9 b\u1EA3y":6,t7:6},wR={"th\xE1ng 1":1,"th\xE1ng m\u1ED9t":1,"th\xE1ng gi\xEAng":1,"th\xE1ng 2":2,"th\xE1ng hai":2,"th\xE1ng 3":3,"th\xE1ng ba":3,"th\xE1ng 4":4,"th\xE1ng t\u01B0":4,"th\xE1ng 5":5,"th\xE1ng n\u0103m":5,"th\xE1ng 6":6,"th\xE1ng s\xE1u":6,"th\xE1ng 7":7,"th\xE1ng b\u1EA3y":7,"th\xE1ng 8":8,"th\xE1ng t\xE1m":8,"th\xE1ng 9":9,"th\xE1ng ch\xEDn":9,"th\xE1ng 10":10,"th\xE1ng m\u01B0\u1EDDi":10,"th\xE1ng 11":11,"th\xE1ng m\u01B0\u1EDDi m\u1ED9t":11,"th\xE1ng 12":12,"th\xE1ng m\u01B0\u1EDDi hai":12,"th\xE1ng ch\u1EA1p":12},yR={m\u1ED9t:1,hai:2,ba:3,b\u1ED1n:4,n\u0103m:5,s\u00E1u:6,b\u1EA3y:7,t\u00E1m:8,ch\u00EDn:9,m\u01B0\u1EDDi:10,"m\u01B0\u1EDDi m\u1ED9t":11,"m\u01B0\u1EDDi hai":12},SC={gi\u00E2y:"second",ph\u00FAt:"minute",gi\u1EDD:"hour",ng\u00E0y:"day",tu\u1EA7n:"week",th\u00E1ng:"month",n\u0103m:"year"},CR="(?:"+ee(yR)+"|[0-9]+|[0-9]+\\.[0-9]+)";ah="(?:[0-9]{1,4}(?:\\s*TCN)?)";$6="("+CR+")\\s{0,5}("+ee(SC)+")\\s{0,5}",R6=new RegExp($6,"i"),ch=Er("",$6)});var Gse,Yse,Kse,O6,DC,N6=b(()=>{zt();Oc();fe();Gse=new RegExp("(?:ng\xE0y\\s*)?([0-9]{1,2})\\s*th\xE1ng\\s*([0-9]{1,2})(?:\\s*n\u0103m\\s*("+ah+"))?(?=\\W|$)","i"),Yse=1,Kse=2,O6=3,DC=class extends L{innerPattern(){return Gse}innerExtract(e,t){let n=parseInt(t[Yse]),i=parseInt(t[Kse]);if(n>31||i>12)return null;let o=e.createParsingResult(t.index,t[0]);return o.start.assign("day",n),o.start.assign("month",i),t[O6]?o.start.assign("year",lh(t[O6])):o.start.imply("year",ft(e.refDate,n,i)),o}}});var Xse,Qse,L6,IC,B6=b(()=>{Oc();ze();fe();Xse=new RegExp("("+ee(wR)+")(?:\\s*(?:n\u0103m|/)\\s*("+ah+"))?(?=\\W|$)","i"),Qse=1,L6=2,IC=class extends L{innerPattern(){return Xse}innerExtract(e,t){let n=wR[t[Qse].toLowerCase()];if(!n)return null;let i=e.createParsingResult(t.index,t[0]);return i.start.assign("month",n),i.start.imply("day",1),t[L6]?i.start.assign("year",lh(t[L6])):i.start.imply("year",e.reference.getDateWithAdjustedTimezone().getFullYear()),i}}});var Zse,U6,Jse,eae,PC,V6=b(()=>{Oc();fe();Zse=new RegExp("(?:\\bn\u0103m\\s*("+ah+")|\\b([0-9]{1,4})\\s*(TCN))(?=\\W|$)","i"),U6=1,Jse=2,eae=3,PC=class extends L{innerPattern(){return Zse}innerExtract(e,t){let n;t[U6]?n=t[U6]:n=t[Jse]+" "+t[eae];let i=e.createParsingResult(t.index,t[0]);return i.start.assign("year",lh(n)),i.start.imply("month",1),i.start.imply("day",1),i}}});var tae,FC,q6=b(()=>{fe();oi();tae=/\b(hôm nay|hôm qua|hôm kia|ngày mai|ngày kia|bây giờ|lúc này)(?=\W|$)/i,FC=class extends L{innerPattern(){return tae}innerExtract(e,t){switch(t[1].toLowerCase()){case"b\xE2y gi\u1EDD":case"l\xFAc n\xE0y":return $r(e.reference);case"h\xF4m nay":return Tr(e.reference);case"h\xF4m qua":return gn(e.reference);case"h\xF4m kia":return Sc(e.reference,2);case"ng\xE0y mai":return vn(e.reference);case"ng\xE0y kia":return Mo(e.reference,2)}return e.createParsingComponents()}}});var rae,MC,W6=b(()=>{pt();fe();nn();rae=/(buổi\s*)?(sáng sớm|sáng|trưa|chiều|tối|đêm|nửa đêm|bình minh)(?=\W|$)/i,MC=class r extends L{innerPattern(){return rae}innerExtract(e,t){let n=e.createParsingComponents();return Lt(n,e.refDate),r.extractTimeComponents(n,t[2].toLowerCase())}static extractTimeComponents(e,t){switch(t){case"b\xECnh minh":case"s\xE1ng s\u1EDBm":e.imply("hour",6),e.imply("minute",0),e.imply("meridiem",G.AM);break;case"s\xE1ng":e.imply("hour",9),e.imply("minute",0),e.imply("meridiem",G.AM);break;case"tr\u01B0a":e.imply("hour",12),e.imply("minute",0),e.imply("meridiem",G.PM);break;case"chi\u1EC1u":e.imply("hour",15),e.imply("minute",0),e.imply("meridiem",G.PM);break;case"t\u1ED1i":e.imply("hour",19),e.imply("minute",0),e.imply("meridiem",G.PM);break;case"\u0111\xEAm":e.imply("hour",22),e.imply("minute",0),e.imply("meridiem",G.PM);break;case"n\u1EEDa \u0111\xEAm":e.imply("hour",0),e.imply("minute",0),e.imply("meridiem",G.AM);break}return e}}});var nae,iae,oae,RC,z6=b(()=>{Oc();ze();fe();Ki();nae=new RegExp("("+ee(bR)+")(?:\\s*(n\xE0y|t\u1EDBi|sau(?!\\s*khi)|qua))?(?=\\W|$)","i"),iae=1,oae=2,RC=class extends L{innerPattern(){return nae}innerExtract(e,t){let n=t[iae].toLowerCase(),i=bR[n];if(i===void 0)return null;let o=t[oae],s=null;if(o){let a=o.toLowerCase();a.includes("t\u1EDBi")||a.includes("sau")?s="next":a.includes("qua")&&(s="last")}return cr(e.reference,i,s)}}});var sae,aae,H6,lae,j6,$C,G6=b(()=>{fe();pt();sae=new RegExp("(?:l\xFAc\\s*|v\xE0o\\s*)?([0-9]{1,2})(?:\\s*gi\u1EDD\\s*([0-9]{1,2})?\\s*(?:ph\xFAt\\s*)?(s\xE1ng|tr\u01B0a|chi\u1EC1u|t\u1ED1i|\u0111\xEAm)?|:([0-9]{2}))(?=\\W|$)","i"),aae=1,H6=2,lae=3,j6=4,$C=class extends L{innerPattern(){return sae}innerExtract(e,t){let n=parseInt(t[aae]);if(n>23)return null;let i=e.createParsingResult(t.index,t[0]);i.start.assign("hour",n);let o=t[j6]?parseInt(t[j6]):t[H6]?parseInt(t[H6]):0;if(o>=60)return null;i.start.assign("minute",o);let s=t[lae]?.toLowerCase();return s==="s\xE1ng"?(i.start.assign("meridiem",G.AM),n===12&&i.start.assign("hour",0)):s==="tr\u01B0a"?n<10?(i.start.assign("meridiem",G.PM),i.start.assign("hour",n+12)):i.start.assign("meridiem",n>=12?G.PM:G.AM):(s==="chi\u1EC1u"||s==="t\u1ED1i"||s==="\u0111\xEAm")&&(i.start.assign("meridiem",G.PM),n<12&&i.start.assign("hour",n+12)),i.start.imply("second",0),i.start.imply("millisecond",0),i}}});var cae,OC,Y6=b(()=>{Oc();Le();fe();Bt();cae=new RegExp("("+ch+")\\s{0,5}(?:tr\u01B0\u1EDBc|qua)(?=\\W|$)","i"),OC=class extends L{constructor(t=!1){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return cae}innerExtract(t,n){let i=Yu(n[1]);return i?Q.createRelativeFromReference(t.reference,tt(i)):null}}});var uae,NC,K6=b(()=>{Oc();Le();fe();uae=new RegExp("("+ch+")\\s{0,5}(?:sau|n\u1EEFa|t\u1EDBi|ti\u1EBFp)(?=\\W|$)","i"),NC=class extends L{constructor(t=!1){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return uae}innerExtract(t,n){let i=Yu(n[1]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var dae,LC,X6=b(()=>{Oc();Le();fe();dae=new RegExp("(?:trong\\s*(?:v\xF2ng\\s*)?)("+ch+")(?=\\W|$)","i"),LC=class extends L{constructor(t=!1){super();le(this,"strictMode");this.strictMode=t}innerPattern(){return dae}innerExtract(t,n){let i=Yu(n[1]);return i?Q.createRelativeFromReference(t.reference,i):null}}});var Q6,pae,BC,Z6=b(()=>{Oc();Le();fe();Bt();ze();Q6="(?:"+CR+"\\s{0,5})?(?:"+ee(SC)+")",pae=new RegExp("(n\xE0y|tr\u01B0\u1EDBc|qua|sau|t\u1EDBi|ti\u1EBFp)\\s*("+Q6+")|("+Q6+")\\s*(n\xE0y|tr\u01B0\u1EDBc|qua|sau|t\u1EDBi|ti\u1EBFp)(?=\\W|$)","i"),BC=class extends L{innerPattern(){return pae}innerExtract(e,t){let n=(t[1]||t[4]||"").toLowerCase(),i=(t[2]||t[3]||"").toLowerCase(),o=Yu(i);if(Object.keys(o).length===0){let s=SC[i];if(!s)return null;o={[s]:1}}return(n==="tr\u01B0\u1EDBc"||n==="qua")&&(o=tt(o)),Q.createRelativeFromReference(e.reference,o)}}});var UC,J6=b(()=>{go();UC=class extends Yt{patternBetween(){return/^\s*(?:–|-|đến|tới|và)\s*$/}}});var VC,ej=b(()=>{vo();VC=class extends Kt{patternBetween(){return/^\s*(?:lúc|vào|,|T|-)?\s*$/}}});var qC,tj=b(()=>{K_();qC=class extends kc{}});var TR={};Zr(TR,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>xR,createCasualConfiguration:()=>rj,createConfiguration:()=>ER,parse:()=>mae,parseDate:()=>hae,strict:()=>fae});function mae(r,e,t){return xR.parse(r,e,t)}function hae(r,e,t){return xR.parseDate(r,e,t)}function rj(r=!0){let e=ER(!1,r);return e.parsers.unshift(new MC),e.parsers.unshift(new FC),e.parsers.unshift(new BC),e}function ER(r=!0,e=!0){return Ht({parsers:[new yo,new vr(e),new DC,new IC,new PC,new RC,new $C,new OC(r),new NC(r),new LC(r)],refiners:[new qC,new UC,new VC]},r)}var xR,fae,nj=b(()=>{xi();si();Le();pt();bp();cs();N6();B6();V6();q6();W6();z6();G6();Y6();K6();X6();Z6();J6();ej();tj();xR=new Se(rj()),fae=new Se(ER(!0))});var AR={};Zr(AR,{Chrono:()=>Se,Meridiem:()=>G,ParsingComponents:()=>Q,ParsingContext:()=>eb,ParsingResult:()=>at,ReferenceWithTimezone:()=>ct,Weekday:()=>Oe,casual:()=>_R,de:()=>bF,en:()=>uF,es:()=>UM,fi:()=>vR,fr:()=>DF,it:()=>iR,ja:()=>MF,nl:()=>jF,parse:()=>vae,parseDate:()=>yae,pt:()=>LF,ru:()=>RM,strict:()=>gae,sv:()=>uR,uk:()=>XM,vi:()=>TR,zh:()=>TM});function vae(r,e,t){return _R.parse(r,e,t)}function yae(r,e,t){return _R.parseDate(r,e,t)}var gae,_R,ij=b(()=>{Gq();si();Le();pt();gW();BW();i3();y3();W3();lz();Dz();Kz();gH();ZH();m6();M6();nj();gae=cF,_R=tb});function bae(){return AR}var kR,El,uh=b(()=>{ij();kR=class{constructor(){this.chrono=bae()}getParsedDate(e){return this.chrono.parseDate(e,new Date,{forwardDate:!0})}parseDate(e){if(!e||!e.trim())return null;try{let t=this.getParsedDate(e);return t?window.moment?{moment:window.moment(t)}:(console.warn("Moment.js is not available"),null):null}catch(t){return console.warn("Failed to parse date:",e,t),null}}},El=new kR});function oj(r){return r<=31||r===127||r===8232||r===8233}function xae(r){let e="",t=0;for(;t<r.length;){let n=t;for(;n<r.length&&r.charCodeAt(n)===32;)n++;if(n<r.length&&oj(r.charCodeAt(n))){for(;n<r.length&&oj(r.charCodeAt(n));)n++;for(;n<r.length&&r.charCodeAt(n)===32;)n++;e+=" ",t=n;continue}e+=r.slice(t,Math.min(n+1,r.length)),t=n+1}return e}function sj(r,e){let t=r.length;for(;t>0&&e.includes(r[t-1]);)t--;return r.slice(0,t)}function Vp(r){return Eae.filter(e=>r.includes(e))}function lj(r){return`A file or folder name cannot contain ${dj(r)}, so this choice would fail at run time. ${uj}`}function cj(r,e){return`Cannot create "${e}": a file or folder name cannot contain ${dj(r)}. ${uj}`}function dj(r){return r.map(e=>`"${e}"`).join(", ")}function ai(r,e="File path"){let{path:t,problems:n}=fj(r,e);if(n.length>0)throw new Error(n[0]);return t}function pj(r,e="File path"){return fj(r,e)}function fj(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):Tae(o,e,t)).join("/"),problems:t}}function Tae(r,e,t){if(r.length===0)return r;let n=wae.test(r),i=Cae.test(r),o=xae(r);n&&(o=o.replace(/^ /u,"")),i&&(o=o.replace(/ $/u,""));let s=sj(o," ");return s==="."||s===".."?(t.push(`${e} cannot contain "." or ".." path segments.`),s):(o=sj(o,". "),o||t.push(`${e} contains an empty path segment after formatting.`),o)}var aj,wae,Cae,Eae,uj,Tl=b(()=>{aj="\0-\x7F\u2028\u2029",wae=new RegExp(`^ *[${aj}]`,"u"),Cae=new RegExp(`[${aj}] *$`,"u");Eae=[":"];uj="Check your own text and tokens like {{TIME}}, which is HH:mm."});function zj(r){let e=t=>{t.preventDefault(),t.stopPropagation()};r.addEventListener("pointerdown",e),r.addEventListener("mousedown",e)}function _le(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 ZC,Xi,Wp=b(()=>{ZC=require("obsidian"),Xi=class r extends ZC.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 ZC.ButtonComponent(t).setButtonText("No").onClick(()=>this.submit(!1));zj(n.buttonEl);let i=new ZC.ButtonComponent(t).setButtonText("Yes").onClick(()=>this.submit(!0)).setDestructive();zj(i.buttonEl),i.buttonEl.focus(),_le([n.buttonEl,i.buttonEl])}submit(t){this.input=t,this.close()}onClose(){super.onClose(),this.resolvePromise(this.input)}}});var Lr,Yr=b(()=>{Lr=(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))(Lr||{})});function Si(r){return typeof r=="object"&&r!==null}function ed(r){return Si(r)&&!Array.isArray(r)}function qce(r){return ed(r)?!1:Array.isArray(r)?r.length>0:Di(r)}function Wn(r){return ed(r)?r.commands:qce(r)?r:void 0}function Dr(r){return Array.isArray(r)?r:[]}function Dh(r){return Array.isArray(r)?r:[]}function lx(r){return Array.isArray(r)}function Di(r){return Array.isArray(r)||r==null?!1:typeof r=="object"?Object.keys(r).length>0:!!r}function d$(r){let e=Dr(r),t=new Set,n=!1,i=[];for(let o of e){if(Array.isArray(o)){let l=d$(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:xr()};t.add(d.id),i.push(d)}n=!0;continue}if(!Si(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:xr()};t.add(a.id),i.push(a),n=!0}return n?{commands:i,changed:n}:{commands:e,changed:!1}}function TG(r){_G(r,new Set)}function _G(r,e){Si(r)&&(e.has(r)||(e.add(r),ed(r)&&(r.id=xr()),sk(Wn(r),e)))}function sk(r,e){if(lx(r))for(let t of r){if(Array.isArray(t)){sk(t,e);continue}if(!Si(t)||e.has(t))continue;e.add(t),t.id=xr();let n=t;sk(n.thenCommands,e),sk(n.elseCommands,e),AG(n.choice,e)}}function AG(r,e){if(!Si(r)||e.has(r))return;e.add(r);let t=r;if(t.id=xr(),t.type==="Macro"&&_G(t.macro,e),t.type==="Multi"&&Array.isArray(t.choices))for(let n of t.choices)AG(n,e)}var Ii=b(()=>{ml()});function td(r){return r!==null&&typeof r=="object"}function pk(r){return r?.secretStorage}function lk(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"setting"}function Hce(r){let e=5381;for(let t=0;t<r.length;t+=1)e=e*33^r.charCodeAt(t);return(e>>>0).toString(36).slice(0,zce)}function SG(r,e){return r.length<=e?r:r.slice(0,e).replace(/-+$/g,"")||"setting"}function PG(r,e){let t=e?.id;return typeof t=="string"&&t.trim().length>0?t:r}function p$(r,e,t){let i=(t?[ak,r,e,t]:[ak,r,e]).join("-");if(i.length<=kG)return i;let o=Hce([r,e,t].filter(Boolean).join(":")),s=t?4:3,a=kG-ak.length-o.length-(t?.length??0)-s,l=Math.max(8,Math.floor(a*.6)),c=Math.max(8,a-l);return[ak,SG(r,l),SG(e,c),...t?[t]:[],o].join("-")}function f$(r){return r?.message??String(r)}function Na(r,e){let t=e;for(;t<r.length;){let n=r[t],i=r[t+1];if(/\s/.test(n)){t+=1;continue}if(n==="/"&&i==="/"){let o=r.indexOf(`
|
||
`,t+2);t=o===-1?r.length:o+1;continue}if(n==="/"&&i==="*"){let o=r.indexOf("*/",t+2);t=o===-1?r.length:o+2;continue}return t}return t}function ux(r,e){let t=r[e];if(t!=='"'&&t!=="'"&&t!=="`")return null;let n="";for(let i=e+1;i<r.length;i++){let o=r[i];if(o==="\\"){let s=r[i+1];if(s===void 0)return null;n+=s,i+=1;continue}if(o===t)return{value:n,end:i+1};n+=o}return null}function DG(r,e){let t=/^[A-Za-z_$][\w$]*/.exec(r.slice(e));return t?{value:t[0],end:e+t[0].length}:null}function cx(r,e,t,n){let i=0;for(let o=e;o<r.length;o++){let s=r[o],a=r[o+1];if(s==='"'||s==="'"||s==="`"){let l=ux(r,o);if(!l)return-1;o=l.end-1;continue}if(s==="/"&&a==="/"){let l=r.indexOf(`
|
||
`,o+2);o=l===-1?r.length:l;continue}if(s==="/"&&a==="*"){let l=r.indexOf("*/",o+2);if(l===-1)return-1;o=l+1;continue}if(s===t){i+=1;continue}if(s===n&&(i-=1,i===0))return o}return-1}function FG(r){let e=new Map,t=/\b(?:const|let|var)\s+([A-Za-z_$][\w$]*)\s*=\s*(["'`])/g,n;for(;(n=t.exec(r))!==null;){let i=ux(r,t.lastIndex-1);i&&(e.set(n[1],i.value),t.lastIndex=i.end)}return e}function jce(r){let e=[],t=FG(r),n=0;for(;n<r.length;){n=Na(r,n);let i=r[n],o=r[n+1];if(i==='"'||i==="'"||i==="`"){let l=ux(r,n);n=l?l.end:n+1;continue}if(i==="/"&&o==="/"){let l=r.indexOf(`
|
||
`,n+2);n=l===-1?r.length:l+1;continue}if(i==="/"&&o==="*"){let l=r.indexOf("*/",n+2);n=l===-1?r.length:l+2;continue}let s=m$(r,n,t);if(!s){n+=1;continue}if(n=Na(r,s.end),r[n]!==":"){n=s.end;continue}if(n=Na(r,n+1),s.name!=="options"||r[n]!=="{")continue;let a=cx(r,n,"{","}");if(a===-1)break;e.push({start:n+1,end:a}),n=a+1}return e}function m$(r,e,t){if(r[e]==='"'||r[e]==="'"||r[e]==="`"){let i=ux(r,e);return i?{name:i.value,end:i.end}:null}if(r[e]==="["){let i=Na(r,e+1),o=DG(r,i),s=cx(r,e,"[","]");if(s===-1)return null;let a=o?Na(r,o.end):i;return{name:o&&a===s?t.get(o.value)??null:null,end:s+1}}let n=DG(r,e);return n?{name:n.value,end:n.end}:null}function Gce(r){let e=new Map,t=0;for(;t<r.length;){if(t=Na(r,t),r[t]===","){t+=1;continue}if(t>=r.length)break;let n=m$(r,t,new Map);if(!n?.name){t+=1;continue}if(t=Na(r,n.end),r[t]!==":"){t+=1;continue}if(t=Na(r,t+1),r[t]==='"'||r[t]==="'"||r[t]==="`"){let i=ux(r,t);if(!i)break;e.set(n.name,i.value),t=i.end;continue}if(r.slice(t,t+4)==="true"){e.set(n.name,!0),t+=4;continue}if(r.slice(t,t+5)==="false"){e.set(n.name,!1),t+=5;continue}if(r[t]==="{"){let i=cx(r,t,"{","}");if(i===-1)break;t=i+1;continue}if(r[t]==="["){let i=cx(r,t,"[","]");if(i===-1)break;t=i+1;continue}for(;t<r.length&&r[t]!==",";)t+=1}return e}function Yce(r){let e=Gce(r),t=e.get("type"),n=e.get("secret");return t==="secret"||(t==="text"||t==="input")&&n===!0}function Ph(r,e){let t=e&&Wce.test(e)?hc(r).code??"":r,n=new Set,i=!1,o=FG(t);for(let{start:s,end:a}of jce(t)){let l=s;for(;l<a;){if(l=Na(t,l),t[l]===","){l+=1;continue}if(l>=a)break;let c=m$(t,l,o);if(!c){l+=1;continue}if(l=Na(t,c.end),t[l]!==":"){l+=1;continue}if(l=Na(t,l+1),t[l]!=="{"){l+=1;continue}let u=cx(t,l,"{","}");if(u===-1||u>a)break;let d=t.slice(l+1,u);Yce(d)&&(i=!0,c.name&&n.add(c.name)),l=u+1}}return{names:n,foundSecretOptions:i}}function Fh(r){return td(r)?r.type==="secret"||(r.type==="text"||r.type==="input")&&r.secret===!0:!1}function Ih(r){return td(r)&&r[IG]===!0&&typeof r.secretRef=="string"&&r.secretRef.trim().length>0}function ck(r){return{[IG]:!0,secretRef:r}}function Kce(r,e,t){let n=r.id?.trim()||r.path||r.name||"script";return p$(lk(n),lk(PG(e,t)))}function Xce(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Fh(t)).map(([t])=>t):[]}function Qce(r){let e=r?.options;return e?Object.entries(e).filter(([,t])=>Fh(t)):[]}function Zce(r){return typeof r.id=="string"&&r.id.trim().length>0}async function h$(r,e){let t=pk(r);if(!t?.getSecret)return null;try{return await Promise.resolve(t.getSecret(e))}catch(n){return F.logWarning(`Failed to read user script SecretStorage entry "${e}": ${f$(n)}`),null}}async function Jce(r,e,t){let n=pk(r);if(!n?.setSecret)return!1;try{return await Promise.resolve(n.setSecret(e,t)),!0}catch(i){return F.logWarning(`Failed to write user script SecretStorage entry "${e}": ${f$(i)}`),!1}}async function eue(r,e,t,n,i){let o=e.id?.trim()||e.path||e.name||"script",s=lk(o),a=lk(PG(t,i)),l=p$(s,a),c=1;for(;;){let u=await h$(r,l);if(!u||u===n)return l;c+=1,l=p$(s,a,String(c))}}async function g$(r,e,t,n,i,o){if(n.length===0)return null;let s=i?.trim()||await eue(r,e,t,n,o);return await Jce(r,s,n)?s:null}async function v$(r,e){let t=e?.trim();if(!t)return!0;let n=pk(r);if(!n)return!0;let i=n.deleteSecret??n.removeSecret??n.delete;try{if(i)return await Promise.resolve(i.call(n,t)),!0;if(n.setSecret)return await Promise.resolve(n.setSecret(t,"")),!0}catch(o){F.logWarning(`Failed to clear user script SecretStorage entry "${t}": ${f$(o)}`)}return!1}async function fk(r,e,t){let n=e.settings??{},i={...n},o=new Set(Xce(t));for(let[s,a]of Object.entries(n)){if(Ih(a)){let l=await h$(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 Mh(r,e,t){let n=Qce(t);if(n.length===0)return!1;let i=pk(r);if(!i?.getSecret||!i?.setSecret)return n.some(([a])=>{let l=e.settings?.[a];return typeof l=="string"&&l.length>0})&&F.logWarning(`SecretStorage unavailable; 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(Ih(l))continue;if(typeof l!="string"||l.length===0){if(!Zce(a))continue;let u=Kce(e,s,a);if(!await h$(r,u))continue;e.settings[s]=ck(u);for(let[f,p]of Object.entries(e.settings))f!==s&&Ih(p)&&p.secretRef===u&&delete e.settings[f];o=!0;continue}let c=await g$(r,e,s,l,void 0,a);c&&(e.settings[s]=ck(c),o=!0)}return o}function mk(r,e){let t=r.settings?.[e];return Ih(t)?t.secretRef:void 0}async function tue(r,e){if(!td(e))return!0;let t=Object.values(e).filter(Ih).map(i=>i.secretRef);return(await Promise.all(t.map(i=>v$(r,i)))).every(Boolean)}async function MG(r,e){if(!td(e))return!0;let t=!0;if(e.type==="Macro"&&(t=await uk(r,Wn(e.macro))&&t),e.type==="Multi"&&Array.isArray(e.choices))for(let n of e.choices)t=await MG(r,n)&&t;return t}async function dx(r,e){if(!td(e))return!0;let t=!0;return e.type==="UserScript"&&(t=await tue(r,e.settings)&&t),Array.isArray(e.thenCommands)&&(t=await uk(r,e.thenCommands)&&t),Array.isArray(e.elseCommands)&&(t=await uk(r,e.elseCommands)&&t),t=await MG(r,e.choice)&&t,t}async function uk(r,e){if(!Array.isArray(e))return!0;let t=!0;for(let n of e){if(Array.isArray(n)){t=await uk(r,n)&&t;continue}t=await dx(r,n)&&t}return t}function rue(r,e){let t=r.path;if(typeof t=="string")return e?.secretOptionNamesByPath?.get(t)}function nue(r,e,t){if(td(r))for(let[n,i]of Object.entries(r)){if(Ih(i)){delete r[n];continue}typeof i=="string"&&(e===null||e?.has(n)||e===void 0&&t?.stripUnknownStringSettings===!0)&&delete r[n]}}function y$(r,e){td(r)&&(r.type==="UserScript"&&nue(r.settings,rue(r,e),e),Array.isArray(r.thenCommands)&&dk(r.thenCommands,e),Array.isArray(r.elseCommands)&&dk(r.elseCommands,e),Rh(r.choice,e))}function dk(r,e){if(Array.isArray(r))for(let t of r){if(Array.isArray(t)){dk(t,e);continue}y$(t,e)}}function Rh(r,e){if(td(r)&&(r.type==="Macro"&&dk(Wn(r.macro),e),r.type==="Multi"&&Array.isArray(r.choices)))for(let t of r.choices)Rh(t,e)}var ak,IG,Wce,kG,zce,Uc=b(()=>{Me();Kv();Ii();ak="quickadd-user-script",IG="__quickaddSecret",Wce=/\.md$/i,kG=64,zce=8});function $h(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&&!Fh(e.options[t])&&(r[t]=e.options[t].defaultValue)}}var hk=b(()=>{Uc()});function Uo(r){if(r.length===0)return 0;let e=new TextEncoder().encode(r).length,t=!1;for(let i=0;i<r.length;i++)if(r.charCodeAt(i)>127){t=!0;break}return Math.max(1,Math.ceil(e/(t?3:4)))}function $G(r){return!Number.isFinite(r)||r<=0?1:Math.max(1,Math.floor(r*.45))}var px=b(()=>{});function BG(){return ce.getState().ai.providers.flatMap(e=>e.models).map(e=>e.name)}function C$(){return ce.getState().ai.providers}function OG(r,e){for(let t of r){let n=t.models.find(i=>i.name===e);if(n)return{provider:t,model:n}}}function w$(r){let e=C$();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 LG(r,e){NG.has(r)||(NG.add(r),F.logWarning(e))}function Kp(r,e){let t=C$(),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=OG(t,r.name);return l?(n||LG(`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=OG(t,r);if(i){let s=w$(r);return s.length>1&&!n&&LG(`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 UG(r.slice(0,o),r.slice(o+1))}function UG(r,e){let t=C$(),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 Oh(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?UG(r.provider,e):Kp(e);if(!t){let n=e.includes("/")?e.slice(e.indexOf("/")+1):e,i=[...w$(e),...n!==e?w$(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 NG,Nh=b(()=>{Me();It();NG=new Set});var Ck=b(()=>{});var ui,Vc=b(()=>{ml();ui=class{constructor(e,t){this.name=e,this.type=t,this.id=xr()}}});var Sk,an,nd=b(()=>{Sk=require("obsidian");Me();Fo();Wr();an=class r extends Sk.FuzzySuggestModal{constructor(t,n,i,o={}){super(t);this.warnedOnEmptyDisplay=!1;this.warnRenderItemFailure=mp("Custom renderItem threw an error; falling back to default rendering");this.warnCustomValueFailure=mp("Custom create-row rendering threw an error; falling back to default rendering");this.allowCustomValue=!0;this.items=i,this.displayItems=n.map(s=>fn(s)),this.searchItems=o.searchItems?.map(s=>fn(s))??[],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.renderItem=o.renderItem,this.allowCustomValue=o.allowCustomValue??!0,this.customValueLabel=o.customValueLabel,this.valueExists=o.valueExists,this.inputEl.addEventListener("keydown",s=>{if(s.code!=="Tab"||!("chooser"in this))return;let{values:a,selectedItem:l}=this.chooser,{value:c}=this.inputEl;this.inputEl.value=a[l]?.item??c}),o.placeholder&&this.setPlaceholder(o.placeholder),typeof o.limit=="number"&&(this.limit=o.limit),o.emptyStateText&&(this.emptyStateText=o.emptyStateText),this.displayItems.length!==this.items.length&&(this.displayItems=this.items.map((s,a)=>{let l=this.displayItems[a];return fn(l??s)})),this.searchItems.length!==this.items.length&&(this.searchItems=this.items.map((s,a)=>fn(this.searchItems[a]??this.displayItems[a]??s))),o.skippable&&QT(this,()=>this.skip()),this.warnIfEmptyDisplay(),this.open()}static Suggest(t,n,i,o={}){return new r(t,n,i,o).promise}getItemText(t){if(t===this.inputEl.value)return t;let n=this.items.indexOf(t),i=n>=0?this.searchItems[n]:void 0;return fn(i??t)}getItems(){return this.items}getSuggestions(t){let n=Cc(t),i=super.getSuggestions(n);if(!this.allowCustomValue)return i;let o=Cc(this.inputEl.value);return!o||this.items.includes(o)||this.valueExists?.(o)||i.some(a=>a.item===o)||i.push({item:o,match:{score:Number.NEGATIVE_INFINITY,matches:[]}}),i}selectSuggestion(t,n){this.resolved=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){if(this.customValueLabel&&t.match.score===Number.NEGATIVE_INFINITY){this.renderCustomValue(t.item,n);return}if(!this.renderItem){super.renderSuggestion(t,n);return}try{n.empty(),this.renderItem(t.item,n)}catch(i){this.warnRenderItemFailure(i),n.empty(),super.renderSuggestion(t,n)}}renderCustomValue(t,n){try{n.empty(),n.addClass("mod-complex"),n.createDiv({cls:"suggestion-content"}).createDiv({cls:"suggestion-title",text:this.customValueLabel?.(t)??t});let o=n.createDiv({cls:"suggestion-aux"});(0,Sk.setIcon)(o.createSpan({cls:"suggestion-flair"}),"file-plus")}catch(i){this.warnCustomValueFailure(i),n.empty(),super.renderSuggestion({item:t,match:{score:0,matches:[]}},n)}}onChooseItem(t,n){this.resolved=!0,this.resolvePromise(t)}skip(){this.resolved=!0,this.resolvePromise(""),this.close()}onClose(){super.onClose(),this.resolved||this.rejectPromise(tn())}warnIfEmptyDisplay(){if(this.warnedOnEmptyDisplay)return;this.displayItems.some(n=>n.length===0)&&(this.warnedOnEmptyDisplay=!0,F.logWarning("QuickAdd suggester received empty display values. Check your displayItems mapping."))}}});var gs=b(()=>{});var Ut,La=b(()=>{Yr();Vc();Cu();Me();Ut=class extends ui{constructor(e){super(e,"EditorCommand"),this.editorCommandType=e}static getSelectedText(e){return this.getActiveMarkdownView(e).editor.getSelection()}static getActiveMarkdownView(e){let t=On(e);if(!t)throw F.logError("no active markdown editor."),new Error("no active markdown editor.");return t}}});var Vh,A$=b(()=>{gs();La();Vh=class extends Ut{constructor(){super("Copy")}static async run(e){let t=Ut.getSelectedText(e);await navigator.clipboard.writeText(t)}}});var qh,k$=b(()=>{gs();La();Me();qh=class extends Ut{constructor(){super("Cut")}static async run(e){let t=Ut.getSelectedText(e),n=Ut.getActiveMarkdownView(e);if(!t){F.logError("nothing selected.");return}await navigator.clipboard.writeText(t),n.editor.replaceSelection("")}}});var Wh,S$=b(()=>{gs();Me();La();Wh=class extends Ut{constructor(){super("Paste")}static async run(e){let t=await navigator.clipboard.readText(),n=Ut.getActiveMarkdownView(e);if(!n){F.logError("no active markdown view.");return}n.editor.replaceSelection(t)}}});var KG,zh,D$=b(()=>{KG=require("obsidian");Me();La();gs();zh=class extends Ut{constructor(){super("Paste with format")}static async run(e){let t=Ut.getActiveMarkdownView(e);if(!t){F.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,KG.htmlToMarkdown)(l),o=!0;break}o||(n=await navigator.clipboard.readText())}else n=await navigator.clipboard.readText();t.editor.replaceSelection(n)}catch(i){F.logWarning(`Formatted paste failed. Falling back to plain text: ${i}`);try{let o=await navigator.clipboard.readText();t.editor.replaceSelection(o)}catch(o){F.logError(`Failed to read clipboard text: ${o}`)}}}}});var Hh,I$=b(()=>{gs();La();Hh=class extends Ut{constructor(){super("Select active line")}static run(e){let t=Ut.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 jh,P$=b(()=>{La();gs();Tt();Me();jh=class extends Ut{constructor(){super("Select link on active line")}static run(e){let t=Ut.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n),o=lB.exec(i);if(!o){F.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 Gh,F$=b(()=>{La();gs();Gh=class extends Ut{constructor(){super("Move cursor to file start")}static run(e){Ut.getActiveMarkdownView(e).editor.setCursor({line:0,ch:0})}}});var Yh,M$=b(()=>{La();gs();Yh=class extends Ut{constructor(){super("Move cursor to file end")}static run(e){let t=Ut.getActiveMarkdownView(e),n=t.editor.lastLine(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});var Kh,R$=b(()=>{La();gs();Kh=class extends Ut{constructor(){super("Move cursor to line start")}static run(e){let t=Ut.getActiveMarkdownView(e),{line:n}=t.editor.getCursor();t.editor.setCursor({line:n,ch:0})}}});var Xh,$$=b(()=>{La();gs();Xh=class extends Ut{constructor(){super("Move cursor to line end")}static run(e){let t=Ut.getActiveMarkdownView(e),{line:n}=t.editor.getCursor(),i=t.editor.getLine(n).length;t.editor.setCursor({line:n,ch:i})}}});function fY(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 que){let o=t[i];o!==void 0&&n.push(...fY(o,e))}return n}function zk(r){return Number(r.replace(/,/g,""))}function Wue(r){let e=r.match(/context (?:length|window)(?:\s+is)?(?:\s+of)?\s*(\d[\d,]*)/i);return e?zk(e[1]):null}function zue(r){let e=r.match(/(\d[\d,]*)\s*(?:tokens?\s+)?in the completion\b/i);if(e){let n=zk(e[1]),i=Wue(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=zk(t[2]),i=t[3]?zk(t[3]):null;return i===null?"input":n>=i?"output":"input"}return null}function wx(r){let e=fY(r).join(" "),t=zue(e);return t==="output"?"output_budget":t==="input"?"input_context":Vue.some(n=>n.test(e))?"output_budget":Uue.some(n=>n.test(e))?"input_context":"other"}function mY(r){return wx(r)==="input_context"}function Hk(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 Uue,Vue,que,Cx=b(()=>{Uue=[/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],Vue=[/max_tokens/i,/max_completion_tokens/i,/max(?:imum)? output tokens/i,/output token limit/i],que=["message","code","type","status","statusText","providerCode","error","response","json","cause"]});function tde(r){return r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||"provider"}function rde(r){let e=r.name?.trim()||"provider";return`${ede}-${tde(e)}`}async function yY(r,e){if(!r?.secretStorage?.getSecret)return null;try{return await Promise.resolve(r.secretStorage.getSecret(e))}catch(t){return F.logWarning(`Failed to read SecretStorage entry "${e}": ${t.message??t}`),null}}async function Ua(r,e){let t=e.apiKeyRef?.trim();if(t){let n=await yY(r,t);if(n)return n}return e.apiKey??""}async function bY(r,e,t){let n=t?.trim();if(!n||!r?.secretStorage?.getSecret||!r.secretStorage?.setSecret)return null;let i=rde(e),o=i,s=1;for(;;){let a=await yY(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 F.logWarning(`Failed to write SecretStorage entry "${o}": ${a.message??a}`),null}}var ede,Xp=b(()=>{Me();ede="quickadd-ai"});function GY(r){try{let e=window.require;return e?e(r):null}catch{return null}}async function lg(r,e){let t=r.vault.adapter;if(typeof oO.FileSystemAdapter!="function"||!(t instanceof oO.FileSystemAdapter))return;let n=GY("fs"),i=GY("path");if(!n?.promises||!i)return;let o=await n.promises.realpath(t.getBasePath()),a=t.getFullPath(e);for(;!lpe(n,a);){let f=i.dirname(a);if(f===a)break;a=f}let l;try{l=await n.promises.realpath(a)}catch{throw new Ex(`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 Ex(`Refusing to write to "${e}": it resolves (via a symlink) outside the vault.`);if(c.split(i.sep).some(f=>f.startsWith(".")))throw new Ex(`Refusing to write to "${e}": it resolves (via a symlink) into a config/hidden directory.`)}function lpe(r,e){try{return r.lstatSync(e),!0}catch{return!1}}var oO,Ex,sO=b(()=>{oO=require("obsidian"),Ex=class extends Error{constructor(e){super(e),this.name="VaultWriteEscapeError"}}});var Ee,Co=b(()=>{Os();Ee=class extends Nt{}});var S4,Nr,Wc=b(()=>{S4=require("obsidian");Me();Fo();Wr();Nr=class r extends S4.FuzzySuggestModal{constructor(t,n,i,o,s){super(t);this.warnedOnEmptyDisplay=!1;this.warnRenderItemFailure=mp("Custom renderItem threw an error; falling back to default rendering");this.renderItem=o,this.items=i,this.displayItems=n.map(a=>fn(a)),this.promise=new Promise((a,l)=>{this.resolvePromise=a,this.rejectPromise=l}),s?.skippable&&QT(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 fn(c??a)})),this.warnIfEmptyDisplay(),this.open()}static Suggest(t,n,i,o,s,a){let l=new r(t,n,i,s,a);return o&&l.setPlaceholder(o),l.promise}getItemText(t){let n=this.items.indexOf(t),i=n>=0?this.displayItems[n]:void 0;return fn(i??t)}getItems(){return this.items}getSuggestions(t){let n=Cc(t);return super.getSuggestions(n)}selectSuggestion(t,n){this.resolved=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){if(!this.renderItem){super.renderSuggestion(t,n);return}try{n.empty(),this.renderItem(t.item,n)}catch(i){this.warnRenderItemFailure(i),n.empty(),super.renderSuggestion(t,n)}}onChooseItem(t,n){this.resolved=!0,this.resolvePromise(t)}skip(){this.resolved=!0,this.resolvePromise(""),this.close()}onClose(){super.onClose(),this.resolved||this.rejectPromise(tn())}warnIfEmptyDisplay(){if(this.warnedOnEmptyDisplay)return;this.displayItems.some(n=>n.length===0)&&(this.warnedOnEmptyDisplay=!0,F.logWarning("QuickAdd suggester received empty display values. Check your displayItems mapping."))}}});function Mi(r,e){if(!r)throw new Error(typeof e=="function"?e():e)}var Sx=b(()=>{});function dg(r){return _O.filter(e=>typeof r[e]=="number")}function _S(r){let e={...r};for(let t of _O)delete e[t];return e}function AO(r,e){return r.supportsTemperature===!1&&dg(e).length>0?_S(e):e}function kO(r,e){return e.length===0?!1:$fe.some(t=>t.test(r))}function AS(r){let e=r.map(t=>Rfe[t]);return e.length<=1?e.join(""):e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")}, and ${e[e.length-1]}`}var _O,Rfe,TS,$fe,D4=b(()=>{_O=["temperature","top_p","frequency_penalty","presence_penalty"],Rfe={temperature:"Temperature",top_p:"Top P",frequency_penalty:"Frequency penalty",presence_penalty:"Presence penalty"};TS=_O.join("|"),$fe=[new RegExp(`unsupported (?:parameter|value)[^.]{0,40}['\`"]?(?:${TS})['\`"]?`,"i"),new RegExp(`['\`"]?(?:${TS})['\`"]?[^.]{0,40}(?:is deprecated|is not supported|not supported|does not support)`,"i"),new RegExp(`unrecognized request argument[^.]{0,40}(?:${TS})`,"i"),new RegExp(`(?:${TS})[^.]{0,40}extra inputs are not permitted`,"i")]});function kS(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 SO=b(()=>{});function Dx(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]=Dx(o);e.properties=n}return e.items&&!Array.isArray(e.items)&&(e.items=Dx(e.items)),t&&(e.additionalProperties=!1,e.required=e.properties?Object.keys(e.properties):[]),e}function Ofe(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 Nfe(r){return r.map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:e.strict?Dx(e.parameters):e.parameters,...e.strict?{strict:!0}:{}}}))}function Lfe(r){return typeof r=="string"?r:{type:"function",function:{name:r.name}}}function Ufe(r,e){let t={model:r,...e.modelParams??{},messages:Ofe(e.messages)};return e.tools&&e.tools.length>0&&(t.tools=Nfe(e.tools),e.toolChoice&&(t.tool_choice=Lfe(e.toolChoice)),e.disableParallel&&(t.parallel_tool_calls=!1)),e.maxOutputTokens!==void 0&&(Bfe.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?Dx(e.responseFormat.schema):e.responseFormat.schema}}:{type:"json_object"}),t}function Vfe(r){let e=r.choices?.[0]??{},t=e.message??{},i=(t.tool_calls??[]).map(a=>qfe(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 I4(r){return r!==null&&typeof r=="object"&&!Array.isArray(r)?r:null}function qfe(r){let e=r.function.arguments;if(typeof e=="string")try{let n=I4(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=I4(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 Wfe(r,e,t){let n=[],i=[];for(let a of e.messages)if(a.role==="system")a.content&&n.push(a.content);else if(a.role==="user")i.push({role:"user",content:a.content});else if(a.role==="assistant"){let l=[];a.content&&l.push({type:"text",text:a.content});for(let c of a.toolCalls??[])l.push({type:"tool_use",id:c.id,name:c.name,input:c.args??{}});i.push({role:"assistant",content:l})}else i.push({role:"user",content:a.results.map(l=>({type:"tool_result",tool_use_id:l.toolCallId,content:l.content,...l.isError?{is_error:!0}:{}}))});let o={model:r,max_tokens:e.maxOutputTokens??t,messages:i};n.length>0&&(o.system=n.join(`
|
||
|
||
`));let s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.top_p=s.top_p),e.tools&&e.tools.length>0&&(o.tools=e.tools.map(a=>({name:a.name,description:a.description,input_schema:a.parameters})),e.toolChoice?o.tool_choice=zfe(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:Dx(e.responseFormat.schema)}}),o}function zfe(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 Hfe(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 jfe(r,e){let t=[],n=[];for(let a of e.messages)if(a.role==="system")a.content&&t.push(a.content);else if(a.role==="user")n.push({role:"user",parts:[{text:a.content}]});else if(a.role==="assistant")if(Array.isArray(a.providerRaw))n.push({role:"model",parts:a.providerRaw});else{let l=[];a.content&&l.push({text:a.content});for(let c of a.toolCalls??[])l.push({functionCall:{name:c.name,args:c.args??{}}});n.push({role:"model",parts:l})}else n.push({role:"user",parts:a.results.map(l=>({functionResponse:{name:l.name,response:l.isError?{error:l.content}:{result:l.content}}}))});let i={contents:n};t.length>0&&(i.systemInstruction={role:"system",parts:[{text:t.join(`
|
||
|
||
`)}]}),e.tools&&e.tools.length>0&&(i.tools=[{functionDeclarations:e.tools.map(a=>({name:a.name,description:a.description,parameters:a.parameters}))}],e.toolChoice&&(i.toolConfig=Gfe(e.toolChoice)));let o={},s=e.modelParams??{};return typeof s.temperature=="number"&&(o.temperature=s.temperature),typeof s.top_p=="number"&&(o.topP=s.top_p),e.maxOutputTokens!==void 0&&(o.maxOutputTokens=e.maxOutputTokens),e.responseFormat?.schema&&(o.responseMimeType="application/json",o.responseSchema=e.responseFormat.schema),Object.keys(o).length>0&&(i.generationConfig=o),i}function Gfe(r){return typeof r=="string"?{functionCallingConfig:{mode:r==="required"?"ANY":r==="none"?"NONE":"AUTO"}}:{functionCallingConfig:{mode:"ANY",allowedFunctionNames:[r.name]}}}function Yfe(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 DO(r,e,t,n=8192){switch(r){case"anthropic":return Wfe(e,t,n);case"gemini":return jfe(e,t);default:return Ufe(e,t)}}function P4(r,e){switch(r){case"anthropic":return Hfe(e);case"gemini":return Yfe(e);default:return Vfe(e)}}var Bfe,F4=b(()=>{Bfe=/^(?:o[1-9]|gpt-(?:[5-9]|\d\d))/i});async function pg(r,e,t){let n=(0,Px.requestUrl)({...r,throw:!1});t&&t();let i=await n;if(i.status>=400)throw Hk(e,i);return i.json}function Kfe(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 Xfe(r){return{id:r.id,model:r.model,content:r.content.filter(e=>e.type==="text").map(e=>e.text??"").join(""),usage:{promptTokens:r.usage.input_tokens,completionTokens:r.usage.output_tokens,totalTokens:r.usage.input_tokens+r.usage.output_tokens},stopReason:r.stop_reason,stopSequence:r.stop_sequence,created:Date.now()}}async function Qfe(r,e,t,n,i,o,s){return pg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${r}`},body:JSON.stringify({model:e.name,...i,messages:[{role:"system",content:n},{role:"user",content:o}]})},t.name,s)}function IO(r){if(typeof r.maxOutputTokens=="number"&&Number.isFinite(r.maxOutputTokens)&&r.maxOutputTokens>0)return Math.floor(r.maxOutputTokens);let e=4096;return Number.isFinite(r.maxTokens)&&r.maxTokens>0?Math.min(e,r.maxTokens):e}async function Zfe(r,e,t,n,i,o,s){let a={model:e.name,max_tokens:IO(e),messages:[{role:"user",content:o}]};return n&&n.trim().length>0&&(a.system=n),typeof i.temperature=="number"&&(a.temperature=i.temperature),typeof i.top_p=="number"&&(a.top_p=i.top_p),pg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":r,"anthropic-version":"2023-06-01"},body:JSON.stringify(a)},t.name,s)}async function Jfe(r,e,t,n,i,o,s){let a=`${t.endpoint}/v1beta/models/${encodeURIComponent(e.name)}:generateContent`,l={};typeof i.temperature=="number"&&(l.temperature=i.temperature),typeof i.top_p=="number"&&(l.topP=i.top_p);let c={contents:[{role:"user",parts:[{text:o}]}]};return n&&n.trim().length>0&&(c.systemInstruction={role:"system",parts:[{text:n}]}),Object.keys(l).length>0&&(c.generationConfig=l),pg({url:a,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":r},body:JSON.stringify(c)},t.name,s)}function eme(r){let e=r.candidates?.[0],n=(e?.content?.parts??[]).map(i=>typeof i.text=="string"?i.text:"").join("");return{id:`${Date.now()}`,model:r.modelVersion??"gemini",content:n,usage:{promptTokens:r.usageMetadata?.promptTokenCount??0,completionTokens:r.usageMetadata?.candidatesTokenCount??0,totalTokens:r.usageMetadata?.totalTokenCount??0},stopReason:e?.finishReason??"",stopSequence:null,created:Date.now()}}function SS(r,e,t,n,i,o={}){return async function(a){if(ce.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let l=Uo(a)+Uo(i),c=Date.now(),u=MO({provider:n.name,endpoint:n.endpoint,model:t.name,systemPrompt:i,prompt:a,modelOptions:o});F.logMessage(`[AI Request ${u}] Started ${n.name}/${t.name}`),Number.isFinite(t.maxTokens)&&t.maxTokens>0&&l>t.maxTokens&&F.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=kS(r),f=Rv(n),p=async w=>f==="anthropic"?Xfe(await Zfe(e,t,n,i,w,a,d)):f==="gemini"?eme(await Jfe(e,t,n,i,w,a,d)):Kfe(await Qfe(e,t,n,i,w,a,d)),m=AO(t,o),v=dg(m);v.length===0&&dg(o).length>0&&F.logMessage(`[AI Request ${u}] ${t.name} uses fixed sampling; not sending ${AS(dg(o))}.`);let g;try{g=await p(m)}catch(w){let x=w.message??String(w);if(!kO(x,v))throw w;let C=AS(v);F.logMessage(`[AI Request ${u}] ${n.name} rejected ${C}; retrying without sampling parameters.`),new Px.Notice(`${t.name} doesn't accept the ${C} setting${v.length>1?"s":""}, so QuickAdd retried without ${v.length>1?"them":"it"}. You can remove ${v.length>1?"them":"it"} from this command's advanced settings.`),g=await p(_S(m))}let y=Date.now()-c;return Ix(u,{status:"success",durationMs:y,usage:g.usage}),F.logMessage(`[AI Request ${u}] Success in ${y}ms`),g}catch(d){let f=d.message??String(d),p=Date.now()-c;Ix(u,{status:"error",durationMs:p,errorMessage:f}),F.logMessage(`[AI Request ${u}] Failed in ${p}ms: ${f}`);let m=wx(d)==="input_context"?" The prompt likely exceeds the model's context window \u2014 shorten it, choose a model with a larger context, or use the chunked AI prompt API.":"",v=new Error(`Error while making request to ${n.name}: ${f}${m}`,{cause:d});throw lt(v),v}}}async function M4(r,e,t,n,i,o){if(r==="anthropic")return pg({url:`${t.endpoint}/v1/messages`,method:"POST",headers:{"Content-Type":"application/json","x-api-key":e,"anthropic-version":"2023-06-01"},body:JSON.stringify(i)},t.name,o);if(r==="gemini"){let s=`${t.endpoint}/v1beta/models/${encodeURIComponent(n.name)}:generateContent`;return pg({url:s,method:"POST",headers:{"Content-Type":"application/json","x-goog-api-key":e},body:JSON.stringify(i)},t.name,o)}return pg({url:`${t.endpoint}/chat/completions`,method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(i)},t.name,o)}async function PO(r,e,t,n,i,o){if(ce.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let s=Rv(n),a={...i,modelParams:AO(t,i.modelParams??{})},l=dg(a.modelParams??{}),c=DO(s,t.name,a,IO(t)),u=i.messages.find(m=>m.role==="system"),d=[...i.messages].reverse().find(m=>m.role==="user"),f=Date.now(),p=MO({provider:n.name,endpoint:n.endpoint,model:t.name,systemPrompt:u&&u.role==="system"?u.content:"",prompt:d&&d.role==="user"?d.content:"[tool-calling turn]",modelOptions:i.modelParams??{}});try{let m;try{m=await M4(s,e,n,t,c,o)}catch(y){let w=y.message??String(y);if(!kO(w,l))throw y;let x=AS(l);F.logMessage(`[AI Chat ${p}] ${n.name} rejected ${x}; retrying without sampling parameters.`),new Px.Notice(`${t.name} doesn't accept the ${x} setting${l.length>1?"s":""}, so QuickAdd retried without ${l.length>1?"them":"it"}.`);let C=DO(s,t.name,{...a,modelParams:_S(a.modelParams??{})},IO(t));m=await M4(s,e,n,t,C,o)}let v=P4(s,m),g=Date.now()-f;return Ix(p,{status:"success",durationMs:g,usage:v.usage}),F.logMessage(`[AI Chat ${p}] Success in ${g}ms`),{id:m.id??`${Date.now()}`,model:t.name,content:v.content,usage:v.usage,stopReason:v.rawStopReason,stopSequence:null,created:Date.now(),toolCalls:v.toolCalls,normalizedStopReason:v.normalizedStopReason,providerRaw:v.providerRaw}}catch(m){let v=m.message??String(m),g=Date.now()-f;Ix(p,{status:"error",durationMs:g,errorMessage:v});let y=new Error(`Error while making request to ${n.name}: ${v}`,{cause:m});throw lt(y),y}}var Px,FO=b(()=>{Px=require("obsidian");D4();It();DS();SO();Cr();es();F4();Me();px();Cx()});function fg(r){if(r){let e=new $4.Notice(R4("starting",""),1e6);return{setMessage:(t,n)=>{e.setMessage(R4(t,n))},hide:()=>e.hide()}}return{setMessage:()=>{},hide:()=>{}}}var $4,R4,RO=b(()=>{$4=require("obsidian"),R4=(r,e)=>`${r==="dead"?"AI request failed.":`Assistant is ${r}.`}${e?`
|
||
|
||
${e}`:""}`});function NO(r){return{...r,modelOptions:{...r.modelOptions},usage:r.usage?{...r.usage}:void 0}}function MO(r){let e=`${Date.now()}-${Math.random().toString(36).slice(2,8)}`,t=Date.now();return ea.push({...r,modelOptions:{...r.modelOptions??{}},id:e,createdAt:t,status:"pending"}),B4(),e}function Ix(r,e){let t=ea.find(n=>n.id===r);t&&(t.status=e.status,t.durationMs=e.durationMs,t.usage=e.usage,t.errorMessage=e.errorMessage,B4())}function L4(r=10){Number.isFinite(r)||(r=10);let e=Math.floor(r);return e<=0?[]:ea.slice(-e).map(NO).reverse()}function B4(){if(ea.length<=O4)return;let r=ea.length-O4;for(;r>0;){let e=ea.findIndex(t=>t.status!=="pending");if(e===-1)break;ea.splice(e,1),r-=1}}function U4(r){let e=ea.find(t=>t.id===r);return e?NO(e):null}function V4(){let r=ea[ea.length-1];return r?NO(r):null}function q4(){ea.splice(0,ea.length)}async function tme(r,e,t){if(typeof r!="function")throw new TypeError("Callback must be a function.");if(!(e instanceof Promise))throw new TypeError("Promise must be an instance of Promise.");if(typeof t!="number"||t<=0)throw new TypeError("Interval must be a positive number.");let n=!1;for(e.then(()=>{n=!0},()=>{n=!0});!n;)r(),await sleep(t)}function rme(r){return r instanceof Error?r:new Error(String(r))}async function nme(r,e,t,n=!0,i){let o;if(e.enable)o=t.find(c=>c.path.endsWith(e.name));else{let c=t.map(u=>u.basename);if(i)o=await i.suggester(c,t,"Select a prompt template");else if(n)o=await Nr.Suggest(r,c,t);else throw new Ee("This AI command asks which prompt template to use, but this run is non-interactive. Enable a specific prompt template in the command, or re-run with the ui flag.")}Mi(o,"Prompt template does not exist");let s=o.path,a=r.vault.getAbstractFileByPath(s);Mi(a instanceof N4.TFile,`${s} is not a file`);let l=await r.vault.cachedRead(a);return[o.basename,l]}async function W4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,promptTemplate:l,systemPrompt:c,promptTemplateFolder:u}=e,d=rs(r,u),[f,p]=await nme(r,l,d,e.interactive??!0,e.promptProvider);n.setMessage("waiting","QuickAdd is formatting the prompt template.");let m=await t(p),v=["prompting",`Using prompt template "${f}".`];n.setMessage(v[0],v[1]);let y=SS(r,i,o,s,c,e.modelOptions)(m),x=(await LO(y,100,E=>{n.setMessage(v[0],`${v[1]} (${(E/1e3).toFixed(2)}s)`)},E=>{n.setMessage("finished",`Took ${(E/1e3).toFixed(2)}s.`)})).content,C=("> "+x).replace(/\n/g,`
|
||
> `),_={[a]:x,[`${a}-quoted`]:C};return window.setTimeout(()=>n.hide(),5e3),_}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),Dt(i)?new St("Input cancelled by user"):i}}async function LO(r,e,t,n){let i=Date.now();return await tme(()=>t(Date.now()-i),r,e),n(Date.now()-i),await r}async function z4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,prompt:c,modelOptions:u}=e;n.setMessage("waiting","QuickAdd is formatting the prompt template.");let d=await t(c),f=["prompting","Using custom prompt."];n.setMessage(f[0],f[1]);let m=SS(r,i,o,s,l,u)(d),g=(await LO(m,100,x=>{n.setMessage(f[0],`${f[1]} (${(x/1e3).toFixed(2)}s)`)},x=>{n.setMessage("finished",`Took ${(x/1e3).toFixed(2)}s.`)})).content,y=("> "+g).replace(/\n/g,`
|
||
> `),w={[a]:g,[`${a}-quoted`]:y};return window.setTimeout(()=>n.hide(),5e3),w}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}function ome(){return Array.from(new Set([OO,...["kebab","snake","camel","pascal","title","lower","upper","slug"].map(r=>$_(OO,r))])).filter(Boolean)}function j4(r){if(r.length<=1)return null;let e=Math.floor(r.length/2),t=[`
|
||
|
||
`,`
|
||
`,". "," "],n=-1,i=Number.POSITIVE_INFINITY;for(let a of t){let l=r.lastIndexOf(a,e),c=r.indexOf(a,e),u=[l,c].filter(d=>d>0);for(let d of u){let f=d+a.length;if(f<=0||f>=r.length)continue;let p=Math.abs(f-e);p<i&&(i=p,n=f)}}if(n>0&&n<r.length)return[r.slice(0,n),r.slice(n)];let o=e,s=r.charCodeAt(o);return s>=56320&&s<=57343&&(o+=1),o<=0||o>=r.length?null:[r.slice(0,o),r.slice(o)]}function sme(r){let e=new RegExp(Hd.source,"gi"),t;for(;(t=e.exec(r))!==null;)if(t[1].split("|")[0].trim().toLowerCase()==="chunk")return!0;return!1}function ame(r){return Rs.test(r)||vu.test(r)||pl.test(r)||dc.test(r)}function lme(r){return H4.some(e=>r.includes(e))}function cme(r){return H4.slice().sort((e,t)=>t.length-e.length).reduce((e,t)=>e.split(t).join(" "),r)}function G4(r){if(r>IS)throw new Error(`QuickAdd would split this chunked AI request into more than ${IS} prompts, which exceeds the safety limit. Increase the chunk size, use a larger chunk separator, or reduce the input text.`)}function ume(r,e,t){let n=Math.max(1,Math.floor(e)),i=[r],o=0;for(;i.length>0;){let s=i.pop(),l=Uo(s)<=n?null:j4(s);if(!l){t.push(s),o+=1,G4(o);continue}i.push(l[1],l[0])}}function dme(r){let e=r.flags.replace(/[gy]/g,"");return new RegExp(r.source+"|",e).exec("").length-1}function fme(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(dme(e)>0||pme.test(e.source))return{chunks:r.split(e),separators:null};let t=new RegExp(`(${e.source})`,e.flags),n=r.split(t),i=[],o=[];for(let s=0;s<n.length;s++)s%2===0?i.push(n[s]):o.push(n[s]);return{chunks:i,separators:o}}function mme(r,e,t,n){let i=[];if(r.forEach((l,c)=>{let u=[];ume(l,t,u),u.forEach((d,f)=>{i.push({text:d,joiner:f===0&&c>0?e?.[c-1]??"":""})})}),!n)return i.map(l=>l.text);let o=[],s="",a=0;for(let l of i){let c=Uo(l.text)+Math.max(1,Uo(l.joiner));s!==""&&a+c>=t&&(o.push(s),s="",a=0),s+=s===""?l.text:l.joiner+l.text,a+=c}return s!==""&&o.push(s),o}function hme(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 Y4(r,e,t){if(ce.getState().disableOnlineFeatures)throw new Error("Online features are disabled in settings. Enable them to use the AI Assistant.");let n=fg(e.showAssistantMessages);try{let{apiKey:i,model:o,provider:s,outputVariableName:a,systemPrompt:l,promptTemplate:c,text:u,modelOptions:d}=e;n.setMessage("chunking","Creating prompt chunks with text and prompt template");let f=e.chunkSeparator||/\n/g,{chunks:p,separators:m}=fme(u,f),v=await t(c,{chunk:OO});if(!(sme(c)||ame(c)&&lme(v)))throw new Error("The chunked prompt template does not reference the chunk text. Add {{VALUE:chunk}} to your prompt template so each chunk is inserted.");let y=o.maxTokens,w=$G(y),x=cme(v),C=Uo(l)+Uo(x);if(C>=y)throw new Error(`The estimated prompt overhead (${C} tokens) exceeds the model's entire context window (${y} tokens). Shorten the system prompt or prompt template, or use a model with a larger context window.`);let{budget:_,clamped:E}=hme(w-C,e.maxChunkTokens);E&&F.logMessage(`[ChunkedPrompt] Requested max chunk tokens (${e.maxChunkTokens}) exceeds this model's estimated input budget; using ${_} estimated tokens per chunk instead.`);let D=e.shouldMerge??!0,P=mme(p,m,_,D);G4(P.length);let V=SS(r,i,o,s,l,d),j=["prompting",`${P.length} prompts being sent.`];n.setMessage(j[0],j[1]);let oe=new $O(5,1e3*30),se=!1,M=0,U=Promise.resolve(),q=ge=>{let be=U.then(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");return t(c,{chunk:ge})});return U=be.then(()=>{},()=>{}),be},B=async(ge,be=0)=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");let xe;try{xe=await q(ge)}catch(Ue){throw se=!0,Ue}try{return[(await oe.add(()=>{if(se)throw new Error("Chunked prompt stopped after an earlier failure.");if(M+=1,M>IS)throw new Error(`Chunked AI request exceeded the safety limit of ${IS} provider requests.`);return V(xe)})).content]}catch(Ue){let $t=j4(ge);if(be>=ime||!$t||!mY(Ue))throw se=!0,Ue;n.setMessage("prompting","Provider rejected a prompt for context length. Retrying with smaller chunks.");let[Ne,Ke]=$t,Qe=await B(Ne,be+1),ye=await B(Ke,be+1);return[...Qe,...ye]}},ie=Promise.all(P.map(ge=>B(ge))),X=(await LO(ie,100,ge=>{n.setMessage(j[0],`${j[1]} (${(ge/1e3).toFixed(2)}s)`)},ge=>{n.setMessage("finished",`Took ${(ge/1e3).toFixed(2)}s.`)})).flat().join(e.resultJoiner),ae=("> "+X).replace(/\n/g,`
|
||
> `),pe={[a]:X,[`${a}-quoted`]:ae};return window.setTimeout(()=>n.hide(),5e3),pe}catch(i){throw n.setMessage("dead",i.message),window.setTimeout(()=>n.hide(),5e3),i}}var N4,O4,ea,$O,ime,IS,OO,H4,pme,DS=b(()=>{N4=require("obsidian");Wr();Co();Wc();It();qt();Sx();Cr();FO();Cx();RO();px();Me();Tt();O_();O4=25,ea=[];$O=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(rme(i))}}),this.schedule()})}schedule(){if(this.queue.length===0)return;let e=Date.now();if(this.startTimes=this.startTimes.filter(i=>e-i<this.intervalMs),this.startTimes.length>=this.maxRequests){let i=this.startTimes[0],o=Math.max(0,this.intervalMs-(e-i));window.setTimeout(()=>this.schedule(),o+1);return}let t=this.queue.shift();if(!t)return;this.startTimes.push(e);let n=t();window.setTimeout(()=>this.schedule(),this.intervalMs),this.schedule()}},ime=12,IS=500,OO="quickadd_chunk_probe_123456789";H4=ome();pme=/(?:^|[^\\])(?:\\\\)*\\[1-9]/});function K4(r){return r.normalize("NFKD").toLowerCase()}var gme,Qp,BO=b(()=>{gme=0;Qp=class{constructor(e,t){this.options=t;this.instanceId=++gme;this.indexedItems=[];this.renderedRows=[];this.query="";this.rootEl=document.createElement("div"),this.rootEl.className="qa-searchable-multi-select";let n=document.createElement("div");n.className="search-input-container qa-searchable-multi-select__search-container",this.searchInputEl=document.createElement("input"),this.searchInputEl.className="qa-searchable-multi-select__search",this.searchInputEl.type="search",this.searchInputEl.name=`qa-multi-select-search-${this.instanceId}`,this.searchInputEl.placeholder=t.searchPlaceholder??"Search options...",this.searchInputEl.setAttribute("aria-label",this.searchInputEl.placeholder),this.searchInputEl.setAttribute("autocomplete","off"),this.searchInputEl.setAttribute("spellcheck","false"),n.appendChild(this.searchInputEl),this.summaryEl=document.createElement("div"),this.summaryEl.className="qa-searchable-multi-select__summary",this.summaryEl.setAttribute("aria-live","polite"),this.listEl=document.createElement("div"),this.listEl.className="qa-searchable-multi-select__list",this.listEl.setAttribute("role","group"),this.listEl.setAttribute("aria-label","Options"),this.rootEl.append(n,this.summaryEl,this.listEl),e.appendChild(this.rootEl),this.searchInputEl.addEventListener("input",()=>{this.query=this.searchInputEl.value,this.renderList()}),this.searchInputEl.addEventListener("keydown",i=>{if(i.key==="ArrowDown"){i.preventDefault(),this.renderedRows[0]?.input.focus();return}if(i.key==="ArrowUp"){i.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}i.key==="Escape"&&this.query&&(i.preventDefault(),i.stopPropagation(),this.query="",this.searchInputEl.value="",this.renderList())}),this.setItems(t.items)}setItems(e){this.indexedItems=e.map((t,n)=>({item:t,index:n,searchableText:K4(`${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=K4(this.query.trim()).split(/\s+/).filter(Boolean);return e.length===0?this.indexedItems:this.indexedItems.filter(({searchableText:t})=>e.every(n=>t.includes(n)))}getVisibleItems(e){if(e.length<=200)return e;let t=[],n=[];for(let i of e)(this.options.isSelected(i.item)?t:n).push(i);return[...t,...n].slice(0,200)}renderList(){this.listEl.replaceChildren(),this.renderedRows=[];let e=this.getMatchingItems(),t=this.getVisibleItems(e);if(t.length===0){let n=document.createElement("div");n.className="qa-searchable-multi-select__empty",n.setAttribute("role","status"),n.textContent=this.indexedItems.length?`No options match \u201C${this.query.trim()}\u201D`:this.options.emptyText??"No options available",this.listEl.appendChild(n)}for(let n of t)this.renderRow(n);if(e.length>t.length){let n=document.createElement("div");n.className="qa-searchable-multi-select__limit",n.setAttribute("role","status"),n.textContent=`Showing ${t.length} of ${e.length} options. Refine your search to see the rest.`,this.listEl.appendChild(n)}this.updateSummary(e.length)}renderRow(e){let{item:t,index:n}=e,i=document.createElement("label");i.className="qa-searchable-multi-select__option";let o=document.createElement("input");o.type="checkbox",o.name=`qa-multi-select-${this.instanceId}`,o.id=`qa-multi-select-${this.instanceId}-${n}`,o.checked=this.options.isSelected(t);let s=document.createElement("span");s.className="qa-searchable-multi-select__option-label",s.textContent=t.label,i.htmlFor=o.id,i.classList.toggle("is-selected",o.checked),i.append(s,o),o.addEventListener("change",()=>{this.options.onToggle(t,o.checked),this.refreshSelection()}),o.addEventListener("keydown",a=>{this.handleOptionKeydown(a,o)}),this.listEl.appendChild(i),this.renderedRows.push({item:t,input:o})}handleOptionKeydown(e,t){let n=this.renderedRows.findIndex(i=>i.input===t);if(e.key==="ArrowDown"){e.preventDefault(),this.renderedRows[n+1]?.input.focus();return}if(e.key==="ArrowUp"){e.preventDefault(),n===0?this.searchInputEl.focus():this.renderedRows[n-1]?.input.focus();return}if(e.key==="Home"){e.preventDefault(),this.renderedRows[0]?.input.focus();return}if(e.key==="End"){e.preventDefault(),this.renderedRows.at(-1)?.input.focus();return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),t.checked=!t.checked,t.dispatchEvent(new Event("change",{bubbles:!0}));return}e.key==="/"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&(e.preventDefault(),this.searchInputEl.focus())}updateSummary(e=this.getMatchingItems().length){let n=`${this.options.getSelectedCount?.()??new Set(this.indexedItems.filter(({item:i})=>this.options.isSelected(i)).map(({item:i})=>i.key)).size} selected`;if(!this.query.trim()){this.summaryEl.textContent=`${n} \xB7 ${this.indexedItems.length} options`;return}this.summaryEl.textContent=`${n} \xB7 ${e} matches`}}});var sd,Zp,X4=b(()=>{sd=require("obsidian");Fo();Wr();BO();Zp=class r extends sd.Modal{constructor(t,n,i,o={}){super(t);this.didSubmit=!1;this.skipped=!1;this.selected=new Set;this.customValues=[];this.draft="";this.items=i,this.displayItems=n.length===i.length?n:i,this.opts=o,this.seedPreselection(o.preselected),this.waitForClose=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.render(),this.open(),this.picker.focusSearchOnOpen()}static Suggest(t,n,i,o={}){return new r(t,n,i,o).waitForClose}seedPreselection(t){if(t?.length)for(let n of t){let i=n?.trim();i&&(!this.items.includes(i)&&!this.customValues.includes(i)&&this.customValues.push(i),this.selected.add(i))}}render(){this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","qaMultiSuggester"),this.titleEl.setText(this.opts.placeholder??"Select one or more");let{contentEl:t}=this;t.empty();let n=t.createDiv({cls:"qa-multi-list"});this.picker=new Qp(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 sd.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 sd.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:fn(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 sd.Notice(`"${t}" is already added.`),!1):(!this.items.includes(t)&&!this.customValues.includes(t)&&this.customValues.push(t),this.selected.add(t),this.draft="",this.render(),this.focusCustomInput(),!0):(new sd.Notice("Enter a value to add."),!1)}focusCustomInput(){this.contentEl.querySelector(".qa-multi-custom-input")?.focus()}submit(){if(this.opts.allowCustomValue&&this.draft.trim()){let t=this.draft.trim();!this.items.includes(t)&&!this.customValues.includes(t)&&this.customValues.push(t),this.selected.add(t),this.draft=""}this.didSubmit=!0,this.close()}collectResult(){let t=[];for(let n of this.items)this.selected.has(n)&&t.push(n);for(let n of this.customValues)this.selected.has(n)&&t.push(n);return t}onClose(){super.onClose(),this.didSubmit?this.resolvePromise(this.skipped?[]:this.collectResult()):this.rejectPromise(tn())}}});var ad,vme,yme,bme,Z4,UO,Fx,VO,Q4,PS,qO=b(()=>{ad=r=>r.toString().padStart(2,"0"),vme=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},yme=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))},bme=(r,e)=>new Intl.DateTimeFormat(void 0,{month:"long",year:"numeric"}).format(new Date(r,e,1)),Z4=(r,e,t)=>`${r}-${ad(e+1)}-${ad(t)}`,UO=r=>Z4(r.getFullYear(),r.getMonth(),r.getDate()),Fx=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},VO=(r,e,t,n)=>{let i=Z4(r,e,t);return n?`${i}T${ad(n.hour)}:${ad(n.minute)}:00`:i},Q4=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}},PS=r=>{let e=vme(r.weekStartsOn),t=yme(e),n=Fx(r.initialIso)??new Date,i=n.getFullYear(),o=n.getMonth(),s=r.initialIso,a=r.withTime===!0,l=a?Q4(r.initialIso)??{hour:0,minute:0}:null,c=r.container.createDiv({cls:"qa-date-picker"}),u=c.createDiv({cls:"qa-date-picker__header"}),d=u.createEl("button",{cls:"qa-date-picker__nav",text:"\u2039"});d.type="button",d.setAttr("aria-label","Previous month");let f=u.createDiv({cls:"qa-date-picker__label"}),p=u.createEl("button",{cls:"qa-date-picker__nav",text:"\u203A"});p.type="button",p.setAttr("aria-label","Next month");let m=c.createDiv({cls:"qa-date-picker__weekdays"});t.forEach(P=>{let V=m.createDiv({cls:"qa-date-picker__weekday"});V.textContent=P});let v=c.createDiv({cls:"qa-date-picker__grid"}),g=c.createDiv({cls:"qa-date-picker__actions"}),y=g.createEl("button",{cls:"qa-date-picker__action",text:"Today"});y.type="button";let w=g.createEl("button",{cls:"qa-date-picker__action",text:"Clear"});w.type="button";let x;if(a){let P=c.createDiv({cls:"qa-date-picker__time"});P.createEl("label",{cls:"qa-date-picker__time-label",text:"Time"}),x=P.createEl("input",{cls:"qa-date-picker__time-input"}),x.type="time",l&&(x.value=`${ad(l.hour)}:${ad(l.minute)}`)}let C=P=>{o+=P,o>11?(o=0,i+=1):o<0&&(o=11,i-=1),D()},_=(P,V)=>{s=P,r.onSelect(P,V),D()},E=P=>{s=void 0,r.onSelect(null,P),D()};d.addEventListener("click",()=>C(-1)),p.addEventListener("click",()=>C(1)),y.addEventListener("click",()=>{let P=new Date,V=VO(P.getFullYear(),P.getMonth(),P.getDate(),l);i=P.getFullYear(),o=P.getMonth(),_(V,"action")}),w.addEventListener("click",()=>E("action")),x&&x.addEventListener("change",()=>{if(x.value.trim()==="")l={hour:0,minute:0};else{let[P,V]=x.value.split(":").map(j=>Number.parseInt(j,10));if(Number.isNaN(P)||Number.isNaN(V))return;l={hour:P,minute:V}}if(s){let P=Fx(s);P&&_(VO(P.getFullYear(),P.getMonth(),P.getDate(),l),"picker")}});let D=()=>{f.textContent=bme(i,o),v.empty();let V=(new Date(i,o,1).getDay()-e+7)%7,j=new Date(i,o,1-V),oe=UO(new Date),se=s?Fx(s):null,M=se?UO(se):void 0,U=new Intl.DateTimeFormat(void 0,{weekday:"long",year:"numeric",month:"long",day:"numeric"});for(let q=0;q<42;q+=1){let B=new Date(j);B.setDate(j.getDate()+q);let ie=UO(B),W=B.getMonth()!==o,Y=ie===oe,X=M&&ie===M,ae=v.createEl("button",{cls:"qa-date-picker__day",text:String(B.getDate())});ae.type="button",ae.setAttr("aria-label",U.format(B)),W&&ae.addClass("is-outside"),Y&&ae.addClass("is-today"),X&&(ae.addClass("is-selected"),ae.setAttr("aria-pressed","true")),ae.addEventListener("click",()=>{let pe=VO(B.getFullYear(),B.getMonth(),B.getDate(),l);_(pe,"picker")})}};return D(),{setSelectedIso:(P,{updateView:V}={})=>{if(s=P,P&&V!==!1){let j=Fx(P);j&&(i=j.getFullYear(),o=j.getMonth())}if(a&&P){let j=Q4(P);j&&(l=j,x&&(x.value=`${ad(j.hour)}:${ad(j.minute)}`))}D()},setViewFromIso:P=>{let V=Fx(P);V&&(i=V.getFullYear(),o=V.getMonth(),D())},destroy:()=>{c.remove()}}}});function Jp(r,e,t=El,n){if(!r||!r.trim())return{isValid:!1,error:"Empty input"};try{let i=n??ce.getState().dateAliases,o=Ov(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 Nl(r,e){if(!window.moment)return null;try{let t=window.moment(r);if(t.isValid())return t.format(e)}catch{}return null}var Mx=b(()=>{uh();It();Wd()});var hg,mg,ef,WO=b(()=>{hg=require("obsidian");zs();qO();Mx();It();Wd();mg=class mg extends Sr{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,hg.debounce)(this.updatePreview.bind(this),250,!0),this.updatePreview()}static Prompt(t,n,i,o,s,a,l){return new mg(t,n,i,o,s,a,l).waitForClose}createInputField(t,n,i){t.addClass("qa-date-input");let o=new hg.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=PS({container:this.pickerHostEl,initialIso:this.selectedIso,withTime:this.withTime,onSelect:t=>{t?this.applyPickerSelection(t):this.clearPickerSelection()}})}createPreviewElement(t){let n=t.createDiv("vdate-preview-container");n.createEl("div",{text:"Preview:",cls:"vdate-preview-label"}),this.previewEl=n.createEl("div",{cls:"vdate-preview-text"}),this.previewEl.textContent=mg.PREVIEW_PLACEHOLDER;let i=Nv(ce.getState().dateAliases);if(i.length>0){let o=n.createEl("details",{cls:"vdate-alias-details"});o.createEl("summary",{text:`Aliases (${i.length})`}).addClass("vdate-alias-summary");let a=o.createEl("div",{cls:"vdate-alias-list"});a.textContent=hT(ce.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":mg.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=Nl(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=Jp(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=Jp(this.defaultValue,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`}if(n){let i=Jp(n,this.dateFormat);if(i.isValid&&i.isoString)return`@date:${i.isoString}`;new hg.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()}};mg.PREVIEW_PLACEHOLDER="Preview will appear here";ef=mg});function wme(r,e,t,n={}){let i=n.tab??" ";if(e===t){let d=e+i.length;return{regionStart:e,regionEnd:e,replacement:i,selectionStart:d,selectionEnd:d}}let o=e===0?0:r.lastIndexOf(`
|
||
`,e-1)+1,a=r.slice(o,t).split(`
|
||
`),l=a.length-1,c=0,u=a.map((d,f)=>f===l&&d===""?d:(c+=i.length,i+d));return{regionStart:o,regionEnd:t,replacement:u.join(`
|
||
`),selectionStart:e+i.length,selectionEnd:t+c}}function Cme(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 J4(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;Cme(r,wme(r.value,o,s,e))};r.addEventListener("keydown",t);let n=!1;return()=>{n||(n=!0,r.removeEventListener("keydown",t))}}var e5=b(()=>{});var gg,ld,zO=b(()=>{gg=require("obsidian");SP();DP();IP();PP();FP();e5();zs();h_();Wr();ld=class r extends gg.Modal{constructor(t,n,i,o,s,a,l){super(t);this.header=n;this.linkSourcePath=s;this.options=l;this.didSubmit=!1;this.didClose=!1;this.submitClickCallback=t=>this.submit();this.cancelClickCallback=t=>this.cancel();this.skipClickCallback=t=>this.skip();this.submitEnterCallback=t=>{if(this.isOptionalPrompt&&RP(t)){t.preventDefault(),this.skip();return}(t.ctrlKey||t.metaKey)&&t.key==="Enter"&&(t.preventDefault(),this.submit())};this.placeholder=i??"",this.description=a?.trim()||void 0,this.draftHandler=new _m({kind:"multi",header:this.header,placeholder:this.placeholder,linkSourcePath:this.linkSourcePath,scopeId:l?.draftScopeId}),this.input=this.draftHandler.hydrate(o??""),this.waitForClose=new Promise((c,u)=>{this.resolvePromise=c,this.rejectPromise=u}),this.display(),this.open(),this.fileSuggester=new xm(t,this.inputComponent.inputEl,{sourcePath:this.linkSourcePath}),this.tagSuggester=new Em(t,this.inputComponent.inputEl)}static Prompt(t,n,i,o,s,a){return new r(t,n,i,o,void 0,s,a).waitForClose}static PromptWithContext(t,n,i,o,s,a,l){return new r(t,n,i,o,s,a,l).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaWideInputPrompt"),this.contentEl.empty(),this.titleEl.textContent=this.header,d_(this.contentEl,this.options?.contextLine,this.options?.contextLineFull),this.description&&this.contentEl.createDiv({text:this.description,cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"}),this.isOptionalPrompt&&this.contentEl.createDiv({text:"Optional \u2014 leave empty, press Skip, or ctrl/cmd+shift+\u21B5.",cls:"setting-item-description"}).setCssStyles({marginBottom:"0.75rem"});let t=this.contentEl.createDiv();this.inputComponent=this.createInputField(t,this.placeholder,this.input),this.createButtonBar(t)}createInputField(t,n,i){let o=new gg.TextAreaComponent(t);return o.inputEl.classList.add("wideInputPromptInputEl"),o.inputEl.setAttribute("dir","auto"),o.setPlaceholder(n??"").setValue(i??"").onChange(s=>this.onInputChanged(s)).inputEl.addEventListener("keydown",this.submitEnterCallback),this.disposeIndent=J4(o.inputEl),this.options?.imagePaste&&(this.imagePasteHandle=Am(this.app,o.inputEl,this.options.imagePaste)),o}createButton(t,n,i){let o=new gg.ButtonComponent(t);return o.setButtonText(n).onClick(i),o}get isOptionalPrompt(){return this.options?.optional===!0}createButtonBar(t){let n=t.createDiv();if(this.createButton(n,"Ok",this.submitClickCallback).setCta().buttonEl.setCssStyles({marginRight:"0"}),this.createButton(n,"Cancel",this.cancelClickCallback),this.isOptionalPrompt){let i=this.createButton(n,"Skip",this.skipClickCallback);i.setTooltip("Leave this field empty"),i.buttonEl.setAttribute("aria-label","Skip and leave empty")}n.setCssStyles({display:"flex",flexDirection:"row-reverse",justifyContent:"flex-start",marginTop:"1rem",gap:"0.5rem"})}submit(){if(!(this.didSubmit||this.didClose)){if(this.imagePasteHandle?.isBusy()){this.imagePasteHandle.whenIdle().then(()=>this.submit());return}this.input=this.inputComponent?.inputEl?.value??this.input,this.didSubmit=!0,this.close()}}skip(){this.didSubmit||(this.input="",this.didSubmit=!0,this.close())}cancel(){this.close()}resolveInput(){this.didSubmit?this.resolvePromise(this.input):this.rejectPromise(tn())}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)}removeInputListener(){this.inputComponent.inputEl.removeEventListener("keydown",this.submitEnterCallback),this.disposeIndent?.(),this.imagePasteHandle?.detach()}onOpen(){super.onOpen(),u_(this.inputComponent.inputEl,this.options)}onClose(){this.didClose=!0,this.didSubmit||this.syncInputFromEl(),this.persistDraft(),this.resolveInput(),this.removeInputListener(),this.fileSuggester?.destroy(),this.tagSuggester?.destroy(),super.onClose()}}});var Rx,t5=b(()=>{zs();vl();Rx=class r extends Sr{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?"":Ma(e,this.options.numeric):e}}});var HO,$x,r5=b(()=>{zs();vl();HO={min:0,max:100,step:1},$x=class r extends Sr{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??HO,o=this.isOptionalPrompt&&!n,s=xy(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=Ma(e,this.options?.slider??HO);t!==""&&(this.sliderEl.value=t),this.onInputChanged(e)}transformInputOnSubmit(e){return e===""&&this.isOptionalPrompt?"":xy(e,this.options?.slider??HO)}}});var vg,n5=b(()=>{zO();zs();t5();r5();hl();vg=class{factory(e){return e==="multiline"?ld:e==="number"?Rx:e==="slider"?$x:ri().settings.inputPrompt==="multi-line"?ld:Sr}}});function Tme(r){return`\\begin{${r}}
|
||
\u261A
|
||
\\end{${r}}\u261A`}var xme,Eme,i5,jO=b(()=>{xme=["\\!","\\,","\\:","\\>","\\;","\\#","\\$","\\%","\\&","\\","_","{ }","|","^{\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"],Eme=["align","align*","alignat","alignat*","array","Bmatrix","bmatrix","cases","eqnarray","eqnarray*","equation","equation*","gather","gather*","matrix","pmatrix","smallmatrix","subarray","Vmatrix","vmatrix"];i5=[...xme,...Eme.map(Tme)]});function Ame(r){if(GO.has(r))return GO.get(r)??null;let e=null;try{e=(0,o5.renderMath)(r,!0)}catch{e=null}return GO.set(r,e),e}function kme(r){return YO===null&&(YO=new Mu(r,{findAllMatches:!0,threshold:.8})),YO}var o5,_me,GO,YO,FS,s5=b(()=>{fl();a_();o5=require("obsidian");jO();hl();_me=new RegExp(/\\([a-z{}A-Z0-9]*)$/),GO=new Map,YO=null;FS=class extends mn{constructor(t){super(ri().app,t);this.inputEl=t;this.lastInput="";this.symbols=Object.assign([],i5)}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=_me.exec(s),l=[];a&&(this.lastInput=a[1],l=this.symbols.filter(d=>d.toLowerCase().contains(this.lastInput)));let c=new Set(l);return kme(this.symbols).search(this.lastInput).map(d=>d.item).filter(d=>c.has(d))}renderSuggestion(t,n){if(t){n.setText(t);let i=Ame(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 Vo,MS,a5=b(()=>{Vo=require("obsidian");hl();jO();s5();Wr();MS=class r extends Vo.Modal{constructor(){super(ri().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 FS(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 Vo.TextAreaComponent(this.contentEl);n.inputEl.setCssStyles({width:"100%",height:"10rem"}),this.inputEl=n.inputEl,n.onChange((0,Vo.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,Vo.loadMathJax)()}async mathjaxLoop(t,n){let i=(0,Vo.renderMath)(n,!0);await(0,Vo.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 Vo.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(tn())}submit(){this.didSubmit=!0,this.close()}cancel(){this.close()}onClose(){super.onClose(),this.resolveInput(),this.removeInputListeners()}}});var B8=M7(Ul=>{"use strict";Object.defineProperty(Ul,"__esModule",{value:!0});require("obsidian");var Hc=class extends Error{},n1=class extends Hc{constructor(e){super(`Invalid DateTime: ${e.toMessage()}`)}},i1=class extends Hc{constructor(e){super(`Invalid Interval: ${e.toMessage()}`)}},o1=class extends Hc{constructor(e){super(`Invalid Duration: ${e.toMessage()}`)}},nf=class extends Hc{},qS=class extends Hc{constructor(e){super(`Invalid unit ${e}`)}},qo=class extends Hc{},Ll=class extends Hc{constructor(){super("Zone is an abstract class")}},Te="numeric",Ga="short",bs="long",WS={year:Te,month:Te,day:Te},B5={year:Te,month:Ga,day:Te},Sme={year:Te,month:Ga,day:Te,weekday:Ga},U5={year:Te,month:bs,day:Te},V5={year:Te,month:bs,day:Te,weekday:bs},q5={hour:Te,minute:Te},W5={hour:Te,minute:Te,second:Te},z5={hour:Te,minute:Te,second:Te,timeZoneName:Ga},H5={hour:Te,minute:Te,second:Te,timeZoneName:bs},j5={hour:Te,minute:Te,hourCycle:"h23"},G5={hour:Te,minute:Te,second:Te,hourCycle:"h23"},Y5={hour:Te,minute:Te,second:Te,hourCycle:"h23",timeZoneName:Ga},K5={hour:Te,minute:Te,second:Te,hourCycle:"h23",timeZoneName:bs},X5={year:Te,month:Te,day:Te,hour:Te,minute:Te},Q5={year:Te,month:Te,day:Te,hour:Te,minute:Te,second:Te},Z5={year:Te,month:Ga,day:Te,hour:Te,minute:Te},J5={year:Te,month:Ga,day:Te,hour:Te,minute:Te,second:Te},Dme={year:Te,month:Ga,day:Te,weekday:Ga,hour:Te,minute:Te},e8={year:Te,month:bs,day:Te,hour:Te,minute:Te,timeZoneName:Ga},t8={year:Te,month:bs,day:Te,hour:Te,minute:Te,second:Te,timeZoneName:Ga},r8={year:Te,month:bs,day:Te,weekday:bs,hour:Te,minute:Te,timeZoneName:bs},n8={year:Te,month:bs,day:Te,weekday:bs,hour:Te,minute:Te,second:Te,timeZoneName:bs},af=class{get type(){throw new Ll}get name(){throw new Ll}get ianaName(){return this.name}get isUniversal(){throw new Ll}offsetName(e,t){throw new Ll}formatOffset(e,t){throw new Ll}offset(e){throw new Ll}equals(e){throw new Ll}get isValid(){throw new Ll}},KO=null,zS=class r extends af{static get instance(){return KO===null&&(KO=new r),KO}get type(){return"system"}get name(){return new Intl.DateTimeFormat().resolvedOptions().timeZone}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return o8(e,t,n)}formatOffset(e,t){return Vx(this.offset(e),t)}offset(e){return-new Date(e).getTimezoneOffset()}equals(e){return e.type==="system"}get isValid(){return!0}},US={};function Ime(r){return US[r]||(US[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"})),US[r]}var Pme={year:0,month:1,day:2,era:3,hour:4,minute:5,second:6};function Fme(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 Mme(r,e){let t=r.formatToParts(e),n=[];for(let i=0;i<t.length;i++){let{type:o,value:s}=t[i],a=Pme[o];o==="era"?n[a]=s:Mt(a)||(n[a]=parseInt(s,10))}return n}var RS={},fd=class r extends af{static create(e){return RS[e]||(RS[e]=new r(e)),RS[e]}static resetCache(){RS={},US={}}static isValidSpecifier(e){return this.isValidZone(e)}static isValidZone(e){if(!e)return!1;try{return new Intl.DateTimeFormat("en-US",{timeZone:e}).format(),!0}catch{return!1}}constructor(e){super(),this.zoneName=e,this.valid=r.isValidZone(e)}get type(){return"iana"}get name(){return this.zoneName}get isUniversal(){return!1}offsetName(e,{format:t,locale:n}){return o8(e,t,n,this.name)}formatOffset(e,t){return Vx(this.offset(e),t)}offset(e){let t=new Date(e);if(isNaN(t))return NaN;let n=Ime(this.name),[i,o,s,a,l,c,u]=n.formatToParts?Mme(n,t):Fme(n,t);a==="BC"&&(i=-Math.abs(i)+1);let f=JS({year:i,month:o,day:s,hour:l===24?0:l,minute:c,second:u,millisecond:0}),p=+t,m=p%1e3;return p-=m>=0?m:1e3+m,(f-p)/(60*1e3)}equals(e){return e.type==="iana"&&e.name===this.name}get isValid(){return this.valid}},l5={};function Rme(r,e={}){let t=JSON.stringify([r,e]),n=l5[t];return n||(n=new Intl.ListFormat(r,e),l5[t]=n),n}var s1={};function a1(r,e={}){let t=JSON.stringify([r,e]),n=s1[t];return n||(n=new Intl.DateTimeFormat(r,e),s1[t]=n),n}var l1={};function $me(r,e={}){let t=JSON.stringify([r,e]),n=l1[t];return n||(n=new Intl.NumberFormat(r,e),l1[t]=n),n}var c1={};function Ome(r,e={}){let{base:t,...n}=e,i=JSON.stringify([r,n]),o=c1[i];return o||(o=new Intl.RelativeTimeFormat(r,e),c1[i]=o),o}var Bx=null;function Nme(){return Bx||(Bx=new Intl.DateTimeFormat().resolvedOptions().locale,Bx)}function Lme(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=a1(r).resolvedOptions(),i=r}catch{let l=r.substring(0,t);n=a1(l).resolvedOptions(),i=l}let{numberingSystem:o,calendar:s}=n;return[i,o,s]}}function Bme(r,e,t){return(t||e)&&(r.includes("-u-")||(r+="-u"),t&&(r+=`-ca-${t}`),e&&(r+=`-nu-${e}`)),r}function Ume(r){let e=[];for(let t=1;t<=12;t++){let n=At.utc(2009,t,1);e.push(r(n))}return e}function Vme(r){let e=[];for(let t=1;t<=7;t++){let n=At.utc(2016,11,13+t);e.push(r(n))}return e}function $S(r,e,t,n){let i=r.listingMode();return i==="error"?null:i==="en"?t(e):n(e)}function qme(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 u1=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=$me(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):T1(e,3);return xn(t,this.padTo)}}},d1=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&&fd.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=a1(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()}},p1=class{constructor(e,t,n){this.opts={style:"long",...n},!t&&i8()&&(this.rtf=Ome(e,n))}format(e,t){return this.rtf?this.rtf.format(e,t):ihe(t,e,this.opts.numeric,this.opts.style!=="long")}formatToParts(e,t){return this.rtf?this.rtf.formatToParts(e,t):[]}},Qr=class r{static fromOpts(e){return r.create(e.locale,e.numberingSystem,e.outputCalendar,e.defaultToEN)}static create(e,t,n,i=!1){let o=e||Xr.defaultLocale,s=o||(i?"en-US":Nme()),a=t||Xr.defaultNumberingSystem,l=n||Xr.defaultOutputCalendar;return new r(s,a,l,o)}static resetCache(){Bx=null,s1={},l1={},c1={}}static fromObject({locale:e,numberingSystem:t,outputCalendar:n}={}){return r.create(e,t,n)}constructor(e,t,n,i){let[o,s,a]=Lme(e);this.locale=o,this.numberingSystem=t||s||null,this.outputCalendar=n||a||null,this.intl=Bme(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=qme(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 $S(this,e,l8,()=>{let n=t?{month:e,day:"numeric"}:{month:e},i=t?"format":"standalone";return this.monthsCache[i][e]||(this.monthsCache[i][e]=Ume(o=>this.extract(o,n,"month"))),this.monthsCache[i][e]})}weekdays(e,t=!1){return $S(this,e,d8,()=>{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]=Vme(o=>this.extract(o,n,"weekday"))),this.weekdaysCache[i][e]})}meridiems(){return $S(this,void 0,()=>p8,()=>{if(!this.meridiemCache){let e={hour:"numeric",hourCycle:"h12"};this.meridiemCache=[At.utc(2016,11,13,9),At.utc(2016,11,13,19)].map(t=>this.extract(t,e,"dayperiod"))}return this.meridiemCache})}eras(e){return $S(this,e,f8,()=>{let t={era:e};return this.eraCache[e]||(this.eraCache[e]=[At.utc(-40,1,1),At.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 u1(this.intl,e.forceSimple||this.fastNumbers,e)}dtFormatter(e,t={}){return new d1(e,this.intl,t)}relFormatter(e={}){return new p1(this.intl,this.isEnglish(),e)}listFormatter(e={}){return Rme(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}},XO=null,na=class r extends af{static get utcInstance(){return XO===null&&(XO=new r(0)),XO}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(eD(t[1],t[2]))}return null}constructor(e){super(),this.fixed=e}get type(){return"fixed"}get name(){return this.fixed===0?"UTC":`UTC${Vx(this.fixed,"narrow")}`}get ianaName(){return this.fixed===0?"Etc/UTC":`Etc/GMT${Vx(-this.fixed,"narrow")}`}offsetName(){return this.name}formatOffset(e,t){return Vx(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}},f1=class extends af{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 pd(r,e){if(Mt(r)||r===null)return e;if(r instanceof af)return r;if(Wme(r)){let t=r.toLowerCase();return t==="default"?e:t==="local"||t==="system"?zS.instance:t==="utc"||t==="gmt"?na.utcInstance:na.parseSpecifier(t)||fd.create(r)}else return sf(r)?na.instance(r):typeof r=="object"&&"offset"in r&&typeof r.offset=="function"?r:new f1(r)}var c5=()=>Date.now(),u5="system",d5=null,p5=null,f5=null,m5=60,h5,Xr=class{static get now(){return c5}static set now(e){c5=e}static set defaultZone(e){u5=e}static get defaultZone(){return pd(u5,zS.instance)}static get defaultLocale(){return d5}static set defaultLocale(e){d5=e}static get defaultNumberingSystem(){return p5}static set defaultNumberingSystem(e){p5=e}static get defaultOutputCalendar(){return f5}static set defaultOutputCalendar(e){f5=e}static get twoDigitCutoffYear(){return m5}static set twoDigitCutoffYear(e){m5=e%100}static get throwOnInvalid(){return h5}static set throwOnInvalid(e){h5=e}static resetCaches(){Qr.resetCache(),fd.resetCache()}};function Mt(r){return typeof r>"u"}function sf(r){return typeof r=="number"}function ZS(r){return typeof r=="number"&&r%1===0}function Wme(r){return typeof r=="string"}function zme(r){return Object.prototype.toString.call(r)==="[object Date]"}function i8(){try{return typeof Intl<"u"&&!!Intl.RelativeTimeFormat}catch{return!1}}function Hme(r){return Array.isArray(r)?r:[r]}function g5(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 jme(r,e){return e.reduce((t,n)=>(t[n]=r[n],t),{})}function Eg(r,e){return Object.prototype.hasOwnProperty.call(r,e)}function zc(r,e,t){return ZS(r)&&r>=e&&r<=t}function Gme(r,e){return r-e*Math.floor(r/e)}function xn(r,e=2){let t=r<0,n;return t?n="-"+(""+-r).padStart(e,"0"):n=(""+r).padStart(e,"0"),n}function dd(r){if(!(Mt(r)||r===null||r===""))return parseInt(r,10)}function tf(r){if(!(Mt(r)||r===null||r===""))return parseFloat(r)}function E1(r){if(!(Mt(r)||r===null||r==="")){let e=parseFloat("0."+r)*1e3;return Math.floor(e)}}function T1(r,e,t=!1){let n=10**e;return(t?Math.trunc:Math.round)(r*n)/n}function zx(r){return r%4===0&&(r%100!==0||r%400===0)}function Ux(r){return zx(r)?366:365}function HS(r,e){let t=Gme(e-1,12)+1,n=r+(e-t)/12;return t===2?zx(n)?29:28:[31,null,31,30,31,30,31,31,30,31,30,31][t-1]}function JS(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 jS(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 m1(r){return r>99?r:r>Xr.twoDigitCutoffYear?1900+r:2e3+r}function o8(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 eD(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 s8(r){let e=Number(r);if(typeof r=="boolean"||r===""||Number.isNaN(e))throw new qo(`Invalid unit value ${r}`);return e}function GS(r,e){let t={};for(let n in r)if(Eg(r,n)){let i=r[n];if(i==null)continue;t[e(n)]=s8(i)}return t}function Vx(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}${xn(t,2)}:${xn(n,2)}`;case"narrow":return`${i}${t}${n>0?`:${n}`:""}`;case"techie":return`${i}${xn(t,2)}${xn(n,2)}`;default:throw new RangeError(`Value format ${e} is out of range for property format`)}}function tD(r){return jme(r,["hour","minute","second","millisecond"])}var Yme=["January","February","March","April","May","June","July","August","September","October","November","December"],a8=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],Kme=["J","F","M","A","M","J","J","A","S","O","N","D"];function l8(r){switch(r){case"narrow":return[...Kme];case"short":return[...a8];case"long":return[...Yme];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 c8=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],u8=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],Xme=["M","T","W","T","F","S","S"];function d8(r){switch(r){case"narrow":return[...Xme];case"short":return[...u8];case"long":return[...c8];case"numeric":return["1","2","3","4","5","6","7"];default:return null}}var p8=["AM","PM"],Qme=["Before Christ","Anno Domini"],Zme=["BC","AD"],Jme=["B","A"];function f8(r){switch(r){case"narrow":return[...Jme];case"short":return[...Zme];case"long":return[...Qme];default:return null}}function ehe(r){return p8[r.hour<12?0:1]}function the(r,e){return d8(e)[r.weekday-1]}function rhe(r,e){return l8(e)[r.month-1]}function nhe(r,e){return f8(e)[r.year<0?0:1]}function ihe(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 v5(r,e){let t="";for(let n of r)n.literal?t+=n.val:t+=e(n.val);return t}var ohe={D:WS,DD:B5,DDD:U5,DDDD:V5,t:q5,tt:W5,ttt:z5,tttt:H5,T:j5,TT:G5,TTT:Y5,TTTT:K5,f:X5,ff:Z5,fff:e8,ffff:r8,F:Q5,FF:J5,FFF:t8,FFFF:n8},vs=class r{static create(e,t={}){return new r(e,t)}static parseFormat(e){let t=null,n="",i=!1,o=[];for(let s=0;s<e.length;s++){let a=e.charAt(s);a==="'"?(n.length>0&&o.push({literal:i||/^\s+$/.test(n),val:n}),t=null,n="",i=!i):i||a===t?n+=a:(n.length>0&&o.push({literal:/^\s+$/.test(n),val:n}),n=a,t=a)}return n.length>0&&o.push({literal:i||/^\s+$/.test(n),val:n}),o}static macroTokenToFormatOpts(e){return ohe[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 xn(e,t);let n={...this.opts};return t>0&&(n.padTo=t),this.loc.numberFormatter(n).format(e)}formatDateTimeFromString(e,t){let n=this.loc.listingMode()==="en",i=this.loc.outputCalendar&&this.loc.outputCalendar!=="gregory",o=(p,m)=>this.loc.extract(e,p,m),s=p=>e.isOffsetFixed&&e.offset===0&&p.allowZ?"Z":e.isValid?e.zone.formatOffset(e.ts,p.format):"",a=()=>n?ehe(e):o({hour:"numeric",hourCycle:"h12"},"dayperiod"),l=(p,m)=>n?rhe(e,p):o(m?{month:p}:{month:p,day:"numeric"},"month"),c=(p,m)=>n?the(e,p):o(m?{weekday:p}:{weekday:p,month:"long",day:"numeric"},"weekday"),u=p=>{let m=r.macroTokenToFormatOpts(p);return m?this.formatWithSystemDefault(e,m):p},d=p=>n?nhe(e,p):o({era:p},"era"),f=p=>{switch(p){case"S":return this.num(e.millisecond);case"u":case"SSS":return this.num(e.millisecond,3);case"s":return this.num(e.second);case"ss":return this.num(e.second,2);case"uu":return this.num(Math.floor(e.millisecond/10),2);case"uuu":return this.num(Math.floor(e.millisecond/100));case"m":return this.num(e.minute);case"mm":return this.num(e.minute,2);case"h":return this.num(e.hour%12===0?12:e.hour%12);case"hh":return this.num(e.hour%12===0?12:e.hour%12,2);case"H":return this.num(e.hour);case"HH":return this.num(e.hour,2);case"Z":return s({format:"narrow",allowZ:this.opts.allowZ});case"ZZ":return s({format:"short",allowZ:this.opts.allowZ});case"ZZZ":return s({format:"techie",allowZ:this.opts.allowZ});case"ZZZZ":return e.zone.offsetName(e.ts,{format:"short",locale:this.loc.locale});case"ZZZZZ":return e.zone.offsetName(e.ts,{format:"long",locale:this.loc.locale});case"z":return e.zoneName;case"a":return a();case"d":return i?o({day:"numeric"},"day"):this.num(e.day);case"dd":return i?o({day:"2-digit"},"day"):this.num(e.day,2);case"c":return this.num(e.weekday);case"ccc":return c("short",!0);case"cccc":return c("long",!0);case"ccccc":return c("narrow",!0);case"E":return this.num(e.weekday);case"EEE":return c("short",!1);case"EEEE":return c("long",!1);case"EEEEE":return c("narrow",!1);case"L":return i?o({month:"numeric",day:"numeric"},"month"):this.num(e.month);case"LL":return i?o({month:"2-digit",day:"numeric"},"month"):this.num(e.month,2);case"LLL":return l("short",!0);case"LLLL":return l("long",!0);case"LLLLL":return l("narrow",!0);case"M":return i?o({month:"numeric"},"month"):this.num(e.month);case"MM":return i?o({month:"2-digit"},"month"):this.num(e.month,2);case"MMM":return l("short",!1);case"MMMM":return l("long",!1);case"MMMMM":return l("narrow",!1);case"y":return i?o({year:"numeric"},"year"):this.num(e.year);case"yy":return i?o({year:"2-digit"},"year"):this.num(e.year.toString().slice(-2),2);case"yyyy":return i?o({year:"numeric"},"year"):this.num(e.year,4);case"yyyyyy":return i?o({year:"numeric"},"year"):this.num(e.year,6);case"G":return d("short");case"GG":return d("long");case"GGGGG":return d("narrow");case"kk":return this.num(e.weekYear.toString().slice(-2),2);case"kkkk":return this.num(e.weekYear,4);case"W":return this.num(e.weekNumber);case"WW":return this.num(e.weekNumber,2);case"o":return this.num(e.ordinal);case"ooo":return this.num(e.ordinal,3);case"q":return this.num(e.quarter);case"qq":return this.num(e.quarter,2);case"X":return this.num(Math.floor(e.ts/1e3));case"x":return this.num(e.ts);default:return u(p)}};return v5(r.parseFormat(t),f)}formatDurationFromString(e,t){let n=l=>{switch(l[0]){case"S":return"millisecond";case"s":return"second";case"m":return"minute";case"h":return"hour";case"d":return"day";case"w":return"week";case"M":return"month";case"y":return"year";default:return null}},i=l=>c=>{let u=n(c);return u?this.num(l.get(u),c.length):c},o=r.parseFormat(t),s=o.reduce((l,{literal:c,val:u})=>c?l:l.concat(u),[]),a=e.shiftTo(...s.map(n).filter(l=>l));return v5(o,i(a))}},ys=class{constructor(e,t){this.reason=e,this.explanation=t}toMessage(){return this.explanation?`${this.reason}: ${this.explanation}`:this.reason}},m8=/[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;function Tg(...r){let e=r.reduce((t,n)=>t+n.source,"");return RegExp(`^${e}$`)}function _g(...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 Ag(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 h8(...r){return(e,t)=>{let n={},i;for(i=0;i<r.length;i++)n[r[i]]=dd(e[t+i]);return[n,null,t+i]}}var g8=/(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/,she=`(?:${g8.source}?(?:\\[(${m8.source})\\])?)?`,_1=/(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/,v8=RegExp(`${_1.source}${she}`),A1=RegExp(`(?:T${v8.source})?`),ahe=/([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/,lhe=/(\d{4})-?W(\d\d)(?:-?(\d))?/,che=/(\d{4})-?(\d{3})/,uhe=h8("weekYear","weekNumber","weekDay"),dhe=h8("year","ordinal"),phe=/(\d{4})-(\d\d)-(\d\d)/,y8=RegExp(`${_1.source} ?(?:${g8.source}|(${m8.source}))?`),fhe=RegExp(`(?: ${y8.source})?`);function Cg(r,e,t){let n=r[e];return Mt(n)?t:dd(n)}function mhe(r,e){return[{year:Cg(r,e),month:Cg(r,e+1,1),day:Cg(r,e+2,1)},null,e+3]}function kg(r,e){return[{hours:Cg(r,e,0),minutes:Cg(r,e+1,0),seconds:Cg(r,e+2,0),milliseconds:E1(r[e+3])},null,e+4]}function Hx(r,e){let t=!r[e]&&!r[e+1],n=eD(r[e+1],r[e+2]),i=t?null:na.instance(n);return[{},i,e+3]}function jx(r,e){let t=r[e]?fd.create(r[e]):null;return[{},t,e+1]}var hhe=RegExp(`^T?${_1.source}$`),ghe=/^-?P(?:(?:(-?\d{1,20}(?:\.\d{1,20})?)Y)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20}(?:\.\d{1,20})?)W)?(?:(-?\d{1,20}(?:\.\d{1,20})?)D)?(?:T(?:(-?\d{1,20}(?:\.\d{1,20})?)H)?(?:(-?\d{1,20}(?:\.\d{1,20})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,20}))?S)?)?)$/;function vhe(r){let[e,t,n,i,o,s,a,l,c]=r,u=e[0]==="-",d=l&&l[0]==="-",f=(p,m=!1)=>p!==void 0&&(m||p&&u)?-p:p;return[{years:f(tf(t)),months:f(tf(n)),weeks:f(tf(i)),days:f(tf(o)),hours:f(tf(s)),minutes:f(tf(a)),seconds:f(tf(l),l==="-0"),milliseconds:f(E1(c),d)}]}var yhe={GMT:0,EDT:-240,EST:-300,CDT:-300,CST:-360,MDT:-360,MST:-420,PDT:-420,PST:-480};function k1(r,e,t,n,i,o,s){let a={year:e.length===2?m1(dd(e)):dd(e),month:a8.indexOf(t)+1,day:dd(n),hour:dd(i),minute:dd(o)};return s&&(a.second=dd(s)),r&&(a.weekday=r.length>3?c8.indexOf(r)+1:u8.indexOf(r)+1),a}var bhe=/^(?:(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 whe(r){let[,e,t,n,i,o,s,a,l,c,u,d]=r,f=k1(e,i,n,t,o,s,a),p;return l?p=yhe[l]:c?p=0:p=eD(u,d),[f,new na(p)]}function Che(r){return r.replace(/\([^()]*\)|[\n\t]/g," ").replace(/(\s\s+)/g," ").trim()}var xhe=/^(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$/,Ehe=/^(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$/,The=/^(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 y5(r){let[,e,t,n,i,o,s,a]=r;return[k1(e,i,n,t,o,s,a),na.utcInstance]}function _he(r){let[,e,t,n,i,o,s,a]=r;return[k1(e,a,t,n,i,o,s),na.utcInstance]}var Ahe=Tg(ahe,A1),khe=Tg(lhe,A1),She=Tg(che,A1),Dhe=Tg(v8),b8=_g(mhe,kg,Hx,jx),Ihe=_g(uhe,kg,Hx,jx),Phe=_g(dhe,kg,Hx,jx),Fhe=_g(kg,Hx,jx);function Mhe(r){return Ag(r,[Ahe,b8],[khe,Ihe],[She,Phe],[Dhe,Fhe])}function Rhe(r){return Ag(Che(r),[bhe,whe])}function $he(r){return Ag(r,[xhe,y5],[Ehe,y5],[The,_he])}function Ohe(r){return Ag(r,[ghe,vhe])}var Nhe=_g(kg);function Lhe(r){return Ag(r,[hhe,Nhe])}var Bhe=Tg(phe,fhe),Uhe=Tg(y8),Vhe=_g(kg,Hx,jx);function qhe(r){return Ag(r,[Bhe,b8],[Uhe,Vhe])}var b5="Invalid Duration",w8={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}},Whe={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},...w8},ta=146097/400,yg=146097/4800,zhe={years:{quarters:4,months:12,weeks:ta/7,days:ta,hours:ta*24,minutes:ta*24*60,seconds:ta*24*60*60,milliseconds:ta*24*60*60*1e3},quarters:{months:3,weeks:ta/28,days:ta/4,hours:ta*24/4,minutes:ta*24*60/4,seconds:ta*24*60*60/4,milliseconds:ta*24*60*60*1e3/4},months:{weeks:yg/7,days:yg,hours:yg*24,minutes:yg*24*60,seconds:yg*24*60*60,milliseconds:yg*24*60*60*1e3},...w8},of=["years","quarters","months","weeks","days","hours","minutes","seconds","milliseconds"],Hhe=of.slice(0).reverse();function ud(r,e,t=!1){let n={values:t?e.values:{...r.values,...e.values||{}},loc:r.loc.clone(e.loc),conversionAccuracy:e.conversionAccuracy||r.conversionAccuracy,matrix:e.matrix||r.matrix};return new Xe(n)}function C8(r,e){let t=e.milliseconds??0;for(let n of Hhe.slice(1))e[n]&&(t+=e[n]*r[n].milliseconds);return t}function w5(r,e){let t=C8(r,e)<0?-1:1;of.reduceRight((n,i)=>{if(Mt(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),of.reduce((n,i)=>{if(Mt(e[i]))return n;if(n){let o=e[n]%1;e[n]-=o,e[i]+=o*r[n][i]}return i},null)}function jhe(r){let e={};for(let[t,n]of Object.entries(r))n!==0&&(e[t]=n);return e}var Xe=class r{constructor(e){let t=e.conversionAccuracy==="longterm"||!1,n=t?zhe:Whe;e.matrix&&(n=e.matrix),this.values=e.values,this.loc=e.loc||Qr.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 qo(`Duration.fromObject: argument expected to be an object, got ${e===null?"null":typeof e}`);return new r({values:GS(e,r.normalizeUnit),loc:Qr.fromObject(t),conversionAccuracy:t.conversionAccuracy,matrix:t.matrix})}static fromDurationLike(e){if(sf(e))return r.fromMillis(e);if(r.isDuration(e))return e;if(typeof e=="object")return r.fromObject(e);throw new qo(`Unknown duration argument ${e} of type ${typeof e}`)}static fromISO(e,t){let[n]=Ohe(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]=Lhe(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 qo("need to specify a reason the Duration is invalid");let n=e instanceof ys?e:new ys(e,t);if(Xr.throwOnInvalid)throw new o1(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 qS(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?vs.create(this.loc,n).formatDurationFromString(this,e):b5}toHuman(e={}){if(!this.isValid)return b5;let t=of.map(n=>{let i=this.values[n];return Mt(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+=T1(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},At.fromMillis(t,{zone:"UTC"}).toISOTime(e))}toJSON(){return this.toISO()}toString(){return this.toISO()}toMillis(){return this.isValid?C8(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 of)(Eg(t.values,i)||Eg(this.values,i))&&(n[i]=t.get(i)+this.get(i));return ud(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]=s8(e(this.values[n],n));return ud(this,{values:t},!0)}get(e){return this[r.normalizeUnit(e)]}set(e){if(!this.isValid)return this;let t={...this.values,...GS(e,r.normalizeUnit)};return ud(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 ud(this,s)}as(e){return this.isValid?this.shiftTo(e).get(e):NaN}normalize(){if(!this.isValid)return this;let e=this.toObject();return w5(this.matrix,e),ud(this,{values:e},!0)}rescale(){if(!this.isValid)return this;let e=jhe(this.normalize().shiftToAll().toObject());return ud(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 of)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;sf(i[s])&&(a+=i[s]);let l=Math.trunc(a);t[s]=l,n[s]=(a*1e3-l*1e3)/1e3}else sf(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 w5(this.matrix,t),ud(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 ud(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 of)if(!t(this.values[n],e.values[n]))return!1;return!0}},bg="Invalid Interval";function Ghe(r,e){return!r||!r.isValid?xg.invalid("missing or invalid start"):!e||!e.isValid?xg.invalid("missing or invalid end"):e<r?xg.invalid("end before start",`The end of an interval must be after its start, but you had start=${r.toISO()} and end=${e.toISO()}`):null}var xg=class r{constructor(e){this.s=e.start,this.e=e.end,this.invalid=e.invalid||null,this.isLuxonInterval=!0}static invalid(e,t=null){if(!e)throw new qo("need to specify a reason the Interval is invalid");let n=e instanceof ys?e:new ys(e,t);if(Xr.throwOnInvalid)throw new i1(n);return new r({invalid:n})}static fromDateTimes(e,t){let n=Nx(e),i=Nx(t),o=Ghe(n,i);return o??new r({start:n,end:i})}static after(e,t){let n=Xe.fromDurationLike(t),i=Nx(e);return r.fromDateTimes(i,i.plus(n))}static before(e,t){let n=Xe.fromDurationLike(t),i=Nx(e);return r.fromDateTimes(i.minus(n),i)}static fromISO(e,t){let[n,i]=(e||"").split("/",2);if(n&&i){let o,s;try{o=At.fromISO(n,t),s=o.isValid}catch{s=!1}let a,l;try{a=At.fromISO(i,t),l=a.isValid}catch{l=!1}if(s&&l)return r.fromDateTimes(o,a);if(s){let c=Xe.fromISO(i,t);if(c.isValid)return r.after(o,c)}else if(l){let c=Xe.fromISO(n,t);if(c.isValid)return r.before(a,c)}}return r.invalid("unparsable",`the input "${e}" can't be parsed as ISO 8601`)}static isInterval(e){return e&&e.isLuxonInterval||!1}get start(){return this.isValid?this.s:null}get end(){return this.isValid?this.e:null}get isValid(){return this.invalidReason===null}get invalidReason(){return this.invalid?this.invalid.reason:null}get invalidExplanation(){return this.invalid?this.invalid.explanation:null}length(e="milliseconds"){return this.isValid?this.toDuration(e).get(e):NaN}count(e="milliseconds"){if(!this.isValid)return NaN;let t=this.start.startOf(e),n=this.end.startOf(e);return Math.floor(n.diff(t,e).get(e))+(n.valueOf()!==this.end.valueOf())}hasSame(e){return this.isValid?this.isEmpty()||this.e.minus(1).hasSame(this.s,e):!1}isEmpty(){return this.s.valueOf()===this.e.valueOf()}isAfter(e){return this.isValid?this.s>e:!1}isBefore(e){return this.isValid?this.e<=e:!1}contains(e){return this.isValid?this.s<=e&&this.e>e:!1}set({start:e,end:t}={}){return this.isValid?r.fromDateTimes(e||this.s,t||this.e):this}splitAt(...e){if(!this.isValid)return[];let t=e.map(Nx).filter(s=>this.contains(s)).sort(),n=[],{s:i}=this,o=0;for(;i<this.e;){let s=t[o]||this.e,a=+s>+this.e?this.e:s;n.push(r.fromDateTimes(i,a)),i=a,o+=1}return n}splitBy(e){let t=Xe.fromDurationLike(e);if(!this.isValid||!t.isValid||t.as("milliseconds")===0)return[];let{s:n}=this,i=1,o,s=[];for(;n<this.e;){let a=this.start.plus(t.mapUnits(l=>l*i));o=+a>+this.e?this.e:a,s.push(r.fromDateTimes(n,o)),n=o,i+=1}return s}divideEqually(e){return this.isValid?this.splitBy(this.length()/e).slice(0,e):[]}overlaps(e){return this.e>e.s&&this.s<e.e}abutsStart(e){return this.isValid?+this.e==+e.s:!1}abutsEnd(e){return this.isValid?+e.e==+this.s:!1}engulfs(e){return this.isValid?this.s<=e.s&&this.e>=e.e:!1}equals(e){return!this.isValid||!e.isValid?!1:this.s.equals(e.s)&&this.e.equals(e.e)}intersection(e){if(!this.isValid)return this;let t=this.s>e.s?this.s:e.s,n=this.e<e.e?this.e:e.e;return t>=n?null:r.fromDateTimes(t,n)}union(e){if(!this.isValid)return this;let t=this.s<e.s?this.s:e.s,n=this.e>e.e?this.e:e.e;return r.fromDateTimes(t,n)}static merge(e){let[t,n]=e.sort((i,o)=>i.s-o.s).reduce(([i,o],s)=>o?o.overlaps(s)||o.abutsStart(s)?[i,o.union(s)]:[i.concat([o]),s]:[i,s],[[],null]);return n&&t.push(n),t}static xor(e){let t=null,n=0,i=[],o=e.map(l=>[{time:l.s,type:"s"},{time:l.e,type:"e"}]),s=Array.prototype.concat(...o),a=s.sort((l,c)=>l.time-c.time);for(let l of a)n+=l.type==="s"?1:-1,n===1?t=l.time:(t&&+t!=+l.time&&i.push(r.fromDateTimes(t,l.time)),t=null);return r.merge(i)}difference(...e){return r.xor([this].concat(e)).map(t=>this.intersection(t)).filter(t=>t&&!t.isEmpty())}toString(){return this.isValid?`[${this.s.toISO()} \u2013 ${this.e.toISO()})`:bg}toLocaleString(e=WS,t={}){return this.isValid?vs.create(this.s.loc.clone(t),e).formatInterval(this):bg}toISO(e){return this.isValid?`${this.s.toISO(e)}/${this.e.toISO(e)}`:bg}toISODate(){return this.isValid?`${this.s.toISODate()}/${this.e.toISODate()}`:bg}toISOTime(e){return this.isValid?`${this.s.toISOTime(e)}/${this.e.toISOTime(e)}`:bg}toFormat(e,{separator:t=" \u2013 "}={}){return this.isValid?`${this.s.toFormat(e)}${t}${this.e.toFormat(e)}`:bg}toDuration(e,t){return this.isValid?this.e.diff(this.s,e,t):Xe.invalid(this.invalidReason)}mapEndpoints(e){return r.fromDateTimes(e(this.s),e(this.e))}},wg=class{static hasDST(e=Xr.defaultZone){let t=At.now().setZone(e).set({month:12});return!e.isUniversal&&t.offset!==t.set({month:6}).offset}static isValidIANAZone(e){return fd.isValidZone(e)}static normalizeZone(e){return pd(e,Xr.defaultZone)}static months(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||Qr.create(t,n,o)).months(e)}static monthsFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null,outputCalendar:o="gregory"}={}){return(i||Qr.create(t,n,o)).months(e,!0)}static weekdays(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||Qr.create(t,n,null)).weekdays(e)}static weekdaysFormat(e="long",{locale:t=null,numberingSystem:n=null,locObj:i=null}={}){return(i||Qr.create(t,n,null)).weekdays(e,!0)}static meridiems({locale:e=null}={}){return Qr.create(e).meridiems()}static eras(e="short",{locale:t=null}={}){return Qr.create(t,null,"gregory").eras(e)}static features(){return{relative:i8()}}};function C5(r,e){let t=i=>i.toUTC(0,{keepLocalTime:!0}).startOf("day").valueOf(),n=t(e)-t(r);return Math.floor(Xe.fromMillis(n).as("days"))}function Yhe(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=C5(l,c);return(u-u%7)/7}],["days",C5]],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 Khe(r,e,t,n){let[i,o,s,a]=Yhe(r,e,t),l=e-i,c=t.filter(d=>["hours","minutes","seconds","milliseconds"].indexOf(d)>=0);c.length===0&&(s<e&&(s=i.plus({[a]:1})),s!==i&&(o[a]=(o[a]||0)+l/(s-i)));let u=Xe.fromObject(o,n);return c.length>0?Xe.fromMillis(l,n).shiftTo(...c).plus(u):u}var S1={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"},x5={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]},Xhe=S1.hanidec.replace(/[\[|\]]/g,"").split("");function Qhe(r){let e=parseInt(r,10);if(isNaN(e)){e="";for(let t=0;t<r.length;t++){let n=r.charCodeAt(t);if(r[t].search(S1.hanidec)!==-1)e+=Xhe.indexOf(r[t]);else for(let i in x5){let[o,s]=x5[i];n>=o&&n<=s&&(e+=n-o)}}return parseInt(e,10)}else return e}function za({numberingSystem:r},e=""){return new RegExp(`${S1[r||"latn"]}${e}`)}var Zhe="missing Intl.DateTimeFormat.formatToParts support";function Xt(r,e=t=>t){return{regex:r,deser:([t])=>e(Qhe(t))}}var Jhe="\xA0",x8=`[ ${Jhe}]`,E8=new RegExp(x8,"g");function ege(r){return r.replace(/\./g,"\\.?").replace(E8,x8)}function E5(r){return r.replace(/\./g,"").replace(E8," ").toLowerCase()}function Ha(r,e){return r===null?null:{regex:RegExp(r.map(ege).join("|")),deser:([t])=>r.findIndex(n=>E5(t)===E5(n))+e}}function T5(r,e){return{regex:r,deser:([,t,n])=>eD(t,n),groups:e}}function OS(r){return{regex:r,deser:([e])=>e}}function tge(r){return r.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function rge(r,e){let t=za(e),n=za(e,"{2}"),i=za(e,"{3}"),o=za(e,"{4}"),s=za(e,"{6}"),a=za(e,"{1,2}"),l=za(e,"{1,3}"),c=za(e,"{1,6}"),u=za(e,"{1,9}"),d=za(e,"{2,4}"),f=za(e,"{4,6}"),p=g=>({regex:RegExp(tge(g.val)),deser:([y])=>y,literal:!0}),v=(g=>{if(r.literal)return p(g);switch(g.val){case"G":return Ha(e.eras("short"),0);case"GG":return Ha(e.eras("long"),0);case"y":return Xt(c);case"yy":return Xt(d,m1);case"yyyy":return Xt(o);case"yyyyy":return Xt(f);case"yyyyyy":return Xt(s);case"M":return Xt(a);case"MM":return Xt(n);case"MMM":return Ha(e.months("short",!0),1);case"MMMM":return Ha(e.months("long",!0),1);case"L":return Xt(a);case"LL":return Xt(n);case"LLL":return Ha(e.months("short",!1),1);case"LLLL":return Ha(e.months("long",!1),1);case"d":return Xt(a);case"dd":return Xt(n);case"o":return Xt(l);case"ooo":return Xt(i);case"HH":return Xt(n);case"H":return Xt(a);case"hh":return Xt(n);case"h":return Xt(a);case"mm":return Xt(n);case"m":return Xt(a);case"q":return Xt(a);case"qq":return Xt(n);case"s":return Xt(a);case"ss":return Xt(n);case"S":return Xt(l);case"SSS":return Xt(i);case"u":return OS(u);case"uu":return OS(a);case"uuu":return Xt(t);case"a":return Ha(e.meridiems(),0);case"kkkk":return Xt(o);case"kk":return Xt(d,m1);case"W":return Xt(a);case"WW":return Xt(n);case"E":case"c":return Xt(t);case"EEE":return Ha(e.weekdays("short",!1),1);case"EEEE":return Ha(e.weekdays("long",!1),1);case"ccc":return Ha(e.weekdays("short",!0),1);case"cccc":return Ha(e.weekdays("long",!0),1);case"Z":case"ZZ":return T5(new RegExp(`([+-]${a.source})(?::(${n.source}))?`),2);case"ZZZ":return T5(new RegExp(`([+-]${a.source})(${n.source})?`),2);case"z":return OS(/[a-z_+-/]{1,256}?/i);case" ":return OS(/[^\S\n\r]/);default:return p(g)}})(r)||{invalidReason:Zhe};return v.token=r,v}var nge={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 ige(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=nge[s];if(typeof a=="object"&&(a=a[o]),a)return{literal:!1,val:a}}function oge(r){return[`^${r.map(t=>t.regex).reduce((t,n)=>`${t}(${n.source})`,"")}$`,r]}function sge(r,e,t){let n=r.match(e);if(n){let i={},o=1;for(let s in t)if(Eg(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 age(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 Mt(r.z)||(t=fd.create(r.z)),Mt(r.Z)||(t||(t=new na(r.Z)),n=r.Z),Mt(r.q)||(r.M=(r.q-1)*3+1),Mt(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),Mt(r.u)||(r.S=E1(r.u)),[Object.keys(r).reduce((o,s)=>{let a=e(s);return a&&(o[a]=r[s]),o},{}),t,n]}var QO=null;function lge(){return QO||(QO=At.fromMillis(1555555555555)),QO}function cge(r,e){if(r.literal)return r;let t=vs.macroTokenToFormatOpts(r.val),n=A8(t,e);return n==null||n.includes(void 0)?r:n}function T8(r,e){return Array.prototype.concat(...r.map(t=>cge(t,e)))}function _8(r,e,t){let n=T8(vs.parseFormat(t),r),i=n.map(s=>rge(s,r)),o=i.find(s=>s.invalidReason);if(o)return{input:e,tokens:n,invalidReason:o.invalidReason};{let[s,a]=oge(i),l=RegExp(s,"i"),[c,u]=sge(e,l,a),[d,f,p]=u?age(u):[null,null,void 0];if(Eg(u,"a")&&Eg(u,"H"))throw new nf("Can't include meridiem when specifying 24-hour format");return{input:e,tokens:n,regex:l,rawMatches:c,matches:u,result:d,zone:f,specificOffset:p}}}function uge(r,e,t){let{result:n,zone:i,specificOffset:o,invalidReason:s}=_8(r,e,t);return[n,i,o,s]}function A8(r,e){if(!r)return null;let n=vs.create(e,r).dtFormatter(lge()),i=n.formatToParts(),o=n.resolvedOptions();return i.map(s=>ige(s,r,o))}var k8=[0,31,59,90,120,151,181,212,243,273,304,334],S8=[0,31,60,91,121,152,182,213,244,274,305,335];function ra(r,e){return new ys("unit out of range",`you specified ${e} (of type ${typeof e}) as a ${r}, which is invalid`)}function D8(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 I8(r,e,t){return t+(zx(r)?S8:k8)[e-1]}function P8(r,e){let t=zx(r)?S8:k8,n=t.findIndex(o=>o<e),i=e-t[n];return{month:n+1,day:i}}function h1(r){let{year:e,month:t,day:n}=r,i=I8(e,t,n),o=D8(e,t,n),s=Math.floor((i-o+10)/7),a;return s<1?(a=e-1,s=jS(a)):s>jS(e)?(a=e+1,s=1):a=e,{weekYear:a,weekNumber:s,weekday:o,...tD(r)}}function _5(r){let{weekYear:e,weekNumber:t,weekday:n}=r,i=D8(e,1,4),o=Ux(e),s=t*7+n-i-3,a;s<1?(a=e-1,s+=Ux(a)):s>o?(a=e+1,s-=Ux(e)):a=e;let{month:l,day:c}=P8(a,s);return{year:a,month:l,day:c,...tD(r)}}function ZO(r){let{year:e,month:t,day:n}=r,i=I8(e,t,n);return{year:e,ordinal:i,...tD(r)}}function A5(r){let{year:e,ordinal:t}=r,{month:n,day:i}=P8(e,t);return{year:e,month:n,day:i,...tD(r)}}function dge(r){let e=ZS(r.weekYear),t=zc(r.weekNumber,1,jS(r.weekYear)),n=zc(r.weekday,1,7);return e?t?n?!1:ra("weekday",r.weekday):ra("week",r.week):ra("weekYear",r.weekYear)}function pge(r){let e=ZS(r.year),t=zc(r.ordinal,1,Ux(r.year));return e?t?!1:ra("ordinal",r.ordinal):ra("year",r.year)}function F8(r){let e=ZS(r.year),t=zc(r.month,1,12),n=zc(r.day,1,HS(r.year,r.month));return e?t?n?!1:ra("day",r.day):ra("month",r.month):ra("year",r.year)}function M8(r){let{hour:e,minute:t,second:n,millisecond:i}=r,o=zc(e,0,23)||e===24&&t===0&&n===0&&i===0,s=zc(t,0,59),a=zc(n,0,59),l=zc(i,0,999);return o?s?a?l?!1:ra("millisecond",i):ra("second",n):ra("minute",t):ra("hour",e)}var JO="Invalid DateTime",k5=864e13;function NS(r){return new ys("unsupported zone",`the zone "${r.name}" is not supported`)}function e1(r){return r.weekData===null&&(r.weekData=h1(r.c)),r.weekData}function rf(r,e){let t={ts:r.ts,zone:r.zone,c:r.c,o:r.o,loc:r.loc,invalid:r.invalid};return new At({...t,...e,old:t})}function R8(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 LS(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 VS(r,e,t){return R8(JS(r),e,t)}function S5(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,HS(n,i))+Math.trunc(e.days)+Math.trunc(e.weeks)*7},s=Xe.fromObject({years:e.years-Math.trunc(e.years),quarters:e.quarters-Math.trunc(e.quarters),months:e.months-Math.trunc(e.months),weeks:e.weeks-Math.trunc(e.weeks),days:e.days-Math.trunc(e.days),hours:e.hours,minutes:e.minutes,seconds:e.seconds,milliseconds:e.milliseconds}).as("milliseconds"),a=JS(o),[l,c]=R8(a,t,r.zone);return s!==0&&(l+=s,c=r.zone.offset(l)),{ts:l,o:c}}function Ox(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=At.fromObject(r,{...t,zone:l,specificOffset:o});return s?c:c.setZone(a)}else return At.invalid(new ys("unparsable",`the input "${i}" can't be parsed as ${n}`))}function BS(r,e,t=!0){return r.isValid?vs.create(Qr.create("en-US"),{allowZ:t,forceSimple:!0}).formatDateTimeFromString(r,e):null}function t1(r,e){let t=r.c.year>9999||r.c.year<0,n="";return t&&r.c.year>=0&&(n+="+"),n+=xn(r.c.year,t?6:4),e?(n+="-",n+=xn(r.c.month),n+="-",n+=xn(r.c.day)):(n+=xn(r.c.month),n+=xn(r.c.day)),n}function D5(r,e,t,n,i,o){let s=xn(r.c.hour);return e?(s+=":",s+=xn(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=":")):s+=xn(r.c.minute),(r.c.millisecond!==0||r.c.second!==0||!t)&&(s+=xn(r.c.second),(r.c.millisecond!==0||!n)&&(s+=".",s+=xn(r.c.millisecond,3))),i&&(r.isOffsetFixed&&r.offset===0&&!o?s+="Z":r.o<0?(s+="-",s+=xn(Math.trunc(-r.o/60)),s+=":",s+=xn(Math.trunc(-r.o%60))):(s+="+",s+=xn(Math.trunc(r.o/60)),s+=":",s+=xn(Math.trunc(r.o%60)))),o&&(s+="["+r.zone.ianaName+"]"),s}var $8={month:1,day:1,hour:0,minute:0,second:0,millisecond:0},fge={weekNumber:1,weekday:1,hour:0,minute:0,second:0,millisecond:0},mge={ordinal:1,hour:0,minute:0,second:0,millisecond:0},O8=["year","month","day","hour","minute","second","millisecond"],hge=["weekYear","weekNumber","weekday","hour","minute","second","millisecond"],gge=["year","ordinal","hour","minute","second","millisecond"];function I5(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 qS(r);return e}function P5(r,e){let t=pd(e.zone,Xr.defaultZone),n=Qr.fromObject(e),i=Xr.now(),o,s;if(Mt(r.year))o=i;else{for(let c of O8)Mt(r[c])&&(r[c]=$8[c]);let a=F8(r)||M8(r);if(a)return At.invalid(a);let l=t.offset(i);[o,s]=VS(r,l,t)}return new At({ts:o,zone:t,loc:n,o:s})}function F5(r,e,t){let n=Mt(t.round)?!0:t.round,i=(s,a)=>(s=T1(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 M5(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 At=class r{constructor(e){let t=e.zone||Xr.defaultZone,n=e.invalid||(Number.isNaN(e.ts)?new ys("invalid input"):null)||(t.isValid?null:NS(t));this.ts=Mt(e.ts)?Xr.now():e.ts;let i=null,o=null;if(!n)if(e.old&&e.old.ts===this.ts&&e.old.zone.equals(t))[i,o]=[e.old.c,e.old.o];else{let a=t.offset(this.ts);i=LS(this.ts,a),n=Number.isNaN(i.year)?new ys("invalid input"):null,i=n?null:i,o=n?null:a}this._zone=t,this.loc=e.loc||Qr.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]=M5(arguments),[n,i,o,s,a,l,c]=t;return P5({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static utc(){let[e,t]=M5(arguments),[n,i,o,s,a,l,c]=t;return e.zone=na.utcInstance,P5({year:n,month:i,day:o,hour:s,minute:a,second:l,millisecond:c},e)}static fromJSDate(e,t={}){let n=zme(e)?e.valueOf():NaN;if(Number.isNaN(n))return r.invalid("invalid input");let i=pd(t.zone,Xr.defaultZone);return i.isValid?new r({ts:n,zone:i,loc:Qr.fromObject(t)}):r.invalid(NS(i))}static fromMillis(e,t={}){if(sf(e))return e<-k5||e>k5?r.invalid("Timestamp out of range"):new r({ts:e,zone:pd(t.zone,Xr.defaultZone),loc:Qr.fromObject(t)});throw new qo(`fromMillis requires a numerical input, but received a ${typeof e} with value ${e}`)}static fromSeconds(e,t={}){if(sf(e))return new r({ts:e*1e3,zone:pd(t.zone,Xr.defaultZone),loc:Qr.fromObject(t)});throw new qo("fromSeconds requires a numerical input")}static fromObject(e,t={}){e=e||{};let n=pd(t.zone,Xr.defaultZone);if(!n.isValid)return r.invalid(NS(n));let i=Xr.now(),o=Mt(t.specificOffset)?n.offset(i):t.specificOffset,s=GS(e,I5),a=!Mt(s.ordinal),l=!Mt(s.year),c=!Mt(s.month)||!Mt(s.day),u=l||c,d=s.weekYear||s.weekNumber,f=Qr.fromObject(t);if((u||a)&&d)throw new nf("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(c&&a)throw new nf("Can't mix ordinal dates with month/day");let p=d||s.weekday&&!u,m,v,g=LS(i,o);p?(m=hge,v=fge,g=h1(g)):a?(m=gge,v=mge,g=ZO(g)):(m=O8,v=$8);let y=!1;for(let P of m){let V=s[P];Mt(V)?y?s[P]=v[P]:s[P]=g[P]:y=!0}let w=p?dge(s):a?pge(s):F8(s),x=w||M8(s);if(x)return r.invalid(x);let C=p?_5(s):a?A5(s):s,[_,E]=VS(C,o,n),D=new r({ts:_,zone:n,o:E,loc:f});return s.weekday&&u&&e.weekday!==D.weekday?r.invalid("mismatched weekday",`you can't specify both a weekday of ${s.weekday} and a date of ${D.toISO()}`):D}static fromISO(e,t={}){let[n,i]=Mhe(e);return Ox(n,i,t,"ISO 8601",e)}static fromRFC2822(e,t={}){let[n,i]=Rhe(e);return Ox(n,i,t,"RFC 2822",e)}static fromHTTP(e,t={}){let[n,i]=$he(e);return Ox(n,i,t,"HTTP",t)}static fromFormat(e,t,n={}){if(Mt(e)||Mt(t))throw new qo("fromFormat requires an input string and a format");let{locale:i=null,numberingSystem:o=null}=n,s=Qr.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0}),[a,l,c,u]=uge(s,e,t);return u?r.invalid(u):Ox(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]=qhe(e);return Ox(n,i,t,"SQL",e)}static invalid(e,t=null){if(!e)throw new qo("need to specify a reason the DateTime is invalid");let n=e instanceof ys?e:new ys(e,t);if(Xr.throwOnInvalid)throw new n1(n);return new r({invalid:n})}static isDateTime(e){return e&&e.isLuxonDateTime||!1}static parseFormatForOpts(e,t={}){let n=A8(e,Qr.fromObject(t));return n?n.map(i=>i?i.val:null).join(""):null}static expandFormat(e,t={}){return T8(vs.parseFormat(e),Qr.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?e1(this).weekYear:NaN}get weekNumber(){return this.isValid?e1(this).weekNumber:NaN}get weekday(){return this.isValid?e1(this).weekday:NaN}get ordinal(){return this.isValid?ZO(this.c).ordinal:NaN}get monthShort(){return this.isValid?wg.months("short",{locObj:this.loc})[this.month-1]:null}get monthLong(){return this.isValid?wg.months("long",{locObj:this.loc})[this.month-1]:null}get weekdayShort(){return this.isValid?wg.weekdays("short",{locObj:this.loc})[this.weekday-1]:null}get weekdayLong(){return this.isValid?wg.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=JS(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=LS(l,s),d=LS(c,a);return u.hour===d.hour&&u.minute===d.minute&&u.second===d.second&&u.millisecond===d.millisecond?[rf(this,{ts:l}),rf(this,{ts:c})]:[this]}get isInLeapYear(){return zx(this.year)}get daysInMonth(){return HS(this.year,this.month)}get daysInYear(){return this.isValid?Ux(this.year):NaN}get weeksInWeekYear(){return this.isValid?jS(this.weekYear):NaN}resolvedLocaleOptions(e={}){let{locale:t,numberingSystem:n,calendar:i}=vs.create(this.loc.clone(e),e).resolvedOptions(this);return{locale:t,numberingSystem:n,outputCalendar:i}}toUTC(e=0,t={}){return this.setZone(na.instance(e),t)}toLocal(){return this.setZone(Xr.defaultZone)}setZone(e,{keepLocalTime:t=!1,keepCalendarTime:n=!1}={}){if(e=pd(e,Xr.defaultZone),e.equals(this.zone))return this;if(e.isValid){let i=this.ts;if(t||n){let o=e.offset(this.ts),s=this.toObject();[i]=VS(s,o,e)}return rf(this,{ts:i,zone:e})}else return r.invalid(NS(e))}reconfigure({locale:e,numberingSystem:t,outputCalendar:n}={}){let i=this.loc.clone({locale:e,numberingSystem:t,outputCalendar:n});return rf(this,{loc:i})}setLocale(e){return this.reconfigure({locale:e})}set(e){if(!this.isValid)return this;let t=GS(e,I5),n=!Mt(t.weekYear)||!Mt(t.weekNumber)||!Mt(t.weekday),i=!Mt(t.ordinal),o=!Mt(t.year),s=!Mt(t.month)||!Mt(t.day),a=o||s,l=t.weekYear||t.weekNumber;if((a||i)&&l)throw new nf("Can't mix weekYear/weekNumber units with year/month/day or ordinals");if(s&&i)throw new nf("Can't mix ordinal dates with month/day");let c;n?c=_5({...h1(this.c),...t}):Mt(t.ordinal)?(c={...this.toObject(),...t},Mt(t.day)&&(c.day=Math.min(HS(c.year,c.month),c.day))):c=A5({...ZO(this.c),...t});let[u,d]=VS(c,this.o,this.zone);return rf(this,{ts:u,o:d})}plus(e){if(!this.isValid)return this;let t=Xe.fromDurationLike(e);return rf(this,S5(this,t))}minus(e){if(!this.isValid)return this;let t=Xe.fromDurationLike(e).negate();return rf(this,S5(this,t))}startOf(e){if(!this.isValid)return this;let t={},n=Xe.normalizeUnit(e);switch(n){case"years":t.month=1;case"quarters":case"months":t.day=1;case"weeks":case"days":t.hour=0;case"hours":t.minute=0;case"minutes":t.second=0;case"seconds":t.millisecond=0;break}if(n==="weeks"&&(t.weekday=1),n==="quarters"){let i=Math.ceil(this.month/3);t.month=(i-1)*3+1}return this.set(t)}endOf(e){return this.isValid?this.plus({[e]:1}).startOf(e).minus(1):this}toFormat(e,t={}){return this.isValid?vs.create(this.loc.redefaultToEN(t)).formatDateTimeFromString(this,e):JO}toLocaleString(e=WS,t={}){return this.isValid?vs.create(this.loc.clone(t),e).formatDateTime(this):JO}toLocaleParts(e={}){return this.isValid?vs.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=t1(this,s);return a+="T",a+=D5(this,s,t,n,i,o),a}toISODate({format:e="extended"}={}){return this.isValid?t1(this,e==="extended"):null}toISOWeekDate(){return BS(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":"")+D5(this,s==="extended",t,e,n,o):null}toRFC2822(){return BS(this,"EEE, dd LLL yyyy HH:mm:ss ZZZ",!1)}toHTTP(){return BS(this.toUTC(),"EEE, dd LLL yyyy HH:mm:ss 'GMT'")}toSQLDate(){return this.isValid?t1(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")),BS(this,i,!0)}toSQL(e={}){return this.isValid?`${this.toSQLDate()} ${this.toSQLTime(e)}`:null}toString(){return this.isValid?this.toISO():JO}valueOf(){return this.toMillis()}toMillis(){return this.isValid?this.ts:NaN}toSeconds(){return this.isValid?this.ts/1e3:NaN}toUnixInteger(){return this.isValid?Math.floor(this.ts/1e3):NaN}toJSON(){return this.toISO()}toBSON(){return this.toJSDate()}toObject(e={}){if(!this.isValid)return{};let t={...this.c};return e.includeConfig&&(t.outputCalendar=this.outputCalendar,t.numberingSystem=this.loc.numberingSystem,t.locale=this.loc.locale),t}toJSDate(){return new Date(this.isValid?this.ts:NaN)}diff(e,t="milliseconds",n={}){if(!this.isValid||!e.isValid)return Xe.invalid("created by diffing an invalid DateTime");let i={locale:this.locale,numberingSystem:this.numberingSystem,...n},o=Hme(t).map(Xe.normalizeUnit),s=e.valueOf()>this.valueOf(),a=s?this:e,l=s?e:this,c=Khe(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?xg.fromDateTimes(this,e):this}hasSame(e,t){if(!this.isValid)return!1;let n=e.valueOf(),i=this.setZone(e.zone,{keepLocalTime:!0});return i.startOf(t)<=n&&n<=i.endOf(t)}equals(e){return this.isValid&&e.isValid&&this.valueOf()===e.valueOf()&&this.zone.equals(e.zone)&&this.loc.equals(e.loc)}toRelative(e={}){if(!this.isValid)return null;let t=e.base||r.fromObject({},{zone:this.zone}),n=e.padding?this<t?-e.padding:e.padding:0,i=["years","months","days","hours","minutes","seconds"],o=e.unit;return Array.isArray(e.unit)&&(i=e.unit,o=void 0),F5(t,this.plus(n),{...e,numeric:"always",units:i,unit:o})}toRelativeCalendar(e={}){return this.isValid?F5(e.base||r.fromObject({},{zone:this.zone}),this,{...e,numeric:"auto",units:["years","months","days"],calendary:!0}):null}static min(...e){if(!e.every(r.isDateTime))throw new qo("min requires all arguments be DateTimes");return g5(e,t=>t.valueOf(),Math.min)}static max(...e){if(!e.every(r.isDateTime))throw new qo("max requires all arguments be DateTimes");return g5(e,t=>t.valueOf(),Math.max)}static fromFormatExplain(e,t,n={}){let{locale:i=null,numberingSystem:o=null}=n,s=Qr.fromOpts({locale:i,numberingSystem:o,defaultToEN:!0});return _8(s,e,t)}static fromStringExplain(e,t,n={}){return r.fromFormatExplain(e,t,n)}static get DATE_SHORT(){return WS}static get DATE_MED(){return B5}static get DATE_MED_WITH_WEEKDAY(){return Sme}static get DATE_FULL(){return U5}static get DATE_HUGE(){return V5}static get TIME_SIMPLE(){return q5}static get TIME_WITH_SECONDS(){return W5}static get TIME_WITH_SHORT_OFFSET(){return z5}static get TIME_WITH_LONG_OFFSET(){return H5}static get TIME_24_SIMPLE(){return j5}static get TIME_24_WITH_SECONDS(){return G5}static get TIME_24_WITH_SHORT_OFFSET(){return Y5}static get TIME_24_WITH_LONG_OFFSET(){return K5}static get DATETIME_SHORT(){return X5}static get DATETIME_SHORT_WITH_SECONDS(){return Q5}static get DATETIME_MED(){return Z5}static get DATETIME_MED_WITH_SECONDS(){return J5}static get DATETIME_MED_WITH_WEEKDAY(){return Dme}static get DATETIME_FULL(){return e8}static get DATETIME_FULL_WITH_SECONDS(){return t8}static get DATETIME_HUGE(){return r8}static get DATETIME_HUGE_WITH_SECONDS(){return n8}};function Nx(r){if(At.isDateTime(r))return r;if(r&&r.valueOf&&sf(r.valueOf()))return At.fromJSDate(r);if(r&&typeof r=="object")return At.fromObject(r);throw new qo(`Unknown datetime argument: ${r}, of type ${typeof r}`)}var D1={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},vge={allowHtml:!0};({...D1,...vge});var g1=class r{constructor(e){le(this,"value");le(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}},v1=class r{constructor(e){le(this,"error");le(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)}},YS;(function(r){function e(o){return new g1(o)}r.success=e;function t(o){return new v1(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})(YS||(YS={}));var yge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},KS={exports:{}};KS.exports;(function(r,e){(function(t,n){r.exports=n()})(typeof self<"u"?self:yge,function(){return(function(t){var n={};function i(o){if(n[o])return n[o].exports;var s=n[o]={i:o,l:!1,exports:{}};return t[o].call(s.exports,s,s.exports,i),s.l=!0,s.exports}return i.m=t,i.c=n,i.d=function(o,s,a){i.o(o,s)||Object.defineProperty(o,s,{configurable:!1,enumerable:!0,get:a})},i.r=function(o){Object.defineProperty(o,"__esModule",{value:!0})},i.n=function(o){var s=o&&o.__esModule?function(){return o.default}:function(){return o};return i.d(s,"a",s),s},i.o=function(o,s){return Object.prototype.hasOwnProperty.call(o,s)},i.p="",i(i.s=0)})([function(t,n,i){function o(T){if(!(this instanceof o))return new o(T);this._=T}var s=o.prototype;function a(T,k){for(var N=0;N<T;N++)k(N)}function l(T,k,N){return(function(K,J){a(J.length,function(ue){K(J[ue],ue,J)})})(function(K,J,ue){k=T(k,K,J,ue)},N),k}function c(T,k){return l(function(N,K,J,ue){return N.concat([T(K,J,ue)])},[],k)}function u(T,k){var N={v:0,buf:k};return a(T,function(){var K;N={v:N.v<<1|(K=N.buf,K[0]>>7),buf:(function(J){var ue=l(function(ve,Ve,vt,Pr){return ve.concat(vt===Pr.length-1?Buffer.from([Ve,0]).readUInt16BE(0):Pr.readUInt16BE(vt))},[],J);return Buffer.from(c(function(ve){return(ve<<1&65535)>>8},ue))})(N.buf)}}),N}function d(){return typeof Buffer<"u"}function f(){if(!d())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function p(T){f();var k=l(function(ue,ve){return ue+ve},0,T);if(k%8!=0)throw new Error("The bits ["+T.join(", ")+"] add up to "+k+" which is not an even number of bytes; the total should be divisible by 8");var N,K=k/8,J=(N=function(ue){return ue>48},l(function(ue,ve){return ue||(N(ve)?ve:ue)},null,T));if(J)throw new Error(J+" bit range requested exceeds 48 bit (6 byte) Number max.");return new o(function(ue,ve){var Ve=K+ve;return Ve>ue.length?P(ve,K.toString()+" bytes"):D(Ve,l(function(vt,Pr){var jt=u(Pr,vt.buf);return{coll:vt.coll.concat(jt.v),buf:jt.buf}},{coll:[],buf:ue.slice(ve,Ve)},T).coll)})}function m(T,k){return new o(function(N,K){return f(),K+k>N.length?P(K,k+" bytes for "+T):D(K+k,N.slice(K,K+k))})}function v(T,k){if(typeof(N=k)!="number"||Math.floor(N)!==N||k<0||k>6)throw new Error(T+" requires integer length in range [0, 6].");var N}function g(T){return v("uintBE",T),m("uintBE("+T+")",T).map(function(k){return k.readUIntBE(0,T)})}function y(T){return v("uintLE",T),m("uintLE("+T+")",T).map(function(k){return k.readUIntLE(0,T)})}function w(T){return v("intBE",T),m("intBE("+T+")",T).map(function(k){return k.readIntBE(0,T)})}function x(T){return v("intLE",T),m("intLE("+T+")",T).map(function(k){return k.readIntLE(0,T)})}function C(T){return T instanceof o}function _(T){return{}.toString.call(T)==="[object Array]"}function E(T){return d()&&Buffer.isBuffer(T)}function D(T,k){return{status:!0,index:T,value:k,furthest:-1,expected:[]}}function P(T,k){return _(k)||(k=[k]),{status:!1,index:-1,value:null,furthest:T,expected:k}}function V(T,k){if(!k||T.furthest>k.furthest)return T;var N=T.furthest===k.furthest?(function(K,J){if((function(){if(o._supportsSet!==void 0)return o._supportsSet;var pr=typeof Set<"u";return o._supportsSet=pr,pr})()&&Array.from){for(var ue=new Set(K),ve=0;ve<J.length;ve++)ue.add(J[ve]);var Ve=Array.from(ue);return Ve.sort(),Ve}for(var vt={},Pr=0;Pr<K.length;Pr++)vt[K[Pr]]=!0;for(var jt=0;jt<J.length;jt++)vt[J[jt]]=!0;var $i=[];for(var yt in vt)({}).hasOwnProperty.call(vt,yt)&&$i.push(yt);return $i.sort(),$i})(T.expected,k.expected):k.expected;return{status:T.status,index:T.index,value:T.value,furthest:k.furthest,expected:N}}var j={};function oe(T,k){if(E(T))return{offset:k,line:-1,column:-1};T in j||(j[T]={});for(var N=j[T],K=0,J=0,ue=0,ve=k;ve>=0;){if(ve in N){K=N[ve].line,ue===0&&(ue=N[ve].lineStart);break}(T.charAt(ve)===`
|
||
`||T.charAt(ve)==="\r"&&T.charAt(ve+1)!==`
|
||
`)&&(J++,ue===0&&(ue=ve+1)),ve--}var Ve=K+J,vt=k-ue;return N[k]={line:Ve,lineStart:ue},{offset:k,line:Ve+1,column:vt+1}}function se(T){if(!C(T))throw new Error("not a parser: "+T)}function M(T,k){return typeof T=="string"?T.charAt(k):T[k]}function U(T){if(typeof T!="number")throw new Error("not a number: "+T)}function q(T){if(typeof T!="function")throw new Error("not a function: "+T)}function B(T){if(typeof T!="string")throw new Error("not a string: "+T)}var ie=2,W=3,Y=8,X=5*Y,ae=4*Y,pe=" ";function ge(T,k){return new Array(k+1).join(T)}function be(T,k,N){var K=k-T.length;return K<=0?T:ge(N,K)+T}function xe(T,k,N,K){return{from:T-k>0?T-k:0,to:T+N>K?K:T+N}}function Ue(T,k){var N,K,J,ue,ve,Ve=k.index,vt=Ve.offset,Pr=1;if(vt===T.length)return"Got the end of the input";if(E(T)){var jt=vt-vt%Y,$i=vt-jt,yt=xe(jt,X,ae+Y,T.length),pr=c(function(kt){return c(function(Eo){return be(Eo.toString(16),2,"0")},kt)},(function(kt,Eo){var ua=kt.length,Es=[],ln=0;if(ua<=Eo)return[kt.slice()];for(var _n=0;_n<ua;_n++)Es[ln]||Es.push([]),Es[ln].push(kt[_n]),(_n+1)%Eo==0&&ln++;return Es})(T.slice(yt.from,yt.to).toJSON().data,Y));ue=(function(kt){return kt.from===0&&kt.to===1?{from:kt.from,to:kt.to}:{from:kt.from/Y,to:Math.floor(kt.to/Y)}})(yt),K=jt/Y,N=3*$i,$i>=4&&(N+=1),Pr=2,J=c(function(kt){return kt.length<=4?kt.join(" "):kt.slice(0,4).join(" ")+" "+kt.slice(4).join(" ")},pr),(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2)}else{var kr=T.split(/\r\n|[\n\r\u2028\u2029]/);N=Ve.column-1,K=Ve.line-1,ue=xe(K,ie,W,kr.length),J=kr.slice(ue.from,ue.to),ve=ue.to.toString().length}var Gn=K-ue.from;return E(T)&&(ve=(8*(ue.to>0?ue.to-1:ue.to)).toString(16).length)<2&&(ve=2),l(function(kt,Eo,ua){var Es,ln=ua===Gn,_n=ln?"> ":pe;return Es=E(T)?be((8*(ue.from+ua)).toString(16),ve,"0"):be((ue.from+ua+1).toString(),ve," "),[].concat(kt,[_n+Es+" | "+Eo],ln?[pe+ge(" ",ve)+" | "+be("",N," ")+ge("^",Pr)]:[])},[],J).join(`
|
||
`)}function $t(T,k){return[`
|
||
`,"-- PARSING FAILED "+ge("-",50),`
|
||
|
||
`,Ue(T,k),`
|
||
|
||
`,(N=k.expected,N.length===1?`Expected:
|
||
|
||
`+N[0]:`Expected one of the following:
|
||
|
||
`+N.join(", ")),`
|
||
`].join("");var N}function Ne(T){return T.flags!==void 0?T.flags:[T.global?"g":"",T.ignoreCase?"i":"",T.multiline?"m":"",T.unicode?"u":"",T.sticky?"y":""].join("")}function Ke(){for(var T=[].slice.call(arguments),k=T.length,N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=new Array(k),Ve=0;Ve<k;Ve+=1){if(!(ue=V(T[Ve]._(K,J),ue)).status)return ue;ve[Ve]=ue.value,J=ue.index}return V(D(J,ve),ue)})}function Qe(){var T=[].slice.call(arguments);if(T.length===0)throw new Error("seqMap needs at least one argument");var k=T.pop();return q(k),Ke.apply(null,T).map(function(N){return k.apply(null,N)})}function ye(){var T=[].slice.call(arguments),k=T.length;if(k===0)return ut("zero alternates");for(var N=0;N<k;N+=1)se(T[N]);return o(function(K,J){for(var ue,ve=0;ve<T.length;ve+=1)if((ue=V(T[ve]._(K,J),ue)).status)return ue;return ue})}function We(T,k){return mt(T,k).or(Be([]))}function mt(T,k){return se(T),se(k),Qe(T,k.then(T).many(),function(N,K){return[N].concat(K)})}function He(T){B(T);var k="'"+T+"'";return o(function(N,K){var J=K+T.length,ue=N.slice(K,J);return ue===T?D(J,ue):P(K,k)})}function _e(T,k){(function(J){if(!(J instanceof RegExp))throw new Error("not a regexp: "+J);for(var ue=Ne(J),ve=0;ve<ue.length;ve++){var Ve=ue.charAt(ve);if(Ve!=="i"&&Ve!=="m"&&Ve!=="u"&&Ve!=="s")throw new Error('unsupported regexp flag "'+Ve+'": '+J)}})(T),arguments.length>=2?U(k):k=0;var N=(function(J){return RegExp("^(?:"+J.source+")",Ne(J))})(T),K=""+T;return o(function(J,ue){var ve=N.exec(J.slice(ue));if(ve){if(0<=k&&k<=ve.length){var Ve=ve[0],vt=ve[k];return D(ue+Ve.length,vt)}return P(ue,"valid match group (0 to "+ve.length+") in "+K)}return P(ue,K)})}function Be(T){return o(function(k,N){return D(N,T)})}function ut(T){return o(function(k,N){return P(N,T)})}function or(T){if(C(T))return o(function(k,N){var K=T._(k,N);return K.index=N,K.value="",K});if(typeof T=="string")return or(He(T));if(T instanceof RegExp)return or(_e(T));throw new Error("not a string, regexp, or parser: "+T)}function yr(T){return se(T),o(function(k,N){var K=T._(k,N),J=k.slice(N,K.index);return K.status?P(N,'not "'+J+'"'):D(N,null)})}function Pt(T){return q(T),o(function(k,N){var K=M(k,N);return N<k.length&&T(K)?D(N+1,K):P(N,"a character/byte matching "+T)})}function Ar(T,k){arguments.length<2&&(k=T,T=void 0);var N=o(function(K,J){return N._=k()._,N._(K,J)});return T?N.desc(T):N}function ur(){return ut("fantasy-land/empty")}s.parse=function(T){if(typeof T!="string"&&!E(T))throw new Error(".parse must be called with a string or Buffer as its argument");var k,N=this.skip(xo)._(T,0);return k=N.status?{status:!0,value:N.value}:{status:!1,index:oe(T,N.furthest),expected:N.expected},delete j[T],k},s.tryParse=function(T){var k=this.parse(T);if(k.status)return k.value;var N=$t(T,k),K=new Error(N);throw K.type="ParsimmonError",K.result=k,K},s.assert=function(T,k){return this.chain(function(N){return T(N)?Be(N):ut(k)})},s.or=function(T){return ye(this,T)},s.trim=function(T){return this.wrap(T,T)},s.wrap=function(T,k){return Qe(T,this,k,function(N,K){return K})},s.thru=function(T){return T(this)},s.then=function(T){return se(T),Ke(this,T).map(function(k){return k[1]})},s.many=function(){var T=this;return o(function(k,N){for(var K=[],J=void 0;;){if(!(J=V(T._(k,N),J)).status)return V(D(N,K),J);if(N===J.index)throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause");N=J.index,K.push(J.value)}})},s.tieWith=function(T){return B(T),this.map(function(k){if((function(J){if(!_(J))throw new Error("not an array: "+J)})(k),k.length){B(k[0]);for(var N=k[0],K=1;K<k.length;K++)B(k[K]),N+=T+k[K];return N}return""})},s.tie=function(){return this.tieWith("")},s.times=function(T,k){var N=this;return arguments.length<2&&(k=T),U(T),U(k),o(function(K,J){for(var ue=[],ve=void 0,Ve=void 0,vt=0;vt<T;vt+=1){if(Ve=V(ve=N._(K,J),Ve),!ve.status)return Ve;J=ve.index,ue.push(ve.value)}for(;vt<k&&(Ve=V(ve=N._(K,J),Ve),ve.status);vt+=1)J=ve.index,ue.push(ve.value);return V(D(J,ue),Ve)})},s.result=function(T){return this.map(function(){return T})},s.atMost=function(T){return this.times(0,T)},s.atLeast=function(T){return Qe(this.times(T),this.many(),function(k,N){return k.concat(N)})},s.map=function(T){q(T);var k=this;return o(function(N,K){var J=k._(N,K);return J.status?V(D(J.index,T(J.value)),J):J})},s.contramap=function(T){q(T);var k=this;return o(function(N,K){var J=k.parse(T(N.slice(K)));return J.status?D(K+N.length,J.value):J})},s.promap=function(T,k){return q(T),q(k),this.contramap(T).map(k)},s.skip=function(T){return Ke(this,T).map(function(k){return k[0]})},s.mark=function(){return Qe(dt,this,dt,function(T,k,N){return{start:T,value:k,end:N}})},s.node=function(T){return Qe(dt,this,dt,function(k,N,K){return{name:T,value:N,start:k,end:K}})},s.sepBy=function(T){return We(this,T)},s.sepBy1=function(T){return mt(this,T)},s.lookahead=function(T){return this.skip(or(T))},s.notFollowedBy=function(T){return this.skip(yr(T))},s.desc=function(T){_(T)||(T=[T]);var k=this;return o(function(N,K){var J=k._(N,K);return J.status||(J.expected=T),J})},s.fallback=function(T){return this.or(Be(T))},s.ap=function(T){return Qe(T,this,function(k,N){return k(N)})},s.chain=function(T){var k=this;return o(function(N,K){var J=k._(N,K);return J.status?V(T(J.value)._(N,J.index),J):J})},s.concat=s.or,s.empty=ur,s.of=Be,s["fantasy-land/ap"]=s.ap,s["fantasy-land/chain"]=s.chain,s["fantasy-land/concat"]=s.concat,s["fantasy-land/empty"]=s.empty,s["fantasy-land/of"]=s.of,s["fantasy-land/map"]=s.map;var dt=o(function(T,k){return D(k,oe(T,k))}),Ft=o(function(T,k){return k>=T.length?P(k,"any character/byte"):D(k+1,M(T,k))}),Hn=o(function(T,k){return D(T.length,T.slice(k))}),xo=o(function(T,k){return k<T.length?P(k,"EOF"):D(k,null)}),xs=_e(/[0-9]/).desc("a digit"),jn=_e(/[0-9]*/).desc("optional digits"),re=_e(/[a-z]/i).desc("a letter"),Ie=_e(/[a-z]*/i).desc("optional letters"),dr=_e(/\s*/).desc("optional whitespace"),br=_e(/\s+/).desc("whitespace"),Tn=He("\r"),Ho=He(`
|
||
`),Ka=He(`\r
|
||
`),Xa=ye(Ka,Ho,Tn).desc("newline"),Jc=ye(Xa,xo);o.all=Hn,o.alt=ye,o.any=Ft,o.cr=Tn,o.createLanguage=function(T){var k={};for(var N in T)({}).hasOwnProperty.call(T,N)&&(function(K){k[K]=Ar(function(){return T[K](k)})})(N);return k},o.crlf=Ka,o.custom=function(T){return o(T(D,P))},o.digit=xs,o.digits=jn,o.empty=ur,o.end=Jc,o.eof=xo,o.fail=ut,o.formatError=$t,o.index=dt,o.isParser=C,o.lazy=Ar,o.letter=re,o.letters=Ie,o.lf=Ho,o.lookahead=or,o.makeFailure=P,o.makeSuccess=D,o.newline=Xa,o.noneOf=function(T){return Pt(function(k){return T.indexOf(k)<0}).desc("none of '"+T+"'")},o.notFollowedBy=yr,o.of=Be,o.oneOf=function(T){for(var k=T.split(""),N=0;N<k.length;N++)k[N]="'"+k[N]+"'";return Pt(function(K){return T.indexOf(K)>=0}).desc(k)},o.optWhitespace=dr,o.Parser=o,o.range=function(T,k){return Pt(function(N){return T<=N&&N<=k}).desc(T+"-"+k)},o.regex=_e,o.regexp=_e,o.sepBy=We,o.sepBy1=mt,o.seq=Ke,o.seqMap=Qe,o.seqObj=function(){for(var T,k={},N=0,K=(T=arguments,Array.prototype.slice.call(T)),J=K.length,ue=0;ue<J;ue+=1){var ve=K[ue];if(!C(ve)){if(_(ve)&&ve.length===2&&typeof ve[0]=="string"&&C(ve[1])){var Ve=ve[0];if(Object.prototype.hasOwnProperty.call(k,Ve))throw new Error("seqObj: duplicate key "+Ve);k[Ve]=!0,N++;continue}throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.")}}if(N===0)throw new Error("seqObj expects at least one named parser, found zero");return o(function(vt,Pr){for(var jt,$i={},yt=0;yt<J;yt+=1){var pr,kr;if(_(K[yt])?(pr=K[yt][0],kr=K[yt][1]):(pr=null,kr=K[yt]),!(jt=V(kr._(vt,Pr),jt)).status)return jt;pr&&($i[pr]=jt.value),Pr=jt.index}return V(D(Pr,$i),jt)})},o.string=He,o.succeed=Be,o.takeWhile=function(T){return q(T),o(function(k,N){for(var K=N;K<k.length&&T(M(k,K));)K++;return D(K,k.slice(N,K))})},o.test=Pt,o.whitespace=br,o["fantasy-land/empty"]=ur,o["fantasy-land/of"]=Be,o.Binary={bitSeq:p,bitSeqObj:function(T){f();var k={},N=0,K=c(function(ue){if(_(ue)){var ve=ue;if(ve.length!==2)throw new Error("["+ve.join(", ")+"] should be length 2, got length "+ve.length);if(B(ve[0]),U(ve[1]),Object.prototype.hasOwnProperty.call(k,ve[0]))throw new Error("duplicate key in bitSeqObj: "+ve[0]);return k[ve[0]]=!0,N++,ve}return U(ue),[null,ue]},T);if(N<1)throw new Error("bitSeqObj expects at least one named pair, got ["+T.join(", ")+"]");var J=c(function(ue){return ue[0]},K);return p(c(function(ue){return ue[1]},K)).map(function(ue){return l(function(ve,Ve){return Ve[0]!==null&&(ve[Ve[0]]=Ve[1]),ve},{},c(function(ve,Ve){return[ve,ue[Ve]]},J))})},byte:function(T){if(f(),U(T),T>255)throw new Error("Value specified to byte constructor ("+T+"=0x"+T.toString(16)+") is larger in value than a single byte.");var k=(T>15?"0x":"0x0")+T.toString(16);return o(function(N,K){var J=M(N,K);return J===T?D(K+1,J):P(K,k)})},buffer:function(T){return m("buffer",T).map(function(k){return Buffer.from(k)})},encodedString:function(T,k){return m("string",k).map(function(N){return N.toString(T)})},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:y,uint8LE:y(1),uint16LE:y(2),uint32LE:y(4),intBE:w,int8BE:w(1),int16BE:w(2),int32BE:w(4),intLE:x,int8LE:x(1),int16LE:x(2),int32LE:x(4),floatBE:m("floatBE",4).map(function(T){return T.readFloatBE(0)}),floatLE:m("floatLE",4).map(function(T){return T.readFloatLE(0)}),doubleBE:m("doubleBE",8).map(function(T){return T.readDoubleBE(0)}),doubleLE:m("doubleLE",8).map(function(T){return T.readDoubleLE(0)})},t.exports=o}])})})(KS,KS.exports);var R=KS.exports,I1=()=>/[#*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 N8(r){return r==null?r:r.shiftToAll().normalize()}function R5(r){return r.includes("/")&&(r=r.substring(r.lastIndexOf("/")+1)),r.endsWith(".md")&&(r=r.substring(0,r.length-3)),r}R.alt(R.regex(new RegExp(I1(),"")),R.regex(/[0-9\p{Letter}_-]+/u).map(r=>r.toLocaleLowerCase()),R.whitespace.map(r=>"-"),R.any.map(r=>"")).many().map(r=>r.join(""));var bge=R.alt(R.regex(new RegExp(I1(),"")),R.regex(/[0-9\p{Letter}_-]+/u),R.whitespace.map(r=>" "),R.any.map(r=>" ")).many().map(r=>r.join("").split(/\s+/).join(" ").trim());function wge(r){return bge.tryParse(r)}function Cge(r){return r=N8(r),r=Xe.fromObject(Object.fromEntries(Object.entries(r.toObject()).filter(([,e])=>e!=0))),r.toHuman()}var qx;(function(r){function e(C,_=D1,E=!1){let D=t(C);if(!D)return _.renderNullAs;switch(D.type){case"null":return _.renderNullAs;case"string":return D.value;case"number":case"boolean":return""+D.value;case"html":return D.value.outerHTML;case"widget":return D.value.markdown();case"link":return D.value.markdown();case"function":return"<function>";case"array":let P="";return E&&(P+="["),P+=D.value.map(V=>e(V,_,!0)).join(", "),E&&(P+="]"),P;case"object":return"{ "+Object.entries(D.value).map(V=>V[0]+": "+e(V[1],_,!0)).join(", ")+" }";case"date":return D.value.second==0&&D.value.hour==0&&D.value.minute==0?D.value.toFormat(_.defaultDateFormat):D.value.toFormat(_.defaultDateTimeFormat);case"duration":return Cge(D.value)}}r.toString=e;function t(C){return f(C)?{type:"null",value:C}:c(C)?{type:"number",value:C}:l(C)?{type:"string",value:C}:m(C)?{type:"boolean",value:C}:d(C)?{type:"duration",value:C}:u(C)?{type:"date",value:C}:g(C)?{type:"widget",value:C}:p(C)?{type:"array",value:C}:v(C)?{type:"link",value:C}:x(C)?{type:"function",value:C}:y(C)?{type:"html",value:C}:w(C)?{type:"object",value:C}:void 0}r.wrapValue=t;function n(C,_){if(w(C)){let E={};for(let[D,P]of Object.entries(C))E[D]=n(P,_);return E}else if(p(C)){let E=[];for(let D of C)E.push(n(D,_));return E}else return _(C)}r.mapLeaves=n;function i(C,_,E){if(C===void 0&&(C=null),_===void 0&&(_=null),C===null&&_===null)return 0;if(C===null)return-1;if(_===null)return 1;let D=t(C),P=t(_);if(D===void 0&&P===void 0)return 0;if(D===void 0)return-1;if(P===void 0)return 1;if(D.type!=P.type)return D.type.localeCompare(P.type);if(D.value===P.value)return 0;switch(D.type){case"string":return D.value.localeCompare(P.value);case"number":return D.value<P.value?-1:D.value==P.value?0:1;case"null":return 0;case"boolean":return D.value==P.value?0:D.value?1:-1;case"link":let V=D.value,j=P.value,oe=E??(ae=>ae),se=oe(V.path).localeCompare(oe(j.path));if(se!=0)return se;let M=V.type.localeCompare(j.type);return M!=0?M:V.subpath&&!j.subpath?1:!V.subpath&&j.subpath?-1:!V.subpath&&!j.subpath?0:(V.subpath??"").localeCompare(j.subpath??"");case"date":return D.value<P.value?-1:D.value.equals(P.value)?0:1;case"duration":return D.value<P.value?-1:D.value.equals(P.value)?0:1;case"array":let U=D.value,q=P.value;for(let ae=0;ae<Math.min(U.length,q.length);ae++){let pe=i(U[ae],q[ae]);if(pe!=0)return pe}return U.length-q.length;case"object":let B=D.value,ie=P.value,W=Array.from(Object.keys(B)),Y=Array.from(Object.keys(ie));W.sort(),Y.sort();let X=i(W,Y);if(X!=0)return X;for(let ae of W){let pe=i(B[ae],ie[ae]);if(pe!=0)return pe}return 0;case"widget":case"html":case"function":return 0}}r.compareValue=i;function o(C){return t(C)?.type}r.typeOf=o;function s(C){let _=t(C);if(!_)return!1;switch(_.type){case"number":return _.value!=0;case"string":return _.value.length>0;case"boolean":return _.value;case"link":return!!_.value.path;case"date":return _.value.toMillis()!=0;case"duration":return _.value.as("seconds")!=0;case"object":return Object.keys(_.value).length>0;case"array":return _.value.length>0;case"null":return!1;case"html":case"widget":case"function":return!0}}r.isTruthy=s;function a(C){if(C==null)return C;if(r.isArray(C))return[].concat(C.map(_=>a(_)));if(r.isObject(C)){let _={};for(let[E,D]of Object.entries(C))_[E]=a(D);return _}else return C}r.deepCopy=a;function l(C){return typeof C=="string"}r.isString=l;function c(C){return typeof C=="number"}r.isNumber=c;function u(C){return C instanceof At}r.isDate=u;function d(C){return C instanceof Xe}r.isDuration=d;function f(C){return C==null}r.isNull=f;function p(C){return Array.isArray(C)}r.isArray=p;function m(C){return typeof C=="boolean"}r.isBoolean=m;function v(C){return C instanceof XS}r.isLink=v;function g(C){return C instanceof Wx}r.isWidget=g;function y(C){return typeof HTMLElement<"u"?C instanceof HTMLElement:!1}r.isHtml=y;function w(C){return typeof C=="object"&&!y(C)&&!g(C)&&!p(C)&&!d(C)&&!u(C)&&!v(C)&&C!==void 0&&!f(C)}r.isObject=w;function x(C){return typeof C=="function"}r.isFunction=x})(qx||(qx={}));var $5;(function(r){function e(i){return qx.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})($5||($5={}));var XS=class r{constructor(e){le(this,"path");le(this,"display");le(this,"subpath");le(this,"embed");le(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:wge(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+="|"+R5(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 R5(this.path).replace(".md","")}},Wx=class{constructor(e){le(this,"$widget");this.$widget=e}},y1=class extends Wx{constructor(t,n){super("dataview:list-pair");le(this,"key");le(this,"value");this.key=t,this.value=n}markdown(){return`${qx.toString(this.key)}: ${qx.toString(this.value)}`}},b1=class extends Wx{constructor(t,n){super("dataview:external-link");le(this,"url");le(this,"display");this.url=t,this.display=n}markdown(){return`[${this.display??this.url}](${this.url})`}},O5;(function(r){function e(s,a){return new y1(s,a)}r.listPair=e;function t(s,a){return new b1(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})(O5||(O5={}));var Kr;(function(r){function e(f){return{type:"variable",name:f}}r.variable=e;function t(f){return{type:"literal",value:f}}r.literal=t;function n(f,p,m){return{type:"binaryop",left:f,op:p,right:m}}r.binaryOp=n;function i(f,p){return{type:"index",object:f,index:p}}r.index=i;function o(f){let p=f.split("."),m=r.variable(p[0]);for(let v=1;v<p.length;v++)m=r.index(m,r.literal(p[v]));return m}r.indexVariable=o;function s(f,p){return{type:"lambda",arguments:f,value:p}}r.lambda=s;function a(f,p){return{type:"function",func:f,arguments:p}}r.func=a;function l(f){return{type:"list",values:f}}r.list=l;function c(f){return{type:"object",values:f}}r.object=c;function u(f){return{type:"negated",child:f}}r.negate=u;function d(f){return f=="<="||f=="<"||f==">"||f==">="||f=="!="||f=="="}r.isCompareOp=d,r.NULL=r.literal(null)})(Kr||(Kr={}));var Bl;(function(r){function e(u){return{type:"tag",tag:u}}r.tag=e;function t(u){return{type:"csv",path:u}}r.csv=t;function n(u){return{type:"folder",folder:u}}r.folder=n;function i(u,d){return{type:"link",file:u,direction:d?"incoming":"outgoing"}}r.link=i;function o(u,d,f){return{type:"binaryop",left:u,op:d,right:f}}r.binaryOp=o;function s(u,d){return{type:"binaryop",left:u,op:"&",right:d}}r.and=s;function a(u,d){return{type:"binaryop",left:u,op:"|",right:d}}r.or=a;function l(u){return{type:"negate",child:u}}r.negate=l;function c(){return{type:"empty"}}r.empty=c})(Bl||(Bl={}));var N5=new RegExp(I1(),""),w1={year:Xe.fromObject({years:1}),years:Xe.fromObject({years:1}),yr:Xe.fromObject({years:1}),yrs:Xe.fromObject({years:1}),month:Xe.fromObject({months:1}),months:Xe.fromObject({months:1}),mo:Xe.fromObject({months:1}),mos:Xe.fromObject({months:1}),week:Xe.fromObject({weeks:1}),weeks:Xe.fromObject({weeks:1}),wk:Xe.fromObject({weeks:1}),wks:Xe.fromObject({weeks:1}),w:Xe.fromObject({weeks:1}),day:Xe.fromObject({days:1}),days:Xe.fromObject({days:1}),d:Xe.fromObject({days:1}),hour:Xe.fromObject({hours:1}),hours:Xe.fromObject({hours:1}),hr:Xe.fromObject({hours:1}),hrs:Xe.fromObject({hours:1}),h:Xe.fromObject({hours:1}),minute:Xe.fromObject({minutes:1}),minutes:Xe.fromObject({minutes:1}),min:Xe.fromObject({minutes:1}),mins:Xe.fromObject({minutes:1}),m:Xe.fromObject({minutes:1}),second:Xe.fromObject({seconds:1}),seconds:Xe.fromObject({seconds:1}),sec:Xe.fromObject({seconds:1}),secs:Xe.fromObject({seconds:1}),s:Xe.fromObject({seconds:1})},C1={now:()=>At.local(),today:()=>At.local().startOf("day"),yesterday:()=>At.local().startOf("day").minus(Xe.fromObject({days:1})),tomorrow:()=>At.local().startOf("day").plus(Xe.fromObject({days:1})),sow:()=>At.local().startOf("week"),"start-of-week":()=>At.local().startOf("week"),eow:()=>At.local().endOf("week"),"end-of-week":()=>At.local().endOf("week"),soy:()=>At.local().startOf("year"),"start-of-year":()=>At.local().startOf("year"),eoy:()=>At.local().endOf("year"),"end-of-year":()=>At.local().endOf("year"),som:()=>At.local().startOf("month"),"start-of-month":()=>At.local().startOf("month"),eom:()=>At.local().endOf("month"),"end-of-month":()=>At.local().endOf("month")},x1=["FROM","WHERE","LIMIT","GROUP","FLATTEN"];function xge(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 Ege(r){let[e,t]=xge(r);return XS.infer(e,!1,t)}function Lx(r,e,t){return R.seqMap(r,R.seq(R.optWhitespace,e,R.optWhitespace,r).many(),(n,i)=>{if(i.length==0)return n;let o=t(n,i[0][1],i[0][3]);for(let s=1;s<i.length;s++)o=t(o,i[s][1],i[s][3]);return o})}function Tge(r,...e){return R.custom((t,n)=>(i,o)=>{let s=r._(i,o);if(!s.status)return s;for(let a of e){let l=a(s.value)._(i,s.index);if(!l.status)return s;s=l}return s})}var ja=R.createLanguage({number:r=>R.regexp(/-?[0-9]+(\.[0-9]+)?/).map(e=>Number.parseFloat(e)).desc("number"),string:r=>R.string('"').then(R.alt(r.escapeCharacter,R.noneOf('"\\')).atLeast(0).map(e=>e.join(""))).skip(R.string('"')).desc("string"),escapeCharacter:r=>R.string("\\").then(R.any).map(e=>e==='"'?'"':e==="\\"?"\\":"\\"+e),bool:r=>R.regexp(/true|false|True|False/).map(e=>e.toLowerCase()=="true").desc("boolean ('true' or 'false')"),tag:r=>R.seqMap(R.string("#"),R.alt(R.regexp(/[^\u2000-\u206F\u2E00-\u2E7F'!"#$%&()*+,.:;<=>?@^`{|}~\[\]\\\s]/).desc("text")).many(),(e,t)=>e+t.join("")).desc("tag ('#hello/stuff')"),identifier:r=>R.seqMap(R.alt(R.regexp(/\p{Letter}/u),R.regexp(N5).desc("text")),R.alt(R.regexp(/[0-9\p{Letter}_-]/u),R.regexp(N5).desc("text")).many(),(e,t)=>e+t.join("")).desc("variable identifier"),link:r=>R.regexp(/\[\[([^\[\]]*?)\]\]/u,1).map(e=>Ege(e)).desc("file link"),embedLink:r=>R.seqMap(R.string("!").atMost(1),r.link,(e,t)=>(e.length>0&&(t.embed=!0),t)).desc("file link"),binaryPlusMinus:r=>R.regexp(/\+|-/).map(e=>e).desc("'+' or '-'"),binaryMulDiv:r=>R.regexp(/\*|\/|%/).map(e=>e).desc("'*' or '/' or '%'"),binaryCompareOp:r=>R.regexp(/>=|<=|!=|>|<|=/).map(e=>e).desc("'>=' or '<=' or '!=' or '=' or '>' or '<'"),binaryBooleanOp:r=>R.regexp(/and|or|&|\|/i).map(e=>e.toLowerCase()=="and"?"&":e.toLowerCase()=="or"?"|":e).desc("'and' or 'or'"),rootDate:r=>R.seqMap(R.regexp(/\d{4}/),R.string("-"),R.regexp(/\d{2}/),(e,t,n)=>At.fromObject({year:Number.parseInt(e),month:Number.parseInt(n)})).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),dateShorthand:r=>R.alt(...Object.keys(C1).sort((e,t)=>t.length-e.length).map(R.string)),date:r=>Tge(r.rootDate,e=>R.seqMap(R.string("-"),R.regexp(/\d{2}/),(t,n)=>e.set({day:Number.parseInt(n)})),e=>R.seqMap(R.string("T"),R.regexp(/\d{2}/),(t,n)=>e.set({hour:Number.parseInt(n)})),e=>R.seqMap(R.string(":"),R.regexp(/\d{2}/),(t,n)=>e.set({minute:Number.parseInt(n)})),e=>R.seqMap(R.string(":"),R.regexp(/\d{2}/),(t,n)=>e.set({second:Number.parseInt(n)})),e=>R.alt(R.seqMap(R.string("."),R.regexp(/\d{3}/),(t,n)=>e.set({millisecond:Number.parseInt(n)})),R.succeed(e)),e=>R.alt(R.seqMap(R.string("+").or(R.string("-")),R.regexp(/\d{1,2}(:\d{2})?/),(t,n)=>e.setZone("UTC"+t+n,{keepLocalTime:!0})),R.seqMap(R.string("Z"),()=>e.setZone("utc",{keepLocalTime:!0})),R.seqMap(R.string("["),R.regexp(/[0-9A-Za-z+-\/]+/u),R.string("]"),(t,n,i)=>e.setZone(n,{keepLocalTime:!0})))).assert(e=>e.isValid,"valid date").desc("date in format YYYY-MM[-DDTHH-MM-SS.MS]"),datePlus:r=>R.alt(r.dateShorthand.map(e=>C1[e]()),r.date).desc("date in format YYYY-MM[-DDTHH-MM-SS.MS] or in shorthand"),durationType:r=>R.alt(...Object.keys(w1).sort((e,t)=>t.length-e.length).map(R.string)),duration:r=>R.seqMap(r.number,R.optWhitespace,r.durationType,(e,t,n)=>w1[n].mapUnits(i=>i*e)).sepBy1(R.string(",").trim(R.optWhitespace).or(R.optWhitespace)).map(e=>e.reduce((t,n)=>t.plus(n))).desc("duration like 4hr2min"),rawNull:r=>R.string("null"),tagSource:r=>r.tag.map(e=>Bl.tag(e)),csvSource:r=>R.seqMap(R.string("csv(").skip(R.optWhitespace),r.string,R.string(")"),(e,t,n)=>Bl.csv(t)),linkIncomingSource:r=>r.link.map(e=>Bl.link(e.path,!0)),linkOutgoingSource:r=>R.seqMap(R.string("outgoing(").skip(R.optWhitespace),r.link,R.string(")"),(e,t,n)=>Bl.link(t.path,!1)),folderSource:r=>r.string.map(e=>Bl.folder(e)),parensSource:r=>R.seqMap(R.string("("),R.optWhitespace,r.source,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>n),negateSource:r=>R.seqMap(R.alt(R.string("-"),R.string("!")),r.atomSource,(e,t)=>Bl.negate(t)),atomSource:r=>R.alt(r.parensSource,r.negateSource,r.linkOutgoingSource,r.linkIncomingSource,r.folderSource,r.tagSource,r.csvSource),binaryOpSource:r=>Lx(r.atomSource,r.binaryBooleanOp.map(e=>e),Bl.binaryOp),source:r=>r.binaryOpSource,variableField:r=>r.identifier.chain(e=>x1.includes(e.toUpperCase())?R.fail("Variable fields cannot be a keyword ("+x1.join(" or ")+")"):R.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=>R.seqMap(R.string("date("),R.optWhitespace,r.datePlus,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>Kr.literal(n)).desc("date"),durationField:r=>R.seqMap(R.string("dur("),R.optWhitespace,r.duration,R.optWhitespace,R.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(R.string(",").trim(R.optWhitespace)).wrap(R.string("[").skip(R.optWhitespace),R.optWhitespace.then(R.string("]"))).map(e=>Kr.list(e)).desc("list ('[1, 2, 3]')"),objectField:r=>R.seqMap(r.identifier.or(r.string),R.string(":").trim(R.optWhitespace),r.field,(e,t,n)=>({name:e,value:n})).sepBy(R.string(",").trim(R.optWhitespace)).wrap(R.string("{").skip(R.optWhitespace),R.optWhitespace.then(R.string("}"))).map(e=>{let t={};for(let n of e)t[n.name]=n.value;return Kr.object(t)}).desc("object ('{ a: 1, b: 2 }')"),atomInlineField:r=>R.alt(r.date,r.duration.map(e=>N8(e)),r.string,r.tag,r.embedLink,r.bool,r.number,r.rawNull),inlineFieldList:r=>r.atomInlineField.sepBy(R.string(",").trim(R.optWhitespace).lookahead(r.atomInlineField)),inlineField:r=>R.alt(R.seqMap(r.atomInlineField,R.string(",").trim(R.optWhitespace),r.inlineFieldList,(e,t,n)=>[e].concat(n)),r.atomInlineField),atomField:r=>R.alt(r.embedLink.map(e=>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=>R.seqMap(r.atomField,R.alt(r.dotPostfix,r.indexPostfix,r.functionPostfix).many(),(e,t)=>{let n=e;for(let i of t)switch(i.type){case"dot":n=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=>R.seqMap(R.string("!"),r.indexField,(e,t)=>Kr.negate(t)).desc("negated field"),parensField:r=>R.seqMap(R.string("("),R.optWhitespace,r.field,R.optWhitespace,R.string(")"),(e,t,n,i,o)=>n),lambdaField:r=>R.seqMap(r.identifier.sepBy(R.string(",").trim(R.optWhitespace)).wrap(R.string("(").trim(R.optWhitespace),R.string(")").trim(R.optWhitespace)),R.string("=>").trim(R.optWhitespace),r.field,(e,t,n)=>({type:"lambda",arguments:e,value:n})),dotPostfix:r=>R.seqMap(R.string("."),r.identifier,(e,t)=>({type:"dot",field:t})),indexPostfix:r=>R.seqMap(R.string("["),R.optWhitespace,r.field,R.optWhitespace,R.string("]"),(e,t,n,i,o)=>({type:"index",field:n})),functionPostfix:r=>R.seqMap(R.string("("),R.optWhitespace,r.field.sepBy(R.string(",").trim(R.optWhitespace)),R.optWhitespace,R.string(")"),(e,t,n,i,o)=>({type:"function",fields:n})),binaryMulDivField:r=>Lx(r.indexField,r.binaryMulDiv,Kr.binaryOp),binaryPlusMinusField:r=>Lx(r.binaryMulDivField,r.binaryPlusMinus,Kr.binaryOp),binaryCompareField:r=>Lx(r.binaryPlusMinusField,r.binaryCompareOp,Kr.binaryOp),binaryBooleanField:r=>Lx(r.binaryCompareField,r.binaryBooleanOp,Kr.binaryOp),binaryOpField:r=>r.binaryBooleanField,field:r=>r.binaryOpField});function _ge(r){try{return YS.success(ja.field.tryParse(r))}catch(e){return YS.failure(""+e)}}var QS;(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})(QS||(QS={}));function Age(r){return R.custom((e,t)=>(n,i)=>{let o=r._(n,i);return o.status?Object.assign({},o,{value:[o.value,n.substring(i,o.index)]}):o})}function kge(r){return r.split(/[\r\n]+/).map(e=>e.trim()).join("")}function L5(r,e){return R.eof.map(r).or(R.whitespace.then(e))}var L8=R.createLanguage({queryType:r=>R.alt(R.regexp(/TABLE|LIST|TASK|CALENDAR/i)).map(e=>e.toLowerCase()).desc("query type ('TABLE', 'LIST', 'TASK', or 'CALENDAR')"),explicitNamedField:r=>R.seqMap(ja.field.skip(R.whitespace),R.regexp(/AS/i).skip(R.whitespace),ja.identifier.or(ja.string),(e,t,n)=>QS.named(n,e)),comment:()=>R.Parser((r,e)=>{let t=r.substring(e);if(!t.startsWith("//"))return R.makeFailure(e,"Not a comment");t=t.split(`
|
||
`)[0];let n=t.substring(2).trim();return R.makeSuccess(e+t.length,n)}),namedField:r=>R.alt(r.explicitNamedField,Age(ja.field).map(([e,t])=>QS.named(kge(t),e))),sortField:r=>R.seqMap(ja.field.skip(R.optWhitespace),R.regexp(/ASCENDING|DESCENDING|ASC|DESC/i).atMost(1),(e,t)=>{let n=t.length==0?"ascending":t[0].toLowerCase();return n=="desc"&&(n="descending"),n=="asc"&&(n="ascending"),{field:e,direction:n}}),headerClause:r=>r.queryType.chain(e=>{switch(e){case"table":return L5(()=>({type:e,fields:[],showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),R.sepBy(r.namedField,R.string(",").trim(R.optWhitespace)),(t,n)=>({type:e,fields:n,showId:t.length==0})));case"list":return L5(()=>({type:e,format:void 0,showId:!0}),R.seqMap(R.regexp(/WITHOUT\s+ID/i).skip(R.optWhitespace).atMost(1),ja.field.atMost(1),(t,n)=>({type:e,format:n.length==1?n[0]:void 0,showId:t.length==0})));case"task":return R.succeed({type:e});case"calendar":return R.whitespace.then(R.seqMap(r.namedField,t=>({type:e,showId:!0,field:t})));default:return R.fail(`Unrecognized query type '${e}'`)}}).desc("TABLE or LIST or TASK or CALENDAR"),fromClause:r=>R.seqMap(R.regexp(/FROM/i),R.whitespace,ja.source,(e,t,n)=>n),whereClause:r=>R.seqMap(R.regexp(/WHERE/i),R.whitespace,ja.field,(e,t,n)=>({type:"where",clause:n})).desc("WHERE <expression>"),sortByClause:r=>R.seqMap(R.regexp(/SORT/i),R.whitespace,r.sortField.sepBy1(R.string(",").trim(R.optWhitespace)),(e,t,n)=>({type:"sort",fields:n})).desc("SORT field [ASC/DESC]"),limitClause:r=>R.seqMap(R.regexp(/LIMIT/i),R.whitespace,ja.field,(e,t,n)=>({type:"limit",amount:n})).desc("LIMIT <value>"),flattenClause:r=>R.seqMap(R.regexp(/FLATTEN/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"flatten",field:t})).desc("FLATTEN <value> [AS <name>]"),groupByClause:r=>R.seqMap(R.regexp(/GROUP BY/i).skip(R.whitespace),r.namedField,(e,t)=>({type:"group",field:t})).desc("GROUP BY <value> [AS <name>]"),clause:r=>R.alt(r.fromClause,r.whereClause,r.sortByClause,r.limitClause,r.groupByClause,r.flattenClause),query:r=>R.seqMap(r.headerClause.trim(r1),r.fromClause.trim(r1).atMost(1),r.clause.trim(r1).many(),(e,t,n)=>({header:e,source:t.length==0?Bl.folder(""):t[0],operations:n,settings:D1}))}),r1=R.alt(R.whitespace,L8.comment).many().map(r=>r.join("")),Sge=r=>r?r.plugins.plugins.dataview?.api:window.DataviewAPI,Dge=r=>r.plugins.enabledPlugins.has("dataview");Ul.DATE_SHORTHANDS=C1;Ul.DURATION_TYPES=w1;Ul.EXPRESSION=ja;Ul.KEYWORDS=x1;Ul.QUERY_LANGUAGE=L8;Ul.getAPI=Sge;Ul.isPluginEnabled=Dge;Ul.parseField=_ge});function Gx(r){if(!r.includes(",")){let o=r.trim();return o?[o]:[]}let e=[],t="",n=!1;for(let o=0;o<r.length;o++){let s=r[o],a=r[o+1];if(s==="["&&a==="["){n=!0,t+=s;continue}if(s==="]"&&a==="]"){n=!1,t+=s;continue}if(s===","&&!n){let l=t.trim();l&&e.push(l),t="";continue}t+=s}let i=t.trim();return i&&e.push(i),e}var P1=b(()=>{});function Yx(r){return r.replace(/[\\"]/g,"\\$&")}function Ige(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function U8(r){return Yx(Ige(r))}function rD(r){return typeof r=="object"&&r!==null&&"path"in r&&typeof r.path=="string"}var F1,Kx,V8=b(()=>{F1=UN(B8());Me();P1();Kx=class{static getDataviewAPI(e){let t=(0,F1.getAPI)(e);return t||(F.logMessage("Dataview plugin is not installed or enabled"),null)}static async getFieldValues(e,t){let n=new Set,i=this.getDataviewAPI(e);if(!i)return n;try{let s=`field("${Yx(t)}")`,a=`TABLE ${s} WHERE ${s}`,l=await i.query(a);if(l.successful&&l.value.values)for(let c of l.value.values){let u=c[1];Array.isArray(u)?u.forEach(d=>{d&&typeof d=="string"?n.add(d.trim()):rD(d)?n.add(d.path):d&&typeof d!="object"&&n.add(String(d).trim())}):rD(u)?n.add(u.path):u&&typeof u=="string"?Gx(u).forEach(d=>n.add(d)):u&&typeof u!="object"&&n.add(String(u).trim())}}catch(o){F.logError(new Error(`Failed to query Dataview for field ${t}: ${o}`))}return n}static async getFieldValuesWithFilter(e,t,n={}){let i=new Set,o=this.getDataviewAPI(e);if(!o)return i;try{let a=`field("${Yx(t)}")`,l=[a],c=(n.folders?.length?n.folders:n.folder?[n.folder]:[]).map(v=>v.replace(/^\/+|\/+$/g,"")).filter(Boolean);if(c.length>0){let v=c.map(g=>`regexmatch("^${U8(g)}/", file.path)`);l.push(`(${v.join(" OR ")})`)}n.tags&&n.tags.length>0&&n.tags.forEach(v=>{let g=v.startsWith("#")?v:`#${v}`;l.push(`contains(file.tags, "${Yx(g)}")`)}),n.excludeFolders&&n.excludeFolders.length>0&&n.excludeFolders.forEach(v=>{let g=v.replace(/^\/+|\/+$/g,"");l.push(`!regexmatch("^${U8(g)}/", file.path)`)}),n.excludeTags&&n.excludeTags.length>0&&n.excludeTags.forEach(v=>{let g=v.startsWith("#")?v:`#${v}`;l.push(`!contains(file.tags, "${Yx(g)}")`)});let u=l.join(" AND "),d=`TABLE ${a} WHERE ${u}`,f=await o.query(d),p=n.excludeFiles??[],m=v=>{if(p.length===0)return!1;let g=v[0],y=g&&typeof g.path=="string"?g.path:null;if(!y)return!1;let w=y.split("/").pop()??y;return p.some(x=>x===y||x===w)};if(f.successful&&f.value.values)for(let v of f.value.values){if(m(v))continue;let g=v[1];Array.isArray(g)?g.forEach(y=>{y&&typeof y=="string"?i.add(y.trim()):rD(y)?i.add(y.path):y&&typeof y!="object"&&i.add(String(y).trim())}):rD(g)?i.add(g.path):g&&typeof g=="string"?Gx(g).forEach(y=>i.add(y)):g&&typeof g!="object"&&i.add(String(g).trim())}}catch(s){F.logError(new Error(`Failed to query Dataview for field ${t} with filters: ${s}`))}return i}static isAvailable(e){return(0,F1.getAPI)(e)!==null}}});var Vl,nD=b(()=>{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}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)}}get(e,t){let n=this.makeKey(e,t),i=this.cache.get(n);return i?Date.now()-i.timestamp>this.TTL?(this.cache.delete(n),null):new Set(i.values):null}set(e,t,n){let i=this.makeKey(e,n),o=new Set,s=0;for(let a of t){if(s>=this.MAX_VALUES_PER_ENTRY)break;o.add(a),s++}this.cache.size>=this.MAX_CACHE_ENTRIES&&!this.cache.has(i)&&this.evictOldestEntries(1),this.cache.set(i,{values:o,timestamp:Date.now()})}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(e){let t=[];for(let n of this.cache.keys())this.keyFieldName(n)===e&&t.push(n);for(let n of t)this.cache.delete(n)}else this.cache.clear()}cleanExpired(){let e=Date.now(),t=[];for(let[n,i]of this.cache.entries())e-i.timestamp>this.TTL&&t.push(n);for(let n of t)this.cache.delete(n)}getStats(){return{size:this.cache.size,maxSize:this.MAX_CACHE_ENTRIES,cleanupInterval:this.cleanupInterval}}destroy(){this.cleanupInterval=null,this.cache.clear()}makeKey(e,t){return JSON.stringify([e,t||null])}keyFieldName(e){try{let t=JSON.parse(e);if(Array.isArray(t)&&typeof t[0]=="string")return t[0]}catch{}}}});var Sg,q8=b(()=>{Sg=class{static deduplicate(e,t={}){let{strategy:n="case-insensitive",preserveFirstOccurrence:i=!0,sortResult:o=!0}=t,s=e.length,a;switch(n){case"exact":a=this.deduplicateExact(e);break;case"case-sensitive":a=this.deduplicateCaseSensitive(e,i);break;default:a=this.deduplicateCaseInsensitive(e,i);break}return o&&(a=this.sortValues(a,n)),{values:a,duplicatesRemoved:s-a.length,strategy:n}}static deduplicateExact(e){return this.deduplicateWithSet(e)}static deduplicateCaseSensitive(e,t){if(t){let n=new Set;return e.filter(i=>n.has(i)?!1:(n.add(i),!0))}return this.deduplicateWithSet(e)}static deduplicateWithSet(e){return Array.from(new Set(e))}static deduplicateCaseInsensitive(e,t){let n=new Map;for(let i of e){let o=this.normalizeForComparison(i);n.has(o)&&t||n.set(o,i)}return Array.from(n.values())}static normalizeForComparison(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}static sortValues(e,t){return e.sort((n,i)=>{if(t==="case-insensitive"){let o=n.toLowerCase(),s=i.toLowerCase();return o===s?this.getCasePriority(n)-this.getCasePriority(i):o.localeCompare(s)}return n.localeCompare(i)})}static getCasePriority(e){return e===e.toUpperCase()?3:e===e.toLowerCase()?2:e[0]===e[0].toUpperCase()?1:0}static analyzeVariations(e){let t=new Map;for(let o of e){let s=this.normalizeForComparison(o);t.has(s)||t.set(s,[]);let a=t.get(s);a&&a.push(o)}let n=0,i="";for(let[o,s]of t)s.length>n&&(n=s.length,i=o);return{totalValues:e.length,uniqueValues:t.size,caseVariations:t,mostCommonCase:i}}static getSuggestions(e,t,n=.8){let i=this.normalizeForComparison(e),o=[];for(let s of t){let a=this.normalizeForComparison(s);this.calculateSimilarity(i,a)>=n&&i!==a&&o.push(s)}return o.slice(0,5)}static calculateSimilarity(e,t){if(e.length===0)return t.length===0?1:0;if(t.length===0)return 0;let n=[];for(let o=0;o<=t.length;o++)n[o]=[o];for(let o=0;o<=e.length;o++)n[0][o]=o;for(let o=1;o<=t.length;o++)for(let s=1;s<=e.length;s++)t.charAt(o-1)===e.charAt(s-1)?n[o][s]=n[o-1][s-1]:n[o][s]=Math.min(n[o-1][s-1]+1,n[o][s-1]+1,n[o-1][s]+1);let i=Math.max(e.length,t.length);return 1-n[t.length][e.length]/i}}});var Ya,M1=b(()=>{Tt();q8();Ya=class{static processValues(e,t){let n=e.size,i=Array.from(e).filter(c=>!this.isUnresolvedFieldToken(c)),o={strategy:t.caseSensitive?"case-sensitive":"case-insensitive",preserveFirstOccurrence:!0,sortResult:!0},s=Sg.deduplicate(i,o);i=s.values;let{processedValues:a,hasDefault:l}=this.applyDefaultValues(i,t);return i=a,{values:i,hasDefaultValue:l,duplicatesRemoved:s.duplicatesRemoved,totalProcessed:n}}static isUnresolvedFieldToken(e){return this.unresolvedFieldTokenRegex.test(e.trim())}static applyDefaultValues(e,t){if(!t.defaultValue)return{processedValues:e,hasDefault:!1};let n=t.defaultValue,i=[...e],o=!1,s=a=>t.caseSensitive?a===n:this.normalizeForComparison(a)===this.normalizeForComparison(n);return t.defaultAlways?(i=i.filter(a=>!s(a)),i.unshift(n),o=!0):t.defaultEmpty&&e.length===0?(i=[n],o=!0):!t.defaultEmpty&&!t.defaultAlways&&(i.some(s)||(i.unshift(n),o=!0)),{processedValues:i,hasDefault:o}}static promoteValueToFront(e,t,n=!1){let i=o=>n?o===t:this.normalizeForComparison(o)===this.normalizeForComparison(t);return[t,...e.filter(o=>!i(o))]}static canonicalizeAgainst(e,t,n=!1){if(n)return t;let i=this.normalizeForComparison(t);return e.find(o=>this.normalizeForComparison(o)===i)??t}static normalizeForComparison(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase()}static getSmartDefaults(e,t){let n={status:["To Do","In Progress","Done","Cancelled"],priority:["High","Medium","Low"],type:["Note","Task","Project","Reference"],category:["Personal","Work","Study"],mood:["\u{1F60A} Good","\u{1F610} Neutral","\u{1F614} Bad"],rating:["\u2B50","\u2B50\u2B50","\u2B50\u2B50\u2B50","\u2B50\u2B50\u2B50\u2B50","\u2B50\u2B50\u2B50\u2B50\u2B50"],progress:["0%","25%","50%","75%","100%"],difficulty:["Easy","Medium","Hard"],size:["Small","Medium","Large"]},i=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(n,i))return n[i];for(let[o,s]of Object.entries(n))if(i.includes(o)||o.includes(i))return s;if(t.length>0){let o=new Map;for(let s of t)o.set(s,(o.get(s)||0)+1);return Array.from(o.entries()).sort((s,a)=>a[1]-s[1]).slice(0,5).map(([s])=>s)}return[]}static validateDefaultValue(e,t,n){let i=[],o=[];if(t.length>0){let l=Sg.analyzeVariations(t),c=e.toLowerCase();for(let[d,f]of l.caseVariations)if(d===c){f.includes(e)||(o.push(...f.slice(0,3)),i.push(`Consider using existing case: ${f[0]}`));break}let u=Sg.getSuggestions(e,t,.8);u.length>0&&(o.push(...u),i.push(`Similar existing values found: ${u.slice(0,3).join(", ")}`))}let a=this.getSmartDefaults(n,t);return a.length>0&&!a.includes(e)&&(a.map(c=>c.toLowerCase()).includes(e.toLowerCase())||(o.push(...a.slice(0,3)),i.push(`Consider common values for ${n}: ${a.slice(0,3).join(", ")}`))),{isValid:!0,suggestions:[...new Set(o)],warnings:i}}};Ya.unresolvedFieldTokenRegex=new RegExp(`^${yT.source}$`,"i")});var jc,Dg,R1=b(()=>{P1();jc=class jc{static parseInlineFields(e,t){let n=new Map,i=this.removeCodeBlocksAndFrontmatter(e,t),o;for(;(o=jc.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 Gx(a))n.get(s)?.add(l)}}return jc.INLINE_FIELD_REGEX.lastIndex=0,n}static removeCodeBlocksAndFrontmatter(e,t){return e=e.replace(this.FRONTMATTER_REGEX,""),e=this.filterFencedCodeBlocks(e,t?.includeCodeBlocks),e.replace(this.INLINE_CODE_SPAN_REGEX,"")}static filterFencedCodeBlocks(e,t){if(!e.includes("```"))return e;let n=new Set((t??[]).map(u=>u.trim().toLowerCase()).filter(u=>u.length>0)),i=e.split(`
|
||
`),o=[],s=!1,a=0,l="",c=[];for(let u of i){if(!s){let d=this.matchFenceOpen(u);d?(s=!0,a=d.length,l=d.info,c=[u]):o.push(u);continue}if(this.matchFenceClose(u,a)){let d=l.trim().split(/\s+/)[0]?.toLowerCase();if(n.size>0&&d!==void 0&&d.length>0&&n.has(d))for(let p=1;p<c.length;p++)o.push(c[p]);s=!1,c=[]}else c.push(u)}if(s)for(let u of c)o.push(u);return o.join(`
|
||
`)}static matchFenceOpen(e){let t=this.FENCE_OPEN_REGEX.exec(this.stripTrailingCarriage(e));return t?{length:t[1].length,info:t[2]}:null}static matchFenceClose(e,t){let n=this.FENCE_CLOSE_REGEX.exec(this.stripTrailingCarriage(e));return n!==null&&n[1].length>=t}static stripTrailingCarriage(e){return e.endsWith("\r")?e.slice(0,-1):e}static getFieldValues(e,t,n){return this.parseInlineFields(e,n).get(t)||new Set}};jc.INLINE_FIELD_REGEX=/(?:^|[\n\r])(?![ \t]*[-*+][ \t]+\[[ xX]\])([^:\n\r]+?)::[ \t]*(.*)$/gmu,jc.FRONTMATTER_REGEX=/^---\r?\n[\s\S]*?\r?\n---\r?\n/,jc.INLINE_CODE_SPAN_REGEX=/`[^`]*`/g,jc.FENCE_OPEN_REGEX=/^[ \t]*(`{3,})([^`]*)$/,jc.FENCE_CLOSE_REGEX=/^[ \t]*(`{3,})[ \t]*$/;Dg=jc});function iD(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 W8(r,e,t){let n=Vl.getInstance(),i=iD(t),o=n.get(e,i);return o||(o=await oD(r,e,t),n.set(e,o,i)),Ya.processValues(o,t).values}async function z8(r,e,t){let n=Vl.getInstance(),i=iD(t),o=n.get(e,i);o||(o=await oD(r,e,t),n.set(e,o,i));let s=Ya.processValues(o,t);return{values:s.values,hasDefaultValue:s.hasDefaultValue}}async function oD(r,e,t){let n=e.trim().toLowerCase();if(n==="tags"||n==="tag"){let i=await Pge(r,t);if(i.size>0)return i}try{if(!t.inline&&Kx.isAvailable(r)){let i=await Kx.getFieldValuesWithFilter(r,e,t);if(i.size>0)return i}}catch{}return await Rge(r,e,t)}async function Pge(r,e){if(!(!!e.folder||!!e.folders?.length||!!e.tags?.length||!!e.excludeFolders?.length||!!e.excludeTags?.length||!!e.excludeFiles?.length)){let n=Fge(r);if(n.size>0)return n}return await Mge(r,e)}function Fge(r){let e=new Set;try{let t=r.metadataCache.getTags?.();if(!t)return e;for(let n of Object.keys(t)){let o=(n.startsWith("#")?n.substring(1):n).trim();o&&e.add(o)}}catch{}return e}async function Mge(r,e){let t=new Set,n=r.vault.getMarkdownFiles();n=zi.filterFiles(n,e,o=>r.metadataCache.getFileCache(o));let i=50;for(let o=0;o<n.length;o+=i){let a=n.slice(o,o+i).map(async c=>{let u=new Set;try{let d=r.metadataCache.getFileCache(c),f=d?.frontmatter?.tags;if(f!=null){let m=Array.isArray(f)?f:[f];for(let v of m){let g=String(v).trim();g&&u.add(g)}}let p=d?.frontmatter?.tag;if(p!=null){let m=Array.isArray(p)?p:[p];for(let v of m){let g=String(v).trim();g&&u.add(g)}}if(d?.tags)for(let m of d.tags){let v=String(m.tag??"").trim(),g=v.startsWith("#")?v.substring(1):v;g&&u.add(g)}}catch{}return u}),l=await Promise.all(a);for(let c of l)for(let u of c)t.add(u)}return t}async function Rge(r,e,t){let n=new Set,i=r.vault.getMarkdownFiles();i=zi.filterFiles(i,t,s=>r.metadataCache.getFileCache(s));let o=50;for(let s=0;s<i.length;s+=o){let l=i.slice(s,s+o).map(async u=>{let d=new Set;try{let p=r.metadataCache.getFileCache(u)?.frontmatter?.[e];if(p!=null){if(Array.isArray(p))p.forEach(m=>{let v=String(m).trim();v&&d.add(v)});else if(typeof p!="object"){let m=String(p).trim();m&&d.add(m)}}if(t.inline)try{let m=await r.vault.read(u);Dg.getFieldValues(m,e,{includeCodeBlocks:t.inlineCodeBlocks}).forEach(g=>{let y=String(g).trim();y&&d.add(y)})}catch{}}catch{}return d}),c=await Promise.all(l);for(let u of c)for(let d of u)n.add(d)}return n}var $1=b(()=>{V8();ip();nD();M1();R1()});function $ge(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=H8(o);s!==null&&i.push(s)}return i.length>0?i:null}return H8(n)}function sD(r,e,t){if(!e||e.extension!=="md")return null;let n=r.metadataCache.getFileCache(e)?.frontmatter;return $ge(n,t)}function H8(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 O1=b(()=>{});function Xx(r){return r.replace(Oge," ").replace(/\s+/g," ").trim()}function j8(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 G8(r){let e=[],t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=r[o];if(o===0&&/^---\s*$/.test(s)){let c=o+1;for(;c<r.length&&!/^---\s*$/.test(r[c]);)c++;o=c;continue}if(t){let c=s.match(/^ {0,3}(`{3,}|~{3,})\s*$/);c&&c[1][0]===n&&c[1].length>=i&&(t=!1,n="",i=0);continue}else{let c=s.match(/^ {0,3}(`{3,}|~{3,})/);if(c){t=!0,n=c[1][0],i=c[1].length;continue}}let a=s.match(/^ {0,3}(#{1,6})[ \t]+(.*)$/);if(a){e.push({heading:a[2],level:a[1].length,line:o});continue}let l=s.match(/^ {0,3}(=+|-+)\s*$/);if(l&&o>0){let c=r[o-1],u=e.length>0&&e[e.length-1].line===o-1,d=o<2||!j8(r[o-2]);!u&&d&&j8(c)&&e.push({heading:c.trim(),level:l[1][0]==="="?1:2,line:o-1});continue}}return e}function Nge(r,e){let t=[],n=Xx(r[e].heading);n&&t.push(n);let i=r[e].level;for(let o=e-1;o>=0&&i>1;o--)if(r[o].level<i){i=r[o].level;let s=Xx(r[o].heading);s&&t.unshift(s)}return t}function Y8(r,e){if(r.length===0)return null;let t=-1;for(let u=0;u<r.length&&r[u].line<=e;u++)t=u;if(t===-1)return null;let n=Xx(r[t].heading);if(!n)return null;let i=n.toLowerCase();if(!r.some((u,d)=>d!==t&&Xx(u.heading).toLowerCase()===i))return`#${n}`;let s=Nge(r,t);if(s.length<2)return null;let a=s.join("#"),l=a.toLowerCase();return Lge(r).some((u,d)=>d!==t&&u===l)?null:`#${a}`}function Lge(r){let e=new Array(r.length),t=[];for(let n=0;n<r.length;n++){for(;t.length>0&&r[t[t.length-1]].level>=r[n].level;)t.pop();let i=t.length>0?e[t[t.length-1]]:[],o=Xx(r[n].heading);e[n]=o?[...i,o]:i,t.push(n)}return e.map(n=>n.join("#").toLowerCase())}var Oge,K8=b(()=>{Oge=/[!"#$%&()*+,.:;<=>?@^`{|}~/[\]\\\r\n]/g});function md(r,{logPrefix:e,noticePrefix:t=e,defaultReason:n}){if(!(r instanceof Nt))return!1;let i=typeof r.message=="string"&&r.message.trim().length>0?r.message:n;return F.logMessage(`${e}: ${i}`),(!(r instanceof St||typeof r.message=="string"&&r.message.toLowerCase().includes("cancelled by user"))||ce.getState().showInputCancellationNotification)&&new X8.Notice(`${t}: ${i}`),!0}var X8,Qx=b(()=>{X8=require("obsidian");Os();Wr();It();Me()});var Q8={};Zr(Q8,{SingleMacroEngine:()=>N1});function Uge(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 Bge,N1,Z8=b(()=>{Me();Yr();qt();Wt();hk();Uc();Zx();Qx();Ii();Os();Bge=new Set(["settings","entry","quickadd"]);N1=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}=np(e),o=c=>(c??"").trim(),s=Bn(this.choices).find(c=>c.type==="Macro"&&o(c.name)===o(n));if(!s){let c=d=>o(d).toLowerCase(),u=Bn(this.choices).filter(d=>d.type==="Macro"&&c(d.name)===c(n));if(u.length>1)throw F.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 F.logError(`macro '${e}' does not exist.`),new Error(`macro '${e}' does not exist.`);let a=new ql(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||F.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)),Uge(l)}getVariables(){return this.variables}async tryExecuteExport(e,t,n){let i=Dr(t.macro?.commands);if(!i.length)return{executed:!1};let o=i.map((c,u)=>({command:c,index:u})).filter(c=>Si(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=lx(c)?c:i,d;a!==void 0?d=u.findIndex(C=>Si(C)&&C.id===a&&C.type==="UserScript"):d=s.candidate.index;let f=d>=0?u[d]:void 0;if(!f||f.type!=="UserScript")throw new Nt(`Could not resolve the member-access script for '${t.name}'.`);let p=f;p.settings||(p.settings={});let m=s.candidate.exportsRef!==void 0?s.candidate.exportsRef:await Aa(p,this.app);if(m==null)throw new Nt(`Macro '${t.name}' could not load '${p.name}' for member access.`);let v=typeof m=="object"||typeof m=="function"?m.settings:void 0;v&&typeof v=="object"&&$h(p.settings,v);let g=s.candidate.resolvedMember??this.resolveMemberAccess(m,s.memberAccess);if(!g.found)throw new Nt(`Macro '${t.name}' routes member access to '${p.name}', but that script does not export '${s.memberAccess.join("::")}'.`);let y=u.slice(d+1),w=p.settings;typeof g.value=="function"&&(await Mh(this.app,p,v&&typeof v=="object"?v:void 0)&&await this.plugin.saveSettings?.(),w=await fk(this.app,p,v&&typeof v=="object"?v:void 0));let x=await this.executeResolvedMember(g.value,e,w);return this.ensureNotAborted(),e.setOutput(x),this.syncVariablesFromParams(e),y.length&&(await e.runSubset(y),this.ensureNotAborted()),{executed:!0,result:x}}catch(c){throw md(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 Aa(l.command,this.app);o.push({command:l.command,index:l.index,exportsRef:c,resolvedMember:this.resolveMemberAccess(c,n)})}let s=o.filter(l=>l.resolvedMember.found);if(s.length===1)return{candidate:s[0],memberAccess:n};if(s.length===0)throw new Nt(`Macro '${e.name}' could not find '${n.join("::")}' in any user script.`);if(Bge.has(n[0])){let l=s[0];return this.warnReservedKeyConflict(e,n,l,s),{candidate:l,memberAccess:n}}let a=s.map(l=>`'${l.command.name}'`).join(", ");throw new Nt(`Macro '${e.name}' has multiple user scripts exporting '${n.join("::")}': ${a}. Disambiguate with '{{MACRO:${e.name}::<Script Name>::${n.join("::")}}}'.`)}warnReservedKeyConflict(e,t,n,i){if(this.emittedConflictNotice)return;this.emittedConflictNotice=!0;let o=i.map(s=>`'${s.command.name}'`).join(", ");F.logWarning(`Macro '${e.name}': multiple user scripts export '${t.join("::")}' (${o}); using '${n.command.name}'. Disambiguate with '{{MACRO:${e.name}::<Script Name>::${t.join("::")}}}'.`)}resolveScriptSelector(e,t,n){if(n.length<2)return null;let i=n[0]?.trim(),o=t.filter(s=>s.command.name.trim()===i);if(o.length===0)return null;if(o.length>1)throw new Nt(`Macro '${e.name}' has multiple user scripts named '${i}'. Rename one of them before using '{{MACRO:${e.name}::${i}::${n.slice(1).join("::")}}}'.`);return{command:o[0].command,index:o[0].index,memberAccess:n.slice(1)}}syncVariablesFromParams(e){Object.keys(e.params.variables).forEach(t=>{this.choiceExecutor.variables.set(t,e.params.variables[t])})}formatResult(e){if(e==null)return"";if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||typeof e=="bigint")return e.toString();if(typeof e=="object")try{return JSON.stringify(e)}catch{return Object.prototype.toString.call(e)}return String(e)}ensureNotAborted(){let e=this.choiceExecutor.consumeAbortSignal?.();if(e)throw e}}});var Jx,Ig,L1=b(()=>{Jx=require("obsidian");Tt();Me();qt();Ec();Ig=class{constructor(e){this.app=e}async createFolder(e){await this.app.vault.adapter.exists(e)||await this.app.vault.createFolder(e)}stripLeadingSlash(e){return e.replace(/^\/+/,"")}normalizeMarkdownFilePath(e,t){let n=this.stripLeadingSlash(e),i=n?`${n}/`:"",o=this.stripLeadingSlash(t).replace(ir,"");return`${i}${o}.md`}async fileExists(e){return await this.app.vault.adapter.exists(e)}getFileByPath(e){let t=this.app.vault.getAbstractFileByPath(e);if(!t)throw F.logError(`${e} not found`),new Error(`${e} not found`);if(t instanceof Jx.TFolder)throw F.logError(`${e} found but it's a folder`),new Error(`${e} found but it's a folder`);if(!(t instanceof Jx.TFile))throw new Error(`${e} is not a file`);return t}async createFileWithInput(e,t,n={}){if(Un(e))throw new Error(`Refusing to create a file outside the vault: "${e}".`);let i=e.match(/(.*)[/\\]/),o="";i&&(o=i[1]);let s=this.app.vault.getAbstractFileByPath(o);(!s||!(s instanceof Jx.TFolder))&&await this.createFolder(o);let a=()=>this.app.vault.create(e,t);return n.suppressTemplaterOnCreate&&e.toLowerCase().endsWith(".md")?await _0(this.app,e,a):await a()}}});function qge(r){let e=[],t=[];for(let[n,i]of r){let o=U1(n,i,new Set,0);e.push(...o.warnings),t.push(...o.errors)}return{isValid:t.length===0,warnings:e,errors:t}}function U1(r,e,t,n){let i=[],o=[];if(typeof e=="function")return o.push(`Variable "${r}" contains a function, which cannot be serialized to YAML`),{warnings:i,errors:o};if(typeof e=="symbol")return o.push(`Variable "${r}" contains a symbol, which cannot be serialized to YAML`),{warnings:i,errors:o};if(typeof e=="bigint")return i.push(`Variable "${r}" contains a BigInt, which will be converted to a string`),{warnings:i,errors:o};if(e==null)return{warnings:i,errors:o};if(typeof e!="object")return{warnings:i,errors:o};if(t.has(e))return o.push(`Variable "${r}" contains a circular reference`),{warnings:i,errors:o};if(n>=B1.MAX_NESTING_DEPTH)return o.push(`Variable "${r}" exceeds maximum nesting depth of ${B1.MAX_NESTING_DEPTH}`),{warnings:i,errors:o};t.add(e);try{if(Array.isArray(e))for(let s=0;s<e.length;s++){let a=U1(`${r}[${s}]`,e[s],t,n+1);i.push(...a.warnings),o.push(...a.errors)}else for(let[s,a]of Object.entries(e)){let l=U1(`${r}.${s}`,a,t,n+1);i.push(...l.warnings),o.push(...l.errors)}}finally{t.delete(e)}return{warnings:i,errors:o}}function Pg(r,e){return Vge.includes(r.extension)&&e.size>0}async function Fg(r,e,t){let n=qge(t);if(n.warnings.length>0)for(let i of n.warnings)F.logWarning(`Structured variable validation warning: ${i}`);if(!n.isValid){let i=n.errors.join("; ");F.logError(`Cannot post-process front matter for file ${e.path} due to validation errors: ${i}. The file was created successfully, but some structured variables may not be properly formatted. Please check the variable values and ensure they don't contain circular references, exceed nesting depth of ${B1.MAX_NESTING_DEPTH}, or contain unsupported types (functions, symbols).`);return}try{F.logMessage(`Post-processing front matter for ${e.path} with ${t.size} structured variables`),F.logMessage(`Variable types: ${Array.from(t.entries()).map(([i,o])=>`${i}:${typeof o}`).join(", ")}`),await r.fileManager.processFrontMatter(e,i=>{for(let[o,s]of t){let a=o.includes(Fa.PATH_SEPARATOR)?o.split(Fa.PATH_SEPARATOR):[o],l=k_(s);q1(i,a,l)}}),F.logMessage(`Successfully post-processed front matter for ${e.path}`)}catch(i){F.logError(`Failed to post-process front matter for file ${e.path}: ${i}. The file was created successfully, but structured variables may not be properly formatted. This usually happens when variable values contain unexpected types or when Obsidian's YAML processor encounters an issue. Check the console for more details about which variables caused the problem.`)}}function V1(r){return r.some((e,t)=>e==="__proto__"?!0:!(t===r.length-1)&&Wge.has(e))}function q1(r,e,t){if(e.length===0)return;if(V1(e)){F.logWarning(`Skipping front matter assignment for unsafe key path "${e.join(".")}" to avoid prototype pollution.`);return}let n=r;for(let i=0;i<e.length-1;i++){let o=e[i],s=n[o];(typeof s!="object"||s===null||Array.isArray(s))&&(n[o]={}),n=n[o]}n[e[e.length-1]]=t}var B1,Vge,Wge,aD=b(()=>{Me();by();D_();B1={MAX_NESTING_DEPTH:10},Vge=["md"];Wge=new Set(["prototype","constructor"])});function Mg(r){return((0,W1.normalizePath)(r).split("/").pop()??"").replace(/\.(md|canvas|base)$/i,"")}function Wo(r){let e=(0,W1.normalizePath)(r),t=e.lastIndexOf("/");return t===-1?"":e.slice(0,t)}var W1,Rg=b(()=>{W1=require("obsidian")});async function ia(r,e){try{return r.promptProvider?await e.remote(r.promptProvider):r.interactive===!1?await e.headless():await e.app()}catch(t){throw Dt(t)?new St("Input cancelled by user"):t}}var $g=b(()=>{Wr();Cr()});async function oa(r,e){let t=e.items.map((s,a)=>`${zge}${a}`),n=await r.suggester(e.items.map(s=>s.title),t,e.placeholder,e.allowCustomInput??!1),i=n==null?"":String(n),o=t.indexOf(i);if(o!==-1)return e.items[o].value;if(i==="")throw new St("Input cancelled by user");if(e.allowCustomInput)return i;throw new Error(`A reply to ${e.what} has to be one of the offered options, and "${i.slice(0,60)}" is not. Reply with the item's \`value\` token exactly as it was sent, or \`{"cancelled": true}\` to dismiss it.`)}var zge,Og=b(()=>{Wr();zge="\0qa-eng:"});function eE(r){let e=Vp(r);if(e.length!==0)throw new Ee(cj(e,r))}function J8(r){return Vp(r).length===0}var lD=b(()=>{Co();Tl()});function cD(r){let e=r.map(n=>n||"/");return`Folder must be under: ${e.length>3?`${e.slice(0,3).join(", ")}...`:e.join(", ")}`}function z1(r){return r instanceof Nt||!!r&&typeof r=="object"&&"name"in r&&r.name==="MacroAbortError"}var Ng,Hge,Wl,hd,uD=b(()=>{L1();aD();Lg();Ng=require("obsidian");qt();Wc();nd();Tt();Cr();Tl();Ec();Rg();M_();Os();Co();$g();Og();Me();lD();Hge=3,Wl=class extends Error{constructor(e){super(e),this.name="InvalidFolderPathError"}};hd=class extends Ig{constructor(t,n,i,o){super(t);this.plugin=n;this.lastTemplateFileFailure=null;this.templater=TT(t),this.formatter=new ws(t,n,i),o&&this.formatter.setTemplateInclusionState(o)}async getOrCreateFolder(t,n){let i=this.buildFolderSelectionContext(t,n);if(!this.shouldPromptForFolder(i))return await this.handleSingleSelection(i);let o=await this.promptUntilAllowed(i,n.executor);return o.isEmpty?"":o.resolved}buildFolderSelectionContext(t,n){let i=n.allowCreate??!1,o=n.allowedRoots?.map(d=>this.normalizeFolderPath(d))??[],{items:s,displayItems:a,normalizedItems:l,canonicalByNormalized:c,displayByNormalized:u}=this.buildFolderSuggestions(t,n.topItems??[],o.length>0?o:void 0);return{items:s,displayItems:a,normalizedItems:l,canonicalByNormalized:c,displayByNormalized:u,existingSet:new Set(l),allowCreate:i,allowedRoots:o,placeholder:n.placeholder}}shouldPromptForFolder(t){return t.items.length>1||t.allowCreate&&t.items.length===0}async promptForFolder(t,n){let i=t.placeholder??"Choose a folder or type to create one";return String(await ia(n,{remote:o=>oa(o,{items:t.items.map((s,a)=>({value:s,title:t.displayItems[a]??s})),placeholder:i,allowCustomInput:t.allowCreate,what:"the folder chooser"}),headless:()=>{throw new Ee("This choice needs to ask which folder to create the note in, but this run is non-interactive. Configure a single target folder, or re-run with the ui flag.")},app:()=>t.allowCreate?an.Suggest(this.app,t.displayItems,t.items,{placeholder:i,renderItem:(o,s)=>{this.renderFolderSuggestion(o,s,t.existingSet,t.displayByNormalized)}}):Nr.Suggest(this.app,t.displayItems,t.items,t.placeholder)}))}async resolveSelection(t,n){let i=this.normalizeFolderPath(t),o=i.length===0,s=n.canonicalByNormalized.get(i),a=s??i,l=o?!1:s!==void 0||await this.app.vault.adapter.exists(a),c=n.allowedRoots.length===0?!0:this.isPathAllowed(o?"":a,n.allowedRoots);return{raw:t,normalized:i,resolved:a,exists:l,isAllowed:c,isEmpty:o}}async promptUntilAllowed(t,n){let i=n.promptProvider?Hge:0,o=null;for(;;){if(n.promptProvider&&i--<=0)throw new Ee(o??cD(t.allowedRoots));let s=await this.promptForFolder(t,n),a=await this.resolveSelection(s,t);if(a.isEmpty){if(!a.isAllowed){o=cD(t.allowedRoots),this.showFolderNotAllowedNotice(t.allowedRoots);continue}return a}if(!a.isAllowed){o=cD(t.allowedRoots),this.showFolderNotAllowedNotice(t.allowedRoots);continue}try{this.validateFolderPath(a.resolved)}catch(l){if(l instanceof Wl){o=l.message,new Ng.Notice(l.message);continue}throw l}return await this.ensureFolderExists(a),a}}async ensureFolderExists(t){t.isEmpty||t.exists||await this.createFolder(t.resolved)}async handleSingleSelection(t){let n=t.items[0]??"",i=await this.resolveSelection(n,t);if(i.isEmpty)return"";if(!i.isAllowed)throw this.showFolderNotAllowedNotice(t.allowedRoots),new Nt("Selected folder not allowed.");if(i.resolved)try{this.validateFolderPath(i.resolved)}catch(o){if(o instanceof Wl)return new Ng.Notice(o.message),"";throw o}return await this.ensureFolderExists(i),i.resolved}normalizeFolderPath(t){return t.trim().replace(/^\/+/,"").replace(/\/+$/,"")}validateFolderPath(t){let n=t.trim();if(!n)return;let i=n.split("/");for(let o of i)this.validateFolderSegment(o)}validateFolderSegment(t){if(!t)throw new Wl("Folder name cannot be empty.");if(t==="."||t==="..")throw new Wl("Folder name cannot be '.' or '..'.");if(I_.test(t))throw new Wl("Folder name cannot contain control characters.");if(P_.test(t))throw new Wl('Folder name cannot contain any of the following characters: \\ / : * ? " < > |');if(F_.test(t))throw new Wl("Folder name cannot end with a space or a period.");let n=t.split(".")[0]??"";if(n&&Pm(n))throw new Wl("Folder name cannot be a reserved name like CON, PRN, AUX, NUL, COM1-9, or LPT1-9.")}isPathAllowed(t,n){let i=this.normalizeFolderPath(t);for(let o of n)if(!o||i===o||i.startsWith(`${o}/`))return!0;return!1}showFolderNotAllowedNotice(t){new Ng.Notice(cD(t))}buildFolderSuggestions(t,n,i){let o=[],s=[],a=[],l=new Map,c=new Map,u=new Set,d=(f,p)=>{let m=this.normalizeFolderPath(f);u.has(m)||i&&i.length>0&&!this.isPathAllowed(m,i)||(u.add(m),o.push(f),s.push(p??f),a.push(m),l.set(m,f),p&&c.set(m,p))};for(let f of n)d(f.path,f.label);for(let f of t)d(f);return{items:o,displayItems:s,normalizedItems:a,canonicalByNormalized:l,displayByNormalized:c}}renderFolderSuggestion(t,n,i,o){n.empty(),n.classList.add("mod-complex");let s=this.normalizeFolderPath(t),a=o.get(s),l=t||"/",c=i.has(s),u="";a==="<current folder>"?u="Current folder":c||(u="Create folder"),n.createDiv("suggestion-content").createDiv("suggestion-title").createSpan({text:l}),u&&n.createDiv("suggestion-aux").createEl("kbd",{cls:"suggestion-hotkey",text:u})}stripDuplicateFolderPrefix(t,n){let i=this.stripLeadingSlash(n),o=this.stripLeadingSlash(t);return i?o.startsWith(`${i}/`)?{fileName:o.slice(i.length+1),strippedPrefix:!0}:{fileName:o,strippedPrefix:!1}:{fileName:o,strippedPrefix:!1}}shouldTreatFormattedNameAsVaultRelativePath(t,n,i){if(i||n)return!1;let o=t.trim();if(!o.includes("/")||o.startsWith("./"))return!1;if(o.startsWith("/"))return!0;let[s]=this.stripLeadingSlash(o).split("/");return s?this.app.vault.getAbstractFileByPath(s)instanceof Ng.TFolder:!1}getTemplateExtension(t){return qr.test(t)?".canvas":Vi.test(t)?".base":".md"}normalizeTemplateFilePath(t,n,i){let o=this.stripLeadingSlash(t),s=o?`${o}/`:"",a=this.getTemplateExtension(i),l=ai(this.stripLeadingSlash(n),"File name"),c=ai(l.replace(ir,"").replace(qr,"").replace(Vi,""),"File name");if(!c.slice(c.lastIndexOf("/")+1).trim())throw new Error("File name is empty after formatting. Make sure the tokens in the file name format produce a value (an optional token left empty can cause this).");let d=`${s}${c}${a}`;if(Un(d))throw new Error(`Refusing to build a file path outside the vault: "${d}".`);return d}noteTemplateFileFailure(t,n){this.lastTemplateFileFailure=t instanceof Error&&t.message?t.message:n}async createFileWithTemplate(t,n){this.lastTemplateFileFailure=null,eE(t);try{let i=await this.getTemplateContent(n),o=Mg(t);this.formatter.setTitle(o),this.formatter.setTargetFolderPath(Wo(t)),this.formatter.setPromptRunContext({destination:t,destinationKind:"file"});let s=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",i,()=>this.formatter.formatFileContent(i))),a=this.formatter.getAndClearTemplatePropertyVars();F.logMessage(`TemplateEngine.createFileWithTemplate: Collected ${a.size} template property variables for ${t}`),a.size>0&&F.logMessage(`Variables: ${Array.from(a.keys()).join(", ")}`);let l=t.toLowerCase().endsWith(".md"),c=await this.createFileWithInput(t,s,{suppressTemplaterOnCreate:l});return Pg(c,a)&&await Fg(this.app,c,a),await Xd(this.app,c),c}catch(i){if(z1(i))throw i;return this.noteTemplateFileFailure(i,`Could not create file with template at ${t}`),lt(i,`Could not create file with template at ${t}`),null}}setLinkToCurrentFileBehavior(t){this.formatter.setLinkToCurrentFileBehavior(t)}setTargetFolderPath(t){this.formatter.setTargetFolderPath(t)}setPromptRunContext(t){this.formatter.setPromptRunContext(t)}async resolveTemplateSourcePath(t){return this.formatter.formatTemplateFilePath(t)}async overwriteFileWithTemplate(t,n){this.lastTemplateFileFailure=null;try{let i=await this.getTemplateContent(n),o=t.basename;this.formatter.setTitle(o),this.formatter.setTargetFolderPath(Wo(t.path)),this.formatter.setPromptRunContext({destination:t.path,destinationKind:"file"});let s=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",i,()=>this.formatter.formatFileContent(i))),a=this.formatter.getAndClearTemplatePropertyVars();return F.logMessage(`TemplateEngine.overwriteFileWithTemplate: Collected ${a.size} template property variables for ${t.path}`),a.size>0&&F.logMessage(`Variables: ${Array.from(a.keys()).join(", ")}`),await this.app.vault.modify(t,s),Pg(t,a)&&await Fg(this.app,t,a),await Xd(this.app,t),t}catch(i){if(z1(i))throw i;return this.noteTemplateFileFailure(i,"Could not overwrite file with template"),lt(i,"Could not overwrite file with template"),null}}async appendToFileWithTemplate(t,n,i){this.lastTemplateFileFailure=null;try{let o=await this.getTemplateContent(n),s=t.basename;this.formatter.setTitle(s),this.formatter.setTargetFolderPath(Wo(t.path)),this.formatter.setPromptRunContext({destination:t.path,destinationKind:"file"});let a=await this.formatter.withPromptScope("noteBody",o,()=>this.formatter.formatFileContent(o));t.extension==="md"&&(a=await pc(this.app,a,t));let l=await this.app.vault.cachedRead(t),c=i==="top"?`${a}
|
||
${l}`:`${l}
|
||
${a}`;return await this.app.vault.modify(t,c),t}catch(o){if(z1(o))throw o;return this.noteTemplateFileFailure(o,"Could not append to file with template"),lt(o,"Could not append to file with template"),null}}async getTemplateContent(t){let n=po(this.app,t);if(!n)throw new Error(`Template file not found at path "${t}".`);return await this.app.vault.cachedRead(n)}}});var e9={};Zr(e9,{SingleTemplateEngine:()=>tE});var tE,H1=b(()=>{uD();Me();tE=class extends hd{constructor(t,n,i,o,s){super(t,n,o,s);this.templatePath=i;this.promptScope="noteBody"}setPromptScope(t){this.promptScope=t}async run(){let t=await this.resolveTemplateSourcePath(this.templatePath),n=await this.getTemplateContent(t);return n||F.logError(`Template ${t} not found.`),n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope(this.promptScope,n,()=>this.formatter.formatFileContent(n))),n}getAndClearTemplatePropertyVars(){return this.formatter.getAndClearTemplatePropertyVars()}}});var t9={};Zr(t9,{SingleInlineScriptEngine:()=>j1});var j1,r9=b(()=>{Zx();j1=class extends ql{constructor(e,t,n,i){super(e,t,null,n,i)}async runAndGetOutput(e){let t=Object.getPrototypeOf(async function(){}).constructor;return await new t(e).bind(this.params,this).call()}}});var n9,ws,Lg=b(()=>{n9=require("obsidian");zs();nd();X4();WO();Tt();Wc();n5();a5();uh();Ru();ip();Hs();vl();$1();M1();O1();Cu();Me();$m();vy();K8();Wr();Co();Cr();ws=class extends yl{constructor(t,n,i,o){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.contentValuePromptsAcceptImagePaste=!1;this.dateParser=o||El,i&&(this.variables=i?.variables)}async format(t){let n=t;return n=await this.replaceInlineJavascriptInString(n),n=await this.replaceMacrosInString(n),n=await this.replaceTemplateInString(n),n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n),n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}async formatFileName(t,n="generic"){if($s.test(t))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");let i=await this.withPromptScope(n,t,()=>this.format(t));if($s.test(i))throw new Error("{{title}} cannot be used in file names as it would create a circular dependency. The title is derived from the filename itself.");return i=this.replaceCurrentFileTokensInString(i,{fileName:!0,folder:!0,activeFolder:"path"}),i}async formatFileContent(t){let n=t,i=this.contentValuePromptsAcceptImagePaste;this.contentValuePromptsAcceptImagePaste=!x_(this.promptScope);try{n=await this.format(n)}finally{this.contentValuePromptsAcceptImagePaste=i}return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,folder:!0,activeFolder:"content",title:!0}),n}async formatFolderPath(t){if($s.test(t))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");let n=await this.withPromptScope("folder",t,()=>this.format(t));if($s.test(n))throw new Error("{{title}} cannot be used in folder paths as it would create a circular dependency. The title is derived from the filename itself.");return this.replaceCurrentFileTokensInString(n,{folder:!0,activeFolder:"path"}).replace(/^\/+/,"")}async formatTemplateFilePath(t){if($s.test(t))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");let n=t;if(n=await this.replaceGlobalVarInString(n),$s.test(n))throw new Error("{{title}} cannot be used in a template path \u2014 the title is derived from the created file, not the source template.");return n=await this.withPromptScope("templatePath",t,async()=>{let i=this.replaceDateInString(n);return i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),this.replaceRandomInString(i)}),n.trim()}async formatLocationString(t){let n=await this.withPromptScope("lineTarget",t,()=>this.format(t));return n=this.replaceCurrentFileTokensInString(n,{links:!0,fileName:!0,title:!0}),n}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();return t?this.app.fileManager.generateMarkdownLink(t,""):null}getCurrentFileName(){let t=this.app.workspace.getActiveFile();return t?t.basename:null}getCurrentFolderPath(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=t.parent?.path??"";return n==="/"?"":n}getCurrentFileLinkToSection(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.getLinkSourcePath()??"",i=null;try{i=this.getActiveHeadingSubpath(t)}catch{i=null}return i?this.app.fileManager.generateMarkdownLink(t,n,i):this.app.fileManager.generateMarkdownLink(t,n)}getActiveHeadingSubpath(t){let n=this.app.workspace.getActiveViewOfType(n9.MarkdownView);if(!n||n.file?.path!==t.path||n.getMode()==="preview")return null;let i=n.editor,o=i?.getCursor();if(!i||!o)return null;let s=G8(i.getValue().split(/\r?\n/));return Y8(s,o.line)}getVariableValue(t){return this.variables.get(t)??""}shouldUseSelectionForValue(){return!0}async getSelectedTextForValue(){return await this.getSelectedText()}assertInteractivePrompt(t){if(this.choiceExecutor?.interactive===!1)throw new Ee(`This run is non-interactive but a value for ${t} was not provided up front. Pass it (e.g. a value- flag) or re-run with the ui flag.`)}describeAnonymousValuePrompt(){let t=E_(this.promptScope,this.promptScopeSoleValue),n=t.title??(this.promptRunContext?.choiceName?.trim()||"Enter value"),i=NP(this.promptScope);return{title:n,placeholder:t.placeholder,contextLine:gy(this.promptRunContext,n,{showDestination:i}),contextLineFull:gy(this.promptRunContext,n,{elide:!1,showDestination:i})}}async promptForValue(t){if(this.value===void 0){if(this.shouldUseSelectionForValue()){let o=await this.getSelectedTextForValue();if(o){let s=this.normalizeSelectedTextForPrompt(o);if(s!==void 0)return this.value=s,this.value}}if(this.assertInteractivePrompt("{{VALUE}}"),this.valuePromptContext?.inputTypeOverride==="checkbox"){let o=this.choiceExecutor?.promptProvider;if(o)return this.value=String(await o.suggester(["true","false"],["true","false"],this.valuePromptContext.description??this.describeAnonymousValuePrompt().title,!1)),this.value;try{return this.value=await Nr.Suggest(this.app,["true","false"],["true","false"],this.valuePromptContext.description??this.describeAnonymousValuePrompt().title,void 0,this.valuePromptContext.optional?{skippable:!0}:void 0),this.value}catch(s){throw Dt(s)?new St("Input cancelled by user"):s}}let n=this.describeAnonymousValuePrompt(),i=this.choiceExecutor?.promptProvider;if(i)return this.value=await i.inputPrompt(n.contextLine?`${n.title} (${n.contextLine})`:n.title,this.valuePromptContext?.placeholder??n.placeholder,this.valuePromptContext?.defaultValue),this.value;try{let o=this.getLinkSourcePath(),s=new vg().factory(this.valuePromptContext?.inputTypeOverride),a=this.valuePromptContext?.defaultValue,l=this.valuePromptContext?.description,c=this.buildInputPromptOptions(this.valuePromptContext,n.contextLine,n.contextLineFull),u=this.valuePromptContext?.placeholder??n.placeholder;o?this.value=await s.PromptWithContext(this.app,n.title,u,a,o,l,c):this.value=await s.Prompt(this.app,n.title,u,a,l,c)}catch(o){throw Dt(o)?new St("Input cancelled by user"):o}}return this.value}normalizeSelectedTextForPrompt(t){let n=this.valuePromptContext;if(n?.inputTypeOverride==="checkbox"){let s=t.trim().toLowerCase();return s==="true"||s==="false"?s:void 0}if(n?.inputTypeOverride!=="number"&&n?.inputTypeOverride!=="slider")return t;let i=n.sliderConfig??n.numericConfig,o=Ma(t,i);return o===""?void 0:o}buildInputPromptOptions(t,n,i){let o=this.contentValuePromptsAcceptImagePaste&&t?.inputTypeOverride!=="number"&&t?.inputTypeOverride!=="slider"?{sourcePath:this.getLinkSourcePath()??""}:void 0,s=this.promptRunContext?.draftScopeId;if(!(!t?.optional&&!t?.numericConfig&&!t?.sliderConfig&&!o&&!n&&!s))return{optional:t?.optional,numeric:t?.numericConfig,slider:t?.sliderConfig,imagePaste:o,contextLine:n,contextLineFull:i,draftScopeId:s}}async promptForVariable(t,n){let i=this.choiceExecutor?.promptProvider;if(i)return n?.type==="VDATE"?await i.datePrompt(t??n.label??"Enter date",{defaultValue:n.defaultValue,dateFormat:n.dateFormat??"YYYY-MM-DD",withTime:n.withTime}):n?.inputTypeOverride==="checkbox"?String(await i.suggester(["true","false"],["true","false"],n.description??t??n.label??"Choose value",!1)):await i.inputPrompt(t??n?.label??"Enter value",n?.placeholder,n?.defaultValue);this.assertInteractivePrompt(t?`{{VALUE:${t}}}`:"a template variable");try{let o=t??n?.label??"Enter value",s=NP(this.promptScope),a=gy(this.promptRunContext,o,{showDestination:s}),l=gy(this.promptRunContext,o,{elide:!1,showDestination:s});return n?.type==="VDATE"?await ef.Prompt(this.app,t??n.label??"Enter date",n.withTime?"Enter a date & time (e.g., 'tomorrow at 3pm', '2025-12-25 14:30')":"Enter a date (e.g., 'tomorrow', 'next friday', '2025-12-25')",n.defaultValue,n.dateFormat??"YYYY-MM-DD",{optional:n.optional,contextLine:a,contextLineFull:l,draftScopeId:this.promptRunContext?.draftScopeId},n.withTime):n?.inputTypeOverride==="checkbox"?await Nr.Suggest(this.app,["true","false"],["true","false"],n.description??t??n.label??"Choose value",void 0,n.optional?{skippable:!0}:void 0):await new vg().factory(n?.inputTypeOverride).Prompt(this.app,o,n?.placeholder??(n?.defaultValue?n.defaultValue:void 0),n?.defaultValue,n?.description,this.buildInputPromptOptions(n,a,l))}catch(o){throw Dt(o)?new St("Input cancelled by user"):o}}async promptForMathValue(){let t=this.choiceExecutor?.promptProvider;if(t)return await t.inputPrompt("Enter a math expression");this.assertInteractivePrompt("a {{MVALUE}} math expression");try{return await MS.Prompt()}catch(n){throw Dt(n)?new St("Input cancelled by user"):n}}async suggestForValue(t,n=!1,i){let o=this.choiceExecutor?.promptProvider;if(o)return String(await o.suggester(i?.displayValues??t,t,i?.placeholder,n));this.assertInteractivePrompt(i?.variableKey?`{{VALUE:${i.variableKey}}}`:"a value choice");try{let s=i?.displayValues??t;return n?await an.Suggest(this.app,s,t,{...i?.placeholder?{placeholder:i.placeholder}:{},...i?.optional?{skippable:!0}:{}}):await Nr.Suggest(this.app,s,t,i?.placeholder,void 0,i?.optional?{skippable:!0}:void 0)}catch(s){throw Dt(s)?new St("Input cancelled by user"):s}}async suggestForValueMulti(t,n=!1,i){let o=i?.displayValues??t,s=this.choiceExecutor?.promptProvider;if(s)return await s.suggesterMulti(o,t,{placeholder:i?.placeholder,allowCustomInput:n});this.assertInteractivePrompt(i?.variableKey?`{{VALUE:${i.variableKey}}}`:"a multi-select value");try{return await Zp.Suggest(this.app,o,t,{...i?.placeholder?{placeholder:i.placeholder}:{},allowCustomValue:n,...i?.optional?{skippable:!0}:{}})}catch(a){throw Dt(a)?new St("Input cancelled by user"):a}}async suggestForField(t){this.assertInteractivePrompt(`{{FIELD:${t}}}`);let n=this.choiceExecutor?.promptProvider;try{let{fieldName:i,filters:o,multiSelect:s}=Yi.parse(t),a=o.defaultFrom==="active"?sD(this.app,this.choiceExecutor?.triggerContext?.activeFile??null,i):null,{values:l,hasDefaultValue:c}=await z8(this.app,i,o),u=l,d=c,f=o.defaultValue;!s&&typeof a=="string"?(u=Ya.promoteValueToFront(u,a,o.caseSensitive),f=a,d=!0):!s&&Array.isArray(a)&&a.length>0&&F.logMessage(`{{FIELD:${i}|default-from:active}}: the active note's "${i}" is a list value, which applies only to |multi FIELD prompts, so no default was prefilled.`);let p=s?`Select values for ${i}`:`Enter value for ${i}`;if(d&&f&&(p=s?`Select values for ${i} (default: ${f})`:`Enter value for ${i} (default: ${f})`),s){let m=u;if(u.length===0&&!o.defaultValue){let g=Ya.getSmartDefaults(i,[]);g.length>0&&(m=g)}let v=a===null?void 0:(Array.isArray(a)?a:[a]).map(g=>Ya.canonicalizeAgainst(m,g,o.caseSensitive));return n?await n.suggesterMulti(m,m,{placeholder:p,allowCustomInput:!0,preselected:v&&v.length>0?v:void 0}):await Zp.Suggest(this.app,m,m,{placeholder:p,allowCustomValue:!0,...v&&v.length>0?{preselected:v}:{}})}if(u.length===0){let m="No existing values were found in your vault.";if(!o.defaultValue){let v=Ya.getSmartDefaults(i,[]);v.length>0&&(m+=`
|
||
|
||
Suggested values for ${i}: ${v.slice(0,3).join(", ")}`)}return n?await n.inputPrompt(`Enter value for ${i}`,m):await Sr.PromptWithContext(this.app,`Enter value for ${i}`,m,void 0,this.getLinkSourcePath()??void 0)}return n?String(await n.suggester(u,u,p,!0)):await an.Suggest(this.app,u,u,{placeholder:p})}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}generateCacheKey(t){return iD(t)}async suggestForFile(t){this.assertInteractivePrompt(`{{FILE}} (pick a file from ${t.folderPath})`);let n=this.choiceExecutor?.promptProvider;try{let i=zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,c=>this.app.metadataCache.getFileCache(c)),o=t.label??`Select a file from ${t.folderPath}`;if(i.length===0){let c=`No markdown files found in "${t.folderPath}". Type a value or leave empty.`,u=n?await n.inputPrompt(o,c):await Sr.Prompt(this.app,o,c,void 0,void 0,t.optional?{optional:!0}:void 0);return t.multiSelect?u?[`${as}${u}`]:[]:u?`${as}${u}`:""}let s=Tc(i,c=>this.app.metadataCache.getFileCache(c)),a=i.map(c=>`${gl}${c.path}`);if(t.multiSelect)return(n?await n.suggesterMulti(s,a,{placeholder:o,allowCustomInput:t.allowCustomInput}):await Zp.Suggest(this.app,s,a,{placeholder:o,allowCustomValue:t.allowCustomInput,...t.optional?{skippable:!0}:{}})).map(u=>a.includes(u)?u:`${as}${u}`);if(n){let c=String(await n.suggester(s,a,o,t.allowCustomInput));return c?a.includes(c)?c:`${as}${c}`:""}if(t.allowCustomInput){let c=new Set(i.map(f=>f.basename.toLowerCase())),u=new Set(s.map(f=>f.toLowerCase())),d=await an.Suggest(this.app,s,a,{placeholder:o,valueExists:f=>c.has(f.toLowerCase())||u.has(f.toLowerCase()),...t.optional?{skippable:!0}:{}});return d?a.includes(d)?d:`${as}${d}`:""}return await Nr.Suggest(this.app,s,a,o,void 0,t.optional?{skippable:!0}:void 0)??""}catch(i){throw Dt(i)?new St("Input cancelled by user"):i}}async getMacroValue(t,n){let{SingleMacroEngine:i}=await Promise.resolve().then(()=>(Z8(),Q8)),o=new i(this.app,this.plugin,this.plugin.settings.choices,this.choiceExecutor,this.variables),s=await o.runAndGetOutput(t,n)??"";return o.getVariables().forEach((a,l)=>{this.variables.set(l,a)}),s}async getTemplateContent(t){let{SingleTemplateEngine:n}=await Promise.resolve().then(()=>(H1(),e9));this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0});let i={visited:this.templateInclusion.visited,depth:this.templateInclusion.depth+1},o=new n(this.app,this.plugin,t,this.choiceExecutor,i);o.setTargetFolderPath(this.targetFolderPath),this.promptScope!=="generic"&&o.setPromptScope(this.promptScope),this.promptRunContext&&o.setPromptRunContext({...this.promptRunContext,draftScopeId:`${this.promptRunContext.draftScopeId??""}#${t}`});let s=await o.run();return this.mergeTemplatePropertyVars(o.getAndClearTemplatePropertyVars()),s}async getSelectedText(){let t=On(this.app);return t?t.editor.getSelection():""}async getClipboardContent(){try{return await navigator.clipboard.readText()}catch{return""}}isTemplatePropertyTypesEnabled(){return this.plugin.settings.enableTemplatePropertyTypes}async replaceInlineJavascriptInString(t){let n=t;for(;dc.test(n);){let i=dc.exec(n);if(!i)break;let o=i.at(1)?.trim();if(o){let{SingleInlineScriptEngine:s}=await Promise.resolve().then(()=>(r9(),t9)),a=new s(this.app,this.plugin,this.choiceExecutor,this.variables),l=await a.runAndGetOutput(o);for(let u in a.params.variables)this.variables.set(u,a.params.variables[u]);let c="";typeof l=="string"?c=l:(typeof l=="number"||typeof l=="boolean"||Array.isArray(l))&&(c=this.renderCollectedOrArrayValue({input:n,matchStart:i.index,matchEnd:i.index+i[0].length,rawValue:l,fallbackKey:"inlineScript",heuristicEnabled:this.isTemplatePropertyTypesEnabled()})??String(l)),n=this.replacer(n,dc,c)}else n=this.replacer(n,dc,"")}return n}async collectValuesManually(t,n){return await oD(this.app,t,n)}}});function lf(r){return new TextEncoder().encode(r).length}function jge(r){let e=0;for(let t of r){if(t.role==="tool"){for(let n of t.results)e+=lf(n.content);continue}if(e+=lf(t.content),t.role==="assistant"&&t.toolCalls){for(let n of t.toolCalls)if(typeof n.rawArgs=="string")e+=lf(n.rawArgs);else if(n.args)try{e+=lf(JSON.stringify(n.args))}catch{}}}return e}function Gge(r,e){let t;if(typeof r=="string")t=r;else if(r==null)t='{"ok":true}';else try{t=JSON.stringify(r)}catch{return{content:"tool returned a value that could not be serialized",isError:!0}}if(lf(t)>e){let n=" \u2026[truncated]",i=Math.max(0,e-lf(n)),o=Math.min(t.length,i);for(;o>0&&lf(t.slice(0,o))>i;)o=Math.floor(o*.9)||o-1;t=t.slice(0,o)+n}return{content:t,isError:!1}}async function i9(r){let e=r.maxResultBytes??32768,t=r.maxTranscriptBytes??524288,n=Math.max(1,r.maxSteps),i=[...r.request.messages],o=[],s={promptTokens:0,completionTokens:0,totalTokens:0},a=0,l=!1,c=null;for(let p=0;p<n;p++){if(p>0&&r.isOnlineDisabled?.())return u("aborted");let m=p===n-1,v=l||m,g={...r.request,messages:i,...v?{toolChoice:"none"}:{}};a+=jge(i);let y;try{y=await r.dispatch(g,{isFinalStep:v})}catch(x){if(r.isContextOverflow?.(x))return u("context-overflow");throw x}if(c=y,s.promptTokens+=y.usage.promptTokens,s.completionTokens+=y.usage.completionTokens,s.totalTokens+=y.usage.totalTokens,y.normalizedStopReason!=="tool_calls"||y.toolCalls.length===0||v){o.push({stepNumber:p,text:y.content,toolCalls:y.toolCalls,toolResults:[],finishReason:y.rawStopReason,usage:y.usage}),await r.onStepFinish?.(o[o.length-1]);let x=y.normalizedStopReason==="length"?"length":m&&!l&&p>0?"max-steps":"stop";return u(x)}i.push({role:"assistant",content:y.content,toolCalls:y.toolCalls,providerRaw:y.providerRaw});let w=[];for(let x of y.toolCalls)w.push(await d(x));i.push({role:"tool",results:w}),o.push({stepNumber:p,text:y.content,toolCalls:y.toolCalls,toolResults:w,finishReason:y.rawStopReason,usage:y.usage}),await r.onStepFinish?.(o[o.length-1]),a>t&&(l=!0),r.shouldStop?.({steps:o})&&(l=!0)}return u("max-steps");function u(p){return{text:c?.content??"",steps:o,finishReason:p,usage:s,messages:i,finalTurn:c??{content:"",toolCalls:[],normalizedStopReason:"stop",rawStopReason:"",usage:{promptTokens:0,completionTokens:0,totalTokens:0}}}}async function d(p){if(p.parseError)return f(p,"could not parse the tool arguments as JSON");let m=r.getTool(p.name);if(!m)return f(p,`unknown tool "${p.name}"`);let v=p.args??{},g=r.validateArgs(m,v);if(g)return f(p,`invalid arguments: ${g}`);if(!await r.confirm(p,m))return f(p,"tool call denied by user");let w;try{w=await m.execute(v,{toolCallId:p.id,toolName:p.name})}catch(_){if(r.isAbortError(_))throw _;return f(p,`tool execution failed: ${_ instanceof Error?_.message:String(_)}`)}let{content:x,isError:C}=Gge(w,e);return{toolCallId:p.id,name:p.name,content:x,isError:C}}function f(p,m){return{toolCallId:p.id,name:p.name,content:m,isError:!0}}}var o9=b(()=>{});function pD(r,e="schema"){if(r===null||typeof r!="object"||Array.isArray(r))throw new Gc(`${e} must be a JSON Schema object.`);for(let t of Object.keys(r))if(!s9.has(t))throw new Gc(`${e} uses unsupported JSON Schema keyword "${t}". QuickAdd tool schemas support only: ${[...s9].join(", ")}. (Constraints like pattern/minLength/additionalProperties/$ref/allOf/anyOf/format are rejected because at least one provider would silently drop them.)`);if(r.type!==void 0){let t=Array.isArray(r.type)?r.type:[r.type];for(let n of t)if(!Yge.has(n))throw new Gc(`${e} has invalid type "${String(n)}".`)}if(r.properties!==void 0){if(r.properties===null||typeof r.properties!="object"||Array.isArray(r.properties))throw new Gc(`${e}.properties must be an object.`);for(let[t,n]of Object.entries(r.properties))pD(n,`${e}.properties.${t}`)}if(r.required!==void 0&&(!Array.isArray(r.required)||r.required.some(t=>typeof t!="string")))throw new Gc(`${e}.required must be an array of strings.`);if(r.items!==void 0){if(Array.isArray(r.items))throw new Gc(`${e}.items as an array (tuple validation) is not supported in QuickAdd's schema subset.`);pD(r.items,`${e}.items`)}if(r.enum!==void 0&&!Array.isArray(r.enum))throw new Gc(`${e}.enum must be an array.`)}function dD(r){return r===null?"null":Array.isArray(r)?"array":typeof r=="number"?Number.isInteger(r)?"integer":"number":typeof r=="boolean"?"boolean":typeof r=="string"?"string":"object"}function Kge(r,e){let t=dD(r);return t===e||e==="number"&&t==="integer"}function rE(r,e,t="$"){if(e.type!==void 0){let n=Array.isArray(e.type)?e.type:[e.type];if(!n.some(i=>Kge(r,i)))return`${t}: expected ${n.join(" | ")}, got ${dD(r)}`}if(Array.isArray(e.enum)&&!e.enum.some(i=>fD(i,r)))return`${t}: value is not one of the allowed enum values`;if("const"in e&&!fD(e.const,r))return`${t}: value does not equal the required const`;if(dD(r)==="object"){let n=r;if(Array.isArray(e.required)){for(let i of e.required)if(!Object.prototype.hasOwnProperty.call(n,i))return`${t}.${i}: required property is missing`}if(e.properties){for(let[i,o]of Object.entries(e.properties))if(i in n){let s=rE(n[i],o,`${t}.${i}`);if(s)return s}}}if(dD(r)==="array"&&e.items&&!Array.isArray(e.items)){let n=r;for(let i=0;i<n.length;i++){let o=rE(n[i],e.items,`${t}[${i}]`);if(o)return o}}return null}function fD(r,e){if(r===e)return!0;if(typeof r!=typeof e)return!1;if(r===null||e===null)return r===e;if(Array.isArray(r)&&Array.isArray(e))return r.length===e.length&&r.every((t,n)=>fD(t,e[n]));if(typeof r=="object"&&typeof e=="object"){let t=Object.keys(r),n=Object.keys(e);return t.length!==n.length?!1:t.every(i=>fD(r[i],e[i]))}return!1}var s9,Yge,Gc,a9=b(()=>{s9=new Set(["type","properties","required","items","enum","const","description","title"]),Yge=new Set(["object","array","string","number","integer","boolean","null"]),Gc=class extends Error{constructor(e){super(e),this.name="ToolSchemaError"}}});function mD(r){return r.toLowerCase().startsWith(g0)}var G1=b(()=>{Tt()});function nE(r){let e=r.trim();if(!e)throw new Error("assignToVariable cannot be empty.");if(new Set(["value","title","text","meta"]).has(e.toLowerCase()))throw new Error(`assignToVariable "${e}" is reserved (it would hijack a built-in formatter token).`);if(e.toLowerCase().endsWith("-quoted"))throw new Error(`assignToVariable "${e}" cannot end with "-quoted" (collides with the quoted output variable).`);if(mD(e))throw new Error(`assignToVariable "${e}" uses the reserved "__qa." prefix for QuickAdd internal variables.`);if(/[|,]/.test(e))throw new Error(`assignToVariable "${e}" contains characters unreachable by {{VALUE:name}}.`)}var Y1=b(()=>{G1()});function Xge(r,e){if(!e||typeof e!="object")return"";let t=e,n=typeof t.path=="string"?t.path.trim():"",i=typeof t.heading=="string"?t.heading.trim():"";if(!n&&!i)return"";let o=[];return n&&o.push(`Target: ${n}`),i&&o.push(`Heading: ${i}`),o.join(" \xB7 ")}function Qge(r){try{return JSON.stringify(r,null,2)??String(r)}catch{return String(r)}}function Zge(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 cf,iE,l9=b(()=>{cf=require("obsidian"),iE=class r extends cf.Modal{constructor(t,n,i){super(t);this.toolName=n;this.args=i;this.outcome=null;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Prompt(t,n,i){return new r(t,n,i).waitForClose}display(){this.containerEl.addClass("quickAddModal","qaAIToolConfirm"),this.contentEl.empty(),this.titleEl.textContent=`Run AI tool: ${this.toolName}?`,this.contentEl.createEl("p",{text:"The AI requested this tool call with the arguments below."});let t=Xge(this.toolName,this.args);t&&this.contentEl.createEl("p",{cls:"qaAIToolSummary",text:t});let n=this.contentEl.createEl("pre",{cls:"qaAIToolArgs"});n.textContent=Qge(this.args),n.setCssStyles({whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:"16rem",overflowY:"auto"});let i=this.contentEl.createDiv({cls:"yesNoPromptButtonContainer"}),o=new cf.ButtonComponent(i).setButtonText("Abort run").onClick(()=>this.submit("abort")),s=new cf.ButtonComponent(i).setButtonText("Deny").onClick(()=>this.submit("deny")),a=new cf.ButtonComponent(i).setButtonText("Approve all this run").onClick(()=>this.submit("allow-all")),l=new cf.ButtonComponent(i).setButtonText("Approve").onClick(()=>this.submit("allow"));s.buttonEl.focus(),Zge([o.buttonEl,s.buttonEl,a.buttonEl,l.buttonEl])}submit(t){this.outcome=t,this.close()}onClose(){super.onClose(),this.resolvePromise(this.outcome??"deny")}}});function tve(r){return r instanceof Nt}function rve(r){return{content:r.content,toolCalls:r.toolCalls??[],normalizedStopReason:r.normalizedStopReason??"stop",rawStopReason:r.stopReason,usage:r.usage,providerRaw:r.providerRaw}}function nve(r){if(r)return typeof r=="string"?r:{name:r.toolName}}function ive(r){return{toolCallId:r.id,toolName:r.name,input:r.args}}function ove(r){return{toolCallId:r.toolCallId,toolName:r.name,output:r.content,isError:r.isError??!1}}function u9(r,e){let t;try{t=JSON.parse(sve(r))}catch(i){return{ok:!1,error:`not valid JSON (${i instanceof Error?i.message:String(i)})`}}let n=rE(t,e);return n?{ok:!1,error:n}:{ok:!0,value:t}}function sve(r){let e=r.trim(),t=e.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);return t?t[1]:e}var c9,Jge,eve,K1,hD,d9=b(()=>{It();Lg();RO();Co();Os();Nh();Xp();Cx();SO();FO();o9();a9();Y1();l9();c9=/^[a-zA-Z0-9_-]{1,64}$/,Jge=20,eve=100,K1=new WeakSet;hD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choiceExecutor=n;this.config=i;this.running=!1;this.approveAllThisRun=!1;let o=new Set;for(let[s,a]of Object.entries(i.tools??{})){if(!c9.test(s))throw new Error(`Invalid tool name "${s}". Tool names must match ${c9}.`);if(o.has(s))throw new Error(`Duplicate tool name "${s}".`);o.add(s),pD(a.inputSchema,`tool "${s}".inputSchema`)}}async generate(e={}){if(this.running)throw new Error("This agent is already running a generate() call. Await it, or create a separate agent for concurrent runs.");let t=typeof e.assignToVariable=="string"&&e.assignToVariable.length>0;if(t&&(this.assertAssignableName(e.assignToVariable),K1.has(this.choiceExecutor)))throw new Error("Another AI run with assignToVariable is already in flight in this context \u2014 they would race the shared variables. Run them sequentially.");this.running=!0,t&&K1.add(this.choiceExecutor);let n=kS(this.app);try{return await this.run(e,n)}finally{this.running=!1,t&&K1.delete(this.choiceExecutor);try{n()}catch{}}}async run(e,t){this.approveAllThisRun=!1;let n=ce.getState();if(n.disableOnlineFeatures)throw new Error("Rejecting AI request: Online features are disabled in settings.");let{model:i,provider:o}=Oh(this.config.model),s=await Ua(this.app,o),a=await this.buildSeedMessages(e),l=this.buildToolDefinitions(),c=this.buildRegistry(),u=e.schema?{schema:e.schema,name:"response",strict:!0}:void 0,d={messages:a,...l.length>0?{tools:l}:{},toolChoice:nve(e.toolChoice??this.config.toolChoice)??"auto",maxOutputTokens:e.maxOutputTokens??this.config.maxOutputTokens,modelParams:this.config.modelOptions},f=Math.max(1,Math.min(this.config.maxSteps??Jge,eve)),p=fg(n.ai.showAssistant);p.setMessage("starting","QuickAdd is running the AI agent.");try{let m=await i9({request:d,maxSteps:f,dispatch:async(g,y)=>{let w=this.buildTurnRequest(g,y.isFinalStep,u),x=await PO(this.app,s,i,o,w,t);return rve(x)},getTool:g=>c.get(g),confirm:(g,y)=>this.confirm(g,y),validateArgs:(g,y)=>rE(y,g.definition.parameters),isAbortError:tve,isContextOverflow:g=>wx(g)==="input_context",isOnlineDisabled:()=>ce.getState().disableOnlineFeatures,shouldStop:this.buildShouldStop(),onStepFinish:g=>this.reportStep(p,g)}),v=this.toGenerateResult(m);return e.schema&&(v.object=await this.resolveStructuredObject(m,d,i,o,s,e.schema,t)),typeof e.assignToVariable=="string"&&e.assignToVariable&&this.assignVariable(e.assignToVariable,v.text),p.setMessage("finished",`Ran ${v.steps.length} step${v.steps.length===1?"":"s"}.`),window.setTimeout(()=>p.hide(),5e3),v}catch(m){throw p.setMessage("dead",m?.message??""),window.setTimeout(()=>p.hide(),5e3),m}}reportStep(e,t){let n=t.toolCalls.map(o=>o.name),i=n.length>0?`Step ${t.stepNumber+1}: running ${n.join(", ")}.`:`Step ${t.stepNumber+1}: generating a response.`;e.setMessage("thinking",i)}async buildSeedMessages(e){let t=[],n=e.system??this.config.system??ce.getState().ai.defaultSystemPrompt;n&&n.trim().length>0&&t.push({role:"system",content:n});let i=e.prompt??"",o=i?await new ws(this.app,this.plugin,this.choiceExecutor).formatFileContent(i):"";return t.push({role:"user",content:o}),t}buildToolDefinitions(){return Object.entries(this.config.tools??{}).map(([e,t])=>({name:e,description:t.description,parameters:t.inputSchema,...t.strict?{strict:!0}:{}}))}buildRegistry(){let e=new Map;for(let[t,n]of Object.entries(this.config.tools??{}))e.set(t,{definition:{name:t,description:n.description,parameters:n.inputSchema,strict:n.strict},execute:(i,o)=>n.execute(i,o),readOnly:n.readOnly});return e}buildShouldStop(){let e=this.config.stopWhen?Array.isArray(this.config.stopWhen)?this.config.stopWhen:[this.config.stopWhen]:[];if(e.length!==0)return({steps:t})=>{let n=t.flatMap(i=>i.toolCalls.map(o=>o.name));return e.some(i=>i({stepNumber:t.length,toolCallNames:n}))}}buildTurnRequest(e,t,n){return!!(e.tools&&e.tools.length>0)&&!t?{...e,responseFormat:void 0}:{...e,tools:void 0,toolChoice:t?"none":e.toolChoice,responseFormat:n}}async confirm(e,t){let n=e.args??{},i=await this.resolvePerToolApproval(t,n);if(!(i||this.needsGlobalConfirmation(t))||this.approveAllThisRun&&!i)return!0;if(this.choiceExecutor.interactive===!1)throw new Ee(`'${e.name}' needs approval before it runs, but this run is non-interactive. Set the AI assistant's tool-confirmation to "never", mark the tool readOnly, or re-run with the ui flag.`);let s=await iE.Prompt(this.app,e.name,e.args??{});if(s==="abort")throw new Nt("AI tool run aborted by user");return s==="allow-all"?(this.approveAllThisRun=!0,!0):s==="allow"}async resolvePerToolApproval(e,t){let i=this.config.tools?.[e.definition.name]?.needsApproval;return typeof i=="function"?await i({args:t}):i===!0}needsGlobalConfirmation(e){let t=ce.getState().ai.confirmToolCalls??"destructive";return t==="always"?!0:t==="destructive"?e.readOnly!==!0:!1}async resolveStructuredObject(e,t,n,i,o,s,a){let l=u9(e.finalTurn.content,s);if(l.ok)return l.value;if(e.finishReason==="aborted"||e.finishReason==="context-overflow"||ce.getState().disableOnlineFeatures)return;let c=[...e.messages,{role:"assistant",content:e.finalTurn.content},{role:"user",content:`Your previous reply was not valid JSON matching the required schema (${l.error}). Reply with ONLY a JSON object that matches the schema \u2014 no prose, no code fences.`}],u={...t,messages:c,tools:void 0,toolChoice:"none",responseFormat:{schema:s,name:"response",strict:!0}};try{let d=await PO(this.app,o,n,i,u,a),f=u9(d.content,s);return f.ok?f.value:void 0}catch{return}}toGenerateResult(e){let t=e.steps.map(i=>({stepNumber:i.stepNumber,text:i.text,toolCalls:i.toolCalls.map(ive),toolResults:i.toolResults.map(ove),finishReason:i.finishReason})),n=t[t.length-1];return{text:e.text,steps:t,toolCalls:n?.toolCalls??[],toolResults:n?.toolResults??[],usage:{inputTokens:e.usage.promptTokens,outputTokens:e.usage.completionTokens,totalTokens:e.usage.totalTokens},finishReason:e.finishReason}}assignVariable(e,t){let n=e.trim(),i=("> "+t).replace(/\n/g,`
|
||
> `);this.choiceExecutor.variables.set(n,t),this.choiceExecutor.variables.set(`${n}-quoted`,i)}assertAssignableName(e){nE(e)}}});function X1(r){let e=(0,f9.getFrontMatterInfo)(r);return e.exists?e.contentStart:0}function lve(r,e){let t=X1(r);if(t===0)return 0;if(p9.test(e))return t;let n=p9.exec(r.slice(t));return n?t+n[0].length:t}function Q1(r,e){if(e.length===0)return{content:r,insertedStartOffset:null,insertedEndOffset:null};let t=lve(r,e),n=r.slice(0,t),i=r.slice(t),o=n.length>0&&!n.endsWith(`
|
||
`)&&!ave.test(e)?`
|
||
`:"",s=i.length>0&&!e.endsWith(`
|
||
`)?`
|
||
`:"",a=n.length+o.length,l=a+e.length;return{content:`${n}${o}${e}${s}${i}`,insertedStartOffset:a,insertedEndOffset:l}}function gD(r,e){return Q1(r,e).content}var f9,p9,ave,oE=b(()=>{f9=require("obsidian"),p9=/^[^\S\r\n]*\r?\n/,ave=/^\r?\n/});function Z1(r){return(r??"").trim().replace(/\\/g,"/").replace(/\/+/g,"/").replace(/^\/+|\/+$/g,"").normalize("NFC")}function J1(r,e){return e.some(t=>r===t||r.startsWith(`${t}/`))}function uf(r,e){let t=(e??[]).map(n=>Z1(n)).filter(n=>n.length>0);return t.length===0?!0:r?J1(r.normalize("NFC"),t):!1}var vD=b(()=>{});function df(r,e={}){let t=(r??"").trim();if(!t)throw new sa("Path is empty.");let n=t.replace(/\\/g,"/").normalize("NFC");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new sa(`Refusing to write to an absolute path outside the vault: "${n}".`);let i=n.replace(/\/+/g,"/").replace(/^\/+|\/+$/g,""),o=i.split("/").filter(a=>a.length>0);if(o.length===0)throw new sa("Path is empty after normalization.");for(let a of o){if(a==="."||a==="..")throw new sa(`Refusing path with a traversal segment ("${a}"): "${i}".`);if(a.startsWith("."))throw new sa(`Refusing to write into a dot/config path segment ("${a}"): "${i}".`);cve(a,i)}let s=(e.allowedRoots??[]).map(a=>Z1(a)).filter(a=>a.length>0);if(s.length>0&&!J1(i,s))throw new sa(`Path "${i}" is not under an allowed root (${s.join(", ")}).`);return i}function cve(r,e){if(I_.test(r))throw new sa(`Path segment "${r}" contains control characters: "${e}".`);if(P_.test(r))throw new sa(`Path segment "${r}" contains an illegal character (\\ : * ? " < > |): "${e}".`);if(F_.test(r))throw new sa(`Path segment "${r}" cannot end with a space or a period: "${e}".`);let t=r.split(".")[0]??"";if(t&&Pm(t))throw new sa(`Path segment "${r}" is a reserved device name: "${e}".`)}var sa,m9=b(()=>{M_();vD();sa=class extends Error{constructor(e){super(e),this.name="UnsafeVaultPathError"}}});function Bg(r,e){let t=Object.entries(r),n=new Set(t.map(([o])=>o));if(h9(e.only,n,"only"),h9(e.exclude,n,"exclude"),e.only){let o=new Set(e.only);t=t.filter(([s])=>o.has(s))}if(e.exclude){let o=new Set(e.exclude);t=t.filter(([s])=>!o.has(s))}let i=e.prefix??"";return Object.fromEntries(t.map(([o,s])=>[i+o,s]))}function sE(r){return{...r,__qaTool:!0}}function h9(r,e,t){if(!r)return;let n=r.filter(i=>!e.has(i));n.length!==0&&F.logWarning(`AI tools: ${t} listed unknown tool name(s) ${n.map(i=>`"${i}"`).join(", ")}. Valid names: ${[...e].join(", ")}.`)}var yD=b(()=>{Me()});function x9(r,e={}){let t=e.allowedRoots,n={read_note:pf({description:"Read a note's full markdown content by vault path.",inputSchema:ff({path:aa("Vault path to the note, e.g. Notes/Foo.md")},["path"]),readOnly:!0,execute:async({path:i})=>{let o=df(String(i),{allowedRoots:t}),s=r.vault.getAbstractFileByPath(o);if(!(s instanceof tN.TFile))return{found:!1,path:o};let a=await r.vault.cachedRead(s);return{found:!0,path:o,content:a.length>g9?a.slice(0,g9)+`
|
||
\u2026[truncated]`:a}}}),list_notes:pf({description:"List markdown notes, optionally within a folder.",inputSchema:ff({folder:aa("Folder to list (omit for the whole vault)."),limit:v9("Max results (default 100, capped at 200).")},[]),readOnly:!0,execute:async({folder:i,limit:o})=>{let s=i?df(String(i),{allowedRoots:t}):"",a=w9(b9(o,uve),1,dve),l=rs(r,s).filter(c=>uf(c.path,t));return{total:l.length,notes:l.slice(0,a).map(c=>({path:c.path,basename:c.basename}))}}}),search_notes:pf({description:"Search notes by name and/or content. Returns matching paths with a short snippet.",inputSchema:ff({query:aa("Text to search for."),in:y9(["name","content","both"],"Where to search (default both)."),limit:v9("Max results (default 25, capped at 50).")},["query"]),readOnly:!0,execute:async({query:i,in:o,limit:s})=>{let a=String(i).toLowerCase(),l=o??"both",c=w9(b9(s,pve),1,fve),u=r.vault.getMarkdownFiles().filter(m=>uf(m.path,t)),d=[],f=0,p=!1;for(let m of u){if(d.length>=c)break;if(l!=="content"&&m.basename.toLowerCase().includes(a)){d.push({path:m.path});continue}if(l!=="name"){if(f>=mve){p=!0;continue}f++;let g=await r.vault.cachedRead(m),y=g.toLowerCase().indexOf(a);y>=0&&d.push({path:m.path,snippet:gve(g,y)})}}return{results:d,scannedFiles:f,truncated:d.length>=c||p}}}),get_property_values:pf({description:"List the distinct values a frontmatter property takes across the vault (e.g. existing tags or statuses).",inputSchema:ff({field:aa("Frontmatter property name."),folder:aa("Optional folder scope.")},["field"]),readOnly:!0,execute:async({field:i,folder:o})=>{let s=o?df(String(o),{allowedRoots:t}):"",a=(o?rs(r,s):r.vault.getMarkdownFiles()).filter(c=>uf(c.path,t)),l=new Set;for(let c of a){let d=r.metadataCache.getFileCache(c)?.frontmatter?.[String(i)];if(d!=null){for(let f of Array.isArray(d)?d:[d])if(typeof f!="object"){let p=String(f).trim();p&&l.add(p)}}}return{field:String(i),values:[...l].sort().slice(0,200)}}}),create_note:pf({description:"Create a new markdown note. Fails if the path already exists.",inputSchema:ff({path:aa("Vault path for the new note."),content:aa("Initial markdown content.")},["path"]),needsApproval:!0,execute:async({path:i,content:o})=>{let s=df(eN(String(i)),{allowedRoots:t});return await lg(r,s),await hve(r,s),{created:!0,path:(await r.vault.create(s,String(o??""))).path}}}),append_to_note:pf({description:"Append text to an existing note (frontmatter-aware for top inserts).",inputSchema:ff({path:aa("Vault path to the existing note."),content:aa("Markdown to append."),position:y9(["top","bottom"],"Where to add it (default bottom).")},["path","content"]),needsApproval:!0,execute:async({path:i,content:o,position:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=await r.vault.read(l),u=String(o),d=s==="top"?gD(c,u.endsWith(`
|
||
`)?u:u+`
|
||
`):`${c}${c.endsWith(`
|
||
`)||c.length===0?"":`
|
||
`}${u}`;return await r.vault.modify(l,d),{appended:!0,path:a}}}),insert_under_heading:pf({description:"Insert markdown under an existing heading (matched exactly). Errors if the heading is not found.",inputSchema:ff({path:aa("Vault path to the existing note."),heading:aa("Exact heading text (without the # markers)."),content:aa("Markdown to insert under the heading.")},["path","heading","content"]),needsApproval:!0,execute:async({path:i,heading:o,content:s})=>{let a=df(eN(String(i)),{allowedRoots:t}),l=C9(r,a);await lg(r,a);let c=r.metadataCache.getFileCache(l)?.headings??[],u=c.find(p=>p.heading===String(o));if(!u)throw new Error(`Heading "${o}" not found in ${a}`);let d=await r.vault.read(l),f=vve(d,u.position.start.line,u.level,String(s),c);return await r.vault.modify(l,f),{inserted:!0,path:a,heading:String(o)}}})};return Bg(n,e)}function pf(r){return{...r,__qaTool:!0}}function ff(r,e){return{type:"object",properties:r,required:e}}function aa(r){return{type:"string",description:r}}function v9(r){return{type:"integer",description:r}}function y9(r,e){return{type:"string",enum:r,description:e}}function b9(r,e){let t=Number(r);return Number.isFinite(t)?Math.floor(t):e}function w9(r,e,t){return Math.max(e,Math.min(t,r))}function eN(r){if(/\.md$/i.test(r))return r;if(/\.[a-z0-9]+$/i.test(r))throw new Error(`This tool only operates on markdown notes (.md); refused path: "${r}".`);return`${r}.md`}function C9(r,e){let t=r.vault.getAbstractFileByPath(e);if(!(t instanceof tN.TFile))throw new Error(`Note not found: ${e}`);return t}async function hve(r,e){let t=e.lastIndexOf("/");if(t<=0)return;let n=e.slice(0,t);if(!r.vault.getAbstractFileByPath(n))try{await r.vault.createFolder(n)}catch{}}function gve(r,e){let t=Math.max(0,e-40);return r.slice(t,e+80).replace(/\s+/g," ").trim()}function vve(r,e,t,n,i){let o=r.split(`
|
||
`),s=o.length;for(let u of i)if(u.position.start.line>e&&u.level<=t){s=u.position.start.line;break}let a=n.endsWith(`
|
||
`)?n:n+`
|
||
`,l=o.slice(0,s),c=o.slice(s);for(;l.length>e+1&&l[l.length-1].trim()==="";)l.pop();return[...l,a.replace(/\n$/,""),...c].join(`
|
||
`)}var tN,g9,uve,dve,pve,fve,mve,E9=b(()=>{tN=require("obsidian");qt();oE();vD();m9();sO();yD();g9=16e3,uve=100,dve=200,pve=25,fve=50,mve=400});function _9(r,e={}){let t=e.allowedRoots,n=()=>{let s=r.workspace.getActiveFile();return!(s instanceof bD.TFile)||s.extension!=="md"?null:uf(s.path,t)?s:null},i=()=>{let s=r.workspace.getActiveViewOfType(bD.MarkdownView);return s&&uf(s.file?.path,t)?s:null},o={get_active_note:sE({description:"Get the currently active note (path, basename, and content). Returns active:null if there is none.",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>{let s=n();if(!s)return{active:null};let a=await r.vault.cachedRead(s);return{active:{path:s.path,basename:s.basename,content:a.length>T9?a.slice(0,T9)+`
|
||
\u2026[truncated]`:a}}}}),get_selection:sE({description:"Get the text currently selected in the active editor (empty string if none).",inputSchema:{type:"object",properties:{}},readOnly:!0,execute:async()=>({selection:i()?.editor?.getSelection()??""})})};return Bg(o,e)}var bD,T9,A9=b(()=>{bD=require("obsidian");vD();yD();T9=16e3});function k9(r={}){let e={get_date:sE({description:"Get the current date/time. Optionally pass a moment.js format and a day offset.",inputSchema:{type:"object",properties:{format:{type:"string",description:"moment.js format, e.g. YYYY-MM-DD"},offset:{type:"integer",description:"Day offset from today (e.g. 1 = tomorrow)."}}},readOnly:!0,execute:async({format:t,offset:n})=>({date:Bs({format:t!=null?String(t):void 0,offset:n!=null?Number(n):void 0})})})};return Bg(e,r)}var S9=b(()=>{qt();yD()});var aE,Ug,D9=b(()=>{aE=require("obsidian");Wr();BO();Ug=class r extends aE.Modal{constructor(t,n,i=[],o){super(t);this.items=n;this.selectedItems=i;this.header=o;this._selectedItems=[...i],this.promise=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open(),this.picker.focusSearchOnOpen()}static Open(t,n,i,o){return new r(t,n,i,o).promise}display(){this.contentEl.empty(),this.containerEl.addClass("quickAddModal","qaSearchableMultiSelectModal","checkboxPrompt"),this.header&&(this.titleEl.textContent=this.header),this.addSearchableOptions(),this.addSubmitButton()}onClose(){super.onClose(),this.resolved||this.rejectPromise(tn())}addSearchableOptions(){this.picker=new Qp(this.contentEl,{items:this.items.map(t=>({key:t,value:t,label:t})),isSelected:({value:t})=>this._selectedItems.includes(t),onToggle:({value:t},n)=>{if(n){this._selectedItems.includes(t)||this._selectedItems.push(t);return}this._selectedItems=this._selectedItems.filter(i=>i!==t)},getSelectedCount:()=>new Set(this._selectedItems).size})}addSubmitButton(){let t=this.contentEl.createDiv("submitButtonContainer");new aE.ButtonComponent(t).setButtonText("Submit").setCta().onClick(()=>{this.resolved=!0,this.resolvePromise(this._selectedItems),this.close()}),new aE.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.close()})}}});var wD,lE,I9=b(()=>{wD=require("obsidian"),lE=class r extends wD.Modal{constructor(t,n,i){super(t);this.header=n;this.text=i;this.waitForClose=new Promise(o=>{this.resolvePromise=o}),this.open(),this.display()}static Show(t,n,i){return new r(t,n,i).waitForClose}display(){this.contentEl.empty(),this.titleEl.textContent=this.header,String.isString(this.text)?this.contentEl.createEl("p",{text:this.text}):Array.isArray(this.text)&&this.text.forEach(i=>this.contentEl.createEl("p",{text:i}));let t=this.contentEl.createDiv(),n=new wD.ButtonComponent(t).setButtonText("OK").onClick(()=>this.close());Object.assign(t.style,{display:"flex",justifyContent:"flex-end"}),n.buttonEl.focus()}onClose(){super.onClose(),this.resolvePromise()}}});var CD,P9=b(()=>{Ru();$1();fl();CD=class extends mn{constructor(t,n,i){super(t,n);this.cachedValues=null;this.fieldInput=i;let o=Yi.parse(i);this.fieldName=o.fieldName,this.filters=o.filters}async getSuggestions(t){this.cachedValues||(this.cachedValues=await W8(this.app,this.fieldName,this.filters));let n=(t||"").toLowerCase();return n?this.cachedValues.filter(i=>i.toLowerCase().includes(n)).slice(0,200):this.cachedValues.slice(0,200)}renderSuggestion(t,n){this.renderMatch(n,t,this.getCurrentQuery())}selectSuggestion(t){this.inputEl.value=t;let n=new Event("input",{bubbles:!0});n.fromCompletion=!0,this.inputEl.dispatchEvent(n),this.close()}}});var F9,rN,xD,M9=b(()=>{F9=require("obsidian");fl();rN=200,xD=class extends mn{constructor(t,n,i,o,s,a,l){super(t,n);this.getOptions=i;this.isSelected=o;this.onSelect=s;this.multiSelect=a;this.allowCustomInput=l;a&&n.setAttribute("aria-multiselectable","true")}getSuggestions(t){let n=t.trim(),i=this.getOptions().filter(u=>!this.isSelected(u.value));if(!n)return i.slice(0,rN);let o=(0,F9.prepareFuzzySearch)(n),s=i.map(u=>({option:u,match:o(`${u.label} ${u.path}`)})).filter(u=>u.match!==null).sort((u,d)=>d.match.score-u.match.score).slice(0,rN).map(({option:u})=>u);if(!this.allowCustomInput)return s;let a=n.toLocaleLowerCase(),l=this.getOptions().some(u=>u.label.toLocaleLowerCase()===a||u.path.toLocaleLowerCase()===a),c=this.isSelected(n);return l||c?s:[{value:n,label:`Use \u201C${n}\u201D`,path:"Custom value",isCustom:!0},...s].slice(0,rN)}renderSuggestion(t,n){n.addClass("qa-onepage-file-suggestion");let i=n.createDiv({cls:"qa-onepage-file-suggestion__text"}),o=i.createDiv({cls:"qa-onepage-file-suggestion__label"});t.isCustom?o.setText(t.label):this.renderMatch(o,t.label,this.getCurrentQuery().trim()),i.createDiv({cls:"qa-onepage-file-suggestion__path",text:t.path})}selectSuggestion(t){if(this.onSelect(t),this.inputEl.value="",!this.multiSelect){this.close();return}let n=new Event("input",{bubbles:!0});n.fromCompletion=!0,n.keepOpen=!0,this.inputEl.dispatchEvent(n),this.inputEl.focus()}}});var ED,R9=b(()=>{fl();Fo();ED=class extends mn{constructor(e,t,n,i=!1,o=!1,s){super(e,t),this.options=n.map(a=>fn(a)),this.caseSensitive=i,this.multiSelect=o,this.onSelect=s,this.multiSelect&&this.inputEl.setAttribute("aria-multiselectable","true")}parseMultiSelectInput(e){if(!this.multiSelect)return{alreadySelected:[],activeTerm:e};let t=e.split(",").map(n=>n.trim());return{alreadySelected:t.slice(0,-1).filter(Boolean),activeTerm:t[t.length-1]||""}}getRemainingOptions(e){return this.options.filter(t=>!e.includes(t))}getSuggestions(e){let t=Cc(e),{alreadySelected:n,activeTerm:i}=this.parseMultiSelectInput(t),o=this.caseSensitive?i:i.toLowerCase(),s=this.getRemainingOptions(n);return o?s.filter(a=>(this.caseSensitive?a:a.toLowerCase()).includes(o)).slice(0,200):s.slice(0,200)}renderSuggestion(e,t){this.renderMatch(t,e,this.getCurrentQuery())}selectSuggestion(e){this.multiSelect?this.selectMultipleItem(e):this.selectSingleItem(e)}selectSingleItem(e){this.inputEl.value=e;let t=new Event("input",{bubbles:!0});t.fromCompletion=!0,this.inputEl.dispatchEvent(t),this.close()}selectMultipleItem(e){let{alreadySelected:t}=this.parseMultiSelectInput(this.inputEl.value);t.push(e),this.onSelect?.(e);let n=this.getRemainingOptions(t).length>0;this.inputEl.value=n?t.join(", ")+", ":t.join(", "),this.inputEl.setSelectionRange(this.inputEl.value.length,this.inputEl.value.length);let i=new Event("input",{bubbles:!0}),o=i;o.fromCompletion=!0,n?(o.keepOpen=!0,this.inputEl.dispatchEvent(i),this.inputEl.focus()):(this.inputEl.dispatchEvent(i),this.close())}}});function $9(r,e,t){return t?e.get(r)??r:r}function O9(r,e){return e.length===0?r:r===""?e[0]??"":e.includes(r)?r:e[0]??""}var N9=b(()=>{});var Qt,Vg,nN=b(()=>{Qt=require("obsidian");Tt();qO();P9();M9();R9();Mx();Wd();It();h_();N9();vl();Wr();Hs();Vg=class extends Qt.Modal{constructor(t,n,i,o){super(t);this.result=new Map;this.multiSelections=new Map;this.fileSelections=new Map;this.dateParseErrors=new Set;this.previewContainerEl=null;this.previewToken=0;this.settled=!1;this.imagePasteHandles=[];this.filePickerSuggesters=[];this.requirements=n,this.initialValues=new Map,this.computePreview=o,i?.forEach((s,a)=>{typeof s=="string"&&this.initialValues.set(a,s)}),this.updatePreviewDebounced=(0,Qt.debounce)(this.updatePreviews.bind(this),150,!0),this.waitForClose=new Promise((s,a)=>{this.resolvePromise=s,this.rejectPromise=a}),this.display(),this.open()}display(){this.containerEl.addClass("quickAddModal","onePageInputModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:"Provide inputs"}).addClass("qa-onepage-title"),this.computePreview&&(this.previewContainerEl=this.contentEl.createDiv(),this.previewContainerEl.addClass("qa-onepage-preview","qa-hidden")),this.requirements.forEach(i=>this.renderField(i)),this.computePreview&&this.updatePreviews();let n=this.contentEl.createDiv();new Qt.Setting(n).addButton(i=>i.setButtonText("Submit").setCta().onClick(()=>this.submit())).addButton(i=>i.setButtonText("Cancel").onClick(()=>this.cancel()))}onOpen(){this.contentEl.querySelector("input, textarea, select")?.focus();let n=this.scope;typeof n?.register=="function"&&n.register(["Mod"],"Enter",()=>(this.submit(),!1))}renderField(t){let n=(o,s)=>{this.result.set(o,s),this.updatePreviewDebounced()},i=this.initialValues.get(t.id)??t.defaultValue??"";switch(t.type){case"textarea":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Qt.TextAreaComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),s.inputEl.addClass("qa-onepage-textarea"),this.enableImagePaste(t,s.inputEl);break}case"text":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Qt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),this.enableImagePaste(t,s.inputEl);break}case"number":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Qt.TextComponent(o.controlEl);s.inputEl.type="number",s.inputEl.inputMode="decimal",t.numericConfig?.min!==void 0&&(s.inputEl.min=String(t.numericConfig.min)),t.numericConfig?.max!==void 0&&(s.inputEl.max=String(t.numericConfig.max)),s.inputEl.step=t.numericConfig?.step!==void 0?String(t.numericConfig.step):"any";let a=t.numericConfig?Ma(i,t.numericConfig):i;s.setPlaceholder(t.placeholder??"").setValue(a).onChange(l=>n(t.id,t.numericConfig?Ma(l,t.numericConfig):l)),n(t.id,a);break}case"slider":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));o.controlEl.parentElement?.addClass("qa-onepage-slider-setting"),t.description&&o.setDesc(t.description);let s=t.sliderConfig??{min:0,max:100,step:1},a=t.optional&&i==="",l=xy(i,s),c=o.controlEl.createDiv({cls:"qa-onepage-slider"}),u=c.createEl("input");u.type="range",u.min=String(s.min),u.max=String(s.max),u.step=String(s.step),u.value=l;let d=new Qt.TextComponent(c);d.inputEl.type="number",d.inputEl.inputMode="decimal",d.inputEl.min=String(s.min),d.inputEl.max=String(s.max),d.inputEl.step=String(s.step),d.setValue(a?"":l),n(t.id,a?"":l),u.addEventListener("input",()=>{d.inputEl.value=u.value,n(t.id,u.value)}),d.onChange(f=>{if(f===""&&t.optional){n(t.id,"");return}let p=Ma(f,s);p!==""&&(u.value=p,d.inputEl.value=p,n(t.id,p))});break}case"dropdown":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Qt.DropdownComponent(o.controlEl),a=t.options??[],l=t.displayOptions??a;if(a.length>0){t.optional&&s.addOption("","Skip (leave empty)"),a.forEach((u,d)=>{let f=l[d]??u;s.addOption(u,f)});let c=O9(i,a);s.setValue(c),n(t.id,c),s.onChange(u=>n(t.id,u))}else s.setDisabled(!0),o.controlEl.createDiv({text:t.placeholder||"No options available"}).addClass("qa-onepage-dropdown-note");break}case"date":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=o.controlEl.createDiv({cls:"qa-date-input"}),a=new Qt.TextComponent(s),l="Enter a date (e.g., 'today', 'next friday', '2025-12-25')",c,u=i;i?.startsWith("@date:")&&(c=i.slice(6),u=(t.dateFormat?Nl(c,t.dateFormat):void 0)??(c.length>=10?c.slice(0,10):c)),a.setPlaceholder(l).setValue(u??"");let d=s.createDiv({cls:"qa-date-picker-container"}),f=PS({container:d,initialIso:c,withTime:t.withTime===!0,onSelect:_=>{_?w(_):x()}}),p=s.createDiv();p.addClass("qa-date-preview-text");let m=Nv(ce.getState().dateAliases);if(m.length>0){let _=s.createEl("details");_.addClass("qa-date-alias-details"),_.createEl("summary",{text:`Aliases (${m.length})`}).addClass("qa-date-alias-summary");let D=_.createEl("div");D.textContent=hT(ce.getState().dateAliases),D.addClass("qa-date-alias-list")}let v=_=>{if(t.dateFormat){let E=Nl(_,t.dateFormat);if(E)return E}return _.length>=10?_.slice(0,10):_},g=(_,E)=>{p.setText(_),p.toggleClass("is-error",E)},y=_=>{f.setSelectedIso(_)},w=_=>{c=_,this.dateParseErrors.delete(t.id);let E=v(_);a.inputEl.value=E,n(t.id,`@date:${_}`),g(E,!1),y(_)},x=()=>{a.inputEl.value="",C("")},C=_=>{let E=(_??"").trim();if(!E&&t.defaultValue&&!t.optional){let P=Jp(t.defaultValue,t.dateFormat);if(P.isValid&&P.isoString){c=P.isoString,this.dateParseErrors.delete(t.id),n(t.id,`@date:${P.isoString}`),y(P.isoString);let V=P.formatted??v(P.isoString);g(V,!1);return}g(P.error||"Unable to parse date",!0),this.dateParseErrors.add(t.id),n(t.id,""),y();return}if(!E){c=void 0,this.dateParseErrors.delete(t.id),n(t.id,""),y(),g(t.optional?"Will be left empty":"Preview will appear here",!1);return}if(E.startsWith("@date:")){let P=E.slice(6).trim();if(P){this.dateParseErrors.delete(t.id),w(P);return}}let D=Jp(E,t.dateFormat);if(D.isValid&&D.isoString){c=D.isoString,this.dateParseErrors.delete(t.id),n(t.id,`@date:${D.isoString}`),y(D.isoString);let P=D.formatted??v(D.isoString);g(P,!1)}else c=void 0,this.dateParseErrors.add(t.id),n(t.id,""),y(),g(D.error||"Unable to parse date",!0)};a.onChange(_=>C(_)),c?w(c):C(u??"");break}case"field-suggest":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=new Qt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(l=>n(t.id,l));let a=t.id.startsWith(jd)?t.id.slice(jd.length):t.id;try{new CD(this.app,s.inputEl,a)}catch{}break}case"suggester":{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));t.description&&o.setDesc(t.description);let s=t.options??[],a=t.displayOptions??s,l=new Map,c=new Map;s.forEach((f,p)=>{let m=a[p]??f;l.set(m,f),c.has(f)||c.set(f,m)});let u=c.get(i)??i,d=new Qt.TextComponent(o.controlEl);if(d.setPlaceholder(t.placeholder??"Type to search...").setValue(u).onChange(f=>n(t.id,f)),d.inputEl.addEventListener("input",f=>{let p=!!f.fromCompletion,m=d.inputEl.value,v=$9(m,l,p);(v!==m||p)&&n(t.id,v)}),a.length>0)try{let f=t.suggesterConfig?.caseSensitive??!1,p=t.suggesterConfig?.multiSelect??!1;new ED(this.app,d.inputEl,a,f,p,p?m=>{let v=this.multiSelections.get(t.id)??[];v.push(m),this.multiSelections.set(t.id,v)}:void 0)}catch{}break}case"file-picker":{this.renderFilePickerField(t,i,n);break}default:{let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t)),s=new Qt.TextComponent(o.controlEl);s.setPlaceholder(t.placeholder??"").setValue(i).onChange(a=>n(t.id,a)),this.enableImagePaste(t,s.inputEl)}}this.result.has(t.id)||this.result.set(t.id,i)}renderFilePickerField(t,n,i){let o=new Qt.Setting(this.contentEl).setName(this.decorateLabel(t));o.settingEl.addClass("qa-onepage-file-picker-setting"),t.description&&o.setDesc(t.description);let s=t.options??[],a=t.displayOptions??s,l=s.map((_,E)=>{let D=gp(_);return{value:_,label:a[E]??_,path:D.kind==="file"?D.path:_}}),c=new Map(l.map(_=>[_.value,_])),u=t.suggesterConfig?.multiSelect??!1,d=t.suggesterConfig?.allowCustomInput??!1,f=new Set,p=new Map,m=_=>{let E=p.get(_);if(E)return E;let D={value:_,label:_,path:"Custom value",isCustom:!0};return p.set(_,D),D};if(n&&c.has(n))f.add(n);else if(n&&d){let _=gp(n),E=_.kind==="custom"?_.text:n;m(E),f.add(E)}else!u&&l.length>0&&f.add(l[0].value);let v=o.controlEl.createDiv({cls:"qa-onepage-file-picker"}),g=v.createDiv({cls:"qa-onepage-file-picker__selection"});g.setAttribute("aria-live","polite");let y=new Qt.TextComponent(v);y.inputEl.addClass("qa-onepage-file-picker__input"),y.setPlaceholder(t.placeholder??(u?"Search and add files...":"Search files...")),y.inputEl.setAttribute("aria-label",u?`Add files for ${t.label}`:`Choose file for ${t.label}`);let w=()=>{let _=l.filter(E=>f.has(E.value));for(let E of p.values())f.has(E.value)&&_.push(E);return _},x=()=>{let _=w(),E=_.map(D=>D.value);this.fileSelections.set(t.id,E),i(t.id,u?E.join(", "):E[0]??""),g.empty(),g.toggleClass("qa-hidden",_.length===0);for(let D of _){let P=g.createDiv({cls:"qa-onepage-file-picker__chip"});P.setAttribute("title",D.path),P.createSpan({cls:"qa-onepage-file-picker__chip-label",text:D.label});let V=P.createEl("button",{cls:"qa-onepage-file-picker__remove",text:"\xD7"});V.type="button",V.setAttribute("aria-label",`Remove ${D.label}`),V.addEventListener("click",()=>{f.delete(D.value),x(),y.inputEl.focus()})}},C=_=>{let E=_.isCustom?m(_.value):_;u||f.clear(),f.add(E.value),x()};y.inputEl.addEventListener("keydown",_=>{if(_.key==="Backspace"&&y.inputEl.value===""&&f.size>0){let E=w().at(-1);if(!E)return;_.preventDefault(),f.delete(E.value),x()}});try{let _=new xD(this.app,y.inputEl,()=>[...l,...p.values()],E=>f.has(E),C,u,d);this.filePickerSuggesters.push(_)}catch{y.setDisabled(!0)}x()}enableImagePaste(t,n){t.pathContext||this.imagePasteHandles.push(Am(this.app,n,{}))}decorateLabel(t){if(!t.optional)return t.label;let n=this.contentEl.ownerDocument,i=n.createDocumentFragment();i.appendChild(n.createTextNode(t.label));let o=n.createElement("span");return o.textContent=" (optional)",o.className="qa-onepage-optional-badge",i.appendChild(o),i}submit(){if(this.settled)return;let t=this.imagePasteHandles.find(o=>o.isBusy());if(t){t.whenIdle().then(()=>this.submit());return}let n={},i=this.requirements.find(o=>o.type==="date"&&!o.optional&&this.dateParseErrors.has(o.id));if(i){new Qt.Notice(`QuickAdd: "${i.label}" is not a valid date. Fix it or clear it before submitting.`);return}for(let[o,s]of this.multiSelections){let a=(this.result.get(o)??"").replace(/,\s*$/,"").trim();s.join(", ")!==a&&this.multiSelections.delete(o)}Object.assign(n,this.collectAnswers()),this.settled=!0,this.close(),this.resolvePromise(n)}collectAnswers(){let t=new Map(this.requirements.map(i=>[i.id,i])),n={};return this.result.forEach((i,o)=>{let s=t.get(o);if(s?.type==="date"&&i===""){let a=this.dateParseErrors.has(o);if(!s.optional||a)return}n[o]=i}),n}collectPreviewAnswers(){let t=this.collectAnswers(),n=new Map(this.requirements.map(i=>[i.id,i]));for(let[i,o]of this.fileSelections)t[i]=n.get(i)?.suggesterConfig?.multiSelect?[...o]:o[0]??"";return t}cancel(){this.settled=!0,this.close(),this.rejectPromise(tn())}onClose(){for(let t of this.imagePasteHandles)t.detach();this.imagePasteHandles.length=0;for(let t of this.filePickerSuggesters)t.destroy();this.filePickerSuggesters.length=0,this.settled||(this.settled=!0,this.rejectPromise(tn()))}async updatePreviews(){if(!this.computePreview||!this.previewContainerEl)return;let t=++this.previewToken;try{let n=await this.computePreview(this.collectPreviewAnswers());if(t!==this.previewToken||!this.previewContainerEl)return;this.previewContainerEl.empty(),this.previewContainerEl.toggleClass("qa-hidden",n.length===0);for(let i of n){let o=i.diagnostics.filter(u=>u.severity==="error"),a=o.some(u=>u.kind!=="path")?"Unresolved":o.length>0?"Won't be created":i.label,l=this.previewContainerEl.createDiv({cls:"qa-onepage-preview-row"});l.createEl("div",{text:`${a}:`,cls:"qa-preview-key"}),l.createEl("div",{text:i.text,cls:"qa-preview-val"}).setAttribute("title",i.text);for(let u of i.diagnostics){let d=this.previewContainerEl.createDiv({cls:"qa-preview-issue"});d.toggleClass("qa-preview-issue--error",u.severity==="error"),d.createSpan({cls:"qa-visually-hidden",text:u.severity==="error"?"Error: ":"Warning: "}),d.appendText(u.message),d.setAttribute("title",u.message)}}}catch{}}}});var TD,L9=b(()=>{LT();TD=class{static filterFiles(e,t,n){return Object.keys(t).length===0?e:e.filter(i=>{let o=this.getIncludeFolders(t);return!(o.length>0&&!o.some(s=>this.matchesFolder(i,s))||t.tags&&t.tags.length>0&&!this.matchesTags(i,t.tags,n))})}static getIncludeFolders(e){let t=e.folders?.length?e.folders:e.folder?[e.folder]:[];return[...new Set(t.map(n=>this.normalizePath(n)).filter(Boolean))]}static matchesFolder(e,t){let n=this.normalizePath(t),i=this.normalizePath(e.path);return i.startsWith(n+"/")||i.substring(0,i.lastIndexOf("/"))===n}static matchesTags(e,t,n){let i=n(e);if(!i)return!1;let o=this.getAllTags(i);return t.map(gc).filter(Boolean).every(a=>o.some(l=>l===a||l.startsWith(a+"/")))}static getAllTags(e){let t=[];return e.frontmatter?.tags&&t.push(...Eu(e.frontmatter.tags)),e.frontmatter?.tag&&t.push(...Eu(e.frontmatter.tag)),e.tags&&t.push(...e.tags.map(n=>gc(n.tag))),t.filter(Boolean)}static normalizePath(e){return e.replace(/^\/+|\/+$/g,"")}}});function q9(r){return cE.some(e=>e.id===r)}function B9(r){let e=(0,_D.getFrontMatterInfo)(r);return e.exists?{frontmatterYaml:e.frontmatter,body:r.slice(e.contentStart)}:{frontmatterYaml:null,body:r}}function yve(r,e,t){return t==="bottom"?`${r}
|
||
${e}`:gD(r,`${e}
|
||
`)}function bve(r){return r==null||r===""||Array.isArray(r)&&r.length===0}function U9(r){return typeof r=="string"?r.length>0?[r]:[]:!Array.isArray(r)||!r.every(e=>typeof e=="string")?null:r}function V9(r,e){let t=U9(r),n=U9(e);if(t===null||n===null)return;let i=[],o=new Set(t);for(let s of n)s.length===0||o.has(s)||(o.add(s),i.push(s));if(i.length!==0)return[...t,...i]}var _D,cE,qg,AD=b(()=>{_D=require("obsidian");Me();qt();aD();Sx();D_();by();Rg();oE();uD();Tl();A_();cE=[{id:"cursor",label:"Insert at cursor",description:"Inserts the template at the cursor position in the editor."},{id:"top",label:"Insert at top",description:"Inserts the template below the note's frontmatter, or at the very top."},{id:"bottom",label:"Append to bottom",description:"Adds the template content to the end of the note."},{id:"replace",label:"Replace note content",description:"Replaces the entire note content with the template."}];qg=class extends hd{constructor(t,n,i,o,s,a,l){super(t,n,a);this.targetFile=i;this.templatePath=o;this.mode=s;this.resolvedTemplatePath=l??null}async run(){await this.apply()}async getResolvedTemplatePath(){return this.resolvedTemplatePath===null&&(this.resolvedTemplatePath=await this.resolveTemplateSourcePath(this.templatePath)),this.resolvedTemplatePath}async apply(){switch(Mi(this.templatePath,"Cannot apply template: no template path given."),this.mode){case"replace":return await this.overwriteFileWithTemplate(this.targetFile,await this.getResolvedTemplatePath());case"top":case"bottom":return await this.insertTemplateIntoFile(this.mode);case"cursor":return await this.insertTemplateAtCursor()}}async computeChoiceTargetPath(t){let n=t.folder,i;if(this.formatter.setTargetFolderPath(null),n?.enabled){if(n.chooseWhenCreatingNote)return null;if(n.createInSameFolderAsActiveFile)i=this.targetFile.parent?.path??"";else{if(n.chooseFromSubfolders)return null;if(n.folders.length===1)i=await this.formatter.formatFolderPath(n.folders[0]);else return null}}else i=this.targetFile.parent?.path??"";i==="/"&&(i="");let o=this.targetFile.basename,s=!1;if(t.fileNameFormat?.enabled&&t.fileNameFormat.format){this.formatter.setTargetFolderPath(i);let a=await this.formatter.formatFileName(t.fileNameFormat.format,"generic"),l=ai(a,"File name"),c=this.stripDuplicateFolderPrefix(l,i);o=c.fileName,s=this.shouldTreatFormattedNameAsVaultRelativePath(l,c.strippedPrefix,n?.enabled??!1)}return o.slice(o.lastIndexOf("/")+1).trim()?this.normalizeTemplateFilePath(s?"":i,o,await this.getResolvedTemplatePath()):null}async insertTemplateIntoFile(t){let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=B9(n);return s.trim().length>0&&await this.app.vault.process(this.targetFile,a=>yve(a,s,t)),await this.mergeFrontmatterProperties(o,i),this.targetFile}async insertTemplateAtCursor(){let t=Gv(this.app,this.targetFile);Mi(t,"Cannot insert at cursor: the note is not open in the active editor.");let{formatted:n,templatePropertyVars:i}=await this.formatTemplateForTargetFile(),{frontmatterYaml:o,body:s}=B9(n);return s.trim().length>0&&t.editor.replaceSelection(s),await this.mergeFrontmatterProperties(o,i),this.targetFile}async formatTemplateForTargetFile(){let t=await this.getTemplateContent(await this.getResolvedTemplatePath());this.formatter.setTitle(this.targetFile.basename),this.formatter.setTargetFolderPath(Wo(this.targetFile.path));let n=await this.formatter.withTemplatePropertyCollection(()=>this.formatter.withPromptScope("noteBody",t,()=>this.formatter.formatFileContent(t))),i=this.formatter.getAndClearTemplatePropertyVars();return this.targetFile.extension==="md"&&(n=await pc(this.app,n,this.targetFile)),{formatted:n,templatePropertyVars:i}}async mergeFrontmatterProperties(t,n){if(!t||this.targetFile.extension!=="md")return;let i;try{i=(0,_D.parseYaml)(t)}catch(o){F.logWarning(`Could not parse template frontmatter for merging: ${o}`);return}if(!(!i||typeof i!="object"||Array.isArray(i))){if(n&&n.size>0)for(let[o,s]of n){let a=o.includes(Fa.PATH_SEPARATOR)?o.split(Fa.PATH_SEPARATOR):[o];q1(i,a,k_(s))}await this.app.fileManager.processFrontMatter(this.targetFile,o=>{for(let[s,a]of Object.entries(i)){if(V1([s])){F.logWarning(`Skipping front matter merge for unsafe key "${s}" to avoid prototype pollution.`);continue}let l=Object.hasOwn(o,s)?o[s]:void 0,c=SV(this.app,s);if(bve(l)){c&&Array.isArray(a)?o[s]=V9([],a)??[]:o[s]=a;continue}if(c){let u=V9(l,a);u!==void 0&&(o[s]=u)}}})}}}});function wve(r){return r.trim().length===0}function zg(r){return!qr.test(r)&&!Vi.test(r)}function Cve(r){return r.kind==="choice"?`Choice: ${r.choice.name}`:`Template: ${r.path}`}function W9(r){let e=r.replace(/^\/+/,"").toLowerCase();return/\.(md|canvas|base)$/.test(e)?e:`${e}.md`}function xve(r,e){let t=Bn(r).filter(o=>o.type==="Template"&&!!o.templatePath&&zg(o.templatePath)),n=new Set(t.map(o=>W9(o.templatePath))),i=t.map(o=>({kind:"choice",choice:o}));for(let o of e)zg(o)&&(n.has(W9(o))||i.push({kind:"file",path:o}));return i}async function uE(r,e,t){let n=t.file??r.workspace.getActiveFile();if(!n||n.extension!=="md")return new Wg.Notice("QuickAdd: No active markdown note to apply a template to."),null;let i=t.choiceExecutor.triggerContext;i==null&&(t.choiceExecutor.triggerContext={activeFile:n});try{let o=!t.templatePath,s;if(t.templatePath)s={kind:"file",path:t.templatePath};else{let m=await Eve(r,e);if(!m)return null;s=m}let a=s.kind==="choice"?s.choice.templatePath:s.path;if(!zg(a))return new Wg.Notice("QuickAdd: Only markdown templates can be applied to a note. Canvas and base templates create their own file types."),null;let l=await r.vault.cachedRead(n),c=wve(l),u;if(t.mode)u=t.mode;else if(c)u="replace";else if(!o)u="bottom";else{let m=await Tve(r,n);if(!m)return null;u=m}t.choiceExecutor.variables.has("value")||t.choiceExecutor.variables.set("value",n.basename);let d=new qg(r,e,n,a,u,t.choiceExecutor);d.setPromptRunContext({choiceName:s.kind==="choice"?s.choice.name:void 0,draftScopeId:s.kind==="choice"?s.choice.id:`template-insert#${a}`,destination:n.path,destinationKind:"file"});let f=await d.getResolvedTemplatePath();return zg(f)?await d.apply()?(o&&s.kind==="choice"&&(d.setPromptRunContext({destination:void 0,destinationKind:void 0}),await _ve(r,d,s.choice,n)),await wu(r,n),new Wg.Notice(`Applied template to '${n.basename}'.`),n):null:(new Wg.Notice("QuickAdd: Only markdown templates can be applied to a note. Canvas and base templates create their own file types."),null)}catch(o){return Dt(o)||z9(o)||lt(o,"Error applying template to note"),null}finally{t.choiceExecutor.triggerContext=i}}function z9(r){return!!r&&typeof r=="object"&&r.name==="MacroAbortError"}async function Eve(r,e){let t=xve(e.settings.choices,e.getTemplateFiles().map(n=>n.path));if(t.length===0)return new Wg.Notice("QuickAdd: No Template choices or template files found. Create a Template choice or set the template folder path in settings."),null;try{return await Nr.Suggest(r,t.map(Cve),t,"Apply template to note")}catch(n){if(Dt(n))return null;throw n}}async function Tve(r,e){let t=!!Gv(r,e),n=cE.filter(i=>i.id!=="cursor"||t);try{return await Nr.Suggest(r,n.map(i=>i.label),n.map(i=>i.id),"How should the template be applied?")}catch(i){if(Dt(i))return null;throw i}}async function _ve(r,e,t,n){try{let i=await e.computeChoiceTargetPath(t);if(!i||i===n.path||await r.vault.adapter.exists(i)||!J8(i)||!await Xi.Prompt(r,"Move note to match choice settings?",`'${t.name}' creates notes at '${i}'. Move '${n.path}' there? Links to the note will be updated.`))return;let s=i.lastIndexOf("/"),a=s===-1?"":i.slice(0,s);a&&!await r.vault.adapter.exists(a)&&await r.vault.createFolder(a),await r.fileManager.renameFile(n,i)}catch(i){if(Dt(i)||z9(i))return;F.logWarning(`Could not move note to match choice settings: ${i}`)}}var Wg,iN=b(()=>{Wg=require("obsidian");Tt();Wc();Wp();Me();qt();Wt();lD();Cr();AD()});function j9(r){return Array.from(r.entries())}function G9(r,e){r.clear();for(let[t,n]of e)r.set(t,n)}function Ave(r){if(!r||typeof r!="object")return;let e={};return typeof r.min=="number"&&Number.isFinite(r.min)&&(e.min=r.min),typeof r.max=="number"&&Number.isFinite(r.max)&&(e.max=r.max),e.min!==void 0&&e.max!==void 0&&e.max<e.min&&(delete e.min,delete e.max),typeof r.step=="number"&&Number.isFinite(r.step)&&r.step>0&&(e.step=r.step),Object.keys(e).length>0?e:void 0}function kve(r){if(!r||typeof r!="object")return;let{min:e,max:t}=r,n=r.step??1;if(!(typeof e!="number"||typeof t!="number"||typeof n!="number"||!Number.isFinite(e)||!Number.isFinite(t)||!Number.isFinite(n)||t<=e||n<=0))return{min:e,max:t,step:n}}function Yc(r){throw r instanceof Nt?r:Dt(r)?new St(yu):r}var H9,Hg,oN=b(()=>{Cu();DS();px();Nh();Xp();d9();E9();A9();S9();Y1();Lg();D9();I9();zs();Wc();zO();Wp();nd();WO();Fo();nN();It();Me();qt();Cr();nD();L9();R1();Os();Wr();Mx();iN();AD();H9=!1;Hg=class r{static GetApi(e,t,n){return{requestInputs:async i=>{let o={},s=[];for(let u of i){let d=n.variables.get(u.id);if(d!=null){o[u.id]=String(d);continue}let f=kve(u.sliderConfig),p=f??Ave(u.numericConfig),m=u.type==="slider"&&!f?"number":u.type;s.push({id:u.id,label:u.label??u.id,type:m,placeholder:u.placeholder,defaultValue:u.defaultValue,numericConfig:p,sliderConfig:f,options:u.options,dateFormat:u.dateFormat,description:u.description,optional:u.optional,suggesterConfig:u.suggesterConfig,source:"script"})}let a={};if(s.length>0){let u=n?.promptProvider;if(u)try{let d=await u.requestInputs(s);a=Object.fromEntries(Object.entries(d).map(([f,p])=>[f,Array.isArray(p)?p.join(", "):p]))}catch(d){Yc(d)}else{let d=new Vg(e,s,n.variables);try{a=await d.waitForClose}catch(f){Yc(f)}}}let l={...o,...a};for(let u of i)l[u.id]===void 0&&(l[u.id]="");Object.entries(l).forEach(([u,d])=>n.variables.set(u,d));let c={};for(let u of i){let d=l[u.id];if(d===void 0)continue;let f=d;if(u.type==="date"&&u.dateFormat&&typeof d=="string"&&d.startsWith("@date:")){let p=d.slice(6),m=Nl(p,u.dateFormat);m&&(f=m)}c[u.id]=f}return c},inputPrompt:(i,o,s,a)=>{let l=n?.promptProvider;return l?l.inputPrompt(i,o,s):r.inputPrompt(e,i,o,s,a)},datePrompt:(i,o)=>{let s=n?.promptProvider;return s?s.datePrompt(i,o):r.datePrompt(e,i,o)},wideInputPrompt:(i,o,s,a)=>{let l=n?.promptProvider;return l?l.wideInputPrompt(i,o,s):r.wideInputPrompt(e,i,o,s,a)},yesNoPrompt:(i,o)=>{let s=n?.promptProvider;return s?s.yesNoPrompt(i,o):r.yesNoPrompt(e,i,o)},infoDialog:(i,o)=>{let s=n?.promptProvider;return s?s.infoDialog(i,o):r.infoDialog(e,i,o)},suggester:(i,o,s,a=!1,l)=>{let c=n?.promptProvider;return c?c.suggester(i,o,s,a):r.suggester(e,i,o,s,a,l)},checkboxPrompt:(i,o,s)=>{let a=n?.promptProvider;return a?a.checkboxPrompt(i,o,s):r.checkboxPrompt(e,i,o,s)},executeChoice:async(i,o)=>{let s;try{s=t.getChoiceByName(i)}catch{s=void 0}if(!s){lt(new Error(`Choice named '${i}' not found`),"API executeChoice error");return}o&&Object.keys(o).forEach(l=>{n.variables.set(l,o[l])}),await n.execute(s);let a=n.consumeAbortSignal?.();if(n.variables.clear(),a)throw a},applyTemplateToActiveFile:async(i,o)=>{if(!i)throw new Error("applyTemplateToActiveFile requires a template path.");if(!zg(i))throw new Error("applyTemplateToActiveFile only supports markdown templates. Canvas and base templates cannot be applied to a markdown note.");if(o?.mode!==void 0&&!q9(o.mode))throw new Error(`Invalid mode '${String(o.mode)}'. Valid modes: ${cE.map(a=>a.id).join(", ")}.`);let s=j9(n.variables);try{return await uE(e,t,{templatePath:i,mode:o?.mode,choiceExecutor:n})}finally{G9(n.variables,s)}},format:async(i,o,s=!0)=>{let a=s?j9(n.variables):null;o&&Object.keys(o).forEach(c=>{n.variables.set(c,o[c])});let l=await new ws(e,t,n).formatFileContent(i);return s&&a&&G9(n.variables,a),l},ai:{prompt:async(i,o,s)=>{let a=ce.getState(),l=a.ai;if(a.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let c=r.GetApi(e,t,n).format,{model:u,provider:d}=Oh(o),f=await Ua(e,d);s?.assignToVariable&&nE(s.assignToVariable);let p=await z4(e,{model:u,provider:d,prompt:i,apiKey:f,modelOptions:s?.modelOptions??{},outputVariableName:s?.assignToVariable||s?.variableName||"output",showAssistantMessages:s?.showAssistantMessages??!0,systemPrompt:s?.systemPrompt??l.defaultSystemPrompt},(m,v)=>c(m,v,!1));return p?((s?.shouldAssignVariables||s?.assignToVariable)&&Object.entries(p).forEach(([m,v])=>{n.variables.set(m,v)}),p):(lt(new Error("AI Assistant returned null"),"AI Prompt error"),{})},chunkedPrompt:async(i,o,s,a,l)=>{let c=ce.getState(),u=c.ai;if(c.disableOnlineFeatures)throw new Error("Rejecting request to `prompt` via API AI module. Online features are disabled in settings.");let d=r.GetApi(e,t,n).format,{model:f,provider:p}=Oh(s),m=await Ua(e,p);a?.assignToVariable&&nE(a.assignToVariable);let v=await Y4(e,{model:f,provider:p,text:i,promptTemplate:o,chunkSeparator:a?.chunkSeparator??/\n/,apiKey:m,modelOptions:a?.modelOptions??{},outputVariableName:a?.assignToVariable||a?.variableName||"output",showAssistantMessages:a?.showAssistantMessages??!0,systemPrompt:a?.systemPrompt??u.defaultSystemPrompt,resultJoiner:a?.chunkJoiner??`
|
||
`,shouldMerge:a?.shouldMerge??!0,maxChunkTokens:a?.maxChunkTokens},(g,y)=>{let w={...l,...y};return d(g,w,!1)});return v?((a?.shouldAssignVariables||a?.assignToVariable)&&Object.entries(v).forEach(([g,y])=>{n.variables.set(g,y)}),v):(lt(new Error("AI Assistant returned null"),"Chunked AI Prompt error"),{})},getModels:()=>BG(),getMaxTokens:i=>Oh(i).model.maxTokens,estimateTokens(i){return Uo(i)},countTokens(i,o){return H9||(H9=!0,F.logMessage("quickAddApi.ai.countTokens is deprecated and now returns a provider-agnostic estimate (the model argument is ignored). Use estimateTokens(text) instead.")),Uo(i)},getRequestLogs(i=10){return L4(i)},getRequestLogById(i){return U4(i)},getLastRequestLog(){return V4()},clearRequestLogs(){q4()},agent:i=>new hD(e,t,n,i),tool:i=>({...i,__qaTool:!0}),stepCountIs:i=>({stepNumber:o})=>o>=i,hasToolCall:i=>({toolCallNames:o})=>o.includes(i),tools:{vault:i=>x9(e,i),workspace:i=>_9(e,i),system:i=>k9(i)}},utility:{getClipboard:async()=>await navigator.clipboard.readText(),setClipboard:async i=>await navigator.clipboard.writeText(i),getSelection:()=>{let i=On(e);return i?i.editor.getSelection()??"":""},getSelectedText:()=>{let i=On(e);return i?i.editor.somethingSelected()?i.editor.getSelection():(lt(new Error("No text selected"),"Could not get selected text"),""):(lt(new Error("No active Markdown editor"),"Could not get selected text"),"")}},date:{now:(i,o)=>Bs({format:i,offset:o}),tomorrow:i=>Bs({format:i,offset:1}),yesterday:i=>Bs({format:i,offset:-1})},fieldSuggestions:{getFieldValues:async(i,o)=>{let s=o?.includeInlineCodeBlocks?.map(u=>u.trim().toLowerCase()).filter(u=>u.length>0),a={folder:o?.folder,folders:o?.folders,tags:o?.tags,inline:o?.includeInline??!1,inlineCodeBlocks:s},l=e.vault.getMarkdownFiles();l=TD.filterFiles(l,a,u=>e.metadataCache.getFileCache(u));let c=new Set;for(let u of l){let f=e.metadataCache.getFileCache(u)?.frontmatter?.[i];if(f!=null){if(Array.isArray(f))f.forEach(p=>{if(p==null||typeof p=="object")return;let m=String(p).trim();m&&c.add(m)});else if(typeof f!="object"){let p=String(f).trim();p&&c.add(p)}}if(a.inline)try{let p=await e.vault.read(u);Dg.getFieldValues(p,i,{includeCodeBlocks:s}).forEach(v=>c.add(v))}catch{}}return Array.from(c).sort()},clearCache:i=>{Vl.getInstance().clear(i)}}}}static async inputPrompt(e,t,n,i,o){try{return await Sr.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async datePrompt(e,t,n){try{let i=await ef.Prompt(e,t,n?.placeholder,n?.defaultValue,n?.dateFormat);if(i&&i.startsWith("@date:")){let o=i.slice(6);return(n?.dateFormat?Nl(o,n.dateFormat):null)??o}return i}catch(i){Yc(i)}}static async wideInputPrompt(e,t,n,i,o){try{return await ld.Prompt(e,t,n,i,void 0,o)}catch(s){Yc(s)}}static async yesNoPrompt(e,t,n){let i;try{i=await Xi.Ask(e,t,n)}catch(o){Yc(o)}if(i===null)throw new St(yu);return i}static async infoDialog(e,t,n){try{return await lE.Show(e,t,n)}catch(i){Yc(i)}}static async suggester(e,t,n,i,o=!1,s){try{let a;return typeof t=="function"?a=n.map((l,c,u)=>fn(t(l,c,u))):a=t.map(l=>fn(l)),o?await an.Suggest(e,a,n,{...i?{placeholder:i}:{},...s?.renderItem?{renderItem:s.renderItem}:{}}):await Nr.Suggest(e,a,n,i,s?.renderItem)}catch(a){Yc(a)}}static async checkboxPrompt(e,t,n,i){try{return await(i===void 0?Ug.Open(e,t,n):Ug.Open(e,t,n,i))}catch(o){Yc(o)}}}});var jg,sN=b(()=>{L1();jg=class extends Ig{}});function Y9(r){return new Promise(e=>window.setTimeout(e,r))}function mf(r){return r.split(`
|
||
`)}var kD=b(()=>{});async function X9(r,e){return r.mode==="script"?await e.evaluateScriptCondition(r):Sve(r,e.variables)}function Sve(r,e){let t=r.variableName?.trim();if(!t)return F.logWarning("Conditional command skipped: No variable name configured."),!1;if(!(t in e))return F.logWarning(`Conditional command skipped: Variable '${t}' is not defined.`),!1;let n=e[t];switch(r.operator){case"isTruthy":return!!n;case"isFalsy":return!n}if(Ou(r.operator)){let i=YV(r);return i===void 0?(F.logWarning(`Conditional command: Operator '${r.operator}' requires a comparison value.`),!1):r.operator==="contains"?K9(n,i,r):r.operator==="notContains"?!K9(n,i,r):Dve(n,i,r)}return!1}function K9(r,e,t){if(r==null)return!1;if(typeof e=="string"&&e.length===0)return F.logWarning("Conditional command: 'contains' operator requires a non-empty comparison value."),!1;if(Array.isArray(r))return r.map(o=>QP(o,t.valueType)).some(o=>o===e);if(typeof r=="string")return r.includes($u(e));if(typeof r=="number"&&typeof e=="number")return r===e;let n=$u(r),i=$u(e);return typeof n=="string"&&n.includes(i)}function Dve(r,e,t){let n=QP(r,t.valueType);switch(t.operator){case"equals":return n===e;case"notEquals":return n!==e;case"lessThan":return SD(n,e,(i,o)=>i<o);case"lessThanOrEqual":return SD(n,e,(i,o)=>i<=o);case"greaterThan":return SD(n,e,(i,o)=>i>o);case"greaterThanOrEqual":return SD(n,e,(i,o)=>i>=o);default:return!1}}function SD(r,e,t){let n=Number(r),i=Number(e);return Number.isNaN(n)||Number.isNaN(i)?(F.logWarning("Conditional command numeric comparison failed: non-numeric value encountered."),!1):t(n,i)}var Q9=b(()=>{Me();Rm()});function Z9(r,e=void 0){return r==="horizontal"?"horizontal":r==="vertical"?"vertical":e}function gd(r,e,t){return t?{location:r,direction:t,focus:e,mode:"default"}:{location:r,focus:e,mode:"default"}}function J9(r){let e=r.focus??!0;if(r.location)switch(r.location){case"reuse":return gd("reuse",e);case"tab":return gd("tab",e);case"split":return gd("split",e,Z9(r.direction,"vertical"));case"window":return gd("window",e);case"left-sidebar":return gd("left-sidebar",e);case"right-sidebar":return gd("right-sidebar",e);default:break}let t=r.openInNewTab??!1,n=Z9(r.direction);return t?gd("split",e,n??"vertical"):gd("reuse",e)}var eK=b(()=>{Ck()});function tK(r){let e={hasOwnProperty:t=>r.has(t)};return new Proxy(e,{get(t,n){if(n==="hasOwnProperty")return e.hasOwnProperty;if(typeof n=="string")return r.get(n)},set(t,n,i){return typeof n!="string"||r.set(n,i),!0},deleteProperty(t,n){return typeof n!="string"||r.delete(n),!0},has(t,n){return typeof n=="string"&&r.has(n)},ownKeys(){return Array.from(r.keys())},getOwnPropertyDescriptor(t,n){if(n==="hasOwnProperty")return{value:e.hasOwnProperty,writable:!0,configurable:!0,enumerable:!1};if(!(typeof n!="string"||!r.has(n)))return{value:r.get(n),writable:!0,configurable:!0,enumerable:!0}}})}var rK=b(()=>{});function sK(r){return r!==null&&typeof r=="object"}function Pve(r){return typeof r=="function"}function aK(r){return sK(r)}function Fve(r){if(!aK(r))return;let{settings:e}=r;return sK(e)?e:void 0}function nK(r,e="command"){if(typeof r!="string"||!r.trim())return`the saved entry has no ${e} type, so QuickAdd cannot tell what it was meant to do. It is in .obsidian/plugins/quickadd/data.json.`;let t=e==="command"?Mve.get(r):void 0;return t||`QuickAdd does not recognise the ${e} type '${r}'. It can come from a newer version of QuickAdd, an imported package, or a hand-edited .obsidian/plugins/quickadd/data.json.`}function iK(r){return`${r.scriptPath}::${r.exportName??"default"}`}var Ive,oK,Mve,ql,Zx=b(()=>{Ive=UN(require("obsidian"));Me();Cr();Yr();oN();sN();Wc();$g();Og();hl();qt();gs();k$();A$();S$();D$();I$();P$();F$();M$();R$();$$();kD();DS();Xp();It();Lg();Nh();es();qt();oK=require("obsidian");Os();Wr();Co();hk();NT();Uc();Q9();Qx();eK();rK();Ii();Mve=new Map([["InfiniteAIAssistant",'QuickAdd has removed the "Infinite AI Assistant" command type - no released version could ever run one. Delete the step from the macro. For chunked AI prompts, use quickAddApi.ai.chunkedPrompt() in a user script.']]);ql=class extends jg{constructor(t,n,i,o,s,a,l,c=null){super(t);this.originLeaf=c;this.conditionalScriptCache=new Map;this.choice=i,this.plugin=n,this.macro=i?.macro,this.choiceExecutor=o,this.preloadedUserScripts=a??new Map,this.promptLabel=l,this.userScriptSettingsDefinition=void 0;let u=this.initSharedVariables(o,s);this.choiceExecutor.variables=u,this.params=this.buildParams(t,n,o,u)}buildParams(t,n,i,o){let s=tK(o),a={app:t,quickAddApi:Hg.GetApi(t,n,i),obsidian:Ive,abort:l=>{throw new Nt(l)}};return Object.defineProperty(a,"variables",{get:()=>s,set:l=>{if(l===o||l===s)return;let c=l instanceof Map?Array.from(l.entries()).filter(([u])=>typeof u=="string"):l&&typeof l=="object"?Object.entries(l):null;c&&(o.clear(),c?.forEach(([u,d])=>o.set(u,d)))},enumerable:!0,configurable:!1}),a}initSharedVariables(t,n){let i=t.variables;return n?(i&&n!==i&&i.forEach((o,s)=>{n.has(s)||n.set(s,o)}),n):i??new Map}async run(){if(Di(this.macro?.commands))throw new Error(`Could not read the commands for macro '${this.choice.name}'. The saved value is not a list of commands - QuickAdd has not changed it. It is in .obsidian/plugins/quickadd/data.json.`);let t=Dr(this.macro?.commands);if(t.length===0){lx(this.macro?.commands)||F.logError(`No commands in the macro for choice '${this.choice.name}'`);return}await this.executeCommands(t)}getOutput(){return this.output}async executeCommands(t){try{for(let n of t)if(n)switch(n.type){case"Obsidian":this.executeObsidianCommand(n);break;case"UserScript":await this.executeUserScript(n);break;case"Choice":await this.executeChoice(n);break;case"Wait":await Y9(n.time);break;case"NestedChoice":await this.executeNestedChoice(n);break;case"EditorCommand":await this.executeEditorCommand(n);break;case"AIAssistant":await this.executeAIAssistant(n);break;case"OpenFile":await this.executeOpenFile(n);break;case"Conditional":await this.executeConditional(n);break;default:{let i=n.type;this.reportUnrunnableCommand(n,nK(i));break}}}catch(n){if(md(n,{logPrefix:"Macro execution aborted",noticePrefix:"Macro execution aborted",defaultReason:"Macro execution aborted"})){this.choiceExecutor.signalAbort?.(n);return}throw n}}reportUnrunnableCommand(t,n){let i=typeof t?.name=="string"&&t.name.trim()?`'${t.name}'`:"an unnamed command";F.logError(`Skipped ${i} in the macro for '${this.choice.name}': ${n} QuickAdd did not stop the macro, so its result may be incomplete.`)}async executeUserScript(t){let n=OT(t),i;if(n!==void 0){let s=this.preloadedUserScripts.get(n);s!==void 0&&(i=s,this.preloadedUserScripts.delete(n))}if(i===void 0&&(i=await Aa(t,this.app)),!i){F.logError(`failed to load user script ${t.path}.`);return}t.settings||(t.settings={});let o=Fve(i);o&&$h(t.settings,o),this.userScriptCommand=t,this.userScriptSettingsDefinition=o;try{await this.userScriptDelegator(i)}catch(s){throw s instanceof Nt||lt(s,`Failed to run user script ${t.name} in "${this.choice.name}"`),s}finally{this.userScriptCommand=null,this.userScriptSettingsDefinition=void 0}}async getResolvedUserScriptSettings(t){return await Mh(this.app,t,this.userScriptSettingsDefinition)&&await this.plugin.saveSettings?.(),fk(this.app,t,this.userScriptSettingsDefinition)}async runScriptWithSettings(t,n){if(typeof t!="function"&&t.entry&&typeof t.entry=="function")return await this.onExportIsFunction(t.entry,await this.getResolvedUserScriptSettings(n));if(typeof t=="function")return await this.onExportIsFunction(t,await this.getResolvedUserScriptSettings(n))}async userScriptDelegator(t){switch(typeof t){case"function":if(!Pve(t))break;this.userScriptCommand?await this.runScriptWithSettings(t,this.userScriptCommand):await this.onExportIsFunction(t);break;case"object":aK(t)&&await this.onExportIsObject(t);break;case"bigint":case"boolean":case"number":case"string":this.output=t.toString();break;default:F.logError(`user script in macro for '${this.choice.name}' is invalid`)}}async onExportIsFunction(t,n){this.output=await t(this.params,n||{})}async onExportIsObject(t){if(Object.keys(t).length===0)throw new Error(`user script in macro for '${this.choice.name}' is an empty object`);if(this.userScriptCommand&&typeof t.entry=="function"){await this.runScriptWithSettings(t,this.userScriptCommand);return}let n=Object.keys(t);try{let i=String(await ia(this.choiceExecutor,{remote:o=>oa(o,{items:n.map(s=>({value:s,title:s})),placeholder:this.promptLabel,what:"the user-script member picker"}),headless:()=>{if(n.length===1)return Promise.resolve(n[0]);throw new Ee("This macro's user script exports multiple members and needs to ask which one to run, but this run is non-interactive. Reference a single member (e.g. myScript::start), or re-run with the ui flag.")},app:()=>Nr.Suggest(this.app,n,n,this.promptLabel)}));if(!Object.hasOwn(t,i))throw new Error(`This macro's user script does not export a member named "${i}".`);await this.userScriptDelegator(t[i])}catch(i){throw i instanceof Nt?i:Dt(i)?new St("Input cancelled by user"):i}}executeObsidianCommand(t){let n=this.app.commands.commands;if(n&&!n[t.commandId]){F.logError(`Obsidian command '${t.name}' is no longer available.`);return}this.app.commands.executeCommandById(t.commandId)}async executeChoice(t){let n;try{n=this.plugin.getChoiceById(t.choiceId)}catch(o){let s=o instanceof Error?o.message:String(o);if(!/not found/i.test(s))throw o;F.logError(`choice '${t.name}' could not be found.`);return}await this.choiceExecutor.execute(n);let i=this.choiceExecutor.consumeAbortSignal?.();if(i)throw i}async executeNestedChoice(t){let n=t.choice;if(!n){F.logError(`choice in ${t.name} is invalid`);return}await this.choiceExecutor.execute(n);let i=this.choiceExecutor.consumeAbortSignal?.();if(i)throw i}async executeEditorCommand(t){switch(t.editorCommandType){case"Cut":await qh.run(this.app);break;case"Copy":await Vh.run(this.app);break;case"Paste":await Wh.run(this.app);break;case"Paste with format":await zh.run(this.app);break;case"Select active line":Hh.run(this.app);break;case"Select link on active line":jh.run(this.app);break;case"Move cursor to file start":Gh.run(this.app);break;case"Move cursor to file end":Yh.run(this.app);break;case"Move cursor to line start":Kh.run(this.app);break;case"Move cursor to line end":Xh.run(this.app);break;default:{let n=t.editorCommandType;this.reportUnrunnableCommand(t,nK(n,"editor command"))}}}async executeAIAssistant(t){if(ce.getState().disableOnlineFeatures)throw new Error("Blocking request: Online features are disabled in settings.");let n=ce.getState().ai,i;if(t.model==="Ask me")i=await this.pickModelInteractively();else if(i=Kp(mu(t.model,t.modelRef)??t.model),!i)throw new Error(`Model ${t.model} not found with any provider.`);let{model:o,provider:s}=i,a=new ws(this.app,ri(),this.choiceExecutor);a.setPromptRunContext({choiceName:this.choice?.name,draftScopeId:`${this.choice?.id??"macro"}#aiAssistant:${t.id}`});let l=await Ua(this.app,s),c=await W4(this.app,{apiKey:l,model:o,provider:s,outputVariableName:t.outputVariableName,promptTemplate:t.promptTemplate,promptTemplateFolder:n.promptTemplatesFolderPath,systemPrompt:t.systemPrompt,showAssistantMessages:n.showAssistant,modelOptions:t.modelParameters,interactive:this.choiceExecutor.interactive,promptProvider:this.choiceExecutor.promptProvider},async u=>a.formatFileContent(u));for(let u in c)this.choiceExecutor.variables.set(u,c[u])}async pickModelInteractively(){let n=ce.getState().ai.providers.flatMap(o=>o.models.map(s=>({label:`${s.name} (${o.name})`,qualified:`${o.id??o.name}/${s.name}`,resolved:{provider:o,model:s}})));if(n.length===0)throw new Error("No AI models are configured. Add a provider with models in the AI Assistant settings.");let i=this.choiceExecutor.promptProvider;if(i){let o=String(await i.suggester(n.map(a=>a.label),n.map(a=>a.qualified),"Select a model")),s=n.find(a=>a.qualified===o);if(!s)throw new Error(`Model ${o} not found with any provider.`);return s.resolved}if(this.choiceExecutor.interactive===!1)throw new Ee('This AI command is set to "Ask me" for the model, but this run is non-interactive. Pick a specific model in the command, or re-run with the ui flag.');try{return await Nr.Suggest(this.app,n.map(o=>o.label),n.map(o=>o.resolved),"Select a model")}catch(o){throw Dt(o)?new St("Input cancelled by user"):o}}async executeConditional(t){let n=await X9(t.condition,{variables:this.params.variables,evaluateScriptCondition:async s=>await this.evaluateScriptCondition(s)}),i=n?t.thenCommands:t.elseCommands;if(Di(i))throw new Error(`Could not read the ${n?"then":"else"} commands for '${t.name}'. The saved value is not a list of commands - QuickAdd has not changed it. It is in .obsidian/plugins/quickadd/data.json.`);if(!Array.isArray(i)||i.length===0)return;await this.executeCommands(i);let o=this.choiceExecutor.consumeAbortSignal?.();if(o)throw o}async runSubset(t){t?.length&&await this.executeCommands(t)}setOutput(t){this.output=t}async evaluateScriptCondition(t){let n=iK(t),i=this.conditionalScriptCache.get(n);if(!i){if(i=await this.loadConditionalScript(t),!i)return!1;this.conditionalScriptCache.set(n,i)}let o;try{o=await i()}catch(s){throw lt(s,`Failed to evaluate conditional script '${t.scriptPath}'.`),s}return typeof o!="boolean"?(F.logWarning(`Conditional script '${t.scriptPath}' must return a boolean result.`),!1):o}async loadConditionalScript(t){try{let n=await Aa(this.buildConditionalUserScript(t),this.app);return n==null?void 0:typeof n=="function"?async()=>await n(this.params):async()=>n}catch(n){throw lt(n,`Failed to load conditional script '${t.scriptPath}'.`),n}}buildConditionalUserScript(t){return{id:`conditional-script-${iK(t)}`,name:t.exportName?`${t.scriptPath}::${t.exportName}`:t.scriptPath,type:"UserScript",path:t.scriptPath,settings:{}}}async executeOpenFile(t){try{let n=new ws(this.app,ri(),this.choiceExecutor);n.setPromptRunContext({choiceName:this.choice?.name,draftScopeId:`${this.choice?.id??"macro"}#openFile:${t.id}`});let o=(await n.formatFileName(t.filePath,"filePath")).replace(/\\/g,"/"),s=o.split("/");if(s.some((u,d)=>u===".."||u===""&&d!==0&&d!==s.length-1)){F.logError(`OpenFile: Path traversal not allowed in '${o}'`);return}let l=this.app.vault.getAbstractFileByPath(o);if(!l||!(l instanceof oK.TFile)){F.logError(`OpenFile: '${o}' does not exist or is not a file`);return}let c=J9(t);await mc(this.app,l,{...c,originLeaf:this.originLeaf})}catch(n){F.logError(`OpenFile: Failed to open file '${t.filePath}': ${n.message}`)}}}});var Kbe={};Zr(Kbe,{default:()=>eI});module.exports=R7(Kbe);var Jg=require("obsidian");var od=require("obsidian");var VN;typeof window<"u"&&((VN=window.__svelte??(window.__svelte={})).v??(VN.v=new Set)).add("5");var Gl={};var fr=Symbol("uninitialized"),Ts=Symbol("filename");var EE="http://www.w3.org/1999/xhtml";var TE=!0;var qN=globalThis.process?.env?.NODE_ENV,te=qN&&!qN.toLowerCase().startsWith("prod");var da=Array.isArray,WN=Array.prototype.indexOf,nu=Array.prototype.includes,Ef=Array.from,iI=Object.keys,Oi=Object.defineProperty,Ao=Object.getOwnPropertyDescriptor,_E=Object.getOwnPropertyDescriptors,AE=Object.prototype,zN=Array.prototype,iu=Object.getPrototypeOf,oI=Object.isExtensible;function sI(r){return typeof r=="function"}var Vt=()=>{};function kE(r){for(var e=0;e<r.length;e++)r[e]()}function SE(){var r,e,t=new Promise((n,i)=>{r=n,e=i});return{promise:t,resolve:r,reject:e}}var Sn=Symbol("$state"),rv=Symbol("legacy props"),HN=Symbol(""),DE=Symbol("proxy path"),IE=Symbol("attributes"),nv=Symbol("class"),iv=Symbol("style"),ov=Symbol("text"),ou=Symbol("form reset"),aI=Symbol("hmr anchor"),Yl=new class extends Error{constructor(){super(...arguments);le(this,"name","StaleReactionError");le(this,"message","The reaction that called `getAbortSignal()` was re-run or destroyed")}},PE=!!globalThis.document?.contentType&&globalThis.document.contentType.includes("xml");var wd=3,jo=8;function jN(r){if(te){let e=new Error(`invariant_violation
|
||
An invariant violation occurred, meaning Svelte's internal assumptions were flawed. This is a bug in Svelte, not your app \u2014 please open an issue at https://github.com/sveltejs/svelte, citing the following message: "${r}"
|
||
https://svelte.dev/e/invariant_violation`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/invariant_violation")}function FE(r){if(te){let e=new Error(`lifecycle_outside_component
|
||
\`${r}(...)\` can only be used during component initialisation
|
||
https://svelte.dev/e/lifecycle_outside_component`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/lifecycle_outside_component")}function YN(){if(te){let r=new Error("async_derived_orphan\nCannot create a `$derived(...)` with an `await` expression outside of an effect tree\nhttps://svelte.dev/e/async_derived_orphan");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/async_derived_orphan")}function lI(){if(te){let r=new Error("bind_invalid_checkbox_value\nUsing `bind:value` together with a checkbox input is not allowed. Use `bind:checked` instead\nhttps://svelte.dev/e/bind_invalid_checkbox_value");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/bind_invalid_checkbox_value")}function KN(){if(te){let r=new Error(`derived_references_self
|
||
A derived value cannot reference itself recursively
|
||
https://svelte.dev/e/derived_references_self`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/derived_references_self")}function cI(r,e,t){if(te){let n=new Error(`each_key_duplicate
|
||
${t?`Keyed each block has duplicate key \`${t}\` at indexes ${r} and ${e}`:`Keyed each block has duplicate key at indexes ${r} and ${e}`}
|
||
https://svelte.dev/e/each_key_duplicate`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_duplicate")}function XN(r,e,t){if(te){let n=new Error(`each_key_volatile
|
||
Keyed each block has key that is not idempotent \u2014 the key for item at index ${r} was \`${e}\` but is now \`${t}\`. Keys must be the same each time for a given item
|
||
https://svelte.dev/e/each_key_volatile`);throw n.name="Svelte error",n}else throw new Error("https://svelte.dev/e/each_key_volatile")}function QN(r){if(te){let e=new Error(`effect_in_teardown
|
||
\`${r}\` cannot be used inside an effect cleanup function
|
||
https://svelte.dev/e/effect_in_teardown`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_in_teardown")}function ZN(){if(te){let r=new Error("effect_in_unowned_derived\nEffect cannot be created inside a `$derived` value that was not itself created inside an effect\nhttps://svelte.dev/e/effect_in_unowned_derived");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_in_unowned_derived")}function JN(r){if(te){let e=new Error(`effect_orphan
|
||
\`${r}\` can only be used inside an effect (e.g. during component initialisation)
|
||
https://svelte.dev/e/effect_orphan`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/effect_orphan")}function eL(){if(te){let r=new Error(`effect_update_depth_exceeded
|
||
Maximum update depth exceeded. This typically indicates that an effect reads and writes the same piece of state
|
||
https://svelte.dev/e/effect_update_depth_exceeded`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/effect_update_depth_exceeded")}function tL(){if(te){let r=new Error(`hydration_failed
|
||
Failed to hydrate the application
|
||
https://svelte.dev/e/hydration_failed`);throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/hydration_failed")}function rL(){if(te){let r=new Error("invalid_snippet\nCould not `{@render}` snippet due to the expression being `null` or `undefined`. Consider using optional chaining `{@render snippet?.()}`\nhttps://svelte.dev/e/invalid_snippet");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/invalid_snippet")}function nL(r){if(te){let e=new Error(`props_invalid_value
|
||
Cannot do \`bind:${r}={undefined}\` when \`${r}\` has a fallback value
|
||
https://svelte.dev/e/props_invalid_value`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/props_invalid_value")}function iL(r){if(te){let e=new Error(`rune_outside_svelte
|
||
The \`${r}\` rune is only available inside \`.svelte\` and \`.svelte.js/ts\` files
|
||
https://svelte.dev/e/rune_outside_svelte`);throw e.name="Svelte error",e}else throw new Error("https://svelte.dev/e/rune_outside_svelte")}function oL(){if(te){let r=new Error("state_descriptors_fixed\nProperty descriptors defined on `$state` objects must contain `value` and always be `enumerable`, `configurable` and `writable`.\nhttps://svelte.dev/e/state_descriptors_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_descriptors_fixed")}function sL(){if(te){let r=new Error("state_prototype_fixed\nCannot set prototype of `$state` object\nhttps://svelte.dev/e/state_prototype_fixed");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_prototype_fixed")}function aL(){if(te){let r=new Error("state_unsafe_mutation\nUpdating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`\nhttps://svelte.dev/e/state_unsafe_mutation");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/state_unsafe_mutation")}function lL(){if(te){let r=new Error("svelte_boundary_reset_onerror\nA `<svelte:boundary>` `reset` function cannot be called while an error is still being handled\nhttps://svelte.dev/e/svelte_boundary_reset_onerror");throw r.name="Svelte error",r}else throw new Error("https://svelte.dev/e/svelte_boundary_reset_onerror")}var Za="font-weight: bold",Ja="font-weight: normal";function cL(r){te?console.warn(`%c[svelte] await_reactivity_loss
|
||
%cDetected reactivity loss when reading \`${r}\`. This happens when state is read in an async function after an earlier \`await\`
|
||
https://svelte.dev/e/await_reactivity_loss`,Za,Ja):console.warn("https://svelte.dev/e/await_reactivity_loss")}function uL(r,e){te?console.warn(`%c[svelte] await_waterfall
|
||
%cAn async derived, \`${r}\` (${e}) was not read immediately after it resolved. This often indicates an unnecessary waterfall, which can slow down your app
|
||
https://svelte.dev/e/await_waterfall`,Za,Ja):console.warn("https://svelte.dev/e/await_waterfall")}function dL(){te?console.warn(`%c[svelte] derived_inert
|
||
%cReading a derived belonging to a now-destroyed effect may result in stale values
|
||
https://svelte.dev/e/derived_inert`,Za,Ja):console.warn("https://svelte.dev/e/derived_inert")}function pL(r,e,t){te?console.warn(`%c[svelte] hydration_attribute_changed
|
||
%cThe \`${r}\` attribute on \`${e}\` changed its value between server and client renders. The client value, \`${t}\`, will be ignored in favour of the server value
|
||
https://svelte.dev/e/hydration_attribute_changed`,Za,Ja):console.warn("https://svelte.dev/e/hydration_attribute_changed")}function Cd(r){te?console.warn(`%c[svelte] hydration_mismatch
|
||
%c${r?`Hydration failed because the initial UI does not match what was rendered on the server. The error occurred near ${r}`:"Hydration failed because the initial UI does not match what was rendered on the server"}
|
||
https://svelte.dev/e/hydration_mismatch`,Za,Ja):console.warn("https://svelte.dev/e/hydration_mismatch")}function fL(){te?console.warn(`%c[svelte] lifecycle_double_unmount
|
||
%cTried to unmount a component that was not mounted
|
||
https://svelte.dev/e/lifecycle_double_unmount`,Za,Ja):console.warn("https://svelte.dev/e/lifecycle_double_unmount")}function mL(){te?console.warn("%c[svelte] select_multiple_invalid_value\n%cThe `value` property of a `<select multiple>` element should be an array, but it received a non-array value. The selection will be kept as is.\nhttps://svelte.dev/e/select_multiple_invalid_value",Za,Ja):console.warn("https://svelte.dev/e/select_multiple_invalid_value")}function ME(r){te?console.warn(`%c[svelte] state_proxy_equality_mismatch
|
||
%cReactive \`$state(...)\` proxies and the values they proxy have different identities. Because of this, comparisons with \`${r}\` will produce unexpected results
|
||
https://svelte.dev/e/state_proxy_equality_mismatch`,Za,Ja):console.warn("https://svelte.dev/e/state_proxy_equality_mismatch")}function hL(){te?console.warn(`%c[svelte] state_proxy_unmount
|
||
%cTried to unmount a state proxy, rather than a component
|
||
https://svelte.dev/e/state_proxy_unmount`,Za,Ja):console.warn("https://svelte.dev/e/state_proxy_unmount")}function gL(){te?console.warn("%c[svelte] svelte_boundary_reset_noop\n%cA `<svelte:boundary>` `reset` function only resets the boundary the first time it is called\nhttps://svelte.dev/e/svelte_boundary_reset_noop",Za,Ja):console.warn("https://svelte.dev/e/svelte_boundary_reset_noop")}var Re=!1;function Dn(r){Re=r}var Ze;function tr(r){if(r===null)throw Cd(),Gl;return Ze=r}function Yn(){return tr(hi(Ze))}function S(r){if(Re){if(hi(Ze)!==null)throw Cd(),Gl;Ze=r}}function In(r=1){if(Re){for(var e=r,t=Ze;e--;)t=hi(t);Ze=t}}function el(r=!0){for(var e=0,t=Ze;;){if(t.nodeType===jo){var n=t.data;if(n==="]"){if(e===0)return t;e-=1}else(n==="["||n==="[!"||n[0]==="["&&!isNaN(Number(n.slice(1))))&&(e+=1)}var i=hi(t);r&&t.remove(),t=i}}function av(r){if(!r||r.nodeType!==jo)throw Cd(),Gl;return r.data}function RE(r){return r===this.v}function $E(r,e){return r!=r?e==e:r!==e||r!==null&&typeof r=="object"||typeof r=="function"}function OE(r){return!$E(r,this.v)}var Jr=!1,Kl=!1,pa=!1;var O7="font-weight: bold",N7="font-weight: normal";function uI(r){te?console.warn(`%c[svelte] state_snapshot_uncloneable
|
||
%c${r?`The following properties cannot be cloned with \`$state.snapshot\` \u2014 the return value contains the originals:
|
||
|
||
${r}`:"Value cannot be cloned with `$state.snapshot` \u2014 the original value was returned"}
|
||
https://svelte.dev/e/state_snapshot_uncloneable`,O7,N7):console.warn("https://svelte.dev/e/state_snapshot_uncloneable")}var L7=[];function fa(r,e=!1,t=!1){if(te&&!e){let n=[],i=lv(r,new Map,"",n,null,t);if(n.length===1&&n[0]==="")uI();else if(n.length>0){let o=n.length>10?n.slice(0,7):n.slice(0,10),s=n.length-o.length,a=o.map(l=>`- <value>${l}`).join(`
|
||
`);s>0&&(a+=`
|
||
- ...and ${s} more`),uI(a)}return i}return lv(r,new Map,"",L7,null,t)}function lv(r,e,t,n,i=null,o=!1){if(typeof r=="object"&&r!==null){var s=e.get(r);if(s!==void 0)return s;if(r instanceof Map)return new Map(r);if(r instanceof Set)return new Set(r);if(da(r)){var a=Array(r.length);e.set(r,a),i!==null&&e.set(i,a);for(var l=0;l<r.length;l+=1){var c=r[l];l in r&&(a[l]=lv(c,e,te?`${t}[${l}]`:t,n,null,o))}return a}if(iu(r)===AE){a={},e.set(r,a),i!==null&&e.set(i,a);for(var u of Object.keys(r))a[u]=lv(r[u],e,te?`${t}.${u}`:t,n,null,o);return a}if(r instanceof Date)return structuredClone(r);if(typeof r.toJSON=="function"&&!o)return lv(r.toJSON(),e,te?`${t}.toJSON()`:t,n,r)}if(r instanceof EventTarget)return r;try{return structuredClone(r)}catch{return te&&n.push(t),r}}var cv=null;function Ni(r,e){return r.label=e,NE(r.v,e),r}function NE(r,e){return r?.[DE]?.(e),r}function ma(r){let e=new Error,t=B7();return t.length===0?null:(t.unshift(`
|
||
`),Oi(e,"stack",{value:t.join(`
|
||
`)}),Oi(e,"name",{value:r}),e)}function B7(){let r=Error.stackTraceLimit;Error.stackTraceLimit=1/0;let e=new Error().stack;if(Error.stackTraceLimit=r,!e)return[];let t=e.split(`
|
||
`),n=[];for(let i=0;i<t.length;i++){let o=t[i],s=o.replaceAll("\\","/");if(o.trim()!=="Error"){if(o.includes("validate_each_keys"))return[];s.includes("svelte/src/internal")||s.includes("node_modules/.vite")||n.push(o)}}return n}function yL(r,e){if(!te)throw new Error("invariant(...) was not guarded by if (DEV)");r||jN(e)}var _t=null;function Xl(r){_t=r}var tl=null;function Af(r){tl=r}var ha=null;function LE(r){ha=r}function we(r,e=!1,t){_t={p:_t,i:!1,c:null,e:null,s:r,x:null,r:Fe,l:Kl&&!e?{s:null,u:null,$:[]}:null},te&&(_t.function=t,ha=t)}function Ce(r){var e=_t,t=e.e;if(t!==null){e.e=null;for(var n of t)dI(n)}return r!==void 0&&(e.x=r),e.i=!0,_t=e.p,te&&(ha=_t?.function??null),r??{}}function ga(){return!Kl||_t!==null&&_t.l===null}var xd=[];function bL(){var r=xd;xd=[],kE(r)}function Br(r){if(xd.length===0&&!Ed){var e=xd;queueMicrotask(()=>{e===xd&&bL()})}xd.push(r)}function wL(){for(;xd.length>0;)bL()}var pI=new WeakMap;function BE(r){var e=Fe;if(e===null)return je.f|=8388608,r;if(te&&r instanceof Error&&!pI.has(r)&&pI.set(r,U7(r,e)),(e.f&32768)===0&&(e.f&4)===0)throw te&&!e.parent&&r instanceof Error&&CL(r),r;ya(r,e)}function ya(r,e){if(!(e!==null&&(e.f&16384)!==0)){for(;e!==null;){if((e.f&128)!==0){if((e.f&32768)===0)throw r;try{e.b.error(r);return}catch(t){r=t}}e=e.parent}throw te&&r instanceof Error&&CL(r),r}}function U7(r,e){let t=Ao(r,"message");if(!(t&&!t.configurable)){for(var n=dv?" ":" ",i=`
|
||
${n}in ${e.fn?.name||"<unknown>"}`,o=e.ctx;o!==null;)i+=`
|
||
${n}in ${o.function?.[Ts].split("/").pop()}`,o=o.p;return{message:r.message+`
|
||
${i}
|
||
`,stack:r.stack?.split(`
|
||
`).filter(s=>!s.includes("svelte/src/internal")).join(`
|
||
`)}}}function CL(r){let e=pI.get(r);e&&(Oi(r,"message",{value:e.message}),Oi(r,"stack",{value:e.stack}))}var V7=-7169;function rr(r,e){r.f=r.f&V7|e}function kf(r){(r.f&512)!==0||r.deps===null?rr(r,1024):rr(r,4096)}function xL(r){if(r!==null)for(let e of r)(e.f&2)===0||(e.f&65536)===0||(e.f^=65536,xL(e.deps))}function UE(r,e,t){(r.f&2048)!==0?e.add(r):(r.f&4096)!==0&&t.add(r),xL(r.deps),rr(r,1024)}var EL=!1,VE=!1;function fI(r){var e=VE;try{return VE=!1,[r(),VE]}finally{VE=e}}function Ad(r){Re&&gi(r)!==null&&Df(r)}var TL=!1;function qE(){TL||(TL=!0,document.addEventListener("reset",r=>{Promise.resolve().then(()=>{if(!r.defaultPrevented)for(let e of r.target.elements)e[ou]?.()})},{capture:!0}))}function ks(r){var e=je,t=Fe;Mn(null),Rn(null);try{return r()}finally{Mn(e),Rn(t)}}function WE(r,e,t,n=t){r.addEventListener(e,()=>ks(t));let i=r[ou];i?r[ou]=()=>{i(),n(!0)}:r[ou]=()=>n(!0),qE()}function _L(r){let e=0,t=Ui(0),n;return te&&Ni(t,"createSubscriber version"),()=>{su()&&(h(t),Qn(()=>(e===0&&(n=Ot(()=>r(()=>kd(t)))),e+=1,()=>{Br(()=>{e-=1,e===0&&(n?.(),n=void 0,kd(t))})})))}}var W7=589824;function hv(r,e,t,n){new mI(r,e,t,n)}var Go,pv,Ss,Sd,Do,Ds,io,Yo,Zl,Dd,au,If,fv,mv,rl,jE,sr,kL,SL,hI,DL,gI,zE,HE,vI,yI,mI=class{constructor(e,t,n,i){it(this,sr);le(this,"parent");le(this,"is_pending",!1);le(this,"transform_error");it(this,Go);it(this,pv,Re?Ze:null);it(this,Ss);it(this,Sd);it(this,Do);it(this,Ds,null);it(this,io,null);it(this,Yo,null);it(this,Zl,null);it(this,Dd,0);it(this,au,0);it(this,If,!1);it(this,fv,new Set);it(this,mv,new Set);it(this,rl,null);it(this,jE,_L(()=>(et(this,rl,Ui(H(this,Dd))),te&&Ni(H(this,rl),"$effect.pending()"),()=>{et(this,rl,null)})));et(this,Go,e),et(this,Ss,t),et(this,Sd,o=>{var s=Fe;s.b=this,s.f|=128,n(o)}),this.parent=Fe.b,this.transform_error=i??this.parent?.transform_error??(o=>o),et(this,Do,oo(()=>{if(Re){let o=H(this,pv);Yn();let s=o.data==="[!";if(o.data.startsWith("[?")){let l=JSON.parse(o.data.slice("[?".length));xt(this,sr,SL).call(this,l)}else s?xt(this,sr,DL).call(this):xt(this,sr,kL).call(this)}else xt(this,sr,gI).call(this)},W7)),Re&&et(this,Go,Ze)}defer_effect(e){UE(e,H(this,fv),H(this,mv))}is_rendered(){return!this.is_pending&&(!this.parent||this.parent.is_rendered())}has_pending_snippet(){return!!H(this,Ss).pending}update_pending_count(e,t){xt(this,sr,vI).call(this,e,t),et(this,Dd,H(this,Dd)+e),!(!H(this,rl)||H(this,If))&&(et(this,If,!0),Br(()=>{et(this,If,!1),H(this,rl)&&ba(H(this,rl),H(this,Dd))}))}get_effect_pending(){return H(this,jE).call(this),h(H(this,rl))}error(e){if(!H(this,Ss).onerror&&!H(this,Ss).failed)throw e;qe?.is_fork?(H(this,Ds)&&qe.skip_effect(H(this,Ds)),H(this,io)&&qe.skip_effect(H(this,io)),H(this,Yo)&&qe.skip_effect(H(this,Yo)),qe.oncommit(()=>{xt(this,sr,yI).call(this,e)})):xt(this,sr,yI).call(this,e)}};Go=new WeakMap,pv=new WeakMap,Ss=new WeakMap,Sd=new WeakMap,Do=new WeakMap,Ds=new WeakMap,io=new WeakMap,Yo=new WeakMap,Zl=new WeakMap,Dd=new WeakMap,au=new WeakMap,If=new WeakMap,fv=new WeakMap,mv=new WeakMap,rl=new WeakMap,jE=new WeakMap,sr=new WeakSet,kL=function(){try{et(this,Ds,$n(()=>H(this,Sd).call(this,H(this,Go))))}catch(e){this.error(e)}},SL=function(e){let t=H(this,Ss).failed,{reset:n,invoke_onerror:i}=xt(this,sr,hI).call(this,e);Br(i),t&&et(this,Yo,$n(()=>{t(H(this,Go),()=>e,()=>n)}))},hI=function(e){var t=!1,n=!1;let i=()=>{if(t){gL();return}t=!0,n&&lL(),H(this,Yo)!==null&&nl(H(this,Yo),()=>{et(this,Yo,null)}),xt(this,sr,HE).call(this,()=>{xt(this,sr,gI).call(this)})};return{reset:i,invoke_onerror:()=>{try{n=!0,H(this,Ss).onerror?.(e,i),n=!1}catch(s){ya(s,H(this,Do)&&H(this,Do).parent)}}}},DL=function(){let e=H(this,Ss).pending;e&&(this.is_pending=!0,et(this,io,$n(()=>e(H(this,Go)))),Br(()=>{var t=et(this,Zl,document.createDocumentFragment()),n=en();t.append(n),et(this,Ds,xt(this,sr,HE).call(this,()=>$n(()=>H(this,Sd).call(this,n)))),H(this,au)===0&&(H(this,Go).before(t),et(this,Zl,null),nl(H(this,io),()=>{et(this,io,null)}),xt(this,sr,zE).call(this,qe))}))},gI=function(){try{if(this.is_pending=this.has_pending_snippet(),et(this,au,0),et(this,Dd,0),et(this,Ds,$n(()=>{H(this,Sd).call(this,H(this,Go))})),H(this,au)>0){var e=et(this,Zl,document.createDocumentFragment());Pf(H(this,Ds),e);let t=H(this,Ss).pending;et(this,io,$n(()=>t(H(this,Go))))}else xt(this,sr,zE).call(this,qe)}catch(t){this.error(t)}},zE=function(e){this.is_pending=!1,e.transfer_effects(H(this,fv),H(this,mv))},HE=function(e){var t=Fe,n=je,i=_t;Rn(H(this,Do)),Mn(H(this,Do)),Xl(H(this,Do).ctx);try{return Ko.ensure(),e()}catch(o){return BE(o),null}finally{Rn(t),Mn(n),Xl(i)}},vI=function(e,t){var n;if(!this.has_pending_snippet()){this.parent&&xt(n=this.parent,sr,vI).call(n,e,t);return}et(this,au,H(this,au)+e),H(this,au)===0&&(xt(this,sr,zE).call(this,t),H(this,io)&&nl(H(this,io),()=>{et(this,io,null)}),H(this,Zl)&&(H(this,Go).before(H(this,Zl)),et(this,Zl,null)))},yI=function(e){H(this,Ds)&&(Vr(H(this,Ds)),et(this,Ds,null)),H(this,io)&&(Vr(H(this,io)),et(this,io,null)),H(this,Yo)&&(Vr(H(this,Yo)),et(this,Yo,null)),Re&&(tr(H(this,pv)),In(),tr(el()));let t=H(this,Ss).failed,n=i=>{let{reset:o,invoke_onerror:s}=xt(this,sr,hI).call(this,i);s(),t&&et(this,Yo,xt(this,sr,HE).call(this,()=>{try{return $n(()=>{var a=Fe;a.b=this,a.f|=128,t(H(this,Go),()=>i,()=>o)})}catch(a){return ya(a,H(this,Do).parent),null}}))};Br(()=>{var i;try{i=this.transform_error(e)}catch(o){ya(o,H(this,Do)&&H(this,Do).parent);return}i!==null&&typeof i=="object"&&typeof i.then=="function"?i.then(n,o=>ya(o,H(this,Do)&&H(this,Do).parent)):n(i)})};function GE(r,e,t,n){let i=ga()?lu:Id;var o=r.filter(p=>!p.settled),s=e.map(i);if(te&&s.forEach((p,m)=>{p.label=e[m].toString().replace("() => ","").replaceAll("$.eager(() => ","$state.eager(").replace(/\$\.get\((.+?)\)/g,(v,g)=>g)}),t.length===0&&o.length===0){n(s);return}var a=Fe,l=IL(),c=o.length===1?o[0].promise:o.length>1?Promise.all(o.map(p=>p.promise)):null;function u(p){if((a.f&16384)===0){l();try{n([...s,...p])}catch(m){ya(m,a)}Ff()}}var d=bI();if(t.length===0){c.then(()=>u([])).finally(d);return}function f(){Promise.all(t.map(p=>CI(p))).then(u).catch(p=>ya(p,a)).finally(d)}c?c.then(()=>{l(),f(),Ff()}):f()}function IL(){var r=Fe,e=je,t=_t,n=qe;if(te)var i=tl;return function(s=!0){Rn(r),Mn(e),Xl(t),s&&(r.f&16384)===0&&(n?.activate(),n?.apply()),te&&(wI(null),Af(i))}}function Ff(r=!0){Rn(null),Mn(null),Xl(null),r&&qe?.deactivate(),te&&(wI(null),Af(null))}function bI(){var r=Fe,e=r.b,t=qe,n=!!e?.is_rendered();return e?.update_pending_count(1,t),t.increment(n,r),()=>{e?.update_pending_count(-1,t),t.decrement(n,r)}}var Po=null;function wI(r){Po=r}var gv=new Set;function lu(r){var e=2050;Fe!==null&&(Fe.f|=524288);let t={ctx:_t,deps:null,effects:null,equals:RE,f:e,fn:r,reactions:null,rv:0,v:fr,wv:0,parent:Fe,ac:null};return te&&pa&&(t.created=ma("created at")),t}var Mf=Symbol("obsolete");function CI(r,e,t){let n=Fe;n===null&&YN();var i=void 0,o=Ui(fr);te&&(o.label=e??r.toString());var s=!je,a=new Set;return ML(()=>{var l=Fe;te&&(Po={effect:l,effect_deps:new Set,warned:!1});var c=SE();i=c.promise;try{Promise.resolve(r()).then(c.resolve,p=>{p!==Yl&&c.reject(p)}).finally(Ff)}catch(p){c.reject(p),Ff()}if(te){if(Po){if(l.deps!==null)for(let p=0;p<so;p+=1)Po.effect_deps.add(l.deps[p]);if(Zn!==null)for(let p=0;p<Zn.length;p+=1)Po.effect_deps.add(Zn[p])}Po=null}var u=qe;if(s){if((l.f&32768)!==0)var d=bI();if(n.b?.is_rendered())u.async_deriveds.get(l)?.reject(Mf);else for(let p of a.values())p.reject(Mf);a.add(c),u.async_deriveds.set(l,c)}let f=(p,m=void 0)=>{te&&(Po=null),d?.(),a.delete(c),m!==Mf&&(u.activate(),m?(o.f|=8388608,ba(o,m)):((o.f&8388608)!==0&&(o.f^=8388608),te&&t!==void 0&&!o.equals(p)&&(gv.add(o),setTimeout(()=>{gv.has(o)&&(l.f&16384)===0&&(uL(o.label,t),gv.delete(o))})),ba(o,p)),u.deactivate())};c.promise.then(f,p=>f(null,p||"unknown"))}),Xn(()=>{for(let l of a)l.reject(Mf)}),te&&(o.f|=4194304),new Promise(l=>{function c(u){function d(){u===i?l(o):c(i)}u.then(d,d)}c(i)})}function O(r){let e=lu(r);return Jr||XE(e),e}function Id(r){let e=lu(r);return e.equals=OE,e}function PL(r){var e=r.effects;if(e!==null){r.effects=null;for(var t=0;t<e.length;t+=1)Vr(e[t])}}var xI=[];function vv(r){var e,t=Fe,n=r.parent;if(!Xo&&n!==null&&r.v!==fr&&(n.f&24576)!==0)return dL(),r.v;if(Rn(n),te){let i=Pd;YE(new Set);try{nu.call(xI,r)&&KN(),xI.push(r),r.f&=-65537,PL(r),e=KE(r)}finally{Rn(t),YE(i),xI.pop()}}else try{r.f&=-65537,PL(r),e=KE(r)}finally{Rn(t)}return e}function EI(r){var e=vv(r);if(!r.equals(e)&&(r.wv=Rf(),(!qe?.is_fork||r.deps===null)&&(qe!==null?(qe.capture(r,e,!0),il?.capture(r,e,!0)):r.v=e,r.deps===null))){rr(r,1024);return}Xo||(Jn!==null?(su()||qe?.is_fork)&&Jn.set(r,e):kf(r))}function FL(r){if(r.effects!==null)for(let e of r.effects)(e.teardown||e.ac)&&(e.teardown?.(),e.ac!==null&&ks(()=>{e.ac.abort(Yl),e.ac=null}),e.fn!==null&&(e.teardown=Vt),Fd(e,0),yv(e))}function TI(r){if(r.effects!==null)for(let e of r.effects)e.teardown&&e.fn!==null&&ol(e)}var QE=null,$f=null,qe=null,il=null,Jn=null,kI=null,Ed=!1,_I=!1,Md=null,Cv=null,RL=0,AI=new Set,j7=1,Nf,ec,tc,Lf,Bf,Uf,rc,Vf,ao,xv,nc,wa,sl,qf,cu,Zt,SI,bv,DI,OL,NL,Of,LL,wv,ZE=class ZE{constructor(){it(this,Zt);le(this,"id",j7++);it(this,Nf,!1);le(this,"linked",!0);it(this,ec,null);it(this,tc,null);le(this,"async_deriveds",new Map);le(this,"current",new Map);le(this,"previous",new Map);it(this,Lf,new Set);it(this,Bf,new Set);it(this,Uf,0);it(this,rc,new Map);it(this,Vf,null);it(this,ao,[]);it(this,xv,[]);it(this,nc,new Set);it(this,wa,new Set);it(this,sl,new Map);it(this,qf,new Set);le(this,"is_fork",!1);it(this,cu,!1);$f===null?QE=$f=this:(et($f,tc,this),et(this,ec,$f)),$f=this}skip_effect(e){H(this,sl).has(e)||H(this,sl).set(e,{d:[],m:[]}),H(this,qf).delete(e)}unskip_effect(e,t=n=>this.schedule(n)){var n=H(this,sl).get(e);if(n){H(this,sl).delete(e);for(var i of n.d)rr(i,2048),t(i);for(i of n.m)rr(i,4096),t(i)}H(this,qf).add(e)}capture(e,t,n=!1){e.v!==fr&&!this.previous.has(e)&&this.previous.set(e,e.v),(e.f&8388608)===0&&(this.current.set(e,[t,n]),Jn?.set(e,t)),this.is_fork||(e.v=t)}activate(){qe=this}deactivate(){qe=null,Jn=null}flush(){try{te&&AI.clear(),_I=!0,qe=this,xt(this,Zt,bv).call(this)}finally{if(RL=0,kI=null,Md=null,Cv=null,_I=!1,qe=null,Jn=null,ic.clear(),te)for(let e of AI)e.updated=null}}discard(){for(let e of H(this,Bf))e(this);H(this,Bf).clear();for(let e of this.async_deriveds.values())e.reject(Mf);xt(this,Zt,wv).call(this),H(this,Vf)?.resolve()}register_created_effect(e){H(this,xv).push(e)}increment(e,t){if(et(this,Uf,H(this,Uf)+1),e){let n=H(this,rc).get(t)??0;H(this,rc).set(t,n+1)}}decrement(e,t){if(et(this,Uf,H(this,Uf)-1),e){let n=H(this,rc).get(t)??0;n===1?H(this,rc).delete(t):H(this,rc).set(t,n-1)}H(this,cu)||(et(this,cu,!0),Br(()=>{et(this,cu,!1),this.linked&&this.flush()}))}transfer_effects(e,t){for(let n of e)H(this,nc).add(n);for(let n of t)H(this,wa).add(n);e.clear(),t.clear()}oncommit(e){H(this,Lf).add(e)}ondiscard(e){H(this,Bf).add(e)}settled(){return(H(this,Vf)??et(this,Vf,SE())).promise}static ensure(){if(qe===null){let e=qe=new ZE;!_I&&!Ed&&Br(()=>{H(e,Nf)||e.flush()})}return qe}apply(){if(!Jr||!this.is_fork&&H(this,ec)===null&&H(this,tc)===null){Jn=null;return}Jn=new Map;for(let[t,[n]]of this.current)Jn.set(t,n);for(let t=QE;t!==null;t=H(t,tc))if(!(t===this||t.is_fork)){var e=!1;if(t.id<this.id){for(let[n,[,i]]of t.current)if(!i&&this.current.has(n)){e=!0;break}}if(!e)for(let[n,i]of t.previous)Jn.has(n)||Jn.set(n,i)}}schedule(e){if(kI=e,e.b?.is_pending&&(e.f&16777228)!==0&&(e.f&32768)===0){e.b.defer_effect(e);return}for(var t=e;t.parent!==null;){t=t.parent;var n=t.f;if(Md!==null&&t===Fe&&(Jr||(je===null||(je.f&2)===0)&&!EL))return;if((n&96)!==0){if((n&1024)===0)return;t.f^=1024}}H(this,ao).push(t)}};Nf=new WeakMap,ec=new WeakMap,tc=new WeakMap,Lf=new WeakMap,Bf=new WeakMap,Uf=new WeakMap,rc=new WeakMap,Vf=new WeakMap,ao=new WeakMap,xv=new WeakMap,nc=new WeakMap,wa=new WeakMap,sl=new WeakMap,qf=new WeakMap,cu=new WeakMap,Zt=new WeakSet,SI=function(){if(this.is_fork)return!0;for(let n of H(this,rc).keys()){for(var e=n,t=!1;e.parent!==null;){if(H(this,sl).has(e)){t=!0;break}e=e.parent}if(!t)return!0}return!1},bv=function(){var l,c,u;if(et(this,Nf,!0),RL++>1e3&&(xt(this,Zt,wv).call(this),G7()),te)for(let d of this.current.keys())AI.add(d);for(let d of H(this,nc))H(this,wa).delete(d),rr(d,2048),this.schedule(d);for(let d of H(this,wa))rr(d,4096),this.schedule(d);let e=H(this,ao);et(this,ao,[]),this.apply();var t=Md=[],n=[],i=Cv=[];for(let d of e)try{xt(this,Zt,DI).call(this,d,t,n)}catch(f){throw VL(d),xt(this,Zt,SI).call(this)||this.discard(),f}if(qe=null,i.length>0){var o=ZE.ensure();for(let d of i)o.schedule(d)}if(Md=null,Cv=null,xt(this,Zt,SI).call(this)){xt(this,Zt,Of).call(this,n),xt(this,Zt,Of).call(this,t);for(let[d,f]of H(this,sl))UL(d,f);i.length>0&&xt(l=qe,Zt,bv).call(l);return}let s=xt(this,Zt,OL).call(this);if(s){xt(this,Zt,Of).call(this,n),xt(this,Zt,Of).call(this,t),xt(c=s,Zt,NL).call(c,this);return}H(this,nc).clear(),H(this,wa).clear();for(let d of H(this,Lf))d(this);H(this,Lf).clear(),il=this,$L(n),$L(t),il=null,H(this,Vf)?.resolve();var a=qe;if(H(this,Uf)===0&&(H(this,ao).length===0||a!==null)&&(xt(this,Zt,wv).call(this),Jr&&(xt(this,Zt,LL).call(this),qe=a)),H(this,ao).length>0)if(a!==null){let d=a;H(d,ao).push(...H(this,ao).filter(f=>!H(d,ao).includes(f)))}else a=this;a!==null&&xt(u=a,Zt,bv).call(u)},DI=function(e,t,n){e.f^=1024;for(var i=e.first;i!==null;){var o=i.f,s=(o&96)!==0,a=s&&(o&1024)!==0,l=a||(o&8192)!==0||H(this,sl).has(i);if(!l&&i.fn!==null){s?i.f^=1024:(o&4)!==0?t.push(i):Jr&&(o&16777224)!==0?n.push(i):uu(i)&&((o&16)!==0&&H(this,wa).add(i),ol(i));var c=i.first;if(c!==null){i=c;continue}}for(;i!==null;){var u=i.next;if(u!==null){i=u;break}i=i.parent}}},OL=function(){for(var e=H(this,ec);e!==null;){if(!e.is_fork){for(let[t,[,n]]of this.current)if(e.current.has(t)&&!n)return e}e=H(e,ec)}return null},NL=function(e){var n;for(let[i,o]of e.current)!this.previous.has(i)&&e.previous.has(i)&&this.previous.set(i,e.previous.get(i)),this.current.set(i,o);for(let[i,o]of e.async_deriveds){let s=this.async_deriveds.get(i);s&&o.promise.then(s.resolve).catch(s.reject)}e.async_deriveds.clear(),this.transfer_effects(H(e,nc),H(e,wa));let t=i=>{var o=i.reactions;if(o!==null&&!((i.f&2)!==0&&(i.f&6144)===0))for(let l of o){var s=l.f;if((s&2)!==0)t(l);else{var a=l;s&4194320&&!this.async_deriveds.has(a)&&(H(this,wa).delete(a),rr(a,2048),this.schedule(a))}}};for(let i of this.current.keys())t(i);this.oncommit(()=>e.discard()),xt(n=e,Zt,wv).call(n),qe=this,xt(this,Zt,bv).call(this)},Of=function(e){for(var t=0;t<e.length;t+=1)UE(e[t],H(this,nc),H(this,wa))},LL=function(){var d;for(let f=QE;f!==null;f=H(f,tc)){var e=f.id<this.id,t=[];for(let[p,[m,v]]of this.current){if(f.current.has(p)){var n=f.current.get(p)[0];if(e&&m!==n)f.current.set(p,[m,v]);else continue}t.push(p)}if(e)for(let[p,m]of this.async_deriveds){let v=f.async_deriveds.get(p);v&&m.promise.then(v.resolve).catch(v.reject)}var i=[...f.current.keys()].filter(p=>!f.current.get(p)[1]);if(!(!H(f,Nf)||i.length===0)){var o=i.filter(p=>!this.current.has(p));if(o.length===0)e&&f.discard();else if(t.length>0){if(te&&!H(f,cu)&&yL(H(f,ao).length===0,"Batch has scheduled roots"),e)for(let p of H(this,qf))f.unskip_effect(p,m=>{var v;(m.f&4194320)!==0?f.schedule(m):xt(v=f,Zt,Of).call(v,[m])});f.activate();var s=new Set,a=new Map;for(var l of t)BL(l,o,s,a);a=new Map;var c=[...f.current].filter(([p,m])=>{let v=this.current.get(p);return v?v[0]!==m[0]||v[1]!==m[1]:!0}).map(([p])=>p);if(c.length>0)for(let p of H(this,xv))(p.f&155648)===0&&II(p,c,a)&&((p.f&4194320)!==0?(rr(p,2048),f.schedule(p)):H(f,nc).add(p));if(H(f,ao).length>0&&!H(f,cu)){f.apply();for(var u of H(f,ao))xt(d=f,Zt,DI).call(d,u,[],[]);et(f,ao,[])}f.deactivate()}}}},wv=function(){if(this.linked){var e=H(this,ec),t=H(this,tc);e===null?QE=t:et(e,tc,t),t===null?$f=e:et(t,ec,e),this.linked=!1}};var Ko=ZE;function $d(r){var e=Ed;Ed=!0;try{var t;for(r&&(qe!==null&&!qe.is_fork&&qe.flush(),t=r());;){if(wL(),qe===null)return t;qe.flush()}}finally{Ed=e}}function G7(){if(te){var r=new Map;for(let t of qe.current.keys())for(let[n,i]of t.updated??[]){var e=r.get(n);e||(e={error:i.error,count:0},r.set(n,e)),e.count+=i.count}for(let t of r.values())t.error&&console.error(t.error)}try{eL()}catch(t){te&&Oi(t,"stack",{value:""}),ya(t,kI)}}var Is=null;function $L(r){var e=r.length;if(e!==0){for(var t=0;t<e;){var n=r[t++];if((n.f&24576)===0&&uu(n)&&(Is=new Set,ol(n),n.deps===null&&n.first===null&&n.nodes===null&&n.teardown===null&&n.ac===null&&PI(n),Is?.size>0)){ic.clear();for(let i of Is){if((i.f&24576)!==0)continue;let o=[i],s=i.parent;for(;s!==null;)Is.has(s)&&(Is.delete(s),o.push(s)),s=s.parent;for(let a=o.length-1;a>=0;a--){let l=o[a];(l.f&24576)===0&&ol(l)}}Is.clear()}}Is=null}}function BL(r,e,t,n){if(!t.has(r)&&(t.add(r),r.reactions!==null))for(let i of r.reactions){let o=i.f;(o&2)!==0?BL(i,e,t,n):(o&4194320)!==0&&(o&2048)===0&&II(i,e,n)&&(rr(i,2048),Tv(i))}}function II(r,e,t){let n=t.get(r);if(n!==void 0)return n;if(r.deps!==null)for(let i of r.deps){if(nu.call(e,i))return!0;if((i.f&2)!==0&&II(i,e,t))return t.set(i,!0),!0}return t.set(r,!1),!1}function Tv(r){qe.schedule(r)}function UL(r,e){if(!((r.f&32)!==0&&(r.f&1024)!==0)){(r.f&2048)!==0?e.d.push(r):(r.f&4096)!==0&&e.m.push(r),rr(r,1024);for(var t=r.first;t!==null;)UL(t,e),t=t.next}}function VL(r){rr(r,1024);for(var e=r.first;e!==null;)VL(e),e=e.next}var Pd=new Set,ic=new Map;function YE(r){Pd=r}var FI=!1;function WL(){FI=!0}function Ui(r,e){var t={f:0,v:r,reactions:null,equals:RE,rv:0,wv:0};return te&&pa&&(t.created=e??ma("created at"),t.updated=null,t.set_during_effect=!1,t.trace=null),t}function Ae(r,e){let t=Ui(r,e);return XE(t),t}function Td(r,e=!1,t=!0){var i;let n=Ui(r);return e||(n.equals=OE),Kl&&t&&_t!==null&&_t.l!==null&&((i=_t.l).s??(i.s=[])).push(n),n}function Z(r,e,t=!1){je!==null&&(!lo||(je.f&131072)!==0)&&ga()&&(je.f&4325394)!==0&&(Ca===null||!Ca.has(r))&&aL();let n=t?bt(e):e;return te&&NE(n,r.label),ba(r,n,Cv)}function ba(r,e,t=null){if(!r.equals(e)){ic.set(r,Xo?e:r.v);var n=Ko.ensure();if(n.capture(r,e),te){if(pa||Fe!==null){r.updated??(r.updated=new Map);let i=(r.updated.get("")?.count??0)+1;if(r.updated.set("",{error:null,count:i}),pa||i>5){let o=ma("updated at");if(o!==null){let s=r.updated.get(o.stack);s||(s={error:o,count:0},r.updated.set(o.stack,s)),s.count++}}}Fe!==null&&(r.set_during_effect=!0)}if((r.f&2)!==0){let i=r;(r.f&2048)!==0&&vv(i),Jn===null&&kf(i)}r.wv=Rf(),zL(r,2048,t),ga()&&Fe!==null&&(Fe.f&1024)!==0&&(Fe.f&96)===0&&(Qo===null?HL([r]):Qo.push(r)),!n.is_fork&&Pd.size>0&&!FI&&JE()}return e}function JE(){FI=!1;for(let r of Pd){(r.f&1024)!==0&&rr(r,4096);let e;try{e=uu(r)}catch{e=!0}e&&ol(r)}Pd.clear()}function MI(r,e=1){var t=h(r);return Z(r,e===1?++t:--t)}function kd(r){Z(r,r.v+1)}function zL(r,e,t){var n=r.reactions;if(n!==null)for(var i=ga(),o=n.length,s=0;s<o;s++){var a=n[s],l=a.f;if(!(!i&&a===Fe)){var c=(l&2048)===0;if(c&&rr(a,e),(l&131072)!==0)Pd.add(a);else if((l&2)!==0){var u=a;Jn?.delete(u),(l&65536)===0&&(l&512&&(Fe===null||(Fe.f&2097152)===0)&&(a.f|=65536),zL(u,4096,t))}else if(c){var d=a;(l&16)!==0&&Is!==null&&Is.add(d),t!==null?t.push(d):Tv(d)}}}}var K7=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function bt(r){if(typeof r!="object"||r===null||Sn in r)return r;let e=iu(r);if(e!==AE&&e!==zN)return r;var t=new Map,n=da(r),i=Ae(0),o=te&&pa?ma("created at"):null,s=du,a=d=>{if(du===s)return d();var f=je,p=du;Mn(null),RI(s);var m=d();return Mn(f),RI(p),m};n&&(t.set("length",Ae(r.length,o)),te&&(r=Q7(r)));var l="";let c=!1;function u(d){if(!c){c=!0,l=d,Ni(i,`${l} version`);for(let[f,p]of t)Ni(p,Od(l,f));c=!1}}return new Proxy(r,{defineProperty(d,f,p){(!("value"in p)||p.configurable===!1||p.enumerable===!1||p.writable===!1)&&oL();var m=t.get(f);return m===void 0?a(()=>{var v=Ae(p.value,o);return t.set(f,v),te&&typeof f=="string"&&Ni(v,Od(l,f)),v}):Z(m,p.value,!0),!0},deleteProperty(d,f){var p=t.get(f);if(p===void 0){if(f in d){let m=a(()=>Ae(fr,o));t.set(f,m),kd(i),te&&Ni(m,Od(l,f))}}else Z(p,fr),kd(i);return!0},get(d,f,p){if(f===Sn)return r;if(te&&f===DE)return u;var m=t.get(f),v=f in d;if(m===void 0&&(!v||Ao(d,f)?.writable)&&(m=a(()=>{var y=bt(v?d[f]:fr),w=Ae(y,o);return te&&Ni(w,Od(l,f)),w}),t.set(f,m)),m!==void 0){var g=h(m);return g===fr?void 0:g}return Reflect.get(d,f,p)},getOwnPropertyDescriptor(d,f){var p=Reflect.getOwnPropertyDescriptor(d,f);if(p&&"value"in p){var m=t.get(f);m&&(p.value=h(m))}else if(p===void 0){var v=t.get(f),g=v?.v;if(v!==void 0&&g!==fr)return{enumerable:!0,configurable:!0,value:g,writable:!0}}return p},has(d,f){if(f===Sn)return!0;var p=t.get(f),m=p!==void 0&&p.v!==fr||Reflect.has(d,f);if(p!==void 0||Fe!==null&&(!m||Ao(d,f)?.writable)){p===void 0&&(p=a(()=>{var g=m?bt(d[f]):fr,y=Ae(g,o);return te&&Ni(y,Od(l,f)),y}),t.set(f,p));var v=h(p);if(v===fr)return!1}return m},set(d,f,p,m){var v=t.get(f),g=f in d;if(n&&f==="length")for(var y=p;y<v.v;y+=1){var w=t.get(y+"");w!==void 0?Z(w,fr):y in d&&(w=a(()=>Ae(fr,o)),t.set(y+"",w),te&&Ni(w,Od(l,y)))}if(v===void 0)(!g||Ao(d,f)?.writable)&&(v=a(()=>Ae(void 0,o)),te&&Ni(v,Od(l,f)),Z(v,bt(p)),t.set(f,v));else{g=v.v!==fr;var x=a(()=>bt(p));Z(v,x)}var C=Reflect.getOwnPropertyDescriptor(d,f);if(C?.set&&C.set.call(m,p),!g){if(n&&typeof f=="string"){var _=t.get("length"),E=Number(f);Number.isInteger(E)&&E>=_.v&&Z(_,E+1)}kd(i)}return!0},ownKeys(d){h(i);var f=Reflect.ownKeys(d).filter(v=>{var g=t.get(v);return g===void 0||g.v!==fr});for(var[p,m]of t)m.v!==fr&&!(p in d)&&f.push(p);return f},setPrototypeOf(){sL()}})}function Od(r,e){return typeof e=="symbol"?`${r}[Symbol(${e.description??""})]`:K7.test(e)?`${r}.${e}`:/^\d+$/.test(e)?`${r}[${e}]`:`${r}['${e}']`}function zf(r){try{if(r!==null&&typeof r=="object"&&Sn in r)return r[Sn]}catch{}return r}function $I(r,e){return Object.is(zf(r),zf(e))}var X7=new Set(["copyWithin","fill","pop","push","reverse","shift","sort","splice","unshift"]);function Q7(r){return new Proxy(r,{get(e,t,n){var i=Reflect.get(e,t,n);return X7.has(t)?function(...o){WL();var s=i.apply(this,o);return JE(),s}:i}})}function jL(){let r=Array.prototype,e=Array.__svelte_cleanup;e&&e();let{indexOf:t,lastIndexOf:n,includes:i}=r;r.indexOf=function(o,s){let a=t.call(this,o,s);if(a===-1){for(let l=s??0;l<this.length;l+=1)if(zf(this[l])===o){ME("array.indexOf(...)");break}}return a},r.lastIndexOf=function(o,s){let a=n.call(this,o,s??this.length-1);if(a===-1){for(let l=0;l<=(s??this.length-1);l+=1)if(zf(this[l])===o){ME("array.lastIndexOf(...)");break}}return a},r.includes=function(o,s){let a=i.call(this,o,s);if(!a){for(let l=0;l<this.length;l+=1)if(zf(this[l])===o){ME("array.includes(...)");break}}return a},Array.__svelte_cleanup=()=>{r.indexOf=t,r.lastIndexOf=n,r.includes=i}}var OI,GL,dv,YL,KL;function eT(){if(OI===void 0){OI=window,GL=document,dv=/Firefox/.test(navigator.userAgent);var r=Element.prototype,e=Node.prototype,t=Text.prototype;YL=Ao(e,"firstChild").get,KL=Ao(e,"nextSibling").get,oI(r)&&(r[nv]=void 0,r[IE]=null,r[iv]=void 0,r.__e=void 0),oI(t)&&(t[ov]=void 0),te&&(r.__svelte_meta=null,jL())}}function en(r=""){return document.createTextNode(r)}function gi(r){return YL.call(r)}function hi(r){return KL.call(r)}function I(r,e){if(!Re)return gi(r);var t=gi(Ze);if(t===null)t=Ze.appendChild(en());else if(e&&t.nodeType!==wd){var n=en();return t?.before(n),tr(n),n}return e&&_v(t),tr(t),t}function Pe(r,e=!1){if(!Re){var t=gi(r);return t instanceof Comment&&t.data===""?hi(t):t}if(e){if(Ze?.nodeType!==wd){var n=en();return Ze?.before(n),tr(n),n}_v(Ze)}return Ze}function A(r,e=1,t=!1){let n=Re?Ze:r;for(var i;e--;)i=n,n=hi(n);if(!Re)return n;if(t){if(n?.nodeType!==wd){var o=en();return n===null?i?.after(o):n.before(o),tr(o),o}_v(n)}return tr(n),n}function Df(r){r.textContent=""}function tT(){if(!Jr||Is!==null)return!1;var r=Fe.f;return(r&32768)!==0}function al(r,e,t){return e==null||e===EE?t?document.createElement(r,{is:t}):document.createElement(r):t?document.createElementNS(e,r,{is:t}):document.createElementNS(e,r)}function _v(r){if(r.nodeValue.length<65536)return;let e=r.nextSibling;for(;e!==null&&e.nodeType===wd;)e.remove(),r.nodeValue+=e.nodeValue,e=r.nextSibling}function QL(r){Fe===null&&(je===null&&JN(r),ZN()),Xo&&QN(r)}function J7(r,e){var t=e.last;t===null?e.last=e.first=r:(t.next=r,r.prev=t,e.last=r)}function ll(r,e){var t=Fe;if(te)for(;t!==null&&(t.f&131072)!==0;)t=t.parent;t!==null&&(t.f&8192)!==0&&(r|=8192);var n={ctx:_t,deps:null,nodes:null,f:r|2048|512,first:null,fn:e,last:null,next:null,parent:t,b:t&&t.b,prev:null,teardown:null,wv:0,ac:null};te&&(n.component_function=ha),qe?.register_created_effect(n);var i=n;if((r&4)!==0)Md!==null?Md.push(n):Ko.ensure().schedule(n);else if(e!==null){try{ol(n)}catch(s){throw Vr(n),s}i.deps===null&&i.teardown===null&&i.nodes===null&&i.first===i.last&&(i.f&524288)===0&&(i=i.first,(r&16)!==0&&(r&65536)!==0&&i!==null&&(i.f|=65536))}if(i!==null&&(i.parent=t,t!==null&&J7(i,t),je!==null&&(je.f&2)!==0&&(r&64)===0)){var o=je;(o.effects??(o.effects=[])).push(i)}return n}function su(){return je!==null&&!lo}function Xn(r){let e=ll(8,null);return rr(e,1024),e.teardown=r,e}function hr(r){QL("$effect"),te&&Oi(r,"name",{value:"$effect"});var e=Fe.f,t=!je&&(e&32)!==0&&_t!==null&&!_t.i;if(t){var n=_t;(n.e??(n.e=[])).push(r)}else return dI(r)}function dI(r){return ll(1048580,r)}function LI(r){Ko.ensure();let e=ll(524352,r);return()=>{Vr(e)}}function ZL(r){Ko.ensure();let e=ll(524352,r);return(t={})=>new Promise(n=>{t.outro?nl(e,()=>{Vr(e),n(void 0)}):(Vr(e),n(void 0))})}function cn(r){return ll(4,r)}function ML(r){return ll(4718592,r)}function Qn(r,e=0){return ll(8|e,r)}function de(r,e=[],t=[],n=[]){GE(n,e,t,i=>{ll(8,()=>{r(...i.map(h))})})}function oo(r,e=0){var t=ll(16|e,r);return te&&(t.dev_stack=tl),t}function $n(r){return ll(524320,r)}function BI(r){var e=r.teardown;if(e!==null){let t=Xo,n=je;NI(!0),Mn(null);try{e.call(null)}finally{NI(t),Mn(n)}}}function yv(r,e=!1){var t=r.first;for(r.first=r.last=null;t!==null;){let i=t.ac;i!==null&&ks(()=>{i.abort(Yl)});var n=t.next;(t.f&64)!==0?t.parent=null:Vr(t,e),t=n}}function JL(r){for(var e=r.first;e!==null;){var t=e.next;(e.f&32)===0&&Vr(e),e=t}}function Vr(r,e=!0){var t=!1;(e||(r.f&262144)!==0)&&r.nodes!==null&&r.nodes.end!==null&&(e2(r.nodes.start,r.nodes.end),t=!0),r.f|=33554432,yv(r,e&&!t),Fd(r,0);var n=r.nodes&&r.nodes.t;if(n!==null)for(let o of n)o.stop();BI(r),r.f^=33554432,r.f|=16384;var i=r.parent;i!==null&&i.first!==null&&PI(r),te&&(r.component_function=null),r.next=r.prev=r.teardown=r.ctx=r.deps=r.fn=r.nodes=r.ac=r.b=null}function e2(r,e){for(;r!==null;){var t=r===e?null:hi(r);r.remove(),r=t}}function PI(r){var e=r.parent,t=r.prev,n=r.next;t!==null&&(t.next=n),n!==null&&(n.prev=t),e!==null&&(e.first===r&&(e.first=n),e.last===r&&(e.last=t))}function nl(r,e,t=!0){var n=[];t2(r,n,!0);var i=()=>{t&&Vr(r),e&&e()},o=n.length;if(o>0){var s=()=>--o||i();for(var a of n)a.out(s)}else i()}function t2(r,e,t){if((r.f&8192)===0){r.f^=8192;var n=r.nodes&&r.nodes.t;if(n!==null)for(let a of n)(a.is_global||t)&&e.push(a);for(var i=r.first;i!==null;){var o=i.next;if((i.f&64)===0){var s=(i.f&65536)!==0||(i.f&32)!==0&&(r.f&16)!==0;t2(i,e,s?t:!1)}i=o}}}function Hf(r){r2(r,!0)}function r2(r,e){if((r.f&8192)!==0){r.f^=8192,(r.f&1024)===0&&(rr(r,2048),Ko.ensure().schedule(r));for(var t=r.first;t!==null;){var n=t.next,i=(t.f&65536)!==0||(t.f&32)!==0;r2(t,i?e:!1),t=n}var o=r.nodes&&r.nodes.t;if(o!==null)for(let s of o)(s.is_global||e)&&s.in()}}function Pf(r,e){if(r.nodes)for(var t=r.nodes.start,n=r.nodes.end;t!==null;){var i=t===n?null:hi(t);e.append(t),t=i}}var n2=null;var rT=!1,Xo=!1;function NI(r){Xo=r}var je=null,lo=!1;function Mn(r){je=r}var Fe=null;function Rn(r){Fe=r}var Ca=null;function XE(r){je!==null&&(!Jr||(je.f&2)!==0)&&(Ca??(Ca=new Set)).add(r)}var Zn=null,so=0,Qo=null;function HL(r){Qo=r}var i2=1,Nd=0,du=Nd;function RI(r){du=r}function Rf(){return++i2}function uu(r){var e=r.f;if((e&2048)!==0)return!0;if(e&2&&(r.f&=-65537),(e&4096)!==0){for(var t=r.deps,n=t.length,i=0;i<n;i++){var o=t[i];if(uu(o)&&EI(o),o.wv>r.wv)return!0}(e&512)!==0&&Jn===null&&rr(r,1024)}return!1}function o2(r,e,t=!0){var n=r.reactions;if(n!==null&&!(!Jr&&Ca!==null&&Ca.has(r)))for(var i=0;i<n.length;i++){var o=n[i];(o.f&2)!==0?o2(o,e,!1):e===o&&(t?rr(o,2048):(o.f&1024)!==0&&rr(o,4096),Tv(o))}}function KE(r){var v;var e=Zn,t=so,n=Qo,i=je,o=Ca,s=_t,a=lo,l=du,c=r.f;Zn=null,so=0,Qo=null,je=(c&96)===0?r:null,Ca=null,Xl(r.ctx),lo=!1,du=++Nd,r.ac!==null&&(ks(()=>{r.ac.abort(Yl)}),r.ac=null);try{r.f|=2097152;var u=r.fn,d=u();r.f|=32768;var f=r.deps,p=qe?.is_fork;if(Zn!==null){var m;if(p||Fd(r,so),f!==null&&so>0)for(f.length=so+Zn.length,m=0;m<Zn.length;m++)f[so+m]=Zn[m];else r.deps=f=Zn;if(su()&&(r.f&512)!==0)for(m=so;m<f.length;m++)((v=f[m]).reactions??(v.reactions=[])).push(r)}else!p&&f!==null&&so<f.length&&(Fd(r,so),f.length=so);if(ga()&&Qo!==null&&!lo&&f!==null&&(r.f&6146)===0)for(m=0;m<Qo.length;m++)o2(Qo[m],r);if(i!==null&&i!==r){if(Nd++,i.deps!==null)for(let g=0;g<t;g+=1)i.deps[g].rv=Nd;if(e!==null)for(let g of e)g.rv=Nd;Qo!==null&&(n===null?n=Qo:n.push(...Qo))}return(r.f&8388608)!==0&&(r.f^=8388608),d}catch(g){return BE(g)}finally{r.f^=2097152,Zn=e,so=t,Qo=n,je=i,Ca=o,Xl(s),lo=a,du=l}}function eX(r,e){let t=e.reactions;if(t!==null){var n=WN.call(t,r);if(n!==-1){var i=t.length-1;i===0?t=e.reactions=null:(t[n]=t[i],t.pop())}}if(t===null&&(e.f&2)!==0&&(Zn===null||!nu.call(Zn,e))){var o=e;(o.f&512)!==0&&(o.f^=512,o.f&=-65537),o.v!==fr&&kf(o),o.ac!==null&&ks(()=>{o.ac.abort(Yl),o.ac=null,rr(o,2048)}),FL(o),Fd(o,0)}}function Fd(r,e){var t=r.deps;if(t!==null)for(var n=e;n<t.length;n++)eX(r,t[n])}function ol(r){var e=r.f;if((e&16384)===0){rr(r,1024);var t=Fe,n=rT;if(Fe=r,rT=(e&96)===0,te){var i=ha;LE(r.component_function);var o=tl;Af(r.dev_stack??tl)}try{(e&16777232)!==0?JL(r):yv(r),BI(r);var s=KE(r);if(r.teardown=typeof s=="function"?s:null,r.wv=i2,te&&pa&&(r.f&2048)!==0&&r.deps!==null)for(var a of r.deps)a.set_during_effect&&(a.wv=Rf(),a.set_during_effect=!1)}finally{rT=n,Fe=t,te&&(LE(i),Af(o))}}}async function jf(){if(Jr)return new Promise(r=>{requestAnimationFrame(()=>r()),setTimeout(()=>r())});await Promise.resolve(),$d()}function h(r){var e=r.f,t=(e&2)!==0;if(n2?.add(r),je!==null&&!lo){var n=Fe!==null&&(Fe.f&16384)!==0;if(!n&&(Ca===null||!Ca.has(r))){var i=je.deps;if((je.f&2097152)!==0)r.rv<Nd&&(r.rv=Nd,Zn===null&&i!==null&&i[so]===r?so++:Zn===null?Zn=[r]:Zn.push(r));else{je.deps??(je.deps=[]),nu.call(je.deps,r)||je.deps.push(r);var o=r.reactions;o===null?r.reactions=[je]:nu.call(o,je)||o.push(je)}}}if(te){if(!lo&&Po&&qe===null&&il===null&&!Po.warned&&(Po.effect.f&2097152)===0&&!Po.effect_deps.has(r)){Po.warned=!0,cL(r.label);var s=ma("traced at");s&&console.warn(s)}if(gv.delete(r),pa&&!lo&&cv!==null&&je!==null&&cv.reaction===je){if(r.trace)r.trace();else if(s=ma("traced at"),s){var a=cv.entries.get(r);a===void 0&&(a={traces:[]},cv.entries.set(r,a));var l=a.traces[a.traces.length-1];s.stack!==l?.stack&&a.traces.push(s)}}}if(Xo&&ic.has(r))return ic.get(r);if(t){var c=r;if(Xo){var u=c.v;return((c.f&1024)===0&&c.reactions!==null||a2(c))&&(u=vv(c)),ic.set(c,u),u}var d=(c.f&512)===0&&!lo&&je!==null&&(rT||(je.f&512)!==0),f=(c.f&32768)===0;uu(c)&&(d&&(c.f|=512),EI(c)),d&&!f&&(TI(c),s2(c))}if(Jn?.has(r))return Jn.get(r);if((r.f&8388608)!==0)throw r.v;return r.v}function s2(r){if(r.f|=512,r.deps!==null)for(let e of r.deps)(e.reactions??(e.reactions=[])).push(r),(e.f&2)!==0&&(e.f&512)===0&&(TI(e),s2(e))}function a2(r){if(r.v===fr)return!0;if(r.deps===null)return!1;for(let e of r.deps)if(ic.has(e)||(e.f&2)!==0&&a2(e))return!0;return!1}function Ot(r){var e=lo;try{return lo=!0,r()}finally{lo=e}}function iT(r){if(!(typeof r!="object"||!r||r instanceof EventTarget)){if(Sn in r)nT(r);else if(!Array.isArray(r))for(let e in r){let t=r[e];typeof t=="object"&&t&&Sn in t&&nT(t)}}}function nT(r,e=new Set){if(typeof r=="object"&&r!==null&&!(r instanceof EventTarget)&&!e.has(r)){e.add(r),r instanceof Date&&r.getTime();for(let n in r)try{nT(r[n],e)}catch{}let t=iu(r);if(t!==Object.prototype&&t!==Array.prototype&&t!==Map.prototype&&t!==Set.prototype&&t!==Date.prototype){let n=_E(t);for(let i in n){let o=n[i].get;if(o)try{o.call(r)}catch{}}}}}var Ld=Symbol("events"),UI=new Set,oT=new Set;function c2(r,e,t,n={}){function i(o){if(n.capture||sT.call(e,o),!o.cancelBubble)return ks(()=>t?.call(this,o))}return r.startsWith("pointer")||r.startsWith("touch")||r==="wheel"?Br(()=>{e.addEventListener(r,i,n)}):e.addEventListener(r,i,n),i}function oc(r,e,t,n,i){var o={capture:n,passive:i},s=c2(r,e,t,o);(e===document.body||e===window||e===document||e instanceof HTMLMediaElement)&&Xn(()=>{e.removeEventListener(r,s,o)})}function De(r,e,t){(e[Ld]??(e[Ld]={}))[r]=t}function Et(r){for(var e=0;e<r.length;e++)UI.add(r[e]);for(var t of oT)t(r)}var l2=null;function sT(r){var e=this,t=e.ownerDocument,n=r.type,i=r.composedPath?.()||[],o=i[0]||r.target;l2=r;var s=0,a=l2===r&&r[Ld];if(a){var l=i.indexOf(a);if(l!==-1&&(e===document||e===window)){r[Ld]=e;return}var c=i.indexOf(e);if(c===-1)return;l<=c&&(s=l)}if(o=i[s]||r.target,o!==e){Oi(r,"currentTarget",{configurable:!0,get(){return o||t}});var u=je,d=Fe;Mn(null),Rn(null);try{for(var f,p=[];o!==null&&o!==e;){try{var m=o[Ld]?.[n];m!=null&&(!o.disabled||r.target===o)&&m.call(o,r)}catch(v){f?p.push(v):f=v}if(r.cancelBubble)break;s++,o=s<i.length?i[s]:null}if(f){for(let v of p)queueMicrotask(()=>{throw v});throw f}}finally{r[Ld]=e,delete r.currentTarget,Mn(u),Rn(d)}}}var tX=globalThis?.window?.trustedTypes&&globalThis.window.trustedTypes.createPolicy("svelte-trusted-html",{createHTML:r=>r});function u2(r){return tX?.createHTML(r)??r}function VI(r){var e=al("template");return e.innerHTML=u2(r.replaceAll("<!>","<!---->")),e.content}function Zo(r,e){var t=Fe;t.nodes===null&&(t.nodes={start:r,end:e,a:null,t:null})}function z(r,e){var t=(e&1)!==0,n=(e&2)!==0,i,o=!r.startsWith("<!>");return()=>{if(Re)return Zo(Ze,null),Ze;i===void 0&&(i=VI(o?r:"<!>"+r),t||(i=gi(i)));var s=n||dv?document.importNode(i,!0):i.cloneNode(!0);if(t){var a=gi(s),l=s.lastChild;Zo(a,l)}else Zo(s,s);return s}}function cl(r=""){if(!Re){var e=en(r+"");return Zo(e,e),e}var t=Ze;return t.nodeType!==wd?(t.before(t=en()),tr(t)):_v(t),Zo(t,t),t}function un(){if(Re)return Zo(Ze,null),Ze;var r=document.createDocumentFragment(),e=document.createComment(""),t=en();return r.append(e,t),Zo(e,t),r}function $(r,e){if(Re){var t=Fe;((t.f&32768)===0||t.nodes.end===null)&&(t.nodes.end=Ze),Yn();return}r!==null&&r.before(e)}function Av(){var r;if(Re&&Ze&&Ze.nodeType===jo&&Ze.textContent?.startsWith("$")){let e=Ze.textContent.substring(1);return Yn(),e}return(r=window.__svelte??(window.__svelte={})).uid??(r.uid=1),`c${window.__svelte.uid++}`}var aX=["allowfullscreen","async","autofocus","autoplay","checked","controls","default","disabled","formnovalidate","indeterminate","inert","ismap","loop","multiple","muted","nomodule","novalidate","open","playsinline","readonly","required","reversed","seamless","selected","webkitdirectory","defer","disablepictureinpicture","disableremoteplayback"];var jTe=[...aX,"formNoValidate","isMap","noModule","playsInline","readOnly","value","volume","defaultValue","defaultChecked","srcObject","noValidate","allowFullscreen","disablePictureInPicture","disableRemotePlayback"];var lX=["touchstart","touchmove"];function d2(r){return lX.includes(r)}var cX=["$state","$state.raw","$derived","$derived.by"],GTe=[...cX,"$state.eager","$state.snapshot","$props","$props.id","$bindable","$effect","$effect.pre","$effect.tracking","$effect.root","$effect.pending","$inspect","$inspect().with","$inspect.trace","$host"];var WI=!0;function me(r,e){var n;var t=e==null?"":typeof e=="object"?`${e}`:e;t!==(r[n=ov]??(r[n]=r.nodeValue))&&(r[ov]=t,r.nodeValue=`${t}`)}function Bd(r,e){return p2(r,e)}function HI(r,e){eT(),e.intro=e.intro??!1;let t=e.target,n=Re,i=Ze;try{for(var o=gi(t);o&&(o.nodeType!==jo||o.data!=="[");)o=hi(o);if(!o)throw Gl;Dn(!0),tr(o);let s=p2(r,{...e,anchor:o});return Dn(!1),s}catch(s){if(s instanceof Error&&s.message.split(`
|
||
`).some(a=>a.startsWith("https://svelte.dev/e/")))throw s;return s!==Gl&&console.warn("Failed to hydrate: ",s),e.recover===!1&&tL(),eT(),Df(t),Dn(!1),Bd(r,e)}finally{Dn(n),tr(i)}}var aT=new Map;function p2(r,{target:e,anchor:t,props:n={},events:i,context:o,intro:s=!0,transformError:a}){eT();var l=void 0,c=ZL(()=>{var u=t??e.appendChild(en());hv(u,{pending:()=>{}},p=>{we({});var m=_t;if(o&&(m.c=o),i&&(n.$$events=i),Re&&Zo(p,null),WI=s,l=r(p,n)||{},WI=!0,Re&&(Fe.nodes.end=Ze,Ze===null||Ze.nodeType!==jo||Ze.data!=="]"))throw Cd(),Gl;Ce()},a);var d=new Set,f=p=>{for(var m=0;m<p.length;m++){var v=p[m];if(!d.has(v)){d.add(v);var g=d2(v);for(let x of[e,document]){var y=aT.get(x);y===void 0&&(y=new Map,aT.set(x,y));var w=y.get(v);w===void 0?(x.addEventListener(v,sT,{passive:g}),y.set(v,1)):y.set(v,w+1)}}}};return f(Ef(UI)),oT.add(f),()=>{for(var p of d)for(let g of[e,document]){var m=aT.get(g),v=m.get(p);--v==0?(g.removeEventListener(p,sT),m.delete(p),m.size===0&&aT.delete(g)):m.set(p,v)}oT.delete(f),u!==t&&u.parentNode?.removeChild(u)}});return zI.set(l,c),l}var zI=new WeakMap;function Gf(r,e){let t=zI.get(r);return t?(zI.delete(r),t(e)):(te&&(Sn in r?hL():fL()),Promise.resolve())}var xa,ul,Jo,Ud,kv,Sv,lT,Ea=class{constructor(e,t=!0){le(this,"anchor");it(this,xa,new Map);it(this,ul,new Map);it(this,Jo,new Map);it(this,Ud,new Set);it(this,kv,!0);it(this,Sv,e=>{if(H(this,xa).has(e)){var t=H(this,xa).get(e),n=H(this,ul).get(t);if(n)Hf(n),H(this,Ud).delete(t);else{var i=H(this,Jo).get(t);i&&(Hf(i.effect),H(this,ul).set(t,i.effect),H(this,Jo).delete(t),te&&(i.fragment.lastChild[aI]=this.anchor),i.fragment.lastChild.remove(),this.anchor.before(i.fragment),n=i.effect)}for(let[o,s]of H(this,xa)){if(H(this,xa).delete(o),o===e)break;let a=H(this,Jo).get(s);a&&(Vr(a.effect),H(this,Jo).delete(s))}for(let[o,s]of H(this,ul)){if(o===t||H(this,Ud).has(o))continue;let a=()=>{if(Array.from(H(this,xa).values()).includes(o)){var c=document.createDocumentFragment();Pf(s,c),c.append(en()),H(this,Jo).set(o,{effect:s,fragment:c})}else Vr(s);H(this,Ud).delete(o),H(this,ul).delete(o)};H(this,kv)||!n?(H(this,Ud).add(o),nl(s,a,!1)):a()}}});it(this,lT,e=>{H(this,xa).delete(e);let t=Array.from(H(this,xa).values());for(let[n,i]of H(this,Jo))t.includes(n)||(Vr(i.effect),H(this,Jo).delete(n))});this.anchor=e,et(this,kv,t)}ensure(e,t){var n=qe,i=tT();if(t&&!H(this,ul).has(e)&&!H(this,Jo).has(e))if(i){var o=document.createDocumentFragment(),s=en();o.append(s),H(this,Jo).set(e,{effect:$n(()=>t(s)),fragment:o})}else H(this,ul).set(e,$n(()=>t(this.anchor)));if(H(this,xa).set(n,e),i){for(let[a,l]of H(this,ul))a===e?n.unskip_effect(l):n.skip_effect(l);for(let[a,l]of H(this,Jo))a===e?n.unskip_effect(l.effect):n.skip_effect(l.effect);n.oncommit(H(this,Sv)),n.ondiscard(H(this,lT))}else Re&&(this.anchor=Ze),H(this,Sv).call(this,n)}};xa=new WeakMap,ul=new WeakMap,Jo=new WeakMap,Ud=new WeakMap,kv=new WeakMap,Sv=new WeakMap,lT=new WeakMap;function Dv(r,e,...t){var n=new Ea(r);oo(()=>{let i=e()??null;te&&i==null&&rL(),n.ensure(i,i&&(o=>i(o,...t)))},65536)}if(te){let r=function(e){if(!(e in globalThis)){let t;Object.defineProperty(globalThis,e,{configurable:!0,get:()=>{if(t!==void 0)return t;iL(e)},set:n=>{t=n}})}};r("$state"),r("$effect"),r("$derived"),r("$inspect"),r("$props"),r("$bindable")}function cT(r){_t===null&&FE("onMount"),Kl&&_t.l!==null?pX(_t).m.push(r):hr(()=>{let e=Ot(r);if(typeof e=="function")return e})}function pX(r){var e=r.l;return e.u??(e.u={a:[],b:[],m:[]})}var h2=new Map;function g2(r,e){var t=h2.get(r);t||(t=new Set,h2.set(r,t)),t.add(e)}function ne(r,e,t=!1){var n;Re&&(n=Ze,Yn());var i=new Ea(r),o=t?65536:0;function s(a,l){if(Re){var c=av(n);if(a!==parseInt(c.substring(1))){var u=el();tr(u),i.anchor=u,Dn(!1),i.ensure(a,l),Dn(!0);return}}i.ensure(a,l)}oo(()=>{var a=!1;e((l,c=0)=>{a=!0,s(c,l)}),a||s(-1,null)},o)}var gX=Symbol("NaN");function jI(r,e,t){Re&&Yn();var n=new Ea(r),i=!ga();oo(()=>{var o=e();o!==o&&(o=gX),i&&o!==null&&typeof o=="object"&&(o={}),n.ensure(o,t)})}function Fv(r,e){return e}function CX(r,e,t){for(var n=[],i=e.length,o,s=e.length,a=0;a<i;a++){let d=e[a];nl(d,()=>{if(o){if(o.pending.delete(d),o.done.add(d),o.pending.size===0){var f=r.outrogroups;GI(r,Ef(o.done)),f.delete(o),f.size===0&&(r.outrogroups=null)}}else s-=1},!1)}if(s===0){var l=n.length===0&&t!==null;if(l){var c=t,u=c.parentNode;Df(u),u.append(c),r.items.clear()}GI(r,e,!l)}else o={pending:new Set(e),done:new Set},(r.outrogroups??(r.outrogroups=new Set)).add(o)}function GI(r,e,t=!0){var n;if(r.pending.size>0){n=new Set;for(let s of r.pending.values())for(let a of s)n.add(r.items.get(a).e)}for(var i=0;i<e.length;i++){var o=e[i];if(n?.has(o)){o.f|=33554432;let s=document.createDocumentFragment();Pf(o,s)}else Vr(e[i],t)}}var v2;function ar(r,e,t,n,i,o=null){var s=r,a=new Map,l=(e&4)!==0;if(l){var c=r;s=Re?tr(gi(c)):c.appendChild(en())}Re&&Yn();var u=null,d=Id(()=>{var x=t();return da(x)?x:x==null?[]:Ef(x)});te&&Ni(d,"{#each ...}");var f,p=new Map,m=!0;function v(x){(w.effect.f&16384)===0&&(w.pending.delete(x),w.fallback=u,xX(w,f,s,e,n),u!==null&&(f.length===0?(u.f&33554432)===0?Hf(u):(u.f^=33554432,Pv(u,null,s)):nl(u,()=>{u=null})))}function g(x){w.pending.delete(x)}var y=oo(()=>{f=h(d);var x=f.length;let C=!1;if(Re){var _=av(s)==="[!";_!==(x===0)&&(s=el(),tr(s),Dn(!1),C=!0)}for(var E=new Set,D=qe,P=tT(),V=0;V<x;V+=1){Re&&Ze.nodeType===jo&&Ze.data==="]"&&(s=Ze,C=!0,Dn(!1));var j=f[V],oe=n(j,V);if(te){var se=n(j,V);oe!==se&&XN(String(V),String(oe),String(se))}var M=m?null:a.get(oe);M?(M.v&&ba(M.v,j),M.i&&ba(M.i,V),P&&D.unskip_effect(M.e)):(M=EX(a,m?s:v2??(v2=en()),j,oe,V,i,e,t),m||(M.e.f|=33554432),a.set(oe,M)),E.add(oe)}if(x===0&&o&&!u&&(m?u=$n(()=>o(s)):(u=$n(()=>o(v2??(v2=en()))),u.f|=33554432)),x>E.size&&(te?TX(f,n):cI("","","")),Re&&x>0&&tr(el()),!m)if(p.set(D,E),P){for(let[U,q]of a)E.has(U)||D.skip_effect(q.e);D.oncommit(v),D.ondiscard(g)}else v(D);C&&Dn(!0),h(d)}),w={effect:y,flags:e,items:a,pending:p,outrogroups:null,fallback:u};m=!1,Re&&(s=Ze)}function Iv(r){for(;r!==null&&(r.f&32)===0;)r=r.next;return r}function xX(r,e,t,n,i){var o=(n&8)!==0,s=e.length,a=r.items,l=Iv(r.effect.first),c,u=null,d,f=[],p=[],m,v,g,y;if(o)for(y=0;y<s;y+=1)m=e[y],v=i(m,y),g=a.get(v).e,(g.f&33554432)===0&&(g.nodes?.a?.measure(),(d??(d=new Set)).add(g));for(y=0;y<s;y+=1){if(m=e[y],v=i(m,y),g=a.get(v).e,r.outrogroups!==null)for(let j of r.outrogroups)j.pending.delete(g),j.done.delete(g);if((g.f&8192)!==0&&(Hf(g),o&&(g.nodes?.a?.unfix(),(d??(d=new Set)).delete(g))),(g.f&33554432)!==0)if(g.f^=33554432,g===l)Pv(g,null,t);else{var w=u?u.next:l;g===r.effect.last&&(r.effect.last=g.prev),g.prev&&(g.prev.next=g.next),g.next&&(g.next.prev=g.prev),pu(r,u,g),pu(r,g,w),Pv(g,w,t),u=g,f=[],p=[],l=Iv(u.next);continue}if(g!==l){if(c!==void 0&&c.has(g)){if(f.length<p.length){var x=p[0],C;u=x.prev;var _=f[0],E=f[f.length-1];for(C=0;C<f.length;C+=1)Pv(f[C],x,t);for(C=0;C<p.length;C+=1)c.delete(p[C]);pu(r,_.prev,E.next),pu(r,u,_),pu(r,E,x),l=x,u=E,y-=1,f=[],p=[]}else c.delete(g),Pv(g,l,t),pu(r,g.prev,g.next),pu(r,g,u===null?r.effect.first:u.next),pu(r,u,g),u=g;continue}for(f=[],p=[];l!==null&&l!==g;)(c??(c=new Set)).add(l),p.push(l),l=Iv(l.next);if(l===null)continue}(g.f&33554432)===0&&f.push(g),u=g,l=Iv(g.next)}if(r.outrogroups!==null){for(let j of r.outrogroups)j.pending.size===0&&(GI(r,Ef(j.done)),r.outrogroups?.delete(j));r.outrogroups.size===0&&(r.outrogroups=null)}if(l!==null||c!==void 0){var D=[];if(c!==void 0)for(g of c)(g.f&8192)===0&&D.push(g);for(;l!==null;)(l.f&8192)===0&&l!==r.fallback&&D.push(l),l=Iv(l.next);var P=D.length;if(P>0){var V=(n&4)!==0&&s===0?t:null;if(o){for(y=0;y<P;y+=1)D[y].nodes?.a?.measure();for(y=0;y<P;y+=1)D[y].nodes?.a?.fix()}CX(r,D,V)}}o&&Br(()=>{if(d!==void 0)for(g of d)g.nodes?.a?.apply()})}function EX(r,e,t,n,i,o,s,a){var l=(s&1)!==0?(s&16)===0?Td(t,!1,!1):Ui(t):null,c=(s&2)!==0?Ui(i):null;return te&&l&&(l.trace=()=>{a()[c?.v??i]}),{v:l,i:c,e:$n(()=>(o(e,l??t,c??i,a),()=>{r.delete(n)}))}}function Pv(r,e,t){if(r.nodes)for(var n=r.nodes.start,i=r.nodes.end,o=e&&(e.f&33554432)===0?e.nodes.start:t;n!==null;){var s=hi(n);if(o.before(n),n===i)return;n=s}}function pu(r,e,t){e===null?r.effect.first=t:e.next=t,t===null?r.effect.last=e:t.prev=e}function TX(r,e){let t=new Map,n=r.length;for(let i=0;i<n;i++){let o=e(r[i],i);if(t.has(o)){let s=String(t.get(o)),a=String(i),l=String(o);l.startsWith("[object ")&&(l=null),cI(s,a,l)}t.set(o,i)}}var _X=TE?()=>performance.now():()=>Date.now(),Ta={tick:r=>(TE?requestAnimationFrame:Vt)(r),now:()=>_X(),tasks:new Set};function b2(){let r=Ta.now();Ta.tasks.forEach(e=>{e.c(r)||(Ta.tasks.delete(e),e.f())}),Ta.tasks.size!==0&&Ta.tick(b2)}function w2(r){let e;return Ta.tasks.size===0&&Ta.tick(b2),{promise:new Promise(t=>{Ta.tasks.add(e={c:r,f:t})}),abort(){Ta.tasks.delete(e)}}}function AX(r){if(r==="float")return"cssFloat";if(r==="offset")return"cssOffset";if(r.startsWith("--"))return r;let e=r.split("-");return e.length===1?e[0]:e[0]+e.slice(1).map(t=>t[0].toUpperCase()+t.slice(1)).join("")}function C2(r){let e={},t=r.split(";");for(let n of t){let[i,o]=n.split(":");if(!i||o===void 0)break;let s=AX(i.trim());e[s]=o.trim()}return e}var kX=r=>r,SX=null;function YI(r,e,t){var n=SX??Fe,i=n.nodes,o,s,a,l=null;i.a??(i.a={element:r,measure(){o=this.element.getBoundingClientRect()},apply(){if(a?.abort(),s=this.element.getBoundingClientRect(),o.left!==s.left||o.right!==s.right||o.top!==s.top||o.bottom!==s.bottom){let c=e()(this.element,{from:o,to:s},t?.());a=x2(this.element,c,void 0,1,()=>{},()=>{a?.abort(),a=void 0})}},fix(){if(!r.getAnimations().length){var{position:c,width:u,height:d}=getComputedStyle(r);if(c!=="absolute"&&c!=="fixed"){var f=r.style;l={position:f.position,width:f.width,height:f.height,transform:f.transform},f.position="absolute",f.width=u,f.height=d;var p=r.getBoundingClientRect();if(o.left!==p.left||o.top!==p.top){var m=`translate(${o.left-p.left}px, ${o.top-p.top}px)`;f.transform=f.transform?`${f.transform} ${m}`:m}}}},unfix(){if(l){var c=r.style;c.position=l.position,c.width=l.width,c.height=l.height,c.transform=l.transform}}}),i.a.element=r}function x2(r,e,t,n,i,o){var s=n===1;if(sI(e)){var a,l=!1;return Br(()=>{if(!l){var y=e({direction:s?"in":"out"});a=x2(r,y,t,n,i,o)}}),{abort:()=>{l=!0,a?.abort()},deactivate:()=>a.deactivate(),reset:()=>a.reset(),t:()=>a.t()}}if(t?.deactivate(),!e?.duration&&!e?.delay)return i(),o(),{abort:Vt,deactivate:Vt,reset:Vt,t:()=>n};let{delay:c=0,css:u,tick:d,easing:f=kX}=e;var p=[];if(s&&t===void 0&&(d&&d(0,1),u)){var m=C2(u(0,1));p.push(m,m)}var v=()=>1-n,g=r.animate(p,{duration:c,fill:"forwards"});return g.onfinish=()=>{g.cancel(),i();var y=t?.t()??1-n;t?.abort();var w=n-y,x=e.duration*Math.abs(w),C=[];if(x>0){var _=!1;if(u)for(var E=Math.ceil(x/16.666666666666668),D=0;D<=E;D+=1){var P=y+w*f(D/E),V=C2(u(P,1-P));C.push(V),_||(_=V.overflow==="hidden")}_&&(r.style.overflow="hidden"),v=()=>{var j=g.currentTime;return y+w*f(j/x)},d&&w2(()=>{if(g.playState!=="running")return!1;var j=v();return d(j,1-j),!0})}g=r.animate(C,{duration:x,fill:"forwards"}),g.onfinish=()=>{v=()=>n,d?.(n,1-n),o()}},{abort:()=>{g&&(g.cancel(),g.effect=null,g.onfinish=Vt)},deactivate:()=>{o=Vt},reset:()=>{n===0&&d?.(1,0)},t:()=>v()}}function ot(r,e){cn(()=>{var t=r.getRootNode(),n=t.host?t:t.head??t.ownerDocument.head;if(!n.querySelector("#"+e.hash)){let i=al("style");i.id=e.hash,i.textContent=e.code,n.appendChild(i),te&&g2(e.hash,i)}})}function Fr(r,e,t){cn(()=>{var n=Ot(()=>e(r,t?.())||{});if(t&&n?.update){var i=!1,o={};Qn(()=>{var s=t();iT(s),i&&$E(o,s)&&(o=s,n.update(s))}),i=!0}if(n?.destroy)return()=>n.destroy()})}var E2=[...`
|
||
\r\f\xA0\v\uFEFF`];function _2(r,e,t){var n=r==null?"":""+r;if(e&&(n=n?n+" "+e:e),t){for(var i of Object.keys(t))if(t[i])n=n?n+" "+i:i;else if(n.length)for(var o=i.length,s=0;(s=n.indexOf(i,s))>=0;){var a=s+o;(s===0||E2.includes(n[s-1]))&&(a===n.length||E2.includes(n[a]))?n=(s===0?"":n.substring(0,s))+n.substring(a+1):s=a}}return n===""?null:n}function T2(r,e=!1){var t=e?" !important;":";",n="";for(var i of Object.keys(r)){var o=r[i];o!=null&&o!==""&&(n+=" "+i+": "+o+t)}return n}function KI(r){return r[0]!=="-"||r[1]!=="-"?r.toLowerCase():r}function A2(r,e){if(e){var t="",n,i;if(Array.isArray(e)?(n=e[0],i=e[1]):n=e,r){r=String(r).replaceAll(/\s*\/\*.*?\*\/\s*/g,"").trim();var o=!1,s=0,a=!1,l=[];n&&l.push(...Object.keys(n).map(KI)),i&&l.push(...Object.keys(i).map(KI));var c=0,u=-1;let v=r.length;for(var d=0;d<v;d++){var f=r[d];if(a?f==="/"&&r[d-1]==="*"&&(a=!1):o?o===f&&(o=!1):f==="/"&&r[d+1]==="*"?a=!0:f==='"'||f==="'"?o=f:f==="("?s++:f===")"&&s--,!a&&o===!1&&s===0){if(f===":"&&u===-1)u=d;else if(f===";"||d===v-1){if(u!==-1){var p=KI(r.substring(c,u).trim());if(!l.includes(p)){f!==";"&&d++;var m=r.substring(c,d).trim();t+=" "+m+";"}}c=d+1,u=-1}}}}return n&&(t+=T2(n)),i&&(t+=T2(i,!0)),t=t.trim(),t===""?null:t}return r==null?null:String(r)}function wt(r,e,t,n,i,o){var s=r[nv];if(Re||s!==t||s===void 0){var a=_2(t,n,o);(!Re||a!==r.getAttribute("class"))&&(a==null?r.removeAttribute("class"):e?r.className=a:r.setAttribute("class",a)),r[nv]=t}else if(o&&i!==o)for(var l in o){var c=!!o[l];(i==null||c!==!!i[l])&&r.classList.toggle(l,c)}return o}function XI(r,e={},t,n){for(var i in t){var o=t[i];e[i]!==o&&(t[i]==null?r.style.removeProperty(i):r.style.setProperty(i,o,n))}}function Yf(r,e,t,n){var i=r[iv];if(Re||i!==e){var o=A2(e,n);(!Re||o!==r.getAttribute("style"))&&(o==null?r.removeAttribute("style"):r.style.cssText=o),r[iv]=e}else n&&(Array.isArray(n)?(XI(r,t?.[0],n[0]),XI(r,t?.[1],n[1],"important")):XI(r,t,n));return n}function fu(r,e,t=!1){if(r.multiple){if(e==null)return;if(!da(e))return mL();for(var n of r.options)n.selected=e.includes(Mv(n));return}for(n of r.options){var i=Mv(n);if($I(i,e)){n.selected=!0;return}}(!t||e!==void 0)&&(r.selectedIndex=-1)}function Vd(r){var e=new MutationObserver(()=>{"__value"in r&&fu(r,r.__value)});e.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["value"]}),Xn(()=>{e.disconnect()})}function QI(r,e,t=e){var n=new WeakSet,i=!0;WE(r,"change",o=>{var s=o?"[selected]":":checked",a;if(r.multiple)a=[].map.call(r.querySelectorAll(s),Mv);else{var l=r.querySelector(s)??r.querySelector("option:not([disabled])");a=l&&Mv(l)}t(a),r.__value=a,qe!==null&&n.add(qe)}),cn(()=>{var o=e();if(r===document.activeElement){var s=Jr?il:qe;if(n.has(s))return}if(fu(r,o,i),i&&o===void 0){var a=r.querySelector(":checked");a!==null&&(o=Mv(a),t(o))}r.__value=o,i=!1}),Vd(r)}function Mv(r){return"__value"in r?r.__value:r.value}var FX=Symbol("is custom element"),MX=Symbol("is html"),RX=PE?"link":"LINK";var $X=PE?"progress":"PROGRESS";function gr(r){if(Re){var e=!1,t=()=>{if(!e){if(e=!0,r.hasAttribute("value")){var n=r.value;ke(r,"value",null),r.value=n}if(r.hasAttribute("checked")){var i=r.checked;ke(r,"checked",null),r.checked=i}}};r[ou]=t,Br(t),qE()}}function Ps(r,e){var t=JI(r);t.value===(t.value=e??void 0)||r.value===e&&(e!==0||r.nodeName!==$X)||(r.value=e??"")}function qd(r,e){var t=JI(r);t.checked!==(t.checked=e??void 0)&&(r.checked=e)}function ke(r,e,t,n){var i=JI(r);if(Re&&(i[e]=r.getAttribute(e),e==="src"||e==="srcset"||e==="href"&&r.nodeName===RX)){n||NX(r,e,t??"");return}i[e]!==(i[e]=t)&&(e==="loading"&&(r[HN]=t),t==null?r.removeAttribute(e):typeof t!="string"&&OX(r).includes(e)?r[e]=t:r.setAttribute(e,t))}function JI(r){var e;return r[e=IE]??(r[e]={[FX]:r.nodeName.includes("-"),[MX]:r.namespaceURI===EE})}var k2=new Map;function OX(r){var e=r.getAttribute("is")||r.nodeName,t=k2.get(e);if(t)return t;k2.set(e,t=[]);for(var n,i=r,o=Element.prototype;o!==i;){n=_E(i);for(var s in n)n[s].set&&s!=="innerHTML"&&s!=="textContent"&&s!=="innerText"&&t.push(s);i=iu(i)}return t}function NX(r,e,t){te&&(e==="srcset"&&LX(r,t)||ZI(r.getAttribute(e)??"",t)||pL(e,r.outerHTML.replace(r.innerHTML,r.innerHTML&&"..."),String(t)))}function ZI(r,e){return r===e?!0:new URL(r,document.baseURI).href===new URL(e,document.baseURI).href}function S2(r){return r.split(",").map(e=>e.trim().split(" ").filter(Boolean))}function LX(r,e){var t=S2(r.srcset),n=S2(e);return n.length===t.length&&n.every(([i,o],s)=>o===t[s][1]&&(ZI(t[s][0],i)||ZI(i,t[s][0])))}function co(r,e,t=e){var n=new WeakSet;WE(r,"input",async i=>{te&&r.type==="checkbox"&&lI();var o=i?r.defaultValue:r.value;if(o=e0(r)?t0(o):o,t(o),qe!==null&&n.add(qe),await jf(),o!==(o=e())){var s=r.selectionStart,a=r.selectionEnd,l=r.value.length;if(r.value=o??"",a!==null){var c=r.value.length;s===a&&a===l&&c>l?(r.selectionStart=c,r.selectionEnd=c):(r.selectionStart=s,r.selectionEnd=Math.min(a,c))}}}),(Re&&r.defaultValue!==r.value||Ot(e)==null&&r.value)&&(t(e0(r)?t0(r.value):r.value),qe!==null&&n.add(qe)),Qn(()=>{te&&r.type==="checkbox"&&lI();var i=e();if(r===document.activeElement){var o=Jr?il:qe;if(n.has(o))return}e0(r)&&i===t0(r.value)||r.type==="date"&&!i&&!r.value||i!==r.value&&(r.value=i??"")})}function e0(r){var e=r.type;return e==="number"||e==="range"}function t0(r){return r===""?null:+r}function r0(r,e){return r===e||r?.[Sn]===e}function sc(r={},e,t,n){var i=_t.r,o=Fe;return cn(()=>{var s,a;return Qn(()=>{s=a,a=n?.()||[],Ot(()=>{r0(t(...a),r)||(e(r,...a),s&&r0(t(...s),r)&&e(null,...s))})}),()=>{let l=o;for(;l!==i&&l.parent!==null&&l.parent.f&33554432;)l=l.parent;let c=()=>{a&&r0(t(...a),r)&&e(null,...a)},u=l.teardown;l.teardown=()=>{c(),u?.()}}}),r}function he(r,e,t,n){var i=!Kl||(t&2)!==0,o=(t&8)!==0,s=(t&16)!==0,a=n,l=!0,c=void 0,u=()=>s&&i?(c??(c=lu(n)),h(c)):(l&&(l=!1,a=s?Ot(n):n),a);let d;if(o){var f=Sn in r||rv in r;d=Ao(r,e)?.set??(f&&e in r?C=>r[e]=C:void 0)}var p,m=!1;o?[p,m]=fI(()=>r[e]):p=r[e],p===void 0&&n!==void 0&&(p=u(),d&&(i&&nL(e),d(p)));var v;if(i?v=()=>{var C=r[e];return C===void 0?u():(l=!0,C)}:v=()=>{var C=r[e];return C!==void 0&&(a=void 0),C===void 0?a:C},i&&(t&4)===0)return v;if(d){var g=r.$$legacy;return(function(C,_){return arguments.length>0?((!i||!_||g||m)&&d(_?v():C),C):v()})}var y=!1,w=((t&1)!==0?lu:Id)(()=>(y=!1,v()));te&&(w.label=e),o&&h(w);var x=Fe;return(function(C,_){if(arguments.length>0){let E=_?h(w):i&&o?bt(C):C;return Z(w,E),y=!0,a!==void 0&&(a=E),C}return Xo&&y||(x.f&16384)!==0?w.v:h(w)})}function I2(r){return new i0(r)}var ac,Fs,i0=class{constructor(e){it(this,ac);it(this,Fs);var t=new Map,n=(o,s)=>{var a=Td(s,!1,!1);return t.set(o,a),a};let i=new Proxy({...e.props||{},$$events:{}},{get(o,s){return h(t.get(s)??n(s,Reflect.get(o,s)))},has(o,s){return s===rv?!0:(h(t.get(s)??n(s,Reflect.get(o,s))),Reflect.has(o,s))},set(o,s,a){return Z(t.get(s)??n(s,a),a),Reflect.set(o,s,a)}});et(this,Fs,(e.hydrate?HI:Bd)(e.component,{target:e.target,anchor:e.anchor,props:i,context:e.context,intro:e.intro??!1,recover:e.recover,transformError:e.transformError})),!Jr&&(!e?.props?.$$host||e.sync===!1)&&$d(),et(this,ac,i.$$events);for(let o of Object.keys(H(this,Fs)))o==="$set"||o==="$destroy"||o==="$on"||Oi(this,o,{get(){return H(this,Fs)[o]},set(s){H(this,Fs)[o]=s},enumerable:!0});H(this,Fs).$set=o=>{Object.assign(i,o)},H(this,Fs).$destroy=()=>{Gf(H(this,Fs))}}$set(e){H(this,Fs).$set(e)}$on(e,t){H(this,ac)[e]=H(this,ac)[e]||[];let n=(...i)=>t.call(this,...i);return H(this,ac)[e].push(n),()=>{H(this,ac)[e]=H(this,ac)[e].filter(i=>i!==n)}}$destroy(){H(this,Fs).$destroy()}};ac=new WeakMap,Fs=new WeakMap;var QX;typeof HTMLElement=="function"&&(QX=class extends HTMLElement{constructor(e,t,n){super();le(this,"$$ctor");le(this,"$$s");le(this,"$$c");le(this,"$$cn",!1);le(this,"$$d",{});le(this,"$$r",!1);le(this,"$$p_d",{});le(this,"$$l",{});le(this,"$$l_u",new Map);le(this,"$$me");le(this,"$$shadowRoot",null);this.$$ctor=e,this.$$s=t,n&&(this.$$shadowRoot=this.attachShadow(n))}addEventListener(e,t,n){if(this.$$l[e]=this.$$l[e]||[],this.$$l[e].push(t),this.$$c){let i=this.$$c.$on(e,t);this.$$l_u.set(t,i)}super.addEventListener(e,t,n)}removeEventListener(e,t,n){if(super.removeEventListener(e,t,n),this.$$c){let i=this.$$l_u.get(t);i&&(i(),this.$$l_u.delete(t))}}async connectedCallback(){if(this.$$cn=!0,!this.$$c){let e=function(i){return o=>{let s=al("slot");i!=="default"&&(s.name=i),$(o,s)}};if(await Promise.resolve(),!this.$$cn||this.$$c)return;let t={},n=ZX(this);for(let i of this.$$s)i in n&&(i==="default"&&!this.$$d.children?(this.$$d.children=e(i),t.default=!0):t[i]=e(i));for(let i of this.attributes){let o=this.$$g_p(i.name);o in this.$$d||(this.$$d[o]=o0(o,i.value,this.$$p_d,"toProp"))}for(let i in this.$$p_d)!(i in this.$$d)&&this[i]!==void 0&&(this.$$d[i]=this[i],delete this[i]);this.$$c=I2({component:this.$$ctor,target:this.$$shadowRoot||this,props:{...this.$$d,$$slots:t,$$host:this}}),this.$$me=LI(()=>{Qn(()=>{this.$$r=!0;for(let i of iI(this.$$c)){if(!this.$$p_d[i]?.reflect)continue;this.$$d[i]=this.$$c[i];let o=o0(i,this.$$d[i],this.$$p_d,"toAttribute");o==null?this.removeAttribute(this.$$p_d[i].attribute||i):this.setAttribute(this.$$p_d[i].attribute||i,o)}this.$$r=!1})});for(let i in this.$$l)for(let o of this.$$l[i]){let s=this.$$c.$on(i,o);this.$$l_u.set(o,s)}this.$$l={}}}attributeChangedCallback(e,t,n){this.$$r||(e=this.$$g_p(e),this.$$d[e]=o0(e,n,this.$$p_d,"toProp"),this.$$c?.$set({[e]:this.$$d[e]}))}disconnectedCallback(){this.$$cn=!1,Promise.resolve().then(()=>{!this.$$cn&&this.$$c&&(this.$$c.$destroy(),this.$$me(),this.$$c=void 0)})}$$g_p(e){return iI(this.$$p_d).find(t=>this.$$p_d[t].attribute===e||!this.$$p_d[t].attribute&&t.toLowerCase()===e)||e}});function o0(r,e,t,n){let i=t[r]?.type;if(e=i==="Boolean"&&typeof e!="boolean"?e!=null:e,!n||!t[r])return e;if(n==="toAttribute")switch(i){case"Object":case"Array":return e==null?null:JSON.stringify(e);case"Boolean":return e?"":null;case"Number":return e??null;default:return e}else switch(i){case"Object":case"Array":return e&&JSON.parse(e);case"Boolean":return e;case"Number":return e!=null?+e:e;default:return e}}function ZX(r){let e={};return r.childNodes.forEach(t=>{e[t.slot||"default"]=!0}),e}var og=require("obsidian");It();Me();var QG=require("obsidian");Tt();var Bv={location:"tab",direction:"vertical",mode:"default",focus:!0};function dn(r,e){if(!(e?.fillMissingOnly??!0))return{...Bv,...r??{}};let n={...r??{}};return n.location==null&&(n.location=Bv.location),n.direction==null&&(n.direction=Bv.direction),n.mode==null&&(n.mode=Bv.mode),n.focus==null&&(n.focus=Bv.focus),n}Cr();var fB=require("obsidian"),aQ=z('<span class="quickadd-icon svelte-1fiwm9k"></span>'),lQ={hash:"svelte-1fiwm9k",code:".quickadd-icon.svelte-1fiwm9k {display:inline-flex;align-items:center;}.quickadd-icon.svelte-1fiwm9k svg {display:inline-block;vertical-align:middle;}"};function Rt(r,e){we(e,!0),ot(r,lQ);let t=he(e,"size",3,16),n=Ae(void 0);hr(()=>{if(!h(n)||!e.iconId)return;(0,fB.setIcon)(h(n),e.iconId);let o=h(n).querySelector("svg");o&&(o.setAttribute("width",`${t()}`),o.setAttribute("height",`${t()}`))});var i=aQ();sc(i,o=>Z(n,o),()=>h(n)),$(r,i),Ce()}var cQ=z('<pre class="qaMountFailedDetail svelte-bhgeqn"> </pre>'),uQ=z(`<div class="qaMountFailed svelte-bhgeqn"><div class="qaMountFailedHead svelte-bhgeqn"><!> <span class="qaMountFailedTitle svelte-bhgeqn"> </span></div> <p class="qaMountFailedBody svelte-bhgeqn">This part of QuickAdd could not be drawn, so it has been left out. Nothing
|
||
was changed by the error. Include the message below if you report this.</p> <!></div>`),dQ={hash:"svelte-bhgeqn",code:".qaMountFailed.svelte-bhgeqn {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaMountFailedHead.svelte-bhgeqn {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaMountFailedTitle.svelte-bhgeqn {font-weight:var(--font-semibold);color:var(--text-normal);}.qaMountFailedBody.svelte-bhgeqn {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaMountFailedDetail.svelte-bhgeqn {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function y0(r,e){ot(r,dQ);let t=he(e,"detail",3,"");var n=uQ(),i=I(n),o=I(i);Rt(o,{iconId:"alert-triangle",size:16});var s=A(o,2),a=I(s);S(s),S(i);var l=A(i,4);{var c=u=>{var d=cQ(),f=I(d,!0);S(d),de(()=>me(f,t())),$(u,d)};ne(l,u=>{t()&&u(c)})}S(n),de(()=>me(a,`QuickAdd couldn't display ${e.what??""}`)),$(r,n)}var pQ="this part of QuickAdd";function qi(r,e,t,n={}){let i=new Set(r.childNodes),o;try{o=Bd(e,{target:r,props:t})}catch(a){return fQ(r,i,Yd(a),n)}let s=!1;return{ok:!0,destroy(){s||(s=!0,Gf(o))}}}function fQ(r,e,t,n){let i=n.what??pQ;for(let l of Array.from(r.childNodes))e.has(l)||l.remove();lt(t,`Couldn't display ${i}`);let o=r.ownerDocument.createElement("div");o.className="qa-mount-failed-host",r.appendChild(o);let s=null;try{s=Bd(n.fallbackComponent??y0,{target:o,props:{what:i,detail:t.message}})}catch{o.textContent=`QuickAdd couldn't display ${i}.`}let a=!1;return{ok:!1,destroy(){a||(a=!0,s&&Gf(s),o.remove())}}}var mB=require("obsidian");Tt();function tm(r){return r.trim().replace(/^\/+/,"")}function bu(r){return r.trim().toLowerCase().endsWith(".canvas")}function w0(r,e){let t=tm(e);if(!t||t.includes("{{"))return null;let n=r.vault.getAbstractFileByPath(t);return!n||!(n instanceof mB.TFile)||n.extension!=="canvas"?null:n}function hB(r,e){let n=r.workspace.getMostRecentLeaf?.()?.view;if(!n||n.getViewType?.()!=="canvas")return null;let i=tm(e),o=tm(n.file?.path??r.workspace.getActiveFile()?.path??"");if(!i||i!==o)return null;let s=n.canvas?.selection?Array.from(n.canvas.selection):[];if(s.length!==1)return null;let a=s[0]?.id;return typeof a=="string"&&a.length>0?a:null}function mQ(r){return typeof r=="string"?r:r&&typeof r=="object"&&"path"in r&&typeof r.path=="string"?r.path:"(missing file path)"}function hQ(r){return typeof r.x!="number"||typeof r.y!="number"||typeof r.width!="number"||typeof r.height!="number"?"":`${Math.round(r.x)},${Math.round(r.y)} \xB7 ${Math.round(r.width)}x${Math.round(r.height)}`}function b0(r,e){return r.length<=e?r:r.slice(0,e-1)+"\u2026"}async function gB(r,e){try{let t=await r.vault.cachedRead(e),n=JSON.parse(t);if(!n||typeof n!="object")return[];let i=n.nodes;if(!Array.isArray(i))return[];let o=i.filter(a=>!!a&&typeof a=="object"&&typeof a.id=="string").map(a=>{let l=a.type==="text"?"text":a.type==="file"?"file":"other",c=hQ(a);if(l==="text"){let m=(typeof a.text=="string"?a.text:"").split(`
|
||
`).map(w=>w.trim()).filter(w=>w.length>0),v=b0(m[0]??"(empty text card)",90),g=[`${m.length} line${m.length===1?"":"s"}`];c&&g.push(c);let y=g.join(" \xB7 ");return{id:a.id,type:l,title:v,subtitle:y,searchText:`${a.id} ${v} ${y}`.toLowerCase(),capturable:!0,capturableReason:""}}if(l==="file"){let p=mQ(a.file),m=ir.test(p),v=m?"":"Canvas file cards must link to markdown files (.md).",g=b0(p.split("/").pop()??p,90),y=[b0(p,120)];c&&y.push(c),m||y.push("Not capturable in this version");let w=y.join(" \xB7 ");return{id:a.id,type:l,title:g,subtitle:w,searchText:`${a.id} ${g} ${w}`.toLowerCase(),capturable:m,capturableReason:v}}let d=`Unsupported node (${typeof a.type=="string"&&a.type.length>0?a.type:"unknown"})`,f=c||"Type is not currently capturable";return{id:a.id,type:l,title:d,subtitle:f,searchText:`${a.id} ${d} ${f}`.toLowerCase(),capturable:!1,capturableReason:"This Canvas node type is not capturable."}}),s={text:0,file:1,other:2};return o.sort((a,l)=>{let c=s[a.type]-s[l.type];return c!==0?c:a.title.localeCompare(l.title)})}catch{return[]}}qt();function _u(r){return/\{\{[^}]*\}\}/.test(r)}fl();Fo();Wt();Tt();var YZ=["noteContent","captureTarget","fileName","lineTarget"],KZ=["captureTarget","fileName"],wi=YZ,jU=3;function Je(r,e,t=r.endsWith(":}}")?2:0){return{insert:r,description:e,caretOffset:t}}var XZ=[{regex:W2,contexts:wi,suggestion:Je("{{VALUE}}","Asks you for text when the choice runs")},{regex:z2,contexts:wi,suggestion:Je("{{VALUE:}}","Asks once and reuses the answer by name, or lists options to pick from"),expansions:()=>[Je("{{VALUE:title}}",'Asks once, then reuses the answer as "title"'),Je("{{VALUE:option1,option2,option3}}","Asks you to pick one of these options"),Je("{{VALUE:option1,option2,option3|custom}}","Same, but you can also type your own"),Je("{{VALUE:title|label:Note title}}","Words the prompt yourself"),Je("{{VALUE:option1,option2|label:Pick one}}","A list with your own prompt text"),Je("{{VALUE:title|label:Note title|default:Untitled}}","Opens the prompt with an answer already filled in"),Je("{{VALUE:<items>|text:<display items>}}","Shows one label in the list and inserts another"),Je("{{VALUE:option1,option2|name:category}}","Names the pick, so {{VALUE:category}} reuses it"),Je("{{VALUE:title|case:kebab}}","Reshapes the answer; type |case: for every style"),Je("{{VALUE:title|trim}}","Trims whitespace off the answer"),Je("{{VALUE:title|optional}}","Lets the prompt be skipped, leaving it empty")]},{regex:q2,contexts:wi,suggestion:Je("{{NAME}}","Another name for {{VALUE}}; they do the same thing")},{regex:H2,contexts:wi,suggestion:Je("{{VDATE:}}",'Asks you for a date; "tomorrow" works'),expansions:()=>[Je("{{VDATE:date,YYYY-MM-DD}}",'Asks for a date, reused by name as "date"'),Je("{{VDATE:date,YYYY-MM-DD|today}}","Same, with today filled in"),Je("{{VDATE:dueDate,YYYY-MM-DD|next monday}}","Same, starting at next Monday"),Je("{{VDATE:dueDate,YYYY-MM-DD|optional}}","Same, but skippable")]},{regex:Q2,contexts:wi,suggestion:Je("{{FIELD:}}","Suggests values a property already has in your vault, like {{FIELD:project}}")},{regex:X2,contexts:wi,suggestion:Je("{{FILE:}}","Picks a note from a folder"),expansions:({context:r})=>{let e=[Je("{{FILE:<folder>}}","Picks a note from that folder and inserts its name")];return KZ.includes(r)||e.push(Je("{{FILE:<folder>|link}}","Same, but inserts a link to the note"),Je("{{FILE:<folder>|path}}","Same, but inserts its full path"),Je("{{FILE:<folder>|optional}}","Same, but skippable")),e.push(Je("{{FILE:<folder>|custom}}","Same, but you can also type a name that is not there yet")),e}},{regex:eB,contexts:wi,suggestion:Je("{{MVALUE}}","Asks you for a math formula (LaTeX), with a live preview")},{regex:U2,contexts:wi,suggestion:Je("{{DATE}}","Today's date, as YYYY-MM-DD")},{regex:V2,contexts:wi,suggestion:Je("{{DATE:}}","Today's date in a format you choose, like {{DATE:MMMM Do}}"),expansions:({formatDate:r})=>[...["YYYY-MM-DD","MMMM Do, YYYY","ddd D MMM","gggg-[W]ww"].map(e=>Je(`{{DATE:${e}}}`,r(e))),Je("{{DATE+7}}","Seven days from today"),Je("{{DATE:YYYY-MM-DD|startof:week}}","Snapped to the start of the week, month, quarter or year")]},{regex:sB,contexts:wi,suggestion:Je("{{TIME}}","The current time, as HH:mm")},{regex:aB,contexts:wi,suggestion:Je("{{TIME:}}","The current time in a format you choose, like {{TIME:HH.mm}}")},{regex:j2,contexts:["noteContent","lineTarget"],suggestion:Je("{{LINKCURRENT}}","A link to that note: [[That note]]")},{regex:G2,contexts:["noteContent","lineTarget"],suggestion:Je("{{LINKSECTION}}","A link to the section your cursor is in")},{regex:Y2,contexts:["noteContent","captureTarget","fileName","lineTarget"],suggestion:Je("{{FILENAMECURRENT}}","That note's file name")},{regex:h0,contexts:["noteContent","captureTarget"],suggestion:Je("{{FOLDERCURRENT}}","That note's folder")},{regex:h0,contexts:["fileName"],suggestion:Je("{{FOLDERCURRENT|name}}","That note's folder name, without the path")},{regex:rB,contexts:wi,suggestion:Je("{{SELECTED}}","The text you had selected in the editor")},{regex:tB,contexts:["noteContent","lineTarget"],suggestion:Je("{{TITLE}}","The new note's file name")},{regex:K2,contexts:["fileName"],suggestion:Je("{{FOLDER|name}}","The name of the folder the new note lands in")},{regex:nB,contexts:wi,suggestion:Je("{{CLIPBOARD}}","Whatever you copied last")},{regex:Z2,contexts:wi,suggestion:Je("{{TEMPLATE:}}","The contents of a template file"),expansions:({templatePaths:r})=>r.map(e=>Je(`{{TEMPLATE:${e}}}`,"Inserts this template's contents"))},{regex:J2,contexts:wi,suggestion:Je("{{MACRO:}}","Whatever a macro returns"),expansions:({macroNames:r})=>[...r.map(e=>Je(`{{MACRO:${e}}}`,`Runs your "${e}" macro`)),Je("{{MACRO:MyMacro|label:Label}}","Word the macro's own prompt yourself")]},{regex:oB,contexts:wi,suggestion:Je("{{GLOBAL_VAR:}}","A snippet you defined in QuickAdd's settings"),expansions:({globalVariableNames:r})=>r.map(e=>Je(`{{GLOBAL_VAR:${e}}}`,`Inserts your "${e}" snippet`))},{regex:iB,contexts:wi,suggestion:Je("{{RANDOM:}}","A random ID of the length you give, like {{RANDOM:6}}")}],GU=[{insert:"kebab",description:"my-note-title",caretOffset:0,isFragment:!0},{insert:"snake",description:"my_note_title",caretOffset:0,isFragment:!0},{insert:"camel",description:"myNoteTitle",caretOffset:0,isFragment:!0},{insert:"pascal",description:"MyNoteTitle",caretOffset:0,isFragment:!0},{insert:"title",description:"My Note Title",caretOffset:0,isFragment:!0},{insert:"lower",description:"my note title",caretOffset:0,isFragment:!0},{insert:"upper",description:"MY NOTE TITLE",caretOffset:0,isFragment:!0},{insert:"slug",description:"my-note-title, guarded against reserved file names",caretOffset:0,isFragment:!0}];function YU(r){return XZ.filter(e=>e.contexts.includes(r))}var QZ=/^\{\{(?:VALUE|NAME)[^\n\r}]*\|case:([a-z-]*)$/i,ZZ=/<[^<>\n\r]+>/,Hi=class extends mn{constructor(t,n,i,o="noteContent"){super(t,n);this.app=t;this.inputEl=n;this.plugin=i;this.context=o;this.replaceFrom=0;this.matchedQuery="";this.macroNames=Bn(this.plugin.settings.choices).filter(s=>s.type==="Macro").map(s=>s.name),this.templatePaths=this.plugin.getTemplateFiles().map(s=>s.path)}getSuggestions(t){if(this.inputEl.selectionStart===null)return[];let n=this.inputEl.selectionStart,i=t.lastIndexOf("{{",n-1);if(i===-1)return[];let o=t.slice(i,n);if(o.includes("}}"))return[];let s=o.match(QZ);if(s){let m=s[1]??"";this.matchedQuery=m,this.replaceFrom=n-m.length;let v=m.toLowerCase();return GU.filter(g=>g.insert.startsWith(v)).map(g=>({...g}))}if(o.includes(":"))return[];let a=[],l=new Set,c=m=>{l.has(m.insert)||(l.add(m.insert),a.push(m))};this.replaceFrom=i,this.matchedQuery=o.slice(2);let u=YU(this.context).filter(m=>{let v=m.regex.exec(o);return v!==null&&v.index+v[0].length===o.length}),d=this.matchedQuery.toLowerCase(),f=m=>m.suggestion.insert.slice(2).toLowerCase().startsWith(d),p=[...u.filter(f),...u.filter(m=>!f(m))];for(let m of p)if(c(m.suggestion),!!m.expansions&&!(this.matchedQuery.length<jU))for(let v of m.expansions({templatePaths:this.templatePaths,macroNames:this.macroNames,globalVariableNames:Object.keys(this.plugin?.settings?.globalVariables??{}),context:this.context,formatDate:g=>typeof window.moment=="function"?window.moment().format(g):g}))c(v);return a}selectSuggestion(t){if(this.inputEl.selectionStart===null)return;let n=this.inputEl.selectionStart,i=this.replaceFrom;ZT(this.inputEl,i,n,t.insert,{fromCompletion:!0});let o=ZZ.exec(t.insert);if(o){let s=i+o.index;this.inputEl.setSelectionRange(s,s+o[0].length)}else if(t.caretOffset>0){let s=i+t.insert.length-t.caretOffset;this.inputEl.setSelectionRange(s,s)}this.close()}renderSuggestion(t,n){if(!t)return;n.classList.add("qa-format-suggestion");let i=n.ownerDocument.createElement("span");i.className=t.isFragment?"qa-format-suggestion-token qa-format-suggestion-token-fragment":"qa-format-suggestion-token",this.renderMatch(i,t.insert,this.matchedQuery),n.appendChild(i);let o=n.ownerDocument.createElement("span");o.className="qa-format-suggestion-description",o.textContent=t.description,n.appendChild(o)}};var JZ=z('<label class="setting-item-name"> </label>'),eJ=z('<div class="setting-item-name"> </div>'),tJ=z('<div class="setting-item-description"> </div>'),rJ=z('<div><div class="setting-item-info"><!> <!></div> <div class="setting-item-control"><!></div></div>');function $e(r,e){let t=he(e,"name",3,void 0),n=he(e,"desc",3,void 0),i=he(e,"heading",3,!1),o=he(e,"labelFor",3,void 0),s=he(e,"control",3,void 0),a=he(e,"children",3,void 0);var l=rJ();let c;var u=I(l),d=I(u);{var f=y=>{var w=un(),x=Pe(w);{var C=E=>{var D=JZ(),P=I(D,!0);S(D),de(()=>{ke(D,"for",o()),me(P,t())}),$(E,D)},_=E=>{var D=eJ(),P=I(D,!0);S(D),de(()=>me(P,t())),$(E,D)};ne(x,E=>{o()?E(C):E(_,-1)})}$(y,w)};ne(d,y=>{t()&&y(f)})}var p=A(d,2);{var m=y=>{var w=tJ(),x=I(w,!0);S(w),de(()=>me(x,n())),$(y,w)};ne(p,y=>{n()&&y(m)})}S(u);var v=A(u,2),g=I(v);Dv(g,()=>s()??a()??Vt),S(v),S(l),de(()=>c=wt(l,1,"setting-item",null,c,{"setting-item-heading":i()})),$(r,l)}var nJ=z('<div role="switch"><input type="checkbox" tabindex="-1" aria-hidden="true" class="svelte-1bigjf0"/></div>'),iJ={hash:"svelte-1bigjf0",code:`
|
||
/* Let clicks fall through to the container so a single handler owns toggling. */.checkbox-container.svelte-1bigjf0 > input:where(.svelte-1bigjf0) {pointer-events:none;}`};function lr(r,e){we(e,!0),ot(r,iJ);let t=he(e,"checked",15),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0),s=O(()=>t()??!1);function a(){n()||(t(!h(s)),o()?.(t()))}function l(f){(f.key==="Enter"||f.key===" ")&&(f.preventDefault(),a())}var c=nJ();let u;var d=I(c);gr(d),S(c),de(()=>{u=wt(c,1,"checkbox-container svelte-1bigjf0",null,u,{"is-enabled":h(s),"is-disabled":n()}),ke(c,"aria-checked",h(s)),ke(c,"aria-label",i()),ke(c,"tabindex",n()?-1:0),qd(d,h(s))}),De("click",c,a),De("keydown",c,l),$(r,c),Ce()}Et(["click","keydown"]);var oJ=z("<option> </option>"),sJ=z('<select class="dropdown"></select>');function Jt(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"disabled",3,!1),i=he(e,"ariaLabel",3,void 0),o=he(e,"onchange",3,void 0);var s=sJ();ar(s,21,()=>e.options,a=>a.value,(a,l)=>{var c=oJ(),u=I(c,!0);S(c);var d={};de(()=>{me(u,h(l).label),d!==(d=h(l).value)&&(c.value=(c.__value=h(l).value)??"")}),$(a,c)}),S(s),de(()=>{s.disabled=n(),ke(s,"aria-label",i())}),De("change",s,()=>o()?.(t())),QI(s,t),$(r,s),Ce()}Et(["change"]);zs();Me();Cr();function Sm(r){return r==="Multi"?"folder":"choice"}function gV(r){return r==="Multi"?"Folder":"Choice"}function oee(r){return`${gV(r)} name`}async function g_(r,e,t){try{let i=(await Sr.Prompt(r,oee(t),void 0,e)).trim();return!i||i===e?null:i}catch(n){return Dt(n)||F.logError(Yd(n,"Could not rename")),null}}var see=z('<h2 class="choiceNameHeader"><button type="button" class="choiceNameHeaderButton qa-rename-title-button"><span class="choiceNameHeaderText"> </span> <span class="choiceNameHeaderIcon" aria-hidden="true"><!></span></button></h2>');function py(r,e){we(e,!0);let t=he(e,"name",15);async function n(){let u=await g_(e.app,t());u&&t(u)}var i=see(),o=I(i),s=I(o),a=I(s,!0);S(s);var l=A(s,2),c=I(l);Rt(c,{iconId:"pencil",size:16}),S(l),S(o),S(i),de(()=>{ke(o,"aria-label",`Rename ${t()}`),me(a,t())}),De("click",o,n),$(r,i),Ce()}Et(["click"]);fl();Fo();var ni=class extends mn{constructor(t,n,i,o=1/0){super(t,n);this.app=t;this.inputEl=n;this.items=i;this.maxSuggestions=o;this.items=i.map(s=>fn(s))}getSuggestions(t){let n=Cc(t).toLowerCase(),i=this.items.filter(s=>s.toLowerCase().includes(n));return i.length===0&&this.close(),i.slice(0,this.maxSuggestions)}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){if(!t)return;let i=sy(t),o=sy(this.getCurrentQuery());t.toLowerCase().endsWith(".md")&&o.toLowerCase().startsWith(`${i.toLowerCase()}.`)&&(o=i),this.renderMatch(n,i,o)}getCurrentQuery(){return this.inputEl.value}};function aee(r){return r?Array.isArray(r)?r:[r]:[]}function hp(r,e){let t=aee(e(r));return{destroy(){t.forEach(n=>n.destroy())}}}var lee=z("<textarea></textarea>"),cee=z('<input type="text"/>'),uee=z('<!> <div aria-live="polite"> </div>',1);function Ci(r,e){we(e,!0);let t=he(e,"value",15,""),n=he(e,"placeholder",3,void 0),i=he(e,"inputKind",3,"text"),o=he(e,"required",3,!1),s=he(e,"requiredMessage",3,"This field is required"),a=he(e,"disabled",3,!1),l=he(e,"validator",3,void 0),c=he(e,"trim",3,!0),u=he(e,"suggestions",3,void 0),d=he(e,"maxSuggestions",3,1/0),f=he(e,"makeSuggesters",19,()=>[]),p=he(e,"app",3,void 0),m=he(e,"id",3,void 0),v=he(e,"ariaLabel",3,void 0),g=he(e,"onChange",3,void 0),y=Ae(!1),w=Ae(""),x=Ae("neutral"),C=0,_=!1,E=`qa-hint-${Math.random().toString(36).slice(2)}`,D=Y=>c()?Y.trim():Y;function P(Y,X=!1,ae="neutral"){Z(y,X,!0),Z(w,Y??"",!0),Z(x,X?"neutral":ae,!0)}async function V(Y){if(o()&&D(Y).length===0)return P(s(),!0),!1;if(!l())return P(void 0),!0;let X=++C,ae=await Promise.resolve(l()(Y));return X!==C||_?!0:typeof ae=="boolean"?(P(ae?void 0:"Invalid value",!ae),ae):typeof ae=="string"?(P(ae,!0),!1):(P(ae.message??(ae.valid?void 0:"Invalid value"),!ae.valid,ae.valid?ae.variant??"neutral":"neutral"),ae.valid)}function j(Y){let X=Y.currentTarget.value;t(X),g()?.(X)}hr(()=>{o();let Y=t();V(Y)}),hr(()=>()=>{_=!0});function oe(Y){let X=[];p()&&u()&&u().length&&X.push(new ni(p(),Y,u(),d()));for(let ae of f()){let pe=ae(Y);pe&&X.push(pe)}return X}var se=uee(),M=Pe(se);{var U=Y=>{var X=lee();Ad(X);let ae;Fr(X,(pe,ge)=>hp?.(pe,ge),()=>oe),de(()=>{ae=wt(X,1,"qa-validated-input-full-width qa-validated-input-margin-8 qa-validated-input-textarea",null,ae,{"is-invalid":h(y),"is-valid":!h(y)&&h(x)==="success"&&h(w).length>0}),ke(X,"id",m()),ke(X,"placeholder",n()),X.disabled=a(),ke(X,"aria-label",v()),ke(X,"aria-invalid",h(y)),ke(X,"aria-describedby",E),Ps(X,t())}),De("input",X,j),$(Y,X)},q=Y=>{var X=cee();gr(X);let ae;Fr(X,(pe,ge)=>hp?.(pe,ge),()=>oe),de(()=>{ae=wt(X,1,"qa-validated-input-full-width qa-validated-input-margin-8",null,ae,{"is-invalid":h(y),"is-valid":!h(y)&&h(x)==="success"&&h(w).length>0}),ke(X,"id",m()),ke(X,"placeholder",n()),X.disabled=a(),ke(X,"aria-label",v()),ke(X,"aria-invalid",h(y)),ke(X,"aria-describedby",E),Ps(X,t())}),De("input",X,j),$(Y,X)};ne(M,Y=>{i()==="textarea"?Y(U):Y(q,-1)})}var B=A(M,2);let ie;var W=I(B,!0);S(B),de(()=>{ie=wt(B,1,"qa-field-hint",null,ie,{"qa-field-hint--neutral":!h(y)&&h(x)==="neutral","qa-field-hint--success":!h(y)&&h(x)==="success"}),ke(B,"id",E),me(W,h(w))}),$(r,se),Ce()}Et(["input"]);var dee=z('<div class="qa-field-body"><!></div>'),pee=z('<div class="qa-field"><!> <!></div>');function ss(r,e){let t=Av(),n=he(e,"desc",3,void 0),i=he(e,"control",3,void 0),o=he(e,"bodyVisible",3,!0);var s=pee(),a=I(s);{let u=O(()=>o()?t:void 0);$e(a,{get name(){return e.name},get desc(){return n()},get control(){return i()},get labelFor(){return h(u)}})}var l=A(a,2);{var c=u=>{var d=dee(),f=I(d);Dv(f,()=>e.children,()=>t),S(d),$(u,d)};ne(l,u=>{o()&&u(c)})}S(s),$(r,s)}$m();Cr();var Nu=class{constructor(){this.entries=[];this.seen=new Set}add(e,t,n){let i=ite(t).trim();if(!i)return;let o=`${e} ${i}`;this.seen.has(o)||(this.seen.add(o),this.entries.push({severity:e,message:i,...n?{kind:n}:{}}))}list(){return this.entries}get hasError(){return this.entries.some(e=>e.severity==="error")}};function ite(r){return r.replace(/^\[(QuickAdd:[\s\S]*)\]$/i,"$1").replace(/^QuickAdd:\s*/i,"")}function Om(r){if(Dt(r))return null;if(!(r instanceof Error))return QV;let e=r.message??"";return Dt(e)?null:e.startsWith("Unable to parse variable")?"This token is incomplete. {{VALUE:}} needs a name, for example {{VALUE:title}}.":e.trim()?e:QV}var QV="Preview unavailable - this format could not be resolved.";MT();Tt();uh();Tl();var _ae={title:"My Document Title",name:"Document Name",project:"Project Alpha",category:"Notes",author:"Your Name",status:"Draft",priority:"High",tag:"important",type:"meeting",client:"Acme Corp"},Aae={clipboard:"clipboard_content",date:"formatted_date",time:"current_time",random:"random_value",uuid:"unique_id"},kae=[{pattern:/date|time/i,example:"2024-01-15"},{pattern:/title|name/i,example:"Example Title"},{pattern:/tag/i,example:"important"},{pattern:/category|type/i,example:"Notes"},{pattern:/author|user/i,example:"Your Name"},{pattern:/project/i,example:"Project Alpha"},{pattern:/status/i,example:"In Progress"},{pattern:/priority/i,example:"High"},{pattern:/number|count|id/i,example:"001"}];function xA(r){let e=r.toLowerCase(),t=_ae[e];return t||`${r}_example`}function EA(r){return Aae[r.toLowerCase()]||`${r}_output`}function TA(r){for(let{pattern:e,example:t}of kae)if(e.test(r))return t;return`${r}_value`}function _A(r){return r.length>0?`${r[0]} (${r.length} options)`:"suggestion_list"}function dh(r,e){return Vp(r).length>0?e:r}function AA(r){let e=r.fieldName.trim();return e?`${e}_field_value`:"field_value"}function kA(r){return r?.path?r.basename:"current_file"}function ph(r){return`${r?.path?r.basename:"current_file"}#Section`}function SA(r){return r?.basename||"current_filename"}function DA(r){if(!r)return"current_folder";let e=r.parent?.path??"";return e==="/"?"":e}var _l=class{static generate(e,t=new Date){let n=t.getFullYear(),i=this.getWeekNumber(t),o=[["YYYY",n.toString()],["YY",n.toString().slice(-2)],["MMMM",this.MONTH_NAMES[t.getMonth()]],["MMM",this.MONTH_NAMES_SHORT[t.getMonth()]],["MM",(t.getMonth()+1).toString().padStart(2,"0")],["M",(t.getMonth()+1).toString()],["dddd",this.DAY_NAMES[t.getDay()]],["ddd",this.DAY_NAMES_SHORT[t.getDay()]],["DD",t.getDate().toString().padStart(2,"0")],["D",t.getDate().toString()],["HH",t.getHours().toString().padStart(2,"0")],["H",t.getHours().toString()],["mm",t.getMinutes().toString().padStart(2,"0")],["m",t.getMinutes().toString()],["ss",t.getSeconds().toString().padStart(2,"0")],["s",t.getSeconds().toString()],["ww",i.toString().padStart(2,"0")],["w",i.toString()]],s="",a=0;for(;a<e.length;){let l=!1;for(let[c,u]of o)if(e.startsWith(c,a)){s+=u,a+=c.length,l=!0;break}l||(s+=e[a],a+=1)}return s}static getWeekNumber(e){let t=new Date(e.getFullYear(),0,1),n=(e.getTime()-t.getTime())/864e5;return Math.ceil((n+t.getDay()+1)/7)}};_l.MONTH_NAMES=["January","February","March","April","May","June","July","August","September","October","November","December"],_l.MONTH_NAMES_SHORT=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],_l.DAY_NAMES=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],_l.DAY_NAMES_SHORT=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];vl();_y();Qv();function IA(r){let e=new Date;return r?lm(window.moment(e),r).toDate():e}ip();Hs();var fh=class extends yl{constructor(t,n,i,o={}){super(t);this.plugin=n;this.opts=o;this.diagnostics=new Nu;this.dateParser=i||El}warn(t){this.diagnostics.add("warning",t)}reportProblem(t){this.diagnostics.add("error",t)}async format(t){this.diagnostics=new Nu;try{return await this.formatInternal(t,{expandLinebreakEscapes:!0})}catch(n){let i=Om(n);return i&&this.diagnostics.add("error",i),t}}async formatInternal(t,{expandLinebreakEscapes:n}){let i=t;return i=await this.replaceGlobalVarInString(i),n&&(i=this.expandLinebreakEscapesOutsideTokens(i)),i=this.replaceDateInString(i),i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=this.replaceCurrentFileTokensInString(i,{links:!0,fileName:!0,folder:!0,...this.opts.resolveActiveFolder===!1?{}:{activeFolder:"content"}}),i=await this.replaceMacrosInString(i),i=await this.replaceTemplateInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),i=this.replaceRandomInString(i),i}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}promptForValue(t){return t||"user input"}getVariableValue(t){let n=this.variables.get(t);if(typeof n=="string")return n;let i=Cy(t);return xA(i)}getCurrentFileLink(){return this.app?kA(this.app.workspace.getActiveFile()):null}getCurrentFileLinkToSection(){return this.app?ph(this.app.workspace.getActiveFile()):ph(null)}getCurrentFileName(){return this.app?SA(this.app.workspace.getActiveFile()):"current_filename"}getCurrentFolderPath(){return this.app?DA(this.app.workspace.getActiveFile()):"current_folder"}suggestForValue(t,n=!1,i){return _A(i?.displayValues??t)}getMacroValue(t,n){return EA(t)}promptForMathValue(){return Promise.resolve("calculation_result")}promptForVariable(t,n){return Promise.resolve(TA(t))}async getTemplateContent(t){let n=this.app;if(!n)return this.reportProblem(`Template preview unavailable: ${t}`),`[QuickAdd: template preview unavailable] ${t}`;let i=po(n,t);if(!i)return this.reportProblem(`Template not found: ${t}`),`[QuickAdd: template not found] ${t}`;this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.depth++;try{return await this.formatInternal(await n.vault.cachedRead(i),{expandLinebreakEscapes:!1})}catch(o){let s=Om(o);return s&&this.diagnostics.add("error",s),`[QuickAdd: template preview failed] ${t}`}finally{this.templateInclusion.depth--}}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(t,n){return Promise.resolve(AA(n))}suggestForFile(t){let n=this.app?zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,i=>this.app.metadataCache.getFileCache(i)):[];return n.length>0?`${gl}${n[0].path}`:`${as}${t.folderPath||"file"}`}async replaceDateVariableInString(t){let n=t;return n=n.replace(new RegExp(gu.source,"gi"),(i,o,s,a)=>{let l=o?.trim(),{options:c,error:u}=V_(a);u&&this.reportProblem(u);let{defaultValue:d,optional:f,withTime:p,snap:m}=c,v=s?.trim()||ky(p);if(!l)return i;let g=Sy(this.variables.get(l),v,m,this.dateParser);if(g)return g.text;let y;try{y=_l.generate(v,IA(m))}catch{y=`[${v} format]`}return d&&(y+=` (default: ${d})`),f&&(y+=" (optional)"),y}),n}replaceRandomInString(t){let n=t;return n=n.replace(/{{RANDOM:(\d+)}}/gi,(i,o)=>{let s=parseInt(o);if(s<=0||s>100)return i;let a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",l="";for(let c=0;c<Math.min(s,8);c++)l+=a.charAt(Math.floor(Math.random()*a.length));return s>8&&(l+=`... (${s} chars)`),l}),n}isTemplatePropertyTypesEnabled(){return!1}};$m();_y();var mh=require("obsidian");Tt();uh();Tl();MT();vl();ip();Hs();var mj=25;function Sae(r){let e=r.lastIndexOf("{{");return e===-1?!1:r.indexOf("}}",e+2)===-1}function Dae(r){let e=Ay(r);if(e.length===0)return r;let t="",n=0;for(let i of e)t+=r.slice(n,i.start),n=i.end;return t+r.slice(n)}var hh=class extends yl{constructor(t,n,i){super(t);this.plugin=n;this.diagnostics=new Nu;this.templateIncludeBudget=mj;this.dateParser=i||El}warn(t){this.diagnostics.add("warning",t)}reportProblem(t){this.diagnostics.add("error",t)}async format(t){let n=t;this.diagnostics=new Nu,this.templateIncludeBudget=mj;try{n=await this.formatInternal(t,{included:!1})}catch(o){let s=Om(o);return s&&this.diagnostics.add("error",s),t}this.reportCircularTitle(t,n);let i=pj(n);for(let o of i.problems)this.diagnostics.add("error",o,"path");return this.reportIllegalChars(t,n),i.path}reportCircularTitle(t,n){!$s.test(t)&&!$s.test(n)||this.reportProblem("A file name cannot contain {{title}}, because the title is derived from the file name itself - so this choice would fail at run time.")}reportIllegalChars(t,n){if(this.diagnostics.hasError||Sae(t)||XV(t))return;let i=Vp(Dae(n));i.length!==0&&(this.existsInVault(n)||this.diagnostics.add("error",lj(i),"path"))}existsInVault(t){let n=this.app?.vault;if(typeof n?.getAbstractFileByPath!="function")return!1;let i=t.trim();return i?i.endsWith("/")?n.getAbstractFileByPath(i.slice(0,-1))instanceof mh.TFolder:n.getAbstractFileByPath(i)instanceof mh.TFile||n.getAbstractFileByPath(`${i}.md`)instanceof mh.TFile?!0:n.getAbstractFileByPath(i)instanceof mh.TFolder:!1}async formatInternal(t,{included:n}){let i=t;return i=await this.replaceTemplateOutsideScripts(i),i=await this.replaceGlobalVarInString(i),i=await this.replaceMacrosInString(i),i=this.replaceDateInString(i),i=this.replaceTimeInString(i),i=await this.replaceValueInString(i),i=await this.replaceSelectedInString(i),i=await this.replaceClipboardInString(i),i=await this.replaceDateVariableInString(i),i=await this.replaceVariableInString(i),i=await this.replaceFieldVarInString(i),i=await this.replaceFileInString(i),i=await this.replaceMathValueInString(i),i=this.replaceCurrentFileTokensInString(i,n?{links:!0,fileName:!0,folder:!0,activeFolder:"content"}:{fileName:!0,folder:!0,activeFolder:"path"}),i=this.replaceRandomInString(i),i}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}promptForValue(t){return dh(t||"user input","user input")}getVariableValue(t){let n=this.variables.get(t);if(typeof n=="string")return n;let i=Cy(t);return dh(xA(i),"user input")}getCurrentFileLink(){return this.app?kA(this.app.workspace.getActiveFile()):null}getCurrentFileName(){return this.app?SA(this.app.workspace.getActiveFile()):"current_filename"}getCurrentFolderPath(){return this.app?DA(this.app.workspace.getActiveFile()):"current_folder"}suggestForValue(t,n=!1,i){return t[0]??_A(t)}promptForMathValue(){return Promise.resolve("calculation_result")}getMacroValue(t,n){return dh(EA(t),"macro_output")}async promptForVariable(t,n){return dh(TA(t),"user input")}async replaceTemplateOutsideScripts(t){let n=Ay(t);if(n.length===0)return this.replaceTemplateInString(t);let i="",o=0;for(let s of n)i+=await this.replaceTemplateInString(t.slice(o,s.start)),i+=t.slice(s.start,s.end),o=s.end;return i+await this.replaceTemplateInString(t.slice(o))}async getTemplateContent(t){let n=this.app;if(!n)return this.reportProblem(`Template preview unavailable: ${t}`),`[QuickAdd: template preview unavailable] ${t}`;if(this.templateIncludeBudget<=0){let o="[QuickAdd: too many template includes to preview]";return this.reportProblem(o),o}let i=po(n,t);if(!i)return this.reportProblem(`Template not found: ${t}`),`[QuickAdd: template not found] ${t}`;this.templateIncludeBudget--,this.templateInclusion??(this.templateInclusion={visited:new Set,depth:0}),this.templateInclusion.depth++;try{let o=await n.vault.cachedRead(i),s=this.resolveTitleInIncludedBody(await this.formatInternal(o,{included:!0}));return this.warnIfJoinedIntoOneLine(t,s),s}catch(o){let s=Om(o);return s&&this.diagnostics.add("error",s),`[QuickAdd: template preview failed] ${t}`}finally{this.templateInclusion.depth--}}resolveTitleInIncludedBody(t){if(!$s.test(t))return t;let n=this.variables.get("title"),i=typeof n=="string"?n:"";return t.replace(new RegExp($s.source,"gi"),()=>i)}warnIfJoinedIntoOneLine(t,n){let i=n.split(/\r?\n/).filter(o=>o.trim());i.length<2||this.warn(`Template "${t}" is ${i.length} lines; a file name is one line, so they are joined with spaces.`)}getCurrentFileLinkToSection(){return this.app?ph(this.app.workspace.getActiveFile()):ph(null)}async getSelectedText(){return"selected_text"}async getClipboardContent(){return"clipboard_content"}async suggestForField(t,n){return dh(AA(n),"field_value")}suggestForFile(t){let n=this.app?zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,i=>this.app.metadataCache.getFileCache(i)):[];return n.length>0?`${gl}${n[0].path}`:`${as}${t.folderPath||"file"}`}async replaceDateVariableInString(t){let n=t;return n=n.replace(new RegExp(gu.source,"gi"),(i,o,s,a)=>{let l=o?.trim();if(!l)return i;let{options:c,error:u}=V_(a);u&&this.reportProblem(u);let{withTime:d,snap:f}=c,p=s?.trim()||ky(d),m=Sy(this.variables.get(l),p,f,this.dateParser);if(m)return m.text;try{return _l.generate(p,IA(f))}catch{return`[${p}]`}}),n}replaceRandomInString(t){let n=t;return n=n.replace(/{{RANDOM:(\d+)}}/gi,(i,o)=>{let s=parseInt(o);if(s<=0||s>100)return i;let a="ABC123",l="";for(let c=0;c<Math.min(s,6);c++)l+=a.charAt(c%a.length);return s>6&&(l+="..."),l}),n}isTemplatePropertyTypesEnabled(){return!1}};var Iae=z('<div><span class="qa-visually-hidden"> </span> </div>'),Pae=z('<div class="qa-preview-issues"></div>'),Fae=z('<div><span class="qa-preview-label"> </span><span class="qa-preview-value" aria-live="polite"> </span></div> <!>',1);function hs(r,e){we(e,!0);let t=he(e,"formatterKind",3,"format"),n=500,i=Ae(""),o=Ae(bt([])),s=Ae(!1),a=0,l=O(()=>e.value.trim().length>0),c=O(()=>e.hideWhen?e.hideWhen(h(i))&&!h(o).some(g=>g.severity==="error"&&g.kind!=="path"):!1),u=O(()=>h(s)?h(o).filter(g=>g.severity==="error"):[]),d=O(()=>h(u).some(g=>g.kind!=="path")),f=O(()=>!h(d)&&h(u).length>0);hr(()=>{let g=e.value;if(!g.trim()){a++,Z(i,""),Z(o,[],!0);return}let y=t()==="fileName"?new hh(e.app,e.plugin):new fh(e.app,e.plugin,void 0,{resolveActiveFolder:t()!=="lineTarget"});y.setTargetFolderPath(e.targetFolderPath===null?null:e.targetFolderPath?.trim()?e.targetFolderPath:"Folder/Name");let w=++a;(async()=>{try{let x=await y.format(g);if(w!==a)return;Z(i,x,!0),Z(o,y.diagnostics.list(),!0)}catch{if(w!==a)return;Z(i,g,!0),Z(o,[{severity:"error",message:"Preview unavailable."}],!0)}})()}),hr(()=>{e.value,Z(s,!1);let g=setTimeout(()=>{Z(s,!0)},n);return()=>clearTimeout(g)});var p=un(),m=Pe(p);{var v=g=>{var y=Fae(),w=Pe(y);let x;var C=I(w),_=I(C,!0);S(C);var E=A(C),D=I(E,!0);S(E),S(w);var P=A(w,2);{var V=j=>{var oe=Pae();ar(oe,21,()=>h(o),se=>se.severity+se.message,(se,M)=>{var U=Iae();let q;var B=I(U),ie=I(B,!0);S(B);var W=A(B,1,!0);S(U),de(()=>{q=wt(U,1,"qa-preview-issue",null,q,{"qa-preview-issue--error":h(M).severity==="error"}),ke(U,"title",h(M).message),me(ie,h(M).severity==="error"?"Error: ":"Warning: "),me(W,h(M).message)}),$(se,U)}),S(oe),$(j,oe)};ne(P,j=>{h(s)&&h(o).length>0&&j(V)})}de(()=>{x=wt(w,1,"qa-preview-row",null,x,{"qa-preview-row--one-line":t()==="fileName"}),ke(w,"title",t()==="fileName"?h(i):void 0),me(_,h(d)?"Unresolved: ":h(f)?"Won't be created: ":"Preview: "),me(D,h(i))}),$(g,y)};ne(m,g=>{h(l)&&!h(c)&&g(v)})}$(r,p),Ce()}fc();Me();var WC="https://quickadd.obsidian.guide",Al={gettingStarted:`${WC}/docs/`,formatSyntax:`${WC}/docs/FormatSyntax/`,onePageInputs:`${WC}/docs/Advanced/onePageInputs/`,userScripts:`${WC}/docs/Choices/MacroChoice/#user-scripts`,packages:`${WC}/docs/Choices/Packages/`};function hj(r,e){try{(e?ep(e):window).open(r,"_blank","noopener,noreferrer")}catch(t){F.logError(`QuickAdd: Failed to open documentation (${r}): ${t}`)}}function PA(r,e,t){let n=zr(r,"a");return n.textContent=t,n.href=e,n.target="_blank",n.rel="noopener noreferrer",n.classList.add("quickadd-docs-link"),r.append(n),n}var Mae=z('<div class="qa-token-hint">Type <code>{{</code> to insert a token · <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Format syntax</a></div>');function qp(r,e){we(e,!0);let t=O(()=>!e.value.includes("{{"));var n=un(),i=Pe(n);{var o=s=>{var a=Mae(),l=A(I(a),3);S(a),de(()=>ke(l,"href",Al.formatSyntax)),$(s,a)};ne(i,s=>{h(t)&&s(o)})}$(r,n),Ce()}var gj=require("obsidian");Jd();Hv();var Rae=z('<input type="text" class="text-input" aria-label="Frontmatter property" placeholder="related" required=""/>'),SR=z("<!> <!>",1),$ae=z("<!> <!> <!> <!>",1);function zC(r,e){we(e,!0);let t=he(e,"appendLink",15),n=he(e,"app",3,void 0),i=O(()=>xu(t())),o=O(()=>h(i).linkType??"link"),s=O(()=>h(i).displayText),a=O(()=>h(i).frontmatterHandling??Qd),l=O(()=>h(i).destination.type==="specifiedFile"?h(i).destination.path:""),c=O(()=>h(i).enabled?h(i).requireActiveFile?"required":"optional":"disabled"),u=O(()=>h(i).destination.type),d=O(()=>n()?n().vault.getMarkdownFiles().map(B=>B.path):[]),f=[{value:"required",label:"Enabled (strict)"},{value:"optional",label:"Enabled (skip if unavailable)"},{value:"disabled",label:"Disabled"}],p=[{value:"activeFile",label:"Current note"},{value:"specifiedFile",label:"Specified note"}],m=[{value:"replaceSelection",label:"Replace selection"},{value:"afterSelection",label:"After selection"},{value:"endOfLine",label:"End of line"},{value:"newLine",label:"New line"},{value:"inFrontmatter",label:"In frontmatter property"}],v=[{value:"link",label:"Link"},{value:"embed",label:"Embed"}],g=[{value:"none",label:"Default"},{value:"selection",label:"Selected text"}],y=[{value:"alwaysAppend",label:"Create or convert"},{value:"createProperty",label:"Create if missing"},{value:"error",label:"Require list"}];function w(B){let ie=t(),W=typeof ie=="boolean"?h(i):ie,Y=B.placement??W.placement,X=B.destination??W.destination??h(i).destination,ae=X.type==="activeFile"&&rm(Y)?B.linkType??W.linkType??h(o):"link",pe=X.type==="activeFile"&&_T(Y)&&ae==="link"?B.displayText??h(s):"none";return{enabled:B.enabled??!0,placement:Y,requireActiveFile:B.requireActiveFile??W.requireActiveFile??h(i).requireActiveFile,linkType:ae,displayText:pe,destination:X,frontmatterProperty:B.frontmatterProperty??W.frontmatterProperty,frontmatterHandling:B.frontmatterHandling??W.frontmatterHandling}}function x(B){switch(B){case"disabled":t(w({enabled:!1}));break;case"required":t(w({requireActiveFile:!0}));break;case"optional":t(w({requireActiveFile:!1}));break}}function C(B){t(w({placement:B}))}function _(B){t(w({linkType:B}))}function E(B){t(w({displayText:B}))}function D(B){t(w({frontmatterProperty:B.currentTarget.value}))}function P(B){t(w({frontmatterHandling:B}))}function V(B){let ie=B==="specifiedFile"?{type:"specifiedFile",path:h(l)}:{type:"activeFile"};t(w({destination:ie}))}function j(B){t(w({destination:{type:"specifiedFile",path:B.trim()}}))}function oe(B){let ie=B.trim();if(!ie)return"Destination file is required";if(!n())return!0;let W=n().vault.getAbstractFileByPath(A0(ie));return W instanceof gj.TFile&&W.extension==="md"?!0:"Markdown file not found"}var se=SR(),M=Pe(se);{let B=Y=>{Jt(Y,{get value(){return h(c)},get options(){return f},onchange:x})},ie=O(()=>`Link to ${e.fileLabel} file`),W=O(()=>`Choose whether QuickAdd should insert a link to the ${e.fileLabel} file.`);$e(M,{get name(){return h(ie)},get desc(){return h(W)},control:B,$$slots:{control:!0}})}var U=A(M,2);{var q=B=>{var ie=SR(),W=Pe(ie);{let pe=be=>{Jt(be,{get value(){return h(u)},get options(){return p},onchange:V})},ge=O(()=>`Where QuickAdd writes the link to the ${e.fileLabel} file.`);$e(W,{name:"Link destination",get desc(){return h(ge)},control:pe,$$slots:{control:!0}})}var Y=A(W,2);{var X=pe=>{var ge=$ae(),be=Pe(ge);$e(be,{name:"Link placement",desc:"Where to place the link when appending",control:_e=>{Jt(_e,{get value(){return h(i).placement},get options(){return m},onchange:C})},$$slots:{control:!0}});var xe=A(be,2);{var Ue=He=>{$e(He,{name:"Link type",desc:"Choose whether to insert a link or an embed. Embeds transclude the note's contents at the placement position.",control:Be=>{Jt(Be,{get value(){return h(o)},get options(){return v},onchange:_})},$$slots:{control:!0}})},$t=O(()=>rm(h(i).placement));ne(xe,He=>{h($t)&&He(Ue)})}var Ne=A(xe,2);{var Ke=He=>{$e(He,{name:"Link display text",desc:"What the inserted link displays. 'Selected text' keeps the highlighted text as the link's display text; with nothing selected, the plain link is inserted.",control:Be=>{Jt(Be,{get value(){return h(s)},get options(){return g},onchange:E})},$$slots:{control:!0}})},Qe=O(()=>_T(h(i).placement)&&h(o)==="link");ne(Ne,He=>{h(Qe)&&He(Ke)})}var ye=A(Ne,2);{var We=He=>{var _e=SR(),Be=Pe(_e);$e(Be,{name:"Frontmatter property",desc:"Required property to insert the link into.",control:yr=>{var Pt=Rae();gr(Pt),de(Ar=>{Ps(Pt,h(i).frontmatterProperty??""),ke(Pt,"aria-invalid",Ar)},[()=>!h(i).frontmatterProperty?.trim()]),De("input",Pt,D),$(yr,Pt)},$$slots:{control:!0}});var ut=A(Be,2);$e(ut,{name:"Property handling",desc:"Choose how strict QuickAdd should be when the property is missing or not a list.",control:yr=>{Jt(yr,{get value(){return h(a)},get options(){return y},onchange:P})},$$slots:{control:!0}}),$(He,_e)},mt=O(()=>Zd(h(i).placement));ne(ye,He=>{h(mt)&&He(We)})}$(pe,ge)},ae=pe=>{$e(pe,{name:"Destination file",desc:"Existing Markdown note that receives the link at the bottom.",control:be=>{Ci(be,{get value(){return h(l)},placeholder:"Index.md",get app(){return n()},get suggestions(){return h(d)},maxSuggestions:50,required:!0,requiredMessage:"Destination file is required",validator:oe,ariaLabel:"Append link destination file",onChange:j})},$$slots:{control:!0}})};ne(Y,pe=>{h(u)==="activeFile"?pe(X):pe(ae,-1)})}$(B,ie)};ne(U,B=>{h(c)!=="disabled"&&B(q)})}$(r,se),Ce()}Et(["input"]);function HC(r,e){we(e,!0);let t=he(e,"openFile",15);$e(r,{name:"Open",get desc(){return e.description},control:i=>{lr(i,{get checked(){return t()},set checked(o){t(o)}})},$$slots:{control:!0}}),Ce()}var Oae=z("<!> <!> <!> <!>",1);function jC(r,e){we(e,!0);let t=he(e,"fileOpening",15);t(dn(t()));let n=[{value:"reuse",label:"Reuse current tab"},{value:"tab",label:"New tab"},{value:"split",label:"Split pane"},{value:"window",label:"New window"},{value:"left-sidebar",label:"Left sidebar"},{value:"right-sidebar",label:"Right sidebar"}],i=[{value:"vertical",label:"Split right"},{value:"horizontal",label:"Split down"}],o=[{value:"source",label:"Source"},{value:"preview",label:"Preview"},{value:"live",label:"Live Preview"},{value:"default",label:"Default"}],s=O(()=>typeof t().mode=="string"?t().mode:"default");var a=Oae(),l=Pe(a);{let m=g=>{Jt(g,{get value(){return t().location},get options(){return n},onchange:y=>t(t().location=y,!0)})},v=O(()=>`Where to open the ${e.contextLabel} file`);$e(l,{name:"File opening location",get desc(){return h(v)},control:m,$$slots:{control:!0}})}var c=A(l,2);{var u=m=>{$e(m,{name:"Split direction",desc:"How to arrange the new pane relative to the current one",control:g=>{Jt(g,{get value(){return t().direction},get options(){return i},onchange:y=>t(t().direction=y,!0)})},$$slots:{control:!0}})};ne(c,m=>{t().location==="split"&&m(u)})}var d=A(c,2);$e(d,{name:"View mode",desc:"How to display the opened file",control:v=>{Jt(v,{get value(){return h(s)},get options(){return o},onchange:g=>t(t().mode=g,!0)})},$$slots:{control:!0}});var f=A(d,2);{var p=m=>{$e(m,{name:"Focus new pane",desc:"Focus the opened tab immediately after opening",control:g=>{lr(g,{get checked(){return t().focus},set checked(y){t(t().focus=y,!0)}})},$$slots:{control:!0}})};ne(f,m=>{t().location!=="reuse"&&m(p)})}$(r,a),Ce()}function GC(r,e){we(e,!0);let t=he(e,"onePageInput",15),n=[{value:"",label:"Follow global setting"},{value:"always",label:"Always"},{value:"never",label:"Never"}],i=O(()=>t()??"");function o(s){t(s==="always"||s==="never"?s:void 0)}$e(r,{name:"One-page input override",desc:"Override the global setting for this choice. 'Always' forces the one-page modal even if disabled globally; 'Never' disables it even if enabled globally.",control:a=>{Jt(a,{get value(){return h(i)},get options(){return n},onchange:o})},$$slots:{control:!0}}),Ce()}qt();var Nae=new Intl.Collator(void 0,{numeric:!0,sensitivity:"base"}),Lae=new Intl.Collator(void 0,{numeric:!0,sensitivity:"variant"});function FA(r){return r.trim().replace(/^\/+/,"").replace(/\/+$/,"")}function Bae(r,e){let t=FA(r),n=FA(e);if(t===n)return 0;let i=t===""?[]:t.split("/"),o=n===""?[]:n.split("/"),s=Math.min(i.length,o.length);for(let a=0;a<s;a++){let l=Nae.compare(i[a],o[a]);if(l!==0)return l;let c=Lae.compare(i[a],o[a]);if(c!==0)return c}return i.length-o.length}function Nc(r){return[...r].sort(Bae)}function Uae(r,e){let t=FA(r),n=FA(e);return n?t===n||t.startsWith(`${n}/`):!0}function vj(r,e){return r.filter(t=>e.some(n=>Uae(t,n)))}var Ku=require("obsidian");var Vae=z('<div class="qa-canvas-node-empty"> </div>'),qae=z('<div class="qa-canvas-node-empty">No nodes match the current filter.</div>'),Wae=z('<button type="button"> </button>'),zae=z('<button type="button" disabled="">Unavailable</button>'),Hae=z('<div><div class="qa-canvas-node-item-header"><span> </span> <span class="qa-canvas-node-title"> </span></div> <div class="qa-canvas-node-subtitle"> </div> <div class="qa-canvas-node-meta"><code> </code></div> <div class="qa-canvas-node-item-actions"><!> <button type="button">Copy ID</button></div></div>'),jae=z('<div class="qa-canvas-node-picker"><div class="qa-canvas-node-actions"><button type="button">Open target canvas</button> <button type="button">Use selected in open canvas</button> <button type="button">Clear</button></div> <div class="qa-canvas-node-filter"><input type="text" placeholder="Filter by card text, file path, or node id\u2026" aria-label="Filter canvas nodes"/></div> <div class="qa-canvas-node-status"> </div> <div class="qa-canvas-node-list"><!></div></div>');function DR(r,e){we(e,!0);let t=he(e,"nodeId",15),n=Ae(bt([])),i=Ae("loading"),o=Ae(""),s=Ae(""),a=O(()=>{let M=h(s).trim().toLowerCase();return M.length?h(n).filter(U=>U.searchText.includes(M)):h(n)}),l=O(()=>(t()??"").trim()),c=O(()=>h(i)==="ready"?`Showing ${h(a).length} of ${h(n).length} nodes`:h(i)==="empty"?h(o):"Loading canvas nodes\u2026");cT(()=>{(async()=>{let M=w0(e.app,e.canvasTargetPath);if(!M){Z(o,"Node picker works for direct .canvas paths that already exist in your vault. Format syntax paths cannot be listed here."),Z(i,"empty");return}if(Z(n,await gB(e.app,M),!0),h(n).length===0){Z(o,"No selectable nodes found in the target canvas."),Z(i,"empty");return}Z(i,"ready")})()});function u(M){t(M)}function d(){let M=w0(e.app,e.canvasTargetPath);if(!M){new Ku.Notice("Target canvas file was not found.");return}e.app.workspace.getLeaf(!0).openFile(M).catch(()=>new Ku.Notice("Could not open target canvas."))}function f(){let M=hB(e.app,e.canvasTargetPath);if(!M){new Ku.Notice("Open the target canvas and select exactly one card to use this action.");return}let U=h(n).find(q=>q.id===M);if(!U){new Ku.Notice(h(i)==="ready"?"The selected node was not found in the loaded canvas.":"Canvas nodes are still loading. Wait a moment and try again.");return}if(!U.capturable){new Ku.Notice(U.capturableReason);return}u(M)}function p(M){(async()=>{try{await navigator.clipboard.writeText(M),new Ku.Notice(`Copied node id ${M}`)}catch{new Ku.Notice("Could not copy node id automatically.")}})()}function m(M){return M==="text"?"TEXT":M==="file"?"FILE":"NODE"}var v=jae(),g=I(v),y=I(g),w=A(y,2),x=A(w,2);S(g);var C=A(g,2),_=I(C);gr(_),S(C);var E=A(C,2),D=I(E,!0);S(E);var P=A(E,2),V=I(P);{var j=M=>{var U=Vae(),q=I(U,!0);S(U),de(()=>me(q,h(o))),$(M,U)},oe=M=>{var U=qae();$(M,U)},se=M=>{var U=un(),q=Pe(U);ar(q,17,()=>h(a),B=>B.id,(B,ie)=>{let W=O(()=>h(l)===h(ie).id);var Y=Hae();let X;var ae=I(Y),pe=I(ae),ge=I(pe,!0);S(pe);var be=A(pe,2),xe=I(be,!0);S(be),S(ae);var Ue=A(ae,2),$t=I(Ue,!0);S(Ue);var Ne=A(Ue,2),Ke=I(Ne),Qe=I(Ke,!0);S(Ke),S(Ne);var ye=A(Ne,2),We=I(ye);{var mt=Be=>{var ut=Wae();let or;var yr=I(ut,!0);S(ut),de(()=>{or=wt(ut,1,"",null,or,{"mod-cta":h(W)}),me(yr,h(W)?"Selected":"Use node")}),De("click",ut,()=>u(h(ie).id)),$(Be,ut)},He=Be=>{var ut=zae();de(()=>ke(ut,"title",h(ie).capturableReason)),$(Be,ut)};ne(We,Be=>{h(ie).capturable?Be(mt):Be(He,-1)})}var _e=A(We,2);S(ye),S(Y),de(Be=>{X=wt(Y,1,"qa-canvas-node-item",null,X,{"is-selected":h(W)}),wt(pe,1,`qa-canvas-node-type is-${h(ie).type??""}`),me(ge,Be),me(xe,h(ie).title),me($t,h(ie).subtitle),me(Qe,h(ie).id)},[()=>m(h(ie).type)]),De("click",_e,()=>p(h(ie).id)),$(B,Y)}),$(M,U)};ne(V,M=>{h(i)==="empty"?M(j):h(i)==="ready"&&h(a).length===0?M(oe,1):M(se,-1)})}S(P),S(v),de(()=>me(D,h(c))),De("click",y,d),De("click",w,f),De("click",x,()=>u("")),co(_,()=>h(s),M=>Z(s,M)),$(r,v),Ce()}Et(["click"]);Ru();op();var Gae=new Set(["folder","tag","exclude-folder","exclude-tag","exclude-file"]);function Yae(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 yj(r){let e=Yi.parse(`__capture_scope|${r}`);return{filter:e.filters,multiSelect:e.multiSelect??!1}}function Kae(r){return!!(r.folder||r.folders?.length||r.tags?.length||r.excludeFolders?.length||r.excludeTags?.length||r.excludeFiles?.length)}function gh(r){let e=r.trim();if(!e)return null;if(e.startsWith("#")){let o=Ls(e),s=(o.shift()??"").replace(/^#/,"").replace(/\.md$/i,"").trim();if(!s)return null;let a=o.length>0?yj(o.join("|")):{filter:{},multiSelect:!1};return{filter:{...a.filter,tags:Yae(s,a.filter.tags)},multiSelect:a.multiSelect}}let t=Ls(e)[0]??"",n=fo(t);if(!n||!Gae.has(n.key))return null;let i=yj(e);return Kae(i.filter)?i:null}Ru();var bj=/^property:/i;function vh(r){let e=r.trim();if(!bj.test(e))return null;let t=e.replace(bj,""),{fieldName:n,filters:i}=Yi.parse(t),o=n.indexOf("="),s=(o>=0?n.slice(0,o):n).trim(),a=o>=0?n.slice(o+1).trim():"",l=a.length>0?a:void 0;return{field:s,value:l,filter:i}}function Xae(r){return r.trim().replace(/^\/+/,"")}function YC(r){return[...new Set((r??[]).map(e=>e.trim()).filter(Boolean))]}function KC(r,e="or"){return r.length<=1?r[0]??"":e==="+"?r.join(" + "):r.length===2?`${r[0]} ${e} ${r[1]}`:`${r.slice(0,-1).join(", ")}, ${e} ${r[r.length-1]}`}function wj(r){let e=YC(r.folders??(r.folder?[r.folder]:[])),t=YC(r.tags),n=YC(r.excludeFolders),i=YC(r.excludeTags),o=YC(r.excludeFiles),s=[];return e.length>0&&s.push(`${e.length===1?"folder":"folders"} ${KC(e)}`),t.length>0&&s.push(`${t.length===1?"tag":"tags"} ${KC(t,"+")}`),n.length>0&&s.push(`excluding ${n.length===1?"folder":"folders"} ${KC(n)}`),i.length>0&&s.push(`excluding ${i.length===1?"tag":"tags"} ${KC(i,"+")}`),o.length>0&&s.push(`excluding ${o.length===1?"file":"files"} ${KC(o)}`),s.length>0?s.join("; "):"all notes"}function XC(r){let e=Xae(r),t=vh(e);if(t){if(!t.field)return{recognized:!0,valid:!1,variant:"error",message:"Property capture target needs a field name, e.g. property:type=draft."};let i=t.value?`frontmatter ${t.field} = ${t.value}`:`frontmatter field ${t.field}`,o=wj(t.filter),s=o==="all notes"?"":`; ${o}`;return{recognized:!0,valid:!0,variant:"success",message:`Recognized property target: ${i}${s}.`}}let n=gh(e);return n?n.multiSelect?{recognized:!0,valid:!1,variant:"error",message:"Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata."}:{recognized:!0,valid:!0,variant:"success",message:`Recognized filtered picker: ${wj(n.filter)}.`}:null}var Qae=z("<!> <!> <!>",1),Zae=z('<!> <div class="qa-canvas-node-helper">Tip: open this canvas and select one card to grab its id instantly.</div> <!>',1),Cj=z("<!> <!>",1);function IR(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>{let g=Nc(Ns(e.app)).filter(x=>x.length>0).map(x=>x.endsWith("/")?x:x+"/"),y=e.app.vault.getMarkdownFiles().map(x=>x.path),w=e.app.vault.getFiles().filter(x=>x.extension==="canvas").map(x=>x.path);return Array.from(new Set([...g,...y,...w]))}),i=[g=>new Hi(e.app,g,e.plugin,"captureTarget")],o=O(()=>XC(t().captureTo??"")),s=O(()=>h(o)!==null),a=g=>XC(g)!==null,l=O(()=>!h(s)&&bu(t().captureTo));function c(g){let y=!!t().captureToActiveFile&&t().activeFileWritePosition==="bottom";t(t().captureToActiveFile=g,!0),!g&&y&&t(t().prepend=!0,!0),!g&&t().newLineCapture?.enabled&&t(t().newLineCapture.enabled=!1,!0)}function u(g){let y=tm(t().captureTo),w=bu(t().captureTo),x=XC(g)!==null;t(t().captureTo=g,!0);let C=tm(g),_=bu(g);(x||!_||w&&_&&y!==C)&&t(t().captureToCanvasNodeId="",!0)}function d(g){let y=XC(g);return y?{valid:y.valid,message:y.message,variant:y.valid?"success":void 0}:g.trim()?!0:{valid:!0,message:"Leave empty to pick the note each time this choice runs."}}var f=Cj(),p=Pe(f);$e(p,{name:"Capture to active file",desc:"Capture into whichever note is open when the choice runs, instead of a fixed target.",control:y=>{lr(y,{get checked(){return t().captureToActiveFile},onchange:c})},$$slots:{control:!0}});var m=A(p,2);{var v=g=>{var y=Cj(),w=Pe(y);ss(w,{name:"Capture to",desc:"Vault-relative path to a file or folder, a #tag, or property:field=value. Supports format syntax like {{DATE}}; end with '/' to capture into a folder.",children:(E,D=Vt)=>{var P=Qae(),V=Pe(P);Ci(V,{get id(){return D()},get value(){return t().captureTo},placeholder:"Daily/{{DATE}}.md",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,get makeSuggesters(){return i},validator:d,onChange:u});var j=A(V,2);qp(j,{get value(){return t().captureTo}});var oe=A(j,2);{var se=M=>{hs(M,{get value(){return t().captureTo},formatterKind:"fileName",get app(){return e.app},get plugin(){return e.plugin},hideWhen:a})};ne(oe,M=>{h(s)||M(se)})}$(E,P)},$$slots:{default:!0}});var x=A(w,2);{var C=_=>{var E=Zae(),D=Pe(E);$e(D,{name:"Target canvas node",desc:"Choose a card from the canvas below, or paste an exact node id.",control:j=>{{let oe=O(()=>t().captureToCanvasNodeId??"");Ci(j,{get value(){return h(oe)},placeholder:"Canvas node id",ariaLabel:"Canvas node id",required:!0,requiredMessage:"A canvas capture target requires a node id \u2014 pick a card below or paste an exact node id.",onChange:se=>t(t().captureToCanvasNodeId=se.trim(),!0)})}},$$slots:{control:!0}});var P=A(D,4);jI(P,()=>t().captureTo,V=>{DR(V,{get canvasTargetPath(){return t().captureTo},get app(){return e.app},get nodeId(){return t().captureToCanvasNodeId},set nodeId(j){t(t().captureToCanvasNodeId=j,!0)}})}),$(_,E)};ne(x,_=>{h(l)&&_(C)})}$(g,y)};ne(m,g=>{t().captureToActiveFile||g(v)})}$(r,f),Ce()}var _j=require("obsidian");var Tj=require("obsidian");Tt();function PR(r){let t=r.match(/\{\{DATE:((?:[^}\n\r+|]|\|(?!(?:startof|endof):[a-z]))*)(?:\+-?\d+)?(?:\|(?:startof|endof):[a-z]+)?\}\}/i)?.[1]?.trim();if(t)return t;let i=r.match(/\{\{VDATE:[^,}]+,([^}\n\r]*)\}\}/i)?.[1]?.split("|")[0]?.trim();if(i)return i}var Jae=z(`<div class="setting-item-description">You'll pick a heading from the target note when you run this capture, and the
|
||
text is inserted under it. Use the toggles below to control placement within that
|
||
section.</div>`),xj=z("<!> <!>",1),ele=z(`<div class="setting-item-description">Inline insertion needs a single-line target. The line break (\\n) can't be
|
||
matched on the same line \u2014 remove it, or turn off "Inline insertion".</div>`),Ej=z("<!> <!> <!>",1),tle=z(`<div class="setting-item-description">No sorting: newest-first prepends the new section above existing ones;
|
||
oldest-first appends it below.</div>`),rle=z(`<div class="setting-item-description">This heading uses a date token QuickAdd can't auto-read for sorting. Pick
|
||
"Date" and enter the format, or sections stay in insertion order.</div>`),nle=z(`<div class="setting-item-description">The "Insert after" heading is created at its sorted position among ALL
|
||
same-level headings in the note (it is not scoped to one parent section). It
|
||
does NOT re-sort headings you already have; only the new one is placed. Use
|
||
"Insert at end of section" above for newest-on-top vs. appended entries within
|
||
each section.</div> <!> <!> <!> <!> <!> <!>`,1),ile=z("<!> <!> <!> <!> <!>",1);function FR(r,e){we(e,!0);let t=he(e,"insertAfter",15);t().inline===void 0&&t(t().inline=!1,!0),t().replaceExisting===void 0&&t(t().replaceExisting=!1,!0),t().promptHeading===void 0&&t(t().promptHeading=!1,!0),t().insertAtEnd===void 0&&t(t().insertAtEnd=!1,!0),t().considerSubsections===void 0&&t(t().considerSubsections=!1,!0),t().blankLineAfterMatchMode||t(t().blankLineAfterMatchMode="auto",!0),t().createIfNotFound||t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=uo,!0);let n=[B=>new Hi(e.app,B,e.plugin,"lineTarget")],i=[{value:"auto",label:"Auto (headings only)"},{value:"skip",label:"Always skip"},{value:"none",label:"Never skip"}],o=O(()=>t().inline?[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"}]:[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"},{value:_a,label:"Ordered (place new section among siblings)"}]),s=[{value:"insertion",label:"Insertion order (no sorting)"},{value:"lexical",label:"Text (A\u2192Z)"},{value:"numeric",label:"Number"},{value:"date",label:"Date"},{value:"semver",label:"Version (semver)"}],a=[{value:"desc",label:"Newest / highest first"},{value:"asc",label:"Oldest / lowest first"}],l=[{value:"bottom",label:"Sort existing unparseable headings to bottom"},{value:"top",label:"Sort existing unparseable headings to top"}],c=Ae(!!t().orderBy),u=O(()=>t().createIfNotFoundLocation===_a),d=O(()=>t().createIfNotFound&&h(u)),f=O(()=>new fh(e.app,e.plugin)),p=Ae(!1);hr(()=>{let B=t().after??"",ie=h(f);if(!t().inline||B===""){Z(p,!1);return}let W=!1;return ie.format(B).then(Y=>{W||Z(p,/[\n\r]/.test(Y),!0)}).catch(()=>{W||Z(p,!1)}),()=>{W=!0}});let m=O(()=>t().orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"}),v=O(()=>/\{\{V?DATE\b/i.test(t().after??"")),g=O(()=>h(d)&&t().orderBy?.by==="insertion"&&h(v)&&!PR(t().after??""));hr(()=>{if(!h(d))return;let B=PR(t().after??"");if(!t().orderBy){t(t().orderBy={by:B?"date":"insertion",direction:"desc",dateFormat:B,unparseable:"bottom"},!0);return}!h(c)&&(t().orderBy.by==="insertion"||t().orderBy.by==="date")&&(t(t().orderBy.by=B?"date":"insertion",!0),t(t().orderBy.dateFormat=B,!0))});function y(B){t(t().createIfNotFoundLocation=B,!0),B===_a?t(t().inline=!1,!0):(t(t().orderBy=void 0,!0),Z(c,!1))}function w(B){Z(c,!0),t().orderBy&&t(t().orderBy.by=B,!0)}function x(B){t().promptHeading||B&&!t().after.startsWith("#")&&(t(t().considerSubsections=!1,!0),new Tj.Notice("Consider subsections requires the target to be a heading (starts with #)"))}function C(B){B&&(t(t().inline=!1,!0),t(t().replaceExisting=!1,!0))}var _=ile(),E=Pe(_);$e(E,{name:"Choose heading when capturing",desc:"Instead of typing a target line now, show a dropdown of the target note's headings when you run this capture and insert under the one you pick.",control:ie=>{lr(ie,{onchange:C,get checked(){return t().promptHeading},set checked(W){t(t().promptHeading=W,!0)}})},$$slots:{control:!0}});var D=A(E,2);{var P=B=>{var ie=Jae();$(B,ie)},V=B=>{var ie=Ej(),W=Pe(ie);ss(W,{name:"Insert after",desc:"Insert capture after specified text. Accepts format syntax. Tip: use a heading (starts with #) to target a section. Blank line handling is configurable below.",children:(ge,be=Vt)=>{var xe=xj(),Ue=Pe(xe);Ci(Ue,{get id(){return be()},placeholder:"Insert after",required:!0,requiredMessage:"Insert after text is required",get makeSuggesters(){return n},get value(){return t().after},set value(Ne){t(t().after=Ne,!0)}});var $t=A(Ue,2);hs($t,{get value(){return t().after},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(ge,xe)},$$slots:{default:!0}});var Y=A(W,2);{let pe=be=>{lr(be,{get disabled(){return h(u)},get checked(){return t().inline},set checked(xe){t(t().inline=xe,!0)}})},ge=O(()=>h(u)?"Inline insertion can't be combined with ordered placement.":"Insert captured content on the same line, immediately after the matched text (no newline added).");$e(Y,{name:"Inline insertion",get desc(){return h(ge)},control:pe,$$slots:{control:!0}})}var X=A(Y,2);{var ae=pe=>{var ge=ele();$(pe,ge)};ne(X,pe=>{h(p)&&pe(ae)})}$(B,ie)};ne(D,B=>{t().promptHeading?B(P):B(V,-1)})}var j=A(D,2);{var oe=B=>{$e(B,{name:"Replace existing value",desc:"Replace everything after the matched text up to end-of-line.",control:W=>{lr(W,{get checked(){return t().replaceExisting},set checked(Y){t(t().replaceExisting=Y,!0)}})},$$slots:{control:!0}})},se=B=>{var ie=Ej(),W=Pe(ie);$e(W,{name:"Insert at end of section",desc:"Place the text at the end of the matched section instead of the top.",control:pe=>{lr(pe,{get checked(){return t().insertAtEnd},set checked(ge){t(t().insertAtEnd=ge,!0)}})},$$slots:{control:!0}});var Y=A(W,2);{let ae=ge=>{{let be=O(()=>t().blankLineAfterMatchMode??"auto");Jt(ge,{get value(){return h(be)},get options(){return i},get disabled(){return t().insertAtEnd},onchange:xe=>t(t().blankLineAfterMatchMode=xe,!0)})}},pe=O(()=>t().insertAtEnd?"Not used when inserting at end of section.":"Controls whether Insert After skips existing blank lines after the matched line.");$e(Y,{name:"Blank lines after match",get desc(){return h(pe)},control:ae,$$slots:{control:!0}})}var X=A(Y,2);{let ae=ge=>{{let be=O(()=>!t().insertAtEnd);lr(ge,{get disabled(){return h(be)},onchange:x,get checked(){return t().considerSubsections},set checked(xe){t(t().considerSubsections=xe,!0)}})}},pe=O(()=>t().insertAtEnd?t().promptHeading?"Also include the chosen heading\u2019s subsections (nested headings inside its section).":"Also include the section\u2019s subsections (requires target to be a heading starting with #). Subsections are headings inside the section.":"Only affects placement when \u201CInsert at end of section\u201D is on.");$e(X,{name:"Consider subsections",get desc(){return h(pe)},control:ae,$$slots:{control:!0}})}$(B,ie)};ne(j,B=>{t().inline?B(oe):B(se,-1)})}var M=A(j,2);$e(M,{name:"Create line if not found",desc:"Creates the 'insert after' line if it is not found.",control:ie=>{var W=xj(),Y=Pe(W);lr(Y,{get checked(){return t().createIfNotFound},set checked(ae){t(t().createIfNotFound=ae,!0)}});var X=A(Y,2);{let ae=O(()=>t().createIfNotFoundLocation||uo);Jt(X,{get value(){return h(ae)},get options(){return h(o)},onchange:y})}$(ie,W)},$$slots:{control:!0}});var U=A(M,2);{var q=B=>{var ie=nle(),W=A(Pe(ie),2);$e(W,{name:"Sort sections by",control:Ke=>{Jt(Ke,{get value(){return h(m).by},get options(){return s},onchange:w})},$$slots:{control:!0}});var Y=A(W,2);$e(Y,{name:"Section order",control:Ke=>{Jt(Ke,{get value(){return h(m).direction},get options(){return a},onchange:Qe=>{t().orderBy&&t(t().orderBy.direction=Qe,!0)}})},$$slots:{control:!0}});var X=A(Y,2);{var ae=Ne=>{$e(Ne,{name:"Date format",desc:"Moment format used to parse existing heading dates for sorting (e.g. YYYY-MM-DD).",control:Qe=>{{let ye=O(()=>h(m).dateFormat??"");Ci(Qe,{get value(){return h(ye)},placeholder:"YYYY-MM-DD",ariaLabel:"Date format",onChange:We=>{Z(c,!0),t().orderBy&&t(t().orderBy.dateFormat=We,!0)}})}},$$slots:{control:!0}})};ne(X,Ne=>{h(m).by==="date"&&Ne(ae)})}var pe=A(X,2);{var ge=Ne=>{$e(Ne,{name:"Existing unparseable headings",desc:"Where to rank EXISTING headings whose text can't be parsed for this sort. (A new heading that can't be parsed is appended at the end.)",control:Qe=>{{let ye=O(()=>h(m).unparseable??"bottom");Jt(Qe,{get value(){return h(ye)},get options(){return l},onchange:We=>{t().orderBy&&t(t().orderBy.unparseable=We,!0)}})}},$$slots:{control:!0}})};ne(pe,Ne=>{(h(m).by==="date"||h(m).by==="numeric"||h(m).by==="semver")&&Ne(ge)})}var be=A(pe,2);{var xe=Ne=>{var Ke=tle();$(Ne,Ke)};ne(be,Ne=>{h(m).by==="insertion"&&Ne(xe)})}var Ue=A(be,2);{var $t=Ne=>{var Ke=rle();$(Ne,Ke)};ne(Ue,Ne=>{h(g)&&Ne($t)})}$(B,ie)};ne(U,B=>{h(d)&&t().orderBy&&B(q)})}$(r,_),Ce()}Tt();var MR=z("<!> <!>",1);function RR(r,e){we(e,!0);let t=he(e,"insertBefore",15);t().createIfNotFound===void 0&&t(t().createIfNotFound=!1,!0),t().createIfNotFoundLocation||t(t().createIfNotFoundLocation=uo,!0);let n=[l=>new Hi(e.app,l,e.plugin,"lineTarget")],i=[{value:uo,label:"Top"},{value:lc,label:"Bottom"},{value:cc,label:"Cursor"}];var o=MR(),s=Pe(o);ss(s,{name:"Insert before",desc:"Insert capture before specified text. Accepts format syntax.",children:(c,u=Vt)=>{var d=MR(),f=Pe(d);Ci(f,{get id(){return u()},placeholder:"Insert before",required:!0,requiredMessage:"Insert before text is required",get makeSuggesters(){return n},get value(){return t().before},set value(m){t(t().before=m,!0)}});var p=A(f,2);hs(p,{get value(){return t().before},formatterKind:"lineTarget",get app(){return e.app},get plugin(){return e.plugin}}),$(c,d)},$$slots:{default:!0}});var a=A(s,2);$e(a,{name:"Create line if not found",desc:"Creates the 'insert before' line if it is not found.",control:c=>{var u=MR(),d=Pe(u);lr(d,{get checked(){return t().createIfNotFound},set checked(p){t(t().createIfNotFound=p,!0)}});var f=A(d,2);{let p=O(()=>t().createIfNotFoundLocation||uo);Jt(f,{get value(){return h(p)},get options(){return i},onchange:m=>t(t().createIfNotFoundLocation=m,!0)})}$(c,u)},$$slots:{control:!0}}),$(r,o),Ce()}var ole=z(`<div class="setting-item-description">Canvas note: 'At cursor' and 'New line above/below cursor' are not supported
|
||
for Canvas card capture. Use top, bottom, insert-after, or insert-before
|
||
placement.</div>`),sle=z("<!> <!> <!> <!>",1);function $R(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>!!t().captureToActiveFile),i=O(()=>t().insertAfter?.enabled?"after":t().insertBefore?.enabled?"before":t().newLineCapture?.enabled?t().newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":h(n)?t().activeFileWritePosition==="top"?"activeTop":t().activeFileWritePosition==="bottom"||t().prepend?"bottom":"top":t().prepend?"bottom":"top"),o=O(()=>[{value:"top",label:h(n)?"At cursor":"Top of file"},...h(n)?[{value:"activeTop",label:"Top of file (after frontmatter)"},{value:"newLineAbove",label:"New line above cursor"},{value:"newLineBelow",label:"New line below cursor"}]:[],{value:"after",label:"After line\u2026"},{value:"before",label:"Before line\u2026"},{value:"bottom",label:"Bottom of file"}]);function s(g){if(t(t().prepend=!1,!0),t(t().insertAfter.enabled=!1,!0),t(t().insertAfter.promptHeading=!1,!0),t(t().insertAfter.inline=!1,!0),t(t().insertAfter.replaceExisting=!1,!0),t().insertBefore||t(t().insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},!0),t(t().insertBefore.enabled=!1,!0),t().newLineCapture||t(t().newLineCapture={enabled:!1,direction:"below"},!0),t(t().newLineCapture.enabled=!1,!0),t(t().activeFileWritePosition="cursor",!0),g==="top"){h(n)||t(t().prepend=!1,!0);return}if(g==="activeTop"){h(n)&&t(t().activeFileWritePosition="top",!0);return}if(g==="bottom"){h(n)?t(t().activeFileWritePosition="bottom",!0):t(t().prepend=!0,!0);return}if(g==="newLineAbove"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="above",!0);return}if(g==="newLineBelow"){t(t().newLineCapture.enabled=!0,!0),t(t().newLineCapture.direction="below",!0);return}if(g==="before"){t(t().insertBefore.enabled=!0,!0);return}t(t().insertAfter.enabled=!0,!0)}let a=O(()=>{let g=typeof t().captureTo=="string"&&bu(t().captureTo),y=e.app.workspace.getActiveViewOfType(_j.FileView)?.getViewType()==="canvas",w=h(n)&&!t().insertAfter.enabled&&!t().insertBefore?.enabled&&!t().newLineCapture?.enabled&&(t().activeFileWritePosition??"cursor")==="cursor"&&!t().prepend;return!(!(t().newLineCapture?.enabled||w)||(h(n)?!y:!g))});var l=sle(),c=Pe(l);{let g=w=>{Jt(w,{get value(){return h(i)},get options(){return h(o)},onchange:s})},y=O(()=>h(n)?"Where to place the capture in the current file.":"Where to place the capture in the target file.");$e(c,{name:"Write position",get desc(){return h(y)},control:g,$$slots:{control:!0}})}var u=A(c,2);{var d=g=>{FR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertAfter(){return t().insertAfter},set insertAfter(y){t(t().insertAfter=y,!0)}})};ne(u,g=>{t().insertAfter.enabled&&g(d)})}var f=A(u,2);{var p=g=>{RR(g,{get app(){return e.app},get plugin(){return e.plugin},get insertBefore(){return t().insertBefore},set insertBefore(y){t(t().insertBefore=y,!0)}})};ne(f,g=>{t().insertBefore?.enabled&&g(p)})}var m=A(f,2);{var v=g=>{var y=ole();$(g,y)};ne(m,g=>{h(a)&&g(v)})}$(r,l),Ce()}var ale=new Set(["activity","airplay","alarm-check","alarm-clock-off","alarm-clock","alarm-minus","alarm-plus","album","alert-circle","alert-octagon","alert-triangle","align-center-horizontal","align-center-vertical","align-center","align-end-horizontal","align-end-vertical","align-horizontal-distribute-center","align-horizontal-distribute-end","align-horizontal-distribute-start","align-horizontal-justify-center","align-horizontal-justify-end","align-horizontal-justify-start","align-horizontal-space-around","align-horizontal-space-between","align-justify","align-left","align-right","align-start-horizontal","align-start-vertical","align-vertical-distribute-center","align-vertical-distribute-end","align-vertical-distribute-start","align-vertical-justify-center","align-vertical-justify-end","align-vertical-justify-start","align-vertical-space-around","align-vertical-space-between","anchor","aperture","archive","arrow-big-down","arrow-big-left","arrow-big-right","arrow-big-up","arrow-down-circle","arrow-down-left","arrow-down-right","arrow-down","arrow-left-circle","arrow-left-right","arrow-left","arrow-right-circle","arrow-right","arrow-up-circle","arrow-up-left","arrow-up-right","arrow-up","asterisk","at-sign","award","axe","banknote","bar-chart-2","bar-chart","baseline","battery-charging","battery-full","battery-low","battery-medium","battery","beaker","bell-minus","bell-off","bell-plus","bell-ring","bell","bike","binary","bitcoin","bluetooth-connected","bluetooth-off","bluetooth-searching","bluetooth","bold","book-open","book","bookmark-minus","bookmark-plus","bookmark","bot","box-select","box","briefcase","brush","bug","building-2","building","bus","calculator","calendar","camera-off","camera","car","carrot","cast","check-circle-2","check-circle","check-square","check","chevron-down","chevron-first","chevron-last","chevron-left","chevron-right","chevron-up","chevrons-down-up","chevrons-down","chevrons-left","chevrons-right","chevrons-up-down","chevrons-up","chrome","circle-slashed","circle","clipboard-check","clipboard-copy","clipboard-list","clipboard-x","clipboard","clock-1","clock-10","clock-11","clock-12","clock-2","clock-3","clock-4","clock-5","clock-6","clock-7","clock-8","clock-9","clock","cloud-drizzle","cloud-fog","cloud-hail","cloud-lightning","cloud-moon","cloud-off","cloud-rain-wind","cloud-rain","cloud-snow","cloud-sun","cloud","cloudy","clover","code-2","code","codepen","codesandbox","coffee","coins","columns","command","compass","contact","contrast","cookie","copy","copyleft","copyright","corner-down-left","corner-down-right","corner-left-down","corner-left-up","corner-right-down","corner-right-up","corner-up-left","corner-up-right","cpu","credit-card","crop","cross","crosshair","crown","currency","database","delete","dice-1","dice-2","dice-3","dice-4","dice-5","dice-6","disc","divide-circle","divide-square","divide","dollar-sign","download-cloud","download","dribbble","droplet","droplets","drumstick","edit-2","edit-3","edit","egg","equal-not","equal","eraser","euro","expand","external-link","eye-off","eye","facebook","fast-forward","feather","figma","file-check-2","file-check","file-code","file-digit","file-input","file-minus-2","file-minus","file-output","file-plus-2","file-plus","file-search","file-text","file-x-2","file-x","file","files","film","filter","flag-off","flag-triangle-left","flag-triangle-right","flag","flame","flashlight-off","flashlight","flask-conical","flask-round","folder-minus","folder-open","folder-plus","folder","form-input","forward","frame","framer","frown","function-square","gamepad-2","gamepad","gauge","gavel","gem","ghost","gift","git-branch-plus","git-branch","git-commit","git-fork","git-merge","git-pull-request","github","gitlab","glasses","globe-2","globe","grab","graduation-cap","grid","grip-horizontal","grip-vertical","hammer","hand-metal","hand","hard-drive","hard-hat","hash","haze","headphones","heart","help-circle","hexagon","highlighter","history","home","image-minus","image-off","image-plus","image","import","inbox","indent","indian-rupee","infinity","info","inspect","instagram","italic","japanese-yen","key","keyboard","landmark","languages","laptop-2","laptop","lasso-select","lasso","layers","layout-dashboard","layout-grid","layout-list","layout-template","layout","library","life-buoy","lightbulb-off","lightbulb","link-2-off","link-2","link","linkedin","list-checks","list-minus","list-ordered","list-plus","list-x","list","loader-2","loader","locate-fixed","locate-off","locate","lock","log-in","log-out","mail","map-pin","map","maximize-2","maximize","megaphone","meh","menu","message-circle","message-square","mic-off","mic","minimize-2","minimize","minus-circle","minus-square","minus","monitor-off","monitor-speaker","monitor","moon","more-horizontal","more-vertical","mountain-snow","mountain","mouse-pointer-2","mouse-pointer-click","mouse-pointer","mouse","move-diagonal-2","move-diagonal","move-horizontal","move-vertical","move","music","navigation-2","navigation","network","octagon","option","outdent","package-check","package-minus","package-plus","package-search","package-x","package","palette","palmtree","paperclip","pause-circle","pause-octagon","pause","pen-tool","pencil","percent","person-standing","phone-call","phone-forwarded","phone-incoming","phone-missed","phone-off","phone-outgoing","phone","pie-chart","piggy-bank","pin","pipette","plane","play-circle","play","plug-zap","plus-circle","plus-square","plus","pocket","podcast","pointer","pound-sterling","power-off","power","printer","qr-code","quote","radio-receiver","radio","redo","refresh-ccw","refresh-cw","regex","repeat-1","repeat","reply-all","reply","rewind","rocket","rocking-chair","rotate-ccw","rotate-cw","rss","ruler","russian-ruble","save","scale","scan-line","scan","scissors","screen-share-off","screen-share","search","send","separator-horizontal","separator-vertical","server-crash","server-off","server","settings-2","settings","share-2","share","sheet","shield-alert","shield-check","shield-close","shield-off","shield","shirt","shopping-bag","shopping-cart","shovel","shrink","shuffle","sidebar-close","sidebar-open","sidebar","sigma","signal-high","signal-low","signal-medium","signal-zero","signal","skip-back","skip-forward","skull","slack","slash","sliders","smartphone-charging","smartphone","smile","snowflake","sort-asc","sort-desc","speaker","sprout","square","star-half","star","stop-circle","stretch-horizontal","stretch-vertical","strikethrough","subscript","sun","sunrise","sunset","superscript","swiss-franc","switch-camera","table","tablet","tag","target","tent","terminal-square","terminal","text-cursor-input","text-cursor","thermometer-snowflake","thermometer-sun","thermometer","thumbs-down","thumbs-up","ticket","timer-off","timer-reset","timer","toggle-left","toggle-right","tornado","trash-2","trash","trello","trending-down","trending-up","triangle","truck","tv-2","tv","twitch","twitter","type","umbrella","underline","undo","unlink-2","unlink","unlock","upload-cloud","upload","user-check","user-minus","user-plus","user-x","user","users","verified","vibrate","video-off","video","view","voicemail","volume-1","volume-2","volume-x","volume","wallet","wand","watch","waves","webcam","wifi-off","wifi","wind","wrap-text","wrench","x-circle","x-octagon","x-square","x","youtube","zap-off","zap","zoom-in","zoom-out","search-large","lucide-clock","lucide-cloud","lucide-cross","lucide-folder","lucide-info","lucide-languages","lucide-link","lucide-pencil","lucide-pin","lucide-search","lucide-star","lucide-trash"]),MA=Array.from(ale);Wt();var lle=z('<div class="qa-choice-icon-setting-control svelte-p1gcdx"><span class="qa-choice-icon-setting-preview svelte-p1gcdx" aria-hidden="true"><!></span> <input type="text" class="qa-choice-icon-input svelte-p1gcdx" aria-label="Choice icon"/></div>'),cle={hash:"svelte-p1gcdx",code:".qa-choice-icon-setting-control.svelte-p1gcdx {display:flex;align-items:center;gap:8px;min-width:min(18rem, 100%);}.qa-choice-icon-setting-preview.svelte-p1gcdx {display:inline-flex;align-items:center;justify-content:center;flex:0 0 auto;color:var(--text-muted);}.qa-choice-icon-input.svelte-p1gcdx {width:100%;min-width:0;}"};function QC(r,e){we(e,!0),ot(r,cle);let t=he(e,"icon",15),n=O(()=>bm(e.type)),i=O(()=>typeof t()=="string"?t():""),o=O(()=>h(i).trim()||h(n));function s(l){return new ni(e.app,l,MA,50)}function a(l){let c=l.currentTarget.value.trim();t(c||void 0)}{let l=u=>{var d=lle(),f=I(d),p=I(f);Rt(p,{get iconId(){return h(o)},size:18}),S(f);var m=A(f,2);gr(m),Fr(m,(v,g)=>hp?.(v,g),()=>s),S(d),de(()=>{Ps(m,h(i)),ke(m,"placeholder",h(n))}),De("input",m,a),$(u,d)},c=O(()=>`Lucide/Obsidian icon id. Leave empty to use ${h(n)}.`);$e(r,{name:"Icon",get desc(){return h(c)},control:l,$$slots:{control:!0}})}Ce()}Et(["input"]);var Aj=z("<!> <!>",1),ule=z("<!> <!> <!>",1),dle=z("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function OR(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>e.plugin.getTemplateFiles().map(q=>q.path)),i=[q=>new Hi(e.app,q,e.plugin)];function o(q){let B=q.trim();return B?_u(B)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:po(e.app,B)!==null||"Template not found":!0}let s=[{value:"",label:"Follow global setting"},{value:"enabled",label:"Use selection"},{value:"disabled",label:"Ignore selection"}],a=O(()=>typeof t().useSelectionAsCaptureValue=="boolean"?t().useSelectionAsCaptureValue?"enabled":"disabled":"");function l(q){if(q===""){t(t().useSelectionAsCaptureValue=void 0,!0);return}t(t().useSelectionAsCaptureValue=q==="enabled",!0)}function c(q){t().templater||t(t().templater={},!0),t(t().templater.afterCapture=q?"wholeFile":"none",!0)}var u=dle(),d=Pe(u);py(d,{get app(){return e.app},get name(){return t().name},set name(q){t(t().name=q,!0)}});var f=A(d,2);$e(f,{name:"Location",heading:!0});var p=A(f,2);IR(p,{get app(){return e.app},get plugin(){return e.plugin},get choice(){return t()},set choice(q){t(q)}});var m=A(p,2);{var v=q=>{var B=Aj(),ie=Pe(B);$e(ie,{name:"Create file if it doesn't exist",control:ae=>{lr(ae,{get checked(){return t().createFileIfItDoesntExist.enabled},set checked(pe){t(t().createFileIfItDoesntExist.enabled=pe,!0)}})},$$slots:{control:!0}});var W=A(ie,2);{var Y=X=>{ss(X,{name:"Create file with a template",desc:"Path to the template QuickAdd applies to the new file.",get bodyVisible(){return t().createFileIfItDoesntExist.createWithTemplate},control:ge=>{lr(ge,{get checked(){return t().createFileIfItDoesntExist.createWithTemplate},set checked(be){t(t().createFileIfItDoesntExist.createWithTemplate=be,!0)}})},children:(ge,be=Vt)=>{Ci(ge,{get id(){return be()},get value(){return t().createFileIfItDoesntExist.template},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:xe=>t(t().createFileIfItDoesntExist.template=xe.trim(),!0)})},$$slots:{control:!0,default:!0}})};ne(W,X=>{t().createFileIfItDoesntExist.enabled&&X(Y)})}$(q,B)};ne(m,q=>{t().captureToActiveFile||q(v)})}var g=A(m,2);$e(g,{name:"Position",heading:!0});var y=A(g,2);$R(y,{get app(){return e.app},get plugin(){return e.plugin},get choice(){return t()},set choice(q){t(q)}});var w=A(y,2);$e(w,{name:"Linking",heading:!0});var x=A(w,2);zC(x,{fileLabel:"captured",get app(){return e.app},get appendLink(){return t().appendLink},set appendLink(q){t(t().appendLink=q,!0)}});var C=A(x,2);$e(C,{name:"Copy link to clipboard",desc:"Copy a link to the captured file after the Capture choice runs.",control:B=>{{let ie=O(()=>t().copyLinkToClipboard??!1);lr(B,{get checked(){return h(ie)},onchange:W=>t(t().copyLinkToClipboard=W,!0)})}},$$slots:{control:!0}});var _=A(C,2);$e(_,{name:"Content",heading:!0});var E=A(_,2);$e(E,{name:"Task",desc:"Formats the value as a task.",control:B=>{lr(B,{get checked(){return t().task},set checked(ie){t(t().task=ie,!0)}})},$$slots:{control:!0}});var D=A(E,2);ss(D,{name:"Capture format",desc:"Set the format of the capture. When off, QuickAdd captures {{VALUE}} on its own - what you type at the prompt, or the current selection.",get bodyVisible(){return t().format.enabled},control:ie=>{lr(ie,{get checked(){return t().format.enabled},set checked(W){t(t().format.enabled=W,!0)}})},children:(ie,W=Vt)=>{var Y=ule(),X=Pe(Y);Ci(X,{get id(){return W()},inputKind:"textarea",placeholder:"Format",required:!0,requiredMessage:"Capture format is required when enabled",get makeSuggesters(){return i},get value(){return t().format.format},set value(ge){t(t().format.format=ge,!0)}});var ae=A(X,2);qp(ae,{get value(){return t().format.format}});var pe=A(ae,2);hs(pe,{get value(){return t().format.format},get app(){return e.app},get plugin(){return e.plugin}}),$(ie,Y)},$$slots:{control:!0,default:!0}});var P=A(D,2);$e(P,{name:"Behavior",heading:!0});var V=A(P,2);{var j=q=>{var B=Aj(),ie=Pe(B);HC(ie,{description:"Open the captured file.",get openFile(){return t().openFile},set openFile(X){t(t().openFile=X,!0)}});var W=A(ie,2);{var Y=X=>{jC(X,{contextLabel:"captured",get fileOpening(){return t().fileOpening},set fileOpening(ae){t(t().fileOpening=ae,!0)}})};ne(W,X=>{t().openFile&&X(Y)})}$(q,B)};ne(V,q=>{t().captureToActiveFile||q(j)})}var oe=A(V,2);$e(oe,{name:"Use editor selection as default value",desc:"Controls whether this Capture uses the current editor selection as {{VALUE}}. Does not affect {{SELECTED}}.",control:B=>{Jt(B,{get value(){return h(a)},get options(){return s},onchange:l})},$$slots:{control:!0}});var se=A(oe,2);$e(se,{name:"Run Templater on entire destination file after capture",desc:"Advanced / legacy: this executes any <% %> anywhere in the destination file (including inside code blocks).",control:B=>{{let ie=O(()=>t().templater?.afterCapture==="wholeFile");lr(B,{get checked(){return h(ie)},onchange:c})}},$$slots:{control:!0}});var M=A(se,2);GC(M,{get onePageInput(){return t().onePageInput},set onePageInput(q){t(t().onePageInput=q,!0)}});var U=A(M,2);QC(U,{get type(){return t().type},get app(){return e.app},get icon(){return t().icon},set icon(q){t(t().icon=q,!0)}}),$(r,u),Ce()}function kj(r){return bt({...r,choice:fa(r.choice)})}var Sj=require("obsidian");function yh(r){return fa(r)}function RA(r,e){if(r.containerEl.addClass("qa-choice-builder"),r.modalEl.querySelector(".qa-builder-footer"))return;let t=r.modalEl.ownerDocument,n=t.createElement("div");n.className="qa-builder-footer";let i=t.createElement("span");i.className="qa-builder-footer-note",i.textContent=`Changes to this ${e} are saved automatically`,n.appendChild(i);let o=t.createElement("button");o.type="button",o.className="mod-cta",o.textContent="Done",o.addEventListener("click",()=>r.close()),n.appendChild(o),r.modalEl.appendChild(n)}var bh=class extends Sj.Modal{constructor(t){super(t);this.svelteElements=[];this.waitForClose=new Promise(n=>{this.resolvePromise=n}),this.containerEl.addClass("quickAddModal"),RA(this,"choice"),this.open()}destroySvelteElements(){this.svelteElements.forEach(t=>t.destroy()),this.svelteElements=[]}getResultChoice(){return this.choice}onClose(){super.onClose(),this.destroySvelteElements(),this.resolvePromise(yh(this.getResultChoice()))}};var wh=class extends bh{constructor(t,n,i){super(t);this.plugin=i;this.choice=n,this.normalizeChoice(),this.display()}normalizeChoice(){this.choice.insertBefore||(this.choice.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:uo}),this.choice.activeFileWritePosition||(this.choice.activeFileWritePosition="cursor"),this.choice.createFileIfItDoesntExist||(this.choice.createFileIfItDoesntExist={enabled:!1,createWithTemplate:!1,template:""}),!this.choice.captureToActiveFile&&!bu(this.choice.captureTo)&&(this.choice.captureToCanvasNodeId=""),this.choice.openFile&&(this.choice.fileOpening=dn(this.choice.fileOpening))}display(){this.containerEl.addClass("captureChoiceBuilder"),this.formProps=kj({choice:this.choice,app:this.app,plugin:this.plugin});let t=qi(this.contentEl,OR,this.formProps,{what:"this capture choice's settings"});t.ok||(this.formProps=void 0),this.svelteElements.push(t)}getResultChoice(){return this.formProps?.choice??this.choice}};Tt();var Ij=[{id:"prompt",label:"Ask every time"},{id:"update",label:"Update existing file"},{id:"create",label:"Create another file"},{id:"keep",label:"Keep existing file"}],NR=[{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"}],ple=new Map(NR.map(r=>[r.id,r])),fle={update:"appendBottom",create:"duplicateSuffix",keep:"doNothing"},Dj={"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"},mle={increment:hle,duplicateSuffix:gle};function Ch(r){let e=ple.get(r);if(!e)throw new Error(`Unknown file exists mode: ${r}`);return e}function Pj(r){return NR.filter(e=>e.category===r)}function Fj(r){return Ch(r).category}function Mj(){return[...NR]}function Rj(r){return r.kind==="prompt"?"prompt":Fj(r.mode)}function $j(r,e){return r==="prompt"?{kind:"prompt"}:e?.kind==="apply"&&Fj(e.mode)===r?e:{kind:"apply",mode:fle[r]}}function Oj(r){return typeof r!="string"||!Object.prototype.hasOwnProperty.call(Dj,r)?null:Dj[r]??null}async function Nj(r,e,t){return await mle[e](r,t)}async function hle(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=Lj(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 gle(r,e){let t=r;for(;await e(t);){let{basename:n,extension:i}=Lj(t),o=n.match(/^(.*) \((\d+)\)$/);t=`${o?`${o[1]} (${String(BigInt(o[2])+1n)})`:`${n} (1)`}${i}`}return t}function Lj(r){return qr.test(r)?{basename:r.replace(qr,""),extension:".canvas"}:Vi.test(r)?{basename:r.replace(Vi,""),extension:".base"}:{basename:r.replace(ir,""),extension:".md"}}Me();qt();fl();var $A=class extends mn{constructor(t,n,i,o){super(t,n);this.app=t;this.inputEl=n;this.suggestItems=i;this.currentItems=o}updateCurrentItems(t){this.currentItems=t}getSuggestions(t){return this.suggestItems.filter(n=>n.contains(t))}selectSuggestion(t){this.inputEl.value=t,this.inputEl.trigger("input"),this.close()}renderSuggestion(t,n){t&&n.setText(t)}};function OA(r){let e=t=>t.stopPropagation();return r.addEventListener("mousedown",e),r.addEventListener("touchstart",e,{passive:!0}),{destroy(){r.removeEventListener("mousedown",e),r.removeEventListener("touchstart",e)}}}var vle=z('<button type="button"><!></button>');function er(r,e){let t=he(e,"size",3,16),n=he(e,"extraClass",3,""),i=he(e,"disabled",3,!1);var o=vle();let s;var a=I(o);Rt(a,{get iconId(){return e.iconId},get size(){return t()}}),S(o),Fr(o,l=>OA?.(l)),de(()=>{s=wt(o,1,`qa-icon-button ${n()}`,null,s,{"is-pressed":e.ariaPressed===!0}),ke(o,"aria-label",e.label),ke(o,"aria-pressed",e.ariaPressed),ke(o,"aria-haspopup",e.ariaHasPopup),ke(o,"title",e.title),o.disabled=i()}),De("click",o,function(...l){e.onclick?.apply(this,l)}),$(r,o)}Et(["click"]);var yle=z('<div class="quickAddCommandListItem svelte-ee11ws"><span> </span> <!></div>'),ble=z('<div class="quickAddFolderListGrid quickAddCommandList svelte-ee11ws"></div>'),wle={hash:"svelte-ee11ws",code:`.quickAddCommandListItem.svelte-ee11ws {display:flex;align-items:center;justify-content:space-between;}
|
||
|
||
@media (min-width: 768px) {.quickAddFolderListGrid.svelte-ee11ws {display:grid;grid-template-columns:repeat(2, 1fr);column-gap:20px;}
|
||
}.quickAddCommandList.svelte-ee11ws {max-width:50%;margin:12px auto;}`};function LR(r,e){we(e,!0),ot(r,wle);var t=ble();ar(t,20,()=>e.folders,n=>n,(n,i)=>{var o=yle(),s=I(o),a=I(s,!0);S(s);var l=A(s,2);{let c=O(()=>`Remove folder ${i}`);er(l,{iconId:"trash-2",get label(){return h(c)},onclick:()=>e.deleteFolder(i)})}S(o),de(()=>me(a,i)),$(n,o)}),S(t),$(r,t),Ce()}function Bj(r){return r.enabled?r.chooseWhenCreatingNote?"prompt":r.createInSameFolderAsActiveFile?"active-file":"specified":"obsidian-default"}function Uj(r,e){switch(e){case"obsidian-default":return{...r,enabled:!1,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"specified":return{...r,enabled:!0,chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1};case"active-file":return{...r,enabled:!0,createInSameFolderAsActiveFile:!0,chooseWhenCreatingNote:!1};case"prompt":return{...r,enabled:!0,chooseWhenCreatingNote:!0,createInSameFolderAsActiveFile:!1}}}var Vj=[{value:"obsidian-default",label:"Obsidian default"},{value:"specified",label:"In a specific folder"},{value:"active-file",label:"Same folder as current file"},{value:"prompt",label:"Ask for folder each time"}],qj={"obsidian-default":"Use Obsidian's \u201CDefault location for new notes\u201D setting.",specified:"Create the note in the folder(s) below. With multiple folders, you'll be asked which one when the note is created.","active-file":"Create the note next to the currently active file (falls back to the vault root if no file is open).",prompt:"Choose any folder in the vault when the note is created."};Tt();Tt();function NA(r,e){if(!r.fileNameFormat?.enabled)return!0;let t=e.trim().toLowerCase();return t===Ms.toLowerCase()||t===N2.toLowerCase()}function BR(r,e){return r.discoverExistingNotesBeforeCreate===!0&&NA(r,e)}function UR(r,e,t){return!(!BR(r,e)||t!=null)}Tt();function LA(r){if(!r?.enabled||r.chooseWhenCreatingNote||r.chooseFromSubfolders||r.createInSameFolderAsActiveFile)return;let e=r.folders??[];if(e.length!==1)return;let t=e[0]?.trim();if(t&&!t.includes("{{")&&!dc.test(t))return t}var Cle=z("<!> <!> <!>",1),xle=z(`<div class="qa-folder-mode-warning">Add at least one folder. With none, the note falls back to the active
|
||
file's folder (or you'll be prompted to pick one if no file is open).</div>`),Ele=z('<div class="folderSelectionContainer"><div class="folderList"><!></div> <div class="folderInputContainer"><input type="text" class="qa-folder-path-input" placeholder="Folder path" aria-label="Folder path"/> <button type="button" class="mod-cta">Add</button></div></div> <!> <!>',1),Tle=z("<!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!> <!>",1);function VR(r,e){we(e,!0);let t=he(e,"choice",15),n=O(()=>e.plugin.getTemplateFiles().map(ye=>ye.path)),i=O(()=>Nc(Ns(e.app)));function o(ye){let We=ye.trim();return We?_u(We)?{valid:!0,message:"Contains format syntax \u2014 resolved at run time."}:po(e.app,We)!==null||"Template not found":!0}let s=[ye=>new Hi(e.app,ye,e.plugin,"fileName")],a=O(()=>NA(t(),t().fileNameFormat.enabled?t().fileNameFormat.format:Ms)),l=O(()=>h(a)?"For the default note-title prompt, show matching notes first. Choosing one opens it unchanged; choosing the create row continues with this template.":"Only available when the file name prompt is the default note title: no custom format, {{VALUE}}, or {{NAME}}."),c=O(()=>Bj(t().folder)),u=O(()=>qj[h(c)]),d=O(()=>h(c)==="specified"&&t().folder.folders.length===0);function f(ye){t(t().folder=Uj(t().folder,ye),!0)}let p=Ae(""),m;function v(ye){return m=new $A(e.app,ye,h(i),t().folder.folders),m}hr(()=>{m?.updateCurrentItems(t().folder.folders)});function g(){let ye=h(p).trim();if(ye){if(t().folder.folders.some(We=>We===ye)){F.logWarning("cannot add same folder twice.");return}t().folder.folders.push(ye),Z(p,"")}}function y(ye){t(t().folder.folders=t().folder.folders.filter(We=>We!==ye),!0)}function w(ye){ye.key==="Enter"&&g()}let x=O(()=>Rj(t().fileExistsBehavior)),C=O(()=>h(x)!=="prompt"&&h(x)!=="keep"),_=O(()=>Pj(h(x)==="update"?"update":"create")),E=O(()=>t().fileExistsBehavior.kind==="apply"?t().fileExistsBehavior.mode:h(_)[0].id);function D(ye){t(t().fileExistsBehavior=$j(ye,t().fileExistsBehavior),!0)}function P(ye){t(t().fileExistsBehavior={kind:"apply",mode:ye},!0)}var V=Tle(),j=Pe(V);py(j,{get app(){return e.app},get name(){return t().name},set name(ye){t(t().name=ye,!0)}});var oe=A(j,2);$e(oe,{name:"Template",heading:!0});var se=A(oe,2);ss(se,{name:"Template path",desc:"Path to the template this choice creates notes from.",children:(We,mt=Vt)=>{Ci(We,{get id(){return mt()},get value(){return t().templatePath},placeholder:"Template path",get app(){return e.app},get suggestions(){return h(n)},maxSuggestions:50,validator:o,onChange:He=>t(t().templatePath=He.trim(),!0)})},$$slots:{default:!0}});var M=A(se,2);ss(M,{name:"File name format",desc:"Set the file name format. When off, QuickAdd asks for the note title.",get bodyVisible(){return t().fileNameFormat.enabled},control:mt=>{lr(mt,{get checked(){return t().fileNameFormat.enabled},set checked(He){t(t().fileNameFormat.enabled=He,!0)}})},children:(mt,He=Vt)=>{var _e=Cle(),Be=Pe(_e);Ci(Be,{get id(){return He()},placeholder:"File name format",get makeSuggesters(){return s},get value(){return t().fileNameFormat.format},set value(yr){t(t().fileNameFormat.format=yr,!0)}});var ut=A(Be,2);qp(ut,{get value(){return t().fileNameFormat.format}});var or=A(ut,2);{let yr=O(()=>LA(t().folder));hs(or,{get value(){return t().fileNameFormat.format},formatterKind:"fileName",get targetFolderPath(){return h(yr)},get app(){return e.app},get plugin(){return e.plugin}})}$(mt,_e)},$$slots:{control:!0,default:!0}});var U=A(M,2);$e(U,{name:"Location",heading:!0});var q=A(U,2);$e(q,{name:"New note location",get desc(){return h(u)},control:We=>{Jt(We,{get value(){return h(c)},get options(){return Vj},ariaLabel:"New note location",onchange:f})},$$slots:{control:!0}});var B=A(q,2);{var ie=ye=>{var We=Ele(),mt=Pe(We),He=I(mt),_e=I(He);LR(_e,{get folders(){return t().folder.folders},deleteFolder:y}),S(He);var Be=A(He,2),ut=I(Be);gr(ut),cn(()=>co(ut,()=>h(p),ur=>Z(p,ur))),Fr(ut,(ur,dt)=>hp?.(ur,dt),()=>v);var or=A(ut,2);S(Be),S(mt);var yr=A(mt,2);{var Pt=ur=>{var dt=xle();$(ur,dt)};ne(yr,ur=>{h(d)&&ur(Pt)})}var Ar=A(yr,2);$e(Ar,{name:"Include subfolders",desc:"Get prompted to choose from both the selected folders and their subfolders when creating the note.",control:dt=>{lr(dt,{get checked(){return t().folder.chooseFromSubfolders},set checked(Ft){t(t().folder.chooseFromSubfolders=Ft,!0)}})},$$slots:{control:!0}}),oc("keypress",ut,w),De("click",or,g),$(ye,We)};ne(B,ye=>{h(c)==="specified"&&ye(ie)})}var W=A(B,2);$e(W,{name:"Linking",heading:!0});var Y=A(W,2);zC(Y,{fileLabel:"created",get app(){return e.app},get appendLink(){return t().appendLink},set appendLink(ye){t(t().appendLink=ye,!0)}});var X=A(Y,2);$e(X,{name:"Copy link to clipboard",desc:"Copy a link to the created file after the Template choice runs.",control:We=>{{let mt=O(()=>t().copyLinkToClipboard??!1);lr(We,{get checked(){return h(mt)},onchange:He=>t(t().copyLinkToClipboard=He,!0)})}},$$slots:{control:!0}});var ae=A(X,2);$e(ae,{name:"Behavior",heading:!0});var pe=A(ae,2);$e(pe,{name:"Search existing notes before creating",get desc(){return h(l)},control:We=>{{let mt=O(()=>h(a)?t().discoverExistingNotesBeforeCreate??!1:!1),He=O(()=>!h(a));lr(We,{get checked(){return h(mt)},get disabled(){return h(He)},onchange:_e=>t(t().discoverExistingNotesBeforeCreate=_e,!0)})}},$$slots:{control:!0}});var ge=A(pe,2);$e(ge,{name:"If the target file already exists",desc:"Choose whether QuickAdd should ask what to do, update the existing file, create another file, or keep the existing file.",control:We=>{{let mt=O(()=>Ij.map(He=>({value:He.id,label:He.label})));Jt(We,{get value(){return h(x)},get options(){return h(mt)},onchange:D})}},$$slots:{control:!0}});var be=A(ge,2);{var xe=ye=>{{let We=_e=>{{let Be=O(()=>h(_).map(ut=>({value:ut.id,label:ut.label})));Jt(_e,{get value(){return h(E)},get options(){return h(Be)},onchange:P})}},mt=O(()=>h(x)==="update"?"Update action":"New file naming"),He=O(()=>Ch(h(E)).description);$e(ye,{get name(){return h(mt)},get desc(){return h(He)},control:We,$$slots:{control:!0}})}};ne(be,ye=>{h(C)&&ye(xe)})}var Ue=A(be,2);HC(Ue,{description:"Open the created file.",get openFile(){return t().openFile},set openFile(ye){t(t().openFile=ye,!0)}});var $t=A(Ue,2);{var Ne=ye=>{jC(ye,{contextLabel:"created",get fileOpening(){return t().fileOpening},set fileOpening(We){t(t().fileOpening=We,!0)}})};ne($t,ye=>{t().openFile&&ye(Ne)})}var Ke=A($t,2);GC(Ke,{get onePageInput(){return t().onePageInput},set onePageInput(ye){t(t().onePageInput=ye,!0)}});var Qe=A(Ke,2);QC(Qe,{get type(){return t().type},get app(){return e.app},get icon(){return t().icon},set icon(ye){t(t().icon=ye,!0)}}),$(r,V),Ce()}Et(["click"]);function Wj(r){return bt({...r,choice:fa(r.choice)})}var xh=class extends bh{constructor(t,n,i){super(t);this.plugin=i;this.choice=n,this.normalizeChoice(),this.display()}normalizeChoice(){var t,n,i,o,s,a,l,c,u,d,f;(t=this.choice).fileExistsBehavior??(t.fileExistsBehavior={kind:"prompt"}),this.choice.fileOpening=dn(this.choice.fileOpening),(n=this.choice).templatePath??(n.templatePath=""),(i=this.choice).fileNameFormat??(i.fileNameFormat={enabled:!1,format:""}),(o=this.choice.fileNameFormat).enabled??(o.enabled=!1),(s=this.choice.fileNameFormat).format??(s.format=""),(a=this.choice).folder??(a.folder={enabled:!1,folders:[],chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1,chooseFromSubfolders:!1}),(l=this.choice.folder).enabled??(l.enabled=!1),(c=this.choice.folder).folders??(c.folders=[]),(u=this.choice.folder).chooseWhenCreatingNote??(u.chooseWhenCreatingNote=!1),(d=this.choice.folder).createInSameFolderAsActiveFile??(d.createInSameFolderAsActiveFile=!1),(f=this.choice.folder).chooseFromSubfolders??(f.chooseFromSubfolders=!1)}display(){this.containerEl.addClass("templateChoiceBuilder"),this.formProps=Wj({choice:this.choice,app:this.app,plugin:this.plugin});let t=qi(this.contentEl,VR,this.formProps,{what:"this template choice's settings"});t.ok||(this.formProps=void 0),this.svelteElements.push(t)}getResultChoice(){return this.formProps?.choice??this.choice}};Wp();var Nk=require("obsidian");zs();var Fi=require("obsidian");var zG=require("obsidian");function Hj(r,e){var t=Object.keys(r);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(r);e&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(r,i).enumerable})),t.push.apply(t,n)}return t}function qA(r){for(var e=1;e<arguments.length;e++){var t=arguments[e]!=null?arguments[e]:{};e%2?Hj(Object(t),!0).forEach(function(n){Ah(r,n,t[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(t)):Hj(Object(t)).forEach(function(n){Object.defineProperty(r,n,Object.getOwnPropertyDescriptor(t,n))})}return r}function Eh(r){"@babel/helpers - typeof";return Eh=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Eh(r)}function Ah(r,e,t){return e in r?Object.defineProperty(r,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):r[e]=t,r}function Ale(r,e){if(r==null)return{};var t={},n=Object.keys(r),i,o;for(o=0;o<n.length;o++)i=n[o],!(e.indexOf(i)>=0)&&(t[i]=r[i]);return t}function kle(r,e){if(r==null)return{};var t=Ale(r,e),n,i;if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(r);for(i=0;i<o.length;i++)n=o[i],!(e.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(r,n)&&(t[n]=r[n])}return t}function Sle(r,e){return Ile(r)||Fle(r,e)||e$(r,e)||Rle()}function Js(r){return Dle(r)||Ple(r)||e$(r)||Mle()}function Dle(r){if(Array.isArray(r))return zR(r)}function Ile(r){if(Array.isArray(r))return r}function Ple(r){if(typeof Symbol<"u"&&r[Symbol.iterator]!=null||r["@@iterator"]!=null)return Array.from(r)}function Fle(r,e){var t=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(t!=null){var n=[],i=!0,o=!1,s,a;try{for(t=t.call(r);!(i=(s=t.next()).done)&&(n.push(s.value),!(e&&n.length===e));i=!0);}catch(l){o=!0,a=l}finally{try{!i&&t.return!=null&&t.return()}finally{if(o)throw a}}return n}}function e$(r,e){if(r){if(typeof r=="string")return zR(r,e);var t=Object.prototype.toString.call(r).slice(8,-1);if(t==="Object"&&r.constructor&&(t=r.constructor.name),t==="Map"||t==="Set")return Array.from(r);if(t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return zR(r,e)}}function zR(r,e){(e==null||e>r.length)&&(e=r.length);for(var t=0,n=new Array(e);t<e;t++)n[t]=r[t];return n}function Mle(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
|
||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Rle(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function Gp(r,e){var t=typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(!t){if(Array.isArray(r)||(t=e$(r))||e&&r&&typeof r.length=="number"){t&&(r=t);var n=0,i=function(){};return{s:i,n:function(){return n>=r.length?{done:!0}:{done:!1,value:r[n++]}},e:function(l){throw l},f:i}}throw new TypeError(`Invalid attempt to iterate non-iterable instance.
|
||
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var o=!0,s=!1,a;return{s:function(){t=t.call(r)},n:function(){var l=t.next();return o=l.done,l},e:function(l){s=!0,a=l},f:function(){try{!o&&t.return!=null&&t.return()}finally{if(s)throw a}}}}var $le="finalize",Ole="consider";function kh(r,e,t){r.dispatchEvent(new CustomEvent($le,{detail:{items:e,info:t}}))}function Ju(r,e,t){r.dispatchEvent(new CustomEvent(Ole,{detail:{items:e,info:t}}))}var XA="draggedEntered",sx="draggedLeft",QA="draggedOverIndex",t$="draggedLeftDocument",WA={LEFT_FOR_ANOTHER:"leftForAnother",OUTSIDE_OF_ANY:"outsideOfAny"};function Nle(r,e,t){r.dispatchEvent(new CustomEvent(XA,{detail:{indexObj:e,draggedEl:t}}))}function Lle(r,e,t){r.dispatchEvent(new CustomEvent(sx,{detail:{draggedEl:e,type:WA.LEFT_FOR_ANOTHER,theOtherDz:t}}))}function Ble(r,e){r.dispatchEvent(new CustomEvent(sx,{detail:{draggedEl:e,type:WA.OUTSIDE_OF_ANY}}))}function Ule(r,e,t){r.dispatchEvent(new CustomEvent(QA,{detail:{indexObj:e,draggedEl:t}}))}function Vle(r){window.dispatchEvent(new CustomEvent(t$,{detail:{draggedEl:r}}))}var Ai={DRAG_STARTED:"dragStarted",DRAGGED_ENTERED:XA,DRAGGED_ENTERED_ANOTHER:"dragEnteredAnother",DRAGGED_OVER_INDEX:QA,DRAGGED_LEFT:sx,DRAGGED_LEFT_ALL:"draggedLeftAll",DROPPED_INTO_ZONE:"droppedIntoZone",DROPPED_INTO_ANOTHER:"droppedIntoAnother",DROPPED_OUTSIDE_OF_ANY:"droppedOutsideOfAny",DRAG_STOPPED:"dragStopped"},Qi={POINTER:"pointer",KEYBOARD:"keyboard"},ZA="isDndShadowItem",JA="data-is-dnd-shadow-item-internal",qle="data-is-dnd-shadow-item-hint",ek="id:dnd-shadow-placeholder-0000",Wle="dnd-action-dragged-el",qn="id",HR=0;function rG(){HR++}function nG(){if(HR===0)throw new Error("Bug! trying to decrement when there are no dropzones");HR--}var r$=typeof window>"u",Ct=function(){};function jR(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0,t,n=e?jle(r):r.getBoundingClientRect(),i=getComputedStyle(r),o=i.transform;if(o){var s,a,l,c;if(o.startsWith("matrix3d("))t=o.slice(9,-1).split(/, /),s=+t[0],a=+t[5],l=+t[12],c=+t[13];else if(o.startsWith("matrix("))t=o.slice(7,-1).split(/, /),s=+t[0],a=+t[3],l=+t[4],c=+t[5];else return n;var u=i.transformOrigin,d=n.x-l-(1-s)*parseFloat(u),f=n.y-c-(1-a)*parseFloat(u.slice(u.indexOf(" ")+1)),p=s?n.width/s:r.offsetWidth,m=a?n.height/a:r.offsetHeight;return{x:d,y:f,width:p,height:m,top:f,right:d+p,bottom:f+m,left:d}}else return n}function GR(r){var e=jR(r);return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function iG(r){var e=r.getBoundingClientRect();return{top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}}function oG(r){return{x:(r.left+r.right)/2,y:(r.top+r.bottom)/2}}function zle(r,e){return Math.sqrt(Math.pow(r.x-e.x,2)+Math.pow(r.y-e.y,2))}function rx(r,e){return r.y<=e.bottom&&r.y>=e.top&&r.x>=e.left&&r.x<=e.right}function sG(r){return oG(iG(r))}function jj(r,e){var t=sG(e);return zle(r,t)}function Hle(r){var e=iG(r);return e.right<0||e.left>document.documentElement.scrollWidth||e.bottom<0||e.top>document.documentElement.scrollHeight}function jle(r){for(var e=r.getBoundingClientRect(),t={top:e.top,bottom:e.bottom,left:e.left,right:e.right},n=!1,i=!1,o=r.parentElement;o&&o!==document.body;){var s=window.getComputedStyle(o),a=s.overflowY,l=s.overflowX,c=a==="scroll"||a==="auto",u=l==="scroll"||l==="auto";if(c||u){var d=o.getBoundingClientRect();if(c){var f=Math.max(t.top,d.top),p=Math.min(t.bottom,d.bottom);(f!==t.top||p!==t.bottom)&&(n=!0),t.top=f,t.bottom=p}if(u){var m=Math.max(t.left,d.left),v=Math.min(t.right,d.right);(m!==t.left||v!==t.right)&&(i=!0),t.left=m,t.right=v}}o=o.parentElement}return n||i?{top:t.top,bottom:t.bottom,left:t.left,right:t.right,width:Math.max(0,t.right-t.left),height:Math.max(0,t.bottom-t.top)}:{top:e.top,bottom:e.bottom,left:e.left,right:e.right,width:Math.max(0,e.right-e.left),height:Math.max(0,e.bottom-e.top)}}var _h;function n$(){Ct(function(){return"resetting indexes cache"}),_h=new Map}n$();function Gle(r){var e=Array.from(r.children).findIndex(function(t){return t.getAttribute(JA)});if(e>=0)return _h.has(r)||_h.set(r,new Map),_h.get(r).set(e,GR(r.children[e])),e}function Yle(r,e){var t=GR(e);if(!rx(r,t))return null;var n=e.children;if(n.length===0)return{index:0,isProximityBased:!0};for(var i=Gle(e),o=0;o<n.length;o++){var s=GR(n[o]);if(rx(r,s)){var a=_h.has(e)&&_h.get(e).get(o);return a&&!rx(r,a)?{index:i,isProximityBased:!1}:{index:o,isProximityBased:!1}}}for(var l=Number.MAX_VALUE,c=void 0,u=0;u<n.length;u++){var d=jj(r,n[u]);d<l&&(l=d,c=u)}if(n.length>0){var f=n.length,p=n[f-1],m=p.cloneNode(!1);m.style.visibility="hidden",m.style.pointerEvents="none",e.appendChild(m);var v=jj(r,m);v<l&&(c=f),e.removeChild(m)}return{index:c,isProximityBased:!0}}function Oa(r){return JSON.stringify(r,null,2)}function zA(r){if(!r)throw new Error("cannot get depth of a falsy node");return aG(r,0)}function aG(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0;return r.parentElement?aG(r.parentElement,e+1):e-1}function Kle(r,e){if(Object.keys(r).length!==Object.keys(e).length)return!1;for(var t in r)if(!{}.hasOwnProperty.call(e,t)||e[t]!==r[t])return!1;return!0}function Xle(r,e){if(r.length!==e.length)return!1;for(var t=0;t<r.length;t++)if(r[t]!==e[t])return!1;return!0}var Qle=200,Gj=10,YR;function Zle(r,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:Qle,n=arguments.length>3?arguments[3]:void 0,i=arguments.length>4?arguments[4]:void 0,o,s,a=!1,l,c=Array.from(e).sort(function(d,f){return zA(f)-zA(d)});function u(){var d=i(),f=n.multiScrollIfNeeded();if(!f&&l&&Math.abs(l.x-d.x)<Gj&&Math.abs(l.y-d.y)<Gj){YR=window.setTimeout(u,t);return}if(Hle(r)){Ct(function(){return"off document"}),Vle(r);return}l=d;var p=!1,m=Gp(c),v;try{for(m.s();!(v=m.n()).done;){var g=v.value;f&&n$();var y=Yle(d,g);if(y!==null){var w=y.index;p=!0,g!==o?(o&&Lle(o,r,g),Nle(g,y,r),o=g):w!==s&&(Ule(g,y,r),s=w);break}}}catch(x){m.e(x)}finally{m.f()}!p&&a&&o?(Ble(o,r),o=void 0,s=void 0,a=!1):a=!0,YR=window.setTimeout(u,t)}u()}function Jle(){Ct(function(){return"unobserving"}),clearTimeout(YR),n$()}var JC=30;function ece(){var r;function e(){r={directionObj:void 0,stepPx:0}}e();function t(o){var s=r,a=s.directionObj,l=s.stepPx;a&&(o.scrollBy(a.x*l,a.y*l),window.requestAnimationFrame(function(){return t(o)}))}function n(o){return JC-o}function i(o,s){if(!s)return!1;var a=tce(o,s),l=!!r.directionObj;if(a===null)return l&&e(),!1;var c=!1,u=!1;return s.scrollHeight>s.clientHeight&&(a.bottom<JC?(c=!0,r.directionObj={x:0,y:1},r.stepPx=n(a.bottom)):a.top<JC&&(c=!0,r.directionObj={x:0,y:-1},r.stepPx=n(a.top)),!l&&c)||s.scrollWidth>s.clientWidth&&(a.right<JC?(u=!0,r.directionObj={x:1,y:0},r.stepPx=n(a.right)):a.left<JC&&(u=!0,r.directionObj={x:-1,y:0},r.stepPx=n(a.left)),!l&&u)?(t(s),!0):(e(),!1)}return{scrollIfNeeded:i,resetScrolling:e}}function tce(r,e){var t=e===document.scrollingElement?{top:0,bottom:window.innerHeight,left:0,right:window.innerWidth}:e.getBoundingClientRect();return rx(r,t)?{top:r.y-t.top,bottom:t.bottom-r.y,left:r.x-t.left,right:t.right-r.x}:null}function rce(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],e=arguments.length>1?arguments[1]:void 0;Ct(function(){return"creating multi-scroller"});var t=ice(r),n=Array.from(t).sort(function(l,c){return zA(c)-zA(l)}),i=ece(),o=i.scrollIfNeeded,s=i.resetScrolling;function a(){var l=e();if(!l||!n)return!1;for(var c=n.filter(function(f){return rx(l,f.getBoundingClientRect())||f===document.scrollingElement}),u=0;u<c.length;u++){var d=o(l,c[u]);if(d)return!0}return!1}return{multiScrollIfNeeded:t.size>0?a:function(){return!1},destroy:function(){return s()}}}function nce(r){if(!r)return[];for(var e=[],t=r;t;){var n=window.getComputedStyle(t),i=n.overflow;i.split(" ").some(function(o){return o.includes("auto")||o.includes("scroll")})&&e.push(t),t=t.parentElement}return e}function ice(r){var e=new Set,t=Gp(r),n;try{for(t.s();!(n=t.n()).done;){var i=n.value;nce(i).forEach(function(o){return e.add(o)})}}catch(o){t.e(o)}finally{t.f()}return(document.scrollingElement.scrollHeight>document.scrollingElement.clientHeight||document.scrollingElement.scrollWidth>document.scrollingElement.clientHeight)&&e.add(document.scrollingElement),e}function oce(r){var e=r.cloneNode(!0),t=[],n=r.tagName==="SELECT",i=n?[r]:Js(r.querySelectorAll("select")),o=Gp(i),s;try{for(o.s();!(s=o.n()).done;){var a=s.value;t.push(a.value)}}catch(x){o.e(x)}finally{o.f()}if(i.length>0)for(var l=n?[e]:Js(e.querySelectorAll("select")),c=0;c<l.length;c++){var u=l[c],d=t[c],f=u.querySelector('option[value="'.concat(d,'"'));f&&f.setAttribute("selected",!0)}var p=r.tagName==="CANVAS",m=p?[r]:Js(r.querySelectorAll("canvas"));if(m.length>0)for(var v=p?[e]:Js(e.querySelectorAll("canvas")),g=0;g<v.length;g++){var y=m[g],w=v[g];w.width=y.width,w.height=y.height,y.width>0&&y.height>0&&w.getContext("2d").drawImage(y,0,0)}return e}var ix=Object.freeze({USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT:"USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT"}),sce=Ah({},ix.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT,!1);function lG(r){if(!ix[r])throw new Error("Can't get non existing feature flag ".concat(r,"! Supported flags: ").concat(Object.keys(ix)));return sce[r]}var ace=.2;function Hp(r){return"".concat(r," ").concat(ace,"s ease")}function cG(r){var e=r.style.transitionProperty.split(",").map(function(t){return t.trim()});e.includes("all")||(e.includes("width")||(r.style.transition+=", ".concat(Hp("width"))),e.includes("height")||(r.style.transition+=", ".concat(Hp("height"))))}function lce(r,e){var t=r.getBoundingClientRect(),n=oce(r);uG(r,n),n.id=Wle,n.style.position="fixed";var i=t.top,o=t.left;if(n.style.top="".concat(i,"px"),n.style.left="".concat(o,"px"),e){var s=oG(t);i-=s.y-e.y,o-=s.x-e.x,window.setTimeout(function(){n.style.top="".concat(i,"px"),n.style.left="".concat(o,"px")},0)}return n.style.margin="0",n.style.boxSizing="border-box",n.style.height="".concat(t.height,"px"),n.style.width="".concat(t.width,"px"),n.style.transition="".concat(Hp("top"),", ").concat(Hp("left"),", ").concat(Hp("background-color"),", ").concat(Hp("opacity"),", ").concat(Hp("color")," "),window.setTimeout(function(){return cG(n)},0),n.style.zIndex="9999",n.style.cursor="grabbing",n}function cce(r){r.style.cursor="grab"}function uce(r,e,t,n){cG(r),uG(e,r);var i=e.getBoundingClientRect(),o=r.getBoundingClientRect(),s=window.getComputedStyle(r),a=parseFloat(s.left),l=parseFloat(s.top),c=i.width-o.width,u=i.height-o.height;if(c||u){var d={left:o.width?(t-o.left)/o.width:0,top:o.height?(n-o.top)/o.height:0};lG(ix.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)||(r.style.height="".concat(i.height,"px"),r.style.width="".concat(i.width,"px")),r.style.left="".concat(a-d.left*c,"px"),r.style.top="".concat(l-d.top*u,"px")}}function uG(r,e){var t=window.getComputedStyle(r);Array.from(t).filter(function(n){return n.startsWith("background")||n.startsWith("padding")||n.startsWith("font")||n.startsWith("text")||n.startsWith("align")||n.startsWith("justify")||n.startsWith("display")||n.startsWith("flex")||n.startsWith("border")||n==="opacity"||n==="color"||n==="list-style-type"||lG(ix.USE_COMPUTED_STYLE_INSTEAD_OF_BOUNDING_RECT)&&(n==="width"||n==="height")}).forEach(function(n){return e.style.setProperty(n,t.getPropertyValue(n),t.getPropertyPriority(n))})}function dce(r,e){r.draggable=!1,r.ondragstart=function(){return!1},e?(r.style.userSelect="",r.style.WebkitUserSelect="",r.style.cursor=""):(r.style.userSelect="none",r.style.WebkitUserSelect="none",r.style.cursor="grab")}function dG(r){r.style.display="none",r.style.position="fixed",r.style.zIndex="-5"}function pce(r){r.style.visibility="hidden",r.setAttribute(JA,"true")}function fce(r){r.style.visibility="",r.removeAttribute(JA)}function VA(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};r.forEach(function(n){var i=e(n);Object.keys(i).forEach(function(o){n.style[o]=i[o]}),t(n).forEach(function(o){return n.classList.add(o)})})}function HA(r){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:function(){},t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:function(){return[]};r.forEach(function(n){var i=e(n);Object.keys(i).forEach(function(o){n.style[o]=""}),t(n).forEach(function(o){return n.classList.contains(o)&&n.classList.remove(o)})})}function mce(r){var e=r.style.minHeight;r.style.minHeight=window.getComputedStyle(r).getPropertyValue("height");var t=r.style.minWidth;return r.style.minWidth=window.getComputedStyle(r).getPropertyValue("width"),function(){r.style.minHeight=e,r.style.minWidth=t}}var hce="--any--",gce=100,vce=20,BA=3,yce=80,Yj={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Kj="data-is-dnd-original-dragged-item",Ti,Cn,Bo,i$,Or,tk,Zu,ci,Sl,li,Lc=!1,jA=!1,o$,ax=!1,Th=[],nx,Dl,tx=!1,s$=!1,kl,Xu=new Set,Bc=new Map,sn=new Map,ex=new WeakMap;function bce(r,e){Ct(function(){return"registering drop-zone if absent"}),Bc.has(e)||Bc.set(e,new Set),Bc.get(e).has(r)||(Bc.get(e).add(r),rG())}function Xj(r,e){var t=Bc.get(e);!t||!t.delete(r)||(nG(),t.size===0&&Bc.delete(e))}function wce(){Ct(function(){return"watching dragged element"});var r=Bc.get(i$);if(!(!r||r.size===0)){Xu.size>0&&KR(),Xu=new Set(r);var e=Gp(Xu),t;try{for(e.s();!(t=e.n()).done;){var n=t.value;n.addEventListener(XA,pG),n.addEventListener(sx,fG),n.addEventListener(QA,mG)}}catch(a){e.e(a)}finally{e.f()}window.addEventListener(t$,Sh);var i=Math.max.apply(Math,Js(Array.from(Xu).map(function(a){return sn.get(a).dropAnimationDurationMs}))),o=i===0?vce:Math.max(i,gce);nx=rce(Xu,function(){return li});var s=s$?function(){return{x:li.x+window.scrollX,y:li.y+window.scrollY}}:function(){return sG(Cn)};Zle(Cn,Xu,o*1.07,nx,s)}}function KR(){Ct(function(){return"unwatching dragged element"});var r=Gp(Xu),e;try{for(r.s();!(e=r.n()).done;){var t=e.value;t.removeEventListener(XA,pG),t.removeEventListener(sx,fG),t.removeEventListener(QA,mG)}}catch(n){r.e(n)}finally{r.f()}Xu=new Set,window.removeEventListener(t$,Sh),nx&&(nx.destroy(),nx=void 0),Jle()}function rk(r){return r.findIndex(function(e){return!!e[ZA]})}function Cce(r){var e;return qA(qA({},r),{},(e={},Ah(e,ZA,!0),Ah(e,qn,ek),e))}function pG(r){Ct(function(){return["dragged entered",r.currentTarget,r.detail]});var e=sn.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Or){Ct(function(){return"ignoring dragged entered because drop is currently disabled"});return}if(ax=!1,t=t.filter(function(a){return a[qn]!==Zu[qn]&&a[qn]!==ek}),Ct(function(){return"dragged entered items ".concat(Oa(t))}),Or!==r.currentTarget){var i=sn.get(Or).items,o=i.filter(function(a){return!a[ZA]});Ju(Or,o,{trigger:Ai.DRAGGED_ENTERED_ANOTHER,id:Bo[qn],source:Qi.POINTER})}var s=r.detail.indexObj.index;ci=r.currentTarget,t.splice(s,0,Zu),Ju(r.currentTarget,t,{trigger:Ai.DRAGGED_ENTERED,id:Bo[qn],source:Qi.POINTER})}function fG(r){if(Lc){Ct(function(){return["dragged left",r.currentTarget,r.detail]});var e=sn.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Or&&r.currentTarget!==ci){Ct(function(){return"drop is currently disabled"});return}var i=Js(t),o=rk(i);o!==-1&&i.splice(o,1);var s=ci;ci=void 0;var a=r.detail,l=a.type,c=a.theOtherDz;if(l===WA.OUTSIDE_OF_ANY||l===WA.LEFT_FOR_ANOTHER&&c!==Or&&sn.get(c).dropFromOthersDisabled){Ct(function(){return"dragged left all, putting shadow element back in the origin dz"}),ax=!0,ci=Or;var u=s===Or?i:Js(sn.get(Or).items);u.splice(tk,0,Zu),Ju(Or,u,{trigger:Ai.DRAGGED_LEFT_ALL,id:Bo[qn],source:Qi.POINTER})}Ju(r.currentTarget,i,{trigger:Ai.DRAGGED_LEFT,id:Bo[qn],source:Qi.POINTER})}}function mG(r){Ct(function(){return["dragged is over index",r.currentTarget,r.detail]});var e=sn.get(r.currentTarget),t=e.items,n=e.dropFromOthersDisabled;if(n&&r.currentTarget!==Or){Ct(function(){return"drop is currently disabled"});return}var i=Js(t);ax=!1;var o=r.detail.indexObj.index,s=rk(i);s!==-1&&i.splice(s,1),i.splice(o,0,Zu),Ju(r.currentTarget,i,{trigger:Ai.DRAGGED_OVER_INDEX,id:Bo[qn],source:Qi.POINTER})}function GA(r){r.preventDefault();var e=r.touches?r.touches[0]:r;li={x:e.clientX,y:e.clientY},Cn.style.transform="translate3d(".concat(li.x-Sl.x,"px, ").concat(li.y-Sl.y,"px, 0)")}function Sh(){Ct(function(){return"dropped"}),jA=!0,window.removeEventListener("mousemove",GA),window.removeEventListener("touchmove",GA),window.removeEventListener("mouseup",Sh),window.removeEventListener("touchend",Sh),KR(),cce(Cn),ci||(Ct(function(){return"element was dropped right after it left origin but before entering somewhere else"}),ci=Or),Ct(function(){return["dropped in dz",ci]});var r=sn.get(ci),e=r.items,t=r.type;HA(Bc.get(t),function(o){return sn.get(o).dropTargetStyle},function(o){return sn.get(o).dropTargetClasses});var n=rk(e);n===-1&&ci===Or&&(n=tk),e=e.map(function(o){return o[ZA]?Bo:o});function i(){KR(),o$(),kh(ci,e,{trigger:ax?Ai.DROPPED_OUTSIDE_OF_ANY:Ai.DROPPED_INTO_ZONE,id:Bo[qn],source:Qi.POINTER}),ci!==Or&&kh(Or,sn.get(Or).items,{trigger:Ai.DROPPED_INTO_ANOTHER,id:Bo[qn],source:Qi.POINTER});var o=Array.from(ci.children).find(function(s){return s.getAttribute(JA)});o&&fce(o),Tce()}sn.get(ci).dropAnimationDisabled?i():xce(n,i)}function xce(r,e){var t=r>-1?jR(ci.children[r],!1):jR(ci,!1),n={x:t.left-parseFloat(Cn.style.left),y:t.top-parseFloat(Cn.style.top)},i=sn.get(ci),o=i.dropAnimationDurationMs,s="transform ".concat(o,"ms ease");Cn.style.transition=Cn.style.transition?Cn.style.transition+","+s:s,Cn.style.transform="translate3d(".concat(n.x,"px, ").concat(n.y,"px, 0)"),window.setTimeout(e,o)}function Ece(r,e){var t={dz:r,destroy:e};Th.push(t),window.requestAnimationFrame(function(){Th.includes(t)&&(dG(r),document.body.appendChild(r))})}function Tce(){Cn&&Cn.remove&&Cn.remove(),Ti&&Ti.remove&&Ti.remove(),Cn=void 0,Ti=void 0,Bo=void 0,i$=void 0,Or=void 0,tk=void 0,Zu=void 0,ci=void 0,Sl=void 0,li=void 0,Lc=!1,jA=!1,o$=void 0,ax=!1,Dl&&clearTimeout(Dl),Dl=void 0,tx=!1,s$=!1,kl=void 0,Th.length&&(Ct(function(){return["will destroy zones that were removed during drag",Th]}),Th.forEach(function(r){var e=r.dz,t=r.destroy;t(),e.remove()}),Th=[])}function _ce(r,e){var t=!1,n=!1,i={items:void 0,type:void 0,flipDurationMs:0,dragDisabled:!1,morphDisabled:!1,dropFromOthersDisabled:!1,dropTargetStyle:Yj,dropTargetClasses:[],transformDraggedElement:function(){},centreDraggedOnCursor:!1,useCursorForDetection:!1,dropAnimationDisabled:!1,delayTouchStartMs:0};Ct(function(){return["dndzone good to go options: ".concat(Oa(e),", config: ").concat(Oa(i)),{node:r}]});var o=new Map;function s(){window.addEventListener("mousemove",u,{passive:!1}),window.addEventListener("touchmove",u,{passive:!1,capture:!1}),window.addEventListener("mouseup",c,{passive:!1}),window.addEventListener("touchend",c,{passive:!1})}function a(){window.removeEventListener("mousemove",u),window.removeEventListener("touchmove",u),window.removeEventListener("mouseup",c),window.removeEventListener("touchend",c),Dl&&(clearTimeout(Dl),Dl=void 0,tx=!1)}function l(){kl===r&&(a(),kl=void 0,Ti=void 0,Sl=void 0,li=void 0)}function c(m){if(kl===r&&(l(),m.type==="touchend")){var v=new Event("click",{bubbles:!0,cancelable:!0});m.target.dispatchEvent(v)}}function u(m){if(!(n||kl!==r)){var v=!!m.touches,g=v?m.touches[0]:m;if(v&&i.delayTouchStartMs>0&&!tx){li={x:g.clientX,y:g.clientY},(Math.abs(li.x-Sl.x)>=BA||Math.abs(li.y-Sl.y)>=BA)&&(Dl&&(clearTimeout(Dl),Dl=void 0),c(m));return}m.preventDefault(),li={x:g.clientX,y:g.clientY},(Math.abs(li.x-Sl.x)>=BA||Math.abs(li.y-Sl.y)>=BA)&&f()}}function d(m){if(m.target!==m.currentTarget&&(m.target.value!==void 0||m.target.isContentEditable)){Ct(function(){return"won't initiate drag on a nested input element"});return}if(m.button){Ct(function(){return"ignoring none left click button: ".concat(m.button)});return}if(n||Lc||kl){Ct(function(){return"cannot start a new drag before finalizing the current drag or pending gesture"});return}var v=!!m.touches,g=v&&i.delayTouchStartMs>0;g||m.preventDefault(),m.stopPropagation(),kl=r;var y=v?m.touches[0]:m;if(Sl={x:y.clientX,y:y.clientY},li=qA({},Sl),Ti=m.currentTarget,g){var w=Ti;tx=!1,Dl=window.setTimeout(function(){n||kl!==r||Ti!==w||(tx=!0,f())},i.delayTouchStartMs)}s()}function f(){var m;if(n||kl!==r||Lc||!((m=Ti)!==null&&m!==void 0&&m.parentElement)){l();return}a(),kl=void 0,Ct(function(){return["drag start config: ".concat(Oa(i)),Ti]}),Lc=!0;var v=o.get(Ti);tk=v,Or=Ti.parentElement;var g=Or.closest("dialog")||Or.closest("[popover]")||Or.getRootNode(),y=g.body||g,w=i.items,x=i.type,C=i.centreDraggedOnCursor,_=i.useCursorForDetection,E=Js(w);Bo=E[v],i$=x,Zu=Cce(Bo),s$=_,Cn=lce(Ti,C&&li),y.appendChild(Cn);function D(){!Cn||jA||(Ti.parentElement?window.requestAnimationFrame(D):(Ti.setAttribute(Kj,!0),y.appendChild(Ti),wce(),dG(Ti),Zu[qn]=Bo[qn],Cn.focus()))}window.requestAnimationFrame(D),VA(Array.from(Bc.get(i.type)).filter(function(P){return P===Or||!sn.get(P).dropFromOthersDisabled}),function(P){return sn.get(P).dropTargetStyle},function(P){return sn.get(P).dropTargetClasses}),E.splice(v,1,Zu),o$=mce(Or),Ju(Or,E,{trigger:Ai.DRAG_STARTED,id:Bo[qn],source:Qi.POINTER}),window.addEventListener("mousemove",GA,{passive:!1}),window.addEventListener("touchmove",GA,{passive:!1,capture:!1}),window.addEventListener("mouseup",Sh,{passive:!1}),window.addEventListener("touchend",Sh,{passive:!1})}function p(m){var v=m.items,g=v===void 0?void 0:v,y=m.flipDurationMs,w=y===void 0?0:y,x=m.type,C=x===void 0?hce:x,_=m.dragDisabled,E=_===void 0?!1:_,D=m.morphDisabled,P=D===void 0?!1:D,V=m.dropFromOthersDisabled,j=V===void 0?!1:V,oe=m.dropTargetStyle,se=oe===void 0?Yj:oe,M=m.dropTargetClasses,U=M===void 0?[]:M,q=m.transformDraggedElement,B=q===void 0?function(){}:q,ie=m.centreDraggedOnCursor,W=ie===void 0?!1:ie,Y=m.useCursorForDetection,X=Y===void 0?!1:Y,ae=m.dropAnimationDisabled,pe=ae===void 0?!1:ae,ge=m.delayTouchStart,be=ge===void 0?!1:ge;i.dropAnimationDurationMs=w;var xe=0;be===!0?xe=yce:typeof be=="number"&&isFinite(be)&&be>=0&&(xe=be),i.delayTouchStartMs=xe,i.type&&C!==i.type&&Xj(r,i.type),i.type=C,i.items=Js(g),i.dragDisabled=E,i.morphDisabled=P,i.transformDraggedElement=B,i.centreDraggedOnCursor=W,i.useCursorForDetection=X,i.dropAnimationDisabled=pe,t&&Lc&&!jA&&(!Kle(se,i.dropTargetStyle)||!Xle(U,i.dropTargetClasses))&&(HA([r],function(){return i.dropTargetStyle},function(){return U}),VA([r],function(){return se},function(){return U})),i.dropTargetStyle=se,i.dropTargetClasses=Js(U);function Ue(Qe,ye){return sn.get(Qe)?sn.get(Qe)[ye]:i[ye]}t&&Lc&&i.dropFromOthersDisabled!==j&&(j?HA([r],function(Qe){return Ue(Qe,"dropTargetStyle")},function(Qe){return Ue(Qe,"dropTargetClasses")}):VA([r],function(Qe){return Ue(Qe,"dropTargetStyle")},function(Qe){return Ue(Qe,"dropTargetClasses")})),i.dropFromOthersDisabled=j,sn.set(r,i),bce(r,C);for(var $t=Lc?rk(i.items):-1,Ne=0;Ne<r.children.length;Ne++){var Ke=r.children[Ne];if(dce(Ke,E),Ne===$t){P||uce(Cn,Ke,li.x,li.y),i.transformDraggedElement(Cn,Bo,Ne),pce(Ke);continue}Ke.removeEventListener("mousedown",ex.get(Ke)),Ke.removeEventListener("touchstart",ex.get(Ke)),E||(Ke.addEventListener("mousedown",d),Ke.addEventListener("touchstart",d),ex.set(Ke,d)),o.set(Ke,Ne),t||(t=!0)}}return p(e),{update:function(v){Ct(function(){return"pointer dndzone will update newOptions: ".concat(Oa(v))}),p(v)},destroy:function(){if(n)return;n=!0,l();var v=Gp(r.children),g;try{for(v.s();!(g=v.n()).done;){var y=g.value;y.removeEventListener("mousedown",ex.get(y)),y.removeEventListener("touchstart",ex.get(y))}}catch(x){v.e(x)}finally{v.f()}function w(){Ct(function(){return"pointer dndzone will destroy"});var x=sn.get(r);x&&(Xj(r,x.type),sn.delete(r))}Lc&&!r.closest("[".concat(Kj,"]"))?(Ct(function(){return"pointer dndzone will be scheduled for destruction"}),Ece(r,w)):w()}}}var UA,XR={DND_ZONE_ACTIVE:"dnd-zone-active",DND_ZONE_DRAG_DISABLED:"dnd-zone-drag-disabled"},hG=(UA={},Ah(UA,XR.DND_ZONE_ACTIVE,"Tab to one the items and press space-bar or enter to start dragging it"),Ah(UA,XR.DND_ZONE_DRAG_DISABLED,"This is a disabled drag and drop list"),UA),Ace="dnd-action-aria-alert",wn;function QR(){wn||(wn=document.createElement("div"),(function(){wn.id=Ace,wn.style.position="fixed",wn.style.bottom="0",wn.style.left="0",wn.style.zIndex="-5",wn.style.opacity="0",wn.style.height="0",wn.style.width="0",wn.setAttribute("role","alert")})(),document.body.prepend(wn),Object.entries(hG).forEach(function(r){var e=Sle(r,2),t=e[0],n=e[1];return document.body.prepend(Dce(t,n))}))}function kce(){return r$?null:(document.readyState==="complete"?QR():window.addEventListener("DOMContentLoaded",QR),qA({},XR))}function Sce(){r$||!wn||(Object.keys(hG).forEach(function(r){var e;return(e=document.getElementById(r))===null||e===void 0?void 0:e.remove()}),wn.remove(),wn=void 0)}function Dce(r,e){var t=document.createElement("div");return t.id=r,t.innerHTML="<p>".concat(e,"</p>"),t.style.display="none",t.style.position="fixed",t.style.zIndex="-5",t}function Fl(r){if(!r$){wn||QR(),wn.innerHTML="";var e=document.createTextNode(r);wn.appendChild(e),wn.style.display="none",wn.style.display="inline"}}var Ice="--any--",Qj={outline:"rgba(255, 255, 102, 0.7) solid 2px"},Lo=!1,ZR,bo,jp="",zp,Il,Qu="",YA=new WeakSet,qR=new WeakMap,WR=new WeakMap,JR=new Map,_i=new Map,Pl=new Map,KA;function Pce(r,e){Ct(function(){return"registering drop-zone if absent"}),Pl.size===0&&(Ct(function(){return"adding global keydown and click handlers"}),KA=kce(),window.addEventListener("keydown",gG),window.addEventListener("click",vG)),Pl.has(e)||Pl.set(e,new Set),Pl.get(e).has(r)||(Pl.get(e).add(r),rG())}function Zj(r,e){Ct(function(){return"unregistering drop-zone"}),Lo&&bo===r&&ox();var t=Pl.get(e);!t||!t.delete(r)||(nG(),t.size===0&&Pl.delete(e),Pl.size===0&&(Ct(function(){return"removing global keydown and click handlers"}),window.removeEventListener("keydown",gG),window.removeEventListener("click",vG),KA=void 0,Sce()))}function gG(r){Lo&&r.key==="Escape"&&ox()}function vG(){Lo&&(YA.has(document.activeElement)||(Ct(function(){return"clicked outside of any draggable"}),ox()))}function Jj(r){if(Ct(function(){return"zone focus"}),!!Lo){var e=r.currentTarget;if(e!==bo){jp=e.getAttribute("aria-label")||"";var t=_i.get(bo),n=t.items,i=n.find(function(f){return f[qn]===Il}),o=n.indexOf(i),s=n.splice(o,1)[0],a=_i.get(e),l=a.items,c=a.autoAriaDisabled;e.getBoundingClientRect().top<bo.getBoundingClientRect().top||e.getBoundingClientRect().left<bo.getBoundingClientRect().left?(l.push(s),c||Fl("Moved item ".concat(Qu," to the end of the list ").concat(jp))):(l.unshift(s),c||Fl("Moved item ".concat(Qu," to the beginning of the list ").concat(jp)));var u=bo,d=Il;bo=e,kh(u,n,{trigger:Ai.DROPPED_INTO_ANOTHER,id:d,source:Qi.KEYBOARD}),_i.has(e)&&kh(e,l,{trigger:Ai.DROPPED_INTO_ZONE,id:d,source:Qi.KEYBOARD})}}}function yG(){JR.forEach(function(r,e){var t=r.update;return t(_i.get(e))})}function ox(){var r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!0;if(!(!Lo||!bo)){Ct(function(){return"drop"});var e=bo,t=_i.get(e),n=Il,i=ZR;if(t){t.autoAriaDisabled||Fl("Stopped dragging item ".concat(Qu)),YA.has(document.activeElement)&&document.activeElement.blur(),zp=null,Il=null,Qu="",ZR=null,bo=null,jp="",Lo=!1,r&&Ju(e,t.items,{trigger:Ai.DRAG_STOPPED,id:n,source:Qi.KEYBOARD});var o=Pl.get(i);o&&HA(o,function(s){return _i.get(s).dropTargetStyle},function(s){return _i.get(s).dropTargetClasses}),yG()}}}function Fce(r,e){var t=!1,n={items:void 0,type:void 0,dragDisabled:!1,zoneTabIndex:0,zoneItemTabIndex:0,dropFromOthersDisabled:!1,dropTargetStyle:Qj,dropTargetClasses:[],autoAriaDisabled:!1};function i(d,f,p){d.length<=1||d.splice(p,1,d.splice(f,1,d[p])[0])}function o(d){switch(Ct(function(){return["handling key down",d.key]}),d.key){case"Enter":case" ":{if((d.target.disabled!==void 0||d.target.href||d.target.isContentEditable)&&!YA.has(d.target))return;d.preventDefault(),d.stopPropagation(),Lo?ox():s(d);break}case"ArrowDown":case"ArrowRight":{if(!Lo)return;d.preventDefault(),d.stopPropagation();var f=_i.get(r),p=f.items,m=Array.from(r.children),v=m.indexOf(d.currentTarget);Ct(function(){return["arrow down",v]}),v<m.length-1&&(n.autoAriaDisabled||Fl("Moved item ".concat(Qu," to position ").concat(v+2," in the list ").concat(jp)),i(p,v,v+1),kh(r,p,{trigger:Ai.DROPPED_INTO_ZONE,id:Il,source:Qi.KEYBOARD}));break}case"ArrowUp":case"ArrowLeft":{if(!Lo)return;d.preventDefault(),d.stopPropagation();var g=_i.get(r),y=g.items,w=Array.from(r.children),x=w.indexOf(d.currentTarget);Ct(function(){return["arrow up",x]}),x>0&&(n.autoAriaDisabled||Fl("Moved item ".concat(Qu," to position ").concat(x," in the list ").concat(jp)),i(y,x,x-1),kh(r,y,{trigger:Ai.DROPPED_INTO_ZONE,id:Il,source:Qi.KEYBOARD}));break}}}function s(d){Ct(function(){return"drag start"}),l(d.currentTarget),bo=r,ZR=n.type,Lo=!0;var f=Array.from(Pl.get(n.type)).filter(function(m){return m===bo||!_i.get(m).dropFromOthersDisabled});if(VA(f,function(m){return _i.get(m).dropTargetStyle},function(m){return _i.get(m).dropTargetClasses}),!n.autoAriaDisabled){var p="Started dragging item ".concat(Qu,". Use the arrow keys to move it within its list ").concat(jp);f.length>1&&(p+=", or tab to another list in order to move the item into it"),Fl(p)}Ju(r,_i.get(r).items,{trigger:Ai.DRAG_STARTED,id:Il,source:Qi.KEYBOARD}),yG()}function a(d){Lo&&d.currentTarget!==zp&&(d.stopPropagation(),ox(!1),s(d))}function l(d){var f=_i.get(r),p=f.items,m=Array.from(r.children),v=m.indexOf(d);zp=d,zp.tabIndex=n.zoneItemTabIndex,Il=p[v][qn],Qu=m[v].getAttribute("aria-label")||""}function c(d){var f=d.items,p=f===void 0?[]:f,m=d.type,v=m===void 0?Ice:m,g=d.dragDisabled,y=g===void 0?!1:g,w=d.zoneTabIndex,x=w===void 0?0:w,C=d.zoneItemTabIndex,_=C===void 0?0:C,E=d.dropFromOthersDisabled,D=E===void 0?!1:E,P=d.dropTargetStyle,V=P===void 0?Qj:P,j=d.dropTargetClasses,oe=j===void 0?[]:j,se=d.autoAriaDisabled,M=se===void 0?!1:se;n.items=Js(p),n.dragDisabled=y,n.dropFromOthersDisabled=D,n.zoneTabIndex=x,n.zoneItemTabIndex=_,n.dropTargetStyle=V,n.dropTargetClasses=oe,n.autoAriaDisabled=M,n.type&&v!==n.type&&Zj(r,n.type),n.type=v,Pce(r,v),M||(r.setAttribute("role","list"),r.setAttribute("aria-describedby",y?KA.DND_ZONE_DRAG_DISABLED:KA.DND_ZONE_ACTIVE)),_i.set(r,n),Lo?r.tabIndex=r===bo||zp.contains(r)||n.dropFromOthersDisabled||bo&&n.type!==_i.get(bo).type?-1:0:r.tabIndex=n.zoneTabIndex,r.addEventListener("focus",Jj);for(var U=function(ie){var W=r.children[ie];YA.add(W),W.tabIndex=Lo?-1:n.zoneItemTabIndex,M||W.setAttribute("role","listitem"),W.removeEventListener("keydown",qR.get(W)),W.removeEventListener("click",WR.get(W)),y||(W.addEventListener("keydown",o),qR.set(W,o),W.addEventListener("click",a),WR.set(W,a)),Lo&&n.items[ie][qn]===Il&&(Ct(function(){return["focusing on",{i:ie,focusedItemId:Il}]}),zp=W,zp.tabIndex=n.zoneItemTabIndex,W.focus())},q=0;q<r.children.length;q++)U(q)}c(e);var u={update:function(f){Ct(function(){return"keyboard dndzone will update newOptions: ".concat(Oa(f))}),c(f)},destroy:function(){if(!t){t=!0,Ct(function(){return"keyboard dndzone will destroy"}),r.removeEventListener("focus",Jj);var f=Gp(r.children),p;try{for(f.s();!(p=f.n()).done;){var m=p.value;m.removeEventListener("keydown",qR.get(m)),m.removeEventListener("click",WR.get(m))}}catch(v){f.e(v)}finally{f.f()}Zj(r,n.type),_i.delete(r),JR.delete(r)}}};return JR.set(r,u),u}var Mce=["items","flipDurationMs","type","dragDisabled","morphDisabled","dropFromOthersDisabled","zoneTabIndex","zoneItemTabIndex","dropTargetStyle","dropTargetClasses","transformDraggedElement","autoAriaDisabled","centreDraggedOnCursor","useCursorForDetection","delayTouchStart","dropAnimationDisabled"];function nk(r,e){if(Rce(r))return{update:function(){},destroy:function(){}};eG(e);var t=_ce(r,e),n=Fce(r,e);return{update:function(o){eG(o),t.update(o),n.update(o)},destroy:function(){t.destroy(),n.destroy()}}}function Rce(r){return!!r.closest("[".concat(qle,'="true"]'))}function eG(r){var e=r.items;r.flipDurationMs,r.type,r.dragDisabled,r.morphDisabled,r.dropFromOthersDisabled;var t=r.zoneTabIndex,n=r.zoneItemTabIndex;r.dropTargetStyle;var i=r.dropTargetClasses;r.transformDraggedElement,r.autoAriaDisabled,r.centreDraggedOnCursor,r.useCursorForDetection;var o=r.delayTouchStart;r.dropAnimationDisabled;var s=kle(r,Mce);if(Object.keys(s).length>0&&console.warn("dndzone will ignore unknown options",s),!e)throw new Error("no 'items' key provided to dndzone");var a=e.find(function(u){return!{}.hasOwnProperty.call(u,qn)});if(a)throw new Error("missing '".concat(qn,"' property for item ").concat(Oa(a)));if(i&&!Array.isArray(i))throw new Error("dropTargetClasses should be an array but instead it is a ".concat(Eh(i),", ").concat(Oa(i)));if(t&&!tG(t))throw new Error("zoneTabIndex should be a number but instead it is a ".concat(Eh(t),", ").concat(Oa(t)));if(n&&!tG(n))throw new Error("zoneItemTabIndex should be a number but instead it is a ".concat(Eh(n),", ").concat(Oa(n)));if(o!==void 0&&o!==!1){var l=o===!0,c=typeof o=="number"&&isFinite(o)&&o>=0;if(!l&&!c)throw new Error("delayTouchStart should be a boolean (true/false) or a non-negative number but instead it is a ".concat(Eh(o),", ").concat(Oa(o)))}}function tG(r){return!isNaN(r)&&(function(e){return(e|0)===e})(parseFloat(r))}function bG(r){var e=r,t=new Set;return{get:function(){return e},set:function(i){e=i,Array.from(t).forEach(function(o){return o(e)})},subscribe:function(i){t.add(i),i(e)},unsubscribe:function(i){t.delete(i)}}}var Tnt=bG(!0),_nt=bG(!1);var $ce=[[9,5],[9,12],[9,19],[15,5],[15,12],[15,19]];function wG(r,e,t=!1){if(!r)return;r.classList.add("qa-drag-clone"),r.dataset.qaMulti=t?"true":"false";let n=r.querySelector(":scope > .qa-drag-pill");if(!n){n=r.createDiv({cls:"qa-drag-pill"});let s=n.createSpan({cls:"qa-drag-pill-grip"}).createSvg("svg",{attr:{viewBox:"0 0 24 24",width:14,height:14,fill:"none",stroke:"currentColor","stroke-width":2,"stroke-linecap":"round","stroke-linejoin":"round"}});for(let[a,l]of $ce)s.createSvg("circle",{attr:{cx:a,cy:l,r:1}});n.createSpan({cls:"qa-drag-pill-label"})}let i=n.querySelector(".qa-drag-pill-label");i&&i.textContent!==e&&(i.textContent=e)}function Ml(r){return r.filter(e=>e.id!==ek)}function CG(r,e){return r.map(t=>t.id===e.id?e:t)}function ik(r){let e=r.resolveLabel??(t=>t.name??"");return{items:r.items,dragDisabled:r.dragDisabled,flipDurationMs:r.flipDurationMs??0,morphDisabled:!0,useCursorForDetection:!0,centreDraggedOnCursor:!1,transformDraggedElement:(t,n)=>wG(t,n?e(n):"",n?.type==="Multi"),dropTargetStyle:{},dropTargetClasses:r.dropTargetClasses??[],autoAriaDisabled:!0,zoneItemTabIndex:-1,delayTouchStart:200,...r.type?{type:r.type}:{}}}function ok(){let r=Ae(!1),e=!1;function t(){Z(r,!0),e=!1;let n=()=>{window.removeEventListener("pointerup",n,!0),window.removeEventListener("pointercancel",n,!0),e||Z(r,!1)};window.addEventListener("pointerup",n,!0),window.addEventListener("pointercancel",n,!0)}return{get armed(){return h(r)},markStarted(){e=!0},reset(){Z(r,!1),e=!1},startDrag:t}}hl();Yr();Rm();function Yp(r){if(r.type==="Choice")try{return ri().getChoiceById(r.choiceId).name}catch{return"(missing choice)"}if(r.type==="Conditional"){let e=r.condition;return`If ${Mm(e)}`}return r.name}var Oce=z('<button type="button"><!></button>');function ki(r,e){we(e,!0);let t=he(e,"size",3,16),n=O(()=>!!(e.onMoveUp||e.onMoveDown));function i(l){l.key==="ArrowUp"&&e.onMoveUp?(l.preventDefault(),l.stopPropagation(),e.onMoveUp()):l.key==="ArrowDown"&&e.onMoveDown&&(l.preventDefault(),l.stopPropagation(),e.onMoveDown())}var o=Oce();let s;var a=I(o);Rt(a,{iconId:"grip-vertical",get size(){return t()}}),S(o),de(()=>{s=wt(o,1,"qa-icon-button qa-drag-handle",null,s,{"qa-drag-handle-ready":e.dragDisabled,"qa-drag-handle-active":!e.dragDisabled}),ke(o,"aria-label",e.label),ke(o,"aria-keyshortcuts",h(n)?"ArrowUp ArrowDown":void 0),ke(o,"tabindex",e.dragDisabled?0:-1)}),De("pointerdown",o,()=>e.onDragStart()),De("keydown",o,i),$(r,o),Ce()}Et(["pointerdown","keydown"]);var Nce=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!></div></li>');function a$(r,e){we(e,!0);var t=Nce(),n=I(t),i=I(n,!0);S(n);var o=A(n,2),s=I(o);{let l=O(()=>`Delete ${Yp(e.command)}`);er(s,{iconId:"trash-2",get label(){return h(l)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var a=A(s,2);{let l=O(()=>`Reorder ${Yp(e.command)}`);ki(a,{get label(){return h(l)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(l=>me(i,l),[()=>Yp(e.command)]),$(r,t),Ce()}Yr();var Lce=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> <input type="number" min="0" placeholder=" " class="dotInput svelte-1h5tx3b" aria-label="Wait duration in milliseconds"/>ms</span> <div class="quickAddCommandControls"><!> <!></div></li>'),Bce={hash:"svelte-1h5tx3b",code:".dotInput.svelte-1h5tx3b {border:none;display:inline;font-family:inherit;font-size:inherit;padding:0;width:var(--qa-wait-input-width, 2ch);text-decoration:underline dotted;background-color:transparent;}.dotInput.svelte-1h5tx3b:hover {background-color:transparent;}"};function l$(r,e){we(e,!0),ot(r,Bce);let t=Ae(void 0),n=Ae(bt(Ot(()=>e.command.time)));function i(){if(!h(t))return;let p=String(h(t).value).length;h(t).style.setProperty("--qa-wait-input-width",`${p===0?2:p}ch`)}function o(p){let m=p.currentTarget.valueAsNumber;Z(n,Number.isNaN(m)||m<0?0:m,!0),i(),e.onUpdateCommand({...e.command,time:h(n)})}cT(i);var s=Lce(),a=I(s),l=I(a),c=A(l);gr(c),sc(c,p=>Z(t,p),()=>h(t)),In(),S(a);var u=A(a,2),d=I(u);{let p=O(()=>`Delete ${e.command.name}`);er(d,{iconId:"trash-2",get label(){return h(p)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var f=A(d,2);{let p=O(()=>`Reorder ${e.command.name}`);ki(f,{get label(){return h(p)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(u),S(s),de(()=>{me(l,`${e.command.name??""} for `),Ps(c,h(n))}),De("input",c,o),$(r,s),Ce()}Et(["input"]);var Uce=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function c$(r,e){we(e,!0);var t=Uce(),n=I(t),i=I(n,!0);S(n);var o=A(n,2),s=I(o);{let c=O(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureChoice(e.command)})}var a=A(s,2);{let c=O(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=A(a,2);{let c=O(()=>`Reorder ${e.command.name}`);ki(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Vce=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function u$(r,e){we(e,!0);var t=Vce(),n=I(t),i=I(n,!0);S(n);var o=A(n,2),s=I(o);{let c=O(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureScript(e.command)})}var a=A(s,2);{let c=O(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=A(a,2);{let c=O(()=>`Reorder ${e.command.name}`);ki(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Pi=require("obsidian");hl();function xG(r,e){let t=r.ownerDocument.createElement("div");t.className="qa-format-preview-host",r.appendChild(t);let n=bt({value:e.value,app:e.app,plugin:e.plugin,targetFolderPath:null}),i=qi(t,hs,n,{what:"the preview for this field"}),o=!1;return{setValue(s){o||(n.value=s)},destroy(){o||(o=!0,i.destroy(),t.remove())}}}function EG(r){r.addEventListener("focus",()=>{r.type="text"}),r.addEventListener("blur",()=>{r.type="password"}),r.type="password"}hk();Uc();function iue(r){return typeof r=="string"?r:r==null?"":String(r)}function RG(r){if(typeof r=="string")return r;if(r==null)return"";if(typeof r=="number"||typeof r=="boolean")return String(r);try{return JSON.stringify(r)??String(r)}catch{return String(r)}}var gk=class extends Pi.Modal{constructor(t,n,i,o){super(t);this.command=n;this.settings=i;this.onCommandChange=o;this.previewHandles=[];this.command.settings||(this.command.settings={}),$h(this.command.settings,this.settings),this.display(),this.migrateSecretSettings()}display(){this.containerEl.addClass("quickAddModal","userScriptSettingsModal"),this.destroyPreviews(),this.contentEl.empty();let t=RG(this.settings?.name??this.command.name),n=RG(this.settings?.author);this.titleEl.innerText=`${t}${n?` by ${n}`:""}`;let i=this.settings.options;if(i)for(let o in i){if(!Object.prototype.hasOwnProperty.call(i,o))continue;let s=i[o];if(Fh(s)){let u=this.addSecretInput(o,"placeholder"in s?s.placeholder:void 0);s.description&&u.setDesc(s.description);continue}let a=s.defaultValue;this.command.settings[o]!==void 0&&(a=this.command.settings[o]);let l,c=s.type;c==="text"||c==="input"?l=this.addInputBox(o,a,s?.placeholder,s.secret):c==="textarea"?l=this.addTextArea(o,a,s?.placeholder):c==="checkbox"||c==="toggle"?l=this.addToggle(o,a):c==="dropdown"||c==="select"?l=this.addDropdown(o,s.options,a):c==="format"&&(l=this.addFormatInput(o,a,s.placeholder)),s.description&&l&&l.setDesc(s.description)}}addInputBox(t,n,i,o){return new Pi.Setting(this.contentEl).setName(t).addText(s=>{s.setValue(n).onChange(a=>{this.command.settings[t]=a,this.onCommandChange?.()}).setPlaceholder(i??""),o&&EG(s.inputEl)})}addSecretInput(t,n){let i=new Pi.Setting(this.contentEl).setName(t),o="",s,a=()=>{let c=this.command.settings?.[t];return mk(this.command,t)!==void 0||typeof c=="string"&&c.length>0},l=()=>{s&&(s.placeholder=a()?"Secret saved":n??"Paste secret")};return i.addText(c=>{c.setValue("").onChange(u=>{o=u}),c.inputEl.type="password",c.inputEl.addClass("qa-user-script-secret-input"),c.inputEl.setAttribute("aria-label",t),s=c.inputEl,l()}),i.addButton(c=>{c.setIcon("save").setTooltip("Save secret").onClick(async()=>{if(o.length===0){new Pi.Notice("Paste a secret before saving.");return}let u=await g$(this.app,this.command,t,o,mk(this.command,t),this.settings.options?.[t]);if(!u){new Pi.Notice("SecretStorage is unavailable. Secret was not saved.");return}this.command.settings[t]=ck(u),o="",s&&(s.value=""),l(),this.onCommandChange?.(),new Pi.Notice("Secret saved.")}),c.buttonEl.setAttribute("aria-label",`Save ${t}`)}),i.addButton(c=>{c.setIcon("trash-2").setTooltip("Clear secret").onClick(async()=>{let u=mk(this.command,t);if(u&&!await v$(this.app,u)){new Pi.Notice("SecretStorage is unavailable. Secret was not cleared.");return}delete this.command.settings[t],o="",s&&(s.value=""),l(),this.onCommandChange?.(),new Pi.Notice("Secret cleared.")}),c.buttonEl.setAttribute("aria-label",`Clear ${t}`)}),i}addTextArea(t,n,i){return new Pi.Setting(this.contentEl).setName(t).addTextArea(o=>{o.setValue(n).onChange(s=>{this.command.settings[t]=s,this.onCommandChange?.()}).setPlaceholder(i??""),o.inputEl.addClass("qa-user-script-argument-textarea")})}addToggle(t,n){return new Pi.Setting(this.contentEl).setName(t).addToggle(i=>i.setValue(n).onChange(o=>{this.command.settings[t]=o,this.onCommandChange?.()}))}addDropdown(t,n,i){return new Pi.Setting(this.contentEl).setName(t).addDropdown(o=>{n.forEach(s=>{o.addOption(s,s)}),o.setValue(i),o.onChange(s=>{this.command.settings[t]=s,this.onCommandChange?.()})})}addFormatInput(t,n,i){let o=new Pi.Setting(this.contentEl).setName(t),s=iue(n),a=new Pi.TextAreaComponent(this.contentEl);new Hi(this.app,a.inputEl,ri()),a.inputEl.addClass("qa-user-script-format-textarea"),a.inputEl.setAttribute("aria-label",t);let l=xG(this.contentEl,{app:this.app,plugin:ri(),value:s});return this.previewHandles.push(l),a.setValue(s).onChange(c=>{this.command.settings[t]=c,l.setValue(c),this.onCommandChange?.()}).setPlaceholder(i??""),o}destroyPreviews(){for(let t of this.previewHandles)t.destroy();this.previewHandles=[]}onClose(){this.destroyPreviews(),super.onClose()}async migrateSecretSettings(){await Mh(this.app,this.command,this.settings)&&(this.onCommandChange?.(),this.display())}};Me();qt();var oue=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function b$(r,e){we(e,!0);var t=oue(),n=I(t),i=I(n,!0);S(n);var o=A(n,2),s=I(o);{let c=O(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureAssistant(e.command)})}var a=A(s,2);{let c=O(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=A(a,2);{let c=O(()=>`Reorder ${e.command.name}`);ki(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var wo=require("obsidian");var sue="QuickAdd sends the system prompt to the model as written - format syntax like {{DATE}} is not resolved here. Only the prompt template is formatted.",aue=0;function vk(r,e,t){let n=r.createEl("div",{text:sue,cls:"qa-literal-format-note"}),i=`qa-literal-format-note-${++aue}`;n.id=i;let o=s=>{let a=s.includes("{{");n.classList.toggle("qa-literal-format-note--shown",a),a?e.setAttribute("aria-describedby",i):e.removeAttribute("aria-describedby")};return o(t),o}qt();It();zs();px();var VG=require("obsidian");Nh();var pue=[{key:"temperature",name:"Temperature",desc:"Sampling temperature (0-1, the range every provider accepts). Higher values like 0.8 make the output more random; lower values like 0.2 make it more focused and deterministic.",min:0,max:1,step:.1,fallback:1},{key:"top_p",name:"Top P",desc:"Nucleus sampling - an alternative to temperature. The model considers only the tokens comprising the top P probability mass, so 0.1 means the top 10%.",min:0,max:1,step:.1,fallback:1},{key:"frequency_penalty",name:"Frequency penalty",desc:"Positive values penalize tokens by how often they already appear, reducing verbatim repetition; negative values encourage it. Only sent to providers that support it.",min:-2,max:2,step:.1,fallback:0},{key:"presence_penalty",name:"Presence penalty",desc:"Positive values penalize tokens that have appeared at all, encouraging new topics; negative values do the opposite. Only sent to providers that support it.",min:-2,max:2,step:.1,fallback:0}];function qG(r,e,t,n){let i=Kp(t,{silent:!0})?.model;i?.supportsTemperature===!1&&r.createEl("div",{text:`${i.name} uses fixed sampling, so these settings are not sent to it.`,cls:"setting-item-description"});for(let o of pue){let s=typeof e[o.key]=="number";new VG.Setting(r).setName(o.name).setDesc(s?o.desc:`${o.desc} Currently using the provider's default.`).addSlider(a=>{a.setLimits(o.min,o.max,o.step),a.setDynamicTooltip(),a.setValue(e[o.key]??o.fallback),a.onChange(l=>{e[o.key]=l})}).addExtraButton(a=>{a.setIcon("rotate-ccw"),a.setTooltip("Reset to provider default"),a.setDisabled(!s),a.onClick(()=>{delete e[o.key],n()})})}}Nh();es();It();var Lh="Ask me",yk="__qa-missing-model__";function bk(r,e,t){let n=ce.getState().ai.providers,i=r.selectEl,o=i.ownerDocument;e={model:e.model,modelRef:mu(e.model,e.modelRef)},r.addOption(Lh,Lh);let s=new Map,a=0;for(let c of n){if(c.models.length===0)continue;let u=o.createElement("optgroup");u.label=c.name,i.appendChild(u);for(let d of c.models){let f=`${c.id??c.name}/${d.name}:${a++}`;s.set(f,{providerId:c.id,modelName:d.name});let p=o.createElement("option");p.value=f,p.text=d.name,u.appendChild(p)}}let l=fue(e,s);if(l)r.setValue(l);else{let c=e.modelRef?`${e.modelRef.providerId}/${e.modelRef.name}`:e.model;r.addOption(yk,`(missing) ${c}`);let u=Array.from(i.options).find(d=>d.value===yk);u&&(u.disabled=!0),r.setValue(yk)}r.onChange(c=>{if(c===yk)return;if(c===Lh){t({model:Lh,modelRef:void 0});return}let u=s.get(c);u&&t({model:u.modelName,modelRef:u.providerId?{providerId:u.providerId,name:u.modelName}:void 0})})}function fue(r,e){if(!r.model||r.model===Lh)return Lh;if(r.modelRef){for(let[n,i]of e)if(i.providerId===r.modelRef.providerId&&i.modelName===r.modelRef.name)return n;return}let t=Kp(r.model,{silent:!0});if(t){for(let[n,i]of e)if(i.providerId===t.provider.id&&i.modelName===t.model.name)return n}}es();var wk=class extends wo.Modal{constructor(t,n){super(t);this.isResolved=!1;this.showAdvancedSettings=!1;this.settings=n,this.originalSettings=this.cloneSettings(n),this.waitForClose=new Promise((i,o)=>{this.rejectPromise=o,this.resolvePromise=i}),this.open(),this.display()}get systemPromptTokenLength(){return Uo(this.settings.systemPrompt)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}cloneSettings(t){return{...t,promptTemplate:{...t.promptTemplate},modelParameters:{...t.modelParameters}}}restoreOriginal(){let t=this.cloneSettings(this.originalSettings);Object.assign(this.settings,t),this.settings.promptTemplate=t.promptTemplate,this.settings.modelParameters=t.modelParameters}display(){let t=this.contentEl.createEl("h2");t.addClass("qa-clickable-modal-title"),t.createEl("button",{cls:"qa-rename-title-button",text:`${this.settings.name} settings`,attr:{type:"button","aria-label":`Rename ${this.settings.name}`}}).addEventListener("click",()=>{(async()=>{try{let i=await Sr.Prompt(this.app,"New name",this.settings.name,this.settings.name);i&&i!==this.settings.name&&(this.settings.name=i,this.reload())}catch{}})()}),this.addPromptTemplateSetting(this.contentEl),this.addModelSetting(this.contentEl),this.addOutputVariableNameSetting(this.contentEl),this.addShowAdvancedSettingsToggle(this.contentEl),this.showAdvancedSettings&&(this.settings.modelParameters||(this.settings.modelParameters={}),qG(this.contentEl,this.settings.modelParameters,mu(this.settings.model,this.settings.modelRef)??this.settings.model,()=>this.reload())),this.addSystemPromptSetting(this.contentEl),this.addButtonBar(this.contentEl)}addButtonBar(t){let n=t.createDiv({cls:"qa-command-button-row"});new wo.ButtonComponent(n).setButtonText("Cancel").onClick(()=>{this.restoreOriginal(),this.resolve(null),this.close()}),new wo.ButtonComponent(n).setButtonText("Save").setCta().onClick(()=>{this.resolve(this.settings),this.close()})}reload(){this.contentEl.empty(),this.display()}addPromptTemplateSetting(t){let n=ce.getState().ai.promptTemplatesFolderPath,i=rs(this.app,n).map(o=>o.name);new wo.Setting(t).setName("Prompt template").setDesc("Enabling this will have the assistant use the prompt template you specify. If disable, the assistant will ask you for a prompt template to use.").addToggle(o=>{o.setValue(this.settings.promptTemplate.enable),o.onChange(s=>{this.settings.promptTemplate.enable=s})}).addText(o=>{o.setValue(this.settings.promptTemplate.name).onChange(s=>{this.settings.promptTemplate.name=s}),new ni(this.app,o.inputEl,i)})}addModelSetting(t){new wo.Setting(t).setName("Model").setDesc("The model the AI Assistant will use").addDropdown(n=>{bk(n,this.settings,i=>{this.settings.model=i.model,this.settings.modelRef=i.modelRef,this.reload()})})}addOutputVariableNameSetting(t){new wo.Setting(t).setName("Output variable name").setDesc("The name of the variable used to store the AI Assistant output, i.e. {{value:output}}.").addText(n=>{n.setValue(this.settings.outputVariableName).onChange(i=>{this.settings.outputVariableName=i})})}addSystemPromptSetting(t){new wo.Setting(t).setName("System prompt").setDesc("The system prompt for the AI Assistant");let n=this.contentEl.createEl("div"),i=n.createEl("span",{cls:"qa-ai-token-count"}),o=n.createEl("div",{text:"Estimated locally. Providers enforce exact context limits.",cls:"qa-ai-token-note"});n.appendChild(i),n.appendChild(o);let s=new wo.TextAreaComponent(t);s.inputEl.addClass("qa-ai-prompt-textarea"),s.inputEl.setAttribute("aria-label","System prompt");let a=vk(t,s.inputEl,this.settings.systemPrompt??""),l=(0,wo.debounce)(()=>{i.innerText=`Estimated tokens: ${this.systemPromptTokenLength}`},50);s.setValue(this.settings.systemPrompt).onChange(c=>{this.settings.systemPrompt=c,a(c),l()}),l()}addShowAdvancedSettingsToggle(t){new wo.Setting(t).setName("Show advanced settings").setDesc("Sampling settings such as temperature and top p. Untouched settings use the provider's defaults.").addToggle(n=>{n.setValue(this.showAdvancedSettings),n.onChange(i=>{this.showAdvancedSettings=i,this.reload()})})}onClose(){this.isResolved||(this.restoreOriginal(),this.resolve(null)),super.onClose()}};var mue=z('<li class="quickAddCommandListItem"><span class="quickAddCommandLabel"> </span> <div class="quickAddCommandControls"><!> <!> <!></div></li>');function x$(r,e){we(e,!0);var t=mue(),n=I(t),i=I(n,!0);S(n);var o=A(n,2),s=I(o);{let c=O(()=>`Configure ${e.command.name}`);er(s,{iconId:"settings",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onConfigureOpenFile(e.command)})}var a=A(s,2);{let c=O(()=>`Delete ${e.command.name}`);er(a,{iconId:"trash-2",get label(){return h(c)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var l=A(a,2);{let c=O(()=>`Reorder ${e.command.name}`);ki(l,{get label(){return h(c)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(o),S(t),de(()=>me(i,e.command.name)),$(r,t),Ce()}var Rl=require("obsidian");Ck();Yr();var xk=class extends Rl.Modal{constructor(t,n){super(t);this.isResolved=!1;this.originalCommand=n,this.command={...n,type:"OpenFile"},this.command.focus=this.command.focus??!0,this.command.location=this.command.location??this.deriveLocation(),this.syncLegacyFlagsFromLocation(this.command.location),this.waitForClose=new Promise(i=>{this.resolvePromise=i}),this.display(),this.open()}onClose(){super.onClose(),this.isResolved||(this.resolvePromise(null),this.isResolved=!0)}resolveWithGuard(t){this.isResolved||(this.resolvePromise(t),this.isResolved=!0)}display(){this.containerEl.addClass("quickAddModal","openFileCommandSettingsModal"),this.contentEl.empty();let t=this.contentEl.createEl("h2");t.textContent="Open file command settings",t.addClass("qa-modal-title"),this.addFilePathSetting(),this.addOpenLocationSetting(),this.addFocusSetting(),this.addButtonBar()}addFilePathSetting(){new Rl.Setting(this.contentEl).setName("File path").setDesc("Path to the file. Supports formatting like {{DATE}}, {{VALUE}}, etc.").addText(t=>t.setPlaceholder("{{DATE}}todo.md").setValue(this.command.filePath).onChange(n=>{this.command.filePath=n,this.command.name=`Open file: ${n}`}))}addOpenLocationSetting(){let t=[{value:"reuse",label:"Reuse active tab"},{value:"tab",label:"New tab"},{value:"split",label:"Split"},{value:"window",label:"New window"},{value:"left-sidebar",label:"Left sidebar"},{value:"right-sidebar",label:"Right sidebar"}];new Rl.Setting(this.contentEl).setName("Where to open").setDesc("Choose tab, split, window, or sidebar").addDropdown(n=>{for(let{value:i,label:o}of t)n.addOption(i,o);n.setValue(this.deriveLocation()).onChange(i=>{this.command.location=i,this.syncLegacyFlagsFromLocation(i),this.reload()})}),this.deriveLocation()==="split"&&this.addDirectionSetting()}syncLegacyFlagsFromLocation(t){switch(t){case"split":this.command.openInNewTab=!0,this.command.direction||(this.command.direction="vertical");break;case"tab":case"reuse":this.command.openInNewTab=!1,this.command.direction=void 0;break;default:this.command.openInNewTab=!0,this.command.direction=void 0;break}}addDirectionSetting(){new Rl.Setting(this.contentEl).setName("Split direction").setDesc("How to arrange the new pane relative to the current one").addDropdown(t=>{t.addOption("vertical","Split right").addOption("horizontal","Split down").setValue(this.command.direction??"vertical").onChange(n=>{this.command.direction=n})})}addFocusSetting(){new Rl.Setting(this.contentEl).setName("Focus opened file").setDesc("Bring the opened file to the foreground").addToggle(t=>t.setValue(this.command.focus??!0).onChange(n=>{this.command.focus=n}))}deriveLocation(){return this.command.location?this.command.location:this.command.openInNewTab?"split":"reuse"}addButtonBar(){let t=this.contentEl.createDiv({cls:"qa-command-button-row qa-command-button-row-compact"});new Rl.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.resolveWithGuard(null),this.close()}),new Rl.ButtonComponent(t).setButtonText("Save").setCta().onClick(()=>{this.resolveWithGuard(this.command),this.close()})}reload(){this.display()}};Rm();Ii();var hue=z('<li class="quickAddCommandListItem conditionalCommand svelte-p3uofi"><div class="quickAddCommandLabel"><div class="conditionalSummary svelte-p3uofi"> </div> <div class="conditionalBranches svelte-p3uofi"><span> </span> <span> </span></div></div> <div class="quickAddCommandControls"><!> <!> <!> <!> <!></div></li>'),gue={hash:"svelte-p3uofi",code:".conditionalCommand.svelte-p3uofi {flex-wrap:wrap;}.conditionalSummary.svelte-p3uofi {font-weight:600;margin-bottom:4px;}.conditionalBranches.svelte-p3uofi {display:flex;gap:12px;font-size:0.9em;opacity:0.8;}"};function E$(r,e){we(e,!0),ot(r,gue);let t=O(()=>Mm(e.command.condition)),n=O(()=>Dr(e.command.thenCommands).length),i=O(()=>Dr(e.command.elseCommands).length);var o=hue(),s=I(o),a=I(s),l=I(a,!0);S(a);var c=A(a,2),u=I(c),d=I(u);S(u);var f=A(u,2),p=I(f);S(f),S(c),S(s);var m=A(s,2),v=I(m);{let C=O(()=>`Edit condition for ${h(t)}`);er(v,{iconId:"settings",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onConfigureCondition(e.command)})}var g=A(v,2);{let C=O(()=>`Edit then branch for ${h(t)}`);er(g,{iconId:"corner-down-right",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onEditThenBranch(e.command)})}var y=A(g,2);{let C=O(()=>`Edit else branch for ${h(t)}`);er(y,{iconId:"corner-down-left",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onEditElseBranch(e.command)})}var w=A(y,2);{let C=O(()=>`Delete ${e.command.name}`);er(w,{iconId:"trash-2",get label(){return h(C)},extraClass:"clickable",onclick:()=>e.onDeleteCommand(e.command.id)})}var x=A(w,2);{let C=O(()=>`Reorder ${e.command.name}`);ki(x,{get label(){return h(C)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.startDrag},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(m),S(o),de(()=>{me(l,h(t)),me(d,`Then: ${h(n)??""}`),me(p,`Else: ${h(i)??""}`)}),$(r,o),Ce()}var vue=z('<ol class="quickAddCommandList svelte-16btmqx"></ol>'),yue={hash:"svelte-16btmqx",code:".quickAddCommandList.svelte-16btmqx {display:grid;grid-template-columns:auto;width:auto;border:0 solid black;overflow-y:auto;height:auto;margin-bottom:8px;padding:20px;}"};function T$(r,e){let t=Av();we(e,!0),ot(r,yue);let n=he(e,"commands",31,()=>bt([])),i=O(()=>{let U=new Set;return Array.isArray(n())?n().filter(q=>{if(typeof q!="object"||q===null)return!1;let B=q.id;return typeof B!="string"||B===""||U.has(B)?!1:(U.add(B),!0)}):[]}),o=`command:${t}`,s=zG.Platform.isMobile,a=ok(),l=O(()=>!s&&!a.armed),c=U=>U,u=U=>U,d=U=>U,f=U=>U,p=U=>U,m=U=>U;function v(){e.saveCommands(yh(n()))}function g(U){a.markStarted(),n(Ml(U.detail.items))}function y(U){n(Ml(U.detail.items)),U.detail.info.source===Qi.POINTER&&a.reset(),v()}let w=()=>{a.startDrag()};function x(U,q){let B=Ml(h(i)),ie=B.findIndex(ae=>ae.id===U);if(ie===-1)return;let W=ie+q;if(W<0||W>=B.length)return;let Y=[...B],[X]=Y.splice(ie,1);Y.splice(W,0,X),n(Y),v(),Fl(`Moved ${Yp(X)} to position ${W+1} of ${B.length}`)}function C(U){n(CG(h(i),U)),v()}async function _(U){await e.onConfigureCondition?.(U)&&C(U)}async function E(U){await e.onEditThenBranch?.(U)&&C(U)}async function D(U){await e.onEditElseBranch?.(U)&&C(U)}async function P(U){let q=await V(U.choice)?.waitForClose;if(!q)return;let B={...U,choice:q,name:q.name};C(B)}function V(U){switch(U.type){case"Template":return new xh(e.app,U,e.plugin);case"Capture":return new wh(e.app,U,e.plugin);default:break}}async function j(U){let q=await Aa(U,e.app);if(!q){F.logWarning(`${U.name} could not be loaded.`);return}let B=q.settings??{};new gk(e.app,U,B,()=>v()).open()}async function oe(U){await new wk(e.app,U).waitForClose&&C(U)}async function se(U){let q=await new xk(e.app,U).waitForClose;q&&C(q)}var M=vue();ar(M,21,()=>Ml(h(i)),U=>U.id,(U,q)=>{var B=un(),ie=Pe(B);{var W=xe=>{{let Ue=O(()=>c(h(q)));l$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onUpdateCommand:C,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},Y=xe=>{{let Ue=O(()=>u(h(q)));c$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onConfigureChoice:P,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},X=xe=>{{let Ue=O(()=>d(h(q)));u$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onConfigureScript:j,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},ae=xe=>{{let Ue=O(()=>f(h(q)));b$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onConfigureAssistant:oe,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},pe=xe=>{{let Ue=O(()=>p(h(q)));x$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onConfigureOpenFile:se,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},ge=xe=>{{let Ue=O(()=>m(h(q)));E$(xe,{get command(){return h(Ue)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onConfigureCondition:_,onEditThenBranch:E,onEditElseBranch:D,onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})}},be=xe=>{a$(xe,{get command(){return h(q)},get dragDisabled(){return h(l)},startDrag:w,get onDeleteCommand(){return e.deleteCommand},onMoveUp:()=>x(h(q).id,-1),onMoveDown:()=>x(h(q).id,1)})};ne(ie,xe=>{h(q).type==="Wait"?xe(W):h(q).type==="NestedChoice"?xe(Y,1):h(q).type==="UserScript"?xe(X,2):h(q).type==="AIAssistant"?xe(ae,3):h(q).type==="OpenFile"?xe(pe,4):h(q).type==="Conditional"?xe(ge,5):xe(be,-1)})}$(U,B)}),S(M),Fr(M,(U,q)=>nk?.(U,q),()=>ik({items:h(i),dragDisabled:h(l),type:o,resolveLabel:Yp})),oc("consider",M,g),oc("finalize",M,y),$(r,M),Ce()}function HG(r){return bt(r)}Vc();Yr();ml();var fx=class extends ui{constructor(t,n){super(t,"Obsidian");this.generateId=()=>this.id=xr();this.commandId=n}};Vc();Yr();var Ek=class extends ui{constructor(e,t){super(e,"Choice"),this.choiceId=t}};Vc();Yr();var Tk=class extends ui{constructor(e){super("Wait","Wait"),this.time=e}};Yr();Vc();var _k=class extends ui{constructor(e){super(e.name,"NestedChoice"),this.choice=e}};ml();var $l=class{constructor(e,t){this.id=xr(),this.name=e,this.type=t,this.command=!1,this.onePageInput=void 0}};Tt();var Bh=class extends $l{constructor(e){super(e,"Capture"),this.appendLink=!1,this.copyLinkToClipboard=!1,this.captureTo="",this.captureToActiveFile=!1,this.captureToCanvasNodeId="",this.activeFileWritePosition="cursor",this.createFileIfItDoesntExist={enabled:!1,createWithTemplate:!1,template:""},this.format={enabled:!1,format:""},this.insertAfter={enabled:!1,after:"",insertAtEnd:!1,considerSubsections:!1,createIfNotFound:!1,createIfNotFoundLocation:"top",inline:!1,replaceExisting:!1,blankLineAfterMatchMode:"auto",promptHeading:!1},this.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"},this.newLineCapture={enabled:!1,direction:"below"},this.prepend=!1,this.task=!1,this.openFile=!1,this.fileOpening=dn(),this.templater={afterCapture:"none"}}static Load(e){let t=e;return t.activeFileWritePosition!=="cursor"&&t.activeFileWritePosition!=="top"&&t.activeFileWritePosition!=="bottom"&&(t.activeFileWritePosition="cursor"),typeof t.captureToCanvasNodeId!="string"&&(t.captureToCanvasNodeId=""),t.insertBefore||(t.insertBefore={enabled:!1,before:"",createIfNotFound:!1,createIfNotFoundLocation:"top"}),t.captureToActiveFile&&t.prepend&&!t.insertAfter?.enabled&&!t.insertBefore.enabled&&!t.newLineCapture?.enabled&&(t.activeFileWritePosition!=="top"&&(t.activeFileWritePosition="bottom"),t.prepend=!1),t.templater||(t.templater={afterCapture:"none"}),t.templater.afterCapture!=="wholeFile"&&(t.templater.afterCapture="none"),t.insertAfter&&!t.insertAfter.blankLineAfterMatchMode&&(t.insertAfter.blankLineAfterMatchMode="auto"),t.insertAfter&&t.insertAfter.inline===void 0&&(t.insertAfter.inline=!1),t.insertAfter&&t.insertAfter.replaceExisting===void 0&&(t.insertAfter.replaceExisting=!1),t.insertAfter&&t.insertAfter.promptHeading===void 0&&(t.insertAfter.promptHeading=!1),t.insertAfter?.createIfNotFoundLocation===_a&&(t.insertAfter.createIfNotFound&&!t.insertAfter.orderBy&&(t.insertAfter.orderBy={by:"insertion",direction:"desc",unparseable:"bottom"}),t.insertAfter.inline=!1),t}};var rd=class extends $l{constructor(e){super(e,"Template"),this.templatePath="",this.fileNameFormat={enabled:!1,format:""},this.discoverExistingNotesBeforeCreate=!1,this.folder={enabled:!1,folders:[],chooseWhenCreatingNote:!1,createInSameFolderAsActiveFile:!1,chooseFromSubfolders:!1},this.appendLink=!1,this.copyLinkToClipboard=!1,this.openFile=!1,this.fileOpening=dn(),this.fileExistsBehavior={kind:"prompt"}}static Load(e){return e}};var jG=require("obsidian");Tt();Kv();function Ak(r){let e=[];for(let t of r.vault.getFiles())d0.test(t.path)?e.push({file:t,isMarkdown:!1}):ir.test(t.path)&&bue(r,t)&&e.push({file:t,isMarkdown:!0});return e}function bue(r,e){return r.metadataCache.getFileCache(e)?.sections?.some(n=>n.type==="code")??!1}function GG(r,e,t){let n=e.find(s=>s.file.path===t);if(n)return n;let i=e.find(s=>!s.isMarkdown&&s.file.basename===t);if(i)return i;let o=r.vault.getAbstractFileByPath(t);if(o instanceof jG.TFile){if(d0.test(o.path))return{file:o,isMarkdown:!1};if(ir.test(o.path))return{file:o,isMarkdown:!0}}return null}async function mx(r,e){let t=await r.vault.read(e),{code:n,error:i}=hc(t);return n!==null&&n.length>0?null:i??"No ```js code block found in the note."}function _$(r){return r.isMarkdown?r.file.path:r.file.basename}Vc();Yr();var hx=class extends ui{constructor(e,t){super(e,"UserScript"),this.path=t,this.settings={}}};Wp();var YG=require("obsidian");function kk(r){let t=new YG.Notice("",1e4).messageEl;t.replaceChildren(),Uh(t,"No scripts found","quickadd-notice-title");let n=t.ownerDocument,i=n.createElement("div");t.append(i),Uh(i,"QuickAdd cannot find any .js files or notes with a ```js code block in your vault."),i.append(n.createElement("br")),Uh(i,"Please make sure your scripts are:"),Uh(i,`\u2713 In your vault (not in ${r.vault.configDir} folder)`),Uh(i,"\u2713 Not in hidden folders (starting with a dot)"),Uh(i,"\u2713 A .js file, or a note containing a ```js code block"),i.append(n.createElement("br")),PA(i,Al.userScripts,"View documentation")}function Uh(r,e,t){let n=r.ownerDocument.createElement("div");return n.textContent=e,t&&n.classList.add(t),r.append(n),n}nd();Me();gs();A$();k$();S$();D$();I$();P$();F$();M$();R$();$$();Vc();Yr();It();es();var Dk=class extends ui{constructor(){super("AI Assistant","AIAssistant");let e=ce.getState().ai;this.model=e.defaultModel;let t=mu(e.defaultModel,e.defaultModelRef);this.modelRef=t?{...t}:void 0,this.systemPrompt=e.defaultSystemPrompt,this.outputVariableName="output",this.promptTemplate={enable:!1,name:""},this.modelParameters={}}};It();Yr();ml();Ck();var Ik=class{constructor(e="{{DATE}}.md",t=!1,n,i,o=!0){this.filePath=e;this.type="OpenFile";this.id=xr();this.openInNewTab=t,this.direction=n,this.location=i,this.focus=o,this.name=`Open file: ${this.filePath}`,this.applyLegacyFromLocation()}applyLegacyFromLocation(){if(this.location)switch(this.location){case"split":this.openInNewTab=!0,this.direction||(this.direction="vertical");break;case"tab":case"reuse":this.openInNewTab=!1,this.direction=void 0;break;default:this.openInNewTab=!0,this.direction=void 0;break}}};qt();Vc();Yr();function wue(){return{mode:"variable",variableName:"",operator:"isTruthy",valueType:"string"}}function Cue(r){return r.mode==="variable"?{...r}:{...r}}var Pk=class extends ui{constructor(e){super(e?.name??"If condition","Conditional"),this.condition=e?.condition?Cue(e.condition):wue(),this.thenCommands=e?.thenCommands?[...e.thenCommands]:[],this.elseCommands=e?.elseCommands?[...e.elseCommands]:[]}};Uc();Ii();var xue=z(`<div class="qaDataUnreadable svelte-ktqmtm"><div class="qaDataUnreadableHead svelte-ktqmtm"><!> <span class="qaDataUnreadableTitle svelte-ktqmtm"> </span></div> <p class="qaDataUnreadableBody svelte-ktqmtm">The saved value isn't in a shape QuickAdd understands, so it can't be shown
|
||
or edited here. Nothing has been changed or deleted, and QuickAdd will not
|
||
overwrite it.</p> <p class="qaDataUnreadableBody svelte-ktqmtm">It's stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this
|
||
vault. Make a copy of that file before editing it.</p></div>`),Eue={hash:"svelte-ktqmtm",code:".qaDataUnreadable.svelte-ktqmtm {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaDataUnreadableHead.svelte-ktqmtm {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaDataUnreadableTitle.svelte-ktqmtm {font-weight:var(--font-semibold);color:var(--text-normal);}.qaDataUnreadableBody.svelte-ktqmtm {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}"};function O$(r,e){ot(r,Eue);var t=xue(),n=I(t),i=I(n);Rt(i,{iconId:"alert-triangle",size:16});var o=A(i,2),s=I(o);S(o),S(n),In(4),S(t),de(()=>me(s,`QuickAdd couldn't read ${e.what??""}`)),$(r,t)}var Qh=class{constructor(e){this.obsidianCommands=[];this.scriptCandidates=[];this.commandListHandle=null;this.commandListProps=null;this.containerEl=null;this.unreadableCardHandle=null;this.app=e.app,this.plugin=e.plugin,this.unreadable=Di(e.commands),this.commandsRef=d$(e.commands).commands,this.choices=e.choices,this.onCommandsChange=e.onCommandsChange,this.conditionalHandlers=e.conditionalHandlers,this.loadObsidianCommands(),this.loadScriptCandidates()}render(e){return this.destroy(),this.containerEl=e,e.empty(),e.addClass("quickAddCommandEditor"),this.unreadable?(this.renderUnreadableCard(e),!1):this.renderCommandList(e)?(this.renderCommandBar(e),this.renderAddObsidianCommandSetting(e),this.renderAddEditorCommandSetting(e),this.renderAddUserScriptSetting(e),this.renderAddChoiceSetting(e),!0):!1}renderUnreadableCard(e){let t=e.createDiv("commandList");this.unreadableCardHandle=qi(t,O$,{what:"this macro's commands"},{what:"this macro's commands"})}destroy(){this.commandListHandle?.destroy(),this.commandListHandle=null,this.commandListProps=null,this.unreadableCardHandle?.destroy(),this.unreadableCardHandle=null}loadObsidianCommands(){Object.keys(this.app.commands.commands).forEach(e=>{let t=this.app.commands.commands[e];this.obsidianCommands.push(new fx(t.name,t.id))})}loadScriptCandidates(){this.scriptCandidates=Ak(this.app)}renderCommandList(e){let t=e.createDiv("commandList");return this.commandListProps=HG({app:this.app,plugin:this.plugin,commands:this.commandsRef,deleteCommand:async n=>{let i=this.commandsRef.find(a=>a.id===n);if(!i)throw F.logError("command not found"),new Error("command not found");if(!await Xi.Prompt(this.app,"Are you sure you wish to delete this command?",`If you click yes, you will delete '${i.name}'.`))return;if(!await dx(this.app,i)){new Fi.Notice("Could not clear user script secrets. Command was not deleted.");return}this.commandsRef=this.commandsRef.filter(a=>a.id!==n),this.emitCommandsChanged()},saveCommands:n=>{this.commandsRef=n,this.onCommandsChange?.(n)},onConfigureCondition:this.conditionalHandlers?.configureCondition,onEditThenBranch:this.conditionalHandlers?.editThenBranch,onEditElseBranch:this.conditionalHandlers?.editElseBranch}),this.commandListHandle=qi(t,T$,this.commandListProps,{what:"this macro's commands"}),this.commandListHandle.ok}renderCommandBar(e){let t=e.createDiv("quickCommandContainer");this.addChoiceButton(t,"Capture",Bh),this.addChoiceButton(t,"Template",rd),this.addOpenFileCommandButton(t),this.addWaitCommandButton(t),this.addConditionalCommandButton(t),ce.getState().disableOnlineFeatures||this.addAIAssistantCommandButton(t)}renderAddObsidianCommandSetting(e){let t,n=()=>{let i=t.getValue(),o=this.obsidianCommands.find(a=>a.name===i);if(!o){F.logError(`Could not find Obsidian command with name "${i}"`);return}let s=new fx(o.name,o.commandId);s.generateId(),this.addCommand(s),t.setValue("")};new Fi.Setting(e).setName("Obsidian command").setDesc("Add an Obsidian command").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Obsidian command"),new ni(this.app,i.inputEl,this.obsidianCommands.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}renderAddEditorCommandSetting(e){let t,n=()=>{let i=t.getValue(),o;switch(i){case"Copy":o=new Vh;break;case"Cut":o=new qh;break;case"Paste":o=new Wh;break;case"Paste with format":o=new zh;break;case"Select active line":o=new Hh;break;case"Select link on active line":o=new jh;break;case"Move cursor to file start":o=new Gh;break;case"Move cursor to file end":o=new Yh;break;case"Move cursor to line start":o=new Kh;break;case"Move cursor to line end":o=new Xh;break;default:throw F.logError("invalid editor command type"),new Error("invalid editor command type")}this.addCommand(o),t.setValue("")};new Fi.Setting(e).setName("Editor commands").setDesc("Add editor command").addDropdown(i=>{t=i,i.selectEl.addClass("qa-command-sequence-input"),i.addOption("","Select command").addOption("Copy","Copy").addOption("Cut","Cut").addOption("Paste","Paste").addOption("Paste with format","Paste with format").addOption("Select active line","Select active line").addOption("Select link on active line","Select link on active line").addOption("Move cursor to file start","Move cursor to file start").addOption("Move cursor to file end","Move cursor to file end").addOption("Move cursor to line start","Move cursor to line start").addOption("Move cursor to line end","Move cursor to line end")}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}renderAddUserScriptSetting(e){let t,n=null,i=async()=>{this.loadScriptCandidates();let o=t.getValue().trim();if(!o)return;let s=np(o).basename??o,a=GG(this.app,this.scriptCandidates,s);if(!a){new Fi.Notice(`QuickAdd: No script or js-block note named "${o}" found.`);return}if(a.isMarkdown){let l=await mx(this.app,a.file);if(l){new Fi.Notice(`QuickAdd: "${a.file.path}" \u2014 ${l}`);return}}this.addCommand(new hx(o,a.file.path)),t.setValue(""),n&&n.buttonEl.addClass("qa-hidden")};new Fi.Setting(e).setName("User scripts").setDesc("Add a .js file or a note with a ```js code block - type the name or click Browse").addText(o=>{t=o,o.inputEl.addClass("qa-command-sequence-input"),o.setPlaceholder("Start typing script name..."),new ni(this.app,o.inputEl,this.scriptCandidates.map(s=>_$(s))),o.inputEl.addEventListener("keypress",s=>{s.key==="Enter"&&i()})}).addButton(o=>o.setButtonText("Browse").setTooltip("Browse and select a script (.js file or note)").onClick(async()=>{let s=await this.showScriptPicker();if(s){let a=s.isMarkdown?s.file.path:s.file.basename;this.addCommand(new hx(a,s.file.path))}})).addButton(o=>{n=o,o.setButtonText("Add").setCta().onClick(()=>{i()}),o.buttonEl.addClass("qa-hidden")}),t.onChange(o=>{n&&n.buttonEl.toggleClass("qa-hidden",o.trim().length===0)})}renderAddChoiceSetting(e){let t,n=()=>{let i=t.getValue(),o=this.choices.find(s=>s.name===i);if(!o){new Fi.Notice(`QuickAdd: No choice named "${i}".`);return}this.addCommand(new Ek(o.name,o.id)),t.setValue("")};new Fi.Setting(e).setName("Choices").setDesc("Add existing choice").addText(i=>{t=i,i.inputEl.addClass("qa-command-sequence-input"),i.setPlaceholder("Choice"),new ni(this.app,i.inputEl,this.choices.map(o=>o.name)),i.inputEl.addEventListener("keypress",o=>{o.key==="Enter"&&n()})}).addButton(i=>i.setCta().setButtonText("Add").onClick(n))}addChoiceButton(e,t,n){new Fi.ButtonComponent(e).setButtonText(t).setTooltip(`Add ${t} choice`).onClick(()=>{let o=new n(`Untitled ${t} Choice`);this.addCommand(new _k(o))})}addOpenFileCommandButton(e){new Fi.ButtonComponent(e).setIcon("file-search").setTooltip("Add open file command").onClick(()=>{this.addCommand(new Ik)})}addAIAssistantCommandButton(e){new Fi.ButtonComponent(e).setIcon("bot").setTooltip("Add AI Assistant command").onClick(()=>{this.addCommand(new Dk)})}addWaitCommandButton(e){new Fi.ButtonComponent(e).setIcon("clock").setTooltip("Add wait command").onClick(()=>{this.addCommand(new Tk(100))})}addConditionalCommandButton(e){new Fi.ButtonComponent(e).setIcon("git-branch").setTooltip("Add conditional command").onClick(()=>{this.addCommand(new Pk)})}async showScriptPicker(){if(this.loadScriptCandidates(),this.scriptCandidates.length===0)return kk(this.app),null;let e=this.scriptCandidates.map(o=>o.file.path),t=this.scriptCandidates.map(o=>_$(o)),n=await an.Suggest(this.app,t,e,{placeholder:"Select a script (.js file or note with a ```js block)",emptyStateText:"No scripts found in your vault"});if(!n)return null;let i=this.scriptCandidates.find(o=>o.file.path===n);if(!i)return null;if(i.isMarkdown){let o=await mx(this.app,i.file);if(o)return new Fi.Notice(`QuickAdd: "${i.file.path}" \u2014 ${o}`),null}return i}addCommand(e){this.commandsRef=[...this.commandsRef,e],this.emitCommandsChanged()}emitCommandsChanged(){this.commandListProps&&(this.commandListProps.commands=[...this.commandsRef]),this.onCommandsChange?.(this.commandsRef)}};var di=require("obsidian");Rm();nd();function XG(r){return r.mode==="variable"?{...r}:{...r}}function Tue(){return{mode:"variable",variableName:"",operator:"isTruthy",valueType:"boolean"}}function _ue(){return{mode:"script",scriptPath:""}}var Fk=class extends di.Modal{constructor(t,n){super(t);this.isResolved=!1;this.scriptCandidates=[];this.originalCommand=n,this.workingCommand={...n,condition:XG(n.condition)},this.waitForClose=new Promise(i=>{this.resolvePromise=i}),this.loadScriptCandidates(),this.display(),this.open()}onClose(){super.onClose(),this.isResolved||this.resolve(null)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}loadScriptCandidates(){this.scriptCandidates=Ak(this.app)}reload(){this.display()}display(){this.containerEl.addClass("quickAddModal","conditionalSettingsModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:"Configure conditional command"}).addClass("qa-modal-title"),this.renderModeSelector(),this.workingCommand.condition.mode==="variable"?this.renderVariableConfiguration(this.workingCommand.condition):this.renderScriptConfiguration(this.workingCommand.condition),this.renderButtonBar()}renderModeSelector(){new di.Setting(this.contentEl).setName("Condition type").setDesc("Choose how this condition should be evaluated.").addDropdown(t=>{t.addOption("variable","Macro variable").addOption("script","Run script").setValue(this.workingCommand.condition.mode).onChange(n=>{n!==this.workingCommand.condition.mode&&(this.workingCommand.condition=n==="variable"?Tue():_ue(),this.reload())})})}renderVariableConfiguration(t){this.renderVariableNameSetting(t),this.renderOperatorSetting(t),this.renderValueTypeSetting(t),Ou(t.operator)&&this.renderExpectedValueSetting(t)}renderVariableNameSetting(t){new di.Setting(this.contentEl).setName("Variable name").setDesc("Name of the macro variable to inspect (without the $ prefix).").addText(n=>n.setPlaceholder("e.g. projectStatus").setValue(t.variableName).onChange(i=>{t.variableName=i.trim()}))}renderOperatorSetting(t){let n=[{value:"equals",label:"Equals"},{value:"notEquals",label:"Does not equal"},{value:"lessThan",label:"Less than"},{value:"lessThanOrEqual",label:"Less than or equal"},{value:"greaterThan",label:"Greater than"},{value:"greaterThanOrEqual",label:"Greater than or equal"},{value:"contains",label:"Contains"},{value:"notContains",label:"Does not contain"},{value:"isTruthy",label:"Is truthy"},{value:"isFalsy",label:"Is falsy"}];new di.Setting(this.contentEl).setName("Operator").setDesc("How to compare the variable value.").addDropdown(i=>{i.addOptions(n.reduce((o,s)=>(o[s.value]=s.label,o),{})),i.setValue(t.operator),i.onChange(o=>{t.operator=o,t.valueType=GV(t.operator),Ou(t.operator)||delete t.expectedValue,this.reload()})})}renderValueTypeSetting(t){new di.Setting(this.contentEl).setName("Value type").setDesc("How to interpret the comparison value.").addDropdown(n=>{n.addOption("string","Text").addOption("number","Number").addOption("boolean","Boolean").setValue(t.valueType).onChange(i=>{t.valueType=i,this.reload()})})}renderExpectedValueSetting(t){if(t.valueType==="boolean"){new di.Setting(this.contentEl).setName("Expected value").setDesc("Choose true or false.").addDropdown(n=>{n.addOption("true","True").addOption("false","False").setValue(t.expectedValue??"true").onChange(i=>{t.expectedValue=i})});return}new di.Setting(this.contentEl).setName("Expected value").setDesc("Value to compare against.").addText(n=>{n.setPlaceholder("Enter comparison value").setValue(t.expectedValue??"").onChange(i=>{t.expectedValue=i})})}renderScriptConfiguration(t){this.renderScriptPathSetting(t),this.renderScriptExportSetting(t)}renderScriptPathSetting(t){let n;new di.Setting(this.contentEl).setName("Script path").setDesc("Vault-relative path to a .js file or a note with a ```js code block.").addText(i=>{n=i,i.setPlaceholder("scripts/myCheck.js or Notes/myCheck.md").setValue(t.scriptPath).onChange(o=>{t.scriptPath=o.trim()})}).addButton(i=>i.setButtonText("Browse").setTooltip("Select a script (.js file or note)").onClick(async()=>{if(this.loadScriptCandidates(),this.scriptCandidates.length===0){kk(this.app);return}let o=this.scriptCandidates.map(l=>l.file.path),s=await an.Suggest(this.app,o,o,{placeholder:"Select a script (.js file or note with a ```js block)",emptyStateText:"No scripts found in your vault"});if(!s)return;let a=this.scriptCandidates.find(l=>l.file.path===s);if(a?.isMarkdown){let l=await mx(this.app,a.file);if(l){new di.Notice(`QuickAdd: "${a.file.path}" \u2014 ${l}`);return}}t.scriptPath=s,n.setValue(s)}))}renderScriptExportSetting(t){new di.Setting(this.contentEl).setName("Export name").setDesc("Optional export or member to call (use :: to access nested members).").addText(n=>n.setPlaceholder("default").setValue(t.exportName??"").onChange(i=>{t.exportName=i.trim()||void 0}))}renderButtonBar(){let t=this.contentEl.createDiv({cls:"qa-command-button-row"});new di.ButtonComponent(t).setButtonText("Cancel").onClick(()=>{this.resolve(null),this.close()}),new di.ButtonComponent(t).setCta().setButtonText("Save").onClick(()=>{this.validateCondition()&&(this.applyChanges(),this.resolve(this.originalCommand),this.close())})}validateCondition(){let t=this.workingCommand.condition;return t.mode==="variable"?t.variableName.trim()?!0:(new di.Notice("QuickAdd: Enter a variable name before saving."),!1):t.scriptPath.trim()?!0:(new di.Notice("QuickAdd: Enter a script path before saving."),!1)}applyChanges(){this.originalCommand.condition=XG(this.workingCommand.condition);let t=Mm(this.originalCommand.condition);this.originalCommand.name=`If ${t}`}};var Zh=require("obsidian");vi();Ii();var Mk=class extends Zh.Modal{constructor(t){super(t.app);this.commandEditor=null;this.isResolved=!1;this.plugin=t.plugin,this.choices=t.choices,this.conditionalHandlers=t.conditionalHandlers,this.workingCommands=ht(t.commands),this.waitForClose=new Promise(n=>{this.resolvePromise=n}),this.display(t.title),this.open()}onClose(){super.onClose(),this.commandEditor?.destroy(),this.isResolved||this.resolve(null)}resolve(t){this.isResolved||(this.isResolved=!0,this.resolvePromise(t))}display(t){this.containerEl.addClass("quickAddModal","conditionalBranchModal"),this.contentEl.empty(),this.contentEl.createEl("h2",{text:t}).addClass("qa-modal-title");let i=this.contentEl.createDiv("branchCommandEditor");this.commandEditor=new Qh({app:this.app,plugin:this.plugin,commands:this.workingCommands,choices:this.choices,onCommandsChange:s=>{this.workingCommands=s},conditionalHandlers:this.conditionalHandlers});let o=this.commandEditor.render(i);this.renderButtonBar(o)}renderButtonBar(t){let n=this.contentEl.createDiv({cls:"qa-command-button-row"});if(!t){new Zh.ButtonComponent(n).setCta().setButtonText("Close").onClick(()=>{this.resolve(null),this.close()});return}new Zh.ButtonComponent(n).setButtonText("Cancel").onClick(()=>{this.resolve(null),this.close()}),new Zh.ButtonComponent(n).setCta().setButtonText("Save").onClick(()=>{this.resolve(Dr(this.workingCommands)),this.close()})}};var Rk=require("obsidian");Wt();fc();function Aue(r){let e=r.trim();return e||void 0}function kue(r){return(typeof r.icon=="string"?r.icon.trim():"")||bm(r.type)}function $k(r,e,t,n){let i=bm(t.type),o=new Rk.Setting(e).setName("Icon").setDesc(`Lucide/Obsidian icon id. Leave empty to use ${i}.`);o.settingEl.addClass("qa-choice-icon-setting");let s=zr(e,"span");s.classList.add("qa-choice-icon-setting-preview"),s.setAttribute("aria-hidden","true"),o.controlEl.appendChild(s);function a(){s.replaceChildren(),(0,Rk.setIcon)(s,kue(t))}o.addText(l=>{l.setPlaceholder(i),l.setValue(typeof t.icon=="string"?t.icon:""),l.inputEl.addClass("qa-choice-icon-input"),l.inputEl.setAttribute("aria-label","Choice icon"),new ni(r,l.inputEl,MA,50),l.onChange(c=>{let u=Aue(c);t.icon=u,n(u),a()})}),a()}Wt();Ii();ml();function Sue(r){let e=[],t=n=>{n.forEach(i=>{Ye(i)&&(i.type==="Multi"?t(st(i)):e.push(i))})};return t(hn(r)),e}var Ok=class extends Nk.Modal{constructor(t,n,i,o){super(t);this.choices=[];this.commandEditor=null;this.choice=i,this.macro=i.macro,this.choices=Sue(o),this.plugin=n,this.waitForClose=new Promise(s=>{this.resolvePromise=s}),this.display(),RA(this,"macro"),this.open()}onClose(){super.onClose(),this.resolvePromise(this.choice),this.commandEditor?.destroy(),this.commandEditor=null}display(){this.containerEl.addClass("quickAddModal","macroBuilder"),this.contentEl.empty(),this.addCenteredHeader(this.choice.name),this.addCommandEditor(),this.addRunOnStartupSetting(),this.addIconSetting()}addCenteredHeader(t){let n=this.contentEl.createEl("h2");n.addClass("qa-clickable-modal-title"),n.createEl("button",{cls:"qa-rename-title-button",text:t,attr:{type:"button","aria-label":`Rename ${t}`}}).addEventListener("click",()=>{(async()=>{try{let o=await Sr.Prompt(this.app,`Update name for ${this.choice.name}`,this.choice.name,this.choice.name);if(!o)return;this.choice.name=o,ed(this.macro)&&(this.macro.name=o),this.reload()}catch{}})()})}addRunOnStartupSetting(){new Nk.Setting(this.contentEl).setName("Run on startup").setDesc("Execute this macro when Obsidian starts").addToggle(t=>t.setValue(this.choice.runOnStartup).onChange(n=>{this.choice.runOnStartup=n}))}addIconSetting(){$k(this.app,this.contentEl,this.choice,t=>{this.choice.icon=t})}reload(){this.commandEditor?.destroy(),this.commandEditor=null,this.display()}macroCommandsValue(){return Wn(this.macro)}setMacroCommands(t){if(!ed(this.macro)){this.macro={id:xr(),name:this.choice.name,commands:t},this.choice.macro=this.macro;return}this.macro.commands=t}addCommandEditor(){let t=this.contentEl.createDiv("macroBuilder__editor");this.commandEditor=new Qh({app:this.app,plugin:this.plugin,commands:this.macroCommandsValue(),choices:this.choices,onCommandsChange:n=>{this.setMacroCommands(n)},conditionalHandlers:this.buildConditionalHandlers()}),this.commandEditor.render(t)}buildConditionalHandlers(){return{configureCondition:t=>this.configureConditionalCondition(t),editThenBranch:t=>this.configureConditionalBranch(t,"then"),editElseBranch:t=>this.configureConditionalBranch(t,"else")}}async configureConditionalCondition(t){return await new Fk(this.app,t).waitForClose!==null}async configureConditionalBranch(t,n){let i=n==="then"?"Then branch":"Else branch",s=await new Mk({app:this.app,plugin:this.plugin,choices:this.choices,title:`Edit ${i} commands`,commands:n==="then"?t.thenCommands:t.elseCommands,conditionalHandlers:this.buildConditionalHandlers()}).waitForClose;return s?(n==="then"?t.thenCommands=s:t.elseCommands=s,!0):!1}};var id=require("obsidian");Wr();var Lk=class extends id.Modal{constructor(t,n){super(t);this.choice=n;this.didSubmit=!1;this.name=n.name,this.placeholder=n.placeholder??"",this.icon=typeof n.icon=="string"?n.icon:void 0,this.waitForClose=new Promise((i,o)=>{this.resolvePromise=i,this.rejectPromise=o}),this.containerEl.addClass("quickAddModal","qaMultiChoiceSettingsModal"),this.display(),this.open()}display(){this.contentEl.empty(),this.titleEl.setText("Edit folder"),new id.Setting(this.contentEl).setName("Name").addText(n=>{n.setValue(this.name).onChange(i=>{this.name=i})}),new id.Setting(this.contentEl).setName("Placeholder").setDesc("Shown in the choice picker search box when this folder opens. Leave blank to use the folder name.").addText(n=>{n.setPlaceholder("Defaults to the folder name"),n.setValue(this.placeholder).onChange(i=>{this.placeholder=i})}),$k(this.app,this.contentEl,{type:this.choice.type,icon:this.icon},n=>{this.icon=n});let t=this.contentEl.createDiv();new id.ButtonComponent(t).setButtonText("Save").setCta().onClick(()=>this.submit()),new id.ButtonComponent(t).setButtonText("Cancel").onClick(()=>this.cancel()),t.addClass("qa-modal-button-row")}submit(){this.didSubmit||(this.didSubmit=!0,this.close())}cancel(){this.close()}onClose(){if(super.onClose(),!this.didSubmit){this.rejectPromise(tn());return}let t=this.placeholder.trim(),n={...this.choice,name:this.name.trim()||this.choice.name,placeholder:t||void 0,icon:this.icon};this.resolvePromise(n)}};It();ml();var Bk=class{constructor(e){this.name=e,this.id=xr(),this.commands=[]}};var Jh=class extends $l{constructor(t){super(t,"Macro");this.runOnStartup=!1;this.macro=new Bk(t)}};var eg=class extends $l{constructor(t){super(t,"Multi");this.choices=[];this.collapsed=!1}addChoice(t){return this.choices.push(t),this}addChoices(t){return this.choices.push(...t),this}};Ii();Wt();vi();function N$(r,e){let t=ht(r);for(let n of e)delete t[n];return t}vi();Uc();Me();Ec();var Due={Template:rd,Capture:Bh,Macro:Jh,Multi:eg};function B$(r,e){let t=Due[r];if(!t)throw new Error(`Unknown choice type: ${r}`);return new t(e)}function ZG(r,e){let t=B$(r.type,`${r.name} (copy)`);if(r.type==="Multi"){let n=t,i=r;return Object.assign(n,N$(i,["id","name","choices"])),xc(i)?n.choices=st(i).filter(Ye).map(o=>ZG(o,e)):n.choices=i.choices,n}return Object.assign(t,N$(r,["id","name"])),r.type==="Macro"&&(t.macro=ht(r.macro),TG(t.macro),Rh(t,e)),t}async function JG(r,e){let t=await Iue(e,r);return ZG(r,{secretOptionNamesByPath:t,stripUnknownStringSettings:!0})}function eY(r){return r!==null&&typeof r=="object"}function L$(r,e){if(eY(r)){if(r.type==="UserScript"&&typeof r.path=="string"&&e.add(r.path),Array.isArray(r.thenCommands))for(let t of r.thenCommands)L$(t,e);if(Array.isArray(r.elseCommands))for(let t of r.elseCommands)L$(t,e);U$(r.choice,e)}}function U$(r,e){if(eY(r)){if(r.type==="Macro"){let t=Wn(r.macro);if(Array.isArray(t))for(let n of t)L$(n,e)}if(r.type==="Multi"&&Array.isArray(r.choices))for(let t of r.choices)U$(t,e)}}async function Iue(r,e){let t=new Set;U$(e,t);let n=new Map;for(let i of t)try{if(Un(i)||!await r.vault.adapter.exists(i))continue;let s=Ph(await r.vault.adapter.read(i),i);n.set(i,s.foundSecretOptions&&s.names.size===0?null:s.names)}catch(o){F.logWarning(`QuickAdd could not inspect user-script settings '${i}' while duplicating choice: ${o?.message??o}`)}return n}function Pue(r,e,t){let i={Template:()=>new xh(e,r,t),Capture:()=>new wh(e,r,t),Macro:()=>new Ok(e,t,r,ce.getState().choices),Multi:()=>{}}[r.type];return typeof i=="function"?i():void 0}async function tY(r,e){let t=r.type==="Multi",n=r.type==="Macro",i=l=>{if(Ws(l))return"QuickAdd couldn't read this folder's contents. Deleting it also deletes whatever is still stored under it in data.json.";let c=Bn(st(l));if(c.length===0)return"";let u=c.filter(p=>p.type==="Multi").length,d=c.length-u,f=[];return d>0&&f.push(`${d} ${d===1?"choice":"choices"}`),u>0&&f.push(`${u} ${u===1?"folder":"folders"}`),`Deleting this folder will also delete everything inside it: ${f.join(" and ")}.`},o=l=>Di(Wn(l.macro))?"QuickAdd couldn't read this macro's commands. Deleting it also deletes whatever is still stored under it in data.json.":"Deleting this choice will also delete its macro commands.",s=[`Are you sure you want to delete '${r.name}'?`,t?i(r):"",n?o(r):""].filter(Boolean).join(" ");return await Xi.Prompt(e,`Delete ${Sm(r.type)}`,s)?(n||t)&&!await dx(e,{type:"NestedChoice",choice:r})?(new QG.Notice(`Could not clear user script secrets. The ${Sm(r.type)} was not deleted.`),!1):!0:!1}async function rY(r,e,t){if(r.type==="Multi")try{return await new Lk(e,r).waitForClose}catch{return}let n=Pue(r,e,t);if(!n)throw new Error("Invalid choice type");return await n.waitForClose}function nY(r){return{...r,command:!r.command}}var Uk=class{constructor(e){this.plugin=e}enableCommand(e){this.plugin.addCommandForChoice(e)}disableCommand(e,t){t?this.plugin.removeCommandForChoice(e,t):this.plugin.removeCommandForChoice(e)}updateCommand(e,t){this.plugin.removeCommandForChoice(e),this.plugin.addCommandForChoice(t)}};function iY(r,e,t){if(!e||!t)return r;let n=gx(r,e),i=gx(r,t);if(!n||!i||i.type!=="Multi"||n.type==="Multi"&&(n.id===i.id||Fue(n).has(i.id)))return r;let{updated:o,removed:s}=vx(r,e);return s?V$(o,t,s)??r:r}function oY(r,e){if(!e||r.some(i=>Ye(i)&&i.id===e))return r;let{updated:t,removed:n}=vx(r,e);return n?[...t,n]:r}function gx(r,e){for(let t of r){if(!Ye(t))continue;if(t.id===e)return t;let n=gx(st(t),e);if(n)return n}}function Fue(r){let e=new Set,t=n=>{Ye(n)&&(e.add(n.id),st(n).forEach(t))};return st(r).forEach(t),e}function vx(r,e){let t;return{updated:r.map(i=>{if(!Ye(i))return i;if(i.id===e){t=i;return}if(!xc(i))return i;let o=vx(st(i),e);return o.removed&&(t=o.removed),o.removed?{...i,choices:o.updated}:i}).filter(Boolean),removed:t}}function V$(r,e,t){let n=!1,i=r.map(o=>{if(!Ye(o))return o;if(o.id===e&&o.type==="Multi"){if(Ws(o))return o;n=!0;let a=o;return{...a,choices:[...st(a),t]}}if(!xc(o))return o;let s=V$(st(o),e,t);return s?(n=!0,{...o,choices:s}):o});return n?i:void 0}function q$(r,e,t){let n=r.findIndex(s=>Ye(s)&&s.id===e);if(n!==-1){let s=[...r];return s.splice(n+1,0,t),s}let i=!1,o=r.map(s=>{if(!Ye(s)||!xc(s))return s;let a=q$(st(s),e,t);return a?(i=!0,{...s,choices:a}):s});return i?o:void 0}function sY(r,e,t){if(!t)return[...r,e];let n=V$(r,t,e)??[...r,e];return Mue(n,t)}function W$(r,e,t){return r.map(n=>{if(!Ye(n)||n.type!=="Multi")return n;let i=n;return i.id===e?t(i):xc(i)?{...i,choices:W$(st(i),e,t)}:n})}function z$(r,e,t){return W$(r,e,n=>({...n,collapsed:t}))}function Mue(r,e){return z$(r,e,!1)}function aY(r,e,t){return W$(r,e,n=>({...n,choices:t}))}var lY=require("obsidian");Wt();var H$="quickadd:move-to-root";function Rue(r,e){let t=hn(e);if(t.some(i=>Ye(i)&&i.id===r.id))return!1;let n=i=>{for(let o of i){if(!Ye(o))continue;let s=st(o);if(s.some(a=>a?.id===r.id)||n(s))return!0}return!1};return n(t)}function $ue(r,e){let t=[],n=Array.isArray(e)?e:[],i=(o,s=[])=>{for(let a of o){if(!Ye(a))continue;let l=a.name??"";if(a.type==="Multi"){let c=[...s,l];Oue(r,a)||t.push({id:a.id,path:c.join(" / ")}),i(st(a),[...s,l])}}};return i(n,[]),t}function Oue(r,e){if(e.type!=="Multi"||r.id===e.id||Ws(e))return!0;if(r.type==="Multi"){let t=new Set,n=i=>{Ye(i)&&(t.add(i.id),st(i).forEach(n))};if(st(r).forEach(n),t.has(e.id))return!0}return!1}function cY(r,e,t,n){let i=new lY.Menu;i.addItem(s=>s.setTitle(e.command?"Disable in command palette":"Enable in command palette").setIcon("zap").onClick(n.onToggle)).addItem(s=>s.setTitle("Rename").setIcon("pencil").onClick(n.onRename)).addItem(s=>s.setTitle("Configure").setIcon("settings").onClick(n.onConfigure)).addItem(s=>s.setTitle("Duplicate").setIcon("copy").onClick(n.onDuplicate)).addItem(s=>s.setTitle("Delete").setIcon("trash-2").onClick(n.onDelete)).addSeparator(),Rue(e,t)&&i.addItem(s=>s.setTitle("Move to: (root)").setIcon("folder-up").onClick(()=>n.onMove(H$)));let o=$ue(e,t);return o.length===0?i.addItem(s=>s.setTitle("Move to: (no folders)").setDisabled(!0).setIcon("folder")):o.forEach(s=>i.addItem(a=>a.setTitle(`Move to: ${s.path}`).setIcon("folder-open").onClick(()=>n.onMove(s.id)))),i}function Vk(r,e,t,n,i){e.preventDefault(),cY(r,t,n,i).showAtMouseEvent(e)}function qk(r,e,t,n,i){let o=e.getBoundingClientRect();cY(r,t,n,i).showAtPosition({x:o.left,y:o.bottom})}var Va=require("obsidian");var Ir=require("obsidian");es();var uY=require("obsidian");It();var Wk=null,Nue=1440*60*1e3;async function j$(){if(Wk&&Date.now()-Wk.fetchedAt<Nue)return Wk.data;if(ce.getState().disableOnlineFeatures)throw new Error("Fetching models directory is disabled: Online features are turned off.");let e=await(await(0,uY.requestUrl)({url:"https://models.dev/api.json",method:"GET"})).json;return Wk={data:e,fetchedAt:Date.now()},e}function Lue(r){for(let e of[r,`https://${r}`])try{let t=new URL(e).hostname.toLowerCase();if(t)return t}catch{}return""}function yx(r){let e=r.toLowerCase(),t=Lue(r),n=i=>t===i||t.endsWith(`.${i}`);return n("openai.com")?"openai":n("openrouter.ai")?"openrouter":n("generativelanguage.googleapis.com")?"google":e.includes("anthropic")?"anthropic":n("groq.com")?"groq":n("together.ai")||n("together.xyz")?"togetherai":e.includes("huggingface")?"huggingface":e.includes("github")&&e.includes("models")?"github-models":e.includes("bedrock")||e.includes("aws")?"amazon-bedrock":e.includes("modelscope")?"modelscope":e.includes("dashscope")?"alibaba":n("fireworks.ai")?"fireworks-ai":e.includes("vercel")?"vercel":n("inference.net")?"inference":n("z.ai")||e.includes("zhipu")?"zhipuai":n("deepseek.com")?"deepseek":n("mistral.ai")?"mistral":e.includes("cerebras")?"cerebras":n("venice.ai")?"venice":n("upstage.ai")?"upstage":n("llama.com")?"llama":e.includes("morphllm")?"morph":n("inceptionlabs.ai")?"inception":e.includes("deepinfra")?"deepinfra":n("opencode.ai")?"opencode":n("inference.wandb.ai")?"wandb":n("githubcopilot.com")?"github-copilot":null}function Bue(r){let e=r.modalities?.output;if(Array.isArray(e)&&!e.includes("text"))return!1;let t=r.limit??{};if(typeof t.context=="number"&&t.context<=0||typeof t.output=="number"&&t.output<=1)return!1;let n=(r.family??"").toLowerCase(),i=r.id.toLowerCase();return!(n.includes("embedding")||i.includes("embedding"))}function dY(r){return r.filter(Bue).map(e=>{let t={name:e.id,maxTokens:Math.max(1,Math.floor(e.limit?.context??128e3))};return typeof e.limit?.output=="number"&&e.limit.output>0&&(t.maxOutputTokens=Math.floor(e.limit.output)),typeof e.temperature=="boolean"&&(t.supportsTemperature=e.temperature),t})}async function pY(r,e){let t=yx(r);if(!t)return e;let n;try{n=await j$()}catch{return e}let i=n[t]?.models;return i?e.map(o=>{let s=i[o.name];if(!s)return o;let a={...o};return typeof s.limit?.context=="number"&&s.limit.context>0&&(a.maxTokens=Math.floor(s.limit.context)),a.maxOutputTokens===void 0&&typeof s.limit?.output=="number"&&s.limit.output>0&&(a.maxOutputTokens=Math.floor(s.limit.output)),a.supportsTemperature===void 0&&typeof s.temperature=="boolean"&&(a.supportsTemperature=s.temperature),a}):e}function bx(r,e){let t=new Map(e.map(s=>[s.name,s])),n=r.map(s=>{let a=t.get(s.name);return a?{...s,maxTokens:a.maxTokens,maxOutputTokens:a.maxOutputTokens??s.maxOutputTokens,supportsTemperature:a.supportsTemperature??s.supportsTemperature}:s}),i=new Set(r.map(s=>s.name)),o=e.filter(s=>!i.has(s.name));return n.concat(o)}Me();It();var vY=require("obsidian");es();Cx();It();var jk=128e3;async function Gk(r,e){let t=r.modelSource??"providerApi";if(t==="modelsDev")return hY(r);if(t==="providerApi")return gY(r,e);try{return await gY(r,e)}catch(n){if(!yx(r.endpoint))throw n;return hY(r,n)}}async function hY(r,e){try{let t=await j$(),n=yx(r.endpoint);if(!n||!(n in t))throw new Error(`models.dev does not list a provider that matches ${r.endpoint}.`);let i=Object.values(t[n].models);return dY(i)}catch(t){throw e?new Error(`Provider API failed (${e.message}). Fallback to models.dev also failed: ${t.message}`):t}}async function gY(r,e){let{disableOnlineFeatures:t}=ce.getState();if(t)throw new Error("Online features are disabled \u2014 enable them to browse provider models.");if(!r.endpoint)throw new Error("Provider is missing an endpoint URL.");let n=e??r.apiKey??"",i=Rv(r),o=i==="anthropic"?await Yue(r,n):i==="gemini"?await Kue(r,n):await Gue(r,n);if(!o.length)throw new Error("The provider's models endpoint did not include any usable models.");let s=await pY(r.endpoint,o);return Hue(r.endpoint,s)}function Hue(r,e){let t=yx(r);if(t!=="openai"&&t!=="google"&&t!=="anthropic")return e;let n=new Map($v[t].map(i=>[i.name,i]));return e.map(i=>{let o=n.get(i.name);return o?{...i,maxTokens:i.maxTokens===jk?o.maxTokens:i.maxTokens,maxOutputTokens:i.maxOutputTokens??o.maxOutputTokens,supportsTemperature:i.supportsTemperature??o.supportsTemperature}:i})}async function G$(r,e,t){try{let n=await(0,vY.requestUrl)({url:e,headers:t,throw:!1});if(n.status>=400)throw Hk(r.name,n);return await n.json}catch(n){throw new Error(`Provider rejected the models request: ${n.message}`)}}var jue=/(whisper|-tts|tts-|embed|dall-e|image|moderation|transcribe|realtime|rerank)/i;async function Gue(r,e){let t=r.endpoint.replace(/\/+$/,""),n=t.endsWith("/v1")?`${t}/models`:`${t}/v1/models`,i={};e&&(i.Authorization=`Bearer ${e}`);let o=await G$(r,n,i),s=Xue(o),a=[];for(let l of s){let c=Que(l);c&&!jue.test(c.name)&&a.push(c)}return a}async function Yue(r,e){let t=r.endpoint.replace(/\/+$/,""),n={"anthropic-version":"2023-06-01"};e&&(n["x-api-key"]=e);let i=[],o=null;for(let s=0;s<10;s++){let a=`${t}/v1/models?limit=1000`+(o?`&after_id=${encodeURIComponent(o)}`:""),l=await G$(r,a,n);for(let c of l.data??[])c.id&&i.push({name:c.id,maxTokens:jk});if(!l.has_more||!l.last_id)break;o=l.last_id}return i}async function Kue(r,e){let t=r.endpoint.replace(/\/+$/,""),n={};e&&(n["x-goog-api-key"]=e);let i=[],o=null;for(let s=0;s<10;s++){let a=`${t}/v1beta/models?pageSize=1000`+(o?`&pageToken=${encodeURIComponent(o)}`:""),l=await G$(r,a,n);for(let c of l.models??[]){if(!c.name)continue;let u=c.supportedGenerationMethods;if(Array.isArray(u)&&!u.includes("generateContent"))continue;let d={name:c.name.replace(/^models\//,""),maxTokens:typeof c.inputTokenLimit=="number"&&c.inputTokenLimit>0?c.inputTokenLimit:jk};typeof c.outputTokenLimit=="number"&&c.outputTokenLimit>0&&(d.maxOutputTokens=c.outputTokenLimit),i.push(d)}if(!l.nextPageToken)break;o=l.nextPageToken}return i}function Xue(r){if(Array.isArray(r))return r;if(r&&typeof r=="object"&&Array.isArray(r.data))return r.data;throw new Error("The provider's models response was not a list.")}function Que(r){let e=r.id??r.name;return e?{name:e,maxTokens:Zue(r)}:null}function Zue(r){let e=[r.context_length,r.contextLength,r.context_tokens,r.max_context_tokens,r.max_context_length,r.max_input_tokens,r.max_tokens,r.limit?.context];for(let t of e){let n=Jue(t);if(n&&n>0)return Math.floor(n)}return jk}function Jue(r){if(typeof r=="number"&&Number.isFinite(r))return r;if(typeof r=="string"){let e=Number(r);if(Number.isFinite(e))return e}return null}Xp();var nde=1440*60*1e3;function ide(r,e){let t=new Map(r.map(i=>[i.name,JSON.stringify(i)])),n=0;for(let i of e){let o=t.get(i.name);o!==void 0&&o!==JSON.stringify(i)&&(n+=1)}return n}async function tg(r,e){let t=await Ua(r,e),n=await Gk(e,t),i=e.models;return e.models=bx(e.models,n),{added:e.models.length-i.length,updated:ide(i,e.models)}}function wY(r){return`${(r.name??"").trim().toLowerCase()}\0${(r.endpoint??"").trim().toLowerCase().replace(/\/+$/,"")}`}async function CY(r,e={}){let t=ce.getState();if(t.disableOnlineFeatures)return[];let n=t.ai.providers.filter(l=>l.autoSyncModels);if(n.length===0)return[];let i=t.ai.lastModelAutoSyncAt??0;if(!e.ignoreThrottle&&Date.now()-i<nde)return[];let o=[],s=new Map;for(let l of n){let c={...l,models:l.models.map(u=>({...u}))};try{let{added:u,updated:d}=await tg(r,c);o.push({provider:c.name,added:u,updated:d}),s.set(wY(c),c)}catch(u){o.push({provider:c.name,added:0,updated:0,error:u.message??String(u)})}}let a=o.some(l=>!l.error);ce.setState(l=>({...l,ai:{...l.ai,providers:l.ai.providers.map(c=>{let u=s.get(wY(c));return u?{...c,models:bx(c.models,u.models)}:c}),lastModelAutoSyncAt:a?Date.now():l.ai.lastModelAutoSyncAt}}));for(let l of o)l.error?F.logMessage(`[Model auto-sync] ${l.provider}: failed (${l.error})`):(l.added>0||l.updated>0)&&F.logMessage(`[Model auto-sync] ${l.provider}: ${l.added} new model(s), ${l.updated} updated.`);return o}It();var Ol=require("obsidian");Xp();var Yk=class extends Ol.Modal{constructor(t,n){super(t);this.allModels=[];this.filtered=[];this.selectedIds=new Set;this.mode="add";this.resolved=!1;this.loadError=null;this.provider=n,this.waitForClose=new Promise((i,o)=>{this.resolvePromise=i,this.rejectPromise=o}),this.open(),this.loadData().then(()=>this.display())}async loadData(){try{let t=await Ua(this.app,this.provider);this.allModels=await Gk(this.provider,t),this.filtered=this.allModels.slice(),this.loadError=null}catch(t){this.loadError=`${t.message??t}`,new Ol.Notice(`Failed to load model directory: ${this.loadError}`)}}display(){this.contentEl.empty(),this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.contentEl.createEl("h2",{text:`Browse models for ${this.provider.name}`,cls:"qa-modal-title"}),new Ol.Setting(this.contentEl).setName("Search").addText(t=>{t.setPlaceholder("Filter by name").onChange(n=>{let i=n.trim().toLowerCase();this.filtered=this.allModels.filter(o=>o.name.toLowerCase().includes(i)),this.renderList()})}).addExtraButton(t=>{t.setIcon("check"),t.setTooltip("Select all"),t.onClick(()=>{this.filtered.forEach(n=>this.selectedIds.add(n.name)),this.renderList()})}).addExtraButton(t=>{t.setIcon("x"),t.setTooltip("Clear selection"),t.onClick(()=>{this.selectedIds.clear(),this.renderList()})}),new Ol.Setting(this.contentEl).setName("Import mode").setDesc("Add will append new models. Replace will overwrite existing models with the selected list.").addDropdown(t=>{t.addOption("add","Add only"),t.addOption("replace","Replace existing"),t.setValue(this.mode),t.onChange(n=>this.mode=n)}).addButton(t=>{t.setButtonText("Import selected").setCta().onClick(()=>this.importSelected())}),this.contentEl.createDiv({cls:"qa-model-directory"}),this.renderList()}renderList(){let t=this.contentEl.querySelector(".qa-model-directory");if(t){if(t.empty(),this.filtered.length===0){let n=this.loadError?`Couldn't load models: ${this.loadError}. Check the API key and endpoint.`:this.allModels.length===0?"No models available for this provider.":"No models match your filter.";t.createDiv({text:n,cls:"qa-model-directory-empty"});return}for(let n of this.filtered){let i=t.createEl("label",{cls:"qa-model-row"}),o=this.contentEl.ownerDocument.createElement("input");o.type="checkbox",o.checked=this.selectedIds.has(n.name),o.onchange=()=>{o.checked?this.selectedIds.add(n.name):this.selectedIds.delete(n.name)},i.appendChild(o),i.createDiv({text:n.name,cls:"qa-model-row-title"}),i.createDiv({text:`${n.maxTokens.toLocaleString()} tokens max`,cls:"qa-model-row-meta"})}}}importSelected(){if(this.selectedIds.size===0){new Ol.Notice("Select at least one model.");return}try{let n=this.allModels.filter(i=>this.selectedIds.has(i.name)).map(i=>({...i}));if(!n.length){new Ol.Notice("No models selected to import.");return}this.resolved=!0,this.resolvePromise({imported:n,mode:this.mode}),this.close()}catch(t){new Ol.Notice(`Import failed: ${t.message??t}`)}}onClose(){this.resolved||this.resolvePromise(null),super.onClose()}};vi();zs();var Zi=require("obsidian");es();var xY=[{id:"openai",name:"OpenAI",endpoint:"https://api.openai.com/v1",doc:"https://platform.openai.com/docs/models",kind:"openai",modelSource:"modelsDev",seedKey:"openai"},{id:"gemini",name:"Gemini",endpoint:"https://generativelanguage.googleapis.com",doc:"https://ai.google.dev/gemini-api/docs",kind:"gemini",modelSource:"auto",seedKey:"google"},{id:"anthropic",name:"Anthropic",endpoint:"https://api.anthropic.com",doc:"https://docs.anthropic.com/",kind:"anthropic",modelSource:"auto",seedKey:"anthropic"},{id:"groq",name:"Groq",endpoint:"https://api.groq.com/openai/v1",doc:"https://console.groq.com/docs/models",kind:"openai",modelSource:"auto"},{id:"togetherai",name:"TogetherAI",endpoint:"https://api.together.xyz/v1",doc:"https://docs.together.ai/docs/serverless-models",kind:"openai",modelSource:"auto"},{id:"openrouter",name:"OpenRouter",endpoint:"https://openrouter.ai/api/v1",doc:"https://openrouter.ai/models",kind:"openai",modelSource:"auto"},{id:"hugging-face",name:"Hugging Face",endpoint:"https://router.huggingface.co/v1",doc:"https://huggingface.co/docs/inference-providers",kind:"openai",modelSource:"auto"},{id:"mistral",name:"Mistral",endpoint:"https://api.mistral.ai/v1",doc:"https://docs.mistral.ai/getting-started/models/",kind:"openai",modelSource:"auto"},{id:"deepseek",name:"DeepSeek",endpoint:"https://api.deepseek.com",doc:"https://platform.deepseek.com/api-docs/",kind:"openai",modelSource:"auto"}];var Kk=class extends Zi.Modal{constructor(e,t){super(e),this.providers=t,this.waitForClose=new Promise((n,i)=>{this.resolvePromise=n,this.rejectPromise=i}),this.open(),this.display()}addHeader(e){e.createEl("h2",{text:"Add a provider",cls:"qa-modal-title"})}display(){this.contentEl.empty(),this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.addHeader(this.contentEl);let e=this.contentEl.createDiv({cls:"qa-provider-grid"});for(let t of xY){let n=e.createDiv({cls:"qa-provider-card"});if(n.createEl("div",{text:t.name,cls:"qa-provider-card-title"}),n.createEl("div",{text:t.endpoint,cls:"qa-provider-card-endpoint"}),t.doc){let s=n.createEl("a",{text:"Docs",href:t.doc});s.target="_blank",s.rel="noopener noreferrer"}let i="",o=new Zi.Setting(n).setName("API key").setDesc("Select a secret from SecretStorage").addComponent(s=>new Zi.SecretComponent(this.app,s).setValue(i).onChange(a=>{i=a}));o.settingEl.addClass("qa-provider-api-setting"),o.addButton(s=>{s.setButtonText("Connect").setCta().onClick(async()=>{try{let a=i.trim();try{new URL(t.endpoint)}catch{new Zi.Notice(`Invalid endpoint URL for ${t.name}.`);return}let l=t.endpoint.toLowerCase();if(["openai.com","generativelanguage.googleapis.com","anthropic","api.groq.com","together.xyz","openrouter.ai","router.huggingface.co","api.mistral.ai","api.deepseek.com"].some(m=>l.includes(m))&&!a){new Zi.Notice(`${t.name} requires an API key.`);return}let u=m=>m.trim().toLowerCase(),d=m=>m.trim().toLowerCase().replace(/\/+$/,"");if(this.providers.some(m=>u(m.name)===u(t.name)&&d(m.endpoint)===d(t.endpoint))){new Zi.Notice(`${t.name} is already configured.`);return}let p={name:t.name,endpoint:t.endpoint,id:dT(t.id,this.providers),kind:t.kind,apiKey:"",apiKeyRef:a,models:[],modelSource:t.modelSource??"auto",autoSyncModels:!0};s.setButtonText("Connecting..."),s.setDisabled(!0),await this.importInitialModels(p,t),this.providers.push(p),this.close()}catch(a){s.setButtonText("Connect"),s.setDisabled(!1),new Zi.Notice(`Failed to add provider: ${a.message??a}`)}})})}new Zi.Setting(this.contentEl).setName("Custom provider").setDesc("Create any custom endpoint (OpenAI-compatible or otherwise)").addButton(t=>{t.setButtonText("Add custom...").onClick(()=>{let n={id:dT("custom",this.providers),name:"Custom",endpoint:"",apiKey:"",apiKeyRef:"",models:[],modelSource:"providerApi"};this.providers.push(n),new Zi.Notice("Custom provider added. Click Edit to configure."),this.close()})})}async importInitialModels(e,t){try{await tg(this.app,e),new Zi.Notice(`${t.name} connected with ${e.models.length} models.`)}catch(n){let i=n.message??String(n);t.seedKey?(e.models=fT(t.seedKey),new Zi.Notice(`${t.name} added with its built-in model list. Live model loading failed: ${i}`)):new Zi.Notice(`${t.name} added, but loading models failed: ${i} Use "Sync now" in the provider's settings to retry.`)}}onClose(){this.resolvePromise(this.providers??null),super.onClose()}};Wp();var Xk=class extends Ir.Modal{constructor(e,t){super(t),this.providers=e,pT(this.providers),this.waitForClose=new Promise((n,i)=>{this.rejectPromise=i,this.resolvePromise=n}),this.open(),this.display(),this.autoSyncOnOpen()}async autoSyncOnOpen(){if(ce.getState().disableOnlineFeatures)return;let e=!1;for(let t of this.providers)if(t.autoSyncModels)try{let{added:n}=await tg(this.app,t);e=e||n>0}catch{}e&&!this.selectedProvider&&this.reload()}display(){let e=this.selectedProvider?`${this.selectedProvider.name}`:"Providers";if(this.contentEl.createEl("h2",{text:e,cls:"qa-modal-title"}),this.selectedProvider){this.addProviderSetting(this.contentEl);return}this.addProvidersSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addProvidersSetting(e){new Ir.Setting(e).setName("Providers").setDesc("Providers for the AI Assistant").addButton(n=>{n.setButtonText("Add provider").onClick(async()=>{await new Kk(this.app,this.providers).waitForClose,this.reload()}),n.setCta()});let t=e.createDiv({cls:"providers-container qa-ai-list-container"});this.providers.forEach((n,i)=>{new Ir.Setting(t).setName(n.name).setDesc(n.endpoint).addButton(o=>{o.onClick(async()=>{await Xi.Prompt(this.app,`Are you sure you want to delete ${n.name}?`)&&(this.providers.splice(i,1),this.reload())}),o.setDestructive(),o.setIcon("trash")}).addButton(o=>{o.setButtonText("Edit").onClick(()=>{this.selectedProvider=n,this._selectedProviderClone=ht(n),this.reload()})})})}addProviderSetting(e){this.addNameSetting(e),this.addEndpointSetting(e),this.addApiKeySetting(e),this.addKindSetting(e),this.addModelSourceSetting(e),this.addProviderModelsSetting(e),this.addImportModelsFromDirectorySetting(e),this.addAutoSyncSetting(e),this.addProviderSettingButtonRow(this.contentEl)}addNameSetting(e){let t=this.selectedProvider.id;new Ir.Setting(e).setName("Name").setDesc(t?`The display name of the provider. Its stable ID is "${t}" \u2014 use that to qualify models in scripts, e.g. ai.prompt with "${t}/model-name".`:"The display name of the provider").addText(n=>{n.setValue(this.selectedProvider.name).onChange(i=>{this.selectedProvider.name=i})})}addEndpointSetting(e){new Ir.Setting(e).setName("Endpoint").setDesc("The endpoint for the AI Assistant").addText(t=>{t.setValue(this.selectedProvider.endpoint).onChange(n=>{this.selectedProvider.endpoint=n})})}addApiKeySetting(e){let n=!!this.selectedProvider?.apiKey&&!this.selectedProvider?.apiKeyRef?"Legacy API key detected. Select a SecretStorage entry to migrate.":"Select a secret from SecretStorage";new Ir.Setting(e).setName("API key").setDesc(n).addComponent(i=>new Ir.SecretComponent(this.app,i).setValue(this.selectedProvider?.apiKeyRef??"").onChange(o=>{this.selectedProvider&&(this.selectedProvider.apiKeyRef=o,this.selectedProvider.apiKey="")}))}addKindSetting(e){new Ir.Setting(e).setName("Provider type").setDesc("The request format this provider expects. Auto-detect recognizes the official Anthropic and Gemini endpoints and treats everything else as OpenAI-compatible; pick a type explicitly for a proxy or custom endpoint.").addDropdown(t=>{t.addOption("","Auto-detect"),t.addOption("openai","OpenAI-compatible"),t.addOption("anthropic","Anthropic"),t.addOption("gemini","Gemini"),t.setValue(this.selectedProvider?.kind??""),t.onChange(n=>{this.selectedProvider&&(this.selectedProvider.kind=n||void 0)})})}addModelSourceSetting(e){let t=this.selectedProvider;new Ir.Setting(e).setName("Model source").setDesc("Choose where QuickAdd looks when browsing or syncing models for this provider.").addDropdown(n=>{n.addOption("providerApi","Provider models endpoint (requires API key)"),n.addOption("modelsDev","models.dev directory"),n.addOption("auto","Automatic (try provider, fallback to models.dev)");let i=t?.modelSource??"providerApi";n.setValue(i),n.onChange(o=>{this.selectedProvider&&(this.selectedProvider.modelSource=o,this.reload())})})}addProviderModelsSetting(e){let t=e.createDiv({cls:"models-container qa-ai-list-container"});this.selectedProvider.models.forEach((n,i)=>{let o=[`Context: ${n.maxTokens.toLocaleString()} tokens`];n.maxOutputTokens&&o.push(`Output: ${n.maxOutputTokens.toLocaleString()} tokens`),n.supportsTemperature===!1&&o.push("Fixed sampling (no temperature)"),new Ir.Setting(t).setName(n.name).setDesc(o.join(" \xB7 ")).addButton(s=>{s.onClick(async()=>{await Xi.Prompt(this.app,`Are you sure you want to delete ${n.name}?`)&&(this.selectedProvider.models.splice(i,1),this.reload())}),s.setDestructive(),s.setIcon("trash")})}),new Ir.Setting(t).setName("Add model").addButton(n=>{n.setButtonText("Add model").onClick(async()=>{let i,o;try{i=await Sr.Prompt(this.app,"Model name"),o=await Sr.Prompt(this.app,"Max tokens")}catch{return}let s=i.trim();if(!s){new Ir.Notice("Model name cannot be empty.");return}let a=o.trim();if(!/^[1-9]\d*$/.test(a)){new Ir.Notice("Max tokens must be a positive number.");return}let l=Number(a);this.selectedProvider.models.push({name:s,maxTokens:l}),this.reload()}),n.setCta()})}addImportModelsFromDirectorySetting(e){let t=this.describeModelSource(this.selectedProvider);new Ir.Setting(e).setName("Import models").setDesc(`Browse and import models from ${t}.`).addButton(n=>{n.setButtonText("Browse models").onClick(async()=>{let i=await new Yk(this.app,this.selectedProvider).waitForClose;if(!i)return;let{imported:o,mode:s}=i;s==="replace"?this.selectedProvider.models=o:this.selectedProvider.models=bx(this.selectedProvider.models,o),new Ir.Notice(`Imported ${o.length} models${s==="replace"?" (replaced)":" (added)"}.`),this.reload()}),n.setCta()})}addAutoSyncSetting(e){let t=this.describeModelSource(this.selectedProvider);new Ir.Setting(e).setName("Auto-sync models").setDesc(`Keep this provider's models current automatically: QuickAdd imports new models and refreshed context limits from ${t} once a day and when these settings open.`).addToggle(n=>{let i=!!this.selectedProvider?.autoSyncModels;n.setValue(i).onChange(o=>{this.selectedProvider&&(this.selectedProvider.autoSyncModels=o)})}).addButton(n=>{n.setButtonText("Sync now").onClick(async()=>{try{let{added:i,updated:o}=await tg(this.app,this.selectedProvider);new Ir.Notice(i>0||o>0?`Synced from ${t}: ${i} new model(s), ${o} updated.`:`Synced from ${t}: already up to date.`),this.reload()}catch(i){new Ir.Notice(`Sync failed: ${i.message??i}`)}}),n.setCta()})}restoreSelectedProviderFromClone(){if(!this.selectedProvider||!this._selectedProviderClone)return;let e=this.providers.indexOf(this.selectedProvider);e!==-1&&(this.providers[e]=this._selectedProviderClone),this.selectedProvider=null,this._selectedProviderClone=null}addProviderSettingButtonRow(e){let t=e.createDiv({cls:"button-row qa-ai-provider-button-row"}),n=new Ir.ButtonComponent(t);n.setButtonText("Cancel"),n.setDestructive(),n.onClick(()=>{this.restoreSelectedProviderFromClone(),this.reload()});let i=new Ir.ButtonComponent(t);i.setButtonText("Save"),i.setCta(),i.onClick(()=>{this.selectedProvider=null,this.reload()})}describeModelSource(e){switch(e?.modelSource??"providerApi"){case"modelsDev":return"the models.dev directory";case"auto":return"the provider's models endpoint (falls back to models.dev)";default:return"the provider's models endpoint"}}onClose(){this.restoreSelectedProviderFromClone(),this.resolvePromise(this.providers),super.onClose()}};qt();var Qk=class extends Va.Modal{constructor(e,t){super(e),this.settings=t,this.waitForClose=new Promise((n,i)=>{this.rejectPromise=i,this.resolvePromise=n}),this.open(),this.display()}display(){this.modalEl.addClass("qa-ai-wide-modal"),this.contentEl.addClass("qa-ai-scroll-content"),this.contentEl.createEl("h2",{text:"AI Assistant settings",cls:"qa-modal-title"}),this.addProvidersSetting(this.contentEl),this.addDefaultModelSetting(this.contentEl),this.addPromptTemplateFolderPathSetting(this.contentEl),this.addShowAssistantSetting(this.contentEl),this.addConfirmToolCallsSetting(this.contentEl),this.addDefaultSystemPromptSetting(this.contentEl)}reload(){this.contentEl.empty(),this.display()}addProvidersSetting(e){new Va.Setting(e).setName("Providers").setDesc("The providers for the AI Assistant").addButton(t=>{t.setButtonText("Edit providers").onClick(()=>{new Xk(this.settings.providers,this.app).waitForClose.then(()=>{this.reload()})})})}addDefaultModelSetting(e){new Va.Setting(e).setName("Default model").setDesc("The default model for the AI Assistant").addDropdown(t=>{bk(t,{model:this.settings.defaultModel,modelRef:this.settings.defaultModelRef},n=>{this.settings.defaultModel=n.model,this.settings.defaultModelRef=n.modelRef})})}addPromptTemplateFolderPathSetting(e){new Va.Setting(e).setName("Prompt template folder path").setDesc("Path to your folder with prompt templates").addText(t=>{t.setValue(this.settings.promptTemplatesFolderPath).onChange(n=>{this.settings.promptTemplatesFolderPath=n}),new ni(this.app,t.inputEl,Ns(this.app))})}addShowAssistantSetting(e){new Va.Setting(e).setName("Show assistant").setDesc("Show status messages from the AI Assistant").addToggle(t=>{t.setValue(this.settings.showAssistant),t.onChange(n=>{this.settings.showAssistant=n})})}addConfirmToolCallsSetting(e){new Va.Setting(e).setName("Confirm AI tool calls").setDesc("When an AI agent runs script-defined or built-in tools, ask before executing. 'Destructive only' confirms tools not marked read-only; 'Always' confirms every tool; 'Never' defers to each tool's own setting. A tool that requires approval is always confirmed regardless.").addDropdown(t=>{t.addOption("destructive","Destructive tools only (recommended)"),t.addOption("always","Always confirm every tool"),t.addOption("never","Never (use each tool's own setting)"),t.setValue(this.settings.confirmToolCalls??"destructive"),t.onChange(n=>{this.settings.confirmToolCalls=n})})}addDefaultSystemPromptSetting(e){new Va.Setting(e).setName("Default system prompt").setDesc("The default system prompt for the AI Assistant");let t=new Va.TextAreaComponent(e);t.inputEl.addClass("qa-ai-prompt-textarea"),t.inputEl.setAttribute("aria-label","Default system prompt");let n=vk(e,t.inputEl,this.settings.defaultSystemPrompt??"");t.setValue(this.settings.defaultSystemPrompt).onChange(i=>{this.settings.defaultSystemPrompt=i,n(i)})}onClose(){this.resolvePromise(this.settings),super.onClose()}};var _Y=require("obsidian");Wt();var EY=[{type:"Template",label:"Template",description:"Create a note from a template file.",iconId:"file-text"},{type:"Capture",label:"Capture",description:"Add text to a note \u2014 append, prepend, or insert.",iconId:"pencil"},{type:"Macro",label:"Macro",description:"Run a sequence of commands and scripts.",iconId:"terminal"}];function Zk(r){switch(r){case"Template":return"New template";case"Capture":return"New capture";case"Macro":return"New macro";case"Multi":return"New folder"}}function TY(r,e){let t=Zk(r),n=new Set(Bn(e).map(o=>o.name));if(!n.has(t))return t;let i=2;for(;n.has(`${t} ${i}`);)i++;return`${t} ${i}`}var ode=z('<div><button type="button" class="qaNewFolderBtn svelte-a7rp4h"><!> <span> </span></button> <button type="button" aria-haspopup="menu"><!> <span> </span> <!></button></div>'),sde={hash:"svelte-a7rp4h",code:`.qaAddChoiceControls.svelte-a7rp4h {display:flex;flex-direction:row;align-items:center;gap:0.5rem;}.qaAddChoiceControls.svelte-a7rp4h button:where(.svelte-a7rp4h) {display:inline-flex;align-items:center;gap:0.35em;}
|
||
|
||
/* The chevron sits tighter to the label than the leading plus. */.qaNewChoiceBtn.svelte-a7rp4h svg:last-child {margin-left:-0.1em;opacity:0.85;}
|
||
|
||
/* Per-folder ("compact") controls render as quiet, clickable text links \u2014 not
|
||
filled buttons \u2014 so they read as "add inside this folder" affordances and
|
||
don't compete with the global primary CTA, especially when repeated across
|
||
nested folders. */.qaAddChoiceControls.compact.svelte-a7rp4h {gap:1rem;}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h) {font-size:var(--font-ui-smaller);padding:2px 0;gap:0.25em;background:transparent;border:none;box-shadow:none;color:var(--text-muted);}.qaAddChoiceControls.compact.svelte-a7rp4h button:where(.svelte-a7rp4h):hover {color:var(--text-accent);text-decoration:underline;}
|
||
|
||
/* Mobile/touch: stretch so the two buttons fill the bar width instead of
|
||
cramming to the right. Driven by \`fill\` (Platform.isMobile from the bottom
|
||
bar) because viewport media queries don't fire under desktop mobile-emulation. */.qaAddChoiceControls.fill.svelte-a7rp4h {flex:1;}.qaAddChoiceControls.fill.svelte-a7rp4h button:where(.svelte-a7rp4h) {flex:1;justify-content:center;}
|
||
|
||
/* Narrow desktop windows stack the non-compact controls. Filled controls (the
|
||
mobile bottom bar) are excluded so this can't override \`.fill\`'s side-by-side
|
||
50/50 layout on a phone-width viewport (Platform.isMobile + width <= 800px). */
|
||
@media (max-width: 800px) {.qaAddChoiceControls.svelte-a7rp4h:not(.compact):not(.fill) {flex-direction:column;align-items:stretch;}
|
||
}`};function rg(r,e){we(e,!0),ot(r,sde);let t=he(e,"targetFolderId",3,void 0),n=he(e,"targetFolderName",3,void 0),i=he(e,"compact",3,!1),o=he(e,"fill",3,!1),s=Ae(!1);function a(j){let oe=new _Y.Menu;for(let M of EY)oe.addItem(U=>U.setTitle(`${M.label} \u2014 ${M.description}`).setIcon(M.iconId).onClick(q=>{let B=q.altKey===!0;e.onAddChoice(Zk(M.type),M.type,t(),B)}));Z(s,!0),oe.onHide(()=>{Z(s,!1)});let se=j.target?.closest("button");if(se){let M=se.getBoundingClientRect();oe.showAtPosition({x:M.left,y:M.bottom+4})}else oe.showAtMouseEvent(j)}function l(){e.onAddChoice(Zk("Multi"),"Multi",t(),!0)}let c=O(()=>i()?"Add choice":"New choice"),u=O(()=>i()?"Add folder":"New folder"),d=O(()=>n()?`Add choice to ${n()}`:h(c)),f=O(()=>n()?`Add folder to ${n()}`:h(u));var p=ode();let m;var v=I(p),g=I(v);Rt(g,{iconId:"folder-plus",size:14});var y=A(g,2),w=I(y,!0);S(y),S(v);var x=A(v,2);let C;var _=I(x);Rt(_,{iconId:"plus",size:14});var E=A(_,2),D=I(E,!0);S(E);var P=A(E,2);{var V=j=>{Rt(j,{iconId:"chevron-down",size:12})};ne(P,j=>{i()||j(V)})}S(x),S(p),de(()=>{m=wt(p,1,"qaAddChoiceControls svelte-a7rp4h",null,m,{compact:i(),fill:o()&&!i()}),ke(v,"aria-label",h(f)),ke(v,"title",i()?h(f):void 0),me(w,h(u)),C=wt(x,1,"qaNewChoiceBtn svelte-a7rp4h",null,C,{"mod-cta":!i()}),ke(x,"aria-expanded",h(s)),ke(x,"aria-label",h(d)),ke(x,"title",i()?h(d):void 0),me(D,h(c))}),De("click",v,l),De("click",x,a),$(r,p),Ce()}Et(["click"]);var ade=z('<div class="rightButtonsContainer svelte-1es4f02"><!> <!> <!> <!> <!> <!></div>'),lde={hash:"svelte-1es4f02",code:`.rightButtonsContainer.svelte-1es4f02 {display:flex;align-items:center;
|
||
/* Icons carry their own 3px padding inside the choice rows (24px hit
|
||
boxes), so a tight gap keeps the cluster compact without touching. */gap:2px;flex:0 0 auto;}`};function xx(r,e){we(e,!0),ot(r,lde);let t=he(e,"showConfigureButton",3,!0),n=he(e,"showDuplicateButton",3,!0),i=he(e,"commandEnabled",3,!1),o=he(e,"choiceName",3,"");var s=ade(),a=I(s);{var l=g=>{{let y=O(()=>`Configure${o()?" "+o():""}`);er(g,{iconId:"settings",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onConfigureChoice}})}};ne(a,g=>{t()&&g(l)})}var c=A(a,2);{var u=g=>{{let y=O(()=>`Duplicate${o()?" "+o():""}`);er(g,{iconId:"copy",get label(){return h(y)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDuplicateChoice}})}};ne(c,g=>{n()&&g(u)})}var d=A(c,2);{let g=O(()=>`Delete${o()?" "+o():""}`);er(d,{iconId:"trash-2",get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onDeleteChoice}})}var f=A(d,2);{var p=g=>{{let y=O(()=>`More options${o()?" for "+o():""}`);er(g,{iconId:"more-vertical",ariaHasPopup:"menu",get label(){return h(y)},onclick:w=>e.onOpenMenu?.(w.currentTarget)})}};ne(f,g=>{e.onOpenMenu&&g(p)})}var m=A(f,2);{let g=O(()=>`Command palette${o()?": "+o():""}`);er(m,{iconId:"zap",get ariaPressed(){return i()},get label(){return h(g)},extraClass:"qa-row-secondary-action",get onclick(){return e.onToggleCommand}})}var v=A(m,2);{let g=O(()=>`Reorder${o()?" "+o():""}`);ki(v,{get label(){return h(g)},get dragDisabled(){return e.dragDisabled},get onDragStart(){return e.onDragHandleDown},get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown}})}S(s),$(r,s),Ce()}var eS=require("obsidian");var AY=require("obsidian");function Jk(r,e,t,n){e.replaceChildren(),AY.MarkdownRenderer.render(n,r,e,"/",t)}Wt();var cde=z('<div class="choiceListItem"><span class="qaChoiceRowIcon" aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></div>'),ude={hash:"svelte-1aljzaf",code:""};function Y$(r,e){we(e,!0),ot(r,ude);let t=!0,n=Ae(void 0),i=new eS.Component;hr(()=>{h(n)&&Jk(e.choice.name,h(n),i,e.app)}),hr(()=>()=>i.unload());let o=()=>({onRename:()=>e.actions.onRenameChoice(e.choice),onToggle:()=>e.actions.onToggleCommand(e.choice),onConfigure:()=>e.actions.onConfigureChoice(e.choice),onDuplicate:()=>e.actions.onDuplicateChoice(e.choice),onDelete:()=>e.actions.onDeleteChoice(e.choice),onMove:p=>e.actions.onMoveChoice(e.choice,p)});function s(p){Vk(e.app,p,e.choice,e.roots,o())}function a(p){qk(e.app,p,e.choice,e.roots,o())}var l=cde(),c=I(l),u=I(c);{let p=O(()=>wm(e.choice));Rt(u,{get iconId(){return h(p)},size:15})}S(c);var d=A(c,2);sc(d,p=>Z(n,p),()=>h(n));var f=A(d,2);xx(f,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(e.choice),onConfigureChoice:()=>e.actions.onConfigureChoice(e.choice),onToggleCommand:()=>e.actions.onToggleCommand(e.choice),onDuplicateChoice:()=>e.actions.onDuplicateChoice(e.choice),onOpenMenu:a,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},get choiceName(){return e.choice.name},get commandEnabled(){return e.choice.command},showConfigureButton:t,get dragDisabled(){return e.dragDisabled},showDuplicateButton:!0}),S(l),de(()=>ke(l,"data-choice-id",e.choice.id)),De("contextmenu",l,s),De("dblclick",l,p=>{eS.Platform.isMobile||p.target.closest("button, a")||e.actions.onConfigureChoice(e.choice)}),$(r,l),Ce()}Et(["contextmenu","dblclick"]);var tS=require("obsidian");Wt();var dde=z('<span class="qaFolderCount svelte-1jxjn06" aria-hidden="true"> </span>'),pde=z(`<p class="qaUnreadableFolder svelte-1jxjn06">QuickAdd couldn't read this folder's contents. They're still
|
||
in <code class="svelte-1jxjn06">data.json</code>.</p>`),fde=z('<div class="nestedAddRow svelte-1jxjn06"><!></div>'),mde=z("<!> <!>",1),hde=z('<div class="nestedChoiceList svelte-1jxjn06"><!></div>'),gde=z('<div><div class="multiChoiceListItem"><button type="button" class="multiChoiceListItemName svelte-1jxjn06"><span aria-hidden="true"><!></span> <span class="choiceListItemName"></span> <!></button> <!></div> <!></div>'),vde={hash:"svelte-1jxjn06",code:`
|
||
/* Row surface (min-height, padding, radius, hover, rhythm) is shared with
|
||
leaf rows and lives in styles.css \u2014 see "Choice list rows". Only the
|
||
folder-specific pieces stay here. */
|
||
|
||
/* Base icon = chevron-down (expanded); collapsed rotates to point RIGHT,
|
||
matching Obsidian's own collapse grammar (file explorer, outline). */.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:transform 150ms ease;}.multiChoiceCollapseIcon.is-collapsed.svelte-1jxjn06 {transform:rotate(-90deg);}
|
||
|
||
@media (prefers-reduced-motion: reduce) {.multiChoiceCollapseIcon.svelte-1jxjn06 {transition:none;}
|
||
}
|
||
|
||
/* Full-width collapse toggle: reset native <button> chrome while keeping
|
||
native keyboard activation + aria-expanded. It hosts the shared icon
|
||
column (the chevron), so the folder NAME lands on the exact leaf-name x
|
||
for free \u2014 same 8px column gap as the leaf rows. */.multiChoiceListItemName.svelte-1jxjn06 {flex:1 1 auto;min-width:0;align-self:stretch;display:flex;align-items:center;
|
||
/* Obsidian's base button centers flex content; the name must not rely
|
||
on a growing child to stay left (it stopped growing for the count). */justify-content:flex-start;gap:8px;background:transparent;border:none;box-shadow:none;padding:0;
|
||
/* Obsidian's base button rule sets height: var(--input-height) (30px),
|
||
which would make folder rows 4px taller than leaf rows \u2014 the exact
|
||
rhythm break this redesign removes. */height:auto;min-height:0;font:inherit;color:inherit;text-align:left;cursor:pointer;
|
||
/* Suppress double-tap-zoom + its click delay on touch \u2014 proper touch hygiene
|
||
for a tap target, and reduces the ghost-click the dedupe above also guards. */touch-action:manipulation;}
|
||
|
||
/* The count reads as part of the label ("Misc \xB7 12"), so the name must not
|
||
grow \u2014 it keeps its ellipsis via flex-shrink + the shared min-width: 0. */.multiChoiceListItemName.svelte-1jxjn06 .choiceListItemName {flex:0 1 auto;}
|
||
|
||
/* Same slot, weight and colour as the empty-folder hint in ChoiceList, so a
|
||
folder we cannot read reads as a variation of "empty" rather than an alarm. */.qaUnreadableFolder.svelte-1jxjn06 {margin:0;padding:6px 8px 8px;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.4;}.qaUnreadableFolder.svelte-1jxjn06 code:where(.svelte-1jxjn06) {font-size:inherit;}.qaFolderCount.svelte-1jxjn06 {flex:0 0 auto;color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);font-variant-numeric:tabular-nums;line-height:1;}.multiChoiceListItemName.svelte-1jxjn06:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;border-radius:var(--radius-s, 4px);}
|
||
|
||
/* Just the indent \u2014 the drop-into-folder ring is drawn on the ACTUAL dndzone
|
||
(.choiceList, in ChoiceList.svelte) so the highlighted area equals the
|
||
droppable area (WYSIWYG); it is NOT drawn on this wrapper, which extends past
|
||
the zone to the add-row/hint. The ::before is an indent GUIDE under the
|
||
parent's icon column (x = row padding 8px + half the 18px column, minus
|
||
half the line), clarifying what belongs to the open folder. */.nestedChoiceList.svelte-1jxjn06 {position:relative;padding-left:26px;}.nestedChoiceList.svelte-1jxjn06::before {content:"";position:absolute;left:16px;top:3px;bottom:3px;width:1px;background:var(--background-modifier-border);pointer-events:none;}
|
||
|
||
/* The per-folder add-row reads as a ghost row of the folder: aligned to the
|
||
child rows' padding, one tight step (4px) below the last child. */.nestedAddRow.svelte-1jxjn06 {margin:2px 0 4px 0;padding:0 8px;}`};function K$(r,e){we(e,!0),ot(r,vde);let t=he(e,"choice",7),n=he(e,"forceDragDisabled",3,!1),i=O(()=>st(t())),o=O(()=>Ws(t())),s=!0,a=Ae(void 0),l=new tS.Component;hr(()=>{h(a)&&Jk(t().name,h(a),l,e.app)}),hr(()=>()=>l.unload());let c=()=>({onRename:()=>e.actions.onRenameChoice(t()),onToggle:()=>e.actions.onToggleCommand(t()),onConfigure:()=>e.actions.onConfigureChoice(t()),onDuplicate:()=>e.actions.onDuplicateChoice(t()),onDelete:()=>e.actions.onDeleteChoice(t()),onMove:j=>e.actions.onMoveChoice(t(),j)});function u(j){Vk(e.app,j,t(),e.roots,c())}function d(j){qk(e.app,j,t(),e.roots,c())}let f={...Ot(()=>e.actions),onReorderChoices:j=>{t().choices=j,e.actions.onCommitFolder(t().id,j)}};function p(){n()||e.actions.onToggleCollapsed(t())}var m=gde(),v=I(m),g=I(v),y=I(g);let w;var x=I(y);Rt(x,{iconId:"chevron-down",size:16}),S(y);var C=A(y,2);sc(C,j=>Z(a,j),()=>h(a));var _=A(C,2);{var E=j=>{var oe=dde(),se=I(oe,!0);S(oe),de(()=>me(se,h(i).length)),$(j,oe)};ne(_,j=>{t().collapsed&&h(i).length>0&&j(E)})}S(g),Fr(g,j=>OA?.(j));var D=A(g,2);xx(D,{get onDragHandleDown(){return e.startDrag},onDeleteChoice:()=>e.actions.onDeleteChoice(t()),onConfigureChoice:()=>e.actions.onConfigureChoice(t()),onToggleCommand:()=>e.actions.onToggleCommand(t()),onDuplicateChoice:()=>e.actions.onDuplicateChoice(t()),onOpenMenu:d,get onMoveUp(){return e.onMoveUp},get onMoveDown(){return e.onMoveDown},showConfigureButton:s,get dragDisabled(){return e.dragDisabled},get choiceName(){return t().name},get commandEnabled(){return t().command},showDuplicateButton:!0}),S(v);var P=A(v,2);{var V=j=>{var oe=un(),se=Pe(oe);{var M=U=>{var q=hde(),B=I(q);{var ie=Y=>{var X=pde();$(Y,X)},W=Y=>{var X=mde(),ae=Pe(X);{let be=O(()=>h(i).length===0),xe=O(()=>e.rootReorder??e.actions.onReorderChoices);ng(ae,{get app(){return e.app},get roots(){return e.roots},get choices(){return h(i)},nested:!0,get isEmptyFolder(){return h(be)},get forceDragDisabled(){return n()},get rootReorder(){return h(xe)},get actions(){return f}})}var pe=A(ae,2);{var ge=be=>{var xe=fde(),Ue=I(xe);rg(Ue,{compact:!0,get targetFolderId(){return t().id},get targetFolderName(){return t().name},get onAddChoice(){return e.actions.onAddChoice}}),S(xe),$(be,xe)};ne(pe,be=>{n()||be(ge)})}$(Y,X)};ne(B,Y=>{h(o)?Y(ie):Y(W,-1)})}S(q),$(U,q)};ne(se,U=>{t().collapsed||U(M)})}$(j,oe)};ne(P,j=>{(!e.collapseId||e.collapseId&&t().id!==e.collapseId)&&j(V)})}S(m),de(()=>{ke(v,"data-choice-id",t().id),ke(g,"aria-expanded",!t().collapsed),ke(g,"aria-label",`Toggle ${t().name}`),w=wt(y,1,"qaChoiceRowIcon multiChoiceCollapseIcon svelte-1jxjn06",null,w,{"is-collapsed":t().collapsed})}),De("contextmenu",v,u),De("click",v,j=>{tS.Platform.isMobile||j.target.closest("button, a")||p()}),De("click",g,p),$(r,m),Ce()}Et(["contextmenu","click"]);function kY(r){let e=r-1;return e*e*e+1}function SY(r,{from:e,to:t},n={}){var{delay:i=0,duration:o=E=>Math.sqrt(E)*120,easing:s=kY}=n,a=getComputedStyle(r),l=a.transform==="none"?"":a.transform,[c,u]=a.transformOrigin.split(" ").map(parseFloat);c/=r.clientWidth,u/=r.clientHeight;var d=yde(r),f=r.clientWidth/t.width/d,p=r.clientHeight/t.height/d,m=e.left+e.width*c,v=e.top+e.height*u,g=t.left+t.width*c,y=t.top+t.height*u,w=(m-g)*f,x=(v-y)*p,C=e.width/t.width,_=e.height/t.height;return{delay:i,duration:typeof o=="function"?o(Math.sqrt(w*w+x*x)):o,easing:s,css:(E,D)=>{var P=D*w,V=D*x,j=E+D*C,oe=E+D*_;return`transform: ${l} translate(${P}px, ${V}px) scale(${j}, ${oe});`}}}function yde(r){if("currentCSSZoom"in r)return r.currentCSSZoom;for(var e=r,t=1;e!==null;)t*=+getComputedStyle(e).zoom,e=e.parentElement;return t}var DY=require("obsidian");Wt();var bde=z("<div><!></div>"),wde=z("<div></div>"),Cde={hash:"svelte-2ry05y",code:`.choiceList.svelte-2ry05y {width:auto;}
|
||
|
||
/* Root (non-nested) empty list keeps a little bottom breathing room. The only way to
|
||
render it empty is a zero-match filter \u2014 a truly empty tree shows the hero state. */.choiceList.qa-empty.svelte-2ry05y:not(.qa-nested) {padding-bottom:0.5rem;}.choiceList.qa-nested.svelte-2ry05y {
|
||
/* Own the 2px name->first-row gap so the empty drop band sits the same distance
|
||
below the folder name as a populated folder's first row (collapses with the
|
||
row's own margin-top, so populated folders look identical). */margin-top:2px;position:relative; /* anchor the ring (::before) */border-radius:var(--radius-m);transition:background-color 120ms ease;}
|
||
|
||
/* The drop ring is drawn a few px OUTSIDE the content as an absolutely-positioned
|
||
::before (adds no layout) \u2014 "synthetically" bigger than the rows so it doesn't
|
||
clamp straight against the choice names. The right edge stays at the content edge:
|
||
the settings pane is overflow-x:hidden, so extending the ring right would clip it. */.choiceList.qa-nested.svelte-2ry05y::before {content:"";position:absolute;inset:-4px 0 -4px -6px;border-radius:var(--radius-m);border:2px dashed transparent;pointer-events:none;transition:border-color 120ms ease;}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget {background-color:var(--background-modifier-hover);}.choiceList.qa-nested.svelte-2ry05y.qa-folder-droptarget::before {border-color:var(--interactive-accent);}
|
||
|
||
/* Empty folder: a GENEROUS, STABLE drop target. The band is sized by the folder's
|
||
PERSISTED emptiness (qa-folder-empty), NOT the live \`choices\` length \u2014 so when a
|
||
dragged item is previewed into the zone (filling \`choices\`, toggling qa-empty off)
|
||
the band keeps its height instead of collapsing/expanding under the cursor (the
|
||
"jumps all over the place"). Only persisted-empty folders get it, so populated
|
||
folders never heave at drag start. */.choiceList.qa-nested.qa-folder-empty.svelte-2ry05y {min-height:3rem;display:flex;align-items:center;}
|
||
|
||
/* Hint shows only when the folder is persisted-empty AND nothing is previewed in it
|
||
(qa-empty = live \`choices\` empty), so it cleanly swaps out for the previewed row
|
||
without changing the band's size. */.choiceList.qa-nested.qa-folder-empty.qa-empty.svelte-2ry05y::after {content:"Empty \u2014 add a choice or drag one here.";color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);line-height:1.3;padding-left:8px; /* align with the child rows' own left padding */pointer-events:none;user-select:none;}
|
||
|
||
@media (prefers-reduced-motion: reduce) {.choiceList.qa-nested.svelte-2ry05y,
|
||
.choiceList.qa-nested.svelte-2ry05y::before {transition:none;}
|
||
}`};function ng(r,e){we(e,!0),ot(r,Cde);let t=he(e,"choices",31,()=>bt([])),n=he(e,"forceDragDisabled",3,!1),i=he(e,"isEmptyFolder",3,!1),o=he(e,"nested",3,!1),s=O(()=>{let x=new Set;return hn(t()).filter(C=>{if(!Ye(C))return!1;let _=C.id;return typeof _!="string"||_===""||x.has(_)?!1:(x.add(_),!0)})}),a=O(()=>e.rootReorder??e.actions.onReorderChoices),l=0,c=DY.Platform.isMobile,u=Ae(""),d=ok(),f=O(()=>n()||!c&&!d.armed);function p(x){n()||(d.markStarted(),Z(u,x.detail.info.id,!0),t(Ml(x.detail.items)))}function m(x){if(n())return;Z(u,"");let C=Ml(x.detail.items);x.detail.info.trigger===Ai.DROPPED_INTO_ANOTHER&&(C=C.filter(_=>_.id!==x.detail.info.id)),t(C),d.reset(),e.actions.onReorderChoices(t())}let v=()=>{n()||d.startDrag()};function g(x,C){if(n())return;let _=Ml(h(s)),E=_.findIndex(j=>j.id===x.id);if(E===-1)return;let D=E+C;if(D<0||D>=_.length)return;let P=[..._],[V]=P.splice(E,1);P.splice(D,0,V),t(P),e.actions.onReorderChoices(t()),Fl(`Moved ${x.name} to position ${D+1} of ${_.length}`)}var y=wde();let w;ar(y,29,()=>Ml(h(s)),x=>x.id,(x,C)=>{var _=bde(),E=I(_);{var D=V=>{{let j=O(()=>e.roots??t()),oe=O(()=>n()?void 0:()=>g(h(C),-1)),se=O(()=>n()?void 0:()=>g(h(C),1));Y$(V,{get app(){return e.app},get roots(){return h(j)},get dragDisabled(){return h(f)},startDrag:v,get actions(){return e.actions},get choice(){return h(C)},get onMoveUp(){return h(oe)},get onMoveDown(){return h(se)}})}},P=V=>{{let j=O(()=>e.roots??t()),oe=O(()=>n()?void 0:()=>g(h(C),-1)),se=O(()=>n()?void 0:()=>g(h(C),1));K$(V,{get app(){return e.app},get roots(){return h(j)},get dragDisabled(){return h(f)},startDrag:v,get actions(){return e.actions},get collapseId(){return h(u)},get forceDragDisabled(){return n()},get rootReorder(){return h(a)},get choice(){return h(C)},get onMoveUp(){return h(oe)},get onMoveDown(){return h(se)}})}};ne(E,V=>{h(C).type!=="Multi"?V(D):V(P,-1)})}S(_),YI(_,()=>SY,()=>({duration:l})),$(x,_)}),S(y),Fr(y,(x,C)=>nk?.(x,C),()=>ik({items:h(s),dragDisabled:h(f),flipDurationMs:l,dropTargetClasses:o()?["qa-folder-droptarget"]:[]})),de(()=>w=wt(y,1,"choiceList svelte-2ry05y",null,w,{"qa-nested":o(),"qa-folder-empty":i(),"qa-empty":h(s).length===0})),oc("consider",y,p),oc("finalize",y,m),$(r,y),Ce()}var xde=z('<pre class="qaChoicesUnavailableDetail svelte-1fs8ikt"> </pre>'),Ede=z(`<div class="qaChoicesUnavailable svelte-1fs8ikt"><div class="qaChoicesUnavailableHead svelte-1fs8ikt"><!> <span class="qaChoicesUnavailableTitle svelte-1fs8ikt"> </span></div> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">Something in this vault's QuickAdd settings could not be read. Your choices
|
||
have not been changed or deleted, and QuickAdd will not overwrite them.</p> <p class="qaChoicesUnavailableBody svelte-1fs8ikt">They are stored in <code>.obsidian/plugins/quickadd/data.json</code> inside this vault. Make a
|
||
copy of that file before editing it.</p> <!></div>`),Tde={hash:"svelte-1fs8ikt",code:".qaChoicesUnavailable.svelte-1fs8ikt {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m);padding:12px 14px;margin:4px 0 8px;background:var(--background-secondary);}.qaChoicesUnavailableHead.svelte-1fs8ikt {display:flex;align-items:center;gap:8px;color:var(--text-warning, var(--text-normal));}.qaChoicesUnavailableTitle.svelte-1fs8ikt {font-weight:var(--font-semibold);color:var(--text-normal);}.qaChoicesUnavailableBody.svelte-1fs8ikt {margin:8px 0 0;color:var(--text-muted);font-size:var(--font-ui-small, 13px);max-width:68ch;}.qaChoicesUnavailableDetail.svelte-1fs8ikt {margin:10px 0 0;padding:8px 10px;border-radius:var(--radius-s);background:var(--background-primary);color:var(--text-faint);font-size:var(--font-ui-smaller, 12px);white-space:pre-wrap;word-break:break-word;user-select:text;}"};function ig(r,e){ot(r,Tde);let t=he(e,"what",3,"your choices"),n=he(e,"detail",3,"");var i=Ede(),o=I(i),s=I(o);Rt(s,{iconId:"alert-triangle",size:16});var a=A(s,2),l=I(a);S(a),S(o);var c=A(o,6);{var u=d=>{var f=xde(),p=I(f,!0);S(f),de(()=>me(p,n())),$(d,f)};ne(c,d=>{n()&&d(u)})}S(i),de(()=>me(l,`QuickAdd couldn't display ${t()??""}`)),$(r,i)}Wt();Wt();var X$=new WeakMap;function IY(r){let e=X$.get(r);if(e)return e;let t=HU(r);return X$.set(r,t),t}function PY(r){return X$.has(r)}Cr();var _de=z(`<div class="choiceEmptyState svelte-1r4uuo1"><!> <div class="choiceEmptyTitle svelte-1r4uuo1">No choices yet</div> <p class="choiceEmptyBody svelte-1r4uuo1">A choice is an action QuickAdd can run: create a note, capture
|
||
text, or run a macro. Group them with folders. <a class="quickadd-docs-link" target="_blank" rel="noopener noreferrer">Learn more</a></p> <div class="choiceEmptyActions svelte-1r4uuo1"><!></div></div>`),Ade=z('<button class="search-input-clear-button qaFilterClearButton svelte-1r4uuo1" aria-label="Clear filter"></button>'),kde=z('<div class="choiceFilterEmpty svelte-1r4uuo1">No choices match your filter.</div>'),Sde=z('<button type="button" class="qaAIAssistantBtn clickable-icon svelte-1r4uuo1" aria-label="Configure AI Assistant" title="Configure AI Assistant"><!></button>'),Dde=z('<div class="choiceFilterBar svelte-1r4uuo1"><div class="search-input-container choiceFilterInput svelte-1r4uuo1"><input type="search" placeholder="Filter choices..." autocapitalize="off" autocorrect="off" enterkeyhint="search"/> <!></div></div> <!> <div class="choiceViewBottomBar svelte-1r4uuo1"><!> <!></div>',1),Ide=z("<div><!></div>"),Pde={hash:"svelte-1r4uuo1",code:`.choiceViewBottomBar.svelte-1r4uuo1 {display:flex;flex-direction:row;align-items:center;justify-content:flex-end; /* pack right; "New choice" (primary) is the terminal action */flex-wrap:wrap;gap:0.5rem;margin-top:0.75rem;}
|
||
|
||
/* AI Assistant as a quiet icon button (matches the per-row action icons),
|
||
leading the right cluster so the bar's width barely changes when AI/online
|
||
features toggle. */.qaAIAssistantBtn.svelte-1r4uuo1 {flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;color:var(--text-muted);}.qaAIAssistantBtn.svelte-1r4uuo1:hover {color:var(--text-normal);}.choiceEmptyState.svelte-1r4uuo1 {display:flex;flex-direction:column;align-items:center;text-align:center;gap:0.5rem;padding:2.5rem 1rem;color:var(--text-muted);}.choiceEmptyTitle.svelte-1r4uuo1 {font-weight:var(--font-semibold);color:var(--text-normal);}.choiceEmptyBody.svelte-1r4uuo1 {margin:0;max-width:42ch;}.choiceEmptyActions.svelte-1r4uuo1 {margin-top:0.5rem;}.choiceFilterBar.svelte-1r4uuo1 {margin-bottom:8px;}
|
||
|
||
/* The native container is inline-block by default in some contexts; span
|
||
the full row so the filter aligns with the list edges. */.choiceFilterInput.svelte-1r4uuo1 {width:100%;}
|
||
|
||
/* Obsidian styles .search-input-clear-button (position, the \xD7 glyph, hover)
|
||
\u2014 we only reset the <button> chrome so that styling shows through. A real
|
||
<button> (Obsidian uses a div) keeps it keyboard-operable. */.qaFilterClearButton.svelte-1r4uuo1 {background:transparent;border:none;box-shadow:none;padding:0;margin:0;cursor:var(--cursor, pointer);}.choiceFilterEmpty.svelte-1r4uuo1 {color:var(--text-faint);font-size:var(--font-ui-small, 13px);padding:12px 8px 16px;}`};function Q$(r,e){we(e,!0),ot(r,Pde);let t=he(e,"choices",31,()=>bt([])),n=Ae(""),i=O(()=>!Array.isArray(t())),o=O(()=>`The "choices" value in data.json is ${t()===null?"null":`of type "${typeof t()}"`}, but QuickAdd expects a list.`),s=og.Platform.isMobile,a=Ae(bt(ce.getState().disableOnlineFeatures)),l=new Uk(Ot(()=>e.plugin));function c(W){if(!Array.isArray(W))return W;let Y=PY(W),{choices:X,repaired:ae}=IY(W);if(Y)return X;for(let{choice:pe}of ae)if(pe.command)try{l.enableCommand(pe)}catch(ge){F.logError(`Could not register a command for the repaired choice "${pe.name}": ${ge instanceof Error?ge.message:String(ge)}`)}return X}t(c(t())),hr(()=>{let W=ce.subscribe(Y=>{t(c(Y.choices)),Z(a,Y.disableOnlineFeatures,!0)});return()=>W()});function u(){e.saveChoices(yh(t()))}let d=W=>W.type==="Multi";function f(W,Y){let X=Y.trim();if(!X)return W;let ae=(0,og.prepareFuzzySearch)(X),pe=ge=>{if(!Ye(ge))return null;let be=!!ae(ge.name??"");if(!d(ge))return be?ge:null;let xe=st(ge).map(Ue=>pe(Ue)).filter(Boolean);return be||xe.length>0?{...ge,collapsed:!1,choices:xe}:null};return W.map(ge=>pe(ge)).filter(Boolean)}async function p(W,Y,X,ae=!1){let pe=TY(Y,t()),ge=B$(Y,pe);if(t(sY(t(),ge,X)),!X&&h(n).trim().length>0&&Z(n,""),Y==="Multi")u(),await C(ge),await m(ge.id);else if(ae)u(),await m(ge.id);else{u();try{await w(ge)}catch(be){F.logError(`Failed to configure the new choice: ${be instanceof Error?be.message:String(be)}`),u()}await m(ge.id)}}async function m(W){await jf();try{document.querySelector(`[data-choice-id="${W}"]`)?.scrollIntoView({block:"nearest"})}catch{}}function v(W){return gx(t(),W.id)??W}function g(W){return Ye(W)?W.command?!0:st(W).some(g):!1}async function y(W){let Y=v(W);await tY(Y,e.app)&&(t(vx(t(),W.id).updated),l.disableCommand(Y,{recursive:!0}),u())}async function w(W){let Y=v(W),X=await rY(Y,e.app,e.plugin);X&&(t(t().map(ae=>x(ae,X))),l.updateCommand(Y,X),u())}function x(W,Y){if(!Ye(W))return W;if(W.id===Y.id)return{...W,...Y};if(xc(W)){let X=st(W).map(pe=>x(pe,Y));return{...W,choices:X}}return W}async function C(W){if(!W)return;let Y=await g_(e.app,W.name,W.type);if(!Y)return;let X=v(W),ae={...X,name:Y};t(t().map(pe=>x(pe,ae))),l.updateCommand(X,ae),u()}function _(W){let Y=nY(v(W));t(t().map(X=>x(X,Y))),Y.command?l.enableCommand(Y):l.disableCommand(Y),u()}async function E(W){let Y=await JG(v(W),e.app);t(q$(t(),W.id,Y)??[...t(),Y]),g(Y)&&l.enableCommand(Y),u(),new og.Notice(`Duplicated "${W.name}".`),await m(Y.id)}function D(W,Y){t(Y===H$?oY(t(),W.id):iY(t(),W.id,Y)),u()}function P(W){t(W),u()}function V(W,Y){t(aY(t(),W,Y)),u()}function j(W){t(z$(t(),W.id,!W.collapsed)),u()}function oe(W,Y){return(X,...ae)=>{let pe=Sm(X?.type),ge=X?.name?`the ${pe} \u201C${X.name}\u201D`:`that ${pe}`;em(`Couldn't ${W} ${ge}`,Y)(X,...ae)}}let se={onDeleteChoice:oe("delete",y),onConfigureChoice:oe("open the settings for",w),onToggleCommand:oe("update the command palette entry for",_),onDuplicateChoice:oe("duplicate",E),onRenameChoice:oe("rename",C),onMoveChoice:oe("move",D),onToggleCollapsed:oe("open or close",j),onReorderChoices:em("Couldn't save the new order",P),onCommitFolder:em("Couldn't save that folder's contents",V),onAddChoice:(W,Y,X,ae)=>em(`Couldn't add that ${Sm(Y)}`,p)(W,Y,X,ae)},M=em("Couldn't open the AI assistant settings",async()=>{let W=await new Qk(e.app,ce.getState().ai).waitForClose;W&&ce.setState(Y=>({...Y,ai:W}))});var U=Ide(),q=I(U);{var B=W=>{ig(W,{get detail(){return h(o)}})},ie=W=>{var Y=un(),X=Pe(Y);hv(X,{onerror:pe=>F.logError(`QuickAdd could not render the choice list: ${pe instanceof Error?pe.message:String(pe)}`),failed:(pe,ge=Vt)=>{{let be=O(()=>ge()instanceof Error?ge().message:String(ge()));ig(pe,{get detail(){return h(be)}})}}},pe=>{var ge=un(),be=Pe(ge);{var xe=Ne=>{var Ke=_de(),Qe=I(Ke);Rt(Qe,{iconId:"folder-plus",size:28});var ye=A(Qe,4),We=A(I(ye));S(ye);var mt=A(ye,2),He=I(mt);rg(He,{get onAddChoice(){return se.onAddChoice}}),S(mt),S(Ke),de(()=>ke(We,"href",Al.gettingStarted)),$(Ne,Ke)},Ue=O(()=>t().length===0&&h(n).trim().length===0),$t=Ne=>{var Ke=Dde(),Qe=Pe(Ke),ye=I(Qe),We=I(ye);gr(We),ke(We,"spellcheck",!1);var mt=A(We,2);{var He=dt=>{var Ft=Ade();De("click",Ft,()=>Z(n,"")),$(dt,Ft)};ne(mt,dt=>{h(n)&&dt(He)})}S(ye),S(Qe);var _e=A(Qe,2);{var Be=dt=>{ng(dt,{get app(){return e.app},get roots(){return t()},get actions(){return se},get choices(){return t()},set choices(Ft){t(Ft)}})},ut=O(()=>h(n).trim().length===0),or=dt=>{let Ft=O(()=>f(t(),h(n)));var Hn=un(),xo=Pe(Hn);{var xs=re=>{var Ie=kde();$(re,Ie)},jn=re=>{ng(re,{get app(){return e.app},get roots(){return t()},get choices(){return h(Ft)},forceDragDisabled:!0,get actions(){return se}})};ne(xo,re=>{h(Ft).length===0?re(xs):re(jn,-1)})}$(dt,Hn)};ne(_e,dt=>{h(ut)?dt(Be):dt(or,-1)})}var yr=A(_e,2),Pt=I(yr);{var Ar=dt=>{var Ft=Sde(),Hn=I(Ft);Rt(Hn,{iconId:"sparkles",size:16}),S(Ft),De("click",Ft,M),$(dt,Ft)};ne(Pt,dt=>{h(a)||dt(Ar)})}var ur=A(Pt,2);rg(ur,{get onAddChoice(){return se.onAddChoice},get fill(){return s}}),S(yr),De("keydown",We,dt=>{dt.key==="Escape"&&h(n)&&(Z(n,""),dt.stopPropagation())}),co(We,()=>h(n),dt=>Z(n,dt)),$(Ne,Ke)};ne(be,Ne=>{h(Ue)?Ne(xe):Ne($t,-1)})}$(pe,ge)}),$(W,Y)};ne(q,W=>{h(i)?W(B):W(ie,-1)})}S(U),$(r,U),Ce()}Et(["keydown","click"]);It();var Fde=z('<div class="qa-gv__empty svelte-hx6w4t">No global variables yet.</div>'),Mde=z('<div class="qa-gv__row qa-gv__row--head svelte-hx6w4t"><div class="qa-gv__cell qa-gv__name">Name</div> <div class="qa-gv__cell qa-gv__value">Value</div> <div class="qa-gv__cell qa-gv__ops svelte-hx6w4t">Actions</div></div>'),Rde=z('<div class="qa-gv__row svelte-hx6w4t"><div class="qa-gv__cell qa-gv__name svelte-hx6w4t"><input type="text" placeholder="Name" class="svelte-hx6w4t"/></div> <div class="qa-gv__cell qa-gv__value svelte-hx6w4t"><textarea rows="2" placeholder="Snippet value (supports QuickAdd tokens)" class="svelte-hx6w4t"></textarea></div> <div class="qa-gv__cell qa-gv__ops svelte-hx6w4t"><button class="qa-gv__btn danger svelte-hx6w4t" title="Delete">Delete</button></div></div>'),$de=z('<div class="qa-gv svelte-hx6w4t"><div class="qa-gv__desc svelte-hx6w4t">Define reusable snippets referenced as <code>{{GLOBAL_VAR:<name>}}</code>. Snippets support other QuickAdd tokens and expand before VALUE/VDATE/etc.</div> <div class="qa-gv__table svelte-hx6w4t"><!> <!></div> <div class="qa-gv__actions svelte-hx6w4t"><button class="mod-cta">Add variable</button></div></div>'),Ode={hash:"svelte-hx6w4t",code:`.qa-gv.svelte-hx6w4t {display:flex;flex-direction:column;gap:8px;}
|
||
/* Keeps "Add variable" right-aligned now that it is the row's only child. */.qa-gv__actions.svelte-hx6w4t {display:flex;justify-content:flex-end;}.qa-gv__desc.svelte-hx6w4t {color:var(--text-muted);font-size:12px;}
|
||
/* Mirrors .qa-template-folder-empty, the sibling list's empty state. */.qa-gv__empty.svelte-hx6w4t {color:var(--text-muted);font-size:var(--font-ui-smaller);padding:6px 0;}.qa-gv__table.svelte-hx6w4t {display:grid;gap:8px;}.qa-gv__row.svelte-hx6w4t {display:grid;grid-template-columns:180px 1fr 140px;gap:8px;align-items:start;}.qa-gv__row--head.svelte-hx6w4t {font-weight:600;color:var(--text-muted);}.qa-gv__cell.svelte-hx6w4t input[type="text"]:where(.svelte-hx6w4t) {width:100%;}.qa-gv__cell.svelte-hx6w4t textarea:where(.svelte-hx6w4t) {width:100%;resize:vertical;}.qa-gv__ops.svelte-hx6w4t {display:flex;gap:6px;align-items:center;}.qa-gv__btn.svelte-hx6w4t {padding:4px 8px;}.qa-gv__btn.danger.svelte-hx6w4t {color:var(--text-error);}
|
||
@media (max-width: 900px) {.qa-gv__row.svelte-hx6w4t {grid-template-columns:1fr;}.qa-gv__row--head.svelte-hx6w4t {display:none;}
|
||
}`};function Z$(r,e){we(e,!0),ot(r,Ode);let t=Ae(bt([]));function n(C,_){if(!_.has(C))return C;let E=1;for(;_.has(`${C}${E}`);)E++;return`${C}${E}`}function i(){let _=ce.getState().globalVariables||{};Z(t,Object.keys(_).map(E=>({name:E,value:_[E]??""})),!0)}let o=!1;function s(){let C=h(t).map(P=>P.name.trim()),_=C.some(P=>!P),E=new Set(C).size!==C.length;if(_||E)return;let D={};for(let P of h(t))D[P.name.trim()]=P.value??"";o=!0;try{ce.setState({globalVariables:D})}finally{o=!1}}function a(){let C=new Set(h(t).map(E=>E.name)),_=n("NewVar",C);Z(t,[...h(t),{name:_,value:""}],!0),s()}function l(C){Z(t,h(t).filter((_,E)=>E!==C),!0),s()}function c(C){return new Hi(e.app,C,e.plugin),{destroy(){}}}let u;function d(C){u!==void 0&&window.clearTimeout(u),u=window.setTimeout(()=>{s()},200)}hr(()=>{let C=ce.subscribe(()=>{o||i()});return i(),()=>{u!==void 0&&window.clearTimeout(u),C()}});var f=$de(),p=A(I(f),2),m=I(p);{var v=C=>{var _=Fde();$(C,_)},g=C=>{var _=Mde();$(C,_)};ne(m,C=>{h(t).length===0?C(v):C(g,-1)})}var y=A(m,2);ar(y,17,()=>h(t),Fv,(C,_,E)=>{var D=Rde(),P=I(D),V=I(P);gr(V),Fr(V,U=>c?.(U)),cn(()=>co(V,()=>h(_).name,U=>h(_).name=U)),S(P);var j=A(P,2),oe=I(j);Ad(oe),Fr(oe,U=>c?.(U)),cn(()=>co(oe,()=>h(_).value,U=>h(_).value=U)),S(j);var se=A(j,2),M=I(se);S(se),S(D),De("input",V,()=>{d(h(_))}),De("input",oe,()=>d(h(_))),De("click",M,()=>l(h(t).indexOf(h(_)))),$(C,D)}),S(p);var w=A(p,2),x=I(w);S(w),S(f),De("click",x,a),$(r,f),Ce()}Et(["input","click"]);It();qt();var jY=require("obsidian");var qa=require("obsidian");Wt();Ii();Yr();var Nde=new Set;function eO(r){return r.type==="Multi"}function tO(r){return r.type==="Macro"}function Lde(r){return r.type==="Template"}function Bde(r){return r.type==="Capture"}function rS(r,e,t){return r?e.has(r.id)?t.has(r.id):!0:!1}function FY(r,e,t,n){switch(r.type){case"Choice":{let i=r;if(!t.has(i.choiceId))return!0;let o=e.get(i.choiceId);return o&&rS(o.choice,e,t)&&n(o.choice),!0}case"NestedChoice":{let i=r;return i.choice&&rS(i.choice,e,t)&&n(i.choice),!0}default:return!1}}function Ude(r){let e=new Map,t=(n,i,o)=>{for(let s of n){if(!Ye(s))continue;let a=[...o,s.name];e.set(s.id,{choice:s,parentId:i,path:a}),eO(s)&&Array.isArray(s.choices)&&t(s.choices,s.id,a)}};return t(hn(r),null,[]),e}function MY(r){let e=new Set;for(let t of st(r))Ye(t)&&e.add(t.id);return tO(r)&&J$(r.macro?.commands,e),e}function J$(r,e){for(let t of Dr(r))if(Si(t))switch(t.type){case"Choice":{let n=t;n.choiceId&&e.add(n.choiceId);break}case"Conditional":{let n=t;J$(n.thenCommands,e),J$(n.elseCommands,e);break}case"NestedChoice":{let i=t.choice;if(!i)break;let o=MY(i);for(let s of o)e.add(s);break}default:break}}function nS(r,e,t){let n=Ude(r),i=new Set,o=new Set,s=t?.excludedChoiceIds??Nde,a=e.filter(c=>!s.has(c)),l=[];for(;a.length>0;){let c=a.shift();if(i.has(c))continue;if(s.has(c)){i.add(c);continue}let u=n.get(c);if(!u){o.add(c);continue}i.add(c),l.push(c);let d=MY(u.choice);for(let f of d){if(!n.has(f)){o.add(f);continue}s.has(f)||a.push(f)}}return{catalog:n,choiceIds:l,missingChoiceIds:Array.from(o)}}function iS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&rS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),eO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);tO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l))if(Si(c)&&!FY(c,r,t,s))switch(c.type){case"UserScript":{let u=c;u.path&&i.add(u.path);break}case"Conditional":{let u=c,d=u.condition;d.mode==="script"&&d.scriptPath&&o.add(d.scriptPath),a(u.thenCommands),a(u.elseCommands);break}default:break}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{userScriptPaths:i,conditionalScriptPaths:o}}function oS(r,e){let t=new Set(e),n=new Set,i=new Set,o=new Set,s=l=>{if(l&&rS(l,r,t)&&!n.has(l.id)){if(n.add(l.id),Lde(l)&&l.templatePath&&i.add(l.templatePath),Bde(l)&&l.createFileIfItDoesntExist?.enabled&&l.createFileIfItDoesntExist.createWithTemplate&&l.createFileIfItDoesntExist.template&&o.add(l.createFileIfItDoesntExist.template),eO(l)&&Array.isArray(l.choices))for(let c of l.choices)s(c);tO(l)&&a(l.macro?.commands)}},a=l=>{for(let c of Dr(l))if(Si(c)&&!FY(c,r,t,s)&&c.type==="Conditional"){let u=c;a(u.thenCommands),a(u.elseCommands)}};for(let l of e){let c=r.get(l);c&&s(c.choice)}return{templatePaths:i,captureTemplatePaths:o}}Wt();var VY=require("obsidian");function sS(r){return!!r&&typeof r=="object"}function RY(r){return Array.isArray(r)&&r.every(e=>typeof e=="string")}function Vde(r){return sS(r)?typeof r.id=="string"&&typeof r.name=="string"&&typeof r.type=="string":!1}function qde(r){return sS(r)?Vde(r.choice)&&RY(r.pathHint)&&(r.parentChoiceId===null||typeof r.parentChoiceId=="string"):!1}function Wde(r){if(!sS(r))return!1;let{kind:e,originalPath:t,contentEncoding:n,content:i}=r;return(e==="user-script"||e==="conditional-script"||e==="template"||e==="capture-template")&&typeof t=="string"&&n==="base64"&&typeof i=="string"}function $Y(r){if(!sS(r))return!1;let{schemaVersion:e,quickAddVersion:t,createdAt:n,rootChoiceIds:i,choices:o,assets:s}=r;return typeof e=="number"&&Number.isInteger(e)&&e>=1&&typeof t=="string"&&typeof n=="string"&&RY(i)&&Array.isArray(o)&&o.every(qde)&&Array.isArray(s)&&s.every(Wde)}Me();Wp();var OY=typeof TextEncoder<"u"?new TextEncoder:void 0,NY=typeof TextDecoder<"u"?new TextDecoder:void 0;function LY(r){return typeof window>"u"?!1:typeof window[r]=="function"}function BY(){if(!(typeof Buffer>"u"))return Buffer}function UY(r){if(OY&&LY("btoa")){let t=OY.encode(r),n="";for(let i=0;i<t.length;i++)n+=String.fromCharCode(t[i]);return window.btoa(n)}let e=BY();if(e)return e.from(r,"utf8").toString("base64");throw new Error("Base64 encoding is not supported in this environment.")}function qc(r){if(NY&&LY("atob")){let t=window.atob(r),n=Uint8Array.from(t,i=>i.charCodeAt(0));return NY.decode(n)}let e=BY();if(e)return e.from(r,"base64").toString("utf8");throw new Error("Base64 decoding is not supported in this environment.")}vi();Wt();async function aS(r,e){let t=e.lastIndexOf("/");if(t<0)return;let n=e.slice(0,t);if(!n)return;let i=n.split("/").filter(Boolean),o="";for(let s of i)o=o?`${o}/${s}`:s,await r.vault.adapter.exists(o)||await r.vault.createFolder(o)}Uc();function qY(){return`QuickAdd Packages/quickadd-package-${new Date().toISOString().replace(/[:.]/g,"-")}.quickadd.json`}async function WY(r,e){let{choices:t,rootChoiceIds:n,quickAddVersion:i}=e,o=new Set(e.excludedChoiceIds??[]),s=e.createdAt??new Date().toISOString(),a=nS(t,n,{excludedChoiceIds:o}),l=new Set(a.choiceIds),c=iS(a.catalog,a.choiceIds),u=oS(a.catalog,a.choiceIds),d=zde(c,u),f=await Hde(r,d),p=jde(f.encodedAssets),m=a.choiceIds.map(y=>{let w=a.catalog.get(y);if(!w)throw new Error(`Choice '${y}' missing from catalog.`);let x=ht(w.choice);return zY(x,l),Rh(x,{secretOptionNamesByPath:p,stripUnknownStringSettings:!0}),{choice:x,pathHint:[...w.path],parentChoiceId:w.parentId}}),v=n.filter(y=>l.has(y));return{pkg:{schemaVersion:1,quickAddVersion:i,createdAt:s,rootChoiceIds:[...v],choices:m,assets:f.encodedAssets},missingChoiceIds:a.missingChoiceIds,missingAssets:f.missingAssets}}function zde(r,e){let t=new Map;for(let n of r.userScriptPaths)n&&t.set(n,"user-script");for(let n of r.conditionalScriptPaths)n&&t.set(n,"conditional-script");for(let n of e.templatePaths)n&&(t.has(n)||t.set(n,"template"));for(let n of e.captureTemplatePaths)n&&(t.has(n)||t.set(n,"capture-template"));return Array.from(t.entries()).map(([n,i])=>({path:n,kind:i}))}async function Hde(r,e){let t=[],n=[];for(let{path:i,kind:o}of e)try{if(!await r.vault.adapter.exists(i)){n.push({path:i,kind:o}),F.logWarning(`QuickAdd export skipped missing ${o}: ${i}`);continue}let a=await r.vault.adapter.read(i);t.push({kind:o,originalPath:i,contentEncoding:"base64",content:UY(a)})}catch(s){n.push({path:i,kind:o}),F.logWarning(`QuickAdd export failed to read ${o} '${i}': ${s?.message??s}`)}return{encodedAssets:t,missingAssets:n}}function jde(r){let e=new Map;for(let t of r)if(t.kind==="user-script")try{let n=Ph(qc(t.content),t.originalPath);e.set(t.originalPath,n.foundSecretOptions&&n.names.size===0?null:n.names)}catch(n){F.logWarning(`QuickAdd export could not inspect user-script settings '${t.originalPath}': ${n?.message??n}`)}return e}function zY(r,e){if(r.type!=="Multi")return;let t=r;if(!Array.isArray(t.choices)||t.choices.length===0){t.choices=[];return}t.choices=t.choices.filter(n=>Ye(n)&&e.has(n.id)).map(n=>(zY(n,e),n))}async function Gde(r,e){return Xi.Prompt(r,"Overwrite existing file?",`A file already exists at '${e}'. Saving the package will overwrite it. Continue?`)}async function HY(r,e,t,n={}){let i=(0,VY.normalizePath)(t.trim());if(!i)throw new Error("Output path cannot be empty.");let o=await r.vault.adapter.exists(i);if(o&&!await(n.confirmOverwrite??(c=>Gde(r,c)))(i))throw new Error(`Save cancelled: '${i}' already exists.`);await aS(r,i);let s=JSON.stringify(e,null,2);return await r.vault.adapter.write(i,s),{overwritten:o}}var Yde=z('<p class="emptyState svelte-llmxn2">No choices match the current filter.</p>'),Kde=z('<span class="choicePath svelte-llmxn2"> </span>'),Xde=z('<li><label class="svelte-llmxn2"><input type="checkbox"/> <span class="choiceName svelte-llmxn2"> </span> <!> <span class="choiceType svelte-llmxn2"> </span></label></li>'),Qde=z('<ul class="svelte-llmxn2"></ul>'),Zde=z('<div class="warning svelte-llmxn2"><strong>Missing dependencies detected</strong> <p> </p></div>'),Jde=z("<p> </p>"),epe=z('<li> <span class="assetKind svelte-llmxn2"> </span></li>'),tpe=z('<div><p>Missing assets:</p> <ul class="svelte-llmxn2"></ul></div>'),rpe=z('<section class="warning svelte-llmxn2"><h4>Warnings</h4> <!> <!></section>'),npe=z('<div class="exportPackageModal svelte-llmxn2"><header class="svelte-llmxn2"><h2>Export QuickAdd package</h2> <p class="svelte-llmxn2">Select choices to bundle. Dependencies are added automatically.</p></header> <section class="controls svelte-llmxn2"><input type="text" placeholder="Filter choices" autocapitalize="off" autocorrect="off" class="svelte-llmxn2"/> <div class="controlButtons svelte-llmxn2"><button type="button" class="svelte-llmxn2">Select visible</button> <button type="button" class="svelte-llmxn2">Clear selection</button></div></section> <section class="choiceList svelte-llmxn2"><!></section> <section class="summary svelte-llmxn2"><h3 class="svelte-llmxn2">Package summary</h3> <div class="summaryGrid svelte-llmxn2"><div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Selected choices</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Total packaged</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Auto-included</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Scripts embedded</span></div> <div class="svelte-llmxn2"><strong class="svelte-llmxn2"> </strong> <span>Templates embedded</span></div></div> <!></section> <!> <section class="actions svelte-llmxn2"><div class="actionGroup svelte-llmxn2"><button type="button" class="secondary svelte-llmxn2"><!></button></div> <div class="actionGroup svelte-llmxn2"><label><span>Save to file</span> <div class="saveRow svelte-llmxn2"><input type="text" placeholder="QuickAdd Packages/quickadd-package-YYYY-MM-DD.quickadd.json" class="svelte-llmxn2"/> <button type="button" class="svelte-llmxn2"><!></button></div></label></div></section> <section class="footer svelte-llmxn2"><button type="button" class="secondary svelte-llmxn2">Cancel</button></section></div>'),ipe={hash:"svelte-llmxn2",code:`.exportPackageModal.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;width:min(640px, 100%);min-width:0;max-height:75vh;}header.svelte-llmxn2 p:where(.svelte-llmxn2) {margin:0;color:var(--text-muted);}.controls.svelte-llmxn2 {display:flex;gap:0.75rem;align-items:center;flex-wrap:wrap;}.controls.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.controlButtons.svelte-llmxn2 {display:flex;gap:0.5rem;flex-wrap:wrap;justify-content:flex-end;}.choiceList.svelte-llmxn2 {flex:1;min-height:180px;max-height:260px;overflow:auto;border:1px solid var(--background-modifier-border);border-radius:6px;padding:0.5rem;}.choiceList.svelte-llmxn2 ul:where(.svelte-llmxn2) {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.choiceList.svelte-llmxn2 label:where(.svelte-llmxn2) {display:flex;align-items:center;gap:0.5rem;padding:0.25rem 0.5rem;border-radius:4px;}.choiceList.svelte-llmxn2 label:where(.svelte-llmxn2):hover {background:var(--background-modifier-hover);}.choiceName.svelte-llmxn2 {font-weight:600;}.choicePath.svelte-llmxn2 {color:var(--text-muted);font-size:0.8rem;}.choiceType.svelte-llmxn2 {margin-left:auto;font-size:0.75rem;text-transform:uppercase;color:var(--text-faint);}.emptyState.svelte-llmxn2 {margin:0;color:var(--text-muted);text-align:center;}.summary.svelte-llmxn2 {border:1px solid var(--background-modifier-border);border-radius:6px;padding:0.75rem;display:flex;flex-direction:column;gap:0.5rem;}.summary.svelte-llmxn2 h3:where(.svelte-llmxn2) {margin:0 0 0.5rem 0;font-size:1rem;}.summaryGrid.svelte-llmxn2 {display:grid;grid-template-columns:repeat(auto-fit, minmax(140px, 1fr));gap:0.75rem;}.summaryGrid.svelte-llmxn2 div:where(.svelte-llmxn2) {display:flex;flex-direction:column;}.summaryGrid.svelte-llmxn2 strong:where(.svelte-llmxn2) {font-size:1.1rem;}
|
||
|
||
/* Neutral surface with an amber-tinted border (these are warnings, not
|
||
critical danger): ranked, not a blanket-red fill \u2014 matches the import
|
||
modal's CapabilityBanner treatment. */.warning.svelte-llmxn2 {border:1px solid var(--qa-sev-warning-border);background:var(--background-secondary);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;color:var(--text-normal);}.warning.svelte-llmxn2 ul:where(.svelte-llmxn2) {margin:0.25rem 0 0 1rem;padding:0;}.assetKind.svelte-llmxn2 {color:var(--text-muted);}.actions.svelte-llmxn2 {display:flex;flex-direction:column;gap:1rem;}.actionGroup.svelte-llmxn2 {display:flex;flex-direction:column;gap:0.5rem;}.saveRow.svelte-llmxn2 {display:flex;gap:0.5rem;}.saveRow.svelte-llmxn2 input:where(.svelte-llmxn2) {flex:1;}.footer.svelte-llmxn2 {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-llmxn2 button.secondary:where(.svelte-llmxn2) {background:transparent;}
|
||
|
||
@media (max-width: 600px) {.exportPackageModal.svelte-llmxn2 {max-height:90vh;padding-bottom:0.5rem;}.controls.svelte-llmxn2 {flex-direction:column;align-items:stretch;gap:0.5rem;}.controlButtons.svelte-llmxn2 {width:100%;flex-direction:column;gap:0.5rem;align-items:stretch;}.controlButtons.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.choiceList.svelte-llmxn2 {min-height:160px;max-height:40vh;}.summaryGrid.svelte-llmxn2 {grid-template-columns:1fr;}.actions.svelte-llmxn2 {gap:0.75rem;}.actionGroup.svelte-llmxn2 {align-items:stretch;}.actionGroup.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.saveRow.svelte-llmxn2 {flex-direction:column;}.saveRow.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}.footer.svelte-llmxn2 {flex-direction:column-reverse;align-items:stretch;}.footer.svelte-llmxn2 button:where(.svelte-llmxn2) {width:100%;}
|
||
}`};function rO(r,e){we(e,!0),ot(r,ipe);let t={"user-script":"User script","conditional-script":"Conditional script",template:"Template file","capture-template":"Capture template"},n=Ae(""),i=Ae(bt(new Set)),o=Ae(bt(new Set)),s=Ae(bt(qY())),a=Ae(null),l=Ae(null),c=O(()=>ly(e.allChoices)),u=O(()=>v(h(c),h(n))),d=O(()=>_(h(c),h(i))),f=O(()=>E(e.allChoices,h(d),h(o))),p=O(()=>new Map(h(c).map(k=>[k.id,k.path.join(" / ")])));function m(k){return k.type==="Multi"}function v(k,N){let K=N.trim().toLowerCase();return K?k.filter(J=>`${J.path.join(" ")} ${J.choice.type}`.toLowerCase().includes(K)):k}function g(k){let N=[];for(let K of st(k))Ye(K)&&N.push(K.id,...g(K));return N}function y(k,N){let K=[k.id,...g(k)];if(N){let J=new Set(h(i));for(let ue of K)J.add(ue);if(Z(i,J,!0),h(o).size>0){let ue=new Set(h(o));for(let ve of K)ue.delete(ve);Z(o,ue,!0)}}else{let J=new Set(h(i));for(let ve of K)J.delete(ve);Z(i,J,!0);let ue=new Set(h(o));for(let ve of K)ue.add(ve);Z(o,ue,!0)}}function w(k){let N=h(c).find(J=>J.id===k);if(!N)return;let K=h(i).has(k);y(N.choice,!K),Z(a,null)}function x(){for(let k of h(u))y(k.choice,!0);Z(a,null)}function C(){Z(i,new Set,!0),Z(o,new Set,!0),Z(a,null)}function _(k,N){let K=[];for(let J of k)N.has(J.id)&&(!J.parentId||!N.has(J.parentId))&&K.push(J.id);return K}function E(k,N,K){if(N.length===0)return{rootCount:0,totalChoices:0,dependencyCount:0,missingChoiceIds:[],userScripts:0,conditionalScripts:0,templateFiles:0,captureTemplates:0};let J=nS(k,N,{excludedChoiceIds:K}),ue=iS(J.catalog,J.choiceIds),ve=oS(J.catalog,J.choiceIds);return{rootCount:N.length,totalChoices:J.choiceIds.length,dependencyCount:Math.max(J.choiceIds.length-N.length,0),missingChoiceIds:J.missingChoiceIds,userScripts:ue.userScriptPaths.size,conditionalScripts:ue.conditionalScriptPaths.size,templateFiles:ve.templatePaths.size,captureTemplates:ve.captureTemplatePaths.size}}function D(k){let{missingChoiceIds:N,missingAssets:K}=k;return N.length===0&&K.length===0?null:{missingChoices:N,missingAssets:K}}async function P(){if(h(d).length===0)return new qa.Notice("Select at least one choice to export."),null;try{let k=await WY(e.app,{choices:e.allChoices,rootChoiceIds:h(d),excludedChoiceIds:Array.from(h(o)),quickAddVersion:e.plugin.manifest.version});return Z(a,D(k),!0),k}catch(k){return console.error(k),Z(a,null),new qa.Notice(`Export failed: ${k?.message??String(k)}`),null}}async function V(){if(!h(l)){Z(l,"copy");try{let k=await P();if(!k)return;let N=JSON.stringify(k.pkg,null,2);await oe(N),new qa.Notice(`Copied package (${k.pkg.choices.length} choice${k.pkg.choices.length===1?"":"s"}) to clipboard.`),h(a)?new qa.Notice("Package copied with warnings. Review details below."):e.close()}catch(k){console.error(k),new qa.Notice(`Copy failed: ${k?.message??String(k)}`)}finally{Z(l,null)}}}async function j(){if(h(l))return;let k=h(s).trim();if(!k){new qa.Notice("Enter a file path before saving.");return}Z(l,"save");try{let N=await P();if(!N)return;let{overwritten:K}=await HY(e.app,N.pkg,k),J=N.pkg.choices.length,ue=`${J} choice${J===1?"":"s"}`;new qa.Notice(K?`Overwrote package (${ue}) at '${k}'.`:`Saved package (${ue}) to '${k}'.`),h(a)?new qa.Notice("Package saved with warnings. Review details below."):e.close()}catch(N){let K=N?.message??String(N);if(K.startsWith("Save cancelled:")){new qa.Notice("Save cancelled.");return}console.error(N),new qa.Notice(`Save failed: ${K}`)}finally{Z(l,null)}}async function oe(k){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(k);return}let N=document.createElement("textarea");N.value=k,N.setAttribute("readonly","true"),N.style.position="fixed",N.style.opacity="0",document.body.appendChild(N),N.focus(),N.select();let K=document.execCommand("copy");if(document.body.removeChild(N),!K)throw new Error("Clipboard copy is not supported in this environment.")}var se=npe(),M=A(I(se),2),U=I(M);gr(U),ke(U,"spellcheck",!1);var q=A(U,2),B=I(q),ie=A(B,2);S(q),S(M);var W=A(M,2),Y=I(W);{var X=k=>{var N=Yde();$(k,N)},ae=k=>{var N=Qde();ar(N,21,()=>h(u),K=>K.id,(K,J)=>{var ue=Xde(),ve=I(ue),Ve=I(ve);gr(Ve);var vt=A(Ve,2),Pr=I(vt,!0);S(vt);var jt=A(vt,2);{var $i=kr=>{var Gn=Kde(),kt=I(Gn,!0);S(Gn),de(Eo=>me(kt,Eo),[()=>h(J).path.slice(0,-1).join(" \u203A ")]),$(kr,Gn)};ne(jt,kr=>{h(J).path.length>1&&kr($i)})}var yt=A(jt,2),pr=I(yt,!0);S(yt),S(ve),S(ue),de((kr,Gn)=>{Yf(ue,`padding-left: ${h(J).depth*16}px`),qd(Ve,kr),me(Pr,Gn),me(pr,h(J).choice.type)},[()=>h(i).has(h(J).id),()=>h(J).path.at(-1)]),De("change",Ve,()=>w(h(J).id)),$(K,ue)}),S(N),$(k,N)};ne(Y,k=>{h(u).length===0?k(X):k(ae,-1)})}S(W);var pe=A(W,2),ge=A(I(pe),2),be=I(ge),xe=I(be),Ue=I(xe,!0);S(xe),In(2),S(be);var $t=A(be,2),Ne=I($t),Ke=I(Ne,!0);S(Ne),In(2),S($t);var Qe=A($t,2),ye=I(Qe),We=I(ye,!0);S(ye),In(2),S(Qe);var mt=A(Qe,2),He=I(mt),_e=I(He,!0);S(He),In(2),S(mt);var Be=A(mt,2),ut=I(Be),or=I(ut,!0);S(ut),In(2),S(Be),S(ge);var yr=A(ge,2);{var Pt=k=>{var N=Zde(),K=A(I(N),2),J=I(K);S(K),S(N),de(ue=>me(J,`The following choice IDs were referenced but not found:
|
||
${ue??""}`),[()=>h(f).missingChoiceIds.join(", ")]),$(k,N)};ne(yr,k=>{h(f).missingChoiceIds.length>0&&k(Pt)})}S(pe);var Ar=A(pe,2);{var ur=k=>{var N=rpe(),K=A(I(N),2);{var J=Ve=>{var vt=Jde(),Pr=I(vt);S(vt),de(jt=>me(Pr,`Missing choices:
|
||
${jt??""}`),[()=>h(a).missingChoices.map(jt=>h(p).get(jt)??jt).join(", ")]),$(Ve,vt)};ne(K,Ve=>{h(a).missingChoices.length>0&&Ve(J)})}var ue=A(K,2);{var ve=Ve=>{var vt=tpe(),Pr=A(I(vt),2);ar(Pr,21,()=>h(a).missingAssets,jt=>jt.path,(jt,$i)=>{var yt=epe(),pr=I(yt),kr=A(pr),Gn=I(kr);S(kr),S(yt),de(()=>{me(pr,`${h($i).path??""} `),me(Gn,`(${t[h($i).kind]??""})`)}),$(jt,yt)}),S(Pr),S(vt),$(Ve,vt)};ne(ue,Ve=>{h(a).missingAssets.length>0&&Ve(ve)})}S(N),$(k,N)};ne(Ar,k=>{h(a)&&k(ur)})}var dt=A(Ar,2),Ft=I(dt),Hn=I(Ft),xo=I(Hn);{var xs=k=>{var N=cl("Copying\u2026");$(k,N)},jn=k=>{var N=cl("Copy JSON");$(k,N)};ne(xo,k=>{h(l)==="copy"?k(xs):k(jn,-1)})}S(Hn),S(Ft);var re=A(Ft,2),Ie=I(re),dr=A(I(Ie),2),br=I(dr);gr(br);var Tn=A(br,2),Ho=I(Tn);{var Ka=k=>{var N=cl("Saving\u2026");$(k,N)},Xa=k=>{var N=cl("Save to file");$(k,N)};ne(Ho,k=>{h(l)==="save"?k(Ka):k(Xa,-1)})}S(Tn),S(dr),S(Ie),S(re),S(dt);var Jc=A(dt,2),T=I(Jc);S(Jc),S(se),de(()=>{me(Ue,h(f).rootCount),me(Ke,h(f).totalChoices),me(We,h(f).dependencyCount),me(_e,h(f).userScripts+h(f).conditionalScripts),me(or,h(f).templateFiles+h(f).captureTemplates),Hn.disabled=h(l)!==null,Tn.disabled=h(l)!==null,T.disabled=h(l)!==null}),co(U,()=>h(n),k=>Z(n,k)),De("click",B,x),De("click",ie,C),De("click",Hn,V),co(br,()=>h(s),k=>Z(s,k)),De("click",Tn,j),De("click",T,function(...k){e.close?.apply(this,k)}),$(r,se),Ce()}Et(["click","change"]);var cS=class extends jY.Modal{constructor(t,n,i){super(t);this.plugin=n;this.choices=i;this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageExportModal"),this.handle=qi(this.contentEl,rO,{app:this.app,plugin:this.plugin,allChoices:this.choices,close:()=>this.close()},{what:"the package exporter"})}onClose(){this.handle?.destroy(),this.handle=null}};var x4=require("obsidian");var Ax=require("obsidian");It();qt();var gS=require("obsidian");ml();Wt();Ii();Yr();Yr();Yr();Wt();Ii();function ope(r){return r.type==="Multi"}function spe(r){return r.type==="Macro"}function nO(r,e,t){if(!(!r||typeof r!="object")){if(Array.isArray(r)){e.onUnreadable?.();return}if(!t.has(r)){if(t.add(r),e.onChoice?.(r),ope(r))if(Array.isArray(r.choices))for(let n of r.choices)nO(n,e,t);else t_(r.choices)&&e.onUnreadable?.();spe(r)&&uS(Wn(r.macro),e,t)}}}function uS(r,e,t){if(!Array.isArray(r)){Di(r)&&e.onUnreadable?.();return}for(let n of r){if(!n||typeof n!="object")continue;if(Array.isArray(n)){e.onUnreadable?.();continue}e.onCommand?.(n);let i=n;(n.type==="Conditional"||Array.isArray(i.thenCommands)||Array.isArray(i.elseCommands))&&(uS(i.thenCommands,e,t),uS(i.elseCommands,e,t));let s=n,a=n.type==="NestedChoice"||s.choice&&typeof s.choice=="object"?s.choice:void 0;a&&nO(a,e,t)}}function iO(r,e){let t=new Set;if(Array.isArray(r.choices))for(let i of r.choices)nO(i,e,t);else e.onUnreadable?.();let n=r.macros;if(Array.isArray(n))for(let i of n)uS(Wn(i),e,t);else Di(n)&&e.onUnreadable?.()}function sg(r){let e=!1;return iO(r,{onUnreadable:()=>{e=!0}}),e}function ag(r,e){iO(r.settings,{onChoice:e})}function dS(r,e){iO(r,{onCommand:e})}function ape(r){return r.type==="AIAssistant"}function pS(r,e,t){let n=0;return dS({choices:r},i=>{if(!ape(i)||i.modelRef&&i.modelRef.name===i.model&&e.find(l=>l.id===i.modelRef?.providerId)?.models.some(l=>l.name===i.model)||!i.model||i.model==="Ask me")return;let o=e.find(a=>a.models.some(l=>l.name===i.model));if(!o?.id)return;let s={providerId:o.id,name:i.model};i.modelRef=s,n++,t?.(i,s)}),n}Me();vi();sO();Ec();Uc();Yr();Wt();Ii();Kv();Tt();var lO={"user-script":{severity:"critical",label:"SCRIPT",description:"Runs custom JavaScript with full access to your vault and the network."},"conditional-script":{severity:"critical",label:"CONDITIONAL",description:"Runs custom JavaScript to decide which branch executes."},"bundled-script":{severity:"critical",label:"SCRIPT FILE",description:"Bundles a file that will be written to your vault and can be run as code."},"run-on-startup":{severity:"critical",label:"STARTUP",description:"Runs automatically every time Obsidian starts."},"mislabeled-executable":{severity:"critical",label:"EXECUTABLE",description:"A bundled file is run as code even though it is labeled a template."},"registers-command":{severity:"warning",label:"COMMAND",description:"Adds a command to the command palette."},"obsidian-command":{severity:"warning",label:"OBSIDIAN",description:"Triggers another Obsidian command."},ai:{severity:"warning",label:"AI",description:"Sends note content to your AI provider over the network."},"ai-tools":{severity:"critical",label:"AI TOOLS",description:"Lets an AI model read and write your vault: the script gives the model tools (functions) it calls with model-chosen arguments."},"capture-writes":{severity:"warning",label:"WRITES",description:"Writes captured text into your notes."},"template-write":{severity:"warning",label:"TEMPLATE",description:"Creates notes from a bundled template."},"overwrites-existing-choice":{severity:"warning",label:"OVERWRITES",description:"Replaces a choice that already exists in your vault."},"overwrites-existing-file":{severity:"warning",label:"OVERWRITES",description:"Overwrites a file that already exists in your vault."},"missing-reference":{severity:"warning",label:"MISSING",description:"References a file that is not bundled in this package."},"unknown-command":{severity:"warning",label:"UNKNOWN",description:"An unrecognised command type. Review it manually."},"editor-command":{severity:"info",label:"EDITOR",description:"Runs a built-in editor command."},"open-file":{severity:"info",label:"OPEN FILE",description:"Opens a file in your vault."}};function fS(r){return lO[r].severity}function KY(r){return lO[r].label}function XY(r){return lO[r].description}function QY(r){return r==="user-script"||r==="conditional-script"}function cpe(r,e){return QY(r)||!ir.test(e)}function upe(r,e){if(!ir.test(r))return!1;let t;try{t=qc(e)}catch{return!1}let{code:n}=hc(t);return n!==null&&n.length>0}function dpe(r,e){let t;try{t=qc(e)}catch{return null}if(ir.test(r)){let{code:n}=hc(t);return n!==null&&n.length>0?n:null}return t}var ppe=/\bai\s*\.\s*(?:tools|agent|tool)\b|\btools\s*\.\s*(?:vault|workspace|system)\s*\(/;function fpe(r){return ppe.test(r)}var mS={critical:0,warning:1,info:2},mpe=new Set(Object.values(Lr));function Wa(r){return r.filter(e=>!!e).join(" \u203A ")}function hpe(r){let e=r.name?.trim();return e&&e.length>0?e:String(r.type)}function gpe(r){if(r.mode==="script")return`script: ${r.scriptPath}${r.exportName?` (${r.exportName})`:""}`;let e=r.expectedValue!==void 0?` ${r.expectedValue}`:"";return`${r.variableName} ${r.operator}${e}`}function vpe(r){return r.type==="Macro"}function ype(r){return r.type==="Multi"}function bpe(r){return r.type==="Template"}function wpe(r){return r.type==="Capture"}function Cpe(r){let e=r.fileExistsBehavior;return!e||e.kind!=="apply"?!1:e.mode==="overwrite"||e.mode==="appendTop"||e.mode==="appendBottom"}function ZY(r){let e=[],t=new Set(r.choices.map(n=>n.choice.id));for(let n of r.choices){let i=n.choice,o=Wa(n.pathHint.slice(0,-1))||"Root",s={choiceId:i.id,name:i.name,type:i.type,location:o,registersCommand:!1,flags:new Set,commands:[],usages:[],rows:[]};cO(i,s,[i.name],t,0),e.push(s)}return{choiceWalks:e}}function cO(r,e,t,n,i){if(r.command&&(e.registersCommand=!0,e.flags.add("registers-command")),vpe(r)&&(r.runOnStartup&&(e.flags.add("run-on-startup"),e.rows.push({flag:"run-on-startup",severity:"critical",title:"Runs automatically every time Obsidian starts",detail:Wa(t)})),aO(r.macro?.commands,e,t,n,i)),bpe(r)&&(r.templatePath&&e.usages.push({choiceId:e.choiceId,path:r.templatePath,asScript:!1,impliedKind:"template",breadcrumb:Wa([...t,"template"])}),Cpe(r)&&e.flags.add("template-write")),wpe(r)){e.flags.add("capture-writes");let o=r.createFileIfItDoesntExist;o?.enabled&&o.createWithTemplate&&o.template&&e.usages.push({choiceId:e.choiceId,path:o.template,asScript:!1,impliedKind:"capture-template",breadcrumb:Wa([...t,"new-file template"])})}if(ype(r)&&Array.isArray(r.choices))for(let o of r.choices)Ye(o)&&(n.has(o.id)||cO(o,e,[...t,o.name],n,i))}function aO(r,e,t,n,i){for(let o of Dr(r)){if(!Si(o))continue;let s=hpe(o),a=[...t,s];switch(o.type){case"UserScript":{let l=o;e.flags.add("user-script"),e.commands.push({name:s,type:o.type,depth:i,flag:"user-script",scriptPath:l.path}),l.path&&(e.usages.push({choiceId:e.choiceId,path:l.path,asScript:!0,impliedKind:"user-script",breadcrumb:Wa(a)}),e.rows.push({flag:"user-script",severity:"critical",title:"Runs custom JavaScript with full access to your vault and the network",detail:`${Wa(a)} (${l.path})`,scriptPath:l.path}));break}case"Conditional":{let l=o,c=l.condition,u=c?gpe(c):void 0,d=c?.mode==="script"&&!!c.scriptPath;if(e.commands.push({name:s,type:o.type,depth:i,flag:d?"conditional-script":void 0,scriptPath:d?c.scriptPath:void 0,summary:u}),d){let f=c.scriptPath;e.flags.add("conditional-script"),e.usages.push({choiceId:e.choiceId,path:f,asScript:!0,impliedKind:"conditional-script",breadcrumb:Wa(a)}),e.rows.push({flag:"conditional-script",severity:"critical",title:"Runs custom JavaScript chosen by a condition",detail:`${Wa(a)} (${f})`,scriptPath:f})}aO(l.thenCommands??[],e,[...a,"then"],n,i+1),aO(l.elseCommands??[],e,[...a,"else"],n,i+1);break}case"NestedChoice":{let l=o;e.commands.push({name:s,type:o.type,depth:i}),l.choice&&cO(l.choice,e,[...a,l.choice.name],n,i+1);break}case"Obsidian":{let l=o;e.flags.add("obsidian-command"),e.commands.push({name:s,type:o.type,depth:i}),e.rows.push({flag:"obsidian-command",severity:"warning",title:"Triggers another Obsidian command",detail:`${Wa(a)}${l.commandId?` (${l.commandId})`:""}`});break}case"AIAssistant":{e.flags.add("ai"),e.commands.push({name:s,type:o.type,depth:i}),e.rows.push({flag:"ai",severity:"warning",title:"Sends note content to your AI provider over the network",detail:Wa(a)});break}case"EditorCommand":{e.flags.add("editor-command"),e.commands.push({name:s,type:o.type,depth:i});break}case"OpenFile":{e.flags.add("open-file"),e.commands.push({name:s,type:o.type,depth:i});break}case"Choice":case"Wait":{e.commands.push({name:s,type:o.type,depth:i});break}default:{mpe.has(String(o.type))?e.commands.push({name:s,type:String(o.type),depth:i}):(e.flags.add("unknown-command"),e.commands.push({name:s,type:String(o.type),depth:i,flag:"unknown-command"}),e.rows.push({flag:"unknown-command",severity:"warning",title:"Unknown capability. Review it manually.",detail:`${Wa(a)} (${String(o.type)})`}));break}}}}function JY(r){let{choiceWalks:e}=ZY(r),t=new Set;for(let n of e)for(let i of n.usages)i.path&&t.add(i.path);return Array.from(t)}function xpe(r){let e=r.length;if(e===0)return 0;let t=0;return r.endsWith("==")?t=2:r.endsWith("=")&&(t=1),Math.max(0,Math.floor(e*3/4)-t)}function Epe(r,e){return mS[fS(r)]-mS[fS(e)]}function e4(r,e,t){let{choiceWalks:n}=ZY(e),i=new Set(Bn(r).map(E=>E.id)),o=new Map;for(let E of n)for(let D of E.usages){let P=o.get(D.path)??[];P.push(D),o.set(D.path,P)}let s=new Set;for(let[E,D]of o)D.some(P=>P.asScript)&&s.add(E);let a=new Set(e.assets.map(E=>E.originalPath)),l=e.assets.map(E=>{let D=o.get(E.originalPath)??[],P=s.has(E.originalPath),V=P||cpe(E.kind,E.originalPath)||upe(E.originalPath,E.content);return{originalPath:E.originalPath,kind:E.kind,bundled:!0,executable:P,requiresReview:V,exists:t.has(E.originalPath),sizeBytes:xpe(E.content),orphan:D.length===0,referencedBy:D}}),c=n.map(E=>{let D=i.has(E.choiceId),P=Array.from(E.flags);return D&&P.push("overwrites-existing-choice"),P.sort(Epe),{choiceId:E.choiceId,name:E.name,type:E.type,location:E.location,exists:D,registersCommand:E.registersCommand,flags:P,commands:E.commands}}),u=[];for(let[E,D]of o){if(a.has(E)||t.has(E))continue;let P=D.some(V=>V.asScript);u.push({path:E,asScript:P,breadcrumb:D[0]?.breadcrumb??E})}let d=l.filter(E=>E.orphan).map(E=>E.originalPath),f=[];for(let E of n)for(let D of E.rows)f.push(D);for(let E of l)E.executable&&(QY(E.kind)||f.push({flag:"mislabeled-executable",severity:"critical",title:"Runs a file as code even though it is labeled a template",detail:E.originalPath,scriptPath:E.originalPath}));for(let E of l)E.requiresReview&&(E.executable||f.push({flag:"bundled-script",severity:"critical",title:"Bundles a file that will be written to your vault and can be run as code",detail:E.originalPath,scriptPath:E.originalPath}));for(let E of l){if(!E.requiresReview)continue;let D=e.assets.find(V=>V.originalPath===E.originalPath);if(!D)continue;let P=dpe(D.originalPath,D.content);!P||!fpe(P)||f.push({flag:"ai-tools",severity:"critical",title:"Lets an AI model read and write your vault",detail:E.originalPath,scriptPath:E.originalPath})}let p=c.filter(E=>E.registersCommand).length;p>0&&f.push({flag:"registers-command",severity:"warning",title:"Adds commands to the command palette",detail:`${p} choice${p===1?"":"s"}`});let m=c.filter(E=>E.exists).length;m>0&&f.push({flag:"overwrites-existing-choice",severity:"warning",title:"Replaces choices that already exist in your vault",detail:`${m} choice${m===1?"":"s"}`});let v=l.filter(E=>E.exists).length;if(v>0&&f.push({flag:"overwrites-existing-file",severity:"warning",title:"Overwrites existing files in your vault",detail:`${v} file${v===1?"":"s"}`}),u.length>0){let E=u.filter(D=>D.asScript).length;f.push({flag:"missing-reference",severity:E>0?"critical":"warning",title:E>0?"References scripts that are not bundled, so they run from whatever exists at those paths after import":"References files that are not bundled and not in your vault",detail:`${u.length} reference${u.length===1?"":"s"}`})}f.sort((E,D)=>mS[E.severity]-mS[D.severity]);let g=l.filter(E=>E.requiresReview).map(E=>E.originalPath),y=s.size,w=n.some(E=>E.flags.has("run-on-startup")),x=f.filter(E=>E.severity==="critical").length,C=f.filter(E=>E.severity==="warning").length,_={hasCritical:x>0,hasWarning:C>0,criticalCount:x,warningCount:C,runsOnStartup:w,scriptCount:y,registersCommandCount:p,overwritesChoices:m,overwritesFiles:v,missingCount:u.length};return{quickAddVersion:e.quickAddVersion,createdAt:e.createdAt,choiceCount:e.choices.length,fileCount:e.assets.length,choices:c,files:l,capabilityRows:f,missingReferences:u,orphanAssets:d,criticalScriptPaths:g,summary:_}}var YY=1e5;function Tpe(r){return typeof TextEncoder<"u"?new TextEncoder().encode(r).length:r.length}function _pe(r){if(r.length<1e3)return!1;let e=0,t=1,n=0;for(let o=0;o<r.length;o++)r[o]===`
|
||
`?(n>e&&(e=n),n=0,t++):n++;n>e&&(e=n);let i=r.length/t;return e>1e3||i>250}function hS(r,e){let t=r.assets.find(n=>n.originalPath===e);if(!t)return{found:!1,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:"File is not bundled in this package."};try{let n=qc(t.content),i=n.length>YY,o=i?n.slice(0,YY):n;return{found:!0,text:o,truncated:i,sizeBytes:Tpe(n),looksMinified:_pe(o)}}catch(n){return{found:!0,text:"",truncated:!1,sizeBytes:0,looksMinified:!1,error:n instanceof Error?n.message:String(n)}}}function t4(r){return r.summary.hasCritical}function r4(r,e){return r.criticalScriptPaths.every(t=>e.has(t))}async function n4(r,e){if(Un(e))throw new Error(`Refusing to read a package outside the vault: "${e}".`);let t=(0,gS.normalizePath)(e.trim());if(!t)throw new Error("Package path cannot be empty.");if(!await r.vault.adapter.exists(t))throw new Error(`Package file not found: ${t}`);let i=await r.vault.adapter.read(t);return{pkg:mO(i),path:t}}function mO(r){let e;try{e=JSON.parse(r)}catch(o){throw new Error(`Package content is not valid JSON: ${o?.message??o}`)}if(!$Y(e))throw new Error("Content is not a valid QuickAdd package.");if(e.schemaVersion>1)throw new Error(`Package schema version ${e.schemaVersion} is newer than this plugin supports (${1}).`);let t=Ape(e.assets);if(t!==null)throw new Error(`Package contains duplicate asset path "${t}". Each asset must have a unique path.`);let n=kpe(e.choices);if(n!==null)throw new Error(`Package contains conflicting definitions for choice "${n}". Each choice id must describe the same choice everywhere it appears.`);let i=Spe(e.choices);if(i!==null)throw new Error(`Package choice "${i}" names a parent that does not list it as a child. Each parented choice must appear inside its parent.`);return e}function Ape(r){let e=new Set;for(let t of r){let n=(0,gS.normalizePath)(t.originalPath??"");if(e.has(n))return t.originalPath;e.add(n)}return null}function kpe(r){let e=new Map,t=null,n=i=>{if(t!==null||!i||typeof i!="object")return;let o=i.id;if(typeof o=="string"){let s=dO(i),a=e.get(o);if(a===void 0)e.set(o,s);else if(a!==s){t=o;return}}if(i.type==="Multi"){let s=i;if(Array.isArray(s.choices))for(let a of s.choices)n(a)}i.type==="Macro"&&uO(i.macro?.commands,n)};for(let i of r){if(t!==null)break;n(i?.choice)}return t}function uO(r,e){if(Array.isArray(r)){for(let t of r)if(t){if(t.type==="NestedChoice")e(t.choice);else if(t.type==="Conditional"){let n=t;uO(n.thenCommands,e),uO(n.elseCommands,e)}}}}function dO(r){if(r===null||typeof r!="object"){let n=JSON.stringify(r);return n===void 0?"\0undefined":n}if(Array.isArray(r))return`[${r.map(dO).join(",")}]`;let e=r;return`{${Object.keys(e).sort().map(n=>`${JSON.stringify(n)}:${dO(e[n])}`).join(",")}}`}function Spe(r){let e=new Map(r.map(t=>[t.choice.id,t]));for(let t of r){let n=t.parentChoiceId;if(n===null)continue;let i=e.get(n);if(!i)continue;let o=i.choice;if(!st(o).some(a=>a?.id===t.choice.id))return t.choice.id}return null}async function i4(r,e,t){let n=new Map(Bn(e).map(s=>[s.id,s])),i=t.choices.map(s=>({choiceId:s.choice.id,name:s.choice.name,parentChoiceId:s.parentChoiceId,pathHint:s.pathHint??[],exists:n.has(s.choice.id)})),o=[];for(let s of t.assets){let a=Un(s.originalPath)?!1:await r.vault.adapter.exists(s.originalPath);o.push({originalPath:s.originalPath,exists:a,kind:s.kind})}return{choiceConflicts:i,assetConflicts:o}}async function vS(r,e,t){let n=new Set([...t.assets.map(a=>a.originalPath),...JY(t)]),i=new Set;await Promise.all(Array.from(n,async a=>{a&&(Un(a)||await s4(r,a)&&i.add(a))}));let o=e4(e,t,i),{summary:s}=o;return F.logMessage(`QuickAdd import preview: choices=${o.choiceCount} files=${o.fileCount} scripts=${s.scriptCount} runOnStartup=${s.runsOnStartup} registersCommands=${s.registersCommandCount} overwritesChoices=${s.overwritesChoices} overwritesFiles=${s.overwritesFiles} missing=${s.missingCount} critical=${s.criticalCount} warning=${s.warningCount}`),o}function Dpe(r){let t=(r??"").trim();if(!t)throw new Error("Package asset has an empty destination path.");let n=t.replace(/\\/g,"/");if(n.startsWith("/")||/^[a-zA-Z]:/.test(n))throw new Error(`Refusing to import asset to an absolute path outside the vault: "${n}".`);let i=(0,gS.normalizePath)(t);if(!i||i.trim()==="")throw new Error("Package asset has an empty destination path.");let o=i.split("/").filter(a=>a.length>0);if(o.some(a=>a===".."))throw new Error(`Refusing to import asset with a path-traversal segment ("..") in: "${i}".`);if(o.find(a=>a.startsWith(".")&&!a.startsWith("..%")))throw new Error(`Refusing to import asset into a config directory: "${i}".`);return i}async function o4(r){let{app:e,existingChoices:t,pkg:n}=r,i=new Map(r.choiceDecisions.map(M=>[M.choiceId,M.mode])),o=new Map(r.assetDecisions.map(M=>[M.originalPath,M])),s=new Map(n.choices.map(M=>[M.choice.id,M])),a=Ipe(n),l=new Set,c=new Map,u=new Set,d=M=>{let U=X=>(c.set(M,X),u.delete(M),X);if(c.has(M))return c.get(M);if(u.has(M))return!0;if(u.add(M),i.get(M)==="skip")return U(!1);let B=s.get(M);if(!B)return U(!1);let ie=B.parentChoiceId;if(!ie||!s.has(ie)||i.get(ie)==="skip")return U(!0);let Y=d(ie);return U(Y)};for(let M of n.choices)d(M.choice.id)&&l.add(M.choice.id);let f=new Set,p=new Set,m=new Set,v=new Map,g=M=>{let U=()=>(f.add(M),p.delete(M),!0),q=()=>(p.add(M),!1);if(!l.has(M))return!1;if(f.has(M))return!0;if(p.has(M))return!1;if(m.has(M))return q();m.add(M);try{if(i.get(M)==="duplicate")return U();let W=s.get(M)?.parentChoiceId??null;return W&&(i.get(W)==="duplicate"||l.has(W)&&g(W))?U():q()}finally{m.delete(M)}};for(let M of n.choices){if(!l.has(M.choice.id))continue;let q=g(M.choice.id)?xr():M.choice.id;v.set(M.choice.id,q)}let y=ht(t),w=[],x=[],C=[],_=new Map;for(let M of n.choices){if(!l.has(M.choice.id)){C.push(M.choice.id);continue}let U=ht(M.choice),q=hO(U,v,l,{secretOptionNamesByPath:a,stripUnknownStringSettings:!0});_.set(M.choice.id,q)}r.aiProviders?.length&&pS(Array.from(_.values()),r.aiProviders);let E=new Set;for(let M of n.choices){let U=M.choice.id;if(!l.has(U)||E.has(U))continue;let q=_.get(U);if(!q)continue;let B=q.id,ie=i.get(U)??"import",W=M.parentChoiceId;if(W&&l.has(W)?_.get(W):null){E.add(U);continue}if((ie==="overwrite"||ie==="import")&&a4(y,q)){x.push(B),E.add(U);continue}if(W){let ae=v.get(W)??W;if(l4(y,ae,q)){w.push(B),E.add(U);continue}let ge=Fpe(y,M.pathHint.slice(0,-1));if(ge&&c4(ge,q)){w.push(B),E.add(U);continue}F.logWarning(`QuickAdd import: could not locate parent for '${M.choice.name}'. Adding to root.`)}let X=y.findIndex(ae=>Ye(ae)&&ae.id===B);X!==-1?(y.splice(X,1,q),x.push(B)):(y.push(q),w.push(B)),E.add(U)}let D=new Map,P=[],V=[],j=n.assets.map(M=>{let q=o.get(M.originalPath)?.destinationPath?.trim(),B=Dpe(q||M.originalPath);return{asset:M,destinationPath:B}}),oe=await Ppe(e),se=new Map;for(let{asset:M,destinationPath:U}of j){if(o.get(M.originalPath)?.mode==="skip")continue;let q=oe?U.toLowerCase():U,B=se.get(q);if(B)throw new Error(`Refusing to import: assets "${B.originalPath}" and "${M.originalPath}" resolve to the same destination ("${U}"). Rename one so each imported file is unique.`);se.set(q,{originalPath:M.originalPath,destinationPath:U})}for(let{destinationPath:M}of j)await lg(e,M);for(let{asset:M,destinationPath:U}of j){let q=o.get(M.originalPath),B=await s4(e,U);if((q?.mode??(B?"overwrite":"write"))==="skip"){V.push(U);continue}await aS(e,U);let W=qc(M.content);await e.vault.adapter.write(U,W),P.push(U),D.set(M.originalPath,U)}for(let M of _.values())gO(M,D);return{updatedChoices:y,addedChoiceIds:w,overwrittenChoiceIds:x,skippedChoiceIds:C,writtenAssets:P,skippedAssets:V}}function Ipe(r){let e=new Map;for(let t of r.assets)if(t.kind==="user-script")try{let n=Ph(qc(t.content),t.originalPath);e.set(t.originalPath,n.foundSecretOptions&&n.names.size===0?null:n.names)}catch(n){F.logWarning(`QuickAdd import could not inspect user-script settings '${t.originalPath}': ${n?.message??n}`)}return e}async function s4(r,e){try{return await r.vault.adapter.exists(e)}catch{return!1}}async function Ppe(r){let e=r.vault.configDir;if(!e)return!1;let t=e===e.toLowerCase()?e.toUpperCase():e.toLowerCase();if(t===e)return!1;try{return await r.vault.adapter.exists(t)}catch{return!1}}function hO(r,e,t,n){let i=r.id,o=e.get(i)??i;r.id=o;let s=o!==i;if(r.type==="Macro"){let a=r;s&&ed(a.macro)&&(a.macro.id=xr()),pO(Wn(a.macro),e,t,s,n)}if(r.type==="Multi"){let a=r;Array.isArray(a.choices)&&(a.choices=a.choices.filter(l=>Ye(l)&&t.has(l.id)).map(l=>hO(l,e,t,n)))}return r}function pO(r,e,t,n,i){for(let o of Dr(r))if(Si(o))switch(y$(o,i),n&&(o.id=xr()),o.type){case"Choice":{let s=o,a=e.get(s.choiceId);a&&(s.choiceId=a);break}case"Conditional":{let s=o;pO(s.thenCommands,e,t,n,i),pO(s.elseCommands,e,t,n,i);break}case"NestedChoice":{let s=o;s.choice&&t.has(s.choice.id)&&(s.choice=hO(s.choice,e,t,i));break}default:break}}function a4(r,e){for(let t=0;t<r.length;t++){let n=r[t];if(Ye(n)){if(n.id===e.id)return r.splice(t,1,e),!0;if(a4(st(n),e))return!0}}return!1}function l4(r,e,t){for(let n of r)if(Ye(n)){if(n.id===e&&n.type==="Multi")return c4(n,t);if(l4(st(n),e,t))return!0}return!1}function c4(r,e){if(!Array.isArray(r.choices)){if(Ws(r))return!1;r.choices=[]}let t=r.choices.findIndex(n=>Ye(n)&&n.id===e.id);return t!==-1?r.choices.splice(t,1,e):r.choices.push(e),!0}function Fpe(r,e){if(e.length===0)return null;let t=r,n=null;for(let i of e){let o=t.find(s=>Ye(s)&&s.type==="Multi"&&s.name===i);if(!o)return null;n=o,t=st(o)}return n}function gO(r,e){switch(r.type){case"Macro":{fO(Wn(r.macro),e);break}case"Template":{let t=r,n=e.get(t.templatePath);n&&(t.templatePath=n);break}case"Capture":{let t=r,n=t.createFileIfItDoesntExist?.template;if(n){let i=e.get(n);i&&(t.createFileIfItDoesntExist={...t.createFileIfItDoesntExist,template:i})}break}case"Multi":{r.choices?.forEach(n=>gO(n,e));break}default:break}}function fO(r,e){for(let t of Dr(r))if(Si(t))switch(t.type){case"UserScript":{let n=t,i=e.get(n.path);i&&(n.name===n.path?n.name=i:n.name.startsWith(`${n.path}::`)&&(n.name=i+n.name.slice(n.path.length)),n.path=i);break}case"Conditional":{let n=t;if(n.condition.mode==="script"&&n.condition.scriptPath){let i=e.get(n.condition.scriptPath);i&&(n.condition={...n.condition,scriptPath:i})}fO(n.thenCommands,e),fO(n.elseCommands,e);break}case"NestedChoice":{let n=t;n.choice&&gO(n.choice,e);break}default:break}}var yS=require("obsidian");function Tx(r,e){return e&&(0,yS.setTooltip)(r,e),{update(t){(0,yS.setTooltip)(r,t??"")},destroy(){(0,yS.setTooltip)(r,"")}}}var Mpe=z("<span> </span>"),Rpe={hash:"svelte-5jkd35",code:`.qa-import-tag.svelte-5jkd35 {display:inline-flex;align-items:center;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;font-weight:600;letter-spacing:0.02em;text-transform:uppercase;line-height:1.45;white-space:nowrap;cursor:help;}
|
||
|
||
/* Critical: darkened red so white text clears WCAG AA (~5:1) at this size,
|
||
where Obsidian's stock --color-red (#e93147) lands at ~3.5:1. */.qa-import-tag.critical.svelte-5jkd35 {background:var(--qa-sev-critical-pill);color:#fff;}
|
||
|
||
/* Warning: amber is medium-luminance in both themes, so near-black text
|
||
(~8:1) beats white-on-amber (~2.9:1). Fallback #ff8c00 matches styles.css
|
||
and clears AA (~5.9:1) with #1a1a1a. */.qa-import-tag.warning.svelte-5jkd35 {background:var(--color-orange, #ff8c00);color:#1a1a1a;}.qa-import-tag.info.svelte-5jkd35 {background:var(--background-modifier-border);color:var(--text-normal);}`};function _x(r,e){we(e,!0),ot(r,Rpe);let t=O(()=>fS(e.flag)),n=O(()=>KY(e.flag)),i=O(()=>XY(e.flag));var o=Mpe();let s;var a=I(o,!0);S(o),Fr(o,(l,c)=>Tx?.(l,c),()=>h(i)),de(()=>{s=wt(o,1,"qa-import-tag svelte-5jkd35",null,s,{critical:h(t)==="critical",warning:h(t)==="warning",info:h(t)==="info"}),me(a,h(n))}),$(r,o),Ce()}var $pe=z('<span class="qa-import-banner-detail svelte-tb9yz"> </span>'),Ope=z('<li><span class="qa-import-banner-tag svelte-tb9yz"><!></span><span class="qa-import-banner-title svelte-tb9yz"> </span> <!></li>'),Npe=z('<p class="qa-import-banner-note svelte-tb9yz">Takes effect after you reload the plugin or restart Obsidian.</p>'),Lpe=z('<section aria-label="What this package can do"><div class="qa-import-banner-head svelte-tb9yz"><span class="qa-import-banner-icon svelte-tb9yz"><!></span> <h3 class="svelte-tb9yz">What this package can do</h3></div> <ul class="qa-import-banner-rows svelte-tb9yz"></ul> <!></section>'),Bpe={hash:"svelte-tb9yz",code:`.qa-import-banner.svelte-tb9yz {background:var(--background-secondary);border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.85rem;display:flex;flex-direction:column;gap:0.5rem;}
|
||
|
||
/* Critical packages get a red-tinted hairline + red icon, not a blanket-red
|
||
fill: severity stays ranked and all text keeps its contrast on the neutral
|
||
surface. (A solid colored side-stripe would be the banned pattern.) */.qa-import-banner.critical.svelte-tb9yz {border-color:var(--qa-sev-critical-border);}.qa-import-banner-head.svelte-tb9yz {display:flex;align-items:center;gap:0.5rem;}.qa-import-banner-icon.svelte-tb9yz {display:inline-flex;color:var(--text-warning, var(--text-muted));}.qa-import-banner.critical.svelte-tb9yz .qa-import-banner-icon:where(.svelte-tb9yz) {color:var(--text-error);}.qa-import-banner-head.svelte-tb9yz h3:where(.svelte-tb9yz) {margin:0;font-size:1rem;}.qa-import-banner-rows.svelte-tb9yz {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}
|
||
|
||
/* The pill is an inline lead-in to the sentence (not a fixed left column),
|
||
so long titles wrap full-width under it instead of leaving a dead column
|
||
of whitespace beside a one-line pill. */.qa-import-banner-rows.svelte-tb9yz li:where(.svelte-tb9yz) {display:block;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);}.qa-import-banner-tag.svelte-tb9yz {display:inline-block;vertical-align:middle;margin:0 0.4rem 0.15rem 0;}
|
||
|
||
/* Faint per-row severity wash so critical rows read hottest while warnings
|
||
recede, without saturating the whole banner. Composited over the banner
|
||
surface (not transparent) so the tint is a solid, predictable colour. */.qa-import-banner-rows.svelte-tb9yz li.sev-critical:where(.svelte-tb9yz) {background:var(--qa-sev-critical-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-warning:where(.svelte-tb9yz) {background:var(--qa-sev-warning-wash);}.qa-import-banner-rows.svelte-tb9yz li.sev-info:where(.svelte-tb9yz) {background:var(--qa-sev-info-wash);}.qa-import-banner-title.svelte-tb9yz {line-height:1.4;}.qa-import-banner-detail.svelte-tb9yz {display:block;margin-top:0.15rem;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);overflow-wrap:anywhere;}.qa-import-banner-note.svelte-tb9yz {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}`};function vO(r,e){we(e,!0),ot(r,Bpe);let t=O(()=>e.preview.summary.runsOnStartup||e.preview.summary.registersCommandCount>0);var n=Lpe();let i;var o=I(n),s=I(o),a=I(s);Rt(a,{iconId:"alert-triangle",size:17}),S(s),In(2),S(o);var l=A(o,2);ar(l,21,()=>e.preview.capabilityRows,d=>d.flag+d.detail,(d,f)=>{var p=Ope();let m;var v=I(p),g=I(v);_x(g,{get flag(){return h(f).flag}}),S(v);var y=A(v),w=I(y,!0);S(y);var x=A(y,2);{var C=_=>{var E=$pe(),D=I(E,!0);S(E),de(()=>me(D,h(f).detail)),$(_,E)};ne(x,_=>{h(f).detail&&_(C)})}S(p),de(()=>{m=wt(p,1,"svelte-tb9yz",null,m,{"sev-critical":h(f).severity==="critical","sev-warning":h(f).severity==="warning","sev-info":h(f).severity==="info"}),me(w,h(f).title)}),$(d,p)}),S(l);var c=A(l,2);{var u=d=>{var f=Npe();$(d,f)};ne(c,d=>{h(t)&&d(u)})}S(n),de(()=>i=wt(n,1,"qa-import-banner svelte-tb9yz",null,i,{critical:e.preview.summary.hasCritical})),$(r,n),Ce()}var Upe=z('<span class="qa-import-file-exec svelte-lmqem5">Executable</span>'),Vpe=z('<span class="qa-import-file-reviewed svelte-lmqem5"><!> Reviewed</span>'),qpe=z('<span class="qa-import-file-orphan svelte-lmqem5">Unused</span>'),Wpe=z("<option>Overwrite</option>"),zpe=z(`<p class="qa-import-file-skip-warn svelte-lmqem5" role="note">Won't be written. Any choice that uses this script will run whatever
|
||
file already exists at this path after import, not the contents you
|
||
reviewed.</p>`),Hpe=z('<p class="qa-import-file-error svelte-lmqem5"> </p>'),jpe=z(`<p class="qa-import-file-warn svelte-lmqem5">Minified: cannot be visually reviewed. Import
|
||
only if you trust the source.</p>`),Gpe=z('<p class="qa-import-file-warn svelte-lmqem5"> </p>'),Ype=z('<!> <pre class="qa-import-file-code svelte-lmqem5" tabindex="0" role="region"> </pre> <!>',1),Kpe=z('<div class="qa-import-file-preview svelte-lmqem5"><!></div>'),Xpe=z('<div><div class="qa-import-file-head svelte-lmqem5"><!> <span> </span> <span class="qa-import-file-arrow svelte-lmqem5" aria-hidden="true">\u2192</span> <span class="qa-import-file-dest svelte-lmqem5"> </span></div> <div class="qa-import-file-badges svelte-lmqem5"><!> <!> <!> <span class="qa-import-file-size svelte-lmqem5"> </span></div> <div class="qa-import-file-fields svelte-lmqem5"><label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Destination</span> <input type="text" placeholder="vault/path/to/file" class="svelte-lmqem5"/></label> <label class="qa-import-file-field svelte-lmqem5"><span class="qa-import-file-field-name svelte-lmqem5">Action</span> <select class="dropdown svelte-lmqem5"><option>Write</option><!><option>Skip</option></select></label></div> <!> <button type="button" class="qa-import-file-toggle svelte-lmqem5"><span><!></span> <span> </span></button> <div><div class="qa-import-file-preview-inner svelte-lmqem5"><!></div></div></div>'),Qpe={hash:"svelte-lmqem5",code:`.qa-import-file.svelte-lmqem5 {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;display:flex;flex-direction:column;gap:0.5rem;background:var(--background-secondary);}.qa-import-file.overwrite.svelte-lmqem5 {border-color:var(--qa-sev-critical-border);}.qa-import-file-head.svelte-lmqem5 {display:flex;align-items:center;gap:0.4rem;flex-wrap:wrap;}.qa-import-file-status.svelte-lmqem5 {font-size:0.78rem;font-weight:700;letter-spacing:0.01em;color:var(--text-muted);}.qa-import-file-status.overwrite.svelte-lmqem5 {color:var(--text-error);}.qa-import-file-arrow.svelte-lmqem5 {color:var(--text-muted);}.qa-import-file-dest.svelte-lmqem5 {font-family:var(--font-monospace);font-size:0.85rem;overflow-wrap:anywhere;}.qa-import-file-badges.svelte-lmqem5 {display:flex;flex-wrap:wrap;gap:0.35rem;align-items:center;}.qa-import-file-orphan.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;background:var(--background-modifier-hover);
|
||
/* --text-normal (not --text-muted) so the badge clears AA on the hover
|
||
surface in dark themes too. */color:var(--text-normal);cursor:help;}.qa-import-file-exec.svelte-lmqem5 {display:inline-flex;padding:0.05rem 0.4rem;border-radius:var(--radius-s, 4px);font-size:0.7rem;font-weight:700;letter-spacing:0.02em;text-transform:uppercase;background:var(--qa-sev-critical-pill);color:#fff;cursor:help;}.qa-import-file-reviewed.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.15rem;font-size:0.72rem;color:var(--text-success, var(--color-green, #0aa344));}.qa-import-file-size.svelte-lmqem5 {font-size:0.72rem;color:var(--text-faint);margin-left:auto;}
|
||
|
||
/* Obsidian Setting-row geometry: field name on the left at --text-normal,
|
||
control docked right at its native height \u2014 not a stacked label-above
|
||
form field (which read as non-native). */.qa-import-file-fields.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;}.qa-import-file-field.svelte-lmqem5 {display:flex;align-items:center;gap:1rem;}.qa-import-file-field-name.svelte-lmqem5 {flex:1 1 auto;min-width:0;color:var(--text-normal);}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5) {flex:0 1 300px;min-width:0;}.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:0 0 auto;}
|
||
|
||
/* The native Obsidian input/dropdown focus box-shadow handles focus; no
|
||
custom outline (which would read as non-native). */.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5):disabled {opacity:0.5;cursor:not-allowed;}.qa-import-file-toggle.svelte-lmqem5 {display:inline-flex;align-items:center;gap:0.3rem;align-self:flex-start;background:transparent;border:none;box-shadow:none;padding:0.1rem 0.2rem;margin-left:-0.2rem;cursor:pointer;color:var(--text-accent);font-size:0.85rem;border-radius:var(--radius-s, 4px);}.qa-import-file-toggle.svelte-lmqem5:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.qa-import-file-toggle.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}.qa-import-file-chevron.svelte-lmqem5 {display:inline-flex;transition:transform 180ms ease;}.qa-import-file-chevron.open.svelte-lmqem5 {transform:rotate(90deg);}.qa-import-file-preview-wrap.svelte-lmqem5 {display:grid;grid-template-rows:0fr;transition:grid-template-rows 200ms ease;}.qa-import-file-preview-wrap.open.svelte-lmqem5 {grid-template-rows:1fr;}.qa-import-file-preview-inner.svelte-lmqem5 {overflow:hidden;min-height:0;}.qa-import-file-preview.svelte-lmqem5 {display:flex;flex-direction:column;gap:0.4rem;padding-top:0.2rem;}.qa-import-file-warn.svelte-lmqem5 {margin:0;color:var(--text-warning, var(--text-muted));font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-skip-warn.svelte-lmqem5 {margin:0;padding:0.4rem 0.5rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-warning-wash);color:var(--text-normal);font-size:var(--font-ui-smaller, 0.85rem);line-height:1.4;}.qa-import-file-error.svelte-lmqem5 {margin:0;color:var(--text-error);font-size:var(--font-ui-smaller, 0.85rem);}.qa-import-file-code.svelte-lmqem5 {margin:0;max-height:240px;overflow:auto;padding:0.5rem 0.6rem;border-radius:var(--radius-s, 4px);background:var(--background-modifier-form-field);border:1px solid var(--background-modifier-border);font-family:var(--font-monospace);font-size:0.8rem;line-height:1.5;white-space:pre;tab-size:4;}.qa-import-file-code.svelte-lmqem5:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:1px;}
|
||
|
||
@media (max-width: 600px) {
|
||
/* Stack control under its name and let it use the full width on narrow
|
||
screens, where a right-docked control would be cramped. */.qa-import-file-field.svelte-lmqem5 {flex-wrap:wrap;gap:0.25rem;}.qa-import-file-field.svelte-lmqem5 input:where(.svelte-lmqem5),
|
||
.qa-import-file-field.svelte-lmqem5 select:where(.svelte-lmqem5) {flex:1 1 100%;}.qa-import-file-size.svelte-lmqem5 {margin-left:0;}
|
||
}.is-mobile .qa-import-file-toggle.svelte-lmqem5 {min-height:36px;padding:0.4rem 0.3rem;}
|
||
|
||
@media (prefers-reduced-motion: reduce) {.qa-import-file-chevron.svelte-lmqem5,
|
||
.qa-import-file-preview-wrap.svelte-lmqem5 {transition:none;}
|
||
}`};function bS(r,e){we(e,!0),ot(r,Qpe);let t=he(e,"reviewed",3,!1),n=Ae(!1),i=O(()=>h(n)?hS(e.pkg,e.file.originalPath):null),o=O(()=>`qa-file-preview-${e.file.originalPath.replace(/[^a-zA-Z0-9_-]/g,"-")}`);function s(_e){return _e<1024?`${_e} B`:_e<1024*1024?`${(_e/1024).toFixed(1)} KB`:`${(_e/(1024*1024)).toFixed(1)} MB`}function a(){Z(n,!h(n)),h(n)&&e.file.requiresReview&&e.onReviewed(e.file.originalPath)}function l(_e){e.onPathInput(_e.currentTarget.value)}function c(_e){e.onModeChange(_e.currentTarget.value)}var u=Xpe();let d;var f=I(u),p=I(f);{let _e=O(()=>e.destinationExists?"file-warning":"file-plus");Rt(p,{get iconId(){return h(_e)},size:16})}var m=A(p,2);let v;var g=I(m,!0);S(m);var y=A(m,4),w=I(y,!0);S(y),S(f);var x=A(f,2),C=I(x);{var _=_e=>{var Be=Upe();Fr(Be,(ut,or)=>Tx?.(ut,or),()=>"Runs as code when its choice runs. It can read, change, or delete files in your vault and access the network."),$(_e,Be)};ne(C,_e=>{e.file.executable&&_e(_)})}var E=A(C,2);{var D=_e=>{var Be=Vpe(),ut=I(Be);Rt(ut,{iconId:"check",size:12}),In(),S(Be),$(_e,Be)};ne(E,_e=>{t()&&e.mode!=="skip"&&e.file.requiresReview&&_e(D)})}var P=A(E,2);{var V=_e=>{var Be=qpe();Fr(Be,(ut,or)=>Tx?.(ut,or),()=>"Bundled in this package but not referenced by any choice."),$(_e,Be)};ne(P,_e=>{e.file.orphan&&_e(V)})}var j=A(P,2),oe=I(j,!0);S(j),S(x);var se=A(x,2),M=I(se),U=A(I(M),2);gr(U),S(M);var q=A(M,2),B=A(I(q),2),ie=I(B);ie.value=ie.__value="write";var W=A(ie);{var Y=_e=>{var Be=Wpe();Be.value=Be.__value="overwrite",$(_e,Be)};ne(W,_e=>{e.destinationExists&&_e(Y)})}var X=A(W);X.value=X.__value="skip",S(B);var ae;Vd(B),S(q),S(se);var pe=A(se,2);{var ge=_e=>{var Be=zpe();$(_e,Be)};ne(pe,_e=>{e.file.requiresReview&&e.mode==="skip"&&_e(ge)})}var be=A(pe,2),xe=I(be);let Ue;var $t=I(xe);Rt($t,{iconId:"chevron-right",size:14}),S(xe);var Ne=A(xe,2),Ke=I(Ne,!0);S(Ne),S(be);var Qe=A(be,2);let ye;var We=I(Qe),mt=I(We);{var He=_e=>{var Be=Kpe(),ut=I(Be);{var or=Pt=>{var Ar=Hpe(),ur=I(Ar);S(Ar),de(()=>me(ur,`Preview unavailable: ${h(i).error??""}`)),$(Pt,Ar)},yr=Pt=>{var Ar=Ype(),ur=Pe(Ar);{var dt=jn=>{var re=jpe();$(jn,re)};ne(ur,jn=>{h(i).looksMinified&&jn(dt)})}var Ft=A(ur,2),Hn=I(Ft,!0);S(Ft);var xo=A(Ft,2);{var xs=jn=>{var re=Gpe(),Ie=I(re);S(re),de(()=>me(Ie,`Preview truncated. The full ${e.file.executable?"script will run":"file will be imported"}.`)),$(jn,re)};ne(xo,jn=>{h(i).truncated&&jn(xs)})}de(()=>{ke(Ft,"aria-label",`Contents of ${e.file.originalPath??""}`),me(Hn,h(i).text)}),$(Pt,Ar)};ne(ut,Pt=>{h(i).error?Pt(or):Pt(yr,-1)})}S(Be),$(_e,Be)};ne(mt,_e=>{h(i)&&_e(He)})}S(We),S(Qe),S(u),de(_e=>{d=wt(u,1,"qa-import-file svelte-lmqem5",null,d,{overwrite:e.destinationExists}),v=wt(m,1,"qa-import-file-status svelte-lmqem5",null,v,{overwrite:e.destinationExists}),me(g,e.destinationExists?"Will overwrite":"New file"),me(w,e.destinationPath),me(oe,_e),Ps(U,e.destinationPath),U.disabled=e.mode==="skip",ae!==(ae=e.mode)&&(B.value=(B.__value=e.mode)??"",fu(B,e.mode)),ke(be,"aria-expanded",h(n)),ke(be,"aria-controls",h(o)),Ue=wt(xe,1,"qa-import-file-chevron svelte-lmqem5",null,Ue,{open:h(n)}),me(Ke,h(n)?"Hide contents":"View contents"),ye=wt(Qe,1,"qa-import-file-preview-wrap svelte-lmqem5",null,ye,{open:h(n)}),ke(Qe,"id",h(o))},[()=>s(e.file.sizeBytes)]),De("input",U,l),De("change",B,c),De("click",be,a),$(r,u),Ce()}Et(["input","change","click"]);var Zpe=z('<span class="macroCommandType svelte-1qj0pve"> </span>'),Jpe=z("<code> </code>"),efe=z('<span class="macroCommandSummary svelte-1qj0pve"> </span>'),tfe=z('<li class="svelte-1qj0pve"><span class="macroCommandName svelte-1qj0pve"> </span> <!> <!></li>'),rfe=z('<ul class="macroCommands svelte-1qj0pve"></ul>'),nfe={hash:"svelte-1qj0pve",code:".macroCommands.svelte-1qj0pve {list-style:none;margin:0;padding:0;display:flex;flex-direction:column;gap:0.25rem;}.macroCommands.svelte-1qj0pve li:where(.svelte-1qj0pve) {display:flex;flex-wrap:wrap;align-items:center;gap:0.4rem;font-size:var(--font-ui-smaller, 0.85rem);}.macroCommandName.svelte-1qj0pve {font-weight:500;}.macroCommandType.svelte-1qj0pve {color:var(--text-muted);font-size:0.72rem;}.macroCommandSummary.svelte-1qj0pve {color:var(--text-muted);}"};function yO(r,e){ot(r,nfe);let t={UserScript:"User script",Conditional:"Conditional",NestedChoice:"Nested choice",Obsidian:"Obsidian command",Choice:"Choice",Wait:"Wait",EditorCommand:"Editor command",AIAssistant:"AI assistant",OpenFile:"Open file"};function n(o){return t[o]??o}var i=rfe();ar(i,21,()=>e.commands,Fv,(o,s)=>{var a=tfe(),l=I(a),c=I(l,!0);S(l);var u=A(l,2);{var d=g=>{_x(g,{get flag(){return h(s).flag}})},f=g=>{var y=Zpe(),w=I(y,!0);S(y),de(x=>me(w,x),[()=>n(h(s).type)]),$(g,y)};ne(u,g=>{h(s).flag?g(d):g(f,-1)})}var p=A(u,2);{var m=g=>{var y=Jpe(),w=I(y,!0);S(y),de(()=>me(w,h(s).scriptPath)),$(g,y)},v=g=>{var y=efe(),w=I(y,!0);S(y),de(()=>me(w,h(s).summary)),$(g,y)};ne(p,g=>{h(s).scriptPath?g(m):h(s).summary&&g(v,1)})}S(a),de(()=>{Yf(a,`padding-left:${h(s).depth*1}rem`),me(c,h(s).name)}),$(o,a)}),S(i),$(r,i)}var bO=require("obsidian");Ec();function u4(r,e){return r==="skip"?r:e&&r==="write"?"overwrite":!e&&r==="overwrite"?"write":r}function wO(r,e){return!e&&r==="overwrite"?"import":r}function d4(r,e,t){let n=e(r),i=r.exists||t(n);return{mode:i?"overwrite":"write",destinationPath:n,destinationExists:i}}function p4(r,e){let t=e(r);return{mode:t?"overwrite":"write",destinationPath:r,destinationExists:t}}function f4(r,e,t){let n=new Map;for(let i of r)n.set(i.originalPath,d4(i,e,t));return n}function m4(r,e,t,n){return r.get(e.originalPath)??d4(e,t,n)}function h4(r){let e=new Map;for(let t of r)e.set(t.choiceId,t.exists?"overwrite":"import");return e}function g4(r,e,t){let n=new Map(r);return n.set(e,t),n}function v4(r,e,t,n){let i=r.get(e)??p4(e,n),o=new Map(r);return o.set(e,{...i,mode:t}),o}function y4(r,e,t,n){let i=r.get(e)??p4(e,n),o=t.trim(),s=o||e,a=o||t,l=n(s),c=new Map(r);return c.set(e,{...i,mode:u4(i.mode,l),destinationPath:a,destinationExists:l}),{decisions:c,effectivePath:s}}function b4(r,e,t){let n=r.get(e);if(!n||n.destinationExists===t)return r;let i=new Map(r);return i.set(e,{...n,destinationExists:t,mode:u4(n.mode,t)}),i}function w4(r,e){return r.map(t=>({choiceId:t.choiceId,mode:wO(e.get(t.choiceId)??"import",t.exists)}))}function C4(r,e,t){return r.map(n=>{let i=e.get(n.originalPath),o=i?.destinationPath?.trim()||n.originalPath,s=i?.destinationExists??(n.exists||t(o)),a=i?.mode??(s?"overwrite":"write");return{originalPath:n.originalPath,destinationPath:o,mode:a}})}var wS=class{constructor(e){this.app=e;this.tokens=new Map}optimistic(e){let t=e.trim();return!t||Un(t)?!1:!!this.app.vault.getAbstractFileByPath((0,bO.normalizePath)(t))}async resolve(e){let t=e.trim();if(!t||Un(t))return!1;try{return await this.app.vault.adapter.exists((0,bO.normalizePath)(t))}catch{return!1}}schedule(e,t,n){let i=(this.tokens.get(e)??0)+1;this.tokens.set(e,i),this.resolve(t).then(o=>{this.tokens.get(e)===i&&n(o)})}};var ife=z('<div class="errorMessage svelte-1nd6fqb"> </div>'),ofe=z('<div class="info svelte-1nd6fqb">Analyzing package\u2026</div>'),sfe=z('<p class="svelte-1nd6fqb">No choices found in this package.</p>'),afe=z('<div class="choiceExists svelte-1nd6fqb">already in vault</div>'),lfe=z('<button type="button" class="macroToggle svelte-1nd6fqb"> </button>'),cfe=z('<option class="svelte-1nd6fqb">Overwrite</option>'),ufe=z('<tr class="macroRow svelte-1nd6fqb"><td colspan="3" class="svelte-1nd6fqb"><!></td></tr>'),dfe=z('<tr class="svelte-1nd6fqb"><td data-label="Name" class="svelte-1nd6fqb"><div class="choiceName svelte-1nd6fqb"> </div> <!> <!></td><td data-label="Location" class="svelte-1nd6fqb"> </td><td data-label="Action" class="svelte-1nd6fqb"><select class="dropdown svelte-1nd6fqb"><option class="svelte-1nd6fqb">Import</option><!><option class="svelte-1nd6fqb">Duplicate</option><option class="svelte-1nd6fqb">Skip</option></select></td></tr> <!>',1),pfe=z('<table class="svelte-1nd6fqb"><colgroup class="svelte-1nd6fqb"><col class="colName svelte-1nd6fqb"/><col class="colLocation svelte-1nd6fqb"/><col class="colAction svelte-1nd6fqb"/></colgroup><thead class="svelte-1nd6fqb"><tr class="svelte-1nd6fqb"><th class="svelte-1nd6fqb">Name</th><th class="svelte-1nd6fqb">Location</th><th class="svelte-1nd6fqb">Action</th></tr></thead><tbody class="svelte-1nd6fqb"></tbody></table>'),ffe=z('<p class="svelte-1nd6fqb">No files bundled with this package.</p>'),mfe=z('<h4 class="filesGroupHeading svelte-1nd6fqb"> </h4> <div class="fileRows svelte-1nd6fqb"></div>',1),hfe=z('<h4 class="filesGroupHeading overwrite svelte-1nd6fqb"> </h4> <div class="fileRows svelte-1nd6fqb"></div>',1),gfe=z("<!> <!>",1),vfe=z('<li><code class="svelte-1nd6fqb"> </code> <span class="warnLoc svelte-1nd6fqb"> </span></li>'),yfe=z('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Missing files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),bfe=z(`<li class="svelte-1nd6fqb"><code class="svelte-1nd6fqb"> </code>: bundled but not
|
||
used by any choice</li>`),wfe=z('<div class="warnItem svelte-1nd6fqb"><h4 class="svelte-1nd6fqb">Unreferenced files</h4> <ul class="svelte-1nd6fqb"></ul></div>'),Cfe=z('<section class="warningsBand svelte-1nd6fqb"><!> <!></section>'),xfe=z('<section class="filesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Files</h3> <!></section> <!>',1),Efe=z('<section class="summary svelte-1nd6fqb"><!> <span class="svelte-1nd6fqb"> </span></section>'),Tfe=z('<section class="packageMeta svelte-1nd6fqb"><span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Version</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"><span class="metaLabel svelte-1nd6fqb">Created</span> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span> <span class="metaSep svelte-1nd6fqb" aria-hidden="true">\xB7</span> <span class="svelte-1nd6fqb"> </span></section> <!> <section class="choicesSection svelte-1nd6fqb"><h3 class="svelte-1nd6fqb">Choices</h3> <!></section> <!> <!>',1),_fe=z('<p id="qa-import-ack-hint" class="ackGate-hint svelte-1nd6fqb"> </p>'),Afe=z('<section><label class="ackGate-label svelte-1nd6fqb"><input id="qa-import-ack-checkbox" type="checkbox" class="svelte-1nd6fqb"/> <span class="svelte-1nd6fqb"> </span></label> <!></section>'),kfe=z('<div class="importPackageModal svelte-1nd6fqb"><header class="svelte-1nd6fqb"><h2 class="svelte-1nd6fqb">Import QuickAdd package</h2> <p class="svelte-1nd6fqb">Review what this package adds and runs before importing.</p></header> <section class="pasteSection svelte-1nd6fqb"><label class="svelte-1nd6fqb"><span class="svelte-1nd6fqb">Paste package JSON</span> <textarea placeholder="Paste the contents of a .quickadd.json package here" rows="8" class="svelte-1nd6fqb"></textarea></label> <!></section> <!> <!> <section class="footer svelte-1nd6fqb"><button type="button" class="secondary svelte-1nd6fqb">Cancel</button> <button type="button" class="primary svelte-1nd6fqb"><!></button></section></div>'),Sfe={hash:"svelte-1nd6fqb",code:`.importPackageModal.svelte-1nd6fqb {display:flex;flex-direction:column;gap:1rem;width:min(720px, 100%);max-height:80vh;overflow-y:auto;
|
||
/* overflow-x:hidden (paired with overflow-y:auto) clips child focus rings
|
||
at the flush left/right edges; the inline padding gives the ring room. */overflow-x:hidden;box-sizing:border-box;padding:2px 4px;}.importPackageModal.svelte-1nd6fqb :where(.svelte-1nd6fqb) {box-sizing:border-box;}.importPackageModal.svelte-1nd6fqb > section:where(.svelte-1nd6fqb) {max-width:100%;}.pasteSection.svelte-1nd6fqb label:where(.svelte-1nd6fqb) {display:flex;flex-direction:column;gap:0.5rem;}.pasteSection.svelte-1nd6fqb textarea:where(.svelte-1nd6fqb) {width:100%;font-family:var(--font-monospace);resize:vertical;}.errorMessage.svelte-1nd6fqb {color:var(--text-error);}.info.svelte-1nd6fqb {color:var(--text-muted);}
|
||
|
||
/* A single compact line that sizes to content and wraps naturally, instead
|
||
of a 4-equal-column grid where the date wraps to 3 lines and the rest
|
||
leave dead space. */.packageMeta.svelte-1nd6fqb {display:flex;flex-wrap:wrap;align-items:baseline;gap:0.3rem 0.6rem;padding:0.55rem 0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);width:100%;font-size:var(--font-ui-small, 0.9rem);overflow-wrap:anywhere;}.metaLabel.svelte-1nd6fqb {color:var(--text-muted);}.metaSep.svelte-1nd6fqb {color:var(--text-faint);}.choicesSection.svelte-1nd6fqb,
|
||
.filesSection.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.75rem;}.filesGroupHeading.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-small, 0.9rem);font-weight:600;color:var(--text-muted);}.filesGroupHeading.overwrite.svelte-1nd6fqb {color:var(--text-error);}.fileRows.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.5rem;}.choiceName.svelte-1nd6fqb {font-weight:500;}
|
||
|
||
/* A plain inline text link, not a chrome button: neutralise Obsidian's
|
||
default button background/shadow on every state (!important to win over
|
||
the global button:hover / :focus rules that paint the grey box). */.macroToggle.svelte-1nd6fqb {display:inline-block;margin-top:0.35rem;padding:0;background:transparent !important;border:none;box-shadow:none !important;color:var(--text-accent);cursor:pointer;font-size:var(--font-ui-smaller, 0.8rem);border-radius:var(--radius-s, 4px);}.macroToggle.svelte-1nd6fqb:hover {color:var(--interactive-accent-hover, var(--text-accent));text-decoration:underline;}.macroToggle.svelte-1nd6fqb:focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {background:var(--background-primary-alt, var(--background-secondary));}.warningsBand.svelte-1nd6fqb {display:flex;flex-direction:column;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.6rem 0.75rem;gap:0.5rem;}.warnItem.svelte-1nd6fqb h4:where(.svelte-1nd6fqb) {margin:0;font-size:var(--font-ui-small, 0.9rem);}.warnItem.svelte-1nd6fqb ul:where(.svelte-1nd6fqb) {margin:0.25rem 0 0;padding-left:1rem;}.warnItem.svelte-1nd6fqb li:where(.svelte-1nd6fqb) {overflow-wrap:anywhere;}
|
||
|
||
/* A missing SCRIPT reference is an execution-hijack risk, not a broken
|
||
link: it runs from whatever exists at that path. Mark it as critical. */.warnItem.svelte-1nd6fqb li.script:where(.svelte-1nd6fqb) {padding:0.25rem 0.4rem;border-radius:var(--radius-s, 4px);background:var(--qa-sev-critical-wash);}.warnLoc.svelte-1nd6fqb {color:var(--text-muted);font-size:var(--font-ui-smaller, 0.8rem);}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb) {width:100%;border-collapse:collapse;table-layout:fixed;}.choicesSection.svelte-1nd6fqb col.colName:where(.svelte-1nd6fqb) {width:52%;}.choicesSection.svelte-1nd6fqb col.colLocation:where(.svelte-1nd6fqb) {width:26%;}.choicesSection.svelte-1nd6fqb col.colAction:where(.svelte-1nd6fqb) {width:22%;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb),
|
||
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.5rem;border-bottom:1px solid var(--background-modifier-border);text-align:left;word-break:break-word;overflow-wrap:anywhere;white-space:normal;vertical-align:top;}.choicesSection.svelte-1nd6fqb th:where(.svelte-1nd6fqb) {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);font-weight:600;}.choiceExists.svelte-1nd6fqb {font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);margin-top:0.1rem;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow):hover td:where(.svelte-1nd6fqb) {background:var(--background-modifier-hover);}.choicesSection.svelte-1nd6fqb select:where(.svelte-1nd6fqb) {max-width:100%;}
|
||
|
||
/* Narrow viewports (mobile): a 3-column table can't breathe, so each row
|
||
becomes a stacked card with the column name as an inline label. */
|
||
@media (max-width: 500px) {.choicesSection.svelte-1nd6fqb thead:where(.svelte-1nd6fqb) {display:none;}.choicesSection.svelte-1nd6fqb table:where(.svelte-1nd6fqb),
|
||
.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb),
|
||
.choicesSection.svelte-1nd6fqb tr:where(.svelte-1nd6fqb),
|
||
.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {display:block;width:100%;}.choicesSection.svelte-1nd6fqb tbody:where(.svelte-1nd6fqb) tr:where(.svelte-1nd6fqb):not(.macroRow) {border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);padding:0.5rem 0.6rem;margin-bottom:0.5rem;}.choicesSection.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {border-bottom:none;padding:0.15rem 0;}.choicesSection.svelte-1nd6fqb td[data-label="Location"]:where(.svelte-1nd6fqb)::before,
|
||
.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb)::before {content:attr(data-label) ": ";font-weight:600;color:var(--text-muted);}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) {display:flex;align-items:center;gap:0.4rem;margin-top:0.25rem;}.choicesSection.svelte-1nd6fqb td[data-label="Action"]:where(.svelte-1nd6fqb) select:where(.svelte-1nd6fqb) {flex:1;}.macroRow.svelte-1nd6fqb td:where(.svelte-1nd6fqb) {padding:0.25rem 0;}
|
||
}.summary.svelte-1nd6fqb {display:flex;align-items:center;gap:0.5rem;padding:0.55rem 0.7rem;border-radius:var(--radius-m, 8px);border:1px solid var(--qa-sev-success-border);background:var(--qa-sev-success-wash);color:var(--text-normal);}.summary.svelte-1nd6fqb .quickadd-icon {color:var(--text-success, var(--color-green, #0aa344));flex-shrink:0;}.ackGate.svelte-1nd6fqb {display:flex;flex-direction:column;gap:0.4rem;padding:0.75rem;border:1px solid var(--background-modifier-border);border-radius:var(--radius-m, 8px);background:var(--background-secondary);}.ackGate.critical.svelte-1nd6fqb {border-color:var(--qa-sev-critical-border);}.ackGate-label.svelte-1nd6fqb {display:flex;align-items:flex-start;gap:0.5rem;font-weight:600;cursor:pointer;}.ackGate-label.svelte-1nd6fqb:has(input:where(.svelte-1nd6fqb):disabled) {cursor:not-allowed;opacity:0.6;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb) {margin-top:0.2rem;flex-shrink:0;}.ackGate-label.svelte-1nd6fqb input:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}.ackGate-hint.svelte-1nd6fqb {margin:0;font-size:var(--font-ui-smaller, 0.8rem);color:var(--text-muted);}.footer.svelte-1nd6fqb {display:flex;justify-content:flex-end;gap:0.5rem;margin-top:0.5rem;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb) {background:var(--interactive-accent);color:var(--text-on-accent);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--interactive-accent-hover);}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
|
||
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:translateY(1px);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {background:transparent;}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):hover:not(:disabled) {background:var(--background-modifier-hover);}.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--interactive-accent);outline-offset:2px;}
|
||
|
||
/* Accent background needs a light outline to stay visible. */.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):focus-visible {outline:2px solid var(--text-on-accent);outline-offset:-4px;}.is-mobile .macroToggle.svelte-1nd6fqb {min-height:36px;padding:0.4rem 0.3rem;}
|
||
|
||
@media (prefers-reduced-motion: reduce) {.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb),
|
||
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb) {transition:none;}.footer.svelte-1nd6fqb .primary:where(.svelte-1nd6fqb):active:not(:disabled),
|
||
.footer.svelte-1nd6fqb .secondary:where(.svelte-1nd6fqb):active:not(:disabled) {transform:none;}
|
||
}`};function CO(r,e){we(e,!0),ot(r,Sfe);let t;function n(){return t??(t=new wS(e.app))}let i=Ae(null),o=Ae(null),s=Ae(null),a=Ae(!1),l=Ae(bt(new Set)),c=Ae(bt(new Set)),u=Ae(null),d=Ae(!1),f=Ae(null),p=Ae(bt(new Map)),m=Ae(bt(new Map)),v=Ae(""),g=Ae(!1),y=Ae(0),w=Ae(!1),x=O(()=>h(s)?t4(h(s)):!1),C=O(()=>h(s)?r4(h(s),h(l)):!0),_=O(()=>new Map((h(s)?.choices??[]).map(re=>[re.choiceId,re]))),E=O(()=>new Map((h(s)?.files??[]).map(re=>[re.originalPath,re]))),D=O(()=>!!(h(s)&&(h(s).summary.hasCritical||h(s).summary.hasWarning))),P=O(()=>!!(h(i)&&h(o))&&!h(g)&&(!h(x)||h(a)&&h(C))),V=O(()=>h(s)?.criticalScriptPaths.length??0),j=O(()=>h(s)?.missingReferences.some(re=>re.asScript)??!1),oe=O(()=>{let re=h(f);if(!re)return"";let Ie=[];re.added&&Ie.push(`${re.added} choice${re.added===1?"":"s"} added`),re.overwritten&&Ie.push(`${re.overwritten} overwritten`),re.assetsWritten&&Ie.push(`${re.assetsWritten} file${re.assetsWritten===1?"":"s"} written`);let dr=re.skipped+re.assetsSkipped;return dr&&Ie.push(`${dr} skipped`),Ie.length?`Imported: ${Ie.join(", ")}.`:"Nothing was imported."}),se=O(()=>h(V)>0?h(j)?"I have reviewed each bundled script above and trust the source, including scripts that are not included and cannot be shown.":"I have reviewed each script above and trust the source.":h(j)?"This package runs scripts that are not included and cannot be reviewed. I trust the source.":"I understand this package can run code, and I trust the source.");function M(re){if(h(l).has(re))return;let Ie=new Set(h(l));Ie.add(re),Z(l,Ie,!0)}function U(re){let Ie=new Set(h(c));Ie.has(re)?Ie.delete(re):Ie.add(re),Z(c,Ie,!0)}let q=re=>n().optimistic(re),B=O(()=>(h(o)?.assetConflicts??[]).map(re=>({conflict:re,state:m4(h(m),re,Y,q),file:h(E).get(re.originalPath)}))),ie=O(()=>h(B).filter(re=>!re.state.destinationExists)),W=O(()=>h(B).filter(re=>re.state.destinationExists));function Y(re){let[Ie]=Wi(ce.getState().templateFolderPaths),dr=re.kind==="template"||re.kind==="capture-template";if(Ie&&dr){let br=re.originalPath.split("/").pop()??re.originalPath;return`${Ie}/${br}`}return re.originalPath}function X(re,Ie){n().schedule(re,Ie,dr=>{Z(m,b4(h(m),re,dr),!0)})}function ae(){if(!h(o)){Z(p,new Map,!0),Z(m,new Map,!0);return}Z(p,h4(h(o).choiceConflicts),!0),Z(m,f4(h(o).assetConflicts,Y,q),!0);for(let re of h(o).assetConflicts){let Ie=h(m).get(re.originalPath);Ie&&X(re.originalPath,Ie.destinationPath)}}function pe(re,Ie){Z(p,g4(h(p),re,Ie),!0)}function ge(re,Ie){Z(m,v4(h(m),re,Ie,q),!0)}function be(re,Ie){let{decisions:dr,effectivePath:br}=y4(h(m),re.originalPath,Ie,q);Z(m,dr,!0),X(re.originalPath,br)}function xe(re,Ie){let br=Ie.currentTarget.value;pe(re,br)}function Ue(){Z(s,null),Z(a,!1),Z(l,new Set,!0),Z(c,new Set,!0)}async function $t(re){let Ie=re.trim(),dr=MI(y);if(Z(f,null),Z(w,!1),!Ie){Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue(),Z(u,null);return}Z(g,!0);try{let br=mO(Ie),Tn=ce.getState().choices,Ho=await i4(e.app,Tn,br),Ka=await vS(e.app,Tn,br);if(dr!==h(y))return;Z(i,{pkg:br,path:"[pasted]"},!0),Z(o,Ho,!0),Ue(),Z(s,Ka,!0),Z(u,null),ae()}catch(br){if(dr!==h(y))return;Z(u,br?.message??String(br),!0),Z(i,null),Z(o,null),Z(p,new Map,!0),Z(m,new Map,!0),Ue()}finally{dr===h(y)&&Z(g,!1)}}function Ne(re){let Ie=re.currentTarget.value;Z(v,Ie,!0),$t(Ie)}function Ke(re){return!re||re.length===0?"Root":re.slice(0,-1).join(" \u203A ")||"Root"}async function Qe(){if(h(w)){new Ax.Notice("This package has already been imported.");return}if(!h(i)||!h(o)){new Ax.Notice("Load a package before importing.");return}Z(d,!0),Z(f,null);try{let re=await o4({app:e.app,existingChoices:ce.getState().choices,aiProviders:ce.getState().ai.providers,pkg:h(i).pkg,choiceDecisions:w4(h(o).choiceConflicts,h(p)),assetDecisions:C4(h(o).assetConflicts,h(m),q)});ce.setState(Ie=>({...Ie,choices:re.updatedChoices})),Z(f,{added:re.addedChoiceIds.length,overwritten:re.overwrittenChoiceIds.length,skipped:re.skippedChoiceIds.length,assetsWritten:re.writtenAssets.length,assetsSkipped:re.skippedAssets.length},!0),Z(w,!0),new Ax.Notice(`Imported ${re.addedChoiceIds.length+re.overwrittenChoiceIds.length} choice${re.addedChoiceIds.length+re.overwrittenChoiceIds.length===1?"":"s"} successfully.`)}catch(re){console.error(re),new Ax.Notice(`Import failed: ${re?.message??re}`)}finally{Z(d,!1)}}var ye=kfe(),We=A(I(ye),2),mt=I(We),He=A(I(mt),2);Ad(He),S(mt);var _e=A(mt,2);{var Be=re=>{var Ie=ife(),dr=I(Ie,!0);S(Ie),de(()=>me(dr,h(u))),$(re,Ie)},ut=re=>{var Ie=ofe();$(re,Ie)};ne(_e,re=>{h(u)?re(Be):h(g)&&re(ut,1)})}S(We);var or=A(We,2);{var yr=re=>{var Ie=Tfe(),dr=Pe(Ie),br=I(dr),Tn=A(I(br));S(br);var Ho=A(br,4),Ka=A(I(Ho));S(Ho);var Xa=A(Ho,4),Jc=I(Xa);S(Xa);var T=A(Xa,4),k=I(T);S(T),S(dr);var N=A(dr,2);{var K=yt=>{vO(yt,{get preview(){return h(s)}})};ne(N,yt=>{h(D)&&h(s)&&yt(K)})}var J=A(N,2),ue=A(I(J),2);{var ve=yt=>{var pr=sfe();$(yt,pr)},Ve=yt=>{var pr=pfe(),kr=A(I(pr),2);ar(kr,21,()=>h(o).choiceConflicts,Gn=>Gn.choiceId,(Gn,kt)=>{let Eo=O(()=>wO(h(p).get(h(kt).choiceId)??"import",h(kt).exists)),ua=O(()=>h(_).get(h(kt).choiceId)),Es=O(()=>(h(ua)?.commands?.length??0)>0);var ln=dfe(),_n=Pe(ln),jl=I(_n),bd=I(jl),ev=I(bd,!0);S(bd);var xf=A(bd,2);{var pi=kn=>{var no=afe();$(kn,no)};ne(xf,kn=>{h(kt).exists&&kn(pi)})}var Ji=A(xf,2);{var eo=kn=>{var no=lfe(),xE=I(no,!0);S(no),de((tI,rI)=>{ke(no,"aria-expanded",tI),me(xE,rI)},[()=>h(c).has(h(kt).choiceId),()=>h(c).has(h(kt).choiceId)?"Hide macro":"Show macro"]),De("click",no,()=>U(h(kt).choiceId)),$(kn,no)};ne(Ji,kn=>{h(Es)&&kn(eo)})}S(jl);var to=A(jl),To=I(to,!0);S(to);var An=A(to),Gt=I(An),ro=I(Gt);ro.value=ro.__value="import";var eu=A(ro);{var tu=kn=>{var no=cfe();no.value=no.__value="overwrite",$(kn,no)};ne(eu,kn=>{h(kt).exists&&kn(tu)})}var _o=A(eu);_o.value=_o.__value="duplicate";var ru=A(_o);ru.value=ru.__value="skip",S(Gt);var Qa;Vd(Gt),S(An),S(_n);var T7=A(_n,2);{var _7=kn=>{var no=ufe(),xE=I(no),tI=I(xE);{let rI=O(()=>h(ua)?.commands??[]);yO(tI,{get commands(){return h(rI)}})}S(xE),S(no),$(kn,no)},A7=O(()=>h(Es)&&h(c).has(h(kt).choiceId));ne(T7,kn=>{h(A7)&&kn(_7)})}de(kn=>{me(ev,h(kt).name),me(To,kn),Qa!==(Qa=h(Eo))&&(Gt.value=(Gt.__value=h(Eo))??"",fu(Gt,h(Eo)))},[()=>Ke(h(kt).pathHint)]),De("change",Gt,kn=>xe(h(kt).choiceId,kn)),$(Gn,ln)}),S(kr),S(pr),$(yt,pr)};ne(ue,yt=>{h(o).choiceConflicts.length===0?yt(ve):yt(Ve,-1)})}S(J);var vt=A(J,2);{var Pr=yt=>{var pr=xfe(),kr=Pe(pr),Gn=A(I(kr),2);{var kt=ln=>{var _n=ffe();$(ln,_n)},Eo=ln=>{var _n=gfe(),jl=Pe(_n);{var bd=pi=>{var Ji=mfe(),eo=Pe(Ji),to=I(eo);S(eo);var To=A(eo,2);ar(To,21,()=>h(ie),An=>An.conflict.originalPath,(An,Gt)=>{var ro=un(),eu=Pe(ro);{var tu=_o=>{{let ru=O(()=>h(l).has(h(Gt).file.originalPath));bS(_o,{get file(){return h(Gt).file},get pkg(){return h(i).pkg},get mode(){return h(Gt).state.mode},get destinationPath(){return h(Gt).state.destinationPath},get destinationExists(){return h(Gt).state.destinationExists},onPathInput:Qa=>be(h(Gt).conflict,Qa),onModeChange:Qa=>ge(h(Gt).conflict.originalPath,Qa),get reviewed(){return h(ru)},onReviewed:M})}};ne(eu,_o=>{h(Gt).file&&_o(tu)})}$(An,ro)}),S(To),de(()=>me(to,`Added (${h(ie).length??""})`)),$(pi,Ji)};ne(jl,pi=>{h(ie).length>0&&pi(bd)})}var ev=A(jl,2);{var xf=pi=>{var Ji=hfe(),eo=Pe(Ji),to=I(eo);S(eo);var To=A(eo,2);ar(To,21,()=>h(W),An=>An.conflict.originalPath,(An,Gt)=>{var ro=un(),eu=Pe(ro);{var tu=_o=>{{let ru=O(()=>h(l).has(h(Gt).file.originalPath));bS(_o,{get file(){return h(Gt).file},get pkg(){return h(i).pkg},get mode(){return h(Gt).state.mode},get destinationPath(){return h(Gt).state.destinationPath},get destinationExists(){return h(Gt).state.destinationExists},onPathInput:Qa=>be(h(Gt).conflict,Qa),onModeChange:Qa=>ge(h(Gt).conflict.originalPath,Qa),get reviewed(){return h(ru)},onReviewed:M})}};ne(eu,_o=>{h(Gt).file&&_o(tu)})}$(An,ro)}),S(To),de(()=>me(to,`Will overwrite (${h(W).length??""})`)),$(pi,Ji)};ne(ev,pi=>{h(W).length>0&&pi(xf)})}$(ln,_n)};ne(Gn,ln=>{h(B).length===0?ln(kt):ln(Eo,-1)})}S(kr);var ua=A(kr,2);{var Es=ln=>{var _n=Cfe(),jl=I(_n);{var bd=pi=>{var Ji=yfe(),eo=A(I(Ji),2);ar(eo,21,()=>h(s).missingReferences,to=>to.path,(to,To)=>{var An=vfe();let Gt;var ro=I(An),eu=I(ro,!0);S(ro);var tu=A(ro),_o=A(tu),ru=I(_o,!0);S(_o),S(An),de(()=>{Gt=wt(An,1,"svelte-1nd6fqb",null,Gt,{script:h(To).asScript}),me(eu,h(To).path),me(tu,`:
|
||
${h(To).asScript?"not bundled, so it runs from whatever file exists at that path after import":"not bundled and not in your vault"} `),me(ru,h(To).breadcrumb)}),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(jl,pi=>{h(s).missingReferences.length>0&&pi(bd)})}var ev=A(jl,2);{var xf=pi=>{var Ji=wfe(),eo=A(I(Ji),2);ar(eo,20,()=>h(s).orphanAssets,to=>to,(to,To)=>{var An=bfe(),Gt=I(An),ro=I(Gt,!0);S(Gt),In(),S(An),de(()=>me(ro,To)),$(to,An)}),S(eo),S(Ji),$(pi,Ji)};ne(ev,pi=>{h(s).orphanAssets.length>0&&pi(xf)})}S(_n),$(ln,_n)};ne(ua,ln=>{h(s)&&(h(s).missingReferences.length>0||h(s).orphanAssets.length>0)&&ln(Es)})}$(yt,pr)};ne(vt,yt=>{h(i)&&yt(Pr)})}var jt=A(vt,2);{var $i=yt=>{var pr=Efe(),kr=I(pr);Rt(kr,{iconId:"check-circle",size:16});var Gn=A(kr,2),kt=I(Gn,!0);S(Gn),S(pr),de(()=>me(kt,h(oe))),$(yt,pr)};ne(jt,yt=>{h(f)&&yt($i)})}de(yt=>{me(Tn,` ${h(i).pkg.quickAddVersion??""}`),me(Ka,` ${yt??""}`),me(Jc,`${h(o).choiceConflicts.length??""} choice${h(o).choiceConflicts.length===1?"":"s"}`),me(k,`${h(i).pkg.assets.length??""} file${h(i).pkg.assets.length===1?"":"s"}`)},[()=>new Date(h(i).pkg.createdAt).toLocaleDateString()]),$(re,Ie)};ne(or,re=>{h(i)&&h(o)&&re(yr)})}var Pt=A(or,2);{var Ar=re=>{var Ie=Afe();let dr;var br=I(Ie),Tn=I(br);gr(Tn);var Ho=A(Tn,2),Ka=I(Ho,!0);S(Ho),S(br);var Xa=A(br,2);{var Jc=T=>{var k=_fe(),N=I(k);S(k),de(()=>me(N,`Open \u201CView contents\u201D on each of the ${h(V)??""} executable
|
||
script${h(V)===1?"":"s"} above to enable this.`)),$(T,k)};ne(Xa,T=>{h(V)>0&&!h(C)&&T(Jc)})}S(Ie),de(()=>{dr=wt(Ie,1,"ackGate svelte-1nd6fqb",null,dr,{critical:h(s)?.summary.hasCritical}),qd(Tn,h(a)),Tn.disabled=!h(C),ke(Tn,"aria-describedby",h(V)>0&&!h(C)?"qa-import-ack-hint":void 0),me(Ka,h(se))}),De("change",Tn,T=>Z(a,T.currentTarget.checked,!0)),$(re,Ie)};ne(Pt,re=>{h(i)&&h(x)&&!h(w)&&re(Ar)})}var ur=A(Pt,2),dt=I(ur),Ft=A(dt,2),Hn=I(Ft);{var xo=re=>{var Ie=cl("Importing\u2026");$(re,Ie)},xs=re=>{var Ie=cl("Close");$(re,Ie)},jn=re=>{var Ie=cl("Import package");$(re,Ie)};ne(Hn,re=>{h(d)?re(xo):h(w)?re(xs,1):re(jn,-1)})}S(Ft),S(ur),S(ye),de(()=>{dt.disabled=h(d),Ft.disabled=h(d)||!h(w)&&!h(P),ke(Ft,"title",!h(w)&&h(x)&&h(C)&&!h(a)?"Confirm the acknowledgement above to continue":void 0)}),De("input",He,Ne),co(He,()=>h(v),re=>Z(v,re)),De("click",dt,function(...re){e.close?.apply(this,re)}),De("click",Ft,function(...re){(h(w)?e.close:Qe)?.apply(this,re)}),$(r,ye),Ce()}Et(["input","click","change"]);var CS=class extends x4.Modal{constructor(t){super(t);this.handle=null}onOpen(){this.modalEl.addClass("quickAddModal","packageImportModal"),this.handle=qi(this.contentEl,CO,{app:this.app,close:()=>this.close()},{what:"the package importer"})}onClose(){this.handle?.destroy(),this.handle=null}};Tm();Wd();fc();function xO(r,e,t,n){let i=zr(r,"div"),o=zr(r,"strong");return o.textContent=e,i.appendChild(o),i.appendChild(jv(r,` ${t}`)),n?.className&&i.classList.add(n.className),i.classList.add("qa-dev-info-row"),r.appendChild(i),i}function E4(r,e){if(e.branch!==null&&xO(r,"Branch:",e.branch),e.commit!==null&&xO(r,"Commit:",e.commit),e.dirty!==null){let t=e.dirty?"Yes (uncommitted changes)":"No",n=e.dirty?"qa-dev-dirty-status":"qa-dev-clean-status";xO(r,"Uncommitted changes:",t,{className:n})}}Wt();var EO="Bundle or import QuickAdd automations as reusable packages.",xS=class extends od.PluginSettingTab{constructor(t,n){super(t,n);this.choiceViewHandle=null;this.globalVariablesViewHandle=null;this.packagesUnsubscribe=null;this.plugin=n,this.icon="zap"}getControlValue(t){let n=ce.getState();return t==="inputPrompt"?n.inputPrompt==="multi-line":n[t]}setControlValue(t,n){if(t==="inputPrompt"){ce.setState({inputPrompt:n?"multi-line":"single-line"});return}if(t==="persistInputPromptDrafts"){let i=!!n;ce.setState({persistInputPromptDrafts:i}),i||Gi.getInstance().clearAll();return}ce.setState({[t]:n})}getSettingDefinitions(){return[this.choicesAndPackagesGroup(),this.choicePickerGroup(),this.inputGroup(),this.templatesGroup(),this.notificationsGroup(),this.globalVariablesGroup(),this.aiAndOnlineGroup(),this.appearanceGroup()]}hide(){super.hide(),this.destroySettingViews()}destroySettingViews(){this.choiceViewHandle?.destroy(),this.choiceViewHandle=null,this.globalVariablesViewHandle?.destroy(),this.globalVariablesViewHandle=null,this.packagesUnsubscribe?.(),this.packagesUnsubscribe=null}choicesAndPackagesGroup(){return{type:"group",heading:"Choices & packages",extraButtons:[t=>t.setIcon("help-circle").setTooltip("QuickAdd documentation").onClick(()=>hj(Al.gettingStarted,t.extraSettingsEl))],items:[{name:"Choices",render:t=>this.renderChoicesView(t)},{name:"Packages",desc:EO,render:t=>this.renderPackages(t)}]}}choicePickerGroup(){return{type:"group",heading:"Choice picker",items:[{name:"Search nested choices",desc:"When searching in the choice picker, also match choices nested inside folders and show their path. Note that nested matches can outrank same-level ones. Disable to search only the open level.",control:{type:"toggle",key:"searchNestedChoices"}},{name:"\u201CNew note from template\u201D in the launcher",desc:"Add a row to Run QuickAdd that lists templates from your configured template folder, so you can create a note from a template without a dedicated Template choice. Only appears when a template folder is configured; the command palette entry works regardless.",control:{type:"dropdown",key:"templateFolderLauncherRow",defaultValue:"bottom",options:{bottom:"Show at the bottom (keeps your top choice first)",top:"Show at the top",off:"Hide"}}}]}}inputGroup(){return{type:"group",heading:"Input",items:[{name:"Use multi-line input prompt",desc:"Use multi-line input prompt instead of single-line input prompt. Submit multi-line prompts with Ctrl/Cmd+Enter; Enter inserts a newline.",control:{type:"toggle",key:"inputPrompt"}},{name:"Persist input prompt drafts",desc:"Keep drafts when closing input prompts so they can be restored on reopen. Drafts are stored only for this session.",control:{type:"toggle",key:"persistInputPromptDrafts"}},{name:"Use editor selection as default Capture value",desc:"When enabled, Capture uses the current editor selection as {{VALUE}} and may skip the prompt. When disabled, Capture always prompts for {{VALUE}}.",control:{type:"toggle",key:"useSelectionAsCaptureValue"}},{name:"One-page input for choices",desc:this.descWithDocsLink("Collect a choice's inputs in one form before it runs, instead of one prompt at a time. Works with Template and Capture choices, and with Macros whose scripts declare inputs. Template and Capture choices can override this individually. ",Al.onePageInputs,"Learn more about one-page inputs"),control:{type:"toggle",key:"onePageInputEnabled"}},{name:"Date aliases",desc:"Shortcodes for natural language date parsing. One per line: alias = phrase. Example: tm = tomorrow.",render:t=>this.renderDateAliases(t)}]}}templatesGroup(){return{type:"group",heading:"Templates & properties",items:[{name:"Template folder paths",desc:"Folders where templates are stored. Used to suggest template files when configuring QuickAdd. Add as many as you like; leave empty to suggest every template file in the vault.",render:t=>this.renderTemplateFolderPaths(t)},{name:"Convert string front matter variables to typed properties (Beta)",desc:'List/object values from scripts are always written as proper Obsidian properties (a list becomes a List). This toggle additionally converts string values into typed properties: a comma or bullet-list string becomes a List, "42" becomes a Number, "true" becomes a Checkbox, etc. Disabled by default; the string conversion is a beta heuristic that may have edge cases.',control:{type:"toggle",key:"enableTemplatePropertyTypes"}}]}}notificationsGroup(){return{type:"group",heading:"Notifications",items:[{name:"Announce updates",desc:"Display release notes when a new version is installed. This includes new features, demo videos, and bug fixes.",control:{type:"dropdown",key:"announceUpdates",defaultValue:"major",options:{all:"Show updates on each new release",major:"Show updates only on major releases (new features, breaking changes)",none:"Don't show"}}},{name:"Show capture notifications",desc:"Display a notification when content is captured successfully to confirm the operation completed.",control:{type:"toggle",key:"showCaptureNotification"}},{name:"Show input cancellation notifications",desc:"Display a notification when an input prompt is cancelled without submitting. Disable this to avoid extra notices when dismissing prompts.",control:{type:"toggle",key:"showInputCancellationNotification"}}]}}globalVariablesGroup(){return{type:"group",heading:"Global variables",items:[{name:"Global variables",render:t=>this.renderGlobalVariablesView(t)}]}}aiAndOnlineGroup(){return{type:"group",heading:"AI & online",items:[{name:"Disable AI & online features",desc:"This prevents the plugin from making requests to external providers like OpenAI. You can still use user scripts to execute arbitrary code, including contacting external providers. However, this setting disables plugin features like the AI Assistant from doing so. You need to disable this setting to use the AI Assistant.",control:{type:"toggle",key:"disableOnlineFeatures"}},{name:"Allow URI x-callback-url",desc:"When on, an obsidian://quickadd URI may open a callback URL (x-success / x-error / x-cancel) after a Template or Capture choice finishes \u2014 sending the outcome and the affected note's vault path and URL to that callback. While on, a URI that carries x-* callback params is restricted to Template and Capture choices (other choice types are warned and skipped). Off by default because the callback URL is set by whoever creates the obsidian:// link. Only shortcuts: and obsidian: callback URLs are permitted.",control:{type:"toggle",key:"enableUriCallbacks"}}]}}appearanceGroup(){return{type:"group",heading:"Appearance",items:[{name:"Show icon in sidebar",desc:"Add QuickAdd icon to the sidebar ribbon. Requires a reload.",control:{type:"toggle",key:"enableRibbonIcon"}}]}}developerGroup(){return{type:"group",heading:"Developer",items:[{name:"Development information",desc:"Git information for developers.",render:t=>this.renderDevInfo(t)}]}}descWithDocsLink(t,n,i="Learn more"){let o=document.createDocumentFragment();return o.append(document.createTextNode(t)),PA(o,n,i),o}prepareFullWidthSetting(t){t.infoEl.remove(),t.settingEl.addClass("qa-setting-full-width"),t.controlEl.addClass("qa-setting-full-width-control")}renderChoicesView(t){this.prepareFullWidthSetting(t),this.choiceViewHandle?.destroy();let n=qi(t.controlEl,Q$,{app:this.app,plugin:this.plugin,choices:ce.getState().choices,saveChoices:i=>{ce.setState({choices:i})}},{what:"your choices",fallbackComponent:ig});return this.choiceViewHandle=n,()=>{n.destroy(),this.choiceViewHandle===n&&(this.choiceViewHandle=null)}}renderGlobalVariablesView(t){this.prepareFullWidthSetting(t),this.globalVariablesViewHandle?.destroy();let n=qi(t.controlEl,Z$,{app:this.app,plugin:this.plugin},{what:"your global variables"});return this.globalVariablesViewHandle=n,()=>{n.destroy(),this.globalVariablesViewHandle===n&&(this.globalVariablesViewHandle=null)}}packagesDesc(t){return this.descWithDocsLink(t?`${EO} Export becomes available once you have a choice. `:`${EO} `,Al.packages,"Learn more about packages")}renderPackages(t){let n;t.addButton(a=>{n=a,a.setButtonText("Export package\u2026").onClick(()=>{let l=hn(ce.getState().choices);new cS(this.app,this.plugin,l).open()})}),t.addButton(a=>a.setButtonText("Import package\u2026").onClick(()=>{new CS(this.app).open()}));let i=a=>{t.setDesc(this.packagesDesc(a)),n&&(n.setDisabled(a),a?n.setTooltip("Nothing to export yet"):n.buttonEl.removeAttribute("aria-label"))},o=hn(ce.getState().choices).length===0;i(o),this.packagesUnsubscribe?.();let s=ce.subscribe(a=>{let l=hn(a.choices).length===0;l!==o&&(o=l,i(l))});return this.packagesUnsubscribe=s,()=>{s(),this.packagesUnsubscribe===s&&(this.packagesUnsubscribe=null)}}renderDateAliases(t){t.settingEl.addClass("qa-date-alias-setting"),t.controlEl.addClass("qa-date-alias-control");let n=null;t.addTextArea(i=>{n=i,i.setPlaceholder(`t = today
|
||
tm = tomorrow
|
||
yd = yesterday`).setValue(s0(ce.getState().dateAliases)).onChange(o=>{ce.setState({dateAliases:O2(o)})}),i.inputEl.addClass("qa-date-alias-input")}),t.addButton(i=>{i.setButtonText("Reset to defaults").onClick(()=>{ce.setState({dateAliases:Kf}),n?.setValue(s0(Kf))}),i.buttonEl.addClass("qa-date-alias-reset")})}renderTemplateFolderPaths(t){t.settingEl.addClass("qa-template-folders-setting");let n=t.controlEl.createDiv("qa-template-folders"),i=n.createDiv("qa-template-folder-list"),o=()=>Wi(ce.getState().templateFolderPaths),s=p=>{ce.setState({templateFolderPaths:p})},a=()=>{i.empty();let p=o();if(p.length===0){i.createDiv({cls:"qa-template-folder-empty",text:"No folders added yet."});return}for(let m of p){let v=i.createDiv("qa-template-folder-row");v.createSpan({cls:"qa-template-folder-name",text:m,attr:{title:m}}),new od.ExtraButtonComponent(v).setIcon("trash-2").setTooltip(`Remove ${m}`).onClick(()=>{s(o().filter(g=>g!==m)),a()})}},l=n.createDiv("qa-template-folder-input-row"),c=new od.TextComponent(l);c.setPlaceholder("templates/"),c.inputEl.addClass("qa-template-folder-input");let u=new ni(this.app,c.inputEl,Nc(Ns(this.app)).filter(p=>p!=="/")),d=()=>{let[p]=Wi([c.inputEl.value]);if(c.inputEl.value="",!p)return;let m=o();m.includes(p)||(s([...m,p]),a())},f=p=>{p.key==="Enter"&&(p.preventDefault(),d())};return c.inputEl.addEventListener("keydown",f),new od.ButtonComponent(l).setCta().setButtonText("Add").onClick(()=>d()),a(),()=>{c.inputEl.removeEventListener("keydown",f),u.destroy()}}renderDevInfo(t){let n=t.settingEl.createDiv();n.addClass("qa-dev-info"),E4(n,{branch:null,commit:null,dirty:null})}};a0();Me();CT();var cg=class{formatOutputString(e){return`QuickAdd: (${e.level}) ${e.message}`}getQuickAddError(e,t,n,i){return{message:e,level:t,time:Date.now(),stack:n,originalError:i}}};Cr();var kx=class extends cg{constructor(){super(...arguments);this.ErrorLog=[]}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.error(this.formatOutputString(o),s)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);this.addMessageToErrorLog(o);let s=i||new Error(t);console.warn(this.formatOutputString(o),s)}logMessage(t,n,i){let o=this.getQuickAddError(t,"LOG",n,i);this.addMessageToErrorLog(o),i?console.log(this.formatOutputString(o),i):console.log(this.formatOutputString(o))}addMessageToErrorLog(t){this.ErrorLog.push(t),this.ErrorLog.length>v0&&(this.ErrorLog=this.ErrorLog.slice(-v0))}clearErrorLog(){this.ErrorLog=[]}};var TO=require("obsidian");CT();var ES=class extends cg{constructor(t){super();this.plugin=t}logError(t,n,i){let o=this.getQuickAddError(t,"ERROR",n,i);new TO.Notice(this.formatOutputString(o),15e3)}logWarning(t,n,i){let o=this.getQuickAddError(t,"WARNING",n,i);new TO.Notice(this.formatOutputString(o))}logMessage(t,n,i){}};Me();Cr();Cr();var T4=1e4,_4=50,Dfe=/plugin:([^\s:)]+)/;function Ife(r){let e=r.stack??"",t=`${r.name}: ${r.message}`;return(e.startsWith(t)?e.slice(t.length):e).split(`
|
||
`)}function Pfe(r){for(let e of Ife(r)){let t=Dfe.exec(e);if(t)return{pluginId:t[1],frame:e.trim()}}return null}function Ffe(r,e){return`${r.name}@${e}`}function A4(r,e=Date.now){let t=r.manifest.id,n=new Map;r.registerDomEvent(window,"unhandledrejection",i=>{let o=i.reason,s=o instanceof Error?Pfe(o):null;if(s?.pluginId!==t)return;if(Dt(o)){i.preventDefault();return}let a=o,l=Ffe(a,s.frame),c=e(),u=n.get(l);if(n.set(l,c),!(u!==void 0&&c-u<T4)){if(n.size>=_4){for(let[d,f]of n)c-f>=T4&&n.delete(d);if(n.size>=_4){let d=n.keys().next();!d.done&&d.value!==l&&n.delete(d.value)}}lt(a,"A QuickAdd action failed")&&i.preventDefault()}})}var k4=require("obsidian");Me();function Mfe(r,e){try{let t=r.setting;return!t?.open||!t?.openTabById?(F.logMessage("QuickAdd: Obsidian internal settings API is unavailable."),!1):(t.open(),t.openTabById(e),!0)}catch(t){return F.logMessage(`QuickAdd: Failed to open plugin settings automatically: ${t}`),!1}}function ug(r,e,t){let n=Mfe(r,e);return!n&&t?.notice!==!1&&new k4.Notice("QuickAdd: Unable to open settings automatically. Open Settings \u2192 QuickAdd manually."),n}Zx();Wt();Cr();var DD=class{constructor(e,t,n,i){this.app=e;this.plugin=t;this.choices=n;this.choiceExecutor=i}async run(){let e=Bn(this.choices).filter(t=>t.type==="Macro"&&t.runOnStartup);for(let t of e)try{await new ql(this.app,this.plugin,t,this.choiceExecutor,new Map).run()}catch(n){lt(n,`Startup macro '${t.name}' failed`)}}};var HK=require("obsidian");var Yg=require("obsidian");Sx();Tt();Wc();Me();var cK=require("obsidian");nd();$g();Og();Co();var lK=require("obsidian");Hs();Fo();function dE(r,e,t){let n=e.lastIndexOf("/"),i=n>=0?e.slice(0,n):"",o=sy(n>=0?e.slice(n+1):e),s=t?.vault.getAbstractFileByPath(e),a=t&&s instanceof lK.TFile?OP([s],d=>t.metadataCache.getFileCache(d))[0]:null,l=a?.primary??o,c=a?.secondary??i;r.addClass("mod-complex");let u=r.createDiv({cls:"suggestion-content"});u.createDiv({cls:"suggestion-title",text:l}),c&&u.createDiv({cls:"suggestion-note",text:c})}function hf(r,e={}){let{openedAtOf:t,recentRankOf:n,isExcluded:i}=e;return r.map(o=>({file:o,name:o.basename||o.path,excluded:i?.(o.path)??!1,openedAt:t?.(o.path),recentRank:n?.(o.path)})).sort((o,s)=>{if(o.excluded!==s.excluded)return o.excluded?1:-1;let a=o.openedAt!=null,l=s.openedAt!=null;if(a!==l)return a?-1:1;if(a&&l&&o.openedAt!==s.openedAt)return s.openedAt-o.openedAt;let c=o.recentRank??Number.POSITIVE_INFINITY,u=s.recentRank??Number.POSITIVE_INFINITY;return c!==u?c-u:o.name.localeCompare(s.name)}).map(o=>o.file)}AP();function gf(r){let e=r.workspace?.getLastOpenFiles?.(),t=Array.isArray(e)?e:[],n=new Map;t.forEach((s,a)=>{n.has(s)||n.set(s,a)});let i;try{i=Cm.getInstanceIfExists()}catch{i=void 0}let o=r.metadataCache;return{openedAtOf:s=>i?.getLastOpenedAt(s),recentRankOf:s=>n.get(s),isExcluded:s=>o?.isUserIgnored?.(s)??!1}}Cr();Wr();Tl();Ec();var aN="@quickadd-existing-note:",lN="@quickadd-unresolved-note:";function Rve(r){return`${aN}${r}`}function $ve(r){return`${lN}${r}`}function Ove(r){return r.startsWith(aN)}function Nve(r){return r.startsWith(lN)}function Lve(r){return r.slice(aN.length)}function Bve(r){return r.slice(lN.length)}function vf(r){return r.trim().replace(/\.md$/i,"").toLowerCase()}function uK(r){return r.trim().replace(/^\/+/,"")}function Uve(r){return r.trim().length>0&&!r.includes("{{")}function Vve(r){if(!Uve(r.templatePath))return new Set;let e=uK(r.templatePath),t=/\.md$/i.test(e)?e:`${e}.md`;return new Set([t.toLowerCase()])}function qve(r,e,t){let n=e.replace(/\.md$/i,"");r.add(vf(e)),r.add(vf(n)),r.add(vf(t))}function Wve(r,e){let t=r.metadataCache.getFileCache(e)?.frontmatter;if(!t)return[];let n=[];for(let[i,o]of Object.entries(t)){let s=i.toLowerCase();s!=="alias"&&s!=="aliases"||(typeof o=="string"?n.push(...o.split(",").map(a=>a.trim()).filter(Boolean)):Array.isArray(o)&&n.push(...o.filter(a=>typeof a=="string").map(a=>a.trim()).filter(Boolean)))}return n}function zve(r){let n=((r.split("|")[0]?.trim()??"").split("#")[0]?.trim()??"").replace(/\.md$/i,"").trim();return!n||n==="/"||Un(n)?null:n}function Hve(r){let e=r.metadataCache.unresolvedLinks??{},t=new Map;for(let n of Object.values(e))for(let i of Object.keys(n)){let o=zve(i);if(!o)continue;let s=vf(o);t.has(s)||t.set(s,o)}return[...t.values()].sort((n,i)=>n.localeCompare(i))}function jve(r,e){let t=new Set,n=Vve(e),i=hf(r.vault.getMarkdownFiles(),gf(r)),o=[];for(let s of i){if(n.has(uK(s.path).toLowerCase()))continue;qve(t,s.path,s.basename);let a=Wve(r,s),l=[s.basename,s.path,...a].join(" ");o.push({item:Rve(s.path),display:l,title:a[0]?`${s.basename} (${s.path})`:s.path,renderPath:s.path,renderAlias:a[0]})}for(let s of Hve(r)){let a=vf(s);t.has(a)||o.push({item:$ve(s),display:s,title:`${s} (unresolved link)`,unresolvedTitle:s})}return{candidates:o,existingKeys:t}}function Gve(r,e){r.addClass("mod-complex");let t=r.createDiv({cls:"suggestion-content"});t.createDiv({cls:"suggestion-title",text:e}),t.createDiv({cls:"suggestion-note",text:"Unresolved link"})}function Yve(r,e,t){if(dE(r,e),!t)return;r.querySelector(".suggestion-content")?.createDiv({cls:"suggestion-note",text:`Alias: ${t}`})}async function dK(r,e,t){let{candidates:n,existingKeys:i}=jve(r,e),o=new Map(n.map(a=>[a.item,a])),s=`Search notes or create ${e.name}`;try{let a=String(await ia(t,{remote:c=>oa(c,{items:n.map(u=>({value:u.item,title:u.title})),placeholder:s,allowCustomInput:!0,what:"the note-discovery picker"}),headless:()=>{throw new Ee(`'${e.name}' needs to ask which note to open or create, but this run is non-interactive. Pass the note name (e.g. value-value=<name>), or re-run with the ui flag.`)},app:()=>an.Suggest(r,n.map(c=>c.display),n.map(c=>c.item),{placeholder:s,allowCustomValue:!0,customValueLabel:c=>`Create new note: ${c}`,valueExists:c=>{let u=vf(c);return i.has(u)||n.some(d=>d.unresolvedTitle&&vf(d.unresolvedTitle)===u)},renderItem:(c,u)=>{let d=o.get(c);if(d){if(d.renderPath){Yve(u,d.renderPath,d.renderAlias);return}d.unresolvedTitle&&Gve(u,d.unresolvedTitle)}}})}));if(Ove(a)){let c=r.vault.getAbstractFileByPath(Lve(a));if(c instanceof cK.TFile)return{kind:"openExisting",file:c};throw new Error("Selected note no longer exists. Please run QuickAdd again.")}if(Nve(a)){let c=ai(Bve(a),"Note title");return{kind:"create",title:c,...c.includes("/")?{vaultRelativePath:c}:{}}}let l=ai(a,"Note title");return{kind:"create",title:l,...l.includes("/")?{vaultRelativePath:l}:{}}}catch(a){throw Dt(a)?new St("Input cancelled by user"):a}}$g();Og();Jd();qt();Cr();var Gg=class{constructor(e){this.executor=e;this.closed=!1}success(e,t){this.closed=!0,this.executor.recordExecutionResult?.({status:"success",file:e,effect:t})}failure(e){this.closed||this.executor.recordExecutionResult?.({status:"error",reason:e})}};function ID(r){return r instanceof Error?r.message||pK:String(r)||pK}var pK="Choice execution failed.";Tl();Hv();nm();Tm();uD();AD();Os();Co();Qx();Rg();var PD=class extends hd{constructor(t,n,i,o,s=null){super(t,n,o);this.originLeaf=s;this.choiceExecutor=o,this.outcome=new Gg(o),this.choice=i,this.formatter.setPromptRunContext({draftScopeId:i.id,choiceName:i.name})}async run(){let t=null,n=null;try{Mi(this.choice.templatePath,()=>`Invalid template path for ${this.choice.name}. ${this.choice.templatePath.length===0?"Template path is empty.":`Template path is not valid: ${this.choice.templatePath}`}`);let i=xu(this.choice.appendLink);if(this.setLinkToCurrentFileBehavior(i.enabled&&!i.requireActiveFile?"optional":"required"),!this.validateAppendLinkDestination(i))return;let o=this.choice.fileNameFormat.enabled?this.choice.fileNameFormat.format:Ms;if(UR(this.choice,o,this.choiceExecutor.variables.get("value"))){let w=await dK(this.app,this.choice,this.choiceExecutor);if(w.kind==="openExisting"){await this.openDiscoveredExistingNote(w.file),this.outcome.success(w.file,"unchanged");return}t=this.setTemporaryValueVariable(w.title),n=w.vaultRelativePath??null}let s=await this.resolveTemplateSourcePath(this.choice.templatePath),a="";if(n)a=Wo(n);else if(this.choice.folder.enabled)a=await this.getFolderPath();else{let w=this.app.fileManager.getNewFileParent(this.app.workspace.getActiveFile()?.path??"");a=w===this.app.vault.getRoot()?"":w.path}this.formatter.setTargetFolderPath(a),this.choice.folder.enabled&&this.formatter.setPromptRunContext({destination:a,destinationKind:"folder"});let l=n||await this.formatter.formatFileName(o,"noteTitle"),c=ai(l,"File name"),{fileName:u,strippedPrefix:d}=n?{fileName:c,strippedPrefix:!1}:this.stripDuplicateFolderPrefix(c,a),f=this.shouldTreatFormattedNameAsVaultRelativePath(c,d,this.choice.folder.enabled),p=this.normalizeTemplateFilePath(n||f?"":a,u,s),m,v=!1,g=!1,y="created";if(await this.app.vault.adapter.exists(p)){let w=await this.getSelectedFileExistsMode(),x=Ch(w);y=x.resolutionKind==="reuseExisting"?"unchanged":x.resolutionKind==="createNew"?"created":"changed";let C=x.requiresExistingFile?this.findExistingFile(p):null;if(x.requiresExistingFile&&(!(C instanceof Yg.TFile)||C.extension!=="md"&&C.extension!=="canvas"&&C.extension!=="base")){this.failRun(`'${p}' already exists but could not be resolved as a markdown, canvas, or base file.`);return}if({createdFile:m,shouldAutoOpen:v}=await this.applyFileExistsMode(w,p,C,s,i),!m){this.lastTemplateFileFailure?this.failRun(this.lastTemplateFileFailure,"none"):this.failRun(`Could not resolve file exists behavior for '${p}'.`,"warning");return}}else{if(m=await this.createFileWithTemplate(p,s),!m){this.failRun(this.lastTemplateFileFailure??`Could not create file '${p}'.`,"none");return}g=!0}if(this.outcome.success(m,y),i.enabled&&m)try{i.destination.type==="specifiedFile"?await kT(this.app,m,i):Zd(i.placement)?await tp(this.app,m,i):this.choiceExecutor.focusedProperty?await IT(this.app,this.choiceExecutor.focusedProperty,m):await tp(this.app,m,i)}catch(w){if(w instanceof Nt)throw w;F.logWarning(`Created '${m.basename}' but could not insert the link: ${w instanceof Error?w.message:String(w)}`)}if(this.choice.copyLinkToClipboard&&m)try{await ST(m)}catch(w){F.logWarning(`Could not copy link to clipboard for '${m.path}': ${w instanceof Error?w.message:String(w)}`)}if((this.choice.openFile||v)&&m){let w=dn(this.choice.fileOpening),x=w.focus??!0;rp(this.app,m,x)||await mc(this.app,m,{...w,originLeaf:this.originLeaf}),await wu(this.app,m)}else g&&!i.enabled&&!this.choice.copyLinkToClipboard&&new Yg.Notice(`Created '${m.basename}'.`)}catch(i){if(md(i,{logPrefix:"Template execution aborted",noticePrefix:"Template execution aborted",defaultReason:"Template execution aborted"})){this.choiceExecutor.signalAbort?.(i);return}Gi.getInstance().markExecutionScopeFailed(),this.outcome.failure(ID(i)),lt(i,`Error running template choice "${this.choice.name}"`)}finally{t?.()}}failRun(t,n="error"){Gi.getInstance().markExecutionScopeFailed(),n==="warning"?F.logWarning(t):n==="error"&&F.logError(t),this.outcome.failure(t)}setTemporaryValueVariable(t){let n=this.choiceExecutor.variables,i=n.has("value"),o=n.get("value");return n.set("value",t),()=>{if(i){n.set("value",o);return}n.delete("value")}}validateAppendLinkDestination(t){return!t.enabled||t.destination.type!=="specifiedFile"||zv(this.app,t.destination)?!0:(this.failRun(`Append link target file not found or is not a Markdown file: ${t.destination.path}`),!1)}async getSelectedFileExistsMode(){var i;if((i=this.choice).fileExistsBehavior??(i.fileExistsBehavior={kind:"prompt"}),this.choice.fileExistsBehavior.kind==="apply")return this.choice.fileExistsBehavior.mode;let t=Mj(),n="If the target file already exists";return await ia(this.choiceExecutor,{remote:o=>oa(o,{items:t.map(s=>({value:s.id,title:s.label})),placeholder:n,what:'the "file already exists" chooser'}),headless:()=>{throw new Ee(`'${this.choice.name}' needs to ask what to do because a note with that name already exists, but this run is non-interactive. Set the choice's "If the file already exists" behaviour to a specific action (e.g. Increment, Overwrite), or re-run with the ui flag.`)},app:()=>Nr.Suggest(this.app,t.map(o=>o.label),t.map(o=>o.id),n)})}async applyFileExistsMode(t,n,i,o,s){let a=Ch(t);switch(a.resolutionKind){case"modifyExisting":return{createdFile:await this.applyExistingFileUpdate(a.id,i,o,s),shouldAutoOpen:!1};case"createNew":{let l=await Nj(n,a.id,async u=>await this.app.vault.adapter.exists(u)),c=await this.createFileWithTemplate(l,o);return c&&l!==n&&!this.choice.openFile&&new Yg.Notice(`Created '${c.basename}'.`),{createdFile:c,shouldAutoOpen:!1}}case"reuseExisting":return F.logMessage(`Opening existing file: ${i.path}`),{createdFile:i,shouldAutoOpen:!0}}}async openDiscoveredExistingNote(t){let n=dn(this.choice.fileOpening);rp(this.app,t,!0)||await mc(this.app,t,{...n,focus:!0,originLeaf:this.originLeaf})}async applyExistingFileUpdate(t,n,i,o){switch(t){case"appendTop":return await this.appendToExistingFileWithTemplate(n,i,"top",o);case"appendBottom":return await this.appendToExistingFileWithTemplate(n,i,"bottom",o);case"overwrite":return await this.overwriteFileWithTemplate(n,i)}}async appendToExistingFileWithTemplate(t,n,i,o){if(t.extension==="canvas"||t.extension==="base")return this.lastTemplateFileFailure=`Cannot append to '${t.path}': appending a template to a ${t.extension} file would corrupt it. Use the "Overwrite" file-exists option instead.`,Gi.getInstance().markExecutionScopeFailed(),F.logError(this.lastTemplateFileFailure),null;if(t.extension!=="md")return await this.appendToFileWithTemplate(t,n,i);let s=new qg(this.app,this.plugin,t,n,i,this.choiceExecutor,n);return s.setPromptRunContext({draftScopeId:this.choice.id,choiceName:this.choice.name,destination:t.path,destinationKind:"file"}),s.setLinkToCurrentFileBehavior(o.enabled&&!o.requireActiveFile?"optional":"required"),await this.withAnonymousValueForInsertEngine(()=>s.apply())}async withAnonymousValueForInsertEngine(t){let n=this.formatter.getAnonymousValue(),i=this.choiceExecutor.variables;if(!(n!==void 0&&!i.has("value")))return await t();i.set("value",n);try{return await t()}finally{i.delete("value")}}findExistingFile(t){let n=this.app.vault.getAbstractFileByPath(t);if(n instanceof Yg.TFile)return n;if(n)return null;let i=t.toLowerCase(),o=this.app.vault.getFiles().filter(s=>s.path.toLowerCase()===i);if(o.length===1)return o[0];if(o.length>1){let s=o.map(a=>a.path).join(", ");F.logError(`Multiple files match '${t}' when ignoring case: ${s}`)}return null}async formatFolderPaths(t){let n=[];for(let i of t)n.push(await this.formatter.formatFolderPath(i));return n}async getFolderPath(){let t=await this.formatFolderPaths([...this.choice.folder.folders]),n=this.getCurrentFolderSuggestion(),i=n?[n]:[],o=this.choiceExecutor;if(this.choice.folder?.chooseFromSubfolders&&!(this.choice.folder?.chooseWhenCreatingNote||this.choice.folder?.createInSameFolderAsActiveFile)){let s=Nc(Ns(this.app)),a=vj(s,t);return await this.getOrCreateFolder(a,{allowCreate:!0,allowedRoots:t,topItems:i,executor:o})}if(this.choice.folder?.chooseWhenCreatingNote){let s=Nc(Ns(this.app));return await this.getOrCreateFolder(s,{allowCreate:!0,topItems:i,executor:o})}if(this.choice.folder?.createInSameFolderAsActiveFile){let s=this.app.workspace.getActiveFile();return!s||!s.parent?(F.logWarning("No active file or active file has no parent. Cannot create file in same folder as active file. Creating in root folder."),""):await this.getOrCreateFolder([s.parent.path],{allowCreate:!0,topItems:i,executor:o})}return await this.getOrCreateFolder(t,{allowCreate:!0,allowedRoots:t,topItems:i,executor:o})}getCurrentFolderSuggestion(){let t=this.app.workspace.getActiveFile(),n=t?.parent;return!t||!n?null:{path:n.path??"",label:"<current folder>"}}};var Zc=require("obsidian");Cu();nd();Sx();var FD=class{isResolved(){return!this.hasConflicts}isConflicted(){return this.hasConflicts}},pE=class r extends FD{constructor(e,t,n){super(),this.left=e,this.base=t,this.right=n,this.hasConflicts=!0}static create(e){return new r(e.left,e.base,e.right)}apply(e){return r.create({left:e(this.left),base:e(this.base),right:e(this.right)})}},la=class r extends FD{constructor(e){super(),this.hasConflicts=!1,this.result=e}combine(e){this.result=this.result.concat(e.result)}apply(e){return new r(e(this.result))}};var Kc=class r{constructor(e,t){this.left=e,this.right=t}static executeDiff(e,t){if(!e.push)throw new Error("Argument is not an array");let n=r.diff(e,t);return new uN(e,t,n).convertToTypedOutput()}static diff(e,t){return new r(e,t).performDiff()}performDiff(){let e=this.identifyUniquePositions();e.sort((o,s)=>s[0]-o[0]);let[t,n]=this.findNextChange(),i=new MD(t,n,[]);return e.forEach(o=>{i=this.getDifferences(i,o)}),i.changeRanges}getDifferences(e,t){let[n,i]=[e.leftChangePos,e.rightChangePos],[o,s]=t;if(o<n||s<i)return e;{let[a,l,c,u]=this.findPrevChange(n,i,o-1,s-1),[d,f]=this.findNextChange(o+1,s+1),p=this.appendChangeRange(e.changeRanges,a,l,c,u);return new MD(d,f,p)}}findNextChange(e=0,t=0){let n=this.left.slice(e)||[],i=this.right.slice(t)||[],o=this.mismatchOffset(n,i);return[e+o,t+o]}findPrevChange(e,t,n,i){if(e>n||t>i)return[e,n,t,i];{let o=this.left.slice(e,n+1).reverse()||[],s=this.right.slice(t,i+1).reverse()||[],a=this.mismatchOffset(o,s);return[e,n-a,t,i-a]}}mismatchOffset(e,t){let n=Math.max(e.length,t.length);for(let i=0;i<n;i++)if(e[i]!==t[i])return i;return Math.min(e.length,t.length)}identifyUniquePositions(){let e=this.findUnique(this.left),t=this.findUnique(this.right),n=new Set(...e.keys()),i=new Set(...t.keys()),s=[...new Set([...n].filter(a=>i.has(a)))].map(a=>[e.get(a),t.get(a)]);return s.unshift([this.left.length,this.right.length]),s}findUnique(e){let t=new Map;e.forEach((i,o)=>{t.set(i,new cN(o,!t.has(i)))});let n=new Map;for(let[i,o]of t.entries())o.unique&&n.set(i,o.pos);return n}appendChangeRange(e,t,n,i,o){return t<=n&&i<=o?e.push(new fE(zl.change,t+1,n+1,i+1,o+1)):t<=n?e.push(new fE(zl.remove,t+1,n+1,i+1,i)):i<=o&&e.push(new fE(zl.add,t+1,t,i+1,o+1)),e}},cN=class{constructor(e,t){this.pos=e,this.unique=t}},Kg=class{constructor(e,t){this.text=e,this.low=t}},uN=class{constructor(e,t,n){this.oldTextArray=e,this.newTextArray=t,this.chunks=n,this.oldText=[],this.newText=[]}convertToTypedOutput(){let e=new dN(0,0);return this.chunks.forEach(t=>{let[n,i]=this.setTextNodeIndexes(t,e.oldIndex,e.newIndex),[o,s]=this.appendChanges(t,e.oldIndex+n,e.newIndex+i);e.oldIndex=o,e.newIndex=s}),this.setTheRemainingTextNodeIndexes(e.oldIndex,e.newIndex),{oldText:this.oldText,newText:this.newText}}setTextNodeIndexes(e,t,n){let i=0;for(;t+i<e.leftLo-1;)this.oldText.push(new Kg(this.oldTextArray[t+i],n+i)),i+=1;let o=0;for(;n+o<e.rightLo-1;)this.newText.push(new Kg(this.newTextArray[n+o],t+o)),o+=1;return[i,o]}appendChanges(e,t,n){for(;t<=e.leftHi-1;)this.oldText.push(this.oldTextArray[t]),t+=1;for(;n<=e.rightHi-1;)this.newText.push(this.newTextArray[n]),n+=1;return[t,n]}setTheRemainingTextNodeIndexes(e,t){let n=0;for(;e+n<this.oldTextArray.length;)this.oldText.push(new Kg(this.oldTextArray[e+n],t+n)),n+=1;for(;t+n<this.newTextArray.length;)this.newText.push(new Kg(this.newTextArray[t+n],e+n)),n+=1}},dN=class{constructor(e,t){this.oldIndex=e,this.newIndex=t}},zl;(function(r){r.change="change",r.add="add",r.remove="remove"})(zl||(zl={}));var fE=class{constructor(e,t,n,i,o){this.action=e,this.leftLo=t,this.leftHi=n,this.rightLo=i,this.rightHi=o}},MD=class{constructor(e,t,n){this.leftChangePos=e,this.rightChangePos=t,this.changeRanges=n}};var RD=class r{constructor(e,t,n,i,o){this.code=e,this.baseLo=t,this.baseHi=n,this.sideLo=i,this.sideHi=o}static fromChangeRange(e){return new r(e.action,e.leftLo,e.leftHi,e.rightLo,e.rightHi)}},Xg=class r{constructor(e,t,n){this.left=e,this.base=t,this.right=n}static executeDiff(e,t,n){return new r(e,t,n).getDifferences()}getDifferences(){let e=Kc.diff(this.base,this.left).map(n=>RD.fromChangeRange(n)),t=Kc.diff(this.base,this.right).map(n=>RD.fromChangeRange(n));return this.collapseDifferences(new $D(e,t))}collapseDifferences(e,t=[]){if(e.isFinished())return t;{let n=new $D,i=e.chooseSide(),o=e.dequeue();return n.enqueue(i,o),e.switchSides(),this.buildResultQueue(e,o.baseHi,n),t.push(this.determineDifference(n,i,e.switchSides())),this.collapseDifferences(e,t)}}buildResultQueue(e,t,n){if(this.queueIsFinished(e.peek(),t))return n;{let i=e.dequeue();return n.enqueue(e.currentSide,i),t<i.baseHi?(e.switchSides(),this.buildResultQueue(e,i.baseHi,n)):this.buildResultQueue(e,t,n)}}queueIsFinished(e,t){return e.length===0||e[0].baseLo>t+1}determineDifference(e,t,n){let i=e.get(t)[0].baseLo,o=e.get(n),s=o[o.length-1].baseHi,[a,l]=this.diffableEndpoints(e.get(zn.left),i,s),[c,u]=this.diffableEndpoints(e.get(zn.right),i,s),d=this.left.slice(a-1,l),f=this.right.slice(c-1,u),p=this.decideAction(e,d,f);return new pN(p,a,l,c,u,i,s)}diffableEndpoints(e,t,n){if(e.length){let i=e[0],o=e[e.length-1],s=i.sideLo-i.baseLo+t,a=o.sideHi-o.baseHi+n;return[s,a]}else return[t,n]}decideAction(e,t,n){return e.isEmpty(zn.left)?Xc.chooseRight:e.isEmpty(zn.right)?Xc.chooseLeft:t.every((i,o)=>n[o]===i)?Xc.noConflictFound:Xc.possibleConflict}},pN=class{constructor(e,t,n,i,o,s,a){this.changeType=e,this.leftLo=t,this.leftHi=n,this.rightLo=i,this.rightHi=o,this.baseLo=s,this.baseHi=a}},Xc;(function(r){r.chooseRight="choose_right",r.chooseLeft="choose_left",r.possibleConflict="possible_conflict",r.noConflictFound="no_conflict_found"})(Xc||(Xc={}));var zn;(function(r){r.left="left",r.right="right"})(zn||(zn={}));var $D=class{constructor(e=[],t=[]){this.diffs={left:e,right:t}}dequeue(e=this.currentSide){return this.diffs[e].shift()}peek(e=this.currentSide){return this.diffs[e]}isFinished(){return this.isEmpty(zn.left)&&this.isEmpty(zn.right)}enqueue(e=this.currentSide,t){return this.diffs[e].push(t)}get(e=this.currentSide){return this.diffs[e]}isEmpty(e=this.currentSide){return this.diffs[e].length===0}switchSides(e=this.currentSide){return this.currentSide=e===zn.left?zn.right:zn.left}chooseSide(){return this.isEmpty(zn.left)?this.currentSide=zn.right:this.isEmpty(zn.right)?this.currentSide=zn.left:this.currentSide=this.get(zn.left)[0].baseLo<=this.get(zn.right)[0].baseLo?zn.left:zn.right,this.currentSide}};var mE=class r{static merge(e,t,n){let i=new r(e,t,n);return i.executeThreeWayMerge(),i.result}constructor(e,t,n){this.result=[],this.text3=new fN(e,n,t)}executeThreeWayMerge(){let e=Xg.executeDiff(this.text3.left,this.text3.base,this.text3.right),t=1;e.forEach(i=>{let o=[];for(let s=t;s<i.baseLo;s++)o.push(this.text3.base[s-1]);o.length&&this.result.push(new la(o)),this.interpretChunk(i),t=i.baseHi+1});let n=this.accumulateLines(t,this.text3.base.length,this.text3.base);n.length&&this.result.push(new la(n))}setConflict(e){let t=pE.create({left:this.accumulateLines(e.leftLo,e.leftHi,this.text3.left),base:this.accumulateLines(e.baseLo,e.baseHi,this.text3.base),right:this.accumulateLines(e.rightLo,e.rightHi,this.text3.right)});this.result.push(t)}determineConflict(e,t,n){let i=1;e.forEach(s=>{for(let l=i;l<=s.leftLo;l++)this.result.push(new la(this.accumulateLines(i,l,n)));let a=this.determineOutcome(s,t,n);i=s.rightHi+1,a&&this.result.push(a)});let o=this.accumulateLines(i,n.length+1,n);o.length&&this.result.push(new la(o))}determineOutcome(e,t,n){return e.action===zl.change?pE.create({left:this.accumulateLines(e.rightLo,e.rightHi,t),right:this.accumulateLines(e.leftLo,e.leftHi,n),base:[]}):e.action===zl.add?new la(this.accumulateLines(e.rightLo,e.rightHi,t)):null}setText(e,t,n){let i=[];for(let o=t;o<=n;o++)i.push(e[o-1]);return i}_conflictRange(e){let t=this.setText(this.text3.right,e.rightLo,e.rightHi),n=this.setText(this.text3.left,e.leftLo,e.leftHi),i=Kc.diff(t,n);(this._assocRange(i,zl.change)||this._assocRange(i,zl.remove))&&e.baseLo<=e.baseHi?this.setConflict(e):this.determineConflict(i,n,t)}interpretChunk(e){if(e.changeType==Xc.chooseLeft){let t=this.accumulateLines(e.leftLo,e.leftHi,this.text3.left);t.length&&this.result.push(new la(t))}else if(e.changeType!==Xc.possibleConflict){let t=this.accumulateLines(e.rightLo,e.rightHi,this.text3.right);t.length&&this.result.push(new la(t))}else this._conflictRange(e)}_assocRange(e,t){for(let n=0;n<e.length;n++){let i=e[n];if(i.action===t)return i}return null}accumulateLines(e,t,n){let i=[];for(let o=e;o<=t;o++)n[o-1]&&i.push(n[o-1]);return i}},fN=class{constructor(e,t,n){this.left=e,this.right=t,this.base=n}};var yf=class{constructor(e,t,n={}){this.results=e,this.joinFunction=t,this.conflictHandler=n.conflictHandler,this.conflict=n.conflict||!1}isSuccess(){return!this.conflict}isConflict(){return!!this.conflict}joinedResults(){if(this.isConflict())return this.conflictHandler?this.conflictHandler(this.results):this.results;{let[e,t]=[this.results[0],this.results.slice(1)],n=e;return t.forEach(i=>n.combine(i)),n.apply(this.joinFunction).result}}};var hE=class r{static collateMerge(e,t,n){return e.length?(e=r.combineNonConflicts(e),e.length===1&&e[0].isResolved()?new yf(e,t):new yf(e,t,{conflict:!0,conflictHandler:n})):new yf([new la([])],t)}static combineNonConflicts(e){let t=[];return e.forEach(n=>{t.length&&t[t.length-1].isResolved()&&n.isResolved()?t[t.length-1].combine(n):t.push(n)}),t}};function fK(r,e,t,n){return function(o){return o.map(s=>{if(s.isResolved())return s.apply(n).result;{let a=s.apply(n),{left:l,right:c}=a;return[r,l,e,c,t].join(`
|
||
`)}}).join(`
|
||
`)}}var mK=r=>r.join(""),Kve=r=>r.split(/\b/),Xve=fK("<<<<<<< YOUR CHANGES","=======",">>>>>>> APP AUTHORS CHANGES",mK),Qve={splitFunction:Kve,joinFunction:mK,conflictFunction:Xve};function mN(r,e,t,n={}){n=Object.assign({},Qve,n);let[i,o,s]=[r,e,t].map(c=>n.splitFunction.call(n,c)),a=mE.merge(i,o,s);return hE.collateMerge(a,n.joinFunction,n.conflictFunction)}var hK=mN;Tt();Cu();kD();Tt();qt();Co();Lg();function gK(r,e){return r.line===e.line}function Qc(r){let e=[];return r.forEach((t,n)=>{let i=t.match(/^(#+)[\s]+(.*)$/);i&&e.push({level:i[1].length,text:i[2],line:n})}),e}function vd(r,e,t=!1){let n=Qc(r),i=n.find(c=>c.line===e),o=!!i;if(!o&&t)throw new Error(`Target line ${e} is not a heading, but we are trying to find the end of its section.`);if(!o&&!t){let c=vK(r,e,u=>u.trim()==="");return c!==null&&c>e?c-1:e}let s=r.length-1,a=Zve(i,n,r,t),l=tye(r,a,c=>c.trim()!=="");if(l!==null){if(l<e)return e;let c=r[l+1].trim()==="";return l+1===s&&!c?a:l===0?l+1:l}return a}function Zve(r,e,t,n){let i=e.findIndex(u=>gK(u,r)),o=i===e.length-1,s=t.length-1;if(o)return s;let[a,l]=Jve(r,e);if(l&&a===e.length)return s;if(l&&n)return e[a].line-1;if(l&&!n)return e[i+1].line;if(!n&&!l){let u=eye(r.line,e);return u===null?s:u}return s}function Jve(r,e){let t=e.findIndex(i=>gK(i,r)),n=vK(e,t,i=>i.level<=r.level);return n===null?[-1,!1]:[n,!0]}function eye(r,e){let t=e.find(n=>n.line>r);return t?t.line:null}function tye(r,e,t){for(let n=e-1;n>=0;n--)if(t(r[n]))return n;return null}function vK(r,e,t){for(let n=e+1;n<r.length;n++)if(t(r[n]))return n;return null}var rye="\u200B";function gE(r){let e=r.slice(),t=!1,n="",i=0;for(let o=0;o<r.length;o++){let s=r[o].match(/^(\s*)(`{3,}|~{3,})/);if(!t){s&&(t=!0,n=s[2][0],i=s[2].length);continue}e[o]=r[o].replace(/^(\s*)#+(\s)/,`$1${rye}$2`),s&&s[2][0]===n&&s[2].length>=i&&r[o].slice(s[1].length+s[2].length).trim()===""&&(t=!1,n="",i=0)}return e}function yK(r){return(r.match(/^#+\s+(.*)$/)?.[1]??"").trim()}function nye(r){let e=r.match(/^\[?v?(\d+)\.(\d+)\.(\d+)(?:[-+\]].*)?$/i)??r.match(/^\[?v?(\d+)(?:\.(\d+))?(?:\.(\d+))?/i);if(!e)return{value:0,parsed:!1};let t=n=>Math.min(Number(n??"0"),999999);return{value:t(e[1])*1e12+t(e[2])*1e6+t(e[3]),parsed:!0}}function bK(r,e,t){switch(e.by){case"lexical":return{value:r.toLocaleLowerCase(),parsed:!0};case"numeric":{let n=r.match(/^-?\d+(?:\.\d+)?/);return n?{value:Number(n[0]),parsed:!0}:{value:0,parsed:!1}}case"date":{let n=t?t(r,e.dateFormat||void 0,!1):null;return n&&n.isValid()?{value:n.valueOf(),parsed:!0}:{value:0,parsed:!1}}case"semver":return nye(r);default:return{value:0,parsed:!0}}}function iye(r,e){if(typeof r.value=="string"&&typeof e.value=="string")return r.value<e.value?-1:r.value>e.value?1:0;let t=r.value,n=e.value;return t<n?-1:t>n?1:0}function wK(r,e,t,n,i,o=0){let s=gE(r),a=Qc(s).filter(f=>f.line>=o),l=a.filter(f=>f.level===t),c=bK(yK(e),n,i);if(l.length===0){let f=a.filter(p=>p.level<t).pop();return f?{mode:"after",line:vd(s,f.line,!0)}:{mode:"bodyStart"}}let u=()=>{let f=l[l.length-1];return{mode:"after",line:vd(s,f.line,!0)}};if(n.by==="insertion")return n.direction==="desc"?{mode:"before",line:l[0].line}:u();if(!c.parsed)return u();let d=n.unparseable??"bottom";for(let f of l){let p=bK(yK(s[f.line]),n,i),m;if(!p.parsed)m=d==="bottom";else{let v=iye(c,p);m=n.direction==="desc"?v>0:v<0}if(m)return{mode:"before",line:f.line}}return u()}oE();function hN(r){let e=r.split(`
|
||
`);for(;e.length>1&&e[e.length-1].trim()==="";)e.pop();return e}function gN(r){return r.length===0||r.length===1&&r[0].trim()===""}function vN(r,e){if(e.length<=1){let t=oye(r,e[0]??"");return{start:t,end:t}}return sye(r,e)}function oye(r,e){let t=e.trimEnd(),n=-1;for(let i=0;i<r.length;i++){let o=r[i].trimStart();if(o===t)return i;if(o.startsWith(t)){let a=o.slice(t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i);continue}let s=o.indexOf(t);if(s!==-1){let a=o.slice(s+t.length);if(/^\s*$/.test(a))return i;n===-1&&(n=i)}}return n}function sye(r,e){let t=e.length,n=e.map(i=>CK(i));for(let i=0;i+t<=r.length;i++){let o=!0;for(let s=0;s<t;s++)if(CK(r[i+s])!==n[s]){o=!1;break}if(o)return{start:i,end:i+t-1}}return{start:-1,end:-1}}function CK(r){return r.trimEnd()}function xK(r,e,t){return r?Qc([e[t]??""]).length>0:!1}function aye(r,e){return r==="skip"?!0:r==="none"?!1:lye(e)}function lye(r){return/^\s{0,3}#{1,6}\s+\S/.test(r)}function yN(r,e,t,n){if(e<0)return e;let i=r[e]??"";if(!aye(n,i))return e;let s=t.endsWith(`
|
||
`)?Math.max(r.length-1,0):r.length,a=e;for(let l=e+1;l<s;l++){if(r[l].trim().length===0){a=l;continue}break}return a}function OD(r,e,t,n){if(e<0)return e;let i=e,o=e+1;for(;o<r.length&&r[o].trim().length===0;)i=o,o++;return i===e||o!==r.length||!n.endsWith(`
|
||
`)?e:t.endsWith(`
|
||
`)?Math.max(e,i-1):i}function EK(r){return r.includes(`
|
||
`)||r.includes("\r")}function TK(r,e){let t=r.indexOf(`
|
||
`,e);return t===-1?r.length:t>0&&r[t-1]==="\r"?t-1:t}function bN(r){let e=X1(r);return e>0?r.slice(0,e).split(`
|
||
`).length-1:0}function _K(r,e){let t=bN(e),n=r.map((i,o)=>o<t?"":i);return gE(n).map(i=>i.replace(/\r$/,""))}function AK(r,e,t,n){let i=e.split(`
|
||
`),o=i.slice(0,t+1).join(`
|
||
`),s=i.slice(t+1).join(`
|
||
`),l=(i[t+1]??"").trim(),c=e.endsWith(`
|
||
`)&&t+1===i.length-1,u=t+1<i.length&&!c&&l==="",d=n&&r.endsWith(`
|
||
`)&&u?r.slice(0,-1):r,f=!d.endsWith(`
|
||
`)&&l!==""?`
|
||
`:"";return{content:`${o}
|
||
${d}${f}${s}`,insertedEndOffset:o.length+1+d.length}}function kK(r,e,t,n=r.length){let i=e.length>0&&!r.endsWith(`
|
||
`)?`
|
||
`:"",o=Math.max(0,Math.min(n,r.length));if(t<=0)return{content:`${r}${i}${e}`,insertedEndOffset:o};let s=e.split(`
|
||
`),a=s.slice(0,t).join(`
|
||
`),l=s.slice(t).join(`
|
||
`);return{content:`${a}
|
||
${r}${i}${l}`,insertedEndOffset:a.length+1+o}}function SK(r,e,t,n){let i=n,o=i.includes(`\r
|
||
`)?`\r
|
||
`:`
|
||
`,s=e.mode==="before"?e.line:e.line+1,a=0;for(let w=0;w<s&&w<r.length;w++)a+=r[w].length+1;a>i.length&&(a=i.length);let l=i.slice(0,a),c=i.slice(a),u=s>0?(r[s-1]??"").replace(/\r$/,""):"",d=s<r.length?(r[s]??"").replace(/\r$/,""):"",f=t.split(`
|
||
`).map(w=>w.replace(/\r$/,""));f.length>1&&f[f.length-1]===""&&f.pop();let p=[];s>0&&u.trim()!==""&&p.push(""),p.push(...f),s<r.length&&d.trim()!==""&&p.push("");let m=p.join(o),v=l.length>0&&!/\n$/.test(l)?o:"",g=c.length>0||/\n$/.test(i)?o:"",y=l.length+v.length;return{content:`${l}${v}${m}${g}${c}`,insertedEndOffset:y+m.length}}oE();Rg();MP();var uye=/^[ \t\r\n\f\v]*$/;function DK(r){return uye.test(r)}var ND=class extends ws{constructor(){super(...arguments);this.file=null;this.fileContent="";this.sourcePath=null;this.useSelectionAsCaptureValue=!0;this.clipboardImageFallbackEnabled=!1;this.createdClipboardAttachmentPaths=[];this.templaterProcessed=!1;this.insertAfterTargetOverride=null;this.lastResolvedInsertAfterHeading=null;this.linebreaksProcessed=!1;this.captureInsertionEndOffset=null}setDestinationFile(t){this.file=t,this.sourcePath=t.path,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(t.path)),this.setPromptRunContext({destination:t.path,destinationKind:"file"})}setDestinationSourcePath(t){this.sourcePath=t,this.file=null,this.clipboardAttachmentLink=void 0,this.setTargetFolderPath(Wo(t)),this.setPromptRunContext({destination:t,destinationKind:"file"})}setUseSelectionAsCaptureValue(t){this.useSelectionAsCaptureValue=t}setInsertAfterTargetOverride(t){this.insertAfterTargetOverride=t}getResolvedInsertAfterHeading(){return this.lastResolvedInsertAfterHeading}consumeCreatedClipboardAttachmentPaths(){let t=this.createdClipboardAttachmentPaths;return this.createdClipboardAttachmentPaths=[],t}getCaptureInsertionEndOffset(){return this.captureInsertionEndOffset}setCaptureInsertionEndOffset(t){this.captureInsertionEndOffset=typeof t=="number"&&Number.isFinite(t)&&t>=0?t:null}shouldUseSelectionForValue(){return this.useSelectionAsCaptureValue}async getSelectedTextForValue(){let t=await this.getSelectedText();return t.trim().length>0?t:""}getLinkSourcePath(){return this.sourcePath??this.file?.path??null}async getClipboardContent(){let t=await super.getClipboardContent();return t.length>0||!this.clipboardImageFallbackEnabled?t:this.clipboardAttachmentLink!==void 0?this.clipboardAttachmentLink??"":(this.clipboardAttachmentLink=await this.saveClipboardImageAsAttachment(),this.clipboardAttachmentLink??"")}async withClipboardImageFallback(t){let n=this.clipboardImageFallbackEnabled;this.clipboardImageFallbackEnabled=!0;try{return await t()}finally{this.clipboardImageFallbackEnabled=n}}async saveClipboardImageAsAttachment(){let t=navigator.clipboard;if(typeof t?.read!="function")return null;let n,i;try{if(n=await this.getFirstClipboardImageItem(t),!n)return null;i=await(await n.clipboardItem.getType(n.mimeType)).arrayBuffer()}catch{return null}let o=this.getLinkSourcePath()??"",s=await p_(this.app,i,n.mimeType,o);return this.createdClipboardAttachmentPaths.push(s.path),f_(this.app,s,o)}async getFirstClipboardImageItem(t){let n=await t.read();for(let i of n){let o=i.types.find(s=>dy[s]!==void 0);if(o)return{clipboardItem:i,mimeType:o}}return null}getCurrentFileLink(){let t=this.app.workspace.getActiveFile();if(!t)return null;let n=this.sourcePath??this.file?.path??"";return this.app.fileManager.generateMarkdownLink(t,n)}async formatContentWithFile(t,n,i,o){if(this.setCaptureInsertionEndOffset(null),this.choice=n,this.file=o,this.fileContent=i,!n||!o||i===null)return t;this.setTargetFolderPath(Wo(o.path));let s=n.insertAfter.enabled||!!n.insertBefore?.enabled||n.prepend||!n.captureToActiveFile||n.activeFileWritePosition==="top"||n.activeFileWritePosition==="bottom";return await this.formatFileContent(t,s)}async formatContent(t,n){return this.choice=n,n?await this.formatFileContent(t):t}async formatFileContent(t,n=!0){let i=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));if(n&&this.file&&!this.templaterProcessed){let a=await pc(this.app,i,this.file);a&&(i=a),this.templaterProcessed=!0}if(DK(i))return this.fileContent;if(this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWritePosition==="bottom"){let a=!this.choice.task,l=this.fileContent.length>0&&!this.fileContent.endsWith(`
|
||
`)&&!i.startsWith(`
|
||
`),c=a||l?`
|
||
`:"";return this.setCaptureInsertionEndOffset(this.fileContent.length+c.length+i.length),`${this.fileContent}${c}${i}`}return this.choice.insertAfter.enabled?await this.insertAfterHandler(i):this.choice.insertBefore?.enabled?await this.insertBeforeHandler(i):this.insertAtNoteBodyStartTracking(i)}async formatContentOnly(t){let n=await this.withClipboardImageFallback(async()=>this.withPromptScope("captureText",t,async()=>super.formatFileContent(await this.expandTemplateLinebreaksOnce(t))));return DK(n)?this.fileContent:n}async expandTemplateLinebreaksOnce(t){return this.linebreaksProcessed?t:(this.linebreaksProcessed=!0,this.expandFormatTemplateEscapes(t))}async expandFormatTemplateEscapes(t){let n=await this.replaceGlobalVarInString(t);return this.expandLinebreakEscapesOutsideTokens(n)}async insertAfterHandler(t){let n=this.insertAfterTargetOverride;if(this.choice.insertAfter?.inline&&n===null){let f=await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));return await this.insertAfterInlineHandler(t,f)}let i=n??await this.formatLocationString(await this.expandFormatTemplateEscapes(this.choice.insertAfter.after));if(n===null){let f=i.split(`
|
||
`,1)[0];this.lastResolvedInsertAfterHeading=/^#+\s+\S/.test(f)?f.trim():null}let o=hN(i);if(gN(o))throw new Ee("Insert-after target is empty after formatting.");let s=mf(this.fileContent),a=this.isOrderedCreate()?_K(s,this.fileContent):s,{start:l,end:c}=vN(a,o);if(l===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInsertAfterIfNotFound(t,i);throw new Ee(`Insert-after target not found: '${i}'.`)}let d;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let f=vd(s,l,this.considerSubsectionsForAnchor(s,l)),p=Math.max(f??s.length-1,c);d=OD(s,p,this.fileContent,t)}else{let f=this.choice.insertAfter?.blankLineAfterMatchMode??"auto";d=yN(s,c,this.fileContent,f)}return this.insertTextAfterPositionInBody(t,this.fileContent,d)}async insertBeforeHandler(t){let n=this.choice.insertBefore;if(!n)throw new Ee("Insert-before settings are missing.");let i=await this.formatLocationString(await this.expandFormatTemplateEscapes(n.before)),o=hN(i);if(gN(o))throw new Ee("Insert-before target is empty after formatting.");let s=mf(this.fileContent),{start:a}=vN(s,o);if(a===-1){if(n.createIfNotFound)return await this.createInsertBeforeIfNotFound(t,i);throw new Ee(`Insert-before target not found: '${i}'.`)}return this.insertTextBeforePositionInBody(t,this.fileContent,a)}async insertAfterInlineHandler(t,n){if(EK(n))throw new Ee("Inline insert-after target must be a single line \u2014 remove the line break (\\n) or turn off inline insertion.");let i=this.fileContent.indexOf(n);if(i===-1){if(this.choice.insertAfter?.createIfNotFound)return await this.createInlineInsertAfterIfNotFound(t,n);throw new Ee(`Inline insert-after target not found: '${n}'.`)}let o=i+n.length;if(this.setCaptureInsertionEndOffset(o+t.length),this.choice.insertAfter?.replaceExisting){let s=TK(this.fileContent,o);return this.fileContent.slice(0,o)+t+this.fileContent.slice(s)}return this.fileContent.slice(0,o)+t+this.fileContent.slice(o)}async createInsertAfterIfNotFound(t,n){let i=`${n}
|
||
${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
|
||
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;if(this.choice.insertAfter?.insertAtEnd){if(!this.file)throw new Error("Tried to get sections without file.");let c=mf(this.fileContent),u=vd(c,a,this.considerSubsectionsForAnchor(c,a));a=OD(c,u??c.length-1,this.fileContent,i)}return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}if(this.choice.insertAfter?.createIfNotFoundLocation===_a)return this.createInsertAfterOrdered(t,n);throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}isOrderedCreate(){return!!this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation===_a}considerSubsectionsForAnchor(t,n){return xK(!!this.choice.insertAfter?.considerSubsections,t,n)}createInsertAfterOrdered(t,n){let i=this.choice.insertAfter?.orderBy??{by:"insertion",direction:"desc",unparseable:"bottom"},o=n.split(/\r?\n/,1)[0],s=Qc([o])[0]?.level??0,a=`${n}
|
||
${t}`;if(s===0)return this.insertAtNoteBodyStartTracking(a);let l=mf(this.fileContent),c=l.map(g=>g.replace(/\r$/,"")),u=bN(this.fileContent),d=gE(c),f=o.replace(/\r$/,"").trimEnd(),p=d.findIndex((g,y)=>y>=u&&g.trimEnd()===f);if(p!==-1){let g=this.choice.insertAfter?.insertAtEnd?OD(d,vd(d,p,this.considerSubsectionsForAnchor(d,p))??d.length-1,this.fileContent,t):yN(d,p,this.fileContent,this.choice.insertAfter?.blankLineAfterMatchMode??"auto");return this.insertTextAfterPositionInBody(t,this.fileContent,g)}let m=typeof window<"u"?window.moment:void 0,v=wK(c,o,s,i,m,u);return v.mode==="bodyStart"?this.insertAtNoteBodyStartTracking(a):this.spliceOrderedSection(l,v,a)}spliceOrderedSection(t,n,i){let{content:o,insertedEndOffset:s}=SK(t,n,i,this.fileContent);return this.setCaptureInsertionEndOffset(s),o}async createInsertBeforeIfNotFound(t,n){let i=this.choice.insertBefore;if(!i)throw new Ee("Insert-before settings are missing.");let o=t.endsWith(`
|
||
`)||t.length===0?`${t}${n}`:`${t}
|
||
${n}`;if(i.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(o,t.length);if(i.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+t.length),`${this.fileContent}
|
||
${o}`;if(i.createIfNotFoundLocation===cc){let s=On(this.app);if(!s)throw new Ee(`Unable to insert line '${i.before}' at cursor position: no active markdown editor.`);try{let a=s.editor.getCursor();return this.insertTextBeforePositionInBody(o,this.fileContent,a.line,t.length)}catch{throw new Ee(`Unable to insert line '${i.before}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${i.createIfNotFoundLocation}`)}async createInlineInsertAfterIfNotFound(t,n){let i=`${n}${t}`;if(this.choice.insertAfter?.createIfNotFoundLocation===uo)return this.insertAtNoteBodyStartTracking(i);if(this.choice.insertAfter?.createIfNotFoundLocation===lc)return this.setCaptureInsertionEndOffset(this.fileContent.length+1+i.length),`${this.fileContent}
|
||
${i}`;if(this.choice.insertAfter?.createIfNotFoundLocation===cc){let o=On(this.app);if(!o)throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position: no active markdown editor.`);try{let a=o.editor.getCursor().line;return this.insertTextAfterPositionInBody(i,this.fileContent,a)}catch{throw new Ee(`Unable to insert line '${this.choice.insertAfter.after}' at cursor position.`)}}throw new Ee(`Unknown createIfNotFoundLocation: ${this.choice.insertAfter?.createIfNotFoundLocation}`)}insertAtNoteBodyStartTracking(t,n=t.length){let i=Q1(this.fileContent,t);if(i.insertedStartOffset===null)return this.setCaptureInsertionEndOffset(null),i.content;let o=Math.max(0,Math.min(n,t.length));return this.setCaptureInsertionEndOffset(i.insertedStartOffset+o),i.content}insertTextAfterPositionInBody(t,n,i){let{content:o,insertedEndOffset:s}=AK(t,n,i,!!this.choice.task);return this.setCaptureInsertionEndOffset(s),o}insertTextBeforePositionInBody(t,n,i,o=t.length){let{content:s,insertedEndOffset:a}=kK(t,n,i,o);return this.setCaptureInsertionEndOffset(a),s}};kD();Me();Jd();qt();Cr();$g();Og();var IK=require("obsidian");Tt();Co();Tl();function PK(r,e){let t=r.trim().replace(/^\/+/,"");if(t==="")return{kind:"vault"};let n=vh(t);if(n){if(!n.field)throw new Ee("Property capture target needs a field name, e.g. property:type=draft");return{kind:"property",field:n.field,value:n.value,filter:n.filter}}let i=gh(t);if(i){if(i.multiSelect)throw new Ee("Capture target filters select one destination file. Use {{FILE:...|multi}} in the capture format for multi-value metadata.");return{kind:"filter",filter:i.filter}}let o=ai(t,"Capture target file path");if(Vi.test(o))throw new Ee(`Capture to '.base' files is not supported (${o}). Use a Template choice instead.`);let s=o.endsWith("/"),a=o.replace(/\/+$/,"");if(s)return{kind:"folder",folder:a};if(ir.test(o)||qr.test(o))return{kind:"file",path:o};let l=e.normalizeMarkdownFilePath("",a),u=e.getAbstractFileByPath(l)instanceof IK.TFile;return e.isFolder(a)&&!u?{kind:"folder",folder:a}:{kind:"file",path:o}}Tt();function LD(r){return`${r.replace(/^\/+/,"").replace(ir,"")}.md`}function BD(r,e,t){if(t)return null;let n=(e??"").trim().replace(/^\/+/,"");if(_u(n))return null;let i=vh(n),o=!!i&&!!i.field,s=o?null:gh(n),a=!!s&&!s.multiSelect,l=!o&&!s&&n.startsWith("#"),c=n.endsWith("/"),u=!l&&!o&&!a&&!c&&(ir.test(n)||qr.test(n)||Vi.test(n)),d=n.replace(/\/+$/,""),f=!l&&!o&&!a&&!u&&(n===""||r.isFolder(d)&&!r.markdownFileExists(d)),p=!o&&!a&&c;if(o&&i)return{kind:"property",field:i.field,value:i.value,filter:i.filter};if(a&&s)return{kind:"filter",filter:s.filter};if(l)return{kind:"tag",tag:n};if(f||p){let m=d;return{kind:"folder",folderPathSlash:m===""?"":`${m}/`}}return null}Hv();Tl();Ec();Tm();nm();Rg();Hs();sN();aD();Co();lD();H1();function FK(r){let e=r.insertAfter.enabled||!!r.insertBefore?.enabled;return r.captureToActiveFile&&!e&&r.newLineCapture?.enabled?r.newLineCapture.direction==="above"?"newLineAbove":"newLineBelow":r.captureToActiveFile&&!e?r.activeFileWritePosition==="top"?"activeFileTop":r.activeFileWritePosition==="bottom"||r.prepend?"append":"currentLine":r.insertAfter.enabled?"insertAfter":r.insertBefore?.enabled?"insertBefore":r.prepend?"prepend":"append"}Tt();Co();function wN(r){return r?.type==="text"?"text":r?.type==="file"||r?.file?"file":typeof r?.text=="string"?"text":"unsupported"}function dye(r,e){let t=e.id;if(!t)return null;let n=r.getData?.();return n?.nodes?.length?n.nodes.find(i=>i.id===t)??null:null}function MK(r,e){if(r==="text"){if(e==="currentLine")return"Canvas capture does not support 'At cursor' for text cards. Use top, bottom, insert-after, or insert-before placement.";if(e==="newLineAbove"||e==="newLineBelow")return"Canvas capture does not support 'New line above/below cursor' for text cards. Use top, bottom, insert-after, or insert-before placement."}return r==="file"&&(e==="currentLine"||e==="newLineAbove"||e==="newLineBelow")?"Canvas file cards do not support cursor-based capture modes. Use top, bottom, insert-after, or insert-before modes.":null}function pye(r){let e=r.file;return e?typeof e=="string"?e:typeof e=="object"&&"path"in e&&typeof e.path=="string"?e.path:null:null}function CN(r){return!!r&&"path"in r&&"extension"in r}function fye(r){let t=(r.workspace.activeLeaf??r.workspace.getMostRecentLeaf?.()??null)?.view;return!t||t.getViewType?.()!=="canvas"?null:t}function mye(r,e){let t=e.file??r.workspace.getActiveFile?.();if(!t)throw new Ee("Cannot capture to Canvas because no active Canvas file is available.");return t}function hye(r){let e=r.selection?Array.from(r.selection):[];if(e.length!==1)throw new Ee("Canvas capture requires exactly one selected node.");return e[0]}function RK(r){let e=pye(r);if(!e)throw new Ee("Selected Canvas file card does not have a valid linked file path.");if(!ir.test(e))throw new Ee("Canvas file card targets markdown files only in this version.");return e}function gye(r,e){let t=RK(e),n=r.vault.getAbstractFileByPath(t);if(!CN(n))throw new Ee(`Selected Canvas file card target not found: ${t}`);return n}function vye(r,e){let t=RK(e),n=r.vault.getAbstractFileByPath(t);if(!n)return{targetPath:t};if(!CN(n))throw new Ee(`Selected Canvas file card target not found: ${t}`);return{targetPath:t,targetFile:n}}function yye(r,e){let t;try{t=JSON.parse(r)}catch{throw new Ee(`Canvas file is not valid JSON: ${e}`)}if(!t||typeof t!="object")throw new Ee(`Canvas file has invalid structure: ${e}`);if(!Array.isArray(t.nodes))throw new Ee(`Canvas file has no nodes array: ${e}`);return t}function $K(r,e){let t=r,n=fye(t);if(!n)return null;let i=n.canvas;if(!i)throw new Ee("Canvas capture is unavailable in this Obsidian version.");let o=mye(t,n),s=hye(i),a=dye(i,s),l=wN(s);if(l==="unsupported"&&a&&(l=wN(a)),l==="unsupported")throw new Ee("Canvas capture currently supports only text and file cards.");let c=MK(l,e);if(c)throw new Ee(c);if(l==="text")return{kind:"text",source:"active",canvas:i,canvasFile:o,node:s,nodeData:a};let u=s.file||!a?.file?s:{...s,file:a.file};return{kind:"file",source:"active",canvasFile:o,node:u,targetFile:gye(t,u)}}async function OK(r,e,t,n){let i=t.trim();if(!i)throw new Ee("Canvas node id is required for Canvas node capture.");let o=r.vault.getAbstractFileByPath(e);if(!CN(o))throw new Ee(`Canvas target not found: ${e}`);if(!qr.test(o.path))throw new Ee("Canvas node capture requires the target path to be a .canvas file.");let s=await r.vault.read(o),a=yye(s,o.path),l=a.nodes.findIndex(v=>v.id===i);if(l===-1)throw new Ee(`Canvas node id '${i}' was not found in ${o.path}.`);let c=a.nodes[l],u=wN(c);if(u==="unsupported")throw new Ee("Canvas capture currently supports only text and file cards.");let d=MK(u,n);if(d)throw new Ee(d);if(u==="text")return{kind:"text",source:"configured",canvasFile:o,rawCanvas:s,canvasData:a,nodeData:c,nodeIndex:l};let f=r,{targetPath:p,targetFile:m}=vye(f,c);return{kind:"file",source:"configured",canvasFile:o,nodeData:c,targetPath:p,targetFile:m}}function NK(r){return r.source==="active"?typeof r.node.text=="string"?r.node.text:typeof r.nodeData?.text=="string"?r.nodeData.text:"":typeof r.nodeData.text=="string"?r.nodeData.text:""}async function LK(r,e,t){if(e.source==="active"){typeof e.node.setText=="function"?e.node.setText(t):e.node.text=t,e.canvas.requestSave?.();return}if(await r.vault.read(e.canvasFile)!==e.rawCanvas)throw new Ee("Canvas target changed while capture was running. Re-run capture to avoid overwriting newer Canvas edits.");e.nodeData.text=t,e.canvasData.nodes[e.nodeIndex]=e.nodeData,await r.vault.modify(e.canvasFile,JSON.stringify(e.canvasData,null," "))}Qx();var UD=4e3,bye=/^[ \t\r\n\f\v]*$/;function wye(r){return bye.test(r)}var VD=class extends jg{constructor(t,n,i,o,s=null){super(t);this.choiceExecutor=o;this.originLeaf=s;this.capturePropertyVars=new Map;this.suppressFrontmatterCollection=!1;this.resolvedInsertAfterHeading=null;this.choice=i,this.plugin=n,this.outcome=new Gg(o),this.formatter=new ND(t,n,o),this.formatter.setPromptRunContext({draftScopeId:i.id,choiceName:i.name})}captureResolvedOrderedHeading(){if(this.choice.insertAfter?.enabled&&this.choice.insertAfter.createIfNotFoundLocation===_a){let t=this.formatter.getResolvedInsertAfterHeading();t&&(this.resolvedInsertAfterHeading=t)}}showSuccessNotice(t,{wasNewFile:n,action:i}){let o=`'${t.basename}'`;if(n){new Zc.Notice(`Created and captured to ${o}`,UD);return}let s=this.choice.prepend||this.choice.captureToActiveFile&&this.choice.activeFileWritePosition==="bottom",a="";switch(i){case"currentLine":a=`Captured to current line in ${o}`;break;case"newLineAbove":a=`Captured on a new line above cursor in ${o}`;break;case"newLineBelow":a=`Captured on a new line below cursor in ${o}`;break;case"activeFileTop":a=`Captured to top of ${o}`;break;case"prepend":case"append":a=s?`Captured to bottom of ${o}`:`Captured to top of ${o}`;break;case"insertAfter":{let l=this.resolvedInsertAfterHeading??this.choice.insertAfter.after;a=l?`Captured to ${o} under '${l}'`:`Captured to ${o}`;break}case"insertBefore":{let l=this.choice.insertBefore?.before;a=l?`Captured to ${o} before '${l}'`:`Captured to ${o}`;break}default:a=`Captured to ${o}`;break}new Zc.Notice(a,UD)}showNothingToCaptureNotice(t,{wasNewFile:n}){let i=`'${t.basename}'`;new Zc.Notice(n?`Created ${i} \u2014 nothing to capture (no content)`:`Nothing to capture \u2014 ${i} unchanged`,UD)}hasActiveMarkdownCaptureContext(){let t=!!this.app.workspace.getActiveFile(),n=!!On(this.app);return t&&n}shouldSkipRequiredCanvasLinkInsertion(t,n){return n&&t.destination?.type!=="specifiedFile"&&t.requireActiveFile&&!this.hasActiveMarkdownCaptureContext()}async insertCaptureLink(t,n,{isCanvasTriggered:i}){if(!n.enabled)return;if(n.destination?.type==="specifiedFile"){await kT(this.app,t,n);return}if(Zd(n.placement)){await tp(this.app,t,n);return}if(this.shouldSkipRequiredCanvasLinkInsertion(n,i)){this.plugin.settings.showCaptureNotification&&new Zc.Notice("Canvas capture skipped link insertion because no Markdown editor is focused.",UD);return}let o=this.choiceExecutor.focusedProperty;if(o){await IT(this.app,o,t);return}await tp(this.app,t,n)}async copyCapturedFileLinkToClipboard(t){if(this.choice.copyLinkToClipboard)try{await ST(t)}catch(n){F.logWarning(`Could not copy link to clipboard for '${t.path}': ${n instanceof Error?n.message:String(n)}`)}}validateAppendLinkDestination(t){return!t.enabled||t.destination.type!=="specifiedFile"||zv(this.app,t.destination)?!0:(this.failRun(`Append link target file not found or is not a Markdown file: ${t.destination.path}`),!1)}async run(){let t=!1;try{this.capturePropertyVars.clear();let n=xu(this.choice.appendLink);if(this.formatter.setLinkToCurrentFileBehavior(n.enabled&&!n.requireActiveFile?"optional":"required"),!this.validateAppendLinkDestination(n))return;let i=this.choice.useSelectionAsCaptureValue,o=this.plugin.settings.useSelectionAsCaptureValue??!0,s=typeof i=="boolean"?i:o;this.formatter.setUseSelectionAsCaptureValue(s);let a=FK(this.choice),l=a==="currentLine"||a==="newLineAbove"||a==="newLineBelow",c=this.choice.captureToActiveFile?$K(this.app,a):null,u=await this.resolveConfiguredCanvasTarget(a),d=c??u;if(d?.kind==="text"){await this.handleCanvasTextCapture(d,a,n,()=>{t=!0});return}if(d?.kind==="file"&&(a==="insertAfter"&&this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation==="cursor"||a==="insertBefore"&&this.choice.insertBefore?.createIfNotFound&&this.choice.insertBefore?.createIfNotFoundLocation==="cursor"))throw new Ee("Canvas file cards do not support creating missing line targets at cursor. Use top or bottom.");let f=d?.kind==="file"?d.source==="configured"?d.targetFile?.path??d.targetPath:d.targetFile.path:await this.getFormattedPathToCaptureTo(this.choice.captureToActiveFile);if(!d&&!this.choice.captureToActiveFile&&qr.test(f))throw new Ee("Capture to a .canvas file requires a target canvas node id.");let p=this.getCaptureContent(),m,v=await this.fileExists(f);!v&&this.choice?.createFileIfItDoesntExist?.enabled&&eE(f),this.isInsertAfterHeadingMode()&&!qr.test(f)&&await this.maybeResolveInsertAfterHeading(await this.readNoteBodyForHeadingPicker(f,v));let g=!v&&!!this.choice?.createFileIfItDoesntExist?.enabled&&!this.choice?.createFileIfItDoesntExist?.createWithTemplate;if(this.suppressFrontmatterCollection=!g,this.suppressFrontmatterCollection&&/\{\{(?:VALUE|FILE|FIELD):[^}]*\|\s*multi(?=[:}|]|$)/i.test(this.choice?.format?.format??"")&&F.logWarning("QuickAdd: {{VALUE:\u2026|multi}}, {{FILE:\u2026|multi}} and {{FIELD:\u2026|multi}} in this capture write comma-separated strings, not YAML lists. Multi-select produces a real list only when capturing into a brand-new note's front matter (Create file if it doesn't exist, without a template)."),v)m=this.onFileExists.bind(this);else if(this.choice?.createFileIfItDoesntExist?.enabled)m=((se,M,U)=>this.onCreateFileIfItDoesntExist(se,M,n));else throw new Ee(`Target file missing: ${f}. Enable "Create file if it doesn't exist" or choose an existing file.`);let{file:y,newFileContent:w,captureContent:x,priorContent:C,cursorEndOffset:_,cursorPlacementSafe:E=!0}=await m(f,p),D=null,P=E,V=!1,j=wye(x);if(this.captureResolvedOrderedHeading(),l)if(j)t=!0;else{let se=await pc(this.app,x,y),M=!1;switch(a){case"currentLine":M=k0(se,this.app);break;case"newLineAbove":M=D0(se,this.app);break;case"newLineBelow":M=I0(se,this.app);break}if(!M){await this.cleanupCreatedClipboardAttachments(),this.failRun(`Capture "${this.choice.name}": no active Markdown editor to insert into.`);return}t=!0}else{await this.app.vault.modify(y,w),t=!0,this.choice.templater?.afterCapture==="wholeFile"&&(await Xd(this.app,y),P=!1,V=!0);let se=await this.applyCapturePropertyVars(y);se&&(P=!1),se&&(V=!0),D=P?w:null}let oe=l?j?"unchanged":"changed":v?w!==C||V?"changed":"unchanged":"created";if(this.outcome.success(y,oe),this.plugin.settings.showCaptureNotification&&(j?this.showNothingToCaptureNotice(y,{wasNewFile:!v}):this.showSuccessNotice(y,{wasNewFile:!v,action:a})),await this.copyCapturedFileLinkToClipboard(y),await this.insertCaptureLink(y,n,{isCanvasTriggered:!!d}),this.choice.openFile&&y){let se=dn(this.choice.fileOpening),M=se.focus??!0;rp(this.app,y,M)||await mc(this.app,y,{...se,originLeaf:this.originLeaf}),!await wu(this.app,y)&&P&&M&&D!==null&&typeof _=="number"&&P0(this.app,y,_,D)}}catch(n){if(t||await this.cleanupCreatedClipboardAttachments(),md(n,{logPrefix:"Capture execution aborted",noticePrefix:"Capture execution aborted",defaultReason:"Capture aborted"})){this.choiceExecutor.signalAbort?.(n);return}Gi.getInstance().markExecutionScopeFailed(),this.outcome.failure(ID(n)),lt(n,`Error running capture choice "${this.choice.name}"`)}finally{t&&this.formatter.consumeCreatedClipboardAttachmentPaths()}}failRun(t){Gi.getInstance().markExecutionScopeFailed(),F.logError(t),this.outcome.failure(t)}async cleanupCreatedClipboardAttachments(){let t=this.formatter.consumeCreatedClipboardAttachmentPaths();for(let n of t)try{let i=this.app.vault.getAbstractFileByPath(n);i instanceof Zc.TFile&&await this.app.fileManager.trashFile(i)}catch(i){F.logWarning(`QuickAdd: failed to clean up clipboard attachment '${n}': ${String(i)}`)}}async handleCanvasTextCapture(t,n,i,o){if(n==="currentLine"||n==="newLineAbove"||n==="newLineBelow")throw new Ee("Canvas text cards support top, bottom, insert-after, and insert-before positions only.");if(n==="insertAfter"&&this.choice.insertAfter?.createIfNotFound&&this.choice.insertAfter?.createIfNotFoundLocation==="cursor"||n==="insertBefore"&&this.choice.insertBefore?.createIfNotFound&&this.choice.insertBefore?.createIfNotFoundLocation==="cursor")throw new Ee("Canvas text cards do not support creating missing line targets at cursor. Use top or bottom.");let s=t.canvasFile;this.formatter.setTitle(Mg(s.basename)),this.formatter.setDestinationFile(s);let a=this.getCaptureContent(),l=NK(t);this.isInsertAfterHeadingMode()&&await this.maybeResolveInsertAfterHeading(l);let c=await this.formatter.formatContentWithFile(a,this.choice,l,s);this.captureResolvedOrderedHeading();let u=c===l;if(u||await LK(this.app,t,c),o(),this.outcome.success(s,u?"unchanged":"changed"),this.plugin.settings.showCaptureNotification&&(u?this.showNothingToCaptureNotice(s,{wasNewFile:!1}):this.showSuccessNotice(s,{wasNewFile:!1,action:n})),await this.copyCapturedFileLinkToClipboard(s),await this.insertCaptureLink(s,i,{isCanvasTriggered:!0}),this.choice.openFile&&s){let d=dn(this.choice.fileOpening),f=d.focus??!0;rp(this.app,s,f)||await mc(this.app,s,{...d,originLeaf:this.originLeaf}),await wu(this.app,s)}}async resolveConfiguredCanvasTarget(t){if(this.choice.captureToActiveFile)return null;let n=this.choice.captureTo?.trim()??"",i=this.choice.captureToCanvasNodeId?.trim()??"";if(!n||!i)return null;let o=await this.formatFilePath(n);return qr.test(o)?await OK(this.app,o,i,t):null}assertInteractiveCaptureTarget(){if(this.choiceExecutor.interactive===!1)throw new Ee(`'${this.choice.name}' needs to ask which note to capture into, but this run is non-interactive. Point "Capture to" at a specific file, or re-run with the ui flag.`)}async maybeResolveInsertAfterHeading(t){let n=this.choice.insertAfter;if(!n?.enabled||!n.promptHeading)return;let i=!!n.createIfNotFound,o=mf(t),s=Qc(o),a=s.map(p=>o[p.line]),l=s.map(p=>`${" ".repeat(Math.max(0,p.level-1))}${p.text}`),c=s.map(p=>p.text),u="Choose a heading to insert under",d=String(await ia(this.choiceExecutor,{remote:p=>oa(p,{items:a.map((m,v)=>({value:m,title:l[v]??m})),placeholder:u,allowCustomInput:i,what:"the heading picker"}),headless:()=>{throw new Ee(`'${this.choice.name}' needs to ask which heading to capture under, but this run is non-interactive. Turn off "Choose heading when capturing" and set a fixed heading, or re-run with the ui flag.`)},app:()=>an.Suggest(this.app,l,a,{allowCustomValue:i,placeholder:u,emptyStateText:i?"No headings found \u2014 type a heading to create":"No headings found in the target note",customValueLabel:p=>`Insert after new line: ${p}`})}));Mi(!!d&&d.length>0,"No heading selected for capture."),this.formatter.setInsertAfterTargetOverride(d);let f=a.indexOf(d);this.resolvedInsertAfterHeading=f>=0?c[f]:d}isInsertAfterHeadingMode(){return!!this.choice.insertAfter?.enabled&&!!this.choice.insertAfter.promptHeading}async readNoteBodyForHeadingPicker(t,n){if(!n)return"";let i=this.app.vault.getAbstractFileByPath(t);return i instanceof Zc.TFile?await this.app.vault.read(i):""}getCaptureContent(){let t;return this.choice.format.enabled?t=this.choice.format.format:t=Ms,this.choice.task&&(t=`- [ ] ${t}
|
||
`),t}async getFormattedPathToCaptureTo(t){if(t){let a=this.app.workspace.getActiveFile();return Mi(a,"Cannot capture to active file - no active file."),a.path}let n=this.getPreselectedCaptureTargetPath();if(n!==void 0){let a=BD({isFolder:l=>om(this.app,l),markdownFileExists:l=>this.app.vault.getAbstractFileByPath(LD(l))instanceof Zc.TFile},this.choice.captureTo??"",!1);if(a){let l=this.confinePreselectedToScope(a,n);if(l!==null)return this.normalizeCaptureFilePath(l)}}let i=this.choice.captureTo,o=await this.formatter.formatFileName(i,"captureTarget"),s=this.resolveCaptureTarget(o);switch(s.kind){case"vault":return this.selectFileInFolder("",!0);case"filter":return this.selectFileWithFilter(s.filter);case"property":return this.selectFileWithProperty(s.field,s.value,s.filter);case"folder":return this.selectFileInFolder(s.folder,!1);case"file":return this.normalizeCaptureFilePath(s.path)}}getPreselectedCaptureTargetPath(){let t=this.choiceExecutor?.variables?.get(Gd);return typeof t=="string"&&t.length>0?t:void 0}confinePreselectedToScope(t,n){let i=this.stripLeadingSlash(n);if(t.kind==="folder")return t.folderPathSlash&&!i.startsWith(t.folderPathSlash)?`${t.folderPathSlash}${i}`:i;if(this.resolveScopeFiles(t).some(l=>l.path===i))return i;if(!(this.choice.createFileIfItDoesntExist?.enabled??!1))return null;let a=new Set(this.app.vault.getMarkdownFiles().map(l=>l.basename.toLowerCase()));return this.captureTargetAlreadyExists(i,a)?null:i}resolveScopeFiles(t){switch(t.kind){case"filter":return sm(this.app,t.filter);case"property":return am(this.app,t.field,t.value,t.filter);case"tag":return Xv(this.app,t.tag);case"folder":return rs(this.app,t.folderPathSlash)}}resolveCaptureTarget(t){return PK(t,{getAbstractFileByPath:n=>this.app.vault.getAbstractFileByPath(n),isFolder:n=>om(this.app,n),normalizeMarkdownFilePath:(n,i)=>this.normalizeMarkdownFilePath(n,i)})}captureTargetExists(t,n){let i=n.startsWith(t)?n:`${t}${n}`,o;try{o=ai(i,"Capture target file path")}catch{return!1}let s=[o];return/\.(md|canvas)$/i.test(o)||s.push(`${o}.md`,`${o}.canvas`),s.some(a=>!!this.app.vault.getAbstractFileByPath(a))}async selectFileInFolder(t,n){let i=t.endsWith("/")||n?t:`${t}/`,o=rs(this.app,i),s=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(s||o.length>0,`Folder ${i} is empty.`);let a=hf(o,gf(this.app)),l=a.map(v=>v.path),c=Tc(a,v=>this.app.metadataCache.getFileCache(v)),u=l.map((v,g)=>`${c[g]??v} ${v}`),d=new Set(c.map(v=>v.toLowerCase())),f=s?"Choose a note or type to create one":void 0,p=String(await ia(this.choiceExecutor,{remote:v=>oa(v,{items:l.map((g,y)=>({value:g,title:c[y]??g})),placeholder:f,allowCustomInput:s,what:"the capture-target picker"}),headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>an.Suggest(this.app,c,l,{placeholder:f,emptyStateText:s?"Type a note name to create it":void 0,renderItem:(v,g)=>dE(g,v,this.app),searchItems:u,allowCustomValue:s,customValueLabel:v=>`Create new note: ${v}`,valueExists:v=>d.has(v.toLowerCase())||this.captureTargetExists(i,v)})}));Mi(!!p&&p.length>0,"No file selected for capture.");let m=p.startsWith(`${i}`)?p:`${i}${p}`;return await this.formatFilePath(m)}async selectFileWithFilter(t){let n=sm(this.app,t);return this.selectFileFromSet(n,"No files matched the capture target filters.")}async selectFileWithProperty(t,n,i){let o=am(this.app,t,n,i),s=n!==void 0?`${t}=${n}`:t;return this.selectFileFromSet(o,`No notes with property ${s}.`)}captureTargetAlreadyExists(t,n){let i=t.trim();if(!i)return!1;let o;try{o=ai(i,"Capture target file path")}catch{return!1}let s=o.replace(/\.(md|canvas)$/i,"");if([o,`${s}.md`,`${s}.canvas`].some(c=>!!this.app.vault.getAbstractFileByPath(c)))return!0;let l=s.slice(s.lastIndexOf("/")+1);return n.has(l.toLowerCase())}async selectFileFromSet(t,n){let i=this.choice.createFileIfItDoesntExist?.enabled??!1;Mi(i||t.length>0,n);let o=hf(t,gf(this.app)),s=o.map(m=>m.path),a=Tc(o,m=>this.app.metadataCache.getFileCache(m)),l=s.map((m,v)=>`${a[v]??m} ${m}`),c=new Set(this.app.vault.getMarkdownFiles().map(m=>m.basename.toLowerCase())),u=new Set(a.map(m=>m.toLowerCase())),d=m=>u.has(m.toLowerCase())||this.captureTargetAlreadyExists(m,c),f=i?"Choose a note or type to create one":void 0,p=String(await ia(this.choiceExecutor,{remote:async m=>{let v=await oa(m,{items:s.map((g,y)=>({value:g,title:a[y]??g})),placeholder:f,allowCustomInput:i,what:"the capture-target picker"});if(!s.includes(v)&&d(v))throw new Error(`"${v}" already exists but is not one of the notes this capture targets. Pick one of the offered notes, or type a name that does not exist yet.`);return v},headless:()=>{throw this.assertInteractiveCaptureTarget(),new Error("unreachable")},app:()=>an.Suggest(this.app,a,s,{placeholder:f,emptyStateText:i?"Type a note name to create it":void 0,renderItem:(m,v)=>dE(v,m,this.app),searchItems:l,allowCustomValue:i,customValueLabel:m=>`Create new note: ${m}`,valueExists:d})}));return Mi(!!p&&p.length>0,"No file selected for capture."),await this.formatFilePath(p)}async onFileExists(t,n){let i=this.getFileByPath(t);if(!i)throw new Error("File not found");this.formatter.setTitle(i.basename),this.formatter.setDestinationFile(i);let o=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let s=await this.app.vault.read(i),a=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(o,this.choice,s,i));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let l=this.formatter.getCaptureInsertionEndOffset(),c=await this.app.vault.read(i),u=a,d=!0;if(c!==s){let f=hK(c,s,a);Mi(f.isSuccess(),()=>`The file ${t} has been modified since the last read.
|
||
QuickAdd could not merge the versions two without conflicts, and will not modify the file.
|
||
This is in order to prevent data loss.`),u=f.joinedResults(),d=!1}return{file:i,newFileContent:u,captureContent:o,priorContent:c,cursorEndOffset:l??void 0,cursorPlacementSafe:d}}async onCreateFileIfItDoesntExist(t,n,i){eE(t);let o=Mg(t);this.formatter.setTitle(o),this.formatter.setDestinationSourcePath(t);let s=await this.collectIfFrontmatter(()=>this.formatter.formatContentOnly(n));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let a="";if(this.choice.createFileIfItDoesntExist.createWithTemplate){let f=new tE(this.app,this.plugin,this.choice.createFileIfItDoesntExist.template,this.choiceExecutor);i?.enabled&&!i.requireActiveFile&&f.setLinkToCurrentFileBehavior("optional"),f.setTargetFolderPath(Wo(t)),f.setPromptRunContext({draftScopeId:`${this.choice.id}#${this.choice.createFileIfItDoesntExist.template}`,choiceName:this.choice.name,destination:t,destinationKind:"file"}),a=await f.run();let p=f.getAndClearTemplatePropertyVars();F.logMessage(`CaptureChoiceEngine: Collected ${p.size} template property variables`),p.size>0&&F.logMessage(`Variables: ${Array.from(p.keys()).join(", ")}`),this.templatePropertyVars=p}let l=await this.createFileWithInput(t,a,{suppressTemplaterOnCreate:this.choice.createFileIfItDoesntExist.createWithTemplate});this.choice.createFileIfItDoesntExist.createWithTemplate&&this.templatePropertyVars&&Pg(l,this.templatePropertyVars)&&await Fg(this.app,l,this.templatePropertyVars),this.choice.createFileIfItDoesntExist.createWithTemplate&&a?await Xd(this.app,l):qv(this.app)&&await T0(this.app,l);let c=await this.app.vault.read(l),u=await this.collectIfFrontmatter(()=>this.formatter.formatContentWithFile(s,this.choice,c,l));this.mergeCapturePropertyVars(this.formatter.getAndClearTemplatePropertyVars());let d=this.formatter.getCaptureInsertionEndOffset();return{file:l,newFileContent:u,captureContent:s,priorContent:c,cursorEndOffset:d??void 0,cursorPlacementSafe:!0}}async formatFilePath(t){let n=await this.formatter.formatFileName(t,"captureTarget");return this.normalizeCaptureFilePath(n)}normalizeCaptureFilePath(t){let n=ai(this.stripLeadingSlash(t),"Capture target file path");if(Vi.test(n))throw new Ee(`Capture to '.base' files is not supported (${n}). Use a Template choice instead.`);let i=this.normalizeCaptureFilePathExtension(n);if(!Mg(i).trim())throw new Ee(`Capture target file name is empty after formatting ('${i}'). Make sure the tokens in 'Capture to' produce a value.`);if(Un(i))throw new Ee(`Refusing to capture to a file outside the vault: "${i}".`);return i}normalizeCaptureFilePathExtension(t){let n=t.match(ir)?.[0];if(n)return`${ai(t.replace(ir,""),"Capture target file path")}${n}`;let i=t.match(qr)?.[0];return i?`${ai(t.replace(qr,""),"Capture target file path")}${i}`:this.normalizeMarkdownFilePath("",t)}collectIfFrontmatter(t){return this.suppressFrontmatterCollection?t():this.formatter.withTemplatePropertyCollection(t)}mergeCapturePropertyVars(t){if(!(!t||t.size===0)){for(let[n,i]of t)this.capturePropertyVars.set(n,i);F.logMessage(`CaptureChoiceEngine: Accumulated ${this.capturePropertyVars.size} structured capture variables`)}}async applyCapturePropertyVars(t){return this.capturePropertyVars.size===0?!1:Pg(t,this.capturePropertyVars)?(F.logMessage(`CaptureChoiceEngine: Post-processing front matter with ${this.capturePropertyVars.size} capture variables`),await Fg(this.app,t,this.capturePropertyVars),this.capturePropertyVars.clear(),!0):(this.capturePropertyVars.clear(),!1)}};Zx();var Cs=require("obsidian");Fo();Cr();Wr();It();Wt();nm();var xN=require("obsidian");Tt();Wc();qt();Cr();function BK(r){let e=r.split("/").pop()??r,t=e.lastIndexOf(".");return t>0?e.slice(0,t):e}function EN(r){let e=new rd(BK(r));return e.id=`folder-template:${r}`,e.templatePath=r,e.openFile=!0,e.fileNameFormat={enabled:!0,format:Ms},e.discoverExistingNotesBeforeCreate=!0,e}function TN(r){return Wi(r.settings.templateFolderPaths).length>0}function Cye(r,e){let t=r.lastIndexOf("/"),n=t===-1?"":r.slice(0,t),i=e.createDiv({cls:"suggestion-content"});i.createDiv({cls:"suggestion-title",text:BK(r)}),n&&(e.classList.add("mod-complex"),i.createDiv({cls:"suggestion-note",text:n}))}async function xye(r,e){let n=[...e].sort((i,o)=>i.path.localeCompare(o.path)).map(i=>i.path);try{return await Nr.Suggest(r,n,n,"New note from template",(i,o)=>Cye(i,o))}catch(i){if(Dt(i))return null;throw i}}async function qD(r,e,t){try{let n=t.templatePath?.trim()||void 0;if(!n){if(!TN(e)){new xN.Notice("QuickAdd: Set a template folder in Settings \u2192 QuickAdd \u2192 Templates & properties to use \u201CNew note from template\u201D.",8e3),ug(r,e.manifest.id,{notice:!1});return}let i=e.getTemplateFiles();if(i.length===0){new xN.Notice("QuickAdd: No template files found in your configured template folder(s).");return}let o=await xye(r,i);if(!o)return;n=o}await t.choiceExecutor.execute(EN(n))}catch(n){if(Dt(n))return;lt(n,"Error running template from folder")}}Wt();fc();var Eye="\u2190 Back",Tye="Select a choice";function yE(r){return Ws(r)?`QuickAdd couldn't read the contents of "${r.name}". They're still in data.json.`:`Folder "${r.name}" is empty.`}var _ye="Empty",Aye="Unreadable";function kye(r){return _N(r)?Ws(r)?Aye:_ye:""}var vE="quickadd:run-template-from-folder",Sye="New note from template\u2026",Qg="quickadd:back";function _N(r){return r.type==="Multi"&&r.id!==Qg&&st(r).length===0}var Dye=.5;function Iye(r){return r.replace(/\[\[([^\]|]+)\|([^\]]+)\]\]/g,"$2").replace(/\[\[([^\]]+)\]\]/g,"$1").replace(/\[([^\]]*)\]\([^)]*\)/g,"$1").replace(/(\*\*|__)(.+?)\1/g,"$2").replace(/\*(.+?)\*/g,"$1").replace(/`([^`]+)`/g,"$1").replace(/~~(.+?)~~/g,"$1")}function AN(r){return(r.settings.templateFolderLauncherRow??"bottom")!=="off"&&TN(r)}function Pye(){return{id:vE,name:Sye,type:"Template",command:!1}}var bf=class r extends Cs.FuzzySuggestModal{constructor(t,n,i){super(t.app);this.plugin=t;this.choices=n;this.focusedProperty=null;this.triggerContext=null;this.placeholderStack=[];this.selectionDispatched=!1;this.breadcrumbById=new Map;this.markdownComponent=new Cs.Component;this.warnRenderFailure=mp("Could not render a choice name as Markdown; showing it as plain text");if(this.choiceExecutor=i?.choiceExecutor??new Ri(this.app,this.plugin),this.focusedProperty=i&&"focusedProperty"in i?i.focusedProperty??null:DT(this.app),this.triggerContext=i&&"triggerContext"in i?i.triggerContext??null:{activeFile:this.app.workspace.getActiveFile()},this.placeholderStack=i?.placeholderStack??[],this.completion=i?.completion,this.currentPlaceholder=i?.placeholder?.trim()||Tye,this.setPlaceholder(this.currentPlaceholder),this.markdownComponent.load(),i?.includeTemplateFolderRow){let o=this.plugin.settings.templateFolderLauncherRow??"bottom";if(AN(this.plugin)){let s=Pye();this.choices=o==="top"?[s,...this.choices]:[...this.choices,s]}}}static Open(t,n,i){new r(t,n,i).open()}onClose(){super.onClose(),this.markdownComponent.unload(),this.completion&&!this.selectionDispatched&&this.completion(tn())}getSuggestions(t){let n=t.trim();if(!n||!ce.getState().searchNestedChoices)return super.getSuggestions(n);let i=(0,Cs.prepareFuzzySearch)(n),o=[];for(let s of this.getNestedSearchCandidates()){let a=i(s.text);a&&(s.nameOffset>0&&a.matches.length>0&&a.matches.every(([,l])=>l<=s.nameOffset)&&(a.score-=Dye),o.push({item:s.choice,match:a}))}return o.sort((s,a)=>a.match.score-s.match.score),o}getNestedSearchCandidates(){if(!this.nestedSearchCandidates){let t=this.choices.filter(n=>n.id!==Qg&&n.id!==vE);this.nestedSearchCandidates=ly(t).map(({choice:n,path:i})=>{let o=i.slice(0,-1);o.length>0&&this.breadcrumbById.set(n.id,o.map(Iye).join(" / "));let s=i.join(" / ");return{choice:n,text:s,nameOffset:s.length-n.name.length}})}return this.nestedSearchCandidates}selectSuggestion(t,n){if(_N(t.item)){if("repeat"in n&&n.repeat)return;new Cs.Notice(yE(t.item)),this.inputEl.focus();return}this.selectionDispatched=!0,super.selectSuggestion(t,n)}renderSuggestion(t,n){n.empty(),n.classList.remove("mod-complex");let i=this.breadcrumbById.get(t.item.id),o=n.createDiv({cls:"quickadd-choice-suggestion-content"});this.renderChoiceIcon(t.item,o);let s;if(i){n.classList.add("mod-complex");let c=o.createDiv({cls:"suggestion-content quickadd-choice-suggestion-text"});s=c.createDiv({cls:"suggestion-title"}),c.createDiv({cls:"suggestion-note",text:i})}else s=o.createDiv({cls:"quickadd-choice-suggestion-title quickadd-choice-suggestion-text"});Cs.MarkdownRenderer.render(this.app,t.item.name,s,"",this.markdownComponent).catch(c=>{s.textContent=t.item.name,this.warnRenderFailure(c)}),n.classList.add("quickadd-choice-suggestion"),t.item.id===Qg&&n.classList.add("quickadd-choice-suggestion-back"),t.item.id===vE&&n.classList.add("quickadd-choice-suggestion-run-template");let a=kye(t.item),l=a!=="";if(n.classList.toggle("quickadd-choice-suggestion-empty",l),l){n.setAttribute("aria-disabled","true");let c=zr(o,"span");c.classList.add("quickadd-choice-suggestion-empty-flair"),c.textContent=a,o.appendChild(c)}else n.removeAttribute("aria-disabled")}renderChoiceIcon(t,n){let i=this.getChoiceSuggestionIcon(t);if(!i)return;let o=zr(n,"span");o.classList.add("quickadd-choice-icon"),o.setAttribute("aria-hidden","true"),n.appendChild(o),(0,Cs.setIcon)(o,i)}getChoiceSuggestionIcon(t){if(t.id!==Qg)return t.id===vE?"file-plus":wm(t)}getItemText(t){return t.name}getItems(){return this.choices}settleCompletion(t,n){t.then(()=>this.completion?.(),i=>{Jf(i,n),this.completion?.(i)})}onChooseItem(t,n){if(t.id===vE){this.settleCompletion(qD(this.app,this.plugin,{choiceExecutor:this.choiceExecutor}),"Could not run a template from that folder");return}if(t.type==="Multi")this.onChooseMultiType(t);else{let i=this.choiceExecutor.executeWithFocusedProperty?this.choiceExecutor.executeWithFocusedProperty(t,this.focusedProperty,this.triggerContext):this.choiceExecutor.execute(t);this.settleCompletion(i,`Could not run "${t.name}"`)}}onChooseMultiType(t){let n=t.id===Qg;if(!n&&_N(t)){new Cs.Notice(yE(t)),this.completion?.();return}let i=[...st(t)];if(!n){let a=new eg(Eye).addChoices(this.choices);a.id=Qg,i.push(a)}let o=n?this.placeholderStack[this.placeholderStack.length-1]:t.placeholder?.trim()||t.name,s=n?this.placeholderStack.slice(0,-1):[...this.placeholderStack,this.currentPlaceholder];r.Open(this.plugin,i,{choiceExecutor:this.choiceExecutor,focusedProperty:this.focusedProperty,triggerContext:this.triggerContext,placeholder:o,placeholderStack:s,completion:this.completion})}};It();Tt();Os();Me();nN();Hs();jP();var UK=require("obsidian");Cu();$m();Tt();Yr();Ii();qt();Me();NT();Hs();vl();Tt();$m();vy();uh();vl();_y();ip();Ru();O1();Hs();var bE=class extends yl{constructor(t,n,i){super(t);this.app=t;this.plugin=n;this.choiceExecutor=i;this.requirements=new Map;this.templatesToScan=new Set;this.scannedTemplateRefDepths=new Map;this.scanningPathContext=!1;this.scanningScope="generic";this.scanningSoleValue=!1;this.dateParser=El,i&&(this.variables=new Map(i.variables))}warn(){}reportProblem(){}async scanString(t,n=!1,i="generic"){let o=this.scanningPathContext,s=this.scanningScope,a=this.scanningSoleValue;this.scanningPathContext=n,this.scanningScope=i,this.scanningSoleValue=C_(i,t);try{let l=await this.replaceGlobalVarInString(t);if(this.scanVariableTokens(l),this.scanDateTokens(l),this.scanFileTokens(l),n){if(new RegExp(uc.source,"i").test(l)){let c=this.requirements.get("value");c&&(c.pathContext=!0)}if(new RegExp(wT.source,"i").test(l)){let c=this.requirements.get("mvalue");c&&(c.pathContext=!0)}}await this.format(l)}finally{this.scanningPathContext=o,this.scanningScope=s,this.scanningSoleValue=a}}markScanContext(t){this.scanningPathContext&&(t.pathContext=!0)}async format(t){let n=t;n=await this.replaceGlobalVarInString(n),n=this.replaceDateInString(n),n=this.replaceTimeInString(n),n=await this.replaceValueInString(n),n=await this.replaceSelectedInString(n),n=await this.replaceClipboardInString(n),n=await this.replaceDateVariableInString(n),n=await this.replaceVariableInString(n),n=await this.replaceFieldVarInString(n),n=await this.replaceFileInString(n),n=await this.replaceMathValueInString(n),n=this.replaceRandomInString(n);{let i=new RegExp(Rs.source,"gi"),o;for(;(o=i.exec(n))!==null;){let s=o[1];s&&this.templatesToScan.add(s)}}return n}async replaceGlobalVarInString(t){let n=t,i=0,o=new RegExp(pl.source,"gi");for(;o.test(n)&&!(++i>5);)n=n.replace(o,(s,a)=>{let l=String(a??"").trim();if(!l)return s;let c=this.plugin?.settings?.globalVariables?.[l];return typeof c=="string"?c:""});return n}scanVariableTokens(t){let n=new RegExp(Hd.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=(i[1]??"").trim();if(!o)continue;let s=Ey(o,{warn:this.warnSink});if(!s)continue;let{variableName:a,variableKey:l,label:c,defaultValue:u,displayValues:d,hasOptions:f}=s;if(!a)continue;let p=f&&c?c:a,m=!f&&c?c:void 0,v=l;if(this.requirements.has(v)){let g=this.requirements.get(v);if(this.markScanContext(g),f&&!this.hasOptionList(g)&&(g.type=this.optionFieldType(s),g.label=p,this.applyOptionFields(g,s),g.defaultValue!==void 0&&!s.allowCustomInput)){let y=KP(g.defaultValue);g.defaultValue=s.suggestedValues.includes(y)?y:void 0}u&&g.defaultValue===void 0&&(g.defaultValue=u),!g.displayOptions&&d&&(g.displayOptions=d),g.optional=(g.optional??!1)&&s.optional}else{let g=!f&&s.inputTypeOverride==="checkbox",y=!f&&s.inputTypeOverride==="number",w=!f&&s.inputTypeOverride==="slider",x=s.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",C={id:v,label:p,type:f?this.optionFieldType(s):g?"dropdown":y?"number":w?"slider":x,description:m,optional:s.optional};f?this.applyOptionFields(C,s):g?C.options=["true","false"]:y?C.numericConfig=s.numericConfig:w&&(C.numericConfig=s.numericConfig,C.sliderConfig=s.sliderConfig),u&&(C.defaultValue=u),this.markScanContext(C),this.requirements.set(v,C)}}}optionFieldType(t){return t.allowCustomInput||t.multiSelect?"suggester":"dropdown"}hasOptionList(t){return Array.isArray(t.options)&&t.options.length>0}applyOptionFields(t,n){t.options=n.suggestedValues,n.displayValues&&(t.displayOptions=n.displayValues),n.multiSelect?t.multiEmit=n.multiEmit??"text":delete t.multiEmit,n.allowCustomInput||n.multiSelect?t.suggesterConfig={allowCustomInput:n.allowCustomInput,caseSensitive:!1,multiSelect:n.multiSelect??!1}:delete t.suggesterConfig}scanDateTokens(t){let n=new RegExp(gu.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=i[1]?.trim();if(!o)continue;let{defaultValue:s,optional:a,withTime:l}=Ty(i[3]),c=i[2]?.trim()||(l?"YYYY-MM-DD HH:mm":"YYYY-MM-DD"),u=this.requirements.get(o);u?(u.type==="date"&&s&&u.defaultValue===void 0&&(u.defaultValue=s),u.optional=(u.optional??!1)&&a,u.type==="date"&&l&&!u.withTime&&(u.withTime=!0,i[2]?.trim()||(u.dateFormat="YYYY-MM-DD HH:mm"))):this.requirements.set(o,{id:o,label:o,type:"date",defaultValue:s,dateFormat:c,withTime:l,optional:a,source:"collected"})}}async promptForValue(t){let n="value";if(!this.requirements.has(n)){let i=this.valuePromptContext?.inputTypeOverride==="checkbox",o=this.valuePromptContext?.inputTypeOverride==="number",s=this.valuePromptContext?.inputTypeOverride==="slider",a=E_(this.scanningScope,this.scanningSoleValue);this.requirements.set(n,{id:n,label:a.title||t||"Enter value",type:i?"dropdown":o?"number":s?"slider":this.valuePromptContext?.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",description:this.valuePromptContext?.description,placeholder:a.placeholder,defaultValue:this.valuePromptContext?.defaultValue,numericConfig:this.valuePromptContext?.numericConfig,sliderConfig:this.valuePromptContext?.sliderConfig,options:i?["true","false"]:void 0,source:"collected",optional:this.valuePromptContext?.optional})}return this.markScanContext(this.requirements.get(n)),""}async promptForVariable(t,n){if(!t)return"";let i=n?.variableKey??t;if(n?.type==="VDATE")return n.defaultValue??"@date:1970-01-01T00:00:00.000Z";if(!this.requirements.has(i)){let o=wy(t).map(f=>f.trim()).filter(Boolean),s=o.length>1,a=!s&&n?.inputTypeOverride==="number",l=!s&&n?.inputTypeOverride==="slider",c=!s&&n?.inputTypeOverride==="checkbox",u=n?.inputTypeOverride==="multiline"||this.plugin.settings.inputPrompt==="multi-line"?"textarea":"text",d={id:i,label:t,type:s||c?"dropdown":a?"number":l?"slider":u,description:n?.description,numericConfig:n?.numericConfig,sliderConfig:n?.sliderConfig,source:"collected"};s?d.options=o:c&&(d.options=["true","false"]),n?.defaultValue&&(d.defaultValue=n.defaultValue),this.requirements.set(i,d)}return this.markScanContext(this.requirements.get(i)),n?.defaultValue??""}async promptForMathValue(){let t="mvalue";return this.requirements.has(t)||this.requirements.set(t,{id:t,label:"Math expression",type:"text",placeholder:"e.g., 2+2*3"}),this.markScanContext(this.requirements.get(t)),""}async suggestForField(t){let n=Yi.parse(t),i=`${jd}${t}`;if(!this.requirements.has(i)){let o={id:i,label:n.fieldName||t,type:"field-suggest",source:"collected",runtimeOnly:n.multiSelect};if(!n.multiSelect&&n.filters.defaultFrom==="active"){let s=sD(this.app,this.choiceExecutor?.triggerContext?.activeFile??null,n.fieldName),a=(typeof s=="string"?s:void 0)??n.filters.defaultValue;a!==void 0&&(o.defaultValue=a)}this.requirements.set(i,o)}return""}scanFileTokens(t){let n=new RegExp(bT.source,"gi"),i;for(;(i=n.exec(t))!==null;){let o=w_(i[1]??"");o&&this.recordFileRequirement(o)}}recordFileRequirement(t){let n=t.variableKey,i=this.requirements.get(n);if(i){i.optional=(i.optional??!1)&&t.optional,i.type="file-picker",i.suggesterConfig={allowCustomInput:(i.suggesterConfig?.allowCustomInput??!1)||t.allowCustomInput,caseSensitive:!1,multiSelect:(i.suggesterConfig?.multiSelect??!1)||t.multiSelect};return}let o=zi.filterFiles(this.app.vault.getMarkdownFiles(),t.filter,u=>this.app.metadataCache.getFileCache(u)),s=o.map(u=>`${gl}${u.path}`),a=Tc(o,u=>this.app.metadataCache.getFileCache(u)),l=t.allowCustomInput||s.length===0,c=t.mode==="name"?`File from ${t.folderPath}`:`File from ${t.folderPath} (${t.mode})`;this.requirements.set(n,{id:n,label:t.label??c,type:"file-picker",source:"collected",options:s,displayOptions:a,optional:t.optional,suggesterConfig:{allowCustomInput:l,caseSensitive:!1,multiSelect:t.multiSelect}})}suggestForFile(t){return""}async suggestForValue(t,n,i){return""}getVariableValue(t){return""}async getTemplateContent(t){return""}async getSelectedText(){return""}async getClipboardContent(){return""}getCurrentFileLink(){return null}getCurrentFileName(){return null}async getMacroValue(t,n){return""}isTemplatePropertyTypesEnabled(){return!1}};vy();var Fye=["text","number","textarea","dropdown","slider","date","field-suggest","file-picker","suggester"];function Mye(r){return typeof r=="string"&&Fye.includes(r)}function Rye(r){if(!r||typeof r!="object")return null;let e=r,t=e.id,n=e.type;if(typeof t!="string"||!Mye(n))return null;let i=$ye(e.numericConfig),o=Oye(e.sliderConfig),s=n==="slider"&&!o?"number":n;return{id:t,label:typeof e.label=="string"?e.label:t,type:s,placeholder:typeof e.placeholder=="string"?e.placeholder:void 0,defaultValue:typeof e.defaultValue=="string"?e.defaultValue:void 0,numericConfig:o??i,sliderConfig:o,options:Array.isArray(e.options)?e.options.filter(a=>typeof a=="string"):void 0,dateFormat:typeof e.dateFormat=="string"?e.dateFormat:void 0,description:typeof e.description=="string"?e.description:void 0,optional:typeof e.optional=="boolean"?e.optional:void 0,source:"script"}}function $ye(r){if(!r||typeof r!="object")return;let e=r,t=typeof e.min=="number"&&Number.isFinite(e.min)?e.min:void 0,n=typeof e.max=="number"&&Number.isFinite(e.max)?e.max:void 0,i=typeof e.step=="number"&&Number.isFinite(e.step)&&e.step>0?e.step:void 0;if(t!==void 0&&n!==void 0&&n<t)return i===void 0?void 0:{step:i};let o={};return t!==void 0&&(o.min=t),n!==void 0&&(o.max=n),i!==void 0&&(o.step=i),Object.keys(o).length>0?o:void 0}function Oye(r){if(!r||typeof r!="object")return;let e=r,t=typeof e.min=="number"?e.min:void 0,n=typeof e.max=="number"?e.max:void 0,i=e.step===void 0?1:typeof e.step=="number"?e.step:void 0;if(!(t===void 0||n===void 0||i===void 0||!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(i)||n<=t||i<=0))return{min:t,max:n,step:i}}function Nye(r){let e=t=>{if(!t||typeof t!="object"&&typeof t!="function")return[];let n=t.quickadd;if(!n||typeof n!="object")return[];let i=n.inputs;return Array.isArray(i)?i:[]};return e(r)}async function VK(r,e){let t=po(r,e);return t?await r.vault.cachedRead(t):""}function Lye(r){let e=new Set,t=new RegExp(Rs.source,"gi"),n;for(;(n=t.exec(r))!==null;)n[1]&&e.add(n[1]);return e}async function yd(r,e,t,n=new Set,i=0,o="generic"){let s=x_(o),a=Lye(t);e.templatesToScan.clear(),await e.scanString(t,s,o);let l=[...e.templatesToScan].filter(c=>a.has(c));if(e.templatesToScan.clear(),!(i>=q_))for(let c of l){if(n.has(c))continue;let u=`${s?"path":"content"}:${c}`,d=e.scannedTemplateRefDepths.get(u);if(!(d!==void 0&&d<=i)){e.scannedTemplateRefDepths.set(u,i),n.add(c);try{await yd(r,e,await VK(r,c),n,i+1,o)}finally{n.delete(c)}}}}async function qK(r,e,t){if(await e.scanString(t,!0,"templatePath"),_u(t)){F.logMessage(`Preflight: template path "${t}" uses format syntax; its body's prompts are collected at run time, not in the one-page form.`);return}await yd(r,e,await VK(r,t),new Set([t]),0,"noteBody")}async function Bye(r,e,t,n){let i=new bE(r,e,t);if(n.fileNameFormat?.enabled&&await yd(r,i,n.fileNameFormat.format,void 0,0,"noteTitle"),n.folder?.enabled)for(let o of n.folder.folders??[])await yd(r,i,o,void 0,0,"folder");return n.templatePath&&await qK(r,i,n.templatePath),i}function Uye(r){let e=On(r);return e?e.editor.getSelection():""}async function Vye(r,e,t,n,i){let o=new bE(r,e,t);await yd(r,o,n.captureTo,void 0,0,"captureTarget"),n.format?.enabled&&await yd(r,o,n.format.format,void 0,0,"captureText"),n.insertAfter?.enabled&&!n.insertAfter.promptHeading&&await yd(r,o,n.insertAfter.after,void 0,0,"lineTarget"),n.insertBefore?.enabled&&await yd(r,o,n.insertBefore.before,void 0,0,"lineTarget");let s=n.createFileIfItDoesntExist;s?.enabled&&s.createWithTemplate&&s.template&&await qK(r,o,s.template);let a=BD({isFolder:l=>om(r,l),markdownFileExists:l=>r.vault.getAbstractFileByPath(LD(l))instanceof UK.TFile},n.captureTo??"",n.captureToActiveFile);if(a){let l=[];switch(a.kind){case"property":l=am(r,a.field,a.value,a.filter);break;case"filter":l=sm(r,a.filter);break;case"tag":l=Xv(r,a.tag);break;case"folder":l=rs(r,a.folderPathSlash);break}let c=hf(l,gf(r)),u=c.map(p=>p.path),d=Tc(c,p=>r.metadataCache?.getFileCache(p)??null),f=n.createFileIfItDoesntExist?.enabled??!1;u.length===0&&f?o.requirements.set(Gd,{id:Gd,label:"Select capture target file",type:"file-picker",source:"collected",options:u,displayOptions:d,runtimeOnly:!0,placeholder:"Type a new note name in the capture target picker"}):o.requirements.set(Gd,{id:Gd,label:"Select capture target file",type:"dropdown",options:u,displayOptions:d,placeholder:u.length?void 0:"No files found in target scope"})}if(i){let l=n.useSelectionAsCaptureValue,c=e.settings.useSelectionAsCaptureValue??!0;if(typeof l=="boolean"?l:c){let d=t.variables.get("value");if(d==null){let f=Uye(r);f.trim().length>0&&t.variables.set("value",f)}}}return o}async function qye(r,e,t){let n=[],i=Dr(e?.macro?.commands);for(let o of i){if(o?.type!=="UserScript")continue;let s=o;try{let a=OT(s),l=a!==void 0?t?.get(a):void 0;l===void 0&&(l=await Aa(s,r,{reportLoadErrors:!1}),a!==void 0&&l!==void 0&&t?.set(a,l));let c=Nye(l);for(let u of c){let d=Rye(u);d&&n.push(d)}}catch(a){let l=s.path??s.id,c=a instanceof Error?a.message:String(a);if(OB(a)){F.logMessage(`QuickAdd preflight could not inspect user script '${l}': ${c}`);continue}F.logWarning(`Preflight could not inspect user script '${l}': ${c}`)}}return n}async function wE(r,e,t,n,i){let o=null,s=[];if(n.type==="Template")o=await Bye(r,e,t,n);else if(n.type==="Capture")o=await Vye(r,e,t,n,i?.seedCaptureSelectionAsValue??!1);else if(n.type==="Macro")s=await qye(r,n,i?.preloadedUserScripts);else return[];let a=new Map;for(let l of o?Array.from(o.requirements.values()):[])a.set(l.id,l);for(let l of s)a.has(l.id)||a.set(l.id,l);return Array.from(a.values())}function CE(r,e){return r.filter(t=>{let n=U_(e,t.id);return n?e.get(n)==null:!0})}function WK(r,e){let t=r.trim();if(!t)return[];let n=Array.from(e.keys()).sort((s,a)=>a.length-s.length),i=[],o=t;for(;o.length>0;){let s=n.find(a=>o===a||o.startsWith(`${a}, `));if(!s)break;i.push(s),o=o===s?"":o.slice(s.length+2)}if(o.length>0)for(let s of o.split(",")){let a=s.trim();a&&i.push(a)}return i}function Wye(r,e,t){let n=r.filter(o=>t||e.includes(o)),i=new Set(n);return[...e.filter(o=>i.has(o)),...n.filter((o,s)=>!e.includes(o)&&n.indexOf(o)===s)]}function zye(r,e){if(r.type!=="Template"||e!=="value")return!1;let t=r,n=t.fileNameFormat?.enabled?t.fileNameFormat.format:Ms;return BR(t,n)}async function zK(r,e,t,n){try{let i=await wE(r,e,t,n,{seedCaptureSelectionAsValue:!0,preloadedUserScripts:t.preloadedUserScripts});if(i.length===0)return!1;let o=CE(i,t.variables);if(o.length===0)return!1;let s=o.filter(p=>!p.runtimeOnly&&!zye(n,p.id));if(s.length===0)return!1;let a=async p=>{try{let m=new hh(r,e),v=[];if(n.type==="Template"){let g=n;if(g.fileNameFormat?.enabled){m.setTargetFolderPath(LA(g.folder)??"Folder/Name");for(let[y,w]of Object.entries(p))m.variables.set(y,w);v.push({label:"File name",text:await m.format(g.fileNameFormat.format),diagnostics:m.diagnostics.list()})}}return v}catch{return[]}},l=t.promptProvider,c=null,u;l?u=await l.requestInputs(s):(c=new Vg(r,s,t.variables,a),u=await c.waitForClose);let d=new Map,f=new Map;for(let p of s){if(p.id.startsWith(hy)){let m=p.options??[],v=p.displayOptions??m;d.set(p.id,{options:m,displayToValue:new Map(m.map((g,y)=>[(v[y]??g).trim(),g])),allowCustom:p.suggesterConfig?.allowCustomInput??!1,multiSelect:p.suggesterConfig?.multiSelect??!1})}if(p.suggesterConfig?.multiSelect&&!p.id.startsWith(hy)){let m=p.options??[],v=p.displayOptions??m,g=new Map;m.forEach((y,w)=>{g.set((v[w]??y).trim(),y)}),f.set(p.id,{emit:p.multiEmit??"text",allowCustom:p.suggesterConfig.allowCustomInput??!1,displayToValue:g})}}return Object.entries(u).forEach(([p,m])=>{let v=d.get(p);if(v!==void 0){let w=c?.fileSelections.get(p)??(Array.isArray(m)?m.map(String):void 0)??(v.multiSelect?WK(String(m),v.displayToValue).map(_=>v.displayToValue.get(_)??_):[String(m)]),C=Wye(w,v.options,v.allowCustom).map(_=>xV(_,v.options));t.variables.set(p,v.multiSelect?C:C[0]??"");return}let g=f.get(p);if(g!==void 0){let w=(c?.multiSelections.get(p)??WK(String(m),g.displayToValue)).filter(x=>g.allowCustom||g.displayToValue.has(x)).map(x=>g.displayToValue.get(x)??x);t.variables.set(p,g.emit==="linklist"?w.map(N_):w);return}t.variables.set(p,m)}),!0}catch(i){if(i instanceof Nt)throw i;return t.promptProvider||F.logWarning(`One-page input failed for choice "${n.name}"; falling back to step-by-step prompts: ${i instanceof Error?i.message:String(i)}`),!1}}Os();Co();Wr();Cr();qt();Tm();nm();Wt();var Ri=class{constructor(e,t){this.app=e;this.plugin=t;this.variables=new Map;this.interactive=!0;this.preloadedUserScripts=new Map;this.focusedProperty=null;this.triggerContext=null;this.pendingAbort=null;this.pendingResult=null;this.executionDepth=0}signalAbort(e){this.pendingAbort=e}consumeAbortSignal(){let e=this.pendingAbort;return this.pendingAbort=null,e??null}recordExecutionResult(e){this.pendingResult=e}beginExecutionContext(){this.executionDepth===0&&(this.focusedProperty=this.focusedPropertyOverride!==void 0?this.focusedPropertyOverride:DT(this.app),this.triggerContext=this.triggerContextOverride!==void 0?this.triggerContextOverride:{activeFile:this.app.workspace.getActiveFile()}),this.executionDepth++}endExecutionContext(){this.executionDepth=Math.max(0,this.executionDepth-1),this.executionDepth===0&&(this.focusedProperty=null,this.triggerContext=null,this.preloadedUserScripts.clear())}async execute(e){this.pendingAbort=null;let t=this.pendingResult;this.beginExecutionContext();let n=Yv(this.app),i=Gi.getInstance();i.beginExecutionScope();try{switch(await this.runOnePagePreflightIfEnabled(e),e.type){case"Template":{let o=e;await this.onChooseTemplateType(o,n);break}case"Capture":{let o=e;await this.onChooseCaptureType(o,n);break}case"Macro":{let o=e;await this.onChooseMacroType(o,n);break}case"Multi":{let o=e;await this.onChooseMultiType(o);break}default:break}if(this.pendingAbort){i.rollbackExecutionScope();return}i.commitExecutionScope()}catch(o){throw i.rollbackExecutionScope(),o}finally{this.pendingResult=t,this.endExecutionContext()}}async executeWithFocusedProperty(e,t,n){let i=this.focusedPropertyOverride,o=this.triggerContextOverride;this.focusedPropertyOverride=t,this.triggerContextOverride=n;try{await this.execute(e)}finally{this.focusedPropertyOverride=i,this.triggerContextOverride=o}}async executeWithOutcome(e){this.pendingAbort=null,this.pendingResult=null,this.beginExecutionContext();let t=Yv(this.app),n=Gi.getInstance();n.beginExecutionScope();try{if(await this.runOnePagePreflightIfEnabled(e),e.type==="Template"?await this.onChooseTemplateType(e,t):await this.onChooseCaptureType(e,t),this.pendingAbort){n.rollbackExecutionScope();let o=this.consumeAbortSignal(),s=o instanceof St;return{status:"cancelled",cancelKind:s?"user":"aborted",reason:s?void 0:o?.message}}n.commitExecutionScope();let i=this.pendingResult;return this.pendingResult=null,i??{status:"error"}}catch(i){return n.rollbackExecutionScope(),i instanceof St?{status:"cancelled",cancelKind:"user"}:i instanceof Nt?{status:"cancelled",cancelKind:"aborted",reason:i.message}:(lt(i,"Error executing choice from URI"),{status:"error",reason:i instanceof Error?i.message:String(i)})}finally{this.endExecutionContext()}}async runOnePagePreflightIfEnabled(e){let t=ce.getState().onePageInputEnabled,n=e.onePageInput,i=this.promptProvider!=null;if((n==="always"||n!=="never"&&(t||i))&&(e.type==="Template"||e.type==="Capture"||e.type==="Macro"))try{await zK(this.app,this.plugin,this,e)}catch(s){throw Dt(s)?new St("One-page input cancelled by user"):s}}async onChooseTemplateType(e,t){await new PD(this.app,this.plugin,e,this,t).run()}async onChooseCaptureType(e,t){await new VD(this.app,this.plugin,e,this,t).run()}async onChooseMacroType(e,t){let n=new ql(this.app,this.plugin,e,this,this.variables,this.preloadedUserScripts,void 0,t);await n.run(),Object.entries(n.params.variables).forEach(([i,o])=>{this.variables.set(i,o)})}async onChooseMultiType(e){let t=st(e);if(this.promptProvider||this.interactive===!1){let n=this.promptProvider?"Run one of its choices directly.":"Run one of its choices directly, or re-run with the ui flag.";this.signalAbort(new Ee(t.length===0?yE(e):`"${e.name}" is a folder of choices, and picking from it needs someone at the window. ${n}`));return}if(t.length===0){new HK.Notice(yE(e));return}await new Promise((n,i)=>{bf.Open(this.plugin,t,{choiceExecutor:this,focusedProperty:this.focusedProperty,triggerContext:this.triggerContext,placeholder:e.placeholder?.trim()||e.name,completion:o=>o===void 0?n():i(o)})})}};qt();var jK=require("obsidian");var Hye="QuickAdd: No choices yet. Create your first one in Settings \u2192 QuickAdd.";function kN(r){let e=Array.isArray(r.settings.choices)?r.settings.choices:[];if(!(e.length>0||AN(r))){new jK.Notice(Hye,8e3),ug(r.app,r.manifest.id,{notice:!1});return}bf.Open(r,e,{includeTemplateFolderRow:!0})}oN();Me();Me();qt();var GK={description:"Use QuickAdd template folder instead of Obsidian templates plugin folder / Templater templates folder.",migrate:async r=>{try{let e=r.app.plugins.plugins.templater,t=r.app.internalPlugins.plugins.templates;if(!e&&!t){F.logMessage("No template plugin found. Skipping migration.");return}let n=[];if(t){let s=t.instance.options;s.folder&&(n.push(s.folder),F.logMessage("Migrated template folder path to Obsidian Templates' setting."))}if(e){let s=e.settings;s.template_folder&&(n.push(s.template_folder),F.logMessage("Migrated template folder path to Templaters setting."))}let i=Wi(r.settings.templateFolderPaths),o=Wi([...i,...n]);o.length>0&&(r.settings.templateFolderPaths=o)}catch(e){throw F.logError("Failed to migrate template folder path."),e}}};vi();function WD(r){return r===null||typeof r!="object"||!("type"in r)||!("choices"in r)?!1:r.type==="Multi"&&Array.isArray(r.choices)}function zD(r){return r===null||typeof r!="object"||!("choice"in r)?!1:r.choice!==void 0}Wt();Ii();function YK(r){return typeof r=="object"&&r!==null&&"type"in r&&r.type==="Template"&&"incrementFileName"in r}function KK(r){for(let e of r)WD(e)&&(e.choices=KK(e.choices)),YK(e)&&(e.setFileExistsBehavior=!0,e.fileExistsMode="Increment the file name",delete e.incrementFileName);return r}function jye(r){for(let e of r)for(let t of Dr(Wn(e)))zD(t)&&YK(t.choice)&&(t.choice.setFileExistsBehavior=!0,t.choice.fileExistsMode="Increment the file name",delete t.choice.incrementFileName);return r}var Gye={description:"'Increment file name' setting moved to 'Set default behavior if file already exists' setting",migrate:async r=>{let e=r.settings,t=!ym(r.settings.choices)&&!Di(e.macros);if(Array.isArray(r.settings.choices)){let o=ht(r.settings.choices);r.settings.choices=ht(KK(o))}let n=ht(Dh(e.macros)),i=jye(n);if(Array.isArray(e.macros)&&(e.macros=i),!t)return{complete:!1}}},XK=Gye;vi();function QK(r){return typeof r=="object"&&r!==null&&"type"in r&&r.type==="Template"}function Yye(r){return r.fileExistsBehavior?r.fileExistsBehavior:r.setFileExistsBehavior?{kind:"apply",mode:Oj(r.fileExistsMode)??"increment"}:r.incrementFileName?{kind:"apply",mode:"increment"}:{kind:"prompt"}}function ZK(r){r.fileExistsBehavior=Yye(r),delete r.incrementFileName,delete r.setFileExistsBehavior,delete r.fileExistsMode}var Kye={description:"Re-run template file collision normalization for users with older migration state",migrate:async r=>{let e=r.settings,t=!sg(e);if(Array.isArray(r.settings.choices)&&(r.settings.choices=ht(r.settings.choices)),Array.isArray(e.macros)&&(e.macros=ht(e.macros)),ag(r,n=>{QK(n)&&ZK(n)}),!t)return{complete:!1}}},HD=Kye;var Xye={description:"Repair template file collision settings that may have been left in legacy format",migrate:HD.migrate},JK=Xye;Wt();function SN(r){return Ye(r)&&r.type==="Capture"}vi();Wt();Ii();function e7(r){for(let e of r)WD(e)&&(e.choices=e7(e.choices)),SN(e)&&e.insertAfter?.enabled&&e.prepend&&(e.prepend=!1);return r}function Qye(r){for(let e of r)for(let t of Dr(Wn(e)))zD(t)&&SN(t.choice)&&t.choice.insertAfter?.enabled&&t.choice.prepend&&(t.choice.prepend=!1);return r}var Zye={description:"Mutual exclusion of insertAfter and writeToBottomOfFile settings. If insertAfter is enabled, writeToBottomOfFile is disabled. To support changes in settings UI.",migrate:async r=>{let e=r.settings,t=!ym(r.settings.choices)&&!Di(e.macros);if(Array.isArray(r.settings.choices)){let o=ht(r.settings.choices);r.settings.choices=e7(o)}let n=ht(Dh(e.macros)),i=Qye(n);if(Array.isArray(e.macros)&&(e.macros=i),!t)return{complete:!1}}},t7=Zye;It();var Jye={description:"Set version to the current plugin version.",migrate:async r=>{ce.setState({version:r.manifest.version})}},r7=Jye;es();It();vi();var ebe={description:"Add default AI providers to the settings.",migrate:async r=>{let e=ce.getState().ai,t=ht(mT);if("OpenAIApiKey"in e&&typeof e.OpenAIApiKey=="string"){let n=t.find(i=>i.name==="OpenAI");n&&(n.apiKey=e.OpenAIApiKey)}"OpenAIApiKey"in e&&delete e.OpenAIApiKey,ce.setState({ai:{...ce.getState().ai,providers:t}})}},n7=ebe;Me();Wt();Ii();var tbe={description:"Remove macro indirection - embed macros directly in macro choices",migrate:async r=>{let e=r.settings;if(ym(e.choices))return F.logMessage("QuickAdd could not read part of the choice list, so legacy macros were left in place to be migrated later."),{complete:!1};if(!Array.isArray(e.choices))return F.logMessage("QuickAdd could not read the choice list, so legacy macros were left in place to be migrated later."),{complete:!1};if(Di(e.macros))return F.logMessage("QuickAdd could not read the legacy macro list, so it was left in place to be migrated later."),{complete:!1};let t=Dh(e.macros),n=new Map,i=Bn(e.choices);for(let o of i)if(o.type==="Macro"){let s=o;if(s.macroId){let a=s.macroId;n.has(a)||n.set(a,[]),n.get(a).push(s)}}for(let o of t){if(!o||typeof o!="object"||typeof o.id!="string"||o.id==="")continue;let s=n.get(o.id)??i.filter(a=>a.type==="Macro"&&a.macro?.id===o.id);if(s.length===0){let a=new Jh(o.name);a.macro={id:o.id,name:o.name,commands:o.commands||[]},a.runOnStartup=o.runOnStartup||!1,e.choices.push(a)}else for(let a of s)a.macro={id:o.id,name:o.name,commands:o.commands||[]},a.runOnStartup??(a.runOnStartup=o.runOnStartup??!1),delete a.macroId}for(let o of i)if(o.type==="Macro"){let s=o;s.macroId&&(F.logMessage(`Removing orphaned macroId reference: ${s.macroId}`),delete s.macroId)}"macros"in e&&delete e.macros}},i7=tbe;Me();function jD(r){if(r==null)return null;if(typeof r=="boolean")return{enabled:r};if(typeof r!="object")return null;let e=r;return{enabled:typeof e.enabled=="boolean"?e.enabled:void 0,direction:e.direction==="horizontal"||e.direction==="vertical"?e.direction:void 0,focus:typeof e.focus=="boolean"?e.focus:void 0}}function GD(r,e){let t=r.direction==="horizontal"?"horizontal":"vertical",n=typeof e=="string"&&e!=="default"?e:"default";return dn({location:r.enabled?"split":"tab",direction:t,focus:r.focus??!0,mode:n})}var rbe={description:"Migrate legacy openFileInNewTab settings to new fileOpening format",migrate:async r=>{F.logMessage("Starting migration of file opening settings...");let e=sg(r.settings),t=0;if(ag(r,i=>{if(i.type!=="Template"&&i.type!=="Capture")return;let o=i,s=o.openFileInNewTab,a=o.openFileInMode,l=jD(s);if(!o.fileOpening&&l){let c={enabled:l?.enabled??!1,direction:l?.direction??"vertical",focus:l?.focus??!0};o.fileOpening=GD(c,a??"default"),t++,F.logMessage(`Migrated file opening settings for choice: ${i.name}`)}}),F.logMessage(`Migration complete. Migrated ${t} choices.`),e)return{complete:!1}}},o7=rbe;Me();var nbe={description:"Backfill missing file opening defaults for older choices",migrate:async r=>{F.logMessage("Starting file opening defaults backfill...");let e=sg(r.settings),t=0;if(ag(r,i=>{if(i.type!=="Template"&&i.type!=="Capture")return;let o=i,s=typeof o.fileOpening=="object"&&o.fileOpening!==null?o.fileOpening:void 0,a=o,l=a.openFileInNewTab,c=a.openFileInMode,u=jD(l);(!s||s.location==null||s.direction==null||s.mode==null||s.focus==null)&&(!s&&u?o.fileOpening=GD(u,c):o.fileOpening=dn(s),t++)}),F.logMessage(`File opening defaults backfill complete. Updated ${t} choice(s).`),e)return{complete:!1}}},s7=nbe;It();vi();var ibe={description:"Ensure every AI provider has a discovery mode so browsing works without models.dev",migrate:async r=>{let t=ce.getState().ai.providers??[],n=!1;for(let i of t)i.modelSource||(i.modelSource="auto",n=!0);n&&ce.setState(i=>({...i,ai:{...i.ai,providers:ht(t)}}))}},a7=ibe;vi();Me();It();vi();Xp();var obe={description:"Move AI provider API keys into Obsidian SecretStorage",migrate:async r=>{let e=ce.getState().ai.providers??[],t=()=>e.some(o=>(o.apiKey?.trim()??"")!==""),n=r.app?.secretStorage;if(!n?.getSecret||!n?.setSecret)return t()?(F.logWarning("SecretStorage unavailable; deferring AI provider API key migration until it is available."),{complete:!1}):void 0;let i=!1;for(let o of e){let s=o.apiKey?.trim(),a=o.apiKeyRef?.trim();if(a){try{let l=await Promise.resolve(n.getSecret(a));!l&&s?(await Promise.resolve(n.setSecret(a,s)),o.apiKey="",i=!0):l&&s&&(o.apiKey="",i=!0)}catch(l){F.logWarning(`Failed to migrate secret for ${o.name}: ${l.message??l}`)}continue}if(s)try{let l=await bY(r.app,o,s);l&&(o.apiKeyRef=l,o.apiKey="",i=!0)}catch(l){F.logWarning(`Failed to store API key for ${o.name}: ${l.message??l}`)}}if(i&&ce.setState(o=>({...o,ai:{...o.ai,providers:ht(e)}})),t())return{complete:!1}}},l7=obe;qt();var c7={description:"Move the single template folder path into the multi-folder list.",migrate:async r=>{let e=r.settings,t=Wi(e.templateFolderPaths);t.length>0?e.templateFolderPaths=t:e.templateFolderPaths=Wi([e.templateFolderPath]),delete e.templateFolderPath}};es();Yr();It();vi();Me();function sbe(r){for(let e of[r,`https://${r}`])try{let t=new URL(e).hostname.toLowerCase();if(t)return t}catch{}return""}function abe(r){let e=sbe(r.endpoint??"");return e==="api.openai.com"?"openai":e==="generativelanguage.googleapis.com"?"google":e==="api.anthropic.com"?"anthropic":null}function lbe(r,e,t){let n=new Set(e==="anthropic"?[]:R2[e]);r.models=r.models.filter(o=>!n.has(o.name));let i=new Map(r.models.map(o=>[o.name,o]));for(let o of $v[e]){let s=i.get(o.name);s?(s.maxTokens=o.maxTokens,s.maxOutputTokens=o.maxOutputTokens,s.supportsTemperature=o.supportsTemperature):t.has(o.name)||r.models.push({...o})}}var cbe={temperature:1,top_p:1,frequency_penalty:0,presence_penalty:0};function ube(r){return r.type==="AIAssistant"}var dbe={description:"Refresh built-in AI provider model lists: drop retired models, add the current generation, and turn on auto-sync.",migrate:async r=>{let e=ce.getState(),t=ht(e.ai.providers??[]),n=ht(e.choices??[]),i=new Set;for(let l of t){let c=abe(l);if(!c)continue;let u=new Set(t.filter(p=>p!==l).flatMap(p=>p.models.map(m=>m.name))),d=l.models.map(p=>p.name);lbe(l,c,u);let f=new Set(l.models.map(p=>p.name));for(let p of d)f.has(p)||i.add(p);l.autoSyncModels=!0,c==="openai"&&(l.modelSource="modelsDev")}let o=new Set(t.flatMap(l=>l.models.map(c=>c.name))),s=new Set([...i].filter(l=>!o.has(l)));dS({choices:n},l=>{if(!ube(l))return;l.model&&s.has(l.model)&&(F.logMessage(`AI command "${l.name}" used ${l.model}, which its provider has retired. It now asks for a model when it runs.`),l.model="Ask me");let c=l.modelParameters;if(c&&typeof c=="object")for(let[u,d]of Object.entries(cbe))c[u]===d&&delete c[u]});let a=s.has(e.ai.defaultModel)?"Ask me":e.ai.defaultModel;ce.setState({choices:n,ai:{...ce.getState().ai,defaultModel:a,providers:t}})}},u7=dbe;es();It();vi();Me();function pbe(r,e){return r.find(t=>t.models.some(n=>n.name===e))}var fbe={description:"Pin AI commands' models to the provider they currently resolve to, and give every provider a stable id.",migrate:async r=>{let e=ce.getState(),t=ht(e.ai.providers??[]),n=ht(e.choices??[]);pT(t),pS(n,t,(s,a)=>{F.logMessage(`Pinned AI command "${s.name}"'s model to ${a.providerId}/${a.name}.`)});let i,o=e.ai.defaultModel;if(e.ai.defaultModelRef&&e.ai.defaultModelRef.name===o)i=e.ai.defaultModelRef;else if(o&&o!=="Ask me"){let s=pbe(t,o);s?.id&&(i={providerId:s.id,name:o},F.logMessage(`Pinned the default model to ${s.id}/${o}.`))}ce.setState({choices:n,ai:{...ce.getState().ai,providers:t,...i?{defaultModelRef:i}:{}}})}},d7=fbe;It();var DN={useQuickAddTemplateFolder:GK,incrementFileNameSettingMoveToDefaultBehavior:XK,consolidateFileExistsBehavior:HD,repairTemplateFileExistsBehavior:JK,mutualExclusionInsertAfterAndWriteToBottomOfFile:t7,setVersionAfterUpdateModalRelease:r7,addDefaultAIProviders:n7,removeMacroIndirection:i7,migrateFileOpeningSettings:o7,backfillFileOpeningDefaults:s7,setProviderModelDiscoveryMode:a7,migrateProviderApiKeysToSecretStorage:l7,migrateToMultipleTemplateFolders:c7,refreshStaleDefaultModelSeeds:u7,pinAiModelRefs:d7};async function mbe(r){let e=Object.keys(DN).filter(t=>!r.settings.migrations[t]);if(e.length===0){F.logMessage("No migrations to run.");return}ce.replaceState(ht(r.settings));for(let t of e){F.logMessage(`Running migration ${t}: ${DN[t].description}`);let n=ht(r.settings),i=ce.getState();try{let o=await DN[t].migrate(r);ce.getState()!==i&&(r.settings=ht(ce.getState()));let s=o?.complete===!1;s||(r.settings.migrations[t]=!0),ce.replaceState(ht(r.settings)),F.logMessage(s?`Migration ${t} incomplete; will retry on a later launch.`:`Migration ${t} successful.`)}catch(o){F.logError(`Migration '${t}' was unsuccessful. Please create an issue with the following error message:
|
||
|
||
${o}
|
||
|
||
QuickAdd will now revert to backup.`),r.settings=n,ce.replaceState(ht(r.settings))}}r.saveSettings()}var p7=mbe;It();var Hl=require("obsidian");Me();async function hbe(r,e,t){let n=await(0,Hl.requestUrl)({url:`https://api.github.com/repos/${r}/${e}/releases`,throw:!1}),i=n.json;if(n.status>=400||!Array.isArray(i)){let a=typeof i=="object"&&i!==null&&"message"in i&&typeof i.message=="string"?i.message:"Unknown error";throw new Error(`Failed to fetch releases: ${a}`)}let o=i,s=o.findIndex(a=>a.tag_name===t);if(s===-1)throw new Error(`Could not find release with tag ${t}`);return o.slice(0,s).filter(a=>!a.draft&&!a.prerelease)}var IN=/^https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+$/,f7=/^\[!\[[^\]]*\]\(([^)\s"]+)\)\]\((https:\/\/github\.com\/user-attachments\/assets\/[A-Za-z0-9-]+)\)$/,gbe=/^<!--\s*poster:\s*(https:\/\/[^\s"'>]+)\s*-->$/;function vbe(r,e){let t=e?` poster="${e}"`:"";return`<video controls preload="metadata" playsinline style="width: 100%; border-radius: 8px;" src="${r}"${t}></video>`}function ybe(r){let e=r.split(`
|
||
`),t=new Set;for(let s of e){let a=s.trim();IN.test(a)&&t.add(a)}let n=new Map;for(let s of e){let a=s.trim().match(f7);a&&t.has(a[2])&&n.set(a[2],a[1])}let i=new Set;for(let s=0;s<e.length;s++)if(IN.test(e[s].trim()))for(let a of[1,-1]){let l=s+a;for(;l>=0&&l<e.length&&e[l].trim()==="";)l+=a;let c=l>=0&&l<e.length?e[l].trim().match(gbe):null;if(c){n.set(e[s].trim(),c[1]),i.add(l);break}}let o=[];for(let s=0;s<e.length;s++){let a=e[s],l=a.trim();if(i.has(s))continue;let c=l.match(f7);if(!(c&&t.has(c[2]))){if(IN.test(l)){o.push(vbe(l,n.get(l)));continue}o.push(a)}}return o.join(`
|
||
`)}function bbe(r,e=1){let t=r.split(`
|
||
`);for(let n=0;n<t.length;n++)t[n].startsWith("#")&&(t[n]="#".repeat(e)+t[n]);return t.join(`
|
||
`)}var YD=class extends Hl.Modal{constructor(t,n){super(t);this.markdownComponent=new Hl.Component;this.isClosed=!1;this.previousVersion=n,this.releaseNotesPromise=hbe("chhoumann","quickadd",n),this.releaseNotesPromise.then(i=>{if(!this.isClosed){if(this.releases=i,this.releases.length===0){this.close();return}this.display()}}).catch(i=>{F.logError(`Failed to fetch release notes: ${i}`)})}onOpen(){let{contentEl:t}=this;t.empty(),t.createEl("h1",{text:"Fetching release notes..."}),this.addCloseFooter()}addCloseFooter(){let t=this.contentEl.createDiv("quickadd-update-modal-footer");new Hl.ButtonComponent(t).setButtonText("Done").setCta().onClick(()=>this.close())}onClose(){let{contentEl:t}=this;this.isClosed=!0,this.markdownComponent.unload(),t.empty()}display(){let{contentEl:t}=this;t.empty(),t.classList.add("quickadd-update-modal-container");let n=`### New in QuickAdd v${this.releases[0].tag_name}
|
||
`,i="Thank you for using QuickAdd! If you like the plugin, please consider supporting me by buying me a coffee. With your sponsorship, I'll be able to contribute more to my existing projects, start new ones, and be more responsive to issues & feature requests.",o='<div class="quickadd-bmac-container"><a href="https://www.buymeacoffee.com/chhoumann" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" style="height: 40px !important;width: 144px !important;" ></a></div>',s=t.createDiv("quickadd-update-modal"),a=this.releases.map(d=>ybe(d.body??"")).join(`
|
||
---
|
||
`),l=`And now, here is everything new in QuickAdd since your last update (v${this.previousVersion}):`,u=`${n}
|
||
${i}
|
||
${o}
|
||
I'd love to get your feedback on QuickAdd! Please fill out this <a href="https://forms.gle/WRq1ewcKK8qmkqps6">feedback form</a> to let me know what you think.
|
||
|
||
${l}
|
||
|
||
---
|
||
|
||
${bbe(a)}`;this.markdownComponent.load(),Hl.MarkdownRenderer.render(this.app,u,s,this.app.vault.getRoot().path,this.markdownComponent),this.addCloseFooter()}};nD();Wr();Co();var wbe=25e3,Cbe=6e4,xbe=3e4,Ebe=75e3,Tbe=32;function _be(r,e){if(r.length!==e.length)return!1;let t=0;for(let n=0;n<r.length;n++)t|=r.charCodeAt(n)^e.charCodeAt(n);return t===0}function Abe(r){if(r.origin||r.referer)return!1;let e=(r.host??"").split(":")[0];return e==="127.0.0.1"||e==="localhost"}function kbe(r){try{let e=window.require;return e?e(r):null}catch{return null}}function KD(){let r=window.crypto;if(r?.randomUUID)return r.randomUUID();if(r?.getRandomValues){let e=r.getRandomValues(new Uint8Array(16));return Array.from(e,t=>t.toString(16).padStart(2,"0")).join("")}throw new Error("Interactive prompts require a secure random source (crypto), which is unavailable here.")}var XD="No pending prompt for that requestId",PN="The interactive client disconnected, so the run was ended.";function Sbe(r,e){if(e.cancelled!==void 0&&typeof e.cancelled!="boolean")return`The "cancelled" flag must be the literal true (or omitted). A cancel that is not recognised would otherwise be answered on the user's behalf.`;if(e.cancelled===!0)return null;if(r==="confirm"){let t=e.value;if(!(t===!0||t===!1||t==="true"||t==="false"))return`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Dbe(t)}.`}return null}function Dbe(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}var FN=class{constructor(){this.server=null;this.port=0;this.sessions=new Map;this.startPromise=null;this.generation=0}async ensureStarted(){if(this.server)return this.port;if(this.startPromise)return this.startPromise;let e=kbe("http");if(!e)throw new Error("Interactive prompts require desktop Obsidian (Node http is unavailable).");let t=this.generation;return this.startPromise=new Promise((n,i)=>{let o=e.createServer((s,a)=>{this.handle(s,a)});o.on("error",s=>{this.generation===t&&(this.startPromise=null),i(s)}),o.listen(0,"127.0.0.1",()=>{if(this.generation!==t){o.close(),i(new Error("Interactive server stopped during startup."));return}let s=o.address();this.port=typeof s=="object"&&s?s.port:0,this.server=o,n(this.port)})}),this.startPromise}createSession(){if(this.sessions.size>=Tbe)throw new Error("Too many active interactive sessions.");let e=KD(),t=KD()+KD(),n={id:e,token:t,queue:[],waiter:null,waiterTimer:null,pending:new Map,finished:!1,aborted:!1,cleanupTimer:null,attached:!1,attachTimer:null,pollWatchdog:null};return n.attachTimer=window.setTimeout(()=>{!n.attached&&!n.finished&&this.finish(n.id,{kind:"error",error:"No client attached to the interactive session."})},xbe),this.sessions.set(e,n),{id:e,token:t}}emitPrompt(e,t){let n=this.sessions.get(e);if(!n)return Promise.reject(new Error("Unknown session"));if(n.finished)return Promise.reject(new Ee(PN));if(n.aborted)return Promise.reject(new St(yu));let i=KD();return new Promise((o,s)=>{n.pending.set(i,{resolve:o,reject:s,promptType:t.type}),this.push(n,{kind:"prompt",requestId:i,prompt:t})})}finish(e,t){let n=this.sessions.get(e);if(!(!n||n.finished)){n.finished=!0,n.attachTimer&&(window.clearTimeout(n.attachTimer),n.attachTimer=null),n.pollWatchdog&&(window.clearTimeout(n.pollWatchdog),n.pollWatchdog=null);for(let[,i]of n.pending)i.reject(new Ee(PN));n.pending.clear(),this.push(n,t),n.cleanupTimer=window.setTimeout(()=>this.destroySession(n),Cbe)}}abortSession(e){let t=this.sessions.get(e);if(!t||t.finished)return null;t.aborted=!0;let n=[...t.pending.values()];t.pending.clear();for(let i of n)i.reject(new St(yu));return t.queue=t.queue.filter(i=>i.kind!=="prompt"),n.length}stop(){this.generation++;for(let e of this.sessions.values()){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t.reject(new Ee("QuickAdd was unloaded during an interactive run."));if(e.waiter){let t=e.waiter;e.waiter=null,t({kind:"error",error:"QuickAdd unloaded"})}}this.sessions.clear(),this.server?.close(),this.server=null,this.port=0,this.startPromise=null}push(e,t){if(e.waiter){let n=e.waiter;e.waiter=null,e.waiterTimer&&(window.clearTimeout(e.waiterTimer),e.waiterTimer=null),n(t)}else e.queue.push(t)}destroySession(e){e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.cleanupTimer&&window.clearTimeout(e.cleanupTimer),e.attachTimer&&window.clearTimeout(e.attachTimer),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog);for(let[,t]of e.pending)t.reject(new Ee(PN));e.pending.clear(),this.sessions.delete(e.id),this.sessions.size===0&&(this.server?.close(),this.server=null,this.port=0,this.startPromise=null)}authed(e,t){return!!e&&!!t&&_be(e.token,t)}originAllowed(e){return Abe({origin:e.headers.origin,referer:e.headers.referer,host:e.headers.host})}submitReply(e,t,n,i=!1){let o=this.sessions.get(e);if(!o)return!1;let s=o.pending.get(t);return s?(o.pending.delete(t),i===!0?s.promptType==="info"?s.resolve(n):s.reject(new St(yu)):s.resolve(n),!0):!1}pendingPromptType(e,t){return e.pending.get(t)?.promptType}send(e,t,n){let i=JSON.stringify(n);e.writeHead(t,{"content-type":"application/json","cache-control":"no-store"}),e.end(i)}async drainBody(e){let t=0;for await(let n of e)if(t+=n.length,t>1e6)throw new Error("Request body too large")}async readBody(e){let t=[],n=0;for await(let i of e){if(n+=i.length,n>1e6)throw new Error("Request body too large");t.push(i)}return t.length===0?{}:JSON.parse(Buffer.concat(t).toString("utf8"))}async handle(e,t){try{if(!this.originAllowed(e)){this.send(t,403,{ok:!1,error:"Forbidden"});return}let n=new URL(e.url??"/","http://127.0.0.1"),i=n.searchParams.get("session"),o=n.searchParams.get("token"),s=i?this.sessions.get(i):void 0;if(!this.authed(s,o)){this.send(t,404,{ok:!1,error:"Unknown session or token"});return}if(e.method==="GET"&&n.pathname==="/poll"){this.handlePoll(s,t);return}if(e.method==="POST"&&n.pathname==="/abort"){await this.drainBody(e);let a=this.abortSession(s.id);if(a===null){this.send(t,409,{ok:!1,error:"The interactive session has already ended"});return}this.send(t,200,{ok:!0,interrupted:a});return}if(e.method==="POST"&&n.pathname==="/reply"){let a=await this.readBody(e),l=this.submitWireReply(s.id,a);l.ok?this.send(t,200,{ok:!0}):this.send(t,l.status,{ok:!1,error:l.error});return}this.send(t,404,{ok:!1,error:"Not found"})}catch(n){this.send(t,400,{ok:!1,error:n instanceof Error?n.message:String(n)})}}handlePoll(e,t){e.attached||(e.attached=!0,e.attachTimer&&(window.clearTimeout(e.attachTimer),e.attachTimer=null)),e.pollWatchdog&&window.clearTimeout(e.pollWatchdog),e.pollWatchdog=window.setTimeout(()=>{this.finish(e.id,{kind:"error",error:"Interactive client disconnected."})},Ebe);let n=e.queue.shift();if(n){this.send(t,200,n);return}if(e.waiter){this.send(t,200,{kind:"idle"});return}let i=o=>this.send(t,200,o);e.waiter=i,e.waiterTimer=window.setTimeout(()=>{e.waiter===i&&(e.waiter=null,e.waiterTimer=null,this.send(t,200,{kind:"idle"}))},wbe),t.on("close",()=>{e.waiter===i&&(e.waiterTimer&&window.clearTimeout(e.waiterTimer),e.waiter=null,e.waiterTimer=null)})}submitWireReply(e,t){let n=this.sessions.get(e);if(!n)return{ok:!1,status:409,error:XD};if(!t.requestId)return{ok:!1,status:409,error:XD};let i=this.pendingPromptType(n,t.requestId);if(!i)return{ok:!1,status:409,error:XD};let o=Sbe(i,t);return o?{ok:!1,status:400,error:o}:this.submitReply(n.id,t.requestId,t.value,t.cancelled)?{ok:!0}:{ok:!1,status:409,error:XD}}},ca=new FN;function MN(r){if(!r||typeof r!="string")return null;let e=r.split("-")[0]?.split("+")[0]?.trim();if(!e)return null;let t=e.split(".");if(t.length!==3)return null;let n=Number.parseInt(t[0]??"",10),i=Number.parseInt(t[1]??"",10),o=Number.parseInt(t[2]??"",10);return Number.isNaN(n)||Number.isNaN(i)||Number.isNaN(o)||n<0||i<0||o<0?null:{major:n,minor:i,patch:o}}Wt();G1();qt();Me();Mx();var wf="\0qa-idx:";function Ibe(r){return r===void 0?"no value":r===null?"null":typeof r=="string"?JSON.stringify(r.slice(0,40)):typeof r=="number"||typeof r=="boolean"?String(r):Array.isArray(r)?"an array":typeof r}var QD=class{constructor(e,t=ca){this.sessionId=e;this.server=t}async suggester(e,t,n,i=!1){let o=typeof e=="function"?t.map((c,u,d)=>String(e(c,u,d))):e.map(c=>String(c)),s=t.map((c,u)=>({title:o[u]??String(c),value:`${wf}${u}`})),a=await this.server.emitPrompt(this.sessionId,{type:"suggester",placeholder:n,allowCustomInput:i,items:s});if(a==null)return"";let l=String(a);if(l.startsWith(wf)){let c=Number(l.slice(wf.length));if(Number.isInteger(c)&&c>=0&&c<t.length)return t[c]}return l}async suggesterMulti(e,t,n){let i=t.map((a,l)=>({title:e[l]??String(a),value:`${wf}${l}`})),o=[];for(let a of n?.preselected??[]){let l=t.indexOf(a);if(l>=0)o.push(`${wf}${l}`);else{let c=String(a);i.push({title:c,value:c}),o.push(c)}}let s=await this.server.emitPrompt(this.sessionId,{type:"multiselect",placeholder:n?.placeholder,allowCustomInput:n?.allowCustomInput??!1,items:i,preselected:o});return Array.isArray(s)?s.map(a=>{let l=String(a);if(l.startsWith(wf)){let c=Number(l.slice(wf.length));if(Number.isInteger(c)&&c>=0&&c<t.length)return t[c]}return l}):[]}async inputPrompt(e,t,n){return this.textPrompt(e,t,n,!1)}async wideInputPrompt(e,t,n){return this.textPrompt(e,t,n,!0)}async textPrompt(e,t,n,i){let o=await this.server.emitPrompt(this.sessionId,{type:"input",header:e,placeholder:t,defaultValue:n,multiline:i});return o==null?"":String(o)}async datePrompt(e,t){let n=await this.server.emitPrompt(this.sessionId,{type:"date",header:e,placeholder:t?.placeholder,defaultValue:t?.defaultValue,dateFormat:t?.dateFormat,withTime:t?.withTime}),i=String(n??"");if(!i)return"";let o=i.startsWith("@date:")?i.slice(6):i,s=t?.dateFormat;return(s?Nl(o,s):null)??o}async yesNoPrompt(e,t){let n=await this.server.emitPrompt(this.sessionId,{type:"confirm",header:e,text:t});if(n===!0||n==="true")return!0;if(n===!1||n==="false")return!1;throw new Error(`A confirm prompt needs a boolean reply, or {"cancelled": true} if the user dismissed it. Got ${Ibe(n)}.`)}async checkboxPrompt(e,t,n){let i=new Set(t??[]),o=await this.server.emitPrompt(this.sessionId,{type:"checkbox",header:n,items:e.map(s=>({title:String(s),value:String(s),checked:i.has(s)}))});return Array.isArray(o)?o.map(s=>String(s)):[]}async infoDialog(e,t){await this.server.emitPrompt(this.sessionId,{type:"info",header:e,text:Array.isArray(t)?t:[t]})}async requestInputs(e){let t=e.map(s=>({id:s.id,label:s.label??s.id,type:s.type==="file-picker"?"suggester":s.type,placeholder:s.placeholder,defaultValue:s.defaultValue,description:s.description,options:s.options,displayOptions:s.displayOptions,dateFormat:s.dateFormat,optional:s.optional,numericConfig:s.numericConfig,suggesterConfig:s.suggesterConfig?{allowCustomInput:s.suggesterConfig.allowCustomInput,multiSelect:s.suggesterConfig.multiSelect}:void 0})),n=await this.server.emitPrompt(this.sessionId,{type:"form",fields:t});if(!n||typeof n!="object")return{};let i=new Set(e.filter(s=>s.type==="date").map(s=>s.id)),o={};for(let[s,a]of Object.entries(n)){if(Array.isArray(a)){o[s]=a.map(c=>String(c));continue}let l=a==null?"":String(a);l&&i.has(s)&&!l.startsWith("@date:")&&(l=`@date:${l}`),o[s]=l}return o}};Wt();var m7={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON"},ui:{description:"Allow interactive prompts"},verify:{description:"Report the verified outcome for Template/Capture choices (file path and effect on success, honest failure when the engine swallows an error)"}},Pbe={type:{value:"<Template|Capture|Macro|Multi>",description:"Filter by choice type"},commands:{description:"Only include command-enabled choices"}},Fbe={path:{value:"<vault-path>",description:"Path to a template file in the vault"},vars:{value:"<json>",description:"Variables object as JSON"},ui:{description:"Allow interactive prompts"}},Mbe={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON"},fields:{description:"Include full field metadata (options, defaults, widget config)"}},Rbe={choice:{value:"<name>",description:"Choice name"},id:{value:"<id>",description:"Choice id"},vars:{value:"<json>",description:"Variables object as JSON (pre-seeded inputs)"}},$be={path:{value:"<vault-path>",description:"Path to a .quickadd.json package file in the vault"},decode:{description:"Inline decoded contents for each bundled file"}},Obe=new Set(["choice","id","vars","ui","verify"]),h7=new Set(["path","vars","ui"]),Nbe=new Set(["choice","id","vars","fields"]),Lbe=new Set(["choice","id","vars"]),En={runDefault:"quickadd",run:"quickadd:run",runTemplate:"quickadd:run-template",list:"quickadd:list",check:"quickadd:check",preview:"quickadd:package-preview",interactive:"quickadd:interactive"},Bbe=new Set(["template","capture","macro","multi"]);function _r(r){return JSON.stringify(r)}function Zg(r){if(r===void 0)return!1;let e=r.toLowerCase();return e==="true"||e==="1"||e==="yes"||e==="on"}function Ube(r){let e;try{e=JSON.parse(r)}catch(t){throw new Error(`Invalid vars JSON: ${t instanceof Error?t.message:String(t)}`)}if(!e||typeof e!="object"||Array.isArray(e))throw new Error("Invalid vars JSON: expected an object");return e}function ZD(r,e){let t={};typeof r.vars=="string"&&Object.assign(t,Ube(r.vars));for(let[n,i]of Object.entries(r)){if(n.startsWith("value-")){let o=n.slice(6);o&&(t[o]=i);continue}e.has(n)||(t[n]=i)}return t}function v7(r,e=[]){let t=[];for(let n of hn(r)){if(!Ye(n))continue;let i=[...e,n.name],o=i.join(" / "),s=n.type==="Multi";t.push({id:n.id,name:n.name,type:n.type,command:n.command,path:o,runnable:!s}),s&&t.push(...v7(st(n),i))}return t}function RN(r,e){if(typeof e.id=="string"&&e.id.trim().length>0)return r.getChoiceById(e.id);if(typeof e.choice=="string"&&e.choice.trim().length>0)return r.getChoiceByName(e.choice);throw new Error("Missing choice selector. Provide either choice=<name> or id=<id>")}function $N(r){return{id:r.id,label:r.label,type:r.type,source:r.source??"collected",placeholder:r.placeholder,defaultValue:r.defaultValue,description:r.description,optionCount:r.options?.length??0}}function Vbe(r){return{...$N(r),options:r.options,displayOptions:r.displayOptions,dateFormat:r.dateFormat,withTime:r.withTime,optional:r.optional,runtimeOnly:r.runtimeOnly,multiEmit:r.multiEmit,filters:r.filters,numericConfig:r.numericConfig,sliderConfig:r.sliderConfig,suggesterConfig:r.suggesterConfig}}function ON(r,e){for(let[t,n]of Object.entries(e))r.variables.set(t,n)}function zo(r){return{id:r.id,name:r.name,type:r.type}}async function y7(r,e,t,n,i,o=!1){let s=Date.now();try{if(n.type==="Multi")return _r({ok:!1,command:t,error:"Multi choices are interactive and cannot be run via CLI.",choice:zo(n)});let a=ZD(e,i),l=new Ri(r.app,r);ON(l,a);let c=Zg(e.ui);if(l.interactive=c,!c){let f=await wE(r.app,r,l,n,{preloadedUserScripts:l.preloadedUserScripts}),p=CE(f,l.variables);if(p.length>0)return _r({ok:!1,command:t,error:"Missing required inputs for non-interactive CLI run.",choice:zo(n),missing:p.map($N),missingFlags:p.map(m=>`value-${m.id}=<value>`)})}if(o&&(n.type==="Template"||n.type==="Capture")&&typeof l.executeWithOutcome=="function"){let f=await l.executeWithOutcome(n),p=Date.now()-s;return f.status==="success"?_r({ok:!0,command:t,choice:zo(n),file:f.file?.path,verified:!0,effect:f.effect,durationMs:p}):f.status==="cancelled"?_r({ok:!1,command:t,error:f.reason||(f.cancelKind==="user"?"Execution cancelled by user":"Execution aborted"),aborted:!0,choice:zo(n),durationMs:p}):_r({ok:!1,command:t,error:f.reason||"Choice execution failed; no file was created.",choice:zo(n),durationMs:p})}await l.execute(n);let u=l.consumeAbortSignal?.(),d=Date.now()-s;return _r(u?{ok:!1,command:t,error:u.message||"Choice execution aborted",aborted:!0,choice:zo(n),durationMs:d}:{ok:!0,command:t,choice:zo(n),verified:!1,effect:"unknown",durationMs:d})}catch(a){return _r({ok:!1,command:t,error:a instanceof Error?a.message:String(a)})}}async function g7(r,e,t){let n;try{n=RN(r,e)}catch(i){return _r({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}return y7(r,e,t,n,Obe,Zg(e.verify))}async function qbe(r,e){let t=En.runTemplate;try{let n=typeof e.path=="string"?e.path.trim():"";if(!n)return _r({ok:!1,command:t,error:"Missing template path. Provide path=<vault-path>."});let i=po(r.app,n);if(!i)return _r({ok:!1,command:t,error:`No template file found at '${n}'.`});let o=EN(i.path);if(!Zg(e.ui)){let a=ZD(e,h7).value;if(a==null||String(a).trim().length===0)return _r({ok:!1,command:t,error:"Missing required inputs for non-interactive CLI run.",choice:zo(o),missing:[{id:"value",label:"New note name",type:"text",source:"collected",optionCount:0}],missingFlags:["value-value=<value>"]})}return await y7(r,e,t,o,h7,!0)}catch(n){return _r({ok:!1,command:t,error:n instanceof Error?n.message:String(n)})}}function Wbe(r,e){try{let t=typeof e.type=="string"?e.type.trim():"",n=t.toLowerCase(),i=Zg(e.commands);if(n&&!Bbe.has(n))return _r({ok:!1,command:En.list,error:`Invalid type filter '${t}'.`});let s=v7(r.settings.choices).filter(a=>!(n&&a.type.toLowerCase()!==n||i&&!a.command));return _r({ok:!0,command:En.list,count:s.length,choices:s})}catch(t){return _r({ok:!1,command:En.list,error:t instanceof Error?t.message:String(t)})}}async function zbe(r,e){try{let t=RN(r,e);if(t.type==="Multi")return _r({ok:!1,command:En.check,error:"Multi choices are interactive and cannot be checked via CLI.",choice:zo(t)});let n=ZD(e,Nbe),i=new Ri(r.app,r);ON(i,n);let o=await wE(r.app,r,i,t),s=CE(o,i.variables),a=Zg(e.fields)?Vbe:$N;return _r({ok:s.length===0,command:En.check,choice:zo(t),requiredInputCount:o.length,missingInputCount:s.length,missing:s.map(a),missingFlags:s.map(l=>`value-${l.id}=<value>`)})}catch(t){return _r({ok:!1,command:En.check,error:t instanceof Error?t.message:String(t)})}}async function Hbe(r,e){let t=En.interactive,n;try{n=RN(r,e)}catch(i){return _r({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}if(n.type==="Multi")return _r({ok:!1,command:t,error:"Multi choices cannot be run interactively via CLI.",choice:zo(n)});try{let i=await ca.ensureStarted(),{id:o,token:s}=ca.createSession(),a=new Ri(r.app,r);return ON(a,ZD(e,Lbe)),a.interactive=!0,a.promptProvider=new QD(o),(async()=>{try{if((n.type==="Template"||n.type==="Capture")&&typeof a.executeWithOutcome=="function"){let c=await a.executeWithOutcome(n);if(c.status==="success"){ca.finish(o,{kind:"done",result:{ok:!0,choice:zo(n),file:c.file?.path,verified:!0,effect:c.effect}});return}ca.finish(o,{kind:"error",error:c.status==="cancelled"?c.reason||(c.cancelKind==="user"?"Execution cancelled by user":"Execution aborted"):c.reason||"Choice execution failed; no file was created."});return}await a.execute(n);let l=a.consumeAbortSignal?.();if(l){ca.finish(o,{kind:"error",error:l.message||"Choice execution aborted"});return}ca.finish(o,{kind:"done",result:{ok:!0,choice:zo(n),verified:!1,effect:"unknown"}})}catch(l){ca.finish(o,{kind:"error",error:l instanceof Error?l.message:String(l)})}})(),_r({ok:!0,command:t,choice:zo(n),host:"127.0.0.1",port:i,sessionId:o,token:s,capabilities:["abort","outcome-effect"]})}catch(i){return _r({ok:!1,command:t,error:i instanceof Error?i.message:String(i)})}}async function jbe(r,e){try{let t=typeof e.path=="string"?e.path.trim():"";if(!t)return _r({ok:!1,command:En.preview,error:"Missing package path. Provide path=<vault-path>."});let{pkg:n}=await n4(r.app,t),i=await vS(r.app,r.settings.choices,n),o={ok:!0,command:En.preview,preview:i};return Zg(e.decode)&&(o.contents=i.files.map(s=>({path:s.originalPath,...hS(n,s.originalPath)}))),_r(o)}catch(t){return _r({ok:!1,command:En.preview,error:t instanceof Error?t.message:String(t)})}}function b7(r){let e=r;if(typeof e.registerCliHandler!="function")return F.logMessage("Skipping QuickAdd CLI handler registration: registerCliHandler is unavailable."),!1;let t=e.registerCliHandler.bind(e);return t(En.runDefault,"Run a QuickAdd choice (ok:true reports the choice ran without aborting; check verified to know QuickAdd confirmed the run, and effect to know whether the vault changed: created/changed/unchanged/unknown)",m7,n=>g7(r,n,En.runDefault)),t(En.run,"Run a QuickAdd choice (ok:true reports the choice ran without aborting; check verified to know QuickAdd confirmed the run, and effect to know whether the vault changed: created/changed/unchanged/unknown)",m7,n=>g7(r,n,En.run)),t(En.runTemplate,"Create a new note from a template file (no Template choice required)",Fbe,n=>qbe(r,n)),t(En.list,"List QuickAdd choices",Pbe,n=>Wbe(r,n)),t(En.check,"Check missing inputs for a QuickAdd choice",Mbe,n=>zbe(r,n)),t(En.preview,"Preview a QuickAdd package before importing (files + capabilities)",$be,n=>jbe(r,n)),t(En.interactive,"Run a choice interactively: forwards its runtime prompts to the caller over a local server (returns host/port/sessionId/token to attach)",Rbe,n=>Hbe(r,n)),F.logMessage("Registered QuickAdd CLI handlers."),!0}var Cf={run:"Run",runTemplateFromFolder:"New note from template",applyTemplate:"Apply template to active note",reloadDev:"Reload (dev)",openSettings:"Open settings"};hl();iN();var Gbe=new Set(["shortcuts:","obsidian:"]);function JD(r){return typeof r=="string"&&r.length>0?r:void 0}function w7(r){let e=JD(r["x-success"]),t=JD(r["x-error"]),n=JD(r["x-cancel"]);if(e||t||n)return{success:e,error:t,cancel:n,any:!0};let i=JD(r["x-callback-url"]);return i?{success:i,cancel:i,any:!0}:{any:!1}}function C7(r){return[r.success,r.error,r.cancel].filter(e=>typeof e=="string"&&e.length>0)}function NN(r){try{let e=new URL(r).protocol.toLowerCase();return Gbe.has(e)}catch{return!1}}function x7(r,e){let t=new URL(r);for(let[n,i]of Object.entries(e))t.searchParams.set(n,i);return t.toString()}function E7(r,e){return"obsidian://open?vault="+encodeURIComponent(r)+"&file="+encodeURIComponent(e)}var Ybe=1e3,eI=class extends Jg.Plugin{constructor(){super(...arguments);this.requestSave=(0,Jg.debounce)(()=>{(async()=>await this.saveData(this.settings))()},Ybe)}get api(){return Hg.GetApi(this.app,this,new Ri(this.app,this))}async onload(){F.logMessage("Loading QuickAdd"),dV(this),await this.loadSettings(),ce.replaceState(this.settings),this.unsubscribeSettingsStore=ce.subscribe(o=>{this.settings=o,this.requestSave()}),this.addCommand({id:"runQuickAdd",name:Cf.run,callback:()=>{kN(this)}}),this.addCommand({id:"runTemplateFromFolder",name:Cf.runTemplateFromFolder,callback:()=>{qD(this.app,this,{choiceExecutor:new Ri(this.app,this)})}}),this.addCommand({id:"applyTemplateToActiveFile",name:Cf.applyTemplate,checkCallback:o=>{let s=this.app.workspace.getActiveFile(),a=s?.extension==="md";if(o)return a;a&&uE(this.app,this,{file:s,choiceExecutor:new Ri(this.app,this)})}}),this.registerEvent(this.app.workspace.on("file-menu",(o,s)=>{s instanceof Jg.TFile&&s.extension==="md"&&o.addItem(a=>a.setTitle(`QuickAdd: ${Cf.applyTemplate}`).setIcon("file-plus").onClick(()=>{uE(this.app,this,{file:s,choiceExecutor:new Ri(this.app,this)})}))})),this.addCommand({id:"reloadQuickAdd",name:Cf.reloadDev,checkCallback:o=>{if(o)return this.settings.devMode;let s=this.manifest.id,a=this.app.plugins;a.disablePlugin(s).then(()=>a.enablePlugin(s))}}),Vl.getInstance().startAutomaticCleanup(o=>this.registerInterval(o)),this.addCommand({id:"openQuickAddSettings",name:Cf.openSettings,callback:()=>{ug(this.app,this.manifest.id)}}),this.registerObsidianProtocolHandler("quickadd",async o=>{let s=o,a=this.settings.enableUriCallbacks?w7(s):{any:!1};if(!a.any){await this.runUriChoiceLegacy(s);return}let l=C7(a).filter(f=>!NN(f));if(l.length>0){F.logWarning(`QuickAdd URI: ignoring disallowed callback URL(s): ${l.join(", ")}`),a.error&&NN(a.error)&&this.openUriCallback(a.error,{status:"error",errorCode:"bad-callback-url"});return}if(!s.choice){F.logWarning("URI was executed without a `choice` parameter."),this.fireUriError(a,"choice-not-found");return}let c=this.getChoice("name",s.choice);if(!c){F.logWarning(`URI could not find any choice named '${s.choice}'`),this.fireUriError(a,"choice-not-found");return}if(this.warnIfChoiceNameAmbiguous(s.choice),c.type!=="Template"&&c.type!=="Capture"){F.logWarning(`QuickAdd URI x-callback supports Template and Capture choices only ('${c.name}' is ${c.type}). A URI with x-* callback params cannot run a ${c.type} choice while "Enable URI callbacks" is on; remove the x-* params to run it on the legacy path.`),this.fireUriError(a,"unsupported-choice-type");return}let u=new Ri(this.app,this);this.applyUriValueParameters(u,s);let d=await u.executeWithOutcome(c);switch(d.status){case"success":this.fireUriSuccess(a,d.file,d.effect);break;case"cancelled":d.cancelKind==="user"?this.fireUriCancel(a):this.fireUriError(a,"execution-aborted");break;case"error":this.fireUriError(a,"execution-failed");break}}),F.register(new kx).register(new ES(this)),A4(this),this.settings.enableRibbonIcon&&this.addRibbonIcon("file-plus","QuickAdd",()=>{kN(this)}),this.addSettingTab(new xS(this.app,this)),this.addCommandsForChoices(this.settings.choices);try{await p7(this)}catch(o){lt(o,"QuickAdd could not run its settings migrations")}let n=()=>{try{b7(this)}catch(o){lt(o,"QuickAdd could not register its CLI handlers")}};this.app.workspace.layoutReady?n():this.app.workspace.onLayoutReady(n);let i=async()=>{try{await new DD(this.app,this,this.settings.choices,new Ri(this.app,this)).run()}catch(o){lt(o,"QuickAdd could not run its startup macros")}};this.app.workspace.layoutReady?i():this.app.workspace.onLayoutReady(i),this.app.workspace.onLayoutReady(()=>{window.setTimeout(()=>{CY(this.app)},5e3)}),this.announceUpdate()}async runUriChoiceLegacy(t){if(!t.choice){F.logWarning("URI was executed without a `choice` parameter.");return}let n=this.getChoice("name",t.choice);if(!n){lt(new Error(`URI could not find any choice named '${t.choice}'`),"URI handler error");return}this.warnIfChoiceNameAmbiguous(t.choice);let i=new Ri(this.app,this);this.applyUriValueParameters(i,t);try{await i.execute(n)}catch(o){Jf(o,`Could not run "${n.name}"`)}}applyUriValueParameters(t,n){Object.entries(n).filter(([i])=>i.startsWith("value-")).forEach(([i,o])=>{let s=i.slice(6);s&&typeof o=="string"&&!mD(s)&&t.variables.set(s,o)})}fireUriSuccess(t,n,i){let o={status:"success",effect:i};n&&(o.path=n.path,o.url=E7(this.app.vault.getName(),n.path)),t.success&&this.openUriCallback(t.success,o)}fireUriError(t,n){t.error&&this.openUriCallback(t.error,{status:"error",errorCode:n})}fireUriCancel(t){t.cancel&&this.openUriCallback(t.cancel,{status:"cancel"})}openUriCallback(t,n){pB(()=>{window.open(x7(t,n))},"QuickAdd URI: failed to open callback URL")}onunload(){F.logMessage("Unloading QuickAdd"),this.requestSave.run(),this.unsubscribeSettingsStore?.call(this),Lv.loggers.forEach(n=>{n instanceof kx&&n.clearErrorLog()}),Vl.getInstance().destroy(),ca.stop()}async loadSettings(){let t=await this.loadData(),n=Object.assign({},gT,t);typeof n.announceUpdates=="boolean"&&(n.announceUpdates=n.announceUpdates?"all":"none"),Array.isArray(n.choices)&&(n.choices=zU(n.choices)),this.settings=n}async saveSettings(){this.requestSave.cancel(),await this.saveData(this.settings)}addCommandsForChoices(t){for(let n of hn(t))if(Ye(n))try{this.addCommandForChoice(n)}catch(i){lt(i,"Could not add a command for a QuickAdd choice")}}addCommandForChoice(t){if(t.type==="Multi"&&this.addCommandsForChoices(st(t)),t.command){let n=t.id;this.addCommand({id:`choice:${n}`,name:t.name,icon:wm(t),callback:async()=>{let i;try{i=this.getChoiceById(n),await new Ri(this.app,this).execute(i)}catch(o){Jf(o,`Could not run "${i?.name??t.name}"`)}}})}}getChoiceById(t){let n=this.getChoice("id",t);if(!n)throw new Error(`Choice ${t} not found`);return n}getChoiceByName(t){let n=this.getChoice("name",t);if(!n)throw new Error(`Choice ${t} not found`);return n}getChoice(t,n,i=this.settings.choices){for(let o of hn(i))if(Ye(o)){if(o[t]===n)return o;if(o.type==="Multi"){let s=this.getChoice(t,n,st(o));if(s)return s}}return null}countChoicesByName(t,n=this.settings.choices){let i=0;for(let o of hn(n))Ye(o)&&(o.name===t&&i++,o.type==="Multi"&&(i+=this.countChoicesByName(t,st(o))));return i}warnIfChoiceNameAmbiguous(t){let n=this.countChoicesByName(t);n>1&&F.logWarning(`QuickAdd URI: ${n} choices are named '${t}'. Ran the first match \u2014 rename choices to keep names unique so URIs target the right one.`)}removeCommandForChoice(t,n){if(n?.recursive&&t.type==="Multi")for(let i of st(t))Ye(i)&&this.removeCommandForChoice(i,n);O0(this.app,`quickadd:choice:${t.id}`)}getTemplateFiles(){let t=Wi(this.settings.templateFolderPaths);return this.app.vault.getFiles().filter(n=>FT(n.path)).filter(n=>F0(n.path,t))}announceUpdate(){let t=(l,c)=>{let u=MN(l),d=MN(c);return!u||!d?!0:u.major!==d.major?u.major>d.major:u.minor>d.minor},n=this.manifest.version,i=this.settings.version;if(n===i)return;let o=this.settings.announceUpdates,s=!0;if((o==="none"||o==="major"&&!t(n,i))&&(s=!1),this.settings.version=n,this.saveSettings(),!s)return;new YD(this.app,i).open()}};
|
||
|
||
/* nosourcemap */ |