Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@daily-co/daily-react

Package Overview
Dependencies
Maintainers
15
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@daily-co/daily-react - npm Package Compare versions

Comparing version 0.21.3 to 0.22.0

2

dist/daily-react.cjs.production.min.js

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("jotai/utils"),t=require("react"),a=e(t),i=require("jotai"),r=e(require("lodash.throttle")),o=e(require("@daily-co/daily-js")),u=e(require("fast-deep-equal"));function l(e,n,t,a,i,r,o){try{var u=e[r](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(a,i)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(a,i){var r=e.apply(n,t);function o(e){l(r,a,i,o,u,"next",e)}function u(e){l(r,a,i,o,u,"throw",e)}o(void 0)}))}}function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}function d(e,n){if(null==e)return{};var t,a,i={},r=Object.keys(e);for(a=0;a<r.length;a++)n.indexOf(t=r[a])>=0||(i[t]=e[t]);return i}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=new Array(n);t<n;t++)a[t]=e[t];return a}function p(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return f(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?f(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var v=t.createContext(null),m=function(){var e=t.useContext(v);return t.useDebugValue(e),e},g=t.createContext({on:function(){},off:function(){}}),b=-1,y=function(){return b--},k=1,h=function(){return k++},C=function(e,n,a){void 0===a&&(a=!1);var i=t.useContext(g),r=i.off,o=i.on,u=t.useState(!1),l=u[0],c=u[1],s=t.useRef(0),d=t.useMemo((function(){return a?y():h()}),[a]);t.useEffect((function(){if(e&&!l){if(s.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",n),void c(!0);s.current++;var t=setTimeout((function(){s.current=0}),50);return o(e,n,d),function(){clearTimeout(t),r(e,d)}}}),[n,e,d,l,r,o]),t.useDebugValue({event:e,eventId:d,isBlocked:l,callback:n})};function A(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(!A(e[t],n[t]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&n instanceof MediaStream)return e.id===n.id&&e.active===n.active&&e.getTracks().length===n.getTracks().length&&e.getTracks().every((function(e,t){return A(e,n.getTracks()[t])}));if(MediaStreamTrack&&e instanceof MediaStreamTrack&&n instanceof MediaStreamTrack)return e.id===n.id&&e.kind===n.kind&&e.readyState===n.readyState;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.source===n.source&&e.flags===n.flags;if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;var a=Array.from(e).sort(),i=Array.from(n).sort();return a.every((function(e,n){return A(e,i[n])}))}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(var r,o=p(e.entries());!(r=o()).done;){var u=r.value,l=u[0],c=u[1];if(!n.has(l)||!A(c,n.get(l)))return!1}return!0}if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var s=Object.keys(e),d=Object.keys(n);if(s.length!==d.length)return!1;for(var f=0;f<s.length;f++){var v=s[f];if(!Object.prototype.hasOwnProperty.call(n,v)||!A(e[v],n[v]))return!1}return!0}function S(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++){var a=e[t],i=n[t];if(null!==a&&"object"==typeof a||null!==i&&"object"==typeof i){if(!A(a,i))return!1}else if(a!==i)return!1}return!0}function E(e){var n=new Map,t=new Map;return function(a){if(!n.has(a)){var r=i.atom((function(n){var i=e.get(a)(n),r=t.get(a);return null!=r&&e.equals(i,r)?r:(t.set(a,i),i)}));n.set(a,r)}return n.get(a)}}var D=function(e,n){return e+"::"+n},w=function(e,n){return I(D(e,n))},x=n.atomFamily((function(e){return i.atom([])})),I=n.atomFamily((function(e){return i.atom(null)})),V=E({equals:S,get:function(e){return function(n){var t=e.split("::"),a=t[0];return t[1].split(";").map((function(e){return n(w(a,e))}))}}}),L=function(e,n){var a,r=i.useAtomValue(Array.isArray(n)?V(function(e,n){return e+"::"+n.join(";")}(e,n)):I(D(e,n)));return t.useDebugValue(Array.isArray(n)?n.reduce((function(e,n,t){return e[n]=r[t],e}),{}):((a={})[n]=r,a)),r},R=function(e,n,a,i){void 0===a&&(a=500),void 0===i&&(i=!1);var o=t.useContext(g),u=o.off,l=o.on,c=t.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=i?y():h(),e}),{}):((n={})[e]=i?y():h(),n)}),[e,i]),s=t.useRef([]);C("call-instance-destroyed",t.useCallback((function(){s.current.length=0}),[]));var d=t.useMemo((function(){return r((function(){0!==s.current.length&&(n(s.current),s.current.length=0)}),a,{trailing:!0})}),[n,a]);t.useEffect((function(){if(e){var n=function(e){s.current.push(e),d()};return Array.isArray(e)?e.forEach((function(e){return l(e,n,c[e])})):l(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return u(e,c[e])})):u(e,c[e])}}}),[d,e,c,u,l]),t.useDebugValue({event:e,eventId:c})},P=function(e){return function e(n,t,a){if(void 0===t&&(t=""),void 0===a&&(a=new Set),"object"!=typeof n||null===n||a.has(n))return[t];a.add(n);var i=[];for(var r in n)if(Object.prototype.hasOwnProperty.call(n,r)){var o=t?t+"."+r:r;i.push.apply(i,[o].concat(e(n[r],o,a)))}return a.delete(n),i}(e)},_=function(e,n){return n.map((function(n){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(e,n)}))},j=i.atom(null),M=i.atom(""),T=i.atom(null),O=i.atom([]),F=n.atomFamily((function(e){return i.atom(null)})),q=i.atom([]),B=n.atomFamily((function(e){return i.atom({awaitingAccess:{level:"full"},id:e,name:""})})),U=E({equals:S,get:function(){return function(e){return e(q).map((function(n){return e(B(n))}))}}}),W=function(e){var i=e.children,r=m(),o=t.useState(!1),u=o[0],l=o[1],c=n.useAtomCallback(t.useCallback((function(e,n,t){n(M,t.local.session_id);var a=Object.values(t),i=a.map((function(e){return e.session_id}));n(O,i),a.forEach((function(e){n(F(e.session_id),e);var t=P(e);n(x(e.session_id),t),t.forEach((function(t){var a=_(e,[t])[0];n(w(e.session_id,t),a)}))})),l(!0)}),[]));t.useEffect((function(){if(r&&!u){var e=setInterval((function(){var n=r.participants();"local"in n&&(c(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[r,u,c]);var d=t.useCallback((function(){if(r){var e=null==r?void 0:r.participants();e.local&&c(e)}}),[r,c]);C("started-camera",d,!0),C("access-state-updated",d,!0),C("joining-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(T,new Date),d()}),[d])),!0),C("joined-meeting",t.useCallback((function(e){c(e.participants)}),[c]),!0);var f=n.useAtomCallback(t.useCallback((function(e,n){n(M,""),n(j,null),e(O).forEach((function(e){return F.remove(e)})),n(O,[])}),[]));return C("call-instance-destroyed",f,!0),C("left-meeting",f,!0),R(["active-speaker-change","participant-joined","participant-updated","participant-left"],n.useAtomCallback(t.useCallback((function(e,n,t){t.length&&t.forEach((function(t){switch(t.action){case"active-speaker-change":n(j,t.activeSpeaker.peerId),n(F(t.activeSpeaker.peerId),(function(e){return e?s({},e,{last_active:new Date}):null}));break;case"participant-joined":n(O,(function(e){return e.includes(t.participant.session_id)?e:[].concat(e,[t.participant.session_id])})),n(F(t.participant.session_id),t.participant);var a=P(t.participant);n(x(t.participant.session_id),a),a.forEach((function(e){var a=_(t.participant,[e])[0];n(w(t.participant.session_id,e),a)}));break;case"participant-updated":n(F(t.participant.session_id),t.participant),t.participant.local&&n(M,t.participant.session_id);var i=P(t.participant),r=e(x(t.participant.session_id));(i.length!==r.length||i.some((function(e){return!r.includes(e)})))&&n(x(t.participant.session_id),i);var o=new Set(r),u=_(t.participant,i);i.forEach((function(e,a){var i=u[a];o.delete(e),n(w(t.participant.session_id,e),(function(e){return A(e,i)?e:i}))})),o.forEach((function(e){n(w(t.participant.session_id,e),null)}));break;case"participant-left":n(O,(function(e){return e.includes(t.participant.session_id)?e.filter((function(e){return e!==t.participant.session_id})):e})),F.remove(t.participant.session_id),e(x(t.participant.session_id)).forEach((function(e){I.remove(D(t.participant.session_id,e))})),x.remove(t.participant.session_id)}}))}),[])),100,!0),R(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],n.useAtomCallback(t.useCallback((function(e,n,t){t.forEach((function(e){switch(e.action){case"waiting-participant-added":n(q,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),n(B(e.participant.id),e.participant);break;case"waiting-participant-updated":n(B(e.participant.id),e.participant);break;case"waiting-participant-removed":n(q,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),B.remove(e.participant.id)}}))}),[])),100,!0),a.createElement(a.Fragment,null,i)},z=function(){var e=i.useAtomValue(M);return t.useDebugValue(e),e},N=function(){return!0},G=function(e){var n=void 0===e?{}:e,a=n.filter,r=void 0===a?N:a,o=n.ignoreLocal,u=void 0!==o&&o,l=z(),c=i.useAtomValue(j),s=u&&c===l,d=!(null!=r&&r(c)),f=t.useState(s||d?null:c),p=f[0],v=f[1];return t.useEffect((function(){s||d||v(c)}),[d,s,c]),t.useDebugValue(p),p},H=function(e){return["blocked","off"].includes(e)},J=function(e,n){return e+";"+n},Q=E({equals:A,get:function(e){return function(n){var t=e.split(";"),a=t[0],i=t[1];return n(O).filter((function(e){switch(a){case"local":case"owner":case"record":return n(w(e,a));case"remote":return!n(w(e,"local"));case"screen":var t=n(w(e,"tracks.screenAudio.state")),i=n(w(e,"tracks.screenVideo.state"));return!H(t)||!H(i);default:return!0}})).sort((function(e,t){switch(i){case"joined_at":case"session_id":case"user_id":case"user_name":var a=n(w(e,i)),r=n(w(t,i));if(void 0!==a||void 0!==r){if(void 0===a)return-1;if(void 0===r)return 1;if(a>r)return 1;if(a<r)return-1}return 0;default:return 0}}))}}}),$=function(e){var a=void 0===e?{}:e,r=a.filter,o=a.onActiveSpeakerChange,u=a.onParticipantJoined,l=a.onParticipantLeft,c=a.onParticipantUpdated,s=a.sort,d=i.useAtomValue(Q(J("string"==typeof r?r:null,"string"==typeof s?s:null))),f="function"==typeof r||"function"==typeof s,p=t.useCallback((function(e){return"function"!=typeof r&&"function"!=typeof s?[]:d.map((function(n){return e(F(n))})).filter((function(e){return Boolean(e)})).filter("function"==typeof r?r:function(){return!0}).sort("function"==typeof s?s:function(){return 0}).map((function(e){return e.session_id})).filter(Boolean)}),[r,d,s]),v=t.useState([]),m=v[0],g=v[1],b=n.useAtomCallback(t.useCallback((function(e){if(f){var n=p(e);A(n,m)||g(n)}}),[m,p,f]));t.useEffect((function(){b()}),[b]),R(["participant-joined","participant-updated","active-speaker-change","participant-left"],t.useCallback((function(e){e.length&&(e.forEach((function(e){switch(e.action){case"participant-joined":null==u||u(e);break;case"participant-updated":null==c||c(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==l||l(e)}})),b())}),[b,o,u,l,c]));var y="function"==typeof r||"function"==typeof s?m:d;return t.useDebugValue(y),y},K=E({equals:S,get:function(){return function(e){return e(Q(J("screen",null))).map((function(n){return{local:e(w(n,"local")),screenAudio:e(w(n,"tracks.screenAudio")),screenVideo:e(w(n,"tracks.screenVideo")),screenId:n+"-screen",session_id:n}}))}}}),X=function(e){var n=void 0===e?{}:e,a=n.onError,r=n.onLocalScreenShareStarted,o=n.onLocalScreenShareStopped,u=m(),l=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==u||u.startScreenShare.apply(u,n)}),[u]),c=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==u||u.stopScreenShare.apply(u,n)}),[u]);C("local-screen-share-started",t.useCallback((function(){return null==r?void 0:r()}),[r])),C("local-screen-share-stopped",t.useCallback((function(){return null==o?void 0:o()}),[o])),C("nonfatal-error",t.useCallback((function(e){"screen-share-error"===e.type&&(null==a||a(e))}),[a]));var s=i.useAtomValue(K(void 0)),d={isSharingScreen:s.some((function(e){return e.local})),screens:s,startScreenShare:l,stopScreenShare:c};return t.useDebugValue(d),d},Y=function(e,n){void 0===n&&(n="video");var a=L(e,"tracks."+n),i=a?s({},a,{isOff:H(a.state)}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1};return t.useDebugValue(i),i};function Z(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return t.useCallback((function(e){for(var t=0;t<n.length;t++){var a=n[t];"function"==typeof a?a(e):a&&"object"==typeof a&&(a.current=e)}}),n)}var ee=["onPlayFailed","sessionId","type"],ne=t.memo(t.forwardRef((function(e,n){var i=e.onPlayFailed,r=e.sessionId,o=e.type,u=void 0===o?"audio":o,l=d(e,ee),c=t.useRef(null),s=Y(r,u),f=Z(c,n),p=null==s?void 0:s.subscribed;return t.useEffect((function(){var e=c.current;if(e&&null!=s&&s.persistentTrack){var n=function(){e.play().catch((function(n){null==i||i({sessionId:r,target:e,type:u,message:n.message,name:n.name})}))},t=function(){clearTimeout(void 0)};return MediaStream?(e.addEventListener("canplay",n),e.addEventListener("play",t),e.srcObject=new MediaStream([null==s?void 0:s.persistentTrack]),function(){null==e||e.removeEventListener("canplay",n),null==e||e.removeEventListener("play",t)}):(console.warn("MediaStream API not available. Can't setup "+u+" for "+r),void(null==i||i({sessionId:r,target:e,type:u,message:"MediaStream API not available",name:"MediaStream API not available"})))}}),[null==s?void 0:s.persistentTrack,i,r,u]),a.createElement("audio",Object.assign({autoPlay:!0,ref:f},l,{"data-session-id":r,"data-audio-type":u,"data-subscribed":p}))})));ne.displayName="DailyAudioTrack";var te=t.memo(t.forwardRef((function(e,i){var r=e.autoSubscribeActiveSpeaker,o=void 0!==r&&r,u=e.maxSpeakers,l=void 0===u?5:u,s=e.onPlayFailed,d=e.playLocalScreenAudio,f=void 0!==d&&d,p=m(),v=t.useState(new Array(l).fill("")),g=v[0],b=v[1],y=X().screens,k=z(),h=G({ignoreLocal:!0}),C=t.useRef(null);t.useImperativeHandle(i,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=C.current)?void 0:n.querySelector('audio[data-session-id="'+h+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[h]);var A=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n,t){var a,i=Object.values(null!=(a=null==p?void 0:p.participants())?a:{}).filter((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)})),r=function(e){return i.some((function(n){return n.session_id===e}))};if(!r(t)){if(!p||p.isDestroyed()||!o||p.subscribeToTracksAutomatically())return;p.updateParticipant(t,{setSubscribedTracks:{audio:!0}})}b((function(n){var a;if(n.includes(t))return n;var o=function(e){return!e||!r(e)};if(n.some(o)){var u=n.findIndex(o);return n[u]=t,[].concat(n)}var l=n.findIndex((function(e){return i.some((function(n){return n.session_id===e&&H(n.tracks.audio.state)}))}));if(l>=0)return n[l]=t,[].concat(n);var c=i.filter((function(e){return n.includes(e.session_id)&&e.session_id!==h})).sort((function(n,t){var a,i,r=null!=(a=e(w(n.session_id,"last_active")))?a:new Date("1970-01-01"),o=null!=(i=e(w(t.session_id,"last_active")))?i:new Date("1970-01-01");return r>o?1:r<o?-1:0}));if(!c.length){var s=n.findIndex((function(e){return e!==h}));return n[s]=t,[].concat(n)}var d=n.indexOf(null==(a=c[0])?void 0:a.session_id);return n[d]=t,[].concat(n)}))}));return function(n,t,a){return e.apply(this,arguments)}}(),[h,o,p])),S=t.useCallback((function(e){b((function(n){if(!n.includes(e))return n;var t=[].concat(n),a=t.indexOf(e);return t[a]="",t}))}),[]);R(["active-speaker-change","track-started","participant-left"],t.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===k)return;A(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&A(e.participant.session_id);break;case"participant-left":S(e.participant.session_id)}}))}),[A,k,S]),200);var E=$({filter:t.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return a.createElement("div",{ref:C},g.map((function(e,n){return a.createElement(ne,{key:"speaker-slot-"+n,onPlayFailed:s,sessionId:e,type:"audio"})})),y.filter((function(e){return!!f||!e.local})).map((function(e){return a.createElement(ne,{key:e.screenId,onPlayFailed:s,sessionId:e.session_id,type:"screenAudio"})})),E.map((function(e){return a.createElement(ne,{key:e+"-rmp",onPlayFailed:s,sessionId:e,type:"rmpAudio"})})))})));te.displayName="DailyAudio";var ae=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],ie=t.forwardRef((function(e,n){var i=e.automirror,r=e.fit,o=void 0===r?"contain":r,u=e.mirror,l=e.onResize,c=e.playableStyle,f=void 0===c?{}:c,p=e.sessionId,v=e.style,m=void 0===v?{}:v,g=e.type,b=void 0===g?"video":g,y=d(e,ae),k=z()===p,h="screenVideo"===b,C=k&&!h,A=t.useRef(null),S=Z(A,n),E=Y(p,b),D=E.persistentTrack,w=C||h||!E.isOff,x=L(p,"tracks."+b),I=null==x?void 0:x.subscribed,V=t.useMemo((function(){if("boolean"==typeof u)return u;if(!i)return!1;if(!D)return C;var e=D.getSettings();return"facingMode"in e?C&&"user"===e.facingMode:C}),[i,C,u,D]);return t.useEffect((function(){var e=A.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},a=function(){e.style.transform="scale(1)"},i=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},r=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",a),e.addEventListener("leavepictureinpicture",i),document.addEventListener("visibilitychange",r),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",a),e.removeEventListener("leavepictureinpicture",i),document.removeEventListener("visibilitychange",r)}}}),[]),t.useEffect((function(){var e=A.current;if(e&&D){if(MediaStream)return e.srcObject=new MediaStream([D]),e.load(),function(){e.srcObject=null,e.load()};console.warn("MediaStream API not available. Can't setup "+b+" for "+p)}}),[p,b,D,null==D?void 0:D.id]),t.useEffect((function(){var e,n=A.current;if(l&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=A.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==l||l({aspectRatio:n/t,height:t,width:n}))}}))}}),[l]),a.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:S,"data-local":k,"data-mirrored":V||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":I,"data-video-type":b,style:s({objectFit:o,transform:V?"scale(-1, 1)":""},m,w?f:{})},y))}));ie.displayName="DailyVideo";var re=t.createContext({refreshDevices:function(){return Promise.resolve()}}),oe=i.atom("idle"),ue=i.atom("idle"),le=i.atom([]),ce=i.atom([]),se=i.atom([]),de=i.atom(null),fe=function(e){var i=e.children,r=m(),o=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){var t,a,i,o;if(void 0===(null==(t=navigator)||null==(a=t.mediaDevices)?void 0:a.getUserMedia)||void 0===(null==(i=navigator)||null==(o=i.mediaDevices)?void 0:o.enumerateDevices))return n(oe,"not-supported"),void n(ue,"not-supported");if(r)try{var u=(yield r.enumerateDevices()).devices,l=u.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),d=yield r.getInputDevices(),f=d.camera,p=d.mic,v=d.speaker,m=function(e,n,t){var a,i;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(a=null==(i=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:i.state)?a:"granted"}},g=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n(le,(function(e){return l.filter(Boolean).map((function(n){return m(f,n,e)})).sort(g)})),n(ce,(function(e){return c.filter(Boolean).map((function(n){return m(p,n,e)})).sort(g)})),n(se,(function(e){return s.filter(Boolean).map((function(n){return m(v,n,e)})).sort(g)}))}catch(e){n(oe,"not-supported"),n(ue,"not-supported")}}));return function(n,t){return e.apply(this,arguments)}}(),[r])),u=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){var t,a,i,u,l,c,d,f,p,v,m,g,b,y;if(r){var k=e(oe),h=e(ue),C=r.participants();if(C.local){var A=C.local.tracks,S="prompt",E="prompt";if(navigator.permissions)try{S=(yield navigator.permissions.query({name:"camera"})).state,E=(yield navigator.permissions.query({name:"microphone"})).state}catch(e){}var D="prompt"===S&&["idle","pending"].includes(k)&&"interrupted"===A.video.state&&!A.video.persistentTrack,w=["idle","pending"].includes(k)&&!A.video.persistentTrack&&Boolean(null==(t=A.video.off)?void 0:t.byUser),x="prompt"===E&&["idle","pending"].includes(h)&&"interrupted"===A.audio.state&&!A.audio.persistentTrack,I=["idle","pending"].includes(h)&&!A.audio.persistentTrack&&Boolean(null==(a=A.audio.off)?void 0:a.byUser);null!=(i=A.audio)&&null!=(u=i.blocked)&&u.byDeviceInUse?(n(ue,"in-use"),n(ce,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"in-use"}):e}))}))):null!=(l=A.audio)&&null!=(c=l.blocked)&&c.byDeviceMissing?n(ue,"not-found"):null!=(d=A.audio)&&null!=(f=d.blocked)&&f.byPermissions||"denied"===E?n(ue,"blocked"):x?n(ue,"pending"):I?n(ue,"idle"):(n(ue,"granted"),n(ce,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"granted"}):e}))}))),null!=(p=A.video)&&null!=(v=p.blocked)&&v.byDeviceInUse?(n(oe,"in-use"),n(le,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"in-use"}):e}))}))):null!=(m=A.video)&&null!=(g=m.blocked)&&g.byDeviceMissing?n(oe,"not-found"):null!=(b=A.video)&&null!=(y=b.blocked)&&y.byPermissions||"denied"===S?n(oe,"blocked"):D?n(oe,"pending"):w?n(oe,"idle"):(n(oe,"granted"),n(le,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"granted"}):e}))}))),o()}}}));return function(n,t){return e.apply(this,arguments)}}(),[r,o]));return C("participant-updated",t.useCallback((function(e){e.participant.local&&u()}),[u])),C("available-devices-updated",o),C("selected-devices-updated",o),C("camera-error",n.useAtomCallback(t.useCallback((function(e,n,t){var a,i,r,o,u,l,c;switch(n(de,t.error),null==(a=t.error)?void 0:a.type){case"cam-in-use":n(oe,"in-use");break;case"mic-in-use":n(ue,"in-use");break;case"cam-mic-in-use":n(oe,"in-use"),n(ue,"in-use");break;case"not-found":null!=(i=t.error)&&i.missingMedia.includes("video")&&n(oe,"not-found"),null!=(r=t.error)&&r.missingMedia.includes("audio")&&n(ue,"not-found");break;case"permissions":null!=(o=t.error)&&o.blockedMedia.includes("video")&&n(oe,"blocked"),null!=(u=t.error)&&u.blockedMedia.includes("audio")&&n(ue,"blocked");break;case"constraints":"invalid"===(null==(l=t.error)?void 0:l.reason)?(n(oe,"constraints-invalid"),n(ue,"constraints-invalid")):"none-specified"===(null==(c=t.error)?void 0:c.reason)&&(n(oe,"constraints-none-specified"),n(ue,"constraints-none-specified"));break;case"undefined-mediadevices":n(oe,"undefined-mediadevices"),n(ue,"undefined-mediadevices");break;case"unknown":default:n(oe,"unknown"),n(ue,"unknown")}}),[]))),C("started-camera",n.useAtomCallback(t.useCallback((function(e,n){n(oe,"granted"),n(ue,"granted"),u()}),[u]))),a.createElement(re.Provider,{value:{refreshDevices:o}},i)},pe=i.atom({errorMsg:void 0,isLiveStreaming:!1,layout:void 0}),ve=function(e){var i=e.children;return C("live-streaming-started",n.useAtomCallback(t.useCallback((function(e,n,t){n(pe,{isLiveStreaming:!0,layout:null==t?void 0:t.layout})}),[]))),C("live-streaming-stopped",n.useAtomCallback(t.useCallback((function(e,n){n(pe,(function(e){return s({},e,{isLiveStreaming:!1,layout:void 0})}))}),[]))),C("live-streaming-error",n.useAtomCallback(t.useCallback((function(e,n,t){n(pe,(function(e){return s({},e,{errorMsg:t.errorMsg})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(pe,{errorMsg:void 0,isLiveStreaming:!1,layout:void 0})}),[]))),a.createElement(a.Fragment,null,i)},me=i.atom("new"),ge=i.atom(null),be=i.atom(null),ye=i.atom({data:void 0,topology:"none"}),ke=function(e){var i=e.children,r=m(),o=n.useAtomCallback(t.useCallback((function(e,n){if(r){var t=r.meetingState();return n(me,t),t}}),[r]));C("loading",o),C("loaded",o),C("joining-meeting",o),C("joined-meeting",o),C("left-meeting",o),C("error",n.useAtomCallback(t.useCallback((function(e,n,t){n(ge,t),o()}),[o]))),C("nonfatal-error",n.useAtomCallback(t.useCallback((function(e,n,t){n(be,t)}),[])));var u=n.useAtomCallback(t.useCallback((function(e,n){r&&n(ye,r.meetingSessionState())}),[r]));return C("joined-meeting",u),C("meeting-session-state-updated",n.useAtomCallback(t.useCallback((function(e,n,t){n(ye,t.meetingSessionState)}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(ye,{data:void 0,topology:"none"})}),[]))),C("call-instance-destroyed",n.useAtomCallback(t.useCallback((function(e,n){n(me,"new"),n(ge,null),n(be,null),n(ye,{data:void 0,topology:"none"})}),[]))),a.createElement(a.Fragment,null,i)},he=i.atom("none"),Ce=i.atom(100),Ae=i.atom("good"),Se=function(e){var r=e.children,o=m(),u=i.useAtomValue(he),l=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){if(o){var t=yield o.getNetworkTopology();t&&"none"!==(null==t?void 0:t.topology)&&n(he,t.topology)}}));return function(n,t){return e.apply(this,arguments)}}(),[o]));return C("joined-meeting",l),C("network-connection",n.useAtomCallback(t.useCallback((function(e,n,t){switch(t.event){case"connected":"peer-to-peer"===t.type&&n(he,"peer"),"sfu"===t.type&&n(he,"sfu")}}),[]))),C("network-quality-change",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ce,(function(e){return e!==t.quality?t.quality:e})),n(Ae,(function(e){return e!==t.threshold?t.threshold:e}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(he,"none"),n(Ce,100),n(Ae,"good")}),[]))),t.useEffect((function(){o&&"none"===u&&l()}),[o,l,u]),a.createElement(a.Fragment,null,r)},Ee=i.atom({isLocalParticipantRecorded:!1,isRecording:!1}),De=function(e){var i=e.children,r=z(),o=$({filter:"record"}),u=n.useAtomCallback(t.useCallback((function(e,n,t,a){var i=e(Ee),r={isLocalParticipantRecorded:i.isLocalParticipantRecorded,isRecording:i.isRecording,local:i.local,type:i.type},o={isLocalParticipantRecorded:"local"!==(null==r?void 0:r.type)&&null!=r&&r.type?r.isLocalParticipantRecorded:t,isRecording:"local"!==(null==r?void 0:r.type)&&null!=r&&r.type?r.isRecording:t,local:"local"!==(null==r?void 0:r.type)&&null!=r&&r.type||!t?null==r?void 0:r.local:a,type:t?"local":null==i?void 0:i.type};A(r,o)||n(Ee,s({},r,o))}),[]));return t.useEffect((function(){var e=o.length>0,n=o.includes(r||"local");u(e,n)}),[r,u,o]),C("recording-started",n.useAtomCallback(t.useCallback((function(e,n,t){var a=!0;switch(t.type){case"cloud-beta":case"cloud":var i;r&&"single-participant"===(null==(i=t.layout)?void 0:i.preset)&&t.layout.session_id!==r&&(a=!1)}n(Ee,{error:!1,isLocalParticipantRecorded:a,isRecording:!0,layout:null==t?void 0:t.layout,local:null==t?void 0:t.local,recordingId:null==t?void 0:t.recordingId,recordingStartedDate:new Date,startedBy:null==t?void 0:t.startedBy,type:null==t?void 0:t.type})}),[r]))),C("recording-stopped",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,(function(e){return s({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}),[]))),C("recording-error",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,(function(e){return s({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,{isLocalParticipantRecorded:!1,isRecording:!1})}),[]))),a.createElement(a.Fragment,null,i)},we=function(){var e=i.useAtomValue(me);return t.useDebugValue(e),e},xe=i.atom(null),Ie=function(e){var i=e.children,r=m(),o=we(),u=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){if(r&&"left-meeting"!==o){var t=yield r.room();return t&&"id"in t&&n(xe,t),t}}));return function(n,t){return e.apply(this,arguments)}}(),[r,o]));return C("access-state-updated",u),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){return function(){n(xe,null)}}),[]))),a.createElement(a.Fragment,null,i)},Ve=i.atom({isTranscribing:!1,model:"general",language:"en",transcriptions:[]}),Le=function(e){var i=e.children;return C("transcription-started",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ve,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:t.endpointing,extra:t.extra,includeRawResponse:t.includeRawResponse,instanceId:t.instanceId,language:t.language,model:t.model,profanity_filter:t.profanity_filter,punctuate:t.punctuate,redact:t.redact,startedBy:t.startedBy,tier:t.tier})}),[]))),C("transcription-stopped",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ve,(function(e){return s({},e,{updatedBy:t.updatedBy,isTranscribing:!1})}))}),[]))),C("transcription-error",n.useAtomCallback(t.useCallback((function(e,n){n(Ve,(function(e){return s({},e,{error:!0,isTranscribing:!1})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(Ve,(function(e){return s({},e,{isTranscribing:!1})}))}),[]))),C("app-message",n.useAtomCallback(t.useCallback((function(e,n,t){"transcription"===(null==t?void 0:t.fromId)&&n(Ve,(function(e){return s({},e,{isTranscribing:!0,transcriptions:[].concat(e.transcriptions,[t.data])})}))}),[]))),a.createElement(a.Fragment,null,i)},Re={},Pe=function(){return!0},_e={options:Re,shouldCreateInstance:Pe},je=function(e,n){var a=void 0===n?_e:n,i=a.parentElRef,r=a.options,u=void 0===r?Re:r,l=a.shouldCreateInstance,d=void 0===l?Pe:l,f=t.useState(null),p=f[0],v=f[1],m=t.useRef();return t.useEffect((function(){if(("callFrame"!==e||null!==(null==i?void 0:i.current))&&d()){var n=function(){setTimeout((function(){return v(null)}),0)},t=o.getCallInstance();if(!p&&t&&!t.isDestroyed())return t.once("call-instance-destroyed",n),void v(t);if(p)A(m.current,u)||function(e){a.apply(this,arguments)}(p);else{if(!t||t.isDestroyed()){switch(e){case"callFrame":t=null!=i&&i.current?o.createFrame(i.current,s({},u)):o.createFrame(s({},u));break;case"callObject":t=o.createCallObject(s({},u))}m.current=u}v(t),t.once("call-instance-destroyed",n)}}function a(){return(a=c((function*(e){yield e.destroy()}))).apply(this,arguments)}}),[p,u,i,d,e]),p},Me=function(e){return je("callObject",e)},Te=["children","jotaiStore"],Oe=function(e,n){var a=void 0===n?{}:n,r=a.onParticipantLeft,o=a.onParticipantUpdated,u=i.useAtomValue(F(e));return R(["participant-updated","participant-left"],t.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==r||r(e)}}))}),[r,o,e])),t.useDebugValue(u),u},Fe="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),qe=i.atom({state:"low",reason:"none"}),Be=function(){var e={meetingError:i.useAtomValue(ge),nonFatalError:i.useAtomValue(be)};return t.useDebugValue(e),e},Ue=i.atom(null),We=i.atom({hidden:0,present:0}),ze=n.atomFamily((function(e){return i.atom({},(function(n,t,a){t(ze(e),a)}))})),Ne=function(){var e=i.useAtomValue(xe);return t.useDebugValue(e),e},Ge=i.atom(null);exports.DailyAudio=te,exports.DailyAudioTrack=ne,exports.DailyProvider=function(e){var n=e.children,r=e.jotaiStore,o=d(e,Te),u=t.useRef({}),l=t.useCallback((function(e){var n,t;if("action"in e)for(var a,i=Array.from(null!=(n=null==(t=u.current)?void 0:t[e.action])?n:[]),r=i.filter((function(e){return e[0]<0})),o=i.filter((function(e){return e[0]>0})),l=p([].concat(r,o));!(a=l()).done;)(0,a.value[1])(e)}),[]),c=t.useCallback((function(e){e&&Object.keys(u.current).forEach((function(n){e.off(n,l),e.isDestroyed()||e.on(n,l)}))}),[l]),s="callObject"in o?o.callObject:null,f=t.useMemo((function(){return"callObject"in o?{}:o}),[o]),m=Me({options:f,shouldCreateInstance:t.useCallback((function(){return!("callObject"in o)}),[o])}),b=null!=s?s:m;t.useEffect((function(){b&&c(b)}),[b,c]);var y=t.useCallback((function(e,n,t){var a,i;u.current[e]||(u.current[e]=new Map,b&&(b.off(e,l),b.isDestroyed()||b.on(e,l))),null!=(a=u.current[e])&&a.has(t)||null==(i=u.current[e])||i.set(t,n)}),[b,l]),k=t.useCallback((function(e,n){var t,a;null==(t=u.current[e])||t.delete(n),0===(null==(a=u.current[e])?void 0:a.size)&&(null==b||b.off(e,l),delete u.current[e])}),[b,l]);return a.createElement(i.Provider,{store:r},a.createElement(v.Provider,{value:b},a.createElement(g.Provider,{value:{on:y,off:k}},a.createElement(Ie,null,a.createElement(ke,null,a.createElement(Se,null,a.createElement(W,null,a.createElement(De,null,a.createElement(ve,null,a.createElement(Le,null,a.createElement(fe,null,n)))))))))))},exports.DailyVideo=ie,exports.useActiveParticipant=function(e){var n=void 0===e?{}:e,a=n.ignoreLocal,r=void 0!==a&&a,o=n.onActiveSpeakerChange,u=m(),l=i.useAtomValue(j),c=t.useState(""),s=c[1],d=Oe(c[0]);return t.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;r&&l===(null==n?void 0:n.session_id)||s(null!=l?l:"")}}),[u,r,l]),C("active-speaker-change",t.useCallback((function(e){null==o||o(e)}),[o])),t.useDebugValue(d),d},exports.useActiveSpeakerId=G,exports.useAppMessage=function(e){var n=(void 0===e?{}:e).onAppMessage,a=m(),i=t.useCallback((function(e,n){void 0===n&&(n="*"),a&&a.sendAppMessage(e,n)}),[a]),r=t.useCallback((function(e){null==n||n(e,i)}),[n,i]);return C("app-message",r),i},exports.useAudioLevel=function(e,n){var a=t.useRef();t.useEffect((function(){if(e){var t="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(t){a.current||(a.current=new t);var i=a.current;if(i&&MediaStream){var r,o,u=i.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{r=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){try{yield i.audioWorklet.addModule(Fe),r=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){console.error(e)}}if(r&&o){r.port.onmessage=function(e){var t=0;e.data.volume&&(t=e.data.volume),r&&n(t)},o.gain.value=0;try{u.connect(r).connect(o).connect(i.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=r)||e.disconnect(),r=null,null==u||u.disconnect()}}}}}),[n,e])},exports.useAudioLevelObserver=function(e,n){var a=m(),i=z(),r=e===i;C("local-audio-level",t.useCallback((function(e){r&&n(e.audioLevel)}),[n,r])),C("remote-participants-audio-level",t.useCallback((function(t){r||n(t.participantsAudioLevel[e])}),[n,e,r])),t.useEffect((function(){a&&!a.isDestroyed()&&r&&(a.isLocalAudioLevelObserverRunning()||a.startLocalAudioLevelObserver())}),[a,r]),t.useEffect((function(){!a||a.isDestroyed()||r||a.isRemoteParticipantsAudioLevelObserverRunning()||a.startRemoteParticipantsAudioLevelObserver()}),[a,r])},exports.useAudioTrack=function(e){return Y(e,"audio")},exports.useCPULoad=function(e){var a=(void 0===e?{}:e).onCPULoadChange,r=i.useAtomValue(qe),o=m(),l=we(),c=n.useAtomCallback(t.useCallback((function(e,n,t){var a=e(qe);u(a,t)||n(qe,t)}),[]));return t.useEffect((function(){var e=!0;if(o&&!o.isDestroyed()&&"joined-meeting"===l)return o.getCpuLoadStats().then((function(n){e&&c({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[o,l,c]),C("cpu-load-change",t.useCallback((function(e){c({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==a||a(e)}),[a,c])),t.useDebugValue(r),r},exports.useCallFrame=function(e){return je("callFrame",e)},exports.useCallObject=Me,exports.useDaily=m,exports.useDailyError=Be,exports.useDailyEvent=C,exports.useDevices=function(){var e=m(),n=i.useAtomValue(oe),a=i.useAtomValue(ue),r=i.useAtomValue(le),o=i.useAtomValue(ce),u=i.useAtomValue(se),l=i.useAtomValue(de),s=t.useContext(re).refreshDevices,d=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"],g={cameraError:l,cameras:r,camState:n,currentCam:r.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:v.includes(n),hasMicError:v.includes(a),microphones:o,micState:a,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u};return t.useDebugValue(g),g},exports.useInputSettings=function(e){var a=void 0===e?{}:e,r=a.onError,o=a.onInputSettingsUpdated,u=i.useAtomValue(Ue),l=Be().nonFatalError,c=m(),s=n.useAtomCallback(t.useCallback((function(e,n,t){n(Ue,t)}),[]));t.useEffect((function(){c&&c.getInputSettings().then(s)}),[c,s]),C("input-settings-updated",t.useCallback((function(e){s(e.inputSettings),null==o||o(e)}),[o,s])),C("nonfatal-error",t.useCallback((function(e){"input-settings-error"===e.type&&(null==r||r(e))}),[r]));var d=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return null==c?void 0:c.updateInputSettings.apply(c,n)}),[c]),f={errorMsg:"input-settings-error"===(null==l?void 0:l.type)?l.errorMsg:null,inputSettings:u,updateInputSettings:d};return t.useDebugValue(f),f},exports.useLiveStreaming=function(e){var n=void 0===e?{}:e,a=n.onLiveStreamingError,r=n.onLiveStreamingStarted,o=n.onLiveStreamingStopped,u=n.onLiveStreamingUpdated,l=n.onLiveStreamingWarning,c=m(),d=i.useAtomValue(pe);C("live-streaming-started",t.useCallback((function(e){null==r||r(e)}),[r])),C("live-streaming-stopped",t.useCallback((function(e){null==o||o(e)}),[o])),C("live-streaming-updated",t.useCallback((function(e){null==u||u(e)}),[u])),C("live-streaming-error",t.useCallback((function(e){null==a||a(e)}),[a])),C("nonfatal-error",t.useCallback((function(e){"live-streaming-warning"===e.type&&(null==l||l(e))}),[l]));var f=s({},d,{startLiveStreaming:t.useCallback((function(){c&&c.startLiveStreaming.apply(c,arguments)}),[c]),stopLiveStreaming:t.useCallback((function(){c&&c.stopLiveStreaming.apply(c,arguments)}),[c]),updateLiveStreaming:t.useCallback((function(){c&&c.updateLiveStreaming.apply(c,arguments)}),[c])});return t.useDebugValue(f),f},exports.useLocalParticipant=function(){var e=i.useAtomValue(M),n=Oe(e);return t.useDebugValue(n),n},exports.useLocalSessionId=z,exports.useMediaTrack=Y,exports.useMeetingSessionState=function(e){var n=(void 0===e?{}:e).onError,a=i.useAtomValue(ye);C("nonfatal-error",t.useCallback((function(e){"meeting-session-data-error"===e.type&&(null==n||n(e))}),[n]));var r={data:null==a?void 0:a.data,topology:null==a?void 0:a.topology};return t.useDebugValue(r),r},exports.useMeetingState=we,exports.useNetwork=function(e){var n=void 0===e?{}:e,a=n.onNetworkConnection,r=n.onNetworkQualityChange,o=m(),u=i.useAtomValue(he),l=i.useAtomValue(Ce),s=i.useAtomValue(Ae);C("network-connection",t.useCallback((function(e){null==a||a(e)}),[a])),C("network-quality-change",t.useCallback((function(e){null==r||r(e)}),[r]));var d={getStats:t.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u};return t.useDebugValue(d),d},exports.useParticipant=Oe,exports.useParticipantCounts=function(e){var a=(void 0===e?{}:e).onParticipantCountsUpdated,r=m(),o=i.useAtomValue(We),u=n.useAtomCallback(t.useCallback((function(e,n,t){n(We,t)}),[]));return C("participant-counts-updated",t.useCallback((function(e){u(e.participantCounts),null==a||a(e)}),[a,u])),t.useEffect((function(){r&&!r.isDestroyed()&&u(r.participantCounts())}),[r,u]),t.useDebugValue(o),o},exports.useParticipantIds=$,exports.useParticipantProperty=L,exports.usePermissions=function(e){var n,a,i,r,o,u,l,c,s,d=z(),f=L(null!=e?e:d,"permissions"),p="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(n=f.canSend)?void 0:n.has("audio")),v="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(a=f.canSend)?void 0:a.has("video")),m="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(i=f.canSend)?void 0:i.has("customAudio")),g="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(r=f.canSend)?void 0:r.has("customVideo")),b="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(o=f.canSend)?void 0:o.has("screenAudio")),y="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(u=f.canSend)?void 0:u.has("screenVideo")),k={canAdminParticipants:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(l=f.canAdmin)?void 0:l.has("participants")),canAdminStreaming:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(c=f.canAdmin)?void 0:c.has("streaming")),canAdminTranscription:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(s=f.canAdmin)?void 0:s.has("transcription")),canSendAudio:p,canSendCustomAudio:m,canSendCustomVideo:g,canSendScreenAudio:b,canSendScreenVideo:y,canSendVideo:v,hasPresence:null==f?void 0:f.hasPresence,permissions:f};return t.useDebugValue(k),k},exports.useReceiveSettings=function(e){var a=void 0===e?{}:e,r=a.id,o=void 0===r?"base":r,u=a.onReceiveSettingsUpdated,l=i.useAtom(ze("base"))[0],c=i.useAtom(ze(o))[0],d=m(),f=we(),p=n.useAtomCallback(t.useCallback((function(e,n,t){for(var a=s({},t),i=0,r=Object.entries(a);i<r.length;i++){var u=r[i],l=u[1];n(ze(u[0]),l)}o in a||ze.remove(o)}),[o]));C("receive-settings-updated",t.useCallback((function(e){p(e.receiveSettings),null==u||u(e)}),[u,p])),t.useEffect((function(){d&&!d.isDestroyed()&&d.getReceiveSettings().then(p)}),[d,p]);var v=t.useCallback((function(){if(d&&"joined-meeting"===f){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==d||null==d.updateReceiveSettings||d.updateReceiveSettings.apply(d,n)}}),[d,f]),g={receiveSettings:"base"===o||0===Object.keys(c).length?l:c,updateReceiveSettings:v};return t.useDebugValue(g),g},exports.useRecording=function(e){var n=void 0===e?{}:e,a=n.onRecordingData,r=n.onRecordingError,o=n.onRecordingStarted,u=n.onRecordingStopped,l=m(),c=i.useAtomValue(Ee);C("recording-started",t.useCallback((function(e){null==o||o(e)}),[o])),C("recording-stopped",t.useCallback((function(e){null==u||u(e)}),[u])),C("recording-error",t.useCallback((function(e){null==r||r(e)}),[r])),C("recording-data",t.useCallback((function(e){null==a||a(e)}),[a]));var d=s({},c,{startRecording:t.useCallback((function(){l&&l.startRecording.apply(l,arguments)}),[l]),stopRecording:t.useCallback((function(){l&&l.stopRecording.apply(l,arguments)}),[l]),updateRecording:t.useCallback((function(){l&&l.updateRecording.apply(l,arguments)}),[l])});return t.useDebugValue(d),d},exports.useRoom=Ne,exports.useRoomExp=function(e){var n,a,r,o,u,l,c=(void 0===e?{}:e).onCountdown,s=i.useAtomValue(T),d=Ne(),f=t.useState(null),p=f[0],v=f[1];t.useEffect((function(){var e,n,t,a,i,r,o,u,l,c,f,p,m=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(a=d.config)?void 0:a.eject_after_elapsed)?e:0,g=null!=(i=null!=(r=null==d||null==(o=d.tokenConfig)?void 0:o.exp)?r:null==d||null==(u=d.config)?void 0:u.exp)?i:0,b=null!=(l=null!=(c=null==d||null==(f=d.tokenConfig)?void 0:f.eject_at_token_exp)?c:null==d||null==(p=d.config)?void 0:p.eject_at_room_exp)&&l,y=new Date(0);if(m&&s&&(y=new Date(s.getTime()+1e3*m)),b&&g){var k=new Date(1e3*g);(!y.getTime()||y.getTime()>0&&k<y)&&(y=k)}0!==y.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==y.getTime()?y:e}))}),[s,null==d||null==(n=d.config)?void 0:n.eject_after_elapsed,null==d||null==(a=d.config)?void 0:a.eject_at_room_exp,null==d||null==(r=d.config)?void 0:r.exp,null==d||null==(o=d.tokenConfig)?void 0:o.eject_after_elapsed,null==d||null==(u=d.tokenConfig)?void 0:u.eject_at_token_exp,null==d||null==(l=d.tokenConfig)?void 0:l.exp]),t.useEffect((function(){if(p&&0!==p.getTime()){var e=setInterval((function(){var e,n=(null!=(e=null==p?void 0:p.getTime())?e:0)/1e3-Date.now()/1e3;if(!(n<0)){var t=Math.max(0,Math.floor(n/3600)),a=Math.max(0,Math.floor(n%3600/60)),i=Math.max(0,Math.floor(n%60));null==c||c({hours:t,minutes:a,seconds:i})}}),1e3);return function(){clearInterval(e)}}}),[p,c]);var m={ejectDate:p};return t.useDebugValue(m),m},exports.useScreenAudioTrack=function(e){return Y(e,"screenAudio")},exports.useScreenShare=X,exports.useScreenVideoTrack=function(e){return Y(e,"screenVideo")},exports.useSendSettings=function(e){var n=(void 0===e?{}:e).onSendSettingsUpdated,a=m(),r=i.useAtom(Ge),o=r[0],u=r[1];C("send-settings-updated",t.useCallback((function(e){u(e.sendSettings),null==n||n(e)}),[n,u]));var l=t.useCallback((function(e){u(e)}),[u]);t.useEffect((function(){a&&!a.isDestroyed()&&l(a.getSendSettings())}),[a,l]);var s={sendSettings:o,updateSendSettings:t.useCallback(c((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var i=yield null==a?void 0:a.updateSendSettings.apply(a,n);if(i)return l(i),i})),[a,l])};return t.useDebugValue(s),s},exports.useThrottledDailyEvent=R,exports.useTranscription=function(e){var n=void 0===e?{}:e,a=n.onTranscriptionAppData,r=n.onTranscriptionError,o=n.onTranscriptionMessage,u=n.onTranscriptionStarted,l=n.onTranscriptionStopped,c=m(),d=i.useAtomValue(Ve);C("transcription-started",t.useCallback((function(e){null==u||u(e)}),[u])),C("transcription-stopped",t.useCallback((function(e){null==l||l(e)}),[l])),C("transcription-error",t.useCallback((function(e){null==r||r(e)}),[r])),C("transcription-message",t.useCallback((function(e){null==o||o(e)}),[o])),C("app-message",t.useCallback((function(e){"transcription"===(null==e?void 0:e.fromId)&&(null==a||a(e))}),[a]));var f=s({},d,{startTranscription:t.useCallback((function(){c&&c.startTranscription.apply(c,arguments)}),[c]),stopTranscription:t.useCallback((function(){c&&c.stopTranscription.apply(c,arguments)}),[c])});return t.useDebugValue(f),f},exports.useVideoTrack=function(e){return Y(e,"video")},exports.useWaitingParticipants=function(e){var n=void 0===e?{}:e,a=n.onWaitingParticipantAdded,r=n.onWaitingParticipantRemoved,o=n.onWaitingParticipantUpdated,u=m(),l=i.useAtomValue(U(void 0));C("waiting-participant-added",t.useCallback((function(e){null==a||a(e)}),[a])),C("waiting-participant-removed",t.useCallback((function(e){null==r||r(e)}),[r])),C("waiting-participant-updated",t.useCallback((function(e){null==o||o(e)}),[o]));var c=t.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]),s={waitingParticipants:l,grantAccess:t.useCallback((function(e){c(e,!0)}),[c]),denyAccess:t.useCallback((function(e){c(e,!1)}),[c])};return t.useDebugValue(s),s};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var n=require("jotai/utils"),t=require("react"),a=e(t),r=require("jotai"),i=e(require("lodash.throttle")),o=e(require("@daily-co/daily-js")),u=e(require("fast-deep-equal"));function l(e,n,t,a,r,i,o){try{var u=e[i](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(a,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(a,r){var i=e.apply(n,t);function o(e){l(i,a,r,o,u,"next",e)}function u(e){l(i,a,r,o,u,"throw",e)}o(void 0)}))}}function s(){return(s=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[a]=t[a])}return e}).apply(this,arguments)}function d(e,n){if(null==e)return{};var t,a,r={},i=Object.keys(e);for(a=0;a<i.length;a++)n.indexOf(t=i[a])>=0||(r[t]=e[t]);return r}function f(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,a=new Array(n);t<n;t++)a[t]=e[t];return a}function p(e,n){var t="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(t)return(t=t.call(e)).next.bind(t);if(Array.isArray(e)||(t=function(e,n){if(e){if("string"==typeof e)return f(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?f(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var a=0;return function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var v=t.createContext(null),m=function(){var e=t.useContext(v);return t.useDebugValue(e),e},g=t.createContext({on:function(){},off:function(){}}),b=-1,y=function(){return b--},k=1,h=function(){return k++},C=function(e,n,a){void 0===a&&(a=!1);var r=t.useContext(g),i=r.off,o=r.on,u=t.useState(!1),l=u[0],c=u[1],s=t.useRef(0),d=t.useMemo((function(){return a?y():h()}),[a]);t.useEffect((function(){if(e&&!l){if(s.current>1e5)return console.error("useDailyEvent called with potentially non-memoized event callback or due to too many re-renders.\n Memoize using useCallback to avoid re-render loop or reduce the amount of state transitions the callback depends on.\n Passed callback for '"+e+"' event is NOT registered.",n),void c(!0);s.current++;var t=setTimeout((function(){s.current=0}),50);return o(e,n,d),function(){clearTimeout(t),i(e,d)}}}),[n,e,d,l,i,o]),t.useDebugValue({event:e,eventId:d,isBlocked:l,callback:n})};function A(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++)if(!A(e[t],n[t]))return!1;return!0}if(MediaStream&&e instanceof MediaStream&&n instanceof MediaStream)return e.id===n.id&&e.active===n.active&&e.getTracks().length===n.getTracks().length&&e.getTracks().every((function(e,t){return A(e,n.getTracks()[t])}));if(MediaStreamTrack&&e instanceof MediaStreamTrack&&n instanceof MediaStreamTrack)return e.id===n.id&&e.kind===n.kind&&e.readyState===n.readyState;if(e instanceof Date&&n instanceof Date)return e.getTime()===n.getTime();if(e instanceof RegExp&&n instanceof RegExp)return e.source===n.source&&e.flags===n.flags;if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;var a=Array.from(e).sort(),r=Array.from(n).sort();return a.every((function(e,n){return A(e,r[n])}))}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(var i,o=p(e.entries());!(i=o()).done;){var u=i.value,l=u[0],c=u[1];if(!n.has(l)||!A(c,n.get(l)))return!1}return!0}if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var s=Object.keys(e),d=Object.keys(n);if(s.length!==d.length)return!1;for(var f=0;f<s.length;f++){var v=s[f];if(!Object.prototype.hasOwnProperty.call(n,v)||!A(e[v],n[v]))return!1}return!0}function S(e,n){if(e===n)return!0;if(e.length!==n.length)return!1;for(var t=0;t<e.length;t++){var a=e[t],r=n[t];if(null!==a&&"object"==typeof a||null!==r&&"object"==typeof r){if(!A(a,r))return!1}else if(a!==r)return!1}return!0}function L(e){return"daily-react-"+e}function E(e){var n=new Map,t=new Map;return function(a){if(!n.has(a)){var i=r.atom((function(n){var r=e.get(a)(n),i=t.get(a);return null!=i&&e.equals(r,i)?i:(t.set(a,r),r)}));n.set(a,i)}return n.get(a)}}var w=function(e,n){return e+"::"+n},D=function(e,n){return I(w(e,n))},x=n.atomFamily((function(e){var n=r.atom([]);return n.debugLabel=L("participant-property-paths-"+e),n})),I=n.atomFamily((function(e){var n=r.atom(null);return n.debugLabel=L("participant-property-"+e),n})),V=E({equals:S,get:function(e){return function(n){var t=e.split("::"),a=t[0];return t[1].split(";").map((function(e){return n(D(a,e))}))}}}),R=function(e,n){var a,i=r.useAtomValue(Array.isArray(n)?V(function(e,n){return e+"::"+n.join(";")}(e,n)):I(w(e,n)));return t.useDebugValue(Array.isArray(n)?n.reduce((function(e,n,t){return e[n]=i[t],e}),{}):((a={})[n]=i,a)),i},P=function(e,n,a,r){void 0===a&&(a=500),void 0===r&&(r=!1);var o=t.useContext(g),u=o.off,l=o.on,c=t.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=r?y():h(),e}),{}):((n={})[e]=r?y():h(),n)}),[e,r]),s=t.useRef([]);C("call-instance-destroyed",t.useCallback((function(){s.current.length=0}),[]));var d=t.useMemo((function(){return i((function(){0!==s.current.length&&(n(s.current),s.current.length=0)}),a,{trailing:!0})}),[n,a]);t.useEffect((function(){if(e){var n=function(e){s.current.push(e),d()};return Array.isArray(e)?e.forEach((function(e){return l(e,n,c[e])})):l(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return u(e,c[e])})):u(e,c[e])}}}),[d,e,c,u,l]),t.useDebugValue({event:e,eventId:c})},M=function(e){return function e(n,t,a){if(void 0===t&&(t=""),void 0===a&&(a=new Set),"object"!=typeof n||null===n||a.has(n))return[t];a.add(n);var r=[];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var o=t?t+"."+i:i;r.push.apply(r,[o].concat(e(n[i],o,a)))}return a.delete(n),r}(e)},j=function(e,n){return n.map((function(n){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(e,n)}))},_=r.atom(null);_.debugLabel=L("active-id");var T=r.atom("");T.debugLabel=L("local-id");var O=r.atom(null);O.debugLabel=L("local-join-date");var F=r.atom([]);F.debugLabel=L("participant-ids");var q=n.atomFamily((function(e){var n=r.atom(null);return n.debugLabel=L("participant-"+e),n})),B=r.atom([]);B.debugLabel=L("waiting-participants");var U=n.atomFamily((function(e){var n=r.atom({awaitingAccess:{level:"full"},id:e,name:""});return n.debugLabel=L("waiting-participant-"+e),n})),W=E({equals:S,get:function(){return function(e){return e(B).map((function(n){return e(U(n))}))}}}),z=function(e){var r=e.children,i=m(),o=t.useState(!1),u=o[0],l=o[1],c=n.useAtomCallback(t.useCallback((function(e,n,t){n(T,t.local.session_id);var a=Object.values(t),r=a.map((function(e){return e.session_id}));n(F,r),a.forEach((function(e){n(q(e.session_id),e);var t=M(e);n(x(e.session_id),t),t.forEach((function(t){var a=j(e,[t])[0];n(D(e.session_id,t),a)}))})),l(!0)}),[]));t.useEffect((function(){if(i&&!u){var e=setInterval((function(){var n=i.participants();"local"in n&&(c(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[i,u,c]);var d=t.useCallback((function(){if(i){var e=null==i?void 0:i.participants();e.local&&c(e)}}),[i,c]);C("started-camera",d,!0),C("access-state-updated",d,!0),C("joining-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(O,new Date),d()}),[d])),!0),C("joined-meeting",t.useCallback((function(e){c(e.participants)}),[c]),!0);var f=n.useAtomCallback(t.useCallback((function(e,n){n(T,""),n(_,null),e(F).forEach((function(e){return q.remove(e)})),n(F,[])}),[]));return C("call-instance-destroyed",f,!0),C("left-meeting",f,!0),P(["active-speaker-change","participant-joined","participant-updated","participant-left"],n.useAtomCallback(t.useCallback((function(e,n,t){t.length&&t.forEach((function(t){switch(t.action){case"active-speaker-change":n(_,t.activeSpeaker.peerId),n(q(t.activeSpeaker.peerId),(function(e){return e?s({},e,{last_active:new Date}):null}));break;case"participant-joined":n(F,(function(e){return e.includes(t.participant.session_id)?e:[].concat(e,[t.participant.session_id])})),n(q(t.participant.session_id),t.participant);var a=M(t.participant);n(x(t.participant.session_id),a),a.forEach((function(e){var a=j(t.participant,[e])[0];n(D(t.participant.session_id,e),a)}));break;case"participant-updated":n(q(t.participant.session_id),t.participant),t.participant.local&&n(T,t.participant.session_id);var r=M(t.participant),i=e(x(t.participant.session_id));(r.length!==i.length||r.some((function(e){return!i.includes(e)})))&&n(x(t.participant.session_id),r);var o=new Set(i),u=j(t.participant,r);r.forEach((function(e,a){var r=u[a];o.delete(e),n(D(t.participant.session_id,e),(function(e){return A(e,r)?e:r}))})),o.forEach((function(e){n(D(t.participant.session_id,e),null)}));break;case"participant-left":n(F,(function(e){return e.includes(t.participant.session_id)?e.filter((function(e){return e!==t.participant.session_id})):e})),q.remove(t.participant.session_id),e(x(t.participant.session_id)).forEach((function(e){I.remove(w(t.participant.session_id,e))})),x.remove(t.participant.session_id)}}))}),[])),100,!0),P(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],n.useAtomCallback(t.useCallback((function(e,n,t){t.forEach((function(e){switch(e.action){case"waiting-participant-added":n(B,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),n(U(e.participant.id),e.participant);break;case"waiting-participant-updated":n(U(e.participant.id),e.participant);break;case"waiting-participant-removed":n(B,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),U.remove(e.participant.id)}}))}),[])),100,!0),a.createElement(a.Fragment,null,r)},N=function(){var e=r.useAtomValue(T);return t.useDebugValue(e),e},G=function(){return!0},H=function(e){var n=void 0===e?{}:e,a=n.filter,i=void 0===a?G:a,o=n.ignoreLocal,u=void 0!==o&&o,l=N(),c=r.useAtomValue(_),s=u&&c===l,d=!(null!=i&&i(c)),f=t.useState(s||d?null:c),p=f[0],v=f[1];return t.useEffect((function(){s||d||v(c)}),[d,s,c]),t.useDebugValue(p),p},J=function(e){return["blocked","off"].includes(e)},Q=function(e,n){return e+";"+n},$=E({equals:A,get:function(e){return function(n){var t=e.split(";"),a=t[0],r=t[1];return n(F).filter((function(e){switch(a){case"local":case"owner":case"record":return n(D(e,a));case"remote":return!n(D(e,"local"));case"screen":var t=n(D(e,"tracks.screenAudio.state")),r=n(D(e,"tracks.screenVideo.state"));return!J(t)||!J(r);default:return!0}})).sort((function(e,t){switch(r){case"joined_at":case"session_id":case"user_id":case"user_name":var a=n(D(e,r)),i=n(D(t,r));if(void 0!==a||void 0!==i){if(void 0===a)return-1;if(void 0===i)return 1;if(a>i)return 1;if(a<i)return-1}return 0;default:return 0}}))}}}),K=function(e){var a=void 0===e?{}:e,i=a.filter,o=a.onActiveSpeakerChange,u=a.onParticipantJoined,l=a.onParticipantLeft,c=a.onParticipantUpdated,s=a.sort,d=r.useAtomValue($(Q("string"==typeof i?i:null,"string"==typeof s?s:null))),f="function"==typeof i||"function"==typeof s,p=t.useCallback((function(e){return"function"!=typeof i&&"function"!=typeof s?[]:d.map((function(n){return e(q(n))})).filter((function(e){return Boolean(e)})).filter("function"==typeof i?i:function(){return!0}).sort("function"==typeof s?s:function(){return 0}).map((function(e){return e.session_id})).filter(Boolean)}),[i,d,s]),v=t.useState([]),m=v[0],g=v[1],b=n.useAtomCallback(t.useCallback((function(e){if(f){var n=p(e);A(n,m)||g(n)}}),[m,p,f]));t.useEffect((function(){b()}),[b]),P(["participant-joined","participant-updated","active-speaker-change","participant-left"],t.useCallback((function(e){e.length&&(e.forEach((function(e){switch(e.action){case"participant-joined":null==u||u(e);break;case"participant-updated":null==c||c(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==l||l(e)}})),b())}),[b,o,u,l,c]));var y="function"==typeof i||"function"==typeof s?m:d;return t.useDebugValue(y),y},X=E({equals:S,get:function(){return function(e){return e($(Q("screen",null))).map((function(n){return{local:e(D(n,"local")),screenAudio:e(D(n,"tracks.screenAudio")),screenVideo:e(D(n,"tracks.screenVideo")),screenId:n+"-screen",session_id:n}}))}}}),Y=function(e){var n=void 0===e?{}:e,a=n.onError,i=n.onLocalScreenShareStarted,o=n.onLocalScreenShareStopped,u=m(),l=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==u||u.startScreenShare.apply(u,n)}),[u]),c=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==u||u.stopScreenShare.apply(u,n)}),[u]);C("local-screen-share-started",t.useCallback((function(){return null==i?void 0:i()}),[i])),C("local-screen-share-stopped",t.useCallback((function(){return null==o?void 0:o()}),[o])),C("nonfatal-error",t.useCallback((function(e){"screen-share-error"===e.type&&(null==a||a(e))}),[a]));var s=r.useAtomValue(X(void 0)),d={isSharingScreen:s.some((function(e){return e.local})),screens:s,startScreenShare:l,stopScreenShare:c};return t.useDebugValue(d),d},Z=function(e,n){void 0===n&&(n="video");var a=R(e,"tracks."+n),r=a?s({},a,{isOff:J(a.state)}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1};return t.useDebugValue(r),r};function ee(){for(var e=arguments.length,n=new Array(e),a=0;a<e;a++)n[a]=arguments[a];return t.useCallback((function(e){for(var t=0;t<n.length;t++){var a=n[t];"function"==typeof a?a(e):a&&"object"==typeof a&&(a.current=e)}}),n)}var ne=["onPlayFailed","sessionId","type"],te=t.memo(t.forwardRef((function(e,n){var r=e.onPlayFailed,i=e.sessionId,o=e.type,u=void 0===o?"audio":o,l=d(e,ne),c=t.useRef(null),s=Z(i,u),f=ee(c,n),p=null==s?void 0:s.subscribed;return t.useEffect((function(){var e=c.current;if(e&&null!=s&&s.persistentTrack){var n=function(){e.play().catch((function(n){null==r||r({sessionId:i,target:e,type:u,message:n.message,name:n.name})}))},t=function(){clearTimeout(void 0)};return MediaStream?(e.addEventListener("canplay",n),e.addEventListener("play",t),e.srcObject=new MediaStream([null==s?void 0:s.persistentTrack]),function(){null==e||e.removeEventListener("canplay",n),null==e||e.removeEventListener("play",t)}):(console.warn("MediaStream API not available. Can't setup "+u+" for "+i),void(null==r||r({sessionId:i,target:e,type:u,message:"MediaStream API not available",name:"MediaStream API not available"})))}}),[null==s?void 0:s.persistentTrack,r,i,u]),a.createElement("audio",Object.assign({autoPlay:!0,ref:f},l,{"data-session-id":i,"data-audio-type":u,"data-subscribed":p}))})));te.displayName="DailyAudioTrack";var ae=t.memo(t.forwardRef((function(e,r){var i=e.autoSubscribeActiveSpeaker,o=void 0!==i&&i,u=e.maxSpeakers,l=void 0===u?5:u,s=e.onPlayFailed,d=e.playLocalScreenAudio,f=void 0!==d&&d,p=m(),v=t.useState(new Array(l).fill("")),g=v[0],b=v[1],y=Y().screens,k=N(),h=H({ignoreLocal:!0}),C=t.useRef(null);t.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=C.current)?void 0:n.querySelector('audio[data-session-id="'+h+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getRmpAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll('audio[data-audio-type="rmpAudio"]'))?e:[])},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=C.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getRmpAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="rmpAudio"]'))?n:null},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=C.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[h]);var A=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n,t){var a,r=Object.values(null!=(a=null==p?void 0:p.participants())?a:{}).filter((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)})),i=function(e){return r.some((function(n){return n.session_id===e}))};if(!i(t)){if(!p||p.isDestroyed()||!o||p.subscribeToTracksAutomatically())return;p.updateParticipant(t,{setSubscribedTracks:{audio:!0}})}b((function(n){var a;if(n.includes(t))return n;var o=function(e){return!e||!i(e)};if(n.some(o)){var u=n.findIndex(o);return n[u]=t,[].concat(n)}var l=n.findIndex((function(e){return r.some((function(n){return n.session_id===e&&J(n.tracks.audio.state)}))}));if(l>=0)return n[l]=t,[].concat(n);var c=r.filter((function(e){return n.includes(e.session_id)&&e.session_id!==h})).sort((function(n,t){var a,r,i=null!=(a=e(D(n.session_id,"last_active")))?a:new Date("1970-01-01"),o=null!=(r=e(D(t.session_id,"last_active")))?r:new Date("1970-01-01");return i>o?1:i<o?-1:0}));if(!c.length){var s=n.findIndex((function(e){return e!==h}));return n[s]=t,[].concat(n)}var d=n.indexOf(null==(a=c[0])?void 0:a.session_id);return n[d]=t,[].concat(n)}))}));return function(n,t,a){return e.apply(this,arguments)}}(),[h,o,p])),S=t.useCallback((function(e){b((function(n){if(!n.includes(e))return n;var t=[].concat(n),a=t.indexOf(e);return t[a]="",t}))}),[]);P(["active-speaker-change","track-started","participant-left"],t.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===k)return;A(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&A(e.participant.session_id);break;case"participant-left":S(e.participant.session_id)}}))}),[A,k,S]),200);var L=K({filter:t.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return a.createElement("div",{ref:C},g.map((function(e,n){return a.createElement(te,{key:"speaker-slot-"+n,onPlayFailed:s,sessionId:e,type:"audio"})})),y.filter((function(e){return!!f||!e.local})).map((function(e){return a.createElement(te,{key:e.screenId,onPlayFailed:s,sessionId:e.session_id,type:"screenAudio"})})),L.map((function(e){return a.createElement(te,{key:e+"-rmp",onPlayFailed:s,sessionId:e,type:"rmpAudio"})})))})));ae.displayName="DailyAudio";var re=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],ie=t.forwardRef((function(e,n){var r=e.automirror,i=e.fit,o=void 0===i?"contain":i,u=e.mirror,l=e.onResize,c=e.playableStyle,f=void 0===c?{}:c,p=e.sessionId,v=e.style,m=void 0===v?{}:v,g=e.type,b=void 0===g?"video":g,y=d(e,re),k=N()===p,h="screenVideo"===b,C=k&&!h,A=t.useRef(null),S=ee(A,n),L=Z(p,b),E=L.persistentTrack,w=C||h||!L.isOff,D=R(p,"tracks."+b),x=null==D?void 0:D.subscribed,I=t.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!E)return C;var e=E.getSettings();return"facingMode"in e?C&&"user"===e.facingMode:C}),[r,C,u,E]);return t.useEffect((function(){var e=A.current;if(e){var n=function(){var n=e.play();void 0!==n&&n.then((function(){e.controls=!1})).catch((function(n){e.controls=!0,console.warn("Failed to play video",n)}))},t=function(){e.paused&&n()},a=function(){e.style.transform="scale(1)"},r=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},i=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",a),e.addEventListener("leavepictureinpicture",r),document.addEventListener("visibilitychange",i),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",a),e.removeEventListener("leavepictureinpicture",r),document.removeEventListener("visibilitychange",i)}}}),[]),t.useEffect((function(){var e=A.current;if(e&&E){if(MediaStream)return e.srcObject=new MediaStream([E]),e.load(),function(){e.srcObject=null,e.load()};console.warn("MediaStream API not available. Can't setup "+b+" for "+p)}}),[p,b,E,null==E?void 0:E.id]),t.useEffect((function(){var e,n=A.current;if(l&&n)return t(),n.addEventListener("loadedmetadata",t),n.addEventListener("resize",t),function(){e&&cancelAnimationFrame(e),n.removeEventListener("loadedmetadata",t),n.removeEventListener("resize",t)};function t(){e&&cancelAnimationFrame(e),e=requestAnimationFrame((function(){var e=A.current;if(e&&!document.hidden){var n=e.videoWidth,t=e.videoHeight;n&&t&&(null==l||l({aspectRatio:n/t,height:t,width:n}))}}))}}),[l]),a.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:S,"data-local":k,"data-mirrored":I||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":x,"data-video-type":b,style:s({objectFit:o,transform:I?"scale(-1, 1)":""},m,w?f:{})},y))}));ie.displayName="DailyVideo";var oe=t.createContext({refreshDevices:function(){return Promise.resolve()}}),ue=r.atom("idle");ue.debugLabel=L("camera-state");var le=r.atom("idle");le.debugLabel=L("microphone-state");var ce=r.atom([]);ce.debugLabel=L("camera-devices");var se=r.atom([]);se.debugLabel=L("microphone-devices");var de=r.atom([]);de.debugLabel=L("speaker-devices");var fe=r.atom(null);fe.debugLabel=L("last-camera-error");var pe=function(e){var r=e.children,i=m(),o=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){var t,a,r,o;if(void 0===(null==(t=navigator)||null==(a=t.mediaDevices)?void 0:a.getUserMedia)||void 0===(null==(r=navigator)||null==(o=r.mediaDevices)?void 0:o.enumerateDevices))return n(ue,"not-supported"),void n(le,"not-supported");if(i)try{var u=(yield i.enumerateDevices()).devices,l=u.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),d=yield i.getInputDevices(),f=d.camera,p=d.mic,v=d.speaker,m=function(e,n,t){var a,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(a=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?a:"granted"}},g=function(e,n){return"default"===e.device.deviceId?-1:"default"===n.device.deviceId?1:e.device.label<n.device.label?-1:e.device.label>n.device.label?1:0};n(ce,(function(e){return l.filter(Boolean).map((function(n){return m(f,n,e)})).sort(g)})),n(se,(function(e){return c.filter(Boolean).map((function(n){return m(p,n,e)})).sort(g)})),n(de,(function(e){return s.filter(Boolean).map((function(n){return m(v,n,e)})).sort(g)}))}catch(e){n(ue,"not-supported"),n(le,"not-supported")}}));return function(n,t){return e.apply(this,arguments)}}(),[i])),u=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){var t,a,r,u,l,c,d,f,p,v,m,g,b,y;if(i){var k=e(ue),h=e(le),C=i.participants();if(C.local){var A=C.local.tracks,S="prompt",L="prompt";if(navigator.permissions)try{S=(yield navigator.permissions.query({name:"camera"})).state,L=(yield navigator.permissions.query({name:"microphone"})).state}catch(e){}var E="prompt"===S&&["idle","pending"].includes(k)&&"interrupted"===A.video.state&&!A.video.persistentTrack,w=["idle","pending"].includes(k)&&!A.video.persistentTrack&&Boolean(null==(t=A.video.off)?void 0:t.byUser),D="prompt"===L&&["idle","pending"].includes(h)&&"interrupted"===A.audio.state&&!A.audio.persistentTrack,x=["idle","pending"].includes(h)&&!A.audio.persistentTrack&&Boolean(null==(a=A.audio.off)?void 0:a.byUser);null!=(r=A.audio)&&null!=(u=r.blocked)&&u.byDeviceInUse?(n(le,"in-use"),n(se,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"in-use"}):e}))}))):null!=(l=A.audio)&&null!=(c=l.blocked)&&c.byDeviceMissing?n(le,"not-found"):null!=(d=A.audio)&&null!=(f=d.blocked)&&f.byPermissions||"denied"===L?n(le,"blocked"):D?n(le,"pending"):x?n(le,"idle"):(n(le,"granted"),n(se,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"granted"}):e}))}))),null!=(p=A.video)&&null!=(v=p.blocked)&&v.byDeviceInUse?(n(ue,"in-use"),n(ce,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"in-use"}):e}))}))):null!=(m=A.video)&&null!=(g=m.blocked)&&g.byDeviceMissing?n(ue,"not-found"):null!=(b=A.video)&&null!=(y=b.blocked)&&y.byPermissions||"denied"===S?n(ue,"blocked"):E?n(ue,"pending"):w?n(ue,"idle"):(n(ue,"granted"),n(ce,(function(e){return e.map((function(e){return e.selected?s({},e,{state:"granted"}):e}))}))),o()}}}));return function(n,t){return e.apply(this,arguments)}}(),[i,o]));return C("participant-updated",t.useCallback((function(e){e.participant.local&&u()}),[u])),C("available-devices-updated",o),C("selected-devices-updated",o),C("camera-error",n.useAtomCallback(t.useCallback((function(e,n,t){var a,r,i,o,u,l,c;switch(n(fe,t.error),null==(a=t.error)?void 0:a.type){case"cam-in-use":n(ue,"in-use");break;case"mic-in-use":n(le,"in-use");break;case"cam-mic-in-use":n(ue,"in-use"),n(le,"in-use");break;case"not-found":null!=(r=t.error)&&r.missingMedia.includes("video")&&n(ue,"not-found"),null!=(i=t.error)&&i.missingMedia.includes("audio")&&n(le,"not-found");break;case"permissions":null!=(o=t.error)&&o.blockedMedia.includes("video")&&n(ue,"blocked"),null!=(u=t.error)&&u.blockedMedia.includes("audio")&&n(le,"blocked");break;case"constraints":"invalid"===(null==(l=t.error)?void 0:l.reason)?(n(ue,"constraints-invalid"),n(le,"constraints-invalid")):"none-specified"===(null==(c=t.error)?void 0:c.reason)&&(n(ue,"constraints-none-specified"),n(le,"constraints-none-specified"));break;case"undefined-mediadevices":n(ue,"undefined-mediadevices"),n(le,"undefined-mediadevices");break;case"unknown":default:n(ue,"unknown"),n(le,"unknown")}}),[]))),C("started-camera",n.useAtomCallback(t.useCallback((function(e,n){n(ue,"granted"),n(le,"granted"),u()}),[u]))),a.createElement(oe.Provider,{value:{refreshDevices:o}},r)},ve=r.atom({errorMsg:void 0,isLiveStreaming:!1,layout:void 0});ve.debugLabel=L("live-streaming");var me=function(e){var r=e.children;return C("live-streaming-started",n.useAtomCallback(t.useCallback((function(e,n,t){n(ve,{isLiveStreaming:!0,layout:null==t?void 0:t.layout})}),[]))),C("live-streaming-stopped",n.useAtomCallback(t.useCallback((function(e,n){n(ve,(function(e){return s({},e,{isLiveStreaming:!1,layout:void 0})}))}),[]))),C("live-streaming-error",n.useAtomCallback(t.useCallback((function(e,n,t){n(ve,(function(e){return s({},e,{errorMsg:t.errorMsg})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(ve,{errorMsg:void 0,isLiveStreaming:!1,layout:void 0})}),[]))),a.createElement(a.Fragment,null,r)},ge=r.atom("new");ge.debugLabel=L("meeting-state");var be=r.atom(null);be.debugLabel=L("meeting-error");var ye=r.atom(null);ye.debugLabel=L("non-fatal-error");var ke=r.atom({data:void 0,topology:"none"});ke.debugLabel=L("meeting-session-data");var he=function(e){var r=e.children,i=m(),o=n.useAtomCallback(t.useCallback((function(e,n){if(i){var t=i.meetingState();return n(ge,t),t}}),[i]));C("loading",o),C("loaded",o),C("joining-meeting",o),C("joined-meeting",o),C("left-meeting",o),C("error",n.useAtomCallback(t.useCallback((function(e,n,t){n(be,t),o()}),[o]))),C("nonfatal-error",n.useAtomCallback(t.useCallback((function(e,n,t){n(ye,t)}),[])));var u=n.useAtomCallback(t.useCallback((function(e,n){i&&n(ke,i.meetingSessionState())}),[i]));return C("joined-meeting",u),C("meeting-session-state-updated",n.useAtomCallback(t.useCallback((function(e,n,t){n(ke,t.meetingSessionState)}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(ke,{data:void 0,topology:"none"})}),[]))),C("call-instance-destroyed",n.useAtomCallback(t.useCallback((function(e,n){n(ge,"new"),n(be,null),n(ye,null),n(ke,{data:void 0,topology:"none"})}),[]))),a.createElement(a.Fragment,null,r)},Ce=r.atom("none");Ce.debugLabel=L("topology");var Ae=r.atom(100);Ae.debugLabel=L("network-quality");var Se=r.atom("good");Se.debugLabel=L("network-threshold");var Le=function(e){var i=e.children,o=m(),u=r.useAtomValue(Ce),l=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){if(o){var t=yield o.getNetworkTopology();t&&"none"!==(null==t?void 0:t.topology)&&n(Ce,t.topology)}}));return function(n,t){return e.apply(this,arguments)}}(),[o]));return C("joined-meeting",l),C("network-connection",n.useAtomCallback(t.useCallback((function(e,n,t){switch(t.event){case"connected":"peer-to-peer"===t.type&&n(Ce,"peer"),"sfu"===t.type&&n(Ce,"sfu")}}),[]))),C("network-quality-change",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ae,(function(e){return e!==t.quality?t.quality:e})),n(Se,(function(e){return e!==t.threshold?t.threshold:e}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(Ce,"none"),n(Ae,100),n(Se,"good")}),[]))),t.useEffect((function(){o&&"none"===u&&l()}),[o,l,u]),a.createElement(a.Fragment,null,i)},Ee=r.atom({isLocalParticipantRecorded:!1,isRecording:!1});Ee.debugLabel=L("recording-state");var we=function(e){var r=e.children,i=N(),o=K({filter:"record"}),u=n.useAtomCallback(t.useCallback((function(e,n,t,a){var r=e(Ee),i={isLocalParticipantRecorded:r.isLocalParticipantRecorded,isRecording:r.isRecording,local:r.local,type:r.type},o={isLocalParticipantRecorded:"local"!==(null==i?void 0:i.type)&&null!=i&&i.type?i.isLocalParticipantRecorded:t,isRecording:"local"!==(null==i?void 0:i.type)&&null!=i&&i.type?i.isRecording:t,local:"local"!==(null==i?void 0:i.type)&&null!=i&&i.type||!t?null==i?void 0:i.local:a,type:t?"local":null==r?void 0:r.type};A(i,o)||n(Ee,s({},i,o))}),[]));return t.useEffect((function(){var e=o.length>0,n=o.includes(i||"local");u(e,n)}),[i,u,o]),C("recording-started",n.useAtomCallback(t.useCallback((function(e,n,t){var a=!0;switch(t.type){case"cloud-beta":case"cloud":var r;i&&"single-participant"===(null==(r=t.layout)?void 0:r.preset)&&t.layout.session_id!==i&&(a=!1)}n(Ee,{error:!1,isLocalParticipantRecorded:a,isRecording:!0,layout:null==t?void 0:t.layout,local:null==t?void 0:t.local,recordingId:null==t?void 0:t.recordingId,recordingStartedDate:new Date,startedBy:null==t?void 0:t.startedBy,type:null==t?void 0:t.type})}),[i]))),C("recording-stopped",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,(function(e){return s({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}),[]))),C("recording-error",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,(function(e){return s({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(Ee,{isLocalParticipantRecorded:!1,isRecording:!1})}),[]))),a.createElement(a.Fragment,null,r)},De=function(){var e=r.useAtomValue(ge);return t.useDebugValue(e),e},xe=r.atom(null);xe.debugLabel=L("room-state");var Ie=function(e){var r=e.children,i=m(),o=De(),u=n.useAtomCallback(t.useCallback(function(){var e=c((function*(e,n){if(i&&"left-meeting"!==o){var t=yield i.room();return t&&"id"in t&&n(xe,t),t}}));return function(n,t){return e.apply(this,arguments)}}(),[i,o]));return C("access-state-updated",u),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){return function(){n(xe,null)}}),[]))),a.createElement(a.Fragment,null,r)},Ve=r.atom({isTranscribing:!1,model:"general",language:"en",transcriptions:[]});Ve.debugLabel=L("transcription-state");var Re=function(e){var r=e.children;return C("transcription-started",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ve,{error:!1,transcriptionStartDate:new Date,isTranscribing:!0,transcriptions:[],endpointing:t.endpointing,extra:t.extra,includeRawResponse:t.includeRawResponse,instanceId:t.instanceId,language:t.language,model:t.model,profanity_filter:t.profanity_filter,punctuate:t.punctuate,redact:t.redact,startedBy:t.startedBy,tier:t.tier})}),[]))),C("transcription-stopped",n.useAtomCallback(t.useCallback((function(e,n,t){n(Ve,(function(e){return s({},e,{updatedBy:t.updatedBy,isTranscribing:!1})}))}),[]))),C("transcription-error",n.useAtomCallback(t.useCallback((function(e,n){n(Ve,(function(e){return s({},e,{error:!0,isTranscribing:!1})}))}),[]))),C("left-meeting",n.useAtomCallback(t.useCallback((function(e,n){n(Ve,(function(e){return s({},e,{isTranscribing:!1})}))}),[]))),C("app-message",n.useAtomCallback(t.useCallback((function(e,n,t){"transcription"===(null==t?void 0:t.fromId)&&n(Ve,(function(e){return s({},e,{isTranscribing:!0,transcriptions:[].concat(e.transcriptions,[t.data])})}))}),[]))),a.createElement(a.Fragment,null,r)},Pe={},Me=function(){return!0},je={options:Pe,shouldCreateInstance:Me},_e=function(e,n){var a=void 0===n?je:n,r=a.parentElRef,i=a.options,u=void 0===i?Pe:i,l=a.shouldCreateInstance,d=void 0===l?Me:l,f=t.useState(null),p=f[0],v=f[1],m=t.useRef();return t.useEffect((function(){if(("callFrame"!==e||null!==(null==r?void 0:r.current))&&d()){var n=function(){setTimeout((function(){return v(null)}),0)},t=o.getCallInstance();if(!p&&t&&!t.isDestroyed())return t.once("call-instance-destroyed",n),void v(t);if(p)A(m.current,u)||function(e){a.apply(this,arguments)}(p);else{if(!t||t.isDestroyed()){switch(e){case"callFrame":t=null!=r&&r.current?o.createFrame(r.current,s({},u)):o.createFrame(s({},u));break;case"callObject":t=o.createCallObject(s({},u))}m.current=u}v(t),t.once("call-instance-destroyed",n)}}function a(){return(a=c((function*(e){yield e.destroy()}))).apply(this,arguments)}}),[p,u,r,d,e]),p},Te=function(e){return _e("callObject",e)},Oe=["children","jotaiStore"],Fe=function(e,n){var a=void 0===n?{}:n,i=a.onParticipantLeft,o=a.onParticipantUpdated,u=r.useAtomValue(q(e));return P(["participant-updated","participant-left"],t.useCallback((function(n){var t=n.filter((function(n){return n.participant.session_id===e}));t.length&&t.forEach((function(e){switch(e.action){case"participant-updated":null==o||o(e);break;case"participant-left":null==i||i(e)}}))}),[i,o,e])),t.useDebugValue(u),u},qe="data:application/javascript;charset=utf8,"+encodeURIComponent("\n class AudioLevelProcessor extends AudioWorkletProcessor {\n volume;\n interval;\n nextFrame;\n \n constructor() {\n super();\n this.volume = 0;\n this.interval = 25;\n this.nextFrame = this.interval;\n }\n \n get intervalInFrames() {\n // sampleRate is globally defined in AudioWorklets.\n // See https://developer.mozilla.org/en-US/docs/Web/API/AudioWorkletGlobalScope\n // eslint-disable-next-line no-undef\n return (this.interval / 1000) * sampleRate;\n }\n \n process(inputList) {\n const firstInput = inputList[0];\n \n if (firstInput.length > 0) {\n const inputData = firstInput[0];\n let total = 0;\n \n for (let i = 0; i < inputData.length; ++i) {\n total += Math.abs(inputData[i]);\n }\n \n const rms = Math.sqrt(total / inputData.length);\n this.volume = Math.max(0, Math.min(1, rms));\n \n this.nextFrame -= inputData.length;\n if (this.nextFrame < 0) {\n this.nextFrame += this.intervalInFrames;\n this.port.postMessage({ volume: this.volume });\n }\n }\n \n return true;\n }\n }\n \n registerProcessor('audiolevel', AudioLevelProcessor); \n"),Be=r.atom({state:"low",reason:"none"});Be.debugLabel=L("cpu-load");var Ue=function(){var e={meetingError:r.useAtomValue(be),nonFatalError:r.useAtomValue(ye)};return t.useDebugValue(e),e},We=r.atom(null);We.debugLabel=L("input-settings");var ze=r.atom({hidden:0,present:0});ze.debugLabel=L("participant-counts");var Ne=n.atomFamily((function(e){var n=r.atom({},(function(n,t,a){t(Ne(e),a)}));return n.debugLabel=L("participant-receive-settings-"+e),n})),Ge=function(){var e=r.useAtomValue(xe);return t.useDebugValue(e),e},He=r.atom(null);He.debugLabel=L("send-settings"),exports.DailyAudio=ae,exports.DailyAudioTrack=te,exports.DailyProvider=function(e){var n=e.children,i=e.jotaiStore,o=d(e,Oe),u=t.useRef({}),l=t.useCallback((function(e){var n,t;if("action"in e)for(var a,r=Array.from(null!=(n=null==(t=u.current)?void 0:t[e.action])?n:[]),i=r.filter((function(e){return e[0]<0})),o=r.filter((function(e){return e[0]>0})),l=p([].concat(i,o));!(a=l()).done;)(0,a.value[1])(e)}),[]),c=t.useCallback((function(e){e&&Object.keys(u.current).forEach((function(n){e.off(n,l),e.isDestroyed()||e.on(n,l)}))}),[l]),s="callObject"in o?o.callObject:null,f=t.useMemo((function(){return"callObject"in o?{}:o}),[o]),m=Te({options:f,shouldCreateInstance:t.useCallback((function(){return!("callObject"in o)}),[o])}),b=null!=s?s:m;t.useEffect((function(){b&&c(b)}),[b,c]);var y=t.useCallback((function(e,n,t){var a,r;u.current[e]||(u.current[e]=new Map,b&&(b.off(e,l),b.isDestroyed()||b.on(e,l))),null!=(a=u.current[e])&&a.has(t)||null==(r=u.current[e])||r.set(t,n)}),[b,l]),k=t.useCallback((function(e,n){var t,a;null==(t=u.current[e])||t.delete(n),0===(null==(a=u.current[e])?void 0:a.size)&&(null==b||b.off(e,l),delete u.current[e])}),[b,l]);return a.createElement(r.Provider,{store:i},a.createElement(v.Provider,{value:b},a.createElement(g.Provider,{value:{on:y,off:k}},a.createElement(Ie,null,a.createElement(he,null,a.createElement(Le,null,a.createElement(z,null,a.createElement(we,null,a.createElement(me,null,a.createElement(Re,null,a.createElement(pe,null,n)))))))))))},exports.DailyVideo=ie,exports.useActiveParticipant=function(e){var n=void 0===e?{}:e,a=n.ignoreLocal,i=void 0!==a&&a,o=n.onActiveSpeakerChange,u=m(),l=r.useAtomValue(_),c=t.useState(""),s=c[1],d=Fe(c[0]);return t.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;i&&l===(null==n?void 0:n.session_id)||s(null!=l?l:"")}}),[u,i,l]),C("active-speaker-change",t.useCallback((function(e){null==o||o(e)}),[o])),t.useDebugValue(d),d},exports.useActiveSpeakerId=H,exports.useAppMessage=function(e){var n=(void 0===e?{}:e).onAppMessage,a=m(),r=t.useCallback((function(e,n){void 0===n&&(n="*"),a&&a.sendAppMessage(e,n)}),[a]),i=t.useCallback((function(e){null==n||n(e,r)}),[n,r]);return C("app-message",i),r},exports.useAudioLevel=function(e,n){var a=t.useRef();t.useEffect((function(){if(e){var t="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(t){a.current||(a.current=new t);var r=a.current;if(r&&MediaStream){var i,o,u=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=c((function*(){try{i=new AudioWorkletNode(r,"audiolevel"),o=r.createGain()}catch(e){try{yield r.audioWorklet.addModule(qe),i=new AudioWorkletNode(r,"audiolevel"),o=r.createGain()}catch(e){console.error(e)}}if(i&&o){i.port.onmessage=function(e){var t=0;e.data.volume&&(t=e.data.volume),i&&n(t)},o.gain.value=0;try{u.connect(i).connect(o).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=i)||e.disconnect(),i=null,null==u||u.disconnect()}}}}}),[n,e])},exports.useAudioLevelObserver=function(e,n,a){var r=m(),i=N(),o=e===i;C("local-audio-level",t.useCallback((function(e){o&&n(e.audioLevel)}),[n,o])),C("remote-participants-audio-level",t.useCallback((function(t){o||n(t.participantsAudioLevel[e])}),[n,e,o])),t.useEffect((function(){if(r&&!r.isDestroyed()&&o&&!r.isLocalAudioLevelObserverRunning())try{r.startLocalAudioLevelObserver()}catch(e){null==a||a("Local audio level observer not supported in this browser")}}),[r,a,o]),t.useEffect((function(){!r||r.isDestroyed()||o||r.isRemoteParticipantsAudioLevelObserverRunning()||r.startRemoteParticipantsAudioLevelObserver()}),[r,o])},exports.useAudioTrack=function(e){return Z(e,"audio")},exports.useCPULoad=function(e){var a=(void 0===e?{}:e).onCPULoadChange,i=r.useAtomValue(Be),o=m(),l=De(),c=n.useAtomCallback(t.useCallback((function(e,n,t){var a=e(Be);u(a,t)||n(Be,t)}),[]));return t.useEffect((function(){var e=!0;if(o&&!o.isDestroyed()&&"joined-meeting"===l)return o.getCpuLoadStats().then((function(n){e&&c({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[o,l,c]),C("cpu-load-change",t.useCallback((function(e){c({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==a||a(e)}),[a,c])),t.useDebugValue(i),i},exports.useCallFrame=function(e){return _e("callFrame",e)},exports.useCallObject=Te,exports.useDaily=m,exports.useDailyError=Ue,exports.useDailyEvent=C,exports.useDevices=function(){var e=m(),n=r.useAtomValue(ue),a=r.useAtomValue(le),i=r.useAtomValue(ce),o=r.useAtomValue(se),u=r.useAtomValue(de),l=r.useAtomValue(fe),s=t.useContext(oe).refreshDevices,d=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=t.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"],g={cameraError:l,cameras:i,camState:n,currentCam:i.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:v.includes(n),hasMicError:v.includes(a),microphones:o,micState:a,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u};return t.useDebugValue(g),g},exports.useInputSettings=function(e){var a=void 0===e?{}:e,i=a.onError,o=a.onInputSettingsUpdated,u=r.useAtomValue(We),l=Ue().nonFatalError,c=m(),s=n.useAtomCallback(t.useCallback((function(e,n,t){n(We,t)}),[]));t.useEffect((function(){c&&c.getInputSettings().then(s)}),[c,s]),C("input-settings-updated",t.useCallback((function(e){s(e.inputSettings),null==o||o(e)}),[o,s])),C("nonfatal-error",t.useCallback((function(e){"input-settings-error"===e.type&&(null==i||i(e))}),[i]));var d=t.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return null==c?void 0:c.updateInputSettings.apply(c,n)}),[c]),f={errorMsg:"input-settings-error"===(null==l?void 0:l.type)?l.errorMsg:null,inputSettings:u,updateInputSettings:d};return t.useDebugValue(f),f},exports.useLiveStreaming=function(e){var n=void 0===e?{}:e,a=n.onLiveStreamingError,i=n.onLiveStreamingStarted,o=n.onLiveStreamingStopped,u=n.onLiveStreamingUpdated,l=n.onLiveStreamingWarning,c=m(),d=r.useAtomValue(ve);C("live-streaming-started",t.useCallback((function(e){null==i||i(e)}),[i])),C("live-streaming-stopped",t.useCallback((function(e){null==o||o(e)}),[o])),C("live-streaming-updated",t.useCallback((function(e){null==u||u(e)}),[u])),C("live-streaming-error",t.useCallback((function(e){null==a||a(e)}),[a])),C("nonfatal-error",t.useCallback((function(e){"live-streaming-warning"===e.type&&(null==l||l(e))}),[l]));var f=s({},d,{startLiveStreaming:t.useCallback((function(){c&&c.startLiveStreaming.apply(c,arguments)}),[c]),stopLiveStreaming:t.useCallback((function(){c&&c.stopLiveStreaming.apply(c,arguments)}),[c]),updateLiveStreaming:t.useCallback((function(){c&&c.updateLiveStreaming.apply(c,arguments)}),[c])});return t.useDebugValue(f),f},exports.useLocalParticipant=function(){var e=r.useAtomValue(T),n=Fe(e);return t.useDebugValue(n),n},exports.useLocalSessionId=N,exports.useMediaTrack=Z,exports.useMeetingSessionState=function(e){var n=(void 0===e?{}:e).onError,a=r.useAtomValue(ke);C("nonfatal-error",t.useCallback((function(e){"meeting-session-data-error"===e.type&&(null==n||n(e))}),[n]));var i={data:null==a?void 0:a.data,topology:null==a?void 0:a.topology};return t.useDebugValue(i),i},exports.useMeetingState=De,exports.useNetwork=function(e){var n=void 0===e?{}:e,a=n.onNetworkConnection,i=n.onNetworkQualityChange,o=m(),u=r.useAtomValue(Ce),l=r.useAtomValue(Ae),s=r.useAtomValue(Se);C("network-connection",t.useCallback((function(e){null==a||a(e)}),[a])),C("network-quality-change",t.useCallback((function(e){null==i||i(e)}),[i]));var d={getStats:t.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u};return t.useDebugValue(d),d},exports.useParticipant=Fe,exports.useParticipantCounts=function(e){var a=(void 0===e?{}:e).onParticipantCountsUpdated,i=m(),o=r.useAtomValue(ze),u=n.useAtomCallback(t.useCallback((function(e,n,t){n(ze,t)}),[]));return C("participant-counts-updated",t.useCallback((function(e){u(e.participantCounts),null==a||a(e)}),[a,u])),t.useEffect((function(){i&&!i.isDestroyed()&&u(i.participantCounts())}),[i,u]),t.useDebugValue(o),o},exports.useParticipantIds=K,exports.useParticipantProperty=R,exports.usePermissions=function(e){var n,a,r,i,o,u,l,c,s,d=N(),f=R(null!=e?e:d,"permissions"),p="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(n=f.canSend)?void 0:n.has("audio")),v="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(a=f.canSend)?void 0:a.has("video")),m="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(r=f.canSend)?void 0:r.has("customAudio")),g="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(i=f.canSend)?void 0:i.has("customVideo")),b="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(o=f.canSend)?void 0:o.has("screenAudio")),y="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(u=f.canSend)?void 0:u.has("screenVideo")),k={canAdminParticipants:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(l=f.canAdmin)?void 0:l.has("participants")),canAdminStreaming:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(c=f.canAdmin)?void 0:c.has("streaming")),canAdminTranscription:"boolean"==typeof(null==f?void 0:f.canAdmin)?null==f?void 0:f.canAdmin:Boolean(null==f||null==(s=f.canAdmin)?void 0:s.has("transcription")),canSendAudio:p,canSendCustomAudio:m,canSendCustomVideo:g,canSendScreenAudio:b,canSendScreenVideo:y,canSendVideo:v,hasPresence:null==f?void 0:f.hasPresence,permissions:f};return t.useDebugValue(k),k},exports.useReceiveSettings=function(e){var a=void 0===e?{}:e,i=a.id,o=void 0===i?"base":i,u=a.onReceiveSettingsUpdated,l=r.useAtom(Ne("base"))[0],c=r.useAtom(Ne(o))[0],d=m(),f=De(),p=n.useAtomCallback(t.useCallback((function(e,n,t){for(var a=s({},t),r=0,i=Object.entries(a);r<i.length;r++){var u=i[r],l=u[1];n(Ne(u[0]),l)}o in a||Ne.remove(o)}),[o]));C("receive-settings-updated",t.useCallback((function(e){p(e.receiveSettings),null==u||u(e)}),[u,p])),t.useEffect((function(){d&&!d.isDestroyed()&&d.getReceiveSettings().then(p)}),[d,p]);var v=t.useCallback((function(){if(d&&"joined-meeting"===f){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==d||null==d.updateReceiveSettings||d.updateReceiveSettings.apply(d,n)}}),[d,f]),g={receiveSettings:"base"===o||0===Object.keys(c).length?l:c,updateReceiveSettings:v};return t.useDebugValue(g),g},exports.useRecording=function(e){var n=void 0===e?{}:e,a=n.onRecordingData,i=n.onRecordingError,o=n.onRecordingStarted,u=n.onRecordingStopped,l=m(),c=r.useAtomValue(Ee);C("recording-started",t.useCallback((function(e){null==o||o(e)}),[o])),C("recording-stopped",t.useCallback((function(e){null==u||u(e)}),[u])),C("recording-error",t.useCallback((function(e){null==i||i(e)}),[i])),C("recording-data",t.useCallback((function(e){null==a||a(e)}),[a]));var d=s({},c,{startRecording:t.useCallback((function(){l&&l.startRecording.apply(l,arguments)}),[l]),stopRecording:t.useCallback((function(){l&&l.stopRecording.apply(l,arguments)}),[l]),updateRecording:t.useCallback((function(){l&&l.updateRecording.apply(l,arguments)}),[l])});return t.useDebugValue(d),d},exports.useRoom=Ge,exports.useRoomExp=function(e){var n,a,i,o,u,l,c=(void 0===e?{}:e).onCountdown,s=r.useAtomValue(O),d=Ge(),f=t.useState(null),p=f[0],v=f[1];t.useEffect((function(){var e,n,t,a,r,i,o,u,l=[],c=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(a=d.config)?void 0:a.eject_after_elapsed)?e:0;c&&s&&l.push(s.getTime()+1e3*c),null!=d&&null!=(r=d.tokenConfig)&&r.exp&&null!=d&&null!=(i=d.tokenConfig)&&i.eject_at_token_exp&&l.push(1e3*d.tokenConfig.exp),null!=d&&null!=(o=d.config)&&o.exp&&null!=d&&null!=(u=d.config)&&u.eject_at_room_exp&&l.push(1e3*d.config.exp);var f=l.length>0?new Date(Math.min.apply(Math,l)):new Date(0);0!==f.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==f.getTime()?f:e}))}),[s,null==d||null==(n=d.config)?void 0:n.eject_after_elapsed,null==d||null==(a=d.config)?void 0:a.eject_at_room_exp,null==d||null==(i=d.config)?void 0:i.exp,null==d||null==(o=d.tokenConfig)?void 0:o.eject_after_elapsed,null==d||null==(u=d.tokenConfig)?void 0:u.eject_at_token_exp,null==d||null==(l=d.tokenConfig)?void 0:l.exp]),t.useEffect((function(){if(p&&0!==p.getTime()){var e=setInterval((function(){var e,n=(null!=(e=null==p?void 0:p.getTime())?e:0)/1e3-Date.now()/1e3;if(!(n<0)){var t=Math.max(0,Math.floor(n/3600)),a=Math.max(0,Math.floor(n%3600/60)),r=Math.max(0,Math.floor(n%60));null==c||c({hours:t,minutes:a,seconds:r})}}),1e3);return function(){clearInterval(e)}}}),[p,c]);var m={ejectDate:p};return t.useDebugValue(m),m},exports.useScreenAudioTrack=function(e){return Z(e,"screenAudio")},exports.useScreenShare=Y,exports.useScreenVideoTrack=function(e){return Z(e,"screenVideo")},exports.useSendSettings=function(e){var n=(void 0===e?{}:e).onSendSettingsUpdated,a=m(),i=r.useAtom(He),o=i[0],u=i[1];C("send-settings-updated",t.useCallback((function(e){u(e.sendSettings),null==n||n(e)}),[n,u]));var l=t.useCallback((function(e){u(e)}),[u]);t.useEffect((function(){a&&!a.isDestroyed()&&l(a.getSendSettings())}),[a,l]);var s={sendSettings:o,updateSendSettings:t.useCallback(c((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=yield null==a?void 0:a.updateSendSettings.apply(a,n);if(r)return l(r),r})),[a,l])};return t.useDebugValue(s),s},exports.useThrottledDailyEvent=P,exports.useTranscription=function(e){var n=void 0===e?{}:e,a=n.onTranscriptionAppData,i=n.onTranscriptionError,o=n.onTranscriptionMessage,u=n.onTranscriptionStarted,l=n.onTranscriptionStopped,c=m(),d=r.useAtomValue(Ve);C("transcription-started",t.useCallback((function(e){null==u||u(e)}),[u])),C("transcription-stopped",t.useCallback((function(e){null==l||l(e)}),[l])),C("transcription-error",t.useCallback((function(e){null==i||i(e)}),[i])),C("transcription-message",t.useCallback((function(e){null==o||o(e)}),[o])),C("app-message",t.useCallback((function(e){"transcription"===(null==e?void 0:e.fromId)&&(null==a||a(e))}),[a]));var f=s({},d,{startTranscription:t.useCallback((function(){c&&c.startTranscription.apply(c,arguments)}),[c]),stopTranscription:t.useCallback((function(){c&&c.stopTranscription.apply(c,arguments)}),[c])});return t.useDebugValue(f),f},exports.useVideoTrack=function(e){return Z(e,"video")},exports.useWaitingParticipants=function(e){var n=void 0===e?{}:e,a=n.onWaitingParticipantAdded,i=n.onWaitingParticipantRemoved,o=n.onWaitingParticipantUpdated,u=m(),l=r.useAtomValue(W(void 0));C("waiting-participant-added",t.useCallback((function(e){null==a||a(e)}),[a])),C("waiting-participant-removed",t.useCallback((function(e){null==i||i(e)}),[i])),C("waiting-participant-updated",t.useCallback((function(e){null==o||o(e)}),[o]));var c=t.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]),s={waitingParticipants:l,grantAccess:t.useCallback((function(e){c(e,!0)}),[c]),denyAccess:t.useCallback((function(e){c(e,!1)}),[c])};return t.useDebugValue(s),s};
//# sourceMappingURL=daily-react.cjs.production.min.js.map
declare type AudioLevelCallback = (volume: number) => void;
declare type ErrorCallback = (errorMsg: string) => void;
/**

@@ -6,4 +7,5 @@ * Observes the volume level for a given participant.

* @param cb The function to execute when the volume changes. Can be used to visualise audio output.
* @param errorCb Error callback. Called when local audio level observer is not available in browser.
*/
export declare const useAudioLevelObserver: (id: string, cb: AudioLevelCallback) => void;
export declare const useAudioLevelObserver: (id: string, cb: AudioLevelCallback, errorCb?: ErrorCallback | undefined) => void;
export {};
import { Getter, WritableAtom } from 'jotai';
export declare function jotaiDebugLabel(label: string): string;
interface EqualAtomOptions<T> {

@@ -3,0 +4,0 @@ key?: string;

{
"version": "0.21.3",
"version": "0.22.0",
"license": "BSD-2-Clause",

@@ -37,4 +37,5 @@ "keywords": [

"@daily-co/daily-js": ">=0.68.0 <1",
"jotai": ">=2.9.3",
"react": ">=16.13.1"
"jotai": "^2",
"react": "^16.8 || ^17.0 || ^18.0 || ^19.0",
"react-dom": "^16.8 || ^17.0 || ^18.0 || ^19.0"
},

@@ -41,0 +42,0 @@ "husky": {

@@ -8,2 +8,3 @@ import { useCallback, useEffect } from 'react';

type AudioLevelCallback = (volume: number) => void;
type ErrorCallback = (errorMsg: string) => void;

@@ -14,4 +15,9 @@ /**

* @param cb The function to execute when the volume changes. Can be used to visualise audio output.
* @param errorCb Error callback. Called when local audio level observer is not available in browser.
*/
export const useAudioLevelObserver = (id: string, cb: AudioLevelCallback) => {
export const useAudioLevelObserver = (
id: string,
cb: AudioLevelCallback,
errorCb?: ErrorCallback
) => {
const daily = useDaily();

@@ -47,5 +53,9 @@ const localSessionId = useLocalSessionId();

if (daily.isLocalAudioLevelObserverRunning()) return;
daily.startLocalAudioLevelObserver();
try {
daily.startLocalAudioLevelObserver();
} catch {
errorCb?.('Local audio level observer not supported in this browser');
}
},
[daily, isLocal]
[daily, errorCb, isLocal]
);

@@ -52,0 +62,0 @@

@@ -7,2 +7,3 @@ import { DailyCpuLoadStats, DailyEventObject } from '@daily-co/daily-js';

import { jotaiDebugLabel } from '../lib/jotai-custom';
import { useDaily } from './useDaily';

@@ -21,2 +22,3 @@ import { useDailyEvent } from './useDailyEvent';

});
CPULoadState.debugLabel = jotaiDebugLabel('cpu-load');

@@ -23,0 +25,0 @@ interface Props {

@@ -11,2 +11,3 @@ import {

import { jotaiDebugLabel } from '../lib/jotai-custom';
import { Reconstruct } from '../types/Reconstruct';

@@ -29,2 +30,3 @@ import { useDaily } from './useDaily';

const inputSettingsState = atom<DailyInputSettings | null>(null);
inputSettingsState.debugLabel = jotaiDebugLabel('input-settings');

@@ -31,0 +33,0 @@ export const useInputSettings = ({

@@ -6,2 +6,3 @@ import { DailyEventObject, DailyParticipantCounts } from '@daily-co/daily-js';

import { jotaiDebugLabel } from '../lib/jotai-custom';
import { useDaily } from './useDaily';

@@ -14,2 +15,3 @@ import { useDailyEvent } from './useDailyEvent';

});
participantCountsState.debugLabel = jotaiDebugLabel('participant-counts');

@@ -16,0 +18,0 @@ interface Props {

@@ -7,3 +7,3 @@ import { atom, useAtomValue } from 'jotai';

import { arraysDeepEqual } from '../lib/customDeepEqual';
import { equalAtomFamily } from '../lib/jotai-custom';
import { equalAtomFamily, jotaiDebugLabel } from '../lib/jotai-custom';
import type { NumericKeys } from '../types/NumericKeys';

@@ -32,5 +32,11 @@ import type { Paths } from '../types/paths';

*/
export const participantPropertyPathsState = atomFamily((_id: string) =>
atom<Paths<ExtendedDailyParticipant>[]>([])
);
export const participantPropertyPathsState = atomFamily((id: string) => {
const participantPropertyPathsAtom = atom<Paths<ExtendedDailyParticipant>[]>(
[]
);
participantPropertyPathsAtom.debugLabel = jotaiDebugLabel(
`participant-property-paths-${id}`
);
return participantPropertyPathsAtom;
});

@@ -40,5 +46,9 @@ /**

*/
export const participantPropertyState = atomFamily((_param: string) =>
atom<any>(null)
);
export const participantPropertyState = atomFamily((param: string) => {
const participantPropertyAtom = atom<any>(null);
participantPropertyAtom.debugLabel = jotaiDebugLabel(
`participant-property-${param}`
);
return participantPropertyAtom;
});

@@ -45,0 +55,0 @@ /**

@@ -12,2 +12,3 @@ import {

import { jotaiDebugLabel } from '../lib/jotai-custom';
import { useDaily } from './useDaily';

@@ -25,3 +26,3 @@ import { useDailyEvent } from './useDailyEvent';

>((id) => {
return atom<
const participantReceiveSettingsAtom = atom<
DailySingleParticipantReceiveSettings,

@@ -33,2 +34,6 @@ [DailySingleParticipantReceiveSettings],

});
participantReceiveSettingsAtom.debugLabel = jotaiDebugLabel(
`participant-receive-settings-${id}`
);
return participantReceiveSettingsAtom;
});

@@ -35,0 +40,0 @@

@@ -24,2 +24,4 @@ import { useAtomValue } from 'jotai';

useEffect(() => {
const expCandidates: number[] = [];
const ejectAfterElapsed =

@@ -29,25 +31,18 @@ room?.tokenConfig?.eject_after_elapsed ??

0;
const expUTCTimeStamp = room?.tokenConfig?.exp ?? room?.config?.exp ?? 0;
const ejectAtExp =
room?.tokenConfig?.eject_at_token_exp ??
room?.config?.eject_at_room_exp ??
false;
let newEjectDate: Date = new Date(0);
if (ejectAfterElapsed && localJoinDate) {
newEjectDate = new Date(
localJoinDate.getTime() + 1000 * ejectAfterElapsed
);
expCandidates.push(localJoinDate.getTime() + 1000 * ejectAfterElapsed);
}
if (ejectAtExp && expUTCTimeStamp) {
const expDate = new Date(expUTCTimeStamp * 1000);
if (
!newEjectDate.getTime() ||
(newEjectDate.getTime() > 0 && expDate < newEjectDate)
)
newEjectDate = expDate;
if (room?.tokenConfig?.exp && room?.tokenConfig?.eject_at_token_exp) {
expCandidates.push(room.tokenConfig.exp * 1000);
}
if (room?.config?.exp && room?.config?.eject_at_room_exp) {
expCandidates.push(room.config.exp * 1000);
}
const newEjectDate =
expCandidates.length > 0
? new Date(Math.min(...expCandidates))
: new Date(0);
if (newEjectDate.getTime() === 0) return;

@@ -54,0 +49,0 @@

@@ -9,2 +9,3 @@ import {

import { jotaiDebugLabel } from '../lib/jotai-custom';
import { useDaily } from './useDaily';

@@ -14,2 +15,3 @@ import { useDailyEvent } from './useDailyEvent';

const sendSettingsState = atom<DailySendSettings | null>(null);
sendSettingsState.debugLabel = jotaiDebugLabel('send-settings');

@@ -16,0 +18,0 @@ interface Props {

import { atom, Getter, WritableAtom } from 'jotai';
export function jotaiDebugLabel(label: string) {
return 'daily-react-' + label;
}
interface EqualAtomOptions<T> {

@@ -4,0 +8,0 @@ key?: string;

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc