(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["2601"],{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),l=n(1469),o=n(37005);e.exports=function(e){return"string"==typeof e||!l(e)&&o(e)&&"[object String]"==i(e)}},1581:function(e,t,n){var i=n(62705),l=n(278),o=n(64160),r=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(r(e))return a(e)?u(e):l(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),l=n(3674);e.exports=function(e){return null==e?[]:i(e,l(e))}},74386:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,n(36150).Z)("Bold",[["path",{d:"M6 12h9a4 4 0 0 1 0 8H7a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h7a4 4 0 0 1 0 8",key:"mg9rjx"}]])},74032:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,n(36150).Z)("Italic",[["line",{x1:"19",x2:"10",y1:"4",y2:"4",key:"15jd3p"}],["line",{x1:"14",x2:"5",y1:"20",y2:"20",key:"bu0au3"}],["line",{x1:"15",x2:"9",y1:"4",y2:"20",key:"uljnxc"}]])},96592:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,n(36150).Z)("ListOrdered",[["path",{d:"M10 12h11",key:"6m4ad9"}],["path",{d:"M10 18h11",key:"11hvi2"}],["path",{d:"M10 6h11",key:"c7qv1k"}],["path",{d:"M4 10h2",key:"16xx2s"}],["path",{d:"M4 6h1v4",key:"cnovpq"}],["path",{d:"M6 18H4c0-1 2-2 2-3s-1-1.5-2-1",key:"m9a95d"}]])},28549:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,n(36150).Z)("List",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]])},79692:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let i=(0,n(36150).Z)("Strikethrough",[["path",{d:"M16 4H9a3 3 0 0 0-2.83 4",key:"43sutm"}],["path",{d:"M14 12a4 4 0 0 1 0 8H6",key:"nlfj13"}],["line",{x1:"4",x2:"20",y1:"12",y2:"12",key:"1e0a9i"}]])},24830:function(e,t,n){"use strict";n.d(t,{Z:()=>i});/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */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),l=n(6400),o=n(98661),r=n(30396);let a=(0,l.createContext)(null);function d(e){let{root:t,children:n}=e,l=(0,r.sO)(t);return(0,i.BX)(a.Provider,{value:l,children:[n,!t&&(0,i.tZ)("div",{ref:l})]})}function s(e){let{children:t}=e,n=(0,r.qp)(a).current;return n?(0,o.createPortal)(t,n):null}},62298:function(e,t,n){"use strict";n.d(t,{H:()=>a});var i=n(16584),l=n(30396),o=n(98961),r=n(15771);function a(e){let{mediaUpload:t,selectedFile:n,onInputChange:a}=e,d=(0,l.sO)();return t||n?null:(0,i.BX)(r.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:()=>e6});var i=n(7409),l=n(99282),o=n(16584),r=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),C=n(95441),k=n(40647),_=n(60807),w=n(92291),x=n(77338),T=n(5952),S=n(25991),P=n(62298),E=n(25642),I=n(2891),B=n(16451),N=n(7882),M=n(68733),U=n(76721),O=n(68833),A=n(39556),L=n(48980),z=n(59176),R=n(98914),j=n(94874),F=n(71068),X=n(15771),D=n(19081),q=n(8594),H=n(36500),J=n(6490),V=n(98248),G=n(96302),W=n(58175),K=n(70379),Y=n(1669),$=n(55722),Q=n(75795),ee=n(98848),et=n(51127),en=n(38621),ei=n(89290),el=n(76405),eo=n(55679),er=n(94184),ea=n.n(er),ed=n(74386),es=n(74032),ec=n(79692);/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */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),eC=n(24717),ek=n(56782),e_=n(43557),ew=n(75481),ex=n(61767),eT=n(55786),eS=n(32018),eP=n(91077),eE=n(87597),eI=n(55963),eB=n(22966);let eN=e_.Z.extend({addAttributes:()=>({schemaVersion:{default:"v1"}})}),eM=[eb.ZP,eZ.ZP,eC.ZP,ek.ZP,ew.ZP,eT.Z,eS.ZP,eP.Z,eE.ZP,eI.Z,eN,ey.ZP,ex.Z.configure({linkOnPaste:!1,openOnClick:!1,HTMLAttributes:{class:"note-link",rel:"nofollow ugc noopener",target:"_blank"}}),eB.T6];var eU=n(8357),eO=n(5749),eA=n(76201);function eL(e){let{defaultValue:t,onAddFiles:n,placeholder:l,disabled:a,onChange:d,isDragging:s,onDrop:c,onReturn:p,onEscape:m}=e,h=(0,r.Ye)(()=>u()(e=>{let{editor:t}=e,n=null;t&&!t.isEmpty&&(n=(0,eU.Z)(t.getJSON())),d(n)},100),[d]),f=(0,eo.jE)({content:t,editable:!a,autofocus:"end",extensions:[...eM,ei.ZP,et.Z,en.Z.configure({placeholder:l})],onUpdate:h,editorProps:{attributes:(0,i._)({class:eO.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 el.p2(function e(t){let n=t;return t.forEach((t,i,l)=>{let o=t.marks.find(e=>"link"===e.type.name),r=t;if(o){let{href:e}=o.attrs;e!==r.text&&(r=r.type.schema.text(e,t.marks))}else t.content&&(r=r.copy(e(t.content)));r!==t&&(n=n.replaceChild(l,r))}),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)(ez,{Icon:ed.Z,active:f.isActive("bold"),onClick:()=>f.chain().focus().toggleBold().run()}),(0,o.tZ)(ez,{Icon:es.Z,active:f.isActive("italic"),onClick:()=>f.chain().focus().toggleItalic().run()}),(0,o.tZ)(ez,{Icon:ec.Z,active:f.isActive("strike"),onClick:()=>f.chain().focus().toggleStrike().run()}),(0,o.tZ)(ez,{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)(ez,{Icon:ep.Z,active:f.isActive("bulletList"),onClick:()=>f.chain().focus().toggleBulletList().run()}),(0,o.tZ)(ez,{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)(ez,{Icon:ev.kn,active:f.isActive("blockquote"),onClick:()=>f.chain().focus().toggleBlockquote().run()}),(0,o.tZ)(ez,{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 ez(e){var{Icon:t,active:n}=e,r=(0,ee._)(e,["Icon","active"]);return(0,o.tZ)(X.kG,(0,l._)((0,i._)({className:ea()(eA.Z.editorMenuButton,n&&eA.Z.editorMenuButtonActive),resetCss:!0},r),{children:(0,o.tZ)(t,{size:18})}))}var eR=n(78446),ej=n(91400),eF=n(64172),eX=n(9738),eD=n(93608),eq=n(50364),eH=n(73943),eJ=n(1581),eV=n.n(eJ),eG=n(20521),eW=n(5889),eK=n(19834);function eY(e){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:eM,i=(0,eK.Z)(e||""),l=i.split(/[\n\r]/g).filter(Boolean).map(e=>t(e,n));if(0===l.length||!l[0])return t(i,n);let o=l[0];if(o.content)for(let e of l.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 e6(e){var t,n,d,c,p,f,v,g,y,b,Z,w;let{onSuccess:x,onError:T,onClose:P,editComment:I,restackUrl:B,parentPostId:U,parentPubId:F,parentCommentId:X,initialText:q,initialFiles:H,tabId:J,surface:V,videoUploadId:G,mediaClipId:$,parentMediaClipId:Q,isPost:ee}=e,et=$||Q,en=(0,_.aF)(),ei=function(){let e=(0,eF.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:el}=(0,C.M1)(),eo={postId:null!==(d=null==I?void 0:I.post_id)&&void 0!==d?d:U,commentId:null!==(c=null==I?void 0:I.id)&&void 0!==c?c:X},er=I||q?e2:function(){var e,t,n;let{postId:i,commentId:l}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},o=l?"c:".concat(l):i?"p:".concat(i):"default";return null!==(n=null===(e=(null!==(t=(0,z.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}(eo),[ea,ed]=(0,r.eJ)(null!==(p=null==I?void 0:I.reply_minimum_role)&&void 0!==p?p:"everyone"),[es,ec]=(0,r.eJ)(null!==(g=null!==(v=null!==(f=null==I?void 0:I.body_json)&&void 0!==f?f:(null==I?void 0:I.body)?eY(I.body):null)&&void 0!==v?v:q?eY(q):null)&&void 0!==g?g:er.content),eu=es?(0,a._4)(es,eM):"",[ep,em]=(0,r.eJ)(H?[]:(null!==(y=null==I?void 0:I.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})),[eh,ef]=(0,r.eJ)(!1),[ev,eg]=(0,r.eJ)(!1),[ey,eb]=(0,r.eJ)(null!==(b=null==I?void 0:null===(t=I.attachments)||void 0===t?void 0:t.find(e=>"video"===e.type))&&void 0!==b?b:null),[eZ,eC]=(0,r.eJ)(!1),[ek,e_]=(0,r.eJ)(null),[ew,ex]=(0,r.eJ)(null),[eT,eS]=(0,r.eJ)(null),eP=(0,eX.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"}});eb(e),eS(t)}catch(e){console.error(e)}})({mediaUpload:t})},onError:e=>{console.error("something went wrong",e),e7.popToast(t=>{var n;return(0,o.tZ)(K.FN,(0,l._)((0,i._)({},t),{text:null!==(n=(0,R.zx)(e))&&void 0!==n?n:"Something went wrong. Please try again."}))})}}),eE=(0,eX.h)({onComplete:e=>{let{mediaUpload:t}=e;e_(e=>{var n,o;return e?(0,l._)((0,i._)({},e),{post:(0,l._)((0,i._)({},e.post),{videoUpload:t}),clipInfo:{startTime:0,duration:t.duration||5,isAutoSelected:!1},mediaClip:e.mediaClip?(0,l._)((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,l._)((0,i._)({},e),{mediaUpload:t}))}):null}):null}),eC(!1)},onError:()=>{eC(!1)}});(0,r.d4)(()=>{G&&(0,L.rd)("/api/v1/video/upload/".concat(G),{method:"GET"}).then(e=>{eS(e),eP.startPolling({mediaUpload:e})})},[G]);let eI=(0,r.I4)(e=>{ec(e)},[eo.postId,eo.commentId]),eB=eq.Zu,eN=eV()(eu).length,eU=eN>eB,eO=e=>{let t=e.filter(e=>e.type.startsWith("image/"));if((null==t?void 0:t.length)>0){let e=6-ep.length;if(ep.length>0&&e<1){e7.popToast(e=>(0,o.tZ)(K.FN,(0,l._)((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,l._)((0,i._)({},t),{attachment:e})).catch(e=>(0,l._)((0,i._)({},t),{error:e})).then(e=>(em(n=>n.map(n=>n===t?e:n)),e)),t});em(e=>[...e,...n].slice(0,6))}};(0,r.d4)(()=>{(0,O.j)(O.FP.FEED_COMPOSER_SCREEN_VIEWED,{parent_post_id:U,parent_comment_id:X,edit_comment_id:null==I?void 0:I.id,restack_url:B,media_clip_id:$})},[]),(0,r.d4)(()=>{H&&eO(H)},[H]);let eA=async e=>{let t=await (0,A.O)(e.url,{trackingProps:{surface:"note"}}),n=tc(t).then(e=>(0,l._)((0,i._)({},o),{attachment:e}),e=>(0,l._)((0,i._)({},o),{error:e})).then(e=>(em(t=>t.map(t=>t.promise===n?e:t)),e)),o=(0,l._)((0,i._)({},e),{url:URL.createObjectURL(t),promise:n});em(t=>t.map(t=>t===e?o:t))},ez=(null!==(Z=null==I?void 0:I.attachments)&&void 0!==Z?Z:er.attachments).find(e=>!["missing","image"].includes(e.type)),ej=(0,N.ib)({pathname:"/api/v1/comment/attachment",method:"POST",initialResult:ez,deps:[]}),eD=null!=B?B:null===(n=(0,eW.gg)(eu))||void 0===n?void 0:n.href;(0,r.d4)(()=>{$&&(0,L.rd)("/api/v1/comment/attachment",{method:"POST",json:{mediaClipId:$,type:"post"}}).then(e=>{var t,n,i,l,o;e_(e);let r=(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(eC(r),r){let t=null===(o=e.mediaClip)||void 0===o?void 0:null===(l=o.assets)||void 0===l?void 0:null===(i=l.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?eE.startPolling({mediaUpload:t}):eC(!1)}})},[$]);let eH=(0,r.Ye)(()=>{let e=null,t=ez?Promise.resolve(ez):null;return n=>(n!==e&&(e=n,n&&(t=ej.refetch({json:{url:n,type:"link",mediaClipId:n===B?$:void 0}}))),t)},[]),eJ=(0,r.Ye)(()=>u()(eH,500),[eH]);(0,r.d4)(()=>{I&&ej.result||eJ(null!=eD?eD:null)},[eD]);let eK=ej.result,eQ=(null==eK?void 0:eK.type)==="post"&&eK.postSelection?eK:null,{preferredTheme:e6}=(0,E.P$)(),[e8,e9]=(0,r.eJ)(null!==(w=null==eQ?void 0:eQ.postSelectionTheme)&&void 0!==w?w:e6);(0,r.d4)(()=>{let e=[];for(let t of ep)t.attachment&&e.push(t.attachment);eK&&e.push(eK),to({content:es,attachments:e},eo)},[es,ep,eK]);let e7=(0,K.pm)(),{create:e5,isLoading:e3,error:te}=function(){let{editComment:e}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,N.ib)({pathname:e?"/api/v1/feed/comment/".concat(e.id):"/api/v1/comment/feed"});return{create:async n=>{let{bodyJson:l,parentPostId:o,parentPubId:r,parent_id:a,attachmentIds:d,tabId:s,surface:c,replyMinimumRole:u,notifySubscribersPubId:p,isPost:m,videoUploadId:h,mediaClipId:f}=n;return m?await t.refetch({pathname:"/api/v1/publish/posts",method:"POST",json:{title:"Test Post",body:l,audience:"everyone",should_send_email:!1,video_upload_id:h}}):await t.refetch({pathname:e?"/api/v1/feed/comment/".concat(e.id):o?"/api/v1/post/".concat(o,"/comment"):"/api/v1/comment/feed",method:e?"PATCH":"POST",json:(0,i._)({bodyJson:l,parent_id:a,publication_id:r,attachmentIds:d,tabId:s,surface:c,replyMinimumRole:u,notifySubscribersPubId:p},f&&{mediaClipId:f})})},error:t.error,isLoading:t.isLoading}}({editComment:I}),tt=X||U,ti=!ey&&!!(ew||eT),ta=eh||eU||e3||ti||!(eu||ep.length>0||eK||ey||ek),tp=(0,eR.N4)(),tm=function(){var e;let t=(0,eF.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:tf}=(0,k.xR)(),tv=tf("enable_author_note_email_toggle"),tg=!ta&&tv&&tm.length>0&&!I&&!tt&&(!eK||"post"!==eK.type),ty=async()=>{if(ta)return;let e=null;if(tv&&ev&&!(e=await tp.confirm()))return;ef(!0);let t=ej.result||ej.isLoading?await eH(null!=eD?eD:null):null,n=t instanceof Error?null:t,r=await Promise.all(ep.map(e=>e.promise)),a=[];for(let e of r)if(e){let{attachment:t}=e;t&&"missing"!==t.type&&a.push(t.id)}if(ey&&a.push(ey.id),ek&&a.push(ek.id),n&&"missing"!==n.type&&n.id!==(null==ey?void 0:ey.id)&&a.push(n.id),(null==n?void 0:n.type)==="post"&&n.postSelection&&e8)try{await (0,L.rd)("/api/v1/comment/attachment/".concat(n.id,"/post_selection_theme"),{method:"PATCH",json:{theme_name:e8.name,theme_alignment:e8.alignment}})}catch(e){console.error(e),console.warn("Failed to update theme. Skipping.")}let d=await e5({bodyJson:es,parentPostId:U,parentPubId:F,parent_id:X,attachmentIds:a.length>0?a:void 0,tabId:J,surface:V,replyMinimumRole:ea,notifySubscribersPubId:null!=e?e:void 0,isPost:ee,videoUploadId:null==ey?void 0:ey.media_upload_id,mediaClipId:et});d instanceof Error?(e7.popToast(e=>(0,o.tZ)(K.FN,(0,l._)((0,i._)({},e),{text:"Failed to share"}))),console.error(d),T&&T(d)):(to(null,eo),e7.popToast(e=>(0,o.tZ)(K.FN,(0,l._)((0,i._)({},e),{text:I?"Note edited":tt?"Reply sent":B?"Restacked":"Note sent",cta:"View",href:(0,e$.Sg)(d)}))),x(d)),ef(!1)},tb=(0,M.uk)({onAddFiles:e=>{let t=e.filter(e=>(0,M.zN)({fileType:e.type}));t.length>0&&t[0]&&ex(t[0]),eO(e)},acceptFile:e=>{let{fileType:t}=e;return(0,M.N1)({fileType:t})||!!(0,M.zN)({fileType:t})}});return en?(0,o.BX)(e4,{onClose:e=>{e.stopPropagation(),P()},title:I?"Edit":tt?"Reply":B?"Restack":"New note",postLabel:I?"Save":ev?"Continue":"Post",hasImageAttachment:ep.length>0,onSubmit:e=>{e.preventDefault(),ty()},disabled:ta,onImageChange:e=>{if(eh)return;let{files:t}=e.currentTarget;eO(Array.from(t))},isDragging:tb.isDragging,videoUploadProps:{onVideoFileSelected:e=>{let t=()=>{e7.popToast(e=>(0,o.tZ)(K.FN,(0,l._)((0,i._)({},e),{text:el("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:r}=n;if(!r){console.warn("input change event had no files"),t();return}if(r.length>1&&console.error("selected multiple files, at most 1 file allowed"),0===r.length){console.error("must select exactly one file"),t();return}ex(r[0]),n.value=""},mediaUpload:eT,selectedVideoFile:ew},menu:!ei||X||U||(null==I?void 0:I.ancestor_path)?null:(0,o.tZ)(td,{value:ea,onChange:ed}),composerFooterRow:tg?(0,o.tZ)(tn,{checked:ev,onChange:eg}):null,parentPostId:U,children:[(0,o.tZ)(ts,{modal:tp,userPubs:tm,initialSelectedPubId:1===tm.length&&tm[0]?tm[0].id:null}),(0,o.BX)(D.tu,{flex:"grow",children:[X&&(0,o.tZ)(tr,{commentId:X}),(0,o.BX)(D.hs,{gap:12,minWidth:0,children:[(0,o.tZ)(j.qE,{size:36,user:en}),(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)(S.Et,{user:en}),(0,o.tZ)(eL,{defaultValue:es,placeholder:tt?"Leave a reply...":B?"Write something...":"What's on your mind?",onChange:eI,onReturn:ty,onEscape:P,onDrop:tb.props.onDrop,onAddFiles:eO,disabled:eh})]}),(0,o.tZ)(tl,{files:ep,handleImageRemove:e=>{em(t=>t.filter(t=>t!==e))},handleImageEdit:eA,onReorder:em}),(0,o.tZ)(tu,{selectedVideoFile:ew,initialMediaUpload:eT,setSelectedVideoFile:ex,setVideoAttachment:eb,setInitialMediaUpload:eS}),(0,o.tZ)(th,{attachment:ek,isLoading:eZ,onRemove:()=>e_(null)}),(0,o.tZ)(th,{attachment:eK,isLoading:ej.isLoading,onRemove:()=>ej.setResult(null),onQuoteThemeChange:e9})]})]})]}),(eU||te)&&(0,o.BX)(D.gq,{direction:"row-reverse",justifyContent:"space-between",paddingY:16,children:[eU&&(0,o.tZ)(W.xv.Meta,{color:eU?"error":void 0,children:eB-eN}),te&&(0,o.tZ)(Y.o,{error:te})]})]}):null}function e4(e){let{title:t,postLabel:n,disabled:i,onImageChange:l,videoUploadProps:r,isDragging:a,onSubmit:d,onClose:s,children:c,menu:u,composerFooterRow:p,hasImageAttachment:m,parentPostId:h}=e,f=!!r.selectedVideoFile&&!r.mediaUpload||!!r.mediaUpload;return(0,o.BX)(I.T,{children:[(0,o.BX)(D.tu,{className:e0.Z.modalColumn,gap:16,paddingY:16,children:[(0,o.tZ)(e8,{title:t,postLabel:n,disabled:i,onClose:s,onSubmit:d}),(0,o.tZ)(e7,{children:u}),(0,o.tZ)(e5,{children:c}),null!=p?p:null,(0,o.tZ)(e3,{parentPostId:h,onImageChange:l,hasVideoFile:f,hasImageAttachment:m,videoUploadProps:r,disabled:i,postLabel:n,onClose:s,onSubmit:d})]}),(0,o.tZ)(Q.t,{visible:a})]})}function e8(e){return(0,ej.XA)()?(0,o.tZ)(e9,(0,i._)({},e)):null}function e9(e){let{title:t,postLabel:n,disabled:i,onClose:l,onSubmit:r}=e;return(0,o.BX)(D.gq,{borderBottom:"detail",alignItems:"center",paddingBottom:12,paddingX:16,gap:12,justifyContent:"space-between",children:[(0,o.tZ)(X.hU,{"aria-label":"Back",priority:"secondary",size:"sm",onClick:l,children:(0,o.tZ)(f.Z,{size:20})}),(0,o.tZ)(W.xv.H4,{flex:"grow",children:t}),(0,o.tZ)(X.zx,{disabled:i,size:"sm",onClick:r,children:n})]})}function e7(e){let{children:t}=e;return t?(0,o.tZ)(D.hs,{padding:16,paddingY:0,children:t}):null}function e5(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,ej.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:l,videoUploadProps:r}=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}),!l&&(0,o.tZ)(P.H,{mediaUpload:r.mediaUpload,selectedFile:r.selectedVideoFile,onInputChange:r.onVideoFileSelected})]})})}function tt(e){let{parentPostId:t,onImageChange:n,hasVideoFile:i,hasImageAttachment:l,videoUploadProps:r,disabled:a,postLabel:d,onClose:s,onSubmit:c}=e,{iString:u}=(0,C.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&&!l&&(0,o.tZ)(P.H,{mediaUpload:r.mediaUpload,selectedFile:r.selectedVideoFile,onInputChange:r.onVideoFileSelected})]}),(0,o.BX)(D.gq,{gap:12,children:[(0,o.tZ)(X.zx,{priority:"secondary",onClick:s,children:u("Cancel")}),(0,o.tZ)(X.zx,{disabled:a,onClick:c,children:d})]})]})}function tn(e){let{checked:t,onChange:n}=e,{iString:i}=(0,C.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,O.j)(O.FP.SEND_NOTE_AS_EMAIL_TOGGLE_CLICKED,{checked:e}),n(e)}})]})})}function ti(e){let{onChange:t,useVideo:n=!1}=e,i=(0,r.sO)();return(0,o.BX)(X.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 tl(e){let{files:t,handleImageRemove:n,handleImageEdit:r,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,l._)((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)(X.GI,{size:"sm",onClick:()=>n(e),children:(0,o.tZ)(y.Z,{size:20})}),(0,o.tZ)(X.GI,{size:"sm",onClick:()=>r(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]:{},l=i?"c:".concat(i):n?"p:".concat(n):"default",o=null!==(t=(0,z.mM)(e1))&&void 0!==t?t:[],r=o.findIndex(e=>{let[t]=e;return t===l});r>=0&&o.splice(r,1),e&&(o.unshift([l,e]),o.splice(10)),(0,z.ex)(e1,o)}function tr(e){let{commentId:t}=e,{result:n}=(0,N.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,U.Z)(t),l=n[n.length-1];return(0,o.BX)(D.hs,{className:eO.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)(S.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})]}),l&&(0,o.BX)(W.xv.B5,{color:"secondary",children:["Replying to ",l.name]}),(0,o.tZ)(B.sP,{children:i&&(0,o.tZ)(x.x,{content:i,attachedLinks:(0,T.Bk)(t)})})]}),t.attachments&&(0,o.tZ)(w.yd,{readOnly:!0,attachments:t.attachments})]})]})}function td(e){let{value:t,onChange:n}=e,{iString:i}=(0,C.M1)();return(0,o.BX)(H.v2,{trigger:(0,o.tZ)(X.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.ti,{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:l}=e,[a,d]=(0,r.eJ)(l),s=(0,ej.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,O.j)(O.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,F.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)(X.zx,{priority:"secondary",onClick:()=>{(0,O.j)(O.FP.SEND_NOTE_AS_EMAIL_CONFIRMATION_REJECTED),n.handleCancel(null)},rounded:!0,children:"Cancel"}),(0,o.tZ)(X.zx,{disabled:null===a,onClick:()=>{a&&((0,O.j)(O.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,R.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:l,setInitialMediaUpload:r}=e,{getConfigFor:a}=(0,k.xR)();if(!t&&!n)return null;let d=()=>{i(null),l(null),r(null)},s=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"}});l(e)}catch(e){console.error(e)}};return(0,o.tZ)(eD._,{file:t,initialMediaUpload:n,maxVideoDurationSeconds:a("ignore_video_in_notes_length_limit")?Number.MAX_SAFE_INTEGER:eH.u,onCancel:d,onRemoveVideo:d,onComplete:s,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)(X.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:l}=e;return t||n?n?(0,o.tZ)(tp,{}):t?(0,o.tZ)(tm,{onRemove:i,children:(0,o.tZ)(w.yd,{attachments:[t],readOnly:!0,isComposing:!0,onQuoteThemeChange:l})}):null:null}},2891:function(e,t,n){"use strict";n.d(t,{T:()=>o});var i=n(16584),l=n(5749);function o(e){let{children:t}=e;return(0,i.tZ)("div",{className:l.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 l(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:()=>l,O:()=>i})},75795:function(e,t,n){"use strict";n.d(t,{t:()=>c});var i=n(16584),l=n(94184),o=n.n(l);/** * @license lucide-preact v0.453.0 - ISC * * This source code is licensed under the ISC license. * See the LICENSE file in the root directory of this source tree. */let r=(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:l=!0,className:c}=e;return(0,i.BX)(a.tu,{className:o()(t&&s.visible,l&&s.blur,s.outer,c),alignItems:"center",justifyContent:"center",gap:12,children:[(0,i.tZ)(r,{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),l=n(30396),o=n(15771),r=n(15562);function a(){let[e,t]=(0,l.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:l="Cancel",confirmLabel:a="Confirm",modal:d}=e;return(0,i.tZ)(r.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:l})})}},93608:function(e,t,n){"use strict";n.d(t,{_:()=>g});var i=n(7409),l=n(99282),o=n(16584),r=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:C,videoPlayerProps:k}=e,_=(0,r.sO)(null),{isMobile:w}=(0,c.v9)(),[x,T]=(0,r.eJ)(!1),[S,P]=(0,r.eJ)(null!=n?n:null),[E,I]=(0,r.eJ)(null),B=(0,m.pm)(),N=()=>{P(null),T(!1),I(null)},M=(0,f.h)({onComplete:e=>{let{mediaUpload:t}=e;P(t),Z({mediaUpload:t})},onError:e=>{console.error("something went wrong",e),N(),B.popToast(t=>{var n;return(0,o.tZ)(m.FN,(0,l._)((0,i._)({},t),{text:null!==(n=(0,s.zx)(e))&&void 0!==n?n:"Something went wrong. Please try again."}))})}});if((0,r.d4)(()=>{if(!t)return;let e=_.current;if(!e){console.error("Video not found");return}return e.src=URL.createObjectURL(t),()=>{URL.revokeObjectURL(e.src)}},[t]),(0,r.d4)(()=>{P(n)},[n]),!t&&!S)return null;let U=()=>{M.cancel(),P(null),T(!1),I(null),g()};if(!t&&S&&"uploaded"===S.state)return(0,o.tZ)(y,{mediaUpload:S});if(S&&"transcoded"===S.state)return(0,o.tZ)(u.gq,{wrap:"wrap",children:(0,o.BX)(u.gq,{position:"relative",children:[(0,o.tZ)(h.Jl,{mediaUpload:S,videoPlayerProps:k,composing:!0}),(0,o.tZ)(u.GI,{onClick:()=>{M.cancel(),P(null),T(!1),I(null),b()},priority:"primary",position:"absolute",className:v.remove,rounded:!0,size:"sm",children:(0,o.tZ)(a.Z,{size:"20"})})]})});let O=w?h.YQ:h.PJ;return(0,o.BX)(u.gq,{wrap:"wrap",position:"relative",children:[(0,o.tZ)(d.nP,{initialFile:t,maxVideoDurationSeconds:C,onVideoTooLong:()=>{B.popToast(e=>(0,o.tZ)(m.FN,(0,l._)((0,i._)({},e),{text:"Video is too long. Maximum duration is ".concat(C," seconds.")}))),U()},videoFeature:"hero",mediaType:"video",onProgress:e=>{let{percentComplete:t}=e;I(t)},onUpload:e=>{T(!0);let t=e.mediaUpload;P(t),M.startPolling({mediaUpload:t})},setPostId:null,onUploadCanceled:()=>{U()}}),(0,o.BX)(u.gq,{position:"relative",radius:"md",outline:"detail",bg:"secondary",overflow:"hidden",children:[(0,o.tZ)("video",{ref:_,className:v.videoPlaceholder,style:{maxHeight:"".concat(O,"px"),maxWidth:"".concat(O,"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:()=>{U()},children:(0,o.tZ)(a.Z,{size:20})}),(0,o.tZ)(u.xu,{position:"absolute",style:{pointerEvents:"none"},children:x||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:l}=e,r=null!==(t=l.width)&&void 0!==t?t:640,d=null!==(n=l.height)&&void 0!==n?n:360,s=d>r;return(0,o.BX)(u.gq,{alignItems:"center",bg:"secondary",justifyContent:"center",radius:"md",position:"relative",style:(0,i._)({aspectRatio:"".concat(r," / ").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),l=n(48980);function o(e){let{onComplete:t,onError:n}=e,[o,r]=(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,"]"));r({mediaState:"error",mediaUpload:o.mediaUpload,error:e}),n({err:e});return}try{let e=await (0,l.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");r({mediaState:"error",mediaUpload:e,error:t}),n({err:t});break}case"cancelled":{let t=Error("media upload was in canceled state");r({mediaState:"error",mediaUpload:e,error:t}),n({err:t});break}case"transcoded":r({mediaState:"complete",mediaUpload:e}),t({mediaUpload:e});break;case"created":case"uploaded":{let e=window.setTimeout(()=>{d()},5e3);r(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),r({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,"]")),r({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 l=n(58865),o=n(6400),r=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,l._)(["No results for ",""]);return v=function(){return e},e}let g=a.ZP.extend({name:"substack_mention",addAttributes:()=>({id:k("id"),label:k("label"),mentionType:k("mentionType"),url:k("url")}),renderHTML(e){let{node:t,HTMLAttributes:n}=e;return["substack-mention",(0,r.P1)({class:"substack-mention","data-type":this.name},this.options.HTMLAttributes,n),this.options.renderLabel({options:this.options,node:t})]},addNodeView:()=>(0,s.fW)(C)}),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 l=u().prototype.stopCallback,o=function(t){var n,i;let l=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:r,iTemplate:a}=I18N.i(o);return{items:t.items,query:t.query,isLoading:l,selectItem:e=>{e&&!e.disabledReason&&t.command({id:e.id,label:e.name,mentionType:e.type,url:e.url})},placeholderText:r("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||l(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=l},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=l,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 C(e){let{node:{attrs:{id:t,label:n,mentionType:i,url:l}}}=e;return(0,o.h)(s.T5,{as:"a",href:"pub"===i?l:(0,f.GR3)(t,n),className:"substack-mention",target:"_blank"},[n])}function k(e){return{default:null,parseHTML:t=>t.getAttribute("data-".concat(e)),renderHTML:t=>t[e]?{["data-".concat(e)]:t[e]}:{}}}},8357:function(e,t,n){"use strict";n.d(t,{Z:()=>function e(t){var n,r,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,l._)((0,i._)({},t),{text:e})}return t}let c=t.content.length,u=0;if(d)for(;uC});var i=n(98661),l=n(57319),o=n(28842),r=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:l=`headlessui-label-${n}`,passive:o=!1,...r}=e,d=function e(){let t=(0,i.useContext)(g);if(null===t){let t=Error("You used a