import { Theme } from '../types/webcomponent-config' ; import { OvSettings } from '../types/ov-settings' ; import { OvSettingsModel } from './ovSettings' ; export class ExternalConfigModel { protected ovSettings : OvSettingsModel ; protected sessionName : string ; protected ovServerUrl : string ; protected ovSecret : string ; protected theme = Theme . DARK ; protected nickname : string ; protected tokens : string [ ] ; constructor ( ) { this . ovSettings = new OvSettingsModel ( ) ; } public getComponentName ( ) { } public getOvSettings ( ) { return this . ovSettings ; } public getSessionName ( ) { return this . sessionName ; } public getOvServerUrl ( ) { return this . ovServerUrl ; } public getOvSecret ( ) { return this . ovSecret ; } public getTheme ( ) { return this . theme ; } public getNickname ( ) { return this . nickname ; } public getTokens ( ) { return this . tokens ; } public getScreenToken ( ) { return this . tokens [ 1 ] ; } public getWebcamToken ( ) { return this . tokens [ 0 ] ; } public setOvSettings ( ovSettings ) { if ( ! ! ovSettings ) { this . ovSettings . set ( ovSettings ) ; } } public setSessionName ( sessionName ) { this . sessionName = sessionName ; } public setOvServerUrl ( url ) { this . ovServerUrl = url ; } public setOvSecret ( secret ) { this . ovSecret = secret ; } public setTheme ( theme ) { if ( ( < any > Object ) . values ( Theme ) . includes ( theme ) ) { this . theme = theme === Theme . DARK ? Theme . DARK : Theme . LIGHT ; } } public setNickname ( nickname ) { this . nickname = nickname ; } public setTokens ( tokens ) { this . tokens = tokens ; } public canJoinToSession ( ) { return this . canOVCallGenerateToken ( ) || this . hasReceivedToken ( ) ; } public hasTokens ( ) { return this . tokens ?. length > 0 ; } private canOVCallGenerateToken ( ) { return ! ! this . sessionName && ! ! this . ovServerUrl && ! ! this . ovSecret && ! ! this . nickname ; } private hasReceivedToken ( ) { return ! ! this . tokens && this . tokens . length > 0 && ! ! this . nickname ; } }