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