-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdrawio.plug.js
18 lines (18 loc) · 23.8 KB
/
drawio.plug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
var Pe=Object.create;var G=Object.defineProperty;var Te=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var Ve=Object.getPrototypeOf,Ue=Object.prototype.hasOwnProperty;var Fe=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),b=(e,t)=>{for(var o in t)G(e,o,{get:t[o],enumerable:!0})},We=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Ze(t))!Ue.call(e,a)&&a!==o&&G(e,a,{get:()=>t[a],enumerable:!(i=Te(t,a))||i.enumerable});return e};var Re=(e,t,o)=>(o=e!=null?Pe(Ve(e)):{},We(t||!e||!e.__esModule?G(o,"default",{value:e,enumerable:!0}):o,e));var ue=Fe((J,X)=>{(function(e,t){var o,i;typeof J=="object"&&typeof X<"u"?X.exports=t():typeof define=="function"&&define.amd?define(t):(o=e.Base64,(i=t()).noConflict=function(){return e.Base64=o,i},e.Meteor&&(Base64=i),e.Base64=i)})(typeof self<"u"?self:typeof window<"u"?window:typeof global<"u"?global:J,function(){"use strict";var e,t="3.7.3",o=typeof atob=="function",i=typeof btoa=="function",a=typeof Buffer=="function",c=typeof TextDecoder=="function"?new TextDecoder:void 0,d=typeof TextEncoder=="function"?new TextEncoder:void 0,m=Array.prototype.slice.call("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="),y=(e={},m.forEach(function(r,s){return e[r]=s}),e),W=/^(?:[A-Za-z\d+\/]{4})*?(?:[A-Za-z\d+\/]{2}(?:==)?|[A-Za-z\d+\/]{3}=?)?$/,l=String.fromCharCode.bind(String),K=typeof Uint8Array.from=="function"?Uint8Array.from.bind(Uint8Array):function(r,s){return s===void 0&&(s=function(u){return u}),new Uint8Array(Array.prototype.slice.call(r,0).map(s))},z=function(r){return r.replace(/=/g,"").replace(/[+\/]/g,function(s){return s=="+"?"-":"_"})},j=function(r){return r.replace(/[^A-Za-z0-9\+\/]/g,"")},H=function(r){for(var s,u,h,C,p="",S=r.length%3,Z=0;Z<r.length;){if((u=r.charCodeAt(Z++))>255||(h=r.charCodeAt(Z++))>255||(C=r.charCodeAt(Z++))>255)throw new TypeError("invalid character found");p+=m[(s=u<<16|h<<8|C)>>18&63]+m[s>>12&63]+m[s>>6&63]+m[63&s]}return S?p.slice(0,S-3)+"===".substring(S):p},R=i?function(r){return btoa(r)}:a?function(r){return Buffer.from(r,"binary").toString("base64")}:H,N=a?function(r){return Buffer.from(r).toString("base64")}:function(r){for(var s=[],u=0,h=r.length;u<h;u+=4096)s.push(l.apply(null,r.subarray(u,u+4096)));return R(s.join(""))},P=function(r,s){return s===void 0&&(s=!1),s?z(N(r)):N(r)},xe=function(r){if(r.length<2)return(s=r.charCodeAt(0))<128?r:s<2048?l(192|s>>>6)+l(128|63&s):l(224|s>>>12&15)+l(128|s>>>6&63)+l(128|63&s);var s=65536+1024*(r.charCodeAt(0)-55296)+(r.charCodeAt(1)-56320);return l(240|s>>>18&7)+l(128|s>>>12&63)+l(128|s>>>6&63)+l(128|63&s)},be=/[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g,D=function(r){return r.replace(be,xe)},O=a?function(r){return Buffer.from(r,"utf8").toString("base64")}:d?function(r){return N(d.encode(r))}:function(r){return R(D(r))},x=function(r,s){return s===void 0&&(s=!1),s?z(O(r)):O(r)},L=function(r){return x(r,!0)},Ce=/[\xC0-\xDF][\x80-\xBF]|[\xE0-\xEF][\x80-\xBF]{2}|[\xF0-\xF7][\x80-\xBF]{3}/g,Ie=function(r){switch(r.length){case 4:var s=((7&r.charCodeAt(0))<<18|(63&r.charCodeAt(1))<<12|(63&r.charCodeAt(2))<<6|63&r.charCodeAt(3))-65536;return l(55296+(s>>>10))+l(56320+(1023&s));case 3:return l((15&r.charCodeAt(0))<<12|(63&r.charCodeAt(1))<<6|63&r.charCodeAt(2));default:return l((31&r.charCodeAt(0))<<6|63&r.charCodeAt(1))}},q=function(r){return r.replace(Ce,Ie)},$=function(r){if(r=r.replace(/\s+/g,""),!W.test(r))throw new TypeError("malformed base64.");r+="==".slice(2-(3&r.length));for(var s,u,h,C="",p=0;p<r.length;)s=y[r.charAt(p++)]<<18|y[r.charAt(p++)]<<12|(u=y[r.charAt(p++)])<<6|(h=y[r.charAt(p++)]),C+=u===64?l(s>>16&255):h===64?l(s>>16&255,s>>8&255):l(s>>16&255,s>>8&255,255&s);return C},w=o?function(r){return atob(j(r))}:a?function(r){return Buffer.from(r,"base64").toString("binary")}:$,_=a?function(r){return K(Buffer.from(r,"base64"))}:function(r){return K(w(r),function(s){return s.charCodeAt(0)})},ee=function(r){return _(te(r))},Ae=a?function(r){return Buffer.from(r,"base64").toString("utf8")}:c?function(r){return c.decode(_(r))}:function(r){return q(w(r))},te=function(r){return j(r.replace(/[-_]/g,function(s){return s=="-"?"+":"/"}))},v=function(r){return Ae(te(r))},re=function(r){return{value:r,enumerable:!1,writable:!0,configurable:!0}},ne=function(){var r=function(s,u){return Object.defineProperty(String.prototype,s,re(u))};r("fromBase64",function(){return v(this)}),r("toBase64",function(s){return x(this,s)}),r("toBase64URI",function(){return x(this,!0)}),r("toBase64URL",function(){return x(this,!0)}),r("toUint8Array",function(){return ee(this)})},oe=function(){var r=function(s,u){return Object.defineProperty(Uint8Array.prototype,s,re(u))};r("toBase64",function(s){return P(this,s)}),r("toBase64URI",function(){return P(this,!0)}),r("toBase64URL",function(){return P(this,!0)})},T={version:t,VERSION:"3.7.3",atob:w,atobPolyfill:$,btoa:R,btoaPolyfill:H,fromBase64:v,toBase64:x,encode:x,encodeURI:L,encodeURL:L,utob:D,btou:q,decode:v,isValid:function(r){if(typeof r!="string")return!1;var s=r.replace(/\s+/g,"").replace(/={0,2}$/,"");return!/[^\s0-9a-zA-Z\+/]/.test(s)||!/[^\s0-9a-zA-Z\-_]/.test(s)},fromUint8Array:P,toUint8Array:ee,extendString:ne,extendUint8Array:oe,extendBuiltins:function(){ne(),oe()},Base64:{}};return Object.keys(T).forEach(function(r){return T.Base64[r]=T[r]}),T})});var I=e=>{throw new Error("Not initialized yet")},B=typeof window>"u"&&typeof globalThis.WebSocketPair>"u";typeof Deno>"u"&&(self.Deno={args:[],build:{arch:"x86_64"},env:{get(){}}});var k=new Map,Y=0;B&&(globalThis.syscall=async(e,...t)=>await new Promise((o,i)=>{Y++,k.set(Y,{resolve:o,reject:i}),I({type:"sys",id:Y,name:e,args:t})}));function ie(e,t,o){B&&(I=o,self.addEventListener("message",i=>{(async()=>{let a=i.data;switch(a.type){case"inv":{let c=e[a.name];if(!c)throw new Error(`Function not loaded: ${a.name}`);try{let d=await Promise.resolve(c(...a.args||[]));I({type:"invr",id:a.id,result:d})}catch(d){console.error("An exception was thrown as a result of invoking function",a.name,"error:",d.message),I({type:"invr",id:a.id,error:d.message})}}break;case"sysr":{let c=a.id,d=k.get(c);if(!d)throw Error("Invalid request id");k.delete(c),a.error?d.reject(new Error(a.error)):d.resolve(a.result)}break}})().catch(console.error)}),I({type:"manifest",manifest:t}))}function Ne(e){let t=atob(e),o=t.length,i=new Uint8Array(o);for(let a=0;a<o;a++)i[a]=t.charCodeAt(a);return i}function se(e){typeof e=="string"&&(e=new TextEncoder().encode(e));let t="",o=e.byteLength;for(let i=0;i<o;i++)t+=String.fromCharCode(e[i]);return btoa(t)}async function we(e,t){if(typeof e!="string"){let o=new Uint8Array(await e.arrayBuffer()),i=o.length>0?se(o):void 0;t={method:e.method,headers:Object.fromEntries(e.headers.entries()),base64Body:i},e=e.url}return syscall("sandboxFetch.fetch",e,t)}globalThis.nativeFetch=globalThis.fetch;function ve(){globalThis.fetch=async function(e,t){let o=t&&t.body?se(new Uint8Array(await new Response(t.body).arrayBuffer())):void 0,i=await we(e,t&&{method:t.method,headers:t.headers,base64Body:o});return new Response(i.base64Body?Ne(i.base64Body):null,{status:i.status,headers:i.headers})}}B&&ve();var g={};b(g,{confirm:()=>dt,copyToClipboard:()=>Ct,deleteLine:()=>It,dispatch:()=>at,downloadFile:()=>Le,filterBox:()=>_e,flashNotification:()=>$e,fold:()=>gt,foldAll:()=>ft,getCurrentPage:()=>Se,getCursor:()=>ke,getSelection:()=>Be,getText:()=>Ge,getUiOption:()=>lt,goHistory:()=>Oe,hidePanel:()=>tt,insertAtCursor:()=>st,insertAtPos:()=>rt,moveCursor:()=>ot,moveCursorToLine:()=>it,navigate:()=>Je,newWindow:()=>De,openCommandPalette:()=>Qe,openPageNavigator:()=>Xe,openSearchPanel:()=>bt,openUrl:()=>He,prompt:()=>ct,redo:()=>xt,reloadConfigAndCommands:()=>je,reloadPage:()=>Ke,reloadUI:()=>ze,replaceRange:()=>nt,save:()=>Ee,setSelection:()=>Me,setText:()=>Ye,setUiOption:()=>ut,showPanel:()=>et,toggleFold:()=>pt,undo:()=>ht,unfold:()=>mt,unfoldAll:()=>yt,uploadFile:()=>qe,vimEx:()=>At});typeof self>"u"&&(self={syscall:()=>{throw new Error("Not implemented here")}});function n(e,...t){return globalThis.syscall(e,...t)}function Se(){return n("editor.getCurrentPage")}function Ge(){return n("editor.getText")}function Ye(e,t=!1){return n("editor.setText",e,t)}function ke(){return n("editor.getCursor")}function Be(){return n("editor.getSelection")}function Me(e,t){return n("editor.setSelection",e,t)}function Ee(){return n("editor.save")}function Je(e,t=!1,o=!1){return n("editor.navigate",e,t,o)}function Xe(e="page"){return n("editor.openPageNavigator",e)}function Qe(){return n("editor.openCommandPalette")}function Ke(){return n("editor.reloadPage")}function ze(){return n("editor.reloadUI")}function je(){return n("editor.reloadConfigAndCommands")}function He(e,t=!1){return n("editor.openUrl",e,t)}function De(){return n("editor.newWindow")}function Oe(e){return n("editor.goHistory",e)}function Le(e,t){return n("editor.downloadFile",e,t)}function qe(e,t){return n("editor.uploadFile",e,t)}function $e(e,t="info"){return n("editor.flashNotification",e,t)}function _e(e,t,o="",i=""){return n("editor.filterBox",e,t,o,i)}function et(e,t,o,i=""){return n("editor.showPanel",e,t,o,i)}function tt(e){return n("editor.hidePanel",e)}function rt(e,t){return n("editor.insertAtPos",e,t)}function nt(e,t,o){return n("editor.replaceRange",e,t,o)}function ot(e,t=!1){return n("editor.moveCursor",e,t)}function it(e,t=1,o=!1){return n("editor.moveCursorToLine",e,t,o)}function st(e){return n("editor.insertAtCursor",e)}function at(e){return n("editor.dispatch",e)}function ct(e,t=""){return n("editor.prompt",e,t)}function dt(e){return n("editor.confirm",e)}function lt(e){return n("editor.getUiOption",e)}function ut(e,t){return n("editor.setUiOption",e,t)}function gt(){return n("editor.fold")}function mt(){return n("editor.unfold")}function pt(){return n("editor.toggleFold")}function ft(){return n("editor.foldAll")}function yt(){return n("editor.unfoldAll")}function ht(){return n("editor.undo")}function xt(){return n("editor.redo")}function bt(){return n("editor.openSearchPanel")}function Ct(e){return n("editor.copyToClipboard",e)}function It(){return n("editor.deleteLine")}function At(e){return n("editor.vimEx",e)}var V={};b(V,{parseMarkdown:()=>Pt,renderParseTree:()=>Tt});function Pt(e){return n("markdown.parseMarkdown",e)}function Tt(e){return n("markdown.renderParseTree",e)}var f={};b(f,{deleteAttachment:()=>Gt,deleteFile:()=>Et,deletePage:()=>Wt,fileExists:()=>Jt,getAttachmentMeta:()=>wt,getFileMeta:()=>Bt,getPageMeta:()=>Vt,listAttachments:()=>Nt,listFiles:()=>Yt,listPages:()=>Zt,listPlugs:()=>Rt,readAttachment:()=>vt,readFile:()=>kt,readPage:()=>Ut,writeAttachment:()=>St,writeFile:()=>Mt,writePage:()=>Ft});function Zt(){return n("space.listPages")}function Vt(e){return n("space.getPageMeta",e)}function Ut(e){return n("space.readPage",e)}function Ft(e,t){return n("space.writePage",e,t)}function Wt(e){return n("space.deletePage",e)}function Rt(){return n("space.listPlugs")}function Nt(){return n("space.listAttachments")}function wt(e){return n("space.getAttachmentMeta",e)}function vt(e){return n("space.readAttachment",e)}function St(e,t){return n("space.writeAttachment",e,t)}function Gt(e){return n("space.deleteAttachment",e)}function Yt(){return n("space.listFiles")}function kt(e){return n("space.readFile",e)}function Bt(e){return n("space.getFileMeta",e)}function Mt(e,t){return n("space.writeFile",e,t)}function Et(e){return n("space.deleteFile",e)}function Jt(e){return n("space.fileExists",e)}var U={};b(U,{applyAttributeExtractors:()=>Ht,getEnv:()=>qt,getMode:()=>$t,getSpaceConfig:()=>Dt,getVersion:()=>_t,invokeCommand:()=>Qt,invokeFunction:()=>Xt,invokeSpaceFunction:()=>jt,listCommands:()=>Kt,listSyscalls:()=>zt,reloadConfig:()=>Lt,reloadPlugs:()=>Ot});function Xt(e,...t){return n("system.invokeFunction",e,...t)}function Qt(e,t){return n("system.invokeCommand",e,t)}function Kt(){return n("system.listCommands")}function zt(){return n("system.listSyscalls")}function jt(e,...t){return n("system.invokeSpaceFunction",e,...t)}function Ht(e,t,o){return n("system.applyAttributeExtractors",e,t,o)}async function Dt(e,t){return await n("system.getSpaceConfig",e)??t}function Ot(){return n("system.reloadPlugs")}function Lt(){return n("system.reloadConfig")}function qt(){return n("system.getEnv")}function $t(){return n("system.getMode")}function _t(){return n("system.getVersion")}var A={};b(A,{readAsset:()=>ar});function sr(e){let t=atob(e),o=t.length,i=new Uint8Array(o);for(let a=0;a<o;a++)i[a]=t.charCodeAt(a);return i}function ae(e){let t=e.split(",",2)[1];return sr(t)}async function ar(e,t,o="utf8"){let i=await n("asset.readAsset",e,t);switch(o){case"utf8":return new TextDecoder().decode(ae(i));case"dataurl":return i}}var F={};b(F,{parse:()=>lr,stringify:()=>ur});function lr(e){return n("yaml.parse",e)}function ur(e){return n("yaml.stringify",e)}function M(e,t){if(t(e))return[e];let o=[];if(e.children)for(let i of e.children)o=[...o,...M(i,t)];return o}function E(e,t){return M(e,o=>o.type===t)[0]}function ce(e,t){M(e,t)}async function yr(e,t){let o=await f.readPage(e),i=await V.parseMarkdown(o),a;return ce(i,c=>{if(c.type!=="FencedCode")return!1;let d=E(c,"CodeInfo");if(t&&!d||t&&!t.includes(d.children[0].text))return!1;let m=E(c,"CodeText");return m?(a=m.children[0].text,!0):!1}),a}async function de(e,t=["yaml"]){let o=await yr(e,t);if(o!==void 0)try{return F.parse(o)}catch(i){throw console.error("YAML Page parser error",i),new Error(`YAML Error: ${i.message}`)}}async function le(e,t){try{return await U.getSpaceConfig(e)??t}catch{try{let i=(await de("SETTINGS")||{})[e];return i===void 0?t:i}catch(o){if(o.message==="Not found")return t;throw o}}}var ge=Re(ue());function Q(e){let t=e.lastIndexOf(".");return t!==-1?e.slice(t+1):""}function hr(e){let t=/\((.*?)\)/g,o=[],i;for(;(i=t.exec(e))!==null;){let a=Q(i[1]);(a=="svg"||a=="png")&&o.push(i[1])}return o}async function xr(){let e=await le("drawio"),t="";return e&&e.editorUrl?t=e.editorUrl:t="https://embed.diagrams.net/?embed=1&spin=1&proto=json&configure=1",t}async function br(e){let t=await f.readAttachment(e),o=Q(e);return o=="svg"?t=String.fromCharCode.apply(null,t):o=="png"&&(t="data:image/png;base64,"+ge.Base64.fromUint8Array(t)),t}async function me(e){let t=await A.readAsset("drawio","assets/drawioframe.js"),o=await xr(),i=await br(e);await g.showPanel("modal",1,`
<style type="text/css">
iframe {
border: 0;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
width: 100%;
height: 100%
}
</style>
<div>
<div id="drawiodata" hidden>${i}</div>
<iframe id="draioiframe" src=${o} drawio-path='${e}'></iframe>
</div>
`,`${t}`)}async function pe(){let e=await g.getCurrentPage(),t=e.substring(0,e.lastIndexOf("/")),o=await g.getText(),i=hr(o),a="";if(i.length==0){g.flashNotification("No png or svg diagrams attached to this page!","error");return}if(i.length==1)a=t+"/"+i[0];else{let c=i.map(m=>({name:m,description:""})),d=await g.filterBox("Edit",c,"","");if(!d){await g.flashNotification("No diagram selected!","error");return}a=t+"/"+d.name}await me(a)}async function Cr(e){let t=new Uint8Array([0]),o=await A.readAsset("drawio","assets/sample."+e+".base64");if(e=="png")t=Uint8Array.from(atob(o),i=>i.charCodeAt(0));else if(e=="svg"){let i=atob(o);t=Uint8Array.from(i,a=>a.charCodeAt(0))}return t}async function Ir(e,t){if(await f.fileExists(e)&&!await g.confirm("File already exist! Do you want to overwrite?"))return!1;let i=await Cr(t);return f.writeFile(e,i),!0}async function fe(){let e=await g.getText(),t=await g.getSelection(),o=t.from,a=e.slice(o,t.to);a.length==0&&(a=await g.prompt("Enter a diagram name: ","sample.svg"));let c=Q(a);c!="svg"&&c!="png"&&(c="svg",a=a+"."+c);let d=await g.getCurrentPage(),y=d.substring(0,d.lastIndexOf("/"))+"/"+a;if(!await Ir(y,c))return;let W=`![${a}](${a})`;await g.replaceRange(o,t.to,W),await me(y)}var ye={editdrawio:pe,createdrawio:fe},he={name:"drawio",version:.1,assets:{"assets/sample.svg.base64":{data:"data:application/octet-stream;base64,UEQ5NGJXd2dkbVZ5YzJsdmJqMGlNUzR3SWlCbGJtTnZaR2x1WnowaVZWUkdMVGdpUHo0S1BDRXRMU0JFYnlCdWIzUWdaV1JwZENCMGFHbHpJR1pwYkdVZ2QybDBhQ0JsWkdsMGIzSnpJRzkwYUdWeUlIUm9ZVzRnWkhKaGR5NXBieUF0TFQ0S1BDRkVUME5VV1ZCRklITjJaeUJRVlVKTVNVTWdJaTB2TDFjelF5OHZSRlJFSUZOV1J5QXhMakV2TDBWT0lpQWlhSFIwY0RvdkwzZDNkeTUzTXk1dmNtY3ZSM0poY0docFkzTXZVMVpITHpFdU1TOUVWRVF2YzNabk1URXVaSFJrSWo0S1BITjJaeUI0Yld4dWN6MGlhSFIwY0RvdkwzZDNkeTUzTXk1dmNtY3ZNakF3TUM5emRtY2lJSE4wZVd4bFBTSmlZV05yWjNKdmRXNWtPaUIwY21GdWMzQmhjbVZ1ZERzZ1ltRmphMmR5YjNWdVpDMWpiMnh2Y2pvZ2RISmhibk53WVhKbGJuUTdJR052Ykc5eUxYTmphR1Z0WlRvZ2JHbG5hSFFnWkdGeWF6c2lJSGh0Ykc1ek9uaHNhVzVyUFN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GVudFdpbmRvdy5wb3N0TWVzc2FnZShKU09OLnN0cmluZ2lmeSh7CiAgICAgICAgICAgIGFjdGlvbjogJ2V4cG9ydCcsCiAgICAgICAgICAgIGZvcm1hdDogZXh0ID09ICdwbmcnID8gJ3htbHBuZycgOiAneG1sc3ZnJywKICAgICAgICAgICAgeG1sOiBtc2cueG1sLAogICAgICAgICAgICBzcGluOiAnVXBkYXRpbmcgcGFnZScKICAgICAgICB9KSwgJyonKTsKICAgIH0KICAgIGVsc2UgaWYgKG1zZy5ldmVudCA9PSAnZXhpdCcpIHsKICAgICAgICBjbG9zZSgpOwogICAgfQoKfTsKCndpbmRvdy5hZGRFdmVudExpc3RlbmVyKCdtZXNzYWdlJywgcmVjZWl2ZSk7",mtime:1736784316569},"assets/sample.png.base64":{data:"data:application/octet-stream;base64,aVZCT1J3MEtHZ29BQUFBTlNVaEVVZ0FBQUFFQUFBQUJDQVlBQUFBZkZjU0pBQUFBQVhOU1IwSUFyczRjNlFBQUFtQjBSVmgwYlhobWFXeGxBQ1V6UTIxNFptbHNaU1V5TUdodmMzUWxNMFFsTWpKaGNIQXVaR2xoWjNKaGJYTXVibVYwSlRJeUpUSXdZV2RsYm5RbE0wUWxNakpOYjNwcGJHeGhKVEpHTlM0d0pUSXdLRmRwYm1SdmQzTWxNakJPVkNVeU1ERXdMakFsTTBJbE1qQlhhVzQyTkNVelFpVXlNSGcyTkNrbE1qQkJjSEJzWlZkbFlrdHBkQ1V5UmpVek55NHpOaVV5TUNoTFNGUk5UQ1V5UXlVeU1HeHBhMlVsTWpCSFpXTnJieWtsTWpCRGFISnZiV1VsTWtZeE16RXVNQzR3TGpBbE1qQlRZV1poY21rbE1rWTFNemN1TXpZbE1qQkZaR2NsTWtZeE16RXVNQzR3TGpBbE1qSWxNakIyWlhKemFXOXVKVE5FSlRJeU1qWXVNQzQxSlRJeUpUTkZKVE5EWkdsaFozSmhiU1V5TUc1aGJXVWxNMFFsTWpKUVlXZGxMVEVsTWpJbE1qQnBaQ1V6UkNVeU1tTXRha1Y1ZFZkUU5tMXhVRGxNTjA1algwMWpKVEl5SlRORlpHUklRa1Z2U1dkRlFVUlJjaVV5UWtkUGEyeFBaSHBtVEZONVZVNXVVbXBhYUVKc01FZGhZbE1sTWtKUWFEQjNXVFozVEhNM2VHUlhSMWxvVEVjbE1rWklhU1V5UWxaSFdHeEhRVXBwYTFaSk1rVnVhM0ZhU0hseFdqRm9jV1ZJWWt4bU16QkdaMnhRUTFWeVZrOXZSa0ZYYmxGb2VFeFJValJWVDFWVWRHeFpjWGw0TmpaQ01tdFlSbkpqV1dwTU4zRnFhbkp2V1ROelNVZHhOVzV4Y2s1NVYyTTVTSEpKTms5dmJIRkZXWFZ1VWsxaFRXa3habWxuVURCclozTmpkbTluVm1oUFZWY3dabTF2U0ZoUVVUZ2xNa0o1VjNWbWFIbzFlaVV5UmxwNk9FMXpaRTgzU0dkVGJGazNOVFF5TUZGbGVEUm5NQ1V6UkNVelF5VXlSbVJwWVdkeVlXMGxNMFVsTTBNbE1rWnRlR1pwYkdVbE0wWFNCLy95QUFBQUMwbEVRVlFZVjJOZ0FBSUFBQVVBQWFyVnlGRUFBQUFBU1VWT1JLNUNZSUk9",mtime:1736784316569}},imports:["https://get.silverbullet.md/global.plug.json"],requiredPermissions:["shell","fetch"],functions:{editdrawio:{path:"./drawio.ts:editDrawioDiagram",command:{name:"Draw.io: Edit diagram",requireMode:"r"}},createdrawio:{path:"./drawio.ts:createDrawioDiagram",command:{name:"Draw.io: Create diagram",requireMode:"r"}}}},dn={manifest:he,functionMapping:ye};ie(ye,he,self.postMessage);export{dn as plug};