84 lines
2.9 MiB
JavaScript
84 lines
2.9 MiB
JavaScript
|
"use strict";var obsidian_module=require("obsidian");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.index++)),s|=(u>0?1:0)*p,p<<=1;switch(c=s){case 0:for(s=0,a=Math.pow(
|
||
|
/*!
|
||
|
* html2canvas 1.4.1 <https://html2canvas.hertzen.com>
|
||
|
* Copyright (c) 2022 Niklas von Hertzen <https://hertzen.com>
|
||
|
* Released under MIT License
|
||
|
*/html2canvas$1.exports,function(e,t){e.exports=function(){
|
||
|
/*! *****************************************************************************
|
||
|
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(t,A){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var A in t)Object.prototype.hasOwnProperty.call(t,A)&&(e[A]=t[A])},e(t,A)};function t(t,A){if("function"!=typeof A&&null!==A)throw new TypeError("Class extends value "+String(A)+" is not a constructor or null");function i(){this.constructor=t}e(t,A),t.prototype=null===A?Object.create(A):(i.prototype=A.prototype,new i)}var A=function(){return A=Object.assign||function(e){for(var t,A=1,i=arguments.length;A<i;A++)for(var n in t=arguments[A])Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n]);return e},A.apply(this,arguments)};function i(e,t,A,i){return new(A||(A=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 t;e.done?n(e.value):(t=e.value,t instanceof A?t:new A((function(e){e(t)}))).then(r,s)}o((i=i.apply(e,t||[])).next())}))}function n(e,t){var A,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(A)throw new TypeError("Generator is already executing.");for(;r;)try{if(A=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=t.call(e,r)}catch(e){a=[6,e],i=0}finally{A=n=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}}function a(e,t,A){if(A||2===arguments.length)for(var i,n=0,a=t.length;n<a;n++)!i&&n in t||(i||(i=Array.prototype.slice.call(t,0,n)),i[n]=t[n]);return e.concat(i||t)}for(var r=function(){function e(e,t,A,i){this.left=e,this.top=t,this.width=A,this.height=i}return e.prototype.add=function(t,A,i,n){return new e(this.left+t,this.top+A,this.width+i,this.height+n)},e.fromClientRect=function(t,A){return new e(A.left+t.windowBounds.left,A.top+t.windowBounds.top,A.width,A.height)},e.fromDOMRectList=function(t,A){var i=Array.from(A).find((function(e){return 0!==e.width}));return i?new e(i.left+t.windowBounds.left,i.top+t.windowBounds.top,i.width,i.height):e.EMPTY},e.EMPTY=new e(0,0,0,0),e}(),s=function(e,t){return r.fromClientRect(e,t.getBoundingClientRect())},o=function(e){for(var t=[],A=0,i=e.length;A<i;){var n=e.charCodeAt(A++);if(n>=55296&&n<=56319&&A<i){var a=e.charCodeAt(A++);56320==(64512&a)?t.push(((1023&n)<<10)+(1023&a)+65536):(t.push(n),A--)}else t.push(n)}return t},l=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(String.fromCodePoint)return String.fromCodePoint.apply(String,e);var A=e.length;if(!A)return"";for(var i=[],n=-1,a="";++n<A;){var r=e[n];r<=65535?i.push(r):(r-=65536,i.push(55296+(r>>10),r%1024+56320)),(n+1===A||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<64;h++)d[c.charCodeAt(h)]=h;for(var u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",g="undefined"==typeof Uint8Array?[]:new Uint8Array(256),p=0;p<64;p++)g[u.charCodeAt(p)]=p;for(var m=function(e,t,A){return e.slice?e.slice(t,A):new Uint16Array(Array.prototype.slice.call(e,t,A))},f=function(){function e(e,t,A,i,n,a){this.initialValue=e,this.errorValue=t,this.highStart=A,this.highValueIndex=i,this.index=n,this.data=a}return e.prototype.get=function(e){var t;if(e>=0){if(e<55296||e>56319&&e<=65535)return t=((t=this.index[e>>5])<<2)+(31&e),this.data[t];if(e<=65535)return t=((t
|
||
|
//![[link|alias]] [alias](link){num}
|
||
|
EXPR:/(!)?(\[\[([^|\]]+)\|?([^\]]+)?]]|\[([^\]]*)]\(([^)]*)\))(\{(\d+)\})?/g,getResList:e=>{const t=e.matchAll(REGEX_LINK.EXPR);let A;const i=[];for(;!(A=t.next()).done;)i.push(A);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 A=parseInt(e.value[8]);return isNaN(A)?t>0?t:null:A}},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,A=e.matchAll(DRAWING_COMPRESSED_REG);return t=A.next(),t.done&&(A=e.matchAll(DRAWING_COMPRESSED_REG_FALLBACK),t=A.next()),t.value&&t.value.length>1?[decompress(t.value[2]),t]:[null,t]},changeThemeOfExcalidrawMD=e=>{const t=isCompressedMD(e);let A=t?getDecompressedScene(e)[0]:e;return A?(isObsidianThemeDark?1===(A.match(/"theme"\s*:\s*"light"\s*,/g)||[]).length&&(A=A.replace(/"theme"\s*:\s*"light"\s*,/,'"theme": "dark",')):1===(A.match(/"theme"\s*:\s*"dark"\s*,/g)||[]).length&&(A=A.replace(/"theme"\s*:\s*"dark"\s*,/,'"theme": "light",')),t?e.replace(DRAWING_COMPRESSED_REG,`$1${compress(A)}$3`):A):e};function getJSON(e){let t,A;if(isCompressedMD(e)){const[t,A]=getDecompressedScene(e);return t?{scene:t.substring(0,t.lastIndexOf("}")+1),pos:A.value.index}:{scene:e,pos:A.value?A.value.index:0}}if(t=e.matchAll(DRAWING_REG),A=t.next(),A.done&&(t=e.matchAll(DRAWING_REG_FALLBACK),A=t.next()),A.value&&A.value.length>1){const e=A.value[2];return{scene:e.substr(0,e.lastIndexOf("}")+1),pos:A.value.index}}return{scene:e,pos:A.value?A.value.index:0}}function getMarkdownDrawingSection(e,t){return t?`%%\n# Drawing\n\`\`\`compressed-json\n${compress(e)}\n\`\`\`\n%%`:`%%\n# Drawing\n\`\`\`json\n${e}\n\`\`\`\n%%`}const estimateMaxLineLen=(e,t)=>{if(!t||!e)return null;if(e===t)return null;let A=0;const i=e.split("\n");if(1===i.length)return null;for(const e of i){const t=e.trim();t.length>A&&(A=t.length)}return A},wrap=(e,t)=>t?wrapTextAtCharLength(e,t,!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.embeddableTheme="auto",this.autoexportPreference=AutoexportPreference.inherit,this.textMode=TextMode.raw,this.loaded=!1,this.files=null,this.equations=null,this.mermaids=null,this.compatibilityMode=!1,this.selectedElementIds={},this.disableCompression=!1,this.app=e.app,this.files=new Map,this.equations=new Map,this.mermaids=new Map}initializeNonInitializedFields(){var e,t,A;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("iframe"===e.type&&(e.type="embeddable"),e.boundElements){const t=new Map;e.boundElements.forEach((e=>{t.set(e.id,e.type)}));const A=Array.from(t,(([e,t])=>({id:e,type:t})));A.length!==e.boundElements.length&&(e.boundElements=A)}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===(t=e.startBinding)||void 0===t?void 0:t.focus)&&(e.startBinding.focus=0),null===(null===(A=e.endBinding)||void 0===A?void 0:A.focus)&&(e.endBinding.focus=0),null===e.fontSize&&(e.fontSize=20)}try{n.filter((e=>"text"===e.type&&e.containerId&&n.some((t=>t.id===e.containerId&&t.boundElements.length>0&&t.boundElements.some((t=>"text"===t.type&&t.id!==e.id&&t.id.length>8)))))).forEach((e=>{try{const
|
||
|
/**
|
||
|
* 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,A){return void 0===t&&(t=0),void 0===A&&(A=1),e<t?t:e>A?A:e},t=e,A={},i=0,n=["Boolean","Number","String","Function","Array","Date","RegExp","Undefined","Null"];i<n.length;i+=1){var a=n[i];A["[object "+a+"]"]=a.toLowerCase()}var r=function(e){return A[Object.prototype.toString.call(e)]||"object"},s=r,o=r,l=Math.PI,c={clip_rgb:function(e){e._clipped=!1,e._unclipped=e.slice(0);for(var A=0;A<=3;A++)A<3?((e[A]<0||e[A]>255)&&(e._clipped=!0),e[A]=t(e[A],0,255)):3===A&&(e[A]=t(e[A],0,1));return e},limit:e,type:r,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"==o(e[t])?e[t].toLowerCase():null},PI:l,TWOPI:2*l,PITHIRD:l/3,DEG2RAD:l/180,RAD2DEG:180/l},d={format:{},autodetect:[]},h=c.last,u=c.clip_rgb,g=c.type,p=d,m=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=this;if("object"===g(e[0])&&e[0].constructor&&e[0].constructor===this.constructor)return e[0];var i=h(e),n=!1;if(!i){n=!0,p.sorted||(p.autodetect=p.autodetect.sort((function(e,t){return t.p-e.p})),p.sorted=!0);for(var a=0,r=p.autodetect;a<r.length;a+=1){var s=r[a];if(i=s.test.apply(s,e))break}}if(!p.format[i])throw new Error("unknown format: "+e);var o=p.format[i].apply(null,n?e:e.slice(0,-1));A._rgb=u(o),3===A._rgb.length&&A._rgb.push(1)};m.prototype.toString=function(){return"function"==g(this.hex)?this.hex():"["+this._rgb.join(",")+"]"};var f=m,w=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(w.Color,[null].concat(e)))};w.Color=f,w.version="2.4.2";var E=w,b=c.unpack,B=Math.max,v=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=b(e,"rgb"),i=A[0],n=A[1],a=A[2],r=1-B(i/=255,B(n/=255,a/=255)),s=r<1?1/(1-r):0;return[(1-i-r)*s,(1-n-r)*s,(1-a-r)*s,r]},C=c.unpack,y=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=(e=C(e,"cmyk"))[0],i=e[1],n=e[2],a=e[3],r=e.length>4?e[4]:1;return 1===a?[0,0,0,r]:[A>=1?0:255*(1-A)*(1-a),i>=1?0:255*(1-i)*(1-a),n>=1?0:255*(1-n)*(1-a),r]},x=E,F=f,S=d,T=c.unpack,I=c.type,M=v;F.prototype.cmyk=function(){return M(this._rgb)},x.cmyk=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];return new(Function.prototype.bind.apply(F,[null].concat(e,["cmyk"])))},S.format.cmyk=y,S.autodetect.push({p:2,test:function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];if(e=T(e,"cmyk"),"array"===I(e)&&4===e.length)return"cmyk"}});var k=c.unpack,U=c.last,O=function(e){return Math.round(100*e)/100},L=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=k(e,"hsla"),i=U(e)||"lsa";return A[0]=O(A[0]||0),A[1]=O(100*A[1])+"%",A[2]=O(100*A[2])+"%","hsla"===i||A.length>3&&A[3]<1?(A[3]=A.length>3?A[3]:1,i="hsla"):A.length=3,i+"("+A.join(",")+")"},Q=c.unpack,N=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=(e=Q(e,"rgba"))[0],i=e[1],n=e[2];A/=255,i/=255,n/=255;var a,r,s=Math.min(A,i,n),o=Math.max(A,i,n),l=(o+s)/2;return o===s?(a=0,r=Number.NaN):a=l<.5?(o-s)/(o+s):(o-s)/(2-o-s),A==o?r=(i-n)/(o-s):i==o?r=2+(n-A)/(o-s):n==o&&(r=4+(A-i)/(o-s)),(r*=60)<0&&(r+=360),e.length>3&&void 0!==e[3]?[r,a,l,e[3]]:[r,a,l]},D=c.unpack,R=c.last,H=L,P=N,V=Math.round,K=function(){for(var e=[],t=arguments.length;t--;)e[t]=arguments[t];var A=D(e,"rgba"),i=R(e)||"rgb";return"hsl"==i.substr(0,3)?H(P(A),i):(A[0]=V(A[0]),A[1]=V(A[1]),A[2]=V(A[2]),("rgba"===i||A.length>3&&A[3]<1)&&(A[3]=A.length>3?A[3]:1,i="rgba"),i+"("+A.slice(0,"rgb"===i?3:4).join(",")+")")},G=c.unpack,W=Math.round,z=function(){for(var e,t=[],A=arguments.length;A--;)t[A]=arguments[A];var i,n,a,r=(t=G(t,"hsl"))[0],s=t[1],o=t[2];if(0===s)i=n=a=255*o;else{var l=[0,0,0],c=[0,0,0],d=o<.5?o*(1+s):o+s-o*s,h=2*o-d,u=r/360;l[0]=u+1/3,l[1]=u,l[2]=u-1/3;for(var g=0;g<3;g++)l[g]<0&&(l[g]+=1),l[g]>1&&(l[g]-=1),6*l[g]<1?c[g]=h+6*(d-h)*l[g]:2*l[g]<1?c
|
||
|
//! onauxclick: (e: any) => {e.preventDefault()},
|
||
|
renderTopRightUI:(e,t)=>this.obsidianMenu.renderButton(e,t),renderEmbeddableMenu:e=>this.embeddableMenu.renderButtons(e),onPaste:(e,t)=>{const A=this.getHookServer();if(e&&A.onPasteHook){const i=A.onPasteHook({ea:A,payload:e,event:t,excalidrawFile:this.file,view:this,pointerPosition:this.currentPosition});if("boolean"==typeof i&&!1===i)return!1}if(!this.modifierKeyDown.ctrlKey&&null!=t&&DEVICE.isLinux)return console.debug("Prevented what is likely middle mouse button paste."),!1;if(e&&e.text&&hyperlinkIsImage(e.text))return this.addImageWithURL(e.text),!1;if(e&&e.text&&!this.modifierKeyDown.shiftKey){const t=obsidianPDFQuoteWithRef(e.text);if(t){const e=getEA(this),A=this.excalidrawAPI.getAppState(),i=A.currentItemStrokeColor,n=A.viewBackgroundColor;e.style.strokeColor="transparent"===i?e.getCM("transparent"===n?"white":n).invert().stringHEX({alpha:!1}):i,e.style.fontFamily=A.currentItemFontFamily,e.style.fontSize=A.currentItemFontSize;const a=e.measureText(t.quote),r=a.width+60,s=e.addText(this.currentPosition.x,this.currentPosition.y,t.quote,{box:!0,boxStrokeColor:"transparent",width:Math.min(500,r),height:a.height+60});return e.elementsDict[s].link=`[[${t.link}]]`,e.addElementsToView(!1,!1),!1}}if(e.elements){const e=this;setTimeout((()=>e.save(!1)),300)}return!0},onThemeChange:async e=>{var t;this.excalidrawData.scene.appState.theme=e,this.loadSceneFiles(),null===(t=null==n?void 0:n.current)||void 0===t||t.setTheme(e),setTimeout((()=>setDynamicStyle(this.plugin.ea,this,this.previousBackgroundColor,this.plugin.settings.dynamicStyling)))},ownerDocument:this.ownerDocument,ownerWindow:this.ownerWindow,onDrop:e=>{this.draginfoDiv&&(this.ownerDocument.body.removeChild(this.draginfoDiv),delete this.draginfoDiv);const t=this.excalidrawAPI;if(!t)return!1;const A=t.getAppState();this.currentPosition=viewportCoordsToSceneCoords({clientX:e.clientX,clientY:e.clientY},A);const i=app.dragManager.draggable,n=internalDragModifierType(e),a=externalDragModifierType(e),r=(t,A,n)=>{if(!this.getHookServer().onDropHook)return!1;try{return this.getHookServer().onDropHook({ea:this.getHookServer(),event:e,draggable:i,type:t,payload:{files:A,text:n},excalidrawFile:this.file,view:this,pointerPosition:this.currentPosition})}catch(e){return new obsidian_module.Notice("on drop hook error. See console log for details"),errorlog({where:"ExcalidrawView.onDrop",error:e}),!1}};switch(null==i?void 0:i.type){case"file":if(!r("file",[i.file],null)){const e=i.file;if(e.path.match(REG_LINKINDEX_INVALIDCHARS))return new obsidian_module.Notice(t$d("FILENAME_INVALID_CHARS"),4e3),!1;if(["image","image-fullsize"].contains(n)&&(IMAGE_TYPES.contains(e.extension)||"md"===e.extension||"pdf"===e.extension.toLowerCase()))return"pdf"===e.extension.toLowerCase()?new InsertPDFModal(this.plugin,this).open(e):(async()=>{const t=getEA(this);t.selectElementsInView([await insertImageToView(t,this.currentPosition,e,!("image-fullsize"===n))])})(),!1;if("embeddable"===n)return(async()=>{const t=getEA(this);t.selectElementsInView([await insertEmbeddableToView(t,this.currentPosition,e)])})(),!1;this.addText(`[[${app.metadataCache.fileToLinktext(i.file,this.file.path,!0)}]]`)}return!1;case"files":return r("file",i.files,null)||(async()=>{if(["image","image-fullsize"].contains(n)){const e=getEA(this);e.canvas.theme=t.getAppState().theme;let A=0;const a=[];for(const t of i.files)(IMAGE_TYPES.contains(t.extension)||"md"===t.extension)&&(a.push(await e.addImage(this.currentPosition.x+50*A,this.currentPosition.y+50*A,t,!("image-fullsize"===n))),A++,await e.addElementsToView(!1,!1,!0),e.selectElementsInView(a)),"pdf"===t.extension.toLowerCase()&&new InsertPDFModal(this.plugin,this).open(t)}else{if("embeddable"===n){const e=getEA(this);let t=0,A=0;const n=[];for(const a of i.files)n.push(await insertEmbeddableToView(e,{x:this.currentPosition.x+500*t,y:this.currentPosition.y+550*A},a)),t=(t+1)%3,0===t&&A++;return!1}for(const e of i.files)await this.addText(`[[${app.metadataCache.fileToLinktext(e,this.file.path,!0)}]]`,void 0,!1),this.currentPosition.y+=2*A.currentItemFontSize;this.save(!1
|
||
|
//!Temporary hack
|
||
|
if(e.activeExcalidrawView=n,n&&(e.lastActiveExcalidrawFilePath=null===(A=n.file)||void 0===A?void 0:A.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!==t&&i.semaphores.dirty&&!i.semaphores.viewunload&&await i.save(!0),i.file&&e.triggerEmbedUpdates(i.file.path)),n&&(!i||i.leaf!==t)){const e=n.file;n.file&&setTimeout((()=>{var t;n&&n._loaded&&(null===(t=n.file)||void 0===t?void 0:t.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 t=e.app.keymap.getRootScope(),A=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 n=t.register(["Mod"],"f",(()=>{const e=this.app.workspace.getActiveViewOfType(ExcalidrawView);return!!e&&(search(e),!0)}));t.keys.unshift(t.keys.pop());const a=e.forceSaveCommand&&"s"===e.forceSaveCommand.hotkeys[0].key&&e.forceSaveCommand.hotkeys[0].modifiers.includes("Ctrl")?t.register(["Ctrl"],"s",(()=>e.forceSaveActiveView(!1))):void 0;a&&t.keys.unshift(t.keys.pop()),e.popScope=()=>{t.unregister(A),t.unregister(i),t.unregister(n),Boolean(a)&&t.unregister(a)}}}))),e.addFileSaveTriggerEventHandlers();const t=app.metadataCache;t.getCachedFiles().forEach((A=>{var i;const n=null===(i=t.getCache(A))||void 0===i?void 0:i.frontmatter;(n&&void 0!==n[FRONTMATTER_KEY]||A.match(/\.excalidraw$/))&&e.updateFileCache(app.vault.getAbstractFileByPath(A),n)})),this.registerEvent(t.on("changed",((e,t,A)=>this.updateFileCache(e,null==A?void 0:A.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.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 t=document.querySelector(".workspace-drawer.mod-left"),A=document.querySelector(".workspace-drawer.mod-right");if(t||A){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=new MutationObserver(e),this.workspaceDrawerLeftObserver.observe(t,i)),A&&(this.workspaceDrawerRightObserver=new MutationObserver(e),this.workspaceDrawerRightObserver.observe(A,i))}}updateFileCache(e,t,A=!1){t&&void 0!==t[FRONTMATTER_KEY]?this.excalidrawFiles.add(e):A||"excalidraw"!==e.extension?this.excalidrawFiles.delete(e):this.excalidrawFiles.add(e)}onunload(){this.stylesManager.unload(),this.removeEventLisnters.forEach((e=>e())),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.ap
|