UNPKG

@dicdikshaorg/epub-player-v9

Version:

Contains Epub player library components powered by angular. These components are designed to be used in sunbird consumption platforms *(mobile app, web portal, offline desktop app)* to drive reusability, maintainability hence reducing the redundant develo

1,229 lines 55.1 kB
import * as i0 from '@angular/core';
import { Injectable, EventEmitter, Component, Renderer2, ViewChild, Input, Output, HostListener, NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { __awaiter } from 'tslib';
import { CsTelemetryModule } from '@project-sunbird/client-services/telemetry';
import * as i3 from '@angular/common/http';
import { HttpClient, HttpHeaders, HttpClientModule } from '@angular/common/http';
import { errorCode, errorMessage, ErrorService } from '@project-sunbird/sunbird-player-sdk-v9';
import { Subject } from 'rxjs';
import { takeUntil } from 'rxjs/operators';
import * as _ from 'lodash';
import Epub from 'epubjs';
import { SunbirdPlayerSdkModule } from '@dicdikshaorg/player-sdk-v9';
import { CommonModule } from '@angular/common';

var epubPlayerConstants;
(function (epubPlayerConstants) {
    epubPlayerConstants["LOADING"] = "LOADING";
    epubPlayerConstants["START"] = "START";
    epubPlayerConstants["END"] = "END";
    epubPlayerConstants["EPUBLOADED"] = "epubLoaded";
    epubPlayerConstants["PAGECHANGE"] = "pageChange";
    epubPlayerConstants["NEXT"] = "NEXT";
    epubPlayerConstants["PREVIOUS"] = "PREVIOUS";
    epubPlayerConstants["ERROR"] = "error";
    epubPlayerConstants["UNABLE_TO_FETCH_URL_ONLINE"] = "Internet is avialable but unable to fetch the url";
    epubPlayerConstants["NAVIGATE_TO_PAGE"] = "NAVIGATE_TO_PAGE";
    epubPlayerConstants["INVALID_PAGE_ERROR"] = "INVALID_PAGE_ERROR";
})(epubPlayerConstants || (epubPlayerConstants = {}));
var telemetryType;
(function (telemetryType) {
    telemetryType["INTERACT"] = "INTERACT";
    telemetryType["IMPRESSION"] = "IMPRESSION";
})(telemetryType || (telemetryType = {}));
var pageId;
(function (pageId) {
    pageId["startPage"] = "START_PAGE";
    pageId["submitPage"] = "SUBMIT_PAGE";
    pageId["endPage"] = "END_PAGE";
    pageId["shortAnswer"] = "SHORT_ANSWER";
})(pageId || (pageId = {}));
var eventName;
(function (eventName) {
    eventName["pageScrolled"] = "PAGE_SCROLLED";
    eventName["viewHint"] = "VIEW_HINT";
    eventName["showAnswer"] = "SHOW_ANSWER_CLICKED";
    eventName["nextClicked"] = "NEXT_CLICKED";
    eventName["prevClicked"] = "PREV_CLICKED";
    eventName["progressBar"] = "PROGRESSBAR_CLICKED";
    eventName["replayClicked"] = "REPLAY_CLICKED";
    eventName["startPageLoaded"] = "START_PAGE_LOADED";
    eventName["viewSolutionClicked"] = "VIEW_SOLUTION_CLICKED";
    eventName["solutionClosed"] = "SOLUTION_CLOSED";
    eventName["closedFeedBack"] = "CLOSED_FEEDBACK";
    eventName["tryAgain"] = "TRY_AGAIN";
    eventName["optionClicked"] = "OPTION_CLICKED";
    eventName["scoreBoardSubmitClicked"] = "SCORE_BOARD_SUBMIT_CLICKED";
    eventName["endPageExitClicked"] = "EXIT";
    eventName["zoomClicked"] = "ZOOM_CLICKED";
    eventName["zoomInClicked"] = "ZOOM_IN_CLICKED";
    eventName["zoomOutClicked"] = "ZOOM_OUT_CLICKED";
    eventName["zoomCloseClicked"] = "ZOOM_CLOSE_CLICKED";
    eventName["goToQuestion"] = "GO_TO_QUESTION";
    eventName["nextContentPlay"] = "NEXT_CONTENT_PLAY";
})(eventName || (eventName = {}));

class UtilService {
    constructor() {
        this.fromConst = epubPlayerConstants;
    }
    uniqueId(length = 32) {
        let result = '';
        const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
        const charactersLength = characters.length;
        for (let i = 0; i < length; i++) {
            result += characters.charAt(Math.floor(Math.random() * charactersLength));
        }
        return result;
    }
    getTimeSpentText(pdfPlayerStartTime) {
        const duration = new Date().getTime() - pdfPlayerStartTime;
        const minutes = Math.floor(duration / 60000);
        const seconds = Number(((duration % 60000) / 1000).toFixed(0));
        return (minutes + ':' + (seconds < 10 ? '0' : '') + seconds);
    }
    getCurrentIndex(event, currentPageIndex) {
        if ((event === null || event === void 0 ? void 0 : event.interaction) === this.fromConst.NEXT) {
            return currentPageIndex + 1;
        }
        if ((event === null || event === void 0 ? void 0 : event.interaction) === this.fromConst.PREVIOUS) {
            return currentPageIndex - 1 === 0 ? 1 : currentPageIndex - 1;
        }
    }
    fulfillWithTimeLimit(timeLimit, task, failureValue) {
        return __awaiter(this, void 0, void 0, function* () {
            let timeout;
            const timeoutPromise = new Promise((resolve, reject) => {
                timeout = setTimeout(() => {
                    resolve(failureValue);
                }, timeLimit);
            });
            const response = yield Promise.race([task, timeoutPromise]);
            if (timeout) {
                clearTimeout(timeout);
            }
            return response;
        });
    }
}
/** @nocollapse */ UtilService.ɵprov = i0.ɵɵdefineInjectable({ factory: function UtilService_Factory() { return new UtilService(); }, token: UtilService, providedIn: "root" });
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
UtilService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
UtilService.ctorParameters = () => [];

class EpubPlayerService {
    constructor(utilService) {
        this.utilService = utilService;
        this.contentSessionId = this.utilService.uniqueId();
    }
    initialize({ context, config, metadata }) {
        this.context = context;
        this.config = config;
        this.playSessionId = this.utilService.uniqueId();
        this.channel = this.context.channel;
        this.pdata = this.context.pdata;
        this.sid = this.context.sid;
        this.uid = this.context.uid;
        this.rollup = this.context.rollup;
        if (!CsTelemetryModule.instance.isInitialised) {
            CsTelemetryModule.instance.init({});
            const telemetryConfig = {
                config: {
                    pdata: context.pdata,
                    env: 'contentplayer',
                    channel: context.channel,
                    did: context.did,
                    authtoken: context.authToken || '',
                    uid: context.uid || '',
                    sid: context.sid,
                    batchsize: 20,
                    mode: context.mode,
                    host: context.host || '',
                    endpoint: context.endpoint || '/data/v3/telemetry',
                    tags: context.tags,
                    cdata: [{ id: this.contentSessionId, type: 'ContentSession' },
                        { id: this.playSessionId, type: 'PlaySession' },
                        { id: '2.0', type: 'PlayerVersion' }],
                },
                userOrgDetails: {}
            };
            if (context.dispatcher) {
                telemetryConfig.config.dispatcher = context.dispatcher;
            }
            CsTelemetryModule.instance.telemetryService.initTelemetry(telemetryConfig);
        }
        this.telemetryObject = {
            id: metadata.identifier,
            type: 'Content',
            ver: metadata.pkgVersion + '' || '1.0',
            rollup: context.objectRollup || {}
        };
    }
    start(duration) {
        CsTelemetryModule.instance.telemetryService.raiseStartTelemetry({
            options: this.getEventOptions(),
            edata: { type: 'content', mode: 'play', pageid: '', duration: Number((duration / 1e3).toFixed(2)) }
        });
    }
    interact(id, currentPage) {
        CsTelemetryModule.instance.telemetryService.raiseInteractTelemetry({
            options: this.getEventOptions(),
            edata: { type: 'TOUCH', subtype: '', id, pageid: currentPage + '' }
        });
    }
    impression(currentPage) {
        CsTelemetryModule.instance.telemetryService.raiseImpressionTelemetry({
            options: this.getEventOptions(),
            edata: { type: 'workflow', subtype: '', pageid: currentPage + '', uri: '' }
        });
    }
    end(duration, percentage, curentPage, endpageseen) {
        const durationSec = Number((duration / 1e3).toFixed(2));
        CsTelemetryModule.instance.telemetryService.raiseEndTelemetry({
            edata: {
                type: 'content',
                mode: 'play',
                pageid: 'sunbird-player-Endpage',
                summary: [
                    {
                        progress: percentage
                    },
                    {
                        totallength: (percentage === 100 ? curentPage : 1)
                    },
                    {
                        visitedlength: curentPage
                    },
                    {
                        visitedcontentend: (percentage === 100)
                    },
                    {
                        totalseekedlength: 0
                    },
                    {
                        endpageseen
                    }
                ],
                duration: durationSec
            },
            options: this.getEventOptions()
        });
    }
    error(errorCode, errorType, pageid, stacktrace) {
        CsTelemetryModule.instance.telemetryService.raiseErrorTelemetry({
            options: this.getEventOptions(),
            edata: {
                err: errorCode,
                errtype: errorType,
                stacktrace: stacktrace.toString(),
                pageid: pageid || ''
            }
        });
    }
    getEventOptions() {
        return ({
            object: this.telemetryObject,
            context: {
                channel: this.channel,
                pdata: this.pdata,
                env: 'contentplayer',
                sid: this.sid,
                uid: this.uid,
                cdata: [{ id: this.contentSessionId, type: 'ContentSession' },
                    { id: this.playSessionId, type: 'PlaySession' },
                    { id: '2.0', type: 'PlayerVersion' }],
                rollup: this.rollup || {}
            }
        });
    }
}
/** @nocollapse */ EpubPlayerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function EpubPlayerService_Factory() { return new EpubPlayerService(i0.ɵɵinject(UtilService)); }, token: EpubPlayerService, providedIn: "root" });
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
EpubPlayerService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
EpubPlayerService.ctorParameters = () => [
    { type: UtilService }
];

class ViwerService {
    constructor(utilService, epubPlayerService, http) {
        this.utilService = utilService;
        this.epubPlayerService = epubPlayerService;
        this.http = http;
        this.currentIndex = 0;
        this.totalNumberOfPages = 0;
        this.endPageSeen = false;
        this.timeSpent = '0:0';
        this.version = '1.0';
        this.playerEvent = new EventEmitter();
        this.isAvailableLocally = false;
        this.isEndEventRaised = false;
    }
    initialize({ context, config, metadata }) {
        this.epubPlayerStartTime = this.epubLastPageTime = new Date().getTime();
        this.totalNumberOfPages = 0;
        this.currentIndex = 0;
        this.contentName = metadata.name;
        this.identifier = metadata.identifier;
        this.artifactUrl = metadata.artifactUrl;
        this.isAvailableLocally = metadata.isAvailableLocally;
        if (this.isAvailableLocally) {
            const basePath = (metadata.streamingUrl) ? (metadata.streamingUrl) : (metadata.basePath || metadata.baseDir);
            this.src = `${basePath}/${metadata.artifactUrl}`;
        }
        else {
            this.src = metadata.streamingUrl || metadata.artifactUrl;
        }
        if (context.userData) {
            const { userData: { firstName, lastName } } = context;
            this.userName = firstName === lastName ? firstName : `${firstName} ${lastName}`;
        }
        this.metaData = {
            pagesVisited: [],
            totalPages: 0,
            duration: [],
            zoom: [],
            rotation: []
        };
        this.showDownloadPopup = false;
        this.endPageSeen = false;
    }
    raiseStartEvent(event) {
        this.currentIndex = event.items[0].index;
        const duration = new Date().getTime() - this.epubPlayerStartTime;
        const startEvent = {
            eid: 'START',
            ver: this.version,
            edata: {
                type: 'START',
                currentPage: this.currentIndex,
                duration
            },
            metaData: this.metaData
        };
        this.playerEvent.emit(startEvent);
        this.epubLastPageTime = this.epubPlayerStartTime = new Date().getTime();
        this.epubPlayerService.start(duration);
    }
    raiseHeartBeatEvent(event, teleType) {
        if (event.data) {
            this.currentIndex = event.data.index;
        }
        const eventType = event.type ? event.type : event;
        const heartBeatEvent = {
            eid: 'HEARTBEAT',
            ver: this.version,
            edata: {
                type: eventType,
                currentPage: this.currentIndex
            },
            metaData: this.metaData
        };
        this.playerEvent.emit(heartBeatEvent);
        if (telemetryType.IMPRESSION === teleType) {
            this.epubPlayerService.impression(this.currentIndex);
        }
        if (telemetryType.INTERACT === teleType) {
            this.epubPlayerService.interact(eventType.toLowerCase(), this.currentIndex);
        }
    }
    raiseEndEvent(event) {
        if (!this.isEndEventRaised) {
            this.currentIndex = event.data.index;
            const percentage = event.data.percentage || 0;
            if (event.data.percentage) {
                this.endPageSeen = true;
            }
            const duration = new Date().getTime() - this.epubPlayerStartTime;
            this.metaData.duration = duration;
            this.metaData.totalPages = this.totalNumberOfPages;
            const endEvent = {
                eid: 'END',
                ver: this.version,
                edata: {
                    type: 'END',
                    currentPage: event.data.index,
                    totalPages: this.totalNumberOfPages,
                    duration
                },
                metaData: this.metaData
            };
            this.playerEvent.emit(endEvent);
            const visitedlength = this.currentIndex;
            this.timeSpent = this.utilService.getTimeSpentText(this.epubPlayerStartTime);
            this.epubPlayerService.end(duration, percentage, this.currentIndex, this.endPageSeen);
        }
    }
    raiseExceptionLog(errorCode, pageIndex, errorType, traceId, stacktrace) {
        const exceptionLogEvent = {
            eid: 'ERROR',
            edata: {
                err: errorCode,
                errtype: errorType,
                requestid: traceId || '',
                stacktrace
            }
        };
        this.playerEvent.emit(exceptionLogEvent);
        this.epubPlayerService.error(errorCode, errorType, pageIndex, stacktrace);
    }
    isValidEpubSrc(src) {
        return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {
            this.http.get(src, { responseType: 'blob' }).toPromise().then((res) => {
                resolve(res);
            }).catch((error) => {
                reject(error);
            });
        }));
    }
    raiseHeartBeatEventNew(type, telemetryType1, pageId, nextContentId) {
        const hearBeatEvent = {
            eid: 'HEARTBEAT',
            ver: this.version,
            edata: {
                type,
                currentPage: this.currentIndex
            },
            metaData: this.metaData
        };
        if (type === eventName.nextContentPlay && nextContentId) {
            hearBeatEvent.edata.nextContentId = nextContentId;
        }
        // if (this.isSectionsAvailable) {
        //   hearBeatEvent.edata.sectionId = this.questionSetId;
        // }
        this.playerEvent.emit(hearBeatEvent);
        if (telemetryType.INTERACT === telemetryType1) {
            this.epubPlayerService.interact(type.toLowerCase(), pageId);
        }
        else if (telemetryType.IMPRESSION === telemetryType1) {
            this.epubPlayerService.impression(pageId);
        }
    }
}
/** @nocollapse */ ViwerService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ViwerService_Factory() { return new ViwerService(i0.ɵɵinject(UtilService), i0.ɵɵinject(EpubPlayerService), i0.ɵɵinject(i3.HttpClient)); }, token: ViwerService, providedIn: "root" });
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
ViwerService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
ViwerService.ctorParameters = () => [
    { type: UtilService },
    { type: EpubPlayerService },
    { type: HttpClient }
];

