wp/wp-includes/js/dist/router.js
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
--- a/wp/wp-includes/js/dist/router.js	Fri Sep 05 18:40:08 2025 +0200
+++ b/wp/wp-includes/js/dist/router.js	Fri Sep 05 18:52:52 2025 +0200
@@ -42,24 +42,704 @@
   privateApis: () => (/* reexport */ privateApis)
 });
 
-;// CONCATENATED MODULE: external ["wp","element"]
-const external_wp_element_namespaceObject = window["wp"]["element"];
-;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
+;// ./node_modules/route-recognizer/dist/route-recognizer.es.js
+var createObject = Object.create;
+function createMap() {
+    var map = createObject(null);
+    map["__"] = undefined;
+    delete map["__"];
+    return map;
+}
+
+var Target = function Target(path, matcher, delegate) {
+    this.path = path;
+    this.matcher = matcher;
+    this.delegate = delegate;
+};
+Target.prototype.to = function to (target, callback) {
+    var delegate = this.delegate;
+    if (delegate && delegate.willAddRoute) {
+        target = delegate.willAddRoute(this.matcher.target, target);
+    }
+    this.matcher.add(this.path, target);
+    if (callback) {
+        if (callback.length === 0) {
+            throw new Error("You must have an argument in the function passed to `to`");
+        }
+        this.matcher.addChild(this.path, target, callback, this.delegate);
+    }
+};
+var Matcher = function Matcher(target) {
+    this.routes = createMap();
+    this.children = createMap();
+    this.target = target;
+};
+Matcher.prototype.add = function add (path, target) {
+    this.routes[path] = target;
+};
+Matcher.prototype.addChild = function addChild (path, target, callback, delegate) {
+    var matcher = new Matcher(target);
+    this.children[path] = matcher;
+    var match = generateMatch(path, matcher, delegate);
+    if (delegate && delegate.contextEntered) {
+        delegate.contextEntered(target, match);
+    }
+    callback(match);
+};
+function generateMatch(startingPath, matcher, delegate) {
+    function match(path, callback) {
+        var fullPath = startingPath + path;
+        if (callback) {
+            callback(generateMatch(fullPath, matcher, delegate));
+        }
+        else {
+            return new Target(fullPath, matcher, delegate);
+        }
+    }
+    
+    return match;
+}
+function addRoute(routeArray, path, handler) {
+    var len = 0;
+    for (var i = 0; i < routeArray.length; i++) {
+        len += routeArray[i].path.length;
+    }
+    path = path.substr(len);
+    var route = { path: path, handler: handler };
+    routeArray.push(route);
+}
+function eachRoute(baseRoute, matcher, callback, binding) {
+    var routes = matcher.routes;
+    var paths = Object.keys(routes);
+    for (var i = 0; i < paths.length; i++) {
+        var path = paths[i];
+        var routeArray = baseRoute.slice();
+        addRoute(routeArray, path, routes[path]);
+        var nested = matcher.children[path];
+        if (nested) {
+            eachRoute(routeArray, nested, callback, binding);
+        }
+        else {
+            callback.call(binding, routeArray);
+        }
+    }
+}
+var map = function (callback, addRouteCallback) {
+    var matcher = new Matcher();
+    callback(generateMatch("", matcher, this.delegate));
+    eachRoute([], matcher, function (routes) {
+        if (addRouteCallback) {
+            addRouteCallback(this, routes);
+        }
+        else {
+            this.add(routes);
+        }
+    }, this);
+};
+
+// Normalizes percent-encoded values in `path` to upper-case and decodes percent-encoded
+// values that are not reserved (i.e., unicode characters, emoji, etc). The reserved
+// chars are "/" and "%".
+// Safe to call multiple times on the same path.
+// Normalizes percent-encoded values in `path` to upper-case and decodes percent-encoded
+function normalizePath(path) {
+    return path.split("/")
+        .map(normalizeSegment)
+        .join("/");
+}
+// We want to ensure the characters "%" and "/" remain in percent-encoded
+// form when normalizing paths, so replace them with their encoded form after
+// decoding the rest of the path
+var SEGMENT_RESERVED_CHARS = /%|\//g;
+function normalizeSegment(segment) {
+    if (segment.length < 3 || segment.indexOf("%") === -1)
+        { return segment; }
+    return decodeURIComponent(segment).replace(SEGMENT_RESERVED_CHARS, encodeURIComponent);
+}
+// We do not want to encode these characters when generating dynamic path segments
+// See https://tools.ietf.org/html/rfc3986#section-3.3
+// sub-delims: "!", "$", "&", "'", "(", ")", "*", "+", ",", ";", "="
+// others allowed by RFC 3986: ":", "@"
+//
+// First encode the entire path segment, then decode any of the encoded special chars.
+//
+// The chars "!", "'", "(", ")", "*" do not get changed by `encodeURIComponent`,
+// so the possible encoded chars are:
+// ['%24', '%26', '%2B', '%2C', '%3B', '%3D', '%3A', '%40'].
+var PATH_SEGMENT_ENCODINGS = /%(?:2(?:4|6|B|C)|3(?:B|D|A)|40)/g;
+function encodePathSegment(str) {
+    return encodeURIComponent(str).replace(PATH_SEGMENT_ENCODINGS, decodeURIComponent);
+}
+
+var escapeRegex = /(\/|\.|\*|\+|\?|\||\(|\)|\[|\]|\{|\}|\\)/g;
+var isArray = Array.isArray;
+var route_recognizer_es_hasOwnProperty = Object.prototype.hasOwnProperty;
+function getParam(params, key) {
+    if (typeof params !== "object" || params === null) {
+        throw new Error("You must pass an object as the second argument to `generate`.");
+    }
+    if (!route_recognizer_es_hasOwnProperty.call(params, key)) {
+        throw new Error("You must provide param `" + key + "` to `generate`.");
+    }
+    var value = params[key];
+    var str = typeof value === "string" ? value : "" + value;
+    if (str.length === 0) {
+        throw new Error("You must provide a param `" + key + "`.");
+    }
+    return str;
+}
+var eachChar = [];
+eachChar[0 /* Static */] = function (segment, currentState) {
+    var state = currentState;
+    var value = segment.value;
+    for (var i = 0; i < value.length; i++) {
+        var ch = value.charCodeAt(i);
+        state = state.put(ch, false, false);
+    }
+    return state;
+};
+eachChar[1 /* Dynamic */] = function (_, currentState) {
+    return currentState.put(47 /* SLASH */, true, true);
+};
+eachChar[2 /* Star */] = function (_, currentState) {
+    return currentState.put(-1 /* ANY */, false, true);
+};
+eachChar[4 /* Epsilon */] = function (_, currentState) {
+    return currentState;
+};
+var regex = [];
+regex[0 /* Static */] = function (segment) {
+    return segment.value.replace(escapeRegex, "\\$1");
+};
+regex[1 /* Dynamic */] = function () {
+    return "([^/]+)";
+};
+regex[2 /* Star */] = function () {
+    return "(.+)";
+};
+regex[4 /* Epsilon */] = function () {
+    return "";
+};
+var generate = [];
+generate[0 /* Static */] = function (segment) {
+    return segment.value;
+};
+generate[1 /* Dynamic */] = function (segment, params) {
+    var value = getParam(params, segment.value);
+    if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
+        return encodePathSegment(value);
+    }
+    else {
+        return value;
+    }
+};
+generate[2 /* Star */] = function (segment, params) {
+    return getParam(params, segment.value);
+};
+generate[4 /* Epsilon */] = function () {
+    return "";
+};
+var EmptyObject = Object.freeze({});
+var EmptyArray = Object.freeze([]);
+// The `names` will be populated with the paramter name for each dynamic/star
+// segment. `shouldDecodes` will be populated with a boolean for each dyanamic/star
+// segment, indicating whether it should be decoded during recognition.
+function parse(segments, route, types) {
+    // normalize route as not starting with a "/". Recognition will
+    // also normalize.
+    if (route.length > 0 && route.charCodeAt(0) === 47 /* SLASH */) {
+        route = route.substr(1);
+    }
+    var parts = route.split("/");
+    var names = undefined;
+    var shouldDecodes = undefined;
+    for (var i = 0; i < parts.length; i++) {
+        var part = parts[i];
+        var flags = 0;
+        var type = 0;
+        if (part === "") {
+            type = 4 /* Epsilon */;
+        }
+        else if (part.charCodeAt(0) === 58 /* COLON */) {
+            type = 1 /* Dynamic */;
+        }
+        else if (part.charCodeAt(0) === 42 /* STAR */) {
+            type = 2 /* Star */;
+        }
+        else {
+            type = 0 /* Static */;
+        }
+        flags = 2 << type;
+        if (flags & 12 /* Named */) {
+            part = part.slice(1);
+            names = names || [];
+            names.push(part);
+            shouldDecodes = shouldDecodes || [];
+            shouldDecodes.push((flags & 4 /* Decoded */) !== 0);
+        }
+        if (flags & 14 /* Counted */) {
+            types[type]++;
+        }
+        segments.push({
+            type: type,
+            value: normalizeSegment(part)
+        });
+    }
+    return {
+        names: names || EmptyArray,
+        shouldDecodes: shouldDecodes || EmptyArray,
+    };
+}
+function isEqualCharSpec(spec, char, negate) {
+    return spec.char === char && spec.negate === negate;
+}
+// A State has a character specification and (`charSpec`) and a list of possible
+// subsequent states (`nextStates`).
+//
+// If a State is an accepting state, it will also have several additional
+// properties:
+//
+// * `regex`: A regular expression that is used to extract parameters from paths
+//   that reached this accepting state.
+// * `handlers`: Information on how to convert the list of captures into calls
+//   to registered handlers with the specified parameters
+// * `types`: How many static, dynamic or star segments in this route. Used to
+//   decide which route to use if multiple registered routes match a path.
+//
+// Currently, State is implemented naively by looping over `nextStates` and
+// comparing a character specification against a character. A more efficient
+// implementation would use a hash of keys pointing at one or more next states.
+var State = function State(states, id, char, negate, repeat) {
+    this.states = states;
+    this.id = id;
+    this.char = char;
+    this.negate = negate;
+    this.nextStates = repeat ? id : null;
+    this.pattern = "";
+    this._regex = undefined;
+    this.handlers = undefined;
+    this.types = undefined;
+};
+State.prototype.regex = function regex$1 () {
+    if (!this._regex) {
+        this._regex = new RegExp(this.pattern);
+    }
+    return this._regex;
+};
+State.prototype.get = function get (char, negate) {
+        var this$1 = this;
+
+    var nextStates = this.nextStates;
+    if (nextStates === null)
+        { return; }
+    if (isArray(nextStates)) {
+        for (var i = 0; i < nextStates.length; i++) {
+            var child = this$1.states[nextStates[i]];
+            if (isEqualCharSpec(child, char, negate)) {
+                return child;
+            }
+        }
+    }
+    else {
+        var child$1 = this.states[nextStates];
+        if (isEqualCharSpec(child$1, char, negate)) {
+            return child$1;
+        }
+    }
+};
+State.prototype.put = function put (char, negate, repeat) {
+    var state;
+    // If the character specification already exists in a child of the current
+    // state, just return that state.
+    if (state = this.get(char, negate)) {
+        return state;
+    }
+    // Make a new state for the character spec
+    var states = this.states;
+    state = new State(states, states.length, char, negate, repeat);
+    states[states.length] = state;
+    // Insert the new state as a child of the current state
+    if (this.nextStates == null) {
+        this.nextStates = state.id;
+    }
+    else if (isArray(this.nextStates)) {
+        this.nextStates.push(state.id);
+    }
+    else {
+        this.nextStates = [this.nextStates, state.id];
+    }
+    // Return the new state
+    return state;
+};
+// Find a list of child states matching the next character
+State.prototype.match = function match (ch) {
+        var this$1 = this;
+
+    var nextStates = this.nextStates;
+    if (!nextStates)
+        { return []; }
+    var returned = [];
+    if (isArray(nextStates)) {
+        for (var i = 0; i < nextStates.length; i++) {
+            var child = this$1.states[nextStates[i]];
+            if (isMatch(child, ch)) {
+                returned.push(child);
+            }
+        }
+    }
+    else {
+        var child$1 = this.states[nextStates];
+        if (isMatch(child$1, ch)) {
+            returned.push(child$1);
+        }
+    }
+    return returned;
+};
+function isMatch(spec, char) {
+    return spec.negate ? spec.char !== char && spec.char !== -1 /* ANY */ : spec.char === char || spec.char === -1 /* ANY */;
+}
+// This is a somewhat naive strategy, but should work in a lot of cases
+// A better strategy would properly resolve /posts/:id/new and /posts/edit/:id.
+//
+// This strategy generally prefers more static and less dynamic matching.
+// Specifically, it
+//
+//  * prefers fewer stars to more, then
+//  * prefers using stars for less of the match to more, then
+//  * prefers fewer dynamic segments to more, then
+//  * prefers more static segments to more
+function sortSolutions(states) {
+    return states.sort(function (a, b) {
+        var ref = a.types || [0, 0, 0];
+        var astatics = ref[0];
+        var adynamics = ref[1];
+        var astars = ref[2];
+        var ref$1 = b.types || [0, 0, 0];
+        var bstatics = ref$1[0];
+        var bdynamics = ref$1[1];
+        var bstars = ref$1[2];
+        if (astars !== bstars) {
+            return astars - bstars;
+        }
+        if (astars) {
+            if (astatics !== bstatics) {
+                return bstatics - astatics;
+            }
+            if (adynamics !== bdynamics) {
+                return bdynamics - adynamics;
+            }
+        }
+        if (adynamics !== bdynamics) {
+            return adynamics - bdynamics;
+        }
+        if (astatics !== bstatics) {
+            return bstatics - astatics;
+        }
+        return 0;
+    });
+}
+function recognizeChar(states, ch) {
+    var nextStates = [];
+    for (var i = 0, l = states.length; i < l; i++) {
+        var state = states[i];
+        nextStates = nextStates.concat(state.match(ch));
+    }
+    return nextStates;
+}
+var RecognizeResults = function RecognizeResults(queryParams) {
+    this.length = 0;
+    this.queryParams = queryParams || {};
+};
+
+RecognizeResults.prototype.splice = Array.prototype.splice;
+RecognizeResults.prototype.slice = Array.prototype.slice;
+RecognizeResults.prototype.push = Array.prototype.push;
+function findHandler(state, originalPath, queryParams) {
+    var handlers = state.handlers;
+    var regex = state.regex();
+    if (!regex || !handlers)
+        { throw new Error("state not initialized"); }
+    var captures = originalPath.match(regex);
+    var currentCapture = 1;
+    var result = new RecognizeResults(queryParams);
+    result.length = handlers.length;
+    for (var i = 0; i < handlers.length; i++) {
+        var handler = handlers[i];
+        var names = handler.names;
+        var shouldDecodes = handler.shouldDecodes;
+        var params = EmptyObject;
+        var isDynamic = false;
+        if (names !== EmptyArray && shouldDecodes !== EmptyArray) {
+            for (var j = 0; j < names.length; j++) {
+                isDynamic = true;
+                var name = names[j];
+                var capture = captures && captures[currentCapture++];
+                if (params === EmptyObject) {
+                    params = {};
+                }
+                if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS && shouldDecodes[j]) {
+                    params[name] = capture && decodeURIComponent(capture);
+                }
+                else {
+                    params[name] = capture;
+                }
+            }
+        }
+        result[i] = {
+            handler: handler.handler,
+            params: params,
+            isDynamic: isDynamic
+        };
+    }
+    return result;
+}
+function decodeQueryParamPart(part) {
+    // http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4.1
+    part = part.replace(/\+/gm, "%20");
+    var result;
+    try {
+        result = decodeURIComponent(part);
+    }
+    catch (error) {
+        result = "";
+    }
+    return result;
+}
+var RouteRecognizer = function RouteRecognizer() {
+    this.names = createMap();
+    var states = [];
+    var state = new State(states, 0, -1 /* ANY */, true, false);
+    states[0] = state;
+    this.states = states;
+    this.rootState = state;
+};
+RouteRecognizer.prototype.add = function add (routes, options) {
+    var currentState = this.rootState;
+    var pattern = "^";
+    var types = [0, 0, 0];
+    var handlers = new Array(routes.length);
+    var allSegments = [];
+    var isEmpty = true;
+    var j = 0;
+    for (var i = 0; i < routes.length; i++) {
+        var route = routes[i];
+        var ref = parse(allSegments, route.path, types);
+            var names = ref.names;
+            var shouldDecodes = ref.shouldDecodes;
+        // preserve j so it points to the start of newly added segments
+        for (; j < allSegments.length; j++) {
+            var segment = allSegments[j];
+            if (segment.type === 4 /* Epsilon */) {
+                continue;
+            }
+            isEmpty = false;
+            // Add a "/" for the new segment
+            currentState = currentState.put(47 /* SLASH */, false, false);
+            pattern += "/";
+            // Add a representation of the segment to the NFA and regex
+            currentState = eachChar[segment.type](segment, currentState);
+            pattern += regex[segment.type](segment);
+        }
+        handlers[i] = {
+            handler: route.handler,
+            names: names,
+            shouldDecodes: shouldDecodes
+        };
+    }
+    if (isEmpty) {
+        currentState = currentState.put(47 /* SLASH */, false, false);
+        pattern += "/";
+    }
+    currentState.handlers = handlers;
+    currentState.pattern = pattern + "$";
+    currentState.types = types;
+    var name;
+    if (typeof options === "object" && options !== null && options.as) {
+        name = options.as;
+    }
+    if (name) {
+        // if (this.names[name]) {
+        //   throw new Error("You may not add a duplicate route named `" + name + "`.");
+        // }
+        this.names[name] = {
+            segments: allSegments,
+            handlers: handlers
+        };
+    }
+};
+RouteRecognizer.prototype.handlersFor = function handlersFor (name) {
+    var route = this.names[name];
+    if (!route) {
+        throw new Error("There is no route named " + name);
+    }
+    var result = new Array(route.handlers.length);
+    for (var i = 0; i < route.handlers.length; i++) {
+        var handler = route.handlers[i];
+        result[i] = handler;
+    }
+    return result;
+};
+RouteRecognizer.prototype.hasRoute = function hasRoute (name) {
+    return !!this.names[name];
+};
+RouteRecognizer.prototype.generate = function generate$1 (name, params) {
+    var route = this.names[name];
+    var output = "";
+    if (!route) {
+        throw new Error("There is no route named " + name);
+    }
+    var segments = route.segments;
+    for (var i = 0; i < segments.length; i++) {
+        var segment = segments[i];
+        if (segment.type === 4 /* Epsilon */) {
+            continue;
+        }
+        output += "/";
+        output += generate[segment.type](segment, params);
+    }
+    if (output.charAt(0) !== "/") {
+        output = "/" + output;
+    }
+    if (params && params.queryParams) {
+        output += this.generateQueryString(params.queryParams);
+    }
+    return output;
+};
+RouteRecognizer.prototype.generateQueryString = function generateQueryString (params) {
+    var pairs = [];
+    var keys = Object.keys(params);
+    keys.sort();
+    for (var i = 0; i < keys.length; i++) {
+        var key = keys[i];
+        var value = params[key];
+        if (value == null) {
+            continue;
+        }
+        var pair = encodeURIComponent(key);
+        if (isArray(value)) {
+            for (var j = 0; j < value.length; j++) {
+                var arrayPair = key + "[]" + "=" + encodeURIComponent(value[j]);
+                pairs.push(arrayPair);
+            }
+        }
+        else {
+            pair += "=" + encodeURIComponent(value);
+            pairs.push(pair);
+        }
+    }
+    if (pairs.length === 0) {
+        return "";
+    }
+    return "?" + pairs.join("&");
+};
+RouteRecognizer.prototype.parseQueryString = function parseQueryString (queryString) {
+    var pairs = queryString.split("&");
+    var queryParams = {};
+    for (var i = 0; i < pairs.length; i++) {
+        var pair = pairs[i].split("="), key = decodeQueryParamPart(pair[0]), keyLength = key.length, isArray = false, value = (void 0);
+        if (pair.length === 1) {
+            value = "true";
+        }
+        else {
+            // Handle arrays
+            if (keyLength > 2 && key.slice(keyLength - 2) === "[]") {
+                isArray = true;
+                key = key.slice(0, keyLength - 2);
+                if (!queryParams[key]) {
+                    queryParams[key] = [];
+                }
+            }
+            value = pair[1] ? decodeQueryParamPart(pair[1]) : "";
+        }
+        if (isArray) {
+            queryParams[key].push(value);
+        }
+        else {
+            queryParams[key] = value;
+        }
+    }
+    return queryParams;
+};
+RouteRecognizer.prototype.recognize = function recognize (path) {
+    var results;
+    var states = [this.rootState];
+    var queryParams = {};
+    var isSlashDropped = false;
+    var hashStart = path.indexOf("#");
+    if (hashStart !== -1) {
+        path = path.substr(0, hashStart);
+    }
+    var queryStart = path.indexOf("?");
+    if (queryStart !== -1) {
+        var queryString = path.substr(queryStart + 1, path.length);
+        path = path.substr(0, queryStart);
+        queryParams = this.parseQueryString(queryString);
+    }
+    if (path.charAt(0) !== "/") {
+        path = "/" + path;
+    }
+    var originalPath = path;
+    if (RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS) {
+        path = normalizePath(path);
+    }
+    else {
+        path = decodeURI(path);
+        originalPath = decodeURI(originalPath);
+    }
+    var pathLen = path.length;
+    if (pathLen > 1 && path.charAt(pathLen - 1) === "/") {
+        path = path.substr(0, pathLen - 1);
+        originalPath = originalPath.substr(0, originalPath.length - 1);
+        isSlashDropped = true;
+    }
+    for (var i = 0; i < path.length; i++) {
+        states = recognizeChar(states, path.charCodeAt(i));
+        if (!states.length) {
+            break;
+        }
+    }
+    var solutions = [];
+    for (var i$1 = 0; i$1 < states.length; i$1++) {
+        if (states[i$1].handlers) {
+            solutions.push(states[i$1]);
+        }
+    }
+    states = sortSolutions(solutions);
+    var state = solutions[0];
+    if (state && state.handlers) {
+        // if a trailing slash was dropped and a star segment is the last segment
+        // specified, put the trailing slash back
+        if (isSlashDropped && state.pattern && state.pattern.slice(-5) === "(.+)$") {
+            originalPath = originalPath + "/";
+        }
+        results = findHandler(state, originalPath, queryParams);
+    }
+    return results;
+};
+RouteRecognizer.VERSION = "0.3.4";
+// Set to false to opt-out of encoding and decoding path segments.
+// See https://github.com/tildeio/route-recognizer/pull/55
+RouteRecognizer.ENCODE_AND_DECODE_PATH_SEGMENTS = true;
+RouteRecognizer.Normalizer = {
+    normalizeSegment: normalizeSegment, normalizePath: normalizePath, encodePathSegment: encodePathSegment
+};
+RouteRecognizer.prototype.map = map;
+
+/* harmony default export */ const route_recognizer_es = (RouteRecognizer);
+
+
+;// ./node_modules/@babel/runtime/helpers/esm/extends.js
 function extends_extends() {
-  extends_extends = Object.assign ? Object.assign.bind() : function (target) {
-    for (var i = 1; i < arguments.length; i++) {
-      var source = arguments[i];
-      for (var key in source) {
-        if (Object.prototype.hasOwnProperty.call(source, key)) {
-          target[key] = source[key];
-        }
-      }
+  return extends_extends = Object.assign ? Object.assign.bind() : function (n) {
+    for (var e = 1; e < arguments.length; e++) {
+      var t = arguments[e];
+      for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]);
     }
-    return target;
-  };
-  return extends_extends.apply(this, arguments);
+    return n;
+  }, extends_extends.apply(null, arguments);
 }
