/*! For license information please see 4213.93dec63f.js.LICENSE.txt */ (self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["4213"],{28657:function(e,t,n){"use strict";n.d(t,{Z:()=>i});let i={track:"track-e0UsGc",sm:"sm-NTA_dM",md:"md-t9_OLv",enabled:"enabled-z80ktY",checked:"checked-shaJTW",unchecked:"unchecked-xbnGJz",disabled:"disabled-HU7KbB",nub:"nub-sJTvJy",animate:"animate-HqAcLR",theme_accent:"theme_accent-jLc1V8",themeAccent:"theme_accent-jLc1V8",theme_success:"theme_success-OT7UOf",themeSuccess:"theme_success-OT7UOf",theme_error:"theme_error-iKFnqH",themeError:"theme_error-iKFnqH",theme_select:"theme_select-ZrBXM7",themeSelect:"theme_select-ZrBXM7"}},76201:function(e,t,n){"use strict";n.d(t,{Z:()=>i});let i={textEditor:"textEditor-tqxRQ1",isDragging:"isDragging-xLNam_",divider:"divider-ODsTIh",editorContent:"editorContent-EGQjBF",editorMenu:"editorMenu-DBTlov",editorMenuButton:"editorMenuButton-dkphLM",editorMenuButtonActive:"editorMenuButtonActive-EG6QVa",chatOverrides:"chatOverrides-loIrHB"}},47415:function(e,t,n){var i=n(29932);e.exports=function(e,t){return i(t,function(t){return e[t]})}},80059:function(e){e.exports=function(e){for(var t,n=[];!(t=e.next()).done;)n.push(t.value);return n}},47037:function(e,t,n){var i=n(44239),r=n(1469),o=n(37005);e.exports=function(e){return"string"==typeof e||!r(e)&&o(e)&&"[object String]"==i(e)}},1581:function(e,t,n){var i=n(62705),r=n(278),o=n(64160),l=n(98612),a=n(47037),d=n(80059),s=n(68776),c=n(21814),u=n(83140),p=n(52628),m=i?i.iterator:void 0;e.exports=function(e){if(!e)return[];if(l(e))return a(e)?u(e):r(e);if(m&&e[m])return d(e[m]());var t=o(e);return("[object Map]"==t?s:"[object Set]"==t?c:p)(e)}},52628:function(e,t,n){var i=n(47415),r=n(3674);e.exports=function(e){return null==e?[]:i(e,r(e))}},24830:function(e,t,n){"use strict";n.d(t,{Z:()=>i});let i=(0,n(36150).Z)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},96726:function(e,t,n){"use strict";n.d(t,{X:()=>d,h:()=>s});var i=n(16584),r=n(6400),o=n(98661),l=n(30396);let a=(0,r.createContext)(null);function d(e){let{root:t,children:n}=e,r=(0,l.sO)(t);return(0,i.BX)(a.Provider,{value:r,children:[n,!t&&(0,i.tZ)("div",{ref:r})]})}function s(e){let{children:t}=e,n=(0,l.qp)(a).current;return n?(0,o.createPortal)(t,n):null}},51214:function(e,t,n){"use strict";n.d(t,{Z:()=>a});var i=n(7409),r=n(99282),o=n(16584),l=n(64515);let a=e=>(0,o.BX)(l.l,(0,r._)((0,i._)({},e),{name:"SimpleCheckmarkIcon",svgParams:{height:100,width:100},children:[(0,o.tZ)("path",{d:"m40.9 70c-.5 0-1-.2-1.4-.6-.8-.8-.8-2 0-2.8l36.8-36.8c.8-.8 2-.8 2.8 0s.8 2 0 2.8l-36.8 36.8c-.4.4-.9.6-1.4.6z"}),(0,o.tZ)("path",{d:"m40.9 70c-.5 0-1-.2-1.4-.6l-16.5-16.5c-.8-.8-.8-2 0-2.8s2-.8 2.8 0l16.5 16.5c.8.8.8 2 0 2.8-.4.4-.9.6-1.4.6z"})]}))},3258:function(e,t,n){"use strict";n.d(t,{O7:()=>b,ZP:()=>f,wg:()=>g});var i=n(7409),r=n(99282),o=n(16584),l=n(94184),a=n.n(l),d=n(80569),s=n.n(d),c=n(85685),u=n(85095),p=n(33017),m=n(63651),h=n(51885);let f=/^(3270|6673|7778)$/.test(n.j)?null:e=>{let{id:t,type:n,name:i,url:r,photo_url:l,uuid:d,mentionText:s,isStatic:f=!1,isEditorContext:v=!1}=e;return f?(0,o.tZ)("span",{className:a()(h.Z.mention,h.Z.mentionStatic),"data-component-name":"MentionStatic",children:(0,o.tZ)("a",{href:(0,m.gpq)(n,t,i,r),children:i||"Substack user"})}):"user"===n?(0,o.tZ)(u.am,{children:(0,o.tZ)(c.ProfileHoverCard,{subject:{id:t,name:i||"Substack user",photo_url:l},utmSource:"mention",children:(0,o.tZ)("a",{className:h.Z.mention,href:v?void 0:(0,m.gpq)(n,t,i,r),target:"_blank",rel:"noopener","data-attrs":JSON.stringify({name:i,id:t,type:n,url:r,photo_url:l,uuid:d}),onClick:e=>e.stopPropagation(),"data-component-name":"MentionUser",children:null!=s?s:i})})}):"pub"===n?(0,o.tZ)(p.Sm,{publication_id:t,utmSource:"mention",children:(0,o.tZ)("a",{className:h.Z.mention,href:r,target:"_blank",rel:"noopener","data-attrs":JSON.stringify({name:i,id:t,type:n,url:v?void 0:(0,m.gpq)(n,t,i,r),uuid:d}),onClick:e=>e.stopPropagation(),"data-component-name":"MentionPub",children:null!=s?s:i})}):(0,o.tZ)("a",{className:h.Z.mention,target:"_blank",rel:"noopener",href:(0,m.gpq)(n,t,i,r),"data-attrs":JSON.stringify({name:i,id:t,type:n,url:r,photo_url:l,uuid:d}),"data-component-name":"Mention",children:null!=s?s:i})},v={},g=async function(e){let{pathname:t="/api/v1/posts/mention"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(v[e])return v[e];let{profiles:n,publications:o}=(await s().get(t).query({query:e,include_unmentionables:!0})).body,l=new Map;return n&&n.length&&l.set("Writers",n.map(e=>(0,r._)((0,i._)({},e),{type:"user",disabledReason:e.is_mentionable?void 0:"unmentionable"}))),o&&o.length&&l.set("Publications",null==o?void 0:o.map(e=>(0,r._)((0,i._)({},e),{type:"pub",url:(0,m.HQ5)({subdomain:e.subdomain}),photo_url:e.logo_url}))),v[e]=l,l},y=2987==n.j?{}:null,b=async function(e){let{pathname:t="/api/v1/community/mention"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="".concat(t,"-").concat(e);if(y[n])return y[n];let i=(await s().get(t).query({query:e,include_unmentionables:!0})).body.results,r=new Map;return i&&r.set("Writers",i.map(e=>{var t,n,i;return{id:e.user_id,type:"user",name:e.name,photo_url:null!==(t=e.photo_url)&&void 0!==t?t:void 0,bestseller_tier:null!==(n=e.bestseller_tier)&&void 0!==n?n:0,handle:null!==(i=e.handle)&&void 0!==i?i:void 0,disabledReason:e.is_mentionable?void 0:"unmentionable"}})),y[n]=r,r}},62298:function(e,t,n){"use strict";n.d(t,{H:()=>a});var i=n(16584),r=n(30396),o=n(98961),l=n(15771);function a(e){let{mediaUpload:t,selectedFile:n,onInputChange:a}=e,d=(0,r.sO)();return t||n?null:(0,i.BX)(l.hU,{priority:"tertiary",size:"md",onClick:()=>{var e;null===(e=d.current)||void 0===e||e.click()},children:[(0,i.tZ)(o.Z,{size:20}),(0,i.tZ)("input",{type:"file",accept:"video/*",multiple:!0,onChange:a,ref:d,style:{display:"none"}})]})}},5817:function(e,t,n){"use strict";n.r(t),n.d(t,{NoteComposer:()=>e8});var i=n(7409),r=n(99282),o=n(16584),l=n(30396),a=n(88897),d=n(39693),s=n.n(d),c=n(23279),u=n.n(c),p=n(24350),m=n.n(p),h=n(24830),f=n(56743),v=n(98961),g=n(65445),y=n(71375),b=n(887),Z=n(86374),_=n(95441),w=n(40647),k=n(60807),C=n(92291),T=n(77338),S=n(5952),x=n(25991),P=n(62298),E=n(25642),N=n(2891),B=n(16451),I=n(7882),U=n(68733),O=n(76721),M=n(68833),A=n(39556),L=n(48980),X=n(59176),z=n(98914),R=n(94874),j=n(71068),F=n(15771),D=n(19081),q=n(8594),H=n(44424),J=n(6490),V=n(98248),G=n(96302),W=n(58175),Y=n(70379),K=n(1669),$=n(55722),Q=n(75795),ee=n(98848),et=n(51127),en=n(38621),ei=n(89290),er=n(76405),eo=n(55679),el=n(94184),ea=n.n(el),ed=n(74386),es=n(74032),ec=n(79692);let eu=(0,n(36150).Z)("CodeXml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);var ep=n(28549),em=n(96592),eh=n(96726),ef=n(50515),ev=n(38664),eg=n(36349),ey=n(19512),eb=n(56070),eZ=n(18490),e_=n(24717),ew=n(56782),ek=n(43557),eC=n(75481),eT=n(61767),eS=n(55786),ex=n(32018),eP=n(91077),eE=n(87597),eN=n(55963),eB=n(22966);let eI=ek.Z.extend({addAttributes:()=>({schemaVersion:{default:"v1"}})}),eU=[eb.ZP,eZ.ZP,e_.ZP,ew.ZP,eC.ZP,eS.Z,ex.ZP,eP.Z,eE.ZP,eN.Z,eI,ey.ZP,eT.Z.configure({linkOnPaste:!1,openOnClick:!1,HTMLAttributes:{class:"note-link",rel:"nofollow ugc noopener",target:"_blank"}}),eB.T6];var eO=n(8357),eM=n(5749),eA=n(76201);function eL(e){let{defaultValue:t,onAddFiles:n,placeholder:r,disabled:a,onChange:d,isDragging:s,onDrop:c,onReturn:p,onEscape:m}=e,h=(0,l.Ye)(()=>u()(e=>{let{editor:t}=e,n=null;t&&!t.isEmpty&&(n=(0,eO.Z)(t.getJSON())),d(n)},100),[d]),f=(0,eo.jE)({content:t,editable:!a,autofocus:"end",extensions:[...eU,ei.ZP,et.Z,en.Z.configure({placeholder:r})],onUpdate:h,editorProps:{attributes:(0,i._)({class:eM.Z.feedCommentBodyInner},ef.J),handlePaste:(e,t)=>!!(t.clipboardData&&(0,eg.d)(t.clipboardData))&&(n(Array.from(t.clipboardData.files)),!0),handleDrop:(e,t)=>(c(t),!!t.defaultPrevented),handleKeyDown:(e,t)=>"Escape"===t.key&&(m(),!0),transformPasted:e=>new er.p2(function e(t){let n=t;return t.forEach((t,i,r)=>{let o=t.marks.find(e=>"link"===e.type.name),l=t;if(o){let{href:e}=o.attrs;e!==l.text&&(l=l.type.schema.text(e,t.marks))}else t.content&&(l=l.copy(e(t.content)));l!==t&&(n=n.replaceChild(r,l))}),n}(e.content),e.openStart,e.openEnd)}});return(0,o.BX)(D.tu,{className:eA.Z.textEditor,onClick:()=>{f&&!f.isFocused&&f.commands.focus()},children:[f&&(0,o.tZ)(eh.h,{children:(0,o.BX)(eo.NM,{className:eA.Z.editorMenu,editor:f,tippyOptions:{duration:50},shouldShow:e=>{let{from:t,to:n}=e;return t!==n&&!f.isEmpty},children:[(0,o.tZ)(eX,{Icon:ed.Z,active:f.isActive("bold"),onClick:()=>f.chain().focus().toggleBold().run()}),(0,o.tZ)(eX,{Icon:es.Z,active:f.isActive("italic"),onClick:()=>f.chain().focus().toggleItalic().run()}),(0,o.tZ)(eX,{Icon:ec.Z,active:f.isActive("strike"),onClick:()=>f.chain().focus().toggleStrike().run()}),(0,o.tZ)(eX,{Icon:eu,active:f.isActive("code"),onClick:()=>f.chain().focus().toggleCode().run()}),(0,o.tZ)(D.hs,{flex:"grow",className:eA.Z.divider}),(0,o.tZ)(eX,{Icon:ep.Z,active:f.isActive("bulletList"),onClick:()=>f.chain().focus().toggleBulletList().run()}),(0,o.tZ)(eX,{Icon:em.Z,active:f.isActive("orderedList"),onClick:()=>f.chain().focus().toggleOrderedList().run()}),(0,o.tZ)(D.hs,{flex:"grow",className:eA.Z.divider}),(0,o.tZ)(eX,{Icon:ev.kn,active:f.isActive("blockquote"),onClick:()=>f.chain().focus().toggleBlockquote().run()}),(0,o.tZ)(eX,{Icon:ev.MM,active:f.isActive("codeBlock"),onClick:()=>f.chain().focus().toggleCodeBlock().run()})]})}),(0,o.tZ)(eo.kg,{className:eA.Z.editorContent,editor:f,onKeyDown:e=>{"Enter"===e.key&&(e.metaKey||e.ctrlKey)&&p()}}),(0,o.tZ)(Q.t,{visible:s})]})}function eX(e){var{Icon:t,active:n}=e,l=(0,ee._)(e,["Icon","active"]);return(0,o.tZ)(F.kG,(0,r._)((0,i._)({className:ea()(eA.Z.editorMenuButton,n&&eA.Z.editorMenuButtonActive),resetCss:!0},l),{children:(0,o.tZ)(t,{size:18})}))}var ez=n(78446),eR=n(91400),ej=n(64172),eF=n(9738),eD=n(93608),eq=n(50364),eH=n(73943),eJ=n(1581),eV=n.n(eJ),eG=n(20521),eW=n(5889),eY=n(19834);function eK(e){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eU,i=(0,eY.Z)(e||""),r=i.split(/[\n\r]/g).filter(Boolean).map(e=>t(e,n));if(0===r.length||!r[0])return t(i,n);let o=r[0];if(o.content)for(let e of r.slice(1))e.content&&o.content.push(...e.content);return o}(e,a.AW)}var e$=n(33884),eQ=n(63651),e0=n(7083);let e1="unsent_composer_content_v3",e2={content:null,attachments:[]};function e8(e){var t,n,d,c,p,f,v,g,y,b,Z,C;let{onSuccess:T,onError:S,onClose:P,editComment:N,restackUrl:B,parentPostId:O,parentPubId:j,parentCommentId:F,initialText:q,initialFiles:H,tabId:J,surface:V,videoUploadId:G,mediaClipId:$,isPost:Q}=e,ee=(0,k.aF)(),et=function(){let e=(0,ej.Th)().result;if(!e)return!1;let{publicationUsers:t,publicationMap:n}=e;return t.some(e=>{var t;return null===(t=n.get(e.publication_id))||void 0===t?void 0:t.plans})}(),{iString:en}=(0,_.M1)(),ei={postId:null!==(d=null==N?void 0:N.post_id)&&void 0!==d?d:O,commentId:null!==(c=null==N?void 0:N.id)&&void 0!==c?c:F},er=N||q?e2:function(){var e,t,n;let{postId:i,commentId:r}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=r?"c:".concat(r):i?"p:".concat(i):"default";return null!==(n=null===(e=(null!==(t=(0,X.mM)(e1))&&void 0!==t?t:[]).find(e=>{let[t]=e;return t===o}))||void 0===e?void 0:e[1])&&void 0!==n?n:e2}(ei),[eo,el]=(0,l.eJ)(null!==(p=null==N?void 0:N.reply_minimum_role)&&void 0!==p?p:"everyone"),[ea,ed]=(0,l.eJ)(null!==(g=null!==(v=null!==(f=null==N?void 0:N.body_json)&&void 0!==f?f:(null==N?void 0:N.body)?eK(N.body):null)&&void 0!==v?v:q?eK(q):null)&&void 0!==g?g:er.content),es=ea?(0,a._4)(ea,eU):"",[ec,eu]=(0,l.eJ)(H?[]:(null!==(y=null==N?void 0:N.attachments)&&void 0!==y?y:er.attachments).filter(e=>"image"===e.type).map(e=>{let t={url:e.imageUrl,attachment:e};return t.promise=Promise.resolve(t),t})),[ep,em]=(0,l.eJ)(!1),[eh,ef]=(0,l.eJ)(!1),[ev,eg]=(0,l.eJ)(null!==(b=null==N?void 0:null===(t=N.attachments)||void 0===t?void 0:t.find(e=>"video"===e.type))&&void 0!==b?b:null),[ey,eb]=(0,l.eJ)(!1),[eZ,e_]=(0,l.eJ)(null),[ew,ek]=(0,l.eJ)(null),[eC,eT]=(0,l.eJ)(null),eS=(0,eF.h)({onComplete:e=>{let{mediaUpload:t}=e;(async e=>{let{mediaUpload:t}=e;try{let e=await (0,L.rd)("/api/v1/comment/attachment",{method:"POST",json:{mediaUploadId:t.id,type:"video"}});eg(e),eT(t)}catch(e){console.error(e)}})({mediaUpload:t})},onError:e=>{console.error("something went wrong",e),e4.popToast(t=>{var n;return(0,o.tZ)(Y.FN,(0,r._)((0,i._)({},t),{text:null!==(n=(0,z.zx)(e))&&void 0!==n?n:"Something went wrong. Please try again."}))})}}),ex=(0,eF.h)({onComplete:e=>{let{mediaUpload:t}=e;e_(e=>{var n,o;return e?(0,r._)((0,i._)({},e),{post:(0,r._)((0,i._)({},e.post),{videoUpload:t}),clipInfo:{startTime:0,duration:t.duration||5,isAutoSelected:!1},mediaClip:e.mediaClip?(0,r._)((0,i._)({},e.mediaClip),{assets:null==e?void 0:null===(o=e.mediaClip)||void 0===o?void 0:null===(n=o.assets)||void 0===n?void 0:n.map(e=>(0,r._)((0,i._)({},e),{mediaUpload:t}))}):null}):null}),eb(!1)},onError:()=>{eb(!1)}});(0,l.d4)(()=>{G&&(0,L.rd)("/api/v1/video/upload/".concat(G),{method:"GET"}).then(e=>{eT(e),eS.startPolling({mediaUpload:e})})},[G]);let eP=(0,l.I4)(e=>{ed(e)},[ei.postId,ei.commentId]),eE=eq.Zu,eN=eV()(es).length,eB=eN>eE,eI=e=>{let t=e.filter(e=>e.type.startsWith("image/"));if((null==t?void 0:t.length)>0){let e=6-ec.length;if(ec.length>0&&e<1){e4.popToast(e=>(0,o.tZ)(Y.FN,(0,r._)((0,i._)({},e),{text:"Notes cannot include more than ".concat(6," images."),Icon:h.Z})));return}let n=[...t].slice(0,e).map(e=>{let t={file:e,url:URL.createObjectURL(e)};return t.promise=tc(e).then(e=>(0,r._)((0,i._)({},t),{attachment:e})).catch(e=>(0,r._)((0,i._)({},t),{error:e})).then(e=>(eu(n=>n.map(n=>n===t?e:n)),e)),t});eu(e=>[...e,...n].slice(0,6))}};(0,l.d4)(()=>{(0,M.j)(M.FP.FEED_COMPOSER_SCREEN_VIEWED,{parent_post_id:O,parent_comment_id:F,edit_comment_id:null==N?void 0:N.id,restack_url:B,media_clip_id:$})},[]),(0,l.d4)(()=>{H&&eI(H)},[H]);let eO=async e=>{let t=await (0,A.O)(e.url,{trackingProps:{surface:"note"}}),n=tc(t).then(e=>(0,r._)((0,i._)({},o),{attachment:e}),e=>(0,r._)((0,i._)({},o),{error:e})).then(e=>(eu(t=>t.map(t=>t.promise===n?e:t)),e)),o=(0,r._)((0,i._)({},e),{url:URL.createObjectURL(t),promise:n});eu(t=>t.map(t=>t===e?o:t))},eM=(null!==(Z=null==N?void 0:N.attachments)&&void 0!==Z?Z:er.attachments).find(e=>!["missing","image"].includes(e.type)),eA=(0,I.ib)({pathname:"/api/v1/comment/attachment",method:"POST",initialResult:eM,deps:[]}),eX=null!=B?B:null===(n=(0,eW.gg)(es))||void 0===n?void 0:n.href;(0,l.d4)(()=>{$&&(0,L.rd)("/api/v1/comment/attachment",{method:"POST",json:{mediaClipId:$,type:"post"}}).then(e=>{var t,n,i,r,o;e_(e);let l=(null==e?void 0:e.type)==="post"&&!!(null===(n=e.mediaClip)||void 0===n?void 0:null===(t=n.assets)||void 0===t?void 0:t.find(e=>{var t;return(null===(t=e.mediaUpload)||void 0===t?void 0:t.state)!=="transcoded"}));if(eb(l),l){let t=null===(o=e.mediaClip)||void 0===o?void 0:null===(r=o.assets)||void 0===r?void 0:null===(i=r.find(e=>{var t;return(null===(t=e.mediaUpload)||void 0===t?void 0:t.state)!=="transcoded"}))||void 0===i?void 0:i.mediaUpload;t?ex.startPolling({mediaUpload:t}):eb(!1)}})},[$]);let eR=(0,l.Ye)(()=>{let e=null,t=eM?Promise.resolve(eM):null;return n=>(n!==e&&(e=n,n&&(t=eA.refetch({json:{url:n,type:"link",mediaClipId:n===B?$:void 0}}))),t)},[]),eD=(0,l.Ye)(()=>u()(eR,500),[eR]);(0,l.d4)(()=>{N&&eA.result||eD(null!=eX?eX:null)},[eX]);let eH=eA.result,eJ=(null==eH?void 0:eH.type)==="post"&&eH.postSelection?eH:null,{preferredTheme:eY}=(0,E.P$)(),[eQ,e8]=(0,l.eJ)(null!==(C=null==eJ?void 0:eJ.postSelectionTheme)&&void 0!==C?C:eY);(0,l.d4)(()=>{let e=[];for(let t of ec)t.attachment&&e.push(t.attachment);eH&&e.push(eH),to({content:ea,attachments:e},ei)},[ea,ec,eH]);let e4=(0,Y.pm)(),{create:e5,isLoading:e9,error:e7}=function(){let{editComment:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,I.ib)({pathname:e?"/api/v1/feed/comment/".concat(e.id):"/api/v1/comment/feed"});return{create:async n=>{let{bodyJson:i,parentPostId:r,parentPubId:o,parent_id:l,attachmentIds:a,tabId:d,surface:s,replyMinimumRole:c,notifySubscribersPubId:u,isPost:p,videoUploadId:m}=n;return p?await t.refetch({pathname:"/api/v1/publish/posts",method:"POST",json:{title:"Test Post",body:i,audience:"everyone",should_send_email:!1,video_upload_id:m}}):await t.refetch({pathname:e?"/api/v1/feed/comment/".concat(e.id):r?"/api/v1/post/".concat(r,"/comment"):"/api/v1/comment/feed",method:e?"PATCH":"POST",json:{bodyJson:i,parent_id:l,publication_id:o,attachmentIds:a,tabId:d,surface:s,replyMinimumRole:c,notifySubscribersPubId:u}})},error:t.error,isLoading:t.isLoading}}({editComment:N}),e3=F||O,te=!ev&&!!(ew||eC),tt=ep||eB||e9||te||!(es||ec.length>0||eH||ev||eZ),ti=(0,ez.N4)(),ta=function(){var e;let t=(0,ej.Th)().result;if(!t||!(null===(e=t.publicationUsers)||void 0===e?void 0:e.length))return[];let n=m()(t.publications,"id"),i=(0,eG.x)(t.publicationUsers.filter(e=>{let{role:t}=e;return["admin","contributor"].includes(t)}));return s()(i.map(e=>{let{publication_id:t}=e;return n[t]}))}(),{getConfigFor:tp}=(0,w.xR)(),tm=tp("enable_author_note_email_toggle"),tf=!tt&&tm&&ta.length>0&&!N&&!e3&&(!eH||"post"!==eH.type),tv=async()=>{if(tt)return;let e=null;if(tm&&eh&&!(e=await ti.confirm()))return;em(!0);let t=eA.result||eA.isLoading?await eR(null!=eX?eX:null):null,n=t instanceof Error?null:t,l=await Promise.all(ec.map(e=>e.promise)),a=[];for(let e of l)if(e){let{attachment:t}=e;t&&"missing"!==t.type&&a.push(t.id)}if(ev&&a.push(ev.id),eZ&&a.push(eZ.id),n&&"missing"!==n.type&&n.id!==(null==ev?void 0:ev.id)&&a.push(n.id),(null==n?void 0:n.type)==="post"&&n.postSelection&&eQ)try{await (0,L.rd)("/api/v1/comment/attachment/".concat(n.id,"/post_selection_theme"),{method:"PATCH",json:{theme_name:eQ.name,theme_alignment:eQ.alignment}})}catch(e){console.error(e),console.warn("Failed to update theme. Skipping.")}let d=await e5({bodyJson:ea,parentPostId:O,parentPubId:j,parent_id:F,attachmentIds:a.length>0?a:void 0,tabId:J,surface:V,replyMinimumRole:eo,notifySubscribersPubId:null!=e?e:void 0,isPost:Q,videoUploadId:null==ev?void 0:ev.media_upload_id});d instanceof Error?(e4.popToast(e=>(0,o.tZ)(Y.FN,(0,r._)((0,i._)({},e),{text:"Failed to share"}))),console.error(d),S&&S(d)):(to(null,ei),e4.popToast(e=>(0,o.tZ)(Y.FN,(0,r._)((0,i._)({},e),{text:N?"Note edited":e3?"Reply sent":B?"Restacked":"Note sent",cta:"View",href:(0,e$.Sg)(d)}))),T(d)),em(!1)},tg=(0,U.uk)({onAddFiles:e=>{let t=e.filter(e=>(0,U.zN)({fileType:e.type}));t.length>0&&t[0]&&ek(t[0]),eI(e)},acceptFile:e=>{let{fileType:t}=e;return(0,U.N1)({fileType:t})||!!(0,U.zN)({fileType:t})}});return ee?(0,o.BX)(e6,{onClose:e=>{e.stopPropagation(),P()},title:N?"Edit":e3?"Reply":B?"Restack":"New note",postLabel:N?"Save":eh?"Continue":"Post",hasImageAttachment:ec.length>0,onSubmit:e=>{e.preventDefault(),tv()},disabled:tt,onImageChange:e=>{if(ep)return;let{files:t}=e.currentTarget;eI(Array.from(t))},isDragging:tg.isDragging,videoUploadProps:{onVideoFileSelected:e=>{let t=()=>{e4.popToast(e=>(0,o.tZ)(Y.FN,(0,r._)((0,i._)({},e),{text:en("Something went wrong. Please try again.")})))};if(!e.currentTarget){console.warn("input change event had no currentTarget"),t();return}if(!(e.currentTarget instanceof HTMLInputElement)){console.warn("input change event currentTarget was not an input"),t();return}let n=e.currentTarget,{files:l}=n;if(!l){console.warn("input change event had no files"),t();return}if(l.length>1&&console.error("selected multiple files, at most 1 file allowed"),0===l.length){console.error("must select exactly one file"),t();return}ek(l[0]),n.value=""},mediaUpload:eC,selectedVideoFile:ew},menu:!et||F||O||(null==N?void 0:N.ancestor_path)?null:(0,o.tZ)(td,{value:eo,onChange:el}),composerFooterRow:tf?(0,o.tZ)(tn,{checked:eh,onChange:ef}):null,parentPostId:O,children:[(0,o.tZ)(ts,{modal:ti,userPubs:ta,initialSelectedPubId:1===ta.length&&ta[0]?ta[0].id:null}),(0,o.BX)(D.tu,{flex:"grow",children:[F&&(0,o.tZ)(tl,{commentId:F}),(0,o.BX)(D.hs,{gap:12,minWidth:0,children:[(0,o.tZ)(R.qE,{size:36,user:ee}),(0,o.BX)(D.tu,{gap:8,flex:"grow",className:e0.Z.editorContainer,minWidth:0,children:[(0,o.BX)(D.tu,{gap:2,flex:"fill",children:[(0,o.tZ)(x.Et,{user:ee}),(0,o.tZ)(eL,{defaultValue:ea,placeholder:e3?"Leave a reply...":B?"Write something...":"What's on your mind?",onChange:eP,onReturn:tv,onEscape:P,onDrop:tg.props.onDrop,onAddFiles:eI,disabled:ep})]}),(0,o.tZ)(tr,{files:ec,handleImageRemove:e=>{eu(t=>t.filter(t=>t!==e))},handleImageEdit:eO,onReorder:eu}),(0,o.tZ)(tu,{selectedVideoFile:ew,initialMediaUpload:eC,setSelectedVideoFile:ek,setVideoAttachment:eg,setInitialMediaUpload:eT}),(0,o.tZ)(th,{attachment:eZ,isLoading:ey,onRemove:()=>e_(null)}),(0,o.tZ)(th,{attachment:eH,isLoading:eA.isLoading,onRemove:()=>eA.setResult(null),onQuoteThemeChange:e8})]})]})]}),(eB||e7)&&(0,o.BX)(D.gq,{direction:"row-reverse",justifyContent:"space-between",paddingY:16,children:[eB&&(0,o.tZ)(W.xv.Meta,{color:eB?"error":void 0,children:eE-eN}),e7&&(0,o.tZ)(K.o,{error:e7})]})]}):null}function e6(e){let{title:t,postLabel:n,disabled:i,onImageChange:r,videoUploadProps:l,isDragging:a,onSubmit:d,onClose:s,children:c,menu:u,composerFooterRow:p,hasImageAttachment:m,parentPostId:h}=e,f=!!l.selectedVideoFile&&!l.mediaUpload||!!l.mediaUpload;return(0,o.BX)(N.T,{children:[(0,o.BX)(D.tu,{className:e0.Z.modalColumn,gap:16,paddingY:16,children:[(0,o.tZ)(e4,{title:t,postLabel:n,disabled:i,onClose:s,onSubmit:d}),(0,o.tZ)(e9,{children:u}),(0,o.tZ)(e7,{children:c}),null!=p?p:null,(0,o.tZ)(e3,{parentPostId:h,onImageChange:r,hasVideoFile:f,hasImageAttachment:m,videoUploadProps:l,disabled:i,postLabel:n,onClose:s,onSubmit:d})]}),(0,o.tZ)(Q.t,{visible:a})]})}function e4(e){return(0,eR.XA)()?(0,o.tZ)(e5,(0,i._)({},e)):null}function e5(e){let{title:t,postLabel:n,disabled:i,onClose:r,onSubmit:l}=e;return(0,o.BX)(D.gq,{borderBottom:"detail",alignItems:"center",paddingBottom:12,paddingX:16,gap:12,justifyContent:"space-between",children:[(0,o.tZ)(F.hU,{"aria-label":"Back",priority:"secondary",size:"sm",onClick:r,children:(0,o.tZ)(f.Z,{size:20})}),(0,o.tZ)(W.xv.H4,{flex:"grow",children:t}),(0,o.tZ)(F.zx,{disabled:i,size:"sm",onClick:l,children:n})]})}function e9(e){let{children:t}=e;return t?(0,o.tZ)(D.hs,{padding:16,paddingY:0,children:t}):null}function e7(e){let{children:t}=e;return(0,o.tZ)(D.tu,{paddingX:16,paddingBottom:0,style:{flex:"1 1 auto",flexDirection:"column",maxHeight:"80vh"},gap:12,overflowY:"auto",scrollBar:"hidden",children:t})}function e3(e){return(0,eR.XA)()?(0,o.tZ)(te,(0,i._)({},e)):(0,o.tZ)(tt,(0,i._)({},e))}function te(e){let{parentPostId:t,onImageChange:n,hasVideoFile:i,hasImageAttachment:r,videoUploadProps:l}=e;return t?null:(0,o.tZ)(D.tu,{paddingX:16,style:{flex:"0 0 auto"},minHeight:0,children:(0,o.BX)(D.gq,{alignItems:"start",justifyContent:"start",paddingX:4,paddingY:12,borderTop:"detail",sizing:"border-box",children:[n&&!i&&(0,o.tZ)(ti,{onChange:n}),!r&&(0,o.tZ)(P.H,{mediaUpload:l.mediaUpload,selectedFile:l.selectedVideoFile,onInputChange:l.onVideoFileSelected})]})})}function tt(e){let{parentPostId:t,onImageChange:n,hasVideoFile:i,hasImageAttachment:r,videoUploadProps:l,disabled:a,postLabel:d,onClose:s,onSubmit:c}=e,{iString:u}=(0,_.M1)();return(0,o.BX)(D.gq,{justifyContent:"space-between",paddingX:16,children:[(0,o.BX)(D.gq,{gap:4,children:[!t&&n&&!i&&(0,o.tZ)(ti,{onChange:n}),!t&&!r&&(0,o.tZ)(P.H,{mediaUpload:l.mediaUpload,selectedFile:l.selectedVideoFile,onInputChange:l.onVideoFileSelected})]}),(0,o.BX)(D.gq,{gap:12,children:[(0,o.tZ)(F.zx,{priority:"secondary",onClick:s,children:u("Cancel")}),(0,o.tZ)(F.zx,{disabled:a,onClick:c,children:d})]})]})}function tn(e){let{checked:t,onChange:n}=e,{iString:i}=(0,_.M1)();return(0,o.tZ)(D.tu,{paddingX:16,paddingTop:12,children:(0,o.BX)(D.hs,{gap:8,alignItems:"center",justifyContent:"space-between",bg:"secondary",flex:"grow",padding:12,radius:"sm",children:[(0,o.tZ)(W.xv.B4,{weight:"semibold",children:i("Also send as email")}),(0,o.tZ)(G.rs,{checked:t,onChange:e=>{(0,M.j)(M.FP.SEND_NOTE_AS_EMAIL_TOGGLE_CLICKED,{checked:e}),n(e)}})]})})}function ti(e){let{onChange:t,useVideo:n=!1}=e,i=(0,l.sO)();return(0,o.BX)(F.hU,{priority:"tertiary",onClick:()=>{var e;null===(e=i.current)||void 0===e||e.click()},children:[n?(0,o.tZ)(v.Z,{size:20}):(0,o.tZ)(g.Z,{size:20}),(0,o.tZ)("input",{type:"file",accept:"image/*,.heic",multiple:!0,onChange:e=>{t(e),i.current.value=""},ref:i,style:{display:"none"}})]})}function tr(e){let{files:t,handleImageRemove:n,handleImageEdit:l,onReorder:a}=e,d=t.map(e=>e.url);return 0===t.length?null:(0,o.tZ)(q.A,{items:d,onReorder:e=>{a(e.map(e=>t.find(t=>t.url===e)))},children:(0,o.tZ)(D.gq,{gap:8,wrap:"wrap",children:t.map((e,t)=>(0,o.tZ)(q.L,{item:e.url,index:t,children:t=>{var a,d;let{listeners:s}=t;return(0,o.BX)(D.hs,(0,r._)((0,i._)({className:e0.Z.imageContainer,position:"relative",outline:"detail",radius:"sm",overflow:"hidden",flex:"auto",cursor:"grab"},s),{children:[(null===(a=e.attachment)||void 0===a?void 0:a.type)==="image"&&e.attachment.imageUrl.endsWith(".heic")?(0,o.tZ)("img",{src:(0,eQ.zF4)(e.attachment.imageUrl)}):(null===(d=e.file)||void 0===d?void 0:d.type)==="image/heic"?null:(0,o.tZ)("img",{src:e.url}),(0,o.BX)(D.tu,{position:"absolute",alignItems:"end",gap:8,className:e0.Z.imageActions,children:[(0,o.tZ)(F.GI,{size:"sm",onClick:()=>n(e),children:(0,o.tZ)(y.Z,{size:20})}),(0,o.tZ)(F.GI,{size:"sm",onClick:()=>l(e),children:(0,o.tZ)(b.Z,{size:18})})]})]}))}},e.url))})})}function to(e){var t;let{postId:n,commentId:i}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=i?"c:".concat(i):n?"p:".concat(n):"default",o=null!==(t=(0,X.mM)(e1))&&void 0!==t?t:[],l=o.findIndex(e=>{let[t]=e;return t===r});l>=0&&o.splice(l,1),e&&(o.unshift([r,e]),o.splice(10)),(0,X.ex)(e1,o)}function tl(e){let{commentId:t}=e,{result:n}=(0,I.ib)({pathname:"/api/v1/reader/comment/".concat(t),deps:[t],auto:!0});return n?(0,o.tZ)(ta,{comment:n.item.comment,parentComments:n.item.parentComments}):null}function ta(e){let{comment:t,parentComments:n}=e,{truncatedBodyJson:i}=(0,O.Z)(t),r=n[n.length-1];return(0,o.BX)(D.hs,{className:eM.Z.replyUnit,gap:12,paddingBottom:20,children:[(0,o.tZ)(B.Zb,{user:t}),(0,o.BX)(D.tu,{minWidth:0,gap:16,flex:"grow",children:[(0,o.BX)(D.tu,{children:[(0,o.BX)(x.KF,{children:[(0,o.tZ)(W.xv,{as:"span",weight:"medium",children:t.name}),(0,o.tZ)($.o,{tier:t.user_bestseller_tier}),(0,o.tZ)(B.Ku,{timestamp:t.date})]}),r&&(0,o.BX)(W.xv.B5,{color:"secondary",children:["Replying to ",r.name]}),(0,o.tZ)(B.sP,{children:i&&(0,o.tZ)(T.x,{content:i,attachedLinks:(0,S.Bk)(t)})})]}),t.attachments&&(0,o.tZ)(C.yd,{readOnly:!0,attachments:t.attachments})]})]})}function td(e){let{value:t,onChange:n}=e,{iString:i}=(0,_.M1)();return(0,o.BX)(H.v2,{layerOptions:{placement:"bottom-start"},trigger:(0,o.tZ)(F.zx,{priority:"secondary",size:"sm",trailing:(0,o.tZ)(Z.Z,{}),children:"everyone"===t?"Anyone can reply":"free_subscriber"===t?"Subscriber replies":"Paid replies only"}),children:[(0,o.tZ)(H.yU,{children:i("Who can reply to this note?")}),(0,o.tZ)(H.sN,{onClick:()=>n("everyone"),children:i("Anyone")}),(0,o.tZ)(H.sN,{onClick:()=>n("paid_subscriber"),children:i("Only paid subscribers")})]})}function ts(e){var t;let{modal:n,userPubs:i,initialSelectedPubId:r}=e,[a,d]=(0,l.eJ)(r),s=(0,eR.XA)();return(0,o.tZ)(J.u_,{onClose:()=>n.handleCancel(null),isOpen:n.isConfirming,children:(0,o.BX)(D.tu,{padding:24,gap:24,children:[(0,o.BX)(D.tu,{gap:12,children:[(0,o.tZ)(W.xv.H3,{children:"Are you sure you want to notify your subscribers via email?"}),(0,o.BX)(W.xv.B3,{children:[1===i.length&&i[0]?"This note will be emailed to subscribers of ".concat(null!==(t=i[0].name)&&void 0!==t?t:"your publication","."):"Select which subscriber list to email this note to."," ","Only readers who opted into note notifications will receive it:"]}),1===i.length?void 0:(0,o.tZ)(D.tu,{padding:4,border:"detail",radius:"md",overflowY:"auto",style:{maxHeight:s?200:500},children:i.map(e=>(0,o.BX)(D.gq,{className:e0.Z.notifyConformModalPubRow,gap:12,alignItems:"center",flex:"fill",onClick:()=>{(0,M.j)(M.FP.SEND_NOTE_AS_EMAIL_PUBLICATION_SELECTED,{publication_id:e.id}),d(e.id)},padding:6,radius:"sm",cursor:"pointer",children:[(0,o.tZ)("input",{type:"radio",name:"selectedEmailPubId",checked:a===e.id,value:e.id}),(0,o.tZ)("img",{width:32,src:(0,eQ.zF4)(e.logo_url||"/img/substack-nomargin.png",32),className:(0,j.oB)({radius:"sm"})}),(0,o.tZ)(W.xv.B4,{overflow:"hidden",ellipsis:!0,children:e.name})]},e.id))})]}),(0,o.BX)(D.hs,{justifyContent:"end",gap:12,children:[(0,o.tZ)(F.zx,{priority:"secondary",onClick:()=>{(0,M.j)(M.FP.SEND_NOTE_AS_EMAIL_CONFIRMATION_REJECTED),n.handleCancel(null)},rounded:!0,children:"Cancel"}),(0,o.tZ)(F.zx,{disabled:null===a,onClick:()=>{a&&((0,M.j)(M.FP.SEND_NOTE_AS_EMAIL_CONFIRMATION_REJECTED,{publication_id:a}),n.handleConfirm(a))},rounded:!0,children:"Post"})]})]})})}async function tc(e){let t=await (0,z.Zk)(e),n=await (0,L.rd)("/api/v1/image",{method:"POST",json:{image:t}});return await (0,L.rd)("/api/v1/comment/attachment",{method:"POST",json:{url:n.url,type:"image"}})}function tu(e){let{selectedVideoFile:t,initialMediaUpload:n,setSelectedVideoFile:i,setVideoAttachment:r,setInitialMediaUpload:l}=e;if(!t&&!n)return null;let a=()=>{i(null),r(null),l(null)},d=async e=>{let{mediaUpload:t}=e;if(t)try{let e=await (0,L.rd)("/api/v1/comment/attachment",{method:"POST",json:{mediaUploadId:t.id,type:"video"}});r(e)}catch(e){console.error(e)}};return(0,o.tZ)(eD._,{file:t,initialMediaUpload:n,maxVideoDurationSeconds:eH.u,onCancel:a,onRemoveVideo:a,onComplete:d,videoPlayerProps:{surface:"feed",contentType:"comment",entityType:"comment",entityKey:"unknown"}})}function tp(){return(0,o.tZ)(D.hs,{className:e0.Z.postAttachment,height:120,bg:"secondary",border:"detail",radius:"md",alignItems:"center",justifyContent:"center",children:(0,o.tZ)(V.$j,{})})}function tm(e){let{onRemove:t,children:n}=e;return(0,o.BX)(D.tu,{position:"relative",children:[n,(0,o.tZ)(F.GI,{className:e0.Z.removeAttachment,position:"absolute",size:"sm",rounded:!0,onClick:t,zIndex:1,children:(0,o.tZ)(y.Z,{size:20})})]})}function th(e){let{attachment:t,isLoading:n,onRemove:i,onQuoteThemeChange:r}=e;return t||n?n?(0,o.tZ)(tp,{}):t?(0,o.tZ)(tm,{onRemove:i,children:(0,o.tZ)(C.yd,{attachments:[t],readOnly:!0,isComposing:!0,onQuoteThemeChange:r})}):null:null}},2891:function(e,t,n){"use strict";n.d(t,{T:()=>o});var i=n(16584),r=n(5749);function o(e){let{children:t}=e;return(0,i.tZ)("div",{className:r.Z.variables,children:t})}},36349:function(e,t,n){"use strict";function i(e){return Array.from(e.items).filter(e=>"file"===e.kind&&e.type.startsWith("image/")).length>0}n.d(t,{d:()=>i})},39556:function(e,t,n){"use strict";async function i(e,t){let{editImage:i}=await Promise.all([n.e("6666"),n.e("4769")]).then(n.bind(n,71682));return i(e,t)}async function r(e,t){let{editImageAndRehost:i}=await Promise.all([n.e("6666"),n.e("4769")]).then(n.bind(n,71682));return i(e,t)}n.d(t,{N:()=>r,O:()=>i})},10656:function(e,t,n){"use strict";n.d(t,{G5:()=>d,Iw:()=>u,Nm:()=>p,tS:()=>c,z_:()=>s});var i=n(16584),r=n(6400),o=n(95441),l=n(31582),a=n(84864);let d=(e,t)=>{var n,i,l;let a="undefined"!=typeof window&&null!==(l=null===(i=window._preloads)||void 0===i?void 0:null===(n=i.pub)||void 0===n?void 0:n.language)&&void 0!==l?l:"en";(0,r.render)((0,r.h)(o._7,{language:a,children:e}),t)},s=e=>e.podcast_url&&e.podcast_duration>0?"podcast":e.videoUpload&&e.videoUpload.duration&&e.videoUpload.duration>0?"video":"thread"===e.type?"thread":"newsletter",c=function(e){let t,n,r,o,d,{currency:s,totalAmount:c,discount:u,quantity:p=1,trial_end_override:m,noTrial:h=!1,recurring:f=!0,isGroupSubscription:v=!1,isUnlimitedGroupSubscription:g=!1,language:y="en"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{iString:b,iPlural:Z}=I18N.i(y);if(s||(s=e.currency),void 0!==c)t=c;else{let n=(0,l.$e)(e,s);if(void 0===n){var _;s=e.currency,n=null!==(_=e.amount)&&void 0!==_?_:0}t=n*p}let w=(0,a.centsToPriceString)(t,s);if(u&&!u.loading&&!u.error&&(u.percent_off||u.amount_off)){let e;u.percent_off?e=Math.round(t*(1-(u.percent_off_precise||u.percent_off)/100)):u.amount_off&&(e=Math.max(0,t-u.amount_off)),n=(0,a.centsToPriceString)(e,s)}let k=n||w;e.is_bitcoin?("month"===e.interval&&(r=Z("%2/1 month","%2/%1 months",e.interval_count,k)),"week"===e.interval&&(r=Z("%2/1 week","%2/%1 weeks",e.interval_count,k)),"day"===e.interval&&(r=Z("%2/1 day","%2/%1 days",e.interval_count,k)),"year"===e.interval&&(r=Z("%2/1 year","%2/%1 years",e.interval_count,k))):e&&f&&!v&&!g?("month"===e.interval&&(r=Z("%2 per month","%2 per %1 months",e.interval_count,k)),"week"===e.interval&&(r=Z("%2 per week","%2 per %1 weeks",e.interval_count,k)),"day"===e.interval&&(r=Z("%2 per day","%2 per %1 days",e.interval_count,k)),"year"===e.interval&&(r=Z("%2 per year","%2 per %1 years",e.interval_count,k))):!e||f||v||g?e&&f&&v&&!g?("month"===e.interval&&(r=Z("%2 for one month per person","%2 for %1 months per person",e.interval_count,k)),"week"===e.interval&&(r=Z("%2 for one week per person","%2 for %1 weeks per person",e.interval_count,k)),"day"===e.interval&&(r=Z("%2 for one day per person","%2 for %1 days per person",e.interval_count,k)),"year"===e.interval&&(r=Z("%2 for one year per person","%2 for %1 years per person",e.interval_count,k))):e&&f&&v&&g&&("month"===e.interval&&(r=Z("%2 for one month for unlimited seats","%2 for %1 months for unlimited seats",e.interval_count,k)),"week"===e.interval&&(r=Z("%2 for one week for unlimited seats","%2 for %1 weeks for unlimited seats",e.interval_count,k)),"day"===e.interval&&(r=Z("%2 for one day for unlimited seats","%2 for %1 days for unlimited seats",e.interval_count,k)),"year"===e.interval&&(r=Z("%2 for one year for unlimited seats","%2 for %1 years for unlimited seats",e.interval_count,k))):("month"===e.interval&&(r=Z("%2 for one month","%2 for %1 months",e.interval_count,k)),"week"===e.interval&&(r=Z("%2 for one week","%2 for %1 weeks",e.interval_count,k)),"day"===e.interval&&(r=Z("%2 for one day","%2 for %1 days",e.interval_count,k)),"year"===e.interval&&(r=Z("%2 for one year","%2 for %1 years",e.interval_count,k)));let C=Math.max(0,"trial_period_days"in e&&e.trial_period_days||0,u&&u.trial_period_days||0,m?Math.ceil((m-Date.now()/1e3)/60/60/24):0);if(!h&&C>0&&(o=Z("1 day free trial","%1 day free trial",C)),u&&n&&f&&"forever"!==u.duration){let t="once"===u.duration?1:u.duration_in_months/("year"===e.interval?12:1)*e.interval_count;"month"===e.interval&&(d=Z("for first month","for first %1 months",t)),"week"===e.interval&&(d=Z("for first week","for first %1 weeks",t)),"day"===e.interval&&(d=Z("for first day","for first %1 days",t)),"year"===e.interval&&(d=Z("for first year","for first %1 years",t))}return u&&u.loading?(0,i.BX)(i.HY,{children:[r," ",(0,i.BX)("span",{className:"discount-price",children:[" (",b("coupon loading"),")"]})]}):u&&u.error?(0,i.BX)(i.HY,{children:[r," ",(0,i.BX)("span",{className:"discount-price error",children:[" (",b("coupon invalid or expired"),")"]})]}):n?(0,i.BX)(i.HY,{children:[(0,i.tZ)("span",{className:"crossed-out",children:w})," ",(0,i.BX)("span",{className:"discount-price",children:[r," ",d?"(".concat(d,") "):"",o]})]}):(0,i.BX)(i.HY,{children:[r," ",o]})};async function u(e){let{timeout:t=5e3}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=document.createElement("video");n.volume=0;let i=!1,r=Promise.race([new Promise(e=>{n.onloadedmetadata=()=>{n.onloadedmetadata=null,n.duration===1/0?(n.currentTime=Number.MAX_SAFE_INTEGER,n.ontimeupdate=()=>{n.ontimeupdate=null,i=!0,e(n.duration),n.currentTime=0}):e(n.duration)},n.onerror=t=>{i=!0;let n=null;"string"==typeof t?n=t:t.target&&"error"in t.target&&(n=t.target.error),e({is_error:!0,err:n})}}),new Promise(e=>{setTimeout(()=>{i||e({is_error:!0,err:Error("Blob duration fetching timed out")})},t)})]);try{n.src="string"==typeof e||"string"==typeof e?e:window.URL.createObjectURL(e)}catch(e){return{is_error:!0,err:e}}return r}let p=(e,t)=>{let{decimals:n=0}=t||{};return Math.round(e*Math.pow(10,n))/Math.pow(10,n)}},96302:function(e,t,n){"use strict";n.d(t,{ZP:()=>g,rs:()=>h});var i=n(7409),r=n(99282),o=n(98848),l=n(16584),a=n(59278),d=n(94184),s=n.n(d);n(98661);var c=n(95441),u=n(71068);n(58175);var p=n(28657);let m=e=>{var{children:t,size:n}=e,d=(0,o._)(e,["children","size"]);let{iString:s}=(0,c.M1)();return(0,l.tZ)(a.r,(0,r._)((0,i._)({"aria-label":s("Toggle setting")},d),{onClick:e=>{e.stopPropagation()},children:t}))},h=e=>{var{checked:t,disabled:n,size:a="md",theme:d="accent",leading:c,trailing:u}=e,h=(0,o._)(e,["checked","disabled","size","theme","leading","trailing"]);return(0,l.BX)(v,{children:[c&&c,(0,l.tZ)(m,(0,r._)((0,i._)({checked:t,disabled:n,className:s()(p.Z.track,n?p.Z.disabled:p.Z.enabled,t?p.Z.checked:p.Z.unchecked,p.Z[a],p.Z["theme_".concat(d)])},h),{children:(0,l.tZ)(f,{className:s()(p.Z.nub,n?p.Z.disabled:p.Z.enabled,t?p.Z.checked:p.Z.unchecked,p.Z[a])})})),u&&u]})},f=e=>{let{className:t}=e;return(0,l.tZ)(u.xu,{"aria-hidden":"true",className:t})},v=(0,u.zo)({display:"flex",justifyContent:"center",alignItems:"center",gap:8}),g=/^(1612|3270|4153|6673|7778)$/.test(n.j)?null:h},75795:function(e,t,n){"use strict";n.d(t,{t:()=>c});var i=n(16584),r=n(94184),o=n.n(r);let l=(0,n(36150).Z)("CircleArrowDown",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"m8 12 4 4 4-4",key:"k98ssh"}]]);var a=n(19081),d=n(58175);let s={outer:"outer-cgmpdg",blur:"blur-gBxOTe",visible:"visible-noUyc6",icon:"icon-mx19LD"};function c(e){let{visible:t=!1,label:n="Drop file here to upload",blur:r=!0,className:c}=e;return(0,i.BX)(a.tu,{className:o()(t&&s.visible,r&&s.blur,s.outer,c),alignItems:"center",justifyContent:"center",gap:12,children:[(0,i.tZ)(l,{size:32,stroke:"var(--color-utility-white)",className:o()(t&&s.visible,s.icon)}),n&&(0,i.tZ)(d.xv.B3,{weight:"regular",color:"white",children:n})]})}},78446:function(e,t,n){"use strict";n.d(t,{N4:()=>a,sm:()=>d});var i=n(16584),r=n(30396),o=n(15771),l=n(15562);function a(){let[e,t]=(0,r.eJ)(null);return{confirm:()=>new Promise((n,i)=>{e&&i(Error("Already confirming.")),t({resolve:n,reject:i})}),isConfirming:!!e,handleConfirm:n=>{t(null),null==e||e.resolve(n)},handleCancel:n=>{t(null),null==e||e.resolve(n)}}}function d(e){let{title:t,body:n,cancelLabel:r="Cancel",confirmLabel:a="Confirm",modal:d}=e;return(0,i.tZ)(l.W,{isOpen:d.isConfirming,onClose:()=>d.handleCancel(!1),title:t,description:n,primaryButton:(0,i.tZ)(o.zx,{priority:"destructive",onClick:()=>d.handleConfirm(!0),children:a}),secondaryButton:(0,i.tZ)(o.zx,{priority:"secondary",onClick:()=>d.handleCancel(!1),children:r})})}},93608:function(e,t,n){"use strict";n.d(t,{_:()=>g});var i=n(7409),r=n(99282),o=n(16584),l=n(30396),a=n(71375),d=n(82061),s=n(98914),c=n(98422),u=n(80026),p=n(98248),m=n(70379),h=n(76820),f=n(9738);let v={videoPlaceholder:"videoPlaceholder-Z0QT3t",remove:"remove-Gneeir",loader:"loader-R9PbTT"};function g(e){let{file:t,initialMediaUpload:n,onCancel:g,onRemoveVideo:b,onComplete:Z,maxVideoDurationSeconds:_,videoPlayerProps:w}=e,k=(0,l.sO)(null),{isMobile:C}=(0,c.v9)(),[T,S]=(0,l.eJ)(!1),[x,P]=(0,l.eJ)(null!=n?n:null),[E,N]=(0,l.eJ)(null),B=(0,m.pm)(),I=()=>{P(null),S(!1),N(null)},U=(0,f.h)({onComplete:e=>{let{mediaUpload:t}=e;P(t),Z({mediaUpload:t})},onError:e=>{console.error("something went wrong",e),I(),B.popToast(t=>{var n;return(0,o.tZ)(m.FN,(0,r._)((0,i._)({},t),{text:null!==(n=(0,s.zx)(e))&&void 0!==n?n:"Something went wrong. Please try again."}))})}});if((0,l.d4)(()=>{if(!t)return;let e=k.current;if(!e){console.error("Video not found");return}return e.src=URL.createObjectURL(t),()=>{URL.revokeObjectURL(e.src)}},[t]),(0,l.d4)(()=>{P(n)},[n]),!t&&!x)return null;let O=()=>{U.cancel(),P(null),S(!1),N(null),g()};if(!t&&x&&"uploaded"===x.state)return(0,o.tZ)(y,{mediaUpload:x});if(x&&"transcoded"===x.state)return(0,o.tZ)(u.gq,{wrap:"wrap",children:(0,o.BX)(u.gq,{position:"relative",children:[(0,o.tZ)(h.Jl,{mediaUpload:x,videoPlayerProps:w,composing:!0}),(0,o.tZ)(u.GI,{onClick:()=>{U.cancel(),P(null),S(!1),N(null),b()},priority:"primary",position:"absolute",className:v.remove,rounded:!0,size:"sm",children:(0,o.tZ)(a.Z,{size:"20"})})]})});let M=C?h.YQ:h.PJ;return(0,o.BX)(u.gq,{wrap:"wrap",position:"relative",children:[(0,o.tZ)(d.nP,{initialFile:t,maxVideoDurationSeconds:_,onVideoTooLong:()=>{B.popToast(e=>(0,o.tZ)(m.FN,(0,r._)((0,i._)({},e),{text:"Video is too long. Maximum duration is ".concat(_," seconds.")}))),O()},videoFeature:"hero",mediaType:"video",onProgress:e=>{let{percentComplete:t}=e;N(t)},onUpload:e=>{S(!0);let t=e.mediaUpload;P(t),U.startPolling({mediaUpload:t})},setPostId:null,onUploadCanceled:()=>{O()}}),(0,o.BX)(u.gq,{position:"relative",radius:"md",outline:"detail",bg:"secondary",overflow:"hidden",children:[(0,o.tZ)("video",{ref:k,className:v.videoPlaceholder,style:{maxHeight:"".concat(M,"px"),maxWidth:"".concat(M,"px")}}),(0,o.BX)(u.tu,{position:"absolute",inset:0,justifyContent:"center",alignItems:"center",children:[(0,o.tZ)(u.GI,{priority:"primary",rounded:!0,size:"lg",onClick:()=>{O()},children:(0,o.tZ)(a.Z,{size:20})}),(0,o.tZ)(u.xu,{position:"absolute",style:{pointerEvents:"none"},children:T||E&&E>=1?(0,o.tZ)(p.$j,{size:40,media:!0}):(0,o.tZ)(p.Hl,{percent:null!=E?E:0,size:40,media:!0,className:v.loader})})]})]})]})}let y=e=>{var t,n;let{mediaUpload:r}=e,l=null!==(t=r.width)&&void 0!==t?t:640,d=null!==(n=r.height)&&void 0!==n?n:360,s=d>l;return(0,o.BX)(u.gq,{alignItems:"center",bg:"secondary",justifyContent:"center",radius:"md",position:"relative",style:(0,i._)({aspectRatio:"".concat(l," / ").concat(d)},s?{height:400,alignSelf:"flex-start"}:{width:"100%"}),children:[(0,o.tZ)(u.GI,{priority:"primary",rounded:!0,size:"lg",disabled:!0,children:(0,o.tZ)(a.Z,{size:20})}),(0,o.tZ)(u.xu,{position:"absolute",style:{pointerEvents:"none"},children:(0,o.tZ)(p.$j,{size:40,media:!0})})]})}},9738:function(e,t,n){"use strict";n.d(t,{h:()=>o});var i=n(30396),r=n(48980);function o(e){let{onComplete:t,onError:n}=e,[o,l]=(0,i.eJ)({mediaState:"waitingForUpload",mediaUpload:null}),a=(0,i.I4)(async()=>{"polling"===o.mediaState&&o.pollTranscodeTimer&&clearTimeout(o.pollTranscodeTimer)},[o]),d=async()=>{if("polling"!==o.mediaState){console.warn("pollForCompletion called, state must be uploaded|polling but was",o.mediaState);let e=Error("pollForCompletion called, state must be uploaded|polling but was [".concat(o.mediaState,"]"));l({mediaState:"error",mediaUpload:o.mediaUpload,error:e}),n({err:e});return}try{let e=await (0,r.rd)("/api/v1/video/upload/".concat(o.mediaUpload.id),{method:"GET"});switch(e.state){case"error":{let t=Error("media upload was in error state");l({mediaState:"error",mediaUpload:e,error:t}),n({err:t});break}case"cancelled":{let t=Error("media upload was in canceled state");l({mediaState:"error",mediaUpload:e,error:t}),n({err:t});break}case"transcoded":l({mediaState:"complete",mediaUpload:e}),t({mediaUpload:e});break;case"created":case"uploaded":{let e=window.setTimeout(()=>{d()},5e3);l(t=>"polling"!==t.mediaState?(console.warn("in pollForCompletion, prev.mediaState should be polling but was ",t.mediaState),t):{mediaState:"polling",mediaUpload:t.mediaUpload,pollTranscodeTimer:e});break}default:console.error("unhandled state for media upload",e)}}catch(e){console.error("Failed to load media upload:",e),l({mediaState:"error",error:e,mediaUpload:o.mediaUpload}),n({err:e})}};return(0,i.d4)(()=>("polling"===o.mediaState&&null===o.pollTranscodeTimer&&d(),()=>{"polling"===o.mediaState&&o.pollTranscodeTimer&&clearTimeout(o.pollTranscodeTimer)}),[o]),{mediaUpload:o.mediaUpload,mediaState:o.mediaState,cancel:a,startPolling:e=>{let{mediaUpload:t}=e;"uploaded"!==t.state&&console.warn("startPolling called, but mediaUpload was not in state uploaded, was [".concat(t.state,"]")),l({mediaState:"polling",mediaUpload:t,pollTranscodeTimer:null})}}}},22966:function(e,t,n){"use strict";let i;n.d(t,{T6:()=>Z,d0:()=>b,oJ:()=>y});var r=n(58865),o=n(6400),l=n(88897),a=n(59981),d=n(92007),s=n(55679),c=n(42441),u=n.n(c),p=n(45088),m=n(70075),h=n(3258),f=n(63651);function v(){let e=(0,r._)(["No results for ",""]);return v=function(){return e},e}let g=a.ZP.extend({name:"substack_mention",addAttributes:()=>({id:w("id"),label:w("label"),mentionType:w("mentionType"),url:w("url")}),renderHTML(e){let{node:t,HTMLAttributes:n}=e;return["substack-mention",(0,l.P1)({class:"substack-mention","data-type":this.name},this.options.HTMLAttributes,n),this.options.renderLabel({options:this.options,node:t})]},addNodeView:()=>(0,s.fW)(_)}),y=e=>async t=>{let{query:n}=t;return n.length<2?[]:await (0,h.O7)(n,{pathname:e})},b=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"user",{onActive:t}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return()=>{let n,i;let r=u().prototype.stopCallback,o=function(t){var n,i;let r=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o="undefined"!=typeof window&&(null===(i=window._preloads)||void 0===i?void 0:null===(n=i.pub)||void 0===n?void 0:n.language)||"en",{iString:l,iTemplate:a}=I18N.i(o);return{items:t.items,query:t.query,isLoading:r,selectItem:e=>{e&&!e.disabledReason&&t.command({id:e.id,label:e.name,mentionType:e.type,url:e.url})},placeholderText:l("user"===e?"Search for a person":"Search for a person or publication"),noResultsText:a(v(),t.query),minQueryLength:2,language:o}};return{onStart:e=>{n=new s.M_(m.c,{props:o(e),editor:e.editor}),i=(0,p.ZP)("body",{getReferenceClientRect:e.clientRect,appendTo:()=>document.body,content:n.element,popperOptions:{strategy:"absolute",modifiers:[{options:{altAxis:!0}}]},showOnCreate:!0,interactive:!0,trigger:"manual",placement:"bottom-start"}),u().prototype.stopCallback=function(e,t,n){return"esc"===n||r(e,t,n)},null==t||t(!0)},onBeforeUpdate(e){i&&i[0].show(),n&&n.updateProps(o(e,!0)),e.clientRect&&i&&i[0].setProps({getReferenceClientRect:e.clientRect})},onUpdate(e){n&&n.updateProps(o(e,!1)),i&&i[0].setProps({getReferenceClientRect:e.clientRect})},onKeyDown(e){var o;return"Escape"===e.event.key?(i&&i[0]&&i[0].destroy(),i=null,n&&n.destroy(),n=null,setTimeout(()=>{u().prototype.stopCallback=r},0),null==t||t(!1),!0):null==n?void 0:null===(o=n.ref)||void 0===o?void 0:o.onKeyDown(e)},onExit(){u().prototype.stopCallback=r,i&&i[0]&&i[0].destroy(),i=null,n&&n.destroy(),n=null,null==t||t(!1)}}}},Z=g.configure({HTMLAttributes:{class:"substack-mention"},suggestion:{char:"@",pluginKey:new d.H$("substack_mention"),decorationClass:"substack-mention",allowSpaces:!0,startOfLine:!1,items:(i="/api/v1/reader/comments/mention",async e=>{let{query:t}=e;return t.length<1?[]:await (0,h.wg)(t,{pathname:i})}),render:b("user")}});function _(e){let{node:{attrs:{id:t,label:n,mentionType:i,url:r}}}=e;return(0,o.h)(s.T5,{as:"a",href:"pub"===i?r:(0,f.GR3)(t,n),className:"substack-mention",target:"_blank"},[n])}function w(e){return{default:null,parseHTML:t=>t.getAttribute("data-".concat(e)),renderHTML:t=>t[e]?{["data-".concat(e)]:t[e]}:{}}}},5889:function(e,t,n){"use strict";n.d(t,{gg:()=>r,m:()=>o});var i=n(25235);function r(e){return e&&o(e).pop()||null}function o(e){return(0,i.find)(e).filter(e=>"url"===e.type&&e.href.startsWith("http"))}},8357:function(e,t,n){"use strict";n.d(t,{Z:()=>function e(t){var n,l,a;let{left:d=!0,right:s=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!(null==t?void 0:null===(n=t.content)||void 0===n?void 0:n.length)){if(!t||o(t))t=null;else if("text"===t.type){let e=t.text;d&&(e=null==e?void 0:e.trimStart()),s&&(e=null==e?void 0:e.trimEnd()),t=(0,r._)((0,i._)({},t),{text:e})}return t}let c=t.content.length,u=0;if(d)for(;u_});var i=n(98661),r=n(57319),o=n(28842),l=n(76396),a=n(16457),d=n(45514),s=n(16653),c=n(57820),u=n(17714),p=n(42800),m=n(4470),h=n(76576),f=n(35521),v=n(98790);let g=(0,i.createContext)(null),y=Object.assign((0,m.yV)(function(e,t){let n=(0,a.M)(),{id:r=`headlessui-label-${n}`,passive:o=!1,...l}=e,d=function e(){let t=(0,i.useContext)(g);if(null===t){let t=Error("You used a