/**
 * Copyright 2019 The Pennsylvania State University
 * @license Apache-2.0, see License.md for full text.
 */
import{LitElement as t,html as i}from"../../../../../lit/index.js";import{store as e}from"../haxcms-site-store.js";import{autorun as s,toJS as a}from"../../../../../mobx/dist/mobx.esm.js";import"../../../../jwt-login/jwt-login.js";class HAXCMSBackendPHP extends t{static get tag(){return"haxcms-backend-php"}render(){return i`
      <jwt-login
        id="jwt"
        jwt="${this.jwt}"
        @jwt-changed="${this.jwtChanged}"
      ></jwt-login>
    `}jwtChanged(t){this.jwt=t.detail.value,e.jwt=this.jwt,e.cmsSiteEditor&&e.cmsSiteEditor.instance&&(e.cmsSiteEditor.instance.jwt=this.jwt),null!=this.jwt&&"null"!=this.jwt&&""!=this.jwt&&"string"==typeof this.jwt&&this.dynamicallyImportEditor()}firstUpdated(t){setTimeout((()=>{if(globalThis.appSettings){let t=this.shadowRoot.querySelector("#jwt");t.url=globalThis.appSettings.login,t.refreshUrl=globalThis.appSettings.refreshUrl,t.logoutUrl=globalThis.appSettings.logout,t.redirectUrl=globalThis.appSettings.redirectUrl,globalThis.appSettings.jwt&&(this.jwt=globalThis.appSettings.jwt)}null!=this.jwt&&"null"!=this.jwt&&""!=this.jwt&&"string"==typeof this.jwt?this.dynamicallyImportEditor():globalThis.dispatchEvent(new CustomEvent("haxcms-not-logged-in",{bubbles:!0,composed:!0,cancelable:!1,detail:this}))}),500)}constructor(){super(),this.__disposer=[],s((t=>{this.jwt=a(e.jwt),this.__disposer.push(t)}))}disconnectedCallback(){for(var t in this.__disposer)this.__disposer[t].dispose();super.disconnectedCallback()}static get properties(){return{jwt:{type:String}}}dynamicallyImportEditor(){try{import("../haxcms-site-editor.js").then((t=>{globalThis.appSettings&&(e.cmsSiteEditorAvailability(),e.cmsSiteEditor.instance.jwt=this.jwt,e.jwt=this.jwt,e.cmsSiteEditor.instance.saveNodePath=globalThis.appSettings.saveNodePath,e.cmsSiteEditor.instance.saveManifestPath=globalThis.appSettings.saveManifestPath,e.cmsSiteEditor.instance.saveOutlinePath=globalThis.appSettings.saveOutlinePath,e.cmsSiteEditor.instance.getSiteFieldsPath=globalThis.appSettings.getSiteFieldsPath,e.cmsSiteEditor.instance.getFormToken=globalThis.appSettings.getFormToken,e.cmsSiteEditor.instance.publishSitePath=globalThis.appSettings.publishSitePath,e.cmsSiteEditor.instance.syncSitePath=globalThis.appSettings.syncSitePath,e.cmsSiteEditor.instance.revertSitePath=globalThis.appSettings.revertSitePath,e.cmsSiteEditor.instance.createNodePath=globalThis.appSettings.createNodePath,e.cmsSiteEditor.instance.deleteNodePath=globalThis.appSettings.deleteNodePath,e.cmsSiteEditor.instance.getUserDataPath=globalThis.appSettings.getUserDataPath,e.cmsSiteEditor.instance.appStore=globalThis.appSettings.appStore)}),(t=>{}))}catch(t){}}}customElements.define(HAXCMSBackendPHP.tag,HAXCMSBackendPHP);export{HAXCMSBackendPHP};