-;// CONCATENATED MODULE: ./node_modules/history/index.js
+
+;// ./node_modules/history/index.js
 
 
 /**
@@ -849,106 +1529,249 @@
 
 
 
-;// CONCATENATED MODULE: external ["wp","url"]
+;// external ["wp","element"]
+const external_wp_element_namespaceObject = window["wp"]["element"];
+;// external ["wp","url"]
 const external_wp_url_namespaceObject = window["wp"]["url"];
-;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/history.js
+;// external ["wp","compose"]
+const external_wp_compose_namespaceObject = window["wp"]["compose"];
+;// external "ReactJSXRuntime"
+const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
+;// ./node_modules/@wordpress/router/build-module/router.js
+/* wp:polyfill */
 /**
  * External dependencies
  */
 
 
+
 /**
  * WordPress dependencies
  */
 
-const history_history = createBrowserHistory();
-const originalHistoryPush = history_history.push;
-const originalHistoryReplace = history_history.replace;
+
+
+
+/**
+ * Internal dependencies
+ */
 
-// Preserve the `wp_theme_preview` query parameter when navigating
-// around the Site Editor.
-// TODO: move this hack out of the router into Site Editor code.
-function preserveThemePreview(params) {
-  if (params.hasOwnProperty('wp_theme_preview')) {
-    return params;
+const router_history = createBrowserHistory();
+const RoutesContext = (0,external_wp_element_namespaceObject.createContext)(null);
+const ConfigContext = (0,external_wp_element_namespaceObject.createContext)({
+  pathArg: 'p'
+});
+const locationMemo = new WeakMap();
+function getLocationWithQuery() {
+  const location = router_history.location;
+  let locationWithQuery = locationMemo.get(location);
+  if (!locationWithQuery) {
+    locationWithQuery = {
+      ...location,
+      query: Object.fromEntries(new URLSearchParams(location.search))
+    };
+    locationMemo.set(location, locationWithQuery);
   }
-  const currentSearch = new URLSearchParams(history_history.location.search);
-  const currentThemePreview = currentSearch.get('wp_theme_preview');
-  if (currentThemePreview === null) {
-    return params;
+  return locationWithQuery;
+}
+function useLocation() {
+  const context = (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
+  if (!context) {
+    throw new Error('useLocation must be used within a RouterProvider');
   }
-  return {
-    ...params,
-    wp_theme_preview: currentThemePreview
-  };
-}
-function push(params, state) {
-  const search = (0,external_wp_url_namespaceObject.buildQueryString)(preserveThemePreview(params));
-  return originalHistoryPush.call(history_history, {
-    search
-  }, state);
+  return context;
 }
-function replace(params, state) {
-  const search = (0,external_wp_url_namespaceObject.buildQueryString)(preserveThemePreview(params));
-  return originalHistoryReplace.call(history_history, {
-    search
-  }, state);
+function useHistory() {
+  const {
+    pathArg,
+    beforeNavigate
+  } = (0,external_wp_element_namespaceObject.useContext)(ConfigContext);
+  const navigate = (0,external_wp_compose_namespaceObject.useEvent)(async (rawPath, options = {}) => {
+    var _getPath;
+    const query = (0,external_wp_url_namespaceObject.getQueryArgs)(rawPath);
+    const path = (_getPath = (0,external_wp_url_namespaceObject.getPath)('http://domain.com/' + rawPath)) !== null && _getPath !== void 0 ? _getPath : '';
+    const performPush = () => {
+      const result = beforeNavigate ? beforeNavigate({
+        path,
+        query
+      }) : {
+        path,
+        query
+      };
+      return router_history.push({
+        search: (0,external_wp_url_namespaceObject.buildQueryString)({
+          [pathArg]: result.path,
+          ...result.query
+        })
+      }, options.state);
+    };
+
+    /*
+     * Skip transition in mobile, otherwise it crashes the browser.
+     * See: https://github.com/WordPress/gutenberg/pull/63002.
+     */
+    const isMediumOrBigger = window.matchMedia('(min-width: 782px)').matches;
+    if (!isMediumOrBigger || !document.startViewTransition || !options.transition) {
+      performPush();
+      return;
+    }
+    await new Promise(resolve => {
+      var _options$transition;
+      const classname = (_options$transition = options.transition) !== null && _options$transition !== void 0 ? _options$transition : '';
+      document.documentElement.classList.add(classname);
+      const transition = document.startViewTransition(() => performPush());
+      transition.finished.finally(() => {
+        document.documentElement.classList.remove(classname);
+        resolve();
+      });
+    });
+  });
+  return (0,external_wp_element_namespaceObject.useMemo)(() => ({
+    navigate,
+    back: router_history.back
+  }), [navigate]);
 }
-const locationMemo = new WeakMap();
-function getLocationWithParams() {
-  const location = history_history.location;
-  let locationWithParams = locationMemo.get(location);
-  if (!locationWithParams) {
-    locationWithParams = {
-      ...location,
-      params: Object.fromEntries(new URLSearchParams(location.search))
+function useMatch(location, matcher, pathArg, matchResolverArgs) {
+  const {
+    query: rawQuery = {}
+  } = location;
+  return (0,external_wp_element_namespaceObject.useMemo)(() => {
+    const {
+      [pathArg]: path = '/',
+      ...query
+    } = rawQuery;
+    const result = matcher.recognize(path)?.[0];
+    if (!result) {
+      return {
+        name: '404',
+        path: (0,external_wp_url_namespaceObject.addQueryArgs)(path, query),
+        areas: {},
+        widths: {},
+        query,
+        params: {}
+      };
+    }
+    const matchedRoute = result.handler;
+    const resolveFunctions = (record = {}) => {
+      return Object.fromEntries(Object.entries(record).map(([key, value]) => {
+        if (typeof value === 'function') {
+          return [key, value({
+            query,
+            params: result.params,
+            ...matchResolverArgs
+          })];
+        }
+        return [key, value];
+      }));
     };
-    locationMemo.set(location, locationWithParams);
-  }
-  return locationWithParams;
+    return {
+      name: matchedRoute.name,
+      areas: resolveFunctions(matchedRoute.areas),
+      widths: resolveFunctions(matchedRoute.widths),
+      params: result.params,
+      query,
+      path: (0,external_wp_url_namespaceObject.addQueryArgs)(path, query)
+    };
+  }, [matcher, rawQuery, pathArg, matchResolverArgs]);
 }
-history_history.push = push;
-history_history.replace = replace;
-history_history.getLocationWithParams = getLocationWithParams;
-/* harmony default export */ const build_module_history = (history_history);
+function RouterProvider({
+  routes,
+  pathArg,
+  beforeNavigate,
+  children,
+  matchResolverArgs
+}) {
+  const location = (0,external_wp_element_namespaceObject.useSyncExternalStore)(router_history.listen, getLocationWithQuery, getLocationWithQuery);
+  const matcher = (0,external_wp_element_namespaceObject.useMemo)(() => {
+    const ret = new route_recognizer_es();
+    routes.forEach(route => {
+      ret.add([{
+        path: route.path,
+        handler: route
+      }], {
+        as: route.name
+      });
+    });
+    return ret;
+  }, [routes]);
+  const match = useMatch(location, matcher, pathArg, matchResolverArgs);
+  const config = (0,external_wp_element_namespaceObject.useMemo)(() => ({
+    beforeNavigate,
+    pathArg
+  }), [beforeNavigate, pathArg]);
+  return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConfigContext.Provider, {
+    value: config,
+    children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RoutesContext.Provider, {
+      value: match,
+      children: children
+    })
+  });
+}
 
-;// CONCATENATED MODULE: external "ReactJSXRuntime"
-const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
-;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/router.js
+;// ./node_modules/@wordpress/router/build-module/link.js
 /**
  * WordPress dependencies
  */
 
 
+
 /**
  * Internal dependencies
  */
 
 
-const RoutesContext = (0,external_wp_element_namespaceObject.createContext)();
-const HistoryContext = (0,external_wp_element_namespaceObject.createContext)();
-function useLocation() {
-  return (0,external_wp_element_namespaceObject.useContext)(RoutesContext);
-}
-function useHistory() {
-  return (0,external_wp_element_namespaceObject.useContext)(HistoryContext);
+function useLink(to, options = {}) {
+  var _getPath;
+  const history = useHistory();
+  const {
+    pathArg,
+    beforeNavigate
+  } = (0,external_wp_element_namespaceObject.useContext)(ConfigContext);
+  function onClick(event) {
+    event?.preventDefault();
+    history.navigate(to, options);
+  }
+  const query = (0,external_wp_url_namespaceObject.getQueryArgs)(to);
+  const path = (_getPath = (0,external_wp_url_namespaceObject.getPath)('http://domain.com/' + to)) !== null && _getPath !== void 0 ? _getPath : '';
+  const link = (0,external_wp_element_namespaceObject.useMemo)(() => {
+    return beforeNavigate ? beforeNavigate({
+      path,
+      query
+    }) : {
+      path,
+      query
+    };
+  }, [path, query, beforeNavigate]);
+  const [before] = window.location.href.split('?');
+  return {
+    href: `${before}?${(0,external_wp_url_namespaceObject.buildQueryString)({
+      [pathArg]: link.path,
+      ...link.query
+    })}`,
+    onClick
+  };
 }
-function RouterProvider({
-  children
+function Link({
+  to,
+  options,
+  children,
+  ...props
 }) {
-  const location = (0,external_wp_element_namespaceObject.useSyncExternalStore)(build_module_history.listen, build_module_history.getLocationWithParams, build_module_history.getLocationWithParams);
-  return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(HistoryContext.Provider, {
-    value: build_module_history,
-    children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RoutesContext.Provider, {
-      value: location,
-      children: children
-    })
+  const {
+    href,
+    onClick
+  } = useLink(to, options);
+  return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
+    href: href,
+    onClick: onClick,
+    ...props,
+    children: children
   });
 }
 
-;// CONCATENATED MODULE: external ["wp","privateApis"]
+;// external ["wp","privateApis"]
 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
-;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/lock-unlock.js
+;// ./node_modules/@wordpress/router/build-module/lock-unlock.js
 /**
  * WordPress dependencies
  */
@@ -958,20 +1781,23 @@
   unlock
 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/router');
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/private-apis.js
+;// ./node_modules/@wordpress/router/build-module/private-apis.js
 /**
  * Internal dependencies
  */
 
 
+
 const privateApis = {};
 lock(privateApis, {
   useHistory: useHistory,
   useLocation: useLocation,
-  RouterProvider: RouterProvider
+  RouterProvider: RouterProvider,
+  useLink: useLink,
+  Link: Link
 });
 
-;// CONCATENATED MODULE: ./node_modules/@wordpress/router/build-module/index.js
+;// ./node_modules/@wordpress/router/build-module/index.js
 
 
 (window.wp = window.wp || {}).router = __webpack_exports__;