var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
  get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
}) : x2)(function(x2) {
  if (typeof require !== "undefined") return require.apply(this, arguments);
  throw Error('Dynamic require of "' + x2 + '" is not supported');
});
var __commonJS = (cb, mod) => function __require4() {
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
  for (var name2 in all)
    __defProp(target, name2, { get: all[name2], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));

// package-external:@wordpress/i18n
var require_i18n = __commonJS({
  "package-external:@wordpress/i18n"(exports, module) {
    module.exports = window.wp.i18n;
  }
});

// package-external:@wordpress/element
var require_element = __commonJS({
  "package-external:@wordpress/element"(exports, module) {
    module.exports = window.wp.element;
  }
});

// vendor-external:react
var require_react = __commonJS({
  "vendor-external:react"(exports, module) {
    module.exports = window.React;
  }
});

// vendor-external:react/jsx-runtime
var require_jsx_runtime = __commonJS({
  "vendor-external:react/jsx-runtime"(exports, module) {
    module.exports = window.ReactJSXRuntime;
  }
});

// vendor-external:react-dom
var require_react_dom = __commonJS({
  "vendor-external:react-dom"(exports, module) {
    module.exports = window.ReactDOM;
  }
});

// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js
var require_use_sync_external_store_shim_development = __commonJS({
  "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.development.js"(exports) {
    "use strict";
    (function() {
      function is(x2, y2) {
        return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
      }
      function useSyncExternalStore$2(subscribe, getSnapshot) {
        didWarnOld18Alpha || void 0 === React48.startTransition || (didWarnOld18Alpha = true, console.error(
          "You are using an outdated, pre-release alpha of React 18 that does not support useSyncExternalStore. The use-sync-external-store shim will not work correctly. Upgrade to a newer pre-release."
        ));
        var value = getSnapshot();
        if (!didWarnUncachedGetSnapshot) {
          var cachedValue = getSnapshot();
          objectIs(value, cachedValue) || (console.error(
            "The result of getSnapshot should be cached to avoid an infinite loop"
          ), didWarnUncachedGetSnapshot = true);
        }
        cachedValue = useState29({
          inst: { value, getSnapshot }
        });
        var inst = cachedValue[0].inst, forceUpdate = cachedValue[1];
        useLayoutEffect4(
          function() {
            inst.value = value;
            inst.getSnapshot = getSnapshot;
            checkIfSnapshotChanged(inst) && forceUpdate({ inst });
          },
          [subscribe, value, getSnapshot]
        );
        useEffect20(
          function() {
            checkIfSnapshotChanged(inst) && forceUpdate({ inst });
            return subscribe(function() {
              checkIfSnapshotChanged(inst) && forceUpdate({ inst });
            });
          },
          [subscribe]
        );
        useDebugValue2(value);
        return value;
      }
      function checkIfSnapshotChanged(inst) {
        var latestGetSnapshot = inst.getSnapshot;
        inst = inst.value;
        try {
          var nextValue = latestGetSnapshot();
          return !objectIs(inst, nextValue);
        } catch (error) {
          return true;
        }
      }
      function useSyncExternalStore$1(subscribe, getSnapshot) {
        return getSnapshot();
      }
      "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
      var React48 = require_react(), objectIs = "function" === typeof Object.is ? Object.is : is, useState29 = React48.useState, useEffect20 = React48.useEffect, useLayoutEffect4 = React48.useLayoutEffect, useDebugValue2 = React48.useDebugValue, didWarnOld18Alpha = false, didWarnUncachedGetSnapshot = false, shim = "undefined" === typeof window || "undefined" === typeof window.document || "undefined" === typeof window.document.createElement ? useSyncExternalStore$1 : useSyncExternalStore$2;
      exports.useSyncExternalStore = void 0 !== React48.useSyncExternalStore ? React48.useSyncExternalStore : shim;
      "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
    })();
  }
});

// node_modules/use-sync-external-store/shim/index.js
var require_shim = __commonJS({
  "node_modules/use-sync-external-store/shim/index.js"(exports, module) {
    "use strict";
    if (false) {
      module.exports = null;
    } else {
      module.exports = require_use_sync_external_store_shim_development();
    }
  }
});

// node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js
var require_with_selector_development = __commonJS({
  "node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js"(exports) {
    "use strict";
    (function() {
      function is(x2, y2) {
        return x2 === y2 && (0 !== x2 || 1 / x2 === 1 / y2) || x2 !== x2 && y2 !== y2;
      }
      "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(Error());
      var React48 = require_react(), shim = require_shim(), objectIs = "function" === typeof Object.is ? Object.is : is, useSyncExternalStore2 = shim.useSyncExternalStore, useRef23 = React48.useRef, useEffect20 = React48.useEffect, useMemo29 = React48.useMemo, useDebugValue2 = React48.useDebugValue;
      exports.useSyncExternalStoreWithSelector = function(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
        var instRef = useRef23(null);
        if (null === instRef.current) {
          var inst = { hasValue: false, value: null };
          instRef.current = inst;
        } else inst = instRef.current;
        instRef = useMemo29(
          function() {
            function memoizedSelector(nextSnapshot) {
              if (!hasMemo) {
                hasMemo = true;
                memoizedSnapshot = nextSnapshot;
                nextSnapshot = selector(nextSnapshot);
                if (void 0 !== isEqual && inst.hasValue) {
                  var currentSelection = inst.value;
                  if (isEqual(currentSelection, nextSnapshot))
                    return memoizedSelection = currentSelection;
                }
                return memoizedSelection = nextSnapshot;
              }
              currentSelection = memoizedSelection;
              if (objectIs(memoizedSnapshot, nextSnapshot))
                return currentSelection;
              var nextSelection = selector(nextSnapshot);
              if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))
                return memoizedSnapshot = nextSnapshot, currentSelection;
              memoizedSnapshot = nextSnapshot;
              return memoizedSelection = nextSelection;
            }
            var hasMemo = false, memoizedSnapshot, memoizedSelection, maybeGetServerSnapshot = void 0 === getServerSnapshot ? null : getServerSnapshot;
            return [
              function() {
                return memoizedSelector(getSnapshot());
              },
              null === maybeGetServerSnapshot ? void 0 : function() {
                return memoizedSelector(maybeGetServerSnapshot());
              }
            ];
          },
          [getSnapshot, getServerSnapshot, selector, isEqual]
        );
        var value = useSyncExternalStore2(subscribe, instRef[0], instRef[1]);
        useEffect20(
          function() {
            inst.hasValue = true;
            inst.value = value;
          },
          [value]
        );
        useDebugValue2(value);
        return value;
      };
      "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop && __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(Error());
    })();
  }
});

// node_modules/use-sync-external-store/shim/with-selector.js
var require_with_selector = __commonJS({
  "node_modules/use-sync-external-store/shim/with-selector.js"(exports, module) {
    "use strict";
    if (false) {
      module.exports = null;
    } else {
      module.exports = require_with_selector_development();
    }
  }
});

// package-external:@wordpress/primitives
var require_primitives = __commonJS({
  "package-external:@wordpress/primitives"(exports, module) {
    module.exports = window.wp.primitives;
  }
});

// package-external:@wordpress/compose
var require_compose = __commonJS({
  "package-external:@wordpress/compose"(exports, module) {
    module.exports = window.wp.compose;
  }
});

// package-external:@wordpress/theme
var require_theme = __commonJS({
  "package-external:@wordpress/theme"(exports, module) {
    module.exports = window.wp.theme;
  }
});

// package-external:@wordpress/private-apis
var require_private_apis = __commonJS({
  "package-external:@wordpress/private-apis"(exports, module) {
    module.exports = window.wp.privateApis;
  }
});

// package-external:@wordpress/components
var require_components = __commonJS({
  "package-external:@wordpress/components"(exports, module) {
    module.exports = window.wp.components;
  }
});

// package-external:@wordpress/editor
var require_editor = __commonJS({
  "package-external:@wordpress/editor"(exports, module) {
    module.exports = window.wp.editor;
  }
});

// package-external:@wordpress/core-data
var require_core_data = __commonJS({
  "package-external:@wordpress/core-data"(exports, module) {
    module.exports = window.wp.coreData;
  }
});

// package-external:@wordpress/data
var require_data = __commonJS({
  "package-external:@wordpress/data"(exports, module) {
    module.exports = window.wp.data;
  }
});

// package-external:@wordpress/blocks
var require_blocks = __commonJS({
  "package-external:@wordpress/blocks"(exports, module) {
    module.exports = window.wp.blocks;
  }
});

// package-external:@wordpress/block-editor
var require_block_editor = __commonJS({
  "package-external:@wordpress/block-editor"(exports, module) {
    module.exports = window.wp.blockEditor;
  }
});

// package-external:@wordpress/style-engine
var require_style_engine = __commonJS({
  "package-external:@wordpress/style-engine"(exports, module) {
    module.exports = window.wp.styleEngine;
  }
});

// node_modules/fast-deep-equal/es6/index.js
var require_es6 = __commonJS({
  "node_modules/fast-deep-equal/es6/index.js"(exports, module) {
    "use strict";
    module.exports = function equal(a2, b2) {
      if (a2 === b2) return true;
      if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
        if (a2.constructor !== b2.constructor) return false;
        var length, i2, keys;
        if (Array.isArray(a2)) {
          length = a2.length;
          if (length != b2.length) return false;
          for (i2 = length; i2-- !== 0; )
            if (!equal(a2[i2], b2[i2])) return false;
          return true;
        }
        if (a2 instanceof Map && b2 instanceof Map) {
          if (a2.size !== b2.size) return false;
          for (i2 of a2.entries())
            if (!b2.has(i2[0])) return false;
          for (i2 of a2.entries())
            if (!equal(i2[1], b2.get(i2[0]))) return false;
          return true;
        }
        if (a2 instanceof Set && b2 instanceof Set) {
          if (a2.size !== b2.size) return false;
          for (i2 of a2.entries())
            if (!b2.has(i2[0])) return false;
          return true;
        }
        if (ArrayBuffer.isView(a2) && ArrayBuffer.isView(b2)) {
          length = a2.length;
          if (length != b2.length) return false;
          for (i2 = length; i2-- !== 0; )
            if (a2[i2] !== b2[i2]) return false;
          return true;
        }
        if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
        if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
        if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
        keys = Object.keys(a2);
        length = keys.length;
        if (length !== Object.keys(b2).length) return false;
        for (i2 = length; i2-- !== 0; )
          if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
        for (i2 = length; i2-- !== 0; ) {
          var key = keys[i2];
          if (!equal(a2[key], b2[key])) return false;
        }
        return true;
      }
      return a2 !== a2 && b2 !== b2;
    };
  }
});

// node_modules/deepmerge/dist/cjs.js
var require_cjs = __commonJS({
  "node_modules/deepmerge/dist/cjs.js"(exports, module) {
    "use strict";
    var isMergeableObject = function isMergeableObject2(value) {
      return isNonNullObject(value) && !isSpecial(value);
    };
    function isNonNullObject(value) {
      return !!value && typeof value === "object";
    }
    function isSpecial(value) {
      var stringValue = Object.prototype.toString.call(value);
      return stringValue === "[object RegExp]" || stringValue === "[object Date]" || isReactElement(value);
    }
    var canUseSymbol = typeof Symbol === "function" && Symbol.for;
    var REACT_ELEMENT_TYPE = canUseSymbol ? /* @__PURE__ */ Symbol.for("react.element") : 60103;
    function isReactElement(value) {
      return value.$$typeof === REACT_ELEMENT_TYPE;
    }
    function emptyTarget(val) {
      return Array.isArray(val) ? [] : {};
    }
    function cloneUnlessOtherwiseSpecified(value, options) {
      return options.clone !== false && options.isMergeableObject(value) ? deepmerge2(emptyTarget(value), value, options) : value;
    }
    function defaultArrayMerge(target, source, options) {
      return target.concat(source).map(function(element) {
        return cloneUnlessOtherwiseSpecified(element, options);
      });
    }
    function getMergeFunction(key, options) {
      if (!options.customMerge) {
        return deepmerge2;
      }
      var customMerge = options.customMerge(key);
      return typeof customMerge === "function" ? customMerge : deepmerge2;
    }
    function getEnumerableOwnPropertySymbols(target) {
      return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
        return Object.propertyIsEnumerable.call(target, symbol);
      }) : [];
    }
    function getKeys(target) {
      return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
    }
    function propertyIsOnObject(object, property) {
      try {
        return property in object;
      } catch (_) {
        return false;
      }
    }
    function propertyIsUnsafe(target, key) {
      return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
    }
    function mergeObject(target, source, options) {
      var destination = {};
      if (options.isMergeableObject(target)) {
        getKeys(target).forEach(function(key) {
          destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
        });
      }
      getKeys(source).forEach(function(key) {
        if (propertyIsUnsafe(target, key)) {
          return;
        }
        if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
          destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
        } else {
          destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
        }
      });
      return destination;
    }
    function deepmerge2(target, source, options) {
      options = options || {};
      options.arrayMerge = options.arrayMerge || defaultArrayMerge;
      options.isMergeableObject = options.isMergeableObject || isMergeableObject;
      options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
      var sourceIsArray = Array.isArray(source);
      var targetIsArray = Array.isArray(target);
      var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
      if (!sourceAndTargetTypesMatch) {
        return cloneUnlessOtherwiseSpecified(source, options);
      } else if (sourceIsArray) {
        return options.arrayMerge(target, source, options);
      } else {
        return mergeObject(target, source, options);
      }
    }
    deepmerge2.all = function deepmergeAll(array, options) {
      if (!Array.isArray(array)) {
        throw new Error("first argument should be an array");
      }
      return array.reduce(function(prev, next) {
        return deepmerge2(prev, next, options);
      }, {});
    };
    var deepmerge_1 = deepmerge2;
    module.exports = deepmerge_1;
  }
});

// package-external:@wordpress/keycodes
var require_keycodes = __commonJS({
  "package-external:@wordpress/keycodes"(exports, module) {
    module.exports = window.wp.keycodes;
  }
});

// package-external:@wordpress/api-fetch
var require_api_fetch = __commonJS({
  "package-external:@wordpress/api-fetch"(exports, module) {
    module.exports = window.wp.apiFetch;
  }
});

// package-external:@wordpress/date
var require_date = __commonJS({
  "package-external:@wordpress/date"(exports, module) {
    module.exports = window.wp.date;
  }
});

// node_modules/clsx/dist/clsx.mjs
function r(e2) {
  var t3, f2, n2 = "";
  if ("string" == typeof e2 || "number" == typeof e2) n2 += e2;
  else if ("object" == typeof e2) if (Array.isArray(e2)) {
    var o3 = e2.length;
    for (t3 = 0; t3 < o3; t3++) e2[t3] && (f2 = r(e2[t3])) && (n2 && (n2 += " "), n2 += f2);
  } else for (f2 in e2) e2[f2] && (n2 && (n2 += " "), n2 += f2);
  return n2;
}
function clsx() {
  for (var e2, t3, f2 = 0, n2 = "", o3 = arguments.length; f2 < o3; f2++) (e2 = arguments[f2]) && (t3 = r(e2)) && (n2 && (n2 += " "), n2 += t3);
  return n2;
}
var clsx_default = clsx;

// node_modules/@base-ui/utils/safeReact.mjs
var React2 = __toESM(require_react(), 1);
var SafeReact = {
  ...React2
};

// node_modules/@base-ui/utils/useRefWithInit.mjs
var React3 = __toESM(require_react(), 1);
var UNINITIALIZED = {};
function useRefWithInit(init, initArg) {
  const ref = React3.useRef(UNINITIALIZED);
  if (ref.current === UNINITIALIZED) {
    ref.current = init(initArg);
  }
  return ref;
}

// node_modules/@base-ui/utils/useStableCallback.mjs
var useInsertionEffect = SafeReact.useInsertionEffect;
var useSafeInsertionEffect = (
  // React 17 doesn't have useInsertionEffect.
  useInsertionEffect && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
  useInsertionEffect !== SafeReact.useLayoutEffect ? useInsertionEffect : (fn) => fn()
);
function useStableCallback(callback) {
  const stable = useRefWithInit(createStableCallback).current;
  stable.next = callback;
  useSafeInsertionEffect(stable.effect);
  return stable.trampoline;
}
function createStableCallback() {
  const stable = {
    next: void 0,
    callback: assertNotCalled,
    trampoline: (...args) => stable.callback?.(...args),
    effect: () => {
      stable.callback = stable.next;
    }
  };
  return stable;
}
function assertNotCalled() {
  if (true) {
    throw (
      /* minify-error-disabled */
      new Error("Base UI: Cannot call an event handler while rendering.")
    );
  }
}

// node_modules/@base-ui/utils/useIsoLayoutEffect.mjs
var React4 = __toESM(require_react(), 1);
var noop = () => {
};
var useIsoLayoutEffect = typeof document !== "undefined" ? React4.useLayoutEffect : noop;

// node_modules/@base-ui/utils/warn.mjs
var set;
if (true) {
  set = /* @__PURE__ */ new Set();
}
function warn(...messages) {
  if (true) {
    const messageKey = messages.join(" ");
    if (!set.has(messageKey)) {
      set.add(messageKey);
      console.warn(`Base UI: ${messageKey}`);
    }
  }
}

// node_modules/@base-ui/react/internals/direction-context/DirectionContext.mjs
var React5 = __toESM(require_react(), 1);
var DirectionContext = /* @__PURE__ */ React5.createContext(void 0);
if (true) DirectionContext.displayName = "DirectionContext";
function useDirection() {
  const context = React5.useContext(DirectionContext);
  return context?.direction ?? "ltr";
}

// node_modules/@base-ui/react/internals/useRenderElement.mjs
var React8 = __toESM(require_react(), 1);

// node_modules/@base-ui/utils/useMergedRefs.mjs
function useMergedRefs(a2, b2, c2, d2) {
  const forkRef = useRefWithInit(createForkRef).current;
  if (didChange(forkRef, a2, b2, c2, d2)) {
    update(forkRef, [a2, b2, c2, d2]);
  }
  return forkRef.callback;
}
function useMergedRefsN(refs) {
  const forkRef = useRefWithInit(createForkRef).current;
  if (didChangeN(forkRef, refs)) {
    update(forkRef, refs);
  }
  return forkRef.callback;
}
function createForkRef() {
  return {
    callback: null,
    cleanup: null,
    refs: []
  };
}
function didChange(forkRef, a2, b2, c2, d2) {
  return forkRef.refs[0] !== a2 || forkRef.refs[1] !== b2 || forkRef.refs[2] !== c2 || forkRef.refs[3] !== d2;
}
function didChangeN(forkRef, newRefs) {
  return forkRef.refs.length !== newRefs.length || forkRef.refs.some((ref, index2) => ref !== newRefs[index2]);
}
function update(forkRef, refs) {
  forkRef.refs = refs;
  if (refs.every((ref) => ref == null)) {
    forkRef.callback = null;
    return;
  }
  forkRef.callback = (instance) => {
    if (forkRef.cleanup) {
      forkRef.cleanup();
      forkRef.cleanup = null;
    }
    if (instance != null) {
      const cleanupCallbacks = Array(refs.length).fill(null);
      for (let i2 = 0; i2 < refs.length; i2 += 1) {
        const ref = refs[i2];
        if (ref == null) {
          continue;
        }
        switch (typeof ref) {
          case "function": {
            const refCleanup = ref(instance);
            if (typeof refCleanup === "function") {
              cleanupCallbacks[i2] = refCleanup;
            }
            break;
          }
          case "object": {
            ref.current = instance;
            break;
          }
          default:
        }
      }
      forkRef.cleanup = () => {
        for (let i2 = 0; i2 < refs.length; i2 += 1) {
          const ref = refs[i2];
          if (ref == null) {
            continue;
          }
          switch (typeof ref) {
            case "function": {
              const cleanupCallback = cleanupCallbacks[i2];
              if (typeof cleanupCallback === "function") {
                cleanupCallback();
              } else {
                ref(null);
              }
              break;
            }
            case "object": {
              ref.current = null;
              break;
            }
            default:
          }
        }
      };
    }
  };
}

// node_modules/@base-ui/utils/getReactElementRef.mjs
var React7 = __toESM(require_react(), 1);

// node_modules/@base-ui/utils/reactVersion.mjs
var React6 = __toESM(require_react(), 1);
var majorVersion = parseInt(React6.version, 10);
function isReactVersionAtLeast(reactVersionToCheck) {
  return majorVersion >= reactVersionToCheck;
}

// node_modules/@base-ui/utils/getReactElementRef.mjs
function getReactElementRef(element) {
  if (!/* @__PURE__ */ React7.isValidElement(element)) {
    return null;
  }
  const reactElement = element;
  const propsWithRef = reactElement.props;
  return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
}

// node_modules/@base-ui/utils/mergeObjects.mjs
function mergeObjects(a2, b2) {
  if (a2 && !b2) {
    return a2;
  }
  if (!a2 && b2) {
    return b2;
  }
  if (a2 || b2) {
    return {
      ...a2,
      ...b2
    };
  }
  return void 0;
}

// node_modules/@base-ui/utils/empty.mjs
function NOOP() {
}
var EMPTY_ARRAY = Object.freeze([]);
var EMPTY_OBJECT = Object.freeze({});

// node_modules/@base-ui/react/internals/getStateAttributesProps.mjs
function getStateAttributesProps(state, customMapping) {
  const props = {};
  for (const key in state) {
    const value = state[key];
    if (customMapping?.hasOwnProperty(key)) {
      const customProps = customMapping[key](value);
      if (customProps != null) {
        Object.assign(props, customProps);
      }
      continue;
    }
    if (value === true) {
      props[`data-${key.toLowerCase()}`] = "";
    } else if (value) {
      props[`data-${key.toLowerCase()}`] = value.toString();
    }
  }
  return props;
}

// node_modules/@base-ui/react/utils/resolveClassName.mjs
function resolveClassName(className, state) {
  return typeof className === "function" ? className(state) : className;
}

// node_modules/@base-ui/react/utils/resolveStyle.mjs
function resolveStyle(style, state) {
  return typeof style === "function" ? style(state) : style;
}

// node_modules/@base-ui/react/merge-props/mergeProps.mjs
var EMPTY_PROPS = {};
function mergeProps(a2, b2, c2, d2, e2) {
  if (!c2 && !d2 && !e2 && !a2) {
    return createInitialMergedProps(b2);
  }
  let merged = createInitialMergedProps(a2);
  if (b2) {
    merged = mergeInto(merged, b2);
  }
  if (c2) {
    merged = mergeInto(merged, c2);
  }
  if (d2) {
    merged = mergeInto(merged, d2);
  }
  if (e2) {
    merged = mergeInto(merged, e2);
  }
  return merged;
}
function mergePropsN(props) {
  if (props.length === 0) {
    return EMPTY_PROPS;
  }
  if (props.length === 1) {
    return createInitialMergedProps(props[0]);
  }
  let merged = createInitialMergedProps(props[0]);
  for (let i2 = 1; i2 < props.length; i2 += 1) {
    merged = mergeInto(merged, props[i2]);
  }
  return merged;
}
function createInitialMergedProps(inputProps) {
  if (isPropsGetter(inputProps)) {
    return {
      ...resolvePropsGetter(inputProps, EMPTY_PROPS)
    };
  }
  return copyInitialProps(inputProps);
}
function mergeInto(merged, inputProps) {
  if (isPropsGetter(inputProps)) {
    return resolvePropsGetter(inputProps, merged);
  }
  return mutablyMergeInto(merged, inputProps);
}
function copyInitialProps(inputProps) {
  const copiedProps = {
    ...inputProps
  };
  for (const propName in copiedProps) {
    const propValue = copiedProps[propName];
    if (isEventHandler(propName, propValue)) {
      copiedProps[propName] = wrapEventHandler(propValue);
    }
  }
  return copiedProps;
}
function mutablyMergeInto(mergedProps, externalProps) {
  if (!externalProps) {
    return mergedProps;
  }
  for (const propName in externalProps) {
    const externalPropValue = externalProps[propName];
    switch (propName) {
      case "style": {
        mergedProps[propName] = mergeObjects(mergedProps.style, externalPropValue);
        break;
      }
      case "className": {
        mergedProps[propName] = mergeClassNames(mergedProps.className, externalPropValue);
        break;
      }
      default: {
        if (isEventHandler(propName, externalPropValue)) {
          mergedProps[propName] = mergeEventHandlers(mergedProps[propName], externalPropValue);
        } else {
          mergedProps[propName] = externalPropValue;
        }
      }
    }
  }
  return mergedProps;
}
function isEventHandler(key, value) {
  const code0 = key.charCodeAt(0);
  const code1 = key.charCodeAt(1);
  const code2 = key.charCodeAt(2);
  return code0 === 111 && code1 === 110 && code2 >= 65 && code2 <= 90 && (typeof value === "function" || typeof value === "undefined");
}
function isPropsGetter(inputProps) {
  return typeof inputProps === "function";
}
function resolvePropsGetter(inputProps, previousProps) {
  if (isPropsGetter(inputProps)) {
    return inputProps(previousProps);
  }
  return inputProps ?? EMPTY_PROPS;
}
function mergeEventHandlers(ourHandler, theirHandler) {
  if (!theirHandler) {
    return ourHandler;
  }
  if (!ourHandler) {
    return wrapEventHandler(theirHandler);
  }
  return (...args) => {
    const event = args[0];
    if (isSyntheticEvent(event)) {
      const baseUIEvent = event;
      makeEventPreventable(baseUIEvent);
      const result2 = theirHandler(...args);
      if (!baseUIEvent.baseUIHandlerPrevented) {
        ourHandler?.(...args);
      }
      return result2;
    }
    const result = theirHandler(...args);
    ourHandler?.(...args);
    return result;
  };
}
function wrapEventHandler(handler) {
  if (!handler) {
    return handler;
  }
  return (...args) => {
    const event = args[0];
    if (isSyntheticEvent(event)) {
      makeEventPreventable(event);
    }
    return handler(...args);
  };
}
function makeEventPreventable(event) {
  event.preventBaseUIHandler = () => {
    event.baseUIHandlerPrevented = true;
  };
  return event;
}
function mergeClassNames(ourClassName, theirClassName) {
  if (theirClassName) {
    if (ourClassName) {
      return theirClassName + " " + ourClassName;
    }
    return theirClassName;
  }
  return ourClassName;
}
function isSyntheticEvent(event) {
  return event != null && typeof event === "object" && "nativeEvent" in event;
}

// node_modules/@base-ui/react/internals/useRenderElement.mjs
var import_react = __toESM(require_react(), 1);
function useRenderElement(element, componentProps, params = {}) {
  const renderProp = componentProps.render;
  const outProps = useRenderElementProps(componentProps, params);
  if (params.enabled === false) {
    return null;
  }
  const state = params.state ?? EMPTY_OBJECT;
  return evaluateRenderProp(element, renderProp, outProps, state);
}
function useRenderElementProps(componentProps, params = {}) {
  const {
    className: classNameProp,
    style: styleProp,
    render: renderProp
  } = componentProps;
  const {
    state = EMPTY_OBJECT,
    ref,
    props,
    stateAttributesMapping: stateAttributesMapping3,
    enabled = true
  } = params;
  const className = enabled ? resolveClassName(classNameProp, state) : void 0;
  const style = enabled ? resolveStyle(styleProp, state) : void 0;
  const stateProps = enabled ? getStateAttributesProps(state, stateAttributesMapping3) : EMPTY_OBJECT;
  const resolvedProps = enabled && props ? resolveRenderFunctionProps(props) : void 0;
  const outProps = enabled ? mergeObjects(stateProps, resolvedProps) ?? {} : EMPTY_OBJECT;
  if (typeof document !== "undefined") {
    if (!enabled) {
      useMergedRefs(null, null);
    } else if (Array.isArray(ref)) {
      outProps.ref = useMergedRefsN([outProps.ref, getReactElementRef(renderProp), ...ref]);
    } else {
      outProps.ref = useMergedRefs(outProps.ref, getReactElementRef(renderProp), ref);
    }
  }
  if (!enabled) {
    return EMPTY_OBJECT;
  }
  if (className !== void 0) {
    outProps.className = mergeClassNames(outProps.className, className);
  }
  if (style !== void 0) {
    outProps.style = mergeObjects(outProps.style, style);
  }
  return outProps;
}
function resolveRenderFunctionProps(props) {
  if (Array.isArray(props)) {
    return mergePropsN(props);
  }
  return mergeProps(void 0, props);
}
var REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy");
var COMPONENT_IDENTIFIER_PATTERN = /^[A-Z][A-Za-z0-9$]*$/;
var LOWERCASE_CHARACTER_PATTERN = /[a-z]/;
function evaluateRenderProp(element, render, props, state) {
  if (render) {
    if (typeof render === "function") {
      if (true) {
        warnIfRenderPropLooksLikeComponent(render);
      }
      return render(props, state);
    }
    const mergedProps = mergeProps(props, render.props);
    mergedProps.ref = props.ref;
    let newElement = render;
    if (newElement?.$$typeof === REACT_LAZY_TYPE) {
      const children = React8.Children.toArray(render);
      newElement = children[0];
    }
    if (true) {
      if (!/* @__PURE__ */ React8.isValidElement(newElement)) {
        throw new Error(["Base UI: The `render` prop was provided an invalid React element as `React.isValidElement(render)` is `false`.", "A valid React element must be provided to the `render` prop because it is cloned with props to replace the default element.", "https://base-ui.com/r/invalid-render-prop"].join("\n"));
      }
    }
    return /* @__PURE__ */ React8.cloneElement(newElement, mergedProps);
  }
  if (element) {
    if (typeof element === "string") {
      return renderTag(element, props);
    }
  }
  throw new Error(true ? "Base UI: Render element or function are not defined." : formatErrorMessage_default(8));
}
function warnIfRenderPropLooksLikeComponent(renderFn) {
  const functionName = renderFn.name;
  if (functionName.length === 0) {
    return;
  }
  if (!COMPONENT_IDENTIFIER_PATTERN.test(functionName)) {
    return;
  }
  if (!LOWERCASE_CHARACTER_PATTERN.test(functionName)) {
    return;
  }
  warn(`The \`render\` prop received a function named \`${functionName}\` that starts with an uppercase letter.`, "This usually means a React component was passed directly as `render={Component}`.", "Base UI calls `render` as a plain function, which can break the Rules of Hooks during reconciliation.", "If this is an intentional render callback, rename it to start with a lowercase letter.", "Use `render={<Component />}` or `render={(props) => <Component {...props} />}` instead.", "https://base-ui.com/r/invalid-render-prop");
}
function renderTag(Tag, props) {
  if (Tag === "button") {
    return /* @__PURE__ */ (0, import_react.createElement)("button", {
      type: "button",
      ...props,
      key: props.key
    });
  }
  if (Tag === "img") {
    return /* @__PURE__ */ (0, import_react.createElement)("img", {
      alt: "",
      ...props,
      key: props.key
    });
  }
  return /* @__PURE__ */ React8.createElement(Tag, props);
}

// node_modules/@base-ui/utils/useId.mjs
var React9 = __toESM(require_react(), 1);
var globalId = 0;
function useGlobalId(idOverride, prefix = "mui") {
  const [defaultId, setDefaultId] = React9.useState(idOverride);
  const id = idOverride || defaultId;
  React9.useEffect(() => {
    if (defaultId == null) {
      globalId += 1;
      setDefaultId(`${prefix}-${globalId}`);
    }
  }, [defaultId, prefix]);
  return id;
}
var maybeReactUseId = SafeReact.useId;
function useId(idOverride, prefix) {
  if (maybeReactUseId !== void 0) {
    const reactId = maybeReactUseId();
    return idOverride ?? (prefix ? `${prefix}-${reactId}` : reactId);
  }
  return useGlobalId(idOverride, prefix);
}

// node_modules/@base-ui/react/internals/useBaseUiId.mjs
function useBaseUiId(idOverride) {
  return useId(idOverride, "base-ui");
}

// node_modules/@base-ui/react/internals/reason-parts.mjs
var reason_parts_exports = {};
__export(reason_parts_exports, {
  cancelOpen: () => cancelOpen,
  chipRemovePress: () => chipRemovePress,
  clearPress: () => clearPress,
  closePress: () => closePress,
  closeWatcher: () => closeWatcher,
  decrementPress: () => decrementPress,
  disabled: () => disabled,
  drag: () => drag,
  escapeKey: () => escapeKey,
  focusOut: () => focusOut,
  imperativeAction: () => imperativeAction,
  incrementPress: () => incrementPress,
  initial: () => initial,
  inputBlur: () => inputBlur,
  inputChange: () => inputChange,
  inputClear: () => inputClear,
  inputPaste: () => inputPaste,
  inputPress: () => inputPress,
  itemPress: () => itemPress,
  keyboard: () => keyboard,
  linkPress: () => linkPress,
  listNavigation: () => listNavigation,
  missing: () => missing,
  none: () => none,
  outsidePress: () => outsidePress,
  pointer: () => pointer,
  scrub: () => scrub,
  siblingOpen: () => siblingOpen,
  swipe: () => swipe,
  trackPress: () => trackPress,
  triggerFocus: () => triggerFocus,
  triggerHover: () => triggerHover,
  triggerPress: () => triggerPress,
  wheel: () => wheel,
  windowResize: () => windowResize
});
var none = "none";
var triggerPress = "trigger-press";
var triggerHover = "trigger-hover";
var triggerFocus = "trigger-focus";
var outsidePress = "outside-press";
var itemPress = "item-press";
var closePress = "close-press";
var linkPress = "link-press";
var clearPress = "clear-press";
var chipRemovePress = "chip-remove-press";
var trackPress = "track-press";
var incrementPress = "increment-press";
var decrementPress = "decrement-press";
var inputChange = "input-change";
var inputClear = "input-clear";
var inputBlur = "input-blur";
var inputPaste = "input-paste";
var inputPress = "input-press";
var focusOut = "focus-out";
var escapeKey = "escape-key";
var closeWatcher = "close-watcher";
var listNavigation = "list-navigation";
var keyboard = "keyboard";
var pointer = "pointer";
var drag = "drag";
var wheel = "wheel";
var scrub = "scrub";
var cancelOpen = "cancel-open";
var siblingOpen = "sibling-open";
var disabled = "disabled";
var missing = "missing";
var initial = "initial";
var imperativeAction = "imperative-action";
var swipe = "swipe";
var windowResize = "window-resize";

// node_modules/@base-ui/react/internals/createBaseUIEventDetails.mjs
function createChangeEventDetails(reason, event, trigger, customProperties) {
  let canceled = false;
  let allowPropagation = false;
  const custom = customProperties ?? EMPTY_OBJECT;
  const details = {
    reason,
    event: event ?? new Event("base-ui"),
    cancel() {
      canceled = true;
    },
    allowPropagation() {
      allowPropagation = true;
    },
    get isCanceled() {
      return canceled;
    },
    get isPropagationAllowed() {
      return allowPropagation;
    },
    trigger,
    ...custom
  };
  return details;
}

// node_modules/@base-ui/react/internals/useTransitionStatus.mjs
var React11 = __toESM(require_react(), 1);

// node_modules/@base-ui/utils/useOnMount.mjs
var React10 = __toESM(require_react(), 1);
var EMPTY = [];
function useOnMount(fn) {
  React10.useEffect(fn, EMPTY);
}

// node_modules/@base-ui/utils/useAnimationFrame.mjs
var EMPTY2 = null;
var LAST_RAF = globalThis.requestAnimationFrame;
var Scheduler = class {
  /* This implementation uses an array as a backing data-structure for frame callbacks.
   * It allows `O(1)` callback cancelling by inserting a `null` in the array, though it
   * never calls the native `cancelAnimationFrame` if there are no frames left. This can
   * be much more efficient if there is a call pattern that alterns as
   * "request-cancel-request-cancel-…".
   * But in the case of "request-request-…-cancel-cancel-…", it leaves the final animation
   * frame to run anyway. We turn that frame into a `O(1)` no-op via `callbacksCount`. */
  callbacks = [];
  callbacksCount = 0;
  nextId = 1;
  startId = 1;
  isScheduled = false;
  tick = (timestamp) => {
    this.isScheduled = false;
    const currentCallbacks = this.callbacks;
    const currentCallbacksCount = this.callbacksCount;
    this.callbacks = [];
    this.callbacksCount = 0;
    this.startId = this.nextId;
    if (currentCallbacksCount > 0) {
      for (let i2 = 0; i2 < currentCallbacks.length; i2 += 1) {
        currentCallbacks[i2]?.(timestamp);
      }
    }
  };
  request(fn) {
    const id = this.nextId;
    this.nextId += 1;
    this.callbacks.push(fn);
    this.callbacksCount += 1;
    const didRAFChange = LAST_RAF !== requestAnimationFrame && (LAST_RAF = requestAnimationFrame, true);
    if (!this.isScheduled || didRAFChange) {
      requestAnimationFrame(this.tick);
      this.isScheduled = true;
    }
    return id;
  }
  cancel(id) {
    const index2 = id - this.startId;
    if (index2 < 0 || index2 >= this.callbacks.length) {
      return;
    }
    this.callbacks[index2] = null;
    this.callbacksCount -= 1;
  }
};
var scheduler = new Scheduler();
var AnimationFrame = class _AnimationFrame {
  static create() {
    return new _AnimationFrame();
  }
  static request(fn) {
    return scheduler.request(fn);
  }
  static cancel(id) {
    return scheduler.cancel(id);
  }
  currentId = EMPTY2;
  /**
   * Executes `fn` after `delay`, clearing any previously scheduled call.
   */
  request(fn) {
    this.cancel();
    this.currentId = scheduler.request(() => {
      this.currentId = EMPTY2;
      fn();
    });
  }
  cancel = () => {
    if (this.currentId !== EMPTY2) {
      scheduler.cancel(this.currentId);
      this.currentId = EMPTY2;
    }
  };
  disposeEffect = () => {
    return this.cancel;
  };
};
function useAnimationFrame() {
  const timeout = useRefWithInit(AnimationFrame.create).current;
  useOnMount(timeout.disposeEffect);
  return timeout;
}

// node_modules/@base-ui/react/internals/useTransitionStatus.mjs
function useTransitionStatus(open, enableIdleState = false, deferEndingState = false) {
  const [transitionStatus, setTransitionStatus] = React11.useState(open && enableIdleState ? "idle" : void 0);
  const [mounted, setMounted] = React11.useState(open);
  if (open && !mounted) {
    setMounted(true);
    setTransitionStatus("starting");
  }
  if (!open && mounted && transitionStatus !== "ending" && !deferEndingState) {
    setTransitionStatus("ending");
  }
  if (!open && !mounted && transitionStatus === "ending") {
    setTransitionStatus(void 0);
  }
  useIsoLayoutEffect(() => {
    if (!open && mounted && transitionStatus !== "ending" && deferEndingState) {
      const frame = AnimationFrame.request(() => {
        setTransitionStatus("ending");
      });
      return () => {
        AnimationFrame.cancel(frame);
      };
    }
    return void 0;
  }, [open, mounted, transitionStatus, deferEndingState]);
  useIsoLayoutEffect(() => {
    if (!open || enableIdleState) {
      return void 0;
    }
    const frame = AnimationFrame.request(() => {
      setTransitionStatus(void 0);
    });
    return () => {
      AnimationFrame.cancel(frame);
    };
  }, [enableIdleState, open]);
  useIsoLayoutEffect(() => {
    if (!open || !enableIdleState) {
      return void 0;
    }
    if (open && mounted && transitionStatus !== "idle") {
      setTransitionStatus("starting");
    }
    const frame = AnimationFrame.request(() => {
      setTransitionStatus("idle");
    });
    return () => {
      AnimationFrame.cancel(frame);
    };
  }, [enableIdleState, open, mounted, transitionStatus]);
  return {
    mounted,
    setMounted,
    transitionStatus
  };
}

// node_modules/@base-ui/react/internals/stateAttributesMapping.mjs
var TransitionStatusDataAttributes = /* @__PURE__ */ (function(TransitionStatusDataAttributes2) {
  TransitionStatusDataAttributes2["startingStyle"] = "data-starting-style";
  TransitionStatusDataAttributes2["endingStyle"] = "data-ending-style";
  return TransitionStatusDataAttributes2;
})({});
var STARTING_HOOK = {
  [TransitionStatusDataAttributes.startingStyle]: ""
};
var ENDING_HOOK = {
  [TransitionStatusDataAttributes.endingStyle]: ""
};
var transitionStatusMapping = {
  transitionStatus(value) {
    if (value === "starting") {
      return STARTING_HOOK;
    }
    if (value === "ending") {
      return ENDING_HOOK;
    }
    return null;
  }
};

// node_modules/@floating-ui/utils/dist/floating-ui.utils.dom.mjs
function hasWindow() {
  return typeof window !== "undefined";
}
function getNodeName(node) {
  if (isNode(node)) {
    return (node.nodeName || "").toLowerCase();
  }
  return "#document";
}
function getWindow(node) {
  var _node$ownerDocument;
  return (node == null || (_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.defaultView) || window;
}
function getDocumentElement(node) {
  var _ref;
  return (_ref = (isNode(node) ? node.ownerDocument : node.document) || window.document) == null ? void 0 : _ref.documentElement;
}
function isNode(value) {
  if (!hasWindow()) {
    return false;
  }
  return value instanceof Node || value instanceof getWindow(value).Node;
}
function isElement(value) {
  if (!hasWindow()) {
    return false;
  }
  return value instanceof Element || value instanceof getWindow(value).Element;
}
function isHTMLElement(value) {
  if (!hasWindow()) {
    return false;
  }
  return value instanceof HTMLElement || value instanceof getWindow(value).HTMLElement;
}
function isShadowRoot(value) {
  if (!hasWindow() || typeof ShadowRoot === "undefined") {
    return false;
  }
  return value instanceof ShadowRoot || value instanceof getWindow(value).ShadowRoot;
}
function isOverflowElement(element) {
  const {
    overflow,
    overflowX,
    overflowY,
    display
  } = getComputedStyle2(element);
  return /auto|scroll|overlay|hidden|clip/.test(overflow + overflowY + overflowX) && display !== "inline" && display !== "contents";
}
function isTableElement(element) {
  return /^(table|td|th)$/.test(getNodeName(element));
}
function isTopLayer(element) {
  try {
    if (element.matches(":popover-open")) {
      return true;
    }
  } catch (_e) {
  }
  try {
    return element.matches(":modal");
  } catch (_e) {
    return false;
  }
}
var willChangeRe = /transform|translate|scale|rotate|perspective|filter/;
var containRe = /paint|layout|strict|content/;
var isNotNone = (value) => !!value && value !== "none";
var isWebKitValue;
function isContainingBlock(elementOrCss) {
  const css = isElement(elementOrCss) ? getComputedStyle2(elementOrCss) : elementOrCss;
  return isNotNone(css.transform) || isNotNone(css.translate) || isNotNone(css.scale) || isNotNone(css.rotate) || isNotNone(css.perspective) || !isWebKit() && (isNotNone(css.backdropFilter) || isNotNone(css.filter)) || willChangeRe.test(css.willChange || "") || containRe.test(css.contain || "");
}
function getContainingBlock(element) {
  let currentNode = getParentNode(element);
  while (isHTMLElement(currentNode) && !isLastTraversableNode(currentNode)) {
    if (isContainingBlock(currentNode)) {
      return currentNode;
    } else if (isTopLayer(currentNode)) {
      return null;
    }
    currentNode = getParentNode(currentNode);
  }
  return null;
}
function isWebKit() {
  if (isWebKitValue == null) {
    isWebKitValue = typeof CSS !== "undefined" && CSS.supports && CSS.supports("-webkit-backdrop-filter", "none");
  }
  return isWebKitValue;
}
function isLastTraversableNode(node) {
  return /^(html|body|#document)$/.test(getNodeName(node));
}
function getComputedStyle2(element) {
  return getWindow(element).getComputedStyle(element);
}
function getNodeScroll(element) {
  if (isElement(element)) {
    return {
      scrollLeft: element.scrollLeft,
      scrollTop: element.scrollTop
    };
  }
  return {
    scrollLeft: element.scrollX,
    scrollTop: element.scrollY
  };
}
function getParentNode(node) {
  if (getNodeName(node) === "html") {
    return node;
  }
  const result = (
    // Step into the shadow DOM of the parent of a slotted node.
    node.assignedSlot || // DOM Element detected.
    node.parentNode || // ShadowRoot detected.
    isShadowRoot(node) && node.host || // Fallback.
    getDocumentElement(node)
  );
  return isShadowRoot(result) ? result.host : result;
}
function getNearestOverflowAncestor(node) {
  const parentNode = getParentNode(node);
  if (isLastTraversableNode(parentNode)) {
    return node.ownerDocument ? node.ownerDocument.body : node.body;
  }
  if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
    return parentNode;
  }
  return getNearestOverflowAncestor(parentNode);
}
function getOverflowAncestors(node, list, traverseIframes) {
  var _node$ownerDocument2;
  if (list === void 0) {
    list = [];
  }
  if (traverseIframes === void 0) {
    traverseIframes = true;
  }
  const scrollableAncestor = getNearestOverflowAncestor(node);
  const isBody = scrollableAncestor === ((_node$ownerDocument2 = node.ownerDocument) == null ? void 0 : _node$ownerDocument2.body);
  const win = getWindow(scrollableAncestor);
  if (isBody) {
    const frameElement = getFrameElement(win);
    return list.concat(win, win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : [], frameElement && traverseIframes ? getOverflowAncestors(frameElement) : []);
  } else {
    return list.concat(scrollableAncestor, getOverflowAncestors(scrollableAncestor, [], traverseIframes));
  }
}
function getFrameElement(win) {
  return win.parent && Object.getPrototypeOf(win.parent) ? win.frameElement : null;
}

// node_modules/@base-ui/utils/addEventListener.mjs
function addEventListener(target, type, listener, options) {
  target.addEventListener(type, listener, options);
  return () => {
    target.removeEventListener(type, listener, options);
  };
}

// node_modules/@base-ui/utils/useValueAsRef.mjs
function useValueAsRef(value) {
  const latest = useRefWithInit(createLatestRef, value).current;
  latest.next = value;
  useIsoLayoutEffect(latest.effect);
  return latest;
}
function createLatestRef(value) {
  const latest = {
    current: value,
    next: value,
    effect: () => {
      latest.current = latest.next;
    }
  };
  return latest;
}

// node_modules/@base-ui/utils/owner.mjs
function ownerDocument(node) {
  return node?.ownerDocument || document;
}

// node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
var React12 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
var ReactDOM = __toESM(require_react_dom(), 1);

// node_modules/@base-ui/react/utils/resolveRef.mjs
function resolveRef(maybeRef) {
  if (maybeRef == null) {
    return maybeRef;
  }
  return "current" in maybeRef ? maybeRef.current : maybeRef;
}

// node_modules/@base-ui/react/internals/useAnimationsFinished.mjs
function useAnimationsFinished(elementOrRef, waitForStartingStyleRemoved = false, treatAbortedAsFinished = true) {
  const frame = useAnimationFrame();
  return useStableCallback((fnToExecute, signal = null) => {
    frame.cancel();
    const element = resolveRef(elementOrRef);
    if (element == null) {
      return;
    }
    const resolvedElement = element;
    const done = () => {
      ReactDOM.flushSync(fnToExecute);
    };
    if (typeof resolvedElement.getAnimations !== "function" || globalThis.BASE_UI_ANIMATIONS_DISABLED) {
      fnToExecute();
      return;
    }
    function exec() {
      Promise.all(resolvedElement.getAnimations().map((animation) => animation.finished)).then(() => {
        if (!signal?.aborted) {
          done();
        }
      }).catch(() => {
        if (treatAbortedAsFinished) {
          if (!signal?.aborted) {
            done();
          }
          return;
        }
        const currentAnimations = resolvedElement.getAnimations();
        if (!signal?.aborted && currentAnimations.length > 0 && currentAnimations.some((animation) => animation.pending || animation.playState !== "finished")) {
          exec();
        }
      });
    }
    if (waitForStartingStyleRemoved) {
      const startingStyleAttribute = TransitionStatusDataAttributes.startingStyle;
      if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
        frame.request(exec);
        return;
      }
      const attributeObserver = new MutationObserver(() => {
        if (!resolvedElement.hasAttribute(startingStyleAttribute)) {
          attributeObserver.disconnect();
          exec();
        }
      });
      attributeObserver.observe(resolvedElement, {
        attributes: true,
        attributeFilter: [startingStyleAttribute]
      });
      signal?.addEventListener("abort", () => attributeObserver.disconnect(), {
        once: true
      });
      return;
    }
    frame.request(exec);
  });
}

// node_modules/@base-ui/react/internals/useOpenChangeComplete.mjs
function useOpenChangeComplete(parameters) {
  const {
    enabled = true,
    open,
    ref,
    onComplete: onCompleteParam
  } = parameters;
  const onComplete = useStableCallback(onCompleteParam);
  const runOnceAnimationsFinish = useAnimationsFinished(ref, open, false);
  React12.useEffect(() => {
    if (!enabled) {
      return void 0;
    }
    const abortController = new AbortController();
    runOnceAnimationsFinish(onComplete, abortController.signal);
    return () => {
      abortController.abort();
    };
  }, [enabled, open, onComplete, runOnceAnimationsFinish]);
}

// node_modules/@base-ui/utils/useOnFirstRender.mjs
var React13 = __toESM(require_react(), 1);
function useOnFirstRender(fn) {
  const ref = React13.useRef(true);
  if (ref.current) {
    ref.current = false;
    fn();
  }
}

// node_modules/@base-ui/utils/platform/parts.mjs
var parts_exports = {};
__export(parts_exports, {
  engine: () => engine_exports,
  env: () => env_exports,
  os: () => os_exports,
  screenReader: () => screen_reader_exports
});

// node_modules/@base-ui/utils/platform/os.mjs
var os_exports = {};
__export(os_exports, {
  android: () => android,
  apple: () => apple,
  ios: () => ios,
  linux: () => linux,
  mac: () => mac,
  windows: () => windows
});

// node_modules/@base-ui/utils/platform/shared.mjs
function readRawData() {
  if (typeof navigator === "undefined") {
    return {
      userAgent: "",
      platform: "",
      maxTouchPoints: 0
    };
  }
  if (true) {
    const uaData = navigator.userAgentData;
    if (uaData && Array.isArray(uaData.brands)) {
      return {
        userAgent: uaData.brands.map(({
          brand,
          version: version2
        }) => `${brand}/${version2}`).join(" "),
        platform: uaData.platform ?? navigator.platform ?? "",
        maxTouchPoints: navigator.maxTouchPoints ?? 0
      };
    }
  }
  return {
    userAgent: navigator.userAgent,
    platform: navigator.platform ?? "",
    maxTouchPoints: navigator.maxTouchPoints ?? 0
  };
}
var {
  userAgent,
  platform,
  maxTouchPoints
} = readRawData();
var lowerUserAgent = userAgent.toLowerCase();
var lowerPlatform = platform.toLowerCase();

// node_modules/@base-ui/utils/platform/os.mjs
var ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === "macintel" && maxTouchPoints > 1;
var ANDROID_STRING = "android";
var android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
var mac = !ios && lowerPlatform.startsWith("mac");
var windows = lowerPlatform.startsWith("win");
var linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
var apple = mac || ios;

// node_modules/@base-ui/utils/platform/engine.mjs
var engine_exports = {};
__export(engine_exports, {
  blink: () => blink,
  gecko: () => gecko,
  webkit: () => webkit
});
var webkit = typeof CSS !== "undefined" && !!CSS.supports?.("-webkit-backdrop-filter:none");
var gecko = !webkit && lowerUserAgent.includes("firefox");
var blink = !webkit && lowerUserAgent.includes("chrom");

// node_modules/@base-ui/utils/platform/screen-reader.mjs
var screen_reader_exports = {};
__export(screen_reader_exports, {
  voiceOver: () => voiceOver
});
var voiceOver = apple;

// node_modules/@base-ui/utils/platform/env.mjs
var env_exports = {};
__export(env_exports, {
  jsdom: () => jsdom
});
var jsdom = /jsdom|happydom/.test(lowerUserAgent);

// node_modules/@base-ui/utils/useTimeout.mjs
var EMPTY3 = 0;
var Timeout = class _Timeout {
  static create() {
    return new _Timeout();
  }
  currentId = EMPTY3;
  /**
   * Executes `fn` after `delay`, clearing any previously scheduled call.
   */
  start(delay, fn) {
    this.clear();
    this.currentId = setTimeout(() => {
      this.currentId = EMPTY3;
      fn();
    }, delay);
  }
  isStarted() {
    return this.currentId !== EMPTY3;
  }
  clear = () => {
    if (this.currentId !== EMPTY3) {
      clearTimeout(this.currentId);
      this.currentId = EMPTY3;
    }
  };
  disposeEffect = () => {
    return this.clear;
  };
};
function useTimeout() {
  const timeout = useRefWithInit(Timeout.create).current;
  useOnMount(timeout.disposeEffect);
  return timeout;
}

// node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
var React14 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/floating-ui-react/utils/event.mjs
function isReactEvent(event) {
  return "nativeEvent" in event;
}
function isMouseLikePointerType(pointerType, strict) {
  const values = ["mouse", "pen"];
  if (!strict) {
    values.push("", void 0);
  }
  return values.includes(pointerType);
}
function isClickLikeEvent(event) {
  const type = event.type;
  return type === "click" || type === "mousedown" || type === "keydown" || type === "keyup";
}

// node_modules/@base-ui/react/floating-ui-react/utils/constants.mjs
var FOCUSABLE_ATTRIBUTE = "data-base-ui-focusable";
var TYPEABLE_SELECTOR = "input:not([type='hidden']):not([disabled]),[contenteditable]:not([contenteditable='false']),textarea:not([disabled])";

// node_modules/@base-ui/react/internals/shadowDom.mjs
function activeElement(doc) {
  let element = doc.activeElement;
  while (element?.shadowRoot?.activeElement != null) {
    element = element.shadowRoot.activeElement;
  }
  return element;
}
function contains(parent, child) {
  if (!parent || !child) {
    return false;
  }
  const rootNode = child.getRootNode?.();
  if (parent.contains(child)) {
    return true;
  }
  if (rootNode && isShadowRoot(rootNode)) {
    let next = child;
    while (next) {
      if (parent === next) {
        return true;
      }
      next = next.parentNode || next.host;
    }
  }
  return false;
}
function getTarget(event) {
  if ("composedPath" in event) {
    return event.composedPath()[0];
  }
  return event.target;
}

// node_modules/@base-ui/react/floating-ui-react/utils/element.mjs
function isTargetInsideEnabledTrigger(target, triggerElements) {
  if (!isElement(target)) {
    return false;
  }
  const targetElement = target;
  if (triggerElements.hasElement(targetElement)) {
    return !targetElement.hasAttribute("data-trigger-disabled");
  }
  for (const [, trigger] of triggerElements.entries()) {
    if (contains(trigger, targetElement)) {
      return !trigger.hasAttribute("data-trigger-disabled");
    }
  }
  return false;
}
function isEventTargetWithin(event, node) {
  if (node == null) {
    return false;
  }
  if ("composedPath" in event) {
    return event.composedPath().includes(node);
  }
  const eventAgain = event;
  return eventAgain.target != null && node.contains(eventAgain.target);
}
function isRootElement(element) {
  return element.matches("html,body");
}
function isTypeableElement(element) {
  return isHTMLElement(element) && element.matches(TYPEABLE_SELECTOR);
}
function isInteractiveElement(element) {
  return element?.closest(`button,a[href],[role="button"],select,[tabindex]:not([tabindex="-1"]),${TYPEABLE_SELECTOR}`) != null;
}
function matchesFocusVisible(element) {
  if (!element || parts_exports.env.jsdom) {
    return true;
  }
  try {
    return element.matches(":focus-visible");
  } catch (_e) {
    return true;
  }
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverShared.mjs
function resolveValue(value, pointerType) {
  if (pointerType != null && !isMouseLikePointerType(pointerType)) {
    return 0;
  }
  if (typeof value === "function") {
    return value();
  }
  return value;
}
function getDelay(value, prop, pointerType) {
  const result = resolveValue(value, pointerType);
  if (typeof result === "number") {
    return result;
  }
  return result?.[prop];
}
function getRestMs(value) {
  if (typeof value === "function") {
    return value();
  }
  return value;
}
function isClickLikeOpenEvent(openEventType, interactedInside) {
  return interactedInside || openEventType === "click" || openEventType === "mousedown";
}
function isHoverOpenEvent(openEventType) {
  return openEventType?.includes("mouse") && openEventType !== "mousedown";
}

// node_modules/@base-ui/react/floating-ui-react/components/FloatingDelayGroup.mjs
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
var FloatingDelayGroupContext = /* @__PURE__ */ React14.createContext({
  hasProvider: false,
  timeoutMs: 0,
  delayRef: {
    current: 0
  },
  initialDelayRef: {
    current: 0
  },
  timeout: new Timeout(),
  currentIdRef: {
    current: null
  },
  currentContextRef: {
    current: null
  }
});
if (true) FloatingDelayGroupContext.displayName = "FloatingDelayGroupContext";
function resetDelayRef(delayRef, initialDelayRef) {
  delayRef.current = initialDelayRef.current;
}
function FloatingDelayGroup(props) {
  const {
    children,
    delay,
    timeoutMs = 0
  } = props;
  const delayRef = React14.useRef(delay);
  const initialDelayRef = React14.useRef(delay);
  const currentIdRef = React14.useRef(null);
  const currentContextRef = React14.useRef(null);
  const timeout = useTimeout();
  useIsoLayoutEffect(() => {
    initialDelayRef.current = delay;
    if (!currentIdRef.current) {
      delayRef.current = delay;
      return;
    }
    delayRef.current = {
      open: getDelay(delayRef.current, "open"),
      close: getDelay(delay, "close")
    };
  }, [delay, currentIdRef, delayRef, initialDelayRef]);
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FloatingDelayGroupContext.Provider, {
    value: React14.useMemo(() => ({
      hasProvider: true,
      delayRef,
      initialDelayRef,
      currentIdRef,
      timeoutMs,
      currentContextRef,
      timeout
    }), [timeoutMs, timeout]),
    children
  });
}
function useDelayGroup(context, options = {
  open: false
}) {
  const {
    open
  } = options;
  const store = "rootStore" in context ? context.rootStore : context;
  const floatingId = store.useState("floatingId");
  const groupContext = React14.useContext(FloatingDelayGroupContext);
  const {
    currentIdRef,
    delayRef,
    timeoutMs,
    initialDelayRef,
    currentContextRef,
    hasProvider,
    timeout
  } = groupContext;
  const [isInstantPhase, setIsInstantPhase] = React14.useState(false);
  const openRef = React14.useRef(open);
  const isUnmountedRef = React14.useRef(false);
  useIsoLayoutEffect(() => {
    openRef.current = open;
  }, [open]);
  useIsoLayoutEffect(() => {
    return () => {
      isUnmountedRef.current = true;
    };
  }, []);
  useIsoLayoutEffect(() => {
    function unset() {
      if (!isUnmountedRef.current) {
        setIsInstantPhase(false);
      }
      currentContextRef.current?.setIsInstantPhase(false);
      currentIdRef.current = null;
      currentContextRef.current = null;
      delayRef.current = initialDelayRef.current;
      timeout.clear();
    }
    if (!currentIdRef.current) {
      return void 0;
    }
    if (!open && currentIdRef.current === floatingId) {
      setIsInstantPhase(false);
      if (timeoutMs) {
        const closingId = floatingId;
        timeout.start(timeoutMs, () => {
          if (store.select("open") || currentIdRef.current && currentIdRef.current !== closingId) {
            return;
          }
          unset();
        });
        return () => {
          if (openRef.current || currentIdRef.current !== closingId) {
            timeout.clear();
          }
        };
      }
      unset();
    }
    return void 0;
  }, [open, floatingId, currentIdRef, delayRef, timeoutMs, initialDelayRef, currentContextRef, timeout, store]);
  useIsoLayoutEffect(() => {
    if (!open) {
      return;
    }
    const prevContext = currentContextRef.current;
    const prevId = currentIdRef.current;
    timeout.clear();
    currentContextRef.current = {
      onOpenChange: store.setOpen,
      setIsInstantPhase
    };
    currentIdRef.current = floatingId;
    delayRef.current = {
      open: 0,
      close: getDelay(initialDelayRef.current, "close")
    };
    if (prevId !== null && prevId !== floatingId) {
      setIsInstantPhase(true);
      prevContext?.setIsInstantPhase(true);
      prevContext?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.none));
    } else {
      setIsInstantPhase(false);
      prevContext?.setIsInstantPhase(false);
    }
  }, [open, floatingId, store, currentIdRef, delayRef, initialDelayRef, currentContextRef, timeout]);
  useIsoLayoutEffect(() => {
    return () => {
      if (currentIdRef.current === floatingId) {
        currentContextRef.current = null;
        if (!openRef.current) {
          return;
        }
        currentIdRef.current = null;
        resetDelayRef(delayRef, initialDelayRef);
        timeout.clear();
      }
    };
  }, [currentContextRef, currentIdRef, delayRef, floatingId, initialDelayRef, timeout]);
  return React14.useMemo(() => ({
    hasProvider,
    delayRef,
    isInstantPhase
  }), [hasProvider, delayRef, isInstantPhase]);
}

// node_modules/@base-ui/utils/mergeCleanups.mjs
function mergeCleanups(...cleanups) {
  return () => {
    for (let i2 = 0; i2 < cleanups.length; i2 += 1) {
      const cleanup = cleanups[i2];
      if (cleanup) {
        cleanup();
      }
    }
  };
}

// node_modules/@base-ui/react/utils/FocusGuard.mjs
var React15 = __toESM(require_react(), 1);

// node_modules/@base-ui/utils/visuallyHidden.mjs
var visuallyHiddenBase = {
  clipPath: "inset(50%)",
  overflow: "hidden",
  whiteSpace: "nowrap",
  border: 0,
  padding: 0,
  width: 1,
  height: 1,
  margin: -1
};
var visuallyHidden = {
  ...visuallyHiddenBase,
  position: "fixed",
  top: 0,
  left: 0
};
var visuallyHiddenInput = {
  ...visuallyHiddenBase,
  position: "absolute"
};

// node_modules/@base-ui/react/utils/FocusGuard.mjs
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
var FocusGuard = /* @__PURE__ */ React15.forwardRef(function FocusGuard2(props, ref) {
  const [role, setRole] = React15.useState();
  useIsoLayoutEffect(() => {
    if (parts_exports.screenReader.voiceOver && parts_exports.engine.webkit) {
      setRole("button");
    }
  }, []);
  const restProps = {
    tabIndex: 0,
    // Role is only for VoiceOver
    role
  };
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", {
    ...props,
    ref,
    style: visuallyHidden,
    "aria-hidden": role ? void 0 : true,
    ...restProps,
    "data-base-ui-focus-guard": ""
  });
});
if (true) FocusGuard.displayName = "FocusGuard";

// node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
var sides = ["top", "right", "bottom", "left"];
var min = Math.min;
var max = Math.max;
var round = Math.round;
var floor = Math.floor;
var createCoords = (v2) => ({
  x: v2,
  y: v2
});
var oppositeSideMap = {
  left: "right",
  right: "left",
  bottom: "top",
  top: "bottom"
};
function clamp(start, value, end) {
  return max(start, min(value, end));
}
function evaluate(value, param) {
  return typeof value === "function" ? value(param) : value;
}
function getSide(placement) {
  return placement.split("-")[0];
}
function getAlignment(placement) {
  return placement.split("-")[1];
}
function getOppositeAxis(axis) {
  return axis === "x" ? "y" : "x";
}
function getAxisLength(axis) {
  return axis === "y" ? "height" : "width";
}
function getSideAxis(placement) {
  const firstChar = placement[0];
  return firstChar === "t" || firstChar === "b" ? "y" : "x";
}
function getAlignmentAxis(placement) {
  return getOppositeAxis(getSideAxis(placement));
}
function getAlignmentSides(placement, rects, rtl) {
  if (rtl === void 0) {
    rtl = false;
  }
  const alignment = getAlignment(placement);
  const alignmentAxis = getAlignmentAxis(placement);
  const length = getAxisLength(alignmentAxis);
  let mainAlignmentSide = alignmentAxis === "x" ? alignment === (rtl ? "end" : "start") ? "right" : "left" : alignment === "start" ? "bottom" : "top";
  if (rects.reference[length] > rects.floating[length]) {
    mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
  }
  return [mainAlignmentSide, getOppositePlacement(mainAlignmentSide)];
}
function getExpandedPlacements(placement) {
  const oppositePlacement = getOppositePlacement(placement);
  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
}
function getOppositeAlignmentPlacement(placement) {
  return placement.includes("start") ? placement.replace("start", "end") : placement.replace("end", "start");
}
var lrPlacement = ["left", "right"];
var rlPlacement = ["right", "left"];
var tbPlacement = ["top", "bottom"];
var btPlacement = ["bottom", "top"];
function getSideList(side, isStart, rtl) {
  switch (side) {
    case "top":
    case "bottom":
      if (rtl) return isStart ? rlPlacement : lrPlacement;
      return isStart ? lrPlacement : rlPlacement;
    case "left":
    case "right":
      return isStart ? tbPlacement : btPlacement;
    default:
      return [];
  }
}
function getOppositeAxisPlacements(placement, flipAlignment, direction, rtl) {
  const alignment = getAlignment(placement);
  let list = getSideList(getSide(placement), direction === "start", rtl);
  if (alignment) {
    list = list.map((side) => side + "-" + alignment);
    if (flipAlignment) {
      list = list.concat(list.map(getOppositeAlignmentPlacement));
    }
  }
  return list;
}
function getOppositePlacement(placement) {
  const side = getSide(placement);
  return oppositeSideMap[side] + placement.slice(side.length);
}
function expandPaddingObject(padding) {
  return {
    top: 0,
    right: 0,
    bottom: 0,
    left: 0,
    ...padding
  };
}
function getPaddingObject(padding) {
  return typeof padding !== "number" ? expandPaddingObject(padding) : {
    top: padding,
    right: padding,
    bottom: padding,
    left: padding
  };
}
function rectToClientRect(rect) {
  const {
    x: x2,
    y: y2,
    width,
    height
  } = rect;
  return {
    width,
    height,
    top: y2,
    left: x2,
    right: x2 + width,
    bottom: y2 + height,
    x: x2,
    y: y2
  };
}

// node_modules/@base-ui/react/floating-ui-react/utils/composite.mjs
function isHiddenByStyles(styles) {
  return styles.visibility === "hidden" || styles.visibility === "collapse";
}
function isElementVisible(element, styles = element ? getComputedStyle2(element) : null) {
  if (!element || !element.isConnected || !styles || isHiddenByStyles(styles)) {
    return false;
  }
  if (typeof element.checkVisibility === "function") {
    return element.checkVisibility();
  }
  return styles.display !== "none" && styles.display !== "contents";
}

// node_modules/@base-ui/react/floating-ui-react/utils/tabbable.mjs
var CANDIDATE_SELECTOR = 'a[href],button,input,select,textarea,summary,details,iframe,object,embed,[tabindex],[contenteditable]:not([contenteditable="false"]),audio[controls],video[controls]';
function getParentElement(element) {
  const assignedSlot = element.assignedSlot;
  if (assignedSlot) {
    return assignedSlot;
  }
  if (element.parentElement) {
    return element.parentElement;
  }
  const rootNode = element.getRootNode();
  return isShadowRoot(rootNode) ? rootNode.host : null;
}
function getDetailsSummary(details) {
  for (const child of Array.from(details.children)) {
    if (getNodeName(child) === "summary") {
      return child;
    }
  }
  return null;
}
function isWithinOpenDetailsSummary(element, details) {
  const summary = getDetailsSummary(details);
  return !!summary && (element === summary || contains(summary, element));
}
function isFocusableCandidate(element) {
  const nodeName = element ? getNodeName(element) : "";
  return element != null && element.matches(CANDIDATE_SELECTOR) && (nodeName !== "summary" || element.parentElement != null && getNodeName(element.parentElement) === "details" && getDetailsSummary(element.parentElement) === element) && (nodeName !== "details" || getDetailsSummary(element) == null) && (nodeName !== "input" || element.type !== "hidden");
}
function isFocusableElement(element) {
  if (!isFocusableCandidate(element) || !element.isConnected || element.matches(":disabled")) {
    return false;
  }
  for (let current = element; current; current = getParentElement(current)) {
    const isAncestor = current !== element;
    const isSlot = getNodeName(current) === "slot";
    if (current.hasAttribute("inert")) {
      return false;
    }
    if (isAncestor && getNodeName(current) === "details" && !current.open && !isWithinOpenDetailsSummary(element, current) || current.hasAttribute("hidden") || !isSlot && !isVisibleInTabbableTree(current, isAncestor)) {
      return false;
    }
  }
  return true;
}
function isVisibleInTabbableTree(element, isAncestor) {
  const styles = getComputedStyle2(element);
  if (!isAncestor) {
    return isElementVisible(element, styles);
  }
  return styles.display !== "none";
}
function getTabIndex(element) {
  const tabIndex = element.tabIndex;
  if (tabIndex < 0) {
    const nodeName = getNodeName(element);
    if (nodeName === "details" || nodeName === "audio" || nodeName === "video" || isHTMLElement(element) && element.isContentEditable) {
      return 0;
    }
  }
  return tabIndex;
}
function getNamedRadioInput(element) {
  if (getNodeName(element) !== "input") {
    return null;
  }
  const input = element;
  return input.type === "radio" && input.name !== "" ? input : null;
}
function isTabbableRadio(element, candidates) {
  const input = getNamedRadioInput(element);
  if (!input) {
    return true;
  }
  const checkedRadio = candidates.find((candidate) => {
    const radio = getNamedRadioInput(candidate);
    return radio?.name === input.name && radio.form === input.form && radio.checked;
  });
  if (checkedRadio) {
    return checkedRadio === input;
  }
  return candidates.find((candidate) => {
    const radio = getNamedRadioInput(candidate);
    return radio?.name === input.name && radio.form === input.form;
  }) === input;
}
function getComposedChildren(container) {
  if (isHTMLElement(container) && getNodeName(container) === "slot") {
    const assignedElements = container.assignedElements({
      flatten: true
    });
    if (assignedElements.length > 0) {
      return assignedElements;
    }
  }
  if (isHTMLElement(container) && container.shadowRoot) {
    return Array.from(container.shadowRoot.children);
  }
  return Array.from(container.children);
}
function appendCandidates(container, list) {
  getComposedChildren(container).forEach((child) => {
    if (isFocusableCandidate(child)) {
      list.push(child);
    }
    appendCandidates(child, list);
  });
}
function appendMatchingElements(container, selector, list) {
  getComposedChildren(container).forEach((child) => {
    if (isHTMLElement(child) && child.matches(selector)) {
      list.push(child);
    }
    appendMatchingElements(child, selector, list);
  });
}
function focusable(container) {
  const candidates = [];
  appendCandidates(container, candidates);
  return candidates.filter(isFocusableElement);
}
function tabbable(container) {
  const candidates = focusable(container);
  return candidates.filter((element) => getTabIndex(element) >= 0 && isTabbableRadio(element, candidates));
}
function getTabbableIn(container, dir) {
  const list = tabbable(container);
  const len = list.length;
  if (len === 0) {
    return void 0;
  }
  const active = activeElement(ownerDocument(container));
  const index2 = list.indexOf(active);
  const nextIndex = index2 === -1 ? dir === 1 ? 0 : len - 1 : index2 + dir;
  return list[nextIndex];
}
function getNextTabbable(referenceElement) {
  return getTabbableIn(ownerDocument(referenceElement).body, 1) || referenceElement;
}
function getPreviousTabbable(referenceElement) {
  return getTabbableIn(ownerDocument(referenceElement).body, -1) || referenceElement;
}
function isOutsideEvent(event, container) {
  const containerElement = container || event.currentTarget;
  const relatedTarget = event.relatedTarget;
  return !relatedTarget || !contains(containerElement, relatedTarget);
}
function disableFocusInside(container) {
  const tabbableElements = tabbable(container);
  tabbableElements.forEach((element) => {
    element.dataset.tabindex = element.getAttribute("tabindex") || "";
    element.setAttribute("tabindex", "-1");
  });
}
function enableFocusInside(container) {
  const elements2 = [];
  appendMatchingElements(container, "[data-tabindex]", elements2);
  elements2.forEach((element) => {
    const tabindex = element.dataset.tabindex;
    delete element.dataset.tabindex;
    if (tabindex) {
      element.setAttribute("tabindex", tabindex);
    } else {
      element.removeAttribute("tabindex");
    }
  });
}

// node_modules/@base-ui/react/floating-ui-react/utils/nodes.mjs
function getNodeChildren(nodes, id, onlyOpenChildren = true) {
  const directChildren = nodes.filter((node) => node.parentId === id);
  return directChildren.flatMap((child) => [...!onlyOpenChildren || child.context?.open ? [child] : [], ...getNodeChildren(nodes, child.id, onlyOpenChildren)]);
}

// node_modules/@base-ui/react/floating-ui-react/utils/createAttribute.mjs
function createAttribute(name2) {
  return `data-base-ui-${name2}`;
}

// node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
var React16 = __toESM(require_react(), 1);
var ReactDOM2 = __toESM(require_react_dom(), 1);

// node_modules/@base-ui/react/internals/constants.mjs
var DISABLED_TRANSITIONS_STYLE = {
  style: {
    transition: "none"
  }
};
var BASE_UI_SWIPE_IGNORE_ATTRIBUTE = "data-base-ui-swipe-ignore";
var LEGACY_SWIPE_IGNORE_ATTRIBUTE = "data-swipe-ignore";
var BASE_UI_SWIPE_IGNORE_SELECTOR = `[${BASE_UI_SWIPE_IGNORE_ATTRIBUTE}]`;
var LEGACY_SWIPE_IGNORE_SELECTOR = `[${LEGACY_SWIPE_IGNORE_ATTRIBUTE}]`;
var POPUP_COLLISION_AVOIDANCE = {
  fallbackAxisSide: "end"
};
var ownerVisuallyHidden = {
  clipPath: "inset(50%)",
  position: "fixed",
  top: 0,
  left: 0
};

// node_modules/@base-ui/react/floating-ui-react/components/FloatingPortal.mjs
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
var PortalContext = /* @__PURE__ */ React16.createContext(null);
if (true) PortalContext.displayName = "PortalContext";
var usePortalContext = () => React16.useContext(PortalContext);
var attr = createAttribute("portal");
function useFloatingPortalNode(props = {}) {
  const {
    ref,
    container: containerProp,
    componentProps = EMPTY_OBJECT,
    elementProps
  } = props;
  const uniqueId = useId();
  const portalContext = usePortalContext();
  const parentPortalNode = portalContext?.portalNode;
  const [containerElement, setContainerElement] = React16.useState(null);
  const [portalNode, setPortalNode] = React16.useState(null);
  const setPortalNodeRef = useStableCallback((node) => {
    if (node !== null) {
      setPortalNode(node);
    }
  });
  const containerRef = React16.useRef(null);
  useIsoLayoutEffect(() => {
    if (containerProp === null) {
      if (containerRef.current) {
        containerRef.current = null;
        setPortalNode(null);
        setContainerElement(null);
      }
      return;
    }
    if (uniqueId == null) {
      return;
    }
    const resolvedContainer = (containerProp && (isNode(containerProp) ? containerProp : containerProp.current)) ?? parentPortalNode ?? document.body;
    if (resolvedContainer == null) {
      if (containerRef.current) {
        containerRef.current = null;
        setPortalNode(null);
        setContainerElement(null);
      }
      return;
    }
    if (containerRef.current !== resolvedContainer) {
      containerRef.current = resolvedContainer;
      setPortalNode(null);
      setContainerElement(resolvedContainer);
    }
  }, [containerProp, parentPortalNode, uniqueId]);
  const portalElement = useRenderElement("div", componentProps, {
    ref: [ref, setPortalNodeRef],
    props: [{
      id: uniqueId,
      [attr]: ""
    }, elementProps]
  });
  const portalSubtree = containerElement && portalElement ? /* @__PURE__ */ ReactDOM2.createPortal(portalElement, containerElement) : null;
  return {
    portalNode,
    portalSubtree
  };
}
var FloatingPortal = /* @__PURE__ */ React16.forwardRef(function FloatingPortal2(componentProps, forwardedRef) {
  const {
    render,
    className,
    style,
    children,
    container,
    renderGuards,
    ...elementProps
  } = componentProps;
  const {
    portalNode,
    portalSubtree
  } = useFloatingPortalNode({
    container,
    ref: forwardedRef,
    componentProps,
    elementProps
  });
  const beforeOutsideRef = React16.useRef(null);
  const afterOutsideRef = React16.useRef(null);
  const beforeInsideRef = React16.useRef(null);
  const afterInsideRef = React16.useRef(null);
  const [focusManagerState, setFocusManagerState] = React16.useState(null);
  const focusInsideDisabledRef = React16.useRef(false);
  const modal = focusManagerState?.modal;
  const open = focusManagerState?.open;
  const shouldRenderGuards = typeof renderGuards === "boolean" ? renderGuards : !!focusManagerState && !focusManagerState.modal && focusManagerState.open && !!portalNode;
  React16.useEffect(() => {
    if (!portalNode || modal) {
      return void 0;
    }
    function onFocus(event) {
      if (portalNode && event.relatedTarget && isOutsideEvent(event)) {
        if (event.type === "focusin") {
          if (focusInsideDisabledRef.current) {
            enableFocusInside(portalNode);
            focusInsideDisabledRef.current = false;
          }
        } else {
          disableFocusInside(portalNode);
          focusInsideDisabledRef.current = true;
        }
      }
    }
    return mergeCleanups(addEventListener(portalNode, "focusin", onFocus, true), addEventListener(portalNode, "focusout", onFocus, true));
  }, [portalNode, modal]);
  useIsoLayoutEffect(() => {
    if (!portalNode || open !== true || !focusInsideDisabledRef.current) {
      return;
    }
    enableFocusInside(portalNode);
    focusInsideDisabledRef.current = false;
  }, [open, portalNode]);
  const portalContextValue = React16.useMemo(() => ({
    beforeOutsideRef,
    afterOutsideRef,
    beforeInsideRef,
    afterInsideRef,
    portalNode,
    setFocusManagerState
  }), [portalNode]);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(React16.Fragment, {
    children: [portalSubtree, /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(PortalContext.Provider, {
      value: portalContextValue,
      children: [shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
        "data-type": "outside",
        ref: beforeOutsideRef,
        onFocus: (event) => {
          if (isOutsideEvent(event, portalNode)) {
            beforeInsideRef.current?.focus();
          } else {
            const domReference = focusManagerState ? focusManagerState.domReference : null;
            const prevTabbable = getPreviousTabbable(domReference);
            prevTabbable?.focus();
          }
        }
      }), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", {
        "aria-owns": portalNode.id,
        style: ownerVisuallyHidden
      }), portalNode && /* @__PURE__ */ ReactDOM2.createPortal(children, portalNode), shouldRenderGuards && portalNode && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FocusGuard, {
        "data-type": "outside",
        ref: afterOutsideRef,
        onFocus: (event) => {
          if (isOutsideEvent(event, portalNode)) {
            afterInsideRef.current?.focus();
          } else {
            const domReference = focusManagerState ? focusManagerState.domReference : null;
            const nextTabbable = getNextTabbable(domReference);
            nextTabbable?.focus();
            if (focusManagerState?.closeOnFocusOut) {
              focusManagerState?.onOpenChange(false, createChangeEventDetails(reason_parts_exports.focusOut, event.nativeEvent));
            }
          }
        }
      })]
    })]
  });
});
if (true) FloatingPortal.displayName = "FloatingPortal";

// node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
var React17 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/floating-ui-react/utils/createEventEmitter.mjs
function createEventEmitter() {
  const map = /* @__PURE__ */ new Map();
  return {
    emit(event, data) {
      map.get(event)?.forEach((listener) => listener(data));
    },
    on(event, listener) {
      if (!map.has(event)) {
        map.set(event, /* @__PURE__ */ new Set());
      }
      map.get(event).add(listener);
    },
    off(event, listener) {
      map.get(event)?.delete(listener);
    }
  };
}

// node_modules/@base-ui/react/floating-ui-react/components/FloatingTree.mjs
var import_jsx_runtime4 = __toESM(require_jsx_runtime(), 1);
var FloatingNodeContext = /* @__PURE__ */ React17.createContext(null);
if (true) FloatingNodeContext.displayName = "FloatingNodeContext";
var FloatingTreeContext = /* @__PURE__ */ React17.createContext(null);
if (true) FloatingTreeContext.displayName = "FloatingTreeContext";
var useFloatingParentNodeId = () => React17.useContext(FloatingNodeContext)?.id || null;
var useFloatingTree = (externalTree) => {
  const contextTree = React17.useContext(FloatingTreeContext);
  return externalTree ?? contextTree;
};

// node_modules/@base-ui/react/floating-ui-react/hooks/useClientPoint.mjs
var React18 = __toESM(require_react(), 1);
function createVirtualElement(domElement, data) {
  let offsetX = null;
  let offsetY = null;
  let isAutoUpdateEvent = false;
  return {
    contextElement: domElement || void 0,
    getBoundingClientRect() {
      const domRect = domElement?.getBoundingClientRect() || {
        width: 0,
        height: 0,
        x: 0,
        y: 0
      };
      const isXAxis = data.axis === "x" || data.axis === "both";
      const isYAxis = data.axis === "y" || data.axis === "both";
      const canTrackCursorOnAutoUpdate = ["mouseenter", "mousemove"].includes(data.dataRef.current.openEvent?.type || "") && data.pointerType !== "touch";
      let width = domRect.width;
      let height = domRect.height;
      let x2 = domRect.x;
      let y2 = domRect.y;
      if (offsetX == null && data.x && isXAxis) {
        offsetX = domRect.x - data.x;
      }
      if (offsetY == null && data.y && isYAxis) {
        offsetY = domRect.y - data.y;
      }
      x2 -= offsetX || 0;
      y2 -= offsetY || 0;
      width = 0;
      height = 0;
      if (!isAutoUpdateEvent || canTrackCursorOnAutoUpdate) {
        width = data.axis === "y" ? domRect.width : 0;
        height = data.axis === "x" ? domRect.height : 0;
        x2 = isXAxis && data.x != null ? data.x : x2;
        y2 = isYAxis && data.y != null ? data.y : y2;
      } else if (isAutoUpdateEvent && !canTrackCursorOnAutoUpdate) {
        height = data.axis === "x" ? domRect.height : height;
        width = data.axis === "y" ? domRect.width : width;
      }
      isAutoUpdateEvent = true;
      return {
        width,
        height,
        x: x2,
        y: y2,
        top: y2,
        right: x2 + width,
        bottom: y2 + height,
        left: x2
      };
    }
  };
}
function isMouseBasedEvent(event) {
  return event != null && event.clientX != null;
}
function useClientPoint(context, props = {}) {
  const {
    enabled = true,
    axis = "both"
  } = props;
  const store = "rootStore" in context ? context.rootStore : context;
  const open = store.useState("open");
  const floating = store.useState("floatingElement");
  const domReference = store.useState("domReferenceElement");
  const dataRef = store.context.dataRef;
  const initialRef = React18.useRef(false);
  const cleanupListenerRef = React18.useRef(null);
  const [pointerType, setPointerType] = React18.useState();
  const [reactive, setReactive] = React18.useState([]);
  const resetReference = useStableCallback((reference2) => {
    store.set("positionReference", reference2);
  });
  const setReference = useStableCallback((newX, newY, referenceElement) => {
    if (initialRef.current) {
      return;
    }
    if (dataRef.current.openEvent && !isMouseBasedEvent(dataRef.current.openEvent)) {
      return;
    }
    store.set("positionReference", createVirtualElement(referenceElement ?? domReference, {
      x: newX,
      y: newY,
      axis,
      dataRef,
      pointerType
    }));
  });
  const handleReferenceEnterOrMove = useStableCallback((event) => {
    if (!open) {
      setReference(event.clientX, event.clientY, event.currentTarget);
    } else if (!cleanupListenerRef.current) {
      setReference(event.clientX, event.clientY, event.currentTarget);
      setReactive([]);
    }
  });
  const openCheck = isMouseLikePointerType(pointerType) ? floating : open;
  React18.useEffect(() => {
    if (!enabled) {
      resetReference(domReference);
      return void 0;
    }
    if (!openCheck) {
      return void 0;
    }
    function cleanupListener() {
      cleanupListenerRef.current?.();
      cleanupListenerRef.current = null;
    }
    const win = getWindow(floating);
    function handleMouseMove(event) {
      const target = getTarget(event);
      if (!contains(floating, target)) {
        setReference(event.clientX, event.clientY);
      } else {
        cleanupListener();
      }
    }
    if (!dataRef.current.openEvent || isMouseBasedEvent(dataRef.current.openEvent)) {
      cleanupListenerRef.current = addEventListener(win, "mousemove", handleMouseMove);
    } else {
      resetReference(domReference);
    }
    return cleanupListener;
  }, [openCheck, enabled, floating, dataRef, domReference, store, setReference, resetReference, reactive]);
  React18.useEffect(() => () => {
    store.set("positionReference", null);
  }, [store]);
  React18.useEffect(() => {
    if (enabled && !floating) {
      initialRef.current = false;
    }
  }, [enabled, floating]);
  React18.useEffect(() => {
    if (!enabled && open) {
      initialRef.current = true;
    }
  }, [enabled, open]);
  const reference = React18.useMemo(() => {
    function setPointerTypeRef(event) {
      setPointerType(event.pointerType);
    }
    return {
      onPointerDown: setPointerTypeRef,
      onPointerEnter: setPointerTypeRef,
      onMouseMove: handleReferenceEnterOrMove,
      onMouseEnter: handleReferenceEnterOrMove
    };
  }, [handleReferenceEnterOrMove]);
  return React18.useMemo(() => enabled ? {
    reference,
    trigger: reference
  } : {}, [enabled, reference]);
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useDismiss.mjs
var React19 = __toESM(require_react(), 1);
function alwaysFalse() {
  return false;
}
function normalizeProp(normalizable) {
  return {
    escapeKey: typeof normalizable === "boolean" ? normalizable : normalizable?.escapeKey ?? false,
    outsidePress: typeof normalizable === "boolean" ? normalizable : normalizable?.outsidePress ?? true
  };
}
function useDismiss(context, props = {}) {
  const {
    enabled = true,
    escapeKey: escapeKey2 = true,
    outsidePress: outsidePressProp = true,
    outsidePressEvent = "sloppy",
    referencePress = alwaysFalse,
    bubbles,
    externalTree
  } = props;
  const store = "rootStore" in context ? context.rootStore : context;
  const open = store.useState("open");
  const floatingElement = store.useState("floatingElement");
  const {
    dataRef
  } = store.context;
  const tree = useFloatingTree(externalTree);
  const outsidePressFn = useStableCallback(typeof outsidePressProp === "function" ? outsidePressProp : () => false);
  const outsidePress2 = typeof outsidePressProp === "function" ? outsidePressFn : outsidePressProp;
  const outsidePressEnabled = outsidePress2 !== false;
  const getOutsidePressEventProp = useStableCallback(() => outsidePressEvent);
  const {
    escapeKey: escapeKeyBubbles,
    outsidePress: outsidePressBubbles
  } = normalizeProp(bubbles);
  const pressStartedInsideRef = React19.useRef(false);
  const pressStartPreventedRef = React19.useRef(false);
  const suppressNextOutsideClickRef = React19.useRef(false);
  const isComposingRef = React19.useRef(false);
  const currentPointerTypeRef = React19.useRef("");
  const touchStateRef = React19.useRef(null);
  const cancelDismissOnEndTimeout = useTimeout();
  const clearInsideReactTreeTimeout = useTimeout();
  const clearInsideReactTree = useStableCallback(() => {
    clearInsideReactTreeTimeout.clear();
    dataRef.current.insideReactTree = false;
  });
  const hasBlockingChild = useStableCallback((bubbleKey) => {
    const nodeId = dataRef.current.floatingContext?.nodeId;
    const children = tree ? getNodeChildren(tree.nodesRef.current, nodeId) : [];
    return children.some((child) => child.context?.open && !child.context.dataRef.current[bubbleKey]);
  });
  const isEventWithinOwnElements = useStableCallback((event) => {
    return isEventTargetWithin(event, store.select("floatingElement")) || isEventTargetWithin(event, store.select("domReferenceElement"));
  });
  const closeOnReferencePress = useStableCallback((event) => {
    if (!referencePress()) {
      return;
    }
    store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerPress, event.nativeEvent));
  });
  const closeOnEscapeKeyDown = useStableCallback((event) => {
    if (!open || !enabled || !escapeKey2 || event.key !== "Escape") {
      return;
    }
    if (isComposingRef.current) {
      return;
    }
    if (!escapeKeyBubbles && hasBlockingChild("__escapeKeyBubbles")) {
      return;
    }
    const native = isReactEvent(event) ? event.nativeEvent : event;
    const eventDetails = createChangeEventDetails(reason_parts_exports.escapeKey, native);
    store.setOpen(false, eventDetails);
    if (!eventDetails.isCanceled) {
      event.preventDefault();
    }
    if (!escapeKeyBubbles && !eventDetails.isPropagationAllowed) {
      event.stopPropagation();
    }
  });
  const markInsideReactTree = useStableCallback(() => {
    dataRef.current.insideReactTree = true;
    clearInsideReactTreeTimeout.start(0, clearInsideReactTree);
  });
  const markPressStartedInsideReactTree = useStableCallback((event) => {
    if (!open || !enabled || event.button !== 0) {
      return;
    }
    const target = getTarget(event.nativeEvent);
    if (!contains(store.select("floatingElement"), target)) {
      return;
    }
    if (!pressStartedInsideRef.current) {
      pressStartedInsideRef.current = true;
      pressStartPreventedRef.current = false;
    }
  });
  const markInsidePressStartPrevented = useStableCallback((event) => {
    if (!open || !enabled) {
      return;
    }
    if (!(event.defaultPrevented || event.nativeEvent.defaultPrevented)) {
      return;
    }
    if (pressStartedInsideRef.current) {
      pressStartPreventedRef.current = true;
    }
  });
  React19.useEffect(() => {
    if (!open || !enabled) {
      return void 0;
    }
    dataRef.current.__escapeKeyBubbles = escapeKeyBubbles;
    dataRef.current.__outsidePressBubbles = outsidePressBubbles;
    const compositionTimeout = new Timeout();
    const preventedPressSuppressionTimeout = new Timeout();
    function handleCompositionStart() {
      compositionTimeout.clear();
      isComposingRef.current = true;
    }
    function handleCompositionEnd() {
      compositionTimeout.start(
        // 0ms or 1ms don't work in Safari. 5ms appears to consistently work.
        // Only apply to WebKit for the test to remain 0ms.
        parts_exports.engine.webkit ? 5 : 0,
        () => {
          isComposingRef.current = false;
        }
      );
    }
    function suppressImmediateOutsideClickAfterPreventedStart() {
      suppressNextOutsideClickRef.current = true;
      preventedPressSuppressionTimeout.start(0, () => {
        suppressNextOutsideClickRef.current = false;
      });
    }
    function resetPressStartState() {
      pressStartedInsideRef.current = false;
      pressStartPreventedRef.current = false;
    }
    function getOutsidePressEvent() {
      const type = currentPointerTypeRef.current;
      const computedType = type === "pen" || !type ? "mouse" : type;
      const outsidePressEventValue = getOutsidePressEventProp();
      const resolved = typeof outsidePressEventValue === "function" ? outsidePressEventValue() : outsidePressEventValue;
      if (typeof resolved === "string") {
        return resolved;
      }
      return resolved[computedType];
    }
    function shouldIgnoreEvent(event) {
      const computedOutsidePressEvent = getOutsidePressEvent();
      return computedOutsidePressEvent === "intentional" && event.type !== "click" || computedOutsidePressEvent === "sloppy" && event.type === "click";
    }
    function isEventWithinFloatingTree(event) {
      const nodeId = dataRef.current.floatingContext?.nodeId;
      const targetIsInsideChildren = tree && getNodeChildren(tree.nodesRef.current, nodeId).some((node) => isEventTargetWithin(event, node.context?.elements.floating));
      return isEventWithinOwnElements(event) || targetIsInsideChildren;
    }
    function closeOnPressOutside(event) {
      if (shouldIgnoreEvent(event)) {
        if (event.type !== "click" && !isEventWithinOwnElements(event)) {
          preventedPressSuppressionTimeout.clear();
          suppressNextOutsideClickRef.current = false;
        }
        clearInsideReactTree();
        return;
      }
      if (dataRef.current.insideReactTree) {
        clearInsideReactTree();
        return;
      }
      const target = getTarget(event);
      const inertSelector = `[${createAttribute("inert")}]`;
      const targetRoot = isElement(target) ? target.getRootNode() : null;
      const markers = Array.from((isShadowRoot(targetRoot) ? targetRoot : ownerDocument(store.select("floatingElement"))).querySelectorAll(inertSelector));
      const triggers = store.context.triggerElements;
      if (target && (triggers.hasElement(target) || triggers.hasMatchingElement((trigger) => contains(trigger, target)))) {
        return;
      }
      let targetRootAncestor = isElement(target) ? target : null;
      while (targetRootAncestor && !isLastTraversableNode(targetRootAncestor)) {
        const nextParent = getParentNode(targetRootAncestor);
        if (isLastTraversableNode(nextParent) || !isElement(nextParent)) {
          break;
        }
        targetRootAncestor = nextParent;
      }
      if (markers.length && isElement(target) && !isRootElement(target) && // Clicked on a direct ancestor (e.g. FloatingOverlay).
      !contains(target, store.select("floatingElement")) && // If the target root element contains none of the markers, then the
      // element was injected after the floating element rendered.
      markers.every((marker) => !contains(targetRootAncestor, marker))) {
        return;
      }
      if (isHTMLElement(target) && !("touches" in event)) {
        const lastTraversableNode = isLastTraversableNode(target);
        const style = getComputedStyle2(target);
        const scrollRe = /auto|scroll/;
        const isScrollableX = lastTraversableNode || scrollRe.test(style.overflowX);
        const isScrollableY = lastTraversableNode || scrollRe.test(style.overflowY);
        const canScrollX = isScrollableX && target.clientWidth > 0 && target.scrollWidth > target.clientWidth;
        const canScrollY = isScrollableY && target.clientHeight > 0 && target.scrollHeight > target.clientHeight;
        const isRTL12 = style.direction === "rtl";
        const pressedVerticalScrollbar = canScrollY && (isRTL12 ? event.offsetX <= target.offsetWidth - target.clientWidth : event.offsetX > target.clientWidth);
        const pressedHorizontalScrollbar = canScrollX && event.offsetY > target.clientHeight;
        if (pressedVerticalScrollbar || pressedHorizontalScrollbar) {
          return;
        }
      }
      if (isEventWithinFloatingTree(event)) {
        return;
      }
      if (getOutsidePressEvent() === "intentional" && suppressNextOutsideClickRef.current) {
        preventedPressSuppressionTimeout.clear();
        suppressNextOutsideClickRef.current = false;
        return;
      }
      if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
        return;
      }
      if (hasBlockingChild("__outsidePressBubbles")) {
        return;
      }
      store.setOpen(false, createChangeEventDetails(reason_parts_exports.outsidePress, event));
      clearInsideReactTree();
    }
    function handlePointerDown(event) {
      if (getOutsidePressEvent() !== "sloppy" || event.pointerType === "touch" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
        return;
      }
      closeOnPressOutside(event);
    }
    function handleTouchStart(event) {
      if (getOutsidePressEvent() !== "sloppy" || !store.select("open") || !enabled || isEventWithinOwnElements(event)) {
        return;
      }
      const touch = event.touches[0];
      if (touch) {
        touchStateRef.current = {
          startTime: Date.now(),
          startX: touch.clientX,
          startY: touch.clientY,
          dismissOnTouchEnd: false,
          dismissOnMouseDown: true
        };
        cancelDismissOnEndTimeout.start(1e3, () => {
          if (touchStateRef.current) {
            touchStateRef.current.dismissOnTouchEnd = false;
            touchStateRef.current.dismissOnMouseDown = false;
          }
        });
      }
    }
    function addTargetEventListenerOnce(event, listener) {
      const target = getTarget(event);
      if (!target) {
        return;
      }
      const unsubscribe2 = addEventListener(target, event.type, () => {
        listener(event);
        unsubscribe2();
      });
    }
    function handleTouchStartCapture(event) {
      currentPointerTypeRef.current = "touch";
      addTargetEventListenerOnce(event, handleTouchStart);
    }
    function closeOnPressOutsideCapture(event) {
      cancelDismissOnEndTimeout.clear();
      if (event.type === "pointerdown") {
        currentPointerTypeRef.current = event.pointerType;
      }
      if (event.type === "mousedown" && touchStateRef.current && !touchStateRef.current.dismissOnMouseDown) {
        return;
      }
      addTargetEventListenerOnce(event, (targetEvent) => {
        if (targetEvent.type === "pointerdown") {
          handlePointerDown(targetEvent);
        } else {
          closeOnPressOutside(targetEvent);
        }
      });
    }
    function handlePressEndCapture(event) {
      if (!pressStartedInsideRef.current) {
        return;
      }
      const pressStartedInsideDefaultPrevented = pressStartPreventedRef.current;
      resetPressStartState();
      if (getOutsidePressEvent() !== "intentional") {
        return;
      }
      if (event.type === "pointercancel") {
        if (pressStartedInsideDefaultPrevented) {
          suppressImmediateOutsideClickAfterPreventedStart();
        }
        return;
      }
      if (isEventWithinFloatingTree(event)) {
        return;
      }
      if (pressStartedInsideDefaultPrevented) {
        suppressImmediateOutsideClickAfterPreventedStart();
        return;
      }
      if (typeof outsidePress2 === "function" && !outsidePress2(event)) {
        return;
      }
      preventedPressSuppressionTimeout.clear();
      suppressNextOutsideClickRef.current = true;
      clearInsideReactTree();
    }
    function handleTouchMove(event) {
      if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
        return;
      }
      const touch = event.touches[0];
      if (!touch) {
        return;
      }
      const deltaX = Math.abs(touch.clientX - touchStateRef.current.startX);
      const deltaY = Math.abs(touch.clientY - touchStateRef.current.startY);
      const distance = Math.sqrt(deltaX * deltaX + deltaY * deltaY);
      if (distance > 5) {
        touchStateRef.current.dismissOnTouchEnd = true;
      }
      if (distance > 10) {
        closeOnPressOutside(event);
        cancelDismissOnEndTimeout.clear();
        touchStateRef.current = null;
      }
    }
    function handleTouchMoveCapture(event) {
      addTargetEventListenerOnce(event, handleTouchMove);
    }
    function handleTouchEnd(event) {
      if (getOutsidePressEvent() !== "sloppy" || !touchStateRef.current || isEventWithinOwnElements(event)) {
        return;
      }
      if (touchStateRef.current.dismissOnTouchEnd) {
        closeOnPressOutside(event);
      }
      cancelDismissOnEndTimeout.clear();
      touchStateRef.current = null;
    }
    function handleTouchEndCapture(event) {
      addTargetEventListenerOnce(event, handleTouchEnd);
    }
    const doc = ownerDocument(floatingElement);
    const unsubscribe = mergeCleanups(escapeKey2 && mergeCleanups(addEventListener(doc, "keydown", closeOnEscapeKeyDown), addEventListener(doc, "compositionstart", handleCompositionStart), addEventListener(doc, "compositionend", handleCompositionEnd)), outsidePressEnabled && mergeCleanups(addEventListener(doc, "click", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerdown", closeOnPressOutsideCapture, true), addEventListener(doc, "pointerup", handlePressEndCapture, true), addEventListener(doc, "pointercancel", handlePressEndCapture, true), addEventListener(doc, "mousedown", closeOnPressOutsideCapture, true), addEventListener(doc, "mouseup", handlePressEndCapture, true), addEventListener(doc, "touchstart", handleTouchStartCapture, true), addEventListener(doc, "touchmove", handleTouchMoveCapture, true), addEventListener(doc, "touchend", handleTouchEndCapture, true)));
    return () => {
      unsubscribe();
      compositionTimeout.clear();
      preventedPressSuppressionTimeout.clear();
      resetPressStartState();
      suppressNextOutsideClickRef.current = false;
    };
  }, [dataRef, floatingElement, escapeKey2, outsidePressEnabled, outsidePress2, open, enabled, escapeKeyBubbles, outsidePressBubbles, closeOnEscapeKeyDown, clearInsideReactTree, getOutsidePressEventProp, hasBlockingChild, isEventWithinOwnElements, tree, store, cancelDismissOnEndTimeout]);
  React19.useEffect(clearInsideReactTree, [outsidePress2, clearInsideReactTree]);
  const reference = React19.useMemo(() => ({
    onKeyDown: closeOnEscapeKeyDown,
    onPointerDown: closeOnReferencePress,
    onClick: closeOnReferencePress
  }), [closeOnEscapeKeyDown, closeOnReferencePress]);
  const floating = React19.useMemo(() => ({
    onKeyDown: closeOnEscapeKeyDown,
    // `onMouseDown` may be blocked if `event.preventDefault()` is called in
    // `onPointerDown`, such as with <NumberField.ScrubArea>.
    // See https://github.com/mui/base-ui/pull/3379
    onPointerDown: markInsidePressStartPrevented,
    onMouseDown: markInsidePressStartPrevented,
    onClickCapture: markInsideReactTree,
    onMouseDownCapture(event) {
      markInsideReactTree();
      markPressStartedInsideReactTree(event);
    },
    onPointerDownCapture(event) {
      markInsideReactTree();
      markPressStartedInsideReactTree(event);
    },
    onMouseUpCapture: markInsideReactTree,
    onTouchEndCapture: markInsideReactTree,
    onTouchMoveCapture: markInsideReactTree
  }), [closeOnEscapeKeyDown, markInsideReactTree, markPressStartedInsideReactTree, markInsidePressStartPrevented]);
  return React19.useMemo(() => enabled ? {
    reference,
    floating,
    trigger: reference
  } : {}, [enabled, reference, floating]);
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
var React26 = __toESM(require_react(), 1);

// node_modules/@floating-ui/core/dist/floating-ui.core.mjs
function computeCoordsFromPlacement(_ref, placement, rtl) {
  let {
    reference,
    floating
  } = _ref;
  const sideAxis = getSideAxis(placement);
  const alignmentAxis = getAlignmentAxis(placement);
  const alignLength = getAxisLength(alignmentAxis);
  const side = getSide(placement);
  const isVertical = sideAxis === "y";
  const commonX = reference.x + reference.width / 2 - floating.width / 2;
  const commonY = reference.y + reference.height / 2 - floating.height / 2;
  const commonAlign = reference[alignLength] / 2 - floating[alignLength] / 2;
  let coords;
  switch (side) {
    case "top":
      coords = {
        x: commonX,
        y: reference.y - floating.height
      };
      break;
    case "bottom":
      coords = {
        x: commonX,
        y: reference.y + reference.height
      };
      break;
    case "right":
      coords = {
        x: reference.x + reference.width,
        y: commonY
      };
      break;
    case "left":
      coords = {
        x: reference.x - floating.width,
        y: commonY
      };
      break;
    default:
      coords = {
        x: reference.x,
        y: reference.y
      };
  }
  switch (getAlignment(placement)) {
    case "start":
      coords[alignmentAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
      break;
    case "end":
      coords[alignmentAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
      break;
  }
  return coords;
}
async function detectOverflow(state, options) {
  var _await$platform$isEle;
  if (options === void 0) {
    options = {};
  }
  const {
    x: x2,
    y: y2,
    platform: platform3,
    rects,
    elements: elements2,
    strategy
  } = state;
  const {
    boundary = "clippingAncestors",
    rootBoundary = "viewport",
    elementContext = "floating",
    altBoundary = false,
    padding = 0
  } = evaluate(options, state);
  const paddingObject = getPaddingObject(padding);
  const altContext = elementContext === "floating" ? "reference" : "floating";
  const element = elements2[altBoundary ? altContext : elementContext];
  const clippingClientRect = rectToClientRect(await platform3.getClippingRect({
    element: ((_await$platform$isEle = await (platform3.isElement == null ? void 0 : platform3.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || await (platform3.getDocumentElement == null ? void 0 : platform3.getDocumentElement(elements2.floating)),
    boundary,
    rootBoundary,
    strategy
  }));
  const rect = elementContext === "floating" ? {
    x: x2,
    y: y2,
    width: rects.floating.width,
    height: rects.floating.height
  } : rects.reference;
  const offsetParent = await (platform3.getOffsetParent == null ? void 0 : platform3.getOffsetParent(elements2.floating));
  const offsetScale = await (platform3.isElement == null ? void 0 : platform3.isElement(offsetParent)) ? await (platform3.getScale == null ? void 0 : platform3.getScale(offsetParent)) || {
    x: 1,
    y: 1
  } : {
    x: 1,
    y: 1
  };
  const elementClientRect = rectToClientRect(platform3.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform3.convertOffsetParentRelativeRectToViewportRelativeRect({
    elements: elements2,
    rect,
    offsetParent,
    strategy
  }) : rect);
  return {
    top: (clippingClientRect.top - elementClientRect.top + paddingObject.top) / offsetScale.y,
    bottom: (elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom) / offsetScale.y,
    left: (clippingClientRect.left - elementClientRect.left + paddingObject.left) / offsetScale.x,
    right: (elementClientRect.right - clippingClientRect.right + paddingObject.right) / offsetScale.x
  };
}
var MAX_RESET_COUNT = 50;
var computePosition = async (reference, floating, config) => {
  const {
    placement = "bottom",
    strategy = "absolute",
    middleware = [],
    platform: platform3
  } = config;
  const platformWithDetectOverflow = platform3.detectOverflow ? platform3 : {
    ...platform3,
    detectOverflow
  };
  const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(floating));
  let rects = await platform3.getElementRects({
    reference,
    floating,
    strategy
  });
  let {
    x: x2,
    y: y2
  } = computeCoordsFromPlacement(rects, placement, rtl);
  let statefulPlacement = placement;
  let resetCount = 0;
  const middlewareData = {};
  for (let i2 = 0; i2 < middleware.length; i2++) {
    const currentMiddleware = middleware[i2];
    if (!currentMiddleware) {
      continue;
    }
    const {
      name: name2,
      fn
    } = currentMiddleware;
    const {
      x: nextX,
      y: nextY,
      data,
      reset
    } = await fn({
      x: x2,
      y: y2,
      initialPlacement: placement,
      placement: statefulPlacement,
      strategy,
      middlewareData,
      rects,
      platform: platformWithDetectOverflow,
      elements: {
        reference,
        floating
      }
    });
    x2 = nextX != null ? nextX : x2;
    y2 = nextY != null ? nextY : y2;
    middlewareData[name2] = {
      ...middlewareData[name2],
      ...data
    };
    if (reset && resetCount < MAX_RESET_COUNT) {
      resetCount++;
      if (typeof reset === "object") {
        if (reset.placement) {
          statefulPlacement = reset.placement;
        }
        if (reset.rects) {
          rects = reset.rects === true ? await platform3.getElementRects({
            reference,
            floating,
            strategy
          }) : reset.rects;
        }
        ({
          x: x2,
          y: y2
        } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
      }
      i2 = -1;
    }
  }
  return {
    x: x2,
    y: y2,
    placement: statefulPlacement,
    strategy,
    middlewareData
  };
};
var flip = function(options) {
  if (options === void 0) {
    options = {};
  }
  return {
    name: "flip",
    options,
    async fn(state) {
      var _middlewareData$arrow, _middlewareData$flip;
      const {
        placement,
        middlewareData,
        rects,
        initialPlacement,
        platform: platform3,
        elements: elements2
      } = state;
      const {
        mainAxis: checkMainAxis = true,
        crossAxis: checkCrossAxis = true,
        fallbackPlacements: specifiedFallbackPlacements,
        fallbackStrategy = "bestFit",
        fallbackAxisSideDirection = "none",
        flipAlignment = true,
        ...detectOverflowOptions
      } = evaluate(options, state);
      if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
        return {};
      }
      const side = getSide(placement);
      const initialSideAxis = getSideAxis(initialPlacement);
      const isBasePlacement = getSide(initialPlacement) === initialPlacement;
      const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating));
      const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
      const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
      if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
        fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
      }
      const placements2 = [initialPlacement, ...fallbackPlacements];
      const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
      const overflows = [];
      let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
      if (checkMainAxis) {
        overflows.push(overflow[side]);
      }
      if (checkCrossAxis) {
        const sides2 = getAlignmentSides(placement, rects, rtl);
        overflows.push(overflow[sides2[0]], overflow[sides2[1]]);
      }
      overflowsData = [...overflowsData, {
        placement,
        overflows
      }];
      if (!overflows.every((side2) => side2 <= 0)) {
        var _middlewareData$flip2, _overflowsData$filter;
        const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
        const nextPlacement = placements2[nextIndex];
        if (nextPlacement) {
          const ignoreCrossAxisOverflow = checkCrossAxis === "alignment" ? initialSideAxis !== getSideAxis(nextPlacement) : false;
          if (!ignoreCrossAxisOverflow || // We leave the current main axis only if every placement on that axis
          // overflows the main axis.
          overflowsData.every((d2) => getSideAxis(d2.placement) === initialSideAxis ? d2.overflows[0] > 0 : true)) {
            return {
              data: {
                index: nextIndex,
                overflows: overflowsData
              },
              reset: {
                placement: nextPlacement
              }
            };
          }
        }
        let resetPlacement = (_overflowsData$filter = overflowsData.filter((d2) => d2.overflows[0] <= 0).sort((a2, b2) => a2.overflows[1] - b2.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
        if (!resetPlacement) {
          switch (fallbackStrategy) {
            case "bestFit": {
              var _overflowsData$filter2;
              const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
                if (hasFallbackAxisSideDirection) {
                  const currentSideAxis = getSideAxis(d2.placement);
                  return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
                  // reading directions favoring greater width.
                  currentSideAxis === "y";
                }
                return true;
              }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
              if (placement2) {
                resetPlacement = placement2;
              }
              break;
            }
            case "initialPlacement":
              resetPlacement = initialPlacement;
              break;
          }
        }
        if (placement !== resetPlacement) {
          return {
            reset: {
              placement: resetPlacement
            }
          };
        }
      }
      return {};
    }
  };
};
function getSideOffsets(overflow, rect) {
  return {
    top: overflow.top - rect.height,
    right: overflow.right - rect.width,
    bottom: overflow.bottom - rect.height,
    left: overflow.left - rect.width
  };
}
function isAnySideFullyClipped(overflow) {
  return sides.some((side) => overflow[side] >= 0);
}
var hide = function(options) {
  if (options === void 0) {
    options = {};
  }
  return {
    name: "hide",
    options,
    async fn(state) {
      const {
        rects,
        platform: platform3
      } = state;
      const {
        strategy = "referenceHidden",
        ...detectOverflowOptions
      } = evaluate(options, state);
      switch (strategy) {
        case "referenceHidden": {
          const overflow = await platform3.detectOverflow(state, {
            ...detectOverflowOptions,
            elementContext: "reference"
          });
          const offsets = getSideOffsets(overflow, rects.reference);
          return {
            data: {
              referenceHiddenOffsets: offsets,
              referenceHidden: isAnySideFullyClipped(offsets)
            }
          };
        }
        case "escaped": {
          const overflow = await platform3.detectOverflow(state, {
            ...detectOverflowOptions,
            altBoundary: true
          });
          const offsets = getSideOffsets(overflow, rects.floating);
          return {
            data: {
              escapedOffsets: offsets,
              escaped: isAnySideFullyClipped(offsets)
            }
          };
        }
        default: {
          return {};
        }
      }
    }
  };
};
var originSides = /* @__PURE__ */ new Set(["left", "top"]);
async function convertValueToCoords(state, options) {
  const {
    placement,
    platform: platform3,
    elements: elements2
  } = state;
  const rtl = await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating));
  const side = getSide(placement);
  const alignment = getAlignment(placement);
  const isVertical = getSideAxis(placement) === "y";
  const mainAxisMulti = originSides.has(side) ? -1 : 1;
  const crossAxisMulti = rtl && isVertical ? -1 : 1;
  const rawValue = evaluate(options, state);
  let {
    mainAxis,
    crossAxis,
    alignmentAxis
  } = typeof rawValue === "number" ? {
    mainAxis: rawValue,
    crossAxis: 0,
    alignmentAxis: null
  } : {
    mainAxis: rawValue.mainAxis || 0,
    crossAxis: rawValue.crossAxis || 0,
    alignmentAxis: rawValue.alignmentAxis
  };
  if (alignment && typeof alignmentAxis === "number") {
    crossAxis = alignment === "end" ? alignmentAxis * -1 : alignmentAxis;
  }
  return isVertical ? {
    x: crossAxis * crossAxisMulti,
    y: mainAxis * mainAxisMulti
  } : {
    x: mainAxis * mainAxisMulti,
    y: crossAxis * crossAxisMulti
  };
}
var offset = function(options) {
  if (options === void 0) {
    options = 0;
  }
  return {
    name: "offset",
    options,
    async fn(state) {
      var _middlewareData$offse, _middlewareData$arrow;
      const {
        x: x2,
        y: y2,
        placement,
        middlewareData
      } = state;
      const diffCoords = await convertValueToCoords(state, options);
      if (placement === ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse.placement) && (_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
        return {};
      }
      return {
        x: x2 + diffCoords.x,
        y: y2 + diffCoords.y,
        data: {
          ...diffCoords,
          placement
        }
      };
    }
  };
};
var shift = function(options) {
  if (options === void 0) {
    options = {};
  }
  return {
    name: "shift",
    options,
    async fn(state) {
      const {
        x: x2,
        y: y2,
        placement,
        platform: platform3
      } = state;
      const {
        mainAxis: checkMainAxis = true,
        crossAxis: checkCrossAxis = false,
        limiter = {
          fn: (_ref) => {
            let {
              x: x3,
              y: y3
            } = _ref;
            return {
              x: x3,
              y: y3
            };
          }
        },
        ...detectOverflowOptions
      } = evaluate(options, state);
      const coords = {
        x: x2,
        y: y2
      };
      const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
      const crossAxis = getSideAxis(getSide(placement));
      const mainAxis = getOppositeAxis(crossAxis);
      let mainAxisCoord = coords[mainAxis];
      let crossAxisCoord = coords[crossAxis];
      if (checkMainAxis) {
        const minSide = mainAxis === "y" ? "top" : "left";
        const maxSide = mainAxis === "y" ? "bottom" : "right";
        const min2 = mainAxisCoord + overflow[minSide];
        const max2 = mainAxisCoord - overflow[maxSide];
        mainAxisCoord = clamp(min2, mainAxisCoord, max2);
      }
      if (checkCrossAxis) {
        const minSide = crossAxis === "y" ? "top" : "left";
        const maxSide = crossAxis === "y" ? "bottom" : "right";
        const min2 = crossAxisCoord + overflow[minSide];
        const max2 = crossAxisCoord - overflow[maxSide];
        crossAxisCoord = clamp(min2, crossAxisCoord, max2);
      }
      const limitedCoords = limiter.fn({
        ...state,
        [mainAxis]: mainAxisCoord,
        [crossAxis]: crossAxisCoord
      });
      return {
        ...limitedCoords,
        data: {
          x: limitedCoords.x - x2,
          y: limitedCoords.y - y2,
          enabled: {
            [mainAxis]: checkMainAxis,
            [crossAxis]: checkCrossAxis
          }
        }
      };
    }
  };
};
var limitShift = function(options) {
  if (options === void 0) {
    options = {};
  }
  return {
    options,
    fn(state) {
      const {
        x: x2,
        y: y2,
        placement,
        rects,
        middlewareData
      } = state;
      const {
        offset: offset4 = 0,
        mainAxis: checkMainAxis = true,
        crossAxis: checkCrossAxis = true
      } = evaluate(options, state);
      const coords = {
        x: x2,
        y: y2
      };
      const crossAxis = getSideAxis(placement);
      const mainAxis = getOppositeAxis(crossAxis);
      let mainAxisCoord = coords[mainAxis];
      let crossAxisCoord = coords[crossAxis];
      const rawOffset = evaluate(offset4, state);
      const computedOffset = typeof rawOffset === "number" ? {
        mainAxis: rawOffset,
        crossAxis: 0
      } : {
        mainAxis: 0,
        crossAxis: 0,
        ...rawOffset
      };
      if (checkMainAxis) {
        const len = mainAxis === "y" ? "height" : "width";
        const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;
        const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;
        if (mainAxisCoord < limitMin) {
          mainAxisCoord = limitMin;
        } else if (mainAxisCoord > limitMax) {
          mainAxisCoord = limitMax;
        }
      }
      if (checkCrossAxis) {
        var _middlewareData$offse, _middlewareData$offse2;
        const len = mainAxis === "y" ? "width" : "height";
        const isOriginSide = originSides.has(getSide(placement));
        const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? ((_middlewareData$offse = middlewareData.offset) == null ? void 0 : _middlewareData$offse[crossAxis]) || 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);
        const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : ((_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) || 0) - (isOriginSide ? computedOffset.crossAxis : 0);
        if (crossAxisCoord < limitMin) {
          crossAxisCoord = limitMin;
        } else if (crossAxisCoord > limitMax) {
          crossAxisCoord = limitMax;
        }
      }
      return {
        [mainAxis]: mainAxisCoord,
        [crossAxis]: crossAxisCoord
      };
    }
  };
};
var size = function(options) {
  if (options === void 0) {
    options = {};
  }
  return {
    name: "size",
    options,
    async fn(state) {
      var _state$middlewareData, _state$middlewareData2;
      const {
        placement,
        rects,
        platform: platform3,
        elements: elements2
      } = state;
      const {
        apply = () => {
        },
        ...detectOverflowOptions
      } = evaluate(options, state);
      const overflow = await platform3.detectOverflow(state, detectOverflowOptions);
      const side = getSide(placement);
      const alignment = getAlignment(placement);
      const isYAxis = getSideAxis(placement) === "y";
      const {
        width,
        height
      } = rects.floating;
      let heightSide;
      let widthSide;
      if (side === "top" || side === "bottom") {
        heightSide = side;
        widthSide = alignment === (await (platform3.isRTL == null ? void 0 : platform3.isRTL(elements2.floating)) ? "start" : "end") ? "left" : "right";
      } else {
        widthSide = side;
        heightSide = alignment === "end" ? "top" : "bottom";
      }
      const maximumClippingHeight = height - overflow.top - overflow.bottom;
      const maximumClippingWidth = width - overflow.left - overflow.right;
      const overflowAvailableHeight = min(height - overflow[heightSide], maximumClippingHeight);
      const overflowAvailableWidth = min(width - overflow[widthSide], maximumClippingWidth);
      const noShift = !state.middlewareData.shift;
      let availableHeight = overflowAvailableHeight;
      let availableWidth = overflowAvailableWidth;
      if ((_state$middlewareData = state.middlewareData.shift) != null && _state$middlewareData.enabled.x) {
        availableWidth = maximumClippingWidth;
      }
      if ((_state$middlewareData2 = state.middlewareData.shift) != null && _state$middlewareData2.enabled.y) {
        availableHeight = maximumClippingHeight;
      }
      if (noShift && !alignment) {
        const xMin = max(overflow.left, 0);
        const xMax = max(overflow.right, 0);
        const yMin = max(overflow.top, 0);
        const yMax = max(overflow.bottom, 0);
        if (isYAxis) {
          availableWidth = width - 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right));
        } else {
          availableHeight = height - 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom));
        }
      }
      await apply({
        ...state,
        availableWidth,
        availableHeight
      });
      const nextDimensions = await platform3.getDimensions(elements2.floating);
      if (width !== nextDimensions.width || height !== nextDimensions.height) {
        return {
          reset: {
            rects: true
          }
        };
      }
      return {};
    }
  };
};

// node_modules/@floating-ui/dom/dist/floating-ui.dom.mjs
function getCssDimensions(element) {
  const css = getComputedStyle2(element);
  let width = parseFloat(css.width) || 0;
  let height = parseFloat(css.height) || 0;
  const hasOffset = isHTMLElement(element);
  const offsetWidth = hasOffset ? element.offsetWidth : width;
  const offsetHeight = hasOffset ? element.offsetHeight : height;
  const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
  if (shouldFallback) {
    width = offsetWidth;
    height = offsetHeight;
  }
  return {
    width,
    height,
    $: shouldFallback
  };
}
function unwrapElement(element) {
  return !isElement(element) ? element.contextElement : element;
}
function getScale(element) {
  const domElement = unwrapElement(element);
  if (!isHTMLElement(domElement)) {
    return createCoords(1);
  }
  const rect = domElement.getBoundingClientRect();
  const {
    width,
    height,
    $: $2
  } = getCssDimensions(domElement);
  let x2 = ($2 ? round(rect.width) : rect.width) / width;
  let y2 = ($2 ? round(rect.height) : rect.height) / height;
  if (!x2 || !Number.isFinite(x2)) {
    x2 = 1;
  }
  if (!y2 || !Number.isFinite(y2)) {
    y2 = 1;
  }
  return {
    x: x2,
    y: y2
  };
}
var noOffsets = /* @__PURE__ */ createCoords(0);
function getVisualOffsets(element) {
  const win = getWindow(element);
  if (!isWebKit() || !win.visualViewport) {
    return noOffsets;
  }
  return {
    x: win.visualViewport.offsetLeft,
    y: win.visualViewport.offsetTop
  };
}
function shouldAddVisualOffsets(element, isFixed, floatingOffsetParent) {
  if (isFixed === void 0) {
    isFixed = false;
  }
  if (!floatingOffsetParent || isFixed && floatingOffsetParent !== getWindow(element)) {
    return false;
  }
  return isFixed;
}
function getBoundingClientRect(element, includeScale, isFixedStrategy, offsetParent) {
  if (includeScale === void 0) {
    includeScale = false;
  }
  if (isFixedStrategy === void 0) {
    isFixedStrategy = false;
  }
  const clientRect = element.getBoundingClientRect();
  const domElement = unwrapElement(element);
  let scale = createCoords(1);
  if (includeScale) {
    if (offsetParent) {
      if (isElement(offsetParent)) {
        scale = getScale(offsetParent);
      }
    } else {
      scale = getScale(element);
    }
  }
  const visualOffsets = shouldAddVisualOffsets(domElement, isFixedStrategy, offsetParent) ? getVisualOffsets(domElement) : createCoords(0);
  let x2 = (clientRect.left + visualOffsets.x) / scale.x;
  let y2 = (clientRect.top + visualOffsets.y) / scale.y;
  let width = clientRect.width / scale.x;
  let height = clientRect.height / scale.y;
  if (domElement) {
    const win = getWindow(domElement);
    const offsetWin = offsetParent && isElement(offsetParent) ? getWindow(offsetParent) : offsetParent;
    let currentWin = win;
    let currentIFrame = getFrameElement(currentWin);
    while (currentIFrame && offsetParent && offsetWin !== currentWin) {
      const iframeScale = getScale(currentIFrame);
      const iframeRect = currentIFrame.getBoundingClientRect();
      const css = getComputedStyle2(currentIFrame);
      const left = iframeRect.left + (currentIFrame.clientLeft + parseFloat(css.paddingLeft)) * iframeScale.x;
      const top = iframeRect.top + (currentIFrame.clientTop + parseFloat(css.paddingTop)) * iframeScale.y;
      x2 *= iframeScale.x;
      y2 *= iframeScale.y;
      width *= iframeScale.x;
      height *= iframeScale.y;
      x2 += left;
      y2 += top;
      currentWin = getWindow(currentIFrame);
      currentIFrame = getFrameElement(currentWin);
    }
  }
  return rectToClientRect({
    width,
    height,
    x: x2,
    y: y2
  });
}
function getWindowScrollBarX(element, rect) {
  const leftScroll = getNodeScroll(element).scrollLeft;
  if (!rect) {
    return getBoundingClientRect(getDocumentElement(element)).left + leftScroll;
  }
  return rect.left + leftScroll;
}
function getHTMLOffset(documentElement, scroll) {
  const htmlRect = documentElement.getBoundingClientRect();
  const x2 = htmlRect.left + scroll.scrollLeft - getWindowScrollBarX(documentElement, htmlRect);
  const y2 = htmlRect.top + scroll.scrollTop;
  return {
    x: x2,
    y: y2
  };
}
function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
  let {
    elements: elements2,
    rect,
    offsetParent,
    strategy
  } = _ref;
  const isFixed = strategy === "fixed";
  const documentElement = getDocumentElement(offsetParent);
  const topLayer = elements2 ? isTopLayer(elements2.floating) : false;
  if (offsetParent === documentElement || topLayer && isFixed) {
    return rect;
  }
  let scroll = {
    scrollLeft: 0,
    scrollTop: 0
  };
  let scale = createCoords(1);
  const offsets = createCoords(0);
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
    if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
      scroll = getNodeScroll(offsetParent);
    }
    if (isOffsetParentAnElement) {
      const offsetRect = getBoundingClientRect(offsetParent);
      scale = getScale(offsetParent);
      offsets.x = offsetRect.x + offsetParent.clientLeft;
      offsets.y = offsetRect.y + offsetParent.clientTop;
    }
  }
  const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
  return {
    width: rect.width * scale.x,
    height: rect.height * scale.y,
    x: rect.x * scale.x - scroll.scrollLeft * scale.x + offsets.x + htmlOffset.x,
    y: rect.y * scale.y - scroll.scrollTop * scale.y + offsets.y + htmlOffset.y
  };
}
function getClientRects(element) {
  return Array.from(element.getClientRects());
}
function getDocumentRect(element) {
  const html = getDocumentElement(element);
  const scroll = getNodeScroll(element);
  const body = element.ownerDocument.body;
  const width = max(html.scrollWidth, html.clientWidth, body.scrollWidth, body.clientWidth);
  const height = max(html.scrollHeight, html.clientHeight, body.scrollHeight, body.clientHeight);
  let x2 = -scroll.scrollLeft + getWindowScrollBarX(element);
  const y2 = -scroll.scrollTop;
  if (getComputedStyle2(body).direction === "rtl") {
    x2 += max(html.clientWidth, body.clientWidth) - width;
  }
  return {
    width,
    height,
    x: x2,
    y: y2
  };
}
var SCROLLBAR_MAX = 25;
function getViewportRect(element, strategy) {
  const win = getWindow(element);
  const html = getDocumentElement(element);
  const visualViewport = win.visualViewport;
  let width = html.clientWidth;
  let height = html.clientHeight;
  let x2 = 0;
  let y2 = 0;
  if (visualViewport) {
    width = visualViewport.width;
    height = visualViewport.height;
    const visualViewportBased = isWebKit();
    if (!visualViewportBased || visualViewportBased && strategy === "fixed") {
      x2 = visualViewport.offsetLeft;
      y2 = visualViewport.offsetTop;
    }
  }
  const windowScrollbarX = getWindowScrollBarX(html);
  if (windowScrollbarX <= 0) {
    const doc = html.ownerDocument;
    const body = doc.body;
    const bodyStyles = getComputedStyle(body);
    const bodyMarginInline = doc.compatMode === "CSS1Compat" ? parseFloat(bodyStyles.marginLeft) + parseFloat(bodyStyles.marginRight) || 0 : 0;
    const clippingStableScrollbarWidth = Math.abs(html.clientWidth - body.clientWidth - bodyMarginInline);
    if (clippingStableScrollbarWidth <= SCROLLBAR_MAX) {
      width -= clippingStableScrollbarWidth;
    }
  } else if (windowScrollbarX <= SCROLLBAR_MAX) {
    width += windowScrollbarX;
  }
  return {
    width,
    height,
    x: x2,
    y: y2
  };
}
function getInnerBoundingClientRect(element, strategy) {
  const clientRect = getBoundingClientRect(element, true, strategy === "fixed");
  const top = clientRect.top + element.clientTop;
  const left = clientRect.left + element.clientLeft;
  const scale = isHTMLElement(element) ? getScale(element) : createCoords(1);
  const width = element.clientWidth * scale.x;
  const height = element.clientHeight * scale.y;
  const x2 = left * scale.x;
  const y2 = top * scale.y;
  return {
    width,
    height,
    x: x2,
    y: y2
  };
}
function getClientRectFromClippingAncestor(element, clippingAncestor, strategy) {
  let rect;
  if (clippingAncestor === "viewport") {
    rect = getViewportRect(element, strategy);
  } else if (clippingAncestor === "document") {
    rect = getDocumentRect(getDocumentElement(element));
  } else if (isElement(clippingAncestor)) {
    rect = getInnerBoundingClientRect(clippingAncestor, strategy);
  } else {
    const visualOffsets = getVisualOffsets(element);
    rect = {
      x: clippingAncestor.x - visualOffsets.x,
      y: clippingAncestor.y - visualOffsets.y,
      width: clippingAncestor.width,
      height: clippingAncestor.height
    };
  }
  return rectToClientRect(rect);
}
function hasFixedPositionAncestor(element, stopNode) {
  const parentNode = getParentNode(element);
  if (parentNode === stopNode || !isElement(parentNode) || isLastTraversableNode(parentNode)) {
    return false;
  }
  return getComputedStyle2(parentNode).position === "fixed" || hasFixedPositionAncestor(parentNode, stopNode);
}
function getClippingElementAncestors(element, cache) {
  const cachedResult = cache.get(element);
  if (cachedResult) {
    return cachedResult;
  }
  let result = getOverflowAncestors(element, [], false).filter((el) => isElement(el) && getNodeName(el) !== "body");
  let currentContainingBlockComputedStyle = null;
  const elementIsFixed = getComputedStyle2(element).position === "fixed";
  let currentNode = elementIsFixed ? getParentNode(element) : element;
  while (isElement(currentNode) && !isLastTraversableNode(currentNode)) {
    const computedStyle = getComputedStyle2(currentNode);
    const currentNodeIsContaining = isContainingBlock(currentNode);
    if (!currentNodeIsContaining && computedStyle.position === "fixed") {
      currentContainingBlockComputedStyle = null;
    }
    const shouldDropCurrentNode = elementIsFixed ? !currentNodeIsContaining && !currentContainingBlockComputedStyle : !currentNodeIsContaining && computedStyle.position === "static" && !!currentContainingBlockComputedStyle && (currentContainingBlockComputedStyle.position === "absolute" || currentContainingBlockComputedStyle.position === "fixed") || isOverflowElement(currentNode) && !currentNodeIsContaining && hasFixedPositionAncestor(element, currentNode);
    if (shouldDropCurrentNode) {
      result = result.filter((ancestor) => ancestor !== currentNode);
    } else {
      currentContainingBlockComputedStyle = computedStyle;
    }
    currentNode = getParentNode(currentNode);
  }
  cache.set(element, result);
  return result;
}
function getClippingRect(_ref) {
  let {
    element,
    boundary,
    rootBoundary,
    strategy
  } = _ref;
  const elementClippingAncestors = boundary === "clippingAncestors" ? isTopLayer(element) ? [] : getClippingElementAncestors(element, this._c) : [].concat(boundary);
  const clippingAncestors = [...elementClippingAncestors, rootBoundary];
  const firstRect = getClientRectFromClippingAncestor(element, clippingAncestors[0], strategy);
  let top = firstRect.top;
  let right = firstRect.right;
  let bottom = firstRect.bottom;
  let left = firstRect.left;
  for (let i2 = 1; i2 < clippingAncestors.length; i2++) {
    const rect = getClientRectFromClippingAncestor(element, clippingAncestors[i2], strategy);
    top = max(rect.top, top);
    right = min(rect.right, right);
    bottom = min(rect.bottom, bottom);
    left = max(rect.left, left);
  }
  return {
    width: right - left,
    height: bottom - top,
    x: left,
    y: top
  };
}
function getDimensions(element) {
  const {
    width,
    height
  } = getCssDimensions(element);
  return {
    width,
    height
  };
}
function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
  const isOffsetParentAnElement = isHTMLElement(offsetParent);
  const documentElement = getDocumentElement(offsetParent);
  const isFixed = strategy === "fixed";
  const rect = getBoundingClientRect(element, true, isFixed, offsetParent);
  let scroll = {
    scrollLeft: 0,
    scrollTop: 0
  };
  const offsets = createCoords(0);
  function setLeftRTLScrollbarOffset() {
    offsets.x = getWindowScrollBarX(documentElement);
  }
  if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
    if (getNodeName(offsetParent) !== "body" || isOverflowElement(documentElement)) {
      scroll = getNodeScroll(offsetParent);
    }
    if (isOffsetParentAnElement) {
      const offsetRect = getBoundingClientRect(offsetParent, true, isFixed, offsetParent);
      offsets.x = offsetRect.x + offsetParent.clientLeft;
      offsets.y = offsetRect.y + offsetParent.clientTop;
    } else if (documentElement) {
      setLeftRTLScrollbarOffset();
    }
  }
  if (isFixed && !isOffsetParentAnElement && documentElement) {
    setLeftRTLScrollbarOffset();
  }
  const htmlOffset = documentElement && !isOffsetParentAnElement && !isFixed ? getHTMLOffset(documentElement, scroll) : createCoords(0);
  const x2 = rect.left + scroll.scrollLeft - offsets.x - htmlOffset.x;
  const y2 = rect.top + scroll.scrollTop - offsets.y - htmlOffset.y;
  return {
    x: x2,
    y: y2,
    width: rect.width,
    height: rect.height
  };
}
function isStaticPositioned(element) {
  return getComputedStyle2(element).position === "static";
}
function getTrueOffsetParent(element, polyfill) {
  if (!isHTMLElement(element) || getComputedStyle2(element).position === "fixed") {
    return null;
  }
  if (polyfill) {
    return polyfill(element);
  }
  let rawOffsetParent = element.offsetParent;
  if (getDocumentElement(element) === rawOffsetParent) {
    rawOffsetParent = rawOffsetParent.ownerDocument.body;
  }
  return rawOffsetParent;
}
function getOffsetParent(element, polyfill) {
  const win = getWindow(element);
  if (isTopLayer(element)) {
    return win;
  }
  if (!isHTMLElement(element)) {
    let svgOffsetParent = getParentNode(element);
    while (svgOffsetParent && !isLastTraversableNode(svgOffsetParent)) {
      if (isElement(svgOffsetParent) && !isStaticPositioned(svgOffsetParent)) {
        return svgOffsetParent;
      }
      svgOffsetParent = getParentNode(svgOffsetParent);
    }
    return win;
  }
  let offsetParent = getTrueOffsetParent(element, polyfill);
  while (offsetParent && isTableElement(offsetParent) && isStaticPositioned(offsetParent)) {
    offsetParent = getTrueOffsetParent(offsetParent, polyfill);
  }
  if (offsetParent && isLastTraversableNode(offsetParent) && isStaticPositioned(offsetParent) && !isContainingBlock(offsetParent)) {
    return win;
  }
  return offsetParent || getContainingBlock(element) || win;
}
var getElementRects = async function(data) {
  const getOffsetParentFn = this.getOffsetParent || getOffsetParent;
  const getDimensionsFn = this.getDimensions;
  const floatingDimensions = await getDimensionsFn(data.floating);
  return {
    reference: getRectRelativeToOffsetParent(data.reference, await getOffsetParentFn(data.floating), data.strategy),
    floating: {
      x: 0,
      y: 0,
      width: floatingDimensions.width,
      height: floatingDimensions.height
    }
  };
};
function isRTL(element) {
  return getComputedStyle2(element).direction === "rtl";
}
var platform2 = {
  convertOffsetParentRelativeRectToViewportRelativeRect,
  getDocumentElement,
  getClippingRect,
  getOffsetParent,
  getElementRects,
  getClientRects,
  getDimensions,
  getScale,
  isElement,
  isRTL
};
function rectsAreEqual(a2, b2) {
  return a2.x === b2.x && a2.y === b2.y && a2.width === b2.width && a2.height === b2.height;
}
function observeMove(element, onMove) {
  let io = null;
  let timeoutId;
  const root = getDocumentElement(element);
  function cleanup() {
    var _io;
    clearTimeout(timeoutId);
    (_io = io) == null || _io.disconnect();
    io = null;
  }
  function refresh(skip, threshold) {
    if (skip === void 0) {
      skip = false;
    }
    if (threshold === void 0) {
      threshold = 1;
    }
    cleanup();
    const elementRectForRootMargin = element.getBoundingClientRect();
    const {
      left,
      top,
      width,
      height
    } = elementRectForRootMargin;
    if (!skip) {
      onMove();
    }
    if (!width || !height) {
      return;
    }
    const insetTop = floor(top);
    const insetRight = floor(root.clientWidth - (left + width));
    const insetBottom = floor(root.clientHeight - (top + height));
    const insetLeft = floor(left);
    const rootMargin = -insetTop + "px " + -insetRight + "px " + -insetBottom + "px " + -insetLeft + "px";
    const options = {
      rootMargin,
      threshold: max(0, min(1, threshold)) || 1
    };
    let isFirstUpdate = true;
    function handleObserve(entries) {
      const ratio = entries[0].intersectionRatio;
      if (ratio !== threshold) {
        if (!isFirstUpdate) {
          return refresh();
        }
        if (!ratio) {
          timeoutId = setTimeout(() => {
            refresh(false, 1e-7);
          }, 1e3);
        } else {
          refresh(false, ratio);
        }
      }
      if (ratio === 1 && !rectsAreEqual(elementRectForRootMargin, element.getBoundingClientRect())) {
        refresh();
      }
      isFirstUpdate = false;
    }
    try {
      io = new IntersectionObserver(handleObserve, {
        ...options,
        // Handle <iframe>s
        root: root.ownerDocument
      });
    } catch (_e) {
      io = new IntersectionObserver(handleObserve, options);
    }
    io.observe(element);
  }
  refresh(true);
  return cleanup;
}
function autoUpdate(reference, floating, update2, options) {
  if (options === void 0) {
    options = {};
  }
  const {
    ancestorScroll = true,
    ancestorResize = true,
    elementResize = typeof ResizeObserver === "function",
    layoutShift = typeof IntersectionObserver === "function",
    animationFrame = false
  } = options;
  const referenceEl = unwrapElement(reference);
  const ancestors = ancestorScroll || ancestorResize ? [...referenceEl ? getOverflowAncestors(referenceEl) : [], ...floating ? getOverflowAncestors(floating) : []] : [];
  ancestors.forEach((ancestor) => {
    ancestorScroll && ancestor.addEventListener("scroll", update2, {
      passive: true
    });
    ancestorResize && ancestor.addEventListener("resize", update2);
  });
  const cleanupIo = referenceEl && layoutShift ? observeMove(referenceEl, update2) : null;
  let reobserveFrame = -1;
  let resizeObserver = null;
  if (elementResize) {
    resizeObserver = new ResizeObserver((_ref) => {
      let [firstEntry] = _ref;
      if (firstEntry && firstEntry.target === referenceEl && resizeObserver && floating) {
        resizeObserver.unobserve(floating);
        cancelAnimationFrame(reobserveFrame);
        reobserveFrame = requestAnimationFrame(() => {
          var _resizeObserver;
          (_resizeObserver = resizeObserver) == null || _resizeObserver.observe(floating);
        });
      }
      update2();
    });
    if (referenceEl && !animationFrame) {
      resizeObserver.observe(referenceEl);
    }
    if (floating) {
      resizeObserver.observe(floating);
    }
  }
  let frameId;
  let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
  if (animationFrame) {
    frameLoop();
  }
  function frameLoop() {
    const nextRefRect = getBoundingClientRect(reference);
    if (prevRefRect && !rectsAreEqual(prevRefRect, nextRefRect)) {
      update2();
    }
    prevRefRect = nextRefRect;
    frameId = requestAnimationFrame(frameLoop);
  }
  update2();
  return () => {
    var _resizeObserver2;
    ancestors.forEach((ancestor) => {
      ancestorScroll && ancestor.removeEventListener("scroll", update2);
      ancestorResize && ancestor.removeEventListener("resize", update2);
    });
    cleanupIo == null || cleanupIo();
    (_resizeObserver2 = resizeObserver) == null || _resizeObserver2.disconnect();
    resizeObserver = null;
    if (animationFrame) {
      cancelAnimationFrame(frameId);
    }
  };
}
var offset2 = offset;
var shift2 = shift;
var flip2 = flip;
var size2 = size;
var hide2 = hide;
var limitShift2 = limitShift;
var computePosition2 = (reference, floating, options) => {
  const cache = /* @__PURE__ */ new Map();
  const mergedOptions = {
    platform: platform2,
    ...options
  };
  const platformWithCache = {
    ...mergedOptions.platform,
    _c: cache
  };
  return computePosition(reference, floating, {
    ...mergedOptions,
    platform: platformWithCache
  });
};

// node_modules/@floating-ui/react-dom/dist/floating-ui.react-dom.mjs
var React20 = __toESM(require_react(), 1);
var import_react2 = __toESM(require_react(), 1);
var ReactDOM3 = __toESM(require_react_dom(), 1);
var isClient = typeof document !== "undefined";
var noop2 = function noop3() {
};
var index = isClient ? import_react2.useLayoutEffect : noop2;
function deepEqual(a2, b2) {
  if (a2 === b2) {
    return true;
  }
  if (typeof a2 !== typeof b2) {
    return false;
  }
  if (typeof a2 === "function" && a2.toString() === b2.toString()) {
    return true;
  }
  let length;
  let i2;
  let keys;
  if (a2 && b2 && typeof a2 === "object") {
    if (Array.isArray(a2)) {
      length = a2.length;
      if (length !== b2.length) return false;
      for (i2 = length; i2-- !== 0; ) {
        if (!deepEqual(a2[i2], b2[i2])) {
          return false;
        }
      }
      return true;
    }
    keys = Object.keys(a2);
    length = keys.length;
    if (length !== Object.keys(b2).length) {
      return false;
    }
    for (i2 = length; i2-- !== 0; ) {
      if (!{}.hasOwnProperty.call(b2, keys[i2])) {
        return false;
      }
    }
    for (i2 = length; i2-- !== 0; ) {
      const key = keys[i2];
      if (key === "_owner" && a2.$$typeof) {
        continue;
      }
      if (!deepEqual(a2[key], b2[key])) {
        return false;
      }
    }
    return true;
  }
  return a2 !== a2 && b2 !== b2;
}
function getDPR(element) {
  if (typeof window === "undefined") {
    return 1;
  }
  const win = element.ownerDocument.defaultView || window;
  return win.devicePixelRatio || 1;
}
function roundByDPR(element, value) {
  const dpr = getDPR(element);
  return Math.round(value * dpr) / dpr;
}
function useLatestRef(value) {
  const ref = React20.useRef(value);
  index(() => {
    ref.current = value;
  });
  return ref;
}
function useFloating(options) {
  if (options === void 0) {
    options = {};
  }
  const {
    placement = "bottom",
    strategy = "absolute",
    middleware = [],
    platform: platform3,
    elements: {
      reference: externalReference,
      floating: externalFloating
    } = {},
    transform = true,
    whileElementsMounted,
    open
  } = options;
  const [data, setData] = React20.useState({
    x: 0,
    y: 0,
    strategy,
    placement,
    middlewareData: {},
    isPositioned: false
  });
  const [latestMiddleware, setLatestMiddleware] = React20.useState(middleware);
  if (!deepEqual(latestMiddleware, middleware)) {
    setLatestMiddleware(middleware);
  }
  const [_reference, _setReference] = React20.useState(null);
  const [_floating, _setFloating] = React20.useState(null);
  const setReference = React20.useCallback((node) => {
    if (node !== referenceRef.current) {
      referenceRef.current = node;
      _setReference(node);
    }
  }, []);
  const setFloating = React20.useCallback((node) => {
    if (node !== floatingRef.current) {
      floatingRef.current = node;
      _setFloating(node);
    }
  }, []);
  const referenceEl = externalReference || _reference;
  const floatingEl = externalFloating || _floating;
  const referenceRef = React20.useRef(null);
  const floatingRef = React20.useRef(null);
  const dataRef = React20.useRef(data);
  const hasWhileElementsMounted = whileElementsMounted != null;
  const whileElementsMountedRef = useLatestRef(whileElementsMounted);
  const platformRef = useLatestRef(platform3);
  const openRef = useLatestRef(open);
  const update2 = React20.useCallback(() => {
    if (!referenceRef.current || !floatingRef.current) {
      return;
    }
    const config = {
      placement,
      strategy,
      middleware: latestMiddleware
    };
    if (platformRef.current) {
      config.platform = platformRef.current;
    }
    computePosition2(referenceRef.current, floatingRef.current, config).then((data2) => {
      const fullData = {
        ...data2,
        // The floating element's position may be recomputed while it's closed
        // but still mounted (such as when transitioning out). To ensure
        // `isPositioned` will be `false` initially on the next open, avoid
        // setting it to `true` when `open === false` (must be specified).
        isPositioned: openRef.current !== false
      };
      if (isMountedRef.current && !deepEqual(dataRef.current, fullData)) {
        dataRef.current = fullData;
        ReactDOM3.flushSync(() => {
          setData(fullData);
        });
      }
    });
  }, [latestMiddleware, placement, strategy, platformRef, openRef]);
  index(() => {
    if (open === false && dataRef.current.isPositioned) {
      dataRef.current.isPositioned = false;
      setData((data2) => ({
        ...data2,
        isPositioned: false
      }));
    }
  }, [open]);
  const isMountedRef = React20.useRef(false);
  index(() => {
    isMountedRef.current = true;
    return () => {
      isMountedRef.current = false;
    };
  }, []);
  index(() => {
    if (referenceEl) referenceRef.current = referenceEl;
    if (floatingEl) floatingRef.current = floatingEl;
    if (referenceEl && floatingEl) {
      if (whileElementsMountedRef.current) {
        return whileElementsMountedRef.current(referenceEl, floatingEl, update2);
      }
      update2();
    }
  }, [referenceEl, floatingEl, update2, whileElementsMountedRef, hasWhileElementsMounted]);
  const refs = React20.useMemo(() => ({
    reference: referenceRef,
    floating: floatingRef,
    setReference,
    setFloating
  }), [setReference, setFloating]);
  const elements2 = React20.useMemo(() => ({
    reference: referenceEl,
    floating: floatingEl
  }), [referenceEl, floatingEl]);
  const floatingStyles = React20.useMemo(() => {
    const initialStyles = {
      position: strategy,
      left: 0,
      top: 0
    };
    if (!elements2.floating) {
      return initialStyles;
    }
    const x2 = roundByDPR(elements2.floating, data.x);
    const y2 = roundByDPR(elements2.floating, data.y);
    if (transform) {
      return {
        ...initialStyles,
        transform: "translate(" + x2 + "px, " + y2 + "px)",
        ...getDPR(elements2.floating) >= 1.5 && {
          willChange: "transform"
        }
      };
    }
    return {
      position: strategy,
      left: x2,
      top: y2
    };
  }, [strategy, transform, elements2.floating, data.x, data.y]);
  return React20.useMemo(() => ({
    ...data,
    update: update2,
    refs,
    elements: elements2,
    floatingStyles
  }), [data, update2, refs, elements2, floatingStyles]);
}
var offset3 = (options, deps) => {
  const result = offset2(options);
  return {
    name: result.name,
    fn: result.fn,
    options: [options, deps]
  };
};
var shift3 = (options, deps) => {
  const result = shift2(options);
  return {
    name: result.name,
    fn: result.fn,
    options: [options, deps]
  };
};
var limitShift3 = (options, deps) => {
  const result = limitShift2(options);
  return {
    fn: result.fn,
    options: [options, deps]
  };
};
var flip3 = (options, deps) => {
  const result = flip2(options);
  return {
    name: result.name,
    fn: result.fn,
    options: [options, deps]
  };
};
var size3 = (options, deps) => {
  const result = size2(options);
  return {
    name: result.name,
    fn: result.fn,
    options: [options, deps]
  };
};
var hide3 = (options, deps) => {
  const result = hide2(options);
  return {
    name: result.name,
    fn: result.fn,
    options: [options, deps]
  };
};

// node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
var React25 = __toESM(require_react(), 1);
var ReactDOM4 = __toESM(require_react_dom(), 1);

// node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
var React24 = __toESM(require_react(), 1);

// node_modules/@base-ui/utils/store/createSelector.mjs
var createSelector = (a2, b2, c2, d2, e2, f2, ...other) => {
  if (other.length > 0) {
    throw new Error(true ? "Unsupported number of selectors" : formatErrorMessage_default(1));
  }
  let selector;
  if (a2 && b2 && c2 && d2 && e2 && f2) {
    selector = (state, a1, a22, a3) => {
      const va = a2(state, a1, a22, a3);
      const vb = b2(state, a1, a22, a3);
      const vc = c2(state, a1, a22, a3);
      const vd = d2(state, a1, a22, a3);
      const ve = e2(state, a1, a22, a3);
      return f2(va, vb, vc, vd, ve, a1, a22, a3);
    };
  } else if (a2 && b2 && c2 && d2 && e2) {
    selector = (state, a1, a22, a3) => {
      const va = a2(state, a1, a22, a3);
      const vb = b2(state, a1, a22, a3);
      const vc = c2(state, a1, a22, a3);
      const vd = d2(state, a1, a22, a3);
      return e2(va, vb, vc, vd, a1, a22, a3);
    };
  } else if (a2 && b2 && c2 && d2) {
    selector = (state, a1, a22, a3) => {
      const va = a2(state, a1, a22, a3);
      const vb = b2(state, a1, a22, a3);
      const vc = c2(state, a1, a22, a3);
      return d2(va, vb, vc, a1, a22, a3);
    };
  } else if (a2 && b2 && c2) {
    selector = (state, a1, a22, a3) => {
      const va = a2(state, a1, a22, a3);
      const vb = b2(state, a1, a22, a3);
      return c2(va, vb, a1, a22, a3);
    };
  } else if (a2 && b2) {
    selector = (state, a1, a22, a3) => {
      const va = a2(state, a1, a22, a3);
      return b2(va, a1, a22, a3);
    };
  } else if (a2) {
    selector = a2;
  } else {
    throw (
      /* minify-error-disabled */
      new Error("Missing arguments")
    );
  }
  return selector;
};

// node_modules/@base-ui/utils/store/useStore.mjs
var React22 = __toESM(require_react(), 1);
var import_shim = __toESM(require_shim(), 1);
var import_with_selector = __toESM(require_with_selector(), 1);

// node_modules/@base-ui/utils/fastHooks.mjs
var React21 = __toESM(require_react(), 1);
var hooks = [];
var currentInstance = void 0;
function getInstance() {
  return currentInstance;
}
function register(hook) {
  hooks.push(hook);
}
function fastComponent(fn) {
  const FastComponent = (props, forwardedRef) => {
    const instance = useRefWithInit(createInstance).current;
    let result;
    try {
      currentInstance = instance;
      for (const hook of hooks) {
        hook.before(instance);
      }
      result = fn(props, forwardedRef);
      for (const hook of hooks) {
        hook.after(instance);
      }
      instance.didInitialize = true;
    } finally {
      currentInstance = void 0;
    }
    return result;
  };
  FastComponent.displayName = fn.displayName || fn.name;
  return FastComponent;
}
function fastComponentRef(fn) {
  return /* @__PURE__ */ React21.forwardRef(fastComponent(fn));
}
function createInstance() {
  return {
    didInitialize: false
  };
}

// node_modules/@base-ui/utils/store/useStore.mjs
var canUseRawUseSyncExternalStore = isReactVersionAtLeast(19);
var useStoreImplementation = canUseRawUseSyncExternalStore ? useStoreFast : useStoreLegacy;
function useStore(store, selector, a1, a2, a3) {
  return useStoreImplementation(store, selector, a1, a2, a3);
}
function useStoreR19(store, selector, a1, a2, a3) {
  const getSelection = React22.useCallback(() => selector(store.getSnapshot(), a1, a2, a3), [store, selector, a1, a2, a3]);
  return (0, import_shim.useSyncExternalStore)(store.subscribe, getSelection, getSelection);
}
register({
  before(instance) {
    instance.syncIndex = 0;
    if (!instance.didInitialize) {
      instance.syncTick = 1;
      instance.syncHooks = [];
      instance.didChangeStore = true;
      instance.getSnapshot = () => {
        let didChange2 = false;
        for (let i2 = 0; i2 < instance.syncHooks.length; i2 += 1) {
          const hook = instance.syncHooks[i2];
          const value = hook.selector(hook.store.state, hook.a1, hook.a2, hook.a3);
          if (!Object.is(hook.value, value)) {
            didChange2 = true;
            hook.value = value;
          }
        }
        if (didChange2) {
          instance.syncTick += 1;
        }
        return instance.syncTick;
      };
    }
  },
  after(instance) {
    if (instance.syncHooks.length > 0) {
      if (instance.didChangeStore) {
        instance.didChangeStore = false;
        instance.subscribe = (onStoreChange) => {
          const stores = /* @__PURE__ */ new Set();
          for (const hook of instance.syncHooks) {
            stores.add(hook.store);
          }
          const unsubscribes = [];
          for (const store of stores) {
            unsubscribes.push(store.subscribe(onStoreChange));
          }
          return () => {
            for (const unsubscribe of unsubscribes) {
              unsubscribe();
            }
          };
        };
      }
      (0, import_shim.useSyncExternalStore)(instance.subscribe, instance.getSnapshot, instance.getSnapshot);
    }
  }
});
function useStoreFast(store, selector, a1, a2, a3) {
  const instance = getInstance();
  if (!instance) {
    return useStoreR19(store, selector, a1, a2, a3);
  }
  const index2 = instance.syncIndex;
  instance.syncIndex += 1;
  let hook;
  if (!instance.didInitialize) {
    hook = {
      store,
      selector,
      a1,
      a2,
      a3,
      value: selector(store.getSnapshot(), a1, a2, a3)
    };
    instance.syncHooks.push(hook);
  } else {
    hook = instance.syncHooks[index2];
    if (hook.store !== store || hook.selector !== selector || !Object.is(hook.a1, a1) || !Object.is(hook.a2, a2) || !Object.is(hook.a3, a3)) {
      if (hook.store !== store) {
        instance.didChangeStore = true;
      }
      hook.store = store;
      hook.selector = selector;
      hook.a1 = a1;
      hook.a2 = a2;
      hook.a3 = a3;
      hook.value = selector(store.getSnapshot(), a1, a2, a3);
    }
  }
  return hook.value;
}
function useStoreLegacy(store, selector, a1, a2, a3) {
  return (0, import_with_selector.useSyncExternalStoreWithSelector)(store.subscribe, store.getSnapshot, store.getSnapshot, (state) => selector(state, a1, a2, a3));
}

// node_modules/@base-ui/utils/store/Store.mjs
var Store = class {
  /**
   * The current state of the store.
   * This property is updated immediately when the state changes as a result of calling {@link setState}, {@link update}, or {@link set}.
   * To subscribe to state changes, use the {@link useState} method. The value returned by {@link useState} is updated after the component renders (similarly to React's useState).
   * The values can be used directly (to avoid subscribing to the store) in effects or event handlers.
   *
   * Do not modify properties in state directly. Instead, use the provided methods to ensure proper state management and listener notification.
   */
  // Internal state to handle recursive `setState()` calls
  constructor(state) {
    this.state = state;
    this.listeners = /* @__PURE__ */ new Set();
    this.updateTick = 0;
  }
  /**
   * Registers a listener that will be called whenever the store's state changes.
   *
   * @param fn The listener function to be called on state changes.
   * @returns A function to unsubscribe the listener.
   */
  subscribe = (fn) => {
    this.listeners.add(fn);
    return () => {
      this.listeners.delete(fn);
    };
  };
  /**
   * Returns the current state of the store.
   */
  getSnapshot = () => {
    return this.state;
  };
  /**
   * Updates the entire store's state and notifies all registered listeners.
   *
   * @param newState The new state to set for the store.
   */
  setState(newState) {
    if (this.state === newState) {
      return;
    }
    this.state = newState;
    this.updateTick += 1;
    const currentTick = this.updateTick;
    for (const listener of this.listeners) {
      if (currentTick !== this.updateTick) {
        return;
      }
      listener(newState);
    }
  }
  /**
   * Merges the provided changes into the current state and notifies listeners if there are changes.
   *
   * @param changes An object containing the changes to apply to the current state.
   */
  update(changes) {
    for (const key in changes) {
      if (!Object.is(this.state[key], changes[key])) {
        this.setState({
          ...this.state,
          ...changes
        });
        return;
      }
    }
  }
  /**
   * Sets a specific key in the store's state to a new value and notifies listeners if the value has changed.
   *
   * @param key The key in the store's state to update.
   * @param value The new value to set for the specified key.
   */
  set(key, value) {
    if (!Object.is(this.state[key], value)) {
      this.setState({
        ...this.state,
        [key]: value
      });
    }
  }
  /**
   * Gives the state a new reference and updates all registered listeners.
   */
  notifyAll() {
    const newState = {
      ...this.state
    };
    this.setState(newState);
  }
  use(selector, a1, a2, a3) {
    return useStore(this, selector, a1, a2, a3);
  }
};

// node_modules/@base-ui/utils/store/ReactStore.mjs
var React23 = __toESM(require_react(), 1);
var ReactStore = class extends Store {
  /**
   * Creates a new ReactStore instance.
   *
   * @param state Initial state of the store.
   * @param context Non-reactive context values.
   * @param selectors Optional selectors for use with `useState`.
   */
  constructor(state, context = {}, selectors3) {
    super(state);
    this.context = context;
    this.selectors = selectors3;
  }
  /**
   * Non-reactive values such as refs, callbacks, etc.
   */
  /**
   * Synchronizes a single external value into the store.
   *
   * Note that the while the value in `state` is updated immediately, the value returned
   * by `useState` is updated before the next render (similarly to React's `useState`).
   */
  useSyncedValue(key, value) {
    React23.useDebugValue(key);
    const store = this;
    useIsoLayoutEffect(() => {
      if (store.state[key] !== value) {
        store.set(key, value);
      }
    }, [store, key, value]);
  }
  /**
   * Synchronizes a single external value into the store and
   * cleans it up (sets to `undefined`) on unmount.
   *
   * Note that the while the value in `state` is updated immediately, the value returned
   * by `useState` is updated before the next render (similarly to React's `useState`).
   */
  useSyncedValueWithCleanup(key, value) {
    const store = this;
    useIsoLayoutEffect(() => {
      if (store.state[key] !== value) {
        store.set(key, value);
      }
      return () => {
        store.set(key, void 0);
      };
    }, [store, key, value]);
  }
  /**
   * Synchronizes multiple external values into the store.
   *
   * Note that the while the values in `state` are updated immediately, the values returned
   * by `useState` are updated before the next render (similarly to React's `useState`).
   */
  useSyncedValues(statePart) {
    const store = this;
    if (true) {
      React23.useDebugValue(statePart, (p3) => Object.keys(p3));
      const keys = React23.useRef(Object.keys(statePart)).current;
      const nextKeys = Object.keys(statePart);
      if (keys.length !== nextKeys.length || keys.some((key, index2) => key !== nextKeys[index2])) {
        console.error("ReactStore.useSyncedValues expects the same prop keys on every render. Keys should be stable.");
      }
    }
    const dependencies = Object.values(statePart);
    useIsoLayoutEffect(() => {
      store.update(statePart);
    }, [store, ...dependencies]);
  }
  /**
   * Registers a controllable prop pair (`controlled`, `defaultValue`) for a specific key. If `controlled`
   * is non-undefined, the store's state at `key` is updated to match `controlled`.
   */
  useControlledProp(key, controlled) {
    React23.useDebugValue(key);
    const store = this;
    const isControlled = controlled !== void 0;
    useIsoLayoutEffect(() => {
      if (isControlled && !Object.is(store.state[key], controlled)) {
        store.setState({
          ...store.state,
          [key]: controlled
        });
      }
    }, [store, key, controlled, isControlled]);
    if (true) {
      const cache = this.controlledValues ??= /* @__PURE__ */ new Map();
      if (!cache.has(key)) {
        cache.set(key, isControlled);
      }
      const previouslyControlled = cache.get(key);
      if (previouslyControlled !== void 0 && previouslyControlled !== isControlled) {
        console.error(`A component is changing the ${isControlled ? "" : "un"}controlled state of ${key.toString()} to be ${isControlled ? "un" : ""}controlled. Elements should not switch from uncontrolled to controlled (or vice versa).`);
      }
    }
  }
  /** Gets the current value from the store using a selector with the provided key.
   *
   * @param key Key of the selector to use.
   */
  select(key, a1, a2, a3) {
    const selector = this.selectors[key];
    return selector(this.state, a1, a2, a3);
  }
  /**
   * Returns a value from the store's state using a selector function.
   * Used to subscribe to specific parts of the state.
   * This methods causes a rerender whenever the selected state changes.
   *
   * @param key Key of the selector to use.
   */
  useState(key, a1, a2, a3) {
    React23.useDebugValue(key);
    return useStore(this, this.selectors[key], a1, a2, a3);
  }
  /**
   * Wraps a function with `useStableCallback` to ensure it has a stable reference
   * and assigns it to the context.
   *
   * @param key Key of the event callback. Must be a function in the context.
   * @param fn Function to assign.
   */
  useContextCallback(key, fn) {
    React23.useDebugValue(key);
    const stableFunction = useStableCallback(fn ?? NOOP);
    this.context[key] = stableFunction;
  }
  /**
   * Returns a stable setter function for a specific key in the store's state.
   * It's commonly used to pass as a ref callback to React elements.
   *
   * @param key Key of the state to set.
   */
  useStateSetter(key) {
    const ref = React23.useRef(void 0);
    if (ref.current === void 0) {
      ref.current = (value) => {
        this.set(key, value);
      };
    }
    return ref.current;
  }
  /**
   * Observes changes derived from the store's selectors and calls the listener when the selected value changes.
   *
   * @param key Key of the selector to observe.
   * @param listener Listener function called when the selector result changes.
   */
  observe(selector, listener) {
    let selectFn;
    if (typeof selector === "function") {
      selectFn = selector;
    } else {
      selectFn = this.selectors[selector];
    }
    let prevValue = selectFn(this.state);
    listener(prevValue, prevValue, this);
    return this.subscribe((nextState) => {
      const nextValue = selectFn(nextState);
      if (!Object.is(prevValue, nextValue)) {
        const oldValue = prevValue;
        prevValue = nextValue;
        listener(nextValue, oldValue, this);
      }
    });
  }
};

// node_modules/@base-ui/react/floating-ui-react/components/FloatingRootStore.mjs
var selectors = {
  open: createSelector((state) => state.open),
  transitionStatus: createSelector((state) => state.transitionStatus),
  domReferenceElement: createSelector((state) => state.domReferenceElement),
  referenceElement: createSelector((state) => state.positionReference ?? state.referenceElement),
  floatingElement: createSelector((state) => state.floatingElement),
  floatingId: createSelector((state) => state.floatingId)
};
var FloatingRootStore = class extends ReactStore {
  constructor(options) {
    const {
      syncOnly,
      nested,
      onOpenChange,
      triggerElements,
      ...initialState
    } = options;
    super({
      ...initialState,
      positionReference: initialState.referenceElement,
      domReferenceElement: initialState.referenceElement
    }, {
      onOpenChange,
      dataRef: {
        current: {}
      },
      events: createEventEmitter(),
      nested,
      triggerElements
    }, selectors);
    this.syncOnly = syncOnly;
  }
  /**
   * Syncs the event used by hover logic to distinguish hover-open from click-like interaction.
   */
  syncOpenEvent = (newOpen, event) => {
    if (!newOpen || !this.state.open || // Prevent a pending hover-open from overwriting a click-open event, while allowing
    // click events to upgrade a hover-open.
    event != null && isClickLikeEvent(event)) {
      this.context.dataRef.current.openEvent = newOpen ? event : void 0;
    }
  };
  /**
   * Runs the root-owned side effects for an open state change.
   */
  dispatchOpenChange = (newOpen, eventDetails) => {
    this.syncOpenEvent(newOpen, eventDetails.event);
    const details = {
      open: newOpen,
      reason: eventDetails.reason,
      nativeEvent: eventDetails.event,
      nested: this.context.nested,
      triggerElement: eventDetails.trigger
    };
    this.context.events.emit("openchange", details);
  };
  /**
   * Emits the `openchange` event through the internal event emitter and calls the `onOpenChange` handler with the provided arguments.
   *
   * @param newOpen The new open state.
   * @param eventDetails Details about the event that triggered the open state change.
   */
  setOpen = (newOpen, eventDetails) => {
    if (this.syncOnly) {
      this.context.onOpenChange?.(newOpen, eventDetails);
      return;
    }
    this.dispatchOpenChange(newOpen, eventDetails);
    this.context.onOpenChange?.(newOpen, eventDetails);
  };
};

// node_modules/@base-ui/react/floating-ui-react/hooks/useSyncedFloatingRootContext.mjs
function useSyncedFloatingRootContext(options) {
  const {
    popupStore,
    treatPopupAsFloatingElement = false,
    floatingRootContext: floatingRootContextProp,
    floatingId,
    nested,
    onOpenChange
  } = options;
  const open = popupStore.useState("open");
  const referenceElement = popupStore.useState("activeTriggerElement");
  const floatingElement = popupStore.useState(treatPopupAsFloatingElement ? "popupElement" : "positionerElement");
  const triggerElements = popupStore.context.triggerElements;
  const handleOpenChange = onOpenChange;
  const internalStoreRef = React24.useRef(null);
  if (floatingRootContextProp === void 0 && internalStoreRef.current === null) {
    internalStoreRef.current = new FloatingRootStore({
      open,
      transitionStatus: void 0,
      referenceElement,
      floatingElement,
      triggerElements,
      onOpenChange: handleOpenChange,
      floatingId,
      syncOnly: true,
      nested
    });
  }
  const store = floatingRootContextProp ?? internalStoreRef.current;
  popupStore.useSyncedValue("floatingId", floatingId);
  useIsoLayoutEffect(() => {
    const valuesToSync = {
      open,
      floatingId,
      referenceElement,
      floatingElement
    };
    if (isElement(referenceElement)) {
      valuesToSync.domReferenceElement = referenceElement;
    }
    if (store.state.positionReference === store.state.referenceElement) {
      valuesToSync.positionReference = referenceElement;
    }
    store.update(valuesToSync);
  }, [open, floatingId, referenceElement, floatingElement, store]);
  store.context.onOpenChange = handleOpenChange;
  store.context.nested = nested;
  return store;
}

// node_modules/@base-ui/react/utils/popups/popupStoreUtils.mjs
var FOCUSABLE_POPUP_PROPS = {
  tabIndex: -1,
  [FOCUSABLE_ATTRIBUTE]: ""
};
function usePopupStore(externalStore, createStore, treatPopupAsFloatingElement = false) {
  const floatingId = useId();
  const nested = useFloatingParentNodeId() != null;
  const internalStoreRef = React25.useRef(null);
  if (externalStore === void 0 && internalStoreRef.current === null) {
    internalStoreRef.current = createStore(floatingId, nested);
  }
  const store = externalStore ?? internalStoreRef.current;
  useSyncedFloatingRootContext({
    popupStore: store,
    treatPopupAsFloatingElement,
    floatingRootContext: store.state.floatingRootContext,
    floatingId,
    nested,
    onOpenChange: store.setOpen
  });
  return {
    store,
    internalStore: internalStoreRef.current
  };
}
function useTriggerRegistration(id, store) {
  const registeredElementIdRef = React25.useRef(null);
  const registeredElementRef = React25.useRef(null);
  return React25.useCallback((element) => {
    if (id === void 0) {
      return;
    }
    let shouldSyncTriggerCount = false;
    if (registeredElementIdRef.current !== null) {
      const registeredId = registeredElementIdRef.current;
      const registeredElement = registeredElementRef.current;
      const currentElement = store.context.triggerElements.getById(registeredId);
      if (registeredElement && currentElement === registeredElement) {
        store.context.triggerElements.delete(registeredId);
        shouldSyncTriggerCount = true;
      }
      registeredElementIdRef.current = null;
      registeredElementRef.current = null;
    }
    if (element !== null) {
      registeredElementIdRef.current = id;
      registeredElementRef.current = element;
      store.context.triggerElements.add(id, element);
      shouldSyncTriggerCount = true;
    }
    if (shouldSyncTriggerCount) {
      const triggerCount = store.context.triggerElements.size;
      if (store.select("open") && store.state.triggerCount !== triggerCount) {
        store.set("triggerCount", triggerCount);
      }
    }
  }, [store, id]);
}
function setPopupOpenState(state, open, trigger, preventUnmountOnClose = false) {
  if (open) {
    state.preventUnmountingOnClose = false;
  } else if (preventUnmountOnClose) {
    state.preventUnmountingOnClose = true;
  }
  const triggerId = trigger?.id ?? null;
  if (triggerId || open) {
    state.activeTriggerId = triggerId;
    state.activeTriggerElement = trigger ?? null;
  }
}
function attachPreventUnmountOnClose(eventDetails) {
  let preventUnmountOnClose = false;
  eventDetails.preventUnmountOnClose = () => {
    preventUnmountOnClose = true;
  };
  return () => preventUnmountOnClose;
}
function applyPopupOpenChange(store, nextOpen, eventDetails, options = {}) {
  const reason = eventDetails.reason;
  const isHover = reason === reason_parts_exports.triggerHover;
  const isFocusOpen = nextOpen && reason === reason_parts_exports.triggerFocus;
  const isDismissClose = !nextOpen && (reason === reason_parts_exports.triggerPress || reason === reason_parts_exports.escapeKey);
  const shouldPreventUnmountOnClose = attachPreventUnmountOnClose(eventDetails);
  store.context.onOpenChange?.(nextOpen, eventDetails);
  if (eventDetails.isCanceled) {
    return;
  }
  options.onBeforeDispatch?.();
  store.state.floatingRootContext.dispatchOpenChange(nextOpen, eventDetails);
  const changeState = () => {
    const updatedState = {
      ...options.extraState,
      open: nextOpen
    };
    if (isFocusOpen) {
      updatedState.instantType = "focus";
    } else if (isDismissClose) {
      updatedState.instantType = "dismiss";
    } else if (isHover) {
      updatedState.instantType = void 0;
    }
    setPopupOpenState(updatedState, nextOpen, eventDetails.trigger, shouldPreventUnmountOnClose());
    store.update(updatedState);
  };
  if (isHover) {
    ReactDOM4.flushSync(changeState);
  } else {
    changeState();
  }
}
function useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerId) {
  useOnFirstRender(() => {
    if (openProp === void 0 && store.state.open === false && defaultOpen) {
      store.state = {
        ...store.state,
        open: true,
        activeTriggerId: defaultTriggerId,
        preventUnmountingOnClose: false
      };
    }
  });
}
function useTriggerDataForwarding(triggerId, triggerElementRef, store, stateUpdates) {
  const isMountedByThisTrigger = store.useState("isMountedByTrigger", triggerId);
  const baseRegisterTrigger = useTriggerRegistration(triggerId, store);
  const registerTrigger = useStableCallback((element) => {
    baseRegisterTrigger(element);
    if (!element) {
      return;
    }
    const open = store.select("open");
    const activeTriggerId = store.select("activeTriggerId");
    if (activeTriggerId === triggerId) {
      store.update({
        activeTriggerElement: element,
        ...open ? stateUpdates : null
      });
      return;
    }
    if (activeTriggerId == null && open) {
      store.update({
        activeTriggerId: triggerId,
        activeTriggerElement: element,
        ...stateUpdates
      });
    }
  });
  useIsoLayoutEffect(() => {
    if (isMountedByThisTrigger) {
      store.update({
        activeTriggerElement: triggerElementRef.current,
        ...stateUpdates
      });
    }
  }, [isMountedByThisTrigger, store, triggerElementRef, ...Object.values(stateUpdates)]);
  return {
    registerTrigger,
    isMountedByThisTrigger
  };
}
function useImplicitActiveTrigger(store, options = {}) {
  const {
    closeOnActiveTriggerUnmount = false
  } = options;
  const open = store.useState("open");
  const reactiveTriggerCount = store.useState("triggerCount");
  useIsoLayoutEffect(() => {
    if (!open) {
      if (store.state.triggerCount !== 0) {
        store.set("triggerCount", 0);
      }
      return;
    }
    const triggerCount = store.context.triggerElements.size;
    const stateUpdates = {};
    if (store.state.triggerCount !== triggerCount) {
      stateUpdates.triggerCount = triggerCount;
    }
    const activeTriggerId = store.select("activeTriggerId");
    let lostActiveTriggerId = null;
    if (activeTriggerId) {
      const activeTriggerElement = store.context.triggerElements.getById(activeTriggerId);
      if (!activeTriggerElement) {
        lostActiveTriggerId = activeTriggerId;
      } else if (activeTriggerElement !== store.state.activeTriggerElement) {
        stateUpdates.activeTriggerElement = activeTriggerElement;
      }
    }
    if (!lostActiveTriggerId && !activeTriggerId && triggerCount === 1) {
      const iteratorResult = store.context.triggerElements.entries().next();
      if (!iteratorResult.done) {
        const [implicitTriggerId, implicitTriggerElement] = iteratorResult.value;
        stateUpdates.activeTriggerId = implicitTriggerId;
        stateUpdates.activeTriggerElement = implicitTriggerElement;
      }
    }
    if (stateUpdates.triggerCount !== void 0 || stateUpdates.activeTriggerId !== void 0 || stateUpdates.activeTriggerElement !== void 0) {
      store.update(stateUpdates);
    }
    if (lostActiveTriggerId) {
      if (closeOnActiveTriggerUnmount) {
        queueMicrotask(() => {
          if (store.select("open") && store.select("activeTriggerId") === lostActiveTriggerId && !store.context.triggerElements.getById(lostActiveTriggerId)) {
            const eventDetails = createChangeEventDetails(reason_parts_exports.none);
            store.setOpen(false, eventDetails);
            if (!eventDetails.isCanceled) {
              store.update({
                activeTriggerId: null,
                activeTriggerElement: null
              });
            }
          }
        });
      }
    }
  }, [open, store, reactiveTriggerCount, closeOnActiveTriggerUnmount]);
}
function useOpenStateTransitions(open, store, onUnmount) {
  const {
    mounted,
    setMounted,
    transitionStatus
  } = useTransitionStatus(open);
  const preventUnmountingOnClose = store.useState("preventUnmountingOnClose");
  const syncedPreventUnmountingOnClose = open ? false : preventUnmountingOnClose;
  store.useSyncedValues({
    mounted,
    transitionStatus,
    preventUnmountingOnClose: syncedPreventUnmountingOnClose
  });
  const forceUnmount = useStableCallback(() => {
    setMounted(false);
    store.update({
      activeTriggerId: null,
      activeTriggerElement: null,
      mounted: false,
      preventUnmountingOnClose: false
    });
    onUnmount?.();
    store.context.onOpenChangeComplete?.(false);
  });
  useOpenChangeComplete({
    enabled: mounted && !open && !syncedPreventUnmountingOnClose,
    open,
    ref: store.context.popupRef,
    onComplete() {
      if (!open) {
        forceUnmount();
      }
    }
  });
  return {
    forceUnmount,
    transitionStatus
  };
}
function usePopupInteractionProps(store, statePart) {
  store.useSyncedValues(statePart);
  useIsoLayoutEffect(() => () => {
    store.update({
      activeTriggerProps: EMPTY_OBJECT,
      inactiveTriggerProps: EMPTY_OBJECT,
      popupProps: EMPTY_OBJECT
    });
  }, [store]);
}

// node_modules/@base-ui/react/utils/popups/popupTriggerMap.mjs
var PopupTriggerMap = class {
  constructor() {
    this.elementsSet = /* @__PURE__ */ new Set();
    this.idMap = /* @__PURE__ */ new Map();
  }
  /**
   * Adds a trigger element with the given ID.
   *
   * Note: The provided element is assumed to not be registered under multiple IDs.
   */
  add(id, element) {
    const existingElement = this.idMap.get(id);
    if (existingElement === element) {
      return;
    }
    if (existingElement !== void 0) {
      this.elementsSet.delete(existingElement);
    }
    this.elementsSet.add(element);
    this.idMap.set(id, element);
    if (true) {
      if (this.elementsSet.size !== this.idMap.size) {
        throw new Error("Base UI: A trigger element cannot be registered under multiple IDs in PopupTriggerMap.");
      }
    }
  }
  /**
   * Removes the trigger element with the given ID.
   */
  delete(id) {
    const element = this.idMap.get(id);
    if (element) {
      this.elementsSet.delete(element);
      this.idMap.delete(id);
    }
  }
  /**
   * Whether the given element is registered as a trigger.
   */
  hasElement(element) {
    return this.elementsSet.has(element);
  }
  /**
   * Whether there is a registered trigger element matching the given predicate.
   */
  hasMatchingElement(predicate) {
    for (const element of this.elementsSet) {
      if (predicate(element)) {
        return true;
      }
    }
    return false;
  }
  /**
   * Returns the trigger element associated with the given ID, or undefined if no such element exists.
   */
  getById(id) {
    return this.idMap.get(id);
  }
  /**
   * Returns an iterable of all registered trigger entries, where each entry is a tuple of [id, element].
   */
  entries() {
    return this.idMap.entries();
  }
  /**
   * Returns an iterable of all registered trigger elements.
   */
  elements() {
    return this.elementsSet.values();
  }
  /**
   * Returns the number of registered trigger elements.
   */
  get size() {
    return this.idMap.size;
  }
};

// node_modules/@base-ui/react/floating-ui-react/utils/getEmptyRootContext.mjs
function getEmptyRootContext() {
  return new FloatingRootStore({
    open: false,
    transitionStatus: void 0,
    floatingElement: null,
    referenceElement: null,
    triggerElements: new PopupTriggerMap(),
    floatingId: void 0,
    syncOnly: false,
    nested: false,
    onOpenChange: void 0
  });
}

// node_modules/@base-ui/react/utils/popups/store.mjs
function createInitialPopupStoreState() {
  return {
    open: false,
    openProp: void 0,
    mounted: false,
    transitionStatus: void 0,
    floatingRootContext: getEmptyRootContext(),
    floatingId: void 0,
    triggerCount: 0,
    preventUnmountingOnClose: false,
    payload: void 0,
    activeTriggerId: null,
    activeTriggerElement: null,
    triggerIdProp: void 0,
    popupElement: null,
    positionerElement: null,
    activeTriggerProps: EMPTY_OBJECT,
    inactiveTriggerProps: EMPTY_OBJECT,
    popupProps: EMPTY_OBJECT
  };
}
function createPopupFloatingRootContext(triggerElements, floatingId, nested = false) {
  return new FloatingRootStore({
    open: false,
    transitionStatus: void 0,
    floatingElement: null,
    referenceElement: null,
    triggerElements,
    floatingId,
    syncOnly: true,
    nested,
    onOpenChange: void 0
  });
}
var activeTriggerIdSelector = createSelector((state) => state.triggerIdProp ?? state.activeTriggerId);
var openSelector = createSelector((state) => state.openProp ?? state.open);
var popupIdSelector = createSelector((state) => {
  const popupId = state.popupElement?.id ?? state.floatingId;
  return popupId || void 0;
});
function triggerOwnsOpenPopup(state, triggerId) {
  return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) === triggerId;
}
function triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) {
  if (triggerOwnsOpenPopup(state, triggerId)) {
    return true;
  }
  return triggerId !== void 0 && openSelector(state) && activeTriggerIdSelector(state) == null && state.triggerCount === 1;
}
var popupStoreSelectors = {
  open: openSelector,
  mounted: createSelector((state) => state.mounted),
  transitionStatus: createSelector((state) => state.transitionStatus),
  floatingRootContext: createSelector((state) => state.floatingRootContext),
  triggerCount: createSelector((state) => state.triggerCount),
  preventUnmountingOnClose: createSelector((state) => state.preventUnmountingOnClose),
  payload: createSelector((state) => state.payload),
  activeTriggerId: activeTriggerIdSelector,
  activeTriggerElement: createSelector((state) => state.mounted ? state.activeTriggerElement : null),
  popupId: popupIdSelector,
  /**
   * Whether the trigger with the given ID was used to open the popup.
   */
  isTriggerActive: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId),
  /**
   * Whether the popup is open and was activated by a trigger with the given ID.
   */
  isOpenedByTrigger: createSelector((state, triggerId) => triggerOwnsOpenPopup(state, triggerId)),
  /**
   * Whether the popup is mounted and was activated by a trigger with the given ID.
   */
  isMountedByTrigger: createSelector((state, triggerId) => triggerId !== void 0 && activeTriggerIdSelector(state) === triggerId && state.mounted),
  triggerProps: createSelector((state, isActive) => isActive ? state.activeTriggerProps : state.inactiveTriggerProps),
  /**
   * Popup id for the trigger that currently owns the open popup.
   */
  triggerPopupId: createSelector((state, triggerId) => triggerOwnsOpenPopupOrIsOnlyTrigger(state, triggerId) ? popupIdSelector(state) : void 0),
  popupProps: createSelector((state) => state.popupProps),
  popupElement: createSelector((state) => state.popupElement),
  positionerElement: createSelector((state) => state.positionerElement)
};

// node_modules/@base-ui/react/floating-ui-react/hooks/useFloatingRootContext.mjs
function useFloatingRootContext(options) {
  const {
    open = false,
    onOpenChange,
    elements: elements2 = {}
  } = options;
  const floatingId = useId();
  const nested = useFloatingParentNodeId() != null;
  if (true) {
    const optionDomReference = elements2.reference;
    if (optionDomReference && !isElement(optionDomReference)) {
      console.error("Cannot pass a virtual element to the `elements.reference` option,", "as it must be a real DOM element. Use `context.setPositionReference()`", "instead.");
    }
  }
  const store = useRefWithInit(() => new FloatingRootStore({
    open,
    transitionStatus: void 0,
    onOpenChange,
    referenceElement: elements2.reference ?? null,
    floatingElement: elements2.floating ?? null,
    triggerElements: new PopupTriggerMap(),
    floatingId,
    syncOnly: false,
    nested
  })).current;
  useIsoLayoutEffect(() => {
    const valuesToSync = {
      open,
      floatingId
    };
    if (elements2.reference !== void 0) {
      valuesToSync.referenceElement = elements2.reference;
      valuesToSync.domReferenceElement = isElement(elements2.reference) ? elements2.reference : null;
    }
    if (elements2.floating !== void 0) {
      valuesToSync.floatingElement = elements2.floating;
    }
    store.update(valuesToSync);
  }, [open, floatingId, elements2.reference, elements2.floating, store]);
  store.context.onOpenChange = onOpenChange;
  store.context.nested = nested;
  return store;
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useFloating.mjs
function useFloating2(options = {}) {
  const {
    nodeId,
    externalTree
  } = options;
  const internalStore = useFloatingRootContext(options);
  const store = options.rootContext || internalStore;
  const referenceElement = store.useState("referenceElement");
  const floatingElement = store.useState("floatingElement");
  const domReferenceElement = store.useState("domReferenceElement");
  const open = store.useState("open");
  const floatingId = store.useState("floatingId");
  const [positionReference, setPositionReferenceRaw] = React26.useState(null);
  const [localDomReference, setLocalDomReference] = React26.useState(void 0);
  const [localFloatingElement, setLocalFloatingElement] = React26.useState(void 0);
  const domReferenceRef = React26.useRef(null);
  const tree = useFloatingTree(externalTree);
  const storeElements = React26.useMemo(() => ({
    reference: referenceElement,
    floating: floatingElement,
    domReference: domReferenceElement
  }), [referenceElement, floatingElement, domReferenceElement]);
  const position = useFloating({
    ...options,
    elements: {
      ...storeElements,
      ...positionReference && {
        reference: positionReference
      }
    }
  });
  const localDomReferenceElement = isElement(localDomReference) ? localDomReference : null;
  const syncedFloatingElement = localFloatingElement === void 0 ? store.state.floatingElement : localFloatingElement;
  store.useSyncedValue("referenceElement", localDomReference ?? null);
  store.useSyncedValue("domReferenceElement", localDomReference === void 0 ? domReferenceElement : localDomReferenceElement);
  store.useSyncedValue("floatingElement", syncedFloatingElement);
  const setPositionReference = React26.useCallback((node) => {
    const computedPositionReference = isElement(node) ? {
      getBoundingClientRect: () => node.getBoundingClientRect(),
      getClientRects: () => node.getClientRects(),
      contextElement: node
    } : node;
    setPositionReferenceRaw(computedPositionReference);
    position.refs.setReference(computedPositionReference);
  }, [position.refs]);
  const setReference = React26.useCallback((node) => {
    if (isElement(node) || node === null) {
      domReferenceRef.current = node;
      setLocalDomReference(node);
    }
    if (isElement(position.refs.reference.current) || position.refs.reference.current === null || // Don't allow setting virtual elements using the old technique back to
    // `null` to support `positionReference` + an unstable `reference`
    // callback ref.
    node !== null && !isElement(node)) {
      position.refs.setReference(node);
    }
  }, [position.refs, setLocalDomReference]);
  const setFloating = React26.useCallback((node) => {
    setLocalFloatingElement(node);
    position.refs.setFloating(node);
  }, [position.refs]);
  const refs = React26.useMemo(() => ({
    ...position.refs,
    setReference,
    setFloating,
    setPositionReference,
    domReference: domReferenceRef
  }), [position.refs, setReference, setFloating, setPositionReference]);
  const elements2 = React26.useMemo(() => ({
    ...position.elements,
    domReference: domReferenceElement
  }), [position.elements, domReferenceElement]);
  const context = React26.useMemo(() => ({
    ...position,
    dataRef: store.context.dataRef,
    open,
    onOpenChange: store.setOpen,
    events: store.context.events,
    floatingId,
    refs,
    elements: elements2,
    nodeId,
    rootStore: store
  }), [position, refs, elements2, nodeId, store, open, floatingId]);
  useIsoLayoutEffect(() => {
    if (domReferenceElement) {
      domReferenceRef.current = domReferenceElement;
    }
  }, [domReferenceElement]);
  useIsoLayoutEffect(() => {
    store.context.dataRef.current.floatingContext = context;
    const node = tree?.nodesRef.current.find((n2) => n2.id === nodeId);
    if (node) {
      node.context = context;
    }
  });
  return React26.useMemo(() => ({
    ...position,
    context,
    refs,
    elements: elements2,
    rootStore: store
  }), [position, refs, elements2, context, store]);
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useFocus.mjs
var React27 = __toESM(require_react(), 1);
var isMacSafari = parts_exports.os.mac && parts_exports.engine.webkit;
function useFocus(context, props = {}) {
  const {
    enabled = true,
    delay
  } = props;
  const store = "rootStore" in context ? context.rootStore : context;
  const {
    events,
    dataRef
  } = store.context;
  const blockFocusRef = React27.useRef(false);
  const blockedReferenceRef = React27.useRef(null);
  const keyboardModalityRef = React27.useRef(true);
  const timeout = useTimeout();
  React27.useEffect(() => {
    const domReference = store.select("domReferenceElement");
    if (!enabled) {
      return void 0;
    }
    const win = getWindow(domReference);
    function onBlur() {
      const currentDomReference = store.select("domReferenceElement");
      if (!store.select("open") && isHTMLElement(currentDomReference) && currentDomReference === activeElement(ownerDocument(currentDomReference))) {
        blockFocusRef.current = true;
      }
    }
    function onKeyDown() {
      keyboardModalityRef.current = true;
    }
    function onPointerDown() {
      keyboardModalityRef.current = false;
    }
    return mergeCleanups(addEventListener(win, "blur", onBlur), isMacSafari && addEventListener(win, "keydown", onKeyDown, true), isMacSafari && addEventListener(win, "pointerdown", onPointerDown, true));
  }, [store, enabled]);
  React27.useEffect(() => {
    if (!enabled) {
      return void 0;
    }
    function onOpenChangeLocal(details) {
      if (details.reason === reason_parts_exports.triggerPress || details.reason === reason_parts_exports.escapeKey) {
        const referenceElement = store.select("domReferenceElement");
        if (isElement(referenceElement)) {
          blockedReferenceRef.current = referenceElement;
          blockFocusRef.current = true;
        }
      }
    }
    events.on("openchange", onOpenChangeLocal);
    return () => {
      events.off("openchange", onOpenChangeLocal);
    };
  }, [events, enabled, store]);
  const reference = React27.useMemo(() => {
    function resetBlockedFocus() {
      blockFocusRef.current = false;
      blockedReferenceRef.current = null;
    }
    return {
      onMouseLeave() {
        resetBlockedFocus();
      },
      onFocus(event) {
        const focusTarget = event.currentTarget;
        if (blockFocusRef.current) {
          if (blockedReferenceRef.current === focusTarget) {
            return;
          }
          resetBlockedFocus();
        }
        const target = getTarget(event.nativeEvent);
        if (isElement(target)) {
          if (isMacSafari && !event.relatedTarget) {
            if (!keyboardModalityRef.current && !isTypeableElement(target)) {
              return;
            }
          } else if (!matchesFocusVisible(target)) {
            return;
          }
        }
        const movedFromOtherEnabledTrigger = isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements);
        const {
          nativeEvent,
          currentTarget
        } = event;
        const delayValue = typeof delay === "function" ? delay() : delay;
        if (store.select("open") && movedFromOtherEnabledTrigger || delayValue === 0 || delayValue === void 0) {
          store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
          return;
        }
        timeout.start(delayValue, () => {
          if (blockFocusRef.current) {
            return;
          }
          store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent, currentTarget));
        });
      },
      onBlur(event) {
        resetBlockedFocus();
        const relatedTarget = event.relatedTarget;
        const nativeEvent = event.nativeEvent;
        const movedToFocusGuard = isElement(relatedTarget) && relatedTarget.hasAttribute(createAttribute("focus-guard")) && relatedTarget.getAttribute("data-type") === "outside";
        timeout.start(0, () => {
          const domReference = store.select("domReferenceElement");
          const activeEl = activeElement(ownerDocument(domReference));
          if (!relatedTarget && activeEl === domReference) {
            return;
          }
          if (contains(dataRef.current.floatingContext?.refs.floating.current, activeEl) || contains(domReference, activeEl) || movedToFocusGuard) {
            return;
          }
          const nextFocusedElement = relatedTarget ?? activeEl;
          if (isTargetInsideEnabledTrigger(nextFocusedElement, store.context.triggerElements)) {
            return;
          }
          store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerFocus, nativeEvent));
        });
      }
    };
  }, [dataRef, delay, store, timeout]);
  return React27.useMemo(() => enabled ? {
    reference,
    trigger: reference
  } : {}, [enabled, reference]);
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
var React28 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverInteractionSharedState.mjs
var HoverInteraction = class _HoverInteraction {
  constructor() {
    this.pointerType = void 0;
    this.interactedInside = false;
    this.handler = void 0;
    this.blockMouseMove = true;
    this.performedPointerEventsMutation = false;
    this.pointerEventsScopeElement = null;
    this.pointerEventsReferenceElement = null;
    this.pointerEventsFloatingElement = null;
    this.restTimeoutPending = false;
    this.openChangeTimeout = new Timeout();
    this.restTimeout = new Timeout();
    this.handleCloseOptions = void 0;
  }
  static create() {
    return new _HoverInteraction();
  }
  dispose = () => {
    this.openChangeTimeout.clear();
    this.restTimeout.clear();
  };
  disposeEffect = () => {
    return this.dispose;
  };
};
var pointerEventsMutationOwnerByScopeElement = /* @__PURE__ */ new WeakMap();
function clearSafePolygonPointerEventsMutation(instance) {
  if (!instance.performedPointerEventsMutation) {
    return;
  }
  const scopeElement = instance.pointerEventsScopeElement;
  if (scopeElement && pointerEventsMutationOwnerByScopeElement.get(scopeElement) === instance) {
    instance.pointerEventsScopeElement?.style.removeProperty("pointer-events");
    instance.pointerEventsReferenceElement?.style.removeProperty("pointer-events");
    instance.pointerEventsFloatingElement?.style.removeProperty("pointer-events");
    pointerEventsMutationOwnerByScopeElement.delete(scopeElement);
  }
  instance.performedPointerEventsMutation = false;
  instance.pointerEventsScopeElement = null;
  instance.pointerEventsReferenceElement = null;
  instance.pointerEventsFloatingElement = null;
}
function applySafePolygonPointerEventsMutation(instance, options) {
  const {
    scopeElement,
    referenceElement,
    floatingElement
  } = options;
  const existingOwner = pointerEventsMutationOwnerByScopeElement.get(scopeElement);
  if (existingOwner && existingOwner !== instance) {
    clearSafePolygonPointerEventsMutation(existingOwner);
  }
  clearSafePolygonPointerEventsMutation(instance);
  instance.performedPointerEventsMutation = true;
  instance.pointerEventsScopeElement = scopeElement;
  instance.pointerEventsReferenceElement = referenceElement;
  instance.pointerEventsFloatingElement = floatingElement;
  pointerEventsMutationOwnerByScopeElement.set(scopeElement, instance);
  scopeElement.style.pointerEvents = "none";
  referenceElement.style.pointerEvents = "auto";
  floatingElement.style.pointerEvents = "auto";
}
function useHoverInteractionSharedState(store) {
  const data = store.context.dataRef.current;
  const instance = useRefWithInit(() => data.hoverInteractionState ?? HoverInteraction.create()).current;
  if (!data.hoverInteractionState) {
    data.hoverInteractionState = instance;
  }
  useOnMount(data.hoverInteractionState.disposeEffect);
  return data.hoverInteractionState;
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverFloatingInteraction.mjs
function useHoverFloatingInteraction(context, parameters = {}) {
  const {
    enabled = true,
    closeDelay: closeDelayProp = 0,
    nodeId: nodeIdProp
  } = parameters;
  const store = "rootStore" in context ? context.rootStore : context;
  const open = store.useState("open");
  const floatingElement = store.useState("floatingElement");
  const domReferenceElement = store.useState("domReferenceElement");
  const {
    dataRef
  } = store.context;
  const tree = useFloatingTree();
  const parentId = useFloatingParentNodeId();
  const instance = useHoverInteractionSharedState(store);
  const childClosedTimeout = useTimeout();
  const isClickLikeOpenEvent2 = useStableCallback(() => {
    return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
  });
  const isHoverOpen = useStableCallback(() => {
    return isHoverOpenEvent(dataRef.current.openEvent?.type);
  });
  const clearPointerEvents = useStableCallback(() => {
    clearSafePolygonPointerEventsMutation(instance);
  });
  useIsoLayoutEffect(() => {
    if (!open) {
      instance.pointerType = void 0;
      instance.restTimeoutPending = false;
      instance.interactedInside = false;
      clearPointerEvents();
    }
  }, [open, instance, clearPointerEvents]);
  React28.useEffect(() => {
    return clearPointerEvents;
  }, [clearPointerEvents]);
  useIsoLayoutEffect(() => {
    if (!enabled) {
      return void 0;
    }
    if (open && instance.handleCloseOptions?.blockPointerEvents && isHoverOpen() && isElement(domReferenceElement) && floatingElement) {
      const ref = domReferenceElement;
      const floatingEl = floatingElement;
      const doc = ownerDocument(floatingElement);
      const parentFloating = tree?.nodesRef.current.find((node) => node.id === parentId)?.context?.elements.floating;
      if (parentFloating) {
        parentFloating.style.pointerEvents = "";
      }
      const cachedScopeElement = instance.pointerEventsScopeElement !== floatingEl ? instance.pointerEventsScopeElement : null;
      const parentScopeElement = parentFloating !== floatingEl ? parentFloating : null;
      const scopeElement = instance.handleCloseOptions?.getScope?.() ?? cachedScopeElement ?? parentScopeElement ?? ref.closest("[data-rootownerid]") ?? doc.body;
      applySafePolygonPointerEventsMutation(instance, {
        scopeElement,
        referenceElement: ref,
        floatingElement: floatingEl
      });
      return () => {
        clearPointerEvents();
      };
    }
    return void 0;
  }, [enabled, open, domReferenceElement, floatingElement, instance, isHoverOpen, tree, parentId, clearPointerEvents]);
  React28.useEffect(() => {
    if (!enabled) {
      return void 0;
    }
    function hasParentChildren() {
      return !!(tree && parentId && getNodeChildren(tree.nodesRef.current, parentId).length > 0);
    }
    function closeWithDelay(event) {
      const closeDelay = getDelay(closeDelayProp, "close", instance.pointerType);
      const close = () => {
        store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
        tree?.events.emit("floating.closed", event);
      };
      if (closeDelay) {
        instance.openChangeTimeout.start(closeDelay, close);
      } else {
        instance.openChangeTimeout.clear();
        close();
      }
    }
    function handleInteractInside(event) {
      const target = getTarget(event);
      if (!isInteractiveElement(target)) {
        instance.interactedInside = false;
        return;
      }
      instance.interactedInside = target?.closest("[aria-haspopup]") != null;
    }
    function onFloatingMouseEnter() {
      instance.openChangeTimeout.clear();
      childClosedTimeout.clear();
      tree?.events.off("floating.closed", onNodeClosed);
      clearPointerEvents();
    }
    function onFloatingMouseLeave(event) {
      if (hasParentChildren() && tree) {
        tree.events.on("floating.closed", onNodeClosed);
        return;
      }
      if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
        return;
      }
      const currentNodeId = dataRef.current.floatingContext?.nodeId ?? nodeIdProp;
      const relatedTarget = event.relatedTarget;
      const isMovingIntoDescendantFloating = tree && currentNodeId && isElement(relatedTarget) && getNodeChildren(tree.nodesRef.current, currentNodeId, false).some((node) => contains(node.context?.elements.floating, relatedTarget));
      if (isMovingIntoDescendantFloating) {
        return;
      }
      if (instance.handler) {
        instance.handler(event);
        return;
      }
      clearPointerEvents();
      if (isHoverOpen() && !isClickLikeOpenEvent2()) {
        closeWithDelay(event);
      }
    }
    function onNodeClosed(event) {
      if (!tree || !parentId || hasParentChildren()) {
        return;
      }
      childClosedTimeout.start(0, () => {
        tree.events.off("floating.closed", onNodeClosed);
        store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
        tree.events.emit("floating.closed", event);
      });
    }
    const floating = floatingElement;
    return mergeCleanups(floating && addEventListener(floating, "mouseenter", onFloatingMouseEnter), floating && addEventListener(floating, "mouseleave", onFloatingMouseLeave), floating && addEventListener(floating, "pointerdown", handleInteractInside, true), () => {
      tree?.events.off("floating.closed", onNodeClosed);
    });
  }, [enabled, floatingElement, store, dataRef, closeDelayProp, nodeIdProp, isHoverOpen, isClickLikeOpenEvent2, clearPointerEvents, instance, tree, parentId, childClosedTimeout]);
}

// node_modules/@base-ui/react/floating-ui-react/hooks/useHoverReferenceInteraction.mjs
var React29 = __toESM(require_react(), 1);
var ReactDOM5 = __toESM(require_react_dom(), 1);
var EMPTY_REF = {
  current: null
};
function useHoverReferenceInteraction(context, props = {}) {
  const {
    enabled = true,
    delay = 0,
    handleClose = null,
    mouseOnly = false,
    restMs = 0,
    move = true,
    triggerElementRef = EMPTY_REF,
    externalTree,
    isActiveTrigger = true,
    getHandleCloseContext,
    isClosing,
    shouldOpen: shouldOpenProp
  } = props;
  const store = "rootStore" in context ? context.rootStore : context;
  const {
    dataRef,
    events
  } = store.context;
  const tree = useFloatingTree(externalTree);
  const instance = useHoverInteractionSharedState(store);
  const isHoverCloseActiveRef = React29.useRef(false);
  const handleCloseRef = useValueAsRef(handleClose);
  const delayRef = useValueAsRef(delay);
  const restMsRef = useValueAsRef(restMs);
  const enabledRef = useValueAsRef(enabled);
  const shouldOpenRef = useValueAsRef(shouldOpenProp);
  const isClosingRef = useValueAsRef(isClosing);
  const isClickLikeOpenEvent2 = useStableCallback(() => {
    return isClickLikeOpenEvent(dataRef.current.openEvent?.type, instance.interactedInside);
  });
  const checkShouldOpen = useStableCallback(() => {
    return shouldOpenRef.current?.() !== false;
  });
  const isOverInactiveTrigger = useStableCallback((currentDomReference, currentTarget, target) => {
    const allTriggers = store.context.triggerElements;
    if (allTriggers.hasElement(currentTarget)) {
      return !currentDomReference || !contains(currentDomReference, currentTarget);
    }
    if (!isElement(target)) {
      return false;
    }
    const targetElement = target;
    return allTriggers.hasMatchingElement((trigger) => contains(trigger, targetElement)) && (!currentDomReference || !contains(currentDomReference, targetElement));
  });
  const cleanupMouseMoveHandler = useStableCallback(() => {
    if (!instance.handler) {
      return;
    }
    const doc = ownerDocument(store.select("domReferenceElement"));
    doc.removeEventListener("mousemove", instance.handler);
    instance.handler = void 0;
  });
  const clearPointerEvents = useStableCallback(() => {
    clearSafePolygonPointerEventsMutation(instance);
  });
  if (isActiveTrigger) {
    instance.handleCloseOptions = handleCloseRef.current?.__options;
  }
  React29.useEffect(() => cleanupMouseMoveHandler, [cleanupMouseMoveHandler]);
  React29.useEffect(() => {
    if (!enabled) {
      return void 0;
    }
    function onOpenChangeLocal(details) {
      if (!details.open) {
        isHoverCloseActiveRef.current = details.reason === reason_parts_exports.triggerHover;
        cleanupMouseMoveHandler();
        instance.openChangeTimeout.clear();
        instance.restTimeout.clear();
        instance.blockMouseMove = true;
        instance.restTimeoutPending = false;
      } else {
        isHoverCloseActiveRef.current = false;
      }
    }
    events.on("openchange", onOpenChangeLocal);
    return () => {
      events.off("openchange", onOpenChangeLocal);
    };
  }, [enabled, events, instance, cleanupMouseMoveHandler]);
  React29.useEffect(() => {
    if (!enabled) {
      return void 0;
    }
    function closeWithDelay(event, runElseBranch = true) {
      const closeDelay = getDelay(delayRef.current, "close", instance.pointerType);
      if (closeDelay) {
        instance.openChangeTimeout.start(closeDelay, () => {
          store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
          tree?.events.emit("floating.closed", event);
        });
      } else if (runElseBranch) {
        instance.openChangeTimeout.clear();
        store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
        tree?.events.emit("floating.closed", event);
      }
    }
    const trigger = triggerElementRef.current ?? (isActiveTrigger ? store.select("domReferenceElement") : null);
    if (!isElement(trigger)) {
      return void 0;
    }
    function onMouseEnter(event) {
      instance.openChangeTimeout.clear();
      instance.blockMouseMove = false;
      if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
        return;
      }
      const restMsValue = getRestMs(restMsRef.current);
      const openDelay = getDelay(delayRef.current, "open", instance.pointerType);
      const eventTarget = getTarget(event);
      const currentTarget = event.currentTarget ?? null;
      const currentDomReference = store.select("domReferenceElement");
      let triggerNode = currentTarget;
      if (isElement(eventTarget) && !store.context.triggerElements.hasElement(eventTarget)) {
        for (const triggerElement of store.context.triggerElements.elements()) {
          if (contains(triggerElement, eventTarget)) {
            triggerNode = triggerElement;
            break;
          }
        }
      }
      if (isElement(currentTarget) && isElement(currentDomReference) && !store.context.triggerElements.hasElement(currentTarget) && contains(currentTarget, currentDomReference)) {
        triggerNode = currentDomReference;
      }
      const isOverInactive = triggerNode == null ? false : isOverInactiveTrigger(currentDomReference, triggerNode, eventTarget);
      const isOpen = store.select("open");
      const isInClosingTransition = isClosingRef.current?.() ?? store.select("transitionStatus") === "ending";
      const isHoverCloseTransition = !isOpen && isInClosingTransition && isHoverCloseActiveRef.current;
      const isReenteringSameTriggerDuringCloseTransition = !isOverInactive && isElement(triggerNode) && isElement(currentDomReference) && contains(currentDomReference, triggerNode) && isHoverCloseTransition;
      const isRestOnlyDelay = restMsValue > 0 && !openDelay;
      const shouldOpenImmediately = isOverInactive && (isOpen || isHoverCloseTransition) || isReenteringSameTriggerDuringCloseTransition;
      const shouldOpen = !isOpen || isOverInactive;
      if (shouldOpenImmediately) {
        if (checkShouldOpen()) {
          store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
        }
        return;
      }
      if (isRestOnlyDelay) {
        return;
      }
      if (openDelay) {
        instance.openChangeTimeout.start(openDelay, () => {
          if (shouldOpen && checkShouldOpen()) {
            store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
          }
        });
      } else if (shouldOpen) {
        if (checkShouldOpen()) {
          store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerNode));
        }
      }
    }
    function onMouseLeave(event) {
      if (isClickLikeOpenEvent2()) {
        clearPointerEvents();
        return;
      }
      cleanupMouseMoveHandler();
      const domReferenceElement = store.select("domReferenceElement");
      const doc = ownerDocument(domReferenceElement);
      instance.restTimeout.clear();
      instance.restTimeoutPending = false;
      const handleCloseContextBase = dataRef.current.floatingContext ?? getHandleCloseContext?.();
      if (isTargetInsideEnabledTrigger(event.relatedTarget, store.context.triggerElements)) {
        return;
      }
      if (handleCloseRef.current && handleCloseContextBase) {
        if (!store.select("open")) {
          instance.openChangeTimeout.clear();
        }
        const currentTrigger = triggerElementRef.current;
        instance.handler = handleCloseRef.current({
          ...handleCloseContextBase,
          tree,
          x: event.clientX,
          y: event.clientY,
          onClose() {
            clearPointerEvents();
            cleanupMouseMoveHandler();
            if (enabledRef.current && !isClickLikeOpenEvent2() && currentTrigger === store.select("domReferenceElement")) {
              closeWithDelay(event, true);
            }
          }
        });
        doc.addEventListener("mousemove", instance.handler);
        instance.handler(event);
        return;
      }
      const shouldClose = instance.pointerType === "touch" ? !contains(store.select("floatingElement"), event.relatedTarget) : true;
      if (shouldClose) {
        closeWithDelay(event);
      }
    }
    if (move) {
      return mergeCleanups(addEventListener(trigger, "mousemove", onMouseEnter, {
        once: true
      }), addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
    }
    return mergeCleanups(addEventListener(trigger, "mouseenter", onMouseEnter), addEventListener(trigger, "mouseleave", onMouseLeave));
  }, [cleanupMouseMoveHandler, clearPointerEvents, dataRef, delayRef, store, enabled, handleCloseRef, instance, isActiveTrigger, isOverInactiveTrigger, isClickLikeOpenEvent2, mouseOnly, move, restMsRef, triggerElementRef, tree, enabledRef, getHandleCloseContext, isClosingRef, checkShouldOpen]);
  return React29.useMemo(() => {
    if (!enabled) {
      return void 0;
    }
    function setPointerRef(event) {
      instance.pointerType = event.pointerType;
    }
    return {
      onPointerDown: setPointerRef,
      onPointerEnter: setPointerRef,
      onMouseMove(event) {
        const {
          nativeEvent
        } = event;
        const trigger = event.currentTarget;
        const currentDomReference = store.select("domReferenceElement");
        const currentOpen = store.select("open");
        const isOverInactive = isOverInactiveTrigger(currentDomReference, trigger, event.target);
        if (mouseOnly && !isMouseLikePointerType(instance.pointerType)) {
          return;
        }
        if (currentOpen && isOverInactive && instance.handleCloseOptions?.blockPointerEvents) {
          const floatingElement = store.select("floatingElement");
          if (floatingElement) {
            const scopeElement = instance.handleCloseOptions?.getScope?.() ?? trigger.ownerDocument.body;
            applySafePolygonPointerEventsMutation(instance, {
              scopeElement,
              referenceElement: trigger,
              floatingElement
            });
          }
        }
        const restMsValue = getRestMs(restMsRef.current);
        if (currentOpen && !isOverInactive || restMsValue === 0) {
          return;
        }
        if (!isOverInactive && instance.restTimeoutPending && event.movementX ** 2 + event.movementY ** 2 < 2) {
          return;
        }
        instance.restTimeout.clear();
        function handleMouseMove() {
          instance.restTimeoutPending = false;
          if (isClickLikeOpenEvent2()) {
            return;
          }
          const latestOpen = store.select("open");
          if (!instance.blockMouseMove && (!latestOpen || isOverInactive) && checkShouldOpen()) {
            store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, nativeEvent, trigger));
          }
        }
        if (instance.pointerType === "touch") {
          ReactDOM5.flushSync(() => {
            handleMouseMove();
          });
        } else if (isOverInactive && currentOpen) {
          handleMouseMove();
        } else {
          instance.restTimeoutPending = true;
          instance.restTimeout.start(restMsValue, handleMouseMove);
        }
      }
    };
  }, [enabled, instance, isClickLikeOpenEvent2, isOverInactiveTrigger, mouseOnly, store, restMsRef, checkShouldOpen]);
}

// node_modules/@base-ui/react/floating-ui-react/safePolygon.mjs
var CURSOR_SPEED_THRESHOLD = 0.1;
var CURSOR_SPEED_THRESHOLD_SQUARED = CURSOR_SPEED_THRESHOLD * CURSOR_SPEED_THRESHOLD;
var POLYGON_BUFFER = 0.5;
function hasIntersectingEdge(pointX, pointY, xi, yi, xj, yj) {
  return yi >= pointY !== yj >= pointY && pointX <= (xj - xi) * (pointY - yi) / (yj - yi) + xi;
}
function isPointInQuadrilateral(pointX, pointY, x1, y1, x2, y2, x3, y3, x4, y4) {
  let isInsideValue = false;
  if (hasIntersectingEdge(pointX, pointY, x1, y1, x2, y2)) {
    isInsideValue = !isInsideValue;
  }
  if (hasIntersectingEdge(pointX, pointY, x2, y2, x3, y3)) {
    isInsideValue = !isInsideValue;
  }
  if (hasIntersectingEdge(pointX, pointY, x3, y3, x4, y4)) {
    isInsideValue = !isInsideValue;
  }
  if (hasIntersectingEdge(pointX, pointY, x4, y4, x1, y1)) {
    isInsideValue = !isInsideValue;
  }
  return isInsideValue;
}
function isInsideRect(pointX, pointY, rect) {
  return pointX >= rect.x && pointX <= rect.x + rect.width && pointY >= rect.y && pointY <= rect.y + rect.height;
}
function isInsideAxisAlignedRect(pointX, pointY, x1, y1, x2, y2) {
  const minX = Math.min(x1, x2);
  const maxX = Math.max(x1, x2);
  const minY = Math.min(y1, y2);
  const maxY = Math.max(y1, y2);
  return pointX >= minX && pointX <= maxX && pointY >= minY && pointY <= maxY;
}
function safePolygon(options = {}) {
  const {
    blockPointerEvents = false
  } = options;
  const timeout = new Timeout();
  const fn = ({
    x: x2,
    y: y2,
    placement,
    elements: elements2,
    onClose,
    nodeId,
    tree
  }) => {
    const side = placement?.split("-")[0];
    let hasLanded = false;
    let lastX = null;
    let lastY = null;
    let lastCursorTime = typeof performance !== "undefined" ? performance.now() : 0;
    function isCursorMovingSlowly(nextX, nextY) {
      const currentTime = performance.now();
      const elapsedTime = currentTime - lastCursorTime;
      if (lastX === null || lastY === null || elapsedTime === 0) {
        lastX = nextX;
        lastY = nextY;
        lastCursorTime = currentTime;
        return false;
      }
      const deltaX = nextX - lastX;
      const deltaY = nextY - lastY;
      const distanceSquared = deltaX * deltaX + deltaY * deltaY;
      const thresholdSquared = elapsedTime * elapsedTime * CURSOR_SPEED_THRESHOLD_SQUARED;
      lastX = nextX;
      lastY = nextY;
      lastCursorTime = currentTime;
      return distanceSquared < thresholdSquared;
    }
    function close() {
      timeout.clear();
      onClose();
    }
    return function onMouseMove(event) {
      timeout.clear();
      const domReference = elements2.domReference;
      const floating = elements2.floating;
      if (!domReference || !floating || side == null || x2 == null || y2 == null) {
        return void 0;
      }
      const {
        clientX,
        clientY
      } = event;
      const target = getTarget(event);
      const isLeave = event.type === "mouseleave";
      const isOverFloatingEl = contains(floating, target);
      const isOverReferenceEl = contains(domReference, target);
      if (isOverFloatingEl) {
        hasLanded = true;
        if (!isLeave) {
          return void 0;
        }
      }
      if (isOverReferenceEl) {
        hasLanded = false;
        if (!isLeave) {
          hasLanded = true;
          return void 0;
        }
      }
      if (isLeave && isElement(event.relatedTarget) && contains(floating, event.relatedTarget)) {
        return void 0;
      }
      function hasOpenChildNode() {
        return Boolean(tree && getNodeChildren(tree.nodesRef.current, nodeId).length > 0);
      }
      function closeIfNoOpenChild() {
        if (!hasOpenChildNode()) {
          close();
        }
      }
      if (hasOpenChildNode()) {
        return void 0;
      }
      const refRect = domReference.getBoundingClientRect();
      const rect = floating.getBoundingClientRect();
      const cursorLeaveFromRight = x2 > rect.right - rect.width / 2;
      const cursorLeaveFromBottom = y2 > rect.bottom - rect.height / 2;
      const isFloatingWider = rect.width > refRect.width;
      const isFloatingTaller = rect.height > refRect.height;
      const left = (isFloatingWider ? refRect : rect).left;
      const right = (isFloatingWider ? refRect : rect).right;
      const top = (isFloatingTaller ? refRect : rect).top;
      const bottom = (isFloatingTaller ? refRect : rect).bottom;
      if (side === "top" && y2 >= refRect.bottom - 1 || side === "bottom" && y2 <= refRect.top + 1 || side === "left" && x2 >= refRect.right - 1 || side === "right" && x2 <= refRect.left + 1) {
        closeIfNoOpenChild();
        return void 0;
      }
      let isInsideTroughRect = false;
      switch (side) {
        case "top":
          isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, refRect.top + 1, right, rect.bottom - 1);
          break;
        case "bottom":
          isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, left, rect.top + 1, right, refRect.bottom - 1);
          break;
        case "left":
          isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, rect.right - 1, bottom, refRect.left + 1, top);
          break;
        case "right":
          isInsideTroughRect = isInsideAxisAlignedRect(clientX, clientY, refRect.right - 1, bottom, rect.left + 1, top);
          break;
        default:
      }
      if (isInsideTroughRect) {
        return void 0;
      }
      if (hasLanded && !isInsideRect(clientX, clientY, refRect)) {
        closeIfNoOpenChild();
        return void 0;
      }
      if (!isLeave && isCursorMovingSlowly(clientX, clientY)) {
        closeIfNoOpenChild();
        return void 0;
      }
      let isInsidePolygon = false;
      switch (side) {
        case "top": {
          const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
          const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
          const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
          const cursorPointY = y2 + POLYGON_BUFFER + 1;
          const commonYLeft = cursorLeaveFromRight ? rect.bottom - POLYGON_BUFFER : isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top;
          const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.bottom - POLYGON_BUFFER : rect.top : rect.bottom - POLYGON_BUFFER;
          isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
          break;
        }
        case "bottom": {
          const cursorXOffset = isFloatingWider ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
          const cursorPointOneX = isFloatingWider ? x2 + cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
          const cursorPointTwoX = isFloatingWider ? x2 - cursorXOffset : cursorLeaveFromRight ? x2 + cursorXOffset : x2 - cursorXOffset;
          const cursorPointY = y2 - POLYGON_BUFFER;
          const commonYLeft = cursorLeaveFromRight ? rect.top + POLYGON_BUFFER : isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom;
          const commonYRight = cursorLeaveFromRight ? isFloatingWider ? rect.top + POLYGON_BUFFER : rect.bottom : rect.top + POLYGON_BUFFER;
          isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointOneX, cursorPointY, cursorPointTwoX, cursorPointY, rect.left, commonYLeft, rect.right, commonYRight);
          break;
        }
        case "left": {
          const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
          const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
          const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
          const cursorPointX = x2 + POLYGON_BUFFER + 1;
          const commonXTop = cursorLeaveFromBottom ? rect.right - POLYGON_BUFFER : isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left;
          const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.right - POLYGON_BUFFER : rect.left : rect.right - POLYGON_BUFFER;
          isInsidePolygon = isPointInQuadrilateral(clientX, clientY, commonXTop, rect.top, commonXBottom, rect.bottom, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY);
          break;
        }
        case "right": {
          const cursorYOffset = isFloatingTaller ? POLYGON_BUFFER / 2 : POLYGON_BUFFER * 4;
          const cursorPointOneY = isFloatingTaller ? y2 + cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
          const cursorPointTwoY = isFloatingTaller ? y2 - cursorYOffset : cursorLeaveFromBottom ? y2 + cursorYOffset : y2 - cursorYOffset;
          const cursorPointX = x2 - POLYGON_BUFFER;
          const commonXTop = cursorLeaveFromBottom ? rect.left + POLYGON_BUFFER : isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right;
          const commonXBottom = cursorLeaveFromBottom ? isFloatingTaller ? rect.left + POLYGON_BUFFER : rect.right : rect.left + POLYGON_BUFFER;
          isInsidePolygon = isPointInQuadrilateral(clientX, clientY, cursorPointX, cursorPointOneY, cursorPointX, cursorPointTwoY, commonXTop, rect.top, commonXBottom, rect.bottom);
          break;
        }
        default:
      }
      if (!isInsidePolygon) {
        closeIfNoOpenChild();
      } else if (!hasLanded) {
        timeout.start(40, closeIfNoOpenChild);
      }
      return void 0;
    };
  };
  fn.__options = {
    ...options,
    blockPointerEvents
  };
  return fn;
}

// node_modules/@base-ui/react/utils/popupStateMapping.mjs
var CommonPopupDataAttributes = (function(CommonPopupDataAttributes2) {
  CommonPopupDataAttributes2["open"] = "data-open";
  CommonPopupDataAttributes2["closed"] = "data-closed";
  CommonPopupDataAttributes2[CommonPopupDataAttributes2["startingStyle"] = TransitionStatusDataAttributes.startingStyle] = "startingStyle";
  CommonPopupDataAttributes2[CommonPopupDataAttributes2["endingStyle"] = TransitionStatusDataAttributes.endingStyle] = "endingStyle";
  CommonPopupDataAttributes2["anchorHidden"] = "data-anchor-hidden";
  CommonPopupDataAttributes2["side"] = "data-side";
  CommonPopupDataAttributes2["align"] = "data-align";
  return CommonPopupDataAttributes2;
})({});
var CommonTriggerDataAttributes = /* @__PURE__ */ (function(CommonTriggerDataAttributes2) {
  CommonTriggerDataAttributes2["popupOpen"] = "data-popup-open";
  CommonTriggerDataAttributes2["pressed"] = "data-pressed";
  return CommonTriggerDataAttributes2;
})({});
var TRIGGER_HOOK = {
  [CommonTriggerDataAttributes.popupOpen]: ""
};
var PRESSABLE_TRIGGER_HOOK = {
  [CommonTriggerDataAttributes.popupOpen]: "",
  [CommonTriggerDataAttributes.pressed]: ""
};
var POPUP_OPEN_HOOK = {
  [CommonPopupDataAttributes.open]: ""
};
var POPUP_CLOSED_HOOK = {
  [CommonPopupDataAttributes.closed]: ""
};
var ANCHOR_HIDDEN_HOOK = {
  [CommonPopupDataAttributes.anchorHidden]: ""
};
var triggerOpenStateMapping = {
  open(value) {
    if (value) {
      return TRIGGER_HOOK;
    }
    return null;
  }
};
var popupStateMapping = {
  open(value) {
    if (value) {
      return POPUP_OPEN_HOOK;
    }
    return POPUP_CLOSED_HOOK;
  },
  anchorHidden(value) {
    if (value) {
      return ANCHOR_HIDDEN_HOOK;
    }
    return null;
  }
};

// node_modules/@base-ui/utils/inertValue.mjs
function inertValue(value) {
  if (isReactVersionAtLeast(19)) {
    return value;
  }
  return value ? "true" : void 0;
}

// node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
var React30 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/floating-ui-react/middleware/arrow.mjs
var baseArrow = (options) => ({
  name: "arrow",
  options,
  async fn(state) {
    const {
      x: x2,
      y: y2,
      placement,
      rects,
      platform: platform3,
      elements: elements2,
      middlewareData
    } = state;
    const {
      element,
      padding = 0,
      offsetParent = "real"
    } = evaluate(options, state) || {};
    if (element == null) {
      return {};
    }
    const paddingObject = getPaddingObject(padding);
    const coords = {
      x: x2,
      y: y2
    };
    const axis = getAlignmentAxis(placement);
    const length = getAxisLength(axis);
    const arrowDimensions = await platform3.getDimensions(element);
    const isYAxis = axis === "y";
    const minProp = isYAxis ? "top" : "left";
    const maxProp = isYAxis ? "bottom" : "right";
    const clientProp = isYAxis ? "clientHeight" : "clientWidth";
    const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
    const startDiff = coords[axis] - rects.reference[axis];
    const arrowOffsetParent = offsetParent === "real" ? await platform3.getOffsetParent?.(element) : elements2.floating;
    let clientSize = elements2.floating[clientProp] || rects.floating[length];
    if (!clientSize || !await platform3.isElement?.(arrowOffsetParent)) {
      clientSize = elements2.floating[clientProp] || rects.floating[length];
    }
    const centerToReference = endDiff / 2 - startDiff / 2;
    const largestPossiblePadding = clientSize / 2 - arrowDimensions[length] / 2 - 1;
    const minPadding = Math.min(paddingObject[minProp], largestPossiblePadding);
    const maxPadding = Math.min(paddingObject[maxProp], largestPossiblePadding);
    const min2 = minPadding;
    const max2 = clientSize - arrowDimensions[length] - maxPadding;
    const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
    const offset4 = clamp(min2, center, max2);
    const shouldAddOffset = !middlewareData.arrow && getAlignment(placement) != null && center !== offset4 && rects.reference[length] / 2 - (center < min2 ? minPadding : maxPadding) - arrowDimensions[length] / 2 < 0;
    const alignmentOffset = shouldAddOffset ? center < min2 ? center - min2 : center - max2 : 0;
    return {
      [axis]: coords[axis] + alignmentOffset,
      data: {
        [axis]: offset4,
        centerOffset: center - offset4 - alignmentOffset,
        ...shouldAddOffset && {
          alignmentOffset
        }
      },
      reset: shouldAddOffset
    };
  }
});
var arrow4 = (options, deps) => ({
  ...baseArrow(options),
  options: [options, deps]
});

// node_modules/@base-ui/react/utils/hideMiddleware.mjs
var nativeHideFn = hide3().fn;
var hide4 = {
  name: "hide",
  async fn(state) {
    const {
      width,
      height,
      x: x2,
      y: y2
    } = state.rects.reference;
    const anchorHidden = width === 0 && height === 0 && x2 === 0 && y2 === 0;
    const nativeHideResult = await nativeHideFn(state);
    return {
      data: {
        referenceHidden: nativeHideResult.data?.referenceHidden || anchorHidden
      }
    };
  }
};

// node_modules/@base-ui/react/utils/adaptiveOriginMiddleware.mjs
var DEFAULT_SIDES = {
  sideX: "left",
  sideY: "top"
};
var adaptiveOrigin = {
  name: "adaptiveOrigin",
  async fn(state) {
    const {
      x: rawX,
      y: rawY,
      rects: {
        floating: floatRect
      },
      elements: {
        floating
      },
      platform: platform3,
      strategy,
      placement
    } = state;
    const win = getWindow(floating);
    const styles = win.getComputedStyle(floating);
    const hasTransition = styles.transitionDuration !== "0s" && styles.transitionDuration !== "";
    if (!hasTransition) {
      return {
        x: rawX,
        y: rawY,
        data: DEFAULT_SIDES
      };
    }
    const offsetParent = await platform3.getOffsetParent?.(floating);
    let offsetDimensions = {
      width: 0,
      height: 0
    };
    if (strategy === "fixed" && win?.visualViewport) {
      offsetDimensions = {
        width: win.visualViewport.width,
        height: win.visualViewport.height
      };
    } else if (offsetParent === win) {
      const doc = ownerDocument(floating);
      offsetDimensions = {
        width: doc.documentElement.clientWidth,
        height: doc.documentElement.clientHeight
      };
    } else if (await platform3.isElement?.(offsetParent)) {
      offsetDimensions = await platform3.getDimensions(offsetParent);
    }
    const currentSide = getSide(placement);
    let x2 = rawX;
    let y2 = rawY;
    if (currentSide === "left") {
      x2 = offsetDimensions.width - (rawX + floatRect.width);
    }
    if (currentSide === "top") {
      y2 = offsetDimensions.height - (rawY + floatRect.height);
    }
    const sideX = currentSide === "left" ? "right" : DEFAULT_SIDES.sideX;
    const sideY = currentSide === "top" ? "bottom" : DEFAULT_SIDES.sideY;
    return {
      x: x2,
      y: y2,
      data: {
        sideX,
        sideY
      }
    };
  }
};

// node_modules/@base-ui/react/utils/useAnchorPositioning.mjs
function getLogicalSide(sideParam, renderedSide, isRtl) {
  const isLogicalSideParam = sideParam === "inline-start" || sideParam === "inline-end";
  const logicalRight = isRtl ? "inline-start" : "inline-end";
  const logicalLeft = isRtl ? "inline-end" : "inline-start";
  return {
    top: "top",
    right: isLogicalSideParam ? logicalRight : "right",
    bottom: "bottom",
    left: isLogicalSideParam ? logicalLeft : "left"
  }[renderedSide];
}
function getOffsetData(state, sideParam, isRtl) {
  const {
    rects,
    placement
  } = state;
  const data = {
    side: getLogicalSide(sideParam, getSide(placement), isRtl),
    align: getAlignment(placement) || "center",
    anchor: {
      width: rects.reference.width,
      height: rects.reference.height
    },
    positioner: {
      width: rects.floating.width,
      height: rects.floating.height
    }
  };
  return data;
}
function useAnchorPositioning(params) {
  const {
    // Public parameters
    anchor,
    positionMethod = "absolute",
    side: sideParam = "bottom",
    sideOffset = 0,
    align = "center",
    alignOffset = 0,
    collisionBoundary,
    collisionPadding: collisionPaddingParam = 5,
    sticky = false,
    arrowPadding = 5,
    disableAnchorTracking = false,
    inline: inlineMiddleware,
    // Private parameters
    keepMounted = false,
    floatingRootContext,
    mounted,
    collisionAvoidance,
    shiftCrossAxis = false,
    nodeId,
    adaptiveOrigin: adaptiveOrigin2,
    lazyFlip = false,
    externalTree
  } = params;
  const [mountSide, setMountSide] = React30.useState(null);
  if (!mounted && mountSide !== null) {
    setMountSide(null);
  }
  const collisionAvoidanceSide = collisionAvoidance.side || "flip";
  const collisionAvoidanceAlign = collisionAvoidance.align || "flip";
  const collisionAvoidanceFallbackAxisSide = collisionAvoidance.fallbackAxisSide || "end";
  const anchorFn = typeof anchor === "function" ? anchor : void 0;
  const anchorFnCallback = useStableCallback(anchorFn);
  const anchorDep = anchorFn ? anchorFnCallback : anchor;
  const anchorValueRef = useValueAsRef(anchor);
  const mountedRef = useValueAsRef(mounted);
  const direction = useDirection();
  const isRtl = direction === "rtl";
  const side = mountSide || {
    top: "top",
    right: "right",
    bottom: "bottom",
    left: "left",
    "inline-end": isRtl ? "left" : "right",
    "inline-start": isRtl ? "right" : "left"
  }[sideParam];
  const placement = align === "center" ? side : `${side}-${align}`;
  let collisionPadding = collisionPaddingParam;
  const bias = 1;
  const biasTop = sideParam === "bottom" ? bias : 0;
  const biasBottom = sideParam === "top" ? bias : 0;
  const biasLeft = sideParam === "right" ? bias : 0;
  const biasRight = sideParam === "left" ? bias : 0;
  if (typeof collisionPadding === "number") {
    collisionPadding = {
      top: collisionPadding + biasTop,
      right: collisionPadding + biasRight,
      bottom: collisionPadding + biasBottom,
      left: collisionPadding + biasLeft
    };
  } else if (collisionPadding) {
    collisionPadding = {
      top: (collisionPadding.top || 0) + biasTop,
      right: (collisionPadding.right || 0) + biasRight,
      bottom: (collisionPadding.bottom || 0) + biasBottom,
      left: (collisionPadding.left || 0) + biasLeft
    };
  }
  const commonCollisionProps = {
    boundary: collisionBoundary === "clipping-ancestors" ? "clippingAncestors" : collisionBoundary,
    padding: collisionPadding
  };
  const arrowRef = React30.useRef(null);
  const sideOffsetRef = useValueAsRef(sideOffset);
  const alignOffsetRef = useValueAsRef(alignOffset);
  const sideOffsetDep = typeof sideOffset !== "function" ? sideOffset : 0;
  const alignOffsetDep = typeof alignOffset !== "function" ? alignOffset : 0;
  const middleware = [];
  if (inlineMiddleware) {
    middleware.push(inlineMiddleware);
  }
  middleware.push(offset3((state) => {
    const data = getOffsetData(state, sideParam, isRtl);
    const sideAxis = typeof sideOffsetRef.current === "function" ? sideOffsetRef.current(data) : sideOffsetRef.current;
    const alignAxis = typeof alignOffsetRef.current === "function" ? alignOffsetRef.current(data) : alignOffsetRef.current;
    return {
      mainAxis: sideAxis,
      crossAxis: alignAxis,
      alignmentAxis: alignAxis
    };
  }, [sideOffsetDep, alignOffsetDep, isRtl, sideParam]));
  const shiftDisabled = collisionAvoidanceAlign === "none" && collisionAvoidanceSide !== "shift";
  const crossAxisShiftEnabled = !shiftDisabled && (sticky || shiftCrossAxis || collisionAvoidanceSide === "shift");
  const flipMiddleware = collisionAvoidanceSide === "none" ? null : flip3({
    ...commonCollisionProps,
    // Ensure the popup flips if it's been limited by its --available-height and it resizes.
    // Since the size() padding is smaller than the flip() padding, flip() will take precedence.
    padding: {
      top: collisionPadding.top + bias,
      right: collisionPadding.right + bias,
      bottom: collisionPadding.bottom + bias,
      left: collisionPadding.left + bias
    },
    mainAxis: !shiftCrossAxis && collisionAvoidanceSide === "flip",
    crossAxis: collisionAvoidanceAlign === "flip" ? "alignment" : false,
    fallbackAxisSideDirection: collisionAvoidanceFallbackAxisSide
  });
  const shiftMiddleware = shiftDisabled ? null : shift3((data) => {
    const html = ownerDocument(data.elements.floating).documentElement;
    return {
      ...commonCollisionProps,
      // Use the Layout Viewport to avoid shifting around when pinch-zooming
      // for context menus.
      rootBoundary: shiftCrossAxis ? {
        x: 0,
        y: 0,
        width: html.clientWidth,
        height: html.clientHeight
      } : void 0,
      mainAxis: collisionAvoidanceAlign !== "none",
      crossAxis: crossAxisShiftEnabled,
      limiter: sticky || shiftCrossAxis ? void 0 : limitShift3((limitData) => {
        if (!arrowRef.current) {
          return {};
        }
        const {
          width,
          height
        } = arrowRef.current.getBoundingClientRect();
        const sideAxis = getSideAxis(getSide(limitData.placement));
        const arrowSize = sideAxis === "y" ? width : height;
        const offsetAmount = sideAxis === "y" ? collisionPadding.left + collisionPadding.right : collisionPadding.top + collisionPadding.bottom;
        return {
          offset: arrowSize / 2 + offsetAmount / 2
        };
      })
    };
  }, [commonCollisionProps, sticky, shiftCrossAxis, collisionPadding, collisionAvoidanceAlign]);
  if (collisionAvoidanceSide === "shift" || collisionAvoidanceAlign === "shift" || align === "center") {
    middleware.push(shiftMiddleware, flipMiddleware);
  } else {
    middleware.push(flipMiddleware, shiftMiddleware);
  }
  middleware.push(size3({
    ...commonCollisionProps,
    apply({
      elements: {
        floating
      },
      availableWidth,
      availableHeight,
      rects
    }) {
      if (!mountedRef.current) {
        return;
      }
      const floatingStyle = floating.style;
      floatingStyle.setProperty("--available-width", `${availableWidth}px`);
      floatingStyle.setProperty("--available-height", `${availableHeight}px`);
      const dpr = getWindow(floating).devicePixelRatio || 1;
      const {
        x: x3,
        y: y3,
        width,
        height
      } = rects.reference;
      const anchorWidth = (Math.round((x3 + width) * dpr) - Math.round(x3 * dpr)) / dpr;
      const anchorHeight = (Math.round((y3 + height) * dpr) - Math.round(y3 * dpr)) / dpr;
      floatingStyle.setProperty("--anchor-width", `${anchorWidth}px`);
      floatingStyle.setProperty("--anchor-height", `${anchorHeight}px`);
    }
  }), arrow4((state) => ({
    // `transform-origin` calculations rely on an element existing. If the arrow hasn't been set,
    // we'll create a fake element.
    element: arrowRef.current || ownerDocument(state.elements.floating).createElement("div"),
    padding: arrowPadding,
    offsetParent: "floating"
  }), [arrowPadding]), {
    name: "transformOrigin",
    fn(state) {
      const {
        elements: elements3,
        middlewareData: middlewareData2,
        placement: renderedPlacement2,
        rects,
        y: y3
      } = state;
      const currentRenderedSide = getSide(renderedPlacement2);
      const currentRenderedAxis = getSideAxis(currentRenderedSide);
      const arrowEl = arrowRef.current;
      const arrowX = middlewareData2.arrow?.x || 0;
      const arrowY = middlewareData2.arrow?.y || 0;
      const arrowWidth = arrowEl?.clientWidth || 0;
      const arrowHeight = arrowEl?.clientHeight || 0;
      const transformX = arrowX + arrowWidth / 2;
      const transformY = arrowY + arrowHeight / 2;
      const shiftY = Math.abs(middlewareData2.shift?.y || 0);
      const halfAnchorHeight = rects.reference.height / 2;
      const sideOffsetValue = typeof sideOffset === "function" ? sideOffset(getOffsetData(state, sideParam, isRtl)) : sideOffset;
      const isOverlappingAnchor = shiftY > sideOffsetValue;
      const adjacentTransformOrigin = {
        top: `${transformX}px calc(100% + ${sideOffsetValue}px)`,
        bottom: `${transformX}px ${-sideOffsetValue}px`,
        left: `calc(100% + ${sideOffsetValue}px) ${transformY}px`,
        right: `${-sideOffsetValue}px ${transformY}px`
      }[currentRenderedSide];
      const overlapTransformOrigin = `${transformX}px ${rects.reference.y + halfAnchorHeight - y3}px`;
      elements3.floating.style.setProperty("--transform-origin", crossAxisShiftEnabled && currentRenderedAxis === "y" && isOverlappingAnchor ? overlapTransformOrigin : adjacentTransformOrigin);
      return {};
    }
  }, hide4, adaptiveOrigin2);
  useIsoLayoutEffect(() => {
    if (!mounted && floatingRootContext) {
      floatingRootContext.update({
        referenceElement: null,
        floatingElement: null,
        domReferenceElement: null,
        positionReference: null
      });
    }
  }, [mounted, floatingRootContext]);
  const autoUpdateOptions = React30.useMemo(() => ({
    elementResize: !disableAnchorTracking && typeof ResizeObserver !== "undefined",
    layoutShift: !disableAnchorTracking && typeof IntersectionObserver !== "undefined"
  }), [disableAnchorTracking]);
  const {
    refs,
    elements: elements2,
    x: x2,
    y: y2,
    middlewareData,
    update: update2,
    placement: renderedPlacement,
    context,
    isPositioned,
    floatingStyles: originalFloatingStyles
  } = useFloating2({
    rootContext: floatingRootContext,
    open: keepMounted ? mounted : void 0,
    placement,
    middleware,
    strategy: positionMethod,
    whileElementsMounted: keepMounted ? void 0 : (...args) => autoUpdate(...args, autoUpdateOptions),
    nodeId,
    externalTree
  });
  const {
    sideX,
    sideY
  } = middlewareData.adaptiveOrigin || DEFAULT_SIDES;
  const resolvedPosition = isPositioned ? positionMethod : "fixed";
  const floatingStyles = React30.useMemo(() => {
    const base = adaptiveOrigin2 ? {
      position: resolvedPosition,
      [sideX]: x2,
      [sideY]: y2
    } : {
      position: resolvedPosition,
      ...originalFloatingStyles
    };
    if (!isPositioned) {
      base.opacity = 0;
    }
    return base;
  }, [adaptiveOrigin2, resolvedPosition, sideX, x2, sideY, y2, originalFloatingStyles, isPositioned]);
  const registeredPositionReferenceRef = React30.useRef(null);
  useIsoLayoutEffect(() => {
    if (!mounted) {
      return;
    }
    const anchorValue = anchorValueRef.current;
    const resolvedAnchor = typeof anchorValue === "function" ? anchorValue() : anchorValue;
    const unwrappedElement = (isRef(resolvedAnchor) ? resolvedAnchor.current : resolvedAnchor) || null;
    const finalAnchor = unwrappedElement || null;
    if (finalAnchor !== registeredPositionReferenceRef.current) {
      refs.setPositionReference(finalAnchor);
      registeredPositionReferenceRef.current = finalAnchor;
    }
  }, [mounted, refs, anchorDep, anchorValueRef]);
  React30.useEffect(() => {
    if (!mounted) {
      return;
    }
    const anchorValue = anchorValueRef.current;
    if (typeof anchorValue === "function") {
      return;
    }
    if (isRef(anchorValue) && anchorValue.current !== registeredPositionReferenceRef.current) {
      refs.setPositionReference(anchorValue.current);
      registeredPositionReferenceRef.current = anchorValue.current;
    }
  }, [mounted, refs, anchorDep, anchorValueRef]);
  React30.useEffect(() => {
    if (keepMounted && mounted && elements2.reference && elements2.floating) {
      return autoUpdate(elements2.reference, elements2.floating, update2, autoUpdateOptions);
    }
    return void 0;
  }, [keepMounted, mounted, elements2, update2, autoUpdateOptions]);
  const renderedSide = getSide(renderedPlacement);
  const logicalRenderedSide = getLogicalSide(sideParam, renderedSide, isRtl);
  const renderedAlign = getAlignment(renderedPlacement) || "center";
  const anchorHidden = Boolean(middlewareData.hide?.referenceHidden);
  useIsoLayoutEffect(() => {
    if (lazyFlip && mounted && isPositioned) {
      setMountSide(renderedSide);
    }
  }, [lazyFlip, mounted, isPositioned, renderedSide]);
  const arrowStyles = React30.useMemo(() => ({
    position: "absolute",
    top: middlewareData.arrow?.y,
    left: middlewareData.arrow?.x
  }), [middlewareData.arrow]);
  const arrowUncentered = middlewareData.arrow?.centerOffset !== 0;
  return React30.useMemo(() => ({
    positionerStyles: floatingStyles,
    arrowStyles,
    arrowRef,
    arrowUncentered,
    side: logicalRenderedSide,
    align: renderedAlign,
    physicalSide: renderedSide,
    anchorHidden,
    refs,
    context,
    isPositioned,
    update: update2
  }), [floatingStyles, arrowStyles, arrowRef, arrowUncentered, logicalRenderedSide, renderedAlign, renderedSide, anchorHidden, refs, context, isPositioned, update2]);
}
function isRef(param) {
  return param != null && "current" in param;
}

// node_modules/@base-ui/react/utils/getDisabledMountTransitionStyles.mjs
function getDisabledMountTransitionStyles(transitionStatus) {
  return transitionStatus === "starting" ? DISABLED_TRANSITIONS_STYLE : EMPTY_OBJECT;
}

// node_modules/@base-ui/react/utils/usePositioner.mjs
function usePositioner(componentProps, state, {
  styles,
  transitionStatus,
  props,
  refs,
  hidden,
  inert = false
}) {
  const style = {
    ...styles
  };
  if (inert) {
    style.pointerEvents = "none";
  }
  return useRenderElement("div", componentProps, {
    state,
    ref: refs,
    props: [{
      role: "presentation",
      hidden,
      style
    }, getDisabledMountTransitionStyles(transitionStatus), props],
    stateAttributesMapping: popupStateMapping
  });
}

// node_modules/@base-ui/react/utils/usePopupViewport.mjs
var React33 = __toESM(require_react(), 1);
var ReactDOM6 = __toESM(require_react_dom(), 1);

// node_modules/@base-ui/utils/usePreviousValue.mjs
var React31 = __toESM(require_react(), 1);
function usePreviousValue(value) {
  const [state, setState] = React31.useState({
    current: value,
    previous: null
  });
  if (value !== state.current) {
    setState({
      current: value,
      previous: state.current
    });
  }
  return state.previous;
}

// node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
var React32 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/utils/getCssDimensions.mjs
function getCssDimensions2(element) {
  const css = getComputedStyle2(element);
  let width = parseFloat(css.width) || 0;
  let height = parseFloat(css.height) || 0;
  const hasOffset = isHTMLElement(element);
  const offsetWidth = hasOffset ? element.offsetWidth : width;
  const offsetHeight = hasOffset ? element.offsetHeight : height;
  const shouldFallback = round(width) !== offsetWidth || round(height) !== offsetHeight;
  if (shouldFallback) {
    width = offsetWidth;
    height = offsetHeight;
  }
  return {
    width,
    height
  };
}

// node_modules/@base-ui/react/utils/usePopupAutoResize.mjs
function usePopupAutoResize(parameters) {
  const {
    popupElement,
    positionerElement,
    content,
    mounted,
    onMeasureLayout: onMeasureLayoutParam,
    onMeasureLayoutComplete: onMeasureLayoutCompleteParam,
    side,
    direction
  } = parameters;
  const runOnceAnimationsFinish = useAnimationsFinished(popupElement, true, false);
  const animationFrame = useAnimationFrame();
  const committedDimensionsRef = React32.useRef(null);
  const isInitialRenderRef = React32.useRef(true);
  const restoreAnchoringStylesRef = React32.useRef(NOOP);
  const onMeasureLayout = useStableCallback(onMeasureLayoutParam);
  const onMeasureLayoutComplete = useStableCallback(onMeasureLayoutCompleteParam);
  const anchoringStyles = React32.useMemo(() => {
    let isOriginSide = side === "top";
    let isPhysicalLeft = side === "left";
    if (direction === "rtl") {
      isOriginSide = isOriginSide || side === "inline-end";
      isPhysicalLeft = isPhysicalLeft || side === "inline-end";
    } else {
      isOriginSide = isOriginSide || side === "inline-start";
      isPhysicalLeft = isPhysicalLeft || side === "inline-start";
    }
    return isOriginSide ? {
      position: "absolute",
      [side === "top" ? "bottom" : "top"]: "0",
      [isPhysicalLeft ? "right" : "left"]: "0"
    } : EMPTY_OBJECT;
  }, [side, direction]);
  useIsoLayoutEffect(() => {
    if (!mounted) {
      restoreAnchoringStylesRef.current = NOOP;
      isInitialRenderRef.current = true;
      committedDimensionsRef.current = null;
      return void 0;
    }
    if (!popupElement || !positionerElement) {
      return void 0;
    }
    restoreAnchoringStylesRef.current = applyElementStyles(popupElement, anchoringStyles);
    setPopupCssSize(popupElement, "auto");
    const restorePopupPosition = overrideElementStyle(popupElement, "position", "static");
    const restorePopupTransform = overrideElementStyle(popupElement, "transform", "none");
    const restorePopupScale = overrideElementStyle(popupElement, "scale", "1");
    const restorePositionerAvailableSize = applyElementStyles(positionerElement, {
      "--available-width": "max-content",
      "--available-height": "max-content"
    });
    function restoreMeasurementOverrides() {
      restorePopupPosition();
      restorePopupTransform();
      restorePositionerAvailableSize();
    }
    function restoreMeasurementOverridesIncludingScale() {
      restoreMeasurementOverrides();
      restorePopupScale();
    }
    onMeasureLayout?.();
    if (isInitialRenderRef.current || committedDimensionsRef.current === null) {
      setPositionerCssSize(positionerElement, "max-content");
      const dimensions = getCssDimensions2(popupElement);
      committedDimensionsRef.current = dimensions;
      setPositionerCssSize(positionerElement, dimensions);
      restoreMeasurementOverridesIncludingScale();
      onMeasureLayoutComplete?.(null, dimensions);
      isInitialRenderRef.current = false;
      return () => {
        restoreAnchoringStylesRef.current();
        restoreAnchoringStylesRef.current = NOOP;
      };
    }
    setPositionerCssSize(positionerElement, "max-content");
    const previousDimensions = committedDimensionsRef.current;
    const newDimensions = getCssDimensions2(popupElement);
    committedDimensionsRef.current = newDimensions;
    setPopupCssSize(popupElement, previousDimensions);
    restoreMeasurementOverridesIncludingScale();
    onMeasureLayoutComplete?.(previousDimensions, newDimensions);
    setPositionerCssSize(positionerElement, newDimensions);
    const abortController = new AbortController();
    animationFrame.request(() => {
      setPopupCssSize(popupElement, newDimensions);
      runOnceAnimationsFinish(() => {
        popupElement.style.setProperty("--popup-width", "auto");
        popupElement.style.setProperty("--popup-height", "auto");
      }, abortController.signal);
    });
    return () => {
      abortController.abort();
      animationFrame.cancel();
      restoreAnchoringStylesRef.current();
      restoreAnchoringStylesRef.current = NOOP;
    };
  }, [content, popupElement, positionerElement, runOnceAnimationsFinish, animationFrame, mounted, onMeasureLayout, onMeasureLayoutComplete, anchoringStyles]);
}
function overrideElementStyle(element, property, value) {
  const originalValue = element.style.getPropertyValue(property);
  element.style.setProperty(property, value);
  return () => {
    element.style.setProperty(property, originalValue);
  };
}
function applyElementStyles(element, styles) {
  const restorers = [];
  for (const [key, value] of Object.entries(styles)) {
    restorers.push(overrideElementStyle(element, key, value));
  }
  return restorers.length ? () => {
    restorers.forEach((restore) => restore());
  } : NOOP;
}
function setPopupCssSize(popupElement, size4) {
  const width = size4 === "auto" ? "auto" : `${size4.width}px`;
  const height = size4 === "auto" ? "auto" : `${size4.height}px`;
  popupElement.style.setProperty("--popup-width", width);
  popupElement.style.setProperty("--popup-height", height);
}
function setPositionerCssSize(positionerElement, size4) {
  const width = size4 === "max-content" ? "max-content" : `${size4.width}px`;
  const height = size4 === "max-content" ? "max-content" : `${size4.height}px`;
  positionerElement.style.setProperty("--positioner-width", width);
  positionerElement.style.setProperty("--positioner-height", height);
}

// node_modules/@base-ui/react/utils/usePopupViewport.mjs
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
function usePopupViewport(parameters) {
  const {
    store,
    side,
    cssVars,
    children
  } = parameters;
  const direction = useDirection();
  const activeTrigger = store.useState("activeTriggerElement");
  const activeTriggerId = store.useState("activeTriggerId");
  const open = store.useState("open");
  const payload = store.useState("payload");
  const mounted = store.useState("mounted");
  const popupElement = store.useState("popupElement");
  const positionerElement = store.useState("positionerElement");
  const previousActiveTrigger = usePreviousValue(open ? activeTrigger : null);
  const currentContentKey = usePopupContentKey(activeTriggerId, payload);
  const capturedNodeRef = React33.useRef(null);
  const [previousContentNode, setPreviousContentNode] = React33.useState(null);
  const [newTriggerOffset, setNewTriggerOffset] = React33.useState(null);
  const currentContainerRef = React33.useRef(null);
  const previousContainerRef = React33.useRef(null);
  const onAnimationsFinished = useAnimationsFinished(currentContainerRef, true, false);
  const cleanupFrame = useAnimationFrame();
  const [previousContentDimensions, setPreviousContentDimensions] = React33.useState(null);
  const [showStartingStyleAttribute, setShowStartingStyleAttribute] = React33.useState(false);
  useIsoLayoutEffect(() => {
    store.set("hasViewport", true);
    return () => {
      store.set("hasViewport", false);
    };
  }, [store]);
  const handleMeasureLayout = useStableCallback(() => {
    currentContainerRef.current?.style.setProperty("animation", "none");
    currentContainerRef.current?.style.setProperty("transition", "none");
    previousContainerRef.current?.style.setProperty("display", "none");
  });
  const handleMeasureLayoutComplete = useStableCallback((previousDimensions) => {
    currentContainerRef.current?.style.removeProperty("animation");
    currentContainerRef.current?.style.removeProperty("transition");
    previousContainerRef.current?.style.removeProperty("display");
    if (previousDimensions) {
      setPreviousContentDimensions(previousDimensions);
    }
  });
  const lastHandledTriggerRef = React33.useRef(null);
  useIsoLayoutEffect(() => {
    if (!open || !mounted) {
      lastHandledTriggerRef.current = null;
    }
  }, [open, mounted]);
  useIsoLayoutEffect(() => {
    if (activeTrigger && previousActiveTrigger && activeTrigger !== previousActiveTrigger && lastHandledTriggerRef.current !== activeTrigger && capturedNodeRef.current) {
      setPreviousContentNode(capturedNodeRef.current);
      setShowStartingStyleAttribute(true);
      const offset4 = calculateRelativePosition(previousActiveTrigger, activeTrigger);
      setNewTriggerOffset(offset4);
      cleanupFrame.request(() => {
        ReactDOM6.flushSync(() => {
          setShowStartingStyleAttribute(false);
        });
        onAnimationsFinished(() => {
          setPreviousContentNode(null);
          setPreviousContentDimensions(null);
          capturedNodeRef.current = null;
        });
      });
      lastHandledTriggerRef.current = activeTrigger;
    }
  }, [activeTrigger, previousActiveTrigger, previousContentNode, onAnimationsFinished, cleanupFrame]);
  useIsoLayoutEffect(() => {
    const source = currentContainerRef.current;
    if (!source) {
      return;
    }
    const wrapper = ownerDocument(source).createElement("div");
    for (const child of Array.from(source.childNodes)) {
      wrapper.appendChild(child.cloneNode(true));
    }
    capturedNodeRef.current = wrapper;
  });
  const isTransitioning = previousContentNode != null;
  let childrenToRender;
  if (!isTransitioning) {
    childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
      "data-current": true,
      ref: currentContainerRef,
      children
    }, currentContentKey);
  } else {
    childrenToRender = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(React33.Fragment, {
      children: [/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
        "data-previous": true,
        inert: inertValue(true),
        ref: previousContainerRef,
        style: {
          ...previousContentDimensions ? {
            [cssVars.popupWidth]: `${previousContentDimensions.width}px`,
            [cssVars.popupHeight]: `${previousContentDimensions.height}px`
          } : null,
          position: "absolute"
        },
        "data-ending-style": showStartingStyleAttribute ? void 0 : ""
      }, "previous"), /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", {
        "data-current": true,
        ref: currentContainerRef,
        "data-starting-style": showStartingStyleAttribute ? "" : void 0,
        children
      }, currentContentKey)]
    });
  }
  useIsoLayoutEffect(() => {
    const container = previousContainerRef.current;
    if (!container || !previousContentNode) {
      return;
    }
    container.replaceChildren(...Array.from(previousContentNode.childNodes));
  }, [previousContentNode]);
  usePopupAutoResize({
    popupElement,
    positionerElement,
    mounted,
    content: payload,
    onMeasureLayout: handleMeasureLayout,
    onMeasureLayoutComplete: handleMeasureLayoutComplete,
    side,
    direction
  });
  const state = {
    activationDirection: getActivationDirection(newTriggerOffset),
    transitioning: isTransitioning
  };
  return {
    children: childrenToRender,
    state
  };
}
function getActivationDirection(offset4) {
  if (!offset4) {
    return void 0;
  }
  return `${getValueWithTolerance(offset4.horizontal, 5, "right", "left")} ${getValueWithTolerance(offset4.vertical, 5, "down", "up")}`;
}
function getValueWithTolerance(value, tolerance, positiveLabel, negativeLabel) {
  if (value > tolerance) {
    return positiveLabel;
  }
  if (value < -tolerance) {
    return negativeLabel;
  }
  return "";
}
function calculateRelativePosition(from, to) {
  const fromRect = from.getBoundingClientRect();
  const toRect = to.getBoundingClientRect();
  const fromCenter = {
    x: fromRect.left + fromRect.width / 2,
    y: fromRect.top + fromRect.height / 2
  };
  const toCenter = {
    x: toRect.left + toRect.width / 2,
    y: toRect.top + toRect.height / 2
  };
  return {
    horizontal: toCenter.x - fromCenter.x,
    vertical: toCenter.y - fromCenter.y
  };
}
function usePopupContentKey(activeTriggerId, payload) {
  const [contentKey, setContentKey] = React33.useState(0);
  const previousActiveTriggerIdRef = React33.useRef(activeTriggerId);
  const previousPayloadRef = React33.useRef(payload);
  const pendingPayloadUpdateRef = React33.useRef(false);
  useIsoLayoutEffect(() => {
    const previousActiveTriggerId = previousActiveTriggerIdRef.current;
    const previousPayload = previousPayloadRef.current;
    const triggerIdChanged = activeTriggerId !== previousActiveTriggerId;
    const payloadChanged = payload !== previousPayload;
    if (triggerIdChanged) {
      setContentKey((value) => value + 1);
      pendingPayloadUpdateRef.current = !payloadChanged;
    } else if (pendingPayloadUpdateRef.current && payloadChanged) {
      setContentKey((value) => value + 1);
      pendingPayloadUpdateRef.current = false;
    }
    previousActiveTriggerIdRef.current = activeTriggerId;
    previousPayloadRef.current = payload;
  }, [activeTriggerId, payload]);
  return `${activeTriggerId ?? "current"}-${contentKey}`;
}

// node_modules/@base-ui/react/utils/FloatingPortalLite.mjs
var React34 = __toESM(require_react(), 1);
var ReactDOM7 = __toESM(require_react_dom(), 1);
var import_jsx_runtime6 = __toESM(require_jsx_runtime(), 1);
var FloatingPortalLite = /* @__PURE__ */ React34.forwardRef(function FloatingPortalLite2(componentProps, forwardedRef) {
  const {
    children,
    container,
    className,
    render,
    style,
    ...elementProps
  } = componentProps;
  const {
    portalNode,
    portalSubtree
  } = useFloatingPortalNode({
    container,
    ref: forwardedRef,
    componentProps,
    elementProps
  });
  if (!portalSubtree && !portalNode) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(React34.Fragment, {
    children: [portalSubtree, portalNode && /* @__PURE__ */ ReactDOM7.createPortal(children, portalNode)]
  });
});
if (true) FloatingPortalLite.displayName = "FloatingPortalLite";

// node_modules/@base-ui/react/tooltip/index.parts.mjs
var index_parts_exports = {};
__export(index_parts_exports, {
  Arrow: () => TooltipArrow,
  Handle: () => TooltipHandle,
  Popup: () => TooltipPopup,
  Portal: () => TooltipPortal,
  Positioner: () => TooltipPositioner,
  Provider: () => TooltipProvider,
  Root: () => TooltipRoot,
  Trigger: () => TooltipTrigger,
  Viewport: () => TooltipViewport,
  createHandle: () => createTooltipHandle
});

// node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
var React37 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/tooltip/root/TooltipRootContext.mjs
var React35 = __toESM(require_react(), 1);
var TooltipRootContext = /* @__PURE__ */ React35.createContext(void 0);
if (true) TooltipRootContext.displayName = "TooltipRootContext";
function useTooltipRootContext(optional) {
  const context = React35.useContext(TooltipRootContext);
  if (context === void 0 && !optional) {
    throw new Error(true ? "Base UI: TooltipRootContext is missing. Tooltip parts must be placed within <Tooltip.Root>." : formatErrorMessage_default(72));
  }
  return context;
}

// node_modules/@base-ui/react/tooltip/store/TooltipStore.mjs
var React36 = __toESM(require_react(), 1);
var selectors2 = {
  ...popupStoreSelectors,
  disabled: createSelector((state) => state.disabled),
  instantType: createSelector((state) => state.instantType),
  isInstantPhase: createSelector((state) => state.isInstantPhase),
  trackCursorAxis: createSelector((state) => state.trackCursorAxis),
  disableHoverablePopup: createSelector((state) => state.disableHoverablePopup),
  lastOpenChangeReason: createSelector((state) => state.openChangeReason),
  closeOnClick: createSelector((state) => state.closeOnClick),
  closeDelay: createSelector((state) => state.closeDelay),
  hasViewport: createSelector((state) => state.hasViewport)
};
var TooltipStore = class _TooltipStore extends ReactStore {
  constructor(initialState, floatingId, nested = false) {
    const triggerElements = new PopupTriggerMap();
    const state = {
      ...createInitialState(),
      ...initialState
    };
    state.floatingRootContext = createPopupFloatingRootContext(triggerElements, floatingId, nested);
    super(state, {
      popupRef: /* @__PURE__ */ React36.createRef(),
      onOpenChange: void 0,
      onOpenChangeComplete: void 0,
      triggerElements
    }, selectors2);
  }
  setOpen = (nextOpen, eventDetails) => {
    applyPopupOpenChange(this, nextOpen, eventDetails, {
      extraState: {
        openChangeReason: eventDetails.reason
      }
    });
  };
  // Used by trigger clicks to clear a delayed hover open without reporting a public open-state change.
  cancelPendingOpen(event) {
    this.state.floatingRootContext.dispatchOpenChange(false, createChangeEventDetails(reason_parts_exports.triggerPress, event));
  }
  static useStore(externalStore, initialState) {
    const store = usePopupStore(externalStore, (floatingId, nested) => new _TooltipStore(initialState, floatingId, nested)).store;
    return store;
  }
};
function createInitialState() {
  return {
    ...createInitialPopupStoreState(),
    disabled: false,
    instantType: void 0,
    isInstantPhase: false,
    trackCursorAxis: "none",
    disableHoverablePopup: false,
    openChangeReason: null,
    closeOnClick: true,
    closeDelay: 0,
    hasViewport: false
  };
}

// node_modules/@base-ui/react/tooltip/root/TooltipRoot.mjs
var import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
var TooltipRoot = fastComponent(function TooltipRoot2(props) {
  const {
    disabled: disabled2 = false,
    defaultOpen = false,
    open: openProp,
    disableHoverablePopup = false,
    trackCursorAxis = "none",
    actionsRef,
    onOpenChange,
    onOpenChangeComplete,
    handle,
    triggerId: triggerIdProp,
    defaultTriggerId: defaultTriggerIdProp = null,
    children
  } = props;
  const store = TooltipStore.useStore(handle?.store, {
    open: defaultOpen,
    openProp,
    activeTriggerId: defaultTriggerIdProp,
    triggerIdProp
  });
  useInitialOpenSync(store, openProp, defaultOpen, defaultTriggerIdProp);
  store.useControlledProp("openProp", openProp);
  store.useControlledProp("triggerIdProp", triggerIdProp);
  store.useContextCallback("onOpenChange", onOpenChange);
  store.useContextCallback("onOpenChangeComplete", onOpenChangeComplete);
  const openState = store.useState("open");
  const open = !disabled2 && openState;
  const activeTriggerId = store.useState("activeTriggerId");
  const mounted = store.useState("mounted");
  const payload = store.useState("payload");
  store.useSyncedValues({
    trackCursorAxis,
    disableHoverablePopup
  });
  store.useSyncedValue("disabled", disabled2);
  useImplicitActiveTrigger(store, {
    closeOnActiveTriggerUnmount: true
  });
  const {
    forceUnmount,
    transitionStatus
  } = useOpenStateTransitions(open, store);
  const isInstantPhase = store.useState("isInstantPhase");
  const instantType = store.useState("instantType");
  const lastOpenChangeReason = store.useState("lastOpenChangeReason");
  const previousInstantTypeRef = React37.useRef(null);
  useIsoLayoutEffect(() => {
    if (openState && disabled2) {
      store.setOpen(false, createChangeEventDetails(reason_parts_exports.disabled));
    }
  }, [openState, disabled2, store]);
  useIsoLayoutEffect(() => {
    if (transitionStatus === "ending" && lastOpenChangeReason === reason_parts_exports.none || transitionStatus !== "ending" && isInstantPhase) {
      if (instantType !== "delay") {
        previousInstantTypeRef.current = instantType;
      }
      store.set("instantType", "delay");
    } else if (previousInstantTypeRef.current !== null) {
      store.set("instantType", previousInstantTypeRef.current);
      previousInstantTypeRef.current = null;
    }
  }, [transitionStatus, isInstantPhase, lastOpenChangeReason, instantType, store]);
  useIsoLayoutEffect(() => {
    if (open) {
      if (activeTriggerId == null) {
        store.set("payload", void 0);
      }
    }
  }, [store, activeTriggerId, open]);
  const handleImperativeClose = React37.useCallback(() => {
    store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction));
  }, [store]);
  React37.useImperativeHandle(actionsRef, () => ({
    unmount: forceUnmount,
    close: handleImperativeClose
  }), [forceUnmount, handleImperativeClose]);
  const shouldRenderInteractions = open || mounted || !disabled2 && trackCursorAxis !== "none";
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(TooltipRootContext.Provider, {
    value: store,
    children: [shouldRenderInteractions && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TooltipInteractions, {
      store,
      disabled: disabled2,
      trackCursorAxis
    }), typeof children === "function" ? children({
      payload
    }) : children]
  });
});
if (true) TooltipRoot.displayName = "TooltipRoot";
function TooltipInteractions({
  store,
  disabled: disabled2,
  trackCursorAxis
}) {
  const floatingRootContext = store.useState("floatingRootContext");
  const dismiss = useDismiss(floatingRootContext, {
    enabled: !disabled2,
    referencePress: () => store.select("closeOnClick")
  });
  const clientPoint = useClientPoint(floatingRootContext, {
    enabled: !disabled2 && trackCursorAxis !== "none",
    axis: trackCursorAxis === "none" ? void 0 : trackCursorAxis
  });
  const activeTriggerProps = React37.useMemo(() => mergeProps(clientPoint.reference, dismiss.reference), [clientPoint.reference, dismiss.reference]);
  const inactiveTriggerProps = React37.useMemo(() => mergeProps(clientPoint.trigger, dismiss.trigger), [clientPoint.trigger, dismiss.trigger]);
  const popupProps = React37.useMemo(() => mergeProps(FOCUSABLE_POPUP_PROPS, clientPoint.floating, dismiss.floating), [clientPoint.floating, dismiss.floating]);
  usePopupInteractionProps(store, {
    activeTriggerProps,
    inactiveTriggerProps,
    popupProps
  });
  return null;
}

// node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
var React39 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/tooltip/provider/TooltipProviderContext.mjs
var React38 = __toESM(require_react(), 1);
var TooltipProviderContext = /* @__PURE__ */ React38.createContext(void 0);
if (true) TooltipProviderContext.displayName = "TooltipProviderContext";
function useTooltipProviderContext() {
  return React38.useContext(TooltipProviderContext);
}

// node_modules/@base-ui/react/tooltip/trigger/TooltipTriggerDataAttributes.mjs
var TooltipTriggerDataAttributes = (function(TooltipTriggerDataAttributes2) {
  TooltipTriggerDataAttributes2[TooltipTriggerDataAttributes2["popupOpen"] = CommonTriggerDataAttributes.popupOpen] = "popupOpen";
  TooltipTriggerDataAttributes2["triggerDisabled"] = "data-trigger-disabled";
  return TooltipTriggerDataAttributes2;
})({});

// node_modules/@base-ui/react/tooltip/utils/constants.mjs
var OPEN_DELAY = 600;

// node_modules/@base-ui/react/tooltip/trigger/TooltipTrigger.mjs
var TOOLTIP_TRIGGER_IDENTIFIER = "data-base-ui-tooltip-trigger";
function getTargetElement(event) {
  if ("composedPath" in event) {
    const path = event.composedPath();
    for (let i2 = 0; i2 < path.length; i2 += 1) {
      const element = path[i2];
      if (isElement(element)) {
        return element;
      }
    }
  }
  const target = event.target;
  if (isElement(target)) {
    return target;
  }
  return null;
}
function closestEnabledTooltipTrigger(element) {
  let current = element;
  while (current) {
    if (current.hasAttribute(TOOLTIP_TRIGGER_IDENTIFIER)) {
      return current;
    }
    const parentElement = current.parentElement;
    if (parentElement) {
      current = parentElement;
      continue;
    }
    const root = current.getRootNode();
    current = "host" in root && isElement(root.host) ? root.host : null;
  }
  return null;
}
var TooltipTrigger = fastComponentRef(function TooltipTrigger2(componentProps, forwardedRef) {
  const {
    render,
    className,
    style,
    handle,
    payload,
    disabled: disabledProp,
    delay,
    closeOnClick = true,
    closeDelay,
    id: idProp,
    ...elementProps
  } = componentProps;
  const rootContext = useTooltipRootContext(true);
  const store = handle?.store ?? rootContext;
  if (!store) {
    throw new Error(true ? "Base UI: <Tooltip.Trigger> must be either used within a <Tooltip.Root> component or provided with a handle." : formatErrorMessage_default(82));
  }
  const thisTriggerId = useBaseUiId(idProp);
  const isTriggerActive = store.useState("isTriggerActive", thisTriggerId);
  const isOpenedByThisTrigger = store.useState("isOpenedByTrigger", thisTriggerId);
  const floatingRootContext = store.useState("floatingRootContext");
  const triggerElementRef = React39.useRef(null);
  const delayWithDefault = delay ?? OPEN_DELAY;
  const closeDelayWithDefault = closeDelay ?? 0;
  const {
    registerTrigger,
    isMountedByThisTrigger
  } = useTriggerDataForwarding(thisTriggerId, triggerElementRef, store, {
    payload,
    closeOnClick,
    closeDelay: closeDelayWithDefault
  });
  const providerContext = useTooltipProviderContext();
  const {
    delayRef,
    isInstantPhase,
    hasProvider
  } = useDelayGroup(floatingRootContext, {
    open: isOpenedByThisTrigger
  });
  const hoverInteraction = useHoverInteractionSharedState(floatingRootContext);
  store.useSyncedValue("isInstantPhase", isInstantPhase);
  const rootDisabled = store.useState("disabled");
  const disabled2 = disabledProp ?? rootDisabled;
  const disabledRef = useValueAsRef(disabled2);
  const trackCursorAxis = store.useState("trackCursorAxis");
  const disableHoverablePopup = store.useState("disableHoverablePopup");
  const isNestedTriggerHoveredRef = React39.useRef(false);
  const nestedTriggerOpenTimeout = useTimeout();
  const pointerTypeRef = React39.useRef(void 0);
  function getOpenDelay() {
    const providerDelay = providerContext?.delay;
    const groupOpenValue = typeof delayRef.current === "object" ? delayRef.current.open : void 0;
    let computedOpenDelay = delayWithDefault;
    if (hasProvider) {
      if (groupOpenValue !== 0) {
        computedOpenDelay = delay ?? providerDelay ?? delayWithDefault;
      } else {
        computedOpenDelay = 0;
      }
    }
    return computedOpenDelay;
  }
  function isEnabledNestedTriggerTarget(target) {
    const triggerEl = triggerElementRef.current;
    if (!triggerEl || !target) {
      return false;
    }
    const nearestTrigger = closestEnabledTooltipTrigger(target);
    return nearestTrigger !== null && nearestTrigger !== triggerEl && contains(triggerEl, nearestTrigger);
  }
  function detectNestedTriggerHover(target) {
    const nestedTriggerHovered = isEnabledNestedTriggerTarget(target);
    isNestedTriggerHoveredRef.current = nestedTriggerHovered;
    if (nestedTriggerHovered) {
      hoverInteraction.openChangeTimeout.clear();
      hoverInteraction.restTimeout.clear();
      hoverInteraction.restTimeoutPending = false;
      nestedTriggerOpenTimeout.clear();
    }
    return nestedTriggerHovered;
  }
  const hoverProps = useHoverReferenceInteraction(floatingRootContext, {
    enabled: !disabled2,
    mouseOnly: true,
    move: false,
    handleClose: !disableHoverablePopup && trackCursorAxis !== "both" ? safePolygon() : null,
    restMs: getOpenDelay,
    delay() {
      const closeValue = typeof delayRef.current === "object" ? delayRef.current.close : void 0;
      let computedCloseDelay = closeDelayWithDefault;
      if (closeDelay == null && hasProvider) {
        computedCloseDelay = closeValue;
      }
      return {
        close: computedCloseDelay
      };
    },
    triggerElementRef,
    isActiveTrigger: isTriggerActive,
    isClosing: () => store.select("transitionStatus") === "ending",
    shouldOpen() {
      return !isNestedTriggerHoveredRef.current;
    }
  });
  const focusProps = useFocus(floatingRootContext, {
    enabled: !disabled2
  }).reference;
  const handleNestedTriggerHover = (event) => {
    const wasNestedTriggerHovered = isNestedTriggerHoveredRef.current;
    const target = getTargetElement(event);
    const nestedTriggerHovered = detectNestedTriggerHover(target);
    const triggerEl = triggerElementRef.current;
    const targetInsideTrigger = triggerEl && target && contains(triggerEl, target);
    if (nestedTriggerHovered && store.select("open") && store.select("lastOpenChangeReason") === reason_parts_exports.triggerHover) {
      store.setOpen(false, createChangeEventDetails(reason_parts_exports.triggerHover, event));
      return;
    }
    if (wasNestedTriggerHovered && !nestedTriggerHovered && targetInsideTrigger && !disabledRef.current && !store.select("open") && triggerEl && // Match the hover hook's non-strict mouse fallback for mouse-only event sequences.
    isMouseLikePointerType(pointerTypeRef.current)) {
      const open = () => {
        if (!isNestedTriggerHoveredRef.current && !disabledRef.current && !store.select("open")) {
          store.setOpen(true, createChangeEventDetails(reason_parts_exports.triggerHover, event, triggerEl));
        }
      };
      const openDelay = getOpenDelay();
      if (openDelay === 0) {
        nestedTriggerOpenTimeout.clear();
        open();
      } else {
        nestedTriggerOpenTimeout.start(openDelay, open);
      }
    }
  };
  const rootTriggerProps = store.useState("triggerProps", isMountedByThisTrigger);
  const shouldApplyRootTriggerProps = isMountedByThisTrigger || trackCursorAxis !== "none";
  const state = {
    open: isOpenedByThisTrigger
  };
  const element = useRenderElement("button", componentProps, {
    state,
    ref: [forwardedRef, registerTrigger, triggerElementRef],
    props: [hoverProps, focusProps, shouldApplyRootTriggerProps ? rootTriggerProps : void 0, {
      onMouseOver(event) {
        handleNestedTriggerHover(event.nativeEvent);
      },
      onFocus(event) {
        if (isEnabledNestedTriggerTarget(getTargetElement(event.nativeEvent))) {
          event.preventBaseUIHandler();
        }
      },
      onMouseLeave() {
        isNestedTriggerHoveredRef.current = false;
        nestedTriggerOpenTimeout.clear();
        pointerTypeRef.current = void 0;
      },
      onPointerEnter(event) {
        pointerTypeRef.current = event.pointerType;
      },
      onPointerDown(event) {
        pointerTypeRef.current = event.pointerType;
        store.set("closeOnClick", closeOnClick);
        if (closeOnClick && !store.select("open")) {
          store.cancelPendingOpen(event.nativeEvent);
        }
      },
      onClick(event) {
        if (closeOnClick && !store.select("open")) {
          store.cancelPendingOpen(event.nativeEvent);
        }
      },
      id: thisTriggerId,
      [TooltipTriggerDataAttributes.triggerDisabled]: disabled2 ? "" : void 0,
      [TOOLTIP_TRIGGER_IDENTIFIER]: disabled2 ? void 0 : ""
    }, elementProps],
    stateAttributesMapping: triggerOpenStateMapping
  });
  return element;
});
if (true) TooltipTrigger.displayName = "TooltipTrigger";

// node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
var React41 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/tooltip/portal/TooltipPortalContext.mjs
var React40 = __toESM(require_react(), 1);
var TooltipPortalContext = /* @__PURE__ */ React40.createContext(void 0);
if (true) TooltipPortalContext.displayName = "TooltipPortalContext";
function useTooltipPortalContext() {
  const value = React40.useContext(TooltipPortalContext);
  if (value === void 0) {
    throw new Error(true ? "Base UI: <Tooltip.Portal> is missing." : formatErrorMessage_default(70));
  }
  return value;
}

// node_modules/@base-ui/react/tooltip/portal/TooltipPortal.mjs
var import_jsx_runtime8 = __toESM(require_jsx_runtime(), 1);
var TooltipPortal = /* @__PURE__ */ React41.forwardRef(function TooltipPortal2(props, forwardedRef) {
  const {
    keepMounted = false,
    ...portalProps
  } = props;
  const store = useTooltipRootContext();
  const mounted = store.useState("mounted");
  const shouldRender = mounted || keepMounted;
  if (!shouldRender) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TooltipPortalContext.Provider, {
    value: keepMounted,
    children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloatingPortalLite, {
      ref: forwardedRef,
      ...portalProps
    })
  });
});
if (true) TooltipPortal.displayName = "TooltipPortal";

// node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
var React43 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/tooltip/positioner/TooltipPositionerContext.mjs
var React42 = __toESM(require_react(), 1);
var TooltipPositionerContext = /* @__PURE__ */ React42.createContext(void 0);
if (true) TooltipPositionerContext.displayName = "TooltipPositionerContext";
function useTooltipPositionerContext() {
  const context = React42.useContext(TooltipPositionerContext);
  if (context === void 0) {
    throw new Error(true ? "Base UI: TooltipPositionerContext is missing. TooltipPositioner parts must be placed within <Tooltip.Positioner>." : formatErrorMessage_default(71));
  }
  return context;
}

// node_modules/@base-ui/react/tooltip/positioner/TooltipPositioner.mjs
var import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
var TooltipPositioner = /* @__PURE__ */ React43.forwardRef(function TooltipPositioner2(componentProps, forwardedRef) {
  const {
    render,
    className,
    anchor,
    positionMethod = "absolute",
    side = "top",
    align = "center",
    sideOffset = 0,
    alignOffset = 0,
    collisionBoundary = "clipping-ancestors",
    collisionPadding = 5,
    arrowPadding = 5,
    sticky = false,
    disableAnchorTracking = false,
    collisionAvoidance = POPUP_COLLISION_AVOIDANCE,
    style,
    ...elementProps
  } = componentProps;
  const store = useTooltipRootContext();
  const keepMounted = useTooltipPortalContext();
  const open = store.useState("open");
  const mounted = store.useState("mounted");
  const trackCursorAxis = store.useState("trackCursorAxis");
  const disableHoverablePopup = store.useState("disableHoverablePopup");
  const floatingRootContext = store.useState("floatingRootContext");
  const instantType = store.useState("instantType");
  const transitionStatus = store.useState("transitionStatus");
  const hasViewport = store.useState("hasViewport");
  const positioning = useAnchorPositioning({
    anchor,
    positionMethod,
    floatingRootContext,
    mounted,
    side,
    sideOffset,
    align,
    alignOffset,
    collisionBoundary,
    collisionPadding,
    sticky,
    arrowPadding,
    disableAnchorTracking,
    keepMounted,
    collisionAvoidance,
    adaptiveOrigin: hasViewport ? adaptiveOrigin : void 0
  });
  const state = React43.useMemo(() => ({
    open,
    side: positioning.side,
    align: positioning.align,
    anchorHidden: positioning.anchorHidden,
    instant: trackCursorAxis !== "none" ? "tracking-cursor" : instantType
  }), [open, positioning.side, positioning.align, positioning.anchorHidden, trackCursorAxis, instantType]);
  const element = usePositioner(componentProps, state, {
    styles: positioning.positionerStyles,
    transitionStatus,
    props: elementProps,
    refs: [forwardedRef, store.useStateSetter("positionerElement")],
    hidden: !mounted,
    inert: !open || trackCursorAxis === "both" || disableHoverablePopup
  });
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TooltipPositionerContext.Provider, {
    value: positioning,
    children: element
  });
});
if (true) TooltipPositioner.displayName = "TooltipPositioner";

// node_modules/@base-ui/react/tooltip/popup/TooltipPopup.mjs
var React44 = __toESM(require_react(), 1);
var stateAttributesMapping = {
  ...popupStateMapping,
  ...transitionStatusMapping
};
var TooltipPopup = /* @__PURE__ */ React44.forwardRef(function TooltipPopup2(componentProps, forwardedRef) {
  const {
    render,
    className,
    style,
    ...elementProps
  } = componentProps;
  const store = useTooltipRootContext();
  const {
    side,
    align
  } = useTooltipPositionerContext();
  const open = store.useState("open");
  const instantType = store.useState("instantType");
  const transitionStatus = store.useState("transitionStatus");
  const popupProps = store.useState("popupProps");
  const floatingContext = store.useState("floatingRootContext");
  const disabled2 = store.useState("disabled");
  const closeDelay = store.useState("closeDelay");
  useOpenChangeComplete({
    open,
    ref: store.context.popupRef,
    onComplete() {
      if (open) {
        store.context.onOpenChangeComplete?.(true);
      }
    }
  });
  useHoverFloatingInteraction(floatingContext, {
    enabled: !disabled2,
    closeDelay
  });
  const setPopupElement = store.useStateSetter("popupElement");
  const state = {
    open,
    side,
    align,
    instant: instantType,
    transitionStatus
  };
  const element = useRenderElement("div", componentProps, {
    state,
    ref: [forwardedRef, store.context.popupRef, setPopupElement],
    props: [popupProps, getDisabledMountTransitionStyles(transitionStatus), elementProps],
    stateAttributesMapping
  });
  return element;
});
if (true) TooltipPopup.displayName = "TooltipPopup";

// node_modules/@base-ui/react/tooltip/arrow/TooltipArrow.mjs
var React45 = __toESM(require_react(), 1);
var TooltipArrow = /* @__PURE__ */ React45.forwardRef(function TooltipArrow2(componentProps, forwardedRef) {
  const {
    render,
    className,
    style,
    ...elementProps
  } = componentProps;
  const store = useTooltipRootContext();
  const {
    arrowRef,
    side,
    align,
    arrowUncentered,
    arrowStyles
  } = useTooltipPositionerContext();
  const open = store.useState("open");
  const instantType = store.useState("instantType");
  const state = {
    open,
    side,
    align,
    uncentered: arrowUncentered,
    instant: instantType
  };
  const element = useRenderElement("div", componentProps, {
    state,
    ref: [forwardedRef, arrowRef],
    props: [{
      style: arrowStyles,
      "aria-hidden": true
    }, elementProps],
    stateAttributesMapping: popupStateMapping
  });
  return element;
});
if (true) TooltipArrow.displayName = "TooltipArrow";

// node_modules/@base-ui/react/tooltip/provider/TooltipProvider.mjs
var React46 = __toESM(require_react(), 1);
var import_jsx_runtime10 = __toESM(require_jsx_runtime(), 1);
var TooltipProvider = function TooltipProvider2(props) {
  const {
    delay,
    closeDelay,
    timeout = 400
  } = props;
  const contextValue = React46.useMemo(() => ({
    delay,
    closeDelay
  }), [delay, closeDelay]);
  const delayValue = React46.useMemo(() => ({
    open: delay,
    close: closeDelay
  }), [delay, closeDelay]);
  return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(TooltipProviderContext.Provider, {
    value: contextValue,
    children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(FloatingDelayGroup, {
      delay: delayValue,
      timeoutMs: timeout,
      children: props.children
    })
  });
};
if (true) TooltipProvider.displayName = "TooltipProvider";

// node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
var React47 = __toESM(require_react(), 1);

// node_modules/@base-ui/react/tooltip/viewport/TooltipViewportCssVars.mjs
var TooltipViewportCssVars = /* @__PURE__ */ (function(TooltipViewportCssVars2) {
  TooltipViewportCssVars2["popupWidth"] = "--popup-width";
  TooltipViewportCssVars2["popupHeight"] = "--popup-height";
  return TooltipViewportCssVars2;
})({});

// node_modules/@base-ui/react/tooltip/viewport/TooltipViewport.mjs
var stateAttributesMapping2 = {
  activationDirection: (value) => value ? {
    "data-activation-direction": value
  } : null
};
var TooltipViewport = /* @__PURE__ */ React47.forwardRef(function TooltipViewport2(componentProps, forwardedRef) {
  const {
    render,
    className,
    style,
    children,
    ...elementProps
  } = componentProps;
  const store = useTooltipRootContext();
  const positioner = useTooltipPositionerContext();
  const instantType = store.useState("instantType");
  const {
    children: childrenToRender,
    state: viewportState
  } = usePopupViewport({
    store,
    side: positioner.side,
    cssVars: TooltipViewportCssVars,
    children
  });
  const state = {
    activationDirection: viewportState.activationDirection,
    transitioning: viewportState.transitioning,
    instant: instantType
  };
  return useRenderElement("div", componentProps, {
    state,
    ref: forwardedRef,
    props: [elementProps, {
      children: childrenToRender
    }],
    stateAttributesMapping: stateAttributesMapping2
  });
});
if (true) TooltipViewport.displayName = "TooltipViewport";

// node_modules/@base-ui/react/tooltip/store/TooltipHandle.mjs
var TooltipHandle = class {
  /**
   * Internal store holding the tooltip state.
   * @internal
   */
  constructor() {
    this.store = new TooltipStore();
  }
  /**
   * Opens the tooltip and associates it with the trigger with the given ID.
   * The trigger must be a Tooltip.Trigger component with this handle passed as a prop.
   *
   * This method should only be called in an event handler or an effect (not during rendering).
   *
   * @param triggerId ID of the trigger to associate with the tooltip.
   */
  open(triggerId) {
    const triggerElement = triggerId ? this.store.context.triggerElements.getById(triggerId) : void 0;
    if (triggerId && !triggerElement) {
      throw new Error(true ? `Base UI: TooltipHandle.open: No trigger found with id "${triggerId}".` : formatErrorMessage_default(81, triggerId));
    }
    this.store.setOpen(true, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, triggerElement));
  }
  /**
   * Closes the tooltip.
   */
  close() {
    this.store.setOpen(false, createChangeEventDetails(reason_parts_exports.imperativeAction, void 0, void 0));
  }
  /**
   * Indicates whether the tooltip is currently open.
   */
  get isOpen() {
    return this.store.select("open");
  }
};
function createTooltipHandle() {
  return new TooltipHandle();
}

// node_modules/@base-ui/react/use-render/useRender.mjs
function useRender(params) {
  return useRenderElement(params.defaultTagName ?? "div", params, params);
}

// packages/ui/build-module/text/text.mjs
var import_element10 = __toESM(require_element(), 1);
var STYLE_HASH_ATTRIBUTE = "data-wp-hash";
function getRuntime() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument(targetDocument) {
  const runtime = getRuntime();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle(hash, css) {
  const runtime = getRuntime();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle("a495f9d138", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._83ed8a8da5dd50ea__text{margin:0}._14437cfb77831647__heading-2xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-2xl,32px);--_gcd-p-line-height:var(--wpds-typography-line-height-2xl,40px);font-size:var(--wpds-typography-font-size-2xl,32px);line-height:var(--wpds-typography-line-height-2xl,40px)}._14437cfb77831647__heading-2xl,._3c78b7fa9b4072dd__heading-xl{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600)}._3c78b7fa9b4072dd__heading-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-md,24px)}.aa58f227716bcde2__heading-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-lg,15px)}.aa58f227716bcde2__heading-lg,.fc4da56d8dfe52c4__heading-md{font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-sm,20px)}.fc4da56d8dfe52c4__heading-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px)}.a9b78c7c82e8dff7__heading-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-emphasis,600);--_gcd-p-font-size:var(--wpds-typography-font-size-xs,11px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-family:var(--wpds-typography-font-family-heading,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-xs,11px);font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:var(--wpds-typography-line-height-xs,16px);text-transform:uppercase}._305ff559e52180d5__body-xl{--_gcd-heading-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-xl,20px);--_gcd-p-line-height:var(--wpds-typography-line-height-xl,32px);font-size:var(--wpds-typography-font-size-xl,20px);line-height:var(--wpds-typography-line-height-xl,32px)}._305ff559e52180d5__body-xl,.ca1aa3fc2029e958__body-lg{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}.ca1aa3fc2029e958__body-lg{--_gcd-heading-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-lg,15px);--_gcd-p-line-height:var(--wpds-typography-line-height-md,24px);font-size:var(--wpds-typography-font-size-lg,15px);line-height:var(--wpds-typography-line-height-md,24px)}._131101940be12424__body-md{--_gcd-heading-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-md,13px);--_gcd-p-line-height:var(--wpds-typography-line-height-sm,20px);font-size:var(--wpds-typography-font-size-md,13px);line-height:var(--wpds-typography-line-height-sm,20px)}._0e8d87a42c1f75fa__body-sm,._131101940be12424__body-md{font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-weight:var(--wpds-typography-font-weight-default,400)}._0e8d87a42c1f75fa__body-sm{--_gcd-heading-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-heading-font-weight:var(--wpds-typography-font-weight-default,400);--_gcd-p-font-size:var(--wpds-typography-font-size-sm,12px);--_gcd-p-line-height:var(--wpds-typography-line-height-xs,16px);font-size:var(--wpds-typography-font-size-sm,12px);line-height:var(--wpds-typography-line-height-xs,16px)}}}');
}
var style_default = { "text": "_83ed8a8da5dd50ea__text", "heading-2xl": "_14437cfb77831647__heading-2xl", "heading-xl": "_3c78b7fa9b4072dd__heading-xl", "heading-lg": "aa58f227716bcde2__heading-lg", "heading-md": "fc4da56d8dfe52c4__heading-md", "heading-sm": "a9b78c7c82e8dff7__heading-sm", "body-xl": "_305ff559e52180d5__body-xl", "body-lg": "ca1aa3fc2029e958__body-lg", "body-md": "_131101940be12424__body-md", "body-sm": "_0e8d87a42c1f75fa__body-sm" };
if (typeof process === "undefined" || true) {
  registerStyle("af6d9984a6", "._6defc79820e382c6__button{box-sizing:var(--_gcd-button-box-sizing,border-box);font-family:var(--_gcd-button-font-family,inherit);font-size:var(--_gcd-button-font-size,inherit);font-weight:var(--_gcd-button-font-weight,inherit)}.d2cff2e5dea83bd1__input{box-sizing:var(--_gcd-input-box-sizing,border-box);font-family:var(--_gcd-input-font-family,inherit);font-size:var(--_gcd-input-font-size,inherit);font-weight:var(--_gcd-input-font-weight,inherit);margin:var(--_gcd-input-margin,0);&:is(textarea,[type=text],[type=password],[type=color],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){background-color:var(--_gcd-input-background-color,transparent);border:var(--_gcd-input-border,none);border-radius:var(--_gcd-input-border-radius,0);box-shadow:var(--_gcd-input-box-shadow,0 0 0 transparent);color:var(--_gcd-input-color,var(--wpds-color-foreground-interactive-neutral,#1e1e1e));&:focus{border-color:var(--_gcd-input-border-color-focus,var(--wp-admin-theme-color));box-shadow:var(--_gcd-input-box-shadow-focus,none);outline:var(--_gcd-input-outline-focus,none)}&:disabled{background:var(--_gcd-input-background-disabled,transparent);border-color:var(--_gcd-input-border-color-disabled,transparent);box-shadow:var(--_gcd-input-box-shadow-disabled,none);color:var(--_gcd-input-color-disabled,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}&::placeholder{color:var(--_gcd-input-placeholder-color,var(--wpds-color-foreground-interactive-neutral-disabled,#8d8d8d))}}&:is(textarea,[type=text],[type=password],[type=date],[type=datetime],[type=datetime-local],[type=email],[type=month],[type=number],[type=search],[type=tel],[type=time],[type=url],[type=week]){line-height:var(--_gcd-input-line-height,inherit);min-height:var(--_gcd-input-min-height,auto);padding:var(--_gcd-input-padding,0)}}._547d86373d02e108__textarea{box-sizing:var(--_gcd-textarea-box-sizing,border-box);overflow:var(--_gcd-textarea-overflow,auto);resize:var(--_gcd-textarea-resize,block)}._8c15fd0ed9f28ba4__div{outline:var(--_gcd-div-outline,0 solid transparent)}p._43cec3e1eec1066d__p{font-size:var(--_gcd-p-font-size,13px);line-height:var(--_gcd-p-line-height,1.5);margin:var(--_gcd-p-margin,0)}:is(h1,h2,h3,h4,h5,h6).e97669c6d9a38497__heading{color:var(--_gcd-heading-color,var(--wpds-color-foreground-content-neutral,#1e1e1e));font-size:var(--_gcd-heading-font-size,inherit);font-weight:var(--_gcd-heading-font-weight,var(--wpds-typography-font-weight-emphasis,600));margin:var(--_gcd-heading-margin,0)}._2c0831b0499dbd6e__a,._2c0831b0499dbd6e__a:is(:hover,:focus,:active){border-radius:var(--_gcd-a-border-radius,0);box-shadow:var(--_gcd-a-box-shadow,none);color:var(--_gcd-a-color,inherit);outline:var(--_gcd-a-outline,0 solid transparent);transition:var(--_gcd-a-transition,none)}");
}
var global_css_defense_default = { "button": "_6defc79820e382c6__button", "input": "d2cff2e5dea83bd1__input", "textarea": "_547d86373d02e108__textarea", "div": "_8c15fd0ed9f28ba4__div", "p": "_43cec3e1eec1066d__p", "heading": "e97669c6d9a38497__heading", "a": "_2c0831b0499dbd6e__a" };
var Text = (0, import_element10.forwardRef)(function Text2({ variant = "body-md", render, className, ...props }, ref) {
  const element = useRender({
    render,
    defaultTagName: "span",
    ref,
    props: mergeProps(props, {
      className: clsx_default(
        style_default.text,
        global_css_defense_default.heading,
        global_css_defense_default.p,
        style_default[variant],
        className
      )
    })
  });
  return element;
});

// packages/icons/build-module/icon/index.mjs
var import_element11 = __toESM(require_element(), 1);
var icon_default = (0, import_element11.forwardRef)(
  ({ icon, size: size4 = 24, ...props }, ref) => {
    return (0, import_element11.cloneElement)(icon, {
      width: size4,
      height: size4,
      ...props,
      ref
    });
  }
);

// packages/icons/build-module/library/chevron-left.mjs
var import_primitives = __toESM(require_primitives(), 1);
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_primitives.Path, { d: "M14.6 7l-1.2-1L8 12l5.4 6 1.2-1-4.6-5z" }) });

// packages/icons/build-module/library/chevron-right.mjs
var import_primitives2 = __toESM(require_primitives(), 1);
var import_jsx_runtime12 = __toESM(require_jsx_runtime(), 1);
var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_primitives2.Path, { d: "M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" }) });

// packages/icons/build-module/library/more-vertical.mjs
var import_primitives3 = __toESM(require_primitives(), 1);
var import_jsx_runtime13 = __toESM(require_jsx_runtime(), 1);
var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_primitives3.Path, { d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z" }) });

// packages/icons/build-module/library/next.mjs
var import_primitives4 = __toESM(require_primitives(), 1);
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
var next_default = /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_primitives4.Path, { d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z" }) });

// packages/icons/build-module/library/previous.mjs
var import_primitives5 = __toESM(require_primitives(), 1);
var import_jsx_runtime15 = __toESM(require_jsx_runtime(), 1);
var previous_default = /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_primitives5.Path, { d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z" }) });

// packages/ui/build-module/utils/render-slot-with-children.mjs
var import_element12 = __toESM(require_element(), 1);
function renderSlotWithChildren(slot, defaultSlot, children) {
  return (0, import_element12.cloneElement)(slot ?? defaultSlot, { children });
}

// packages/ui/build-module/utils/theme-provider.mjs
var theme = __toESM(require_theme(), 1);

// packages/ui/build-module/lock-unlock.mjs
var import_private_apis = __toESM(require_private_apis(), 1);
var { lock, unlock } = (0, import_private_apis.__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/ui"
);

// packages/ui/build-module/utils/theme-provider.mjs
function getThemeProvider() {
  const themePackage = theme;
  if (themePackage.ThemeProvider) {
    return themePackage.ThemeProvider;
  }
  if (!themePackage.privateApis) {
    throw new Error(
      "@wordpress/ui: @wordpress/theme must expose `ThemeProvider` or `privateApis.ThemeProvider`."
    );
  }
  return unlock(
    themePackage.privateApis
  ).ThemeProvider;
}
var ThemeProvider = getThemeProvider();

// packages/ui/build-module/stack/stack.mjs
var import_element13 = __toESM(require_element(), 1);
var STYLE_HASH_ATTRIBUTE2 = "data-wp-hash";
function getRuntime2() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument2(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash2(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE2}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE2) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle2(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime2();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash2(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE2, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument2(targetDocument) {
  const runtime = getRuntime2();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle2(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle2(hash, css) {
  const runtime = getRuntime2();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle2(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle2("32aba35fe1", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._19ce0419607e1896__stack{display:flex}}}");
}
var style_default2 = { "stack": "_19ce0419607e1896__stack" };
var gapTokens = {
  xs: "var(--wpds-dimension-gap-xs, 4px)",
  sm: "var(--wpds-dimension-gap-sm, 8px)",
  md: "var(--wpds-dimension-gap-md, 12px)",
  lg: "var(--wpds-dimension-gap-lg, 16px)",
  xl: "var(--wpds-dimension-gap-xl, 24px)",
  "2xl": "var(--wpds-dimension-gap-2xl, 32px)",
  "3xl": "var(--wpds-dimension-gap-3xl, 40px)"
};
var Stack = (0, import_element13.forwardRef)(function Stack2({ direction, gap, align, justify, wrap, render, ...props }, ref) {
  const style = {
    gap: gap && gapTokens[gap],
    alignItems: align,
    justifyContent: justify,
    flexDirection: direction,
    flexWrap: wrap
  };
  const element = useRender({
    render,
    ref,
    props: mergeProps(props, { style, className: style_default2.stack })
  });
  return element;
});

// packages/ui/build-module/tooltip/index.mjs
var tooltip_exports = {};
__export(tooltip_exports, {
  Popup: () => Popup,
  Portal: () => Portal,
  Positioner: () => Positioner,
  Provider: () => Provider,
  Root: () => Root,
  Trigger: () => Trigger
});

// packages/ui/build-module/tooltip/popup.mjs
var import_element16 = __toESM(require_element(), 1);

// packages/ui/build-module/tooltip/portal.mjs
var import_element14 = __toESM(require_element(), 1);

// packages/ui/build-module/utils/wp-compat-overlay-slot.mjs
var STYLE_HASH_ATTRIBUTE3 = "data-wp-hash";
function getRuntime3() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument3(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash3(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE3}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE3) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle3(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime3();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash3(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE3, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument3(targetDocument) {
  const runtime = getRuntime3();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle3(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle3(hash, css) {
  const runtime = getRuntime3();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle3(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle3("be37f31c1e", "._11fc52b637ff8a7e__slot{inset:0;isolation:isolate;pointer-events:none;position:fixed;z-index:1000000003}@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._11fc52b637ff8a7e__slot>*{pointer-events:auto}}}");
}
var wp_compat_overlay_slot_default = { "slot": "_11fc52b637ff8a7e__slot" };
var WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE = "data-wp-compat-overlay-slot";
function resolveOwnerDocument() {
  return typeof document === "undefined" ? null : document;
}
function isInWordPressEnvironment() {
  let topWp;
  try {
    topWp = window.top?.wp;
  } catch {
  }
  const wp = topWp ?? window.wp;
  return typeof wp?.components === "object" && wp.components !== null;
}
var cachedSlot = null;
function ensureSlotIsAccessible(element) {
  element.setAttribute("aria-hidden", "false");
  return element;
}
function createSlot(ownerDocument2) {
  const element = ownerDocument2.createElement("div");
  element.setAttribute(WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE, "");
  if (wp_compat_overlay_slot_default.slot) {
    element.classList.add(wp_compat_overlay_slot_default.slot);
  }
  ownerDocument2.body.appendChild(element);
  return element;
}
function getWpCompatOverlaySlot() {
  if (typeof window === "undefined") {
    return void 0;
  }
  if (!isInWordPressEnvironment() && window.__wpUiCompatOverlaySlotEnabled !== true) {
    return void 0;
  }
  const ownerDocument2 = resolveOwnerDocument();
  if (!ownerDocument2 || !ownerDocument2.body) {
    return void 0;
  }
  if (cachedSlot && cachedSlot.ownerDocument === ownerDocument2 && cachedSlot.isConnected) {
    return ensureSlotIsAccessible(cachedSlot);
  }
  const existing = ownerDocument2.querySelector(
    `[${WP_COMPAT_OVERLAY_SLOT_ATTRIBUTE}]`
  );
  if (existing instanceof HTMLDivElement) {
    cachedSlot = ensureSlotIsAccessible(existing);
    return cachedSlot;
  }
  if (cachedSlot?.isConnected) {
    cachedSlot.remove();
  }
  cachedSlot = ensureSlotIsAccessible(createSlot(ownerDocument2));
  return cachedSlot;
}

// packages/ui/build-module/tooltip/portal.mjs
var import_jsx_runtime16 = __toESM(require_jsx_runtime(), 1);
var Portal = (0, import_element14.forwardRef)(
  function TooltipPortal3({ container, ...restProps }, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
      index_parts_exports.Portal,
      {
        container: container ?? getWpCompatOverlaySlot(),
        ...restProps,
        ref
      }
    );
  }
);

// packages/ui/build-module/tooltip/positioner.mjs
var import_element15 = __toESM(require_element(), 1);
var import_jsx_runtime17 = __toESM(require_jsx_runtime(), 1);
var STYLE_HASH_ATTRIBUTE4 = "data-wp-hash";
function getRuntime4() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument4(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash4(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE4}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE4) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle4(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime4();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash4(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE4, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument4(targetDocument) {
  const runtime = getRuntime4();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle4(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle4(hash, css) {
  const runtime = getRuntime4();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle4(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle4("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
}
var resets_default = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
if (typeof process === "undefined" || true) {
  registerStyle4("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
}
var style_default3 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
var Positioner = (0, import_element15.forwardRef)(
  function TooltipPositioner3({ align = "center", className, side = "top", sideOffset = 4, ...props }, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
      index_parts_exports.Positioner,
      {
        ref,
        align,
        side,
        sideOffset,
        ...props,
        className: clsx_default(
          resets_default["box-sizing"],
          style_default3.positioner,
          className
        )
      }
    );
  }
);

// packages/ui/build-module/tooltip/popup.mjs
var import_jsx_runtime18 = __toESM(require_jsx_runtime(), 1);
var STYLE_HASH_ATTRIBUTE5 = "data-wp-hash";
function getRuntime5() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument5(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash5(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE5}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE5) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle5(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime5();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash5(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE5, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument5(targetDocument) {
  const runtime = getRuntime5();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle5(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle5(hash, css) {
  const runtime = getRuntime5();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle5(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle5("19fcc06039", '@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{._480b748dd3510e64__positioner{z-index:var(--wp-ui-tooltip-z-index,initial)}._50096b232db7709d__popup{--_wp-ui-elevation-sm:0 1px 2px rgba(0,0,0,.05),0 2px 3px rgba(0,0,0,.04),0 6px 6px rgba(0,0,0,.03),0 8px 8px rgba(0,0,0,.02);background-color:var(--wpds-color-background-surface-neutral-strong,#fff);border-radius:var(--wpds-border-radius-md,4px);box-shadow:var(--_wp-ui-elevation-sm);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);font-family:var(--wpds-typography-font-family-body,-apple-system,system-ui,"Segoe UI","Roboto","Oxygen-Sans","Ubuntu","Cantarell","Helvetica Neue",sans-serif);font-size:var(--wpds-typography-font-size-sm,12px);line-height:1.4;padding:var(--wpds-dimension-padding-xs,4px) var(--wpds-dimension-padding-sm,8px);@media (forced-colors:active){border-bottom-color:CanvasText;border-bottom-style:solid;border-bottom-width:1px;border-left-color:CanvasText;border-left-style:solid;border-left-width:1px;border-right-color:CanvasText;border-right-style:solid;border-right-width:1px;border-top-color:CanvasText;border-top-style:solid;border-top-width:1px}}}}');
}
var style_default4 = { "positioner": "_480b748dd3510e64__positioner", "popup": "_50096b232db7709d__popup" };
var POPUP_COLOR = { background: "#1e1e1e" };
var Popup = (0, import_element16.forwardRef)(function TooltipPopup3({ portal, positioner, children, className, ...props }, ref) {
  const popupContent = /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(ThemeProvider, { color: POPUP_COLOR, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
    index_parts_exports.Popup,
    {
      ref,
      className: clsx_default(style_default4.popup, className),
      ...props,
      children
    }
  ) });
  const positionedPopup = renderSlotWithChildren(
    positioner,
    /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Positioner, {}),
    popupContent
  );
  return renderSlotWithChildren(portal, /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Portal, {}), positionedPopup);
});

// packages/ui/build-module/tooltip/trigger.mjs
var import_element17 = __toESM(require_element(), 1);
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);
var Trigger = (0, import_element17.forwardRef)(
  function TooltipTrigger3(props, ref) {
    return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(index_parts_exports.Trigger, { ref, ...props });
  }
);

// packages/ui/build-module/tooltip/root.mjs
var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
function Root(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(index_parts_exports.Root, { ...props });
}

// packages/ui/build-module/tooltip/provider.mjs
var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);
function Provider({ ...props }) {
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(index_parts_exports.Provider, { ...props });
}

// packages/ui/build-module/skeleton/skeleton.mjs
var import_element18 = __toESM(require_element(), 1);
var STYLE_HASH_ATTRIBUTE6 = "data-wp-hash";
function getRuntime6() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument6(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash6(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE6}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE6) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle6(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime6();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash6(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE6, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument6(targetDocument) {
  const runtime = getRuntime6();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle6(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle6(hash, css) {
  const runtime = getRuntime6();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle6(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle6("10f3806643", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer utilities{._336cd3e4e743482f__box-sizing{box-sizing:border-box;*,:after,:before{box-sizing:inherit}}}}");
}
var resets_default2 = { "box-sizing": "_336cd3e4e743482f__box-sizing" };
if (typeof process === "undefined" || true) {
  registerStyle6("ed2c39ec90", "@layer wp-ui{@layer utilities, components, compositions, overrides;@layer components{.b20cc1690085c2f0__skeleton{background-color:var(--wpds-color-background-surface-neutral-weak,#f4f4f4);display:block;@media (forced-colors:active){border:var(--wpds-border-width-xs,1px) solid CanvasText}}._9b143194fdb45f93__pulse{@media not (prefers-reduced-motion){animation:e2b9fe0690281bc8__skeleton-pulse 1.5s ease-in-out infinite}}@keyframes e2b9fe0690281bc8__skeleton-pulse{0%,to{opacity:1}50%{opacity:.4}}}}");
}
var style_default5 = { "skeleton": "b20cc1690085c2f0__skeleton", "pulse": "_9b143194fdb45f93__pulse", "skeleton-pulse": "e2b9fe0690281bc8__skeleton-pulse" };
var Skeleton = (0, import_element18.forwardRef)(
  function Skeleton2({ render, ...props }, ref) {
    return useRender({
      render,
      ref,
      props: mergeProps(
        {
          className: clsx_default(
            style_default5.skeleton,
            style_default5.pulse,
            resets_default2["box-sizing"]
          ),
          // Decorative by default; consumers mark the loading
          // region with aria-busy / role="status".
          "aria-hidden": true
        },
        props
      )
    });
  }
);

// packages/admin-ui/build-module/navigable-region/index.mjs
var import_element19 = __toESM(require_element(), 1);
var import_jsx_runtime22 = __toESM(require_jsx_runtime(), 1);
var NavigableRegion = (0, import_element19.forwardRef)(
  ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
    return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
      Tag,
      {
        ref,
        className: clsx_default("admin-ui-navigable-region", className),
        "aria-label": ariaLabel,
        role: "region",
        tabIndex: "-1",
        ...props,
        children
      }
    );
  }
);
NavigableRegion.displayName = "NavigableRegion";
var navigable_region_default = NavigableRegion;

// packages/admin-ui/build-module/page/sidebar-toggle-slot.mjs
var import_components = __toESM(require_components(), 1);
var { Fill: SidebarToggleFill, Slot: SidebarToggleSlot } = (0, import_components.createSlotFill)("SidebarToggle");

// packages/admin-ui/build-module/page/header.mjs
var import_jsx_runtime23 = __toESM(require_jsx_runtime(), 1);
var STYLE_HASH_ATTRIBUTE7 = "data-wp-hash";
function getRuntime7() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument7(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash7(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE7}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE7) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle7(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime7();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash7(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE7, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument7(targetDocument) {
  const runtime = getRuntime7();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle7(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle7(hash, css) {
  const runtime = getRuntime7();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle7(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle7("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
}
var style_default6 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
function Header({
  headingLevel = 1,
  breadcrumbs,
  badges,
  visual,
  title,
  subTitle,
  actions,
  showSidebarToggle = true
}) {
  const HeadingTag = `h${headingLevel}`;
  return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Stack, { direction: "column", className: style_default6.header, children: [
    /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
      Stack,
      {
        className: style_default6["header-content"],
        direction: "row",
        gap: "sm",
        justify: "space-between",
        children: [
          /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(Stack, { direction: "row", gap: "sm", align: "center", justify: "start", children: [
            showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
              SidebarToggleSlot,
              {
                bubblesVirtually: true,
                className: style_default6["sidebar-toggle-slot"]
              }
            ),
            visual && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
              "div",
              {
                className: style_default6["header-visual"],
                "aria-hidden": "true",
                children: visual
              }
            ),
            title && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
              Text,
              {
                className: style_default6["header-title"],
                render: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(HeadingTag, {}),
                variant: "heading-lg",
                children: title
              }
            ),
            breadcrumbs,
            badges
          ] }),
          actions && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
            Stack,
            {
              align: "center",
              className: style_default6["header-actions"],
              direction: "row",
              gap: "sm",
              children: actions
            }
          )
        ]
      }
    ),
    subTitle && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
      Text,
      {
        render: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)("p", {}),
        variant: "body-md",
        className: style_default6["header-subtitle"],
        children: subTitle
      }
    )
  ] });
}

// packages/admin-ui/build-module/page/index.mjs
var import_jsx_runtime24 = __toESM(require_jsx_runtime(), 1);
var STYLE_HASH_ATTRIBUTE8 = "data-wp-hash";
function getRuntime8() {
  const globalScope = globalThis;
  if (globalScope.__wpStyleRuntime) {
    return globalScope.__wpStyleRuntime;
  }
  globalScope.__wpStyleRuntime = {
    documents: /* @__PURE__ */ new Map(),
    styles: /* @__PURE__ */ new Map(),
    injectedStyles: /* @__PURE__ */ new WeakMap()
  };
  if (typeof document !== "undefined") {
    registerDocument8(document);
  }
  return globalScope.__wpStyleRuntime;
}
function documentContainsStyleHash8(targetDocument, hash) {
  if (!targetDocument.head) {
    return false;
  }
  for (const style of targetDocument.head.querySelectorAll(
    `style[${STYLE_HASH_ATTRIBUTE8}]`
  )) {
    if (style.getAttribute(STYLE_HASH_ATTRIBUTE8) === hash) {
      return true;
    }
  }
  return false;
}
function injectStyle8(targetDocument, hash, css) {
  if (!targetDocument.head) {
    return;
  }
  const runtime = getRuntime8();
  let injectedStyles = runtime.injectedStyles.get(targetDocument);
  if (!injectedStyles) {
    injectedStyles = /* @__PURE__ */ new Set();
    runtime.injectedStyles.set(targetDocument, injectedStyles);
  }
  if (injectedStyles.has(hash)) {
    return;
  }
  if (documentContainsStyleHash8(targetDocument, hash)) {
    injectedStyles.add(hash);
    return;
  }
  const style = targetDocument.createElement("style");
  style.setAttribute(STYLE_HASH_ATTRIBUTE8, hash);
  style.appendChild(targetDocument.createTextNode(css));
  targetDocument.head.appendChild(style);
  injectedStyles.add(hash);
}
function registerDocument8(targetDocument) {
  const runtime = getRuntime8();
  runtime.documents.set(
    targetDocument,
    (runtime.documents.get(targetDocument) ?? 0) + 1
  );
  for (const [hash, css] of runtime.styles) {
    injectStyle8(targetDocument, hash, css);
  }
  return () => {
    const count = runtime.documents.get(targetDocument);
    if (count === void 0) {
      return;
    }
    if (count <= 1) {
      runtime.documents.delete(targetDocument);
      return;
    }
    runtime.documents.set(targetDocument, count - 1);
  };
}
function registerStyle8(hash, css) {
  const runtime = getRuntime8();
  runtime.styles.set(hash, css);
  for (const targetDocument of runtime.documents.keys()) {
    injectStyle8(targetDocument, hash, css);
  }
}
if (typeof process === "undefined" || true) {
  registerStyle8("ddd9aab364", "._956b6df0898efed0__page{text-wrap:pretty;background-color:var(--wpds-color-background-surface-neutral,#fcfcfc);color:var(--wpds-color-foreground-content-neutral,#1e1e1e);display:flex;flex-flow:column;height:100%;position:relative;z-index:1}._0625b55e82a0d93d__header{background:var(--wpds-color-background-surface-neutral-strong,#fff);border-block-end:var(--wpds-border-width-xs,1px) solid var(--wpds-color-stroke-surface-neutral-weak,#f0f0f0);inset-block-start:0;padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px);position:sticky;z-index:1}.a43c44d5ae28b2e8__header-content{min-height:var(--wpds-dimension-size-md,32px)}.b7cb5b9daf3a3b25__header-actions{flex-shrink:0}._8113be94e7caf73c__header-title{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}._9a776c7f70996f61__header-visual{display:grid;flex-shrink:0;grid-template-columns:1fr;grid-template-rows:1fr;height:var(--wpds-dimension-size-sm,24px);width:var(--wpds-dimension-size-sm,24px);>*{grid-column:1/-1;grid-row:1/-1;max-height:100%;max-width:100%}}.d5e0920cd15d35bc__sidebar-toggle-slot:empty{display:none}._60fea2f6bf5319cd__header-subtitle{color:var(--wpds-color-foreground-content-neutral-weak,#707070);padding-block-end:var(--wpds-dimension-padding-xs,4px)}.be5e57d029ec4036__content{display:flex;flex-direction:column;flex-grow:1;overflow:auto;&._128806d0b26e3a50__has-padding{padding:var(--wpds-dimension-padding-lg,16px) var(--wpds-dimension-padding-2xl,24px)}}");
}
var style_default7 = { "page": "_956b6df0898efed0__page", "header": "_0625b55e82a0d93d__header", "header-content": "a43c44d5ae28b2e8__header-content", "header-actions": "b7cb5b9daf3a3b25__header-actions", "header-title": "_8113be94e7caf73c__header-title", "header-visual": "_9a776c7f70996f61__header-visual", "sidebar-toggle-slot": "d5e0920cd15d35bc__sidebar-toggle-slot", "header-subtitle": "_60fea2f6bf5319cd__header-subtitle", "content": "be5e57d029ec4036__content", "has-padding": "_128806d0b26e3a50__has-padding" };
function Page({
  headingLevel,
  breadcrumbs,
  badges,
  visual,
  title,
  subTitle,
  children,
  className,
  actions,
  ariaLabel,
  hasPadding = false,
  showSidebarToggle = true
}) {
  const classes = clsx_default(style_default7.page, className);
  const effectiveAriaLabel = ariaLabel ?? (typeof title === "string" ? title : "");
  return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(navigable_region_default, { className: classes, ariaLabel: effectiveAriaLabel, children: [
    (title || breadcrumbs || badges || actions || visual) && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
      Header,
      {
        headingLevel,
        breadcrumbs,
        badges,
        visual,
        title,
        subTitle,
        actions,
        showSidebarToggle
      }
    ),
    hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
      "div",
      {
        className: clsx_default(
          style_default7.content,
          style_default7["has-padding"]
        ),
        children
      }
    ) : children
  ] });
}
Page.SidebarToggleFill = SidebarToggleFill;
var page_default = Page;

// routes/font-list/stage.tsx
var import_i18n47 = __toESM(require_i18n());
var import_components60 = __toESM(require_components());
var import_editor = __toESM(require_editor());
var import_core_data12 = __toESM(require_core_data());
var import_data13 = __toESM(require_data());
var import_element52 = __toESM(require_element());

// packages/global-styles-ui/build-module/global-styles-ui.mjs
var import_components59 = __toESM(require_components(), 1);
var import_blocks5 = __toESM(require_blocks(), 1);
var import_data12 = __toESM(require_data(), 1);
var import_block_editor14 = __toESM(require_block_editor(), 1);
var import_element51 = __toESM(require_element(), 1);
var import_compose6 = __toESM(require_compose(), 1);

// packages/global-styles-engine/build-module/utils/object.mjs
function setImmutably(object, path, value) {
  path = Array.isArray(path) ? [...path] : [path];
  object = Array.isArray(object) ? [...object] : { ...object };
  const leaf = path.pop();
  let prev = object;
  for (const key of path) {
    const lvl = prev[key];
    prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
  }
  prev[leaf] = value;
  return object;
}
var getValueFromObjectPath = (object, path, defaultValue) => {
  const arrayPath = Array.isArray(path) ? path : path.split(".");
  let value = object;
  arrayPath.forEach((fieldName) => {
    value = value?.[fieldName];
  });
  return value ?? defaultValue;
};

// packages/global-styles-engine/build-module/settings/get-setting.mjs
var VALID_SETTINGS = [
  "appearanceTools",
  "useRootPaddingAwareAlignments",
  "background.backgroundImage",
  "background.backgroundRepeat",
  "background.backgroundSize",
  "background.backgroundPosition",
  "background.gradient",
  "border.color",
  "border.radius",
  "border.radiusSizes",
  "border.style",
  "border.width",
  "shadow.presets",
  "shadow.defaultPresets",
  "color.background",
  "color.button",
  "color.caption",
  "color.custom",
  "color.customDuotone",
  "color.customGradient",
  "color.defaultDuotone",
  "color.defaultGradients",
  "color.defaultPalette",
  "color.duotone",
  "color.gradients",
  "color.heading",
  "color.link",
  "color.palette",
  "color.text",
  "custom",
  "dimensions.aspectRatio",
  "dimensions.height",
  "dimensions.minHeight",
  "dimensions.minWidth",
  "dimensions.width",
  "dimensions.dimensionSizes",
  "layout.contentSize",
  "layout.definitions",
  "layout.wideSize",
  "lightbox.enabled",
  "lightbox.allowEditing",
  "position.fixed",
  "position.sticky",
  "spacing.customSpacingSize",
  "spacing.defaultSpacingSizes",
  "spacing.spacingSizes",
  "spacing.spacingScale",
  "spacing.blockGap",
  "spacing.margin",
  "spacing.padding",
  "spacing.units",
  "typography.fluid",
  "typography.customFontSize",
  "typography.defaultFontSizes",
  "typography.dropCap",
  "typography.fontFamilies",
  "typography.fontSizes",
  "typography.fontStyle",
  "typography.fontWeight",
  "typography.letterSpacing",
  "typography.lineHeight",
  "typography.textAlign",
  "typography.textColumns",
  "typography.textDecoration",
  "typography.textIndent",
  "typography.textTransform",
  "typography.writingMode",
  "viewport.mobile",
  "viewport.tablet"
];
function getSetting(globalStyles, path, blockName) {
  const appendedBlockPath = blockName ? ".blocks." + blockName : "";
  const appendedPropertyPath = path ? "." + path : "";
  const contextualPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
  const globalPath = `settings${appendedPropertyPath}`;
  if (path) {
    return getValueFromObjectPath(globalStyles, contextualPath) ?? getValueFromObjectPath(globalStyles, globalPath);
  }
  let result = {};
  VALID_SETTINGS.forEach((setting) => {
    const value = getValueFromObjectPath(
      globalStyles,
      `settings${appendedBlockPath}.${setting}`
    ) ?? getValueFromObjectPath(globalStyles, `settings.${setting}`);
    if (value !== void 0) {
      result = setImmutably(result, setting.split("."), value);
    }
  });
  return result;
}

// packages/global-styles-engine/build-module/settings/set-setting.mjs
function setSetting(globalStyles, path, newValue, blockName) {
  const appendedBlockPath = blockName ? ".blocks." + blockName : "";
  const appendedPropertyPath = path ? "." + path : "";
  const finalPath = `settings${appendedBlockPath}${appendedPropertyPath}`;
  return setImmutably(
    globalStyles,
    finalPath.split("."),
    newValue
  );
}

// packages/global-styles-engine/build-module/utils/common.mjs
var import_style_engine = __toESM(require_style_engine(), 1);

// packages/global-styles-engine/build-module/utils/fluid.mjs
var DEFAULT_MAXIMUM_VIEWPORT_WIDTH = "1600px";
var DEFAULT_MINIMUM_VIEWPORT_WIDTH = "320px";
var DEFAULT_SCALE_FACTOR = 1;
var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN = 0.25;
var DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX = 0.75;
var DEFAULT_MINIMUM_FONT_SIZE_LIMIT = "14px";
function getComputedFluidTypographyValue({
  minimumFontSize,
  maximumFontSize,
  fontSize,
  minimumViewportWidth = DEFAULT_MINIMUM_VIEWPORT_WIDTH,
  maximumViewportWidth = DEFAULT_MAXIMUM_VIEWPORT_WIDTH,
  scaleFactor = DEFAULT_SCALE_FACTOR,
  minimumFontSizeLimit
}) {
  minimumFontSizeLimit = !!getTypographyValueAndUnit(minimumFontSizeLimit) ? minimumFontSizeLimit : DEFAULT_MINIMUM_FONT_SIZE_LIMIT;
  if (fontSize) {
    const fontSizeParsed = getTypographyValueAndUnit(fontSize);
    if (!fontSizeParsed?.unit || !fontSizeParsed?.value) {
      return null;
    }
    const minimumFontSizeLimitParsed = getTypographyValueAndUnit(
      minimumFontSizeLimit,
      {
        coerceTo: fontSizeParsed.unit
      }
    );
    if (!!minimumFontSizeLimitParsed?.value && !minimumFontSize && !maximumFontSize) {
      if (fontSizeParsed?.value <= minimumFontSizeLimitParsed?.value) {
        return null;
      }
    }
    if (!maximumFontSize) {
      maximumFontSize = `${fontSizeParsed.value}${fontSizeParsed.unit}`;
    }
    if (!minimumFontSize) {
      const fontSizeValueInPx = fontSizeParsed.unit === "px" ? fontSizeParsed.value : fontSizeParsed.value * 16;
      const minimumFontSizeFactor = Math.min(
        Math.max(
          1 - 0.075 * Math.log2(fontSizeValueInPx),
          DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MIN
        ),
        DEFAULT_MINIMUM_FONT_SIZE_FACTOR_MAX
      );
      const calculatedMinimumFontSize = roundToPrecision(
        fontSizeParsed.value * minimumFontSizeFactor,
        3
      );
      if (!!minimumFontSizeLimitParsed?.value && calculatedMinimumFontSize < minimumFontSizeLimitParsed?.value) {
        minimumFontSize = `${minimumFontSizeLimitParsed.value}${minimumFontSizeLimitParsed.unit}`;
      } else {
        minimumFontSize = `${calculatedMinimumFontSize}${fontSizeParsed.unit}`;
      }
    }
  }
  const minimumFontSizeParsed = getTypographyValueAndUnit(minimumFontSize);
  const fontSizeUnit = minimumFontSizeParsed?.unit || "rem";
  const maximumFontSizeParsed = getTypographyValueAndUnit(maximumFontSize, {
    coerceTo: fontSizeUnit
  });
  if (!minimumFontSizeParsed || !maximumFontSizeParsed) {
    return null;
  }
  const minimumFontSizeRem = getTypographyValueAndUnit(minimumFontSize, {
    coerceTo: "rem"
  });
  const maximumViewportWidthParsed = getTypographyValueAndUnit(
    maximumViewportWidth,
    { coerceTo: fontSizeUnit }
  );
  const minimumViewportWidthParsed = getTypographyValueAndUnit(
    minimumViewportWidth,
    { coerceTo: fontSizeUnit }
  );
  if (!maximumViewportWidthParsed || !minimumViewportWidthParsed || !minimumFontSizeRem) {
    return null;
  }
  const linearDenominator = maximumViewportWidthParsed.value - minimumViewportWidthParsed.value;
  if (!linearDenominator) {
    return null;
  }
  const minViewportWidthOffsetValue = roundToPrecision(
    minimumViewportWidthParsed.value / 100,
    3
  );
  const viewportWidthOffset = roundToPrecision(minViewportWidthOffsetValue, 3) + fontSizeUnit;
  const linearFactor = 100 * ((maximumFontSizeParsed.value - minimumFontSizeParsed.value) / linearDenominator);
  const linearFactorScaled = roundToPrecision(
    (linearFactor || 1) * scaleFactor,
    3
  );
  const fluidTargetFontSize = `${minimumFontSizeRem.value}${minimumFontSizeRem.unit} + ((1vw - ${viewportWidthOffset}) * ${linearFactorScaled})`;
  return `clamp(${minimumFontSize}, ${fluidTargetFontSize}, ${maximumFontSize})`;
}
function getTypographyValueAndUnit(rawValue, options = {}) {
  if (typeof rawValue !== "string" && typeof rawValue !== "number") {
    return null;
  }
  if (isFinite(rawValue)) {
    rawValue = `${rawValue}px`;
  }
  const { coerceTo, rootSizeValue, acceptableUnits } = {
    coerceTo: "",
    // Default browser font size. Later we could inject some JS to compute this `getComputedStyle( document.querySelector( "html" ) ).fontSize`.
    rootSizeValue: 16,
    acceptableUnits: ["rem", "px", "em"],
    ...options
  };
  const acceptableUnitsGroup = acceptableUnits?.join("|");
  const regexUnits = new RegExp(
    `^(\\d*\\.?\\d+)(${acceptableUnitsGroup}){1,1}$`
  );
  const matches = rawValue.toString().match(regexUnits);
  if (!matches || matches.length < 3) {
    return null;
  }
  let [, value, unit] = matches;
  let returnValue = parseFloat(value);
  if ("px" === coerceTo && ("em" === unit || "rem" === unit)) {
    returnValue = returnValue * rootSizeValue;
    unit = coerceTo;
  }
  if ("px" === unit && ("em" === coerceTo || "rem" === coerceTo)) {
    returnValue = returnValue / rootSizeValue;
    unit = coerceTo;
  }
  if (("em" === coerceTo || "rem" === coerceTo) && ("em" === unit || "rem" === unit)) {
    unit = coerceTo;
  }
  if (!unit) {
    return null;
  }
  return {
    value: roundToPrecision(returnValue, 3),
    unit
  };
}
function roundToPrecision(value, digits = 3) {
  const base = Math.pow(10, digits);
  return Math.round(value * base) / base;
}

// packages/global-styles-engine/build-module/utils/typography.mjs
function isFluidTypographyEnabled(typographySettings) {
  const fluidSettings = typographySettings?.fluid;
  return true === fluidSettings || fluidSettings && typeof fluidSettings === "object" && Object.keys(fluidSettings).length > 0;
}
function getFluidTypographyOptionsFromSettings(settings) {
  const typographySettings = settings?.typography ?? {};
  const layoutSettings = settings?.layout;
  const defaultMaxViewportWidth = getTypographyValueAndUnit(
    layoutSettings?.wideSize
  ) ? layoutSettings?.wideSize : null;
  return isFluidTypographyEnabled(typographySettings) && defaultMaxViewportWidth ? {
    fluid: {
      maxViewportWidth: defaultMaxViewportWidth,
      ...typeof typographySettings.fluid === "object" ? typographySettings.fluid : {}
    }
  } : {
    fluid: typographySettings?.fluid
  };
}
function getTypographyFontSizeValue(preset, settings) {
  const { size: defaultSize } = preset;
  if (!defaultSize || "0" === defaultSize || false === preset?.fluid) {
    return defaultSize;
  }
  if (!isFluidTypographyEnabled(settings?.typography) && !isFluidTypographyEnabled(preset)) {
    return defaultSize;
  }
  const fluidTypographySettings = getFluidTypographyOptionsFromSettings(settings)?.fluid ?? {};
  const fluidFontSizeValue = getComputedFluidTypographyValue({
    minimumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.min,
    maximumFontSize: typeof preset?.fluid === "boolean" ? void 0 : preset?.fluid?.max,
    fontSize: defaultSize,
    minimumFontSizeLimit: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minFontSize : void 0,
    maximumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.maxViewportWidth : void 0,
    minimumViewportWidth: typeof fluidTypographySettings === "object" ? fluidTypographySettings?.minViewportWidth : void 0
  });
  if (!!fluidFontSizeValue) {
    return fluidFontSizeValue;
  }
  return defaultSize;
}

// packages/global-styles-engine/build-module/utils/common.mjs
var PRESET_METADATA = [
  {
    path: ["color", "palette"],
    valueKey: "color",
    cssVarInfix: "color",
    classes: [
      { classSuffix: "color", propertyName: "color" },
      {
        classSuffix: "background-color",
        propertyName: "background-color"
      },
      {
        classSuffix: "border-color",
        propertyName: "border-color"
      }
    ]
  },
  {
    path: ["color", "gradients"],
    valueKey: "gradient",
    cssVarInfix: "gradient",
    classes: [
      {
        classSuffix: "gradient-background",
        propertyName: "background"
      }
    ]
  },
  {
    path: ["color", "duotone"],
    valueKey: "colors",
    cssVarInfix: "duotone",
    valueFunc: ({ slug }) => `url( '#wp-duotone-${slug}' )`,
    classes: []
  },
  {
    path: ["shadow", "presets"],
    valueKey: "shadow",
    cssVarInfix: "shadow",
    classes: []
  },
  {
    path: ["typography", "fontSizes"],
    valueFunc: (preset, settings) => getTypographyFontSizeValue(preset, settings),
    valueKey: "size",
    cssVarInfix: "font-size",
    classes: [{ classSuffix: "font-size", propertyName: "font-size" }]
  },
  {
    path: ["typography", "fontFamilies"],
    valueKey: "fontFamily",
    cssVarInfix: "font-family",
    classes: [
      { classSuffix: "font-family", propertyName: "font-family" }
    ]
  },
  {
    path: ["spacing", "spacingSizes"],
    valueKey: "size",
    cssVarInfix: "spacing",
    valueFunc: ({ size: size4 }) => size4,
    classes: []
  },
  {
    path: ["border", "radiusSizes"],
    valueKey: "size",
    cssVarInfix: "border-radius",
    classes: []
  },
  {
    path: ["dimensions", "dimensionSizes"],
    valueKey: "size",
    cssVarInfix: "dimension",
    classes: []
  }
];
function getResolvedRefValue(ruleValue, tree) {
  if (!ruleValue || !tree) {
    return ruleValue;
  }
  if (typeof ruleValue === "object" && "ref" in ruleValue && ruleValue?.ref) {
    const resolvedRuleValue = (0, import_style_engine.getCSSValueFromRawStyle)(
      getValueFromObjectPath(tree, ruleValue.ref)
    );
    if (typeof resolvedRuleValue === "object" && resolvedRuleValue !== null && "ref" in resolvedRuleValue && resolvedRuleValue?.ref) {
      return void 0;
    }
    if (resolvedRuleValue === void 0) {
      return ruleValue;
    }
    return resolvedRuleValue;
  }
  return ruleValue;
}
function getResolvedThemeFilePath(file, themeFileURIs) {
  if (!file || !themeFileURIs || !Array.isArray(themeFileURIs)) {
    return file;
  }
  const uri = themeFileURIs.find(
    (themeFileUri) => themeFileUri?.name === file
  );
  if (!uri?.href) {
    return file;
  }
  return uri?.href;
}
function getResolvedValue(ruleValue, tree) {
  if (!ruleValue || !tree) {
    return ruleValue;
  }
  const resolvedValue = getResolvedRefValue(ruleValue, tree);
  if (typeof resolvedValue === "object" && resolvedValue !== null && "url" in resolvedValue && resolvedValue?.url) {
    resolvedValue.url = getResolvedThemeFilePath(
      resolvedValue.url,
      tree?._links?.["wp:theme-file"]
    );
  }
  return resolvedValue;
}
function findInPresetsBy(settings, blockName, presetPath = [], presetProperty = "slug", presetValueValue) {
  const orderedPresetsByOrigin = [
    blockName ? getValueFromObjectPath(settings, [
      "blocks",
      blockName,
      ...presetPath
    ]) : void 0,
    getValueFromObjectPath(settings, presetPath)
  ].filter(Boolean);
  for (const presetByOrigin of orderedPresetsByOrigin) {
    if (presetByOrigin) {
      const origins = ["custom", "theme", "default"];
      for (const origin of origins) {
        const presets = presetByOrigin[origin];
        if (presets) {
          const presetObject = presets.find(
            (preset) => preset[presetProperty] === presetValueValue
          );
          if (presetObject) {
            if (presetProperty === "slug") {
              return presetObject;
            }
            const highestPresetObjectWithSameSlug = findInPresetsBy(
              settings,
              blockName,
              presetPath,
              "slug",
              presetObject.slug
            );
            if (highestPresetObjectWithSameSlug[presetProperty] === presetObject[presetProperty]) {
              return presetObject;
            }
            return void 0;
          }
        }
      }
    }
  }
}
function getValueFromPresetVariable(features, blockName, variable, [presetType, slug] = []) {
  const metadata = PRESET_METADATA.find(
    (data) => data.cssVarInfix === presetType
  );
  if (!metadata || !features.settings) {
    return variable;
  }
  const presetObject = findInPresetsBy(
    features.settings,
    blockName,
    metadata.path,
    "slug",
    slug
  );
  if (presetObject) {
    const { valueKey } = metadata;
    const result = presetObject[valueKey];
    return getValueFromVariable(features, blockName, result);
  }
  return variable;
}
function getValueFromCustomVariable(features, blockName, variable, path = []) {
  const result = (blockName ? getValueFromObjectPath(features?.settings ?? {}, [
    "blocks",
    blockName,
    "custom",
    ...path
  ]) : void 0) ?? getValueFromObjectPath(features?.settings ?? {}, [
    "custom",
    ...path
  ]);
  if (!result) {
    return variable;
  }
  return getValueFromVariable(features, blockName, result);
}
function getValueFromVariable(features, blockName, variable) {
  if (!variable || typeof variable !== "string") {
    if (typeof variable === "object" && variable !== null && "ref" in variable && typeof variable.ref === "string") {
      const resolvedVariable = getValueFromObjectPath(
        features,
        variable.ref
      );
      if (!resolvedVariable || typeof resolvedVariable === "object" && "ref" in resolvedVariable) {
        return resolvedVariable;
      }
      variable = resolvedVariable;
    } else {
      return variable;
    }
  }
  const USER_VALUE_PREFIX = "var:";
  const THEME_VALUE_PREFIX = "var(--wp--";
  const THEME_VALUE_SUFFIX = ")";
  let parsedVar;
  if (variable.startsWith(USER_VALUE_PREFIX)) {
    parsedVar = variable.slice(USER_VALUE_PREFIX.length).split("|");
  } else if (variable.startsWith(THEME_VALUE_PREFIX) && variable.endsWith(THEME_VALUE_SUFFIX)) {
    parsedVar = variable.slice(THEME_VALUE_PREFIX.length, -THEME_VALUE_SUFFIX.length).split("--");
  } else {
    return variable;
  }
  const [type, ...path] = parsedVar;
  if (type === "preset") {
    return getValueFromPresetVariable(
      features,
      blockName,
      variable,
      path
    );
  }
  if (type === "custom") {
    return getValueFromCustomVariable(
      features,
      blockName,
      variable,
      path
    );
  }
  return variable;
}

// packages/global-styles-engine/build-module/style-state-back-compat.mjs
var LEGACY_STYLE_STATE_ALIASES = {
  "@mobile": "mobile",
  "@tablet": "tablet",
  "-current": "@current"
};
function isObjectRecord(value) {
  return !!value && typeof value === "object" && !Array.isArray(value);
}
function normalizeStyleStateNode(node) {
  if (!isObjectRecord(node)) {
    return node;
  }
  let normalized = node;
  Object.entries(LEGACY_STYLE_STATE_ALIASES).forEach(
    ([state, legacyState]) => {
      if (Object.hasOwn(node, legacyState)) {
        if (normalized === node) {
          normalized = { ...node };
        }
        if (!Object.hasOwn(node, state)) {
          normalized[state] = node[legacyState];
        }
        delete normalized[legacyState];
      }
    }
  );
  Object.entries(normalized).forEach(([key, value]) => {
    if (!isObjectRecord(value)) {
      return;
    }
    const normalizedValue = normalizeStyleStateNode(value);
    if (normalizedValue !== value) {
      if (normalized === node) {
        normalized = { ...node };
      }
      normalized[key] = normalizedValue;
    }
  });
  return normalized;
}
function normalizeStyleStateAliases(globalStyles) {
  if (true) {
    return globalStyles;
  }
  if (!globalStyles?.styles) {
    return globalStyles;
  }
  const styles = normalizeStyleStateNode(globalStyles.styles);
  return styles === globalStyles.styles ? globalStyles : { ...globalStyles, styles };
}
function getLegacyStyleStatePath(path) {
  if (true) {
    return void 0;
  }
  const pathParts = path.split(".");
  const legacyPathParts = pathParts.map(
    (part) => LEGACY_STYLE_STATE_ALIASES[part] ?? part
  );
  return legacyPathParts.some(
    (part, index2) => part !== pathParts[index2]
  ) ? legacyPathParts.join(".") : void 0;
}

// packages/global-styles-engine/build-module/settings/get-style.mjs
function getStyle(globalStyles, path, blockName, shouldDecodeEncode = true) {
  const appendedPath = path ? "." + path : "";
  const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
  if (!globalStyles) {
    return void 0;
  }
  let rawResult = getValueFromObjectPath(globalStyles, finalPath);
  const legacyPath = getLegacyStyleStatePath(finalPath);
  if (rawResult === void 0 && legacyPath) {
    let hasCanonicalPath = true;
    let currentValue = globalStyles;
    for (const pathPart of finalPath.split(".")) {
      if (!currentValue || typeof currentValue !== "object" || !Object.hasOwn(currentValue, pathPart)) {
        hasCanonicalPath = false;
        break;
      }
      currentValue = currentValue[pathPart];
    }
    if (!hasCanonicalPath) {
      rawResult = getValueFromObjectPath(globalStyles, legacyPath);
    }
  }
  const result = shouldDecodeEncode ? getValueFromVariable(globalStyles, blockName, rawResult) : rawResult;
  return result;
}

// packages/global-styles-engine/build-module/settings/set-style.mjs
function setStyle(globalStyles, path, newValue, blockName) {
  const appendedPath = path ? "." + path : "";
  const finalPath = !blockName ? `styles${appendedPath}` : `styles.blocks.${blockName}${appendedPath}`;
  return setImmutably(
    normalizeStyleStateAliases(globalStyles),
    finalPath.split("."),
    newValue
  );
}

// packages/global-styles-engine/build-module/core/equal.mjs
var import_es6 = __toESM(require_es6(), 1);
function areGlobalStylesEqual(original, variation) {
  if (typeof original !== "object" || typeof variation !== "object") {
    return original === variation;
  }
  return (0, import_es6.default)(original?.styles, variation?.styles) && (0, import_es6.default)(original?.settings, variation?.settings);
}

// packages/global-styles-engine/build-module/core/merge.mjs
var import_deepmerge = __toESM(require_cjs(), 1);

// node_modules/is-plain-object/dist/is-plain-object.mjs
function isObject(o3) {
  return Object.prototype.toString.call(o3) === "[object Object]";
}
function isPlainObject(o3) {
  var ctor, prot;
  if (isObject(o3) === false) return false;
  ctor = o3.constructor;
  if (ctor === void 0) return true;
  prot = ctor.prototype;
  if (isObject(prot) === false) return false;
  if (prot.hasOwnProperty("isPrototypeOf") === false) {
    return false;
  }
  return true;
}

// packages/global-styles-engine/build-module/core/merge.mjs
function mergeGlobalStyles(base, user) {
  return (0, import_deepmerge.default)(
    normalizeStyleStateAliases(base),
    normalizeStyleStateAliases(user),
    {
      /*
       * We only pass as arrays the presets,
       * in which case we want the new array of values
       * to override the old array (no merging).
       */
      isMergeableObject: isPlainObject,
      /*
       * Exceptions to the above rule.
       * Background images should be replaced, not merged,
       * as they themselves are specific object definitions for the style.
       */
      customMerge: (key) => {
        if (key === "backgroundImage") {
          return (baseConfig, userConfig) => userConfig ?? baseConfig;
        }
        return void 0;
      }
    }
  );
}

// node_modules/colord/index.mjs
var r2 = { grad: 0.9, turn: 360, rad: 360 / (2 * Math.PI) };
var t = function(r3) {
  return "string" == typeof r3 ? r3.length > 0 : "number" == typeof r3;
};
var n = function(r3, t3, n2) {
  return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = Math.pow(10, t3)), Math.round(n2 * r3) / n2 + 0;
};
var e = function(r3, t3, n2) {
  return void 0 === t3 && (t3 = 0), void 0 === n2 && (n2 = 1), r3 > n2 ? n2 : r3 > t3 ? r3 : t3;
};
var u = function(r3) {
  return (r3 = isFinite(r3) ? r3 % 360 : 0) > 0 ? r3 : r3 + 360;
};
var a = function(r3) {
  return { r: e(r3.r, 0, 255), g: e(r3.g, 0, 255), b: e(r3.b, 0, 255), a: e(r3.a) };
};
var o = function(r3) {
  return { r: n(r3.r), g: n(r3.g), b: n(r3.b), a: n(r3.a, 3) };
};
var i = /^#([0-9a-f]{3,8})$/i;
var s = function(r3) {
  var t3 = r3.toString(16);
  return t3.length < 2 ? "0" + t3 : t3;
};
var h = function(r3) {
  var t3 = r3.r, n2 = r3.g, e2 = r3.b, u2 = r3.a, a2 = Math.max(t3, n2, e2), o3 = a2 - Math.min(t3, n2, e2), i2 = o3 ? a2 === t3 ? (n2 - e2) / o3 : a2 === n2 ? 2 + (e2 - t3) / o3 : 4 + (t3 - n2) / o3 : 0;
  return { h: 60 * (i2 < 0 ? i2 + 6 : i2), s: a2 ? o3 / a2 * 100 : 0, v: a2 / 255 * 100, a: u2 };
};
var b = function(r3) {
  var t3 = r3.h, n2 = r3.s, e2 = r3.v, u2 = r3.a;
  t3 = t3 / 360 * 6, n2 /= 100, e2 /= 100;
  var a2 = Math.floor(t3), o3 = e2 * (1 - n2), i2 = e2 * (1 - (t3 - a2) * n2), s2 = e2 * (1 - (1 - t3 + a2) * n2), h2 = a2 % 6;
  return { r: 255 * [e2, i2, o3, o3, s2, e2][h2], g: 255 * [s2, e2, e2, i2, o3, o3][h2], b: 255 * [o3, o3, s2, e2, e2, i2][h2], a: u2 };
};
var g = function(r3) {
  return { h: u(r3.h), s: e(r3.s, 0, 100), l: e(r3.l, 0, 100), a: e(r3.a) };
};
var d = function(r3) {
  return { h: n(r3.h), s: n(r3.s), l: n(r3.l), a: n(r3.a, 3) };
};
var f = function(r3) {
  return b((n2 = (t3 = r3).s, { h: t3.h, s: (n2 *= ((e2 = t3.l) < 50 ? e2 : 100 - e2) / 100) > 0 ? 2 * n2 / (e2 + n2) * 100 : 0, v: e2 + n2, a: t3.a }));
  var t3, n2, e2;
};
var c = function(r3) {
  return { h: (t3 = h(r3)).h, s: (u2 = (200 - (n2 = t3.s)) * (e2 = t3.v) / 100) > 0 && u2 < 200 ? n2 * e2 / 100 / (u2 <= 100 ? u2 : 200 - u2) * 100 : 0, l: u2 / 2, a: t3.a };
  var t3, n2, e2, u2;
};
var l = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
var p2 = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
var v = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
var m = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i;
var y = { string: [[function(r3) {
  var t3 = i.exec(r3);
  return t3 ? (r3 = t3[1]).length <= 4 ? { r: parseInt(r3[0] + r3[0], 16), g: parseInt(r3[1] + r3[1], 16), b: parseInt(r3[2] + r3[2], 16), a: 4 === r3.length ? n(parseInt(r3[3] + r3[3], 16) / 255, 2) : 1 } : 6 === r3.length || 8 === r3.length ? { r: parseInt(r3.substr(0, 2), 16), g: parseInt(r3.substr(2, 2), 16), b: parseInt(r3.substr(4, 2), 16), a: 8 === r3.length ? n(parseInt(r3.substr(6, 2), 16) / 255, 2) : 1 } : null : null;
}, "hex"], [function(r3) {
  var t3 = v.exec(r3) || m.exec(r3);
  return t3 ? t3[2] !== t3[4] || t3[4] !== t3[6] ? null : a({ r: Number(t3[1]) / (t3[2] ? 100 / 255 : 1), g: Number(t3[3]) / (t3[4] ? 100 / 255 : 1), b: Number(t3[5]) / (t3[6] ? 100 / 255 : 1), a: void 0 === t3[7] ? 1 : Number(t3[7]) / (t3[8] ? 100 : 1) }) : null;
}, "rgb"], [function(t3) {
  var n2 = l.exec(t3) || p2.exec(t3);
  if (!n2) return null;
  var e2, u2, a2 = g({ h: (e2 = n2[1], u2 = n2[2], void 0 === u2 && (u2 = "deg"), Number(e2) * (r2[u2] || 1)), s: Number(n2[3]), l: Number(n2[4]), a: void 0 === n2[5] ? 1 : Number(n2[5]) / (n2[6] ? 100 : 1) });
  return f(a2);
}, "hsl"]], object: [[function(r3) {
  var n2 = r3.r, e2 = r3.g, u2 = r3.b, o3 = r3.a, i2 = void 0 === o3 ? 1 : o3;
  return t(n2) && t(e2) && t(u2) ? a({ r: Number(n2), g: Number(e2), b: Number(u2), a: Number(i2) }) : null;
}, "rgb"], [function(r3) {
  var n2 = r3.h, e2 = r3.s, u2 = r3.l, a2 = r3.a, o3 = void 0 === a2 ? 1 : a2;
  if (!t(n2) || !t(e2) || !t(u2)) return null;
  var i2 = g({ h: Number(n2), s: Number(e2), l: Number(u2), a: Number(o3) });
  return f(i2);
}, "hsl"], [function(r3) {
  var n2 = r3.h, a2 = r3.s, o3 = r3.v, i2 = r3.a, s2 = void 0 === i2 ? 1 : i2;
  if (!t(n2) || !t(a2) || !t(o3)) return null;
  var h2 = (function(r4) {
    return { h: u(r4.h), s: e(r4.s, 0, 100), v: e(r4.v, 0, 100), a: e(r4.a) };
  })({ h: Number(n2), s: Number(a2), v: Number(o3), a: Number(s2) });
  return b(h2);
}, "hsv"]] };
var N = function(r3, t3) {
  for (var n2 = 0; n2 < t3.length; n2++) {
    var e2 = t3[n2][0](r3);
    if (e2) return [e2, t3[n2][1]];
  }
  return [null, void 0];
};
var x = function(r3) {
  return "string" == typeof r3 ? N(r3.trim(), y.string) : "object" == typeof r3 && null !== r3 ? N(r3, y.object) : [null, void 0];
};
var M = function(r3, t3) {
  var n2 = c(r3);
  return { h: n2.h, s: e(n2.s + 100 * t3, 0, 100), l: n2.l, a: n2.a };
};
var H = function(r3) {
  return (299 * r3.r + 587 * r3.g + 114 * r3.b) / 1e3 / 255;
};
var $ = function(r3, t3) {
  var n2 = c(r3);
  return { h: n2.h, s: n2.s, l: e(n2.l + 100 * t3, 0, 100), a: n2.a };
};
var j = (function() {
  function r3(r4) {
    this.parsed = x(r4)[0], this.rgba = this.parsed || { r: 0, g: 0, b: 0, a: 1 };
  }
  return r3.prototype.isValid = function() {
    return null !== this.parsed;
  }, r3.prototype.brightness = function() {
    return n(H(this.rgba), 2);
  }, r3.prototype.isDark = function() {
    return H(this.rgba) < 0.5;
  }, r3.prototype.isLight = function() {
    return H(this.rgba) >= 0.5;
  }, r3.prototype.toHex = function() {
    return r4 = o(this.rgba), t3 = r4.r, e2 = r4.g, u2 = r4.b, i2 = (a2 = r4.a) < 1 ? s(n(255 * a2)) : "", "#" + s(t3) + s(e2) + s(u2) + i2;
    var r4, t3, e2, u2, a2, i2;
  }, r3.prototype.toRgb = function() {
    return o(this.rgba);
  }, r3.prototype.toRgbString = function() {
    return r4 = o(this.rgba), t3 = r4.r, n2 = r4.g, e2 = r4.b, (u2 = r4.a) < 1 ? "rgba(" + t3 + ", " + n2 + ", " + e2 + ", " + u2 + ")" : "rgb(" + t3 + ", " + n2 + ", " + e2 + ")";
    var r4, t3, n2, e2, u2;
  }, r3.prototype.toHsl = function() {
    return d(c(this.rgba));
  }, r3.prototype.toHslString = function() {
    return r4 = d(c(this.rgba)), t3 = r4.h, n2 = r4.s, e2 = r4.l, (u2 = r4.a) < 1 ? "hsla(" + t3 + ", " + n2 + "%, " + e2 + "%, " + u2 + ")" : "hsl(" + t3 + ", " + n2 + "%, " + e2 + "%)";
    var r4, t3, n2, e2, u2;
  }, r3.prototype.toHsv = function() {
    return r4 = h(this.rgba), { h: n(r4.h), s: n(r4.s), v: n(r4.v), a: n(r4.a, 3) };
    var r4;
  }, r3.prototype.invert = function() {
    return w({ r: 255 - (r4 = this.rgba).r, g: 255 - r4.g, b: 255 - r4.b, a: r4.a });
    var r4;
  }, r3.prototype.saturate = function(r4) {
    return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, r4));
  }, r3.prototype.desaturate = function(r4) {
    return void 0 === r4 && (r4 = 0.1), w(M(this.rgba, -r4));
  }, r3.prototype.grayscale = function() {
    return w(M(this.rgba, -1));
  }, r3.prototype.lighten = function(r4) {
    return void 0 === r4 && (r4 = 0.1), w($(this.rgba, r4));
  }, r3.prototype.darken = function(r4) {
    return void 0 === r4 && (r4 = 0.1), w($(this.rgba, -r4));
  }, r3.prototype.rotate = function(r4) {
    return void 0 === r4 && (r4 = 15), this.hue(this.hue() + r4);
  }, r3.prototype.alpha = function(r4) {
    return "number" == typeof r4 ? w({ r: (t3 = this.rgba).r, g: t3.g, b: t3.b, a: r4 }) : n(this.rgba.a, 3);
    var t3;
  }, r3.prototype.hue = function(r4) {
    var t3 = c(this.rgba);
    return "number" == typeof r4 ? w({ h: r4, s: t3.s, l: t3.l, a: t3.a }) : n(t3.h);
  }, r3.prototype.isEqual = function(r4) {
    return this.toHex() === w(r4).toHex();
  }, r3;
})();
var w = function(r3) {
  return r3 instanceof j ? r3 : new j(r3);
};
var S = [];
var k = function(r3) {
  r3.forEach(function(r4) {
    S.indexOf(r4) < 0 && (r4(j, y), S.push(r4));
  });
};

// packages/global-styles-engine/build-module/utils/viewport.mjs
var DEFAULT_VIEWPORT_BREAKPOINTS = {
  mobile: "480px",
  tablet: "782px"
};
var VIEWPORT_SIZE_REGEXP = /^(\d+|\d*\.\d+)(px|em|rem)$/;
var DEFAULT_FONT_SIZE = 16;
function isViewportSettings(configOrSettings) {
  return "mobile" in configOrSettings || "tablet" in configOrSettings;
}
function getViewportSettings(configOrSettings) {
  if (!configOrSettings || typeof configOrSettings !== "object") {
    return {};
  }
  if (isViewportSettings(configOrSettings)) {
    return configOrSettings;
  }
  return configOrSettings.settings?.viewport ?? {};
}
function isValidViewportSize(value) {
  return typeof value === "string" && VIEWPORT_SIZE_REGEXP.test(value.trim());
}
function getViewportBreakpointValueInPixels(value) {
  if (typeof value === "number") {
    return value;
  }
  if (typeof value !== "string") {
    return void 0;
  }
  const match2 = value.trim().match(VIEWPORT_SIZE_REGEXP);
  if (!match2) {
    return void 0;
  }
  const numericValue = Number.parseFloat(match2[1]);
  const unit = match2[2];
  return unit === "px" ? numericValue : numericValue * DEFAULT_FONT_SIZE;
}
function getViewportBreakpoints(configOrSettings) {
  const viewportSettings = getViewportSettings(configOrSettings);
  const breakpoints = {};
  const breakpointValuesInPixels = {};
  Object.keys(DEFAULT_VIEWPORT_BREAKPOINTS).forEach((breakpoint) => {
    const key = breakpoint;
    const value = viewportSettings[key];
    const px = getViewportBreakpointValueInPixels(value);
    if (px !== void 0 && isValidViewportSize(value)) {
      breakpoints[key] = value.trim();
      breakpointValuesInPixels[key] = px;
    }
  });
  const breakpointNames = Object.keys(breakpoints);
  if (!breakpointNames.length) {
    return { ...DEFAULT_VIEWPORT_BREAKPOINTS };
  }
  if (1 === breakpointNames.length) {
    return breakpoints;
  }
  const mobile = breakpoints.mobile;
  const tablet = breakpoints.tablet;
  if (breakpointValuesInPixels.mobile >= breakpointValuesInPixels.tablet) {
    return { mobile };
  }
  return { mobile, tablet };
}
function getResponsiveMediaQueries(configOrSettings) {
  const breakpoints = getViewportBreakpoints(configOrSettings);
  const mediaQueries = {};
  if (breakpoints.mobile) {
    mediaQueries["@mobile"] = `@media (width <= ${breakpoints.mobile})`;
  }
  if (breakpoints.tablet) {
    mediaQueries["@tablet"] = breakpoints.mobile ? `@media (${breakpoints.mobile} < width <= ${breakpoints.tablet})` : `@media (width <= ${breakpoints.tablet})`;
  }
  return mediaQueries;
}

// packages/global-styles-engine/build-module/variation.mjs
function getVariationStyle(globalStyles, name2, variation, { resolveRefs = true } = {}) {
  if (!globalStyles?.styles?.blocks?.[name2]?.variations?.[variation]) {
    return void 0;
  }
  const replaceRefs = (variationStyles) => {
    Object.keys(variationStyles).forEach((key) => {
      const value = variationStyles[key];
      if (typeof value === "object" && value !== null) {
        if (value.ref !== void 0) {
          if (typeof value.ref !== "string" || value.ref.trim() === "") {
            delete variationStyles[key];
          } else {
            const refValue = getValueFromObjectPath(
              globalStyles,
              value.ref
            );
            if (refValue !== void 0 && refValue !== null) {
              variationStyles[key] = refValue;
            } else {
              delete variationStyles[key];
            }
          }
        } else {
          replaceRefs(value);
          if (Object.keys(value).length === 0) {
            delete variationStyles[key];
          }
        }
      }
    });
  };
  const styles = JSON.parse(
    JSON.stringify(
      globalStyles.styles.blocks[name2].variations[variation]
    )
  );
  if (resolveRefs) {
    replaceRefs(styles);
  }
  return styles;
}

// packages/global-styles-engine/build-module/resolve-style.mjs
var DEFAULT_STATE_VALUE = "default";
function isDefaultBlockStyleState(selectedState) {
  const viewport = selectedState?.viewport;
  const pseudoState = selectedState?.pseudoState;
  return (!viewport || viewport === DEFAULT_STATE_VALUE) && (!pseudoState || pseudoState === DEFAULT_STATE_VALUE);
}
function getStyleStatePath(selectedState) {
  if (isDefaultBlockStyleState(selectedState)) {
    return [];
  }
  return [selectedState.viewport, selectedState.pseudoState].filter(
    (state) => !!state && state !== DEFAULT_STATE_VALUE
  );
}
function getStyleForState(style, selectedState) {
  const path = getStyleStatePath(selectedState);
  if (!path.length) {
    return style;
  }
  return getValueFromObjectPath(style, path);
}
var TREE_STRUCTURAL_KEYS = /* @__PURE__ */ new Set(["blocks", "variations", "css"]);
var EMPTY_INHERITANCE = Object.freeze({
  value: {},
  sources: {}
});
var SOURCE_DESCRIPTORS = {
  root: { layer: "root" },
  element: { layer: "element" },
  block: { layer: "block" },
  blockVariation: { layer: "blockVariation" }
};
function createSourceDescriptor(type) {
  const descriptor = SOURCE_DESCRIPTORS[type];
  if (!descriptor) {
    return null;
  }
  return { ...descriptor };
}
function createContribution(styles, source) {
  if (!styles || !source) {
    return null;
  }
  return { styles, source };
}
function getPathKey(path) {
  return path.join(".");
}
function getSourceForPath(source) {
  return { ...source };
}
function isExplicitEmpty(value) {
  if (value === "" || value === null) {
    return true;
  }
  if (typeof value === "object" && !Array.isArray(value) && Object.keys(value).length === 0) {
    return true;
  }
  return false;
}
function isRefObject(value) {
  return value !== null && typeof value === "object" && !Array.isArray(value) && typeof value.ref === "string";
}
function pickLayerRootContribution(layer) {
  if (!layer || typeof layer !== "object" || Array.isArray(layer)) {
    return null;
  }
  const contribution = {};
  for (const key of Object.keys(layer)) {
    if (TREE_STRUCTURAL_KEYS.has(key)) {
      continue;
    }
    if (key === "elements") {
      if (layer.elements && typeof layer.elements === "object") {
        contribution.elements = layer.elements;
      }
      continue;
    }
    if (isExplicitEmpty(layer[key])) {
      continue;
    }
    contribution[key] = layer[key];
  }
  return Object.keys(contribution).length === 0 ? null : contribution;
}
var ATOMIC_OBJECT_KEYS = /* @__PURE__ */ new Set(["backgroundImage"]);
function deepMergeDroppingEmpties(target, source, globalStyles, sourceMetadata, sources, path = []) {
  if (!source || typeof source !== "object" || Array.isArray(source)) {
    return target;
  }
  for (const key of Object.keys(source)) {
    let sourceValue = source[key];
    if (isExplicitEmpty(sourceValue)) {
      continue;
    }
    if (isRefObject(sourceValue)) {
      if (sourceValue.ref.trim() === "") {
        continue;
      }
      const resolved = getValueFromObjectPath(
        globalStyles,
        sourceValue.ref
      );
      if (resolved === void 0 || resolved === null || isRefObject(resolved)) {
        continue;
      }
      sourceValue = resolved;
    }
    const nextPath = [...path, key];
    if (!ATOMIC_OBJECT_KEYS.has(key) && sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) && !isRefObject(sourceValue)) {
      const existing = target[key] && typeof target[key] === "object" && !Array.isArray(target[key]) ? target[key] : {};
      target[key] = deepMergeDroppingEmpties(
        { ...existing },
        sourceValue,
        globalStyles,
        sourceMetadata,
        sources,
        nextPath
      );
    } else {
      target[key] = ATOMIC_OBJECT_KEYS.has(key) && sourceValue !== null && typeof sourceValue === "object" && !Array.isArray(sourceValue) ? { ...sourceValue } : sourceValue;
      if (sourceMetadata && sources) {
        sources[getPathKey(nextPath)] = getSourceForPath(sourceMetadata);
      }
    }
  }
  return target;
}
function getStateSlice(layerObject, selectedState) {
  if (!layerObject) {
    return null;
  }
  const slice = getStyleForState(layerObject, selectedState);
  return slice && typeof slice === "object" && !Array.isArray(slice) ? slice : null;
}
var NON_CASCADING_ROOT_PREFIXES = [
  "color.background",
  "color.gradient",
  "background",
  "spacing",
  "dimensions",
  "border",
  "shadow",
  "filter"
];
function isNonCascadingRootPath(pathKey) {
  if (pathKey.startsWith("elements.")) {
    return false;
  }
  return NON_CASCADING_ROOT_PREFIXES.some(
    (prefix) => pathKey === prefix || pathKey.startsWith(`${prefix}.`)
  );
}
function deleteAtPath(target, pathSegments) {
  if (!target || typeof target !== "object") {
    return;
  }
  const [head2, ...rest] = pathSegments;
  if (rest.length === 0) {
    delete target[head2];
    return;
  }
  const child = target[head2];
  if (child && typeof child === "object") {
    deleteAtPath(child, rest);
    if (Object.keys(child).length === 0) {
      delete target[head2];
    }
  }
}
function dropNonCascadingRootLeaves(value, sources) {
  for (const pathKey of Object.keys(sources)) {
    if (sources[pathKey].layer === "root" && isNonCascadingRootPath(pathKey)) {
      deleteAtPath(value, pathKey.split("."));
      delete sources[pathKey];
    }
  }
}
function resolveThemeFileBackgroundImage(value, globalStyles, links) {
  const image = value?.background?.backgroundImage;
  if (!image) {
    return;
  }
  const resolved = getResolvedValue(image, {
    ...globalStyles,
    _links: links ?? void 0
  });
  if (resolved !== void 0) {
    value.background.backgroundImage = resolved;
  }
}
function computeResolvedStyle(globalStyles, {
  blockName,
  variationName = null,
  elements: elements2 = null,
  viewport = null,
  pseudoState = null
} = {}) {
  if (!globalStyles || !globalStyles.styles) {
    return EMPTY_INHERITANCE;
  }
  if (!blockName) {
    return EMPTY_INHERITANCE;
  }
  const styles = globalStyles.styles;
  const selectedState = { viewport, pseudoState };
  const root = styles;
  const block = styles.blocks?.[blockName] ?? null;
  const elementLayers = (elements2 ?? []).map((elementName) => styles.elements?.[elementName] ?? null).filter((layer) => !!layer);
  const variation = variationName ? getVariationStyle(globalStyles, blockName, variationName) ?? null : null;
  const contributions = [
    createContribution(
      pickLayerRootContribution(root),
      createSourceDescriptor("root")
    ),
    ...elementLayers.map(
      (layer) => createContribution(
        pickLayerRootContribution(layer),
        createSourceDescriptor("element")
      )
    ),
    block ? createContribution(
      pickLayerRootContribution(block),
      createSourceDescriptor("block")
    ) : null,
    variation ? createContribution(
      pickLayerRootContribution(variation),
      createSourceDescriptor("blockVariation")
    ) : null
  ];
  if (!isDefaultBlockStyleState(selectedState)) {
    contributions.push(
      createContribution(
        pickLayerRootContribution(
          getStateSlice(root, selectedState)
        ),
        createSourceDescriptor("root")
      ),
      ...elementLayers.map(
        (layer) => createContribution(
          pickLayerRootContribution(
            getStateSlice(layer, selectedState)
          ),
          createSourceDescriptor("element")
        )
      ),
      block ? createContribution(
        pickLayerRootContribution(
          getStateSlice(block, selectedState)
        ),
        createSourceDescriptor("block")
      ) : null,
      variation ? createContribution(
        pickLayerRootContribution(
          getStateSlice(variation, selectedState)
        ),
        createSourceDescriptor("blockVariation")
      ) : null
    );
  }
  const filteredContributions = contributions.filter(
    Boolean
  );
  if (filteredContributions.length === 0) {
    return EMPTY_INHERITANCE;
  }
  const sources = {};
  const value = filteredContributions.reduce(
    (mergedValue, contribution) => deepMergeDroppingEmpties(
      mergedValue,
      contribution.styles,
      globalStyles,
      contribution.source,
      sources
    ),
    {}
  );
  dropNonCascadingRootLeaves(value, sources);
  resolveThemeFileBackgroundImage(
    value,
    globalStyles,
    globalStyles._links ?? null
  );
  return { value, sources };
}
var NO_LINKS = {};
var memo = /* @__PURE__ */ new WeakMap();
function resolveStyle2(globalStyles, context = {}) {
  const styleData = globalStyles?.styles;
  if (!styleData || typeof styleData !== "object") {
    return computeResolvedStyle(globalStyles, context);
  }
  let byLinks = memo.get(styleData);
  if (!byLinks) {
    byLinks = /* @__PURE__ */ new WeakMap();
    memo.set(styleData, byLinks);
  }
  const linksKey = globalStyles?._links ?? NO_LINKS;
  let inner = byLinks.get(linksKey);
  if (!inner) {
    inner = /* @__PURE__ */ new Map();
    byLinks.set(linksKey, inner);
  }
  const sliceKey = `${context.elements?.join(",") ?? ""}:${context.viewport ?? ""}:${context.pseudoState ?? ""}`;
  const key = (context.blockName || "") + "" + (context.variationName || "") + "" + sliceKey;
  if (inner.has(key)) {
    return inner.get(key);
  }
  const result = computeResolvedStyle(globalStyles, context);
  inner.set(key, result);
  return result;
}

// packages/global-styles-engine/build-module/lock-unlock.mjs
var import_private_apis2 = __toESM(require_private_apis(), 1);
var { lock: lock2, unlock: unlock2 } = (0, import_private_apis2.__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/global-styles-engine"
);

// packages/global-styles-engine/build-module/private-apis.mjs
var privateApis = {};
lock2(privateApis, {
  getResponsiveMediaQueries,
  getViewportBreakpoints,
  getViewportBreakpointValueInPixels,
  resolveStyle: resolveStyle2,
  getVariationStyle
});

// packages/global-styles-ui/build-module/provider.mjs
var import_element21 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/context.mjs
var import_element20 = __toESM(require_element(), 1);
var GlobalStylesContext = (0, import_element20.createContext)({
  user: { styles: {}, settings: {} },
  base: { styles: {}, settings: {} },
  merged: { styles: {}, settings: {} },
  onChange: () => {
  },
  fontLibraryEnabled: false
});

// packages/global-styles-ui/build-module/provider.mjs
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);
function GlobalStylesProvider({
  children,
  value,
  baseValue,
  onChange,
  fontLibraryEnabled
}) {
  const merged = (0, import_element21.useMemo)(() => {
    return mergeGlobalStyles(baseValue, value);
  }, [baseValue, value]);
  const contextValue = (0, import_element21.useMemo)(
    () => ({
      user: value,
      base: baseValue,
      merged,
      onChange,
      fontLibraryEnabled
    }),
    [value, baseValue, merged, onChange, fontLibraryEnabled]
  );
  return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(GlobalStylesContext.Provider, { value: contextValue, children });
}

// packages/global-styles-ui/build-module/screen-root.mjs
var import_components8 = __toESM(require_components(), 1);
var import_i18n5 = __toESM(require_i18n(), 1);
var import_data2 = __toESM(require_data(), 1);
var import_core_data2 = __toESM(require_core_data(), 1);

// packages/global-styles-ui/build-module/icon-with-current-color.mjs
var import_jsx_runtime26 = __toESM(require_jsx_runtime(), 1);
function IconWithCurrentColor({
  className,
  ...props
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
    icon_default,
    {
      className: clsx_default(
        className,
        "global-styles-ui-icon-with-current-color"
      ),
      ...props
    }
  );
}

// packages/global-styles-ui/build-module/navigation-button.mjs
var import_components2 = __toESM(require_components(), 1);
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
function GenericNavigationButton({
  icon,
  children,
  ...props
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components2.__experimentalItem, { ...props, children: [
    icon && /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_components2.__experimentalHStack, { justify: "flex-start", children: [
      /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(IconWithCurrentColor, { icon, size: 24 }),
      /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components2.FlexItem, { children })
    ] }),
    !icon && children
  ] });
}
function NavigationButtonAsItem(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components2.Navigator.Button, { as: GenericNavigationButton, ...props });
}

// packages/global-styles-ui/build-module/root-menu.mjs
var import_components3 = __toESM(require_components(), 1);
var import_i18n3 = __toESM(require_i18n(), 1);
var import_block_editor = __toESM(require_block_editor(), 1);

// node_modules/colord/plugins/a11y.mjs
var o2 = function(o3) {
  var t3 = o3 / 255;
  return t3 < 0.04045 ? t3 / 12.92 : Math.pow((t3 + 0.055) / 1.055, 2.4);
};
var t2 = function(t3) {
  return 0.2126 * o2(t3.r) + 0.7152 * o2(t3.g) + 0.0722 * o2(t3.b);
};
function a11y_default(o3) {
  o3.prototype.luminance = function() {
    return o4 = t2(this.rgba), void 0 === (r3 = 2) && (r3 = 0), void 0 === n2 && (n2 = Math.pow(10, r3)), Math.round(n2 * o4) / n2 + 0;
    var o4, r3, n2;
  }, o3.prototype.contrast = function(r3) {
    void 0 === r3 && (r3 = "#FFF");
    var n2, a2, i2, e2, v2, u2, d2, c2 = r3 instanceof o3 ? r3 : new o3(r3);
    return e2 = this.rgba, v2 = c2.toRgb(), u2 = t2(e2), d2 = t2(v2), n2 = u2 > d2 ? (u2 + 0.05) / (d2 + 0.05) : (d2 + 0.05) / (u2 + 0.05), void 0 === (a2 = 2) && (a2 = 0), void 0 === i2 && (i2 = Math.pow(10, a2)), Math.floor(i2 * n2) / i2 + 0;
  }, o3.prototype.isReadable = function(o4, t3) {
    return void 0 === o4 && (o4 = "#FFF"), void 0 === t3 && (t3 = {}), this.contrast(o4) >= (e2 = void 0 === (i2 = (r3 = t3).size) ? "normal" : i2, "AAA" === (a2 = void 0 === (n2 = r3.level) ? "AA" : n2) && "normal" === e2 ? 7 : "AA" === a2 && "large" === e2 ? 3 : 4.5);
    var r3, n2, a2, i2, e2;
  };
}

// packages/global-styles-ui/build-module/hooks.mjs
var import_element22 = __toESM(require_element(), 1);
var import_data = __toESM(require_data(), 1);
var import_core_data = __toESM(require_core_data(), 1);
var import_i18n2 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/utils.mjs
var import_i18n = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/lock-unlock.mjs
var import_private_apis4 = __toESM(require_private_apis(), 1);
var { lock: lock3, unlock: unlock3 } = (0, import_private_apis4.__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/global-styles-ui"
);

// packages/global-styles-ui/build-module/utils.mjs
var { getViewportBreakpoints: getViewportBreakpoints2 } = unlock3(privateApis);
var VALID_ELEMENT_STATES = {
  link: [
    { value: ":link", label: (0, import_i18n.__)("Link") },
    { value: ":any-link", label: (0, import_i18n.__)("Any Link") },
    { value: ":visited", label: (0, import_i18n.__)("Visited") },
    { value: ":hover", label: (0, import_i18n.__)("Hover") },
    { value: ":focus", label: (0, import_i18n.__)("Focus") },
    { value: ":focus-visible", label: (0, import_i18n.__)("Focus-visible") },
    { value: ":active", label: (0, import_i18n.__)("Active") }
  ],
  button: [
    { value: ":link", label: (0, import_i18n.__)("Link") },
    { value: ":any-link", label: (0, import_i18n.__)("Any Link") },
    { value: ":visited", label: (0, import_i18n.__)("Visited") },
    { value: ":hover", label: (0, import_i18n.__)("Hover") },
    { value: ":focus", label: (0, import_i18n.__)("Focus") },
    { value: ":focus-visible", label: (0, import_i18n.__)("Focus-visible") },
    { value: ":active", label: (0, import_i18n.__)("Active") }
  ]
};
var VALID_BLOCK_STATES = {
  "core/button": [
    { value: ":hover", label: (0, import_i18n.__)("Hover") },
    { value: ":focus", label: (0, import_i18n.__)("Focus") },
    { value: ":focus-visible", label: (0, import_i18n.__)("Focus-visible") },
    { value: ":active", label: (0, import_i18n.__)("Active") }
  ]
};
var RESPONSIVE_STATES = [
  { value: "@tablet", label: (0, import_i18n.__)("Tablet") },
  { value: "@mobile", label: (0, import_i18n.__)("Mobile") }
];
function removePropertiesFromObject(object, properties) {
  if (!properties?.length) {
    return object;
  }
  if (typeof object !== "object" || !object || !Object.keys(object).length) {
    return object;
  }
  for (const key in object) {
    if (properties.includes(key)) {
      delete object[key];
    } else if (typeof object[key] === "object") {
      removePropertiesFromObject(object[key], properties);
    }
  }
  return object;
}
var filterObjectByProperties = (object, properties) => {
  if (!object || !properties?.length) {
    return {};
  }
  const newObject = {};
  Object.keys(object).forEach((key) => {
    if (properties.includes(key)) {
      newObject[key] = object[key];
    } else if (typeof object[key] === "object") {
      const newFilter = filterObjectByProperties(
        object[key],
        properties
      );
      if (Object.keys(newFilter).length) {
        newObject[key] = newFilter;
      }
    }
  });
  return newObject;
};
function isVariationWithProperties(variation, properties) {
  const variationWithProperties = filterObjectByProperties(
    structuredClone(variation),
    properties
  );
  return areGlobalStylesEqual(variationWithProperties, variation);
}
function getFontFamilyFromSetting(fontFamilies, setting) {
  if (!Array.isArray(fontFamilies) || !setting) {
    return null;
  }
  const fontFamilyVariable = setting.replace("var(", "").replace(")", "");
  const fontFamilySlug = fontFamilyVariable?.split("--").slice(-1)[0];
  return fontFamilies.find(
    (fontFamily) => fontFamily.slug === fontFamilySlug
  );
}
function getFontFamilies(themeJson) {
  const themeFontFamilies = themeJson?.settings?.typography?.fontFamilies?.theme;
  const customFontFamilies = themeJson?.settings?.typography?.fontFamilies?.custom;
  let fontFamilies = [];
  if (themeFontFamilies && customFontFamilies) {
    fontFamilies = [...themeFontFamilies, ...customFontFamilies];
  } else if (themeFontFamilies) {
    fontFamilies = themeFontFamilies;
  } else if (customFontFamilies) {
    fontFamilies = customFontFamilies;
  }
  const bodyFontFamilySetting = themeJson?.styles?.typography?.fontFamily;
  const bodyFontFamily = getFontFamilyFromSetting(
    fontFamilies,
    bodyFontFamilySetting
  );
  const headingFontFamilySetting = themeJson?.styles?.elements?.heading?.typography?.fontFamily;
  let headingFontFamily;
  if (!headingFontFamilySetting) {
    headingFontFamily = bodyFontFamily;
  } else {
    headingFontFamily = getFontFamilyFromSetting(
      fontFamilies,
      themeJson?.styles?.elements?.heading?.typography?.fontFamily
    );
  }
  return [bodyFontFamily, headingFontFamily];
}

// packages/global-styles-ui/build-module/hooks.mjs
k([a11y_default]);
function useStyle(path, blockName, readFrom = "merged", shouldDecodeEncode = true, state) {
  const { user, base, merged, onChange } = (0, import_element22.useContext)(GlobalStylesContext);
  const statePathParts = state?.split(".").filter(Boolean) ?? [];
  const pseudoSelectorState = statePathParts.find(
    (value) => value.startsWith(":")
  );
  const statePathWithoutPseudo = statePathParts.filter((value) => !value.startsWith(":")).join(".");
  const stylePath = [path, statePathWithoutPseudo].filter(Boolean).join(".");
  let sourceValue = merged;
  if (readFrom === "base") {
    sourceValue = base;
  } else if (readFrom === "user") {
    sourceValue = user;
  }
  const styleValue = (0, import_element22.useMemo)(() => {
    const rawValue = getStyle(
      sourceValue,
      stylePath,
      blockName,
      shouldDecodeEncode
    );
    if (pseudoSelectorState) {
      return rawValue?.[pseudoSelectorState] ?? {};
    }
    return rawValue;
  }, [
    sourceValue,
    stylePath,
    blockName,
    shouldDecodeEncode,
    pseudoSelectorState
  ]);
  const setStyleValue = (0, import_element22.useCallback)(
    (newValue) => {
      let valueToSet = newValue;
      if (pseudoSelectorState) {
        const fullCurrentValue = getStyle(
          user,
          stylePath,
          blockName,
          false
        );
        valueToSet = {
          ...fullCurrentValue,
          [pseudoSelectorState]: newValue
        };
      }
      const newGlobalStyles = setStyle(
        user,
        stylePath,
        valueToSet,
        blockName
      );
      onChange(newGlobalStyles);
    },
    [user, onChange, stylePath, blockName, pseudoSelectorState]
  );
  return [styleValue, setStyleValue];
}
function useSetting(path, blockName, readFrom = "merged") {
  const { user, base, merged, onChange } = (0, import_element22.useContext)(GlobalStylesContext);
  let sourceValue = merged;
  if (readFrom === "base") {
    sourceValue = base;
  } else if (readFrom === "user") {
    sourceValue = user;
  }
  const settingValue = (0, import_element22.useMemo)(
    () => getSetting(sourceValue, path, blockName),
    [sourceValue, path, blockName]
  );
  const setSettingValue = (0, import_element22.useCallback)(
    (newValue) => {
      const newGlobalStyles = setSetting(
        user,
        path,
        newValue,
        blockName
      );
      onChange(newGlobalStyles);
    },
    [user, onChange, path, blockName]
  );
  return [settingValue, setSettingValue];
}
var EMPTY_ARRAY2 = [];
function hasThemeVariation({
  title,
  settings,
  styles
}) {
  return title === (0, import_i18n2.__)("Default") || Object.keys(settings || {}).length > 0 || Object.keys(styles || {}).length > 0;
}
function useCurrentMergeThemeStyleVariationsWithUserConfig(properties = []) {
  const { variationsFromTheme } = (0, import_data.useSelect)((select) => {
    const _variationsFromTheme = select(
      import_core_data.store
    ).__experimentalGetCurrentThemeGlobalStylesVariations?.();
    return {
      variationsFromTheme: _variationsFromTheme || EMPTY_ARRAY2
    };
  }, []);
  const { user: userVariation } = (0, import_element22.useContext)(GlobalStylesContext);
  return (0, import_element22.useMemo)(() => {
    const clonedUserVariation = structuredClone(userVariation);
    const userVariationWithoutProperties = removePropertiesFromObject(
      clonedUserVariation,
      properties
    );
    userVariationWithoutProperties.title = (0, import_i18n2.__)("Default");
    const variationsWithPropertiesAndBase = variationsFromTheme.filter((variation) => {
      return isVariationWithProperties(variation, properties);
    }).map((variation) => {
      return mergeGlobalStyles(
        userVariationWithoutProperties,
        variation
      );
    });
    const variationsByProperties = [
      userVariationWithoutProperties,
      ...variationsWithPropertiesAndBase
    ];
    return variationsByProperties?.length ? variationsByProperties.filter(hasThemeVariation) : [];
  }, [properties, userVariation, variationsFromTheme]);
}

// packages/global-styles-ui/build-module/root-menu.mjs
var import_jsx_runtime28 = __toESM(require_jsx_runtime(), 1);
var {
  useHasDimensionsPanel,
  useHasTypographyPanel,
  useHasColorPanel,
  useSettingsForBlockElement,
  useHasBackgroundPanel
} = unlock3(import_block_editor.privateApis);

// packages/global-styles-ui/build-module/preview-styles.mjs
var import_components7 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/preview-hooks.mjs
function useStylesPreviewColors() {
  const [textColor = "black"] = useStyle("color.text");
  const [backgroundColor = "white"] = useStyle("color.background");
  const [headingColor = textColor] = useStyle(
    "elements.h1.color.text"
  );
  const [linkColor = headingColor] = useStyle(
    "elements.link.color.text"
  );
  const [buttonBackgroundColor = linkColor] = useStyle(
    "elements.button.color.background"
  );
  const [coreColors] = useSetting("color.palette.core") || [];
  const [themeColors] = useSetting("color.palette.theme") || [];
  const [customColors] = useSetting("color.palette.custom") || [];
  const paletteColors = (themeColors ?? []).concat(customColors ?? []).concat(coreColors ?? []);
  const textColorObject = paletteColors.filter(
    ({ color }) => color === textColor
  );
  const buttonBackgroundColorObject = paletteColors.filter(
    ({ color }) => color === buttonBackgroundColor
  );
  const highlightedColors = textColorObject.concat(buttonBackgroundColorObject).concat(paletteColors).filter(
    // we exclude these background color because it is already visible in the preview.
    ({ color }) => color !== backgroundColor
  ).slice(0, 2);
  return {
    paletteColors,
    highlightedColors
  };
}

// packages/global-styles-ui/build-module/typography-example.mjs
var import_element23 = __toESM(require_element(), 1);
var import_components4 = __toESM(require_components(), 1);
var import_i18n4 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/font-library/utils/preview-styles.mjs
function findNearest(input, numbers) {
  if (numbers.length === 0) {
    return null;
  }
  numbers.sort((a2, b2) => Math.abs(input - a2) - Math.abs(input - b2));
  return numbers[0];
}
function extractFontWeights(fontFaces) {
  const result = [];
  fontFaces.forEach((face) => {
    const weights = String(face.fontWeight).split(" ");
    if (weights.length === 2) {
      const start = parseInt(weights[0]);
      const end = parseInt(weights[1]);
      for (let i2 = start; i2 <= end; i2 += 100) {
        result.push(i2);
      }
    } else if (weights.length === 1) {
      result.push(parseInt(weights[0]));
    }
  });
  return result;
}
function formatFontFamily(input) {
  const regex = /^(?!generic\([ a-zA-Z\-]+\)$)(?!^[a-zA-Z\-]+$).+/;
  const output = input.trim();
  const formatItem = (item) => {
    item = item.trim();
    if (item.match(regex)) {
      item = item.replace(/^["']|["']$/g, "");
      return `"${item}"`;
    }
    return item;
  };
  if (output.includes(",")) {
    return output.split(",").map(formatItem).filter((item) => item !== "").join(", ");
  }
  return formatItem(output);
}
function formatFontFaceName(input) {
  if (!input) {
    return "";
  }
  let output = input.trim();
  if (output.includes(",")) {
    output = (output.split(",").find((item) => item.trim() !== "") ?? "").trim();
  }
  output = output.replace(/^["']|["']$/g, "");
  if (window.navigator.userAgent.toLowerCase().includes("firefox")) {
    output = `"${output}"`;
  }
  return output;
}
function getFamilyPreviewStyle(family) {
  const style = {
    fontFamily: formatFontFamily(family.fontFamily)
  };
  if (!("fontFace" in family) || !Array.isArray(family.fontFace)) {
    style.fontWeight = "400";
    style.fontStyle = "normal";
    return style;
  }
  if (family.fontFace) {
    const normalFaces = family.fontFace.filter(
      (face) => face?.fontStyle && face.fontStyle.toLowerCase() === "normal"
    );
    if (normalFaces.length > 0) {
      style.fontStyle = "normal";
      const normalWeights = extractFontWeights(normalFaces);
      const nearestWeight = findNearest(400, normalWeights);
      style.fontWeight = String(nearestWeight) || "400";
    } else {
      style.fontStyle = family.fontFace.length && family.fontFace[0].fontStyle || "normal";
      style.fontWeight = family.fontFace.length && String(family.fontFace[0].fontWeight) || "400";
    }
  }
  return style;
}
function getFacePreviewStyle(face) {
  return {
    fontFamily: formatFontFamily(face.fontFamily),
    fontStyle: face.fontStyle || "normal",
    fontWeight: face.fontWeight || "400"
  };
}

// packages/global-styles-ui/build-module/typography-example.mjs
var import_jsx_runtime29 = __toESM(require_jsx_runtime(), 1);
function PreviewTypography({
  fontSize,
  variation
}) {
  const { base } = (0, import_element23.useContext)(GlobalStylesContext);
  let config = base;
  if (variation) {
    config = { ...base, ...variation };
  }
  const [textColor] = useStyle("color.text");
  const [bodyFontFamilies, headingFontFamilies] = getFontFamilies(config);
  const bodyPreviewStyle = bodyFontFamilies ? getFamilyPreviewStyle(bodyFontFamilies) : {};
  const headingPreviewStyle = headingFontFamilies ? getFamilyPreviewStyle(headingFontFamilies) : {};
  if (textColor) {
    bodyPreviewStyle.color = textColor;
    headingPreviewStyle.color = textColor;
  }
  if (fontSize) {
    bodyPreviewStyle.fontSize = fontSize;
    headingPreviewStyle.fontSize = fontSize;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)(
    import_components4.__unstableMotion.div,
    {
      animate: {
        scale: 1,
        opacity: 1
      },
      initial: {
        scale: 0.1,
        opacity: 0
      },
      transition: {
        delay: 0.3,
        type: "tween"
      },
      style: {
        textAlign: "center",
        lineHeight: 1
      },
      children: [
        /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n4._x)("A", "Uppercase letter A") }),
        /* @__PURE__ */ (0, import_jsx_runtime29.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n4._x)("a", "Lowercase letter A") })
      ]
    }
  );
}

// packages/global-styles-ui/build-module/highlighted-colors.mjs
var import_components5 = __toESM(require_components(), 1);
var import_jsx_runtime30 = __toESM(require_jsx_runtime(), 1);
function HighlightedColors({
  normalizedColorSwatchSize,
  ratio
}) {
  const { highlightedColors } = useStylesPreviewColors();
  const scaledSwatchSize = normalizedColorSwatchSize * ratio;
  return highlightedColors.map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
    import_components5.__unstableMotion.div,
    {
      style: {
        height: scaledSwatchSize,
        width: scaledSwatchSize,
        background: color,
        borderRadius: scaledSwatchSize / 2
      },
      animate: {
        scale: 1,
        opacity: 1
      },
      initial: {
        scale: 0.1,
        opacity: 0
      },
      transition: {
        delay: index2 === 1 ? 0.2 : 0.1
      }
    },
    `${slug}-${index2}`
  ));
}

// packages/global-styles-ui/build-module/preview-wrapper.mjs
var import_components6 = __toESM(require_components(), 1);
var import_compose = __toESM(require_compose(), 1);
var import_element24 = __toESM(require_element(), 1);
var import_jsx_runtime31 = __toESM(require_jsx_runtime(), 1);
var normalizedWidth = 248;
var normalizedHeight = 152;
var THROTTLE_OPTIONS = {
  leading: true,
  trailing: true
};
function PreviewWrapper({
  children,
  label,
  isFocused,
  withHoverView
}) {
  const [backgroundColor = "white"] = useStyle("color.background");
  const [gradientValue] = useStyle("color.gradient");
  const disableMotion = (0, import_compose.useReducedMotion)();
  const [isHovered, setIsHovered] = (0, import_element24.useState)(false);
  const [containerResizeListener, { width }] = (0, import_compose.useResizeObserver)();
  const [throttledWidth, setThrottledWidthState] = (0, import_element24.useState)(width);
  const [ratioState, setRatioState] = (0, import_element24.useState)();
  const setThrottledWidth = (0, import_compose.useThrottle)(
    setThrottledWidthState,
    250,
    THROTTLE_OPTIONS
  );
  (0, import_element24.useLayoutEffect)(() => {
    if (width) {
      setThrottledWidth(width);
    }
  }, [width, setThrottledWidth]);
  (0, import_element24.useLayoutEffect)(() => {
    const newRatio = throttledWidth ? throttledWidth / normalizedWidth : 1;
    const ratioDiff = newRatio - (ratioState || 0);
    const isRatioDiffBigEnough = Math.abs(ratioDiff) > 0.1;
    if (isRatioDiffBigEnough || !ratioState) {
      setRatioState(newRatio);
    }
  }, [throttledWidth, ratioState]);
  const fallbackRatio = width ? width / normalizedWidth : 1;
  const ratio = ratioState ? ratioState : fallbackRatio;
  const isReady = !!width;
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_jsx_runtime31.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }),
    !isReady && // Match the preview aspect ratio so layout doesn't jump once width is measured.
    /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
      Skeleton,
      {
        className: "global-styles-ui-preview__wrapper",
        style: {
          aspectRatio: normalizedWidth / normalizedHeight
        }
      }
    ),
    isReady && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
      "div",
      {
        className: clsx_default("global-styles-ui-preview__wrapper", {
          "is-hoverable": withHoverView
        }),
        style: {
          height: normalizedHeight * ratio
        },
        onMouseEnter: () => setIsHovered(true),
        onMouseLeave: () => setIsHovered(false),
        tabIndex: -1,
        children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
          import_components6.__unstableMotion.div,
          {
            style: {
              height: normalizedHeight * ratio,
              width: "100%",
              background: gradientValue ?? backgroundColor
            },
            initial: "start",
            animate: (isHovered || isFocused) && !disableMotion && label ? "hover" : "start",
            children: [].concat(children).map(
              (child, key) => child({ ratio, key })
            )
          }
        )
      }
    )
  ] });
}
var preview_wrapper_default = PreviewWrapper;

// packages/global-styles-ui/build-module/preview-styles.mjs
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
var firstFrameVariants = {
  start: {
    scale: 1,
    opacity: 1
  },
  hover: {
    scale: 0,
    opacity: 0
  }
};
var midFrameVariants = {
  hover: {
    opacity: 1
  },
  start: {
    opacity: 0.5
  }
};
var secondFrameVariants = {
  hover: {
    scale: 1,
    opacity: 1
  },
  start: {
    scale: 0,
    opacity: 0
  }
};
function PreviewStyles({
  label,
  isFocused,
  withHoverView,
  variation
}) {
  const [fontWeight] = useStyle("typography.fontWeight");
  const [fontFamily = "serif"] = useStyle(
    "typography.fontFamily"
  );
  const [headingFontFamily = fontFamily] = useStyle(
    "elements.h1.typography.fontFamily"
  );
  const [headingFontWeight = fontWeight] = useStyle(
    "elements.h1.typography.fontWeight"
  );
  const [textColor = "black"] = useStyle("color.text");
  const [headingColor = textColor] = useStyle(
    "elements.h1.color.text"
  );
  const { paletteColors } = useStylesPreviewColors();
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
    preview_wrapper_default,
    {
      label,
      isFocused,
      withHoverView,
      children: [
        ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
          import_components7.__unstableMotion.div,
          {
            variants: firstFrameVariants,
            style: {
              height: "100%",
              overflow: "hidden"
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(
              import_components7.__experimentalHStack,
              {
                spacing: 10 * ratio,
                justify: "center",
                style: {
                  height: "100%",
                  overflow: "hidden"
                },
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
                    PreviewTypography,
                    {
                      fontSize: 65 * ratio,
                      variation
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(import_components7.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
                    HighlightedColors,
                    {
                      normalizedColorSwatchSize: 32,
                      ratio
                    }
                  ) })
                ]
              }
            )
          },
          key
        ),
        ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
          import_components7.__unstableMotion.div,
          {
            variants: withHoverView ? midFrameVariants : void 0,
            style: {
              height: "100%",
              width: "100%",
              position: "absolute",
              top: 0,
              overflow: "hidden",
              filter: "blur(60px)",
              opacity: 0.1
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
              import_components7.__experimentalHStack,
              {
                spacing: 0,
                justify: "flex-start",
                style: {
                  height: "100%",
                  overflow: "hidden"
                },
                children: paletteColors.slice(0, 4).map(({ color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
                  "div",
                  {
                    style: {
                      height: "100%",
                      background: color,
                      flexGrow: 1
                    }
                  },
                  index2
                ))
              }
            )
          },
          key
        ),
        ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
          import_components7.__unstableMotion.div,
          {
            variants: secondFrameVariants,
            style: {
              height: "100%",
              width: "100%",
              overflow: "hidden",
              position: "absolute",
              top: 0
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
              import_components7.__experimentalVStack,
              {
                spacing: 3 * ratio,
                justify: "center",
                style: {
                  height: "100%",
                  overflow: "hidden",
                  padding: 10 * ratio,
                  boxSizing: "border-box"
                },
                children: label && /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
                  "div",
                  {
                    style: {
                      fontSize: 40 * ratio,
                      fontFamily: headingFontFamily,
                      color: headingColor,
                      fontWeight: headingFontWeight,
                      lineHeight: "1em",
                      textAlign: "center"
                    },
                    children: label
                  }
                )
              }
            )
          },
          key
        )
      ]
    }
  );
}
var preview_styles_default = PreviewStyles;

// packages/global-styles-ui/build-module/screen-root.mjs
var import_jsx_runtime33 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-block-list.mjs
var import_blocks2 = __toESM(require_blocks(), 1);
var import_i18n7 = __toESM(require_i18n(), 1);
var import_components11 = __toESM(require_components(), 1);
var import_data4 = __toESM(require_data(), 1);
var import_element25 = __toESM(require_element(), 1);
var import_block_editor3 = __toESM(require_block_editor(), 1);
var import_compose2 = __toESM(require_compose(), 1);
import { speak } from "@wordpress/a11y";

// packages/global-styles-ui/build-module/variations/variations-panel.mjs
var import_blocks = __toESM(require_blocks(), 1);
var import_data3 = __toESM(require_data(), 1);
var import_components9 = __toESM(require_components(), 1);
var import_jsx_runtime34 = __toESM(require_jsx_runtime(), 1);
function getFilteredBlockStyles(blockStyles, variations) {
  return blockStyles?.filter(
    (style) => style.source === "block" || variations.includes(style.name)
  ) || [];
}
function useBlockVariations(name2) {
  const blockStyles = (0, import_data3.useSelect)(
    (select) => {
      const { getBlockStyles } = select(import_blocks.store);
      return getBlockStyles(name2);
    },
    [name2]
  );
  const [variations] = useStyle("variations", name2);
  const variationNames = Object.keys(variations ?? {});
  return getFilteredBlockStyles(blockStyles, variationNames);
}

// packages/global-styles-ui/build-module/screen-header.mjs
var import_components10 = __toESM(require_components(), 1);
var import_i18n6 = __toESM(require_i18n(), 1);
var import_block_editor2 = __toESM(require_block_editor(), 1);
var import_jsx_runtime35 = __toESM(require_jsx_runtime(), 1);
var { StateControl, StateControlBadges } = unlock3(import_block_editor2.privateApis);

// packages/global-styles-ui/build-module/screen-block-list.mjs
var import_jsx_runtime36 = __toESM(require_jsx_runtime(), 1);
var {
  useHasDimensionsPanel: useHasDimensionsPanel2,
  useHasTypographyPanel: useHasTypographyPanel2,
  useHasBorderPanel,
  useSettingsForBlockElement: useSettingsForBlockElement2,
  useHasColorPanel: useHasColorPanel2,
  useHasBackgroundPanel: useHasBackgroundPanel2
} = unlock3(import_block_editor3.privateApis);
function useSortedBlockTypes() {
  const blockItems = (0, import_data4.useSelect)(
    (select) => select(import_blocks2.store).getBlockTypes(),
    []
  );
  const groupByType = (blocks, block) => {
    const { core, noncore } = blocks;
    const type = block.name.startsWith("core/") ? core : noncore;
    type.push(block);
    return blocks;
  };
  const { core: coreItems, noncore: nonCoreItems } = blockItems.reduce(
    groupByType,
    { core: [], noncore: [] }
  );
  return [...coreItems, ...nonCoreItems];
}
function useBlockHasGlobalStyles(blockName) {
  const [rawSettings] = useSetting("", blockName);
  const settings = useSettingsForBlockElement2(rawSettings, blockName);
  const hasTypographyPanel = useHasTypographyPanel2(settings);
  const hasColorPanel = useHasColorPanel2(settings);
  const hasBackgroundPanel = useHasBackgroundPanel2(settings);
  const hasBorderPanel = useHasBorderPanel(settings);
  const hasDimensionsPanel = useHasDimensionsPanel2(settings);
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
  const hasVariationsPanel = !!useBlockVariations(blockName)?.length;
  const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasBackgroundPanel || hasLayoutPanel || hasVariationsPanel;
  return hasGlobalStyles;
}
function BlockMenuItem({ block }) {
  const hasBlockMenuItem = useBlockHasGlobalStyles(block.name);
  if (!hasBlockMenuItem) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
    NavigationButtonAsItem,
    {
      path: "/blocks/" + encodeURIComponent(block.name),
      children: /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components11.__experimentalHStack, { justify: "flex-start", children: [
        /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_block_editor3.BlockIcon, { icon: block.icon }),
        /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components11.FlexItem, { children: block.title })
      ] })
    }
  );
}
function BlockList({ filterValue }) {
  const sortedBlockTypes = useSortedBlockTypes();
  const debouncedSpeak = (0, import_compose2.useDebounce)(speak, 500);
  const { isMatchingSearchTerm } = (0, import_data4.useSelect)(import_blocks2.store);
  const filteredBlockTypes = !filterValue ? sortedBlockTypes : sortedBlockTypes.filter(
    (blockType) => isMatchingSearchTerm(blockType, filterValue)
  );
  const blockTypesListRef = (0, import_element25.useRef)(null);
  (0, import_element25.useEffect)(() => {
    if (!filterValue) {
      return;
    }
    const count = blockTypesListRef.current?.childElementCount || 0;
    const resultsFoundMessage = (0, import_i18n7.sprintf)(
      /* translators: %d: number of results. */
      (0, import_i18n7._n)("%d result found.", "%d results found.", count),
      count
    );
    debouncedSpeak(resultsFoundMessage, "polite");
  }, [filterValue, debouncedSpeak]);
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
    "div",
    {
      ref: blockTypesListRef,
      className: "global-styles-ui-block-types-item-list",
      role: "list",
      children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components11.__experimentalText, { align: "center", as: "p", children: (0, import_i18n7.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
        BlockMenuItem,
        {
          block
        },
        "menu-itemblock-" + block.name
      ))
    }
  );
}
var MemoizedBlockList = (0, import_element25.memo)(BlockList);

// packages/global-styles-ui/build-module/screen-block.mjs
var import_blocks4 = __toESM(require_blocks(), 1);
var import_block_editor5 = __toESM(require_block_editor(), 1);
var import_element27 = __toESM(require_element(), 1);
var import_data5 = __toESM(require_data(), 1);
var import_core_data3 = __toESM(require_core_data(), 1);
var import_components14 = __toESM(require_components(), 1);
var import_i18n8 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/block-preview-panel.mjs
var import_block_editor4 = __toESM(require_block_editor(), 1);
var import_blocks3 = __toESM(require_blocks(), 1);
var import_components12 = __toESM(require_components(), 1);
var import_element26 = __toESM(require_element(), 1);
var import_jsx_runtime37 = __toESM(require_jsx_runtime(), 1);
var { getViewportBreakpoints: getViewportBreakpoints3, getViewportBreakpointValueInPixels: getViewportBreakpointValueInPixels2 } = unlock3(
  privateApis
);

// packages/global-styles-ui/build-module/subtitle.mjs
var import_components13 = __toESM(require_components(), 1);
var import_jsx_runtime38 = __toESM(require_jsx_runtime(), 1);
function Subtitle({ children, level = 2 }) {
  return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(import_components13.__experimentalHeading, { className: "global-styles-ui-subtitle", level, children });
}

// packages/global-styles-ui/build-module/screen-block.mjs
var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);
var {
  useHasDimensionsPanel: useHasDimensionsPanel3,
  useHasTypographyPanel: useHasTypographyPanel3,
  useHasBorderPanel: useHasBorderPanel2,
  useSettingsForBlockElement: useSettingsForBlockElement3,
  useHasColorPanel: useHasColorPanel3,
  useHasFiltersPanel,
  useHasImageSettingsPanel,
  useHasBackgroundPanel: useHasBackgroundPanel3,
  BackgroundPanel: StylesBackgroundPanel,
  BorderPanel: StylesBorderPanel,
  ColorPanel: StylesColorPanel,
  TypographyPanel: StylesTypographyPanel,
  DimensionsPanel: StylesDimensionsPanel,
  FiltersPanel: StylesFiltersPanel,
  ImageSettingsPanel,
  AdvancedPanel: StylesAdvancedPanel
} = unlock3(import_block_editor5.privateApis);

// packages/global-styles-ui/build-module/screen-typography.mjs
var import_i18n22 = __toESM(require_i18n(), 1);
var import_components33 = __toESM(require_components(), 1);
var import_element39 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/screen-body.mjs
var import_components15 = __toESM(require_components(), 1);
var import_jsx_runtime40 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/typography-elements.mjs
var import_i18n9 = __toESM(require_i18n(), 1);
var import_components16 = __toESM(require_components(), 1);
var import_jsx_runtime41 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/variations/variations-typography.mjs
var import_components18 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/preview-typography.mjs
var import_components17 = __toESM(require_components(), 1);
var import_jsx_runtime42 = __toESM(require_jsx_runtime(), 1);
var StylesPreviewTypography = ({
  variation,
  isFocused,
  withHoverView
}) => {
  return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
    preview_wrapper_default,
    {
      label: variation.title,
      isFocused,
      withHoverView,
      children: ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
        import_components17.__experimentalHStack,
        {
          spacing: 10 * ratio,
          justify: "center",
          style: {
            height: "100%",
            overflow: "hidden"
          },
          children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
            PreviewTypography,
            {
              variation,
              fontSize: 85 * ratio
            }
          )
        },
        key
      )
    }
  );
};
var preview_typography_default = StylesPreviewTypography;

// packages/global-styles-ui/build-module/variations/variation.mjs
var import_element28 = __toESM(require_element(), 1);
var import_keycodes = __toESM(require_keycodes(), 1);
var import_i18n10 = __toESM(require_i18n(), 1);
var import_jsx_runtime43 = __toESM(require_jsx_runtime(), 1);
function Variation({
  variation,
  children,
  isPill = false,
  properties,
  showTooltip = false
}) {
  const [isFocused, setIsFocused] = (0, import_element28.useState)(false);
  const {
    base,
    user,
    onChange: setUserConfig
  } = (0, import_element28.useContext)(GlobalStylesContext);
  const context = (0, import_element28.useMemo)(() => {
    let merged = mergeGlobalStyles(base, variation);
    if (properties) {
      merged = filterObjectByProperties(merged, properties);
    }
    return {
      user: variation,
      base,
      merged,
      onChange: () => {
      }
    };
  }, [variation, base, properties]);
  const selectVariation = () => setUserConfig(variation);
  const selectOnEnter = (event) => {
    if (event.keyCode === import_keycodes.ENTER) {
      event.preventDefault();
      selectVariation();
    }
  };
  const isActive = (0, import_element28.useMemo)(
    () => areGlobalStylesEqual(user, variation),
    [user, variation]
  );
  let label = variation?.title;
  if (variation?.description) {
    label = (0, import_i18n10.sprintf)(
      /* translators: 1: variation title. 2: variation description. */
      (0, import_i18n10._x)("%1$s (%2$s)", "variation label"),
      variation?.title,
      variation?.description
    );
  }
  const content = /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
    "div",
    {
      className: clsx_default("global-styles-ui-variations_item", {
        "is-active": isActive
      }),
      role: "button",
      onClick: selectVariation,
      onKeyDown: selectOnEnter,
      tabIndex: 0,
      "aria-label": label,
      "aria-current": isActive,
      onFocus: () => setIsFocused(true),
      onBlur: () => setIsFocused(false),
      children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(
        "div",
        {
          className: clsx_default("global-styles-ui-variations_item-preview", {
            "is-pill": isPill
          }),
          children: children(isFocused)
        }
      )
    }
  );
  return /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)(tooltip_exports.Root, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(tooltip_exports.Trigger, { render: content }),
    /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(tooltip_exports.Popup, { children: variation?.title })
  ] }) : content });
}

// packages/global-styles-ui/build-module/variations/variations-typography.mjs
var import_jsx_runtime44 = __toESM(require_jsx_runtime(), 1);
var propertiesToFilter = ["typography"];
function TypographyVariations({
  title,
  gap = 2
}) {
  const typographyVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter);
  if (typographyVariations?.length <= 1) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_components18.__experimentalVStack, { spacing: 3, children: [
    title && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(Subtitle, { level: 3, children: title }),
    /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
      import_components18.__experimentalGrid,
      {
        columns: 3,
        gap,
        className: "global-styles-ui-style-variations-container",
        children: typographyVariations.map(
          (variation, index2) => {
            return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
              Variation,
              {
                variation,
                properties: propertiesToFilter,
                showTooltip: true,
                children: () => /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
                  preview_typography_default,
                  {
                    variation
                  }
                )
              },
              index2
            );
          }
        )
      }
    )
  ] });
}

// packages/global-styles-ui/build-module/font-families.mjs
var import_i18n20 = __toESM(require_i18n(), 1);
var import_components31 = __toESM(require_components(), 1);
var import_element38 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/font-library/context.mjs
var import_element29 = __toESM(require_element(), 1);
var import_data6 = __toESM(require_data(), 1);
var import_core_data5 = __toESM(require_core_data(), 1);
var import_i18n12 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/font-library/api.mjs
var import_api_fetch = __toESM(require_api_fetch(), 1);
var import_core_data4 = __toESM(require_core_data(), 1);
var FONT_FAMILIES_URL = "/wp/v2/font-families";
function invalidateFontFamilyCache(registry) {
  const { receiveEntityRecords } = registry.dispatch(import_core_data4.store);
  receiveEntityRecords(
    "postType",
    "wp_font_family",
    [],
    void 0,
    true
    // invalidateCache
  );
}
async function fetchInstallFontFamily(data, registry) {
  const config = {
    path: FONT_FAMILIES_URL,
    method: "POST",
    body: data
  };
  const response = await (0, import_api_fetch.default)(config);
  invalidateFontFamilyCache(registry);
  return {
    id: response.id,
    ...response.font_family_settings,
    fontFace: []
  };
}
async function fetchInstallFontFace(fontFamilyId, data, registry) {
  const config = {
    path: `${FONT_FAMILIES_URL}/${fontFamilyId}/font-faces`,
    method: "POST",
    body: data
  };
  const response = await (0, import_api_fetch.default)(config);
  invalidateFontFamilyCache(registry);
  return {
    id: response.id,
    ...response.font_face_settings
  };
}

// packages/global-styles-ui/build-module/font-library/utils/index.mjs
var import_components19 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/font-library/utils/constants.mjs
var import_i18n11 = __toESM(require_i18n(), 1);
var ALLOWED_FILE_EXTENSIONS = ["otf", "ttf", "woff", "woff2"];
var FONT_WEIGHTS = {
  100: (0, import_i18n11._x)("Thin", "font weight"),
  200: (0, import_i18n11._x)("Extra-light", "font weight"),
  300: (0, import_i18n11._x)("Light", "font weight"),
  400: (0, import_i18n11._x)("Normal", "font weight"),
  500: (0, import_i18n11._x)("Medium", "font weight"),
  600: (0, import_i18n11._x)("Semi-bold", "font weight"),
  700: (0, import_i18n11._x)("Bold", "font weight"),
  800: (0, import_i18n11._x)("Extra-bold", "font weight"),
  900: (0, import_i18n11._x)("Black", "font weight")
};
var FONT_STYLES = {
  normal: (0, import_i18n11._x)("Normal", "font style"),
  italic: (0, import_i18n11._x)("Italic", "font style")
};

// packages/global-styles-ui/build-module/font-library/utils/index.mjs
var { File } = window;
var { kebabCase } = unlock3(import_components19.privateApis);
function setUIValuesNeeded(font2, extraValues = {}) {
  if (!font2.name && (font2.fontFamily || font2.slug)) {
    font2.name = font2.fontFamily || font2.slug;
  }
  return {
    ...font2,
    ...extraValues
  };
}
function isUrlEncoded(url) {
  if (typeof url !== "string") {
    return false;
  }
  return url !== decodeURIComponent(url);
}
function getFontFaceVariantName(face) {
  const weightName = FONT_WEIGHTS[face.fontWeight ?? ""] || face.fontWeight;
  const styleName = face.fontStyle === "normal" ? "" : FONT_STYLES[face.fontStyle ?? ""] || face.fontStyle;
  return `${weightName} ${styleName}`;
}
function mergeFontFaces(existing = [], incoming = []) {
  const map = /* @__PURE__ */ new Map();
  for (const face of existing) {
    map.set(`${face.fontWeight}${face.fontStyle}`, face);
  }
  for (const face of incoming) {
    map.set(`${face.fontWeight}${face.fontStyle}`, face);
  }
  return Array.from(map.values());
}
function mergeFontFamilies(existing = [], incoming = []) {
  const map = /* @__PURE__ */ new Map();
  for (const font2 of existing) {
    map.set(font2.slug, { ...font2 });
  }
  for (const font2 of incoming) {
    if (map.has(font2.slug)) {
      const { fontFace: incomingFontFaces, ...restIncoming } = font2;
      const existingFont = map.get(font2.slug);
      const mergedFontFaces = mergeFontFaces(
        existingFont.fontFace,
        incomingFontFaces
      );
      map.set(font2.slug, {
        ...restIncoming,
        fontFace: mergedFontFaces
      });
    } else {
      map.set(font2.slug, { ...font2 });
    }
  }
  return Array.from(map.values());
}
async function loadFontFaceInBrowser(fontFace, source, addTo = "all") {
  let dataSource;
  if (typeof source === "string") {
    dataSource = `url(${source})`;
  } else if (source instanceof File) {
    dataSource = await source.arrayBuffer();
  } else {
    return;
  }
  const newFont = new window.FontFace(
    formatFontFaceName(fontFace.fontFamily),
    dataSource,
    {
      style: fontFace.fontStyle,
      weight: String(fontFace.fontWeight)
    }
  );
  const loadedFace = await newFont.load();
  if (addTo === "document" || addTo === "all") {
    document.fonts.add(loadedFace);
  }
  if (addTo === "iframe" || addTo === "all") {
    const iframe = document.querySelector(
      'iframe[name="editor-canvas"]'
    );
    if (iframe?.contentDocument) {
      iframe.contentDocument.fonts.add(loadedFace);
    }
  }
}
function unloadFontFaceInBrowser(fontFace, removeFrom = "all") {
  const unloadFontFace = (fonts) => {
    fonts.forEach((f2) => {
      if (f2.family === formatFontFaceName(fontFace?.fontFamily) && f2.weight === fontFace?.fontWeight && f2.style === fontFace?.fontStyle) {
        fonts.delete(f2);
      }
    });
  };
  if (removeFrom === "document" || removeFrom === "all") {
    unloadFontFace(document.fonts);
  }
  if (removeFrom === "iframe" || removeFrom === "all") {
    const iframe = document.querySelector(
      'iframe[name="editor-canvas"]'
    );
    if (iframe?.contentDocument) {
      unloadFontFace(iframe.contentDocument.fonts);
    }
  }
}
function getDisplaySrcFromFontFace(input) {
  if (!input) {
    return;
  }
  let src;
  if (Array.isArray(input)) {
    src = input[0];
  } else {
    src = input;
  }
  if (src.startsWith("file:.")) {
    return;
  }
  if (!isUrlEncoded(src)) {
    src = encodeURI(src);
  }
  return src;
}
function makeFontFamilyFormData(fontFamily) {
  const formData = new FormData();
  const { fontFace, category, ...familyWithValidParameters } = fontFamily;
  const fontFamilySettings = {
    ...familyWithValidParameters,
    slug: kebabCase(fontFamily.slug)
  };
  formData.append(
    "font_family_settings",
    JSON.stringify(fontFamilySettings)
  );
  return formData;
}
function makeFontFacesFormData(font2) {
  const fontFacesFormData = (font2?.fontFace ?? []).map(
    (item, faceIndex) => {
      const face = { ...item };
      const formData = new FormData();
      if (face.file) {
        const files = Array.isArray(face.file) ? face.file : [face.file];
        const src = [];
        files.forEach((file, key) => {
          const fileId = `file-${faceIndex}-${key}`;
          formData.append(fileId, file, file.name);
          src.push(fileId);
        });
        face.src = src.length === 1 ? src[0] : src;
        delete face.file;
        formData.append("font_face_settings", JSON.stringify(face));
      } else {
        formData.append("font_face_settings", JSON.stringify(face));
      }
      return formData;
    }
  );
  return fontFacesFormData;
}
async function batchInstallFontFaces(fontFamilyId, fontFacesData, registry) {
  const responses = [];
  for (const faceData of fontFacesData) {
    try {
      const response = await fetchInstallFontFace(
        fontFamilyId,
        faceData,
        registry
      );
      responses.push({ status: "fulfilled", value: response });
    } catch (error) {
      responses.push({ status: "rejected", reason: error });
    }
  }
  const results = {
    errors: [],
    successes: []
  };
  responses.forEach((result, index2) => {
    if (result.status === "fulfilled" && result.value) {
      const response = result.value;
      results.successes.push(response);
    } else if (result.reason) {
      results.errors.push({
        data: fontFacesData[index2],
        message: result.reason.message
      });
    }
  });
  return results;
}
async function downloadFontFaceAssets(src) {
  src = Array.isArray(src) ? src : [src];
  const files = await Promise.all(
    src.map(async (url) => {
      return fetch(new Request(url)).then((response) => {
        if (!response.ok) {
          throw new Error(
            `Error downloading font face asset from ${url}. Server responded with status: ${response.status}`
          );
        }
        return response.blob();
      }).then((blob) => {
        const filename = url.split("/").pop();
        const file = new File([blob], filename, {
          type: blob.type
        });
        return file;
      });
    })
  );
  return files.length === 1 ? files[0] : files;
}
function checkFontFaceInstalled(fontFace, collection) {
  return -1 !== collection.findIndex((collectionFontFace) => {
    return collectionFontFace.fontWeight === fontFace.fontWeight && collectionFontFace.fontStyle === fontFace.fontStyle;
  });
}

// packages/global-styles-ui/build-module/font-library/utils/set-immutably.mjs
function setImmutably2(object, path, value) {
  path = Array.isArray(path) ? [...path] : [path];
  object = Array.isArray(object) ? [...object] : { ...object };
  const leaf = path.pop();
  let prev = object;
  for (const key of path) {
    const lvl = prev[key];
    prev = prev[key] = Array.isArray(lvl) ? [...lvl] : { ...lvl };
  }
  prev[leaf] = value;
  return object;
}

// packages/global-styles-ui/build-module/font-library/utils/toggleFont.mjs
function toggleFont(font2, face, initialfonts = []) {
  const isFontActivated = (f2) => f2.slug === font2.slug;
  const getActivatedFont = (fonts) => fonts.find(isFontActivated);
  const toggleEntireFontFamily = (activatedFont2) => {
    if (!activatedFont2) {
      return [...initialfonts, font2];
    }
    return initialfonts.filter(
      (f2) => !isFontActivated(f2)
    );
  };
  const toggleFontVariant = (activatedFont2) => {
    const isFaceActivated = (f2) => f2.fontWeight === face.fontWeight && f2.fontStyle === face.fontStyle;
    if (!activatedFont2) {
      return [...initialfonts, { ...font2, fontFace: [face] }];
    }
    let newFontFaces = activatedFont2.fontFace || [];
    if (newFontFaces.find(isFaceActivated)) {
      newFontFaces = newFontFaces.filter(
        (f2) => !isFaceActivated(f2)
      );
    } else {
      newFontFaces = [...newFontFaces, face];
    }
    if (newFontFaces.length === 0) {
      return initialfonts.filter(
        (f2) => !isFontActivated(f2)
      );
    }
    return initialfonts.map(
      (f2) => isFontActivated(f2) ? { ...f2, fontFace: newFontFaces } : f2
    );
  };
  const activatedFont = getActivatedFont(initialfonts);
  if (!face) {
    return toggleEntireFontFamily(activatedFont);
  }
  return toggleFontVariant(activatedFont);
}

// packages/global-styles-ui/build-module/font-library/context.mjs
var import_jsx_runtime45 = __toESM(require_jsx_runtime(), 1);
var FontLibraryContext = (0, import_element29.createContext)(
  {}
);
FontLibraryContext.displayName = "FontLibraryContext";
function FontLibraryProvider({ children }) {
  const registry = (0, import_data6.useRegistry)();
  const { saveEntityRecord, deleteEntityRecord } = (0, import_data6.useDispatch)(import_core_data5.store);
  const { globalStylesId } = (0, import_data6.useSelect)((select) => {
    const { __experimentalGetCurrentGlobalStylesId } = select(import_core_data5.store);
    return { globalStylesId: __experimentalGetCurrentGlobalStylesId() };
  }, []);
  const globalStyles = (0, import_core_data5.useEntityRecord)(
    "root",
    "globalStyles",
    globalStylesId
  );
  const [isInstalling, setIsInstalling] = (0, import_element29.useState)(false);
  const { records: libraryPosts = [], isResolving: isResolvingLibrary } = (0, import_core_data5.useEntityRecords)(
    "postType",
    "wp_font_family",
    {
      _embed: true
    }
  );
  const libraryFonts = (libraryPosts || []).map((fontFamilyPost) => {
    return {
      id: fontFamilyPost.id,
      ...fontFamilyPost.font_family_settings || {},
      fontFace: fontFamilyPost?._embedded?.font_faces?.map(
        (face) => face.font_face_settings
      ) || []
    };
  }) || [];
  const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
  const saveFontFamilies = async (fonts) => {
    if (!globalStyles.record) {
      return;
    }
    const updatedGlobalStyles = globalStyles.record;
    const finalGlobalStyles = setImmutably2(
      updatedGlobalStyles ?? {},
      ["settings", "typography", "fontFamilies"],
      fonts
    );
    await saveEntityRecord("root", "globalStyles", finalGlobalStyles);
  };
  const [modalTabOpen, setModalTabOpen] = (0, import_element29.useState)("");
  const [libraryFontSelected, setLibraryFontSelected] = (0, import_element29.useState)(void 0);
  const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f2) => setUIValuesNeeded(f2, { source: "theme" })).sort((a2, b2) => a2.name.localeCompare(b2.name)) : [];
  const customFonts = fontFamilies?.custom ? fontFamilies.custom.map((f2) => setUIValuesNeeded(f2, { source: "custom" })).sort((a2, b2) => a2.name.localeCompare(b2.name)) : [];
  const baseCustomFonts = libraryFonts ? libraryFonts.map((f2) => setUIValuesNeeded(f2, { source: "custom" })).sort((a2, b2) => a2.name.localeCompare(b2.name)) : [];
  (0, import_element29.useEffect)(() => {
    if (!modalTabOpen) {
      setLibraryFontSelected(void 0);
    }
  }, [modalTabOpen]);
  const handleSetLibraryFontSelected = (font2) => {
    if (!font2) {
      setLibraryFontSelected(void 0);
      return;
    }
    const fonts = font2.source === "theme" ? themeFonts : baseCustomFonts;
    const fontSelected = fonts.find((f2) => f2.slug === font2.slug);
    setLibraryFontSelected({
      ...fontSelected || font2,
      source: font2.source
    });
  };
  const [loadedFontUrls] = (0, import_element29.useState)(/* @__PURE__ */ new Set());
  const getAvailableFontsOutline = (availableFontFamilies) => {
    const outline = availableFontFamilies.reduce(
      (acc, font2) => {
        const availableFontFaces = font2?.fontFace && font2.fontFace?.length > 0 ? font2?.fontFace.map(
          (face) => `${face.fontStyle ?? ""}${face.fontWeight ?? ""}`
        ) : ["normal400"];
        acc[font2.slug] = availableFontFaces;
        return acc;
      },
      {}
    );
    return outline;
  };
  const getActivatedFontsOutline = (source) => {
    switch (source) {
      case "theme":
        return getAvailableFontsOutline(themeFonts);
      case "custom":
      default:
        return getAvailableFontsOutline(customFonts);
    }
  };
  const isFontActivated = (slug, style, weight, source) => {
    if (!style && !weight) {
      return !!getActivatedFontsOutline(source)[slug];
    }
    return !!getActivatedFontsOutline(source)[slug]?.includes(
      (style ?? "") + (weight ?? "")
    );
  };
  const getFontFacesActivated = (slug, source) => {
    return getActivatedFontsOutline(source)[slug] || [];
  };
  async function installFonts(fontFamiliesToInstall) {
    setIsInstalling(true);
    try {
      const fontFamiliesToActivate = [];
      let installationErrors = [];
      for (const fontFamilyToInstall of fontFamiliesToInstall) {
        let isANewFontFamily = false;
        const fontFamilyRecords = await (0, import_data6.resolveSelect)(
          import_core_data5.store
        ).getEntityRecords(
          "postType",
          "wp_font_family",
          {
            slug: fontFamilyToInstall.slug,
            per_page: 1,
            _embed: true
          }
        );
        const fontFamilyPost = fontFamilyRecords && fontFamilyRecords.length > 0 ? fontFamilyRecords[0] : null;
        let installedFontFamily = fontFamilyPost ? {
          id: fontFamilyPost.id,
          ...fontFamilyPost.font_family_settings,
          fontFace: (fontFamilyPost?._embedded?.font_faces ?? []).map(
            (face) => face.font_face_settings
          ) || []
        } : null;
        if (!installedFontFamily) {
          isANewFontFamily = true;
          installedFontFamily = await fetchInstallFontFamily(
            makeFontFamilyFormData(fontFamilyToInstall),
            registry
          );
        }
        const alreadyInstalledFontFaces = installedFontFamily.fontFace && fontFamilyToInstall.fontFace ? installedFontFamily.fontFace.filter(
          (fontFaceToInstall) => fontFaceToInstall && fontFamilyToInstall.fontFace && checkFontFaceInstalled(
            fontFaceToInstall,
            fontFamilyToInstall.fontFace
          )
        ) : [];
        if (installedFontFamily.fontFace && fontFamilyToInstall.fontFace) {
          fontFamilyToInstall.fontFace = fontFamilyToInstall.fontFace.filter(
            (fontFaceToInstall) => !checkFontFaceInstalled(
              fontFaceToInstall,
              installedFontFamily.fontFace
            )
          );
        }
        let successfullyInstalledFontFaces = [];
        let unsuccessfullyInstalledFontFaces = [];
        if (fontFamilyToInstall?.fontFace?.length ?? 0 > 0) {
          const response = await batchInstallFontFaces(
            // @ts-expect-error - Type mismatch: WpFontFamily.id can be number | string, but batchInstallFontFaces expects only string.
            installedFontFamily.id,
            makeFontFacesFormData(
              fontFamilyToInstall
            ),
            registry
          );
          successfullyInstalledFontFaces = response?.successes;
          unsuccessfullyInstalledFontFaces = response?.errors;
        }
        if (successfullyInstalledFontFaces?.length > 0 || alreadyInstalledFontFaces?.length > 0) {
          installedFontFamily.fontFace = [
            ...successfullyInstalledFontFaces
          ];
          fontFamiliesToActivate.push(installedFontFamily);
        }
        if (installedFontFamily && !fontFamilyToInstall?.fontFace?.length) {
          fontFamiliesToActivate.push(installedFontFamily);
        }
        if (isANewFontFamily && (fontFamilyToInstall?.fontFace?.length ?? 0) > 0 && successfullyInstalledFontFaces?.length === 0) {
          await deleteEntityRecord(
            "postType",
            "wp_font_family",
            installedFontFamily.id,
            { force: true }
          );
        }
        installationErrors = installationErrors.concat(
          unsuccessfullyInstalledFontFaces
        );
      }
      const installationErrorMessages = installationErrors.reduce(
        (unique, item) => unique.includes(item.message) ? unique : [...unique, item.message],
        []
      );
      if (fontFamiliesToActivate.length > 0) {
        const activeFonts = activateCustomFontFamilies(
          // @ts-expect-error - Type mismatch: items may have id as number | string, but FontFamily.id should be string | undefined.
          fontFamiliesToActivate
        );
        await saveFontFamilies(activeFonts);
      }
      if (installationErrorMessages.length > 0) {
        const installError = new Error((0, import_i18n12.__)("There was an error installing fonts."));
        installError.installationErrors = installationErrorMessages;
        throw installError;
      }
    } finally {
      setIsInstalling(false);
    }
  }
  async function uninstallFontFamily(fontFamilyToUninstall) {
    if (!fontFamilyToUninstall?.id) {
      throw new Error((0, import_i18n12.__)("Font family to uninstall is not defined."));
    }
    try {
      await deleteEntityRecord(
        "postType",
        "wp_font_family",
        fontFamilyToUninstall.id,
        { force: true }
      );
      const activeFonts = deactivateFontFamily(fontFamilyToUninstall);
      await saveFontFamilies(activeFonts);
      return { deleted: true };
    } catch (error) {
      console.error(
        `There was an error uninstalling the font family:`,
        error
      );
      throw error;
    }
  }
  const deactivateFontFamily = (font2) => {
    const initialCustomFonts = fontFamilies?.[font2.source ?? ""] ?? [];
    const newCustomFonts = initialCustomFonts.filter(
      (f2) => f2.slug !== font2.slug
    );
    const activeFonts = {
      ...fontFamilies,
      [font2.source ?? ""]: newCustomFonts
    };
    setFontFamilies(activeFonts);
    if (font2.fontFace) {
      font2.fontFace.forEach((face) => {
        unloadFontFaceInBrowser(face, "all");
      });
    }
    return activeFonts;
  };
  const activateCustomFontFamilies = (fontsToAdd) => {
    const fontsToActivate = cleanFontsForSave(fontsToAdd);
    const activeFonts = {
      ...fontFamilies,
      // Merge the existing custom fonts with the new fonts.
      custom: mergeFontFamilies(fontFamilies?.custom, fontsToActivate)
    };
    setFontFamilies(activeFonts);
    loadFontsInBrowser(fontsToActivate);
    return activeFonts;
  };
  const cleanFontsForSave = (fonts) => {
    return fonts.map(({ id: _familyDbId, fontFace, ...font2 }) => ({
      ...font2,
      ...fontFace && fontFace.length > 0 ? {
        fontFace: fontFace.map(
          ({ id: _faceDbId, ...face }) => face
        )
      } : {}
    }));
  };
  const loadFontsInBrowser = (fonts) => {
    fonts.forEach((font2) => {
      if (font2.fontFace) {
        font2.fontFace.forEach((face) => {
          const displaySrc = getDisplaySrcFromFontFace(
            face?.src ?? ""
          );
          if (displaySrc) {
            loadFontFaceInBrowser(face, displaySrc, "all");
          }
        });
      }
    });
  };
  const toggleActivateFont = (font2, face) => {
    const initialFonts = fontFamilies?.[font2.source ?? ""] ?? [];
    const newFonts = toggleFont(font2, face, initialFonts);
    setFontFamilies({
      ...fontFamilies,
      [font2.source ?? ""]: newFonts
    });
    const isFaceActivated = isFontActivated(
      font2.slug,
      face?.fontStyle ?? "",
      face?.fontWeight ?? "",
      font2.source ?? "custom"
    );
    if (face && isFaceActivated) {
      unloadFontFaceInBrowser(face, "all");
    } else {
      const displaySrc = getDisplaySrcFromFontFace(face?.src ?? "");
      if (face && displaySrc) {
        loadFontFaceInBrowser(face, displaySrc, "all");
      }
    }
  };
  const loadFontFaceAsset = async (fontFace) => {
    if (!fontFace.src) {
      return;
    }
    const src = getDisplaySrcFromFontFace(fontFace.src);
    if (!src || loadedFontUrls.has(src)) {
      return;
    }
    loadFontFaceInBrowser(fontFace, src, "document");
    loadedFontUrls.add(src);
  };
  return /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
    FontLibraryContext.Provider,
    {
      value: {
        libraryFontSelected,
        handleSetLibraryFontSelected,
        fontFamilies: fontFamilies ?? {},
        baseCustomFonts,
        isFontActivated,
        getFontFacesActivated,
        loadFontFaceAsset,
        installFonts,
        uninstallFontFamily,
        toggleActivateFont,
        getAvailableFontsOutline,
        modalTabOpen,
        setModalTabOpen,
        saveFontFamilies,
        isResolvingLibrary,
        isInstalling
      },
      children
    }
  );
}
var context_default = FontLibraryProvider;

// packages/global-styles-ui/build-module/font-library/modal.mjs
var import_i18n18 = __toESM(require_i18n(), 1);
var import_components29 = __toESM(require_components(), 1);
var import_core_data8 = __toESM(require_core_data(), 1);
var import_data8 = __toESM(require_data(), 1);

// packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
var import_components23 = __toESM(require_components(), 1);
var import_core_data6 = __toESM(require_core_data(), 1);
var import_data7 = __toESM(require_data(), 1);
var import_element33 = __toESM(require_element(), 1);
var import_i18n14 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/font-library/font-card.mjs
var import_i18n13 = __toESM(require_i18n(), 1);
var import_element31 = __toESM(require_element(), 1);
var import_components21 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/font-library/font-demo.mjs
var import_components20 = __toESM(require_components(), 1);
var import_element30 = __toESM(require_element(), 1);
var import_jsx_runtime46 = __toESM(require_jsx_runtime(), 1);
function getPreviewUrl(fontFace) {
  if (fontFace.preview) {
    return fontFace.preview;
  }
  if (fontFace.src) {
    return Array.isArray(fontFace.src) ? fontFace.src[0] : fontFace.src;
  }
  return void 0;
}
function getDisplayFontFace(font2) {
  if ("fontStyle" in font2 && font2.fontStyle || "fontWeight" in font2 && font2.fontWeight) {
    return font2;
  }
  if ("fontFace" in font2 && font2.fontFace && font2.fontFace.length) {
    return font2.fontFace.find(
      (face) => face.fontStyle === "normal" && face.fontWeight === "400"
    ) || font2.fontFace[0];
  }
  return {
    fontStyle: "normal",
    fontWeight: "400",
    fontFamily: font2.fontFamily
  };
}
function FontDemo({ font: font2, text }) {
  const ref = (0, import_element30.useRef)(null);
  const fontFace = getDisplayFontFace(font2);
  const style = getFamilyPreviewStyle(font2);
  text = text || ("name" in font2 ? font2.name : "");
  const customPreviewUrl = font2.preview;
  const [isIntersecting, setIsIntersecting] = (0, import_element30.useState)(false);
  const [isAssetLoaded, setIsAssetLoaded] = (0, import_element30.useState)(false);
  const { loadFontFaceAsset } = (0, import_element30.useContext)(FontLibraryContext);
  const previewUrl = customPreviewUrl ?? getPreviewUrl(fontFace);
  const isPreviewImage = previewUrl && previewUrl.match(/\.(png|jpg|jpeg|gif|svg)$/i);
  const faceStyles = getFacePreviewStyle(fontFace);
  const textDemoStyle = {
    fontSize: "18px",
    lineHeight: 1,
    opacity: isAssetLoaded ? "1" : "0",
    ...style,
    ...faceStyles
  };
  (0, import_element30.useEffect)(() => {
    const observer = new window.IntersectionObserver(([entry]) => {
      setIsIntersecting(entry.isIntersecting);
    }, {});
    if (ref.current) {
      observer.observe(ref.current);
    }
    return () => observer.disconnect();
  }, [ref]);
  (0, import_element30.useEffect)(() => {
    const loadAsset = async () => {
      if (isIntersecting) {
        if (!isPreviewImage && fontFace.src) {
          await loadFontFaceAsset(fontFace);
        }
        setIsAssetLoaded(true);
      }
    };
    loadAsset();
  }, [fontFace, isIntersecting, loadFontFaceAsset, isPreviewImage]);
  return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { ref, children: isPreviewImage ? /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
    "img",
    {
      src: previewUrl,
      loading: "lazy",
      alt: text,
      className: "font-library__font-variant_demo-image"
    }
  ) : /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
    import_components20.__experimentalText,
    {
      style: textDemoStyle,
      className: "font-library__font-variant_demo-text",
      children: text
    }
  ) });
}
var font_demo_default = FontDemo;

// packages/global-styles-ui/build-module/font-library/font-card.mjs
var import_jsx_runtime47 = __toESM(require_jsx_runtime(), 1);
function FontCard({
  font: font2,
  onClick,
  variantsText,
  navigatorPath,
  shouldFocus
}) {
  const variantsCount = font2.fontFace?.length || 1;
  const style = {
    cursor: !!onClick ? "pointer" : "default"
  };
  const navigator2 = (0, import_components21.useNavigator)();
  const ref = (0, import_element31.useRef)(null);
  (0, import_element31.useEffect)(() => {
    if (shouldFocus) {
      ref.current?.focus();
    }
  }, [shouldFocus]);
  return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(
    import_components21.Button,
    {
      ref,
      __next40pxDefaultSize: true,
      onClick: () => {
        onClick();
        if (navigatorPath) {
          navigator2.goTo(navigatorPath);
        }
      },
      style,
      className: "font-library__font-card",
      children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_components21.Flex, { justify: "space-between", wrap: false, children: [
        /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(font_demo_default, { font: font2 }),
        /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(import_components21.Flex, { justify: "flex-end", children: [
          /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components21.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components21.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, import_i18n13.sprintf)(
            /* translators: %d: Number of font variants. */
            (0, import_i18n13._n)(
              "%d variant",
              "%d variants",
              variantsCount
            ),
            variantsCount
          ) }) }),
          /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(import_components21.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(icon_default, { icon: (0, import_i18n13.isRTL)() ? chevron_left_default : chevron_right_default }) })
        ] })
      ] })
    }
  );
}
var font_card_default = FontCard;

// packages/global-styles-ui/build-module/font-library/library-font-variant.mjs
var import_element32 = __toESM(require_element(), 1);
var import_components22 = __toESM(require_components(), 1);
var import_jsx_runtime48 = __toESM(require_jsx_runtime(), 1);
function LibraryFontVariant({
  face,
  font: font2
}) {
  const { isFontActivated, toggleActivateFont } = (0, import_element32.useContext)(FontLibraryContext);
  const isInstalled = (font2?.fontFace?.length ?? 0) > 0 ? isFontActivated(
    font2.slug,
    face.fontStyle,
    face.fontWeight,
    font2.source
  ) : isFontActivated(font2.slug, void 0, void 0, font2.source);
  const handleToggleActivation = () => {
    if ((font2?.fontFace?.length ?? 0) > 0) {
      toggleActivateFont(font2, face);
      return;
    }
    toggleActivateFont(font2);
  };
  const displayName = font2.name + " " + getFontFaceVariantName(face);
  const checkboxId = (0, import_element32.useId)();
  return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)(import_components22.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
    /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
      import_components22.CheckboxControl,
      {
        checked: isInstalled,
        onChange: handleToggleActivation,
        id: checkboxId
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime48.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
      font_demo_default,
      {
        font: face,
        text: displayName,
        onClick: handleToggleActivation
      }
    ) })
  ] }) });
}
var library_font_variant_default = LibraryFontVariant;

// packages/global-styles-ui/build-module/font-library/utils/sort-font-faces.mjs
function getNumericFontWeight(value) {
  switch (value) {
    case "normal":
      return 400;
    case "bold":
      return 700;
    case "bolder":
      return 500;
    case "lighter":
      return 300;
    default:
      return parseInt(value, 10);
  }
}
function sortFontFaces(faces) {
  return faces.sort((a2, b2) => {
    if (a2.fontStyle === "normal" && b2.fontStyle !== "normal") {
      return -1;
    }
    if (b2.fontStyle === "normal" && a2.fontStyle !== "normal") {
      return 1;
    }
    if (a2.fontStyle === b2.fontStyle) {
      return getNumericFontWeight(a2.fontWeight?.toString() ?? "normal") - getNumericFontWeight(b2.fontWeight?.toString() ?? "normal");
    }
    if (!a2.fontStyle || !b2.fontStyle) {
      return !a2.fontStyle ? 1 : -1;
    }
    return a2.fontStyle.localeCompare(b2.fontStyle);
  });
}

// packages/global-styles-ui/build-module/font-library/installed-fonts.mjs
var import_jsx_runtime49 = __toESM(require_jsx_runtime(), 1);
function getFontFamiliesKey(fontFamilies) {
  if (!fontFamilies) {
    return "";
  }
  const normalized = {};
  for (const source of Object.keys(fontFamilies).sort()) {
    normalized[source] = (fontFamilies[source] ?? []).map((family) => ({
      slug: family.slug,
      fontFace: (family.fontFace ?? []).map(
        (face) => `${face.fontStyle}-${face.fontWeight}`
      ).sort()
    })).sort((a2, b2) => a2.slug.localeCompare(b2.slug));
  }
  return JSON.stringify(normalized);
}
function InstalledFonts() {
  const {
    baseCustomFonts,
    libraryFontSelected,
    handleSetLibraryFontSelected,
    uninstallFontFamily,
    isResolvingLibrary,
    isInstalling,
    saveFontFamilies,
    getFontFacesActivated
  } = (0, import_element33.useContext)(FontLibraryContext);
  const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
  const [lastSelectedFontSlug, setLastSelectedFontSlug] = (0, import_element33.useState)(void 0);
  const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0, import_element33.useState)(false);
  const [notice, setNotice] = (0, import_element33.useState)(null);
  const [baseFontFamilies] = useSetting("typography.fontFamilies", void 0, "base");
  const globalStylesId = (0, import_data7.useSelect)((select) => {
    const { __experimentalGetCurrentGlobalStylesId } = select(import_core_data6.store);
    return __experimentalGetCurrentGlobalStylesId();
  }, []);
  const globalStyles = (0, import_core_data6.useEntityRecord)(
    "root",
    "globalStyles",
    globalStylesId
  );
  const editedFontFamilies = globalStyles?.edits?.settings?.typography?.fontFamilies;
  const savedFontFamilies = globalStyles?.record?.settings?.typography?.fontFamilies;
  const fontFamiliesHasChanges = (0, import_element33.useMemo)(() => {
    if (editedFontFamilies === void 0) {
      return false;
    }
    return getFontFamiliesKey(editedFontFamilies) !== getFontFamiliesKey(savedFontFamilies);
  }, [editedFontFamilies, savedFontFamilies]);
  const themeFonts = fontFamilies?.theme ? fontFamilies.theme.map((f2) => setUIValuesNeeded(f2, { source: "theme" })).sort((a2, b2) => a2.name.localeCompare(b2.name)) : [];
  const themeFontsSlugs = new Set(themeFonts.map((f2) => f2.slug));
  const baseThemeFonts = baseFontFamilies?.theme ? themeFonts.concat(
    baseFontFamilies.theme.filter((f2) => !themeFontsSlugs.has(f2.slug)).map((f2) => setUIValuesNeeded(f2, { source: "theme" })).sort((a2, b2) => a2.name.localeCompare(b2.name))
  ) : [];
  const customFontFamilyId = libraryFontSelected?.source === "custom" && libraryFontSelected?.id;
  const canUserDelete = (0, import_data7.useSelect)(
    (select) => {
      const { canUser } = select(import_core_data6.store);
      return customFontFamilyId && canUser("delete", {
        kind: "postType",
        name: "wp_font_family",
        id: customFontFamilyId
      });
    },
    [customFontFamilyId]
  );
  const shouldDisplayDeleteButton = !!libraryFontSelected && libraryFontSelected?.source !== "theme" && canUserDelete;
  const handleUninstallClick = () => {
    setIsConfirmDeleteOpen(true);
  };
  const handleUpdate = async () => {
    setNotice(null);
    try {
      await saveFontFamilies(fontFamilies);
      setNotice({
        type: "success",
        message: (0, import_i18n14.__)("Font family updated successfully.")
      });
    } catch (error) {
      setNotice({
        type: "error",
        message: (0, import_i18n14.sprintf)(
          /* translators: %s: error message */
          (0, import_i18n14.__)("There was an error updating the font family. %s"),
          error.message
        )
      });
    }
  };
  const getFontFacesToDisplay = (font2) => {
    if (!font2) {
      return [];
    }
    if (!font2.fontFace || !font2.fontFace.length) {
      return [
        {
          fontFamily: font2.fontFamily,
          fontStyle: "normal",
          fontWeight: "400"
        }
      ];
    }
    return sortFontFaces(font2.fontFace);
  };
  const getFontCardVariantsText = (font2) => {
    const variantsInstalled = font2?.fontFace && (font2?.fontFace?.length ?? 0) > 0 ? font2.fontFace.length : 1;
    const variantsActive = getFontFacesActivated(
      font2.slug,
      font2.source
    ).length;
    return (0, import_i18n14.sprintf)(
      /* translators: 1: Active font variants, 2: Total font variants. */
      (0, import_i18n14.__)("%1$d of %2$d active"),
      variantsActive,
      variantsInstalled
    );
  };
  (0, import_element33.useEffect)(() => {
    handleSetLibraryFontSelected(libraryFontSelected);
  }, []);
  const activeFontsCount = libraryFontSelected ? getFontFacesActivated(
    libraryFontSelected.slug,
    libraryFontSelected.source
  ).length : 0;
  const selectedFontsCount = libraryFontSelected?.fontFace?.length ?? (libraryFontSelected?.fontFamily ? 1 : 0);
  const isIndeterminate = activeFontsCount > 0 && activeFontsCount !== selectedFontsCount;
  const isSelectAllChecked = activeFontsCount === selectedFontsCount;
  const toggleSelectAll = () => {
    if (!libraryFontSelected || !libraryFontSelected?.source) {
      return;
    }
    const initialFonts = fontFamilies?.[libraryFontSelected.source]?.filter(
      (f2) => f2.slug !== libraryFontSelected.slug
    ) ?? [];
    const newFonts = isSelectAllChecked ? initialFonts : [...initialFonts, libraryFontSelected];
    setFontFamilies({
      ...fontFamilies,
      [libraryFontSelected.source]: newFonts
    });
    if (libraryFontSelected.fontFace) {
      libraryFontSelected.fontFace.forEach((face) => {
        if (isSelectAllChecked) {
          unloadFontFaceInBrowser(face, "all");
        } else {
          const displaySrc = getDisplaySrcFromFontFace(
            face?.src ?? ""
          );
          if (displaySrc) {
            loadFontFaceInBrowser(face, displaySrc, "all");
          }
        }
      });
    }
  };
  const hasFonts = baseThemeFonts.length > 0 || baseCustomFonts.length > 0;
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.ProgressBar, {}) }),
    !isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(
        import_components23.Navigator,
        {
          initialPath: libraryFontSelected ? "/fontFamily" : "/",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.__experimentalVStack, { spacing: "8", children: [
              notice && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                import_components23.Notice,
                {
                  status: notice.type,
                  onRemove: () => setNotice(null),
                  children: notice.message
                }
              ),
              !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalText, { as: "p", children: (0, import_i18n14.__)("No fonts installed.") }),
              baseThemeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.__experimentalVStack, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h2", {
                  className: "font-library__fonts-title",
                  /* translators: Heading for a list of fonts provided by the theme. */
                  children: (0, import_i18n14._x)("Theme", "font source")
                }),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: baseThemeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                          font_card_default,
                          {
                            font: font2,
                            navigatorPath: "/fontFamily",
                            variantsText: getFontCardVariantsText(
                              font2
                            ),
                            shouldFocus: font2.slug === lastSelectedFontSlug,
                            onClick: () => {
                              setNotice(null);
                              handleSetLibraryFontSelected(
                                font2
                              );
                            }
                          }
                        )
                      },
                      font2.slug
                    ))
                  }
                )
              ] }),
              baseCustomFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.__experimentalVStack, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)("h2", {
                  className: "font-library__fonts-title",
                  /* translators: Heading for a list of fonts installed by the user. */
                  children: (0, import_i18n14._x)("Custom", "font source")
                }),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: baseCustomFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                          font_card_default,
                          {
                            font: font2,
                            navigatorPath: "/fontFamily",
                            variantsText: getFontCardVariantsText(
                              font2
                            ),
                            shouldFocus: font2.slug === lastSelectedFontSlug,
                            onClick: () => {
                              setNotice(null);
                              handleSetLibraryFontSelected(
                                font2
                              );
                            }
                          }
                        )
                      },
                      font2.slug
                    ))
                  }
                )
              ] })
            ] }) }),
            /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.Navigator.Screen, { path: "/fontFamily", children: [
              libraryFontSelected && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                ConfirmDeleteDialog,
                {
                  font: libraryFontSelected,
                  isOpen: isConfirmDeleteOpen,
                  setIsOpen: setIsConfirmDeleteOpen,
                  setNotice,
                  uninstallFontFamily,
                  handleSetLibraryFontSelected
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.Flex, { justify: "flex-start", children: [
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  import_components23.Navigator.BackButton,
                  {
                    icon: (0, import_i18n14.isRTL)() ? chevron_right_default : chevron_left_default,
                    size: "small",
                    onClick: () => {
                      setLastSelectedFontSlug(
                        libraryFontSelected?.slug
                      );
                      handleSetLibraryFontSelected(
                        void 0
                      );
                      setNotice(null);
                    },
                    label: (0, import_i18n14.__)("Back")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  import_components23.__experimentalHeading,
                  {
                    level: 2,
                    size: 13,
                    className: "global-styles-ui-header",
                    children: libraryFontSelected?.name
                  }
                )
              ] }),
              notice && /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_jsx_runtime49.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalSpacer, { margin: 1 }),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  import_components23.Notice,
                  {
                    status: notice.type,
                    onRemove: () => setNotice(null),
                    children: notice.message
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalSpacer, { margin: 1 })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalText, { children: (0, import_i18n14.__)(
                "Choose font variants. Keep in mind that too many variants could make your site slower."
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.__experimentalVStack, { spacing: 0, children: [
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  import_components23.CheckboxControl,
                  {
                    className: "font-library__select-all",
                    label: (0, import_i18n14.__)("Select all"),
                    checked: isSelectAllChecked,
                    onChange: toggleSelectAll,
                    indeterminate: isIndeterminate
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.__experimentalSpacer, { margin: 8 }),
                /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: libraryFontSelected && getFontFacesToDisplay(
                      libraryFontSelected
                    ).map((face, i2) => /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
                          library_font_variant_default,
                          {
                            font: libraryFontSelected,
                            face
                          },
                          `face${i2}`
                        )
                      },
                      `face${i2}`
                    ))
                  }
                )
              ] })
            ] })
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime49.jsxs)(import_components23.__experimentalHStack, { justify: "flex-end", className: "font-library__footer", children: [
        isInstalling && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(import_components23.ProgressBar, {}),
        shouldDisplayDeleteButton && /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
          import_components23.Button,
          {
            __next40pxDefaultSize: true,
            isDestructive: true,
            variant: "tertiary",
            onClick: handleUninstallClick,
            children: (0, import_i18n14.__)("Delete")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
          import_components23.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            onClick: handleUpdate,
            disabled: !fontFamiliesHasChanges,
            accessibleWhenDisabled: true,
            children: (0, import_i18n14.__)("Update")
          }
        )
      ] })
    ] })
  ] });
}
function ConfirmDeleteDialog({
  font: font2,
  isOpen,
  setIsOpen,
  setNotice,
  uninstallFontFamily,
  handleSetLibraryFontSelected
}) {
  const navigator2 = (0, import_components23.useNavigator)();
  const handleConfirmUninstall = async () => {
    setNotice(null);
    setIsOpen(false);
    try {
      await uninstallFontFamily(font2);
      navigator2.goBack();
      handleSetLibraryFontSelected(void 0);
      setNotice({
        type: "success",
        message: (0, import_i18n14.__)("Font family uninstalled successfully.")
      });
    } catch (error) {
      setNotice({
        type: "error",
        message: (0, import_i18n14.__)("There was an error uninstalling the font family.") + error.message
      });
    }
  };
  const handleCancelUninstall = () => {
    setIsOpen(false);
  };
  return /* @__PURE__ */ (0, import_jsx_runtime49.jsx)(
    import_components23.__experimentalConfirmDialog,
    {
      isOpen,
      cancelButtonText: (0, import_i18n14.__)("Cancel"),
      confirmButtonText: (0, import_i18n14.__)("Delete"),
      onCancel: handleCancelUninstall,
      onConfirm: handleConfirmUninstall,
      size: "medium",
      children: font2 && (0, import_i18n14.sprintf)(
        /* translators: %s: Name of the font. */
        (0, import_i18n14.__)(
          'Are you sure you want to delete "%s" font and all its variants and assets?'
        ),
        font2.name
      )
    }
  );
}
var installed_fonts_default = InstalledFonts;

// packages/global-styles-ui/build-module/font-library/font-collection.mjs
var import_element35 = __toESM(require_element(), 1);
var import_components26 = __toESM(require_components(), 1);
var import_compose3 = __toESM(require_compose(), 1);
var import_i18n16 = __toESM(require_i18n(), 1);
var import_core_data7 = __toESM(require_core_data(), 1);

// packages/global-styles-ui/build-module/font-library/utils/filter-fonts.mjs
function filterFonts(fonts, filters) {
  const { category, search } = filters;
  let filteredFonts = fonts || [];
  if (category && category !== "all") {
    filteredFonts = filteredFonts.filter(
      (font2) => font2.categories && font2.categories.indexOf(category) !== -1
    );
  }
  if (search) {
    filteredFonts = filteredFonts.filter(
      (font2) => font2.font_family_settings && font2.font_family_settings.name.toLowerCase().includes(search.toLowerCase())
    );
  }
  return filteredFonts;
}

// packages/global-styles-ui/build-module/font-library/utils/fonts-outline.mjs
function getFontsOutline(fonts) {
  return fonts.reduce(
    (acc, font2) => ({
      ...acc,
      [font2.slug]: (font2?.fontFace || []).reduce(
        (faces, face) => ({
          ...faces,
          [`${face.fontStyle}-${face.fontWeight}`]: true
        }),
        {}
      )
    }),
    {}
  );
}
function isFontFontFaceInOutline(slug, face, outline) {
  if (!face) {
    return !!outline[slug];
  }
  return !!outline[slug]?.[`${face.fontStyle}-${face.fontWeight}`];
}

// packages/global-styles-ui/build-module/font-library/google-fonts-confirm-dialog.mjs
var import_i18n15 = __toESM(require_i18n(), 1);
var import_components24 = __toESM(require_components(), 1);
var import_jsx_runtime50 = __toESM(require_jsx_runtime(), 1);
function GoogleFontsConfirmDialog() {
  const handleConfirm = () => {
    window.localStorage.setItem(
      "wp-font-library-google-fonts-permission",
      "true"
    );
    window.dispatchEvent(new Event("storage"));
  };
  return /* @__PURE__ */ (0, import_jsx_runtime50.jsx)("div", { className: "font-library__google-fonts-confirm", children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime50.jsxs)(import_components24.CardBody, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalHeading, { level: 2, children: (0, import_i18n15.__)("Connect to Google Fonts") }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalSpacer, { margin: 6 }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalText, { as: "p", children: (0, import_i18n15.__)(
      "To install fonts from Google you must give permission to connect directly to Google servers. The fonts you install will be downloaded from Google and stored on your site. Your site will then use these locally-hosted fonts."
    ) }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalSpacer, { margin: 3 }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalText, { as: "p", children: (0, import_i18n15.__)(
      "You can alternatively upload files directly on the Upload tab."
    ) }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(import_components24.__experimentalSpacer, { margin: 6 }),
    /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
      import_components24.Button,
      {
        __next40pxDefaultSize: true,
        variant: "primary",
        onClick: handleConfirm,
        children: (0, import_i18n15.__)("Allow access to Google Fonts")
      }
    )
  ] }) }) });
}
var google_fonts_confirm_dialog_default = GoogleFontsConfirmDialog;

// packages/global-styles-ui/build-module/font-library/collection-font-variant.mjs
var import_element34 = __toESM(require_element(), 1);
var import_components25 = __toESM(require_components(), 1);
var import_jsx_runtime51 = __toESM(require_jsx_runtime(), 1);
function CollectionFontVariant({
  face,
  font: font2,
  handleToggleVariant,
  selected
}) {
  const handleToggleActivation = () => {
    if (font2?.fontFace) {
      handleToggleVariant(font2, face);
      return;
    }
    handleToggleVariant(font2);
  };
  const displayName = font2.name + " " + getFontFaceVariantName(face);
  const checkboxId = (0, import_element34.useId)();
  return /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime51.jsxs)(import_components25.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
    /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
      import_components25.CheckboxControl,
      {
        checked: selected,
        onChange: handleToggleActivation,
        id: checkboxId
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime51.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
      font_demo_default,
      {
        font: face,
        text: displayName,
        onClick: handleToggleActivation
      }
    ) })
  ] }) });
}
var collection_font_variant_default = CollectionFontVariant;

// packages/global-styles-ui/build-module/font-library/font-collection.mjs
var import_jsx_runtime52 = __toESM(require_jsx_runtime(), 1);
var DEFAULT_CATEGORY = {
  slug: "all",
  name: (0, import_i18n16._x)("All", "font categories")
};
var LOCAL_STORAGE_ITEM = "wp-font-library-google-fonts-permission";
var MIN_WINDOW_HEIGHT = 500;
function FontCollection({ slug }) {
  const requiresPermission = slug === "google-fonts";
  const getGoogleFontsPermissionFromStorage = () => {
    return window.localStorage.getItem(LOCAL_STORAGE_ITEM) === "true";
  };
  const [selectedFont, setSelectedFont] = (0, import_element35.useState)(
    null
  );
  const [lastSelectedFontSlug, setLastSelectedFontSlug] = (0, import_element35.useState)(void 0);
  const [notice, setNotice] = (0, import_element35.useState)(null);
  const [fontsToInstall, setFontsToInstall] = (0, import_element35.useState)(
    []
  );
  const [page, setPage] = (0, import_element35.useState)(1);
  const [filters, setFilters] = (0, import_element35.useState)({});
  const [renderConfirmDialog, setRenderConfirmDialog] = (0, import_element35.useState)(
    requiresPermission && !getGoogleFontsPermissionFromStorage()
  );
  const { installFonts, isInstalling } = (0, import_element35.useContext)(FontLibraryContext);
  const { record: selectedCollection, isResolving: isLoading } = (0, import_core_data7.useEntityRecord)("root", "fontCollection", slug);
  (0, import_element35.useEffect)(() => {
    const handleStorage = () => {
      setRenderConfirmDialog(
        requiresPermission && !getGoogleFontsPermissionFromStorage()
      );
    };
    handleStorage();
    window.addEventListener("storage", handleStorage);
    return () => window.removeEventListener("storage", handleStorage);
  }, [slug, requiresPermission]);
  const revokeAccess = () => {
    window.localStorage.setItem(LOCAL_STORAGE_ITEM, "false");
    window.dispatchEvent(new Event("storage"));
  };
  (0, import_element35.useEffect)(() => {
    setSelectedFont(null);
  }, [slug]);
  (0, import_element35.useEffect)(() => {
    setFontsToInstall([]);
  }, [selectedFont]);
  const collectionFonts = (0, import_element35.useMemo)(
    () => selectedCollection?.font_families ?? [],
    [selectedCollection]
  );
  const collectionCategories = selectedCollection?.categories ?? [];
  const categories = [DEFAULT_CATEGORY, ...collectionCategories];
  const fonts = (0, import_element35.useMemo)(
    () => filterFonts(collectionFonts, filters),
    [collectionFonts, filters]
  );
  const windowHeight = Math.max(window.innerHeight, MIN_WINDOW_HEIGHT);
  const pageSize = Math.floor((windowHeight - 417) / 61);
  const totalPages = Math.ceil(fonts.length / pageSize);
  const itemsStart = (page - 1) * pageSize;
  const itemsLimit = page * pageSize;
  const items = fonts.slice(itemsStart, itemsLimit);
  const handleCategoryFilter = (category) => {
    setFilters({ ...filters, category });
    setPage(1);
  };
  const handleUpdateSearchInput = (value) => {
    setFilters({ ...filters, search: value });
    setPage(1);
  };
  const debouncedUpdateSearchInput = (0, import_compose3.debounce)(handleUpdateSearchInput, 300);
  const handleToggleVariant = (font2, face) => {
    const newFontsToInstall = toggleFont(font2, face, fontsToInstall);
    setFontsToInstall(newFontsToInstall);
  };
  const fontToInstallOutline = getFontsOutline(fontsToInstall);
  const resetFontsToInstall = () => {
    setFontsToInstall([]);
  };
  const selectFontCount = fontsToInstall.length > 0 ? fontsToInstall[0]?.fontFace?.length ?? 0 : 0;
  const isIndeterminate = selectFontCount > 0 && selectFontCount !== selectedFont?.fontFace?.length;
  const isSelectAllChecked = selectFontCount === selectedFont?.fontFace?.length;
  const toggleSelectAll = () => {
    const newFonts = [];
    if (!isSelectAllChecked && selectedFont) {
      newFonts.push(selectedFont);
    }
    setFontsToInstall(newFonts);
  };
  const handleInstall = async () => {
    setNotice(null);
    const fontFamily = fontsToInstall[0];
    try {
      if (fontFamily?.fontFace) {
        await Promise.all(
          fontFamily.fontFace.map(async (fontFace) => {
            if (fontFace.src) {
              fontFace.file = await downloadFontFaceAssets(
                fontFace.src
              );
            }
          })
        );
      }
    } catch {
      setNotice({
        type: "error",
        message: (0, import_i18n16.__)(
          "Error installing the fonts, could not be downloaded."
        )
      });
      return;
    }
    try {
      await installFonts([fontFamily]);
      setNotice({
        type: "success",
        message: (0, import_i18n16.__)("Fonts were installed successfully.")
      });
    } catch (error) {
      setNotice({
        type: "error",
        message: error.message
      });
    }
    resetFontsToInstall();
  };
  const getSortedFontFaces = (fontFamily) => {
    if (!fontFamily) {
      return [];
    }
    if (!fontFamily.fontFace || !fontFamily.fontFace.length) {
      return [
        {
          fontFamily: fontFamily.fontFamily,
          fontStyle: "normal",
          fontWeight: "400"
        }
      ];
    }
    return sortFontFaces(fontFamily.fontFace);
  };
  if (renderConfirmDialog) {
    return /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(google_fonts_confirm_dialog_default, {});
  }
  const showActions = slug === "google-fonts" && !renderConfirmDialog && !selectedFont;
  return /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    isLoading && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.ProgressBar, {}) }),
    !isLoading && selectedCollection && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
        import_components26.Navigator,
        {
          initialPath: "/",
          className: "font-library__tabpanel-layout",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.Navigator.Screen, { path: "/", children: [
              /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.__experimentalHStack, { justify: "space-between", children: [
                /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.__experimentalVStack, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalHeading, { level: 2, size: 13, children: selectedCollection.name }),
                  /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalText, { children: selectedCollection.description })
                ] }),
                showActions && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.DropdownMenu,
                  {
                    icon: more_vertical_default,
                    label: (0, import_i18n16.__)("Actions"),
                    popoverProps: {
                      position: "bottom left"
                    },
                    controls: [
                      {
                        title: (0, import_i18n16.__)(
                          "Revoke access to Google Fonts"
                        ),
                        onClick: revokeAccess
                      }
                    ]
                  }
                )
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.__experimentalHStack, { spacing: 4, justify: "space-between", children: [
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.SearchControl,
                  {
                    value: filters.search,
                    placeholder: (0, import_i18n16.__)("Font name\u2026"),
                    label: (0, import_i18n16.__)("Search"),
                    onChange: debouncedUpdateSearchInput,
                    hideLabelFromVision: false
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.SelectControl,
                  {
                    label: (0, import_i18n16.__)("Category"),
                    value: filters.category,
                    onChange: handleCategoryFilter,
                    children: categories && categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                      "option",
                      {
                        value: category.slug,
                        children: category.name
                      },
                      category.slug
                    ))
                  }
                )
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 4 }),
              !!selectedCollection?.font_families?.length && !fonts.length && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalText, { children: (0, import_i18n16.__)(
                "No fonts found. Try with a different search term."
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { className: "font-library__fonts-grid__main", children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                "ul",
                {
                  role: "list",
                  className: "font-library__fonts-list",
                  children: items.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                    "li",
                    {
                      className: "font-library__fonts-list-item",
                      children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                        font_card_default,
                        {
                          font: font2.font_family_settings,
                          navigatorPath: "/fontFamily",
                          shouldFocus: font2.font_family_settings.slug === lastSelectedFontSlug,
                          onClick: () => {
                            setSelectedFont(
                              font2.font_family_settings
                            );
                          }
                        }
                      )
                    },
                    font2.font_family_settings.slug
                  ))
                }
              ) })
            ] }),
            /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.Navigator.Screen, { path: "/fontFamily", children: [
              /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.Flex, { justify: "flex-start", children: [
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.Navigator.BackButton,
                  {
                    icon: (0, import_i18n16.isRTL)() ? chevron_right_default : chevron_left_default,
                    size: "small",
                    onClick: () => {
                      setLastSelectedFontSlug(
                        selectedFont?.slug
                      );
                      setSelectedFont(null);
                      setNotice(null);
                    },
                    label: (0, import_i18n16.__)("Back")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.__experimentalHeading,
                  {
                    level: 2,
                    size: 13,
                    className: "global-styles-ui-header",
                    children: selectedFont?.name
                  }
                )
              ] }),
              notice && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_jsx_runtime52.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 1 }),
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                  import_components26.Notice,
                  {
                    status: notice.type,
                    onRemove: () => setNotice(null),
                    children: notice.message
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 1 })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalText, { children: (0, import_i18n16.__)("Select font variants to install.") }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                import_components26.CheckboxControl,
                {
                  className: "font-library__select-all",
                  label: (0, import_i18n16.__)("Select all"),
                  checked: isSelectAllChecked,
                  onChange: toggleSelectAll,
                  indeterminate: isIndeterminate
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                "ul",
                {
                  role: "list",
                  className: "font-library__fonts-list",
                  children: selectedFont && getSortedFontFaces(selectedFont).map(
                    (face, i2) => /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                          collection_font_variant_default,
                          {
                            font: selectedFont,
                            face,
                            handleToggleVariant,
                            selected: isFontFontFaceInOutline(
                              selectedFont.slug,
                              selectedFont.fontFace ? face : null,
                              // If the font has no fontFace, we want to check if the font is in the outline
                              fontToInstallOutline
                            )
                          }
                        )
                      },
                      `face${i2}`
                    )
                  )
                }
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(import_components26.__experimentalSpacer, { margin: 16 })
            ] })
          ]
        }
      ),
      selectedFont && /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
        import_components26.Flex,
        {
          justify: "flex-end",
          className: "font-library__footer",
          children: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
            import_components26.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              onClick: handleInstall,
              isBusy: isInstalling,
              disabled: fontsToInstall.length === 0 || isInstalling,
              accessibleWhenDisabled: true,
              children: (0, import_i18n16.__)("Install")
            }
          )
        }
      ),
      !selectedFont && /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(
        import_components26.__experimentalHStack,
        {
          expanded: false,
          className: "font-library__footer",
          justify: "end",
          spacing: 6,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
              import_components26.__experimentalHStack,
              {
                justify: "flex-start",
                expanded: false,
                spacing: 1,
                className: "font-library__page-selection",
                children: (0, import_element35.createInterpolateElement)(
                  (0, import_i18n16.sprintf)(
                    // translators: 1: Current page number, 2: Total number of pages.
                    (0, import_i18n16._x)(
                      "<div>Page</div>%1$s<div>of %2$d</div>",
                      "paging"
                    ),
                    "<CurrentPage />",
                    totalPages
                  ),
                  {
                    div: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)("div", { "aria-hidden": true }),
                    // @ts-expect-error — Tag injected via sprintf argument, not visible in format string.
                    CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                      import_components26.SelectControl,
                      {
                        "aria-label": (0, import_i18n16.__)(
                          "Current page"
                        ),
                        value: page.toString(),
                        options: [
                          ...Array(totalPages)
                        ].map((e2, i2) => {
                          return {
                            label: (i2 + 1).toString(),
                            value: (i2 + 1).toString()
                          };
                        }),
                        onChange: (newPage) => setPage(
                          parseInt(newPage)
                        ),
                        size: "small",
                        variant: "minimal"
                      }
                    )
                  }
                )
              }
            ),
            /* @__PURE__ */ (0, import_jsx_runtime52.jsxs)(import_components26.__experimentalHStack, { expanded: false, spacing: 1, children: [
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                import_components26.Button,
                {
                  onClick: () => setPage(page - 1),
                  disabled: page === 1,
                  accessibleWhenDisabled: true,
                  label: (0, import_i18n16.__)("Previous page"),
                  icon: (0, import_i18n16.isRTL)() ? next_default : previous_default,
                  showTooltip: true,
                  size: "compact",
                  tooltipPosition: "top"
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime52.jsx)(
                import_components26.Button,
                {
                  onClick: () => setPage(page + 1),
                  disabled: page === totalPages,
                  accessibleWhenDisabled: true,
                  label: (0, import_i18n16.__)("Next page"),
                  icon: (0, import_i18n16.isRTL)() ? previous_default : next_default,
                  showTooltip: true,
                  size: "compact",
                  tooltipPosition: "top"
                }
              )
            ] })
          ]
        }
      )
    ] })
  ] });
}
var font_collection_default = FontCollection;

// packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
var import_i18n17 = __toESM(require_i18n(), 1);
var import_components28 = __toESM(require_components(), 1);
var import_element36 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/font-library/lib/unbrotli.mjs
var __require2 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
  get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2]
}) : x2)(function(x2) {
  if (typeof __require !== "undefined") return __require.apply(this, arguments);
  throw Error('Dynamic require of "' + x2 + '" is not supported');
});
var unbrotli_default = (function() {
  var define, module, exports;
  return (/* @__PURE__ */ (function() {
    function r3(e2, n2, t3) {
      function o3(i22, f2) {
        if (!n2[i22]) {
          if (!e2[i22]) {
            var c2 = "function" == typeof __require2 && __require2;
            if (!f2 && c2) return c2(i22, true);
            if (u2) return u2(i22, true);
            var a2 = new Error("Cannot find module '" + i22 + "'");
            throw a2.code = "MODULE_NOT_FOUND", a2;
          }
          var p3 = n2[i22] = { exports: {} };
          e2[i22][0].call(
            p3.exports,
            function(r22) {
              var n22 = e2[i22][1][r22];
              return o3(n22 || r22);
            },
            p3,
            p3.exports,
            r3,
            e2,
            n2,
            t3
          );
        }
        return n2[i22].exports;
      }
      for (var u2 = "function" == typeof __require2 && __require2, i2 = 0; i2 < t3.length; i2++)
        o3(t3[i2]);
      return o3;
    }
    return r3;
  })())(
    {
      1: [
        function(require2, module2, exports2) {
          var BROTLI_READ_SIZE = 4096;
          var BROTLI_IBUF_SIZE = 2 * BROTLI_READ_SIZE + 32;
          var BROTLI_IBUF_MASK = 2 * BROTLI_READ_SIZE - 1;
          var kBitMask = new Uint32Array([
            0,
            1,
            3,
            7,
            15,
            31,
            63,
            127,
            255,
            511,
            1023,
            2047,
            4095,
            8191,
            16383,
            32767,
            65535,
            131071,
            262143,
            524287,
            1048575,
            2097151,
            4194303,
            8388607,
            16777215
          ]);
          function BrotliBitReader(input) {
            this.buf_ = new Uint8Array(BROTLI_IBUF_SIZE);
            this.input_ = input;
            this.reset();
          }
          BrotliBitReader.READ_SIZE = BROTLI_READ_SIZE;
          BrotliBitReader.IBUF_MASK = BROTLI_IBUF_MASK;
          BrotliBitReader.prototype.reset = function() {
            this.buf_ptr_ = 0;
            this.val_ = 0;
            this.pos_ = 0;
            this.bit_pos_ = 0;
            this.bit_end_pos_ = 0;
            this.eos_ = 0;
            this.readMoreInput();
            for (var i2 = 0; i2 < 4; i2++) {
              this.val_ |= this.buf_[this.pos_] << 8 * i2;
              ++this.pos_;
            }
            return this.bit_end_pos_ > 0;
          };
          BrotliBitReader.prototype.readMoreInput = function() {
            if (this.bit_end_pos_ > 256) {
              return;
            } else if (this.eos_) {
              if (this.bit_pos_ > this.bit_end_pos_)
                throw new Error(
                  "Unexpected end of input " + this.bit_pos_ + " " + this.bit_end_pos_
                );
            } else {
              var dst = this.buf_ptr_;
              var bytes_read = this.input_.read(
                this.buf_,
                dst,
                BROTLI_READ_SIZE
              );
              if (bytes_read < 0) {
                throw new Error("Unexpected end of input");
              }
              if (bytes_read < BROTLI_READ_SIZE) {
                this.eos_ = 1;
                for (var p3 = 0; p3 < 32; p3++)
                  this.buf_[dst + bytes_read + p3] = 0;
              }
              if (dst === 0) {
                for (var p3 = 0; p3 < 32; p3++)
                  this.buf_[(BROTLI_READ_SIZE << 1) + p3] = this.buf_[p3];
                this.buf_ptr_ = BROTLI_READ_SIZE;
              } else {
                this.buf_ptr_ = 0;
              }
              this.bit_end_pos_ += bytes_read << 3;
            }
          };
          BrotliBitReader.prototype.fillBitWindow = function() {
            while (this.bit_pos_ >= 8) {
              this.val_ >>>= 8;
              this.val_ |= this.buf_[this.pos_ & BROTLI_IBUF_MASK] << 24;
              ++this.pos_;
              this.bit_pos_ = this.bit_pos_ - 8 >>> 0;
              this.bit_end_pos_ = this.bit_end_pos_ - 8 >>> 0;
            }
          };
          BrotliBitReader.prototype.readBits = function(n_bits) {
            if (32 - this.bit_pos_ < n_bits) {
              this.fillBitWindow();
            }
            var val = this.val_ >>> this.bit_pos_ & kBitMask[n_bits];
            this.bit_pos_ += n_bits;
            return val;
          };
          module2.exports = BrotliBitReader;
        },
        {}
      ],
      2: [
        function(require2, module2, exports2) {
          var CONTEXT_LSB6 = 0;
          var CONTEXT_MSB6 = 1;
          var CONTEXT_UTF8 = 2;
          var CONTEXT_SIGNED = 3;
          exports2.lookup = new Uint8Array([
            /* CONTEXT_UTF8, last byte. */
            /* ASCII range. */
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            4,
            4,
            0,
            0,
            4,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            8,
            12,
            16,
            12,
            12,
            20,
            12,
            16,
            24,
            28,
            12,
            12,
            32,
            12,
            36,
            12,
            44,
            44,
            44,
            44,
            44,
            44,
            44,
            44,
            44,
            44,
            32,
            32,
            24,
            40,
            28,
            12,
            12,
            48,
            52,
            52,
            52,
            48,
            52,
            52,
            52,
            48,
            52,
            52,
            52,
            52,
            52,
            48,
            52,
            52,
            52,
            52,
            52,
            48,
            52,
            52,
            52,
            52,
            52,
            24,
            12,
            28,
            12,
            12,
            12,
            56,
            60,
            60,
            60,
            56,
            60,
            60,
            60,
            56,
            60,
            60,
            60,
            60,
            60,
            56,
            60,
            60,
            60,
            60,
            60,
            56,
            60,
            60,
            60,
            60,
            60,
            24,
            12,
            28,
            12,
            0,
            /* UTF8 continuation byte range. */
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            0,
            1,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            2,
            3,
            /* ASCII range. */
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            1,
            1,
            1,
            1,
            1,
            1,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            1,
            1,
            1,
            1,
            0,
            /* UTF8 continuation byte range. */
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            0,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            1,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            2,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            3,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            4,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            5,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            6,
            7,
            /* CONTEXT_SIGNED, last byte, same as the above values shifted by 3 bits. */
            0,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            8,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            24,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            32,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            40,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            48,
            56,
            /* CONTEXT_LSB6, last byte. */
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26,
            27,
            28,
            29,
            30,
            31,
            32,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42,
            43,
            44,
            45,
            46,
            47,
            48,
            49,
            50,
            51,
            52,
            53,
            54,
            55,
            56,
            57,
            58,
            59,
            60,
            61,
            62,
            63,
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26,
            27,
            28,
            29,
            30,
            31,
            32,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42,
            43,
            44,
            45,
            46,
            47,
            48,
            49,
            50,
            51,
            52,
            53,
            54,
            55,
            56,
            57,
            58,
            59,
            60,
            61,
            62,
            63,
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26,
            27,
            28,
            29,
            30,
            31,
            32,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42,
            43,
            44,
            45,
            46,
            47,
            48,
            49,
            50,
            51,
            52,
            53,
            54,
            55,
            56,
            57,
            58,
            59,
            60,
            61,
            62,
            63,
            0,
            1,
            2,
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15,
            16,
            17,
            18,
            19,
            20,
            21,
            22,
            23,
            24,
            25,
            26,
            27,
            28,
            29,
            30,
            31,
            32,
            33,
            34,
            35,
            36,
            37,
            38,
            39,
            40,
            41,
            42,
            43,
            44,
            45,
            46,
            47,
            48,
            49,
            50,
            51,
            52,
            53,
            54,
            55,
            56,
            57,
            58,
            59,
            60,
            61,
            62,
            63,
            /* CONTEXT_MSB6, last byte. */
            0,
            0,
            0,
            0,
            1,
            1,
            1,
            1,
            2,
            2,
            2,
            2,
            3,
            3,
            3,
            3,
            4,
            4,
            4,
            4,
            5,
            5,
            5,
            5,
            6,
            6,
            6,
            6,
            7,
            7,
            7,
            7,
            8,
            8,
            8,
            8,
            9,
            9,
            9,
            9,
            10,
            10,
            10,
            10,
            11,
            11,
            11,
            11,
            12,
            12,
            12,
            12,
            13,
            13,
            13,
            13,
            14,
            14,
            14,
            14,
            15,
            15,
            15,
            15,
            16,
            16,
            16,
            16,
            17,
            17,
            17,
            17,
            18,
            18,
            18,
            18,
            19,
            19,
            19,
            19,
            20,
            20,
            20,
            20,
            21,
            21,
            21,
            21,
            22,
            22,
            22,
            22,
            23,
            23,
            23,
            23,
            24,
            24,
            24,
            24,
            25,
            25,
            25,
            25,
            26,
            26,
            26,
            26,
            27,
            27,
            27,
            27,
            28,
            28,
            28,
            28,
            29,
            29,
            29,
            29,
            30,
            30,
            30,
            30,
            31,
            31,
            31,
            31,
            32,
            32,
            32,
            32,
            33,
            33,
            33,
            33,
            34,
            34,
            34,
            34,
            35,
            35,
            35,
            35,
            36,
            36,
            36,
            36,
            37,
            37,
            37,
            37,
            38,
            38,
            38,
            38,
            39,
            39,
            39,
            39,
            40,
            40,
            40,
            40,
            41,
            41,
            41,
            41,
            42,
            42,
            42,
            42,
            43,
            43,
            43,
            43,
            44,
            44,
            44,
            44,
            45,
            45,
            45,
            45,
            46,
            46,
            46,
            46,
            47,
            47,
            47,
            47,
            48,
            48,
            48,
            48,
            49,
            49,
            49,
            49,
            50,
            50,
            50,
            50,
            51,
            51,
            51,
            51,
            52,
            52,
            52,
            52,
            53,
            53,
            53,
            53,
            54,
            54,
            54,
            54,
            55,
            55,
            55,
            55,
            56,
            56,
            56,
            56,
            57,
            57,
            57,
            57,
            58,
            58,
            58,
            58,
            59,
            59,
            59,
            59,
            60,
            60,
            60,
            60,
            61,
            61,
            61,
            61,
            62,
            62,
            62,
            62,
            63,
            63,
            63,
            63,
            /* CONTEXT_{M,L}SB6, second last byte, */
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0,
            0
          ]);
          exports2.lookupOffsets = new Uint16Array([
            /* CONTEXT_LSB6 */
            1024,
            1536,
            1280,
            1536,
            0,
            256,
            768,
            512
          ]);
        },
        {}
      ],
      3: [
        function(require2, module2, exports2) {
          var BrotliInput = require2("./streams").BrotliInput;
          var BrotliOutput = require2("./streams").BrotliOutput;
          var BrotliBitReader = require2("./bit_reader");
          var BrotliDictionary = require2("./dictionary");
          var HuffmanCode = require2("./huffman").HuffmanCode;
          var BrotliBuildHuffmanTable = require2("./huffman").BrotliBuildHuffmanTable;
          var Context = require2("./context");
          var Prefix = require2("./prefix");
          var Transform = require2("./transform");
          var kDefaultCodeLength = 8;
          var kCodeLengthRepeatCode = 16;
          var kNumLiteralCodes = 256;
          var kNumInsertAndCopyCodes = 704;
          var kNumBlockLengthCodes = 26;
          var kLiteralContextBits = 6;
          var kDistanceContextBits = 2;
          var HUFFMAN_TABLE_BITS = 8;
          var HUFFMAN_TABLE_MASK = 255;
          var HUFFMAN_MAX_TABLE_SIZE = 1080;
          var CODE_LENGTH_CODES = 18;
          var kCodeLengthCodeOrder = new Uint8Array([
            1,
            2,
            3,
            4,
            0,
            5,
            17,
            6,
            16,
            7,
            8,
            9,
            10,
            11,
            12,
            13,
            14,
            15
          ]);
          var NUM_DISTANCE_SHORT_CODES = 16;
          var kDistanceShortCodeIndexOffset = new Uint8Array([
            3,
            2,
            1,
            0,
            3,
            3,
            3,
            3,
            3,
            3,
            2,
            2,
            2,
            2,
            2,
            2
          ]);
          var kDistanceShortCodeValueOffset = new Int8Array([
            0,
            0,
            0,
            0,
            -1,
            1,
            -2,
            2,
            -3,
            3,
            -1,
            1,
            -2,
            2,
            -3,
            3
          ]);
          var kMaxHuffmanTableSize = new Uint16Array([
            256,
            402,
            436,
            468,
            500,
            534,
            566,
            598,
            630,
            662,
            694,
            726,
            758,
            790,
            822,
            854,
            886,
            920,
            952,
            984,
            1016,
            1048,
            1080
          ]);
          function DecodeWindowBits(br) {
            var n2;
            if (br.readBits(1) === 0) {
              return 16;
            }
            n2 = br.readBits(3);
            if (n2 > 0) {
              return 17 + n2;
            }
            n2 = br.readBits(3);
            if (n2 > 0) {
              return 8 + n2;
            }
            return 17;
          }
          function DecodeVarLenUint8(br) {
            if (br.readBits(1)) {
              var nbits = br.readBits(3);
              if (nbits === 0) {
                return 1;
              } else {
                return br.readBits(nbits) + (1 << nbits);
              }
            }
            return 0;
          }
          function MetaBlockLength() {
            this.meta_block_length = 0;
            this.input_end = 0;
            this.is_uncompressed = 0;
            this.is_metadata = false;
          }
          function DecodeMetaBlockLength(br) {
            var out = new MetaBlockLength();
            var size_nibbles;
            var size_bytes;
            var i2;
            out.input_end = br.readBits(1);
            if (out.input_end && br.readBits(1)) {
              return out;
            }
            size_nibbles = br.readBits(2) + 4;
            if (size_nibbles === 7) {
              out.is_metadata = true;
              if (br.readBits(1) !== 0)
                throw new Error("Invalid reserved bit");
              size_bytes = br.readBits(2);
              if (size_bytes === 0) return out;
              for (i2 = 0; i2 < size_bytes; i2++) {
                var next_byte = br.readBits(8);
                if (i2 + 1 === size_bytes && size_bytes > 1 && next_byte === 0)
                  throw new Error("Invalid size byte");
                out.meta_block_length |= next_byte << i2 * 8;
              }
            } else {
              for (i2 = 0; i2 < size_nibbles; ++i2) {
                var next_nibble = br.readBits(4);
                if (i2 + 1 === size_nibbles && size_nibbles > 4 && next_nibble === 0)
                  throw new Error("Invalid size nibble");
                out.meta_block_length |= next_nibble << i2 * 4;
              }
            }
            ++out.meta_block_length;
            if (!out.input_end && !out.is_metadata) {
              out.is_uncompressed = br.readBits(1);
            }
            return out;
          }
          function ReadSymbol(table, index2, br) {
            var start_index = index2;
            var nbits;
            br.fillBitWindow();
            index2 += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK;
            nbits = table[index2].bits - HUFFMAN_TABLE_BITS;
            if (nbits > 0) {
              br.bit_pos_ += HUFFMAN_TABLE_BITS;
              index2 += table[index2].value;
              index2 += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1;
            }
            br.bit_pos_ += table[index2].bits;
            return table[index2].value;
          }
          function ReadHuffmanCodeLengths(code_length_code_lengths, num_symbols, code_lengths, br) {
            var symbol = 0;
            var prev_code_len = kDefaultCodeLength;
            var repeat = 0;
            var repeat_code_len = 0;
            var space = 32768;
            var table = [];
            for (var i2 = 0; i2 < 32; i2++)
              table.push(new HuffmanCode(0, 0));
            BrotliBuildHuffmanTable(
              table,
              0,
              5,
              code_length_code_lengths,
              CODE_LENGTH_CODES
            );
            while (symbol < num_symbols && space > 0) {
              var p3 = 0;
              var code_len;
              br.readMoreInput();
              br.fillBitWindow();
              p3 += br.val_ >>> br.bit_pos_ & 31;
              br.bit_pos_ += table[p3].bits;
              code_len = table[p3].value & 255;
              if (code_len < kCodeLengthRepeatCode) {
                repeat = 0;
                code_lengths[symbol++] = code_len;
                if (code_len !== 0) {
                  prev_code_len = code_len;
                  space -= 32768 >> code_len;
                }
              } else {
                var extra_bits = code_len - 14;
                var old_repeat;
                var repeat_delta;
                var new_len = 0;
                if (code_len === kCodeLengthRepeatCode) {
                  new_len = prev_code_len;
                }
                if (repeat_code_len !== new_len) {
                  repeat = 0;
                  repeat_code_len = new_len;
                }
                old_repeat = repeat;
                if (repeat > 0) {
                  repeat -= 2;
                  repeat <<= extra_bits;
                }
                repeat += br.readBits(extra_bits) + 3;
                repeat_delta = repeat - old_repeat;
                if (symbol + repeat_delta > num_symbols) {
                  throw new Error(
                    "[ReadHuffmanCodeLengths] symbol + repeat_delta > num_symbols"
                  );
                }
                for (var x2 = 0; x2 < repeat_delta; x2++)
                  code_lengths[symbol + x2] = repeat_code_len;
                symbol += repeat_delta;
                if (repeat_code_len !== 0) {
                  space -= repeat_delta << 15 - repeat_code_len;
                }
              }
            }
            if (space !== 0) {
              throw new Error(
                "[ReadHuffmanCodeLengths] space = " + space
              );
            }
            for (; symbol < num_symbols; symbol++)
              code_lengths[symbol] = 0;
          }
          function ReadHuffmanCode(alphabet_size, tables, table, br) {
            var table_size = 0;
            var simple_code_or_skip;
            var code_lengths = new Uint8Array(alphabet_size);
            br.readMoreInput();
            simple_code_or_skip = br.readBits(2);
            if (simple_code_or_skip === 1) {
              var i2;
              var max_bits_counter = alphabet_size - 1;
              var max_bits = 0;
              var symbols = new Int32Array(4);
              var num_symbols = br.readBits(2) + 1;
              while (max_bits_counter) {
                max_bits_counter >>= 1;
                ++max_bits;
              }
              for (i2 = 0; i2 < num_symbols; ++i2) {
                symbols[i2] = br.readBits(max_bits) % alphabet_size;
                code_lengths[symbols[i2]] = 2;
              }
              code_lengths[symbols[0]] = 1;
              switch (num_symbols) {
                case 1:
                  break;
                case 3:
                  if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[1] === symbols[2]) {
                    throw new Error(
                      "[ReadHuffmanCode] invalid symbols"
                    );
                  }
                  break;
                case 2:
                  if (symbols[0] === symbols[1]) {
                    throw new Error(
                      "[ReadHuffmanCode] invalid symbols"
                    );
                  }
                  code_lengths[symbols[1]] = 1;
                  break;
                case 4:
                  if (symbols[0] === symbols[1] || symbols[0] === symbols[2] || symbols[0] === symbols[3] || symbols[1] === symbols[2] || symbols[1] === symbols[3] || symbols[2] === symbols[3]) {
                    throw new Error(
                      "[ReadHuffmanCode] invalid symbols"
                    );
                  }
                  if (br.readBits(1)) {
                    code_lengths[symbols[2]] = 3;
                    code_lengths[symbols[3]] = 3;
                  } else {
                    code_lengths[symbols[0]] = 2;
                  }
                  break;
              }
            } else {
              var i2;
              var code_length_code_lengths = new Uint8Array(
                CODE_LENGTH_CODES
              );
              var space = 32;
              var num_codes = 0;
              var huff = [
                new HuffmanCode(2, 0),
                new HuffmanCode(2, 4),
                new HuffmanCode(2, 3),
                new HuffmanCode(3, 2),
                new HuffmanCode(2, 0),
                new HuffmanCode(2, 4),
                new HuffmanCode(2, 3),
                new HuffmanCode(4, 1),
                new HuffmanCode(2, 0),
                new HuffmanCode(2, 4),
                new HuffmanCode(2, 3),
                new HuffmanCode(3, 2),
                new HuffmanCode(2, 0),
                new HuffmanCode(2, 4),
                new HuffmanCode(2, 3),
                new HuffmanCode(4, 5)
              ];
              for (i2 = simple_code_or_skip; i2 < CODE_LENGTH_CODES && space > 0; ++i2) {
                var code_len_idx = kCodeLengthCodeOrder[i2];
                var p3 = 0;
                var v2;
                br.fillBitWindow();
                p3 += br.val_ >>> br.bit_pos_ & 15;
                br.bit_pos_ += huff[p3].bits;
                v2 = huff[p3].value;
                code_length_code_lengths[code_len_idx] = v2;
                if (v2 !== 0) {
                  space -= 32 >> v2;
                  ++num_codes;
                }
              }
              if (!(num_codes === 1 || space === 0))
                throw new Error(
                  "[ReadHuffmanCode] invalid num_codes or space"
                );
              ReadHuffmanCodeLengths(
                code_length_code_lengths,
                alphabet_size,
                code_lengths,
                br
              );
            }
            table_size = BrotliBuildHuffmanTable(
              tables,
              table,
              HUFFMAN_TABLE_BITS,
              code_lengths,
              alphabet_size
            );
            if (table_size === 0) {
              throw new Error(
                "[ReadHuffmanCode] BuildHuffmanTable failed: "
              );
            }
            return table_size;
          }
          function ReadBlockLength(table, index2, br) {
            var code;
            var nbits;
            code = ReadSymbol(table, index2, br);
            nbits = Prefix.kBlockLengthPrefixCode[code].nbits;
            return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits);
          }
          function TranslateShortCodes(code, ringbuffer, index2) {
            var val;
            if (code < NUM_DISTANCE_SHORT_CODES) {
              index2 += kDistanceShortCodeIndexOffset[code];
              index2 &= 3;
              val = ringbuffer[index2] + kDistanceShortCodeValueOffset[code];
            } else {
              val = code - NUM_DISTANCE_SHORT_CODES + 1;
            }
            return val;
          }
          function MoveToFront(v2, index2) {
            var value = v2[index2];
            var i2 = index2;
            for (; i2; --i2) v2[i2] = v2[i2 - 1];
            v2[0] = value;
          }
          function InverseMoveToFrontTransform(v2, v_len) {
            var mtf = new Uint8Array(256);
            var i2;
            for (i2 = 0; i2 < 256; ++i2) {
              mtf[i2] = i2;
            }
            for (i2 = 0; i2 < v_len; ++i2) {
              var index2 = v2[i2];
              v2[i2] = mtf[index2];
              if (index2) MoveToFront(mtf, index2);
            }
          }
          function HuffmanTreeGroup(alphabet_size, num_htrees) {
            this.alphabet_size = alphabet_size;
            this.num_htrees = num_htrees;
            this.codes = new Array(
              num_htrees + num_htrees * kMaxHuffmanTableSize[alphabet_size + 31 >>> 5]
            );
            this.htrees = new Uint32Array(num_htrees);
          }
          HuffmanTreeGroup.prototype.decode = function(br) {
            var i2;
            var table_size;
            var next = 0;
            for (i2 = 0; i2 < this.num_htrees; ++i2) {
              this.htrees[i2] = next;
              table_size = ReadHuffmanCode(
                this.alphabet_size,
                this.codes,
                next,
                br
              );
              next += table_size;
            }
          };
          function DecodeContextMap(context_map_size, br) {
            var out = { num_htrees: null, context_map: null };
            var use_rle_for_zeros;
            var max_run_length_prefix = 0;
            var table;
            var i2;
            br.readMoreInput();
            var num_htrees = out.num_htrees = DecodeVarLenUint8(br) + 1;
            var context_map = out.context_map = new Uint8Array(
              context_map_size
            );
            if (num_htrees <= 1) {
              return out;
            }
            use_rle_for_zeros = br.readBits(1);
            if (use_rle_for_zeros) {
              max_run_length_prefix = br.readBits(4) + 1;
            }
            table = [];
            for (i2 = 0; i2 < HUFFMAN_MAX_TABLE_SIZE; i2++) {
              table[i2] = new HuffmanCode(0, 0);
            }
            ReadHuffmanCode(
              num_htrees + max_run_length_prefix,
              table,
              0,
              br
            );
            for (i2 = 0; i2 < context_map_size; ) {
              var code;
              br.readMoreInput();
              code = ReadSymbol(table, 0, br);
              if (code === 0) {
                context_map[i2] = 0;
                ++i2;
              } else if (code <= max_run_length_prefix) {
                var reps = 1 + (1 << code) + br.readBits(code);
                while (--reps) {
                  if (i2 >= context_map_size) {
                    throw new Error(
                      "[DecodeContextMap] i >= context_map_size"
                    );
                  }
                  context_map[i2] = 0;
                  ++i2;
                }
              } else {
                context_map[i2] = code - max_run_length_prefix;
                ++i2;
              }
            }
            if (br.readBits(1)) {
              InverseMoveToFrontTransform(
                context_map,
                context_map_size
              );
            }
            return out;
          }
          function DecodeBlockType(max_block_type, trees, tree_type, block_types, ringbuffers, indexes, br) {
            var ringbuffer = tree_type * 2;
            var index2 = tree_type;
            var type_code = ReadSymbol(
              trees,
              tree_type * HUFFMAN_MAX_TABLE_SIZE,
              br
            );
            var block_type;
            if (type_code === 0) {
              block_type = ringbuffers[ringbuffer + (indexes[index2] & 1)];
            } else if (type_code === 1) {
              block_type = ringbuffers[ringbuffer + (indexes[index2] - 1 & 1)] + 1;
            } else {
              block_type = type_code - 2;
            }
            if (block_type >= max_block_type) {
              block_type -= max_block_type;
            }
            block_types[tree_type] = block_type;
            ringbuffers[ringbuffer + (indexes[index2] & 1)] = block_type;
            ++indexes[index2];
          }
          function CopyUncompressedBlockToOutput(output, len, pos, ringbuffer, ringbuffer_mask, br) {
            var rb_size = ringbuffer_mask + 1;
            var rb_pos = pos & ringbuffer_mask;
            var br_pos = br.pos_ & BrotliBitReader.IBUF_MASK;
            var nbytes;
            if (len < 8 || br.bit_pos_ + (len << 3) < br.bit_end_pos_) {
              while (len-- > 0) {
                br.readMoreInput();
                ringbuffer[rb_pos++] = br.readBits(8);
                if (rb_pos === rb_size) {
                  output.write(ringbuffer, rb_size);
                  rb_pos = 0;
                }
              }
              return;
            }
            if (br.bit_end_pos_ < 32) {
              throw new Error(
                "[CopyUncompressedBlockToOutput] br.bit_end_pos_ < 32"
              );
            }
            while (br.bit_pos_ < 32) {
              ringbuffer[rb_pos] = br.val_ >>> br.bit_pos_;
              br.bit_pos_ += 8;
              ++rb_pos;
              --len;
            }
            nbytes = br.bit_end_pos_ - br.bit_pos_ >> 3;
            if (br_pos + nbytes > BrotliBitReader.IBUF_MASK) {
              var tail = BrotliBitReader.IBUF_MASK + 1 - br_pos;
              for (var x2 = 0; x2 < tail; x2++)
                ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
              nbytes -= tail;
              rb_pos += tail;
              len -= tail;
              br_pos = 0;
            }
            for (var x2 = 0; x2 < nbytes; x2++)
              ringbuffer[rb_pos + x2] = br.buf_[br_pos + x2];
            rb_pos += nbytes;
            len -= nbytes;
            if (rb_pos >= rb_size) {
              output.write(ringbuffer, rb_size);
              rb_pos -= rb_size;
              for (var x2 = 0; x2 < rb_pos; x2++)
                ringbuffer[x2] = ringbuffer[rb_size + x2];
            }
            while (rb_pos + len >= rb_size) {
              nbytes = rb_size - rb_pos;
              if (br.input_.read(ringbuffer, rb_pos, nbytes) < nbytes) {
                throw new Error(
                  "[CopyUncompressedBlockToOutput] not enough bytes"
                );
              }
              output.write(ringbuffer, rb_size);
              len -= nbytes;
              rb_pos = 0;
            }
            if (br.input_.read(ringbuffer, rb_pos, len) < len) {
              throw new Error(
                "[CopyUncompressedBlockToOutput] not enough bytes"
              );
            }
            br.reset();
          }
          function JumpToByteBoundary(br) {
            var new_bit_pos = br.bit_pos_ + 7 & ~7;
            var pad_bits = br.readBits(new_bit_pos - br.bit_pos_);
            return pad_bits == 0;
          }
          function BrotliDecompressedSize(buffer) {
            var input = new BrotliInput(buffer);
            var br = new BrotliBitReader(input);
            DecodeWindowBits(br);
            var out = DecodeMetaBlockLength(br);
            return out.meta_block_length;
          }
          exports2.BrotliDecompressedSize = BrotliDecompressedSize;
          function BrotliDecompressBuffer(buffer, output_size) {
            var input = new BrotliInput(buffer);
            if (output_size == null) {
              output_size = BrotliDecompressedSize(buffer);
            }
            var output_buffer = new Uint8Array(output_size);
            var output = new BrotliOutput(output_buffer);
            BrotliDecompress(input, output);
            if (output.pos < output.buffer.length) {
              output.buffer = output.buffer.subarray(
                0,
                output.pos
              );
            }
            return output.buffer;
          }
          exports2.BrotliDecompressBuffer = BrotliDecompressBuffer;
          function BrotliDecompress(input, output) {
            var i2;
            var pos = 0;
            var input_end = 0;
            var window_bits = 0;
            var max_backward_distance;
            var max_distance = 0;
            var ringbuffer_size;
            var ringbuffer_mask;
            var ringbuffer;
            var ringbuffer_end;
            var dist_rb = [16, 15, 11, 4];
            var dist_rb_idx = 0;
            var prev_byte1 = 0;
            var prev_byte2 = 0;
            var hgroup = [
              new HuffmanTreeGroup(0, 0),
              new HuffmanTreeGroup(0, 0),
              new HuffmanTreeGroup(0, 0)
            ];
            var block_type_trees;
            var block_len_trees;
            var br;
            var kRingBufferWriteAheadSlack = 128 + BrotliBitReader.READ_SIZE;
            br = new BrotliBitReader(input);
            window_bits = DecodeWindowBits(br);
            max_backward_distance = (1 << window_bits) - 16;
            ringbuffer_size = 1 << window_bits;
            ringbuffer_mask = ringbuffer_size - 1;
            ringbuffer = new Uint8Array(
              ringbuffer_size + kRingBufferWriteAheadSlack + BrotliDictionary.maxDictionaryWordLength
            );
            ringbuffer_end = ringbuffer_size;
            block_type_trees = [];
            block_len_trees = [];
            for (var x2 = 0; x2 < 3 * HUFFMAN_MAX_TABLE_SIZE; x2++) {
              block_type_trees[x2] = new HuffmanCode(0, 0);
              block_len_trees[x2] = new HuffmanCode(0, 0);
            }
            while (!input_end) {
              var meta_block_remaining_len = 0;
              var is_uncompressed;
              var block_length = [1 << 28, 1 << 28, 1 << 28];
              var block_type = [0];
              var num_block_types = [1, 1, 1];
              var block_type_rb = [0, 1, 0, 1, 0, 1];
              var block_type_rb_index = [0];
              var distance_postfix_bits;
              var num_direct_distance_codes;
              var distance_postfix_mask;
              var num_distance_codes;
              var context_map = null;
              var context_modes = null;
              var num_literal_htrees;
              var dist_context_map = null;
              var num_dist_htrees;
              var context_offset = 0;
              var context_map_slice = null;
              var literal_htree_index = 0;
              var dist_context_offset = 0;
              var dist_context_map_slice = null;
              var dist_htree_index = 0;
              var context_lookup_offset1 = 0;
              var context_lookup_offset2 = 0;
              var context_mode;
              var htree_command;
              for (i2 = 0; i2 < 3; ++i2) {
                hgroup[i2].codes = null;
                hgroup[i2].htrees = null;
              }
              br.readMoreInput();
              var _out = DecodeMetaBlockLength(br);
              meta_block_remaining_len = _out.meta_block_length;
              if (pos + meta_block_remaining_len > output.buffer.length) {
                var tmp = new Uint8Array(
                  pos + meta_block_remaining_len
                );
                tmp.set(output.buffer);
                output.buffer = tmp;
              }
              input_end = _out.input_end;
              is_uncompressed = _out.is_uncompressed;
              if (_out.is_metadata) {
                JumpToByteBoundary(br);
                for (; meta_block_remaining_len > 0; --meta_block_remaining_len) {
                  br.readMoreInput();
                  br.readBits(8);
                }
                continue;
              }
              if (meta_block_remaining_len === 0) {
                continue;
              }
              if (is_uncompressed) {
                br.bit_pos_ = br.bit_pos_ + 7 & ~7;
                CopyUncompressedBlockToOutput(
                  output,
                  meta_block_remaining_len,
                  pos,
                  ringbuffer,
                  ringbuffer_mask,
                  br
                );
                pos += meta_block_remaining_len;
                continue;
              }
              for (i2 = 0; i2 < 3; ++i2) {
                num_block_types[i2] = DecodeVarLenUint8(br) + 1;
                if (num_block_types[i2] >= 2) {
                  ReadHuffmanCode(
                    num_block_types[i2] + 2,
                    block_type_trees,
                    i2 * HUFFMAN_MAX_TABLE_SIZE,
                    br
                  );
                  ReadHuffmanCode(
                    kNumBlockLengthCodes,
                    block_len_trees,
                    i2 * HUFFMAN_MAX_TABLE_SIZE,
                    br
                  );
                  block_length[i2] = ReadBlockLength(
                    block_len_trees,
                    i2 * HUFFMAN_MAX_TABLE_SIZE,
                    br
                  );
                  block_type_rb_index[i2] = 1;
                }
              }
              br.readMoreInput();
              distance_postfix_bits = br.readBits(2);
              num_direct_distance_codes = NUM_DISTANCE_SHORT_CODES + (br.readBits(4) << distance_postfix_bits);
              distance_postfix_mask = (1 << distance_postfix_bits) - 1;
              num_distance_codes = num_direct_distance_codes + (48 << distance_postfix_bits);
              context_modes = new Uint8Array(
                num_block_types[0]
              );
              for (i2 = 0; i2 < num_block_types[0]; ++i2) {
                br.readMoreInput();
                context_modes[i2] = br.readBits(2) << 1;
              }
              var _o1 = DecodeContextMap(
                num_block_types[0] << kLiteralContextBits,
                br
              );
              num_literal_htrees = _o1.num_htrees;
              context_map = _o1.context_map;
              var _o2 = DecodeContextMap(
                num_block_types[2] << kDistanceContextBits,
                br
              );
              num_dist_htrees = _o2.num_htrees;
              dist_context_map = _o2.context_map;
              hgroup[0] = new HuffmanTreeGroup(
                kNumLiteralCodes,
                num_literal_htrees
              );
              hgroup[1] = new HuffmanTreeGroup(
                kNumInsertAndCopyCodes,
                num_block_types[1]
              );
              hgroup[2] = new HuffmanTreeGroup(
                num_distance_codes,
                num_dist_htrees
              );
              for (i2 = 0; i2 < 3; ++i2) {
                hgroup[i2].decode(br);
              }
              context_map_slice = 0;
              dist_context_map_slice = 0;
              context_mode = context_modes[block_type[0]];
              context_lookup_offset1 = Context.lookupOffsets[context_mode];
              context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
              htree_command = hgroup[1].htrees[0];
              while (meta_block_remaining_len > 0) {
                var cmd_code;
                var range_idx;
                var insert_code;
                var copy_code;
                var insert_length;
                var copy_length;
                var distance_code;
                var distance;
                var context;
                var j2;
                var copy_dst;
                br.readMoreInput();
                if (block_length[1] === 0) {
                  DecodeBlockType(
                    num_block_types[1],
                    block_type_trees,
                    1,
                    block_type,
                    block_type_rb,
                    block_type_rb_index,
                    br
                  );
                  block_length[1] = ReadBlockLength(
                    block_len_trees,
                    HUFFMAN_MAX_TABLE_SIZE,
                    br
                  );
                  htree_command = hgroup[1].htrees[block_type[1]];
                }
                --block_length[1];
                cmd_code = ReadSymbol(
                  hgroup[1].codes,
                  htree_command,
                  br
                );
                range_idx = cmd_code >> 6;
                if (range_idx >= 2) {
                  range_idx -= 2;
                  distance_code = -1;
                } else {
                  distance_code = 0;
                }
                insert_code = Prefix.kInsertRangeLut[range_idx] + (cmd_code >> 3 & 7);
                copy_code = Prefix.kCopyRangeLut[range_idx] + (cmd_code & 7);
                insert_length = Prefix.kInsertLengthPrefixCode[insert_code].offset + br.readBits(
                  Prefix.kInsertLengthPrefixCode[insert_code].nbits
                );
                copy_length = Prefix.kCopyLengthPrefixCode[copy_code].offset + br.readBits(
                  Prefix.kCopyLengthPrefixCode[copy_code].nbits
                );
                prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
                prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
                for (j2 = 0; j2 < insert_length; ++j2) {
                  br.readMoreInput();
                  if (block_length[0] === 0) {
                    DecodeBlockType(
                      num_block_types[0],
                      block_type_trees,
                      0,
                      block_type,
                      block_type_rb,
                      block_type_rb_index,
                      br
                    );
                    block_length[0] = ReadBlockLength(
                      block_len_trees,
                      0,
                      br
                    );
                    context_offset = block_type[0] << kLiteralContextBits;
                    context_map_slice = context_offset;
                    context_mode = context_modes[block_type[0]];
                    context_lookup_offset1 = Context.lookupOffsets[context_mode];
                    context_lookup_offset2 = Context.lookupOffsets[context_mode + 1];
                  }
                  context = Context.lookup[context_lookup_offset1 + prev_byte1] | Context.lookup[context_lookup_offset2 + prev_byte2];
                  literal_htree_index = context_map[context_map_slice + context];
                  --block_length[0];
                  prev_byte2 = prev_byte1;
                  prev_byte1 = ReadSymbol(
                    hgroup[0].codes,
                    hgroup[0].htrees[literal_htree_index],
                    br
                  );
                  ringbuffer[pos & ringbuffer_mask] = prev_byte1;
                  if ((pos & ringbuffer_mask) === ringbuffer_mask) {
                    output.write(
                      ringbuffer,
                      ringbuffer_size
                    );
                  }
                  ++pos;
                }
                meta_block_remaining_len -= insert_length;
                if (meta_block_remaining_len <= 0) break;
                if (distance_code < 0) {
                  var context;
                  br.readMoreInput();
                  if (block_length[2] === 0) {
                    DecodeBlockType(
                      num_block_types[2],
                      block_type_trees,
                      2,
                      block_type,
                      block_type_rb,
                      block_type_rb_index,
                      br
                    );
                    block_length[2] = ReadBlockLength(
                      block_len_trees,
                      2 * HUFFMAN_MAX_TABLE_SIZE,
                      br
                    );
                    dist_context_offset = block_type[2] << kDistanceContextBits;
                    dist_context_map_slice = dist_context_offset;
                  }
                  --block_length[2];
                  context = (copy_length > 4 ? 3 : copy_length - 2) & 255;
                  dist_htree_index = dist_context_map[dist_context_map_slice + context];
                  distance_code = ReadSymbol(
                    hgroup[2].codes,
                    hgroup[2].htrees[dist_htree_index],
                    br
                  );
                  if (distance_code >= num_direct_distance_codes) {
                    var nbits;
                    var postfix;
                    var offset4;
                    distance_code -= num_direct_distance_codes;
                    postfix = distance_code & distance_postfix_mask;
                    distance_code >>= distance_postfix_bits;
                    nbits = (distance_code >> 1) + 1;
                    offset4 = (2 + (distance_code & 1) << nbits) - 4;
                    distance_code = num_direct_distance_codes + (offset4 + br.readBits(nbits) << distance_postfix_bits) + postfix;
                  }
                }
                distance = TranslateShortCodes(
                  distance_code,
                  dist_rb,
                  dist_rb_idx
                );
                if (distance < 0) {
                  throw new Error(
                    "[BrotliDecompress] invalid distance"
                  );
                }
                if (pos < max_backward_distance && max_distance !== max_backward_distance) {
                  max_distance = pos;
                } else {
                  max_distance = max_backward_distance;
                }
                copy_dst = pos & ringbuffer_mask;
                if (distance > max_distance) {
                  if (copy_length >= BrotliDictionary.minDictionaryWordLength && copy_length <= BrotliDictionary.maxDictionaryWordLength) {
                    var offset4 = BrotliDictionary.offsetsByLength[copy_length];
                    var word_id = distance - max_distance - 1;
                    var shift4 = BrotliDictionary.sizeBitsByLength[copy_length];
                    var mask = (1 << shift4) - 1;
                    var word_idx = word_id & mask;
                    var transform_idx = word_id >> shift4;
                    offset4 += word_idx * copy_length;
                    if (transform_idx < Transform.kNumTransforms) {
                      var len = Transform.transformDictionaryWord(
                        ringbuffer,
                        copy_dst,
                        offset4,
                        copy_length,
                        transform_idx
                      );
                      copy_dst += len;
                      pos += len;
                      meta_block_remaining_len -= len;
                      if (copy_dst >= ringbuffer_end) {
                        output.write(
                          ringbuffer,
                          ringbuffer_size
                        );
                        for (var _x10 = 0; _x10 < copy_dst - ringbuffer_end; _x10++)
                          ringbuffer[_x10] = ringbuffer[ringbuffer_end + _x10];
                      }
                    } else {
                      throw new Error(
                        "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                      );
                    }
                  } else {
                    throw new Error(
                      "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                    );
                  }
                } else {
                  if (distance_code > 0) {
                    dist_rb[dist_rb_idx & 3] = distance;
                    ++dist_rb_idx;
                  }
                  if (copy_length > meta_block_remaining_len) {
                    throw new Error(
                      "Invalid backward reference. pos: " + pos + " distance: " + distance + " len: " + copy_length + " bytes left: " + meta_block_remaining_len
                    );
                  }
                  for (j2 = 0; j2 < copy_length; ++j2) {
                    ringbuffer[pos & ringbuffer_mask] = ringbuffer[pos - distance & ringbuffer_mask];
                    if ((pos & ringbuffer_mask) === ringbuffer_mask) {
                      output.write(
                        ringbuffer,
                        ringbuffer_size
                      );
                    }
                    ++pos;
                    --meta_block_remaining_len;
                  }
                }
                prev_byte1 = ringbuffer[pos - 1 & ringbuffer_mask];
                prev_byte2 = ringbuffer[pos - 2 & ringbuffer_mask];
              }
              pos &= 1073741823;
            }
            output.write(ringbuffer, pos & ringbuffer_mask);
          }
          exports2.BrotliDecompress = BrotliDecompress;
          BrotliDictionary.init();
        },
        {
          "./bit_reader": 1,
          "./context": 2,
          "./dictionary": 6,
          "./huffman": 7,
          "./prefix": 9,
          "./streams": 10,
          "./transform": 11
        }
      ],
      4: [
        function(require2, module2, exports2) {
          var base64 = require2("base64-js");
          exports2.init = function() {
            var BrotliDecompressBuffer = require2("./decode").BrotliDecompressBuffer;
            var compressed = base64.toByteArray(
              require2("./dictionary.bin.js")
            );
            return BrotliDecompressBuffer(compressed);
          };
        },
        { "./decode": 3, "./dictionary.bin.js": 5, "base64-js": 8 }
      ],
      5: [
        function(require2, module2, exports2) {
          module2.exports = " ";
        },
        {}
      ],
      6: [
        function(require2, module2, exports2) {
          var data = require2("./dictionary-browser");
          exports2.init = function() {
            exports2.dictionary = data.init();
          };
          exports2.offsetsByLength = new Uint32Array([
            0,
            0,
            0,
            0,
            0,
            4096,
            9216,
            21504,
            35840,
            44032,
            53248,
            63488,
            74752,
            87040,
            93696,
            100864,
            104704,
            106752,
            108928,
            113536,
            115968,
            118528,
            119872,
            121280,
            122016
          ]);
          exports2.sizeBitsByLength = new Uint8Array([
            0,
            0,
            0,
            0,
            10,
            10,
            11,
            11,
            10,
            10,
            10,
            10,
            10,
            9,
            9,
            8,
            7,
            7,
            8,
            7,
            7,
            6,
            6,
            5,
            5
          ]);
          exports2.minDictionaryWordLength = 4;
          exports2.maxDictionaryWordLength = 24;
        },
        { "./dictionary-browser": 4 }
      ],
      7: [
        function(require2, module2, exports2) {
          function HuffmanCode(bits, value) {
            this.bits = bits;
            this.value = value;
          }
          exports2.HuffmanCode = HuffmanCode;
          var MAX_LENGTH = 15;
          function GetNextKey(key, len) {
            var step = 1 << len - 1;
            while (key & step) {
              step >>= 1;
            }
            return (key & step - 1) + step;
          }
          function ReplicateValue(table, i2, step, end, code) {
            do {
              end -= step;
              table[i2 + end] = new HuffmanCode(
                code.bits,
                code.value
              );
            } while (end > 0);
          }
          function NextTableBitSize(count, len, root_bits) {
            var left = 1 << len - root_bits;
            while (len < MAX_LENGTH) {
              left -= count[len];
              if (left <= 0) break;
              ++len;
              left <<= 1;
            }
            return len - root_bits;
          }
          exports2.BrotliBuildHuffmanTable = function(root_table, table, root_bits, code_lengths, code_lengths_size) {
            var start_table = table;
            var code;
            var len;
            var symbol;
            var key;
            var step;
            var low;
            var mask;
            var table_bits;
            var table_size;
            var total_size;
            var sorted;
            var count = new Int32Array(
              MAX_LENGTH + 1
            );
            var offset4 = new Int32Array(
              MAX_LENGTH + 1
            );
            sorted = new Int32Array(code_lengths_size);
            for (symbol = 0; symbol < code_lengths_size; symbol++) {
              count[code_lengths[symbol]]++;
            }
            offset4[1] = 0;
            for (len = 1; len < MAX_LENGTH; len++) {
              offset4[len + 1] = offset4[len] + count[len];
            }
            for (symbol = 0; symbol < code_lengths_size; symbol++) {
              if (code_lengths[symbol] !== 0) {
                sorted[offset4[code_lengths[symbol]]++] = symbol;
              }
            }
            table_bits = root_bits;
            table_size = 1 << table_bits;
            total_size = table_size;
            if (offset4[MAX_LENGTH] === 1) {
              for (key = 0; key < total_size; ++key) {
                root_table[table + key] = new HuffmanCode(
                  0,
                  sorted[0] & 65535
                );
              }
              return total_size;
            }
            key = 0;
            symbol = 0;
            for (len = 1, step = 2; len <= root_bits; ++len, step <<= 1) {
              for (; count[len] > 0; --count[len]) {
                code = new HuffmanCode(
                  len & 255,
                  sorted[symbol++] & 65535
                );
                ReplicateValue(
                  root_table,
                  table + key,
                  step,
                  table_size,
                  code
                );
                key = GetNextKey(key, len);
              }
            }
            mask = total_size - 1;
            low = -1;
            for (len = root_bits + 1, step = 2; len <= MAX_LENGTH; ++len, step <<= 1) {
              for (; count[len] > 0; --count[len]) {
                if ((key & mask) !== low) {
                  table += table_size;
                  table_bits = NextTableBitSize(
                    count,
                    len,
                    root_bits
                  );
                  table_size = 1 << table_bits;
                  total_size += table_size;
                  low = key & mask;
                  root_table[start_table + low] = new HuffmanCode(
                    table_bits + root_bits & 255,
                    table - start_table - low & 65535
                  );
                }
                code = new HuffmanCode(
                  len - root_bits & 255,
                  sorted[symbol++] & 65535
                );
                ReplicateValue(
                  root_table,
                  table + (key >> root_bits),
                  step,
                  table_size,
                  code
                );
                key = GetNextKey(key, len);
              }
            }
            return total_size;
          };
        },
        {}
      ],
      8: [
        function(require2, module2, exports2) {
          "use strict";
          exports2.byteLength = byteLength;
          exports2.toByteArray = toByteArray;
          exports2.fromByteArray = fromByteArray;
          var lookup = [];
          var revLookup = [];
          var Arr = typeof Uint8Array !== "undefined" ? Uint8Array : Array;
          var code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
          for (var i2 = 0, len = code.length; i2 < len; ++i2) {
            lookup[i2] = code[i2];
            revLookup[code.charCodeAt(i2)] = i2;
          }
          revLookup["-".charCodeAt(0)] = 62;
          revLookup["_".charCodeAt(0)] = 63;
          function getLens(b64) {
            var len2 = b64.length;
            if (len2 % 4 > 0) {
              throw new Error(
                "Invalid string. Length must be a multiple of 4"
              );
            }
            var validLen = b64.indexOf("=");
            if (validLen === -1) validLen = len2;
            var placeHoldersLen = validLen === len2 ? 0 : 4 - validLen % 4;
            return [validLen, placeHoldersLen];
          }
          function byteLength(b64) {
            var lens = getLens(b64);
            var validLen = lens[0];
            var placeHoldersLen = lens[1];
            return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
          }
          function _byteLength(b64, validLen, placeHoldersLen) {
            return (validLen + placeHoldersLen) * 3 / 4 - placeHoldersLen;
          }
          function toByteArray(b64) {
            var tmp;
            var lens = getLens(b64);
            var validLen = lens[0];
            var placeHoldersLen = lens[1];
            var arr = new Arr(
              _byteLength(b64, validLen, placeHoldersLen)
            );
            var curByte = 0;
            var len2 = placeHoldersLen > 0 ? validLen - 4 : validLen;
            for (var i22 = 0; i22 < len2; i22 += 4) {
              tmp = revLookup[b64.charCodeAt(i22)] << 18 | revLookup[b64.charCodeAt(i22 + 1)] << 12 | revLookup[b64.charCodeAt(i22 + 2)] << 6 | revLookup[b64.charCodeAt(i22 + 3)];
              arr[curByte++] = tmp >> 16 & 255;
              arr[curByte++] = tmp >> 8 & 255;
              arr[curByte++] = tmp & 255;
            }
            if (placeHoldersLen === 2) {
              tmp = revLookup[b64.charCodeAt(i22)] << 2 | revLookup[b64.charCodeAt(i22 + 1)] >> 4;
              arr[curByte++] = tmp & 255;
            }
            if (placeHoldersLen === 1) {
              tmp = revLookup[b64.charCodeAt(i22)] << 10 | revLookup[b64.charCodeAt(i22 + 1)] << 4 | revLookup[b64.charCodeAt(i22 + 2)] >> 2;
              arr[curByte++] = tmp >> 8 & 255;
              arr[curByte++] = tmp & 255;
            }
            return arr;
          }
          function tripletToBase64(num) {
            return lookup[num >> 18 & 63] + lookup[num >> 12 & 63] + lookup[num >> 6 & 63] + lookup[num & 63];
          }
          function encodeChunk(uint8, start, end) {
            var tmp;
            var output = [];
            for (var i22 = start; i22 < end; i22 += 3) {
              tmp = (uint8[i22] << 16 & 16711680) + (uint8[i22 + 1] << 8 & 65280) + (uint8[i22 + 2] & 255);
              output.push(tripletToBase64(tmp));
            }
            return output.join("");
          }
          function fromByteArray(uint8) {
            var tmp;
            var len2 = uint8.length;
            var extraBytes = len2 % 3;
            var parts = [];
            var maxChunkLength = 16383;
            for (var i22 = 0, len22 = len2 - extraBytes; i22 < len22; i22 += maxChunkLength) {
              parts.push(
                encodeChunk(
                  uint8,
                  i22,
                  i22 + maxChunkLength > len22 ? len22 : i22 + maxChunkLength
                )
              );
            }
            if (extraBytes === 1) {
              tmp = uint8[len2 - 1];
              parts.push(
                lookup[tmp >> 2] + lookup[tmp << 4 & 63] + "=="
              );
            } else if (extraBytes === 2) {
              tmp = (uint8[len2 - 2] << 8) + uint8[len2 - 1];
              parts.push(
                lookup[tmp >> 10] + lookup[tmp >> 4 & 63] + lookup[tmp << 2 & 63] + "="
              );
            }
            return parts.join("");
          }
        },
        {}
      ],
      9: [
        function(require2, module2, exports2) {
          function PrefixCodeRange(offset4, nbits) {
            this.offset = offset4;
            this.nbits = nbits;
          }
          exports2.kBlockLengthPrefixCode = [
            new PrefixCodeRange(1, 2),
            new PrefixCodeRange(5, 2),
            new PrefixCodeRange(9, 2),
            new PrefixCodeRange(13, 2),
            new PrefixCodeRange(17, 3),
            new PrefixCodeRange(25, 3),
            new PrefixCodeRange(33, 3),
            new PrefixCodeRange(41, 3),
            new PrefixCodeRange(49, 4),
            new PrefixCodeRange(65, 4),
            new PrefixCodeRange(81, 4),
            new PrefixCodeRange(97, 4),
            new PrefixCodeRange(113, 5),
            new PrefixCodeRange(145, 5),
            new PrefixCodeRange(177, 5),
            new PrefixCodeRange(209, 5),
            new PrefixCodeRange(241, 6),
            new PrefixCodeRange(305, 6),
            new PrefixCodeRange(369, 7),
            new PrefixCodeRange(497, 8),
            new PrefixCodeRange(753, 9),
            new PrefixCodeRange(1265, 10),
            new PrefixCodeRange(2289, 11),
            new PrefixCodeRange(4337, 12),
            new PrefixCodeRange(8433, 13),
            new PrefixCodeRange(16625, 24)
          ];
          exports2.kInsertLengthPrefixCode = [
            new PrefixCodeRange(0, 0),
            new PrefixCodeRange(1, 0),
            new PrefixCodeRange(2, 0),
            new PrefixCodeRange(3, 0),
            new PrefixCodeRange(4, 0),
            new PrefixCodeRange(5, 0),
            new PrefixCodeRange(6, 1),
            new PrefixCodeRange(8, 1),
            new PrefixCodeRange(10, 2),
            new PrefixCodeRange(14, 2),
            new PrefixCodeRange(18, 3),
            new PrefixCodeRange(26, 3),
            new PrefixCodeRange(34, 4),
            new PrefixCodeRange(50, 4),
            new PrefixCodeRange(66, 5),
            new PrefixCodeRange(98, 5),
            new PrefixCodeRange(130, 6),
            new PrefixCodeRange(194, 7),
            new PrefixCodeRange(322, 8),
            new PrefixCodeRange(578, 9),
            new PrefixCodeRange(1090, 10),
            new PrefixCodeRange(2114, 12),
            new PrefixCodeRange(6210, 14),
            new PrefixCodeRange(22594, 24)
          ];
          exports2.kCopyLengthPrefixCode = [
            new PrefixCodeRange(2, 0),
            new PrefixCodeRange(3, 0),
            new PrefixCodeRange(4, 0),
            new PrefixCodeRange(5, 0),
            new PrefixCodeRange(6, 0),
            new PrefixCodeRange(7, 0),
            new PrefixCodeRange(8, 0),
            new PrefixCodeRange(9, 0),
            new PrefixCodeRange(10, 1),
            new PrefixCodeRange(12, 1),
            new PrefixCodeRange(14, 2),
            new PrefixCodeRange(18, 2),
            new PrefixCodeRange(22, 3),
            new PrefixCodeRange(30, 3),
            new PrefixCodeRange(38, 4),
            new PrefixCodeRange(54, 4),
            new PrefixCodeRange(70, 5),
            new PrefixCodeRange(102, 5),
            new PrefixCodeRange(134, 6),
            new PrefixCodeRange(198, 7),
            new PrefixCodeRange(326, 8),
            new PrefixCodeRange(582, 9),
            new PrefixCodeRange(1094, 10),
            new PrefixCodeRange(2118, 24)
          ];
          exports2.kInsertRangeLut = [0, 0, 8, 8, 0, 16, 8, 16, 16];
          exports2.kCopyRangeLut = [0, 8, 0, 8, 16, 0, 16, 8, 16];
        },
        {}
      ],
      10: [
        function(require2, module2, exports2) {
          function BrotliInput(buffer) {
            this.buffer = buffer;
            this.pos = 0;
          }
          BrotliInput.prototype.read = function(buf, i2, count) {
            if (this.pos + count > this.buffer.length) {
              count = this.buffer.length - this.pos;
            }
            for (var p3 = 0; p3 < count; p3++)
              buf[i2 + p3] = this.buffer[this.pos + p3];
            this.pos += count;
            return count;
          };
          exports2.BrotliInput = BrotliInput;
          function BrotliOutput(buf) {
            this.buffer = buf;
            this.pos = 0;
          }
          BrotliOutput.prototype.write = function(buf, count) {
            if (this.pos + count > this.buffer.length)
              throw new Error(
                "Output buffer is not large enough"
              );
            this.buffer.set(buf.subarray(0, count), this.pos);
            this.pos += count;
            return count;
          };
          exports2.BrotliOutput = BrotliOutput;
        },
        {}
      ],
      11: [
        function(require2, module2, exports2) {
          var BrotliDictionary = require2("./dictionary");
          var kIdentity = 0;
          var kOmitLast1 = 1;
          var kOmitLast2 = 2;
          var kOmitLast3 = 3;
          var kOmitLast4 = 4;
          var kOmitLast5 = 5;
          var kOmitLast6 = 6;
          var kOmitLast7 = 7;
          var kOmitLast8 = 8;
          var kOmitLast9 = 9;
          var kUppercaseFirst = 10;
          var kUppercaseAll = 11;
          var kOmitFirst1 = 12;
          var kOmitFirst2 = 13;
          var kOmitFirst3 = 14;
          var kOmitFirst4 = 15;
          var kOmitFirst5 = 16;
          var kOmitFirst6 = 17;
          var kOmitFirst7 = 18;
          var kOmitFirst8 = 19;
          var kOmitFirst9 = 20;
          function Transform(prefix, transform, suffix) {
            this.prefix = new Uint8Array(prefix.length);
            this.transform = transform;
            this.suffix = new Uint8Array(suffix.length);
            for (var i2 = 0; i2 < prefix.length; i2++)
              this.prefix[i2] = prefix.charCodeAt(i2);
            for (var i2 = 0; i2 < suffix.length; i2++)
              this.suffix[i2] = suffix.charCodeAt(i2);
          }
          var kTransforms = [
            new Transform("", kIdentity, ""),
            new Transform("", kIdentity, " "),
            new Transform(" ", kIdentity, " "),
            new Transform("", kOmitFirst1, ""),
            new Transform("", kUppercaseFirst, " "),
            new Transform("", kIdentity, " the "),
            new Transform(" ", kIdentity, ""),
            new Transform("s ", kIdentity, " "),
            new Transform("", kIdentity, " of "),
            new Transform("", kUppercaseFirst, ""),
            new Transform("", kIdentity, " and "),
            new Transform("", kOmitFirst2, ""),
            new Transform("", kOmitLast1, ""),
            new Transform(", ", kIdentity, " "),
            new Transform("", kIdentity, ", "),
            new Transform(" ", kUppercaseFirst, " "),
            new Transform("", kIdentity, " in "),
            new Transform("", kIdentity, " to "),
            new Transform("e ", kIdentity, " "),
            new Transform("", kIdentity, '"'),
            new Transform("", kIdentity, "."),
            new Transform("", kIdentity, '">'),
            new Transform("", kIdentity, "\n"),
            new Transform("", kOmitLast3, ""),
            new Transform("", kIdentity, "]"),
            new Transform("", kIdentity, " for "),
            new Transform("", kOmitFirst3, ""),
            new Transform("", kOmitLast2, ""),
            new Transform("", kIdentity, " a "),
            new Transform("", kIdentity, " that "),
            new Transform(" ", kUppercaseFirst, ""),
            new Transform("", kIdentity, ". "),
            new Transform(".", kIdentity, ""),
            new Transform(" ", kIdentity, ", "),
            new Transform("", kOmitFirst4, ""),
            new Transform("", kIdentity, " with "),
            new Transform("", kIdentity, "'"),
            new Transform("", kIdentity, " from "),
            new Transform("", kIdentity, " by "),
            new Transform("", kOmitFirst5, ""),
            new Transform("", kOmitFirst6, ""),
            new Transform(" the ", kIdentity, ""),
            new Transform("", kOmitLast4, ""),
            new Transform("", kIdentity, ". The "),
            new Transform("", kUppercaseAll, ""),
            new Transform("", kIdentity, " on "),
            new Transform("", kIdentity, " as "),
            new Transform("", kIdentity, " is "),
            new Transform("", kOmitLast7, ""),
            new Transform("", kOmitLast1, "ing "),
            new Transform("", kIdentity, "\n	"),
            new Transform("", kIdentity, ":"),
            new Transform(" ", kIdentity, ". "),
            new Transform("", kIdentity, "ed "),
            new Transform("", kOmitFirst9, ""),
            new Transform("", kOmitFirst7, ""),
            new Transform("", kOmitLast6, ""),
            new Transform("", kIdentity, "("),
            new Transform("", kUppercaseFirst, ", "),
            new Transform("", kOmitLast8, ""),
            new Transform("", kIdentity, " at "),
            new Transform("", kIdentity, "ly "),
            new Transform(" the ", kIdentity, " of "),
            new Transform("", kOmitLast5, ""),
            new Transform("", kOmitLast9, ""),
            new Transform(" ", kUppercaseFirst, ", "),
            new Transform("", kUppercaseFirst, '"'),
            new Transform(".", kIdentity, "("),
            new Transform("", kUppercaseAll, " "),
            new Transform("", kUppercaseFirst, '">'),
            new Transform("", kIdentity, '="'),
            new Transform(" ", kIdentity, "."),
            new Transform(".com/", kIdentity, ""),
            new Transform(" the ", kIdentity, " of the "),
            new Transform("", kUppercaseFirst, "'"),
            new Transform("", kIdentity, ". This "),
            new Transform("", kIdentity, ","),
            new Transform(".", kIdentity, " "),
            new Transform("", kUppercaseFirst, "("),
            new Transform("", kUppercaseFirst, "."),
            new Transform("", kIdentity, " not "),
            new Transform(" ", kIdentity, '="'),
            new Transform("", kIdentity, "er "),
            new Transform(" ", kUppercaseAll, " "),
            new Transform("", kIdentity, "al "),
            new Transform(" ", kUppercaseAll, ""),
            new Transform("", kIdentity, "='"),
            new Transform("", kUppercaseAll, '"'),
            new Transform("", kUppercaseFirst, ". "),
            new Transform(" ", kIdentity, "("),
            new Transform("", kIdentity, "ful "),
            new Transform(" ", kUppercaseFirst, ". "),
            new Transform("", kIdentity, "ive "),
            new Transform("", kIdentity, "less "),
            new Transform("", kUppercaseAll, "'"),
            new Transform("", kIdentity, "est "),
            new Transform(" ", kUppercaseFirst, "."),
            new Transform("", kUppercaseAll, '">'),
            new Transform(" ", kIdentity, "='"),
            new Transform("", kUppercaseFirst, ","),
            new Transform("", kIdentity, "ize "),
            new Transform("", kUppercaseAll, "."),
            new Transform("\xC2\xA0", kIdentity, ""),
            new Transform(" ", kIdentity, ","),
            new Transform("", kUppercaseFirst, '="'),
            new Transform("", kUppercaseAll, '="'),
            new Transform("", kIdentity, "ous "),
            new Transform("", kUppercaseAll, ", "),
            new Transform("", kUppercaseFirst, "='"),
            new Transform(" ", kUppercaseFirst, ","),
            new Transform(" ", kUppercaseAll, '="'),
            new Transform(" ", kUppercaseAll, ", "),
            new Transform("", kUppercaseAll, ","),
            new Transform("", kUppercaseAll, "("),
            new Transform("", kUppercaseAll, ". "),
            new Transform(" ", kUppercaseAll, "."),
            new Transform("", kUppercaseAll, "='"),
            new Transform(" ", kUppercaseAll, ". "),
            new Transform(" ", kUppercaseFirst, '="'),
            new Transform(" ", kUppercaseAll, "='"),
            new Transform(" ", kUppercaseFirst, "='")
          ];
          exports2.kTransforms = kTransforms;
          exports2.kNumTransforms = kTransforms.length;
          function ToUpperCase(p3, i2) {
            if (p3[i2] < 192) {
              if (p3[i2] >= 97 && p3[i2] <= 122) {
                p3[i2] ^= 32;
              }
              return 1;
            }
            if (p3[i2] < 224) {
              p3[i2 + 1] ^= 32;
              return 2;
            }
            p3[i2 + 2] ^= 5;
            return 3;
          }
          exports2.transformDictionaryWord = function(dst, idx, word, len, transform) {
            var prefix = kTransforms[transform].prefix;
            var suffix = kTransforms[transform].suffix;
            var t3 = kTransforms[transform].transform;
            var skip = t3 < kOmitFirst1 ? 0 : t3 - (kOmitFirst1 - 1);
            var i2 = 0;
            var start_idx = idx;
            var uppercase;
            if (skip > len) {
              skip = len;
            }
            var prefix_pos = 0;
            while (prefix_pos < prefix.length) {
              dst[idx++] = prefix[prefix_pos++];
            }
            word += skip;
            len -= skip;
            if (t3 <= kOmitLast9) {
              len -= t3;
            }
            for (i2 = 0; i2 < len; i2++) {
              dst[idx++] = BrotliDictionary.dictionary[word + i2];
            }
            uppercase = idx - len;
            if (t3 === kUppercaseFirst) {
              ToUpperCase(dst, uppercase);
            } else if (t3 === kUppercaseAll) {
              while (len > 0) {
                var step = ToUpperCase(dst, uppercase);
                uppercase += step;
                len -= step;
              }
            }
            var suffix_pos = 0;
            while (suffix_pos < suffix.length) {
              dst[idx++] = suffix[suffix_pos++];
            }
            return idx - start_idx;
          };
        },
        { "./dictionary": 6 }
      ],
      12: [
        function(require2, module2, exports2) {
          module2.exports = require2("./dec/decode").BrotliDecompressBuffer;
        },
        { "./dec/decode": 3 }
      ]
    },
    {},
    [12]
  )(12);
})();

// packages/global-styles-ui/build-module/font-library/lib/inflate.mjs
var __require3 = /* @__PURE__ */ ((x2) => typeof __require !== "undefined" ? __require : typeof Proxy !== "undefined" ? new Proxy(x2, {
  get: (a2, b2) => (typeof __require !== "undefined" ? __require : a2)[b2]
}) : x2)(function(x2) {
  if (typeof __require !== "undefined") return __require.apply(this, arguments);
  throw Error('Dynamic require of "' + x2 + '" is not supported');
});
var inflate_default = (function() {
  var define, module, exports;
  return (/* @__PURE__ */ (function() {
    function r3(e2, n2, t3) {
      function o3(i22, f2) {
        if (!n2[i22]) {
          if (!e2[i22]) {
            var c2 = "function" == typeof __require3 && __require3;
            if (!f2 && c2) return c2(i22, true);
            if (u2) return u2(i22, true);
            var a2 = new Error("Cannot find module '" + i22 + "'");
            throw a2.code = "MODULE_NOT_FOUND", a2;
          }
          var p3 = n2[i22] = { exports: {} };
          e2[i22][0].call(
            p3.exports,
            function(r22) {
              var n22 = e2[i22][1][r22];
              return o3(n22 || r22);
            },
            p3,
            p3.exports,
            r3,
            e2,
            n2,
            t3
          );
        }
        return n2[i22].exports;
      }
      for (var u2 = "function" == typeof __require3 && __require3, i2 = 0; i2 < t3.length; i2++)
        o3(t3[i2]);
      return o3;
    }
    return r3;
  })())(
    {
      1: [
        function(require2, module2, exports2) {
          "use strict";
          var TYPED_OK = typeof Uint8Array !== "undefined" && typeof Uint16Array !== "undefined" && typeof Int32Array !== "undefined";
          function _has(obj, key) {
            return Object.prototype.hasOwnProperty.call(obj, key);
          }
          exports2.assign = function(obj) {
            var sources = Array.prototype.slice.call(
              arguments,
              1
            );
            while (sources.length) {
              var source = sources.shift();
              if (!source) {
                continue;
              }
              if (typeof source !== "object") {
                throw new TypeError(
                  source + "must be non-object"
                );
              }
              for (var p3 in source) {
                if (_has(source, p3)) {
                  obj[p3] = source[p3];
                }
              }
            }
            return obj;
          };
          exports2.shrinkBuf = function(buf, size4) {
            if (buf.length === size4) {
              return buf;
            }
            if (buf.subarray) {
              return buf.subarray(0, size4);
            }
            buf.length = size4;
            return buf;
          };
          var fnTyped = {
            arraySet: function(dest, src, src_offs, len, dest_offs) {
              if (src.subarray && dest.subarray) {
                dest.set(
                  src.subarray(src_offs, src_offs + len),
                  dest_offs
                );
                return;
              }
              for (var i2 = 0; i2 < len; i2++) {
                dest[dest_offs + i2] = src[src_offs + i2];
              }
            },
            // Join array of chunks to single array.
            flattenChunks: function(chunks) {
              var i2, l2, len, pos, chunk, result;
              len = 0;
              for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) {
                len += chunks[i2].length;
              }
              result = new Uint8Array(len);
              pos = 0;
              for (i2 = 0, l2 = chunks.length; i2 < l2; i2++) {
                chunk = chunks[i2];
                result.set(chunk, pos);
                pos += chunk.length;
              }
              return result;
            }
          };
          var fnUntyped = {
            arraySet: function(dest, src, src_offs, len, dest_offs) {
              for (var i2 = 0; i2 < len; i2++) {
                dest[dest_offs + i2] = src[src_offs + i2];
              }
            },
            // Join array of chunks to single array.
            flattenChunks: function(chunks) {
              return [].concat.apply([], chunks);
            }
          };
          exports2.setTyped = function(on) {
            if (on) {
              exports2.Buf8 = Uint8Array;
              exports2.Buf16 = Uint16Array;
              exports2.Buf32 = Int32Array;
              exports2.assign(exports2, fnTyped);
            } else {
              exports2.Buf8 = Array;
              exports2.Buf16 = Array;
              exports2.Buf32 = Array;
              exports2.assign(exports2, fnUntyped);
            }
          };
          exports2.setTyped(TYPED_OK);
        },
        {}
      ],
      2: [
        function(require2, module2, exports2) {
          "use strict";
          var utils = require2("./common");
          var STR_APPLY_OK = true;
          var STR_APPLY_UIA_OK = true;
          try {
            String.fromCharCode.apply(null, [0]);
          } catch (__43) {
            STR_APPLY_OK = false;
          }
          try {
            String.fromCharCode.apply(null, new Uint8Array(1));
          } catch (__43) {
            STR_APPLY_UIA_OK = false;
          }
          var _utf8len = new utils.Buf8(256);
          for (var q = 0; q < 256; q++) {
            _utf8len[q] = q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1;
          }
          _utf8len[254] = _utf8len[254] = 1;
          exports2.string2buf = function(str) {
            var buf, c2, c22, m_pos, i2, str_len = str.length, buf_len = 0;
            for (m_pos = 0; m_pos < str_len; m_pos++) {
              c2 = str.charCodeAt(m_pos);
              if ((c2 & 64512) === 55296 && m_pos + 1 < str_len) {
                c22 = str.charCodeAt(m_pos + 1);
                if ((c22 & 64512) === 56320) {
                  c2 = 65536 + (c2 - 55296 << 10) + (c22 - 56320);
                  m_pos++;
                }
              }
              buf_len += c2 < 128 ? 1 : c2 < 2048 ? 2 : c2 < 65536 ? 3 : 4;
            }
            buf = new utils.Buf8(buf_len);
            for (i2 = 0, m_pos = 0; i2 < buf_len; m_pos++) {
              c2 = str.charCodeAt(m_pos);
              if ((c2 & 64512) === 55296 && m_pos + 1 < str_len) {
                c22 = str.charCodeAt(m_pos + 1);
                if ((c22 & 64512) === 56320) {
                  c2 = 65536 + (c2 - 55296 << 10) + (c22 - 56320);
                  m_pos++;
                }
              }
              if (c2 < 128) {
                buf[i2++] = c2;
              } else if (c2 < 2048) {
                buf[i2++] = 192 | c2 >>> 6;
                buf[i2++] = 128 | c2 & 63;
              } else if (c2 < 65536) {
                buf[i2++] = 224 | c2 >>> 12;
                buf[i2++] = 128 | c2 >>> 6 & 63;
                buf[i2++] = 128 | c2 & 63;
              } else {
                buf[i2++] = 240 | c2 >>> 18;
                buf[i2++] = 128 | c2 >>> 12 & 63;
                buf[i2++] = 128 | c2 >>> 6 & 63;
                buf[i2++] = 128 | c2 & 63;
              }
            }
            return buf;
          };
          function buf2binstring(buf, len) {
            if (len < 65534) {
              if (buf.subarray && STR_APPLY_UIA_OK || !buf.subarray && STR_APPLY_OK) {
                return String.fromCharCode.apply(
                  null,
                  utils.shrinkBuf(buf, len)
                );
              }
            }
            var result = "";
            for (var i2 = 0; i2 < len; i2++) {
              result += String.fromCharCode(buf[i2]);
            }
            return result;
          }
          exports2.buf2binstring = function(buf) {
            return buf2binstring(buf, buf.length);
          };
          exports2.binstring2buf = function(str) {
            var buf = new utils.Buf8(str.length);
            for (var i2 = 0, len = buf.length; i2 < len; i2++) {
              buf[i2] = str.charCodeAt(i2);
            }
            return buf;
          };
          exports2.buf2string = function(buf, max2) {
            var i2, out, c2, c_len;
            var len = max2 || buf.length;
            var utf16buf = new Array(len * 2);
            for (out = 0, i2 = 0; i2 < len; ) {
              c2 = buf[i2++];
              if (c2 < 128) {
                utf16buf[out++] = c2;
                continue;
              }
              c_len = _utf8len[c2];
              if (c_len > 4) {
                utf16buf[out++] = 65533;
                i2 += c_len - 1;
                continue;
              }
              c2 &= c_len === 2 ? 31 : c_len === 3 ? 15 : 7;
              while (c_len > 1 && i2 < len) {
                c2 = c2 << 6 | buf[i2++] & 63;
                c_len--;
              }
              if (c_len > 1) {
                utf16buf[out++] = 65533;
                continue;
              }
              if (c2 < 65536) {
                utf16buf[out++] = c2;
              } else {
                c2 -= 65536;
                utf16buf[out++] = 55296 | c2 >> 10 & 1023;
                utf16buf[out++] = 56320 | c2 & 1023;
              }
            }
            return buf2binstring(utf16buf, out);
          };
          exports2.utf8border = function(buf, max2) {
            var pos;
            max2 = max2 || buf.length;
            if (max2 > buf.length) {
              max2 = buf.length;
            }
            pos = max2 - 1;
            while (pos >= 0 && (buf[pos] & 192) === 128) {
              pos--;
            }
            if (pos < 0) {
              return max2;
            }
            if (pos === 0) {
              return max2;
            }
            return pos + _utf8len[buf[pos]] > max2 ? pos : max2;
          };
        },
        { "./common": 1 }
      ],
      3: [
        function(require2, module2, exports2) {
          "use strict";
          function adler32(adler, buf, len, pos) {
            var s1 = adler & 65535 | 0, s2 = adler >>> 16 & 65535 | 0, n2 = 0;
            while (len !== 0) {
              n2 = len > 2e3 ? 2e3 : len;
              len -= n2;
              do {
                s1 = s1 + buf[pos++] | 0;
                s2 = s2 + s1 | 0;
              } while (--n2);
              s1 %= 65521;
              s2 %= 65521;
            }
            return s1 | s2 << 16 | 0;
          }
          module2.exports = adler32;
        },
        {}
      ],
      4: [
        function(require2, module2, exports2) {
          "use strict";
          module2.exports = {
            /* Allowed flush values; see deflate() and inflate() below for details */
            Z_NO_FLUSH: 0,
            Z_PARTIAL_FLUSH: 1,
            Z_SYNC_FLUSH: 2,
            Z_FULL_FLUSH: 3,
            Z_FINISH: 4,
            Z_BLOCK: 5,
            Z_TREES: 6,
            /* Return codes for the compression/decompression functions. Negative values
             * are errors, positive values are used for special but normal events.
             */
            Z_OK: 0,
            Z_STREAM_END: 1,
            Z_NEED_DICT: 2,
            Z_ERRNO: -1,
            Z_STREAM_ERROR: -2,
            Z_DATA_ERROR: -3,
            //Z_MEM_ERROR:     -4,
            Z_BUF_ERROR: -5,
            //Z_VERSION_ERROR: -6,
            /* compression levels */
            Z_NO_COMPRESSION: 0,
            Z_BEST_SPEED: 1,
            Z_BEST_COMPRESSION: 9,
            Z_DEFAULT_COMPRESSION: -1,
            Z_FILTERED: 1,
            Z_HUFFMAN_ONLY: 2,
            Z_RLE: 3,
            Z_FIXED: 4,
            Z_DEFAULT_STRATEGY: 0,
            /* Possible values of the data_type field (though see inflate()) */
            Z_BINARY: 0,
            Z_TEXT: 1,
            //Z_ASCII:                1, // = Z_TEXT (deprecated)
            Z_UNKNOWN: 2,
            /* The deflate compression method */
            Z_DEFLATED: 8
            //Z_NULL:                 null // Use -1 or null inline, depending on var type
          };
        },
        {}
      ],
      5: [
        function(require2, module2, exports2) {
          "use strict";
          function makeTable() {
            var c2, table = [];
            for (var n2 = 0; n2 < 256; n2++) {
              c2 = n2;
              for (var k2 = 0; k2 < 8; k2++) {
                c2 = c2 & 1 ? 3988292384 ^ c2 >>> 1 : c2 >>> 1;
              }
              table[n2] = c2;
            }
            return table;
          }
          var crcTable = makeTable();
          function crc32(crc, buf, len, pos) {
            var t3 = crcTable, end = pos + len;
            crc ^= -1;
            for (var i2 = pos; i2 < end; i2++) {
              crc = crc >>> 8 ^ t3[(crc ^ buf[i2]) & 255];
            }
            return crc ^ -1;
          }
          module2.exports = crc32;
        },
        {}
      ],
      6: [
        function(require2, module2, exports2) {
          "use strict";
          function GZheader() {
            this.text = 0;
            this.time = 0;
            this.xflags = 0;
            this.os = 0;
            this.extra = null;
            this.extra_len = 0;
            this.name = "";
            this.comment = "";
            this.hcrc = 0;
            this.done = false;
          }
          module2.exports = GZheader;
        },
        {}
      ],
      7: [
        function(require2, module2, exports2) {
          "use strict";
          var BAD = 30;
          var TYPE = 12;
          module2.exports = function inflate_fast(strm, start) {
            var state;
            var _in;
            var last;
            var _out;
            var beg;
            var end;
            var dmax;
            var wsize;
            var whave;
            var wnext;
            var s_window;
            var hold;
            var bits;
            var lcode;
            var dcode;
            var lmask;
            var dmask;
            var here;
            var op;
            var len;
            var dist;
            var from;
            var from_source;
            var input, output;
            state = strm.state;
            _in = strm.next_in;
            input = strm.input;
            last = _in + (strm.avail_in - 5);
            _out = strm.next_out;
            output = strm.output;
            beg = _out - (start - strm.avail_out);
            end = _out + (strm.avail_out - 257);
            dmax = state.dmax;
            wsize = state.wsize;
            whave = state.whave;
            wnext = state.wnext;
            s_window = state.window;
            hold = state.hold;
            bits = state.bits;
            lcode = state.lencode;
            dcode = state.distcode;
            lmask = (1 << state.lenbits) - 1;
            dmask = (1 << state.distbits) - 1;
            top: do {
              if (bits < 15) {
                hold += input[_in++] << bits;
                bits += 8;
                hold += input[_in++] << bits;
                bits += 8;
              }
              here = lcode[hold & lmask];
              dolen: for (; ; ) {
                op = here >>> 24;
                hold >>>= op;
                bits -= op;
                op = here >>> 16 & 255;
                if (op === 0) {
                  output[_out++] = here & 65535;
                } else if (op & 16) {
                  len = here & 65535;
                  op &= 15;
                  if (op) {
                    if (bits < op) {
                      hold += input[_in++] << bits;
                      bits += 8;
                    }
                    len += hold & (1 << op) - 1;
                    hold >>>= op;
                    bits -= op;
                  }
                  if (bits < 15) {
                    hold += input[_in++] << bits;
                    bits += 8;
                    hold += input[_in++] << bits;
                    bits += 8;
                  }
                  here = dcode[hold & dmask];
                  dodist: for (; ; ) {
                    op = here >>> 24;
                    hold >>>= op;
                    bits -= op;
                    op = here >>> 16 & 255;
                    if (op & 16) {
                      dist = here & 65535;
                      op &= 15;
                      if (bits < op) {
                        hold += input[_in++] << bits;
                        bits += 8;
                        if (bits < op) {
                          hold += input[_in++] << bits;
                          bits += 8;
                        }
                      }
                      dist += hold & (1 << op) - 1;
                      if (dist > dmax) {
                        strm.msg = "invalid distance too far back";
                        state.mode = BAD;
                        break top;
                      }
                      hold >>>= op;
                      bits -= op;
                      op = _out - beg;
                      if (dist > op) {
                        op = dist - op;
                        if (op > whave) {
                          if (state.sane) {
                            strm.msg = "invalid distance too far back";
                            state.mode = BAD;
                            break top;
                          }
                        }
                        from = 0;
                        from_source = s_window;
                        if (wnext === 0) {
                          from += wsize - op;
                          if (op < len) {
                            len -= op;
                            do {
                              output[_out++] = s_window[from++];
                            } while (--op);
                            from = _out - dist;
                            from_source = output;
                          }
                        } else if (wnext < op) {
                          from += wsize + wnext - op;
                          op -= wnext;
                          if (op < len) {
                            len -= op;
                            do {
                              output[_out++] = s_window[from++];
                            } while (--op);
                            from = 0;
                            if (wnext < len) {
                              op = wnext;
                              len -= op;
                              do {
                                output[_out++] = s_window[from++];
                              } while (--op);
                              from = _out - dist;
                              from_source = output;
                            }
                          }
                        } else {
                          from += wnext - op;
                          if (op < len) {
                            len -= op;
                            do {
                              output[_out++] = s_window[from++];
                            } while (--op);
                            from = _out - dist;
                            from_source = output;
                          }
                        }
                        while (len > 2) {
                          output[_out++] = from_source[from++];
                          output[_out++] = from_source[from++];
                          output[_out++] = from_source[from++];
                          len -= 3;
                        }
                        if (len) {
                          output[_out++] = from_source[from++];
                          if (len > 1) {
                            output[_out++] = from_source[from++];
                          }
                        }
                      } else {
                        from = _out - dist;
                        do {
                          output[_out++] = output[from++];
                          output[_out++] = output[from++];
                          output[_out++] = output[from++];
                          len -= 3;
                        } while (len > 2);
                        if (len) {
                          output[_out++] = output[from++];
                          if (len > 1) {
                            output[_out++] = output[from++];
                          }
                        }
                      }
                    } else if ((op & 64) === 0) {
                      here = dcode[(here & 65535) + (hold & (1 << op) - 1)];
                      continue dodist;
                    } else {
                      strm.msg = "invalid distance code";
                      state.mode = BAD;
                      break top;
                    }
                    break;
                  }
                } else if ((op & 64) === 0) {
                  here = lcode[(here & 65535) + (hold & (1 << op) - 1)];
                  continue dolen;
                } else if (op & 32) {
                  state.mode = TYPE;
                  break top;
                } else {
                  strm.msg = "invalid literal/length code";
                  state.mode = BAD;
                  break top;
                }
                break;
              }
            } while (_in < last && _out < end);
            len = bits >> 3;
            _in -= len;
            bits -= len << 3;
            hold &= (1 << bits) - 1;
            strm.next_in = _in;
            strm.next_out = _out;
            strm.avail_in = _in < last ? 5 + (last - _in) : 5 - (_in - last);
            strm.avail_out = _out < end ? 257 + (end - _out) : 257 - (_out - end);
            state.hold = hold;
            state.bits = bits;
            return;
          };
        },
        {}
      ],
      8: [
        function(require2, module2, exports2) {
          "use strict";
          var utils = require2("../utils/common");
          var adler32 = require2("./adler32");
          var crc32 = require2("./crc32");
          var inflate_fast = require2("./inffast");
          var inflate_table = require2("./inftrees");
          var CODES = 0;
          var LENS = 1;
          var DISTS = 2;
          var Z_FINISH = 4;
          var Z_BLOCK = 5;
          var Z_TREES = 6;
          var Z_OK = 0;
          var Z_STREAM_END = 1;
          var Z_NEED_DICT = 2;
          var Z_STREAM_ERROR = -2;
          var Z_DATA_ERROR = -3;
          var Z_MEM_ERROR = -4;
          var Z_BUF_ERROR = -5;
          var Z_DEFLATED = 8;
          var HEAD = 1;
          var FLAGS = 2;
          var TIME = 3;
          var OS = 4;
          var EXLEN = 5;
          var EXTRA = 6;
          var NAME = 7;
          var COMMENT = 8;
          var HCRC = 9;
          var DICTID = 10;
          var DICT = 11;
          var TYPE = 12;
          var TYPEDO = 13;
          var STORED = 14;
          var COPY_ = 15;
          var COPY = 16;
          var TABLE = 17;
          var LENLENS = 18;
          var CODELENS = 19;
          var LEN_ = 20;
          var LEN = 21;
          var LENEXT = 22;
          var DIST = 23;
          var DISTEXT = 24;
          var MATCH = 25;
          var LIT = 26;
          var CHECK = 27;
          var LENGTH = 28;
          var DONE = 29;
          var BAD = 30;
          var MEM = 31;
          var SYNC = 32;
          var ENOUGH_LENS = 852;
          var ENOUGH_DISTS = 592;
          var MAX_WBITS = 15;
          var DEF_WBITS = MAX_WBITS;
          function zswap32(q) {
            return (q >>> 24 & 255) + (q >>> 8 & 65280) + ((q & 65280) << 8) + ((q & 255) << 24);
          }
          function InflateState() {
            this.mode = 0;
            this.last = false;
            this.wrap = 0;
            this.havedict = false;
            this.flags = 0;
            this.dmax = 0;
            this.check = 0;
            this.total = 0;
            this.head = null;
            this.wbits = 0;
            this.wsize = 0;
            this.whave = 0;
            this.wnext = 0;
            this.window = null;
            this.hold = 0;
            this.bits = 0;
            this.length = 0;
            this.offset = 0;
            this.extra = 0;
            this.lencode = null;
            this.distcode = null;
            this.lenbits = 0;
            this.distbits = 0;
            this.ncode = 0;
            this.nlen = 0;
            this.ndist = 0;
            this.have = 0;
            this.next = null;
            this.lens = new utils.Buf16(
              320
            );
            this.work = new utils.Buf16(
              288
            );
            this.lendyn = null;
            this.distdyn = null;
            this.sane = 0;
            this.back = 0;
            this.was = 0;
          }
          function inflateResetKeep(strm) {
            var state;
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            strm.total_in = strm.total_out = state.total = 0;
            strm.msg = "";
            if (state.wrap) {
              strm.adler = state.wrap & 1;
            }
            state.mode = HEAD;
            state.last = 0;
            state.havedict = 0;
            state.dmax = 32768;
            state.head = null;
            state.hold = 0;
            state.bits = 0;
            state.lencode = state.lendyn = new utils.Buf32(
              ENOUGH_LENS
            );
            state.distcode = state.distdyn = new utils.Buf32(
              ENOUGH_DISTS
            );
            state.sane = 1;
            state.back = -1;
            return Z_OK;
          }
          function inflateReset(strm) {
            var state;
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            state.wsize = 0;
            state.whave = 0;
            state.wnext = 0;
            return inflateResetKeep(strm);
          }
          function inflateReset2(strm, windowBits) {
            var wrap;
            var state;
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            if (windowBits < 0) {
              wrap = 0;
              windowBits = -windowBits;
            } else {
              wrap = (windowBits >> 4) + 1;
              if (windowBits < 48) {
                windowBits &= 15;
              }
            }
            if (windowBits && (windowBits < 8 || windowBits > 15)) {
              return Z_STREAM_ERROR;
            }
            if (state.window !== null && state.wbits !== windowBits) {
              state.window = null;
            }
            state.wrap = wrap;
            state.wbits = windowBits;
            return inflateReset(strm);
          }
          function inflateInit2(strm, windowBits) {
            var ret;
            var state;
            if (!strm) {
              return Z_STREAM_ERROR;
            }
            state = new InflateState();
            strm.state = state;
            state.window = null;
            ret = inflateReset2(strm, windowBits);
            if (ret !== Z_OK) {
              strm.state = null;
            }
            return ret;
          }
          function inflateInit(strm) {
            return inflateInit2(strm, DEF_WBITS);
          }
          var virgin = true;
          var lenfix, distfix;
          function fixedtables(state) {
            if (virgin) {
              var sym;
              lenfix = new utils.Buf32(512);
              distfix = new utils.Buf32(32);
              sym = 0;
              while (sym < 144) {
                state.lens[sym++] = 8;
              }
              while (sym < 256) {
                state.lens[sym++] = 9;
              }
              while (sym < 280) {
                state.lens[sym++] = 7;
              }
              while (sym < 288) {
                state.lens[sym++] = 8;
              }
              inflate_table(
                LENS,
                state.lens,
                0,
                288,
                lenfix,
                0,
                state.work,
                { bits: 9 }
              );
              sym = 0;
              while (sym < 32) {
                state.lens[sym++] = 5;
              }
              inflate_table(
                DISTS,
                state.lens,
                0,
                32,
                distfix,
                0,
                state.work,
                { bits: 5 }
              );
              virgin = false;
            }
            state.lencode = lenfix;
            state.lenbits = 9;
            state.distcode = distfix;
            state.distbits = 5;
          }
          function updatewindow(strm, src, end, copy) {
            var dist;
            var state = strm.state;
            if (state.window === null) {
              state.wsize = 1 << state.wbits;
              state.wnext = 0;
              state.whave = 0;
              state.window = new utils.Buf8(state.wsize);
            }
            if (copy >= state.wsize) {
              utils.arraySet(
                state.window,
                src,
                end - state.wsize,
                state.wsize,
                0
              );
              state.wnext = 0;
              state.whave = state.wsize;
            } else {
              dist = state.wsize - state.wnext;
              if (dist > copy) {
                dist = copy;
              }
              utils.arraySet(
                state.window,
                src,
                end - copy,
                dist,
                state.wnext
              );
              copy -= dist;
              if (copy) {
                utils.arraySet(
                  state.window,
                  src,
                  end - copy,
                  copy,
                  0
                );
                state.wnext = copy;
                state.whave = state.wsize;
              } else {
                state.wnext += dist;
                if (state.wnext === state.wsize) {
                  state.wnext = 0;
                }
                if (state.whave < state.wsize) {
                  state.whave += dist;
                }
              }
            }
            return 0;
          }
          function inflate(strm, flush) {
            var state;
            var input, output;
            var next;
            var put;
            var have, left;
            var hold;
            var bits;
            var _in, _out;
            var copy;
            var from;
            var from_source;
            var here = 0;
            var here_bits, here_op, here_val;
            var last_bits, last_op, last_val;
            var len;
            var ret;
            var hbuf = new utils.Buf8(
              4
            );
            var opts;
            var n2;
            var order = (
              /* permutation of code lengths */
              [
                16,
                17,
                18,
                0,
                8,
                7,
                9,
                6,
                10,
                5,
                11,
                4,
                12,
                3,
                13,
                2,
                14,
                1,
                15
              ]
            );
            if (!strm || !strm.state || !strm.output || !strm.input && strm.avail_in !== 0) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            if (state.mode === TYPE) {
              state.mode = TYPEDO;
            }
            put = strm.next_out;
            output = strm.output;
            left = strm.avail_out;
            next = strm.next_in;
            input = strm.input;
            have = strm.avail_in;
            hold = state.hold;
            bits = state.bits;
            _in = have;
            _out = left;
            ret = Z_OK;
            inf_leave: for (; ; ) {
              switch (state.mode) {
                case HEAD:
                  if (state.wrap === 0) {
                    state.mode = TYPEDO;
                    break;
                  }
                  while (bits < 16) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if (state.wrap & 2 && hold === 35615) {
                    state.check = 0;
                    hbuf[0] = hold & 255;
                    hbuf[1] = hold >>> 8 & 255;
                    state.check = crc32(
                      state.check,
                      hbuf,
                      2,
                      0
                    );
                    hold = 0;
                    bits = 0;
                    state.mode = FLAGS;
                    break;
                  }
                  state.flags = 0;
                  if (state.head) {
                    state.head.done = false;
                  }
                  if (!(state.wrap & 1) || (((hold & 255) << 8) + (hold >> 8)) % 31) {
                    strm.msg = "incorrect header check";
                    state.mode = BAD;
                    break;
                  }
                  if ((hold & 15) !== Z_DEFLATED) {
                    strm.msg = "unknown compression method";
                    state.mode = BAD;
                    break;
                  }
                  hold >>>= 4;
                  bits -= 4;
                  len = (hold & 15) + 8;
                  if (state.wbits === 0) {
                    state.wbits = len;
                  } else if (len > state.wbits) {
                    strm.msg = "invalid window size";
                    state.mode = BAD;
                    break;
                  }
                  state.dmax = 1 << len;
                  strm.adler = state.check = 1;
                  state.mode = hold & 512 ? DICTID : TYPE;
                  hold = 0;
                  bits = 0;
                  break;
                case FLAGS:
                  while (bits < 16) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  state.flags = hold;
                  if ((state.flags & 255) !== Z_DEFLATED) {
                    strm.msg = "unknown compression method";
                    state.mode = BAD;
                    break;
                  }
                  if (state.flags & 57344) {
                    strm.msg = "unknown header flags set";
                    state.mode = BAD;
                    break;
                  }
                  if (state.head) {
                    state.head.text = hold >> 8 & 1;
                  }
                  if (state.flags & 512) {
                    hbuf[0] = hold & 255;
                    hbuf[1] = hold >>> 8 & 255;
                    state.check = crc32(
                      state.check,
                      hbuf,
                      2,
                      0
                    );
                  }
                  hold = 0;
                  bits = 0;
                  state.mode = TIME;
                /* falls through */
                case TIME:
                  while (bits < 32) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if (state.head) {
                    state.head.time = hold;
                  }
                  if (state.flags & 512) {
                    hbuf[0] = hold & 255;
                    hbuf[1] = hold >>> 8 & 255;
                    hbuf[2] = hold >>> 16 & 255;
                    hbuf[3] = hold >>> 24 & 255;
                    state.check = crc32(
                      state.check,
                      hbuf,
                      4,
                      0
                    );
                  }
                  hold = 0;
                  bits = 0;
                  state.mode = OS;
                /* falls through */
                case OS:
                  while (bits < 16) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if (state.head) {
                    state.head.xflags = hold & 255;
                    state.head.os = hold >> 8;
                  }
                  if (state.flags & 512) {
                    hbuf[0] = hold & 255;
                    hbuf[1] = hold >>> 8 & 255;
                    state.check = crc32(
                      state.check,
                      hbuf,
                      2,
                      0
                    );
                  }
                  hold = 0;
                  bits = 0;
                  state.mode = EXLEN;
                /* falls through */
                case EXLEN:
                  if (state.flags & 1024) {
                    while (bits < 16) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.length = hold;
                    if (state.head) {
                      state.head.extra_len = hold;
                    }
                    if (state.flags & 512) {
                      hbuf[0] = hold & 255;
                      hbuf[1] = hold >>> 8 & 255;
                      state.check = crc32(
                        state.check,
                        hbuf,
                        2,
                        0
                      );
                    }
                    hold = 0;
                    bits = 0;
                  } else if (state.head) {
                    state.head.extra = null;
                  }
                  state.mode = EXTRA;
                /* falls through */
                case EXTRA:
                  if (state.flags & 1024) {
                    copy = state.length;
                    if (copy > have) {
                      copy = have;
                    }
                    if (copy) {
                      if (state.head) {
                        len = state.head.extra_len - state.length;
                        if (!state.head.extra) {
                          state.head.extra = new Array(
                            state.head.extra_len
                          );
                        }
                        utils.arraySet(
                          state.head.extra,
                          input,
                          next,
                          // extra field is limited to 65536 bytes
                          // - no need for additional size check
                          copy,
                          /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
                          len
                        );
                      }
                      if (state.flags & 512) {
                        state.check = crc32(
                          state.check,
                          input,
                          copy,
                          next
                        );
                      }
                      have -= copy;
                      next += copy;
                      state.length -= copy;
                    }
                    if (state.length) {
                      break inf_leave;
                    }
                  }
                  state.length = 0;
                  state.mode = NAME;
                /* falls through */
                case NAME:
                  if (state.flags & 2048) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    copy = 0;
                    do {
                      len = input[next + copy++];
                      if (state.head && len && state.length < 65536) {
                        state.head.name += String.fromCharCode(len);
                      }
                    } while (len && copy < have);
                    if (state.flags & 512) {
                      state.check = crc32(
                        state.check,
                        input,
                        copy,
                        next
                      );
                    }
                    have -= copy;
                    next += copy;
                    if (len) {
                      break inf_leave;
                    }
                  } else if (state.head) {
                    state.head.name = null;
                  }
                  state.length = 0;
                  state.mode = COMMENT;
                /* falls through */
                case COMMENT:
                  if (state.flags & 4096) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    copy = 0;
                    do {
                      len = input[next + copy++];
                      if (state.head && len && state.length < 65536) {
                        state.head.comment += String.fromCharCode(len);
                      }
                    } while (len && copy < have);
                    if (state.flags & 512) {
                      state.check = crc32(
                        state.check,
                        input,
                        copy,
                        next
                      );
                    }
                    have -= copy;
                    next += copy;
                    if (len) {
                      break inf_leave;
                    }
                  } else if (state.head) {
                    state.head.comment = null;
                  }
                  state.mode = HCRC;
                /* falls through */
                case HCRC:
                  if (state.flags & 512) {
                    while (bits < 16) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (hold !== (state.check & 65535)) {
                      strm.msg = "header crc mismatch";
                      state.mode = BAD;
                      break;
                    }
                    hold = 0;
                    bits = 0;
                  }
                  if (state.head) {
                    state.head.hcrc = state.flags >> 9 & 1;
                    state.head.done = true;
                  }
                  strm.adler = state.check = 0;
                  state.mode = TYPE;
                  break;
                case DICTID:
                  while (bits < 32) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  strm.adler = state.check = zswap32(hold);
                  hold = 0;
                  bits = 0;
                  state.mode = DICT;
                /* falls through */
                case DICT:
                  if (state.havedict === 0) {
                    strm.next_out = put;
                    strm.avail_out = left;
                    strm.next_in = next;
                    strm.avail_in = have;
                    state.hold = hold;
                    state.bits = bits;
                    return Z_NEED_DICT;
                  }
                  strm.adler = state.check = 1;
                  state.mode = TYPE;
                /* falls through */
                case TYPE:
                  if (flush === Z_BLOCK || flush === Z_TREES) {
                    break inf_leave;
                  }
                /* falls through */
                case TYPEDO:
                  if (state.last) {
                    hold >>>= bits & 7;
                    bits -= bits & 7;
                    state.mode = CHECK;
                    break;
                  }
                  while (bits < 3) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  state.last = hold & 1;
                  hold >>>= 1;
                  bits -= 1;
                  switch (hold & 3) {
                    case 0:
                      state.mode = STORED;
                      break;
                    case 1:
                      fixedtables(state);
                      state.mode = LEN_;
                      if (flush === Z_TREES) {
                        hold >>>= 2;
                        bits -= 2;
                        break inf_leave;
                      }
                      break;
                    case 2:
                      state.mode = TABLE;
                      break;
                    case 3:
                      strm.msg = "invalid block type";
                      state.mode = BAD;
                  }
                  hold >>>= 2;
                  bits -= 2;
                  break;
                case STORED:
                  hold >>>= bits & 7;
                  bits -= bits & 7;
                  while (bits < 32) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if ((hold & 65535) !== (hold >>> 16 ^ 65535)) {
                    strm.msg = "invalid stored block lengths";
                    state.mode = BAD;
                    break;
                  }
                  state.length = hold & 65535;
                  hold = 0;
                  bits = 0;
                  state.mode = COPY_;
                  if (flush === Z_TREES) {
                    break inf_leave;
                  }
                /* falls through */
                case COPY_:
                  state.mode = COPY;
                /* falls through */
                case COPY:
                  copy = state.length;
                  if (copy) {
                    if (copy > have) {
                      copy = have;
                    }
                    if (copy > left) {
                      copy = left;
                    }
                    if (copy === 0) {
                      break inf_leave;
                    }
                    utils.arraySet(
                      output,
                      input,
                      next,
                      copy,
                      put
                    );
                    have -= copy;
                    next += copy;
                    left -= copy;
                    put += copy;
                    state.length -= copy;
                    break;
                  }
                  state.mode = TYPE;
                  break;
                case TABLE:
                  while (bits < 14) {
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  state.nlen = (hold & 31) + 257;
                  hold >>>= 5;
                  bits -= 5;
                  state.ndist = (hold & 31) + 1;
                  hold >>>= 5;
                  bits -= 5;
                  state.ncode = (hold & 15) + 4;
                  hold >>>= 4;
                  bits -= 4;
                  if (state.nlen > 286 || state.ndist > 30) {
                    strm.msg = "too many length or distance symbols";
                    state.mode = BAD;
                    break;
                  }
                  state.have = 0;
                  state.mode = LENLENS;
                /* falls through */
                case LENLENS:
                  while (state.have < state.ncode) {
                    while (bits < 3) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.lens[order[state.have++]] = hold & 7;
                    hold >>>= 3;
                    bits -= 3;
                  }
                  while (state.have < 19) {
                    state.lens[order[state.have++]] = 0;
                  }
                  state.lencode = state.lendyn;
                  state.lenbits = 7;
                  opts = { bits: state.lenbits };
                  ret = inflate_table(
                    CODES,
                    state.lens,
                    0,
                    19,
                    state.lencode,
                    0,
                    state.work,
                    opts
                  );
                  state.lenbits = opts.bits;
                  if (ret) {
                    strm.msg = "invalid code lengths set";
                    state.mode = BAD;
                    break;
                  }
                  state.have = 0;
                  state.mode = CODELENS;
                /* falls through */
                case CODELENS:
                  while (state.have < state.nlen + state.ndist) {
                    for (; ; ) {
                      here = state.lencode[hold & (1 << state.lenbits) - 1];
                      here_bits = here >>> 24;
                      here_op = here >>> 16 & 255;
                      here_val = here & 65535;
                      if (here_bits <= bits) {
                        break;
                      }
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (here_val < 16) {
                      hold >>>= here_bits;
                      bits -= here_bits;
                      state.lens[state.have++] = here_val;
                    } else {
                      if (here_val === 16) {
                        n2 = here_bits + 2;
                        while (bits < n2) {
                          if (have === 0) {
                            break inf_leave;
                          }
                          have--;
                          hold += input[next++] << bits;
                          bits += 8;
                        }
                        hold >>>= here_bits;
                        bits -= here_bits;
                        if (state.have === 0) {
                          strm.msg = "invalid bit length repeat";
                          state.mode = BAD;
                          break;
                        }
                        len = state.lens[state.have - 1];
                        copy = 3 + (hold & 3);
                        hold >>>= 2;
                        bits -= 2;
                      } else if (here_val === 17) {
                        n2 = here_bits + 3;
                        while (bits < n2) {
                          if (have === 0) {
                            break inf_leave;
                          }
                          have--;
                          hold += input[next++] << bits;
                          bits += 8;
                        }
                        hold >>>= here_bits;
                        bits -= here_bits;
                        len = 0;
                        copy = 3 + (hold & 7);
                        hold >>>= 3;
                        bits -= 3;
                      } else {
                        n2 = here_bits + 7;
                        while (bits < n2) {
                          if (have === 0) {
                            break inf_leave;
                          }
                          have--;
                          hold += input[next++] << bits;
                          bits += 8;
                        }
                        hold >>>= here_bits;
                        bits -= here_bits;
                        len = 0;
                        copy = 11 + (hold & 127);
                        hold >>>= 7;
                        bits -= 7;
                      }
                      if (state.have + copy > state.nlen + state.ndist) {
                        strm.msg = "invalid bit length repeat";
                        state.mode = BAD;
                        break;
                      }
                      while (copy--) {
                        state.lens[state.have++] = len;
                      }
                    }
                  }
                  if (state.mode === BAD) {
                    break;
                  }
                  if (state.lens[256] === 0) {
                    strm.msg = "invalid code -- missing end-of-block";
                    state.mode = BAD;
                    break;
                  }
                  state.lenbits = 9;
                  opts = { bits: state.lenbits };
                  ret = inflate_table(
                    LENS,
                    state.lens,
                    0,
                    state.nlen,
                    state.lencode,
                    0,
                    state.work,
                    opts
                  );
                  state.lenbits = opts.bits;
                  if (ret) {
                    strm.msg = "invalid literal/lengths set";
                    state.mode = BAD;
                    break;
                  }
                  state.distbits = 6;
                  state.distcode = state.distdyn;
                  opts = { bits: state.distbits };
                  ret = inflate_table(
                    DISTS,
                    state.lens,
                    state.nlen,
                    state.ndist,
                    state.distcode,
                    0,
                    state.work,
                    opts
                  );
                  state.distbits = opts.bits;
                  if (ret) {
                    strm.msg = "invalid distances set";
                    state.mode = BAD;
                    break;
                  }
                  state.mode = LEN_;
                  if (flush === Z_TREES) {
                    break inf_leave;
                  }
                /* falls through */
                case LEN_:
                  state.mode = LEN;
                /* falls through */
                case LEN:
                  if (have >= 6 && left >= 258) {
                    strm.next_out = put;
                    strm.avail_out = left;
                    strm.next_in = next;
                    strm.avail_in = have;
                    state.hold = hold;
                    state.bits = bits;
                    inflate_fast(strm, _out);
                    put = strm.next_out;
                    output = strm.output;
                    left = strm.avail_out;
                    next = strm.next_in;
                    input = strm.input;
                    have = strm.avail_in;
                    hold = state.hold;
                    bits = state.bits;
                    if (state.mode === TYPE) {
                      state.back = -1;
                    }
                    break;
                  }
                  state.back = 0;
                  for (; ; ) {
                    here = state.lencode[hold & (1 << state.lenbits) - 1];
                    here_bits = here >>> 24;
                    here_op = here >>> 16 & 255;
                    here_val = here & 65535;
                    if (here_bits <= bits) {
                      break;
                    }
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if (here_op && (here_op & 240) === 0) {
                    last_bits = here_bits;
                    last_op = here_op;
                    last_val = here_val;
                    for (; ; ) {
                      here = state.lencode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
                      here_bits = here >>> 24;
                      here_op = here >>> 16 & 255;
                      here_val = here & 65535;
                      if (last_bits + here_bits <= bits) {
                        break;
                      }
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    hold >>>= last_bits;
                    bits -= last_bits;
                    state.back += last_bits;
                  }
                  hold >>>= here_bits;
                  bits -= here_bits;
                  state.back += here_bits;
                  state.length = here_val;
                  if (here_op === 0) {
                    state.mode = LIT;
                    break;
                  }
                  if (here_op & 32) {
                    state.back = -1;
                    state.mode = TYPE;
                    break;
                  }
                  if (here_op & 64) {
                    strm.msg = "invalid literal/length code";
                    state.mode = BAD;
                    break;
                  }
                  state.extra = here_op & 15;
                  state.mode = LENEXT;
                /* falls through */
                case LENEXT:
                  if (state.extra) {
                    n2 = state.extra;
                    while (bits < n2) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.length += hold & (1 << state.extra) - 1;
                    hold >>>= state.extra;
                    bits -= state.extra;
                    state.back += state.extra;
                  }
                  state.was = state.length;
                  state.mode = DIST;
                /* falls through */
                case DIST:
                  for (; ; ) {
                    here = state.distcode[hold & (1 << state.distbits) - 1];
                    here_bits = here >>> 24;
                    here_op = here >>> 16 & 255;
                    here_val = here & 65535;
                    if (here_bits <= bits) {
                      break;
                    }
                    if (have === 0) {
                      break inf_leave;
                    }
                    have--;
                    hold += input[next++] << bits;
                    bits += 8;
                  }
                  if ((here_op & 240) === 0) {
                    last_bits = here_bits;
                    last_op = here_op;
                    last_val = here_val;
                    for (; ; ) {
                      here = state.distcode[last_val + ((hold & (1 << last_bits + last_op) - 1) >> last_bits)];
                      here_bits = here >>> 24;
                      here_op = here >>> 16 & 255;
                      here_val = here & 65535;
                      if (last_bits + here_bits <= bits) {
                        break;
                      }
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    hold >>>= last_bits;
                    bits -= last_bits;
                    state.back += last_bits;
                  }
                  hold >>>= here_bits;
                  bits -= here_bits;
                  state.back += here_bits;
                  if (here_op & 64) {
                    strm.msg = "invalid distance code";
                    state.mode = BAD;
                    break;
                  }
                  state.offset = here_val;
                  state.extra = here_op & 15;
                  state.mode = DISTEXT;
                /* falls through */
                case DISTEXT:
                  if (state.extra) {
                    n2 = state.extra;
                    while (bits < n2) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    state.offset += hold & (1 << state.extra) - 1;
                    hold >>>= state.extra;
                    bits -= state.extra;
                    state.back += state.extra;
                  }
                  if (state.offset > state.dmax) {
                    strm.msg = "invalid distance too far back";
                    state.mode = BAD;
                    break;
                  }
                  state.mode = MATCH;
                /* falls through */
                case MATCH:
                  if (left === 0) {
                    break inf_leave;
                  }
                  copy = _out - left;
                  if (state.offset > copy) {
                    copy = state.offset - copy;
                    if (copy > state.whave) {
                      if (state.sane) {
                        strm.msg = "invalid distance too far back";
                        state.mode = BAD;
                        break;
                      }
                    }
                    if (copy > state.wnext) {
                      copy -= state.wnext;
                      from = state.wsize - copy;
                    } else {
                      from = state.wnext - copy;
                    }
                    if (copy > state.length) {
                      copy = state.length;
                    }
                    from_source = state.window;
                  } else {
                    from_source = output;
                    from = put - state.offset;
                    copy = state.length;
                  }
                  if (copy > left) {
                    copy = left;
                  }
                  left -= copy;
                  state.length -= copy;
                  do {
                    output[put++] = from_source[from++];
                  } while (--copy);
                  if (state.length === 0) {
                    state.mode = LEN;
                  }
                  break;
                case LIT:
                  if (left === 0) {
                    break inf_leave;
                  }
                  output[put++] = state.length;
                  left--;
                  state.mode = LEN;
                  break;
                case CHECK:
                  if (state.wrap) {
                    while (bits < 32) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold |= input[next++] << bits;
                      bits += 8;
                    }
                    _out -= left;
                    strm.total_out += _out;
                    state.total += _out;
                    if (_out) {
                      strm.adler = state.check = /*UPDATE(state.check, put - _out, _out);*/
                      state.flags ? crc32(
                        state.check,
                        output,
                        _out,
                        put - _out
                      ) : adler32(
                        state.check,
                        output,
                        _out,
                        put - _out
                      );
                    }
                    _out = left;
                    if ((state.flags ? hold : zswap32(hold)) !== state.check) {
                      strm.msg = "incorrect data check";
                      state.mode = BAD;
                      break;
                    }
                    hold = 0;
                    bits = 0;
                  }
                  state.mode = LENGTH;
                /* falls through */
                case LENGTH:
                  if (state.wrap && state.flags) {
                    while (bits < 32) {
                      if (have === 0) {
                        break inf_leave;
                      }
                      have--;
                      hold += input[next++] << bits;
                      bits += 8;
                    }
                    if (hold !== (state.total & 4294967295)) {
                      strm.msg = "incorrect length check";
                      state.mode = BAD;
                      break;
                    }
                    hold = 0;
                    bits = 0;
                  }
                  state.mode = DONE;
                /* falls through */
                case DONE:
                  ret = Z_STREAM_END;
                  break inf_leave;
                case BAD:
                  ret = Z_DATA_ERROR;
                  break inf_leave;
                case MEM:
                  return Z_MEM_ERROR;
                case SYNC:
                /* falls through */
                default:
                  return Z_STREAM_ERROR;
              }
            }
            strm.next_out = put;
            strm.avail_out = left;
            strm.next_in = next;
            strm.avail_in = have;
            state.hold = hold;
            state.bits = bits;
            if (state.wsize || _out !== strm.avail_out && state.mode < BAD && (state.mode < CHECK || flush !== Z_FINISH)) {
              if (updatewindow(
                strm,
                strm.output,
                strm.next_out,
                _out - strm.avail_out
              )) {
                state.mode = MEM;
                return Z_MEM_ERROR;
              }
            }
            _in -= strm.avail_in;
            _out -= strm.avail_out;
            strm.total_in += _in;
            strm.total_out += _out;
            state.total += _out;
            if (state.wrap && _out) {
              strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
              state.flags ? crc32(
                state.check,
                output,
                _out,
                strm.next_out - _out
              ) : adler32(
                state.check,
                output,
                _out,
                strm.next_out - _out
              );
            }
            strm.data_type = state.bits + (state.last ? 64 : 0) + (state.mode === TYPE ? 128 : 0) + (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
            if ((_in === 0 && _out === 0 || flush === Z_FINISH) && ret === Z_OK) {
              ret = Z_BUF_ERROR;
            }
            return ret;
          }
          function inflateEnd(strm) {
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            var state = strm.state;
            if (state.window) {
              state.window = null;
            }
            strm.state = null;
            return Z_OK;
          }
          function inflateGetHeader(strm, head2) {
            var state;
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            if ((state.wrap & 2) === 0) {
              return Z_STREAM_ERROR;
            }
            state.head = head2;
            head2.done = false;
            return Z_OK;
          }
          function inflateSetDictionary(strm, dictionary) {
            var dictLength = dictionary.length;
            var state;
            var dictid;
            var ret;
            if (!strm || !strm.state) {
              return Z_STREAM_ERROR;
            }
            state = strm.state;
            if (state.wrap !== 0 && state.mode !== DICT) {
              return Z_STREAM_ERROR;
            }
            if (state.mode === DICT) {
              dictid = 1;
              dictid = adler32(
                dictid,
                dictionary,
                dictLength,
                0
              );
              if (dictid !== state.check) {
                return Z_DATA_ERROR;
              }
            }
            ret = updatewindow(
              strm,
              dictionary,
              dictLength,
              dictLength
            );
            if (ret) {
              state.mode = MEM;
              return Z_MEM_ERROR;
            }
            state.havedict = 1;
            return Z_OK;
          }
          exports2.inflateReset = inflateReset;
          exports2.inflateReset2 = inflateReset2;
          exports2.inflateResetKeep = inflateResetKeep;
          exports2.inflateInit = inflateInit;
          exports2.inflateInit2 = inflateInit2;
          exports2.inflate = inflate;
          exports2.inflateEnd = inflateEnd;
          exports2.inflateGetHeader = inflateGetHeader;
          exports2.inflateSetDictionary = inflateSetDictionary;
          exports2.inflateInfo = "pako inflate (from Nodeca project)";
        },
        {
          "../utils/common": 1,
          "./adler32": 3,
          "./crc32": 5,
          "./inffast": 7,
          "./inftrees": 9
        }
      ],
      9: [
        function(require2, module2, exports2) {
          "use strict";
          var utils = require2("../utils/common");
          var MAXBITS = 15;
          var ENOUGH_LENS = 852;
          var ENOUGH_DISTS = 592;
          var CODES = 0;
          var LENS = 1;
          var DISTS = 2;
          var lbase = [
            /* Length codes 257..285 base */
            3,
            4,
            5,
            6,
            7,
            8,
            9,
            10,
            11,
            13,
            15,
            17,
            19,
            23,
            27,
            31,
            35,
            43,
            51,
            59,
            67,
            83,
            99,
            115,
            131,
            163,
            195,
            227,
            258,
            0,
            0
          ];
          var lext = [
            /* Length codes 257..285 extra */
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            16,
            17,
            17,
            17,
            17,
            18,
            18,
            18,
            18,
            19,
            19,
            19,
            19,
            20,
            20,
            20,
            20,
            21,
            21,
            21,
            21,
            16,
            72,
            78
          ];
          var dbase = [
            /* Distance codes 0..29 base */
            1,
            2,
            3,
            4,
            5,
            7,
            9,
            13,
            17,
            25,
            33,
            49,
            65,
            97,
            129,
            193,
            257,
            385,
            513,
            769,
            1025,
            1537,
            2049,
            3073,
            4097,
            6145,
            8193,
            12289,
            16385,
            24577,
            0,
            0
          ];
          var dext = [
            /* Distance codes 0..29 extra */
            16,
            16,
            16,
            16,
            17,
            17,
            18,
            18,
            19,
            19,
            20,
            20,
            21,
            21,
            22,
            22,
            23,
            23,
            24,
            24,
            25,
            25,
            26,
            26,
            27,
            27,
            28,
            28,
            29,
            29,
            64,
            64
          ];
          module2.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts) {
            var bits = opts.bits;
            var len = 0;
            var sym = 0;
            var min2 = 0, max2 = 0;
            var root = 0;
            var curr = 0;
            var drop = 0;
            var left = 0;
            var used = 0;
            var huff = 0;
            var incr;
            var fill;
            var low;
            var mask;
            var next;
            var base = null;
            var base_index = 0;
            var end;
            var count = new utils.Buf16(MAXBITS + 1);
            var offs = new utils.Buf16(MAXBITS + 1);
            var extra = null;
            var extra_index = 0;
            var here_bits, here_op, here_val;
            for (len = 0; len <= MAXBITS; len++) {
              count[len] = 0;
            }
            for (sym = 0; sym < codes; sym++) {
              count[lens[lens_index + sym]]++;
            }
            root = bits;
            for (max2 = MAXBITS; max2 >= 1; max2--) {
              if (count[max2] !== 0) {
                break;
              }
            }
            if (root > max2) {
              root = max2;
            }
            if (max2 === 0) {
              table[table_index++] = 1 << 24 | 64 << 16 | 0;
              table[table_index++] = 1 << 24 | 64 << 16 | 0;
              opts.bits = 1;
              return 0;
            }
            for (min2 = 1; min2 < max2; min2++) {
              if (count[min2] !== 0) {
                break;
              }
            }
            if (root < min2) {
              root = min2;
            }
            left = 1;
            for (len = 1; len <= MAXBITS; len++) {
              left <<= 1;
              left -= count[len];
              if (left < 0) {
                return -1;
              }
            }
            if (left > 0 && (type === CODES || max2 !== 1)) {
              return -1;
            }
            offs[1] = 0;
            for (len = 1; len < MAXBITS; len++) {
              offs[len + 1] = offs[len] + count[len];
            }
            for (sym = 0; sym < codes; sym++) {
              if (lens[lens_index + sym] !== 0) {
                work[offs[lens[lens_index + sym]]++] = sym;
              }
            }
            if (type === CODES) {
              base = extra = work;
              end = 19;
            } else if (type === LENS) {
              base = lbase;
              base_index -= 257;
              extra = lext;
              extra_index -= 257;
              end = 256;
            } else {
              base = dbase;
              extra = dext;
              end = -1;
            }
            huff = 0;
            sym = 0;
            len = min2;
            next = table_index;
            curr = root;
            drop = 0;
            low = -1;
            used = 1 << root;
            mask = used - 1;
            if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
              return 1;
            }
            for (; ; ) {
              here_bits = len - drop;
              if (work[sym] < end) {
                here_op = 0;
                here_val = work[sym];
              } else if (work[sym] > end) {
                here_op = extra[extra_index + work[sym]];
                here_val = base[base_index + work[sym]];
              } else {
                here_op = 32 + 64;
                here_val = 0;
              }
              incr = 1 << len - drop;
              fill = 1 << curr;
              min2 = fill;
              do {
                fill -= incr;
                table[next + (huff >> drop) + fill] = here_bits << 24 | here_op << 16 | here_val | 0;
              } while (fill !== 0);
              incr = 1 << len - 1;
              while (huff & incr) {
                incr >>= 1;
              }
              if (incr !== 0) {
                huff &= incr - 1;
                huff += incr;
              } else {
                huff = 0;
              }
              sym++;
              if (--count[len] === 0) {
                if (len === max2) {
                  break;
                }
                len = lens[lens_index + work[sym]];
              }
              if (len > root && (huff & mask) !== low) {
                if (drop === 0) {
                  drop = root;
                }
                next += min2;
                curr = len - drop;
                left = 1 << curr;
                while (curr + drop < max2) {
                  left -= count[curr + drop];
                  if (left <= 0) {
                    break;
                  }
                  curr++;
                  left <<= 1;
                }
                used += 1 << curr;
                if (type === LENS && used > ENOUGH_LENS || type === DISTS && used > ENOUGH_DISTS) {
                  return 1;
                }
                low = huff & mask;
                table[low] = root << 24 | curr << 16 | next - table_index | 0;
              }
            }
            if (huff !== 0) {
              table[next + huff] = len - drop << 24 | 64 << 16 | 0;
            }
            opts.bits = root;
            return 0;
          };
        },
        { "../utils/common": 1 }
      ],
      10: [
        function(require2, module2, exports2) {
          "use strict";
          module2.exports = {
            2: "need dictionary",
            1: "stream end",
            0: "",
            "-1": "file error",
            "-2": "stream error",
            "-3": "data error",
            "-4": "insufficient memory",
            "-5": "buffer error",
            "-6": "incompatible version"
          };
        },
        {}
      ],
      11: [
        function(require2, module2, exports2) {
          "use strict";
          function ZStream() {
            this.input = null;
            this.next_in = 0;
            this.avail_in = 0;
            this.total_in = 0;
            this.output = null;
            this.next_out = 0;
            this.avail_out = 0;
            this.total_out = 0;
            this.msg = "";
            this.state = null;
            this.data_type = 2;
            this.adler = 0;
          }
          module2.exports = ZStream;
        },
        {}
      ],
      "/lib/inflate.js": [
        function(require2, module2, exports2) {
          "use strict";
          var zlib_inflate = require2("./zlib/inflate");
          var utils = require2("./utils/common");
          var strings = require2("./utils/strings");
          var c2 = require2("./zlib/constants");
          var msg = require2("./zlib/messages");
          var ZStream = require2("./zlib/zstream");
          var GZheader = require2("./zlib/gzheader");
          var toString = Object.prototype.toString;
          function Inflate(options) {
            if (!(this instanceof Inflate))
              return new Inflate(options);
            this.options = utils.assign(
              {
                chunkSize: 16384,
                windowBits: 0,
                to: ""
              },
              options || {}
            );
            var opt = this.options;
            if (opt.raw && opt.windowBits >= 0 && opt.windowBits < 16) {
              opt.windowBits = -opt.windowBits;
              if (opt.windowBits === 0) {
                opt.windowBits = -15;
              }
            }
            if (opt.windowBits >= 0 && opt.windowBits < 16 && !(options && options.windowBits)) {
              opt.windowBits += 32;
            }
            if (opt.windowBits > 15 && opt.windowBits < 48) {
              if ((opt.windowBits & 15) === 0) {
                opt.windowBits |= 15;
              }
            }
            this.err = 0;
            this.msg = "";
            this.ended = false;
            this.chunks = [];
            this.strm = new ZStream();
            this.strm.avail_out = 0;
            var status = zlib_inflate.inflateInit2(
              this.strm,
              opt.windowBits
            );
            if (status !== c2.Z_OK) {
              throw new Error(msg[status]);
            }
            this.header = new GZheader();
            zlib_inflate.inflateGetHeader(this.strm, this.header);
            if (opt.dictionary) {
              if (typeof opt.dictionary === "string") {
                opt.dictionary = strings.string2buf(
                  opt.dictionary
                );
              } else if (toString.call(opt.dictionary) === "[object ArrayBuffer]") {
                opt.dictionary = new Uint8Array(
                  opt.dictionary
                );
              }
              if (opt.raw) {
                status = zlib_inflate.inflateSetDictionary(
                  this.strm,
                  opt.dictionary
                );
                if (status !== c2.Z_OK) {
                  throw new Error(msg[status]);
                }
              }
            }
          }
          Inflate.prototype.push = function(data, mode) {
            var strm = this.strm;
            var chunkSize = this.options.chunkSize;
            var dictionary = this.options.dictionary;
            var status, _mode;
            var next_out_utf8, tail, utf8str;
            var allowBufError = false;
            if (this.ended) {
              return false;
            }
            _mode = mode === ~~mode ? mode : mode === true ? c2.Z_FINISH : c2.Z_NO_FLUSH;
            if (typeof data === "string") {
              strm.input = strings.binstring2buf(data);
            } else if (toString.call(data) === "[object ArrayBuffer]") {
              strm.input = new Uint8Array(data);
            } else {
              strm.input = data;
            }
            strm.next_in = 0;
            strm.avail_in = strm.input.length;
            do {
              if (strm.avail_out === 0) {
                strm.output = new utils.Buf8(chunkSize);
                strm.next_out = 0;
                strm.avail_out = chunkSize;
              }
              status = zlib_inflate.inflate(
                strm,
                c2.Z_NO_FLUSH
              );
              if (status === c2.Z_NEED_DICT && dictionary) {
                status = zlib_inflate.inflateSetDictionary(
                  this.strm,
                  dictionary
                );
              }
              if (status === c2.Z_BUF_ERROR && allowBufError === true) {
                status = c2.Z_OK;
                allowBufError = false;
              }
              if (status !== c2.Z_STREAM_END && status !== c2.Z_OK) {
                this.onEnd(status);
                this.ended = true;
                return false;
              }
              if (strm.next_out) {
                if (strm.avail_out === 0 || status === c2.Z_STREAM_END || strm.avail_in === 0 && (_mode === c2.Z_FINISH || _mode === c2.Z_SYNC_FLUSH)) {
                  if (this.options.to === "string") {
                    next_out_utf8 = strings.utf8border(
                      strm.output,
                      strm.next_out
                    );
                    tail = strm.next_out - next_out_utf8;
                    utf8str = strings.buf2string(
                      strm.output,
                      next_out_utf8
                    );
                    strm.next_out = tail;
                    strm.avail_out = chunkSize - tail;
                    if (tail) {
                      utils.arraySet(
                        strm.output,
                        strm.output,
                        next_out_utf8,
                        tail,
                        0
                      );
                    }
                    this.onData(utf8str);
                  } else {
                    this.onData(
                      utils.shrinkBuf(
                        strm.output,
                        strm.next_out
                      )
                    );
                  }
                }
              }
              if (strm.avail_in === 0 && strm.avail_out === 0) {
                allowBufError = true;
              }
            } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c2.Z_STREAM_END);
            if (status === c2.Z_STREAM_END) {
              _mode = c2.Z_FINISH;
            }
            if (_mode === c2.Z_FINISH) {
              status = zlib_inflate.inflateEnd(this.strm);
              this.onEnd(status);
              this.ended = true;
              return status === c2.Z_OK;
            }
            if (_mode === c2.Z_SYNC_FLUSH) {
              this.onEnd(c2.Z_OK);
              strm.avail_out = 0;
              return true;
            }
            return true;
          };
          Inflate.prototype.onData = function(chunk) {
            this.chunks.push(chunk);
          };
          Inflate.prototype.onEnd = function(status) {
            if (status === c2.Z_OK) {
              if (this.options.to === "string") {
                this.result = this.chunks.join("");
              } else {
                this.result = utils.flattenChunks(
                  this.chunks
                );
              }
            }
            this.chunks = [];
            this.err = status;
            this.msg = this.strm.msg;
          };
          function inflate(input, options) {
            var inflator = new Inflate(options);
            inflator.push(input, true);
            if (inflator.err) {
              throw inflator.msg || msg[inflator.err];
            }
            return inflator.result;
          }
          function inflateRaw(input, options) {
            options = options || {};
            options.raw = true;
            return inflate(input, options);
          }
          exports2.Inflate = Inflate;
          exports2.inflate = inflate;
          exports2.inflateRaw = inflateRaw;
          exports2.ungzip = inflate;
        },
        {
          "./utils/common": 1,
          "./utils/strings": 2,
          "./zlib/constants": 4,
          "./zlib/gzheader": 6,
          "./zlib/inflate": 8,
          "./zlib/messages": 10,
          "./zlib/zstream": 11
        }
      ]
    },
    {},
    []
  )("/lib/inflate.js");
})();

// packages/global-styles-ui/build-module/font-library/lib/lib-font.browser.mjs
var fetchFunction = globalThis.fetch;
var Event2 = class {
  constructor(type, detail = {}, msg) {
    this.type = type;
    this.detail = detail;
    this.msg = msg;
    Object.defineProperty(this, `__mayPropagate`, {
      enumerable: false,
      writable: true
    });
    this.__mayPropagate = true;
  }
  preventDefault() {
  }
  stopPropagation() {
    this.__mayPropagate = false;
  }
  valueOf() {
    return this;
  }
  toString() {
    return this.msg ? `[${this.type} event]: ${this.msg}` : `[${this.type} event]`;
  }
};
var EventManager = class {
  constructor() {
    this.listeners = {};
  }
  addEventListener(type, listener, useCapture) {
    let bin = this.listeners[type] || [];
    if (useCapture) bin.unshift(listener);
    else bin.push(listener);
    this.listeners[type] = bin;
  }
  removeEventListener(type, listener) {
    let bin = this.listeners[type] || [];
    let pos = bin.findIndex((e2) => e2 === listener);
    if (pos > -1) {
      bin.splice(pos, 1);
      this.listeners[type] = bin;
    }
  }
  dispatch(event) {
    let bin = this.listeners[event.type];
    if (bin) {
      for (let l2 = 0, e2 = bin.length; l2 < e2; l2++) {
        if (!event.__mayPropagate) break;
        bin[l2](event);
      }
    }
  }
};
var startDate = (/* @__PURE__ */ new Date(`1904-01-01T00:00:00+0000`)).getTime();
function asText(data) {
  return Array.from(data).map((v2) => String.fromCharCode(v2)).join(``);
}
var Parser = class {
  constructor(dict, dataview, name2) {
    this.name = (name2 || dict.tag || ``).trim();
    this.length = dict.length;
    this.start = dict.offset;
    this.offset = 0;
    this.data = dataview;
    [
      `getInt8`,
      `getUint8`,
      `getInt16`,
      `getUint16`,
      `getInt32`,
      `getUint32`,
      `getBigInt64`,
      `getBigUint64`
    ].forEach((name3) => {
      let fn = name3.replace(/get(Big)?/, "").toLowerCase();
      let increment = parseInt(name3.replace(/[^\d]/g, "")) / 8;
      Object.defineProperty(this, fn, {
        get: () => this.getValue(name3, increment)
      });
    });
  }
  get currentPosition() {
    return this.start + this.offset;
  }
  set currentPosition(position) {
    this.start = position;
    this.offset = 0;
  }
  skip(n2 = 0, bits = 8) {
    this.offset += n2 * bits / 8;
  }
  getValue(type, increment) {
    let pos = this.start + this.offset;
    this.offset += increment;
    try {
      return this.data[type](pos);
    } catch (e2) {
      console.error(`parser`, type, increment, this);
      console.error(`parser`, this.start, this.offset);
      throw e2;
    }
  }
  flags(n2) {
    if (n2 === 8 || n2 === 16 || n2 === 32 || n2 === 64) {
      return this[`uint${n2}`].toString(2).padStart(n2, 0).split(``).map((v2) => v2 === "1");
    }
    console.error(
      `Error parsing flags: flag types can only be 1, 2, 4, or 8 bytes long`
    );
    console.trace();
  }
  get tag() {
    const t3 = this.uint32;
    return asText([
      t3 >> 24 & 255,
      t3 >> 16 & 255,
      t3 >> 8 & 255,
      t3 & 255
    ]);
  }
  get fixed() {
    let major = this.int16;
    let minor = Math.round(1e3 * this.uint16 / 65356);
    return major + minor / 1e3;
  }
  get legacyFixed() {
    let major = this.uint16;
    let minor = this.uint16.toString(16).padStart(4, 0);
    return parseFloat(`${major}.${minor}`);
  }
  get uint24() {
    return (this.uint8 << 16) + (this.uint8 << 8) + this.uint8;
  }
  get uint128() {
    let value = 0;
    for (let i2 = 0; i2 < 5; i2++) {
      let byte = this.uint8;
      value = value * 128 + (byte & 127);
      if (byte < 128) break;
    }
    return value;
  }
  get longdatetime() {
    return new Date(startDate + 1e3 * parseInt(this.int64.toString()));
  }
  get fword() {
    return this.int16;
  }
  get ufword() {
    return this.uint16;
  }
  get Offset16() {
    return this.uint16;
  }
  get Offset32() {
    return this.uint32;
  }
  get F2DOT14() {
    const bits = p.uint16;
    const integer = [0, 1, -2, -1][bits >> 14];
    const fraction = bits & 16383;
    return integer + fraction / 16384;
  }
  verifyLength() {
    if (this.offset != this.length) {
      console.error(
        `unexpected parsed table size (${this.offset}) for "${this.name}" (expected ${this.length})`
      );
    }
  }
  readBytes(n2 = 0, position = 0, bits = 8, signed = false) {
    n2 = n2 || this.length;
    if (n2 === 0) return [];
    if (position) this.currentPosition = position;
    const fn = `${signed ? `` : `u`}int${bits}`, slice = [];
    while (n2--) slice.push(this[fn]);
    return slice;
  }
};
var ParsedData = class {
  constructor(parser) {
    const pGetter = { enumerable: false, get: () => parser };
    Object.defineProperty(this, `parser`, pGetter);
    const start = parser.currentPosition;
    const startGetter = { enumerable: false, get: () => start };
    Object.defineProperty(this, `start`, startGetter);
  }
  load(struct) {
    Object.keys(struct).forEach((p22) => {
      let props = Object.getOwnPropertyDescriptor(struct, p22);
      if (props.get) {
        this[p22] = props.get.bind(this);
      } else if (props.value !== void 0) {
        this[p22] = props.value;
      }
    });
    if (this.parser.length) {
      this.parser.verifyLength();
    }
  }
};
var SimpleTable = class extends ParsedData {
  constructor(dict, dataview, name2) {
    const { parser, start } = super(
      new Parser(dict, dataview, name2)
    );
    const pGetter = { enumerable: false, get: () => parser };
    Object.defineProperty(this, `p`, pGetter);
    const startGetter = { enumerable: false, get: () => start };
    Object.defineProperty(this, `tableStart`, startGetter);
  }
};
function lazy$1(object, property, getter) {
  let val;
  Object.defineProperty(object, property, {
    get: () => {
      if (val) return val;
      val = getter();
      return val;
    },
    enumerable: true
  });
}
var SFNT = class extends SimpleTable {
  constructor(font2, dataview, createTable2) {
    const { p: p22 } = super({ offset: 0, length: 12 }, dataview, `sfnt`);
    this.version = p22.uint32;
    this.numTables = p22.uint16;
    this.searchRange = p22.uint16;
    this.entrySelector = p22.uint16;
    this.rangeShift = p22.uint16;
    p22.verifyLength();
    this.directory = [...new Array(this.numTables)].map(
      (_) => new TableRecord(p22)
    );
    this.tables = {};
    this.directory.forEach((entry) => {
      const getter = () => createTable2(
        this.tables,
        {
          tag: entry.tag,
          offset: entry.offset,
          length: entry.length
        },
        dataview
      );
      lazy$1(this.tables, entry.tag.trim(), getter);
    });
  }
};
var TableRecord = class {
  constructor(p22) {
    this.tag = p22.tag;
    this.checksum = p22.uint32;
    this.offset = p22.uint32;
    this.length = p22.uint32;
  }
};
var gzipDecode = inflate_default.inflate || void 0;
var nativeGzipDecode = void 0;
var WOFF$1 = class extends SimpleTable {
  constructor(font2, dataview, createTable2) {
    const { p: p22 } = super({ offset: 0, length: 44 }, dataview, `woff`);
    this.signature = p22.tag;
    this.flavor = p22.uint32;
    this.length = p22.uint32;
    this.numTables = p22.uint16;
    p22.uint16;
    this.totalSfntSize = p22.uint32;
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.metaOffset = p22.uint32;
    this.metaLength = p22.uint32;
    this.metaOrigLength = p22.uint32;
    this.privOffset = p22.uint32;
    this.privLength = p22.uint32;
    p22.verifyLength();
    this.directory = [...new Array(this.numTables)].map(
      (_) => new WoffTableDirectoryEntry(p22)
    );
    buildWoffLazyLookups(this, dataview, createTable2);
  }
};
var WoffTableDirectoryEntry = class {
  constructor(p22) {
    this.tag = p22.tag;
    this.offset = p22.uint32;
    this.compLength = p22.uint32;
    this.origLength = p22.uint32;
    this.origChecksum = p22.uint32;
  }
};
function buildWoffLazyLookups(woff, dataview, createTable2) {
  woff.tables = {};
  woff.directory.forEach((entry) => {
    lazy$1(woff.tables, entry.tag.trim(), () => {
      let offset4 = 0;
      let view = dataview;
      if (entry.compLength !== entry.origLength) {
        const data = dataview.buffer.slice(
          entry.offset,
          entry.offset + entry.compLength
        );
        let unpacked;
        if (gzipDecode) {
          unpacked = gzipDecode(new Uint8Array(data));
        } else if (nativeGzipDecode) {
          unpacked = nativeGzipDecode(new Uint8Array(data));
        } else {
          const msg = `no brotli decoder available to decode WOFF2 font`;
          if (font.onerror) font.onerror(msg);
          throw new Error(msg);
        }
        view = new DataView(unpacked.buffer);
      } else {
        offset4 = entry.offset;
      }
      return createTable2(
        woff.tables,
        { tag: entry.tag, offset: offset4, length: entry.origLength },
        view
      );
    });
  });
}
var brotliDecode = unbrotli_default;
var nativeBrotliDecode = void 0;
var WOFF2$1 = class extends SimpleTable {
  constructor(font2, dataview, createTable2) {
    const { p: p22 } = super({ offset: 0, length: 48 }, dataview, `woff2`);
    this.signature = p22.tag;
    this.flavor = p22.uint32;
    this.length = p22.uint32;
    this.numTables = p22.uint16;
    p22.uint16;
    this.totalSfntSize = p22.uint32;
    this.totalCompressedSize = p22.uint32;
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.metaOffset = p22.uint32;
    this.metaLength = p22.uint32;
    this.metaOrigLength = p22.uint32;
    this.privOffset = p22.uint32;
    this.privLength = p22.uint32;
    p22.verifyLength();
    this.directory = [...new Array(this.numTables)].map(
      (_) => new Woff2TableDirectoryEntry(p22)
    );
    let dictOffset = p22.currentPosition;
    this.directory[0].offset = 0;
    this.directory.forEach((e2, i2) => {
      let next = this.directory[i2 + 1];
      if (next) {
        next.offset = e2.offset + (e2.transformLength !== void 0 ? e2.transformLength : e2.origLength);
      }
    });
    let decoded;
    let buffer = dataview.buffer.slice(dictOffset);
    if (brotliDecode) {
      decoded = brotliDecode(new Uint8Array(buffer));
    } else if (nativeBrotliDecode) {
      decoded = new Uint8Array(nativeBrotliDecode(buffer));
    } else {
      const msg = `no brotli decoder available to decode WOFF2 font`;
      if (font2.onerror) font2.onerror(msg);
      throw new Error(msg);
    }
    buildWoff2LazyLookups(this, decoded, createTable2);
  }
};
var Woff2TableDirectoryEntry = class {
  constructor(p22) {
    this.flags = p22.uint8;
    const tagNumber = this.tagNumber = this.flags & 63;
    if (tagNumber === 63) {
      this.tag = p22.tag;
    } else {
      this.tag = getWOFF2Tag(tagNumber);
    }
    const transformVersion = this.transformVersion = (this.flags & 192) >> 6;
    let hasTransforms = transformVersion !== 0;
    if (this.tag === `glyf` || this.tag === `loca`) {
      hasTransforms = this.transformVersion !== 3;
    }
    this.origLength = p22.uint128;
    if (hasTransforms) {
      this.transformLength = p22.uint128;
    }
  }
};
function buildWoff2LazyLookups(woff2, decoded, createTable2) {
  woff2.tables = {};
  woff2.directory.forEach((entry) => {
    lazy$1(woff2.tables, entry.tag.trim(), () => {
      const start = entry.offset;
      const end = start + (entry.transformLength ? entry.transformLength : entry.origLength);
      const data = new DataView(decoded.slice(start, end).buffer);
      try {
        return createTable2(
          woff2.tables,
          { tag: entry.tag, offset: 0, length: entry.origLength },
          data
        );
      } catch (e2) {
        console.error(e2);
      }
    });
  });
}
function getWOFF2Tag(flag) {
  return [
    `cmap`,
    `head`,
    `hhea`,
    `hmtx`,
    `maxp`,
    `name`,
    `OS/2`,
    `post`,
    `cvt `,
    `fpgm`,
    `glyf`,
    `loca`,
    `prep`,
    `CFF `,
    `VORG`,
    `EBDT`,
    `EBLC`,
    `gasp`,
    `hdmx`,
    `kern`,
    `LTSH`,
    `PCLT`,
    `VDMX`,
    `vhea`,
    `vmtx`,
    `BASE`,
    `GDEF`,
    `GPOS`,
    `GSUB`,
    `EBSC`,
    `JSTF`,
    `MATH`,
    `CBDT`,
    `CBLC`,
    `COLR`,
    `CPAL`,
    `SVG `,
    `sbix`,
    `acnt`,
    `avar`,
    `bdat`,
    `bloc`,
    `bsln`,
    `cvar`,
    `fdsc`,
    `feat`,
    `fmtx`,
    `fvar`,
    `gvar`,
    `hsty`,
    `just`,
    `lcar`,
    `mort`,
    `morx`,
    `opbd`,
    `prop`,
    `trak`,
    `Zapf`,
    `Silf`,
    `Glat`,
    `Gloc`,
    `Feat`,
    `Sill`
  ][flag & 63];
}
var tableClasses = {};
var tableClassesLoaded = false;
Promise.all([
  Promise.resolve().then(function() {
    return cmap$1;
  }),
  Promise.resolve().then(function() {
    return head$1;
  }),
  Promise.resolve().then(function() {
    return hhea$1;
  }),
  Promise.resolve().then(function() {
    return hmtx$1;
  }),
  Promise.resolve().then(function() {
    return maxp$1;
  }),
  Promise.resolve().then(function() {
    return name$1;
  }),
  Promise.resolve().then(function() {
    return OS2$1;
  }),
  Promise.resolve().then(function() {
    return post$1;
  }),
  Promise.resolve().then(function() {
    return BASE$1;
  }),
  Promise.resolve().then(function() {
    return GDEF$1;
  }),
  Promise.resolve().then(function() {
    return GSUB$1;
  }),
  Promise.resolve().then(function() {
    return GPOS$1;
  }),
  Promise.resolve().then(function() {
    return SVG$1;
  }),
  Promise.resolve().then(function() {
    return fvar$1;
  }),
  Promise.resolve().then(function() {
    return cvt$1;
  }),
  Promise.resolve().then(function() {
    return fpgm$1;
  }),
  Promise.resolve().then(function() {
    return gasp$1;
  }),
  Promise.resolve().then(function() {
    return glyf$1;
  }),
  Promise.resolve().then(function() {
    return loca$1;
  }),
  Promise.resolve().then(function() {
    return prep$1;
  }),
  Promise.resolve().then(function() {
    return CFF$1;
  }),
  Promise.resolve().then(function() {
    return CFF2$1;
  }),
  Promise.resolve().then(function() {
    return VORG$1;
  }),
  Promise.resolve().then(function() {
    return EBLC$1;
  }),
  Promise.resolve().then(function() {
    return EBDT$1;
  }),
  Promise.resolve().then(function() {
    return EBSC$1;
  }),
  Promise.resolve().then(function() {
    return CBLC$1;
  }),
  Promise.resolve().then(function() {
    return CBDT$1;
  }),
  Promise.resolve().then(function() {
    return sbix$1;
  }),
  Promise.resolve().then(function() {
    return COLR$1;
  }),
  Promise.resolve().then(function() {
    return CPAL$1;
  }),
  Promise.resolve().then(function() {
    return DSIG$1;
  }),
  Promise.resolve().then(function() {
    return hdmx$1;
  }),
  Promise.resolve().then(function() {
    return kern$1;
  }),
  Promise.resolve().then(function() {
    return LTSH$1;
  }),
  Promise.resolve().then(function() {
    return MERG$1;
  }),
  Promise.resolve().then(function() {
    return meta$1;
  }),
  Promise.resolve().then(function() {
    return PCLT$1;
  }),
  Promise.resolve().then(function() {
    return VDMX$1;
  }),
  Promise.resolve().then(function() {
    return vhea$1;
  }),
  Promise.resolve().then(function() {
    return vmtx$1;
  })
]).then((data) => {
  data.forEach((e2) => {
    let name2 = Object.keys(e2)[0];
    tableClasses[name2] = e2[name2];
  });
  tableClassesLoaded = true;
});
function createTable(tables, dict, dataview) {
  let name2 = dict.tag.replace(/[^\w\d]/g, ``);
  let Type = tableClasses[name2];
  if (Type) return new Type(dict, dataview, tables);
  console.warn(
    `lib-font has no definition for ${name2}. The table was skipped.`
  );
  return {};
}
function loadTableClasses() {
  let count = 0;
  function checkLoaded(resolve, reject) {
    if (!tableClassesLoaded) {
      if (count > 10) {
        return reject(new Error(`loading took too long`));
      }
      count++;
      return setTimeout(() => checkLoaded(resolve), 250);
    }
    resolve(createTable);
  }
  return new Promise((resolve, reject) => checkLoaded(resolve));
}
function getFontCSSFormat(path, errorOnStyle) {
  let pos = path.lastIndexOf(`.`);
  let ext = (path.substring(pos + 1) || ``).toLowerCase();
  let format = {
    ttf: `truetype`,
    otf: `opentype`,
    woff: `woff`,
    woff2: `woff2`
  }[ext];
  if (format) return format;
  let msg = {
    eot: `The .eot format is not supported: it died in January 12, 2016, when Microsoft retired all versions of IE that didn't already support WOFF.`,
    svg: `The .svg format is not supported: SVG fonts (not to be confused with OpenType with embedded SVG) were so bad we took the entire fonts chapter out of the SVG specification again.`,
    fon: `The .fon format is not supported: this is an ancient Windows bitmap font format.`,
    ttc: `Based on the current CSS specification, font collections are not (yet?) supported.`
  }[ext];
  if (!msg) msg = `${path} is not a known webfont format.`;
  if (errorOnStyle) {
    throw new Error(msg);
  } else {
    console.warn(`Could not load font: ${msg}`);
  }
}
async function setupFontFace(name2, url, options = {}) {
  if (!globalThis.document) return;
  let format = getFontCSSFormat(url, options.errorOnStyle);
  if (!format) return;
  let style = document.createElement(`style`);
  style.className = `injected-by-Font-js`;
  let rules = [];
  if (options.styleRules) {
    rules = Object.entries(options.styleRules).map(
      ([key, value]) => `${key}: ${value};`
    );
  }
  style.textContent = `
@font-face {
    font-family: "${name2}";
    ${rules.join(
    `
	`
  )}
    src: url("${url}") format("${format}");
}`;
  globalThis.document.head.appendChild(style);
  return style;
}
var TTF = [0, 1, 0, 0];
var OTF = [79, 84, 84, 79];
var WOFF = [119, 79, 70, 70];
var WOFF2 = [119, 79, 70, 50];
function match(ar1, ar2) {
  if (ar1.length !== ar2.length) return;
  for (let i2 = 0; i2 < ar1.length; i2++) {
    if (ar1[i2] !== ar2[i2]) return;
  }
  return true;
}
function validFontFormat(dataview) {
  const LEAD_BYTES = [
    dataview.getUint8(0),
    dataview.getUint8(1),
    dataview.getUint8(2),
    dataview.getUint8(3)
  ];
  if (match(LEAD_BYTES, TTF) || match(LEAD_BYTES, OTF)) return `SFNT`;
  if (match(LEAD_BYTES, WOFF)) return `WOFF`;
  if (match(LEAD_BYTES, WOFF2)) return `WOFF2`;
}
function checkFetchResponseStatus(response) {
  if (!response.ok) {
    throw new Error(
      `HTTP ${response.status} - ${response.statusText}`
    );
  }
  return response;
}
var Font = class extends EventManager {
  constructor(name2, options = {}) {
    super();
    this.name = name2;
    this.options = options;
    this.metrics = false;
  }
  get src() {
    return this.__src;
  }
  set src(src) {
    this.__src = src;
    (async () => {
      if (globalThis.document && !this.options.skipStyleSheet) {
        await setupFontFace(this.name, src, this.options);
      }
      this.loadFont(src);
    })();
  }
  async loadFont(url, filename) {
    fetch(url).then(
      (response) => checkFetchResponseStatus(response) && response.arrayBuffer()
    ).then(
      (buffer) => this.fromDataBuffer(buffer, filename || url)
    ).catch((err) => {
      const evt = new Event2(
        `error`,
        err,
        `Failed to load font at ${filename || url}`
      );
      this.dispatch(evt);
      if (this.onerror) this.onerror(evt);
    });
  }
  async fromDataBuffer(buffer, filenameOrUrL) {
    this.fontData = new DataView(buffer);
    let type = validFontFormat(this.fontData);
    if (!type) {
      throw new Error(
        `${filenameOrUrL} is either an unsupported font format, or not a font at all.`
      );
    }
    await this.parseBasicData(type);
    const evt = new Event2("load", { font: this });
    this.dispatch(evt);
    if (this.onload) this.onload(evt);
  }
  async parseBasicData(type) {
    return loadTableClasses().then((createTable2) => {
      if (type === `SFNT`) {
        this.opentype = new SFNT(this, this.fontData, createTable2);
      }
      if (type === `WOFF`) {
        this.opentype = new WOFF$1(this, this.fontData, createTable2);
      }
      if (type === `WOFF2`) {
        this.opentype = new WOFF2$1(this, this.fontData, createTable2);
      }
      return this.opentype;
    });
  }
  getGlyphId(char) {
    return this.opentype.tables.cmap.getGlyphId(char);
  }
  reverse(glyphid) {
    return this.opentype.tables.cmap.reverse(glyphid);
  }
  supports(char) {
    return this.getGlyphId(char) !== 0;
  }
  supportsVariation(variation) {
    return this.opentype.tables.cmap.supportsVariation(variation) !== false;
  }
  measureText(text, size4 = 16) {
    if (this.__unloaded)
      throw new Error(
        "Cannot measure text: font was unloaded. Please reload before calling measureText()"
      );
    let d2 = document.createElement("div");
    d2.textContent = text;
    d2.style.fontFamily = this.name;
    d2.style.fontSize = `${size4}px`;
    d2.style.color = `transparent`;
    d2.style.background = `transparent`;
    d2.style.top = `0`;
    d2.style.left = `0`;
    d2.style.position = `absolute`;
    document.body.appendChild(d2);
    let bbox = d2.getBoundingClientRect();
    document.body.removeChild(d2);
    const OS22 = this.opentype.tables["OS/2"];
    bbox.fontSize = size4;
    bbox.ascender = OS22.sTypoAscender;
    bbox.descender = OS22.sTypoDescender;
    return bbox;
  }
  unload() {
    if (this.styleElement.parentNode) {
      this.styleElement.parentNode.removeElement(this.styleElement);
      const evt = new Event2("unload", { font: this });
      this.dispatch(evt);
      if (this.onunload) this.onunload(evt);
    }
    this._unloaded = true;
  }
  load() {
    if (this.__unloaded) {
      delete this.__unloaded;
      document.head.appendChild(this.styleElement);
      const evt = new Event2("load", { font: this });
      this.dispatch(evt);
      if (this.onload) this.onload(evt);
    }
  }
};
globalThis.Font = Font;
var Subtable = class extends ParsedData {
  constructor(p22, plaformID, encodingID) {
    super(p22);
    this.plaformID = plaformID;
    this.encodingID = encodingID;
  }
};
var Format0 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 0;
    this.length = p22.uint16;
    this.language = p22.uint16;
    this.glyphIdArray = [...new Array(256)].map((_) => p22.uint8);
  }
  supports(charCode) {
    if (charCode.charCodeAt) {
      charCode = -1;
      console.warn(
        `supports(character) not implemented for cmap subtable format 0. only supports(id) is implemented.`
      );
    }
    return 0 <= charCode && charCode <= 255;
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 0`);
    return {};
  }
  getSupportedCharCodes() {
    return [{ start: 1, end: 256 }];
  }
};
var Format2 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 2;
    this.length = p22.uint16;
    this.language = p22.uint16;
    this.subHeaderKeys = [...new Array(256)].map((_) => p22.uint16);
    const subHeaderCount = Math.max(...this.subHeaderKeys);
    const subHeaderOffset = p22.currentPosition;
    lazy$1(this, `subHeaders`, () => {
      p22.currentPosition = subHeaderOffset;
      return [...new Array(subHeaderCount)].map(
        (_) => new SubHeader(p22)
      );
    });
    const glyphIndexOffset = subHeaderOffset + subHeaderCount * 8;
    lazy$1(this, `glyphIndexArray`, () => {
      p22.currentPosition = glyphIndexOffset;
      return [...new Array(subHeaderCount)].map((_) => p22.uint16);
    });
  }
  supports(charCode) {
    if (charCode.charCodeAt) {
      charCode = -1;
      console.warn(
        `supports(character) not implemented for cmap subtable format 2. only supports(id) is implemented.`
      );
    }
    const low = charCode && 255;
    const high = charCode && 65280;
    const subHeaderKey = this.subHeaders[high];
    const subheader = this.subHeaders[subHeaderKey];
    const first = subheader.firstCode;
    const last = first + subheader.entryCount;
    return first <= low && low <= last;
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 2`);
    return {};
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) {
      return this.subHeaders.map((h2) => ({
        firstCode: h2.firstCode,
        lastCode: h2.lastCode
      }));
    }
    return this.subHeaders.map((h2) => ({
      start: h2.firstCode,
      end: h2.lastCode
    }));
  }
};
var SubHeader = class {
  constructor(p22) {
    this.firstCode = p22.uint16;
    this.entryCount = p22.uint16;
    this.lastCode = this.first + this.entryCount;
    this.idDelta = p22.int16;
    this.idRangeOffset = p22.uint16;
  }
};
var Format4 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 4;
    this.length = p22.uint16;
    this.language = p22.uint16;
    this.segCountX2 = p22.uint16;
    this.segCount = this.segCountX2 / 2;
    this.searchRange = p22.uint16;
    this.entrySelector = p22.uint16;
    this.rangeShift = p22.uint16;
    const endCodePosition = p22.currentPosition;
    lazy$1(
      this,
      `endCode`,
      () => p22.readBytes(this.segCount, endCodePosition, 16)
    );
    const startCodePosition = endCodePosition + 2 + this.segCountX2;
    lazy$1(
      this,
      `startCode`,
      () => p22.readBytes(this.segCount, startCodePosition, 16)
    );
    const idDeltaPosition = startCodePosition + this.segCountX2;
    lazy$1(
      this,
      `idDelta`,
      () => p22.readBytes(this.segCount, idDeltaPosition, 16, true)
    );
    const idRangePosition = idDeltaPosition + this.segCountX2;
    lazy$1(
      this,
      `idRangeOffset`,
      () => p22.readBytes(this.segCount, idRangePosition, 16)
    );
    const glyphIdArrayPosition = idRangePosition + this.segCountX2;
    const glyphIdArrayLength = this.length - (glyphIdArrayPosition - this.tableStart);
    lazy$1(
      this,
      `glyphIdArray`,
      () => p22.readBytes(glyphIdArrayLength, glyphIdArrayPosition, 16)
    );
    lazy$1(
      this,
      `segments`,
      () => this.buildSegments(idRangePosition, glyphIdArrayPosition, p22)
    );
  }
  buildSegments(idRangePosition, glyphIdArrayPosition, p22) {
    const build = (_, i2) => {
      let startCode = this.startCode[i2], endCode = this.endCode[i2], idDelta = this.idDelta[i2], idRangeOffset = this.idRangeOffset[i2], idRangeOffsetPointer = idRangePosition + 2 * i2, glyphIDs = [];
      if (idRangeOffset === 0) {
        for (let i22 = startCode + idDelta, e2 = endCode + idDelta; i22 <= e2; i22++) {
          glyphIDs.push(i22);
        }
      } else {
        for (let i22 = 0, e2 = endCode - startCode; i22 <= e2; i22++) {
          p22.currentPosition = idRangeOffsetPointer + idRangeOffset + i22 * 2;
          glyphIDs.push(p22.uint16);
        }
      }
      return {
        startCode,
        endCode,
        idDelta,
        idRangeOffset,
        glyphIDs
      };
    };
    return [...new Array(this.segCount)].map(build);
  }
  reverse(glyphID) {
    let s2 = this.segments.find((v2) => v2.glyphIDs.includes(glyphID));
    if (!s2) return {};
    const code = s2.startCode + s2.glyphIDs.indexOf(glyphID);
    return { code, unicode: String.fromCodePoint(code) };
  }
  getGlyphId(charCode) {
    if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
    if (55296 <= charCode && charCode <= 57343) return 0;
    if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
      return 0;
    let segment = this.segments.find(
      (s2) => s2.startCode <= charCode && charCode <= s2.endCode
    );
    if (!segment) return 0;
    return segment.glyphIDs[charCode - segment.startCode];
  }
  supports(charCode) {
    return this.getGlyphId(charCode) !== 0;
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) return this.segments;
    return this.segments.map((v2) => ({
      start: v2.startCode,
      end: v2.endCode
    }));
  }
};
var Format6 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 6;
    this.length = p22.uint16;
    this.language = p22.uint16;
    this.firstCode = p22.uint16;
    this.entryCount = p22.uint16;
    this.lastCode = this.firstCode + this.entryCount - 1;
    const getter = () => [...new Array(this.entryCount)].map((_) => p22.uint16);
    lazy$1(this, `glyphIdArray`, getter);
  }
  supports(charCode) {
    if (charCode.charCodeAt) {
      charCode = -1;
      console.warn(
        `supports(character) not implemented for cmap subtable format 6. only supports(id) is implemented.`
      );
    }
    if (charCode < this.firstCode) return {};
    if (charCode > this.firstCode + this.entryCount) return {};
    const code = charCode - this.firstCode;
    return { code, unicode: String.fromCodePoint(code) };
  }
  reverse(glyphID) {
    let pos = this.glyphIdArray.indexOf(glyphID);
    if (pos > -1) return this.firstCode + pos;
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) {
      return [{ firstCode: this.firstCode, lastCode: this.lastCode }];
    }
    return [{ start: this.firstCode, end: this.lastCode }];
  }
};
var Format8 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 8;
    p22.uint16;
    this.length = p22.uint32;
    this.language = p22.uint32;
    this.is32 = [...new Array(8192)].map((_) => p22.uint8);
    this.numGroups = p22.uint32;
    const getter = () => [...new Array(this.numGroups)].map(
      (_) => new SequentialMapGroup$1(p22)
    );
    lazy$1(this, `groups`, getter);
  }
  supports(charCode) {
    if (charCode.charCodeAt) {
      charCode = -1;
      console.warn(
        `supports(character) not implemented for cmap subtable format 8. only supports(id) is implemented.`
      );
    }
    return this.groups.findIndex(
      (s2) => s2.startcharCode <= charCode && charCode <= s2.endcharCode
    ) !== -1;
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 8`);
    return {};
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) return this.groups;
    return this.groups.map((v2) => ({
      start: v2.startcharCode,
      end: v2.endcharCode
    }));
  }
};
var SequentialMapGroup$1 = class {
  constructor(p22) {
    this.startcharCode = p22.uint32;
    this.endcharCode = p22.uint32;
    this.startGlyphID = p22.uint32;
  }
};
var Format10 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 10;
    p22.uint16;
    this.length = p22.uint32;
    this.language = p22.uint32;
    this.startCharCode = p22.uint32;
    this.numChars = p22.uint32;
    this.endCharCode = this.startCharCode + this.numChars;
    const getter = () => [...new Array(this.numChars)].map((_) => p22.uint16);
    lazy$1(this, `glyphs`, getter);
  }
  supports(charCode) {
    if (charCode.charCodeAt) {
      charCode = -1;
      console.warn(
        `supports(character) not implemented for cmap subtable format 10. only supports(id) is implemented.`
      );
    }
    if (charCode < this.startCharCode) return false;
    if (charCode > this.startCharCode + this.numChars) return false;
    return charCode - this.startCharCode;
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 10`);
    return {};
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) {
      return [
        {
          startCharCode: this.startCharCode,
          endCharCode: this.endCharCode
        }
      ];
    }
    return [{ start: this.startCharCode, end: this.endCharCode }];
  }
};
var Format12 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 12;
    p22.uint16;
    this.length = p22.uint32;
    this.language = p22.uint32;
    this.numGroups = p22.uint32;
    const getter = () => [...new Array(this.numGroups)].map(
      (_) => new SequentialMapGroup(p22)
    );
    lazy$1(this, `groups`, getter);
  }
  supports(charCode) {
    if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
    if (55296 <= charCode && charCode <= 57343) return 0;
    if ((charCode & 65534) === 65534 || (charCode & 65535) === 65535)
      return 0;
    return this.groups.findIndex(
      (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode
    ) !== -1;
  }
  reverse(glyphID) {
    for (let group of this.groups) {
      let start = group.startGlyphID;
      if (start > glyphID) continue;
      if (start === glyphID) return group.startCharCode;
      let end = start + (group.endCharCode - group.startCharCode);
      if (end < glyphID) continue;
      const code = group.startCharCode + (glyphID - start);
      return { code, unicode: String.fromCodePoint(code) };
    }
    return {};
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) return this.groups;
    return this.groups.map((v2) => ({
      start: v2.startCharCode,
      end: v2.endCharCode
    }));
  }
};
var SequentialMapGroup = class {
  constructor(p22) {
    this.startCharCode = p22.uint32;
    this.endCharCode = p22.uint32;
    this.startGlyphID = p22.uint32;
  }
};
var Format13 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.format = 13;
    p22.uint16;
    this.length = p22.uint32;
    this.language = p22.uint32;
    this.numGroups = p22.uint32;
    const getter = [...new Array(this.numGroups)].map(
      (_) => new ConstantMapGroup(p22)
    );
    lazy$1(this, `groups`, getter);
  }
  supports(charCode) {
    if (charCode.charCodeAt) charCode = charCode.charCodeAt(0);
    return this.groups.findIndex(
      (s2) => s2.startCharCode <= charCode && charCode <= s2.endCharCode
    ) !== -1;
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 13`);
    return {};
  }
  getSupportedCharCodes(preservePropNames = false) {
    if (preservePropNames) return this.groups;
    return this.groups.map((v2) => ({
      start: v2.startCharCode,
      end: v2.endCharCode
    }));
  }
};
var ConstantMapGroup = class {
  constructor(p22) {
    this.startCharCode = p22.uint32;
    this.endCharCode = p22.uint32;
    this.glyphID = p22.uint32;
  }
};
var Format14 = class extends Subtable {
  constructor(p22, platformID, encodingID) {
    super(p22, platformID, encodingID);
    this.subTableStart = p22.currentPosition;
    this.format = 14;
    this.length = p22.uint32;
    this.numVarSelectorRecords = p22.uint32;
    lazy$1(
      this,
      `varSelectors`,
      () => [...new Array(this.numVarSelectorRecords)].map(
        (_) => new VariationSelector(p22)
      )
    );
  }
  supports() {
    console.warn(`supports not implemented for cmap subtable format 14`);
    return 0;
  }
  getSupportedCharCodes() {
    console.warn(
      `getSupportedCharCodes not implemented for cmap subtable format 14`
    );
    return [];
  }
  reverse(glyphID) {
    console.warn(`reverse not implemented for cmap subtable format 14`);
    return {};
  }
  supportsVariation(variation) {
    let v2 = this.varSelector.find(
      (uvs) => uvs.varSelector === variation
    );
    return v2 ? v2 : false;
  }
  getSupportedVariations() {
    return this.varSelectors.map((v2) => v2.varSelector);
  }
};
var VariationSelector = class {
  constructor(p22) {
    this.varSelector = p22.uint24;
    this.defaultUVSOffset = p22.Offset32;
    this.nonDefaultUVSOffset = p22.Offset32;
  }
};
function createSubTable(parser, platformID, encodingID) {
  const format = parser.uint16;
  if (format === 0) return new Format0(parser, platformID, encodingID);
  if (format === 2) return new Format2(parser, platformID, encodingID);
  if (format === 4) return new Format4(parser, platformID, encodingID);
  if (format === 6) return new Format6(parser, platformID, encodingID);
  if (format === 8) return new Format8(parser, platformID, encodingID);
  if (format === 10) return new Format10(parser, platformID, encodingID);
  if (format === 12) return new Format12(parser, platformID, encodingID);
  if (format === 13) return new Format13(parser, platformID, encodingID);
  if (format === 14) return new Format14(parser, platformID, encodingID);
  return {};
}
var cmap = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numTables = p22.uint16;
    this.encodingRecords = [...new Array(this.numTables)].map(
      (_) => new EncodingRecord(p22, this.tableStart)
    );
  }
  getSubTable(tableID) {
    return this.encodingRecords[tableID].table;
  }
  getSupportedEncodings() {
    return this.encodingRecords.map((r3) => ({
      platformID: r3.platformID,
      encodingId: r3.encodingID
    }));
  }
  getSupportedCharCodes(platformID, encodingID) {
    const recordID = this.encodingRecords.findIndex(
      (r3) => r3.platformID === platformID && r3.encodingID === encodingID
    );
    if (recordID === -1) return false;
    const subtable = this.getSubTable(recordID);
    return subtable.getSupportedCharCodes();
  }
  reverse(glyphid) {
    for (let i2 = 0; i2 < this.numTables; i2++) {
      let code = this.getSubTable(i2).reverse(glyphid);
      if (code) return code;
    }
  }
  getGlyphId(char) {
    let last = 0;
    this.encodingRecords.some((_, tableID) => {
      let t3 = this.getSubTable(tableID);
      if (!t3.getGlyphId) return false;
      last = t3.getGlyphId(char);
      return last !== 0;
    });
    return last;
  }
  supports(char) {
    return this.encodingRecords.some((_, tableID) => {
      const t3 = this.getSubTable(tableID);
      return t3.supports && t3.supports(char) !== false;
    });
  }
  supportsVariation(variation) {
    return this.encodingRecords.some((_, tableID) => {
      const t3 = this.getSubTable(tableID);
      return t3.supportsVariation && t3.supportsVariation(variation) !== false;
    });
  }
};
var EncodingRecord = class {
  constructor(p22, tableStart) {
    const platformID = this.platformID = p22.uint16;
    const encodingID = this.encodingID = p22.uint16;
    const offset4 = this.offset = p22.Offset32;
    lazy$1(this, `table`, () => {
      p22.currentPosition = tableStart + offset4;
      return createSubTable(p22, platformID, encodingID);
    });
  }
};
var cmap$1 = Object.freeze({ __proto__: null, cmap });
var head = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.load({
      majorVersion: p22.uint16,
      minorVersion: p22.uint16,
      fontRevision: p22.fixed,
      checkSumAdjustment: p22.uint32,
      magicNumber: p22.uint32,
      flags: p22.flags(16),
      unitsPerEm: p22.uint16,
      created: p22.longdatetime,
      modified: p22.longdatetime,
      xMin: p22.int16,
      yMin: p22.int16,
      xMax: p22.int16,
      yMax: p22.int16,
      macStyle: p22.flags(16),
      lowestRecPPEM: p22.uint16,
      fontDirectionHint: p22.uint16,
      indexToLocFormat: p22.uint16,
      glyphDataFormat: p22.uint16
    });
  }
};
var head$1 = Object.freeze({ __proto__: null, head });
var hhea = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.ascender = p22.fword;
    this.descender = p22.fword;
    this.lineGap = p22.fword;
    this.advanceWidthMax = p22.ufword;
    this.minLeftSideBearing = p22.fword;
    this.minRightSideBearing = p22.fword;
    this.xMaxExtent = p22.fword;
    this.caretSlopeRise = p22.int16;
    this.caretSlopeRun = p22.int16;
    this.caretOffset = p22.int16;
    p22.int16;
    p22.int16;
    p22.int16;
    p22.int16;
    this.metricDataFormat = p22.int16;
    this.numberOfHMetrics = p22.uint16;
    p22.verifyLength();
  }
};
var hhea$1 = Object.freeze({ __proto__: null, hhea });
var hmtx = class extends SimpleTable {
  constructor(dict, dataview, tables) {
    const { p: p22 } = super(dict, dataview);
    const numberOfHMetrics = tables.hhea.numberOfHMetrics;
    const numGlyphs = tables.maxp.numGlyphs;
    const metricsStart = p22.currentPosition;
    lazy$1(this, `hMetrics`, () => {
      p22.currentPosition = metricsStart;
      return [...new Array(numberOfHMetrics)].map(
        (_) => new LongHorMetric(p22.uint16, p22.int16)
      );
    });
    if (numberOfHMetrics < numGlyphs) {
      const lsbStart = metricsStart + numberOfHMetrics * 4;
      lazy$1(this, `leftSideBearings`, () => {
        p22.currentPosition = lsbStart;
        return [...new Array(numGlyphs - numberOfHMetrics)].map(
          (_) => p22.int16
        );
      });
    }
  }
};
var LongHorMetric = class {
  constructor(w2, b2) {
    this.advanceWidth = w2;
    this.lsb = b2;
  }
};
var hmtx$1 = Object.freeze({ __proto__: null, hmtx });
var maxp = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.legacyFixed;
    this.numGlyphs = p22.uint16;
    if (this.version === 1) {
      this.maxPoints = p22.uint16;
      this.maxContours = p22.uint16;
      this.maxCompositePoints = p22.uint16;
      this.maxCompositeContours = p22.uint16;
      this.maxZones = p22.uint16;
      this.maxTwilightPoints = p22.uint16;
      this.maxStorage = p22.uint16;
      this.maxFunctionDefs = p22.uint16;
      this.maxInstructionDefs = p22.uint16;
      this.maxStackElements = p22.uint16;
      this.maxSizeOfInstructions = p22.uint16;
      this.maxComponentElements = p22.uint16;
      this.maxComponentDepth = p22.uint16;
    }
    p22.verifyLength();
  }
};
var maxp$1 = Object.freeze({ __proto__: null, maxp });
var name = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.format = p22.uint16;
    this.count = p22.uint16;
    this.stringOffset = p22.Offset16;
    this.nameRecords = [...new Array(this.count)].map(
      (_) => new NameRecord(p22, this)
    );
    if (this.format === 1) {
      this.langTagCount = p22.uint16;
      this.langTagRecords = [...new Array(this.langTagCount)].map(
        (_) => new LangTagRecord(p22.uint16, p22.Offset16)
      );
    }
    this.stringStart = this.tableStart + this.stringOffset;
  }
  get(nameID) {
    let record = this.nameRecords.find(
      (record2) => record2.nameID === nameID
    );
    if (record) return record.string;
  }
};
var LangTagRecord = class {
  constructor(length, offset4) {
    this.length = length;
    this.offset = offset4;
  }
};
var NameRecord = class {
  constructor(p22, nameTable) {
    this.platformID = p22.uint16;
    this.encodingID = p22.uint16;
    this.languageID = p22.uint16;
    this.nameID = p22.uint16;
    this.length = p22.uint16;
    this.offset = p22.Offset16;
    lazy$1(this, `string`, () => {
      p22.currentPosition = nameTable.stringStart + this.offset;
      return decodeString(p22, this);
    });
  }
};
function decodeString(p22, record) {
  const { platformID, length } = record;
  if (length === 0) return ``;
  if (platformID === 0 || platformID === 3) {
    const str2 = [];
    for (let i2 = 0, e2 = length / 2; i2 < e2; i2++)
      str2[i2] = String.fromCharCode(p22.uint16);
    return str2.join(``);
  }
  const bytes = p22.readBytes(length);
  const str = [];
  bytes.forEach(function(b2, i2) {
    str[i2] = String.fromCharCode(b2);
  });
  return str.join(``);
}
var name$1 = Object.freeze({ __proto__: null, name });
var OS2 = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.xAvgCharWidth = p22.int16;
    this.usWeightClass = p22.uint16;
    this.usWidthClass = p22.uint16;
    this.fsType = p22.uint16;
    this.ySubscriptXSize = p22.int16;
    this.ySubscriptYSize = p22.int16;
    this.ySubscriptXOffset = p22.int16;
    this.ySubscriptYOffset = p22.int16;
    this.ySuperscriptXSize = p22.int16;
    this.ySuperscriptYSize = p22.int16;
    this.ySuperscriptXOffset = p22.int16;
    this.ySuperscriptYOffset = p22.int16;
    this.yStrikeoutSize = p22.int16;
    this.yStrikeoutPosition = p22.int16;
    this.sFamilyClass = p22.int16;
    this.panose = [...new Array(10)].map((_) => p22.uint8);
    this.ulUnicodeRange1 = p22.flags(32);
    this.ulUnicodeRange2 = p22.flags(32);
    this.ulUnicodeRange3 = p22.flags(32);
    this.ulUnicodeRange4 = p22.flags(32);
    this.achVendID = p22.tag;
    this.fsSelection = p22.uint16;
    this.usFirstCharIndex = p22.uint16;
    this.usLastCharIndex = p22.uint16;
    this.sTypoAscender = p22.int16;
    this.sTypoDescender = p22.int16;
    this.sTypoLineGap = p22.int16;
    this.usWinAscent = p22.uint16;
    this.usWinDescent = p22.uint16;
    if (this.version === 0) return p22.verifyLength();
    this.ulCodePageRange1 = p22.flags(32);
    this.ulCodePageRange2 = p22.flags(32);
    if (this.version === 1) return p22.verifyLength();
    this.sxHeight = p22.int16;
    this.sCapHeight = p22.int16;
    this.usDefaultChar = p22.uint16;
    this.usBreakChar = p22.uint16;
    this.usMaxContext = p22.uint16;
    if (this.version <= 4) return p22.verifyLength();
    this.usLowerOpticalPointSize = p22.uint16;
    this.usUpperOpticalPointSize = p22.uint16;
    if (this.version === 5) return p22.verifyLength();
  }
};
var OS2$1 = Object.freeze({ __proto__: null, OS2 });
var post = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.legacyFixed;
    this.italicAngle = p22.fixed;
    this.underlinePosition = p22.fword;
    this.underlineThickness = p22.fword;
    this.isFixedPitch = p22.uint32;
    this.minMemType42 = p22.uint32;
    this.maxMemType42 = p22.uint32;
    this.minMemType1 = p22.uint32;
    this.maxMemType1 = p22.uint32;
    if (this.version === 1 || this.version === 3) return p22.verifyLength();
    this.numGlyphs = p22.uint16;
    if (this.version === 2) {
      this.glyphNameIndex = [...new Array(this.numGlyphs)].map(
        (_) => p22.uint16
      );
      this.namesOffset = p22.currentPosition;
      this.glyphNameOffsets = [1];
      for (let i2 = 0; i2 < this.numGlyphs; i2++) {
        let index2 = this.glyphNameIndex[i2];
        if (index2 < macStrings.length) {
          this.glyphNameOffsets.push(this.glyphNameOffsets[i2]);
          continue;
        }
        let bytelength = p22.int8;
        p22.skip(bytelength);
        this.glyphNameOffsets.push(
          this.glyphNameOffsets[i2] + bytelength + 1
        );
      }
    }
    if (this.version === 2.5) {
      this.offset = [...new Array(this.numGlyphs)].map(
        (_) => p22.int8
      );
    }
  }
  getGlyphName(glyphid) {
    if (this.version !== 2) {
      console.warn(
        `post table version ${this.version} does not support glyph name lookups`
      );
      return ``;
    }
    let index2 = this.glyphNameIndex[glyphid];
    if (index2 < 258) return macStrings[index2];
    let offset4 = this.glyphNameOffsets[glyphid];
    let next = this.glyphNameOffsets[glyphid + 1];
    let len = next - offset4 - 1;
    if (len === 0) return `.notdef.`;
    this.parser.currentPosition = this.namesOffset + offset4;
    const data = this.parser.readBytes(
      len,
      this.namesOffset + offset4,
      8,
      true
    );
    return data.map((b2) => String.fromCharCode(b2)).join(``);
  }
};
var macStrings = [
  `.notdef`,
  `.null`,
  `nonmarkingreturn`,
  `space`,
  `exclam`,
  `quotedbl`,
  `numbersign`,
  `dollar`,
  `percent`,
  `ampersand`,
  `quotesingle`,
  `parenleft`,
  `parenright`,
  `asterisk`,
  `plus`,
  `comma`,
  `hyphen`,
  `period`,
  `slash`,
  `zero`,
  `one`,
  `two`,
  `three`,
  `four`,
  `five`,
  `six`,
  `seven`,
  `eight`,
  `nine`,
  `colon`,
  `semicolon`,
  `less`,
  `equal`,
  `greater`,
  `question`,
  `at`,
  `A`,
  `B`,
  `C`,
  `D`,
  `E`,
  `F`,
  `G`,
  `H`,
  `I`,
  `J`,
  `K`,
  `L`,
  `M`,
  `N`,
  `O`,
  `P`,
  `Q`,
  `R`,
  `S`,
  `T`,
  `U`,
  `V`,
  `W`,
  `X`,
  `Y`,
  `Z`,
  `bracketleft`,
  `backslash`,
  `bracketright`,
  `asciicircum`,
  `underscore`,
  `grave`,
  `a`,
  `b`,
  `c`,
  `d`,
  `e`,
  `f`,
  `g`,
  `h`,
  `i`,
  `j`,
  `k`,
  `l`,
  `m`,
  `n`,
  `o`,
  `p`,
  `q`,
  `r`,
  `s`,
  `t`,
  `u`,
  `v`,
  `w`,
  `x`,
  `y`,
  `z`,
  `braceleft`,
  `bar`,
  `braceright`,
  `asciitilde`,
  `Adieresis`,
  `Aring`,
  `Ccedilla`,
  `Eacute`,
  `Ntilde`,
  `Odieresis`,
  `Udieresis`,
  `aacute`,
  `agrave`,
  `acircumflex`,
  `adieresis`,
  `atilde`,
  `aring`,
  `ccedilla`,
  `eacute`,
  `egrave`,
  `ecircumflex`,
  `edieresis`,
  `iacute`,
  `igrave`,
  `icircumflex`,
  `idieresis`,
  `ntilde`,
  `oacute`,
  `ograve`,
  `ocircumflex`,
  `odieresis`,
  `otilde`,
  `uacute`,
  `ugrave`,
  `ucircumflex`,
  `udieresis`,
  `dagger`,
  `degree`,
  `cent`,
  `sterling`,
  `section`,
  `bullet`,
  `paragraph`,
  `germandbls`,
  `registered`,
  `copyright`,
  `trademark`,
  `acute`,
  `dieresis`,
  `notequal`,
  `AE`,
  `Oslash`,
  `infinity`,
  `plusminus`,
  `lessequal`,
  `greaterequal`,
  `yen`,
  `mu`,
  `partialdiff`,
  `summation`,
  `product`,
  `pi`,
  `integral`,
  `ordfeminine`,
  `ordmasculine`,
  `Omega`,
  `ae`,
  `oslash`,
  `questiondown`,
  `exclamdown`,
  `logicalnot`,
  `radical`,
  `florin`,
  `approxequal`,
  `Delta`,
  `guillemotleft`,
  `guillemotright`,
  `ellipsis`,
  `nonbreakingspace`,
  `Agrave`,
  `Atilde`,
  `Otilde`,
  `OE`,
  `oe`,
  `endash`,
  `emdash`,
  `quotedblleft`,
  `quotedblright`,
  `quoteleft`,
  `quoteright`,
  `divide`,
  `lozenge`,
  `ydieresis`,
  `Ydieresis`,
  `fraction`,
  `currency`,
  `guilsinglleft`,
  `guilsinglright`,
  `fi`,
  `fl`,
  `daggerdbl`,
  `periodcentered`,
  `quotesinglbase`,
  `quotedblbase`,
  `perthousand`,
  `Acircumflex`,
  `Ecircumflex`,
  `Aacute`,
  `Edieresis`,
  `Egrave`,
  `Iacute`,
  `Icircumflex`,
  `Idieresis`,
  `Igrave`,
  `Oacute`,
  `Ocircumflex`,
  `apple`,
  `Ograve`,
  `Uacute`,
  `Ucircumflex`,
  `Ugrave`,
  `dotlessi`,
  `circumflex`,
  `tilde`,
  `macron`,
  `breve`,
  `dotaccent`,
  `ring`,
  `cedilla`,
  `hungarumlaut`,
  `ogonek`,
  `caron`,
  `Lslash`,
  `lslash`,
  `Scaron`,
  `scaron`,
  `Zcaron`,
  `zcaron`,
  `brokenbar`,
  `Eth`,
  `eth`,
  `Yacute`,
  `yacute`,
  `Thorn`,
  `thorn`,
  `minus`,
  `multiply`,
  `onesuperior`,
  `twosuperior`,
  `threesuperior`,
  `onehalf`,
  `onequarter`,
  `threequarters`,
  `franc`,
  `Gbreve`,
  `gbreve`,
  `Idotaccent`,
  `Scedilla`,
  `scedilla`,
  `Cacute`,
  `cacute`,
  `Ccaron`,
  `ccaron`,
  `dcroat`
];
var post$1 = Object.freeze({ __proto__: null, post });
var BASE = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.horizAxisOffset = p22.Offset16;
    this.vertAxisOffset = p22.Offset16;
    lazy$1(
      this,
      `horizAxis`,
      () => new AxisTable(
        { offset: dict.offset + this.horizAxisOffset },
        dataview
      )
    );
    lazy$1(
      this,
      `vertAxis`,
      () => new AxisTable(
        { offset: dict.offset + this.vertAxisOffset },
        dataview
      )
    );
    if (this.majorVersion === 1 && this.minorVersion === 1) {
      this.itemVarStoreOffset = p22.Offset32;
      lazy$1(
        this,
        `itemVarStore`,
        () => new AxisTable(
          { offset: dict.offset + this.itemVarStoreOffset },
          dataview
        )
      );
    }
  }
};
var AxisTable = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview, `AxisTable`);
    this.baseTagListOffset = p22.Offset16;
    this.baseScriptListOffset = p22.Offset16;
    lazy$1(
      this,
      `baseTagList`,
      () => new BaseTagListTable(
        { offset: dict.offset + this.baseTagListOffset },
        dataview
      )
    );
    lazy$1(
      this,
      `baseScriptList`,
      () => new BaseScriptListTable(
        { offset: dict.offset + this.baseScriptListOffset },
        dataview
      )
    );
  }
};
var BaseTagListTable = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview, `BaseTagListTable`);
    this.baseTagCount = p22.uint16;
    this.baselineTags = [...new Array(this.baseTagCount)].map(
      (_) => p22.tag
    );
  }
};
var BaseScriptListTable = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview, `BaseScriptListTable`);
    this.baseScriptCount = p22.uint16;
    const recordStart = p22.currentPosition;
    lazy$1(this, `baseScriptRecords`, () => {
      p22.currentPosition = recordStart;
      return [...new Array(this.baseScriptCount)].map(
        (_) => new BaseScriptRecord(this.start, p22)
      );
    });
  }
};
var BaseScriptRecord = class {
  constructor(baseScriptListTableStart, p22) {
    this.baseScriptTag = p22.tag;
    this.baseScriptOffset = p22.Offset16;
    lazy$1(this, `baseScriptTable`, () => {
      p22.currentPosition = baseScriptListTableStart + this.baseScriptOffset;
      return new BaseScriptTable(p22);
    });
  }
};
var BaseScriptTable = class {
  constructor(p22) {
    this.start = p22.currentPosition;
    this.baseValuesOffset = p22.Offset16;
    this.defaultMinMaxOffset = p22.Offset16;
    this.baseLangSysCount = p22.uint16;
    this.baseLangSysRecords = [...new Array(this.baseLangSysCount)].map(
      (_) => new BaseLangSysRecord(this.start, p22)
    );
    lazy$1(this, `baseValues`, () => {
      p22.currentPosition = this.start + this.baseValuesOffset;
      return new BaseValuesTable(p22);
    });
    lazy$1(this, `defaultMinMax`, () => {
      p22.currentPosition = this.start + this.defaultMinMaxOffset;
      return new MinMaxTable(p22);
    });
  }
};
var BaseLangSysRecord = class {
  constructor(baseScriptTableStart, p22) {
    this.baseLangSysTag = p22.tag;
    this.minMaxOffset = p22.Offset16;
    lazy$1(this, `minMax`, () => {
      p22.currentPosition = baseScriptTableStart + this.minMaxOffset;
      return new MinMaxTable(p22);
    });
  }
};
var BaseValuesTable = class {
  constructor(p22) {
    this.parser = p22;
    this.start = p22.currentPosition;
    this.defaultBaselineIndex = p22.uint16;
    this.baseCoordCount = p22.uint16;
    this.baseCoords = [...new Array(this.baseCoordCount)].map(
      (_) => p22.Offset16
    );
  }
  getTable(id) {
    this.parser.currentPosition = this.start + this.baseCoords[id];
    return new BaseCoordTable(this.parser);
  }
};
var MinMaxTable = class {
  constructor(p22) {
    this.minCoord = p22.Offset16;
    this.maxCoord = p22.Offset16;
    this.featMinMaxCount = p22.uint16;
    const recordStart = p22.currentPosition;
    lazy$1(this, `featMinMaxRecords`, () => {
      p22.currentPosition = recordStart;
      return [...new Array(this.featMinMaxCount)].map(
        (_) => new FeatMinMaxRecord(p22)
      );
    });
  }
};
var FeatMinMaxRecord = class {
  constructor(p22) {
    this.featureTableTag = p22.tag;
    this.minCoord = p22.Offset16;
    this.maxCoord = p22.Offset16;
  }
};
var BaseCoordTable = class {
  constructor(p22) {
    this.baseCoordFormat = p22.uint16;
    this.coordinate = p22.int16;
    if (this.baseCoordFormat === 2) {
      this.referenceGlyph = p22.uint16;
      this.baseCoordPoint = p22.uint16;
    }
    if (this.baseCoordFormat === 3) {
      this.deviceTable = p22.Offset16;
    }
  }
};
var BASE$1 = Object.freeze({ __proto__: null, BASE });
var ClassDefinition = class {
  constructor(p22) {
    this.classFormat = p22.uint16;
    if (this.classFormat === 1) {
      this.startGlyphID = p22.uint16;
      this.glyphCount = p22.uint16;
      this.classValueArray = [...new Array(this.glyphCount)].map(
        (_) => p22.uint16
      );
    }
    if (this.classFormat === 2) {
      this.classRangeCount = p22.uint16;
      this.classRangeRecords = [
        ...new Array(this.classRangeCount)
      ].map((_) => new ClassRangeRecord(p22));
    }
  }
};
var ClassRangeRecord = class {
  constructor(p22) {
    this.startGlyphID = p22.uint16;
    this.endGlyphID = p22.uint16;
    this.class = p22.uint16;
  }
};
var CoverageTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.coverageFormat = p22.uint16;
    if (this.coverageFormat === 1) {
      this.glyphCount = p22.uint16;
      this.glyphArray = [...new Array(this.glyphCount)].map(
        (_) => p22.uint16
      );
    }
    if (this.coverageFormat === 2) {
      this.rangeCount = p22.uint16;
      this.rangeRecords = [...new Array(this.rangeCount)].map(
        (_) => new CoverageRangeRecord(p22)
      );
    }
  }
};
var CoverageRangeRecord = class {
  constructor(p22) {
    this.startGlyphID = p22.uint16;
    this.endGlyphID = p22.uint16;
    this.startCoverageIndex = p22.uint16;
  }
};
var ItemVariationStoreTable = class {
  constructor(table, p22) {
    this.table = table;
    this.parser = p22;
    this.start = p22.currentPosition;
    this.format = p22.uint16;
    this.variationRegionListOffset = p22.Offset32;
    this.itemVariationDataCount = p22.uint16;
    this.itemVariationDataOffsets = [
      ...new Array(this.itemVariationDataCount)
    ].map((_) => p22.Offset32);
  }
};
var GDEF = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.glyphClassDefOffset = p22.Offset16;
    lazy$1(this, `glyphClassDefs`, () => {
      if (this.glyphClassDefOffset === 0) return void 0;
      p22.currentPosition = this.tableStart + this.glyphClassDefOffset;
      return new ClassDefinition(p22);
    });
    this.attachListOffset = p22.Offset16;
    lazy$1(this, `attachList`, () => {
      if (this.attachListOffset === 0) return void 0;
      p22.currentPosition = this.tableStart + this.attachListOffset;
      return new AttachList(p22);
    });
    this.ligCaretListOffset = p22.Offset16;
    lazy$1(this, `ligCaretList`, () => {
      if (this.ligCaretListOffset === 0) return void 0;
      p22.currentPosition = this.tableStart + this.ligCaretListOffset;
      return new LigCaretList(p22);
    });
    this.markAttachClassDefOffset = p22.Offset16;
    lazy$1(this, `markAttachClassDef`, () => {
      if (this.markAttachClassDefOffset === 0) return void 0;
      p22.currentPosition = this.tableStart + this.markAttachClassDefOffset;
      return new ClassDefinition(p22);
    });
    if (this.minorVersion >= 2) {
      this.markGlyphSetsDefOffset = p22.Offset16;
      lazy$1(this, `markGlyphSetsDef`, () => {
        if (this.markGlyphSetsDefOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.markGlyphSetsDefOffset;
        return new MarkGlyphSetsTable(p22);
      });
    }
    if (this.minorVersion === 3) {
      this.itemVarStoreOffset = p22.Offset32;
      lazy$1(this, `itemVarStore`, () => {
        if (this.itemVarStoreOffset === 0) return void 0;
        p22.currentPosition = this.tableStart + this.itemVarStoreOffset;
        return new ItemVariationStoreTable(p22);
      });
    }
  }
};
var AttachList = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.coverageOffset = p22.Offset16;
    this.glyphCount = p22.uint16;
    this.attachPointOffsets = [...new Array(this.glyphCount)].map(
      (_) => p22.Offset16
    );
  }
  getPoint(pointID) {
    this.parser.currentPosition = this.start + this.attachPointOffsets[pointID];
    return new AttachPoint(this.parser);
  }
};
var AttachPoint = class {
  constructor(p22) {
    this.pointCount = p22.uint16;
    this.pointIndices = [...new Array(this.pointCount)].map(
      (_) => p22.uint16
    );
  }
};
var LigCaretList = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.coverageOffset = p22.Offset16;
    lazy$1(this, `coverage`, () => {
      p22.currentPosition = this.start + this.coverageOffset;
      return new CoverageTable(p22);
    });
    this.ligGlyphCount = p22.uint16;
    this.ligGlyphOffsets = [...new Array(this.ligGlyphCount)].map(
      (_) => p22.Offset16
    );
  }
  getLigGlyph(ligGlyphID) {
    this.parser.currentPosition = this.start + this.ligGlyphOffsets[ligGlyphID];
    return new LigGlyph(this.parser);
  }
};
var LigGlyph = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.caretCount = p22.uint16;
    this.caretValueOffsets = [...new Array(this.caretCount)].map(
      (_) => p22.Offset16
    );
  }
  getCaretValue(caretID) {
    this.parser.currentPosition = this.start + this.caretValueOffsets[caretID];
    return new CaretValue(this.parser);
  }
};
var CaretValue = class {
  constructor(p22) {
    this.caretValueFormat = p22.uint16;
    if (this.caretValueFormat === 1) {
      this.coordinate = p22.int16;
    }
    if (this.caretValueFormat === 2) {
      this.caretValuePointIndex = p22.uint16;
    }
    if (this.caretValueFormat === 3) {
      this.coordinate = p22.int16;
      this.deviceOffset = p22.Offset16;
    }
  }
};
var MarkGlyphSetsTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.markGlyphSetTableFormat = p22.uint16;
    this.markGlyphSetCount = p22.uint16;
    this.coverageOffsets = [...new Array(this.markGlyphSetCount)].map(
      (_) => p22.Offset32
    );
  }
  getMarkGlyphSet(markGlyphSetID) {
    this.parser.currentPosition = this.start + this.coverageOffsets[markGlyphSetID];
    return new CoverageTable(this.parser);
  }
};
var GDEF$1 = Object.freeze({ __proto__: null, GDEF });
var ScriptList = class extends ParsedData {
  static EMPTY = { scriptCount: 0, scriptRecords: [] };
  constructor(p22) {
    super(p22);
    this.scriptCount = p22.uint16;
    this.scriptRecords = [...new Array(this.scriptCount)].map(
      (_) => new ScriptRecord(p22)
    );
  }
};
var ScriptRecord = class {
  constructor(p22) {
    this.scriptTag = p22.tag;
    this.scriptOffset = p22.Offset16;
  }
};
var ScriptTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.defaultLangSys = p22.Offset16;
    this.langSysCount = p22.uint16;
    this.langSysRecords = [...new Array(this.langSysCount)].map(
      (_) => new LangSysRecord(p22)
    );
  }
};
var LangSysRecord = class {
  constructor(p22) {
    this.langSysTag = p22.tag;
    this.langSysOffset = p22.Offset16;
  }
};
var LangSysTable = class {
  constructor(p22) {
    this.lookupOrder = p22.Offset16;
    this.requiredFeatureIndex = p22.uint16;
    this.featureIndexCount = p22.uint16;
    this.featureIndices = [...new Array(this.featureIndexCount)].map(
      (_) => p22.uint16
    );
  }
};
var FeatureList = class extends ParsedData {
  static EMPTY = { featureCount: 0, featureRecords: [] };
  constructor(p22) {
    super(p22);
    this.featureCount = p22.uint16;
    this.featureRecords = [...new Array(this.featureCount)].map(
      (_) => new FeatureRecord(p22)
    );
  }
};
var FeatureRecord = class {
  constructor(p22) {
    this.featureTag = p22.tag;
    this.featureOffset = p22.Offset16;
  }
};
var FeatureTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.featureParams = p22.Offset16;
    this.lookupIndexCount = p22.uint16;
    this.lookupListIndices = [...new Array(this.lookupIndexCount)].map(
      (_) => p22.uint16
    );
  }
  getFeatureParams() {
    if (this.featureParams > 0) {
      const p22 = this.parser;
      p22.currentPosition = this.start + this.featureParams;
      const tag = this.featureTag;
      if (tag === `size`) return new Size(p22);
      if (tag.startsWith(`cc`)) return new CharacterVariant(p22);
      if (tag.startsWith(`ss`)) return new StylisticSet(p22);
    }
  }
};
var CharacterVariant = class {
  constructor(p22) {
    this.format = p22.uint16;
    this.featUiLabelNameId = p22.uint16;
    this.featUiTooltipTextNameId = p22.uint16;
    this.sampleTextNameId = p22.uint16;
    this.numNamedParameters = p22.uint16;
    this.firstParamUiLabelNameId = p22.uint16;
    this.charCount = p22.uint16;
    this.character = [...new Array(this.charCount)].map(
      (_) => p22.uint24
    );
  }
};
var Size = class {
  constructor(p22) {
    this.designSize = p22.uint16;
    this.subfamilyIdentifier = p22.uint16;
    this.subfamilyNameID = p22.uint16;
    this.smallEnd = p22.uint16;
    this.largeEnd = p22.uint16;
  }
};
var StylisticSet = class {
  constructor(p22) {
    this.version = p22.uint16;
    this.UINameID = p22.uint16;
  }
};
function undoCoverageOffsetParsing(instance) {
  instance.parser.currentPosition -= 2;
  delete instance.coverageOffset;
  delete instance.getCoverageTable;
}
var LookupType$1 = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.substFormat = p22.uint16;
    this.coverageOffset = p22.Offset16;
  }
  getCoverageTable() {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.coverageOffset;
    return new CoverageTable(p22);
  }
};
var SubstLookupRecord = class {
  constructor(p22) {
    this.glyphSequenceIndex = p22.uint16;
    this.lookupListIndex = p22.uint16;
  }
};
var LookupType1$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    this.deltaGlyphID = p22.int16;
  }
};
var LookupType2$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    this.sequenceCount = p22.uint16;
    this.sequenceOffsets = [...new Array(this.sequenceCount)].map(
      (_) => p22.Offset16
    );
  }
  getSequence(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.sequenceOffsets[index2];
    return new SequenceTable(p22);
  }
};
var SequenceTable = class {
  constructor(p22) {
    this.glyphCount = p22.uint16;
    this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
      (_) => p22.uint16
    );
  }
};
var LookupType3$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    this.alternateSetCount = p22.uint16;
    this.alternateSetOffsets = [
      ...new Array(this.alternateSetCount)
    ].map((_) => p22.Offset16);
  }
  getAlternateSet(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.alternateSetOffsets[index2];
    return new AlternateSetTable(p22);
  }
};
var AlternateSetTable = class {
  constructor(p22) {
    this.glyphCount = p22.uint16;
    this.alternateGlyphIDs = [...new Array(this.glyphCount)].map(
      (_) => p22.uint16
    );
  }
};
var LookupType4$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    this.ligatureSetCount = p22.uint16;
    this.ligatureSetOffsets = [...new Array(this.ligatureSetCount)].map(
      (_) => p22.Offset16
    );
  }
  getLigatureSet(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.ligatureSetOffsets[index2];
    return new LigatureSetTable(p22);
  }
};
var LigatureSetTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.ligatureCount = p22.uint16;
    this.ligatureOffsets = [...new Array(this.ligatureCount)].map(
      (_) => p22.Offset16
    );
  }
  getLigature(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.ligatureOffsets[index2];
    return new LigatureTable(p22);
  }
};
var LigatureTable = class {
  constructor(p22) {
    this.ligatureGlyph = p22.uint16;
    this.componentCount = p22.uint16;
    this.componentGlyphIDs = [
      ...new Array(this.componentCount - 1)
    ].map((_) => p22.uint16);
  }
};
var LookupType5$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    if (this.substFormat === 1) {
      this.subRuleSetCount = p22.uint16;
      this.subRuleSetOffsets = [
        ...new Array(this.subRuleSetCount)
      ].map((_) => p22.Offset16);
    }
    if (this.substFormat === 2) {
      this.classDefOffset = p22.Offset16;
      this.subClassSetCount = p22.uint16;
      this.subClassSetOffsets = [
        ...new Array(this.subClassSetCount)
      ].map((_) => p22.Offset16);
    }
    if (this.substFormat === 3) {
      undoCoverageOffsetParsing(this);
      this.glyphCount = p22.uint16;
      this.substitutionCount = p22.uint16;
      this.coverageOffsets = [...new Array(this.glyphCount)].map(
        (_) => p22.Offset16
      );
      this.substLookupRecords = [
        ...new Array(this.substitutionCount)
      ].map((_) => new SubstLookupRecord(p22));
    }
  }
  getSubRuleSet(index2) {
    if (this.substFormat !== 1)
      throw new Error(
        `lookup type 5.${this.substFormat} has no subrule sets.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subRuleSetOffsets[index2];
    return new SubRuleSetTable(p22);
  }
  getSubClassSet(index2) {
    if (this.substFormat !== 2)
      throw new Error(
        `lookup type 5.${this.substFormat} has no subclass sets.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subClassSetOffsets[index2];
    return new SubClassSetTable(p22);
  }
  getCoverageTable(index2) {
    if (this.substFormat !== 3 && !index2)
      return super.getCoverageTable();
    if (!index2)
      throw new Error(
        `lookup type 5.${this.substFormat} requires an coverage table index.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.coverageOffsets[index2];
    return new CoverageTable(p22);
  }
};
var SubRuleSetTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.subRuleCount = p22.uint16;
    this.subRuleOffsets = [...new Array(this.subRuleCount)].map(
      (_) => p22.Offset16
    );
  }
  getSubRule(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subRuleOffsets[index2];
    return new SubRuleTable(p22);
  }
};
var SubRuleTable = class {
  constructor(p22) {
    this.glyphCount = p22.uint16;
    this.substitutionCount = p22.uint16;
    this.inputSequence = [...new Array(this.glyphCount - 1)].map(
      (_) => p22.uint16
    );
    this.substLookupRecords = [
      ...new Array(this.substitutionCount)
    ].map((_) => new SubstLookupRecord(p22));
  }
};
var SubClassSetTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.subClassRuleCount = p22.uint16;
    this.subClassRuleOffsets = [
      ...new Array(this.subClassRuleCount)
    ].map((_) => p22.Offset16);
  }
  getSubClass(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subClassRuleOffsets[index2];
    return new SubClassRuleTable(p22);
  }
};
var SubClassRuleTable = class extends SubRuleTable {
  constructor(p22) {
    super(p22);
  }
};
var LookupType6$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    if (this.substFormat === 1) {
      this.chainSubRuleSetCount = p22.uint16;
      this.chainSubRuleSetOffsets = [
        ...new Array(this.chainSubRuleSetCount)
      ].map((_) => p22.Offset16);
    }
    if (this.substFormat === 2) {
      this.backtrackClassDefOffset = p22.Offset16;
      this.inputClassDefOffset = p22.Offset16;
      this.lookaheadClassDefOffset = p22.Offset16;
      this.chainSubClassSetCount = p22.uint16;
      this.chainSubClassSetOffsets = [
        ...new Array(this.chainSubClassSetCount)
      ].map((_) => p22.Offset16);
    }
    if (this.substFormat === 3) {
      undoCoverageOffsetParsing(this);
      this.backtrackGlyphCount = p22.uint16;
      this.backtrackCoverageOffsets = [
        ...new Array(this.backtrackGlyphCount)
      ].map((_) => p22.Offset16);
      this.inputGlyphCount = p22.uint16;
      this.inputCoverageOffsets = [
        ...new Array(this.inputGlyphCount)
      ].map((_) => p22.Offset16);
      this.lookaheadGlyphCount = p22.uint16;
      this.lookaheadCoverageOffsets = [
        ...new Array(this.lookaheadGlyphCount)
      ].map((_) => p22.Offset16);
      this.seqLookupCount = p22.uint16;
      this.seqLookupRecords = [
        ...new Array(this.substitutionCount)
      ].map((_) => new SequenceLookupRecord(p22));
    }
  }
  getChainSubRuleSet(index2) {
    if (this.substFormat !== 1)
      throw new Error(
        `lookup type 6.${this.substFormat} has no chainsubrule sets.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubRuleSetOffsets[index2];
    return new ChainSubRuleSetTable(p22);
  }
  getChainSubClassSet(index2) {
    if (this.substFormat !== 2)
      throw new Error(
        `lookup type 6.${this.substFormat} has no chainsubclass sets.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubClassSetOffsets[index2];
    return new ChainSubClassSetTable(p22);
  }
  getCoverageFromOffset(offset4) {
    if (this.substFormat !== 3)
      throw new Error(
        `lookup type 6.${this.substFormat} does not use contextual coverage offsets.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + offset4;
    return new CoverageTable(p22);
  }
};
var ChainSubRuleSetTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.chainSubRuleCount = p22.uint16;
    this.chainSubRuleOffsets = [
      ...new Array(this.chainSubRuleCount)
    ].map((_) => p22.Offset16);
  }
  getSubRule(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubRuleOffsets[index2];
    return new ChainSubRuleTable(p22);
  }
};
var ChainSubRuleTable = class {
  constructor(p22) {
    this.backtrackGlyphCount = p22.uint16;
    this.backtrackSequence = [
      ...new Array(this.backtrackGlyphCount)
    ].map((_) => p22.uint16);
    this.inputGlyphCount = p22.uint16;
    this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
      (_) => p22.uint16
    );
    this.lookaheadGlyphCount = p22.uint16;
    this.lookAheadSequence = [
      ...new Array(this.lookAheadGlyphCount)
    ].map((_) => p22.uint16);
    this.substitutionCount = p22.uint16;
    this.substLookupRecords = [...new Array(this.SubstCount)].map(
      (_) => new SubstLookupRecord(p22)
    );
  }
};
var ChainSubClassSetTable = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.chainSubClassRuleCount = p22.uint16;
    this.chainSubClassRuleOffsets = [
      ...new Array(this.chainSubClassRuleCount)
    ].map((_) => p22.Offset16);
  }
  getSubClass(index2) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubRuleOffsets[index2];
    return new ChainSubClassRuleTable(p22);
  }
};
var ChainSubClassRuleTable = class {
  constructor(p22) {
    this.backtrackGlyphCount = p22.uint16;
    this.backtrackSequence = [
      ...new Array(this.backtrackGlyphCount)
    ].map((_) => p22.uint16);
    this.inputGlyphCount = p22.uint16;
    this.inputSequence = [...new Array(this.inputGlyphCount - 1)].map(
      (_) => p22.uint16
    );
    this.lookaheadGlyphCount = p22.uint16;
    this.lookAheadSequence = [
      ...new Array(this.lookAheadGlyphCount)
    ].map((_) => p22.uint16);
    this.substitutionCount = p22.uint16;
    this.substLookupRecords = [
      ...new Array(this.substitutionCount)
    ].map((_) => new SequenceLookupRecord(p22));
  }
};
var SequenceLookupRecord = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.sequenceIndex = p22.uint16;
    this.lookupListIndex = p22.uint16;
  }
};
var LookupType7$1 = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.substFormat = p22.uint16;
    this.extensionLookupType = p22.uint16;
    this.extensionOffset = p22.Offset32;
  }
};
var LookupType8$1 = class extends LookupType$1 {
  constructor(p22) {
    super(p22);
    this.backtrackGlyphCount = p22.uint16;
    this.backtrackCoverageOffsets = [
      ...new Array(this.backtrackGlyphCount)
    ].map((_) => p22.Offset16);
    this.lookaheadGlyphCount = p22.uint16;
    this.lookaheadCoverageOffsets = [
      new Array(this.lookaheadGlyphCount)
    ].map((_) => p22.Offset16);
    this.glyphCount = p22.uint16;
    this.substituteGlyphIDs = [...new Array(this.glyphCount)].map(
      (_) => p22.uint16
    );
  }
};
var GSUBtables = {
  buildSubtable: function(type, p22) {
    const subtable = new [
      void 0,
      LookupType1$1,
      LookupType2$1,
      LookupType3$1,
      LookupType4$1,
      LookupType5$1,
      LookupType6$1,
      LookupType7$1,
      LookupType8$1
    ][type](p22);
    subtable.type = type;
    return subtable;
  }
};
var LookupType = class extends ParsedData {
  constructor(p22) {
    super(p22);
  }
};
var LookupType1 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 1`);
  }
};
var LookupType2 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 2`);
  }
};
var LookupType3 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 3`);
  }
};
var LookupType4 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 4`);
  }
};
var LookupType5 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 5`);
  }
};
var LookupType6 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 6`);
  }
};
var LookupType7 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 7`);
  }
};
var LookupType8 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 8`);
  }
};
var LookupType9 = class extends LookupType {
  constructor(p22) {
    super(p22);
    console.log(`lookup type 9`);
  }
};
var GPOStables = {
  buildSubtable: function(type, p22) {
    const subtable = new [
      void 0,
      LookupType1,
      LookupType2,
      LookupType3,
      LookupType4,
      LookupType5,
      LookupType6,
      LookupType7,
      LookupType8,
      LookupType9
    ][type](p22);
    subtable.type = type;
    return subtable;
  }
};
var LookupList = class extends ParsedData {
  static EMPTY = { lookupCount: 0, lookups: [] };
  constructor(p22) {
    super(p22);
    this.lookupCount = p22.uint16;
    this.lookups = [...new Array(this.lookupCount)].map(
      (_) => p22.Offset16
    );
  }
};
var LookupTable = class extends ParsedData {
  constructor(p22, type) {
    super(p22);
    this.ctType = type;
    this.lookupType = p22.uint16;
    this.lookupFlag = p22.uint16;
    this.subTableCount = p22.uint16;
    this.subtableOffsets = [...new Array(this.subTableCount)].map(
      (_) => p22.Offset16
    );
    this.markFilteringSet = p22.uint16;
  }
  get rightToLeft() {
    return this.lookupFlag & true;
  }
  get ignoreBaseGlyphs() {
    return this.lookupFlag & true;
  }
  get ignoreLigatures() {
    return this.lookupFlag & true;
  }
  get ignoreMarks() {
    return this.lookupFlag & true;
  }
  get useMarkFilteringSet() {
    return this.lookupFlag & true;
  }
  get markAttachmentType() {
    return this.lookupFlag & true;
  }
  getSubTable(index2) {
    const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
    this.parser.currentPosition = this.start + this.subtableOffsets[index2];
    return builder.buildSubtable(this.lookupType, this.parser);
  }
};
var CommonLayoutTable = class extends SimpleTable {
  constructor(dict, dataview, name2) {
    const { p: p22, tableStart } = super(dict, dataview, name2);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.scriptListOffset = p22.Offset16;
    this.featureListOffset = p22.Offset16;
    this.lookupListOffset = p22.Offset16;
    if (this.majorVersion === 1 && this.minorVersion === 1) {
      this.featureVariationsOffset = p22.Offset32;
    }
    const no_content = !(this.scriptListOffset || this.featureListOffset || this.lookupListOffset);
    lazy$1(this, `scriptList`, () => {
      if (no_content) return ScriptList.EMPTY;
      p22.currentPosition = tableStart + this.scriptListOffset;
      return new ScriptList(p22);
    });
    lazy$1(this, `featureList`, () => {
      if (no_content) return FeatureList.EMPTY;
      p22.currentPosition = tableStart + this.featureListOffset;
      return new FeatureList(p22);
    });
    lazy$1(this, `lookupList`, () => {
      if (no_content) return LookupList.EMPTY;
      p22.currentPosition = tableStart + this.lookupListOffset;
      return new LookupList(p22);
    });
    if (this.featureVariationsOffset) {
      lazy$1(this, `featureVariations`, () => {
        if (no_content) return FeatureVariations.EMPTY;
        p22.currentPosition = tableStart + this.featureVariationsOffset;
        return new FeatureVariations(p22);
      });
    }
  }
  getSupportedScripts() {
    return this.scriptList.scriptRecords.map((r3) => r3.scriptTag);
  }
  getScriptTable(scriptTag) {
    let record = this.scriptList.scriptRecords.find(
      (r3) => r3.scriptTag === scriptTag
    );
    this.parser.currentPosition = this.scriptList.start + record.scriptOffset;
    let table = new ScriptTable(this.parser);
    table.scriptTag = scriptTag;
    return table;
  }
  ensureScriptTable(arg) {
    if (typeof arg === "string") {
      return this.getScriptTable(arg);
    }
    return arg;
  }
  getSupportedLangSys(scriptTable) {
    scriptTable = this.ensureScriptTable(scriptTable);
    const hasDefault = scriptTable.defaultLangSys !== 0;
    const supported = scriptTable.langSysRecords.map(
      (l2) => l2.langSysTag
    );
    if (hasDefault) supported.unshift(`dflt`);
    return supported;
  }
  getDefaultLangSysTable(scriptTable) {
    scriptTable = this.ensureScriptTable(scriptTable);
    let offset4 = scriptTable.defaultLangSys;
    if (offset4 !== 0) {
      this.parser.currentPosition = scriptTable.start + offset4;
      let table = new LangSysTable(this.parser);
      table.langSysTag = ``;
      table.defaultForScript = scriptTable.scriptTag;
      return table;
    }
  }
  getLangSysTable(scriptTable, langSysTag = `dflt`) {
    if (langSysTag === `dflt`)
      return this.getDefaultLangSysTable(scriptTable);
    scriptTable = this.ensureScriptTable(scriptTable);
    let record = scriptTable.langSysRecords.find(
      (l2) => l2.langSysTag === langSysTag
    );
    this.parser.currentPosition = scriptTable.start + record.langSysOffset;
    let table = new LangSysTable(this.parser);
    table.langSysTag = langSysTag;
    return table;
  }
  getFeatures(langSysTable) {
    return langSysTable.featureIndices.map(
      (index2) => this.getFeature(index2)
    );
  }
  getFeature(indexOrTag) {
    let record;
    if (parseInt(indexOrTag) == indexOrTag) {
      record = this.featureList.featureRecords[indexOrTag];
    } else {
      record = this.featureList.featureRecords.find(
        (f2) => f2.featureTag === indexOrTag
      );
    }
    if (!record) return;
    this.parser.currentPosition = this.featureList.start + record.featureOffset;
    let table = new FeatureTable(this.parser);
    table.featureTag = record.featureTag;
    return table;
  }
  getLookups(featureTable) {
    return featureTable.lookupListIndices.map(
      (index2) => this.getLookup(index2)
    );
  }
  getLookup(lookupIndex, type) {
    let lookupOffset = this.lookupList.lookups[lookupIndex];
    this.parser.currentPosition = this.lookupList.start + lookupOffset;
    return new LookupTable(this.parser, type);
  }
};
var GSUB = class extends CommonLayoutTable {
  constructor(dict, dataview) {
    super(dict, dataview, `GSUB`);
  }
  getLookup(lookupIndex) {
    return super.getLookup(lookupIndex, `GSUB`);
  }
};
var GSUB$1 = Object.freeze({ __proto__: null, GSUB });
var GPOS = class extends CommonLayoutTable {
  constructor(dict, dataview) {
    super(dict, dataview, `GPOS`);
  }
  getLookup(lookupIndex) {
    return super.getLookup(lookupIndex, `GPOS`);
  }
};
var GPOS$1 = Object.freeze({ __proto__: null, GPOS });
var SVG6 = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.offsetToSVGDocumentList = p22.Offset32;
    p22.currentPosition = this.tableStart + this.offsetToSVGDocumentList;
    this.documentList = new SVGDocumentList(p22);
  }
};
var SVGDocumentList = class extends ParsedData {
  constructor(p22) {
    super(p22);
    this.numEntries = p22.uint16;
    this.documentRecords = [...new Array(this.numEntries)].map(
      (_) => new SVGDocumentRecord(p22)
    );
  }
  getDocument(documentID) {
    let record = this.documentRecords[documentID];
    if (!record) return "";
    let offset4 = this.start + record.svgDocOffset;
    this.parser.currentPosition = offset4;
    return this.parser.readBytes(record.svgDocLength);
  }
  getDocumentForGlyph(glyphID) {
    let id = this.documentRecords.findIndex(
      (d2) => d2.startGlyphID <= glyphID && glyphID <= d2.endGlyphID
    );
    if (id === -1) return "";
    return this.getDocument(id);
  }
};
var SVGDocumentRecord = class {
  constructor(p22) {
    this.startGlyphID = p22.uint16;
    this.endGlyphID = p22.uint16;
    this.svgDocOffset = p22.Offset32;
    this.svgDocLength = p22.uint32;
  }
};
var SVG$1 = Object.freeze({ __proto__: null, SVG: SVG6 });
var fvar = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.axesArrayOffset = p22.Offset16;
    p22.uint16;
    this.axisCount = p22.uint16;
    this.axisSize = p22.uint16;
    this.instanceCount = p22.uint16;
    this.instanceSize = p22.uint16;
    const axisStart = this.tableStart + this.axesArrayOffset;
    lazy$1(this, `axes`, () => {
      p22.currentPosition = axisStart;
      return [...new Array(this.axisCount)].map(
        (_) => new VariationAxisRecord(p22)
      );
    });
    const instanceStart = axisStart + this.axisCount * this.axisSize;
    lazy$1(this, `instances`, () => {
      let instances = [];
      for (let i2 = 0; i2 < this.instanceCount; i2++) {
        p22.currentPosition = instanceStart + i2 * this.instanceSize;
        instances.push(
          new InstanceRecord(p22, this.axisCount, this.instanceSize)
        );
      }
      return instances;
    });
  }
  getSupportedAxes() {
    return this.axes.map((a2) => a2.tag);
  }
  getAxis(name2) {
    return this.axes.find((a2) => a2.tag === name2);
  }
};
var VariationAxisRecord = class {
  constructor(p22) {
    this.tag = p22.tag;
    this.minValue = p22.fixed;
    this.defaultValue = p22.fixed;
    this.maxValue = p22.fixed;
    this.flags = p22.flags(16);
    this.axisNameID = p22.uint16;
  }
};
var InstanceRecord = class {
  constructor(p22, axisCount, size4) {
    let start = p22.currentPosition;
    this.subfamilyNameID = p22.uint16;
    p22.uint16;
    this.coordinates = [...new Array(axisCount)].map(
      (_) => p22.fixed
    );
    if (p22.currentPosition - start < size4) {
      this.postScriptNameID = p22.uint16;
    }
  }
};
var fvar$1 = Object.freeze({ __proto__: null, fvar });
var cvt = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    const n2 = dict.length / 2;
    lazy$1(
      this,
      `items`,
      () => [...new Array(n2)].map((_) => p22.fword)
    );
  }
};
var cvt$1 = Object.freeze({ __proto__: null, cvt });
var fpgm = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    lazy$1(
      this,
      `instructions`,
      () => [...new Array(dict.length)].map((_) => p22.uint8)
    );
  }
};
var fpgm$1 = Object.freeze({ __proto__: null, fpgm });
var gasp = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numRanges = p22.uint16;
    const getter = () => [...new Array(this.numRanges)].map(
      (_) => new GASPRange(p22)
    );
    lazy$1(this, `gaspRanges`, getter);
  }
};
var GASPRange = class {
  constructor(p22) {
    this.rangeMaxPPEM = p22.uint16;
    this.rangeGaspBehavior = p22.uint16;
  }
};
var gasp$1 = Object.freeze({ __proto__: null, gasp });
var glyf = class extends SimpleTable {
  constructor(dict, dataview) {
    super(dict, dataview);
  }
  getGlyphData(offset4, length) {
    this.parser.currentPosition = this.tableStart + offset4;
    return this.parser.readBytes(length);
  }
};
var glyf$1 = Object.freeze({ __proto__: null, glyf });
var loca = class extends SimpleTable {
  constructor(dict, dataview, tables) {
    const { p: p22 } = super(dict, dataview);
    const n2 = tables.maxp.numGlyphs + 1;
    if (tables.head.indexToLocFormat === 0) {
      this.x2 = true;
      lazy$1(
        this,
        `offsets`,
        () => [...new Array(n2)].map((_) => p22.Offset16)
      );
    } else {
      lazy$1(
        this,
        `offsets`,
        () => [...new Array(n2)].map((_) => p22.Offset32)
      );
    }
  }
  getGlyphDataOffsetAndLength(glyphID) {
    let offset4 = this.offsets[glyphID] * this.x2 ? 2 : 1;
    let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
    return { offset: offset4, length: nextOffset - offset4 };
  }
};
var loca$1 = Object.freeze({ __proto__: null, loca });
var prep = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    lazy$1(
      this,
      `instructions`,
      () => [...new Array(dict.length)].map((_) => p22.uint8)
    );
  }
};
var prep$1 = Object.freeze({ __proto__: null, prep });
var CFF = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    lazy$1(this, `data`, () => p22.readBytes());
  }
};
var CFF$1 = Object.freeze({ __proto__: null, CFF });
var CFF2 = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    lazy$1(this, `data`, () => p22.readBytes());
  }
};
var CFF2$1 = Object.freeze({ __proto__: null, CFF2 });
var VORG = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.defaultVertOriginY = p22.int16;
    this.numVertOriginYMetrics = p22.uint16;
    lazy$1(
      this,
      `vertORiginYMetrics`,
      () => [...new Array(this.numVertOriginYMetrics)].map(
        (_) => new VertOriginYMetric(p22)
      )
    );
  }
};
var VertOriginYMetric = class {
  constructor(p22) {
    this.glyphIndex = p22.uint16;
    this.vertOriginY = p22.int16;
  }
};
var VORG$1 = Object.freeze({ __proto__: null, VORG });
var BitmapSize = class {
  constructor(p22) {
    this.indexSubTableArrayOffset = p22.Offset32;
    this.indexTablesSize = p22.uint32;
    this.numberofIndexSubTables = p22.uint32;
    this.colorRef = p22.uint32;
    this.hori = new SbitLineMetrics(p22);
    this.vert = new SbitLineMetrics(p22);
    this.startGlyphIndex = p22.uint16;
    this.endGlyphIndex = p22.uint16;
    this.ppemX = p22.uint8;
    this.ppemY = p22.uint8;
    this.bitDepth = p22.uint8;
    this.flags = p22.int8;
  }
};
var BitmapScale = class {
  constructor(p22) {
    this.hori = new SbitLineMetrics(p22);
    this.vert = new SbitLineMetrics(p22);
    this.ppemX = p22.uint8;
    this.ppemY = p22.uint8;
    this.substitutePpemX = p22.uint8;
    this.substitutePpemY = p22.uint8;
  }
};
var SbitLineMetrics = class {
  constructor(p22) {
    this.ascender = p22.int8;
    this.descender = p22.int8;
    this.widthMax = p22.uint8;
    this.caretSlopeNumerator = p22.int8;
    this.caretSlopeDenominator = p22.int8;
    this.caretOffset = p22.int8;
    this.minOriginSB = p22.int8;
    this.minAdvanceSB = p22.int8;
    this.maxBeforeBL = p22.int8;
    this.minAfterBL = p22.int8;
    this.pad1 = p22.int8;
    this.pad2 = p22.int8;
  }
};
var EBLC = class extends SimpleTable {
  constructor(dict, dataview, name2) {
    const { p: p22 } = super(dict, dataview, name2);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.numSizes = p22.uint32;
    lazy$1(
      this,
      `bitMapSizes`,
      () => [...new Array(this.numSizes)].map(
        (_) => new BitmapSize(p22)
      )
    );
  }
};
var EBLC$1 = Object.freeze({ __proto__: null, EBLC });
var EBDT = class extends SimpleTable {
  constructor(dict, dataview, name2) {
    const { p: p22 } = super(dict, dataview, name2);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
  }
};
var EBDT$1 = Object.freeze({ __proto__: null, EBDT });
var EBSC = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.majorVersion = p22.uint16;
    this.minorVersion = p22.uint16;
    this.numSizes = p22.uint32;
    lazy$1(
      this,
      `bitmapScales`,
      () => [...new Array(this.numSizes)].map(
        (_) => new BitmapScale(p22)
      )
    );
  }
};
var EBSC$1 = Object.freeze({ __proto__: null, EBSC });
var CBLC = class extends EBLC {
  constructor(dict, dataview) {
    super(dict, dataview, `CBLC`);
  }
};
var CBLC$1 = Object.freeze({ __proto__: null, CBLC });
var CBDT = class extends EBDT {
  constructor(dict, dataview) {
    super(dict, dataview, `CBDT`);
  }
};
var CBDT$1 = Object.freeze({ __proto__: null, CBDT });
var sbix = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.flags = p22.flags(16);
    this.numStrikes = p22.uint32;
    lazy$1(
      this,
      `strikeOffsets`,
      () => [...new Array(this.numStrikes)].map((_) => p22.Offset32)
    );
  }
};
var sbix$1 = Object.freeze({ __proto__: null, sbix });
var COLR = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numBaseGlyphRecords = p22.uint16;
    this.baseGlyphRecordsOffset = p22.Offset32;
    this.layerRecordsOffset = p22.Offset32;
    this.numLayerRecords = p22.uint16;
  }
  getBaseGlyphRecord(glyphID) {
    let start = this.tableStart + this.baseGlyphRecordsOffset;
    this.parser.currentPosition = start;
    let first = new BaseGlyphRecord(this.parser);
    let firstID = first.gID;
    let end = this.tableStart + this.layerRecordsOffset - 6;
    this.parser.currentPosition = end;
    let last = new BaseGlyphRecord(this.parser);
    let lastID = last.gID;
    if (firstID === glyphID) return first;
    if (lastID === glyphID) return last;
    while (true) {
      if (start === end) break;
      let mid = start + (end - start) / 12;
      this.parser.currentPosition = mid;
      let middle = new BaseGlyphRecord(this.parser);
      let midID = middle.gID;
      if (midID === glyphID) return middle;
      else if (midID > glyphID) {
        end = mid;
      } else if (midID < glyphID) {
        start = mid;
      }
    }
    return false;
  }
  getLayers(glyphID) {
    let record = this.getBaseGlyphRecord(glyphID);
    this.parser.currentPosition = this.tableStart + this.layerRecordsOffset + 4 * record.firstLayerIndex;
    return [...new Array(record.numLayers)].map(
      (_) => new LayerRecord(p)
    );
  }
};
var BaseGlyphRecord = class {
  constructor(p22) {
    this.gID = p22.uint16;
    this.firstLayerIndex = p22.uint16;
    this.numLayers = p22.uint16;
  }
};
var LayerRecord = class {
  constructor(p22) {
    this.gID = p22.uint16;
    this.paletteIndex = p22.uint16;
  }
};
var COLR$1 = Object.freeze({ __proto__: null, COLR });
var CPAL = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numPaletteEntries = p22.uint16;
    const numPalettes = this.numPalettes = p22.uint16;
    this.numColorRecords = p22.uint16;
    this.offsetFirstColorRecord = p22.Offset32;
    this.colorRecordIndices = [...new Array(this.numPalettes)].map(
      (_) => p22.uint16
    );
    lazy$1(this, `colorRecords`, () => {
      p22.currentPosition = this.tableStart + this.offsetFirstColorRecord;
      return [...new Array(this.numColorRecords)].map(
        (_) => new ColorRecord(p22)
      );
    });
    if (this.version === 1) {
      this.offsetPaletteTypeArray = p22.Offset32;
      this.offsetPaletteLabelArray = p22.Offset32;
      this.offsetPaletteEntryLabelArray = p22.Offset32;
      lazy$1(this, `paletteTypeArray`, () => {
        p22.currentPosition = this.tableStart + this.offsetPaletteTypeArray;
        return new PaletteTypeArray(p22, numPalettes);
      });
      lazy$1(this, `paletteLabelArray`, () => {
        p22.currentPosition = this.tableStart + this.offsetPaletteLabelArray;
        return new PaletteLabelsArray(p22, numPalettes);
      });
      lazy$1(this, `paletteEntryLabelArray`, () => {
        p22.currentPosition = this.tableStart + this.offsetPaletteEntryLabelArray;
        return new PaletteEntryLabelArray(p22, numPalettes);
      });
    }
  }
};
var ColorRecord = class {
  constructor(p22) {
    this.blue = p22.uint8;
    this.green = p22.uint8;
    this.red = p22.uint8;
    this.alpha = p22.uint8;
  }
};
var PaletteTypeArray = class {
  constructor(p22, numPalettes) {
    this.paletteTypes = [...new Array(numPalettes)].map(
      (_) => p22.uint32
    );
  }
};
var PaletteLabelsArray = class {
  constructor(p22, numPalettes) {
    this.paletteLabels = [...new Array(numPalettes)].map(
      (_) => p22.uint16
    );
  }
};
var PaletteEntryLabelArray = class {
  constructor(p22, numPalettes) {
    this.paletteEntryLabels = [...new Array(numPalettes)].map(
      (_) => p22.uint16
    );
  }
};
var CPAL$1 = Object.freeze({ __proto__: null, CPAL });
var DSIG = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint32;
    this.numSignatures = p22.uint16;
    this.flags = p22.uint16;
    this.signatureRecords = [...new Array(this.numSignatures)].map(
      (_) => new SignatureRecord(p22)
    );
  }
  getData(signatureID) {
    const record = this.signatureRecords[signatureID];
    this.parser.currentPosition = this.tableStart + record.offset;
    return new SignatureBlockFormat1(this.parser);
  }
};
var SignatureRecord = class {
  constructor(p22) {
    this.format = p22.uint32;
    this.length = p22.uint32;
    this.offset = p22.Offset32;
  }
};
var SignatureBlockFormat1 = class {
  constructor(p22) {
    p22.uint16;
    p22.uint16;
    this.signatureLength = p22.uint32;
    this.signature = p22.readBytes(this.signatureLength);
  }
};
var DSIG$1 = Object.freeze({ __proto__: null, DSIG });
var hdmx = class extends SimpleTable {
  constructor(dict, dataview, tables) {
    const { p: p22 } = super(dict, dataview);
    const numGlyphs = tables.hmtx.numGlyphs;
    this.version = p22.uint16;
    this.numRecords = p22.int16;
    this.sizeDeviceRecord = p22.int32;
    this.records = [...new Array(numRecords)].map(
      (_) => new DeviceRecord(p22, numGlyphs)
    );
  }
};
var DeviceRecord = class {
  constructor(p22, numGlyphs) {
    this.pixelSize = p22.uint8;
    this.maxWidth = p22.uint8;
    this.widths = p22.readBytes(numGlyphs);
  }
};
var hdmx$1 = Object.freeze({ __proto__: null, hdmx });
var kern = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.nTables = p22.uint16;
    lazy$1(this, `tables`, () => {
      let offset4 = this.tableStart + 4;
      const tables = [];
      for (let i2 = 0; i2 < this.nTables; i2++) {
        p22.currentPosition = offset4;
        let subtable = new KernSubTable(p22);
        tables.push(subtable);
        offset4 += subtable;
      }
      return tables;
    });
  }
};
var KernSubTable = class {
  constructor(p22) {
    this.version = p22.uint16;
    this.length = p22.uint16;
    this.coverage = p22.flags(8);
    this.format = p22.uint8;
    if (this.format === 0) {
      this.nPairs = p22.uint16;
      this.searchRange = p22.uint16;
      this.entrySelector = p22.uint16;
      this.rangeShift = p22.uint16;
      lazy$1(
        this,
        `pairs`,
        () => [...new Array(this.nPairs)].map((_) => new Pair(p22))
      );
    }
    if (this.format === 2) {
      console.warn(
        `Kern subtable format 2 is not supported: this parser currently only parses universal table data.`
      );
    }
  }
  get horizontal() {
    return this.coverage[0];
  }
  get minimum() {
    return this.coverage[1];
  }
  get crossstream() {
    return this.coverage[2];
  }
  get override() {
    return this.coverage[3];
  }
};
var Pair = class {
  constructor(p22) {
    this.left = p22.uint16;
    this.right = p22.uint16;
    this.value = p22.fword;
  }
};
var kern$1 = Object.freeze({ __proto__: null, kern });
var LTSH = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numGlyphs = p22.uint16;
    this.yPels = p22.readBytes(this.numGlyphs);
  }
};
var LTSH$1 = Object.freeze({ __proto__: null, LTSH });
var MERG = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.mergeClassCount = p22.uint16;
    this.mergeDataOffset = p22.Offset16;
    this.classDefCount = p22.uint16;
    this.offsetToClassDefOffsets = p22.Offset16;
    lazy$1(
      this,
      `mergeEntryMatrix`,
      () => [...new Array(this.mergeClassCount)].map(
        (_) => p22.readBytes(this.mergeClassCount)
      )
    );
    console.warn(`Full MERG parsing is currently not supported.`);
    console.warn(
      `If you need this table parsed, please file an issue, or better yet, a PR.`
    );
  }
};
var MERG$1 = Object.freeze({ __proto__: null, MERG });
var meta = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint32;
    this.flags = p22.uint32;
    p22.uint32;
    this.dataMapsCount = p22.uint32;
    this.dataMaps = [...new Array(this.dataMapsCount)].map(
      (_) => new DataMap(this.tableStart, p22)
    );
  }
};
var DataMap = class {
  constructor(tableStart, p22) {
    this.tableStart = tableStart;
    this.parser = p22;
    this.tag = p22.tag;
    this.dataOffset = p22.Offset32;
    this.dataLength = p22.uint32;
  }
  getData() {
    this.parser.currentField = this.tableStart + this.dataOffset;
    return this.parser.readBytes(this.dataLength);
  }
};
var meta$1 = Object.freeze({ __proto__: null, meta });
var PCLT = class extends SimpleTable {
  constructor(dict, dataview) {
    super(dict, dataview);
    console.warn(
      `This font uses a PCLT table, which is currently not supported by this parser.`
    );
    console.warn(
      `If you need this table parsed, please file an issue, or better yet, a PR.`
    );
  }
};
var PCLT$1 = Object.freeze({ __proto__: null, PCLT });
var VDMX = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.uint16;
    this.numRecs = p22.uint16;
    this.numRatios = p22.uint16;
    this.ratRanges = [...new Array(this.numRatios)].map(
      (_) => new RatioRange(p22)
    );
    this.offsets = [...new Array(this.numRatios)].map(
      (_) => p22.Offset16
    );
    this.VDMXGroups = [...new Array(this.numRecs)].map(
      (_) => new VDMXGroup(p22)
    );
  }
};
var RatioRange = class {
  constructor(p22) {
    this.bCharSet = p22.uint8;
    this.xRatio = p22.uint8;
    this.yStartRatio = p22.uint8;
    this.yEndRatio = p22.uint8;
  }
};
var VDMXGroup = class {
  constructor(p22) {
    this.recs = p22.uint16;
    this.startsz = p22.uint8;
    this.endsz = p22.uint8;
    this.records = [...new Array(this.recs)].map(
      (_) => new vTable(p22)
    );
  }
};
var vTable = class {
  constructor(p22) {
    this.yPelHeight = p22.uint16;
    this.yMax = p22.int16;
    this.yMin = p22.int16;
  }
};
var VDMX$1 = Object.freeze({ __proto__: null, VDMX });
var vhea = class extends SimpleTable {
  constructor(dict, dataview) {
    const { p: p22 } = super(dict, dataview);
    this.version = p22.fixed;
    this.ascent = this.vertTypoAscender = p22.int16;
    this.descent = this.vertTypoDescender = p22.int16;
    this.lineGap = this.vertTypoLineGap = p22.int16;
    this.advanceHeightMax = p22.int16;
    this.minTopSideBearing = p22.int16;
    this.minBottomSideBearing = p22.int16;
    this.yMaxExtent = p22.int16;
    this.caretSlopeRise = p22.int16;
    this.caretSlopeRun = p22.int16;
    this.caretOffset = p22.int16;
    this.reserved = p22.int16;
    this.reserved = p22.int16;
    this.reserved = p22.int16;
    this.reserved = p22.int16;
    this.metricDataFormat = p22.int16;
    this.numOfLongVerMetrics = p22.uint16;
    p22.verifyLength();
  }
};
var vhea$1 = Object.freeze({ __proto__: null, vhea });
var vmtx = class extends SimpleTable {
  constructor(dict, dataview, tables) {
    super(dict, dataview);
    const numOfLongVerMetrics = tables.vhea.numOfLongVerMetrics;
    const numGlyphs = tables.maxp.numGlyphs;
    const metricsStart = p.currentPosition;
    lazy(this, `vMetrics`, () => {
      p.currentPosition = metricsStart;
      return [...new Array(numOfLongVerMetrics)].map(
        (_) => new LongVertMetric(p.uint16, p.int16)
      );
    });
    if (numOfLongVerMetrics < numGlyphs) {
      const tsbStart = metricsStart + numOfLongVerMetrics * 4;
      lazy(this, `topSideBearings`, () => {
        p.currentPosition = tsbStart;
        return [...new Array(numGlyphs - numOfLongVerMetrics)].map(
          (_) => p.int16
        );
      });
    }
  }
};
var LongVertMetric = class {
  constructor(h2, b2) {
    this.advanceHeight = h2;
    this.topSideBearing = b2;
  }
};
var vmtx$1 = Object.freeze({ __proto__: null, vmtx });

// packages/global-styles-ui/build-module/font-library/utils/make-families-from-faces.mjs
var import_components27 = __toESM(require_components(), 1);
var { kebabCase: kebabCase2 } = unlock3(import_components27.privateApis);
function makeFamiliesFromFaces(fontFaces) {
  const fontFamiliesObject = fontFaces.reduce(
    (acc, item) => {
      if (!acc[item.fontFamily]) {
        acc[item.fontFamily] = {
          name: item.fontFamily,
          fontFamily: item.fontFamily,
          slug: kebabCase2(item.fontFamily.toLowerCase()),
          fontFace: []
        };
      }
      acc[item.fontFamily].fontFace.push(item);
      return acc;
    },
    {}
  );
  return Object.values(fontFamiliesObject);
}

// packages/global-styles-ui/build-module/font-library/upload-fonts.mjs
var import_jsx_runtime53 = __toESM(require_jsx_runtime(), 1);
function UploadFonts() {
  const { installFonts } = (0, import_element36.useContext)(FontLibraryContext);
  const [isUploading, setIsUploading] = (0, import_element36.useState)(false);
  const [notice, setNotice] = (0, import_element36.useState)(null);
  const handleDropZone = (files) => {
    handleFilesUpload(files);
  };
  const onFilesUpload = (event) => {
    handleFilesUpload(event.target.files);
  };
  const handleFilesUpload = async (files) => {
    if (!files) {
      return;
    }
    setNotice(null);
    setIsUploading(true);
    const uniqueFilenames = /* @__PURE__ */ new Set();
    const selectedFiles = [...files];
    let hasInvalidFiles = false;
    const checkFilesPromises = selectedFiles.map(async (file) => {
      const isFont = await isFontFile(file);
      if (!isFont) {
        hasInvalidFiles = true;
        return null;
      }
      if (uniqueFilenames.has(file.name)) {
        return null;
      }
      const fileExtension = (((file.name ?? "").split(".") ?? []).pop() ?? "").toLowerCase();
      if (ALLOWED_FILE_EXTENSIONS.includes(fileExtension)) {
        uniqueFilenames.add(file.name);
        return file;
      }
      return null;
    });
    const allowedFiles = (await Promise.all(checkFilesPromises)).filter((file) => null !== file);
    if (allowedFiles.length > 0) {
      loadFiles(allowedFiles);
    } else {
      const message = hasInvalidFiles ? (0, import_i18n17.__)("Sorry, you are not allowed to upload this file type.") : (0, import_i18n17.__)("No fonts found to install.");
      setNotice({
        type: "error",
        message
      });
      setIsUploading(false);
    }
  };
  const loadFiles = async (files) => {
    const fontFacesLoaded = await Promise.all(
      files.map(async (fontFile) => {
        const fontFaceData = await getFontFaceMetadata(fontFile);
        await loadFontFaceInBrowser(
          fontFaceData,
          fontFaceData.file,
          "all"
        );
        return fontFaceData;
      })
    );
    handleInstall(fontFacesLoaded);
  };
  async function isFontFile(file) {
    const font2 = new Font("Uploaded Font");
    try {
      const buffer = await readFileAsArrayBuffer(file);
      await font2.fromDataBuffer(buffer, "font");
      return true;
    } catch {
      return false;
    }
  }
  async function readFileAsArrayBuffer(file) {
    return new Promise((resolve, reject) => {
      const reader = new window.FileReader();
      reader.readAsArrayBuffer(file);
      reader.onload = () => resolve(reader.result);
      reader.onerror = reject;
    });
  }
  const getFontFaceMetadata = async (fontFile) => {
    const buffer = await readFileAsArrayBuffer(fontFile);
    const fontObj = new Font("Uploaded Font");
    fontObj.fromDataBuffer(buffer, fontFile.name);
    const onloadEvent = await new Promise(
      (resolve) => fontObj.onload = resolve
    );
    const font2 = onloadEvent.detail.font;
    const { name: name2 } = font2.opentype.tables;
    const fontName = name2.get(16) || name2.get(1);
    const isItalic = name2.get(2).toLowerCase().includes("italic");
    const fontWeight = font2.opentype.tables["OS/2"].usWeightClass || "normal";
    const isVariable = !!font2.opentype.tables.fvar;
    const weightAxis = isVariable && font2.opentype.tables.fvar.axes.find(
      ({ tag }) => tag === "wght"
    );
    const weightRange = weightAxis ? `${weightAxis.minValue} ${weightAxis.maxValue}` : null;
    return {
      file: fontFile,
      fontFamily: fontName,
      fontStyle: isItalic ? "italic" : "normal",
      fontWeight: weightRange || fontWeight
    };
  };
  const handleInstall = async (fontFaces) => {
    const fontFamilies = makeFamiliesFromFaces(fontFaces);
    try {
      await installFonts(fontFamilies);
      setNotice({
        type: "success",
        message: (0, import_i18n17.__)("Fonts were installed successfully.")
      });
    } catch (error) {
      const typedError = error;
      setNotice({
        type: "error",
        message: typedError.message,
        errors: typedError?.installationErrors
      });
    }
    setIsUploading(false);
  };
  return /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components28.DropZone, { onFilesDrop: handleDropZone }),
    /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(import_components28.__experimentalVStack, { className: "font-library__local-fonts", justify: "start", children: [
      notice && /* @__PURE__ */ (0, import_jsx_runtime53.jsxs)(
        import_components28.Notice,
        {
          status: notice.type,
          __unstableHTML: true,
          onRemove: () => setNotice(null),
          children: [
            notice.message,
            notice.errors && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("ul", { children: notice.errors.map((error, index2) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("li", { children: error }, index2)) })
          ]
        }
      ),
      isUploading && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components28.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)("div", { className: "font-library__upload-area", children: /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components28.ProgressBar, {}) }) }),
      !isUploading && /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
        import_components28.FormFileUpload,
        {
          accept: ALLOWED_FILE_EXTENSIONS.map(
            (ext) => `.${ext}`
          ).join(","),
          multiple: true,
          onChange: onFilesUpload,
          render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(
            import_components28.Button,
            {
              __next40pxDefaultSize: true,
              className: "font-library__upload-area",
              onClick: openFileDialog,
              children: (0, import_i18n17.__)("Upload font")
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime53.jsx)(import_components28.__experimentalText, { className: "font-library__upload-area__text", children: (0, import_i18n17.__)(
        "Uploaded fonts appear in your library and can be used in your theme. Supported formats: .ttf, .otf, .woff, and .woff2."
      ) })
    ] })
  ] });
}
var upload_fonts_default = UploadFonts;

// packages/global-styles-ui/build-module/font-library/modal.mjs
var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
var { Tabs } = unlock3(import_components29.privateApis);
var DEFAULT_TAB = {
  id: "installed-fonts",
  title: (0, import_i18n18._x)("Library", "Font library")
};
var UPLOAD_TAB = {
  id: "upload-fonts",
  title: (0, import_i18n18._x)("Upload", "noun")
};

// packages/global-styles-ui/build-module/font-family-item.mjs
var import_i18n19 = __toESM(require_i18n(), 1);
var import_components30 = __toESM(require_components(), 1);
var import_element37 = __toESM(require_element(), 1);
var import_jsx_runtime55 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-families.mjs
var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/font-sizes-count.mjs
var import_i18n21 = __toESM(require_i18n(), 1);
var import_components32 = __toESM(require_components(), 1);
var import_jsx_runtime57 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-typography.mjs
var import_jsx_runtime58 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-typography-element.mjs
var import_i18n23 = __toESM(require_i18n(), 1);
var import_components34 = __toESM(require_components(), 1);
var import_element40 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/typography-panel.mjs
var import_block_editor6 = __toESM(require_block_editor(), 1);
var import_jsx_runtime59 = __toESM(require_jsx_runtime(), 1);
var { useSettingsForBlockElement: useSettingsForBlockElement4, TypographyPanel: StylesTypographyPanel2 } = unlock3(import_block_editor6.privateApis);

// packages/global-styles-ui/build-module/typography-preview.mjs
var import_jsx_runtime60 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-typography-element.mjs
var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
var elements = {
  text: {
    description: (0, import_i18n23.__)("Manage the fonts used on the site."),
    title: (0, import_i18n23.__)("Text")
  },
  link: {
    description: (0, import_i18n23.__)("Manage the fonts and typography used on the links."),
    title: (0, import_i18n23.__)("Links")
  },
  heading: {
    description: (0, import_i18n23.__)("Manage the fonts and typography used on headings."),
    title: (0, import_i18n23.__)("Headings")
  },
  caption: {
    description: (0, import_i18n23.__)("Manage the fonts and typography used on captions."),
    title: (0, import_i18n23.__)("Captions")
  },
  button: {
    description: (0, import_i18n23.__)("Manage the fonts and typography used on buttons."),
    title: (0, import_i18n23.__)("Buttons")
  }
};

// packages/global-styles-ui/build-module/screen-colors.mjs
var import_i18n25 = __toESM(require_i18n(), 1);
var import_components37 = __toESM(require_components(), 1);
var import_block_editor7 = __toESM(require_block_editor(), 1);

// packages/global-styles-ui/build-module/palette.mjs
var import_components36 = __toESM(require_components(), 1);
var import_i18n24 = __toESM(require_i18n(), 1);
var import_element41 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/color-indicator-wrapper.mjs
var import_components35 = __toESM(require_components(), 1);
var import_jsx_runtime62 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/palette.mjs
var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-colors.mjs
var import_jsx_runtime64 = __toESM(require_jsx_runtime(), 1);
var { useSettingsForBlockElement: useSettingsForBlockElement5, ColorPanel: StylesColorPanel2 } = unlock3(
  import_block_editor7.privateApis
);

// packages/global-styles-ui/build-module/screen-color-palette.mjs
var import_i18n28 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/color-palette-panel.mjs
var import_compose4 = __toESM(require_compose(), 1);
var import_components40 = __toESM(require_components(), 1);
var import_i18n26 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/variations/variations-color.mjs
var import_components39 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/preview-colors.mjs
var import_components38 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/preset-colors.mjs
var import_jsx_runtime65 = __toESM(require_jsx_runtime(), 1);
function PresetColors() {
  const { paletteColors } = useStylesPreviewColors();
  return paletteColors.slice(0, 4).map(({ slug, color }, index2) => /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(
    "div",
    {
      style: {
        flexGrow: 1,
        height: "100%",
        background: color
      }
    },
    `${slug}-${index2}`
  ));
}

// packages/global-styles-ui/build-module/preview-colors.mjs
var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
var firstFrameVariants2 = {
  start: {
    scale: 1,
    opacity: 1
  },
  hover: {
    scale: 0,
    opacity: 0
  }
};
var StylesPreviewColors = ({
  label,
  isFocused,
  withHoverView
}) => {
  return /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
    preview_wrapper_default,
    {
      label,
      isFocused,
      withHoverView,
      children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
        import_components38.__unstableMotion.div,
        {
          variants: firstFrameVariants2,
          style: {
            height: "100%",
            overflow: "hidden"
          },
          children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(
            import_components38.__experimentalHStack,
            {
              spacing: 0,
              justify: "center",
              style: {
                height: "100%",
                overflow: "hidden"
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime66.jsx)(PresetColors, {})
            }
          )
        },
        key
      )
    }
  );
};
var preview_colors_default = StylesPreviewColors;

// packages/global-styles-ui/build-module/variations/variations-color.mjs
var import_jsx_runtime67 = __toESM(require_jsx_runtime(), 1);
var propertiesToFilter2 = ["color"];
function ColorVariations({
  title,
  gap = 2
}) {
  const colorVariations = useCurrentMergeThemeStyleVariationsWithUserConfig(propertiesToFilter2);
  if (colorVariations?.length <= 1) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime67.jsxs)(import_components39.__experimentalVStack, { spacing: 3, children: [
    title && /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(Subtitle, { level: 3, children: title }),
    /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(import_components39.__experimentalGrid, { gap, children: colorVariations.map((variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
      Variation,
      {
        variation,
        isPill: true,
        properties: propertiesToFilter2,
        showTooltip: true,
        children: () => /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(preview_colors_default, {})
      },
      index2
    )) })
  ] });
}

// packages/global-styles-ui/build-module/color-palette-panel.mjs
var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/gradients-palette-panel.mjs
var import_compose5 = __toESM(require_compose(), 1);
var import_components41 = __toESM(require_components(), 1);
var import_i18n27 = __toESM(require_i18n(), 1);
var import_jsx_runtime69 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-color-palette.mjs
var import_jsx_runtime70 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-background.mjs
var import_i18n29 = __toESM(require_i18n(), 1);
var import_block_editor9 = __toESM(require_block_editor(), 1);
var import_components42 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/background-panel.mjs
var import_block_editor8 = __toESM(require_block_editor(), 1);
var import_jsx_runtime71 = __toESM(require_jsx_runtime(), 1);
var { BackgroundPanel: StylesBackgroundPanel2 } = unlock3(
  import_block_editor8.privateApis
);

// packages/global-styles-ui/build-module/screen-background.mjs
var import_jsx_runtime72 = __toESM(require_jsx_runtime(), 1);
var { useHasBackgroundPanel: useHasBackgroundPanel4 } = unlock3(import_block_editor9.privateApis);

// packages/global-styles-ui/build-module/shadows-panel.mjs
var import_components44 = __toESM(require_components(), 1);
var import_i18n31 = __toESM(require_i18n(), 1);
var import_element42 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/confirm-reset-shadow-dialog.mjs
var import_components43 = __toESM(require_components(), 1);
var import_i18n30 = __toESM(require_i18n(), 1);
var import_jsx_runtime73 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/shadows-panel.mjs
var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);
var { Menu } = unlock3(import_components44.privateApis);

// packages/global-styles-ui/build-module/shadows-edit-panel.mjs
var import_components45 = __toESM(require_components(), 1);
var import_i18n32 = __toESM(require_i18n(), 1);
var import_element43 = __toESM(require_element(), 1);
var import_jsx_runtime75 = __toESM(require_jsx_runtime(), 1);
var { Menu: Menu2 } = unlock3(import_components45.privateApis);
var customShadowMenuItems = [
  {
    label: (0, import_i18n32.__)("Rename"),
    action: "rename"
  },
  {
    label: (0, import_i18n32.__)("Delete"),
    action: "delete"
  }
];
var presetShadowMenuItems = [
  {
    label: (0, import_i18n32.__)("Reset"),
    action: "reset"
  }
];

// packages/global-styles-ui/build-module/screen-shadows.mjs
var import_jsx_runtime76 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-layout.mjs
var import_i18n33 = __toESM(require_i18n(), 1);
var import_block_editor11 = __toESM(require_block_editor(), 1);

// packages/global-styles-ui/build-module/dimensions-panel.mjs
var import_block_editor10 = __toESM(require_block_editor(), 1);
var import_element44 = __toESM(require_element(), 1);
var import_jsx_runtime77 = __toESM(require_jsx_runtime(), 1);
var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock3(import_block_editor10.privateApis);

// packages/global-styles-ui/build-module/screen-layout.mjs
var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
var { useHasDimensionsPanel: useHasDimensionsPanel4, useSettingsForBlockElement: useSettingsForBlockElement7 } = unlock3(
  import_block_editor11.privateApis
);

// packages/global-styles-ui/build-module/screen-style-variations.mjs
var import_components48 = __toESM(require_components(), 1);
var import_i18n36 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/style-variations-content.mjs
var import_i18n35 = __toESM(require_i18n(), 1);
var import_components47 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/style-variations-container.mjs
var import_core_data9 = __toESM(require_core_data(), 1);
var import_data9 = __toESM(require_data(), 1);
var import_element45 = __toESM(require_element(), 1);
var import_components46 = __toESM(require_components(), 1);
var import_i18n34 = __toESM(require_i18n(), 1);
var import_jsx_runtime79 = __toESM(require_jsx_runtime(), 1);
function StyleVariationsContainer({
  gap = 2
}) {
  const { user } = (0, import_element45.useContext)(GlobalStylesContext);
  const userStyles = user?.styles;
  const variations = (0, import_data9.useSelect)((select) => {
    const result = select(
      import_core_data9.store
    ).__experimentalGetCurrentThemeGlobalStylesVariations();
    return Array.isArray(result) ? result : void 0;
  }, []);
  const fullStyleVariations = variations?.filter(
    (variation) => {
      return !isVariationWithProperties(variation, ["color"]) && !isVariationWithProperties(variation, [
        "typography",
        "spacing"
      ]);
    }
  );
  const themeVariations = (0, import_element45.useMemo)(() => {
    const withEmptyVariation = [
      {
        title: (0, import_i18n34.__)("Default"),
        settings: {},
        styles: {}
      },
      ...fullStyleVariations ?? []
    ];
    return [
      ...withEmptyVariation.map((variation) => {
        const blockStyles = variation?.styles?.blocks ? { ...variation.styles.blocks } : {};
        if (userStyles?.blocks) {
          Object.keys(userStyles.blocks).forEach((blockName) => {
            if (userStyles.blocks?.[blockName]?.css) {
              const variationBlockStyles = blockStyles[blockName] || {};
              const customCSS = {
                css: `${blockStyles[blockName]?.css || ""} ${userStyles.blocks?.[blockName]?.css?.trim() || ""}`
              };
              blockStyles[blockName] = {
                ...variationBlockStyles,
                ...customCSS
              };
            }
          });
        }
        const css = userStyles?.css || variation.styles?.css ? {
          css: `${variation.styles?.css || ""} ${userStyles?.css || ""}`
        } : {};
        const blocks = Object.keys(blockStyles).length > 0 ? { blocks: blockStyles } : {};
        const styles = {
          ...variation.styles,
          ...css,
          ...blocks
        };
        return {
          ...variation,
          settings: variation.settings ?? {},
          styles
        };
      })
    ];
  }, [fullStyleVariations, userStyles?.blocks, userStyles?.css]);
  if (!fullStyleVariations || fullStyleVariations.length < 1) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
    import_components46.__experimentalGrid,
    {
      columns: 2,
      className: "global-styles-ui-style-variations-container",
      gap,
      children: themeVariations.map(
        (variation, index2) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
          preview_styles_default,
          {
            label: variation?.title,
            withHoverView: true,
            isFocused,
            variation
          }
        ) }, index2)
      )
    }
  );
}
var style_variations_container_default = StyleVariationsContainer;

// packages/global-styles-ui/build-module/style-variations-content.mjs
var import_jsx_runtime80 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-style-variations.mjs
var import_jsx_runtime81 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-css.mjs
var import_i18n37 = __toESM(require_i18n(), 1);
var import_components49 = __toESM(require_components(), 1);
var import_block_editor12 = __toESM(require_block_editor(), 1);
var import_jsx_runtime82 = __toESM(require_jsx_runtime(), 1);
var { AdvancedPanel: StylesAdvancedPanel2 } = unlock3(import_block_editor12.privateApis);

// packages/global-styles-ui/build-module/screen-revisions/index.mjs
var import_i18n40 = __toESM(require_i18n(), 1);
var import_components52 = __toESM(require_components(), 1);
var import_element47 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/screen-revisions/use-global-styles-revisions.mjs
var import_data10 = __toESM(require_data(), 1);
var import_core_data10 = __toESM(require_core_data(), 1);
var import_element46 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs
var import_i18n38 = __toESM(require_i18n(), 1);
var import_components50 = __toESM(require_components(), 1);
var import_date = __toESM(require_date(), 1);
var import_core_data11 = __toESM(require_core_data(), 1);
var import_data11 = __toESM(require_data(), 1);
var import_keycodes2 = __toESM(require_keycodes(), 1);
var import_jsx_runtime83 = __toESM(require_jsx_runtime(), 1);
var { Badge: WCBadge } = unlock3(import_components50.privateApis);
var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;

// packages/global-styles-ui/build-module/pagination/index.mjs
var import_components51 = __toESM(require_components(), 1);
var import_i18n39 = __toESM(require_i18n(), 1);
var import_jsx_runtime84 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-revisions/index.mjs
var import_jsx_runtime85 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
var import_i18n42 = __toESM(require_i18n(), 1);
var import_components54 = __toESM(require_components(), 1);
var import_element48 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/font-sizes/confirm-reset-font-sizes-dialog.mjs
var import_components53 = __toESM(require_components(), 1);
var import_i18n41 = __toESM(require_i18n(), 1);
var import_jsx_runtime86 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
var import_jsx_runtime87 = __toESM(require_jsx_runtime(), 1);
var { Menu: Menu3 } = unlock3(import_components54.privateApis);

// packages/global-styles-ui/build-module/font-sizes/font-size.mjs
var import_i18n46 = __toESM(require_i18n(), 1);
var import_components58 = __toESM(require_components(), 1);
var import_element50 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/font-sizes/font-size-preview.mjs
var import_block_editor13 = __toESM(require_block_editor(), 1);
var import_i18n43 = __toESM(require_i18n(), 1);
var import_jsx_runtime88 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/confirm-delete-font-size-dialog.mjs
var import_components55 = __toESM(require_components(), 1);
var import_i18n44 = __toESM(require_i18n(), 1);
var import_jsx_runtime89 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs
var import_components56 = __toESM(require_components(), 1);
var import_i18n45 = __toESM(require_i18n(), 1);
var import_element49 = __toESM(require_element(), 1);
var import_jsx_runtime90 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/size-control/index.mjs
var import_components57 = __toESM(require_components(), 1);
var import_jsx_runtime91 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/font-sizes/font-size.mjs
var import_jsx_runtime92 = __toESM(require_jsx_runtime(), 1);
var { Menu: Menu4 } = unlock3(import_components58.privateApis);

// packages/global-styles-ui/build-module/global-styles-ui.mjs
var import_jsx_runtime93 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/with-global-styles-provider.mjs
var import_jsx_runtime94 = __toESM(require_jsx_runtime(), 1);
function withGlobalStylesProvider(Component) {
  return function WrappedComponent({
    value,
    baseValue,
    onChange,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(
      GlobalStylesProvider,
      {
        value,
        baseValue,
        onChange,
        children: /* @__PURE__ */ (0, import_jsx_runtime94.jsx)(Component, { ...props })
      }
    );
  };
}

// packages/global-styles-ui/build-module/style-variations.mjs
var StyleVariations = withGlobalStylesProvider(style_variations_container_default);

// packages/global-styles-ui/build-module/color-variations.mjs
var ColorVariations2 = withGlobalStylesProvider(ColorVariations);

// packages/global-styles-ui/build-module/typography-variations.mjs
var TypographyVariations2 = withGlobalStylesProvider(TypographyVariations);

// packages/global-styles-ui/build-module/font-library/font-library.mjs
var import_jsx_runtime95 = __toESM(require_jsx_runtime(), 1);
function FontLibrary({
  value,
  baseValue,
  onChange,
  activeTab = "installed-fonts"
}) {
  let content;
  switch (activeTab) {
    case "upload-fonts":
      content = /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(upload_fonts_default, {});
      break;
    case "installed-fonts":
      content = /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(installed_fonts_default, {});
      break;
    default:
      content = /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(font_collection_default, { slug: activeTab });
  }
  return /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(
    GlobalStylesProvider,
    {
      value,
      baseValue,
      onChange,
      children: /* @__PURE__ */ (0, import_jsx_runtime95.jsx)(context_default, { children: content })
    }
  );
}

// routes/font-list/lock-unlock.ts
var import_private_apis5 = __toESM(require_private_apis());
var { unlock: unlock4 } = (0, import_private_apis5.__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/font-list-route"
);

// routes/font-list/style.scss
if (typeof document !== "undefined" && true && !document.head.querySelector("style[data-wp-hash='911f938962']")) {
  const style = document.createElement("style");
  style.setAttribute("data-wp-hash", "911f938962");
  style.appendChild(document.createTextNode('@media (min-width:782px){.font-library-modal.font-library-modal{width:65vw}}.font-library-modal .components-modal__header{border-bottom:none}.font-library-modal .components-modal__content{margin-bottom:90px;padding:0}.font-library-modal .font-library__subtitle{font-size:11px;font-weight:var(--wpds-typography-font-weight-emphasis,600);text-transform:uppercase}.font-library-modal__tab-panel{height:calc(100% - 50px)}.font-library__tabpanel-layout{display:flex;flex-direction:column;height:100%}.font-library__tabpanel-layout>div{flex-grow:1}.font-library__tabpanel-layout .font-library__loading{align-items:center;box-sizing:border-box;display:flex;height:100%;justify-content:center;left:0;padding-top:124px;position:absolute;top:0;width:100%}.font-library__footer,.font-library__tabpanel-layout .components-navigator-screen{padding:24px;width:100%}.font-library__footer{background-color:#fff;border-top:1px solid #ddd;bottom:0;box-sizing:border-box;flex-grow:0!important;flex-shrink:0;height:90px;position:absolute}.font-library__page-selection{font-size:11px;font-weight:var(--wpds-typography-font-weight-emphasis,600);text-transform:uppercase}@media (min-width:600px){.font-library__page-selection .font-library__page-selection-trigger{font-size:11px!important;font-weight:var(--wpds-typography-font-weight-emphasis,600)}}.font-library__fonts-title{font-size:11px;font-weight:var(--wpds-typography-font-weight-emphasis,600);margin-bottom:0;margin-top:0;text-transform:uppercase}.font-library__fonts-list{list-style:none;margin-bottom:0;margin-top:0;padding:0}.font-library__fonts-list-item{margin-bottom:0}.font-library__font-card{border:1px solid #ddd;box-sizing:border-box;height:auto!important;margin-top:-1px;padding:16px;width:100%}.font-library__font-card:hover{background-color:#f0f0f0}.font-library__font-card:focus{position:relative}.font-library__font-card .font-library__font-card__name{font-weight:700}.font-library__font-card .font-library__font-card__count{color:#757575}.font-library__font-card .font-library__font-variant_demo-image{display:block;height:24px;width:auto}.font-library__font-card .font-library__font-variant_demo-text{flex-shrink:0;white-space:nowrap}@media not (prefers-reduced-motion){.font-library__font-card .font-library__font-variant_demo-text{transition:opacity .3s ease-in-out}}.font-library-modal__tablist-container{background:#fff;border-bottom:1px solid #ddd;position:sticky;top:0;z-index:1}.font-library__upload-area{align-items:center;display:flex;height:256px!important;justify-content:center;width:100%}button.font-library__upload-area{background-color:#f0f0f0}.font-library__local-fonts{margin:24px auto;width:80%}.font-library__local-fonts .font-library__upload-area__text{color:#757575}.font-library__google-fonts-confirm{align-items:center;display:flex;justify-content:center;margin-top:64px}.font-library__google-fonts-confirm p{line-height:1.4}.font-library__google-fonts-confirm h2{font-size:1.2rem;font-weight:400}.font-library__google-fonts-confirm .components-card{padding:16px;width:400px}.font-library__google-fonts-confirm .components-button{justify-content:center;width:100%}.font-library__select-all{padding:16px 16px 16px 17px}.font-library__select-all .components-checkbox-control__label{padding-left:16px}.global-styles-ui-pagination .components-button.is-tertiary{height:32px;justify-content:center;width:32px}.global-styles-ui-screen-revisions__revisions-list{flex-grow:1;list-style:none;margin:0 16px 16px}.global-styles-ui-screen-revisions__revisions-list li{margin-bottom:0}.global-styles-ui-screen-revisions__revision-item{cursor:var(--wpds-cursor-control,pointer);display:flex;flex-direction:column;position:relative}.global-styles-ui-screen-revisions__revision-item[role=option]:active,.global-styles-ui-screen-revisions__revision-item[role=option]:focus{box-shadow:0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);outline:2px solid transparent}.global-styles-ui-screen-revisions__revision-item:hover{background:rgba(var(--wp-admin-theme-color--rgb),.04)}.global-styles-ui-screen-revisions__revision-item:hover .global-styles-ui-screen-revisions__date{color:var(--wp-admin-theme-color)}.global-styles-ui-screen-revisions__revision-item:after,.global-styles-ui-screen-revisions__revision-item:before{content:"\\a";display:block;position:absolute}.global-styles-ui-screen-revisions__revision-item:before{background:#ddd;border:4px solid transparent;border-radius:50%;height:8px;left:17px;top:18px;transform:translate(-50%,-50%);width:8px;z-index:1}.global-styles-ui-screen-revisions__revision-item[aria-selected=true]{background:rgba(var(--wp-admin-theme-color--rgb),.04);border-radius:2px;color:var(--wp-admin-theme-color);outline:3px solid transparent;outline-offset:-2px}.global-styles-ui-screen-revisions__revision-item[aria-selected=true] .global-styles-ui-screen-revisions__date{color:var(--wp-admin-theme-color)}.global-styles-ui-screen-revisions__revision-item[aria-selected=true]:before{background:var(--wp-admin-theme-color)}.global-styles-ui-screen-revisions__revision-item[aria-selected=true] .global-styles-ui-screen-revisions__changes>li,.global-styles-ui-screen-revisions__revision-item[aria-selected=true] .global-styles-ui-screen-revisions__meta{color:#1e1e1e}.global-styles-ui-screen-revisions__revision-item:after{border:.5px solid #ddd;height:100%;left:16px;top:0;width:0}.global-styles-ui-screen-revisions__revision-item:first-child:after{top:18px}.global-styles-ui-screen-revisions__revision-item:last-child:after{height:18px}.global-styles-ui-screen-revisions__revision-item-wrapper{display:block;padding:12px 12px 4px 40px}.global-styles-ui-screen-revisions__active-badge,.global-styles-ui-screen-revisions__apply-button.is-primary{align-self:flex-start;margin:0 12px 12px 40px}.global-styles-ui-screen-revisions__changes,.global-styles-ui-screen-revisions__meta{color:#757575;font-size:12px}.global-styles-ui-screen-revisions__description{align-items:flex-start;display:flex;flex-direction:column;gap:8px}.global-styles-ui-screen-revisions__description .global-styles-ui-screen-revisions__date{font-size:12px;font-weight:var(--wpds-typography-font-weight-emphasis,600);text-transform:uppercase}.global-styles-ui-screen-revisions__meta{align-items:flex-start;display:flex;justify-content:start;margin-bottom:4px;text-align:left;width:100%}.global-styles-ui-screen-revisions__meta img{border-radius:100%;height:16px;margin-right:8px;width:16px}.global-styles-ui-screen-revisions__loading{margin:24px auto!important}.global-styles-ui-screen-revisions__changes{line-height:1.4;list-style:disc;margin-left:12px;text-align:left}.global-styles-ui-screen-revisions__changes li{margin-bottom:4px}.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination{gap:2px;justify-content:space-between}.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination .edit-site-pagination__total{height:1px;left:-1000px;margin:-1px;overflow:hidden;position:absolute}.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination .components-text{font-size:12px;will-change:opacity}.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination .components-button.is-tertiary{color:#1e1e1e}.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination .components-button.is-tertiary:disabled,.global-styles-ui-screen-revisions__pagination.global-styles-ui-screen-revisions__pagination .components-button.is-tertiary[aria-disabled=true]{color:#949494}.global-styles-ui-screen-revisions__footer{background:#fff;border-top:1px solid #ddd;bottom:0;box-sizing:border-box;height:56px;min-width:100%;padding:12px;position:sticky;z-index:1}.global-styles-ui-variations_item{box-sizing:border-box;cursor:var(--wpds-cursor-control,pointer)}.global-styles-ui-variations_item .global-styles-ui-variations_item-preview{border-radius:2px;outline:1px solid rgba(0,0,0,.1);outline-offset:-1px;overflow:hidden;position:relative}@media not (prefers-reduced-motion){.global-styles-ui-variations_item .global-styles-ui-variations_item-preview{transition:outline .1s linear}}.global-styles-ui-variations_item .global-styles-ui-variations_item-preview.is-pill{height:32px}.global-styles-ui-variations_item .global-styles-ui-variations_item-preview.is-pill .block-editor-iframe__scale-container{overflow:hidden}.global-styles-ui-variations_item:not(.is-active):hover .global-styles-ui-variations_item-preview{outline-color:rgba(0,0,0,.3)}.global-styles-ui-variations_item.is-active .global-styles-ui-variations_item-preview,.global-styles-ui-variations_item:focus-visible .global-styles-ui-variations_item-preview{outline-color:#1e1e1e;outline-offset:1px;outline-width:var(--wp-admin-border-width-focus)}.global-styles-ui-variations_item:focus-visible .global-styles-ui-variations_item-preview{outline-color:var(--wp-admin-theme-color)}.global-styles-ui-preview__wrapper{display:block;max-width:100%;width:100%}.global-styles-ui-preview__wrapper.is-hoverable{cursor:var(--wpds-cursor-control,pointer)}.global-styles-ui-typography-preview{align-items:center;background:#f0f0f0;border-radius:2px;display:flex;justify-content:center;margin-bottom:20px;min-height:100px;overflow:hidden}.global-styles-ui-font-size__item{line-break:anywhere;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.global-styles-ui-font-size__item-value{color:#757575}.global-styles-ui-screen-typography__indicator{align-items:center;border-radius:2px;display:flex!important;font-size:14px;height:24px;justify-content:center;width:24px}.global-styles-ui-block-types-search{margin-bottom:10px;padding:0 16px}.global-styles-ui-screen-typography__font-variants-count{color:#757575}.global-styles-ui-font-families__manage-fonts{justify-content:center}.global-styles-ui-screen .color-block-support-panel{border-top:none;padding-left:0;padding-right:0;padding-top:0;row-gap:12px}.global-styles-ui-header{line-height:1.9!important;margin-bottom:0!important}.global-styles-ui-subtitle{font-size:11px!important;font-weight:var(--wpds-typography-font-weight-emphasis,600)!important;margin-bottom:0!important;text-transform:uppercase}.global-styles-ui-section-title{color:#2f2f2f;font-weight:var(--wpds-typography-font-weight-emphasis,600);line-height:1.2;margin:0;padding:16px 16px 0}.global-styles-ui-icon-with-current-color{fill:currentColor}.global-styles-ui__color-indicator-wrapper{flex-shrink:0;height:24px}.global-styles-ui__shadows-panel__options-container,.global-styles-ui__typography-panel__options-container{height:24px}.global-styles-ui__block-preview-panel{border:1px solid #ddd;border-radius:2px;overflow:hidden;position:relative;width:100%}.global-styles-ui__shadow-preview-panel{background-image:repeating-linear-gradient(45deg,#e0e0e0 25%,transparent 0,transparent 75%,#e0e0e0 0,#e0e0e0),repeating-linear-gradient(45deg,#e0e0e0 25%,transparent 0,transparent 75%,#e0e0e0 0,#e0e0e0);background-position:0 0,8px 8px;background-size:16px 16px;border:1px solid #ddd;border-radius:2px;height:144px;overflow:auto}.global-styles-ui__shadow-preview-panel .global-styles-ui__shadow-preview-block{background-color:#fff;border:1px solid #ddd;border-radius:2px;height:60px;width:60%}.global-styles-ui__shadow-editor__dropdown-content{width:280px}.global-styles-ui__shadow-editor-panel{margin-bottom:4px}.global-styles-ui__shadow-editor__dropdown{position:relative;width:100%}.global-styles-ui__shadow-editor__dropdown-toggle{border-radius:inherit;height:auto;padding-bottom:8px;padding-top:8px;text-align:left;width:100%}.global-styles-ui__shadow-editor__dropdown-toggle.is-open{background:#f0f0f0;color:var(--wp-admin-theme-color)}.global-styles-ui__shadow-editor__remove-button{opacity:0;position:absolute;right:8px;top:8px}.global-styles-ui__shadow-editor__remove-button.global-styles-ui__shadow-editor__remove-button{border:none}.global-styles-ui__shadow-editor__dropdown-toggle:hover+.global-styles-ui__shadow-editor__remove-button,.global-styles-ui__shadow-editor__remove-button:focus,.global-styles-ui__shadow-editor__remove-button:hover{opacity:1}@media (hover:none){.global-styles-ui__shadow-editor__remove-button{opacity:1}}.global-styles-ui-screen-css{display:flex;flex:1 1 auto;flex-direction:column;margin:16px}.global-styles-ui-screen-css .block-editor-global-styles-advanced-panel{flex:1 1 auto}.global-styles-ui-screen-css .block-editor-global-styles-advanced-panel__custom-css-input,.global-styles-ui-screen-css .block-editor-global-styles-advanced-panel__custom-css-input .components-base-control__field{display:flex;flex:1 1 auto;flex-direction:column}.global-styles-ui-screen-css .block-editor-global-styles-advanced-panel__custom-css-input textarea{flex:1 1 auto}.global-styles-ui-screen-css-help-link{display:inline-block;margin-top:8px}.global-styles-ui-screen-variations{border-top:1px solid #ddd;margin-top:16px}.global-styles-ui-screen-variations>*{margin:24px 16px}.global-styles-ui-sidebar__navigator-provider{height:100%}.global-styles-ui-sidebar__navigator-screen{display:flex;flex-direction:column;height:100%}.global-styles-ui-color-palette__tablist-container{border-bottom:1px solid #ddd}.global-styles-ui-color-palette__tablist{margin-bottom:-1px}.global-styles-ui-sidebar__navigator-screen .single-column{grid-column:span 1}.global-styles-ui-screen-root.global-styles-ui-screen-root,.global-styles-ui-screen-style-variations.global-styles-ui-screen-style-variations{background:unset;color:inherit}.global-styles-ui-sidebar__panel .block-editor-block-icon svg{fill:currentColor}.global-styles-ui-screen-root__active-style-tile.global-styles-ui-screen-root__active-style-tile,.global-styles-ui-screen-root__active-style-tile.global-styles-ui-screen-root__active-style-tile .global-styles-ui-screen-root__active-style-tile-preview{border-radius:2px}.global-styles-ui-screen-root__active-style-tile-preview{clip-path:border-box}.global-styles-ui-color-palette-panel,.global-styles-ui-gradient-palette-panel{padding:16px}.font-library-page__tablist{border-bottom:1px solid #f0f0f0;padding:0 24px}.font-library-page__tab-panel{flex-grow:1;max-height:calc(100% - 110px);overflow:auto}.font-library-page:has(.font-library__footer) .font-library-page__tab-panel{max-height:calc(100% - 198px)}'));
  document.head.appendChild(style);
}

// routes/font-list/stage.tsx
var { Tabs: Tabs2 } = unlock4(import_components60.privateApis);
var { useGlobalStyles } = unlock4(import_editor.privateApis);
function FontLibraryPage() {
  const { records: collections = [] } = (0, import_core_data12.useEntityRecords)("root", "fontCollection", {
    _fields: "slug,name,description"
  });
  const [activeTab, setActiveTab] = (0, import_element52.useState)("installed-fonts");
  const { base, user, setUser, isReady } = useGlobalStyles();
  const canUserCreate = (0, import_data13.useSelect)((select) => {
    return select(import_core_data12.store).canUser("create", {
      kind: "postType",
      name: "wp_font_family"
    });
  }, []);
  if (!isReady) {
    return null;
  }
  const tabs = [
    {
      id: "installed-fonts",
      title: (0, import_i18n47._x)("Library", "Font library")
    }
  ];
  if (canUserCreate) {
    tabs.push({
      id: "upload-fonts",
      title: (0, import_i18n47._x)("Upload", "noun")
    });
    tabs.push(
      ...(collections || []).map(({ slug, name: name2 }) => ({
        id: slug,
        title: collections && collections.length === 1 && slug === "google-fonts" ? (0, import_i18n47.__)("Install Fonts") : name2
      }))
    );
  }
  return /* @__PURE__ */ React.createElement(page_default, { title: (0, import_i18n47.__)("Fonts"), className: "font-library-page" }, /* @__PURE__ */ React.createElement(
    Tabs2,
    {
      selectedTabId: activeTab,
      onSelect: (tabId) => setActiveTab(tabId)
    },
    /* @__PURE__ */ React.createElement("div", { className: "font-library-page__tablist" }, /* @__PURE__ */ React.createElement(Tabs2.TabList, null, tabs.map(({ id, title }) => /* @__PURE__ */ React.createElement(Tabs2.Tab, { key: id, tabId: id }, title)))),
    tabs.map(({ id }) => /* @__PURE__ */ React.createElement(
      Tabs2.TabPanel,
      {
        key: id,
        tabId: id,
        focusable: false,
        className: "font-library-page__tab-panel"
      },
      /* @__PURE__ */ React.createElement(
        FontLibrary,
        {
          value: user,
          baseValue: base,
          onChange: setUser,
          activeTab: id
        }
      )
    ))
  ));
}
function Stage() {
  return /* @__PURE__ */ React.createElement(FontLibraryPage, null);
}
var stage = Stage;
export {
  stage
};
/*! Bundled license information:

use-sync-external-store/cjs/use-sync-external-store-shim.development.js:
  (**
   * @license React
   * use-sync-external-store-shim.development.js
   *
   * Copyright (c) Meta Platforms, Inc. and affiliates.
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE file in the root directory of this source tree.
   *)

use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.development.js:
  (**
   * @license React
   * use-sync-external-store-shim/with-selector.development.js
   *
   * Copyright (c) Meta Platforms, Inc. and affiliates.
   *
   * This source code is licensed under the MIT license found in the
   * LICENSE file in the root directory of this source tree.
   *)

is-plain-object/dist/is-plain-object.mjs:
  (*!
   * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
   *
   * Copyright (c) 2014-2017, Jon Schlinkert.
   * Released under the MIT License.
   *)
*/
