text: import{html as t,PolymerElement as e}from"../../../../@polymer/polymer/polymer-element.js";import"../../../../@polymer/polymer/lib/elements/dom-if.js";import"../../../../@polymer/iron-ajax/iron-ajax.js";import"../../../../@polymer/paper-toast/paper-toast.js";import"../../../lrnsys-button/lrnsys-button.js";class LrnappStudioProjectButton extends e{static get template(){return t`
        <style>
          :host {
            display: block;
          }
        </style>
        <template is="dom-if" if="[[createProjectsUrl]]">
          <lrnsys-button
            class$="[[classes]]"
            button-class$="[[classes]]"
            icon="[[icon]]"
            on-click="_createProject"
            label="Create project"
          ></lrnsys-button>
          <iron-ajax
            id="ajaxCreateStub"
            url="[[createProjectsUrl]]"
            method="POST"
            handle-as="json"
            on-response="_ajaxCreateStubHandler"
          ></iron-ajax>
        </template>
        <template is="dom-if" if="[[displayErrors]]">
          <paper-toast id="toast"></paper-toast>
        </template>
      `}static get tag(){return"lrnapp-studio-project-button"}static get properties(){return{elmslnCourse:{type:String},elmslnSection:{type:String},basePath:{type:String},csrfToken:{type:String},endPoint:{type:String},auto:{type:Boolean,reflectToAttribute:!0,value:!1,notify:!0},displayErrors:{type:Boolean,value:!0},createProjectsUrl:{type:String,value:null},classes:{type:String,value:""},icon:{type:String,value:""}}}ready(){super.ready(),this.createProjectsUrl=this.endPoint+"/api/projects/create-stub?token="+this.csrfToken}_createProject(){this.shadowRoot.querySelector("#ajaxCreateStub").generateRequest()}_ajaxCreateStubHandler(t){var e=t.detail.response.status,r=t.detail.response;if(201===e){var o=t.detail.response.data;o&&this.dispatchEvent(new CustomEvent("project-created",{bubbles:!0,cancelable:!0,composed:!0,detail:{project:o}}))}if(void 0!==r.errors){document.createElement("ul");var a="";r.errors.forEach((function(t){a=a+" "+t})),this.shadowRoot.querySelector("#toast").show(a)}}}window.customElements.define(LrnappStudioProjectButton.tag,LrnappStudioProjectButton);export{LrnappStudioProjectButton};