"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["7892"],{8131:function(e,t,i){i(16584),i(98661),i(30396),i(94184),i(8400),i(23279),i(23493),i(80569),i(93666),i(95441),i(15771),i(19081),i(98248),i(58175),i(60308)},347:function(e,t,i){i.d(t,{h:()=>l});var o=i(16584);i(98661);var n=i(4615),a=i(4291);function l(e){let{children:t}=e;return(0,o.tZ)(n.f6,{theme:a.Z.pubTheme,children:t})}},81924:function(e,t,i){i.d(t,{w:()=>f});var o=i(16584),n=i(30396),a=i(55679),l=i(70109),d=i(94184),r=i.n(d);i(23279);var s=i(47976);i(95441);var c=i(39800);i(68833);var p=i(98914);i(15771);var u=i(19081);i(38023),i(6490);var h=i(58175),m=i(81355),v=i(60520);let f=e=>{let{node:t,id:i}=e,[d,f]=(0,n.eJ)(t.attrs.persistentExpression);return(0,n.d4)(()=>{f(t.attrs.persistentExpression)},[t]),(0,n.d4)(()=>{let e=e=>{let{detail:i}=e;i.node.attrs.id===t.attrs.id&&f(i.persistentExpression)};return(0,c.oj)().addEventListener("close",e),()=>{(0,c.oj)().removeEventListener("close",e)}},[]),(0,o.tZ)(a.T5,{"data-drag-handle":"",children:(0,o.tZ)(m.e,{children:(0,o.tZ)("div",{className:"latex-block",id:i,children:(0,o.tZ)(u.tu,{className:r()(v.Z.latexWrapper,t.attrs.persistentExpression||(0,p.K1)()?v.Z.emptyStateWrapper:null),radius:"md","data-attrs":JSON.stringify({persistentExpression:d,id:t.attrs.id}),onClick:()=>{d!==t.attrs.persistentExpression&&f(t.attrs.persistentExpression),(0,c.oj)().dispatchEvent(new CustomEvent("open",{detail:{persistentExpression:t.attrs.persistentExpression,node:t}}))},children:(0,o.BX)(u.gq,{paddingY:8,paddingX:16,flex:"grow",justifyContent:"center",alignItems:"center",children:[d||t.attrs.persistentExpression?(0,o.tZ)(u.tu,{alignItems:"center",justifyContent:"center",children:(0,o.tZ)(l.Z,{typesettingOptions:{fn:"tex2chtml",options:void 0},text:"".concat(d||t.attrs.persistentExpression),renderMode:"pre",inline:!1,dynamic:!0})}):(0,o.tZ)(u.tu,{alignSelf:"center",children:(0,o.tZ)(h.xv.Meta,{fontStyle:"italic",translated:!0,color:"secondary",children:"Edit & enter LaTeX expressions here"})}),(0,o.tZ)(u.tu,{children:(0,o.tZ)("button",{className:v.Z.latexEdit,children:(0,o.tZ)(s.Z,{width:20,height:20})})})]})})})})})}},1148:function(e,t,i){i.d(t,{H:()=>n});var o=i(16584);let n=e=>(0,o.tZ)("div",{className:"file-embed-wrapper-editor",children:(0,o.tZ)("div",{className:"file-embed-aligner",children:(0,o.tZ)("div",{className:"file-embed-container placeholder",children:(0,o.tZ)(a,{})})})}),a=()=>(0,o.BX)("div",{className:"embed-loader-container",children:[(0,o.tZ)("div",{className:"embed-loader"}),(0,o.tZ)("div",{className:"embed-loader-text",children:"Loading..."})]})},42684:function(e,t,i){i(27412),i(7409),i(99282),i(16584),i(16564),i(86657),i(64819),i(24763);var o=i(21903);i(24791),i(60308),o.ZP},28771:function(e,t,i){i.d(t,{M$:()=>l}),i(16584);var o=i(6400),n=i(30396);i(94184),i(1852),i(71068),i(70379),i(7149);let a=(0,o.createContext)({initialTab:"settings",isDrawerOpen:()=>!1,openDrawerId:null,setInitialTab:()=>void 0,setIsDrawerOpen:()=>void 0,setPreventChange:()=>void 0});function l(){return(0,n.qp)(a)}},19908:function(e,t,i){i.d(t,{M:()=>n});var o=i(83857);"undefined"!=typeof navigator&&/Mac/.test(navigator.platform);let n=e=>(t,i,n)=>{if(i){var a,l,d;(0,o.d)(e.marks.link,{scrollParent:".editor-scroll",language:"undefined"!=typeof window?null===(d=window)||void 0===d?void 0:null===(l=d._preloads)||void 0===l?void 0:null===(a=l.publication)||void 0===a?void 0:a.language:null}).spec.run(t,i,n)}return!0}},21903:function(e,t,i){i.d(t,{QM:()=>b,ZP:()=>M,hJ:()=>w});var o=i(27412),n=i(7409),a=i(58865),l=i(6400),d=i(14293),r=i.n(d),s=i(81763),c=i.n(s),p=i(80569),u=i.n(p),h=i(88452),m=i(40647),v=i(68833),f=i(98914),y=i(10656),g=i(98012),E=i(84864);function x(){let e=(0,a._)(["This will remove your audio. Are you sure?"]);return x=function(){return e},e}function U(){let e=(0,a._)(["This will remove your video. Are you sure?"]);return U=function(){return e},e}function T(){let e=(0,a._)(["File too large. Your file is ","; the maximum is ",". Try encoding at a lower bitrate."]);return T=function(){return e},e}function _(){let e=(0,a._)(["It looks like your file is empty (0 bytes). Please check that the file you are trying to upload is not corrupted."]);return _=function(){return e},e}let w="video/*";class M extends l.Component{componentDidMount(){this.syncUploads()}componentWillUnmount(){this.clearSyncMediaUploadTimeouts(),this.stopUpdatingTranscodingTime()}componentDidUpdate(e,t){e.mediaUploadId!==this.props.mediaUploadId&&null===this.props.mediaUploadId&&(this.clearSyncMediaUploadTimeouts(),this.stopUpdatingTranscodingTime(),this.setState({mediaUpload:null,audioExtractMediaUploadId:null,audioExtractMediaUpload:null,audioExtractPreviewMediaUploadId:null,audioExtractPreviewMediaUpload:null})),this.checkTranscodeStates(t),this.checkForNewUploads(e)}getMediaUploadId(){return this.state.mediaUploadId}stopUpdatingTranscodingTime(){clearTimeout(this.updateTranscodingTimeout),this.updateTranscodingTimeout=null}getEstimatedTranscodingTime(){let e=1,t=0,i=new Date().getTime(),{mediaUpload:o}=this.state;if((null==o?void 0:o.state)==="uploaded"&&o.uploaded_at&&o.duration&&o.duration>0){let n="video"===this.props.mediaType?.7:.03,a=1e3*Math.max("video"===this.props.mediaType?60:5,o.duration*n),l=Math.max(0,a-Math.max(0,Date.now()-new Date(o.uploaded_at).getTime()));e=Math.max(0,1-l/a),this.state.timeLeft&&this.state.timeLeft{var e;this.updateTranscodingTimeout||(this.setState(this.getEstimatedTranscodingTime()),(null===(e=this.state.mediaUpload)||void 0===e?void 0:e.state)==="uploaded"&&(this.updateTranscodingTimeout=window.setTimeout(()=>{this.updateTranscodingTimeout=null,this.updateTranscodingTime()},1e3)))}),(0,o._)(this,"onMediaUpload",e=>{var t;let{mediaUpload:i}=e;clearTimeout(null!==(t=this.syncMediaUploadTimeout)&&void 0!==t?t:void 0),this.setState({mediaUploadId:null==i?void 0:i.id,mediaUpload:i},()=>{var e,t;this.syncUpload({uploadIdKey:"mediaUploadId",uploadKey:"mediaUpload",uploadTimeoutKey:"syncMediaUploadTimeout",uploadSyncingKey:"syncingMediaUpload",endpoint:"/api/v1/".concat(this.props.mediaType,"/upload/{id}")}),null===(e=(t=this.props).onChange)||void 0===e||e.call(t,{mediaUpload:i})})}),(0,o._)(this,"onAudioExtractMediaUpload",e=>{let{mediaUpload:t}=e;clearTimeout(this.syncAudioExtractMediaUploadTimeout),this.setState({audioExtractMediaUploadId:null==t?void 0:t.id,audioExtractMediaUpload:t},()=>{var e,i;this.syncUpload({uploadIdKey:"audioExtractMediaUploadId",uploadKey:"audioExtractMediaUpload",uploadTimeoutKey:"syncAudioExtractMediaUploadTimeout",uploadSyncingKey:"syncingAudioExtractMediaUpload",endpoint:"/api/v1/audio/upload/{id}"}),null===(e=(i=this.props).onAudioExtractChange)||void 0===e||e.call(i,{mediaUpload:t})})}),(0,o._)(this,"onAudioExtractPreviewMediaUpload",e=>{let{mediaUpload:t}=e;clearTimeout(this.onAudioExtractPreviewMediaUpload),this.setState({audioExtractPreviewMediaUploadId:null==t?void 0:t.id,audioExtractPreviewMediaUpload:t},()=>{var e,i;this.syncUpload({uploadIdKey:"audioExtractPreviewMediaUploadId",uploadKey:"audioExtractPreviewMediaUpload",uploadTimeoutKey:"syncAudioExtractPreviewMediaUploadTimeout",uploadSyncingKey:"syncingAudioExtractPreviewMediaUpload",endpoint:"/api/v1/audio/upload/{id}"}),null===(e=(i=this.props).onAudioExtractPreviewChange)||void 0===e||e.call(i,{mediaUpload:t})})}),(0,o._)(this,"onMediaUploadUpdated",e=>{var t,i;null===(t=(i=this.props).onChange)||void 0===t||t.call(i,{mediaUpload:(0,n._)({},this.props.mediaUpload,e)})}),(0,o._)(this,"removeUpload",function(){var e;let{skipConfirm:t=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{iTemplate:o}=i.i18n,{mediaUploadId:n,mediaUpload:a}=i.state;if(n){if(!t&&!["cancelled","error"].includes(null==a?void 0:a.state)&&!confirm(o((null==a?void 0:a.media_type)==="audio"?x():U())))return;null===(e=i.optionsDropdown)||void 0===e||e.close(),i.clearSyncMediaUploadTimeouts(),i.setState({mediaUploadId:null,mediaUpload:null,audioExtractMediaUploadId:null,audioExtractMediaUpload:null,audioExtractPreviewMediaUploadId:null,audioExtractPreviewMediaUpload:null},()=>{var e,t,o,n,a,l;null===(e=(t=i.props).onChange)||void 0===e||e.call(t,{mediaUpload:null}),null===(o=(n=i.props).onAudioExtractChange)||void 0===o||o.call(n,{mediaUpload:null}),null===(a=(l=i.props).onAudioExtractPreviewChange)||void 0===a||a.call(l,{mediaUpload:null})})}}),(0,o._)(this,"syncUploads",()=>{this.syncUpload({uploadIdKey:"mediaUploadId",uploadKey:"mediaUpload",uploadTimeoutKey:"syncMediaUploadTimeout",uploadSyncingKey:"syncingMediaUpload",endpoint:"/api/v1/".concat(this.props.mediaType,"/upload/{id}")}),this.syncUpload({uploadIdKey:"audioExtractMediaUploadId",uploadKey:"audioExtractMediaUpload",uploadTimeoutKey:"syncAudioExtractMediaUploadTimeout",uploadSyncingKey:"syncingAudioExtractMediaUpload",endpoint:"/api/v1/audio/upload/{id}"}),this.syncUpload({uploadIdKey:"audioExtractPreviewMediaUploadId",uploadKey:"audioExtractPreviewMediaUpload",uploadTimeoutKey:"syncAudioExtractPreviewMediaUploadTimeout",uploadSyncingKey:"syncingAudioExtractPreviewMediaUpload",endpoint:"/api/v1/audio/upload/{id}"})}),(0,o._)(this,"getTimeoutDuration",e=>(0,g.Z)(e).add(6e4,"milliseconds").isBeforeNow()?3e4:1e4),(0,o._)(this,"clearSyncMediaUploadTimeouts",()=>{this.syncMediaUploadTimeout&&clearTimeout(this.syncMediaUploadTimeout),this.syncAudioExtractMediaUploadTimeout&&clearTimeout(this.syncAudioExtractMediaUploadTimeout),this.syncAudioExtractPreviewMediaUploadTimeout&&clearTimeout(this.syncAudioExtractPreviewMediaUploadTimeout)}),(0,o._)(this,"syncUpload",async e=>{var t,i;let{uploadIdKey:o,uploadKey:n,uploadTimeoutKey:a,uploadSyncingKey:l,endpoint:d}=e,r=this.state[o],s=this.state[n];if(!r){s&&this.setState({[n]:null});return}if((null==s?void 0:s.state)!=="transcoded"&&!this[l]){this[l]=!0;try{let e=await u().get(d.replace("{id}",r));this.setState({[n]:e.body},()=>{"uploaded"!==e.body.state?this.stopUpdatingTranscodingTime():this.updateTranscodingTime()})}catch(e){alert((0,f.zx)(e))}this.state[n]&&(null===(t=this.state[n])||void 0===t?void 0:t.state)!=="uploaded"||(this[a]=window.setTimeout(()=>this.syncUpload({uploadIdKey:o,uploadKey:n,uploadTimeoutKey:a,uploadSyncingKey:l,endpoint:d}),this.getTimeoutDuration(null===(i=this.state[n])||void 0===i?void 0:i.created_at))),this[l]=!1}}),(0,o._)(this,"checkTranscodeStates",e=>{var t,i,o,n,a,l,d,r,s,c,p,u,h,m,v,f;(null===(t=this.state.mediaUpload)||void 0===t?void 0:t.state)==="transcoded"&&(null===(i=e.mediaUpload)||void 0===i?void 0:i.state)!==(null===(o=this.state.mediaUpload)||void 0===o?void 0:o.state)&&(null===(p=(u=this.props).onChange)||void 0===p||p.call(u,{mediaUpload:this.state.mediaUpload})),((null===(n=this.state.audioExtractMediaUpload)||void 0===n?void 0:n.state)==="transcoded"||(null===(a=this.state.audioExtractMediaUpload)||void 0===a?void 0:a.state)==="error")&&(null===(l=e.audioExtractMediaUpload)||void 0===l?void 0:l.state)!==(null===(d=this.state.audioExtractMediaUpload)||void 0===d?void 0:d.state)&&(null===(h=(m=this.props).onAudioExtractChange)||void 0===h||h.call(m,{mediaUpload:this.state.audioExtractMediaUpload})),(null===(r=this.state.audioExtractPreviewMediaUpload)||void 0===r?void 0:r.state)==="transcoded"&&(null===(s=e.audioExtractPreviewMediaUpload)||void 0===s?void 0:s.state)!==(null===(c=this.state.audioExtractPreviewMediaUpload)||void 0===c?void 0:c.state)&&(null===(v=(f=this.props).onAudioExtractPreviewChange)||void 0===v||v.call(f,{mediaUpload:this.state.audioExtractPreviewMediaUpload}))}),(0,o._)(this,"checkForNewUploads",e=>{var t,i,o,n,a,l;(e.mediaUpload!==this.props.mediaUpload||e.mediaUploadId!==this.props.mediaUploadId)&&this.setState({mediaUpload:null!==(t=this.props.mediaUpload)&&void 0!==t?t:null,mediaUploadId:null!==(i=this.props.mediaUploadId)&&void 0!==i?i:null}),(e.audioExtractMediaUpload!==this.props.audioExtractMediaUpload||e.audioExtractMediaUploadId!==this.props.audioExtractMediaUploadId)&&this.setState({audioExtractMediaUpload:null!==(o=this.props.audioExtractMediaUpload)&&void 0!==o?o:null,audioExtractMediaUploadId:null!==(n=this.props.audioExtractMediaUploadId)&&void 0!==n?n:null}),(e.audioExtractPreviewMediaUpload!==this.props.audioExtractPreviewMediaUpload||e.audioExtractPreviewMediaUploadId!==this.props.audioExtractPreviewMediaUploadId)&&this.setState({audioExtractPreviewMediaUpload:null!==(a=this.props.audioExtractPreviewMediaUpload)&&void 0!==a?a:null,audioExtractPreviewMediaUploadId:null!==(l=this.props.audioExtractPreviewMediaUploadId)&&void 0!==l?l:null})}),this.state={mediaUploadId:e.mediaUploadId,mediaUpload:e.mediaUpload||null,estimatedTimeLeftAt:null,timeLeft:0,percentComplete:1},this.updateTranscodingTimeout=null,this.syncMediaUploadTimeout=null,this.syncAudioExtractMediaUploadTimeout=null,this.syncAudioExtractPreviewMediaUploadTimeout=null,this.syncingMediaUpload=!1,this.syncingAudioExtractMediaUpload=!1,this.syncingAudioExtractPreviewMediaUpload=!1,this.i18n=I18N.i(e.language)}}M.contextType=m.QA;class b extends h.Z{componentDidUpdate(e){this.props.initialFile!==e.initialFile&&(this.onFileSelected(this.props.initialFile),e.initialFile&&this.cancelUpload())}trackUploadClicked(){}onError(){var e,t,i;let{upload_state:o="uploading",customMessage:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};(0,v.j)(v.FP.MEDIA_UPLOAD_FAILED,{upload_state:o,media_upload_id:null===(e=this.state.mediaUpload)||void 0===e?void 0:e.id,post_id:this.props.postId,customMessage:n}),null===(t=(i=this.props).onUploadCanceled)||void 0===t||t.call(i),super.onError({upload_state:o},n)}render(e,t){return console.error("render must be implemented by child class"),null}constructor(e,t){if(super(e,t),(0,o._)(this,"accepts",void 0),(0,o._)(this,"chunkSize",void 0),(0,o._)(this,"input",null),(0,o._)(this,"i18n",void 0),(0,o._)(this,"onUploadClicked",async()=>{this.trackUploadClicked()}),(0,o._)(this,"uploadToS3",async e=>{var t,i,o,a,l,d,r,s,c,p;let h;if((null===(t=this.state)||void 0===t?void 0:t.preuploading)||(null===(i=this.state)||void 0===i?void 0:i.uploading))return;null===(o=(a=this.props).onUploadStarted)||void 0===o||o.call(a),this.setState({preuploading:!0});let{iTemplate:m}=this.i18n;if(e.size>E.MAX_MEDIA_FILE_SIZE){this.onError({upload_state:"preupload",customMessage:m(T(),(0,E.formatBytes)(e.size),(0,E.formatBytes)(E.MAX_MEDIA_FILE_SIZE))});return}if(0===e.size){this.onError({upload_state:"preupload",customMessage:m(_())});return}this.props.postId||(this.props.setPostId?await (null===(l=(d=this.props).setPostId)||void 0===l?void 0:l.call(d)):console.warn("missing postId and cannot set postId, likely a non post editor")),this.setState({durationPromise:(0,y.Iw)(e)});try{let t="video"===this.props.mediaType?"/api/v1/video/upload":"/api/v1/audio/upload";h=await u().post(t).query((0,n._)({filetype:e.type,fileSize:e.size,fileName:"".concat(null==e?void 0:e.name)},this.props.postId?{post_id:this.props.postId}:{})),(0,v.j)(v.FP.MEDIA_UPLOAD_CREATED,{media_type:this.props.mediaType,file_size:e.size,file_type:e.type,parts_size:(null!==(r=h.body.multipartUploadUrls)&&void 0!==r?r:[]).length,post_id:this.props.postId})}catch(e){console.error("Failed to create media upload:",e),this.onError({upload_state:"preupload",customMessage:(0,f.zx)(e)});return}let{mediaUpload:g,multipartUploadId:x,multipartUploadUrls:U}=h.body,w=(null!==(s=null==g?void 0:g.parts)&&void 0!==s?s:[]).map(e=>e.etag).filter(Boolean);"created"===g.state&&w.length===U.length?(this.setState({mediaUpload:g,mediaUploadId:g.id}),await this.initTranscode(g,w)):"uploaded"===g.state||"transcoded"===g.state?null===(c=(p=this.props).onUpload)||void 0===c||c.call(p,h.body):(this.setState({preuploading:!1,mediaUpload:g,multipartUploadId:x,existingEtags:w}),(0,v.j)(v.FP.MEDIA_UPLOAD_STARTED,{media_upload_id:g.id,media_type:this.props.mediaType,post_id:this.props.postId}),super.uploadFile(e,null,{urls:U,method:"PUT",withCredentials:!1,useFormData:!1,mediaUpload:g}))}),(0,o._)(this,"onFileSelected",async e=>{var t,i,o,n;if(this.setState({recording:!1}),e=e||(null===(i=this.input)||void 0===i?void 0:null===(t=i.files)||void 0===t?void 0:t[0]),this.input&&(this.input.value=""),e){if(!r()(this.props.maxVideoDurationSeconds))try{let t=await (0,y.Iw)(e);if("number"==typeof t&&t>this.props.maxVideoDurationSeconds){(0,v.j)(v.FP.VIDEO_UPLOAD_IN_NOTES_FAILED,{duration_seconds:t,reason:"too_long"}),null===(o=(n=this.props).onVideoTooLong)||void 0===o||o.call(n);return}}catch(e){console.warn("could not get video duration",e)}this.uploadToS3(e)}}),(0,o._)(this,"onComplete",async()=>{var e,t,i;let o=null===(e=this.state.uploading)||void 0===e?void 0:e.status;if(!o||o<200||o>=400){this.onError();return}(0,v.j)(v.FP.MEDIA_UPLOAD_COMPLETED,{media_upload_id:this.state.mediaUpload.id,post_id:this.props.postId});let n=[...null!==(i=this.state.existingEtags)&&void 0!==i?i:[],...null===(t=this.state.uploadingXhrs)||void 0===t?void 0:t.map(e=>e.getResponseHeader("Etag")).filter(Boolean)];await this.initTranscode(this.state.mediaUpload,n)}),(0,o._)(this,"initTranscode",async(e,t)=>{let i=null;try{if((i=await this.state.durationPromise)&&"object"==typeof i&&"is_error"in i)throw i}catch(e){console.error("Failed to fetch video duration:",e)}try{var o,n;let a=await u().post("/api/v1/".concat(this.props.mediaType,"/upload/").concat(e.id,"/transcode")).send({duration:c()(i)?i:null,multipart_upload_id:e.multipart_upload_id,multipart_upload_etags:t});this.setState({mediaUpload:null,audioExtractMediaUpload:null,multipartUploadId:null}),this.resetUpload(),null===(o=(n=this.props).onUpload)||void 0===o||o.call(n,a.body,"")}catch(e){throw alert((0,f.zx)(e)),this.onError({upload_state:"transcoding"}),e}}),!["video","audio"].includes(e.mediaType))throw Error("unsupported media type: ".concat(e.mediaType));this.accepts="video"===e.mediaType?w:"audio/mpeg,audio/mp3,audio/m4a,audio/x-m4a,audio/aac,audio/aiff,audio/x-aiff,audio/amr,audio/flac,audio/ogg,audio/wav,audio/x-wav",this.fudgeFactor=.9,this.chunkSize=E.MAX_MEDIA_UPLOAD_CHUNK_SIZE,this.i18n=I18N.i(e.language),e.initialFile&&this.onFileSelected(this.props.initialFile)}}b.contextType=m.QA},44369:function(e,t,i){i.d(t,{$4:()=>r,Sm:()=>h,cS:()=>v,nv:()=>u,om:()=>y,pA:()=>f,vM:()=>m});var o=i(27412),n=i(42249),a=i(68833),l=i(98914),d=i(60308);class r extends n.sN{static fromMenuItem(e,t){let{spec:i}=e;return new r(i,t)}constructor(e,t){super(e);let i=this.spec.run;this.spec.run=(e,o,n,l)=>((0,a.j)(a.FP.EDITOR_MENU_ICON_CLICKED,{button:t||this.spec.label||this.spec.title}),i.call(this,e,o,n,l))}}let s="ProseMirror-prompt",c="".concat(s,"-visible");class p{read(e){return e.value}validate(e){return(e=this.clean(e))||!this.options.required?this.options.validate&&this.options.validate(e):"Required field"}clean(e){return this.options.clean?this.options.clean(e):e}constructor(e){(0,o._)(this,"options",void 0),this.options=e}}class u extends p{render(){let e=document.createElement("input");return e.type="text",e.placeholder=this.options.label,e.value=this.options.value||"",e.className=this.options.className||"",e.autocomplete="off",e}}class h extends u{constructor(e,t,i="en"){let{iString:o}=I18N.i(i);super({label:o("Enter URL..."),className:"url-input",value:t||e&&e.mark.attrs.href||"",required:!0,clean:e=>{let t;return e?(t=e.trim()).startsWith("http")||t.startsWith("mailto")||/^%%.*%%$/.test(t)?t:"http://".concat(t):""},validate:e=>{if(!/^%%.*%%$/.test(e)){if(e.startsWith("".concat((0,d.SVA)(),"/publish/post/"))&&alert(o("This is a link to a post draft. Readers will not be able to access this page.")),e.length>1900)return o("Link is too long");try{let t=new URL(e);if(["http:","https:","mailto:"].includes(t.protocol))return}catch(e){}return e.startsWith("http")?o("Invalid URL"):o("Invalid URL. Try using http://")}}})}}function m(e,t){let{from:i,$from:o,to:n,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||o.marks()):e.doc.rangeHasMark(i,n,t)}function v(e){if(f(e))return;let{iString:t}=I18N.i(e.language||"en"),i="".concat(s,"-").concat(e.parentClass),o=e.root||document.body,n=e.scrollParent&&document.querySelector&&document.querySelector(e.scrollParent)||function e(t){return null==t?null:t.scrollHeight>t.clientHeight?t:e(t.parentElement)}(o)||window,a=o.appendChild(document.createElement("div"));a.classList.add(s),e.className&&a.classList.add(e.className),a.id=i,(0,l.cn)(document.body,c);let d=e=>{a.contains(e.target)||u()},r=()=>{if(e.position)e.position(a,h);else{var t,i;let o=e.parentClass&&(null===(t=(i=document).querySelector)||void 0===t?void 0:t.call(i,".".concat(e.parentClass)));if(o){let t=o.getBoundingClientRect();a.style.top="".concat(t.bottom+(e.offsetTop||0),"px"),a.style.left="".concat(t.left+(e.offsetLeft||0),"px")}else{let t=a.getBoundingClientRect();a.style.top="".concat((window.innerHeight-t.height)/2+(e.offsetTop||0),"px"),a.style.left="".concat((window.innerWidth-t.width)/2+(e.offsetLeft||0),"px")}}},p=t=>{var i;t&&t.preventDefault();let o=function(e,t){let i={},o=0;for(let n in e){let a=e[n],l=t[o++],d=a.read(l),r=a.validate(d);if(r)return function(e,t){let i=e.parentNode;if(!i)return;let o=i.appendChild(document.createElement("div"));o.style.left="".concat(e.offsetLeft+e.offsetWidth+2,"px"),o.style.top="".concat(e.offsetTop-5,"px"),o.className="ProseMirror-invalid",o.textContent=t,setTimeout(()=>i.removeChild(o),1500)}(l,r),null;i[n]=a.clean(d)}return i}(null!==(i=e.fields)&&void 0!==i?i:{},m);o&&u(o)},u=t=>{(0,l.IV)(document.body,c),window.removeEventListener("mousedown",d),window.removeEventListener("resize",r,!1),n.removeEventListener("scroll",r,!1),a.parentNode&&a.parentNode.removeChild(a),t?(e.onSubmit&&e.onSubmit(t),e.callback&&e.callback(t)):e.onCancel&&e.onCancel(),e.onClose&&e.onClose()};setTimeout(()=>window.addEventListener("mousedown",d),50),window.addEventListener("resize",r,!1),n.addEventListener("scroll",r,!1);let h=a.appendChild(document.createElement("span"));h.className="head";let m=[],v=0;for(let t in e.fields){v++;let i=e.fields[t].render();i.tabIndex=v,m.push(i)}let y=a.appendChild(document.createElement("form"));if(e.title&&(y.appendChild(document.createElement("h5")).textContent=e.title),m.forEach(e=>{y.appendChild(document.createElement("div")).appendChild(e)}),!e.no_buttons){let i=document.createElement("button");i.type="submit",i.className="".concat(s,"-submit"),i.textContent=e.submitText||"OK",i.addEventListener("click",p);let o=document.createElement("button");o.type="button",o.className="".concat(s,"-cancel"),o.textContent=t("Cancel"),o.addEventListener("click",()=>u());let n=y.appendChild(document.createElement("div"));n.className="".concat(s,"-buttons"),n.appendChild(i),n.appendChild(document.createTextNode(" ")),n.appendChild(o)}if(e.footer&&y.appendChild(e.footer),e.openseaEmbedFooter&&y.appendChild(e.openseaEmbedFooter),r(),y.addEventListener("submit",p),e.onInput&&y.addEventListener("input",t=>{var i;null===(i=e.onInput)||void 0===i||i.call(e,t,a)}),y.addEventListener("keydown",e=>{if(27==e.keyCode)e.preventDefault(),u();else if(13!=e.keyCode||e.ctrlKey||e.metaKey||e.shiftKey){if(9==e.keyCode&&(window.setTimeout(()=>{a.contains(document.activeElement)||u()},500),m.length>1)){for(let t=0;t0){let e=y.elements[0];for(let t of Array.from(y.elements))if(!t.value&&["INPUT","TEXTAREA"].includes(t.nodeName)){e=t;break}e.focus()}}function f(e){let t="".concat(s,"-").concat(e.parentClass),i=document.getElementById(t);if(i){let e;if(i.querySelector&&(e=i.querySelector(".".concat(s,"-cancel"))),e)e.click();else{var o;null===(o=i.parentNode)||void 0===o||o.removeChild(i),(0,l.IV)(document.body,c)}return!0}}function y(e,t){let i=e.selection.$from;for(let e=i.depth;e>=0;e--){let o=i.index(e);if(i.node(e).canReplaceWith(o,o,t))return!0}return!1}},66586:function(e,t,i){i(16584),i(30396);var o=i(23493),n=i.n(o);i(16564),i(95441),i(42684),i(47921),i(68833),i(15771),i(19081),i(58175),i(87077),n()((e,t)=>{e({mediaUploadId:null==t?void 0:t.id,duration:null==t?void 0:t.duration,mediaUpload:t})},1e3,{trailing:!1})},89871:function(e,t,i){i.d(t,{z:()=>l}),i(16584);var o=i(98661),n=i(30396);i(89734),i(80569),i(40647),i(61381),i(63018);let a=(0,o.createContext)({existingClips:[],mediaClipsRequest:null,isTranscribing:!1,podcastUpload:null,setExistingClips:()=>void 0,setIsTranscribing:()=>void 0,setMediaClipsRequest:()=>void 0,setTranscription:()=>void 0,setUploadProgress:()=>void 0,syncClips:()=>Promise.resolve(),transcription:null,transcriptionGenerated:!1,uploadProgress:null,transcodeProgress:null,setTranscodeProgress:()=>void 0,nonStandardInputReasons:{},uploadState:"no-upload",videoUpload:null,onVideoTranscodeUpdate:()=>Promise.resolve(),postMediaComposition:null,setPostMediaComposition:()=>void 0,updatingActivePostMediaComposition:!1,setUpdatingActivePostMediaComposition:()=>void 0,fetchPostMediaComposition:()=>Promise.resolve()}),l=()=>(0,n.qp)(a)},47921:function(e,t,i){i(16584),i(33804),i(71068),i(15771),i(6400),i(98661),i(30396),i(94184),i(19081),i(58175)},66067:function(e,t,i){i(16584),i(30396);var o=i(23493),n=i.n(o);i(95441),i(28771),i(47921),i(82061),i(68833),i(93687),i(15771),i(19081),i(58175),i(87077),n()((e,t)=>{e({mediaUploadId:null==t?void 0:t.id,duration:null==t?void 0:t.duration,mediaUpload:t})},1e3,{trailing:!1})},61381:function(e,t,i){i.d(t,{y:()=>d});var o=i(7409),n=i(99282),a=i(30396),l=i(28771);let d=()=>{let{initialTab:e,isDrawerOpen:t,setInitialTab:i,setIsDrawerOpen:d,setPreventChange:r}=(0,l.M$)(),s=(0,a.I4)(e=>{d((0,n._)((0,o._)({},e),{drawerId:"podcast",variant:"push"}))},[d]);return{initialTab:e,isPodcastDrawerOpen:t("podcast"),setInitialTab:i,setIsPodcastDrawerOpen:s,setPreventChange:e=>r({preventChange:e,preventChangeMessage:"Please wait until the upload is finished before closing the drawer"})}}},39800:function(e,t,i){i.d(t,{oj:()=>v});var o=i(7409),n=i(99282),a=i(98848),l=i(16584),d=i(98661),r=i(30396),s=i(94184);i(80569),i(8131),i(86374),i(66067);var c=i(15771);i(81924),i(347),i(95441),i(14952),i(56629),i(60807),i(80026),i(6490),i(39693),i(24350),i(57557),i(71171),i(98914),i(55014),i(19081),i(8594),i(68709),i(88e3),i(98248),i(58175),i(51776),i(70379),i(63651),i(23279),i(23493),i(64515),i(93666),i(7882),i(17688),i(44369),i(66586),i(33804);var p=i(68833);i(49762),i(61254),i(36500);var u=i(84747);i(73857),i(73943),i(6070),i(84864);let h=(e,t,i)=>{(0,p.j)(p.FP.EDITOR_MENU_ICON_CLICKED,{button:i}),t(e)};function m(e,t){return(0,r.I4)(i=>{e&&(t?h(i,e,t):e(i))},[e,t])}(0,d.forwardRef)((e,t)=>{var{trackedName:i,testId:d,priority:r="tertiary",onClick:s}=e,p=(0,a._)(e,["trackedName","testId","priority","onClick"]);let u=m(s,i);return(0,l.tZ)(c.hU,(0,n._)((0,o._)({},p),{size:"sm","data-testId":d,onClick:u,ref:t,priority:r}))}),(0,d.forwardRef)((e,t)=>{var{trackedName:i,testId:d,priority:r="tertiary",onClick:s}=e,p=(0,a._)(e,["trackedName","testId","priority","onClick"]);let u=m(s,i);return(0,l.tZ)(c.zx,(0,n._)((0,o._)({},p),{size:"sm","data-testId":d,onClick:u,ref:t,priority:r}))}),(0,d.forwardRef)((e,t)=>{var{trackedName:i,testId:d,onClick:r}=e,s=(0,a._)(e,["trackedName","testId","onClick"]);let c=m(r,i);return(0,l.tZ)(u.u,(0,n._)((0,o._)({},s),{"data-testId":d,onClick:c,ref:t}))});let v=()=>{if(window)return window.LatexModalEvent||(window.LatexModalEvent=new EventTarget),window.LatexModalEvent}},70232:function(e,t,i){i.d(t,{zF:()=>o}),i(98914);let o="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY4AAAB0BAMAAABgVMiEAAAAMFBMVEX////7+/vt7e3o6Ojm5ubn5+fu7u709PTs7Oz39/f19fX29vby8vLx8fHz8/Pw8PCxY+A8AAAAoklEQVR4AWJgVHYZ+sBIgEE0vXzog7JAhrZZq4Y+WJnB4A5o5w5oAAYBGAi6mcKpQgIaClhCBklz7+AM/Gjo5+Dg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODgeO7g4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4ODg4OD4Zse3dmVXfIST0/B1vh0UtMKbNF7rAAAAAElFTkSuQmCC"},82061:function(e,t,i){i.d(t,{nP:()=>C});var o=i(27412),n=i(7409),a=i(99282),l=i(58865),d=i(16584),r=i(98661),s=i(94184),c=i.n(s),p=i(98961),u=(i(2647),i(57560)),h=i(80569),m=i(13304),v=i(93666),f=(i(12281),i(95441)),y=i(41688),g=(i(31098),i(71825),i(21903)),E=(i(21680),i(40158),i(29719),i(68833)),x=(i(98914),i(88788)),U=i(80449),T=i(15771),_=i(19081),w=(i(84747),i(58175),i(74134),i(18618),i(84864)),M=i(96085);function b(){let e=(0,l._)([""," remaining"]);return b=function(){return e},e}function I(e){let{children:t,className:i}=e,o=(0,r.useRef)(null);if(!o.current){let e=document.getElementById("video-portal");if(e)o.current=e;else{let e=document.createElement("div");e.setAttribute("id","video-portal"),e.className=i||"",document.body.appendChild(e),o.current=e}}return(0,r.createPortal)(t,o.current)}g.ZP;let A=e=>{let{onCancel:t,percentComplete:i,msLeft:o}=e,{iString:n,iTemplate:a}=(0,f.M1)(),l=(0,w.secondsToLargestUnit)(o/1e3,{long:!0,secondsCutoff:30});return(0,d.BX)("div",{className:"video-uploader-progress",children:[(0,d.BX)("div",{className:"video-uploader-progress-label",children:[n("Uploading video..."),o?a(b(),l):""]}),(0,d.BX)("div",{className:"video-uploader-progress-status",children:[(0,d.tZ)(T.hU,{size:"sm",priority:"quaternary",onClick:()=>{t()},children:(0,d.tZ)(m.Z,{})}),(0,d.tZ)("div",{className:"video-uploader-progress-bar",children:(0,d.tZ)("div",{className:"video-uploader-progress-bar-filled",style:"width: ".concat(100*i,"%;")})})]})]})};g.QM;class C extends g.QM{trackUploadClicked(){(0,E.j)(E.FP.UPLOAD_VIDEO_CLICKED,{source:"notes"})}render(e,t){return null}constructor(e,t){super(e,t),(0,o._)(this,"videoRecorderModal",null),this.state=(0,a._)((0,n._)({},this.state),{hideVideoInfoPanel:!1})}}class S extends v.p{getClassName(){return"video-recorder-modal"}componentWillUnmount(){super.componentWillUnmount(),this.recorder.stopCapture(),this.close()}onBeforeOpen(){this.startCapturePromise||(this.startCapturePromise=this.recorder.startCapture())}async onOpen(){var e,t;(0,E.j)(E.FP.VIDEO_RECORDER_SHOWN),null===(t=this.props)||void 0===t||null===(e=t.onOpen)||void 0===e||e.call(t);let i=this.startCapturePromise;if(this.startCapturePromise=null,!await i){this.close();return}if(this.recorder.stream instanceof Promise){console.error("onOpen called before stream was ready");return}this.videoElement&&"srcObject"in this.videoElement?this.videoElement.srcObject=this.recorder.stream:this.videoElement.src=URL.createObjectURL(this.recorder.stream)}onBeforeClose(){if(this.videoElement&&(this.videoElement.pause(),this.videoElement.srcObject=null,this.videoElement.src=null),this.recorder.state===x.Z.STATE.STARTED&&["embed","podcast"].includes(this.props.videoFeature))this.onButtonClick();else if(this.recorder.state===x.Z.STATE.STARTED);else if(this.recorder.state===x.Z.STATE.STARTING){let e=this.recorder;e.onStarted=()=>e.stop({dropRecording:!0})}else this.recorder.stopCapture()}onClose(){var e,t;(0,E.j)(E.FP.VIDEO_RECORDER_HIDDEN),null===(t=this.props)||void 0===t||null===(e=t.onClose)||void 0===e||e.call(t),this.setState({videoLoading:!0})}onButtonClick(){this.recorder.state===x.Z.STATE.STOPPED?(this.setState({countDown:3}),setTimeout(()=>this.setState({countDown:2}),700),setTimeout(()=>this.setState({countDown:1}),1400),this.recorder.start({startAt:Date.now()+2100})):this.recorder.state===x.Z.STATE.STARTED&&this.recorder.stop({stopCapture:!1})}renderChildren(e,t){let{children:i}=e,{videoLoading:o,recorderState:n,recorderDuration:a,recorderVolume:l,countDown:r}=t,{iString:s}=this.context;return(0,d.BX)("div",{className:"video-recorder-modal-wrap",children:[(0,d.tZ)("video",{ref:this.assignVideoElement,className:"video-recorder-preview",onLoadedMetadata:this.onVideoElementLoadedMetadata}),(0,d.tZ)("div",{className:"video-recorder-duration ".concat(n),children:n===x.Z.STATE.STOPPED?s(o?"Loading...":"Press to record"):n===x.Z.STATE.STARTING?"".concat(r||3):(0,w.secondsToHHMMSS)(a||0)}),(0,d.BX)("div",{className:"video-recorder-button ".concat(n),onClick:()=>this.onButtonClick(),children:[(0,d.tZ)("div",{className:"video-recorder-button-volume",style:"border-width:".concat(20*l,"px")}),(0,d.tZ)("div",{className:"video-recorder-button-inner"})]})]})}constructor(e,t){super(e,t),(0,o._)(this,"recorder",void 0),(0,o._)(this,"startCapturePromise",null),(0,o._)(this,"videoElement",null),(0,o._)(this,"recorderUpdateInterval",null),(0,o._)(this,"assignVideoElement",e=>{this.videoElement=e}),(0,o._)(this,"onVideoElementLoadedMetadata",()=>{if(!this.videoElement){console.error("onVideoElementLoadedMetadata called, videoElement not set");return}this.videoElement.volume=0,this.videoElement.play(),this.setState({videoLoading:!1})}),(0,o._)(this,"onRecorderStarting",()=>{(0,E.j)(E.FP.VIDEO_RECORDER_STARTING),this.onRecorderUpdated()}),(0,o._)(this,"onRecorderStarted",()=>{(0,E.j)(E.FP.VIDEO_RECORDER_STARTED),this.onRecorderUpdated(),this.recorderUpdateInterval=window.setInterval(()=>this.onRecorderUpdated(),100)}),(0,o._)(this,"onRecorderStopping",()=>{(0,E.j)(E.FP.VIDEO_RECORDER_STOPPING),this.recorderUpdateInterval&&clearInterval(this.recorderUpdateInterval),this.onRecorderUpdated()}),(0,o._)(this,"onRecorderStopped",e=>{if((0,E.j)(E.FP.VIDEO_RECORDER_STOPPED),this.onRecorderUpdated(),e){var t,i;(0,E.j)(E.FP.VIDEO_RECORDED,{videoType:e.type,videoSize:e.size}),null===(t=(i=this.props).onVideoRecorded)||void 0===t||t.call(i,e)}}),(0,o._)(this,"onRecorderUpdated",()=>{this.setState({recorderState:this.recorder.state,recorderDuration:this.recorder.duration,recorderVolume:this.recorder.volume})}),this.state.videoLoading=!0,this.recorder=new x.Z({aspectRatio:1920/1080,onStarting:this.onRecorderStarting,onStarted:this.onRecorderStarted,onStopping:this.onRecorderStopping,onStopped:this.onRecorderStopped,language:this.props.language}),this.onRecorderUpdated()}}(0,o._)(S,"contextType",f.wj)},88e3:function(e,t,i){i.d(t,{Q:()=>u,l:()=>h});var o=i(16584),n=i(19425),a=i(12048),l=i(94184),d=i.n(l),r=i(98661),s=i(71068),c=i(91400),p=i(68742);let u=e=>{let{children:t}=e;return(0,o.tZ)(n.u.Child,{as:r.Fragment,enter:p.Z.panelEnter,enterFrom:p.Z.panelEnterFrom,enterTo:p.Z.panelEnterTo,leave:p.Z.panelLeave,leaveFrom:p.Z.panelLeaveFrom,leaveTo:p.Z.panelLeaveTo,children:t})},h=(0,r.forwardRef)((e,t)=>{let{children:i,className:n,position:l="default",fullscreenMobile:r,maxFullscreenMobile:u,width:h=440,overflow:m}=e,v=(0,c.XA)();return(0,o.tZ)(a.V.Panel,{ref:t,className:d()(n,(0,s.oB)({display:"flex",radius:"lg"}),p.Z.panel,p.Z["position-".concat(l)],r&&p.Z.fullscreenMobile,v&&r&&p.Z.fullscreenMobileHeight,v&&u&&p.Z.maxFullscreenMobile),style:{width:v||"full"===l?void 0:h,overflow:m},children:i})})},8594:function(e,t,i){i.d(t,{A:()=>h,L:()=>m});var o=i(7409),n=i(99282),a=i(98848),l=i(16584),d=i(94697),r=i(45587),s=i(24285),c=i(71068);let p={opacity:.5,zIndex:1e3},u=e=>"item-".concat(e);function h(e){let{children:t,items:i,onReorder:o}=e,n=(0,d.Dy)((0,d.VT)(d.we,{activationConstraint:{distance:2}}),(0,d.VT)(d.Lg,{coordinateGetter:r.is}));return(0,l.tZ)(d.LB,{sensors:n,collisionDetection:d.pE,onDragEnd:e=>{let{active:t,over:n}=e;if(!n||t.id===n.id)return;let a=i.findIndex(e=>u(e)===t.id),l=i.findIndex(e=>u(e)===n.id);o((0,r.Rp)(i,a,l))},autoScroll:!1,children:(0,l.tZ)(r.Fo,{items:i.map(e=>u(e)),strategy:r.U2,children:t})})}function m(e){var{item:t}=e,i=(0,a._)(e,["item"]);return(0,l.tZ)(v,(0,o._)({id:u(t)},i))}let v=e=>{let{children:t,id:i,useDragHandle:a=!1}=e,{listeners:d,setNodeRef:u,transform:h,transition:m,isDragging:v}=(0,r.nB)({id:i});return(0,l.tZ)(c.xu,(0,n._)((0,o._)({ref:e=>u(e),style:(0,o._)({transform:s.ux.Translate.toString(h),transition:m},v?p:{})},a?{}:(0,o._)({},d)),{children:"function"==typeof t?t({listeners:d}):t}))}},12988:function(e,t,i){i.d(t,{Ws:()=>o}),i(75472);let o=(e,t)=>{let i;let{showLiveOverlay:o,subtitle:n,aspectRatio:a,pub:l}=null!=t?t:{},d={},r=!1,s=e.width&&e.height?e.width/e.height:1,c=!!e.live_stream_id,p=!(e.live_stream_id&&s>=1);if(e.liveStream){var u,h,m;r=(null!==(h=e.liveStream.joinedOrCompletedLiveStreamInvites)&&void 0!==h?h:[]).length>0,i=null!==(m=null===(u=e.liveStream.user)||void 0===u?void 0:u.handle)&&void 0!==m?m:void 0}return(null==l?void 0:l.author_handle)&&(i=l.author_handle),(c||o)&&(p||(d.legacy_watermark={type:"legacy_watermark",show:!1}),(s<1||["vertical_fill","vertical_fit"].includes(null!=a?a:""))&&(o&&(d.live_overlay={type:"live_overlay",position:r?"bottom":"center",subtitle:n||(i?"@".concat(i):void 0)}),d.captions={type:"captions",position:r?["center","center"]:["center",700]})),d}},54809:function(e,t,i){i.d(t,{ER:()=>a,Lz:()=>r,Nf:()=>c,Xb:()=>s,Z$:()=>d,uM:()=>l});var o=i(80983),n=i(84864);let a={"application/x-cbr":[[82,97,114,33,26,7,0],[82,97,114,33,26,7,1,0],[127,69,76,70]],"application/x-cbz":[[80,75,3,4],[80,75,5,6],[80,75,7,8]]},l={"application/vnd.amazon.kfx":[[75,70,88,32]],"application/vnd.amazon.kpf":[[80,75,3,4]],"application/epub+zip":[[80,75,3,4]],"application/x-mobipocket-ebook":[[77,79,66,73]]},d={"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":[[80,75,3,4],[80,75,5,6],[80,75,7,8]]},r={"application/pdf":[[37,80,68,70]]};function s(e){let{mimeTypesToSignature:t,substackType:i,actionButtonAttr:o}=e;return[{tag:"div.file-embed-wrapper",getAttrs:e=>{let a={};try{var l,d,r;let[s,c,p]=e.children[0].children;if(!s)return!1;let[u,h]=s.children;if(!h||!u)return!1;let[m,v]=h.children;if(!v)return!1;a.title=null==m?void 0:m.textContent;let[f,y]=(null===(l=v.textContent)||void 0===l?void 0:l.split("∙"))||[];if(!f||!y)return!1;a.filesize=(0,n.formattedBytesToNumber)(f);let g=null===(r=y.split("File"))||void 0===r?void 0:null===(d=r[0])||void 0===d?void 0:d.trim().toLowerCase();if(!g)return!1;if(t[g]||i===g)a.filetype=g;else{if("file"!==i)return!1;a.filetype=g}return(null==u?void 0:u.classList.contains("file-embed-thumbnail-default"))||(a.thumbnail=u.getAttribute("src")||""),a.description=null==c?void 0:c.innerText,a[o]=null==p?void 0:p.getAttribute("href"),a}catch(e){return!1}}}]}function c(e){var t;let{attrs:i}=e;return"".concat((0,n.numberToHumanFileSize)(null!==(t=Number(i.filesize))&&void 0!==t?t:void 0)," ∙ ").concat(function(e){var t,i,n,a;let{filetype:l}=e;return l?["application/vnd.amazon.kfx","application/vnd.amazon.kpf","application/vnd.amazon.ebook"].includes(l)?"Kindle":null!==(a=null===(i=o.extension(l)||(null===(n=l.split("/").pop())||void 0===n?void 0:n.split("-").pop()))||void 0===i?void 0:null===(t=i.toUpperCase)||void 0===t?void 0:t.call(i))&&void 0!==a?a:"":""}({filetype:i.filetype})," file")}},62092:function(e,t,i){function o(e){let{fragment:t}=e;return"content"in t?t.content:[]}function n(e){let{fragment:t,content:i}=e;t.content=i}function a(e){return"type"in e&&"object"==typeof e.type}function l(e){return"type"in e&&"string"==typeof e.type}i.d(t,{PH:()=>a,f5:()=>l,uR:()=>n,yX:()=>o})},68303:function(e,t,i){i.d(t,{$9:()=>W,$_:()=>K,C4:()=>q,Co:()=>S,DY:()=>x,Dg:()=>D,E5:()=>U,Hs:()=>H,N5:()=>g,PH:()=>f,S7:()=>k,Wi:()=>B,cb:()=>m.cb,do:()=>Z,fX:()=>I,fp:()=>E,gR:()=>L,je:()=>m.je,k:()=>P,lr:()=>A,o4:()=>X,qe:()=>O,qj:()=>v});var o=i(7409),n=i(99282),a=i(92007);i(39693);var l=i(14293),d=i.n(l),r=i(10691),s=i.n(r),c=i(19834),p=i(36186),u=i(84864),h=i(88956),m=i(22498);let v=[["list_item","listItem"],["bullet_list","bulletList"],["ordered_list","orderedList"],["hard_break","hardBreak"],["horizontal_rule","horizontalRule"],["code_block","codeBlock"]],f=[["em","italic"],["strong","bold"],["strikethrough","strike"]],y={image2:1,image:0,horizontal_rule:0,audio:0,video:0,youtube:0,youtube2:0,vimeo:0,opensea:0,twitter:0,twitter2:0,spotify:0,spotify2:0,soundcloud:0,bandcamp:0,kindle:0,tiktok:0,prediction_market:0,lichess:0,datawrapper:0,recipe:0,pinterest:0},g=function(e){let{maxLength:t=356,getAfterCutoff:i=!1,withEllipsis:o=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="",a=!1,l={},d=q(e),r=!1,s=(0,h.Y)(e,e=>{var o;if(a)return i;if("paywall"===e.type)return a=!0,!1;if(d)return!0;let s=null!==(o=e.type)&&void 0!==o?o:"undefined";if(l[s]=(l[s]||0)+1,e.type&&e.type in y&&l[s]>y[e.type])return a=!0,i;let c=t-n.length;if(c<=0&&!d||!(c>0))return i;if(i){if("text"===e.type&&e.text){if(!(t-(n+=e.text).length<=0))return!1;e.text=e.text.substring(e.text.length+t-n.length-1,e.text.length)}}else if("text"===e.type&&e.text){n+=e.text;let t=e.text;e.text=(0,u.truncateText)(t,c),r=t!==e.text}return!0});if(s&&o&&!r){let e=function(e){let t=[],i=[e];for(;i.length;){var o;let e=i.pop();if(!e)break;if(e.content&&(null===(o=e.content)||void 0===o?void 0:o.length)>0)for(let t=e.content.length-1;t>=0;t--){let o=e.content[t];o&&i.push(o)}else t.push(e)}return t}(s),t=null,i=null;for(let o=e.length-1;o>=0&&(!t||!i);o--){let n=e[o];null===t&&(null==n?void 0:n.type)==="text"&&(t=o),null===i&&(null==n?void 0:n.type)!=="text"&&(null==n?void 0:n.type)!=="paragraph"&&(i=o)}let o=null!==t?e[t]:null,n=o&&null!==i&&null!==t&&i>t;o&&!n&&(o.text=C(o.text))}return s},E=(e,t)=>{let i=[];if(e&&(t(e)&&i.push(e),e.content))for(let o of e.content)i=i.concat(E(o,t));return i},x=(e,t)=>{if(e){if(t(e))return e;if(e.content)for(let i of e.content){let e=x(i,t);if(e)return e}}return null},U=e=>{let t=[];return e.nodesBetween(0,e.content.size,e=>{var i;(null===(i=e.type)||void 0===i?void 0:i.name)==="cashtag"&&t.push(e.attrs.symbol)},0),t},T=new Set(["caption","footnote","captionedImage","image","image2"]),_=new Set(["bullet_list","bulletList","ordered_list","orderedList","blockquote"]),w="x_li_start_placeholder_x",M=(e,t)=>{var i,o,n,a;if((null===(i=e.type)||void 0===i?void 0:i.name)==="list_item"||(null===(o=e.type)||void 0===o?void 0:o.name)==="listItem")return{open:w,close:""};if((null===(n=e.type)||void 0===n?void 0:n.name)==="paragraph"||e.isBlock&&e.textContent.length>0&&!_.has(null===(a=e.type)||void 0===a?void 0:a.name)){let e="

";return(t.length>0?t[t.length-1]:null)===w&&(t.pop(),e+="* "),{open:e,close:"

"}}return null},b=e=>{var t,i,o;let{node:n,recursiveDepth:a,tokens:l}=e;if(a>100)return console.warn("Reached max recursive depth while converting document to HTML for podcast"),!1;let d=!0;if(T.has(null===(t=n.type)||void 0===t?void 0:t.name))d=!1;else if(n.isText){if(n.text&&n.text.length>0){let e=n.marks.find(e=>"link"===e.type.name&&e.attrs.href),t=n.marks.find(e=>"em"===e.type.name),i=n.marks.find(e=>"strong"===e.type.name),o=n.text;t&&(o="".concat(o,"")),i&&(o="".concat(o,"")),e&&(o='').concat(o,"")),l.push(o)}}else if(M(n,[])){let e=M(n,l);e&&l.push(e.open),n.descendants(e=>b({node:e,recursiveDepth:a+1,tokens:l})),e&&l.push(e.close),d=!1}else if((null===(i=n.type)||void 0===i?void 0:i.name)==="cashtag")l.push("".concat(n.attrs.symbol," "));else if((null===(o=n.type)||void 0===o?void 0:o.name)==="substack_mentions"){let e=n.marks.find(e=>"em"===e.type.name),t=n.marks.find(e=>"strong"===e.type.name),i=n.attrs.name;if(e&&(i="".concat(i,"")),t&&(i="".concat(i,"")),"user"===n.attrs.type){let e=(0,p.GR)(n.attrs.id,n.attrs.name);l.push('').concat(i,""))}else if("pub"===n.attrs.type){let e=n.attrs.url;l.push('').concat(i,""))}}return d},I=e=>{let t=[];return e.descendants(e=>b({node:e,recursiveDepth:1,tokens:t})),t.filter(e=>e!==w).join("").trim()},A=function(e){let{withLinks:t=!0,withCaptionsAndFootnotes:i=!1,forPodcast:o=!1,truncateAt:n=null,truncateTo:a=n,truncateEllipsis:l="…",truncateExtension:r=null}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},s="",p="",h="",m=!0;return e.nodesBetween(0,e.content.size,e=>{var n,v,f,y;if(!i&&["caption","footnote"].includes(null===(n=e.type)||void 0===n?void 0:n.name))return!1;if(e.isText){if(e.text&&e.text.length>0){let i;m=!1,!d()(a)&&s.length=a&&(i=(0,u.truncateText)(e.text,a-s.length,{ellipsis:l,extension:r}));let n=e.marks.filter(e=>"link"===e.type.name&&e.attrs.href)[0],v=e.marks.filter(e=>"em"===e.type.name)[0],f=e.marks.filter(e=>"strong"===e.type.name)[0],y=e.text;s+=y,v&&o&&(i&&(i="".concat(i,"")),y="".concat(y,"")),f&&o&&(i&&(i="".concat(i,"")),y="".concat(y,"")),n&&t?o?(i&&(h="".concat(p,'').concat(i,"")),p+='').concat(y,"")):(i&&(h="".concat(p).concat(i," [ ").concat(n.attrs.href," ]")),p+="".concat(y," [ ").concat(n.attrs.href," ]")):(i&&(h=p+i),p+=y)}}else!m&&["hard_break","hardBreak"].includes(null===(v=e.type)||void 0===v?void 0:v.name)?(m=!0,s+="\n",o?p+="
":p+="\n"):!m&&e.isBlock?(m=!0,s+="\n",o?p+="

":p+="\n"):(null===(f=e.type)||void 0===f?void 0:f.name)==="cashtag"?p+="".concat(e.attrs.symbol," "):(null===(y=e.type)||void 0===y?void 0:y.name)==="substack_mentions"&&(p+="".concat(e.attrs.name," "))},0),!d()(n)&&s.length>n&&h&&(p=h),p=p.trim(),o&&(p=p.replace(/\s*()+$/,"").trim()),p},C=e=>"".concat(s()(e,"."),"..."),S=(e,t)=>(0,n._)((0,o._)({name:e},t),{addAttributes:()=>t.attrs||{},parseHTML:()=>t.parseDOM,renderHTML(i){let{node:o}=i;return t.toDOM?t.toDOM(o):(console.warn("trying to create TipTapNode, no toDOM found for node",e),["span"])}}),D=(e,t)=>{let i,o,n;if(e.doc.nodesBetween(e.selection.from,e.selection.to,(e,a)=>{if(i||o)return!1;let l=e.marks.find(e=>e.type===t);l&&(i=e,o=l,n={from:a,to:a+e.nodeSize})}),i)return{node:i,mark:o,pos:n}},P=(e,t)=>{let i,o,n;if(e.doc.nodesBetween(e.selection.from,e.selection.to,(a,l)=>{if(i||o||!(l<=e.selection.from)||!(e.selection.to<=l+a.nodeSize))return!1;{let e=a.marks.find(e=>e.type===t);e&&(i=a,o=e,n={from:l,to:l+a.nodeSize})}}),!i){if(e.selection.empty){let d=e.doc.resolve(e.selection.from),r=d.nodeBefore&&d.nodeBefore.marks.find(e=>e.type===t),s=d.nodeAfter&&d.nodeAfter.marks.find(e=>e.type===t);if(r||s){var a,l;i=s?d.nodeAfter:d.nodeBefore,o=s||r,n=s?{from:d.pos,to:d.pos+d.nodeAfter.nodeSize}:{from:d.pos-(null!==(l=null===(a=d.nodeBefore)||void 0===a?void 0:a.nodeSize)&&void 0!==l?l:0),to:d.pos}}}if(!i)return}return{node:i,mark:o,pos:n}},k=function(e){let{allowedMarks:t=[]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!!e.selection.empty||O(e,e.selection.from,e.selection.to,{allowedMarks:t})},O=function(e,t,i){let{allowedMarks:o=[]}=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=!0,a=!1;return e.doc.nodesBetween(t,i,t=>{if(!n)return!1;t.type!==e.schema.nodes.text?a?n=!1:a=!0:t.marks.find(e=>!o.includes(e.type))&&(n=!1)}),n},L=(e,t)=>{if(e.selection.empty)return!1;let i=Array.isArray(t)?t:[t];if("node"in e.selection){var o;let t=e.selection;return i.includes(null===(o=t.node)||void 0===o?void 0:o.type)}return R(e,e.selection.from,e.selection.to,i)},R=(e,t,i,o)=>{let n=null;return e.doc.nodesBetween(t,i,e=>{if(!(!1!==n&&o.includes(e.type)))return n=!1,!1;n=!0}),n||!1},Z=e=>e.selection.empty?null:N(e,e.selection.from,e.selection.to),N=(e,t,i)=>{let o=null;return e.doc.nodesBetween(t,i,t=>!o&&(t.type===e.schema.nodes.image2?(o=t.attrs.href,!1):void(t.type===e.schema.nodes.image3&&(o=t.attrs.href)))),o||null},B=(e,t,i)=>{e.selection.empty||z(e,t,e.selection.from,e.selection.to,i)},z=(e,t,i,o,n)=>{e.doc.nodesBetween(i,o,(i,o)=>{(i.type===e.schema.nodes.image2||i.type===e.schema.nodes.image3)&&t.setNodeMarkup(o,i.type,Object.assign({},i.attrs,{href:n}),i.marks)})},F=e=>({top:e.top+window.scrollY,bottom:e.bottom+window.scrollY,left:e.left+window.scrollX,right:e.right+window.scrollX}),K=(e,t,i,o)=>{let n=document.body,a=window.innerWidth<=481,l=j(e,t.from,t.to,t=>[e.state.schema.nodes.image,e.state.schema.nodes.image2].includes(t.type))?-44:8,d=F(e.coordsAtPos(t.from)),r=F(e.coordsAtPos(t.to));i.style.position="fixed";let s=r.bottom+(a?n.scrollTop:0),c=n.clientHeight-i.clientHeight-96-l;d.topi.clientWidth?(o&&(o.style.left="10px"),i.style.right="",i.style.left="".concat(d.left,"px")):(o&&(o.style.left="".concat(d.left-n.clientWidth+i.clientWidth,"px")),i.style.right="10px",i.style.left=""),a||s{let n=!1;return e.state.doc.nodesBetween(t,i,e=>{if(n)return!1;n=o(e)}),n},V=e=>e.doc.resolve(e.selection.from).node(1),W=(e,t)=>{var i;return t.includes(null===(i=V(e))||void 0===i?void 0:i.type)},X=(e,t)=>{var i,o,n;let l=e.tr,d=l.selection instanceof a.Bs,r=d&&(null===(n=l.selection.$from)||void 0===n?void 0:null===(o=n.parent)||void 0===o?void 0:null===(i=o.content)||void 0===i?void 0:i.size)===0?e.selection.to-1:e.selection.to;if(Array.isArray(t))for(let e of t.slice().reverse())l.insert(r,e);else l.insert(r,t);return d||l.setSelection(a.qv.near(l.doc.resolve(r))),l},H=(e,t)=>{let i=e.tr;return i.replaceSelectionWith(t),i},q=e=>!!x(e,e=>"paywall"===e.type)},80870:function(e,t,i){function o(e,t){let i=1,o=1;e.doc.descendants((n,a)=>{if(n.type===t.nodes.footnote){if(n.attrs.number!==i){let o=t.nodes.footnote.create({number:i},n.content);e.replaceWith(a,a+n.nodeSize,o)}i+=1}else if(n.type===t.nodes.footnoteAnchor){if(n.attrs.number!==o){let i=t.nodes.footnoteAnchor.create({number:o});e.replaceWith(a,a+n.nodeSize,i)}o+=1}})}function n(e,t){let i=0;e.doc.nodesBetween(0,e.selection.from,e=>{e.type===t.nodes.footnoteAnchor&&(i+=1)});let o=[];return(e.doc.forEach((e,i)=>{e.type===t.nodes.footnote&&o.push(i)}),io,dG:()=>n})}}]);