/**
 * Copyright 2021 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
class ShadowStyle extends HTMLElement{constructor(){super(),null!=this.getAttribute("evil")&&(Element.prototype._attachShadow=Element.prototype.attachShadow,Element.prototype.attachShadow=function(){return this._attachShadow({mode:"open"})},console.error("Leave us.."),console.warn("No, stay here. I'm in charge"),console.error("[laying a hand on the web component] Do you feel in charge?"),console.warn("..I've paid your APIs a small fortune."),console.error("And this gives you... power over me?"),console.warn("What is this.."),console.error("You APIs and web platform have been important, till now"),console.warn("What are you.."),console.error("I'm web standards' reckoning, here to end the ball of twine you've all been coding on."),console.warn("You .. you're evil."),console.error("I am nessecary evil")),this.cssMap={},this.style.display="none",this.processShadowText(this.innerText)}static get tag(){return"shadow-style"}async processShadowText(e){let o,t=new RegExp("(.*?)([^{])s*{s*([^}]*?)}","gim"),s=[];for(;o=t.exec(e);){let e=o[1].trim().replace(/\s\s+/g," ").split("::shadow"),t=e[0],a=e[1].replace("(","").replace(")","");this.cssMap[t]||(this.cssMap[t]={}),this.cssMap[t][a]?this.cssMap[t][a]+=o[3].trim().replace(/\s\s+/g," "):this.cssMap[t][a]=o[3].trim().replace(/\s\s+/g," "),s.push(customElements.whenDefined(t))}await Promise.all(s),setTimeout((()=>{for(var e in this.cssMap)this.getRootNode().querySelectorAll(e).forEach((o=>{let t=o;o.shadowRoot&&(t=o.shadowRoot);let s=globalThis.document.createElement("style");s.innerHTML="";for(let o in this.cssMap[e])s.innerHTML+=`${o} {${this.cssMap[e][o]}}`;t.appendChild(s)}))}),0)}}customElements.define(ShadowStyle.tag,ShadowStyle);export{ShadowStyle};