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AAAA,EAAAA,EAAAA,CAAAA,IACtC,CAACC,EAAWC,EAAYC,EAA2B,CAAGhC,CAAAA,EAAAA,EAAAA,YAAAA,EAC1DC,CAAAA,EAAAA,EAAAA,CAAAA,EAAW,GAAW,CACpBC,EAAM4B,SAAS,CACf5B,EAAM6B,UAAU,CAChB7B,EAAM8B,0BAA0B,CACjC,GAGG,CAAEC,QAAAA,CAAO,CAAE,CAAGC,CAAAA,EAAAA,EAAAA,MAAAA,EAAO,CACzBzB,OAAQ,MAAO0B,IACb,GAAM,CAAEf,SAAAA,CAAQ,CAAEgB,QAAAA,CAAO,CAAEC,aAAAA,CAAY,CAAE,CAAGF,MAAAA,EAAAA,EAAW,CAAC,EA0BxD,GAxBI,CAACC,IACHJ,EAA2B,IAEvBM,EAAAA,EAAWA,CAACC,KAAK,EACnB,MAAMC,EAAAA,EAAQA,CAAC/B,MAAM,IAIzBgC,eAAeC,UAAU,CAACC,EAAAA,EAAWA,CAACC,qBAAqB,EAC3DH,eAAeC,UAAU,CAACC,EAAAA,EAAWA,CAACE,aAAa,EACnDJ,eAAeC,UAAU,CAACC,EAAAA,EAAWA,CAACG,kBAAkB,EAEpDT,GACFI,eAAeM,OAAO,CACpBJ,EAAAA,EAAWA,CAACK,YAAY,CACxBC,KAAKC,SAAS,CAACb,IAInBV,EAAe,MACfC,EAAgB,MAChBE,EAAU,MACVC,EAAW,IAEPK,CAAAA,GAAWe,CAAAA,EAAAA,EAAAA,EAAAA,MAAmBC,EAAAA,EAAUA,CAACC,MAAM,QAEnD,EACStC,SAASM,OAAO,CAACD,GAGnBL,SAASuC,MAAM,EACxB,CACF,GAEA,OAAOrB,CACT","sources":["webpack://_N_E/?fbd7","webpack://_N_E/./src/app/(guest)/template.tsx","webpack://_N_E/./src/hooks/useLogout.ts"],"sourcesContent":["import(/* webpackMode: \"eager\" */ \"/codebuild/output/src3951433904/src/wello-client/packages/wello/src/app/(guest)/template.tsx\");\n","'use client';\n\nimport { usePathname, useSearchParams } from 'next/navigation';\nimport { useLayoutEffect } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\n\nimport { LoadingPageTemplate } from '@/components/client';\nimport { ROUTES } from '@/constants';\nimport { useCustomRouter } from '@/hooks/useCustomRouter';\nimport { useLogout } from '@/hooks/useLogout';\nimport { useAuthStore } from '@/stores/AuthStore';\n\ninterface GuestAccessControllerProps {\n children: React.ReactNode;\n}\n\nconst GuestAccessController = ({ children }: GuestAccessControllerProps) => {\n const [isLogin, isDisabledAccessControl] = useAuthStore(\n useShallow((state) => [state.isLogin, state.isDisabledAccessControl]),\n );\n\n const router = useCustomRouter();\n\n const pathname = usePathname();\n const searchParams = useSearchParams();\n\n const { logout } = useLogout();\n\n useLayoutEffect(() => {\n if (isDisabledAccessControl) return;\n\n if (!searchParams || !pathname) return;\n\n if (searchParams.get('logout') === 'true') {\n const url = new URL(location.href);\n\n url.searchParams.delete('logout');\n\n console.info('logout by logout LoginPageTemplate');\n\n logout({ redirect: url.href });\n\n return;\n }\n\n if (isLogin) {\n console.info('redirected by guest access controller');\n router.replace(ROUTES.HOME.pathname);\n\n return;\n }\n }, [\n isDisabledAccessControl,\n isLogin,\n logout,\n pathname,\n router,\n searchParams,\n ]);\n\n return isDisabledAccessControl || isLogin === false ? (\n children\n ) : (\n \n );\n};\n\nexport default GuestAccessController;\n","import type { ToastOptions } from '@common/hooks';\nimport { getSubDomain } from '@common/utils';\nimport { useRef } from 'react';\nimport { useShallow } from 'zustand/react/shallow';\n\nimport { AUTH_API, AuthOpenApi } from '@/api';\nimport { STORAGE_KEY } from '@/constants';\nimport { useAuthStore } from '@/stores/AuthStore';\nimport { SUB_DOMAIN } from '@/stores/DeviceStore';\n\nimport { useAccessToken } from './useAccessToken';\n\ninterface LogoutOptions {\n redirect?: string;\n forInit?: boolean;\n toastOptions?: ToastOptions;\n}\n\nexport const useLogout = () => {\n const { setAccessToken, setRefreshToken } = useAccessToken();\n const [setMyInfo, setIsLogin, setIsDisabledAccessControl] = useAuthStore(\n useShallow((state) => [\n state.setMyInfo,\n state.setIsLogin,\n state.setIsDisabledAccessControl,\n ]),\n );\n\n const { current } = useRef({\n logout: async (options?: LogoutOptions) => {\n const { redirect, forInit, toastOptions } = options ?? {};\n\n if (!forInit) {\n setIsDisabledAccessControl(true);\n\n if (AuthOpenApi.TOKEN) {\n await AUTH_API.logout();\n }\n }\n\n sessionStorage.removeItem(STORAGE_KEY.POLICY_FILTER_LANDING);\n sessionStorage.removeItem(STORAGE_KEY.POLICY_FILTER);\n sessionStorage.removeItem(STORAGE_KEY.EASY_CERTIFICATION);\n\n if (toastOptions) {\n sessionStorage.setItem(\n STORAGE_KEY.LOGOUT_TOAST,\n JSON.stringify(toastOptions),\n );\n }\n\n setAccessToken(null);\n setRefreshToken(null);\n setMyInfo(null);\n setIsLogin(false);\n\n if (forInit || getSubDomain() === SUB_DOMAIN.KB_PAY) return;\n\n if (redirect) {\n return location.replace(redirect);\n }\n\n return location.reload();\n },\n });\n\n return current;\n};\n"],"names":["Promise","resolve","then","__webpack_require__","bind","__webpack_exports__","children","param","isLogin","isDisabledAccessControl","useAuthStore","useShallow","state","router","useCustomRouter","pathname","usePathname","searchParams","useSearchParams","logout","useLogout","useLayoutEffect","get","url","URL","location","href","delete","console","info","redirect","replace","ROUTES","HOME","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__","jsx","LoadingPageTemplate","setAccessToken","setRefreshToken","useAccessToken","setMyInfo","setIsLogin","setIsDisabledAccessControl","current","useRef","options","forInit","toastOptions","AuthOpenApi","TOKEN","AUTH_API","sessionStorage","removeItem","STORAGE_KEY","POLICY_FILTER_LANDING","POLICY_FILTER","EASY_CERTIFICATION","setItem","LOGOUT_TOAST","JSON","stringify","getSubDomain","SUB_DOMAIN","KB_PAY","reload"],"sourceRoot":""}