import{__decorate as s}from"tslib";import{html as i}from"lit";import{state as t,property as e,customElement as l}from"lit/decorators.js";import{s as r}from"./nile-link.css.esm.js";import{H as a}from"../slot.esm.js";import{ifDefined as o}from"lit/directives/if-defined.js";import{classMap as n}from"lit/directives/class-map.js";import{N as m,s as c}from"../internal/nile-element.esm.js";import{A as h}from"../internal/accessibility/a11y.property.enum.esm.js";import{R as f}from"../internal/accessibility/role.enum.esm.js";import{A as d}from"../internal/accessibility/a11y.custom-value.enum.esm.js";import{A as p}from"../internal/accessibility/a11y.role.enum.esm.js";import{A as u}from"../internal/accessibility/a11y.state.enum.esm.js";let b=class extends m{constructor(){super(...arguments),this.hasSlotController=new a(this,"[default]","prefix","suffix"),this.hasFocus=!1,this.disabled=!1,this.button=!1}static get styles(){return[r]}connectedCallback(){super.connectedCallback(),this.handleHostClick=this.handleHostClick.bind(this),this.addEventListener("click",this.handleHostClick),this.emit("nile-init"),c(this,{[f.Role]:p.Link,[h.AriaLabel]:this.textContent?.trim()||d.Link})}updated(s){super.updated(s),s.has("disabled")&&c(this,{[u.AriaDisabled]:this.disabled})}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleHostClick),this.emit("nile-destroy")}handleHostClick(s){this.disabled&&(s.preventDefault(),s.stopImmediatePropagation(),s.stopPropagation())}handleBlur(){this.hasFocus=!1,this.emit("nile-blur")}handleFocus(){this.hasFocus=!0,this.emit("nile-focus")}handleClick(s){if(this.disabled)return s.preventDefault(),void s.stopPropagation()}render(){return i`
      <a
        part="base"
        href="${o(this.href)}"
        class=${n({link:!0,"link--disabled":this.disabled,link__button:this.button})}
        .disabled=${this.disabled}
        title=${this.title}
        aria-disabled=${this.disabled?"true":"false"}
        tabindex=${this.disabled?"-1":"0"}
        @blur=${this.handleBlur}
        @focus=${this.handleFocus}
        @click=${this.handleClick}
      >
        <slot name="prefix" part="prefix" class="link__prefix"></slot>
        <slot part="label" class="link__label"></slot>
        <slot name="suffix" part="suffix" class="link__suffix"></slot>
      </a>
    `}};s([t()],b.prototype,"hasFocus",void 0),s([e({type:Boolean,reflect:!0})],b.prototype,"disabled",void 0),s([e({type:Boolean})],b.prototype,"button",void 0),s([e({type:String})],b.prototype,"href",void 0),b=s([l("nile-link")],b);export{b as N};
