import{LitElement as t,html as e,css as c}from"lit";import{iconRemixInformationFill as i}from"./assets/cc-remix.icons.js";import{ccLink as r,linkStyles as o}from"./templates/cc-link/cc-link.js";import{i18n as n}from"./translation.js";import"./cc-badge.js";import"./cc-block.js";import"./cc-notice.js";import"./cc-tcp-redirection.js";const s=[{type:"loading"},{type:"loading"}];class d extends t{static get properties(){return{context:{type:String},state:{type:Object}}}constructor(){super(),this.context="user",this.state={type:"loading"}}render(){const t="admin"===this.context?"close":"off";return e`<cc-block toggle=${t}><div slot=header-title>${n("cc-tcp-redirection-form.title")} ${this._renderRedirectionCountBadge()}</div><div slot=content class=content>${"user"===this.context?e`<div class=description>${n("cc-tcp-redirection-form.description")}</div>`:""} ${"error"===this.state.type?e`<cc-notice intent=warning message=${n("cc-tcp-redirection-form.error")}></cc-notice>`:""} ${"loading"===this.state.type?e`${s.map((t=>e`<cc-tcp-redirection .state=${t}></cc-tcp-redirection>`))}`:""} ${"loaded"===this.state.type?e`${this.state.redirections.map((t=>e`<cc-tcp-redirection .state=${t}></cc-tcp-redirection>`))} ${0===this.state.redirections.length?e`<div class=empty-msg>${n("cc-tcp-redirection-form.empty")}</div>`:""}`:""}</div><div slot=footer-right>${r("https://developers.clever-cloud.com/doc/administrate/tcp-redirections/",e`<cc-icon .icon=${i}></cc-icon>${n("cc-tcp-redirection-form.documentation.text")}`)}</div></cc-block>`}_renderRedirectionCountBadge(){if("admin"===this.context&&"loaded"===this.state.type){const t=this.state.redirections.filter((({sourcePort:t})=>null!=t)).length;if(t>=1)return e`<cc-badge circle weight=strong>${t}</cc-badge>`}return""}static get styles(){return[o,c`:host{display:block}cc-badge{font-size:.8em;margin-left:.5em;vertical-align:middle}.content{display:grid;gap:1em}.description{line-height:1.6}.description p{margin:0 0 1em}.description code{background-color:var(--cc-color-bg-neutral);border-radius:var(--cc-border-radius-default,.25em);font-family:var(--cc-ff-monospace);padding:.15em .3em}.empty-msg{color:var(--cc-color-text-weak);font-style:italic}[slot=footer-right] .cc-link{align-items:center;display:flex;gap:.5em}`]}}window.customElements.define("cc-tcp-redirection-form",d);export{d as CcTcpRedirectionForm};
//# sourceMappingURL=cc-tcp-redirection-form.js.map
