import{ERROR_TYPES as e}from"@clevercloud/client/esm/utils/payment.js";import{LitElement as r,html as n,css as t}from"lit";import{i18n as a}from"./translation.js";import"./cc-link.js";import"./cc-notice.js";class i extends r{static get properties(){return{errors:{type:Array},mode:{type:String}}}constructor(){super(),this.errors=[{type:e.NO_PAYMENT_METHOD}],this.mode="billing"}_getOrgaError({type:r}){switch(r){case e.NO_PAYMENT_METHOD:return{title:a("cc-payment-warning.orga.no-payment-method.title"),errorMessage:a("cc-payment-warning.orga.no-payment-method")};case e.NO_DEFAULT_PAYMENT_METHOD:return{title:a("cc-payment-warning.orga.no-default-payment-method.title"),errorMessage:a("cc-payment-warning.orga.no-default-payment-method")};case e.DEFAULT_PAYMENT_METHOD_IS_EXPIRED:return{title:a("cc-payment-warning.orga.default-payment-method-is-expired.title"),errorMessage:a("cc-payment-warning.orga.default-payment-method-is-expired")};default:return{title:null,errorMessage:null}}}_getHomeError({type:r,orgaName:n}){switch(r){case e.NO_PAYMENT_METHOD:return a("cc-payment-warning.generic.no-payment-method",{orgaName:n});case e.NO_DEFAULT_PAYMENT_METHOD:return a("cc-payment-warning.generic.no-default-payment-method",{orgaName:n});case e.DEFAULT_PAYMENT_METHOD_IS_EXPIRED:return a("cc-payment-warning.generic.default-payment-method-is-expired",{orgaName:n})}}render(){switch(this.mode){case"home":return this._renderHomeWarning(this.errors);case"billing":case"overview":return this._renderOrgaWarning(this.errors[0])}}_renderOrgaWarning({type:e,orgaName:r,orgaBillingLink:t}){const{title:i,errorMessage:o}=this._getOrgaError({type:e}),g="overview"===this.mode?a("cc-payment-warning.billing-page-link",{orgaName:r,orgaBillingLink:t}):"";return n`
      <cc-notice .heading="${i}" intent="warning">
        <div slot="message">${o} ${g}</div>
      </cc-notice>
    `}_renderHomeWarning(e){return n`
      <cc-notice .heading="${a("cc-payment-warning.home.title")}" intent="warning">
        <div slot="message" class="error-container">
          <span>${a("cc-payment-warning.home",{orgaCount:this.errors.length})}</span>
          <ul>
            ${e.map((e=>n`
                <li>
                  ${this._getHomeError(e)}
                  ${a("cc-payment-warning.billing-page-link",{orgaName:e.orgaName,orgaBillingLink:e.orgaBillingLink})}
                </li>
              `))}
          </ul>
        </div>
      </cc-notice>
    `}static get styles(){return[t`
        :host {
          display: block;
        }

        ul {
          margin: 0.5em 0 0 1.5em;
          padding: 0;
        }

        li {
          margin-top: 0.5em;
        }
      `]}}window.customElements.define("cc-warning-payment",i);export{i as CcWarningPayment};
//# sourceMappingURL=cc-warning-payment.js.map
