"use strict";(self.webpackChunksubstack=self.webpackChunksubstack||[]).push([["9044"],{16564:function(t,e,a){a.d(e,{KH:()=>S,MR:()=>k,YX:()=>_,_g:()=>Z,cM:()=>X,ko:()=>N,nO:()=>M});var l,w,r=a(7409),s=a(99282),i=a(58865),n=a(16584),o=a(94184),d=a.n(o),c=a(1852),u=a(86657);a(36081),a(36813);var b=a(99987),m=a(1055),p=a(72708),f=a(95441);a(68833);var h=a(15771),v=a(6490),x=a(84864),g=a(72925);function y(){let t=(0,i._)(["Playback rate ",""]);return y=function(){return t},t}var k=((l={}).Embed="Embed audio",l.Voiceover="Add voiceover",l.Podcast="Audio",l.PodcastPreview="Podcast free version",l.VideoPodcast="Video",l.ShareQuote="Share quote",l),Z=((w={})[w.PubAccent=0]="PubAccent",w[w.PubFull=1]="PubFull",w[w.Substack=2]="Substack",w);let N=t=>{let{containerRef:e,currentTime:a,remainingTime:l,progress:w,onMouseDown:r,shouldCollapseOnMobile:s=!1,theme:i=1}=t;return(0,n.BX)("div",{className:"tw-flex tw-grow tw-items-center tw-gap-3 tw-font-meta tw-text-sm tw-text-substack-primary sm:tw-gap-3","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":100*w,children:[(0,n.tZ)("div",{className:d()("tw-min-w-[40px] tw-text-right",{"tw-hidden sm:tw-block":s}),children:a}),(0,n.BX)("div",{ref:e,className:d()("tw-relative tw-h-5 tw-grow ",{"tw-ml-2 sm:tw-ml-0":s}),onMouseDown:r,children:[(0,n.tZ)("div",{className:d()("audio-progress-bar tw-absolute tw-top-2 tw-right-0 tw-left-0 tw-h-1 tw-rounded",{"tw-bg-pub-detail":1===i,"tw-bg-substack-detail":1!==i})}),(0,n.tZ)("div",{className:d()("tw-absolute tw-top-2 tw-left-0 tw-h-1 tw-rounded-l-full",{"tw-bg-pub-accent":2!==i,"tw-bg-substack-accent":2===i}),style:{width:"".concat(100*w,"%")}}),(0,n.tZ)("div",{className:d()("audio-playhead tw-absolute tw-ml-[-10px] tw-h-4 tw-w-4 tw-rounded-full tw-border-2 tw-border-solid ",{"tw-border-pub-background":1===i,"tw-border-substack-bg":1!==i,"tw-bg-substack-accent":2===i,"tw-bg-pub-accent":2!==i}),style:{left:"".concat(100*w,"%")}})]}),(0,n.tZ)("div",{className:"tw-min-w-[40px]",children:l})]})},P=[{value:1,display:"1"},{value:1.25,display:"1.25"},{value:1.5,display:"1.5"},{value:1.75,display:"1.75"},{value:2,display:"2"}],B=t=>{var e;let{onSetPlaybackRate:a,playbackRate:l,className:w}=t,r=P.findIndex(t=>{let{value:e}=t;return e===l}),{iTemplate:s}=(0,f.M1)(),i=(null==P?void 0:null===(e=P[r])||void 0===e?void 0:e.display)?"".concat(null==P?void 0:P[r].display,"x"):"";return(0,n.BX)("div",{onClick:()=>{let t=(r+1)%P.length;a(P[t].value)},className:w,"aria-label":s(y(),i),children:[P[r].display,"\xd7"]})},X=t=>{let{iString:e}=(0,f.M1)();return(0,n.tZ)(u.Z,(0,s._)((0,r._)({},t),{metricsPost:t.post,feature:"Embed audio",render:a=>{let{currentTime:l,isPlaying:w,progress:r,progressBarRef:s,progressBarOnMouseDown:i,remainingTime:o,playbackRate:d,setPlaybackRate:c,togglePlayback:u}=a;return(0,n.BX)("div",{"data-component-name":"AudioEmbedPlayer","data-drag-handle":"",className:"audio-embed tw-my-4 tw-box-border tw-flex tw-w-full tw-select-none tw-items-center tw-gap-4 tw-space-y-0 tw-rounded-full tw-bg-pub-wash tw-p-4 tw-font-sans sm:tw-gap-5",role:"region","aria-label":e("Audio embed player"),children:[(0,n.tZ)(B,{onSetPlaybackRate:c,playbackRate:d,className:"audio-button tw-w-12 tw-cursor-pointer tw-rounded-full tw-border tw-border-solid tw-border-pub-detail-light tw-py-1 tw-text-center tw-font-meta tw-text-sm tw-font-semibold tw-leading-none tw-text-pub-secondary-text hover:tw-border-pub-detail"}),(0,n.BX)("div",{className:"tw-flex tw-w-full tw-flex-wrap",children:[t.label&&(0,n.tZ)("div",{className:"tw-basis-full tw-pb-2 tw-text-ssm tw-font-semibold tw-text-pub-primary-text",children:t.label}),(0,n.tZ)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-gap-2 sm:tw-gap-4",children:(0,n.tZ)(N,{currentTime:l,remainingTime:o,containerRef:s,progress:r,onMouseDown:i})})]}),(0,n.tZ)("div",{className:"audio-embed-play-button tw-relative tw-flex tw-h-12 tw-w-12 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-rounded-full tw-border-2 tw-border-solid tw-border-pub-detail tw-bg-pub-background tw-transition-transform hover:tw-scale-105",onClick:u,role:"button","aria-label":e("Play/pause"),children:w?(0,n.BX)("div",{className:"tw-flex tw-h-5 tw-w-4 tw-justify-between",children:[(0,n.tZ)("div",{className:"pause-icon tw-h-full tw-w-1/3 tw-rounded-sm tw-bg-pub-accent"}),(0,n.tZ)("div",{className:"pause-icon tw-h-full tw-w-1/3 tw-rounded-sm tw-bg-pub-accent"})]}):(0,n.tZ)(m.Z,{className:"tw-relative tw-left-[.1rem] tw-fill-pub-accent",stroke:"none",height:18})})]})}}))},M=t=>{var e;let{pub:a,post:l,duration:w,label:r}=t,{iString:s}=(0,f.M1)();return(0,n.tZ)("table",{"data-component-name":"AudioEmbedPlayerStatic",className:"tw-w-full tw-rounded-full tw-bg-substack-wash",children:(0,n.tZ)("tr",{children:(0,n.tZ)("td",{className:"tw-text-center tw-font-meta tw-text-ssm tw-uppercase tw-text-substack-primary",children:(0,n.BX)("a",{href:null==l?void 0:l.canonical_url,className:d()("tw-block tw-w-full tw-p-4 tw-text-substack-primary",g.Z.noUnderline),children:[(0,n.tZ)(b.Z,{className:"tw-w-max-4 tw-mr-2 tw-inline-block tw-w-4 tw-align-middle",stroke:null===(e=a.theme)||void 0===e?void 0:e.background_pop_color,isStatic:!0}),(0,n.BX)("span",{className:"tw-align-middle",children:[(0,x.truncateText)(r,10)||s("Listen now")," \xb7 ",(0,x.secondsToHHMMSS)(w||0)]})]})})})})},S=t=>{let e=(0,c.useMediaQuery)({maxWidth:631}),a="/api/v1/audio/upload/".concat(t.mediaUploadId,"/src"),{iString:l}=(0,f.M1)();return(0,n.tZ)(u.Z,(0,s._)((0,r._)({},t),{src:a,feature:"Add voiceover",metricsPost:t.post,render:t=>{let{isPaywalled:a,currentTime:w,isPlaying:r,progress:s,progressBarRef:i,progressBarOnMouseDown:o,remainingTime:d,playbackRate:c,setPlaybackRate:u,togglePlayback:b}=t;return(0,n.BX)("div",{className:"tw-mb-6 tw-flex sm:tw-gap-1",children:[(0,n.tZ)("div",{className:"tw-hidden tw-h-20 tw-shrink-0 tw-basis-20 tw-items-center tw-justify-center tw-rounded-md tw-bg-pub-wash tw-fill-pub-primary-text tw-text-pub-primary-text sm:tw-flex",children:(0,n.tZ)(p.Z,{className:"tw-stroke-pub-secondary-text"})}),(0,n.BX)("div",{className:"tw-box-border tw-flex tw-h-20 tw-w-full tw-select-none tw-items-center tw-gap-3 tw-space-y-0 tw-rounded-l-md tw-rounded-r-[64px] tw-bg-pub-wash tw-p-4 tw-font-sans",children:[a?(0,n.tZ)("div",{className:"tw-flex tw-w-full tw-flex-wrap tw-justify-center tw-text-ssm tw-text-pub-secondary-text sm:tw-text-sm",children:l("Upgrade to paid to play voiceover")}):(0,n.BX)("div",{className:"tw-flex tw-w-full tw-flex-wrap",children:[(0,n.tZ)("div",{className:"tw-basis-full tw-pb-2 tw-text-ssm tw-font-semibold tw-uppercase tw-text-pub-secondary-text",children:l("Article voiceover")}),(0,n.BX)("div",{className:"tw-flex tw-w-full tw-items-center tw-justify-between tw-gap-2 ",children:[(0,n.tZ)(B,{onSetPlaybackRate:u,playbackRate:c,className:"tw-w-12 tw-cursor-pointer tw-rounded-full tw-border tw-border-solid tw-border-pub-detail-light tw-py-1 tw-text-center tw-font-meta tw-text-sm tw-font-semibold tw-leading-none tw-text-pub-secondary-text hover:tw-border-pub-detail"}),(0,n.tZ)(N,{currentTime:w,remainingTime:d,containerRef:i,progress:s,onMouseDown:o,shouldCollapseOnMobile:!0})]})]}),a?(0,n.tZ)("div",{className:"tw-relative tw-flex tw-h-14 tw-w-14 tw-shrink-0 tw-cursor-not-allowed tw-items-center tw-justify-center tw-rounded-full tw-border-2 tw-border-solid tw-border-pub-detail tw-bg-pub-background tw-transition-transform",children:(0,n.tZ)(m.Z,{className:"tw-relative tw-left-[.15rem] tw-fill-pub-detail",stroke:"none",height:e?20:24})}):(0,n.tZ)("div",{className:"tw-relative tw-flex tw-h-14 tw-w-14 tw-shrink-0 tw-cursor-pointer tw-items-center tw-justify-center tw-rounded-full tw-border-2 tw-border-solid tw-border-pub-detail tw-bg-pub-background tw-transition-transform hover:tw-scale-105",onClick:b,role:"button",children:r?(0,n.BX)("div",{className:"tw-flex tw-h-5 tw-w-5 tw-justify-between",children:[(0,n.tZ)("div",{className:"tw-h-full tw-w-1/3 tw-rounded-sm tw-bg-pub-accent"}),(0,n.tZ)("div",{className:"tw-h-full tw-w-1/3 tw-rounded-sm tw-bg-pub-accent"})]}):(0,n.tZ)(m.Z,{className:"tw-relative tw-left-[.15rem] tw-fill-pub-accent",stroke:"none",height:20})})]})]})}}))},_=t=>{let{isOpen:e,onDismiss:a}=t,{iString:l}=(0,f.M1)();return(0,n.BX)(v.u_,{isOpen:e,onClose:a,children:[(0,n.tZ)(v.xB,{showClose:!1,title:l("Something went wrong...")}),(0,n.tZ)(v.fe,{children:l("Unfortunately, there was a problem with your audio file upload. We'll investigate, but in the meantime, please try again, and we apologize for the inconvenience.")}),(0,n.tZ)(v.mz,{showDivider:!1,direction:"row",primaryButton:(0,n.tZ)(h.zx,{onClick:a,priority:"primary",children:l("Got it")})})]})}}}]);