import { proxyCustomElement, HTMLElement, createEvent, forceUpdate, h, Host, Fragment } from '@stencil/core/internal/client';
import { h as handleHiddenFormButtonClick, r as removeDisabledFalse, b as inheritAttributes, d as renderFileHiddenInput, g as getBrandFromContext, I as IcBrandForegroundEnum, i as isSlotUsed } from './helpers.js';
import { I as IC_INHERITED_ARIA } from './constants.js';
import { d as defineCustomElement$3 } from './ic-loading-indicator2.js';
import { d as defineCustomElement$2 } from './ic-tooltip2.js';
import { d as defineCustomElement$1 } from './ic-typography2.js';

const arrowDropdown = `<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
    <path d="M7 9.5L12 14.5L17 9.5H7Z" fill="currentColor"/>
</svg>`;

const icButtonCss = "/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */html{line-height:1.15;-webkit-text-size-adjust:100%;}body{margin:0}main{display:block}h1{font-size:2em;margin:0.67em 0}hr{box-sizing:content-box;height:0;overflow:visible;}pre{font-family:monospace, monospace;font-size:1em;}a{background-color:transparent}abbr[title]{border-bottom:none;text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace, monospace;font-size:1em;}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-0.25em}sup{top:-0.5em}img{border-style:none}button,input,optgroup,select,textarea{font-family:inherit;font-size:100%;line-height:1.15;margin:0;}button,input{overflow:visible}button,select{text-transform:none}button,[type=\"button\"],[type=\"reset\"],[type=\"submit\"]{-webkit-appearance:button}button::-moz-focus-inner,[type=\"button\"]::-moz-focus-inner,[type=\"reset\"]::-moz-focus-inner,[type=\"submit\"]::-moz-focus-inner{border-style:none;padding:0}button:-moz-focusring,[type=\"button\"]:-moz-focusring,[type=\"reset\"]:-moz-focusring,[type=\"submit\"]:-moz-focusring{outline:1px dotted ButtonText}fieldset{padding:0.35em 0.75em 0.625em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal;}progress{vertical-align:baseline}textarea{overflow:auto}[type=\"checkbox\"],[type=\"radio\"]{box-sizing:border-box;padding:0;}[type=\"number\"]::-webkit-inner-spin-button,[type=\"number\"]::-webkit-outer-spin-button{height:auto}[type=\"search\"]{-webkit-appearance:textfield;outline-offset:-2px;}[type=\"search\"]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit;}details{display:block}summary{display:list-item}template{display:none}[hidden]{display:none}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font-size:100%;font-style:inherit;vertical-align:baseline}:host{display:inline-block;position:relative;--icon-width:100%;--icon-height:100%}.button,::slotted(a){font-family:var(--ic-font-body-family);text-decoration:none;font-weight:600;font-size:0.875rem;transition:var(--ic-easing-transition-fast);border-radius:var(--ic-border-radius);min-width:var(--min-width, 6.25rem);display:inline-flex;flex-direction:row;justify-content:center;align-items:center;background:none;border:none;box-sizing:border-box;white-space:nowrap;vertical-align:middle}:host(.with-badge) .button{border-radius:0.2188rem}.button:hover,::slotted(a:hover){cursor:pointer}.button:focus,::slotted(a:focus){box-shadow:var(--ic-border-focus)}.button:focus-visible,::slotted(a:focus-visible){outline:var(--ic-hc-focus-outline)}:host(.ic-button-disabled),:host(.ic-button-disabled) .button,:host(.ic-button-disabled) ::slotted(a),:host(.ic-button-loading),:host(.ic-button-loading) .button{pointer-events:none}:host(.top-icon) .button{flex-direction:column;--height:fit-content}:host(.top-icon) .button .icon-container{margin-right:0}:host(.ic-button-variant-primary) .button,:host(.ic-button-variant-icon-primary) .button{color:var(--ic-button-primary-text);background-color:var(--ic-button-primary-background)}:host(.ic-button-variant-primary:not(.ic-button-disabled)) ::slotted(svg){color:var(--ic-button-primary-icon)}:host(.ic-button-variant-primary) ::slotted(a),:host(.ic-button-variant-icon-primary) ::slotted(a){--ic-typography-color:var(--ic-button-primary-text);color:var(--ic-button-primary-text);background-color:var(--ic-button-primary-background) !important}:host(.ic-button-variant-primary) .button:hover,:host(.ic-button-variant-icon-primary) .button:hover{background-color:var(--ic-button-primary-background-hover)}:host(.ic-button-variant-primary) ::slotted(a:hover),:host(.ic-button-variant-icon-primary) ::slotted(a:hover){background-color:var(--ic-button-primary-background-hover) !important}:host(.ic-button-variant-primary.ic-button-loading) .button,:host(.ic-button-variant-primary) .button:active,:host(.ic-button-variant-icon-primary.ic-button-loading) .button,:host(.ic-button-variant-icon-primary) .button:active{background-color:var(--ic-button-primary-background-pressed);--button-loading-inner-color:var(--ic-button-primary-text);--button-loading-outer-color:var(--ic-button-primary-background-pressed)}:host(.ic-button-variant-primary) ::slotted(a:active),:host(.ic-button-variant-icon-primary) ::slotted(a:active){background-color:var(--ic-button-primary-background-pressed) !important}:host(.ic-button-variant-primary.ic-button-disabled) .button,:host(.ic-button-variant-icon-primary.ic-button-disabled) .button{background:var(--ic-button-primary-background-disabled);color:var(--ic-button-primary-text-disabled)}:host(.ic-button-variant-primary.ic-button-disabled) ::slotted(a),:host(.ic-button-variant-icon-primary.ic-button-disabled) ::slotted(a){background:var(--ic-button-primary-background-disabled) !important;--ic-typography-color:var(--ic-button-primary-text-disabled) !important;color:var(--ic-button-primary-text-disabled) !important}:host(.ic-button-variant-primary.monochrome) .button,:host(.ic-button-variant-icon-primary.monochrome) .button{color:var(--ic-button-primary-text-monochrome);background-color:var(--ic-button-primary-background-monochrome)}:host(.ic-button-variant-primary.monochrome) ::slotted(a),:host(.ic-button-variant-icon-primary.monochrome) ::slotted(a){background-color:var(--ic-button-primary-background-monochrome) !important}:host(.ic-button-variant-primary.monochrome) .button:hover,:host(.ic-button-variant-icon-primary.monochrome) .button:hover{background-color:var(--ic-button-primary-background-hover-monochrome)}:host(.ic-button-variant-primary.monochrome) ::slotted(a:hover),:host(.ic-button-variant-icon-primary.monochrome) ::slotted(a:hover){background-color:var(\n    --ic-button-primary-background-hover-monochrome\n  ) !important}:host(.ic-button-variant-primary.ic-button-loading.monochrome) .button,:host(.ic-button-variant-primary.monochrome) .button:active,:host(.ic-button-variant-icon-primary.ic-button-loading.monochrome) .button,:host(.ic-button-variant-icon-primary.monochrome) .button:active{background-color:var(--ic-button-primary-background-pressed-monochrome);--button-loading-inner-color:var(--ic-button-primary-text-monochrome);--button-loading-outer-color:var(--ic-button-primary-background-monochrome)}:host(.ic-button-variant-primary.monochrome) ::slotted(a:active),:host(.ic-button-variant-icon-primary.monochrome) ::slotted(a:active){background-color:var(\n    --ic-button-primary-background-pressed-monochrome\n  ) !important}:host(.ic-button-variant-primary.ic-button-disabled.monochrome) .button,:host(.ic-button-variant-icon-primary.ic-button-disabled.monochrome) .button{background-color:var(--ic-button-primary-background-disabled-monochrome);color:var(--ic-button-primary-text-disabled-monochrome)}:host(.ic-button-variant-primary.ic-button-disabled.monochrome) ::slotted(a),:host(.ic-button-variant-icon-primary.ic-button-disabled.monochrome) ::slotted(a){background-color:var(\n    --ic-button-primary-background-disabled-monochrome\n  ) !important}:host(.ic-button-variant-secondary) .button,:host(.ic-button-variant-icon-secondary) .button{border:var(--ic-border-width) solid var(--ic-button-secondary-border);color:var(--ic-button-secondary-text)}:host(.ic-button-variant-secondary) ::slotted(a),:host(.ic-button-variant-icon-secondary) ::slotted(a){border:var(--ic-border-width) solid var(--ic-button-secondary-border) !important;color:var(--ic-button-secondary-text) !important;--ic-typography-color:var(--ic-button-secondary-text) !important}:host(.ic-button-variant-secondary) .button:hover,:host(.ic-button-variant-icon-secondary) .button:hover{background-color:var(--ic-button-secondary-background-hover-active);border-color:var(--ic-button-secondary-border-hover);color:var(--ic-button-secondary-text-hover-active)}:host(.ic-button-variant-secondary) ::slotted(a:hover),:host(.ic-button-variant-icon-secondary) ::slotted(a:hover){background-color:var(\n    --ic-button-secondary-background-hover-active\n  ) !important}:host(.ic-button-variant-secondary) .button:active,:host(.ic-button-variant-icon-secondary) .button:active{border-color:var(--ic-button-secondary-border-pressed);background-color:var(--ic-button-secondary-background-pressed-active);color:var(--ic-button-secondary-text-pressed-active)}:host(.ic-button-variant-secondary) ::slotted(a:active),:host(.ic-button-variant-icon-secondary) ::slotted(a:active){background-color:var(\n    --ic-button-secondary-background-pressed-active\n  ) !important}:host(.ic-button-variant-secondary.ic-button-loading) .button,:host(.ic-button-variant-icon-secondary.ic-button-loading) .button{border-color:var(--ic-button-secondary-border-pressed);background-color:var(\n    --loading-button-background,\n    var(--ic-button-secondary-background-pressed-active)\n  ) !important;color:var(--ic-button-secondary-text-pressed-active);--button-loading-inner-color:var(--ic-button-secondary-border-pressed);--button-loading-outer-color:var(\n    --ic-button-secondary-background-pressed-active\n  )}:host(.ic-button-variant-secondary.ic-button-disabled) .button,:host(.ic-button-variant-icon-secondary.ic-button-disabled) .button{border-color:var(--ic-button-secondary-border-disabled);color:var(--ic-button-secondary-text-disabled);background:none}:host(.ic-button-variant-secondary.ic-button-disabled) ::slotted(a),:host(.ic-button-variant-icon-secondary.ic-button-disabled) ::slotted(a){background:none !important}:host(.ic-button-variant-secondary.background) .button,:host(.ic-button-variant-icon-secondary.background) .button{background-color:var(--ic-button-secondary-background)}:host(.ic-button-variant-secondary.background) ::slotted(a),:host(.ic-button-variant-icon-secondary.background) ::slotted(a){background-color:var(--ic-button-secondary-background) !important}:host(.ic-button-variant-secondary.background) .button:hover,:host(.ic-button-variant-icon-secondary.background) .button:hover{background-image:var(--ic-button-secondary-background-non-transparent-hover)}:host(.ic-button-variant-secondary.background) ::slotted(a:hover),:host(.ic-button-variant-icon-secondary.background) ::slotted(a:hover){background-image:var(\n    --ic-button-secondary-background-non-transparent-hover\n  ) !important}:host(.ic-button-variant-secondary.background) .button:active,:host(.ic-button-variant-icon-secondary.background) .button:active{background-image:var(\n    --ic-button-secondary-background-non-transparent-active\n  )}:host(.ic-button-variant-secondary.background) ::slotted(a:active),:host(.ic-button-variant-icon-secondary.background) ::slotted(a:active){background-image:var(\n    --ic-button-secondary-background-non-transparent-active\n  ) !important}:host(.ic-button-variant-secondary.monochrome) .button,:host(.ic-button-variant-icon-secondary.monochrome) .button{background-color:none;border:var(--ic-border-width) solid\n    var(--ic-button-secondary-border-monochrome);color:var(--ic-button-secondary-text-monochrome)}:host(.ic-button-variant-secondary.monochrome) ::slotted(a),:host(.ic-button-variant-icon-secondary.monochrome) ::slotted(a){background-color:none !important}:host(.ic-button-variant-secondary.monochrome) .button:hover,:host(.ic-button-variant-icon-secondary.monochrome) .button:hover{background-color:var(--ic-button-secondary-background-hover-monochrome);border-color:var(--ic-button-secondary-border-hover-monochrome);color:var(--ic-button-secondary-text-hover-monochrome)}:host(.ic-button-variant-secondary.monochrome) ::slotted(a:hover),:host(.ic-button-variant-icon-secondary.monochrome) ::slotted(a:hover){background-color:var(\n    --ic-button-secondary-background-hover-monochrome\n  ) !important}:host(.ic-button-variant-secondary.monochrome) .button:active,:host(.ic-button-variant-icon-secondary.monochrome) .button:active{background-color:var(--ic-button-secondary-background-pressed-monochrome);border-color:var(--ic-button-secondary-border-pressed-monochrome);color:var(--ic-button-secondary-text-pressed-monochrome)}:host(.ic-button-variant-secondary.monochrome) ::slotted(a:active),:host(.ic-button-variant-icon-secondary.monochrome) ::slotted(a:active){background-color:var(\n    --ic-button-secondary-background-pressed-monochrome\n  ) !important}:host(.ic-button-variant-secondary.ic-button-loading.monochrome) .button,:host(.ic-button-variant-icon-secondary.ic-button-loading.monochrome) .button{background-color:var(\n    --ic-button-secondary-background-pressed-monochrome\n  ) !important;border-color:var(--ic-button-secondary-border-pressed-monochrome);color:var(--ic-button-secondary-text-pressed-monochrome);--button-loading-inner-color:var(\n    --ic-button-secondary-text-pressed-monochrome\n  );--button-loading-outer-color:var(\n    --ic-button-secondary-background-pressed-monochrome\n  )}:host(.ic-button-variant-secondary.ic-button-disabled.monochrome) .button,:host(.ic-button-variant-icon-secondary.ic-button-disabled.monochrome) .button{background:none;border-color:var(--ic-button-secondary-border-disabled-monochrome);color:var(--ic-button-secondary-text-disabled-monochrome)}:host(.ic-button-variant-secondary.ic-button-disabled.monochrome) ::slotted(a),:host(.ic-button-variant-icon-secondary.ic-button-disabled.monochrome) ::slotted(a){background:none !important}:host(.ic-button-variant-secondary.background.monochrome) .button,:host(.ic-button-variant-icon-secondary.background.monochrome) .button{background-color:var(--ic-button-secondary-background-monochrome)}:host(.ic-button-variant-secondary.background.monochrome) ::slotted(a),:host(.ic-button-variant-icon-secondary.background.monochrome) ::slotted(a){background-color:var(--ic-button-secondary-background-monochrome) !important}:host(.ic-button-variant-secondary.background.monochrome) .button:hover,:host(.ic-button-variant-icon-secondary.background.monochrome) .button:hover{background-image:var(\n    --ic-button-secondary-background-non-transparent-monochrome-hover\n  )}:host(.ic-button-variant-secondary.background.monochrome) ::slotted(a:hover),:host(.ic-button-variant-icon-secondary.background.monochrome) ::slotted(a:hover){background-image:var(\n    --ic-button-secondary-background-non-transparent-monochrome-hover\n  ) !important}:host(.ic-button-variant-secondary.background.monochrome) .button:active,:host(.ic-button-variant-icon-secondary.background.monochrome) .button:active{background-image:var(\n    --ic-button-secondary-background-non-transparent-monochrome-active\n  )}:host(.ic-button-variant-secondary.background.monochrome) ::slotted(a:active),:host(.ic-button-variant-icon-secondary.background.monochrome) ::slotted(a:active){background-image:var(\n    --ic-button-secondary-background-non-transparent-monochrome-active\n  ) !important}:host(.ic-button-variant-tertiary) .button,:host(.ic-button-variant-icon-tertiary) .button,:host(.ic-button-variant-tertiary) ::slotted(a),:host(.ic-button-variant-icon-tertiary) ::slotted(a){color:var(--ic-button-tertiary-text-active);--ic-typography-color:var(--ic-button-tertiary-text-active)}:host(.ic-button-variant-tertiary) .button:hover,:host(.ic-button-variant-icon-tertiary) .button:hover{background-color:var(--ic-button-tertiary-background-hover-active);color:var(--ic-button-tertiary-text-hover-active)}:host(.ic-button-variant-tertiary) ::slotted(a:hover),:host(.ic-button-variant-icon-tertiary) ::slotted(a:hover){background-color:var(\n    --ic-button-tertiary-background-hover-active\n  ) !important}:host(.ic-button-variant-tertiary) .button:active,:host(.ic-button-variant-tertiary.ic-button-loading) .button,:host(.ic-button-variant-icon-tertiary) .button:active,:host(.ic-button-variant-icon-tertiary.ic-button-loading) .button{background-color:var(--ic-button-tertiary-background-pressed-active);color:var(--ic-button-tertiary-text-pressed-active);--button-loading-inner-color:var(--ic-button-tertiary-text-pressed-active);--button-loading-outer-color:var(--ic-button-tertiary-background-pressed)}:host(.ic-button-variant-tertiary) ::slotted(a:active),:host(.ic-button-variant-icon-tertiary) ::slotted(a:active){background-color:var(\n    --ic-button-tertiary-background-pressed-active\n  ) !important}:host(.ic-button-variant-tertiary.ic-button-disabled) .button,:host(.ic-button-variant-icon-tertiary.ic-button-disabled) .button{color:var(--ic-button-tertiary-text-disabled);background:none}:host(.ic-button-variant-tertiary.ic-button-disabled) ::slotted(a),:host(.ic-button-variant-icon-tertiary.ic-button-disabled) ::slotted(a){background:none !important}:host(.ic-button-variant-tertiary.background) .button,:host(.ic-button-variant-icon-tertiary.background) .button{background-color:var(--ic-button-tertiary-background)}:host(.ic-button-variant-tertiary.background) ::slotted(a),:host(.ic-button-variant-icon-tertiary.background) ::slotted(a){background-color:var(--ic-button-tertiary-background) !important}:host(.ic-button-variant-tertiary.background) .button:hover,:host(.ic-button-variant-icon-tertiary.background) .button:hover{background-image:var(--ic-button-tertiary-background-non-transparent-hover)}:host(.ic-button-variant-tertiary.background) ::slotted(a:hover),:host(.ic-button-variant-icon-tertiary.background) ::slotted(a:hover){background-image:var(\n    --ic-button-tertiary-background-non-transparent-hover\n  ) !important}:host(.ic-button-variant-tertiary.background) .button:active,:host(.ic-button-variant-icon-tertiary.background) .button:active{background-image:var(--ic-button-tertiary-background-non-transparent-active)}:host(.ic-button-variant-tertiary.background) ::slotted(a:active),:host(.ic-button-variant-icon-tertiary.background) ::slotted(a:active){background-image:var(\n    --ic-button-tertiary-background-non-transparent-active\n  ) !important}:host(.ic-button-variant-tertiary.monochrome) .button,:host(.ic-button-variant-tertiary.monochrome) ::slotted(a),:host(.ic-button-variant-icon-tertiary.monochrome) .button,:host(.ic-button-variant-icon-tertiary.monochrome) ::slotted(a){color:var(--ic-button-tertiary-text-monochrome);--ic-typography-color:var(--ic-button-tertiary-text-monochrome)}:host(.ic-button-variant-tertiary.monochrome) .button:hover,:host(.ic-button-variant-icon-tertiary.monochrome) .button:hover{background-color:var(--ic-button-tertiary-background-hover-monochrome);color:var(--ic-button-tertiary-text-hover-monochrome)}:host(.ic-button-variant-tertiary.monochrome) ::slotted(a:hover),:host(.ic-button-variant-icon-tertiary.monochrome) ::slotted(a:hover){background-color:var(\n    --ic-button-tertiary-background-hover-monochrome\n  ) !important}:host(.ic-button-variant-tertiary.monochrome) .button:active,:host(.ic-button-variant-tertiary.ic-button-loading.monochrome) .button,:host(.ic-button-variant-icon-tertiary.monochrome) .button:active,:host(.ic-button-variant-icon-tertiary.ic-button-loading.monochrome) .button{background-color:var(--ic-button-tertiary-background-pressed-monochrome);color:var(--ic-button-tertiary-text-pressed-monochrome);--button-loading-inner-color:var(\n    --ic-button-tertiary-text-pressed-monochrome\n  );--button-loading-outer-color:var(\n    --ic-button-tertiary-background-pressed-monochrome\n  )}:host(.ic-button-variant-tertiary.monochrome) ::slotted(a:active),:host(.ic-button-variant-icon-tertiary.monochrome) ::slotted(a:active){background-color:var(\n    --ic-button-tertiary-background-pressed-monochrome\n  ) !important}:host(.ic-button-variant-tertiary.ic-button-disabled.monochrome) .button,:host(.ic-button-variant-icon-tertiary.ic-button-disabled.monochrome) .button{color:var(--ic-button-tertiary-text-disabled-monochrome);background:none}:host(.ic-button-variant-tertiary.ic-button-disabled.monochrome) ::slotted(a),:host(.ic-button-variant-icon-tertiary.ic-button-disabled.monochrome) ::slotted(a){background:none !important}:host(.ic-button-variant-tertiary.background.monochrome) .button,:host(.ic-button-variant-icon-tertiary.background.monochrome) .button{background-color:var(--ic-button-tertiary-background-monochrome)}:host(.ic-button-variant-tertiary.background.monochrome) ::slotted(a),:host(.ic-button-variant-icon-tertiary.background.monochrome) ::slotted(a){background-color:var(--ic-button-tertiary-background-monochrome) !important}:host(.ic-button-variant-tertiary.background.monochrome) .button:hover,:host(.ic-button-variant-icon-tertiary.background.monochrome) .button:hover{background-image:var(\n    --ic-button-tertiary-background-non-transparent-monochrome-hover\n  )}:host(.ic-button-variant-tertiary.background.monochrome) ::slotted(a:hover),:host(.ic-button-variant-icon-tertiary.background.monochrome) ::slotted(a:hover){background-image:var(\n    --ic-button-tertiary-background-non-transparent-monochrome-hover\n  ) !important}:host(.ic-button-variant-tertiary.background.monochrome) .button:active,:host(.ic-button-variant-icon-tertiary.background.monochrome) .button:active{background-image:var(\n    --ic-button-tertiary-background-non-transparent-monochrome-active\n  )}:host(.ic-button-variant-tertiary.background.monochrome) ::slotted(a:active),:host(.ic-button-variant-icon-tertiary.background.monochrome) ::slotted(a:active){background-image:var(\n    --ic-button-tertiary-background-non-transparent-monochrome-active\n  ) !important}:host(.ic-button-variant-destructive) .button,:host(.ic-button-variant-icon-destructive) .button{color:var(--ic-button-destructive-text);background-color:var(--ic-button-destructive-background);text-transform:uppercase}:host(.ic-button-variant-destructive) ::slotted(a),:host(.ic-button-variant-icon-destructive) ::slotted(a){color:var(--ic-button-destructive-text) !important;--ic-typography-color:var(--ic-button-destructive-text) !important;background-color:var(--ic-button-destructive-background) !important;text-transform:uppercase !important}:host(.ic-button-variant-destructive) .button:hover,:host(.ic-button-variant-icon-destructive) .button:hover{background-color:var(--ic-button-destructive-background-hover)}:host(.ic-button-variant-destructive) ::slotted(a:hover),:host(.ic-button-variant-icon-destructive) ::slotted(a:hover){background-color:var(--ic-button-destructive-background-hover) !important}:host(.ic-button-variant-destructive) .button:active,:host(.ic-button-variant-destructive.ic-button-loading) .button,:host(.ic-button-variant-icon-destructive.ic-button-loading) .button{color:var(--ic-button-primary-text);background-color:var(--ic-button-destructive-background-pressed);--button-loading-inner-color:var(--ic-button-primary-text);--button-loading-outer-color:var(--ic-button-destructive-background-pressed)}:host(.ic-button-variant-destructive) ::slotted(a:active),:host(.ic-button-variant-icon-destructive) ::slotted(a:active){background-color:var(--ic-button-destructive-background-pressed) !important}:host(.ic-button-variant-destructive.ic-button-disabled) .button,:host(.ic-button-variant-icon-destructive.ic-button-disabled) .button{background-color:var(--ic-button-destructive-background-disabled);color:var(--ic-button-destructive-text-disabled)}:host(.ic-button-variant-destructive.ic-button-disabled) ::slotted(a),:host(.ic-button-variant-icon-destructive.ic-button-disabled) ::slotted(a){background-color:var(--ic-button-destructive-background-disabled) !important}:host(.ic-button-variant-icon) .button{color:var(--ic-button-icon-color);background-color:var(--ic-button-icon-color-background);min-width:0;gap:var(--ic-space-xs)}:host(.ic-button-variant-icon) ::slotted(a){color:var(--ic-button-icon-color);background-color:var(--ic-button-icon-color-background) !important;min-width:0;gap:var(--ic-space-xs)}:host(.ic-button-variant-icon) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important}:host(.ic-button-variant-icon) .button:hover{color:var(--ic-button-icon-color-hover);background-color:var(--ic-button-icon-color-background-hover)}:host(.ic-button-variant-icon) ::slotted(a:hover){color:var(--ic-button-icon-color-hover);background-color:var(--ic-button-icon-color-background-hover) !important}:host(.ic-button-variant-icon) .button:active:not(:focus),:host(.ic-button-variant-icon.ic-button-loading) .button{color:var(--ic-button-icon-color-active);background-color:var(--ic-button-icon-color-background-active)}:host(.ic-button-variant-icon) ::slotted(a:active:not(:focus)){color:var(--ic-button-icon-color-active);background-color:var(--ic-button-icon-color-background-active) !important}:host(.ic-button-variant-icon.ic-button-disabled) .button{color:var(--ic-color-icon-disabled-mid);background:none}:host(.ic-button-variant-icon.ic-button-disabled) ::slotted(a){color:var(--ic-color-icon-disabled-mid);background:none !important}:host(.ic-button-variant-icon-primary) .button,:host(.ic-button-variant-icon-primary) ::slotted(a){min-width:0;gap:var(--ic-space-xs);color:var(--ic-button-primary-icon)}:host(.ic-button-variant-icon-primary.monochrome) .button,:host(.ic-button-variant-primary.monochrome:not(.ic-button-disabled)) ::slotted(svg){color:var(--ic-button-primary-icon-monochrome)}:host(.ic-button-variant-icon-primary) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important;margin:0;pointer-events:none}:host(.ic-button-variant-icon.monochrome) ::slotted(a),:host(.ic-button-variant-icon.monochrome) ::slotted(svg){color:var(--ic-button-icon-monochrome)}:host(.ic-button-variant-icon-secondary) .button,:host(.ic-button-variant-icon-secondary) ::slotted(a){min-width:0;gap:var(--ic-space-xs)}:host(.ic-button-variant-icon-secondary) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important;margin:0;pointer-events:none}:host(.ic-button-variant-icon-tertiary) .button,:host(.ic-button-variant-icon-tertiary) ::slotted(a){min-width:0;gap:var(--ic-space-xs)}:host(.ic-button-variant-icon-tertiary) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important;margin:0;pointer-events:none}:host(.ic-button-variant-icon-destructive) .button,:host(.ic-button-variant-icon-destructive) ::slotted(a){min-width:0;gap:var(--ic-space-xs)}:host(.ic-button-variant-icon-destructive) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important;margin:0;pointer-events:none}:host(.ic-button-size-medium) .button{height:var(--height, 2.5rem);padding:var(--ic-space-xs) var(--ic-space-md)}:host(.ic-button-size-medium) ::slotted(a){height:var(--height, 2.5rem) !important;padding:var(--ic-space-xs) var(--ic-space-md) !important}:host(.ic-button-size-small) .button{height:var(--height, var(--ic-space-xl));padding:var(--ic-space-xxs) var(--ic-space-md)}:host(.ic-button-size-small) ::slotted(a){height:var(--height, var(--ic-space-xl)) !important;padding:var(--ic-space-xxs) var(--ic-space-md) !important}:host(.ic-button-size-large) .button{height:var(--height, var(--ic-space-xxl));padding:var(--ic-space-sm) var(--ic-space-md)}:host(.ic-button-size-large) ::slotted(a){height:var(--height, var(--ic-space-xxl)) !important;padding:var(--ic-space-sm) var(--ic-space-md) !important}:host(.ic-button-size-medium.ic-button-variant-icon) .button,:host(.ic-button-size-medium.ic-button-variant-icon-primary) .button,:host(.ic-button-size-medium.ic-button-variant-icon-secondary) .button,:host(.ic-button-size-medium.ic-button-variant-icon-tertiary) .button,:host(.ic-button-size-medium.ic-button-variant-icon-destructive) .button{height:var(--height, var(--ic-space-xl));width:var(--ic-space-xl);padding:0.375rem}:host(.ic-button-size-medium.ic-button-variant-icon-primary) ::slotted(a),:host(.ic-button-size-medium.ic-button-variant-icon-secondary) ::slotted(a),:host(.ic-button-size-medium.ic-button-variant-icon-tertiary) ::slotted(a),:host(.ic-button-size-medium.ic-button-variant-icon-destructive) ::slotted(a){height:var(--height, var(--ic-space-xl)) !important;width:var(--ic-space-xl) !important;padding:0.375rem !important}:host(.ic-button-size-small.ic-button-variant-icon) .button,:host(.ic-button-size-small.ic-button-variant-icon-primary) .button,:host(.ic-button-size-small.ic-button-variant-icon-secondary) .button,:host(.ic-button-size-small.ic-button-variant-icon-tertiary) .button,:host(.ic-button-size-small.ic-button-variant-icon-destructive) .button{height:var(--height, var(--ic-space-lg));width:var(--ic-space-lg);padding:var(--ic-space-xxs)}:host(.ic-button-size-small.ic-button-variant-icon-primary) ::slotted(a),:host(.ic-button-size-small.ic-button-variant-icon-secondary) ::slotted(a),:host(.ic-button-size-small.ic-button-variant-icon-tertiary) ::slotted(a),:host(.ic-button-size-small.ic-button-variant-icon-destructive) ::slotted(a),:host(.ic-button-size-small.ic-button-variant-icon) ::slotted(a){height:var(--height, var(--ic-space-lg)) !important;width:var(--ic-space-lg) !important;padding:var(--ic-space-xxs) !important}:host(.ic-button-size-large.ic-button-variant-icon) .button,:host(.ic-button-size-large.ic-button-variant-icon-primary) .button,:host(.ic-button-size-large.ic-button-variant-icon-secondary) .button,:host(.ic-button-size-large.ic-button-variant-icon-tertiary) .button,:host(.ic-button-size-large.ic-button-variant-icon-destructive) .button{height:var(--height, 2.5rem);width:2.5rem;padding:var(--ic-space-xs)}:host(.ic-button-size-large.ic-button-variant-icon-destructive) .button,:host(.ic-button-size-large.ic-button-variant-icon-primary) ::slotted(a),:host(.ic-button-size-large.ic-button-variant-icon-secondary) ::slotted(a),:host(.ic-button-size-large.ic-button-variant-icon-tertiary) ::slotted(a),:host(.ic-button-size-large.ic-button-variant-icon-destructive) ::slotted(a),:host(.ic-button-size-large.ic-button-variant-icon) ::slotted(a){height:var(--height, 2.5rem) !important;width:2.5rem !important;padding:var(--ic-space-xs) !important}:host(.ic-button-full-width),:host(.ic-button-full-width) .button{width:100%}:host(.ic-button-full-width) ::slotted(a){width:100% !important}div.loading-container{position:relative;align-items:center;width:100%}.loading-indicator-icon-button{--circular-diameter:var(--ic-space-md)}:host(.ic-button-size-small) .loading-indicator-icon-button{--circular-diameter:calc(var(--ic-space-sm) + var(--ic-space-xxxs))}:host(.ic-button-size-large) .loading-indicator-icon-button{--circular-diameter:calc(var(--ic-space-sm) + var(--ic-space-xs))}ic-loading-indicator{--inner-color:var(--button-loading-inner-color);--outer-color:var(--button-loading-outer-color), transparent}@keyframes loading-animation{0%{width:0%;left:0%}25%{width:0%;left:0%;opacity:0}50%{width:100%;left:0%;opacity:1}75%{width:0%;left:100%}100%{width:0%;left:100%;opacity:0}}div.icon-container{box-sizing:border-box;width:var(--ic-space-lg);height:var(--ic-space-lg);display:flex;justify-content:center;align-items:center;margin-right:var(--ic-space-xs)}div.right-icon{margin-right:auto;margin-left:var(--ic-space-xs)}:host(.ic-button-full-width) .right-icon{margin-right:var(--ic-space-xs)}::slotted(:not(ic-badge)){width:var(--icon-width) !important;height:var(--icon-height) !important;fill:currentcolor !important;pointer-events:none}:host(.ic-button-variant-icon) .button .icon-container{margin:0;pointer-events:none}:host(.search-submit-button) ::slotted(svg){--icon-height:1.25rem;--icon-width:1.25rem;color:var(--ic-atoms-input-search-button)}:host(.search-submit-button-small) ::slotted(svg){--icon-height:1rem;--icon-width:1rem;color:var(--ic-atoms-input-search-button)}:host(.search-submit-button) .button:focus{box-shadow:none}:host(.search-submit-button) .button:not(:active):focus{box-shadow:none;background-color:var(--ic-action-default-bg-hover)}:host(.search-submit-button) .button:not(:active):focus ::slotted(svg){color:var(--ic-button-primary-text)}:host(.search-submit-button){display:flex;align-items:center;margin:0 var(--ic-space-xxs)}:host(.ic-button-variant-icon) .button,:host(.ic-button-variant-icon) ::slotted(a){background-color:inherit;min-width:0;gap:var(--ic-space-xs)}:host(.button-variant-icon) .button,:host(.button-variant-icon) ::slotted(a){color:var(--button-default);min-width:0;gap:var(--ic-space-xs)}:host(.button-variant-icon) .icon-container{width:var(--ic-space-lg) !important;height:var(--ic-space-lg) !important}:host(.button-variant-icon) .button:hover,:host(.button-variant-icon) ::slotted(a:hover){background-color:var(--button-default-background-hover);color:var(--button-default-hover)}:host(.button-variant-icon) .button:active:not(:focus),:host(.button-variant-icon) ::slotted(a:active:not(:focus)),:host(.button-variant-icon.loading) .button{background-color:var(--button-default-background-active);color:var(--button-default-active)}:host(.button-variant-icon.disabled) .button,:host(.button-variant-icon.disabled) ::slotted(a){color:var(--ic-color-icon-disabled-mid);background:none}:host(.clear-button){color:var(--ic-atoms-input-clear-button);margin:0 var(--ic-space-xxs)}:host(.clear-button) .button:focus,:host(.calendar-button) .button:focus,:host(.clock-button) .button:focus{box-shadow:none}:host(.clear-button) .button,:host(.clear-button) ::slotted(a){background-color:inherit;color:var(--ic-atoms-input-clear-button)}:host(.clear-button) .button:hover,:host(.clear-button) ::slotted(a:hover){color:var(--ic-atoms-input-clear-button)}:host(.clear-button) .button:not(:active):focus ::slotted(svg){background-color:var(--ic-atoms-input-clear-button-focus-inner);color:var(--ic-button-primary-text);}:host(.menu-close-button) ::slotted(svg){--icon-height:0.875rem;--icon-width:0.875rem;color:var(--ic-top-navigation-icon-active)}:host(.popout-menu-button) .button{height:var(--height);justify-content:left;border-radius:0;white-space:pre-line;text-align:start}:host(.popout-menu-button) div.icon-container{flex:none}:host(.popout-menu-button) .button:focus{box-shadow:var(--ic-border-focus-inset);border-radius:var(--ic-border-radius-inset)}.ic-button-describedby{display:none}:host .ic-tooltip{display:block}:host .arrow-dropdown{margin-top:auto}:host .dropdown-expanded{transform:rotate(180deg);margin-bottom:var(--ic-space-xxxs)}:host(.dropdown-no-icon) .button{padding-right:var(--ic-space-xs)}slot[name=\"router-item\"]::slotted(a){pointer-events:all}::slotted(a){font-size:0.875rem !important;border:none !important;vertical-align:middle !important}:host(#menu-button.ic-theme-dark){--ic-button-secondary-background-hover-monochrome:var(\n    --ic-action-dark-bg-hover\n  );--ic-button-secondary-background-pressed-monochrome:var(\n    --ic-action-dark-bg-pressed\n  );--ic-button-secondary-text-hover-monochrome:var(\n    --ic-action-monochrome-hover-dark\n  );--ic-button-secondary-text-pressed-monochrome:var(\n    --ic-action-monochrome-pressed-dark\n  );--ic-button-secondary-border-hover-monochrome:var(\n    --ic-color-border-neutral-hover-dark\n  );--ic-button-secondary-border-pressed-monochrome:var(\n    --ic-color-border-neutral-pressed-dark\n  )}:host(#menu-button.ic-theme-light){--ic-button-secondary-background-hover-monochrome:var(\n    --ic-action-light-bg-hover\n  );--ic-button-secondary-background-pressed-monochrome:var(\n    --ic-action-light-bg-pressed\n  );--ic-button-secondary-text-hover-monochrome:var(\n    --ic-action-monochrome-hover\n  );--ic-button-secondary-text-pressed-monochrome:var(\n    --ic-action-monochrome-pressed\n  );--ic-button-secondary-border-hover-monochrome:var(\n    --ic-color-border-neutral-hover-light\n  );--ic-button-secondary-border-pressed-monochrome:var(\n    --ic-color-border-neutral-default\n  )}@media (forced-colors: active){.button,::slotted(a){border:0.125rem solid transparent !important}.search-submit-button ::slotted(a),.ic-button-variant-icon ::slotted(a),.clear-button ::slotted(a),.search-submit-button ::slotted(svg),.ic-button-variant-icon ::slotted(svg),.clear-button ::slotted(svg){color:HighlightText}:host(.ic-button-variant-icon.monochrome) ::slotted(a),:host(.ic-button-variant-icon.monochrome) ::slotted(svg){color:white}:host(.clear-button) .button:not(:active):focus ::slotted(svg){color:white !important;background-color:inherit}:host(.ic-button-variant-primary:not(.ic-button-disabled)) ::slotted(svg){color:currentcolor !important}}@media (prefers-reduced-motion: reduce){.button,::slotted(a){transition:none}}:host(.flip) ::slotted(svg){transform:scaleX(-1)}";
const IcButtonStyle0 = icButtonCss;

