{"version":3,"file":"deep-equal-BvQBG8wE.cjs","names":[],"sources":["../src/utils/fetchWithRetry.ts","../src/utils/deep-equal.ts"],"sourcesContent":["export interface FetchWithRetryOptions {\n  shouldRetryResponse?: (response: Response) => boolean;\n}\n\nconst defaultShouldRetryResponse = () => true;\n\n/**\n * Performs a fetch request with automatic retries using exponential backoff.\n * Network failures are always retried. Non-OK responses are retried unless\n * `shouldRetryResponse` returns false.\n */\nexport async function fetchWithRetry(\n  url: string,\n  options: RequestInit = {},\n  maxRetries: number = 3,\n  retryOptions: FetchWithRetryOptions = {},\n): Promise<Response> {\n  let retryCount = 0;\n  let lastError: Error | null = null;\n  const shouldRetryResponse = retryOptions.shouldRetryResponse ?? defaultShouldRetryResponse;\n\n  while (retryCount < maxRetries) {\n    let response: Response | undefined;\n\n    try {\n      response = await fetch(url, options);\n    } catch (error) {\n      lastError = error instanceof Error ? error : new Error(String(error));\n    }\n\n    if (response) {\n      if (!response.ok) {\n        lastError = new Error(`Request failed with status: ${response.status} ${response.statusText}`);\n\n        if (!shouldRetryResponse(response)) {\n          throw lastError;\n        }\n      } else {\n        return response;\n      }\n    }\n\n    retryCount++;\n\n    if (retryCount >= maxRetries) {\n      break;\n    }\n\n    const delay = Math.min(1000 * Math.pow(2, retryCount), 10000);\n    await new Promise(resolve => setTimeout(resolve, delay));\n  }\n\n  throw lastError || new Error('Request failed after multiple retry attempts');\n}\n","/**\n * Deep equality comparison for comparing two values.\n * Handles primitives, arrays, objects, and Date instances.\n */\nexport function deepEqual(a: unknown, b: unknown): boolean {\n  // Handle identical references and primitives\n  if (a === b) return true;\n\n  // Handle null/undefined\n  if (a == null || b == null) return a === b;\n\n  // Handle different types\n  if (typeof a !== typeof b) return false;\n\n  // Handle arrays\n  if (Array.isArray(a) && Array.isArray(b)) {\n    if (a.length !== b.length) return false;\n    return a.every((item, index) => deepEqual(item, b[index]));\n  }\n\n  // Handle dates (must check before generic objects since Date is also an object)\n  if (a instanceof Date && b instanceof Date) {\n    return a.getTime() === b.getTime();\n  }\n\n  // Handle objects (after Date check to avoid treating Dates as plain objects)\n  if (typeof a === 'object' && typeof b === 'object') {\n    const aObj = a as Record<string, unknown>;\n    const bObj = b as Record<string, unknown>;\n    const aKeys = Object.keys(aObj);\n    const bKeys = Object.keys(bObj);\n\n    if (aKeys.length !== bKeys.length) return false;\n\n    // Verify that bObj has the same keys as aObj before comparing values\n    return aKeys.every(key => Object.prototype.hasOwnProperty.call(bObj, key) && deepEqual(aObj[key], bObj[key]));\n  }\n\n  return false;\n}\n"],"mappings":";AAIA,MAAM,mCAAmC;;;;;;AAOzC,eAAsB,eACpB,KACA,UAAuB,CAAC,GACxB,aAAqB,GACrB,eAAsC,CAAC,GACpB;CACnB,IAAI,aAAa;CACjB,IAAI,YAA0B;CAC9B,MAAM,sBAAsB,aAAa,uBAAuB;CAEhE,OAAO,aAAa,YAAY;EAC9B,IAAI;EAEJ,IAAI;GACF,WAAW,MAAM,MAAM,KAAK,OAAO;EACrC,SAAS,OAAO;GACd,YAAY,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;EACtE;EAEA,IAAI,UACF,IAAI,CAAC,SAAS,IAAI;GAChB,4BAAY,IAAI,MAAM,+BAA+B,SAAS,OAAO,GAAG,SAAS,YAAY;GAE7F,IAAI,CAAC,oBAAoB,QAAQ,GAC/B,MAAM;EAEV,OACE,OAAO;EAIX;EAEA,IAAI,cAAc,YAChB;EAGF,MAAM,QAAQ,KAAK,IAAI,MAAO,KAAK,IAAI,GAAG,UAAU,GAAG,GAAK;EAC5D,MAAM,IAAI,SAAQ,YAAW,WAAW,SAAS,KAAK,CAAC;CACzD;CAEA,MAAM,6BAAa,IAAI,MAAM,8CAA8C;AAC7E;;;;;;;ACjDA,SAAgB,UAAU,GAAY,GAAqB;CAEzD,IAAI,MAAM,GAAG,OAAO;CAGpB,IAAI,KAAK,QAAQ,KAAK,MAAM,OAAO,MAAM;CAGzC,IAAI,OAAO,MAAM,OAAO,GAA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