import { AfterContentInit , ChangeDetectionStrategy , ChangeDetectorRef , Component , ElementRef , HostBinding , Input , Renderer2 , ViewRef , } from '@angular/core' ; import { BgsPlayer } from '../../../models/battlegrounds/bgs-player' ; import { AppUiStoreFacadeService } from '../../../services/ui-store/app-ui-store-facade.service' ; import { AbstractSubscriptionComponent } from '../../abstract-subscription.component' ; @ Component ( { selector : 'bgs-overlay-hero-overview' , styleUrls : [ `../../../../css/global/components-global.scss` , `../../../../css/global/reset-styles.scss` , '../../../../css/themes/battlegrounds-theme.scss' , '../../../../css/component/battlegrounds/overlay/bgs-overlay-hero-overview.component.scss' , ] , template : `
		<div class="battlegrounds-theme bgs-hero-overview-tooltip scalable">
			<bgs-opponent-overview-big
				[opponent]="_opponent"
				[enableSimulation]="false"
				[maxBoardHeight]="-1"
				[currentTurn]="currentTurn"
				tavernTitle="Latest upgrade"
				[showTavernsIfEmpty]="false"
				[showLastOpponentIcon]="isLastOpponent"
			></bgs-opponent-overview-big>
		</div>
	` , changeDetection : ChangeDetectionStrategy . OnPush , } ) export class BgsOverlayHeroOverviewComponent extends AbstractSubscriptionComponent implements AfterContentInit { @ Input ( ) set config ( value ) { this . _opponent = value . player ; this . currentTurn = value . currentTurn ; this . isLastOpponent = value . isLastOpponent ; this . componentClass = value . additionalClasses ; if ( ! ( this . cdr as ViewRef ) ?. destroyed ) { this . cdr . detectChanges ( ) ; } } @ HostBinding ( 'class' ) get hostClasses ( ) { return `${ this . componentClass }` ; } componentClass : string ; _opponent : BgsPlayer ; currentTurn : number ; isLastOpponent : boolean ; constructor ( private readonly el , private readonly renderer , protected readonly store , protected readonly cdr ) { super ( store , cdr ) ; this . store . listenPrefs$ ( ( prefs ) => prefs . bgsOpponentBoardScale ) . pipe ( this . mapData ( ( [ pref ] ) => pref ) ) . subscribe ( ( scale ) => { try { const newScale = scale / 100 ; const element = this . el . nativeElement . querySelector ( '.scalable' ) ; this . renderer . setStyle ( element , 'transform' , `scale(${ newScale })` ) ; } catch ( e ) { console . debug ( 'error' , e ) ; } } ) ; } async ngAfterContentInit ( ) { console . debug ( 'after content init' ) ; } }