티스토리 수익 글 보기
!function(){try{var e=”undefined”!=typeof window?window:”undefined”!=typeof global?global:”undefined”!=typeof globalThis?globalThis:”undefined”!=typeof self?self:{};e.SENTRY_RELEASE={id:”substack@cdd116e”};var n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]=”a6222adb-eb15-41d7-af8c-3f9ae349220b”,e._sentryDebugIdIdentifier=”sentry-dbid-a6222adb-eb15-41d7-af8c-3f9ae349220b”)}catch(e){}}();”use strict”;(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([[“90883”],{5109:function(e,n,t){t.d(n,{QL:()=>L,dx:()=>B});var r=t(69277),o=t(70408),i=t(32641),l=t(79785),a=t(4006),u=t(32485),s=t.n(u),d=t(69843),c=t.n(d),p=t(17402),m=t(75136),h=t(52820),f=t(84605),g=t(92905),b=t(86500),v=t(94729),y=t(12501),Y=t(35369),_=t(33727),w=t(60322),S=t(76977),C=t(20500),I=t(76171),k=t(28911),E=t(81203),F=t(94996),D=t(63136),N=t(11587),T=t(65842),A=t(61554),x=t(96400),P=t(39318),O=t(46058),R=t(16722);function U(){let e=(0,l._)([“”,” on Substack”]);return U=function(){return e},e}let B=(0,h.WR)((0,f.wr)(function(e){let{className:n,user:t,numVisibleSubscriptions:r,numSubscriptions:o,freeSignup:i,freeSignupEmail:l,needsPhoto:u,optionalPhoto:d,showHandle:h=!0,token:f,text:k,onSuccess:P,prepareData:B,pageTitle:L,primaryEligiblePublications:W,isPostInvite:H,complete:G,profileExists:q,onSkip:M,onEditReadVisibility:j,barebones:z,onEditRecommendations:V,numRecommendationsToMake:J,noSubscribeCta:K,style:Q,iString:X,iPlural:$,iTemplate:Z,showSocialHandle:ee,pub:en,autoSubmit:et,onAutoSubmitFailed:er}=e,[eo,ei]=(0,p.useState)(null),[el,ea]=(0,p.useState)(null),[eu,es]=(0,p.useState)(null),[ed,ec]=(0,p.useState)(t&&t.is_magic?t.email:null),[ep,em]=(0,p.useState)(“instagram”),[eh,ef]=(0,p.useState)(!!H&&!(null==t?void 0:t.has_publication)),[eg,eb]=(0,p.useState)(void 0),[ev,ey]=(0,p.useState)(!1),[eY,e_]=(0,p.useState)(!1),[ew,eS]=(0,p.useState)(!1),[eC,eI]=(0,p.useState)(void 0),[ek,eE]=(0,p.useState)(!!H||!!q),[eF,eD]=(0,p.useState)(!0),[eN,eT]=(0,p.useState)(!1),eA=(0,p.useRef)(null),ex=(0,p.useRef)(!1),{isLoading:eP,error:eO,refetch:eR,clearError:eU}=(0,y.st)({pathname:”/api/v1/user/profile”,method:”PUT”,auto:!1,deps:[]}),{trackInputFilled:eB,trackSubmitPressed:eL,trackError:eW}=(0,g.a)(“Signup Profile Form”),eH=eg||(0,O.w3)(t,{}),eG=eo||t&&t.name||””,eq=el||(null==t?void 0:t.handle)||””,eM=”string”==typeof eu?eu:t&&t.bio||””,ej=()=>t&&!t.is_magic&&t.name&&(!u||t.photo_url),ez=async(e,n)=>{try{let t=await (0,v.x6)(“/api/v1/publication/suggestion”),r=n||Z(U(),e);await (0,v.x6)(“/api/v1/publication”,{method:”post”,json:{name:e,subdomain:t.subdomain,hero_text:r,tos:!0}})}catch(e){(0,b.u4)(b.qY.DEFAULT_PUBLICATION_CREATION_FAILED),console.warn(“couldn’t set up a default publication”,e)}},eV=async()=>{let e=ed||l;if(!eN&&e){eT(!0);try{await (0,v.x6)(“/api/v1/email-login”,{method:”post”,json:{email:e,redirect:document.location.href}}),e_(!0)}catch(e){console.error(“Failed send login email:”,e)}eT(!1)}},eJ=async e=>{if(null==e||e.preventDefault(),eL(),eU(),!eA.current)return;let n=Object.fromEntries(new FormData(eA.current).entries());B&&B(n,e);let t=await eR({json:n});if(t instanceof Error){var r;eW(t),et&&!ev&&(ey(!0),null==er||er()),e_(!1),t instanceof v.fk&&(null==(r=t.response)?void 0:r.status)===401&&eV()}else{if(t.emailConfirmationRequired)return void eS(!0);eh&&await ez(eG,eM),P({body:t},n)}};(0,p.useEffect)(()=>{et&&!ex.current&&(ex.current=!0,ej()?eJ():null==er||er())},[]);let eK=”string”==typeof L||null===L?L:X(ej()?”Update your profile”:”Create your profile”),eQ=(!t||t.is_magic)&&!l&&!H,eX=!q&&!!V&&!c()(J)&&J>0,e$=H&&W&&(null==t?void 0:t.has_publication)&&W.length>1,eZ=”number”==typeof r&&!c()(o)&&o>0&&j,e0=!K&&!(t&&(t.is_subscribed||t.is_free_subscribed)||i),e1=H&&!(null==t?void 0:t.has_publication),e2=eP||eN;return(0,a.FD)(“div”,{className:s()(“profile-updater”,n),style:Q,children:[eK&&(0,a.Y)(D.EY.H4,{align:”left”,paddingBottom:20,children:eK}),(eH||u||d)&&(0,a.Y)(S.fI,{flex:”grow”,justifyContent:”center”,alignItems:”center”,children:(0,a.Y)(m.U,{user:{photo_url:eg||(null==t?void 0:t.photo_url)||null},onChangePhoto:e=>{let{photo_url:n}=e;return eb(n)}})}),(0,a.FD)(“form”,{ref:eA,className:”form”,onSubmit:eJ,noValidate:!0,children:[(0,a.FD)(S.VP,{gap:20,children:[(0,a.FD)(T.A0,{children:[(0,a.Y)(I.sb,{htmlFor:”name”,children:X(“Name”)}),en?(0,a.Y)(“input”,{type:”hidden”,name:”pub_id”,value:en.id}):null,(0,a.Y)(T.ks,{autoFocus:!0,type:”text”,className:”profile-name”,placeholder:X(“Type your name…”),name:”name”,id:”name”,value:eG,disabled:e2,onInput:e=>{ei(e.currentTarget.value)},onBlur:eB})]}),eQ&&(0,a.FD)(T.A0,{children:[(0,a.Y)(I.sb,{htmlFor:”email”,children:X(“Email”)}),(0,a.Y)(T.ks,{type:”email”,placeholder:X(“Enter your email address…”),name:”email”,value:null!=ed?ed:void 0,disabled:e2,onInput:e=>{ec(e.currentTarget.value)}})]}),h&&(0,a.FD)(T.A0,{children:[(0,a.Y)(I.JU,{htmlFor:”handle”,children:X(“Handle”)}),(0,a.Y)(T.ks,{type:”text”,className:”profile-name”,placeholder:X(“Type your handle…”),name:”handle”,id:”handle”,value:eq,disabled:e2,onInput:e=>{ea(e.currentTarget.value)}})]}),!z&&(0,a.FD)(T.A0,{children:[(0,a.Y)(I.JU,{htmlFor:”bio”,children:X(“Bio”)}),(0,a.Y)(N.T,{placeholder:X(“Say something about yourself…”),name:”bio”,id:”bio”,value:eM,disabled:e2,onInput:e=>{es(e.currentTarget.value)}}),H&&(0,a.Y)(C.EE,{align:”left”,children:X(“Tip: this will be shown at the bottom of your guest post”)})]}),H&&(0,a.Y)(“input”,{type:”hidden”,name:”needs_bio”,value:”true”}),ee&&(0,a.FD)(T.A0,{children:[(0,a.Y)(I.Sy,{htmlFor:”social”,hint:X(“Optional”),children:X(“Where else can you be found?”)}),(0,a.FD)(S.fI,{gap:8,wrap:”wrap”,children:[(0,a.Y)(S.fI,{flex:”grow”,minWidth:200,children:(0,a.FD)(F.I,{flex:”grow”,name:”social”,value:ep,disabled:e2,onChange:e=>{em(e.currentTarget.value)},children:[(0,a.Y)(F.K,{children:X(“Select a social network”)}),(0,a.Y)(“option”,{value:”twitter”,children:X(“Twitter”)}),(0,a.Y)(“option”,{value:”instagram”,children:X(“Instagram”)}),(0,a.Y)(“option”,{value:”tiktok”,children:X(“Tiktok”)}),(0,a.Y)(“option”,{value:”linkedin”,children:X(“LinkedIn”)}),(0,a.Y)(“option”,{value:”youtube”,children:X(“Youtube”)})]})}),(0,a.Y)(S.fI,{flex:”grow”,minWidth:200,children:(0,a.Y)(T.ks,{flex:”grow”,type:”text”,placeholder:X(“@yourhandle”),name:”socialHandle”,value:eC,disabled:e2,onInput:e=>{eI(e.currentTarget.value)}})})]})]}),e$&&(0,a.FD)(T.A0,{children:[(0,a.Y)(I.JU,{children:X(“Publication to display”)}),(0,a.Y)(_.Z,{padding:12,gap:12,children:W.map((e,n)=>{var t,r;return(0,a.Y)(I.JU,{htmlFor:”primary-radio-“.concat(e.id),children:(0,a.FD)(S.fI,{gap:12,alignItems:”center”,children:[(0,a.Y)(“input”,{id:”primary-radio-“.concat(e.id),type:”radio”,name:”primary_publication_user_id”,value:e.id,defaultChecked:0===n,disabled:e2}),(0,a.Y)(E.Nq,{pub:e.publication,size:24}),(0,a.Y)(D.EY.B3,{as:”span”,children:null!=(r=null==(t=e.publication)?void 0:t.name)?r:””})]})},e.id)})})]}),e0&&(0,a.FD)(S.Ye,{as:”label”,className:R.A.checkbox,gap:8,children:[(0,a.Y)(w.S,{size:”sm”,name:”free_signup”,defaultChecked:!0,checked:eF,onChange:e=>eD(e)}),(0,a.Y)(D.EY.B3,{as:”span”,children:X(“Subscribe to the newsletter”)})]}),e1&&(0,a.FD)(S.Ye,{as:”label”,className:R.A.checkbox,gap:8,children:[(0,a.Y)(w.S,{name:”create_publication”,id:”create-publication-checkbox”,checked:eh,onChange:e=>{ef(e)}}),(0,a.Y)(D.EY.B3,{as:”span”,children:X(“Create a Substack publication for me”)})]}),(0,a.Y)(“input”,{type:”hidden”,name:”confirmation_redirect_pathname”,value:document.location.pathname}),(0,a.Y)(“input”,{type:”hidden”,name:”photo_url”,value:null!=eH?eH:void 0}),(0,a.Y)(“input”,{type:”hidden”,name:”user_id”,value:(null==t?void 0:t.id)||””}),(0,a.Y)(“input”,{type:”hidden”,name:”needs_photo”,value:!!u}),(0,a.Y)(“input”,{type:”hidden”,name:”token”,value:f}),G&&(0,a.Y)(“input”,{type:”hidden”,name:”complete”,value:!0}),(0,a.FD)(“div”,{children:[eO&&!eY&&(0,a.Y)(“div”,{className:”error other-error”,children:(()=>{if(!eO)return null;if(eO instanceof v.fk){var e,n,t,r;return(null==(t=eO.body)||null==(n=t.errors)||null==(e=n[0])?void 0:e.msg)||(null==(r=eO.body)?void 0:r.error)||”Something went wrong”}return”Something went wrong”})()}),eY&&(0,a.FD)(D.EY,{as:”div”,translated:!0,className:”error other-error”,children:[“If you have an account with us, we’ve sent an email to “,(0,a.Y)(“b”,{children:x.TH.p(null!=ed?ed:””)}),” with a link that you can use to sign in.”]}),ew&&(0,a.Y)(“div”,{className:”error other-error”,children:X(“We have sent you a confirmation email. Please check your inbox before continuing.”)})]}),eZ&&(0,a.FD)(D.EY.B3,{as:”span”,children:[(0,a.Y)(D.Yq,{cursor:”pointer”,decoration:”underline”,onClick:j,children:$(“1 subscription”,”%1 subscriptions”,r)}),” “,X(“will be displayed on your profile.”)]}),eX&&(0,a.FD)(D.EY.B3,{as:”span”,children:[(0,a.Y)(D.Yq,{cursor:”pointer”,decoration:”underline”,onClick:V,children:$(“1 recommendation”,”%1 recommendations”,J)}),” “,X(“will be made on your publication.”)]})]}),(0,a.FD)(S.VP,{gap:8,children:[!t&&(0,a.Y)(S.VP,{className:R.A.tosCheckboxContainer,paddingBottom:12,children:(0,a.Y)(A.U,{checked:ek,onCheckboxChange:e=>eE(e),style:{display:”flex”}})}),(0,a.Y)(Y.$n,{priority:”primary”,disabled:!t&&!ek||e2,loading:e2,type:”submit”,children:k||X(“Save”)}),M&&(0,a.Y)(Y.$n,{priority:”secondary”,onClick:M||(()=>{}),disabled:e2,children:X(“Skip”)})]})]})]})}));function L(e){var{isOpen:n,onClose:t,contributor:l}=e,u=(0,i._)(e,[“isOpen”,”onClose”,”contributor”]);return(0,a.FD)(k.aF,{isOpen:n,onClose:()=>t(),width:490,children:[(0,a.Y)(k.rQ,{onClose:()=>t()}),(0,a.Y)(k.cw,{children:l?(0,a.Y)(W,(0,o._)((0,r._)({},u),{user:u.user,pub:u.pub,profile:u.profile,onSuccess:()=>t()})):(0,a.Y)(B,(0,o._)((0,r._)({},u),{onSuccess:()=>t()}))})]})}let W=e=>{let{profile:n,user:t,pub:r,onSuccess:o,isOwnProfile:i}=e,{iString:l}=(0,f.GO)(),[u,s]=(0,p.useState)(null),d=u||n&&n.photo_url,[c,h]=(0,p.useState)(n.name),[g,b]=(0,p.useState)(n.bio),{isLoading:_,error:w,refetch:S,clearError:C}=(0,y.st)({pathname:”/api/v1/publication/users/”.concat(n.id),method:”PATCH”,auto:!1,deps:[n.id]}),I=async e=>{e.preventDefault(),C();let n=Object.fromEntries(new FormData(e.currentTarget).entries());await S({json:n}) instanceof Error||null==o||o()};return(0,a.FD)(“div”,{className:”profile-updater”,children:[(0,a.Y)(“h2″,{className:”page-title profile-updater-title”,children:”Edit contributor profile”}),(0,a.Y)(“div”,{className:”profile-photo-wrap”,children:(0,a.Y)(m.U,{user:{photo_url:u||(null==n?void 0:n.photo_url)||null},onChangePhoto:e=>{let{photo_url:n}=e;return s(n)}})}),(0,a.FD)(“form”,{className:”form”,onSubmit:I,noValidate:!0,children:[(0,a.Y)(“input”,{type:”text”,className:”profile-name”,placeholder:”Contributor’s name…”,name:”name”,value:c,disabled:_,onInput:e=>{h(e.target.value)}}),(0,a.Y)(“textarea”,{className:”profile-bio”,placeholder:”Contributor’s bio…”,name:”bio”,value:g,disabled:_,onInput:e=>{b(e.target.value)}}),(0,a.Y)(“input”,{type:”hidden”,name:”photo_url”,value:d}),w&&(0,a.Y)(“div”,{className:”error other-error”,children:(()=>{if(!w)return null;if(w instanceof v.fk){var e,n,t,r;return(null==(t=w.body)||null==(n=t.errors)||null==(e=n[0])?void 0:e.msg)||(null==(r=w.body)?void 0:r.error)||”Something went wrong”}return”Something went wrong”})()}),(0,a.FD)(“span”,{className:”notice”,children:[(0,a.FD)(D.EY,{translated:!0,as:”p”,children:[(0,a.Y)(“b”,{children:”Note:”}),” This is a contributor profile, viewable by “,x.TH.p(r.name),”‘s readers.”]}),i&&(0,a.FD)(D.EY,{translated:!0,as:”p”,children:[“You may also edit your”,” “,(0,a.Y)(“a”,{“data-native”:!0,href:””.concat((0,P.gYq)(t)),children:”personal profile”}),”.”]})]}),(0,a.Y)(Y.$n,{priority:”primary”,type:”submit”,loading:_,disabled:_,children:l(“Update profile”)})]})]})}},70145:function(e,n,t){t.d(n,{ct:()=>c,ey:()=>d,jN:()=>p});var r=t(69277),o=t(70408),i=t(4006),l=t(17402),a=t(15734),u=t.n(a);let s=(0,l.createContext)({oauthAccessToken:null,isOAuthProvider:!1}),d=()=>(0,l.useContext)(s);function c(e){let n=n=>{let{oauthAccessToken:t}=d();return(0,i.Y)(e,(0,o._)((0,r._)({},n),{oauthAccessToken:t}))};return n.displayName=”WithOAuthEmbed(“.concat(e.displayName||e.name||”Component”,”)”),n}let p=()=>{let{oauthAccessToken:e}=d();return(0,l.useMemo)(()=>{let n=n=>(e&&n.set(“Authorization”,”Bearer “.concat(e)),n);return{get:e=>n(u().get(e)),post:e=>n(u().post(e)),put:e=>n(u().put(e)),delete:e=>n(u().delete(e)),patch:e=>n(u().patch(e))}},[e])}},62578:function(e,n,t){t.d(n,{N:()=>a});var r=t(17402),o=t(46271),i=t(13022),l=t(12501);function a(e){let{editingCommentUserId:n,postPublicationId:t}=e,a=(0,o.Jd)(),u=!!(0,i.Ay)(“enable_notes_admins”),[s,d]=(0,r.useState)(null),{result:c}=(0,l.st)({pathname:”/api/v1/publication_user/notes_permissions”,auto:u}),p=(0,r.useRef)(null!=n?n:null);function m(e){var n;p.current=null!=(n=null==e?void 0:e.id)?n:null,d(e)}(0,r.useEffect)(()=>{if(p.current&&!s&&c&&c.length>1){let e=c.find(e=>e.id===p.current);m(null!=e?e:null)}},[c,s]);let h=null!=c?c:[];return{postAsUserId:p,enableUserSwitcher:u,eligiblePostAsUsers:t?h.filter(e=>{var n;return(null==(n=e.primary_publication)?void 0:n.id)===t||e.id===(null==a?void 0:a.id)}):h,postAsUser:s,handleUpdatePostAsUser:m}}},56878:function(e,n,t){t.d(n,{g:()=>Q});var r=t(69277),o=t(70408),i=t(79785),l=t(4006),a=t(32485),u=t.n(a),s=t(75107),d=t(17402),c=t(15734),p=t.n(c),m=t(34746),h=t(5109),f=t(84605),g=t(70145),b=t(58292),v=t(62578),y=t(86500),Y=t(53928),_=t(94729),w=t(68349),S=t(57023),C=t(43954),I=t(25859),k=t(38093),E=t(28911),F=t(84843),D=t(63136),N=t(39318);function T(){let e=(0,i._)([“We’ve sent an email to “,”. Click the magic link or enter the code below:”]);return T=function(){return e},e}function A(){let e=(0,i._)([“We’ve sent an email to “,”. Click the magic link inside to continue.”]);return A=function(){return e},e}function x(e){var n,t;let{isOpen:r,onClose:o,user:i,pub:a,otpLoginEnabled:u,onboardingRedirect:s}=e,{iString:d,iTemplate:c}=(0,f.GO)();return(0,l.FD)(E.aF,{isOpen:r,onClose:o,className:”finish-magic-login-modal”,children:[(0,l.Y)(E.rQ,{icon:(0,l.Y)(F.qx,{icon:(0,l.Y)(C.A,{size:20})}),title:d(“Check your email to continue”),description:u?(0,l.Y)(D.EY,{children:c(T(),null!=(n=null==i?void 0:i.email)?n:”your email address”)}):(0,l.Y)(D.EY,{children:c(A(),null!=(t=null==i?void 0:i.email)?t:”your email address”)}),alignItems:”center”,onClose:o}),(0,l.Y)(E.cw,{children:u?(0,l.Y)(k.Z,{email:null==i?void 0:i.email,redirect:s||document.location.href}):(0,l.Y)(D.EY.B4,{align:”center”,color:”secondary”,decoration:”underline”,children:(0,l.Y)(I.Yq,{href:(0,N.a7q)({for_pub:a.subdomain,with_password:!0}),children:d(“Sign in with password instead”)})})})]})}var P=t(87087),O=t(89490),R=t(35369),U=t(60322),B=t(8149),L=t(76977),W=t(88774),H=t(81929),G=t(47784),q=t(36372),M=t(56689),j=t(56262),z=t(49807),V=t(82776);function J(){let e=(0,i._)([“Only “,” subscribers can comment on this post”]);return J=function(){return e},e}let K=”commentInput”,Q=(0,d.forwardRef)((e,n)=>{let{commentBeingEdited:t,parent:i,post:a,autoFocus:s,formClassName:c,saveEdit:m,onCancel:h,onSuccess:b,user:S,freeSignup:C,freeSignupEmail:I,pub:k,token:E,bannedFromNotes:F,alwaysShowButtons:D,mediaClipId:T}=e,{iString:A}=(0,f.GO)(),O=(0,q.d)(),R=(0,g.jN)(),{isOAuthProvider:U,oauthAccessToken:B}=(0,g.ey)(),[W,H]=(0,d.useState)(!1),[G,j]=(0,d.useState)(null),[J,Q]=(0,d.useState)(!1),[X,$]=(0,d.useState)(!1),{enableUserSwitcher:Z,eligiblePostAsUsers:ee,postAsUser:en,handleUpdatePostAsUser:et}=(0,v.N)({editingCommentUserId:null==t?void 0:t.user_id,postPublicationId:a.publication_id}),er=(0,d.useMemo)(()=>{if(“undefined”!=typeof localStorage){let e=JSON.parse(localStorage.getItem(K)||”{}”);if(e.postId===a.id)return{value:e.value,alsoShareToNotes:!!e.alsoShareToNotes};localStorage.removeItem(K)}},[]),el=(0,r._)({value:null==t?void 0:t.body,alsoShareToNotes:!1,loading:!1,error:null},er),[{value:ea,alsoShareToNotes:eu,loading:es,error:ed},ec]=(0,d.useState)(el),ep=e=>ec(n=>(0,o._)((0,r._)({},n),{value:e})),em=(0,d.useRef)(null),eh=(0,d.useRef)(null);(0,d.useImperativeHandle)(n,()=>({focus(){var e;null==(e=em.current)||e.focus()},getTextareaRef:()=>em}),[]),(0,d.useEffect)(()=>{if(s){var e;null==(e=em.current)||e.focus()}},[]);let ef=!(null==S?void 0:S.name),[eg,eb]=(0,d.useState)(!1),ev=async()=>{(0,y.u4)(y.qY.COMMENT_PAYWALL_SHOWN,{post_id:a.id,post_type:a.type,parent_id:null==i?void 0:i.id}),(0,Y.jN)(Y.ti.TRACK_PAYWALL_SHOWN),eb(!0)},ey=async()=>{(0,y.u4)(y.qY.FINISH_MAGIC_LOGIN_MODAL_SHOWN,{post_id:a.id,post_type:a.type,parent_id:null==i?void 0:i.id}),await eC(),$(!0)},[eY,e_]=(0,d.useState)(!1),ew=async()=>{(0,y.u4)(y.qY.PROFILE_UPDATER_SHOWN,{post_id:a.id,parent_id:null==i?void 0:i.id}),e_(!0)},eS=(0,d.useRef)(!1),eC=async()=>{if(!S)return void console.error(“cannot sendLoginEmail, user not defined”);if(!eS.current){eS.current=!0;try{var e;let n=await (0,_.x6)(“/api/v1/email-login”,{method:”POST”,json:{email:S.email,redirect:null==(e=document.location.href.split(“?”)[0])?void 0:e.split(“#”)[0]}});”optional”===n.verification_code&&(H(!0),n.onboarding_redirect&&j(n.onboarding_redirect))}catch(e){alert((0,w.uX)(e))}}},eI=()=>{localStorage.setItem(K,JSON.stringify({postId:a.id,value:ea,alsoShareToNotes:eu}))},ek=async()=>{if(t){ec(e=>(0,o._)((0,r._)({},e),{loading:!0}));try{let e=await (null==m?void 0:m(ea));eF(e)}catch(e){ec(n=>(0,o._)((0,r._)({},n),{loading:!1,error:e}))}}else eE()},eE=async function(){var e;let{profileUpdated:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(es)return;if(!(0,V.canPostComments)(S,a,k).canReply){eI(),await ev(),await (0,M.c)(600),ec(e=>(0,o._)((0,r._)({},e),{error:A(“Please sign in.”)}));return}if(ef&&!n){eI(),U?(Q(!0),ec(e=>(0,o._)((0,r._)({},e),{loading:!1,error:A(“Please set your profile name to comment.”)}))):(Q(!1),await ew(),await (0,M.c)(600),ec(e=>(0,o._)((0,r._)({},e),{error:A(“Please update your profile.”)})));return}ec(e=>(0,o._)((0,r._)({},e),{loading:!0}));let t={body:null==(e=em.current)?void 0:e.value,token:E,postAsUserId:null==en?void 0:en.id};T&&(t.mediaClipId=T);try{let e;if(eu){let n=await R.post(“/api/v1/comment/attachment”).send({type:”link”,url:i?(0,P.XB)(a,i,k):(0,N.wu9)(k,a)}),o=null==n?void 0:n.body;if(o){let n=(0,r._)({},t);n.attachmentIds=[o.id],e=await R.post(“/api/v1/comment/feed”).send(n)}else console.warn(“Error creating attachment”)}i&&(t.parent_id=i.id);let n=await R.post(“/api/v1/post/”.concat(a.id,”/comment”)).send(t);if(localStorage.removeItem(K),!(null==S?void 0:S.profile_set_up_at)&&!U){let{body:{count:e}}=await p().get(“/api/v1/user/profile_role_count”);if(e>=2){let e=(0,N.yRP)(“”.concat((0,N.Ewe)(),”/profile/start”),{commentProfileFlow:!0,next:(0,P.XB)(a,n.body,k)});return(0,w.V2)(e,{local_navigation:!1}),!1}}eF({notesComment:e,res:n})}catch(e){e.response&&403===e.response.statusCode&&(S&&S.is_magic?await ey():await ev()),ec(n=>(0,o._)((0,r._)({},n),{loading:!1,error:e}))}},eF=e=>{let{res:n,notesComment:t}=e;if(!1!==n){if(b&&!ef){if(eu&&t){let e=(0,z.Zgx)(t.body);O.popToast(()=>(0,l.Y)(q.y,{text:A(“Shared to Notes”),cta:A(“View now”),href:e}))}ep(“”),b(n.body)}else{let e=(0,P.PG)(a,k);U?(0,w.V2)((0,P.EQ)(a,k,null!=B?B:””)):window.location.pathname===e?window.location.reload():(0,w.V2)((0,P.PG)(a,k,eu?{feedCommentUrl:(0,z.Zgx)(n.body)}:{}))}ec(e=>(0,o._)((0,r._)({},e),{loading:!1}))}};return(0,l.FD)(L.pT,{“data-test-id”:”comment-input”,flex:”grow”,className:u()({comment:t}),children:[(0,l.Y)(“form”,{className:u()(“form-CkZ7Kt”,c),onSubmit:e=>{e.preventDefault(),ek()},ref:eh,children:(0,l.Y)(ei,{user:S,commentBeingEdited:t,post:a,pub:k,value:ea,bodyInputRef:em,onInput:e=>{let n=e.currentTarget.value;if(!(0,V.canPostComments)(S,a,k).canReply){e.preventDefault(),ev();return}ep(n)},onKeyDown:e=>{var n,t;if(null==S?void 0:S.is_magic){e&&e.preventDefault(),ey();return}if(!(0,V.canPostComments)(S,a,k).canReply){e.preventDefault(),ev();return}”Escape”===e.key&&(null==(n=em.current)?void 0:n.value.trim())===””?(null==(t=em.current)||t.blur(),null==h||h()):”Enter”===e.key&&e.metaKey&&ek()},bannedFromNotes:F,alsoShareToNotes:eu,onShareToNotesChange:()=>ec(e=>(0,o._)((0,r._)({},e),{alsoShareToNotes:!eu})),onCancel:()=>{h?h():ep(“”)},error:ed,loading:es,alwaysShowButtons:D,isReplying:!!i,showProfileSetupLinkOnError:J,enableUserSwitcher:Z,eligiblePostAsUsers:null!=ee?ee:[],postAsUser:en,handleUpdatePostAsUser:et})}),(0,l.Y)(eo,{user:S,freeSignup:C,freeSignupEmail:I,pub:k,post:a,token:E,isProfileUpdateModalOpen:eY,setIsProfileUpdateModalOpen:e_,isPaywallModalOpen:eg,setIsPaywallModalOpen:eb,onProfileUpdaterSuccess:e=>”boolean”!=typeof e||!!(e&&eE({profileUpdated:e}))}),(0,l.Y)(x,{isOpen:X,onClose:()=>$(!1),user:S,pub:k,otpLoginEnabled:W,onboardingRedirect:G})]})}),X=e=>{let{error:n,showProfileSetupLinkOnError:t}=e,{iString:r}=(0,f.GO)();if(!n)return null;let o=”string”==typeof n?n:(0,w.uX)(n,”Something went wrong.”);return(0,l.FD)(L.pT,{direction:”column”,gap:4,children:[(0,l.Y)(H.vw,{priority:”secondary”,theme:”error”,flex:”auto”,children:o}),t&&(0,l.Y)(D.EY.B3,{children:(0,l.Y)(“a”,{href:””.concat((0,N.Ewe)(),”/profile/edit”),target:”_blank”,children:r(“Set up profile”)})})]})},$=e=>{let{alsoShareToNotes:n,onChange:t}=e,{iString:r}=(0,f.GO)();return(0,l.FD)(L.pT,{as:”label”,gap:12,alignItems:”center”,justifyContent:”center”,children:[(0,l.Y)(U.S,{name:”also_feed”,checked:n,onChange:t}),(0,l.Y)(D.EY.B3,{color:”secondary”,children:r(“Also share to Notes”)})]})},Z=e=>{let{bodyInputRef:n,value:t,onInput:r,onKeyDown:o,iString:i,disabled:a}=e;return(0,l.Y)(G.A,{ref:n,name:”body”,placeholder:i(“Write a comment…”),defaultRows:4,maxRows:24,value:t||””,onInput:r,onKeyDown:o,className:”input-qHk4bN”,disabled:a,”aria-label”:i(“Write a comment…”)})},ee=e=>{let{isEditing:n,isReplying:t,bannedFromNotes:r,alsoShareToNotes:o,onShareToNotesChange:i,onCancel:a,loading:u,disableSubmit:s}=e;return(0,l.FD)(L.fI,{alignItems:”center”,justifyContent:”space-between”,children:[!n&&!r&&(0,l.Y)($,{alsoShareToNotes:o,onChange:i}),(0,l.FD)(en,{children:[(0,l.Y)(et,{onCancel:a}),(0,l.Y)(er,{isEditing:n,isReplying:t,loading:u,disabled:s})]})]})},en=e=>{let{children:n}=e;return(0,l.Y)(L.fI,{gap:8,justifyContent:”end”,flex:”grow”,children:n})},et=e=>{let{onCancel:n}=e,{iString:t}=(0,f.GO)();return(0,l.Y)(R.$n,{priority:”secondary”,onClick:n,children:t(“Cancel”)})},er=e=>{let{isEditing:n,isReplying:t,loading:r,disabled:o}=e,{iString:i}=(0,f.GO)();return(0,l.Y)(R.$n,{priority:”primary”,type:”submit”,loading:r,disabled:o,children:i(n?”Save”:t?”Reply”:”Post”)})},eo=e=>{let{user:n,freeSignup:t,freeSignupEmail:r,pub:o,post:i,token:a,isProfileUpdateModalOpen:u,setIsProfileUpdateModalOpen:s,isPaywallModalOpen:d,setIsPaywallModalOpen:c,onProfileUpdaterSuccess:p}=e,{iString:g,iTemplate:b}=(0,f.GO)();return(0,l.FD)(l.FK,{children:[(0,l.Y)(h.QL,{isOpen:u,onClose:e=>{s(!1),p(e)},user:n,freeSignup:t,freeSignupEmail:r,optionalPhoto:!0,token:a,text:g(“Save and post comment”)}),(0,l.Y)(m.EH,{isOpen:d,onClose:()=>c(!1),user:n,freeSignup:t,freeSignupEmail:r,publication:o,post:i,title:b(J(),(0,j.isFoundingAudience)(i.audience)?”founding”:”paid”),reauthenticationTitle:g(“To post a comment, please re-authenticate.”)})]})},ei=e=>{let{user:n,commentBeingEdited:t,post:r,pub:o,value:i,bodyInputRef:a,onInput:u,onKeyDown:s,bannedFromNotes:d,alsoShareToNotes:c,onShareToNotesChange:p,onCancel:m,error:h,loading:g,alwaysShowButtons:v,isReplying:y,showProfileSetupLinkOnError:Y,enableUserSwitcher:_,eligiblePostAsUsers:w,postAsUser:C,handleUpdatePostAsUser:I}=e,{iString:k}=(0,f.GO)(),E=!(null==i?void 0:i.trim());return(0,l.FD)(l.FK,{children:[_&&w&&w.length>1?(0,l.Y)(el,{user:null!=C?C:n,eligiblePostAsUsers:w,handleUpdatePostAsUser:I}):(0,l.Y)(b.bB,{size:32,user:n}),(0,l.FD)(L.I1,{flex:”grow”,gap:8,children:[t&&(0,l.Y)(S.P,{comment:t,post:r,pub:o,isCollapsed:!0,userBanned:!1,hideContextMenu:!0,onChange:()=>{},startEdit:()=>{},startReport:()=>{},openBan:()=>{}}),(0,l.Y)(Z,{bodyInputRef:a,value:i,onInput:u,onKeyDown:s,iString:k,disabled:g}),(0,l.Y)(X,{error:h,showProfileSetupLinkOnError:Y}),(0,l.Y)(B.N,{open:!E||!!v,children:(0,l.Y)(ee,{isReplying:y,isEditing:!!t,bannedFromNotes:d,alsoShareToNotes:c,onShareToNotesChange:p,onCancel:m,loading:g,disableSubmit:E})})]})]})};function el(e){let{user:n,eligiblePostAsUsers:t,handleUpdatePostAsUser:r}=e;return(0,l.Y)(W.W1,{trigger:(0,l.FD)(O.az,{className:”postAsUserSwitcher-IPqxbX”,children:[(0,l.Y)(b.bB,{size:32,user:n}),(0,l.Y)(s.A,{size:12,className:”postAsUserSwitcherIcon-Q4hhV0″})]}),children:t.map(e=>(0,l.Y)(W.Dr,{onClick:()=>r(e),children:e.name},e.id))})}},57023:function(e,n,t){t.d(n,{P:()=>k});var r=t(79785),o=t(4006),i=t(69843),l=t.n(i),a=t(17402),u=t(84777),s=t(84605),d=t(46271),c=t(27332),p=t(25859),m=t(58292),h=t(23294),f=t(42774),g=t(87087),b=t(89490),v=t(35369),y=t(76977),Y=t(63136),_=t(16291),w=t(82776),S=t(57324),C=t(70515);function I(){let e=(0,r._)([“Edited”]);return I=function(){return e},e}function k(e){let{post:n,pub:t,comment:r,isCollapsed:i,onProfileClick:l,userBanned:a,toggleCollapse:u,userPendingApproval:s,onChange:p,startEdit:m,startReport:f,openBan:g,hideContextMenu:b}=e,v=(0,d.Jd)();return(0,o.FD)(y.Ye,{children:[(0,o.FD)(P,{children:[(0,o.Y)(c.X6,{children:(0,o.FD)(c.qv,{children:[(0,o.Y)(E,{comment:r,onClick:l}),(0,o.Y)(F,{comment:r}),(0,o.Y)(N,{comment:r,post:n,pub:t}),(0,o.Y)(T,{comment:r})]})}),!i&&(0,o.Y)(x,{comment:r,userBanned:a,userPendingApproval:s}),(0,o.Y)(A,{comment:r,isCollapsed:i,toggleCollapse:u})]}),(0,o.Y)(O,{onClick:u}),!b&&(0,o.Y)(h.f,{comment:r,pub:t,post:n,user:v,onChange:p,startEdit:m,startReport:f,openBan:g,isCollapsed:i,toggleCollapse:u})]})}function E(e){let{comment:n,onClick:t}=e,{iString:r}=(0,s.GO)();if(n.name&&!l()(n.user_id))return(0,o.Y)(Y.EY.B4,{color:”primary”,display:”flex”,gap:6,children:(0,o.Y)(c.wF,{user:(0,g.DH)(n),onClick:t?()=>t(n):void 0})});let i=r(n.hidden?”Comment hidden”:n.deleted?”Comment deleted”:(0,C.Pp)(n)?”Anonymous”:”Comment removed”);return(0,o.Y)(Y.EY.B4,{color:”secondary”,children:i})}function F(e){var n,t,r,i,l;let{comment:a}=e,s=(null==(n=a.metadata)?void 0:n.author_on_other_pub)&&!a.metadata.is_author,d=(null==(r=a.metadata)||null==(t=r.author_on_other_pub)?void 0:t.id)&&!a.hidden;return s?d?(0,o.Y)(u.m,{pubId:null!=(l=null==(i=a.metadata.author_on_other_pub)?void 0:i.id)?l:0,trigger:(0,o.Y)(D,{comment:a})}):(0,o.Y)(D,{comment:a}):null}function D(e){var n;let{comment:t}=e,r=(0,d.Jd)();return t.metadata.author_on_other_pub&&r?(0,o.Y)(Y.EY.B4,{as:”span”,color:”secondary”,weight:”regular”,children:(0,o.Y)(p.RC,{publication:t.metadata.author_on_other_pub,utm_source:S.VU.substackFeedItem,utm_content:S.fL.commentMetadata,user:r,children:(0,o.FD)(“span”,{children:[(0,w.truncateText)(null==(n=t.metadata.author_on_other_pub)?void 0:n.name,32),” “]})})}):null}function N(e){let{comment:n,post:t,pub:r}=e;return(0,o.Y)(Y.Yq,{href:(0,g.XB)(t,n,r),onClick:e=>null===this||void 0===this?void 0:this.onDateClick(e),rel:”nofollow”,”data-native”:!0,color:”secondary”,title:c.M6.format((0,_.A)(n.date).toDate()),children:(0,o.Y)(m.iE,{timestamp:n.date})})}function T(e){let{comment:n}=e,{iTemplate:t}=(0,s.GO)();return n.edited_at?(0,o.Y)(Y.EY.B4,{as:”span”,fontStyle:”italic”,decoration:”hover-underline”,cursor:”pointer”,color:”tertiary”,title:c.M6.format((0,_.A)(n.edited_at).toDate()),children:t(I())}):null}function A(e){let{comment:n,toggleCollapse:t,isCollapsed:r}=e,{iString:i}=(0,s.GO)(),[l,u]=(0,a.useState)(!1);if(!r||!t)return null;let d=e=>{var n,t;return(null!=(n=e.children)?n:[]).length+(null!=(t=e.children)?t:[]).reduce((e,n)=>e+d(n),0)},c=d(n),p=i(l?”Loading”:c>0?”Show replies”:”Show comment”);return(0,o.Y)(y.fI,{children:(0,o.Y)(v.$n,{size:”sm”,flex:”auto”,priority:”secondary-outline”,maxHeight:28,onClick:()=>{u(!0),setTimeout(()=>{t(),u(!1)},0)},children:p})})}function x(e){let{comment:n,userBanned:t,userPendingApproval:r}=e,i=(0,f.Ud)({comment:n}),l=(0,f.Q0)({comment:n,userBanned:t}),a=(0,f.GL)({comment:n,userPendingApproval:r});return i||l||a?(0,o.FD)(f.FS,{children:[i,l,a]}):null}let P=(0,b.I4)({display:”flex”,direction:”column”,gap:4}),O=(0,b.I4)({display:”flex”,direction:”column”,flex:”grow”})},47784:function(e,n,t){t.d(n,{A:()=>m});var r=t(69277),o=t(70408),i=t(32641),l=t(4006),a=t(32485),u=t.n(a),s=t(17402),d=t(11587),c=t(65842),p=t(24311);let m=(0,s.forwardRef)((e,n)=>{var{className:t,error:a=!1,defaultRows:m=4,maxRows:h,value:f,onChange:g}=e,b=(0,i._)(e,[“className”,”error”,”defaultRows”,”maxRows”,”value”,”onChange”]);let{innerRef:v,combinedRef:y}=(0,c.N)(n),{value:Y,handleChange:_}=(0,d.u)({value:f,onChange:g}),w=(0,s.useCallback)(()=>{let e=v.current;if(!e)return;let n=window.getComputedStyle(e),t=parseInt(n.borderTopWidth)+parseInt(n.borderBottomWidth),r=parseInt(n.paddingTop)+parseInt(n.paddingBottom),o=parseInt(n.lineHeight);e.style.height=”auto”;let i=h?o*h+t+r:1/0,l=o*m+t+r,a=Math.min(Math.max(e.scrollHeight+t,l),i);e.style.height=””.concat(a,”px”)},[m,h]);return(0,s.useEffect)(()=>{w(),document.fonts&&”loaded”!==document.fonts.status&&document.fonts.ready.then(w)},[w,f]),(0,s.useEffect)(()=>(window.addEventListener(“resize”,w),()=>window.removeEventListener(“resize”,w)),[w]),(0,l.Y)(d.T,(0,o._)((0,r._)({},b),{value:Y,onChange:e=>{_(e),w()},rows:m,className:u()(t,p.A.autogrowing),ref:y,error:a}))})}}]);