import{proxyCustomElement as t,HTMLElement as e,createEvent as i,h as o,transformTag as n}from"@stencil/core/internal/client";import{g as r}from"./extension-mapping.js";import{d as s}from"./navigation-button.js";function a(t){if(!t)return"";const e=t.lastIndexOf(".");return e<1?"":t.slice(e+1).toLowerCase()}const h=t(class t extends e{constructor(e){super(),!1!==e&&this.__registerHost(),this.__attachShadow(),this.actionSelected=i(this,"actionSelected",7),this.triggerDelay=600,this.openDirection="top",this.popoverMaxWidth="20rem",this.popoverMaxHeight="min(35rem, calc(100vh - 2rem))",this.actions=[],this.isPopoverOpen=!1,this.openPopoverWithDelay=e=>{e.stopPropagation(),clearTimeout(this.hoverTimeout),this.hoverTimeout=window.setTimeout((()=>{t.currentOpenPopover&&t.currentOpenPopover!==this&&(t.currentOpenPopover.isPopoverOpen=!1),t.currentOpenPopover=this,this.isPopoverOpen=!0}),this.triggerDelay)},this.resetTimeout=()=>{this.isPopoverOpen||clearTimeout(this.hoverTimeout)},this.onPopoverClose=e=>{e.stopPropagation(),this.isPopoverOpen=!1,t.currentOpenPopover===this&&(t.currentOpenPopover=null)},this.handleCloseClick=t=>{t.stopPropagation(),this.isPopoverOpen=!1},this.handleSelected=t=>{this.actionSelected.emit(t.detail)}}render(){return o("limel-popover",{key:"901e726d37719331f2b30df6e35f2375951c161f",style:{"--limebb-summary-popover-timeout":`${this.triggerDelay}ms`},open:this.isPopoverOpen,onClose:this.onPopoverClose,openDirection:this.openDirection},o("div",{key:"a9a73b0a0f16cf12aaa6fa3434071c56a26a1038",slot:"trigger",onMouseEnter:this.openPopoverWithDelay,onMouseLeave:this.resetTimeout,onFocusin:this.openPopoverWithDelay},o("slot",{key:"594bcc9e419e33ef97fd6ca863cf44a67617fa48",name:"trigger"}),o("div",{key:"a6f548eeb737f4392e2c938682a1c9a509523658",class:"opening-countdown-indicator"})),this.renderCard({"--navigation-button-background-color":"rgb(var(--contrast-100), 0.8)",position:"absolute",top:"0.125rem",right:"0.125rem"}))}renderCard(t){return o("limel-card",{style:{"max-width":this.popoverMaxWidth,"max-height":this.popoverMaxHeight,"min-width":"7rem","min-height":"3rem"},orientation:"landscape",heading:this.heading,subheading:this.subheading,icon:this.icon,value:this.value,image:this.image,actions:this.actions,onActionSelected:this.handleSelected},this.renderFileViewer(),o("limebb-navigation-button",{slot:"component",type:"close",style:t,tooltipLabel:"Close",tooltipHelperLabel:"Esc",onClick:this.handleCloseClick}))}renderFileViewer(){var t;if(!this.file)return;const e=a(null!==(t=this.file.filename)&&void 0!==t?t:""),i=r(e);return o("limel-file-viewer",{slot:"component",style:{flex:"1",overflow:"hidden",borderRadius:"0.5rem",minHeight:"pdf"===e?"20rem":void 0},url:this.file.href,filename:"sharepoint"===i||"unsupported"===i?void 0:this.file.filename,allowDownload:!0})}static get style(){return"limel-popover{--popover-border-radius:0.95rem;--popover-body-background-color:transparent;--popover-box-shadow:var(--shadow-depth-8)}div[slot=trigger]{position:relative;display:flex;align-items:center;justify-content:center}div[slot=trigger] *{min-width:0;min-height:0}.opening-countdown-indicator{position:absolute;inset:auto 0 -0.25rem 0;margin:0 auto;height:0.125rem;border-radius:1rem;transition:width ease-out, opacity ease;transition-duration:120ms;opacity:0;width:0%;background-color:var(--mdc-theme-primary)}div[slot=trigger]:not([aria-expanded=true]):hover .opening-countdown-indicator{transition-duration:var(--limebb-summary-popover-timeout);opacity:1;width:100%}"}},[257,"limebb-summary-popover",{triggerDelay:[514,"trigger-delay"],heading:[513],subheading:[513],image:[16],file:[16],icon:[513],value:[1],openDirection:[513,"open-direction"],popoverMaxWidth:[513,"popover-max-width"],popoverMaxHeight:[513,"popover-max-height"],actions:[16],isPopoverOpen:[32]}]);function l(){"undefined"!=typeof customElements&&["limebb-summary-popover","limebb-navigation-button"].forEach((t=>{switch(t){case"limebb-summary-popover":customElements.get(n(t))||customElements.define(n(t),h);break;case"limebb-navigation-button":customElements.get(n(t))||s()}}))}h.currentOpenPopover=null;export{h as S,l as d,a as g}