var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/ticketBooking/hooks/useNetworkStatus.ts
var useNetworkStatus_exports = {};
__export(useNetworkStatus_exports, {
  NetworkStatus: () => NetworkStatus,
  NetworkStatusColor: () => NetworkStatusColor,
  useNetworkStatus: () => useNetworkStatus
});
module.exports = __toCommonJS(useNetworkStatus_exports);
var import_react = require("react");
var NetworkStatus = /* @__PURE__ */ ((NetworkStatus2) => {
  NetworkStatus2["GOOD"] = "GOOD";
  NetworkStatus2["WEAK"] = "WEAK";
  NetworkStatus2["OFFLINE"] = "OFFLINE";
  return NetworkStatus2;
})(NetworkStatus || {});
var NetworkStatusColor = {
  ["GOOD" /* GOOD */]: "#3F9E4D",
  // 标准绿色
  ["WEAK" /* WEAK */]: "#CC8E50",
  // 警告橙色
  ["OFFLINE" /* OFFLINE */]: "#F44336"
  // 错误红色
};
var useNetworkStatus = () => {
  const [status, setStatus] = (0, import_react.useState)(
    navigator.onLine ? "GOOD" /* GOOD */ : "OFFLINE" /* OFFLINE */
  );
  (0, import_react.useEffect)(() => {
    const checkNetworkQuality = () => {
      if (!navigator.onLine) {
        setStatus("OFFLINE" /* OFFLINE */);
        return;
      }
      const connection2 = navigator.connection;
      if (connection2) {
        const isWeakNetwork = connection2.effectiveType === "2g" || connection2.effectiveType === "slow-2g" || connection2.rtt > 500 || connection2.downlink < 1;
        setStatus(isWeakNetwork ? "WEAK" /* WEAK */ : "GOOD" /* GOOD */);
      }
    };
    window.addEventListener("online", checkNetworkQuality);
    window.addEventListener("offline", checkNetworkQuality);
    const connection = navigator.connection;
    if (connection) {
      connection.addEventListener("change", checkNetworkQuality);
    }
    checkNetworkQuality();
    return () => {
      window.removeEventListener("online", checkNetworkQuality);
      window.removeEventListener("offline", checkNetworkQuality);
      if (connection) {
        connection.removeEventListener("change", checkNetworkQuality);
      }
    };
  }, []);
  return status;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  NetworkStatus,
  NetworkStatusColor,
  useNetworkStatus
});
