import { expect } from "@playwright/test";
import { apiRequest } from "./api.js";
import { expectId, readJsonSafe } from "./generalFixtures.js";
async function createAvailabilityRuleSetFixture(request, token, data) {
  const response = await apiRequest(request, "POST", "/api/planner/availability-rule-sets", { token, data });
  const body = await readJsonSafe(response);
  expect(response.status(), "POST /api/planner/availability-rule-sets should return 201").toBe(201);
  return expectId(body?.id, "Availability rule set creation response should include id");
}
async function deleteAvailabilityRuleSetIfExists(request, token, id) {
  if (!token || !id) return;
  await apiRequest(
    request,
    "DELETE",
    `/api/planner/availability-rule-sets?id=${encodeURIComponent(id)}`,
    { token }
  ).catch(() => void 0);
}
async function createAvailabilityRuleFixture(request, token, data) {
  const response = await apiRequest(request, "POST", "/api/planner/availability", { token, data });
  const body = await readJsonSafe(response);
  expect(response.status(), "POST /api/planner/availability should return 201").toBe(201);
  return expectId(body?.id, "Availability rule creation response should include id");
}
async function deleteAvailabilityRuleIfExists(request, token, id) {
  if (!token || !id) return;
  await apiRequest(
    request,
    "DELETE",
    `/api/planner/availability?id=${encodeURIComponent(id)}`,
    { token }
  ).catch(() => void 0);
}
export {
  createAvailabilityRuleFixture,
  createAvailabilityRuleSetFixture,
  deleteAvailabilityRuleIfExists,
  deleteAvailabilityRuleSetIfExists
};
//# sourceMappingURL=plannerFixtures.js.map
