@daily-co/daily-react
Advanced tools
Comparing version 0.6.2 to 0.7.0
@@ -17,3 +17,25 @@ import React from 'react'; | ||
} | ||
export declare const DailyAudio: React.FC<Props>; | ||
export interface DailyAudioHandle { | ||
/** | ||
* Returns all rendered audio elements. | ||
*/ | ||
getAllAudio(): HTMLAudioElement[]; | ||
/** | ||
* Returns the audio element assigned to the current active speaker. | ||
*/ | ||
getActiveSpeakerAudio(): HTMLAudioElement | null; | ||
/** | ||
* Returns all rendered audio elements for screenAudio tracks. | ||
*/ | ||
getScreenAudio(): HTMLAudioElement[]; | ||
/** | ||
* Returns the audio track for the given sessionId. | ||
*/ | ||
getAudioBySessionId(sessionId: string): HTMLAudioElement | null; | ||
/** | ||
* Returns the screenAudio track for the given sessionId. | ||
*/ | ||
getScreenAudioBySessionId(sessionId: string): HTMLAudioElement | null; | ||
} | ||
export declare const DailyAudio: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<DailyAudioHandle>>>; | ||
export {}; |
@@ -9,3 +9,3 @@ import React from 'react'; | ||
} | ||
interface Props { | ||
interface Props extends React.AudioHTMLAttributes<HTMLAudioElement> { | ||
/** | ||
@@ -18,3 +18,3 @@ * Callback to handle failed attempt to play audio. | ||
} | ||
export declare const DailyAudioTrack: React.FC<Props>; | ||
export declare const DailyAudioTrack: React.MemoExoticComponent<React.ForwardRefExoticComponent<Props & React.RefAttributes<HTMLAudioElement>>>; | ||
export {}; |
@@ -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),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js"));function o(e,n,t,i,r,a,o){try{var c=e[a](o),u=c.value}catch(e){return void t(e)}c.done?n(u):Promise.resolve(u).then(i,r)}function c(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function c(e){o(a,i,r,c,u,"next",e)}function u(e){o(a,i,r,c,u,"throw",e)}c(void 0)}))}}function u(){return(u=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function l(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}var d=n.createContext(null),f=function(){return n.useContext(d)},p=n.createContext({on:function(){},off:function(){}}),v=0,y=function(){return v++},m=function(e,t){var i=n.useContext(p),r=i.off,a=i.on,o=n.useState(!1),c=o[0],u=o[1],l=n.useRef(0),s=n.useMemo((function(){return y()}),[]);n.useEffect((function(){if(e&&!c){if(l.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 u(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,c,r,a])},g=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(p),o=a.off,c=a.on,u=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=y(),e}),{}):((n={})[e]=y(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return c(e,n,u[e])})):c(e,n,u[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,u[e])})):o(e,u[e])}}}),[s,e,u,o,c])},k=i.atom({key:"daily-react-active-id",default:null}),b=i.atom({key:"daily-react-local-id",default:""}),h=i.atom({key:"daily-react-participants-objects",default:[]}),S=i.selectorFamily({key:"daily-react-participant",get:function(e){return function(n){var t;return null!=(t=(0,n.get)(h).find((function(n){return n.session_id===e})))?t:null}}}),R=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i,r;return r=null!=(i=(0,e.get)(h).find((function(e){return e.session_id===n})))?i:null,t.map((function(e){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(r,e)}))}}}),C=function(e){var r=e.children,a=f(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(b,e.local.session_id),t(h,Object.values(e))}))}}),[]);n.useEffect((function(){if(a){var e=setInterval((function(){var n=a.participants();"local"in n&&(o(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,o]);var c=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&o(e)}}),[a,o]);return m("started-camera",c),m("access-state-updated",c),m("joining-meeting",c),m("joined-meeting",n.useCallback((function(e){o(e.participants)}),[o])),g(["active-speaker-change","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;t(k,n),t(h,(function(e){return[].concat(e).map((function(e){return e.session_id===n?u({},e,{last_active:new Date}):e}))}));break;case"participant-joined":t(h,(function(n){return[].concat(n,[e.participant]).filter((function(e,n,t){return t.findIndex((function(n){return n.session_id===e.session_id}))==n}))}));break;case"participant-updated":t(h,(function(n){return[].concat(n).map((function(n){return n.session_id===e.participant.session_id?u({},e.participant,{last_active:n.last_active}):n}))}));break;case"participant-left":t(h,(function(n){return[].concat(n).filter((function(n){return e.participant.session_id!==n.session_id}))}))}}))}))}}),[])),m("left-meeting",i.useRecoilCallback((function(e){var n=e.reset;return function(){n(b),n(h)}}),[])),t.createElement(t.Fragment,null,r)},E=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,c=i.useRecoilValue(S(e));return g(["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])),c},A=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,c=f(),u=i.useRecoilValue(k),l=n.useState(""),s=l[1],d=E(l[0]);return n.useEffect((function(){var e;if(c){var n=null==c||null==(e=c.participants())?void 0:e.local;a&&u===(null==n?void 0:n.session_id)||s(null!=u?u:"")}}),[c,a,u]),m("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},I=function(){return i.useRecoilValue(b)||null},L=Boolean,_=function(){return 0},T=function(e){var t=void 0===e?{filter:L,sort:_}:e,r=t.filter,a=void 0===r?L:r,o=t.onActiveSpeakerChange,c=t.onParticipantJoined,u=t.onParticipantLeft,l=t.onParticipantUpdated,s=t.sort,d=void 0===s?_:s,f=i.useRecoilValue(h),p=n.useMemo((function(){var e=L;switch(a){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return e.screen};break;default:e=a}return e}),[a]),v=n.useMemo((function(){var e;switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[d],i=n[d];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=d}return e}),[d]),y=n.useMemo((function(){return f.filter(p).sort(v).map((function(e){return e.session_id})).filter(Boolean)}),[f,p,v]);return g(["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==c||c(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==u||u(e)}}))}),[o,c,u,l])),y},w=function(e){var t=void 0===e?{}:e,i=t.onLocalScreenShareStarted,r=t.onLocalScreenShareStopped,a=f(),o=n.useCallback((function(e){null==a||a.startScreenShare(e)}),[a]),c=n.useCallback((function(){null==a||a.stopScreenShare()}),[a]);m("local-screen-share-started",n.useCallback((function(){return null==i?void 0:i()}),[i])),m("local-screen-share-stopped",n.useCallback((function(){return null==r?void 0:r()}),[r]));var u=T({filter:"screen"}),l=n.useMemo((function(){return u.map((function(e){var n,t=Object.values(null!=(n=null==a||null==a.participants?void 0:a.participants())?n:{}).find((function(n){return n.session_id===e}));if(t)return{local:t.local,screenAudio:t.tracks.screenAudio,screenVideo:t.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,u]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:c}},P=function(e,n){var t=i.useRecoilValue(R({id:e,properties:Array.isArray(n)?n:[n]}));return Array.isArray(n)?t:t[0]},x=function(e,n){void 0===n&&(n="video");var t=P(e,"tracks."+n);return t?u({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}},D=function(e){var i=e.onPlayFailed,r=e.sessionId,a=e.type,o=void 0===a?"audio":a,c=n.useRef(null),u=x(r,o);return n.useEffect((function(){var e=c.current;if(e&&(null==u?void 0:u.persistentTrack)){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==i||i({sessionId:r,target:e,type:o}))}),1500)},a=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",a),e.srcObject=new MediaStream([null==u?void 0:u.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",a)}}}),[null==u?void 0:u.persistentTrack,i,r,o]),t.createElement("audio",{autoPlay:!0,"data-session-id":r,"data-audio-type":o,playsInline:!0,ref:c})},j=n.memo((function(e){var r=e.maxSpeakers,a=void 0===r?5:r,o=e.onPlayFailed,u=e.playLocalScreenAudio,l=void 0!==u&&u,s=n.useState([]),d=s[0],f=s[1],p=w().screens,v=I(),y=A({ignoreLocal:!0}),m=T({filter:n.useCallback((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)}),[])}),k=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=c((function*(e){if(m.includes(e)){var t=yield n.getPromise(h);f((function(n){var i;if(n.includes(e))return n;if(n.some((function(e){return!e}))){var r=n.findIndex((function(e){return!e}));return n[r]=e,[].concat(n)}var a=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&["blocked","off"].includes(n.tracks.audio.state)}))}));if(a>=0)return n[a]=e,[].concat(n);var o=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==(null==y?void 0:y.session_id)})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!o.length)return n[0]=e,[].concat(n);var c=n.indexOf(null==(i=o[0])?void 0:i.session_id);return n[c]=e,[].concat(n)}))}}));return function(n){return e.apply(this,arguments)}}()}),[null==y?void 0:y.session_id,m]),b=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);return g(["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===v)return;k(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&k(e.participant.session_id);break;case"participant-left":b(e.participant.session_id)}}))}),[k,v,b])),n.useEffect((function(){var e=new Array(a).fill(null);f(e)}),[a]),t.createElement(t.Fragment,null,d.map((function(e,n){return t.createElement(D,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})})),p.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(D,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})})))}));j.displayName="DailyAudio";var O=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,c=e.mirror,s=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,p=e.sessionId,v=e.style,y=void 0===v?{}:v,m=e.type,g=void 0===m?"video":m,k=l(e,["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"]),b=I()===p,h="screenVideo"===g,S=b&&!h,R=n.useRef(null),C=i||R,E=x(p,g),A=E.persistentTrack,L=S||h||!E.isOff,_=P(p,"tracks."+g+".subscribed"),T=n.useMemo((function(){if("boolean"==typeof c)return c;if(!r)return!1;if(!A)return S;var e=A.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[r,S,c,A]);return n.useEffect((function(){var e=C.current;if(e){var n=function(){e.paused&&e.play()},t=function(){e.style.transform="scale(1)"},i=function(){e.style.transform="",setTimeout((function(){e.paused&&e.play()}),100)},r=function(){"hidden"!==document.visibilityState&&e.paused&&e.play()};return e.addEventListener("canplay",n),e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",i),document.addEventListener("visibilitychange",r),function(){e.removeEventListener("canplay",n),e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",i),document.removeEventListener("visibilitychange",r)}}}),[C]),n.useEffect((function(){var e=C.current;if(e&&A)return e.srcObject=new MediaStream([A]),e.load(),function(){e.srcObject=null,e.load()}}),[C,A,null==A?void 0:A.id]),n.useEffect((function(){var e=C.current;if(s&&e){var n,t=function(){e&&(n&&cancelAnimationFrame(n),n=requestAnimationFrame((function(){if(!document.hidden){var n=null==e?void 0:e.videoWidth,t=null==e?void 0:e.videoHeight;n&&t&&s({aspectRatio:n/t,height:t,width:n})}})))};return t(),null==e||e.addEventListener("resize",t),function(){return null==e?void 0:e.removeEventListener("resize",t)}}}),[s,C,A]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:C,"data-local":b,"data-mirrored":T||void 0,"data-playable":L||void 0,"data-session-id":p,"data-subscribed":_,"data-video-type":g,style:u({objectFit:o,transform:T?"scale(-1, 1)":""},y,L?f:{})},k))}));O.displayName="DailyVideo";var M=n.createContext({refreshDevices:function(){return Promise.resolve()}}),V=i.atom({key:"daily-react-general-camera-state",default:"pending"}),B=i.atom({key:"daily-react-general-microphone-state",default:"pending"}),U=i.atom({key:"daily-react-camera-devices",default:[]}),N=i.atom({key:"daily-react-microphone-devices",default:[]}),F=i.atom({key:"daily-react-speaker-devices",default:[]}),q=i.atom({key:"daily-react-last-camera-error",default:null}),z=function(e){var r=e.children,a=f(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return c((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,c=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),u=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=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 i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},y=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(U,(function(e){return c.filter(Boolean).map((function(n){return v(d,n,e)})).sort(y)})),n(N,(function(e){return u.filter(Boolean).map((function(n){return v(f,n,e)})).sort(y)})),n(F,(function(e){return l.filter(Boolean).map((function(n){return v(p,n,e)})).sort(y)}))}))}catch(e){n((function(e){var n=e.set;n(V,"not-supported"),n(B,"not-supported")}))}}else n((function(e){var n=e.set;n(V,"not-supported"),n(B,"not-supported")}))}))}),[a]),l=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return c((function*(){var e,r,c,l,s,d,f,p,v,y,m,g;if(a){var k=yield t.getPromise(V),b=yield t.getPromise(B),h=a.participants();if(h.local){var S=h.local.tracks,R="pending"===k&&"interrupted"===S.video.state,C="pending"===b&&"interrupted"===S.audio.state;(null==(e=S.audio)||null==(r=e.blocked)?void 0:r.byDeviceInUse)?i((function(e){var n=e.set;n(B,"in-use"),n(N,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))})):(null==(c=S.audio)||null==(l=c.blocked)?void 0:l.byDeviceMissing)?n(B,"not-found"):(null==(s=S.audio)||null==(d=s.blocked)?void 0:d.byPermissions)?n(B,"blocked"):C||i((function(e){var n=e.set;n(B,"granted"),n(N,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))})),(null==(f=S.video)||null==(p=f.blocked)?void 0:p.byDeviceInUse)?i((function(e){var n=e.set;n(V,"in-use"),n(U,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"in-use"}):e}))}))})):(null==(v=S.video)||null==(y=v.blocked)?void 0:y.byDeviceMissing)?n(V,"not-found"):(null==(m=S.video)||null==(g=m.blocked)?void 0:g.byPermissions)?n(V,"blocked"):R||i((function(e){var n=e.set;n(V,"granted"),n(U,(function(e){return e.map((function(e){return e.selected?u({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return m("participant-updated",n.useCallback((function(e){e.participant.local&&l()}),[l])),m("available-devices-updated",o),m("selected-devices-updated",o),m("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,c,u,l=n.set;switch(l(q,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(V,"in-use");break;case"mic-in-use":l(B,"in-use");break;case"cam-mic-in-use":l(V,"in-use"),l(B,"in-use");break;case"not-found":(null==(i=e.error)?void 0:i.missingMedia.includes("video"))&&l(V,"not-found"),(null==(r=e.error)?void 0:r.missingMedia.includes("audio"))&&l(B,"not-found");break;case"permissions":(null==(a=e.error)?void 0:a.blockedMedia.includes("video"))&&l(V,"blocked"),(null==(o=e.error)?void 0:o.blockedMedia.includes("audio"))&&l(B,"blocked");break;case"constraints":"invalid"===(null==(c=e.error)?void 0:c.reason)?(l(V,"constraints-invalid"),l(B,"constraints-invalid")):"none-specified"===(null==(u=e.error)?void 0:u.reason)&&(l(V,"constraints-none-specified"),l(B,"constraints-none-specified"));break;case"undefined-mediadevices":l(V,"undefined-mediadevices"),l(B,"undefined-mediadevices");break;case"unknown":default:l(V,"unknown"),l(B,"unknown")}}))}}),[])),m("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(V,"granted"),n(B,"granted")})),l()}}),[l])),t.createElement(M.Provider,{value:{refreshDevices:o}},r)},W=i.atom({key:"daily-react-room",default:null}),H=function(e){var n=e.children,r=f(),a=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(r&&"left-meeting"!==r.meetingState()){var e=yield r.room();return e&&"id"in e&&n(W,e),e}}))}),[r]);return m("access-state-updated",a),t.createElement(t.Fragment,null,n)},Q=function(){return!0},G=i.atom({key:"daily-react-input-settings",default:null}),J=i.atom({key:"daily-react-input-settings-error",default:null}),$=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),K=i.atom({key:"daily-react-topology",default:"none"}),X=i.atom({key:"daily-react-networkQuality",default:100}),Y=i.atom({key:"daily-react-networkThreshold",default:"good"}),Z=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),ee=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),ne=function(){return i.useRecoilValue(W)},te=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}}),ie=i.atom({key:"daily-react-waiting-participants",default:[]}),re=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),ae=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(ie).map((function(e){return n(re(e))}))}});exports.DailyAudio=j,exports.DailyAudioTrack=D,exports.DailyProvider=function(e){var r=e.children,o=e.recoilRootProps,c=void 0===o?{}:o,u=l(e,["children","recoilRootProps"]),f=n.useState("callObject"in u?u.callObject:null),v=f[0],y=f[1],m=n.useRef({});n.useEffect((function(){var e;if("callObject"in u){var n=(null==v?void 0:v._callFrameId)!==(null==u||null==(e=u.callObject)?void 0:e._callFrameId);u.callObject?(n||!v&&u.callObject)&&y(u.callObject):y(null)}}),[v,u]);var g=n.useCallback((function(e){if("action"in e)for(var n,t=function(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 s(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)?s(e,void 0):void 0}}(e))){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(null!=(i=null==(r=m.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),k=n.useCallback((function(e){e&&Object.keys(m.current).forEach((function(n){e.off(n,g).on(n,g)}))}),[g]);n.useEffect((function(){if(!v){if("callObject"in u)return y(u.callObject),void k(u.callObject);var e=a.createCallObject(u);y(e),k(e)}}),[v,k,u]);var b=n.useCallback((function(e,n,t){var i,r;m.current[e]||(m.current[e]=new Map,v&&v.off(e,g).on(e,g)),(null==(i=m.current[e])?void 0:i.has(t))||null==(r=m.current[e])||r.set(t,n)}),[v,g]),h=n.useCallback((function(e,n){var t,i;null==(t=m.current[e])||t.delete(n),0===(null==(i=m.current[e])?void 0:i.size)&&(null==v||v.off(e,g),delete m.current[e])}),[v,g]);return t.createElement(i.RecoilRoot,Object.assign({},c),t.createElement(d.Provider,{value:v},t.createElement(p.Provider,{value:{on:b,off:h}},t.createElement(H,null,t.createElement(C,null,t.createElement(z,null,r))))))},exports.DailyVideo=O,exports.useActiveParticipant=A,exports.useActiveSpeakerId=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?Q:r,o=t.ignoreLocal,c=void 0!==o&&o,u=I(),l=i.useRecoilValue(k),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){c&&l===u||(null==a?void 0:a(l))&&f(l)}),[a,u,c,l]),d},exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=f(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return m("app-message",a),r},exports.useAudioTrack=function(e){return x(e,"audio")},exports.useDaily=f,exports.useDailyEvent=m,exports.useDevices=function(){var e=f(),t=i.useRecoilValue(V),r=i.useRecoilValue(B),a=i.useRecoilValue(U),o=i.useRecoilValue(N),u=i.useRecoilValue(F),l=i.useRecoilValue(q),s=n.useContext(M).refreshDevices,d=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),p=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=n.useCallback(function(){var n=c((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),y=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,hasCamError:y.includes(t),hasMicError:y.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:p,setSpeaker:v,speakers:u}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue(G),c=i.useRecoilValue(J),u=f(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(G,e)}}),[]);return n.useEffect((function(){u&&u.getInputSettings().then(l)}),[u,l]),m("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),m("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(J,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:c,inputSettings:o,updateInputSettings:n.useCallback((function(e){null==u||u.updateInputSettings(e)}),[u])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,c=f(),l=i.useRecoilValue($);return m("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n($,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),null==a||a(e)}}),[a])),m("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n($,(function(e){return u({},e,{isLiveStreaming:!1,layout:void 0})})),null==o||o(e)}}),[o])),m("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n($,(function(n){return u({},n,{errorMsg:e.errorMsg})})),null==r||r(e)}}),[r])),u({},l,{startLiveStreaming:n.useCallback((function(e){c&&c.startLiveStreaming(e)}),[c]),stopLiveStreaming:n.useCallback((function(){c&&c.stopLiveStreaming()}),[c]),updateLiveStreaming:n.useCallback((function(e){c&&c.updateLiveStreaming({layout:e.layout})}),[c])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(b);return E(e)},exports.useLocalSessionId=I,exports.useMediaTrack=x,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=f(),u=i.useRecoilValue(K),l=i.useRecoilValue(X),s=i.useRecoilValue(Y),d=i.useRecoilCallback((function(e){var n=e.set;return c((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(K,e.topology)}}))}),[o]),p=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(K,"peer"),"sfu"===e.type&&t(K,"sfu")}})),null==r||r(e)}}),[r]),v=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(X,(function(n){return n!==e.quality?e.quality:n})),t(Y,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return m("joined-meeting",d),m("network-connection",p),m("network-quality-change",v),n.useEffect((function(){o&&!u&&d()}),[o,d,u]),{getStats:n.useCallback(c((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:u}},exports.useParticipant=E,exports.useParticipantIds=T,exports.useParticipantProperty=P,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,c=i.useRecoilValue(Z("base")),l=i.useRecoilValue(Z(a)),s=f();m("receive-settings-updated",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=u({},e.receiveSettings),o=0,c=Object.entries(r);o<c.length;o++){var l=c[o],s=l[1];i(Z(l[0]),s)}a in r||t(Z(a))})),null==o||o(e)}}),[a,o]));var d=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===a||0===Object.keys(l).length?c:l,updateReceiveSettings:d}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,c=t.onRecordingStopped,l=f(),s=i.useRecoilValue(ee),d=i.useSetRecoilState(ee),p=I(),v=T({filter:"record"});return n.useEffect((function(){var e=v.length>0,n=v.includes(null!=p?p:"local");d((function(t){return u({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[p,v,d]),m("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;p&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==p&&(t=!1)}n(ee,{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}),null==o||o(e)}}),[p,o])),m("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ee,(function(e){return u({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),null==c||c(e)}}),[c])),m("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(ee,(function(e){return u({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),null==a||a(e)}}),[a])),m("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),u({},s,{startRecording:n.useCallback((function(e){l&&l.startRecording(e)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording()}),[l]),updateRecording:n.useCallback((function(e){l&&l.updateRecording(e)}),[l])})},exports.useRoom=ne,exports.useScreenAudioTrack=function(e){return x(e,"screenAudio")},exports.useScreenShare=w,exports.useScreenVideoTrack=function(e){return x(e,"screenVideo")},exports.useThrottledDailyEvent=g,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,c=r.onTranscriptionStarted,l=r.onTranscriptionStopped,s=f(),d=i.useRecoilValue(te),p=i.useSetRecoilState(te),v=ne();return n.useEffect((function(){var e;(null==v||null==(e=v.domainConfig)?void 0:e.enable_transcription)&&p((function(e){return u({},e,{isTranscriptionEnabled:!0})}))}),[null==v||null==(t=v.domainConfig)?void 0:t.enable_transcription,p]),m("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(te,u({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==c||c(e)}}),[c])),m("transcription-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(te,(function(n){return u({},n,{updatedBy:null==e?void 0:e.updatedBy,isTranscribing:!1})})),null==l||l(e)}}),[l])),m("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(te,(function(e){return u({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),m("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&(null==e||null==(t=e.data)?void 0:t.is_final)&&(n(te,(function(n){return u({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),u({},d,{startTranscription:n.useCallback((function(e){s&&s.startTranscription(e)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription()}),[s])})},exports.useVideoTrack=function(e){return x(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,c=f(),u=i.useRecoilValue(ae),l=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(ie,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),t(re(e.participant.id),e.participant)})),null==r||r(e)}}),[r]),s=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset;(0,n.set)(ie,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(re(e.participant.id))})),null==a||a(e)}}),[a]),d=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(re(e.participant.id),e.participant),null==o||o(e)}}),[o]);m("waiting-participant-added",l),m("waiting-participant-removed",s),m("waiting-participant-updated",d);var p=n.useCallback((function(e,n){"*"!==e?null==c||c.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==c||c.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[c]);return{waitingParticipants:u,grantAccess:n.useCallback((function(e){p(e,!0)}),[p]),denyAccess:n.useCallback((function(e){p(e,!1)}),[p])}}; | ||
"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),i=require("recoil"),r=e(require("lodash.throttle")),a=e(require("@daily-co/daily-js"));function o(e,n,t,i,r,a,o){try{var u=e[a](o),c=u.value}catch(e){return void t(e)}u.done?n(c):Promise.resolve(c).then(i,r)}function u(e){return function(){var n=this,t=arguments;return new Promise((function(i,r){var a=e.apply(n,t);function u(e){o(a,i,r,u,c,"next",e)}function c(e){o(a,i,r,u,c,"throw",e)}u(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var n=1;n<arguments.length;n++){var t=arguments[n];for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i])}return e}).apply(this,arguments)}function l(e,n){if(null==e)return{};var t,i,r={},a=Object.keys(e);for(i=0;i<a.length;i++)n.indexOf(t=a[i])>=0||(r[t]=e[t]);return r}function s(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,i=new Array(n);t<n;t++)i[t]=e[t];return i}var d=n.createContext(null),f=function(){return n.useContext(d)},v=n.createContext({on:function(){},off:function(){}}),p=0,y=function(){return p++},m=function(e,t){var i=n.useContext(v),r=i.off,a=i.on,o=n.useState(!1),u=o[0],c=o[1],l=n.useRef(0),s=n.useMemo((function(){return y()}),[]);n.useEffect((function(){if(e&&!u){if(l.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 c(!0);l.current++;var n=setTimeout((function(){l.current=0}),50);return a(e,t,s),function(){clearTimeout(n),r(e,s)}}}),[t,e,s,u,r,a])},g=function(e,t,i){void 0===i&&(i=100);var a=n.useContext(v),o=a.off,u=a.on,c=n.useMemo((function(){var n;return Array.isArray(e)?e.reduce((function(e,n){return e[n]=y(),e}),{}):((n={})[e]=y(),n)}),[e]),l=n.useRef([]),s=n.useMemo((function(){return r((function(){0!==l.current.length&&(t(l.current),l.current=[])}),i,{trailing:!0})}),[t,i]);n.useEffect((function(){if(e){var n=function(e){l.current.push(e),setTimeout(s,0)};return Array.isArray(e)?e.forEach((function(e){return u(e,n,c[e])})):u(e,n,c[e]),function(){Array.isArray(e)?e.forEach((function(e){return o(e,c[e])})):o(e,c[e])}}}),[s,e,c,o,u])},k=i.atom({key:"daily-react-active-id",default:null}),b=i.atom({key:"daily-react-local-id",default:""}),h=i.atom({key:"daily-react-participants-objects",default:[]}),S=i.selectorFamily({key:"daily-react-participant",get:function(e){return function(n){var t;return null!=(t=(0,n.get)(h).find((function(n){return n.session_id===e})))?t:null}}}),R=i.selectorFamily({key:"daily-react-participant-property",get:function(e){var n=e.id,t=e.properties;return function(e){var i,r;return r=null!=(i=(0,e.get)(h).find((function(e){return e.session_id===n})))?i:null,t.map((function(e){return function(e,n){return String(n).split(".").filter((function(e){return e.length})).reduce((function(e,n){return e&&e[n]}),e)}(r,e)}))}}}),C=function(e){var r=e.children,a=f(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(b,e.local.session_id),t(h,Object.values(e))}))}}),[]);n.useEffect((function(){if(a){var e=setInterval((function(){var n=a.participants();"local"in n&&(o(n),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[a,o]);var u=n.useCallback((function(){if(a){var e=null==a?void 0:a.participants();e.local&&o(e)}}),[a,o]);return m("started-camera",u),m("access-state-updated",u),m("joining-meeting",u),m("joined-meeting",n.useCallback((function(e){o(e.participants)}),[o])),g(["active-speaker-change","participant-joined","participant-updated","participant-left"],i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;e.forEach((function(e){switch(e.action){case"active-speaker-change":var n=e.activeSpeaker.peerId;t(k,n),t(h,(function(e){return[].concat(e).map((function(e){return e.session_id===n?c({},e,{last_active:new Date}):e}))}));break;case"participant-joined":t(h,(function(n){return[].concat(n,[e.participant]).filter((function(e,n,t){return t.findIndex((function(n){return n.session_id===e.session_id}))==n}))}));break;case"participant-updated":t(h,(function(n){return[].concat(n).map((function(n){return n.session_id===e.participant.session_id?c({},e.participant,{last_active:n.last_active}):n}))})),e.participant.local&&t(b,(function(n){return n!==e.participant.session_id?e.participant.session_id:n}));break;case"participant-left":t(h,(function(n){return[].concat(n).filter((function(n){return e.participant.session_id!==n.session_id}))}))}}))}))}}),[])),m("left-meeting",i.useRecoilCallback((function(e){var n=e.reset;return function(){n(b),n(h)}}),[])),t.createElement(t.Fragment,null,r)},A=function(){return i.useRecoilValue(b)||null},E=function(){return!0},I=function(e){var t=void 0===e?{}:e,r=t.filter,a=void 0===r?E:r,o=t.ignoreLocal,u=void 0!==o&&o,c=A(),l=i.useRecoilValue(k),s=n.useState(null),d=s[0],f=s[1];return n.useEffect((function(){u&&l===c||(null==a?void 0:a(l))&&f(l)}),[a,c,u,l]),d},w=Boolean,x=function(){return 0},L=function(e){var t=void 0===e?{filter:w,sort:x}:e,r=t.filter,a=void 0===r?w:r,o=t.onActiveSpeakerChange,u=t.onParticipantJoined,c=t.onParticipantLeft,l=t.onParticipantUpdated,s=t.sort,d=void 0===s?x:s,f=i.useRecoilValue(h),v=n.useMemo((function(){var e=w;switch(a){case"local":e=function(e){return e.local};break;case"owner":e=function(e){return e.owner};break;case"record":e=function(e){return e.record};break;case"remote":e=function(e){return!e.local};break;case"screen":e=function(e){return e.screen};break;default:e=a}return e}),[a]),p=n.useMemo((function(){var e;switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,n){var t=e[d],i=n[d];if(void 0!==t||void 0!==i){if(void 0===t)return-1;if(void 0===i)return 1;if(t>i)return 1;if(t<i)return-1}return 0};break;default:e=d}return e}),[d]),y=n.useMemo((function(){return f.filter(v).sort(p).map((function(e){return e.session_id})).filter(Boolean)}),[f,v,p]);return g(["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==u||u(e);break;case"participant-updated":null==l||l(e);break;case"active-speaker-change":null==o||o(e);break;case"participant-left":null==c||c(e)}}))}),[o,u,c,l])),y},T=function(e){var t=void 0===e?{}:e,i=t.onLocalScreenShareStarted,r=t.onLocalScreenShareStopped,a=f(),o=n.useCallback((function(e){null==a||a.startScreenShare(e)}),[a]),u=n.useCallback((function(){null==a||a.stopScreenShare()}),[a]);m("local-screen-share-started",n.useCallback((function(){return null==i?void 0:i()}),[i])),m("local-screen-share-stopped",n.useCallback((function(){return null==r?void 0:r()}),[r]));var c=L({filter:"screen"}),l=n.useMemo((function(){return c.map((function(e){var n,t=Object.values(null!=(n=null==a||null==a.participants?void 0:a.participants())?n:{}).find((function(n){return n.session_id===e}));if(t)return{local:t.local,screenAudio:t.tracks.screenAudio,screenVideo:t.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[a,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:o,stopScreenShare:u}},_=function(e,n){var t=i.useRecoilValue(R({id:e,properties:Array.isArray(n)?n:[n]}));return Array.isArray(n)?t:t[0]},P=function(e,n){void 0===n&&(n="video");var t=_(e,"tracks."+n);return t?c({},t,{isOff:"blocked"===t.state||"off"===t.state}):{isOff:!0,persistentTrack:void 0,state:"off",subscribed:!1}};function D(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n.useCallback((function(e){for(var n=0;n<t.length;n++){var i=t[n];"function"==typeof i?i(e):i&&"object"==typeof i&&(i.current=e)}}),t)}var M=n.memo(n.forwardRef((function(e,i){var r=e.onPlayFailed,a=e.sessionId,o=e.type,u=void 0===o?"audio":o,c=l(e,["onPlayFailed","sessionId","type"]),s=n.useRef(null),d=P(a,u),f=D(s,i);return n.useEffect((function(){var e=s.current;if(e&&(null==d?void 0:d.persistentTrack)){var n,t=function(){n=setTimeout((function(){(e.readyState!==e.HAVE_ENOUGH_DATA||e.paused)&&(null==r||r({sessionId:a,target:e,type:u}))}),1500)},i=function(){clearTimeout(n)};return e.addEventListener("canplay",t),e.addEventListener("play",i),e.srcObject=new MediaStream([null==d?void 0:d.persistentTrack]),function(){null==e||e.removeEventListener("canplay",t),null==e||e.removeEventListener("play",i)}}}),[null==d?void 0:d.persistentTrack,r,a,u]),n.useMemo((function(){return t.createElement("audio",Object.assign({autoPlay:!0,playsInline:!0,ref:f},c,{"data-session-id":a,"data-audio-type":u}))}),[f,c,a,u])})));M.displayName="DailyAudioTrack";var j=n.memo(n.forwardRef((function(e,r){var a=e.maxSpeakers,o=e.onPlayFailed,c=e.playLocalScreenAudio,l=void 0!==c&&c,s=n.useState(new Array(void 0===a?5:a).fill("")),d=s[0],f=s[1],v=T().screens,p=A(),y=I({ignoreLocal:!0}),m=n.useRef(null);n.useImperativeHandle(r,(function(){return{getActiveSpeakerAudio:function(){var e,n;return null!=(e=null==(n=m.current)?void 0:n.querySelector('audio[data-session-id="'+y+'"][data-audio-type="audio"]'))?e:null},getAllAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll("audio"))?e:[])},getAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="audio"]'))?n:null},getScreenAudio:function(){var e,n;return Array.from(null!=(e=null==(n=m.current)?void 0:n.querySelectorAll('audio[data-audio-type="screenAudio"]'))?e:[])},getScreenAudioBySessionId:function(e){var n,t;return null!=(n=null==(t=m.current)?void 0:t.querySelector('audio[data-session-id="'+e+'"][data-audio-type="screenAudio"]'))?n:null}}}),[y]);var k=L({filter:n.useCallback((function(e){return!e.local&&Boolean(e.tracks.audio.subscribed)}),[])}),b=i.useRecoilCallback((function(e){var n=e.snapshot;return function(){var e=u((function*(e){if(k.includes(e)){var t=(yield n.getPromise(h)).filter((function(e){return k.includes(e.session_id)}));f((function(n){var i;if(n.includes(e))return n;var r=function(e){return!e||!k.includes(e)};if(n.some(r)){var a=n.findIndex(r);return n[a]=e,[].concat(n)}var o=n.findIndex((function(e){return t.some((function(n){return n.session_id===e&&["blocked","off"].includes(n.tracks.audio.state)}))}));if(o>=0)return n[o]=e,[].concat(n);var u=t.filter((function(e){return n.includes(e.session_id)&&e.session_id!==y})).sort((function(e,n){var t,i,r=null!=(t=null==e?void 0:e.last_active)?t:new Date("1970-01-01"),a=null!=(i=null==n?void 0:n.last_active)?i:new Date("1970-01-01");return r>a?1:r<a?-1:0}));if(!u.length){var c=n.findIndex((function(e){return e!==y}));return n[c]=e,[].concat(n)}var l=n.indexOf(null==(i=u[0])?void 0:i.session_id);return n[l]=e,[].concat(n)}))}}));return function(n){return e.apply(this,arguments)}}()}),[y,k]),S=n.useCallback((function(e){f((function(n){if(!n.includes(e))return n;var t=[].concat(n),i=t.indexOf(e);return t[i]="",t}))}),[]);g(["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===p)return;b(e.activeSpeaker.peerId);break;case"track-started":"audio"===e.track.kind&&e.participant&&!e.participant.local&&b(e.participant.session_id);break;case"participant-left":S(e.participant.session_id)}}))}),[b,p,S]));var R=n.useMemo((function(){return d.map((function(e,n){return t.createElement(M,{key:"speaker-slot-"+n,onPlayFailed:o,sessionId:e,type:"audio"})}))}),[o,d]),C=n.useMemo((function(){return v.filter((function(e){return!!l||!e.local})).map((function(e){return t.createElement(M,{key:e.screenId,onPlayFailed:o,sessionId:e.session_id,type:"screenAudio"})}))}),[o,l,v]);return t.createElement("div",{ref:m},R,C)})));j.displayName="DailyAudio";var O=n.forwardRef((function(e,i){var r=e.automirror,a=e.fit,o=void 0===a?"contain":a,u=e.mirror,s=e.onResize,d=e.playableStyle,f=void 0===d?{}:d,v=e.sessionId,p=e.style,y=void 0===p?{}:p,m=e.type,g=void 0===m?"video":m,k=l(e,["automirror","fit","mirror","onResize","playableStyle","sessionId","style","type"]),b=A()===v,h="screenVideo"===g,S=b&&!h,R=n.useRef(null),C=D(R,i),E=P(v,g),I=E.persistentTrack,w=S||h||!E.isOff,x=_(v,"tracks."+g+".subscribed"),L=n.useMemo((function(){if("boolean"==typeof u)return u;if(!r)return!1;if(!I)return S;var e=I.getSettings();return"facingMode"in e?S&&"user"===e.facingMode:S}),[r,S,u,I]);return n.useEffect((function(){var e=R.current;if(e){var n=function(){e.paused&&e.play()},t=function(){e.style.transform="scale(1)"},i=function(){e.style.transform="",setTimeout((function(){e.paused&&e.play()}),100)},r=function(){"hidden"!==document.visibilityState&&e.paused&&e.play()};return e.addEventListener("canplay",n),e.addEventListener("enterpictureinpicture",t),e.addEventListener("leavepictureinpicture",i),document.addEventListener("visibilitychange",r),function(){e.removeEventListener("canplay",n),e.removeEventListener("enterpictureinpicture",t),e.removeEventListener("leavepictureinpicture",i),document.removeEventListener("visibilitychange",r)}}}),[]),n.useEffect((function(){var e=R.current;if(e&&I)return e.srcObject=new MediaStream([I]),e.load(),function(){e.srcObject=null,e.load()}}),[I,null==I?void 0:I.id]),n.useEffect((function(){var e=R.current;if(s&&e){var n,t=function(){e&&(n&&cancelAnimationFrame(n),n=requestAnimationFrame((function(){if(!document.hidden){var n=null==e?void 0:e.videoWidth,t=null==e?void 0:e.videoHeight;n&&t&&s({aspectRatio:n/t,height:t,width:n})}})))};return t(),null==e||e.addEventListener("resize",t),function(){return null==e?void 0:e.removeEventListener("resize",t)}}}),[s,I]),t.createElement("video",Object.assign({autoPlay:!0,muted:!0,playsInline:!0,ref:C,"data-local":b,"data-mirrored":L||void 0,"data-playable":w||void 0,"data-session-id":v,"data-subscribed":x,"data-video-type":g,style:c({objectFit:o,transform:L?"scale(-1, 1)":""},y,w?f:{})},k))}));O.displayName="DailyVideo";var V=n.createContext({refreshDevices:function(){return Promise.resolve()}}),B=i.atom({key:"daily-react-general-camera-state",default:"idle"}),U=i.atom({key:"daily-react-general-microphone-state",default:"idle"}),F=i.atom({key:"daily-react-camera-devices",default:[]}),N=i.atom({key:"daily-react-microphone-devices",default:[]}),q=i.atom({key:"daily-react-speaker-devices",default:[]}),W=i.atom({key:"daily-react-last-camera-error",default:null}),z=function(e){var r=e.children,a=f(),o=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return u((function*(){var e,t,i,r;if(void 0!==(null==(e=navigator)||null==(t=e.mediaDevices)?void 0:t.getUserMedia)&&void 0!==(null==(i=navigator)||null==(r=i.mediaDevices)?void 0:r.enumerateDevices)){if(a)try{var o=(yield a.enumerateDevices()).devices,u=o.filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),c=o.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),l=o.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),s=yield a.getInputDevices(),d=s.camera,f=s.mic,v=s.speaker,p=function(e,n,t){var i,r;return{device:n,selected:"deviceId"in e&&n.deviceId===e.deviceId,state:null!=(i=null==(r=t.find((function(e){return e.device.deviceId===n.deviceId})))?void 0:r.state)?i:"granted"}},y=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(F,(function(e){return u.filter(Boolean).map((function(n){return p(d,n,e)})).sort(y)})),n(N,(function(e){return c.filter(Boolean).map((function(n){return p(f,n,e)})).sort(y)})),n(q,(function(e){return l.filter(Boolean).map((function(n){return p(v,n,e)})).sort(y)}))}))}catch(e){n((function(e){var n=e.set;n(B,"not-supported"),n(U,"not-supported")}))}}else n((function(e){var n=e.set;n(B,"not-supported"),n(U,"not-supported")}))}))}),[a]),l=i.useRecoilCallback((function(e){var n=e.set,t=e.snapshot,i=e.transact_UNSTABLE;return u((function*(){var e,r,u,l,s,d,f,v,p,y,m,g,k,b;if(a){var h=yield t.getPromise(B),S=yield t.getPromise(U),R=a.participants();if(R.local){var C=R.local.tracks,A=["idle","pending"].includes(h)&&"interrupted"===C.video.state&&!C.video.persistentTrack,E=!C.video.persistentTrack&&Boolean(null==(e=C.video.off)?void 0:e.byUser),I=["idle","pending"].includes(S)&&"interrupted"===C.audio.state&&!C.audio.persistentTrack,w=!C.audio.persistentTrack&&Boolean(null==(r=C.audio.off)?void 0:r.byUser);(null==(u=C.audio)||null==(l=u.blocked)?void 0:l.byDeviceInUse)?i((function(e){var n=e.set;n(U,"in-use"),n(N,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):(null==(s=C.audio)||null==(d=s.blocked)?void 0:d.byDeviceMissing)?n(U,"not-found"):(null==(f=C.audio)||null==(v=f.blocked)?void 0:v.byPermissions)?n(U,"blocked"):I?n(U,"pending"):w?n(U,"idle"):i((function(e){var n=e.set;n(U,"granted"),n(N,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),(null==(p=C.video)||null==(y=p.blocked)?void 0:y.byDeviceInUse)?i((function(e){var n=e.set;n(B,"in-use"),n(F,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):(null==(m=C.video)||null==(g=m.blocked)?void 0:g.byDeviceMissing)?n(B,"not-found"):(null==(k=C.video)||null==(b=k.blocked)?void 0:b.byPermissions)?n(B,"blocked"):A?n(B,"pending"):E?n(B,"idle"):i((function(e){var n=e.set;n(B,"granted"),n(F,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),o()}}}))}),[a,o]);return m("participant-updated",n.useCallback((function(e){e.participant.local&&l()}),[l])),m("available-devices-updated",o),m("selected-devices-updated",o),m("camera-error",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t,i,r,a,o,u,c,l=n.set;switch(l(W,e.error),null==(t=e.error)?void 0:t.type){case"cam-in-use":l(B,"in-use");break;case"mic-in-use":l(U,"in-use");break;case"cam-mic-in-use":l(B,"in-use"),l(U,"in-use");break;case"not-found":(null==(i=e.error)?void 0:i.missingMedia.includes("video"))&&l(B,"not-found"),(null==(r=e.error)?void 0:r.missingMedia.includes("audio"))&&l(U,"not-found");break;case"permissions":(null==(a=e.error)?void 0:a.blockedMedia.includes("video"))&&l(B,"blocked"),(null==(o=e.error)?void 0:o.blockedMedia.includes("audio"))&&l(U,"blocked");break;case"constraints":"invalid"===(null==(u=e.error)?void 0:u.reason)?(l(B,"constraints-invalid"),l(U,"constraints-invalid")):"none-specified"===(null==(c=e.error)?void 0:c.reason)&&(l(B,"constraints-none-specified"),l(U,"constraints-none-specified"));break;case"undefined-mediadevices":l(B,"undefined-mediadevices"),l(U,"undefined-mediadevices");break;case"unknown":default:l(B,"unknown"),l(U,"unknown")}}))}}),[])),m("started-camera",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(){n((function(e){var n=e.set;n(B,"granted"),n(U,"granted")})),l()}}),[l])),t.createElement(V.Provider,{value:{refreshDevices:o}},r)},H=i.atom({key:"daily-react-room",default:null}),G=function(e){var n=e.children,r=f(),a=i.useRecoilCallback((function(e){var n=e.set;return u((function*(){if(r&&"left-meeting"!==r.meetingState()){var e=yield r.room();return e&&"id"in e&&n(H,e),e}}))}),[r]);return m("access-state-updated",a),t.createElement(t.Fragment,null,n)},Q=function(e,t){var r=void 0===t?{}:t,a=r.onParticipantLeft,o=r.onParticipantUpdated,u=i.useRecoilValue(S(e));return g(["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])),u},J="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"),$=i.atom({key:"daily-react-input-settings",default:null}),K=i.atom({key:"daily-react-input-settings-error",default:null}),X=i.atom({key:"daily-react-live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),Y=i.atom({key:"daily-react-topology",default:"none"}),Z=i.atom({key:"daily-react-networkQuality",default:100}),ee=i.atom({key:"daily-react-networkThreshold",default:"good"}),ne=i.atomFamily({key:"daily-react-participant-receive-settings",default:{}}),te=i.atom({key:"daily-react-recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),ie=function(){return i.useRecoilValue(H)},re=i.atom({key:"daily-react-transcription",default:{isTranscriptionEnabled:!1,isTranscribing:!1,model:"general",language:"en",transcriptions:[]}}),ae=i.atom({key:"daily-react-waiting-participants",default:[]}),oe=i.atomFamily({key:"daily-react-waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),ue=i.selector({key:"daily-react-waitingParticipantsSelector",get:function(e){var n=e.get;return n(ae).map((function(e){return n(oe(e))}))}});exports.DailyAudio=j,exports.DailyAudioTrack=M,exports.DailyProvider=function(e){var r=e.children,o=e.recoilRootProps,u=void 0===o?{}:o,c=l(e,["children","recoilRootProps"]),f=n.useState("callObject"in c?c.callObject:null),p=f[0],y=f[1],m=n.useRef({});n.useEffect((function(){var e;if("callObject"in c){var n=(null==p?void 0:p._callFrameId)!==(null==c||null==(e=c.callObject)?void 0:e._callFrameId);c.callObject?(n||!p&&c.callObject)&&y(c.callObject):y(null)}}),[p,c]);var g=n.useCallback((function(e){if("action"in e)for(var n,t=function(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 s(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)?s(e,void 0):void 0}}(e))){t&&(e=t);var i=0;return function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(null!=(i=null==(r=m.current)||null==(a=r[e.action])?void 0:a.values())?i:[]);!(n=t()).done;){var i,r,a;(0,n.value)(e)}}),[]),k=n.useCallback((function(e){e&&Object.keys(m.current).forEach((function(n){e.off(n,g).on(n,g)}))}),[g]);n.useEffect((function(){if(!p){if("callObject"in c)return y(c.callObject),void k(c.callObject);var e=a.createCallObject(c);y(e),k(e)}}),[p,k,c]);var b=n.useCallback((function(e,n,t){var i,r;m.current[e]||(m.current[e]=new Map,p&&p.off(e,g).on(e,g)),(null==(i=m.current[e])?void 0:i.has(t))||null==(r=m.current[e])||r.set(t,n)}),[p,g]),h=n.useCallback((function(e,n){var t,i;null==(t=m.current[e])||t.delete(n),0===(null==(i=m.current[e])?void 0:i.size)&&(null==p||p.off(e,g),delete m.current[e])}),[p,g]);return t.createElement(i.RecoilRoot,Object.assign({},u),t.createElement(d.Provider,{value:p},t.createElement(v.Provider,{value:{on:b,off:h}},t.createElement(G,null,t.createElement(C,null,t.createElement(z,null,r))))))},exports.DailyVideo=O,exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,a=void 0!==r&&r,o=t.onActiveSpeakerChange,u=f(),c=i.useRecoilValue(k),l=n.useState(""),s=l[1],d=Q(l[0]);return n.useEffect((function(){var e;if(u){var n=null==u||null==(e=u.participants())?void 0:e.local;a&&c===(null==n?void 0:n.session_id)||s(null!=c?c:"")}}),[u,a,c]),m("active-speaker-change",n.useCallback((function(e){null==o||o(e)}),[o])),d},exports.useActiveSpeakerId=I,exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,i=f(),r=n.useCallback((function(e,n){void 0===n&&(n="*"),i&&i.sendAppMessage(e,n)}),[i]),a=n.useCallback((function(e){null==t||t(e,r)}),[t,r]);return m("app-message",a),r},exports.useAudioLevel=function(e,t){var i=n.useRef();n.useEffect((function(){if(e){var n="undefined"!=typeof AudioContext?AudioContext:void 0!==window.webkitAudioContext?window.webkitAudioContext:null;if(n){i.current||(i.current=new n);var r=i.current;if(r){var a,o=r.createMediaStreamSource(new MediaStream([e]));return function(){var e=u((function*(){try{a=new AudioWorkletNode(r,"audiolevel")}catch(e){try{yield r.audioWorklet.addModule(J),a=new AudioWorkletNode(r,"audiolevel")}catch(e){console.error(e)}}if(a){a.port.onmessage=function(e){var n=0;e.data.volume&&(n=e.data.volume),a&&t(n)};try{o.connect(a).connect(r.destination)}catch(e){console.warn(e)}}}));return function(){return e.apply(this,arguments)}}()(),function(){var e;null==(e=a)||e.disconnect(),a=null,null==o||o.disconnect()}}}}}),[t,e])},exports.useAudioTrack=function(e){return P(e,"audio")},exports.useDaily=f,exports.useDailyEvent=m,exports.useDevices=function(){var e=f(),t=i.useRecoilValue(B),r=i.useRecoilValue(U),a=i.useRecoilValue(F),o=i.useRecoilValue(N),c=i.useRecoilValue(q),l=i.useRecoilValue(W),s=n.useContext(V).refreshDevices,d=n.useCallback(function(){var n=u((function*(n){yield null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),v=n.useCallback(function(){var n=u((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=u((function*(n){yield null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n})}));return function(e){return n.apply(this,arguments)}}(),[e]),y=["blocked","in-use","not-found","constraints-invalid","constraints-none-specified","undefined-mediadevices","unknown"];return{cameraError:l,cameras:a,camState:t,hasCamError:y.includes(t),hasMicError:y.includes(r),microphones:o,micState:r,refreshDevices:s,setCamera:d,setMicrophone:v,setSpeaker:p,speakers:c}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,a=t.onInputSettingsUpdated,o=i.useRecoilValue($),u=i.useRecoilValue(K),c=f(),l=i.useRecoilCallback((function(e){var n=e.set;return function(e){n($,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),m("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),null==a||a(e)}),[a,l])),m("nonfatal-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){"input-settings-error"===e.type&&(n(K,e.errorMsg),null==r||r(e))}}),[r])),{errorMsg:u,inputSettings:o,updateInputSettings:n.useCallback((function(e){null==c||c.updateInputSettings(e)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,a=t.onLiveStreamingStarted,o=t.onLiveStreamingStopped,u=f(),l=i.useRecoilValue(X);return m("live-streaming-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(X,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),null==a||a(e)}}),[a])),m("live-streaming-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(X,(function(e){return c({},e,{isLiveStreaming:!1,layout:void 0})})),null==o||o(e)}}),[o])),m("live-streaming-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(X,(function(n){return c({},n,{errorMsg:e.errorMsg})})),null==r||r(e)}}),[r])),c({},l,{startLiveStreaming:n.useCallback((function(e){u&&u.startLiveStreaming(e)}),[u]),stopLiveStreaming:n.useCallback((function(){u&&u.stopLiveStreaming()}),[u]),updateLiveStreaming:n.useCallback((function(e){u&&u.updateLiveStreaming({layout:e.layout})}),[u])})},exports.useLocalParticipant=function(){var e=i.useRecoilValue(b);return Q(e)},exports.useLocalSessionId=A,exports.useMediaTrack=P,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,a=t.onNetworkQualityChange,o=f(),c=i.useRecoilValue(Y),l=i.useRecoilValue(Z),s=i.useRecoilValue(ee),d=i.useRecoilCallback((function(e){var n=e.set;return u((function*(){if(o){var e=yield o.getNetworkTopology();e&&"none"!==(null==e?void 0:e.topology)&&n(Y,e.topology)}}))}),[o]),v=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&t(Y,"peer"),"sfu"===e.type&&t(Y,"sfu")}})),null==r||r(e)}}),[r]),p=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(Z,(function(n){return n!==e.quality?e.quality:n})),t(ee,(function(n){return n!==e.threshold?e.threshold:n}))})),null==a||a(e)}}),[a]);return m("joined-meeting",d),m("network-connection",v),m("network-quality-change",p),n.useEffect((function(){o&&!c&&d()}),[o,d,c]),{getStats:n.useCallback(u((function*(){var e=yield null==o?void 0:o.getNetworkStats();return null==e?void 0:e.stats})),[o]),quality:l,threshold:s,topology:c}},exports.useParticipant=Q,exports.useParticipantIds=L,exports.useParticipantProperty=_,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,a=void 0===r?"base":r,o=t.onReceiveSettingsUpdated,u=i.useRecoilValue(ne("base")),l=i.useRecoilValue(ne(a)),s=f();m("receive-settings-updated",i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){for(var t=n.reset,i=n.set,r=c({},e.receiveSettings),o=0,u=Object.entries(r);o<u.length;o++){var l=u[o],s=l[1];i(ne(l[0]),s)}a in r||t(ne(a))})),null==o||o(e)}}),[a,o]));var d=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===a||0===Object.keys(l).length?u:l,updateReceiveSettings:d}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,a=t.onRecordingError,o=t.onRecordingStarted,u=t.onRecordingStopped,l=f(),s=i.useRecoilValue(te),d=i.useSetRecoilState(te),v=A(),p=L({filter:"record"});return n.useEffect((function(){var e=p.length>0,n=p.includes(null!=v?v:"local");d((function(t){return c({},t,{isLocalParticipantRecorded:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isLocalParticipantRecorded:e,isRecording:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)?t.isRecording:e,local:"local"!==(null==t?void 0:t.type)&&(null==t?void 0:t.type)||!e?null==t?void 0:t.local:n,type:e?"local":null==t?void 0:t.type})}))}),[v,p,d]),m("recording-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t=!0;switch(e.type){case"cloud-beta":case"cloud":var i;v&&"single-participant"===(null==(i=e.layout)?void 0:i.preset)&&e.layout.session_id!==v&&(t=!1)}n(te,{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}),null==o||o(e)}}),[v,o])),m("recording-stopped",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(te,(function(e){return c({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),null==u||u(e)}}),[u])),m("recording-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(te,(function(e){return c({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),null==a||a(e)}}),[a])),m("recording-data",n.useCallback((function(e){null==r||r(e)}),[r])),c({},s,{startRecording:n.useCallback((function(e){l&&l.startRecording(e)}),[l]),stopRecording:n.useCallback((function(){l&&l.stopRecording()}),[l]),updateRecording:n.useCallback((function(e){l&&l.updateRecording(e)}),[l])})},exports.useRoom=ie,exports.useScreenAudioTrack=function(e){return P(e,"screenAudio")},exports.useScreenShare=T,exports.useScreenVideoTrack=function(e){return P(e,"screenVideo")},exports.useThrottledDailyEvent=g,exports.useTranscription=function(e){var t,r=void 0===e?{}:e,a=r.onTranscriptionAppData,o=r.onTranscriptionError,u=r.onTranscriptionStarted,l=r.onTranscriptionStopped,s=f(),d=i.useRecoilValue(re),v=i.useSetRecoilState(re),p=ie();return n.useEffect((function(){var e;(null==p||null==(e=p.domainConfig)?void 0:e.enable_transcription)&&v((function(e){return c({},e,{isTranscriptionEnabled:!0})}))}),[null==p||null==(t=p.domainConfig)?void 0:t.enable_transcription,v]),m("transcription-started",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(re,c({isTranscriptionEnabled:!0,error:!1,isTranscribing:!0,transcriptionStartDate:new Date,transcriptions:[]},e)),null==u||u(e)}}),[u])),m("transcription-stopped",i.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})})),null==l||l(e)}}),[l])),m("transcription-error",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(re,(function(e){return c({},e,{error:!0,isTranscribing:!1})})),null==o||o(e)}}),[o])),m("app-message",i.useRecoilCallback((function(e){var n=e.set;return function(e){var t;"transcription"===(null==e?void 0:e.fromId)&&(null==e||null==(t=e.data)?void 0:t.is_final)&&(n(re,(function(n){return c({},n,{isTranscribing:!0,transcriptions:[].concat(n.transcriptions,[e.data])})})),null==a||a(e))}}),[a])),c({},d,{startTranscription:n.useCallback((function(e){s&&s.startTranscription(e)}),[s]),stopTranscription:n.useCallback((function(){s&&s.stopTranscription()}),[s])})},exports.useVideoTrack=function(e){return P(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,a=t.onWaitingParticipantRemoved,o=t.onWaitingParticipantUpdated,u=f(),c=i.useRecoilValue(ue),l=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.set;t(ae,(function(n){return n.includes(e.participant.id)?n:[].concat(n,[e.participant.id])})),t(oe(e.participant.id),e.participant)})),null==r||r(e)}}),[r]),s=i.useRecoilCallback((function(e){var n=e.transact_UNSTABLE;return function(e){n((function(n){var t=n.reset;(0,n.set)(ae,(function(n){return n.filter((function(n){return n!==e.participant.id}))})),t(oe(e.participant.id))})),null==a||a(e)}}),[a]),d=i.useRecoilCallback((function(e){var n=e.set;return function(e){n(oe(e.participant.id),e.participant),null==o||o(e)}}),[o]);m("waiting-participant-added",l),m("waiting-participant-removed",s),m("waiting-participant-updated",d);var v=n.useCallback((function(e,n){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:n}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:n}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){v(e,!0)}),[v]),denyAccess:n.useCallback((function(e){v(e,!1)}),[v])}}; | ||
//# sourceMappingURL=daily-react.cjs.production.min.js.map |
import React from 'react'; | ||
declare type GeneralState = 'pending' | 'not-supported' | 'granted' | 'blocked' | 'in-use' | 'not-found' | 'constraints-invalid' | 'constraints-none-specified' | 'undefined-mediadevices' | 'unknown'; | ||
declare type GeneralState = 'idle' | 'pending' | 'not-supported' | 'granted' | 'blocked' | 'in-use' | 'not-found' | 'constraints-invalid' | 'constraints-none-specified' | 'undefined-mediadevices' | 'unknown'; | ||
declare type DeviceState = 'granted' | 'in-use'; | ||
@@ -4,0 +4,0 @@ export interface StatefulDevice { |
@@ -16,3 +16,3 @@ /** | ||
*/ | ||
camState: "undefined-mediadevices" | "not-found" | "unknown" | "pending" | "not-supported" | "granted" | "blocked" | "in-use" | "constraints-invalid" | "constraints-none-specified"; | ||
camState: "undefined-mediadevices" | "not-found" | "unknown" | "idle" | "pending" | "not-supported" | "granted" | "blocked" | "in-use" | "constraints-invalid" | "constraints-none-specified"; | ||
/** | ||
@@ -33,3 +33,3 @@ * Indicates that there's an issue with camera devices. | ||
*/ | ||
micState: "undefined-mediadevices" | "not-found" | "unknown" | "pending" | "not-supported" | "granted" | "blocked" | "in-use" | "constraints-invalid" | "constraints-none-specified"; | ||
micState: "undefined-mediadevices" | "not-found" | "unknown" | "idle" | "pending" | "not-supported" | "granted" | "blocked" | "in-use" | "constraints-invalid" | "constraints-none-specified"; | ||
/** | ||
@@ -36,0 +36,0 @@ * Refreshes the list of devices using [enumerateDevices](https://docs.daily.co/reference/daily-js/instance-methods/enumerate-devices). |
@@ -10,2 +10,3 @@ export { DailyAudio } from './components/DailyAudio'; | ||
export { useAppMessage } from './hooks/useAppMessage'; | ||
export { useAudioLevel } from './hooks/useAudioLevel'; | ||
export { useAudioTrack } from './hooks/useAudioTrack'; | ||
@@ -12,0 +13,0 @@ export { useDaily } from './hooks/useDaily'; |
{ | ||
"version": "0.6.2", | ||
"version": "0.7.0", | ||
"license": "BSD-2-Clause", | ||
@@ -73,2 +73,3 @@ "keywords": [ | ||
"@size-limit/preset-small-lib": "^5.0.3", | ||
"@testing-library/react": "^12.1.5", | ||
"@testing-library/react-hooks": "^7.0.2", | ||
@@ -90,2 +91,3 @@ "@types/faker": "^5.5.9", | ||
"eslint-plugin-sort-destructure-keys": "^1.4.0", | ||
"fake-mediastreamtrack": "^1.1.6", | ||
"faker": "^5.5.3", | ||
@@ -92,0 +94,0 @@ "fs-extra": "^10.1.0", |
@@ -10,2 +10,3 @@ export { DailyAudio } from './components/DailyAudio'; | ||
export { useAppMessage } from './hooks/useAppMessage'; | ||
export { useAudioLevel } from './hooks/useAudioLevel'; | ||
export { useAudioTrack } from './hooks/useAudioTrack'; | ||
@@ -12,0 +13,0 @@ export { useDaily } from './hooks/useDaily'; |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
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
871879
105
8709
33
5