!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{};e.SENTRY_RELEASE={id:"substack@47b17f0"};var t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="d7ded107-5361-4fe9-86dd-83d4cd34752e",e._sentryDebugIdIdentifier="sentry-dbid-d7ded107-5361-4fe9-86dd-83d4cd34752e")}catch(e){}}();"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["76767"],{36066:function(e,t,i){i.d(t,{A:()=>r});var a=i(4006),s=i(67078),n=i(84824),o=i(91461);let r=e=>{let{audience:t,className:i,size:r=16,isStatic:l,thin:d}=e;return"only_paid"===t?d?(0,a.Y)(o.A,{className:i,size:r,color:"#262626",isStatic:l}):(0,a.Y)(s.A,{className:i,size:r}):"founding"===t?(0,a.Y)(n.A,{className:i,height:r,isStatic:l,strokeWidth:1}):null}},70735:function(e,t,i){i.d(t,{A:()=>l});var a=i(69277),s=i(70408),n=i(32641),o=i(4006),r=i(97731);let l=e=>{var{size:t=20,fill:i="var(--color-fg-primary)"}=e,l=(0,n._)(e,["size","fill"]);return(0,o.Y)(r.A,(0,s._)((0,a._)({},l),{name:"PlayIconLockFilled",svgParams:{viewBox:"0 0 20 20"},width:t,height:t,fill:i,children:(0,o.Y)("path",{stroke:"none",fillRule:"evenodd",clipRule:"evenodd",d:"M4.04688 18.5527C4.4375 18.5527 4.76953 18.3965 5.16016 18.1719L6.2041 17.5685V14.633V13.4815C6.2041 12.4757 6.61309 11.9682 7.46663 11.9001C7.46663 10 9.07077 8.01343 11.4472 8.01343C13.8237 8.01343 15.4278 10 15.4278 11.901C15.5875 11.9144 15.7314 11.9429 15.86 11.9869L16.5469 11.5898C17.3574 11.1113 17.6406 10.7988 17.6406 10.2812C17.6406 9.76367 17.3574 9.45117 16.5469 8.98242L5.16016 2.39062C4.76953 2.16602 4.4375 2.01953 4.04688 2.01953C3.32422 2.01953 2.875 2.56641 2.875 3.41602V17.1465C2.875 17.9961 3.32422 18.5527 4.04688 18.5527ZM10.1094 12.9648H12.7852V11.8418C12.7852 10.8262 12.2871 10.2793 11.4473 10.2793C10.6074 10.2793 10.1094 10.8262 10.1094 11.8418V12.9648ZM14.0645 12.9707V11.9492C14.0645 10.1816 13.0098 9 11.4473 9C9.8848 9 8.8301 10.1816 8.8301 11.9492V12.97C8.2689 13.0149 8 13.3485 8 14.0098V17.8086C8 18.5215 8.3125 18.8535 8.9668 18.8535H13.918C14.582 18.8535 14.8945 18.5215 14.8945 17.8086V14.0098C14.8945 13.3515 14.6281 13.0179 14.0645 12.9707Z"})}))}},80548:function(e,t,i){i.d(t,{A:()=>l});var a=i(69277),s=i(70408),n=i(32641),o=i(4006),r=i(97731);let l=e=>{var{size:t=24,fill:i="var(--color-fg-primary)"}=e,l=(0,n._)(e,["size","fill"]);return(0,o.Y)(r.A,(0,s._)((0,a._)({},l),{name:"TwitterIcon",svgParams:{viewBox:"0 0 20 20"},width:t,height:t,fill:i,stroke:"none",children:(0,o.Y)("path",{stroke:"none",d:"M6.2918 18.1249C13.8371 18.1249 17.9652 11.8721 17.9652 6.45143C17.9652 6.27565 17.9613 6.09596 17.9535 5.92018C18.7566 5.33943 19.4496 4.62009 20 3.79596C19.2521 4.12871 18.458 4.34603 17.6449 4.44049C18.5011 3.9273 19.1421 3.1211 19.4492 2.17135C18.6438 2.64868 17.763 2.98539 16.8445 3.16705C16.2257 2.50951 15.4075 2.07414 14.5164 1.92825C13.6253 1.78237 12.711 1.93409 11.9148 2.35996C11.1186 2.78583 10.4848 3.46213 10.1115 4.2843C9.73825 5.10648 9.64619 6.02872 9.84961 6.90846C8.21874 6.82662 6.62328 6.40296 5.16665 5.66496C3.71002 4.92696 2.42474 3.89108 1.39414 2.62448C0.870333 3.52758 0.710047 4.59625 0.945859 5.61329C1.18167 6.63033 1.79589 7.51942 2.66367 8.09987C2.01219 8.07918 1.37498 7.90378 0.804688 7.58815V7.63893C0.804104 8.58667 1.13175 9.50537 1.73192 10.2389C2.3321 10.9723 3.16777 11.4753 4.09687 11.6624C3.49338 11.8275 2.85999 11.8515 2.2457 11.7327C2.50788 12.5477 3.01798 13.2606 3.70481 13.7718C4.39164 14.283 5.22093 14.567 6.07695 14.5842C4.62369 15.7258 2.82848 16.345 0.980469 16.3421C0.652739 16.3416 0.325333 16.3215 0 16.2819C1.87738 17.4863 4.06128 18.126 6.2918 18.1249Z"})}))}},41873:function(e,t,i){i.d(t,{A:()=>E,b:()=>A});var a=i(99851),s=i(69277),n=i(70408),o=i(4006),r=i(32485),l=i.n(r),d=i(17402),p=i(68414),h=i(59307),u=i(13505),c=i(86500),y=i(53928),m=i(13022),v=i(17186),w=i(68349),g=i(89490),_=i(35369),f=i(13348),b=i(39318),P=i(9036),k=i(82776),T=i(18012);let C={hls:"application/x-mpegURL",mp4:"video/mp4"};class E extends d.Component{componentDidMount(){this._initHlsjs(),null===w.dO||void 0===w.dO||w.dO.on("play",this.onGlobalPlay),"undefined"!=typeof window&&(document.addEventListener("keydown",this.onGlobalKeyDown,!1),window.addEventListener("beforeunload",this.onBeforeUnload,!1)),this.player&&(this.player.volume=1,this.player.addEventListener("loadedmetadata",this.onLoadedMetadata),this.player.addEventListener("loadeddata",this.onLoadedData),this.player.addEventListener("canplay",this.onCanPlay),this.player.addEventListener("play",this.onPlay),this.player.addEventListener("pause",this.onPause),this.player.addEventListener("ended",this.onEnded),this.player.addEventListener("timeupdate",this.onTimeUpdate),this.player.addEventListener("waiting",this.onWaiting),this.player.addEventListener("playing",this.onPlaying),this.player.addEventListener("contextmenu",this.onContextMenu),this.player.addEventListener("click",this.onUserInteraction),this.player.addEventListener("mouseover",this.onUserInteraction),this.player.addEventListener("mousedown",this.onUserInteraction),this.player.addEventListener("touchstart",this.onUserInteraction),this.player.addEventListener("seeked",this.onSeeked)),this.onTimeUpdate();let e=window.location.pathname.startsWith("/p/")&&"post"===this.props.surface&&"post"===this.props.videoType,t=window.location.pathname.startsWith("/watch");if(this.player&&"undefined"!=typeof window&&window._cbv_strategies&&(e||t)&&(window._cbv=window._cbv||[],window._cbv.push(this.player),(0,y.MZ)(this.player)),window&&window._preloads.mux_env_key){let{entityType:e}=this.getEntityKeyAndType();i.e("25505").then(i.t.bind(i,21624,23)).then(t=>{var i;let a=t.default||t;a.monitor(this.player,{Hls:this.hlsModule,hlsjs:this.hls,debug:!1,data:{env_key:window._preloads.mux_env_key,player_name:null!=(i=this.props.surface)?i:"substack",player_init_time:a.utils.now(),video_id:this.props.mediaUpload.id,video_stream_type:e}})})}}componentWillUnmount(){var e;this.setPlaybackRestoreLocation(),this.lastTimeUpdate=null,this.previewHiddingTimeout&&clearTimeout(this.previewHiddingTimeout),null==(e=this._autoplayObserver)||e.disconnect(),this._autoplayObserver=null,null===w.dO||void 0===w.dO||w.dO.off("play",this.onGlobalPlay),"undefined"!=typeof window&&(document.removeEventListener("keydown",this.onGlobalKeyDown,!1),window.removeEventListener("beforeunload",this.onBeforeUnload,!1)),this.player&&(this.player.removeEventListener("loadedmetadata",this.onLoadedMetadata),this.player.removeEventListener("loadeddata",this.onLoadedData),this.player.removeEventListener("canplay",this.onCanPlay),this.player.removeEventListener("play",this.onPlay),this.player.removeEventListener("pause",this.onPause),this.player.removeEventListener("ended",this.onEnded),this.player.removeEventListener("timeupdate",this.onTimeUpdate),this.player.removeEventListener("waiting",this.onWaiting),this.player.removeEventListener("playing",this.onPlaying),this.player.removeEventListener("contextmenu",this.onContextMenu),this.player.removeEventListener("click",this.onUserInteraction),this.player.removeEventListener("mouseover",this.onUserInteraction),this.player.removeEventListener("mousedown",this.onUserInteraction),this.player.removeEventListener("touchstart",this.onUserInteraction),this.player.removeEventListener("seeked",this.onSeeked),(0,y.cO)()),this.onVideoReachEnd({resetTime:!1,triggerCallback:!1,track:!1}),null!=this.hls&&this.hls.destroy()}componentDidUpdate(e,t){var i,a,n;if((this.props.noPreview!==e.noPreview||this.props.noControls!==e.noControls||this.props.noKeyboardShortcuts!==e.noKeyboardShortcuts||this.props.mediaUpload.id!==e.mediaUpload.id)&&(this._initHlsjs(),this.resetDurationTracking()),!this.state.playing&&"number"==typeof this.state.waiting&&"number"!=typeof t.waiting){let{useHLSJS:e,browserCanPlayHLS:t,HLSerrored:i}=this.state;this.track(c.qY.VIDEO_BUFFERING_STARTED,{use_hlsjs:e,browser_can_play_hls:t,hls_errored:i})}if(!this.state.playing||t.playing||this.state.waiting||"number"!=typeof t.waiting||this.track(c.qY.VIDEO_BUFFERING_COMPLETED,{buffering_duration:Date.now()-t.waiting}),this.state.playing&&!(null==(i=this.player)?void 0:i.ended)&&Math.floor(this.state.currentTime)!==Math.floor(t.currentTime)&&Math.floor(this.state.currentTime)%5==0&&(this.trackMedia(c.qY.MEDIA_PLAYBACK_CONTINUED),this.props.mediaUpload.post_id&&this.state.duration&&(!this.props.surface||"post"===this.props.surface)&&(!this.props.videoType||"post"===this.props.videoType)&&!this.props.isClip)){let e=Math.min(Math.max(0,this.state.currentTime/this.state.duration),1);(0,u.AG)(this.props.mediaUpload.post_id,"video",e)}if(!this.state.playing&&t.playing&&(null==(a=this.player)?void 0:a.ended)&&this.trackMedia(c.qY.MEDIA_PLAYBACK_COMPLETED),this.props.mediaUpload.id&&(0,m.Ay)("use_preloaded_player_sources")&&(this.props.mediaUpload.id!==e.mediaUpload.id||!(null==(n=Object.keys(this.state.sources))?void 0:n.length))){let e=async e=>fetch((0,b.oRR)("/api/v1/video/upload/".concat(this.props.mediaUpload.id,"/src.json"),{type:e})).then(e=>e.json()).then(t=>({[e]:t.src}));Promise.all(["hls"].map(t=>e(t))).then(e=>{let t=e.reduce((e,t)=>(0,s._)({},e,t),{});this.setState({sources:t})})}}getPlaybackLocationKey(){return"".concat("video:playback_location:").concat(this.props.mediaUpload.id)}shouldShowNativeVideoControls(){let{noControls:e,noPreview:t}=this.props,{previewHidden:i,showControls:a}=this.state;return a&&!e&&!(!t&&!i)}getPlaybackRestoreLocation(){if(this.playbackEnabled()&&this.props.restorePlaybackLocation&&this.props.mediaUpload.duration&&this.props.mediaUpload.duration>240){let e=(0,v.xm)(this.getPlaybackLocationKey());if((null==e?void 0:e.currentTime)>5&&null!==this.props.duration&&void 0!==this.props.duration&&this.props.duration-e.currentTime>60){let t=3*(Date.now()-e.watchedAt>60),i=Math.max(0,e.currentTime-t);if(i)return i}}return null}setPlaybackRestoreLocation(){var e;this.playbackEnabled()&&(null==(e=this.player)?void 0:e.currentTime)&&(0,v.X3)(this.getPlaybackLocationKey(),{currentTime:this.player.currentTime,watchedAt:Date.now()})}onPreviewClick(e){var t,i,a,s,n;if(this.props.disableClickToPlayPause)return;let o=!(0,w.nr)()||!this.shouldShowNativeVideoControls();if((this.props.stopPropagation||o)&&(e.preventDefault(),e.stopPropagation()),null==(t=this.player)||t.setAttribute("data-user-changed-playback","true"),this.state.previewHidden){o&&((null==(i=this.player)?void 0:i.paused)?this.player.play().catch(e=>{console.warn("VideoPlayer: play() was rejected after user click",e)}):null==(a=this.player)||a.pause());return}if(!this.href()){if(!this.playbackEnabled())return void this.onClickNonPlayableVideo();this.state.attemptingToPlay?(this.lastTimeUpdate=null,this.setState({attemptingToPlay:!1,autoPlay:!1}),null==(s=this.player)||s.pause(),this.previewHiddingTimeout&&clearTimeout(this.previewHiddingTimeout)):(this.setState({attemptingToPlay:!0}),null==(n=this.player)||n.play().catch(e=>{console.warn("VideoPlayer: play() was rejected on preview click",e),this.setState({attemptingToPlay:!1,autoPlay:!1})}),this.previewHiddingTimeout=window.setTimeout(()=>this.setState({previewHidden:!0}),3e3))}}track(e){var t,i,a,s;let n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=this.props.communityPostEmbedPostId||this.props.mediaUpload.post_id,r=this.props.mediaUpload.user_id;(0,c.u4)(e,Object.assign({post_id:o,video_user_id:r,community_post_id:this.props.communityPostId,media_upload_id:this.props.mediaUpload.id,live_stream_id:this.props.liveStreamId,current_time:this.state.currentTime?Math.floor(this.state.currentTime):0,duration:this.state.duration&&isFinite(this.state.duration)?Math.floor(this.state.duration):0,is_clip:null!=(i=this.props.isClip)&&i,surface:this.props.surface,is_preview:null!=(a=this.props.usePreview)&&a,muted:null!=(s=null==(t=this.player)?void 0:t.muted)&&s,video_type:this.props.videoType,display:(0,w.aS)()?"fullscreen":document.pictureInPictureElement?"pip":"inline"},n))}trackMedia(e){var t,i,a,o,r,l,d,p,h;let u=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{mediaUpload:y,videoType:m,surface:v,primaryEntityKey:g,primaryEntityType:_,contentType:f,feedItemTrackingParameters:b}=this.props,P=null!=f?f:m?null!=(a=({communityCommentReply:"communityComment","video-embed":"embed"})[m])?a:m:"unknown",{entityKey:k,entityType:T}=this.getEntityKeyAndType(),C=Array.from(null!=(o=null==(t=this.player)?void 0:t.textTracks)?o:[]),E=C.length>0,A=this.isShowingCaptionsElsewhere||C.some(e=>["subtitles","captions"].includes(e.kind)&&"showing"===e.mode);(0,c.u4)(e,(0,s._)((0,n._)((0,s._)({},b),{media_type:"video",video_upload_id:y.id,src_video_upload_id:y.src_media_upload_id,content_type:P,primary_entity_key:String(null!=g?g:k),primary_entity_type:null!=_?_:T,entity_key:String(k),entity_type:T,publication_id:y.publication_id,surface:v,display:(0,w.aS)()?"fullscreen":document.pictureInPictureElement?"pip":"inline",muted:null!=(r=null==(i=this.player)?void 0:i.muted)&&r,captions_enabled:E?A:null,autoplay:this.state.autoPlay&&!this.state.failedAutoplay,is_preview:null!=(l=this.props.usePreview)&&l,current_time:Math.floor(null!=(d=this.state.currentTime)?d:0),duration:isFinite(null!=(p=this.state.duration)?p:0)?Math.floor(null!=(h=this.state.duration)?h:0):0,duration_played:Math.floor(this.state.durationPlayed),duration_played_id:this.state.durationPlayedId}),u))}render(){var e;let t=this.props,i=null!=(e=this.state)?e:{},{height:a,width:s}=(0,k.videoPlayerDimensions)(t.mediaUpload,{isStatic:!1}),n=l()("video-player",{"video-player-clip":t.isClipping,"video-player-with-background":!t.omitBackgroundColor},t.videoPlayerClassName);return(0,o.Y)(S,{className:l()(t.className,{"with-preview":!i.previewHidden,"full-width":s>=960,"video-player-wrapper-clip":t.isClipping,"video-player-with-background":!t.omitBackgroundColor}),linkClassName:n,href:this.href(),width:s,height:a,onClick:this.onPreviewClick,style:t.style,liveStreamId:t.liveStreamId,children:this.renderPlayer(this.props,this.state)})}renderPlayer(e,t){var i,a;let{hidePlayButton:s,mediaUpload:n,noPreview:r,renderPlayButton:l,renderOverlay:p,startMuted:u,videoClassName:c,liveStreamId:y,loop:v,thumbnailUrl:g,noPictureInPicture:P=!1}=e,{autoPlay:k,attemptingToPlay:E,previewHidden:A,useHLSJS:S,browserCanPlayHLS:U,HLSerrored:Y,failedAutoplay:I,playing:M}=t,R=!this.playbackEnabled(),H=this.getBaseVideoSrc(),O=[];O=y?["hls"]:U?["hls","mp4"]:S?[]:(0,w.m0)()?["hls","mp4"]:Y?["mp4"]:["hls","mp4"];let N=(0,w.rr)(),V=(0,w.gI)(),F=!!(0,m.Ay)("use_preloaded_player_sources")&&N,B=k&&!I&&this.playbackEnabled(),x=g||"".concat((0,b.H10)(n),"?refresh=").concat(n.updated_at),K=this.shouldShowNativeVideoControls();return[this.playbackEnabled()&&"undefined"!=typeof window&&(0,o.Y)("video",{ref:this.assignPlayer,controls:K,controlsList:"nodownload",autoPlay:B,preload:B?"auto":"metadata",title:(null==(i=this.props.post)?void 0:i.title)||void 0,"data-video-id":this.props.mediaUpload.id,"data-video-title":(null==(a=this.props.post)?void 0:a.title)||void 0,poster:x,muted:u,loop:v,className:c,playsInline:N||V,disablePictureInPicture:P,crossOrigin:"anonymous",children:F?Object.entries(this.state.sources).map((e,t)=>{let[i,a]=e;return(0,o.Y)("source",{src:a,type:C[i],onError:t===Object.keys(this.state.sources).length-1?this.onAllSourcesFailed:void 0},"".concat(i,"_").concat(t))}):O.map((e,t)=>(0,o.Y)("source",{src:(0,b.oRR)(H,{type:e}),type:C[e],onError:t===O.length-1?this.onAllSourcesFailed:void 0},"".concat(e,"_").concat(t)))},"video"),p&&(0,o.Y)("div",{className:T.A.previewOverlay,children:p({isPlaying:M,getCurrentTimeInSeconds:()=>this.state.currentTime})},"overlay"),!r&&!A&&!s&&(0,o.FD)(d.Fragment,{children:[R&&(0,o.Y)(L,{mediaUpload:n,thumbnailUrl:x}),!l&&(0,o.Y)(D,{children:this.cta()?(0,o.Y)(_.Bj,{href:this.href(),loading:E&&this.playbackEnabled(),"aria-label":"play",leading:(0,o.Y)(h.A,{height:16,width:16,style:{stroke:"none",fill:"white"}}),children:this.cta()}):(0,o.Y)(f.ro,{isPlaying:!1,href:this.href(),size:72,loading:E&&this.playbackEnabled()})}),l&&(0,o.Y)(D,{children:l()})]},"preview")]}isChromeWithBrokenNativeHLS(){var e;if("undefined"==typeof navigator)return!1;let t=null==(e=navigator.userAgentData)?void 0:e.brands;if(!t)return!1;let i=t.find(e=>"Google Chrome"===e.brand);return i&&parseInt(i.version)>=141}_initHlsjs(){let e=!!(this.player&&this.player.canPlayType("application/vnd.apple.mpegurl"));if(e&&!(0,w.m0)()&&!this.isChromeWithBrokenNativeHLS()){this.setState({browserCanPlayHLS:e}),this.autoPlayVideo();return}i.e("9234").then(i.bind(i,40137)).then(e=>{this._initHlsjsWrapped(e.default)})}autoPlayVideo(){if(this.state.autoPlay&&this.player){var e;null==(e=this._autoplayObserver)||e.disconnect(),this._autoplayObserver=new IntersectionObserver(e=>{e.forEach(e=>{var t,i;null==(t=this._autoplayObserver)||t.unobserve(e.target),e.isIntersecting&&this.player&&(this.player.muted=null!=(i=this.props.startMuted)&&i,this.player.play().catch(e=>{console.error("Unable to autoplay prior to user interaction with the dom.",e),this.setState({failedAutoplay:!0,attemptingToPlay:!1}),this.player&&(this.player.muted=!0,this.player.play().then(()=>{var e,t;null==(e=(t=this.props).onAutoplayMuted)||e.call(t)}).catch(e=>{console.error("Unable to autoplay prior to user interaction with the dom when muted.",e),this.setState({failedAutoplay:!0,attemptingToPlay:!1})}))}))})},{threshold:.5}),this._autoplayObserver.observe(this.player)}}_initHlsjsWrapped(e){let t=this,i=e.isSupported();if(!e.isSupported()){this.setState({useHLSJS:i}),this.autoPlayVideo();return}null!=this.hls&&this.hls.destroy();let a=new e((0,s._)({enableWorker:!1},{}));null!=this.player&&a.attachMedia(this.player);let n=this.getBaseVideoSrc("hls");a.on(e.Events.MEDIA_ATTACHED,()=>{a.loadSource(n),a.on(e.Events.MANIFEST_PARSED,()=>{var e,t;this.autoPlayVideo(),null==(e=(t=this.props).onPlaybackReady)||e.call(t)})}),a.on(e.Events.ERROR,(i,s)=>{var n,o,r;if(t.props.liveStreamId&&(null==(n=s.response)?void 0:n.code)===412){a.destroy(),null==(o=(r=t.props).onPlaybackNotReady)||o.call(r);return}if(s.fatal)switch(s.type){case e.ErrorTypes.NETWORK_ERROR:t.setState({useHLSJS:!1}),a.destroy();break;case e.ErrorTypes.MEDIA_ERROR:a.recoverMediaError();break;default:t._initHlsjs()}}),this.hls=a,this.hlsModule=e}constructor(e,t){var i,o;super(e,t),i=this,(0,a._)(this,"player",null),(0,a._)(this,"previewHiddingTimeout",null),(0,a._)(this,"lastTimeUpdate",null),(0,a._)(this,"_accumulatedDurationPlayed",0),(0,a._)(this,"containerRef",(0,d.createRef)()),(0,a._)(this,"isShowingCaptionsElsewhere",!1),(0,a._)(this,"_autoplayObserver",null),(0,a._)(this,"assignPlayer",e=>{this.player=e}),(0,a._)(this,"resetDurationTracking",()=>{this.lastTimeUpdate=null,this._accumulatedDurationPlayed=0,this.setState({durationPlayed:0,durationPlayedId:(0,p.v4)()})}),(0,a._)(this,"onLoadedMetadata",()=>{this.state.playbackRestoreLocation&&(this.player&&(this.player.currentTime=this.state.playbackRestoreLocation),this.previewHiddingTimeout=window.setTimeout(()=>this.setState({playbackRestoreLocation:null,previewHidden:!0}),3e3))}),(0,a._)(this,"onLoadedData",()=>{this.state.playbackRestoreLocation&&(this.previewHiddingTimeout&&clearTimeout(this.previewHiddingTimeout),this.setState({playbackRestoreLocation:null,previewHidden:!0}))}),(0,a._)(this,"onCanPlay",()=>{this.onTimeUpdate()}),(0,a._)(this,"onPlay",()=>{null===w.dO||void 0===w.dO||w.dO.emit("play",this),this.setState({playing:!0}),this.lastTimeUpdate=Date.now(),this.trackMedia(c.qY.MEDIA_PLAYBACK_STARTED)}),(0,a._)(this,"onPause",()=>{var e;this.setPlaybackRestoreLocation(),this.lastTimeUpdate=null,this.setState({playing:!1,waiting:!1,previewHidden:!this.props.showPreviewWhenPaused&&this.state.previewHidden}),(null==(e=this.player)?void 0:e.ended)||this.trackMedia(c.qY.MEDIA_PLAYBACK_PAUSED),this.player&&this.player.currentTime>this.player.duration-.1&&this.onVideoReachEnd()}),(0,a._)(this,"onEnded",()=>{this.lastTimeUpdate=null,this.setState({playing:!1,waiting:!1,previewHidden:!this.props.showPreviewWhenPaused&&this.state.previewHidden}),this.trackMedia(c.qY.MEDIA_PLAYBACK_PAUSED),this.onVideoReachEnd()}),(0,a._)(this,"onTimeUpdate",()=>{if(!this.player||!isFinite(this.player.duration)&&!1!==this.props.isLive)return;let e=this.player.currentTime,t=Date.now();if(this.state.playing&&null!==this.lastTimeUpdate){let e=(t-this.lastTimeUpdate)/1e3;e>0&&e<1&&(this._accumulatedDurationPlayed=(this._accumulatedDurationPlayed||0)+e,this._accumulatedDurationPlayed>=1&&(this.setState(e=>({durationPlayed:e.durationPlayed+this._accumulatedDurationPlayed})),this._accumulatedDurationPlayed=0))}this.lastTimeUpdate=t;let i=this.props.duration||this.player.duration;(this.props.duration||this.state.duration===this.player.duration)&&this.state.currentTime===e?!1!==this.state.waiting&&this.setState({waiting:!1}):this.setState({duration:isFinite(i)?i:this.state.duration,currentTime:e,waiting:!1})}),(0,a._)(this,"onWaiting",()=>{this.lastTimeUpdate=null,this.setState({waiting:Date.now()})}),(0,a._)(this,"onPlaying",()=>{this.previewHiddingTimeout&&clearTimeout(this.previewHiddingTimeout),this.lastTimeUpdate=Date.now(),this.setState({playing:!0,waiting:!1,previewHidden:!0,attemptingToPlay:!1,autoPlay:!1,hasPlayed:!0})}),(0,a._)(this,"onSeeked",()=>{this.lastTimeUpdate=Date.now(),this.trackMedia(c.qY.MEDIA_SEEKED)}),(0,a._)(this,"onVideoReachEnd",function(){let{resetTime:e=!0,triggerCallback:t=!0,track:a=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};i.lastTimeUpdate=null,i.player&&!i.player.paused&&i.player.pause(),i.state.previewHidden&&i.setState({previewHidden:!1,attemptingToPlay:!1,hasReachedEnd:!0}),e&&i.player&&!(0,w.gI)()&&!i.props.doNotResetOnEnd&&(i.player.currentTime=0),(0,w.Eh)(),(0,w.wp)(),i.props.onFinishVideo&&t&&i.props.onFinishVideo(),a&&i.trackMedia(c.qY.MEDIA_PLAYBACK_COMPLETED)}),(0,a._)(this,"onContextMenu",e=>{e.preventDefault()}),(0,a._)(this,"onUserInteraction",()=>{this.state.showControls||this.setState({showControls:!0})}),(0,a._)(this,"onAllSourcesFailed",()=>{var e,t;console.info("Failed to load all video sources, falling back to preview image"),this.setState((0,n._)((0,s._)({},this.props.liveStreamId?{}:{previewHidden:!1,attemptingToPlay:!1,autoPlay:!1}),{allSourcesFailed:!0})),null==(e=(t=this.props).onPlaybackFailed)||e.call(t)}),(0,a._)(this,"onBeforeUnload",()=>{this.setPlaybackRestoreLocation(),this.state.previewHidden&&this.setState({previewHidden:!1,attemptingToPlay:!1}),this.player&&!this.player.paused&&this.player.pause()}),(0,a._)(this,"onGlobalPlay",e=>{this!==e&&this.player&&!this.player.paused&&this.player.pause()}),(0,a._)(this,"onGlobalKeyDown",e=>{var t;this.props.noKeyboardShortcuts||e.metaKey||e.altKey||e.ctrlKey||document.activeElement!==document.body||!this.player||(!((null!=(t=null===w.dO||void 0===w.dO?void 0:w.dO.listenerCount("play"))?t:0)>1)||!this.player.paused)&&("f"===e.key?(0,w.aS)()?(0,w.Eh)()&&e.preventDefault():((0,w.gK)(this.player)&&e.preventDefault(),this.player.paused&&this.player.play().catch(e=>{console.warn("VideoPlayer: play() was rejected on fullscreen key",e)})):" "!==e.key||(0,w.aS)()?"ArrowRight"===e.key?this.player.currentTime+5>this.player.duration?this.onVideoReachEnd():(this.player.currentTime+=5,this.state.previewHidden||this.setState({previewHidden:!0,attemptingToPlay:!1})):"ArrowLeft"===e.key&&(this.player.currentTime-=5):(e.preventDefault(),this.player.paused?this.player.play().catch(e=>{console.warn("VideoPlayer: play() was rejected on keyboard shortcut",e)}):this.player.pause()))}),(0,a._)(this,"getEntityKeyAndType",()=>{let{mediaUpload:e,communityPostId:t,entityKey:i,entityType:a}=this.props;return i?{entityKey:i,entityType:a}:t?{entityKey:t,entityType:"community_post"}:e.post_id?{entityKey:String(e.post_id),entityType:"post"}:{entityKey:i,entityType:a}}),(0,a._)(this,"getBaseVideoSrc",e=>{var t;let i={token:this.props.reaction_token,override_publication_id:null==(t=this.props.pub)?void 0:t.id,preview:this.props.usePreview};return e&&(i.type=e),(0,b.oRR)("/api/v1/video/upload/".concat(this.props.mediaUpload.id,"/src"),i)}),(0,a._)(this,"hls",null),(0,a._)(this,"hlsModule",void 0),(0,a._)(this,"cta",()=>""),(0,a._)(this,"href",()=>this.props.href),(0,a._)(this,"playbackEnabled",()=>!0),(0,a._)(this,"onClickNonPlayableVideo",()=>{});const r="undefined"!=typeof window?(0,P.m)(window.location.href):{};let l=null;r.timestamp?l=parseInt(r.timestamp):r.t&&(l=parseInt(r.t));const h=null!==l&&!isNaN(l);h||(0,w.qm)("timestamp");const u=h?l:this.getPlaybackRestoreLocation();this.state={playbackRestoreLocation:u,currentTime:0,waiting:!0,duration:null!=(o=e.mediaUpload.duration)?o:null,autoPlay:e.autoPlay,playing:!1,attemptingToPlay:e.autoPlay,previewHidden:null!==u&&u>0,showControls:!1,hasPlayed:!1,hasReachedEnd:!1,browserCanPlayHLS:!1,useHLSJS:!0,HLSerrored:!1,allSourcesFailed:!1,failedAutoplay:!1,sources:{},durationPlayed:0,durationPlayedId:(0,p.v4)()},this.onPreviewClick=this.onPreviewClick.bind(this)}}function A(e){let{className:t,mediaUpload:i,href:a}=e;return(0,o.Y)(S,(0,n._)((0,s._)({},(0,k.videoPlayerDimensions)(i,{isStatic:!0})),{className:l()(t,"video-player-with-background","is-static"),linkClassName:"video-player-with-background",href:a,children:(0,o.Y)(L,{mediaUpload:i,testId:"video-player-static-preview-image",isStatic:!0})}))}function S(e){let{className:t,linkClassName:i,width:a,height:s,href:n,onClick:r,children:d,style:p,liveStreamId:h}=e,u={paddingBottom:"".concat(Math.min(h?56.25:60,100*s/a).toFixed(4),"%")};return(0,o.Y)("div",{className:l()(t,"video-player-wrapper",a>=960&&"full-width"),onClick:r,role:"region","aria-label":"Video player",style:p,children:(0,o.Y)(n?"a":"div",{className:l()("video-player",i),href:n,style:u,children:d})})}function L(e){let{mediaUpload:t,thumbnailUrl:i,testId:a,isStatic:s}=e;return(0,o.Y)("img",{className:"video-player-preview",width:550,src:i||(0,b.Pzx)(t,{isStatic:s}),"data-component-name":"VideoPlayer-PreviewImg","data-testid":a})}let D=(0,g.I4)({position:"absolute",className:l()(T.A.buttonContainer,"video-player-button")})},80988:function(e,t,i){i.d(t,{a:()=>v,k:()=>w});var a=i(4006),s=i(35426),n=i(38390),o=i(17402),r=i(89490),l=i(90460),d=i(10996),p=i(45346),h=i(48028),u=i(98793),c=i(11510),y=i(53168),m=i(57241);function v(e){let{isOpen:t,onOpen:i=()=>void 0,onClose:r=()=>void 0,children:y,width:m=440,className:v,initialFocus:g,fullscreenMobile:_,disableCloseOnBackdropClick:f=!1,testId:b="modal",style:P}=e,k=(0,c.Iu)(),T=(0,o.useRef)(t);(0,l.h)(t),(0,o.useEffect)(()=>{t&&!T.current&&(null==i||i()),T.current=t},[t,i]);let C=k&&!_?u.r:u.p;return(0,a.Y)(n.bL,{open:t,onOpenChange:e=>{e||null==r||r()},children:(0,a.Y)(n.ZL,{forceMount:!0,children:(0,a.Y)(s.e.Root,{show:t,children:(0,a.FD)(w,{children:[(0,a.Y)(p.B,{children:(0,a.Y)(p.k,{onClose:r,disableCloseOnBackdropClick:f})}),(0,a.Y)(d.e$,{children:(0,a.Y)(C,{children:(0,a.Y)(h.I,{onClose:r,fullscreenMobile:_,width:m,className:v,initialFocus:g,disableCloseOnBackdropClick:f,testId:b,style:P,children:y})},k?"mobile":"desktop")})]})})})})}function w(e){let{children:t}=e;return(0,a.Y)(r.az,{className:m.A.layout,style:{zIndex:y.Up},children:t})}},45346:function(e,t,i){i.d(t,{B:()=>d,k:()=>l});var a=i(4006),s=i(35426),n=i(38390),o=i(17402),r=i(55739);let l=(0,o.forwardRef)((e,t)=>{let{onClose:i,disableCloseOnBackdropClick:s}=e;return(0,a.Y)(n.hJ,{forceMount:!0,className:r.A.backdrop,ref:t,"data-modal-role":"backdrop",onClick:()=>{s||i()}})});function d(e){let{children:t}=e;return(0,a.Y)(s.e.Child,{enter:r.A.transition,enterFrom:r.A.from,enterTo:r.A.to,leave:r.A.transition,leaveFrom:r.A.to,leaveTo:r.A.from,children:t})}},98793:function(e,t,i){i.d(t,{p:()=>d,r:()=>p});var a=i(4006),s=i(35426),n=i(32485),o=i.n(n),r=i(17402),l=i(37266);let d=e=>{let{children:t}=e;return(0,a.Y)(s.e.Child,{as:r.Fragment,enter:l.A.transition,enterFrom:l.A.from,enterTo:l.A.to,leave:l.A.transition,leaveFrom:l.A.to,leaveTo:l.A.from,children:t})},p=e=>{let{children:t}=e;return(0,a.Y)(s.e.Child,{as:r.Fragment,enter:o()(l.A.transition,l.A.mobile),enterFrom:o()(l.A.from,l.A.mobile),enterTo:o()(l.A.to,l.A.mobile),leave:o()(l.A.transition,l.A.mobile),leaveFrom:o()(l.A.to,l.A.mobile),leaveTo:o()(l.A.from,l.A.mobile),children:t})}},24777:function(e,t,i){i.d(t,{A:()=>c,d:()=>u});var a=i(69277),s=i(70408),n=i(32641),o=i(4006),r=i(39651),l=i(32485),d=i.n(l);i(17402);var p=i(84605),h=i(77700);function u(e){var{size:t="md",theme:i="accent",onChange:l}=e,u=(0,n._)(e,["size","theme","onChange"]);let{iString:c}=(0,p.GO)();return(0,o.Y)(r.bL,(0,s._)((0,a._)({onCheckedChange:l,"aria-label":u["aria-label"]||c("Toggle setting"),className:d()(h.A.root,h.A[t],h.A["theme_".concat(i)])},u),{children:(0,o.Y)(r.zi,{className:d()(h.A.thumb,h.A[t])})}))}let c=u},67211:function(e,t,i){i.d(t,{Y:()=>r});var a=i(4006),s=i(60322),n=i(76977),o=i(63136);let r=e=>{let{contentBelow:t,details:i,disabled:r,label:l,name:d,paddingBottom:p,paddingTop:h,testid:u,track:c,value:y,onChange:m,usePublicationTheme:v}=e;return(0,a.FD)(n.Ye,{as:"label",gap:8,cursor:"pointer",paddingBottom:p,paddingTop:h,children:[(0,a.Y)(s.S,{checked:y,name:null!=d?d:u,"data-testid":u,"data-track-input":c,disabled:r,size:"sm",onChange:m}),(0,a.FD)(n.I1,{flex:"grow",children:[(0,a.Y)(o.EY.B4,{as:"span",color:r?v?"pub-secondary-text":"secondary":v?"pub-primary-text":"primary",children:l}),i&&(0,a.Y)(o.EY.B5,{color:v?"pub-secondary-text":"secondary",children:i}),t]})]})}},84270:function(e,t,i){i.d(t,{z:()=>o});var a=i(4006),s=i(25318),n=i(94996);let o=e=>{let{details:t,helpText:i,label:o,name:r,options:l,paddingBottom:d,paddingTop:p,flex:h,value:u,disabled:c,onChange:y}=e;return(0,a.Y)(s.D,{label:o,details:t,helpText:i,paddingTop:p,paddingBottom:d,flex:h,wrapWithLabel:!0,children:(0,a.Y)(n.I,{name:r,value:u,onChange:e=>{let t=e.target;y(t.value,{name:t.name})},disabled:c,children:l.map(e=>(0,a.Y)("option",{value:e.value,children:e.label},e.value))})})}},58278:function(e,t,i){i.d(t,{HN:()=>d,JG:()=>r,d9:()=>o,uB:()=>l});var a=i(12550),s=i.n(a),n=i(82776);let o=function(e){let{softMax:t=32,hardMax:i=48,extension:a=!1,extensionSeparator:n="-"}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=r(e);if(o.length>t){let e=o.indexOf("-",t);-1!==e&&(o=o.substr(0,e))}o.length>i&&(o=o.substr(0,i));let l=a&&"string"==typeof a?a:s()().substr(0,3);return o?a&&(o+="".concat(n).concat(l)):o=l,o},r=function(e){let{hashIfEmpty:t=!1,allowUnicode:i=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=(e||"").toString().normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().trim().replace(/\s+/g,"-").replace(/&/g,"-and-").replace(i?RegExp("[^\\p{L}\\p{N}-]+","gu"):/[^\w-]+/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"");return e&&"string"==typeof e&&!a&&t?Array.from(e).map(e=>e.codePointAt(0)).map(e=>{var t;return null!=(t=null==e?void 0:e.toString(16))?t:""}).join("").substring(0,12):a},l=(e,t)=>r((0,n.truncateText)(e,500,{ellipsis:""}),{allowUnicode:t}),d=(e,t)=>{let i=l(e,!0),a=l(e,!1);return t<0x3f9b46c&&i!==a?a:i}}}]);