var __rest = (undefined && undefined.__rest) || function (s, e) {
    var t = {};
    for (var p in s)
        if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
            t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
let buttonIds = 0;
const Button = /*@__PURE__*/ proxyCustomElement(class Button extends HTMLElement {
    constructor() {
        super();
        this.__registerHost();
        this.__attachShadow();
        this.icBlur = createEvent(this, "icBlur", 7);
        this.icFileSelection = createEvent(this, "icFileSelection", 7);
        this.icFocus = createEvent(this, "icFocus", 7);
        this.buttonIdNum = buttonIds++;
        this.hasTooltip = false;
        this.inheritedAttributes = {};
        this.describedbyEl = null;
        this.mutationObserver = null;
        this.hostMutationObserver = null;
        this.ariaLabel = "";
        this.title = "";
        /**
         * If `fileUpload` is set to `true`, this is the accepted list of file types.
         */
        this.accept = "*";
        /**
         * If `true`, the button will be in disabled state.
         */
        this.disabled = false;
        /**
         * If `true`, the ic-tooltip which is shown for icon variant will be disabled. Title or aria-label must be set if this prop is not applied.
         */
        this.disableTooltip = false;
        /**
         * If `true`, the user can save the linked URL instead of navigating to it.
         */
        this.download = false;
        /**
         * If `true`, the button will show a dropdown icon.
         */
        this.dropdown = false;
        /**
         * If `true`, the aria-expanded value will be set to true. This is only applied if the dropdown prop is also true.
         */
        this.dropdownExpanded = false;
        /**
         * If `true`, when the button is clicked the native file explorer will be launched.
         */
        this.fileUpload = false;
        /**
         * The name of the control for the file input, which is submitted with the form data.
         */
        this.fileInputName = `ic-button-file-upload-input-${buttonIds++}`;
        /**
         * If `true`, the button will fill the width of the container.
         */
        this.fullWidth = false;
        /**
         * If `true`, the button will be in loading state.
         */
        this.loading = false;
        /**
         * If `true`, the button will display as monochromatic in either `light` or `dark` theme.
         */
        this.monochrome = false;
        /**
         * If `fileUpload` is set to `true`, this boolean determines whether multiple files are accepted.
         */
        this.multiple = false;
        /**
         * The size of the button to be displayed.
         */
        this.size = "medium";
        /**
         * Sets the theme color to the dark or light theme color. "inherit" will set the color based on the system settings or ic-theme component.
         */
        this.theme = "inherit";
        /**
         * Setting to `true` can help in situations where tooltip content is clipped by a parent element.
         */
        this.tooltipFixedPositioning = false;
        /**
         * The position of the tooltip in relation to the button.
         */
        this.tooltipPlacement = "bottom";
        /**
         * If `true`, the secondary & tertiary variants of button will have a transparent background when not hovered, pressed or loading.
         */
        this.transparentBackground = true;
        /**
         * The type of the button.
         */
        this.type = "button";
        /**
         * The variant of the button to be displayed.
         */
        this.variant = "primary";
        this.getSlottedIcon = (position) => this.el.querySelector(`[slot="${position}-icon"]`);
        this.handleClick = () => {
            if ((this.el.type === "submit" || this.el.type === "reset") &&
                !this.hasRouterSlot() &&
                (this.form || !!this.el.closest("FORM"))) {
                const form = this.form
                    ? document.querySelector(`form[id=${this.form}]`)
                    : this.el.closest("FORM");
                handleHiddenFormButtonClick(form, this.el);
            }
        };
        this.handleKeyDown = (ev) => {
            if (ev.key === "Escape" && this.hasTooltip) {
                this.closeButtonTooltip(ev);
            }
        };
        this.onFocus = () => {
            this.icFocus.emit();
        };
        this.onBlur = () => {
            this.icBlur.emit();
        };
        /**
         * Creates/updates clone of aria-describedby element node tree in shadow dom
         * Required due to ids being scoped to the shadow dom
         */
        this.updateAriaDescribedbyClone = () => {
            var _a, _b;
            if (this.describedbyNode) {
                const wrapper = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("#describedby-wrapper");
                if (!wrapper) {
                    (_b = this.el.shadowRoot) === null || _b === void 0 ? void 0 : _b.appendChild(Object.assign(document.createElement("div"), {
                        id: "describedby-wrapper",
                        className: "ic-button-describedby",
                    }));
                }
                while (wrapper === null || wrapper === void 0 ? void 0 : wrapper.firstChild)
                    wrapper.firstChild.remove();
                wrapper === null || wrapper === void 0 ? void 0 : wrapper.appendChild(this.describedbyNode);
            }
        };
        /**
         * Triggered when light dom aria-describedby element updates
         */
        this.mutationCallback = () => {
            var _a;
            if (this.describedbyEl)
                this.describedbyNode = (_a = this.describedbyEl) === null || _a === void 0 ? void 0 : _a.cloneNode(true);
        };
        /**
         * Triggered when attributes of host element change
         * @param mutationList the list of changes made to the host element
         */
        this.hostMutationCallback = (mutationList) => {
            let forceComponentUpdate = false;
            mutationList.forEach(({ attributeName }) => {
                if (attributeName) {
                    const attribute = this.el.getAttribute(attributeName);
                    if (attribute) {
                        if (attributeName === "title")
                            this.title = attribute;
                        else if (attributeName === "aria-label")
                            this.ariaLabel = attribute;
                        if (IC_INHERITED_ARIA.includes(attributeName)) {
                            this.inheritedAttributes[attributeName] = attribute;
                            forceComponentUpdate = true;
                        }
                    }
                }
            });
            if (forceComponentUpdate) {
                forceUpdate(this);
            }
        };
        this.setHasTooltip = () => {
            this.hasTooltip =
                !this.disableTooltip && (!!this.title || !!this.isIconVariant());
        };
        this.isIconVariant = () => this.variant.startsWith("icon");
        this.arrangeRouterItem = () => {
            var _a;
            const setStyles = (element, styles) => {
                Object.entries(styles).forEach(([key, value]) => {
                    element.style.setProperty(key, value);
                });
            };
            if (this.routerSlot) {
                const icTypography = document.createElement("ic-typography");
                setStyles(icTypography, {
                    "font-family": "var(--ic-font-body-family)",
                    "font-size": "0.875rem",
                    "font-weight": "600",
                });
                setStyles(this.routerSlot, {
                    gap: "0",
                });
                const icon = this.routerSlot.querySelector("svg");
                const iconSlot = icon === null || icon === void 0 ? void 0 : icon.getAttribute("slot");
                const iconWrapper = document.createElement("div");
                if (icon) {
                    setStyles(icon, {
                        fill: "currentcolor",
                    });
                    if (iconSlot === "top-icon") {
                        setStyles(this.routerSlot, {
                            display: "flex",
                            "flex-direction": "column",
                            "--height": "fit-content",
                        });
                    }
                    else if (iconSlot) {
                        const marginPlacement = iconSlot === "left-icon" ? "right" : "left";
                        setStyles(iconWrapper, {
                            [`margin-${marginPlacement}`]: "var(--ic-space-xs)",
                        });
                    }
                    iconWrapper.append(icon);
                }
                const badge = this.routerSlot.querySelector("ic-badge");
                const label = (_a = this.routerSlot.textContent) === null || _a === void 0 ? void 0 : _a.trim();
                if (badge)
                    iconWrapper.append(badge);
                if (label)
                    icTypography.textContent = label;
                this.routerSlot.textContent = "";
                if (iconSlot === "right-icon") {
                    this.routerSlot.append(icTypography);
                    this.routerSlot.append(iconWrapper);
                }
                else {
                    this.routerSlot.append(iconWrapper);
                    this.routerSlot.append(icTypography);
                }
            }
        };
    }
    watchDescribedbyNodeHandler() {
        this.updateAriaDescribedbyClone();
    }
    watchDisabledHandler() {
        removeDisabledFalse(this.disabled, this.el);
    }
    watchVariantHandler(newVariant) {
        if (newVariant === "icon")
            this.variant = "icon-tertiary";
    }
    disconnectedCallback() {
        var _a, _b;
        (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
        (_b = this.hostMutationObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
    }
    componentWillUpdate() {
        if (this.loading) {
            this.el.style.setProperty("--min-width", `${this.el.getBoundingClientRect().width}px`);
        }
        this.setHasTooltip();
    }
    componentWillLoad() {
        const _a = inheritAttributes(this.el, [...IC_INHERITED_ARIA, "title"]), { title, "aria-label": ariaLabel } = _a, restInheritedAttributes = __rest(_a, ["title", "aria-label"]);
        this.title = title;
        this.ariaLabel = ariaLabel;
        this.inheritedAttributes = restInheritedAttributes;
        removeDisabledFalse(this.disabled, this.el);
        this.el.setAttribute("exportparts", "button");
        this.id = this.el.id || null;
        this.setHasTooltip();
        if (!this.hasTooltip) {
            const describedById = this.inheritedAttributes["aria-describedby"];
            if (describedById) {
                this.describedById = describedById;
                const el = document.querySelector(`#${describedById}`);
                if (el) {
                    this.describedbyEl = el;
                    this.describedbyNode = el.cloneNode(true);
                }
            }
        }
        if (this.variant === "icon") {
            this.variant = "icon-tertiary";
        }
    }
    componentDidLoad() {
        this.updateTheme();
        if (typeof MutationObserver !== "undefined") {
            if (this.describedbyEl && this.describedById) {
                this.mutationObserver = new MutationObserver(this.mutationCallback);
                this.mutationObserver.observe(this.describedbyEl, {
                    characterData: true,
                    childList: true,
                    subtree: true,
                });
            }
            this.hostMutationObserver = new MutationObserver(this.hostMutationCallback);
            this.hostMutationObserver.observe(this.el, {
                attributes: true,
            });
            if (this.hasRouterSlot())
                this.arrangeRouterItem();
        }
        this.updateAriaDescribedbyClone();
    }
    componentWillRender() {
        const iconEl = this.getSlottedIcon("left") || this.getSlottedIcon("right");
        iconEl === null || iconEl === void 0 ? void 0 : iconEl.setAttribute("viewBox", "0 0 24 24");
    }
    handleHostClick(event) {
        if (!this.hasRouterSlot()) {
            if (this.fileUpload) {
                renderFileHiddenInput(this.icFileSelection, this.el, !!this.multiple, !!this.disabled, this.accept, this.fileInputName, this.selectedFiles);
            }
            if (this.disabled || this.loading) {
                event.stopImmediatePropagation();
            }
            if (this.dropdown) {
                this.dropdownExpanded = !this.dropdownExpanded;
            }
        }
    }
    brandChangeHandler({ detail }) {
        this.updateTheme(detail.mode);
    }
    /**
     * Sets focus on the native `button`.
     */
    async setFocus() {
        var _a;
        (_a = this.buttonEl) === null || _a === void 0 ? void 0 : _a.focus();
    }
    async closeButtonTooltip(ev) {
        var _a;
        const tooltip = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector("ic-tooltip");
        if (tooltip && (await tooltip.isTooltipVisible())) {
            tooltip.displayTooltip(false);
            ev.preventDefault();
            ev.stopImmediatePropagation();
        }
    }
    hasRouterSlot() {
        this.routerSlot = this.el.querySelector('[slot="router-item"]');
        if (this.routerSlot) {
            this.routerSlot.ariaLabel = this.routerSlot.textContent;
        }
        return !!this.routerSlot;
    }
    updateTheme(mode = null) {
        const foregroundColor = getBrandFromContext(this.el, mode);
        if (foregroundColor !== IcBrandForegroundEnum.Default) {
            this.theme =
                foregroundColor === IcBrandForegroundEnum.Light
                    ? IcBrandForegroundEnum.Dark
                    : IcBrandForegroundEnum.Light;
            this.monochrome = true;
        }
    }
    render() {
        const { ariaControlsId, ariaLabel, ariaOwnsId, buttonIdNum, describedById, disabled, download, dropdown, dropdownExpanded, form, formaction, formenctype, formmethod, formnovalidate, formtarget, fullWidth, handleClick, handleKeyDown, hasTooltip, href, hreflang, id, inheritedAttributes, isIconVariant, loading, monochrome, onBlur, onFocus, referrerpolicy, rel, size, target, theme, title, tooltipFixedPositioning, tooltipPlacement, transparentBackground, type, variant, } = this;
        const TagType = href ? "a" : "button";
        const buttonAttrs = TagType === "button"
            ? {
                type,
                disabled,
                form,
                formaction,
                formenctype,
                formmethod,
                formnovalidate,
                formtarget,
            }
            : {
                download: download !== false ? download : null,
                href,
                rel,
                target,
                referrerpolicy,
                hreflang,
            };
        const buttonId = hasTooltip
            ? `ic-button-with-tooltip-${id || buttonIdNum}`
            : undefined;
        const describedby = !hasTooltip ? describedById : `ic-tooltip-${buttonId}`;
        const hasLeftIcon = !!this.getSlottedIcon("left");
        const hasRightIcon = !!this.getSlottedIcon("right");
        const ButtonContent = () => this.hasRouterSlot() ? (h("slot", { name: "router-item" })) : (h(TagType, Object.assign({ class: "button", tabindex: 0, "aria-disabled": loading || disabled ? "true" : null, "aria-label": loading ? "Loading" : ariaLabel, "aria-expanded": dropdown && `${dropdownExpanded}` }, buttonAttrs, inheritedAttributes, { onFocus: onFocus, onBlur: onBlur, ref: (el) => (this.buttonEl = el), "aria-describedby": describedby, part: "button" }), loading ? (h("div", { class: "loading-container" }, h("ic-loading-indicator", { type: isIconVariant() ? "circular" : "linear", class: { "loading-indicator-icon-button": isIconVariant() }, monochrome: monochrome, theme: theme }))) : (h(Fragment, null, (hasLeftIcon ||
            (!!this.getSlottedIcon("top") && !hasRightIcon)) && (h("div", { class: "icon-container" }, h("slot", { name: `${hasLeftIcon ? "left" : "top"}-icon` }))), h("slot", null), !dropdown
            ? hasRightIcon && (h("div", { class: { "icon-container": true, "right-icon": true } }, h("slot", { name: "right-icon" })))
            : variant !== "icon" &&
                variant !== "destructive" && (h("span", { class: dropdownExpanded
                    ? "dropdown-expanded"
                    : "arrow-dropdown", innerHTML: arrowDropdown }))))));
        return (h(Host, { key: '9af3124fa3bb001b9b744b4df20d0e107f865df1', class: {
                "ic-button-disabled": disabled && !loading,
                "ic-button-full-width": fullWidth,
                "ic-button-loading": loading,
                [`ic-button-size-${size}`]: true,
                [`ic-button-variant-${variant}`]: true,
                [`ic-theme-${theme}`]: theme !== "inherit",
                background: (variant === "secondary" || variant === "tertiary") &&
                    !transparentBackground &&
                    !disabled,
                "dropdown-no-icon": dropdown &&
                    !isSlotUsed(this.el, "icon") &&
                    !isSlotUsed(this.el, "left-icon"),
                monochrome,
                "top-icon": isSlotUsed(this.el, "top-icon"),
                "with-badge": isSlotUsed(this.el, "badge"),
            }, onClick: handleClick, onKeyDown: handleKeyDown, "aria-owns": ariaOwnsId, "aria-controls": ariaControlsId, "aria-expanded": dropdown && `${dropdownExpanded}` }, hasTooltip && (h("ic-tooltip", { key: '533f8aac9579f16eaae0a167a683f7c42973de95', id: describedby, label: title || ariaLabel, target: buttonId, placement: tooltipPlacement, fixedPositioning: tooltipFixedPositioning, silent: isIconVariant() && !!ariaLabel }, h(ButtonContent, { key: '67502a4253722031847e36ae3275ca48c7d01bd4' }))), isSlotUsed(this.el, "badge") && h("slot", { key: 'e4e5081c6f415f0447ae43398fd11fcf51a426f3', name: "badge" }), !hasTooltip && h(ButtonContent, { key: '5185de2240ddaddbc0bb35bdab51bc63e91492a5' })));
    }
    static get delegatesFocus() { return true; }
    get el() { return this; }
    static get watchers() { return {
        "describedbyNode": ["watchDescribedbyNodeHandler"],
        "disabled": ["watchDisabledHandler"],
        "variant": ["watchVariantHandler"]
    }; }
    static get style() { return IcButtonStyle0; }
}, [17, "ic-button", {
        "accept": [1],
        "ariaControlsId": [8, "aria-controls-id"],
        "ariaOwnsId": [8, "aria-owns-id"],
        "disabled": [4],
        "disableTooltip": [4, "disable-tooltip"],
        "download": [8],
        "dropdown": [4],
        "dropdownExpanded": [1540, "dropdown-expanded"],
        "fileUpload": [4, "file-upload"],
        "fileInputName": [1, "file-input-name"],
        "form": [1],
        "formaction": [1],
        "formenctype": [1],
        "formmethod": [1],
        "formnovalidate": [4],
        "formtarget": [1],
        "fullWidth": [4, "full-width"],
        "href": [1],
        "hreflang": [1],
        "loading": [4],
        "monochrome": [1028],
        "multiple": [4],
        "referrerpolicy": [1],
        "rel": [1],
        "selectedFiles": [16],
        "size": [1],
        "target": [1],
        "theme": [1025],
        "tooltipFixedPositioning": [4, "tooltip-fixed-positioning"],
        "tooltipPlacement": [1, "tooltip-placement"],
        "transparentBackground": [4, "transparent-background"],
        "type": [1],
        "variant": [1025],
        "ariaLabel": [32],
        "describedbyNode": [32],
        "title": [32],
        "setFocus": [64]
    }, [[2, "click", "handleHostClick"], [4, "brandChange", "brandChangeHandler"]], {
        "describedbyNode": ["watchDescribedbyNodeHandler"],
        "disabled": ["watchDisabledHandler"],
        "variant": ["watchVariantHandler"]
    }]);
function defineCustomElement() {
    if (typeof customElements === "undefined") {
        return;
    }
    const components = ["ic-button", "ic-loading-indicator", "ic-tooltip", "ic-typography"];
    components.forEach(tagName => { switch (tagName) {
        case "ic-button":
            if (!customElements.get(tagName)) {
                customElements.define(tagName, Button);
            }
            break;
        case "ic-loading-indicator":
            if (!customElements.get(tagName)) {
                defineCustomElement$3();
            }
            break;
        case "ic-tooltip":
            if (!customElements.get(tagName)) {
                defineCustomElement$2();
            }
            break;
        case "ic-typography":
            if (!customElements.get(tagName)) {
                defineCustomElement$1();
            }
            break;
    } });
}

export { Button as B, defineCustomElement as d };

//# sourceMappingURL=ic-button2.js.map