!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},a=(new e.Error).stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="62d088c1-13e9-4910-b744-58d51f9c1e96",e._sentryDebugIdIdentifier="sentry-dbid-62d088c1-13e9-4910-b744-58d51f9c1e96")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7352],{53375:function(e,a,t){t.d(a,{r:function(){return r}}),t(9150);var r="gnx4pm0"},40785:function(e,a,t){t.d(a,{bu:function(){return l},eQ:function(){return o},gw:function(){return r},tG:function(){return n}}),t(9150),t(99466),t(60336),t(79881),t(90935),t(63207),t(45808),t(72462),t(60349),t(74678),t(50056),t(14611),t(27531),t(73435),t(21148);var r={articleMetaStandard:"_1ajq89k2 _1ajq89k0",articleMetaFeature:"_1ajq89kc _1ajq89k2 _1ajq89k0",articleMetaFeatureSplit:"_1ajq89kw _1ajq89k2 _1ajq89k0",articleMetaSpecial:"_1ajq89k8 _1ajq89k2 _1ajq89k0",articleMetaSpecialSplit:"_1ajq89k8 _1ajq89k2 _1ajq89k0",articleMetaSpecialOverlay:"_1ajq89kc _1ajq89k2 _1ajq89k0",pageHeader:"_1ajq89k10 _1ajq89k2 _1ajq89k0",homepageOnBoarding:"_1ajq89k11 _1ajq89k2 _1ajq89k0"},o={articleMetaStandard:"_1ajq89k5 _1ajq89k3 _1lp96da0",articleMetaFeature:"_1ajq89kd _1ajq89k5 _1ajq89k3 _1lp96da0",articleMetaFeatureSplit:"_1ajq89k14 _1ajq89k5 _1ajq89k3 _1lp96da0",articleMetaSpecial:"_1ajq89k9 _1ajq89k5 _1ajq89k3 _1lp96da0",articleMetaSpecialSplit:"_1ajq89k9 _1ajq89k5 _1ajq89k3 _1lp96da0",articleMetaSpecialOverlay:"_1ajq89kd _1ajq89k5 _1ajq89k3 _1lp96da0",pageHeader:"_1ajq89k18 _1ajq89k5 _1ajq89k3 _1lp96da0",homepageOnBoarding:"_1ajq89k5 _1ajq89k3 _1lp96da0"},n={articleMetaStandard:"_1ajq89k1 _1ajq89k0",articleMetaFeature:"_1ajq89ka _1ajq89k1 _1ajq89k0",articleMetaFeatureSplit:"_1ajq89kg _1ajq89k1 _1ajq89k0",articleMetaSpecial:"_1ajq89k6 _1ajq89k1 _1ajq89k0",articleMetaSpecialSplit:"_1ajq89k6 _1ajq89k1 _1ajq89k0",articleMetaSpecialOverlay:"_1ajq89ka _1ajq89k1 _1ajq89k0",pageHeader:"_1ajq89kk _1ajq89k1 _1ajq89k0",homepageOnBoarding:"_1ajq89kl _1ajq89k1 _1ajq89k0"},l={articleMetaStandard:"_1ajq89k4 _1ajq89k3 _1lp96da0",articleMetaFeature:"_1ajq89kb _1ajq89k4 _1ajq89k3 _1lp96da0",articleMetaFeatureSplit:"_1ajq89ko _1ajq89k4 _1ajq89k3 _1lp96da0",articleMetaSpecial:"_1ajq89k7 _1ajq89k4 _1ajq89k3 _1lp96da0",articleMetaSpecialSplit:"_1ajq89k7 _1ajq89k4 _1ajq89k3 _1lp96da0",articleMetaSpecialOverlay:"_1ajq89kb _1ajq89k4 _1ajq89k3 _1lp96da0",pageHeader:"_1ajq89ks _1ajq89k4 _1ajq89k3 _1lp96da0",homepageOnBoarding:"_1ajq89kt _1ajq89k4 _1ajq89k3 _1lp96da0"}},44477:function(e,a,t){var r=t(35683),o=t(40785);a.Z=e=>{let{layout:a,tooltipRef:t}=e;return(0,r.jsx)("span",{ref:t,className:o.gw[a],children:(0,r.jsx)("svg",{className:o.eQ[a],width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-label":"Following",children:(0,r.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M8.8004 1.78498L3.604 7.79332L0.599609 5.14239L1.39356 4.24259L3.48917 6.09166L7.89276 1L8.8004 1.78498Z"})})})}},93757:function(e,a,t){var r=t(35683),o=t(40785);a.Z=e=>{let{layout:a,tooltipRef:t}=e;return(0,r.jsx)("span",{ref:t,className:o.tG[a],children:(0,r.jsx)("svg",{className:o.bu[a],width:"9",height:"9",viewBox:"0 0 9 9",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-label":"Follow",children:(0,r.jsx)("path",{d:"M5 0H4V4H0V5H4V9H5V5H9V4H5V0Z"})})})}},84633:function(e,a,t){t.d(a,{S3:function(){return j},Xe:function(){return _},hE:function(){return w}});var r=t(35683),o=t(66123),n=t(23411),l=t(7209),i=t(84994),c=t(7914),s=t(51477),u=t(60725);let d=(0,o.createContext)({followResource:async()=>!0,unfollowResource:async()=>!0,sendAnalyticsEvent:()=>{},canFollow:!1,loading:!0}),_=()=>(0,o.useContext)(d),w=e=>{let a=(0,o.useContext)(d),t=a.authors?.find(a=>a.id===e);return!!(t=a.categories?.find(a=>a.id===e)||t)},k=e=>{let{userEmail:a,token:t}=e;(0,u.Z)(a,["Verge Follows"],"follows",window.location.href,t).catch(e=>{e instanceof Error&&console.error(`Error subscribing user to follows newsletter: ${e.message}`)})},f=e=>{let a="production";return`user:${e.slice(0,6)}:${a?a+":":""}follows`},j=e=>{let{children:a}=e,[t,u]=(0,o.useState)(null),[_,w]=(0,o.useState)(!0),[j,h]=(0,o.useState)(!1),{user:p}=(0,i.aC)(),q=(0,l.z$)(),{fetchCaptchaToken:g}=(0,c.m)(s.e);(0,o.useEffect)(()=>{window.location.search.match("errorTestMode")&&h(!0)},[]),(0,o.useEffect)(()=>{if(!p)return;let e=f(p.uid),a=localStorage.getItem(e);a&&u(JSON.parse(a)),(0,n.Ev)({userId:p.uid}).then(a=>{u(a),w(!1);try{localStorage.setItem(e,JSON.stringify(a))}catch{}}).catch(()=>u(null))},[p]);let m=(0,o.useCallback)(e=>{u({categories:t?.categories||[],authors:e})},[t]),S=(0,o.useCallback)(e=>{u({authors:t?.authors||[],categories:e})},[t]),y=(0,o.useCallback)(e=>{let{eventType:a,type:t,name:r,gaComponentName:o}=e;q?.emit({event:a,[a]:{click_text:r.toLowerCase(),type:"author"===t?"author":"topic",position:o}})},[q]),v=(0,o.useCallback)(async e=>{let{resourceId:a,name:r,type:o,gaComponentName:l}=e;if(j)throw Error("Testing error states!");if(!p)return!1;let i="author"===o?m:S,c="author"===o?"authors":"categories",s=[...t?.[c]||[]];if(s.find(e=>e.id===a))return!1;if((t?.authors||[]).length+(t?.categories||[]).length>=30)throw Error("You have reached the maximum number of follows.");i([...s,{id:a,metadata:{name:r}}]);try{let e=await (0,n.ZN)({userId:p.uid,resourceId:a,name:r,type:o});i(e)}catch(e){throw i(s),e}return y({eventType:"follow",type:o,name:r,gaComponentName:l}),0===s.length&&k({userEmail:p.email||"",token:await g()}),!0},[t,p,S,m,j,y,g]),b=(0,o.useCallback)(async e=>{let{resourceId:a,name:r,type:o,gaComponentName:l}=e;if(j)throw Error("Testing error states!");if(!p)return!1;let i="author"===o?m:S,c="author"===o?"authors":"categories",s=[...t?.[c]||[]];i(s.filter(e=>e.id!==a));try{let e=await (0,n.fv)({userId:p.uid,resourceIds:[a],type:o});i(e)}catch(e){throw i(s),e}return y({eventType:"unfollow",type:o,name:r,gaComponentName:l}),!0},[t,p,S,m,j,y]);return(0,r.jsx)(d.Provider,{value:{...t,followResource:v,unfollowResource:b,sendAnalyticsEvent:y,canFollow:!!p,loading:_},children:a})}},23411:function(e,a,t){t.d(a,{$j:function(){return p},Ev:function(){return i},SU:function(){return f},VV:function(){return _},ZN:function(){return n},cU:function(){return h},fv:function(){return l},nR:function(){return j}});var r=t(24767);let o=async(e,a)=>{if(a.ok)return await a.json();throw Error(`Unable to complete ${e} action, HTTP ${a.status} response`)},n=async e=>{let{userId:a,resourceId:t,name:r,type:n}=e,l=await fetch(`/api/preferences/${a}/follows`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:t,name:r,type:n})});return await o("follow",l)},l=async e=>{let{userId:a,resourceIds:t,type:r}=e,n=await fetch(`/api/preferences/${a}/follows`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({ids:t,type:r})});return await o("unfollow",n)},i=async e=>{let{userId:a}=e,t=await fetch(`/api/preferences/${a}/follows`,{method:"GET",headers:{"Content-Type":"application/json"}});return await o("get follows",t)},c=async e=>{let{userId:a}=e,t=await i({userId:a}),r=[l({userId:a,resourceIds:t.authors.map(e=>e.id),type:"author"}),l({userId:a,resourceIds:t.categories.map(e=>e.id),type:"category"})];await Promise.all(r).then(()=>{console.log("Unfollowed all authors and topics")}).catch(e=>{throw console.error("Error unfollowing all authors and topics"),e})};r.Z&&(window.vergeFollow=n,window.vergeUnFollow=l,window.vergeGetFollows=i,window.vergeUnfollowAll=()=>c({userId:"1234"}));let s="followItem",u="followItemSource",d="followOnboarding",_=(e,a,t)=>{let r=new URLSearchParams({[s]:e,[u]:a});t&&r.set(d,"1");let o=encodeURIComponent(`${window.location.pathname}?${r.toString()}`);window.location.href=`/auth/login?returnPath=${o}&itm_campaign=follow&itm_medium=site`},w=()=>{let e=new URLSearchParams(window.location.search);return e.has(s)?e.get(s):null},k=()=>{let e=new URLSearchParams(window.location.search);return e.has(u)?e.get(u):null},f=()=>{let e=new URLSearchParams(window.location.search);return e.has(d)?"1"===e.get(d):null},j=(e,a)=>{let t=w();return k()===a&&t===e},h=()=>{let e=new URL(window.location.href);e.search="",window.history.replaceState({},"",e)},p=(e,a,t,r)=>`follow-${e}-${t}${r?`_${r}`:""}-${a}`},30904:function(e,a,t){t.d(a,{BZ:function(){return n},J0:function(){return l}});var r=t(66123);let o=(0,r.createContext)(null),n=()=>{let e=(0,r.useContext)(o);return e&&e.authorList||null},l=()=>{let e=(0,r.useContext)(o);return e&&e.categoryList||null};a.ZP=o},2707:function(e,a,t){t.d(a,{Cj:function(){return r},G3:function(){return n},su:function(){return o}});let r=(e,a)=>{try{localStorage.setItem(e,a)}catch(t){try{sessionStorage.setItem(e,a)}catch(e){console.warn("Failed to save to both localStorage and sessionStorage:",e)}}},o=e=>{try{let a=localStorage.getItem(e);if(null!==a)return a}catch(e){}try{return sessionStorage.getItem(e)}catch(e){return console.warn("Failed to read from both localStorage and sessionStorage:",e),null}},n=e=>{localStorage.removeItem(e),sessionStorage.removeItem(e)}}}]);