varQ=Object.defineProperty;varhe=Object.getOwnPropertyDescriptor;varge=Object.getOwnPropertyNames;varfe=Object.prototype.hasOwnProperty;varye=(f,n)=>{for(vareinn)Q(f,e,{get:n[e],enumerable:!0})},we=(f,n,e,t)=>{if(n&&typeofn=="object"||typeofn=="function")for(letiofge(n))!fe.call(f,i)&&i!==e&&Q(f,i,{get:()=>n[i],enumerable:!(t=he(n,i))||t.enumerable});returnf};varme=f=>we(Q({},"__esModule",{value:!0}),f);varxe={};ye(xe,{default:()=>J});module.exports=me(xe);varue=require("obsidian");varT=require("obsidian");var_=class{constructor(){this.values=newMap}put(n,e){this.values.set(n,e)}get(n,e){vart;return(t=this.values.get(n))!=null?t:e}getFirst(n,e){for(lett=0;t<n.length;t++){leti=n[t];if(this.containsKey(i))returnthis.get(i,e)}returne}containsKey(n){returnthis.values.has(n)}getKeys(){returnArray.from(this.values.keys())}removeKey(n){returnthis.values.delete(n)}clear(){this.values.clear()}};vary=class{staticsetActive(n){y.isActive=n,y.isActive||this.clear()}staticsetAutoExpire(n){y.baseMinutesToExpire=n!=null?n:0,y.updateExpiryTime()}staticsetLevel(n){y.level!=n&&(y.level=n,this.clear())}staticupdateExpiryTime(){y.baseMinutesToExpire==0||y.baseMinutesToExpire==null?y.expiryTime=null:y.expiryTime=Date.now()+y.baseMinutesToExpire*1e3*60}staticputByPath(n,e){if(!y.isActive)return;lett=y.getPathCacheKey(e);this.cache.put(t,n),y.updateExpiryTime()}staticgetByPath(n){if(!y.isActive)returny.blankPasswordAndHint;this.clearIfExpired(),y.updateExpiryTime();lete=y.getPathCacheKey(n);returnthis.cache.get(e,y.blankPasswordAndHint)}staticgetPathCacheKey(n){lete=n.split("/").slice(0,-1).join("/");switch(y.level){casey.LevelParentPath:returne;default:returnn}}staticclearIfExpired(){y.expiryTime!=null&&(Date.now()<y.expiryTime||this.clear())}staticclearForPath(n){lete=y.getPathCacheKey(n);this.cache.removeKey(e)}staticclear(){this.cache.clear()}},u=y;u.isActive=!0,u.blankPasswordAndHint={password:"",hint:""},u.cache=new_,u.baseMinutesToExpire=0,u.expiryTime=null,u.LevelFullPath="fullPath",u.LevelParentPath="parentPath",u.level=y.LevelFullPath;varB=classextendsT.PluginSettingTab{constructor(e,t,i,s){super(e,t);this.plugin=t,this.settings=i,this.features=s}display(){let{containerEl:e}=this;e.empty(),e.createEl("h1",{text:"Settings for Meld Encrypt"}),newT.Setting(e).setHeading().setName("Common Settings"),newT.Setting(e).setName("Confirm password?").setDesc("Confirm password when encrypting.").addToggle(r=>{r.setValue(this.settings.confirmPassword).onChange(asynco=>{this.settings.confirmPassword=o,awaitthis.plugin.saveSettings()})});lett=()=>{if(!this.settings.rememberPassword){i.settingEl.hide(),s.settingEl.hide();return}i.settingEl.show(),s.settingEl.show();letr=this.settings.rememberPasswordTimeout,o=`For ${r} minutes`;r==0&&(o="Always"),i.setName(`Remember Password (${o})`)};newT.Setting(e).setName("Remember password?").setDesc("Remember the last used passwords when encrypting or decrypting.").addToggle(r=>{r.setValue(this.settings.rememberPassword).onChange(asynco=>{this.settings.rememberPassword=o,awaitthis.plugin.saveSettings(),u.setActive(this.settings.rememberPassword),t()})});leti=newT.Setting(e).setDesc("The number of minutes to remember passwords.").addSlider(r=>{r.setLimits(0,120,5).setValue(this.settings.rememberPasswordTimeout).onChange(asynco=>{this.settings.rememberPasswordTimeout=o,awaitthis.plugin.saveSettings(),u.setAutoExpire(this.settings.rememberPasswordTimeout),t()})}),s=newT.Setting(e).setDesc("Remember passwords by using").addDropdown(r=>{r.addOption(u.LevelFullPath,"Full Path").addOption(u.LevelParentPath,"Parent Path").setValue(this.settings.rememberPasswordLevel).onChange(asynco=>{this.settings.rememberPasswordLevel=o,awaitthis.plugin.saveSettings(),u.setLevel(this.settings.rememberPasswordLevel),t()})});t(),this.features.forEach(r=>{r.buildSettingsUi(e,async()=>awaitthis.plugin.saveSettings())})}};varP=require("obsidian");vark=require("obsidian"),I=classextendsk.Modal{constructor(e,t,i=""){super(e);this.decryptInPlace=!1;this.canDecryptInPlac
`).slice(e,t+1).join(`
`)}static findFirstMarker(n,e,t=0){let i=null,s=null;return n.forEach(r=>{let o=e.indexOf(r,t);o!=-1&&(i==null||o<i)&&(i=o,s=r)}),s==null||i==null?null:{marker:s,position:i}}};var v=require("obsidian");var m=require("obsidian");var V=class{static get showInlineTitle(){var n;return(n=app.vault.getConfig("showInlineTitle"))!=null?n:!0}static get readableLineLength(){var n;return(n=app.vault.getConfig("readableLineLength"))!=null?n:!0}};var K="meld-encrypted-file-content-view",q=class extends m.TextFileView{constructor(e,t){var i;super(e);this.iconReadingView="book-open";this.iconSourceView="code";this.iconToggleEditView="edit";this.iconLockFile="lock";this.iconChangePassword="key";this.currentView=0;this.encryptionPassword="";this.hint="";this.currentEditorSourceText="";this.settings=t,this.defaultEditNoteView=(i=t.defaultView)!=null?i:"Source",this.currentEditNoteMode=this.defaultEditNoteView,this.elActionEditView=this.addAction(this.iconSourceView,"Source",()=>this.actionToggleEditMode()),this.elActionReadingView=this.addAction(this.iconReadingView,"Reading",()=>this.actionToggleEditMode()),this.elActionIconLockNote=this.addAction(this.iconLockFile,"Lock",()=>this.actionLockFile()),this.elActionChangePassword=this.addAction(this.iconChangePassword,"Change Password",()=>this.actionChangePassword()),this.elActionEditView.hide(),this.elActionReadingView.hide(),this.elActionIconLockNote.hide(),this.elActionChangePassword.hide(),this.containerEl.classList.add("meld-encrypt-encrypted-note-view"),this.contentEl.classList.add("meld-encrypt-encrypted-note-view-content")}actionToggleEditMode(){this.currentView==2&&(this.currentEditNoteMode=="Reading"?this.currentEditNoteMode="Source":this.currentEditNoteMode=="Source"&&(this.currentEditNoteMode="Reading"),this.refreshView(2))}actionLockFile(){this.encryptionPassword="",u.clearForPath(this.file.path),this.refreshView(1)}actionChangePassword(){this.refreshView(3)}onPaneMenu(e,t){t=="tab-header"&&this.currentView==2&&(e.addItem(i=>{i.setSection("action").setIcon(this.iconToggleEditView).setTitle("Toggle Editing/Reading").onClick(()=>this.actionToggleEditMode())}),e.addItem(i=>{i.setSection("action").setIcon(this.iconLockFile).setTitle("Lock").onClick(()=>this.actionLockFile())}),e.addItem(i=>{i.setSection("action").setIcon(this.iconChangePassword).setTitle("Change Password").onClick(()=>this.actionChangePassword())})),super.onPaneMenu(e,t)}addHeader(e,t){var i;e.createDiv({text:`\u{1F510}${t}\u{1F510}`,cls:"encrypted-note-message"}),V.showInlineTitle&&e.createDiv({text:(i=this.file)==null?void 0:i.basename,cls:"inline-title"})}validatePassword(e){return e.length==0?"Password is too short":""}validateConfirm(e,t){return e===t?"":"Password doesn't match"}addNewNoteView(e){this.addHeader(e,"This note will be encrypted");let t=this.addUserInputContainer(e);new m.Setting(t).setDesc("Please provide a password and hint to start editing this note.");let i=async(c,d,g)=>{let w=this.validatePassword(c),M=this.validateConfirm(c,d);p.setDesc(w),h.setDesc(M),w.length===0&&M.length===0&&(this.encryptionPassword=c,this.hint=g,V.showInlineTitle||(this.currentEditorSourceText=`#${this.file.basename}