@byomakase/omakase-react-components 1.4.1 → 1.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +2 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.es.js +34 -28
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -97,8 +97,8 @@ ${n(m)}`)}),d.join(`
|
|
|
97
97
|
`)}function s(l){const d=[];l.identifier&&d.push(l.identifier);const f=c(l.start),m=c(l.end),h=l.styles?`${l.styles}`:"";return d.push(`${f} --> ${m} ${h}`),d.push(l.text),d.join(`
|
|
98
98
|
`)}function c(l){const d=(l%1).toFixed(3);l=Math.round(l-d);const f=Math.floor(l/3600),m=Math.floor((l-f*3600)/60),h=l-f*3600-m*60;return`${`${i(f,2)}:`}${i(m,2)}:${i(h,2)}.${i(d*1e3,3)}`}return Kr={hlsSegment:t,hlsSegmentPlaylist:r},Kr}var Jr,hu;function U1(){if(hu)return Jr;hu=1;const e=Bm().parse,t=E1().compile,r=Km().segment,i=O1();return Jr={parse:e,compile:t,segment:r,hls:i},Jr}var D1=U1();async function N1(e){const t=await fetch(e);if(!t.ok)throw new Error(`Failed to fetch: ${e}`);const r=await t.arrayBuffer();return new TextDecoder("utf-8").decode(r)}function gu(e){e<0&&(e=0);const t=Math.floor(e/3600).toString().padStart(2,"0"),r=Math.floor(e%3600/60).toString().padStart(2,"0"),i=(e%60).toFixed(3).padStart(6,"0");return`${t}:${r}:${i}`}async function j1(e,t){return e.length?await Promise.all(e.map(async i=>{const n=await N1(i),o=D1.parse(n,{strict:!1,meta:!0});let a=o.cues;t!==void 0&&(a=a.map(l=>({...l,start:l.start-t,end:l.end-t})).filter(l=>l.end>0).map(l=>({...l,start:Math.max(0,l.start),end:Math.max(0,l.end)})));const u=[];u.push("WEBVTT"),o.meta&&o.meta["X-TIMESTAMP-MAP=LOCAL"]&&u.push(`X-TIMESTAMP-MAP=LOCAL${o.meta["X-TIMESTAMP-MAP=LOCAL"]}`),u.push("");for(const l of a)u.push(`${gu(l.start)} --> ${gu(l.end)}`),u.push(l.text),u.push("");const s=u.join(`
|
|
99
99
|
`).trim()+`
|
|
100
|
-
`,c=new Blob([s],{type:"text/vtt"});return URL.createObjectURL(c)})):[]}class P1{static slewSubtitlesFlows(t,r){return new ye(i=>{(async()=>{var n;try{const o=(n=t.subflows)==null?void 0:n.filter(
|
|
101
|
-
`)}static generateThumbnailVttBlob(t,r,i){const n=this.generateThumbnailVtt(t,r,i),o=new Blob([n],{type:"text/vtt"});return URL.createObjectURL(o)}static toTimestamp(t){const r=Math.floor(t/3600),i=Math.floor(t%3600/60),n=Math.floor(t%60),o=Math.round(t%1*1e3);return`${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}.${String(o).padStart(3,"0")}`}static generateThumbnailTrackUrl(t,r,i,n){const o=this.resolveLowestQualityImageFlow(t);return o?this.generateThumbnailVttBlob(r.get(o.id),i,n):void 0}}class Jm{constructor(t){k(this,"_player");k(this,"_videoApiProxy");k(this,"_authenticationData");k(this,"_tamsEndpoint");this._player=new V.OmakasePlayer(t),this._videoApiProxy=new Gu(this._player),this._authenticationData=t==null?void 0:t.authentication}loadVideo(t,r){if(r!=null&&r.duration&&(r!=null&&r.timerange)&&console.warn("Duration and timerange are both set. Using timerange."),this._videoApiProxy.loadOptions=structuredClone(r),this._videoApiProxy.requestedDuration=r==null?void 0:r.duration,typeof t=="string")if((r==null?void 0:r.protocol)===void 0){const i=this._tamsEndpoint??uu(t).at(0);if(i===null)throw Error("Provided URL is not pointing to TAMS");const n=new lu(i,this._authenticationData?su(this._authenticationData):void 0),o=(r==null?void 0:r.timerange)??(r==null?void 0:r.duration);return Rr(a=>{n.fetchManifestResources(t,o).pipe(Mr(u=>this._loadTamsMedia(u,r))).subscribe(a)})}else return this._player.loadVideo(t,r);else if(Array.isArray(t)){if(r!=null&&r.protocol)throw new Error(`Protocol ${r.protocol} can't be used with TAMS media`);const i=this._tamsEndpoint??uu(t.at(0)).at(0);if(i===null)throw Error("Provided URL is not pointing to TAMS");const n=new lu(i,this._authenticationData?su(this._authenticationData):void 0),o=(r==null?void 0:r.timerange)??(r==null?void 0:r.duration);return Rr(a=>{n.fetchManifestResourcesForMultipleFlows(t,o).pipe(Mr(u=>this._loadTamsMedia(u,r).pipe(Ma(s=>{var c;return s.tamsMediaData&&(s.tamsMediaData.flow=void 0,(c=s.tamsMediaData.flowsSegments)==null||c.delete(yn)),s})))).subscribe(a)})}else return this._loadTamsMedia(t,r)}_loadTamsMedia(t,r){return Rr(i=>{const n=ph([t.flow,...t.subflows??[]],t.flowsSegments,r==null?void 0:r.ffomTimeZoneOffset),o={protocol:"hls",ffom:n.ffom,frameRate:n.frameRate,dropFrame:n.dropFrame};let a;r?(r.protocol="hls",a={...o,...r,ffom:o.ffom}):a=o,delete a.duration,this._videoApiProxy.requestedDuration=r==null?void 0:r.duration;const u=Cu(t.flow,t.subflows,t.flowsSegments);if(!u.valid){i.error(u.message);return}if(r&&!z1(r)){i.error("Invalid ffomTimeZoneOffset");return}P1.slewSubtitlesFlows(t,n).pipe(Mr(
|
|
100
|
+
`,c=new Blob([s],{type:"text/vtt"});return URL.createObjectURL(c)})):[]}class P1{static slewSubtitlesFlows(t,r){return new ye(i=>{(async()=>{var n;try{const o=new Map,a=(n=t.subflows)==null?void 0:n.filter(u=>u.format==="urn:x-nmos:format:data"&&u.container==="text/vtt");a!=null&&a.length&&await Promise.all(a.map(async u=>{const s=t.flowsSegments.get(u.id),c=s.map(f=>{var m;return(m=f.get_urls)==null?void 0:m.at(-1).url});let l=await j1(c,r.mediaStartTime);l=l.map(f=>T1(f));const d=s.map((f,m)=>({...f,get_urls:[{url:l.at(m)}]}));o.set(u.id,d)})),i.next(o),i.complete()}catch(o){i.error(o)}})()})}}class A1{static resolveLowestQualityImageFlow(t){const r=t.filter(n=>n.format==="urn:x-tam:format:image");return r.length===0?void 0:r.reduce((n,o)=>{if(n===void 0)return o;const a=n.essence_parameters.frame_width*n.essence_parameters.frame_height;return o.essence_parameters.frame_height*o.essence_parameters.frame_width<a?o:n},void 0)}static generateThumbnailVtt(t,r,i){let n=["WEBVTT",""];return t.forEach((o,a)=>{if((o.get_urls||[]).length===0)return;const s=P.timeMomentToSeconds(P.parseTimeRange(o.timerange).start);let c;if(a===t.length-1?c=r-.001:c=P.timeMomentToSeconds(P.parseTimeRange(t.at(a+1).timerange).start)-.001,c<=s){console.debug(`Malformed thumbnail vtt cue, skipped ${s} --> ${c}`);return}const l=this.toTimestamp(s-i),d=this.toTimestamp(c-i);n.push(`${l} --> ${d}`),n.push(o.get_urls.at(-1).url),n.push("")}),n.join(`
|
|
101
|
+
`)}static generateThumbnailVttBlob(t,r,i){const n=this.generateThumbnailVtt(t,r,i),o=new Blob([n],{type:"text/vtt"});return URL.createObjectURL(o)}static toTimestamp(t){const r=Math.floor(t/3600),i=Math.floor(t%3600/60),n=Math.floor(t%60),o=Math.round(t%1*1e3);return`${String(r).padStart(2,"0")}:${String(i).padStart(2,"0")}:${String(n).padStart(2,"0")}.${String(o).padStart(3,"0")}`}static generateThumbnailTrackUrl(t,r,i,n){const o=this.resolveLowestQualityImageFlow(t);return o?this.generateThumbnailVttBlob(r.get(o.id),i,n):void 0}}class Jm{constructor(t){k(this,"_player");k(this,"_videoApiProxy");k(this,"_authenticationData");k(this,"_tamsEndpoint");this._player=new V.OmakasePlayer(t),this._videoApiProxy=new Gu(this._player),this._authenticationData=t==null?void 0:t.authentication}loadVideo(t,r){if(r!=null&&r.duration&&(r!=null&&r.timerange)&&console.warn("Duration and timerange are both set. Using timerange."),this._videoApiProxy.loadOptions=structuredClone(r),this._videoApiProxy.requestedDuration=r==null?void 0:r.duration,typeof t=="string")if((r==null?void 0:r.protocol)===void 0){const i=this._tamsEndpoint??uu(t).at(0);if(i===null)throw Error("Provided URL is not pointing to TAMS");const n=new lu(i,this._authenticationData?su(this._authenticationData):void 0),o=(r==null?void 0:r.timerange)??(r==null?void 0:r.duration);return Rr(a=>{n.fetchManifestResources(t,o).pipe(Mr(u=>this._loadTamsMedia(u,r))).subscribe(a)})}else return this._player.loadVideo(t,r);else if(Array.isArray(t)){if(r!=null&&r.protocol)throw new Error(`Protocol ${r.protocol} can't be used with TAMS media`);const i=this._tamsEndpoint??uu(t.at(0)).at(0);if(i===null)throw Error("Provided URL is not pointing to TAMS");const n=new lu(i,this._authenticationData?su(this._authenticationData):void 0),o=(r==null?void 0:r.timerange)??(r==null?void 0:r.duration);return Rr(a=>{n.fetchManifestResourcesForMultipleFlows(t,o).pipe(Mr(u=>this._loadTamsMedia(u,r).pipe(Ma(s=>{var c;return s.tamsMediaData&&(s.tamsMediaData.flow=void 0,(c=s.tamsMediaData.flowsSegments)==null||c.delete(yn)),s})))).subscribe(a)})}else return this._loadTamsMedia(t,r)}_loadTamsMedia(t,r){return Rr(i=>{const n=ph([t.flow,...t.subflows??[]],t.flowsSegments,r==null?void 0:r.ffomTimeZoneOffset),o={protocol:"hls",ffom:n.ffom,frameRate:n.frameRate,dropFrame:n.dropFrame};let a;r?(r.protocol="hls",a={...o,...r,ffom:o.ffom}):a=o,delete a.duration,this._videoApiProxy.requestedDuration=r==null?void 0:r.duration;const u=Cu(t.flow,t.subflows,t.flowsSegments);if(!u.valid){i.error(u.message);return}if(r&&!z1(r)){i.error("Invalid ffomTimeZoneOffset");return}P1.slewSubtitlesFlows(t,n).pipe(Mr(s=>{const c=new Map([...t.flowsSegments,...s]),l=Zu(t.flow,t.subflows,c);return this._player.loadVideo(l.url,a).pipe(Ma(d=>{this._videoApiProxy.mediaStartTime=n.mediaStartTime;const f=A1.generateThumbnailTrackUrl(t.subflows??[],c,this._player.video.getDuration()+n.mediaStartTime,n.mediaStartTime);return f&&this._player.chroming.setThumbnailVttUrl(f),{...d,mediaStartTime:n.mediaStartTime,tamsMediaData:r!=null&&r.returnTamsMediaData?t:void 0,thumbnailVttTrackUrl:f,videoUrls:l.video,audioUrls:l.audio,textUrls:l.text}}),Yh(d=>{this._videoApiProxy.setTamsVideo(d),this._videoApiProxy.emitVideoLoadedEvent()}))})).subscribe(i)})}createTimeline(t){return this._player.createTimeline(t)}createMarkerList(t){return this._player.createMarkerList(t)}initializeRouterVisualization(t){return this._player.initializeRouterVisualization(t)}setAuthentication(t){return this._authenticationData=t,this._player.setAuthentication(t)}get timeline(){return this._player.timeline}get audio(){return this._player.audio}get subtitles(){return this._player.subtitles}get config(){return this._player.config}set config(t){this._player.config=t}get chroming(){return this._player.chroming}destroy(){return this._player.destroy()}get video(){return this._videoApiProxy.proxy}setTamsEndpoint(t){this._tamsEndpoint=t}}class L1{constructor(t){k(this,"_lanes",[]);k(this,"_markersLaneMap",new Map);k(this,"_laneNodenMap",new Map);this.omakasePlayer=t}addMarkerLane(t){const r={config:t,type:"marker"};this._lanes.push(r)}addMarkers(t,r){this._markersLaneMap.get(t)===void 0&&this._markersLaneMap.set(t,[]),this._markersLaneMap.get(t).push(...r)}addTimelineNode(t,r){this._laneNodenMap.get(t)||this._laneNodenMap.set(t,[]),this._laneNodenMap.get(t).push(r)}addThumbnailLane(t){const r={config:t,type:"thumbnail"};this._lanes.push(r)}addLabelLane(t){const r={config:t,type:"label"};this._lanes.push(r)}addSubtitlesLane(t){const r={config:t,type:"subtitles"};this._lanes.push(r)}buildAndAttachTimeline(t){this.omakasePlayer.createTimeline(t).subscribe({next:r=>{this.buildAttachedTimeline(r)}})}buildAttachedTimeline(t){this._lanes.forEach(r=>this._createAndAttachLane(t,r))}_createAndAttachLane(t,r){let i;if(r.type==="marker"){i=new V.MarkerLane(r.config),t.addTimelineLane(i);const o=this._markersLaneMap.get(i.id);o==null||o.forEach(a=>i.addMarker(a))}else r.type==="thumbnail"?(i=new V.ThumbnailLane(r.config),t.addTimelineLane(i)):r.type==="label"?(i=new V.LabelLane(r.config),t.addTimelineLane(i)):r.type==="subtitles"&&(i=new V.SubtitlesLane(r.config),t.addTimelineLane(i));const n=this._laneNodenMap.get(i.id);n==null||n.forEach(o=>{i.addTimelineNode(o.config)})}}var si=function(e,t){return si=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,i){r.__proto__=i}||function(r,i){for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r[n]=i[n])},si(e,t)};function an(e,t){if(typeof t!="function"&&t!==null)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");si(e,t);function r(){this.constructor=e}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}function C1(e,t,r,i){function n(o){return o instanceof r?o:new r(function(a){a(o)})}return new(r||(r=Promise))(function(o,a){function u(l){try{c(i.next(l))}catch(d){a(d)}}function s(l){try{c(i.throw(l))}catch(d){a(d)}}function c(l){l.done?o(l.value):n(l.value).then(u,s)}c((i=i.apply(e,t||[])).next())})}function Gm(e,t){var r={label:0,sent:function(){if(o[0]&1)throw o[1];return o[1]},trys:[],ops:[]},i,n,o,a=Object.create((typeof Iterator=="function"?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),typeof Symbol=="function"&&(a[Symbol.iterator]=function(){return this}),a;function u(c){return function(l){return s([c,l])}}function s(c){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,c[0]&&(r=0)),r;)try{if(i=1,n&&(o=c[0]&2?n.return:c[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,c[1])).done)return o;switch(n=0,o&&(c=[c[0]&2,o.value]),c[0]){case 0:case 1:o=c;break;case 4:return r.label++,{value:c[1],done:!1};case 5:r.label++,n=c[1],c=[0];continue;case 7:c=r.ops.pop(),r.trys.pop();continue;default:if(o=r.trys,!(o=o.length>0&&o[o.length-1])&&(c[0]===6||c[0]===2)){r=0;continue}if(c[0]===3&&(!o||c[1]>o[0]&&c[1]<o[3])){r.label=c[1];break}if(c[0]===6&&r.label<o[1]){r.label=o[1],o=c;break}if(o&&r.label<o[2]){r.label=o[2],r.ops.push(c);break}o[2]&&r.ops.pop(),r.trys.pop();continue}c=t.call(e,r)}catch(l){c=[6,l],n=0}finally{i=o=0}if(c[0]&5)throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}}function yt(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],i=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&i>=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Pn(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var i=r.call(e),n,o=[],a;try{for(;(t===void 0||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(u){a={error:u}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return o}function An(e,t,r){if(r||arguments.length===2)for(var i=0,n=t.length,o;i<n;i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))}function st(e){return this instanceof st?(this.v=e,this):new st(e)}function Z1(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var i=r.apply(e,t||[]),n,o=[];return n=Object.create((typeof AsyncIterator=="function"?AsyncIterator:Object).prototype),u("next"),u("throw"),u("return",a),n[Symbol.asyncIterator]=function(){return this},n;function a(m){return function(h){return Promise.resolve(h).then(m,d)}}function u(m,h){i[m]&&(n[m]=function(p){return new Promise(function(v,w){o.push([m,p,v,w])>1||s(m,p)})},h&&(n[m]=h(n[m])))}function s(m,h){try{c(i[m](h))}catch(p){f(o[0][3],p)}}function c(m){m.value instanceof st?Promise.resolve(m.value.v).then(l,d):f(o[0][2],m)}function l(m){s("next",m)}function d(m){s("throw",m)}function f(m,h){m(h),o.shift(),o.length&&s(o[0][0],o[0][1])}}function M1(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof yt=="function"?yt(e):e[Symbol.iterator](),r={},i("next"),i("throw"),i("return"),r[Symbol.asyncIterator]=function(){return this},r);function i(o){r[o]=e[o]&&function(a){return new Promise(function(u,s){a=e[o](a),n(u,s,a.done,a.value)})}}function n(o,a,u,s){Promise.resolve(s).then(function(c){o({value:c,done:u})},a)}}function re(e){return typeof e=="function"}function ha(e){var t=function(i){Error.call(i),i.stack=new Error().stack},r=e(t);return r.prototype=Object.create(Error.prototype),r.prototype.constructor=r,r}var Gr=ha(function(e){return function(r){e(this),this.message=r?r.length+` errors occurred during unsubscription:
|
|
102
102
|
`+r.map(function(i,n){return n+1+") "+i.toString()}).join(`
|
|
103
103
|
`):"",this.name="UnsubscriptionError",this.errors=r}});function li(e,t){if(e){var r=e.indexOf(t);0<=r&&e.splice(r,1)}}var jr=(function(){function e(t){this.initialTeardown=t,this.closed=!1,this._parentage=null,this._finalizers=null}return e.prototype.unsubscribe=function(){var t,r,i,n,o;if(!this.closed){this.closed=!0;var a=this._parentage;if(a)if(this._parentage=null,Array.isArray(a))try{for(var u=yt(a),s=u.next();!s.done;s=u.next()){var c=s.value;c.remove(this)}}catch(p){t={error:p}}finally{try{s&&!s.done&&(r=u.return)&&r.call(u)}finally{if(t)throw t.error}}else a.remove(this);var l=this.initialTeardown;if(re(l))try{l()}catch(p){o=p instanceof Gr?p.errors:[p]}var d=this._finalizers;if(d){this._finalizers=null;try{for(var f=yt(d),m=f.next();!m.done;m=f.next()){var h=m.value;try{vu(h)}catch(p){o=o??[],p instanceof Gr?o=An(An([],Pn(o)),Pn(p.errors)):o.push(p)}}}catch(p){i={error:p}}finally{try{m&&!m.done&&(n=f.return)&&n.call(f)}finally{if(i)throw i.error}}}if(o)throw new Gr(o)}},e.prototype.add=function(t){var r;if(t&&t!==this)if(this.closed)vu(t);else{if(t instanceof e){if(t.closed||t._hasParent(this))return;t._addParent(this)}(this._finalizers=(r=this._finalizers)!==null&&r!==void 0?r:[]).push(t)}},e.prototype._hasParent=function(t){var r=this._parentage;return r===t||Array.isArray(r)&&r.includes(t)},e.prototype._addParent=function(t){var r=this._parentage;this._parentage=Array.isArray(r)?(r.push(t),r):r?[r,t]:t},e.prototype._removeParent=function(t){var r=this._parentage;r===t?this._parentage=null:Array.isArray(r)&&li(r,t)},e.prototype.remove=function(t){var r=this._finalizers;r&&li(r,t),t instanceof e&&t._removeParent(this)},e.EMPTY=(function(){var t=new e;return t.closed=!0,t})(),e})(),qm=jr.EMPTY;function Wm(e){return e instanceof jr||e&&"closed"in e&&re(e.remove)&&re(e.add)&&re(e.unsubscribe)}function vu(e){re(e)?e():e.unsubscribe()}var R1={Promise:void 0},F1={setTimeout:function(e,t){for(var r=[],i=2;i<arguments.length;i++)r[i-2]=arguments[i];return setTimeout.apply(void 0,An([e,t],Pn(r)))},clearTimeout:function(e){return clearTimeout(e)},delegate:void 0};function Hm(e){F1.setTimeout(function(){throw e})}function di(){}function $n(e){e()}var ga=(function(e){an(t,e);function t(r){var i=e.call(this)||this;return i.isStopped=!1,r?(i.destination=r,Wm(r)&&r.add(i)):i.destination=K1,i}return t.create=function(r,i,n){return new fi(r,i,n)},t.prototype.next=function(r){this.isStopped||this._next(r)},t.prototype.error=function(r){this.isStopped||(this.isStopped=!0,this._error(r))},t.prototype.complete=function(){this.isStopped||(this.isStopped=!0,this._complete())},t.prototype.unsubscribe=function(){this.closed||(this.isStopped=!0,e.prototype.unsubscribe.call(this),this.destination=null)},t.prototype._next=function(r){this.destination.next(r)},t.prototype._error=function(r){try{this.destination.error(r)}finally{this.unsubscribe()}},t.prototype._complete=function(){try{this.destination.complete()}finally{this.unsubscribe()}},t})(jr),V1=(function(){function e(t){this.partialObserver=t}return e.prototype.next=function(t){var r=this.partialObserver;if(r.next)try{r.next(t)}catch(i){mn(i)}},e.prototype.error=function(t){var r=this.partialObserver;if(r.error)try{r.error(t)}catch(i){mn(i)}else mn(t)},e.prototype.complete=function(){var t=this.partialObserver;if(t.complete)try{t.complete()}catch(r){mn(r)}},e})(),fi=(function(e){an(t,e);function t(r,i,n){var o=e.call(this)||this,a;return re(r)||!r?a={next:r??void 0,error:i??void 0,complete:n??void 0}:a=r,o.destination=new V1(a),o}return t})(ga);function mn(e){Hm(e)}function B1(e){throw e}var K1={closed:!0,next:di,error:B1,complete:di},va=(function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"})();function Pr(e){return e}function J1(e){return e.length===0?Pr:e.length===1?e[0]:function(r){return e.reduce(function(i,n){return n(i)},r)}}var pe=(function(){function e(t){t&&(this._subscribe=t)}return e.prototype.lift=function(t){var r=new e;return r.source=this,r.operator=t,r},e.prototype.subscribe=function(t,r,i){var n=this,o=q1(t)?t:new fi(t,r,i);return $n(function(){var a=n,u=a.operator,s=a.source;o.add(u?u.call(o,s):s?n._subscribe(o):n._trySubscribe(o))}),o},e.prototype._trySubscribe=function(t){try{return this._subscribe(t)}catch(r){t.error(r)}},e.prototype.forEach=function(t,r){var i=this;return r=bu(r),new r(function(n,o){var a=new fi({next:function(u){try{t(u)}catch(s){o(s),a.unsubscribe()}},error:o,complete:n});i.subscribe(a)})},e.prototype._subscribe=function(t){var r;return(r=this.source)===null||r===void 0?void 0:r.subscribe(t)},e.prototype[va]=function(){return this},e.prototype.pipe=function(){for(var t=[],r=0;r<arguments.length;r++)t[r]=arguments[r];return J1(t)(this)},e.prototype.toPromise=function(t){var r=this;return t=bu(t),new t(function(i,n){var o;r.subscribe(function(a){return o=a},function(a){return n(a)},function(){return i(o)})})},e.create=function(t){return new e(t)},e})();function bu(e){var t;return(t=e??R1.Promise)!==null&&t!==void 0?t:Promise}function G1(e){return e&&re(e.next)&&re(e.error)&&re(e.complete)}function q1(e){return e&&e instanceof ga||G1(e)&&Wm(e)}function W1(e){return re(e==null?void 0:e.lift)}function Ge(e){return function(t){if(W1(t))return t.lift(function(r){try{return e(r,this)}catch(i){this.error(i)}});throw new TypeError("Unable to lift unknown Observable type")}}function qe(e,t,r,i,n){return new H1(e,t,r,i,n)}var H1=(function(e){an(t,e);function t(r,i,n,o,a,u){var s=e.call(this,r)||this;return s.onFinalize=a,s.shouldUnsubscribe=u,s._next=i?function(c){try{i(c)}catch(l){r.error(l)}}:e.prototype._next,s._error=o?function(c){try{o(c)}catch(l){r.error(l)}finally{this.unsubscribe()}}:e.prototype._error,s._complete=n?function(){try{n()}catch(c){r.error(c)}finally{this.unsubscribe()}}:e.prototype._complete,s}return t.prototype.unsubscribe=function(){var r;if(!this.shouldUnsubscribe||this.shouldUnsubscribe()){var i=this.closed;e.prototype.unsubscribe.call(this),!i&&((r=this.onFinalize)===null||r===void 0||r.call(this))}},t})(ga),X1=ha(function(e){return function(){e(this),this.name="ObjectUnsubscribedError",this.message="object unsubscribed"}}),He=(function(e){an(t,e);function t(){var r=e.call(this)||this;return r.closed=!1,r.currentObservers=null,r.observers=[],r.isStopped=!1,r.hasError=!1,r.thrownError=null,r}return t.prototype.lift=function(r){var i=new _u(this,this);return i.operator=r,i},t.prototype._throwIfClosed=function(){if(this.closed)throw new X1},t.prototype.next=function(r){var i=this;$n(function(){var n,o;if(i._throwIfClosed(),!i.isStopped){i.currentObservers||(i.currentObservers=Array.from(i.observers));try{for(var a=yt(i.currentObservers),u=a.next();!u.done;u=a.next()){var s=u.value;s.next(r)}}catch(c){n={error:c}}finally{try{u&&!u.done&&(o=a.return)&&o.call(a)}finally{if(n)throw n.error}}}})},t.prototype.error=function(r){var i=this;$n(function(){if(i._throwIfClosed(),!i.isStopped){i.hasError=i.isStopped=!0,i.thrownError=r;for(var n=i.observers;n.length;)n.shift().error(r)}})},t.prototype.complete=function(){var r=this;$n(function(){if(r._throwIfClosed(),!r.isStopped){r.isStopped=!0;for(var i=r.observers;i.length;)i.shift().complete()}})},t.prototype.unsubscribe=function(){this.isStopped=this.closed=!0,this.observers=this.currentObservers=null},Object.defineProperty(t.prototype,"observed",{get:function(){var r;return((r=this.observers)===null||r===void 0?void 0:r.length)>0},enumerable:!1,configurable:!0}),t.prototype._trySubscribe=function(r){return this._throwIfClosed(),e.prototype._trySubscribe.call(this,r)},t.prototype._subscribe=function(r){return this._throwIfClosed(),this._checkFinalizedStatuses(r),this._innerSubscribe(r)},t.prototype._innerSubscribe=function(r){var i=this,n=this,o=n.hasError,a=n.isStopped,u=n.observers;return o||a?qm:(this.currentObservers=null,u.push(r),new jr(function(){i.currentObservers=null,li(u,r)}))},t.prototype._checkFinalizedStatuses=function(r){var i=this,n=i.hasError,o=i.thrownError,a=i.isStopped;n?r.error(o):a&&r.complete()},t.prototype.asObservable=function(){var r=new pe;return r.source=this,r},t.create=function(r,i){return new _u(r,i)},t})(pe),_u=(function(e){an(t,e);function t(r,i){var n=e.call(this)||this;return n.destination=r,n.source=i,n}return t.prototype.next=function(r){var i,n;(n=(i=this.destination)===null||i===void 0?void 0:i.next)===null||n===void 0||n.call(i,r)},t.prototype.error=function(r){var i,n;(n=(i=this.destination)===null||i===void 0?void 0:i.error)===null||n===void 0||n.call(i,r)},t.prototype.complete=function(){var r,i;(i=(r=this.destination)===null||r===void 0?void 0:r.complete)===null||i===void 0||i.call(r)},t.prototype._subscribe=function(r){var i,n;return(n=(i=this.source)===null||i===void 0?void 0:i.subscribe(r))!==null&&n!==void 0?n:qm},t})(He),Y1=new pe(function(e){return e.complete()});function Q1(e){return e&&re(e.schedule)}function Xm(e){return e[e.length-1]}function e0(e){return re(Xm(e))?e.pop():void 0}function t0(e){return Q1(Xm(e))?e.pop():void 0}var Ym=(function(e){return e&&typeof e.length=="number"&&typeof e!="function"});function Qm(e){return re(e==null?void 0:e.then)}function ep(e){return re(e[va])}function tp(e){return Symbol.asyncIterator&&re(e==null?void 0:e[Symbol.asyncIterator])}function np(e){return new TypeError("You provided "+(e!==null&&typeof e=="object"?"an invalid object":"'"+e+"'")+" where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.")}function n0(){return typeof Symbol!="function"||!Symbol.iterator?"@@iterator":Symbol.iterator}var rp=n0();function ip(e){return re(e==null?void 0:e[rp])}function op(e){return Z1(this,arguments,function(){var r,i,n,o;return Gm(this,function(a){switch(a.label){case 0:r=e.getReader(),a.label=1;case 1:a.trys.push([1,,9,10]),a.label=2;case 2:return[4,st(r.read())];case 3:return i=a.sent(),n=i.value,o=i.done,o?[4,st(void 0)]:[3,5];case 4:return[2,a.sent()];case 5:return[4,st(n)];case 6:return[4,a.sent()];case 7:return a.sent(),[3,2];case 8:return[3,10];case 9:return r.releaseLock(),[7];case 10:return[2]}})})}function ap(e){return re(e==null?void 0:e.getReader)}function Ar(e){if(e instanceof pe)return e;if(e!=null){if(ep(e))return r0(e);if(Ym(e))return i0(e);if(Qm(e))return o0(e);if(tp(e))return up(e);if(ip(e))return a0(e);if(ap(e))return u0(e)}throw np(e)}function r0(e){return new pe(function(t){var r=e[va]();if(re(r.subscribe))return r.subscribe(t);throw new TypeError("Provided object does not correctly implement Symbol.observable")})}function i0(e){return new pe(function(t){for(var r=0;r<e.length&&!t.closed;r++)t.next(e[r]);t.complete()})}function o0(e){return new pe(function(t){e.then(function(r){t.closed||(t.next(r),t.complete())},function(r){return t.error(r)}).then(null,Hm)})}function a0(e){return new pe(function(t){var r,i;try{for(var n=yt(e),o=n.next();!o.done;o=n.next()){var a=o.value;if(t.next(a),t.closed)return}}catch(u){r={error:u}}finally{try{o&&!o.done&&(i=n.return)&&i.call(n)}finally{if(r)throw r.error}}t.complete()})}function up(e){return new pe(function(t){c0(e,t).catch(function(r){return t.error(r)})})}function u0(e){return up(op(e))}function c0(e,t){var r,i,n,o;return C1(this,void 0,void 0,function(){var a,u;return Gm(this,function(s){switch(s.label){case 0:s.trys.push([0,5,6,11]),r=M1(e),s.label=1;case 1:return[4,r.next()];case 2:if(i=s.sent(),!!i.done)return[3,4];if(a=i.value,t.next(a),t.closed)return[2];s.label=3;case 3:return[3,1];case 4:return[3,11];case 5:return u=s.sent(),n={error:u},[3,11];case 6:return s.trys.push([6,,9,10]),i&&!i.done&&(o=r.return)?[4,o.call(r)]:[3,8];case 7:s.sent(),s.label=8;case 8:return[3,10];case 9:if(n)throw n.error;return[7];case 10:return[7];case 11:return t.complete(),[2]}})})}function Me(e,t,r,i,n){i===void 0&&(i=0),n===void 0&&(n=!1);var o=t.schedule(function(){r(),n?e.add(this.schedule(null,i)):this.unsubscribe()},i);if(e.add(o),!n)return o}function cp(e,t){return t===void 0&&(t=0),Ge(function(r,i){r.subscribe(qe(i,function(n){return Me(i,e,function(){return i.next(n)},t)},function(){return Me(i,e,function(){return i.complete()},t)},function(n){return Me(i,e,function(){return i.error(n)},t)}))})}function sp(e,t){return t===void 0&&(t=0),Ge(function(r,i){i.add(e.schedule(function(){return r.subscribe(i)},t))})}function s0(e,t){return Ar(e).pipe(sp(t),cp(t))}function l0(e,t){return Ar(e).pipe(sp(t),cp(t))}function d0(e,t){return new pe(function(r){var i=0;return t.schedule(function(){i===e.length?r.complete():(r.next(e[i++]),r.closed||this.schedule())})})}function f0(e,t){return new pe(function(r){var i;return Me(r,t,function(){i=e[rp](),Me(r,t,function(){var n,o,a;try{n=i.next(),o=n.value,a=n.done}catch(u){r.error(u);return}a?r.complete():r.next(o)},0,!0)}),function(){return re(i==null?void 0:i.return)&&i.return()}})}function lp(e,t){if(!e)throw new Error("Iterable cannot be null");return new pe(function(r){Me(r,t,function(){var i=e[Symbol.asyncIterator]();Me(r,t,function(){i.next().then(function(n){n.done?r.complete():r.next(n.value)})},0,!0)})})}function m0(e,t){return lp(op(e),t)}function p0(e,t){if(e!=null){if(ep(e))return s0(e,t);if(Ym(e))return d0(e,t);if(Qm(e))return l0(e,t);if(tp(e))return lp(e,t);if(ip(e))return f0(e,t);if(ap(e))return m0(e,t)}throw np(e)}function dp(e,t){return t?p0(e,t):Ar(e)}var fp=ha(function(e){return function(){e(this),this.name="EmptyError",this.message="no elements in sequence"}});function h0(e,t){return Ge(function(r,i){var n=0;r.subscribe(qe(i,function(o){i.next(e.call(t,o,n++))}))})}var g0=Array.isArray;function v0(e,t){return g0(t)?e.apply(void 0,An([],Pn(t))):e(t)}function b0(e){return h0(function(t){return v0(e,t)})}var _0=Array.isArray,y0=Object.getPrototypeOf,$0=Object.prototype,w0=Object.keys;function S0(e){if(e.length===1){var t=e[0];if(_0(t))return{args:t,keys:null};if(k0(t)){var r=w0(t);return{args:r.map(function(i){return t[i]}),keys:r}}}return{args:e,keys:null}}function k0(e){return e&&typeof e=="object"&&y0(e)===$0}function I0(e,t){return e.reduce(function(r,i,n){return r[i]=t[n],r},{})}function x0(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=t0(e),i=e0(e),n=S0(e),o=n.args,a=n.keys;if(o.length===0)return dp([],r);var u=new pe(T0(o,r,a?function(s){return I0(a,s)}:Pr));return i?u.pipe(b0(i)):u}function T0(e,t,r){return r===void 0&&(r=Pr),function(i){yu(t,function(){for(var n=e.length,o=new Array(n),a=n,u=n,s=function(l){yu(t,function(){var d=dp(e[l],t),f=!1;d.subscribe(qe(i,function(m){o[l]=m,f||(f=!0,u--),u||i.next(r(o.slice()))},function(){--a||i.complete()}))},i)},c=0;c<n;c++)s(c)},i)}}function yu(e,t,r){e?Me(r,e,t):t()}function z0(e,t){return Ge(function(r,i){var n=0;r.subscribe(qe(i,function(o){return e.call(t,o,n++)&&i.next(o)}))})}function E0(e){return Ge(function(t,r){var i=!1;t.subscribe(qe(r,function(n){i=!0,r.next(n)},function(){i||r.next(e),r.complete()}))})}function O0(e){return e<=0?function(){return Y1}:Ge(function(t,r){var i=0;t.subscribe(qe(r,function(n){++i<=e&&(r.next(n),e<=i&&r.complete())}))})}function U0(e){return e===void 0&&(e=D0),Ge(function(t,r){var i=!1;t.subscribe(qe(r,function(n){i=!0,r.next(n)},function(){return i?r.complete():r.error(e())}))})}function D0(){return new fp}function at(e,t){var r=arguments.length>=2;return function(i){return i.pipe(Pr,O0(1),r?E0(t):U0(function(){return new fp}))}}function ie(e){return Ge(function(t,r){Ar(e).subscribe(qe(r,function(){return r.complete()},di)),!r.closed&&t.subscribe(r)})}class N0{constructor(){k(this,"actionZoomIn");k(this,"actionZoomOut");k(this,"actionResetZoom");k(this,"actionToggleNextAudioTrack");k(this,"actionTogglePreviousAudioTrack");k(this,"actionToggleCti")}getKeyboardShortcutsHelpMenuGroup(){let t=(...n)=>n.join(" + "),r="shift".toUpperCase();return{name:"Timeline function shortcuts",items:[{description:"Timeline Zoom In",name:t("=")},{description:"Timeline Zoom Out",name:t("-")},{description:"Timeline Zoom level 100%",name:t("0")},{description:"Toggle Next Audio Track",name:t(r,"e")},{description:"Toggle Previous Audio Track",name:t("e")},{description:"Toggle CTI into / out-of Interactive Mode",name:t("'")}]}}handleKeyboardEvent(t){const r=t.target;return["INPUT","TEXTAREA","OMAKASE-MARKER-LIST"].includes(r.tagName.toUpperCase())?!1:t.code==="Equal"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionZoomIn&&this.actionZoomIn(),!0):t.code==="Minus"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionZoomOut&&this.actionZoomOut(),!0):t.code==="Digit0"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionResetZoom&&this.actionResetZoom(),!0):t.code==="KeyE"&&!t.ctrlKey&&!t.metaKey?(t.shiftKey?this.actionToggleNextAudioTrack&&this.actionToggleNextAudioTrack():this.actionTogglePreviousAudioTrack&&this.actionTogglePreviousAudioTrack(),!0):t.code==="Quote"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionToggleCti&&this.actionToggleCti(),!0):!1}}const j0=$.memo(({omakasePlayer:e,onTimelineCreatedCallback:t,timelineConfig:r,enableHotKeys:i})=>($.useEffect(()=>{if(r.timelineHTMLElementId===void 0&&(r.timelineHTMLElementId="omakase-timeline"),e.createTimeline(r).subscribe({next:n=>{x0([e.timeline.onReady$,e.video.onVideoLoaded$.pipe(z0(o=>!!o))]).subscribe({next:()=>t(n)})}}),i===void 0||i){const n=new N0;n.actionToggleCti=()=>{var u;return(u=e.timeline)==null?void 0:u.toggleTimecodeEdit()},n.actionResetZoom=()=>{var u;return(u=e.timeline)==null?void 0:u.zoomToEased(100)},n.actionZoomIn=()=>{var u;return(u=e.timeline)==null?void 0:u.zoomInEased()},n.actionZoomOut=()=>{var u;return(u=e.timeline)==null?void 0:u.zoomOutEased()};const o=u=>{const s=e.audio.getAudioTracks(),c=e.audio.getActiveAudioTrack(),d=s.findIndex(f=>f.id===(c==null?void 0:c.id))+(u?-1:1);d>=0&&d<s.length&&e.audio.setActiveAudioTrack(s.at(d).id)};n.actionTogglePreviousAudioTrack=()=>o(!0),n.actionToggleNextAudioTrack=()=>o(!1);const a=u=>{n.handleKeyboardEvent(u)&&(u.preventDefault(),u.stopPropagation())};return window.addEventListener("keydown",a),e.chroming.appendHelpMenuGroup(n.getKeyboardShortcutsHelpMenuGroup()),()=>{window.removeEventListener("keydown",a)}}},[e]),$.createElement("div",{id:r.timelineHTMLElementId})));class mp{static get window(){return window}static get navigator(){return window.navigator}static get userAgent(){var r;const t=((r=this.navigator)==null?void 0:r.userAgent)||"";return/Android/i.test(t)?"android":/Firefox/i.test(t)?"firefox":/Edg/i.test(t)?"edge":(/Chrome/i.test(t)||/CriOS/i.test(t))&&!/Edg/i.test(t)?"chrome":/Chrome/i.test(t)||/CriOS/i.test(t)?"chromium":/Safari/i.test(t)?"safari":"unknown"}static get platform(){var r,i,n;const t=((i=(r=this.navigator)==null?void 0:r.userAgentData)==null?void 0:i.platform)||((n=this.navigator)==null?void 0:n.platform);return t!=null&&t.toUpperCase().includes("MAC")?"macos":t!=null&&t.toUpperCase().includes("WIN")?"windows":t!=null&&t.toUpperCase().includes("LINUX")?"linux":"unknown"}static isUserAgent(t){return this.userAgent===t}static isPlatform(t){return this.platform===t}static open(t,r="_blank"){this.window.open(t,r)}}const xt=[.25,.5,.75,1,2,4,8];class Ln{static getKeyboardShortcutsHelpMenuGroup(){let t=(...o)=>o.join(" + "),r="shift".toUpperCase(),i="ctrl".toUpperCase();return{name:"Playback function shortcuts",items:[{description:"Play / Pause",name:t("Space")},{description:"Toggle Sound",name:t("s")},{description:"Toggle Text On / Off",name:t("d")},{description:"Toggle Full Screen",name:t("f")},{description:"Increase Volume",name:t(r,"\\")},{description:"Reduce Volume",name:t("\\")},{description:"One Frame Forward",name:t("Right Arrow")},{description:"One Frame Backward",name:t("Left Arrow")},{description:"10 Frames Forward",name:t(r,"Right Arrow")},{description:"10 Frames Backwards",name:t(r,"Left Arrow")},{description:"Stop shuttle and pause",name:t("k")},{description:"Decrease Shuttle Forwards",name:t("l")},{description:"Increase Shuttle Forwards",name:t(r,"l")},{description:"Set playhead to Start of Media and Stop",name:t("1 / Home")},{description:"Set playhead to End of Media and Stop",name:t(i,"1")+" / End"}]}}static handleKeyboardEvent(t,r){const i=t.target,n=["INPUT","TEXTAREA","OMAKASE-MARKER-LIST"],o=mp.userAgent;if(n.includes(i.tagName.toUpperCase()))return!1;if(r&&r.video){if(t.code==="Space"&&(o!=="safari"||!r.video.isFullscreen()))return r.video.togglePlayPause(),!0;if(t.code==="KeyS"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey)return r.audio.toggleAudioOutputMuteUnmute(),!0;if(t.code==="Backslash"){let a=10,u=t.shiftKey?1:-1,s=r.audio.getAudioOutputVolume()*100+a*u;s>=100?s=100:s<=0&&(s=0),r.audio.setAudioOutputVolume(s/100)}if(t.code==="KeyD"&&!(t.ctrlKey&&t.shiftKey&&t.metaKey))return r.subtitles.toggleShowHideActiveTrack(),!0;if(t.code==="KeyK"&&!t.ctrlKey&&!t.shiftKey&&!t.metaKey&&(r.video.setPlaybackRate(1),r.video.pause()),t.code==="KeyL"&&!t.ctrlKey&&!t.metaKey){let a=t.shiftKey?1:-1;const u=xt.indexOf(r.video.getPlaybackRate())+a;let s;return u<0?s=xt.at(0):u>=xt.length?s=xt.at(-1):s=xt.at(u),r.video.setPlaybackRate(s),r.video.isPaused()&&r.video.play(),!0}if(r.video.isVideoLoaded()){if(["ArrowLeft","ArrowRight"].includes(t.key)&&!t.metaKey&&!t.altKey){let a=t.key==="ArrowRight"?1:-1,u=t.shiftKey?10:1;return r.video.isPlaying()&&r.video.pause(),r.video.seekFromCurrentFrame(u*a),!0}if(t.code==="Digit1"&&!t.ctrlKey&&!t.metaKey&&!t.shiftKey&&!t.altKey||t.code==="Home")return r.video.pause().subscribe(()=>r.video.seekToFrame(0)),!0;if(t.code==="Digit1"&&t.ctrlKey||t.code==="End")return r.video.isPlaying()?r.video.pause().subscribe(()=>r.video.seekToEnd()):r.video.seekToEnd(),!0}if(t.code==="KeyF"&&!t.ctrlKey&&!t.shiftKey&&!t.metaKey)return r.video.toggleFullscreen(),!0}return!1}}const P0=$.memo(function({videoUrl:t,config:r,videoLoadOptions:i,onVideoLoadedCallback:n,enableHotkeys:o}){return r&&(r==null?void 0:r.playerHTMLElementId)===void 0&&(r.playerHTMLElementId="omakase-player"),$.useEffect(()=>{var s,c;let a=new V.OmakasePlayer(r);const u=l=>{Ln.handleKeyboardEvent(l,a)&&(l.stopPropagation(),l.preventDefault())};return(o===void 0||o)&&((s=document.querySelector("media-controller"))==null||s.setAttribute("nohotkeys",""),(c=document.querySelector("media-controller"))==null||c.setAttribute("tabindex","-1"),window.addEventListener("keydown",u),a.chroming.appendHelpMenuGroup(Ln.getKeyboardShortcutsHelpMenuGroup())),a.loadVideo(t,i).subscribe({next:l=>{n&&n(a,l)}}),()=>{(o===void 0||o)&&window.removeEventListener("keydown",u)}},[t]),$.createElement("div",{id:r.playerHTMLElementId})}),A0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M10.5675 21C10.2375 21 9.9675 20.73 9.9675 20.4V16.7925L5.6325 12.3675L9.9675 8.235V3.6C9.9675 3.27 10.2375 3 10.5675 3C10.8975 3 11.1675 3.27 11.1675 3.6V8.7525L7.3425 12.3975L11.1675 16.305V20.4C11.1675 20.73 10.8975 21 10.5675 21Z",fill:"currentColor"}),$.createElement("path",{d:"M17.7675 17.145C17.61 17.145 17.46 17.085 17.34 16.965L12.8325 12.3675L17.355 8.0625C17.595 7.8375 17.9775 7.845 18.2025 8.085C18.4275 8.325 18.42 8.7075 18.18 8.9325L14.5425 12.3975L18.195 16.125C18.4275 16.365 18.42 16.74 18.1875 16.9725C18.075 17.085 17.9175 17.145 17.7675 17.145Z",fill:"currentColor"})),L0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M13.4325 21C13.7625 21 14.0325 20.73 14.0325 20.4V16.7925L18.3675 12.3675L14.0325 8.235V3.6C14.0325 3.27 13.7625 3 13.4325 3C13.1025 3 12.8325 3.27 12.8325 3.6V8.7525L16.6575 12.3975L12.8325 16.305V20.4C12.8325 20.73 13.1025 21 13.4325 21Z",fill:"currentColor"}),$.createElement("path",{d:"M6.2325 17.145C6.39 17.145 6.54 17.085 6.66 16.965L11.1675 12.3675L6.645 8.0625C6.405 7.8375 6.0225 7.845 5.7975 8.085C5.5725 8.325 5.58 8.7075 5.82 8.9325L9.4575 12.3975L5.805 16.125C5.5725 16.365 5.58 16.74 5.8125 16.9725C5.925 17.085 6.0825 17.145 6.2325 17.145Z",fill:"currentColor"})),C0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M14.1675 21C13.8375 21 13.5675 20.73 13.5675 20.4V16.7925L9.2325 12.3675L13.5675 8.235V3.6C13.5675 3.27 13.8375 3 14.1675 3C14.4975 3 14.7675 3.27 14.7675 3.6V8.7525L10.9425 12.3975L14.7675 16.305V20.4C14.7675 20.73 14.4975 21 14.1675 21Z",fill:"currentColor"})),Z0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M9.8325 21C10.1625 21 10.4325 20.73 10.4325 20.4V16.7925L14.7675 12.3675L10.4325 8.235V3.6C10.4325 3.27 10.1625 3 9.8325 3C9.5025 3 9.2325 3.27 9.2325 3.6V8.7525L13.0575 12.3975L9.2325 16.305V20.4C9.2325 20.73 9.5025 21 9.8325 21Z",fill:"currentColor"})),M0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M11.3475 3H5.775V21L11.3475 17.0475V3Z",fill:"currentColor"}),$.createElement("path",{d:"M18.225 21L12.6525 17.0475V3H18.225V21ZM13.7775 16.47L17.1 18.825V4.125H13.7775V16.47Z",fill:"currentColor"})),R0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M4.6875 3V21L8.0625 17.0475L11.4375 21V3H4.6875Z",fill:"currentColor"}),$.createElement("path",{d:"M12.5625 3V21L15.9375 17.0475L19.3125 21V3H12.5625Z",fill:"currentColor"})),F0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M6.39001 3V21L12 17.0175L17.61 21V3H6.38251H6.39001ZM16.44 3.84L7.23001 18.7125V3.84H16.44ZM12 15.9975L8.25751 18.6525L16.77 4.89V19.3725L12 15.9825V15.9975Z",fill:"currentColor"})),V0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M12.3075 8.0175L14.4525 5.8725C14.6175 5.7075 14.6175 5.43 14.4525 5.265L12.3 3.12C12.135 2.955 11.8575 2.955 11.6925 3.12C11.5275 3.285 11.5275 3.5625 11.6925 3.7275L13.1025 5.1375H6.64499C5.22749 5.1375 4.07249 6.2925 4.07249 7.71V16.2825C4.07249 17.7 5.22749 18.855 6.64499 18.855C6.87749 18.855 7.07249 18.66 7.07249 18.4275C7.07249 18.195 6.87749 18 6.64499 18C5.69249 18 4.93499 17.2275 4.93499 16.29V7.7175C4.93499 6.765 5.70749 6.0075 6.64499 6.0075H13.11L11.7 7.4175C11.535 7.5825 11.535 7.86 11.7 8.025C11.865 8.19 12.1425 8.19 12.3075 8.025V8.0175Z",fill:"currentColor"}),$.createElement("path",{d:"M17.355 18.8625C18.7725 18.8625 19.9275 17.7075 19.9275 16.29V7.7175C19.9275 6.3 18.7725 5.145 17.355 5.145C17.1225 5.145 16.9275 5.34 16.9275 5.5725C16.9275 5.805 17.1225 6 17.355 6C18.3075 6 19.065 6.7725 19.065 7.71V16.2825C19.065 17.235 18.2925 17.9925 17.355 17.9925H10.89L12.3075 16.5825C12.3825 16.5075 12.435 16.395 12.435 16.2825C12.435 16.17 12.3975 16.0575 12.3075 15.9825C12.15 15.8175 11.8575 15.825 11.7 15.9825L9.52501 18.1575V18.18C9.45751 18.255 9.42751 18.345 9.42751 18.435C9.42751 18.555 9.46501 18.66 9.55501 18.735L11.7 20.88C11.8575 21.045 12.15 21.045 12.3075 20.88C12.4725 20.715 12.4725 20.4375 12.3075 20.2725L10.89 18.8625H17.355Z",fill:"currentColor"})),B0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("g",{clipPath:"url(#clip0_3377_237)"},$.createElement("path",{d:"M13.02 19.95C17.42 19.95 21 16.37 21 11.97C21 7.57 17.42 4 13.02 4C8.88 4 5.39 7.24 5.08 11.37L5.02 12.14L3.56 10.68C3.49 10.61 3.41 10.58 3.33 10.58C3.25 10.58 3.17 10.61 3.1 10.68C3.03 10.75 3 10.83 3 10.92C3 11 3.03 11.08 3.1 11.15L5.22 13.27C5.35 13.4 5.55 13.43 5.65 13.3L7.8 11.15C7.87 11.08 7.9 11 7.9 10.92C7.9 10.84 7.86 10.76 7.8 10.69C7.73 10.62 7.65 10.59 7.57 10.59C7.49 10.59 7.41 10.62 7.34 10.69L5.9 12.13L6.03 11.11C6.45 7.57 9.46 4.91 13.02 4.91C16.91 4.91 20.08 8.08 20.08 11.97C20.08 15.86 16.91 19.03 13.02 19.03C12.77 19.03 12.56 19.24 12.56 19.49C12.56 19.74 12.77 19.95 13.02 19.95Z",fill:"currentColor"}),$.createElement("path",{d:"M14.95 13.19C14.95 13.72 14.75 14.14 14.36 14.45C13.97 14.76 13.43 14.91 12.75 14.91C12.16 14.91 11.69 14.81 11.32 14.62V13.53C11.7 13.81 12.14 13.95 12.65 13.95C12.98 13.95 13.23 13.88 13.41 13.74C13.59 13.6 13.67 13.41 13.67 13.17C13.67 12.93 13.56 12.72 13.34 12.58C13.12 12.44 12.82 12.37 12.43 12.37H11.92V11.41H12.39C13.13 11.41 13.5 11.16 13.5 10.67C13.5 10.21 13.22 9.98 12.65 9.98C12.26 9.98 11.89 10.1 11.54 10.35V9.33C11.93 9.13 12.4 9.03 12.94 9.03C13.48 9.03 13.94 9.16 14.28 9.41C14.62 9.66 14.79 10.01 14.79 10.44C14.79 11.19 14.41 11.65 13.66 11.84V11.86C14.06 11.91 14.37 12.05 14.61 12.29C14.85 12.53 14.96 12.83 14.96 13.19H14.95Z",fill:"currentColor"})),$.createElement("defs",null,$.createElement("clipPath",{id:"clip0_3377_237"},$.createElement("rect",{width:"18",height:"15.95",fill:"white",transform:"translate(3 4)"})))),K0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("g",{clipPath:"url(#clip0_3377_260)"},$.createElement("path",{d:"M10.98 19.95C6.58 19.95 3 16.37 3 11.98C3 7.58 6.58 4 10.98 4C15.12 4 18.61 7.24 18.93 11.37L18.99 12.14L20.45 10.68C20.52 10.61 20.6 10.58 20.68 10.58C20.76 10.58 20.84 10.61 20.91 10.68C20.98 10.75 21.01 10.83 21.01 10.91C21.01 10.99 20.98 11.07 20.91 11.14L18.79 13.26C18.66 13.39 18.46 13.42 18.36 13.29L16.21 11.14C16.14 11.07 16.11 10.99 16.11 10.91C16.11 10.83 16.15 10.75 16.21 10.68C16.28 10.61 16.36 10.58 16.44 10.58C16.52 10.58 16.6 10.61 16.67 10.68L18.11 12.12L17.98 11.1C17.55 7.57 14.54 4.91 10.98 4.91C7.09 4.91 3.92 8.08 3.92 11.97C3.92 15.86 7.09 19.03 10.98 19.03C11.23 19.03 11.44 19.24 11.44 19.49C11.44 19.74 11.23 19.95 10.98 19.95Z",fill:"currentColor"}),$.createElement("path",{d:"M12.91 13.19C12.91 13.72 12.71 14.14 12.32 14.45C11.93 14.76 11.39 14.91 10.71 14.91C10.12 14.91 9.65 14.81 9.28 14.62V13.53C9.66 13.81 10.1 13.95 10.61 13.95C10.94 13.95 11.19 13.88 11.37 13.74C11.55 13.6 11.63 13.41 11.63 13.17C11.63 12.93 11.52 12.72 11.3 12.58C11.08 12.44 10.78 12.37 10.39 12.37H9.88V11.41H10.35C11.09 11.41 11.46 11.16 11.46 10.67C11.46 10.21 11.18 9.98 10.61 9.98C10.22 9.98 9.85 10.1 9.5 10.35V9.33C9.89 9.13 10.36 9.03 10.9 9.03C11.44 9.03 11.9 9.16 12.24 9.41C12.58 9.66 12.75 10.01 12.75 10.44C12.75 11.19 12.37 11.65 11.62 11.84V11.86C12.02 11.91 12.33 12.05 12.57 12.29C12.81 12.53 12.92 12.83 12.92 13.19H12.91Z",fill:"currentColor"})),$.createElement("defs",null,$.createElement("clipPath",{id:"clip0_3377_260"},$.createElement("rect",{width:"18",height:"15.95",fill:"white",transform:"translate(3 4)"})))),ve=({Icon:e,onClick:t,width:r,height:i,text:n,disabled:o})=>$.createElement("button",{disabled:o,onClick:t},$.createElement(e,{width:r,height:i})," ",n),J0=({width:e,height:t})=>$.createElement("svg",{width:e??24,height:t??24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("path",{d:"M12.6525 17.0475L18.225 21V3H12.6525V17.0475Z",fill:"currentColor"}),$.createElement("path",{d:"M5.775 3H11.3475V17.0475L5.775 21V3ZM10.2225 4.125H6.9V18.825L10.2225 16.47V4.125Z",fill:"currentColor"})),G0=({width:e,height:t})=>$.createElement("svg",{width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg"},$.createElement("rect",{x:"0.5",y:"0.5",width:"13",height:"13",rx:"2.5",stroke:"currentColor"}),$.createElement("path",{d:"M7.16667 6.33333V6.83333H7.66667H10.3333C10.4257 6.83333 10.5 6.90769 10.5 7C10.5 7.09231 10.4257 7.16667 10.3333 7.16667H7.66667H7.16667V7.66667V10.3333C7.16667 10.4257 7.09231 10.5 7 10.5C6.90769 10.5 6.83333 10.4257 6.83333 10.3333V7.66667V7.16667H6.33333H3.66667C3.57468 7.16667 3.5 7.09199 3.5 7C3.5 6.90801 3.57468 6.83333 3.66667 6.83333H6.33333H6.83333V6.33333V3.66667C6.83333 3.57468 6.90801 3.5 7 3.5C7.09199 3.5 7.16667 3.57468 7.16667 3.66667V6.33333Z",fill:"currentColor",stroke:"currentColor"}));function Se(e){e.next(),e.complete()}class q0{constructor(){k(this,"actionMarkerInOut");k(this,"actionMarkerSplit");k(this,"actionMarkerDelete");k(this,"actionPreviousMarkerToggle");k(this,"actionNextMarkerToggle");k(this,"actionSetMarkerStartToPlayhead");k(this,"actionSetMarkerEndToPlayhead");k(this,"actionSetPlayheadToMarkerStart");k(this,"actionSetPlayheadToMarkerEnd");k(this,"actionRewind3SecondsAndPlayToCurrent");k(this,"actionPlay3SecondsAndRewindToCurrent");k(this,"actionLoopActiveMarker")}getKeyboardShortcutsHelpMenuGroup(){let t=(...a)=>a.join(" + "),r="shift".toUpperCase();const i=mp.platform;let n=i==="windows"?"win":i==="linux"?"super":"cmd";return{name:"Segmentation function shortcuts",items:[{description:"Mark In / Out",name:t("m")},{description:"Split Active Marker",name:t(".")},{description:"Delete Active Marker",name:t("n")},{description:"Toggle Previous Marker",name:t("/")},{description:"Toggle Next Marker",name:t(r,"/")},{description:"Set Start of Active Marker to Playhead Position",name:t("i")},{description:"Set End of Active Marker to Playhead Position",name:t("o")},{description:"Set Playhead to Start of Active Marker",name:t("[")},{description:"Set Playhead to End of Active Marker",name:t("]")},{description:"Rewind 3 Seconds and Play to Current Playhead",name:t(n,"Arrow Left")},{description:"Play 3 Seconds and Rewind to Current Playhead",name:t(n,"Arrow Right")},{description:"Loop on Active Marker",name:t("p")}]}}handleKeyboardEvent(t,r){const i=t.target;return["INPUT","TEXTAREA","OMAKASE-MARKER-LIST"].includes(i.tagName.toUpperCase())?!1:t.code==="KeyM"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionMarkerInOut&&this.actionMarkerInOut(),!0):t.code==="Period"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionMarkerSplit&&this.actionMarkerSplit(),!0):t.code==="KeyN"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionMarkerDelete&&this.actionMarkerDelete(),!0):t.code==="Slash"&&!t.ctrlKey&&!t.metaKey?(t.shiftKey?this.actionNextMarkerToggle&&this.actionNextMarkerToggle():this.actionPreviousMarkerToggle&&this.actionPreviousMarkerToggle(),!0):t.code==="KeyI"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionSetMarkerStartToPlayhead&&this.actionSetMarkerStartToPlayhead(),!0):t.code==="KeyO"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionSetMarkerEndToPlayhead&&this.actionSetMarkerEndToPlayhead(),!0):t.code==="BracketLeft"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionSetPlayheadToMarkerStart&&this.actionSetPlayheadToMarkerStart(),!0):t.code==="BracketRight"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionSetPlayheadToMarkerEnd&&this.actionSetPlayheadToMarkerEnd(),!0):t.code==="ArrowLeft"&&!t.shiftKey&&!t.ctrlKey&&t.metaKey?(this.actionRewind3SecondsAndPlayToCurrent&&this.actionRewind3SecondsAndPlayToCurrent(),!0):t.code==="ArrowRight"&&!t.shiftKey&&!t.ctrlKey&&t.metaKey?(this.actionPlay3SecondsAndRewindToCurrent&&this.actionPlay3SecondsAndRewindToCurrent(),!0):t.code==="KeyP"&&!t.shiftKey&&!t.ctrlKey&&!t.metaKey?(this.actionLoopActiveMarker&&this.actionLoopActiveMarker(),!0):!1}}const Tt=(e,t,r)=>e.getMarkers().reduce((i,n)=>{if(t.id===n.id)return i;if(n instanceof V.PeriodMarker&&n.timeObservation.start!=null&&n.timeObservation.end!=null){const o=t.timeObservation,a=n.timeObservation.start,u=n.timeObservation.end,s=(r==null?void 0:r.start)??o.start,c=(r==null?void 0:r.end)??o.end;if(Number.isFinite(s)&&Number.isFinite(c))return i||s<=u&&c>=a;if(Number.isFinite(s))return i||s>=a&&s<=u;if(Number.isFinite(c))return i||c>=a&&c<=u}return i},!1);function pn(e,t,r){if(!e||!(e instanceof V.PeriodMarker)||!r.video.isVideoLoaded())return!0;const i=e.timeObservation.start,n=e.timeObservation.end;if(i==null||n==null)return!0;const o=r.video.calculateTimeToFrame(n),a=r.video.calculateTimeToFrame(i),u=r.video.getCurrentFrame();return t<i||o-u<2||u-a<1}function hn(e){return!(e.timeObservation.start==null||e.timeObservation.end==null)}const W0=({selectedMarker:e,omakasePlayer:t,enableHotKeys:r,segmentationLanes:i,setSegmentationLanes:n,setSelectedMarker:o,onMarkerClickCallback:a,setSource:u,source:s,constants:c})=>{const l=$.useRef(void 0),d=$.useRef(void 0),f=$.useRef(new He),m=$.useRef(!1),h=S=>{if(z===void 0||!t.video.isVideoLoaded())return!0;const x=z.timeObservation.start,j=S??t.video.getCurrentTime();return!!(x==null||x>=j||Tt(s,z,{end:j}))},p=S=>{if(z!==void 0||s===void 0||!t.video.isVideoLoaded())return!0;const x=S??t.video.getCurrentTime(),j=t.video.calculateTimeToFrame(x);if(j+1>t.video.getTotalFrames())return!0;const W=new V.PeriodMarker({timeObservation:{start:t.video.calculateFrameToTime(j),end:t.video.calculateFrameToTime(j+2)}});return Tt(s,W)},[v,w]=$.useState(void 0),[E,T]=$.useState(pn(e,t.video.getCurrentTime(),t)),[z,M]=$.useState(void 0),[R,Q]=$.useState(h()),[te,Y]=$.useState(p()),Te=S=>{if(S===void 0||s===void 0||!(S instanceof V.PeriodMarker))return!0;const x=Tt(s,S,{start:t.video.getCurrentTime()});if(x)return x;if(S instanceof V.PeriodMarker){const j=S.timeObservation.end;if(j!=null&&t.video.getCurrentTime()>=j)return!0}return!1},ue=S=>{if(S===void 0||s===void 0||!(S instanceof V.PeriodMarker))return!0;const x=Tt(s,S,{end:t.video.getCurrentTime()});if(x)return x;if(S instanceof V.PeriodMarker){if(S.timeObservation.end==null)return!0;const j=S.timeObservation.start;if(j!=null&&t.video.getCurrentTime()<=j)return!0}return!1},[We,Ae]=$.useState(Te(e)),[it,ee]=$.useState(ue(e));$.useEffect(()=>{if(Q(()=>h()),Y(()=>p()),z&&z!==e){const S=i.find(x=>x.getMarker(z.id));S==null||S.removeMarker(z.id),M(void 0)}},[e,z,i,M]),$.useEffect(()=>()=>Se(f.current),[]),$.useEffect(()=>{if(Ae(Te(e)),ee(ue(e)),e){const S=pn(e,t.video.getCurrentTime(),t);T(S);const x=t.video.onVideoTimeChange$.pipe(ie(f.current)).subscribe({next:j=>{T(W=>pn(e,j.currentTime,t)),Ae(()=>Te(e)),ee(()=>ue(e))}});return()=>x.unsubscribe()}},[e]),$.useEffect(()=>{t.video.onSeeking$.pipe(ie(f.current)).subscribe({next:x=>{Q(()=>h(x.toTime)),Y(()=>p(x.toTime))}});const S=t.video.onVideoTimeChange$.pipe(ie(f.current)).subscribe({next:x=>{Q(()=>h()),Y(()=>p())}});return()=>S.unsubscribe()},[z,s]),$.useEffect(()=>{const S=i.map(x=>x.onMarkerUpdate$.pipe(ie(f.current)).subscribe({next:j=>{(e==null?void 0:e.id)===j.marker.id&&(T(W=>pn(e,t.video.getCurrentTime(),t)),Ae(()=>Te(e)),ee(()=>ue(e)))}}));return()=>S.forEach(x=>x.unsubscribe())},[i,e]),$.useEffect(()=>{v&&(v.marker.style={...v.marker.style,color:v.color},v.marker.timeObservation={...v.marker.timeObservation},w(void 0))},[e]),$.useEffect(()=>{if(s){Q(()=>h()),Y(()=>p());const S=s.onMarkerDelete$.pipe(ie(f.current)).subscribe({next:j=>{const W=j.marker;w(K=>{if((K==null?void 0:K.marker.id)!==W.id)return K}),o(K=>{if((K==null?void 0:K.id)!==W.id)return K}),M(K=>{if((K==null?void 0:K.id)!==W.id)return K}),Q(()=>h()),Y(()=>p())}}),x=s.onMarkerUpdate$.pipe(ie(f.current)).subscribe({next:()=>{Q(()=>h()),Y(()=>p())}});return()=>{S.unsubscribe(),x.unsubscribe()}}},[s]);const F=(S,x)=>{if(x===void 0)return;const j=x.timeObservation;S.video.seekToTime(j.start)},ba=(S,x)=>{if(x===void 0)return;const j=x.timeObservation;S.video.seekToTime(j.end)},_a=(S,x)=>{x instanceof V.PeriodMarker&&x.timeObservation.start!==void 0&&(x.timeObservation={...x.timeObservation,start:S.video.getCurrentTime()})},ya=(S,x)=>{x instanceof V.PeriodMarker&&x.timeObservation.end!==void 0&&(x.timeObservation={...x.timeObservation,end:S.video.getCurrentTime()})},$a=(S,x)=>{l.current&&Se(l.current),l.current=new He,S.video.pause();const j=S.video.getCurrentFrame(),W=S.video.getFrameRate(),K=j-x*W,Le=K>=0?K:0;S.video.seekToFrame(Le).pipe(at()).subscribe(()=>{}),S.video.play(),S.video.onVideoTimeChange$.pipe(ie(l.current),ie(f.current)).subscribe(un=>{un.frame>=j-1&&(S.video.pause().subscribe(()=>{S.video.seekToFrame(j).pipe(at()).subscribe(()=>{})}),Se(l.current))})},wa=(S,x)=>{l.current&&Se(l.current),l.current=new He,d.current&&Se(d.current),d.current=new He;const j=S.video.getCurrentFrame(),W=S.video.getFrameRate(),K=j+x*W;S.video.play(),S.video.onVideoTimeChange$.pipe(ie(l.current),ie(f.current)).subscribe(Le=>{Le.frame>=K-1&&(S.video.pause().subscribe(()=>{S.video.seekToFrame(j).pipe(at()).subscribe(()=>{})}),Se(l.current))}),S.video.onEnded$.pipe(ie(d.current),ie(f.current)).subscribe(Le=>{setTimeout(()=>{S.video.seekToFrame(j).pipe(at()).subscribe(()=>{})},1),Se(d.current)})},Lr=S=>{s.removeMarker(S.id),(z==null?void 0:z.id)===S.id&&M(void 0)},Sa=(S,x)=>{if(!(x instanceof V.PeriodMarker))return;const j=x.timeObservation.start,W=x.timeObservation.end,K=S.video.getCurrentTime();if(j==null||W==null)return;const Le=j,un=K,hp=un+1/S.video.getFrameRate(),gp=W;Lr(x);const Cr=new V.PeriodMarker({style:c.PERIOD_MARKER_STYLE,timeObservation:{start:Le,end:un},editable:!0});Cr.onClick$.subscribe({next:()=>a(Cr)});const kt=new V.PeriodMarker({style:c.HIGHLIGHTED_PERIOD_MARKER_STYLE,timeObservation:{start:hp,end:gp},editable:!0});kt.onClick$.subscribe({next:()=>a(kt)}),s.addMarker(Cr),s.addMarker(kt),a(kt),setTimeout(()=>{w({marker:kt,color:c.PERIOD_MARKER_STYLE.color})},0)},ka=()=>{const S=t.video.getCurrentTime(),x=new V.PeriodMarker({timeObservation:{start:S},style:c.PERIOD_MARKER_STYLE,editable:!0});x.onClick$.subscribe({next:()=>a(x)}),s.addMarker(x),M(x),Q(h()),a(x)},Ia=()=>{const S=t.video.getCurrentTime();z.timeObservation={...z.timeObservation,end:S},M(void 0)},xa=S=>{l.current&&Se(l.current),l.current=new He,d.current&&Se(d.current),d.current=new He;const x=t.video.calculateTimeToFrame(S.timeObservation.start),j=t.video.calculateTimeToFrame(S.timeObservation.end);t.video.pause(),t.video.seekToFrame(x),t.video.play(),t.video.onVideoTimeChange$.pipe(ie(l.current),ie(f.current)).subscribe(W=>{W.frame>=j-1&&(t.video.pause().subscribe(()=>{t.video.seekToFrame(x).pipe(at()).subscribe(()=>{})}),Se(l.current))}),t.video.onEnded$.pipe(ie(d.current),ie(f.current)).subscribe(W=>{setTimeout(()=>{t.video.seekToFrame(x).pipe(at()).subscribe(()=>{})},1),Se(d.current)})},pp=()=>{const S=i.length,x=`Segmentation ${i.length+1}`,j=new V.MarkerLane({style:c.TIMELINE_LANE_STYLE,description:x});j.onMarkerUpdate$.pipe(ie(f.current)).subscribe({next:W=>{Tt(j,W.marker)&&(W.marker.timeObservation=W.oldValue.timeObservation)}}),t.timeline.addTimelineLaneAtIndex(j,S+1),n([...i,j]),a(void 0),u(j)},Ta=S=>{if(!s)return;const x=s.getMarkers().filter(K=>K instanceof V.PeriodMarker).sort((K,Le)=>(K.timeObservation.start??0)-(Le.timeObservation.start??0));if(e===void 0){a(x.at(0));return}const W=x.findIndex(K=>K.id===e.id)+(S?-1:1);W>=0&&W<x.length&&a(x.at(W))};return $.useEffect(()=>{if(!r)return;const S=new q0;S.actionLoopActiveMarker=()=>e instanceof V.PeriodMarker&&hn(e)&&xa(e),S.actionSetPlayheadToMarkerStart=()=>e&&F(t,e),S.actionSetPlayheadToMarkerEnd=()=>e&&e instanceof V.PeriodMarker&&hn(e)&&ba(t,e),S.actionSetMarkerStartToPlayhead=()=>!We&&_a(t,e),S.actionSetMarkerEndToPlayhead=()=>!it&&ya(t,e),S.actionMarkerSplit=()=>!E&&Sa(t,e),S.actionMarkerDelete=()=>e&&Lr(e),S.actionMarkerInOut=()=>{z===void 0?!te&&ka():!R&&Ia()},S.actionPlay3SecondsAndRewindToCurrent=()=>wa(t,3),S.actionRewind3SecondsAndPlayToCurrent=()=>$a(t,3),S.actionNextMarkerToggle=()=>Ta(!1),S.actionPreviousMarkerToggle=()=>Ta(!0);const x=j=>{S.handleKeyboardEvent(j,t)&&(j.stopPropagation(),j.preventDefault())};return window.addEventListener("keydown",x),m.current||(t.chroming.appendHelpMenuGroup(S.getKeyboardShortcutsHelpMenuGroup()),m.current=!0),()=>window.removeEventListener("keydown",x)}),$.createElement("div",{className:"omakase-player-timeline-controls-toolbar"},$.createElement("div",{className:"omakase-player-timeline-controls-toolbar-control-panel"},$.createElement(ve,{Icon:A0,onClick:()=>F(t,e),disabled:e===void 0}),$.createElement(ve,{Icon:L0,onClick:()=>ba(t,e),disabled:e===void 0||e instanceof V.PeriodMarker&&!hn(e)}),$.createElement(ve,{Icon:C0,onClick:()=>_a(t,e),disabled:We}),$.createElement(ve,{Icon:Z0,onClick:()=>ya(t,e),disabled:it}),z===void 0?$.createElement(ve,{Icon:M0,onClick:ka,disabled:te}):$.createElement(ve,{Icon:J0,onClick:Ia,disabled:R}),$.createElement(ve,{Icon:F0,onClick:()=>Lr(e),disabled:e===void 0}),$.createElement(ve,{Icon:R0,onClick:()=>Sa(t,e),disabled:E||e===void 0}),$.createElement(ve,{Icon:V0,onClick:()=>xa(e),disabled:!(e instanceof V.PeriodMarker&&hn(e))}),$.createElement(ve,{Icon:B0,onClick:()=>$a(t,3)}),$.createElement(ve,{Icon:K0,onClick:()=>wa(t,3)})),$.createElement("div",{className:"omakase-player-timeline-controls-toolbar-control-panel"},$.createElement("div",{className:"segmentation-button-wrapper"},$.createElement(ve,{Icon:G0,text:"NEW SEGMENTATION",onClick:()=>pp(),disabled:i.length>=3}))))},H0=$.memo(function({flow:t,subflows:r,flowsSegments:i,onVideoLoadedCallback:n,config:o,timerange:a,videoLoadOptions:u,enableHotkeys:s}){return o&&(o==null?void 0:o.playerHTMLElementId)===void 0&&(o.playerHTMLElementId="omakase-player"),$.useEffect(()=>{var d,f;let c=new Jm(o);const l=m=>{Ln.handleKeyboardEvent(m,c)&&(m.stopPropagation(),m.preventDefault())};return(s===void 0||s)&&((d=document.querySelector("media-controller"))==null||d.setAttribute("nohotkeys",""),(f=document.querySelector("media-controller"))==null||f.setAttribute("tabindex","-1"),window.addEventListener("keydown",l),c.video.appendHelpMenuGroup(Ln.getKeyboardShortcutsHelpMenuGroup())),c.loadVideo({flow:t,subflows:r,flowsSegments:i},u).subscribe({next:m=>{n&&n(c,m)}}),()=>{(s===void 0||s)&&window.removeEventListener("keydown",l)}},[t,a]),$.createElement("div",{id:o.playerHTMLElementId})});function X0(e){const t=Math.round(e/60)*60,r=new Date(t*1e3);return`${r.getUTCHours()}h ${r.getUTCMinutes()}min`}function Y0(e){const t=Math.round(e/60)*60,r=Math.floor(t/86400),i=new Date(t*1e3);return r>=1?`${r}d ${i.getUTCHours()}h ${i.getUTCMinutes()}min`:`${i.getUTCHours()}h ${i.getUTCMinutes()}min`}const Q0=`
|
|
104
104
|
:root {
|