wiki/static/js/lsplugin.core.js

2 lines
95 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*! 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,(()=>(()=>{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";function e(t){return(e="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})(t)}function t(e,n){return(t=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,n)}function n(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function r(e,i,o){return(r=n()?Reflect.construct:function(e,n,r){var i=[null];i.push.apply(i,n);var o=new(Function.bind.apply(e,i));return r&&t(o,r.prototype),o}).apply(null,arguments)}function i(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=Object.hasOwnProperty,a=Object.setPrototypeOf,c=Object.isFrozen,l=Object.getPrototypeOf,u=Object.getOwnPropertyDescriptor,d=Object.freeze,h=Object.seal,p=Object.create,f="undefined"!=typeof Reflect&&Reflect,g=f.apply,m=f.construct;g||(g=function(e,t,n){return e.apply(t,n)}),d||(d=function(e){return e}),h||(h=function(e){return e}),m||(m=function(e,t){return r(e,i(t))});var y,_=k(Array.prototype.forEach),b=k(Array.prototype.pop),v=k(Array.prototype.push),w=k(String.prototype.toLowerCase),x=k(String.prototype.match),C=k(String.prototype.replace),S=k(String.prototype.indexOf),E=k(String.prototype.trim),O=k(RegExp.prototype.test),A=(y=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return m(y,t)});function k(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return g(e,t,r)}}function T(e,t){a&&a(e,null);for(var n=t.length;n--;){var r=t[n];if("string"==typeof r){var i=w(r);i!==r&&(c(t)||(t[n]=i),r=i)}e[r]=!0}return e}function j(e){var t,n=p(null);for(t in e)g(s,e,[t])&&(n[t]=e[t]);return n}function I(e,t){for(;null!==e;){var n=u(e,t);if(n){if(n.get)return k(n.get);if("function"==typeof n.value)return k(n.value)}e=l(e)}return function(e){return console.warn("fallback value for",e),null}}var L=d(["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"]),N=d(["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"]),M=d(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),R=d(["animate","color-profile","cursor","discard","fedropshadow","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"]),F=d(["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"]),P=d(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),D=d(["#text"]),U=d(["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","nonce","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"]),$=d(["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","transform-origin","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"]),z=d(["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"]),H=d(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),q=h(/\{\{[\w\W]*|[\w\W]*\}\}/gm),B=h(/<%[\w\W]*|[\w\W]*%>/gm),W=h(/^data-[\-\w.\u00B7-\uFFFF]/),G=h(/^aria-[\-\w]+$/),J=h(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Z=h(/^(?:\w+script|data):/i),K=h(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),V=h(/^html$/i),Y=function(){return"undefined"==typeof window?null:window},X=function(t,n){if("object"!==e(t)||"function"!=typeof t.createPolicy)return null;var r=null,i="data-tt-policy-suffix";n.currentScript&&n.currentScript.hasAttribute(i)&&(r=n.currentScript.getAttribute(i));var o="dompurify"+(r?"#"+r:"");try{return t.createPolicy(o,{createHTML:function(e){return e}})}catch(e){return console.warn("TrustedTypes policy "+o+" could not be created."),null}};return function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Y(),r=function(e){return t(e)};if(r.version="2.3.8",r.removed=[],!n||!n.document||9!==n.document.nodeType)return r.isSupported=!1,r;var o=n.document,s=n.document,a=n.DocumentFragment,c=n.HTMLTemplateElement,l=n.Node,u=n.Element,h=n.NodeFilter,p=n.NamedNodeMap,f=void 0===p?n.NamedNodeMap||n.MozNamedAttrMap:p,g=n.HTMLFormElement,m=n.DOMParser,y=n.trustedTypes,k=u.prototype,Q=I(k,"cloneNode"),ee=I(k,"nextSibling"),te=I(k,"childNodes"),ne=I(k,"parentNode");if("function"==typeof c){var re=s.createElement("template");re.content&&re.content.ownerDocument&&(s=re.content.ownerDocument)}var ie=X(y,o),oe=ie?ie.createHTML(""):"",se=s,ae=se.implementation,ce=se.createNodeIterator,le=se.createDocumentFragment,ue=se.getElementsByTagName,de=o.importNode,he={};try{he=j(s).documentMode?s.documentMode:{}}catch(e){}var pe={};r.isSupported="function"==typeof ne&&ae&&void 0!==ae.createHTMLDocument&&9!==he;var fe,ge,me=q,ye=B,_e=W,be=G,ve=Z,we=K,xe=J,Ce=null,Se=T({},[].concat(i(L),i(N),i(M),i(F),i(D))),Ee=null,Oe=T({},[].concat(i(U),i($),i(z),i(H))),Ae=Object.seal(Object.create(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),ke=null,Te=null,je=!0,Ie=!0,Le=!1,Ne=!1,Me=!1,Re=!1,Fe=!1,Pe=!1,De=!1,Ue=!1,$e=!0,ze=!0,He=!1,qe={},Be=null,We=T({},["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"]),Ge=null,Je=T({},["audio","video","img","source","image","track"]),Ze=null,Ke=T({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ve="http://www.w3.org/1998/Math/MathML",Ye="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml",Qe=Xe,et=!1,tt=["application/xhtml+xml","text/html"],nt="text/html",rt=null,it=s.createElement("form"),ot=function(e){return e instanceof RegExp||e instanceof Function},st=function(t){rt&&rt===t||(t&&"object"===e(t)||(t={}),t=j(t),Ce="ALLOWED_TAGS"in t?T({},t.ALLOWED_TAGS):Se,Ee="ALLOWED_ATTR"in t?T({},t.ALLOWED_ATTR):Oe,Ze="ADD_URI_SAFE_ATTR"in t?T(j(Ke),t.ADD_URI_SAFE_ATTR):Ke,Ge="ADD_DATA_URI_TAGS"in t?T(j(Je),t.ADD_DATA_URI_TAGS):Je,Be="FORBID_CONTENTS"in t?T({},t.FORBID_CONTENTS):We,ke="FORBID_TAGS"in t?T({},t.FORBID_TAGS):{},Te="FORBID_ATTR"in t?T({},t.FORBID_ATTR):{},qe="USE_PROFILES"in t&&t.USE_PROFILES,je=!1!==t.ALLOW_ARIA_ATTR,Ie=!1!==t.ALLOW_DATA_ATTR,Le=t.ALLOW_UNKNOWN_PROTOCOLS||!1,Ne=t.SAFE_FOR_TEMPLATES||!1,Me=t.WHOLE_DOCUMENT||!1,Pe=t.RETURN_DOM||!1,De=t.RETURN_DOM_FRAGMENT||!1,Ue=t.RETURN_TRUSTED_TYPE||!1,Fe=t.FORCE_BODY||!1,$e=!1!==t.SANITIZE_DOM,ze=!1!==t.KEEP_CONTENT,He=t.IN_PLACE||!1,xe=t.ALLOWED_URI_REGEXP||xe,Qe=t.NAMESPACE||Xe,t.CUSTOM_ELEMENT_HANDLING&&ot(t.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ae.tagNameCheck=t.CUSTOM_ELEMENT_HANDLING.tagNameCheck),t.CUSTOM_ELEMENT_HANDLING&&ot(t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ae.attributeNameCheck=t.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),t.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ae.allowCustomizedBuiltInElements=t.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),fe=fe=-1===tt.indexOf(t.PARSER_MEDIA_TYPE)?nt:t.PARSER_MEDIA_TYPE,ge="application/xhtml+xml"===fe?function(e){return e}:w,Ne&&(Ie=!1),De&&(Pe=!0),qe&&(Ce=T({},i(D)),Ee=[],!0===qe.html&&(T(Ce,L),T(Ee,U)),!0===qe.svg&&(T(Ce,N),T(Ee,$),T(Ee,H)),!0===qe.svgFilters&&(T(Ce,M),T(Ee,$),T(Ee,H)),!0===qe.mathMl&&(T(Ce,F),T(Ee,z),T(Ee,H))),t.ADD_TAGS&&(Ce===Se&&(Ce=j(Ce)),T(Ce,t.ADD_TAGS)),t.ADD_ATTR&&(Ee===Oe&&(Ee=j(Ee)),T(Ee,t.ADD_ATTR)),t.ADD_URI_SAFE_ATTR&&T(Ze,t.ADD_URI_SAFE_ATTR),t.FORBID_CONTENTS&&(Be===We&&(Be=j(Be)),T(Be,t.FORBID_CONTENTS)),ze&&(Ce["#text"]=!0),Me&&T(Ce,["html","head","body"]),Ce.table&&(T(Ce,["tbody"]),delete ke.tbody),d&&d(t),rt=t)},at=T({},["mi","mo","mn","ms","mtext"]),ct=T({},["foreignobject","desc","title","annotation-xml"]),lt=T({},["title","style","font","a","script"]),ut=T({},N);T(ut,M),T(ut,R);var dt=T({},F);T(dt,P);var ht=function(e){var t=ne(e);t&&t.tagName||(t={namespaceURI:Xe,tagName:"template"});var n=w(e.tagName),r=w(t.tagName);return e.namespaceURI===Ye?t.namespaceURI===Xe?"svg"===n:t.namespaceURI===Ve?"svg"===n&&("annotation-xml"===r||at[r]):Boolean(ut[n]):e.namespaceURI===Ve?t.namespaceURI===Xe?"math"===n:t.namespaceURI===Ye?"math"===n&&ct[r]:Boolean(dt[n]):e.namespaceURI===Xe&&!(t.namespaceURI===Ye&&!ct[r])&&!(t.namespaceURI===Ve&&!at[r])&&!dt[n]&&(lt[n]||!ut[n])},pt=function(e){v(r.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){try{e.outerHTML=oe}catch(t){e.remove()}}},ft=function(e,t){try{v(r.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){v(r.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Ee[e])if(Pe||De)try{pt(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},gt=function(e){var t,n;if(Fe)e="<remove></remove>"+e;else{var r=x(e,/^[\r\n\t ]+/);n=r&&r[0]}"application/xhtml+xml"===fe&&(e='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+e+"</body></html>");var i=ie?ie.createHTML(e):e;if(Qe===Xe)try{t=(new m).parseFromString(i,fe)}catch(e){}if(!t||!t.documentElement){t=ae.createDocument(Qe,"template",null);try{t.documentElement.innerHTML=et?"":i}catch(e){}}var o=t.body||t.documentElement;return e&&n&&o.insertBefore(s.createTextNode(n),o.childNodes[0]||null),Qe===Xe?ue.call(t,Me?"html":"body")[0]:Me?t.documentElement:o},mt=function(e){return ce.call(e.ownerDocument||e,e,h.SHOW_ELEMENT|h.SHOW_COMMENT|h.SHOW_TEXT,null,!1)},yt=function(e){return e instanceof g&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof f)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore)},_t=function(t){return"object"===e(l)?t instanceof l:t&&"object"===e(t)&&"number"==typeof t.nodeType&&"string"==typeof t.nodeName},bt=function(e,t,n){pe[e]&&_(pe[e],(function(e){e.call(r,t,n,rt)}))},vt=function(e){var t;if(bt("beforeSanitizeElements",e,null),yt(e))return pt(e),!0;if(O(/[\u0080-\uFFFF]/,e.nodeName))return pt(e),!0;var n=ge(e.nodeName);if(bt("uponSanitizeElement",e,{tagName:n,allowedTags:Ce}),e.hasChildNodes()&&!_t(e.firstElementChild)&&(!_t(e.content)||!_t(e.content.firstElementChild))&&O(/<[/\w]/g,e.innerHTML)&&O(/<[/\w]/g,e.textContent))return pt(e),!0;if("select"===n&&O(/<template/i,e.innerHTML))return pt(e),!0;if(!Ce[n]||ke[n]){if(!ke[n]&&xt(n)){if(Ae.tagNameCheck instanceof RegExp&&O(Ae.tagNameCheck,n))return!1;if(Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))return!1}if(ze&&!Be[n]){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 pt(e),!0}return e instanceof u&&!ht(e)?(pt(e),!0):"noscript"!==n&&"noembed"!==n||!O(/<\/no(script|embed)/i,e.innerHTML)?(Ne&&3===e.nodeType&&(t=e.textContent,t=C(t,me," "),t=C(t,ye," "),e.textContent!==t&&(v(r.removed,{element:e.cloneNode()}),e.textContent=t)),bt("afterSanitizeElements",e,null),!1):(pt(e),!0)},wt=function(e,t,n){if($e&&("id"===t||"name"===t)&&(n in s||n in it))return!1;if(Ie&&!Te[t]&&O(_e,t));else if(je&&O(be,t));else if(!Ee[t]||Te[t]){if(!(xt(e)&&(Ae.tagNameCheck instanceof RegExp&&O(Ae.tagNameCheck,e)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(e))&&(Ae.attributeNameCheck instanceof RegExp&&O(Ae.attributeNameCheck,t)||Ae.attributeNameCheck instanceof Function&&Ae.attributeNameCheck(t))||"is"===t&&Ae.allowCustomizedBuiltInElements&&(Ae.tagNameCheck instanceof RegExp&&O(Ae.tagNameCheck,n)||Ae.tagNameCheck instanceof Function&&Ae.tagNameCheck(n))))return!1}else if(Ze[t]);else if(O(xe,C(n,we,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==S(n,"data:")||!Ge[e])if(Le&&!O(ve,C(n,we,"")));else if(n)return!1;return!0},xt=function(e){return e.indexOf("-")>0},Ct=function(e){var t,n,i,o;bt("beforeSanitizeAttributes",e,null);var s=e.attributes;if(s){var a={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Ee};for(o=s.length;o--;){var c=t=s[o],l=c.name,u=c.namespaceURI;if(n="value"===l?t.value:E(t.value),i=ge(l),a.attrName=i,a.attrValue=n,a.keepAttr=!0,a.forceKeepAttr=void 0,bt("uponSanitizeAttribute",e,a),n=a.attrValue,!a.forceKeepAttr&&(ft(l,e),a.keepAttr))if(O(/\/>/i,n))ft(l,e);else{Ne&&(n=C(n,me," "),n=C(n,ye," "));var d=ge(e.nodeName);if(wt(d,i,n))try{u?e.setAttributeNS(u,l,n):e.setAttribute(l,n),b(r.removed)}catch(e){}}}bt("afterSanitizeAttributes",e,null)}},St=function e(t){var n,r=mt(t);for(bt("beforeSanitizeShadowDOM",t,null);n=r.nextNode();)bt("uponSanitizeShadowNode",n,null),vt(n)||(n.content instanceof a&&e(n.content),Ct(n));bt("afterSanitizeShadowDOM",t,null)};return r.sanitize=function(t,i){var s,c,u,d,h;if((et=!t)&&(t="\x3c!--\x3e"),"string"!=typeof t&&!_t(t)){if("function"!=typeof t.toString)throw A("toString is not a function");if("string"!=typeof(t=t.toString()))throw A("dirty is not a string, aborting")}if(!r.isSupported){if("object"===e(n.toStaticHTML)||"function"==typeof n.toStaticHTML){if("string"==typeof t)return n.toStaticHTML(t);if(_t(t))return n.toStaticHTML(t.outerHTML)}return t}if(Re||st(i),r.removed=[],"string"==typeof t&&(He=!1),He){if(t.nodeName){var p=ge(t.nodeName);if(!Ce[p]||ke[p])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(t instanceof l)1===(c=(s=gt("\x3c!----\x3e")).ownerDocument.importNode(t,!0)).nodeType&&"BODY"===c.nodeName||"HTML"===c.nodeName?s=c:s.appendChild(c);else{if(!Pe&&!Ne&&!Me&&-1===t.indexOf("<"))return ie&&Ue?ie.createHTML(t):t;if(!(s=gt(t)))return Pe?null:Ue?oe:""}s&&Fe&&pt(s.firstChild);for(var f=mt(He?t:s);u=f.nextNode();)3===u.nodeType&&u===d||vt(u)||(u.content instanceof a&&St(u.content),Ct(u),d=u);if(d=null,He)return t;if(Pe){if(De)for(h=le.call(s.ownerDocument);s.firstChild;)h.appendChild(s.firstChild);else h=s;return Ee.shadowroot&&(h=de.call(o,h,!0)),h}var g=Me?s.outerHTML:s.innerHTML;return Me&&Ce["!doctype"]&&s.ownerDocument&&s.ownerDocument.doctype&&s.ownerDocument.doctype.name&&O(V,s.ownerDocument.doctype.name)&&(g="<!DOCTYPE "+s.ownerDocument.doctype.name+">\n"+g),Ne&&(g=C(g,me," "),g=C(g,ye," ")),ie&&Ue?ie.createHTML(g):g},r.setConfig=function(e){st(e),Re=!0},r.clearConfig=function(){rt=null,Re=!1},r.isValidAttribute=function(e,t,n){rt||st({});var r=ge(e),i=ge(t);return wt(r,i,n)},r.addHook=function(e,t){"function"==typeof t&&(pe[e]=pe[e]||[],v(pe[e],t))},r.removeHook=function(e){if(pe[e])return b(pe[e])},r.removeHooks=function(e){pe[e]&&(pe[e]=[])},r.removeAllHooks=function(){pe={}},r}()}()},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),c=n?n+t:t;return e._events[c]?e._events[c].fn?e._events[c]=[e._events[c],a]:e._events[c].push(a):(e._events[c]=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 c,l,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(l=1,c=new Array(d-1);l<d;l++)c[l-1]=arguments[l];u.fn.apply(u.context,c)}else{var h,p=u.length;for(l=0;l<p;l++)switch(u[l].once&&this.removeListener(e,u[l].fn,void 0,!0),d){case 1:u[l].fn.call(u[l].context);break;case 2:u[l].fn.call(u[l].context,t);break;case 3:u[l].fn.call(u[l].context,t,r);break;case 4:u[l].fn.call(u[l].context,t,r,i);break;default:if(!c)for(h=1,c=new Array(d-1);h<d;h++)c[h-1]=arguments[h];u[l].fn.apply(u[l].context,c)}}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 c=0,l=[],u=a.length;c<u;c++)(a[c].fn!==t||i&&!a[c].once||r&&a[c].context!==r)&&l.push(a[c]);l.length?this._events[o]=1===l.length?l[0]:l: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,c,l=typeof e;if("string"===l&&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"===l&&isFinite(e))return s.long?(a=e,(c=Math.abs(a))>=i?o(a,c,i,"day"):c>=r?o(a,c,r,"hour"):c>=n?o(a,c,n,"minute"):c>=t?o(a,c,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 c=/^([a-zA-Z]:|[\\\/]{2}[^\\\/]+[\\\/]+[^\\\/]+)?([\\\/])?([\s\S]*?)$/,l=/^([\s\S]*?)((?:\.{1,2}|[^\\\/]+?|)(\.[^.\/\\]*|))(?:[\\\/]*)$/,u={};function d(e){var t=c.exec(e),n=(t[1]||"")+(t[2]||""),r=t[3]||"",i=l.exec(r);return[n,i[1],i[2],i[3]]}function h(e){var t=c.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 c=h(a),l=c.device,u=c.isUnc,d=c.isAbsolute,f=c.tail;if((!l||!e||l.toLowerCase()===e.toLowerCase())&&(e||(e=l),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("\\")),c=Math.min(o.length,s.length),l=c,d=0;d<c;d++)if(o[d]!==s[d]){l=d;break}if(0==l)return t;var h=[];for(d=l;d<o.length;d++)h.push("..");return(h=h.concat(i.slice(l))).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 c=[];for(s=o;s<n.length;s++)c.push("..");return(c=c.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,c=[],l=!1,u=-1;function d(){l&&a&&(l=!1,a.length?c=a.concat(c):u=-1,c.length&&h())}function h(){if(!l){var e=s(d);l=!0;for(var t=c.length;t;){for(a=c,c=[];++u<t;)a&&a[u].run();u=-1,t=c.length}a=null,l=!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];c.push(new p(e,t)),1!==c.length||l||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}})),c=r[n];n<o;c=r[++n])g(c)||!v(c)?s+=" "+c:s+=" "+a(c);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:l};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=c),u(r,e,r.depth)}function c(e,t){var n=a.styles[t];return n?"["+a.colors[n][0]+"m"+e+"["+a.colors[n][1]+"m":e}function l(e,t){return e}function u(e,n,r){if(e.customInspect&&n&&C(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(C(n)){var c=n.name?": "+n.name:"";return e.stylize("[Function"+c+"]","special")}if(b(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 l,v="",S=!1,E=["{","}"];return p(n)&&(S=!0,E=["[","]"]),C(n)&&(v=" [Function"+(n.name?": "+n.name:"")+"]"),b(n)&&(v=" "+RegExp.prototype.toString.call(n)),w(n)&&(v=" "+Date.prototype.toUTCString.call(n)),x(n)&&(v=" "+d(n)),0!==s.length||S&&0!=n.length?r<0?b(n)?e.stylize(RegExp.prototype.toString.call(n),"regexp"):e.stylize("[Object]","special"):(e.seen.push(n),l=S?function(e,t,n,r,i){for(var o=[],s=0,a=t.length;s<a;++s)k(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,S)})),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]}(l,v,E)):E[0]+v+E[1]}function d(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,n,r,i,o){var s,a,c;if((c=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?a=c.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):c.set&&(a=e.stylize("[Setter]","special")),k(r,i)||(s="["+i+"]"),a||(e.seen.indexOf(c.value)<0?(a=g(n)?u(e,c.value,null):u(e,c.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 b(e){return v(e)&&"[object RegExp]"===S(e)}function v(e){return"object"==typeof e&&null!==e}function w(e){return v(e)&&"[object Date]"===S(e)}function x(e){return v(e)&&("[object Error]"===S(e)||e instanceof Error)}function C(e){return"function"==typeof e}function S(e){return Object.prototype.toString.call(e)}function E(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=b,t.isObject=v,t.isDate=w,t.isError=x,t.isFunction=C,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 O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function A(){var e=new Date,t=[E(e.getHours()),E(e.getMinutes()),E(e.getSeconds())].join(":");return[e.getDate(),O[e.getMonth()],t].join(" ")}function k(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",A(),t.format.apply(t,arguments))},t.inherits=n(717),t._extend=function(e,t){if(!t||!v(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:()=>Mn,pluginHelpers:()=>t,setupPluginCore:()=>Fn});var e={};n.r(e),n.d(e,{setSDKMetadata:()=>ut});var t={};n.r(t),n.d(t,{IS_DEV:()=>ht,PROTOCOL_FILE:()=>pt,PROTOCOL_LSP:()=>ft,URL_LSP:()=>gt,cleanInjectedScripts:()=>Mt,cleanInjectedUI:()=>Nt,deepMerge:()=>wt,deferred:()=>At,genID:()=>xt,getAppPathRoot:()=>_t,getSDKPathRoot:()=>bt,injectTheme:()=>Ft,invokeHostExportedApi:()=>kt,isObject:()=>vt,mergeSettingsWithSchema:()=>Pt,path:()=>dt,safeSnakeCase:()=>yt,safetyPathJoin:()=>Et,safetyPathNormalize:()=>Ot,setupIframeSandbox:()=>Tt,setupInjectedStyle:()=>jt,setupInjectedUI:()=>Lt,transformableEvent:()=>Rt,ucFirst:()=>Ct,withFileProtocol:()=>St});var i=n(729),o=n.n(i),s=n(520),a=n(856),c=n.n(a);const l=function(e,t){return e===t||e!=e&&t!=t},u=function(e,t){for(var n=e.length;n--;)if(l(e[n][0],t))return n;return-1};var d=Array.prototype.splice;function h(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])}}h.prototype.clear=function(){this.__data__=[],this.size=0},h.prototype.delete=function(e){var t=this.__data__,n=u(t,e);return!(n<0||(n==t.length-1?t.pop():d.call(t,n,1),--this.size,0))},h.prototype.get=function(e){var t=this.__data__,n=u(t,e);return n<0?void 0:t[n][1]},h.prototype.has=function(e){return u(this.__data__,e)>-1},h.prototype.set=function(e,t){var n=this.__data__,r=u(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};const p=h,f="object"==typeof global&&global&&global.Object===Object&&global;var g="object"==typeof self&&self&&self.Object===Object&&self;const m=f||g||Function("return this")(),y=m.Symbol;var _=Object.prototype,b=_.hasOwnProperty,v=_.toString,w=y?y.toStringTag:void 0;var x=Object.prototype.toString;var C=y?y.toStringTag:void 0;const S=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":C&&C in Object(e)?function(e){var t=b.call(e,w),n=e[w];try{e[w]=void 0;var r=!0}catch(e){}var i=v.call(e);return r&&(t?e[w]=n:delete e[w]),i}(e):function(e){return x.call(e)}(e)},E=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},O=function(e){if(!E(e))return!1;var t=S(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},A=m["__core-js_shared__"];var k,T=(k=/[^.]+$/.exec(A&&A.keys&&A.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"";var j=Function.prototype.toString;var I=/^\[object .+?Constructor\]$/,L=Function.prototype,N=Object.prototype,M=L.toString,R=N.hasOwnProperty,F=RegExp("^"+M.call(R).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");const P=function(e){return!(!E(e)||(t=e,T&&T in t))&&(O(e)?F:I).test(function(e){if(null!=e){try{return j.call(e)}catch(e){}try{return e+""}catch(e){}}return""}(e));var t},D=function(e,t){var n=function(e,t){return null==e?void 0:e[t]}(e,t);return P(n)?n:void 0},U=D(m,"Map"),$=D(Object,"create");var z=Object.prototype.hasOwnProperty;var H=Object.prototype.hasOwnProperty;function q(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])}}q.prototype.clear=function(){this.__data__=$?$(null):{},this.size=0},q.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},q.prototype.get=function(e){var t=this.__data__;if($){var n=t[e];return"__lodash_hash_undefined__"===n?void 0:n}return z.call(t,e)?t[e]:void 0},q.prototype.has=function(e){var t=this.__data__;return $?void 0!==t[e]:H.call(t,e)},q.prototype.set=function(e,t){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=$&&void 0===t?"__lodash_hash_undefined__":t,this};const B=q,W=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 G(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])}}G.prototype.clear=function(){this.size=0,this.__data__={hash:new B,map:new(U||p),string:new B}},G.prototype.delete=function(e){var t=W(this,e).delete(e);return this.size-=t?1:0,t},G.prototype.get=function(e){return W(this,e).get(e)},G.prototype.has=function(e){return W(this,e).has(e)},G.prototype.set=function(e,t){var n=W(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};const J=G;function Z(e){var t=this.__data__=new p(e);this.size=t.size}Z.prototype.clear=function(){this.__data__=new p,this.size=0},Z.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},Z.prototype.get=function(e){return this.__data__.get(e)},Z.prototype.has=function(e){return this.__data__.has(e)},Z.prototype.set=function(e,t){var n=this.__data__;if(n instanceof p){var r=n.__data__;if(!U||r.length<199)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new J(r)}return n.set(e,t),this.size=n.size,this};const K=Z,V=function(){try{var e=D(Object,"defineProperty");return e({},"",{}),e}catch(e){}}(),Y=function(e,t,n){"__proto__"==t&&V?V(e,t,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[t]=n},X=function(e,t,n){(void 0!==n&&!l(e[t],n)||void 0===n&&!(t in e))&&Y(e,t,n)},Q=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 ee="object"==typeof exports&&exports&&!exports.nodeType&&exports,te=ee&&"object"==typeof module&&module&&!module.nodeType&&module,ne=te&&te.exports===ee?m.Buffer:void 0,re=ne?ne.allocUnsafe:void 0;const ie=m.Uint8Array,oe=function(e,t){var n,r,i=t?(n=e.buffer,r=new n.constructor(n.byteLength),new ie(r).set(new ie(n)),r):e.buffer;return new e.constructor(i,e.byteOffset,e.length)};var se=Object.create;const ae=function(){function e(){}return function(t){if(!E(t))return{};if(se)return se(t);e.prototype=t;var n=new e;return e.prototype=void 0,n}}(),ce=(le=Object.getPrototypeOf,ue=Object,function(e){return le(ue(e))});var le,ue,de=Object.prototype;const he=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||de)},pe=function(e){return null!=e&&"object"==typeof e},fe=function(e){return pe(e)&&"[object Arguments]"==S(e)};var ge=Object.prototype,me=ge.hasOwnProperty,ye=ge.propertyIsEnumerable;const _e=fe(function(){return arguments}())?fe:function(e){return pe(e)&&me.call(e,"callee")&&!ye.call(e,"callee")},be=Array.isArray,ve=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},we=function(e){return null!=e&&ve(e.length)&&!O(e)};var xe="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ce=xe&&"object"==typeof module&&module&&!module.nodeType&&module,Se=Ce&&Ce.exports===xe?m.Buffer:void 0;const Ee=(Se?Se.isBuffer:void 0)||function(){return!1};var Oe=Function.prototype,Ae=Object.prototype,ke=Oe.toString,Te=Ae.hasOwnProperty,je=ke.call(Object);var Ie={};Ie["[object Float32Array]"]=Ie["[object Float64Array]"]=Ie["[object Int8Array]"]=Ie["[object Int16Array]"]=Ie["[object Int32Array]"]=Ie["[object Uint8Array]"]=Ie["[object Uint8ClampedArray]"]=Ie["[object Uint16Array]"]=Ie["[object Uint32Array]"]=!0,Ie["[object Arguments]"]=Ie["[object Array]"]=Ie["[object ArrayBuffer]"]=Ie["[object Boolean]"]=Ie["[object DataView]"]=Ie["[object Date]"]=Ie["[object Error]"]=Ie["[object Function]"]=Ie["[object Map]"]=Ie["[object Number]"]=Ie["[object Object]"]=Ie["[object RegExp]"]=Ie["[object Set]"]=Ie["[object String]"]=Ie["[object WeakMap]"]=!1;var Le="object"==typeof exports&&exports&&!exports.nodeType&&exports,Ne=Le&&"object"==typeof module&&module&&!module.nodeType&&module,Me=Ne&&Ne.exports===Le&&f.process,Re=function(){try{return Ne&&Ne.require&&Ne.require("util").types||Me&&Me.binding&&Me.binding("util")}catch(e){}}(),Fe=Re&&Re.isTypedArray;const Pe=Fe?function(e){return function(t){return e(t)}}(Fe):function(e){return pe(e)&&ve(e.length)&&!!Ie[S(e)]},De=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]};var Ue=Object.prototype.hasOwnProperty;const $e=function(e,t,n){var r=e[t];Ue.call(e,t)&&l(r,n)&&(void 0!==n||t in e)||Y(e,t,n)};var ze=/^(?:0|[1-9]\d*)$/;const He=function(e,t){var n=typeof e;return!!(t=null==t?9007199254740991:t)&&("number"==n||"symbol"!=n&&ze.test(e))&&e>-1&&e%1==0&&e<t};var qe=Object.prototype.hasOwnProperty;const Be=function(e,t){var n=be(e),r=!n&&_e(e),i=!n&&!r&&Ee(e),o=!n&&!r&&!i&&Pe(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):[],c=a.length;for(var l in e)!t&&!qe.call(e,l)||s&&("length"==l||i&&("offset"==l||"parent"==l)||o&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||He(l,c))||a.push(l);return a};var We=Object.prototype.hasOwnProperty;const Ge=function(e){if(!E(e))return function(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t}(e);var t=he(e),n=[];for(var r in e)("constructor"!=r||!t&&We.call(e,r))&&n.push(r);return n},Je=function(e){return we(e)?Be(e,!0):Ge(e)},Ze=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],c=r?r(n[a],e[a],a,n,e):void 0;void 0===c&&(c=e[a]),i?Y(n,a,c):$e(n,a,c)}return n}(e,Je(e))},Ke=function(e,t,n,r,i,o,s){var a,c=De(e,n),l=De(t,n),u=s.get(l);if(u)X(e,n,u);else{var d=o?o(c,l,n+"",e,t,s):void 0,h=void 0===d;if(h){var p=be(l),f=!p&&Ee(l),g=!p&&!f&&Pe(l);d=l,p||f||g?be(c)?d=c:pe(a=c)&&we(a)?d=function(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t}(c):f?(h=!1,d=function(e,t){if(t)return e.slice();var n=e.length,r=re?re(n):new e.constructor(n);return e.copy(r),r}(l,!0)):g?(h=!1,d=oe(l,!0)):d=[]:function(e){if(!pe(e)||"[object Object]"!=S(e))return!1;var t=ce(e);if(null===t)return!0;var n=Te.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&ke.call(n)==je}(l)||_e(l)?(d=c,_e(c)?d=Ze(c):E(c)&&!O(c)||(d=function(e){return"function"!=typeof e.constructor||he(e)?{}:ae(ce(e))}(l))):h=!1}h&&(s.set(l,d),i(d,l,r,o,s),s.delete(l)),X(e,n,d)}},Ve=function e(t,n,r,i,o){t!==n&&Q(n,(function(s,a){if(o||(o=new K),E(s))Ke(t,n,a,r,e,i,o);else{var c=i?i(De(t,a),s,a+"",t,n,o):void 0;void 0===c&&(c=s),X(t,a,c)}}),Je)},Ye=function(e){return e},Xe=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 Qe=Math.max;const et=V?function(e,t){return V(e,"toString",{configurable:!0,enumerable:!1,value:(n=t,function(){return n}),writable:!0});var n}:Ye;var tt=Date.now;const nt=function(e){var t=0,n=0;return function(){var r=tt(),i=16-(r-n);if(n=r,i>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(et),rt=(it=function(e,t,n){Ve(e,t,n)},function(e,t){return nt(function(e,t,n){return t=Qe(void 0===t?e.length-1:t,0),function(){for(var r=arguments,i=-1,o=Qe(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),Xe(e,this,a)}}(e,t,Ye),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=it.length>3&&"function"==typeof i?(r--,i):void 0,o&&function(e,t,n){if(!E(n))return!1;var r=typeof t;return!!("number"==r?we(n)&&He(t,n.length):"string"==r&&t in n)&&l(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&&it(e,s,n)}return e})));var it,ot=function(){return(ot=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 st(e){return e.toLowerCase()}Object.create,Object.create;var at=[/([a-z0-9])([A-Z])/g,/([A-Z])([A-Z][a-z])/g],ct=/[^A-Z0-9]+/gi;function lt(e,t,n){return t instanceof RegExp?e.replace(t,n):t.reduce((function(e,t){return e.replace(t,n)}),e)}function ut(e){this?.sdk&&e&&(this.sdk=Object.assign({},this.sdk,e))}const dt="win32"===navigator.platform.toLowerCase()?s.win32:s.posix,ht=!1,pt="file://",ft="lsp://",gt=ft+"logseq.io/";let mt;const yt=function(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?at:n,i=t.stripRegexp,o=void 0===i?ct:i,s=t.transform,a=void 0===s?st:s,c=t.delimiter,l=void 0===c?" ":c,u=lt(lt(e,r,"$1\0$2"),o,"\0"),d=0,h=u.length;"\0"===u.charAt(d);)d++;for(;"\0"===u.charAt(h-1);)h--;return u.slice(d,h).split("\0").map(a).join(l)}(e,ot({delimiter:"."},t))}(e,ot({delimiter:"_"},t))};async function _t(){return mt||(mt=await kt("_callApplication","getAppPath"))}async function bt(){return ht?localStorage.getItem("LSP_DEV_SDK_ROOT")||"http://localhost:8080":Et(await _t(),"js")}function vt(e){return e===Object(e)&&!Array.isArray(e)}const wt=rt;function xt(){return"_"+Math.random().toString(36).substr(2,9)}function Ct(e){return e.charAt(0).toUpperCase()+e.slice(1)}function St(e){return e?(/^(http|file|lsp)/.test(e)||(e=pt+e),e):""}function Et(e,...t){try{const n=new URL(e);if(!n.origin)throw new Error(null);const r=dt.join(e.substr(n.origin.length),...t);return n.origin+r}catch(n){return dt.join(e,...t)}}function Ot(e){return e?.match(/^(http?|lsp|assets):/)||(e=dt.normalize(e)),e}function At(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 kt(t,...n){t=t?.startsWith("_call")?t:t?.replace(/^[_$]+/,"");const r=yt(t),i=Object.assign(window.logseq?.api||{},e),o=i[r]||window.apis[r]||i[t]||window.apis[t];if(!o)throw new Error(`Not existed method #${t}`);return"function"!=typeof o?o:o.apply(this,n)}function Tt(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 jt(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 It=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=`${s.id}--${e.key}`,l=a,u=i?document.body:r&&document.querySelector(r);if(!u)return void console.error(`${this.debugTag} can not resolve selector target ${r}`);if(!e.template)return void It.get(a)?.call(null);e.template=c().sanitize(e.template,{ADD_TAGS:["iframe"],ALLOW_UNKNOWN_PROTOCOLS:!0,ADD_ATTR:["allow","src","allowfullscreen","frameborder","scrolling","target"]});let d,h,p=document.querySelector(`#${a}`),f=i?p?.querySelector(".ls-ui-float-content"):p;if(!f)return p=document.createElement("div"),p.id=a,p.dataset.injectedUi=l||"",i?(f=document.createElement("div"),f.classList.add("ls-ui-float-content"),p.appendChild(f)):f=p,f.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{p.setAttribute(e,t)})),e.style&&Object.entries(e.style).forEach((([e,t])=>{p.style[e]=t})),i&&(p.setAttribute("draggable","true"),p.setAttribute("resizable","true"),e.close&&(p.dataset.close=e.close),p.classList.add("lsp-ui-float-container","visible"),s._setupResizableContainer(p,l),h=s._setupDraggableContainer(p,{key:l,close:()=>d(),title:t?.title})),o&&e.reset&&Array.from(u.querySelectorAll("[data-injected-ui]")).map((e=>e.id))?.forEach((e=>{It.get(e)?.call(null)})),u.appendChild(p),["click","focus","focusin","focusout","blur","dblclick","keyup","keypress","keydown","change","input"].forEach((e=>{p.addEventListener(e,(t=>{const n=t.target.closest(`[data-on-${e}]`);if(!n)return;const r=n.dataset[`on${Ct(e)}`];r&&s.caller?.callUserModel(r,Rt(n))}),!1)})),n?.({el:p,float:i}),d=()=>{h?.(),It.delete(a),u.removeChild(p)},It.set(a,d),d;{f.innerHTML=e.template,t&&Object.entries(t).forEach((([e,t])=>{p.setAttribute(e,t)}));let n=null!=p.dataset.dx;e.style&&Object.entries(e.style).forEach((([e,t])=>{n&&["left","top","bottom","right","width","height"].includes(e)||(p.style[e]=t)}))}}function Nt(e){if(!It.has(e))return;const t=It.get(e);try{t()}catch(t){console.warn("[CLEAN Injected UI] ",e,t)}}function Mt(){document.head.querySelectorAll(`script[data-ref=${this.id}]`)?.forEach((e=>e.remove()))}function Rt(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}function Ft(e){const t=document.createElement("link");return t.rel="stylesheet",t.href=e,document.head.appendChild(t),()=>{try{document.head.removeChild(t)}catch(e){console.error(e)}}}function Pt(e,t){const n=(t||[]).reduce(((e,t)=>("default"in t&&(e[t.key]=t.default),e)),{});return Object.assign(n,e)}window.__injectedUIEffects=It;var Dt=n(227),Ut=n.n(Dt);const $t="application/x-postmate-v1+json";let zt=0;const Ht={handshake:1,"handshake-reply":1,call:1,emit:1,reply:1,request:1},qt=(e,t)=>!("string"==typeof t&&e.origin!==t||!e.data||"object"==typeof e.data&&!("postmate"in e.data)||e.data.type!==$t||!Ht[e.data.postmate]);class Bt{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(!qt(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=++zt,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:$t,property:e,uid:n},this.childOrigin)}))}call(e,t){this.child.postMessage({postmate:"call",type:$t,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 Wt{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(!qt(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:$t,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:$t,value:{name:e,data:t}},this.parentOrigin)}}class Gt{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=>!!qt(e,t)&&("handshake-reply"===e.data.postmate?(clearInterval(n),this.parent.removeEventListener("message",s,!1),this.childOrigin=e.origin,i(new Bt(this))):o("Failed handshake"));this.parent.addEventListener("message",s,!1);const a=()=>{r++,this.child.postMessage({postmate:"handshake",type:$t,model:this.model},t),5===r&&clearInterval(n)};this.frame.addEventListener("load",(()=>{a(),n=setInterval(a,500)})),this.frame.src=e}))}}class Jt{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:$t},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 Wt(this))}return t("Handshake Reply Failed")}};this.child.addEventListener("message",n,!1)}))}}class Zt{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]})}}class Kt{ctx;constructor(e){this.ctx=e}get React(){return this.ensureHostScope().React}get ReactDOM(){return this.ensureHostScope().ReactDOM}get pluginLocal(){return this.ensureHostScope().LSPluginCore.ensurePlugin(this.ctx.baseInfo.id)}invokeExperMethod(e,...t){const n=this.ensureHostScope();return e=yt(e)?.toLowerCase(),n.logseq.api["exper_"+e]?.apply(n,t)}async loadScripts(...e){(e=e.map((e=>e?.startsWith("http")?e:this.ctx.resolveResourceFullUrl(e)))).unshift(this.ctx.baseInfo.id),await this.invokeExperMethod("loadScripts",...e)}registerFencedCodeRenderer(e,t){return this.ensureHostScope().logseq.api.exper_register_fenced_code_renderer(this.ctx.baseInfo.id,e,t)}registerExtensionsEnhancer(e,t){const n=this.ensureHostScope();switch(e){case"katex":n.katex&&t(n.katex).catch(console.error)}return n.logseq.api.exper_register_extensions_enhancer(this.ctx.baseInfo.id,e,t)}ensureHostScope(){if(window===top)throw new Error("Can not access host scope!");return top}}const Vt=e=>`task_callback_${e}`;class Yt{_client;_requestId;_requestOptions;_promise;_aborted=!1;constructor(e,t,n={}){this._client=e,this._requestId=t,this._requestOptions=n,this._promise=new Promise(((e,t)=>{if(!this._requestId)return t(null);this._client.once(Vt(this._requestId),(n=>{n&&n instanceof Error?t(n):e(n)}))}));const{success:r,fail:i,final:o}=this._requestOptions;this._promise.then((e=>{r?.(e)})).catch((e=>{i?.(e)})).finally((()=>{o?.()}))}abort(){this._requestOptions.abortable&&!this._aborted&&(this._client.ctx._execCallableAPI("http_request_abort",this._requestId),this._aborted=!0)}get promise(){return this._promise}get client(){return this._client}get requestId(){return this._requestId}}class Xt extends i.EventEmitter{_ctx;constructor(e){super(),this._ctx=e,this.ctx.caller.on("#lsp#request#callback",(e=>{const t=e?.requestId;t&&this.emit(Vt(t),e?.payload)}))}static createRequestTask(e,t,n){return new Yt(e,t,n)}async _request(e){const t=this.ctx.baseInfo.id,{success:n,fail:r,final:i,...o}=e,s=this.ctx.Experiments.invokeExperMethod("request",t,o),a=Xt.createRequestTask(this.ctx.Request,s,e);return o.abortable?a:a.promise}get ctx(){return this._ctx}}const Qt=Symbol.for("proxy-continue"),en=Ut()("LSPlugin:user");function tn(e,t,n){if("function"!=typeof n)return!1;const{key:r,label:i,desc:o,palette:s,keybinding:a}=t,c=`SimpleCommandHook${r}${++on}`;this.Editor["on"+c](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",c]],s]})}let nn=null;const rn={async getInfo(e){return nn||(nn=await this._execCallableAPIAsync("get-app-info")),"string"==typeof e?nn[e]:nn},registerCommand:tn,registerCommandPalette(e,t){const{key:n,label:r,keybinding:i}=e;return tn.call(this,"$palette$",{key:n,label:r,palette:!0,keybinding:i},t)},registerCommandShortcut(e,t){const{binding:n}=e,r="$shortcut$",i=r+yt(n);return tn.call(this,r,{key:i,palette:!1,keybinding:e},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;tn.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 on=0;const sn={newBlockUUID(){return this._execCallableAPIAsync("new_block_uuid")},registerSlashCommand(e,t){en("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}${++on}`;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;tn.call(this,"block-context-menu-item",{key:n,label:r},t)},scrollToBlockInPage(e,t,n){const r="block-content-"+t;n?.replaceState?this.App.replaceState("page",{name:e},{anchor:r}):this.App.pushState("page",{name:e},{anchor:r})}},an={onBlockChanged(e,t){const n=this.baseInfo.id,r=`hook:db:${yt(`block:${e}`)}`,i=({block:n,txData:r,txMeta:i})=>{n.uuid===e&&t(n,r,i)};return this.caller.on(r,i),this.App._installPluginHook(n,r),()=>{this.caller.off(r,i),this.App._uninstallPluginHook(n,r)}}},cn={},ln={},un={};class dn extends(o()){_baseInfo;_caller;_version=LIB_VERSION;_debugTag="";_settingsSchema;_connected=!1;_ui=new Map;_mFileStorage;_mRequest;_mExperiments;_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)}}))}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=wt(this._baseInfo,n),this._settingsSchema&&(n.settings=Pt(n.settings,this._settingsSchema),await this.useSettingsSchema(this._settingsSchema)),n?.id&&(this._debugTag=this._caller.debugTag=`#${n.id} [${n.name}]`);try{await this._execCallableAPIAsync("setSDKMetadata",{version:this._version})}catch(e){console.warn(e)}t&&t.call(this,n)}catch(e){console.error(`${this._debugTag} [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 version(){return this._version}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(/^[.\\/]+/,""),Et(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){const r=s.apply(n,e.concat(t));if(r!==Qt)return r}if(t){const o=i.toString().match(/^(once|off|on)/i);if(null!=o){const i=o[0].toLowerCase(),s=o.input.slice(i.length),a="off"===i,c=n.baseInfo.id,l=`hook:${t}:${yt(s)}`,u=e[0];r[i](l,u);const d=()=>{r.off(l,u),r.listenerCount(l)||n.App._uninstallPluginHook(c,l)};return a?void d():(n.App._installPluginHook(c,l),d)}}let o=i;return["git","ui","assets"].includes(t)&&(o=t+"_"+o),r.callAsync("api:call",{tag:t,method:o,args:e})}}})}_execCallableAPIAsync(e,...t){return this._caller.callAsync("api:call",{method:e,args:t})}_execCallableAPI(e,...t){this._caller.call("api:call",{method:e,args:t})}_callWin(...e){return this._execCallableAPIAsync("_callMainWin",...e)}get App(){return this._makeUserProxy(rn,"app")}get Editor(){return this._makeUserProxy(sn,"editor")}get DB(){return this._makeUserProxy(an,"db")}get Git(){return this._makeUserProxy(cn,"git")}get UI(){return this._makeUserProxy(ln,"ui")}get Assets(){return this._makeUserProxy(un,"assets")}get FileStorage(){let e=this._mFileStorage;return e||(e=this._mFileStorage=new Zt(this)),e}get Request(){let e=this._mRequest;return e||(e=this._mRequest=new Xt(this)),e}get Experiments(){let e=this._mExperiments;return e||(e=this._mExperiments=new Kt(this)),e}}if(null==window.__LSP__HOST__){const e=new En(null);window.logseq=new dn({},e)}const{importHTML:hn,createSandboxContainer:pn}=window.QSandbox||{};function fn(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 gn extends(o()){_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 hn(t,{fetch:fn});this._mount(n,document.body);const i=pn(e,{elementGetter:()=>this._root?.firstChild}).instance.proxy;i.__shadow_mode__=!0,i.LSPluginLocal=this._pluginLocal,i.LSPluginShadow=this,i.LSPluginUser=i.logseq=new dn(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 mn=Ut()("LSPlugin:caller"),yn="#await#response#",_n="#lspmsg#",bn="#lspmsg#error#",vn="#lspmsg#settings#",wn="#lspmsg#beforeunload#",xn="#lspmsg#reply#",Cn="#lspmsg#ready#",Sn=e=>`#lspmsg#${e}`;class En extends(o()){_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=At(5e3),a=this._extendUserModel({[Cn]:async e=>{a[Sn(e?.pid)]=({type:e,payload:n})=>{mn(`[host (_call) -> *user] ${this._debugTag}`,e,n),t.emit(e,n)},await s.resolve()},[wn]:async e=>{const n=At(1e4);t.emit("beforeunload",Object.assign({actor:n},e)),await n.promise},[vn]:async({type:e,payload:n})=>{t.emit("settings:changed",n)},[_n]:async({ns:e,type:n,payload:r})=>{mn(`[host (async) -> *user] ${this._debugTag} ns=${e} type=${n}`,r),e&&e.startsWith("hook")?t.emit(`${e}:${n}`,r):t.emit(n,r)},[xn]:({_sync:e,result:t})=>{if(mn(`[sync host -> *user] #${e}`,t),o.has(e)){const n=o.get(e);n&&(t?.hasOwnProperty(bn)?n.reject(t[bn]):n.resolve(t),o.delete(e))}},...e});if(n)return await s.promise,JSON.parse(JSON.stringify(this._pluginLocal?.toJSON()));const c=new Jt(a).sendHandshakeReply();return this._status="pending",await c.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}`),mn(`async call #${e}`)}return e.emit(Sn(a.baseInfo.id),{type:t,payload:n}),r?.promise},this._callUserModel=async(e,t)=>{try{a[e](t)}catch(t){mn(`[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=At(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=`${t}_lsp_main`,r=new URL(e.options.entry);r.searchParams.set("__v__",ht?Date.now().toString():e.options.version);const i=document.querySelector(`#${n}`);i&&i.parentElement.removeChild(i);const o=document.createElement("div");o.classList.add("lsp-iframe-sandbox-container"),o.id=n,o.dataset.pid=t;try{const e=(await this._pluginLocal._loadLayoutsData())?.$$0;if(e){o.dataset.inited_layout="true";const{width:t,height:n,left:r,top:i}=e;Object.assign(o.style,{width:t+"px",height:n+"px",left:r+"px",top:i+"px"})}}catch(e){console.error("[Restore Layout Error]",e)}document.body.appendChild(o);let s,a=new Gt({id:t+"_iframe",container:o,url:r.href,classListArray:["lsp-iframe-sandbox"],model:{baseInfo:JSON.parse(JSON.stringify(e.toJSON()))}}).sendHandshake();return this._status="pending",new Promise(((t,n)=>{s=setTimeout((()=>{n(new Error("handshake Timeout"))}),8e3),a.then((n=>{this._parent=n,this._connected=!0,this.emit("connected"),n.on(Sn(e.id),(({type:e,payload:t})=>{mn("[user -> *host] ",e,t),this._pluginLocal?.emit(e,t||{})})),this._call=async(...t)=>{await n.call(Sn(e.id),{type:t[0],payload:Object.assign(t[1]||{},{$$pid:e.id})})},this._callUserModel=async(e,t)=>{if(e.startsWith(yn))return await n.get(e.replace(yn,""));n.call(e,t)},t(null)})).catch((e=>{n(e)})).finally((()=>{clearTimeout(s)}))})).catch((e=>{throw mn("[iframe sandbox] error",e),e})).finally((()=>{this._status=void 0}))}async _setupShadowSandbox(){const e=this._pluginLocal,t=this._shadow=new gn(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(yn)&&(t=t.replace(yn,""));const n=e[1]||{},r=this._userModel[t];"function"==typeof r&&await r.call(null,n)}}catch(e){throw mn("[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 On=Ut()("LSPlugin:core"),An="plugins";class kn extends(o()){_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=wt({},this._settings);if("string"==typeof e){if(this._settings[e]==t)return;this._settings[e]=t}else{if(!vt(e))return;wt(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=Pt(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 Tn extends(o()){_tag;_logs=[];constructor(e){super(),this._tag=e}write(e,t){const 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 jn;function In(e,t){return t&&e.startsWith(pt+t)&&(e=Et(gt,e.substr(pt.length+t.length))),e}!function(e){e.LOADING="loading",e.UNLOADING="unloading",e.LOADED="loaded",e.UNLOADED="unload",e.ERROR="error"}(jn||(jn={}));class Ln extends Error{constructor(e){super(e),this.name=Ln.name}}class Nn extends Error{constructor(e){super(e),this.name=Nn.name}}class Mn extends(o()){_options;_themeMgr;_ctx;_sdk={};_disposes=[];_id;_status=jn.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||xt(),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;kt("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():o.ownerDocument.activeElement.blur(),r&&kt("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){const t=e=>`provider:${e}`;let 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(jt(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 kt.apply(r,[e.method,...e.args])}catch(e){t={[bn]:e}}const{_sync:n}=e;if(r.shadow)e.actor&&e.actor.resolve(t);else if(null!=n){const e=e=>{r.caller?.callUserModel(xn,{result:e,_sync:n})};Promise.resolve(t).then(e,e)}}))}async _setupUserSettings(e){const{_options:t}=this,n=t.logger=new Tn("Loader");if(!t.settings||e)try{const n=()=>kt("load_plugin_user_settings",this.id),[r,i]=await n();this._dotSettingsFile=r;let o=t.settings;if(o||(o=t.settings=new kn(i)),e)return void(o.settings=i);const s=async(e,t)=>{if(On("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&&kt("save_plugin_user_settings",this.id,e)};return o.on("change",s),()=>{}}catch(e){On("[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=dt.join(t,e);e=n.test(r)?r:pt+r}return!this.options.effect&&this.isInstalledInDotRoot?In(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(On("prepare package root",e),t=await kt("load_plugin_config",e),!t||(t=JSON.parse(t),!t))throw new Error(`Parse package config error #${e}/package.json`)}catch(e){throw new Ln(e.message)}const n=this._localRoot=Ot(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=dt.basename(n);else if(r.id)this._id=r.id;else{r.id=this.id;try{await kt("save_plugin_config",e,{...t,logseq:r})}catch(e){On("[save plugin ID Error] ",e)}}const{registeredPlugins:c,isRegistering:l}=this._ctx;if(l&&c.has(r.id))throw new Nn("prepare package Error");return async()=>{try{const e=r.themes;e&&await this._loadConfigThemes(Array.isArray(e)?e:[e])}catch(e){On("[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=dt.join(An,r));const o=(new Date).getDay(),s=await bt(),a=await kt(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 ${ht?`<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=In(St(dt.normalize(a)),this.dotPluginsRoot),this._options.entry=e}async _loadConfigThemes(e){e.forEach((e=>{e.url&&(!e.url.startsWith("http")&&this._localRoot&&(e.url=dt.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 kt("load_plugin_user_settings",e);return t||{}}async _saveLayoutsData(e){const t=this.id+"_layouts";await kt("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-"+xt());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=>{e.target?.closest(".r")&&(e.stopPropagation(),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-"+xt());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=jn.LOADING,this._loadErr=void 0;try{const 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 En(this),await this._caller.connectToChild();const n=()=>{this._caller?.callUserModel(Cn,{pid:this.id})};e?.indicator?e.indicator.promise.then(n):n(),this._dispose((async()=>{await(this._caller?.destroy())})),this._dispose(Mt.bind(this))}catch(e){console.error("[Load Plugin Error] ",e),this.logger?.error(e),this._status=jn.ERROR,this._loadErr=e}finally{this._loadErr||(this.disabled?this._status=jn.UNLOADED:this._status=jn.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=jn.UNLOADING;const t={unregister:e};try{await(this._caller?.callUserModel((wn,`${yn}#lspmsg#beforeunload#`),t)),this.emit("beforeunload",t)}catch(e){console.error("[beforeunload Error]",e)}await this.dispose(),this.emit("unloaded")}catch(e){return On("[plugin unload Error]",e),!1}finally{this._status=jn.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===jn.LOADED}get pending(){return[jn.LOADING,jn.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 dt.normalize(this._ctx.options.dotConfigRoot)}get dotSettingsFile(){return this._dotSettingsFile}get dotPluginsRoot(){return dt.join(this.dotConfigRoot,An)}get sdk(){return this._sdk}set sdk(e){this._sdk=e}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 Rn extends(o()){_options;_isRegistering=!1;_readyIndicator;_hostMountedActor=At();_userPreferences={theme:null,themes:{mode:"light",light:null,dark:null},externals:[]};_registeredThemes=new Map;_registeredPlugins=new Map;_currentTheme;constructor(e){super(),this._options=e}async loadUserPreferences(){try{const e=await kt("load_user_preferences");e&&Object.assign(this._userPreferences,e)}catch(e){On("[load user preferences Error]",e)}}async saveUserPreferences(e){try{e&&Object.assign(this._userPreferences,e),await kt("save_user_preferences",this._userPreferences)}catch(e){On("[save user preferences Error]",e)}}async activateUserPreferences(){const{theme:e,themes:t}=this._userPreferences,n=t[t.mode];n?await this.selectTheme(n,{effect:!1}):e&&await this.selectTheme(e,{effect:!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{id:n,options:r,status:i,disabled:o}=t.o;return!0===o||!r.entry&&(r.name||r.entry)||(e[n]={name:r.name,entry:r.entry,status:i,enabled:"boolean"==typeof o?o?"⚫️":"🟢":"🔴",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=At();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 Mn(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&&(On("[Failed LOAD Plugin] #",t),this.emit("error",a),a instanceof Ln||a instanceof Nn)||(s.e=performance.now(),r.settings?.on("change",(e=>{this.emit("settings-changed",r.id,e),r.caller?.callUserModel(vn,{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){On(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)}const 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){const i=`${e}:${yt(t)}`,o="hook:db:changed"===i,s=i.startsWith("hook:db:block"),a=r=>{On(`[call hook][#${r.id}]`,e,t),r.caller?.callUserModel(_n,{ns:e,type:yt(t),payload:n})};for(const[e,t]of this._registeredPlugins)if(!t.options.theme&&!t.disabled)if(r){if(r===t.id){a(t);break}}else{const e=t.sdk?.version;if(!e){if(o||s)continue;a(t)}e&&kt("should_exec_plugin_hook",t.id,i)&&a(t)}}async hookApp(e,t,n){return await this._hook("hook:app",e,t,n)}async hookEditor(e,t,n){return await this._hook("hook:editor",e,t,n)}async hookDb(e,t,n){return await this._hook("hook:db",e,t,n)}ensurePlugin(e){if(e instanceof Mn)return e;const t=this._registeredPlugins.get(e);if(!t)throw new Error(`plugin #${e} not existed.`);return t}hostMounted(){this._hostMountedActor.resolve()}_forceCleanInjectedUI(e){if(e)return Nt(e)}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(On("Register theme #",e,t),!e)return;let n=this._registeredThemes.get(e);n||this._registeredThemes.set(e,n=[]),n.push(t),this.emit("themes-changed",this.themes,{id:e,...t})}async selectTheme(e,t={}){const{effect:n,emit:r}=Object.assign({},{effect:!0,emit:!0},t);if(this._currentTheme&&this._currentTheme.eject(),e.url){const t=Ft(e.url);this._currentTheme={pid:e.pid,opt:e,eject:t}}else this._currentTheme=null;n&&await this.saveUserPreferences(e.mode?{themes:{...this._userPreferences.themes,mode:e.mode,[e.mode]:e}}:{theme:e}),r&&this.emit("theme-selected",e)}async unregisterTheme(e,t=!0){if(On("Unregister theme #",e),this._registeredThemes.has(e)&&(this._registeredThemes.delete(e),this.emit("themes-changed",this.themes,{id:e}),t&&this._currentTheme?.pid===e)){this._currentTheme.eject(),this._currentTheme=null;const{theme:t,themes:n}=this._userPreferences;await this.saveUserPreferences({theme:t?.pid===e?null:t,themes:{...n,light:n.light?.pid===e?null:n.light,dark:n.dark?.pid===e?null:n.dark}}),this.emit("reset-custom-theme",this._userPreferences.themes)}}}function Fn(e){const t=new Rn(e);On("=== 🔗 Setup Logseq Plugin System 🔗 ==="),window.LSPluginCore=t}})(),r})()));