import{Q as t,_ as e,t as o,m as i,i as n,n as s,T as r,B as d,U as l,x as c,o as a,D as u,p as h,I as m,J as p,c as f,d as y,f as g,g as x,V as b,W as T,X as v,Y as I,Z as E,$ as A,M as C}from"./core.js";export{K as createSetFromIndex,L as isEventMulti,G as isIndexSet}from"./core.js";import"./mwc-list.js";import"./mwc-list-item.js";const S={TOP_LEFT:t.TOP_LEFT,TOP_RIGHT:t.TOP_RIGHT,BOTTOM_LEFT:t.BOTTOM_LEFT,BOTTOM_RIGHT:t.BOTTOM_RIGHT,TOP_START:t.TOP_START,TOP_END:t.TOP_END,BOTTOM_START:t.BOTTOM_START,BOTTOM_END:t.BOTTOM_END};class w extends d{constructor(){super(...arguments),this.mdcFoundationClass=l,this.absolute=!1,this.fullwidth=!1,this.fixed=!1,this.x=null,this.y=null,this.quick=!1,this.open=!1,this.stayOpenOnBodyClick=!1,this.bitwiseCorner=t.TOP_START,this.previousMenuCorner=null,this.menuCorner="START",this.corner="TOP_START",this.styleTop="",this.styleLeft="",this.styleRight="",this.styleBottom="",this.styleMaxHeight="",this.styleTransformOrigin="",this.anchor=null,this.previouslyFocused=null,this.previousAnchor=null,this.onBodyClickBound=()=>{}}render(){return this.renderSurface()}renderSurface(){const t=this.getRootClasses(),e=this.getRootStyles();return c`
${this.renderContent()}
`}getRootClasses(){return{"mdc-menu-surface":!0,"mdc-menu-surface--fixed":this.fixed,"mdc-menu-surface--fullwidth":this.fullwidth}}getRootStyles(){return{top:this.styleTop,left:this.styleLeft,right:this.styleRight,bottom:this.styleBottom,"max-height":this.styleMaxHeight,"transform-origin":this.styleTransformOrigin}}renderContent(){return c``}createAdapter(){return Object.assign(Object.assign({},h(this.mdcRoot)),{hasAnchor:()=>!!this.anchor,notifyClose:()=>{const t=new CustomEvent("closed",{bubbles:!0,composed:!0});this.open=!1,this.mdcRoot.dispatchEvent(t)},notifyClosing:()=>{const t=new CustomEvent("closing",{bubbles:!0,composed:!0});this.mdcRoot.dispatchEvent(t)},notifyOpen:()=>{const t=new CustomEvent("opened",{bubbles:!0,composed:!0});this.open=!0,this.mdcRoot.dispatchEvent(t)},notifyOpening:()=>{const t=new CustomEvent("opening",{bubbles:!0,composed:!0});this.mdcRoot.dispatchEvent(t)},isElementInContainer:()=>!1,isRtl:()=>!!this.mdcRoot&&"rtl"===getComputedStyle(this.mdcRoot).direction,setTransformOrigin:t=>{this.mdcRoot&&(this.styleTransformOrigin=t)},isFocused:()=>m(this),saveFocus:()=>{const t=p(),e=t.length;e||(this.previouslyFocused=null),this.previouslyFocused=t[e-1]},restoreFocus:()=>{this.previouslyFocused&&"focus"in this.previouslyFocused&&this.previouslyFocused.focus()},getInnerDimensions:()=>{const t=this.mdcRoot;return t?{width:t.offsetWidth,height:t.offsetHeight}:{width:0,height:0}},getAnchorDimensions:()=>{const t=this.anchor;return t?t.getBoundingClientRect():null},getBodyDimensions:()=>({width:document.body.clientWidth,height:document.body.clientHeight}),getWindowDimensions:()=>({width:window.innerWidth,height:window.innerHeight}),getWindowScroll:()=>({x:window.pageXOffset,y:window.pageYOffset}),setPosition:t=>{this.mdcRoot&&(this.styleLeft="left"in t?`${t.left}px`:"",this.styleRight="right"in t?`${t.right}px`:"",this.styleTop="top"in t?`${t.top}px`:"",this.styleBottom="bottom"in t?`${t.bottom}px`:"")},setMaxHeight:async t=>{this.mdcRoot&&(this.styleMaxHeight=t,await this.updateComplete,this.styleMaxHeight=`var(--mdc-menu-max-height, ${t})`)}})}onKeydown(t){this.mdcFoundation&&this.mdcFoundation.handleKeydown(t)}onBodyClick(t){if(this.stayOpenOnBodyClick)return;-1===t.composedPath().indexOf(this)&&this.close()}registerBodyClick(){this.onBodyClickBound=this.onBodyClick.bind(this),document.body.addEventListener("click",this.onBodyClickBound,{passive:!0,capture:!0})}deregisterBodyClick(){document.body.removeEventListener("click",this.onBodyClickBound,{capture:!0})}onOpenChanged(t,e){this.mdcFoundation&&(t?this.mdcFoundation.open():void 0!==e&&this.mdcFoundation.close())}close(){this.open=!1}show(){this.open=!0}}e([n(".mdc-menu-surface")],w.prototype,"mdcRoot",void 0),e([n("slot")],w.prototype,"slotElement",void 0),e([s({type:Boolean}),i((function(t){this.mdcFoundation&&!this.fixed&&this.mdcFoundation.setIsHoisted(t)}))],w.prototype,"absolute",void 0),e([s({type:Boolean})],w.prototype,"fullwidth",void 0),e([s({type:Boolean}),i((function(t){this.mdcFoundation&&!this.absolute&&this.mdcFoundation.setFixedPosition(t)}))],w.prototype,"fixed",void 0),e([s({type:Number}),i((function(t){this.mdcFoundation&&null!==this.y&&null!==t&&(this.mdcFoundation.setAbsolutePosition(t,this.y),this.mdcFoundation.setAnchorMargin({left:t,top:this.y,right:-t,bottom:this.y}))}))],w.prototype,"x",void 0),e([s({type:Number}),i((function(t){this.mdcFoundation&&null!==this.x&&null!==t&&(this.mdcFoundation.setAbsolutePosition(this.x,t),this.mdcFoundation.setAnchorMargin({left:this.x,top:t,right:-this.x,bottom:t}))}))],w.prototype,"y",void 0),e([s({type:Boolean}),i((function(t){this.mdcFoundation&&this.mdcFoundation.setQuickOpen(t)}))],w.prototype,"quick",void 0),e([s({type:Boolean,reflect:!0}),i((function(t,e){this.onOpenChanged(t,e)}))],w.prototype,"open",void 0),e([s({type:Boolean})],w.prototype,"stayOpenOnBodyClick",void 0),e([o(),i((function(t){this.mdcFoundation&&this.mdcFoundation.setAnchorCorner(t)}))],w.prototype,"bitwiseCorner",void 0),e([s({type:String}),i((function(t){if(this.mdcFoundation){const e="START"===t||"END"===t,o=null===this.previousMenuCorner,i=!o&&t!==this.previousMenuCorner;e&&(i||o&&"END"===t)&&(this.bitwiseCorner=this.bitwiseCorner^r.RIGHT,this.mdcFoundation.flipCornerHorizontally(),this.previousMenuCorner=t)}}))],w.prototype,"menuCorner",void 0),e([s({type:String}),i((function(t){if(this.mdcFoundation&&t){let e=S[t];"END"===this.menuCorner&&(e^=r.RIGHT),this.bitwiseCorner=e}}))],w.prototype,"corner",void 0),e([o()],w.prototype,"styleTop",void 0),e([o()],w.prototype,"styleLeft",void 0),e([o()],w.prototype,"styleRight",void 0),e([o()],w.prototype,"styleBottom",void 0),e([o()],w.prototype,"styleMaxHeight",void 0),e([o()],w.prototype,"styleTransformOrigin",void 0);const O=f`.mdc-menu-surface{display:none;position:absolute;box-sizing:border-box;max-width:calc(100vw - 32px);max-width:var(--mdc-menu-max-width, calc(100vw - 32px));max-height:calc(100vh - 32px);max-height:var(--mdc-menu-max-height, calc(100vh - 32px));margin:0;padding:0;transform:scale(1);transform-origin:top left;opacity:0;overflow:auto;will-change:transform,opacity;z-index:8;transition:opacity .03s linear,transform .12s cubic-bezier(0, 0, 0.2, 1),height 250ms cubic-bezier(0, 0, 0.2, 1);box-shadow:0px 5px 5px -3px rgba(0, 0, 0, 0.2),0px 8px 10px 1px rgba(0, 0, 0, 0.14),0px 3px 14px 2px rgba(0,0,0,.12);background-color:#fff;background-color:var(--mdc-theme-surface, #fff);color:#000;color:var(--mdc-theme-on-surface, #000);border-radius:4px;border-radius:var(--mdc-shape-medium, 4px);transform-origin-left:top left;transform-origin-right:top right}.mdc-menu-surface:focus{outline:none}.mdc-menu-surface--animating-open{display:inline-block;transform:scale(0.8);opacity:0}.mdc-menu-surface--open{display:inline-block;transform:scale(1);opacity:1}.mdc-menu-surface--animating-closed{display:inline-block;opacity:0;transition:opacity .075s linear}[dir=rtl] .mdc-menu-surface,.mdc-menu-surface[dir=rtl]{transform-origin-left:top right;transform-origin-right:top left}.mdc-menu-surface--anchor{position:relative;overflow:visible}.mdc-menu-surface--fixed{position:fixed}.mdc-menu-surface--fullwidth{width:100%}:host(:not([open])){display:none}.mdc-menu-surface{z-index:8;z-index:var(--mdc-menu-z-index, 8);min-width:112px;min-width:var(--mdc-menu-min-width, 112px)}`;let F=class extends w{};F.styles=[O],F=e([y("mwc-menu-surface")],F);var R=function(t){function e(o){var i=t.call(this,x(x({},e.defaultAdapter),o))||this;return i.closeAnimationEndTimerId=0,i.defaultFocusState=b.LIST_ROOT,i.selectedIndex=-1,i}return g(e,t),Object.defineProperty(e,"cssClasses",{get:function(){return T},enumerable:!1,configurable:!0}),Object.defineProperty(e,"strings",{get:function(){return v},enumerable:!1,configurable:!0}),Object.defineProperty(e,"numbers",{get:function(){return I},enumerable:!1,configurable:!0}),Object.defineProperty(e,"defaultAdapter",{get:function(){return{addClassToElementAtIndex:function(){},removeClassFromElementAtIndex:function(){},addAttributeToElementAtIndex:function(){},removeAttributeFromElementAtIndex:function(){},getAttributeFromElementAtIndex:function(){return null},elementContainsClass:function(){return!1},closeSurface:function(){},getElementIndex:function(){return-1},notifySelected:function(){},getMenuItemCount:function(){return 0},focusItemAtIndex:function(){},focusListRoot:function(){},getSelectedSiblingOfItemAtIndex:function(){return-1},isSelectableItemAtIndex:function(){return!1}}},enumerable:!1,configurable:!0}),e.prototype.destroy=function(){this.closeAnimationEndTimerId&&clearTimeout(this.closeAnimationEndTimerId),this.adapter.closeSurface()},e.prototype.handleKeydown=function(t){var e=t.key,o=t.keyCode;("Tab"===e||9===o)&&this.adapter.closeSurface(!0)},e.prototype.handleItemAction=function(t){var e=this,o=this.adapter.getElementIndex(t);if(!(o<0)){this.adapter.notifySelected({index:o});var i="true"===this.adapter.getAttributeFromElementAtIndex(o,v.SKIP_RESTORE_FOCUS);this.adapter.closeSurface(i),this.closeAnimationEndTimerId=setTimeout((function(){var o=e.adapter.getElementIndex(t);o>=0&&e.adapter.isSelectableItemAtIndex(o)&&e.setSelectedIndex(o)}),E.numbers.TRANSITION_CLOSE_DURATION)}},e.prototype.handleMenuSurfaceOpened=function(){switch(this.defaultFocusState){case b.FIRST_ITEM:this.adapter.focusItemAtIndex(0);break;case b.LAST_ITEM:this.adapter.focusItemAtIndex(this.adapter.getMenuItemCount()-1);break;case b.NONE:break;default:this.adapter.focusListRoot()}},e.prototype.setDefaultFocusState=function(t){this.defaultFocusState=t},e.prototype.getSelectedIndex=function(){return this.selectedIndex},e.prototype.setSelectedIndex=function(t){if(this.validatedIndex(t),!this.adapter.isSelectableItemAtIndex(t))throw new Error("MDCMenuFoundation: No selection group at specified index.");var e=this.adapter.getSelectedSiblingOfItemAtIndex(t);e>=0&&(this.adapter.removeAttributeFromElementAtIndex(e,v.ARIA_CHECKED_ATTR),this.adapter.removeClassFromElementAtIndex(e,T.MENU_SELECTED_LIST_ITEM)),this.adapter.addClassToElementAtIndex(t,T.MENU_SELECTED_LIST_ITEM),this.adapter.addAttributeToElementAtIndex(t,v.ARIA_CHECKED_ATTR,"true"),this.selectedIndex=t},e.prototype.setEnabled=function(t,e){this.validatedIndex(t),e?(this.adapter.removeClassFromElementAtIndex(t,A.LIST_ITEM_DISABLED_CLASS),this.adapter.addAttributeToElementAtIndex(t,v.ARIA_DISABLED_ATTR,"false")):(this.adapter.addClassToElementAtIndex(t,A.LIST_ITEM_DISABLED_CLASS),this.adapter.addAttributeToElementAtIndex(t,v.ARIA_DISABLED_ATTR,"true"))},e.prototype.validatedIndex=function(t){var e=this.adapter.getMenuItemCount();if(!(t>=0&&t ${this.renderList()} `}getSurfaceClasses(){return{"mdc-menu":!0,"mdc-menu-surface":!0}}renderList(){const t="menu"===this.innerRole?"menuitem":"option",e=this.renderListClasses();return c` `}renderListClasses(){return{"mdc-deprecated-list":!0}}createAdapter(){return{addClassToElementAtIndex:(t,e)=>{const o=this.listElement;if(!o)return;const i=o.items[t];i&&("mdc-menu-item--selected"===e?this.forceGroupSelection&&!i.selected&&o.toggle(t,!0):i.classList.add(e))},removeClassFromElementAtIndex:(t,e)=>{const o=this.listElement;if(!o)return;const i=o.items[t];i&&("mdc-menu-item--selected"===e?i.selected&&o.toggle(t,!1):i.classList.remove(e))},addAttributeToElementAtIndex:(t,e,o)=>{const i=this.listElement;if(!i)return;const n=i.items[t];n&&n.setAttribute(e,o)},removeAttributeFromElementAtIndex:(t,e)=>{const o=this.listElement;if(!o)return;const i=o.items[t];i&&i.removeAttribute(e)},getAttributeFromElementAtIndex:(t,e)=>{const o=this.listElement;if(!o)return null;const i=o.items[t];return i?i.getAttribute(e):null},elementContainsClass:(t,e)=>t.classList.contains(e),closeSurface:()=>{this.open=!1},getElementIndex:t=>{const e=this.listElement;return e?e.items.indexOf(t):-1},notifySelected:()=>{},getMenuItemCount:()=>{const t=this.listElement;return t?t.items.length:0},focusItemAtIndex:t=>{const e=this.listElement;if(!e)return;const o=e.items[t];o&&o.focus()},focusListRoot:()=>{this.listElement&&this.listElement.focus()},getSelectedSiblingOfItemAtIndex:t=>{const e=this.listElement;if(!e)return-1;const o=e.items[t];if(!o||!o.group)return-1;for(let i=0;i{const e=this.listElement;if(!e)return!1;const o=e.items[t];return!!o&&o.hasAttribute("group")}}}onKeydown(t){this.mdcFoundation&&this.mdcFoundation.handleKeydown(t)}onAction(t){const e=this.listElement;if(this.mdcFoundation&&e){const o=t.detail.index,i=e.items[o];i&&this.mdcFoundation.handleItemAction(i)}}onOpened(){this.open=!0,this.mdcFoundation&&this.mdcFoundation.handleMenuSurfaceOpened()}onClosed(){this.open=!1}async getUpdateComplete(){await this._listUpdateComplete;return await super.getUpdateComplete()}async firstUpdated(){super.firstUpdated();const t=this.listElement;t&&(this._listUpdateComplete=t.updateComplete,await this._listUpdateComplete)}select(t){const e=this.listElement;e&&e.select(t)}close(){this.open=!1}show(){this.open=!0}getFocusedItemIndex(){const t=this.listElement;return t?t.getFocusedItemIndex():-1}focusItemAtIndex(t){const e=this.listElement;e&&e.focusItemAtIndex(t)}layout(t=!0){const e=this.listElement;e&&e.layout(t)}}e([n(".mdc-menu")],B.prototype,"mdcRoot",void 0),e([n("slot")],B.prototype,"slotElement",void 0),e([s({type:Object})],B.prototype,"anchor",void 0),e([s({type:Boolean,reflect:!0})],B.prototype,"open",void 0),e([s({type:Boolean})],B.prototype,"quick",void 0),e([s({type:Boolean})],B.prototype,"wrapFocus",void 0),e([s({type:String})],B.prototype,"innerRole",void 0),e([s({type:String})],B.prototype,"innerAriaLabel",void 0),e([s({type:String})],B.prototype,"corner",void 0),e([s({type:Number})],B.prototype,"x",void 0),e([s({type:Number})],B.prototype,"y",void 0),e([s({type:Boolean})],B.prototype,"absolute",void 0),e([s({type:Boolean})],B.prototype,"multi",void 0),e([s({type:Boolean})],B.prototype,"activatable",void 0),e([s({type:Boolean})],B.prototype,"fixed",void 0),e([s({type:Boolean})],B.prototype,"forceGroupSelection",void 0),e([s({type:Boolean})],B.prototype,"fullwidth",void 0),e([s({type:String})],B.prototype,"menuCorner",void 0),e([s({type:Boolean})],B.prototype,"stayOpenOnBodyClick",void 0),e([s({type:String}),i((function(t){this.mdcFoundation&&this.mdcFoundation.setDefaultFocusState(b[t])}))],B.prototype,"defaultFocus",void 0);const _=f`mwc-list ::slotted([mwc-list-item]:not([twoline])),mwc-list ::slotted([noninteractive]:not([twoline])){height:var(--mdc-menu-item-height, 48px)}`;let M=class extends B{};M.styles=[_],M=e([y("mwc-menu")],M);export{M as Menu};