1 | var __generator = (this && this.__generator) || function (thisArg, body) {
|
2 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
3 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
4 | function verb(n) { return function (v) { return step([n, v]); }; }
|
5 | function step(op) {
|
6 | if (f) throw new TypeError("Generator is already executing.");
|
7 | while (_) try {
|
8 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
9 | if (y = 0, t) op = [op[0] & 2, t.value];
|
10 | switch (op[0]) {
|
11 | case 0: case 1: t = op; break;
|
12 | case 4: _.label++; return { value: op[1], done: false };
|
13 | case 5: _.label++; y = op[1]; op = [0]; continue;
|
14 | case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
15 | default:
|
16 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
17 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
18 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
19 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
20 | if (t[2]) _.ops.pop();
|
21 | _.trys.pop(); continue;
|
22 | }
|
23 | op = body.call(thisArg, _);
|
24 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
25 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
26 | }
|
27 | };
|
28 | var __spreadArray = (this && this.__spreadArray) || function (to, from) {
|
29 | for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
|
30 | to[j] = from[i];
|
31 | return to;
|
32 | };
|
33 | var __create = Object.create;
|
34 | var __defProp = Object.defineProperty;
|
35 | var __defProps = Object.defineProperties;
|
36 | var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
37 | var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
38 | var __getOwnPropNames = Object.getOwnPropertyNames;
|
39 | var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
40 | var __getProtoOf = Object.getPrototypeOf;
|
41 | var __hasOwnProp = Object.prototype.hasOwnProperty;
|
42 | var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
43 | var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
|
44 | var __spreadValues = function (a, b) {
|
45 | for (var prop in b || (b = {}))
|
46 | if (__hasOwnProp.call(b, prop))
|
47 | __defNormalProp(a, prop, b[prop]);
|
48 | if (__getOwnPropSymbols)
|
49 | for (var _j = 0, _k = __getOwnPropSymbols(b); _j < _k.length; _j++) {
|
50 | var prop = _k[_j];
|
51 | if (__propIsEnum.call(b, prop))
|
52 | __defNormalProp(a, prop, b[prop]);
|
53 | }
|
54 | return a;
|
55 | };
|
56 | var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
|
57 | var __markAsModule = function (target) { return __defProp(target, "__esModule", { value: true }); };
|
58 | var __objRest = function (source, exclude) {
|
59 | var target = {};
|
60 | for (var prop in source)
|
61 | if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
62 | target[prop] = source[prop];
|
63 | if (source != null && __getOwnPropSymbols)
|
64 | for (var _j = 0, _k = __getOwnPropSymbols(source); _j < _k.length; _j++) {
|
65 | var prop = _k[_j];
|
66 | if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
67 | target[prop] = source[prop];
|
68 | }
|
69 | return target;
|
70 | };
|
71 | var __export = function (target, all) {
|
72 | for (var name in all)
|
73 | __defProp(target, name, { get: all[name], enumerable: true });
|
74 | };
|
75 | var __reExport = function (target, module2, desc) {
|
76 | if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
77 | var _loop_1 = function (key) {
|
78 | if (!__hasOwnProp.call(target, key) && key !== "default")
|
79 | __defProp(target, key, { get: function () { return module2[key]; }, enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
80 | };
|
81 | for (var _j = 0, _k = __getOwnPropNames(module2); _j < _k.length; _j++) {
|
82 | var key = _k[_j];
|
83 | _loop_1(key);
|
84 | }
|
85 | }
|
86 | return target;
|
87 | };
|
88 | var __toModule = function (module2) {
|
89 | return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: function () { return module2.default; }, enumerable: true } : { value: module2, enumerable: true })), module2);
|
90 | };
|
91 | var __async = function (__this, __arguments, generator) {
|
92 | return new Promise(function (resolve, reject) {
|
93 | var fulfilled = function (value) {
|
94 | try {
|
95 | step(generator.next(value));
|
96 | }
|
97 | catch (e) {
|
98 | reject(e);
|
99 | }
|
100 | };
|
101 | var rejected = function (value) {
|
102 | try {
|
103 | step(generator.throw(value));
|
104 | }
|
105 | catch (e) {
|
106 | reject(e);
|
107 | }
|
108 | };
|
109 | var step = function (x) { return x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected); };
|
110 | step((generator = generator.apply(__this, __arguments)).next());
|
111 | });
|
112 | };
|
113 |
|
114 | __markAsModule(exports);
|
115 | __export(exports, {
|
116 | QueryStatus: function () { return QueryStatus; },
|
117 | buildCreateApi: function () { return buildCreateApi; },
|
118 | copyWithStructuralSharing: function () { return copyWithStructuralSharing; },
|
119 | coreModule: function () { return coreModule; },
|
120 | createApi: function () { return createApi; },
|
121 | defaultSerializeQueryArgs: function () { return defaultSerializeQueryArgs; },
|
122 | fakeBaseQuery: function () { return fakeBaseQuery; },
|
123 | fetchBaseQuery: function () { return fetchBaseQuery; },
|
124 | retry: function () { return retry; },
|
125 | setupListeners: function () { return setupListeners; },
|
126 | skipSelector: function () { return skipSelector; },
|
127 | skipToken: function () { return skipToken; }
|
128 | });
|
129 |
|
130 | var QueryStatus;
|
131 | (function (QueryStatus2) {
|
132 | QueryStatus2["uninitialized"] = "uninitialized";
|
133 | QueryStatus2["pending"] = "pending";
|
134 | QueryStatus2["fulfilled"] = "fulfilled";
|
135 | QueryStatus2["rejected"] = "rejected";
|
136 | })(QueryStatus || (QueryStatus = {}));
|
137 | function getRequestStatusFlags(status) {
|
138 | return {
|
139 | status: status,
|
140 | isUninitialized: status === QueryStatus.uninitialized,
|
141 | isLoading: status === QueryStatus.pending,
|
142 | isSuccess: status === QueryStatus.fulfilled,
|
143 | isError: status === QueryStatus.rejected
|
144 | };
|
145 | }
|
146 |
|
147 | function isAbsoluteUrl(url) {
|
148 | return new RegExp("(^|:)//").test(url);
|
149 | }
|
150 |
|
151 | var withoutTrailingSlash = function (url) { return url.replace(/\/$/, ""); };
|
152 | var withoutLeadingSlash = function (url) { return url.replace(/^\//, ""); };
|
153 | function joinUrls(base, url) {
|
154 | if (!base) {
|
155 | return url;
|
156 | }
|
157 | if (!url) {
|
158 | return base;
|
159 | }
|
160 | if (isAbsoluteUrl(url)) {
|
161 | return url;
|
162 | }
|
163 | var delimiter = base.endsWith("/") || !url.startsWith("?") ? "/" : "";
|
164 | base = withoutTrailingSlash(base);
|
165 | url = withoutLeadingSlash(url);
|
166 | return "" + base + delimiter + url;
|
167 | }
|
168 |
|
169 | var flatten = function (arr) { return [].concat.apply([], arr); };
|
170 |
|
171 | function isOnline() {
|
172 | return typeof navigator === "undefined" ? true : navigator.onLine === void 0 ? true : navigator.onLine;
|
173 | }
|
174 |
|
175 | function isDocumentVisible() {
|
176 | if (typeof document === "undefined") {
|
177 | return true;
|
178 | }
|
179 | return document.visibilityState !== "hidden";
|
180 | }
|
181 |
|
182 | var import_toolkit = __toModule(require("@reduxjs/toolkit"));
|
183 | var isPlainObject = import_toolkit.isPlainObject;
|
184 | function copyWithStructuralSharing(oldObj, newObj) {
|
185 | if (oldObj === newObj || !(isPlainObject(oldObj) && isPlainObject(newObj) || Array.isArray(oldObj) && Array.isArray(newObj))) {
|
186 | return newObj;
|
187 | }
|
188 | var newKeys = Object.keys(newObj);
|
189 | var oldKeys = Object.keys(oldObj);
|
190 | var isSameObject = newKeys.length === oldKeys.length;
|
191 | var mergeObj = Array.isArray(newObj) ? [] : {};
|
192 | for (var _j = 0, newKeys_1 = newKeys; _j < newKeys_1.length; _j++) {
|
193 | var key = newKeys_1[_j];
|
194 | mergeObj[key] = copyWithStructuralSharing(oldObj[key], newObj[key]);
|
195 | if (isSameObject)
|
196 | isSameObject = oldObj[key] === mergeObj[key];
|
197 | }
|
198 | return isSameObject ? oldObj : mergeObj;
|
199 | }
|
200 |
|
201 | var import_toolkit2 = __toModule(require("@reduxjs/toolkit"));
|
202 | var defaultFetchFn = function () {
|
203 | var args = [];
|
204 | for (var _j = 0; _j < arguments.length; _j++) {
|
205 | args[_j] = arguments[_j];
|
206 | }
|
207 | return fetch.apply(void 0, args);
|
208 | };
|
209 | var defaultValidateStatus = function (response) { return response.status >= 200 && response.status <= 299; };
|
210 | var defaultIsJsonContentType = function (headers) { return /ion\/(vnd\.api\+)?json/.test(headers.get("content-type") || ""); };
|
211 | function stripUndefined(obj) {
|
212 | if (!(0, import_toolkit2.isPlainObject)(obj)) {
|
213 | return obj;
|
214 | }
|
215 | var copy = __spreadValues({}, obj);
|
216 | for (var _j = 0, _k = Object.entries(copy); _j < _k.length; _j++) {
|
217 | var _l = _k[_j], k = _l[0], v = _l[1];
|
218 | if (v === void 0)
|
219 | delete copy[k];
|
220 | }
|
221 | return copy;
|
222 | }
|
223 | function fetchBaseQuery(_a) {
|
224 | var _this = this;
|
225 | if (_a === void 0) { _a = {}; }
|
226 | var _b = _a, baseUrl = _b.baseUrl, _j = _b.prepareHeaders, prepareHeaders = _j === void 0 ? function (x) { return x; } : _j, _k = _b.fetchFn, fetchFn = _k === void 0 ? defaultFetchFn : _k, paramsSerializer = _b.paramsSerializer, _l = _b.isJsonContentType, isJsonContentType = _l === void 0 ? defaultIsJsonContentType : _l, _m = _b.jsonContentType, jsonContentType = _m === void 0 ? "application/json" : _m, jsonReplacer = _b.jsonReplacer, defaultTimeout = _b.timeout, globalValidateStatus = _b.validateStatus, baseFetchOptions = __objRest(_b, [
|
227 | "baseUrl",
|
228 | "prepareHeaders",
|
229 | "fetchFn",
|
230 | "paramsSerializer",
|
231 | "isJsonContentType",
|
232 | "jsonContentType",
|
233 | "jsonReplacer",
|
234 | "timeout",
|
235 | "validateStatus"
|
236 | ]);
|
237 | if (typeof fetch === "undefined" && fetchFn === defaultFetchFn) {
|
238 | console.warn("Warning: `fetch` is not available. Please supply a custom `fetchFn` property to use `fetchBaseQuery` on SSR environments.");
|
239 | }
|
240 | return function (arg, api) { return __async(_this, null, function () {
|
241 | var signal, getState, extra, endpoint, forced, type, meta, _a2, url, _j, headers, _k, params, _l, responseHandler, _m, validateStatus, _o, timeout, rest, config, _p, isJsonifiable, divider, query, request, requestClone, response, timedOut, timeoutId, e_1, responseClone, resultData, responseText, handleResponseError_1, e_2;
|
242 | return __generator(this, function (_q) {
|
243 | switch (_q.label) {
|
244 | case 0:
|
245 | signal = api.signal, getState = api.getState, extra = api.extra, endpoint = api.endpoint, forced = api.forced, type = api.type;
|
246 | _a2 = typeof arg == "string" ? { url: arg } : arg, url = _a2.url, _j = _a2.headers, headers = _j === void 0 ? new Headers(baseFetchOptions.headers) : _j, _k = _a2.params, params = _k === void 0 ? void 0 : _k, _l = _a2.responseHandler, responseHandler = _l === void 0 ? "json" : _l, _m = _a2.validateStatus, validateStatus = _m === void 0 ? globalValidateStatus != null ? globalValidateStatus : defaultValidateStatus : _m, _o = _a2.timeout, timeout = _o === void 0 ? defaultTimeout : _o, rest = __objRest(_a2, [
|
247 | "url",
|
248 | "headers",
|
249 | "params",
|
250 | "responseHandler",
|
251 | "validateStatus",
|
252 | "timeout"
|
253 | ]);
|
254 | config = __spreadValues(__spreadProps(__spreadValues({}, baseFetchOptions), {
|
255 | signal: signal
|
256 | }), rest);
|
257 | headers = new Headers(stripUndefined(headers));
|
258 | _p = config;
|
259 | return [4 , prepareHeaders(headers, {
|
260 | getState: getState,
|
261 | extra: extra,
|
262 | endpoint: endpoint,
|
263 | forced: forced,
|
264 | type: type
|
265 | })];
|
266 | case 1:
|
267 | _p.headers = (_q.sent()) || headers;
|
268 | isJsonifiable = function (body) { return typeof body === "object" && ((0, import_toolkit2.isPlainObject)(body) || Array.isArray(body) || typeof body.toJSON === "function"); };
|
269 | if (!config.headers.has("content-type") && isJsonifiable(config.body)) {
|
270 | config.headers.set("content-type", jsonContentType);
|
271 | }
|
272 | if (isJsonifiable(config.body) && isJsonContentType(config.headers)) {
|
273 | config.body = JSON.stringify(config.body, jsonReplacer);
|
274 | }
|
275 | if (params) {
|
276 | divider = ~url.indexOf("?") ? "&" : "?";
|
277 | query = paramsSerializer ? paramsSerializer(params) : new URLSearchParams(stripUndefined(params));
|
278 | url += divider + query;
|
279 | }
|
280 | url = joinUrls(baseUrl, url);
|
281 | request = new Request(url, config);
|
282 | requestClone = request.clone();
|
283 | meta = { request: requestClone };
|
284 | timedOut = false, timeoutId = timeout && setTimeout(function () {
|
285 | timedOut = true;
|
286 | api.abort();
|
287 | }, timeout);
|
288 | _q.label = 2;
|
289 | case 2:
|
290 | _q.trys.push([2, 4, 5, 6]);
|
291 | return [4 , fetchFn(request)];
|
292 | case 3:
|
293 | response = _q.sent();
|
294 | return [3 , 6];
|
295 | case 4:
|
296 | e_1 = _q.sent();
|
297 | return [2 , {
|
298 | error: {
|
299 | status: timedOut ? "TIMEOUT_ERROR" : "FETCH_ERROR",
|
300 | error: String(e_1)
|
301 | },
|
302 | meta: meta
|
303 | }];
|
304 | case 5:
|
305 | if (timeoutId)
|
306 | clearTimeout(timeoutId);
|
307 | return [7 ];
|
308 | case 6:
|
309 | responseClone = response.clone();
|
310 | meta.response = responseClone;
|
311 | responseText = "";
|
312 | _q.label = 7;
|
313 | case 7:
|
314 | _q.trys.push([7, 9, , 10]);
|
315 | return [4 , Promise.all([
|
316 | handleResponse(response, responseHandler).then(function (r) { return resultData = r; }, function (e) { return handleResponseError_1 = e; }),
|
317 | responseClone.text().then(function (r) { return responseText = r; }, function () {
|
318 | })
|
319 | ])];
|
320 | case 8:
|
321 | _q.sent();
|
322 | if (handleResponseError_1)
|
323 | throw handleResponseError_1;
|
324 | return [3 , 10];
|
325 | case 9:
|
326 | e_2 = _q.sent();
|
327 | return [2 , {
|
328 | error: {
|
329 | status: "PARSING_ERROR",
|
330 | originalStatus: response.status,
|
331 | data: responseText,
|
332 | error: String(e_2)
|
333 | },
|
334 | meta: meta
|
335 | }];
|
336 | case 10: return [2 , validateStatus(response, resultData) ? {
|
337 | data: resultData,
|
338 | meta: meta
|
339 | } : {
|
340 | error: {
|
341 | status: response.status,
|
342 | data: resultData
|
343 | },
|
344 | meta: meta
|
345 | }];
|
346 | }
|
347 | });
|
348 | }); };
|
349 | function handleResponse(response, responseHandler) {
|
350 | return __async(this, null, function () {
|
351 | var text;
|
352 | return __generator(this, function (_j) {
|
353 | switch (_j.label) {
|
354 | case 0:
|
355 | if (typeof responseHandler === "function") {
|
356 | return [2 , responseHandler(response)];
|
357 | }
|
358 | if (responseHandler === "content-type") {
|
359 | responseHandler = isJsonContentType(response.headers) ? "json" : "text";
|
360 | }
|
361 | if (!(responseHandler === "json")) return [3 , 2];
|
362 | return [4 , response.text()];
|
363 | case 1:
|
364 | text = _j.sent();
|
365 | return [2 , text.length ? JSON.parse(text) : null];
|
366 | case 2: return [2 , response.text()];
|
367 | }
|
368 | });
|
369 | });
|
370 | }
|
371 | }
|
372 |
|
373 | var HandledError = (function () {
|
374 | function HandledError(value, meta) {
|
375 | if (meta === void 0) { meta = void 0; }
|
376 | this.value = value;
|
377 | this.meta = meta;
|
378 | }
|
379 | return HandledError;
|
380 | }());
|
381 |
|
382 | function defaultBackoff(attempt, maxRetries) {
|
383 | if (attempt === void 0) { attempt = 0; }
|
384 | if (maxRetries === void 0) { maxRetries = 5; }
|
385 | return __async(this, null, function () {
|
386 | var attempts, timeout;
|
387 | return __generator(this, function (_j) {
|
388 | switch (_j.label) {
|
389 | case 0:
|
390 | attempts = Math.min(attempt, maxRetries);
|
391 | timeout = ~~((Math.random() + 0.4) * (300 << attempts));
|
392 | return [4 , new Promise(function (resolve) { return setTimeout(function (res) { return resolve(res); }, timeout); })];
|
393 | case 1:
|
394 | _j.sent();
|
395 | return [2 ];
|
396 | }
|
397 | });
|
398 | });
|
399 | }
|
400 | function fail(e) {
|
401 | throw Object.assign(new HandledError({ error: e }), {
|
402 | throwImmediately: true
|
403 | });
|
404 | }
|
405 | var EMPTY_OPTIONS = {};
|
406 | var retryWithBackoff = function (baseQuery, defaultOptions) { return function (args, api, extraOptions) { return __async(void 0, null, function () {
|
407 | var possibleMaxRetries, maxRetries, defaultRetryCondition, options, retry2, result, e_3;
|
408 | return __generator(this, function (_j) {
|
409 | switch (_j.label) {
|
410 | case 0:
|
411 | possibleMaxRetries = [
|
412 | 5,
|
413 | (defaultOptions || EMPTY_OPTIONS).maxRetries,
|
414 | (extraOptions || EMPTY_OPTIONS).maxRetries
|
415 | ].filter(function (x) { return x !== void 0; });
|
416 | maxRetries = possibleMaxRetries.slice(-1)[0];
|
417 | defaultRetryCondition = function (_, __, _j) {
|
418 | var attempt = _j.attempt;
|
419 | return attempt <= maxRetries;
|
420 | };
|
421 | options = __spreadValues(__spreadValues({
|
422 | maxRetries: maxRetries,
|
423 | backoff: defaultBackoff,
|
424 | retryCondition: defaultRetryCondition
|
425 | }, defaultOptions), extraOptions);
|
426 | retry2 = 0;
|
427 | _j.label = 1;
|
428 | case 1:
|
429 | if (!true) return [3 , 7];
|
430 | _j.label = 2;
|
431 | case 2:
|
432 | _j.trys.push([2, 4, , 6]);
|
433 | return [4 , baseQuery(args, api, extraOptions)];
|
434 | case 3:
|
435 | result = _j.sent();
|
436 | if (result.error) {
|
437 | throw new HandledError(result);
|
438 | }
|
439 | return [2 , result];
|
440 | case 4:
|
441 | e_3 = _j.sent();
|
442 | retry2++;
|
443 | if (e_3.throwImmediately) {
|
444 | if (e_3 instanceof HandledError) {
|
445 | return [2 , e_3.value];
|
446 | }
|
447 | throw e_3;
|
448 | }
|
449 | if (e_3 instanceof HandledError && !options.retryCondition(e_3.value.error, args, {
|
450 | attempt: retry2,
|
451 | baseQueryApi: api,
|
452 | extraOptions: extraOptions
|
453 | })) {
|
454 | return [2 , e_3.value];
|
455 | }
|
456 | return [4 , options.backoff(retry2, options.maxRetries)];
|
457 | case 5:
|
458 | _j.sent();
|
459 | return [3 , 6];
|
460 | case 6: return [3 , 1];
|
461 | case 7: return [2 ];
|
462 | }
|
463 | });
|
464 | }); }; };
|
465 | var retry = Object.assign(retryWithBackoff, { fail: fail });
|
466 |
|
467 | var import_toolkit3 = __toModule(require("@reduxjs/toolkit"));
|
468 | var onFocus = (0, import_toolkit3.createAction)("__rtkq/focused");
|
469 | var onFocusLost = (0, import_toolkit3.createAction)("__rtkq/unfocused");
|
470 | var onOnline = (0, import_toolkit3.createAction)("__rtkq/online");
|
471 | var onOffline = (0, import_toolkit3.createAction)("__rtkq/offline");
|
472 | var initialized = false;
|
473 | function setupListeners(dispatch, customHandler) {
|
474 | function defaultHandler() {
|
475 | var handleFocus = function () { return dispatch(onFocus()); };
|
476 | var handleFocusLost = function () { return dispatch(onFocusLost()); };
|
477 | var handleOnline = function () { return dispatch(onOnline()); };
|
478 | var handleOffline = function () { return dispatch(onOffline()); };
|
479 | var handleVisibilityChange = function () {
|
480 | if (window.document.visibilityState === "visible") {
|
481 | handleFocus();
|
482 | }
|
483 | else {
|
484 | handleFocusLost();
|
485 | }
|
486 | };
|
487 | if (!initialized) {
|
488 | if (typeof window !== "undefined" && window.addEventListener) {
|
489 | window.addEventListener("visibilitychange", handleVisibilityChange, false);
|
490 | window.addEventListener("focus", handleFocus, false);
|
491 | window.addEventListener("online", handleOnline, false);
|
492 | window.addEventListener("offline", handleOffline, false);
|
493 | initialized = true;
|
494 | }
|
495 | }
|
496 | var unsubscribe = function () {
|
497 | window.removeEventListener("focus", handleFocus);
|
498 | window.removeEventListener("visibilitychange", handleVisibilityChange);
|
499 | window.removeEventListener("online", handleOnline);
|
500 | window.removeEventListener("offline", handleOffline);
|
501 | initialized = false;
|
502 | };
|
503 | return unsubscribe;
|
504 | }
|
505 | return customHandler ? customHandler(dispatch, { onFocus: onFocus, onFocusLost: onFocusLost, onOffline: onOffline, onOnline: onOnline }) : defaultHandler();
|
506 | }
|
507 |
|
508 | var import_toolkit7 = __toModule(require("@reduxjs/toolkit"));
|
509 |
|
510 | var DefinitionType;
|
511 | (function (DefinitionType2) {
|
512 | DefinitionType2["query"] = "query";
|
513 | DefinitionType2["mutation"] = "mutation";
|
514 | })(DefinitionType || (DefinitionType = {}));
|
515 | function isQueryDefinition(e) {
|
516 | return e.type === DefinitionType.query;
|
517 | }
|
518 | function isMutationDefinition(e) {
|
519 | return e.type === DefinitionType.mutation;
|
520 | }
|
521 | function calculateProvidedBy(description, result, error, queryArg, meta, assertTagTypes) {
|
522 | if (isFunction(description)) {
|
523 | return description(result, error, queryArg, meta).map(expandTagDescription).map(assertTagTypes);
|
524 | }
|
525 | if (Array.isArray(description)) {
|
526 | return description.map(expandTagDescription).map(assertTagTypes);
|
527 | }
|
528 | return [];
|
529 | }
|
530 | function isFunction(t) {
|
531 | return typeof t === "function";
|
532 | }
|
533 | function expandTagDescription(description) {
|
534 | return typeof description === "string" ? { type: description } : description;
|
535 | }
|
536 |
|
537 | var import_toolkit6 = __toModule(require("@reduxjs/toolkit"));
|
538 |
|
539 | function isNotNullish(v) {
|
540 | return v != null;
|
541 | }
|
542 |
|
543 | var forceQueryFnSymbol = Symbol("forceQueryFn");
|
544 | var isUpsertQuery = function (arg) { return typeof arg[forceQueryFnSymbol] === "function"; };
|
545 | function buildInitiate(_j) {
|
546 | var serializeQueryArgs = _j.serializeQueryArgs, queryThunk = _j.queryThunk, mutationThunk = _j.mutationThunk, api = _j.api, context = _j.context;
|
547 | var runningQueries = new Map();
|
548 | var runningMutations = new Map();
|
549 | var _k = api.internalActions, unsubscribeQueryResult = _k.unsubscribeQueryResult, removeMutationResult = _k.removeMutationResult, updateSubscriptionOptions = _k.updateSubscriptionOptions;
|
550 | return {
|
551 | buildInitiateQuery: buildInitiateQuery,
|
552 | buildInitiateMutation: buildInitiateMutation,
|
553 | getRunningQueryThunk: getRunningQueryThunk,
|
554 | getRunningMutationThunk: getRunningMutationThunk,
|
555 | getRunningQueriesThunk: getRunningQueriesThunk,
|
556 | getRunningMutationsThunk: getRunningMutationsThunk,
|
557 | getRunningOperationPromises: getRunningOperationPromises,
|
558 | removalWarning: removalWarning
|
559 | };
|
560 | function removalWarning() {
|
561 | throw new Error("This method had to be removed due to a conceptual bug in RTK.\n Please see https://github.com/reduxjs/redux-toolkit/pull/2481 for details.\n See https://redux-toolkit.js.org/rtk-query/usage/server-side-rendering for new guidance on SSR.");
|
562 | }
|
563 | function getRunningOperationPromises() {
|
564 | if (typeof process !== "undefined" && true) {
|
565 | removalWarning();
|
566 | }
|
567 | else {
|
568 | var extract = function (v) { return Array.from(v.values()).flatMap(function (queriesForStore) { return queriesForStore ? Object.values(queriesForStore) : []; }); };
|
569 | return __spreadArray(__spreadArray([], extract(runningQueries)), extract(runningMutations)).filter(isNotNullish);
|
570 | }
|
571 | }
|
572 | function getRunningQueryThunk(endpointName, queryArgs) {
|
573 | return function (dispatch) {
|
574 | var _a;
|
575 | var endpointDefinition = context.endpointDefinitions[endpointName];
|
576 | var queryCacheKey = serializeQueryArgs({
|
577 | queryArgs: queryArgs,
|
578 | endpointDefinition: endpointDefinition,
|
579 | endpointName: endpointName
|
580 | });
|
581 | return (_a = runningQueries.get(dispatch)) == null ? void 0 : _a[queryCacheKey];
|
582 | };
|
583 | }
|
584 | function getRunningMutationThunk(_endpointName, fixedCacheKeyOrRequestId) {
|
585 | return function (dispatch) {
|
586 | var _a;
|
587 | return (_a = runningMutations.get(dispatch)) == null ? void 0 : _a[fixedCacheKeyOrRequestId];
|
588 | };
|
589 | }
|
590 | function getRunningQueriesThunk() {
|
591 | return function (dispatch) { return Object.values(runningQueries.get(dispatch) || {}).filter(isNotNullish); };
|
592 | }
|
593 | function getRunningMutationsThunk() {
|
594 | return function (dispatch) { return Object.values(runningMutations.get(dispatch) || {}).filter(isNotNullish); };
|
595 | }
|
596 | function middlewareWarning(dispatch) {
|
597 | if (true) {
|
598 | if (middlewareWarning.triggered)
|
599 | return;
|
600 | var registered = dispatch(api.internalActions.internal_probeSubscription({
|
601 | queryCacheKey: "DOES_NOT_EXIST",
|
602 | requestId: "DUMMY_REQUEST_ID"
|
603 | }));
|
604 | middlewareWarning.triggered = true;
|
605 | if (typeof registered !== "boolean") {
|
606 | throw new Error("Warning: Middleware for RTK-Query API at reducerPath \"" + api.reducerPath + "\" has not been added to the store.\nYou must add the middleware for RTK-Query to function correctly!");
|
607 | }
|
608 | }
|
609 | }
|
610 | function buildInitiateQuery(endpointName, endpointDefinition) {
|
611 | var queryAction = function (arg, _j) {
|
612 | var _k = _j === void 0 ? {} : _j, _l = _k.subscribe, subscribe = _l === void 0 ? true : _l, forceRefetch = _k.forceRefetch, subscriptionOptions = _k.subscriptionOptions, _m = forceQueryFnSymbol, forceQueryFn = _k[_m];
|
613 | return function (dispatch, getState) {
|
614 | var _j;
|
615 | var _a;
|
616 | var queryCacheKey = serializeQueryArgs({
|
617 | queryArgs: arg,
|
618 | endpointDefinition: endpointDefinition,
|
619 | endpointName: endpointName
|
620 | });
|
621 | var thunk = queryThunk((_j = {
|
622 | type: "query",
|
623 | subscribe: subscribe,
|
624 | forceRefetch: forceRefetch,
|
625 | subscriptionOptions: subscriptionOptions,
|
626 | endpointName: endpointName,
|
627 | originalArgs: arg,
|
628 | queryCacheKey: queryCacheKey
|
629 | },
|
630 | _j[forceQueryFnSymbol] = forceQueryFn,
|
631 | _j));
|
632 | var selector = api.endpoints[endpointName].select(arg);
|
633 | var thunkResult = dispatch(thunk);
|
634 | var stateAfter = selector(getState());
|
635 | middlewareWarning(dispatch);
|
636 | var requestId = thunkResult.requestId, abort = thunkResult.abort;
|
637 | var skippedSynchronously = stateAfter.requestId !== requestId;
|
638 | var runningQuery = (_a = runningQueries.get(dispatch)) == null ? void 0 : _a[queryCacheKey];
|
639 | var selectFromState = function () { return selector(getState()); };
|
640 | var statePromise = Object.assign(forceQueryFn ? thunkResult.then(selectFromState) : skippedSynchronously && !runningQuery ? Promise.resolve(stateAfter) : Promise.all([runningQuery, thunkResult]).then(selectFromState), {
|
641 | arg: arg,
|
642 | requestId: requestId,
|
643 | subscriptionOptions: subscriptionOptions,
|
644 | queryCacheKey: queryCacheKey,
|
645 | abort: abort,
|
646 | unwrap: function () {
|
647 | return __async(this, null, function () {
|
648 | var result;
|
649 | return __generator(this, function (_j) {
|
650 | switch (_j.label) {
|
651 | case 0: return [4 , statePromise];
|
652 | case 1:
|
653 | result = _j.sent();
|
654 | if (result.isError) {
|
655 | throw result.error;
|
656 | }
|
657 | return [2 , result.data];
|
658 | }
|
659 | });
|
660 | });
|
661 | },
|
662 | refetch: function () { return dispatch(queryAction(arg, { subscribe: false, forceRefetch: true })); },
|
663 | unsubscribe: function () {
|
664 | if (subscribe)
|
665 | dispatch(unsubscribeQueryResult({
|
666 | queryCacheKey: queryCacheKey,
|
667 | requestId: requestId
|
668 | }));
|
669 | },
|
670 | updateSubscriptionOptions: function (options) {
|
671 | statePromise.subscriptionOptions = options;
|
672 | dispatch(updateSubscriptionOptions({
|
673 | endpointName: endpointName,
|
674 | requestId: requestId,
|
675 | queryCacheKey: queryCacheKey,
|
676 | options: options
|
677 | }));
|
678 | }
|
679 | });
|
680 | if (!runningQuery && !skippedSynchronously && !forceQueryFn) {
|
681 | var running_1 = runningQueries.get(dispatch) || {};
|
682 | running_1[queryCacheKey] = statePromise;
|
683 | runningQueries.set(dispatch, running_1);
|
684 | statePromise.then(function () {
|
685 | delete running_1[queryCacheKey];
|
686 | if (!Object.keys(running_1).length) {
|
687 | runningQueries.delete(dispatch);
|
688 | }
|
689 | });
|
690 | }
|
691 | return statePromise;
|
692 | };
|
693 | };
|
694 | return queryAction;
|
695 | }
|
696 | function buildInitiateMutation(endpointName) {
|
697 | return function (arg, _j) {
|
698 | var _k = _j === void 0 ? {} : _j, _l = _k.track, track = _l === void 0 ? true : _l, fixedCacheKey = _k.fixedCacheKey;
|
699 | return function (dispatch, getState) {
|
700 | var thunk = mutationThunk({
|
701 | type: "mutation",
|
702 | endpointName: endpointName,
|
703 | originalArgs: arg,
|
704 | track: track,
|
705 | fixedCacheKey: fixedCacheKey
|
706 | });
|
707 | var thunkResult = dispatch(thunk);
|
708 | middlewareWarning(dispatch);
|
709 | var requestId = thunkResult.requestId, abort = thunkResult.abort, unwrap = thunkResult.unwrap;
|
710 | var returnValuePromise = thunkResult.unwrap().then(function (data) { return ({ data: data }); }).catch(function (error) { return ({ error: error }); });
|
711 | var reset = function () {
|
712 | dispatch(removeMutationResult({ requestId: requestId, fixedCacheKey: fixedCacheKey }));
|
713 | };
|
714 | var ret = Object.assign(returnValuePromise, {
|
715 | arg: thunkResult.arg,
|
716 | requestId: requestId,
|
717 | abort: abort,
|
718 | unwrap: unwrap,
|
719 | unsubscribe: reset,
|
720 | reset: reset
|
721 | });
|
722 | var running = runningMutations.get(dispatch) || {};
|
723 | runningMutations.set(dispatch, running);
|
724 | running[requestId] = ret;
|
725 | ret.then(function () {
|
726 | delete running[requestId];
|
727 | if (!Object.keys(running).length) {
|
728 | runningMutations.delete(dispatch);
|
729 | }
|
730 | });
|
731 | if (fixedCacheKey) {
|
732 | running[fixedCacheKey] = ret;
|
733 | ret.then(function () {
|
734 | if (running[fixedCacheKey] === ret) {
|
735 | delete running[fixedCacheKey];
|
736 | if (!Object.keys(running).length) {
|
737 | runningMutations.delete(dispatch);
|
738 | }
|
739 | }
|
740 | });
|
741 | }
|
742 | return ret;
|
743 | };
|
744 | };
|
745 | }
|
746 | }
|
747 |
|
748 | var import_toolkit4 = __toModule(require("@reduxjs/toolkit"));
|
749 | var import_immer = __toModule(require("immer"));
|
750 | var import_toolkit5 = __toModule(require("@reduxjs/toolkit"));
|
751 | function defaultTransformResponse(baseQueryReturnValue) {
|
752 | return baseQueryReturnValue;
|
753 | }
|
754 | function buildThunks(_j) {
|
755 | var _this = this;
|
756 | var reducerPath = _j.reducerPath, baseQuery = _j.baseQuery, endpointDefinitions = _j.context.endpointDefinitions, serializeQueryArgs = _j.serializeQueryArgs, api = _j.api;
|
757 | var patchQueryData = function (endpointName, args, patches) { return function (dispatch) {
|
758 | var endpointDefinition = endpointDefinitions[endpointName];
|
759 | dispatch(api.internalActions.queryResultPatched({
|
760 | queryCacheKey: serializeQueryArgs({
|
761 | queryArgs: args,
|
762 | endpointDefinition: endpointDefinition,
|
763 | endpointName: endpointName
|
764 | }),
|
765 | patches: patches
|
766 | }));
|
767 | }; };
|
768 | var updateQueryData = function (endpointName, args, updateRecipe) { return function (dispatch, getState) {
|
769 | var _j, _k;
|
770 | var currentState = api.endpoints[endpointName].select(args)(getState());
|
771 | var ret = {
|
772 | patches: [],
|
773 | inversePatches: [],
|
774 | undo: function () { return dispatch(api.util.patchQueryData(endpointName, args, ret.inversePatches)); }
|
775 | };
|
776 | if (currentState.status === QueryStatus.uninitialized) {
|
777 | return ret;
|
778 | }
|
779 | if ("data" in currentState) {
|
780 | if ((0, import_immer.isDraftable)(currentState.data)) {
|
781 | var _l = (0, import_immer.produceWithPatches)(currentState.data, updateRecipe), patches = _l[1], inversePatches = _l[2];
|
782 | (_j = ret.patches).push.apply(_j, patches);
|
783 | (_k = ret.inversePatches).push.apply(_k, inversePatches);
|
784 | }
|
785 | else {
|
786 | var value = updateRecipe(currentState.data);
|
787 | ret.patches.push({ op: "replace", path: [], value: value });
|
788 | ret.inversePatches.push({
|
789 | op: "replace",
|
790 | path: [],
|
791 | value: currentState.data
|
792 | });
|
793 | }
|
794 | }
|
795 | dispatch(api.util.patchQueryData(endpointName, args, ret.patches));
|
796 | return ret;
|
797 | }; };
|
798 | var upsertQueryData = function (endpointName, args, value) { return function (dispatch) {
|
799 | var _j;
|
800 | return dispatch(api.endpoints[endpointName].initiate(args, (_j = {
|
801 | subscribe: false,
|
802 | forceRefetch: true
|
803 | },
|
804 | _j[forceQueryFnSymbol] = function () { return ({
|
805 | data: value
|
806 | }); },
|
807 | _j)));
|
808 | }; };
|
809 | var executeEndpoint = function (_0, _1) { return __async(_this, [_0, _1], function (arg, _j) {
|
810 | var endpointDefinition, transformResponse, result, baseQueryApi_1, forceQueryFn, what, err, _k, _l, key, _m, error_1, catchedError, transformErrorResponse, _o, e_4;
|
811 | var _p, _q;
|
812 | var signal = _j.signal, abort = _j.abort, rejectWithValue = _j.rejectWithValue, fulfillWithValue = _j.fulfillWithValue, dispatch = _j.dispatch, getState = _j.getState, extra = _j.extra;
|
813 | return __generator(this, function (_r) {
|
814 | switch (_r.label) {
|
815 | case 0:
|
816 | endpointDefinition = endpointDefinitions[arg.endpointName];
|
817 | _r.label = 1;
|
818 | case 1:
|
819 | _r.trys.push([1, 8, , 13]);
|
820 | transformResponse = defaultTransformResponse;
|
821 | result = void 0;
|
822 | baseQueryApi_1 = {
|
823 | signal: signal,
|
824 | abort: abort,
|
825 | dispatch: dispatch,
|
826 | getState: getState,
|
827 | extra: extra,
|
828 | endpoint: arg.endpointName,
|
829 | type: arg.type,
|
830 | forced: arg.type === "query" ? isForcedQuery(arg, getState()) : void 0
|
831 | };
|
832 | forceQueryFn = arg.type === "query" ? arg[forceQueryFnSymbol] : void 0;
|
833 | if (!forceQueryFn) return [3 , 2];
|
834 | result = forceQueryFn();
|
835 | return [3 , 6];
|
836 | case 2:
|
837 | if (!endpointDefinition.query) return [3 , 4];
|
838 | return [4 , baseQuery(endpointDefinition.query(arg.originalArgs), baseQueryApi_1, endpointDefinition.extraOptions)];
|
839 | case 3:
|
840 | result = _r.sent();
|
841 | if (endpointDefinition.transformResponse) {
|
842 | transformResponse = endpointDefinition.transformResponse;
|
843 | }
|
844 | return [3 , 6];
|
845 | case 4: return [4 , endpointDefinition.queryFn(arg.originalArgs, baseQueryApi_1, endpointDefinition.extraOptions, function (arg2) { return baseQuery(arg2, baseQueryApi_1, endpointDefinition.extraOptions); })];
|
846 | case 5:
|
847 | result = _r.sent();
|
848 | _r.label = 6;
|
849 | case 6:
|
850 | if (typeof process !== "undefined" && true) {
|
851 | what = endpointDefinition.query ? "`baseQuery`" : "`queryFn`";
|
852 | err = void 0;
|
853 | if (!result) {
|
854 | err = what + " did not return anything.";
|
855 | }
|
856 | else if (typeof result !== "object") {
|
857 | err = what + " did not return an object.";
|
858 | }
|
859 | else if (result.error && result.data) {
|
860 | err = what + " returned an object containing both `error` and `result`.";
|
861 | }
|
862 | else if (result.error === void 0 && result.data === void 0) {
|
863 | err = what + " returned an object containing neither a valid `error` and `result`. At least one of them should not be `undefined`";
|
864 | }
|
865 | else {
|
866 | for (_k = 0, _l = Object.keys(result); _k < _l.length; _k++) {
|
867 | key = _l[_k];
|
868 | if (key !== "error" && key !== "data" && key !== "meta") {
|
869 | err = "The object returned by " + what + " has the unknown property " + key + ".";
|
870 | break;
|
871 | }
|
872 | }
|
873 | }
|
874 | if (err) {
|
875 | console.error("Error encountered handling the endpoint " + arg.endpointName + ".\n " + err + "\n It needs to return an object with either the shape `{ data: <value> }` or `{ error: <value> }` that may contain an optional `meta` property.\n Object returned was:", result);
|
876 | }
|
877 | }
|
878 | if (result.error)
|
879 | throw new HandledError(result.error, result.meta);
|
880 | _m = fulfillWithValue;
|
881 | return [4 , transformResponse(result.data, result.meta, arg.originalArgs)];
|
882 | case 7: return [2 , _m.apply(void 0, [_r.sent(), (_p = {
|
883 | fulfilledTimeStamp: Date.now(),
|
884 | baseQueryMeta: result.meta
|
885 | },
|
886 | _p[import_toolkit5.SHOULD_AUTOBATCH] = true,
|
887 | _p)])];
|
888 | case 8:
|
889 | error_1 = _r.sent();
|
890 | catchedError = error_1;
|
891 | if (!(catchedError instanceof HandledError)) return [3 , 12];
|
892 | transformErrorResponse = defaultTransformResponse;
|
893 | if (endpointDefinition.query && endpointDefinition.transformErrorResponse) {
|
894 | transformErrorResponse = endpointDefinition.transformErrorResponse;
|
895 | }
|
896 | _r.label = 9;
|
897 | case 9:
|
898 | _r.trys.push([9, 11, , 12]);
|
899 | _o = rejectWithValue;
|
900 | return [4 , transformErrorResponse(catchedError.value, catchedError.meta, arg.originalArgs)];
|
901 | case 10: return [2 , _o.apply(void 0, [_r.sent(), (_q = { baseQueryMeta: catchedError.meta }, _q[import_toolkit5.SHOULD_AUTOBATCH] = true, _q)])];
|
902 | case 11:
|
903 | e_4 = _r.sent();
|
904 | catchedError = e_4;
|
905 | return [3 , 12];
|
906 | case 12:
|
907 | if (typeof process !== "undefined" && true) {
|
908 | console.error("An unhandled error occurred processing a request for the endpoint \"" + arg.endpointName + "\".\nIn the case of an unhandled error, no tags will be \"provided\" or \"invalidated\".", catchedError);
|
909 | }
|
910 | else {
|
911 | console.error(catchedError);
|
912 | }
|
913 | throw catchedError;
|
914 | case 13: return [2 ];
|
915 | }
|
916 | });
|
917 | }); };
|
918 | function isForcedQuery(arg, state) {
|
919 | var _a, _b, _c, _d;
|
920 | var requestState = (_b = (_a = state[reducerPath]) == null ? void 0 : _a.queries) == null ? void 0 : _b[arg.queryCacheKey];
|
921 | var baseFetchOnMountOrArgChange = (_c = state[reducerPath]) == null ? void 0 : _c.config.refetchOnMountOrArgChange;
|
922 | var fulfilledVal = requestState == null ? void 0 : requestState.fulfilledTimeStamp;
|
923 | var refetchVal = (_d = arg.forceRefetch) != null ? _d : arg.subscribe && baseFetchOnMountOrArgChange;
|
924 | if (refetchVal) {
|
925 | return refetchVal === true || (Number(new Date()) - Number(fulfilledVal)) / 1e3 >= refetchVal;
|
926 | }
|
927 | return false;
|
928 | }
|
929 | var queryThunk = (0, import_toolkit5.createAsyncThunk)(reducerPath + "/executeQuery", executeEndpoint, {
|
930 | getPendingMeta: function () {
|
931 | var _j;
|
932 | return _j = { startedTimeStamp: Date.now() }, _j[import_toolkit5.SHOULD_AUTOBATCH] = true, _j;
|
933 | },
|
934 | condition: function (queryThunkArgs, _j) {
|
935 | var getState = _j.getState;
|
936 | var _a, _b, _c;
|
937 | var state = getState();
|
938 | var requestState = (_b = (_a = state[reducerPath]) == null ? void 0 : _a.queries) == null ? void 0 : _b[queryThunkArgs.queryCacheKey];
|
939 | var fulfilledVal = requestState == null ? void 0 : requestState.fulfilledTimeStamp;
|
940 | var currentArg = queryThunkArgs.originalArgs;
|
941 | var previousArg = requestState == null ? void 0 : requestState.originalArgs;
|
942 | var endpointDefinition = endpointDefinitions[queryThunkArgs.endpointName];
|
943 | if (isUpsertQuery(queryThunkArgs)) {
|
944 | return true;
|
945 | }
|
946 | if ((requestState == null ? void 0 : requestState.status) === "pending") {
|
947 | return false;
|
948 | }
|
949 | if (isForcedQuery(queryThunkArgs, state)) {
|
950 | return true;
|
951 | }
|
952 | if (isQueryDefinition(endpointDefinition) && ((_c = endpointDefinition == null ? void 0 : endpointDefinition.forceRefetch) == null ? void 0 : _c.call(endpointDefinition, {
|
953 | currentArg: currentArg,
|
954 | previousArg: previousArg,
|
955 | endpointState: requestState,
|
956 | state: state
|
957 | }))) {
|
958 | return true;
|
959 | }
|
960 | if (fulfilledVal) {
|
961 | return false;
|
962 | }
|
963 | return true;
|
964 | },
|
965 | dispatchConditionRejection: true
|
966 | });
|
967 | var mutationThunk = (0, import_toolkit5.createAsyncThunk)(reducerPath + "/executeMutation", executeEndpoint, {
|
968 | getPendingMeta: function () {
|
969 | var _j;
|
970 | return _j = { startedTimeStamp: Date.now() }, _j[import_toolkit5.SHOULD_AUTOBATCH] = true, _j;
|
971 | }
|
972 | });
|
973 | var hasTheForce = function (options) { return "force" in options; };
|
974 | var hasMaxAge = function (options) { return "ifOlderThan" in options; };
|
975 | var prefetch = function (endpointName, arg, options) { return function (dispatch, getState) {
|
976 | var force = hasTheForce(options) && options.force;
|
977 | var maxAge = hasMaxAge(options) && options.ifOlderThan;
|
978 | var queryAction = function (force2) {
|
979 | if (force2 === void 0) { force2 = true; }
|
980 | return api.endpoints[endpointName].initiate(arg, { forceRefetch: force2 });
|
981 | };
|
982 | var latestStateValue = api.endpoints[endpointName].select(arg)(getState());
|
983 | if (force) {
|
984 | dispatch(queryAction());
|
985 | }
|
986 | else if (maxAge) {
|
987 | var lastFulfilledTs = latestStateValue == null ? void 0 : latestStateValue.fulfilledTimeStamp;
|
988 | if (!lastFulfilledTs) {
|
989 | dispatch(queryAction());
|
990 | return;
|
991 | }
|
992 | var shouldRetrigger = (Number(new Date()) - Number(new Date(lastFulfilledTs))) / 1e3 >= maxAge;
|
993 | if (shouldRetrigger) {
|
994 | dispatch(queryAction());
|
995 | }
|
996 | }
|
997 | else {
|
998 | dispatch(queryAction(false));
|
999 | }
|
1000 | }; };
|
1001 | function matchesEndpoint(endpointName) {
|
1002 | return function (action) {
|
1003 | var _a, _b;
|
1004 | return ((_b = (_a = action == null ? void 0 : action.meta) == null ? void 0 : _a.arg) == null ? void 0 : _b.endpointName) === endpointName;
|
1005 | };
|
1006 | }
|
1007 | function buildMatchThunkActions(thunk, endpointName) {
|
1008 | return {
|
1009 | matchPending: (0, import_toolkit4.isAllOf)((0, import_toolkit4.isPending)(thunk), matchesEndpoint(endpointName)),
|
1010 | matchFulfilled: (0, import_toolkit4.isAllOf)((0, import_toolkit4.isFulfilled)(thunk), matchesEndpoint(endpointName)),
|
1011 | matchRejected: (0, import_toolkit4.isAllOf)((0, import_toolkit4.isRejected)(thunk), matchesEndpoint(endpointName))
|
1012 | };
|
1013 | }
|
1014 | return {
|
1015 | queryThunk: queryThunk,
|
1016 | mutationThunk: mutationThunk,
|
1017 | prefetch: prefetch,
|
1018 | updateQueryData: updateQueryData,
|
1019 | upsertQueryData: upsertQueryData,
|
1020 | patchQueryData: patchQueryData,
|
1021 | buildMatchThunkActions: buildMatchThunkActions
|
1022 | };
|
1023 | }
|
1024 | function calculateProvidedByThunk(action, type, endpointDefinitions, assertTagType) {
|
1025 | return calculateProvidedBy(endpointDefinitions[action.meta.arg.endpointName][type], (0, import_toolkit4.isFulfilled)(action) ? action.payload : void 0, (0, import_toolkit4.isRejectedWithValue)(action) ? action.payload : void 0, action.meta.arg.originalArgs, "baseQueryMeta" in action.meta ? action.meta.baseQueryMeta : void 0, assertTagType);
|
1026 | }
|
1027 |
|
1028 | var import_immer2 = __toModule(require("immer"));
|
1029 | function updateQuerySubstateIfExists(state, queryCacheKey, update) {
|
1030 | var substate = state[queryCacheKey];
|
1031 | if (substate) {
|
1032 | update(substate);
|
1033 | }
|
1034 | }
|
1035 | function getMutationCacheKey(id) {
|
1036 | var _a;
|
1037 | return (_a = "arg" in id ? id.arg.fixedCacheKey : id.fixedCacheKey) != null ? _a : id.requestId;
|
1038 | }
|
1039 | function updateMutationSubstateIfExists(state, id, update) {
|
1040 | var substate = state[getMutationCacheKey(id)];
|
1041 | if (substate) {
|
1042 | update(substate);
|
1043 | }
|
1044 | }
|
1045 | var initialState = {};
|
1046 | function buildSlice(_j) {
|
1047 | var reducerPath = _j.reducerPath, queryThunk = _j.queryThunk, mutationThunk = _j.mutationThunk, _k = _j.context, definitions = _k.endpointDefinitions, apiUid = _k.apiUid, extractRehydrationInfo = _k.extractRehydrationInfo, hasRehydrationInfo = _k.hasRehydrationInfo, assertTagType = _j.assertTagType, config = _j.config;
|
1048 | var resetApiState = (0, import_toolkit6.createAction)(reducerPath + "/resetApiState");
|
1049 | var querySlice = (0, import_toolkit6.createSlice)({
|
1050 | name: reducerPath + "/queries",
|
1051 | initialState: initialState,
|
1052 | reducers: {
|
1053 | removeQueryResult: {
|
1054 | reducer: function (draft, _j) {
|
1055 | var queryCacheKey = _j.payload.queryCacheKey;
|
1056 | delete draft[queryCacheKey];
|
1057 | },
|
1058 | prepare: (0, import_toolkit6.prepareAutoBatched)()
|
1059 | },
|
1060 | queryResultPatched: function (draft, _j) {
|
1061 | var _k = _j.payload, queryCacheKey = _k.queryCacheKey, patches = _k.patches;
|
1062 | updateQuerySubstateIfExists(draft, queryCacheKey, function (substate) {
|
1063 | substate.data = (0, import_immer2.applyPatches)(substate.data, patches.concat());
|
1064 | });
|
1065 | }
|
1066 | },
|
1067 | extraReducers: function (builder) {
|
1068 | builder.addCase(queryThunk.pending, function (draft, _j) {
|
1069 | var meta = _j.meta, arg = _j.meta.arg;
|
1070 | var _a, _b;
|
1071 | var upserting = isUpsertQuery(arg);
|
1072 | if (arg.subscribe || upserting) {
|
1073 | (_b = draft[_a = arg.queryCacheKey]) != null ? _b : draft[_a] = {
|
1074 | status: QueryStatus.uninitialized,
|
1075 | endpointName: arg.endpointName
|
1076 | };
|
1077 | }
|
1078 | updateQuerySubstateIfExists(draft, arg.queryCacheKey, function (substate) {
|
1079 | substate.status = QueryStatus.pending;
|
1080 | substate.requestId = upserting && substate.requestId ? substate.requestId : meta.requestId;
|
1081 | if (arg.originalArgs !== void 0) {
|
1082 | substate.originalArgs = arg.originalArgs;
|
1083 | }
|
1084 | substate.startedTimeStamp = meta.startedTimeStamp;
|
1085 | });
|
1086 | }).addCase(queryThunk.fulfilled, function (draft, _j) {
|
1087 | var meta = _j.meta, payload = _j.payload;
|
1088 | updateQuerySubstateIfExists(draft, meta.arg.queryCacheKey, function (substate) {
|
1089 | var _a;
|
1090 | if (substate.requestId !== meta.requestId && !isUpsertQuery(meta.arg))
|
1091 | return;
|
1092 | var merge = definitions[meta.arg.endpointName].merge;
|
1093 | substate.status = QueryStatus.fulfilled;
|
1094 | if (merge) {
|
1095 | if (substate.data !== void 0) {
|
1096 | var fulfilledTimeStamp_1 = meta.fulfilledTimeStamp, arg_1 = meta.arg, baseQueryMeta_1 = meta.baseQueryMeta, requestId_1 = meta.requestId;
|
1097 | var newData = (0, import_toolkit6.createNextState)(substate.data, function (draftSubstateData) {
|
1098 | return merge(draftSubstateData, payload, {
|
1099 | arg: arg_1.originalArgs,
|
1100 | baseQueryMeta: baseQueryMeta_1,
|
1101 | fulfilledTimeStamp: fulfilledTimeStamp_1,
|
1102 | requestId: requestId_1
|
1103 | });
|
1104 | });
|
1105 | substate.data = newData;
|
1106 | }
|
1107 | else {
|
1108 | substate.data = payload;
|
1109 | }
|
1110 | }
|
1111 | else {
|
1112 | substate.data = ((_a = definitions[meta.arg.endpointName].structuralSharing) != null ? _a : true) ? copyWithStructuralSharing(substate.data, payload) : payload;
|
1113 | }
|
1114 | delete substate.error;
|
1115 | substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
1116 | });
|
1117 | }).addCase(queryThunk.rejected, function (draft, _j) {
|
1118 | var _k = _j.meta, condition = _k.condition, arg = _k.arg, requestId = _k.requestId, error = _j.error, payload = _j.payload;
|
1119 | updateQuerySubstateIfExists(draft, arg.queryCacheKey, function (substate) {
|
1120 | if (condition) {
|
1121 | }
|
1122 | else {
|
1123 | if (substate.requestId !== requestId)
|
1124 | return;
|
1125 | substate.status = QueryStatus.rejected;
|
1126 | substate.error = payload != null ? payload : error;
|
1127 | }
|
1128 | });
|
1129 | }).addMatcher(hasRehydrationInfo, function (draft, action) {
|
1130 | var queries = extractRehydrationInfo(action).queries;
|
1131 | for (var _j = 0, _k = Object.entries(queries); _j < _k.length; _j++) {
|
1132 | var _l = _k[_j], key = _l[0], entry = _l[1];
|
1133 | if ((entry == null ? void 0 : entry.status) === QueryStatus.fulfilled || (entry == null ? void 0 : entry.status) === QueryStatus.rejected) {
|
1134 | draft[key] = entry;
|
1135 | }
|
1136 | }
|
1137 | });
|
1138 | }
|
1139 | });
|
1140 | var mutationSlice = (0, import_toolkit6.createSlice)({
|
1141 | name: reducerPath + "/mutations",
|
1142 | initialState: initialState,
|
1143 | reducers: {
|
1144 | removeMutationResult: {
|
1145 | reducer: function (draft, _j) {
|
1146 | var payload = _j.payload;
|
1147 | var cacheKey = getMutationCacheKey(payload);
|
1148 | if (cacheKey in draft) {
|
1149 | delete draft[cacheKey];
|
1150 | }
|
1151 | },
|
1152 | prepare: (0, import_toolkit6.prepareAutoBatched)()
|
1153 | }
|
1154 | },
|
1155 | extraReducers: function (builder) {
|
1156 | builder.addCase(mutationThunk.pending, function (draft, _j) {
|
1157 | var meta = _j.meta, _k = _j.meta, requestId = _k.requestId, arg = _k.arg, startedTimeStamp = _k.startedTimeStamp;
|
1158 | if (!arg.track)
|
1159 | return;
|
1160 | draft[getMutationCacheKey(meta)] = {
|
1161 | requestId: requestId,
|
1162 | status: QueryStatus.pending,
|
1163 | endpointName: arg.endpointName,
|
1164 | startedTimeStamp: startedTimeStamp
|
1165 | };
|
1166 | }).addCase(mutationThunk.fulfilled, function (draft, _j) {
|
1167 | var payload = _j.payload, meta = _j.meta;
|
1168 | if (!meta.arg.track)
|
1169 | return;
|
1170 | updateMutationSubstateIfExists(draft, meta, function (substate) {
|
1171 | if (substate.requestId !== meta.requestId)
|
1172 | return;
|
1173 | substate.status = QueryStatus.fulfilled;
|
1174 | substate.data = payload;
|
1175 | substate.fulfilledTimeStamp = meta.fulfilledTimeStamp;
|
1176 | });
|
1177 | }).addCase(mutationThunk.rejected, function (draft, _j) {
|
1178 | var payload = _j.payload, error = _j.error, meta = _j.meta;
|
1179 | if (!meta.arg.track)
|
1180 | return;
|
1181 | updateMutationSubstateIfExists(draft, meta, function (substate) {
|
1182 | if (substate.requestId !== meta.requestId)
|
1183 | return;
|
1184 | substate.status = QueryStatus.rejected;
|
1185 | substate.error = payload != null ? payload : error;
|
1186 | });
|
1187 | }).addMatcher(hasRehydrationInfo, function (draft, action) {
|
1188 | var mutations = extractRehydrationInfo(action).mutations;
|
1189 | for (var _j = 0, _k = Object.entries(mutations); _j < _k.length; _j++) {
|
1190 | var _l = _k[_j], key = _l[0], entry = _l[1];
|
1191 | if (((entry == null ? void 0 : entry.status) === QueryStatus.fulfilled || (entry == null ? void 0 : entry.status) === QueryStatus.rejected) && key !== (entry == null ? void 0 : entry.requestId)) {
|
1192 | draft[key] = entry;
|
1193 | }
|
1194 | }
|
1195 | });
|
1196 | }
|
1197 | });
|
1198 | var invalidationSlice = (0, import_toolkit6.createSlice)({
|
1199 | name: reducerPath + "/invalidation",
|
1200 | initialState: initialState,
|
1201 | reducers: {},
|
1202 | extraReducers: function (builder) {
|
1203 | builder.addCase(querySlice.actions.removeQueryResult, function (draft, _j) {
|
1204 | var queryCacheKey = _j.payload.queryCacheKey;
|
1205 | for (var _k = 0, _l = Object.values(draft); _k < _l.length; _k++) {
|
1206 | var tagTypeSubscriptions = _l[_k];
|
1207 | for (var _m = 0, _o = Object.values(tagTypeSubscriptions); _m < _o.length; _m++) {
|
1208 | var idSubscriptions = _o[_m];
|
1209 | var foundAt = idSubscriptions.indexOf(queryCacheKey);
|
1210 | if (foundAt !== -1) {
|
1211 | idSubscriptions.splice(foundAt, 1);
|
1212 | }
|
1213 | }
|
1214 | }
|
1215 | }).addMatcher(hasRehydrationInfo, function (draft, action) {
|
1216 | var _a, _b, _c, _d;
|
1217 | var provided = extractRehydrationInfo(action).provided;
|
1218 | for (var _j = 0, _k = Object.entries(provided); _j < _k.length; _j++) {
|
1219 | var _l = _k[_j], type = _l[0], incomingTags = _l[1];
|
1220 | for (var _m = 0, _o = Object.entries(incomingTags); _m < _o.length; _m++) {
|
1221 | var _p = _o[_m], id = _p[0], cacheKeys = _p[1];
|
1222 | var subscribedQueries = (_d = (_b = (_a = draft[type]) != null ? _a : draft[type] = {})[_c = id || "__internal_without_id"]) != null ? _d : _b[_c] = [];
|
1223 | for (var _q = 0, cacheKeys_1 = cacheKeys; _q < cacheKeys_1.length; _q++) {
|
1224 | var queryCacheKey = cacheKeys_1[_q];
|
1225 | var alreadySubscribed = subscribedQueries.includes(queryCacheKey);
|
1226 | if (!alreadySubscribed) {
|
1227 | subscribedQueries.push(queryCacheKey);
|
1228 | }
|
1229 | }
|
1230 | }
|
1231 | }
|
1232 | }).addMatcher((0, import_toolkit6.isAnyOf)((0, import_toolkit6.isFulfilled)(queryThunk), (0, import_toolkit6.isRejectedWithValue)(queryThunk)), function (draft, action) {
|
1233 | var _a, _b, _c, _d;
|
1234 | var providedTags = calculateProvidedByThunk(action, "providesTags", definitions, assertTagType);
|
1235 | var queryCacheKey = action.meta.arg.queryCacheKey;
|
1236 | for (var _j = 0, _k = Object.values(draft); _j < _k.length; _j++) {
|
1237 | var tagTypeSubscriptions = _k[_j];
|
1238 | for (var _l = 0, _m = Object.values(tagTypeSubscriptions); _l < _m.length; _l++) {
|
1239 | var idSubscriptions = _m[_l];
|
1240 | var foundAt = idSubscriptions.indexOf(queryCacheKey);
|
1241 | if (foundAt !== -1) {
|
1242 | idSubscriptions.splice(foundAt, 1);
|
1243 | }
|
1244 | }
|
1245 | }
|
1246 | for (var _o = 0, providedTags_1 = providedTags; _o < providedTags_1.length; _o++) {
|
1247 | var _p = providedTags_1[_o], type = _p.type, id = _p.id;
|
1248 | var subscribedQueries = (_d = (_b = (_a = draft[type]) != null ? _a : draft[type] = {})[_c = id || "__internal_without_id"]) != null ? _d : _b[_c] = [];
|
1249 | var alreadySubscribed = subscribedQueries.includes(queryCacheKey);
|
1250 | if (!alreadySubscribed) {
|
1251 | subscribedQueries.push(queryCacheKey);
|
1252 | }
|
1253 | }
|
1254 | });
|
1255 | }
|
1256 | });
|
1257 | var subscriptionSlice = (0, import_toolkit6.createSlice)({
|
1258 | name: reducerPath + "/subscriptions",
|
1259 | initialState: initialState,
|
1260 | reducers: {
|
1261 | updateSubscriptionOptions: function (d, a) {
|
1262 | },
|
1263 | unsubscribeQueryResult: function (d, a) {
|
1264 | },
|
1265 | internal_probeSubscription: function (d, a) {
|
1266 | }
|
1267 | }
|
1268 | });
|
1269 | var internalSubscriptionsSlice = (0, import_toolkit6.createSlice)({
|
1270 | name: reducerPath + "/internalSubscriptions",
|
1271 | initialState: initialState,
|
1272 | reducers: {
|
1273 | subscriptionsUpdated: function (state, action) {
|
1274 | return (0, import_immer2.applyPatches)(state, action.payload);
|
1275 | }
|
1276 | }
|
1277 | });
|
1278 | var configSlice = (0, import_toolkit6.createSlice)({
|
1279 | name: reducerPath + "/config",
|
1280 | initialState: __spreadValues({
|
1281 | online: isOnline(),
|
1282 | focused: isDocumentVisible(),
|
1283 | middlewareRegistered: false
|
1284 | }, config),
|
1285 | reducers: {
|
1286 | middlewareRegistered: function (state, _j) {
|
1287 | var payload = _j.payload;
|
1288 | state.middlewareRegistered = state.middlewareRegistered === "conflict" || apiUid !== payload ? "conflict" : true;
|
1289 | }
|
1290 | },
|
1291 | extraReducers: function (builder) {
|
1292 | builder.addCase(onOnline, function (state) {
|
1293 | state.online = true;
|
1294 | }).addCase(onOffline, function (state) {
|
1295 | state.online = false;
|
1296 | }).addCase(onFocus, function (state) {
|
1297 | state.focused = true;
|
1298 | }).addCase(onFocusLost, function (state) {
|
1299 | state.focused = false;
|
1300 | }).addMatcher(hasRehydrationInfo, function (draft) { return __spreadValues({}, draft); });
|
1301 | }
|
1302 | });
|
1303 | var combinedReducer = (0, import_toolkit6.combineReducers)({
|
1304 | queries: querySlice.reducer,
|
1305 | mutations: mutationSlice.reducer,
|
1306 | provided: invalidationSlice.reducer,
|
1307 | subscriptions: internalSubscriptionsSlice.reducer,
|
1308 | config: configSlice.reducer
|
1309 | });
|
1310 | var reducer = function (state, action) { return combinedReducer(resetApiState.match(action) ? void 0 : state, action); };
|
1311 | var actions = __spreadProps(__spreadValues(__spreadValues(__spreadValues(__spreadValues(__spreadValues({}, configSlice.actions), querySlice.actions), subscriptionSlice.actions), internalSubscriptionsSlice.actions), mutationSlice.actions), {
|
1312 | unsubscribeMutationResult: mutationSlice.actions.removeMutationResult,
|
1313 | resetApiState: resetApiState
|
1314 | });
|
1315 | return { reducer: reducer, actions: actions };
|
1316 | }
|
1317 |
|
1318 | var skipToken = Symbol.for("RTKQ/skipToken");
|
1319 | var skipSelector = skipToken;
|
1320 | var initialSubState = {
|
1321 | status: QueryStatus.uninitialized
|
1322 | };
|
1323 | var defaultQuerySubState = (0, import_toolkit7.createNextState)(initialSubState, function () {
|
1324 | });
|
1325 | var defaultMutationSubState = (0, import_toolkit7.createNextState)(initialSubState, function () {
|
1326 | });
|
1327 | function buildSelectors(_j) {
|
1328 | var serializeQueryArgs = _j.serializeQueryArgs, reducerPath = _j.reducerPath;
|
1329 | var selectSkippedQuery = function (state) { return defaultQuerySubState; };
|
1330 | var selectSkippedMutation = function (state) { return defaultMutationSubState; };
|
1331 | return { buildQuerySelector: buildQuerySelector, buildMutationSelector: buildMutationSelector, selectInvalidatedBy: selectInvalidatedBy };
|
1332 | function withRequestFlags(substate) {
|
1333 | return __spreadValues(__spreadValues({}, substate), getRequestStatusFlags(substate.status));
|
1334 | }
|
1335 | function selectInternalState(rootState) {
|
1336 | var state = rootState[reducerPath];
|
1337 | if (true) {
|
1338 | if (!state) {
|
1339 | if (selectInternalState.triggered)
|
1340 | return state;
|
1341 | selectInternalState.triggered = true;
|
1342 | console.error("Error: No data found at `state." + reducerPath + "`. Did you forget to add the reducer to the store?");
|
1343 | }
|
1344 | }
|
1345 | return state;
|
1346 | }
|
1347 | function buildQuerySelector(endpointName, endpointDefinition) {
|
1348 | return function (queryArgs) {
|
1349 | var serializedArgs = serializeQueryArgs({
|
1350 | queryArgs: queryArgs,
|
1351 | endpointDefinition: endpointDefinition,
|
1352 | endpointName: endpointName
|
1353 | });
|
1354 | var selectQuerySubstate = function (state) {
|
1355 | var _a, _b, _c;
|
1356 | return (_c = (_b = (_a = selectInternalState(state)) == null ? void 0 : _a.queries) == null ? void 0 : _b[serializedArgs]) != null ? _c : defaultQuerySubState;
|
1357 | };
|
1358 | var finalSelectQuerySubState = queryArgs === skipToken ? selectSkippedQuery : selectQuerySubstate;
|
1359 | return (0, import_toolkit7.createSelector)(finalSelectQuerySubState, withRequestFlags);
|
1360 | };
|
1361 | }
|
1362 | function buildMutationSelector() {
|
1363 | return function (id) {
|
1364 | var _a;
|
1365 | var mutationId;
|
1366 | if (typeof id === "object") {
|
1367 | mutationId = (_a = getMutationCacheKey(id)) != null ? _a : skipToken;
|
1368 | }
|
1369 | else {
|
1370 | mutationId = id;
|
1371 | }
|
1372 | var selectMutationSubstate = function (state) {
|
1373 | var _a2, _b, _c;
|
1374 | return (_c = (_b = (_a2 = selectInternalState(state)) == null ? void 0 : _a2.mutations) == null ? void 0 : _b[mutationId]) != null ? _c : defaultMutationSubState;
|
1375 | };
|
1376 | var finalSelectMutationSubstate = mutationId === skipToken ? selectSkippedMutation : selectMutationSubstate;
|
1377 | return (0, import_toolkit7.createSelector)(finalSelectMutationSubstate, withRequestFlags);
|
1378 | };
|
1379 | }
|
1380 | function selectInvalidatedBy(state, tags) {
|
1381 | var _a;
|
1382 | var apiState = state[reducerPath];
|
1383 | var toInvalidate = new Set();
|
1384 | for (var _j = 0, _k = tags.map(expandTagDescription); _j < _k.length; _j++) {
|
1385 | var tag = _k[_j];
|
1386 | var provided = apiState.provided[tag.type];
|
1387 | if (!provided) {
|
1388 | continue;
|
1389 | }
|
1390 | var invalidateSubscriptions = (_a = tag.id !== void 0 ? provided[tag.id] : flatten(Object.values(provided))) != null ? _a : [];
|
1391 | for (var _l = 0, invalidateSubscriptions_1 = invalidateSubscriptions; _l < invalidateSubscriptions_1.length; _l++) {
|
1392 | var invalidate = invalidateSubscriptions_1[_l];
|
1393 | toInvalidate.add(invalidate);
|
1394 | }
|
1395 | }
|
1396 | return flatten(Array.from(toInvalidate.values()).map(function (queryCacheKey) {
|
1397 | var querySubState = apiState.queries[queryCacheKey];
|
1398 | return querySubState ? [
|
1399 | {
|
1400 | queryCacheKey: queryCacheKey,
|
1401 | endpointName: querySubState.endpointName,
|
1402 | originalArgs: querySubState.originalArgs
|
1403 | }
|
1404 | ] : [];
|
1405 | }));
|
1406 | }
|
1407 | }
|
1408 |
|
1409 | var import_toolkit8 = __toModule(require("@reduxjs/toolkit"));
|
1410 | var defaultSerializeQueryArgs = function (_j) {
|
1411 | var endpointName = _j.endpointName, queryArgs = _j.queryArgs;
|
1412 | return endpointName + "(" + JSON.stringify(queryArgs, function (key, value) { return (0, import_toolkit8.isPlainObject)(value) ? Object.keys(value).sort().reduce(function (acc, key2) {
|
1413 | acc[key2] = value[key2];
|
1414 | return acc;
|
1415 | }, {}) : value; }) + ")";
|
1416 | };
|
1417 |
|
1418 | var import_toolkit9 = __toModule(require("@reduxjs/toolkit"));
|
1419 | var import_reselect = __toModule(require("reselect"));
|
1420 | function buildCreateApi() {
|
1421 | var modules = [];
|
1422 | for (var _j = 0; _j < arguments.length; _j++) {
|
1423 | modules[_j] = arguments[_j];
|
1424 | }
|
1425 | return function baseCreateApi(options) {
|
1426 | var extractRehydrationInfo = (0, import_reselect.defaultMemoize)(function (action) {
|
1427 | var _a, _b;
|
1428 | return (_b = options.extractRehydrationInfo) == null ? void 0 : _b.call(options, action, {
|
1429 | reducerPath: (_a = options.reducerPath) != null ? _a : "api"
|
1430 | });
|
1431 | });
|
1432 | var optionsWithDefaults = __spreadProps(__spreadValues({
|
1433 | reducerPath: "api",
|
1434 | keepUnusedDataFor: 60,
|
1435 | refetchOnMountOrArgChange: false,
|
1436 | refetchOnFocus: false,
|
1437 | refetchOnReconnect: false
|
1438 | }, options), {
|
1439 | extractRehydrationInfo: extractRehydrationInfo,
|
1440 | serializeQueryArgs: function (queryArgsApi) {
|
1441 | var finalSerializeQueryArgs = defaultSerializeQueryArgs;
|
1442 | if ("serializeQueryArgs" in queryArgsApi.endpointDefinition) {
|
1443 | var endpointSQA_1 = queryArgsApi.endpointDefinition.serializeQueryArgs;
|
1444 | finalSerializeQueryArgs = function (queryArgsApi2) {
|
1445 | var initialResult = endpointSQA_1(queryArgsApi2);
|
1446 | if (typeof initialResult === "string") {
|
1447 | return initialResult;
|
1448 | }
|
1449 | else {
|
1450 | return defaultSerializeQueryArgs(__spreadProps(__spreadValues({}, queryArgsApi2), {
|
1451 | queryArgs: initialResult
|
1452 | }));
|
1453 | }
|
1454 | };
|
1455 | }
|
1456 | else if (options.serializeQueryArgs) {
|
1457 | finalSerializeQueryArgs = options.serializeQueryArgs;
|
1458 | }
|
1459 | return finalSerializeQueryArgs(queryArgsApi);
|
1460 | },
|
1461 | tagTypes: __spreadArray([], options.tagTypes || [])
|
1462 | });
|
1463 | var context = {
|
1464 | endpointDefinitions: {},
|
1465 | batch: function (fn) {
|
1466 | fn();
|
1467 | },
|
1468 | apiUid: (0, import_toolkit9.nanoid)(),
|
1469 | extractRehydrationInfo: extractRehydrationInfo,
|
1470 | hasRehydrationInfo: (0, import_reselect.defaultMemoize)(function (action) { return extractRehydrationInfo(action) != null; })
|
1471 | };
|
1472 | var api = {
|
1473 | injectEndpoints: injectEndpoints,
|
1474 | enhanceEndpoints: function (_j) {
|
1475 | var addTagTypes = _j.addTagTypes, endpoints = _j.endpoints;
|
1476 | if (addTagTypes) {
|
1477 | for (var _k = 0, addTagTypes_1 = addTagTypes; _k < addTagTypes_1.length; _k++) {
|
1478 | var eT = addTagTypes_1[_k];
|
1479 | if (!optionsWithDefaults.tagTypes.includes(eT)) {
|
1480 | ;
|
1481 | optionsWithDefaults.tagTypes.push(eT);
|
1482 | }
|
1483 | }
|
1484 | }
|
1485 | if (endpoints) {
|
1486 | for (var _l = 0, _m = Object.entries(endpoints); _l < _m.length; _l++) {
|
1487 | var _o = _m[_l], endpointName = _o[0], partialDefinition = _o[1];
|
1488 | if (typeof partialDefinition === "function") {
|
1489 | partialDefinition(context.endpointDefinitions[endpointName]);
|
1490 | }
|
1491 | else {
|
1492 | Object.assign(context.endpointDefinitions[endpointName] || {}, partialDefinition);
|
1493 | }
|
1494 | }
|
1495 | }
|
1496 | return api;
|
1497 | }
|
1498 | };
|
1499 | var initializedModules = modules.map(function (m) { return m.init(api, optionsWithDefaults, context); });
|
1500 | function injectEndpoints(inject) {
|
1501 | var evaluatedEndpoints = inject.endpoints({
|
1502 | query: function (x) { return __spreadProps(__spreadValues({}, x), { type: DefinitionType.query }); },
|
1503 | mutation: function (x) { return __spreadProps(__spreadValues({}, x), { type: DefinitionType.mutation }); }
|
1504 | });
|
1505 | for (var _j = 0, _k = Object.entries(evaluatedEndpoints); _j < _k.length; _j++) {
|
1506 | var _l = _k[_j], endpointName = _l[0], definition = _l[1];
|
1507 | if (!inject.overrideExisting && endpointName in context.endpointDefinitions) {
|
1508 | if (typeof process !== "undefined" && true) {
|
1509 | console.error("called `injectEndpoints` to override already-existing endpointName " + endpointName + " without specifying `overrideExisting: true`");
|
1510 | }
|
1511 | continue;
|
1512 | }
|
1513 | context.endpointDefinitions[endpointName] = definition;
|
1514 | for (var _m = 0, initializedModules_1 = initializedModules; _m < initializedModules_1.length; _m++) {
|
1515 | var m = initializedModules_1[_m];
|
1516 | m.injectEndpoint(endpointName, definition);
|
1517 | }
|
1518 | }
|
1519 | return api;
|
1520 | }
|
1521 | return api.injectEndpoints({ endpoints: options.endpoints });
|
1522 | };
|
1523 | }
|
1524 |
|
1525 | function fakeBaseQuery() {
|
1526 | return function () {
|
1527 | throw new Error("When using `fakeBaseQuery`, all queries & mutations must use the `queryFn` definition syntax.");
|
1528 | };
|
1529 | }
|
1530 |
|
1531 | var import_toolkit13 = __toModule(require("@reduxjs/toolkit"));
|
1532 |
|
1533 | function isObjectEmpty(obj) {
|
1534 | for (var k in obj) {
|
1535 | return false;
|
1536 | }
|
1537 | return true;
|
1538 | }
|
1539 | var THIRTY_TWO_BIT_MAX_TIMER_SECONDS = 2147483647 / 1e3 - 1;
|
1540 | var buildCacheCollectionHandler = function (_j) {
|
1541 | var reducerPath = _j.reducerPath, api = _j.api, context = _j.context, internalState = _j.internalState;
|
1542 | var _k = api.internalActions, removeQueryResult = _k.removeQueryResult, unsubscribeQueryResult = _k.unsubscribeQueryResult;
|
1543 | function anySubscriptionsRemainingForKey(queryCacheKey) {
|
1544 | var subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
1545 | return !!subscriptions && !isObjectEmpty(subscriptions);
|
1546 | }
|
1547 | var currentRemovalTimeouts = {};
|
1548 | var handler = function (action, mwApi, internalState2) {
|
1549 | var _a;
|
1550 | if (unsubscribeQueryResult.match(action)) {
|
1551 | var state = mwApi.getState()[reducerPath];
|
1552 | var queryCacheKey = action.payload.queryCacheKey;
|
1553 | handleUnsubscribe(queryCacheKey, (_a = state.queries[queryCacheKey]) == null ? void 0 : _a.endpointName, mwApi, state.config);
|
1554 | }
|
1555 | if (api.util.resetApiState.match(action)) {
|
1556 | for (var _j = 0, _k = Object.entries(currentRemovalTimeouts); _j < _k.length; _j++) {
|
1557 | var _l = _k[_j], key = _l[0], timeout = _l[1];
|
1558 | if (timeout)
|
1559 | clearTimeout(timeout);
|
1560 | delete currentRemovalTimeouts[key];
|
1561 | }
|
1562 | }
|
1563 | if (context.hasRehydrationInfo(action)) {
|
1564 | var state = mwApi.getState()[reducerPath];
|
1565 | var queries = context.extractRehydrationInfo(action).queries;
|
1566 | for (var _m = 0, _o = Object.entries(queries); _m < _o.length; _m++) {
|
1567 | var _p = _o[_m], queryCacheKey = _p[0], queryState = _p[1];
|
1568 | handleUnsubscribe(queryCacheKey, queryState == null ? void 0 : queryState.endpointName, mwApi, state.config);
|
1569 | }
|
1570 | }
|
1571 | };
|
1572 | function handleUnsubscribe(queryCacheKey, endpointName, api2, config) {
|
1573 | var _a;
|
1574 | var endpointDefinition = context.endpointDefinitions[endpointName];
|
1575 | var keepUnusedDataFor = (_a = endpointDefinition == null ? void 0 : endpointDefinition.keepUnusedDataFor) != null ? _a : config.keepUnusedDataFor;
|
1576 | if (keepUnusedDataFor === Infinity) {
|
1577 | return;
|
1578 | }
|
1579 | var finalKeepUnusedDataFor = Math.max(0, Math.min(keepUnusedDataFor, THIRTY_TWO_BIT_MAX_TIMER_SECONDS));
|
1580 | if (!anySubscriptionsRemainingForKey(queryCacheKey)) {
|
1581 | var currentTimeout = currentRemovalTimeouts[queryCacheKey];
|
1582 | if (currentTimeout) {
|
1583 | clearTimeout(currentTimeout);
|
1584 | }
|
1585 | currentRemovalTimeouts[queryCacheKey] = setTimeout(function () {
|
1586 | if (!anySubscriptionsRemainingForKey(queryCacheKey)) {
|
1587 | api2.dispatch(removeQueryResult({ queryCacheKey: queryCacheKey }));
|
1588 | }
|
1589 | delete currentRemovalTimeouts[queryCacheKey];
|
1590 | }, finalKeepUnusedDataFor * 1e3);
|
1591 | }
|
1592 | }
|
1593 | return handler;
|
1594 | };
|
1595 |
|
1596 | var import_toolkit10 = __toModule(require("@reduxjs/toolkit"));
|
1597 | var buildInvalidationByTagsHandler = function (_j) {
|
1598 | var reducerPath = _j.reducerPath, context = _j.context, endpointDefinitions = _j.context.endpointDefinitions, mutationThunk = _j.mutationThunk, api = _j.api, assertTagType = _j.assertTagType, refetchQuery = _j.refetchQuery;
|
1599 | var removeQueryResult = api.internalActions.removeQueryResult;
|
1600 | var isThunkActionWithTags = (0, import_toolkit10.isAnyOf)((0, import_toolkit10.isFulfilled)(mutationThunk), (0, import_toolkit10.isRejectedWithValue)(mutationThunk));
|
1601 | var handler = function (action, mwApi) {
|
1602 | if (isThunkActionWithTags(action)) {
|
1603 | invalidateTags(calculateProvidedByThunk(action, "invalidatesTags", endpointDefinitions, assertTagType), mwApi);
|
1604 | }
|
1605 | if (api.util.invalidateTags.match(action)) {
|
1606 | invalidateTags(calculateProvidedBy(action.payload, void 0, void 0, void 0, void 0, assertTagType), mwApi);
|
1607 | }
|
1608 | };
|
1609 | function invalidateTags(tags, mwApi) {
|
1610 | var rootState = mwApi.getState();
|
1611 | var state = rootState[reducerPath];
|
1612 | var toInvalidate = api.util.selectInvalidatedBy(rootState, tags);
|
1613 | context.batch(function () {
|
1614 | var _a;
|
1615 | var valuesArray = Array.from(toInvalidate.values());
|
1616 | for (var _j = 0, valuesArray_1 = valuesArray; _j < valuesArray_1.length; _j++) {
|
1617 | var queryCacheKey = valuesArray_1[_j].queryCacheKey;
|
1618 | var querySubState = state.queries[queryCacheKey];
|
1619 | var subscriptionSubState = (_a = state.subscriptions[queryCacheKey]) != null ? _a : {};
|
1620 | if (querySubState) {
|
1621 | if (Object.keys(subscriptionSubState).length === 0) {
|
1622 | mwApi.dispatch(removeQueryResult({
|
1623 | queryCacheKey: queryCacheKey
|
1624 | }));
|
1625 | }
|
1626 | else if (querySubState.status !== QueryStatus.uninitialized) {
|
1627 | mwApi.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1628 | }
|
1629 | }
|
1630 | }
|
1631 | });
|
1632 | }
|
1633 | return handler;
|
1634 | };
|
1635 |
|
1636 | var buildPollingHandler = function (_j) {
|
1637 | var reducerPath = _j.reducerPath, queryThunk = _j.queryThunk, api = _j.api, refetchQuery = _j.refetchQuery, internalState = _j.internalState;
|
1638 | var currentPolls = {};
|
1639 | var handler = function (action, mwApi) {
|
1640 | if (api.internalActions.updateSubscriptionOptions.match(action) || api.internalActions.unsubscribeQueryResult.match(action)) {
|
1641 | updatePollingInterval(action.payload, mwApi);
|
1642 | }
|
1643 | if (queryThunk.pending.match(action) || queryThunk.rejected.match(action) && action.meta.condition) {
|
1644 | updatePollingInterval(action.meta.arg, mwApi);
|
1645 | }
|
1646 | if (queryThunk.fulfilled.match(action) || queryThunk.rejected.match(action) && !action.meta.condition) {
|
1647 | startNextPoll(action.meta.arg, mwApi);
|
1648 | }
|
1649 | if (api.util.resetApiState.match(action)) {
|
1650 | clearPolls();
|
1651 | }
|
1652 | };
|
1653 | function startNextPoll(_j, api2) {
|
1654 | var queryCacheKey = _j.queryCacheKey;
|
1655 | var state = api2.getState()[reducerPath];
|
1656 | var querySubState = state.queries[queryCacheKey];
|
1657 | var subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
1658 | if (!querySubState || querySubState.status === QueryStatus.uninitialized)
|
1659 | return;
|
1660 | var lowestPollingInterval = findLowestPollingInterval(subscriptions);
|
1661 | if (!Number.isFinite(lowestPollingInterval))
|
1662 | return;
|
1663 | var currentPoll = currentPolls[queryCacheKey];
|
1664 | if (currentPoll == null ? void 0 : currentPoll.timeout) {
|
1665 | clearTimeout(currentPoll.timeout);
|
1666 | currentPoll.timeout = void 0;
|
1667 | }
|
1668 | var nextPollTimestamp = Date.now() + lowestPollingInterval;
|
1669 | var currentInterval = currentPolls[queryCacheKey] = {
|
1670 | nextPollTimestamp: nextPollTimestamp,
|
1671 | pollingInterval: lowestPollingInterval,
|
1672 | timeout: setTimeout(function () {
|
1673 | currentInterval.timeout = void 0;
|
1674 | api2.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1675 | }, lowestPollingInterval)
|
1676 | };
|
1677 | }
|
1678 | function updatePollingInterval(_j, api2) {
|
1679 | var queryCacheKey = _j.queryCacheKey;
|
1680 | var state = api2.getState()[reducerPath];
|
1681 | var querySubState = state.queries[queryCacheKey];
|
1682 | var subscriptions = internalState.currentSubscriptions[queryCacheKey];
|
1683 | if (!querySubState || querySubState.status === QueryStatus.uninitialized) {
|
1684 | return;
|
1685 | }
|
1686 | var lowestPollingInterval = findLowestPollingInterval(subscriptions);
|
1687 | if (!Number.isFinite(lowestPollingInterval)) {
|
1688 | cleanupPollForKey(queryCacheKey);
|
1689 | return;
|
1690 | }
|
1691 | var currentPoll = currentPolls[queryCacheKey];
|
1692 | var nextPollTimestamp = Date.now() + lowestPollingInterval;
|
1693 | if (!currentPoll || nextPollTimestamp < currentPoll.nextPollTimestamp) {
|
1694 | startNextPoll({ queryCacheKey: queryCacheKey }, api2);
|
1695 | }
|
1696 | }
|
1697 | function cleanupPollForKey(key) {
|
1698 | var existingPoll = currentPolls[key];
|
1699 | if (existingPoll == null ? void 0 : existingPoll.timeout) {
|
1700 | clearTimeout(existingPoll.timeout);
|
1701 | }
|
1702 | delete currentPolls[key];
|
1703 | }
|
1704 | function clearPolls() {
|
1705 | for (var _j = 0, _k = Object.keys(currentPolls); _j < _k.length; _j++) {
|
1706 | var key = _k[_j];
|
1707 | cleanupPollForKey(key);
|
1708 | }
|
1709 | }
|
1710 | function findLowestPollingInterval(subscribers) {
|
1711 | if (subscribers === void 0) { subscribers = {}; }
|
1712 | var lowestPollingInterval = Number.POSITIVE_INFINITY;
|
1713 | for (var key in subscribers) {
|
1714 | if (!!subscribers[key].pollingInterval) {
|
1715 | lowestPollingInterval = Math.min(subscribers[key].pollingInterval, lowestPollingInterval);
|
1716 | }
|
1717 | }
|
1718 | return lowestPollingInterval;
|
1719 | }
|
1720 | return handler;
|
1721 | };
|
1722 |
|
1723 | var buildWindowEventHandler = function (_j) {
|
1724 | var reducerPath = _j.reducerPath, context = _j.context, api = _j.api, refetchQuery = _j.refetchQuery, internalState = _j.internalState;
|
1725 | var removeQueryResult = api.internalActions.removeQueryResult;
|
1726 | var handler = function (action, mwApi) {
|
1727 | if (onFocus.match(action)) {
|
1728 | refetchValidQueries(mwApi, "refetchOnFocus");
|
1729 | }
|
1730 | if (onOnline.match(action)) {
|
1731 | refetchValidQueries(mwApi, "refetchOnReconnect");
|
1732 | }
|
1733 | };
|
1734 | function refetchValidQueries(api2, type) {
|
1735 | var state = api2.getState()[reducerPath];
|
1736 | var queries = state.queries;
|
1737 | var subscriptions = internalState.currentSubscriptions;
|
1738 | context.batch(function () {
|
1739 | for (var _j = 0, _k = Object.keys(subscriptions); _j < _k.length; _j++) {
|
1740 | var queryCacheKey = _k[_j];
|
1741 | var querySubState = queries[queryCacheKey];
|
1742 | var subscriptionSubState = subscriptions[queryCacheKey];
|
1743 | if (!subscriptionSubState || !querySubState)
|
1744 | continue;
|
1745 | var shouldRefetch = Object.values(subscriptionSubState).some(function (sub) { return sub[type] === true; }) || Object.values(subscriptionSubState).every(function (sub) { return sub[type] === void 0; }) && state.config[type];
|
1746 | if (shouldRefetch) {
|
1747 | if (Object.keys(subscriptionSubState).length === 0) {
|
1748 | api2.dispatch(removeQueryResult({
|
1749 | queryCacheKey: queryCacheKey
|
1750 | }));
|
1751 | }
|
1752 | else if (querySubState.status !== QueryStatus.uninitialized) {
|
1753 | api2.dispatch(refetchQuery(querySubState, queryCacheKey));
|
1754 | }
|
1755 | }
|
1756 | }
|
1757 | });
|
1758 | }
|
1759 | return handler;
|
1760 | };
|
1761 |
|
1762 | var import_toolkit11 = __toModule(require("@reduxjs/toolkit"));
|
1763 | var neverResolvedError = new Error("Promise never resolved before cacheEntryRemoved.");
|
1764 | var buildCacheLifecycleHandler = function (_j) {
|
1765 | var api = _j.api, reducerPath = _j.reducerPath, context = _j.context, queryThunk = _j.queryThunk, mutationThunk = _j.mutationThunk, internalState = _j.internalState;
|
1766 | var isQueryThunk = (0, import_toolkit11.isAsyncThunkAction)(queryThunk);
|
1767 | var isMutationThunk = (0, import_toolkit11.isAsyncThunkAction)(mutationThunk);
|
1768 | var isFulfilledThunk = (0, import_toolkit11.isFulfilled)(queryThunk, mutationThunk);
|
1769 | var lifecycleMap = {};
|
1770 | var handler = function (action, mwApi, stateBefore) {
|
1771 | var cacheKey = getCacheKey(action);
|
1772 | if (queryThunk.pending.match(action)) {
|
1773 | var oldState = stateBefore[reducerPath].queries[cacheKey];
|
1774 | var state = mwApi.getState()[reducerPath].queries[cacheKey];
|
1775 | if (!oldState && state) {
|
1776 | handleNewKey(action.meta.arg.endpointName, action.meta.arg.originalArgs, cacheKey, mwApi, action.meta.requestId);
|
1777 | }
|
1778 | }
|
1779 | else if (mutationThunk.pending.match(action)) {
|
1780 | var state = mwApi.getState()[reducerPath].mutations[cacheKey];
|
1781 | if (state) {
|
1782 | handleNewKey(action.meta.arg.endpointName, action.meta.arg.originalArgs, cacheKey, mwApi, action.meta.requestId);
|
1783 | }
|
1784 | }
|
1785 | else if (isFulfilledThunk(action)) {
|
1786 | var lifecycle = lifecycleMap[cacheKey];
|
1787 | if (lifecycle == null ? void 0 : lifecycle.valueResolved) {
|
1788 | lifecycle.valueResolved({
|
1789 | data: action.payload,
|
1790 | meta: action.meta.baseQueryMeta
|
1791 | });
|
1792 | delete lifecycle.valueResolved;
|
1793 | }
|
1794 | }
|
1795 | else if (api.internalActions.removeQueryResult.match(action) || api.internalActions.removeMutationResult.match(action)) {
|
1796 | var lifecycle = lifecycleMap[cacheKey];
|
1797 | if (lifecycle) {
|
1798 | delete lifecycleMap[cacheKey];
|
1799 | lifecycle.cacheEntryRemoved();
|
1800 | }
|
1801 | }
|
1802 | else if (api.util.resetApiState.match(action)) {
|
1803 | for (var _j = 0, _k = Object.entries(lifecycleMap); _j < _k.length; _j++) {
|
1804 | var _l = _k[_j], cacheKey2 = _l[0], lifecycle = _l[1];
|
1805 | delete lifecycleMap[cacheKey2];
|
1806 | lifecycle.cacheEntryRemoved();
|
1807 | }
|
1808 | }
|
1809 | };
|
1810 | function getCacheKey(action) {
|
1811 | if (isQueryThunk(action))
|
1812 | return action.meta.arg.queryCacheKey;
|
1813 | if (isMutationThunk(action))
|
1814 | return action.meta.requestId;
|
1815 | if (api.internalActions.removeQueryResult.match(action))
|
1816 | return action.payload.queryCacheKey;
|
1817 | if (api.internalActions.removeMutationResult.match(action))
|
1818 | return getMutationCacheKey(action.payload);
|
1819 | return "";
|
1820 | }
|
1821 | function handleNewKey(endpointName, originalArgs, queryCacheKey, mwApi, requestId) {
|
1822 | var endpointDefinition = context.endpointDefinitions[endpointName];
|
1823 | var onCacheEntryAdded = endpointDefinition == null ? void 0 : endpointDefinition.onCacheEntryAdded;
|
1824 | if (!onCacheEntryAdded)
|
1825 | return;
|
1826 | var lifecycle = {};
|
1827 | var cacheEntryRemoved = new Promise(function (resolve) {
|
1828 | lifecycle.cacheEntryRemoved = resolve;
|
1829 | });
|
1830 | var cacheDataLoaded = Promise.race([
|
1831 | new Promise(function (resolve) {
|
1832 | lifecycle.valueResolved = resolve;
|
1833 | }),
|
1834 | cacheEntryRemoved.then(function () {
|
1835 | throw neverResolvedError;
|
1836 | })
|
1837 | ]);
|
1838 | cacheDataLoaded.catch(function () {
|
1839 | });
|
1840 | lifecycleMap[queryCacheKey] = lifecycle;
|
1841 | var selector = api.endpoints[endpointName].select(endpointDefinition.type === DefinitionType.query ? originalArgs : queryCacheKey);
|
1842 | var extra = mwApi.dispatch(function (_, __, extra2) { return extra2; });
|
1843 | var lifecycleApi = __spreadProps(__spreadValues({}, mwApi), {
|
1844 | getCacheEntry: function () { return selector(mwApi.getState()); },
|
1845 | requestId: requestId,
|
1846 | extra: extra,
|
1847 | updateCachedData: endpointDefinition.type === DefinitionType.query ? function (updateRecipe) { return mwApi.dispatch(api.util.updateQueryData(endpointName, originalArgs, updateRecipe)); } : void 0,
|
1848 | cacheDataLoaded: cacheDataLoaded,
|
1849 | cacheEntryRemoved: cacheEntryRemoved
|
1850 | });
|
1851 | var runningHandler = onCacheEntryAdded(originalArgs, lifecycleApi);
|
1852 | Promise.resolve(runningHandler).catch(function (e) {
|
1853 | if (e === neverResolvedError)
|
1854 | return;
|
1855 | throw e;
|
1856 | });
|
1857 | }
|
1858 | return handler;
|
1859 | };
|
1860 |
|
1861 | var import_toolkit12 = __toModule(require("@reduxjs/toolkit"));
|
1862 | var buildQueryLifecycleHandler = function (_j) {
|
1863 | var api = _j.api, context = _j.context, queryThunk = _j.queryThunk, mutationThunk = _j.mutationThunk;
|
1864 | var isPendingThunk = (0, import_toolkit12.isPending)(queryThunk, mutationThunk);
|
1865 | var isRejectedThunk = (0, import_toolkit12.isRejected)(queryThunk, mutationThunk);
|
1866 | var isFullfilledThunk = (0, import_toolkit12.isFulfilled)(queryThunk, mutationThunk);
|
1867 | var lifecycleMap = {};
|
1868 | var handler = function (action, mwApi) {
|
1869 | var _a, _b, _c;
|
1870 | if (isPendingThunk(action)) {
|
1871 | var _j = action.meta, requestId = _j.requestId, _k = _j.arg, endpointName_1 = _k.endpointName, originalArgs_1 = _k.originalArgs;
|
1872 | var endpointDefinition = context.endpointDefinitions[endpointName_1];
|
1873 | var onQueryStarted = endpointDefinition == null ? void 0 : endpointDefinition.onQueryStarted;
|
1874 | if (onQueryStarted) {
|
1875 | var lifecycle_1 = {};
|
1876 | var queryFulfilled = new Promise(function (resolve, reject) {
|
1877 | lifecycle_1.resolve = resolve;
|
1878 | lifecycle_1.reject = reject;
|
1879 | });
|
1880 | queryFulfilled.catch(function () {
|
1881 | });
|
1882 | lifecycleMap[requestId] = lifecycle_1;
|
1883 | var selector_1 = api.endpoints[endpointName_1].select(endpointDefinition.type === DefinitionType.query ? originalArgs_1 : requestId);
|
1884 | var extra = mwApi.dispatch(function (_, __, extra2) { return extra2; });
|
1885 | var lifecycleApi = __spreadProps(__spreadValues({}, mwApi), {
|
1886 | getCacheEntry: function () { return selector_1(mwApi.getState()); },
|
1887 | requestId: requestId,
|
1888 | extra: extra,
|
1889 | updateCachedData: endpointDefinition.type === DefinitionType.query ? function (updateRecipe) { return mwApi.dispatch(api.util.updateQueryData(endpointName_1, originalArgs_1, updateRecipe)); } : void 0,
|
1890 | queryFulfilled: queryFulfilled
|
1891 | });
|
1892 | onQueryStarted(originalArgs_1, lifecycleApi);
|
1893 | }
|
1894 | }
|
1895 | else if (isFullfilledThunk(action)) {
|
1896 | var _l = action.meta, requestId = _l.requestId, baseQueryMeta = _l.baseQueryMeta;
|
1897 | (_a = lifecycleMap[requestId]) == null ? void 0 : _a.resolve({
|
1898 | data: action.payload,
|
1899 | meta: baseQueryMeta
|
1900 | });
|
1901 | delete lifecycleMap[requestId];
|
1902 | }
|
1903 | else if (isRejectedThunk(action)) {
|
1904 | var _m = action.meta, requestId = _m.requestId, rejectedWithValue = _m.rejectedWithValue, baseQueryMeta = _m.baseQueryMeta;
|
1905 | (_c = lifecycleMap[requestId]) == null ? void 0 : _c.reject({
|
1906 | error: (_b = action.payload) != null ? _b : action.error,
|
1907 | isUnhandledError: !rejectedWithValue,
|
1908 | meta: baseQueryMeta
|
1909 | });
|
1910 | delete lifecycleMap[requestId];
|
1911 | }
|
1912 | };
|
1913 | return handler;
|
1914 | };
|
1915 |
|
1916 | var buildDevCheckHandler = function (_j) {
|
1917 | var api = _j.api, apiUid = _j.context.apiUid, reducerPath = _j.reducerPath;
|
1918 | return function (action, mwApi) {
|
1919 | var _a, _b;
|
1920 | if (api.util.resetApiState.match(action)) {
|
1921 | mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
1922 | }
|
1923 | if (typeof process !== "undefined" && true) {
|
1924 | if (api.internalActions.middlewareRegistered.match(action) && action.payload === apiUid && ((_b = (_a = mwApi.getState()[reducerPath]) == null ? void 0 : _a.config) == null ? void 0 : _b.middlewareRegistered) === "conflict") {
|
1925 | console.warn("There is a mismatch between slice and middleware for the reducerPath \"" + reducerPath + "\".\nYou can only have one api per reducer path, this will lead to crashes in various situations!" + (reducerPath === "api" ? "\nIf you have multiple apis, you *have* to specify the reducerPath option when using createApi!" : ""));
|
1926 | }
|
1927 | }
|
1928 | };
|
1929 | };
|
1930 |
|
1931 | var import_immer3 = __toModule(require("immer"));
|
1932 | var promise;
|
1933 | var queueMicrotaskShim = typeof queueMicrotask === "function" ? queueMicrotask.bind(typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : globalThis) : function (cb) { return (promise || (promise = Promise.resolve())).then(cb).catch(function (err) { return setTimeout(function () {
|
1934 | throw err;
|
1935 | }, 0); }); };
|
1936 | var buildBatchedActionsHandler = function (_j) {
|
1937 | var api = _j.api, queryThunk = _j.queryThunk, internalState = _j.internalState;
|
1938 | var subscriptionsPrefix = api.reducerPath + "/subscriptions";
|
1939 | var previousSubscriptions = null;
|
1940 | var dispatchQueued = false;
|
1941 | var _k = api.internalActions, updateSubscriptionOptions = _k.updateSubscriptionOptions, unsubscribeQueryResult = _k.unsubscribeQueryResult;
|
1942 | var actuallyMutateSubscriptions = function (mutableState, action) {
|
1943 | var _a, _b, _c, _d, _e, _f, _g, _h, _i;
|
1944 | if (updateSubscriptionOptions.match(action)) {
|
1945 | var _j = action.payload, queryCacheKey = _j.queryCacheKey, requestId = _j.requestId, options = _j.options;
|
1946 | if ((_a = mutableState == null ? void 0 : mutableState[queryCacheKey]) == null ? void 0 : _a[requestId]) {
|
1947 | mutableState[queryCacheKey][requestId] = options;
|
1948 | }
|
1949 | return true;
|
1950 | }
|
1951 | if (unsubscribeQueryResult.match(action)) {
|
1952 | var _k = action.payload, queryCacheKey = _k.queryCacheKey, requestId = _k.requestId;
|
1953 | if (mutableState[queryCacheKey]) {
|
1954 | delete mutableState[queryCacheKey][requestId];
|
1955 | }
|
1956 | return true;
|
1957 | }
|
1958 | if (api.internalActions.removeQueryResult.match(action)) {
|
1959 | delete mutableState[action.payload.queryCacheKey];
|
1960 | return true;
|
1961 | }
|
1962 | if (queryThunk.pending.match(action)) {
|
1963 | var _l = action.meta, arg = _l.arg, requestId = _l.requestId;
|
1964 | if (arg.subscribe) {
|
1965 | var substate = (_c = mutableState[_b = arg.queryCacheKey]) != null ? _c : mutableState[_b] = {};
|
1966 | substate[requestId] = (_e = (_d = arg.subscriptionOptions) != null ? _d : substate[requestId]) != null ? _e : {};
|
1967 | return true;
|
1968 | }
|
1969 | }
|
1970 | if (queryThunk.rejected.match(action)) {
|
1971 | var _m = action.meta, condition = _m.condition, arg = _m.arg, requestId = _m.requestId;
|
1972 | if (condition && arg.subscribe) {
|
1973 | var substate = (_g = mutableState[_f = arg.queryCacheKey]) != null ? _g : mutableState[_f] = {};
|
1974 | substate[requestId] = (_i = (_h = arg.subscriptionOptions) != null ? _h : substate[requestId]) != null ? _i : {};
|
1975 | return true;
|
1976 | }
|
1977 | }
|
1978 | return false;
|
1979 | };
|
1980 | return function (action, mwApi) {
|
1981 | var _a, _b;
|
1982 | if (!previousSubscriptions) {
|
1983 | previousSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
|
1984 | }
|
1985 | if (api.internalActions.internal_probeSubscription.match(action)) {
|
1986 | var _j = action.payload, queryCacheKey = _j.queryCacheKey, requestId = _j.requestId;
|
1987 | var hasSubscription = !!((_a = internalState.currentSubscriptions[queryCacheKey]) == null ? void 0 : _a[requestId]);
|
1988 | return [false, hasSubscription];
|
1989 | }
|
1990 | var didMutate = actuallyMutateSubscriptions(internalState.currentSubscriptions, action);
|
1991 | if (didMutate) {
|
1992 | if (!dispatchQueued) {
|
1993 | queueMicrotaskShim(function () {
|
1994 | var newSubscriptions = JSON.parse(JSON.stringify(internalState.currentSubscriptions));
|
1995 | var _j = (0, import_immer3.produceWithPatches)(previousSubscriptions, function () { return newSubscriptions; }), patches = _j[1];
|
1996 | mwApi.next(api.internalActions.subscriptionsUpdated(patches));
|
1997 | previousSubscriptions = newSubscriptions;
|
1998 | dispatchQueued = false;
|
1999 | });
|
2000 | dispatchQueued = true;
|
2001 | }
|
2002 | var isSubscriptionSliceAction = !!((_b = action.type) == null ? void 0 : _b.startsWith(subscriptionsPrefix));
|
2003 | var isAdditionalSubscriptionAction = queryThunk.rejected.match(action) && action.meta.condition && !!action.meta.arg.subscribe;
|
2004 | var actionShouldContinue = !isSubscriptionSliceAction && !isAdditionalSubscriptionAction;
|
2005 | return [actionShouldContinue, false];
|
2006 | }
|
2007 | return [true, false];
|
2008 | };
|
2009 | };
|
2010 |
|
2011 | function buildMiddleware(input) {
|
2012 | var reducerPath = input.reducerPath, queryThunk = input.queryThunk, api = input.api, context = input.context;
|
2013 | var apiUid = context.apiUid;
|
2014 | var actions = {
|
2015 | invalidateTags: (0, import_toolkit13.createAction)(reducerPath + "/invalidateTags")
|
2016 | };
|
2017 | var isThisApiSliceAction = function (action) {
|
2018 | return !!action && typeof action.type === "string" && action.type.startsWith(reducerPath + "/");
|
2019 | };
|
2020 | var handlerBuilders = [
|
2021 | buildDevCheckHandler,
|
2022 | buildCacheCollectionHandler,
|
2023 | buildInvalidationByTagsHandler,
|
2024 | buildPollingHandler,
|
2025 | buildCacheLifecycleHandler,
|
2026 | buildQueryLifecycleHandler
|
2027 | ];
|
2028 | var middleware = function (mwApi) {
|
2029 | var initialized2 = false;
|
2030 | var internalState = {
|
2031 | currentSubscriptions: {}
|
2032 | };
|
2033 | var builderArgs = __spreadProps(__spreadValues({}, input), {
|
2034 | internalState: internalState,
|
2035 | refetchQuery: refetchQuery
|
2036 | });
|
2037 | var handlers = handlerBuilders.map(function (build) { return build(builderArgs); });
|
2038 | var batchedActionsHandler = buildBatchedActionsHandler(builderArgs);
|
2039 | var windowEventsHandler = buildWindowEventHandler(builderArgs);
|
2040 | return function (next) {
|
2041 | return function (action) {
|
2042 | if (!initialized2) {
|
2043 | initialized2 = true;
|
2044 | mwApi.dispatch(api.internalActions.middlewareRegistered(apiUid));
|
2045 | }
|
2046 | var mwApiWithNext = __spreadProps(__spreadValues({}, mwApi), { next: next });
|
2047 | var stateBefore = mwApi.getState();
|
2048 | var _j = batchedActionsHandler(action, mwApiWithNext, stateBefore), actionShouldContinue = _j[0], hasSubscription = _j[1];
|
2049 | var res;
|
2050 | if (actionShouldContinue) {
|
2051 | res = next(action);
|
2052 | }
|
2053 | else {
|
2054 | res = hasSubscription;
|
2055 | }
|
2056 | if (!!mwApi.getState()[reducerPath]) {
|
2057 | windowEventsHandler(action, mwApiWithNext, stateBefore);
|
2058 | if (isThisApiSliceAction(action) || context.hasRehydrationInfo(action)) {
|
2059 | for (var _k = 0, handlers_1 = handlers; _k < handlers_1.length; _k++) {
|
2060 | var handler = handlers_1[_k];
|
2061 | handler(action, mwApiWithNext, stateBefore);
|
2062 | }
|
2063 | }
|
2064 | }
|
2065 | return res;
|
2066 | };
|
2067 | };
|
2068 | };
|
2069 | return { middleware: middleware, actions: actions };
|
2070 | function refetchQuery(querySubState, queryCacheKey, override) {
|
2071 | if (override === void 0) { override = {}; }
|
2072 | return queryThunk(__spreadValues({
|
2073 | type: "query",
|
2074 | endpointName: querySubState.endpointName,
|
2075 | originalArgs: querySubState.originalArgs,
|
2076 | subscribe: false,
|
2077 | forceRefetch: true,
|
2078 | queryCacheKey: queryCacheKey
|
2079 | }, override));
|
2080 | }
|
2081 | }
|
2082 |
|
2083 | function assertCast(v) {
|
2084 | }
|
2085 | function safeAssign(target) {
|
2086 | var args = [];
|
2087 | for (var _j = 1; _j < arguments.length; _j++) {
|
2088 | args[_j - 1] = arguments[_j];
|
2089 | }
|
2090 | Object.assign.apply(Object, __spreadArray([target], args));
|
2091 | }
|
2092 |
|
2093 | var import_immer4 = __toModule(require("immer"));
|
2094 | var coreModuleName = Symbol();
|
2095 | var coreModule = function () { return ({
|
2096 | name: coreModuleName,
|
2097 | init: function (api, _j, context) {
|
2098 | var baseQuery = _j.baseQuery, tagTypes = _j.tagTypes, reducerPath = _j.reducerPath, serializeQueryArgs = _j.serializeQueryArgs, keepUnusedDataFor = _j.keepUnusedDataFor, refetchOnMountOrArgChange = _j.refetchOnMountOrArgChange, refetchOnFocus = _j.refetchOnFocus, refetchOnReconnect = _j.refetchOnReconnect;
|
2099 | (0, import_immer4.enablePatches)();
|
2100 | assertCast(serializeQueryArgs);
|
2101 | var assertTagType = function (tag) {
|
2102 | if (typeof process !== "undefined" && true) {
|
2103 | if (!tagTypes.includes(tag.type)) {
|
2104 | console.error("Tag type '" + tag.type + "' was used, but not specified in `tagTypes`!");
|
2105 | }
|
2106 | }
|
2107 | return tag;
|
2108 | };
|
2109 | Object.assign(api, {
|
2110 | reducerPath: reducerPath,
|
2111 | endpoints: {},
|
2112 | internalActions: {
|
2113 | onOnline: onOnline,
|
2114 | onOffline: onOffline,
|
2115 | onFocus: onFocus,
|
2116 | onFocusLost: onFocusLost
|
2117 | },
|
2118 | util: {}
|
2119 | });
|
2120 | var _k = buildThunks({
|
2121 | baseQuery: baseQuery,
|
2122 | reducerPath: reducerPath,
|
2123 | context: context,
|
2124 | api: api,
|
2125 | serializeQueryArgs: serializeQueryArgs
|
2126 | }), queryThunk = _k.queryThunk, mutationThunk = _k.mutationThunk, patchQueryData = _k.patchQueryData, updateQueryData = _k.updateQueryData, upsertQueryData = _k.upsertQueryData, prefetch = _k.prefetch, buildMatchThunkActions = _k.buildMatchThunkActions;
|
2127 | var _l = buildSlice({
|
2128 | context: context,
|
2129 | queryThunk: queryThunk,
|
2130 | mutationThunk: mutationThunk,
|
2131 | reducerPath: reducerPath,
|
2132 | assertTagType: assertTagType,
|
2133 | config: {
|
2134 | refetchOnFocus: refetchOnFocus,
|
2135 | refetchOnReconnect: refetchOnReconnect,
|
2136 | refetchOnMountOrArgChange: refetchOnMountOrArgChange,
|
2137 | keepUnusedDataFor: keepUnusedDataFor,
|
2138 | reducerPath: reducerPath
|
2139 | }
|
2140 | }), reducer = _l.reducer, sliceActions = _l.actions;
|
2141 | safeAssign(api.util, {
|
2142 | patchQueryData: patchQueryData,
|
2143 | updateQueryData: updateQueryData,
|
2144 | upsertQueryData: upsertQueryData,
|
2145 | prefetch: prefetch,
|
2146 | resetApiState: sliceActions.resetApiState
|
2147 | });
|
2148 | safeAssign(api.internalActions, sliceActions);
|
2149 | var _m = buildMiddleware({
|
2150 | reducerPath: reducerPath,
|
2151 | context: context,
|
2152 | queryThunk: queryThunk,
|
2153 | mutationThunk: mutationThunk,
|
2154 | api: api,
|
2155 | assertTagType: assertTagType
|
2156 | }), middleware = _m.middleware, middlewareActions = _m.actions;
|
2157 | safeAssign(api.util, middlewareActions);
|
2158 | safeAssign(api, { reducer: reducer, middleware: middleware });
|
2159 | var _o = buildSelectors({
|
2160 | serializeQueryArgs: serializeQueryArgs,
|
2161 | reducerPath: reducerPath
|
2162 | }), buildQuerySelector = _o.buildQuerySelector, buildMutationSelector = _o.buildMutationSelector, selectInvalidatedBy = _o.selectInvalidatedBy;
|
2163 | safeAssign(api.util, { selectInvalidatedBy: selectInvalidatedBy });
|
2164 | var _p = buildInitiate({
|
2165 | queryThunk: queryThunk,
|
2166 | mutationThunk: mutationThunk,
|
2167 | api: api,
|
2168 | serializeQueryArgs: serializeQueryArgs,
|
2169 | context: context
|
2170 | }), buildInitiateQuery = _p.buildInitiateQuery, buildInitiateMutation = _p.buildInitiateMutation, getRunningMutationThunk = _p.getRunningMutationThunk, getRunningMutationsThunk = _p.getRunningMutationsThunk, getRunningQueriesThunk = _p.getRunningQueriesThunk, getRunningQueryThunk = _p.getRunningQueryThunk, getRunningOperationPromises = _p.getRunningOperationPromises, removalWarning = _p.removalWarning;
|
2171 | safeAssign(api.util, {
|
2172 | getRunningOperationPromises: getRunningOperationPromises,
|
2173 | getRunningOperationPromise: removalWarning,
|
2174 | getRunningMutationThunk: getRunningMutationThunk,
|
2175 | getRunningMutationsThunk: getRunningMutationsThunk,
|
2176 | getRunningQueryThunk: getRunningQueryThunk,
|
2177 | getRunningQueriesThunk: getRunningQueriesThunk
|
2178 | });
|
2179 | return {
|
2180 | name: coreModuleName,
|
2181 | injectEndpoint: function (endpointName, definition) {
|
2182 | var _a, _b;
|
2183 | var anyApi = api;
|
2184 | (_b = (_a = anyApi.endpoints)[endpointName]) != null ? _b : _a[endpointName] = {};
|
2185 | if (isQueryDefinition(definition)) {
|
2186 | safeAssign(anyApi.endpoints[endpointName], {
|
2187 | name: endpointName,
|
2188 | select: buildQuerySelector(endpointName, definition),
|
2189 | initiate: buildInitiateQuery(endpointName, definition)
|
2190 | }, buildMatchThunkActions(queryThunk, endpointName));
|
2191 | }
|
2192 | else if (isMutationDefinition(definition)) {
|
2193 | safeAssign(anyApi.endpoints[endpointName], {
|
2194 | name: endpointName,
|
2195 | select: buildMutationSelector(),
|
2196 | initiate: buildInitiateMutation(endpointName)
|
2197 | }, buildMatchThunkActions(mutationThunk, endpointName));
|
2198 | }
|
2199 | }
|
2200 | };
|
2201 | }
|
2202 | }); };
|
2203 |
|
2204 | var createApi = buildCreateApi(coreModule());
|
2205 |
|
\ | No newline at end of file |