| 1 |
- "use strict";(self.webpackChunkfront=self.webpackChunkfront||[]).push([[921],{5984:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resetSubscribers=t.removeSubscriber=t.addSubscriber=t.hasSubscribers=t.getSubscribers=void 0;var r={},n=[];t.getSubscribers=function(e){return(0,t.hasSubscribers)(e)?Array.from(r[e]):n},t.hasSubscribers=function(e){var t;return(null===(t=r[e])||void 0===t?void 0:t.size)>0},t.addSubscriber=function(e,t){r[e]=r[e]||new Set,r[e].add(t)},t.removeSubscriber=function(e,t){r[e].delete(t)},t.resetSubscribers=function(e){if(e&&r.hasOwnProperty(e))delete r[e];else for(var t in r)r.hasOwnProperty(t)&&delete r[t]}},16421:function(e,t,r){var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,c){function u(e){try{s(n.next(e))}catch(e){c(e)}}function a(e){try{s(n.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,a)}s((n=n.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var r,n,o,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},c=this&&this.__spreadArray||function(e,t,r){if(r||2===arguments.length)for(var n,o=0,c=t.length;o<c;o++)!n&&o in t||(n||(n=Array.prototype.slice.call(t,0,o)),n[o]=t[o]);return e.concat(n||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.getUrl=void 0;var u=r(99789),a=r(29800);t.getUrl=function(e,r){for(var s=[],i=2;i<arguments.length;i++)s[i-2]=arguments[i];return n(void 0,c([e,r],s,!0),void 0,(function(e,r,n){var c,s,i,l,f,d,p;return void 0===n&&(n=0),o(this,(function(o){switch(o.label){case 0:if("function"!=typeof e)return[3,10];o.label=1;case 1:return o.trys.push([1,3,,9]),[4,e()];case 2:return c=o.sent(),[3,9];case 3:return o.sent(),r.current.retryOnError?(s=null!==(f=r.current.reconnectAttempts)&&void 0!==f?f:a.DEFAULT_RECONNECT_LIMIT,n<s?(i="function"==typeof r.current.reconnectInterval?r.current.reconnectInterval(n):r.current.reconnectInterval,[4,(v=null!=i?i:a.DEFAULT_RECONNECT_INTERVAL_MS,new Promise((function(e){return window.setTimeout(e,v)})))]):[3,5]):[3,7];case 4:return o.sent(),[2,(0,t.getUrl)(e,r,n+1)];case 5:return null===(p=(d=r.current).onReconnectStop)||void 0===p||p.call(d,n),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:c=e,o.label=11;case 11:return l=r.current.fromSocketIO?(0,u.parseSocketIOUrl)(c):c,[2,r.current.queryParams?(0,u.appendQueryParams)(l,r.current.queryParams):l]}var v}))}))}},18049:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.attachListeners=void 0;var o=r(99789),c=r(87889),u=r(29800),a=r(81001);t.attachListeners=function(e,t,r,s,i,l,f){var d,p,v,S=t.setLastMessage,b=t.setReadyState;return r.current.fromSocketIO&&(d=(0,o.setUpSocketIOPing)(f)),function(e,t,r,n){e.onmessage=function(e){var o;t.current.onMessage&&t.current.onMessage(e),"number"==typeof(null==n?void 0:n.current)&&(n.current=Date.now()),"function"==typeof t.current.filter&&!0!==t.current.filter(e)||t.current.heartbeat&&"boolean"!=typeof t.current.heartbeat&&(null===(o=t.current.heartbeat)||void 0===o?void 0:o.returnMessage)===e.data||r(e)}}(e,r,S,l),function(e,t,r,n,o){e.onopen=function(a){if(t.current.onOpen&&t.current.onOpen(a),n.current=0,r(u.ReadyState.OPEN),t.current.heartbeat&&e instanceof WebSocket){var s="boolean"==typeof t.current.heartbeat?void 0:t.current.heartbeat;o.current=Date.now(),(0,c.heartbeat)(e,o,s)}}}(e,r,b,i,l),p=function(e,t,r,n,o){return u.isEventSourceSupported&&e instanceof EventSource?function(){}:((0,a.assertIsWebSocket)(e,t.current.skipAssert),e.onclose=function(e){var a;if(t.current.onClose&&t.current.onClose(e),r(u.ReadyState.CLOSED),t.current.shouldReconnect&&t.current.shouldReconnect(e)){var s=null!==(a=t.current.reconnectAttempts)&&void 0!==a?a:u.DEFAULT_RECONNECT_LIMIT;if(o.current<s){var i="function"==typeof t.current.reconnectInterval?t.current.reconnectInterval(o.current):t.current.reconnectInterval;c=window.setTimeout((function(){o.current++,n()}),null!=i?i:u.DEFAULT_RECONNECT_INTERVAL_MS)}else t.current.onReconnectStop&&t.current.onReconnectStop(s),console.warn("Max reconnect attempts of ".concat(s," exceeded"))}},function(){return c&&window.clearTimeout(c)});var c}(e,r,b,s,i),v=function(e,t,r,o,c){var a;return e.onerror=function(s){var i;if(t.current.onError&&t.current.onError(s),u.isEventSourceSupported&&e instanceof EventSource&&(t.current.onClose&&t.current.onClose(n(n({},s),{code:1006,reason:"An error occurred with the EventSource: ".concat(s),wasClean:!1})),r(u.ReadyState.CLOSED),e.close()),t.current.retryOnError)if(c.current<(null!==(i=t.current.reconnectAttempts)&&void 0!==i?i:u.DEFAULT_RECONNECT_LIMIT)){var l="function"==typeof t.current.reconnectInterval?t.current.reconnectInterval(c.current):t.current.reconnectInterval;a=window.setTimeout((function(){c.current++,o()}),null!=l?l:u.DEFAULT_RECONNECT_INTERVAL_MS)}else t.current.onReconnectStop&&t.current.onReconnectStop(t.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(t.current.reconnectAttempts," exceeded"))},function(){return a&&window.clearTimeout(a)}}(e,r,b,s,i),function(){b(u.ReadyState.CLOSING),p(),v(),e.close(),d&&clearInterval(d)}}},18389:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.resetWebSockets=t.sharedWebSockets=void 0,t.sharedWebSockets={},t.resetWebSockets=function(e){if(e&&t.sharedWebSockets.hasOwnProperty(e))delete t.sharedWebSockets[e];else for(var r in t.sharedWebSockets)t.sharedWebSockets.hasOwnProperty(r)&&delete t.sharedWebSockets[r]}},21881:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.websocketWrapper=void 0,t.websocketWrapper=function(e,t){return new Proxy(e,{get:function(e,r){var n=e[r];return"reconnect"===r?t:"function"==typeof n?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):n},set:function(e,t,r){return/^on/.test(t)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(e[t]=r,!0)}})},t.default=t.websocketWrapper},29800:(e,t)=>{var r;Object.defineProperty(t,"__esModule",{value:!0}),t.isEventSourceSupported=t.isReactNative=t.ReadyState=t.DEFAULT_HEARTBEAT=t.UNPARSABLE_JSON_OBJECT=t.DEFAULT_RECONNECT_INTERVAL_MS=t.DEFAULT_RECONNECT_LIMIT=t.SOCKET_IO_PING_CODE=t.SOCKET_IO_PATH=t.SOCKET_IO_PING_INTERVAL=t.DEFAULT_EVENT_SOURCE_OPTIONS=t.EMPTY_EVENT_HANDLERS=t.DEFAULT_OPTIONS=void 0,t.DEFAULT_OPTIONS={},t.EMPTY_EVENT_HANDLERS={},t.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:t.EMPTY_EVENT_HANDLERS},t.SOCKET_IO_PING_INTERVAL=25e3,t.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",t.SOCKET_IO_PING_CODE="2",t.DEFAULT_RECONNECT_LIMIT=20,t.DEFAULT_RECONNECT_INTERVAL_MS=5e3,t.UNPARSABLE_JSON_OBJECT={},t.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3},function(e){e[e.UNINSTANTIATED=-1]="UNINSTANTIATED",e[e.CONNECTING=0]="CONNECTING",e[e.OPEN=1]="OPEN",e[e.CLOSING=2]="CLOSING",e[e.CLOSED=3]="CLOSED"}(r||(t.ReadyState=r={})),t.isReactNative="undefined"!=typeof navigator&&"ReactNative"===navigator.product,t.isEventSourceSupported=!t.isReactNative&&function(){try{return"EventSource"in globalThis}catch(e){return!1}}()},44921:(e,t,r)=>{t.Ay=void 0;var n=r(91380);Object.defineProperty(t,"Ay",{enumerable:!0,get:function(){return n.useWebSocket}});r(47407),r(29800),r(69797),r(81001)},45784:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.attachSharedListeners=void 0;var o=r(18389),c=r(29800),u=r(5984),a=r(99789),s=r(87889);t.attachSharedListeners=function(e,t,r,i){var l;return r.current.fromSocketIO&&(l=(0,a.setUpSocketIOPing)(i)),function(e,t,r){e.onmessage=function(e){(0,u.getSubscribers)(t).forEach((function(t){var n;t.optionsRef.current.onMessage&&t.optionsRef.current.onMessage(e),"number"==typeof(null===(n=null==t?void 0:t.lastMessageTime)||void 0===n?void 0:n.current)&&(t.lastMessageTime.current=Date.now()),"function"==typeof t.optionsRef.current.filter&&!0!==t.optionsRef.current.filter(e)||r&&"boolean"!=typeof r&&(null==r?void 0:r.returnMessage)===e.data||t.setLastMessage(e)}))}}(e,t,r.current.heartbeat),function(e,t){e instanceof WebSocket&&(e.onclose=function(e){(0,u.getSubscribers)(t).forEach((function(t){t.optionsRef.current.onClose&&t.optionsRef.current.onClose(e),t.setReadyState(c.ReadyState.CLOSED)})),delete o.sharedWebSockets[t],(0,u.getSubscribers)(t).forEach((function(t){var r;if(t.optionsRef.current.shouldReconnect&&t.optionsRef.current.shouldReconnect(e)){var n=null!==(r=t.optionsRef.current.reconnectAttempts)&&void 0!==r?r:c.DEFAULT_RECONNECT_LIMIT;if(t.reconnectCount.current<n){var o="function"==typeof t.optionsRef.current.reconnectInterval?t.optionsRef.current.reconnectInterval(t.reconnectCount.current):t.optionsRef.current.reconnectInterval;setTimeout((function(){t.reconnectCount.current++,t.reconnect.current()}),null!=o?o:c.DEFAULT_RECONNECT_INTERVAL_MS)}else t.optionsRef.current.onReconnectStop&&t.optionsRef.current.onReconnectStop(t.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(n," exceeded"))}}))})}(e,t),function(e,t,r){e.onopen=function(n){var o=(0,u.getSubscribers)(t);o.forEach((function(t){t.reconnectCount.current=0,t.optionsRef.current.onOpen&&t.optionsRef.current.onOpen(n),t.setReadyState(c.ReadyState.OPEN),r&&e instanceof WebSocket&&(t.lastMessageTime.current=Date.now())})),r&&e instanceof WebSocket&&(0,s.heartbeat)(e,o.map((function(e){return e.lastMessageTime})),"boolean"==typeof r?void 0:r)}}(e,t,r.current.heartbeat),function(e,t){e.onerror=function(r){(0,u.getSubscribers)(t).forEach((function(t){t.optionsRef.current.onError&&t.optionsRef.current.onError(r),c.isEventSourceSupported&&e instanceof EventSource&&(t.optionsRef.current.onClose&&t.optionsRef.current.onClose(n(n({},r),{code:1006,reason:"An error occurred with the EventSource: ".concat(r),wasClean:!1})),t.setReadyState(c.ReadyState.CLOSED))})),c.isEventSourceSupported&&e instanceof EventSource&&e.close()}}(e,t),function(){l&&clearInterval(l)}}},47407:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.useSocketIO=void 0;var o=r(96540),c=r(91380),u=r(29800),a={type:"empty",payload:null};t.useSocketIO=function(e,t,r){void 0===t&&(t=u.DEFAULT_OPTIONS),void 0===r&&(r=!0);var s=(0,o.useMemo)((function(){return n(n({},t),{fromSocketIO:!0})}),[]),i=(0,c.useWebSocket)(e,s,r),l=i.sendMessage,f=i.sendJsonMessage,d=i.lastMessage,p=i.readyState,v=i.getWebSocket,S=(0,o.useMemo)((function(){return function(e){if(!e||!e.data)return a;var t=e.data.match(/\[.*]/);if(!t)return a;var r=JSON.parse(t);return Array.isArray(r)&&r[1]?{type:r[0],payload:r[1]}:a}(d)}),[d]);return{sendMessage:l,sendJsonMessage:f,lastMessage:S,lastJsonMessage:S,readyState:p,getWebSocket:v}}},62604:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createOrJoinSocket=void 0;var n=r(18389),o=r(29800),c=r(18049),u=r(45784),a=r(5984);t.createOrJoinSocket=function(e,t,r,s,i,l,f,d,p){if(!o.isEventSourceSupported&&s.current.eventSourceOptions)throw o.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(s.current.share){var v=null;void 0===n.sharedWebSockets[t]?(n.sharedWebSockets[t]=s.current.eventSourceOptions?new EventSource(t,s.current.eventSourceOptions):new WebSocket(t,s.current.protocols),e.current=n.sharedWebSockets[t],r(o.ReadyState.CONNECTING),v=(0,u.attachSharedListeners)(n.sharedWebSockets[t],t,s,p)):(e.current=n.sharedWebSockets[t],r(n.sharedWebSockets[t].readyState));var S={setLastMessage:i,setReadyState:r,optionsRef:s,reconnectCount:f,lastMessageTime:d,reconnect:l};return(0,a.addSubscriber)(t,S),function(e,t,r,c,u){return function(){if((0,a.removeSubscriber)(e,t),!(0,a.hasSubscribers)(e)){try{var s=n.sharedWebSockets[e];s instanceof WebSocket&&(s.onclose=function(e){r.current.onClose&&r.current.onClose(e),c(o.ReadyState.CLOSED)}),s.close()}catch(e){}u&&u(),delete n.sharedWebSockets[e]}}}(t,S,s,r,v)}if(e.current=s.current.eventSourceOptions?new EventSource(t,s.current.eventSourceOptions):new WebSocket(t,s.current.protocols),r(o.ReadyState.CONNECTING),!e.current)throw new Error("WebSocket failed to be created");return(0,c.attachListeners)(e.current,{setLastMessage:i,setReadyState:r},s,l.current,f,d,p)}},69797:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__rest||function(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(e);o<n.length;o++)t.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(e,n[o])&&(r[n[o]]=e[n[o]])}return r};Object.defineProperty(t,"__esModule",{value:!0}),t.useEventSource=void 0;var c=r(96540),u=r(91380),a=r(29800);t.useEventSource=function(e,t,r){void 0===t&&(t=a.DEFAULT_EVENT_SOURCE_OPTIONS);var s=t.withCredentials,i=t.events,l=o(t,["withCredentials","events"]);void 0===r&&(r=!0);var f=n(n({},l),{eventSourceOptions:{withCredentials:s}}),d=(0,c.useRef)(a.EMPTY_EVENT_HANDLERS);i&&(d.current=i);var p=(0,u.useWebSocket)(e,f,r),v=p.lastMessage,S=p.readyState,b=p.getWebSocket;return(0,c.useEffect)((function(){(null==v?void 0:v.type)&&Object.entries(d.current).forEach((function(e){var t=e[0],r=e[1];t===v.type&&r(v)}))}),[v]),{lastEvent:v,readyState:S,getEventSource:b}}},81001:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.assertIsWebSocket=function(e,t){if(!t&&e instanceof WebSocket==0)throw new Error("")},t.resetGlobalState=function(e){(0,o.resetSubscribers)(e),(0,n.resetWebSockets)(e)};var n=r(18389),o=r(5984)},87889:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.heartbeat=function(e,t,r){var o=r||{},c=o.interval,u=void 0===c?n.DEFAULT_HEARTBEAT.interval:c,a=o.timeout,s=void 0===a?n.DEFAULT_HEARTBEAT.timeout:a,i=o.message,l=void 0===i?n.DEFAULT_HEARTBEAT.message:i,f=Math.max(100,u/10),d=Date.now(),p=setInterval((function(){var r=Date.now(),n=function(e){return Array.isArray(e)?e.reduce((function(e,t){return e.current>t.current?e:t})).current:e.current}(t);if(n+s<=r)console.warn("Heartbeat timed out, closing connection, last message received ".concat(r-n,"ms ago, last ping sent ").concat(r-d,"ms ago")),e.close();else if(n+u<=r&&d+u<=r)try{"function"==typeof l?e.send(l()):e.send(l),d=r}catch(t){console.error("Heartbeat failed, closing connection",t instanceof Error?t.message:t),e.close()}}),f);return e.addEventListener("close",(function(){clearInterval(p)})),function(){}};var n=r(29800)},91380:function(e,t,r){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r<n;r++)for(var o in t=arguments[r])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(o,c){function u(e){try{s(n.next(e))}catch(e){c(e)}}function a(e){try{s(n.throw(e))}catch(e){c(e)}}function s(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(u,a)}s((n=n.apply(e,t||[])).next())}))},c=this&&this.__generator||function(e,t){var r,n,o,c={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},u=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return u.next=a(0),u.throw=a(1),u.return=a(2),"function"==typeof Symbol&&(u[Symbol.iterator]=function(){return this}),u;function a(a){return function(s){return function(a){if(r)throw new TypeError("Generator is already executing.");for(;u&&(u=0,a[0]&&(c=0)),c;)try{if(r=1,n&&(o=2&a[0]?n.return:a[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,a[1])).done)return o;switch(n=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return c.label++,{value:a[1],done:!1};case 5:c.label++,n=a[1],a=[0];continue;case 7:a=c.ops.pop(),c.trys.pop();continue;default:if(!((o=(o=c.trys).length>0&&o[o.length-1])||6!==a[0]&&2!==a[0])){c=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){c.label=a[1];break}if(6===a[0]&&c.label<o[1]){c.label=o[1],o=a;break}if(o&&c.label<o[2]){c.label=o[2],c.ops.push(a);break}o[2]&&c.ops.pop(),c.trys.pop();continue}a=t.call(e,c)}catch(e){a=[6,e],n=0}finally{r=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,s])}}},u=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.useWebSocket=void 0;var a=r(96540),s=r(40961),i=r(29800),l=r(62604),f=r(16421),d=u(r(21881)),p=r(81001);t.useWebSocket=function(e,t,r){void 0===t&&(t=i.DEFAULT_OPTIONS),void 0===r&&(r=!0);var u=(0,a.useState)(null),v=u[0],S=u[1],b=(0,a.useState)({}),E=b[0],h=b[1],O=(0,a.useMemo)((function(){if(!t.disableJson&&v)try{return JSON.parse(v.data)}catch(e){return i.UNPARSABLE_JSON_OBJECT}return null}),[v,t.disableJson]),y=(0,a.useRef)(null),_=(0,a.useRef)(null),T=(0,a.useRef)((function(){})),R=(0,a.useRef)(0),w=(0,a.useRef)(Date.now()),N=(0,a.useRef)([]),g=(0,a.useRef)(null),I=(0,a.useRef)(t);I.current=t;var C=y.current&&void 0!==E[y.current]?E[y.current]:null!==e&&!0===r?i.ReadyState.CONNECTING:i.ReadyState.UNINSTANTIATED,A=t.queryParams?JSON.stringify(t.queryParams):null,k=(0,a.useCallback)((function(e,t){var r;void 0===t&&(t=!0),i.isEventSourceSupported&&_.current instanceof EventSource?console.warn("Unable to send a message from an eventSource"):(null===(r=_.current)||void 0===r?void 0:r.readyState)===i.ReadyState.OPEN?((0,p.assertIsWebSocket)(_.current,I.current.skipAssert),_.current.send(e)):t&&N.current.push(e)}),[]),m=(0,a.useCallback)((function(e,t){void 0===t&&(t=!0),k(JSON.stringify(e),t)}),[k]),P=(0,a.useCallback)((function(){return!0!==I.current.share||i.isEventSourceSupported&&_.current instanceof EventSource?_.current:(null===g.current&&_.current&&((0,p.assertIsWebSocket)(_.current,I.current.skipAssert),g.current=(0,d.default)(_.current,T)),g.current)}),[]);return(0,a.useEffect)((function(){if(null!==e&&!0===r){var t,u=!1,a=!0,d=function(){return o(void 0,void 0,void 0,(function(){var r,o,d;return c(this,(function(c){switch(c.label){case 0:return r=y,[4,(0,f.getUrl)(e,I)];case 1:return r.current=c.sent(),null===y.current?(console.error("Failed to get a valid URL. WebSocket connection aborted."),y.current="ABORTED",(0,s.flushSync)((function(){return h((function(e){return n(n({},e),{ABORTED:i.ReadyState.CLOSED})}))})),[2]):(o=function(e){u||(0,s.flushSync)((function(){return S(e)}))},d=function(e){u||(0,s.flushSync)((function(){return h((function(t){var r;return n(n({},t),y.current&&((r={})[y.current]=e,r))}))}))},a&&(t=(0,l.createOrJoinSocket)(_,y.current,d,I,o,T,R,w,k)),[2])}}))}))};return T.current=function(){u||(g.current&&(g.current=null),null==t||t(),d())},d(),function(){u=!0,a=!1,g.current&&(g.current=null),null==t||t(),S(null)}}null!==e&&!1!==r||(R.current=0,h((function(e){var t;return n(n({},e),y.current&&((t={})[y.current]=i.ReadyState.CLOSED,t))})))}),[e,r,A,k]),(0,a.useEffect)((function(){C===i.ReadyState.OPEN&&N.current.splice(0).forEach((function(e){k(e)}))}),[C]),{sendMessage:k,sendJsonMessage:m,lastMessage:v,lastJsonMessage:O,readyState:C,getWebSocket:P}}},99789:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.setUpSocketIOPing=t.appendQueryParams=t.parseSocketIOUrl=void 0;var n=r(29800);t.parseSocketIOUrl=function(e){if(e){var t=/^https|wss/.test(e),r=e.replace(/^(https?|wss?)(:\/\/)?/,"").replace(/\/$/,"");return"".concat(o=t?"wss":"ws","://").concat(r).concat(n.SOCKET_IO_PATH)}if(""===e){var o=(t=/^https/.test(window.location.protocol))?"wss":"ws",c=window.location.port?":".concat(window.location.port):"";return"".concat(o,"://").concat(window.location.hostname).concat(c).concat(n.SOCKET_IO_PATH)}return e},t.appendQueryParams=function(e,t){void 0===t&&(t={});var r=/\?([\w]+=[\w]+)/.test(e),n="".concat(Object.entries(t).reduce((function(e,t){var r=t[0],n=t[1];return e+"".concat(r,"=").concat(n,"&")}),"").slice(0,-1));return"".concat(e).concat(r?"&":"?").concat(n)},t.setUpSocketIOPing=function(e,t){return void 0===t&&(t=n.SOCKET_IO_PING_INTERVAL),window.setInterval((function(){return e(n.SOCKET_IO_PING_CODE)}),t)}}}]);
|