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EAAU,KACR,IAAMT,EAAQO,EAAaG,GAAG,CAAC,QAC3BV,IACFW,aAAaC,OAAO,CAACtC,EAAiB0B,GACtCO,EAAaM,MAAM,CAAC,QAExB,EAAG,CAACN,EAAa,CACnB,EAKaO,EAA8B,KACzC,IAAMC,EAAgB9D,CAAAA,EAAAA,EAAAA,CAAAA,IAEhB+D,EAAgB1D,CAAAA,EAAAA,EAAAA,WAAAA,EAAY,KAChC,IAAM0C,EAAQW,aAAaM,OAAO,CAAC3C,GACnC,GAAK0B,EAEL,GAAI,CACF,GAAM,CAAEnB,KAAAA,CAAI,CAAEM,UAAAA,CAAS,CAAES,QAAAA,CAAO,CAAE,CAAGM,EAA8BF,GAC7D/B,EAAOwB,EAA4B,CACvC/B,GAAIkC,EAAQlC,EAAE,CACd6B,MAAOK,EAAQL,KAAK,CACpBC,KAAMI,EAAQpB,IAAI,EAAEgB,MAAQ,GAC5BX,KAAAA,EACAM,UAAAA,CACF,GACA4B,EAAc9C,GACd0C,aAAaO,UAAU,CAAC5C,GAExB6C,EAAAA,EAAKA,CAACC,CAAC,CAACC,aAAa,CAAC3C,KAAK,CAAC4C,SAAS,CAAC,CACpCzC,KAAAA,EACAM,UAAAA,CACF,EACF,CAAE,MAAOoC,EAAK,CACZC,QAAQC,KAAK,CAAC,6CAA8CF,EAC9D,CACF,EAAG,CAACR,EAAc,EAElBN,CAAAA,EAAAA,EAAAA,SAAAA,EAAU,KACRO,IACAU,OAAOC,gBAAgB,CAAC,QAASX,GAC1B,KACLU,OAAOE,mBAAmB,CAAC,QAASZ,EACtC,GACC,CAACA,EAAc,CACpB,C","sources":["webpack://@affine/web/../core/src/components/affine/subscription-landing/notify.css.ts","webpack://@affine/web/../core/src/components/affine/subscription-landing/notify.tsx","webpack://@affine/web/../core/src/hooks/affine/use-subscription-notify.tsx"],"sourcesContent":["import \"../core/src/components/affine/subscription-landing/notify.css.ts.vanilla.css!=!../../../../../../../node_modules/@vanilla-extract/webpack-plugin/virtualFileLoader/dist/vanilla-extract-webpack-plugin-virtualFileLoader.cjs.js?{\\\"fileName\\\":\\\"../core/src/components/affine/subscription-landing/notify.css.ts.vanilla.css\\\",\\\"source\\\":\\\"LnQ1bmtiZzAgewogIGZvbnQtd2VpZ2h0OiA1MDA7CiAgZm9udC1zaXplOiAxNXB4Owp9Ci50NW5rYmcxIHsKICBkaXNwbGF5OiBmbGV4OwogIGp1c3RpZnktY29udGVudDogZW5kOwogIGdhcDogMTJweDsKICBwYWRkaW5nLXRvcDogOHB4Owp9Ci50NW5rYmcyIHsKICBmb250LXNpemU6IHZhcigtLWFmZmluZS1mb250LXNtKTsKICBmb250LXdlaWdodDogNTAwOwogIGxpbmUtaGVpZ2h0OiAyMnB4Owp9Ci50NW5rYmczLnBsYWluIHsKICBjb2xvcjogdmFyKC0tYWZmaW5lLWJyYW5kLWNvbG9yKTsKfQoudDVua2JnNC5wbGFpbiB7CiAgY29sb3I6IHZhcigtLWFmZmluZS10ZXh0LXByaW1hcnktY29sb3IpOwp9\\\"}!../../../../../../../node_modules/@vanilla-extract/webpack-plugin/extracted.js\"\nexport var actionButton = 't5nkbg2';\nexport var cancelButton = 't5nkbg4';\nexport var confirmButton = 't5nkbg3';\nexport var notifyFooter = 't5nkbg1';\nexport var notifyHeader = 't5nkbg0';","import { Button, notify } from '@affine/component';\nimport { useI18n } from '@affine/i18n';\nimport clsx from 'clsx';\nimport { useCallback, useRef } from 'react';\n\nimport {\n actionButton,\n cancelButton,\n confirmButton,\n notifyFooter,\n notifyHeader,\n} from './notify.css';\n\ninterface SubscriptionChangedNotifyFooterProps {\n onCancel: () => void;\n onConfirm?: () => void;\n to: string;\n okText: string;\n cancelText: string;\n}\n\nconst SubscriptionChangedNotifyFooter = ({\n to,\n okText,\n cancelText,\n onCancel,\n onConfirm,\n}: SubscriptionChangedNotifyFooterProps) => {\n return (\n
\n \n {cancelText}\n \n \n \n {okText}\n \n \n
\n );\n};\n\nconst isDesktop = environment.isDesktop;\nexport const useUpgradeNotify = () => {\n const t = useI18n();\n const prevNotifyIdRef = useRef(null);\n\n return useCallback(\n (link: string) => {\n prevNotifyIdRef.current && notify.dismiss(prevNotifyIdRef.current);\n const id = notify(\n {\n title: (\n \n {t['com.arms.payment.upgrade-success-notify.title']()}\n \n ),\n message: t['com.arms.payment.upgrade-success-notify.content'](),\n alignMessage: 'title',\n icon: null,\n footer: (\n notify.dismiss(id)}\n onConfirm={() => notify.dismiss(id)}\n />\n ),\n },\n { duration: 24 * 60 * 60 * 1000 }\n );\n prevNotifyIdRef.current = id;\n },\n [t]\n );\n};\n\nexport const useDowngradeNotify = () => {\n const t = useI18n();\n const prevNotifyIdRef = useRef(null);\n\n return useCallback(\n (link: string) => {\n prevNotifyIdRef.current && notify.dismiss(prevNotifyIdRef.current);\n const id = notify(\n {\n title: (\n \n {t['com.arms.payment.downgraded-notify.title']()}\n \n ),\n message: t['com.arms.payment.downgraded-notify.content'](),\n alignMessage: 'title',\n icon: null,\n footer: (\n notify.dismiss(id)}\n onConfirm={() => notify.dismiss(id)}\n />\n ),\n },\n { duration: 24 * 60 * 60 * 1000 }\n );\n prevNotifyIdRef.current = id;\n },\n [t]\n );\n};\n","import { useUpgradeNotify } from '@affine/core/components/affine/subscription-landing/notify';\nimport { track } from '@affine/core/mixpanel';\nimport { SubscriptionPlan, SubscriptionRecurring } from '@affine/graphql';\nimport { nanoid } from 'nanoid';\nimport { useCallback, useEffect } from 'react';\nimport { useSearchParams } from 'react-router-dom';\n\nimport { type AuthAccountInfo } from '../../modules/cloud';\n\nconst separator = '::';\nconst recoverSeparator = nanoid();\nconst localStorageKey = 'subscription-succeed-info';\n\nconst typeFormUrl = 'https://6dxre9ihosp.typeform.com/to';\nconst typeFormUpgradeId = 'mUMGGQS8';\nconst typeFormDowngradeId = 'RvD9AoRg';\n\ntype TypeFormInfo = {\n id: string;\n name?: string;\n email?: string;\n plan: string | string[];\n recurring: string;\n};\nconst getTypeFormLink = (id: string, info: TypeFormInfo) => {\n const plans = Array.isArray(info.plan) ? info.plan : [info.plan];\n const product_id = plans\n .map(plan => (plan === SubscriptionPlan.AI ? 'ai' : 'cloud'))\n .join('-');\n const product_price =\n info.recurring === SubscriptionRecurring.Monthly\n ? 'monthly'\n : info.recurring === SubscriptionRecurring.Lifetime\n ? 'lifeTime'\n : 'annually';\n return `${typeFormUrl}/${id}#email=${info.email ?? ''}&name=${info.name ?? 'Unknown'}&user_id=${info.id}&product_id=${product_id}&product_price=${product_price}`;\n};\nexport const getUpgradeQuestionnaireLink = (info: TypeFormInfo) =>\n getTypeFormLink(typeFormUpgradeId, info);\nexport const getDowngradeQuestionnaireLink = (info: TypeFormInfo) =>\n getTypeFormLink(typeFormDowngradeId, info);\n\n/**\n * Generate subscription callback link with account info\n */\nexport const generateSubscriptionCallbackLink = (\n account: AuthAccountInfo | null,\n plan: SubscriptionPlan,\n recurring: SubscriptionRecurring\n) => {\n if (account === null) {\n throw new Error('Account is required');\n }\n const baseUrl =\n plan === SubscriptionPlan.AI ? '/ai-upgrade-success' : '/upgrade-success';\n\n let name = account?.info?.name ?? '';\n if (name.includes(separator)) {\n name = name.replaceAll(separator, recoverSeparator);\n }\n\n const query = [\n plan,\n recurring,\n account.id,\n account.email,\n account.info?.name ?? '',\n ].join(separator);\n\n return `${baseUrl}?info=${encodeURIComponent(query)}`;\n};\n\n/**\n * Parse subscription callback query.info\n * @returns\n */\nexport const parseSubscriptionCallbackLink = (query: string) => {\n const [plan, recurring, id, email, rawName] =\n decodeURIComponent(query).split(separator);\n const name = rawName.replaceAll(recoverSeparator, separator);\n\n return {\n plan: plan as SubscriptionPlan,\n recurring: recurring as SubscriptionRecurring,\n account: {\n id,\n email,\n info: {\n name,\n },\n },\n };\n};\n\n/**\n * Hook to parse subscription callback link, and save to local storage and delete the query\n */\nexport const useSubscriptionNotifyWriter = () => {\n const [searchParams] = useSearchParams();\n\n useEffect(() => {\n const query = searchParams.get('info');\n if (query) {\n localStorage.setItem(localStorageKey, query);\n searchParams.delete('info');\n }\n }, [searchParams]);\n};\n\n/**\n * Hook to read and parse subscription info from localStorage\n */\nexport const useSubscriptionNotifyReader = () => {\n const upgradeNotify = useUpgradeNotify();\n\n const readAndNotify = useCallback(() => {\n const query = localStorage.getItem(localStorageKey);\n if (!query) return;\n\n try {\n const { plan, recurring, account } = parseSubscriptionCallbackLink(query);\n const link = getUpgradeQuestionnaireLink({\n id: account.id,\n email: account.email,\n name: account.info?.name ?? '',\n plan,\n recurring,\n });\n upgradeNotify(link);\n localStorage.removeItem(localStorageKey);\n\n track.$.settingsPanel.plans.subscribe({\n plan,\n recurring,\n });\n } catch (err) {\n console.error('Failed to parse subscription callback link', err);\n }\n }, [upgradeNotify]);\n\n useEffect(() => {\n readAndNotify();\n window.addEventListener('focus', readAndNotify);\n return () => {\n window.removeEventListener('focus', readAndNotify);\n };\n }, [readAndNotify]);\n};\n"],"names":["actionButton","notifyHeader","SubscriptionChangedNotifyFooter","to","okText","cancelText","onCancel","onConfirm","div","className","Button","clsx","size","onClick","variant","a","href","target","rel","isDesktop","environment","useUpgradeNotify","t","useI18n","prevNotifyIdRef","useRef","useCallback","current","notify","dismiss","id","title","span","message","alignMessage","icon","footer","link","duration","useDowngradeNotify","recoverSeparator","nanoid","localStorageKey","getTypeFormLink","info","product_id","plans","Array","isArray","plan","map","SubscriptionPlan","AI","join","product_price","recurring","SubscriptionRecurring","Monthly","Lifetime","email","name","getUpgradeQuestionnaireLink","getDowngradeQuestionnaireLink","generateSubscriptionCallbackLink","account","baseUrl","includes","replaceAll","query","encodeURIComponent","parseSubscriptionCallbackLink","rawName","decodeURIComponent","split","useSubscriptionNotifyWriter","searchParams","useSearchParams","useEffect","get","localStorage","setItem","delete","useSubscriptionNotifyReader","upgradeNotify","readAndNotify","getItem","removeItem","track","$","settingsPanel","subscribe","err","console","error","window","addEventListener","removeEventListener"],"sourceRoot":""}