triston-notes/.obsidian/plugins/obsidian-excalidraw-plugin/main.js

22 lines
2.5 MiB
JavaScript
Raw Permalink Normal View History

2023-10-21 23:52:54 +00:00
"use strict";var obsidian_module=require("obsidian");var LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;n<o.length;n++)t[o][o.charAt(n)]=n}return t[o][r]}var r=String.fromCharCode,n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",t={},i={compressToBase64:function(o){if(null==o)return"";var r=i._compress(o,6,function(o){return n.charAt(o)});switch(r.length%4){default:case 0:return r;case 1:return r+"===";case 2:return r+"==";case 3:return r+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(e){return o(n,r.charAt(e))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompressFromUTF16:function(o){return null==o?"":""==o?null:i._decompress(o.length,16384,function(r){return o.charCodeAt(r)-32})},compressToUint8Array:function(o){for(var r=i.compress(o),n=new Uint8Array(2*r.length),e=0,t=r.length;t>e;e++){var s=r.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null===o||void 0===o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;t>e;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":i._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(n){return o(e,r.charAt(n))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(o,r,n){if(null==o)return"";var e,t,i,s={},p={},u="",c="",a="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;i<o.length;i+=1)if(u=o.charAt(i),Object.prototype.hasOwnProperty.call(s,u)||(s[u]=f++,p[u]=!0),c=a+u,Object.prototype.hasOwnProperty.call(s,c))a=c;else{if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++),s[c]=f++,a=String(u)}if(""!==a){if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(n(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:i._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(o,n,e){var t,i,s,p,u,c,a,l,f=[],h=4,d=4,m=3,v="",w=[],A={val:e(0),position:n,index:1};for(i=0;3>i;i+=1)f[i]=i;for(p=0,c=Math.pow(2,2),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(t=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 2:return""}for(f[3]=l,s=l,w.push(l);;){if(A.index>o)return"";for(p=0,c=Math.pow(2,m),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(l=p){case
const EXCALIDRAW_PACKAGES = "PQKhCgAIUgBAbAlgYwKYDsDOrICVUCGyALlDAE6EkB0ADuQPYAmAriYg+tQLaJcBWmMmUgBhBrQCe5RAHMAFsUgAKZAEpIAMSKoARgwYBrADSQAkumTVIBdE0iJimGwDMXiJAWKpM1YdEgAFXlEZ0wGFnI0SGRmHFDIJDQsVHsWO1RySGJ5HABZM0DElAxsSBcIuwd0bNyRABkzUQBRADkAZWbyj3ianJxGBiUmREoSBnJJSAYXWoTwyOjiSlQ/aGBwZRd09k5lNQBvAHIWMsxllGIjgG4tneIOdFVjAA9DgCIGXX5UEneAXkBxEktFQM0gqBetAmTgAZLD3ukmKh3OhUu8AIRAkFg2bcZgseCoAD8L2UkOh5CcagAXO9tpYHpwAdjQeDkajUPCOXxVgRuExiTy0coANrvCkwzDvAC6r1pqn+yA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BSGIMkE8NYLMIcNCnxGINx2CO0IUIcMDlx0kGIKTBMMoPzAdwmGMGPANFCDyEqG8FxRDRv2jHP37HQGTVOVOU0AmDQAAFVdx9xkMY5+47Q8IMByjUBTl8AfFUAm4GiQ1nwYYw9WiyiKiej5ZejvBGjL9mjB5DgiZ2pExWUaBzJMA5B0BjA1xcJrgOx3whghgcQdtMBdQSBxBuBoQ0QZwtidiRwG5AZgdxjh1IN+jG1J4aUQxqxJltYK9HR3jx4C44wsQXQvlMZe9QV5DsBiAJjUBlBqBYTaRshAEfAbAagaVphZh20cB/In9dAiRnB5UwJ9xphlVyhBsOwQh5oFUNFoUUTIUlBwQMSEUZACAcSfA6FfJwBJwCSIIIcRiOixjITHjzQlxo1nwH4
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
var e=function(A,t){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,A){e.__proto__=A}||function(e,A){for(var t in A)Object.prototype.hasOwnProperty.call(A,t)&&(e[t]=A[t])},e(A,t)};function A(A,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function i(){this.constructor=A}e(A,t),A.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var t=function(){return t=Object.assign||function(e){for(var A,t=1,i=arguments.length;t<i;t++)for(var n in A=arguments[t])Object.prototype.hasOwnProperty.call(A,n)&&(e[n]=A[n]);return e},t.apply(this,arguments)};function i(e,A,t,i){return new(t||(t=Promise))((function(n,a){function r(e){try{o(i.next(e))}catch(e){a(e)}}function s(e){try{o(i.throw(e))}catch(e){a(e)}}function o(e){var A;e.done?n(e.value):(A=e.value,A instanceof t?A:new t((function(e){e(A)}))).then(r,s)}o((i=i.apply(e,A||[])).next())}))}function n(e,A){var t,i,n,a,r={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]};return a={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(a){return function(s){return function(a){if(t)throw new TypeError("Generator is already executing.");for(;r;)try{if(t=1,i&&(n=2&a[0]?i.return:a[0]?i.throw||((n=i.return)&&n.call(i),0):i.next)&&!(n=n.call(i,a[1])).done)return n;switch(i=0,n&&(a=[2&a[0],n.value]),a[0]){case 0:case 1:n=a;break;case 4:return r.label++,{value:a[1],done:!1};case 5:r.label++,i=a[1],a=[0];continue;case 7:a=r.ops.pop(),r.trys.pop();continue;default:if(!((n=(n=r.trys).length>0&&n[n.length-1])||6!==a[0]&&2!==a[0])){r=0;continue}if(3===a[0]&&(!n||a[1]>n[0]&&a[1]<n[3])){r.label=a[1];break}if(6===a[0]&&r.label<n[1]){r.label=n[1],n=a;break}if(n&&r.label<n[2]){r.label=n[2],r.ops.push(a);break}n[2]&&r.ops.pop(),r.trys.pop();continue}a=A.call(e,r)}catch(e){a=[6,e],i=0}finally{t=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function a(e,A,t){if(t||2===arguments.length)for(var i,n=0,a=A.length;n<a;n++)!i&&n in A||(i||(i=Array.prototype.slice.call(A,0,n)),i[n]=A[n]);return e.concat(i||A)}for(var r=function(){function e(e,A,t,i){this.left=e,this.top=A,this.width=t,this.height=i}return e.prototype.add=function(A,t,i,n){return new e(this.left+A,this.top+t,this.width+i,this.height+n)},e.fromClientRect=function(A,t){return new e(t.left+A.windowBounds.left,t.top+A.windowBounds.top,t.width,t.height)},e.fromDOMRectList=function(A,t){var i=Array.from(t).find((function(e){return 0!==e.width}));return i?new e(i.left+A.windowBounds.left,i.top+A.windowBounds.top,i.width,i.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),s=function(e,A){return r.fromClientRect(e,A.getBoundingClientRect())},o=function(e){for(var A=[],t=0,i=e.length;t<i;){var n=e.charCodeAt(t++);if(n>=55296&&n<=56319&&t<i){var a=e.charCodeAt(t++);56320==(64512&a)?A.push(((1023&n)<<10)+(1023&a)+65536):(A.push(n),t--)}else A.push(n)}return A},l=function(){for(var e=[],A=0;A<arguments.length;A++)e[A]=arguments[A];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var t=e.length;if(!t)return"";for(var i=[],n=-1,a="";++n<t;){var r=e[n];r<=65535?i.push(r):(r-=65536,i.push(55296+(r>>10),r%1024+56320)),(n+1===t||i.length>16384)&&(a+=String.fromCharCode.apply(String,i),i.length=0)}return a},c="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="undefined"==typeof Uint8Array?[]:new Uint8Array(256),h=0;h<c.length;h++)d[c.charCodeAt(h)]=h;for(var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="undefined"==typeof Uint8Array?[]:new Uint8Array(256),p=0;p<u.length;p++)g[u.charCodeAt(p)]=p;for(var m=function(e,A,t){return e.slice?e.slice(A,t):new Uint16Array(Array.prototype.slice.call(e,A,t))},w=function(){function e(e,A,t,i,n,a){this.initialValue=e,this.errorValue=A,this.highStart=t,this.highValueIndex=i,this.index=n,this.data=a}return e.prototype.get=function(e){var A;if(e>=0){if(e<55296||e>56319&&e<=65535)return A=((A=this.index[e>>5])<<2)+(31&e),this.data[A];if(e<=65535)
//![[link|alias]] [alias](link){num}
EXPR:/(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g,getRes:e=>e.matchAll(REGEX_LINK.EXPR),isTransclusion:e=>!!e.value[1],getLink:e=>e.value[3]?e.value[3]:e.value[6],isWikiLink:e=>!!e.value[3],getAliasOrLink:e=>REGEX_LINK.isWikiLink(e)?e.value[4]?e.value[4]:e.value[3]:e.value[5]?e.value[5]:e.value[6],getWrapLength:(e,A)=>{const t=parseInt(e.value[8]);return isNaN(t)?A>0?A:null:t}},DRAWING_REG=/\n# Drawing\n[^`]*(```json\n)([\s\S]*?)```\n/gm,DRAWING_REG_FALLBACK=/\n# Drawing\n(```json\n)?(.*)(```)?(%%)?/gm,DRAWING_COMPRESSED_REG=/(\n# Drawing\n[^`]*(?:```compressed\-json\n))([\s\S]*?)(```\n)/gm,DRAWING_COMPRESSED_REG_FALLBACK=/(\n# Drawing\n(?:```compressed\-json\n)?)(.*)((```)?(%%)?)/gm,REG_LINKINDEX_HYPERLINK=/^\w+:\/\//,isCompressedMD=e=>null!==e.match(/```compressed\-json\n/gm),getDecompressedScene=e=>{let A,t=e.matchAll(DRAWING_COMPRESSED_REG);return A=t.next(),A.done&&(t=e.matchAll(DRAWING_COMPRESSED_REG_FALLBACK),A=t.next()),A.value&&A.value.length>1?[decompress(A.value[2]),A]:[null,A]},changeThemeOfExcalidrawMD=e=>{const A=isCompressedMD(e);let t=A?getDecompressedScene(e)[0]:e;return t?(isObsidianThemeDark?1===(t.match(/"theme"\s*:\s*"light"\s*,/g)||[]).length&&(t=t.replace(/"theme"\s*:\s*"light"\s*,/,'"theme": "dark",')):1===(t.match(/"theme"\s*:\s*"dark"\s*,/g)||[]).length&&(t=t.replace(/"theme"\s*:\s*"dark"\s*,/,'"theme": "light",')),A?e.replace(DRAWING_COMPRESSED_REG,`$1${compress(t)}$3`):t):e};function getJSON(e){let A,t;if(isCompressedMD(e)){const[A,t]=getDecompressedScene(e);return A?{scene:A.substring(0,A.lastIndexOf("}")+1),pos:t.value.index}:{scene:e,pos:t.value?t.value.index:0}}if(A=e.matchAll(DRAWING_REG),t=A.next(),t.done&&(A=e.matchAll(DRAWING_REG_FALLBACK),t=A.next()),t.value&&t.value.length>1){const e=t.value[2];return{scene:e.substr(0,e.lastIndexOf("}")+1),pos:t.value.index}}return{scene:e,pos:t.value?t.value.index:0}}function getMarkdownDrawingSection(e,A){return A?`%%\n# Drawing\n\`\`\`compressed-json\n${compress(e)}\n\`\`\`\n%%`:`%%\n# Drawing\n\`\`\`json\n${e}\n\`\`\`\n%%`}const estimateMaxLineLen=(e,A)=>{if(!A||!e)return null;if(e===A)return null;let t=0;const i=e.split("\n");if(1===i.length)return null;for(const e of i){const A=e.trim();A.length>t&&(t=A.length)}return t},wrap=(e,A)=>A?wrapTextAtCharLength(e,A,!1,0):e;class ExcalidrawData{constructor(e){this.plugin=e,this.textElements=null,this.elementLinks=null,this.scene=null,this.deletedElements=[],this.file=null,this.autoexportPreference=AutoexportPreference.inherit,this.textMode=TextMode.raw,this.loaded=!1,this.files=null,this.equations=null,this.compatibilityMode=!1,this.selectedElementIds={},this.disableCompression=!1,this.app=e.app,this.files=new Map,this.equations=new Map}initializeNonInitializedFields(){var e,A,t;if(!this.scene||!this.scene.elements)return;const i=null!==(e=this.scene.source.split("https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/")[1])&&void 0!==e?e:"1.8.16",n=this.scene.elements;for(const e of n){if(e.boundElements){const A=new Map;e.boundElements.forEach((e=>{A.set(e.id,e.type)}));const t=Array.from(A,(([e,A])=>({id:e,type:A})));t.length!==e.boundElements.length&&(e.boundElements=t)}e.boundElementIds&&(e.boundElements||(e.boundElements=[]),e.boundElements=e.boundElements.concat(e.boundElementIds.map((e=>({type:"arrow",id:e})))),delete e.boundElementIds),"text"!==e.type||e.containerId||(e.containerId=null),null===e.x&&(e.x=0),null===e.y&&(e.y=0),null===(null===(A=e.startBinding)||void 0===A?void 0:A.focus)&&(e.startBinding.focus=0),null===(null===(t=e.endBinding)||void 0===t?void 0:t.focus)&&(e.endBinding.focus=0),null===e.fontSize&&(e.fontSize=20)}try{n.filter((e=>"text"===e.type&&e.containerId&&n.some((A=>A.id===e.containerId&&A.boundElements.length>0&&A.boundElements.some((A=>"text"===A.type&&A.id!==e.id&&A.id.length>8)))))).forEach((e=>{try{const A=n.filter((A=>A.id===e.containerId))[0],t=A.boundElements.filter((e=>!("text"===e.type&&!n.some((A=>A.id===e.id)))));A.boundElements=[{id:e.id,type:"text"}].concat(t)}catch(e){}}));const e=!isVersionNewerThanOther(i,"1.8.1
//!Temporary hack
if(e.activeExcalidrawView=n,n&&(e.lastActiveExcalidrawFilePath=null===(t=n.file)||void 0===t?void 0:t.path),app.isMobile&&n&&!i){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="relative")}if(app.isMobile&&!n&&i){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="")}if(i&&i!==n&&(i.leaf!==A&&i.semaphores.dirty&&!i.semaphores.viewunload&&await i.save(!0),i.file&&e.triggerEmbedUpdates(i.file.path)),n&&(!i||i.leaf!==A)){const e=n.file;n.file&&setTimeout((()=>{var A;n&&n._loaded&&(null===(A=n.file)||void 0===A?void 0:A.path)===(null==e?void 0:e.path)&&(n.activeLoader||n.loadSceneFiles())}),2e3)}if(n&&n._loaded&&n.isLoaded&&n.excalidrawAPI&&e.ea.onCanvasColorChangeHook&&e.ea.onCanvasColorChangeHook(e.ea,n,n.excalidrawAPI.getAppState().viewBackgroundColor),e.popScope&&(e.popScope(),e.popScope=null),n){const A=e.app.keymap.getRootScope(),t=A.register(["Mod"],"Enter",(()=>!0));A.keys.unshift(A.keys.pop());const i=A.register(["Mod"],"k",(()=>!0));A.keys.unshift(A.keys.pop());const n=A.register(["Mod"],"f",(()=>{const e=this.app.workspace.getActiveViewOfType(ExcalidrawView);return!!e&&(search(e),!0)}));A.keys.unshift(A.keys.pop());const a=e.forceSaveCommand&&"s"===e.forceSaveCommand.hotkeys[0].key&&e.forceSaveCommand.hotkeys[0].modifiers.includes("Ctrl")?A.register(["Ctrl"],"s",(()=>e.forceSaveActiveView(!1))):void 0;a&&A.keys.unshift(A.keys.pop()),e.popScope=()=>{A.unregister(t),A.unregister(i),A.unregister(n),Boolean(a)&&A.unregister(a)}}}))),e.addFileSaveTriggerEventHandlers();const A=app.metadataCache;A.getCachedFiles().forEach((t=>{var i;const n=null===(i=A.getCache(t))||void 0===i?void 0:i.frontmatter;(n&&void 0!==n[FRONTMATTER_KEY]||t.match(/\.excalidraw$/))&&e.updateFileCache(app.vault.getAbstractFileByPath(t),n)})),this.registerEvent(A.on("changed",((e,A,t)=>this.updateFileCache(e,null==t?void 0:t.frontmatter))))}))}addFileSaveTriggerEventHandlers(){this.registerEvent(this.app.workspace.on("click",(e=>{this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&(!e.target||"excalidraw__canvas"!==e.target.className&&!getParentOfClass(e.target,"excalidraw-wrapper"))&&this.activeExcalidrawView.save()}))),this.registerEvent(this.app.workspace.on("file-menu",(()=>{this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&this.activeExcalidrawView.save()}))),this.modalContainerObserver=new MutationObserver((async e=>{1===e.length&&"childList"===e[0].type&&1===e[0].addedNodes.length&&this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&this.activeExcalidrawView.save()})),this.modalContainerObserver.observe(document.body,{childList:!0});const e=document.querySelector(".workspace-drawer.mod-left"),A=document.querySelector(".workspace-drawer.mod-right");if(e||A){const t=async e=>{"display: none;"===e[0].oldValue&&this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&this.activeExcalidrawView.save()},i={attributeOldValue:!0,attributeFilter:["style"]};e&&(this.workspaceDrawerLeftObserver=new MutationObserver(t),this.workspaceDrawerLeftObserver.observe(e,i)),A&&(this.workspaceDrawerRightObserver=new MutationObserver(t),this.workspaceDrawerRightObserver.observe(A,i))}}updateFileCache(e,A,t=!1){A&&void 0!==A[FRONTMATTER_KEY]?this.excalidrawFiles.add(e):t||"excalidraw"!==e.extension?this.excalidrawFiles.delete(e):this.excalidrawFiles.add(e)}onunload(){destroyExcalidrawAutomate(),this.popScope&&(this.popScope(),this.popScope=null),this.observer.disconnect(),this.themeObserver.disconnect(),this.modalContainerObserver.disconnect(),this.workspaceDrawerLeftObserver&&this.workspaceDrawerLeftObserver.disconnect(),this.workspaceDrawerRightObserver&&this.workspaceDrawerRightObserver.disconnect(),this.fileExplorerObserver&&this.fileExplorerObserver.disconnect(),this.app.workspace.getLeavesOfType("excalidraw").forEach((e=>{this.setMarkdownView(e)})),this.mathjaxDiv&&document.body.removeChild(this.mathjaxDiv),Object.values(this.packageMap).forEach((e=>{