{
  "version": 3,
  "sources": ["ssg:https://asset.29cm.co.kr/contents/framer/apis/best/BestApiService.js", "ssg:https://asset.29cm.co.kr/contents/framer/hooks/fetchers/useFetchRankingProducts.js"],
  "sourcesContent": ["import { APIService } from \"../APIService.js\";\nimport { throwFailError } from \"../@middlewares/throwFailError.js\";\nimport { env } from \"../../config/index.js\";\nclass BestApiService extends APIService {\n  constructor() {\n    super();\n    this.setBaseUrl(env.api.search);\n    this.setMiddleware(throwFailError);\n  }\n  async getRankedProducts(payload) {\n    return this.post(`/api/v5/best`, payload).then((data) => ({\n      products: formatBestProducts(data.data.products),\n      totalCount: data.data.totalCount\n    }));\n  }\n  async getPLPFacetGroup(payload) {\n    return this.post(`/api/v5/plp/facet-group`, payload);\n  }\n}\nconst bestApi = new BestApiService();\nconst formatBestProducts = (products) => products.map((product) => {\n  var _a;\n  return {\n    ...product,\n    frontBrand: {\n      frontBrandId: product.frontBrandNo,\n      nameKor: product.frontBrandNameKor,\n      nameEng: product.frontBrandNameEng\n    },\n    productId: product.itemNo,\n    productName: product.itemName,\n    isCoupon: product.saleInfoV2.isCoupon,\n    heartOn: true,\n    frontCategories: (_a = product.frontCategoryInfo) == null ? void 0 : _a.map((category) => ({\n      largeCategoryCode: category.categoryLargeCode,\n      largeCategoryName: category.categoryLargeName,\n      mediumCategoryCode: category.categoryMediumCode,\n      mediumCategoryName: category.categoryMediumName,\n      smallCategoryCode: category.categorySmallCode,\n      smallCategoryName: category.categorySmallName\n    }))\n  };\n});\nexport {\n  bestApi\n};\n", "import useSWRInfinite from \"../../node_modules/swr/infinite/dist/index.js\";\nimport { bestApi } from \"../../apis/best/BestApiService.js\";\nconst getKey = (payload, enabled) => (pageIndex) => {\n  if (!enabled) {\n    return null;\n  }\n  return {\n    key: {\n      ...payload,\n      pagination: {\n        ...payload.pagination,\n        page: pageIndex\n      }\n    }\n  };\n};\nconst useFetchRankingProducts = (enabled, payload) => {\n  const {\n    data,\n    isLoading,\n    error,\n    size,\n    isValidating,\n    setSize\n  } = useSWRInfinite(getKey(payload, enabled), ({\n    key\n  }) => {\n    return bestApi.getRankedProducts(key);\n  }, {\n    keepPreviousData: true,\n    revalidateFirstPage: false\n  });\n  const hasError = error !== void 0;\n  const isPending = isLoading || isValidating || hasError || !enabled;\n  return {\n    products: (data == null ? void 0 : data.flatMap((item) => item.products)) ?? [],\n    totalCount: (data == null ? void 0 : data[data.length - 1].totalCount) ?? 0,\n    isPending,\n    size,\n    setSize\n  };\n};\nexport {\n  useFetchRankingProducts\n};\n"],
  "mappings": "kIAGA,IAAMA,EAAN,cAA6BC,CAAW,CACtC,aAAc,CACZ,MAAM,EACN,KAAK,WAAWC,EAAI,IAAI,MAAM,EAC9B,KAAK,cAAcC,CAAc,CACnC,CACA,MAAM,kBAAkBC,EAAS,CAC/B,OAAO,KAAK,KAAK,eAAgBA,CAAO,EAAE,KAAMC,IAAU,CACxD,SAAUC,EAAmBD,EAAK,KAAK,QAAQ,EAC/C,WAAYA,EAAK,KAAK,UACxB,EAAE,CACJ,CACA,MAAM,iBAAiBD,EAAS,CAC9B,OAAO,KAAK,KAAK,0BAA2BA,CAAO,CACrD,CACF,EACMG,EAAU,IAAIP,EACdM,EAAsBE,GAAaA,EAAS,IAAKC,GAAY,CACjE,IAAIC,EACJ,MAAO,CACL,GAAGD,EACH,WAAY,CACV,aAAcA,EAAQ,aACtB,QAASA,EAAQ,kBACjB,QAASA,EAAQ,iBACnB,EACA,UAAWA,EAAQ,OACnB,YAAaA,EAAQ,SACrB,SAAUA,EAAQ,WAAW,SAC7B,QAAS,GACT,iBAAkBC,EAAKD,EAAQ,oBAAsB,KAAO,OAASC,EAAG,IAAKC,IAAc,CACzF,kBAAmBA,EAAS,kBAC5B,kBAAmBA,EAAS,kBAC5B,mBAAoBA,EAAS,mBAC7B,mBAAoBA,EAAS,mBAC7B,kBAAmBA,EAAS,kBAC5B,kBAAmBA,EAAS,iBAC9B,EAAE,CACJ,CACF,CAAC,ECxCD,IAAMC,EAAS,CAACC,EAASC,IAAaC,GAC/BD,EAGE,CACL,IAAK,CACH,GAAGD,EACH,WAAY,CACV,GAAGA,EAAQ,WACX,KAAME,CACR,CACF,CACF,EAVS,KAYLC,EAA0B,CAACF,EAASD,IAAY,CACpD,GAAM,CACJ,KAAAI,EACA,UAAAC,EACA,MAAAC,EACA,KAAAC,EACA,aAAAC,EACA,QAAAC,CACF,EAAIC,EAAeX,EAAOC,EAASC,CAAO,EAAG,CAAC,CAC5C,IAAAU,CACF,IACSC,EAAQ,kBAAkBD,CAAG,EACnC,CACD,iBAAkB,GAClB,oBAAqB,EACvB,CAAC,EAEKE,EAAYR,GAAaG,GADdF,IAAU,QACgC,CAACL,EAC5D,MAAO,CACL,SAAmCG,GAAK,QAASU,GAASA,EAAK,QAAQ,GAAM,CAAC,EAC9E,WAAqCV,IAAKA,EAAK,OAAS,CAAC,EAAE,YAAe,EAC1E,UAAAS,EACA,KAAAN,EACA,QAAAE,CACF,CACF",
  "names": ["BestApiService", "APIService", "env", "throwFailError", "payload", "data", "formatBestProducts", "bestApi", "products", "product", "_a", "category", "getKey", "payload", "enabled", "pageIndex", "useFetchRankingProducts", "data", "isLoading", "error", "size", "isValidating", "setSize", "useSWRInfinite", "key", "bestApi", "isPending", "item"]
}
