import{__decorate as t,__classPrivateFieldGet as e,__classPrivateFieldSet as s}from"../../_virtual/_tslib.js";import'./../../external/lit/external/@lit/reactive-element/reactive-element.js';import'./../../external/lit/external/lit-html/lit-html.js';import{LitElement as i}from'./../../external/lit-element/lit-element.js';import{customElement as n}from'./../../external/lit/external/@lit/reactive-element/decorators/custom-element.js';import{property as o}from'./../../external/lit/external/@lit/reactive-element/decorators/property.js';import{state as l}from'./../../external/lit/external/@lit/reactive-element/decorators/state.js';import{query as r}from'./../../external/lit/external/@lit/reactive-element/decorators/query.js';import{queryAssignedElements as a}from'./../../external/lit/external/@lit/reactive-element/decorators/query-assigned-elements.js';import{queryAssignedNodes as d}from'./../../external/lit/external/@lit/reactive-element/decorators/query-assigned-nodes.js';import{ifDefined as h}from'./../../external/lit/external/lit-html/directives/if-defined.js';import{classMap as m}from'./../../external/lit/external/lit-html/directives/class-map.js';import{debounce as p}from"../../common/helpers/events.js";import{BUTTON_TYPES as c,BUTTON_KINDS as u,BUTTON_SIZES as f,BUTTON_ICON_POSITION as y}from"./defs.js";import _ from"./button.scss.js";import{html as g}from'./../../external/lit-element/external/lit-html/lit-html.js';var k,v,b,E,M,w,$,O,S,W,j,C,P,R,A,I;let q=class extends i{constructor(){super(...arguments),k.set(this,this.attachInternals()),v.set(this,""),b.set(this,c.BUTTON),E.set(this,u.PRIMARY_APP),M.set(this,""),w.set(this,f.MEDIUM),$.set(this,y.CENTER),O.set(this,!1),S.set(this,!1),W.set(this,!1),j.set(this,""),C.set(this,""),P.set(this,void 0),R.set(this,void 0),A.set(this,void 0),I.set(this,void 0)}get internals(){return e(this,k,"f")}set internals(t){s(this,k,t,"f")}get description(){return e(this,v,"f")}set description(t){s(this,v,t,"f")}get type(){return e(this,b,"f")}set type(t){s(this,b,t,"f")}get kind(){return e(this,E,"f")}set kind(t){s(this,E,t,"f")}get href(){return e(this,M,"f")}set href(t){s(this,M,t,"f")}get size(){return e(this,w,"f")}set size(t){s(this,w,t,"f")}get iconPosition(){return e(this,$,"f")}set iconPosition(t){s(this,$,t,"f")}get iconOnly(){return e(this,O,"f")}set iconOnly(t){s(this,O,t,"f")}get disabled(){return e(this,S,"f")}set disabled(t){s(this,S,t,"f")}get destructive(){return e(this,W,"f")}set destructive(t){s(this,W,t,"f")}get value(){return e(this,j,"f")}set value(t){s(this,j,t,"f")}get name(){return e(this,C,"f")}set name(t){s(this,C,t,"f")}get formmethod(){return e(this,P,"f")}set formmethod(t){s(this,P,t,"f")}get _slottedEls(){return e(this,R,"f")}set _slottedEls(t){s(this,R,t,"f")}get _iconEls(){return e(this,A,"f")}set _iconEls(t){s(this,A,t,"f")}get _btnEl(){return e(this,I,"f")}set _btnEl(t){s(this,I,t,"f")}render(){const t={[u.PRIMARY_APP]:"primary-app",[u.PRIMARY_WEB]:"primary-web",[u.SECONDARY]:"secondary",[u.TERTIARY]:"tertiary"}[this.kind],e={button:!0,[`kd-btn--${t}${this.destructive?"-destructive":""}`]:!0,[`kd-btn--${t}`]:!this.destructive,"kd-btn--large":this.size===f.LARGE,"kd-btn--small":this.size===f.SMALL,"kd-btn--medium":this.size===f.MEDIUM,[`kd-btn--icon-${this.iconPosition}`]:!!this.iconPosition&&!this.iconOnly,"kd-btn--icon-center":this._iconEls.length&&this.iconOnly,"icon-only":this._iconEls.length&&this.iconOnly};return g`
      ${this.href&&""!==this.href?g`
            <a
              class=${m(e)}
              href=${this.href}
              ?disabled=${this.disabled}
              aria-label=${h(this.description)}
              title=${h(this.description)}
              @click=${t=>this.handleClick(t)}
            >
              <span>
                <slot @slotchange=${()=>this._handleSlotChange()}></slot>
                <slot
                  name="icon"
                  @slotchange=${()=>this._handleSlotChange()}
                ></slot>
              </span>
            </a>
          `:g`
            <button
              class=${m(e)}
              type=${this.type}
              ?disabled=${this.disabled}
              aria-label=${h(this.description)}
              title=${h(this.description)}
              name=${h(this.name)}
              value=${h(this.value)}
              formmethod=${h(this.formmethod)}
              @click=${t=>this.handleClick(t)}
            >
              <span>
                <slot @slotchange=${()=>this._handleSlotChange()}></slot>
                <slot
                  name="icon"
                  @slotchange=${()=>this._handleSlotChange()}
                ></slot>
              </span>
            </button>
          `}
    `}handleClick(t){this.internals.form&&("submit"===this.type?this.internals.form.requestSubmit():"reset"===this.type&&this.internals.form.reset());const e=new CustomEvent("on-click",{detail:{origEvent:t}});this.dispatchEvent(e)}_testIconOnly(){if(!this._iconEls.length)return!1;return!this._slottedEls.filter((t=>""!==t.textContent.trim())).filter((t=>!t.tagName||t.offsetParent)).length}_handleSlotChange(){this.iconOnly=this._testIconOnly(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),window.addEventListener("resize",p((()=>{this.iconOnly=this._testIconOnly()})))}disconnectedCallback(){window.removeEventListener("resize",p((()=>{this.iconOnly=this._testIconOnly()}))),super.disconnectedCallback()}};k=new WeakMap,v=new WeakMap,b=new WeakMap,E=new WeakMap,M=new WeakMap,w=new WeakMap,$=new WeakMap,O=new WeakMap,S=new WeakMap,W=new WeakMap,j=new WeakMap,C=new WeakMap,P=new WeakMap,R=new WeakMap,A=new WeakMap,I=new WeakMap,q.styles=[_],q.shadowRootOptions={...i.shadowRootOptions,delegatesFocus:!0},q.formAssociated=!0,t([l()],q.prototype,"internals",null),t([o({type:String})],q.prototype,"description",null),t([o({type:String})],q.prototype,"type",null),t([o({type:String})],q.prototype,"kind",null),t([o({type:String})],q.prototype,"href",null),t([o({type:String})],q.prototype,"size",null),t([o({type:String})],q.prototype,"iconPosition",null),t([l()],q.prototype,"iconOnly",null),t([o({type:Boolean,reflect:!0})],q.prototype,"disabled",null),t([o({type:Boolean,reflect:!0})],q.prototype,"destructive",null),t([o({type:String})],q.prototype,"value",null),t([o({type:String})],q.prototype,"name",null),t([o({type:String})],q.prototype,"formmethod",null),t([d()],q.prototype,"_slottedEls",null),t([a({slot:"icon"})],q.prototype,"_iconEls",null),t([r(".button")],q.prototype,"_btnEl",null),q=t([n("kd-button")],q);export{q as Button};
//# sourceMappingURL=button.js.map
