@obb871001/api-integration-sdk 1.0.55 → 1.0.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +7 -7
- package/dist/index.js +1034 -974
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`+Q+
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const M=require("react"),$=require("@tanstack/react-query"),tt=require("axios"),R=require("lodash"),nt=require("react-dom");function at(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var we={exports:{}},Se={};var sr;function ut(){if(sr)return Se;sr=1;var e=M,l=Symbol.for("react.element"),h=Symbol.for("react.fragment"),E=Object.prototype.hasOwnProperty,f=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,y={key:!0,ref:!0,__self:!0,__source:!0};function _(d,o,s){var u,n={},i=null,a=null;s!==void 0&&(i=""+s),o.key!==void 0&&(i=""+o.key),o.ref!==void 0&&(a=o.ref);for(u in o)E.call(o,u)&&!y.hasOwnProperty(u)&&(n[u]=o[u]);if(d&&d.defaultProps)for(u in o=d.defaultProps,o)n[u]===void 0&&(n[u]=o[u]);return{$$typeof:l,type:d,key:i,ref:a,props:n,_owner:f.current}}return Se.Fragment=h,Se.jsx=_,Se.jsxs=_,Se}var _e={};var lr;function ot(){return lr||(lr=1,process.env.NODE_ENV!=="production"&&(function(){var e=M,l=Symbol.for("react.element"),h=Symbol.for("react.portal"),E=Symbol.for("react.fragment"),f=Symbol.for("react.strict_mode"),y=Symbol.for("react.profiler"),_=Symbol.for("react.provider"),d=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),s=Symbol.for("react.suspense"),u=Symbol.for("react.suspense_list"),n=Symbol.for("react.memo"),i=Symbol.for("react.lazy"),a=Symbol.for("react.offscreen"),t=Symbol.iterator,S="@@iterator";function b(r){if(r===null||typeof r!="object")return null;var v=t&&r[t]||r[S];return typeof v=="function"?v:null}var c=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function m(r){{for(var v=arguments.length,g=new Array(v>1?v-1:0),p=1;p<v;p++)g[p-1]=arguments[p];A("error",r,g)}}function A(r,v,g){{var p=c.ReactDebugCurrentFrame,w=p.getStackAddendum();w!==""&&(v+="%s",g=g.concat([w]));var N=g.map(function(C){return String(C)});N.unshift("Warning: "+v),Function.prototype.apply.call(console[r],console,N)}}var k=!1,O=!1,P=!1,I=!1,de=!1,ve;ve=Symbol.for("react.module.reference");function ke(r){return!!(typeof r=="string"||typeof r=="function"||r===E||r===y||de||r===f||r===s||r===u||I||r===a||k||O||P||typeof r=="object"&&r!==null&&(r.$$typeof===i||r.$$typeof===n||r.$$typeof===_||r.$$typeof===d||r.$$typeof===o||r.$$typeof===ve||r.getModuleId!==void 0))}function ge(r,v,g){var p=r.displayName;if(p)return p;var w=v.displayName||v.name||"";return w!==""?g+"("+w+")":g}function H(r){return r.displayName||"Context"}function j(r){if(r==null)return null;if(typeof r.tag=="number"&&m("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof r=="function")return r.displayName||r.name||null;if(typeof r=="string")return r;switch(r){case E:return"Fragment";case h:return"Portal";case y:return"Profiler";case f:return"StrictMode";case s:return"Suspense";case u:return"SuspenseList"}if(typeof r=="object")switch(r.$$typeof){case d:var v=r;return H(v)+".Consumer";case _:var g=r;return H(g._context)+".Provider";case o:return ge(r,r.render,"ForwardRef");case n:var p=r.displayName||null;return p!==null?p:j(r.type)||"Memo";case i:{var w=r,N=w._payload,C=w._init;try{return j(C(N))}catch{return null}}}return null}var B=Object.assign,re=0,K,pe,Oe,U,W,Y,ye;function te(){}te.__reactDisabledLog=!0;function ee(){{if(re===0){K=console.log,pe=console.info,Oe=console.warn,U=console.error,W=console.group,Y=console.groupCollapsed,ye=console.groupEnd;var r={configurable:!0,enumerable:!0,value:te,writable:!0};Object.defineProperties(console,{info:r,log:r,warn:r,error:r,group:r,groupCollapsed:r,groupEnd:r})}re++}}function Te(){{if(re--,re===0){var r={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:B({},r,{value:K}),info:B({},r,{value:pe}),warn:B({},r,{value:Oe}),error:B({},r,{value:U}),group:B({},r,{value:W}),groupCollapsed:B({},r,{value:Y}),groupEnd:B({},r,{value:ye})})}re<0&&m("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ie=c.ReactCurrentDispatcher,Q;function se(r,v,g){{if(Q===void 0)try{throw Error()}catch(w){var p=w.stack.trim().match(/\n( *(at )?)/);Q=p&&p[1]||""}return`
|
|
2
|
+
`+Q+r}}var ne=!1,Ce;{var Nr=typeof WeakMap=="function"?WeakMap:Map;Ce=new Nr}function Ke(r,v){if(!r||ne)return"";{var g=Ce.get(r);if(g!==void 0)return g}var p;ne=!0;var w=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var N;N=ie.current,ie.current=null,ee();try{if(v){var C=function(){throw Error()};if(Object.defineProperty(C.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(C,[])}catch(q){p=q}Reflect.construct(r,[],C)}else{try{C.call()}catch(q){p=q}r.call(C.prototype)}}else{try{throw Error()}catch(q){p=q}r()}}catch(q){if(q&&p&&typeof q.stack=="string"){for(var T=q.stack.split(`
|
|
3
3
|
`),F=p.stack.split(`
|
|
4
|
-
`),
|
|
5
|
-
`+T[
|
|
4
|
+
`),D=T.length-1,L=F.length-1;D>=1&&L>=0&&T[D]!==F[L];)L--;for(;D>=1&&L>=0;D--,L--)if(T[D]!==F[L]){if(D!==1||L!==1)do if(D--,L--,L<0||T[D]!==F[L]){var J=`
|
|
5
|
+
`+T[D].replace(" at new "," at ");return r.displayName&&J.includes("<anonymous>")&&(J=J.replace("<anonymous>",r.displayName)),typeof r=="function"&&Ce.set(r,J),J}while(D>=1&&L>=0);break}}}finally{ne=!1,ie.current=N,Te(),Error.prepareStackTrace=w}var fe=r?r.displayName||r.name:"",ae=fe?se(fe):"";return typeof r=="function"&&Ce.set(r,ae),ae}function Ir(r,v,g){return Ke(r,!1)}function Mr(r){var v=r.prototype;return!!(v&&v.isReactComponent)}function Re(r,v,g){if(r==null)return"";if(typeof r=="function")return Ke(r,Mr(r));if(typeof r=="string")return se(r);switch(r){case s:return se("Suspense");case u:return se("SuspenseList")}if(typeof r=="object")switch(r.$$typeof){case o:return Ir(r.render);case n:return Re(r.type,v,g);case i:{var p=r,w=p._payload,N=p._init;try{return Re(N(w),v,g)}catch{}}}return""}var Ee=Object.prototype.hasOwnProperty,Ye={},Qe=c.ReactDebugCurrentFrame;function Ae(r){if(r){var v=r._owner,g=Re(r.type,r._source,v?v.type:null);Qe.setExtraStackFrame(g)}else Qe.setExtraStackFrame(null)}function Dr(r,v,g,p,w){{var N=Function.call.bind(Ee);for(var C in r)if(N(r,C)){var T=void 0;try{if(typeof r[C]!="function"){var F=Error((p||"React class")+": "+g+" type `"+C+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof r[C]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw F.name="Invariant Violation",F}T=r[C](v,C,p,g,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(D){T=D}T&&!(T instanceof Error)&&(Ae(w),m("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",p||"React class",g,C,typeof T),Ae(null)),T instanceof Error&&!(T.message in Ye)&&(Ye[T.message]=!0,Ae(w),m("Failed %s type: %s",g,T.message),Ae(null))}}}var Lr=Array.isArray;function Ne(r){return Lr(r)}function Ur(r){{var v=typeof Symbol=="function"&&Symbol.toStringTag,g=v&&r[Symbol.toStringTag]||r.constructor.name||"Object";return g}}function jr(r){try{return ze(r),!1}catch{return!0}}function ze(r){return""+r}function Xe(r){if(jr(r))return m("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Ur(r)),ze(r)}var Ze=c.ReactCurrentOwner,Wr={key:!0,ref:!0,__self:!0,__source:!0},er,rr;function Fr(r){if(Ee.call(r,"ref")){var v=Object.getOwnPropertyDescriptor(r,"ref").get;if(v&&v.isReactWarning)return!1}return r.ref!==void 0}function qr(r){if(Ee.call(r,"key")){var v=Object.getOwnPropertyDescriptor(r,"key").get;if(v&&v.isReactWarning)return!1}return r.key!==void 0}function Gr(r,v){typeof r.ref=="string"&&Ze.current}function Jr(r,v){{var g=function(){er||(er=!0,m("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",v))};g.isReactWarning=!0,Object.defineProperty(r,"key",{get:g,configurable:!0})}}function Br(r,v){{var g=function(){rr||(rr=!0,m("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",v))};g.isReactWarning=!0,Object.defineProperty(r,"ref",{get:g,configurable:!0})}}var Hr=function(r,v,g,p,w,N,C){var T={$$typeof:l,type:r,key:v,ref:g,props:C,_owner:N};return T._store={},Object.defineProperty(T._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(T,"_self",{configurable:!1,enumerable:!1,writable:!1,value:p}),Object.defineProperty(T,"_source",{configurable:!1,enumerable:!1,writable:!1,value:w}),Object.freeze&&(Object.freeze(T.props),Object.freeze(T)),T};function Vr(r,v,g,p,w){{var N,C={},T=null,F=null;g!==void 0&&(Xe(g),T=""+g),qr(v)&&(Xe(v.key),T=""+v.key),Fr(v)&&(F=v.ref,Gr(v,w));for(N in v)Ee.call(v,N)&&!Wr.hasOwnProperty(N)&&(C[N]=v[N]);if(r&&r.defaultProps){var D=r.defaultProps;for(N in D)C[N]===void 0&&(C[N]=D[N])}if(T||F){var L=typeof r=="function"?r.displayName||r.name||"Unknown":r;T&&Jr(C,L),F&&Br(C,L)}return Hr(r,T,F,w,p,Ze.current,C)}}var Ie=c.ReactCurrentOwner,tr=c.ReactDebugCurrentFrame;function le(r){if(r){var v=r._owner,g=Re(r.type,r._source,v?v.type:null);tr.setExtraStackFrame(g)}else tr.setExtraStackFrame(null)}var Me;Me=!1;function De(r){return typeof r=="object"&&r!==null&&r.$$typeof===l}function nr(){{if(Ie.current){var r=j(Ie.current.type);if(r)return`
|
|
6
6
|
|
|
7
|
-
Check the render method of \``+
|
|
7
|
+
Check the render method of \``+r+"`."}return""}}function $r(r){return""}var ar={};function xr(r){{var v=nr();if(!v){var g=typeof r=="string"?r:r.displayName||r.name;g&&(v=`
|
|
8
8
|
|
|
9
|
-
Check the top-level render call using <`+g+">.")}return
|
|
9
|
+
Check the top-level render call using <`+g+">.")}return v}}function ur(r,v){{if(!r._store||r._store.validated||r.key!=null)return;r._store.validated=!0;var g=xr(v);if(ar[g])return;ar[g]=!0;var p="";r&&r._owner&&r._owner!==Ie.current&&(p=" It was passed a child from "+j(r._owner.type)+"."),le(r),m('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',g,p),le(null)}}function or(r,v){{if(typeof r!="object")return;if(Ne(r))for(var g=0;g<r.length;g++){var p=r[g];De(p)&&ur(p,v)}else if(De(r))r._store&&(r._store.validated=!0);else if(r){var w=b(r);if(typeof w=="function"&&w!==r.entries)for(var N=w.call(r),C;!(C=N.next()).done;)De(C.value)&&ur(C.value,v)}}}function Kr(r){{var v=r.type;if(v==null||typeof v=="string")return;var g;if(typeof v=="function")g=v.propTypes;else if(typeof v=="object"&&(v.$$typeof===o||v.$$typeof===n))g=v.propTypes;else return;if(g){var p=j(v);Dr(g,r.props,"prop",p,r)}else if(v.PropTypes!==void 0&&!Me){Me=!0;var w=j(v);m("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",w||"Unknown")}typeof v.getDefaultProps=="function"&&!v.getDefaultProps.isReactClassApproved&&m("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Yr(r){{for(var v=Object.keys(r.props),g=0;g<v.length;g++){var p=v[g];if(p!=="children"&&p!=="key"){le(r),m("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",p),le(null);break}}r.ref!==null&&(le(r),m("Invalid attribute `ref` supplied to `React.Fragment`."),le(null))}}var cr={};function ir(r,v,g,p,w,N){{var C=ke(r);if(!C){var T="";(r===void 0||typeof r=="object"&&r!==null&&Object.keys(r).length===0)&&(T+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var F=$r();F?T+=F:T+=nr();var D;r===null?D="null":Ne(r)?D="array":r!==void 0&&r.$$typeof===l?(D="<"+(j(r.type)||"Unknown")+" />",T=" Did you accidentally export a JSX literal instead of a component?"):D=typeof r,m("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",D,T)}var L=Vr(r,v,g,w,N);if(L==null)return L;if(C){var J=v.children;if(J!==void 0)if(p)if(Ne(J)){for(var fe=0;fe<J.length;fe++)or(J[fe],r);Object.freeze&&Object.freeze(J)}else m("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else or(J,r)}if(Ee.call(v,"key")){var ae=j(r),q=Object.keys(v).filter(function(rt){return rt!=="key"}),Le=q.length>0?"{key: someKey, "+q.join(": ..., ")+": ...}":"{key: someKey}";if(!cr[ae+Le]){var et=q.length>0?"{"+q.join(": ..., ")+": ...}":"{}";m(`A props object containing a "key" prop is being spread into JSX:
|
|
10
10
|
let props = %s;
|
|
11
11
|
<%s {...props} />
|
|
12
12
|
React keys must be passed directly to JSX without using spread:
|
|
13
13
|
let props = %s;
|
|
14
|
-
<%s key={someKey} {...props} />`,De,ae,Zr,ae),cr[ae+De]=!0}}return e===E?Kr(D):Br(D),D}}function Yr(e,l,g){return ir(e,l,g,!0)}function Qr(e,l,g){return ir(e,l,g,!1)}var zr=Qr,Xr=Yr;Se.Fragment=E,Se.jsx=zr,Se.jsxs=Xr})()),Se}var fr;function ot(){return fr||(fr=1,process.env.NODE_ENV==="production"?we.exports=at():we.exports=ut()),we.exports}var dr=ot();const Ge=N.createContext(null),ge=()=>{const r=N.useContext(Ge);if(!r)throw new Error("useApiContext must be used within ApiProvider");return r};function ct({baseURL:r,getToken:_,timeoutMs:m=15e3,lng:E="tw",store:f,onError:y}={}){const S=rt.create({baseURL:r,timeout:m,headers:{"Content-Type":"application/json"}});return S.interceptors.request.use(async d=>{if(d.headers=d.headers||{},_){const s=await _();s&&(d.headers.Authorization=`Bearer ${s}`)}const c=f?.getState()?.isWalletCurrency;return d.headers.Currency=c,d.headers["currency-code"]=c,d.headers.lang=E,d}),S.interceptors.response.use(d=>d.data,d=>y?y(d,{instance:S}):Promise.reject(d)),S}function it({children:r,..._}){const m=N.useMemo(()=>ct(_),[_]),f=N.useMemo(()=>new x.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return dr.jsx(x.QueryClientProvider,{client:f,children:dr.jsx(Ge.Provider,{value:{client:m,..._},children:r})})}const st=()=>{const r=(E,f)=>!E&&!f,_=E=>E.startsWith("pc.");return{executeLogout:({isCallBackInvalid:E=!1,hostname:f="",shouldRedirect:y,onShowError:S,onCleanup:d,onRemoveToken:c,onRedirect:s,onGoogleLogout:u})=>{const a=_(f);r(E,a)&&S?.(),d?.(),c?.(),y&&s?.("/"),u?.()},shouldShowErrorNotice:r,isMachineDomain:_}},lt=(r={})=>!M.isObject(r)||M.isEmpty(r)?[]:M.flatMap(r),ft=(r=[])=>!M.isArray(r)||M.isEmpty(r)?[]:M.map(r,"platform"),dt=(r=[])=>!M.isArray(r)||M.isEmpty(r)?[]:M.map(r,"gameTypeName"),vt=(r=[])=>!M.isArray(r)||M.isEmpty(r)?[]:M.map(r,"game_subtype"),Et=(r={})=>!M.isObject(r)||M.isEmpty(r)?[]:M.flatMap(r),yt=(r=[])=>!M.isArray(r)||M.isEmpty(r)?[]:M.flatMap(r,_=>M.isEmpty(_.SubPlatformEnum)?_:_.SubPlatformEnum.map(m=>({..._,...m,platform:m.SubPlatformEnum,platformEnum:m.SubPlatformEnum}))),Je=()=>{const{client:r}=ge(),_=N.useCallback(async S=>{const{mac_address:d="",app_version:c="",anydesk_id:s=""}=S,{data:u}=await r.post("/cash-register/login",{mac_address:d,app_version:c,anydesk_id:s});return u},[r]),m=N.useCallback(async()=>r.get("/member/getMemberInfo"),[r]),E=N.useCallback(async()=>await r.get("member/getGameList"),[r]),f=N.useCallback(async()=>await r.get("/member/getNowCurrencyExchange"),[r]),y=N.useCallback(async()=>await r.get("member/getFavoriteGame"),[r]);return{machineLoginApi:_,userInfoApi:m,userGameListApi:E,userFavoriteGameApi:y,userCurrencyExchangeApi:f}},_t=({otherQueryKey:r=[],options:_={}}={})=>{const{userCurrencyExchangeApi:m}=Je(),{getToken:E}=ge(),{enabled:f,...y}=_,S=!!E&&(f?f.every(d=>d):!0);return x.useQueries({queries:[{queryKey:["userCurrencyExchange",...r],queryFn:()=>m(),enabled:S,...y}]})},St=({refetchInterval:r=5e4,trigger:_=[],enabled:m=!0}={})=>{const{getToken:E}=ge(),{userInfoApi:f}=Je(),y=x.useQueries({queries:[{queryKey:["getMemberInfo",..._],queryFn:async()=>await f(),refetchInterval:r,enabled:!!E&&m}]}),{data:S,isFetching:d,error:c}=y[0]||{};return{data:S,isFetching:d,error:c}},ht=({enabled:r=!0}={})=>{const{userInfoApi:_,userFavoriteGameApi:m,userGameListApi:E,userCurrencyExchangeApi:f}=Je(),y=x.useQuery({queryKey:["getMemInfo"],queryFn:async()=>_(),enabled:r}),S=x.useQuery({queryKey:["getFavoriteGame"],queryFn:async()=>m(),enabled:r&&y.isSuccess}),d=x.useQuery({queryKey:["getUserGameList"],queryFn:async()=>E(),enabled:r&&y.isSuccess&&S.isSuccess}),c=x.useQuery({queryKey:["getUserCurrencyExchange"],queryFn:async()=>f(),enabled:r&&y.isSuccess&&S.isSuccess&&d.isSuccess});return[y,S,d,c]};var je={},G={},Ue={},vr;function B(){return vr||(vr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.isEventSourceSupported=r.isReactNative=r.ReadyState=r.DEFAULT_HEARTBEAT=r.UNPARSABLE_JSON_OBJECT=r.DEFAULT_RECONNECT_INTERVAL_MS=r.DEFAULT_RECONNECT_LIMIT=r.SOCKET_IO_PING_CODE=r.SOCKET_IO_PATH=r.SOCKET_IO_PING_INTERVAL=r.DEFAULT_EVENT_SOURCE_OPTIONS=r.EMPTY_EVENT_HANDLERS=r.DEFAULT_OPTIONS=void 0;var _=1,m=1e3*_;r.DEFAULT_OPTIONS={},r.EMPTY_EVENT_HANDLERS={},r.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:r.EMPTY_EVENT_HANDLERS},r.SOCKET_IO_PING_INTERVAL=25*m,r.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",r.SOCKET_IO_PING_CODE="2",r.DEFAULT_RECONNECT_LIMIT=20,r.DEFAULT_RECONNECT_INTERVAL_MS=5e3,r.UNPARSABLE_JSON_OBJECT={},r.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var E;(function(y){y[y.UNINSTANTIATED=-1]="UNINSTANTIATED",y[y.CONNECTING=0]="CONNECTING",y[y.OPEN=1]="OPEN",y[y.CLOSING=2]="CLOSING",y[y.CLOSED=3]="CLOSED"})(E||(r.ReadyState=E={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};r.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",r.isEventSourceSupported=!r.isReactNative&&f()})(Ue)),Ue}var he={},We={},Er;function He(){return Er||(Er=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetWebSockets=r.sharedWebSockets=void 0,r.sharedWebSockets={};var _=function(m){if(m&&r.sharedWebSockets.hasOwnProperty(m))delete r.sharedWebSockets[m];else for(var E in r.sharedWebSockets)r.sharedWebSockets.hasOwnProperty(E)&&delete r.sharedWebSockets[E]};r.resetWebSockets=_})(We)),We}var ue={},z={},yr;function Ve(){if(yr)return z;yr=1,Object.defineProperty(z,"__esModule",{value:!0}),z.setUpSocketIOPing=z.appendQueryParams=z.parseSocketIOUrl=void 0;var r=B(),_=function(f){if(f){var y=/^https|wss/.test(f),S=f.replace(/^(https?|wss?)(:\/\/)?/,""),d=S.replace(/\/$/,""),c=y?"wss":"ws";return"".concat(c,"://").concat(d).concat(r.SOCKET_IO_PATH)}else if(f===""){var y=/^https/.test(window.location.protocol),c=y?"wss":"ws",s=window.location.port?":".concat(window.location.port):"";return"".concat(c,"://").concat(window.location.hostname).concat(s).concat(r.SOCKET_IO_PATH)}return f};z.parseSocketIOUrl=_;var m=function(f,y){y===void 0&&(y={});var S=/\?([\w]+=[\w]+)/,d=S.test(f),c="".concat(Object.entries(y).reduce(function(s,u){var a=u[0],i=u[1];return s+"".concat(a,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(d?"&":"?").concat(c)};z.appendQueryParams=m;var E=function(f,y){y===void 0&&(y=r.SOCKET_IO_PING_INTERVAL);var S=function(){return f(r.SOCKET_IO_PING_CODE)};return window.setInterval(S,y)};return z.setUpSocketIOPing=E,z}var Pe={},_r;function wr(){if(_r)return Pe;_r=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.heartbeat=m;var r=B();function _(E){return Array.isArray(E)?E.reduce(function(f,y){return f.current>y.current?f:y}).current:E.current}function m(E,f,y){var S=y||{},d=S.interval,c=d===void 0?r.DEFAULT_HEARTBEAT.interval:d,s=S.timeout,u=s===void 0?r.DEFAULT_HEARTBEAT.timeout:s,a=S.message,i=a===void 0?r.DEFAULT_HEARTBEAT.message:a,t=Math.max(100,c/10),n=Date.now(),v=setInterval(function(){var h=Date.now(),o=_(f);if(o+u<=h)console.warn("Heartbeat timed out, closing connection, last message received ".concat(h-o,"ms ago, last ping sent ").concat(h-n,"ms ago")),E.close();else if(o+c<=h&&n+c<=h)try{typeof i=="function"?E.send(i()):E.send(i),n=h}catch(b){console.error("Heartbeat failed, closing connection",b instanceof Error?b.message:b),E.close()}},t);return E.addEventListener("close",function(){clearInterval(v)}),function(){}}return Pe}var be={},Fe={},Sr;function $e(){return Sr||(Sr=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetSubscribers=r.removeSubscriber=r.addSubscriber=r.hasSubscribers=r.getSubscribers=void 0;var _={},m=[],E=function(c){return(0,r.hasSubscribers)(c)?Array.from(_[c]):m};r.getSubscribers=E;var f=function(c){var s;return((s=_[c])===null||s===void 0?void 0:s.size)>0};r.hasSubscribers=f;var y=function(c,s){_[c]=_[c]||new Set,_[c].add(s)};r.addSubscriber=y;var S=function(c,s){_[c].delete(s)};r.removeSubscriber=S;var d=function(c){if(c&&_.hasOwnProperty(c))delete _[c];else for(var s in _)_.hasOwnProperty(s)&&delete _[s]};r.resetSubscribers=d})(Fe)),Fe}var hr;function xe(){if(hr)return be;hr=1,Object.defineProperty(be,"__esModule",{value:!0}),be.assertIsWebSocket=m,be.resetGlobalState=E;var r=He(),_=$e();function m(f,y){if(!y&&!(f instanceof WebSocket))throw new Error("")}function E(f){(0,_.resetSubscribers)(f),(0,r.resetWebSockets)(f)}return be}var br;function bt(){if(br)return ue;br=1;var r=ue&&ue.__assign||function(){return r=Object.assign||function(u){for(var a,i=1,t=arguments.length;i<t;i++){a=arguments[i];for(var n in a)Object.prototype.hasOwnProperty.call(a,n)&&(u[n]=a[n])}return u},r.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.attachListeners=void 0;var _=Ve(),m=wr(),E=B(),f=xe(),y=function(u,a,i,t){u.onmessage=function(n){var v;a.current.onMessage&&a.current.onMessage(n),typeof t?.current=="number"&&(t.current=Date.now()),!(typeof a.current.filter=="function"&&a.current.filter(n)!==!0)&&(a.current.heartbeat&&typeof a.current.heartbeat!="boolean"&&((v=a.current.heartbeat)===null||v===void 0?void 0:v.returnMessage)===n.data||i(n))}},S=function(u,a,i,t,n){u.onopen=function(v){if(a.current.onOpen&&a.current.onOpen(v),t.current=0,i(E.ReadyState.OPEN),a.current.heartbeat&&u instanceof WebSocket){var h=typeof a.current.heartbeat=="boolean"?void 0:a.current.heartbeat;n.current=Date.now(),(0,m.heartbeat)(u,n,h)}}},d=function(u,a,i,t,n){if(E.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,a.current.skipAssert);var v;return u.onclose=function(h){var o;if(a.current.onClose&&a.current.onClose(h),i(E.ReadyState.CLOSED),a.current.shouldReconnect&&a.current.shouldReconnect(h)){var b=(o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT;if(n.current<b){var R=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},R??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(b),console.warn("Max reconnect attempts of ".concat(b," exceeded"))}},function(){return v&&window.clearTimeout(v)}},c=function(u,a,i,t,n){var v;return u.onerror=function(h){var o;if(a.current.onError&&a.current.onError(h),E.isEventSourceSupported&&u instanceof EventSource&&(a.current.onClose&&a.current.onClose(r(r({},h),{code:1006,reason:"An error occurred with the EventSource: ".concat(h),wasClean:!1})),i(E.ReadyState.CLOSED),u.close()),a.current.retryOnError)if(n.current<((o=a.current.reconnectAttempts)!==null&&o!==void 0?o:E.DEFAULT_RECONNECT_LIMIT)){var b=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(n.current):a.current.reconnectInterval;v=window.setTimeout(function(){n.current++,t()},b??E.DEFAULT_RECONNECT_INTERVAL_MS)}else a.current.onReconnectStop&&a.current.onReconnectStop(a.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(a.current.reconnectAttempts," exceeded"))},function(){return v&&window.clearTimeout(v)}},s=function(u,a,i,t,n,v,h){var o=a.setLastMessage,b=a.setReadyState,R,P,O;return i.current.fromSocketIO&&(R=(0,_.setUpSocketIOPing)(h)),y(u,i,o,v),S(u,i,b,n,v),P=d(u,i,b,t,n),O=c(u,i,b,t,n),function(){b(E.ReadyState.CLOSING),P(),O(),u.close(),R&&clearInterval(R)}};return ue.attachListeners=s,ue}var oe={},gr;function gt(){if(gr)return oe;gr=1;var r=oe&&oe.__assign||function(){return r=Object.assign||function(a){for(var i,t=1,n=arguments.length;t<n;t++){i=arguments[t];for(var v in i)Object.prototype.hasOwnProperty.call(i,v)&&(a[v]=i[v])}return a},r.apply(this,arguments)};Object.defineProperty(oe,"__esModule",{value:!0}),oe.attachSharedListeners=void 0;var _=He(),m=B(),E=$e(),f=Ve(),y=wr(),S=function(a,i,t){a.onmessage=function(n){(0,E.getSubscribers)(i).forEach(function(v){var h;v.optionsRef.current.onMessage&&v.optionsRef.current.onMessage(n),typeof((h=v?.lastMessageTime)===null||h===void 0?void 0:h.current)=="number"&&(v.lastMessageTime.current=Date.now()),!(typeof v.optionsRef.current.filter=="function"&&v.optionsRef.current.filter(n)!==!0)&&(t&&typeof t!="boolean"&&t?.returnMessage===n.data||v.setLastMessage(n))})}},d=function(a,i,t){a.onopen=function(n){var v=(0,E.getSubscribers)(i);v.forEach(function(h){h.reconnectCount.current=0,h.optionsRef.current.onOpen&&h.optionsRef.current.onOpen(n),h.setReadyState(m.ReadyState.OPEN),t&&a instanceof WebSocket&&(h.lastMessageTime.current=Date.now())}),t&&a instanceof WebSocket&&(0,y.heartbeat)(a,v.map(function(h){return h.lastMessageTime}),typeof t=="boolean"?void 0:t)}},c=function(a,i){a instanceof WebSocket&&(a.onclose=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onClose&&n.optionsRef.current.onClose(t),n.setReadyState(m.ReadyState.CLOSED)}),delete _.sharedWebSockets[i],(0,E.getSubscribers)(i).forEach(function(n){var v;if(n.optionsRef.current.shouldReconnect&&n.optionsRef.current.shouldReconnect(t)){var h=(v=n.optionsRef.current.reconnectAttempts)!==null&&v!==void 0?v:m.DEFAULT_RECONNECT_LIMIT;if(n.reconnectCount.current<h){var o=typeof n.optionsRef.current.reconnectInterval=="function"?n.optionsRef.current.reconnectInterval(n.reconnectCount.current):n.optionsRef.current.reconnectInterval;setTimeout(function(){n.reconnectCount.current++,n.reconnect.current()},o??m.DEFAULT_RECONNECT_INTERVAL_MS)}else n.optionsRef.current.onReconnectStop&&n.optionsRef.current.onReconnectStop(n.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(h," exceeded"))}})})},s=function(a,i){a.onerror=function(t){(0,E.getSubscribers)(i).forEach(function(n){n.optionsRef.current.onError&&n.optionsRef.current.onError(t),m.isEventSourceSupported&&a instanceof EventSource&&(n.optionsRef.current.onClose&&n.optionsRef.current.onClose(r(r({},t),{code:1006,reason:"An error occurred with the EventSource: ".concat(t),wasClean:!1})),n.setReadyState(m.ReadyState.CLOSED))}),m.isEventSourceSupported&&a instanceof EventSource&&a.close()}},u=function(a,i,t,n){var v;return t.current.fromSocketIO&&(v=(0,f.setUpSocketIOPing)(n)),S(a,i,t.current.heartbeat),c(a,i),d(a,i,t.current.heartbeat),s(a,i),function(){v&&clearInterval(v)}};return oe.attachSharedListeners=u,oe}var mr;function mt(){if(mr)return he;mr=1,Object.defineProperty(he,"__esModule",{value:!0}),he.createOrJoinSocket=void 0;var r=He(),_=B(),m=bt(),E=gt(),f=$e(),y=function(d,c,s,u,a){return function(){if((0,f.removeSubscriber)(d,c),!(0,f.hasSubscribers)(d)){try{var i=r.sharedWebSockets[d];i instanceof WebSocket&&(i.onclose=function(t){s.current.onClose&&s.current.onClose(t),u(_.ReadyState.CLOSED)}),i.close()}catch{}a&&a(),delete r.sharedWebSockets[d]}}},S=function(d,c,s,u,a,i,t,n,v){if(!_.isEventSourceSupported&&u.current.eventSourceOptions)throw _.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var h=null;r.sharedWebSockets[c]===void 0?(r.sharedWebSockets[c]=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),d.current=r.sharedWebSockets[c],s(_.ReadyState.CONNECTING),h=(0,E.attachSharedListeners)(r.sharedWebSockets[c],c,u,v)):(d.current=r.sharedWebSockets[c],s(r.sharedWebSockets[c].readyState));var o={setLastMessage:a,setReadyState:s,optionsRef:u,reconnectCount:t,lastMessageTime:n,reconnect:i};return(0,f.addSubscriber)(c,o),y(c,o,u,s,h)}else{if(d.current=u.current.eventSourceOptions?new EventSource(c,u.current.eventSourceOptions):new WebSocket(c,u.current.protocols),s(_.ReadyState.CONNECTING),!d.current)throw new Error("WebSocket failed to be created");return(0,m.attachListeners)(d.current,{setLastMessage:a,setReadyState:s},u,i.current,t,n,v)}};return he.createOrJoinSocket=S,he}var X={},pr;function pt(){return pr||(pr=1,(function(r){var _=X&&X.__awaiter||function(c,s,u,a){function i(t){return t instanceof u?t:new u(function(n){n(t)})}return new(u||(u=Promise))(function(t,n){function v(b){try{o(a.next(b))}catch(R){n(R)}}function h(b){try{o(a.throw(b))}catch(R){n(R)}}function o(b){b.done?t(b.value):i(b.value).then(v,h)}o((a=a.apply(c,s||[])).next())})},m=X&&X.__generator||function(c,s){var u={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1]},trys:[],ops:[]},a,i,t,n=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return n.next=v(0),n.throw=v(1),n.return=v(2),typeof Symbol=="function"&&(n[Symbol.iterator]=function(){return this}),n;function v(o){return function(b){return h([o,b])}}function h(o){if(a)throw new TypeError("Generator is already executing.");for(;n&&(n=0,o[0]&&(u=0)),u;)try{if(a=1,i&&(t=o[0]&2?i.return:o[0]?i.throw||((t=i.return)&&t.call(i),0):i.next)&&!(t=t.call(i,o[1])).done)return t;switch(i=0,t&&(o=[o[0]&2,t.value]),o[0]){case 0:case 1:t=o;break;case 4:return u.label++,{value:o[1],done:!1};case 5:u.label++,i=o[1],o=[0];continue;case 7:o=u.ops.pop(),u.trys.pop();continue;default:if(t=u.trys,!(t=t.length>0&&t[t.length-1])&&(o[0]===6||o[0]===2)){u=0;continue}if(o[0]===3&&(!t||o[1]>t[0]&&o[1]<t[3])){u.label=o[1];break}if(o[0]===6&&u.label<t[1]){u.label=t[1],t=o;break}if(t&&u.label<t[2]){u.label=t[2],u.ops.push(o);break}t[2]&&u.ops.pop(),u.trys.pop();continue}o=s.call(c,u)}catch(b){o=[6,b],i=0}finally{a=t=0}if(o[0]&5)throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}},E=X&&X.__spreadArray||function(c,s,u){if(u||arguments.length===2)for(var a=0,i=s.length,t;a<i;a++)(t||!(a in s))&&(t||(t=Array.prototype.slice.call(s,0,a)),t[a]=s[a]);return c.concat(t||Array.prototype.slice.call(s))};Object.defineProperty(r,"__esModule",{value:!0}),r.getUrl=void 0;var f=Ve(),y=B(),S=function(c){return new Promise(function(s){return window.setTimeout(s,c)})},d=function(c,s){for(var u=[],a=2;a<arguments.length;a++)u[a-2]=arguments[a];return _(void 0,E([c,s],u,!0),void 0,function(i,t,n){var v,h,o,b,R,P,O,w;return n===void 0&&(n=0),m(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return v=I.sent(),[3,9];case 3:return I.sent(),t.current.retryOnError?(h=(P=t.current.reconnectAttempts)!==null&&P!==void 0?P:y.DEFAULT_RECONNECT_LIMIT,n<h?(o=typeof t.current.reconnectInterval=="function"?t.current.reconnectInterval(n):t.current.reconnectInterval,[4,S(o??y.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,r.getUrl)(i,t,n+1)];case 5:return(w=(O=t.current).onReconnectStop)===null||w===void 0||w.call(O,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:v=i,I.label=11;case 11:return b=t.current.fromSocketIO?(0,f.parseSocketIOUrl)(v):v,R=t.current.queryParams?(0,f.appendQueryParams)(b,t.current.queryParams):b,[2,R]}})})};r.getUrl=d})(X)),X}var qe={},Or;function Ot(){return Or||(Or=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.websocketWrapper=void 0;var _=function(m,E){return new Proxy(m,{get:function(f,y){var S=f[y];return y==="reconnect"?E:typeof S=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):S},set:function(f,y,S){return/^on/.test(y)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[y]=S,!0)}})};r.websocketWrapper=_,r.default=r.websocketWrapper})(qe)),qe}var Tr;function Be(){if(Tr)return G;Tr=1;var r=G&&G.__assign||function(){return r=Object.assign||function(i){for(var t,n=1,v=arguments.length;n<v;n++){t=arguments[n];for(var h in t)Object.prototype.hasOwnProperty.call(t,h)&&(i[h]=t[h])}return i},r.apply(this,arguments)},_=G&&G.__awaiter||function(i,t,n,v){function h(o){return o instanceof n?o:new n(function(b){b(o)})}return new(n||(n=Promise))(function(o,b){function R(w){try{O(v.next(w))}catch(I){b(I)}}function P(w){try{O(v.throw(w))}catch(I){b(I)}}function O(w){w.done?o(w.value):h(w.value).then(R,P)}O((v=v.apply(i,t||[])).next())})},m=G&&G.__generator||function(i,t){var n={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},v,h,o,b=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return b.next=R(0),b.throw=R(1),b.return=R(2),typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function R(O){return function(w){return P([O,w])}}function P(O){if(v)throw new TypeError("Generator is already executing.");for(;b&&(b=0,O[0]&&(n=0)),n;)try{if(v=1,h&&(o=O[0]&2?h.return:O[0]?h.throw||((o=h.return)&&o.call(h),0):h.next)&&!(o=o.call(h,O[1])).done)return o;switch(h=0,o&&(O=[O[0]&2,o.value]),O[0]){case 0:case 1:o=O;break;case 4:return n.label++,{value:O[1],done:!1};case 5:n.label++,h=O[1],O=[0];continue;case 7:O=n.ops.pop(),n.trys.pop();continue;default:if(o=n.trys,!(o=o.length>0&&o[o.length-1])&&(O[0]===6||O[0]===2)){n=0;continue}if(O[0]===3&&(!o||O[1]>o[0]&&O[1]<o[3])){n.label=O[1];break}if(O[0]===6&&n.label<o[1]){n.label=o[1],o=O;break}if(o&&n.label<o[2]){n.label=o[2],n.ops.push(O);break}o[2]&&n.ops.pop(),n.trys.pop();continue}O=t.call(i,n)}catch(w){O=[6,w],h=0}finally{v=o=0}if(O[0]&5)throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}},E=G&&G.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(G,"__esModule",{value:!0}),G.useWebSocket=void 0;var f=N,y=tt,S=B(),d=mt(),c=pt(),s=E(Ot()),u=xe(),a=function(i,t,n){t===void 0&&(t=S.DEFAULT_OPTIONS),n===void 0&&(n=!0);var v=(0,f.useState)(null),h=v[0],o=v[1],b=(0,f.useState)({}),R=b[0],P=b[1],O=(0,f.useMemo)(function(){if(!t.disableJson&&h)try{return JSON.parse(h.data)}catch{return S.UNPARSABLE_JSON_OBJECT}return null},[h,t.disableJson]),w=(0,f.useRef)(null),I=(0,f.useRef)(null),de=(0,f.useRef)(function(){}),ve=(0,f.useRef)(0),ke=(0,f.useRef)(Date.now()),me=(0,f.useRef)([]),V=(0,f.useRef)(null),U=(0,f.useRef)(t);U.current=t;var H=w.current&&R[w.current]!==void 0?R[w.current]:i!==null&&n===!0?S.ReadyState.CONNECTING:S.ReadyState.UNINSTANTIATED,re=t.queryParams?JSON.stringify(t.queryParams):null,K=(0,f.useCallback)(function(j,W){var Y;if(W===void 0&&(W=!0),S.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===S.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,U.current.skipAssert),I.current.send(j)):W&&me.current.push(j)},[]),pe=(0,f.useCallback)(function(j,W){W===void 0&&(W=!0),K(JSON.stringify(j),W)},[K]),Oe=(0,f.useCallback)(function(){return U.current.share!==!0||S.isEventSourceSupported&&I.current instanceof EventSource?I.current:(V.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,U.current.skipAssert),V.current=(0,s.default)(I.current,de)),V.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&n===!0){var j,W=!1,Y=!0,Ee=function(){return _(void 0,void 0,void 0,function(){var te,ee,Te;return m(this,function(ie){switch(ie.label){case 0:return te=w,[4,(0,c.getUrl)(i,U)];case 1:return te.current=ie.sent(),w.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),w.current="ABORTED",(0,y.flushSync)(function(){return P(function(Q){return r(r({},Q),{ABORTED:S.ReadyState.CLOSED})})}),[2]):(ee=function(Q){W||(0,y.flushSync)(function(){return o(Q)})},Te=function(Q){W||(0,y.flushSync)(function(){return P(function(se){var ne;return r(r({},se),w.current&&(ne={},ne[w.current]=Q,ne))})})},Y&&(j=(0,d.createOrJoinSocket)(I,w.current,Te,U,ee,de,ve,ke,K)),[2])}})})};return de.current=function(){W||(V.current&&(V.current=null),j?.(),Ee())},Ee(),function(){W=!0,Y=!1,V.current&&(V.current=null),j?.(),o(null)}}else(i===null||n===!1)&&(ve.current=0,P(function(te){var ee;return r(r({},te),w.current&&(ee={},ee[w.current]=S.ReadyState.CLOSED,ee))}))},[i,n,re,K]),(0,f.useEffect)(function(){H===S.ReadyState.OPEN&&me.current.splice(0).forEach(function(j){K(j)})},[H]),{sendMessage:K,sendJsonMessage:pe,lastMessage:h,lastJsonMessage:O,readyState:H,getWebSocket:Oe}};return G.useWebSocket=a,G}var ce={},Cr;function Tt(){if(Cr)return ce;Cr=1;var r=ce&&ce.__assign||function(){return r=Object.assign||function(d){for(var c,s=1,u=arguments.length;s<u;s++){c=arguments[s];for(var a in c)Object.prototype.hasOwnProperty.call(c,a)&&(d[a]=c[a])}return d},r.apply(this,arguments)};Object.defineProperty(ce,"__esModule",{value:!0}),ce.useSocketIO=void 0;var _=N,m=Be(),E=B(),f={type:"empty",payload:null},y=function(d){if(!d||!d.data)return f;var c=d.data.match(/\[.*]/);if(!c)return f;var s=JSON.parse(c);return!Array.isArray(s)||!s[1]?f:{type:s[0],payload:s[1]}},S=function(d,c,s){c===void 0&&(c=E.DEFAULT_OPTIONS),s===void 0&&(s=!0);var u=(0,_.useMemo)(function(){return r(r({},c),{fromSocketIO:!0})},[]),a=(0,m.useWebSocket)(d,u,s),i=a.sendMessage,t=a.sendJsonMessage,n=a.lastMessage,v=a.readyState,h=a.getWebSocket,o=(0,_.useMemo)(function(){return y(n)},[n]);return{sendMessage:i,sendJsonMessage:t,lastMessage:o,lastJsonMessage:o,readyState:v,getWebSocket:h}};return ce.useSocketIO=S,ce}var Z={},Rr;function Ct(){if(Rr)return Z;Rr=1;var r=Z&&Z.__assign||function(){return r=Object.assign||function(S){for(var d,c=1,s=arguments.length;c<s;c++){d=arguments[c];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(S[u]=d[u])}return S},r.apply(this,arguments)},_=Z&&Z.__rest||function(S,d){var c={};for(var s in S)Object.prototype.hasOwnProperty.call(S,s)&&d.indexOf(s)<0&&(c[s]=S[s]);if(S!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,s=Object.getOwnPropertySymbols(S);u<s.length;u++)d.indexOf(s[u])<0&&Object.prototype.propertyIsEnumerable.call(S,s[u])&&(c[s[u]]=S[s[u]]);return c};Object.defineProperty(Z,"__esModule",{value:!0}),Z.useEventSource=void 0;var m=N,E=Be(),f=B(),y=function(S,d,c){d===void 0&&(d=f.DEFAULT_EVENT_SOURCE_OPTIONS);var s=d.withCredentials,u=d.events,a=_(d,["withCredentials","events"]);c===void 0&&(c=!0);var i=r(r({},a),{eventSourceOptions:{withCredentials:s}}),t=(0,m.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(t.current=u);var n=(0,E.useWebSocket)(S,i,c),v=n.lastMessage,h=n.readyState,o=n.getWebSocket;return(0,m.useEffect)(function(){v?.type&&Object.entries(t.current).forEach(function(b){var R=b[0],P=b[1];R===v.type&&P(v)})},[v]),{lastEvent:v,readyState:h,getEventSource:o}};return Z.useEventSource=y,Z}var Ar;function Rt(){return Ar||(Ar=1,(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.resetGlobalState=r.useEventSource=r.ReadyState=r.useSocketIO=r.default=void 0;var _=Be();Object.defineProperty(r,"default",{enumerable:!0,get:function(){return _.useWebSocket}});var m=Tt();Object.defineProperty(r,"useSocketIO",{enumerable:!0,get:function(){return m.useSocketIO}});var E=B();Object.defineProperty(r,"ReadyState",{enumerable:!0,get:function(){return E.ReadyState}});var f=Ct();Object.defineProperty(r,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var y=xe();Object.defineProperty(r,"resetGlobalState",{enumerable:!0,get:function(){return y.resetGlobalState}})})(je)),je}var At=Rt();const wt=nt(At),$={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},Pt=3e4,kt=({socketUrl:r,socketHandlers:_={},options:m={}})=>{const E=N.useRef(!1),f=N.useRef(_),{sendMessage:y,sendJsonMessage:S,lastMessage:d,readyState:c}=wt(r,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>E.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...m}),s=N.useMemo(()=>{try{return JSON.parse(d?.data)}catch{return null}},[d?.data]);return N.useEffect(()=>{const u=setInterval(()=>y("ping"),Pt);return()=>clearInterval(u)},[y]),N.useEffect(()=>{f.current=_},[_]),N.useEffect(()=>{if(!s)return;const{onDeposit:u,onTransCode:a,onError:i,onUpdateMember:t,onMaintainNotice:n,onMaintainNoticeMember:v,onReload:h,onTransferInGame:o,onCashRegisterLimit:b}=f.current,R=M.get(s,"type",""),P={memberInfoUid:M.get(s,"member_info_uid",null),data:M.get(s,"data",null),memo:M.get(s,"memo",null)};switch(R){case $.DEPOSIT:u?.(P);break;case $.TRANS_CODE:a?.(P);break;case $.ERROR:i?.(P);break;case $.UPDATE_MEMBER:t?.(P);break;case $.MAINTAIN_NOTICE:n?.(P);break;case $.MAINTAIN_NOTICE_MEMBER:v?.(P);break;case $.RELOAD:h?.(P);break;case $.TRANSFER_IN_GAME:case $.CHECK_REQUEST:o?.(P);break;case $.CASH_REGISTER_LIMIT:b?.(P);break;default:console.warn("Unknown socket type:",R);break}},[s]),N.useEffect(()=>()=>E.current=!0,[]),{sendMessage:y,sendJsonMessage:S,readyState:c}},Pr=()=>{const{client:r}=ge(),_=N.useCallback(async()=>{const{data:E}=await r.get("/carousels");return E},[r]),m=N.useCallback(async()=>await r.get("/marquees"),[r]);return{commonCarouselApi:_,commonMarqueeApi:m}},It=()=>{const{commonCarouselApi:r}=Pr();return x.useQuery({queryKey:["getCarouselList"],queryFn:async()=>await r()})},Nt=()=>{const{commonMarqueeApi:r}=Pr();return x.useQuery({queryKey:["getMarqueeList"],queryFn:async()=>r(),select:_=>_.Marquees})};exports.ApiCtx=Ge;exports.ApiProvider=it;exports.createLogoutHandler=st;exports.extractGameSubTypeNames=vt;exports.extractGameTypeNames=dt;exports.extractPlatformNames=ft;exports.flattenAllGames=lt;exports.flattenFavoriteGames=Et;exports.processPlatformData=yt;exports.useApiContext=ge;exports.useBalanceGetter=_t;exports.useClientWebSocket=kt;exports.useGetCarouseList=It;exports.useGetMarquee=Nt;exports.useGetMemberInfo=St;exports.useInitializeWithToken=ht;
|
|
14
|
+
<%s key={someKey} {...props} />`,Le,ae,et,ae),cr[ae+Le]=!0}}return r===E?Yr(L):Kr(L),L}}function Qr(r,v,g){return ir(r,v,g,!0)}function zr(r,v,g){return ir(r,v,g,!1)}var Xr=zr,Zr=Qr;_e.Fragment=E,_e.jsx=Xr,_e.jsxs=Zr})()),_e}var fr;function ct(){return fr||(fr=1,process.env.NODE_ENV==="production"?we.exports=ut():we.exports=ot()),we.exports}var dr=ct();const Ge=M.createContext(null),me=()=>{const e=M.useContext(Ge);if(!e)throw new Error("useApiContext must be used within ApiProvider");return e};function it({baseURL:e,getToken:l,timeoutMs:h=15e3,lng:E="tw",store:f,onError:y}={}){const _=tt.create({baseURL:e,timeout:h,headers:{"Content-Type":"application/json"}});return _.interceptors.request.use(async d=>{if(d.headers=d.headers||{},l){const s=await l();s&&(d.headers.Authorization=`Bearer ${s}`)}const o=f?.getState()?.isWalletCurrency;return d.headers.Currency=o,d.headers["currency-code"]=o,d.headers.lang=E,d}),_.interceptors.response.use(d=>d.data,d=>y?y(d,{instance:_}):Promise.reject(d)),_}function st({children:e,...l}){const h=M.useMemo(()=>it(l),[l]),f=M.useMemo(()=>new $.QueryClient({defaultOptions:{queries:{refetchOnWindowFocus:!1,retry:1}}}),[]);return dr.jsx($.QueryClientProvider,{client:f,children:dr.jsx(Ge.Provider,{value:{client:h,...l},children:e})})}const lt=()=>{const e=(E,f)=>!E&&!f,l=E=>E.startsWith("pc.");return{executeLogout:({isCallBackInvalid:E=!1,hostname:f="",shouldRedirect:y,onShowError:_,onCleanup:d,onRemoveToken:o,onRedirect:s,onGoogleLogout:u})=>{const n=l(f);e(E,n)&&_?.(),d?.(),o?.(),y&&s?.("/"),u?.()},shouldShowErrorNotice:e,isMachineDomain:l}},ft=(e=[],l)=>R.find(e,{gameTypeName:l})?.gameTypeUid,dt=(e=[],l)=>R.find(e,{platform:l})?.platformUid,vt=(e=[],l)=>R.find(e,{SubPlatformEnum:l}),yt=(e=[],l,h)=>R.isEmpty(e)?[]:e.filter(E=>h?String(E?.SubPlatformEnumUid)===String(h?.SubPlatformEnumUid):String(E.platformUid)===String(l)),wr=({gameTypeName:e,platforms:l,gameList:h,allGameTypes:E,allPlatforms:f})=>{const y=ft(E,e);return y?l.reduce((_,d)=>{const o=dt(f,d),s=vt(f,d),u=h[y]||[],n=yt(u,o,s);return R.isEmpty(n)||(_[d]=n),_},{}):{}},Et=({gameTypes:e=[],platforms:l=[],gameList:h={},allGameTypes:E=[],allPlatforms:f=[]})=>!R.isArray(e)||!R.isArray(l)?{}:R.isEmpty(h)?{}:e.reduce((y,_)=>{const d=wr({gameTypeName:_,platforms:l,gameList:h,allGameTypes:E,allPlatforms:f});return R.isEmpty(d)||(y[_]=d),y},{}),St=(e={})=>!R.isObject(e)||R.isEmpty(e)?[]:R.flatMap(e),_t=(e=[])=>!R.isArray(e)||R.isEmpty(e)?[]:R.map(e,"platform"),bt=(e=[])=>!R.isArray(e)||R.isEmpty(e)?[]:R.map(e,"gameTypeName"),ht=(e=[])=>!R.isArray(e)||R.isEmpty(e)?[]:R.map(e,"game_subtype"),mt=(e={})=>!R.isObject(e)||R.isEmpty(e)?[]:R.flatMap(e),gt=({types:e=[],platforms:l=[],allGameType:h=[],allGamePlatform:E=[],allGameList:f={}}={})=>!Array.isArray(e)||!Array.isArray(l)?{}:e.reduce((y,_)=>{const d=h.find(s=>s.gameTypeName===_)?.gameTypeUid;if(!d)return y;const o=l.reduce((s,u)=>{const n=E.find(t=>t.platform===u)?.platformUid,i=(f[d]||[]).filter(t=>String(t.platformUid)===String(n)),a=(i||[]).reduce((t,S)=>{const b=S?.game_subtype??"UNKNOWN";return t[b]||(t[b]=[]),t[b].push(S),t},{});return(i||[]).length?{...s,[u]:a}:s},{});return R.isEmpty(o)||(y[_]=o),y},{}),pt=(e=[])=>!R.isArray(e)||R.isEmpty(e)?[]:R.flatMap(e,l=>R.isEmpty(l.SubPlatformEnum)?l:l.SubPlatformEnum.map(h=>({...l,...h,platform:h.SubPlatformEnum,platformEnum:h.SubPlatformEnum}))),Je=()=>{const{client:e}=me(),l=M.useCallback(async _=>{const{mac_address:d="",app_version:o="",anydesk_id:s=""}=_,{data:u}=await e.post("/cash-register/login",{mac_address:d,app_version:o,anydesk_id:s});return u},[e]),h=M.useCallback(async()=>e.get("/member/getMemberInfo"),[e]),E=M.useCallback(async()=>await e.get("member/getGameList"),[e]),f=M.useCallback(async()=>await e.get("/member/getNowCurrencyExchange"),[e]),y=M.useCallback(async()=>await e.get("member/getFavoriteGame"),[e]);return{machineLoginApi:l,userInfoApi:h,userGameListApi:E,userFavoriteGameApi:y,userCurrencyExchangeApi:f}},Ot=({otherQueryKey:e=[],options:l={}}={})=>{const{userCurrencyExchangeApi:h}=Je(),{getToken:E}=me(),{enabled:f,...y}=l,_=!!E&&(f?f.every(d=>d):!0);return $.useQueries({queries:[{queryKey:["userCurrencyExchange",...e],queryFn:()=>h(),enabled:_,...y}]})},Tt=({refetchInterval:e=5e4,trigger:l=[],enabled:h=!0}={})=>{const{getToken:E}=me(),{userInfoApi:f}=Je(),y=$.useQueries({queries:[{queryKey:["getMemberInfo",...l],queryFn:async()=>await f(),refetchInterval:e,enabled:!!E&&h}]}),{data:_,isFetching:d,error:o}=y[0]||{};return{data:_,isFetching:d,error:o}},Ct=({enabled:e=!0}={})=>{const{userInfoApi:l,userFavoriteGameApi:h,userGameListApi:E,userCurrencyExchangeApi:f}=Je(),y=$.useQuery({queryKey:["getMemInfo"],queryFn:async()=>l(),enabled:e}),_=$.useQuery({queryKey:["getFavoriteGame"],queryFn:async()=>h(),enabled:e&&y.isSuccess}),d=$.useQuery({queryKey:["getUserGameList"],queryFn:async()=>E(),enabled:e&&y.isSuccess&&_.isSuccess}),o=$.useQuery({queryKey:["getUserCurrencyExchange"],queryFn:async()=>f(),enabled:e&&y.isSuccess&&_.isSuccess&&d.isSuccess});return[y,_,d,o]};var Ue={},G={},je={},vr;function x(){return vr||(vr=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.isEventSourceSupported=e.isReactNative=e.ReadyState=e.DEFAULT_HEARTBEAT=e.UNPARSABLE_JSON_OBJECT=e.DEFAULT_RECONNECT_INTERVAL_MS=e.DEFAULT_RECONNECT_LIMIT=e.SOCKET_IO_PING_CODE=e.SOCKET_IO_PATH=e.SOCKET_IO_PING_INTERVAL=e.DEFAULT_EVENT_SOURCE_OPTIONS=e.EMPTY_EVENT_HANDLERS=e.DEFAULT_OPTIONS=void 0;var l=1,h=1e3*l;e.DEFAULT_OPTIONS={},e.EMPTY_EVENT_HANDLERS={},e.DEFAULT_EVENT_SOURCE_OPTIONS={withCredentials:!1,events:e.EMPTY_EVENT_HANDLERS},e.SOCKET_IO_PING_INTERVAL=25*h,e.SOCKET_IO_PATH="/socket.io/?EIO=3&transport=websocket",e.SOCKET_IO_PING_CODE="2",e.DEFAULT_RECONNECT_LIMIT=20,e.DEFAULT_RECONNECT_INTERVAL_MS=5e3,e.UNPARSABLE_JSON_OBJECT={},e.DEFAULT_HEARTBEAT={message:"ping",timeout:6e4,interval:25e3};var E;(function(y){y[y.UNINSTANTIATED=-1]="UNINSTANTIATED",y[y.CONNECTING=0]="CONNECTING",y[y.OPEN=1]="OPEN",y[y.CLOSING=2]="CLOSING",y[y.CLOSED=3]="CLOSED"})(E||(e.ReadyState=E={}));var f=function(){try{return"EventSource"in globalThis}catch{return!1}};e.isReactNative=typeof navigator<"u"&&navigator.product==="ReactNative",e.isEventSourceSupported=!e.isReactNative&&f()})(je)),je}var be={},We={},yr;function Be(){return yr||(yr=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.resetWebSockets=e.sharedWebSockets=void 0,e.sharedWebSockets={};var l=function(h){if(h&&e.sharedWebSockets.hasOwnProperty(h))delete e.sharedWebSockets[h];else for(var E in e.sharedWebSockets)e.sharedWebSockets.hasOwnProperty(E)&&delete e.sharedWebSockets[E]};e.resetWebSockets=l})(We)),We}var ue={},z={},Er;function He(){if(Er)return z;Er=1,Object.defineProperty(z,"__esModule",{value:!0}),z.setUpSocketIOPing=z.appendQueryParams=z.parseSocketIOUrl=void 0;var e=x(),l=function(f){if(f){var y=/^https|wss/.test(f),_=f.replace(/^(https?|wss?)(:\/\/)?/,""),d=_.replace(/\/$/,""),o=y?"wss":"ws";return"".concat(o,"://").concat(d).concat(e.SOCKET_IO_PATH)}else if(f===""){var y=/^https/.test(window.location.protocol),o=y?"wss":"ws",s=window.location.port?":".concat(window.location.port):"";return"".concat(o,"://").concat(window.location.hostname).concat(s).concat(e.SOCKET_IO_PATH)}return f};z.parseSocketIOUrl=l;var h=function(f,y){y===void 0&&(y={});var _=/\?([\w]+=[\w]+)/,d=_.test(f),o="".concat(Object.entries(y).reduce(function(s,u){var n=u[0],i=u[1];return s+"".concat(n,"=").concat(i,"&")},"").slice(0,-1));return"".concat(f).concat(d?"&":"?").concat(o)};z.appendQueryParams=h;var E=function(f,y){y===void 0&&(y=e.SOCKET_IO_PING_INTERVAL);var _=function(){return f(e.SOCKET_IO_PING_CODE)};return window.setInterval(_,y)};return z.setUpSocketIOPing=E,z}var Pe={},Sr;function Pr(){if(Sr)return Pe;Sr=1,Object.defineProperty(Pe,"__esModule",{value:!0}),Pe.heartbeat=h;var e=x();function l(E){return Array.isArray(E)?E.reduce(function(f,y){return f.current>y.current?f:y}).current:E.current}function h(E,f,y){var _=y||{},d=_.interval,o=d===void 0?e.DEFAULT_HEARTBEAT.interval:d,s=_.timeout,u=s===void 0?e.DEFAULT_HEARTBEAT.timeout:s,n=_.message,i=n===void 0?e.DEFAULT_HEARTBEAT.message:n,a=Math.max(100,o/10),t=Date.now(),S=setInterval(function(){var b=Date.now(),c=l(f);if(c+u<=b)console.warn("Heartbeat timed out, closing connection, last message received ".concat(b-c,"ms ago, last ping sent ").concat(b-t,"ms ago")),E.close();else if(c+o<=b&&t+o<=b)try{typeof i=="function"?E.send(i()):E.send(i),t=b}catch(m){console.error("Heartbeat failed, closing connection",m instanceof Error?m.message:m),E.close()}},a);return E.addEventListener("close",function(){clearInterval(S)}),function(){}}return Pe}var he={},Fe={},_r;function Ve(){return _r||(_r=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.resetSubscribers=e.removeSubscriber=e.addSubscriber=e.hasSubscribers=e.getSubscribers=void 0;var l={},h=[],E=function(o){return(0,e.hasSubscribers)(o)?Array.from(l[o]):h};e.getSubscribers=E;var f=function(o){var s;return((s=l[o])===null||s===void 0?void 0:s.size)>0};e.hasSubscribers=f;var y=function(o,s){l[o]=l[o]||new Set,l[o].add(s)};e.addSubscriber=y;var _=function(o,s){l[o].delete(s)};e.removeSubscriber=_;var d=function(o){if(o&&l.hasOwnProperty(o))delete l[o];else for(var s in l)l.hasOwnProperty(s)&&delete l[s]};e.resetSubscribers=d})(Fe)),Fe}var br;function $e(){if(br)return he;br=1,Object.defineProperty(he,"__esModule",{value:!0}),he.assertIsWebSocket=h,he.resetGlobalState=E;var e=Be(),l=Ve();function h(f,y){if(!y&&!(f instanceof WebSocket))throw new Error("")}function E(f){(0,l.resetSubscribers)(f),(0,e.resetWebSockets)(f)}return he}var hr;function Rt(){if(hr)return ue;hr=1;var e=ue&&ue.__assign||function(){return e=Object.assign||function(u){for(var n,i=1,a=arguments.length;i<a;i++){n=arguments[i];for(var t in n)Object.prototype.hasOwnProperty.call(n,t)&&(u[t]=n[t])}return u},e.apply(this,arguments)};Object.defineProperty(ue,"__esModule",{value:!0}),ue.attachListeners=void 0;var l=He(),h=Pr(),E=x(),f=$e(),y=function(u,n,i,a){u.onmessage=function(t){var S;n.current.onMessage&&n.current.onMessage(t),typeof a?.current=="number"&&(a.current=Date.now()),!(typeof n.current.filter=="function"&&n.current.filter(t)!==!0)&&(n.current.heartbeat&&typeof n.current.heartbeat!="boolean"&&((S=n.current.heartbeat)===null||S===void 0?void 0:S.returnMessage)===t.data||i(t))}},_=function(u,n,i,a,t){u.onopen=function(S){if(n.current.onOpen&&n.current.onOpen(S),a.current=0,i(E.ReadyState.OPEN),n.current.heartbeat&&u instanceof WebSocket){var b=typeof n.current.heartbeat=="boolean"?void 0:n.current.heartbeat;t.current=Date.now(),(0,h.heartbeat)(u,t,b)}}},d=function(u,n,i,a,t){if(E.isEventSourceSupported&&u instanceof EventSource)return function(){};(0,f.assertIsWebSocket)(u,n.current.skipAssert);var S;return u.onclose=function(b){var c;if(n.current.onClose&&n.current.onClose(b),i(E.ReadyState.CLOSED),n.current.shouldReconnect&&n.current.shouldReconnect(b)){var m=(c=n.current.reconnectAttempts)!==null&&c!==void 0?c:E.DEFAULT_RECONNECT_LIMIT;if(t.current<m){var A=typeof n.current.reconnectInterval=="function"?n.current.reconnectInterval(t.current):n.current.reconnectInterval;S=window.setTimeout(function(){t.current++,a()},A??E.DEFAULT_RECONNECT_INTERVAL_MS)}else n.current.onReconnectStop&&n.current.onReconnectStop(m),console.warn("Max reconnect attempts of ".concat(m," exceeded"))}},function(){return S&&window.clearTimeout(S)}},o=function(u,n,i,a,t){var S;return u.onerror=function(b){var c;if(n.current.onError&&n.current.onError(b),E.isEventSourceSupported&&u instanceof EventSource&&(n.current.onClose&&n.current.onClose(e(e({},b),{code:1006,reason:"An error occurred with the EventSource: ".concat(b),wasClean:!1})),i(E.ReadyState.CLOSED),u.close()),n.current.retryOnError)if(t.current<((c=n.current.reconnectAttempts)!==null&&c!==void 0?c:E.DEFAULT_RECONNECT_LIMIT)){var m=typeof n.current.reconnectInterval=="function"?n.current.reconnectInterval(t.current):n.current.reconnectInterval;S=window.setTimeout(function(){t.current++,a()},m??E.DEFAULT_RECONNECT_INTERVAL_MS)}else n.current.onReconnectStop&&n.current.onReconnectStop(n.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(n.current.reconnectAttempts," exceeded"))},function(){return S&&window.clearTimeout(S)}},s=function(u,n,i,a,t,S,b){var c=n.setLastMessage,m=n.setReadyState,A,k,O;return i.current.fromSocketIO&&(A=(0,l.setUpSocketIOPing)(b)),y(u,i,c,S),_(u,i,m,t,S),k=d(u,i,m,a,t),O=o(u,i,m,a,t),function(){m(E.ReadyState.CLOSING),k(),O(),u.close(),A&&clearInterval(A)}};return ue.attachListeners=s,ue}var oe={},mr;function At(){if(mr)return oe;mr=1;var e=oe&&oe.__assign||function(){return e=Object.assign||function(n){for(var i,a=1,t=arguments.length;a<t;a++){i=arguments[a];for(var S in i)Object.prototype.hasOwnProperty.call(i,S)&&(n[S]=i[S])}return n},e.apply(this,arguments)};Object.defineProperty(oe,"__esModule",{value:!0}),oe.attachSharedListeners=void 0;var l=Be(),h=x(),E=Ve(),f=He(),y=Pr(),_=function(n,i,a){n.onmessage=function(t){(0,E.getSubscribers)(i).forEach(function(S){var b;S.optionsRef.current.onMessage&&S.optionsRef.current.onMessage(t),typeof((b=S?.lastMessageTime)===null||b===void 0?void 0:b.current)=="number"&&(S.lastMessageTime.current=Date.now()),!(typeof S.optionsRef.current.filter=="function"&&S.optionsRef.current.filter(t)!==!0)&&(a&&typeof a!="boolean"&&a?.returnMessage===t.data||S.setLastMessage(t))})}},d=function(n,i,a){n.onopen=function(t){var S=(0,E.getSubscribers)(i);S.forEach(function(b){b.reconnectCount.current=0,b.optionsRef.current.onOpen&&b.optionsRef.current.onOpen(t),b.setReadyState(h.ReadyState.OPEN),a&&n instanceof WebSocket&&(b.lastMessageTime.current=Date.now())}),a&&n instanceof WebSocket&&(0,y.heartbeat)(n,S.map(function(b){return b.lastMessageTime}),typeof a=="boolean"?void 0:a)}},o=function(n,i){n instanceof WebSocket&&(n.onclose=function(a){(0,E.getSubscribers)(i).forEach(function(t){t.optionsRef.current.onClose&&t.optionsRef.current.onClose(a),t.setReadyState(h.ReadyState.CLOSED)}),delete l.sharedWebSockets[i],(0,E.getSubscribers)(i).forEach(function(t){var S;if(t.optionsRef.current.shouldReconnect&&t.optionsRef.current.shouldReconnect(a)){var b=(S=t.optionsRef.current.reconnectAttempts)!==null&&S!==void 0?S:h.DEFAULT_RECONNECT_LIMIT;if(t.reconnectCount.current<b){var c=typeof t.optionsRef.current.reconnectInterval=="function"?t.optionsRef.current.reconnectInterval(t.reconnectCount.current):t.optionsRef.current.reconnectInterval;setTimeout(function(){t.reconnectCount.current++,t.reconnect.current()},c??h.DEFAULT_RECONNECT_INTERVAL_MS)}else t.optionsRef.current.onReconnectStop&&t.optionsRef.current.onReconnectStop(t.optionsRef.current.reconnectAttempts),console.warn("Max reconnect attempts of ".concat(b," exceeded"))}})})},s=function(n,i){n.onerror=function(a){(0,E.getSubscribers)(i).forEach(function(t){t.optionsRef.current.onError&&t.optionsRef.current.onError(a),h.isEventSourceSupported&&n instanceof EventSource&&(t.optionsRef.current.onClose&&t.optionsRef.current.onClose(e(e({},a),{code:1006,reason:"An error occurred with the EventSource: ".concat(a),wasClean:!1})),t.setReadyState(h.ReadyState.CLOSED))}),h.isEventSourceSupported&&n instanceof EventSource&&n.close()}},u=function(n,i,a,t){var S;return a.current.fromSocketIO&&(S=(0,f.setUpSocketIOPing)(t)),_(n,i,a.current.heartbeat),o(n,i),d(n,i,a.current.heartbeat),s(n,i),function(){S&&clearInterval(S)}};return oe.attachSharedListeners=u,oe}var gr;function wt(){if(gr)return be;gr=1,Object.defineProperty(be,"__esModule",{value:!0}),be.createOrJoinSocket=void 0;var e=Be(),l=x(),h=Rt(),E=At(),f=Ve(),y=function(d,o,s,u,n){return function(){if((0,f.removeSubscriber)(d,o),!(0,f.hasSubscribers)(d)){try{var i=e.sharedWebSockets[d];i instanceof WebSocket&&(i.onclose=function(a){s.current.onClose&&s.current.onClose(a),u(l.ReadyState.CLOSED)}),i.close()}catch{}n&&n(),delete e.sharedWebSockets[d]}}},_=function(d,o,s,u,n,i,a,t,S){if(!l.isEventSourceSupported&&u.current.eventSourceOptions)throw l.isReactNative?new Error("EventSource is not supported in ReactNative"):new Error("EventSource is not supported");if(u.current.share){var b=null;e.sharedWebSockets[o]===void 0?(e.sharedWebSockets[o]=u.current.eventSourceOptions?new EventSource(o,u.current.eventSourceOptions):new WebSocket(o,u.current.protocols),d.current=e.sharedWebSockets[o],s(l.ReadyState.CONNECTING),b=(0,E.attachSharedListeners)(e.sharedWebSockets[o],o,u,S)):(d.current=e.sharedWebSockets[o],s(e.sharedWebSockets[o].readyState));var c={setLastMessage:n,setReadyState:s,optionsRef:u,reconnectCount:a,lastMessageTime:t,reconnect:i};return(0,f.addSubscriber)(o,c),y(o,c,u,s,b)}else{if(d.current=u.current.eventSourceOptions?new EventSource(o,u.current.eventSourceOptions):new WebSocket(o,u.current.protocols),s(l.ReadyState.CONNECTING),!d.current)throw new Error("WebSocket failed to be created");return(0,h.attachListeners)(d.current,{setLastMessage:n,setReadyState:s},u,i.current,a,t,S)}};return be.createOrJoinSocket=_,be}var X={},pr;function Pt(){return pr||(pr=1,(function(e){var l=X&&X.__awaiter||function(o,s,u,n){function i(a){return a instanceof u?a:new u(function(t){t(a)})}return new(u||(u=Promise))(function(a,t){function S(m){try{c(n.next(m))}catch(A){t(A)}}function b(m){try{c(n.throw(m))}catch(A){t(A)}}function c(m){m.done?a(m.value):i(m.value).then(S,b)}c((n=n.apply(o,s||[])).next())})},h=X&&X.__generator||function(o,s){var u={label:0,sent:function(){if(a[0]&1)throw a[1];return a[1]},trys:[],ops:[]},n,i,a,t=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return t.next=S(0),t.throw=S(1),t.return=S(2),typeof Symbol=="function"&&(t[Symbol.iterator]=function(){return this}),t;function S(c){return function(m){return b([c,m])}}function b(c){if(n)throw new TypeError("Generator is already executing.");for(;t&&(t=0,c[0]&&(u=0)),u;)try{if(n=1,i&&(a=c[0]&2?i.return:c[0]?i.throw||((a=i.return)&&a.call(i),0):i.next)&&!(a=a.call(i,c[1])).done)return a;switch(i=0,a&&(c=[c[0]&2,a.value]),c[0]){case 0:case 1:a=c;break;case 4:return u.label++,{value:c[1],done:!1};case 5:u.label++,i=c[1],c=[0];continue;case 7:c=u.ops.pop(),u.trys.pop();continue;default:if(a=u.trys,!(a=a.length>0&&a[a.length-1])&&(c[0]===6||c[0]===2)){u=0;continue}if(c[0]===3&&(!a||c[1]>a[0]&&c[1]<a[3])){u.label=c[1];break}if(c[0]===6&&u.label<a[1]){u.label=a[1],a=c;break}if(a&&u.label<a[2]){u.label=a[2],u.ops.push(c);break}a[2]&&u.ops.pop(),u.trys.pop();continue}c=s.call(o,u)}catch(m){c=[6,m],i=0}finally{n=a=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}},E=X&&X.__spreadArray||function(o,s,u){if(u||arguments.length===2)for(var n=0,i=s.length,a;n<i;n++)(a||!(n in s))&&(a||(a=Array.prototype.slice.call(s,0,n)),a[n]=s[n]);return o.concat(a||Array.prototype.slice.call(s))};Object.defineProperty(e,"__esModule",{value:!0}),e.getUrl=void 0;var f=He(),y=x(),_=function(o){return new Promise(function(s){return window.setTimeout(s,o)})},d=function(o,s){for(var u=[],n=2;n<arguments.length;n++)u[n-2]=arguments[n];return l(void 0,E([o,s],u,!0),void 0,function(i,a,t){var S,b,c,m,A,k,O,P;return t===void 0&&(t=0),h(this,function(I){switch(I.label){case 0:if(typeof i!="function")return[3,10];I.label=1;case 1:return I.trys.push([1,3,,9]),[4,i()];case 2:return S=I.sent(),[3,9];case 3:return I.sent(),a.current.retryOnError?(b=(k=a.current.reconnectAttempts)!==null&&k!==void 0?k:y.DEFAULT_RECONNECT_LIMIT,t<b?(c=typeof a.current.reconnectInterval=="function"?a.current.reconnectInterval(t):a.current.reconnectInterval,[4,_(c??y.DEFAULT_RECONNECT_INTERVAL_MS)]):[3,5]):[3,7];case 4:return I.sent(),[2,(0,e.getUrl)(i,a,t+1)];case 5:return(P=(O=a.current).onReconnectStop)===null||P===void 0||P.call(O,t),[2,null];case 6:return[3,8];case 7:return[2,null];case 8:return[3,9];case 9:return[3,11];case 10:S=i,I.label=11;case 11:return m=a.current.fromSocketIO?(0,f.parseSocketIOUrl)(S):S,A=a.current.queryParams?(0,f.appendQueryParams)(m,a.current.queryParams):m,[2,A]}})})};e.getUrl=d})(X)),X}var qe={},Or;function kt(){return Or||(Or=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.websocketWrapper=void 0;var l=function(h,E){return new Proxy(h,{get:function(f,y){var _=f[y];return y==="reconnect"?E:typeof _=="function"?(console.error("Calling methods directly on the websocket is not supported at this moment. You must use the methods returned by useWebSocket."),function(){}):_},set:function(f,y,_){return/^on/.test(y)?(console.warn("The websocket's event handlers should be defined through the options object passed into useWebSocket."),!1):(f[y]=_,!0)}})};e.websocketWrapper=l,e.default=e.websocketWrapper})(qe)),qe}var Tr;function xe(){if(Tr)return G;Tr=1;var e=G&&G.__assign||function(){return e=Object.assign||function(i){for(var a,t=1,S=arguments.length;t<S;t++){a=arguments[t];for(var b in a)Object.prototype.hasOwnProperty.call(a,b)&&(i[b]=a[b])}return i},e.apply(this,arguments)},l=G&&G.__awaiter||function(i,a,t,S){function b(c){return c instanceof t?c:new t(function(m){m(c)})}return new(t||(t=Promise))(function(c,m){function A(P){try{O(S.next(P))}catch(I){m(I)}}function k(P){try{O(S.throw(P))}catch(I){m(I)}}function O(P){P.done?c(P.value):b(P.value).then(A,k)}O((S=S.apply(i,a||[])).next())})},h=G&&G.__generator||function(i,a){var t={label:0,sent:function(){if(c[0]&1)throw c[1];return c[1]},trys:[],ops:[]},S,b,c,m=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return m.next=A(0),m.throw=A(1),m.return=A(2),typeof Symbol=="function"&&(m[Symbol.iterator]=function(){return this}),m;function A(O){return function(P){return k([O,P])}}function k(O){if(S)throw new TypeError("Generator is already executing.");for(;m&&(m=0,O[0]&&(t=0)),t;)try{if(S=1,b&&(c=O[0]&2?b.return:O[0]?b.throw||((c=b.return)&&c.call(b),0):b.next)&&!(c=c.call(b,O[1])).done)return c;switch(b=0,c&&(O=[O[0]&2,c.value]),O[0]){case 0:case 1:c=O;break;case 4:return t.label++,{value:O[1],done:!1};case 5:t.label++,b=O[1],O=[0];continue;case 7:O=t.ops.pop(),t.trys.pop();continue;default:if(c=t.trys,!(c=c.length>0&&c[c.length-1])&&(O[0]===6||O[0]===2)){t=0;continue}if(O[0]===3&&(!c||O[1]>c[0]&&O[1]<c[3])){t.label=O[1];break}if(O[0]===6&&t.label<c[1]){t.label=c[1],c=O;break}if(c&&t.label<c[2]){t.label=c[2],t.ops.push(O);break}c[2]&&t.ops.pop(),t.trys.pop();continue}O=a.call(i,t)}catch(P){O=[6,P],b=0}finally{S=c=0}if(O[0]&5)throw O[1];return{value:O[0]?O[1]:void 0,done:!0}}},E=G&&G.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(G,"__esModule",{value:!0}),G.useWebSocket=void 0;var f=M,y=nt,_=x(),d=wt(),o=Pt(),s=E(kt()),u=$e(),n=function(i,a,t){a===void 0&&(a=_.DEFAULT_OPTIONS),t===void 0&&(t=!0);var S=(0,f.useState)(null),b=S[0],c=S[1],m=(0,f.useState)({}),A=m[0],k=m[1],O=(0,f.useMemo)(function(){if(!a.disableJson&&b)try{return JSON.parse(b.data)}catch{return _.UNPARSABLE_JSON_OBJECT}return null},[b,a.disableJson]),P=(0,f.useRef)(null),I=(0,f.useRef)(null),de=(0,f.useRef)(function(){}),ve=(0,f.useRef)(0),ke=(0,f.useRef)(Date.now()),ge=(0,f.useRef)([]),H=(0,f.useRef)(null),j=(0,f.useRef)(a);j.current=a;var B=P.current&&A[P.current]!==void 0?A[P.current]:i!==null&&t===!0?_.ReadyState.CONNECTING:_.ReadyState.UNINSTANTIATED,re=a.queryParams?JSON.stringify(a.queryParams):null,K=(0,f.useCallback)(function(U,W){var Y;if(W===void 0&&(W=!0),_.isEventSourceSupported&&I.current instanceof EventSource){console.warn("Unable to send a message from an eventSource");return}((Y=I.current)===null||Y===void 0?void 0:Y.readyState)===_.ReadyState.OPEN?((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),I.current.send(U)):W&&ge.current.push(U)},[]),pe=(0,f.useCallback)(function(U,W){W===void 0&&(W=!0),K(JSON.stringify(U),W)},[K]),Oe=(0,f.useCallback)(function(){return j.current.share!==!0||_.isEventSourceSupported&&I.current instanceof EventSource?I.current:(H.current===null&&I.current&&((0,u.assertIsWebSocket)(I.current,j.current.skipAssert),H.current=(0,s.default)(I.current,de)),H.current)},[]);return(0,f.useEffect)(function(){if(i!==null&&t===!0){var U,W=!1,Y=!0,ye=function(){return l(void 0,void 0,void 0,function(){var te,ee,Te;return h(this,function(ie){switch(ie.label){case 0:return te=P,[4,(0,o.getUrl)(i,j)];case 1:return te.current=ie.sent(),P.current===null?(console.error("Failed to get a valid URL. WebSocket connection aborted."),P.current="ABORTED",(0,y.flushSync)(function(){return k(function(Q){return e(e({},Q),{ABORTED:_.ReadyState.CLOSED})})}),[2]):(ee=function(Q){W||(0,y.flushSync)(function(){return c(Q)})},Te=function(Q){W||(0,y.flushSync)(function(){return k(function(se){var ne;return e(e({},se),P.current&&(ne={},ne[P.current]=Q,ne))})})},Y&&(U=(0,d.createOrJoinSocket)(I,P.current,Te,j,ee,de,ve,ke,K)),[2])}})})};return de.current=function(){W||(H.current&&(H.current=null),U?.(),ye())},ye(),function(){W=!0,Y=!1,H.current&&(H.current=null),U?.(),c(null)}}else(i===null||t===!1)&&(ve.current=0,k(function(te){var ee;return e(e({},te),P.current&&(ee={},ee[P.current]=_.ReadyState.CLOSED,ee))}))},[i,t,re,K]),(0,f.useEffect)(function(){B===_.ReadyState.OPEN&&ge.current.splice(0).forEach(function(U){K(U)})},[B]),{sendMessage:K,sendJsonMessage:pe,lastMessage:b,lastJsonMessage:O,readyState:B,getWebSocket:Oe}};return G.useWebSocket=n,G}var ce={},Cr;function Nt(){if(Cr)return ce;Cr=1;var e=ce&&ce.__assign||function(){return e=Object.assign||function(d){for(var o,s=1,u=arguments.length;s<u;s++){o=arguments[s];for(var n in o)Object.prototype.hasOwnProperty.call(o,n)&&(d[n]=o[n])}return d},e.apply(this,arguments)};Object.defineProperty(ce,"__esModule",{value:!0}),ce.useSocketIO=void 0;var l=M,h=xe(),E=x(),f={type:"empty",payload:null},y=function(d){if(!d||!d.data)return f;var o=d.data.match(/\[.*]/);if(!o)return f;var s=JSON.parse(o);return!Array.isArray(s)||!s[1]?f:{type:s[0],payload:s[1]}},_=function(d,o,s){o===void 0&&(o=E.DEFAULT_OPTIONS),s===void 0&&(s=!0);var u=(0,l.useMemo)(function(){return e(e({},o),{fromSocketIO:!0})},[]),n=(0,h.useWebSocket)(d,u,s),i=n.sendMessage,a=n.sendJsonMessage,t=n.lastMessage,S=n.readyState,b=n.getWebSocket,c=(0,l.useMemo)(function(){return y(t)},[t]);return{sendMessage:i,sendJsonMessage:a,lastMessage:c,lastJsonMessage:c,readyState:S,getWebSocket:b}};return ce.useSocketIO=_,ce}var Z={},Rr;function It(){if(Rr)return Z;Rr=1;var e=Z&&Z.__assign||function(){return e=Object.assign||function(_){for(var d,o=1,s=arguments.length;o<s;o++){d=arguments[o];for(var u in d)Object.prototype.hasOwnProperty.call(d,u)&&(_[u]=d[u])}return _},e.apply(this,arguments)},l=Z&&Z.__rest||function(_,d){var o={};for(var s in _)Object.prototype.hasOwnProperty.call(_,s)&&d.indexOf(s)<0&&(o[s]=_[s]);if(_!=null&&typeof Object.getOwnPropertySymbols=="function")for(var u=0,s=Object.getOwnPropertySymbols(_);u<s.length;u++)d.indexOf(s[u])<0&&Object.prototype.propertyIsEnumerable.call(_,s[u])&&(o[s[u]]=_[s[u]]);return o};Object.defineProperty(Z,"__esModule",{value:!0}),Z.useEventSource=void 0;var h=M,E=xe(),f=x(),y=function(_,d,o){d===void 0&&(d=f.DEFAULT_EVENT_SOURCE_OPTIONS);var s=d.withCredentials,u=d.events,n=l(d,["withCredentials","events"]);o===void 0&&(o=!0);var i=e(e({},n),{eventSourceOptions:{withCredentials:s}}),a=(0,h.useRef)(f.EMPTY_EVENT_HANDLERS);u&&(a.current=u);var t=(0,E.useWebSocket)(_,i,o),S=t.lastMessage,b=t.readyState,c=t.getWebSocket;return(0,h.useEffect)(function(){S?.type&&Object.entries(a.current).forEach(function(m){var A=m[0],k=m[1];A===S.type&&k(S)})},[S]),{lastEvent:S,readyState:b,getEventSource:c}};return Z.useEventSource=y,Z}var Ar;function Mt(){return Ar||(Ar=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.resetGlobalState=e.useEventSource=e.ReadyState=e.useSocketIO=e.default=void 0;var l=xe();Object.defineProperty(e,"default",{enumerable:!0,get:function(){return l.useWebSocket}});var h=Nt();Object.defineProperty(e,"useSocketIO",{enumerable:!0,get:function(){return h.useSocketIO}});var E=x();Object.defineProperty(e,"ReadyState",{enumerable:!0,get:function(){return E.ReadyState}});var f=It();Object.defineProperty(e,"useEventSource",{enumerable:!0,get:function(){return f.useEventSource}});var y=$e();Object.defineProperty(e,"resetGlobalState",{enumerable:!0,get:function(){return y.resetGlobalState}})})(Ue)),Ue}var Dt=Mt();const Lt=at(Dt),V={DEPOSIT:"deposit",TRANS_CODE:"transCode",ERROR:"error",UPDATE_MEMBER:"update_member",MAINTAIN_NOTICE:"maintain_notice",MAINTAIN_NOTICE_MEMBER:"maintain_notice_member",RELOAD:"reload",TRANSFER_IN_GAME:"transfer_in_game",CHECK_REQUEST:"CHECK_RREQUEST",CASH_REGISTER_LIMIT:"cash_register_limit"},Ut=3e4,jt=({socketUrl:e,socketHandlers:l={},options:h={}})=>{const E=M.useRef(!1),f=M.useRef(l),{sendMessage:y,sendJsonMessage:_,lastMessage:d,readyState:o}=Lt(e,{queryParams:{key:"wsky"},onOpen:()=>console.log("連線成功"),shouldReconnect:()=>E.current===!1,reconnectAttempts:9999,reconnectInterval:1e3,...h}),s=M.useMemo(()=>{try{return JSON.parse(d?.data)}catch{return null}},[d?.data]);return M.useEffect(()=>{const u=setInterval(()=>y("ping"),Ut);return()=>clearInterval(u)},[y]),M.useEffect(()=>{f.current=l},[l]),M.useEffect(()=>{if(!s)return;const{onDeposit:u,onTransCode:n,onError:i,onUpdateMember:a,onMaintainNotice:t,onMaintainNoticeMember:S,onReload:b,onTransferInGame:c,onCashRegisterLimit:m}=f.current,A=R.get(s,"type",""),k={memberInfoUid:R.get(s,"member_info_uid",null),data:R.get(s,"data",null),memo:R.get(s,"memo",null)};switch(A){case V.DEPOSIT:u?.(k);break;case V.TRANS_CODE:n?.(k);break;case V.ERROR:i?.(k);break;case V.UPDATE_MEMBER:a?.(k);break;case V.MAINTAIN_NOTICE:t?.(k);break;case V.MAINTAIN_NOTICE_MEMBER:S?.(k);break;case V.RELOAD:b?.(k);break;case V.TRANSFER_IN_GAME:case V.CHECK_REQUEST:c?.(k);break;case V.CASH_REGISTER_LIMIT:m?.(k);break;default:console.warn("Unknown socket type:",A);break}},[s]),M.useEffect(()=>()=>E.current=!0,[]),{sendMessage:y,sendJsonMessage:_,readyState:o}},kr=()=>{const{client:e}=me(),l=M.useCallback(async()=>{const{data:E}=await e.get("/carousels");return E},[e]),h=M.useCallback(async()=>await e.get("/marquees"),[e]);return{commonCarouselApi:l,commonMarqueeApi:h}},Wt=()=>{const{commonCarouselApi:e}=kr();return $.useQuery({queryKey:["getCarouselList"],queryFn:async()=>await e()})},Ft=()=>{const{commonMarqueeApi:e}=kr();return $.useQuery({queryKey:["getMarqueeList"],queryFn:async()=>e(),select:l=>l.Marquees})};exports.ApiCtx=Ge;exports.ApiProvider=st;exports.buildPlatformDataForType=wr;exports.constructGameList=Et;exports.createLogoutHandler=lt;exports.extractGameSubTypeNames=ht;exports.extractGameTypeNames=bt;exports.extractPlatformNames=_t;exports.flattenAllGames=St;exports.flattenFavoriteGames=mt;exports.processPlatformData=pt;exports.sortByGameTypeAndPlatformAndSubType=gt;exports.useApiContext=me;exports.useBalanceGetter=Ot;exports.useClientWebSocket=jt;exports.useGetCarouseList=Wt;exports.useGetMarquee=Ft;exports.useGetMemberInfo=Tt;exports.useInitializeWithToken=Ct;
|