/**
 * Copyright 2021 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{html as t,css as e}from"../../../../../lit/index.js";import{CleanTwo as o}from"../../../../clean-two/clean-two.js";import"../../ui-components/layout/site-footer.js";import"../../../../simple-icon/lib/simple-icon-button-lite.js";class HAXCMSPrintTheme extends o{render(){return t`
      <header>
        <simple-icon-button-lite
          @click="${this.print}"
          id="printbtn"
          icon="print"
        ></simple-icon-button-lite>
      </header>
      <main>
        <article>
          <section>
            <slot></slot>
          </section>
        </article>
      </main>
      <footer>
        <site-footer></site-footer>
      </footer>
    `}async print(t){this.shadowRoot.querySelector("#printbtn").style.display="none",globalThis.addEventListener("afterprint",(t=>{globalThis.close()})),globalThis.SimpleToast&&globalThis.SimpleToast.requestAvailability&&globalThis.SimpleToast.requestAvailability().hide(),globalThis.scrollBy({left:0,top:globalThis.document.body.scrollHeight,behavior:"smooth"}),setTimeout((()=>{globalThis.scrollTo(0,0),setTimeout((()=>{globalThis.document.close(),globalThis.focus(),globalThis.print()}),10)}),500)}firstUpdated(t){super.firstUpdated&&super.firstUpdated(t),globalThis.document.body.style.setProperty("--haxcms-color","white"),globalThis.document.body.style.overflow="auto",globalThis.SimpleToast&&globalThis.SimpleToast.requestAvailability&&globalThis.SimpleToast.requestAvailability().hide();const e=Array.from(globalThis.document.body.querySelectorAll("haxcms-print-theme replace-tag"));for(let t=0;t<e.length;t++)e[t].runReplacement();setTimeout((()=>{const t=Array.from(globalThis.document.body.querySelectorAll("haxcms-print-theme *"));for(let e=0;e<t.length;e++)t[e].elementVisible=!0}),250),setTimeout((()=>{this.shadowRoot.querySelector("#printbtn").focus()}),0)}static get styles(){return e`
      :host {
        display: block;
        margin: 20px;
      }
      #printbtn {
        position: fixed;
        top: 0;
        right: 0;
        color: black;
        width: 50px;
        height: 50px;
      }
    `}static get tag(){return"haxcms-print-theme"}}customElements.define(HAXCMSPrintTheme.tag,HAXCMSPrintTheme);export{HAXCMSPrintTheme};