text: define(["exports","require","../../../lit-element/lit-element.js","../../utils/utils.js","../../../@polymer/iron-ajax/iron-ajax.js"],(function(e,t,i,s,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.CMSViews=void 0,t=babelHelpers.interopRequireWildcard(t);class CMSViews extends i.LitElement{static get styles(){return[i.css`
          :host {
            display: block;
            min-width: 112px;
            min-height: 112px;
            transition: 0.6s all ease;
            background-color: transparent;
          }
          #replacementcontent {
            visibility: visible;
            opacity: 1;
          }
          :host([loading]) {
            text-align: center;
          }
          :host([loading]) #replacementcontent {
            opacity: 0;
            visibility: hidden;
          }
        `]}render(){return i.html`
        <iron-ajax
          id="viewsrequest"
          method="GET"
          url="${this.viewsEndPoint}"
          handle-as="json"
          @last-response-changed="${this.viewsDataChanged}"
        ></iron-ajax>
        ${this.loading?i.html`
              <hexagon-loader
                item-count="4"
                loading
                size="small"
              ></hexagon-loader>
            `:i.html``}
        <span id="replacementcontent"><slot></slot></span>
      `}viewsDataChanged(e){this.viewsData=e.detail.value}static get tag(){return"cms-views"}constructor(){super(),this.loading=!1,this.viewsPrefix="[",this.viewsSuffix="]",new Promise((e,i)=>t.default(["../../hexagon-loader/hexagon-loader.js"],e,i))}updated(e){e.forEach((e,t)=>{["viewsName","viewsDisplay"].includes(t)&&(this.bodyData=this._generateBodyData(this.viewsName,this.viewsDisplay)),"bodyData"==t&&this._viewsChanged(this[t]),"viewsData"==t&&this._handleviewsResponse(this[t])})}static get properties(){return{loading:{type:Boolean,reflect:!0},viewsName:{type:String,reflect:!0,attribute:"views-name"},viewsDisplay:{type:String,reflect:!0,attribute:"views-display"},viewsEndPoint:{type:String,attribute:"views-end-point"},viewsPrefix:{type:String,attribute:"views-prefix"},viewsSuffix:{type:String,attribute:"views-suffix"},bodyData:{type:Object},viewsData:{type:String,attribute:"views-data"}}}_generateBodyData(e,t){if(null!==e&&""!==e)return{name:`${e}`,display:`${t}`}}_handleviewsResponse(e,t){if(null!==e&&void 0!==e.content){null!=document.getElementById("cmstokenidtolockonto")&&(document.getElementById("cmstokenidtolockonto").setAttribute("href",e.editEndpoint),document.getElementById("cmstokenidtolockonto").innerHTML=e.editText),(0,s.wipeSlot)(this);let t=document.createElement("span");t.innerHTML=e.content;let i=t.cloneNode(!0);this.appendChild(i),this.loading=!1}}_viewsChanged(e){void 0===e||""===e||this.loading||(void 0===this.viewsEndPoint&&void 0!==window.cmsviewsEndPoint&&(this.viewsEndPoint=window.cmsviewsEndPoint),this.viewsEndPoint&&(this.loading=!0,this.shadowRoot.querySelector("#viewsrequest").body=e,this.shadowRoot.querySelector("#viewsrequest").generateRequest()))}static get haxProperties(){return{canScale:!0,canPosition:!0,canEditSource:!1,gizmo:{title:"CMS View",description:"CMS views rendered on the backend",icon:"icons:view-module",color:"light-blue",groups:["CMS"],handles:[{type:"cmsviews",views:"views"}],meta:{author:"ELMS:LN"}},settings:{quick:[],configure:[{property:"viewsName",title:"Name",description:"Name of the view from our CMS",inputMethod:"textfield",icon:"editor:title"},{property:"viewsDisplay",title:"Display",description:"Display within that view from our CMS",inputMethod:"textfield",icon:"editor:title"}],advanced:[]},saveOptions:{wipeSlot:!0,unsetAttributes:["loading","views-data","body-data","views-end-point"]}}}postProcessgetHaxJSONSchema(e){return e.properties.__editThis={type:"string",component:{name:"a",properties:{id:"cmstokenidtolockonto",href:"",target:"_blank"},slot:"Edit this view"}},e}}e.CMSViews=CMSViews,window.customElements.define(CMSViews.tag,CMSViews)}));