class ToastrService {
    constructor() {
        this.toastSubject = new Subject();
        this.toastState$ = this.toastSubject.asObservable();
    }
    show(message = '', type = '') {
        console.log(message, "this is message");
        console.log(type, "this is type");
        this.toastSubject.next({ message, type });
    }
}
/** @nocollapse */ ToastrService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ToastrService_Factory() { return new ToastrService(); }, token: ToastrService, providedIn: "root" });
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
ToastrService.decorators = [
    { type: Injectable, args: [{
                providedIn: 'root'
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
ToastrService.ctorParameters = () => [];

class EpubPlayerComponent {
    constructor(viwerService, epubPlayerService, errorService, utilService, renderer2, http, toastrService) {
        this.viwerService = viwerService;
        this.epubPlayerService = epubPlayerService;
        this.errorService = errorService;
        this.utilService = utilService;
        this.renderer2 = renderer2;
        this.http = http;
        this.toastrService = toastrService;
        this.fromConst = epubPlayerConstants;
        this.showFullScreen = false;
        this.headerActionsEvent = new EventEmitter();
        this.telemetryEvent = new EventEmitter();
        this.showControls = true;
        this.validPage = true;
        this.sideMenuConfig = {
            showShare: false,
            showDownload: false,
            showReplay: false,
            showExit: false,
            showPrint: false
        };
        this.urlTTS = 'https://dhruva-api.bhashini.gov.in/services/inference/pipeline';
        this.urlDetectLang = 'https://dhruva-api.bhashini.gov.in/services/inference/txtlangdetection';
        this.audio = '';
        this.audioQueue = [];
        this.playerState = { isPlaying: false };
        this.counter = 0;
        this.loading = false;
        this.chunks = [];
        this.isStreamIntrupted = false;
        this.cancelRequests$ = new Subject();
        this.languageList = [
            { languageCode: 'en', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'hi', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'as', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'bn', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'gu', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'kn', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'mr', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'or', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'pa', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'ta', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'te', modelId: 'Bhashini/IITM/TTS' },
            { languageCode: 'ur', modelId: 'Bhashini/IITM/TTS' }
        ];
        this.isInitialized = false;
        this.viewState = this.fromConst.LOADING;
        this.progress = 0;
        this.currentPageIndex = 1;
        this.headerConfiguration = {
            rotation: false,
            goto: true,
            navigation: true,
            zoom: false
        };
        this.playbackRate = 1.0;
        this.langCode = '';
        this.playerEvent = this.viwerService.playerEvent;
    }
    onTelemetryEvent(event) {
        this.telemetryEvent.emit(event.detail);
    }
    ngOnInit() {
        var _a, _b, _c, _d;
        return __awaiter(this, void 0, void 0, function* () {
            this.mimeType = _.get(this.playerConfig, 'metadata.mimeType');
            this.isInitialized = true;
            if (this.playerConfig) {
                if (typeof this.playerConfig === 'string') {
                    try {
                        this.playerConfig = JSON.parse(this.playerConfig);
                    }
                    catch (error) {
                        console.error('Invalid playerConfig: ', error);
                    }
                }
            }
            // initializing services
            this.viwerService.initialize(this.playerConfig);
            this.epubPlayerService.initialize(this.playerConfig);
            this.traceId = (_b = (_a = this.playerConfig) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.traceId;
            // checks online error while loading epub
            if (!navigator.onLine && !this.viwerService.isAvailableLocally) {
                // tslint:disable-next-line:max-line-length
                this.viwerService.raiseExceptionLog(errorCode.internetConnectivity, this.currentPageIndex, errorMessage.internetConnectivity, this.traceId, new Error(errorMessage.internetConnectivity));
            }
            // checks content compatibility error
            const contentCompabilityLevel = (_d = (_c = this.playerConfig) === null || _c === void 0 ? void 0 : _c.metadata) === null || _d === void 0 ? void 0 : _d.compatibilityLevel;
            if (contentCompabilityLevel) {
                const checkContentCompatible = this.errorService.checkContentCompatibility(contentCompabilityLevel);
                if (!(checkContentCompatible === null || checkContentCompatible === void 0 ? void 0 : checkContentCompatible.isCompitable)) {
                    // tslint:disable-next-line:max-line-length
                    this.viwerService.raiseExceptionLog(errorCode.contentCompatibility, this.currentPageIndex, errorCode.contentCompatibility, this.traceId, checkContentCompatible.error);
                }
            }
            this.showEpubViewer = true;
            this.sideMenuConfig = Object.assign(Object.assign({}, this.sideMenuConfig), this.playerConfig.config.sideMenu);
            this.getEpubLoadingProgress();
            this.nextContent = this.playerConfig.config.nextContent;
        });
    }
    ngOnChanges(changes) {
        var _a;
        if (changes.showFullScreen && !((_a = changes === null || changes === void 0 ? void 0 : changes.showFullScreen) === null || _a === void 0 ? void 0 : _a.firstChange)) {
            this.showFullScreen = changes.showFullScreen.currentValue;
        }
        if (changes.playerConfig.firstChange && this.isInitialized) {
            // Calling for web component explicitly and life cycle works in different order
            this.ngOnInit();
        }
    }
    ngAfterViewInit() {
        const epubPlayerElement = this.epubPlayerRef.nativeElement;
        this.unlistenMouseEnter = this.renderer2.listen(epubPlayerElement, 'mouseenter', () => {
            this.showControls = true;
        });
        this.unlistenMouseLeave = this.renderer2.listen(epubPlayerElement, 'mouseleave', () => {
            this.showControls = false;
        });
    }
    headerActions(eventdata) {
        this.headerActionsEvent.emit(eventdata);
    }
    onPlaybackRateChange(event) {
        this.playbackRate = parseFloat(event.target.value);
        if (this.audio) {
            this.audio.playbackRate = this.playbackRate;
        }
    }
    handleNotification() {
        this.handleButtonstop();
    }
    handleButtonplay() {
        this.audio.play();
    }
    handleButtonpause() {
        this.audio.pause();
    }
    handleButtonstop() {
        if (this.audio && typeof this.audio.pause === 'function') {
            this.audio.pause();
            this.audio.src = '';
            this.isStreamIntrupted = true;
            this.counter = 0;
            this.playerState.isPlaying = false;
        }
        this.cancelRequests();
        this.audioQueue = [];
    }
    getModelId(languageCode) {
        if (languageCode == 'unknown') {
            this.toastrService.show('Sorry, we are currently unable to provide Audio for this document.', 'error');
        }
        const language = this.languageList.find(lang => lang.languageCode === languageCode);
        return language ? language.modelId : null;
    }
    detectLanguage(chunk) {
        return __awaiter(this, void 0, void 0, function* () {
            return new Promise((resolve, reject) => {
                const headers = new HttpHeaders({
                    Authorization: 'Rl1KVAwFU5lUDH2fLfJ_4EJrroYZUGhG06oJbWemJOC3pFw9XA0tVpqKhroKQirW',
                });
                const payload = {
                    config: {
                        serviceId: "bhashini/iiiith/indic-lang-detection-all"
                    },
                    input: [
                        {
                            source: chunk
                        }
                    ]
                };
                this.http.post(this.urlDetectLang, payload, { headers }).subscribe((res) => {
                    this.langCode = res.output[0].langPrediction[0].langCode;
                    const modelId = this.getModelId(this.langCode);
                    resolve(modelId);
                }, error => {
                    console.error('Error detecting language:', error);
                    this.toastrService.show('Something Went Wrong', 'error');
                    resolve(null); // Resolve with null if there's an error
                });
            });
        });
    }
    handleButtonClick(gender) {
        return __awaiter(this, void 0, void 0, function* () {
            this.toastrService.show('Please wait , Audio Processing...', 'info');
            this.isStreamIntrupted = false;
            this.audioQueue = [];
            let epubjsId = document.querySelector('[id^="epubjs-view-"]').id;
            if (epubjsId) {
                let epubHTML = document.getElementById(epubjsId).getAttribute("srcdoc");
                const parser = new DOMParser();
                const htmlDoc = parser.parseFromString(epubHTML, "text/html");
                let hTags = htmlDoc.querySelector("body");
                if (hTags) {
                    let speechText = this.extractTextFromElement(hTags);
                    this.chunks = this.chunkText(speechText, 250);
                    if (!this.chunks || this.chunks.length === 0) {
                        this.toastrService.show('Text is unavailable in current Page', 'error');
                    }
                    // Detect language with the first chunk
                    const serviceId = yield this.detectLanguage(this.chunks[0]);
                    for (let i = 0; i < this.chunks.length; i++) {
                        if (!this.isStreamIntrupted) {
                            yield this.processChunk(this.chunks[i], gender, serviceId);
                        }
                        else {
                            this.chunks = [];
                            break;
                        }
                    }
                }
            }
            else {
                console.log("No epubjsId found");
            }
        });
    }
    extractTextFromElement(element) {
        if (!element)
            return "";
        let text = "";
        element.childNodes.forEach(node => {
            if (node.nodeType === Node.TEXT_NODE) {
                text += node.textContent.trim() + " ";
            }
            else if (node.nodeType === Node.ELEMENT_NODE) {
                text += this.extractTextFromElement(node);
            }
        });
        return text.trim();
    }
    processChunk(chunk, gender, serviceId) {
        return __awaiter(this, void 0, void 0, function* () {
            if (!serviceId) {
                console.error('Model ID not found.');
                return;
            }
            const headers = new HttpHeaders({
                Authorization: 'Rl1KVAwFU5lUDH2fLfJ_4EJrroYZUGhG06oJbWemJOC3pFw9XA0tVpqKhroKQirW',
            });
            const payload = {
                pipelineTasks: [
                    {
                        taskType: 'tts',
                        config: {
                            language: {
                                sourceLanguage: this.langCode,
                            },
                            serviceId: serviceId,
                            gender: gender,
                            speed: 1,
                            samplingRate: 16000,
                        },
                    },
                ],
                inputData: {
                    input: [
                        {
                            source: chunk,
                        },
                    ],
                },
            };
            try {
                // Use RxJS to handle cancellation
                const response = yield this.http
                    .post(this.urlTTS, payload, { headers })
                    .pipe(takeUntil(this.cancelRequests$))
                    .toPromise();
                if (response) {
                    const audioContent = response.pipelineResponse[0].audio[0].audioContent;
                    const base64Audio = audioContent;
                    const audioUrl = 'data:audio/mp3;base64,' + base64Audio;
                    this.audioQueue.push(audioUrl);
                    if (!this.playerState.isPlaying) {
                        this.playNextAudio();
                    }
                }
            }
            catch (error) {
                this.loading = false;
                this.toastrService.show('Something Went Wrong', 'error');
            }
        });
    }
    cancelRequests() {
        this.cancelRequests$.next();
        this.cancelRequests$.complete();
        this.cancelRequests$ = new Subject();
    }
    playNextAudio() {
        if (this.audioQueue.length > 0 && !this.isStreamIntrupted) {
            this.loading = false;
            const audioUrl = this.audioQueue[this.counter++];
            this.audio = new Audio(audioUrl);
            this.audio.controls = true;
            this.audio.playbackRate = this.playbackRate;
            this.playerState.isPlaying = true;
            this.audio.play();
            this.audio.addEventListener('ended', () => {
                this.playerState.isPlaying = false;
                this.playNextAudio();
            });
        }
        else {
            this.playerState.isPlaying = false;
        }
    }
    chunkText(text, chunkSize) {
        const chunks = [];
        if (!text)
            return chunks;
        let startIndex = 0;
        while (startIndex < text.length) {
            let endIndex = Math.min(startIndex + chunkSize, text.length);
            // Ensure we don't split a word
            if (endIndex < text.length && text[endIndex] !== ' ') {
                while (endIndex > startIndex && text[endIndex] !== ' ') {
                    endIndex--;
                }
                // If no space was found, set endIndex to chunkSize
                if (endIndex === startIndex) {
                    endIndex = Math.min(startIndex + chunkSize, text.length);
                }
            }
            chunks.push(text.substring(startIndex, endIndex).trim());
            startIndex = endIndex + 1; // Move past the space
        }
        return chunks;
    }
    viewerEvent(event) {
        if (event.type === this.fromConst.EPUBLOADED) {
            this.onEpubLoaded(event);
        }
        if (event.type === this.fromConst.PAGECHANGE) {
            this.onPageChange(event);
        }
        if (event.type === this.fromConst.END) {
            this.onEpubEnded(event);
        }
        if (event.type === this.fromConst.ERROR) {
            this.onEpubLoadFailed(event);
        }
        if (event.type === this.fromConst.NAVIGATE_TO_PAGE) {
            this.onJumpToPage(event);
        }
        if (event.type === this.fromConst.INVALID_PAGE_ERROR) {
            this.validPage = event.data;
            this.resetValidPage();
        }
    }
    resetValidPage() {
        setTimeout(() => {
            this.validPage = true;
        }, 5000);
    }
    onEpubLoaded(event) {
        var _a, _b, _c;
        clearInterval(this.intervalRef);
        this.viewState = this.fromConst.START;
        this.viwerService.raiseStartEvent(event.data);
        if (((_b = (_a = this.playerConfig.config) === null || _a === void 0 ? void 0 : _a.pagesVisited) === null || _b === void 0 ? void 0 : _b.length) && ((_c = this.playerConfig.config) === null || _c === void 0 ? void 0 : _c.currentLocation)) {
            this.currentPageIndex = this.playerConfig.config.pagesVisited[this.playerConfig.config.pagesVisited.length - 1];
        }
        this.viwerService.metaData.pagesVisited.push(this.currentPageIndex);
    }
    onPageChange(event) {
        var _a;
        if ((_a = event === null || event === void 0 ? void 0 : event.data) === null || _a === void 0 ? void 0 : _a.index) {
            this.currentPageIndex = event.data.index;
        }
        this.currentPageIndex = this.utilService.getCurrentIndex(event, this.currentPageIndex);
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.INTERACT);
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.IMPRESSION);
        this.viwerService.metaData.pagesVisited.push(this.currentPageIndex);
    }
    onJumpToPage(type) {
        var _a;
        this.currentPageIndex = (_a = type === null || type === void 0 ? void 0 : type.event) === null || _a === void 0 ? void 0 : _a.data;
        this.viwerService.raiseHeartBeatEvent(type, telemetryType.INTERACT);
        this.viwerService.raiseHeartBeatEvent(type, telemetryType.IMPRESSION);
        this.viwerService.metaData.pagesVisited.push(this.currentPageIndex);
    }
    onEpubEnded(event) {
        this.handleButtonstop();
        this.viewState = this.fromConst.END;
        this.showEpubViewer = false;
        event.data.index = this.currentPageIndex;
        this.viwerService.raiseEndEvent(event);
    }
    onEpubLoadFailed(error) {
        this.showContentError = true;
        this.viewState = this.fromConst.LOADING;
        // tslint:disable-next-line:max-line-length
        this.viwerService.raiseExceptionLog(error.errorCode, this.currentPageIndex, error.errorMessage, this.traceId, new Error(error.errorMessage));
    }
    replayContent(event) {
        this.currentPageIndex = 1;
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.INTERACT);
        this.viewState = this.fromConst.START;
        this.viwerService.metaData.pagesVisited.push(this.currentPageIndex);
        this.ngOnInit();
    }
    exitContent(event) {
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.INTERACT);
    }
    sideBarEvents(event) {
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.INTERACT);
        if (event.type === 'DOWNLOAD') {
            this.downloadEpub();
        }
    }
    sidebarMenuEvent(event) {
        this.viwerService.raiseHeartBeatEvent(event, telemetryType.INTERACT);
    }
    getEpubLoadingProgress() {
        this.intervalRef = setInterval(() => {
            if (this.progress < 95) {
                this.progress = this.progress + 5;
            }
        }, 10);
    }
    downloadEpub() {
        const a = document.createElement('a');
        a.href = this.viwerService.artifactUrl;
        a.download = this.viwerService.contentName;
        a.target = '_blank';
        document.body.appendChild(a);
        a.click();
        a.remove();
        this.viwerService.raiseHeartBeatEvent('DOWNLOAD');
    }
    ngOnDestroy() {
        this.handleButtonstop();
        const EndEvent = {
            type: this.fromConst.END,
            data: {
                index: this.currentPageIndex
            }
        };
        this.viwerService.raiseEndEvent(EndEvent);
        this.viwerService.isEndEventRaised = false;
        this.unlistenMouseEnter();
        this.unlistenMouseLeave();
    }
    // Function to play next content
    playNextContent(event) {
        this.viwerService.raiseHeartBeatEventNew(event === null || event === void 0 ? void 0 : event.type, telemetryType.INTERACT, pageId.endPage, event === null || event === void 0 ? void 0 : event.identifier);
    }
}
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
EpubPlayerComponent.decorators = [
    { type: Component, args: [{
                // tslint:disable-next-line:component-selector
                selector: 'sunbird-epub-player',
                template: "<div class=\"sunbird-epub-container\" #epubPlayer>\r\n<div *ngIf=\"viewState === fromConst.LOADING\">\r\n    <sb-player-start-page [title]=\"viwerService.contentName\" [progress]=\"progress\"></sb-player-start-page>\r\n</div>\r\n<div class=\"epub-container\" *ngIf=\"showEpubViewer\">\r\n    <ng-container *ngIf=\"viewState === fromConst.START\">\r\n        <sb-player-header class=\"notVisible\" [playerState]=\"playerState\" [mimeType]=\"mimeType\" (buttonclick)=\"handleButtonClick($event)\" (buttonstop)=\"handleButtonstop()\" (buttonPause)=\"handleButtonpause()\" (buttonPlay)=\"handleButtonplay()\" (notify)=\"handleNotification()\" (changePlaybackrate)=\"onPlaybackRateChange($event)\" [totalPages]=\"viwerService?.totalNumberOfPages\"   [pageNumber]=\"currentPageIndex\" [config]=\"headerConfiguration\" (actions)=\"headerActions($event)\" [ngClass]=\"{'isVisible': showControls}\"></sb-player-header>\r\n        <sb-player-side-menu-icon class=\"notVisible\" [ngClass]=\"{'isVisible': showControls}\" (sidebarMenuEvent)=\"sidebarMenuEvent($event)\">\r\n        </sb-player-side-menu-icon>\r\n        <sb-player-sidebar [title]=\"viwerService.contentName\" (sidebarEvent)=\"sideBarEvents($event)\"\r\n            [config]=\"sideMenuConfig\"></sb-player-sidebar>\r\n        <div class=\"sb-epub-reading-status\" *ngIf=\"currentPageIndex && viwerService?.totalNumberOfPages\">\r\n            Page {{currentPageIndex}} of {{viwerService?.totalNumberOfPages}} <span></span> {{((currentPageIndex/viwerService?.totalNumberOfPages) * 100).toFixed(0)}}%\r\n        </div>\r\n        \r\n    </ng-container>\r\n    <epub-viewer  [actions]=\"headerActionsEvent\" [epubSrc]=\"viwerService.src\" [identifier]=\"viwerService.identifier\"\r\n        (viewerEvent)=\"viewerEvent($event)\" [config]=\"playerConfig.config\" [showFullScreen]=\"showFullScreen\">\r\n    </epub-viewer>\r\n</div>\r\n<sb-player-end-page *ngIf=\"viewState === fromConst.END\" [contentName]=\"viwerService.contentName\"\r\n    [outcomeLabel]=\"'Pages read: '\" [outcome]=\"(currentPageIndex -1)\" [showExit]=\"sideMenuConfig.showExit\" [userName]=\"viwerService.userName\"\r\n    [timeSpentLabel]=\"viwerService.timeSpent\" (replayContent)=\"replayContent($event)\" (exitContent)=\"exitContent($event)\" [nextContent]=\"nextContent\" (playNextContent)=\"playNextContent($event)\">\r\n</sb-player-end-page>\r\n<sb-player-contenterror *ngIf=\"showContentError\"></sb-player-contenterror>\r\n</div>\r\n<div class=\"pagenotfound__tooltip\" *ngIf=\"!validPage\">\r\n    <div class=\"pagenotfound__icon\"></div>\r\n    <div class=\"pagenotfound__text\">Page Not Found</div>\r\n</div>\r\n\r\n<toastr></toastr>",
                styles: [".sunbird-epub-container{height:100%;width:100%;background-color:#fff}.sunbird-epub-palyer-container{width:100%;height:100%;overflow:hidden;position:relative}.sb-epub-reading-status{color:var(--gray-800);font-size:.75rem;position:absolute;left:1rem;bottom:.75rem;display:flex;align-items:center;background:var(--white);border-radius:.5rem;padding:.25em .5rem;z-index:5;line-height:normal}.sb-epub-reading-status span{background:var(--gray-800);width:4px;height:4px;display:block;margin:0 .5em;border-radius:50%}.notVisible,.BtmNotVisible{transition:all .3s ease-in-out;position:absolute;width:100%}.notVisible{top:-10rem}.notVisible.isVisible{top:0rem}.BtmNotVisible{bottom:-10rem}.BtmNotVisible.isVisible{bottom:0rem}:host::ng-deep .sb-player-splash-container{height:100vh!important}:host::ng-deep epub-viewer{position:absolute;top:48px;width:100%;height:calc(100% - 48px);overflow-y:auto;overflow-x:hidden;left:0;background-color:#fff}:host::ng-deep .epub-container{height:100%;position:relative;overflow-x:hidden!important}.pagenotfound__tooltip{position:absolute;top:10%;left:50%;transform:translate(-50%);background:#333;z-index:11111;padding:calculateRem(8px) calculateRem(20px);font-size:calculateRem(14px);color:#fff;border-radius:calculateRem(4px);display:flex;align-items:center}.pagenotfound__icon{width:calculateRem(22px);height:calculateRem(22px);margin-right:calculateRem(12px);background:white;border-radius:50%;position:relative}.pagenotfound__icon:after{content:\"!\";position:absolute;top:50%;left:50%;color:#333;font-size:18px;transform:translate(-50%,-50%)}\n"]
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
EpubPlayerComponent.ctorParameters = () => [
    { type: ViwerService },
    { type: EpubPlayerService },
    { type: ErrorService },
    { type: UtilService },
    { type: Renderer2 },
    { type: HttpClient },
    { type: ToastrService }
];
/** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
EpubPlayerComponent.propDecorators = {
    epubPlayerRef: [{ type: ViewChild, args: ['epubPlayer', { static: true },] }],
    playerConfig: [{ type: Input }],
    showFullScreen: [{ type: Input }],
    headerActionsEvent: [{ type: Output }],
    telemetryEvent: [{ type: Output }],
    playerEvent: [{ type: Output }],
    onTelemetryEvent: [{ type: HostListener, args: ['document:TelemetryEvent', ['$event'],] }],
    ngOnDestroy: [{ type: HostListener, args: ['window:beforeunload',] }]
};

const MAX_TIME_TO_LOAD_SPINE = 5 * 60 * 1000; // 5 minutes
class EpubViewerComponent {
    constructor(viwerService, utilService) {
        this.viwerService = viwerService;
        this.utilService = utilService;
        this.actions = new EventEmitter();
        this.showFullScreen = false;
        this.viewerEvent = new EventEmitter();
    }
    ngOnInit() {
        this.idForRendition = `${this.identifier}-content`;
    }
    ngOnChanges(changes) {
        var _a;
        if (this.rendition && !((_a = changes === null || changes === void 0 ? void 0 : changes.showFullScreen) === null || _a === void 0 ? void 0 : _a.firstChange)) {
            this.rendition.resize();
        }
    }
    ngAfterViewInit() {
        return __awaiter(this, void 0, void 0, function* () {
            try {
                if (!this.viwerService.isAvailableLocally) {
                    this.epubBlob = yield this.viwerService.isValidEpubSrc(this.epubSrc);
                    this.eBook = Epub(this.epubBlob);
                }
                else if (this.viwerService.isAvailableLocally) {
                    this.eBook = Epub(this.epubSrc);
                }
                this.rendition = this.eBook.renderTo(this.idForRendition, {
                    flow: 'paginated',
                    width: '100%',
                });
                this.rendition.on('layout', (layout) => {
                    var _a, _b;
                    this.viwerService.totalNumberOfPages = (_b = (_a = this.eBook) === null || _a === void 0 ? void 0 : _a.navigation) === null || _b === void 0 ? void 0 : _b.length;
                    if (this.eBook.navigation.length > 2) {
                        this.rendition.spread('none');
                        this.rendition.flow('scrolled');
                        this.scrolled = true;
                    }
                    else {
                        this.rendition.spread('auto');
                        this.scrolled = false;
                    }
                });
                this.rendition.on('displayError', (error) => {
                    this.emitErrorEvent();
                });
                const spine = yield this.utilService.fulfillWithTimeLimit(MAX_TIME_TO_LOAD_SPINE, this.eBook.loaded.spine, null);
                if (spine) {
                    this.displayEpub();
                    this.lastSection = spine.last();
                    this.viewerEvent.emit({
                        type: epubPlayerConstants.EPUBLOADED,
                        data: spine
                    });
                    this.handleActions(spine);
                }
                else {
                    this.emitErrorEvent();
                }
            }
            catch (error) {
                this.emitErrorEvent();
            }
        });
    }
    displayEpub() {
        const { currentLocation } = this.config;
        if (!currentLocation) {
            this.rendition.display();
        }
        this.eBook.ready.then(() => {
            return this.eBook.locations.generate(1000);
        }).then((locations) => {
            var _a, _b;
            const totalPages = (_b = (_a = this.eBook) === null || _a === void 0 ? void 0 : _a.spine) === null || _b === void 0 ? void 0 : _b.length;
            this.viwerService.totalNumberOfPages = totalPages ? (totalPages - 1) : 0;
            if (currentLocation) {
                const cfi = this.eBook.locations.cfiFromPercentage(Number(currentLocation));
                this.rendition.display(cfi);
            }
        });
    }
    handleActions(spine) {
        this.actions.subscribe((event) => {
            var _a, _b;
            const type = event.type;
            if ((_b = (_a = this.rendition) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.start) {
                const data = this.rendition.location.start;
                if (this.scrolled && data.href === this.lastSection.href) {
                    this.viwerService.metaData.currentLocation = 0;
                    this.emitEndEvent();
                }
                else {
                    if (this.rendition.location.atEnd || (spine.length === 1 &&
                        (this.rendition.location.end.displayed.page + 1 >= this.rendition.location.end.displayed.total))) {
                        this.viwerService.metaData.currentLocation = 0;
                        this.emitEndEvent();
                    }
                }
                if (type === epubPlayerConstants.NEXT) {
                    this.rendition.next().then(() => {
                        this.saveCurrentLocation();
                        this.viewerEvent.emit({
                            type: epubPlayerConstants.PAGECHANGE,
                            data,
                            interaction: epubPlayerConstants.NEXT
                        });
                    });
                }
                else if (type === epubPlayerConstants.PREVIOUS) {
                    this.rendition.prev().then(() => {
                        this.saveCurrentLocation();
                        this.viewerEvent.emit({
                            type: epubPlayerConstants.PAGECHANGE,
                            data,
                            interaction: epubPlayerConstants.PREVIOUS
                        });
                    });
                }
                if (type === epubPlayerConstants.NAVIGATE_TO_PAGE) {
                    this.rendition.display(event.data);
                    this.viewerEvent.emit({
                        type: epubPlayerConstants.NAVIGATE_TO_PAGE,
                        event,
                        interaction: epubPlayerConstants.NAVIGATE_TO_PAGE
                    });
                }
                if (type === epubPlayerConstants.INVALID_PAGE_ERROR) {
                    this.viewerEvent.emit({
                        type: epubPlayerConstants.INVALID_PAGE_ERROR,
                        event,
                        interaction: epubPlayerConstants.INVALID_PAGE_ERROR
                    });
                }
            }
        });
    }
    saveCurrentLocation() {
        var _a;
        const currentLocation = this.rendition.currentLocation();
        if ((_a = currentLocation === null || currentLocation === void 0 ? void 0 : currentLocation.start) === null || _a === void 0 ? void 0 : _a.cfi) {
            // Get the Percentage (or location) from that CFI
            const currentPageLocation = this.eBook.locations.percentageFromCfi(currentLocation.start.cfi);
            this.viwerService.metaData.currentLocation = currentPageLocation;
        }
    }
    emitEndEvent() {
        this.viewerEvent.emit({
            type: epubPlayerConstants.END,
            data: {
                percentage: 100
            }
        });
    }
    emitErrorEvent() {
        this.viewerEvent.emit({
            type: epubPlayerConstants.ERROR,
            errorCode: errorCode.contentLoadFails,
            errorMessage: errorMessage.contentLoadFails
        });
    }
    ngOnDestroy() {
        var _a;
        (_a = this.eBook) === null || _a === void 0 ? void 0 : _a.destroy();
    }
}
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
EpubViewerComponent.decorators = [
    { type: Component, args: [{
                // tslint:disable-next-line:component-selector
                selector: 'epub-viewer',
                template: "<div class=\"rendition\" [id]=\"idForRendition\" #epubViewer></div>",
                styles: [""]
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
EpubViewerComponent.ctorParameters = () => [
    { type: ViwerService },
    { type: UtilService }
];
/** @type {!Object<string, !Array<{type: !Function, args: (undefined|!Array<?>)}>>} */
EpubViewerComponent.propDecorators = {
    epubViewer: [{ type: ViewChild, args: ['epubViewer', { static: true },] }],
    epubSrc: [{ type: Input }],
    config: [{ type: Input }],
    identifier: [{ type: Input }],
    actions: [{ type: Input }],
    showFullScreen: [{ type: Input }],
    viewerEvent: [{ type: Output }]
};

class ToastrComponent {
    constructor(toastrService) {
        this.toastrService = toastrService;
        this.toastr = [];
    }
    ngOnInit() {
        console.log("ngoninit called");
        this.toastSubscription = this.toastrService.toastState$.subscribe(toast => {
            this.toastr.push(toast);
            console.log(this.toastr, "this is toast");
            setTimeout(() => {
                this.toastr.shift();
            }, 3000);
        });
    }
    ngOnDestroy() {
        if (this.toastSubscription) {
            this.toastSubscription.unsubscribe();
        }
    }
}
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
ToastrComponent.decorators = [
    { type: Component, args: [{
                selector: 'toastr',
                template: "<div class=\"toast-container\">\n    <div *ngFor=\"let toast of toastr\" class=\"toast\" [ngClass]=\"toast.type\">\n      {{ toast.message }}\n    </div>\n</div>\n",
                styles: [".toast-container{position:absolute;top:53px;right:6px;z-index:99999}.toast{padding:15px 20px;margin-bottom:10px;border-radius:4px;color:#fff;font-weight:bold;opacity:.9;transition:opacity .5s ease-out}.toast.info{background-color:#2196f3}.toast.success{background-color:#4caf50}.toast.error{background-color:#dc281a}\n"]
            },] }
];
/**
 * @type {function(): !Array<(null|{
 *   type: ?,
 *   decorators: (undefined|!Array<{type: !Function, args: (undefined|!Array<?>)}>),
 * })>}
 * @nocollapse
 */
ToastrComponent.ctorParameters = () => [
    { type: ToastrService }
];

class SunbirdEpubPlayerModule {
}
/** @type {!Array<{type: !Function, args: (undefined|!Array<?>)}>} */
SunbirdEpubPlayerModule.decorators = [
    { type: NgModule, args: [{
                declarations: [EpubPlayerComponent, EpubViewerComponent, ToastrComponent],
                imports: [
                    CommonModule,
                    SunbirdPlayerSdkModule,
                    HttpClientModule
                ],
                schemas: [
                    CUSTOM_ELEMENTS_SCHEMA
                ],
                exports: [EpubPlayerComponent]
            },] }
];

/*
 * Public API Surface of epub-player
 */

/**
 * Generated bundle index. Do not edit.
 */

export { EpubPlayerComponent, EpubPlayerService, SunbirdEpubPlayerModule, UtilService as ɵa, ViwerService as ɵb, ToastrService as ɵc, EpubViewerComponent as ɵd, ToastrComponent as ɵe };
//# sourceMappingURL=dicdikshaorg-epub-player-v9.js.map