node-red-contrib-uibuilder
Version:
Easily create data-driven web UI's for Node-RED using any (or no) front-end library.
3 lines (2 loc) • 21.7 kB
JavaScript
var b=Object.create;var h=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var $=(c,t,e)=>t in c?h(c,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):c[t]=e;var g=(c=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(c,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):c)(function(c){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+c+'" is not supported')});var C=(c,t)=>()=>(t||c((t={exports:{}}).exports,t),t.exports);var x=(c,t,e,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of v(t))!S.call(c,n)&&n!==e&&h(c,n,{get:()=>t[n],enumerable:!(i=E(t,n))||i.enumerable});return c};var m=(c,t,e)=>(e=c!=null?b(k(c)):{},x(t||!c||!c.__esModule?h(e,"default",{value:c,enumerable:!0}):e,c));var u=(c,t,e)=>$(c,typeof t!="symbol"?t+"":t,e);var M=C((L,p)=>{var r,A=(r=class{constructor(t,e,i){u(this,"version","7.0.4-esm.min");u(this,"sanitiseExtraTags",["uib-var"]);u(this,"sanitiseExtraAttribs",["variable","report","undefined"]);u(this,"ui_md_plugins");if(t)r.win=t;else throw new Error("Ui:constructor. Current environment does not include `window`, UI functions cannot be used.");r.doc=r.win.document,e?r.log=e:r.log=function(){return function(){}},i?this.syntaxHighlight=i:this.syntaxHighlight=function(){},r.win.markdownit&&(r.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(n,a){if(a&&window.hljs&&window.hljs.getLanguage(a))try{return'<pre class="">\n <code class="hljs border">'.concat(window.hljs.highlight(n,{language:a,ignoreIllegals:!0}).value,"</code></pre>")}finally{}return'<pre class="hljs border"><code>'.concat(r.md.utils.escapeHtml(n).trim(),"</code></pre>")}},r.md=r.win.markdownit(r.mdOpts))}_markDownIt(){if(r.win.markdownit&&(!this.ui_md_plugins&&r.win.uibuilder&&r.win.uibuilder.ui_md_plugins&&(this.ui_md_plugins=r.win.uibuilder.ui_md_plugins),r.mdOpts={html:!0,xhtmlOut:!1,linkify:!0,_highlight:!0,_strict:!1,_view:"html",langPrefix:"language-",highlight:function(t,e){if(window.hljs)if(e&&window.hljs.getLanguage(e))try{return'<pre><code class="hljs border language-'.concat(e,'" data-language="').concat(e,'" title="Source language: \'').concat(e,"'\">").concat(window.hljs.highlight(t,{language:e,ignoreIllegals:!0}).value,"</code></pre>")}finally{}else try{let i=window.hljs.highlightAuto(t);return'<pre><code class="hljs border language-'.concat(i.language,'" data-language="').concat(i.language,'" title="Source language estimated by HighlightJS: \'').concat(i.language,"'\">").concat(i.value,"</code></pre>")}finally{}return'<pre><code class="border">'.concat(r.md.utils.escapeHtml(t).trim(),"</code></pre>")}},r.md=r.win.markdownit(r.mdOpts),this.ui_md_plugins)){if(!Array.isArray(this.ui_md_plugins)){r.log("error","Ui:_markDownIt:plugins","Could not load plugins, ui_md_plugins is not an array")();return}this.ui_md_plugins.forEach(t=>{if(typeof t=="string")r.md.use(r.win[t]);else{let e=Object.keys(t)[0];r.md.use(r.win[e],t[e])}})}}_showNotification(t){t.topic&&!t.title&&(t.title=t.topic),t.title||(t.title="uibuilder notification"),t.payload&&!t.body&&(t.body=t.payload),t.body||(t.body=" No message given.");try{let e=new Notification(t.title,t);return new Promise((i,n)=>{e.addEventListener("close",a=>{a.currentTarget.userAction="close",i(a)}),e.addEventListener("click",a=>{a.currentTarget.userAction="click",i(a)}),e.addEventListener("error",a=>{a.currentTarget.userAction="error",n(a)})})}catch{return Promise.reject(new Error("Browser refused to create a Notification"))}}_uiAdd(t,e){r.log("trace","Ui:_uiManager:add","Starting _uiAdd")(),t.components.forEach((i,n)=>{r.log("trace","Ui:_uiAdd:components-forEach:".concat(n),"Component to add: ",i)();let a;switch(i.type){case"html":{i.ns="html",a=r.doc.createElement("div");break}case"svg":{i.ns="svg",a=r.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{i.ns="dom",a=r.doc.createElement(i.type);break}}!i.slot&&t.payload&&(i.slot=t.payload),this._uiComposeComponent(a,i);let s;i.parentEl?s=i.parentEl:t.parentEl?s=t.parentEl:i.parent?s=r.doc.querySelector(i.parent):t.parent&&(s=r.doc.querySelector(t.parent)),s||(r.log("info","Ui:_uiAdd","No parent found, adding to body")(),s=r.doc.querySelector("body")),i.position&&i.position==="first"?s.insertBefore(a,s.firstChild):i.position&&Number.isInteger(Number(i.position))?s.insertBefore(a,s.children[i.position]):s.appendChild(a),i.components&&this._uiExtendEl(a,i.components,i.ns)})}_uiComposeComponent(t,e){e.attributes&&Object.keys(e.attributes).forEach(i=>{i==="class"&&Array.isArray(e.attributes[i])&&e.attributes[i].join(" "),r.log("trace","_uiComposeComponent:attributes-forEach","Attribute: '".concat(i,"', value: '").concat(e.attributes[i],"'"))(),i==="value"&&(t.value=e.attributes[i]),i.startsWith("xlink:")?t.setAttributeNS("http://www.w3.org/1999/xlink",i,e.attributes[i]):t.setAttribute(i,e.attributes[i])}),e.id&&t.setAttribute("id",e.id),e.type==="svg"&&(t.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns","http://www.w3.org/2000/svg"),t.setAttributeNS("http://www.w3.org/2000/xmlns/","xmlns:xlink","http://www.w3.org/1999/xlink")),e.events&&Object.keys(e.events).forEach(i=>{i.toLowerCase==="onclick"&&(i="click");try{t.addEventListener(i,n=>{new Function("evt","".concat(e.events[i],"(evt)"))(n)})}catch(n){r.log("error","Ui:_uiComposeComponent","Add event '".concat(i,"' for element '").concat(e.type,"': Cannot add event handler. ").concat(n.message))()}}),e.properties&&Object.keys(e.properties).forEach(i=>{t[i]=e.properties[i],["value","checked"].includes(i)&&(t.dispatchEvent(new Event("input")),t.dispatchEvent(new Event("change")))}),e.slot&&this.replaceSlot(t,e.slot),e.slotMarkdown&&this.replaceSlotMarkdown(t,e)}_uiExtendEl(t,e,i=""){e.forEach((n,a)=>{r.log("trace","Ui:_uiExtendEl:components-forEach:".concat(a),n)();let s;n.ns=i,n.ns==="html"?(s=t,this.replaceSlot(t,n.slot)):n.ns==="svg"?(s=r.doc.createElementNS("http://www.w3.org/2000/svg",n.type),this._uiComposeComponent(s,n),t.appendChild(s)):(s=r.doc.createElement(n.type==="html"?"div":n.type),this._uiComposeComponent(s,n),t.appendChild(s)),n.components&&this._uiExtendEl(s,n.components,n.ns)})}_uiLoad(t){t.components&&(Array.isArray(t.components)||(t.components=[t.components]),t.components.forEach(async e=>{Promise.resolve().then(()=>m(g(e)))})),t.srcScripts&&(Array.isArray(t.srcScripts)||(t.srcScripts=[t.srcScripts]),t.srcScripts.forEach(e=>{this.loadScriptSrc(e)})),t.txtScripts&&(Array.isArray(t.txtScripts)||(t.txtScripts=[t.txtScripts]),this.loadScriptTxt(t.txtScripts.join("\n"))),t.srcStyles&&(Array.isArray(t.srcStyles)||(t.srcStyles=[t.srcStyles]),t.srcStyles.forEach(e=>{this.loadStyleSrc(e)})),t.txtStyles&&(Array.isArray(t.txtStyles)||(t.txtStyles=[t.txtStyles]),this.loadStyleTxt(t.txtStyles.join("\n")))}_uiManager(t){t._ui&&(Array.isArray(t._ui)||(t._ui=[t._ui]),t._ui.forEach((e,i)=>{if(e.mode&&!e.method&&(e.method=e.mode),!e.method){r.log("error","Ui:_uiManager","No method defined for msg._ui[".concat(i,"]. Ignoring. "),e)();return}switch(e.payload=t.payload,e.topic=t.topic,e.method){case"add":{this._uiAdd(e,!1);break}case"remove":{this._uiRemove(e,!1);break}case"removeAll":{this._uiRemove(e,!0);break}case"replace":{this._uiReplace(e);break}case"update":{this._uiUpdate(e);break}case"load":{this._uiLoad(e);break}case"reload":{this._uiReload();break}case"notify":{this.showDialog("notify",e,t);break}case"alert":{this.showDialog("alert",e,t);break}default:{r.log("error","Ui:_uiManager","Invalid msg._ui[".concat(i,"].method (").concat(e.method,"). Ignoring"))();break}}}))}_uiReload(){r.log("trace","Ui:uiManager:reload","reloading")(),location.reload()}_uiRemove(t,e=!1){t.components.forEach(i=>{let n;e!==!0?n=[r.doc.querySelector(i)]:n=r.doc.querySelectorAll(i),n.forEach(a=>{try{a.remove()}catch(s){r.log("trace","Ui:_uiRemove","Could not remove. ".concat(s.message))()}})})}_uiReplace(t){r.log("trace","Ui:_uiReplace","Starting")(),t.components.forEach((e,i)=>{r.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Component to replace: ",e)();let n;if(e.id?n=r.doc.getElementById(e.id):e.selector||e.select?n=r.doc.querySelector(e.selector):e.name?n=r.doc.querySelector('[name="'.concat(e.name,'"]')):e.type&&(n=r.doc.querySelector(e.type)),r.log("trace","Ui:_uiReplace:components-forEach:".concat(i),"Element to replace: ",n)(),n==null){r.log("trace","Ui:_uiReplace:components-forEach:".concat(i,":noReplace"),"Cannot find the DOM element. Adding instead.",e)(),this._uiAdd({components:[e]},!1);return}let a;switch(e.type){case"html":{e.ns="html",a=r.doc.createElement("div");break}case"svg":{e.ns="svg",a=r.doc.createElementNS("http://www.w3.org/2000/svg","svg");break}default:{e.ns="dom",a=r.doc.createElement(e.type);break}}this._uiComposeComponent(a,e),n.replaceWith(a),e.components&&this._uiExtendEl(a,e.components,e.ns)})}_uiUpdate(t){r.log("trace","UI:_uiUpdate:update","Starting _uiUpdate",t)(),t.components||(t.components=[Object.assign({},t)]),t.components.forEach((e,i)=>{r.log("trace","_uiUpdate:components-forEach","Start loop #".concat(i),e)();let n;if(e.parentEl?n=e.parentEl:e.id?n=r.doc.querySelectorAll("#".concat(e.id)):e.selector||e.select?n=r.doc.querySelectorAll(e.selector):e.name?n=r.doc.querySelectorAll('[name="'.concat(e.name,'"]')):e.type&&(n=r.doc.querySelectorAll(e.type)),n===void 0||n.length<1){r.log("warn","Ui:_uiManager:update","Cannot find the DOM element. Ignoring.",e)();return}r.log("trace","_uiUpdate:components-forEach","Element(s) to update. Count: ".concat(n.length),n)(),!e.slot&&e.payload&&(e.slot=e.payload),n.forEach((a,s)=>{if(r.log("trace","_uiUpdate:components-forEach","Updating element #".concat(s),a)(),this._uiComposeComponent(a,e),e.components){r.log("trace","_uiUpdate:nested-component","Element #".concat(s," - nested-component"),e,a)();let o={_ui:[]};e.components.forEach((l,d)=>{let f=l.method||e.method||t.method;l.method&&delete l.method,Array.isArray(l)||(l=[l]),r.log("trace","_uiUpdate:nested-component","Element #".concat(s," - nested-component #").concat(d),l)(),o._ui.push({method:f,parentEl:a,components:l})}),r.log("trace","_uiUpdate:nested-component","Element #".concat(s," - nested-component new manager"),o)(),this._uiManager(o)}})})}$(t,e){let i=r.doc.querySelector(t);if(!i)return r.log(1,"Uib:$","No element found for CSS selector ".concat(t))(),null;if(i.nodeName==="TEMPLATE"&&(i=i.content.firstElementChild,!i))return r.log(0,"Uib:$","Template selected for CSS selector ".concat(t," but it is empty"))(),null;e||(e="el");let n;try{switch(e.toLowerCase()){case"text":{n=i.innerText;break}case"html":{n=i.innerHTML;break}case"attr":case"attributes":{n={};for(let a of i.attributes)n[a.name]=a.value;break}default:{n=i;break}}}catch(a){n=i,r.log(1,"Uib:$",'Could not process output type "'.concat(e,'" for CSS selector ').concat(t,", returned the DOM element. ").concat(a.message),a)()}return n}$$(t){return Array.from(r.doc.querySelectorAll(t))}addClass(t,e){Array.isArray(t)||(t=[t]),e&&e.classList.add(...t)}applyTemplate(t,e,i){i||(i={onceOnly:!1});let n=r.doc.getElementById(t),a=r.doc.getElementById(e);if(n&&a){let s;try{i.onceOnly!==!0?s=r.doc.importNode(n.content,!0):s=r.doc.adoptNode(n.content)}catch{r.log("error","Ui:applyTemplate","Source must be a <template>. id='".concat(t,"'"))();return}if(s){if(i.attributes){let o=s.firstElementChild;Object.keys(i.attributes).forEach(l=>{o.setAttribute(l,i.attributes[l])})}a.appendChild(s)}}else n||r.log("error","Ui:applyTemplate","Source not found: id='".concat(t,"'"))(),a||r.log("error","Ui:applyTemplate","Target not found: id='".concat(e,"'"))()}buildHtmlTable(t){let e;if(!Array.isArray(t)&&(typeof t=="object"&&(e=Object.keys(t),t=Object.values(t)),!Array.isArray(t))){let l=r.doc.createElement("p");return l.textContent="Input data is not an array or an object, cannot create a table.",l}let i=r.doc.createElement("table"),n=r.doc.createElement("thead"),a=r.doc.createElement("tr"),s=Object.keys(t[0]);s.forEach(l=>{let d=r.doc.createElement("th");d.textContent=l,a.appendChild(d)}),n.appendChild(a),i.appendChild(n);let o=r.doc.createElement("tbody");return t.forEach((l,d)=>{let f=r.doc.createElement("tr");e&&(f.id="r-".concat(e[d])),s.forEach(w=>{let y=r.doc.createElement("td");y.innerHTML=this.sanitiseHTML(l[w]),f.appendChild(y)}),o.appendChild(f)}),i.appendChild(o),i}convertMarkdown(t){if(!t)return"";if(!r.win.markdownit)return t;r.md||this._markDownIt();try{return r.md.render(t.trim())}catch(e){return r.log(0,"uibuilder:convertMarkdown","Could not render Markdown. ".concat(e.message),e)(),'<p class="border error">Could not render Markdown<p>'}}async include(t,e){if(!fetch)return r.log(0,"Ui:include","Current environment does not include `fetch`, skipping.")(),"Current environment does not include `fetch`, skipping.";if(!t)return r.log(0,"Ui:include","url parameter must be provided, skipping.")(),"url parameter must be provided, skipping.";if(!e||!e.id)return r.log(0,"Ui:include","uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.")(),"uiOptions parameter MUST be provided and must contain at least an `id` property, skipping.";let i;try{i=await fetch(t)}catch(d){return r.log(0,"Ui:include","Fetch of file '".concat(t,"' failed. "),d.message)(),d.message}if(!i.ok)return r.log(0,"Ui:include","Fetch of file '".concat(t,"' failed. Status='").concat(i.statusText,"'"))(),i.statusText;let n=await i.headers.get("content-type"),a=null;n&&(n.includes("text/html")?a="html":n.includes("application/json")?a="json":n.includes("multipart/form-data")?a="form":n.includes("image/")?a="image":n.includes("video/")?a="video":n.includes("application/pdf")?a="pdf":n.includes("text/plain")&&(a="text"));let s="",o="Include successful",l;switch(a){case"html":{l=await i.text(),s=l;break}case"json":{l=await i.json(),s='<pre class="syntax-highlight">',s+=this.syntaxHighlight(l),s+="</pre>";break}case"form":{l=await i.formData(),s='<pre class="syntax-highlight">',s+=this.syntaxHighlight(l),s+="</pre>";break}case"image":{l=await i.blob(),s='<img src="'.concat(URL.createObjectURL(l),'">'),r.win.DOMPurify&&(o="Include successful. BUT DOMPurify loaded which may block its use.",r.log("warn","Ui:include:image",o)());break}case"video":{l=await i.blob(),s='<video controls autoplay><source src="'.concat(URL.createObjectURL(l),'"></video>'),r.win.DOMPurify&&(o="Include successful. BUT DOMPurify loaded which may block its use.",r.log("warn","Ui:include:video",o)());break}case"pdf":case"text":default:{l=await i.blob(),s='<iframe style="resize:both;width:inherit;height:inherit;" src="'.concat(URL.createObjectURL(l),'">'),r.win.DOMPurify&&(o="Include successful. BUT DOMPurify loaded which may block its use.",r.log("warn","Ui:include:".concat(a),o)());break}}return e.type="div",e.slot=s,e.parent||(e.parent="body"),e.attributes||(e.attributes={class:"included"}),this._uiReplace({components:[e]}),r.log("trace","Ui:include:".concat(a),o)(),o}loadScriptSrc(t){let e=r.doc.createElement("script");e.src=t,e.async=!1,r.doc.head.appendChild(e)}loadScriptTxt(t){let e=r.doc.createElement("script");e.async=!1,e.textContent=t,r.doc.head.appendChild(e)}loadStyleSrc(t){let e=r.doc.createElement("link");e.href=t,e.rel="stylesheet",e.type="text/css",r.doc.head.appendChild(e)}loadStyleTxt(t){let e=r.doc.createElement("style");e.textContent=t,r.doc.head.appendChild(e)}loadui(t){if(!fetch){r.log(0,"Ui:loadui","Current environment does not include `fetch`, skipping.")();return}if(!t){r.log(0,"Ui:loadui","url parameter must be provided, skipping.")();return}fetch(t).then(e=>{if(e.ok===!1)throw new Error("Could not load '".concat(t,"'. Status ").concat(e.status,", Error: ").concat(e.statusText));r.log("trace","Ui:loadui:then1","Loaded '".concat(t,"'. Status ").concat(e.status,", ").concat(e.statusText))();let i=e.headers.get("content-type");if(!i||!i.includes("application/json"))throw new TypeError("Fetch '".concat(t,"' did not return JSON, ignoring"));return e.json()}).then(e=>e!==void 0?(r.log("trace","Ui:loadui:then2","Parsed JSON successfully obtained")(),this._uiManager({_ui:e}),!0):!1).catch(e=>{r.log("warn","Ui:loadui:catch","Error. ",e)()})}moveElement(t){let{sourceSelector:e,targetSelector:i,moveType:n,position:a}=t;if(!document.querySelector(e)){r.log(0,"Ui:moveElement","Source element not found")();return}if(!document.querySelector(i)){r.log(0,"Ui:moveElement","Target element not found")();return}}nodeGet(t,e){let i={id:t.id===""?void 0:t.id,name:t.name,children:t.childNodes.length,type:t.nodeName,attributes:void 0,isUserInput:!!t.validity,userInput:t.validity?{value:t.value,validity:void 0,willValidate:t.willValidate,valueAsDate:t.valueAsDate,valueAsNumber:t.valueAsNumber,type:t.type}:void 0};if(["UL","OL"].includes(t.nodeName)){let n=r.doc.querySelectorAll("".concat(e," li"));n&&(i.list={entries:n.length})}if(t.nodeName==="DL"){let n=r.doc.querySelectorAll("".concat(e," dt"));n&&(i.list={entries:n.length})}if(t.nodeName==="TABLE"){let n=r.doc.querySelectorAll("".concat(e," > tbody > tr")),a=r.doc.querySelectorAll("".concat(e," > thead > tr")),s=r.doc.querySelectorAll("".concat(e," > tbody > tr:last-child > *"));(n||a||s)&&(i.table={headRows:a?a.length:0,bodyRows:n?n.length:0,columns:s?s.length:0})}if(t.nodeName!=="#text"&&t.attributes&&t.attributes.length>0){i.attributes={};for(let n of t.attributes)n.name!=="id"&&(i.attributes[n.name]=t.attributes[n.name].value),n.name==="class"&&(i.classes=Array.from(t.classList))}t.nodeName==="#text"&&(i.text=t.textContent),t.validity&&(i.userInput.validity={});for(let n in t.validity)i.userInput.validity[n]=t.validity[n];return i}async notification(t){if(typeof t=="string"&&(t={body:t}),typeof Notification>"u")return Promise.reject(new Error("Notifications not available in this browser"));let e=Notification.permission;return e==="denied"?Promise.reject(new Error("Notifications not permitted by user")):e==="granted"?this._showNotification(t):(e=await Notification.requestPermission(),e==="granted"?this._showNotification(t):Promise.reject(new Error("Notifications not permitted by user")))}removeClass(t,e){if(!t){e.removeAttribute("class");return}Array.isArray(t)||(t=[t]),e&&e.classList.remove(...t)}replaceSlot(t,e){if(!t)return;e||(e=""),e=this.sanitiseHTML(e);let i=r.doc.createRange().createContextualFragment(e),n=r.doc.createRange();n.selectNodeContents(t),n.deleteContents(),t.append(i)}replaceSlotMarkdown(t,e){t&&e.slotMarkdown&&(e.slotMarkdown=this.convertMarkdown(e.slotMarkdown),e.slotMarkdown=this.sanitiseHTML(e.slotMarkdown),t.innerHTML=e.slotMarkdown)}sanitiseHTML(t){return r.win.DOMPurify?r.win.DOMPurify.sanitize(t,{ADD_TAGS:this.sanitiseExtraTags,ADD_ATTR:this.sanitiseExtraAttribs}):t}showDialog(t,e,i){let n="";if(i.payload&&typeof i.payload=="string"&&(n+="<div>".concat(i.payload,"</div>")),e.content&&(n+="<div>".concat(e.content,"</div>")),n===""){r.log(1,"Ui:showDialog","Toast content is blank. Not shown.")();return}!e.title&&i.topic&&(e.title=i.topic),e.title&&(n='<p class="toast-head">'.concat(e.title,"</p><p>").concat(n,"</p>")),e.noAutohide&&(e.noAutoHide=e.noAutohide),e.noAutoHide&&(e.autohide=!e.noAutoHide),e.autoHideDelay?(e.autohide||(e.autohide=!0),e.delay=e.autoHideDelay):e.autoHideDelay=1e4,Object.prototype.hasOwnProperty.call(e,"autohide")||(e.autohide=!0),t==="alert"&&(e.modal=!0,e.autohide=!1,n='<svg viewBox="0 0 192.146 192.146" style="width:30;background-color:transparent;"><path d="M108.186 144.372c0 7.054-4.729 12.32-12.037 12.32h-.254c-7.054 0-11.92-5.266-11.92-12.32 0-7.298 5.012-12.31 12.174-12.31s11.91 4.992 12.037 12.31zM88.44 125.301h15.447l2.951-61.298H85.46l2.98 61.298zm101.932 51.733c-2.237 3.664-6.214 5.921-10.493 5.921H12.282c-4.426 0-8.51-2.384-10.698-6.233a12.34 12.34 0 0 1 .147-12.349l84.111-149.22c2.208-3.722 6.204-5.96 10.522-5.96h.332c4.445.107 8.441 2.618 10.513 6.546l83.515 149.229c1.993 3.8 1.905 8.363-.352 12.066zm-10.493-6.4L96.354 21.454l-84.062 149.18h167.587z" /></svg> '.concat(n));let a=r.doc.getElementById("toaster");a===null&&(a=r.doc.createElement("div"),a.id="toaster",a.title="Click to clear all notifcations",a.setAttribute("class","toaster"),a.setAttribute("role","dialog"),a.setAttribute("arial-label","Toast message"),a.onclick=function(){a.remove()},r.doc.body.insertAdjacentElement("afterbegin",a));let s=r.doc.createElement("div");s.title="Click to clear this notifcation",s.setAttribute("class","toast ".concat(e.variant?e.variant:""," ").concat(t)),s.innerHTML=n,s.setAttribute("role","alertdialog"),e.modal&&s.setAttribute("aria-modal",e.modal),s.onclick=function(o){o.stopPropagation(),s.remove(),a.childElementCount<1&&a.remove()},a.insertAdjacentElement(e.appendToast===!0?"beforeend":"afterbegin",s),e.autohide===!0&&setInterval(()=>{s.remove(),a.childElementCount<1&&a.remove()},e.autoHideDelay)}ui(t){let e={};t._ui?e=t:e._ui=t,this._uiManager(e)}uiGet(t,e=null){let i=r.doc.querySelectorAll(t),n=[];return i.forEach(a=>{if(e){e==="classes"&&(e="class");let s=a.getAttribute(e);if(s==null)try{s=a[e]}catch{}if(s==null)e.toLowerCase()==="value"?n.push(a.innerText):n.push("Property '".concat(e,"' not found"));else{let o={},l=s.constructor.name.toLowerCase();if(l==="namednodemap")for(let d of s)o[d.name]=s[d.name].value;else if(!l.includes("map"))o[e]=s;else{let d={};for(let f in s)d[f]=s[f]}o.class&&(o.classes=Array.from(a.classList)),n.push(o)}}else n.push(this.nodeGet(a,t))}),n}uiEnhanceElement(t,e){this._uiComposeComponent(t,e)}},u(r,"win"),u(r,"doc"),u(r,"log"),u(r,"mdOpts"),u(r,"md"),r);p.exports=A});export default M();
//# sourceMappingURL=ui.esm.min.js.map