-
-
Notifications
You must be signed in to change notification settings - Fork 10
/
bay.min.js
1 lines (1 loc) · 26.2 KB
/
bay.min.js
1
var __awaiter=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))((function(a,r){function o(e){try{l(i.next(e))}catch(e){r(e)}}function s(e){try{l(i.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,s)}l((i=i.apply(e,t||[])).next())}))};const bay=e=>{"use strict";if(window.bay)return;window.bay={};const t=(e,t)=>e.querySelectorAll(t),n="data-bay-",i="this-attribute";let a="",r=[],o=[],s=new Map,l="";const d=[".passive",".capture",".once",".left",".middle",".right",".enter",".tab",".delete",".backspace",".esc",".space",".arrow-up",".arrow-down",".arrow-left",".arrow-right",".ctrl",".alt",".shift",".meta",".stop",".prevent",".self"];!function e(n){t(n,"template[shadowrootmode], template[shadowroot]").forEach((t=>{const n=t.getAttribute("shadowrootmode")||t.getAttribute("shadowroot"),i=t.parentNode.attachShadow({mode:n});i.appendChild(t.content),t.remove(),e(i)}))}(document);const c=document.createElement("textarea");function u(e){return"string"==typeof e?(c.textContent=e,c.innerHTML.replaceAll('"',""").replaceAll("'","'")):e}function h(e){const t=document.createElement("textarea");return t.innerHTML=e,t.value}function b(e,t){return new Proxy(e,{get(e,n){if("isProxy"===n)return!0;const i=e[n];return void 0===i?"":null!==i?(i.isProxy||"object"!=typeof i||(i instanceof Map?e[n]=function(e,t){return new Proxy(e,{get:(e,n)=>"set"===n?function(n,i){return e.set(n,u(i)),t&&t(),e}:["get","has","delete","clear"].includes(n)?function(...t){return e[n].apply(e,t)}:e[n]})}(i,t):i instanceof WeakMap?e[n]=function(e,t){return new Proxy(e,{get:(e,n)=>"set"===n?function(n,i){return e.set(n,u(i)),t&&t(),e}:["get","has","delete"].includes(n)?function(...t){return e[n].apply(e,t)}:e[n]})}(i,t):i instanceof Set?e[n]=function(e,t){return new Proxy(e,{get:(e,n)=>"add"===n?function(n){return e.add(u(n)),t&&t(),e}:["has","delete","clear"].includes(n)?function(...t){return e[n].apply(e,t)}:e[n]})}(i,t):i instanceof WeakSet?e[n]=function(e,t){return new Proxy(e,{get:(e,n)=>"add"===n?function(n){return e.add(u(n)),t&&t(),e}:["has","delete"].includes(n)?function(...t){return e[n].apply(e,t)}:e[n]})}(i,t):e[n]=b(i,t)),e[n]):void 0},set:(e,n,i)=>(e[n]=u(i),t&&t(),!0)})}let y,p;function w(){Object.entries(window.location).forEach((e=>{window.bay.route[`${e[0]}`]=e[1]})),window.bay.route.path=window.location.pathname,window.bay.route.params={};const e=new URLSearchParams(window.location.search);for(let[t,n]of e)window.bay.route.params[t]=n}function m(e){return([1e7].toString()+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g,(e=>(e^crypto.getRandomValues(new Uint8Array(1))[0]&15>>e/4).toString(16))).replaceAll("-","").substring(0,e)}window.bay.emit=function(e,t){const n={detail:{name:e,data:t}};window.dispatchEvent(new CustomEvent("bay_emit",n)),window.dispatchEvent(new CustomEvent(e,n))},window.bay.receive=function(e,n,i,a){[...t(e,`[data-bay-${i}]`),...t(n,`[data-bay-${i}]`),...t(document,`[data-bay-${i}]`)].forEach((e=>{e.dispatchEvent(new CustomEvent(i,{detail:{name:i,data:a}}))}))},window.bay.global=b({},(()=>{y&&window.cancelAnimationFrame(y),y=window.requestAnimationFrame((()=>{window.dispatchEvent(new CustomEvent("bay_global_event"))}))})),window.bay.route=b({},(()=>{p&&window.cancelAnimationFrame(p),p=window.requestAnimationFrame((()=>{window.dispatchEvent(new CustomEvent("bay_route_event"))}))})),w(),window.addEventListener("popstate",(()=>{w()})),window.bay.router=function(e,t){const n=t.split("/"),i=e.split("/");let a=!0,r={};for(let e=0;e<n.length;e++)if(":"===n[e][0])r[n[e].slice(1)]=i[e];else if("*"!==n[e]&&n[e]!==i[e]){a=!1;break}return!!a&&r};const f=m(8);function $(e){[...document.querySelectorAll("[bay-hydrate]")].forEach(((e,t)=>{e.id="bay-hydrate-"+t;let n=e.querySelector("template").innerHTML,i=document.createElement("bay-hydrate-"+t);i.setAttribute("inner-html","#bay-hydrate-"+t),document.body.appendChild(i),window.bay.create("bay-hydrate-"+t,"<inner-html>"+n+"</inner-html>")})),[...t(e,"[bay]")].forEach(((e,t)=>{"dsd"===e.getAttribute("bay")&&e.setAttribute("bay",`dsd-${t}`),-1===r.indexOf(e.getAttribute("bay")||"")&&r.push(e)})),r.forEach((e=>{-1===o.indexOf(e.getAttribute("bay"))&&function(e){try{const n=e.getAttribute("bay")||"";let i=e.tagName.toLowerCase();if("template"===i)A(h(e.innerHTML),e,n),e.remove();else if("dsd-"===n.substring(0,4))a=n,e.shadowRoot?A(h(e.shadowRoot.innerHTML),e,i):(A(h(t(e,"template")[0].innerHTML),e,i),t(e,"template")[0].remove());else if("#"===n.substring(0,1)){a=n;const r=t(document,n)[0];if(!r)return;A(r.innerHTML,e,i),r.remove()}else fetch(n).then((e=>e.text())).then((t=>{A(t,e,i)})).catch((e=>{}))}catch(e){}}(e),o.push(e.getAttribute("bay"))}))}function v(t){return e?(Object.entries(e).forEach((([e,n])=>{if("string"==typeof n){let i=`%{${e}}`;t=t.replaceAll(i,n)}})),t):t}function g(e,t){[...e.querySelectorAll("include")].forEach((e=>{const n=e.attributes[0];n&&n.value&&fetch(n.value).then((e=>{if(!e.ok)throw new Error(`HTTP error ${e.status}: ${e.statusText}`);return e.text()})).then((n=>{for(;n.indexOf("<style>")>-1;){const e=n.split("<style>")[1].split("</style>")[0];n=n.replaceAll(`<style>${e}</style>`,""),l+=e}n=n.replaceAll(/<!--[\s\S]*?-->/g,""),e.outerHTML=n,t()})).catch((e=>{}))}))}function A(e,n,i){const a=new DOMParser,r="export default /*HTML*/`";let o;for(e=v(e=e.replaceAll(/<!--[\s\S]*?-->/g,"")),l="",e.startsWith(r)&&(e=(e=(e=(e=e.trim()).split(r)[1]).substring(0,e.length-2)).replaceAll("\\${","${").replaceAll("\\`","`"));e.indexOf("<style>")>-1;){const t=e.split("<style>")[1].split("</style>")[0];e=e.replaceAll(`<style>${t}</style>`,""),l+=t}function s(){o&&0===[...o.querySelectorAll("include")].length&&(customElements.get(i)||C(o,i,function(e){let n=[];const i=e=>{"bay"!==e.name&&"inner-html"!==e.name&&"fouc"!==e.name&&-1===n.indexOf(e.name)&&n.push(e.name)};return[...e.attributes].forEach((e=>i(e))),[...t(document,e.tagName.toLocaleLowerCase())].forEach((e=>{[...e.attributes].forEach((e=>i(e)))})),[...t(document,"template")].forEach((n=>{[...t(n.content,e.tagName.toLocaleLowerCase())].forEach((e=>{[...e.attributes].forEach((e=>i(e)))}))})),n}(n),l,!1))}e='<div id="bay-temporary-compile-element"></div>'+e,o=a.parseFromString(e,"text/html"),o.getElementById("bay-temporary-compile-element").remove(),g(o,s),s()}function E(e,t){e.forEach(((e,n)=>{var i,a;if(!t[n].isEqualNode(e)&&t[n]&&(i=e,[...(a=t[n]).attributes].forEach((e=>{"style"!==e.name&&(i.hasAttribute(e.name)||(a.removeAttribute(e.nodeName),S(a,e.nodeName)&&delete a[e.nodeName]))})),[...i.attributes].forEach((e=>{a.hasAttribute(e.nodeName)&&a.getAttribute(e.nodeName)===e.value||a.setAttribute(e.nodeName,e.value),S(a,e.nodeName)&&a[e.nodeName]!==e.value&&(a[e.nodeName]=e.value)}))),!e.hasAttribute("data-bay-style")&&!e.hasAttribute("style")){const e=t[n].style.width,i=t[n].style.height;t[n].removeAttribute("style"),e&&(t[n].style.width=e),i&&(t[n].style.height=i)}}))}function _(e,n){[...t(e,"*")].map(((e,t)=>{if(e.tagName.indexOf("-")>-1){!(""+e.textContent.trim()+e.innerHTML.trim())&&e.setAttribute("no-diff",!0)}})),[...t(e,"[no-diff]")].map(((e,i)=>{[...t(n,"[no-diff]")][i]&&(e.innerHTML=[...t(n,"[no-diff]")][i].innerHTML)}))}function L(e,t,i,a,r){t&&(e.newEvents="",t.forEach(((t,i)=>{[...t.attributes].forEach((a=>function(e,t,i,a,r){if(!i.closest(`[${r}]`))return;let o=t.name;if(o.startsWith(":")){let e=o.split(":")[1];o=o.replace(`:${e}`,`data-bay-${e}`)}if(o.indexOf(n)>-1){if(o.indexOf("-custom-")>-1&&(o=o.replace("custom-","")),o.indexOf("data-bay-style")>-1)i.style!==t.value&&(i.style=t.value);else{let r=t.value.replaceAll("window.bay","$bay");-1===e.newEvents.indexOf("$bay.events=new Map();\n")&&(e.newEvents+="$bay.events=new Map();\n");let s={};d.forEach((e=>{if(-1!==o.indexOf(e))switch(e){case".passive":s.passive=!0;break;case".capture":s.capture=!0;break;case".once":s.once=!0;break;case".enter":r="if (e.key !== 'Enter') return;"+r;break;case".tab":r="if (e.key !== 'Tab') return;"+r;break;case".delete":r="if (e.key !== 'Delete') return;"+r;break;case".backspace":r="if (e.key !== 'Backspace') return;"+r;break;case".esc":r="if (e.key !== 'Escape' && e.key !== 'Esc') return;"+r;break;case".space":r="if (e.key !== ' ' && e.key !== 'Spacebar') return;"+r;break;case".arrow-up":r="if (e.key !== 'ArrowUp') return;"+r;break;case".arrow-down":r="if (e.key !== 'ArrowDown') return;"+r;break;case".arrow-left":r="if (e.key !== 'ArrowLeft') return;"+r;break;case".arrow-right":r="if (e.key !== 'ArrowRight') return;"+r;break;case".ctrl":r="if (!e.ctrlKey) return;"+r;break;case".alt":r="if (!e.altKey) return;"+r;break;case".shift":r="if (!e.shiftKey) return;"+r;break;case".meta":r="if (!e.metaKey) return;"+r;break;case".self":r="if (e.target !== e.currentTarget) return;"+r;break;case".left":r="if (e.button !== 0) return;"+r;break;case".middle":r="if (e.button !== 1) return;"+r;break;case".right":r="if (e.button !== 2) return;"+r;break;case".stop":r="e.stopPropagation();"+r;break;case".prevent":r="e.preventDefault();"+r;break}})),e.newEvents+=`$bay.events.set('${o}-${a}',(e)=>{${r}});\n`;const l=`${e.uniqid}${a}${o}`;let c=o.split(n)[1];d.forEach((e=>{c=c.replace(e,"")})),e.eventHandlers.has(l)&&(i.removeEventListener(c,e.eventHandlers.get(l),s),e.eventHandlers.delete(l)),e.eventHandlers.set(l,(t=>{window.bay[e.uniqid].events&&window.bay[e.uniqid].events.has(`${o}-${a}`)&&window.bay[e.uniqid].events.get(`${o}-${a}`)(t)})),i.addEventListener(c,e.eventHandlers.get(l),s)}}}(e,a,t,i,r)))})),e.newEvents&&e.oldEvents!==e.newEvents&&(e.oldEvents=e.newEvents,function(e,t,n,i){__awaiter(this,void 0,void 0,(function*(){const a=URL.createObjectURL(new Blob([`${n}export default function($bay,$global,$route,$el,$parent,$bay_select_bind,$ref){"use strict";\n${t}};`],{type:"text/javascript"}));(yield import(a)).default.call(window.bay[e.uniqid].proxy,window.bay[e.uniqid],window.bay.global,window.bay.route,window.bay[e.uniqid].$el,window.bay[i]?window.bay[i].proxy:null,window.bay.apply_select,window.bay[e.uniqid].refs),URL.revokeObjectURL(a)}))}(e,e.newEvents,i,a)))}function x(e){e.debouncer&&window.cancelAnimationFrame(e.debouncer),e.debouncer=window.requestAnimationFrame((()=>{e.render()}))}function k(e){e.dsd||(e.tmp=window.bay[e.uniqid].template(),e.shadowDom.getElementById("bay").innerHTML=e.tmp),x(e),e.CSP?e.shadowDom.innerHTML="CSP issue, add blob: to script-src & style-src whitelist.":t(e.shadowDom,"[bay]")[0]&&$(e.shadowDom)}function q(e){return(new DOMParser).parseFromString(e,"text/html").body}function T(e){return 3===e.nodeType?"text":8===e.nodeType?"comment":e.tagName.toLowerCase()}function M(e){return e.childNodes&&e.childNodes.length>0?null:e.textContent}function H(e,t){const n=[...t.childNodes],i=[...e.childNodes];let a=n.length-i.length;if(a>0)for(;a>0;a--)n[n.length-a].parentNode.removeChild(n[n.length-a]);i.forEach(((e,i)=>{if(!n[i])return void t.appendChild(e.cloneNode(!0));if(T(e)!==T(n[i])){try{n[i].parentNode.replaceChild(e.cloneNode(!0),n[i])}catch(e){}return}const a=M(e);if(a&&a!==M(n[i])&&(n[i].textContent=a),n[i].childNodes.length>0&&e.childNodes.length<1)n[i].innerHTML="";else{if(n[i].childNodes.length<1&&e.childNodes.length>0){const t=document.createDocumentFragment();return H(e,t),void n[i].appendChild(t)}e.childNodes.length>0&&H(e,n[i])}}))}function S(e,t){return void 0!==e[t]&&"object"!=typeof e[t]}function C(e,n,a,r,o){let l="",d=`data-${m(8)}`,c=null,y="",p="",v=[],g=!1,A=!1,T=!1,M=!1,S=!1,C=!1,O=[];try{r="*:not(:defined){opacity:0;max-width:0px;max-height:0px}*:not(:defined)*{opacity:0;max-width:0px;max-height:0px}.bay-hide{display:none}"+(r||""),c=e.body,function(e){[...e.querySelectorAll("define")].forEach((t=>{const n=t.getAttribute("this"),i=t.outerHTML;t.remove(),[...e.querySelectorAll(n)].forEach((e=>{e.outerHTML=i}))}))}(c),l=n;const o=document.createElement(`${n}-update`);c.appendChild(o),(c.innerHTML.indexOf("$global.")>-1||c.innerHTML.indexOf("$global[")>-1)&&(g=!0),(c.innerHTML.indexOf("$route.")>-1||c.innerHTML.indexOf("$route[")>-1||c.innerHTML.indexOf("</router>")>-1||c.innerHTML.indexOf("</route>")>-1||c.innerHTML.indexOf("$bay.update_route")>-1)&&(A=!0),c.innerHTML.indexOf("</route>")>-1&&(r=(r||"")+"[bay-route]>*{pointer-events:none}"),c.innerHTML.indexOf("$prop")>-1&&(T=!0),c.innerHTML.indexOf("$bay.on(")>-1&&(C=!0),c.innerHTML.indexOf("</show>")>-1&&bay.create(`show-${f}`,"<div id=\"show\" :style=\"${this.style()}\"><slot></slot></div><script update>$bay.getElementById('show').ontransitionend=()=>this.end();<\/script><script props>this.slide(this.open);<\/script><script mounted>this.slide(this.open);<\/script><script>this.opacity=0;this.display='none';this.slide=(open)=>{let opacity=0;if(open==='true'){opacity=1;this.display='block';};requestAnimationFrame(()=>{this.opacity=opacity;});};this.end=()=>{if(this.open==='false'){this.display='none';}};this.style=()=>{return `display:${this.display};opacity:${this.opacity};transition:opacity ${this.transition || '0s'};`;};<\/script>",["open","transition"]);const s="element, index, array";let u="";const h=(e,n)=>{if(!t(e,n)[0]){const i=e.getAttribute("array")||[],a=e.getAttribute("params")||s,r=e.getAttribute("join")||"",o=e.getAttribute("duration")||!1,l=[...e.attributes][0]?[...e.attributes][0].nodeValue:"",d=e.nextElementSibling?e.nextElementSibling.tagName.toLowerCase():"";let h="`}return ''})()}";const b=e.hasAttribute("break")?"break;":"",y=0===e.innerHTML.length,w=e.attributes.length?e.attributes[0].name:"",$=`<${n}>`,v=`</${n}>`,g=[...e.attributes];!function(e){for(;e.attributes.length>0;)e.removeAttribute(e.attributes[0].name)}(e);let A=e.outerHTML;const E=(t,n)=>{e.outerHTML=A.replace($,t).replace(v,n)};switch(n){case"dsd":e.remove();break;case"noscript":c.innerHTML=c.innerHTML.replaceAll($,"").replaceAll(v,"");break;case"map":E(`\${ ${i}.${n}((${a})=>{return \``,`\`}).join('${r}')}`);break;case"for":const s=`bay_${n}_${m(8)}`;i.length?E(`\${(()=>{let ${s}='';${i}.forEach((${a})=>{${s}+=\``,`\`});return ${s};})()}`):E(`\${(()=>{let ${s}=''; ${n} (${l}) { ${s} += \``,`\`};return ${s};})() }`);break;case"if":"else-if"!==d&&"else"!==d||(h="`}"),E(`\${(()=>{ ${n} (${l}) {return \``,h);break;case"else-if":"else-if"!==d&&"else"!==d||(h="`}"),E(` else if (${l}) {return \``,h);break;case"else":E(` ${n} {return \``,h);break;case"show":o?E(`<show-${f} class="bay-show" open="\${${l}}" transition="${o} ease-in-out">`,`</show-${f}>`):E(`<div class="\${(${l})?'bay-show':'bay-show bay-hide'}">`,"</div>");break;case"switch":E(`\${(()=>{let bay_switch=''; ${n} (${l}) { `," };return bay_switch;})() }");break;case"case":y?E(`${n} ${l}:`," "+b):E(`${n} ${l}: bay_switch += \``,"`; "+b);break;case"default":E(`${n}: bay_switch += \``,"`;");break;case"inner-html":M=!0,E("${ (()=>{$bay_inner_html+=`","`;return ''})()}"),e.remove();break;case"route":let _="";g.forEach((e=>{_+=` ${e.name}="${e.value}"`})),E(`<a bay-route :click="e.preventDefault();history.pushState({},'',e.target.getAttribute('href'));window.bay.update_route();"${_}>`,"</a>");break;case"router":E(`\${(()=>{let $path=window.bay.router(window.bay.route.path,'${l}');if($path){return \``,h);break;case"script":switch(w){case"imports":p+=e.innerText.trim()+"\n",e.remove();break;case"update":E("${/*update*/(()=>{setTimeout(()=>{","}, 0);return ``})()}");break;case"props":E("${/*props updates*/(()=>{$props=()=>{","};return ``})()}");break;case"render":E("${/*render*/(()=>{","})()}");break;case"slotchange":E("${/*slotchange updates*/(()=>{$slotchange=(e)=>{$details=e.detail;\n","};return ``})()}");break;case"mounted":u+=`$bay['$mounted']=()=>{${e.innerText}};`,e.remove();break;default:const i=t(c,n)[0];u+=i.innerText,e.remove();break}e&&e.parentNode&&(e.outerHTML=A,e.remove());break}}};["dsd","noscript","map","for","if","else-if","else","show","switch","case","default","inner-html","route","router","script"].forEach((e=>{for(;[...t(c,e)].length>0;){[...t(c,e)].forEach((t=>h(t,e)))}})),[...t(c,"*")].forEach((e=>{[...e.attributes].forEach((t=>{const n="bind"===t.name,a="custom:"===t.name.substring(0,7),r="input"===e.tagName.toLowerCase(),o="textarea"===e.tagName.toLowerCase();if(function(e,t){const n=document.createElement(e);return n.setAttribute(t,"test_value"),"boolean"==typeof n[t]}(e.tagName.toLowerCase(),t.name)&&e.setAttribute(t.name,"true"),t.name===i){let n=`this-attribute="${t.value}"`;O.push({original:n,new:`\${(() => {return ${t.value} || ''})()}`}),e.setAttribute(d,"")}if(":"===t.name.substring(0,1)||a){let n="";a&&(n="custom-"),e.setAttribute(`data-bay-${n}${t.name.split(":")[1]}`,t.value),e.removeAttribute(t.name),e.setAttribute(d,"")}else n&&"select"===e.tagName.toLowerCase()?(e.setAttribute(`data-bay-custom-select-${f}`,`$bay_select_bind(e, ${t.value})`),e.removeAttribute(t.name),e.innerHTML=`\${${t.value}.map((item)=>{return \`<option \${(()=>{return Object.entries(item).map((o)=> \`\${o[0]}="\${o[1]}"\` ).join(' ')})()}>\${item.text}</option>\`}).join('')}`,S=!0,e.setAttribute(d,"")):n&&(r||o)?(e.setAttribute("data-bay-input",`${t.value} = e.target.value`),e.removeAttribute(t.name),e.setAttribute("value",`\${${t.value}}`),e.setAttribute(d,"")):"bind:"===t.name.substring(0,5)&&(r||o)&&(e.setAttribute(`data-bay-${t.name.split(":")[1]}`,`${t.value} = e.target.value`),e.removeAttribute(t.name),e.setAttribute("value",`\${${t.value}}`),e.setAttribute(d,""))})),e.tagName.indexOf("-")>-1&&[...e.attributes].forEach((t=>{let n=t.value;0===n.indexOf("${")&&0===n.lastIndexOf("${")&&n.endsWith("}")&&(n=n.replace("${","${$bay.encode(JSON.stringify("),n=[...n].reverse().join(""),n=n.replace("}","}))"),n=[...n].reverse().join("")),e.setAttribute(t.name,n)}))})),S&&(window.bay.apply_select=(e,t)=>{[...e.target.options].forEach(((e,n)=>{t[n].selected?(e.selected=!0,e.setAttribute("selected","true")):(e.selected=!1,e.removeAttribute("selected"))})),e.target.onchange=e=>{[...e.target.options].forEach(((e,n)=>{e.selected?t[n].selected=!0:t[n].selected=!1}))}}),[...t(c,"*")].forEach((e=>{if(e.hasAttribute("bay-map")||e.hasAttribute("bay-for")){let t=e.hasAttribute("bay-map")?"map":"for",n=e.getAttribute("this")||"",i=e.getAttribute("params")||"",a=e.getAttribute("bay-map")||e.getAttribute("bay-for")||e.getAttribute("array")||"[]",r=e.getAttribute("join")||"";e.removeAttribute("params"),e.removeAttribute("bay-map"),e.removeAttribute("bay-for"),e.removeAttribute("this"),e.removeAttribute("array"),e.removeAttribute("join");let o=e.outerHTML,s="";if("map"===t)s=`\x3c!--iteration\${ ${a}.map((${i})=>{return \`${o}\`}).join('${r}') }iteration--\x3e`;else{const e=`bay_for_${m(8)}`;s=n?`\x3c!--iteration\${ (()=>{let ${e}=''; for (${n}) { ${e} += \`${o}\`};return ${e};})()}iteration--\x3e`:`\x3c!--iteration\${(()=>{let ${e}='';${a}.forEach((${i})=>{${e}+=\`${o}\`});return ${e};})()}iteration--\x3e`}e.outerHTML=s}})),function(e){[...e.querySelectorAll("define")].forEach((e=>{e.outerHTML=e.innerHTML}))}(c),y=u,v=a}catch(e){}if(l){class e extends HTMLElement{constructor(){super(),this.mounted=!1,this.tmp=`${c.innerHTML}`,this.uniqid=m(8),this.CSP=!1,this.dsd=!1,this.debouncer=!1,this.prefixes=[],this.eventHandlers=new Map;const e=this.getAttribute("inner-html");if(e?t(document,e)[0]&&(this.inner_el=t(document,e)[0]):this.inner_el=this,document.addEventListener("securitypolicyviolation",(e=>{e.preventDefault(),(e.violatedDirective.indexOf("script-src")>-1||e.violatedDirective.indexOf("style-src")>-1)&&"blob"===e.blockedURI&&(this.CSP=!0)})),this.shadowRoot){this.shadowDom=this.shadowRoot;const e=document.createElement("div");e.id="bay",[...this.shadowDom.children].map((t=>e.appendChild(t))),this.shadowRoot.appendChild(e),this.dsd=!0}else{this.attachShadow({mode:"open"}),this.shadowDom=this.shadowRoot;let e=document.createElement("template");e.innerHTML='<div id="bay"></div>',this.shadowDom.appendChild(e.content.cloneNode(!0))}this.shadowDom.proxy=b({},(()=>{x(this)})),this.shadowRootHTML=t(this.shadowDom,"#bay")[0],window.bay[this.uniqid]=this.shadowDom,[...a].forEach((e=>{this.shadowDom.proxy[e.att]=e.value})),window.bay[this.uniqid].$el=this,this.oldEvents="",this.shadowDom.refs=e=>{let t=[...this.shadowDom.querySelectorAll(`[ref="${e}"]`),...document.querySelectorAll(`${n} [ref="${e}"]`),...document.querySelectorAll(`#${n} [ref="${e}"]`),...this.inner_el.querySelectorAll(`[ref="${e}"]`)];if(t.length>1)return t;if(1===t.length)return t[0];{let t=document.createElement("error");return t.innerHTML=`$refs("${e}") not mounted"`,t}},y||(y="/* No script tag found */"),this.shadowDom.uniqid=this.uniqid;const i=this.getRootNode();this.parent_uniqid="",i.host&&(this.parent_uniqid=i.host.uniqid),this.update_evt=new CustomEvent(`bay_local_update_event_${this.uniqid}`);let l="";this.tmp.indexOf("/*props updates*/")>-1&&(l="let $props;\nwindow.addEventListener(`bay_local_update_event_${$bay_uniqid}`,()=>$props());\n");this.tmp.indexOf("/*slotchange updates*/")>-1&&(l="let $slotchange=()=>{};\nlet $details={'element':'','changed':''};\nwindow.addEventListener(`bay_slotchange_event_${$bay_uniqid}`,(e)=>$slotchange(e));\n"),window.bay[this.uniqid].decode=h,window.bay[this.uniqid].encode=u,window.bay.update_route=w,A&&(window.bay[this.uniqid].update_route=window.bay.update_route);let d="";T&&(d="const $prop = prop => JSON.parse($bay.decode(prop));\n"),window.bay[this.uniqid].addEventListener("slotchange",(e=>{this.local_evt=new CustomEvent(`bay_slotchange_event_${this.uniqid}`,{detail:{element:e.target,changed:"slotchange"}}),window.dispatchEvent(this.local_evt)})),t(this,"*").forEach((e=>{new MutationObserver((t=>{t.forEach((t=>{"attributes"===t.type?(this.local_evt=new CustomEvent(`bay_slotchange_event_${this.uniqid}`,{detail:{element:e,changed:"attributes"}}),window.dispatchEvent(this.local_evt)):"childList"===t.type&&(this.local_evt=new CustomEvent(`bay_slotchange_event_${this.uniqid}`,{detail:{element:e,changed:"childList"}}),window.dispatchEvent(this.local_evt))}))})).observe(e,{attributes:!0,childList:!0})}));let f=`// ${n};\n`,$="",v="",g="";M&&($="let $bay_inner_html='';\n",v=" $bay_inner_html=''; ",g="\n$bay.inner_html=()=>{return $bay_inner_html;};");let E="";C&&(E="$bay.on=(name,callback)=>{window.addEventListener(name,e=>callback(e));};\n"),window.bay[this.uniqid].emit=window.bay.emit,window.bay[this.uniqid].receive=window.bay.receive;let _=`${E}function bay_receive_fn(e){$bay.receive($bay,$el,e.detail.name,e.detail.data);}\nwindow.removeEventListener('bay_emit',bay_receive_fn);\nwindow.addEventListener('bay_emit',bay_receive_fn);\n`;this.prefixes=[f,$,l,"",d,_];const L=this.prefixes.join("")+h(y).replace(/(^[ \t]*\n)/gm,"");let q=h(this.tmp).replace(/(^[ \t]*\n)/gm,"");O.forEach((e=>{q=q.replaceAll(e.original,e.new)})),q=q.replaceAll("\x3c!--iteration","").replaceAll("iteration--\x3e","");let H="";if(r&&(H=h(r).replaceAll('"${',"${").replaceAll("'${","${").replaceAll('}"',"}").replaceAll("}'","}").replaceAll(" ","").replaceAll("\n","")),function(e,t,n,i,a,r){__awaiter(this,void 0,void 0,(function*(){if(s.has(n))yield import(s.get(n)).then((t=>{t.default.call(window.bay[e.uniqid].proxy,e.uniqid,window.bay[e.uniqid],window.bay.global,window.bay.route,window.bay[e.uniqid].$el,window.bay[a]?window.bay[a].proxy:null,window.bay[e.uniqid].refs),k(e)}));else{const o=URL.createObjectURL(new Blob([`${r}export default function ($bay_uniqid,$bay,$global,$route,$el,$parent,$ref) {"use strict";\n${i}};`],{type:"text/javascript"}));s.set(n,o),yield import(o).then((n=>{n.default.call(window.bay[e.uniqid].proxy,e.uniqid,window.bay[e.uniqid],window.bay.global,window.bay.route,window.bay[e.uniqid].$el,window.bay[a]?window.bay[a].proxy:null,window.bay[e.uniqid].refs),k(e),t&&URL.revokeObjectURL(o)}))}}))}(this,o,n,`${L}\n$bay.template=()=>{${v}return \`${q}\`;};\n$bay.styles=()=>{return \`${H}\`;};${g}`,this.parent_uniqid,p),this.hasAdopted=!1,"adoptedStyleSheets"in document&&(this.hasAdopted=!0),this.hasAdopted)this.sheet=new CSSStyleSheet,this.sheet.replaceSync(H),this.shadowDom.adoptedStyleSheets=[this.sheet];else{const e=new Blob([H],{type:"text/css"}),t=URL.createObjectURL(e),n=document.createElement("link");n.rel="stylesheet",n.href=t,this.shadowDom.appendChild(n),n.id="bay-style";const i=document.createElement("link");i.id="bay-style-update",i.href=t,i.rel="stylesheet",this.shadowDom.appendChild(i),this.styleLinkUpdate=i}}render(){if(this.CSP)this.shadowDom.innerHTML="";else if(this.tmp&&this.shadowRootHTML.innerHTML&&"function"==typeof window.bay[this.uniqid].template)try{if(M&&function(e,n){if(!n)return;if("function"!=typeof window.bay[e].inner_html)return;window.bay[e].template();const i=q(window.bay[e].inner_html());_(i,n),H(i,n),E([...t(i,"*")],[...t(n,"*")])}(this.uniqid,this.inner_el),function(e,n){const i=q(window.bay[e].template());_(i,n),H(i,n),E([...t(i,"*")],[...t(n,"*")])}(this.uniqid,this.shadowRootHTML),L(this,M?[...t(this.inner_el,"*"),...t(this.shadowRootHTML,"*")]:[...t(this.shadowRootHTML,"*")],p,this.parent_uniqid,d),function(e){const t=window.bay[e.uniqid].styles();if(e.oldStyles!==t)if(e.oldStyles=t,e.hasAdopted)e.sheet.replaceSync(t);else{const n=new Blob([t],{type:"text/css"}),i=URL.createObjectURL(n);e.styleLinkUpdate.href=i,URL.revokeObjectURL(i)}}(this),S){const e=`[data-bay-custom-select-${f}]`;let n=[];n=M?[...t(this.inner_el,e),...t(this.shadowRootHTML,e)]:[...t(this.shadowRootHTML,e)],n.forEach((e=>{e.dispatchEvent(new CustomEvent(`select-${f}`))}))}!1===this.mounted&&window.bay[this.uniqid].$mounted&&(this.mounted=!0,requestAnimationFrame((()=>{window.bay[this.uniqid].$mounted()}))),t(this.shadowDom,"[bay]")[0]&&$(this.shadowDom),t(this.shadowDom,"[bay-hydrate]")[0]&&$(this.shadowDom),M&&(t(this.inner_el,"[bay]")[0]&&$(this.inner_el),t(this.inner_el,"[bay-hydrate]")[0]&&$(this.inner_el)),this.hasAttribute("fouc")&&this.removeAttribute("fouc")}catch(e){}}connectedCallback(){try{g&&window.addEventListener("bay_global_event",(e=>{x(this)})),A&&window.addEventListener("bay_route_event",(e=>{x(this)}))}catch(e){}}static get observedAttributes(){return v}attributeChangedCallback(e,t,n){t!==n&&(this.shadowDom.proxy[e]=n,window.dispatchEvent(this.update_evt))}}customElements.define(l,e)}}window.addEventListener("load",(()=>{$(document)})),bay.refresh=()=>{$(document)},window.bay.refresh=bay.refresh,bay.create=function(e,t,n){const i=new DOMParser,a=n||[];for(t=v(t=t.replaceAll(/<!--[\s\S]*?-->/g,"")),l="";t.indexOf("<style>")>-1;){const e=t.split("<style>")[1].split("</style>")[0];t=t.replaceAll(`<style>${e}</style>`,""),l+=e}t='<div id="bay-temporary-compile-element"></div>'+t;let r=i.parseFromString(t,"text/html");function o(){r&&0===[...r.querySelectorAll("include")].length&&(customElements.get(e.toLowerCase())||C(r,e.toLowerCase(),a,l,!0))}r.getElementById("bay-temporary-compile-element").remove(),g(r,o),o()},window.bay.create=bay.create};bay();