var At=Object.defineProperty,Tt=Object.defineProperties;var It=Object.getOwnPropertyDescriptors;var de=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,qe=Object.prototype.propertyIsEnumerable;var je=(t,s,a)=>s in t?At(t,s,{enumerable:!0,configurable:!0,writable:!0,value:a}):t[s]=a,w=(t,s)=>{for(var a in s||(s={}))Ke.call(s,a)&&je(t,a,s[a]);if(de)for(var a of de(s))qe.call(s,a)&&je(t,a,s[a]);return t},H=(t,s)=>Tt(t,It(s));var Re=(t,s)=>{var a={};for(var n in t)Ke.call(t,n)&&s.indexOf(n)<0&&(a[n]=t[n]);if(t!=null&&de)for(var n of de(t))s.indexOf(n)<0&&qe.call(t,n)&&(a[n]=t[n]);return a};var K=(t,s,a)=>new Promise((n,i)=>{var o=r=>{try{c(a.next(r))}catch(u){i(u)}},d=r=>{try{c(a.throw(r))}catch(u){i(u)}},c=r=>r.done?n(r.value):Promise.resolve(r.value).then(o,d);c((a=a.apply(t,s)).next())});import{y as e,o as v,e as Ot,bK as se,q,bm as Dt,x as Y,a0 as oe,eh as Bt,u as De,cw as xt,a4 as le,Z as he,ah as Ut,ad as Lt,H as ot,m as Ge,t as R,E as k,aL as Be,ai as Gt,Q as Wt,af as Mt,F as Ft,G as rt,a6 as Ye,az as $t,ei as lt,I as Ht,k as zt,ej as xe,r as Vt,ek as Ze,a5 as Je,bk as jt,R as ct,cH as Kt,j as ke,z as ut,A as ie,ec as Qe,bA as Ce,B as Ae,a9 as qt,el as Yt}from"./tracking-9b49f173.js";import{s as Zt,S as Jt}from"./SubstackIconNoPadding-81bacdff.js";import{P as Qt}from"./TextInput-e7970737.js";import{F as ge,f as Xt,u as fe,E as es}from"./free_email_form.module-8694dbe7.js";import{m as ts,C as ss}from"./CaretRightIcon-29da2200.js";import{p as dt,T as as}from"./partition-73756293.js";import{aj as mt,aM as pt,r as ee,cC as bt,T as pe,bP as ns,aK as is,cD as os,cE as rs,au as ls}from"./index-9223b0e7.js";import{u as ht}from"./uniqBy-9b79f594.js";import{B as X}from"./_setToString-39b4f219.js";import{c as Q,T as L,F as z,u as We,S as gt,e as Ue,a as ft,O as re,B as cs}from"./Button-e7002859.js";import{S as _e}from"./SubstackIcon-941283bf.js";import{P as ce,S as us}from"./PubIcon-2cbecd14.js";import{a as Me}from"./user-063a1153.js";import{A as ds,C as ms}from"./index-bbf9fb90.js";import{V as ps}from"./ProfileHoverCard-c7ef38be.js";import{a as bs}from"./useResponsive-efd371d7.js";import{g as Fe}from"./IntroPopup-6f5c0a42.js";import{f as $e}from"./fetchJson-0d0791bb.js";import{d as hs}from"./debounce-e018ec6e.js";import{S as gs}from"./SimpleCheckmarkIcon-18f465b8.js";import{s as be}from"./entry-2c6596bb.js";import{f as _t,a as Nt,d as Et,e as St,c as vt,b as yt}from"./profile-a13fabbd.js";import{b as fs}from"./theme-4bde6337.js";(function(){try{var t=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{},s=new Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="60dbad74-b5e7-4c26-9bef-e7716ea508fb",t._sentryDebugIdIdentifier="sentry-dbid-60dbad74-b5e7-4c26-9bef-e7716ea508fb")}catch(a){}})();const _s=({children:t,className:s})=>e("div",{className:Q("pill",s)},e("span",null,t)),Ns=({publication:t,logo_size:s=60,isStatic:a=!1,children:n})=>a?e(Es,{publication:t,logo_size:s,children:n}):e("div",{className:"publication card"},s&&e("figure",{className:"logo"},e(ce,{pub:t,size:s})),e("div",{className:"title"},e("div",{className:"name"},t.name),e("div",{className:"description"},t.hero_text),n)),Es=({publication:t,logo_size:s=60,className:a="",children:n})=>e("table",{role:"presentation",className:Q("publication","card",a,t.logo_url?"has-logo":"no-logo"),width:"auto",cellpadding:0,cellspacing:0,border:"0"},e("tr",{cellpadding:"0",height:"100%"},s&&e("td",{rowspan:"3",className:"logo"},e("figure",{className:"logo"},t.logo_url?e(us,{pub:t,size:s}):e(_e,{isStatic:!0,fill:t.theme_var_background_pop||Zt,width:s,height:s}))),e("td",null,e("table",{cellpadding:"0",cellspacing:"0"},e("tr",null,e("td",{className:"title"},t.name)),e("tr",{cellpadding:"0",height:"80%"},e("td",{className:"description"},t.hero_text)),n)))),Ss=({onClick:t,checked:s})=>e("div",{className:"select-all"},e("input",{name:"all",type:"checkbox",onInput:t,checked:s}),e("label",{for:"all",onClick:t},"Select ",s?"none":"all")),wt=({disabled:t,onClick:s,children:a})=>e(X,{type:"submit",className:"primary xl",disabled:t,onClick:s},a),Ne=({isStatic:t=!1,extraProps:s={},linkType:a=null,discoverable:n=null,text:i,icon:o=!0,onClick:d=null})=>{const c={};a!==null&&(c.type=a),n!==null&&(c.discoverable=n);const r=Bt(c);return e("div",w({className:"twitter-discover"},s),e("a",H(w({className:"twitter-link",href:r},d&&{onClick:d}),{native:!0}),e("div",{className:"inner"},o&&e(pt,{stroke:"white",fill:"white",isStatic:t}),e("span",{className:"twitter-link-text"},i||"Find writers I follow"))))},vs=({pub:t,checked:s,onToggle:a,isSubscribed:n,author:i,screenName:o})=>e("li",{className:"linked-pub"},e("div",{className:"linked-pub"},e("div",{className:"photo"},e("div",{className:"subscribed-status"},e("input",{type:"checkbox",checked:s||n,disabled:n,onInput:()=>a(t.id)})),e(bt,{size:60,photo_url:i.photo_url}),e("div",{className:"twitter-handle"},e("span",{className:"author"},i==null?void 0:i.name),e("span",{className:"handle"}," @",o))),e("div",{className:"info"},e("div",{className:"publication-row"},e("a",{className:"publication",href:De(`${le(t)}/`,{utm_source:he.substack,utm_medium:Ut.web,utm_content:Lt.discoverTwitter}),target:"_blank",native:!0},e(Ns,{publication:t,logo_size:30},n?e("div",{className:"subscribed"},e(_s,null,"Subscribed")):null)))))),ys=({result:t,selectedPubs:s,onToggle:a})=>{var l;const{publicationAuthor:n,screen_name:i,publication_id:o}=t,{name:d,ownedPublications:c}=n,r=ht(c,_=>_.id),u=mt(r,_=>{var E;return(E=_.latestPost)!=null&&E[0]?oe(_.latestPost[0].post_date).toDate():oe.unix(1).toDate()}).reverse(),b=n.photo_url||((l=c.find(_=>_.id===o))==null?void 0:l.logo_url);return u.map(_=>{var f;const E=!!((f=_.subscriptions)!=null&&f.length);return e(vs,{author:n,screenName:i,authorName:d,showLogo:b!==n.photo_url,pub:_,checked:s.has(_.id),onToggle:a,isSubscribed:E})})},Xe=({user:t,freeSignupEmail:s,twitterEmail:a,twitterToken:n,onConfirmed:i,onSubscribed:o,formAction:d,pubIds:c,subscribeToken:r,redirect:u,showDiscover:b,editable:l,showLogout:_})=>{const E=(t==null?void 0:t.email)||s||a,[f,h]=v(!1),[g,p]=v(!0),[S,N]=v(E);c?u=De(u,{pubIds:c,t:n}):u=De(u,{t:n,d:g});const y=C=>{const{userExists:T,subscribed:D}=C.body;D?o==null||o(D):T?T&&(window.location.href=ot(`${Ge()}/sign-in`,{with_password:!1,email:S,redirect:u})):i==null||i()};return e("div",{className:"twitter-publications container"},e("section",null,e("div",{className:"terms-check"},e(ge,{onSuccess:C=>y(C),method:"post",action:d,loading:!1,autoLock:!0},e("input",{name:"t",type:"hidden",value:n}),c&&e("input",{name:"pubIds",type:"hidden",value:c}),r&&e("input",{name:"subscribeToken",type:"hidden",value:r}),e("input",{name:"email",type:"text",disabled:!l&&!!E,value:S,onInput:C=>{N(C.target.value)}}),e("label",null,e("input",{type:"checkbox",checked:f,onInput:()=>h(!f)}),"I accept the"," ",e("a",{href:"/tos",target:"_blank",native:!0},"Terms of Use")),b&&e("label",null,e("input",{name:"allow_discover",type:"checkbox",checked:g,onInput:()=>p(!f)}),"Allow people to find my publications via Twitter"),_&&e("label",null,e("a",{className:"login-button",href:xt(),native:!0},"Not you?")),e(wt,{disabled:!f},"Next →")))))},ws=()=>e("div",{className:"twitter-publications container landing"},e("h2",null,"Thousands of writers and readers are already on Substack"),e("section",null,e("p",null,"Connect with Twitter to find them and subscribe to their publications."," ",e("span",{className:"light"},"(We'll never post to your Twitter without permission or abuse your data.)")),e("div",{className:"banner"},e(Ne,null)))),Wa=({user:t,stage:s,twitterEmail:a,freeSignupEmail:n,twitterToken:i})=>!i&&!t||s=="connect"?e(ws,null):e(Pt,{user:t,stage:s,twitterEmail:a,freeSignupEmail:n,twitterToken:i}),Pt=({user:t,stage:s,twitterEmail:a,freeSignupEmail:n,twitterToken:i,buttonText:o=null,onSignup:d=null,requireSignup:c=!0,needsEmailConfirm:r=!0,renderIfNoneFound:u=null,useProfilePrefix:b=!1})=>{const[l,_]=v(null),[E,f]=v(null),[h,g]=v(null),[p,S]=v(null),[N,y]=v(!r),[C,T]=v(null),[D,A]=v(!1),[I,x]=v(new Set),[V,U]=v(null),Z=Ot("subscribed"),P=b?"/profile":"";Z?d?d():(g(Z.split(",")),se("/discover-twitter/success")):s&&s!=="connect"&&!l&&!h&&se("/discover-twitter");const O=W=>{const M=new Set(I);I.has(W)?M.delete(W):M.add(W),x(M)},j=W=>Xt(W.map(M=>{var $;return(($=M.publicationAuthor)==null?void 0:$.ownedPublications)||[]}));q(()=>{(()=>K(void 0,null,function*(){if(!D){A(!0);try{const $=(yield ee.get("/api/v1/twitter/publications")).body;if("needsConnect"in $&&$.needsConnect)se("/discover-twitter/connect");else{const{results:ue,subscribeToken:ve,needsTwitterConfirm:kt}=$,Ct=j(ue),ye=new Set(Ct.filter(Pe=>{var Ve;return((Ve=Pe.subscriptions)==null?void 0:Ve.length)===0}).map(Pe=>Pe.id));let we;ye.size<=30?we=new Set(ye):we=new Set,_(ue),T(!1),U(ve),f(ye),x(we),S(!kt)}}catch(M){T(M)}A(!1)}}))()},[]);let G;l&&(l.length>0?p?G=`We found ${l.length} account${l.length>1?"s":""} you follow on Twitter`:G=`Confirm your email to see ${l.length} account${l.length>1?"s":""} you follow on Twitter`:p||(G="Confirm your email to continue")),s==="confirm"&&(G="Confirm your email"),h&&(G="Success!");const te=l?j(l):null,Ee=()=>{y(!0),S(!0)},Se=()=>K(void 0,null,function*(){A(!0);try{const W=yield ee.post("/api/v1/twitter/subscribe").send({pubIds:[...I].join(","),t:i,subscribeToken:V});if(d)d();else{const{subscribed:M}=W.body;g(M),se("/discover-twitter/success")}}catch(W){console.error("error subscribing",W)}A(!1)}),ne=W=>{g(W),se("/discover-twitter/success")},B=W=>{let M;W?M=new Set(E):M=new Set,x(M)},F=()=>{!r||N?Se():se("/discover-twitter/confirm")};return e("div",{className:"twitter-publications pub-list"},e("h2",{className:s},G),D&&e("p",{className:"loading"},"Loading..."),C&&e(Y,null,e("p",{className:"error"},"Sorry, there was an error getting your results!"),e("div",{className:"banner"},e(Ne,null))),e(Dt,null,l&&!h&&p&&!D&&e(Cs,{path:`${P}/discover-twitter`,results:l,selectedPubs:I,subscribablePubs:E!=null?E:new Set([]),onToggleChecked:O,onToggleAll:B,onNext:F,loading:D,buttonText:o,requireSignup:c,renderIfNoneFound:u}),p==!1&&e(Xe,{path:`${P}/discover-twitter`,formAction:"/api/v1/twitter/confirm",redirect:"/api/v1/twitter/continue-confirm",user:t,onConfirmed:Ee,twitterEmail:a,twitterToken:i,freeSignupEmail:n,pubIds:[...I],showDiscover:!0}),!N&&e(Xe,{path:`${P}/discover-twitter/confirm`,redirect:"/api/v1/twitter/continue-subscribe",formAction:"/api/v1/twitter/subscribe",user:t,onSubscribed:ne,twitterEmail:a,twitterToken:i,freeSignupEmail:n,pubIds:[...I],subscribeToken:V,editable:!1,showLogout:!0}),l&&h&&e(Rs,{path:`${P}/discover-twitter/success`,user:t,subscribed:h,pubs:te!=null?te:[],results:l})))},Ps=({pub:t,result:s})=>{const{hero_text:a,stripeAccount:n,logo_url:i}=t,{screen_name:o,publicationAuthor:{name:d,photo_url:c}}=s,r=n==null?void 0:n.plans;return e("li",{className:"linked-pub subscribed"},e("div",{className:"linked-pub"},e("div",{className:"photo"},e(bt,{size:60,photo_url:i||c})),e("div",{className:"info"},e("div",{className:"publication-row"},e("div",{className:"publication"},e("div",{className:"name"},"@",o," - ",d),e("div",{className:"description"},a)),e("div",null,r&&e(pe,{className:"outline small button",href:`${le(t)}/subscribe`,target:"_blank"},"Upgrade"))))))},Rs=({subscribed:t,pubs:s,results:a})=>{const n=ht(s.filter(r=>t.find(u=>u===r.subdomain)),r=>r.id),[i,o]=dt(n,r=>{var u;return(u=r.stripeAccount)==null?void 0:u.plans}),d=[...i,...o].length>1,c=i.length>1;return e("ul",null,e("div",{className:"sign-up"},i.length>0?e(Y,null,c?`${i.length} of the newsletters`:d?"One of the newsletters":"The newsletter"," ","you subscribed to ",c?"have":"has"," a paid version. You can upgrade"," ",c?"those subscriptions":"that subscription"," now or later."):`You're subscribed to the free version of ${d?"these newsletters":"this newsletter"}.  Happy reading!`),[...i,...o].map(r=>{const u=a.find(b=>{var l;return b.screen_name===((l=r.twitterAccount)==null?void 0:l.screen_name)});return u?e(Ps,{pub:r,result:u}):null}))},ks=({onNext:t})=>e("div",null,e("ul",null,e("p",null,"It doesn't appear anyone you follow on Twitter has a Substack yet. We'll let you know if that changes."),e(pe,{className:"primary button",onClick:()=>{t()}},"Continue"))),Cs=({results:t,selectedPubs:s,onNext:a,onToggleChecked:n,onToggleAll:i,subscribablePubs:o,loading:d,buttonText:c,requireSignup:r,renderIfNoneFound:u})=>{if(t.length===0)return u||e(ks,{onNext:a});const b=mt(t,p=>{var N,y,C;let S;return(N=p.publicationAuthor)!=null&&N.ownedPublications?S=ts(p.publicationAuthor.ownedPublications,T=>{var D;return(D=T.latestPost)!=null&&D[0]?oe(T.latestPost[0].post_date).toDate():null}):S=null,(y=S==null?void 0:S.latestPost)!=null&&y[0]?oe((C=S.latestPost[0])==null?void 0:C.post_date).toDate():oe.unix(1).toDate()}).reverse(),[l,_]=dt(b,p=>(p.publicationAuthor.ownedPublications||[]).some(S=>{var N;return((N=S.subscriptions)==null?void 0:N.length)===0})),E=o.size===s.size,f=()=>{i(!E)},h=(!r||s.size>0)&&!d,g=!r||o.size>0?e(wt,{onClick:a,disabled:!h},c?(s.size>0?"Subscribe and ":"")+c:"Sign up →"):null;return e("div",null,e("section",{className:"sign-up"},"Subscribe to free newsletters from the people you already follow on Twitter"),e("ul",null,(!r||o.size>0)&&e(Y,null,(o.size>3||!r)&&g,e("li",null,o.size<30&&e(Ss,{checked:E,onClick:f}))),[...l,..._].map(p=>e(ys,{result:p,selectedPubs:s,onToggle:n})),g))};function As({onComplete:t}){const{getExperimentVariant:s}=fe();q(()=>R(k.READER_ONBOARDING_APP_UPSELL_SHOWN),[]);const a=Be()&&s("reader_onboarding_app_first")==="treatment_no_skip";return e(z,{paddingTop:24,gap:12},e(L.H1,{weight:"heavy"},"Download the Substack app"),e(L.B3,null,"Get the best reading experience on Android and iOS."),e(ds,{utm_campaign:Gt.readerOnboarding,utm_source:he.substack}),!a&&e("div",{className:"modal-ctas"},e(X,{className:"primary",onClick:t},"Continue")))}const Ts=({pub:t,authorFirst:s,selected:a,setSelected:n})=>{const i=`${le(t)}/?utm_source=${he.homepageReaderOnboarding}`;return e("div",{className:"bulk-subscribe-row",href:i,native:!0,target:"_blank"},e("div",{className:"icon-column"},e(ce,{pub:t,size:52})),e("div",{className:"right-column"},e("div",{className:"top-right"},e("div",{className:"info"},s?e(Y,null,e("h4",null,e("a",{href:i,native:!0,target:"_blank"},t.author_name)),e("p",null,"Writes ",t.name)):e(Y,null,e("h4",null,e("a",{href:i,native:!0,target:"_blank"},t.name)),e("p",null,"By ",t.author_name))),e(ns,{name:t.name,checked:a,onChange:()=>n(!a)})),e("div",{className:"bottom-right"},e(L.B4,{color:"secondary",className:"description"},Wt(t.editorial_bio||t.hero_text,Mt()?90:120)))))},Is=({publications:t,authorFirst:s,selected:a,setSelected:n,renderRow:i})=>{const{iString:o}=We(),d=a.length<t.length?e("button",{className:"small",onClick:()=>n(t.map(({id:r})=>r))},o("Select all")):e("button",{className:"small",onClick:()=>n([])},o("Unselect all")),c=r=>u=>n(u?[...a.filter(b=>b!==r.id),r.id]:a.filter(b=>b!==r.id));return e(Y,null,e("div",{className:"bulk-action-row"},d),e("div",{id:"bulk-subscribe",className:"bulk-subscribe"},t.map(r=>i?i({pub:r,selected:a.includes(r.id),setSelected:c(r)}):e(Ts,{key:r.id,pub:r,selected:a.includes(r.id),setSelected:c(r),authorFirst:s}))))},Os=t=>e(gt,H(w({},t),{name:"LargePlusIcon",svgParams:{height:16,width:16,fill:"#78706C",stroke:"none"}}),e("rect",{x:"7",y:"1",width:"2",height:"14",rx:"1"}),e("rect",{x:"15",y:"7",width:"2",height:"14",rx:"1",transform:"rotate(90 15 7)"})),Ma=(t="en")=>{const{iString:s}=I18N.i(t);return{482856:{blurb:s("Since retiring from the NBA, Kareem Abdul-Jabbar has authored 17 books and written award-winning columns. Now, the basketball legend makes Substack his home for thoughts on sports, politics, and pop culture, and how they define America."),rank:1},260347:{blurb:s("A new media company founded by journalist Bari Weiss, The Free Press employs more than 25 full-time staff. From podcasts, events, and investigative stories to their signature commentary, The Free Press produces work that drives the news and shifts the culture."),rank:2},567420:{blurb:s("New York Times bestseller, Booker Prize winner, and creative writing professor at Syracuse University, George Saunders offers a masterclass in storytelling and the craft of short fiction with a unique, educational Substack. Since 2021, his community has grown to more than 125,000 subscribers."),rank:3},220361:{blurb:s("Recipe developer and cookbook author Caroline Chambers’ number one food newsletter offers family-friendly meals and no-nonsense cooking. She also hosts [So Into That](https://whattocook.substack.com/podcast), a new Substack show featuring acclaimed guests diving into recommendations and lifestyle hacks."),rank:4},1662278:{blurb:s("Painter, fashion director, and illustrator Jenny Walton offers glimpses into her fabulous life in Milan. From vintage shopping and flea market finds to a guide to personal style, Jenny calls her Substack “a nice little place to chat that isn’t Instagram.”"),rank:5},445285:{blurb:s("Fashion and culture writer Viv Chen delivers thoughtful reflections and recommendations for secondhand and designer fashion enthusiasts. If you identify as an eBay gremlin, The Molehill is for you."),rank:6},2325511:{blurb:s("Founded by award-winning journalist Mehdi Hasan, Zeteo is a new media organization with more than 150,000 subscribers. Zeteo publishes a weekly streaming show, [Mehdi Unfiltered](https://zeteo.com/s/mehdi-unfiltered), alongside podcasts and essays from contributors including Greta Thunberg, John Harwood, Viet Thanh Nguyen, and Naomi Klein."),rank:7},61371:{blurb:s("Pioneering blogger and journalist Andrew Sullivan publishes essays on politics and the culture wars on his Substack The Weekly Dish, which is also home to his podcast, [The Dishcast](https://andrewsullivan.substack.com). With more than 160,000 subscribers, Sullivan is among the most influential writers in U.S. politics."),rank:8}}},Le=(t,s)=>{if(!t)return"featured";if(t==="featured"||t==="twitter"||t==="podcast")return t;const a=s.find(n=>n.slug===t);return a?a.id:"featured"},He=Ft({});He.displayName="WWWContext";const Fa=t=>{const s=a=>{const n=rt(He);return e(t,w(w({},n),a))};return s.displayName=`withWWWContext(${t.name||t.displayName||"Anonymous"})`,s},Ds=()=>rt(He);function Bs(t){const s=Ds(),{categories:a,publications:n=[],categoryId:i,featuredPublications:o=[],user:d,categorySlug:c="featured",rankingSlug:r,hasMore:u,updateUrl:b=!1,maxPublications:l=5,showTwitterBanner:_,homepageFeaturedPublications:E=[],isHomepage:f}=w(w({},s),t),h=f?8:l,[g,p]=v(a!=null?a:[]),[S,N]=v(ae(n,l)),[y,C]=v(i!=null?i:"featured"),[T,D]=v(f&&E.length?ae(E,h):ae(o,l)),[A,I]=v(null),[x,V]=v("paid"),[U,Z]=v(null),[P,O]=v(0),[j,G]=v(!!u);q(()=>{const B=r||"paid";V(B),g||xs().then(({categories:F,publications:W,featuredPublications:M})=>{p(F);const $=Le(c,F);return C($),D(ae(M,l)),$==="featured"?W:Te($,B,0).then(({publications:ue,more:ve})=>(O(0),l||G(ve),ue))}).then(F=>{N(ae(F,l))})},[g,c,r,l]);const te=Ye(()=>{const B=P+1;R(k.VIEWED_MORE_CATEGORY,{categoryId:y,ranking:x,page:B}),Te(y,x,B).then(({publications:F,more:W})=>{const M=new Set(S.map($=>$.id));O(B),N(S.concat(F.filter($=>!M.has($.id)))),G(W)})},[y,x,P,S,O,N,G]),Ee=({categoryId:B,ranking:F,categories:W})=>{R(k.CLICKED_CATEGORY,{categoryId:B,ranking:F}),b&&se(et({categoryId:B,categories:W,ranking:F}),!0),ne({categoryId:B,ranking:F})},Se=B=>{V(B),b&&se(et({categoryId:y,categories:g,ranking:B}),!0),ne({categoryId:y,ranking:B})},ne=Ye(W=>K(this,[W],function*({categoryId:B,ranking:F}){if(C(B),O(0),B==="featured"||B==="twitter"){I(null),Z(null),G(!1),B==="featured"&&N(ae(T,l));return}I(B),Z(F),N([]),G(!1);const{publications:M,more:$}=yield Te(B,F,0);C(B),I(null),Z(null),V(F),O(0),l||G($),N(ae(M,l))}),[I,Z,C,O,G,N,T,l]);return{categories:g,publications:y==="featured"?T:S,categoryId:y,ranking:x!=null?x:void 0,loadingCategoryId:A,loadingRanking:U,featuredPublications:T,user:d,categorySlug:c,rankingSlug:r,hasMore:j,viewMore:te,loadPublications:ne,onCategoryClicked:Ee,getCategoryIdFromSlug:Le,setCategoryId:C,setRanking:V,onRankingChange:Se,maxPublications:l,showTwitterBanner:!!_}}const ae=(t,s)=>s?t.slice(0,s):t,xs=()=>$e("/api/v1/homepage/initial-category-data"),Te=(t,s,a=0)=>$e(`/api/v1/category/public/${t}/${s}?page=${a}`),et=({categoryId:t,ranking:s,categories:a})=>{let n="";typeof t=="string"&&["twitter"].includes(t)&&(n=t);const i=a.find(o=>o.id===t);return i!=null&&i.slug&&(n=`${i.slug}/${s}`),n?`/discover/category/${n}`:"/discover"},Us={desktop:15,mobile:6},Rt=({className:t,hasFeatured:s,categories:a,categoryId:n,categoryIds:i,loadingCategoryId:o,ranking:d,onCategoryClicked:c,defaultExpanded:r})=>{const[u,b]=v(r||!1),l=bs.useMediaQuery({query:"only screen and (max-width: 650px)"}),_=Us[l?"mobile":"desktop"],E=u&&a?a:a.slice(0,_),f=g=>g.id===n||(i==null?void 0:i.includes(g.id)),{iString:h}=We();return e("div",{className:Q("categories",t)},s?e(X,{className:Q({active:n==="featured"&&(!o||o==="featured"),loading:o==="featured"&&n!=="featured"}),onClick:()=>c({categoryId:"featured",ranking:"all",categories:a})},h("Featured")):null,E.map(g=>e(X,{key:g.id,className:Q({active:f(g)&&(!o||o===g.id),loading:o===g.id&&n!==g.id}),onClick:()=>c({categoryId:g.id,ranking:d,categories:a})},g.id==="twitter"&&e(pt,{width:l?12:15,height:l?12:15,strokeWidth:0}),h(g.name||""))),a.length>_&&!u&&e(X,{className:"show-more",onClick:()=>b(!0)},e(Os,null)))},Ls=({publications:t,explanations:s,ranking:a,openInNew:n,startRankAt:i=0,source:o,onPublicationVisited:d=null,user:c,categoryId:r})=>{const{language:u}=We();return e(Y,null,e("div",{className:"publications"},t.map((b,l)=>{var C,T,D,A,I,x,V;let _=s&&s[l];if(!b)return;_||(_=[]);const E=_.filter(U=>["posts.title","posts.subtitle"].includes(U.type)),f=!!((A=(D=(T=(C=E[0])==null?void 0:C.posts)==null?void 0:T[0])==null?void 0:D[0])!=null&&A.slug);let h;f&&(h=(V=(x=(I=E[0])==null?void 0:I.posts)==null?void 0:x[0])==null?void 0:V[0]);const g=_.filter(U=>U.type==="description")[0],p=_.filter(U=>["name","subdomain","hero_text","custom_domain","author_name"].includes(U.type)).length>0||!g&&!h,S=_.filter(U=>U.type==="description").map(U=>U.keyword),N=_.filter(U=>["posts.title","posts.subtitle"].includes(U.type)).map(U=>U.keyword),y=$t(b,{params:{utm_source:o||he.discover},signedIn:!!c});return e("a",{key:b.id,className:"publication",href:y,native:!0,target:n?"_blank":void 0,onClick:()=>{lt(b,o||"leaderboards",{position:l+1,category:r}),d&&d(b)},rel:"noopener"},a==="paid"?e("div",{className:"publication-rank"},l+1+i):null,e("div",{className:"publication-content"},e(ce,{pub:b,belowTheFold:!0}),e("div",{className:"publication-text-area"},e("div",{className:"publication-title"},b.name),(p||h)&&e("div",{className:"publication-description"},b.editorial_bio||me(b.hero_text,S)),!p&&g&&!h&&e("div",{className:"publication-description"},me(g.sentence,S)),!p&&h&&e("div",{className:"publication-explanation-box"},f&&e("a",{className:"title",href:Ht(b,h)},e("div",{className:"post-preview-content"},e("div",{className:"left-flex"},e("p",{className:"title"},me(h.title,N)),e("p",{className:"subtitle"},me(h.subtitle,N))),e("div",{className:"right-flex"},e("img",{src:h.cover_image,className:h.cover_image?"":"no-preview"}))))),e("div",{className:"publication-author"},Fe(b,{language:u})))))})))};function me(t,s){if(!t)return"";const a=new RegExp(s.join("|"),"ig"),n=t.split(a),i=[...t.matchAll(a)];return e("span",null,n.map((o,d)=>e(Y,null,o,d!==n.length-1&&e("b",null,i[d]))))}const tt=({onCategoryClicked:t,categoryId:s,ranking:a,loadingRanking:n,categories:i})=>typeof s=="string"&&["featured","twitter"].includes(s)?null:e("div",{className:"ranking-toggle"},e(pe,{className:Q({active:a==="paid"&&!n||n==="paid",loading:n==="paid"&&a!=="paid"}),onClick:()=>t({categoryId:s,ranking:"paid",categories:i})},"Top paid"),"  ·  ",e(pe,{className:Q({active:a==="all"&&!n||n==="all",loading:n==="all"&&a!=="all"}),onClick:()=>t({categoryId:s,ranking:"all",categories:i})},"All")),$a=a=>{var n=a,{Component:t=Gs}=n,s=Re(n,["Component"]);const i=Bs(s);return i.categories?e(t,w({},i)):null};class Gs extends zt{componentDidUpdate(s){if(this.props.categorySlug===s.categorySlug&&this.props.rankingSlug===s.rankingSlug)return;const a=Le(this.props.categorySlug,this.props.categories),n=this.props.rankingSlug||"paid";this.props.loadPublications({categoryId:a,ranking:n})}startReading(s){window.sessionStorage.setItem("initialJoinSubstack","true"),R(k.HOMEPAGE_READER_LINK_CLICKED,{url:xe()}),Vt(xe(),{event:s})}render({categories:s,publications:a,categoryId:n,loadingCategoryId:i,ranking:o,loadingRanking:d,onCategoryClicked:c,hasMore:r,viewMore:u,featuredPublications:b,maxPublications:l,showTwitterBanner:_,user:E}){const f=n==="featured",h=n==="twitter",g=s.find(p=>p.id===n);return e("div",{className:Q("new-landing-page reader-landing-page page",{"category-featured":f})},e("div",{className:"container"},e("div",{className:"landing-content"},e("div",{className:"landing-section landing-publications"},e("div",{className:"publications-header not-mobile"},e(tt,{categories:s,categoryId:n,ranking:o,onCategoryClicked:c})),e(Ls,{publications:a,ranking:f?"all":o,categoryId:n}),o==="all"&&!f&&!h&&!l&&r&&e("div",{className:"view-more"},e(X,{className:"primary top-pad",onClick:u},"View more")),l&&n!=="featured"&&e("div",{className:"see-all",style:{paddingLeft:o==="all"?"108px":"146px"}},e("a",{href:f?Ze():Ze(g,o),native:!0},"See all"," ",e(ss,{width:7,height:11,color:"var(--color-primary-themed)",style:{marginLeft:"3px"}})))),e("div",{className:"landing-section landing-categories"},e("div",{className:"only-mobile"},e("div",{className:"mobile-toggle"},e(tt,{categories:s,categoryId:n,ranking:o,onCategoryClicked:c}))),e(Rt,{hasFeatured:b&&b.length>0,categories:s,categoryId:n,loadingCategoryId:i,onCategoryClicked:c,ranking:o,loadingRanking:d}))),_&&n==="featured"&&!(E!=null&&E.has_linked_twitter)?e(Ne,null):null))}}const m={SIGNUP:"SIGNUP",PUB_LANDING:"PUB_LANDING",PUB_SIGNUP:"PUB_SIGNUP",CATEGORIES:"CATEGORIES",CATEGORIES_SUGGESTIONS:"CATEGORIES_SUGGESTIONS",PROFILE:"PROFILE",START_WRITING:"START_WRITING",CREATE_PUBLICATION:"CREATE_PUBLICATION",CREATE_PUBLICATION_SUCCESS:"CREATE_PUBLICATION_SUCCESS",WELCOME:"WELCOME",ERROR:"ERROR",EXIT:"EXIT",APP_UPSELL:"APP_UPSELL"},Ie=7,Oe=(t,s,a,n)=>{var _,E;const i=Object.entries(t).filter(([f])=>f!=="promoted"&&f!=="suggested").map(([f,h])=>h),o=new Set,d=i.map(f=>f.length),c=Math.max(...d);let r=[];for(let f=0;f<c;f+=1)for(const h of i){const g=h[f];g&&!o.has(g.id)&&!(s!=null&&s.includes(g.id))&&(o.add(g.id),r.push(g))}t.suggested&&(r=ps(r,...t.suggested),r.unshift(...t.suggested));const u=(!a||a.length===0)&&(n==null?void 0:n.includes("treatment")),b=r.slice(0,Ie),l=(_=t.promoted)==null?void 0:_[0];return t.promoted&&l&&!o.has((E=t.promoted[0])==null?void 0:E.id)&&(u?b.unshift(l):b.length===Ie?b[Ie-1]=l:b.push(l)),b},Ws=({onCategoriesFinalized:t=null,setStep:s,handleError:a,categories:n,pub:i=null,entry:o,user:d,setPreviousStepData:c,recommendationsSource:r=null,canBeSkipped:u=!1,suggestPubIds:b})=>{const[l,_]=v([]),[E,f]=v({}),[h,g]=v(!1),[p,S]=v([]),[N,y]=v(!1),{getExperimentVariant:C,exposeExperiment:T,refreshExperimentVariants:D}=fe(),A=C("reader_onboarding_model_recs_categories_skipped");q(()=>{D({ignoreDownsampling:!0})},[]),q(()=>{r&&(()=>K(void 0,null,function*(){if(!r)return;const O=yield ee.get(r);f({personalized:O.body});const j=Oe({personalized:O.body},[i==null?void 0:i.id],[],"control").map(({id:G})=>G);S(j),g(!0);for(const{id:G}of O.body)R(k.READER_ONBOARDING_PUB_RECOMMENDED,{entry:o,publication_id:G,recommendationFrom:"personalized"})}))()},[r,o,i==null?void 0:i.id]);const x=is({pathname:"/api/v1/categories",auto:!n,initialResult:n,deps:[]}).result||[],V=({categoryId:P})=>{l.includes(P)?_(l.filter(O=>O!==P)):_([...l,P])},U=()=>K(void 0,null,function*(){let P;try{const O=l.length?l:x.slice(0,3).map(te=>te.id),j={categoryIds:JSON.stringify(O),userDidSelectCategories:!!l.length};b&&(j.suggestedPubIds=b);const G=yield ee.get("/api/v1/category/public/multiple").query(j);f(G.body),P=Oe(G.body,[i==null?void 0:i.id],l,A).map(({id:te})=>te)}catch(O){a(O,{ignore:!0}),s(m.PROFILE);return}R(k.READER_ONBOARDING_CATEGORIES_FINALIZED,{entry:o,numberOfCategories:l.length});for(const O of l)R(k.READER_ONBOARDING_CATEGORY_REQUESTED,{entry:o,categoryId:O});l!=null&&l.length?(T("reader_onboarding_model_recs_categories_selected",{ignoreDownsampling:!0}),S(P)):(T("reader_onboarding_model_recs_categories_skipped",{ignoreDownsampling:!0}),S(A!=null&&A.includes("treatment")?[P[0]]:P)),g(!0),t==null||t();for(const O of P)R(k.READER_ONBOARDING_PUB_RECOMMENDED,{entry:o,publication_id:O,recommendationFrom:"leaderboard"})}),Z=()=>K(void 0,null,function*(){const P=d?d.profile_set_up_at?d.has_publication?m.APP_UPSELL:m.START_WRITING:m.PROFILE:m.SIGNUP;if(p.length>0)try{y(!0),R(k.READER_ONBOARDING_BULK_SUBSCRIBE_SELECTED_IN_UI,{entry:o,numberOfSubscriptions:p.length,recommendationsFrom:"categories"}),d?(yield ee.post("/api/v1/bulk_signup").send({publications:p,visibility:"public",source:`${o==="reader2-profile"?"reader2":o}-reader-onboarding`}),R(k.READER_ONBOARDING_BULK_SUBSCRIBED,{entry:o,numberOfSubscriptions:p.length,recommendationsFrom:"categories"})):c(m.CATEGORIES,{publications:p,selectedCategoryIds:l}),s(P)}catch(O){a(O,{ignore:!1})}else d?R(k.READER_ONBOARDING_BULK_SUBSCRIBE_SKIPPED,{entry:o,recommendationsFrom:"categories"}):c(m.CATEGORIES,{publications:[],selectedCategoryIds:l}),s(P)});return!h&&!r?e("div",{className:"categories-step"},e("div",null,e("div",{className:"categories-header"},e("h3",null,i?e(Y,null,"You're subscribed!",e("br",null),"Now dive"):"Dive"," ","into your interests"),e("p",null,"We'll recommend top publications based on the topics you select.")),e(Rt,{hasFeatured:!1,categories:x,categoryIds:l,onCategoryClicked:V,ranking:"all",defaultExpanded:!0})),e("div",{className:"spacer"}),e("div",{className:"modal-ctas"},e(X,{className:"primary",onClick:U},"Continue"))):e("div",{className:"categories-step"},e("div",{className:"categories-header"},e("h3",null,"Writers you may like"),e("p",null,r?"We found some writers based on your interests.":l.length>0?"Based on your interests, here are some writers you might enjoy.":"Here are some writers you might enjoy.")),e(Is,{publications:Oe(E,[i==null?void 0:i.id],l,A),selected:p,setSelected:S}),e("div",{className:"modal-ctas"},u&&e("p",{className:"skip"},e("a",{className:"small",onClick:()=>{R(k.READER_ONBOARDING_BULK_SUBSCRIBE_SKIPPED,{entry:o,recommendationsFrom:"categories"}),s(m.APP_UPSELL)},disabled:N},"Skip for now")),e(X,{className:"primary",type:"submit",onClick:Z,disabled:N},p.length>0&&`Subscribe to ${p.length} and continue`,p.length===0&&"Continue without subscribing")))},Ms=t=>e(gt,H(w({},t),{name:"InvertedWarningIcon",svgParams:{height:18,width:18}}),e("path",{d:"M9.00033 0.666992C4.39783 0.666992 0.666992 4.39783 0.666992 9.00033C0.666992 13.6028 4.39783 17.3337 9.00033 17.3337C13.6028 17.3337 17.3337 13.6028 17.3337 9.00033C17.3337 4.39783 13.6028 0.666992 9.00033 0.666992ZM9.00033 2.33366C12.682 2.33366 15.667 5.31866 15.667 9.00033C15.667 12.682 12.682 15.667 9.00033 15.667C5.31866 15.667 2.33366 12.682 2.33366 9.00033C2.33366 5.31866 5.31866 2.33366 9.00033 2.33366ZM8.16699 4.83366V9.83366H9.83366V4.83366H8.16699ZM8.16699 11.5003V13.167H9.83366V11.5003H8.16699Z"})),Fs="_right_1b26b_1",$s="_liveUpdatingInput_1b26b_6",Hs="_invalid_1b26b_23",zs="_narrower_1b26b_27",Vs="_autoMargins_1b26b_31",js="_mobileAwareWidth_1b26b_37",Ks="_borderedBox_1b26b_41",qs="_errorText_1b26b_50",Ys="_aTag_1b26b_54",J={right:Fs,liveUpdatingInput:$s,invalid:Hs,narrower:zs,autoMargins:Vs,mobileAwareWidth:js,borderedBox:Ks,errorText:qs,aTag:Ys},Zs=({user:t,setStep:s,entry:a,setPreviousStepData:n})=>{const i=Je(null),o=Je(null),[d,c]=v(""),[r,u]=v([]),[b,l]=v(!1),[_,E]=v(!1),[f,h]=v(!1);q(()=>{const N=()=>K(void 0,null,function*(){try{const y=yield ee.get("/api/v1/publication/suggestion");y.body.subdomain&&(l(!0),c(y.body.subdomain))}catch(y){console.error("Failed to get subdomain suggestion:",y)}});_||(E(!0),R(k.READER_ONBOARDING_CREATE_PUBLICATION_STEP_STARTED,{entry:a}),N(),E(!1))},[_,E,a]);const g=hs(N=>{p(N)},500),p=N=>K(void 0,null,function*(){var C,T;const y=N.target.value;if(c(y),y.length===0){u([]);return}try{if((yield ee.get("/api/v1/check_subdomain",{subdomain:y})).body.available)l(!0),u([]);else{const A=[{msg:"This URL is taken. Try another."}];l(!1),u(A)}}catch(D){const A=[];(T=(C=D.response.body)==null?void 0:C.errors)==null||T.forEach(I=>{D.response.body.errors.length>1&&I.msg==="Please enter a valid web URL (letters and numbers only)"||A.push(I)}),l(!1),u(A)}}),S=()=>K(void 0,null,function*(){var N,y,C,T,D;try{const I=(yield ee.post("/api/v1/publication").send({name:`${jt((N=t==null?void 0:t.name)!=null?N:null)||"My"} Publication`,subdomain:d,hero_text:"Welcome to my publication",tos:!0,captcha_response:f&&((y=o==null?void 0:o.current)==null?void 0:y.getResponse())})).body;n(m.CREATE_PUBLICATION,{createdPub:I}),s(m.CREATE_PUBLICATION_SUCCESS)}catch(A){if(R(k.READER_ONBOARDING_CREATE_PUBLICATION_STEP_ERROR,{entry:a,message:A.toString()}),A.response.statusCode===401){h(!0),l(!1),u([]);return}const I=[];(T=(C=A.response.body)==null?void 0:C.errors)==null||T.forEach(x=>{A.response.body.errors.length>1&&x.msg==="Please enter a valid web URL (letters and numbers only)"||I.push(x)}),(D=A.response.body)!=null&&D.error&&I.push({msg:A.response.body.error}),l(!1),u(I)}});return e(z,{gap:32,paddingTop:48,className:J.mobileAwareWidth},e(L.H1,null,"Create your publication"),e(z,{className:J.borderedBox,gap:56,paddingTop:56,paddingBottom:32,paddingX:{mobile:12,desktop:48},radius:"md"},e(z,{gap:16},e(L.B3,{align:"left",weight:"bold"},"Publication URL"),e(ft,{gap:12,alignItems:"center"},e("input",{ref:i,type:"text",name:"subdomain",id:"subdomain",onInput:N=>{g(N)},value:d,className:Q(J.liveUpdatingInput,{[`${J.invalid}`]:r.length})}),e(L.B3,null,".substack.com"),e(Ue,{className:J.right},b&&!r.length?e(gs,{isStatic:!0,height:18,fill:"#4c3",stroke:"#4c3"}):e(Ms,{height:16,width:16,fill:"#D72B2B",stroke:"#D72B2B",strokeWidth:0}))),f&&e(ms,{ref:o}),(r.length>0||f)&&e(z,{gap:8},r.map(N=>e(L.B4,{className:J.errorText,align:"left"},N.msg)),f&&e(L.B4,{className:J.errorText,align:"left"},"Please complete the captcha to continue"))),e(z,{gap:24},e(re,{size:"lg",onClick:S,disabled:r.length>0},"Continue"))),e(Ue,{className:J.autoMargins,alignItems:"center"},e(L.B4,{color:"secondary",className:J.narrower},"By signing up, you agree to"," ",e("a",{className:J.aTag,href:"https://substack.com/pa",target:"_blank",rel:"noopener"},"our publisher agreement"),","," ",e("a",{className:J.aTag,href:"https://substack.com/ccpa#personal-data-collected",target:"_blank",rel:"noopener"},"information collection notice"),", and"," ",e("a",{className:J.aTag,href:"https://substack.com/privacy",target:"_blank",rel:"noopener"},"privacy policy"))))},Js="_image_1jv7a_1",Qs="_buttonGroup_1jv7a_6",st={image:Js,buttonGroup:Qs},Xs=({setStep:t,entry:s,previousStepData:a})=>{q(()=>{R(k.READER_ONBOARDING_CREATE_PUBLICATION_SUCCESS_STEP_STARTED,{entry:s})});const n=()=>{window.location.href=Kt(a[m.CREATE_PUBLICATION].createdPub,{addBase:!0})},i=()=>{R(k.READER_ONBOARDING_CREATE_PUBLICATION_SUCCESS_STEP_SKIPPED,{entry:s}),t(m.APP_UPSELL)};return e(z,{gap:48,paddingBottom:120,alignItems:"center"},e("img",{className:st.image,src:ct("/img/reader_onboarding/car.png",264)}),e(z,{gap:4},e(L.H1,null,"Success!"),e(L.B3,null,"You're all set! Head over to your dashboard and tell the world about your Susbtack")),e(z,{className:st.buttonGroup,gap:4},e(re,{size:"lg",onClick:n},"Visit writer dashboard"),e(re,{size:"lg",fill:"empty",priority:"secondary",onClick:i},"I'll do it later")))},ea=({close:t})=>e("div",{className:"welcome-step"},e("div",{className:"headings"},e(_e,{className:"substack",width:72,height:72}),e("h3",null,"Something went wrong"),e("p",null,"We're sorry for the inconvenience.")),e("div",{className:"spacer"}),e("div",{className:"spacer"}),e("div",{className:"modal-ctas"},e(X,{className:"primary",onClick:t},"Close"))),ta=({setStep:t,handleError:s,user:a,entry:n,followUserIds:i,redirectAfterProfile:o=!1,barebones:d=!1})=>{const[c,r]=v(null),[u,b]=v(!1),l=a?a.id:null;q(()=>{(()=>K(void 0,null,function*(){if(i!=null&&i.length)try{yield $e("/api/v1/feed/bulk-follow",{method:"POST",json:{surface:"post-follow-referrer-prompt",userIds:i}})}catch(S){console.error("could not bulk-follow",S)}}))()},[i]),q(()=>{R(k.READER_ONBOARDING_PROFILE_SETUP_STARTED,{entry:n}),l&&(()=>K(void 0,null,function*(){var S;try{const y=(yield ee.get(`/api/v1/user/${l}/profile/edit`)).body;y&&!y.profile_set_up_at&&((S=y.subscriptions)==null?void 0:S.length)>0&&(y.subscriptions=y.subscriptions.map(C=>H(w({},C),{visibility:"public"}))),r(y)}catch(N){s(N,{ignore:!0}),t(m.APP_UPSELL)}}))()},[s,t,l,n]);const _=!!(c!=null&&c.profile_set_up_at),E=()=>{t(o?m.EXIT:m.APP_UPSELL)},f=()=>{b(!0),R(k.READER_ONBOARDING_PROFILE_SETUP_SKIPPED,{entry:n})},h=()=>b(!1),g=p=>{if(!c){console.warn("No profile, cannot set visibility");return}r(H(w({},c),{subscriptions:[...c.subscriptions.map(S=>{const N=p[S.publication.id];return N?H(w({},S),{visibility:N}):S})]}))};return e(Y,null,e("div",{className:Q("profile-step",{hidden:!u})},e("h3",null,"Subscriptions displayed on profile"),e("p",null,"Subscriptions appear on your profile by default, but you can choose to hide some or all of them"),e(rs,{profile:c,onFinalizeVisibility:h,onSetVisibility:g,source:"homepage-reader-onboarding"})),e("div",{className:Q("profile-step",{hidden:u})},e("h3",null,"Tell us about yourself"),e("p",null,"Add your name, a profile picture, and a bit more about who you are."),e(os,{pageTitle:"",user:a,freeSignup:!0,freeSignupEmail:null,needsPhoto:!1,optionalPhoto:!0,isPostInvite:!1,primaryEligiblePublications:[],onSuccess:E,onEditReadVisibility:f,numVisibleSubscriptions:(c==null?void 0:c.subscriptions.filter(({visibility:p})=>p==="public").length)||0,numSubscriptions:(c==null?void 0:c.subscriptions.length)||0,complete:!0,text:"Continue",profileExists:_,prepareData:p=>(p.reads_visibility=(c==null?void 0:c.subscriptions.map(({id:S,visibility:N})=>({id:S,visibility:N})))||[],p),barebones:d})))},sa=({pub:t,user:s,setStep:a,entry:n})=>e("div",{className:"pub-landing-step"},e(ge,{method:"post",action:"/api/v1/reader/signup/pub",loading:!1,autoLock:!0,onSuccess:o=>{R(k.READER_ONBOARDING_PUB_LANDING_SIGNUP_SUCCEEDED,{entry:n}),s||be({user:o.body.user}),a(m.CATEGORIES)}},e("div",{className:"headings"},e(ce,{pub:t,size:84}),e("h3",{className:"publication-title"},t.name),e("p",{className:"publication-description"},t.editorial_bio||t.hero_text),e("p",{className:"publication-details"},Fe(t))),e("input",{type:"hidden",name:"email",value:s==null?void 0:s.email}),e("input",{type:"hidden",name:"source",value:`${n}-reader-onboarding`}),e("input",{type:"hidden",name:"publication_id",value:t.id}),e("input",{type:"hidden",name:"visibility",value:"public"}),e("input",{type:"hidden",name:"noWelcomeEmail",value:"true"}),e("input",{type:"hidden",name:"first_url",value:_t}),e("input",{type:"hidden",name:"first_referrer",value:Nt}),e("input",{type:"hidden",name:"first_session_url",value:Et}),e("input",{type:"hidden",name:"first_session_referrer",value:St}),e("input",{type:"hidden",name:"current_url",value:vt}),e("input",{type:"hidden",name:"current_referrer",value:yt}),e("div",{className:"modal-ctas"},e("a",{className:"button let-me-read",href:ot(le(t),{no_cover:!0,utm_source:`${n}-reader-onboarding`}),onClick:()=>{R(k.READER_ONBOARDING_PUB_LANDING_LET_ME_READ_CLICKED,{entry:n}),lt(t,n)}},"Let me read it first"),e(X,{className:"primary",onClick:o=>{R(k.READER_ONBOARDING_PUB_LANDING_SUBSCRIBE_CLICKED,{entry:n}),s||(o.preventDefault(),a(m.PUB_SIGNUP))},type:"submit"},"Subscribe")))),aa=({pub:t,user:s,profile:a,setStep:n,entry:i})=>{var g;const{setUser:o}=Me(),{getExperimentVariant:d,exposeExperiment:c}=fe(),[r,u]=v(""),[b,l]=v(!1),[_,E]=v(d("destination_account_creation_tos")!=="treatment_legal");q(()=>{c("destination_account_creation_tos")},[c]);const f=p=>{s||(be({user:p.body.user}),o(p.body.user)),p.body.requires_confirmation?(R(k.READER_ONBOARDING_PUB_SIGNUP_FAILED,{reason:"user_exists",entry:i}),l(!0)):(R(k.READER_ONBOARDING_PUB_SIGNUP_SUCCEEDED,{entry:i}),be({user:p.body.user}),n(m.CATEGORIES))},h=(g=d("destination_account_creation_tos"))!=null?g:"control";return e("div",{className:"pub-signup-step"},e("div",{className:"headings"},e(ce,{pub:t,size:84,linkify:!1,className:"pub-icon"}),e("h3",{className:"publication-title"},a?"Create an account to start reading":`Subscribe to ${t.name}`),e("p",{className:"publication-description"},a?`Create a Substack account to subscribe to ${a.name}`:t.editorial_bio||t.hero_text),e("p",{className:"publication-details"},a?`Author of ${t.name}`:Fe(t))),e(ge,{method:"post",action:"/api/v1/reader/signup/pub",loading:!1,autoLock:!0,onSuccess:f},e("p",null,e("label",{for:"email"},"Email"),e("input",{type:"email",name:"email","aria-label":"Email",value:r,tabIndex:0,onInput:p=>{u(p.target.value)},onChange:p=>{u(p.target.value)}}),e("input",{type:"hidden",name:"source",value:`${i}-reader-onboarding`}),e("input",{type:"hidden",name:"publication_id",value:t.id}),e("input",{type:"hidden",name:"visibility",value:"public"}),e("input",{type:"hidden",name:"noWelcomeEmail",value:"true"}),e("input",{type:"hidden",name:"first_url",value:_t}),e("input",{type:"hidden",name:"first_referrer",value:Nt}),e("input",{type:"hidden",name:"first_session_url",value:Et}),e("input",{type:"hidden",name:"first_session_referrer",value:St}),e("input",{type:"hidden",name:"current_url",value:vt}),e("input",{type:"hidden",name:"current_referrer",value:yt}),b&&e("div",{className:"error"},"Additional confirmation is required to complete your signup. Please"," ",e("a",{href:ke({for_pub:t.subdomain,email:r})},"login")," ","or click the confirmation link in your email.")),e("div",{id:"error-container"}),["treatment_legal","treatment_moderate"].includes(h)?e(z,{alignItems:"center",justifyContent:"space-between",paddingTop:64,gap:4},e(as,{checked:_,onCheckboxChange:p=>{E(p)}}),e(cs,{type:"submit",priority:"primary",disabled:!_||!r,style:{marginTop:12,marginBottom:4}},"Subscribe and continue"),e(L.B5,{weight:"light",color:"secondary"},"Already have a Substack account?"," ",e(L.B5,{as:"a",weight:"light",color:"secondary",href:ke({for_pub:t.subdomain}),target:"_blank",style:{textDecoration:"underline"}},"Sign in"))):e(Y,null,e("div",{className:"spacer"}),e("div",{className:"modal-ctas"},e("p",null,"Already have a Substack account?"," ",e("a",{href:ke({for_pub:t.subdomain})},"Sign in")),e("p",null,"By continuing, you agree to the"," ",e("a",{href:ut(),target:"_blank"},"Terms of Service")," ","and"," ",e("a",{href:ie(),target:"_blank"},"Privacy Policy")),e("button",{className:"button primary",type:"submit"},"Subscribe and continue")))))},na="_checkboxLabel_35khu_1",ia="_noMargin_35khu_5",at={checkboxLabel:na,noMargin:ia};function oa({user:t,setStep:s,entry:a,previousStepData:n,prefilledEmail:i,skipCategories:o=!1}){var I,x,V,U,Z;const{setUser:d}=Me(),[c,r]=v(i!=null?i:""),[u,b]=v(!1),[l,_]=v(!1);q(()=>{t&&!n[m.CATEGORIES]&&s(m.CATEGORIES)},[t,s,n]);const{getExperimentVariant:E,exposeExperiment:f}=fe(),h=E("reader_onboarding_tos"),[g,p]=v(h!=="treatment_checkbox");q(()=>{f("reader_onboarding_tos")},[f]);const S=P=>K(this,null,function*(){var O;if(P.body.userExists){b(!0);return}if(P.body.emailConfirmationRequired){_(!0);return}if(R(k.READER_ONBOARDING_SIGNUP_SUCCEEDED,{entry:a}),t||(be({user:P.body.user}),d(P.body.user)),n[m.CATEGORIES]){P.body.userExists?s(m.APP_UPSELL):s(m.PROFILE);const j=(O=n[m.CATEGORIES])==null?void 0:O.publications;j!=null&&j.length?(yield ee.post("/api/v1/bulk_signup").send({publications:j,visibility:"public",source:`${a}-reader-onboarding`,email:c}),R(k.READER_ONBOARDING_BULK_SUBSCRIBED,{entry:a,numberOfSubscriptions:j.length,recommendationsFrom:"categories"})):R(k.READER_ONBOARDING_BULK_SUBSCRIBE_SKIPPED,{entry:a,recommendationsFrom:"categories"})}else s(o?m.PROFILE:m.CATEGORIES)});if(l)return e(z,{className:"signup-step"},e(nt,{title:"Verify your email address"}),e(L.B3,null,"We just sent an email to ",e("strong",null,c),". Please check your inbox before continuing."),e(Ue,{flex:"grow"}),e("div",{className:"modal-ctas"},e(ls,{onClick:P=>{P.preventDefault(),_(!1)}},e(L,{as:"span",decoration:"hover-underline"},"Or edit your email address or try again."))));const N="Sign up to subscribe",y="Substack is the home for great writing.",T=(x=(I=n[m.CATEGORIES])==null?void 0:I.publications)!=null?x:[],A=(U=(V=n[m.CATEGORIES])==null?void 0:V.selectedCategoryIds)!=null?U:[];return e("div",{className:"signup-step"},e(nt,{title:N,subtitle:y}),e(ge,{method:"post",action:"/api/v1/reader/signup/just_email",loading:!1,autoLock:!0,onSuccess:S},e("input",{type:"hidden",name:"publicationIds",value:T}),e("input",{type:"hidden",name:"selectedCategoryIds",value:A}),e("p",null,e("label",{for:"email"},"Your email address"),e("input",{type:"email",name:"email","aria-label":"Email",value:c,tabIndex:0,onInput:P=>{r(P.target.value)},onChange:P=>{r(P.target.value)}}),u&&e("div",{className:"error"},"This email is already registered with Substack. Please"," ",e("a",{native:!0,href:Qe()},"sign in to continue"),"."),l&&e("div",{className:"error"},"We have sent you a confirmation email. Please check your inbox before continuing.")),e("div",{id:"error-container"}),["treatment_checkbox","treatment_above","treatment_below"].includes(h!=null?h:"control")?null:e("div",{className:"spacer"}),e(z,{gap:16},h==="treatment_above"?e(L.B3,{paddingTop:16},"By signing up, you agree to Substack’s"," ",e("a",{href:Ce(),target:"_blank"},"Publisher Agreement")," ","and acknowledge its"," ",e("a",{href:Ae(),target:"_blank"},"Information Collection Notice")," ","and"," ",e("a",{href:ie(),target:"_blank"},"Privacy Policy")):null,h==="treatment_checkbox"?e(ft,{as:"label",gap:8,className:at.checkboxLabel},e(fs,{as:"div",checked:g,onChange:P=>{p(P)},size:"sm"}),e(z,{flex:"grow"},e(L.B3,{as:"span"},"I agree to Substack’s"," ",e("a",{href:Ce(),target:"_blank"},"Publisher Agreement")," ","and acknowledge its"," ",e("a",{href:Ae(),target:"_blank"},"Information Collection Notice")," ","and"," ",e("a",{href:ie(),target:"_blank"},"Privacy Policy")))):null,e("button",{className:Q("button primary",{disabled:!g},["treatment_checkbox","treatment_above","treatment_below"].includes(h!=null?h:"control")&&at.noMargin),type:"submit",disabled:!g},n[m.CATEGORIES]&&((Z=n[m.CATEGORIES])!=null&&Z.publications.length)?"Subscribe and join Substack":"Get started"),["treatment_checkbox","treatment_above","treatment_below"].includes(h!=null?h:"control")?null:e(L.B3,null,"By continuing, you agree to the"," ",e("a",{href:ut(),target:"_blank"},"Terms of Service")," ","and"," ",e("a",{href:ie(),target:"_blank"},"Privacy Policy")),h==="treatment_below"?e(L.B3,null,"By signing up, you agree to Substack’s"," ",e("a",{href:Ce(),target:"_blank"},"Publisher Agreement")," ","and acknowledge its"," ",e("a",{href:Ae(),target:"_blank"},"Information Collection Notice")," ","and"," ",e("a",{href:ie(),target:"_blank"},"Privacy Policy")):null,e(L.B3,null,"Already have a Substack account?"," ",e("a",{native:!0,href:Qe()},"Sign in")))))}function nt({title:t,subtitle:s}){return e("div",{className:"headings"},e(_e,{className:"substack",width:68,height:68}),e("h3",null,t),s&&e("p",null,s))}const ra="_image_woi6m_1",la="_buttonGroup_woi6m_6",it={image:ra,buttonGroup:la},ca=({setStep:t,entry:s})=>{q(()=>{R(k.READER_ONBOARDING_START_WRITING_STEP_STARTED,{entry:s})});const a=()=>t(m.CREATE_PUBLICATION),n=()=>{R(k.READER_ONBOARDING_START_WRITING_STEP_SKIPPED,{entry:s}),t(m.APP_UPSELL)};return e(z,{alignItems:"center",gap:48,paddingBottom:120},e("img",{className:it.image,src:ct("/img/reader_onboarding/jobpage_penholder.png",150)}),e(z,{gap:4},e(L.H1,null,"Want to start writing on Substack?"),e(L.B3,{color:"secondary"},"Write posts, grow your audience, and make money on Substack")),e(z,{className:it.buttonGroup,gap:4},e(re,{size:"lg",onClick:a},"Create my publication"),e(re,{size:"lg",fill:"empty",priority:"secondary",onClick:n},"Skip for now")))},ua=({pub:t=null,profile:s,entry:a,setStep:n})=>e("div",{className:"welcome-step"},e("div",{className:"headings"},e(_e,{className:"substack",width:68,height:68}),e("h3",null,"You're all set up"),e("p",null,"You will now start receiving new posts from"," ",s?e(Y,null,e("b",null,s.name)," and the other writers"):t?e(Y,null,e("b",null,t.name)," and the other publications"):"the publications"," ","you subscribed to. Happy reading!")),e("div",{className:"spacer"}),e("div",{className:"spacer"}),e("div",{className:"modal-ctas"},e(X,{className:"primary",onClick:()=>{R(k.READER_ONBOARDING_START_READING_CLICKED,{entry:a}),n(m.EXIT)}},"Start reading",s?` ${s.name}`:t?` ${t.name}`:""))),da=({user:t,useProfilePrefix:s})=>t!=null&&t.has_linked_twitter?e(pa,{user:t,useProfilePrefix:s}):e(ma,null),ma=()=>{const[t,s]=v(!0);return e("div",{className:"inbox-access-form link-twitter"},e(Jt,{className:"onboarding-main-icon",width:38,height:43}),e("h2",null,"Find writers you follow"),e("section",{className:"twitter-description"},"Find writers you know on Substack, and let your Twitter followers find you. We’ll never post without your permission."),e("p",null,e("label",{className:"let-others-find-me"},e("input",{type:"checkbox",checked:t,onChange:()=>s(!t)}),"Let others find me via Twitter")),e(Ne,{linkType:"reader",discoverable:t,icon:!1,text:"Connect Twitter"}),e("a",{className:"skip",href:`${Ge()}/profile/fill`,native:!0},"Skip for now"))},pa=({user:t,useProfilePrefix:s})=>e(Pt,{user:t,onSignup:()=>{const a=t!=null&&t.profile_set_up_at?xe():`${Ge()}/profile/fill`;window.location=a},buttonText:"Continue",requireSignup:!1,needsEmailConfirm:!1,useProfilePrefix:s});class ze extends Qt{constructor(s,a){var n;super(s,a),this.setStep=this.setStep.bind(this),this.state.pub=s.pub||null,this.handleError=this.handleError.bind(this),this.state.previousStepData={},this.setPreviousStepData=this.setPreviousStepData.bind(this),this.state.skipRedirectOnExit=(n=s.skipRedirectOnExit)!=null?n:!1,this.redirect=s.redirect&&s.redirect!=="/"?s.redirect:null,this.state.appOnboardingTreatment=!1,this.state.step=s.step||this.getDefaultStep()}componentDidMount(){super.componentDidMount(),Be()&&(this.context.exposeExperiment("reader_onboarding_app_first"),this.inAppExperimentTreatment())}componentWillReceiveProps(s){this.setState({skipRedirectOnExit:s.skipRedirectOnExit,zIndex:s.zIndex,entry:s.entry,onBeforeClose:s.onBeforeClose})}getDefaultStep(){return this.state.appOnboardingTreatment?m.APP_UPSELL:m.CATEGORIES}inAppExperimentTreatment(){if(this.state.appOnboardingTreatment)return this.state.appOnboardingTreatment;const s=Be()&&["treatment","treatment_no_skip"].includes(this.context.getExperimentVariant("reader_onboarding_app_first"));return s&&this.setState({step:m.APP_UPSELL,appOnboardingTreatment:!0}),s}openForPub(s,a){this.setState({pub:s,profile:a,step:a?this.props.user?m.CATEGORIES:m.PUB_SIGNUP:m.PUB_LANDING}),this.open()}openToPubSignup(s){this.setState({pub:s,step:m.PUB_SIGNUP,profile:null}),this.open()}setStep(s){var a;if(s===m.APP_UPSELL&&this.state.appOnboardingTreatment&&this.state.previousStepData[m.APP_UPSELL]&&(s=m.WELCOME),R(k.READER_ONBOARDING_STEP_CHANGED,{from_step:this.state.step,to_step:s,modal:!0}),s===m.EXIT)if(this.state.skipRedirectOnExit)this.close();else{const n=(a=this.redirect)!=null?a:this.state.pub&&this.state.entry==="reader2"?le(this.state.pub):Yt();document.location.href=n}else setTimeout(()=>this.setState({step:s}),0)}setPreviousStepData(s,a){this.setState({previousStepData:H(w({},this.state.previousStepData),{[s]:a})})}getClassName(){return"reader-onboarding-modal wide"}onClose(){R(k.READER_ONBOARDING_MODAL_CLOSED,{entry:this.props.entry,step:this.state.step}),this.setStep(this.getDefaultStep())}onOpen(){var s;R(k.READER_ONBOARDING_MODAL_OPENED,{entry:this.props.entry,step:this.state.step,for_pub_id:(s=this.state.pub)==null?void 0:s.id})}handleError(s,{ignore:a=!1}={}){const{step:n}=this.state;console.error(`Error in reader onboarding ${n} step: ${s}`),R(k.READER_ONBOARDING_ERROR,{step:n,entry:this.props.entry,ignore:a}),a||this.setStep(m.ERROR)}renderStep(){const l=this.props,{ref:s}=l,a=Re(l,["ref"]),{step:n,open:i,pub:o,profile:d,previousStepData:c,appOnboardingTreatment:r}=this.state,u={setStep:this.setStep,handleError:this.handleError,close:this.close,setPreviousStepData:this.setPreviousStepData,appOnboardingTreatment:r},b=()=>{this.setPreviousStepData(m.APP_UPSELL,!0),r?this.setStep(m.CATEGORIES):this.setStep(m.WELCOME)};if(!i)return null;switch(n){case m.SIGNUP:return e(oa,H(w(w({},a),u),{previousStepData:c}));case m.PUB_LANDING:return e(sa,H(w(w({},a),u),{pub:o}));case m.PUB_SIGNUP:return e(aa,H(w(w({},a),u),{pub:o,profile:d!=null?d:null}));case m.CATEGORIES:return e(Ws,H(w(w({},a),u),{pub:o}));case m.PROFILE:return e(ta,w(w({},a),u));case m.START_WRITING:return e(ca,w(w({},a),u));case m.CREATE_PUBLICATION:return e(Zs,w(w({},a),u));case m.CREATE_PUBLICATION_SUCCESS:return e(Xs,H(w(w({},a),u),{previousStepData:c}));case m.ERROR:return e(ea,w(w({},a),u));case m.APP_UPSELL:return e(As,{onComplete:b});case m.WELCOME:default:return e(ua,H(w(w({},a),u),{pub:o,profile:d!=null?d:null}))}}renderChildren(){return e("div",{className:"reader-onboarding-modal-container"},this.renderStep())}}ze.contextType=es;const ba=qt((t,s)=>{const a=Me(),n=t.onBeforeClose,i=n?()=>n(a.user):void 0,o=H(w({},t),{onBeforeClose:i,user:a.user});return e(ze,H(w({},o),{ref:s}))}),Ha=Object.freeze(Object.defineProperty({__proto__:null,ReaderOnboardingModal:ze,ReaderOnboardingModalWithUserContext:ba,TwitterStage:da},Symbol.toStringTag,{value:"Module"}));export{As as A,Is as B,Rt as C,Ms as I,$a as L,Ls as P,ze as R,Ne as T,He as W,ea as a,Ws as b,oa as c,ta as d,ua as e,ca as f,Ma as g,Zs as h,Xs as i,Wa as j,da as k,Ha as l,Oe as m,m as o,Bs as u,Fa as w};
