/*! For license information please see lsplugin.core.js.LICENSE.txt */ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LSPlugin=t():e.LSPlugin=t()}(self,(function(){return(()=>{var e={227:(e,t,n)=>{var r=n(155);t.formatArgs=function(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+e.exports.humanize(this.diff),!this.useColors)return;const n="color: "+this.color;t.splice(1,0,n,"color: inherit");let r=0,i=0;t[0].replace(/%[a-zA-Z%]/g,(e=>{"%%"!==e&&(r++,"%c"===e&&(i=r))})),t.splice(i,0,n)},t.save=function(e){try{e?t.storage.setItem("debug",e):t.storage.removeItem("debug")}catch(e){}},t.load=function(){let e;try{e=t.storage.getItem("debug")}catch(e){}return!e&&void 0!==r&&"env"in r&&(e=r.env.DEBUG),e},t.useColors=function(){return!("undefined"==typeof window||!window.process||"renderer"!==window.process.type&&!window.process.__nwjs)||("undefined"==typeof navigator||!navigator.userAgent||!navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&("undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},t.storage=function(){try{return localStorage}catch(e){}}(),t.destroy=(()=>{let e=!1;return()=>{e||(e=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.log=console.debug||console.log||(()=>{}),e.exports=n(447)(t);const{formatters:i}=e.exports;i.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}},447:(e,t,n)=>{e.exports=function(e){function t(e){let n,i=null;function o(...e){if(!o.enabled)return;const r=o,i=Number(new Date),s=i-(n||i);r.diff=s,r.prev=n,r.curr=i,n=i,e[0]=t.coerce(e[0]),"string"!=typeof e[0]&&e.unshift("%O");let a=0;e[0]=e[0].replace(/%([a-zA-Z%])/g,((n,i)=>{if("%%"===n)return"%";a++;const o=t.formatters[i];if("function"==typeof o){const t=e[a];n=o.call(r,t),e.splice(a,1),a--}return n})),t.formatArgs.call(r,e),(r.log||t.log).apply(r,e)}return o.namespace=e,o.useColors=t.useColors(),o.color=t.selectColor(e),o.extend=r,o.destroy=t.destroy,Object.defineProperty(o,"enabled",{enumerable:!0,configurable:!1,get:()=>null===i?t.enabled(e):i,set:e=>{i=e}}),"function"==typeof t.init&&t.init(o),o}function r(e,n){const r=t(this.namespace+(void 0===n?":":n)+e);return r.log=this.log,r}function i(e){return e.toString().substring(2,e.toString().length-2).replace(/\.\*\?$/,"*")}return t.debug=t,t.default=t,t.coerce=function(e){return e instanceof Error?e.stack||e.message:e},t.disable=function(){const e=[...t.names.map(i),...t.skips.map(i).map((e=>"-"+e))].join(",");return t.enable(""),e},t.enable=function(e){let n;t.save(e),t.names=[],t.skips=[];const r=("string"==typeof e?e:"").split(/[\s,]+/),i=r.length;for(n=0;n{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t1?n-1:0),i=1;i/gm),U=s(/^data-[\-\w.\u00B7-\uFFFF]/),z=s(/^aria-[\-\w]+$/),$=s(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),H=s(/^(?:\w+script|data):/i),B=s(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),W="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function G(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t0&&void 0!==arguments[0]?arguments[0]:J(),n=function(t){return e(t)};if(n.version="2.2.7",n.removed=[],!t||!t.document||9!==t.document.nodeType)return n.isSupported=!1,n;var r=t.document,i=t.document,s=t.DocumentFragment,a=t.HTMLTemplateElement,l=t.Node,c=t.Element,u=t.NodeFilter,d=t.NamedNodeMap,C=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,Z=t.Text,V=t.Comment,K=t.DOMParser,Y=t.trustedTypes,X=c.prototype,Q=S(X,"cloneNode"),ee=S(X,"nextSibling"),te=S(X,"childNodes"),ne=S(X,"parentNode");if("function"==typeof a){var re=i.createElement("template");re.content&&re.content.ownerDocument&&(i=re.content.ownerDocument)}var ie=q(Y,r),oe=ie&&Ie?ie.createHTML(""):"",se=i,ae=se.implementation,le=se.createNodeIterator,ce=se.getElementsByTagName,ue=se.createDocumentFragment,de=r.importNode,he={};try{he=A(i).documentMode?i.documentMode:{}}catch(e){}var pe={};n.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==he;var fe=I,me=D,ge=U,ye=z,ve=H,be=B,we=$,_e=null,Ce=x({},[].concat(G(E),G(T),G(O),G(L),G(M))),xe=null,Ae=x({},[].concat(G(j),G(P),G(R),G(N))),Se=null,Ee=null,Te=!0,Oe=!0,ke=!1,Le=!1,Fe=!1,Me=!1,je=!1,Pe=!1,Re=!1,Ne=!0,Ie=!1,De=!0,Ue=!0,ze=!1,$e={},He=x({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]),Be=null,We=x({},["audio","video","img","source","image","track"]),Ge=null,Je=x({},["alt","class","for","id","label","name","pattern","placeholder","summary","title","value","style","xmlns"]),qe=null,Ze=i.createElement("form"),Ve=function(e){qe&&qe===e||(e&&"object"===(void 0===e?"undefined":W(e))||(e={}),e=A(e),_e="ALLOWED_TAGS"in e?x({},e.ALLOWED_TAGS):Ce,xe="ALLOWED_ATTR"in e?x({},e.ALLOWED_ATTR):Ae,Ge="ADD_URI_SAFE_ATTR"in e?x(A(Je),e.ADD_URI_SAFE_ATTR):Je,Be="ADD_DATA_URI_TAGS"in e?x(A(We),e.ADD_DATA_URI_TAGS):We,Se="FORBID_TAGS"in e?x({},e.FORBID_TAGS):{},Ee="FORBID_ATTR"in e?x({},e.FORBID_ATTR):{},$e="USE_PROFILES"in e&&e.USE_PROFILES,Te=!1!==e.ALLOW_ARIA_ATTR,Oe=!1!==e.ALLOW_DATA_ATTR,ke=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Le=e.SAFE_FOR_TEMPLATES||!1,Fe=e.WHOLE_DOCUMENT||!1,Pe=e.RETURN_DOM||!1,Re=e.RETURN_DOM_FRAGMENT||!1,Ne=!1!==e.RETURN_DOM_IMPORT,Ie=e.RETURN_TRUSTED_TYPE||!1,je=e.FORCE_BODY||!1,De=!1!==e.SANITIZE_DOM,Ue=!1!==e.KEEP_CONTENT,ze=e.IN_PLACE||!1,we=e.ALLOWED_URI_REGEXP||we,Le&&(Oe=!1),Re&&(Pe=!0),$e&&(_e=x({},[].concat(G(M))),xe=[],!0===$e.html&&(x(_e,E),x(xe,j)),!0===$e.svg&&(x(_e,T),x(xe,P),x(xe,N)),!0===$e.svgFilters&&(x(_e,O),x(xe,P),x(xe,N)),!0===$e.mathMl&&(x(_e,L),x(xe,R),x(xe,N))),e.ADD_TAGS&&(_e===Ce&&(_e=A(_e)),x(_e,e.ADD_TAGS)),e.ADD_ATTR&&(xe===Ae&&(xe=A(xe)),x(xe,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&x(Ge,e.ADD_URI_SAFE_ATTR),Ue&&(_e["#text"]=!0),Fe&&x(_e,["html","head","body"]),_e.table&&(x(_e,["tbody"]),delete Se.tbody),o&&o(e),qe=e)},Ke=x({},["mi","mo","mn","ms","mtext"]),Ye=x({},["foreignobject","desc","title","annotation-xml"]),Xe=x({},T);x(Xe,O),x(Xe,k);var Qe=x({},L);x(Qe,F);var et="http://www.w3.org/1998/Math/MathML",tt="http://www.w3.org/2000/svg",nt="http://www.w3.org/1999/xhtml",rt=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:nt,tagName:"template"});var n=m(e.tagName),r=m(t.tagName);if(e.namespaceURI===tt)return t.namespaceURI===nt?"svg"===n:t.namespaceURI===et?"svg"===n&&("annotation-xml"===r||Ke[r]):Boolean(Xe[n]);if(e.namespaceURI===et)return t.namespaceURI===nt?"math"===n:t.namespaceURI===tt?"math"===n&&Ye[r]:Boolean(Qe[n]);if(e.namespaceURI===nt){if(t.namespaceURI===tt&&!Ye[r])return!1;if(t.namespaceURI===et&&!Ke[r])return!1;var i=x({},["title","style","font","a","script"]);return!Qe[n]&&(i[n]||!Xe[n])}return!1},it=function(e){f(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=oe}catch(t){e.remove()}}},ot=function(e,t){try{f(n.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(n.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!xe[e])if(Pe||Re)try{it(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},st=function(e){var t=void 0,n=void 0;if(je)e=""+e;else{var r=g(e,/^[\r\n\t ]+/);n=r&&r[0]}var o=ie?ie.createHTML(e):e;try{t=(new K).parseFromString(o,"text/html")}catch(e){}if(!t||!t.documentElement){var s=(t=ae.createHTMLDocument("")).body;s.parentNode.removeChild(s.parentNode.firstElementChild),s.outerHTML=o}return e&&n&&t.body.insertBefore(i.createTextNode(n),t.body.childNodes[0]||null),ce.call(t,Fe?"html":"body")[0]},at=function(e){return le.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,(function(){return u.FILTER_ACCEPT}),!1)},lt=function(e){return!(e instanceof Z||e instanceof V||"string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof C&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},ct=function(e){return"object"===(void 0===l?"undefined":W(l))?e instanceof l:e&&"object"===(void 0===e?"undefined":W(e))&&"number"==typeof e.nodeType&&"string"==typeof e.nodeName},ut=function(e,t,r){pe[e]&&h(pe[e],(function(e){e.call(n,t,r,qe)}))},dt=function(e){var t=void 0;if(ut("beforeSanitizeElements",e,null),lt(e))return it(e),!0;if(g(e.nodeName,/[\u0080-\uFFFF]/))return it(e),!0;var r=m(e.nodeName);if(ut("uponSanitizeElement",e,{tagName:r,allowedTags:_e}),!ct(e.firstElementChild)&&(!ct(e.content)||!ct(e.content.firstElementChild))&&w(/<[/\w]/g,e.innerHTML)&&w(/<[/\w]/g,e.textContent))return it(e),!0;if(!_e[r]||Se[r]){if(Ue&&!He[r]){var i=ne(e),o=te(e);if(o&&i)for(var s=o.length-1;s>=0;--s)i.insertBefore(Q(o[s],!0),ee(e))}return it(e),!0}return e instanceof c&&!rt(e)?(it(e),!0):"noscript"!==r&&"noembed"!==r||!w(/<\/no(script|embed)/i,e.innerHTML)?(Le&&3===e.nodeType&&(t=e.textContent,t=y(t,fe," "),t=y(t,me," "),e.textContent!==t&&(f(n.removed,{element:e.cloneNode()}),e.textContent=t)),ut("afterSanitizeElements",e,null),!1):(it(e),!0)},ht=function(e,t,n){if(De&&("id"===t||"name"===t)&&(n in i||n in Ze))return!1;if(Oe&&w(ge,t));else if(Te&&w(ye,t));else{if(!xe[t]||Ee[t])return!1;if(Ge[t]);else if(w(we,y(n,be,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==v(n,"data:")||!Be[e])if(ke&&!w(ve,y(n,be,"")));else if(n)return!1}return!0},pt=function(e){var t=void 0,r=void 0,i=void 0,o=void 0;ut("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:xe};for(o=s.length;o--;){var l=t=s[o],c=l.name,u=l.namespaceURI;if(r=b(t.value),i=m(c),a.attrName=i,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,ut("uponSanitizeAttribute",e,a),r=a.attrValue,!a.forceKeepAttr&&(ot(c,e),a.keepAttr))if(w(/\/>/i,r))ot(c,e);else{Le&&(r=y(r,fe," "),r=y(r,me," "));var d=e.nodeName.toLowerCase();if(ht(d,i,r))try{u?e.setAttributeNS(u,c,r):e.setAttribute(c,r),p(n.removed)}catch(e){}}}ut("afterSanitizeAttributes",e,null)}},ft=function e(t){var n=void 0,r=at(t);for(ut("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)ut("uponSanitizeShadowNode",n,null),dt(n)||(n.content instanceof s&&e(n.content),pt(n));ut("afterSanitizeShadowDOM",t,null)};return n.sanitize=function(e,i){var o=void 0,a=void 0,c=void 0,u=void 0,d=void 0;if(e||(e="\x3c!--\x3e"),"string"!=typeof e&&!ct(e)){if("function"!=typeof e.toString)throw _("toString is not a function");if("string"!=typeof(e=e.toString()))throw _("dirty is not a string, aborting")}if(!n.isSupported){if("object"===W(t.toStaticHTML)||"function"==typeof t.toStaticHTML){if("string"==typeof e)return t.toStaticHTML(e);if(ct(e))return t.toStaticHTML(e.outerHTML)}return e}if(Me||Ve(i),n.removed=[],"string"==typeof e&&(ze=!1),ze);else if(e instanceof l)1===(a=(o=st("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?o=a:o.appendChild(a);else{if(!Pe&&!Le&&!Fe&&-1===e.indexOf("<"))return ie&&Ie?ie.createHTML(e):e;if(!(o=st(e)))return Pe?null:oe}o&&je&&it(o.firstChild);for(var h=at(ze?e:o);c=h.nextNode();)3===c.nodeType&&c===u||dt(c)||(c.content instanceof s&&ft(c.content),pt(c),u=c);if(u=null,ze)return e;if(Pe){if(Re)for(d=ue.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return Ne&&(d=de.call(r,d,!0)),d}var p=Fe?o.outerHTML:o.innerHTML;return Le&&(p=y(p,fe," "),p=y(p,me," ")),ie&&Ie?ie.createHTML(p):p},n.setConfig=function(e){Ve(e),Me=!0},n.clearConfig=function(){qe=null,Me=!1},n.isValidAttribute=function(e,t,n){qe||Ve({});var r=m(e),i=m(t);return ht(r,i,n)},n.addHook=function(e,t){"function"==typeof t&&(pe[e]=pe[e]||[],f(pe[e],t))},n.removeHook=function(e){pe[e]&&p(pe[e])},n.removeHooks=function(e){pe[e]&&(pe[e]=[])},n.removeAllHooks=function(){pe={}},n}()}()},729:e=>{"use strict";var t=Object.prototype.hasOwnProperty,n="~";function r(){}function i(e,t,n){this.fn=e,this.context=t,this.once=n||!1}function o(e,t,r,o,s){if("function"!=typeof r)throw new TypeError("The listener must be a function");var a=new i(r,o||e,s),l=n?n+t:t;return e._events[l]?e._events[l].fn?e._events[l]=[e._events[l],a]:e._events[l].push(a):(e._events[l]=a,e._eventsCount++),e}function s(e,t){0==--e._eventsCount?e._events=new r:delete e._events[t]}function a(){this._events=new r,this._eventsCount=0}Object.create&&(r.prototype=Object.create(null),(new r).__proto__||(n=!1)),a.prototype.eventNames=function(){var e,r,i=[];if(0===this._eventsCount)return i;for(r in e=this._events)t.call(e,r)&&i.push(n?r.slice(1):r);return Object.getOwnPropertySymbols?i.concat(Object.getOwnPropertySymbols(e)):i},a.prototype.listeners=function(e){var t=n?n+e:e,r=this._events[t];if(!r)return[];if(r.fn)return[r.fn];for(var i=0,o=r.length,s=new Array(o);i{"function"==typeof Object.create?e.exports=function(e,t){e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}})}:e.exports=function(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}},824:e=>{var t=1e3,n=60*t,r=60*n,i=24*r;function o(e,t,n,r){var i=t>=1.5*n;return Math.round(e/n)+" "+r+(i?"s":"")}e.exports=function(e,s){s=s||{};var a,l,c=typeof e;if("string"===c&&e.length>0)return function(e){if(!((e=String(e)).length>100)){var o=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(o){var s=parseFloat(o[1]);switch((o[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*s;case"weeks":case"week":case"w":return 6048e5*s;case"days":case"day":case"d":return s*i;case"hours":case"hour":case"hrs":case"hr":case"h":return s*r;case"minutes":case"minute":case"mins":case"min":case"m":return s*n;case"seconds":case"second":case"secs":case"sec":case"s":return s*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return s;default:return}}}}(e);if("number"===c&&isFinite(e))return s.long?(a=e,(l=Math.abs(a))>=i?o(a,l,i,"day"):l>=r?o(a,l,r,"hour"):l>=n?o(a,l,n,"minute"):l>=t?o(a,l,t,"second"):a+" ms"):function(e){var o=Math.abs(e);return o>=i?Math.round(e/i)+"d":o>=r?Math.round(e/r)+"h":o>=n?Math.round(e/n)+"m":o>=t?Math.round(e/t)+"s":e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},520:(e,t,n)=>{"use strict";var r=n(155),i="win32"===r.platform,o=n(539);function s(e,t){for(var n=[],r=0;r=0&&!e[r];r--);return 0===n&&r===t?e:n>r?[]:e.slice(n,r+1)}var l=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,c=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,u={};function d(e){var t=l.exec(e),n=(t[1]||"")+(t[2]||""),r=t[3]||"",i=c.exec(r);return[n,i[1],i[2],i[3]]}function h(e){var t=l.exec(e),n=t[1]||"",r=!!n&&":"!==n[1];return{device:n,isUnc:r,isAbsolute:r||!!t[2],tail:t[3]}}function p(e){return"\\\\"+e.replace(/^[\\\/]+/,"").replace(/[\\\/]+/g,"\\")}u.resolve=function(){for(var e="",t="",n=!1,i=arguments.length-1;i>=-1;i--){var a;if(i>=0?a=arguments[i]:e?(a=r.env["="+e])&&a.substr(0,3).toLowerCase()===e.toLowerCase()+"\\"||(a=e+"\\"):a=r.cwd(),!o.isString(a))throw new TypeError("Arguments to path.resolve must be strings");if(a){var l=h(a),c=l.device,u=l.isUnc,d=l.isAbsolute,f=l.tail;if((!c||!e||c.toLowerCase()===e.toLowerCase())&&(e||(e=c),n||(t=f+"\\"+t,n=d),e&&n))break}}return u&&(e=p(e)),e+(n?"\\":"")+(t=s(t.split(/[\\\/]+/),!n).join("\\"))||"."},u.normalize=function(e){var t=h(e),n=t.device,r=t.isUnc,i=t.isAbsolute,o=t.tail,a=/[\\\/]$/.test(o);return(o=s(o.split(/[\\\/]+/),!i).join("\\"))||i||(o="."),o&&a&&(o+="\\"),r&&(n=p(n)),n+(i?"\\":"")+o},u.isAbsolute=function(e){return h(e).isAbsolute},u.join=function(){for(var e=[],t=0;t=-1&&!t;n--){var i=n>=0?arguments[n]:r.cwd();if(!o.isString(i))throw new TypeError("Arguments to path.resolve must be strings");i&&(e=i+"/"+e,t="/"===i[0])}return(t?"/":"")+(e=s(e.split("/"),!t).join("/"))||"."},m.normalize=function(e){var t=m.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=s(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},m.isAbsolute=function(e){return"/"===e.charAt(0)},m.join=function(){for(var e="",t=0;t{var t,n,r=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(e){if(t===setTimeout)return setTimeout(e,0);if((t===i||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(n){try{return t.call(null,e,0)}catch(n){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:i}catch(e){t=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var a,l=[],c=!1,u=-1;function d(){c&&a&&(c=!1,a.length?l=a.concat(l):u=-1,l.length&&h())}function h(){if(!c){var e=s(d);c=!0;for(var t=l.length;t;){for(a=l,l=[];++u1)for(var n=1;n{e.exports=function(e){return e&&"object"==typeof e&&"function"==typeof e.copy&&"function"==typeof e.fill&&"function"==typeof e.readUInt8}},539:(e,t,n)=>{var r=n(155),i=/%[sdj%]/g;t.format=function(e){if(!y(e)){for(var t=[],n=0;n=o)return e;switch(e){case"%s":return String(r[n++]);case"%d":return Number(r[n++]);case"%j":try{return JSON.stringify(r[n++])}catch(e){return"[Circular]"}default:return e}})),l=r[n];n=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),f(n)?r.showHidden=n:n&&t._extend(r,n),v(r.showHidden)&&(r.showHidden=!1),v(r.depth)&&(r.depth=2),v(r.colors)&&(r.colors=!1),v(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=l),u(r,e,r.depth)}function l(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function c(e,t){return e}function u(e,n,r){if(e.customInspect&&n&&x(n.inspect)&&n.inspect!==t.inspect&&(!n.constructor||n.constructor.prototype!==n)){var i=n.inspect(r,e);return y(i)||(i=u(e,i,r)),i}var o=function(e,t){if(v(t))return e.stylize("undefined","undefined");if(y(t)){var n="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(n,"string")}return g(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):m(t)?e.stylize("null","null"):void 0}(e,n);if(o)return o;var s=Object.keys(n),a=function(e){var t={};return e.forEach((function(e,n){t[e]=!0})),t}(s);if(e.showHidden&&(s=Object.getOwnPropertyNames(n)),C(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(n);if(0===s.length){if(x(n)){var l=n.name?": "+n.name:"";return e.stylize("[Function"+l+"]","special")}if(b(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(_(n))return e.stylize(Date.prototype.toString.call(n),"date");if(C(n))return d(n)}var c,w="",A=!1,S=["{","}"];return p(n)&&(A=!0,S=["[","]"]),x(n)&&(w=" [Function"+(n.name?": "+n.name:"")+"]"),b(n)&&(w=" "+RegExp.prototype.toString.call(n)),_(n)&&(w=" "+Date.prototype.toUTCString.call(n)),C(n)&&(w=" "+d(n)),0!==s.length||A&&0!=n.length?r<0?b(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=A?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,w,S)):S[0]+w+S[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,l;if((l=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=l.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):l.set&&(a=e.stylize("[Setter]","special")),O(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(l.value)<0?(a=m(n)?u(e,l.value,null):u(e,l.value,n-1)).indexOf("\n")>-1&&(a=o?a.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+a.split("\n").map((function(e){return" "+e})).join("\n")):a=e.stylize("[Circular]","special")),v(s)){if(o&&i.match(/^\d+$/))return a;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+a}function p(e){return Array.isArray(e)}function f(e){return"boolean"==typeof e}function m(e){return null===e}function g(e){return"number"==typeof e}function y(e){return"string"==typeof e}function v(e){return void 0===e}function b(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===A(e)}function C(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function x(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function S(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(v(o)&&(o=r.env.NODE_DEBUG||""),e=e.toUpperCase(),!s[e])if(new RegExp("\\b"+e+"\\b","i").test(o)){var n=r.pid;s[e]=function(){var r=t.format.apply(t,arguments);console.error("%s %d: %s",e,n,r)}}else s[e]=function(){};return s[e]},t.inspect=a,a.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},a.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=p,t.isBoolean=f,t.isNull=m,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=v,t.isRegExp=b,t.isObject=w,t.isDate=_,t.isError=C,t.isFunction=x,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=n(384);var E=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function T(){var e=new Date,t=[S(e.getHours()),S(e.getMinutes()),S(e.getSeconds())].join(":");return[e.getDate(),E[e.getMonth()],t].join(" ")}function O(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",T(),t.format.apply(t,arguments))},t.inherits=n(717),t._extend=function(e,t){if(!t||!w(t))return e;for(var n=Object.keys(t),r=n.length;r--;)e[n[r]]=t[n[r]];return e}}},t={};function n(r){if(t[r])return t[r].exports;var i=t[r]={exports:{}};return e[r].call(i.exports,i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{PluginLocal:()=>ee,setupPluginCore:()=>ne});var e=n(729),t=n.n(e),i=function(){return(i=Object.assign||function(e){for(var t,n=1,r=arguments.length;nn=>{e&&clearTimeout(e),t(n),i=!0},s=new Promise(((i,s)=>{n=o(i),r=o(s),e&&(e=setTimeout((()=>r(new Error(`[deferred timeout] ${t}`))),e))}));return{created:Date.now(),setTag:e=>t=e,resolve:n,reject:r,promise:s,get settled(){return i}}}function p(e,...t){const n=c(e),r=window.logseq?.api||{},i=r[n]||window.apis[n]||r[e]||window.apis[e];if(!i)throw new Error(`Not existed method #${e}`);return"function"!=typeof i?i:i.apply(null,t)}function f(e,t){const n=this;let r="";r="slot"in e?`#${e.slot}`:e.path;const i=r&&document.querySelector(r);if(!i)return void console.error(`${this.debugTag} can not resolve selector target ${r}`);const o=`${e.key}-${n.id}`;let s=document.querySelector(`div[data-injected-ui="${o}"]`);if(!s)return s=document.createElement("div"),s.dataset.injectedUi=o||"",s.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{s.setAttribute(e,t)})),i.appendChild(s),["click","focus","focusin","focusout","blur","dblclick","keyup","keypress","keydown","change","input"].forEach((e=>{s.addEventListener(e,(t=>{const r=t.target.closest(`[data-on-${e}]`);if(!r)return;const i=r.dataset[`on${o=e,o.charAt(0).toUpperCase()+o.slice(1)}`];var o;i&&n.caller?.callUserModel(i,function(e,t){const n={};if(e){const t=e.dataset,r="rect";["value","id","className","dataset",r].forEach((i=>{let o;switch(i){case r:if(!t.hasOwnProperty(r))return;o=e.getBoundingClientRect().toJSON();break;default:o=e[i]}"object"==typeof o&&(o={...o}),n[i]=o}))}return n}(r))}),!1)})),()=>{i.removeChild(s)};s.innerHTML=e.template}let m=null;var g=n(227),y=n.n(g),v="application/x-postmate-v1+json",b=0,w={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},_=function(e,t){return!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==v||!w[e.data.postmate])},C=function(){function e(e){var t=this;this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.events={},this.listener=function(e){if(!_(e,t.childOrigin))return!1;var n=((e||{}).data||{}).value||{},r=n.data,i=n.name;"emit"===e.data.postmate&&i in t.events&&t.events[i].call(t,r)},this.parent.addEventListener("message",this.listener,!1)}var t=e.prototype;return t.get=function(e){var t=this;return new A.Promise((function(n){var r=++b;t.parent.addEventListener("message",(function e(i){i.data.uid===r&&"reply"===i.data.postmate&&(t.parent.removeEventListener("message",e,!1),n(i.data.value))}),!1),t.child.postMessage({postmate:"request",type:v,property:e,uid:r},t.childOrigin)}))},t.call=function(e,t){this.child.postMessage({postmate:"call",type:v,property:e,data:t},this.childOrigin)},t.on=function(e,t){this.events[e]=t},t.destroy=function(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)},e}(),x=function(){function e(e){var t=this;this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(function(e){if(_(e,t.parentOrigin)){var n=e.data,r=n.property,i=n.uid,o=n.data;"call"!==e.data.postmate?function(e,t){var n="function"==typeof e[t]?e[t]():e[t];return A.Promise.resolve(n)}(t.model,r).then((function(t){return e.source.postMessage({property:r,postmate:"reply",type:v,uid:i,value:t},e.origin)})):r in t.model&&"function"==typeof t.model[r]&&t.model[r](o)}}))}return e.prototype.emit=function(e,t){this.parent.postMessage({postmate:"emit",type:v,value:{name:e,data:t}},this.parentOrigin)},e}(),A=function(){function e(e){var t=e.container,n=void 0===t?void 0!==n?n:document.body:t,r=e.model,i=e.url,o=e.name,s=e.classListArray,a=void 0===s?[]:s;return this.parent=window,this.frame=document.createElement("iframe"),this.frame.name=o||"",this.frame.classList.add.apply(this.frame.classList,a),n.appendChild(this.frame),this.child=this.frame.contentWindow||this.frame.contentDocument.parentWindow,this.model=r||{},this.sendHandshake(i)}return e.prototype.sendHandshake=function(t){var n,r=this,i=function(e){var t=document.createElement("a");t.href=e;var n=t.protocol.length>4?t.protocol:window.location.protocol,r=t.host.length?"80"===t.port||"443"===t.port?t.hostname:t.host:window.location.host;return t.origin||n+"//"+r}(t),o=0;return new e.Promise((function(e,s){r.parent.addEventListener("message",(function t(o){return!!_(o,i)&&("handshake-reply"===o.data.postmate?(clearInterval(n),r.parent.removeEventListener("message",t,!1),r.childOrigin=o.origin,e(new C(r))):s("Failed handshake"))}),!1);var a=function(){o++,r.child.postMessage({postmate:"handshake",type:v,model:r.model},i),5===o&&clearInterval(n)},l=function(){a(),n=setInterval(a,500)};r.frame.attachEvent?r.frame.attachEvent("onload",l):r.frame.onload=l,r.frame.src=t}))},e}();A.debug=!1,A.Promise=function(){try{return window?window.Promise:Promise}catch(e){return null}}(),A.Model=function(){function e(e){return this.child=window,this.model=e,this.parent=this.child.parent,this.sendHandshakeReply()}return e.prototype.sendHandshakeReply=function(){var e=this;return new A.Promise((function(t,n){e.child.addEventListener("message",(function r(i){if(i.data.postmate){if("handshake"===i.data.postmate){e.child.removeEventListener("message",r,!1),i.source.postMessage({postmate:"handshake-reply",type:v},i.origin),e.parentOrigin=i.origin;var o=i.data.model;return o&&Object.keys(o).forEach((function(t){e.model[t]=o[t]})),t(new x(e))}return n("Handshake Reply Failed")}}),!1)}))},e}();const S=A,E=y()("LSPlugin:user"),T={};let O=0;const k={registerSlashCommand(e,t){return E("Register slash command #",this.baseInfo.id,e,t),t=t.map((e=>{const[t,...n]=e;switch(t){case"editor/hook":let r=n[0],i=()=>{this.caller?.callUserModel(r)};"function"==typeof r&&(i=r);const o=`SlashCommandHook${t}${++O}`;e[1]=o,this.Editor["on"+o](i)}return e})),this.caller?.call("api:call",{method:"register-plugin-slash-command",args:[this.baseInfo.id,[e,t]]}),!1},registerBlockContextMenu(e,t){if("function"!=typeof t)return!1;const n=e,r=e,i=`SimpleCommandHook${e}${++O}`;return this.Editor["on"+i](t),this.caller?.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:n,label:r,type:"block-context-menu"},["editor/hook",i]]]}),!1}},L={};class F extends(t()){constructor(e,t){super(),this._baseInfo=e,this._caller=t,this._connected=!1,this._ui=new Map,t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign(this._baseInfo.settings,e);this.emit("settings:changed",{...n},t)}))}async ready(e,t){if(!this._connected)try{"function"==typeof e&&(t=e,e={});let n=await this._caller.connectToParent(e);n=d(this._baseInfo,n),this._connected=!0,t&&t.call(this,n)}catch(e){console.error("[LSPlugin Ready Error]",e)}}provideModel(e){return this.caller._extendUserModel(e),this}provideTheme(e){return this.caller.call("provider:theme",e),this}provideStyle(e){return this.caller.call("provider:style",e),this}provideUI(e){return this.caller.call("provider:ui",e),this}updateSettings(e){this.caller.call("settings:update",e)}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(){const e={key:0,visible:!1};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}showMainUI(){const e={key:0,visible:!0};this.caller.call("main-ui:visible",e),this.emit("ui:visible:changed",e),this._ui.set(e.key,e)}toggleMainUI(){const e=this._ui.get(0);e&&e.visible?this.hideMainUI():this.showMainUI()}get isMainUIVisible(){const e=this._ui.get(0);return Boolean(e&&e.visible)}get connected(){return this._connected}get baseInfo(){return this._baseInfo}get settings(){return this.baseInfo?.settings}get caller(){return this._caller}_makeUserProxy(e,t){const n=this,r=this.caller;return new Proxy(e,{get(e,i,o){const s=e[i];return function(...e){if(!s||!1!==s.apply(n,e)){if(t){const n=i.toString().match(/^(once|off|on)/i);if(null!=n){const i=n[0],o=n.input.slice(i.length);return void r[i.toLowerCase()](`hook:${t}:${c(o)}`,e[0])}}return r.callAsync("api:call",{method:i,args:e})}}}})}get App(){return this._makeUserProxy(T,"app")}get Editor(){return this._makeUserProxy(k,"editor")}get DB(){return this._makeUserProxy(L)}}if(null==window.__LSP__HOST__){const e=new B(null);window.logseq=new F({},e)}const{importHTML:M,createSandboxContainer:j}=window.QSandbox||{};function P(e,t){return e.startsWith("http")?fetch(e,t):(e=e.replace("file://",""),new Promise((async(t,n)=>{try{const n=await window.apis.doAction(["readFile",e]);t({text:()=>n})}catch(e){console.error(e),n(e)}})))}class R extends(t()){constructor(e){super(),this._pluginLocal=e,this._loaded=!1,this._unmountFns=[],e._dispose((()=>{this._unmount()}))}async load(){const{name:e,entry:t}=this._pluginLocal.options;if(this.loaded||!t)return;const{template:n,execScripts:r}=await M(t,{fetch:P});this._mount(n,document.body);const i=j(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;i.__shadow_mode__=!0,i.LSPluginLocal=this._pluginLocal,i.LSPluginShadow=this,i.LSPluginUser=i.logseq=new F(this._pluginLocal.toJSON(),this._pluginLocal.caller);const o=await r(i,!0);this._unmountFns.push(o.unmount),this._loaded=!0}_mount(e,t){const n=this._frame=document.createElement("div");n.classList.add("lsp-shadow-sandbox"),n.id=this._pluginLocal.id,this._root=n.attachShadow({mode:"open"}),this._root.innerHTML=`
${e}
`,t.appendChild(n),this.emit("mounted")}_unmount(){for(const e of this._unmountFns)e&&e.call(null)}destroy(){this.frame?.parentNode?.removeChild(this.frame)}get loaded(){return this._loaded}get document(){return this._root?.firstChild}get frame(){return this._frame}}const N=y()("LSPlugin:caller"),I="#lspmsg#",D="#lspmsg#error#",U="#lspmsg#settings#",z="#lspmsg#reply#",$="#lspmsg#ready#",H=e=>`#lspmsg#${e}`;class B extends(t()){constructor(e){super(),this._pluginLocal=e,this._connected=!1,this._userModel={}}async connectToChild(){if(this._connected)return;const{shadow:e}=this._pluginLocal;e?await this._setupShadowSandbox():await this._setupIframeSandbox()}async connectToParent(e={}){if(this._connected)return;const t=this,n=null!=this._pluginLocal;let r=0,i=0;const o=new Map,s=h(),a=this._extendUserModel({[$]:async()=>{await s.resolve()},[U]:async({type:e,payload:n})=>{t.emit("settings:changed",n)},[I]:async({ns:e,type:n,payload:r})=>{N(`[call from host #${this._pluginLocal?.id}]`,e,n,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},[z]:({_sync:e,result:t})=>{if(N(`sync reply #${e}`,t),o.has(e)){const n=o.get(e);n&&(t?.hasOwnProperty(D)?n.reject(t[D]):n.resolve(t),o.delete(e))}},...e});if(n)return await s.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const l=new S.Model(a);return this._status="pending",await l.then((e=>{this._child=e,this._connected=!0,this._call=async(t,n={},r)=>{if(r){const e=++i;o.set(e,r),n._sync=e,r.setTag(`async call #${e}`),N("async call #",e)}return e.emit(H(a.baseInfo.id),{type:t,payload:n}),r?.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){N(`model method #${e} not existed`)}},r=setInterval((()=>{if(o.size>100)for(const[e,t]of o)t.settled&&o.delete(e)}),18e5)})).finally((()=>{this._status=void 0})),await s.promise,a.baseInfo}async call(e,t={}){return this.emit(e,t),this._call?.call(this,e,t)}async callAsync(e,t={}){const n=h(1e4);return this._call?.call(this,e,t,n)}async callUserModel(e,t={}){return this._callUserModel?.call(this,e,t)}async _setupIframeSandbox(){const e=this._pluginLocal,t=new S({container:document.body,url:e.options.entry,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}});let n;return this._status="pending",new Promise(((r,i)=>{n=setTimeout((()=>{i(new Error("handshake Timeout"))}),3e3),t.then((t=>{this._parent=t,this._connected=!0,this.emit("connected"),t.frame.setAttribute("id",e.id),t.on(H(e.id),(({type:e,payload:t})=>{N("[call from plugin] ",e,t),this._pluginLocal?.emit(e,t||{})})),this._call=async(...n)=>{await t.call(H(e.id),{type:n[0],payload:n[1]||{}})},this._callUserModel=async(...e)=>{await t.call(e[0],e[1]||{})},r(null)})).catch((e=>{i(e)})).finally((()=>{clearTimeout(n)}))})).catch((e=>{throw N("iframe sandbox error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new R(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(e,t={},n)=>(n&&(t.actor=n),this._pluginLocal?.emit(e,t),n?.promise),this._callUserModel=async(...e)=>{const t=e[0],n=e[1]||{},r=this._userModel[t];"function"==typeof r&&await r.call(null,n)}}catch(e){throw N("shadow sandbox error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame}_getSandboxShadowContainer(){return this._shadow?.frame}async destroy(){this._parent&&await this._parent.destroy(),this._shadow&&this._shadow.destroy()}}var W=n(856),G=n.n(W),J=n(520);const q=y()("LSPlugin:core");class Z extends(t()){constructor(e){super(),this._userPluginSettings=e,this._settings={disabled:!1},Object.assign(this._settings,e)}get(e){return this._settings[e]}set(e,t){const n=d({},this._settings);if("string"==typeof e){if(this._settings[e]==t)return;this._settings[e]=t}else{if(!u(e))return;d(this._settings,e)}this.emit("change",Object.assign({},this._settings),n)}toJSON(){return this._settings}}class V extends(t()){constructor(e){super(),this._tag=e,this._logs=[]}write(e,t){let n=t.reduce(((e,t)=>(t&&t instanceof Error?e+=`${t.message} ${t.stack}`:e+=t.toString(),e)),`[${this._tag}][${(new Date).toLocaleTimeString()}] `);this._logs.push([e,n]),this.emit("change")}clear(){this._logs=[],this.emit("change")}info(...e){this.write("INFO",e)}error(...e){this.write("ERROR",e)}warn(...e){this.write("WARN",e)}toJSON(){return this._logs}}var K;function Y(e){let t=e=>`provider:${e}`,n=!1;e.on(t("theme"),(t=>{e.themeMgr.registerTheme(e.id,t),n||(e._dispose((()=>{e.themeMgr.unregisterTheme(e.id)})),n=!0)})),e.on(t("style"),(t=>{let n;"string"!=typeof t&&(n=t.key,t=t.style),t&&t.trim()&&e._dispose(function(e,t){const n=t["data-injected-style"];let r=n&&document.querySelector(`[data-injected-style=${n}]`);if(!r)return r=document.createElement("style"),r.textContent=e,t&&Object.entries(t).forEach((([e,t])=>{r.setAttribute(e,t)})),document.head.append(r),()=>{document.head.removeChild(r)};r.textContent=e}(t,{"data-injected-style":n?`${n}-${e.id}`:"","data-ref":e.id}))})),e.on(t("ui"),(t=>{e._onHostMounted((()=>{t.template=G().sanitize(t.template),e._dispose(f.call(e,t,{"data-ref":e.id}))}))}))}!function(e){e.LOADING="loading",e.UNLOADING="unloading",e.LOADED="loaded",e.UNLOADED="unload",e.ERROR="error"}(K||(K={}));class X extends Error{constructor(e){super(e),this.name=X.name}}class Q extends Error{constructor(e){super(e),this.name=Q.name}}class ee extends(t()){constructor(e,t,n){var r;super(),this._options=e,this._themeMgr=t,this._ctx=n,this._disposes=[],this._status=K.UNLOADED,this._id=e.key||"_"+Math.random().toString(36).substr(2,9),(r=this).on("settings:update",(e=>{e&&r.settings?.set(e)})),function(e){const t=e=>`main-ui:${e}`;e.on(t("visible"),(({visible:t,toggle:n})=>{const r=e.getMainUI();r?.classList[n?"toggle":t?"add":"remove"]("visible"),!e.shadow&&r&&r.contentWindow?.focus()})),e.on(t("attrs"),(t=>{const n=e.getMainUI();Object.entries(t).forEach((([e,t])=>{n?.setAttribute(e,t)}))})),e.on(t("style"),(t=>{const n=e.getMainUI();Object.entries(t).forEach((([e,t])=>{n.style[e]=t}))}))}(this),Y(this),function(e){e.on("api:call",(async t=>{let n;try{n=await p(t.method,...t.args)}catch(e){n={[D]:e}}const{_sync:r}=t;if(e.shadow)t.actor&&t.actor.resolve(n);else if(null!=r){const t=t=>{e.caller?.callUserModel(z,{result:t,_sync:r})};Promise.resolve(n).then(t,t)}}))}(this)}async _setupUserSettings(){const{_options:e}=this,t=e.name.replace(/[^a-z0-9]/gi,"_").toLowerCase()+"_"+this.id,n=e.logger=new V("Loader");try{const[n,r]=await p("load_plugin_user_settings",t);this._userSettingsFile=n,(e.settings=new Z(r)).on("change",((e,n)=>{q("linked settings change",e),!e.disabled&&n.disabled&&this.load(),e.disabled&&!n.disabled&&this.unload(),e&&p("save_plugin_user_settings",t,e)}))}catch(e){q("[load plugin user settings Error]",e),n?.error(e)}}getMainUI(){return this.shadow?this.caller?._getSandboxShadowContainer():this.caller?._getSandboxIframeContainer()}async _preparePackageConfigs(){const{url:e}=this._options;let t;try{if(!e)throw new Error("Can not resolve package config location");if(q("prepare package root",e),t=await p("load_plugin_config",e),!t||(t=JSON.parse(t),!t))throw new Error(`Parse package config error #${e}/package.json`)}catch(e){throw new X(e.message)}["name","author","version","description"].forEach((e=>{this._options[e]=t[e]}));const n=this._localRoot=e,r=t.logseq||{},i=(e,t=!1)=>{if(!e)return;const r=/^(http|file|assets)/;if(!r.test(e)){const t=J.join(n,e);e=r.test(t)?t:"file://"+t}return t?e:e.replace("file:","assets:")};var o;(o=t.main)&&/\.(js|html)$/.test(o)&&(this._options.entry=i(t.main,!0),r.mode&&(this._options.mode=r.mode));const s=r.icon||t.icon;if(s&&(this._options.icon=i(s)),r.id)this._id=r.id;else{r.id=this.id;try{await p("save_plugin_config",e,{...t,logseq:r})}catch(e){q("[save plugin ID Error] ",e)}}const{registeredPlugins:a,isRegistering:l}=this._ctx;if(l&&a.has(r.id))throw new Q("prepare package Error");return async()=>{try{let e=r.themes;e&&await this._loadConfigThemes(Array.isArray(e)?e:[e])}catch(e){q("[prepare package effect Error]",e)}}}async _tryToNormalizeEntry(){let{entry:e,settings:t}=this.options,n=t?.get("_devEntry");if(n)return void(this._options.entry=n);if(!e.endsWith(".js"))return;let r=await p("_callApplication","getAppPath"),i=await p("write_user_tmp_file",`${this._id}_index.html`,`\n\n \n \n logseq plugin entry\n