import vivliostyle from "./vivliostyle" ; export class PageViewModeInstance { toSpreadViewString ( ) { switch ( this ) { case PageViewMode . SPREAD : return "true" ; case PageViewMode . SINGLE_PAGE : return "false" ; case PageViewMode . AUTO_SPREAD : return "auto" ; default : throw new Error ( "Invalid PageViewMode" ) ; } } toString ( ) { switch ( this ) { case PageViewMode . SPREAD : return "spread" ; case PageViewMode . SINGLE_PAGE : return "singlePage" ; case PageViewMode . AUTO_SPREAD : return "autoSpread" ; default : throw new Error ( "Invalid PageViewMode" ) ; } } } const PageViewMode = { AUTO_SPREAD : new PageViewModeInstance ( ) , SINGLE_PAGE : new PageViewModeInstance ( ) , SPREAD : new PageViewModeInstance ( ) , defaultMode ( ) { return this . AUTO_SPREAD ; } , fromSpreadViewString ( str ) { switch ( str ) { case "true" : return this . SPREAD ; case "false" : return this . SINGLE_PAGE ; case "auto" : default : return this . AUTO_SPREAD ; } } , of ( name ) { switch ( name ) { case vivliostyle . viewer . PageViewMode . SPREAD : return this . SPREAD ; case vivliostyle . viewer . PageViewMode . SINGLE_PAGE : return this . SINGLE_PAGE ; case vivliostyle . viewer . PageViewMode . AUTO_SPREAD : return this . AUTO_SPREAD ; default : throw new Error ( `Invalid PageViewMode name: ${ name }` ) ; } } } ; export default PageViewMode ;