@aigamo/hydrangean-diva
Version:
An open-source online media player that can be deployed to and hosted on GitHub pages.
1 lines • 55.4 kB
JavaScript
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require(`@emotion/react/jsx-runtime`),l=require(`react`),u=require(`ajv`);u=s(u,1);let d=require(`mobx`),f=require(`@aigamo/route-sphere`),p=require(`lodash-es`),m=require(`@aigamo/nostalgic-diva`),h=require(`@elastic/eui`),g=require(`mobx-react-lite`),_=require(`@fluentui/react-icons`),v=require(`ez-modal-react`);v=s(v,1);let y=require(`react-sortablejs`),b=require(`@tanstack/react-router`);var ee=81,x=new Map(Object.entries({Audio:``,Dailymotion:`https://www.dailymotion.com/favicon.ico`,Niconico:`https://www.nicovideo.jp/favicon.ico`,SoundCloud:`https://soundcloud.com/favicon.ico`,Twitch:`https://www.twitch.tv/favicon.ico`,Vimeo:`https://vimeo.com/favicon.ico`,YouTube:`https://www.youtube.com/favicon.ico`})),te=({components:e=[],children:t})=>(0,c.jsx)(c.Fragment,{children:e.reduceRight((e,t)=>(0,c.jsx)(t,{children:e}),t)}),S={playQueue:`PlayQueueStore`,bottomBar:`BottomBarStore`,playlistList:`PlaylistListStore`,playlist:e=>`PlaylistStore/${e}`},C=(0,l.createContext)(void 0),w=()=>(0,l.useContext)(C),T=new u.default({coerceTypes:!0});function E(e,t){let n;if(n=T.getSchema(t),n===void 0&&(T.addSchema(e,t),n=T.getSchema(t)),n===void 0||n.schema!==e)throw Error(`Invalid schema. Expected: '${JSON.stringify(e)}', but got '${JSON.stringify(n?.schema)}'.`);return n}var D=function(e){return e.Off=`Off`,e.All=`All`,e.One=`One`,e}({});function O(e,t,n,r){var i=arguments.length,a=i<3?t:r===null?r=Object.getOwnPropertyDescriptor(t,n):r,o;if(typeof Reflect==`object`&&typeof Reflect.decorate==`function`)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}var ne={type:`object`,properties:{repeat:{type:`string`,enum:Object.values(D),nullable:!0},shuffle:{type:`boolean`,nullable:!0}}},k=class{bottomBar;constructor(e){this.bottomBar=e,(0,d.makeObservable)(this)}get state(){return{repeat:this.bottomBar.repeat,shuffle:this.bottomBar.shuffle}}set state(e){this.bottomBar.repeat=e.repeat??D.Off,this.bottomBar.shuffle=e.shuffle??!1}validateState(e){return E(ne,`BottomBarLocalStorageState`)(e)}};O([d.computed.struct],k.prototype,`state`,null);var A=class{player;playQueue;localStorageState;repeat=D.Off;shuffle=!1;constructor(e,t){this.player=e,this.playQueue=t,(0,d.makeObservable)(this),this.localStorageState=new k(this)}get controller(){return this.player.controller}get playing(){return this.player.playing}get percent(){return this.player.percent}get canSeek(){return!this.playQueue.isEmpty&&this.controller.supports(`setCurrentTime`)}get currentItem(){return this.playQueue.currentItem}get canToggleRepeat(){return!0}get canToggleShuffle(){return!1}get canPlay(){return this.playQueue.canPlay&&this.controller.supports(`play`)}get canPause(){return this.playQueue.canPause&&this.controller.supports(`pause`)}get canPrevious(){return!this.playQueue.isEmpty}get canNext(){return this.playQueue.hasNextItem}get canSkipBack10(){return this.canSeek}get canSkipForward30(){return this.canSeek}get canRemoveFromPlayQueue(){return!this.playQueue.isEmpty}setPercent(e){this.player.setPercent(e)}setSeeking(e){this.player.setSeeking(e)}toggleRepeat(){switch(this.repeat){case D.Off:this.repeat=D.All;break;case D.All:this.repeat=D.One;break;case D.One:this.repeat=D.Off;break}}toggleShuffle(){this.shuffle=!this.shuffle}play(){return this.controller.play()}pause(){return this.controller.pause()}async previous(){if(this.playQueue.hasPreviousItem){let e=await this.controller.getCurrentTime();e===void 0||e<5?await this.playQueue.previous():await this.controller.setCurrentTime(0)}else await this.controller.setCurrentTime(0)}next(){return this.playQueue.next()}async skipBack10(){let e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e-10)}async skipForward30(){let e=await this.controller.getCurrentTime();e!==void 0&&await this.controller.setCurrentTime(e+30)}async removeFromPlayQueue(){this.currentItem!==void 0&&await this.playQueue.removeItems([this.currentItem])}};O([d.observable],A.prototype,`repeat`,void 0),O([d.observable],A.prototype,`shuffle`,void 0),O([d.computed],A.prototype,`controller`,null),O([d.computed],A.prototype,`playing`,null),O([d.computed],A.prototype,`percent`,null),O([d.computed],A.prototype,`canSeek`,null),O([d.computed],A.prototype,`currentItem`,null),O([d.computed],A.prototype,`canToggleRepeat`,null),O([d.computed],A.prototype,`canToggleShuffle`,null),O([d.computed],A.prototype,`canPlay`,null),O([d.computed],A.prototype,`canPause`,null),O([d.computed],A.prototype,`canPrevious`,null),O([d.computed],A.prototype,`canNext`,null),O([d.computed],A.prototype,`canSkipBack10`,null),O([d.computed],A.prototype,`canSkipForward30`,null),O([d.computed],A.prototype,`canRemoveFromPlayQueue`,null),O([d.action.bound],A.prototype,`setPercent`,null),O([d.action.bound],A.prototype,`setSeeking`,null),O([d.action.bound],A.prototype,`toggleRepeat`,null),O([d.action.bound],A.prototype,`toggleShuffle`,null),O([d.action.bound],A.prototype,`play`,null),O([d.action.bound],A.prototype,`pause`,null),O([d.action.bound],A.prototype,`previous`,null),O([d.action.bound],A.prototype,`next`,null),O([d.action.bound],A.prototype,`skipBack10`,null),O([d.action.bound],A.prototype,`skipForward30`,null),O([d.action.bound],A.prototype,`removeFromPlayQueue`,null);var j=(0,l.createContext)(void 0),M=()=>(0,l.useContext)(j),N=(0,l.createContext)(void 0),P=()=>(0,l.useContext)(N),re=({children:e})=>{let t=P(),n=M(),[r]=(0,l.useState)(()=>new A(t,n));return(0,f.useLocalStorageState)(S.bottomBar,r.localStorageState),(0,c.jsx)(C.Provider,{value:r,children:e})},ie=(0,l.createContext)(void 0),ae=()=>(0,l.useContext)(ie),F=class{player;playQueue;bottomBar;constructor(e,t,n){this.player=e,this.playQueue=t,this.bottomBar=n,(0,d.makeObservable)(this)}get interacted(){return this.playQueue.interacted}get controller(){return this.player.controller}get currentItem(){return this.playQueue.currentItem}async onLoaded(){this.interacted&&await this.controller.play()}onPlay(){this.player.onPlay()}onPause(){this.player.onPause()}async onEnded(){switch(this.bottomBar.repeat){case D.One:await this.controller.setCurrentTime(0);break;case D.Off:case D.All:if(this.playQueue.isLastItem)switch(this.bottomBar.repeat){case D.Off:this.player.onEnded();break;case D.All:this.playQueue.hasMultipleItems?await this.playQueue.goToFirst():await this.controller.setCurrentTime(0);break}else await this.playQueue.next();break}}onTimeUpdate(e){this.player.onTimeUpdate(e)}onControllerChange(e){this.player.onControllerChange(e)}};O([d.computed],F.prototype,`interacted`,null),O([d.computed],F.prototype,`controller`,null),O([d.computed],F.prototype,`currentItem`,null),O([d.action.bound],F.prototype,`onLoaded`,null),O([d.action.bound],F.prototype,`onPlay`,null),O([d.action.bound],F.prototype,`onPause`,null),O([d.action.bound],F.prototype,`onEnded`,null),O([d.action.bound],F.prototype,`onTimeUpdate`,null),O([d.action.bound],F.prototype,`onControllerChange`,null);var oe=({children:e})=>{let t=P(),n=M(),r=w(),[i]=(0,l.useState)(()=>new F(t,n,r));return(0,c.jsx)(ie.Provider,{value:i,children:e})},I={type:`object`,properties:{url:{type:`string`},type:{type:`string`},videoId:{type:`string`},title:{type:`string`}},required:[`url`,`type`,`videoId`,`title`]},se={type:`object`,properties:{version:{type:`string`,nullable:!0},repeat:{type:`string`,enum:Object.values(D),nullable:!0},shuffle:{type:`boolean`,nullable:!0},items:{type:`array`,nullable:!0,items:I},currentIndex:{type:`integer`,nullable:!0}}},L=class e{playQueue;dto;static nextId=1;id;isSelected=!1;constructor(t,n){this.playQueue=t,this.dto=n,(0,d.makeObservable)(this),this.id=e.nextId++}static fromDto(t,n){return new e(t,n)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return this.playQueue.currentItem===this}get index(){return this.playQueue.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playQueue.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playQueue.hasMultipleItems}clone(){return this.playQueue.createItemFromDto(this.dto)}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.setCurrentItem(this),Promise.resolve()}remove(){return this.playQueue.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.clone()])}playNext(){return this.playQueue.playNext([this.clone()])}addToPlayQueue(){return this.playQueue.addItems([this.clone()])}moveToTop(){this.playQueue.moveItem(this,0)}moveToBottom(){this.playQueue.moveItem(this,this.playQueue.items.length-1)}removeToTop(){return this.playQueue.removeItemsAbove(this)}removeOthers(){return this.playQueue.removeOtherItems(this)}};O([d.observable],L.prototype,`isSelected`,void 0),O([d.computed],L.prototype,`isCurrent`,null),O([d.computed],L.prototype,`index`,null),O([d.computed],L.prototype,`isFirst`,null),O([d.computed],L.prototype,`isLast`,null),O([d.computed],L.prototype,`canMoveToTop`,null),O([d.computed],L.prototype,`canMoveToBottom`,null),O([d.computed],L.prototype,`canRemoveToTop`,null),O([d.computed],L.prototype,`canRemoveOthers`,null),O([d.action.bound],L.prototype,`unselect`,null),O([d.action.bound],L.prototype,`select`,null),O([d.action.bound],L.prototype,`toggleSelected`,null),O([d.action.bound],L.prototype,`play`,null),O([d.action.bound],L.prototype,`remove`,null),O([d.action.bound],L.prototype,`playFirst`,null),O([d.action.bound],L.prototype,`playNext`,null),O([d.action.bound],L.prototype,`addToPlayQueue`,null),O([d.action.bound],L.prototype,`moveToTop`,null),O([d.action.bound],L.prototype,`moveToBottom`,null),O([d.action.bound],L.prototype,`removeToTop`,null),O([d.action.bound],L.prototype,`removeOthers`,null);var R=class{playQueue;constructor(e){this.playQueue=e,(0,d.makeObservable)(this)}get state(){return{version:`1.0`,items:this.playQueue.items.map(e=>e.dto),currentIndex:this.playQueue.currentIndex}}set state(e){this.playQueue.items=e.items?.map(e=>this.playQueue.createItemFromDto(e))??[],this.playQueue.currentIndex=e.currentIndex}validateState(e){return E(se,`PlayQueueDto`)(e)}};O([d.computed.struct],R.prototype,`state`,null);var z=class{interacted=!1;localStorageState;items=[];currentId;constructor(){(0,d.makeObservable)(this),this.localStorageState=new R(this)}createItemFromDto(e){return L.fromDto(this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get canClear(){return!this.isEmpty}get currentItem(){return this.items.find(e=>e.id===this.currentId)}get canPlay(){return this.currentItem!==void 0}get canPause(){return this.currentItem!==void 0}get hasMultipleItems(){return this.items.length>1}get currentIndex(){return this.currentId===void 0?void 0:this.items.findIndex(e=>e.id===this.currentId)}set currentIndex(e){this.currentId=e===void 0?void 0:this.items.at(e)?.id}get hasPreviousItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex>0}get hasNextItem(){return this.hasMultipleItems&&this.currentIndex!==void 0&&this.currentIndex<this.items.length-1}get isLastItem(){return this.currentIndex!==void 0&&this.currentIndex===this.items.length-1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}interact(){this.interacted=!0}clear(){this.interact(),this.currentIndex=void 0,this.items=[]}unselectAll(){for(let e of this.items)e.unselect()}selectAll(){for(let e of this.items)e.select()}setCurrentItem(e){this.interact(),this.currentId=e?.id}setNextItems(e){this.currentIndex!==void 0&&this.items.splice(this.currentIndex+1,0,...e)}clearAndSetItems(e){this.clear(),this.setCurrentItem(e[0]),this.setNextItems(e)}async playNext(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.setNextItems(e)}async playSelectedItemsNext(){await this.playNext(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async addItems(e){if(this.isEmpty){this.clearAndSetItems(e);return}this.items.push(...e)}async addSelectedItems(){await this.addItems(this.selectedItemsOrAllItems.map(e=>e.clone())),this.unselectAll()}async playFirst(e){if(this.isEmpty){this.clearAndSetItems(e);return}let{currentIndex:t}=this;t!==void 0&&(this.interact(),this.items.splice(t,0,...e),this.currentIndex=t)}moveItem(e,t){let n=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(t,0,n)}async goToFirst(){this.currentIndex!==void 0&&(this.currentIndex=0)}async removeItems(e){let{currentItem:t}=this;(0,p.pull)(this.items,...e.filter(e=>e!==t));let{currentIndex:n,isLastItem:r}=this;(0,p.pull)(this.items,e.find(e=>e===t)),this.currentItem!==t&&(this.interact(),r?await this.goToFirst():this.currentIndex=n)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){let t=e.id;return this.removeItems(this.items.filter(e=>e.id!==t))}async removeItemsAbove(e){let t=this.items.indexOf(e);return this.removeItems(this.items.filter((e,n)=>n<t))}async previous(){this.currentIndex!==void 0&&this.hasPreviousItem&&(this.interact(),this.currentIndex--)}async next(){this.currentIndex!==void 0&&this.hasNextItem&&(this.interact(),this.currentIndex++)}addItemFromDto(e){let t=this.createItemFromDto(e);return this.addItems([t])}};O([d.observable],z.prototype,`interacted`,void 0),O([d.observable],z.prototype,`items`,void 0),O([d.observable],z.prototype,`currentId`,void 0),O([d.computed],z.prototype,`isEmpty`,null),O([d.computed],z.prototype,`canClear`,null),O([d.computed],z.prototype,`currentItem`,null),O([d.computed],z.prototype,`canPlay`,null),O([d.computed],z.prototype,`canPause`,null),O([d.computed],z.prototype,`hasMultipleItems`,null),O([d.computed],z.prototype,`currentIndex`,null),O([d.computed],z.prototype,`hasPreviousItem`,null),O([d.computed],z.prototype,`hasNextItem`,null),O([d.computed],z.prototype,`isLastItem`,null),O([d.computed],z.prototype,`selectedItems`,null),O([d.computed],z.prototype,`allItemsSelected`,null),O([d.computed],z.prototype,`hasSelectedItems`,null),O([d.computed],z.prototype,`selectedItemsOrAllItems`,null),O([d.computed],z.prototype,`canAddSelectedItems`,null),O([d.computed],z.prototype,`canPlaySelectedItemsNext`,null),O([d.computed],z.prototype,`canRemoveSelectedItems`,null),O([d.action.bound],z.prototype,`setItems`,null),O([d.action.bound],z.prototype,`interact`,null),O([d.action.bound],z.prototype,`clear`,null),O([d.action.bound],z.prototype,`unselectAll`,null),O([d.action.bound],z.prototype,`selectAll`,null),O([d.action.bound],z.prototype,`setCurrentItem`,null),O([d.action.bound],z.prototype,`setNextItems`,null),O([d.action.bound],z.prototype,`clearAndSetItems`,null),O([d.action.bound],z.prototype,`playNext`,null),O([d.action.bound],z.prototype,`playSelectedItemsNext`,null),O([d.action.bound],z.prototype,`addItems`,null),O([d.action.bound],z.prototype,`addSelectedItems`,null),O([d.action.bound],z.prototype,`playFirst`,null),O([d.action.bound],z.prototype,`moveItem`,null),O([d.action.bound],z.prototype,`goToFirst`,null),O([d.action.bound],z.prototype,`removeItems`,null),O([d.action.bound],z.prototype,`removeSelectedItems`,null),O([d.action.bound],z.prototype,`removeOtherItems`,null),O([d.action.bound],z.prototype,`removeItemsAbove`,null),O([d.action.bound],z.prototype,`previous`,null),O([d.action.bound],z.prototype,`next`,null),O([d.action.bound],z.prototype,`addItemFromDto`,null);var ce=({children:e})=>{let[t]=(0,l.useState)(()=>new z);(0,f.useLocalStorageState)(S.playQueue,t.localStorageState);let n=(0,m.useNostalgicDiva)();return(0,l.useEffect)(()=>(0,d.reaction)(()=>t.currentItem,async(e,t)=>{e===void 0||t===void 0||e.type===t.type&&e.videoId===t.videoId&&await n.setCurrentTime(0)}),[t,n]),(0,c.jsx)(j.Provider,{value:t,children:e})},B=class{controller=m.nullPlayerController;playing=!1;percent=0;seeking=!1;constructor(){(0,d.makeObservable)(this)}setPlaying(e){this.playing=e}setPercent(e){this.percent=e}setSeeking(e){this.seeking=e}onControllerChange(e){this.controller=e}onPlay(){this.playing=!0}onPause(){this.playing=!1}onEnded(){this.playing=!1}onTimeUpdate({percent:e}){e!==void 0&&(this.seeking||(this.percent=e))}};O([d.observable],B.prototype,`controller`,void 0),O([d.observable],B.prototype,`playing`,void 0),O([d.observable],B.prototype,`percent`,void 0),O([d.observable],B.prototype,`seeking`,void 0),O([d.action.bound],B.prototype,`setPlaying`,null),O([d.action.bound],B.prototype,`setPercent`,null),O([d.action.bound],B.prototype,`setSeeking`,null),O([d.action.bound],B.prototype,`onControllerChange`,null),O([d.action.bound],B.prototype,`onPlay`,null),O([d.action.bound],B.prototype,`onPause`,null),O([d.action.bound],B.prototype,`onEnded`,null),O([d.action.bound],B.prototype,`onTimeUpdate`,null);var le=({children:e})=>{let[t]=(0,l.useState)(()=>new B);return(0,c.jsx)(N.Provider,{value:t,children:e})},V=(0,l.createContext)(void 0),H=()=>(0,l.useContext)(V),U=class{playlistList;id;name;constructor(e,t,n){this.playlistList=e,(0,d.makeObservable)(this),this.id=t,this.name=n}async rename(e){this.name=e}remove(){return this.playlistList.removeItem(this)}};O([d.observable],U.prototype,`id`,void 0),O([d.observable],U.prototype,`name`,void 0),O([d.action.bound],U.prototype,`rename`,null),O([d.action.bound],U.prototype,`remove`,null);var W=class{playlistList;constructor(e){this.playlistList=e,(0,d.makeObservable)(this)}get state(){return{items:this.playlistList.items.map(e=>({id:e.id,name:e.name}))}}set state(e){this.playlistList.items=e.items?.map(e=>new U(this.playlistList,e.id,e.name))??[]}validateState(e){return!0}};O([d.computed.struct],W.prototype,`state`,null);var G=class{localStorageState;items=[];constructor(){(0,d.makeObservable)(this),this.localStorageState=new W(this)}createItem(e){return new U(this,crypto.randomUUID(),e)}setItems(e){this.items=e}async addItem(e){this.items.push(e)}async removeItem(e){(0,p.pull)(this.items,e)}};O([d.observable],G.prototype,`items`,void 0),O([d.action.bound],G.prototype,`setItems`,null),O([d.action.bound],G.prototype,`addItem`,null),O([d.action.bound],G.prototype,`removeItem`,null);var ue=({children:e})=>{let[t]=(0,l.useState)(()=>new G);return(0,f.useLocalStorageState)(S.playlistList,t.localStorageState),(0,c.jsx)(V.Provider,{value:t,children:e})},de=({children:e,nostalgicDivaProps:t})=>(0,c.jsx)(m.NostalgicDivaProvider,{...t,children:(0,c.jsx)(te,{components:[le,ce,re,oe,ue],children:e})}),K={width:400,height:225},fe=(0,g.observer)(({children:e})=>{let t=M();return(0,c.jsxs)(h.EuiPageTemplate,{panelled:!0,style:{minBlockSize:`max(460px, 100vh - 81px)`},children:[e,!t.isEmpty&&(0,c.jsx)(h.EuiSpacer,{style:{blockSize:K.height}})]})}),pe=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Shuffle: ${e.shuffle?`On`:`Off`}`,"aria-label":`Shuffle: ${e.shuffle?`On`:`Off`}`,iconType:e.shuffle?_.ArrowShuffleFilled:_.ArrowShuffleOffFilled,size:`s`,iconSize:`l`,onClick:e.toggleShuffle,disabled:!e.canToggleShuffle})}),me=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Previous`,"aria-label":`Previous`,iconType:_.PreviousFilled,size:`s`,iconSize:`l`,onClick:e.previous,disabled:!e.canPrevious})}),he=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Skip back 10 seconds`,"aria-label":`Skip back 10 seconds`,iconType:_.SkipBack10Regular,size:`s`,iconSize:`l`,onClick:e.skipBack10,disabled:!e.canSkipBack10})}),ge=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Pause`,"aria-label":`Pause`,iconType:_.PauseFilled,size:`s`,iconSize:`l`,onClick:e.pause,disabled:!e.canPause})}),_e=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Play`,"aria-label":`Play`,iconType:_.PlayFilled,size:`s`,iconSize:`l`,onClick:e.play,disabled:!e.canPlay})}),ve=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Skip forward 30 seconds`,"aria-label":`Skip forward 30 seconds`,iconType:_.SkipForward30Regular,size:`s`,iconSize:`l`,onClick:e.skipForward30,disabled:!e.canSkipForward30})}),ye=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Next`,"aria-label":`Next`,iconType:_.NextFilled,size:`s`,iconSize:`l`,onClick:e.next,disabled:!e.canNext})}),q={[D.Off]:_.ArrowRepeatAllOffFilled,[D.All]:_.ArrowRepeatAllFilled,[D.One]:_.ArrowRepeat1Filled},be=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiButtonIcon,{title:`Repeat: ${e.repeat===D.All?`All`:e.repeat===D.One?`One`:`Off`}`,"aria-label":`Repeat: ${e.repeat===D.All?`All`:e.repeat===D.One?`One`:`Off`}`,iconType:q[e.repeat],size:`s`,iconSize:`l`,onClick:e.toggleRepeat,disabled:!e.canToggleRepeat})}),xe=(0,g.observer)(()=>{let e=w();return(0,c.jsxs)(h.EuiFlexGroup,{responsive:!1,gutterSize:`s`,justifyContent:`center`,alignItems:`center`,children:[(0,c.jsx)(h.EuiHideFor,{sizes:[`xs`],children:(0,c.jsx)(pe,{})}),(0,c.jsx)(me,{}),(0,c.jsx)(h.EuiHideFor,{sizes:[`xs`],children:(0,c.jsx)(he,{})}),e.playing?(0,c.jsx)(ge,{}):(0,c.jsx)(_e,{}),(0,c.jsx)(h.EuiHideFor,{sizes:[`xs`],children:(0,c.jsx)(ve,{})}),(0,c.jsx)(ye,{}),(0,c.jsx)(h.EuiHideFor,{sizes:[`xs`],children:(0,c.jsx)(be,{})})]})}),Se=(0,l.memo)(({item:e,closePopover:t})=>{let n=(0,l.useCallback)(({name:e,icon:n,onClick:r})=>({name:e,icon:n,onClick:async e=>{t(),r(e)}}),[t]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[n({name:`Open in new tab`,icon:(0,c.jsx)(h.EuiIcon,{type:_.OpenRegular}),onClick:async()=>{window.open(e.dto.url,`_blank`)}}),n({name:`Copy link address`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:async()=>{await navigator.clipboard.writeText(e.dto.url)}}),n({name:`Copy link text`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:async()=>{await navigator.clipboard.writeText(e.dto.title)}})]}],[n,e])})}),Ce=(0,l.memo)(({item:e})=>{let[t,n]=(0,l.useState)(!1),r=(0,l.useCallback)(()=>n(!t),[t]),i=(0,l.useCallback)(()=>n(!1),[]);return(0,c.jsx)(h.EuiPopover,{button:(0,c.jsx)(h.EuiButtonEmpty,{iconType:x.get(e.type),size:`s`,onClick:r,children:e.title}),isOpen:t,closePopover:i,panelPaddingSize:`none`,anchorPosition:`upLeft`,children:(0,c.jsx)(Se,{item:e,closePopover:i})})}),we=(0,g.observer)(()=>{let e=w();return(0,c.jsx)(h.EuiFlexGroup,{responsive:!1,gutterSize:`s`,justifyContent:`flexStart`,alignItems:`center`,children:e.currentItem&&(0,c.jsx)(Ce,{item:e.currentItem})})}),Te=(0,g.observer)(()=>(0,c.jsx)(h.EuiButtonIcon,{title:`Mute`,"aria-label":`Mute`,iconType:_.Speaker2Regular,size:`s`,iconSize:`l`,disabled:!w().controller.supports(`setMuted`)})),Ee=(0,g.observer)(({button:e,isOpen:t,closePopover:n})=>{let r=w(),[i,a]=(0,l.useState)(`0`),o=(0,m.useNostalgicDiva)();(0,l.useLayoutEffect)(()=>{t&&o.getVolume().then(e=>{e!==void 0&&a(Math.floor(e*100).toString())})},[t,o]);let s=(0,l.useCallback)(async e=>{a(e.currentTarget.value),await o.setVolume(Number(e.currentTarget.value)/100)},[o]);return(0,c.jsx)(h.EuiPopover,{button:e,isOpen:t,closePopover:n,anchorPosition:`upRight`,children:(0,c.jsx)(h.EuiFormRow,{children:(0,c.jsxs)(h.EuiFlexGroup,{responsive:!1,gutterSize:`s`,justifyContent:`center`,alignItems:`center`,children:[(0,c.jsx)(Te,{}),(0,c.jsx)(h.EuiRange,{min:0,max:100,step:1,value:i,onChange:s,css:{blockSize:32},disabled:!r.controller.supports(`setVolume`)})]})})})}),De=(0,g.observer)(()=>{let e=w(),[t,n]=(0,l.useState)(!1);return(0,c.jsx)(Ee,{button:(0,c.jsx)(h.EuiButtonIcon,{title:`Volume`,"aria-label":`Volume`,iconType:_.Speaker2Regular,size:`s`,iconSize:`l`,onClick:()=>n(!t),disabled:!e.controller.supports(`getVolume`)}),isOpen:t,closePopover:()=>n(!1)})}),Oe=({onClickPlayQueueButton:e})=>(0,c.jsx)(h.EuiButtonIcon,{title:`Play queue`,"aria-label":`Play queue`,iconType:_.NavigationPlayRegular,size:`s`,iconSize:`l`,onClick:e}),ke=(0,g.observer)(({closePopover:e})=>{let t=w(),n=(0,m.useNostalgicDiva)(),[r,i]=(0,l.useState)(),a=(0,l.useCallback)(async()=>{await t.controller.getPlaybackRate().then(e=>i(e))},[t]),o=(0,l.useCallback)(({name:t,icon:n,onClick:r,disabled:i,className:a})=>({name:t,icon:n,onClick:async()=>{e(),r()},disabled:i,className:a}),[e]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[{name:`Speed`,icon:(0,c.jsx)(h.EuiIcon,{type:_.TopSpeedRegular}),panel:1,onClick:a,disabled:!t.controller.supports(`getPlaybackRate`)},o({name:`Skip back 10 seconds`,icon:(0,c.jsx)(h.EuiIcon,{type:_.SkipBack10Regular}),onClick:t.skipBack10,disabled:!t.canSkipBack10}),o({name:`Skip forward 30 seconds`,icon:(0,c.jsx)(h.EuiIcon,{type:_.SkipForward30Regular}),onClick:t.skipForward30,disabled:!t.canSkipForward30}),o({name:`Shuffle: ${t.shuffle?`On`:`Off`}`,icon:(0,c.jsx)(h.EuiIcon,{type:t.shuffle?_.ArrowShuffleFilled:_.ArrowShuffleOffFilled}),onClick:t.toggleShuffle,disabled:!t.canToggleShuffle,className:`eui-showFor--xs--flex`}),o({name:`Repeat: ${t.repeat===D.All?`All`:t.repeat===D.One?`One`:`Off`}`,icon:(0,c.jsx)(h.EuiIcon,{type:q[t.repeat]}),onClick:t.toggleRepeat,disabled:!t.canToggleRepeat,className:`eui-showFor--xs--flex`}),{isSeparator:!0},o({name:`Remove from play queue`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DismissRegular}),onClick:t.removeFromPlayQueue,disabled:!t.canRemoveFromPlayQueue})]},{id:1,title:`Speed`,items:[.25,.5,.75,1,1.25,1.5,1.75,2].map(e=>o({name:e.toString(),onClick:()=>n.setPlaybackRate(e),icon:e===r?`check`:`empty`,disabled:!t.controller.supports(`setPlaybackRate`)}))}],[t,o,a,n,r])})}),Ae=(0,l.memo)(({button:e,isOpen:t,closePopover:n})=>(0,c.jsx)(h.EuiPopover,{button:e,isOpen:t,closePopover:n,panelPaddingSize:`none`,anchorPosition:`upRight`,children:(0,c.jsx)(ke,{closePopover:n})})),je=(0,l.memo)(()=>{let[e,t]=(0,l.useState)(!1);return(0,c.jsx)(Ae,{button:(0,c.jsx)(h.EuiButtonIcon,{title:`More options`,"aria-label":`More options`,iconType:_.MoreHorizontalFilled,size:`s`,iconSize:`l`,onClick:()=>t(!e)}),isOpen:e,closePopover:()=>t(!1)})}),Me=(0,l.memo)(({onClickPlayQueueButton:e})=>(0,c.jsxs)(h.EuiFlexGroup,{responsive:!1,gutterSize:`s`,justifyContent:`flexEnd`,alignItems:`center`,children:[(0,c.jsx)(De,{}),e&&(0,c.jsx)(Oe,{onClickPlayQueueButton:e}),(0,c.jsx)(je,{})]})),Ne=(0,g.observer)(()=>{let e=w(),t=(0,m.useNostalgicDiva)(),n=(0,l.useCallback)(t=>{let n=Number(t.currentTarget.value)/100;e.setPercent(n)},[e]),r=(0,l.useCallback)(t=>{t.button===0&&e.setSeeking(!0)},[e]),i=(0,l.useCallback)(async n=>{if(n.button===0){let r=Number(n.currentTarget.value)/100;e.setSeeking(!1);let i=await t.getDuration();i!==void 0&&await t.setCurrentTime(i*r)}},[e,t]);return(0,c.jsx)(h.EuiRange,{min:0,max:100,step:1e-7,value:e.percent*100,onChange:n,onMouseDown:r,onMouseUp:i,fullWidth:!0,showRange:!0,css:{blockSize:32},disabled:!e.canSeek})}),Pe=(0,g.observer)(({onClickPlayQueueButton:e})=>(0,c.jsx)(h.EuiBottomBar,{paddingSize:`s`,children:(0,c.jsxs)(h.EuiFlexGroup,{direction:`column`,gutterSize:`none`,children:[(0,c.jsx)(h.EuiFlexItem,{children:(0,c.jsx)(Ne,{})}),(0,c.jsx)(h.EuiFlexItem,{children:(0,c.jsxs)(h.EuiFlexGroup,{responsive:!1,children:[(0,c.jsx)(h.EuiFlexItem,{css:{width:`calc(100% / 3)`},children:(0,c.jsx)(we,{})}),(0,c.jsx)(h.EuiFlexItem,{css:{width:`calc(100% / 3)`},children:(0,c.jsx)(xe,{})}),(0,c.jsx)(h.EuiFlexItem,{css:{width:`calc(100% / 3)`},children:(0,c.jsx)(Me,{onClickPlayQueueButton:e})})]})})]})})),Fe=(0,g.observer)(()=>{let e=ae(),t=(0,l.useMemo)(()=>({onLoaded:e.onLoaded,onPlay:e.onPlay,onPause:e.onPause,onEnded:e.onEnded,onTimeUpdate:e.onTimeUpdate}),[e]);return(0,c.jsx)(`div`,{css:{position:`fixed`,right:0,bottom:81,width:K.width,height:K.height,zIndex:998,backgroundColor:`rgb(39, 39, 39)`,display:`flex`,flexDirection:`column`},children:(0,c.jsx)(`div`,{css:{flexGrow:1,backgroundColor:`black`},children:e.currentItem&&(0,c.jsx)(m.NostalgicDiva,{src:e.currentItem.url,options:t,onControllerChange:e.onControllerChange})})})});function Ie(e){return typeof e==`object`&&!!e&&`title`in e&&typeof e.title==`string`}var Le=v.default.create(({remove:e,resolve:t})=>{let n=(0,h.useGeneratedHtmlId)({prefix:`modalForm`}),[r,i]=(0,l.useState)(``),[a,o]=(0,l.useState)(``),[s,u]=(0,l.useState)(!1);return(0,c.jsxs)(h.EuiModal,{onClose:e,initialFocus:`[name=url]`,children:[(0,c.jsx)(h.EuiModalHeader,{children:(0,c.jsx)(h.EuiModalHeaderTitle,{children:`Add video`})}),(0,c.jsx)(h.EuiModalBody,{children:(0,c.jsxs)(h.EuiForm,{id:n,component:`form`,onSubmit:async n=>{n.preventDefault();try{u(!0);let n=(0,m.findVideoService)(r);if(n===void 0)return;let i=n.extractVideoId(r);if(i===void 0)return;let o=await(await fetch(`https://noembed.com/embed?url=${encodeURIComponent(r)}`)).json();t({url:r,type:n.type,videoId:i,title:a||(Ie(o)?o.title:i)}),e()}finally{u(!1)}},children:[(0,c.jsx)(h.EuiFormRow,{label:`URL`,children:(0,c.jsx)(h.EuiFieldText,{name:`url`,value:r,onChange:e=>i(e.target.value)})}),(0,c.jsx)(h.EuiFormRow,{label:`Title`,children:(0,c.jsx)(h.EuiFieldText,{name:`title`,value:a,onChange:e=>o(e.target.value)})})]})}),(0,c.jsxs)(h.EuiModalFooter,{children:[(0,c.jsx)(h.EuiButtonEmpty,{onClick:e,children:`Cancel`}),(0,c.jsx)(h.EuiButton,{type:`submit`,form:n,fill:!0,disabled:r.trim().length===0,isLoading:s,children:`Add video`})]})]})}),J=(0,l.memo)(({onFulfilled:e})=>(0,c.jsx)(h.EuiButton,{onClick:()=>v.default.show(Le).then(e),iconType:_.AddRegular,color:`primary`,children:`Add video`})),Re=(0,g.observer)(({playQueue:e})=>(0,c.jsx)(h.EuiButton,{iconType:_.AddRegular,onClick:e.addSelectedItems,disabled:!e.canAddSelectedItems,children:`Add to play queue`})),ze=(0,g.observer)(({playQueue:e,closePopover:t})=>{let n=(0,l.useCallback)(({name:e,icon:n,disabled:r,onClick:i})=>({name:e,icon:n,disabled:r,onClick:async e=>{t(),i(e)}}),[t]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[n({name:`Play next`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),disabled:!e.canPlaySelectedItemsNext,onClick:e.playSelectedItemsNext}),n({name:`Add to play queue`,icon:(0,c.jsx)(h.EuiIcon,{type:_.AddRegular}),onClick:e.addSelectedItems,disabled:!e.canAddSelectedItems}),n({name:`Remove`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DismissRegular}),onClick:e.removeSelectedItems,disabled:!e.canRemoveSelectedItems}),n({name:`Clear`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DeleteRegular}),onClick:e.clear,disabled:!e.canClear})]}],[n,e])})}),Be=(0,l.memo)(({playQueue:e})=>{let[t,n]=(0,l.useState)(!1),r=(0,l.useCallback)(()=>n(!t),[t]),i=(0,l.useCallback)(()=>n(!1),[]);return(0,c.jsx)(h.EuiPopover,{button:(0,c.jsx)(h.EuiButtonIcon,{display:`base`,size:`m`,iconType:_.MoreHorizontalFilled,onClick:r}),isOpen:t,closePopover:i,panelPaddingSize:`none`,anchorPosition:`downLeft`,children:(0,c.jsx)(ze,{playQueue:e,closePopover:i})})}),Ve=(0,g.observer)(({playQueue:e})=>{let{euiTheme:t}=(0,h.useEuiTheme)();return(0,c.jsxs)(h.EuiFlexGroup,{alignItems:`center`,gutterSize:`m`,responsive:!1,style:{position:`sticky`,top:48,zIndex:998,background:t.colors.backgroundBasePlain},children:[(0,c.jsxs)(h.EuiHideFor,{sizes:[`xs`],children:[(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiButton,{disabled:!e.canPlaySelectedItemsNext,onClick:e.playSelectedItemsNext,children:`Play next`})}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(Re,{playQueue:e})}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiButton,{iconType:_.DismissRegular,onClick:e.removeSelectedItems,disabled:!e.canRemoveSelectedItems,children:`Remove`})}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiButton,{iconType:_.DeleteRegular,onClick:e.clear,disabled:!e.canClear,children:`Clear`})})]}),(0,c.jsx)(h.EuiShowFor,{sizes:[`xs`],children:(0,c.jsx)(Be,{playQueue:e})}),(0,c.jsx)(h.EuiFlexItem,{grow:!0}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(J,{onFulfilled:e.addItemFromDto})})]})}),He=(0,g.observer)(({playQueue:e})=>{let{euiTheme:t}=(0,h.useEuiTheme)();return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(h.EuiTableHeaderMobile,{children:(0,c.jsx)(h.EuiFlexGroup,{responsive:!1,justifyContent:`spaceBetween`,alignItems:`baseline`,children:(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiCheckbox,{id:``,checked:e.allItemsSelected,onChange:t=>{t.target.checked?e.selectAll():e.unselectAll()}})})})}),(0,c.jsxs)(h.EuiTableHeader,{style:{position:`sticky`,top:112,zIndex:998,background:t.colors.backgroundBasePlain},children:[(0,c.jsx)(h.EuiTableHeaderCellCheckbox,{children:(0,c.jsx)(h.EuiCheckbox,{id:``,checked:e.allItemsSelected,onChange:t=>{t.target.checked?e.selectAll():e.unselectAll()}})}),(0,c.jsx)(h.EuiTableHeaderCell,{width:24}),(0,c.jsx)(h.EuiTableHeaderCell,{children:`Title`}),(0,c.jsx)(h.EuiTableHeaderCell,{})]})]})}),Ue=(0,g.observer)(({item:e,closePopover:t})=>{let n=(0,l.useCallback)(({name:e,icon:n,disabled:r,onClick:i,className:a})=>({name:e,icon:n,disabled:r,onClick:async e=>{t(),i(e)},className:a}),[t]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[n({name:`Play`,icon:(0,c.jsx)(h.EuiIcon,{type:_.PlayRegular}),onClick:e.play,className:`eui-showFor--xs--flex`}),n({name:`Play first`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.playFirst}),n({name:`Play next`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.playNext}),n({name:`Add to play queue`,icon:(0,c.jsx)(h.EuiIcon,{type:_.AddRegular}),onClick:e.addToPlayQueue}),{isSeparator:!0},n({name:`Move to the top`,icon:(0,c.jsx)(h.EuiIcon,{type:_.ArrowUploadRegular}),onClick:e.moveToTop,disabled:!e.canMoveToTop}),n({name:`Move to the bottom`,icon:(0,c.jsx)(h.EuiIcon,{type:_.ArrowDownloadRegular}),onClick:e.moveToBottom,disabled:!e.canMoveToBottom}),{isSeparator:!0},n({name:`Remove`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DismissRegular}),onClick:e.remove,className:`eui-showFor--xs--flex`}),n({name:`Remove to the top`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.removeToTop,disabled:!e.canRemoveToTop}),n({name:`Remove others`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.removeOthers,disabled:!e.canRemoveOthers})]}],[n,e])})}),We=(0,l.memo)(({item:e})=>{let[t,n]=(0,l.useState)(!1),r=(0,l.useCallback)(()=>n(!t),[t]),i=(0,l.useCallback)(()=>n(!1),[]);return(0,c.jsx)(h.EuiPopover,{button:(0,c.jsx)(h.EuiButtonIcon,{title:`More options`,"aria-label":`More options`,iconType:_.MoreHorizontalFilled,size:`s`,color:`text`,onClick:r}),isOpen:t,closePopover:i,panelPaddingSize:`none`,anchorPosition:`leftCenter`,children:(0,c.jsx)(Ue,{item:e,closePopover:i})})}),Ge=(0,g.observer)(({item:e})=>{let t=(0,m.useNostalgicDiva)();return(0,c.jsxs)(h.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:`right`,children:[(0,c.jsxs)(h.EuiHideFor,{sizes:[`xs`],children:[(0,c.jsx)(h.EuiButton,{iconType:_.PlayRegular,size:`s`,onClick:async()=>{e.isCurrent?await t.setCurrentTime(0):await e.play()},children:`Play`}),(0,c.jsx)(h.EuiButton,{iconType:_.DismissRegular,size:`s`,onClick:e.remove,children:`Remove`})]}),(0,c.jsx)(We,{item:e})]})}),Ke=(0,g.observer)(({item:e})=>(0,c.jsxs)(h.EuiTableRow,{isSelected:e.isCurrent,hasSelection:!0,hasActions:!0,children:[(0,c.jsx)(h.EuiTableRowCellCheckbox,{children:(0,c.jsx)(h.EuiCheckbox,{id:e.id.toString(),checked:e.isSelected,onChange:e.toggleSelected})}),(0,c.jsx)(h.EuiTableRowCell,{textOnly:!1,children:(0,c.jsx)(`img`,{src:x.get(e.type),width:16,height:16,alt:e.type})}),(0,c.jsx)(h.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:`100%`},children:(0,c.jsx)(h.EuiLink,{href:e.url,target:`_blank`,external:!0,children:e.title})}),(0,c.jsx)(Ge,{item:e})]})),qe=(0,g.observer)(({playQueue:e})=>(0,c.jsx)(y.ReactSortable,{tag:`tbody`,list:e.items,setList:t=>e.setItems(t),children:e.items.map(e=>(0,c.jsx)(Ke,{item:e},e.id))})),Je=(0,g.observer)(({playQueue:e})=>(0,c.jsxs)(h.EuiTable,{children:[(0,c.jsx)(He,{playQueue:e}),(0,c.jsx)(qe,{playQueue:e})]})),Y=(0,g.observer)(({playQueue:e})=>{let{euiTheme:t}=(0,h.useEuiTheme)();return(0,c.jsxs)(h.EuiPageTemplate.Section,{children:[(0,c.jsx)(Ve,{playQueue:e}),(0,c.jsx)(h.EuiSpacer,{size:`l`,style:{position:`sticky`,top:88,zIndex:998,background:t.colors.backgroundBasePlain}}),e.isEmpty?(0,c.jsx)(h.EuiEmptyPrompt,{title:(0,c.jsx)(`h2`,{children:`We couldn't find any videos`}),body:(0,c.jsx)(`p`,{children:`Your video library doesn't contain any video content.`}),actions:(0,c.jsx)(J,{onFulfilled:e.addItemFromDto})}):(0,c.jsx)(Je,{playQueue:e})]})}),X=({breadcrumbs:e,tabs:t,...n})=>{let r=(0,b.useRouter)();return(0,c.jsx)(h.EuiPageTemplate.Header,{...n,breadcrumbs:e?.map(({linkProps:e,...t})=>({...t,href:e===void 0?void 0:r.buildLocation(e).href,onClick:e===void 0?void 0:async t=>{t.preventDefault(),await r.navigate(e)}})),tabs:t?.map(({linkProps:e,...t})=>({...t,href:e===void 0?void 0:r.buildLocation(e).href,onClick:e===void 0?void 0:async t=>{t.preventDefault(),await r.navigate(e)}}))})},Ye=()=>{let e=M();return(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(X,{pageTitle:`Play queue`,rightSideItems:[]}),(0,c.jsx)(Y,{playQueue:e})]})},Xe=v.default.create(({remove:e,resolve:t,playlistListItem:n})=>{let[r,i]=(0,l.useState)(!1);return(0,c.jsx)(h.EuiConfirmModal,{title:`Delete playlist permanently?`,onCancel:e,onConfirm:(0,l.useCallback)(async()=>{try{i(!0),t(),e()}finally{i(!1)}},[t,e]),cancelButtonText:`Cancel`,confirmButtonText:`Delete`,buttonColor:`danger`,isLoading:r,children:(0,c.jsxs)(`p`,{children:[`Are you sure you want to delete this playlist? If you delete '`,n.name,`', you won't be able to recover it.`]})})}),Ze=(0,g.observer)(({playlist:e})=>(0,c.jsx)(h.EuiButton,{iconType:_.AddRegular,onClick:e.addSelectedItems,disabled:!e.canAddSelectedItems,children:`Add to play queue`})),Qe=(0,g.observer)(({playlist:e,closePopover:t})=>{let n=(0,l.useCallback)(({name:e,icon:n,disabled:r,onClick:i})=>({name:e,icon:n,disabled:r,onClick:async e=>{t(),i(e)}}),[t]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[n({name:`Play next`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),disabled:!e.canPlaySelectedItemsNext,onClick:e.playSelectedItemsNext}),n({name:`Add to play queue`,icon:(0,c.jsx)(h.EuiIcon,{type:_.AddRegular}),onClick:e.addSelectedItems,disabled:!e.canAddSelectedItems}),n({name:`Remove`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DismissRegular}),onClick:e.removeSelectedItems,disabled:!e.canRemoveSelectedItems})]}],[n,e])})}),$e=(0,l.memo)(({playlist:e})=>{let[t,n]=(0,l.useState)(!1),r=(0,l.useCallback)(()=>n(!t),[t]),i=(0,l.useCallback)(()=>n(!1),[]);return(0,c.jsx)(h.EuiPopover,{button:(0,c.jsx)(h.EuiButtonIcon,{display:`base`,size:`m`,iconType:_.MoreHorizontalFilled,onClick:r}),isOpen:t,closePopover:i,panelPaddingSize:`none`,anchorPosition:`downLeft`,children:(0,c.jsx)(Qe,{playlist:e,closePopover:i})})}),et=(0,g.observer)(({playlist:e})=>{let{euiTheme:t}=(0,h.useEuiTheme)();return(0,c.jsxs)(h.EuiFlexGroup,{alignItems:`center`,gutterSize:`m`,responsive:!1,style:{position:`sticky`,top:48,zIndex:998,background:t.colors.backgroundBasePlain},children:[(0,c.jsxs)(h.EuiHideFor,{sizes:[`xs`],children:[(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiButton,{disabled:!e.canPlaySelectedItemsNext,onClick:e.playSelectedItemsNext,children:`Play next`})}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(Ze,{playlist:e})}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiButton,{iconType:_.DismissRegular,onClick:e.removeSelectedItems,disabled:!e.canRemoveSelectedItems,children:`Remove`})})]}),(0,c.jsx)(h.EuiShowFor,{sizes:[`xs`],children:(0,c.jsx)($e,{playlist:e})}),(0,c.jsx)(h.EuiFlexItem,{grow:!0}),(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(J,{onFulfilled:e.addItemFromDto})})]})}),tt=(0,g.observer)(({playlist:e})=>(0,c.jsxs)(c.Fragment,{children:[(0,c.jsx)(h.EuiTableHeaderMobile,{children:(0,c.jsx)(h.EuiFlexGroup,{responsive:!1,justifyContent:`spaceBetween`,alignItems:`baseline`,children:(0,c.jsx)(h.EuiFlexItem,{grow:!1,children:(0,c.jsx)(h.EuiCheckbox,{id:``,checked:e.allItemsSelected,onChange:t=>{t.target.checked?e.selectAll():e.unselectAll()}})})})}),(0,c.jsxs)(h.EuiTableHeader,{children:[(0,c.jsx)(h.EuiTableHeaderCellCheckbox,{children:(0,c.jsx)(h.EuiCheckbox,{id:``,checked:e.allItemsSelected,onChange:t=>{t.target.checked?e.selectAll():e.unselectAll()}})}),(0,c.jsx)(h.EuiTableHeaderCell,{width:24}),(0,c.jsx)(h.EuiTableHeaderCell,{children:`Title`}),(0,c.jsx)(h.EuiTableHeaderCell,{})]})]})),nt=(0,l.memo)(({item:e,closePopover:t})=>{let n=(0,l.useCallback)(({name:e,icon:n,disabled:r,onClick:i,className:a})=>({name:e,icon:n,disabled:r,onClick:async e=>{t(),i(e)},className:a}),[t]);return(0,c.jsx)(h.EuiContextMenu,{initialPanelId:0,panels:(0,l.useMemo)(()=>[{id:0,items:[n({name:`Play`,icon:(0,c.jsx)(h.EuiIcon,{type:_.PlayRegular}),onClick:e.play,className:`eui-showFor--xs--flex`}),n({name:`Play first`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.playFirst}),n({name:`Play next`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.playNext}),n({name:`Add to play queue`,icon:(0,c.jsx)(h.EuiIcon,{type:_.AddRegular}),onClick:e.addToPlayQueue}),{isSeparator:!0},n({name:`Move to the top`,icon:(0,c.jsx)(h.EuiIcon,{type:_.ArrowUploadRegular}),onClick:e.moveToTop,disabled:!e.canMoveToTop}),n({name:`Move to the bottom`,icon:(0,c.jsx)(h.EuiIcon,{type:_.ArrowDownloadRegular}),onClick:e.moveToBottom,disabled:!e.canMoveToBottom}),{isSeparator:!0},n({name:`Remove`,icon:(0,c.jsx)(h.EuiIcon,{type:_.DismissRegular}),onClick:e.remove,className:`eui-showFor--xs--flex`}),n({name:`Remove to the top`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.removeToTop,disabled:!e.canRemoveToTop}),n({name:`Remove others`,icon:(0,c.jsx)(h.EuiIcon,{type:``}),onClick:e.removeOthers,disabled:!e.canRemoveOthers})]}],[n,e])})}),rt=(0,l.memo)(({item:e})=>{let[t,n]=(0,l.useState)(!1),r=(0,l.useCallback)(()=>n(!t),[t]),i=(0,l.useCallback)(()=>n(!1),[]);return(0,c.jsx)(h.EuiPopover,{button:(0,c.jsx)(h.EuiButtonIcon,{title:`More options`,"aria-label":`More options`,iconType:_.MoreHorizontalFilled,size:`s`,color:`text`,onClick:r}),isOpen:t,closePopover:i,panelPaddingSize:`none`,anchorPosition:`leftCenter`,children:(0,c.jsx)(nt,{item:e,closePopover:i})})}),it=(0,g.observer)(({item:e})=>(0,c.jsxs)(h.EuiTableRowCell,{textOnly:!1,hasActions:!0,align:`right`,children:[(0,c.jsxs)(h.EuiHideFor,{sizes:[`xs`],children:[(0,c.jsx)(h.EuiButton,{iconType:_.PlayRegular,size:`s`,onClick:e.play,children:`Play`}),(0,c.jsx)(h.EuiButton,{iconType:_.DismissRegular,size:`s`,onClick:e.remove,children:`Remove`})]}),(0,c.jsx)(rt,{item:e})]})),at=(0,g.observer)(({item:e})=>(0,c.jsxs)(h.EuiTableRow,{isSelected:e.isCurrent,hasSelection:!0,hasActions:!0,children:[(0,c.jsx)(h.EuiTableRowCellCheckbox,{children:(0,c.jsx)(h.EuiCheckbox,{id:e.id.toString(),checked:e.isSelected,onChange:e.toggleSelected})}),(0,c.jsx)(h.EuiTableRowCell,{textOnly:!1,children:(0,c.jsx)(`img`,{src:x.get(e.type),width:16,height:16,alt:e.type})}),(0,c.jsx)(h.EuiTableRowCell,{mobileOptions:{header:!1,enlarge:!0,width:`100%`},children:(0,c.jsx)(h.EuiLink,{href:e.url,target:`_blank`,external:!0,children:e.title})}),(0,c.jsx)(it,{item:e})]})),ot=(0,g.observer)(({playlist:e})=>(0,c.jsx)(y.ReactSortable,{tag:`tbody`,list:e.items,setList:t=>e.setItems(t),children:e.items.map(e=>(0,c.jsx)(at,{item:e},e.id))})),st=(0,g.observer)(({playlist:e})=>(0,c.jsxs)(h.EuiTable,{children:[(0,c.jsx)(tt,{playlist:e}),(0,c.jsx)(ot,{playlist:e})]})),ct=(0,g.observer)(({playlist:e})=>{let{euiTheme:t}=(0,h.useEuiTheme)();return(0,c.jsxs)(h.EuiPageTemplate.Section,{children:[(0,c.jsx)(et,{playlist:e}),(0,c.jsx)(h.EuiSpacer,{size:`l`,style:{position:`sticky`,top:88,zIndex:998,background:t.colors.backgroundBasePlain}}),e.isEmpty?(0,c.jsx)(c.Fragment,{}):(0,c.jsx)(st,{playlist:e})]})}),lt=v.default.create(({remove:e,resolve:t,playlistListItem:n})=>{let r=(0,h.useGeneratedHtmlId)({prefix:`modalForm`}),[i,a]=(0,l.useState)(n.name),[o,s]=(0,l.useState)(!1);return(0,c.jsxs)(h.EuiModal,{onClose:e,initialFocus:`[name=name]`,children:[(0,c.jsx)(h.EuiModalHeader,{children:(0,c.jsx)(h.EuiModalHeaderTitle,{children:`Rename playlist`})}),(0,c.jsx)(h.EuiModalBody,{children:(0,c.jsx)(h.EuiForm,{id:r,component:`form`,onSubmit:async n=>{n.preventDefault();try{s(!0),t(i),e()}finally{s(!1)}},children:(0,c.jsx)(h.EuiFormRow,{label:`Name`,children:(0,c.jsx)(h.EuiFieldText,{name:`name`,value:i,onChange:e=>a(e.target.value)})})})}),(0,c.jsxs)(h.EuiModalFooter,{children:[(0,c.jsx)(h.EuiButtonEmpty,{onClick:e,children:`Cancel`}),(0,c.jsx)(h.EuiButton,{type:`submit`,form:r,fill:!0,disabled:i.trim().length===0,isLoading:o,children:`Rename`})]})]})}),Z=class e{playQueue;playlist;dto;static nextId=1;id;isSelected=!1;constructor(t,n,r){this.playQueue=t,this.playlist=n,this.dto=r,(0,d.makeObservable)(this),this.id=e.nextId++}static fromDto(t,n,r){return new e(t,n,r)}get url(){return this.dto.url}get type(){return this.dto.type}get videoId(){return this.dto.videoId}get title(){return this.dto.title}get isCurrent(){return!1}get index(){return this.playlist.items.indexOf(this)}get isFirst(){return this.index===0}get isLast(){return this.index===this.playlist.items.length-1}get canMoveToTop(){return!this.isFirst}get canMoveToBottom(){return!this.isLast}get canRemoveToTop(){return!this.isFirst}get canRemoveOthers(){return this.playlist.hasMultipleItems}unselect(){this.isSelected=!1}select(){this.isSelected=!0}toggleSelected(){this.isSelected=!this.isSelected}play(){return this.playQueue.clearAndSetItems([this.playQueue.createItemFromDto(this.dto)]),Promise.resolve()}remove(){return this.playlist.removeItems([this])}playFirst(){return this.playQueue.playFirst([this.playQueue.createItemFromDto(this.dto)])}playNext(){return this.playQueue.playNext([this.playQueue.createItemFromDto(this.dto)])}addToPlayQueue(){return this.playQueue.addItems([this.playQueue.createItemFromDto(this.dto)])}moveToTop(){this.playlist.moveItem(this,0)}moveToBottom(){this.playlist.moveItem(this,this.playlist.items.length-1)}removeToTop(){return this.playlist.removeItemsAbove(this)}removeOthers(){return this.playlist.removeOtherItems(this)}};O([d.observable],Z.prototype,`isSelected`,void 0),O([d.computed],Z.prototype,`isCurrent`,null),O([d.computed],Z.prototype,`index`,null),O([d.computed],Z.prototype,`isFirst`,null),O([d.computed],Z.prototype,`isLast`,null),O([d.computed],Z.prototype,`canMoveToTop`,null),O([d.computed],Z.prototype,`canMoveToBottom`,null),O([d.computed],Z.prototype,`canRemoveToTop`,null),O([d.computed],Z.prototype,`canRemoveOthers`,null),O([d.action.bound],Z.prototype,`unselect`,null),O([d.action.bound],Z.prototype,`select`,null),O([d.action.bound],Z.prototype,`toggleSelected`,null),O([d.action.bound],Z.prototype,`play`,null),O([d.action.bound],Z.prototype,`remove`,null),O([d.action.bound],Z.prototype,`playFirst`,null),O([d.action.bound],Z.prototype,`playNext`,null),O([d.action.bound],Z.prototype,`addToPlayQueue`,null),O([d.action.bound],Z.prototype,`moveToTop`,null),O([d.action.bound],Z.prototype,`moveToBottom`,null),O([d.action.bound],Z.prototype,`removeToTop`,null),O([d.action.bound],Z.prototype,`removeOthers`,null);var ut={type:`object`,properties:{version:{type:`string`,nullable:!0},items:{type:`array`,nullable:!0,items:I}}},Q=class{playlist;constructor(e){this.playlist=e,(0,d.makeObservable)(this)}get state(){return{version:`1.0`,items:this.playlist.items.map(e=>e.dto)}}set state(e){this.playlist.items=e.items?.map(e=>this.playlist.createItemFromDto(e))??[]}validateState(e){return E(ut,`PlaylistLocalStorageState`)(e)}};O([d.computed.struct],Q.prototype,`state`,null);var $=class{playQueue;localStorageState;items=[];constructor(e){this.playQueue=e,(0,d.makeObservable)(this),this.localStorageState=new Q(this)}createItemFromDto(e){return Z.fromDto(this.playQueue,this,{url:e.url,type:e.type,videoId:e.videoId,title:e.title})}get isEmpty(){return this.items.length===0}get hasMultipleItems(){return this.items.length>1}get selectedItems(){return this.items.filter(e=>e.isSelected)}get allItemsSelected(){return this.selectedItems.length===this.items.length}get hasSelectedItems(){return this.selectedItems.length>0}get selectedItemsOrAllItems(){return this.hasSelectedItems?this.selectedItems:this.items}get canAddSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}get canPlaySelectedItemsNext(){return!this.isEmpty&&this.hasSelectedItems}get canRemoveSelectedItems(){return!this.isEmpty&&this.hasSelectedItems}setItems(e){this.items=e}unselectAll(){for(let e of this.items)e.unselect()}selectAll(){for(let e of this.items)e.select()}async playSelectedItemsNext(){await this.playQueue.playNext(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addSelectedItems(){await this.playQueue.addItems(this.selectedItemsOrAllItems.map(e=>this.playQueue.createItemFromDto(e.dto))),this.unselectAll()}async addItems(e){this.items.push(...e)}moveItem(e,t){let n=this.items.splice(this.items.indexOf(e),1)[0];this.items.splice(t,0,n)}async removeItems(e){(0,p.pull)(this.items,...e)}async removeSelectedItems(){await this.removeItems(this.selectedItemsOrAllItems),this.unselectAll()}async removeOtherItems(e){let t=e