102 lines
4.4 MiB
JavaScript
102 lines
4.4 MiB
JavaScript
|
"use strict";var obsidian_module=require("obsidian"),state=require("@codemirror/state"),view=require("@codemirror/view");var LZString=function(){var r=String.fromCharCode,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",e={};function t(r,o){if(!e[r]){e[r]={};for(var n=0;n<r.length;n++)e[r][r.charAt(n)]=n}return e[r][o]}var i={compressToBase64:function(r){if(null==r)return"";var n=i._compress(r,6,function(r){return o.charAt(r)});switch(n.length%4){default:case 0:return n;case 1:return n+"===";case 2:return n+"==";case 3:return n+"="}},decompressFromBase64:function(r){return null==r?"":""==r?null:i._decompress(r.length,32,function(n){return t(o,r.charAt(n))})},compressToUTF16:function(o){return null==o?"":i._compress(o,15,function(o){return r(o+32)})+" "},decompressFromUTF16:function(r){return null==r?"":""==r?null:i._decompress(r.length,16384,function(o){return r.charCodeAt(o)-32})},compressToUint8Array:function(r){for(var o=i.compress(r),n=new Uint8Array(2*o.length),e=0,t=o.length;e<t;e++){var s=o.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null==o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;e<t;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(r){return null==r?"":i._compress(r,6,function(r){return n.charAt(r)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(o){return t(n,r.charAt(o))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(r,o,n){if(null==r)return"";var e,t,i,s={},u={},a="",p="",c="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;i<r.length;i+=1)if(a=r.charAt(i),Object.prototype.hasOwnProperty.call(s,a)||(s[a]=f++,u[a]=!0),p=c+a,Object.prototype.hasOwnProperty.call(s,p))c=p;else{if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++),s[p]=f++,c=String(a)}if(""!==c){if(Object.prototype.hasOwnProperty.call(u,c)){if(c.charCodeAt(0)<256){for(e=0;e<h;e++)m<<=1,v==o-1?(v=0,d.push(n(m)),m=0):v++;for(t=c.charCodeAt(0),e=0;e<8;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;e<h;e++)m=m<<1|t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=c.charCodeAt(0),e=0;e<16;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}0==--l&&(l=Math.pow(2,h),h++),delete u[c]}else for(t=s[c],e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;0==--l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;e<h;e++)m=m<<1|1&t,v==o-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==o-1){d.push(n(m));break}v++}return d.join("")},decompress:function(r){return null==r?"":""==r?null:i._decompress(r.length,32768,function(o){return r.charCodeAt(o)})},_decompress:function(o,n,e){var t,i,s,u,a,p,c,l=[],f=4,h=4,d=3,m="",v=[],g={val:e(0),position:n,index:1};for(t=0;t<3;t+=1)l[t]=t;for(s=0,a=Math.pow(2,2),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;switch(s){case 0:for(s=0,a=Math.pow(2,8),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 1:for(s=0,a=Math.pow(2,16),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.index++)),s|=(u>0?1:0)*p,p<<=1;c=r(s);break;case 2:return""}for(l[3]=c,i=c,v.push(c);;){if(g.index>o)return"";for(s=0,a=Math.pow(2,d),p=1;p!=a;)u=g.val&g.position,g.position>>=1,0==g.position&&(g.position=n,g.val=e(g.i
|
||
|
const EXCALIDRAW_PACKAGES = "PQKhCgAIUgBAbAlgYwKYDsDOrICVUCGyALlDAE6EkB0ADuQPYAmAriYg+tQLaJcBWmMmUgBhBrQCe5RAHMAFsUgAKZAEpIAMSKoARgwYBrADSQAkumTVIBdE0iJimGwDMXiJAWKpM1YdEgAFXlEZ0wGFnI0SGRmHFDIJDQsVHsWO1RySGJ5HABZM0DElAxsSBcIuwd0bNyRABkzUQBRADkAZWbyj3ianJxGBiUmREoSBnJJSAYXWoTwyOjiSlQ/aGBwZRd09k5lNQBvAHIWMsxllGIjgG4tneIOdFVjAA9DgCIGXX5UEneAXkBxEktFQM0gqBetAmTgAZLD3ukmKh3OhUu8AIRAkFg2bcZgseCoAD8L2UkOh5CcagAXO9tpYHpwAdjQeDkajUPCOXxVgRuExiTy0coANrvCkwzDvAC6r1pqn+yAAPsrsPAXK9VNR8ERiP8DgBfNRqY3KHKhYwM3ZPdQHa1MmpkgiHRAuZToQnwQH/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FxRDRv2jHP37HQGTVOVOU0AmDQAAFVdx9xkMY5+47Q8IMByjUBTl8AfFUAm4GiQ1nwYYw9WiyiKiej5ZejvBGjL9mjB5DgiZ2pExWUaBzJMA5B0BjA1xcJrgOx3whghgcQdtMBdQSBxBuBoQ0QZwtidiRwG5AZgdxjh1IN+jG1J4aUQxqxJltYK9HR3jx4C44wsQXQvlMZe9QV5DsBiAJjUBlBqBYTaRshAEfAbAagaVphZh20cB/In9dAiRnB5UwJ9xphlVyhBsOwQh5oFUNFoUUTIUlBwQMSEUZACAcSfA6FfJwBJwCSIIIcRiOixjITHjzQlxo1nwH4
|
||
|
const {react, reactDOM, excalidrawLib} = window.eval.call(window, `(function() {${LZString.decompressFromBase64(EXCALIDRAW_PACKAGES)};return {react: React, reactDOM: ReactDOM, excalidrawLib: ExcalidrawLib};})();`);
|
||
|
const PLUGIN_VERSION="2.2.6";;function _interopNamespace(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(n){if("default"!==n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}})),t.default=e,Object.freeze(t)}var obsidian_module__namespace=_interopNamespace(obsidian_module),React__namespace=_interopNamespace(React);let random$1=e=>crypto.getRandomValues(new Uint8Array(e)),customRandom=(e,t,n)=>{let i=(2<<Math.log(e.length-1)/Math.LN2)-1,r=-~(1.6*i*t/e.length);return(o=t)=>{let a="";for(;;){let t=n(r),s=r;for(;s--;)if(a+=e[t[s]&i]||"",a.length===o)return a}}},customAlphabet=(e,t=21)=>customRandom(e,t,random$1),nanoid$1=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce(((e,t)=>e+((t&=63)<36?t.toString(36):t<62?(t-26).toString(36).toUpperCase():t>62?"-":"_")),""),EXCALIDRAW_PLUGIN=null;const setExcalidrawPlugin=e=>{EXCALIDRAW_PLUGIN=e},MD_EXCALIDRAW="# Excalidraw Data",MD_TEXTELEMENTS="## Text Elements",MD_ELEMENTLINKS="## Element Links",MD_EMBEDFILES="## Embedded Files",MD_DRAWING="## Drawing",MD_EX_SECTIONS=[MD_EXCALIDRAW,MD_TEXTELEMENTS,MD_ELEMENTLINKS,MD_EMBEDFILES,MD_DRAWING],ERROR_IFRAME_CONVERSION_CANCELED="iframe conversion canceled",LOCALE=obsidian_module.moment.locale(),obsidianToExcalidrawMap={en:"en-US",af:"af-ZA",am:"am-ET",ar:"ar-SA",eu:"eu-ES",be:"be-BY",bg:"bg-BG",bn:"bn-BD",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",el:"el-GR",eo:"eo-EO",es:"es-ES",fa:"fa-IR","fi-fi":"fi-FI",fr:"fr-FR",gl:"gl-ES",he:"he-IL",hi:"hi-IN",hu:"hu-HU",id:"id-ID",it:"it-IT",ja:"ja-JP",ko:"ko-KR",lv:"lv-LV",ml:"ml-IN",ms:"ms-MY",nl:"nl-NL",no:"nb-NO",oc:"oc-FR",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sr:"sr-RS",se:"sv-SE",sk:"sk-SK",sq:"sq-AL",ta:"ta-IN",te:"te-IN",th:"th-TH",tr:"tr-TR",uk:"uk-UA",ur:"ur-PK",vi:"vi-VN",zh:"zh-CN","zh-TW":"zh-TW"},{sceneCoordsToViewportCoords:sceneCoordsToViewportCoords,viewportCoordsToSceneCoords:viewportCoordsToSceneCoords,determineFocusDistance:determineFocusDistance,intersectElementWithLine:intersectElementWithLine,getCommonBoundingBox:getCommonBoundingBox,getMaximumGroups:getMaximumGroups,measureText:measureText,getDefaultLineHeight:getDefaultLineHeight,wrapText:wrapText,getFontString:getFontString,getBoundTextMaxWidth:getBoundTextMaxWidth,exportToSvg:exportToSvg,exportToBlob:exportToBlob,mutateElement:mutateElement,restore:restore,mermaidToExcalidraw:mermaidToExcalidraw,getContainerElement:getContainerElement,refreshTextDimensions:refreshTextDimensions}=excalidrawLib;function JSON_parse(e){return JSON.parse(e.replaceAll("[","["))}/Mac|iPod|iPhone|iPad/.test(window.navigator.platform);const DEVICE={isDesktop:!document.body.hasClass("is-tablet")&&!document.body.hasClass("is-mobile"),isPhone:document.body.hasClass("is-phone"),isTablet:document.body.hasClass("is-tablet"),isMobile:document.body.hasClass("is-mobile"),isLinux:document.body.hasClass("mod-linux")&&!document.body.hasClass("is-android"),isMacOS:document.body.hasClass("mod-macos")&&!document.body.hasClass("is-ios"),isWindows:document.body.hasClass("mod-windows"),isIOS:document.body.hasClass("is-ios"),isAndroid:document.body.hasClass("is-android")},ROOTELEMENTSIZE=(()=>{const e=document.createElement("div");e.style.fontSize="1rem",e.style.display="none",document.body.appendChild(e);const t=getComputedStyle(e),n=parseFloat(t.fontSize);return document.body.removeChild(e),n})(),nanoid=customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",8),KEYCODE={ESC:27},ROUNDNESS={LEGACY:1,PROPORTIONAL_RADIUS:2,ADAPTIVE_RADIUS:3},THEME_FILTER="invert(100%) hue-rotate(180deg) saturate(1.25)",GITHUB_RELEASES="https://github.com/zsviczian/obsidian-excalidraw-plugin/releases/tag/",URLFETCHTIMEOUT=3e3,PLUGIN_ID="obsidian-excalidraw-plugin",SCRIPT_INSTALL_CODEBLOCK="excalidraw-script-install",SCRIPT_INSTALL_FOLDER="Downloaded",fileid=customAlphabet("1234567890abcdef",40),REG_LINKINDEX_INVALIDCHARS=/[<>:"\\|?*#]/g,REG_SECTION_REF_CLEAN=/([:#|^\\\r\n]|%%|\[\[|]])/g,REG_BLOCK_REF_CLEA
|
||
|
/*!
|
||
|
*************************************************************************
|
||
|
*
|
||
|
* mhchemParser.ts
|
||
|
* 4.2.1
|
||
|
*
|
||
|
* Parser for the \ce command and \pu command for MathJax and Co.
|
||
|
*
|
||
|
* mhchem's \ce is a tool for writing beautiful chemical equations easily.
|
||
|
* mhchem's \pu is a tool for writing physical units easily.
|
||
|
*
|
||
|
* ----------------------------------------------------------------------
|
||
|
*
|
||
|
* Copyright (c) 2015-2023 Martin Hensel
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
*
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing, software
|
||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||
|
* See the License for the specific language governing permissions and
|
||
|
* limitations under the License.
|
||
|
*
|
||
|
* ----------------------------------------------------------------------
|
||
|
*
|
||
|
* https://github.com/mhchem/mhchemParser
|
||
|
*
|
||
|
*/
|
||
|
Object.defineProperty(mhchemParser$1,"__esModule",{value:!0}),mhchemParser$1.mhchemParser=void 0;var mhchemParser=function(){function e(){}return e.toTex=function(e,t){return _mhchemTexify.go(_mhchemParser.go(e,t),"tex"!==t)},e}();function _mhchemCreateTransitions(e){var t,n,i={};for(t in e)for(n in e[t]){var r=n.split("|");e[t][n].stateArray=r;for(var o=0;o<r.length;o++)i[r[o]]=[]}for(t in e)for(n in e[t])for(r=e[t][n].stateArray||[],o=0;o<r.length;o++){var a=e[t][n];a.action_=[].concat(a.action_);for(var s=0;s<a.action_.length;s++)"string"==typeof a.action_[s]&&(a.action_[s]={type_:a.action_[s]});for(var l=t.split("|"),c=0;c<l.length;c++)if("*"===r[o]){var T=void 0;for(T in i)i[T].push({pattern:l[c],task:a})}else i[r[o]].push({pattern:l[c],task:a})}return i}mhchemParser$1.mhchemParser=mhchemParser;var _mhchemParser={go:function(e,t){if(!e)return[];void 0===t&&(t="ce");var n,i="0",r={parenthesisLevel:0};e=(e=(e=e.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var o=10,a=[];;){n!==e?(o=10,n=e):o--;var s=_mhchemParser.stateMachines[t],l=s.transitions[i]||s.transitions["*"];e:for(var c=0;c<l.length;c++){var T=_mhchemParser.patterns.match_(l[c].pattern,e);if(T){for(var d=l[c].task,Q=0;Q<d.action_.length;Q++){var u=void 0;if(s.actions[d.action_[Q].type_])u=s.actions[d.action_[Q].type_](r,T.match_,d.action_[Q].option);else{if(!_mhchemParser.actions[d.action_[Q].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+d.action_[Q].type_+")"];u=_mhchemParser.actions[d.action_[Q].type_](r,T.match_,d.action_[Q].option)}_mhchemParser.concatArray(a,u)}if(i=d.nextState||i,!(e.length>0))return a;if(d.revisit||(e=T.remainder),!d.toContinue)break e}}if(o<=0)throw["MhchemBugU","mhchem bug U. Please report."]}},concatArray:function(e,t){if(t)if(Array.isArray(t))for(var n=0;n<t.length;n++)e.push(t[n]);else e.push(t)},patterns:{patterns:{empty:/^$/,else:/^./,else2:/^./,space:/^\s/,"space A":/^\s(?=[A-Z\\$])/,space$:/^\s$/,"a-z":/^[a-z]/,x:/^x/,x$:/^x$/,i$:/^i$/,letters:/^(?:[a-zA-Z\u03B1-\u03C9\u0391-\u03A9?@]|(?:\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))))+/,"\\greek":/^\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega|Gamma|Delta|Theta|Lambda|Xi|Pi|Sigma|Upsilon|Phi|Psi|Omega)(?:\s+|\{\}|(?![a-zA-Z]))/,"one lowercase latin letter $":/^(?:([a-z])(?:$|[^a-zA-Z]))$/,"$one lowercase latin letter$ $":/^\$(?:([a-z])(?:$|[^a-zA-Z]))\$$/,"one lowercase greek letter $":/^(?:\$?[\u03B1-\u03C9]\$?|\$?\\(?:alpha|beta|gamma|delta|epsilon|zeta|eta|theta|iota|kappa|lambda|mu|nu|xi|omicron|pi|rho|sigma|tau|upsilon|phi|chi|psi|omega)\s*\$?)(?:\s+|\{\}|(?![a-zA-Z]))$/,digits:/^[0-9]+/,"-9.,9":/^[+\-]?(?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))/,"-9.,9 no missing 0":/^[+\-]?[0-9]+(?:[.,][0-9]+)?/,"(-)(9.,9)(e)(99)":function(e){var t=e.match(/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))?(\((?:[0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+))\))?(?:(?:([eE])|\s*(\*|x|\\times|\u00D7)\s*10\^)([+\-]?[0-9]+|\{[+\-]?[0-9]+\}))?/);return t&&t[0]?{match_:t.slice(1),remainder:e.substr(t[0].length)}:null},"(-)(9)^(-9)":/^(\+\-|\+\/\-|\+|\-|\\pm\s?)?([0-9]+(?:[,.][0-9]+)?|[0-9]*(?:\.[0-9]+)?)\^([+\-]?[0-9]+|\{[+\-]?[0-9]+\})/,"state of aggregation $":function(e){var t=_mhchemParser.patterns.findObserveGroups(e,"",/^\([a-z]{1,3}(?=[\),])/,")","");if(t&&t.remainder.match(/^($|[\s,;\)\]\}])/))return t;var n=e.match(/^(?:\((?:\\ca\s?)?\$[amothc]\$\))/);return n?{match_:n[0],remainder:e.substr(n[0].length)}:null},"_{(state of aggregation)}$":/^_\{(\([a-z]{1,3}\))\}/,"{[(":/^(?:\\\{|\[|\()/,")]}":/^(?:\)|\]|\\\})/,", ":/^[,;]\s*/,",":/^[,;]/,".":/^[.]/,". __* ":/^([.\u22C5\u00B7\u2022]|[*])\s*/,"...":/^\.\.\.(?=$|[^.])/,"^{(...)}":function(e){return _mhchemParser.patterns.findObserveGroups(e,"^{","","","}")},"^($...$)":function(e){return _mhchemParser.pattern
|
||
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */
|
||
|
function isNothing(e){return null==e}function isObject(e){return"object"==typeof e&&null!==e}function toArray(e){return Array.isArray(e)?e:isNothing(e)?[]:[e]}function extend(e,t){var n,i,r,o;if(t)for(n=0,i=(o=Object.keys(t)).length;n<i;n+=1)e[r=o[n]]=t[r];return e}function repeat(e,t){var n,i="";for(n=0;n<t;n+=1)i+=e;return i}function isNegativeZero(e){return 0===e&&Number.NEGATIVE_INFINITY===1/e}var isNothing_1=isNothing,isObject_1=isObject,toArray_1=toArray,repeat_1=repeat,isNegativeZero_1=isNegativeZero,extend_1=extend,common={isNothing:isNothing_1,isObject:isObject_1,toArray:toArray_1,repeat:repeat_1,isNegativeZero:isNegativeZero_1,extend:extend_1};function formatError(e,t){var n="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+="\n\n"+e.mark.snippet),i+" "+n):i}function YAMLException$1(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=formatError(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack||""}YAMLException$1.prototype=Object.create(Error.prototype),YAMLException$1.prototype.constructor=YAMLException$1,YAMLException$1.prototype.toString=function(e){return this.name+": "+formatError(this,e)};var exception=YAMLException$1;function getLine(e,t,n,i,r){var o="",a="",s=Math.floor(r/2)-1;return i-t>s&&(t=i-s+(o=" ... ").length),n-i>s&&(n=i+s-(a=" ...").length),{str:o+e.slice(t,n).replace(/\t/g,"→")+a,pos:i-t+o.length}}function padStart(e,t){return common.repeat(" ",t-e.length)+e}function makeSnippet(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),"number"!=typeof t.indent&&(t.indent=1),"number"!=typeof t.linesBefore&&(t.linesBefore=3),"number"!=typeof t.linesAfter&&(t.linesAfter=2);for(var n,i=/\r?\n|\r|\0/g,r=[0],o=[],a=-1;n=i.exec(e.buffer);)o.push(n.index),r.push(n.index+n[0].length),e.position<=n.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var s,l,c="",T=Math.min(e.line+t.linesAfter,o.length).toString().length,d=t.maxLength-(t.indent+T+3);for(s=1;s<=t.linesBefore&&!(a-s<0);s++)l=getLine(e.buffer,r[a-s],o[a-s],e.position-(r[a]-r[a-s]),d),c=common.repeat(" ",t.indent)+padStart((e.line-s+1).toString(),T)+" | "+l.str+"\n"+c;for(l=getLine(e.buffer,r[a],o[a],e.position,d),c+=common.repeat(" ",t.indent)+padStart((e.line+1).toString(),T)+" | "+l.str+"\n",c+=common.repeat("-",t.indent+T+3+l.pos)+"^\n",s=1;s<=t.linesAfter&&!(a+s>=o.length);s++)l=getLine(e.buffer,r[a+s],o[a+s],e.position-(r[a]-r[a+s]),d),c+=common.repeat(" ",t.indent)+padStart((e.line+s+1).toString(),T)+" | "+l.str+"\n";return c.replace(/\n$/,"")}var snippet=makeSnippet,TYPE_CONSTRUCTOR_OPTIONS=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],YAML_NODE_KINDS=["scalar","sequence","mapping"];function compileStyleAliases(e){var t={};return null!==e&&Object.keys(e).forEach((function(n){e[n].forEach((function(e){t[String(e)]=n}))})),t}function Type$1(e,t){if(t=t||{},Object.keys(t).forEach((function(t){if(-1===TYPE_CONSTRUCTOR_OPTIONS.indexOf(t))throw new exception('Unknown option "'+t+'" is met in definition of "'+e+'" YAML type.')})),this.options=t,this.tag=e,this.kind=t.kind||null,this.resolve=t.resolve||function(){return!0},this.construct=t.construct||function(e){return e},this.instanceOf=t.instanceOf||null,this.predicate=t.predicate||null,this.represent=t.represent||null,this.representName=t.representName||null,this.defaultStyle=t.defaultStyle||null,this.multi=t.multi||!1,this.styleAliases=compileStyleAliases(t.styleAliases||null),-1===YAML_NODE_KINDS.indexOf(this.kind))throw new exception('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var type=Type$1;function compileList(e,t){var n=[];return e[t].forEach((function(e){var t=n.length;n.forEach((function(n,i){n.tag===e.tag&&n.kind===e.kind&&n.multi===e.multi&&(t=i)})),n[t]=e})),n}function compileMap(){var e,t,n={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scala
|
||
|
//![[link|alias]] [alias](link){num}
|
||
|
EXPR:/(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g,getResList:e=>{const t=e.matchAll(REGEX_LINK.EXPR);let n;const i=[];for(;!(n=t.next()).done;)i.push(n);return i},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,t)=>{const n=parseInt(e.value[8]);return isNaN(n)?t>0?t:null:n}},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 t,n=e.matchAll(DRAWING_COMPRESSED_REG);return t=n.next(),t.done&&(n=e.matchAll(DRAWING_COMPRESSED_REG_FALLBACK),t=n.next()),t.value&&t.value.length>1?[decompress(t.value[2]),t]:[null,t]},changeThemeOfExcalidrawMD=e=>{const t=isCompressedMD(e);let n=t?getDecompressedScene(e)[0]:e;return n?(isObsidianThemeDark?1===(n.match(/"theme"\s*:\s*"light"\s*,/g)||[]).length&&(n=n.replace(/"theme"\s*:\s*"light"\s*,/,'"theme": "dark",')):1===(n.match(/"theme"\s*:\s*"dark"\s*,/g)||[]).length&&(n=n.replace(/"theme"\s*:\s*"dark"\s*,/,'"theme": "light",')),t?e.replace(DRAWING_COMPRESSED_REG,`$1${compress(n)}$3`):n):e};function getJSON(e){let t,n;if(isCompressedMD(e)){const[t,n]=getDecompressedScene(e);return t?{scene:t.substring(0,t.lastIndexOf("}")+1),pos:n.value.index}:{scene:e,pos:n.value?n.value.index:0}}if(t=e.matchAll(DRAWING_REG),n=t.next(),n.done&&(t=e.matchAll(DRAWING_REG_FALLBACK),n=t.next()),n.value&&n.value.length>1){const e=n.value[2];return{scene:e.substr(0,e.lastIndexOf("}")+1),pos:n.value.index}}return{scene:e,pos:n.value?n.value.index:0}}function getMarkdownDrawingSection(e,t){return t?`## Drawing\n\`\`\`compressed-json\n${compress(e)}\n\`\`\`\n%%`:`## Drawing\n\`\`\`json\n${e}\n\`\`\`\n%%`}const RE_EXCALIDRAWDATA_WITHSECTION_OK=/^(#\n+)%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_WITHSECTION_NOTOK=/#\n+%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_NOSECTION_OK=/^(%%\n+)?# Excalidraw Data(?:\n|$)/m,RE_TEXTELEMENTS_WITHSECTION_OK=/^#\n+%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_WITHSECTION_NOTOK=/#\n+%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_NOSECTION_OK=/^(%%\n+)?##? Text Elements(?:\n|$)/m,RE_EXCALIDRAWDATA_FALLBACK_1=/(.*)%%\n+# Excalidraw Data(?:\n|$)/m,RE_EXCALIDRAWDATA_FALLBACK_2=/(.*)# Excalidraw Data(?:\n|$)/m,RE_TEXTELEMENTS_FALLBACK_1=/(.*)%%\n+##? Text Elements(?:\n|$)/m,RE_TEXTELEMENTS_FALLBACK_2=/(.*)##? Text Elements(?:\n|$)/m,RE_DRAWING=/^(%%\n+)?##? Drawing\n/m,getExcalidrawMarkdownHeaderSection=(e,t)=>{var n;const i=e.search(RE_DRAWING);i>0&&(e=e.substring(0,i));const r=e.match(RE_EXCALIDRAWDATA_WITHSECTION_OK);let o=null!==(n=null==r?void 0:r.index)&&void 0!==n?n:-1,a=!1;if(o>0&&(o+=r[1].length),-1===o&&(o=e.search(RE_EXCALIDRAWDATA_WITHSECTION_NOTOK),o>0&&(a=!0)),-1===o&&(o=e.search(RE_EXCALIDRAWDATA_NOSECTION_OK)),-1===o){const t=e.match(RE_EXCALIDRAWDATA_FALLBACK_1);t&&Boolean(t[1])&&(o=t.index+t[1].length)}if(-1===o){const t=e.match(RE_EXCALIDRAWDATA_FALLBACK_2);t&&Boolean(t[1])&&(o=t.index+t[1].length)}if(-1===o&&(o=e.search(RE_TEXTELEMENTS_WITHSECTION_OK),o>0&&(o+=2)),-1===o&&(o=e.search(RE_TEXTELEMENTS_WITHSECTION_NOTOK),o>0&&(a=!0)),-1===o&&(o=e.search(RE_TEXTELEMENTS_NOSECTION_OK)),-1===o){const t=e.match(RE_TEXTELEMENTS_FALLBACK_1);t&&Boolean(t[1])&&(o=t.index+t[1].length)}if(-1===o){const t=e.match(RE_TEXTELEMENTS_FALLBACK_2);t&&Boolean(t[1])&&(o=t.index+t[1].length)}if(-1===o&&i>0&&(o=i),-1===o)return e.endsWith("\n")?e:e+"\n";let s=updateFrontmatterInString(e.substring(0,o),t);return a?s+"\n#\n":s.endsWith("\n")?s:s+"\n"};class ExcalidrawData{constructor(e){this.plugin=e,this.textElements=null,this.scene=null,this.delete
|
||
|
/**
|
||
|
* chroma.js - JavaScript library for color conversions
|
||
|
*
|
||
|
* Copyright (c) 2011-2019, Gregor Aisch
|
||
|
* All rights reserved.
|
||
|
*
|
||
|
* Redistribution and use in source and binary forms, with or without
|
||
|
* modification, are permitted provided that the following conditions are met:
|
||
|
*
|
||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||
|
* list of conditions and the following disclaimer.
|
||
|
*
|
||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||
|
* this list of conditions and the following disclaimer in the documentation
|
||
|
* and/or other materials provided with the distribution.
|
||
|
*
|
||
|
* 3. The name Gregor Aisch may not be used to endorse or promote products
|
||
|
* derived from this software without specific prior written permission.
|
||
|
*
|
||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||
|
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
|
* DISCLAIMED. IN NO EVENT SHALL GREGOR AISCH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
|
||
|
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
|
||
|
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||
|
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
|
*
|
||
|
* -------------------------------------------------------
|
||
|
*
|
||
|
* chroma.js includes colors from colorbrewer2.org, which are released under
|
||
|
* the following license:
|
||
|
*
|
||
|
* Copyright (c) 2002 Cynthia Brewer, Mark Harrower,
|
||
|
* and The Pennsylvania State University.
|
||
|
*
|
||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||
|
* you may not use this file except in compliance with the License.
|
||
|
* You may obtain a copy of the License at
|
||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||
|
*
|
||
|
* Unless required by applicable law or agreed to in writing,
|
||
|
* software distributed under the License is distributed on an
|
||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||
|
* either express or implied. See the License for the specific
|
||
|
* language governing permissions and limitations under the License.
|
||
|
*
|
||
|
* ------------------------------------------------------
|
||
|
*
|
||
|
* Named colors are taken from X11 Color Names.
|
||
|
* http://www.w3.org/TR/css3-color/#svg-color
|
||
|
*
|
||
|
* @preserve
|
||
|
*/chroma$1.exports,function(e,t){e.exports=function(){for(var e=function(e,t,n){return void 0===t&&(t=0),void 0===n&&(n=1),e<t?t:e>n?n:e},t=e,n={},i=0,r=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];i<r.length;i+=1){var o=r[i];n["[object "+o+"]"]=o.toLowerCase()}var a=function(e){return n[Object.prototype.toString.call(e)]||"object"},s=a,l=a,c=Math.PI,T={clip_rgb:function(e){e._clipped=!1,e._unclipped=e.slice(0);for(var n=0;n<=3;n++)n<3?((e[n]<0||e[n]>255)&&(e._clipped=!0),e[n]=t(e[n],0,255)):3===n&&(e[n]=t(e[n],0,1));return e},limit:e,type:a,unpack:function(e,t){return void 0===t&&(t=null),e.length>=3?Array.prototype.slice.call(e):"object"==s(e[0])&&t?t.split("").filter((function(t){return void 0!==e[0][t]})).map((function(t){return e[0][t]})):e[0]},last:function(e){if(e.length<2)return null;var t=e.length-1;return"string"==l(e[t])?e[t].toLowerCase():null},PI:c,TWOPI:2*c,PITHIRD:c/3,DEG2RAD:c/180,RAD2DEG:180/c},d={format:{},autodetect:[]},Q=T.last,u=T.clip_rgb,p=T.type,h=d,m=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=this;if("object"===p(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];var i=Q(e),r=!1;if(!i){r=!0,h.sorted||(h.autodetect=h.autodetect.sort((function(e,t){return t.p-e.p})),h.sorted=!0);for(var o=0,a=h.autodetect;o<a.length;o+=1){var s=a[o];if(i=s.test.apply(s,e))break}}if(!h.format[i])throw new Error("unknown format: "+e);var l=h.format[i].apply(null,r?e:e.slice(0,-1));n._rgb=u(l),3===n._rgb.length&&n._rgb.push(1)};m.prototype.toString=function(){return"function"==p(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=m,g=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(g.Color,[null].concat(e)))};g.Color=f,g.version="2.4.2";var b=g,y=T.unpack,L=Math.max,v=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=y(e,"rgb"),i=n[0],r=n[1],o=n[2],a=1-L(i/=255,L(r/=255,o/=255)),s=a<1?1/(1-a):0;return[(1-i-a)*s,(1-r-a)*s,(1-o-a)*s,a]},w=T.unpack,E=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=(e=w(e,"cmyk"))[0],i=e[1],r=e[2],o=e[3],a=e.length>4?e[4]:1;return 1===o?[0,0,0,a]:[n>=1?0:255*(1-n)*(1-o),i>=1?0:255*(1-i)*(1-o),r>=1?0:255*(1-r)*(1-o),a]},_=b,M=f,x=d,H=T.unpack,S=T.type,A=v;M.prototype.cmyk=function(){return A(this._rgb)},_.cmyk=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(M,[null].concat(e,["cmyk"])))},x.format.cmyk=E,x.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=H(e,"cmyk"),"array"===S(e)&&4===e.length)return"cmyk"}});var C=T.unpack,O=T.last,I=function(e){return Math.round(100*e)/100},V=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=C(e,"hsla"),i=O(e)||"lsa";return n[0]=I(n[0]||0),n[1]=I(100*n[1])+"%",n[2]=I(100*n[2])+"%","hsla"===i||n.length>3&&n[3]<1?(n[3]=n.length>3?n[3]:1,i="hsla"):n.length=3,i+"("+n.join(",")+")"},k=T.unpack,N=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=(e=k(e,"rgba"))[0],i=e[1],r=e[2];n/=255,i/=255,r/=255;var o,a,s=Math.min(n,i,r),l=Math.max(n,i,r),c=(l+s)/2;return l===s?(o=0,a=Number.NaN):o=c<.5?(l-s)/(l+s):(l-s)/(2-l-s),n==l?a=(i-r)/(l-s):i==l?a=2+(r-n)/(l-s):r==l&&(a=4+(n-i)/(l-s)),(a*=60)<0&&(a+=360),e.length>3&&void 0!==e[3]?[a,o,c,e[3]]:[a,o,c]},P=T.unpack,R=T.last,D=V,j=N,B=Math.round,F=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var n=P(e,"rgba"),i=R(e)||"rgb";return"hsl"==i.substr(0,3)?D(j(n),i):(n[0]=B(n[0]),n[1]=B(n[1]),n[2]=B(n[2]),("rgba"===i||n.length>3&&n[3]<1)&&(n[3]=n.length>3?n[3]:1,i="rgba"),i+"("+n.slice(0,"rgb"===i?3:4).join(",")+")")},G=T.unpack,W=Math.round,U=function(){for(var e,t=[],n=arguments.length;n--;)t[n]=arguments[n];var i,r,o,a=(t=G(t,"hsl"))[0],s=t[1],l=t[2];if(0===s)i=r=o=255*l;else{var c=[0,0,0],T=[0,0,0],d=l<.5?l*(1+s):l+s-l*s,Q=2*l-d,u=a/360;c[0]=u+1/3,c[1]=u,c[2]=u-1/3;for(var p=0;p<3;p++)c[p]<0&&(c[p]+=1),c[p]>1&&(c[p]-=1),6*c[p]<1?T[p]=Q+6*(d-Q)*c[p]:2*c[p]<1?T
|
||
|
//! onauxclick: (e: any) => {e.preventDefault()},
|
||
|
,renderTopRightUI:(e,t)=>this.obsidianMenu.renderButton(e,t),renderEmbeddableMenu:e=>this.embeddableMenu.renderButtons(e),onPaste:(e,t)=>this.onPaste(e,t),onThemeChange:async e=>this.onThemeChange(e),ownerDocument:this.ownerDocument,ownerWindow:this.ownerWindow,onDrop:e=>this.onDrop(e),onBeforeTextEdit:e=>this.onBeforeTextEdit(e),onBeforeTextSubmit:(e,t,n,i)=>this.onBeforeTextSubmit(e,t,n,i),onLinkOpen:(e,t)=>this.onLinkOpen(e,t),onLinkHover:(e,t)=>this.onLinkHover(e,t),onContextMenu:T,onViewModeChange:e=>this.onViewModeChange(e),validateEmbeddable:!0,renderWebview:DEVICE.isDesktop,renderEmbeddable:(e,t)=>d(e,t),renderMermaid:shouldRenderMermaid(),obsidianHostPlugin:this.plugin},Q(),t.createElement(a,{},t.createElement(a.Center,{},t.createElement(a.Center.Logo,{},t.createElement(LogoWrapper,{},ICONS.ExcalidrawSword)),t.createElement(a.Center.Heading,{},'Type "Excalidraw" in the Command Palette',t.createElement("br"),"Explore the Obsidian Menu in the top right",t.createElement("br"),"Visit the Script Library",t.createElement("br"),"Find help in the hamburger-menu"),t.createElement(a.Center.Menu,{},t.createElement(a.Center.MenuItemLink,{icon:ICONS.YouTube,href:"https://www.youtube.com/@VisualPKM",shortcut:null,"aria-label":"Visual PKM YouTube Channel"}," Check out the Visual PKM YouTube channel."),t.createElement(a.Center.MenuItemLink,{icon:ICONS.Discord,href:"https://discord.gg/DyfAXFwUHc",shortcut:null,"aria-label":"Join the Visual Thinking Discord Server"}," Join the Visual Thinking Discord Server"),t.createElement(a.Center.MenuItemLink,{icon:ICONS.twitter,href:"https://twitter.com/zsviczian",shortcut:null,"aria-label":"Follow me on Twitter"}," Follow me on Twitter"),t.createElement(a.Center.MenuItemLink,{icon:ICONS.heart,href:"https://ko-fi.com/zsolt",shortcut:null,"aria-label":"Donate to support Excalidraw-Obsidian"},' Say "Thank You" & support the plugin.')))),t.createElement(l,{onTextSubmit:async e=>{var t,n,i,r,o,a;try{const s=await postOpenAI({systemPrompt:"The user will provide you with a text prompt. Your task is to generate a mermaid diagram based on the prompt. Use the graph, sequenceDiagram, flowchart or classDiagram types based on what best fits the request. Return a single message containing only the mermaid diagram in a codeblock. Avoid the use of `()` parenthesis in the mermaid script.",text:e,instruction:"Return a single message containing only the mermaid diagram in a codeblock."});if(!s)return{error:new Error("Request failed")};const l=s.json;if(null==l?void 0:l.error)return log(s),{error:new Error(l.error.message)};if(!(null===(i=null===(n=null===(t=null==l?void 0:l.choices)||void 0===t?void 0:t[0])||void 0===n?void 0:n.message)||void 0===i?void 0:i.content))return log(s),{error:new Error("Generation failed... see console log for details")};let c=null===(a=extractCodeBlocks(null===(o=null===(r=l.choices[0])||void 0===r?void 0:r.message)||void 0===o?void 0:o.content)[0])||void 0===a?void 0:a.data;return c?(c.startsWith("mermaid")&&(c=c.replace(/^mermaid/,"").trim()),{generatedResponse:c,rateLimit:100,rateLimitRemaining:100}):(log(s),{error:new Error("Generation failed... see console log for details")})}catch(e){throw new Error("Request failed")}}}),t.createElement(s,{})),u());return t.createElement(t.Fragment,null,g)}));n.createRoot(this.contentEl).render(p)}updateContainerSize(e,t=!1){const n=this.excalidrawAPI;if(!n)return;const i=()=>{const t=e?n.getSceneElements().filter((t=>t.id===e&&"arrow"!==t.type)):n.getSceneElements().filter(isContainer);t.length>0&&(this.initialContainerSizeUpdate&&(this.semaphores.justLoaded=!0),n.updateContainerSize(t)),this.initialContainerSizeUpdate=!1};t?setTimeout((()=>i()),50):i()}zoomToFit(e=!0,t=!1){if(document.body.querySelector("div.modal-container"))return;const n=this.excalidrawAPI;if(!n||this.semaphores.isEditingText||this.semaphores.preventAutozoom)return;const i=this.plugin.settings.zoomToFitMaxLevel,r=n.getSceneElements().filter((e=>e.width<1e4&&e.height<1e4));DEVICE.isMobile&&r.length>1e3||r.length>2500?t&&n.scrollToContent():e?setTimeout((()=>n.zoomToFit(
|
||
|
//!Temporary hack
|
||
|
if(e.activeExcalidrawView=r,r?(e.addModalContainerObserver(),e.lastActiveExcalidrawFilePath=null===(n=r.file)||void 0===n?void 0:n.path):e.removeModalContainerObserver(),DEVICE.isMobile&&r&&!i){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="relative")}if(DEVICE.isMobile&&!r&&i){const e=document.querySelector("body>.app-container>.mobile-navbar");e&&e instanceof HTMLDivElement&&(e.style.position="")}if(i&&i!==r&&(i.leaf!==t&&i.semaphores.dirty&&!i.semaphores.viewunload&&await i.save(!0),i.file&&e.triggerEmbedUpdates(i.file.path)),r&&(!i||i.leaf!==t)){const e=r.file;r.file&&setTimeout((()=>{var t;r&&r._loaded&&(null===(t=r.file)||void 0===t?void 0:t.path)===(null==e?void 0:e.path)&&(r.activeLoader||r.loadSceneFiles())}),2e3)}if(r&&r._loaded&&r.isLoaded&&r.excalidrawAPI&&e.ea.onCanvasColorChangeHook&&e.ea.onCanvasColorChangeHook(e.ea,r,r.excalidrawAPI.getAppState().viewBackgroundColor),e.popScope&&(e.popScope(),e.popScope=null),r){const t=e.app.keymap.getRootScope(),n=t.register(["Mod"],"Enter",(()=>!0));t.keys.unshift(t.keys.pop());const i=t.register(["Mod"],"k",(()=>!0));t.keys.unshift(t.keys.pop());const r=t.register(["Mod"],"f",(()=>{const t=e.app.workspace.getActiveViewOfType(ExcalidrawView);return!!t&&(search(t),!0)}));t.keys.unshift(t.keys.pop());const o=e.forceSaveCommand&&"s"===e.forceSaveCommand.hotkeys[0].key&&e.forceSaveCommand.hotkeys[0].modifiers.includes("Ctrl")?t.register(["Ctrl"],"s",(()=>e.forceSaveActiveView(!1))):void 0;o&&t.keys.unshift(t.keys.pop()),e.popScope=()=>{t.unregister(n),t.unregister(i),t.unregister(r),Boolean(o)&&t.unregister(o)}}};e.activeLeafChangeEventHandler=t,e.registerEvent(e.app.workspace.on("active-leaf-change",t)),e.addFileSaveTriggerEventHandlers();const n=e.app.metadataCache;n.getCachedFiles().forEach((t=>{var i;const r=null===(i=n.getCache(t))||void 0===i?void 0:i.frontmatter;(r&&void 0!==r[FRONTMATTER_KEYS.plugin.name]||t.match(/\.excalidraw$/))&&e.updateFileCache(e.app.vault.getAbstractFileByPath(t),r)})),e.registerEvent(n.on("changed",((t,n,i)=>e.updateFileCache(t,null==i?void 0:i.frontmatter))))}))}addFileSaveTriggerEventHandlers(){const e=e=>{this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&(!e.target||"excalidraw__canvas"!==e.target.className&&!getParentOfClass(e.target,"excalidraw-wrapper"))&&this.activeExcalidrawView.save()};this.app.workspace.containerEl.addEventListener("click",e),this.removeEventLisnters.push((()=>{this.app.workspace.containerEl.removeEventListener("click",e)})),this.registerEvent(this.app.workspace.on("file-menu",(()=>{this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&this.activeExcalidrawView.save()}))),this.addModalContainerObserver();const t=document.querySelector(".workspace-drawer.mod-left"),n=document.querySelector(".workspace-drawer.mod-right");if(t||n){const e=async e=>{"display: none;"===e[0].oldValue&&this.activeExcalidrawView&&this.activeExcalidrawView.semaphores.dirty&&this.activeExcalidrawView.save()},i={attributeOldValue:!0,attributeFilter:["style"]};t&&(this.workspaceDrawerLeftObserver=DEBUGGING?new CustomMutationObserver(e,"slidingDrawerLeftObserver"):new MutationObserver(e),this.workspaceDrawerLeftObserver.observe(t,i)),n&&(this.workspaceDrawerRightObserver=DEBUGGING?new CustomMutationObserver(e,"slidingDrawerRightObserver"):new MutationObserver(e),this.workspaceDrawerRightObserver.observe(n,i))}}addModalContainerObserver(){if(!this.activeExcalidrawView)return;if(this.modalContainerObserver){if(this.activeViewDoc===this.activeExcalidrawView.ownerDocument)return;this.removeModalContainerObserver()}const e=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=DEBUGGING?new CustomMutationObserver(e,"modalContainerObserver"):new MutationObserver(e),this.activeViewDoc=this.activeExcalidrawView.ownerDocument,this.modalContainerObserver.observe(this.activeViewDoc.body,{chil
|