{"version":3,"file":"CalendarTags.utils.DOMWndWP.mjs","names":[],"sources":["https:/asset.29cm.co.kr/contents/framer/components/modules/utils/facet.js","https:/asset.29cm.co.kr/contents/framer/components/systems/curations/CouponCollection/CalendarTags/CalendarTags.utils.js"],"sourcesContent":["import { CategoryType } from \"../types.js\";\nconst CATEGORY_MIN_PRODUCT_COUNT = 12;\nconst mergeByLargeCategories = (values, excludeCategories) => {\n  const map = values.reduce(\n    (prev, curr) => {\n      const {\n        count = 0,\n        children = []\n      } = prev[curr.largeId] ?? {};\n      if (excludeCategories.largeIds.includes(curr.largeId)) {\n        return prev;\n      }\n      return {\n        ...prev,\n        [curr.largeId]: {\n          id: curr.largeId,\n          name: curr.largeName,\n          count: count + curr.count,\n          children: concatMiddleCategories(children, curr, excludeCategories.middleIds)\n        }\n      };\n    },\n    // 중복 카테고리를 솎아내기 쉽도록 카테고리 id 가 key 인 객체로 정의한다.\n    {}\n  );\n  return Object.values(map);\n};\nconst concatMiddleCategories = (categories, value, excludeMiddleCategoryIds) => {\n  if (!value.middleId || !value.middleName || excludeMiddleCategoryIds.includes(value.middleId)) {\n    return categories;\n  }\n  const has = categories.findIndex((category) => category.id === value.middleId) !== -1;\n  return has ? categories : [...categories, {\n    id: value.middleId,\n    name: value.middleName,\n    parentId: value.largeId\n  }];\n};\nconst filterByOverMinProductCount = (values) => {\n  return values.filter(({\n    count = 0\n  }) => count >= CATEGORY_MIN_PRODUCT_COUNT);\n};\nconst orderByGender = (values, matcher, gender) => {\n  const oppositeGender = getOppositeGender(gender);\n  return [...values].sort((x, y) => (\n    // 현재 성별을 우선적으로 검사하여 해당되는 카테고리를 앞으로 보낸다.\n    matcher(y, gender) - matcher(x, gender) || // 현재 성별과 반대되는 성별을 기준으로 검사하여 해당되는 카테고리를 뒤로 보낸다.\n    matcher(x, oppositeGender) - matcher(y, oppositeGender)\n  ));\n};\nconst getOppositeGender = (gender) => {\n  return gender === \"F\" ? \"M\" : \"F\";\n};\nconst isGenderCategoryMatches = (value, gender) => {\n  return Number(value.name.includes(gender === \"F\" ? \"여성\" : \"남성\"));\n};\nconst isGenderProductGroupMatches = (value, gender) => {\n  return Number(value.gender === gender);\n};\nconst reshapeCategoryFacetValues = (values, options) => {\n  const {\n    categoryType,\n    gender,\n    excludeCategories\n  } = options;\n  const categories = orderByGender(filterByOverMinProductCount(mergeByLargeCategories(values, excludeCategories)), isGenderCategoryMatches, gender);\n  switch (categoryType) {\n    case CategoryType.Large:\n      return categories;\n    case CategoryType.Middle:\n      return categories.flatMap((category) => category.children ?? []);\n  }\n};\nexport {\n  filterByOverMinProductCount,\n  isGenderCategoryMatches,\n  isGenderProductGroupMatches,\n  mergeByLargeCategories,\n  orderByGender,\n  reshapeCategoryFacetValues\n};\n","import { createKRTimeZoneDate } from \"../../../../../utils/createUTCDate.js\";\nimport { isAbove } from \"../../../../../utils/date.js\";\nimport { ko } from \"../../../../../node_modules/date-fns/locale/ko.js\";\nimport { isWithinInterval } from \"../../../../../node_modules/date-fns/isWithinInterval.js\";\nimport { formatDate as format } from \"../../../../../node_modules/date-fns/format.js\";\nconst getCurrentBrandSaleIndex = (brandSaleList) => {\n  const now = createKRTimeZoneDate();\n  const currentIndex = brandSaleList.findIndex((brandSale, index) => {\n    const nextInterval = brandSaleList[index + 1];\n    const hasNext = nextInterval !== void 0;\n    const start = new Date(brandSale.displayStartAt);\n    const end = new Date(brandSale.displayEndAt);\n    const isWithin = hasNext && isWithinInterval(now, {\n      start,\n      end\n    });\n    const isLast = !hasNext && isAbove(now, start);\n    return isWithin || isLast;\n  });\n  return currentIndex === -1 ? void 0 : currentIndex;\n};\nconst getCalendarTagName = ({\n  displayStartAt\n}) => {\n  return format(displayStartAt, \"M. d eeeee\", {\n    locale: ko\n  });\n};\nexport {\n  getCalendarTagName,\n  getCurrentBrandSaleIndex\n};\n"],"mappings":"yNAA0C,EACpC,EAA6B,GAC7B,GAA0B,EAAQ,IAAsB,CAC5D,IAAM,EAAM,EAAO,QAChB,EAAM,IAAS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