{"version":3,"file":"EventTrigger.CZ528Wd7.mjs","names":["forwardRef","useRef","useCallback","createContext","forwardRef","useRef","useContext","forwardRef"],"sources":["https:/asset.29cm.co.kr/contents/framer/components/@shared/TextButton/TextButton.js","https:/asset.29cm.co.kr/contents/framer/hooks/useInViewport.js","https:/asset.29cm.co.kr/contents/framer/components/@shared/EventTrigger/Root.js","https:/asset.29cm.co.kr/contents/framer/components/@shared/EventTrigger/Root.hooks.js","https:/asset.29cm.co.kr/contents/framer/components/@shared/EventTrigger/Target.js","https:/asset.29cm.co.kr/contents/framer/components/@shared/EventTrigger/index.js"],"sourcesContent":["import { jsxs, jsx } from \"react/jsx-runtime\";\nimport { forwardRef } from \"react\";\nimport { Icon } from \"../Icon/Icon.js\";\nimport { typography } from \"../../../styles/typography.js\";\nconst TextButton = ({\n  children,\n  style,\n  as,\n  theme = \"light\",\n  size = \"medium\",\n  prefixIcon,\n  postfixIcon,\n  variant,\n  backgroundColor,\n  color,\n  isUnderlined = false,\n  ...rest\n}, ref) => {\n  const Component = as ?? \"button\";\n  const variantStyle = textButtonStyleByVariant[rest.disabled ? \"disabled\" : variant];\n  const textButtonStyle = {\n    ...style,\n    ...baseTextButtonStyle,\n    ...textButtonStyleBySize[size],\n    ...variantStyle[theme],\n    ...isUnderlined && {\n      textDecoration: \"underline\"\n    }\n  };\n  const reshapedProps = {\n    ...rest,\n    href: rest.disabled ? void 0 : rest.href,\n    onClick: rest.disabled ? void 0 : rest.onClick\n  };\n  return /* @__PURE__ */ jsxs(Component, { ref, ...reshapedProps, style: textButtonStyle, children: [\n    prefixIcon ? /* @__PURE__ */ jsx(Icon, { type: getIconType(prefixIcon), fill: getIconFill(prefixIcon), size: iconSizeByButtonSize[size], color: textButtonStyle.color, weight: \"bold\" }) : null,\n    /* @__PURE__ */ jsx(\"div\", { style: contentStyle, children }),\n    postfixIcon ? /* @__PURE__ */ jsx(Icon, { type: getIconType(postfixIcon), fill: getIconFill(postfixIcon), size: iconSizeByButtonSize[size], color: textButtonStyle.color, weight: \"bold\" }) : null\n  ] });\n};\nconst getIconType = (icon) => typeof icon === \"string\" ? icon : icon.type;\nconst getIconFill = (icon) => typeof icon === \"string\" ? void 0 : icon.fill;\nconst baseTextButtonStyle = {\n  minWidth: \"fit-content\",\n  height: \"auto\",\n  display: \"flex\",\n  alignItems: \"center\",\n  justifyContent: \"center\",\n  cursor: \"pointer\",\n  // reset button element css\n  backgroundColor: \"transparent\",\n  textDecoration: \"none\",\n  padding: 0,\n  outline: \"none\",\n  border: \"none\",\n  boxSizing: \"border-box\"\n};\nconst textButtonStyleBySize = {\n  large: {\n    gap: \"4px\",\n    ...typography(18, 600, 1.2)\n  },\n  medium: {\n    gap: \"4px\",\n    ...typography(16, 600, 1.2)\n  },\n  small: {\n    gap: \"2px\",\n    ...typography(14, 600, 1.2)\n  },\n  xSmall: {\n    gap: \"2px\",\n    ...typography(12, 700, 1.36)\n  }\n};\nconst textButtonStyleByVariant = {\n  primary: {\n    light: {\n      color: \"#000\"\n    },\n    dark: {\n      color: \"#fff\"\n    }\n  },\n  secondary: {\n    light: {\n      color: \"#474747\"\n    },\n    dark: {\n      color: \"#a0a0a0\"\n    }\n  },\n  tertiary: {\n    light: {\n      color: \"#a0a0a0\"\n    },\n    dark: {\n      color: \"#474747\"\n    }\n  },\n  disabled: {\n    light: {\n      color: \"#c4c4c4\",\n      cursor: \"not-allowed\"\n    },\n    dark: {\n      color: \"#303033\",\n      cursor: \"not-allowed\"\n    }\n  }\n};\nconst iconSizeByButtonSize = {\n  large: 20,\n  medium: 18,\n  small: 16,\n  xSmall: 12\n};\nconst contentStyle = {\n  display: \"flex\",\n  alignItems: \"center\"\n};\nconst Default = forwardRef(TextButton);\nexport {\n  Default as TextButton\n};\n","import { useRef, useCallback } from \"react\";\nimport { useUpdatedRef } from \"./useUpdatedRef.js\";\nimport { useWindowEventListener } from \"./useWindowEventListener.js\";\nconst useInViewport = (callback) => {\n  const ref = useRef(null);\n  const prevIsInViewport = useRef(false);\n  const updatedCallback = useUpdatedRef(callback);\n  const handleScroll = useCallback(() => {\n    if (ref.current === null) {\n      return;\n    }\n    const isInViewport = getIsInViewport(ref.current);\n    if (isInViewport !== prevIsInViewport.current) {\n      updatedCallback.current(isInViewport);\n    }\n    prevIsInViewport.current = isInViewport;\n  }, []);\n  useWindowEventListener(\"scroll\", handleScroll);\n  return ref;\n};\nconst getIsInViewport = (element) => {\n  const {\n    offsetHeight\n  } = element;\n  const top = getAbsoluteOffsetTop(element);\n  const bottom = top + offsetHeight;\n  const isElementInViewport = window.scrollY <= top && bottom <= window.scrollY + window.innerHeight;\n  const isViewportInElement = top <= window.scrollY && window.scrollY + window.innerHeight <= bottom;\n  return isViewportInElement || isElementInViewport;\n};\nconst getAbsoluteOffsetTop = (element) => {\n  return Math.round(element.getBoundingClientRect().top + window.scrollY);\n};\nexport {\n  useInViewport\n};\n","import { jsx } from \"react/jsx-runtime\";\nimport { createContext, forwardRef, useRef } from \"react\";\nimport { useInViewport } from \"../../../hooks/useInViewport.js\";\nimport \"../../../hooks/stores/content/content.store.js\";\nimport \"../../../utils/event-properties/source.js\";\nimport \"framer\";\nimport { mergeRefs } from \"../../../utils/react/mergeRefs.js\";\nconst EventTriggerContext = createContext({\n  isViewportEntered: () => false,\n  canTriggerFallbackImpression: () => false,\n  setCanTriggerFallbackImpression: () => {\n  },\n  types: [],\n  onImpression: void 0\n});\nconst Root = forwardRef(({\n  children,\n  className,\n  style,\n  types,\n  onImpression\n}, ref) => {\n  const isViewportEntered = useRef(false);\n  const canTriggerFallbackImpression = useRef(true);\n  const observeViewport = types.includes(\"impression\");\n  const handleViewportEnter = () => {\n    if (canTriggerFallbackImpression.current) {\n      onImpression == null ? void 0 : onImpression();\n    }\n    isViewportEntered.current = true;\n    canTriggerFallbackImpression.current = false;\n  };\n  const handleViewportLeave = () => {\n    isViewportEntered.current = false;\n    canTriggerFallbackImpression.current = true;\n  };\n  const containerRef = useInViewport((isInViewport) => {\n    if (!observeViewport) {\n      return;\n    }\n    if (isInViewport) {\n      handleViewportEnter();\n    } else {\n      handleViewportLeave();\n    }\n  });\n  return /* @__PURE__ */ jsx(EventTriggerContext.Provider, { value: {\n    isViewportEntered: () => isViewportEntered.current,\n    canTriggerFallbackImpression: () => canTriggerFallbackImpression.current,\n    setCanTriggerFallbackImpression: (next) => canTriggerFallbackImpression.current = next,\n    types,\n    onImpression\n  }, children: /* @__PURE__ */ jsx(\"div\", { ref: mergeRefs([containerRef, ref]), className, style: {\n    width: \"100%\",\n    ...style\n  }, children }) });\n});\nexport {\n  EventTriggerContext,\n  Root\n};\n","import { useContext } from \"react\";\nimport { EventTriggerContext } from \"./Root.js\";\nconst useEventTriggerContext = () => useContext(EventTriggerContext);\nexport {\n  useEventTriggerContext\n};\n","import { jsx } from \"react/jsx-runtime\";\nimport { forwardRef } from \"react\";\nimport { useEventTriggerContext } from \"./Root.hooks.js\";\nconst Target = forwardRef(({\n  children,\n  onClick,\n  ...rest\n}, ref) => {\n  const {\n    isViewportEntered,\n    canTriggerFallbackImpression,\n    setCanTriggerFallbackImpression,\n    types,\n    onImpression\n  } = useEventTriggerContext();\n  const handleClick = (e) => {\n    onClick == null ? void 0 : onClick(e);\n    const shouldTriggerFallbackImpression = types.includes(\"impression\") && !isViewportEntered() && canTriggerFallbackImpression();\n    if (shouldTriggerFallbackImpression) {\n      onImpression == null ? void 0 : onImpression();\n      setCanTriggerFallbackImpression(false);\n    }\n  };\n  return /* @__PURE__ */ jsx(\"div\", { ref, ...rest, onClick: handleClick, children });\n});\nexport {\n  Target\n};\n","import { Root } from \"./Root.js\";\nimport { Target } from \"./Target.js\";\nconst EventTrigger = {\n  Root,\n  Target\n};\nexport {\n  EventTrigger\n};\n"],"mappings":"mXAA8C,IACX,IACI,IACoB,CACrD,GAAc,CAClB,WACA,QACA,KACA,QAAQ,QACR,OAAO,SACP,aACA,cACA,UACA,kBACA,QACA,eAAe,GACf,GAAG,GACF,IAAQ,CACT,IAAM,EAAY,GAAM,SAClB,EAA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