import{r as t,d as i,h as s,a as e}from"./p-a599f720.js";import{e as a,i as o}from"./p-9811c98c.js";import{d as n}from"./p-901c1d40.js";import{S as r}from"./p-af705ed1.js";var l=function(t,i,s,e){var a,o=arguments.length,n=o<3?i:null===e?e=Object.getOwnPropertyDescriptor(i,s):e;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,i,s,e);else for(var r=t.length-1;r>=0;r--)(a=t[r])&&(n=(o<3?a(n):o>3?a(i,s,n):a(i,s))||n);return o>3&&n&&Object.defineProperty(i,s,n),n};const h=class{constructor(s){t(this,s),this.stateUpdate=i(this,"rtkStateUpdate",7),this.variant="button",this.iconPack=a,this.t=o(),this.pollsActive=!1,this.unreadPollsCount=0,this.canViewPolls=!1,this.onPollsUpdate=({newPoll:t})=>{!0===t&&(this.unreadPollsCount+=1)},this.updateCanView=()=>{this.canViewPolls=n(this.meeting)}}connectedCallback(){this.meetingChanged(this.meeting),this.statesChanged(this.states)}disconnectedCallback(){var t,i,s,e,a,o;null===(i=null===(t=this.meeting)||void 0===t?void 0:t.polls)||void 0===i||i.removeListener("pollsUpdate",this.onPollsUpdate),null===(e=null===(s=this.meeting)||void 0===s?void 0:s.self)||void 0===e||e.permissions.removeListener("pollsUpdate",this.updateCanView),null===(o=null===(a=this.meeting)||void 0===a?void 0:a.stage)||void 0===o||o.removeListener("stageStatusUpdate",this.updateCanView)}meetingChanged(t){var i,s;t&&t.polls&&(this.unreadPollsCount=t.polls.items.length,this.meeting.polls.addListener("pollsUpdate",this.onPollsUpdate),null===(i=null==t?void 0:t.self)||void 0===i||i.permissions.addListener("pollsUpdate",this.updateCanView),this.canViewPolls=n(t),null===(s=null==t?void 0:t.stage)||void 0===s||s.on("stageStatusUpdate",this.updateCanView))}statesChanged(t){null!=t&&(this.pollsActive=!0===t.activeSidebar&&"polls"===t.sidebar)}togglePollsTab(){const t=this.states;this.unreadPollsCount=0,this.pollsActive=!((null==t?void 0:t.activeSidebar)&&"polls"===(null==t?void 0:t.sidebar)),this.stateUpdate.emit({activeSidebar:this.pollsActive,sidebar:this.pollsActive?"polls":void 0,activeMoreMenu:!1})}handlePollsActiveChange(){this.pollsActive||this.states.activeSidebar||this.buttonEl.focus()}render(){if(!this.canViewPolls)return s(e,{"data-hidden":!0});const t=this.t("polls");return s(e,{title:t},0!==this.unreadPollsCount&&!this.pollsActive&&s("div",{class:"unread-count",part:"unread-count"},s("span",null,this.unreadPollsCount<=100?this.unreadPollsCount:"99+")),s("rtk-controlbar-button",{ref:t=>this.buttonEl=t,part:"controlbar-button",size:this.size,iconPack:this.iconPack,class:{active:this.pollsActive},onClick:()=>this.togglePollsTab(),icon:this.iconPack.poll,label:t,variant:this.variant}))}static get watchers(){return{meeting:["meetingChanged"],states:["statesChanged"],pollsActive:["handlePollsActiveChange"]}}};l([r()],h.prototype,"meeting",void 0),l([r()],h.prototype,"states",void 0),l([r()],h.prototype,"iconPack",void 0),l([r()],h.prototype,"t",void 0),h.style=":host{line-height:initial;font-family:var(--rtk-font-family, sans-serif);font-feature-settings:normal;font-variation-settings:normal}p{margin:var(--rtk-space-0, 0px);padding:var(--rtk-space-0, 0px)}:host{position:relative;display:block}:host([data-hidden]){display:none}.unread-count{position:absolute;right:var(--rtk-space-3, 12px);box-sizing:border-box;padding:var(--rtk-space-0\\.5, 2px);-webkit-user-select:none;-moz-user-select:none;user-select:none;--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-bg-opacity));font-size:12px;color:rgb(var(--rtk-colors-text-on-brand-1000, var(--rtk-colors-text-1000, 255 255 255)));display:flex;height:var(--rtk-space-5, 20px);min-width:var(--rtk-space-5, 20px);align-items:center;justify-content:center;border-radius:9999px;z-index:1}:host([variant='horizontal']) .unread-count{right:var(--rtk-space-4, 16px);top:50%;transform:translateY(-50%)}";export{h as rtk_polls_toggle}