{"version":3,"sources":["../src/client/context/JsonApiContext.ts"],"sourcesContent":["\"use client\";\n\nimport { createContext, useContext } from \"react\";\n\nexport type CacheProfile = \"seconds\" | \"minutes\" | \"hours\" | \"days\" | \"weeks\" | \"max\" | \"default\";\n\nexport interface JsonApiConfig {\n  /**\n   * The base URL for API requests (e.g., https://api.example.com)\n   */\n  apiUrl: string;\n\n  /**\n   * Custom token getter function. If not provided, will use default cookie-based token retrieval.\n   */\n  tokenGetter?: () => Promise<string | undefined>;\n\n  /**\n   * Custom language getter function. If not provided, will use browser locale or next-intl.\n   */\n  languageGetter?: () => Promise<string>;\n\n  /**\n   * Default headers to include in all requests\n   */\n  defaultHeaders?: Record<string, string>;\n\n  /**\n   * Global error handler for failed requests (client-side only)\n   */\n  onError?: (status: number, message: string) => void;\n\n  /**\n   * Cache configuration\n   */\n  cacheConfig?: {\n    defaultProfile: CacheProfile;\n  };\n\n  /**\n   * Function to bootstrap the data class registry.\n   * Will be called automatically when needed.\n   */\n  bootstrapper?: () => void;\n}\n\nconst JsonApiContext = createContext<JsonApiConfig | null>(null);\n\nexport function useJsonApiConfig(): JsonApiConfig {\n  const config = useContext(JsonApiContext);\n  if (!config) {\n    throw new Error(\"useJsonApiConfig must be used within a JsonApiProvider\");\n  }\n  return config;\n}\n\nexport function useJsonApiConfigOptional(): JsonApiConfig | null {\n  return useContext(JsonApiContext);\n}\n\nexport { JsonApiContext };\n"],"mappings":";;;;;AAEA,SAAS,eAAe,kBAAkB;AA4C1C,IAAM,iBAAiB,cAAoC,IAAI;AAExD,SAAS,mBAAkC;AAChD,QAAM,SAAS,WAAW,cAAc;AACxC,MAAI,CAAC,QAAQ;AACX,UAAM,IAAI,MAAM,wDAAwD;AAAA,EAC1E;AACA,SAAO;AACT;AANgB;AAQT,SAAS,2BAAiD;AAC/D,SAAO,WAAW,cAAc;AAClC;AAFgB;","names":[]}