import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
  require_react
} from "./chunk-TODKQSCF.js";
import {
  WIX_CONFIG_FILENAME,
  getWixConfigFilePath
} from "./chunk-YT5BPQDJ.js";
import {
  readJson
} from "./chunk-VASURI4S.js";
import {
  external_exports
} from "./chunk-SDLCFZRL.js";
import {
  CliError,
  CliErrorCode
} from "./chunk-MTT3QXBC.js";
import {
  __toESM,
  init_esm_shims
} from "./chunk-EXLZF52D.js";

// ../cli-site-live/src/model.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);

// ../cli-site-live/src/files/wix.config.ts
init_esm_shims();

// ../cli-site-live-definitions/src/index.ts
init_esm_shims();
var wixConfigSchema = external_exports.object({
  siteId: external_exports.string().uuid(),
  veloAppId: external_exports.string().uuid()
});

// ../cli-site-live/src/files/wix.config.ts
async function readWixConfig(projectFolder) {
  const configFile = await readJson(getWixConfigFilePath(projectFolder));
  const config = wixConfigSchema.safeParse(configFile);
  if (config.success) {
    return config.data;
  }
  throw new CliError({
    code: CliErrorCode.InvalidConfigSchemaError({
      configPath: WIX_CONFIG_FILENAME,
      zodError: config.error
    }),
    cause: config.error
  });
}

// ../cli-site-live/src/model.tsx
async function loadProjectModel(projectFolder) {
  const config = await readWixConfig(projectFolder);
  return {
    projectFolder,
    metaSiteId: config.siteId,
    veloAppId: config.veloAppId
  };
}
var ProjectModelContext = (0, import_react.createContext)(null);
var ProjectModelProvider = ({ model, children }) => {
  return /* @__PURE__ */ import_react.default.createElement(ProjectModelContext.Provider, { value: model }, children);
};
function useProjectModel() {
  const context = (0, import_react.useContext)(ProjectModelContext);
  if (context == null) {
    throw new Error(
      "useProjectModel() cannot be used without an <ProjectModelProvider>"
    );
  }
  return context;
}

export {
  loadProjectModel,
  ProjectModelProvider,
  useProjectModel
};
//# sourceMappingURL=chunk-QQCKD2RP.js.map