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 __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/components
var require_components = __commonJS({
  "package-external:@wordpress/components"(exports, module) {
    module.exports = window.wp.components;
  }
});

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

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

// 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/compose
var require_compose = __commonJS({
  "package-external:@wordpress/compose"(exports, module) {
    module.exports = window.wp.compose;
  }
});

// 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/primitives
var require_primitives = __commonJS({
  "package-external:@wordpress/primitives"(exports, module) {
    module.exports = window.wp.primitives;
  }
});

// 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/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;

// packages/admin-ui/build-module/navigable-region/index.mjs
var import_element = __toESM(require_element(), 1);
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
var NavigableRegion = (0, import_element.forwardRef)(
  ({ children, className, ariaLabel, as: Tag = "div", ...props }, ref) => {
    return /* @__PURE__ */ (0, import_jsx_runtime.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/header.mjs
var import_components2 = __toESM(require_components(), 1);

// 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_runtime2 = __toESM(require_jsx_runtime(), 1);
function Header({
  breadcrumbs,
  badges,
  title,
  subTitle,
  actions,
  showSidebarToggle = true
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalVStack, { className: "admin-ui-page__header", as: "header", children: [
    /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { justify: "space-between", spacing: 2, children: [
      /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_components2.__experimentalHStack, { spacing: 2, justify: "left", children: [
        showSidebarToggle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
          SidebarToggleSlot,
          {
            bubblesVirtually: true,
            className: "admin-ui-page__sidebar-toggle-slot"
          }
        ),
        title && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_components2.__experimentalHeading, { as: "h2", level: 3, weight: 500, truncate: true, children: title }),
        breadcrumbs,
        badges
      ] }),
      /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
        import_components2.__experimentalHStack,
        {
          style: { width: "auto", flexShrink: 0 },
          spacing: 2,
          className: "admin-ui-page__header-actions",
          children: actions
        }
      )
    ] }),
    subTitle && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: "admin-ui-page__header-subtitle", children: subTitle })
  ] });
}

// packages/admin-ui/build-module/page/index.mjs
var import_jsx_runtime3 = __toESM(require_jsx_runtime(), 1);
function Page({
  breadcrumbs,
  badges,
  title,
  subTitle,
  children,
  className,
  actions,
  hasPadding = false,
  showSidebarToggle = true
}) {
  const classes = clsx_default("admin-ui-page", className);
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(navigable_region_default, { className: classes, ariaLabel: title, children: [
    (title || breadcrumbs || badges) && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
      Header,
      {
        breadcrumbs,
        badges,
        title,
        subTitle,
        actions,
        showSidebarToggle
      }
    ),
    hasPadding ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { className: "admin-ui-page__content has-padding", children }) : children
  ] });
}
Page.SidebarToggleFill = SidebarToggleFill;
var page_default = Page;

// routes/font-list/stage.tsx
var import_i18n46 = __toESM(require_i18n());
var import_components63 = __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_element34 = __toESM(require_element());

// packages/global-styles-ui/build-module/global-styles-ui.mjs
var import_components62 = __toESM(require_components(), 1);
var import_blocks5 = __toESM(require_blocks(), 1);
var import_data12 = __toESM(require_data(), 1);
var import_block_editor13 = __toESM(require_block_editor(), 1);
var import_element33 = __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",
  "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.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"
];
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 }) => size,
    classes: []
  },
  {
    path: ["border", "radiusSizes"],
    valueKey: "size",
    cssVarInfix: "border-radius",
    classes: []
  },
  {
    path: ["dimensions", "dimensionSizes"],
    valueKey: "size",
    cssVarInfix: "dimension",
    classes: []
  }
];
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/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;
  }
  const rawResult = getValueFromObjectPath(globalStyles, finalPath);
  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(
    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)(base, 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-ui/build-module/provider.mjs
var import_element3 = __toESM(require_element(), 1);

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

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

// packages/global-styles-ui/build-module/screen-root.mjs
var import_components9 = __toESM(require_components(), 1);
var import_i18n4 = __toESM(require_i18n(), 1);

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

// packages/icons/build-module/library/chevron-left.mjs
var import_primitives = __toESM(require_primitives(), 1);
var import_jsx_runtime5 = __toESM(require_jsx_runtime(), 1);
var chevron_left_default = /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_primitives.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime5.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_runtime6 = __toESM(require_jsx_runtime(), 1);
var chevron_right_default = /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_primitives2.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime6.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_runtime7 = __toESM(require_jsx_runtime(), 1);
var more_vertical_default = /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_primitives3.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime7.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_runtime8 = __toESM(require_jsx_runtime(), 1);
var next_default = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_primitives4.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime9 = __toESM(require_jsx_runtime(), 1);
var previous_default = /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_primitives5.SVG, { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", children: /* @__PURE__ */ (0, import_jsx_runtime9.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/global-styles-ui/build-module/screen-root.mjs
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_runtime10 = __toESM(require_jsx_runtime(), 1);
function IconWithCurrentColor({
  className,
  ...props
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime10.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_components3 = __toESM(require_components(), 1);
var import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
function GenericNavigationButton({
  icon,
  children,
  ...props
}) {
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_components3.__experimentalItem, { ...props, children: [
    icon && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_components3.__experimentalHStack, { justify: "flex-start", children: [
      /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(IconWithCurrentColor, { icon, size: 24 }),
      /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_components3.FlexItem, { children })
    ] }),
    !icon && children
  ] });
}
function NavigationButtonAsItem(props) {
  return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_components3.Navigator.Button, { as: GenericNavigationButton, ...props });
}

// packages/global-styles-ui/build-module/root-menu.mjs
var import_components4 = __toESM(require_components(), 1);
var import_i18n2 = __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_element5 = __toESM(require_element(), 1);
var import_data = __toESM(require_data(), 1);
var import_core_data = __toESM(require_core_data(), 1);
var import_i18n = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/utils.mjs
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) {
  const { user, base, merged, onChange } = (0, import_element5.useContext)(GlobalStylesContext);
  let sourceValue = merged;
  if (readFrom === "base") {
    sourceValue = base;
  } else if (readFrom === "user") {
    sourceValue = user;
  }
  const styleValue = (0, import_element5.useMemo)(
    () => getStyle(sourceValue, path, blockName, shouldDecodeEncode),
    [sourceValue, path, blockName, shouldDecodeEncode]
  );
  const setStyleValue = (0, import_element5.useCallback)(
    (newValue) => {
      const newGlobalStyles = setStyle(
        user,
        path,
        newValue,
        blockName
      );
      onChange(newGlobalStyles);
    },
    [user, onChange, path, blockName]
  );
  return [styleValue, setStyleValue];
}
function useSetting(path, blockName, readFrom = "merged") {
  const { user, base, merged, onChange } = (0, import_element5.useContext)(GlobalStylesContext);
  let sourceValue = merged;
  if (readFrom === "base") {
    sourceValue = base;
  } else if (readFrom === "user") {
    sourceValue = user;
  }
  const settingValue = (0, import_element5.useMemo)(
    () => getSetting(sourceValue, path, blockName),
    [sourceValue, path, blockName]
  );
  const setSettingValue = (0, import_element5.useCallback)(
    (newValue) => {
      const newGlobalStyles = setSetting(
        user,
        path,
        newValue,
        blockName
      );
      onChange(newGlobalStyles);
    },
    [user, onChange, path, blockName]
  );
  return [settingValue, setSettingValue];
}
var EMPTY_ARRAY = [];
function hasThemeVariation({
  title,
  settings,
  styles
}) {
  return title === (0, import_i18n.__)("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_ARRAY
    };
  }, []);
  const { user: userVariation } = (0, import_element5.useContext)(GlobalStylesContext);
  return (0, import_element5.useMemo)(() => {
    const clonedUserVariation = structuredClone(userVariation);
    const userVariationWithoutProperties = removePropertiesFromObject(
      clonedUserVariation,
      properties
    );
    userVariationWithoutProperties.title = (0, import_i18n.__)("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/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/global-styles-ui"
);

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

// packages/global-styles-ui/build-module/preview-styles.mjs
var import_components8 = __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_element6 = __toESM(require_element(), 1);
var import_components5 = __toESM(require_components(), 1);
var import_i18n3 = __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_runtime13 = __toESM(require_jsx_runtime(), 1);
function PreviewTypography({
  fontSize,
  variation
}) {
  const { base } = (0, import_element6.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_runtime13.jsxs)(
    import_components5.__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_runtime13.jsx)("span", { style: headingPreviewStyle, children: (0, import_i18n3._x)("A", "Uppercase letter A") }),
        /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { style: bodyPreviewStyle, children: (0, import_i18n3._x)("a", "Lowercase letter A") })
      ]
    }
  );
}

