/**
 * Copyright 2019 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as e,css as t,html as s}from"../../lit/index.js";function camelCaseToDash(e){return e.replace(/([A-Z])/g,(e=>`-${e[0].toLowerCase()}`))}export function createSWC(a){let n=class SWC extends e{constructor(){super();for(let e in a.callbacks)this[e]=a.callbacks[e];for(let e in a.data.values)this[e]=a.data.values[e];setTimeout((()=>{a.deps.map((e=>{import(`../../${e}`)}))}),0)}static get tag(){return a.name}render(){return a.html(this,s)}static get styles(){return[t`
          /* this style helps ease FOUC w/ dynamic imports */
          :host *:not(:defined) {
            display: none;
          }
        `,a.css(this,t)]}static get properties(){let e={};for(let t in a.data.values){e[t]={type:typeof a.data.values[t]},e[t].type=e[t].type.charAt(0).toUpperCase()+e[t].type.slice(1);let s=camelCaseToDash(t);s!==t&&(e[t].attribute=s),a.data.reflect&&a.data.reflect.includes(t)&&(e[t].reflect=!0)}return{...super.properties,...e}}updated(e){super.updated&&super.updated(e),e.forEach(((e,t)=>{a.data.observe&&a.data.observe.forEach(((s,n)=>{if(s[0].includes(t)){let t;if(1===s[0].length)t=a.callbacks[s[1]](this[s[0][0]],e);else{let e=[];s[0].map((t=>{e.push(this[t])})),t=a.callbacks[s[1]](...e)}3==s.length&&(this[s[2]]=Array.isArray(t)?[...t]:t)}})),a.data.notify&&a.data.notify.includes(t)&&this.dispatchEvent(new CustomEvent(`${camelCaseToDash(t)}-changed`,{detail:{value:this[t]}}))}))}__applyWinEvents(e){if(a.events&&a.events.window)for(let t in a.events.window)window[(e?"add":"remove")+"EventListener"](t,a.callbacks[a.events.window[t]].bind(this))}firstUpdated(){if(a.events&&a.events.shadow)for(let e in a.events.shadow)for(let t in a.events.shadow[e])this.shadowRoot.querySelector(e).addEventListener(t,a.callbacks[a.events.shadow[e][t]].bind(this))}connectedCallback(){super.connectedCallback&&super.connectedCallback(),this.__applyWinEvents(!0)}disconnectedCallback(){this.__applyWinEvents(!1),super.disconnectedCallback&&super.disconnectedCallback()}haxProperties(){return{}}};return customElements.define(n.tag,n),n}