@daily-co/daily-react
Advanced tools
Comparing version 0.18.0 to 0.19.0
@@ -7,3 +7,3 @@ import React from 'react'; | ||
} | ||
interface Props extends React.VideoHTMLAttributes<HTMLVideoElement> { | ||
interface Props extends Omit<React.VideoHTMLAttributes<HTMLVideoElement>, 'onResize'> { | ||
/** | ||
@@ -10,0 +10,0 @@ * For local user-facing camera streams, we'll automatically mirror the video. |
@@ -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("react"),t=e(n),r=require("recoil"),i=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js")),o=e(require("fast-deep-equal"));function u(e,n,t,r,i,a,o){try{var u=e[a](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(r,i)}function l(e){return function(){var n=this,t=arguments;return new Promise((function(r,i){var a=e.apply(n,t);function o(e){u(a,r,i,o,l,"next",e)}function l(e){u(a,r,i,o,l,"throw",e)}o(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(i[t]=e[t]);return i}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function f(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 d(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)?d(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 p=n.createContext(null),v=function(){var e=n.useContext(p);return n.useDebugValue(e),e},g=n.createContext({on:function(){},off:function(){}}),y=0,m=function(){return y++},k=function(e,t){var r=n.useContext(g),i=r.off,a=r.on,o=n.useState(!1),u=o[0],l=o[1],c=n.useRef(0),s=n.useMemo((function(){return m()}),[]);n.useEffect((function(){if(e&&!u){if(c.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.",t),void l(!0);c.current++;var n=setTimeout((function(){c.current=0}),50);return a(e,t,s),function(){clearTimeout(n),i(e,s)}}}),[t,e,s,u,i,a]),n.useDebugValue({event:e,eventId:s,isBlocked:u,callback:t})},b=r.atomFamily({key:"daily-react-participant-property-paths",default:[]}),h=r.atomFamily({key:"daily-react-participant-property",default:null,dangerouslyAllowMutability:!0}),S=r.selectorFamily({key:"daily-react-participant-properties",get:function(e){var n=e.id,t=e.properties;return function(e){var r=e.get;return t.map((function(e){return r(h({id:n,property:e}))}))}},dangerouslyAllowMutability:!0}),C=function(e,t){var i,a=r.useRecoilValue(Array.isArray(t)?S({id:e,properties:t}):h({id:e,property:t}));return n.useDebugValue(Array.isArray(t)?t.reduce((function(e,n,t){return e[n]=a[t],e}),{}):((i={})[t]=a,i)),a},R=function(e,t,r){void 0===r&&(r=500);var a=n.useContext(g),o=a.off,u=a.on,l=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=m(),e}),{}):((n={})[e]=m(),n)}),[e]),c=n.useRef([]);k("call-instance-destroyed",n.useCallback((function(){c.current.length=0}),[]));var s=n.useMemo((function(){return i((function(){0!==c.current.length&&(t(c.current),c.current.length=0)}),r,{trailing:!0})}),[t,r]);n.useEffect((function(){if(e){var n=function(e){c.current.push(e),s()};return Array.isArray(e)?e.forEach((function(e){return u(e,n,l[e])})):u(e,n,l[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,l[e])})):o(e,l[e])}}}),[s,e,l,o,u]),n.useDebugValue({event:e,eventId:l})};function A(e,n){if(e===n)return!0;if(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(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;for(var t,r=f(e.values());!(t=r()).done;)if(!n.has(t.value))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(var i,a=f(e.entries());!(i=a()).done;){var o=i.value,u=o[0],l=o[1];if(!n.has(u))return!1;if(!A(l,n.get(u)))return!1}return!0}if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var c=Object.keys(e),s=Object.keys(n);if(c.length!==s.length)return!1;for(var d=0,p=c;d<p.length;d++){var v=p[d];if(!(v in n)||!A(e[v],n[v]))return!1}return!0}function E(e){var n,t=r.selector({key:e.key+"_inner",get:e.get});return r.selector({key:e.key,get:function(r){var i=(0,r.get)(t);return null!=n&&e.equals(i,n)?n:(n=i,i)}})}function D(e){var n=r.selectorFamily({key:e.key+"_inner",get:e.get}),t=new Map;return r.selectorFamily(c({},e,{key:e.key,get:function(r){return function(i){var a=(0,i.get)(n(r)),o=t.get(r);return null!=o&&e.equals(a,o)?o:(t.set(r,a),a)}}}))}var w=function(e){return function e(n,t){if(void 0===t&&(t=""),"object"!=typeof n||null===n)return[t];var r=[];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var a=t?t+"."+i:i;r.push.apply(r,[a].concat(e(n[i],a)))}return r}(e)},x=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({key:"daily-react-active-id",default:null}),V=r.atom({key:"daily-react-local-id",default:""}),I=r.atom({key:"daily-react-local-joined-date",default:null}),L=r.atom({key:"daily-react-participant-ids",default:[]}),T=r.atomFamily({key:"daily-react-participant-state",default:null,dangerouslyAllowMutability:!0}),P=r.atom({key:"daily-react-waiting-participants",default:[]}),j=r.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),M=E({key:"daily-react-waitingParticipantsSelector",equals:A,get:function(e){var n=e.get;return n(P).map((function(e){return n(j(e))}))}}),F=function(e){var i=e.children,a=v(),o=n.useState(!1),u=o[0],l=o[1],s=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(V,e.local.session_id);var r=Object.values(e),i=r.map((function(e){return e.session_id}));t(L,i),r.forEach((function(e){t(T(e.session_id),e);var n=w(e);t(b(e.session_id),n),n.forEach((function(n){var r=x(e,[n])[0];t(h({id:e.session_id,property:n}),r)}))})),l(!0)}))}}),[]);n.useEffect((function(){if(a&&!u){var e=setInterval((function(){var n=a.participants();"local"in n&&(s(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,u,s]);var d=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&s(e)}}),[a,s]);return k("started-camera",d),k("access-state-updated",d),k("joining-meeting",r.useRecoilCallback((function(e){var n=e.set;return function(){n(I,new Date),d()}}),[d])),k("joined-meeting",n.useCallback((function(e){s(e.participants)}),[s])),R(["active-speaker-change","call-instance-destroyed","left-meeting","participant-joined","participant-updated","participant-left"],r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.get,r=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":i(_,e.activeSpeaker.peerId),i(T(e.activeSpeaker.peerId),(function(e){return e?c({},e,{last_active:new Date}):null}));break;case"participant-joined":i(L,(function(n){return n.includes(e.participant.session_id)?n:[].concat(n,[e.participant.session_id])})),i(T(e.participant.session_id),e.participant);var n=w(e.participant);i(b(e.participant.session_id),n),n.forEach((function(n){var t=x(e.participant,[n])[0];i(h({id:e.participant.session_id,property:n}),t)}));break;case"participant-updated":i(T(e.participant.session_id),(function(n){return c({},n,e.participant)})),e.participant.local&&i(V,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));var a=w(e.participant),o=t(b(e.participant.session_id));i(b(e.participant.session_id),(function(e){return A(e,a)?e:a})),o.filter((function(e){return!a.includes(e)})).forEach((function(n){r(h({id:e.participant.session_id,property:n}))})),a.forEach((function(n){var t=x(e.participant,[n])[0];i(h({id:e.participant.session_id,property:n}),(function(e){return A(e,t)?e:t}))}));break;case"participant-left":i(L,(function(n){return n.includes(e.participant.session_id)?[].concat(n.filter((function(n){return n!==e.participant.session_id}))):n})),r(T(e.participant.session_id)),t(b(e.participant.session_id)).forEach((function(n){r(h({id:e.participant.session_id,property:n}))})),r(b(e.participant.session_id));break;case"call-instance-destroyed":case"left-meeting":r(V);var u=t(L);Array.isArray(u)&&u.forEach((function(e){return r(T(e))})),r(L)}}))}))}}),[])),R(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,r=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":r(P,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),r(j(e.participant.id),e.participant);break;case"waiting-participant-updated":r(j(e.participant.id),e.participant);break;case"waiting-participant-removed":r(P,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(j(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,i)},O=function(){var e=r.useRecoilValue(V);return n.useDebugValue(e),e},B=function(){return!0},q=function(e){var t=void 0===e?{}:e,i=t.filter,a=void 0===i?B:i,o=t.ignoreLocal,u=void 0!==o&&o,l=O(),c=r.useRecoilValue(_),s=u&&c===l,d=!(null!=a&&a(c)),f=n.useState(s||d?null:c),p=f[0],v=f[1];return n.useEffect((function(){s||d||v(c)}),[d,s,c]),n.useDebugValue(p),p},U=function(e){return["blocked","off"].includes(e)},N=D({key:"daily-react-participant-ids-filtered-sorted",equals:A,get:function(e){var n=e.filter,t=e.sort;return function(e){var r=e.get;return r(L).filter((function(e){switch(n){case"local":case"owner":case"record":return r(h({id:e,property:n}));case"remote":return!r(h({id:e,property:"local"}));case"screen":var t=r(S({id:e,properties:["tracks.screenAudio.state","tracks.screenVideo.state"]})),i=t[1];return!U(t[0])||!U(i);default:return!0}})).sort((function(e,n){switch(t){case"joined_at":case"session_id":case"user_id":case"user_name":var i=r(S({id:e,properties:[t]}))[0],a=r(S({id:n,properties:[t]}))[0];if(void 0!==i||void 0!==a){if(void 0===i)return-1;if(void 0===a)return 1;if(i>a)return 1;if(i<a)return-1}return 0;default:return 0}}))}}}),W=function(e){var t=void 0===e?{}:e,i=t.filter,a=t.onActiveSpeakerChange,o=t.onParticipantJoined,u=t.onParticipantLeft,l=t.onParticipantUpdated,c=t.sort,s=r.useRecoilValue(N({filter:"string"==typeof i?i:null,sort:"string"==typeof c?c:null})),d=r.useRecoilCallback((function(e){var n=e.snapshot;return function(){return"function"!=typeof i&&"function"!=typeof c?[]:s.map((function(e){return n.getLoadable(T(e)).contents})).filter(Boolean).filter("function"==typeof i?i:function(){return!0}).sort("function"==typeof c?c:function(){return 0}).map((function(e){return e.session_id})).filter(Boolean)}}),[i,s,c]),f=n.useState([]),p=f[0],v=f[1],g=n.useCallback((function(){var e=d();A(e,p)||v(e)}),[p,d]);n.useEffect((function(){g()}),[g]),R(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&(e.forEach((function(e){switch(e.action){case"participant-joined":null==o||o(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==a||a(e);break;case"participant-left":null==u||u(e)}})),g())}),[g,a,o,u,l]));var y="function"==typeof i||"function"==typeof c?p:s;return n.useDebugValue(y),y},z=E({key:"daily-react-screen-shares",equals:A,get:function(e){var n=e.get;return n(N({filter:"screen",sort:null})).map((function(e){return{local:n(h({id:e,property:"local"})),screenAudio:n(h({id:e,property:"tracks.screenAudio"})),screenVideo:n(h({id:e,property:"tracks.screenVideo"})),screenId:e+"-screen",session_id:e}}))}}),G=function(e){var t=void 0===e?{}:e,i=t.onError,a=t.onLocalScreenShareStarted,o=t.onLocalScreenShareStopped,u=v(),l=n.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=n.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]);k("local-screen-share-started",n.useCallback((function(){return null==a?void 0:a()}),[a])),k("local-screen-share-stopped",n.useCallback((function(){return null==o?void 0:o()}),[o])),k("nonfatal-error",n.useCallback((function(e){"screen-share-error"===e.type&&(null==i||i(e))}),[i]));var s=r.useRecoilValue(z),d={isSharingScreen:s.some((function(e){return e.local})),screens:s,startScreenShare:l,stopScreenShare:c};return n.useDebugValue(d),d},H=function(e,t){void 0===t&&(t="video");var r=C(e,"tracks."+t),i=r?c({},r,{isOff:U(r.state)}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1};return n.useDebugValue(i),i};function Q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var r=t[n];"function"==typeof r?r(e):r&&"object"==typeof r&&(r.current=e)}}),t)}var J=["onPlayFailed","sessionId","type"],$=n.memo(n.forwardRef((function(e,r){var i=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,l=s(e,J),c=n.useRef(null),d=H(a,u),f=Q(c,r),p=null==d?void 0:d.subscribed;return n.useEffect((function(){var e=c.current;if(e&&null!=d&&d.persistentTrack){var n=function(){e.play().catch((function(n){null==i||i({sessionId:a,target:e,type:u,message:n.message,name:n.name})}))},t=function(){clearTimeout(void 0)};return e.addEventListener("canplay",n),e.addEventListener("play",t),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",n),null==e||e.removeEventListener("play",t)}}}),[null==d?void 0:d.persistentTrack,i,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},l,{"data-session-id":a,"data-audio-type":u,"data-subscribed":p}))})));$.displayName="DailyAudioTrack";var K=n.memo(n.forwardRef((function(e,i){var a=e.autoSubscribeActiveSpeaker,o=void 0!==a&&a,u=e.maxSpeakers,c=void 0===u?5:u,s=e.onPlayFailed,d=e.playLocalScreenAudio,f=void 0!==d&&d,p=v(),g=n.useState(new Array(c).fill("")),y=g[0],m=g[1],k=G().screens,b=O(),S=q({ignoreLocal:!0}),C=n.useRef(null);n.useImperativeHandle(i,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=C.current)?void 0:n.querySelector('audio[data-session-id="'+S+'"][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}}}),[S]);var A=r.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=l((function*(e){var t,r=Object.values(null!=(t=null==p?void 0:p.participants())?t:{}).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(e)){if(!p||p.isDestroyed()||!o||p.subscribeToTracksAutomatically())return;p.updateParticipant(e,{setSubscribedTracks:{audio:!0}})}m((function(t){var a;if(t.includes(e))return t;var o=function(e){return!e||!i(e)};if(t.some(o)){var u=t.findIndex(o);return t[u]=e,[].concat(t)}var l=t.findIndex((function(e){return r.some((function(n){return n.session_id===e&&U(n.tracks.audio.state)}))}));if(l>=0)return t[l]=e,[].concat(t);var c=r.filter((function(e){return t.includes(e.session_id)&&e.session_id!==S})).sort((function(e,t){var r,i,a=null!=(r=n.getLoadable(h({id:e.session_id,property:"last_active"})).contents)?r:new Date("1970-01-01"),o=null!=(i=n.getLoadable(h({id:t.session_id,property:"last_active"})).contents)?i:new Date("1970-01-01");return a>o?1:a<o?-1:0}));if(!c.length){var s=t.findIndex((function(e){return e!==S}));return t[s]=e,[].concat(t)}var d=t.indexOf(null==(a=c[0])?void 0:a.session_id);return t[d]=e,[].concat(t)}))}));return function(n){return e.apply(this,arguments)}}()}),[S,o,p]),E=n.useCallback((function(e){m((function(n){if(!n.includes(e))return n;var t=[].concat(n),r=t.indexOf(e);return t[r]="",t}))}),[]);R(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===b)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":E(e.participant.session_id)}}))}),[A,b,E]),200);var D=W({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:C},y.map((function(e,n){return t.createElement($,{key:"speaker-slot-"+n,onPlayFailed:s,sessionId:e,type:"audio"})})),k.filter((function(e){return!!f||!e.local})).map((function(e){return t.createElement($,{key:e.screenId,onPlayFailed:s,sessionId:e.session_id,type:"screenAudio"})})),D.map((function(e){return t.createElement($,{key:e+"-rmp",onPlayFailed:s,sessionId:e,type:"rmpAudio"})})))})));K.displayName="DailyAudio";var X=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],Y=n.forwardRef((function(e,r){var i=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,l=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,g=void 0===v?{}:v,y=e.type,m=void 0===y?"video":y,k=s(e,X),b=O()===p,h="screenVideo"===m,S=b&&!h,R=n.useRef(null),A=Q(R,r),E=H(p,m),D=E.persistentTrack,w=S||h||!E.isOff,x=C(p,"tracks."+m),_=null==x?void 0:x.subscribed,V=n.useMemo((function(){if("boolean"==typeof u)return u;if(!i)return!1;if(!D)return S;var e=D.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[i,S,u,D]);return n.useEffect((function(){var e=R.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()},r=function(){e.style.transform="scale(1)"},i=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",r),e.addEventListener("leavepictureinpicture",i),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",r),e.removeEventListener("leavepictureinpicture",i),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=R.current;if(e&&D)return e.srcObject=new MediaStream([D]),e.load(),function(){e.srcObject=null,e.load()}}),[D,null==D?void 0:D.id]),n.useEffect((function(){var e,n=R.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=R.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]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:A,"data-local":b,"data-mirrored":V||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":_,"data-video-type":m,style:c({objectFit:o,transform:V?"scale(-1, 1)":""},g,w?f:{})},k))}));Y.displayName="DailyVideo";var Z=n.createContext({refreshDevices:function(){return Promise.resolve()}}),ee=r.atom({key:"daily-react-general-camera-state",default:"idle"}),ne=r.atom({key:"daily-react-general-microphone-state",default:"idle"}),te=r.atom({key:"daily-react-camera-devices",default:[]}),re=r.atom({key:"daily-react-microphone-devices",default:[]}),ie=r.atom({key:"daily-react-speaker-devices",default:[]}),ae=r.atom({key:"daily-react-last-camera-error",default:null}),oe=function(e){var i=e.children,a=v(),o=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return l((function*(){var e,t,r,i;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var r,i;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(r=null==(i=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:i.state)?r:"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((function(e){var n=e.set;n(te,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(g)})),n(re,(function(e){return l.filter(Boolean).map((function(n){return v(f,n,e)})).sort(g)})),n(ie,(function(e){return c.filter(Boolean).map((function(n){return v(p,n,e)})).sort(g)}))}))}catch(e){n((function(e){var n=e.set;n(ee,"not-supported"),n(ne,"not-supported")}))}}else n((function(e){var n=e.set;n(ee,"not-supported"),n(ne,"not-supported")}))}))}),[a]),u=r.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,r=e.transact_UNSTABLE;return l((function*(){var e,i,u,l,s,d,f,p,v,g,y,m,k,b;if(a){var h=yield t.getPromise(ee),S=yield t.getPromise(ne),C=a.participants();if(C.local){var R=C.local.tracks,A="prompt",E="prompt";if(navigator.permissions)try{A=(yield navigator.permissions.query({name:"camera"})).state,E=(yield navigator.permissions.query({name:"microphone"})).state}catch(e){}var D="prompt"===A&&["idle","pending"].includes(h)&&"interrupted"===R.video.state&&!R.video.persistentTrack,w=["idle","pending"].includes(h)&&!R.video.persistentTrack&&Boolean(null==(e=R.video.off)?void 0:e.byUser),x="prompt"===E&&["idle","pending"].includes(S)&&"interrupted"===R.audio.state&&!R.audio.persistentTrack,_=["idle","pending"].includes(S)&&!R.audio.persistentTrack&&Boolean(null==(i=R.audio.off)?void 0:i.byUser);null!=(u=R.audio)&&null!=(l=u.blocked)&&l.byDeviceInUse?r((function(e){var n=e.set;n(ne,"in-use"),n(re,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(s=R.audio)&&null!=(d=s.blocked)&&d.byDeviceMissing?n(ne,"not-found"):null!=(f=R.audio)&&null!=(p=f.blocked)&&p.byPermissions||"denied"===E?n(ne,"blocked"):x?n(ne,"pending"):_?n(ne,"idle"):r((function(e){var n=e.set;n(ne,"granted"),n(re,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),null!=(v=R.video)&&null!=(g=v.blocked)&&g.byDeviceInUse?r((function(e){var n=e.set;n(ee,"in-use"),n(te,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(y=R.video)&&null!=(m=y.blocked)&&m.byDeviceMissing?n(ee,"not-found"):null!=(k=R.video)&&null!=(b=k.blocked)&&b.byPermissions||"denied"===A?n(ee,"blocked"):D?n(ee,"pending"):w?n(ee,"idle"):r((function(e){var n=e.set;n(ee,"granted"),n(te,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return k("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),k("available-devices-updated",o),k("selected-devices-updated",o),k("camera-error",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,r,i,a,o,u,l,c=n.set;switch(c(ae,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":c(ee,"in-use");break;case"mic-in-use":c(ne,"in-use");break;case"cam-mic-in-use":c(ee,"in-use"),c(ne,"in-use");break;case"not-found":null!=(r=e.error)&&r.missingMedia.includes("video")&&c(ee,"not-found"),null!=(i=e.error)&&i.missingMedia.includes("audio")&&c(ne,"not-found");break;case"permissions":null!=(a=e.error)&&a.blockedMedia.includes("video")&&c(ee,"blocked"),null!=(o=e.error)&&o.blockedMedia.includes("audio")&&c(ne,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(c(ee,"constraints-invalid"),c(ne,"constraints-invalid")):"none-specified"===(null==(l=e.error)?void 0:l.reason)&&(c(ee,"constraints-none-specified"),c(ne,"constraints-none-specified"));break;case"undefined-mediadevices":c(ee,"undefined-mediadevices"),c(ne,"undefined-mediadevices");break;case"unknown":default:c(ee,"unknown"),c(ne,"unknown")}}))}}),[])),k("started-camera",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(ee,"granted"),n(ne,"granted")})),u()}}),[u])),t.createElement(Z.Provider,{value:{refreshDevices:o}},i)},ue=r.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),le=function(e){var n=e.children;return k("live-streaming-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(ue,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),k("live-streaming-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ue,(function(e){return c({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),k("live-streaming-error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(ue,(function(n){return c({},n,{errorMsg:e.errorMsg})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(ue)}}),[])),t.createElement(t.Fragment,null,n)},ce=r.atom({key:"daily-react-meeting-state",default:"new"}),se=r.atom({key:"daily-react-meeting-error",default:null}),de=r.atom({key:"daily-react-non-fatal-error",default:null}),fe=r.atom({key:"meeting-session-data",default:{data:void 0,topology:"none"}}),pe=function(e){var n=e.children,i=v(),a=r.useRecoilCallback((function(e){var n=e.set;return function(){if(i){var e=i.meetingState();return n(ce,e),e}}}),[i]);k("loading",a),k("loaded",a),k("joining-meeting",a),k("joined-meeting",a),k("left-meeting",a),k("error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(se,e),a()}}),[a])),k("nonfatal-error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(de,e)}}),[]));var o=r.useRecoilCallback((function(e){var n=e.set;return function(){i&&n(fe,i.meetingSessionState())}}),[i]);return k("joined-meeting",o),k("meeting-session-state-updated",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(fe,e.meetingSessionState)}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(fe)}}),[])),k("call-instance-destroyed",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.reset;n(ce),n(se),n(de),n(fe)}))}}),[])),t.createElement(t.Fragment,null,n)},ve=r.atom({key:"daily-react-topology",default:"none"}),ge=r.atom({key:"daily-react-networkQuality",default:100}),ye=r.atom({key:"daily-react-networkThreshold",default:"good"}),me=function(e){var i=e.children,a=v(),o=r.useRecoilValue(ve),u=r.useRecoilCallback((function(e){var n=e.set;return l((function*(){if(a){var e=yield a.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(ve,e.topology)}}))}),[a]);return k("joined-meeting",u),k("network-connection",r.useRecoilCallback((function(e){var n=e.set;return function(e){switch(e.event){case"connected":"peer-to-peer"===e.type&&n(ve,"peer"),"sfu"===e.type&&n(ve,"sfu")}}}),[])),k("network-quality-change",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(ge,(function(n){return n!==e.quality?e.quality:n})),t(ye,(function(n){return n!==e.threshold?e.threshold:n}))}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.reset;n(ve),n(ge),n(ye)}))}}),[])),n.useEffect((function(){a&&"none"===o&&u()}),[a,u,o]),t.createElement(t.Fragment,null,i)},ke=r.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),be=function(e){var i=e.children,a=r.useSetRecoilState(ke),o=O(),u=W({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return c({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),k("recording-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var r;o&&"single-participant"===(null==(r=e.layout)?void 0:r.preset)&&e.layout.session_id!==o&&(t=!1)}n(ke,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),k("recording-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ke,(function(e){return c({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("recording-error",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ke,(function(e){return c({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(ke)}}),[])),t.createElement(t.Fragment,null,i)},he=function(){var e=r.useRecoilValue(ce);return n.useDebugValue(e),e},Se=r.atom({key:"daily-react-room",default:null}),Ce=function(e){var n=e.children,i=v(),a=he(),o=r.useRecoilCallback((function(e){var n=e.set;return l((function*(){if(i&&"left-meeting"!==a){var e=yield i.room();return e&&"id"in e&&n(Se,e),e}}))}),[i,a]);return k("access-state-updated",o),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(Se)}}),[])),t.createElement(t.Fragment,null,n)},Re=r.atom({key:"daily-react-transcription",default:{isTranscribing:!1,model:"general",language:"en",transcriptions:[]}}),Ae=function(e){var n=e.children;return k("transcription-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Re,c({error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e))}}),[])),k("transcription-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Re,(function(n){return c({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})}))}}),[])),k("transcription-error",r.useRecoilCallback((function(e){var n=e.set;return function(){n(Re,(function(e){return c({},e,{error:!0,isTranscribing:!1})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.set;return function(){n(Re,(function(e){return c({},e,{isTranscribing:!1})}))}}),[])),k("app-message",r.useRecoilCallback((function(e){var n=e.set;return function(e){"transcription"===(null==e?void 0:e.fromId)&&n(Re,(function(n){return c({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})}))}}),[])),t.createElement(t.Fragment,null,n)},Ee={},De=function(){return!0},we={options:Ee,shouldCreateInstance:De},xe=function(e,t){var r=void 0===t?we:t,i=r.parentEl,o=r.options,u=void 0===o?Ee:o,s=r.shouldCreateInstance,d=void 0===s?De:s,f=n.useState(null),p=f[0],v=f[1],g=n.useRef();return n.useEffect((function(){if(("callFrame"!==e||null!==i)&&d()){var n=function(){setTimeout((function(){return v(null)}),0)},t=a.getCallInstance();if(!p&&t&&!t.isDestroyed())return t.once("call-instance-destroyed",n),void v(t);if(p)A(g.current,u)||function(e){r.apply(this,arguments)}(p);else{if(!t||t.isDestroyed()){switch(e){case"callFrame":t=i?a.createFrame(i,c({},u)):a.createFrame(c({},u));break;case"callObject":t=a.createCallObject(c({},u))}g.current=u}v(t),t.once("call-instance-destroyed",n)}}function r(){return(r=l((function*(e){yield e.destroy()}))).apply(this,arguments)}}),[p,u,i,d,e]),p},_e=function(e){return xe("callObject",e)},Ve=["children","recoilRootProps"],Ie=function(e,t){var i=void 0===t?{}:t,a=i.onParticipantLeft,o=i.onParticipantUpdated,u=r.useRecoilValue(T(e));return R(["participant-updated","participant-left"],n.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==a||a(e)}}))}),[a,o,e])),n.useDebugValue(u),u},Le="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"),Te=r.atom({key:"cpu-load-state",default:{state:"low",reason:"none"}}),Pe=function(){var e={meetingError:r.useRecoilValue(se),nonFatalError:r.useRecoilValue(de)};return n.useDebugValue(e),e},je=r.atom({key:"daily-react-input-settings",default:null}),Me=r.atom({key:"daily-react-participant-counts",default:{hidden:0,present:0}}),Fe=r.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),Oe=function(){var e=r.useRecoilValue(Se);return n.useDebugValue(e),e},Be=r.atom({key:"daily-react-send-settings",default:null});exports.DailyAudio=K,exports.DailyAudioTrack=$,exports.DailyProvider=function(e){var i=e.children,a=e.recoilRootProps,o=void 0===a?{}:a,u=s(e,Ve),l=n.useRef({}),c=n.useCallback((function(e){if("action"in e)for(var n,t=f(null!=(r=null==(i=l.current)||null==(a=i[e.action])?void 0:a.values())?r:[]);!(n=t()).done;){var r,i,a;(0,n.value)(e)}}),[]),d=n.useCallback((function(e){e&&Object.keys(l.current).forEach((function(n){e.off(n,c),e.isDestroyed()||e.on(n,c)}))}),[c]),v="callObject"in u?u.callObject:null,y=n.useMemo((function(){return"callObject"in u?{}:u}),[u]),m=_e({options:y,shouldCreateInstance:n.useCallback((function(){return!("callObject"in u)}),[u])}),k=null!=v?v:m;n.useEffect((function(){k&&d(k)}),[k,d]);var b=n.useCallback((function(e,n,t){var r,i;l.current[e]||(l.current[e]=new Map,k&&(k.off(e,c),k.isDestroyed()||k.on(e,c))),null!=(r=l.current[e])&&r.has(t)||null==(i=l.current[e])||i.set(t,n)}),[k,c]),h=n.useCallback((function(e,n){var t,r;null==(t=l.current[e])||t.delete(n),0===(null==(r=l.current[e])?void 0:r.size)&&(null==k||k.off(e,c),delete l.current[e])}),[k,c]);return t.createElement(r.RecoilRoot,Object.assign({},o),t.createElement(p.Provider,{value:k},t.createElement(g.Provider,{value:{on:b,off:h}},t.createElement(Ce,null,t.createElement(pe,null,t.createElement(me,null,t.createElement(F,null,t.createElement(be,null,t.createElement(le,null,t.createElement(Ae,null,t.createElement(oe,null,i)))))))))))},exports.DailyVideo=Y,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,i=t.ignoreLocal,a=void 0!==i&&i,o=t.onActiveSpeakerChange,u=v(),l=r.useRecoilValue(_),c=n.useState(""),s=c[1],d=Ie(c[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&l===(null==n?void 0:n.session_id)||s(null!=l?l:"")}}),[u,a,l]),k("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),n.useDebugValue(d),d},exports.useActiveSpeakerId=q,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=v(),i=n.useCallback((function(e,n){void 0===n&&(n="*"),r&&r.sendAppMessage(e,n)}),[r]),a=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return k("app-message",a),i},exports.useAudioLevel=function(e,t){var r=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){r.current||(r.current=new n);var i=r.current;if(i){var a,o,u=i.createMediaStreamSource(new MediaStream([e]));return function(){var e=l((function*(){try{a=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){try{yield i.audioWorklet.addModule(Le),a=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){console.error(e)}}if(a&&o){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)},o.gain.value=0;try{u.connect(a).connect(o).connect(i.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==u||u.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return H(e,"audio")},exports.useCPULoad=function(e){var t=(void 0===e?{}:e).onCPULoadChange,i=r.useRecoilValue(Te),a=v(),u=he(),c=r.useRecoilCallback((function(e){var n=e.set,t=e.snapshot;return function(){var e=l((function*(e){var r=yield t.getPromise(Te);o(r,e)||n(Te,e)}));return function(n){return e.apply(this,arguments)}}()}),[]);return n.useEffect((function(){var e=!0;if(a&&!a.isDestroyed()&&"joined-meeting"===u)return a.getCpuLoadStats().then((function(n){e&&c({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[a,u,c]),k("cpu-load-change",n.useCallback((function(e){c({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==t||t(e)}),[t,c])),n.useDebugValue(i),i},exports.useCallFrame=function(e){return xe("callFrame",e)},exports.useCallObject=_e,exports.useDaily=v,exports.useDailyError=Pe,exports.useDailyEvent=k,exports.useDevices=function(){var e=v(),t=r.useRecoilValue(ee),i=r.useRecoilValue(ne),a=r.useRecoilValue(te),o=r.useRecoilValue(re),u=r.useRecoilValue(ie),c=r.useRecoilValue(ae),s=n.useContext(Z).refreshDevices,d=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),g=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"],y={cameraError:c,cameras:a,camState:t,currentCam:a.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:g.includes(t),hasMicError:g.includes(i),microphones:o,micState:i,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u};return n.useDebugValue(y),y},exports.useInputSettings=function(e){var t=void 0===e?{}:e,i=t.onError,a=t.onInputSettingsUpdated,o=r.useRecoilValue(je),u=Pe().nonFatalError,l=v(),c=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(je,e)}}),[]);n.useEffect((function(){l&&l.getInputSettings().then(c)}),[l,c]),k("input-settings-updated",n.useCallback((function(e){c(e.inputSettings),null==a||a(e)}),[a,c])),k("nonfatal-error",n.useCallback((function(e){"input-settings-error"===e.type&&(null==i||i(e))}),[i]));var s=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return null==l?void 0:l.updateInputSettings.apply(l,n)}),[l]),d={errorMsg:"input-settings-error"===(null==u?void 0:u.type)?u.errorMsg:null,inputSettings:o,updateInputSettings:s};return n.useDebugValue(d),d},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,i=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=t.onLiveStreamingUpdated,l=t.onLiveStreamingWarning,s=v(),d=r.useRecoilValue(ue);k("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),k("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),k("live-streaming-updated",n.useCallback((function(e){null==u||u(e)}),[u])),k("live-streaming-error",n.useCallback((function(e){null==i||i(e)}),[i])),k("nonfatal-error",n.useCallback((function(e){"live-streaming-warning"===e.type&&(null==l||l(e))}),[l]));var f=c({},d,{startLiveStreaming:n.useCallback((function(){s&&s.startLiveStreaming.apply(s,arguments)}),[s]),stopLiveStreaming:n.useCallback((function(){s&&s.stopLiveStreaming.apply(s,arguments)}),[s]),updateLiveStreaming:n.useCallback((function(){s&&s.updateLiveStreaming.apply(s,arguments)}),[s])});return n.useDebugValue(f),f},exports.useLocalParticipant=function(){var e=r.useRecoilValue(V),t=Ie(e);return n.useDebugValue(t),t},exports.useLocalSessionId=O,exports.useMediaTrack=H,exports.useMeetingSessionState=function(e){var t=(void 0===e?{}:e).onError,i=r.useRecoilValue(fe);k("nonfatal-error",n.useCallback((function(e){"meeting-session-data-error"===e.type&&(null==t||t(e))}),[t]));var a={data:null==i?void 0:i.data,topology:null==i?void 0:i.topology};return n.useDebugValue(a),a},exports.useMeetingState=he,exports.useNetwork=function(e){var t=void 0===e?{}:e,i=t.onNetworkConnection,a=t.onNetworkQualityChange,o=v(),u=r.useRecoilValue(ve),c=r.useRecoilValue(ge),s=r.useRecoilValue(ye);k("network-connection",n.useCallback((function(e){null==i||i(e)}),[i])),k("network-quality-change",n.useCallback((function(e){null==a||a(e)}),[a]));var d={getStats:n.useCallback(l((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:c,threshold:s,topology:u};return n.useDebugValue(d),d},exports.useParticipant=Ie,exports.useParticipantCounts=function(e){var t=(void 0===e?{}:e).onParticipantCountsUpdated,i=v(),a=r.useRecoilValue(Me),o=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Me,e)}}),[]);return k("participant-counts-updated",n.useCallback((function(e){o(e.participantCounts),null==t||t(e)}),[t,o])),n.useEffect((function(){i&&!i.isDestroyed()&&o(i.participantCounts())}),[i,o]),n.useDebugValue(a),a},exports.useParticipantIds=W,exports.useParticipantProperty=C,exports.usePermissions=function(e){var t,r,i,a,o,u,l,c,s,d=O(),f=C(null!=e?e:d,"permissions"),p="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(t=f.canSend)?void 0:t.has("audio")),v="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("video")),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("customAudio")),y="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("customVideo")),m="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")),k="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")),b={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:g,canSendCustomVideo:y,canSendScreenAudio:m,canSendScreenVideo:k,canSendVideo:v,hasPresence:null==f?void 0:f.hasPresence,permissions:f};return n.useDebugValue(b),b},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,i=t.id,a=void 0===i?"base":i,o=t.onReceiveSettingsUpdated,u=r.useRecoilValue(Fe("base")),l=r.useRecoilValue(Fe(a)),s=v(),d=he(),f=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,r=n.set,i=c({},e),o=0,u=Object.entries(i);o<u.length;o++){var l=u[o],s=l[1];r(Fe(l[0]),s)}a in i||t(Fe(a))}))}}),[a]);k("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var p=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]),g={receiveSettings:"base"===a||0===Object.keys(l).length?u:l,updateReceiveSettings:p};return n.useDebugValue(g),g},exports.useRecording=function(e){var t=void 0===e?{}:e,i=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,l=v(),s=r.useRecoilValue(ke);k("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),k("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),k("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("recording-data",n.useCallback((function(e){null==i||i(e)}),[i]));var d=c({},s,{startRecording:n.useCallback((function(){l&&l.startRecording.apply(l,arguments)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording.apply(l,arguments)}),[l]),updateRecording:n.useCallback((function(){l&&l.updateRecording.apply(l,arguments)}),[l])});return n.useDebugValue(d),d},exports.useRoom=Oe,exports.useRoomExp=function(e){var t,i,a,o,u,l,c=(void 0===e?{}:e).onCountdown,s=r.useRecoilValue(I),d=Oe(),f=n.useState(null),p=f[0],v=f[1];n.useEffect((function(){var e,n,t,r,i,a,o,u,l,c,f,p,g=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(r=d.config)?void 0:r.eject_after_elapsed)?e:0,y=null!=(i=null!=(a=null==d||null==(o=d.tokenConfig)?void 0:o.exp)?a:null==d||null==(u=d.config)?void 0:u.exp)?i:0,m=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,k=new Date(0);if(g&&s&&(k=new Date(s.getTime()+1e3*g)),m&&y){var b=new Date(1e3*y);(!k.getTime()||k.getTime()>0&&b<k)&&(k=b)}0!==k.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==k.getTime()?k:e}))}),[s,null==d||null==(t=d.config)?void 0:t.eject_after_elapsed,null==d||null==(i=d.config)?void 0:i.eject_at_room_exp,null==d||null==(a=d.config)?void 0:a.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]),n.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)),r=Math.max(0,Math.floor(n%3600/60)),i=Math.max(0,Math.floor(n%60));null==c||c({hours:t,minutes:r,seconds:i})}}),1e3);return function(){clearInterval(e)}}}),[p,c]);var g={ejectDate:p};return n.useDebugValue(g),g},exports.useScreenAudioTrack=function(e){return H(e,"screenAudio")},exports.useScreenShare=G,exports.useScreenVideoTrack=function(e){return H(e,"screenVideo")},exports.useSendSettings=function(e){var t=(void 0===e?{}:e).onSendSettingsUpdated,i=v(),a=r.useRecoilValue(Be);k("send-settings-updated",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Be,e.sendSettings),null==t||t(e)}}),[t]));var o=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Be,e)}}),[]);n.useEffect((function(){i&&!i.isDestroyed()&&o(i.getSendSettings())}),[i,o]);var u={sendSettings:a,updateSendSettings:n.useCallback(l((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=yield null==i?void 0:i.updateSendSettings.apply(i,n);if(r)return o(r),r})),[i,o])};return n.useDebugValue(u),u},exports.useThrottledDailyEvent=R,exports.useTranscription=function(e){var t=void 0===e?{}:e,i=t.onTranscriptionAppData,a=t.onTranscriptionError,o=t.onTranscriptionMessage,u=t.onTranscriptionStarted,l=t.onTranscriptionStopped,s=v(),d=r.useRecoilValue(Re);k("transcription-started",n.useCallback((function(e){null==u||u(e)}),[u])),k("transcription-stopped",n.useCallback((function(e){null==l||l(e)}),[l])),k("transcription-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("transcription-message",n.useCallback((function(e){null==o||o(e)}),[o])),k("app-message",n.useCallback((function(e){"transcription"===(null==e?void 0:e.fromId)&&(null==i||i(e))}),[i]));var f=c({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])});return n.useDebugValue(f),f},exports.useVideoTrack=function(e){return H(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,i=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=v(),l=r.useRecoilValue(M);k("waiting-participant-added",n.useCallback((function(e){null==i||i(e)}),[i])),k("waiting-participant-removed",n.useCallback((function(e){null==a||a(e)}),[a])),k("waiting-participant-updated",n.useCallback((function(e){null==o||o(e)}),[o]));var c=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]),s={waitingParticipants:l,grantAccess:n.useCallback((function(e){c(e,!0)}),[c]),denyAccess:n.useCallback((function(e){c(e,!1)}),[c])};return n.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("react"),t=e(n),r=require("recoil"),i=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js")),o=e(require("fast-deep-equal"));function u(e,n,t,r,i,a,o){try{var u=e[a](o),l=u.value}catch(e){return void t(e)}u.done?n(l):Promise.resolve(l).then(r,i)}function l(e){return function(){var n=this,t=arguments;return new Promise((function(r,i){var a=e.apply(n,t);function o(e){u(a,r,i,o,l,"next",e)}function l(e){u(a,r,i,o,l,"throw",e)}o(void 0)}))}}function c(){return(c=Object.assign?Object.assign.bind():function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])}return e}).apply(this,arguments)}function s(e,n){if(null==e)return{};var t,r,i={},a=Object.keys(e);for(r=0;r<a.length;r++)n.indexOf(t=a[r])>=0||(i[t]=e[t]);return i}function d(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function f(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 d(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)?d(e,void 0):void 0}}(e))||n&&e&&"number"==typeof e.length){t&&(e=t);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}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 p=n.createContext(null),v=function(){var e=n.useContext(p);return n.useDebugValue(e),e},g=n.createContext({on:function(){},off:function(){}}),y=0,m=function(){return y++},k=function(e,t){var r=n.useContext(g),i=r.off,a=r.on,o=n.useState(!1),u=o[0],l=o[1],c=n.useRef(0),s=n.useMemo((function(){return m()}),[]);n.useEffect((function(){if(e&&!u){if(c.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.",t),void l(!0);c.current++;var n=setTimeout((function(){c.current=0}),50);return a(e,t,s),function(){clearTimeout(n),i(e,s)}}}),[t,e,s,u,i,a]),n.useDebugValue({event:e,eventId:s,isBlocked:u,callback:t})},b=r.atomFamily({key:"daily-react-participant-property-paths",default:[]}),h=r.atomFamily({key:"daily-react-participant-property",default:null,dangerouslyAllowMutability:!0}),S=r.selectorFamily({key:"daily-react-participant-properties",get:function(e){var n=e.id,t=e.properties;return function(e){var r=e.get;return t.map((function(e){return r(h({id:n,property:e}))}))}},dangerouslyAllowMutability:!0}),C=function(e,t){var i,a=r.useRecoilValue(Array.isArray(t)?S({id:e,properties:t}):h({id:e,property:t}));return n.useDebugValue(Array.isArray(t)?t.reduce((function(e,n,t){return e[n]=a[t],e}),{}):((i={})[t]=a,i)),a},R=function(e,t,r){void 0===r&&(r=500);var a=n.useContext(g),o=a.off,u=a.on,l=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=m(),e}),{}):((n={})[e]=m(),n)}),[e]),c=n.useRef([]);k("call-instance-destroyed",n.useCallback((function(){c.current.length=0}),[]));var s=n.useMemo((function(){return i((function(){0!==c.current.length&&(t(c.current),c.current.length=0)}),r,{trailing:!0})}),[t,r]);n.useEffect((function(){if(e){var n=function(e){c.current.push(e),s()};return Array.isArray(e)?e.forEach((function(e){return u(e,n,l[e])})):u(e,n,l[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,l[e])})):o(e,l[e])}}}),[s,e,l,o,u]),n.useDebugValue({event:e,eventId:l})};function A(e,n){if(e===n)return!0;if(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(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;for(var t,r=f(e.values());!(t=r()).done;)if(!n.has(t.value))return!1;return!0}if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(var i,a=f(e.entries());!(i=a()).done;){var o=i.value,u=o[0],l=o[1];if(!n.has(u))return!1;if(!A(l,n.get(u)))return!1}return!0}if("object"!=typeof e||null===e||"object"!=typeof n||null===n)return!1;var c=Object.keys(e),s=Object.keys(n);if(c.length!==s.length)return!1;for(var d=0,p=c;d<p.length;d++){var v=p[d];if(!(v in n)||!A(e[v],n[v]))return!1}return!0}function E(e){var n,t=r.selector({key:e.key+"_inner",get:e.get});return r.selector({key:e.key,get:function(r){var i=(0,r.get)(t);return null!=n&&e.equals(i,n)?n:(n=i,i)}})}function D(e){var n=r.selectorFamily({key:e.key+"_inner",get:e.get}),t=new Map;return r.selectorFamily(c({},e,{key:e.key,get:function(r){return function(i){var a=(0,i.get)(n(r)),o=t.get(r);return null!=o&&e.equals(a,o)?o:(t.set(r,a),a)}}}))}var w=function(e){return function e(n,t){if(void 0===t&&(t=""),"object"!=typeof n||null===n)return[t];var r=[];for(var i in n)if(Object.prototype.hasOwnProperty.call(n,i)){var a=t?t+"."+i:i;r.push.apply(r,[a].concat(e(n[i],a)))}return r}(e)},x=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({key:"daily-react-active-id",default:null}),V=r.atom({key:"daily-react-local-id",default:""}),I=r.atom({key:"daily-react-local-joined-date",default:null}),L=r.atom({key:"daily-react-participant-ids",default:[]}),T=r.atomFamily({key:"daily-react-participant-state",default:null,dangerouslyAllowMutability:!0}),P=r.atom({key:"daily-react-waiting-participants",default:[]}),j=r.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),M=E({key:"daily-react-waitingParticipantsSelector",equals:A,get:function(e){var n=e.get;return n(P).map((function(e){return n(j(e))}))}}),F=function(e){var i=e.children,a=v(),o=n.useState(!1),u=o[0],l=o[1],s=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(V,e.local.session_id);var r=Object.values(e),i=r.map((function(e){return e.session_id}));t(L,i),r.forEach((function(e){t(T(e.session_id),e);var n=w(e);t(b(e.session_id),n),n.forEach((function(n){var r=x(e,[n])[0];t(h({id:e.session_id,property:n}),r)}))})),l(!0)}))}}),[]);n.useEffect((function(){if(a&&!u){var e=setInterval((function(){var n=a.participants();"local"in n&&(s(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,u,s]);var d=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&s(e)}}),[a,s]);return k("started-camera",d),k("access-state-updated",d),k("joining-meeting",r.useRecoilCallback((function(e){var n=e.set;return function(){n(I,new Date),d()}}),[d])),k("joined-meeting",n.useCallback((function(e){s(e.participants)}),[s])),R(["active-speaker-change","call-instance-destroyed","left-meeting","participant-joined","participant-updated","participant-left"],r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.get,r=n.reset,i=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":i(_,e.activeSpeaker.peerId),i(T(e.activeSpeaker.peerId),(function(e){return e?c({},e,{last_active:new Date}):null}));break;case"participant-joined":i(L,(function(n){return n.includes(e.participant.session_id)?n:[].concat(n,[e.participant.session_id])})),i(T(e.participant.session_id),e.participant);var n=w(e.participant);i(b(e.participant.session_id),n),n.forEach((function(n){var t=x(e.participant,[n])[0];i(h({id:e.participant.session_id,property:n}),t)}));break;case"participant-updated":i(T(e.participant.session_id),(function(n){return c({},n,e.participant)})),e.participant.local&&i(V,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));var a=w(e.participant),o=t(b(e.participant.session_id));i(b(e.participant.session_id),(function(e){return A(e,a)?e:a})),o.filter((function(e){return!a.includes(e)})).forEach((function(n){r(h({id:e.participant.session_id,property:n}))})),a.forEach((function(n){var t=x(e.participant,[n])[0];i(h({id:e.participant.session_id,property:n}),(function(e){return A(e,t)?e:t}))}));break;case"participant-left":i(L,(function(n){return n.includes(e.participant.session_id)?[].concat(n.filter((function(n){return n!==e.participant.session_id}))):n})),r(T(e.participant.session_id)),t(b(e.participant.session_id)).forEach((function(n){r(h({id:e.participant.session_id,property:n}))})),r(b(e.participant.session_id));break;case"call-instance-destroyed":case"left-meeting":r(V);var u=t(L);Array.isArray(u)&&u.forEach((function(e){return r(T(e))})),r(L)}}))}))}}),[])),R(["waiting-participant-added","waiting-participant-updated","waiting-participant-removed"],r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset,r=n.set;e.forEach((function(e){switch(e.action){case"waiting-participant-added":r(P,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),r(j(e.participant.id),e.participant);break;case"waiting-participant-updated":r(j(e.participant.id),e.participant);break;case"waiting-participant-removed":r(P,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(j(e.participant.id))}}))}))}}),[])),t.createElement(t.Fragment,null,i)},O=function(){var e=r.useRecoilValue(V);return n.useDebugValue(e),e},B=function(){return!0},q=function(e){var t=void 0===e?{}:e,i=t.filter,a=void 0===i?B:i,o=t.ignoreLocal,u=void 0!==o&&o,l=O(),c=r.useRecoilValue(_),s=u&&c===l,d=!(null!=a&&a(c)),f=n.useState(s||d?null:c),p=f[0],v=f[1];return n.useEffect((function(){s||d||v(c)}),[d,s,c]),n.useDebugValue(p),p},U=function(e){return["blocked","off"].includes(e)},N=D({key:"daily-react-participant-ids-filtered-sorted",equals:A,get:function(e){var n=e.filter,t=e.sort;return function(e){var r=e.get;return r(L).filter((function(e){switch(n){case"local":case"owner":case"record":return r(h({id:e,property:n}));case"remote":return!r(h({id:e,property:"local"}));case"screen":var t=r(S({id:e,properties:["tracks.screenAudio.state","tracks.screenVideo.state"]})),i=t[1];return!U(t[0])||!U(i);default:return!0}})).sort((function(e,n){switch(t){case"joined_at":case"session_id":case"user_id":case"user_name":var i=r(S({id:e,properties:[t]}))[0],a=r(S({id:n,properties:[t]}))[0];if(void 0!==i||void 0!==a){if(void 0===i)return-1;if(void 0===a)return 1;if(i>a)return 1;if(i<a)return-1}return 0;default:return 0}}))}}}),W=function(e){var t=void 0===e?{}:e,i=t.filter,a=t.onActiveSpeakerChange,o=t.onParticipantJoined,u=t.onParticipantLeft,l=t.onParticipantUpdated,c=t.sort,s=r.useRecoilValue(N({filter:"string"==typeof i?i:null,sort:"string"==typeof c?c:null})),d=r.useRecoilCallback((function(e){var n=e.snapshot;return function(){return"function"!=typeof i&&"function"!=typeof c?[]:s.map((function(e){return n.getLoadable(T(e)).contents})).filter(Boolean).filter("function"==typeof i?i:function(){return!0}).sort("function"==typeof c?c:function(){return 0}).map((function(e){return e.session_id})).filter(Boolean)}}),[i,s,c]),f=n.useState([]),p=f[0],v=f[1],g=n.useCallback((function(){var e=d();A(e,p)||v(e)}),[p,d]);n.useEffect((function(){g()}),[g]),R(["participant-joined","participant-updated","active-speaker-change","participant-left"],n.useCallback((function(e){e.length&&(e.forEach((function(e){switch(e.action){case"participant-joined":null==o||o(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==a||a(e);break;case"participant-left":null==u||u(e)}})),g())}),[g,a,o,u,l]));var y="function"==typeof i||"function"==typeof c?p:s;return n.useDebugValue(y),y},z=E({key:"daily-react-screen-shares",equals:A,get:function(e){var n=e.get;return n(N({filter:"screen",sort:null})).map((function(e){return{local:n(h({id:e,property:"local"})),screenAudio:n(h({id:e,property:"tracks.screenAudio"})),screenVideo:n(h({id:e,property:"tracks.screenVideo"})),screenId:e+"-screen",session_id:e}}))}}),G=function(e){var t=void 0===e?{}:e,i=t.onError,a=t.onLocalScreenShareStarted,o=t.onLocalScreenShareStopped,u=v(),l=n.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=n.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]);k("local-screen-share-started",n.useCallback((function(){return null==a?void 0:a()}),[a])),k("local-screen-share-stopped",n.useCallback((function(){return null==o?void 0:o()}),[o])),k("nonfatal-error",n.useCallback((function(e){"screen-share-error"===e.type&&(null==i||i(e))}),[i]));var s=r.useRecoilValue(z),d={isSharingScreen:s.some((function(e){return e.local})),screens:s,startScreenShare:l,stopScreenShare:c};return n.useDebugValue(d),d},H=function(e,t){void 0===t&&(t="video");var r=C(e,"tracks."+t),i=r?c({},r,{isOff:U(r.state)}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1};return n.useDebugValue(i),i};function Q(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var r=t[n];"function"==typeof r?r(e):r&&"object"==typeof r&&(r.current=e)}}),t)}var J=["onPlayFailed","sessionId","type"],$=n.memo(n.forwardRef((function(e,r){var i=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,l=s(e,J),c=n.useRef(null),d=H(a,u),f=Q(c,r),p=null==d?void 0:d.subscribed;return n.useEffect((function(){var e=c.current;if(e&&null!=d&&d.persistentTrack){var n=function(){e.play().catch((function(n){null==i||i({sessionId:a,target:e,type:u,message:n.message,name:n.name})}))},t=function(){clearTimeout(void 0)};return e.addEventListener("canplay",n),e.addEventListener("play",t),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",n),null==e||e.removeEventListener("play",t)}}}),[null==d?void 0:d.persistentTrack,i,a,u]),t.createElement("audio",Object.assign({autoPlay:!0,ref:f},l,{"data-session-id":a,"data-audio-type":u,"data-subscribed":p}))})));$.displayName="DailyAudioTrack";var K=n.memo(n.forwardRef((function(e,i){var a=e.autoSubscribeActiveSpeaker,o=void 0!==a&&a,u=e.maxSpeakers,c=void 0===u?5:u,s=e.onPlayFailed,d=e.playLocalScreenAudio,f=void 0!==d&&d,p=v(),g=n.useState(new Array(c).fill("")),y=g[0],m=g[1],k=G().screens,b=O(),S=q({ignoreLocal:!0}),C=n.useRef(null);n.useImperativeHandle(i,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=C.current)?void 0:n.querySelector('audio[data-session-id="'+S+'"][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}}}),[S]);var A=r.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=l((function*(e){var t,r=Object.values(null!=(t=null==p?void 0:p.participants())?t:{}).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(e)){if(!p||p.isDestroyed()||!o||p.subscribeToTracksAutomatically())return;p.updateParticipant(e,{setSubscribedTracks:{audio:!0}})}m((function(t){var a;if(t.includes(e))return t;var o=function(e){return!e||!i(e)};if(t.some(o)){var u=t.findIndex(o);return t[u]=e,[].concat(t)}var l=t.findIndex((function(e){return r.some((function(n){return n.session_id===e&&U(n.tracks.audio.state)}))}));if(l>=0)return t[l]=e,[].concat(t);var c=r.filter((function(e){return t.includes(e.session_id)&&e.session_id!==S})).sort((function(e,t){var r,i,a=null!=(r=n.getLoadable(h({id:e.session_id,property:"last_active"})).contents)?r:new Date("1970-01-01"),o=null!=(i=n.getLoadable(h({id:t.session_id,property:"last_active"})).contents)?i:new Date("1970-01-01");return a>o?1:a<o?-1:0}));if(!c.length){var s=t.findIndex((function(e){return e!==S}));return t[s]=e,[].concat(t)}var d=t.indexOf(null==(a=c[0])?void 0:a.session_id);return t[d]=e,[].concat(t)}))}));return function(n){return e.apply(this,arguments)}}()}),[S,o,p]),E=n.useCallback((function(e){m((function(n){if(!n.includes(e))return n;var t=[].concat(n),r=t.indexOf(e);return t[r]="",t}))}),[]);R(["active-speaker-change","track-started","participant-left"],n.useCallback((function(e){e.forEach((function(e){switch(e.action){case"active-speaker-change":if(e.activeSpeaker.peerId===b)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":E(e.participant.session_id)}}))}),[A,b,E]),200);var D=W({filter:n.useCallback((function(e){var n;return Boolean(null==e||null==(n=e.tracks)?void 0:n.rmpAudio)}),[])});return t.createElement("div",{ref:C},y.map((function(e,n){return t.createElement($,{key:"speaker-slot-"+n,onPlayFailed:s,sessionId:e,type:"audio"})})),k.filter((function(e){return!!f||!e.local})).map((function(e){return t.createElement($,{key:e.screenId,onPlayFailed:s,sessionId:e.session_id,type:"screenAudio"})})),D.map((function(e){return t.createElement($,{key:e+"-rmp",onPlayFailed:s,sessionId:e,type:"rmpAudio"})})))})));K.displayName="DailyAudio";var X=["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"],Y=n.forwardRef((function(e,r){var i=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,l=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,g=void 0===v?{}:v,y=e.type,m=void 0===y?"video":y,k=s(e,X),b=O()===p,h="screenVideo"===m,S=b&&!h,R=n.useRef(null),A=Q(R,r),E=H(p,m),D=E.persistentTrack,w=S||h||!E.isOff,x=C(p,"tracks."+m),_=null==x?void 0:x.subscribed,V=n.useMemo((function(){if("boolean"==typeof u)return u;if(!i)return!1;if(!D)return S;var e=D.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[i,S,u,D]);return n.useEffect((function(){var e=R.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()},r=function(){e.style.transform="scale(1)"},i=function(){e.style.transform="",setTimeout((function(){e.paused&&n()}),100)},a=function(){"hidden"!==document.visibilityState&&e.paused&&n()};return e.addEventListener("canplay",t),e.addEventListener("enterpictureinpicture",r),e.addEventListener("leavepictureinpicture",i),document.addEventListener("visibilitychange",a),function(){e.removeEventListener("canplay",t),e.removeEventListener("enterpictureinpicture",r),e.removeEventListener("leavepictureinpicture",i),document.removeEventListener("visibilitychange",a)}}}),[]),n.useEffect((function(){var e=R.current;if(e&&D)return e.srcObject=new MediaStream([D]),e.load(),function(){e.srcObject=null,e.load()}}),[D,null==D?void 0:D.id]),n.useEffect((function(){var e,n=R.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=R.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]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:A,"data-local":b,"data-mirrored":V||void 0,"data-playable":w||void 0,"data-session-id":p,"data-subscribed":_,"data-video-type":m,style:c({objectFit:o,transform:V?"scale(-1, 1)":""},g,w?f:{})},k))}));Y.displayName="DailyVideo";var Z=n.createContext({refreshDevices:function(){return Promise.resolve()}}),ee=r.atom({key:"daily-react-general-camera-state",default:"idle"}),ne=r.atom({key:"daily-react-general-microphone-state",default:"idle"}),te=r.atom({key:"daily-react-camera-devices",default:[]}),re=r.atom({key:"daily-react-microphone-devices",default:[]}),ie=r.atom({key:"daily-react-speaker-devices",default:[]}),ae=r.atom({key:"daily-react-last-camera-error",default:null}),oe=function(e){var i=e.children,a=v(),o=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return l((function*(){var e,t,r,i;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,p=s.speaker,v=function(e,n,t){var r,i;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(r=null==(i=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:i.state)?r:"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((function(e){var n=e.set;n(te,(function(e){return u.filter(Boolean).map((function(n){return v(d,n,e)})).sort(g)})),n(re,(function(e){return l.filter(Boolean).map((function(n){return v(f,n,e)})).sort(g)})),n(ie,(function(e){return c.filter(Boolean).map((function(n){return v(p,n,e)})).sort(g)}))}))}catch(e){n((function(e){var n=e.set;n(ee,"not-supported"),n(ne,"not-supported")}))}}else n((function(e){var n=e.set;n(ee,"not-supported"),n(ne,"not-supported")}))}))}),[a]),u=r.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,r=e.transact_UNSTABLE;return l((function*(){var e,i,u,l,s,d,f,p,v,g,y,m,k,b;if(a){var h=yield t.getPromise(ee),S=yield t.getPromise(ne),C=a.participants();if(C.local){var R=C.local.tracks,A="prompt",E="prompt";if(navigator.permissions)try{A=(yield navigator.permissions.query({name:"camera"})).state,E=(yield navigator.permissions.query({name:"microphone"})).state}catch(e){}var D="prompt"===A&&["idle","pending"].includes(h)&&"interrupted"===R.video.state&&!R.video.persistentTrack,w=["idle","pending"].includes(h)&&!R.video.persistentTrack&&Boolean(null==(e=R.video.off)?void 0:e.byUser),x="prompt"===E&&["idle","pending"].includes(S)&&"interrupted"===R.audio.state&&!R.audio.persistentTrack,_=["idle","pending"].includes(S)&&!R.audio.persistentTrack&&Boolean(null==(i=R.audio.off)?void 0:i.byUser);null!=(u=R.audio)&&null!=(l=u.blocked)&&l.byDeviceInUse?r((function(e){var n=e.set;n(ne,"in-use"),n(re,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(s=R.audio)&&null!=(d=s.blocked)&&d.byDeviceMissing?n(ne,"not-found"):null!=(f=R.audio)&&null!=(p=f.blocked)&&p.byPermissions||"denied"===E?n(ne,"blocked"):x?n(ne,"pending"):_?n(ne,"idle"):r((function(e){var n=e.set;n(ne,"granted"),n(re,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),null!=(v=R.video)&&null!=(g=v.blocked)&&g.byDeviceInUse?r((function(e){var n=e.set;n(ee,"in-use"),n(te,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(y=R.video)&&null!=(m=y.blocked)&&m.byDeviceMissing?n(ee,"not-found"):null!=(k=R.video)&&null!=(b=k.blocked)&&b.byPermissions||"denied"===A?n(ee,"blocked"):D?n(ee,"pending"):w?n(ee,"idle"):r((function(e){var n=e.set;n(ee,"granted"),n(te,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return k("participant-updated",n.useCallback((function(e){e.participant.local&&u()}),[u])),k("available-devices-updated",o),k("selected-devices-updated",o),k("camera-error",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,r,i,a,o,u,l,c=n.set;switch(c(ae,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":c(ee,"in-use");break;case"mic-in-use":c(ne,"in-use");break;case"cam-mic-in-use":c(ee,"in-use"),c(ne,"in-use");break;case"not-found":null!=(r=e.error)&&r.missingMedia.includes("video")&&c(ee,"not-found"),null!=(i=e.error)&&i.missingMedia.includes("audio")&&c(ne,"not-found");break;case"permissions":null!=(a=e.error)&&a.blockedMedia.includes("video")&&c(ee,"blocked"),null!=(o=e.error)&&o.blockedMedia.includes("audio")&&c(ne,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(c(ee,"constraints-invalid"),c(ne,"constraints-invalid")):"none-specified"===(null==(l=e.error)?void 0:l.reason)&&(c(ee,"constraints-none-specified"),c(ne,"constraints-none-specified"));break;case"undefined-mediadevices":c(ee,"undefined-mediadevices"),c(ne,"undefined-mediadevices");break;case"unknown":default:c(ee,"unknown"),c(ne,"unknown")}}))}}),[])),k("started-camera",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(ee,"granted"),n(ne,"granted")})),u()}}),[u])),t.createElement(Z.Provider,{value:{refreshDevices:o}},i)},ue=r.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),le=function(e){var n=e.children;return k("live-streaming-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(ue,{isLiveStreaming:!0,layout:null==e?void 0:e.layout})}}),[])),k("live-streaming-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ue,(function(e){return c({},e,{isLiveStreaming:!1,layout:void 0})}))}}),[])),k("live-streaming-error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(ue,(function(n){return c({},n,{errorMsg:e.errorMsg})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(ue)}}),[])),t.createElement(t.Fragment,null,n)},ce=r.atom({key:"daily-react-meeting-state",default:"new"}),se=r.atom({key:"daily-react-meeting-error",default:null}),de=r.atom({key:"daily-react-non-fatal-error",default:null}),fe=r.atom({key:"meeting-session-data",default:{data:void 0,topology:"none"}}),pe=function(e){var n=e.children,i=v(),a=r.useRecoilCallback((function(e){var n=e.set;return function(){if(i){var e=i.meetingState();return n(ce,e),e}}}),[i]);k("loading",a),k("loaded",a),k("joining-meeting",a),k("joined-meeting",a),k("left-meeting",a),k("error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(se,e),a()}}),[a])),k("nonfatal-error",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(de,e)}}),[]));var o=r.useRecoilCallback((function(e){var n=e.set;return function(){i&&n(fe,i.meetingSessionState())}}),[i]);return k("joined-meeting",o),k("meeting-session-state-updated",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(fe,e.meetingSessionState)}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(fe)}}),[])),k("call-instance-destroyed",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.reset;n(ce),n(se),n(de),n(fe)}))}}),[])),t.createElement(t.Fragment,null,n)},ve=r.atom({key:"daily-react-topology",default:"none"}),ge=r.atom({key:"daily-react-networkQuality",default:100}),ye=r.atom({key:"daily-react-networkThreshold",default:"good"}),me=function(e){var i=e.children,a=v(),o=r.useRecoilValue(ve),u=r.useRecoilCallback((function(e){var n=e.set;return l((function*(){if(a){var e=yield a.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(ve,e.topology)}}))}),[a]);return k("joined-meeting",u),k("network-connection",r.useRecoilCallback((function(e){var n=e.set;return function(e){switch(e.event){case"connected":"peer-to-peer"===e.type&&n(ve,"peer"),"sfu"===e.type&&n(ve,"sfu")}}}),[])),k("network-quality-change",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(ge,(function(n){return n!==e.quality?e.quality:n})),t(ye,(function(n){return n!==e.threshold?e.threshold:n}))}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.reset;n(ve),n(ge),n(ye)}))}}),[])),n.useEffect((function(){a&&"none"===o&&u()}),[a,u,o]),t.createElement(t.Fragment,null,i)},ke=r.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),be=function(e){var i=e.children,a=r.useSetRecoilState(ke),o=O(),u=W({filter:"record"});return n.useEffect((function(){var e=u.length>0,n=u.includes(o||"local");a((function(t){return c({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&null!=t&&t.type||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[o,u,a]),k("recording-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var r;o&&"single-participant"===(null==(r=e.layout)?void 0:r.preset)&&e.layout.session_id!==o&&(t=!1)}n(ke,{error:!1,isLocalParticipantRecorded:t,isRecording:!0,layout:null==e?void 0:e.layout,local:null==e?void 0:e.local,recordingId:null==e?void 0:e.recordingId,recordingStartedDate:new Date,startedBy:null==e?void 0:e.startedBy,type:null==e?void 0:e.type})}}),[o])),k("recording-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ke,(function(e){return c({},e,{isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("recording-error",r.useRecoilCallback((function(e){var n=e.set;return function(){n(ke,(function(e){return c({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(ke)}}),[])),t.createElement(t.Fragment,null,i)},he=function(){var e=r.useRecoilValue(ce);return n.useDebugValue(e),e},Se=r.atom({key:"daily-react-room",default:null}),Ce=function(e){var n=e.children,i=v(),a=he(),o=r.useRecoilCallback((function(e){var n=e.set;return l((function*(){if(i&&"left-meeting"!==a){var e=yield i.room();return e&&"id"in e&&n(Se,e),e}}))}),[i,a]);return k("access-state-updated",o),k("left-meeting",r.useRecoilCallback((function(e){var n=e.reset;return function(){n(Se)}}),[])),t.createElement(t.Fragment,null,n)},Re=r.atom({key:"daily-react-transcription",default:{isTranscribing:!1,model:"general",language:"en",transcriptions:[]}}),Ae=function(e){var n=e.children;return k("transcription-started",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Re,c({error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e))}}),[])),k("transcription-stopped",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Re,(function(n){return c({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})}))}}),[])),k("transcription-error",r.useRecoilCallback((function(e){var n=e.set;return function(){n(Re,(function(e){return c({},e,{error:!0,isTranscribing:!1})}))}}),[])),k("left-meeting",r.useRecoilCallback((function(e){var n=e.set;return function(){n(Re,(function(e){return c({},e,{isTranscribing:!1})}))}}),[])),k("app-message",r.useRecoilCallback((function(e){var n=e.set;return function(e){"transcription"===(null==e?void 0:e.fromId)&&n(Re,(function(n){return c({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})}))}}),[])),t.createElement(t.Fragment,null,n)},Ee={},De=function(){return!0},we={options:Ee,shouldCreateInstance:De},xe=function(e,t){var r=void 0===t?we:t,i=r.parentElRef,o=r.options,u=void 0===o?Ee:o,s=r.shouldCreateInstance,d=void 0===s?De:s,f=n.useState(null),p=f[0],v=f[1],g=n.useRef();return n.useEffect((function(){if(("callFrame"!==e||null!==(null==i?void 0:i.current))&&d()){var n=function(){setTimeout((function(){return v(null)}),0)},t=a.getCallInstance();if(!p&&t&&!t.isDestroyed())return t.once("call-instance-destroyed",n),void v(t);if(p)A(g.current,u)||function(e){r.apply(this,arguments)}(p);else{if(!t||t.isDestroyed()){switch(e){case"callFrame":t=null!=i&&i.current?a.createFrame(i.current,c({},u)):a.createFrame(c({},u));break;case"callObject":t=a.createCallObject(c({},u))}g.current=u}v(t),t.once("call-instance-destroyed",n)}}function r(){return(r=l((function*(e){yield e.destroy()}))).apply(this,arguments)}}),[p,u,i,d,e]),p},_e=function(e){return xe("callObject",e)},Ve=["children","recoilRootProps"],Ie=function(e,t){var i=void 0===t?{}:t,a=i.onParticipantLeft,o=i.onParticipantUpdated,u=r.useRecoilValue(T(e));return R(["participant-updated","participant-left"],n.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==a||a(e)}}))}),[a,o,e])),n.useDebugValue(u),u},Le="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"),Te=r.atom({key:"cpu-load-state",default:{state:"low",reason:"none"}}),Pe=function(){var e={meetingError:r.useRecoilValue(se),nonFatalError:r.useRecoilValue(de)};return n.useDebugValue(e),e},je=r.atom({key:"daily-react-input-settings",default:null}),Me=r.atom({key:"daily-react-participant-counts",default:{hidden:0,present:0}}),Fe=r.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),Oe=function(){var e=r.useRecoilValue(Se);return n.useDebugValue(e),e},Be=r.atom({key:"daily-react-send-settings",default:null});exports.DailyAudio=K,exports.DailyAudioTrack=$,exports.DailyProvider=function(e){var i=e.children,a=e.recoilRootProps,o=void 0===a?{}:a,u=s(e,Ve),l=n.useRef({}),c=n.useCallback((function(e){if("action"in e)for(var n,t=f(null!=(r=null==(i=l.current)||null==(a=i[e.action])?void 0:a.values())?r:[]);!(n=t()).done;){var r,i,a;(0,n.value)(e)}}),[]),d=n.useCallback((function(e){e&&Object.keys(l.current).forEach((function(n){e.off(n,c),e.isDestroyed()||e.on(n,c)}))}),[c]),v="callObject"in u?u.callObject:null,y=n.useMemo((function(){return"callObject"in u?{}:u}),[u]),m=_e({options:y,shouldCreateInstance:n.useCallback((function(){return!("callObject"in u)}),[u])}),k=null!=v?v:m;n.useEffect((function(){k&&d(k)}),[k,d]);var b=n.useCallback((function(e,n,t){var r,i;l.current[e]||(l.current[e]=new Map,k&&(k.off(e,c),k.isDestroyed()||k.on(e,c))),null!=(r=l.current[e])&&r.has(t)||null==(i=l.current[e])||i.set(t,n)}),[k,c]),h=n.useCallback((function(e,n){var t,r;null==(t=l.current[e])||t.delete(n),0===(null==(r=l.current[e])?void 0:r.size)&&(null==k||k.off(e,c),delete l.current[e])}),[k,c]);return t.createElement(r.RecoilRoot,Object.assign({},o),t.createElement(p.Provider,{value:k},t.createElement(g.Provider,{value:{on:b,off:h}},t.createElement(Ce,null,t.createElement(pe,null,t.createElement(me,null,t.createElement(F,null,t.createElement(be,null,t.createElement(le,null,t.createElement(Ae,null,t.createElement(oe,null,i)))))))))))},exports.DailyVideo=Y,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,i=t.ignoreLocal,a=void 0!==i&&i,o=t.onActiveSpeakerChange,u=v(),l=r.useRecoilValue(_),c=n.useState(""),s=c[1],d=Ie(c[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&l===(null==n?void 0:n.session_id)||s(null!=l?l:"")}}),[u,a,l]),k("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),n.useDebugValue(d),d},exports.useActiveSpeakerId=q,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=v(),i=n.useCallback((function(e,n){void 0===n&&(n="*"),r&&r.sendAppMessage(e,n)}),[r]),a=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return k("app-message",a),i},exports.useAudioLevel=function(e,t){var r=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){r.current||(r.current=new n);var i=r.current;if(i){var a,o,u=i.createMediaStreamSource(new MediaStream([e]));return function(){var e=l((function*(){try{a=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){try{yield i.audioWorklet.addModule(Le),a=new AudioWorkletNode(i,"audiolevel"),o=i.createGain()}catch(e){console.error(e)}}if(a&&o){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)},o.gain.value=0;try{u.connect(a).connect(o).connect(i.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==u||u.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return H(e,"audio")},exports.useCPULoad=function(e){var t=(void 0===e?{}:e).onCPULoadChange,i=r.useRecoilValue(Te),a=v(),u=he(),c=r.useRecoilCallback((function(e){var n=e.set,t=e.snapshot;return function(){var e=l((function*(e){var r=yield t.getPromise(Te);o(r,e)||n(Te,e)}));return function(n){return e.apply(this,arguments)}}()}),[]);return n.useEffect((function(){var e=!0;if(a&&!a.isDestroyed()&&"joined-meeting"===u)return a.getCpuLoadStats().then((function(n){e&&c({state:n.cpuLoadState,reason:n.cpuLoadStateReason})})),function(){e=!1}}),[a,u,c]),k("cpu-load-change",n.useCallback((function(e){c({state:e.cpuLoadState,reason:e.cpuLoadStateReason}),null==t||t(e)}),[t,c])),n.useDebugValue(i),i},exports.useCallFrame=function(e){return xe("callFrame",e)},exports.useCallObject=_e,exports.useDaily=v,exports.useDailyError=Pe,exports.useDailyEvent=k,exports.useDevices=function(){var e=v(),t=r.useRecoilValue(ee),i=r.useRecoilValue(ne),a=r.useRecoilValue(te),o=r.useRecoilValue(re),u=r.useRecoilValue(ie),c=r.useRecoilValue(ae),s=n.useContext(Z).refreshDevices,d=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),f=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=n.useCallback(function(){var n=l((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),g=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"],y={cameraError:c,cameras:a,camState:t,currentCam:a.find((function(e){return e.selected})),currentMic:o.find((function(e){return e.selected})),currentSpeaker:u.find((function(e){return e.selected})),hasCamError:g.includes(t),hasMicError:g.includes(i),microphones:o,micState:i,refreshDevices:s,setCamera:d,setMicrophone:f,setSpeaker:p,speakers:u};return n.useDebugValue(y),y},exports.useInputSettings=function(e){var t=void 0===e?{}:e,i=t.onError,a=t.onInputSettingsUpdated,o=r.useRecoilValue(je),u=Pe().nonFatalError,l=v(),c=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(je,e)}}),[]);n.useEffect((function(){l&&l.getInputSettings().then(c)}),[l,c]),k("input-settings-updated",n.useCallback((function(e){c(e.inputSettings),null==a||a(e)}),[a,c])),k("nonfatal-error",n.useCallback((function(e){"input-settings-error"===e.type&&(null==i||i(e))}),[i]));var s=n.useCallback((function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];return null==l?void 0:l.updateInputSettings.apply(l,n)}),[l]),d={errorMsg:"input-settings-error"===(null==u?void 0:u.type)?u.errorMsg:null,inputSettings:o,updateInputSettings:s};return n.useDebugValue(d),d},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,i=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=t.onLiveStreamingUpdated,l=t.onLiveStreamingWarning,s=v(),d=r.useRecoilValue(ue);k("live-streaming-started",n.useCallback((function(e){null==a||a(e)}),[a])),k("live-streaming-stopped",n.useCallback((function(e){null==o||o(e)}),[o])),k("live-streaming-updated",n.useCallback((function(e){null==u||u(e)}),[u])),k("live-streaming-error",n.useCallback((function(e){null==i||i(e)}),[i])),k("nonfatal-error",n.useCallback((function(e){"live-streaming-warning"===e.type&&(null==l||l(e))}),[l]));var f=c({},d,{startLiveStreaming:n.useCallback((function(){s&&s.startLiveStreaming.apply(s,arguments)}),[s]),stopLiveStreaming:n.useCallback((function(){s&&s.stopLiveStreaming.apply(s,arguments)}),[s]),updateLiveStreaming:n.useCallback((function(){s&&s.updateLiveStreaming.apply(s,arguments)}),[s])});return n.useDebugValue(f),f},exports.useLocalParticipant=function(){var e=r.useRecoilValue(V),t=Ie(e);return n.useDebugValue(t),t},exports.useLocalSessionId=O,exports.useMediaTrack=H,exports.useMeetingSessionState=function(e){var t=(void 0===e?{}:e).onError,i=r.useRecoilValue(fe);k("nonfatal-error",n.useCallback((function(e){"meeting-session-data-error"===e.type&&(null==t||t(e))}),[t]));var a={data:null==i?void 0:i.data,topology:null==i?void 0:i.topology};return n.useDebugValue(a),a},exports.useMeetingState=he,exports.useNetwork=function(e){var t=void 0===e?{}:e,i=t.onNetworkConnection,a=t.onNetworkQualityChange,o=v(),u=r.useRecoilValue(ve),c=r.useRecoilValue(ge),s=r.useRecoilValue(ye);k("network-connection",n.useCallback((function(e){null==i||i(e)}),[i])),k("network-quality-change",n.useCallback((function(e){null==a||a(e)}),[a]));var d={getStats:n.useCallback(l((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:c,threshold:s,topology:u};return n.useDebugValue(d),d},exports.useParticipant=Ie,exports.useParticipantCounts=function(e){var t=(void 0===e?{}:e).onParticipantCountsUpdated,i=v(),a=r.useRecoilValue(Me),o=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Me,e)}}),[]);return k("participant-counts-updated",n.useCallback((function(e){o(e.participantCounts),null==t||t(e)}),[t,o])),n.useEffect((function(){i&&!i.isDestroyed()&&o(i.participantCounts())}),[i,o]),n.useDebugValue(a),a},exports.useParticipantIds=W,exports.useParticipantProperty=C,exports.usePermissions=function(e){var t,r,i,a,o,u,l,c,s,d=O(),f=C(null!=e?e:d,"permissions"),p="boolean"==typeof(null==f?void 0:f.canSend)?null==f?void 0:f.canSend:Boolean(null==f||null==(t=f.canSend)?void 0:t.has("audio")),v="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("video")),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("customAudio")),y="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("customVideo")),m="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")),k="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")),b={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:g,canSendCustomVideo:y,canSendScreenAudio:m,canSendScreenVideo:k,canSendVideo:v,hasPresence:null==f?void 0:f.hasPresence,permissions:f};return n.useDebugValue(b),b},exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,i=t.id,a=void 0===i?"base":i,o=t.onReceiveSettingsUpdated,u=r.useRecoilValue(Fe("base")),l=r.useRecoilValue(Fe(a)),s=v(),d=he(),f=r.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,r=n.set,i=c({},e),o=0,u=Object.entries(i);o<u.length;o++){var l=u[o],s=l[1];r(Fe(l[0]),s)}a in i||t(Fe(a))}))}}),[a]);k("receive-settings-updated",n.useCallback((function(e){f(e.receiveSettings),null==o||o(e)}),[o,f])),n.useEffect((function(){s&&!s.isDestroyed()&&s.getReceiveSettings().then(f)}),[s,f]);var p=n.useCallback((function(){if(s&&"joined-meeting"===d){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];null==s||null==s.updateReceiveSettings||s.updateReceiveSettings.apply(s,n)}}),[s,d]),g={receiveSettings:"base"===a||0===Object.keys(l).length?u:l,updateReceiveSettings:p};return n.useDebugValue(g),g},exports.useRecording=function(e){var t=void 0===e?{}:e,i=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,l=v(),s=r.useRecoilValue(ke);k("recording-started",n.useCallback((function(e){null==o||o(e)}),[o])),k("recording-stopped",n.useCallback((function(e){null==u||u(e)}),[u])),k("recording-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("recording-data",n.useCallback((function(e){null==i||i(e)}),[i]));var d=c({},s,{startRecording:n.useCallback((function(){l&&l.startRecording.apply(l,arguments)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording.apply(l,arguments)}),[l]),updateRecording:n.useCallback((function(){l&&l.updateRecording.apply(l,arguments)}),[l])});return n.useDebugValue(d),d},exports.useRoom=Oe,exports.useRoomExp=function(e){var t,i,a,o,u,l,c=(void 0===e?{}:e).onCountdown,s=r.useRecoilValue(I),d=Oe(),f=n.useState(null),p=f[0],v=f[1];n.useEffect((function(){var e,n,t,r,i,a,o,u,l,c,f,p,g=null!=(e=null!=(n=null==d||null==(t=d.tokenConfig)?void 0:t.eject_after_elapsed)?n:null==d||null==(r=d.config)?void 0:r.eject_after_elapsed)?e:0,y=null!=(i=null!=(a=null==d||null==(o=d.tokenConfig)?void 0:o.exp)?a:null==d||null==(u=d.config)?void 0:u.exp)?i:0,m=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,k=new Date(0);if(g&&s&&(k=new Date(s.getTime()+1e3*g)),m&&y){var b=new Date(1e3*y);(!k.getTime()||k.getTime()>0&&b<k)&&(k=b)}0!==k.getTime()&&v((function(e){return(null==e?void 0:e.getTime())!==k.getTime()?k:e}))}),[s,null==d||null==(t=d.config)?void 0:t.eject_after_elapsed,null==d||null==(i=d.config)?void 0:i.eject_at_room_exp,null==d||null==(a=d.config)?void 0:a.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]),n.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)),r=Math.max(0,Math.floor(n%3600/60)),i=Math.max(0,Math.floor(n%60));null==c||c({hours:t,minutes:r,seconds:i})}}),1e3);return function(){clearInterval(e)}}}),[p,c]);var g={ejectDate:p};return n.useDebugValue(g),g},exports.useScreenAudioTrack=function(e){return H(e,"screenAudio")},exports.useScreenShare=G,exports.useScreenVideoTrack=function(e){return H(e,"screenVideo")},exports.useSendSettings=function(e){var t=(void 0===e?{}:e).onSendSettingsUpdated,i=v(),a=r.useRecoilValue(Be);k("send-settings-updated",r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Be,e.sendSettings),null==t||t(e)}}),[t]));var o=r.useRecoilCallback((function(e){var n=e.set;return function(e){n(Be,e)}}),[]);n.useEffect((function(){i&&!i.isDestroyed()&&o(i.getSendSettings())}),[i,o]);var u={sendSettings:a,updateSendSettings:n.useCallback(l((function*(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];var r=yield null==i?void 0:i.updateSendSettings.apply(i,n);if(r)return o(r),r})),[i,o])};return n.useDebugValue(u),u},exports.useThrottledDailyEvent=R,exports.useTranscription=function(e){var t=void 0===e?{}:e,i=t.onTranscriptionAppData,a=t.onTranscriptionError,o=t.onTranscriptionMessage,u=t.onTranscriptionStarted,l=t.onTranscriptionStopped,s=v(),d=r.useRecoilValue(Re);k("transcription-started",n.useCallback((function(e){null==u||u(e)}),[u])),k("transcription-stopped",n.useCallback((function(e){null==l||l(e)}),[l])),k("transcription-error",n.useCallback((function(e){null==a||a(e)}),[a])),k("transcription-message",n.useCallback((function(e){null==o||o(e)}),[o])),k("app-message",n.useCallback((function(e){"transcription"===(null==e?void 0:e.fromId)&&(null==i||i(e))}),[i]));var f=c({},d,{startTranscription:n.useCallback((function(){s&&s.startTranscription.apply(s,arguments)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription.apply(s,arguments)}),[s])});return n.useDebugValue(f),f},exports.useVideoTrack=function(e){return H(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,i=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=v(),l=r.useRecoilValue(M);k("waiting-participant-added",n.useCallback((function(e){null==i||i(e)}),[i])),k("waiting-participant-removed",n.useCallback((function(e){null==a||a(e)}),[a])),k("waiting-participant-updated",n.useCallback((function(e){null==o||o(e)}),[o]));var c=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]),s={waitingParticipants:l,grantAccess:n.useCallback((function(e){c(e,!0)}),[c]),denyAccess:n.useCallback((function(e){c(e,!1)}),[c])};return n.useDebugValue(s),s}; | ||
//# sourceMappingURL=daily-react.cjs.production.min.js.map |
import { DailyCall, DailyFactoryOptions } from '@daily-co/daily-js'; | ||
import { MutableRefObject } from 'react'; | ||
declare type InstanceType = 'callFrame' | 'callObject'; | ||
export interface Props { | ||
parentEl?: HTMLElement | null; | ||
parentElRef?: MutableRefObject<HTMLElement>; | ||
options?: DailyFactoryOptions; | ||
@@ -11,3 +12,3 @@ shouldCreateInstance?(): boolean; | ||
*/ | ||
export declare const useCallInstance: (type: InstanceType, { parentEl, options, shouldCreateInstance, }?: Props) => DailyCall | null; | ||
export declare const useCallInstance: (type: InstanceType, { parentElRef, options, shouldCreateInstance, }?: Props) => DailyCall | null; | ||
export {}; |
@@ -22,5 +22,5 @@ import { DailyEventObjectNonFatalError, DailyTrackState } from '@daily-co/daily-js'; | ||
screens: ScreenShare[]; | ||
startScreenShare: (properties?: import("@daily-co/daily-js").DailyScreenCaptureOptions | import("@daily-co/daily-js").DailyStartScreenShare | undefined) => void; | ||
startScreenShare: (properties?: import("@daily-co/daily-js").DailyScreenCaptureOptions | import("@daily-co/daily-js").DailyStartScreenShare | import("@daily-co/daily-js").DailyStartScreenShareFromStream | undefined) => void; | ||
stopScreenShare: () => void; | ||
}; | ||
export {}; |
{ | ||
"version": "0.18.0", | ||
"version": "0.19.0", | ||
"license": "BSD-2-Clause", | ||
@@ -73,9 +73,7 @@ "keywords": [ | ||
"@size-limit/preset-small-lib": "^5.0.3", | ||
"@testing-library/react": "^12.1.5", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
"@testing-library/react": "^15.0.5", | ||
"@types/faker": "^5.5.9", | ||
"@types/jest": "^27.0.1", | ||
"@types/lodash.throttle": "^4.1.6", | ||
"@types/react": "^17.0.20", | ||
"@types/react-dom": "^17.0.9", | ||
"@types/react": "^18.3.1", | ||
"@typescript-eslint/eslint-plugin": "^4.22.1", | ||
@@ -91,3 +89,3 @@ "@typescript-eslint/parser": "^4.0.0", | ||
"eslint-plugin-sort-destructure-keys": "^1.4.0", | ||
"fake-mediastreamtrack": "^1.1.6", | ||
"fake-mediastreamtrack": "^1.2.0", | ||
"faker": "^5.5.3", | ||
@@ -99,4 +97,4 @@ "fs-extra": "^10.1.0", | ||
"prettier-eslint-cli": "^1.2.0", | ||
"react": "^17.0.2", | ||
"react-dom": "^17.0.2", | ||
"react": "^18.2.0", | ||
"react-dom": "^18.2.0", | ||
"recoil": "^0.7.0", | ||
@@ -107,3 +105,3 @@ "size-limit": "^5.0.3", | ||
"tslib": "^2.3.1", | ||
"typescript": "^4.4.3" | ||
"typescript": "^4.9.5" | ||
}, | ||
@@ -110,0 +108,0 @@ "dependencies": { |
import Daily, { DailyCall, DailyFactoryOptions } from '@daily-co/daily-js'; | ||
import { useEffect, useRef, useState } from 'react'; | ||
import { MutableRefObject, useEffect, useRef, useState } from 'react'; | ||
@@ -12,3 +12,3 @@ import { customDeepEqual } from '../lib/customDeepEqual'; | ||
export interface Props { | ||
parentEl?: HTMLElement | null; | ||
parentElRef?: MutableRefObject<HTMLElement>; | ||
options?: DailyFactoryOptions; | ||
@@ -29,3 +29,3 @@ shouldCreateInstance?(): boolean; | ||
{ | ||
parentEl, | ||
parentElRef, | ||
options = defaultOptions, | ||
@@ -49,3 +49,6 @@ shouldCreateInstance = defaultShouldCreateInstance, | ||
*/ | ||
if ((type === 'callFrame' && parentEl === null) || !shouldCreateInstance()) | ||
if ( | ||
(type === 'callFrame' && parentElRef?.current === null) || | ||
!shouldCreateInstance() | ||
) | ||
return; | ||
@@ -105,4 +108,4 @@ | ||
case 'callFrame': | ||
co = parentEl | ||
? Daily.createFrame(parentEl, { ...options }) | ||
co = parentElRef?.current | ||
? Daily.createFrame(parentElRef.current, { ...options }) | ||
: Daily.createFrame({ ...options }); | ||
@@ -126,5 +129,5 @@ break; | ||
*/ | ||
}, [callInstance, options, parentEl, shouldCreateInstance, type]); | ||
}, [callInstance, options, parentElRef, shouldCreateInstance, type]); | ||
return callInstance; | ||
}; |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1290994
31
12802