// packages/global-styles-ui/build-module/highlighted-colors.mjs
var import_components6 = __toESM(require_components(), 1);
var import_jsx_runtime14 = __toESM(require_jsx_runtime(), 1);
function HighlightedColors({
  normalizedColorSwatchSize,
  ratio
}) {
  const { highlightedColors } = useStylesPreviewColors();
  const scaledSwatchSize = normalizedColorSwatchSize * ratio;
  return highlightedColors.map(({ slug, color }, index) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
    import_components6.__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: index === 1 ? 0.2 : 0.1
      }
    },
    `${slug}-${index}`
  ));
}

// packages/global-styles-ui/build-module/preview-wrapper.mjs
var import_components7 = __toESM(require_components(), 1);
var import_compose = __toESM(require_compose(), 1);
var import_element7 = __toESM(require_element(), 1);
var import_jsx_runtime15 = __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_element7.useState)(false);
  const [containerResizeListener, { width }] = (0, import_compose.useResizeObserver)();
  const [throttledWidth, setThrottledWidthState] = (0, import_element7.useState)(width);
  const [ratioState, setRatioState] = (0, import_element7.useState)();
  const setThrottledWidth = (0, import_compose.useThrottle)(
    setThrottledWidthState,
    250,
    THROTTLE_OPTIONS
  );
  (0, import_element7.useLayoutEffect)(() => {
    if (width) {
      setThrottledWidth(width);
    }
  }, [width, setThrottledWidth]);
  (0, import_element7.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_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: { position: "relative" }, children: containerResizeListener }),
    isReady && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
      "div",
      {
        className: "global-styles-ui-preview__wrapper",
        style: {
          height: normalizedHeight * ratio
        },
        onMouseEnter: () => setIsHovered(true),
        onMouseLeave: () => setIsHovered(false),
        tabIndex: -1,
        children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
          import_components7.__unstableMotion.div,
          {
            style: {
              height: normalizedHeight * ratio,
              width: "100%",
              background: gradientValue ?? backgroundColor,
              cursor: withHoverView ? "pointer" : void 0
            },
            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_runtime16 = __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_runtime16.jsxs)(
    preview_wrapper_default,
    {
      label,
      isFocused,
      withHoverView,
      children: [
        ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
          import_components8.__unstableMotion.div,
          {
            variants: firstFrameVariants,
            style: {
              height: "100%",
              overflow: "hidden"
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
              import_components8.__experimentalHStack,
              {
                spacing: 10 * ratio,
                justify: "center",
                style: {
                  height: "100%",
                  overflow: "hidden"
                },
                children: [
                  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
                    PreviewTypography,
                    {
                      fontSize: 65 * ratio,
                      variation
                    }
                  ),
                  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_components8.__experimentalVStack, { spacing: 4 * ratio, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
                    HighlightedColors,
                    {
                      normalizedColorSwatchSize: 32,
                      ratio
                    }
                  ) })
                ]
              }
            )
          },
          key
        ),
        ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
          import_components8.__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_runtime16.jsx)(
              import_components8.__experimentalHStack,
              {
                spacing: 0,
                justify: "flex-start",
                style: {
                  height: "100%",
                  overflow: "hidden"
                },
                children: paletteColors.slice(0, 4).map(({ color }, index) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
                  "div",
                  {
                    style: {
                      height: "100%",
                      background: color,
                      flexGrow: 1
                    }
                  },
                  index
                ))
              }
            )
          },
          key
        ),
        ({ ratio, key }) => /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
          import_components8.__unstableMotion.div,
          {
            variants: secondFrameVariants,
            style: {
              height: "100%",
              width: "100%",
              overflow: "hidden",
              position: "absolute",
              top: 0
            },
            children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
              import_components8.__experimentalVStack,
              {
                spacing: 3 * ratio,
                justify: "center",
                style: {
                  height: "100%",
                  overflow: "hidden",
                  padding: 10 * ratio,
                  boxSizing: "border-box"
                },
                children: label && /* @__PURE__ */ (0, import_jsx_runtime16.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_runtime17 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-block-list.mjs
var import_blocks2 = __toESM(require_blocks(), 1);
var import_i18n6 = __toESM(require_i18n(), 1);
var import_components12 = __toESM(require_components(), 1);
var import_data4 = __toESM(require_data(), 1);
var import_element8 = __toESM(require_element(), 1);
var import_block_editor2 = __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_components10 = __toESM(require_components(), 1);
var import_jsx_runtime18 = __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_components11 = __toESM(require_components(), 1);
var import_i18n5 = __toESM(require_i18n(), 1);
var import_jsx_runtime19 = __toESM(require_jsx_runtime(), 1);

// packages/global-styles-ui/build-module/screen-block-list.mjs
var import_jsx_runtime20 = __toESM(require_jsx_runtime(), 1);
var {
  useHasDimensionsPanel: useHasDimensionsPanel2,
  useHasTypographyPanel: useHasTypographyPanel2,
  useHasBorderPanel,
  useSettingsForBlockElement: useSettingsForBlockElement2,
  useHasColorPanel: useHasColorPanel2
} = unlock(import_block_editor2.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 hasBorderPanel = useHasBorderPanel(settings);
  const hasDimensionsPanel = useHasDimensionsPanel2(settings);
  const hasLayoutPanel = hasBorderPanel || hasDimensionsPanel;
  const hasVariationsPanel = !!useBlockVariations(blockName)?.length;
  const hasGlobalStyles = hasTypographyPanel || hasColorPanel || hasLayoutPanel || hasVariationsPanel;
  return hasGlobalStyles;
}
function BlockMenuItem({ block }) {
  const hasBlockMenuItem = useBlockHasGlobalStyles(block.name);
  if (!hasBlockMenuItem) {
    return null;
  }
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
    NavigationButtonAsItem,
    {
      path: "/blocks/" + encodeURIComponent(block.name),
      children: /* @__PURE__ */ (0, import_jsx_runtime20.jsxs)(import_components12.__experimentalHStack, { justify: "flex-start", children: [
        /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_block_editor2.BlockIcon, { icon: block.icon }),
        /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components12.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_element8.useRef)(null);
  (0, import_element8.useEffect)(() => {
    if (!filterValue) {
      return;
    }
    const count = blockTypesListRef.current?.childElementCount || 0;
    const resultsFoundMessage = (0, import_i18n6.sprintf)(
      /* translators: %d: number of results. */
      (0, import_i18n6._n)("%d result found.", "%d results found.", count),
      count
    );
    debouncedSpeak(resultsFoundMessage, "polite");
  }, [filterValue, debouncedSpeak]);
  return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
    "div",
    {
      ref: blockTypesListRef,
      className: "global-styles-ui-block-types-item-list",
      role: "list",
      children: filteredBlockTypes.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_components12.__experimentalText, { align: "center", as: "p", children: (0, import_i18n6.__)("No blocks found.") }) : filteredBlockTypes.map((block) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(
        BlockMenuItem,
        {
          block
        },
        "menu-itemblock-" + block.name
      ))
    }
  );
}
var MemoizedBlockList = (0, import_element8.memo)(BlockList);

// packages/global-styles-ui/build-module/screen-block.mjs
var import_blocks4 = __toESM(require_blocks(), 1);
var import_block_editor4 = __toESM(require_block_editor(), 1);
var import_element10 = __toESM(require_element(), 1);
var import_data5 = __toESM(require_data(), 1);
var import_core_data3 = __toESM(require_core_data(), 1);
var import_components15 = __toESM(require_components(), 1);
var import_i18n7 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/block-preview-panel.mjs
var import_block_editor3 = __toESM(require_block_editor(), 1);
var import_blocks3 = __toESM(require_blocks(), 1);
var import_components13 = __toESM(require_components(), 1);
var import_element9 = __toESM(require_element(), 1);
var import_jsx_runtime21 = __toESM(require_jsx_runtime(), 1);

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

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

// packages/global-styles-ui/build-module/screen-typography.mjs
var import_i18n21 = __toESM(require_i18n(), 1);
var import_components35 = __toESM(require_components(), 1);
var import_element21 = __toESM(require_element(), 1);

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

// packages/global-styles-ui/build-module/typography-elements.mjs
var import_i18n8 = __toESM(require_i18n(), 1);
var import_components17 = __toESM(require_components(), 1);
var import_jsx_runtime25 = __toESM(require_jsx_runtime(), 1);

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

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

// packages/global-styles-ui/build-module/variations/variation.mjs
var import_components19 = __toESM(require_components(), 1);
var import_element11 = __toESM(require_element(), 1);
var import_keycodes = __toESM(require_keycodes(), 1);
var import_i18n9 = __toESM(require_i18n(), 1);
var import_jsx_runtime27 = __toESM(require_jsx_runtime(), 1);
function Variation({
  variation,
  children,
  isPill = false,
  properties,
  showTooltip = false
}) {
  const [isFocused, setIsFocused] = (0, import_element11.useState)(false);
  const {
    base,
    user,
    onChange: setUserConfig
  } = (0, import_element11.useContext)(GlobalStylesContext);
  const context = (0, import_element11.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_element11.useMemo)(
    () => areGlobalStylesEqual(user, variation),
    [user, variation]
  );
  let label = variation?.title;
  if (variation?.description) {
    label = (0, import_i18n9.sprintf)(
      /* translators: 1: variation title. 2: variation description. */
      (0, import_i18n9._x)("%1$s (%2$s)", "variation label"),
      variation?.title,
      variation?.description
    );
  }
  const content = /* @__PURE__ */ (0, import_jsx_runtime27.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_runtime27.jsx)(
        "div",
        {
          className: clsx_default("global-styles-ui-variations_item-preview", {
            "is-pill": isPill
          }),
          children: children(isFocused)
        }
      )
    }
  );
  return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(GlobalStylesContext.Provider, { value: context, children: showTooltip ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(import_components19.Tooltip, { text: variation?.title, children: content }) : content });
}

// packages/global-styles-ui/build-module/variations/variations-typography.mjs
var import_jsx_runtime28 = __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_runtime28.jsxs)(import_components20.__experimentalVStack, { spacing: 3, children: [
    title && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Subtitle, { level: 3, children: title }),
    /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
      import_components20.__experimentalGrid,
      {
        columns: 3,
        gap,
        className: "global-styles-ui-style-variations-container",
        children: typographyVariations.map(
          (variation, index) => {
            return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
              Variation,
              {
                variation,
                properties: propertiesToFilter,
                showTooltip: true,
                children: () => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
                  preview_typography_default,
                  {
                    variation
                  }
                )
              },
              index
            );
          }
        )
      }
    )
  ] });
}

