2 lines
87 KiB
JavaScript
2 lines
87 KiB
JavaScript
/*! 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<i;n++)r[n]&&("-"===(e=r[n].replace(/\*/g,".*?"))[0]?t.skips.push(new RegExp("^"+e.substr(1)+"$")):t.names.push(new RegExp("^"+e+"$")))},t.enabled=function(e){if("*"===e[e.length-1])return!0;let n,r;for(n=0,r=t.skips.length;n<r;n++)if(t.skips[n].test(e))return!1;for(n=0,r=t.names.length;n<r;n++)if(t.names[n].test(e))return!0;return!1},t.humanize=n(824),t.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(e).forEach((n=>{t[n]=e[n]})),t.names=[],t.skips=[],t.formatters={},t.selectColor=function(e){let n=0;for(let t=0;t<e.length;t++)n=(n<<5)-n+e.charCodeAt(t),n|=0;return t.colors[Math.abs(n)%t.colors.length]},t.enable(t.load()),t}},856:function(e){e.exports=function(){"use strict";var e=Object.hasOwnProperty,t=Object.setPrototypeOf,n=Object.isFrozen,r=Object.getPrototypeOf,i=Object.getOwnPropertyDescriptor,o=Object.freeze,s=Object.seal,a=Object.create,l="undefined"!=typeof Reflect&&Reflect,c=l.apply,u=l.construct;c||(c=function(e,t,n){return e.apply(t,n)}),o||(o=function(e){return e}),s||(s=function(e){return e}),u||(u=function(e,t){return new(Function.prototype.bind.apply(e,[null].concat(function(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}(t))))});var d,h=x(Array.prototype.forEach),p=x(Array.prototype.pop),f=x(Array.prototype.push),g=x(String.prototype.toLowerCase),m=x(String.prototype.match),y=x(String.prototype.replace),_=x(String.prototype.indexOf),v=x(String.prototype.trim),b=x(RegExp.prototype.test),w=(d=TypeError,function(){for(var e=arguments.length,t=Array(e),n=0;n<e;n++)t[n]=arguments[n];return u(d,t)});function x(e){return function(t){for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return c(e,t,r)}}function S(e,r){t&&t(e,null);for(var i=r.length;i--;){var o=r[i];if("string"==typeof o){var s=g(o);s!==o&&(n(r)||(r[i]=s),o=s)}e[o]=!0}return e}function C(t){var n=a(null),r=void 0;for(r in t)c(e,t,[r])&&(n[r]=t[r]);return n}function O(e,t){for(;null!==e;){var n=i(e,t);if(n){if(n.get)return x(n.get);if("function"==typeof n.value)return x(n.value)}e=r(e)}return function(e){return console.warn("fallback value for",e),null}}var A=o(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),E=o(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),T=o(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),j=o(["animate","color-profile","cursor","discard","fedropshadow","feimage","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),L=o(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover"]),k=o(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),F=o(["#text"]),I=o(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),R=o(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),M=o(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),P=o(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),D=s(/\{\{[\s\S]*|[\s\S]*\}\}/gm),N=s(/<%[\s\S]*|[\s\S]*%>/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 q(e){if(Array.isArray(e)){for(var t=0,n=Array(e.length);t<e.length;t++)n[t]=e[t];return n}return Array.from(e)}var G=function(){return"undefined"==typeof window?null:window},J=function(e,t){if("object"!==(void 0===e?"undefined":W(e))||"function"!=typeof e.createPolicy)return null;var n=null,r="data-tt-policy-suffix";t.currentScript&&t.currentScript.hasAttribute(r)&&(n=t.currentScript.getAttribute(r));var i="dompurify"+(n?"#"+n:"");try{return e.createPolicy(i,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+i+" could not be created."),null}};return function e(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:G(),n=function(t){return e(t)};if(n.version="2.3.1",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,x=void 0===d?t.NamedNodeMap||t.MozNamedAttrMap:d,Z=t.Text,V=t.Comment,K=t.DOMParser,Y=t.trustedTypes,X=c.prototype,Q=O(X,"cloneNode"),ee=O(X,"nextSibling"),te=O(X,"childNodes"),ne=O(X,"parentNode");if("function"==typeof a){var re=i.createElement("template");re.content&&re.content.ownerDocument&&(i=re.content.ownerDocument)}var ie=J(Y,r),oe=ie&&De?ie.createHTML(""):"",se=i,ae=se.implementation,le=se.createNodeIterator,ce=se.createDocumentFragment,ue=se.getElementsByTagName,de=r.importNode,he={};try{he=C(i).documentMode?i.documentMode:{}}catch(e){}var pe={};n.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==he;var fe=D,ge=N,me=U,ye=z,_e=H,ve=B,be=$,we=null,xe=S({},[].concat(q(A),q(E),q(T),q(L),q(F))),Se=null,Ce=S({},[].concat(q(I),q(R),q(M),q(P))),Oe=null,Ae=null,Ee=!0,Te=!0,je=!1,Le=!1,ke=!1,Fe=!1,Ie=!1,Re=!1,Me=!1,Pe=!0,De=!1,Ne=!0,Ue=!0,ze=!1,$e={},He=null,Be=S({},["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"]),We=null,qe=S({},["audio","video","img","source","image","track"]),Ge=null,Je=S({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ze="http://www.w3.org/1998/Math/MathML",Ve="http://www.w3.org/2000/svg",Ke="http://www.w3.org/1999/xhtml",Ye=Ke,Xe=!1,Qe=null,et=i.createElement("form"),tt=function(e){Qe&&Qe===e||(e&&"object"===(void 0===e?"undefined":W(e))||(e={}),e=C(e),we="ALLOWED_TAGS"in e?S({},e.ALLOWED_TAGS):xe,Se="ALLOWED_ATTR"in e?S({},e.ALLOWED_ATTR):Ce,Ge="ADD_URI_SAFE_ATTR"in e?S(C(Je),e.ADD_URI_SAFE_ATTR):Je,We="ADD_DATA_URI_TAGS"in e?S(C(qe),e.ADD_DATA_URI_TAGS):qe,He="FORBID_CONTENTS"in e?S({},e.FORBID_CONTENTS):Be,Oe="FORBID_TAGS"in e?S({},e.FORBID_TAGS):{},Ae="FORBID_ATTR"in e?S({},e.FORBID_ATTR):{},$e="USE_PROFILES"in e&&e.USE_PROFILES,Ee=!1!==e.ALLOW_ARIA_ATTR,Te=!1!==e.ALLOW_DATA_ATTR,je=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Le=e.SAFE_FOR_TEMPLATES||!1,ke=e.WHOLE_DOCUMENT||!1,Re=e.RETURN_DOM||!1,Me=e.RETURN_DOM_FRAGMENT||!1,Pe=!1!==e.RETURN_DOM_IMPORT,De=e.RETURN_TRUSTED_TYPE||!1,Ie=e.FORCE_BODY||!1,Ne=!1!==e.SANITIZE_DOM,Ue=!1!==e.KEEP_CONTENT,ze=e.IN_PLACE||!1,be=e.ALLOWED_URI_REGEXP||be,Ye=e.NAMESPACE||Ke,Le&&(Te=!1),Me&&(Re=!0),$e&&(we=S({},[].concat(q(F))),Se=[],!0===$e.html&&(S(we,A),S(Se,I)),!0===$e.svg&&(S(we,E),S(Se,R),S(Se,P)),!0===$e.svgFilters&&(S(we,T),S(Se,R),S(Se,P)),!0===$e.mathMl&&(S(we,L),S(Se,M),S(Se,P))),e.ADD_TAGS&&(we===xe&&(we=C(we)),S(we,e.ADD_TAGS)),e.ADD_ATTR&&(Se===Ce&&(Se=C(Se)),S(Se,e.ADD_ATTR)),e.ADD_URI_SAFE_ATTR&&S(Ge,e.ADD_URI_SAFE_ATTR),e.FORBID_CONTENTS&&(He===Be&&(He=C(He)),S(He,e.FORBID_CONTENTS)),Ue&&(we["#text"]=!0),ke&&S(we,["html","head","body"]),we.table&&(S(we,["tbody"]),delete Oe.tbody),o&&o(e),Qe=e)},nt=S({},["mi","mo","mn","ms","mtext"]),rt=S({},["foreignobject","desc","title","annotation-xml"]),it=S({},E);S(it,T),S(it,j);var ot=S({},L);S(ot,k);var st=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Ke,tagName:"template"});var n=g(e.tagName),r=g(t.tagName);if(e.namespaceURI===Ve)return t.namespaceURI===Ke?"svg"===n:t.namespaceURI===Ze?"svg"===n&&("annotation-xml"===r||nt[r]):Boolean(it[n]);if(e.namespaceURI===Ze)return t.namespaceURI===Ke?"math"===n:t.namespaceURI===Ve?"math"===n&&rt[r]:Boolean(ot[n]);if(e.namespaceURI===Ke){if(t.namespaceURI===Ve&&!rt[r])return!1;if(t.namespaceURI===Ze&&!nt[r])return!1;var i=S({},["title","style","font","a","script"]);return!ot[n]&&(i[n]||!it[n])}return!1},at=function(e){f(n.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=oe}catch(t){e.remove()}}},lt=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&&!Se[e])if(Re||Me)try{at(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},ct=function(e){var t=void 0,n=void 0;if(Ie)e="<remove></remove>"+e;else{var r=m(e,/^[\r\n\t ]+/);n=r&&r[0]}var o=ie?ie.createHTML(e):e;if(Ye===Ke)try{t=(new K).parseFromString(o,"text/html")}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Ye,"template",null);try{t.documentElement.innerHTML=Xe?"":o}catch(e){}}var s=t.body||t.documentElement;return e&&n&&s.insertBefore(i.createTextNode(n),s.childNodes[0]||null),Ye===Ke?ue.call(t,ke?"html":"body")[0]:ke?t.documentElement:s},ut=function(e){return le.call(e.ownerDocument||e,e,u.SHOW_ELEMENT|u.SHOW_COMMENT|u.SHOW_TEXT,null,!1)},dt=function(e){return!(e instanceof Z||e instanceof V||"string"==typeof e.nodeName&&"string"==typeof e.textContent&&"function"==typeof e.removeChild&&e.attributes instanceof x&&"function"==typeof e.removeAttribute&&"function"==typeof e.setAttribute&&"string"==typeof e.namespaceURI&&"function"==typeof e.insertBefore)},ht=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},pt=function(e,t,r){pe[e]&&h(pe[e],(function(e){e.call(n,t,r,Qe)}))},ft=function(e){var t=void 0;if(pt("beforeSanitizeElements",e,null),dt(e))return at(e),!0;if(m(e.nodeName,/[\u0080-\uFFFF]/))return at(e),!0;var r=g(e.nodeName);if(pt("uponSanitizeElement",e,{tagName:r,allowedTags:we}),!ht(e.firstElementChild)&&(!ht(e.content)||!ht(e.content.firstElementChild))&&b(/<[/\w]/g,e.innerHTML)&&b(/<[/\w]/g,e.textContent))return at(e),!0;if("select"===r&&b(/<template/i,e.innerHTML))return at(e),!0;if(!we[r]||Oe[r]){if(Ue&&!He[r]){var i=ne(e)||e.parentNode,o=te(e)||e.childNodes;if(o&&i)for(var s=o.length-1;s>=0;--s)i.insertBefore(Q(o[s],!0),ee(e))}return at(e),!0}return e instanceof c&&!st(e)?(at(e),!0):"noscript"!==r&&"noembed"!==r||!b(/<\/no(script|embed)/i,e.innerHTML)?(Le&&3===e.nodeType&&(t=e.textContent,t=y(t,fe," "),t=y(t,ge," "),e.textContent!==t&&(f(n.removed,{element:e.cloneNode()}),e.textContent=t)),pt("afterSanitizeElements",e,null),!1):(at(e),!0)},gt=function(e,t,n){if(Ne&&("id"===t||"name"===t)&&(n in i||n in et))return!1;if(Te&&!Ae[t]&&b(me,t));else if(Ee&&b(ye,t));else{if(!Se[t]||Ae[t])return!1;if(Ge[t]);else if(b(be,y(n,ve,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==_(n,"data:")||!We[e])if(je&&!b(_e,y(n,ve,"")));else if(n)return!1}return!0},mt=function(e){var t=void 0,r=void 0,i=void 0,o=void 0;pt("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Se};for(o=s.length;o--;){var l=t=s[o],c=l.name,u=l.namespaceURI;if(r=v(t.value),i=g(c),a.attrName=i,a.attrValue=r,a.keepAttr=!0,a.forceKeepAttr=void 0,pt("uponSanitizeAttribute",e,a),r=a.attrValue,!a.forceKeepAttr&&(lt(c,e),a.keepAttr))if(b(/\/>/i,r))lt(c,e);else{Le&&(r=y(r,fe," "),r=y(r,ge," "));var d=e.nodeName.toLowerCase();if(gt(d,i,r))try{u?e.setAttributeNS(u,c,r):e.setAttribute(c,r),p(n.removed)}catch(e){}}}pt("afterSanitizeAttributes",e,null)}},yt=function e(t){var n=void 0,r=ut(t);for(pt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)pt("uponSanitizeShadowNode",n,null),ft(n)||(n.content instanceof s&&e(n.content),mt(n));pt("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((Xe=!e)&&(e="\x3c!--\x3e"),"string"!=typeof e&&!ht(e)){if("function"!=typeof e.toString)throw w("toString is not a function");if("string"!=typeof(e=e.toString()))throw w("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(ht(e))return t.toStaticHTML(e.outerHTML)}return e}if(Fe||tt(i),n.removed=[],"string"==typeof e&&(ze=!1),ze);else if(e instanceof l)1===(a=(o=ct("\x3c!----\x3e")).ownerDocument.importNode(e,!0)).nodeType&&"BODY"===a.nodeName||"HTML"===a.nodeName?o=a:o.appendChild(a);else{if(!Re&&!Le&&!ke&&-1===e.indexOf("<"))return ie&&De?ie.createHTML(e):e;if(!(o=ct(e)))return Re?null:oe}o&&Ie&&at(o.firstChild);for(var h=ut(ze?e:o);c=h.nextNode();)3===c.nodeType&&c===u||ft(c)||(c.content instanceof s&&yt(c.content),mt(c),u=c);if(u=null,ze)return e;if(Re){if(Me)for(d=ce.call(o.ownerDocument);o.firstChild;)d.appendChild(o.firstChild);else d=o;return Pe&&(d=de.call(r,d,!0)),d}var p=ke?o.outerHTML:o.innerHTML;return Le&&(p=y(p,fe," "),p=y(p,ge," ")),ie&&De?ie.createHTML(p):p},n.setConfig=function(e){tt(e),Fe=!0},n.clearConfig=function(){Qe=null,Fe=!1},n.isValidAttribute=function(e,t,n){Qe||tt({});var r=g(e),i=g(t);return gt(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<o;i++)s[i]=r[i].fn;return s},a.prototype.listenerCount=function(e){var t=n?n+e:e,r=this._events[t];return r?r.fn?1:r.length:0},a.prototype.emit=function(e,t,r,i,o,s){var a=n?n+e:e;if(!this._events[a])return!1;var l,c,u=this._events[a],d=arguments.length;if(u.fn){switch(u.once&&this.removeListener(e,u.fn,void 0,!0),d){case 1:return u.fn.call(u.context),!0;case 2:return u.fn.call(u.context,t),!0;case 3:return u.fn.call(u.context,t,r),!0;case 4:return u.fn.call(u.context,t,r,i),!0;case 5:return u.fn.call(u.context,t,r,i,o),!0;case 6:return u.fn.call(u.context,t,r,i,o,s),!0}for(c=1,l=new Array(d-1);c<d;c++)l[c-1]=arguments[c];u.fn.apply(u.context,l)}else{var h,p=u.length;for(c=0;c<p;c++)switch(u[c].once&&this.removeListener(e,u[c].fn,void 0,!0),d){case 1:u[c].fn.call(u[c].context);break;case 2:u[c].fn.call(u[c].context,t);break;case 3:u[c].fn.call(u[c].context,t,r);break;case 4:u[c].fn.call(u[c].context,t,r,i);break;default:if(!l)for(h=1,l=new Array(d-1);h<d;h++)l[h-1]=arguments[h];u[c].fn.apply(u[c].context,l)}}return!0},a.prototype.on=function(e,t,n){return o(this,e,t,n,!1)},a.prototype.once=function(e,t,n){return o(this,e,t,n,!0)},a.prototype.removeListener=function(e,t,r,i){var o=n?n+e:e;if(!this._events[o])return this;if(!t)return s(this,o),this;var a=this._events[o];if(a.fn)a.fn!==t||i&&!a.once||r&&a.context!==r||s(this,o);else{for(var l=0,c=[],u=a.length;l<u;l++)(a[l].fn!==t||i&&!a[l].once||r&&a[l].context!==r)&&c.push(a[l]);c.length?this._events[o]=1===c.length?c[0]:c:s(this,o)}return this},a.prototype.removeAllListeners=function(e){var t;return e?(t=n?n+e:e,this._events[t]&&s(this,t)):(this._events=new r,this._eventsCount=0),this},a.prototype.off=a.prototype.removeListener,a.prototype.addListener=a.prototype.on,a.prefixed=n,a.EventEmitter=a,e.exports=a},717:e=>{"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<e.length;r++){var i=e[r];i&&"."!==i&&(".."===i?n.length&&".."!==n[n.length-1]?n.pop():t&&n.push(".."):n.push(i))}return n}function a(e){for(var t=e.length-1,n=0;n<=t&&!e[n];n++);for(var r=t;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<arguments.length;t++){var n=arguments[t];if(!o.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&e.push(n)}var r=e.join("\\");return/^[\\\/]{2}[^\\\/]/.test(e[0])||(r=r.replace(/^[\\\/]{2,}/,"\\")),u.normalize(r)},u.relative=function(e,t){e=u.resolve(e),t=u.resolve(t);for(var n=e.toLowerCase(),r=t.toLowerCase(),i=a(t.split("\\")),o=a(n.split("\\")),s=a(r.split("\\")),l=Math.min(o.length,s.length),c=l,d=0;d<l;d++)if(o[d]!==s[d]){c=d;break}if(0==c)return t;var h=[];for(d=c;d<o.length;d++)h.push("..");return(h=h.concat(i.slice(c))).join("\\")},u._makeLong=function(e){if(!o.isString(e))return e;if(!e)return"";var t=u.resolve(e);return/^[a-zA-Z]\:\\/.test(t)?"\\\\?\\"+t:/^\\\\[^?.]/.test(t)?"\\\\?\\UNC\\"+t.substring(2):e},u.dirname=function(e){var t=d(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},u.basename=function(e,t){var n=d(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},u.extname=function(e){return d(e)[3]},u.format=function(e){if(!o.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!o.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);var n=e.dir,r=e.base||"";return n?n[n.length-1]===u.sep?n+r:n+u.sep+r:r},u.parse=function(e){if(!o.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=d(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},u.sep="\\",u.delimiter=";";var f=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/,g={};function m(e){return f.exec(e).slice(1)}g.resolve=function(){for(var e="",t=!1,n=arguments.length-1;n>=-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("/"))||"."},g.normalize=function(e){var t=g.isAbsolute(e),n=e&&"/"===e[e.length-1];return(e=s(e.split("/"),!t).join("/"))||t||(e="."),e&&n&&(e+="/"),(t?"/":"")+e},g.isAbsolute=function(e){return"/"===e.charAt(0)},g.join=function(){for(var e="",t=0;t<arguments.length;t++){var n=arguments[t];if(!o.isString(n))throw new TypeError("Arguments to path.join must be strings");n&&(e+=e?"/"+n:n)}return g.normalize(e)},g.relative=function(e,t){e=g.resolve(e).substr(1),t=g.resolve(t).substr(1);for(var n=a(e.split("/")),r=a(t.split("/")),i=Math.min(n.length,r.length),o=i,s=0;s<i;s++)if(n[s]!==r[s]){o=s;break}var l=[];for(s=o;s<n.length;s++)l.push("..");return(l=l.concat(r.slice(o))).join("/")},g._makeLong=function(e){return e},g.dirname=function(e){var t=m(e),n=t[0],r=t[1];return n||r?(r&&(r=r.substr(0,r.length-1)),n+r):"."},g.basename=function(e,t){var n=m(e)[2];return t&&n.substr(-1*t.length)===t&&(n=n.substr(0,n.length-t.length)),n},g.extname=function(e){return m(e)[3]},g.format=function(e){if(!o.isObject(e))throw new TypeError("Parameter 'pathObject' must be an object, not "+typeof e);var t=e.root||"";if(!o.isString(t))throw new TypeError("'pathObject.root' must be a string or undefined, not "+typeof e.root);return(e.dir?e.dir+g.sep:"")+(e.base||"")},g.parse=function(e){if(!o.isString(e))throw new TypeError("Parameter 'pathString' must be a string, not "+typeof e);var t=m(e);if(!t||4!==t.length)throw new TypeError("Invalid path '"+e+"'");return t[1]=t[1]||"",t[2]=t[2]||"",t[3]=t[3]||"",{root:t[0],dir:t[0]+t[1].slice(0,-1),base:t[2],ext:t[3],name:t[2].slice(0,t[2].length-t[3].length)}},g.sep="/",g.delimiter=":",e.exports=i?u:g,e.exports.posix=g,e.exports.win32=u},155:e=>{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=[];++u<t;)a&&a[u].run();u=-1,t=l.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function f(){}r.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];l.push(new p(e,t)),1!==l.length||c||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},r.title="browser",r.browser=!0,r.env={},r.argv=[],r.version="",r.versions={},r.on=f,r.addListener=f,r.once=f,r.off=f,r.removeListener=f,r.removeAllListeners=f,r.emit=f,r.prependListener=f,r.prependOnceListener=f,r.listeners=function(e){return[]},r.binding=function(e){throw new Error("process.binding is not supported")},r.cwd=function(){return"/"},r.chdir=function(e){throw new Error("process.chdir is not supported")},r.umask=function(){return 0}},384:e=>{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<arguments.length;n++)t.push(a(arguments[n]));return t.join(" ")}n=1;for(var r=arguments,o=r.length,s=String(e).replace(i,(function(e){if("%%"===e)return"%";if(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<o;l=r[++n])g(l)||!b(l)?s+=" "+l:s+=" "+a(l);return s},t.deprecate=function(e,i){if(_(n.g.process))return function(){return t.deprecate(e,i).apply(this,arguments)};if(!0===r.noDeprecation)return e;var o=!1;return function(){if(!o){if(r.throwDeprecation)throw new Error(i);r.traceDeprecation?console.trace(i):console.error(i),o=!0}return e.apply(this,arguments)}};var o,s={};function a(e,n){var r={seen:[],stylize:c};return arguments.length>=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),f(n)?r.showHidden=n:n&&t._extend(r,n),_(r.showHidden)&&(r.showHidden=!1),_(r.depth)&&(r.depth=2),_(r.colors)&&(r.colors=!1),_(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&&S(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(_(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 m(t)?e.stylize(""+t,"number"):f(t)?e.stylize(""+t,"boolean"):g(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)),x(n)&&(s.indexOf("message")>=0||s.indexOf("description")>=0))return d(n);if(0===s.length){if(S(n)){var l=n.name?": "+n.name:"";return e.stylize("[Function"+l+"]","special")}if(v(n))return e.stylize(RegExp.prototype.toString.call(n),"regexp");if(w(n))return e.stylize(Date.prototype.toString.call(n),"date");if(x(n))return d(n)}var c,b="",C=!1,O=["{","}"];return p(n)&&(C=!0,O=["[","]"]),S(n)&&(b=" [Function"+(n.name?": "+n.name:"")+"]"),v(n)&&(b=" "+RegExp.prototype.toString.call(n)),w(n)&&(b=" "+Date.prototype.toUTCString.call(n)),x(n)&&(b=" "+d(n)),0!==s.length||C&&0!=n.length?r<0?v(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),c=C?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)T(t,String(s))?o.push(h(e,t,n,r,String(s),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(h(e,t,n,r,i,!0))})),o}(e,n,r,a,s):s.map((function(t){return h(e,n,r,a,t,C)})),e.seen.pop(),function(e,t,n){return e.reduce((function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?n[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+n[1]:n[0]+t+" "+e.join(", ")+" "+n[1]}(c,b,O)):O[0]+b+O[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")),T(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(l.value)<0?(a=g(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")),_(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 g(e){return null===e}function m(e){return"number"==typeof e}function y(e){return"string"==typeof e}function _(e){return void 0===e}function v(e){return b(e)&&"[object RegExp]"===C(e)}function b(e){return"object"==typeof e&&null!==e}function w(e){return b(e)&&"[object Date]"===C(e)}function x(e){return b(e)&&("[object Error]"===C(e)||e instanceof Error)}function S(e){return"function"==typeof e}function C(e){return Object.prototype.toString.call(e)}function O(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(e){if(_(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=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=m,t.isString=y,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=_,t.isRegExp=v,t.isObject=b,t.isDate=w,t.isError=x,t.isFunction=S,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 A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function E(){var e=new Date,t=[O(e.getHours()),O(e.getMinutes()),O(e.getSeconds())].join(":");return[e.getDate(),A[e.getMonth()],t].join(" ")}function T(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",E(),t.format.apply(t,arguments))},t.inherits=n(717),t._extend=function(e,t){if(!t||!b(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){var i=t[r];if(void 0!==i)return i.exports;var o=t[r]={exports:{}};return e[r].call(o.exports,o,o.exports,n),o.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:()=>Sn,pluginHelpers:()=>e,setupPluginCore:()=>On});var e={};n.r(e),n.d(e,{IS_DEV:()=>ut,PROTOCOL_FILE:()=>dt,PROTOCOL_LSP:()=>ht,URL_LSP:()=>pt,deepMerge:()=>vt,deferred:()=>Ot,genID:()=>bt,getAppPathRoot:()=>mt,getSDKPathRoot:()=>yt,invokeHostExportedApi:()=>At,isObject:()=>_t,mergeSettingsWithSchema:()=>Rt,path:()=>ct,safetyPathJoin:()=>St,safetyPathNormalize:()=>Ct,setupIframeSandbox:()=>Et,setupInjectedStyle:()=>Tt,setupInjectedTheme:()=>It,setupInjectedUI:()=>Lt,transformableEvent:()=>kt,ucFirst:()=>wt,withFileProtocol:()=>xt});var t=n(729),i=n.n(t),o=function(){return(o=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e}).apply(this,arguments)};function s(e){return e.toLowerCase()}Object.create,Object.create;var a=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],l=/[^A-Z0-9]+/gi;function c(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function u(e,t){return void 0===t&&(t={}),function(e,t){return void 0===t&&(t={}),function(e,t){void 0===t&&(t={});for(var n=t.splitRegexp,r=void 0===n?a:n,i=t.stripRegexp,o=void 0===i?l:i,u=t.transform,d=void 0===u?s:u,h=t.delimiter,p=void 0===h?" ":h,f=c(c(e,r,"$1\0$2"),o,"\0"),g=0,m=f.length;"\0"===f.charAt(g);)g++;for(;"\0"===f.charAt(m-1);)m--;return f.slice(g,m).split("\0").map(d).join(p)}(e,o({delimiter:"."},t))}(e,o({delimiter:"_"},t))}var d=n(520),h=n(856),p=n.n(h);const f=function(e,t){return e===t||e!=e&&t!=t},g=function(e,t){for(var n=e.length;n--;)if(f(e[n][0],t))return n;return-1};var m=Array.prototype.splice;function y(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}y.prototype.clear=function(){this.__data__=[],this.size=0},y.prototype.delete=function(e){var t=this.__data__,n=g(t,e);return!(n<0||(n==t.length-1?t.pop():m.call(t,n,1),--this.size,0))},y.prototype.get=function(e){var t=this.__data__,n=g(t,e);return n<0?void 0:t[n][1]},y.prototype.has=function(e){return g(this.__data__,e)>-1},y.prototype.set=function(e,t){var n=this.__data__,r=g(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const _=y,v="object"==typeof global&&global&&global.Object===Object&&global;var b="object"==typeof self&&self&&self.Object===Object&&self;const w=v||b||Function("return this")(),x=w.Symbol;var S=Object.prototype,C=S.hasOwnProperty,O=S.toString,A=x?x.toStringTag:void 0;var E=Object.prototype.toString;var T=x?x.toStringTag:void 0;const j=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":T&&T in Object(e)?function(e){var t=C.call(e,A),n=e[A];try{e[A]=void 0;var r=!0}catch(e){}var i=O.call(e);return r&&(t?e[A]=n:delete e[A]),i}(e):function(e){return E.call(e)}(e)},L=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},k=function(e){if(!L(e))return!1;var t=j(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},F=w["__core-js_shared__"];var I,R=(I=/[^.]+$/.exec(F&&F.keys&&F.keys.IE_PROTO||""))?"Symbol(src)_1."+I:"";var M=Function.prototype.toString;var P=/^\[object .+?Constructor\]$/,D=Function.prototype,N=Object.prototype,U=D.toString,z=N.hasOwnProperty,$=RegExp("^"+U.call(z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const H=function(e){return!(!L(e)||(t=e,R&&R in t))&&(k(e)?$:P).test(function(e){if(null!=e){try{return M.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t},B=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return H(n)?n:void 0},W=B(w,"Map"),q=B(Object,"create");var G=Object.prototype.hasOwnProperty;var J=Object.prototype.hasOwnProperty;function Z(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Z.prototype.clear=function(){this.__data__=q?q(null):{},this.size=0},Z.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Z.prototype.get=function(e){var t=this.__data__;if(q){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return G.call(t,e)?t[e]:void 0},Z.prototype.has=function(e){var t=this.__data__;return q?void 0!==t[e]:J.call(t,e)},Z.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=q&&void 0===t?"__lodash_hash_undefined__":t,this};const V=Z,K=function(e,t){var n,r,i=e.__data__;return("string"==(r=typeof(n=t))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?i["string"==typeof t?"string":"hash"]:i.map};function Y(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}Y.prototype.clear=function(){this.size=0,this.__data__={hash:new V,map:new(W||_),string:new V}},Y.prototype.delete=function(e){var t=K(this,e).delete(e);return this.size-=t?1:0,t},Y.prototype.get=function(e){return K(this,e).get(e)},Y.prototype.has=function(e){return K(this,e).has(e)},Y.prototype.set=function(e,t){var n=K(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const X=Y;function Q(e){var t=this.__data__=new _(e);this.size=t.size}Q.prototype.clear=function(){this.__data__=new _,this.size=0},Q.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Q.prototype.get=function(e){return this.__data__.get(e)},Q.prototype.has=function(e){return this.__data__.has(e)},Q.prototype.set=function(e,t){var n=this.__data__;if(n instanceof _){var r=n.__data__;if(!W||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new X(r)}return n.set(e,t),this.size=n.size,this};const ee=Q,te=function(){try{var e=B(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),ne=function(e,t,n){"__proto__"==t&&te?te(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},re=function(e,t,n){(void 0!==n&&!f(e[t],n)||void 0===n&&!(t in e))&&ne(e,t,n)},ie=function(e,t,n){for(var r=-1,i=Object(e),o=n(e),s=o.length;s--;){var a=o[++r];if(!1===t(i[a],a,i))break}return e};var oe="object"==typeof exports&&exports&&!exports.nodeType&&exports,se=oe&&"object"==typeof module&&module&&!module.nodeType&&module,ae=se&&se.exports===oe?w.Buffer:void 0,le=ae?ae.allocUnsafe:void 0;const ce=w.Uint8Array,ue=function(e,t){var n,r,i=t?(n=e.buffer,r=new n.constructor(n.byteLength),new ce(r).set(new ce(n)),r):e.buffer;return new e.constructor(i,e.byteOffset,e.length)};var de=Object.create;const he=function(){function e(){}return function(t){if(!L(t))return{};if(de)return de(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),pe=(fe=Object.getPrototypeOf,ge=Object,function(e){return fe(ge(e))});var fe,ge,me=Object.prototype;const ye=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||me)},_e=function(e){return null!=e&&"object"==typeof e},ve=function(e){return _e(e)&&"[object Arguments]"==j(e)};var be=Object.prototype,we=be.hasOwnProperty,xe=be.propertyIsEnumerable;const Se=ve(function(){return arguments}())?ve:function(e){return _e(e)&&we.call(e,"callee")&&!xe.call(e,"callee")},Ce=Array.isArray,Oe=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Ae=function(e){return null!=e&&Oe(e.length)&&!k(e)};var Ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,Te=Ee&&"object"==typeof module&&module&&!module.nodeType&&module,je=Te&&Te.exports===Ee?w.Buffer:void 0;const Le=(je?je.isBuffer:void 0)||function(){return!1};var ke=Function.prototype,Fe=Object.prototype,Ie=ke.toString,Re=Fe.hasOwnProperty,Me=Ie.call(Object);var Pe={};Pe["[object Float32Array]"]=Pe["[object Float64Array]"]=Pe["[object Int8Array]"]=Pe["[object Int16Array]"]=Pe["[object Int32Array]"]=Pe["[object Uint8Array]"]=Pe["[object Uint8ClampedArray]"]=Pe["[object Uint16Array]"]=Pe["[object Uint32Array]"]=!0,Pe["[object Arguments]"]=Pe["[object Array]"]=Pe["[object ArrayBuffer]"]=Pe["[object Boolean]"]=Pe["[object DataView]"]=Pe["[object Date]"]=Pe["[object Error]"]=Pe["[object Function]"]=Pe["[object Map]"]=Pe["[object Number]"]=Pe["[object Object]"]=Pe["[object RegExp]"]=Pe["[object Set]"]=Pe["[object String]"]=Pe["[object WeakMap]"]=!1;var De="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ne=De&&"object"==typeof module&&module&&!module.nodeType&&module,Ue=Ne&&Ne.exports===De&&v.process,ze=function(){try{return Ne&&Ne.require&&Ne.require("util").types||Ue&&Ue.binding&&Ue.binding("util")}catch(e){}}(),$e=ze&&ze.isTypedArray;const He=$e?function(e){return function(t){return e(t)}}($e):function(e){return _e(e)&&Oe(e.length)&&!!Pe[j(e)]},Be=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var We=Object.prototype.hasOwnProperty;const qe=function(e,t,n){var r=e[t];We.call(e,t)&&f(r,n)&&(void 0!==n||t in e)||ne(e,t,n)};var Ge=/^(?:0|[1-9]\d*)$/;const Je=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&Ge.test(e))&&e>-1&&e%1==0&&e<t};var Ze=Object.prototype.hasOwnProperty;const Ve=function(e,t){var n=Ce(e),r=!n&&Se(e),i=!n&&!r&&Le(e),o=!n&&!r&&!i&&He(e),s=n||r||i||o,a=s?function(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}(e.length,String):[],l=a.length;for(var c in e)!t&&!Ze.call(e,c)||s&&("length"==c||i&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||Je(c,l))||a.push(c);return a};var Ke=Object.prototype.hasOwnProperty;const Ye=function(e){if(!L(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=ye(e),n=[];for(var r in e)("constructor"!=r||!t&&Ke.call(e,r))&&n.push(r);return n},Xe=function(e){return Ae(e)?Ve(e,!0):Ye(e)},Qe=function(e){return function(e,t,n,r){var i=!n;n||(n={});for(var o=-1,s=t.length;++o<s;){var a=t[o],l=r?r(n[a],e[a],a,n,e):void 0;void 0===l&&(l=e[a]),i?ne(n,a,l):qe(n,a,l)}return n}(e,Xe(e))},et=function(e,t,n,r,i,o,s){var a,l=Be(e,n),c=Be(t,n),u=s.get(c);if(u)re(e,n,u);else{var d=o?o(l,c,n+"",e,t,s):void 0,h=void 0===d;if(h){var p=Ce(c),f=!p&&Le(c),g=!p&&!f&&He(c);d=c,p||f||g?Ce(l)?d=l:_e(a=l)&&Ae(a)?d=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(l):f?(h=!1,d=function(e,t){if(t)return e.slice();var n=e.length,r=le?le(n):new e.constructor(n);return e.copy(r),r}(c,!0)):g?(h=!1,d=ue(c,!0)):d=[]:function(e){if(!_e(e)||"[object Object]"!=j(e))return!1;var t=pe(e);if(null===t)return!0;var n=Re.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&Ie.call(n)==Me}(c)||Se(c)?(d=l,Se(l)?d=Qe(l):L(l)&&!k(l)||(d=function(e){return"function"!=typeof e.constructor||ye(e)?{}:he(pe(e))}(c))):h=!1}h&&(s.set(c,d),i(d,c,r,o,s),s.delete(c)),re(e,n,d)}},tt=function e(t,n,r,i,o){t!==n&&ie(n,(function(s,a){if(o||(o=new ee),L(s))et(t,n,a,r,e,i,o);else{var l=i?i(Be(t,a),s,a+"",t,n,o):void 0;void 0===l&&(l=s),re(t,a,l)}}),Xe)},nt=function(e){return e},rt=function(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)};var it=Math.max;const ot=te?function(e,t){return te(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:nt;var st=Date.now;const at=function(e){var t=0,n=0;return function(){var r=st(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ot),lt=(ft=function(e,t,n){tt(e,t,n)},function(e,t){return at(function(e,t,n){return t=it(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=it(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var a=Array(t+1);++i<t;)a[i]=r[i];return a[t]=n(s),rt(e,this,a)}}(e,t,nt),e+"")}((function(e,t){var n=-1,r=t.length,i=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(i=ft.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!L(n))return!1;var r=typeof t;return!!("number"==r?Ae(n)&&Je(t,n.length):"string"==r&&t in n)&&f(n[t],e)}(t[0],t[1],o)&&(i=r<3?void 0:i,r=1),e=Object(e);++n<r;){var s=t[n];s&&ft(e,s,n)}return e}))),ct="win32"===navigator.platform.toLowerCase()?d.win32:d.posix,ut=!1,dt="file://",ht="lsp://",pt=ht+"logseq.io/";var ft;let gt;async function mt(){return gt||(gt=await At("_callApplication","getAppPath"))}async function yt(){return ut?localStorage.getItem("LSP_DEV_SDK_ROOT")||"http://localhost:8080":St(await mt(),"js")}function _t(e){return e===Object(e)&&!Array.isArray(e)}const vt=lt;function bt(){return"_"+Math.random().toString(36).substr(2,9)}function wt(e){return e.charAt(0).toUpperCase()+e.slice(1)}function xt(e){return e?(/^(http|file|lsp)/.test(e)||(e=dt+e),e):""}function St(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=ct.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return ct.join(e,...t)}}function Ct(e){return e?.match(/^(http?|lsp|assets):/)||(e=ct.normalize(e)),e}function Ot(e,t){let n,r,i=!1;const o=t=>n=>{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 At(e,...t){const n=u(e=e?.startsWith("_call")?e:e?.replace(/^[_$]+/,"")),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 Et(e,t){const n=document.createElement("iframe");return n.classList.add("lsp-iframe-sandbox"),Object.entries(e).forEach((([e,t])=>{n.setAttribute(e,t)})),t.appendChild(n),async()=>{t.removeChild(n)}}function Tt(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}const jt=new Map;function Lt(e,t,n){let r,i,o="";const s=this;"slot"in e?(o=e.slot,r=`#${o}`):"path"in e?r=e.path:i=!0;const a=`${e.key}-${o}-${s.id}`,l=`${e.key}--${s.id}`,c=i?document.body:r&&document.querySelector(r);if(!c)return void console.error(`${this.debugTag} can not resolve selector target ${r}`);if(!e.template)return void jt.get(a)?.call(null);e.template=p().sanitize(e.template,{ADD_TAGS:["iframe"],ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_ATTR:["allow","src","allowfullscreen","frameborder","scrolling","target"]});let u,d,h=document.querySelector(`#${a}`),f=i?h?.querySelector(".ls-ui-float-content"):h;if(!f)return h=document.createElement("div"),h.id=a,h.dataset.injectedUi=l||"",i?(f=document.createElement("div"),f.classList.add("ls-ui-float-content"),h.appendChild(f)):f=h,f.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{h.setAttribute(e,t)})),e.style&&Object.entries(e.style).forEach((([e,t])=>{h.style[e]=t})),i&&(h.setAttribute("draggable","true"),h.setAttribute("resizable","true"),e.close&&(h.dataset.close=e.close),h.classList.add("lsp-ui-float-container","visible"),s._setupResizableContainer(h,l),d=s._setupDraggableContainer(h,{key:l,close:()=>u(),title:t?.title})),o&&e.reset&&Array.from(c.querySelectorAll("[data-injected-ui]")).map((e=>e.id))?.forEach((e=>{jt.get(e)?.call(null)})),c.appendChild(h),["click","focus","focusin","focusout","blur","dblclick","keyup","keypress","keydown","change","input"].forEach((e=>{h.addEventListener(e,(t=>{const n=t.target.closest(`[data-on-${e}]`);if(!n)return;const r=n.dataset[`on${wt(e)}`];r&&s.caller?.callUserModel(r,kt(n))}),!1)})),n?.({el:h,float:i}),u=()=>{d?.(),jt.delete(a),c.removeChild(h)},jt.set(a,u),u;{f.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{h.setAttribute(e,t)}));let n=null!=h.dataset.dx;e.style&&Object.entries(e.style).forEach((([e,t])=>{n&&["left","top","bottom","right","width","height"].includes(e)||(h.style[e]=t)}))}}function kt(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}let Ft=null;function It(e){if(Ft?.call(),!e)return;const t=document.createElement("link");return t.rel="stylesheet",t.href=e,document.head.appendChild(t),Ft=()=>{try{document.head.removeChild(t)}catch(e){console.error(e)}Ft=null}}function Rt(e,t){const n=(t||[]).reduce(((e,t)=>("default"in t&&(e[t.key]=t.default),e)),{});return Object.assign(n,e)}var Mt=n(227),Pt=n.n(Mt);const Dt="application/x-postmate-v1+json";let Nt=0;const Ut={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},zt=(e,t)=>!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==Dt||!Ut[e.data.postmate]);class $t{parent;frame;child;events={};childOrigin;listener;constructor(e){this.parent=e.parent,this.frame=e.frame,this.child=e.child,this.childOrigin=e.childOrigin,this.listener=e=>{if(!zt(e,this.childOrigin))return!1;const{data:t,name:n}=((e||{}).data||{}).value||{};"emit"===e.data.postmate&&n in this.events&&this.events[n].forEach((e=>{e.call(this,t)}))},this.parent.addEventListener("message",this.listener,!1)}get(e){return new Promise((t=>{const n=++Nt,r=e=>{e.data.uid===n&&"reply"===e.data.postmate&&(this.parent.removeEventListener("message",r,!1),t(e.data.value))};this.parent.addEventListener("message",r,!1),this.child.postMessage({postmate:"request",type:Dt,property:e,uid:n},this.childOrigin)}))}call(e,t){this.child.postMessage({postmate:"call",type:Dt,property:e,data:t},this.childOrigin)}on(e,t){this.events[e]||(this.events[e]=[]),this.events[e].push(t)}destroy(){window.removeEventListener("message",this.listener,!1),this.frame.parentNode.removeChild(this.frame)}}class Ht{model;parent;parentOrigin;child;constructor(e){this.model=e.model,this.parent=e.parent,this.parentOrigin=e.parentOrigin,this.child=e.child,this.child.addEventListener("message",(e=>{if(!zt(e,this.parentOrigin))return;const{property:t,uid:n,data:r}=e.data;"call"!==e.data.postmate?((e,t)=>{const n="function"==typeof e[t]?e[t]():e[t];return Promise.resolve(n)})(this.model,t).then((r=>{e.source.postMessage({property:t,postmate:"reply",type:Dt,uid:n,value:r},e.origin)})):t in this.model&&"function"==typeof this.model[t]&&this.model[t](r)}))}emit(e,t){this.parent.postMessage({postmate:"emit",type:Dt,value:{name:e,data:t}},this.parentOrigin)}}class Bt{static debug=!1;container;parent;frame;child;childOrigin;url;model;static Model;constructor(e){this.container=e.container,this.url=e.url,this.parent=window,this.frame=document.createElement("iframe"),e.id&&(this.frame.id=e.id),e.name&&(this.frame.name=e.name),this.frame.classList.add.apply(this.frame.classList,e.classListArray||[]),this.container.appendChild(this.frame),this.child=this.frame.contentWindow,this.model=e.model||{}}sendHandshake(e){const t=(e=>{const t=document.createElement("a");t.href=e;const 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}`})(e=e||this.url);let n,r=0;return new Promise(((i,o)=>{const s=e=>!!zt(e,t)&&("handshake-reply"===e.data.postmate?(clearInterval(n),this.parent.removeEventListener("message",s,!1),this.childOrigin=e.origin,i(new $t(this))):o("Failed handshake"));this.parent.addEventListener("message",s,!1);const a=()=>{r++,this.child.postMessage({postmate:"handshake",type:Dt,model:this.model},t),5===r&&clearInterval(n)};this.frame.addEventListener("load",(()=>{a(),n=setInterval(a,500)})),this.frame.src=e}))}}class Wt{child;model;parent;parentOrigin;constructor(e){this.child=window,this.model=e,this.parent=this.child.parent}sendHandshakeReply(){return new Promise(((e,t)=>{const n=r=>{if(r.data.postmate){if("handshake"===r.data.postmate){this.child.removeEventListener("message",n,!1),r.source.postMessage({postmate:"handshake-reply",type:Dt},r.origin),this.parentOrigin=r.origin;const t=r.data.model;return t&&Object.keys(t).forEach((e=>{this.model[e]=t[e]})),e(new Ht(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)}))}}class qt{ctx;constructor(e){this.ctx=e}get ctxId(){return this.ctx.baseInfo.id}setItem(e,t){return this.ctx.caller.callAsync("api:call",{method:"write-plugin-storage-file",args:[this.ctxId,e,t]})}getItem(e){return this.ctx.caller.callAsync("api:call",{method:"read-plugin-storage-file",args:[this.ctxId,e]})}removeItem(e){return this.ctx.caller.call("api:call",{method:"unlink-plugin-storage-file",args:[this.ctxId,e]})}clear(){return this.ctx.caller.call("api:call",{method:"clear-plugin-storage-files",args:[this.ctxId]})}hasItem(e){return this.ctx.caller.callAsync("api:call",{method:"exist-plugin-storage-file",args:[this.ctxId,e]})}}const Gt=Symbol.for("proxy-continue"),Jt=Pt()("LSPlugin:user");function Zt(e,t,n){if("function"!=typeof n)return!1;const{key:r,label:i,desc:o,palette:s,keybinding:a}=t,l=`SimpleCommandHook${r}${++Kt}`;this.Editor["on"+l](n),this.caller?.call("api:call",{method:"register-plugin-simple-command",args:[this.baseInfo.id,[{key:r,label:i,type:e,desc:o,keybinding:a},["editor/hook",l]],s]})}const Vt={registerCommand:Zt,registerCommandPalette(e,t){const{key:n,label:r,keybinding:i}=e;return Zt.call(this,"global-palette-command",{key:n,label:r,palette:!0,keybinding:i},t)},registerUIItem(e,t){const n=this.baseInfo.id;this.caller?.call("api:call",{method:"register-plugin-ui-item",args:[n,e,t]})},registerPageMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;Zt.call(this,"page-menu-item",{key:n,label:r},t)},setFullScreen(e){const t=(...e)=>this._callWin("setFullScreen",...e);"toggle"===e?this._callWin("isFullScreen").then((e=>{e?t():t(!0)})):e?t(!0):t()}};let Kt=0;const Yt={registerSlashCommand(e,t){Jt("Register slash command #",this.baseInfo.id,e,t),"function"==typeof t&&(t=[["editor/clear-current-slash",!1],["editor/restore-saved-cursor"],["editor/hook",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}${++Kt}`;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]]})},registerBlockContextMenuItem(e,t){if("function"!=typeof t)return!1;const n=e+"_"+this.baseInfo.id,r=e;Zt.call(this,"block-context-menu-item",{key:n,label:r},t)},scrollToBlockInPage(e,t){const n="block-content-"+t;this.App.pushState("page",{name:e},{anchor:n})}},Xt={};class Qt extends(i()){_baseInfo;_caller;_settingsSchema;_connected=!1;_ui=new Map;_fileStorage;_beforeunloadCallback;constructor(e,t){super(),this._baseInfo=e,this._caller=t,t.on("sys:ui:visible",(e=>{e?.toggle&&this.toggleMainUI()})),t.on("settings:changed",(e=>{const t=Object.assign({},this.settings),n=Object.assign(this._baseInfo.settings,e);this.emit("settings:changed",{...n},t)})),t.on("beforeunload",(async e=>{const{actor:n,...r}=e,i=this._beforeunloadCallback;try{i&&await i(r),n?.resolve(null)}catch(e){console.debug(`${t.debugTag} [beforeunload] `,e),n?.reject(e)}})),this._fileStorage=new qt(this)}async ready(e,t){if(!this._connected)try{"function"==typeof e&&(t=e,e={});let n=await this._caller.connectToParent(e);this._connected=!0,n=vt(this._baseInfo,n),this._settingsSchema&&(n.settings=Rt(n.settings,this._settingsSchema),await this.useSettingsSchema(this._settingsSchema)),n?.id&&(this._caller.debugTag=`#${n.id} [${n.name}]`),t&&t.call(this,n)}catch(e){console.error("[LSPlugin Ready Error]",e)}}ensureConnected(){if(!this._connected)throw new Error("not connected")}beforeunload(e){"function"==typeof e&&(this._beforeunloadCallback=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}useSettingsSchema(e){return this.connected&&this.caller.call("settings:schema",{schema:e,isSync:!0}),this._settingsSchema=e,this}updateSettings(e){this.caller.call("settings:update",e)}onSettingsChanged(e){const t="settings:changed";return this.on(t,e),()=>this.off(t,e)}showSettingsUI(){this.caller.call("settings:visible:changed",{visible:!0})}hideSettingsUI(){this.caller.call("settings:visible:changed",{visible:!1})}setMainUIAttrs(e){this.caller.call("main-ui:attrs",e)}setMainUIInlineStyle(e){this.caller.call("main-ui:style",e)}hideMainUI(e){const t={key:0,visible:!1,cursor:e?.restoreEditingCursor};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}showMainUI(e){const t={key:0,visible:!0,autoFocus:e?.autoFocus};this.caller.call("main-ui:visible",t),this.emit("ui:visible:changed",t),this._ui.set(t.key,t)}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}resolveResourceFullUrl(e){if(this.ensureConnected(),e)return e=e.replace(/^[.\\/]+/,""),St(this._baseInfo.lsr,e)}_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||s.apply(n,e)===Gt){if(t){const n=i.toString().match(/^(once|off|on)/i);if(null!=n){const i=n[0].toLowerCase(),o=n.input.slice(i.length),s=`hook:${t}:${u(o)}`,a=e[0];return r[i](s,a),"off"!==i?()=>r.off(s,a):void 0}}return r.callAsync("api:call",{tag:t,method:i,args:e})}}}})}_callWin(...e){return this._caller.callAsync("api:call",{method:"_callMainWin",args:e})}get App(){return this._makeUserProxy(Vt,"app")}get Editor(){return this._makeUserProxy(Yt,"editor")}get DB(){return this._makeUserProxy(Xt)}get FileStorage(){return this._fileStorage}}if(null==window.__LSP__HOST__){const e=new fn(null);window.logseq=new Qt({},e)}const{importHTML:en,createSandboxContainer:tn}=window.QSandbox||{};function nn(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 rn extends(i()){_pluginLocal;_frame;_root;_loaded=!1;_unmountFns=[];constructor(e){super(),this._pluginLocal=e,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 en(t,{fetch:nn});this._mount(n,document.body);const i=tn(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;i.__shadow_mode__=!0,i.LSPluginLocal=this._pluginLocal,i.LSPluginShadow=this,i.LSPluginUser=i.logseq=new Qt(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=`<div>${e}</div>`,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 on=Pt()("LSPlugin:caller"),sn="#await#response#",an="#lspmsg#",ln="#lspmsg#error#",cn="#lspmsg#settings#",un="#lspmsg#beforeunload#",dn="#lspmsg#reply#",hn="#lspmsg#ready#",pn=e=>`#lspmsg#${e}`;class fn extends(i()){_pluginLocal;_connected=!1;_parent;_child;_shadow;_status;_userModel={};_call;_callUserModel;_debugTag="";constructor(e){super(),this._pluginLocal=e,e&&(this._debugTag=e.debugTag)}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=Ot(5e3),a=this._extendUserModel({[hn]:async e=>{a[pn(e?.pid)]=({type:e,payload:n})=>{on(`[call from host (_call)] ${this._debugTag}`,e,n),t.emit(e,n)},await s.resolve()},[un]:async e=>{const n=Ot(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},[cn]:async({type:e,payload:n})=>{t.emit("settings:changed",n)},[an]:async({ns:e,type:n,payload:r})=>{on(`[call from host (async)] ${this._debugTag}`,e,n,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},[dn]:({_sync:e,result:t})=>{if(on(`[sync reply] #${e}`,t),o.has(e)){const n=o.get(e);n&&(t?.hasOwnProperty(ln)?n.reject(t[ln]):n.resolve(t),o.delete(e))}},...e});if(n)return await s.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const l=new Wt(a).sendHandshakeReply();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}`),on("async call #",e)}return e.emit(pn(a.baseInfo.id),{type:t,payload:n}),r?.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){on(`[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._call?.call(this,e,t)}async callAsync(e,t={}){const n=Ot(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=e.id,n=new URL(e.options.entry);n.searchParams.set("__v__",ut?Date.now().toString():e.options.version);const r=document.querySelector(`#${t}`);r&&r.parentElement.removeChild(r);const i=document.createElement("div");i.classList.add("lsp-iframe-sandbox-container"),i.id=t;try{const e=(await this._pluginLocal._loadLayoutsData())?.$$0;if(e){i.dataset.inited_layout="true";const{width:t,height:n,left:r,top:o}=e;Object.assign(i.style,{width:t+"px",height:n+"px",left:r+"px",top:o+"px"})}}catch(e){console.error("[Restore Layout Error]",e)}document.body.appendChild(i);let o,s=new Bt({id:t+"_iframe",container:i,url:n.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}}).sendHandshake();return this._status="pending",new Promise(((t,n)=>{o=setTimeout((()=>{n(new Error("handshake Timeout"))}),3e3),s.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on(pn(e.id),(({type:e,payload:t})=>{on("[call from plugin] ",e,t),this._pluginLocal?.emit(e,t||{})})),this._call=async(...t)=>{await n.call(pn(e.id),{type:t[0],payload:Object.assign(t[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,t)=>{if(e.startsWith(sn))return await n.get(e.replace(sn,""));n.call(e,t)},t(null)})).catch((e=>{n(e)})).finally((()=>{clearTimeout(o)}))})).catch((e=>{throw on("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new rn(e);try{this._status="pending",await t.load(),this._connected=!0,this.emit("connected"),this._call=async(t,n={},r)=>(r&&(n.actor=r),this._pluginLocal?.emit(t,Object.assign(n,{$$pid:e.id})),r?.promise),this._callUserModel=async(...e)=>{let t=e[0];t?.startsWith(sn)&&(t=t.replace(sn,""));const n=e[1]||{},r=this._userModel[t];"function"==typeof r&&await r.call(null,n)}}catch(e){throw on("[shadow sandbox] error",e),e}finally{this._status=void 0}}_extendUserModel(e){return Object.assign(this._userModel,e)}_getSandboxIframeContainer(){return this._parent?.frame.parentNode}_getSandboxShadowContainer(){return this._shadow?.frame.parentNode}_getSandboxIframeRoot(){return this._parent?.frame}_getSandboxShadowRoot(){return this._shadow?.frame}set debugTag(e){this._debugTag=e}async destroy(){let e=null;this._parent&&(e=this._getSandboxIframeContainer(),await this._parent.destroy()),this._shadow&&(e=this._getSandboxShadowContainer(),this._shadow.destroy()),e?.parentNode.removeChild(e)}}const gn=Pt()("LSPlugin:core"),mn="plugins";class yn extends(i()){_userPluginSettings;_schema;_settings={disabled:!1};constructor(e,t){super(),this._userPluginSettings=e,this._schema=t,Object.assign(this._settings,e)}get(e){return this._settings[e]}set(e,t){const n=vt({},this._settings);if("string"==typeof e){if(this._settings[e]==t)return;this._settings[e]=t}else{if(!_t(e))return;vt(this._settings,e)}this.emit("change",Object.assign({},this._settings),n)}set settings(e){this._settings=e}get settings(){return this._settings}setSchema(e,t){if(this._schema=e,t){const t=this._settings;this._settings=Rt(t,e),this.emit("change",this._settings,t)}}reset(){const e=this.settings,t={};this._schema,this.settings=t,this.emit("reset",t,e)}toJSON(){return this._settings}}class _n extends(i()){_tag;_logs=[];constructor(e){super(),this._tag=e}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 vn;function bn(e,t){return t&&e.startsWith(dt+t)&&(e=St(pt,e.substr(dt.length+t.length))),e}!function(e){e.LOADING="loading",e.UNLOADING="unloading",e.LOADED="loaded",e.UNLOADED="unload",e.ERROR="error"}(vn||(vn={}));class wn extends Error{constructor(e){super(e),this.name=wn.name}}class xn extends Error{constructor(e){super(e),this.name=xn.name}}class Sn extends(i()){_options;_themeMgr;_ctx;_disposes=[];_id;_status=vn.UNLOADED;_loadErr;_localRoot;_dotSettingsFile;_caller;constructor(e,t,n){var r;super(),this._options=e,this._themeMgr=t,this._ctx=n,this._id=e.key||bt(),function(e){const t=e=>`settings:${e}`;e.on(t("schema"),(({schema:t,isSync:n})=>{e.settingsSchema=t,e.settings?.setSchema(t,n)})),e.on(t("update"),(t=>{t&&e.settings?.set(t)})),e.on(t("visible:changed"),(t=>{const n=t?.visible;At("set_focused_settings",n?e.id:null)}))}(this),function(e){const t=e=>`main-ui:${e}`;e.on(t("visible"),(({visible:t,toggle:n,cursor:r,autoFocus:i})=>{const o=e.getMainUIContainer();o?.classList[n?"toggle":t?"add":"remove"]("visible"),t&&!e.shadow&&o&&!1!==i&&o.querySelector("iframe")?.contentWindow?.focus(),r&&At("restore_editing_cursor")})),e.on(t("attrs"),(t=>{const n=e.getMainUIContainer();Object.entries(t).forEach((([t,r])=>{n?.setAttribute(t,r),"draggable"===t&&r&&e._dispose(e._setupDraggableContainer(n,{title:e.options.name,close:()=>{e.caller.call("sys:ui:visible",{toggle:!0})}})),"resizable"===t&&r&&e._dispose(e._setupResizableContainer(n))}))})),e.on(t("style"),(t=>{const n=e.getMainUIContainer(),r=!!n.dataset.inited_layout;Object.entries(t).forEach((([e,t])=>{r&&["left","top","bottom","right","width","height"].includes(e)||(n.style[e]=t)}))}))}(this),function(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(Tt(t,{"data-injected-style":n?`${n}-${e.id}`:"","data-ref":e.id}))})),e.on(t("ui"),(t=>{e._onHostMounted((()=>{e._dispose(Lt.call(e,t,Object.assign({"data-ref":e.id},t.attrs||{}),(({el:t,float:n})=>{if(!n)return;const r=t.dataset.identity;e.layoutCore.move_container_to_top(r)})))}))}))}(this),(r=this).on("api:call",(async e=>{let t;try{t=await At(e.method,...e.args)}catch(e){t={[ln]:e}}const{_sync:n}=e;if(r.shadow)e.actor&&e.actor.resolve(t);else if(null!=n){const e=e=>{r.caller?.callUserModel(dn,{result:e,_sync:n})};Promise.resolve(t).then(e,e)}}))}async _setupUserSettings(e){const{_options:t}=this,n=t.logger=new _n("Loader");if(!t.settings||e)try{const n=()=>At("load_plugin_user_settings",this.id),[r,i]=await n();this._dotSettingsFile=r;let o=t.settings;if(o||(o=t.settings=new yn(i)),e)return void(o.settings=i);const s=async(e,t)=>{if(gn("Settings changed",this.debugTag,e),!e.disabled&&t.disabled){const[,t]=await n();t.disabled=!1,e=Object.assign(e,t),o.settings=e,await this.load()}if(e.disabled&&!t.disabled){const[,t]=await n();t.disabled=!0,e=Object.assign(e,t),await this.unload()}e&&At("save_plugin_user_settings",this.id,e)};return o.on("change",s),()=>{}}catch(e){gn("[load plugin user settings Error]",e),n?.error(e)}}getMainUIContainer(){return this.shadow?this.caller?._getSandboxShadowContainer():this.caller?._getSandboxIframeContainer()}_resolveResourceFullUrl(e,t){if(!e?.trim())return;t=t||this._localRoot;const n=/^(http|file)/;if(!n.test(e)){const r=ct.join(t,e);e=n.test(r)?r:dt+r}return!this.options.effect&&this.isInstalledInDotRoot?bn(e,this.dotPluginsRoot):e}async _preparePackageConfigs(){const{url:e}=this._options;let t;try{if(!e)throw new Error("Can not resolve package config location");if(gn("prepare package root",e),t=await At("load_plugin_config",e),!t||(t=JSON.parse(t),!t))throw new Error(`Parse package config error #${e}/package.json`)}catch(e){throw new wn(e.message)}const n=this._localRoot=Ct(e),r=t.logseq||{};["name","author","repository","version","description","repo","title","effect","sponsors"].concat(this.isInstalledInDotRoot?[]:["devEntry"]).forEach((e=>{this._options[e]=t[e]}));const i=r.entry||r.main||t.main;var o;(o=i)&&/\.(js|html)$/.test(o)&&(this._options.entry=this._resolveResourceFullUrl(i,n),this._options.devEntry=r.devEntry,r.mode&&(this._options.mode=r.mode));const s=r.title||t.title,a=r.icon||t.icon;if(this._options.title=s,this._options.icon=a&&this._resolveResourceFullUrl(a),this._options.theme=Boolean(r.theme||!!r.themes),this.isInstalledInDotRoot)this._id=ct.basename(n);else if(r.id)this._id=r.id;else{r.id=this.id;try{await At("save_plugin_config",e,{...t,logseq:r})}catch(e){gn("[save plugin ID Error] ",e)}}const{registeredPlugins:l,isRegistering:c}=this._ctx;if(c&&l.has(r.id))throw new xn("prepare package Error");return async()=>{try{let e=r.themes;e&&await this._loadConfigThemes(Array.isArray(e)?e:[e])}catch(e){gn("[prepare package effect Error]",e)}}}async _tryToNormalizeEntry(){let{entry:e,settings:t,devEntry:n}=this.options;if(n=n||t?.get("_devEntry"),n)return void(this._options.entry=n);if(!e.endsWith(".js"))return;let r=null,i="write_user_tmp_file";this.isInstalledInDotRoot&&(i="write_dotdir_file",r=this._localRoot.replace(this.dotPluginsRoot,""),r=ct.join(mn,r));let o=(new Date).getDay(),s=await yt(),a=await At(i,`${this._id}_index.html`,`<!doctype html>\n<html lang="en">\n <head>\n <meta charset="UTF-8">\n <title>logseq plugin entry</title>\n ${ut?`<script src="${s}/lsplugin.user.js?v=${o}"><\/script>`:`<script src="https://cdn.jsdelivr.net/npm/@logseq/libs/dist/lsplugin.user.min.js?v=${o}"><\/script>`}\n \n </head>\n <body>\n <div id="app"></div>\n <script src="${e}"><\/script>\n </body>\n</html>`,r);e=bn(xt(ct.normalize(a)),this.dotPluginsRoot),this._options.entry=e}async _loadConfigThemes(e){e.forEach((e=>{e.url&&(!e.url.startsWith("http")&&this._localRoot&&(e.url=ct.join(this._localRoot,e.url),e.url.startsWith("file:")||(e.url="assets://"+e.url)),this.emit("provider:theme",e))}))}async _loadLayoutsData(){const e=this.id+"_layouts",[,t]=await At("load_plugin_user_settings",e);return t||{}}async _saveLayoutsData(e){const t=this.id+"_layouts";await At("save_plugin_user_settings",t,e)}async _persistMainUILayoutData(e){const t=await this._loadLayoutsData();t.$$0=e,await this._saveLayoutsData(t)}_setupDraggableContainer(e,t={}){const n=e.dataset;if(n.inited_draggable)return;n.identity||(n.identity="dd-"+bt());const r=!!t.key,i=document.createElement("div");i.classList.add("draggable-handle"),i.innerHTML=`\n <div class="th">\n <div class="l"><h3>${t.title||""}</h3></div>\n <div class="r">\n <a class="button x"><i class="ti ti-x"></i></a>\n </div>\n </div>\n `,i.querySelector(".x").addEventListener("click",(e=>{t?.close?.(),e.stopPropagation()}),!1),i.addEventListener("mousedown",(e=>{if(e.target?.closest(".r"))return e.stopPropagation(),void e.preventDefault()}),!1),e.prepend(i),e.addEventListener("mousedown",(e=>{this.layoutCore.move_container_to_top(n.identity)}),!0);const o=this.layoutCore.setup_draggable_container_BANG_(e,r?()=>{}:this._persistMainUILayoutData.bind(this));var s;n.inited_draggable="true",t.title&&(s=t.title,i.querySelector("h3").textContent=s);let a=null;if("outside"===n.close){const n=n=>{const r=n.target;e.contains(r)||t.close()};document.addEventListener("click",n,!1),a=()=>{document.removeEventListener("click",n)}}return()=>{o(),a?.()}}_setupResizableContainer(e,t){const n=e.dataset;if(n.inited_resizable)return;n.identity||(n.identity="dd-"+bt());const r=document.createElement("div");r.classList.add("resizable-handle"),e.prepend(r);const i=window.frontend.modules.layout.core.setup_resizable_container_BANG_(e,t?()=>{}:this._persistMainUILayoutData.bind(this));return n.inited_resizable="true",i}async load(e){if(!this.pending){this._status=vn.LOADING,this._loadErr=void 0;try{let t=await this._preparePackageConfigs();if(this._dispose(await this._setupUserSettings(e?.reload)),this.disabled||await t.call(null),this.disabled||!this.options.entry)return;await this._tryToNormalizeEntry(),this._caller=new fn(this),await this._caller.connectToChild();const n=()=>{this._caller?.callUserModel(hn,{pid:this.id})};e?.indicator?e.indicator.promise.then(n):n(),this._dispose((async()=>{await(this._caller?.destroy())}))}catch(e){gn("[Load Plugin Error] ",e),this.logger?.error(e),this._status=vn.ERROR,this._loadErr=e}finally{this._loadErr||(this.disabled?this._status=vn.UNLOADED:this._status=vn.LOADED)}}}async reload(){this.pending||(this._ctx.emit("beforereload",this),await this.unload(),await this.load({reload:!0}),this._ctx.emit("reloaded",this))}async unload(e=!1){if(!this.pending){if(e)return await this.unload(),void(this.isInstalledInDotRoot&&this._ctx.emit("unlink-plugin",this.id));try{this._status=vn.UNLOADING;const t={unregister:e};try{await(this._caller?.callUserModel((un,`${sn}#lspmsg#beforeunload#`),t)),this.emit("beforeunload",t)}catch(e){console.error("[beforeunload Error]",e)}await this.dispose(),this.emit("unloaded")}catch(e){return gn("[plugin unload Error]",e),!1}finally{this._status=vn.UNLOADED}}}async dispose(){for(const e of this._disposes)try{e&&await e()}catch(e){console.error(this.debugTag,"dispose Error",e)}this._disposes=[]}_dispose(e){e&&this._disposes.push(e)}_onHostMounted(e){const t=this._ctx.hostMountedActor;!t||t.settled?e():t?.promise.then(e)}get layoutCore(){return window.frontend.modules.layout.core}get isInstalledInDotRoot(){const e=this.dotConfigRoot,t=this.localRoot;return e&&t&&t.startsWith(e)}get loaded(){return this._status===vn.LOADED}get pending(){return[vn.LOADING,vn.UNLOADING].includes(this._status)}get status(){return this._status}get settings(){return this.options.settings}set settingsSchema(e){this.options.settingsSchema=e}get settingsSchema(){return this.options.settingsSchema}get logger(){return this.options.logger}get disabled(){return this.settings?.get("disabled")}get caller(){return this._caller}get id(){return this._id}get shadow(){return"shadow"===this.options.mode}get options(){return this._options}get themeMgr(){return this._themeMgr}get debugTag(){const e=this._options?.name;return`#${this._id} ${e??""}`}get localRoot(){return this._localRoot||this._options.url}get loadErr(){return this._loadErr}get dotConfigRoot(){return ct.normalize(this._ctx.options.dotConfigRoot)}get dotSettingsFile(){return this._dotSettingsFile}get dotPluginsRoot(){return ct.join(this.dotConfigRoot,mn)}toJSON(){const e={...this.options};return e.id=this.id,e.err=this.loadErr,e.usf=this.dotSettingsFile,e.iir=this.isInstalledInDotRoot,e.lsr=this._resolveResourceFullUrl(""),e}}class Cn extends(i()){_options;_isRegistering=!1;_readyIndicator;_hostMountedActor=Ot();_userPreferences={};_registeredThemes=new Map;_registeredPlugins=new Map;_currentTheme;constructor(e){super(),this._options=e}async loadUserPreferences(){try{const e=await At("load_user_preferences");e&&Object.assign(this._userPreferences,e)}catch(e){gn("[load user preferences Error]",e)}}async saveUserPreferences(e){try{e&&Object.assign(this._userPreferences,e),await At("save_user_preferences",this._userPreferences)}catch(e){gn("[save user preferences Error]",e)}}async activateUserPreferences(){const{theme:e}=this._userPreferences;e&&await this.selectTheme(e,!1)}async register(e,t=!1){if(!Array.isArray(e))return void await this.register([e]);const n=new Map,r=()=>{const e=Array.from(n.values()).reduce(((e,t)=>{const{options:n,status:r,disabled:i}=t.o;return e[t.o.id]={name:n.name,entry:n.entry,status:r,enabled:"boolean"==typeof i?i?"⚫️":"🟢":"🔴",perf:t.e?`${(t.e-t.s).toFixed(2)}ms`:t.o.loadErr},e}),{});console.table(e)};window.__debugPluginsPerfInfo=r;try{this._isRegistering=!0,this._options.dotConfigRoot;const i=this._readyIndicator=Ot();await this.loadUserPreferences();const o=new Set(this._userPreferences.externals||[]);t&&(e=e.concat([...o].filter((t=>!e.length||e.every((e=>!e.entry&&e.url!==t)))).map((e=>({url:e})))));for(const t of e){const{url:e}=t,r=new Sn(t,this,this),s={o:r,s:performance.now(),e:0};n.set(r.id,s),await r.load({indicator:i});const{loadErr:a}=r;a&&(gn("[Failed LOAD Plugin] #",t),this.emit("error",a),a instanceof wn||a instanceof xn)||(s.e=performance.now(),r.settings?.on("change",(e=>{this.emit("settings-changed",r.id,e),r.caller?.callUserModel(cn,{payload:e})})),this._registeredPlugins.set(r.id,r),this.emit("registered",r),r.isInstalledInDotRoot||o.add(e))}await this.saveUserPreferences({externals:Array.from(o)}),await this.activateUserPreferences(),i.resolve("ready")}catch(e){console.error(e)}finally{this._isRegistering=!1,r()}}async reload(e){if(Array.isArray(e))for(const t of e)try{const e=this.ensurePlugin(t);await e.reload()}catch(e){gn(e)}else await this.reload([e])}async unregister(e){if(!Array.isArray(e))return void await this.unregister([e]);const t=[];for(const n of e){const e=this.ensurePlugin(n);e.isInstalledInDotRoot||t.push(e.options.url),await e.unload(!0),this._registeredPlugins.delete(n),this.emit("unregistered",n)}let n=this._userPreferences.externals||[];n.length&&t.length&&await this.saveUserPreferences({externals:n.filter((e=>!t.includes(e)))})}async enable(e){const t=this.ensurePlugin(e);t.pending||(this.emit("beforeenable"),t.settings?.set("disabled",!1),this.emit("enabled",t.id))}async disable(e){const t=this.ensurePlugin(e);t.pending||(this.emit("beforedisable"),t.settings?.set("disabled",!0),this.emit("disabled",t.id))}async _hook(e,t,n,r){for(const[i,o]of this._registeredPlugins)r&&r!==o.id||o.caller?.callUserModel(an,{ns:e,type:u(t),payload:n})}hookApp(e,t,n){this._hook("hook:app",e,t,n)}hookEditor(e,t,n){this._hook("hook:editor",e,t,n)}_execDirective(e,...t){}ensurePlugin(e){if(e instanceof Sn)return e;const t=this._registeredPlugins.get(e);if(!t)throw new Error(`plugin #${e} not existed.`);return t}hostMounted(){this._hostMountedActor.resolve()}get registeredPlugins(){return this._registeredPlugins}get options(){return this._options}get readyIndicator(){return this._readyIndicator}get hostMountedActor(){return this._hostMountedActor}get isRegistering(){return this._isRegistering}get themes(){return this._registeredThemes}async registerTheme(e,t){if(gn("registered Theme #",e,t),!e)return;let n=this._registeredThemes.get(e);n||this._registeredThemes.set(e,n=[]),n.push(t),this.emit("theme-changed",this.themes,{id:e,...t})}async selectTheme(e,t=!0){this._currentTheme&&this._currentTheme.dis?.();const n=It(e?.url);this.emit("theme-selected",e),t&&await this.saveUserPreferences({theme:e?.url?e:null}),e?.url&&(this._currentTheme={dis:()=>{n(),t&&this.saveUserPreferences({theme:null})},opt:e,pid:e.pid})}async unregisterTheme(e,t=!0){gn("unregistered Theme #",e),this._registeredThemes.has(e)&&(this._registeredThemes.delete(e),this.emit("theme-changed",this.themes,{id:e}),t&&this._currentTheme?.pid==e&&(this._currentTheme.dis?.(),this._currentTheme=null,this.emit("theme-selected",null)))}}function On(e){const t=new Cn(e);gn("=== 🔗 Setup Logseq Plugin System 🔗 ==="),window.LSPluginCore=t}})(),r})()})); |