{
  "version": 3,
  "sources": ["ssg:https://asset.29cm.co.kr/contents/framer/hooks/useIsNotificationRegistered.js", "ssg:https://asset.29cm.co.kr/contents/framer/components/primitives/Notification/Notification.hooks.js"],
  "sourcesContent": ["import useSWR from \"../node_modules/swr/core/dist/index.js\";\nimport { useEffect } from \"react\";\nimport \"./stores/content/content.store.js\";\nimport { isClient } from \"../utils/context.js\";\nimport \"../utils/event-properties/source.js\";\nimport \"framer\";\nconst useIsNotificationRegistered = (key) => {\n  const {\n    data: isRegistered,\n    mutate\n  } = useSWR(key, () => {\n    return isClient() ? isNotificationAlreadyRegistered(key) : false;\n  });\n  const markAsRegistered = () => {\n    if (!key) {\n      return;\n    }\n    window.localStorage.setItem(key, \"true\");\n    mutate();\n  };\n  useEffect(() => {\n    if (!key) {\n      return;\n    }\n    mutate();\n  }, [key, mutate]);\n  return {\n    isRegistered,\n    markAsRegistered\n  };\n};\nconst isNotificationAlreadyRegistered = (key) => {\n  try {\n    const value = JSON.parse(window.localStorage.getItem(key) ?? \"false\");\n    return value === true;\n  } catch (error) {\n    return false;\n  }\n};\nexport {\n  useIsNotificationRegistered\n};\n", "import { useAnalytics } from \"../../../hooks/analytics/useAnalytics.js\";\nimport { useContentStore } from \"../../../hooks/stores/content/content.store.js\";\nimport { useDialog } from \"../../../hooks/useDialog.js\";\nimport { useIsNotificationRegistered } from \"../../../hooks/useIsNotificationRegistered.js\";\nimport { useNotificationRequirements } from \"../../../hooks/useNotificationRequirements.js\";\nimport { useRequestUserAgreementBottomSheet } from \"../../../hooks/useRequestUserAgreementBottomSheet.js\";\nimport { useWithApp } from \"../../../hooks/useWithApp.js\";\nimport { useWithLogin } from \"../../../hooks/useWithLogin.js\";\nimport { isContentOrigin } from \"../../../utils/location.js\";\nconst NOTIFICATION_AGREEMENTS_API_END_POINT = \"content-detail-page\";\nconst ACCESS_FROM_APP_MESSAGE = \"\uC54C\uB9BC \uC2E0\uCCAD \uAE30\uB2A5\uC740 APP\uC5D0\uC11C\uB9CC \uC0AC\uC6A9\uD560 \uC218 \uC788\uC5B4\uC694\\nAPP\uC5D0\uC11C \uB2E4\uC2DC \uC2DC\uB3C4\uD574 \uC8FC\uC138\uC694.\";\nconst useNotification = (key, options) => {\n  const requestRequirements = useNotificationRequirements();\n  const {\n    isTargetAppVersion,\n    requestUserAgreementBottomSheet\n  } = useRequestUserAgreementBottomSheet();\n  const trackClickNotificationEvent = useTrackClickNotificationEvent(key);\n  const {\n    isRegistered,\n    markAsRegistered\n  } = useIsNotificationRegistered(key);\n  const dialog = useDialog();\n  const withLogin = useWithLogin();\n  const withApp = useWithApp({\n    content: ACCESS_FROM_APP_MESSAGE\n  });\n  const onNotificationEnabled = () => {\n    var _a;\n    markAsRegistered();\n    if (!(options == null ? void 0 : options.bypassNotificationEventTracking)) {\n      trackClickNotificationEvent();\n    }\n    (_a = options == null ? void 0 : options.onNotificationEnabled) == null ? void 0 : _a.call(options);\n  };\n  const registerNotification = withApp(withLogin(() => {\n    if (isTargetAppVersion) {\n      requestUserAgreementBottomSheet({\n        type: \"CONTENT_DETAIL_PAGE\",\n        onConfirm: onNotificationEnabled\n      });\n    } else {\n      requestRequirements({\n        apiEndpoint: NOTIFICATION_AGREEMENTS_API_END_POINT,\n        onNotificationEnabled\n      });\n    }\n  }));\n  const notifyAlreadyRegistered = () => {\n    dialog.show({\n      title: \"\uC54C\uB9BC \uC2E0\uCCAD\uC774 \uC774\uBBF8 \uB418\uC5B4 \uC788\uC5B4\uC694.\",\n      content: \"\uC78A\uC9C0 \uC54A\uB3C4\uB85D \uC54C\uB9BC\uC744 \uBCF4\uB0B4\uB4DC\uB9B4\uAC8C\uC694.\",\n      primaryButtonText: \"\uD655\uC778\"\n    });\n  };\n  return {\n    isRegistered,\n    registerNotification,\n    notifyAlreadyRegistered\n  };\n};\nconst useTrackClickNotificationEvent = (key) => {\n  const {\n    trackFirebase,\n    trackAmplitude\n  } = useAnalytics();\n  const trackClickNotificationEvent = () => {\n    if (!isContentOrigin()) {\n      return;\n    }\n    const {\n      contentId\n    } = useContentStore.getState().summary;\n    const properties = {\n      notification_key: key,\n      curr_screen: getCurrentScreen(),\n      content_no: contentId,\n      format_type: \"FRAMER\",\n      target_status: \"on\"\n    };\n    trackFirebase(\"click_notification\", properties);\n    trackAmplitude(\"click_notification\", properties);\n  };\n  return trackClickNotificationEvent;\n};\nconst getCurrentScreen = () => new URL(document.location.href).pathname.substring(1);\nexport {\n  useNotification,\n  useTrackClickNotificationEvent\n};\n"],
  "mappings": "+PAMA,IAAMA,EAA+BC,GAAQ,CAC3C,GAAM,CACJ,KAAMC,EACN,OAAAC,CACF,EAAIC,EAAOH,EAAK,IACPI,EAAS,EAAIC,EAAgCL,CAAG,EAAI,EAC5D,EACKM,EAAmB,IAAM,CACxBN,IAGLO,EAAO,aAAa,QAAQP,EAAK,MAAM,EACvCE,EAAO,EACT,EACA,OAAAM,EAAU,IAAM,CACTR,GAGLE,EAAO,CACT,EAAG,CAACF,EAAKE,CAAM,CAAC,EACT,CACL,aAAAD,EACA,iBAAAK,CACF,CACF,EACMD,EAAmCL,GAAQ,CAC/C,GAAI,CAEF,OADc,KAAK,MAAMO,EAAO,aAAa,QAAQP,CAAG,GAAK,OAAO,IACnD,EACnB,MAAgB,CACd,MAAO,EACT,CACF,EC7BA,IAAMS,EAAwC,sBACxCC,EAA0B;AAAA,qEAC1BC,EAAkB,CAACC,EAAKC,IAAY,CACxC,IAAMC,EAAsBC,EAA4B,EAClD,CACJ,mBAAAC,EACA,gCAAAC,CACF,EAAIC,EAAmC,EACjCC,EAA8BC,EAA+BR,CAAG,EAChE,CACJ,aAAAS,EACA,iBAAAC,CACF,EAAIC,EAA4BX,CAAG,EAC7BY,EAASC,EAAU,EACnBC,EAAYC,EAAa,EACzBC,EAAUC,EAAW,CACzB,QAASnB,CACX,CAAC,EACKoB,EAAwB,IAAM,CAClC,IAAIC,EACJT,EAAiB,EACgBT,GAAQ,iCACvCM,EAA4B,GAE7BY,EAAgClB,GAAQ,wBAA0B,MAAgBkB,EAAG,KAAKlB,CAAO,CACpG,EACMmB,EAAuBJ,EAAQF,EAAU,IAAM,CAC/CV,EACFC,EAAgC,CAC9B,KAAM,sBACN,UAAWa,CACb,CAAC,EAEDhB,EAAoB,CAClB,YAAaL,EACb,sBAAAqB,CACF,CAAC,CAEL,CAAC,CAAC,EAQF,MAAO,CACL,aAAAT,EACA,qBAAAW,EACA,wBAV8B,IAAM,CACpCR,EAAO,KAAK,CACV,MAAO,gFACP,QAAS,2FACT,kBAAmB,cACrB,CAAC,CACH,CAKA,CACF,EACMJ,EAAkCR,GAAQ,CAC9C,GAAM,CACJ,cAAAqB,EACA,eAAAC,CACF,EAAIC,EAAa,EAkBjB,MAjBoC,IAAM,CACxC,GAAI,CAACC,EAAgB,EACnB,OAEF,GAAM,CACJ,UAAAC,CACF,EAAIC,EAAgB,SAAS,EAAE,QACzBC,EAAa,CACjB,iBAAkB3B,EAClB,YAAa4B,EAAiB,EAC9B,WAAYH,EACZ,YAAa,SACb,cAAe,IACjB,EACAJ,EAAc,qBAAsBM,CAAU,EAC9CL,EAAe,qBAAsBK,CAAU,CACjD,CAEF,EACMC,EAAmB,IAAM,IAAI,IAAI,SAAS,SAAS,IAAI,EAAE,SAAS,UAAU,CAAC",
  "names": ["useIsNotificationRegistered", "key", "isRegistered", "mutate", "useSWR", "isClient", "isNotificationAlreadyRegistered", "markAsRegistered", "window", "ue", "NOTIFICATION_AGREEMENTS_API_END_POINT", "ACCESS_FROM_APP_MESSAGE", "useNotification", "key", "options", "requestRequirements", "useNotificationRequirements", "isTargetAppVersion", "requestUserAgreementBottomSheet", "useRequestUserAgreementBottomSheet", "trackClickNotificationEvent", "useTrackClickNotificationEvent", "isRegistered", "markAsRegistered", "useIsNotificationRegistered", "dialog", "useDialog", "withLogin", "useWithLogin", "withApp", "useWithApp", "onNotificationEnabled", "_a", "registerNotification", "trackFirebase", "trackAmplitude", "useAnalytics", "isContentOrigin", "contentId", "useContentStore", "properties", "getCurrentScreen"]
}
