import{r as t,h as r,a}from"./p-a599f720.js";import{e as i,i as o}from"./p-9811c98c.js";import{h as s}from"./p-3f882e7c.js";import{S as e}from"./p-af705ed1.js";var c=function(t,r,a,i){var o,s=arguments.length,e=s<3?r:null===i?i=Object.getOwnPropertyDescriptor(r,a):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)e=Reflect.decorate(t,r,a,i);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(e=(s<3?o(e):s>3?o(r,a,e):o(r,a))||e);return s>3&&e&&Object.defineProperty(r,a,e),e};const n=class{constructor(r){t(this,r),this.iconPack=i,this.t=o(),this.audioEnabled=!1,this.volume=0,this.onAudioUpdate=({audioEnabled:t,audioTrack:r})=>{if(this.participant)if(t&&r){const t=new MediaStream;t.addTrack(r),this.calcVolume(t),this.audioEnabled=!0}else this.volume=0,this.audioEnabled=!1}}connectedCallback(){this.participantChanged(this.participant)}disconnectedCallback(){var t,r;null===(t=this.hark)||void 0===t||t.stop(),null===(r=this.participant)||void 0===r||r.removeListener("audioUpdate",this.onAudioUpdate)}participantChanged(t){t&&(this.audioEnabled=t.audioEnabled,t.addListener("audioUpdate",this.onAudioUpdate))}calcVolume(t){this.hark=s(t,{play:!1,interval:100}),this.hark.on("volume_change",(t=>{const r=this.volume;let a=Math.round(10**(t/115)*10);a<3&&(a=0);let i=Math.round((2*r+a)/3);r!==i&&(this.volume=i)}))}render(){if(!this.meeting)return null;const t={meeting:this.meeting,size:this.size,config:this.config,states:this.states,iconPack:this.iconPack,t:this.t};let o="bar-0";return o=this.volume>5?"bar-5":this.volume<0?"bar-0":"bar-"+this.volume,r(a,null,r("div",{class:{"avatar-ctr":!0,speaking:this.audioEnabled,[o]:!0}},r("rtk-avatar",{participant:this.participant,size:this.size},!this.audioEnabled&&r("div",{class:"mic-icon"},r("rtk-icon",{icon:i.mic_off})))),r("rtk-name-tag",Object.assign({variant:"text",participant:this.participant},t)),r("slot",null))}static get watchers(){return{participant:["participantChanged"]}}};c([e()],n.prototype,"meeting",void 0),c([e()],n.prototype,"config",void 0),c([e()],n.prototype,"states",void 0),c([e()],n.prototype,"iconPack",void 0),c([e()],n.prototype,"t",void 0),n.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{box-sizing:border-box;display:flex;flex-direction:column}.avatar-ctr{box-sizing:border-box;width:100%;flex:1 1 0%;padding:var(--rtk-space-1\\.5, 6px);border:2px solid transparent;border-radius:calc(var(--rtk-border-radius-xl, 40px) + var(--rtk-space-1\\.5, 6px))}.avatar-ctr.speaking{--tw-border-opacity:1;border-color:rgba(var(--rtk-colors-brand-500, 33 96 253) / var(--tw-border-opacity));transition-property:box-shadow;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transition-duration:150ms}.bar-0{box-shadow:none}.bar-1{box-shadow:0 0 4px rgb(var(--rtk-colors-brand-500, 33 96 253))}.bar-2{box-shadow:0 0 8px rgb(var(--rtk-colors-brand-500, 33 96 253))}.bar-3{box-shadow:0 0 16px 1px rgb(var(--rtk-colors-brand-500, 33 96 253))}.bar-4{box-shadow:0 0 20px 3px rgb(var(--rtk-colors-brand-500, 33 96 253))}.bar-5{box-shadow:0 0 24px 6px rgb(var(--rtk-colors-brand-500, 33 96 253))}rtk-avatar{aspect-ratio:1 / 1;height:100%;width:100%;position:relative;border-radius:var(--rtk-border-radius-xl, 40px)}rtk-name-tag{display:block;height:var(--rtk-space-10, 40px);width:100%;text-align:center;line-height:2.5rem}:host([size='sm']) .avatar-ctr{border-radius:calc(var(--rtk-border-radius-lg, 12px) + var(--rtk-space-1\\.5, 6px))}:host([size='sm']) rtk-name-tag{height:var(--rtk-space-7, 28px);line-height:1.75rem}:host([size='sm']) rtk-avatar{border-radius:var(--rtk-border-radius-lg, 12px)}.mic-icon{position:absolute;bottom:calc(var(--rtk-space-1, 4px) * -1);right:calc(var(--rtk-space-1, 4px) * -1);border-radius:9999px;--tw-bg-opacity:1;background-color:rgba(var(--rtk-colors-background-600, 60 60 60) / var(--tw-bg-opacity));padding:var(--rtk-space-2, 8px);color:rgb(var(--rtk-colors-text-1000, 255 255 255));--tw-shadow:0 1px 2px 0 rgb(0 0 0 / 0.05);--tw-shadow-colored:0 1px 2px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.mic-icon rtk-icon{height:var(--rtk-space-7, 28px);width:var(--rtk-space-7, 28px)}:host([size='sm']) .mic-icon rtk-icon{height:var(--rtk-space-4, 16px);width:var(--rtk-space-4, 16px)}:host([size='md']) .mic-icon rtk-icon{height:var(--rtk-space-5, 20px);width:var(--rtk-space-5, 20px)}";export{n as rtk_audio_tile}