@daily-co/daily-react-hooks
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -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 t=e(require("@daily-co/daily-js")),n=require("react"),r=e(n),i=require("recoil"),o=e(require("lodash.throttle"));function a(e,t,n,r,i,o,a){try{var u=e[o](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,c,"next",e)}function c(e){a(o,r,i,u,c,"throw",e)}u(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=n.createContext(null),f=n.createContext({on:function(){},off:function(){}});function d(e,t){return e(t={exports:{}},t.exports),t.exports}var p=d((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=Object.create((t&&t.prototype instanceof s?t:s).prototype),o=new x(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,o),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function s(){}function f(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,h=v&&v(v(S([])));h&&h!==t&&n.call(h,i)&&(p=h);var g=d.prototype=s.prototype=Object.create(p);function m(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,u){var l=c(e[i],e,o);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,u)}))}u(l.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function k(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function x(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function S(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return f.prototype=g.constructor=d,d.constructor=f,d[a]=f.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a in e||(e[a]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(y.prototype),y.prototype[o]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new y(u(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),g[a]="Generator",g[i]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=S,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:S(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}})),v=function(){return n.useContext(s)},h=0,g=function(){return h++},m=function(e,t){var r=n.useContext(f),i=r.off,o=r.on,a=n.useState(!1),u=a[0],c=a[1],l=n.useRef(0),s=n.useMemo((function(){return g()}),[]);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 o(e,t,s),function(){clearTimeout(n),i(e,s)}}}),[t,e,s,u,i,o])},y=function(e,t,r){void 0===r&&(r=100);var i=n.useContext(f),a=i.off,u=i.on,c=n.useMemo((function(){return g()}),[]),l=n.useRef([]),s=n.useMemo((function(){return o((function(){0!==l.current.length&&(t(l.current),l.current=[])}),r,{trailing:!0})}),[t,r]);n.useEffect((function(){if(e)return u(e,(function(e){l.current.push(e),setTimeout(s,0)}),c),function(){a(e,c)}}),[s,e,c,a,u])},k=i.atom({key:"local-id",default:""}),b=i.atom({key:"participants-objects",default:[]}),w=i.selectorFamily({key:"participant",get:function(e){return function(t){var n;return null!=(n=(0,t.get)(b).find((function(t){return t.session_id===e})))?n:null}}}),x=function(e){var t=e.children,o=v();m("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set,n=e.snapshot;return function(){var e=u(p.mark((function e(r){var i,a;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.activeSpeaker.peerId,e.next=3,n.getPromise(w(i));case 3:if(!(a=e.sent)&&o&&(a=o.participants()[i]),a){e.next=7;break}return e.abrupt("return");case 7:t(b,(function(e){return[].concat(e).map((function(e){return e.session_id===i?c({},e,{last_active:new Date}):e}))}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[o]));var a=i.useRecoilCallback((function(e){var t=e.set;return function(){var e=u(p.mark((function e(n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t(k,n.local.session_id),t(b,(function(e){return[].concat(e,Object.values(n)).filter((function(e,t,n){return n.findIndex((function(t){return t.session_id===e.session_id}))==t}))}));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[]);return n.useEffect((function(){if(o){var e=setInterval((function(){var t=o.participants();"local"in t&&(a(t),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[o,a]),m("joining-meeting",n.useCallback((function(){if(o){var e=null==o?void 0:o.participants();e.local&&a(e)}}),[o,a])),m("joined-meeting",n.useCallback((function(e){a(e.participants)}),[a])),y("participant-joined",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=u(p.mark((function e(n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(b,(function(e){return[].concat(e,n.map((function(e){return e.participant}))).filter((function(e,t,n){return n.findIndex((function(t){return t.session_id===e.session_id}))==t}))}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[])),y("participant-updated",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;e.forEach((function(e){var t=e.participant;n(b,(function(e){return[].concat(e).map((function(e){return e.session_id===t.session_id?t:e}))}))}))}))}}),[])),y("participant-left",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(b,(function(t){return[].concat(t).filter((function(t){return!e.some((function(e){return e.participant.session_id===t.session_id}))}))}))}}),[])),m("left-meeting",i.useRecoilCallback((function(e){var t=e.reset;return function(){t(k),t(b)}}),[])),r.createElement(r.Fragment,null,t)},S=i.atom({key:"room",default:null}),R=function(e){var t=e.children,n=v(),o=i.useRecoilCallback((function(e){var t=e.set;return u(p.mark((function e(){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&"left-meeting"!==n.meetingState()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,n.room();case 4:return(r=e.sent)&&"id"in r&&t(S,r),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})))}),[n]);return m("access-state-updated",o),r.createElement(r.Fragment,null,t)},C=["children"],E=function(e,t){var r=void 0===t?{}:t,o=r.onParticipantLeft,a=r.onParticipantUpdated,u=i.useRecoilValue(w(e));return y("participant-updated",n.useCallback((function(t){var n=t.filter((function(t){return t.participant.session_id===e}));n.length&&n.forEach((function(e){setTimeout((function(){return null==a?void 0:a(e)}),0)}))}),[a,e])),y("participant-left",n.useCallback((function(t){if(t.filter((function(t){return t.participant.session_id===e})).length){var n=t[t.length-1];setTimeout((function(){return null==o?void 0:o(n)}),0)}}),[o,e])),u},L=i.atom({key:"active-id",default:""}),_=i.atomFamily({key:"media-track",default:{state:"loading",subscribed:!1}}),T=function(e,t){void 0===t&&(t="video");var r=v(),o=n.useMemo((function(){return e+"-"+t}),[e,t]),a=i.useRecoilValue(_(o)),u=i.useRecoilCallback((function(n){var r=n.transact_UNSTABLE;return function(n){var i=n.filter((function(t){return t.participant.session_id===e}));i.length&&r((function(e){var n=e.reset,r=e.set;i.forEach((function(e){switch(e.action){case"participant-joined":case"participant-updated":r(_(o),e.participant.tracks[t]);break;case"participant-left":n(_(o))}}))}))}}),[o,e,t]);y("participant-joined",u),y("participant-updated",u),y("participant-left",u),m("joined-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(_(o),e.participants.local.tracks[t])}}),[o,t]));var l=i.useRecoilCallback((function(e){var t=e.set;return function(e){e&&t(_(o),e)}}),[o]);return n.useEffect((function(){if(r){var n=null==r?void 0:r.participants();if(n){var i=Object.values(n).find((function(t){return t.session_id===e}));i&&l(i.tracks[t])}}}),[r,e,l,t]),c({},a,{isOff:"blocked"===a.state||"off"===a.state})},j=i.atom({key:"general-camera-state",default:"pending"}),I=i.atom({key:"general-microphone-state",default:"pending"}),P=i.atom({key:"camera-devices",default:[]}),A=i.atom({key:"microphone-devices",default:[]}),O=i.atom({key:"speaker-devices",default:[]}),D=i.atom({key:"input-settings",default:null}),M=i.atom({key:"input-settings-error",default:null}),V=i.atom({key:"live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),N=function(){var e=i.useRecoilValue(k);return E(e)},U=i.atom({key:"topology",default:"peer"}),B=i.atom({key:"networkQuality",default:100}),F=i.atom({key:"networkThreshold",default:"good"}),q=Boolean,G=function(){return 0},W=function(e){var t=void 0===e?{filter:q,sort:G}:e,r=t.filter,o=void 0===r?q:r,a=t.onActiveSpeakerChange,c=t.onParticipantJoined,l=t.onParticipantLeft,s=t.onParticipantUpdated,f=t.sort,d=void 0===f?G:f,v=i.useRecoilValue(b),h=n.useMemo((function(){var e,t=q;switch(o){case"local":t=function(e){return e.local};break;case"owner":t=function(e){return e.owner};break;case"record":t=function(e){return e.record};break;case"remote":t=function(e){return!e.local};break;case"screen":t=function(e){return e.screen};break;default:t=o}switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,t){return e[d]<t[d]?-1:e[d]>t[d]?1:0};break;default:e=d}return v.filter(t).sort(e).map((function(e){return e.session_id})).filter(Boolean)}),[v,o,d]);return y("participant-joined",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==c?void 0:c(e)}),0)}))}),[c])),y("participant-updated",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==s?void 0:s(e)}),0)}))}),[s])),y("active-speaker-change",n.useCallback(function(){var e=u(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length){e.next=2;break}return e.abrupt("return");case 2:t.forEach((function(e){return setTimeout((function(){return null==a?void 0:a(e)}),0)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[a])),y("participant-left",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==l?void 0:l(e)}),0)}))}),[l])),h},z=i.atomFamily({key:"participant-receive-settings",default:{}}),Q=i.atom({key:"recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),Y=i.atom({key:"waiting-participants",default:[]}),J=i.atomFamily({key:"waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),$=i.selector({key:"waitingParticipantsSelector",get:function(e){var t=e.get;return t(Y).map((function(e){return t(J(e))}))}});exports.DailyProvider=function(e){var o=e.children,a=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(e,C),u=n.useState("callObject"in a?a.callObject:null),c=u[0],d=u[1],p=n.useRef({});n.useEffect((function(){var e;"callObject"in a&&c&&a.callObject&&(null==c?void 0:c._callFrameId)!==(null==a||null==(e=a.callObject)?void 0:e._callFrameId)&&d(a.callObject)}),[c,a]);var v=n.useCallback((function(e){if("action"in e)for(var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);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.")}(null!=(r=null==(i=p.current)||null==(o=i[e.action])?void 0:o.values())?r:[]);!(t=n()).done;){var r,i,o;(0,t.value)(e)}}),[]),h=n.useCallback((function(e){e&&Object.keys(p.current).forEach((function(t){e.off(t,v).on(t,v)}))}),[v]);n.useEffect((function(){if(!c){if("callObject"in a)return d(a.callObject),void h(a.callObject);var e=t.createCallObject(a);d(e),h(e)}}),[c,h,a]);var g=n.useCallback((function(e,t,n){var r,i;p.current[e]||(p.current[e]=new Map,c&&c.off(e,v).on(e,v)),null!=(r=p.current[e])&&r.has(n)||null==(i=p.current[e])||i.set(n,t)}),[c,v]),m=n.useCallback((function(e,t){var n,r;null==(n=p.current[e])||n.delete(t),0===(null==(r=p.current[e])?void 0:r.size)&&(null==c||c.off(e,v),delete p.current[e])}),[c,v]);return r.createElement(i.RecoilRoot,null,r.createElement(s.Provider,{value:c},r.createElement(f.Provider,{value:{on:g,off:m}},r.createElement(R,null,r.createElement(x,null,o)))))},exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,o=void 0!==r&&r,a=t.onActiveSpeakerChange,u=v(),c=i.useRecoilValue(L),l=n.useState(""),s=l[1],f=E(l[0]);return n.useEffect((function(){var e;if(u){var t=null==u||null==(e=u.participants())?void 0:e.local;o&&c===(null==t?void 0:t.session_id)||s(c)}}),[u,o,c]),m("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(L,e.activeSpeaker.peerId),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a])),f},exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=v(),i=n.useCallback((function(e,t){void 0===t&&(t="*"),r&&r.sendAppMessage(e,t)}),[r]),o=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return m("app-message",o),i},exports.useAudioTrack=function(e){return T(e,"audio")},exports.useDaily=v,exports.useDailyEvent=m,exports.useDevices=function(){var e=v(),t=i.useRecoilValue(j),r=i.useRecoilValue(I),o=i.useRecoilValue(P),a=i.useRecoilValue(A),l=i.useRecoilValue(O),s=i.useRecoilCallback((function(t){var n=t.transact_UNSTABLE;return u(p.mark((function t(){var r,i,o,a,u,c,l,s,f,d,v,h,g,m;return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.getUserMedia)&&void 0!==(null==(o=navigator)||null==(a=o.mediaDevices)?void 0:a.enumerateDevices)){t.next=3;break}return n((function(e){var t=e.set;t(j,"not-supported"),t(I,"not-supported")})),t.abrupt("return");case 3:if(e){t.next=5;break}return t.abrupt("return");case 5:return t.prev=5,t.next=8,e.enumerateDevices();case 8:return c=(u=t.sent.devices).filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),t.next=15,e.getInputDevices();case 15:d=(f=t.sent).camera,v=f.mic,h=f.speaker,g=function(e,t,n){var r,i;return{device:t,selected:"deviceId"in e&&t.deviceId===e.deviceId,state:null!=(r=null==(i=n.find((function(e){return e.device.deviceId===t.deviceId})))?void 0:i.state)?r:"granted"}},m=function(e,t){return"default"===e.device.deviceId?-1:"default"===t.device.deviceId?1:e.device.label<t.device.label?-1:e.device.label>t.device.label?1:0},n((function(e){var t=e.set;t(P,(function(e){return c.filter(Boolean).map((function(t){return g(d,t,e)})).sort(m)})),t(A,(function(e){return l.filter(Boolean).map((function(t){return g(v,t,e)})).sort(m)})),t(O,(function(e){return s.filter(Boolean).map((function(t){return g(h,t,e)})).sort(m)}))})),t.next=27;break;case 24:t.prev=24,t.t0=t.catch(5),n((function(e){var t=e.set;t(j,"not-supported"),t(I,"not-supported")}));case 27:case"end":return t.stop()}}),t,null,[[5,24]])})))}),[e]),f=i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot,i=t.transact_UNSTABLE;return u(p.mark((function t(){var o,a,u,l,f,d,v,h,g,m,y,k,b,w,x,S,R;return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(j);case 4:return b=t.sent,t.next=7,r.getPromise(I);case 7:w=t.sent,x=e.participants().local.tracks,S="pending"===b&&"interrupted"===x.video.state,R="pending"===w&&"interrupted"===x.audio.state,null!=(o=x.audio)&&null!=(a=o.blocked)&&a.byDeviceInUse?i((function(e){var t=e.set;t(I,"in-use"),t(A,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(u=x.audio)&&null!=(l=u.blocked)&&l.byDeviceMissing?n(I,"not-found"):null!=(f=x.audio)&&null!=(d=f.blocked)&&d.byPermissions?n(I,"blocked"):R||i((function(e){var t=e.set;t(I,"granted"),t(A,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),null!=(v=x.video)&&null!=(h=v.blocked)&&h.byDeviceInUse?i((function(e){var t=e.set;t(j,"in-use"),t(P,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(g=x.video)&&null!=(m=g.blocked)&&m.byDeviceMissing?n(j,"not-found"):null!=(y=x.video)&&null!=(k=y.blocked)&&k.byPermissions?n(j,"blocked"):S||i((function(e){var t=e.set;t(j,"granted"),t(P,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),s();case 14:case"end":return t.stop()}}),t)})))}),[e,s]);m("participant-updated",n.useCallback((function(e){e.participant.local&&f()}),[f])),m("available-devices-updated",s),m("camera-error",i.useRecoilCallback((function(e){var t=e.set,n=e.transact_UNSTABLE;return function(e){var r=e.error,i=e.errorMsg,o=i.audioOk,a=i.errorMsg,u=i.videoOk;switch(null==r?void 0:r.type){case"cam-in-use":t(j,"in-use");break;case"mic-in-use":t(I,"in-use");break;case"cam-mic-in-use":n((function(e){var t=e.set;t(j,"in-use"),t(I,"in-use")}));break;default:switch(a){case"devices error":n((function(e){var t=e.set;u||t(j,"not-found"),o||t(I,"not-found")}));break;case"not allowed":n((function(e){var t=e.set;t(j,"blocked"),t(I,"blocked")})),f()}}}}),[f])),m("error",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){switch(e.errorMsg){case"not allowed":t((function(e){var t=e.set;t(j,"blocked"),t(I,"blocked")})),f()}}}),[f])),m("started-camera",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(){t((function(e){var t=e.set;t(j,"granted"),t(I,"granted")})),f()}}),[f]));var d=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),h=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),g=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]);return{cameras:o,camState:t,hasCamError:["blocked","in-use","not-found"].includes(t),hasMicError:["blocked","in-use","not-found"].includes(r),microphones:a,micState:r,refreshDevices:s,setCamera:d,setMicrophone:h,setSpeaker:g,speakers:l}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,o=t.onInputSettingsUpdated,a=i.useRecoilValue(D),u=i.useRecoilValue(M),c=v(),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(D,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),m("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),setTimeout((function(){return null==o?void 0:o(e)}),0)}),[o,l])),m("nonfatal-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){"input-settings-error"===e.type&&(t(M,e.errorMsg),setTimeout((function(){return null==r?void 0:r(e)}),0))}}),[r])),{errorMsg:u,inputSettings:a,updateInputSettings:n.useCallback((function(e){null==c||c.updateInputSettings(e)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,o=t.onLiveStreamingStarted,a=t.onLiveStreamingStopped,u=v(),l=i.useRecoilValue(V);return m("live-streaming-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o])),m("live-streaming-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,(function(e){return c({},e,{isLiveStreaming:!1,layout:void 0})})),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a])),m("live-streaming-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,(function(t){return c({},t,{errorMsg:e.errorMsg})})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[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=N,exports.useMediaTrack=T,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,o=t.onNetworkQualityChange,a=v(),c=i.useRecoilValue(U),l=i.useRecoilValue(B),s=i.useRecoilValue(F),f=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&n(U,"peer"),"sfu"===e.type&&n(U,"sfu")}})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[r]),d=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;n(B,(function(t){return t!==e.quality?e.quality:t})),n(F,(function(t){return t!==e.threshold?e.threshold:t}))})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o]);return m("network-connection",f),m("network-quality-change",d),{getStats:n.useCallback(u(p.mark((function e(){var t;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==a?void 0:a.getNetworkStats();case 2:return e.abrupt("return",null==(t=e.sent)?void 0:t.stats);case 4:case"end":return e.stop()}}),e)}))),[a]),quality:l,threshold:s,topology:c}},exports.useParticipant=E,exports.useParticipantIds=W,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,o=void 0===r?"base":r,a=t.onReceiveSettingsUpdated,u=i.useRecoilValue(z("base")),l=i.useRecoilValue(z(o)),s=v();m("receive-settings-updated",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){for(var n=t.reset,r=t.set,i=c({},e.receiveSettings),a=0,u=Object.entries(i);a<u.length;a++){var l=u[a],s=l[1];r(z(l[0]),s)}o in i||n(z(o))})),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[o,a]));var f=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===o||0===Object.keys(l).length?u:l,updateReceiveSettings:f}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,o=t.onRecordingError,a=t.onRecordingStarted,u=t.onRecordingStopped,l=v(),s=i.useRecoilValue(Q),f=i.useSetRecoilState(Q),d=N(),p=W({filter:"record"});return n.useEffect((function(){var e,t=p.length>0,n=p.includes(null!=(e=null==d?void 0:d.session_id)?e:"local");f((function(e){return c({},e,{isLocalParticipantRecorded:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isLocalParticipantRecorded:t,isRecording:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isRecording:t,local:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type||!t?null==e?void 0:e.local:n,type:t?"local":null==e?void 0:e.type})}))}),[null==d?void 0:d.session_id,p,f]),m("recording-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=!0;switch(e.type){case"cloud-beta":case"cloud":var r;d&&"single-participant"===(null==(r=e.layout)?void 0:r.preset)&&e.layout.session_id!==(null==d?void 0:d.session_id)&&(n=!1)}t(Q,{error:!1,isLocalParticipantRecorded:n,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}),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[d,a])),m("recording-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(Q,(function(e){return c({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),setTimeout((function(){return null==u?void 0:u(e)}),0)}}),[u])),m("recording-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(Q,(function(e){return c({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o])),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=function(){return i.useRecoilValue(S)},exports.useScreenAudioTrack=function(e){return T(e,"screenAudio")},exports.useScreenShare=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,o=v(),a=n.useCallback((function(e){null==o||o.startScreenShare(e)}),[o]),u=n.useCallback((function(){null==o||o.stopScreenShare()}),[o]);m("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),m("local-screen-share-stopped",n.useCallback((function(){return null==i?void 0:i()}),[i]));var c=W({filter:"screen"}),l=n.useMemo((function(){return c.map((function(e){var t,n=Object.values(null!=(t=null==o||null==o.participants?void 0:o.participants())?t:{}).find((function(t){return t.session_id===e}));if(n)return{local:n.local,screenAudio:n.tracks.screenAudio,screenVideo:n.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[o,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:a,stopScreenShare:u}},exports.useScreenVideoTrack=function(e){return T(e,"screenVideo")},exports.useThrottledDailyEvent=y,exports.useVideoTrack=function(e){return T(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,o=t.onWaitingParticipantRemoved,a=t.onWaitingParticipantUpdated,u=v(),c=i.useRecoilValue($),l=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;n(Y,(function(t){return t.includes(e.participant.id)?t:[].concat(t,[e.participant.id])})),n(J(e.participant.id),e.participant)})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[r]),s=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.reset;(0,t.set)(Y,(function(t){return t.filter((function(t){return t!==e.participant.id}))})),n(J(e.participant.id))})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o]),f=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(J(e.participant.id),e.participant),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a]);m("waiting-participant-added",l),m("waiting-participant-removed",s),m("waiting-participant-updated",f);var d=n.useCallback((function(e,t){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:t}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:t}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){d(e,!0)}),[d]),denyAccess:n.useCallback((function(e){d(e,!1)}),[d])}}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("@daily-co/daily-js")),n=require("react"),r=e(n),i=require("recoil"),o=e(require("lodash.throttle"));function a(e,t,n,r,i,o,a){try{var u=e[o](a),c=u.value}catch(e){return void n(e)}u.done?t(c):Promise.resolve(c).then(r,i)}function u(e){return function(){var t=this,n=arguments;return new Promise((function(r,i){var o=e.apply(t,n);function u(e){a(o,r,i,u,c,"next",e)}function c(e){a(o,r,i,u,c,"throw",e)}u(void 0)}))}}function c(){return(c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=n.createContext(null),f=n.createContext({on:function(){},off:function(){}});function d(e,t){return e(t={exports:{}},t.exports),t.exports}var p=d((function(e){var t=function(e){var t=Object.prototype,n=t.hasOwnProperty,r="function"==typeof Symbol?Symbol:{},i=r.iterator||"@@iterator",o=r.asyncIterator||"@@asyncIterator",a=r.toStringTag||"@@toStringTag";function u(e,t,n,r){var i=Object.create((t&&t.prototype instanceof s?t:s).prototype),o=new S(r||[]);return i._invoke=function(e,t,n){var r="suspendedStart";return function(i,o){if("executing"===r)throw new Error("Generator is already running");if("completed"===r){if("throw"===i)throw o;return{value:void 0,done:!0}}for(n.method=i,n.arg=o;;){var a=n.delegate;if(a){var u=k(a,n);if(u){if(u===l)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===r)throw r="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);r="executing";var s=c(e,t,n);if("normal"===s.type){if(r=n.done?"completed":"suspendedYield",s.arg===l)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(r="completed",n.method="throw",n.arg=s.arg)}}}(e,n,o),i}function c(e,t,n){try{return{type:"normal",arg:e.call(t,n)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function s(){}function f(){}function d(){}var p={};p[i]=function(){return this};var v=Object.getPrototypeOf,h=v&&v(v(x([])));h&&h!==t&&n.call(h,i)&&(p=h);var g=d.prototype=s.prototype=Object.create(p);function m(e){["next","throw","return"].forEach((function(t){e[t]=function(e){return this._invoke(t,e)}}))}function y(e,t){var r;this._invoke=function(i,o){function a(){return new t((function(r,a){!function r(i,o,a,u){var l=c(e[i],e,o);if("throw"!==l.type){var s=l.arg,f=s.value;return f&&"object"==typeof f&&n.call(f,"__await")?t.resolve(f.__await).then((function(e){r("next",e,a,u)}),(function(e){r("throw",e,a,u)})):t.resolve(f).then((function(e){s.value=e,a(s)}),(function(e){return r("throw",e,a,u)}))}u(l.arg)}(i,o,r,a)}))}return r=r?r.then(a,a):a()}}function k(e,t){var n=e.iterator[t.method];if(void 0===n){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,k(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var r=c(n,e.iterator,t.arg);if("throw"===r.type)return t.method="throw",t.arg=r.arg,t.delegate=null,l;var i=r.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function b(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(b,this),this.reset(!0)}function x(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var r=-1,o=function t(){for(;++r<e.length;)if(n.call(e,r))return t.value=e[r],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:R}}function R(){return{value:void 0,done:!0}}return f.prototype=g.constructor=d,d.constructor=f,d[a]=f.displayName="GeneratorFunction",e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,a in e||(e[a]="GeneratorFunction")),e.prototype=Object.create(g),e},e.awrap=function(e){return{__await:e}},m(y.prototype),y.prototype[o]=function(){return this},e.AsyncIterator=y,e.async=function(t,n,r,i,o){void 0===o&&(o=Promise);var a=new y(u(t,n,r,i),o);return e.isGeneratorFunction(n)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},m(g),g[a]="Generator",g[i]=function(){return this},g.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var n in e)t.push(n);return t.reverse(),function n(){for(;t.length;){var r=t.pop();if(r in e)return n.value=r,n.done=!1,n}return n.done=!0,n}},e.values=x,S.prototype={constructor:S,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&n.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function r(n,r){return a.type="throw",a.arg=e,t.next=n,r&&(t.method="next",t.arg=void 0),!!r}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var u=n.call(o,"catchLoc"),c=n.call(o,"finallyLoc");if(u&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(u){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,t){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.finallyLoc===e)return this.complete(n.completion,n.afterLoc),w(n),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc===e){var r=n.completion;if("throw"===r.type){var i=r.arg;w(n)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,n){return this.delegate={iterator:x(e),resultName:t,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=t}catch(e){Function("r","regeneratorRuntime = r")(t)}})),v=function(){return n.useContext(s)},h=0,g=function(){return h++},m=function(e,t){var r=n.useContext(f),i=r.off,o=r.on,a=n.useState(!1),u=a[0],c=a[1],l=n.useRef(0),s=n.useMemo((function(){return g()}),[]);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 o(e,t,s),function(){clearTimeout(n),i(e,s)}}}),[t,e,s,u,i,o])},y=function(e,t,r){void 0===r&&(r=100);var i=n.useContext(f),a=i.off,u=i.on,c=n.useMemo((function(){return g()}),[]),l=n.useRef([]),s=n.useMemo((function(){return o((function(){0!==l.current.length&&(t(l.current),l.current=[])}),r,{trailing:!0})}),[t,r]);n.useEffect((function(){if(e)return u(e,(function(e){l.current.push(e),setTimeout(s,0)}),c),function(){a(e,c)}}),[s,e,c,a,u])},k=i.atom({key:"local-id",default:""}),b=i.atom({key:"participants-objects",default:[]}),w=i.selectorFamily({key:"participant",get:function(e){return function(t){var n;return null!=(n=(0,t.get)(b).find((function(t){return t.session_id===e})))?n:null}}}),S=function(e){var t=e.children,o=v();m("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set,n=e.snapshot;return function(){var e=u(p.mark((function e(r){var i,a;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=r.activeSpeaker.peerId,e.next=3,n.getPromise(w(i));case 3:if(!(a=e.sent)&&o&&(a=o.participants()[i]),a){e.next=7;break}return e.abrupt("return");case 7:t(b,(function(e){return[].concat(e).map((function(e){return e.session_id===i?c({},e,{last_active:new Date}):e}))}));case 8:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[o]));var a=i.useRecoilCallback((function(e){var t=e.set;return function(){var e=u(p.mark((function e(n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t(k,n.local.session_id),t(b,Object.values(n));case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[]);n.useEffect((function(){if(o){var e=setInterval((function(){var t=o.participants();"local"in t&&(a(t),clearInterval(e))}),100);return function(){clearInterval(e)}}}),[o,a]);var l=n.useCallback((function(){if(o){var e=null==o?void 0:o.participants();e.local&&a(e)}}),[o,a]);return m("started-camera",l),m("access-state-updated",l),m("joining-meeting",l),m("joined-meeting",n.useCallback((function(e){a(e.participants)}),[a])),y("participant-joined",i.useRecoilCallback((function(e){var t=e.set;return function(){var e=u(p.mark((function e(n){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n.length){e.next=2;break}return e.abrupt("return");case 2:t(b,(function(e){return[].concat(e,n.map((function(e){return e.participant}))).filter((function(e,t,n){return n.findIndex((function(t){return t.session_id===e.session_id}))==t}))}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()}),[])),y("participant-updated",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;e.forEach((function(e){var t=e.participant;n(b,(function(e){return[].concat(e).map((function(e){return e.session_id===t.session_id?t:e}))}))}))}))}}),[])),y("participant-left",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(b,(function(t){return[].concat(t).filter((function(t){return!e.some((function(e){return e.participant.session_id===t.session_id}))}))}))}}),[])),m("left-meeting",i.useRecoilCallback((function(e){var t=e.reset;return function(){t(k),t(b)}}),[])),r.createElement(r.Fragment,null,t)},x=i.atom({key:"room",default:null}),R=function(e){var t=e.children,n=v(),o=i.useRecoilCallback((function(e){var t=e.set;return u(p.mark((function e(){var r;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n&&"left-meeting"!==n.meetingState()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,n.room();case 4:return(r=e.sent)&&"id"in r&&t(x,r),e.abrupt("return",r);case 7:case"end":return e.stop()}}),e)})))}),[n]);return m("access-state-updated",o),r.createElement(r.Fragment,null,t)},C=["children"],E=function(e,t){var r=void 0===t?{}:t,o=r.onParticipantLeft,a=r.onParticipantUpdated,u=i.useRecoilValue(w(e));return y("participant-updated",n.useCallback((function(t){var n=t.filter((function(t){return t.participant.session_id===e}));n.length&&n.forEach((function(e){setTimeout((function(){return null==a?void 0:a(e)}),0)}))}),[a,e])),y("participant-left",n.useCallback((function(t){if(t.filter((function(t){return t.participant.session_id===e})).length){var n=t[t.length-1];setTimeout((function(){return null==o?void 0:o(n)}),0)}}),[o,e])),u},L=i.atom({key:"active-id",default:""}),_=i.atomFamily({key:"media-track",default:{state:"loading",subscribed:!1}}),T=function(e,t){void 0===t&&(t="video");var r=v(),o=n.useMemo((function(){return e+"-"+t}),[e,t]),a=i.useRecoilValue(_(o)),u=i.useRecoilCallback((function(n){var r=n.transact_UNSTABLE;return function(n){var i=n.filter((function(t){return t.participant.session_id===e}));i.length&&r((function(e){var n=e.reset,r=e.set;i.forEach((function(e){switch(e.action){case"participant-joined":case"participant-updated":r(_(o),e.participant.tracks[t]);break;case"participant-left":n(_(o))}}))}))}}),[o,e,t]);y("participant-joined",u),y("participant-updated",u),y("participant-left",u),m("joined-meeting",i.useRecoilCallback((function(e){var n=e.set;return function(e){n(_(o),e.participants.local.tracks[t])}}),[o,t]));var l=i.useRecoilCallback((function(e){var t=e.set;return function(e){e&&t(_(o),e)}}),[o]);return n.useEffect((function(){if(r){var n=null==r?void 0:r.participants();if(n){var i=Object.values(n).find((function(t){return t.session_id===e}));i&&l(i.tracks[t])}}}),[r,e,l,t]),c({},a,{isOff:"blocked"===a.state||"off"===a.state})},j=i.atom({key:"general-camera-state",default:"pending"}),I=i.atom({key:"general-microphone-state",default:"pending"}),P=i.atom({key:"camera-devices",default:[]}),A=i.atom({key:"microphone-devices",default:[]}),O=i.atom({key:"speaker-devices",default:[]}),D=i.atom({key:"input-settings",default:null}),M=i.atom({key:"input-settings-error",default:null}),V=i.atom({key:"live-streaming",default:{errorMsg:void 0,isLiveStreaming:!1,layout:void 0}}),N=function(){var e=i.useRecoilValue(k);return E(e)},U=i.atom({key:"topology",default:"peer"}),B=i.atom({key:"networkQuality",default:100}),F=i.atom({key:"networkThreshold",default:"good"}),q=Boolean,G=function(){return 0},W=function(e){var t=void 0===e?{filter:q,sort:G}:e,r=t.filter,o=void 0===r?q:r,a=t.onActiveSpeakerChange,c=t.onParticipantJoined,l=t.onParticipantLeft,s=t.onParticipantUpdated,f=t.sort,d=void 0===f?G:f,v=i.useRecoilValue(b),h=n.useMemo((function(){var e,t=q;switch(o){case"local":t=function(e){return e.local};break;case"owner":t=function(e){return e.owner};break;case"record":t=function(e){return e.record};break;case"remote":t=function(e){return!e.local};break;case"screen":t=function(e){return e.screen};break;default:t=o}switch(d){case"joined_at":case"session_id":case"user_id":case"user_name":e=function(e,t){return e[d]<t[d]?-1:e[d]>t[d]?1:0};break;default:e=d}return v.filter(t).sort(e).map((function(e){return e.session_id})).filter(Boolean)}),[v,o,d]);return y("participant-joined",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==c?void 0:c(e)}),0)}))}),[c])),y("participant-updated",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==s?void 0:s(e)}),0)}))}),[s])),y("active-speaker-change",n.useCallback(function(){var e=u(p.mark((function e(t){return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.length){e.next=2;break}return e.abrupt("return");case 2:t.forEach((function(e){return setTimeout((function(){return null==a?void 0:a(e)}),0)}));case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),[a])),y("participant-left",n.useCallback((function(e){e.length&&e.forEach((function(e){return setTimeout((function(){return null==l?void 0:l(e)}),0)}))}),[l])),h},z=i.atomFamily({key:"participant-receive-settings",default:{}}),Q=i.atom({key:"recording",default:{isLocalParticipantRecorded:!1,isRecording:!1}}),Y=i.atom({key:"waiting-participants",default:[]}),J=i.atomFamily({key:"waiting-participant",default:{awaitingAccess:{level:"full"},id:"",name:""}}),$=i.selector({key:"waitingParticipantsSelector",get:function(e){var t=e.get;return t(Y).map((function(e){return t(J(e))}))}});exports.DailyProvider=function(e){var o=e.children,a=function(e,t){if(null==e)return{};var n,r,i={},o=Object.keys(e);for(r=0;r<o.length;r++)t.indexOf(n=o[r])>=0||(i[n]=e[n]);return i}(e,C),u=n.useState("callObject"in a?a.callObject:null),c=u[0],d=u[1],p=n.useRef({});n.useEffect((function(){var e;"callObject"in a&&c&&a.callObject&&(null==c?void 0:c._callFrameId)!==(null==a||null==(e=a.callObject)?void 0:e._callFrameId)&&d(a.callObject)}),[c,a]);var v=n.useCallback((function(e){if("action"in e)for(var t,n=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return l(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?l(e,void 0):void 0}}(e))){n&&(e=n);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.")}(null!=(r=null==(i=p.current)||null==(o=i[e.action])?void 0:o.values())?r:[]);!(t=n()).done;){var r,i,o;(0,t.value)(e)}}),[]),h=n.useCallback((function(e){e&&Object.keys(p.current).forEach((function(t){e.off(t,v).on(t,v)}))}),[v]);n.useEffect((function(){if(!c){if("callObject"in a)return d(a.callObject),void h(a.callObject);var e=t.createCallObject(a);d(e),h(e)}}),[c,h,a]);var g=n.useCallback((function(e,t,n){var r,i;p.current[e]||(p.current[e]=new Map,c&&c.off(e,v).on(e,v)),null!=(r=p.current[e])&&r.has(n)||null==(i=p.current[e])||i.set(n,t)}),[c,v]),m=n.useCallback((function(e,t){var n,r;null==(n=p.current[e])||n.delete(t),0===(null==(r=p.current[e])?void 0:r.size)&&(null==c||c.off(e,v),delete p.current[e])}),[c,v]);return r.createElement(i.RecoilRoot,null,r.createElement(s.Provider,{value:c},r.createElement(f.Provider,{value:{on:g,off:m}},r.createElement(R,null,r.createElement(S,null,o)))))},exports.useActiveParticipant=function(e){var t=void 0===e?{}:e,r=t.ignoreLocal,o=void 0!==r&&r,a=t.onActiveSpeakerChange,u=v(),c=i.useRecoilValue(L),l=n.useState(""),s=l[1],f=E(l[0]);return n.useEffect((function(){var e;if(u){var t=null==u||null==(e=u.participants())?void 0:e.local;o&&c===(null==t?void 0:t.session_id)||s(c)}}),[u,o,c]),m("active-speaker-change",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(L,e.activeSpeaker.peerId),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a])),f},exports.useAppMessage=function(e){var t=(void 0===e?{}:e).onAppMessage,r=v(),i=n.useCallback((function(e,t){void 0===t&&(t="*"),r&&r.sendAppMessage(e,t)}),[r]),o=n.useCallback((function(e){null==t||t(e,i)}),[t,i]);return m("app-message",o),i},exports.useAudioTrack=function(e){return T(e,"audio")},exports.useDaily=v,exports.useDailyEvent=m,exports.useDevices=function(){var e=v(),t=i.useRecoilValue(j),r=i.useRecoilValue(I),o=i.useRecoilValue(P),a=i.useRecoilValue(A),l=i.useRecoilValue(O),s=i.useRecoilCallback((function(t){var n=t.transact_UNSTABLE;return u(p.mark((function t(){var r,i,o,a,u,c,l,s,f,d,v,h,g,m;return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==(null==(r=navigator)||null==(i=r.mediaDevices)?void 0:i.getUserMedia)&&void 0!==(null==(o=navigator)||null==(a=o.mediaDevices)?void 0:a.enumerateDevices)){t.next=3;break}return n((function(e){var t=e.set;t(j,"not-supported"),t(I,"not-supported")})),t.abrupt("return");case 3:if(e){t.next=5;break}return t.abrupt("return");case 5:return t.prev=5,t.next=8,e.enumerateDevices();case 8:return c=(u=t.sent.devices).filter((function(e){return"videoinput"===e.kind&&""!==e.deviceId})),l=u.filter((function(e){return"audioinput"===e.kind&&""!==e.deviceId})),s=u.filter((function(e){return"audiooutput"===e.kind&&""!==e.deviceId})),t.next=15,e.getInputDevices();case 15:d=(f=t.sent).camera,v=f.mic,h=f.speaker,g=function(e,t,n){var r,i;return{device:t,selected:"deviceId"in e&&t.deviceId===e.deviceId,state:null!=(r=null==(i=n.find((function(e){return e.device.deviceId===t.deviceId})))?void 0:i.state)?r:"granted"}},m=function(e,t){return"default"===e.device.deviceId?-1:"default"===t.device.deviceId?1:e.device.label<t.device.label?-1:e.device.label>t.device.label?1:0},n((function(e){var t=e.set;t(P,(function(e){return c.filter(Boolean).map((function(t){return g(d,t,e)})).sort(m)})),t(A,(function(e){return l.filter(Boolean).map((function(t){return g(v,t,e)})).sort(m)})),t(O,(function(e){return s.filter(Boolean).map((function(t){return g(h,t,e)})).sort(m)}))})),t.next=27;break;case 24:t.prev=24,t.t0=t.catch(5),n((function(e){var t=e.set;t(j,"not-supported"),t(I,"not-supported")}));case 27:case"end":return t.stop()}}),t,null,[[5,24]])})))}),[e]),f=i.useRecoilCallback((function(t){var n=t.set,r=t.snapshot,i=t.transact_UNSTABLE;return u(p.mark((function t(){var o,a,u,l,f,d,v,h,g,m,y,k,b,w,S,x,R;return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,r.getPromise(j);case 4:return b=t.sent,t.next=7,r.getPromise(I);case 7:w=t.sent,S=e.participants().local.tracks,x="pending"===b&&"interrupted"===S.video.state,R="pending"===w&&"interrupted"===S.audio.state,null!=(o=S.audio)&&null!=(a=o.blocked)&&a.byDeviceInUse?i((function(e){var t=e.set;t(I,"in-use"),t(A,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(u=S.audio)&&null!=(l=u.blocked)&&l.byDeviceMissing?n(I,"not-found"):null!=(f=S.audio)&&null!=(d=f.blocked)&&d.byPermissions?n(I,"blocked"):R||i((function(e){var t=e.set;t(I,"granted"),t(A,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),null!=(v=S.video)&&null!=(h=v.blocked)&&h.byDeviceInUse?i((function(e){var t=e.set;t(j,"in-use"),t(P,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"in-use"}):e}))}))})):null!=(g=S.video)&&null!=(m=g.blocked)&&m.byDeviceMissing?n(j,"not-found"):null!=(y=S.video)&&null!=(k=y.blocked)&&k.byPermissions?n(j,"blocked"):x||i((function(e){var t=e.set;t(j,"granted"),t(P,(function(e){return e.map((function(e){return e.selected?c({},e,{state:"granted"}):e}))}))})),s();case 14:case"end":return t.stop()}}),t)})))}),[e,s]);m("participant-updated",n.useCallback((function(e){e.participant.local&&f()}),[f])),m("available-devices-updated",s),m("camera-error",i.useRecoilCallback((function(e){var t=e.set,n=e.transact_UNSTABLE;return function(e){var r=e.error,i=e.errorMsg,o=i.audioOk,a=i.errorMsg,u=i.videoOk;switch(null==r?void 0:r.type){case"cam-in-use":t(j,"in-use");break;case"mic-in-use":t(I,"in-use");break;case"cam-mic-in-use":n((function(e){var t=e.set;t(j,"in-use"),t(I,"in-use")}));break;default:switch(a){case"devices error":n((function(e){var t=e.set;u||t(j,"not-found"),o||t(I,"not-found")}));break;case"not allowed":n((function(e){var t=e.set;t(j,"blocked"),t(I,"blocked")})),f()}}}}),[f])),m("error",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){switch(e.errorMsg){case"not allowed":t((function(e){var t=e.set;t(j,"blocked"),t(I,"blocked")})),f()}}}),[f])),m("started-camera",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(){t((function(e){var t=e.set;t(j,"granted"),t(I,"granted")})),f()}}),[f]));var d=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:null,videoDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),h=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setInputDevicesAsync({audioDeviceId:n,videoDeviceId:null});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]),g=n.useCallback(function(){var t=u(p.mark((function t(n){return p.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,null==e?void 0:e.setOutputDeviceAsync({outputDeviceId:n});case 2:s();case 3:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),[e,s]);return{cameras:o,camState:t,hasCamError:["blocked","in-use","not-found"].includes(t),hasMicError:["blocked","in-use","not-found"].includes(r),microphones:a,micState:r,refreshDevices:s,setCamera:d,setMicrophone:h,setSpeaker:g,speakers:l}},exports.useInputSettings=function(e){var t=void 0===e?{}:e,r=t.onError,o=t.onInputSettingsUpdated,a=i.useRecoilValue(D),u=i.useRecoilValue(M),c=v(),l=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(D,e)}}),[]);return n.useEffect((function(){c&&c.getInputSettings().then(l)}),[c,l]),m("input-settings-updated",n.useCallback((function(e){l(e.inputSettings),setTimeout((function(){return null==o?void 0:o(e)}),0)}),[o,l])),m("nonfatal-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){"input-settings-error"===e.type&&(t(M,e.errorMsg),setTimeout((function(){return null==r?void 0:r(e)}),0))}}),[r])),{errorMsg:u,inputSettings:a,updateInputSettings:n.useCallback((function(e){null==c||c.updateInputSettings(e)}),[c])}},exports.useLiveStreaming=function(e){var t=void 0===e?{}:e,r=t.onLiveStreamingError,o=t.onLiveStreamingStarted,a=t.onLiveStreamingStopped,u=v(),l=i.useRecoilValue(V);return m("live-streaming-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,{isLiveStreaming:!0,layout:null==e?void 0:e.layout}),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o])),m("live-streaming-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,(function(e){return c({},e,{isLiveStreaming:!1,layout:void 0})})),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a])),m("live-streaming-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(V,(function(t){return c({},t,{errorMsg:e.errorMsg})})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[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=N,exports.useMediaTrack=T,exports.useNetwork=function(e){var t=void 0===e?{}:e,r=t.onNetworkConnection,o=t.onNetworkQualityChange,a=v(),c=i.useRecoilValue(U),l=i.useRecoilValue(B),s=i.useRecoilValue(F),f=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;switch(e.event){case"connected":"peer-to-peer"===e.type&&n(U,"peer"),"sfu"===e.type&&n(U,"sfu")}})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[r]),d=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;n(B,(function(t){return t!==e.quality?e.quality:t})),n(F,(function(t){return t!==e.threshold?e.threshold:t}))})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o]);return m("network-connection",f),m("network-quality-change",d),{getStats:n.useCallback(u(p.mark((function e(){var t;return p.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,null==a?void 0:a.getNetworkStats();case 2:return e.abrupt("return",null==(t=e.sent)?void 0:t.stats);case 4:case"end":return e.stop()}}),e)}))),[a]),quality:l,threshold:s,topology:c}},exports.useParticipant=E,exports.useParticipantIds=W,exports.useReceiveSettings=function(e){var t=void 0===e?{}:e,r=t.id,o=void 0===r?"base":r,a=t.onReceiveSettingsUpdated,u=i.useRecoilValue(z("base")),l=i.useRecoilValue(z(o)),s=v();m("receive-settings-updated",i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){for(var n=t.reset,r=t.set,i=c({},e.receiveSettings),a=0,u=Object.entries(i);a<u.length;a++){var l=u[a],s=l[1];r(z(l[0]),s)}o in i||n(z(o))})),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[o,a]));var f=n.useCallback((function(e){s&&"joined-meeting"===s.meetingState()&&(null==s||null==s.updateReceiveSettings||s.updateReceiveSettings(e))}),[s]);return{receiveSettings:"base"===o||0===Object.keys(l).length?u:l,updateReceiveSettings:f}},exports.useRecording=function(e){var t=void 0===e?{}:e,r=t.onRecordingData,o=t.onRecordingError,a=t.onRecordingStarted,u=t.onRecordingStopped,l=v(),s=i.useRecoilValue(Q),f=i.useSetRecoilState(Q),d=N(),p=W({filter:"record"});return n.useEffect((function(){var e,t=p.length>0,n=p.includes(null!=(e=null==d?void 0:d.session_id)?e:"local");f((function(e){return c({},e,{isLocalParticipantRecorded:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isLocalParticipantRecorded:t,isRecording:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type?e.isRecording:t,local:"local"!==(null==e?void 0:e.type)&&null!=e&&e.type||!t?null==e?void 0:e.local:n,type:t?"local":null==e?void 0:e.type})}))}),[null==d?void 0:d.session_id,p,f]),m("recording-started",i.useRecoilCallback((function(e){var t=e.set;return function(e){var n=!0;switch(e.type){case"cloud-beta":case"cloud":var r;d&&"single-participant"===(null==(r=e.layout)?void 0:r.preset)&&e.layout.session_id!==(null==d?void 0:d.session_id)&&(n=!1)}t(Q,{error:!1,isLocalParticipantRecorded:n,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}),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[d,a])),m("recording-stopped",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(Q,(function(e){return c({},e,{isLocalParticipantRecorded:!1,isRecording:!1})})),setTimeout((function(){return null==u?void 0:u(e)}),0)}}),[u])),m("recording-error",i.useRecoilCallback((function(e){var t=e.set;return function(e){t(Q,(function(e){return c({},e,{error:!0,isLocalParticipantRecorded:!1,isRecording:!1})})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o])),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=function(){return i.useRecoilValue(x)},exports.useScreenAudioTrack=function(e){return T(e,"screenAudio")},exports.useScreenShare=function(e){var t=void 0===e?{}:e,r=t.onLocalScreenShareStarted,i=t.onLocalScreenShareStopped,o=v(),a=n.useCallback((function(e){null==o||o.startScreenShare(e)}),[o]),u=n.useCallback((function(){null==o||o.stopScreenShare()}),[o]);m("local-screen-share-started",n.useCallback((function(){return null==r?void 0:r()}),[r])),m("local-screen-share-stopped",n.useCallback((function(){return null==i?void 0:i()}),[i]));var c=W({filter:"screen"}),l=n.useMemo((function(){return c.map((function(e){var t,n=Object.values(null!=(t=null==o||null==o.participants?void 0:o.participants())?t:{}).find((function(t){return t.session_id===e}));if(n)return{local:n.local,screenAudio:n.tracks.screenAudio,screenVideo:n.tracks.screenVideo,screenId:e+"-screen",session_id:e}})).filter((function(e){return!!e}))}),[o,c]);return{isSharingScreen:l.some((function(e){return e.local})),screens:l,startScreenShare:a,stopScreenShare:u}},exports.useScreenVideoTrack=function(e){return T(e,"screenVideo")},exports.useThrottledDailyEvent=y,exports.useVideoTrack=function(e){return T(e,"video")},exports.useWaitingParticipants=function(e){var t=void 0===e?{}:e,r=t.onWaitingParticipantAdded,o=t.onWaitingParticipantRemoved,a=t.onWaitingParticipantUpdated,u=v(),c=i.useRecoilValue($),l=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.set;n(Y,(function(t){return t.includes(e.participant.id)?t:[].concat(t,[e.participant.id])})),n(J(e.participant.id),e.participant)})),setTimeout((function(){return null==r?void 0:r(e)}),0)}}),[r]),s=i.useRecoilCallback((function(e){var t=e.transact_UNSTABLE;return function(e){t((function(t){var n=t.reset;(0,t.set)(Y,(function(t){return t.filter((function(t){return t!==e.participant.id}))})),n(J(e.participant.id))})),setTimeout((function(){return null==o?void 0:o(e)}),0)}}),[o]),f=i.useRecoilCallback((function(e){var t=e.set;return function(e){t(J(e.participant.id),e.participant),setTimeout((function(){return null==a?void 0:a(e)}),0)}}),[a]);m("waiting-participant-added",l),m("waiting-participant-removed",s),m("waiting-participant-updated",f);var d=n.useCallback((function(e,t){"*"!==e?null==u||u.updateWaitingParticipant(e,{grantRequestedAccess:t}):null==u||u.updateWaitingParticipants({"*":{grantRequestedAccess:t}})}),[u]);return{waitingParticipants:c,grantAccess:n.useCallback((function(e){d(e,!0)}),[d]),denyAccess:n.useCallback((function(e){d(e,!1)}),[d])}}; | ||
//# sourceMappingURL=daily-react-hooks.cjs.production.min.js.map |
{ | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"license": "BSD-2-Clause", | ||
@@ -4,0 +4,0 @@ "keywords": [ |
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
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
779559
7712