import{LitElement as e,html as t,css as c}from"lit";import{iconRemixInformationFill as a}from"./assets/cc-remix.icons.js";import{fakeString as s}from"./lib/fake-strings.js";import{i18n as i}from"./translation.js";import"./cc-addon-credentials-content.js";import"./cc-block-details.js";import"./cc-block.js";import"./cc-code.js";import"./cc-input-text.js";import"./cc-link.js";import"./cc-loader.js";import"./cc-notice.js";import"./cc-toggle.js";class o extends e{static get properties(){return{state:{type:Object},_selectedTabName:{type:String,state:!0}}}constructor(){super(),this.state={type:"loading",tabs:{default:{content:[],docLink:{text:s(10),href:null}}}},this._selectedTabName="default"}_getToggleChoiceLabel(e){switch(e){case"admin":return i("cc-addon-credentials-beta.choice.admin");case"api":return i("cc-addon-credentials-beta.choice.api");case"apm":return i("cc-addon-credentials-beta.choice.apm");case"default":return i("cc-addon-credentials-beta.choice.default");case"direct":return i("cc-addon-credentials-beta.choice.direct");case"elastic":return i("cc-addon-credentials-beta.choice.elastic");case"kibana":return i("cc-addon-credentials-beta.choice.kibana");default:return""}}_getToggleChoices(e){return e.map((e=>({label:this._getToggleChoiceLabel(e),value:e})))}_onTabSelect({detail:e}){this._selectedTabName=e}willUpdate(){"loading"===this.state.type&&(this._selectedTabName=Object.keys(this.state.tabs)[0])}render(){if("error"===this.state.type)return t`<cc-notice message="${i("cc-addon-credentials-beta.error")}" intent="warning"></cc-notice>`;const e="loading"===this.state.type,c=Object.keys(this.state.tabs),s=this._getToggleChoices(c),o=this.state.tabs[this._selectedTabName]??Object.values(this.state.tabs)[0];return t`
      <cc-block>
        <div slot="header-title">${i("cc-addon-credentials-beta.heading")}</div>
        ${c.length>1?t`
              <cc-toggle
                .choices="${s}"
                .value="${this._selectedTabName}"
                @cc-select="${this._onTabSelect}"
                slot="header-right"
                ?disabled="${e}"
              ></cc-toggle>
            `:""}
        ${"loaded"===this.state.type||"loading"===this.state.type?t`
              <cc-addon-credentials-content
                .credentials="${o.content}"
                .skeleton="${e}"
                slot="content"
              ></cc-addon-credentials-content>
            `:""}
        <div slot="footer-right">
          <cc-link .href="${o.docLink.href}" .icon="${a}">${o.docLink.text}</cc-link>
        </div>
      </cc-block>
    `}static get styles(){return[c`
        :host {
          display: block;
        }

        cc-toggle {
          display: flex;
          flex-wrap: wrap;
        }
      `]}}customElements.define("cc-addon-credentials-beta",o);export{o as CcAddonCredentialsBeta};
//# sourceMappingURL=cc-addon-credentials-beta.js.map
