`:" ";return n.replaceRange(`${l}^${a}`,o),a}static shouldInsertAfter(n){if(n.type)return["blockquote","code","table","heading","comment","footnoteDefinition"].includes(n.type)}static getBlockId(n){let e=n.workspace.getActiveViewOfType(me.MarkdownView);if(e){let t=e.editor,i=e.file,o=this.getBlock(n,t,i);if(o)return this.getIdOfBlock(t,o)}}};var ve={openFileOnWrite:!0,openDailyInNewPane:!1,openFileOnWriteInNewPane:!1,openFileWithoutWriteInNewPane:!1,idField:"id",useUID:!1,addFilepathWhenUsingUID:!1,allowEval:!1,includeVaultName:!0,vaultParam:"name",linkFormats:[{name:"Markdown",format:"[{{name}}]({{uri}})"}]};var we=require("obsidian");function je(s){let n=s.internalPlugins.plugins["daily-notes"];if(n&&n.enabled)return!0}function Ze(...s){let n=[];for(let t=0,i=s.length;t<i;t++)s[t]&&(n=n.concat(s[t].split("/")));let e=[];for(let t=0,i=n.length;t<i;t++){let o=n[t];!o||o==="."||e.push(o)}return n[0]===""&&e.unshift(""),e.join("/")}async function be(s,n){let{format:e,folder:t}=n.internalPlugins.getEnabledPluginById("daily-notes").options,i=s.format(e);return i.endsWith(".md")||(i+=".md"),(0,we.normalizePath)(Ze(t,i))}var v=require("obsidian");var Me=require("obsidian"),U=class extends Me.SuggestModal{constructor(e,t,i){super(e.app);this.withFormat=t;this.file=i;this.modes=[null,"overwrite","append","prepend"];this.plugin=e,this.setPlaceholder("Type your data to be written to the file or leave it empty to just open it")}getSuggestions(e){e==""&&(e=null);let t=[];for(let i of this.modes)if(!(i==="overwrite"&&!e)){let o;e?i?o=`Write "${e}" in ${i} mode`:o=`Write "${e}"`:i?o=`Open in ${i} mode`:o="Open",t.push({data:e,display:o,mode:i,func:()=>{this.file?this.plugin.tools.copyURI({filepath:this.file,data:e,mode:i},this.withFormat,this.app.vault.getFileByPath(this.file)):this.plugin.tools.copyURI({daily:"true",data:e,mode:i},this.withFormat,void 0)}})}return t}renderSuggestion(e,t){t.innerText=e.display}onChooseSuggestion(e,t){e.func()}};var Ie=require("obsidian"),R=class extends Ie.FuzzySuggestModal{constructor(e,t,i=!0){super(e.app);this.placeHolder=t;this.allowNoFile=i;this.plugin=e,this.setPlaceholder(this.placeHolder)}getItems(){let e=[];this.allowNoFile&&e.push({display:"<Don'tspecifyafile>",source:void 0});let t=this.app.workspace.getActiveFile();return t&&e.push({display:"<Currentfile>",source:t.path}),[...e,...this.app.vault.getFiles().map(i=>({display:i.path,source:i.path}))]}getItemText(e){return e.display}onChooseItem(e,t){}};var Ae=require("obsidian");function re(s){return s.viewmode?{state:{mode:s.viewmode,source:s.viewmode=="source"}}:void 0}function D(s){return navigator.clipboard.writeText(s)}function J(s,n){var o;let e=(o=n.parent)==null?void 0:o.path,t=e==="/"?"":e,i=n.name;for(let a=1;a<100;a++){let l=W(i),r=t+(t==""?"":"/")+l+` ${a}.md`;if(!(s.vault.getAbstractFileByPath(r)!==null))return r}}function Fe(s,n){let e=new URL(s.vault.getResourcePath(n));return e.host="localhosthostlocal",e.protocol="file",e.search="",e.pathname=decodeURIComponent(e.pathname),e.toString().replace("/localhosthostlocal/","/")}function ce(s,n,e){var a,l;let t=s.metadataCache.getFileCache(n),i=t.sections,o=(a=t.headings)==null?void 0:a.find(r=>r.heading===e);if(o){let r=i.findIndex(u=>u.type==="heading"&&u.position.start.line===o.position.start.line),c=i.slice(r+1),d=c==null?void 0:c.findIndex(u=>u.type==="heading");return{lastLine:((l=c[(d!==-1?d:c.length)-1])!=null?l:i[r]).position.end.line+1,firstLine:i[r].position.end.line+1}}else new Ae.Notice("Can't find heading")}var z=class extends Error{constructor(e,t,i){super(e);this.name="KeyPathError",this.errKey=t,i&&(this.cause=i)}};function Pe(s){let{originalObject:n,key:e,data:t}=s;if(e.startsWith("[")&&e.endsWith("]")){let i=e.substring(1,e.length-1).split(","),o=n;for(let a=0;a<i.length;a++){let l=i[a],r;if(o instanceof Array){if(r=parseInt(l),Number.isNaN(r)&&(r=o.find(p=>p==l)),r===void 0)throw new z(`Failed to resolve or convert "${l}" to a valid array index.`,l);r=Math.min(r,o.length),r=Math.max(r,-1)}if(a==i.length-1){o instanceof Array?r===-1?o.unshift(t):o[r]=t:o[l]=t;
${r.message}`):new v.Notice("Failed to update frontmatter, check console for more details")}});return}D(Ce({obj:i,key:e}))}handleWorkspace(n){let e=this.app.internalPlugins.getEnabledPluginById("workspaces");if(!e)new v.Notice("Workspaces plugin is not enabled"),this.plugin.failure(n);else{if(n.saveworkspace=="true"){let t=e.activeWorkspace;e.saveWorkspace(t),new v.Notice(`Saved current workspace to ${t}`)}n.clipboard&&n.clipboard!="false"?this.tools.copyURI({workspace:e.activeWorkspace}):n.workspace!=null&&e.loadWorkspace(n.workspace),this.plugin.success(n)}}async handleCommand(n){if(n.filepath)if(n.mode){if(n.mode=="new"){let t=this.app.metadataCache.getFirstLinkpathDest(n.filepath,"/");t instanceof v.TFile&&(n.filepath=J(this.app,t))}await this.plugin.open({file:n.filepath,mode:"source",parameters:n});let e=this.app.workspace.getActiveViewOfType(v.MarkdownView);if(e){let t=e.editor,i=t.getValue();if(n.mode==="append"){t.setValue(i+`
`);returnawaitthis.app.vault.modify(n,r),e}asyncgetUIDFromFile(n){vari;lete=(i=this.app.metadataCache.getFileCache(n))!=null?i:awaitnewPromise(o=>{leta=this.app.metadataCache.on("changed",l=>{if(l.path==n.path){letr=this.app.metadataCache.getFileCache(n);this.app.metadataCache.offref(a),o(r)}})}),t=(0,P.parseFrontMatterEntry)(e.frontmatter,this.plugin.settings.idField);if(t!=null)returntinstanceofArray?t[0]:t}asyncgenerateURI(n){vara;lete="obsidian://adv-uri",t="",i=this.app.vault.getAbstractFileByPath(n.filepath);this.settings.includeVaultName&&(t+="?vault=",this.settings.vaultParam=="id"&&this.app.appId?t+=encodeURIComponent(this.app.appId):t+=encodeURIComponent(this.app.vault.getName())),this.settings.useUID&&iinstanceofP.TFile&&i.extension=="md"&&(this.settings.addFilepathWhenUsingUID||(n.filepath=void0),n.uid=(a=awaitthis.getUIDFromFile(i))!=null?a:awaitthis.writeUIDToFile(i,pe()));leto=Object.keys(n).filter(l=>n[l]).sort((l,r)=>{letc=["filepath","filename","uid","daily"],d=["data","eval"];returnc.includes(l)?-1:c.includes(r)||d.includes(l)?1:d.includes(r)?-1:0});for(letlofo)n[l]!=null&&(t+=t?"&":"?",t+=`${l}=${encodeURIComponent(n[l])}`);returnt.endsWith("%20")&&(t+="&"),e+t}asynccopyURI(n,e=!1,t=void0){varo,a;leti=awaitthis.generateURI(n);if(e){letl=this.settings.linkFormats;if(l.length==0){newP.Notice("No link formats defined in the settings");return}letr;if(l.length==1)r=l[0];else{letd=l.map(h=>h.name),p=awaitnewne(this.plugin,{options:d,onlySelection:!0,placeholder:"Select link format"}).openAndGetResult();if(!p){newP.Notice("No link format selected");return}r=l.find(h=>h.name==p)}letc=r.format.replace(/\{\{uri\}\}/g,i).replace(/\{\{path\}\}/g,t==null?void0:t.path).replace(/\{\{folder\}\}/g,(o=t==null?void0:t.parent)==null?void0:o.path).replace(/\{\{name\}\}/g,t==null?void0:t.basename).replace(/\{\{vaultName\}\}/g,this.app.vault.getName()).replace(/\{\{vaultId\}\}/g,this.app.appId);if(t&&c.match(/\{\{uid\}\}/g)){letd=(a=awaitthis.getUIDFromFile(t))!=null?a:t.basename;c=c.replace(/\{\{uid\}\}/g,d)}if(t&&c.match(/\{\{alias\}\}/g)){letd=(0,P.parseFrontMatterAliases)(this.app.metadataCache.getFileCache(t).frontmatter),p=d?d[0]:t==null?void0:t.basename;c=c.replace(/\{\{alias\}\}/g,p)}awaitD(c),newP.Notice(`Advanced URI in format "${r.name}" copied to your clipboard`);return}awaitD(i),newP.Notice("Advanced URI copied to your clipboard")}getFileFromUID(n){vari;lete=this.app.vault.getMarkdownFiles(),t=this.settings.idField;for(letoofe){leta=(0,P.parseFrontMatterEntry)((i=this.app.metadataCache.getFileCache(o))==null?void0:i.frontmatter,t);if(ainstanceofArray){if(a.contains(n))returno}elseif(a==n)returno}}getFileFromBlockID(n){vart,i;lete=this.app.vault.getMarkdownFiles();n=n.toLowerCase();for(letoofe)if(((i=(t=this.app.metadataCache.getFileCache(o))==null?void0:t.blocks)==null?void0:i[n])!=null)returno}};varoe=require("obsidian"),ie=classextendsoe.FuzzySuggestModal{constructor(e){super(e.app);this.plugin=e,this.setPlaceholder("Choose a workspace")}getItems(){lete=this.app.internalPlugins.getEnabledPluginById("workspaces");if(!e)newoe.Notice("Workspaces plugin is not enabled");elsereturnObject.keys(e.workspaces)}getItemText(e){returne}onChooseItem(e,t){this.plugin.tools.copyURI({workspace:e})}};varae=classextendsw.Plugin{constructor(){super(...arguments);this.handlers=new$(this);this.tools=newK(this)}asynconload(){awaitthis.loadSettings(),this.addSettingTab(new_(this.app,this)),this.addCommand({id:"copy-uri-current-file",name:"Copy URI for file with options",callback:()=>this.handlers.handleCopyFileURI(!1,!1)}),this.addCommand({id:"copy-uri-current-file-simple",name:"Copy URI for current file",callback:()=>this.handlers.handleCopyFileURI(!0,!1)}),this.addCommand({id:"copy-uri-current-file-with-format",name:"Copy formatted URI for file with options ",callback:()=>this.handlers.handleCopyFileURI(!1,!0)}),this.addCommand({id:"copy-uri-current-file-simple-with-format",name:"Copy formatted URI for current file",callback:()=>this.handlers