"use strict";(globalThis.webpackChunk_affine_web=globalThis.webpackChunk_affine_web||[]).push([[5670],{25670:(e,a,n)=>{n.r(a),n.d(a,{Component:()=>v,appIconMap:()=>g,appNames:()=>x,loader:()=>y});var r=n(36870),t=n(55683),s=n(47387),l=n(21817),i=n(24312),o=n(45483),c=n(86326),f=n(4194),h=n(42277),p=n(67448),u="v9327t4";let m="",d=p.z.enum(["affine","affine-canary","affine-beta","affine-internal","affine-dev"]);p.z.enum(["stable","canary","beta","internal"]);let b={affine:"stable","affine-canary":"canary","affine-beta":"beta","affine-internal":"internal","affine-dev":"canary"},g={stable:"/imgs/app-icon-stable.ico",canary:"/imgs/app-icon-canary.ico",beta:"/imgs/app-icon-beta.ico",internal:"/imgs/app-icon-internal.ico"},x={stable:"AFFiNE",canary:"AFFiNE Canary",beta:"AFFiNE Beta",internal:"AFFiNE Internal"},k=({urlToOpen:e,channel:a})=>{let n=(0,i.s9)(),s=(0,c.useCallback)(()=>{open(`https://affine.pro/download?channel=${a}`,"_blank")},[a]),l=g[a],h=x[a],[p]=(0,f.ok)(),d=(0,c.useMemo)(()=>"false"!==p.get("open"),[p]);return(e&&m!==e&&d&&(m=e,location.href=e),e)?(0,r.jsxs)("div",{className:"v9327t0",children:[(0,r.jsxs)("div",{className:"v9327t2",children:[(0,r.jsx)("a",{href:"/",rel:"noreferrer",className:"v9327t1",children:(0,r.jsx)(o.Logo1Icon,{width:24,height:24})}),(0,r.jsxs)("div",{className:"v9327t3",children:[(0,r.jsx)("a",{href:"https://affine.pro",target:"_blank",rel:"noreferrer",className:u,children:"Official Website"}),(0,r.jsx)("a",{href:"https://community.affine.pro/home",target:"_blank",rel:"noreferrer",className:u,children:"AFFiNE Community"}),(0,r.jsx)("a",{href:"https://affine.pro/blog",target:"_blank",rel:"noreferrer",className:u,children:"Blog"}),(0,r.jsx)("a",{href:"https://affine.pro/about-us",target:"_blank",rel:"noreferrer",className:u,children:"Contact us"})]}),(0,r.jsx)(t.$n,{onClick:s,children:n["com.arms.auth.open.affine.download-app"]()})]}),(0,r.jsxs)("div",{className:"v9327t6",children:[(0,r.jsx)("img",{src:l,alt:h,width:120,height:120}),(0,r.jsx)("div",{className:"v9327t7",children:(0,r.jsxs)(i.x6,{i18nKey:"com.arms.auth.open.affine.prompt",children:["Open ",h," app now"]})}),(0,r.jsx)("a",{className:"v9327t5",href:e,target:"_blank",rel:"noreferrer",children:n["com.arms.auth.open.affine.try-again"]()})]})]}):null},j=()=>{let[e]=(0,f.ok)(),a=(0,c.useMemo)(()=>e.get("url"),[e]),n=(0,c.useMemo)(()=>{let e=new URL(a||""),n=d.safeParse(e.protocol.replace(":",""));return b[n.success?n.data:"affine"]},[a]);return(0,r.jsx)(k,{urlToOpen:a,channel:n})},N=()=>{let{currentUser:e}=(0,h.LG)(),[a]=(0,f.ok)(),n=(0,c.useMemo)(()=>{let e=d.safeParse(a.get("schema"));return e.success?e.data:"affine"},[a]),t=(0,c.useMemo)(()=>a.get("next"),[a]),s=b[n];if(!e||!e?.token?.sessionToken)return null;let l=`${n}://signin-redirect?token=${e.token.sessionToken}&next=${t||""}`;return(0,r.jsx)(k,{urlToOpen:l,channel:s})},v=()=>{let{action:e}=(0,h.LG)();return"url"===e?(0,r.jsx)(j,{}):"signin-redirect"===e?(0,r.jsx)(N,{}):null},y=async e=>{let a=e.params.action||"",n=await (0,s.GO)({query:l.$r}).catch(console.error);return{action:a,currentUser:n?.currentUser||null}}}}]); //# sourceMappingURL=chunk.5670.bb443b94.js.map