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);
var client_exports = {};
__export(client_exports, {
  createApiClient: () => createApiClient
});
module.exports = __toCommonJS(client_exports);
var import_types = require("@playdrop/types");
var import_me = require("./domains/me.js");
var import_search = require("./domains/search.js");
var import_tags = require("./domains/tags.js");
var import_apps = require("./domains/apps.js");
var import_assets = require("./domains/assets.js");
var import_asset_packs = require("./domains/asset-packs.js");
var import_auth = require("./domains/auth.js");
var import_comments = require("./domains/comments.js");
var import_payments = require("./domains/payments.js");
var import_admin = require("./domains/admin.js");
var import_ai = require("./domains/ai.js");
var import_free_credits = require("./domains/free-credits.js");
var import_player_meta = require("./domains/player-meta.js");
var import_request = require("./core/request.js");
var import_errors = require("./core/errors.js");
function createApiClient(config = {}) {
  const fetchImpl = config.fetchImpl ?? globalThis.fetch?.bind(globalThis);
  if (!fetchImpl) {
    throw new Error("api_client_missing_fetch");
  }
  const requestTimeoutMs = (0, import_request.resolveRequestTimeoutMs)(config.requestTimeoutMs);
  const includeBrowserCredentials = config.includeBrowserCredentials ?? true;
  const resolveBaseUrl = (0, import_request.createBaseUrlResolver)(config.baseUrl);
  const getClientHeaders = () => config.clientHeaders ? config.clientHeaders() : {};
  async function resolveToken() {
    if (config.tokenProvider) {
      const token = await config.tokenProvider();
      return token ?? null;
    }
    return null;
  }
  function buildIapQuery(params) {
    if (!params) {
      return "";
    }
    const search = new URLSearchParams();
    if (params.kind) {
      search.set("kind", params.kind);
    }
    if (params.status) {
      const statuses = Array.isArray(params.status) ? params.status : [params.status];
      if (statuses.length > 0) {
        search.set("status", statuses.join(","));
      }
    }
    if (params.from) {
      const fromValue = params.from instanceof Date ? params.from.toISOString() : params.from;
      search.set("from", fromValue);
    }
    if (params.to) {
      const toValue = params.to instanceof Date ? params.to.toISOString() : params.to;
      search.set("to", toValue);
    }
    if (typeof params.appId === "number") {
      search.set("appId", String(params.appId));
    }
    if (typeof params.limit === "number") {
      search.set("limit", String(params.limit));
    }
    if (typeof params.offset === "number") {
      search.set("offset", String(params.offset));
    }
    const query = search.toString();
    return query;
  }
  function normalizeAssetRevisionInput(revision) {
    if (typeof revision === "number") {
      if (!Number.isInteger(revision) || revision <= 0) {
        throw new Error("invalid_asset_revision");
      }
      return String(revision);
    }
    const trimmed = revision.trim().toLowerCase();
    if (!trimmed) {
      throw new Error("invalid_asset_revision");
    }
    const numeric = trimmed.startsWith("r") ? trimmed.slice(1) : trimmed;
    const parsed = Number.parseInt(numeric, 10);
    if (!Number.isInteger(parsed) || parsed <= 0) {
      throw new Error("invalid_asset_revision");
    }
    return String(parsed);
  }
  function normalizeSemverInput(version) {
    const trimmed = typeof version === "string" ? version.trim() : "";
    if (!trimmed) {
      throw new Error("invalid_version_format");
    }
    const semverRegex = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
    if (!semverRegex.test(trimmed)) {
      throw new Error("invalid_version_format");
    }
    return trimmed;
  }
  function normalizeEnumInput(value, allowed, errorCode) {
    if (!allowed.includes(value)) {
      throw new Error(errorCode);
    }
    return value;
  }
  function normalizeSavedItemKindInput(kind) {
    return normalizeEnumInput(kind, import_types.SAVED_ITEM_KIND_VALUES, "invalid_saved_item_kind");
  }
  function normalizeEngagementEventTypeInput(eventType) {
    return normalizeEnumInput(eventType, import_types.ENGAGEMENT_EVENT_TYPE_VALUES, "invalid_engagement_event_type");
  }
  function normalizeEngagementTargetKindInput(targetKind) {
    return normalizeEnumInput(targetKind, import_types.ENGAGEMENT_TARGET_KIND_VALUES, "invalid_engagement_target_kind");
  }
  function normalizeLibraryCategoryInput(category) {
    return normalizeEnumInput(category, import_types.LIBRARY_CATEGORY_VALUES, "invalid_library_category");
  }
  function normalizeLibrarySortInput(sort) {
    return normalizeEnumInput(sort, import_types.LIBRARY_SORT_VALUES, "invalid_library_sort");
  }
  function normalizeFollowingSortInput(sort) {
    return normalizeEnumInput(sort, import_types.FOLLOWING_SORT_VALUES, "invalid_following_sort");
  }
  function normalizeFollowingFeedSectionInput(section) {
    return normalizeEnumInput(section, import_types.FOLLOWING_FEED_SECTION_VALUES, "invalid_following_feed_section");
  }
  function normalizeNotificationStatusInput(status) {
    return normalizeEnumInput(status, import_types.NOTIFICATION_STATUS_VALUES, "invalid_notification_status");
  }
  function normalizeSearchKindInput(kind) {
    return normalizeEnumInput(kind, import_types.SEARCH_KIND_VALUES, "invalid_search_kind");
  }
  function normalizeSearchModeInput(mode) {
    return normalizeEnumInput(mode, import_types.SEARCH_MODE_VALUES, "invalid_search_mode");
  }
  function normalizeSearchAssetTypeInput(assetType) {
    return normalizeEnumInput(assetType, import_types.SEARCH_ASSET_TYPE_VALUES, "invalid_search_asset_type");
  }
  function normalizePositiveIntegerInput(value, errorCode) {
    if (!Number.isInteger(value) || value <= 0) {
      throw new Error(errorCode);
    }
    return value;
  }
  function normalizeNonNegativeIntegerInput(value, errorCode) {
    if (!Number.isInteger(value) || value < 0) {
      throw new Error(errorCode);
    }
    return value;
  }
  function normalizeCreatorItemSlug(value, field) {
    const trimmed = typeof value === "string" ? value.trim() : "";
    if (!trimmed) {
      throw new Error(field === "creator" ? "invalid_creator_username" : "invalid_item_name");
    }
    return trimmed;
  }
  function normalizeWebPushSubscriptionRequest(requestBody) {
    const subscription = requestBody?.subscription;
    const endpoint = typeof subscription?.endpoint === "string" ? subscription.endpoint.trim() : "";
    const expirationTime = subscription?.expirationTime;
    const p256dh = typeof subscription?.keys?.p256dh === "string" ? subscription.keys.p256dh.trim() : "";
    const auth = typeof subscription?.keys?.auth === "string" ? subscription.keys.auth.trim() : "";
    if (!endpoint || !endpoint.startsWith("https://")) {
      throw new Error("invalid_web_push_subscription");
    }
    if (expirationTime !== null && expirationTime !== void 0 && !Number.isFinite(expirationTime)) {
      throw new Error("invalid_web_push_subscription");
    }
    if (!p256dh || !auth) {
      throw new Error("invalid_web_push_subscription");
    }
    return {
      subscription: {
        endpoint,
        expirationTime: expirationTime === void 0 ? null : expirationTime,
        keys: {
          p256dh,
          auth
        }
      }
    };
  }
  function normalizeApplePushDeviceRequest(requestBody) {
    const deviceToken = typeof requestBody?.deviceToken === "string" ? requestBody.deviceToken.trim().toLowerCase() : "";
    const apnsEnvironment = requestBody?.apnsEnvironment;
    if (!/^[0-9a-f]+$/.test(deviceToken) || deviceToken.length < 16) {
      throw new Error("invalid_apple_push_device_token");
    }
    if (apnsEnvironment !== "development" && apnsEnvironment !== "production") {
      throw new Error("invalid_apple_push_environment");
    }
    return {
      deviceToken,
      apnsEnvironment
    };
  }
  function buildCreatorAppMutationPath(creatorUsername, appName, suffix = "") {
    const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
    if (!appName) {
      return `/creators/${encodeURIComponent(creator)}/apps${suffix}`;
    }
    const name = normalizeCreatorItemSlug(appName, "name");
    return `/creators/${encodeURIComponent(creator)}/apps/${encodeURIComponent(name)}${suffix}`;
  }
  function buildCreatorAssetMutationPath(creatorUsername, assetName, suffix = "") {
    const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
    if (!assetName) {
      return `/creators/${encodeURIComponent(creator)}/assets${suffix}`;
    }
    const name = normalizeCreatorItemSlug(assetName, "name");
    return `/creators/${encodeURIComponent(creator)}/assets/${encodeURIComponent(name)}${suffix}`;
  }
  function buildCreatorAssetPackMutationPath(creatorUsername, packName, suffix = "") {
    const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
    if (!packName) {
      return `/creators/${encodeURIComponent(creator)}/asset-packs${suffix}`;
    }
    const name = normalizeCreatorItemSlug(packName, "name");
    return `/creators/${encodeURIComponent(creator)}/asset-packs/${encodeURIComponent(name)}${suffix}`;
  }
  function parseContentDispositionFilename(headerValue) {
    if (!headerValue) {
      return null;
    }
    const utf8Match = /filename\*=UTF-8''([^;]+)/i.exec(headerValue);
    if (utf8Match && utf8Match[1]) {
      try {
        return decodeURIComponent(utf8Match[1]);
      } catch {
        return utf8Match[1];
      }
    }
    const plainMatch = /filename="?([^";]+)"?/i.exec(headerValue);
    return plainMatch?.[1] ?? null;
  }
  const request = (0, import_request.createRequestExecutor)({
    fetchImpl,
    resolveBaseUrl,
    resolveUrl: import_request.resolveUrl,
    parseResponseBody: import_request.parseResponseBody,
    resolveToken,
    getClientHeaders,
    requestTimeoutMs,
    includeBrowserCredentials
  });
  return {
    request,
    ...(0, import_auth.buildAuthApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError
    }),
    ...(0, import_free_credits.buildFreeCreditsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError
    }),
    async me() {
      const response = await request({
        method: "GET",
        path: "/me"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "me");
      }
      return response.body;
    },
    async updateProfile(updateRequest) {
      const response = await request({
        method: "PATCH",
        path: "/me",
        body: updateRequest
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "update_profile");
      }
      return response.body;
    },
    async changePassword(changeRequest) {
      const response = await request({
        method: "POST",
        path: "/me/password",
        body: changeRequest
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "change_password");
      }
      return response.body;
    },
    async exportPrivacyData() {
      const response = await request({
        method: "GET",
        path: "/me/privacy-export"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "export_privacy_data");
      }
      return response.body;
    },
    async deleteAccount(deleteRequest) {
      const response = await request({
        method: "DELETE",
        path: "/me",
        body: deleteRequest
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "delete_account");
      }
      return response.body;
    },
    async upgradeToCreator() {
      const response = await request({
        method: "POST",
        path: "/me/upgrade-to-creator"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "upgrade_to_creator");
      }
      return response.body;
    },
    async fetchUserById(userId) {
      if (!Number.isFinite(userId) || userId <= 0) {
        throw new Error("invalid_user_id");
      }
      const response = await request({
        method: "GET",
        path: `/users/${encodeURIComponent(String(userId))}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_user_by_id");
      }
      return response.body;
    },
    async fetchUserByUsername(username) {
      const trimmed = typeof username === "string" ? username.trim() : "";
      if (!trimmed) {
        throw new Error("invalid_username");
      }
      const response = await request({
        method: "GET",
        path: `/users/by-username/${encodeURIComponent(trimmed)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_user_by_username");
      }
      return response.body;
    },
    async fetchOwnedProfileAssets() {
      const response = await request({
        method: "GET",
        path: "/me/profile-assets"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_owned_profile_assets");
      }
      return response.body;
    },
    async saveItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "PUT",
        path: `/me/saved-items/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "save_item");
      }
      return response.body;
    },
    async unsaveItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "DELETE",
        path: `/me/saved-items/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "unsave_item");
      }
      return response.body;
    },
    async likeItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "PUT",
        path: `/me/likes/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "like_item");
      }
      return response.body;
    },
    async unlikeItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "DELETE",
        path: `/me/likes/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "unlike_item");
      }
      return response.body;
    },
    async dislikeItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "PUT",
        path: `/me/dislikes/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "dislike_item");
      }
      return response.body;
    },
    async undislikeItem(kind, creatorUsername, itemName) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "DELETE",
        path: `/me/dislikes/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "undislike_item");
      }
      return response.body;
    },
    async reportContent(kind, creatorUsername, itemName, requestBody) {
      const normalizedKind = normalizeSavedItemKindInput(kind);
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const name = normalizeCreatorItemSlug(itemName, "name");
      const response = await request({
        method: "POST",
        path: `/me/reports/content/${encodeURIComponent(normalizedKind)}/${encodeURIComponent(creator)}/${encodeURIComponent(name)}`,
        body: requestBody
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "report_content");
      }
      return response.body;
    },
    async reportCreator(creatorUsername, requestBody) {
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const response = await request({
        method: "POST",
        path: `/me/reports/creators/${encodeURIComponent(creator)}`,
        body: requestBody
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "report_creator");
      }
      return response.body;
    },
    async trackEngagementEvent(payload) {
      const eventType = normalizeEngagementEventTypeInput(payload.eventType);
      const targetKind = normalizeEngagementTargetKindInput(payload.targetKind);
      const creatorUsername = normalizeCreatorItemSlug(payload.creatorUsername, "creator");
      const itemName = payload.itemName === void 0 ? void 0 : normalizeCreatorItemSlug(payload.itemName, "name");
      const launchContext = import_types.APP_LAUNCH_CONTEXT_VALUES.includes(payload.launchContext) ? payload.launchContext : void 0;
      const response = await request({
        method: "POST",
        path: "/engagement-events",
        body: {
          eventType,
          targetKind,
          creatorUsername,
          ...itemName !== void 0 ? { itemName } : {},
          ...launchContext ? { launchContext } : {}
        }
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "track_engagement_event");
      }
      return response.body;
    },
    async fetchLibrary(options = {}) {
      const params = new URLSearchParams();
      if (options.category) {
        params.set("category", normalizeLibraryCategoryInput(options.category));
      }
      if (options.sort) {
        params.set("sort", normalizeLibrarySortInput(options.sort));
      }
      const query = params.toString();
      const response = await request({
        method: "GET",
        path: `/me/library${query ? `?${query}` : ""}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_library");
      }
      return response.body;
    },
    async followCreator(creatorUsername) {
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const response = await request({
        method: "PUT",
        path: `/me/following/${encodeURIComponent(creator)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "follow_creator");
      }
      return response.body;
    },
    async unfollowCreator(creatorUsername) {
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const response = await request({
        method: "DELETE",
        path: `/me/following/${encodeURIComponent(creator)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "unfollow_creator");
      }
      return response.body;
    },
    async blockCreator(creatorUsername) {
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const response = await request({
        method: "PUT",
        path: `/me/blocked-creators/${encodeURIComponent(creator)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "block_creator");
      }
      return response.body;
    },
    async unblockCreator(creatorUsername) {
      const creator = normalizeCreatorItemSlug(creatorUsername, "creator");
      const response = await request({
        method: "DELETE",
        path: `/me/blocked-creators/${encodeURIComponent(creator)}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "unblock_creator");
      }
      return response.body;
    },
    async fetchFollowingCreators(options = {}) {
      const params = new URLSearchParams();
      if (options.sort) {
        params.set("sort", normalizeFollowingSortInput(options.sort));
      }
      const query = params.toString();
      const response = await request({
        method: "GET",
        path: `/me/following${query ? `?${query}` : ""}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_following_creators");
      }
      return response.body;
    },
    async fetchFollowingFeed(options) {
      const params = new URLSearchParams();
      params.set("section", normalizeFollowingFeedSectionInput(options.section));
      if (options.limit !== void 0) {
        params.set("limit", String(normalizePositiveIntegerInput(options.limit, "invalid_following_feed_limit")));
      }
      const response = await request({
        method: "GET",
        path: `/me/following/feed?${params.toString()}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_following_feed");
      }
      return response.body;
    },
    async fetchNotifications(options = {}) {
      const params = new URLSearchParams();
      if (options.status) {
        params.set("status", normalizeNotificationStatusInput(options.status));
      }
      if (options.limit !== void 0) {
        params.set("limit", String(normalizePositiveIntegerInput(options.limit, "invalid_notification_limit")));
      }
      if (options.offset !== void 0) {
        params.set("offset", String(normalizeNonNegativeIntegerInput(options.offset, "invalid_notification_offset")));
      }
      const query = params.toString();
      const response = await request({
        method: "GET",
        path: `/me/notifications${query ? `?${query}` : ""}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_notifications");
      }
      return response.body;
    },
    async markNotificationRead(notificationId) {
      if (!Number.isInteger(notificationId) || notificationId <= 0) {
        throw new Error("invalid_notification_id");
      }
      const response = await request({
        method: "POST",
        path: `/me/notifications/${encodeURIComponent(String(notificationId))}/read`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "mark_notification_read");
      }
      return response.body;
    },
    async markAllNotificationsRead() {
      const response = await request({
        method: "POST",
        path: "/me/notifications/read-all"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "mark_all_notifications_read");
      }
      return response.body;
    },
    async fetchWebPushConfig() {
      const response = await request({
        method: "GET",
        path: "/me/push/web/config"
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_web_push_config");
      }
      return response.body;
    },
    async fetchWebPushSubscriptionStatus(requestBody) {
      const response = await request({
        method: "POST",
        path: "/me/push/web/subscription/status",
        body: normalizeWebPushSubscriptionRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_web_push_subscription_status");
      }
      return response.body;
    },
    async upsertWebPushSubscription(requestBody) {
      const response = await request({
        method: "PUT",
        path: "/me/push/web/subscription",
        body: normalizeWebPushSubscriptionRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "upsert_web_push_subscription");
      }
      return response.body;
    },
    async deleteWebPushSubscription(requestBody) {
      const response = await request({
        method: "DELETE",
        path: "/me/push/web/subscription",
        body: normalizeWebPushSubscriptionRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "delete_web_push_subscription");
      }
      return response.body;
    },
    async fetchApplePushDeviceStatus(requestBody) {
      const response = await request({
        method: "POST",
        path: "/me/push/apple/device/status",
        body: normalizeApplePushDeviceRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_apple_push_device_status");
      }
      return response.body;
    },
    async upsertApplePushDevice(requestBody) {
      const response = await request({
        method: "PUT",
        path: "/me/push/apple/device",
        body: normalizeApplePushDeviceRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "upsert_apple_push_device");
      }
      return response.body;
    },
    async deleteApplePushDevice(requestBody) {
      const response = await request({
        method: "DELETE",
        path: "/me/push/apple/device",
        body: normalizeApplePushDeviceRequest(requestBody)
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "delete_apple_push_device");
      }
      return response.body;
    },
    ...(0, import_search.buildSearchApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      normalizeSearchModeInput,
      normalizeSearchKindInput,
      normalizeSearchAssetTypeInput,
      normalizePositiveIntegerInput
    }),
    ...(0, import_tags.buildTagsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      normalizePositiveIntegerInput
    }),
    ...(0, import_comments.buildCommentsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      normalizeSavedItemKindInput,
      normalizeCreatorItemSlug,
      normalizePositiveIntegerInput
    }),
    ...(0, import_apps.buildAppsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      fetchImpl,
      includeBrowserCredentials,
      resolveBaseUrl,
      resolveUrl: import_request.resolveUrl,
      parseResponseBody: import_request.parseResponseBody,
      resolveToken,
      getClientHeaders: () => config.clientHeaders ? config.clientHeaders() : {},
      buildCreatorAppMutationPath,
      normalizeCreatorItemSlug,
      normalizeSemverInput,
      parseContentDispositionFilename
    }),
    ...(0, import_player_meta.buildPlayerMetaApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError
    }),
    ...(0, import_assets.buildAssetsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      fetchImpl,
      includeBrowserCredentials,
      resolveBaseUrl,
      resolveUrl: import_request.resolveUrl,
      parseResponseBody: import_request.parseResponseBody,
      resolveToken,
      getClientHeaders: () => config.clientHeaders ? config.clientHeaders() : {},
      buildCreatorAssetMutationPath,
      normalizeCreatorItemSlug,
      normalizeAssetRevisionInput,
      parseContentDispositionFilename
    }),
    ...(0, import_asset_packs.buildAssetPacksApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      fetchImpl,
      includeBrowserCredentials,
      resolveBaseUrl,
      resolveUrl: import_request.resolveUrl,
      parseResponseBody: import_request.parseResponseBody,
      resolveToken,
      getClientHeaders: () => config.clientHeaders ? config.clientHeaders() : {},
      buildCreatorAssetPackMutationPath,
      normalizeCreatorItemSlug,
      normalizeSemverInput,
      parseContentDispositionFilename
    }),
    ...(0, import_me.buildMeApiClientMethods)({ request, handleApiError: import_errors.handleApiError }),
    async batchUpsertGraphRelations(body) {
      const response = await request({
        method: "POST",
        path: "/me/graph/relations:batchUpsert",
        body
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "batch_upsert_graph_relations");
      }
      return response.body;
    },
    async submitFeedback(feedbackRequest) {
      const response = await request({
        method: "POST",
        path: "/feedback",
        body: feedbackRequest
      });
      if (response.status !== 201 && response.status !== 200) {
        (0, import_errors.handleApiError)(response, "submit_feedback");
      }
      return response.body;
    },
    async listFeedback(options = {}) {
      const params = new URLSearchParams();
      if (options.limit !== void 0) {
        params.set("limit", String(options.limit));
      }
      if (options.offset !== void 0) {
        params.set("offset", String(options.offset));
      }
      if (typeof options.client === "string" && options.client.trim().length > 0) {
        params.set("client", options.client.trim());
      }
      if (typeof options.category === "string" && options.category.trim().length > 0) {
        params.set("category", options.category.trim());
      }
      if (options.userId !== void 0) {
        params.set("userId", String(options.userId));
      }
      const query = params.toString();
      const path = `/feedback${query ? `?${query}` : ""}`;
      const response = await request({
        method: "GET",
        path
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "list_feedback");
      }
      return response.body;
    },
    async fetchAdminFeedback(options = {}) {
      const params = new URLSearchParams();
      if (options.limit !== void 0) {
        params.set("limit", String(options.limit));
      }
      if (options.offset !== void 0) {
        params.set("offset", String(options.offset));
      }
      if (typeof options.client === "string" && options.client.trim().length > 0) {
        params.set("client", options.client.trim());
      }
      if (typeof options.category === "string" && options.category.trim().length > 0) {
        params.set("category", options.category.trim());
      }
      if (typeof options.status === "string" && options.status.trim().length > 0) {
        params.set("status", options.status.trim());
      }
      if (options.userId !== void 0) {
        params.set("userId", String(options.userId));
      }
      const query = params.toString();
      const path = `/admin/feedback${query ? `?${query}` : ""}`;
      const response = await request({
        method: "GET",
        path
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_admin_feedback");
      }
      return response.body;
    },
    async fetchAdminFeedbackEntry(id) {
      const response = await request({
        method: "GET",
        path: `/admin/feedback/${encodeURIComponent(String(id))}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_admin_feedback_entry");
      }
      return response.body;
    },
    async updateAdminFeedback(id, feedbackRequest) {
      const response = await request({
        method: "PATCH",
        path: `/admin/feedback/${encodeURIComponent(String(id))}`,
        body: feedbackRequest
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "update_admin_feedback");
      }
      return response.body;
    },
    async deleteAdminFeedback(id) {
      const response = await request({
        method: "DELETE",
        path: `/admin/feedback/${encodeURIComponent(String(id))}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "delete_admin_feedback");
      }
      return response.body;
    },
    async deleteFeedback(id) {
      const response = await request({
        method: "DELETE",
        path: `/feedback/${encodeURIComponent(String(id))}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "delete_feedback");
      }
      return response.body;
    },
    async setSelectedProfileAsset(profileAssetRequest) {
      const response = await request({
        method: "POST",
        path: "/me/profile-asset",
        body: profileAssetRequest
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "set_profile_asset");
      }
      return response.body;
    },
    async fetchHome(options = {}) {
      const params = new URLSearchParams();
      if (typeof options.section === "string" && options.section.trim().length > 0) {
        params.set("section", options.section.trim());
      }
      if (typeof options.limit === "number") {
        params.set("limit", String(options.limit));
      }
      if (typeof options.offset === "number") {
        params.set("offset", String(options.offset));
      }
      const query = params.toString();
      const response = await request({
        method: "GET",
        path: `/home${query ? `?${query}` : ""}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_home");
      }
      return response.body;
    },
    async fetchHomeGamesCollectionPage(collectionId, options = {}) {
      const normalizedCollectionId = collectionId.trim();
      if (!normalizedCollectionId) {
        throw new Error("invalid_home_collection_id");
      }
      const params = new URLSearchParams();
      if (typeof options.limit === "number") {
        params.set("limit", String(options.limit));
      }
      if (typeof options.offset === "number") {
        params.set("offset", String(options.offset));
      }
      if (typeof options.auth === "string" && options.auth.trim().length > 0) {
        params.set("auth", options.auth.trim());
      }
      if (typeof options.controller === "string" && options.controller.trim().length > 0) {
        params.set("controller", options.controller.trim());
      }
      if (options.controllerCompatible === true) {
        params.set("controllerCompatible", "1");
      }
      if (typeof options.surface === "string" && options.surface.trim().length > 0) {
        params.set("surface", options.surface.trim());
      }
      const query = params.toString();
      const response = await request({
        method: "GET",
        path: `/home/games/collections/${encodeURIComponent(normalizedCollectionId)}${query ? `?${query}` : ""}`
      });
      if (response.status !== 200) {
        (0, import_errors.handleApiError)(response, "fetch_home_games_collection_page");
      }
      return response.body;
    },
    ...(0, import_admin.buildAdminApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      fetchImpl,
      includeBrowserCredentials,
      resolveBaseUrl,
      resolveUrl: import_request.resolveUrl,
      parseResponseBody: import_request.parseResponseBody,
      resolveToken,
      getClientHeaders: () => config.clientHeaders ? config.clientHeaders() : {}
    }),
    ...(0, import_payments.buildPaymentsApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError,
      buildIapQuery
    }),
    ...(0, import_ai.buildAiApiClientMethods)({
      request,
      handleApiError: import_errors.handleApiError
    })
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  createApiClient
});