// packages/global-styles-ui/build-module/font-families.mjs
var import_i18n19 = __toESM(require_i18n(), 1);
var import_components33 = __toESM(require_components(), 1);
var import_element20 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/font-library/context.mjs
var import_element12 = __toESM(require_element(), 1);
var import_data6 = __toESM(require_data(), 1);
var import_core_data5 = __toESM(require_core_data(), 1);
var import_i18n11 = __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_components21 = __toESM(require_components(), 1);

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

// packages/global-styles-ui/build-module/font-library/utils/index.mjs
var { File } = window;
var { kebabCase } = unlock(import_components21.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, index) => {
    if (result.status === "fulfilled" && result.value) {
      const response = result.value;
      results.successes.push(response);
    } else if (result.reason) {
      results.errors.push({
        data: fontFacesData[index],
        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_runtime29 = __toESM(require_jsx_runtime(), 1);
var FontLibraryContext = (0, import_element12.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_element12.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_element12.useState)("");
  const [libraryFontSelected, setLibraryFontSelected] = (0, import_element12.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_element12.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_element12.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_i18n11.__)("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_i18n11.__)("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_runtime29.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_i18n17 = __toESM(require_i18n(), 1);
var import_components31 = __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_components25 = __toESM(require_components(), 1);
var import_core_data6 = __toESM(require_core_data(), 1);
var import_data7 = __toESM(require_data(), 1);
var import_element15 = __toESM(require_element(), 1);
var import_i18n13 = __toESM(require_i18n(), 1);

// packages/global-styles-ui/build-module/font-library/font-card.mjs
var import_i18n12 = __toESM(require_i18n(), 1);
var import_components23 = __toESM(require_components(), 1);

// packages/global-styles-ui/build-module/font-library/font-demo.mjs
var import_components22 = __toESM(require_components(), 1);
var import_element13 = __toESM(require_element(), 1);
var import_jsx_runtime30 = __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_element13.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_element13.useState)(false);
  const [isAssetLoaded, setIsAssetLoaded] = (0, import_element13.useState)(false);
  const { loadFontFaceAsset } = (0, import_element13.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_element13.useEffect)(() => {
    const observer = new window.IntersectionObserver(([entry]) => {
      setIsIntersecting(entry.isIntersecting);
    }, {});
    if (ref.current) {
      observer.observe(ref.current);
    }
    return () => observer.disconnect();
  }, [ref]);
  (0, import_element13.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_runtime30.jsx)("div", { ref, children: isPreviewImage ? /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
    "img",
    {
      src: previewUrl,
      loading: "lazy",
      alt: text,
      className: "font-library__font-variant_demo-image"
    }
  ) : /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
    import_components22.__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_runtime31 = __toESM(require_jsx_runtime(), 1);
function FontCard({
  font: font2,
  onClick,
  variantsText,
  navigatorPath
}) {
  const variantsCount = font2.fontFace?.length || 1;
  const style = {
    cursor: !!onClick ? "pointer" : "default"
  };
  const navigator = (0, import_components23.useNavigator)();
  return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(
    import_components23.Button,
    {
      __next40pxDefaultSize: true,
      onClick: () => {
        onClick();
        if (navigatorPath) {
          navigator.goTo(navigatorPath);
        }
      },
      style,
      className: "font-library__font-card",
      children: /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_components23.Flex, { justify: "space-between", wrap: false, children: [
        /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(font_demo_default, { font: font2 }),
        /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)(import_components23.Flex, { justify: "flex-end", children: [
          /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components23.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components23.__experimentalText, { className: "font-library__font-card__count", children: variantsText || (0, import_i18n12.sprintf)(
            /* translators: %d: Number of font variants. */
            (0, import_i18n12._n)(
              "%d variant",
              "%d variants",
              variantsCount
            ),
            variantsCount
          ) }) }),
          /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_components23.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(icon_default, { icon: (0, import_i18n12.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_element14 = __toESM(require_element(), 1);
var import_components24 = __toESM(require_components(), 1);
var import_jsx_runtime32 = __toESM(require_jsx_runtime(), 1);
function LibraryFontVariant({
  face,
  font: font2
}) {
  const { isFontActivated, toggleActivateFont } = (0, import_element14.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_element14.useId)();
  return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)(import_components24.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
    /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
      import_components24.CheckboxControl,
      {
        checked: isInstalled,
        onChange: handleToggleActivation,
        id: checkboxId
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime32.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_runtime33 = __toESM(require_jsx_runtime(), 1);
function InstalledFonts() {
  const {
    baseCustomFonts,
    libraryFontSelected,
    handleSetLibraryFontSelected,
    uninstallFontFamily,
    isResolvingLibrary,
    isInstalling,
    saveFontFamilies,
    getFontFacesActivated
  } = (0, import_element15.useContext)(FontLibraryContext);
  const [fontFamilies, setFontFamilies] = useSetting("typography.fontFamilies");
  const [isConfirmDeleteOpen, setIsConfirmDeleteOpen] = (0, import_element15.useState)(false);
  const [notice, setNotice] = (0, import_element15.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 fontFamiliesHasChanges = !!globalStyles?.edits?.settings?.typography?.fontFamilies;
  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_i18n13.__)("Font family updated successfully.")
      });
    } catch (error) {
      setNotice({
        type: "error",
        message: (0, import_i18n13.sprintf)(
          /* translators: %s: error message */
          (0, import_i18n13.__)("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_i18n13.sprintf)(
      /* translators: 1: Active font variants, 2: Total font variants. */
      (0, import_i18n13.__)("%1$d/%2$d variants active"),
      variantsActive,
      variantsInstalled
    );
  };
  (0, import_element15.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_runtime33.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.ProgressBar, {}) }),
    !isResolvingLibrary && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(
        import_components25.Navigator,
        {
          initialPath: libraryFontSelected ? "/fontFamily" : "/",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.Navigator.Screen, { path: "/", children: /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.__experimentalVStack, { spacing: "8", children: [
              notice && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                import_components25.Notice,
                {
                  status: notice.type,
                  onRemove: () => setNotice(null),
                  children: notice.message
                }
              ),
              !hasFonts && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalText, { as: "p", children: (0, import_i18n13.__)("No fonts installed.") }),
              baseThemeFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.__experimentalVStack, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h2", {
                  className: "font-library__fonts-title",
                  /* translators: Heading for a list of fonts provided by the theme. */
                  children: (0, import_i18n13._x)("Theme", "font source")
                }),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: baseThemeFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                          font_card_default,
                          {
                            font: font2,
                            navigatorPath: "/fontFamily",
                            variantsText: getFontCardVariantsText(
                              font2
                            ),
                            onClick: () => {
                              setNotice(null);
                              handleSetLibraryFontSelected(
                                font2
                              );
                            }
                          }
                        )
                      },
                      font2.slug
                    ))
                  }
                )
              ] }),
              baseCustomFonts.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.__experimentalVStack, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)("h2", {
                  className: "font-library__fonts-title",
                  /* translators: Heading for a list of fonts installed by the user. */
                  children: (0, import_i18n13._x)("Custom", "font source")
                }),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: baseCustomFonts.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                          font_card_default,
                          {
                            font: font2,
                            navigatorPath: "/fontFamily",
                            variantsText: getFontCardVariantsText(
                              font2
                            ),
                            onClick: () => {
                              setNotice(null);
                              handleSetLibraryFontSelected(
                                font2
                              );
                            }
                          }
                        )
                      },
                      font2.slug
                    ))
                  }
                )
              ] })
            ] }) }),
            /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.Navigator.Screen, { path: "/fontFamily", children: [
              libraryFontSelected && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                ConfirmDeleteDialog,
                {
                  font: libraryFontSelected,
                  isOpen: isConfirmDeleteOpen,
                  setIsOpen: setIsConfirmDeleteOpen,
                  setNotice,
                  uninstallFontFamily,
                  handleSetLibraryFontSelected
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.Flex, { justify: "flex-start", children: [
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  import_components25.Navigator.BackButton,
                  {
                    icon: (0, import_i18n13.isRTL)() ? chevron_right_default : chevron_left_default,
                    size: "small",
                    onClick: () => {
                      handleSetLibraryFontSelected(
                        void 0
                      );
                      setNotice(null);
                    },
                    label: (0, import_i18n13.__)("Back")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  import_components25.__experimentalHeading,
                  {
                    level: 2,
                    size: 13,
                    className: "global-styles-ui-header",
                    children: libraryFontSelected?.name
                  }
                )
              ] }),
              notice && /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_jsx_runtime33.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalSpacer, { margin: 1 }),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  import_components25.Notice,
                  {
                    status: notice.type,
                    onRemove: () => setNotice(null),
                    children: notice.message
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalSpacer, { margin: 1 })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalText, { children: (0, import_i18n13.__)(
                "Choose font variants. Keep in mind that too many variants could make your site slower."
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.__experimentalVStack, { spacing: 0, children: [
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  import_components25.CheckboxControl,
                  {
                    className: "font-library__select-all",
                    label: (0, import_i18n13.__)("Select all"),
                    checked: isSelectAllChecked,
                    onChange: toggleSelectAll,
                    indeterminate: isIndeterminate
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.__experimentalSpacer, { margin: 8 }),
                /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                  "ul",
                  {
                    role: "list",
                    className: "font-library__fonts-list",
                    children: libraryFontSelected && getFontFacesToDisplay(
                      libraryFontSelected
                    ).map((face, i2) => /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
                          library_font_variant_default,
                          {
                            font: libraryFontSelected,
                            face
                          },
                          `face${i2}`
                        )
                      },
                      `face${i2}`
                    ))
                  }
                )
              ] })
            ] })
          ]
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)(import_components25.__experimentalHStack, { justify: "flex-end", className: "font-library__footer", children: [
        isInstalling && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(import_components25.ProgressBar, {}),
        shouldDisplayDeleteButton && /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
          import_components25.Button,
          {
            __next40pxDefaultSize: true,
            isDestructive: true,
            variant: "tertiary",
            onClick: handleUninstallClick,
            children: (0, import_i18n13.__)("Delete")
          }
        ),
        /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
          import_components25.Button,
          {
            __next40pxDefaultSize: true,
            variant: "primary",
            onClick: handleUpdate,
            disabled: !fontFamiliesHasChanges,
            accessibleWhenDisabled: true,
            children: (0, import_i18n13.__)("Update")
          }
        )
      ] })
    ] })
  ] });
}
function ConfirmDeleteDialog({
  font: font2,
  isOpen,
  setIsOpen,
  setNotice,
  uninstallFontFamily,
  handleSetLibraryFontSelected
}) {
  const navigator = (0, import_components25.useNavigator)();
  const handleConfirmUninstall = async () => {
    setNotice(null);
    setIsOpen(false);
    try {
      await uninstallFontFamily(font2);
      navigator.goBack();
      handleSetLibraryFontSelected(void 0);
      setNotice({
        type: "success",
        message: (0, import_i18n13.__)("Font family uninstalled successfully.")
      });
    } catch (error) {
      setNotice({
        type: "error",
        message: (0, import_i18n13.__)("There was an error uninstalling the font family.") + error.message
      });
    }
  };
  const handleCancelUninstall = () => {
    setIsOpen(false);
  };
  return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
    import_components25.__experimentalConfirmDialog,
    {
      isOpen,
      cancelButtonText: (0, import_i18n13.__)("Cancel"),
      confirmButtonText: (0, import_i18n13.__)("Delete"),
      onCancel: handleCancelUninstall,
      onConfirm: handleConfirmUninstall,
      size: "medium",
      children: font2 && (0, import_i18n13.sprintf)(
        /* translators: %s: Name of the font. */
        (0, import_i18n13.__)(
          '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_element17 = __toESM(require_element(), 1);
var import_components28 = __toESM(require_components(), 1);
var import_compose3 = __toESM(require_compose(), 1);
var import_i18n15 = __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_i18n14 = __toESM(require_i18n(), 1);
var import_components26 = __toESM(require_components(), 1);
var import_jsx_runtime34 = __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_runtime34.jsx)("div", { className: "font-library__google-fonts-confirm", children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.Card, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsxs)(import_components26.CardBody, { children: [
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.__experimentalHeading, { level: 2, children: (0, import_i18n14.__)("Connect to Google Fonts") }),
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.__experimentalSpacer, { margin: 6 }),
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.__experimentalText, { as: "p", children: (0, import_i18n14.__)(
      "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_runtime34.jsx)(import_components26.__experimentalSpacer, { margin: 3 }),
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.__experimentalText, { as: "p", children: (0, import_i18n14.__)(
      "You can alternatively upload files directly on the Upload tab."
    ) }),
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(import_components26.__experimentalSpacer, { margin: 6 }),
    /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
      import_components26.Button,
      {
        __next40pxDefaultSize: true,
        variant: "primary",
        onClick: handleConfirm,
        children: (0, import_i18n14.__)("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_element16 = __toESM(require_element(), 1);
var import_components27 = __toESM(require_components(), 1);
var import_jsx_runtime35 = __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_element16.useId)();
  return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "font-library__font-card", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_components27.Flex, { justify: "flex-start", align: "center", gap: "1rem", children: [
    /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
      import_components27.CheckboxControl,
      {
        checked: selected,
        onChange: handleToggleActivation,
        id: checkboxId
      }
    ),
    /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("label", { htmlFor: checkboxId, children: /* @__PURE__ */ (0, import_jsx_runtime35.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_runtime36 = __toESM(require_jsx_runtime(), 1);
var DEFAULT_CATEGORY = {
  slug: "all",
  name: (0, import_i18n15._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_element17.useState)(
    null
  );
  const [notice, setNotice] = (0, import_element17.useState)(null);
  const [fontsToInstall, setFontsToInstall] = (0, import_element17.useState)(
    []
  );
  const [page, setPage] = (0, import_element17.useState)(1);
  const [filters, setFilters] = (0, import_element17.useState)({});
  const [renderConfirmDialog, setRenderConfirmDialog] = (0, import_element17.useState)(
    requiresPermission && !getGoogleFontsPermissionFromStorage()
  );
  const { installFonts, isInstalling } = (0, import_element17.useContext)(FontLibraryContext);
  const { record: selectedCollection, isResolving: isLoading } = (0, import_core_data7.useEntityRecord)("root", "fontCollection", slug);
  (0, import_element17.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_element17.useEffect)(() => {
    setSelectedFont(null);
  }, [slug]);
  (0, import_element17.useEffect)(() => {
    setFontsToInstall([]);
  }, [selectedFont]);
  const collectionFonts = (0, import_element17.useMemo)(
    () => selectedCollection?.font_families ?? [],
    [selectedCollection]
  );
  const collectionCategories = selectedCollection?.categories ?? [];
  const categories = [DEFAULT_CATEGORY, ...collectionCategories];
  const fonts = (0, import_element17.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 (error) {
      setNotice({
        type: "error",
        message: (0, import_i18n15.__)(
          "Error installing the fonts, could not be downloaded."
        )
      });
      return;
    }
    try {
      await installFonts([fontFamily]);
      setNotice({
        type: "success",
        message: (0, import_i18n15.__)("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_runtime36.jsx)(google_fonts_confirm_dialog_default, {});
  }
  const ActionsComponent = () => {
    if (slug !== "google-fonts" || renderConfirmDialog || selectedFont) {
      return null;
    }
    return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
      import_components28.DropdownMenu,
      {
        icon: more_vertical_default,
        label: (0, import_i18n15.__)("Actions"),
        popoverProps: {
          position: "bottom left"
        },
        controls: [
          {
            title: (0, import_i18n15.__)("Revoke access to Google Fonts"),
            onClick: revokeAccess
          }
        ]
      }
    );
  };
  return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    isLoading && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "font-library__loading", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.ProgressBar, {}) }),
    !isLoading && selectedCollection && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
      /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
        import_components28.Navigator,
        {
          initialPath: "/",
          className: "font-library__tabpanel-layout",
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.Navigator.Screen, { path: "/", children: [
              /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.__experimentalHStack, { justify: "space-between", children: [
                /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.__experimentalVStack, { children: [
                  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalHeading, { level: 2, size: 13, children: selectedCollection.name }),
                  /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalText, { children: selectedCollection.description })
                ] }),
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ActionsComponent, {})
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.__experimentalHStack, { spacing: 4, justify: "space-between", children: [
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                  import_components28.SearchControl,
                  {
                    value: filters.search,
                    placeholder: (0, import_i18n15.__)("Font name\u2026"),
                    label: (0, import_i18n15.__)("Search"),
                    onChange: debouncedUpdateSearchInput,
                    hideLabelFromVision: false
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                  import_components28.SelectControl,
                  {
                    __next40pxDefaultSize: true,
                    label: (0, import_i18n15.__)("Category"),
                    value: filters.category,
                    onChange: handleCategoryFilter,
                    children: categories && categories.map((category) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                      "option",
                      {
                        value: category.slug,
                        children: category.name
                      },
                      category.slug
                    ))
                  }
                )
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 4 }),
              !!selectedCollection?.font_families?.length && !fonts.length && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalText, { children: (0, import_i18n15.__)(
                "No fonts found. Try with a different search term."
              ) }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "font-library__fonts-grid__main", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                "ul",
                {
                  role: "list",
                  className: "font-library__fonts-list",
                  children: items.map((font2) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                    "li",
                    {
                      className: "font-library__fonts-list-item",
                      children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                        font_card_default,
                        {
                          font: font2.font_family_settings,
                          navigatorPath: "/fontFamily",
                          onClick: () => {
                            setSelectedFont(
                              font2.font_family_settings
                            );
                          }
                        }
                      )
                    },
                    font2.font_family_settings.slug
                  ))
                }
              ) })
            ] }),
            /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.Navigator.Screen, { path: "/fontFamily", children: [
              /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_components28.Flex, { justify: "flex-start", children: [
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                  import_components28.Navigator.BackButton,
                  {
                    icon: (0, import_i18n15.isRTL)() ? chevron_right_default : chevron_left_default,
                    size: "small",
                    onClick: () => {
                      setSelectedFont(null);
                      setNotice(null);
                    },
                    label: (0, import_i18n15.__)("Back")
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                  import_components28.__experimentalHeading,
                  {
                    level: 2,
                    size: 13,
                    className: "global-styles-ui-header",
                    children: selectedFont?.name
                  }
                )
              ] }),
              notice && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(import_jsx_runtime36.Fragment, { children: [
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 1 }),
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                  import_components28.Notice,
                  {
                    status: notice.type,
                    onRemove: () => setNotice(null),
                    children: notice.message
                  }
                ),
                /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 1 })
              ] }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalText, { children: (0, import_i18n15.__)("Select font variants to install.") }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 4 }),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                import_components28.CheckboxControl,
                {
                  className: "font-library__select-all",
                  label: (0, import_i18n15.__)("Select all"),
                  checked: isSelectAllChecked,
                  onChange: toggleSelectAll,
                  indeterminate: isIndeterminate
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(import_components28.__experimentalVStack, { spacing: 0, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                "ul",
                {
                  role: "list",
                  className: "font-library__fonts-list",
                  children: selectedFont && getSortedFontFaces(selectedFont).map(
                    (face, i2) => /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                      "li",
                      {
                        className: "font-library__fonts-list-item",
                        children: /* @__PURE__ */ (0, import_jsx_runtime36.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_runtime36.jsx)(import_components28.__experimentalSpacer, { margin: 16 })
            ] })
          ]
        }
      ),
      selectedFont && /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
        import_components28.Flex,
        {
          justify: "flex-end",
          className: "font-library__footer",
          children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
            import_components28.Button,
            {
              __next40pxDefaultSize: true,
              variant: "primary",
              onClick: handleInstall,
              isBusy: isInstalling,
              disabled: fontsToInstall.length === 0 || isInstalling,
              accessibleWhenDisabled: true,
              children: (0, import_i18n15.__)("Install")
            }
          )
        }
      ),
      !selectedFont && /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)(
        import_components28.__experimentalHStack,
        {
          expanded: false,
          className: "font-library__footer",
          justify: "end",
          spacing: 6,
          children: [
            /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
              import_components28.__experimentalHStack,
              {
                justify: "flex-start",
                expanded: false,
                spacing: 1,
                className: "font-library__page-selection",
                children: (0, import_element17.createInterpolateElement)(
                  (0, import_i18n15.sprintf)(
                    // translators: 1: Current page number, 2: Total number of pages.
                    (0, import_i18n15._x)(
                      "<div>Page</div>%1$s<div>of %2$d</div>",
                      "paging"
                    ),
                    "<CurrentPage />",
                    totalPages
                  ),
                  {
                    div: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { "aria-hidden": true }),
                    CurrentPage: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                      import_components28.SelectControl,
                      {
                        "aria-label": (0, import_i18n15.__)(
                          "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_runtime36.jsxs)(import_components28.__experimentalHStack, { expanded: false, spacing: 1, children: [
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                import_components28.Button,
                {
                  onClick: () => setPage(page - 1),
                  disabled: page === 1,
                  accessibleWhenDisabled: true,
                  label: (0, import_i18n15.__)("Previous page"),
                  icon: (0, import_i18n15.isRTL)() ? next_default : previous_default,
                  showTooltip: true,
                  size: "compact",
                  tooltipPosition: "top"
                }
              ),
              /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
                import_components28.Button,
                {
                  onClick: () => setPage(page + 1),
                  disabled: page === totalPages,
                  accessibleWhenDisabled: true,
                  label: (0, import_i18n15.__)("Next page"),
                  icon: (0, import_i18n15.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_i18n16 = __toESM(require_i18n(), 1);
var import_components30 = __toESM(require_components(), 1);
var import_element18 = __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, index, br) {
            var start_index = index;
            var nbits;
            br.fillBitWindow();
            index += br.val_ >>> br.bit_pos_ & HUFFMAN_TABLE_MASK;
            nbits = table[index].bits - HUFFMAN_TABLE_BITS;
            if (nbits > 0) {
              br.bit_pos_ += HUFFMAN_TABLE_BITS;
              index += table[index].value;
              index += br.val_ >>> br.bit_pos_ & (1 << nbits) - 1;
            }
            br.bit_pos_ += table[index].bits;
            return table[index].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, index, br) {
            var code;
            var nbits;
            code = ReadSymbol(table, index, br);
            nbits = Prefix.kBlockLengthPrefixCode[code].nbits;
            return Prefix.kBlockLengthPrefixCode[code].offset + br.readBits(nbits);
          }
          function TranslateShortCodes(code, ringbuffer, index) {
            var val;
            if (code < NUM_DISTANCE_SHORT_CODES) {
              index += kDistanceShortCodeIndexOffset[code];
              index &= 3;
              val = ringbuffer[index] + kDistanceShortCodeValueOffset[code];
            } else {
              val = code - NUM_DISTANCE_SHORT_CODES + 1;
            }
            return val;
          }
          function MoveToFront(v2, index) {
            var value = v2[index];
            var i2 = index;
            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 index = v2[i2];
              v2[i2] = mtf[index];
              if (index) MoveToFront(mtf, index);
            }
          }
          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 index = 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[index] & 1)];
            } else if (type_code === 1) {
              block_type = ringbuffers[ringbuffer + (indexes[index] - 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[index] & 1)] = block_type;
            ++indexes[index];
          }
          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 offset;
                    distance_code -= num_direct_distance_codes;
                    postfix = distance_code & distance_postfix_mask;
                    distance_code >>= distance_postfix_bits;
                    nbits = (distance_code >> 1) + 1;
                    offset = (2 + (distance_code & 1) << nbits) - 4;
                    distance_code = num_direct_distance_codes + (offset + 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 offset = BrotliDictionary.offsetsByLength[copy_length];
                    var word_id = distance - max_distance - 1;
                    var shift = BrotliDictionary.sizeBitsByLength[copy_length];
                    var mask = (1 << shift) - 1;
                    var word_idx = word_id & mask;
                    var transform_idx = word_id >> shift;
                    offset += word_idx * copy_length;
                    if (transform_idx < Transform.kNumTransforms) {
                      var len = Transform.transformDictionaryWord(
                        ringbuffer,
                        copy_dst,
                        offset,
                        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 _x9 = 0; _x9 < copy_dst - ringbuffer_end; _x9++)
                          ringbuffer[_x9] = ringbuffer[ringbuffer_end + _x9];
                      }
                    } 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 offset = new Int32Array(
              MAX_LENGTH + 1
            );
            sorted = new Int32Array(code_lengths_size);
            for (symbol = 0; symbol < code_lengths_size; symbol++) {
              count[code_lengths[symbol]]++;
            }
            offset[1] = 0;
            for (len = 1; len < MAX_LENGTH; len++) {
              offset[len + 1] = offset[len] + count[len];
            }
            for (symbol = 0; symbol < code_lengths_size; symbol++) {
              if (code_lengths[symbol] !== 0) {
                sorted[offset[code_lengths[symbol]]++] = symbol;
              }
            }
            table_bits = root_bits;
            table_size = 1 << table_bits;
            total_size = table_size;
            if (offset[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(offset, nbits) {
            this.offset = offset;
            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, size) {
            if (buf.length === size) {
              return buf;
            }
            if (buf.subarray) {
              return buf.subarray(0, size);
            }
            buf.length = size;
            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 (__42) {
            STR_APPLY_OK = false;
          }
          try {
            String.fromCharCode.apply(null, new Uint8Array(1));
          } catch (__42) {
            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, max) {
            var i2, out, c2, c_len;
            var len = max || 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, max) {
            var pos;
            max = max || buf.length;
            if (max > buf.length) {
              max = buf.length;
            }
            pos = max - 1;
            while (pos >= 0 && (buf[pos] & 192) === 128) {
              pos--;
            }
            if (pos < 0) {
              return max;
            }
            if (pos === 0) {
              return max;
            }
            return pos + _utf8len[buf[pos]] > max ? pos : max;
          };
        },
        { "./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 min = 0, max = 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 (max = MAXBITS; max >= 1; max--) {
              if (count[max] !== 0) {
                break;
              }
            }
            if (root > max) {
              root = max;
            }
            if (max === 0) {
              table[table_index++] = 1 << 24 | 64 << 16 | 0;
              table[table_index++] = 1 << 24 | 64 << 16 | 0;
              opts.bits = 1;
              return 0;
            }
            for (min = 1; min < max; min++) {
              if (count[min] !== 0) {
                break;
              }
            }
            if (root < min) {
              root = min;
            }
            left = 1;
            for (len = 1; len <= MAXBITS; len++) {
              left <<= 1;
              left -= count[len];
              if (left < 0) {
                return -1;
              }
            }
            if (left > 0 && (type === CODES || max !== 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 = min;
            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;
              min = 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 === max) {
                  break;
                }
                len = lens[lens_index + work[sym]];
              }
              if (len > root && (huff & mask) !== low) {
                if (drop === 0) {
                  drop = root;
                }
                next += min;
                curr = len - drop;
                left = 1 << curr;
                while (curr + drop < max) {
                  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 offset = 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 {
        offset = entry.offset;
      }
      return createTable2(
        woff.tables,
        { tag: entry.tag, offset, 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, size = 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 = `${size}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 = size;
    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 offset = this.offset = p22.Offset32;
    lazy$1(this, `table`, () => {
      p22.currentPosition = tableStart + offset;
      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, offset) {
    this.length = length;
    this.offset = offset;
  }
};
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 index = this.glyphNameIndex[i2];
        if (index < 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 index = this.glyphNameIndex[glyphid];
    if (index < 258) return macStrings[index];
    let offset = this.glyphNameOffsets[glyphid];
    let next = this.glyphNameOffsets[glyphid + 1];
    let len = next - offset - 1;
    if (len === 0) return `.notdef.`;
    this.parser.currentPosition = this.namesOffset + offset;
    const data = this.parser.readBytes(
      len,
      this.namesOffset + offset,
      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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.sequenceOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.alternateSetOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.ligatureSetOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.ligatureOffsets[index];
    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(index) {
    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[index];
    return new SubRuleSetTable(p22);
  }
  getSubClassSet(index) {
    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[index];
    return new SubClassSetTable(p22);
  }
  getCoverageTable(index) {
    if (this.substFormat !== 3 && !index)
      return super.getCoverageTable();
    if (!index)
      throw new Error(
        `lookup type 5.${this.substFormat} requires an coverage table index.`
      );
    let p22 = this.parser;
    p22.currentPosition = this.start + this.coverageOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subRuleOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.subClassRuleOffsets[index];
    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(index) {
    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[index];
    return new ChainSubRuleSetTable(p22);
  }
  getChainSubClassSet(index) {
    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[index];
    return new ChainSubClassSetTable(p22);
  }
  getCoverageFromOffset(offset) {
    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 + offset;
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
    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(index) {
    let p22 = this.parser;
    p22.currentPosition = this.start + this.chainSubRuleOffsets[index];
    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(index) {
    const builder = this.ctType === `GSUB` ? GSUBtables : GPOStables;
    this.parser.currentPosition = this.start + this.subtableOffsets[index];
    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 offset = scriptTable.defaultLangSys;
    if (offset !== 0) {
      this.parser.currentPosition = scriptTable.start + offset;
      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(
      (index) => this.getFeature(index)
    );
  }
  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(
      (index) => this.getLookup(index)
    );
  }
  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 offset = this.start + record.svgDocOffset;
    this.parser.currentPosition = offset;
    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, size) {
    let start = p22.currentPosition;
    this.subfamilyNameID = p22.uint16;
    p22.uint16;
    this.coordinates = [...new Array(axisCount)].map(
      (_) => p22.fixed
    );
    if (p22.currentPosition - start < size) {
      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(offset, length) {
    this.parser.currentPosition = this.tableStart + offset;
    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 offset = this.offsets[glyphID] * this.x2 ? 2 : 1;
    let nextOffset = this.offsets[glyphID + 1] * this.x2 ? 2 : 1;
    return { offset, length: nextOffset - offset };
  }
};
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 offset = this.tableStart + 4;
      const tables = [];
      for (let i2 = 0; i2 < this.nTables; i2++) {
        p22.currentPosition = offset;
        let subtable = new KernSubTable(p22);
        tables.push(subtable);
        offset += 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_components29 = __toESM(require_components(), 1);
var { kebabCase: kebabCase2 } = unlock(import_components29.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_runtime37 = __toESM(require_jsx_runtime(), 1);
function UploadFonts() {
  const { installFonts } = (0, import_element18.useContext)(FontLibraryContext);
  const [isUploading, setIsUploading] = (0, import_element18.useState)(false);
  const [notice, setNotice] = (0, import_element18.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_i18n16.__)("Sorry, you are not allowed to upload this file type.") : (0, import_i18n16.__)("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 (error) {
      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_i18n16.__)("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_runtime37.jsxs)("div", { className: "font-library__tabpanel-layout", children: [
    /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components30.DropZone, { onFilesDrop: handleDropZone }),
    /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(import_components30.__experimentalVStack, { className: "font-library__local-fonts", justify: "start", children: [
      notice && /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)(
        import_components30.Notice,
        {
          status: notice.type,
          __unstableHTML: true,
          onRemove: () => setNotice(null),
          children: [
            notice.message,
            notice.errors && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("ul", { children: notice.errors.map((error, index) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("li", { children: error }, index)) })
          ]
        }
      ),
      isUploading && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components30.FlexItem, { children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "font-library__upload-area", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components30.ProgressBar, {}) }) }),
      !isUploading && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
        import_components30.FormFileUpload,
        {
          accept: ALLOWED_FILE_EXTENSIONS.map(
            (ext) => `.${ext}`
          ).join(","),
          multiple: true,
          onChange: onFilesUpload,
          render: ({ openFileDialog }) => /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
            import_components30.Button,
            {
              __next40pxDefaultSize: true,
              className: "font-library__upload-area",
              onClick: openFileDialog,
              children: (0, import_i18n16.__)("Upload font")
            }
          )
        }
      ),
      /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_components30.__experimentalText, { className: "font-library__upload-area__text", children: (0, import_i18n16.__)(
        "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_runtime38 = __toESM(require_jsx_runtime(), 1);
var { Tabs } = unlock(import_components31.privateApis);
var DEFAULT_TAB = {
  id: "installed-fonts",
  title: (0, import_i18n17._x)("Library", "Font library")
};
var UPLOAD_TAB = {
  id: "upload-fonts",
  title: (0, import_i18n17._x)("Upload", "noun")
};

// packages/global-styles-ui/build-module/font-family-item.mjs
var import_i18n18 = __toESM(require_i18n(), 1);
var import_components32 = __toESM(require_components(), 1);
var import_element19 = __toESM(require_element(), 1);
var import_jsx_runtime39 = __toESM(require_jsx_runtime(), 1);

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

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

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

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

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

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

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

// packages/global-styles-ui/build-module/screen-colors.mjs
var import_i18n24 = __toESM(require_i18n(), 1);
var import_components39 = __toESM(require_components(), 1);
var import_block_editor6 = __toESM(require_block_editor(), 1);

// packages/global-styles-ui/build-module/palette.mjs
var import_components38 = __toESM(require_components(), 1);
var import_i18n23 = __toESM(require_i18n(), 1);
var import_element23 = __toESM(require_element(), 1);

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

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

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

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

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

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

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

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

// packages/global-styles-ui/build-module/preview-colors.mjs
var import_jsx_runtime50 = __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_runtime50.jsx)(
    preview_wrapper_default,
    {
      label,
      isFocused,
      withHoverView,
      children: ({ key }) => /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
        import_components40.__unstableMotion.div,
        {
          variants: firstFrameVariants2,
          style: {
            height: "100%",
            overflow: "hidden"
          },
          children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(
            import_components40.__experimentalHStack,
            {
              spacing: 0,
              justify: "center",
              style: {
                height: "100%",
                overflow: "hidden"
              },
              children: /* @__PURE__ */ (0, import_jsx_runtime50.jsx)(PresetColors, {})
            }
          )
        },
        key
      )
    }
  );
};
var preview_colors_default = StylesPreviewColors;

// packages/global-styles-ui/build-module/variations/variations-color.mjs
var import_jsx_runtime51 = __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_runtime51.jsxs)(import_components41.__experimentalVStack, { spacing: 3, children: [
    title && /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(Subtitle, { level: 3, children: title }),
    /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(import_components41.__experimentalGrid, { gap, children: colorVariations.map((variation, index) => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(
      Variation,
      {
        variation,
        isPill: true,
        properties: propertiesToFilter2,
        showTooltip: true,
        children: () => /* @__PURE__ */ (0, import_jsx_runtime51.jsx)(preview_colors_default, {})
      },
      index
    )) })
  ] });
}

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

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

// packages/global-styles-ui/build-module/screen-color-palette.mjs
var import_jsx_runtime54 = __toESM(require_jsx_runtime(), 1);
var { Tabs: Tabs2 } = unlock(import_components44.privateApis);

// packages/global-styles-ui/build-module/screen-background.mjs
var import_i18n28 = __toESM(require_i18n(), 1);
var import_block_editor8 = __toESM(require_block_editor(), 1);
var import_components45 = __toESM(require_components(), 1);

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

// packages/global-styles-ui/build-module/screen-background.mjs
var import_jsx_runtime56 = __toESM(require_jsx_runtime(), 1);
var { useHasBackgroundPanel: useHasBackgroundPanel3 } = unlock(import_block_editor8.privateApis);

// packages/global-styles-ui/build-module/shadows-panel.mjs
var import_components47 = __toESM(require_components(), 1);
var import_i18n30 = __toESM(require_i18n(), 1);
var import_element24 = __toESM(require_element(), 1);

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

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

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

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

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

// packages/global-styles-ui/build-module/dimensions-panel.mjs
var import_block_editor9 = __toESM(require_block_editor(), 1);
var import_element26 = __toESM(require_element(), 1);
var import_jsx_runtime61 = __toESM(require_jsx_runtime(), 1);
var { useSettingsForBlockElement: useSettingsForBlockElement6, DimensionsPanel: StylesDimensionsPanel2 } = unlock(import_block_editor9.privateApis);

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

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

// packages/global-styles-ui/build-module/style-variations-content.mjs
var import_i18n34 = __toESM(require_i18n(), 1);
var import_components50 = __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_element27 = __toESM(require_element(), 1);
var import_components49 = __toESM(require_components(), 1);
var import_i18n33 = __toESM(require_i18n(), 1);
var import_jsx_runtime63 = __toESM(require_jsx_runtime(), 1);
function StyleVariationsContainer({
  gap = 2
}) {
  const { user } = (0, import_element27.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_element27.useMemo)(() => {
    const withEmptyVariation = [
      {
        title: (0, import_i18n33.__)("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_runtime63.jsx)(
    import_components49.__experimentalGrid,
    {
      columns: 2,
      className: "global-styles-ui-style-variations-container",
      gap,
      children: themeVariations.map(
        (variation, index) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(Variation, { variation, children: (isFocused) => /* @__PURE__ */ (0, import_jsx_runtime63.jsx)(
          preview_styles_default,
          {
            label: variation?.title,
            withHoverView: true,
            isFocused,
            variation
          }
        ) }, index)
      )
    }
  );
}
var style_variations_container_default = StyleVariationsContainer;

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

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

// packages/global-styles-ui/build-module/screen-css.mjs
var import_i18n36 = __toESM(require_i18n(), 1);
var import_components52 = __toESM(require_components(), 1);
var import_block_editor11 = __toESM(require_block_editor(), 1);
var import_jsx_runtime66 = __toESM(require_jsx_runtime(), 1);
var { AdvancedPanel: StylesAdvancedPanel2 } = unlock(import_block_editor11.privateApis);

// packages/global-styles-ui/build-module/screen-revisions/index.mjs
var import_i18n39 = __toESM(require_i18n(), 1);
var import_components55 = __toESM(require_components(), 1);
var import_element29 = __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_element28 = __toESM(require_element(), 1);

// packages/global-styles-ui/build-module/screen-revisions/revisions-buttons.mjs
var import_i18n37 = __toESM(require_i18n(), 1);
var import_components53 = __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_runtime67 = __toESM(require_jsx_runtime(), 1);
var DAY_IN_MILLISECONDS = 60 * 60 * 1e3 * 24;

// packages/global-styles-ui/build-module/pagination/index.mjs
var import_components54 = __toESM(require_components(), 1);
var import_i18n38 = __toESM(require_i18n(), 1);
var import_jsx_runtime68 = __toESM(require_jsx_runtime(), 1);

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

// packages/global-styles-ui/build-module/font-sizes/font-sizes.mjs
var import_i18n41 = __toESM(require_i18n(), 1);
var import_components57 = __toESM(require_components(), 1);
var import_element30 = __toESM(require_element(), 1);

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

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

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

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

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

// packages/global-styles-ui/build-module/font-sizes/rename-font-size-dialog.mjs
var import_components59 = __toESM(require_components(), 1);
var import_i18n44 = __toESM(require_i18n(), 1);
var import_element31 = __toESM(require_element(), 1);
var import_jsx_runtime74 = __toESM(require_jsx_runtime(), 1);

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

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

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

// packages/global-styles-ui/build-module/with-global-styles-provider.mjs
var import_jsx_runtime78 = __toESM(require_jsx_runtime(), 1);
function withGlobalStylesProvider(Component) {
  return function WrappedComponent({
    value,
    baseValue,
    onChange,
    ...props
  }) {
    return /* @__PURE__ */ (0, import_jsx_runtime78.jsx)(
      GlobalStylesProvider,
      {
        value,
        baseValue,
        onChange,
        children: /* @__PURE__ */ (0, import_jsx_runtime78.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_runtime79 = __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_runtime79.jsx)(upload_fonts_default, {});
      break;
    case "installed-fonts":
      content = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(installed_fonts_default, {});
      break;
    default:
      content = /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(font_collection_default, { slug: activeTab });
  }
  return /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(
    GlobalStylesProvider,
    {
      value,
      baseValue,
      onChange,
      children: /* @__PURE__ */ (0, import_jsx_runtime79.jsx)(context_default, { children: content })
    }
  );
}

// routes/font-list/lock-unlock.ts
var import_private_apis2 = __toESM(require_private_apis());
var { 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/font-list-route"
);

// routes/font-list/style.scss
if (typeof document !== "undefined" && !document.head.querySelector("style[data-wp-hash='89af99528f']")) {
  const style = document.createElement("style");
  style.setAttribute("data-wp-hash", "89af99528f");
  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:499;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:499;text-transform:uppercase}@media (min-width:600px){.font-library__page-selection .font-library__page-selection-trigger{font-size:11px!important;font-weight:499}}.font-library__fonts-title{font-size:11px;font-weight: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: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 #0000}.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 #0000;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 #0000;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__applied-text,.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__applied-text,.global-styles-ui-screen-revisions__apply-button.is-primary{align-self:flex-start;margin:4px 12px 12px 40px}.global-styles-ui-screen-revisions__applied-text,.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: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;height:56px;min-width:100%;padding:12px;position:sticky;z-index:1}.global-styles-ui-variations_item{box-sizing:border-box;cursor:pointer}.global-styles-ui-variations_item .global-styles-ui-variations_item-preview{border-radius:2px;outline:1px solid #0000001a;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:#0000004d}.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{align-items:center;cursor:pointer;display:flex;justify-content:center;line-height:1}.global-styles-ui-preview__wrapper{display:block;max-width:100%;width:100%}.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{margin-bottom:0!important}.global-styles-ui-subtitle{font-size:11px!important;font-weight:499!important;margin-bottom:0!important;text-transform:uppercase}.global-styles-ui-section-title{color:#2f2f2f;font-weight: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%,#0000 0,#0000 75%,#e0e0e0 0,#e0e0e0),repeating-linear-gradient(45deg,#e0e0e0 25%,#0000 0,#0000 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 .components-v-stack{flex:1 1 auto}.global-styles-ui-screen-css .components-v-stack .block-editor-global-styles-advanced-panel__custom-css-input,.global-styles-ui-screen-css .components-v-stack .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 .components-v-stack .block-editor-global-styles-advanced-panel__custom-css-input .components-base-control__field .components-textarea-control__input{direction:ltr;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-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}.admin-ui-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: Tabs3 } = unlock2(import_components63.privateApis);
var { useGlobalStyles } = unlock2(import_editor.privateApis);
function FontLibraryPage() {
  const { records: collections = [] } = (0, import_core_data12.useEntityRecords)("root", "fontCollection", {
    _fields: "slug,name,description"
  });
  const [activeTab, setActiveTab] = (0, import_element34.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_i18n46.__)("Library")
    }
  ];
  if (canUserCreate) {
    tabs.push({
      id: "upload-fonts",
      title: (0, import_i18n46.__)("Upload")
    });
    tabs.push(
      ...(collections || []).map(({ slug, name: name2 }) => ({
        id: slug,
        title: collections && collections.length === 1 && slug === "google-fonts" ? (0, import_i18n46.__)("Install Fonts") : name2
      }))
    );
  }
  return /* @__PURE__ */ React.createElement(page_default, { title: (0, import_i18n46.__)("Fonts") }, /* @__PURE__ */ React.createElement(
    Tabs3,
    {
      selectedTabId: activeTab,
      onSelect: (tabId) => setActiveTab(tabId)
    },
    /* @__PURE__ */ React.createElement("div", { className: "font-library-page__tablist" }, /* @__PURE__ */ React.createElement(Tabs3.TabList, null, tabs.map(({ id, title }) => /* @__PURE__ */ React.createElement(Tabs3.Tab, { key: id, tabId: id }, title)))),
    tabs.map(({ id }) => /* @__PURE__ */ React.createElement(
      Tabs3.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:

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.
   *)
*/
