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ources":["webpack://@affine/web/../core/src/pages/open-app.css.ts","webpack://@affine/web/../core/src/pages/open-app.tsx"],"sourcesContent":["import \"../core/src/pages/open-app.css.ts.vanilla.css!=!../../../../../node_modules/@vanilla-extract/webpack-plugin/virtualFileLoader/dist/vanilla-extract-webpack-plugin-virtualFileLoader.cjs.js?{\\\"fileName\\\":\\\"../core/src/pages/open-app.css.ts.vanilla.css\\\",\\\"source\\\":\\\"LnY5MzI3dDAgewogIGhlaWdodDogMTAwdmg7CiAgd2lkdGg6IDEwMHZ3OwogIGRpc3BsYXk6IGZsZXg7CiAganVzdGlmeS1jb250ZW50OiBjZW50ZXI7CiAgYWxpZ24taXRlbXM6IGNlbnRlcjsKICBmb250LXNpemU6IHZhcigtLWFmZmluZS1mb250LWJhc2UpOwogIHBvc2l0aW9uOiByZWxhdGl2ZTsKfQoudjkzMjd0MSB7CiAgY29sb3I6IGluaGVyaXQ7Cn0KLnY5MzI3dDIgewogIHBvc2l0aW9uOiBhYnNvbHV0ZTsKICB0b3A6IDA7CiAgbGVmdDogMDsKICByaWdodDogMDsKICBkaXNwbGF5OiBmbGV4OwogIGFsaWduLWl0ZW1zOiBjZW50ZXI7CiAganVzdGlmeS1jb250ZW50OiBzcGFjZS1iZXR3ZWVuOwogIHBhZGRpbmc6IDE2cHggMTIwcHg7Cn0KLnY5MzI3dDMgewogIGRpc3BsYXk6IGZsZXg7CiAgY29sdW1uLWdhcDogNHB4Owp9Ci52OTMyN3Q0IHsKICBjb2xvcjogdmFyKC0tYWZmaW5lLXRleHQtcHJpbWFyeS1jb2xvcik7CiAgZm9udC1zaXplOiB2YXIoLS1hZmZpbmUtZm9udC1zbSk7CiAgZm9udC13ZWlnaHQ6IDUwMDsKICB0ZXh0LWRlY29yYXRpb246IG5vbmU7CiAgcGFkZGluZzogNHB4IDE4cHg7Cn0KLnY5MzI3dDUgewogIGNvbG9yOiB2YXIoLS1hZmZpbmUtbGluay1jb2xvcik7CiAgZm9udC13ZWlnaHQ6IDUwMDsKICB0ZXh0LWRlY29yYXRpb246IG5vbmU7CiAgZm9udC1zaXplOiB2YXIoLS1hZmZpbmUtZm9udC1zbSk7Cn0KLnY5MzI3dDYgewogIGRpc3BsYXk6IGZsZXg7CiAgZmxleC1kaXJlY3Rpb246IGNvbHVtbjsKICBhbGlnbi1pdGVtczogY2VudGVyOwogIG1hcmdpbi10b3A6IDQwcHg7Cn0KLnY5MzI3dDcgewogIG1hcmdpbi10b3A6IDIwcHg7CiAgbWFyZ2luLWJvdHRvbTogMTJweDsKfQ==\\\"}!../../../../../node_modules/@vanilla-extract/webpack-plugin/extracted.js\"\nexport var affineLogo = 'v9327t1';\nexport var centerContent = 'v9327t6';\nexport var prompt = 'v9327t7';\nexport var root = 'v9327t0';\nexport var topNav = 'v9327t2';\nexport var topNavLink = 'v9327t4';\nexport var topNavLinks = 'v9327t3';\nexport var tryAgainLink = 'v9327t5';","import { Button } from '@affine/component/ui/button';\nimport type { GetCurrentUserQuery } from '@affine/graphql';\nimport { fetcher, getCurrentUserQuery } from '@affine/graphql';\nimport { Trans, useI18n } from '@affine/i18n';\nimport { Logo1Icon } from '@blocksuite/icons/rc';\nimport { useCallback, useMemo } from 'react';\nimport type { LoaderFunction } from 'react-router-dom';\nimport { useLoaderData, useSearchParams } from 'react-router-dom';\nimport { z } from 'zod';\n\nimport * as styles from './open-app.css';\n\nlet lastOpened = '';\n\nconst appSchemas = z.enum([\n 'affine',\n 'affine-canary',\n 'affine-beta',\n 'affine-internal',\n 'affine-dev',\n]);\n\nconst appChannelSchema = z.enum(['stable', 'canary', 'beta', 'internal']);\n\ntype Schema = z.infer;\ntype Channel = z.infer;\n\nconst schemaToChanel = {\n affine: 'stable',\n 'affine-canary': 'canary',\n 'affine-beta': 'beta',\n 'affine-internal': 'internal',\n 'affine-dev': 'canary', // dev does not have a dedicated app. use canary as the placeholder.\n} as Record;\n\nexport const appIconMap = {\n stable: '/imgs/app-icon-stable.ico',\n canary: '/imgs/app-icon-canary.ico',\n beta: '/imgs/app-icon-beta.ico',\n internal: '/imgs/app-icon-internal.ico',\n} satisfies Record;\n\nexport const appNames = {\n stable: 'AFFiNE',\n canary: 'AFFiNE Canary',\n beta: 'AFFiNE Beta',\n internal: 'AFFiNE Internal',\n} satisfies Record;\n\ninterface OpenAppProps {\n urlToOpen?: string | null;\n channel: Channel;\n}\n\ninterface LoaderData {\n action: 'url' | 'signin-redirect';\n currentUser?: GetCurrentUserQuery['currentUser'];\n}\n\nconst OpenAppImpl = ({ urlToOpen, channel }: OpenAppProps) => {\n const t = useI18n();\n const openDownloadLink = useCallback(() => {\n const url = `https://affine.pro/download?channel=${channel}`;\n open(url, '_blank');\n }, [channel]);\n const appIcon = appIconMap[channel];\n const appName = appNames[channel];\n const [params] = useSearchParams();\n const autoOpen = useMemo(() => params.get('open') !== 'false', [params]);\n\n if (urlToOpen && lastOpened !== urlToOpen && autoOpen) {\n lastOpened = urlToOpen;\n location.href = urlToOpen;\n }\n\n if (!urlToOpen) {\n return null;\n }\n\n return (\n
\n
\n \n \n \n\n
\n \n Official Website\n \n \n AFFiNE Community\n \n \n Blog\n \n \n Contact us\n \n
\n\n \n
\n\n
\n {appName}\n\n
\n \n Open {appName} app now\n \n
\n\n \n {t['com.arms.auth.open.affine.try-again']()}\n \n
\n
\n );\n};\n\nconst OpenUrl = () => {\n const [params] = useSearchParams();\n const urlToOpen = useMemo(() => params.get('url'), [params]);\n const channel = useMemo(() => {\n const urlObj = new URL(urlToOpen || '');\n const maybeSchema = appSchemas.safeParse(urlObj.protocol.replace(':', ''));\n return schemaToChanel[maybeSchema.success ? maybeSchema.data : 'affine'];\n }, [urlToOpen]);\n\n return ;\n};\n\nconst OpenOAuthJwt = () => {\n const { currentUser } = useLoaderData() as LoaderData;\n const [params] = useSearchParams();\n const schema = useMemo(() => {\n const maybeSchema = appSchemas.safeParse(params.get('schema'));\n return maybeSchema.success ? maybeSchema.data : 'affine';\n }, [params]);\n const next = useMemo(() => params.get('next'), [params]);\n const channel = schemaToChanel[schema as Schema];\n\n if (!currentUser || !currentUser?.token?.sessionToken) {\n return null;\n }\n\n const urlToOpen = `${schema}://signin-redirect?token=${\n currentUser.token.sessionToken\n }&next=${next || ''}`;\n\n return ;\n};\n\nexport const Component = () => {\n const { action } = useLoaderData() as LoaderData;\n\n if (action === 'url') {\n return ;\n } else if (action === 'signin-redirect') {\n return ;\n }\n return null;\n};\n\nexport const loader: LoaderFunction = async args => {\n const action = args.params.action || '';\n const res = await fetcher({\n query: getCurrentUserQuery,\n }).catch(console.error);\n\n return {\n action,\n currentUser: res?.currentUser || null,\n };\n};\n"],"names":["topNavLink","lastOpened","appSchemas","z","enum","schemaToChanel","affine","appIconMap","stable","canary","beta","internal","appNames","OpenAppImpl","urlToOpen","channel","t","useI18n","openDownloadLink","useCallback","open","appIcon","appName","params","useSearchParams","autoOpen","useMemo","get","location","href","div","className","a","rel","Logo1Icon","width","height","target","styles","Button","onClick","img","src","alt","Trans","i18nKey","OpenUrl","urlObj","URL","maybeSchema","safeParse","protocol","replace","success","data","OpenOAuthJwt","currentUser","useLoaderData","schema","next","token","sessionToken","Component","action","loader","args","res","fetcher","query","getCurrentUserQuery","catch","console","error"],"sourceRoot":""}