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 __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/venueBooking/index.tsx
var venueBooking_exports = {};
__export(venueBooking_exports, {
  default: () => venueBooking_default
});
module.exports = __toCommonJS(venueBooking_exports);
var import_react = __toESM(require("react"));
var import_utils = require("@pisell/utils");
var import_useEngineContext = __toESM(require("../../hooks/useEngineContext"));
var import_context = require("./context");
var import_Content = __toESM(require("./components/Content"));
var import_hooks = require("./hooks");
var import_locales = __toESM(require("./locales"));
function getViewportHeight() {
  var _a;
  if (typeof window === "undefined") return void 0;
  const visualViewportHeight = (_a = window.visualViewport) == null ? void 0 : _a.height;
  if (visualViewportHeight && visualViewportHeight > 0) return Math.round(visualViewportHeight);
  if (window.innerHeight > 0) return window.innerHeight;
  return void 0;
}
function getViewportHeightFallback() {
  var _a, _b;
  if (typeof CSS !== "undefined" && ((_a = CSS.supports) == null ? void 0 : _a.call(CSS, "height", "100dvh"))) return "100dvh";
  if (typeof CSS !== "undefined" && ((_b = CSS.supports) == null ? void 0 : _b.call(CSS, "height", "100svh"))) return "100svh";
  return "100%";
}
function getIsMobileFooterVisible() {
  if (typeof window === "undefined") return false;
  return window.matchMedia("(max-width: 1023.98px)").matches;
}
function getViewportStyle(viewportHeight) {
  if (viewportHeight === void 0) {
    const fallbackHeight = getViewportHeightFallback();
    return {
      height: fallbackHeight,
      minHeight: fallbackHeight
    };
  }
  return {
    "--vb-viewport-height": `${viewportHeight}px`,
    height: "var(--vb-viewport-height)",
    minHeight: "var(--vb-viewport-height)"
  };
}
function VenueBooking(props) {
  var _a, _b, _c;
  const context = (0, import_useEngineContext.default)();
  const entryContext = (0, import_hooks.normalizeEntryContext)((_a = context == null ? void 0 : context.engine) == null ? void 0 : _a.props);
  import_utils.locales.init(import_locales.default, ((_c = (_b = context == null ? void 0 : context.engine) == null ? void 0 : _b.props) == null ? void 0 : _c.locale) || "en");
  const [viewportHeight, setViewportHeight] = (0, import_react.useState)(
    getViewportHeight
  );
  const [isMobileFooterVisible, setIsMobileFooterVisible] = (0, import_react.useState)(
    getIsMobileFooterVisible
  );
  (0, import_react.useEffect)(() => {
    var _a2, _b2;
    let frameId;
    function updateViewportHeight() {
      if (frameId !== void 0) window.cancelAnimationFrame(frameId);
      frameId = window.requestAnimationFrame(() => {
        frameId = void 0;
        setViewportHeight(getViewportHeight());
        setIsMobileFooterVisible(getIsMobileFooterVisible());
      });
    }
    updateViewportHeight();
    window.addEventListener("resize", updateViewportHeight);
    window.addEventListener("orientationchange", updateViewportHeight);
    (_a2 = window.visualViewport) == null ? void 0 : _a2.addEventListener("resize", updateViewportHeight);
    (_b2 = window.visualViewport) == null ? void 0 : _b2.addEventListener("scroll", updateViewportHeight);
    return () => {
      var _a3, _b3;
      if (frameId !== void 0) window.cancelAnimationFrame(frameId);
      window.removeEventListener("resize", updateViewportHeight);
      window.removeEventListener("orientationchange", updateViewportHeight);
      (_a3 = window.visualViewport) == null ? void 0 : _a3.removeEventListener("resize", updateViewportHeight);
      (_b3 = window.visualViewport) == null ? void 0 : _b3.removeEventListener("scroll", updateViewportHeight);
    };
  }, []);
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: `venue-booking-scope ${isMobileFooterVisible ? "fixed" : ""} overflow-x-hidden overscroll-none bg-[#f5f5f3] text-zinc-900`,
      style: getViewportStyle(viewportHeight)
    },
    /* @__PURE__ */ import_react.default.createElement(import_context.VenueBookingProvider, { entryContext }, /* @__PURE__ */ import_react.default.createElement(import_Content.default, null))
  );
}
var venueBooking_default = VenueBooking;
