kollapsminoriteten/wp-content/plugins/jetpack/_inc/blocks/podcast-player/view.js

15 lines
29 KiB
JavaScript
Raw Normal View History

2025-08-27 08:44:30 +02:00
(()=>{var e={86954:e=>{function t(e,t=100,r={}){if("function"!=typeof e)throw new TypeError(`Expected the first parameter to be a function, got \`${typeof e}\`.`);if(t<0)throw new RangeError("`wait` must not be negative.");const{immediate:s}="boolean"==typeof r?{immediate:r}:r;let a,o,n,i,c;function l(){const t=a,r=o;return a=void 0,o=void 0,c=e.apply(t,r),c}function d(){const e=Date.now()-i;e<t&&e>=0?n=setTimeout(d,t-e):(n=void 0,s||(c=l()))}const u=function(...e){if(a&&this!==a&&Object.getPrototypeOf(this)===Object.getPrototypeOf(a))throw new Error("Debounced method called with different contexts of the same prototype.");a=this,o=e,i=Date.now();const r=s&&!n;return n||(n=setTimeout(d,t)),r&&(c=l()),c};return Object.defineProperty(u,"isPending",{get:()=>void 0!==n}),u.clear=()=>{n&&(clearTimeout(n),n=void 0)},u.flush=()=>{n&&u.trigger()},u.trigger=()=>{c=l(),u.clear()},u}e.exports.debounce=t,e.exports=t},44997:e=>{var t=1e3,r=60*t,s=60*r,a=24*s,o=7*a,n=365.25*a;function i(e,t,r,s){var a=t>=1.5*r;return Math.round(e/r)+" "+s+(a?"s":"")}e.exports=function(e,c){c=c||{};var l=typeof e;if("string"===l&&e.length>0)return function(e){if((e=String(e)).length>100)return;var i=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(e);if(!i)return;var c=parseFloat(i[1]);switch((i[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return c*n;case"weeks":case"week":case"w":return c*o;case"days":case"day":case"d":return c*a;case"hours":case"hour":case"hrs":case"hr":case"h":return c*s;case"minutes":case"minute":case"mins":case"min":case"m":return c*r;case"seconds":case"second":case"secs":case"sec":case"s":return c*t;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return c;default:return}}(e);if("number"===l&&isFinite(e))return c.long?function(e){var o=Math.abs(e);if(o>=a)return i(e,o,a,"day");if(o>=s)return i(e,o,s,"hour");if(o>=r)return i(e,o,r,"minute");if(o>=t)return i(e,o,t,"second");return e+" ms"}(e):function(e){var o=Math.abs(e);if(o>=a)return Math.round(e/a)+"d";if(o>=s)return Math.round(e/s)+"h";if(o>=r)return Math.round(e/r)+"m";if(o>=t)return Math.round(e/t)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},82389:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});var s=r(86087),a=r(13022),o=r(79094),n=r(10790);const i=(0,s.memo)((({playerId:e,title:t,cover:r,link:s,track:a,children:o,showEpisodeTitle:i,showCoverArt:l,showEpisodeDescription:d,colors:u})=>l||i||d?(0,n.jsxs)("div",{className:"jetpack-podcast-player__header",children:[(0,n.jsxs)("div",{className:"jetpack-podcast-player__current-track-info",children:[l&&r&&(0,n.jsx)("div",{className:"jetpack-podcast-player__cover",children:(0,n.jsx)("img",{className:"jetpack-podcast-player__cover-image",src:r,alt:""})}),i&&!!(t||a&&a.title)&&(0,n.jsx)(c,{playerId:e,title:t,link:s,track:a,colors:u})]}),!!(d&&a&&a.description)&&(0,n.jsx)("p",{id:`${e}__track-description`,className:"jetpack-podcast-player__track-description",children:a.description}),o]}):o)),c=(0,s.memo)((({playerId:e,title:t,link:r,track:s,colors:i={primary:{name:null,custom:null,classes:""}}})=>(0,n.jsxs)("h2",{id:`${e}__title`,className:"jetpack-podcast-player__title",children:[!(!s||!s.title)&&(0,n.jsxs)("span",{className:(0,a.A)("jetpack-podcast-player__current-track-title",i.primary.classes),style:{color:i.primary.custom},children:[s.title,(0,n.jsx)("a",{className:"jetpack-podcast-player__track-title-link",href:s.link||s.src,target:"_blank",rel:"noopener noreferrer nofollow",children:o.A})]}),!!(s&&s.title&&t)&&(0,n.jsx)("span",{className:"jetpack-podcast-player--visually-hidden",children:" - "}),!!t&&(0,n.jsx)(l,{title:t,link:r,colors:i})]}))),l=(0,s.memo)((({title:e,link:t})=>(0,n.jsx)("span",{className:"jetpack-podcast-player__podcast-title",children:t?(0,n.jsx)("a",{className:"jetpack-podcast-player__link",href:t,target:"_blank",rel:"noopener noreferrer nofollow",children:e}):{title:e}}))),d=i},3750:(e,t,r)=>{"use strict";r.d(t
`${(0,i.sprintf)(__("Loading: %s","jetpack"),r)} ${o}`,"assertive"),!0};loadAndPlay=e=>{this.recordUserInteraction(),this.loadTrack(e)&&this.props.playMediaSource(this.props.playerId)};getTrack=e=>this.props.tracks[e];handleError=e=>{if(!this.state.hasUserInteraction){const t=window.navigator.userAgent.match(/Trident\/7\./)?"IE11: Playing sounds in webpages setting is not checked":e;this.setState((()=>{throw new Error(t)}))}this.props.errorMediaSource(this.props.playerId),(0,s.speak)(`${__("Error: Episode unavailable - Open in a new tab","jetpack")}`,"assertive")};handlePlay=()=>{this.props.playMediaSource(this.props.playerId),this.setState({hasUserInteraction:!0})};handlePause=()=>{this.props.pauseMediaSource(this.props.playerId),this.props.playerState!==d.pF&&this.props.pauseMediaSource(this.props.playerId)};handleTimeChange=e=>{this.props.setMediaSourceCurrentTime(this.props.playerId,e)};handleJump=()=>{this.props.setMediaSourceCurrentTime(this.props.playerId,this.props.currentTime-5)};handleSkip=()=>{this.props.setMediaSourceCurrentTime(this.props.playerId,this.props.currentTime+30)};updateMediaData=e=>{this.props.updateMediaSourceData(this.props.playerId,{duration:e.target?.duration,domId:e.target?.id})};registerPlayer(){const e=this.getTrack(this.state.currentTrack)||{},{playerId:t}=this.props;this.props.registerMediaSource(t,{title:e.title,link:e.link,state:d.vh}),this.props.setDefaultMediaSource(t)}componentDidMount(){this.props.playerId&&this.registerPlayer()}componentWillUnmount(){this.props.playerId&&this.props.unregisterMediaSource(this.props.playerId)}componentDidUpdate(e){const t=e=>e?.length?e.map((e=>e.guid)):[],r=t(this.props.tracks),s=new Set(t(e.tracks));r.length===s.size&&r.every((e=>s.has(e)))||this.loadTrack(0)}static getDerivedStateFromProps(e,t){return e.tracks.length<=t.currentTrack?{...t,currentTrack:0}:null}render(){const{playerId:e,title:t,link:r,cover:s,tracks:a,attributes:o,currentTime:n,playerState:d}=this.props,{itemsToShow:m,primaryColor:f,customPrimaryColor:g,hexPrimaryColor:k,secondaryColor:C,customSecondaryColor:v,hexSecondaryColor:E,backgroundColor:w,customBackgroundColor:S,hexBackgroundColor:j,showCoverArt:_,showEpisodeTitle:b,showEpisodeDescription:M}=o,{currentTrack:T}=this.state,A=a.slice(0,m),x=this.getTrack(T),F=(0,u.GU)({primaryColor:f,customPrimaryColor:g,secondaryColor:C,customSecondaryColor:v,backgroundColor:w,customBackgroundColor:S}),I={color:v,backgroundColor:S,"--jetpack-podcast-player-primary":k,"--jetpack-podcast-player-secondary":E,"--jetpack-podcast-player-background":j},P=(0,c.A)("jetpack-podcast-player",d,F.secondary.classes,F.background.classes);return(0,y.jsxs)("section",{className:P,style:I,"aria-labelledby":t||x&&x.title?`${e}__title`:void 0,"aria-describedby":x&&x.description?`${e}__track-description`:void 0,"data-jetpack-iframe-ignore":!0,children:[(0,y.jsx)(p.A,{playerId:e,title:t,link:r,cover:s,track:this.getTrack(T),showCoverArt:_,showEpisodeTitle:b,showEpisodeDescription:M,colors:F,children:(0,y.jsx)(l.A,{onJumpBack:this.handleJump,onSkipForward:this.handleSkip,trackSource:this.getTrack(T).src,onPlay:this.handlePlay,onPause:this.handlePause,onError:this.handleError,playStatus:d,currentTime:n,onTimeChange:this.handleTimeChange,onMetadataLoaded:this.updateMediaData})}),A.length>1&&(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)("h4",{id:`jetpack-podcast-player__tracklist-title--${e}`,className:"jetpack-podcast-player--visually-hidden",children:(0,i.sprintf)(
2022-12-15 17:41:53 +01:00
// translators: %s is the track title.
2025-08-27 08:44:30 +02:00
__("Playlist: %s","jetpack"),t)}),(0,y.jsx)("p",{id:`jetpack-podcast-player__tracklist-description--${e}`,className:"jetpack-podcast-player--visually-hidden",children:__("Select an episode to play it in the audio player.","jetpack")}),(0,y.jsx)(h.A,{playerId:e,playerState:d,currentTrack:T,tracks:A,selectTrack:this.selectTrack,colors:F})]})]})}}f.defaultProps={title:"",cover:"",link:"",attributes:{url:null,itemsToShow:5,showCoverArt:!0,showEpisodeTitle:!0,showEpisodeDescription:!0},tracks:[]};const g=(0,a.compose)([m.A,(0,o.withSelect)(((e,t)=>{const{playerId:r}=t,{getMediaSourceCurrentTime:s,getMediaPlayerState:a}=e(d.ax);return{currentTime:s(r),playerState:a(r)}})),(0,o.withDispatch)((e=>{const{registerMediaSource:t,updateMediaSourceData:r,unregisterMediaSource:s,setDefaultMediaSource:a,playMediaSource:o,pauseMediaSource:n,toggleMediaSource:i,errorMediaSource:c,setMediaSourceCurrentTime:l}=e(d.ax);return{registerMediaSource:t,updateMediaSourceData:r,unregisterMediaSource:s,setDefaultMediaSource:a,playMediaSource:o,pauseMediaSource:n,toggleMediaSource:i,errorMediaSource:c,setMediaSourceCurrentTime:l}}))])(f)},74050:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});var s=r(86087),a=r(27723),o=r(10790);const __=a.__,n=(0,s.memo)((({link:e,title:t,colors:r})=>(0,o.jsxs)("div",{className:"jetpack-podcast-player__track-error",children:[__("Episode unavailable.","jetpack")," ",e&&(0,o.jsx)("span",{className:r.secondary.classes,style:{color:r.secondary.custom},children:(0,o.jsxs)("a",{className:"jetpack-podcast-player__link",href:e,rel:"noopener noreferrer nofollow",target:"_blank",children:[(0,o.jsx)("span",{className:"jetpack-podcast-player--visually-hidden",children:`${(0,a.sprintf)(/* translators: %s is the title of the track. This text is visually hidden from the screen, but available to screen readers. */
__("%s:","jetpack"),t)} `}),__("Open in a new tab","jetpack")]})})]})))},35311:(e,t,r)=>{"use strict";r.d(t,{A:()=>i});var s=r(86087),a=r(27723),o=r(62796),n=r(10790);const __=a.__,i=(0,s.memo)((({isPlaying:e,isError:t,className:r})=>{let s,a;t?(a="error",
2022-04-02 10:26:41 +02:00
/* translators: This is text to describe the current state. This will go
before the track title, such as "Error: [The title of the track]". */
2025-07-27 19:58:08 +02:00
s=__("Error:","jetpack")):e&&(a="playing",
2022-04-02 10:26:41 +02:00
/* translators: Text to describe the current state. This will go before the
track title, such as "Playing: [The title of the track]". */
2025-08-27 08:44:30 +02:00
s=__("Playing:","jetpack"));const i=o[a];return i?(0,n.jsxs)("span",{className:`${r} ${r}--${a}`,children:[(0,n.jsx)("span",{className:"jetpack-podcast-player--visually-hidden",children:`${s} `}),i]}):(0,n.jsx)("span",{className:r})}))},91677:(e,t,r)=>{"use strict";r.d(t,{A:()=>d});var s=r(86087),a=r(27723),o=r(13022),n=r(19812),i=r(74050),c=r(35311),l=r(10790);const __=a.__,d=(0,s.memo)((({track:e,isActive:t,isPlaying:r,isError:s,selectTrack:a,index:d,colors:u={primary:{},secondary:{}}})=>{const p=(0,n.tQ)("color",u.primary.name),h=(0,n.tQ)("color",u.secondary.name),m=(0,o.A)("jetpack-podcast-player__track",{"is-active":t,"has-primary":t&&(u.primary.name||u.primary.custom),[p]:t&&!!p,"has-secondary":!t&&(u.secondary.name||u.secondary.custom),[h]:!t&&!!h}),y={};t&&u.primary.custom&&!p?y.color=u.primary.custom:t||!u.secondary.custom||h||(y.color=u.secondary.custom);const
2022-04-02 10:26:41 +02:00
/* translators: This needs to be a single word with no spaces. It describes
the current item in the group. A screen reader will announce it as "[title],
current track". */
2025-08-27 08:44:30 +02:00
f=t?__("track","jetpack"):void 0;return(0,l.jsxs)("li",{className:m,style:Object.keys(y).length?y:null,children:[(0,l.jsxs)("a",{className:"jetpack-podcast-player__link jetpack-podcast-player__track-link",href:e.link||e.src,role:"button","aria-current":f,onClick:e=>{e.shiftKey||e.metaKey||e.altKey||(e.preventDefault(),a(d))},onKeyDown:e=>{" "===event.key&&(e.preventDefault(),a(d))},children:[(0,l.jsx)(c.A,{className:"jetpack-podcast-player__track-status-icon",isPlaying:r,isError:s}),(0,l.jsx)("span",{className:"jetpack-podcast-player__track-title",children:e.title}),e.duration&&(0,l.jsx)("time",{className:"jetpack-podcast-player__track-duration",dateTime:e.duration,children:e.duration})]}),t&&s&&(0,l.jsx)(i.A,{link:e.link,title:e.title,colors:u})]})}))},81166:(e,t,r)=>{"use strict";r.d(t,{A:()=>n});var s=r(86087),a=r(27723),o=r(10790);const __=a.__;function n(e){class t extends s.Component{state={didError:!1,isIE11AudioIssue:!1};componentDidCatch=(e,t)=>{this.props.onError(e,t)};static getDerivedStateFromError=e=>({didError:!0,isIE11AudioIssue:!!e.message.match(/IE11/)});render(){const{didError:t,isIE11AudioIssue:r}=this.state;return t?(0,o.jsx)("section",{className:"jetpack-podcast-player",children:(0,o.jsx)("p",{className:"jetpack-podcast-player__error",children:r?__('The podcast player cannot be displayed as your browser settings do not allow for sounds to be played in webpages. This can be changed in your browsers "Internet options" settings. In the "Advanced" tab you will have to check the box next to "Play sounds in webpages" in the "Multimedia" section. Once you have confirmed that the box is checked, please press "Apply" and then reload this page.',"jetpack"):__("An unexpected error occured within the Podcast Player. Reloading this page might fix the problem.","jetpack",0)})}):(0,o.jsx)(e,{...this.props})}}return t.defaultProps={onError:()=>{}},t}},79094:(e,t,r)=>{"use strict";r.d(t,{A:()=>o});var s=r(5573),a=r(10790);const o=(0,a.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,a.jsx)(s.Path,{d:"M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"})})},62796:(e,t,r)=>{"use strict";r.r(t),r.d(t,{error:()=>i,playing:()=>n});var s=r(5573),a=r(10790);const o={height:"24",viewBox:"0 0 24 24",width:"24",xmlns:"http://www.w3.org/2000/svg"},n=(0,a.jsxs)(s.SVG,{...o,children:[(0,a.jsx)(s.Path,{d:"M0 0h24v24H0V0z",fill:"none"}),(0,a.jsx)(s.Path,{d:"M3 9v6h4l5 5V4L7 9H3zm7-.17v6.34L7.83 13H5v-2h2.83L10 8.83zM16.5 12c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77 0-4.28-2.99-7.86-7-8.77z"})]}),i=(0,a.jsxs)(s.SVG,{...o,children:[(0,a.jsx)(s.Path,{d:"M0 0h24v24H0V0z",fill:"none"}),(0,a.jsx)(s.Path,{d:"M11 15h2v2h-2zm0-8h2v6h-2zm.99-5C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2zM12 20c-4.42 0-8-3.58-8-8s3.58-8 8-8 8 3.58 8 8-3.58 8-8 8z"})]})},19812:(e,t,r)=>{"use strict";r.d(t,{GU:()=>n,tQ:()=>a});var s=r(13022);function a(e,t){if(e&&t)return`has-${t}-${e}`}const o={},n=e=>{const t=Object.values(e).join();return o[t]??=(({primaryColor:e,customPrimaryColor:t,secondaryColor:r,customSecondaryColor:o,backgroundColor:n,customBackgroundColor:i})=>{const c=a("color",e),l=a("color",r),d=a("background-color",n);return{primary:{name:e,custom:t,classes:(0,s.A)({"has-primary":c||t,[c]:c})},secondary:{name:r,custom:o,classes:(0,s.A)({"has-secondary":l||o,[l]:l})},background:{name:n,custom:i,classes:(0,s.A)({"has-background":d||i,[d]:d})}}})(e)}},72445:(e,t,r)=>{"use strict";r.d(t,{A:()=>p});var s=r(20195),a=r(86087),o=r(27723),n=r(86954),i=r.n(n),c=r(23117),l=r(10790);const __=o.__,d="undefined"!=typeof _wpmejsSettings?_wpmejsSettings:{};function u(e,t,r){const s=document.createElement("div");s.className=e;const a=document.createElement("button");return a.innerText=t,a.addEventListe