// Module ID: 9892 // Function ID: 9893 // Name: fetchStore // Dependencies: [32, 19, 5022, 676, 589, 5023, 9893, 2] // Exports: useDebouncedGameAutocomplete // Module 9892 (fetchStore) import GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH from "GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH" /* 5023 */; import _fetchGameAutocomplete from "_fetchGameAutocomplete" /* 9893 */; import closure_2 from "_slicedToArray" /* 32 */; import closure_3 from "noop" /* 19 */; import importDefaultResult from "set" /* 5022 */; import { QueryIds } from "ME" /* 676 */; import initialize from "initialize" /* 589 */; require = arg1; let c4 = importDefaultResult; initialize = { getQueryId(c0) { return QueryIds.GAME_AUTOCOMPLETE(GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH.normalizeGameAutocompleteQuery(c0)); }, get(arg0) { let results = importDefaultResult.getResults(arg0); if (results == null) { results = null; } return results; }, load(arg0) { return _fetchGameAutocomplete.fetchGameAutocomplete(arg0); }, getIsLoading(arg0) { return importDefaultResult.isFetching(arg0); }, retryConfig: initialize, staleAfter: 3600, failureStaleAfter: 60 }; initialize = { retryableErrors: function isRetryableError(status) { status = status.status; let tmp = null != status; if (tmp) { let tmp2 = 429 === status; if (!tmp2) { let tmp3 = status >= 500; if (tmp3) { tmp3 = 503 !== status; } tmp2 = tmp3; } tmp = tmp2; } return tmp; } }; const fetchStore = initialize.createFetchStore(importDefaultResult, initialize); let result = require("set").fileFinishedImporting("modules/games/autocomplete/useGameAutocomplete.tsx"); export const GAME_AUTOCOMPLETE_DEBOUNCE_MS = 200; export const GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS = 500; export const useGameAutocomplete = fetchStore; export const useDebouncedGameAutocomplete = function useDebouncedGameAutocomplete(c0) { let obj = GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH; const result = obj.normalizeGameAutocompleteQuery(c0); require = result; dependencyMap = undefined; let callback; let React; [tmp3, c1] = callback(React.useState(result), 2); callback = React.useRef(tmp3); React = React.useRef(0); const items = [result]; const effect = React.useEffect(() => { if (timeout !== ref.current) { if (null != tmp) { if (null != tmp2.current) { const _Date2 = Date; function emit() { closure_3.current = Date.now(); closure_2.current = closure_0; callback(closure_0); } const _Math = Math; const _Math2 = Math; const _setTimeout = setTimeout; timeout = setTimeout(emit, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current)))); return () => { clearTimeout(closure_0); }; } } const _Date = Date; ref2.current = Date.now(); tmp2.current = tmp; _undefined(tmp); } }, items); const tmp5 = fetchStore(tmp3); ({ data, isLoading } = tmp5); const tmp2 = callback(React.useState(result), 2); [tmp7, tmp8] = callback(React.useState(null), 2); if (null == result) { if (null != tmp7) { tmp8(null); } } else { if (tmp9) { tmp8(data); } tmp9 = null != data && data !== tmp7; } let tmp12 = null; if (null != result) { if (data == null) { data = tmp7; } tmp12 = data; } obj = { results: tmp12, isLoading: null, error: null }; if (!isLoading) { isLoading = tmp3 !== result; } obj[1] = isLoading; error = null; if (tmp3 === result) { error = tmp5.error; } obj[2] = error; return obj; };